public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Baolu Lu <baolu.lu@linux.intel.com>
To: Joel Granados <j.granados@samsung.com>
Cc: baolu.lu@linux.intel.com, David Woodhouse <dwmw2@infradead.org>,
	Joerg Roedel <joro@8bytes.org>, Will Deacon <will@kernel.org>,
	Robin Murphy <robin.murphy@arm.com>,
	Jason Gunthorpe <jgg@ziepe.ca>, Kevin Tian <kevin.tian@intel.com>,
	Klaus Jensen <its@irrelevant.dk>,
	linux-kernel@vger.kernel.org, iommu@lists.linux.dev
Subject: Re: [PATCH 5/6] iommu: init pasid array while doing domain_replace and iopf is active
Date: Thu, 12 Sep 2024 12:21:53 +0800	[thread overview]
Message-ID: <b7a68539-3a3c-4cd9-922b-bfb9db8e7e0b@linux.intel.com> (raw)
In-Reply-To: <20240911105657.iesajd4d5va3wc5y@joelS2.panther.com>

On 9/11/24 6:56 PM, Joel Granados wrote:
> On Thu, Sep 05, 2024 at 11:30:05AM +0800, Baolu Lu wrote:
>> On 9/4/24 9:17 PM, Joel Granados via B4 Relay wrote:
>>> From: Joel Granados<j.granados@samsung.com>
>>>
>>> iommu_report_device_fault expects a pasid array to have an
>>> iommu_attach_handle when a fault is detected.
>> The iommu_attach_handle is expected only when an iopf-capable domain is
>> attached to the device or PASID. The iommu_report_device_fault() treats
>> it as a fault when a fault occurs, but no iopf-capable domain is
>> attached.
>>
>>> Add this handle when the
>>> replacing hwpt has a valid iommufd fault object. Remove it when we
>>> release ownership of the group.
>> The iommu_attach_handle is managed by the caller (iommufd here for
>> example). Therefore, before iommu_attach_handle tries to attach a domain
>> to an iopf-capable device or pasid, it should allocate the handle and
>> pass it to the domain attachment interfaces.
> What do you mean here?
> 1. Do you want to move the iommufd_init_pasid_array call up to
> iommufd_hwpt_replace_device?
> 2. Do you want to move it further up to iommufd_device_do_replace?

I'm having trouble understanding the need for iommu_init_pasid_array()
in the core.

> 
> Note that all this implemented on a call to replace HWPT. So a
> non-iopf-capable VFIO_DEVICE_ATTACH_IOMMUFD_PT ioctl has already been
> completed before the one that calls iommufd_device_do_replace.
> 
>> Conversely, the handle can
>> only be freed after the domain is detached.
> Do you have a function in specific where you would put the free handle
> logic?

drivers/iommu/iommufd/fault.c

void iommufd_fault_domain_detach_dev(struct iommufd_hw_pagetable *hwpt,
                                      struct iommufd_device *idev)
{
         struct iommufd_attach_handle *handle;

         handle = iommufd_device_get_attach_handle(idev);
         iommu_detach_group_handle(hwpt->domain, idev->igroup->group);
         iommufd_auto_response_faults(hwpt, handle);
         iommufd_fault_iopf_disable(idev);
         kfree(handle);
}

Thanks,
baolu

  reply	other threads:[~2024-09-12  4:26 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-04 13:17 [PATCH 0/6] iommu: Enable user space IOPFs in non-nested and non-svm cases Joel Granados via B4 Relay
2024-09-04 13:17 ` [PATCH 1/6] iommu/vt-d: Separate page request queue from SVM Joel Granados via B4 Relay
2024-09-05  3:18   ` Baolu Lu
2024-09-11  7:28     ` Joel Granados
2024-09-04 13:17 ` [PATCH 2/6] iommu/vt-d: Remove the pasid present check in prq_event_thread Joel Granados via B4 Relay
2024-09-04 13:17 ` [PATCH 3/6] iommu: kconfig: Move IOMMU_IOPF into INTEL_IOMMU Joel Granados via B4 Relay
2024-09-07 12:20   ` Jason Gunthorpe
2024-09-11  7:40     ` Joel Granados
2024-09-15 13:37       ` Jason Gunthorpe
2024-09-16 12:24         ` Joel Granados
2024-09-04 13:17 ` [PATCH 4/6] iommufd: Enable PRI when doing the iommufd_hwpt_alloc Joel Granados via B4 Relay
2024-09-04 13:17 ` [PATCH 5/6] iommu: init pasid array while doing domain_replace and iopf is active Joel Granados via B4 Relay
2024-09-05  3:30   ` Baolu Lu
2024-09-05  3:32     ` Baolu Lu
2024-09-11  9:55     ` Joel Granados
2024-09-12  4:17       ` Baolu Lu
2024-09-12 10:22         ` Joel Granados
2024-09-11 10:56     ` Joel Granados
2024-09-12  4:21       ` Baolu Lu [this message]
2024-09-12  8:25         ` Joel Granados
2024-09-12 11:22           ` Baolu Lu
2024-09-13  8:02             ` Joel Granados
2024-09-12 10:00         ` Joel Granados
2024-09-04 13:17 ` [PATCH 6/6] iommu/vt-d: drop pasid requirement for prq initialization Joel Granados via B4 Relay

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=b7a68539-3a3c-4cd9-922b-bfb9db8e7e0b@linux.intel.com \
    --to=baolu.lu@linux.intel.com \
    --cc=dwmw2@infradead.org \
    --cc=iommu@lists.linux.dev \
    --cc=its@irrelevant.dk \
    --cc=j.granados@samsung.com \
    --cc=jgg@ziepe.ca \
    --cc=joro@8bytes.org \
    --cc=kevin.tian@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=robin.murphy@arm.com \
    --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