[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <cdc4a52f-948c-0cbd-b45e-7231ef78b3e4@arm.com>
Date: Mon, 11 Oct 2021 14:50:07 +0530
From: Vivek Kumar Gautam <vivek.gautam@....com>
To: Jean-Philippe Brucker <jean-philippe@...aro.org>
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 Jean,
On 10/11/21 2:46 PM, Jean-Philippe Brucker wrote:
> 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. That's easy then. Will have a xarray in viommu_dev and iterate
over it from the fault handler.
Best regards
Vivek
Powered by blists - more mailing lists