msm: igt-gpu-tools Reference Manual

## msm msm — msm support library |

## Functions

struct msm_device * | igt_msm_dev_open ()
void | igt_msm_dev_close ()
struct msm_bo * | igt_msm_bo_new ()
void | igt_msm_bo_free ()
void * | igt_msm_bo_map ()
struct msm_pipe * | igt_msm_pipe_open ()
void | igt_msm_pipe_close ()
unsigned | pm4_odd_parity_bit ()
uint32_t | pm4_pkt0_hdr ()
uint32_t | pm4_pkt3_hdr ()
uint32_t | pm4_pkt4_hdr ()
uint32_t | pm4_pkt7_hdr ()
struct msm_cmd * | igt_msm_cmd_new ()
int | igt_msm_cmd_submit ()
void | igt_msm_cmd_free ()
void | msm_cmd_emit ()
void | msm_cmd_pkt7 ()
void | msm_cmd_bo ()
#define | U642VOID()
#define | VOID2U64()

## Types and Values

struct | msm_device
struct | msm_bo
struct | msm_pipe
enum | adreno_pm4_packet_type
enum | adreno_pm4_type3_packets
struct | msm_cmd

## Includes

    #include <igt_msm.h>

## Description

This library provides various auxiliary helper functions for writing msm tests.

## Functions

### igt_msm_dev_open ()

    struct msm_device *
    igt_msm_dev_open (void);

Open the msm drm device.

### igt_msm_dev_close ()

    void
    igt_msm_dev_close (struct msm_device *dev);

Close the msm drm device.

#### Parameters

dev | the device to close |

### igt_msm_bo_new ()

    struct msm_bo *
    igt_msm_bo_new (struct msm_device *dev,
                    size_t size,
                    uint32_t flags);

Allocate a buffer object of the requested size.

#### Parameters

dev | the device to allocate the BO from |
size | the requested BO size in bytes |
flags | bitmask of MSM_BO_x |

### igt_msm_bo_free ()

    void
    igt_msm_bo_free (struct msm_bo *bo);

Free a buffer object

#### Parameters

bo | the BO to free |

### igt_msm_bo_map ()

    void *
    igt_msm_bo_map (struct msm_bo *bo);

Returns a pointer to mmap'd buffer.

#### Parameters

bo | the BO to map |

### igt_msm_pipe_open ()

    struct msm_pipe *
    igt_msm_pipe_open (struct msm_device *dev,
                       uint32_t prio);

Allocate a pipe/submitqueue against which cmdstream may be submitted.

#### Parameters

dev | the device to create a submitqueue/pipe against |
prio | the requested priority, from 0 (highest) to MSM_PARAM_PRIORITIES-1 (lowest) |

### igt_msm_pipe_close ()

    void
    igt_msm_pipe_close (struct msm_pipe *pipe);

Close a pipe

#### Parameters

pipe | the pipe to close |

### pm4_odd_parity_bit ()

    unsigned
    pm4_odd_parity_bit (unsigned  val);

### pm4_pkt0_hdr ()

    uint32_t
    pm4_pkt0_hdr (uint16_t regindx,
                  uint16_t cnt);

### pm4_pkt3_hdr ()

    uint32_t
    pm4_pkt3_hdr (uint8_t opcode,
                  uint16_t cnt);

### pm4_pkt4_hdr ()

    uint32_t
    pm4_pkt4_hdr (uint16_t regindx,
                  uint16_t cnt);

### pm4_pkt7_hdr ()

    uint32_t
    pm4_pkt7_hdr (uint8_t opcode,
                  uint16_t cnt);

### igt_msm_cmd_new ()

    struct msm_cmd *
    igt_msm_cmd_new (struct msm_pipe *pipe,
                     size_t size);

#### Parameters

pipe | the submitqueue to submit cmdstream against |
size | the size of requested cmdstream buffer |

### igt_msm_cmd_submit ()

    int
    igt_msm_cmd_submit (struct msm_cmd *cmd);

Returns dma-fence fd

#### Parameters

cmd | the command stream object to submit |

### igt_msm_cmd_free ()

    void
    igt_msm_cmd_free (struct msm_cmd *cmd);

Free a command stream object

#### Parameters

cmd | the command stream object to free |

### msm_cmd_emit ()

    void
    msm_cmd_emit (struct msm_cmd *cmd,
                  uint32_t dword);

### msm_cmd_pkt7 ()

    void
    msm_cmd_pkt7 (struct msm_cmd *cmd,
                  uint8_t opcode,
                  uint16_t cnt);

### msm_cmd_bo ()

    void
    msm_cmd_bo (struct msm_cmd *cmd,
                struct msm_bo *bo,
                uint32_t offset);

### U642VOID()

    #define U642VOID(x) ((void *)(uintptr_t)(x))

### VOID2U64()

    #define VOID2U64(x) ((uint64_t)(uintptr_t)(x))

## Types and Values

### struct msm_device

    struct msm_device {
    	int fd;
    	unsigned gen;
    };

Helper container for device and device related parameters used by tests.

#### Members

int `fd`; | the drm device file descriptor |

### struct msm_bo

    struct msm_bo {
    	struct msm_device *dev;
    	int handle;
    	uint32_t size;
    	void *map;
    	uint64_t iova;
    };

Helper wrapper for a GEM buffer object.

#### Members

struct msm_device *`dev`; | the device the BO is allocated from |
int `handle`; | the BO's GEM handle |
uint32_t `size`; | the BO's size |
void *`map`; | the BO's memory mapping (if mapped) |
uint64_t `iova`; | the BO's GPU address |

### struct msm_pipe

    struct msm_pipe {
    	struct msm_device *dev;
    	uint32_t pipe;
    	uint32_t submitqueue_id;
    };

Helper wrapper for a submitqueue for cmdstream submission.

#### Members

struct msm_device *`dev`; | the device the pipe is allocated from |
uint32_t `pipe`; | the pipe id |
uint32_t `submitqueue_id`; | the submitqueue id |

### enum adreno_pm4_packet_type

#### Members

CP_TYPE0_PKT |  |
CP_TYPE1_PKT |  |
CP_TYPE2_PKT |  |
CP_TYPE3_PKT |  |
CP_TYPE4_PKT |  |
CP_TYPE7_PKT |  |

### enum adreno_pm4_type3_packets

#### Members

CP_NOP |  |
CP_WAIT_MEM_GTE |  |
CP_WAIT_REG_MEM |  |
CP_MEM_WRITE |  |
CP_MEM_TO_MEM |  |

### struct msm_cmd

    struct msm_cmd {
    	struct msm_pipe *pipe;
    	struct msm_bo *cmdstream_bo;
    	uint32_t *cur;
    	uint32_t nr_bos;
    	struct msm_bo *bos[8];
    };

Helper for building cmdstream and cmdstream submission

#### Members

struct msm_pipe *`pipe`; | the submitqueue to submit cmdstream against |
struct msm_bo *`cmdstream_bo`; | the backing cmdstream buffer object |
uint32_t *`cur`; | pointer to current position in cmdstream |
uint32_t `nr_bos`; |  |
struct msm_bo *`bos`[8]; |  |