From: Baolu Lu <baolu.lu@linux.intel.com>
To: "Tian, Kevin" <kevin.tian@intel.com>,
"iommu@lists.linux.dev" <iommu@lists.linux.dev>,
"dmaengine@vger.kernel.org" <dmaengine@vger.kernel.org>
Cc: baolu.lu@linux.intel.com, Joerg Roedel <joro@8bytes.org>,
Will Deacon <will@kernel.org>,
Robin Murphy <robin.murphy@arm.com>,
"Yu, Fenghua" <fenghua.yu@intel.com>,
"Jiang, Dave" <dave.jiang@intel.com>,
Vinod Koul <vkoul@kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 2/2] iommu/vt-d: Move iopf code from SVA to IOPF enabling path
Date: Tue, 7 Feb 2023 14:30:46 +0800 [thread overview]
Message-ID: <615663e4-59e8-deec-93ab-8d2ebd2f35b7@linux.intel.com> (raw)
In-Reply-To: <BN9PR11MB527659435BA073B21A1291588CDA9@BN9PR11MB5276.namprd11.prod.outlook.com>
On 2023/2/6 11:28, Tian, Kevin wrote:
>> From: Lu Baolu <baolu.lu@linux.intel.com>
>> Sent: Friday, February 3, 2023 4:45 PM
>>
>> Generally enabling IOMMU_DEV_FEAT_SVA requires
>> IOMMU_DEV_FEAT_IOPF, but
>> some devices manage I/O Page Faults themselves instead of relying on the
>> IOMMU. Move IOPF related code from SVA to IOPF enabling path to make
>> the
>> driver work for devices that manage IOPF themselves.
>>
>> For the device drivers that relies on the IOMMU for IOPF through PCI/PRI,
>> IOMMU_DEV_FEAT_IOPF must be enabled before and disabled after
>> IOMMU_DEV_FEAT_SVA.
>
> ARM still handles this differently:
>
> arm_smmu_master_enable_sva()
> arm_smmu_master_sva_enable_iopf():
> {
> /*
> * Drivers for devices supporting PRI or stall should enable IOPF first.
> * Others have device-specific fault handlers and don't need IOPF.
> */
> if (!arm_smmu_master_iopf_supported(master))
> return 0;
>
> if (!master->iopf_enabled)
> return -EINVAL;
> }
>
> i.e. device specific IOPF is allowed only when PRI or stall is not supported.
>
> it's different from what this patch does to allow device specific IOPF even
> when PRI is supported.
>
> should we make them consistent given SVA/IOPF capabilities are general
> iommu definitions or fine to leave each iommu driver with different
> restriction?
Good point! I prefer the former. I will add a check in sva enabling path
and return failure if device supports PRI but not enabled (that
implies device has its specific IOPF handling).
>
>>
>> - ret = iopf_queue_add_device(iommu->iopf_queue, dev);
>> - if (!ret)
>> - ret = iommu_register_device_fault_handler(dev,
>> iommu_queue_iopf, dev);
>> -
>> - return ret;
>> + return 0;
>> }
>
> here and below...
>
>> + ret = iopf_queue_add_device(info->iommu->iopf_queue, dev);
>> + if (ret)
>> + return ret;
>> +
>> + ret = iommu_register_device_fault_handler(dev, iommu_queue_iopf,
>> dev);
>> + if (ret)
>> + iopf_queue_remove_device(info->iommu->iopf_queue, dev);
>> +
>> + return ret;
>> }
>
> ...indicate a bug fix on error handling. better to have the fix as
> a separate patch and then move code.
>
Yes. I will post a fix patch before this move.
Best regards,
baolu
next prev parent reply other threads:[~2023-02-07 6:30 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-03 8:44 [PATCH 1/2] dmaengine: idxd: Add enable/disable device IOPF feature Lu Baolu
2023-02-03 8:44 ` [PATCH 2/2] iommu/vt-d: Move iopf code from SVA to IOPF enabling path Lu Baolu
2023-02-06 3:28 ` Tian, Kevin
2023-02-07 6:30 ` Baolu Lu [this message]
2023-02-03 16:08 ` [PATCH 1/2] dmaengine: idxd: Add enable/disable device IOPF feature Dave Jiang
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=615663e4-59e8-deec-93ab-8d2ebd2f35b7@linux.intel.com \
--to=baolu.lu@linux.intel.com \
--cc=dave.jiang@intel.com \
--cc=dmaengine@vger.kernel.org \
--cc=fenghua.yu@intel.com \
--cc=iommu@lists.linux.dev \
--cc=joro@8bytes.org \
--cc=kevin.tian@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=robin.murphy@arm.com \
--cc=vkoul@kernel.org \
--cc=will@kernel.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).