LKML Archive on lore.kernel.org help / color / mirror / Atom feed
From: Nicolin Chen <nicolinc@nvidia.com> To: <will@kernel.org>, <robin.murphy@arm.com>, <joro@8bytes.org>, <alex.williamson@redhat.com>, <cohuck@redhat.com>, <corbet@lwn.net> Cc: <nicoleotsuka@gmail.com>, <vdumpa@nvidia.com>, <thierry.reding@gmail.com>, <linux-tegra@vger.kernel.org>, <nwatterson@nvidia.com>, <Jonathan.Cameron@huawei.com>, <jean-philippe@linaro.org>, <song.bao.hua@hisilicon.com>, <eric.auger@redhat.com>, <thunder.leizhen@huawei.com>, <yuzenghui@huawei.com>, <linux-kernel@vger.kernel.org>, <linux-arm-kernel@lists.infradead.org>, <iommu@lists.linux-foundation.org>, <kvm@vger.kernel.org>, <linux-doc@vger.kernel.org> Subject: [RFC][PATCH v2 10/13] iommu/arm-smmu-v3: Pass cmdq pointer in arm_smmu_cmdq_issue_cmdlist() Date: Mon, 30 Aug 2021 19:59:20 -0700 [thread overview] Message-ID: <20210831025923.15812-11-nicolinc@nvidia.com> (raw) In-Reply-To: <20210831025923.15812-1-nicolinc@nvidia.com> The driver currently calls arm_smmu_get_cmdq() helper internally in different places, though they are all actually called from the same source -- arm_smmu_cmdq_issue_cmdlist() function. This patch changes this to pass the cmdq pointer to these functions instead of calling arm_smmu_get_cmdq() every time. This also helps NVIDIA implementation, which maintains its own cmdq pointers and needs to redirect the cmdq pointer from arm_smmu->cmdq pointer to its own, upon scanning the illegal commands by checking the opcode of the cmdlist. Signed-off-by: Nicolin Chen <nicolinc@nvidia.com> --- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c index 6878a83582b9..216f3442aac4 100644 --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c @@ -584,11 +584,11 @@ static void arm_smmu_cmdq_poll_valid_map(struct arm_smmu_cmdq *cmdq, /* Wait for the command queue to become non-full */ static int arm_smmu_cmdq_poll_until_not_full(struct arm_smmu_device *smmu, + struct arm_smmu_cmdq *cmdq, struct arm_smmu_ll_queue *llq) { unsigned long flags; struct arm_smmu_queue_poll qp; - struct arm_smmu_cmdq *cmdq = arm_smmu_get_cmdq(smmu); int ret = 0; /* @@ -619,11 +619,11 @@ static int arm_smmu_cmdq_poll_until_not_full(struct arm_smmu_device *smmu, * Must be called with the cmdq lock held in some capacity. */ static int __arm_smmu_cmdq_poll_until_msi(struct arm_smmu_device *smmu, + struct arm_smmu_cmdq *cmdq, struct arm_smmu_ll_queue *llq) { int ret = 0; struct arm_smmu_queue_poll qp; - struct arm_smmu_cmdq *cmdq = arm_smmu_get_cmdq(smmu); u32 *cmd = (u32 *)(Q_ENT(&cmdq->q, llq->prod)); queue_poll_init(smmu, &qp); @@ -643,10 +643,10 @@ static int __arm_smmu_cmdq_poll_until_msi(struct arm_smmu_device *smmu, * Must be called with the cmdq lock held in some capacity. */ static int __arm_smmu_cmdq_poll_until_consumed(struct arm_smmu_device *smmu, + struct arm_smmu_cmdq *cmdq, struct arm_smmu_ll_queue *llq) { struct arm_smmu_queue_poll qp; - struct arm_smmu_cmdq *cmdq = arm_smmu_get_cmdq(smmu); u32 prod = llq->prod; int ret = 0; @@ -693,12 +693,13 @@ static int __arm_smmu_cmdq_poll_until_consumed(struct arm_smmu_device *smmu, } static int arm_smmu_cmdq_poll_until_sync(struct arm_smmu_device *smmu, + struct arm_smmu_cmdq *cmdq, struct arm_smmu_ll_queue *llq) { if (smmu->options & ARM_SMMU_OPT_MSIPOLL) - return __arm_smmu_cmdq_poll_until_msi(smmu, llq); + return __arm_smmu_cmdq_poll_until_msi(smmu, cmdq, llq); - return __arm_smmu_cmdq_poll_until_consumed(smmu, llq); + return __arm_smmu_cmdq_poll_until_consumed(smmu, cmdq, llq); } static void arm_smmu_cmdq_write_entries(struct arm_smmu_cmdq *cmdq, u64 *cmds, @@ -755,7 +756,7 @@ static int arm_smmu_cmdq_issue_cmdlist(struct arm_smmu_device *smmu, while (!queue_has_space(&llq, n + sync)) { local_irq_restore(flags); - if (arm_smmu_cmdq_poll_until_not_full(smmu, &llq)) + if (arm_smmu_cmdq_poll_until_not_full(smmu, cmdq, &llq)) dev_err_ratelimited(smmu->dev, "CMDQ timeout\n"); local_irq_save(flags); } @@ -831,7 +832,7 @@ static int arm_smmu_cmdq_issue_cmdlist(struct arm_smmu_device *smmu, /* 5. If we are inserting a CMD_SYNC, we must wait for it to complete */ if (sync) { llq.prod = queue_inc_prod_n(&llq, n); - ret = arm_smmu_cmdq_poll_until_sync(smmu, &llq); + ret = arm_smmu_cmdq_poll_until_sync(smmu, cmdq, &llq); if (ret) { dev_err_ratelimited(smmu->dev, "CMD_SYNC timeout at 0x%08x [hwprod 0x%08x, hwcons 0x%08x]\n", -- 2.17.1
next prev parent reply other threads:[~2021-08-31 3:08 UTC|newest] Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-08-31 2:59 [RFC][PATCH v2 00/13] iommu/arm-smmu-v3: Add NVIDIA implementation Nicolin Chen 2021-08-31 2:59 ` [RFC][PATCH v2 01/13] iommu: Add set_nesting_vmid/get_nesting_vmid functions Nicolin Chen 2021-08-31 2:59 ` [RFC][PATCH v2 02/13] vfio: add VFIO_IOMMU_GET_VMID and VFIO_IOMMU_SET_VMID Nicolin Chen 2021-08-31 2:59 ` [RFC][PATCH v2 03/13] vfio: Document VMID control for IOMMU Virtualization Nicolin Chen 2021-08-31 2:59 ` [RFC][PATCH v2 04/13] vfio: add set_vmid and get_vmid for vfio_iommu_type1 Nicolin Chen 2021-08-31 2:59 ` [RFC][PATCH v2 05/13] vfio/type1: Implement set_vmid and get_vmid Nicolin Chen 2021-08-31 2:59 ` [RFC][PATCH v2 06/13] vfio/type1: Set/get VMID to/from iommu driver Nicolin Chen 2021-08-31 2:59 ` [RFC][PATCH v2 07/13] iommu/arm-smmu-v3: Add shared VMID support for NESTING Nicolin Chen 2021-08-31 2:59 ` [RFC][PATCH v2 08/13] iommu/arm-smmu-v3: Add VMID alloc/free helpers Nicolin Chen 2021-08-31 2:59 ` [RFC][PATCH v2 09/13] iommu/arm-smmu-v3: Pass dev pointer to arm_smmu_detach_dev Nicolin Chen 2021-08-31 2:59 ` Nicolin Chen [this message] 2021-08-31 2:59 ` [RFC][PATCH v2 11/13] iommu/arm-smmu-v3: Add implementation infrastructure Nicolin Chen 2021-08-31 2:59 ` [RFC][PATCH v2 12/13] iommu/arm-smmu-v3: Add support for NVIDIA CMDQ-Virtualization hw Nicolin Chen 2021-08-31 2:59 ` [RFC][PATCH v2 13/13] iommu/nvidia-smmu-v3: Add mdev interface support Nicolin Chen 2021-08-31 16:15 ` [RFC][PATCH v2 00/13] iommu/arm-smmu-v3: Add NVIDIA implementation Alex Williamson 2021-09-01 6:55 ` Tian, Kevin 2021-09-02 14:45 ` Jason Gunthorpe 2021-09-02 22:27 ` Tian, Kevin 2021-09-16 18:21 ` Nicolin Chen
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20210831025923.15812-11-nicolinc@nvidia.com \ --to=nicolinc@nvidia.com \ --cc=Jonathan.Cameron@huawei.com \ --cc=alex.williamson@redhat.com \ --cc=cohuck@redhat.com \ --cc=corbet@lwn.net \ --cc=eric.auger@redhat.com \ --cc=iommu@lists.linux-foundation.org \ --cc=jean-philippe@linaro.org \ --cc=joro@8bytes.org \ --cc=kvm@vger.kernel.org \ --cc=linux-arm-kernel@lists.infradead.org \ --cc=linux-doc@vger.kernel.org \ --cc=linux-kernel@vger.kernel.org \ --cc=linux-tegra@vger.kernel.org \ --cc=nicoleotsuka@gmail.com \ --cc=nwatterson@nvidia.com \ --cc=robin.murphy@arm.com \ --cc=song.bao.hua@hisilicon.com \ --cc=thierry.reding@gmail.com \ --cc=thunder.leizhen@huawei.com \ --cc=vdumpa@nvidia.com \ --cc=will@kernel.org \ --cc=yuzenghui@huawei.com \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).