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

Re: [PATCH v2 5/8] pci/arm: Use iommu_add_dt_pci_device()


  • To: Stewart Hildebrand <stewart.hildebrand@xxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Mon, 15 May 2023 09:30:48 +0200
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=eDofIGobZV3ZfZtNUodE5fycUG4IC6S48IzkCYA1KAY=; b=AhPxECmQ0mo0tk6DXIwadx2UaoNhhyV8HKHt35bBRISH/XLxi8kTG/bZptB+Rxe9+UDmfOOk20Zc4EsX4PteHdR38/VJLvGfWT6hYvta0OAObCMhBjxmjyzf5A5grccJmtRwQkMqn960NnUrbeuvsWowAKxbyy3qlCiWQ0A3zG3Cg/LcDDqrcJ5goUrnQt9dM9zkASlQDYrmDByM+EIDyDUmHQohGUNmye8xObR2PAtNcbYiH17qqS0zqBj4P6DL6s7gNlQS3jPmZt5y/lB0hw+NHQrYyEoYhDf1fABLuWXNoyWDv8JWmTuB6UOuCEAAlEsbUlWxD/mlRFXCN91X2g==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=iqhEiCFq5Oh8XbIZJDMqhTG6C2SgTf8avbI83U8uVCnW9r+cdXiNPTPeylQAFx4wioRY37t2JfkaoWzZcmfo6yjn8bSn4kWdREieln8EeLZZgYwvAOYbTnB/E9G7wFRlCWYR8ukwrM4HkKznuB+G43zR5Eq7zl3j+eduzEEwZlh7N8MPaBNcoX+LqQJ2TNlXfDM0/3+VIRxgEc6BoKY9j80MDp5F6Gb7fZe8Ytaze4/d9Fx/vytOl0ntsN9cFbiJaE5GnlQDNKx+HHyuSHVfJQMXKixEZGU3IlL3wBmNqoA7dtLRjnW2ymEWbCUpLq9mJihmDE3+MP+MvGmJzH5kSA==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: Oleksandr Tyshchenko <oleksandr_tyshchenko@xxxxxxxx>, Paul Durrant <paul@xxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Rahul Singh <rahul.singh@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Bertrand Marquis <bertrand.marquis@xxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx
  • Delivery-date: Mon, 15 May 2023 07:30:58 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 12.05.2023 23:03, Stewart Hildebrand wrote:
> On 5/12/23 03:25, Jan Beulich wrote:
>> On 11.05.2023 21:16, Stewart Hildebrand wrote:
>>> @@ -762,9 +767,20 @@ int pci_add_device(u16 seg, u8 bus, u8 devfn,
>>>              pdev->domain = NULL;
>>>              goto out;
>>>          }
>>> +#ifdef CONFIG_HAS_DEVICE_TREE
>>> +        ret = iommu_add_dt_pci_device(pdev);
>>> +        if ( ret < 0 )
>>> +        {
>>> +            printk(XENLOG_ERR "pci-iommu translation failed: %d\n", ret);
>>> +            goto out;
>>> +        }
>>> +#endif
>>>          ret = iommu_add_device(pdev);
>>
>> Hmm, am I misremembering that in the earlier patch you had #else to
>> invoke the alternative behavior?
> 
> You are remembering correctly. v1 had an #else, v2 does not.
> 
>> Now you end up calling both functions;
>> if that's indeed intended,
> 
> Yes, this is intentional.
> 
>> this may still want doing differently.
>> Looking at the earlier patch introducing the function, I can't infer
>> though whether that's intended: iommu_add_dt_pci_device() checks that
>> the add_device hook is present, but then I didn't find any use of this
>> hook. The revlog there suggests the check might be stale.
> 
> Ah, right, the ops->add_device check is stale in the other patch. Good catch, 
> I'll remove it there.
> 
>> If indeed the function does only preparatory work, I don't see why it
>> would need naming "iommu_..."; I'd rather consider pci_add_dt_device()
>> then.
> 
> The function has now been reduced to reading SMMU configuration data from DT 
> and mapping RID/BDF -> AXI stream ID. However, it is still SMMU related, and 
> it is still invoking another iommu_ops hook function, dt_xlate (which is yet 
> another AXI stream ID translation, separate from what is being discussed 
> here). Does this justify keeping "iommu_..." in the name? I'm not convinced 
> pci_add_dt_device() is a good name for it either (more on this below).

The function being SMMU-related pretty strongly suggests it wants to be
invoked via a hook. If the add_device() one isn't suitable, perhaps we
need a new (optional) prepare_device() one? With pci_add_device() then
calling iommu_prepare_device(), wrapping the hook invocation?

But just to be clear: A new hook would need enough justification as to
the existing one being unsuitable.

Jan



 


Rackspace

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