From: Jonathan Cameron <Jonathan.Cameron@Huawei.com>
To: Jean-Philippe Brucker <jean-philippe@linaro.org>
Cc: <joro@8bytes.org>, <will@kernel.org>, <lorenzo.pieralisi@arm.com>,
<robh+dt@kernel.org>, <guohanjun@huawei.com>,
<sudeep.holla@arm.com>, <rjw@rjwysocki.net>, <lenb@kernel.org>,
<robin.murphy@arm.com>, <eric.auger@redhat.com>,
<iommu@lists.linux-foundation.org>, <devicetree@vger.kernel.org>,
<linux-acpi@vger.kernel.org>,
<linux-arm-kernel@lists.infradead.org>,
<linux-accelerators@lists.ozlabs.org>, <baolu.lu@linux.intel.com>,
<jacob.jun.pan@linux.intel.com>, <kevin.tian@intel.com>,
<vdumpa@nvidia.com>, <zhangfei.gao@linaro.org>,
<shameerali.kolothum.thodi@huawei.com>, <vivek.gautam@arm.com>
Subject: Re: [PATCH v10 10/10] iommu/arm-smmu-v3: Add stall support for platform devices
Date: Thu, 21 Jan 2021 19:12:36 +0000 [thread overview]
Message-ID: <20210121191236.00000103@Huawei.com> (raw)
In-Reply-To: <20210121123623.2060416-11-jean-philippe@linaro.org>
On Thu, 21 Jan 2021 13:36:24 +0100
Jean-Philippe Brucker <jean-philippe@linaro.org> wrote:
> The SMMU provides a Stall model for handling page faults in platform
> devices. It is similar to PCIe PRI, but doesn't require devices to have
> their own translation cache. Instead, faulting transactions are parked
> and the OS is given a chance to fix the page tables and retry the
> transaction.
>
> Enable stall for devices that support it (opt-in by firmware). When an
> event corresponds to a translation error, call the IOMMU fault handler.
> If the fault is recoverable, it will call us back to terminate or
> continue the stall.
>
> To use stall device drivers need to enable IOMMU_DEV_FEAT_IOPF, which
> initializes the fault queue for the device.
>
> Tested-by: Zhangfei Gao <zhangfei.gao@linaro.org>
> Signed-off-by: Jean-Philippe Brucker <jean-philippe@linaro.org>
One thing inline + one comment which was mostly a case of I ran
out of time to walk through why probe and release aren't symmetric...
> ---
> drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h | 43 ++++
> .../iommu/arm/arm-smmu-v3/arm-smmu-v3-sva.c | 59 +++++-
> drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 185 +++++++++++++++++-
> 3 files changed, 273 insertions(+), 14 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 db5d6aa76c3a..af6982aca42e 100644
> --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
> +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
> @@ -32,6 +32,7 @@
...
>
> master->domain = smmu_domain;
> @@ -2484,6 +2624,11 @@ static struct iommu_device *arm_smmu_probe_device(struct device *dev)
> master->ssid_bits = min_t(u8, master->ssid_bits,
> CTXDESC_LINEAR_CDMAX);
>
> + if ((smmu->features & ARM_SMMU_FEAT_STALLS &&
> + device_property_read_bool(dev, "dma-can-stall")) ||
> + smmu->features & ARM_SMMU_FEAT_STALL_FORCE)
> + master->stall_enabled = true;
> +
> return &smmu->iommu;
>
> err_free_master:
> @@ -2502,6 +2647,7 @@ static void arm_smmu_release_device(struct device *dev)
>
> master = dev_iommu_priv_get(dev);
> WARN_ON(arm_smmu_master_sva_enabled(master));
> + iopf_queue_remove_device(master->smmu->evtq.iopf, dev);
> arm_smmu_detach_dev(master);
> arm_smmu_disable_pasid(master);
> arm_smmu_remove_master(master);
The lack of symmetry here bothers me a bit, but it's already true, so I guess
this case is fine as well.
...
>
> @@ -2785,6 +2946,7 @@ static int arm_smmu_cmdq_init(struct arm_smmu_device *smmu)
> static int arm_smmu_init_queues(struct arm_smmu_device *smmu)
> {
> int ret;
> + bool sva = smmu->features & ARM_SMMU_FEAT_STALLS;
FEAT_SVA?
>
> /* cmdq */
> ret = arm_smmu_init_one_queue(smmu, &smmu->cmdq.q, ARM_SMMU_CMDQ_PROD,
> @@ -2804,6 +2966,12 @@ static int arm_smmu_init_queues(struct arm_smmu_device *smmu)
> if (ret)
> return ret;
>
> + if (sva && smmu->features & ARM_SMMU_FEAT_STALLS) {
Isn't this checking same thing twice?
> + smmu->evtq.iopf = iopf_queue_alloc(dev_name(smmu->dev));
> + if (!smmu->evtq.iopf)
> + return -ENOMEM;
> + }
> +
> /* priq */
> if (!(smmu->features & ARM_SMMU_FEAT_PRI))
> return 0;
> @@ -3718,6 +3886,7 @@ static int arm_smmu_device_remove(struct platform_device *pdev)
> iommu_device_unregister(&smmu->iommu);
> iommu_device_sysfs_remove(&smmu->iommu);
> arm_smmu_device_disable(smmu);
> + iopf_queue_free(smmu->evtq.iopf);
>
> return 0;
> }
next prev parent reply other threads:[~2021-01-21 19:15 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-21 12:36 [PATCH v10 00/10] iommu: I/O page faults for SMMUv3 Jean-Philippe Brucker
2021-01-21 12:36 ` [PATCH v10 01/10] iommu: Fix comment for struct iommu_fwspec Jean-Philippe Brucker
2021-01-21 12:36 ` [PATCH v10 02/10] iommu/arm-smmu-v3: Use device properties for pasid-num-bits Jean-Philippe Brucker
2021-01-21 12:36 ` [PATCH v10 03/10] iommu: Separate IOMMU_DEV_FEAT_IOPF from IOMMU_DEV_FEAT_SVA Jean-Philippe Brucker
2021-01-21 12:36 ` [PATCH v10 04/10] iommu/vt-d: Support IOMMU_DEV_FEAT_IOPF Jean-Philippe Brucker
2021-01-22 1:54 ` Lu Baolu
2021-01-21 12:36 ` [PATCH v10 05/10] uacce: Enable IOMMU_DEV_FEAT_IOPF Jean-Philippe Brucker
2021-01-21 12:36 ` [PATCH v10 06/10] iommu: Add a page fault handler Jean-Philippe Brucker
2021-01-21 12:36 ` [PATCH v10 07/10] iommu/arm-smmu-v3: Maintain a SID->device structure Jean-Philippe Brucker
2021-01-22 10:35 ` Auger Eric
2021-01-21 12:36 ` [PATCH v10 08/10] dt-bindings: document stall property for IOMMU masters Jean-Philippe Brucker
2021-01-21 12:36 ` [PATCH v10 09/10] ACPI/IORT: Enable stall support for platform devices Jean-Philippe Brucker
2021-01-21 18:57 ` Jonathan Cameron
2021-01-21 12:36 ` [PATCH v10 10/10] iommu/arm-smmu-v3: Add " Jean-Philippe Brucker
2021-01-21 19:12 ` Jonathan Cameron [this message]
2021-01-22 8:51 ` Jean-Philippe Brucker
2021-01-22 10:58 ` Jonathan Cameron
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=20210121191236.00000103@Huawei.com \
--to=jonathan.cameron@huawei.com \
--cc=baolu.lu@linux.intel.com \
--cc=devicetree@vger.kernel.org \
--cc=eric.auger@redhat.com \
--cc=guohanjun@huawei.com \
--cc=iommu@lists.linux-foundation.org \
--cc=jacob.jun.pan@linux.intel.com \
--cc=jean-philippe@linaro.org \
--cc=joro@8bytes.org \
--cc=kevin.tian@intel.com \
--cc=lenb@kernel.org \
--cc=linux-accelerators@lists.ozlabs.org \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=lorenzo.pieralisi@arm.com \
--cc=rjw@rjwysocki.net \
--cc=robh+dt@kernel.org \
--cc=robin.murphy@arm.com \
--cc=shameerali.kolothum.thodi@huawei.com \
--cc=sudeep.holla@arm.com \
--cc=vdumpa@nvidia.com \
--cc=vivek.gautam@arm.com \
--cc=will@kernel.org \
--cc=zhangfei.gao@linaro.org \
/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: link
Be 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).