cndm: Add mutex for the command mailbox

Signed-off-by: Alex Forencich <alex@alexforencich.com>
This commit is contained in:
Alex Forencich
2026-03-02 15:30:43 -08:00
parent 0f09b8bdaa
commit 14d35dd75f
3 changed files with 9 additions and 0 deletions

View File

@@ -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;

View File

@@ -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;
}

View File

@@ -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