On Fri Jun 6, 2025 at 8:51 AM CEST, Jan Beulich wrote:
> On 05.06.2025 21:47, Alejandro Vallejo wrote:
>> --- a/xen/include/asm-generic/device.h
>> +++ b/xen/include/asm-generic/device.h
>> @@ -1,14 +1,20 @@
>>  /* SPDX-License-Identifier: GPL-2.0-only */
>> +/*
>> + * This header helps DTB-based architectures abstract away where a 
>> particular
>> + * device came from, be it the DTB itself or enumerated on a PCI bus.
>> + */
>>  #ifndef __ASM_GENERIC_DEVICE_H__
>>  #define __ASM_GENERIC_DEVICE_H__
>>  
>> +#ifndef CONFIG_HAS_DEVICE_TREE
>> +#error "Header for exclusive use of DTB-based architectures"
>> +#endif
>> +
>>  #include <xen/stdbool.h>
>>  
>>  enum device_type
>>  {
>> -#ifdef CONFIG_HAS_DEVICE_TREE
>>      DEV_DT,
>> -#endif
>>      DEV_PCI
>>  };
>
> My objection to these changes remains; as a generic header it ought to be what
> that attribute says - generic.
>
> Jan

It is generic for any architecture where platform DTs exist (that is, anything
but x86).

As the commit message states, these guards are useless, provide no functionality
and create the fiction that somehow this header is still relevant on an
architecture where only PCI is available. And that's just not true. x86 being
the sole architecture without DTs actively overrides it, and relies on device_t
(defined as struct device here) to be a "struct pci_dev" instead in
x86/include/asm/device.h, with dev_to_pci() and pci_to_dev() being irrelevant
because device_t* and struct pci_dev* are identical types in x86. Removing that
override header is not just a matter of performance. All the IOMMU ops are
referencing device_t, while the drivers are assuming pci_dev, so all IOMMU
code breaks immediately when x86 tries to use this.

To be perfectly clear, this patch isn't strictly required to do DT unflattening
on x86. But it's a piece of arm tech debt that Xen is better off without.

Cheers,
Alejandro

Reply via email to