From 8dc5855332ce863e7cd9f36b3c37665c10cea68d Mon Sep 17 00:00:00 2001 From: Jon Lin Date: Wed, 20 Dec 2023 09:38:30 +0800 Subject: [PATCH] PCI: rockchip: dw: Add dev mutex to protect elbi0 irq user Change-Id: I9dad204d1d714ecbfa9ac0872123e0001499b981 Signed-off-by: Jon Lin --- drivers/misc/rockchip/pcie-rkep.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/misc/rockchip/pcie-rkep.c b/drivers/misc/rockchip/pcie-rkep.c index 467dcc48534d..7f5ba5a9fcc5 100644 --- a/drivers/misc/rockchip/pcie-rkep.c +++ b/drivers/misc/rockchip/pcie-rkep.c @@ -119,7 +119,7 @@ struct pcie_rkep { struct dma_trx_obj *dma_obj; struct pcie_ep_obj_info *obj_info; struct page *user_pages; /* Allocated physical memory for user space */ - struct mutex dev_lock_mutex; + struct mutex dev_lock_mutex; /* Sync resources in multi-process, such as vid and ELBI0 */ DECLARE_BITMAP(virtual_id_bitmap, RKEP_EP_VIRTUAL_ID_MAX); DECLARE_BITMAP(virtual_id_irq_bitmap, RKEP_EP_VIRTUAL_ID_MAX); wait_queue_head_t wq_head; @@ -220,10 +220,9 @@ static int rkep_ep_raise_elbi_irq(struct pcie_file *pcie_file, u32 interrupt_num if (i >= gap_us) dev_err(&pcie_rkep->pdev->dev, "elbi int is not clear, status=%x\n", val); - mutex_lock(&pcie_file->file_lock_mutex); ret = pci_write_config_dword(pcie_rkep->pdev, PCIE_CFG_ELBI_APP_OFFSET + 4 * index, (1 << (off + 16)) | (1 << off)); - mutex_unlock(&pcie_file->file_lock_mutex); + return ret; } @@ -240,7 +239,9 @@ static int rkep_ep_raise_irq_user_obj(struct pcie_file *pcie_file, u32 index) pcie_rkep->obj_info->irq_type_ep = OBJ_IRQ_USER; pcie_rkep->obj_info->irq_user_data_ep = index; + mutex_lock(&pcie_rkep->dev_lock_mutex); ret = rkep_ep_raise_elbi_irq(pcie_file, 0); + mutex_unlock(&pcie_rkep->dev_lock_mutex); return ret; }