[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v9 2/8] iommu/arm: Introduce iommu_add_dt_pci_sideband_ids API


  • To: Jan Beulich <jbeulich@xxxxxxxx>
  • From: Mykyta Poturai <Mykyta_Poturai@xxxxxxxx>
  • Date: Thu, 20 Mar 2025 10:47:30 +0000
  • Accept-language: en-US
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=epam.com; dmarc=pass action=none header.from=epam.com; dkim=pass header.d=epam.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=BAX8z2eRJ5ZqbStb8Fjl7veWegKVY0OH+onZypfuF9I=; b=o80TtHEkq5k6ayerVJk0k0CKLar90qZSdFz4w7z14lBlrwFpE2NhGPZy5xYyOPfQkcA013wJejqYUJcN96SsVx6NwDHQBg31FbAPtgc6LtCxC6t4iJ0hoEkCfKbxS4OdgEOKUYWEcg3Dp2ZsLVSbMn0TwOPfEbepJ3h4cc+rQ8rUMHtFUrimLVEAkjOiVbWCgxvMDPvT5QncBcNokLe2Y4kUyagvcdHFZW70CH7kHYbunXETfg3ebd5Jzv5oM6LAls6Ptbo4wy05zeW2GGGKwFPbdP67tk42N4Hl6GTRD2IR+d79vI/Fz+yE9UJTAQAabkai+oJFQBzJdMf2ezWGZA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=rI3yHBWqkmJ0f4V4Y7zqDuO4DSCwc2MXtXW8tSoAkgXHJ/TkWM7atxMng2kJiR6hu9iwVdg50/Ywu65PrRcezCbKQoYuW5RWGEgaL7fVdvu6OrCQlQTj0fkjAeURjZzhGSKyYal7BIs8Cqda3HXPjpAFzWmm1pl2grM9JOnijGFQ58G+IMTPJ4yTkxU5YYvqTK4YycJUa4eFKjmT7z6xiaR204zhyeCH1LH3J13FugQEZhbYhl0Kw9OHoMkD6Zj62ivZQXf9MnHZPkTJK13y28TrFmxWKPQrUBh5ivD2elg2SYG2kNq0QaJY4/e7nmkm4Lk4zRlyLkJ84kQr6FvRSQ==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=epam.com;
  • Cc: Oleksandr Tyshchenko <Oleksandr_Tyshchenko@xxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Bertrand Marquis <bertrand.marquis@xxxxxxx>, Michal Orzel <michal.orzel@xxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, Stewart Hildebrand <stewart.hildebrand@xxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • Delivery-date: Thu, 20 Mar 2025 10:47:42 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Thread-index: AQHblOXcI08sNdwZJ0ah+pJJkNPOtLN3b9CAgAMregCAAAIvgIABQ66A
  • Thread-topic: [PATCH v9 2/8] iommu/arm: Introduce iommu_add_dt_pci_sideband_ids API

On 19.03.25 17:28, Jan Beulich wrote:
> On 19.03.2025 16:21, Mykyta Poturai wrote:
>> On 17.03.25 16:56, Jan Beulich wrote:
>>> On 14.03.2025 14:34, Mykyta Poturai wrote:
>>>> From: Oleksandr Tyshchenko <oleksandr_tyshchenko@xxxxxxxx>
>>>>
>>>> The main purpose of this patch is to add a way to register PCI device
>>>> (which is behind the IOMMU) using the generic PCI-IOMMU DT bindings [1]
>>>> before assigning that device to a domain.
>>>>
>>>> This behaves similarly to the existing iommu_add_dt_device API, except it
>>>> handles PCI devices, and it is to be invoked from the add_device hook in 
>>>> the
>>>> SMMU driver.
>>>>
>>>> The function dt_map_id to translate an ID through a downstream mapping
>>>> (which is also suitable for mapping Requester ID) was borrowed from Linux
>>>> (v5.10-rc6) and updated according to the Xen code base.
>>>>
>>>> [1] 
>>>> https://www.kernel.org/doc/Documentation/devicetree/bindings/pci/pci-iommu.txt
>>>>
>>>> Signed-off-by: Oleksandr Tyshchenko <oleksandr_tyshchenko@xxxxxxxx>
>>>> Signed-off-by: Stewart Hildebrand <stewart.hildebrand@xxxxxxx>
>>>> Signed-off-by: Mykyta Poturai <mykyta_poturai@xxxxxxxx>
>>>> ---
>>>> Regarding pci_for_each_dma_alias question: getting host bridge node
>>>> directly seems like a simpler solution with the same result. AFAIU
>>>> with pci_for_each_dma_alias in linux we would arrive to the host brige
>>>> node anyway, but also try to call dt_map_id for each device along the
>>>> way. I am not sure why exactly it is done this way in linux, as
>>>> according to the pci-iommu.txt, iommu-map node can only be present in
>>>> the PCI root.
>>>>
>>>> v8->v9:
>>>> * replace DT_NO_IOMMU with 1
>>>> * guard iommu_add_pci_sideband_ids with CONFIG_ARM
>>>
>>> I fear I'm confused: Isn't this contradicting ...
>>>
>>>> v7->v8:
>>>> * ENOSYS->EOPNOTSUPP
>>>> * move iommu_add_pci_sideband_ids to iommu.c to fix x86 build
>>>
>>> ... this earlier change? Really, with there being no caller, I can't see
>>> why there could be any build issue here affecting only x86. Except for
>>> Misra complaining about unreachable code being introduced, which I'm sure
>>> I said before should be avoided.
>>
>> The original reason for moving this function was the conflicting ACPI
>> and EFI headers, I described it in V8 comments here[1].
>>
>>>
>>>> --- a/xen/drivers/passthrough/iommu.c
>>>> +++ b/xen/drivers/passthrough/iommu.c
>>>> @@ -20,6 +20,7 @@
>>>>    #include <xen/param.h>
>>>>    #include <xen/softirq.h>
>>>>    #include <xen/keyhandler.h>
>>>> +#include <xen/acpi.h>
>>>>    #include <xsm/xsm.h>
>>>>
>>>>    #ifdef CONFIG_X86
>>>> @@ -744,6 +745,20 @@ int __init 
>>>> iommu_get_extra_reserved_device_memory(iommu_grdm_t *func,
>>>>        return 0;
>>>>    }
>>>>
>>>> +#ifdef CONFIG_ARM
>>>
>>> I realize we have CONFIG_X86 here as well (visible even in context of the
>>> earlier hunk. Yet then the goal ought to be to reduce these anomalies, not
>>> add new ones. Since I don't have a clear picture of what's wanted, I'm also
>>> in trouble suggesting any alternative, I'm afraid.
>>
>> Here is a short summary:
>>
>> The main problem is that we need this function somewhere, but there is
>> no good place for it. It is only called on ARM for now but it's not
>> ARM-specific by nature and can be eventually used on other platforms as
>> well. It can't be just dropped because of the effort to support the
>> co-existence of DT and ACPI. It also can't be declared as a static
>> function because it requires the inclusion of <xen/acpi.h> for
>> acpi_disabled define, which leads to build errors[1]. And without ifdef
>> guards it would be a MISRA violation.
> 
> An abridged version of this ought to go in the patch description, I think.
> This is special, so it needs calling out.
> 
> As to the placement - would making an entirely new .c file possibly help?
> (Then, instead of in the patch description, maybe the special aspect could
> be put in a code comment at the top of the file.)
> 
> Jan

It seems to me creating a new file would be overkill for one small 
function. I considered moving it to xen/drivers/passthrough/arm/iommu.c 
to reduce ifdefs but I feared it would suggest that it is arch-specific 
a bit too strongly. So maybe move it there after all if you think it 
would be better?

-- 
Mykyta

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.