[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <YWQA8JLXfmQ4DMXv@myrica>
Date: Mon, 11 Oct 2021 10:16:32 +0100
From: Jean-Philippe Brucker <jean-philippe@...aro.org>
To: Vivek Gautam <vivek.gautam@....com>
Cc: "Tian, Kevin" <kevin.tian@...el.com>, mst@...hat.com,
Will Deacon <will.deacon@....com>,
open list <linux-kernel@...r.kernel.org>,
virtualization@...ts.linux-foundation.org,
"list@....net:IOMMU DRIVERS <iommu@...ts.linux-foundation.org>, Joerg
Roedel <joro@...tes.org>," <iommu@...ts.linux-foundation.org>,
Robin Murphy <robin.murphy@....com>,
Linux ARM <linux-arm-kernel@...ts.infradead.org>
Subject: Re: [PATCH RFC v1 03/11] iommu/virtio: Handle incoming page faults
Hi Vivek,
On Mon, Oct 11, 2021 at 01:41:15PM +0530, Vivek Gautam wrote:
> > > + list_for_each_entry(ep, &viommu->endpoints, list) {
> > > + if (ep->eid == endpoint) {
> > > + vdev = ep->vdev;
>
> I have a question here though -
> Is endpoint-ID unique across all the endpoints available per 'viommu_dev' or
> per 'viommu_domain'?
> If it is per 'viommu_domain' then the above list is also incorrect.
> As you pointed to in the patch [1] -
> [PATCH RFC v1 02/11] iommu/virtio: Maintain a list of endpoints served
> by viommu_dev
> I am planning to add endpoint ID into a static global xarray in
> viommu_probe_device() as below:
>
> vdev_for_each_id(i, eid, vdev) {
> ret = xa_insert(&viommu_ep_ids, eid, vdev, GFP_KERNEL);
> if (ret)
> goto err_free_dev;
> }
>
> and replace the above list traversal as below:
>
> xa_lock_irqsave(&viommu_ep_ids, flags);
> xa_for_each(&viommu_ep_ids, eid, vdev) {
> if (eid == endpoint) {
> ret =
> iommu_report_device_fault(vdev->dev, &fault_evt);
> if (ret)
> dev_err(vdev->dev, "Couldn't
> handle page request\n");
> }
> }
> xa_unlock_irqrestore(&viommu_ep_ids, flags);
>
> But using a global xarray would also be incorrect if the endpointsID are global
> across 'viommu_domain'.
>
> I need to find the correct 'viommu_endpoint' to call iommu_report_device_fault()
> with the correct device.
The endpoint IDs are only unique across viommu_dev, so a global xarray
wouldn't work but one in viommu_dev would. In vdomain it doesn't work
either because we can't get to the domain from the fault handler without
first finding the endpoint
Thanks,
Jean
Powered by blists - more mailing lists