mirror of
https://github.com/fpganinja/taxi.git
synced 2026-04-07 04:38:42 -07:00
cndm: Add mutex for the command mailbox
Signed-off-by: Alex Forencich <alex@alexforencich.com>
This commit is contained in:
@@ -51,6 +51,8 @@ struct cndm_dev {
|
||||
phys_addr_t hw_regs_phys;
|
||||
void __iomem *hw_addr;
|
||||
|
||||
struct mutex mbox_lock;
|
||||
|
||||
u32 port_count;
|
||||
u32 port_offset;
|
||||
u32 port_stride;
|
||||
|
||||
@@ -17,6 +17,8 @@ int cndm_exec_mbox_cmd(struct cndm_dev *cdev, void *cmd, void *rsp)
|
||||
if (!cmd || !rsp)
|
||||
return -EINVAL;
|
||||
|
||||
mutex_lock(&cdev->mbox_lock);
|
||||
|
||||
// write command to mailbox
|
||||
for (k = 0; k < 16; k++) {
|
||||
iowrite32(*((u32 *)(cmd + k*4)), cdev->hw_addr + 0x10000 + k*4);
|
||||
@@ -38,6 +40,9 @@ int cndm_exec_mbox_cmd(struct cndm_dev *cdev, void *cmd, void *rsp)
|
||||
for (k = 0; k < 16; k++) {
|
||||
*((u32 *)(rsp + k*4)) = ioread32(cdev->hw_addr + 0x10000 + 0x40 + k*4);
|
||||
}
|
||||
|
||||
mutex_unlock(&cdev->mbox_lock);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -47,6 +47,8 @@ static int cndm_common_probe(struct cndm_dev *cdev)
|
||||
int ret = 0;
|
||||
int k;
|
||||
|
||||
mutex_init(&cdev->mbox_lock);
|
||||
|
||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 15, 0)
|
||||
devlink_register(devlink);
|
||||
#else
|
||||
|
||||
Reference in New Issue
Block a user