|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [PATCH] xen/pci: replace call to is_memory_hole to pci_check_bar
On 05.08.22 18:43, Rahul Singh wrote: Hello Rahul Thank you very much for that patch! From: Oleksandr Andrushchenko <oleksandr_andrushchenko@xxxxxxxx> I am not 100% sure regarding that. This is *completely* different patch from what Oleksandr initially made here: https://lore.kernel.org/xen-devel/20220719174253.541965-2-olekstysh@xxxxxxxxx/ Copy below for the convenience: +bool is_memory_hole(mfn_t start, mfn_t end) +{ + /* TODO: this needs to be properly implemented. */ + return true; +} Patch looks good, just a couple of minor comments/nits.
Nit: This is only used by pci-host-common.c, so I think it could be declared there. + /* Default ECAM ops */ extern const struct pci_ecam_ops pci_generic_ecam_ops;@@ -125,6 +135,8 @@ int pci_host_iterate_bridges_and_count(struct domain *d, int pci_host_bridge_mappings(struct domain *d); +bool pci_check_bar(const struct pci_dev *pdev, mfn_t start, mfn_t end);+ #else /*!CONFIG_HAS_PCI*/struct arch_pci_dev { }; Nit: white space after 'e' is missed in the last part of the check The cast is present here because of the const?I would consider passing "const struct pci_dev *pdev" instead of "struct device *dev" to pci_find_host_bridge_node() and dropping conversion (pci<->dev) in both functions. Something like below (not tested): diff --git a/xen/arch/arm/include/asm/pci.h b/xen/arch/arm/include/asm/pci.h index 5c4ab2c4dc..a17ef32252 100644 --- a/xen/arch/arm/include/asm/pci.h +++ b/xen/arch/arm/include/asm/pci.h @@ -116,7 +116,7 @@ bool pci_ecam_need_p2m_hwdom_mapping(struct domain *d, struct pci_host_bridge *bridge, uint64_t addr);struct pci_host_bridge *pci_find_host_bridge(uint16_t segment, uint8_t bus); -struct dt_device_node *pci_find_host_bridge_node(struct device *dev);+struct dt_device_node *pci_find_host_bridge_node(const struct pci_dev *pdev); int pci_get_host_bridge_segment(const struct dt_device_node *node, uint16_t *segment);diff --git a/xen/arch/arm/pci/pci-host-common.c b/xen/arch/arm/pci/pci-host-common.c index 8ea1aaeece..3a64a7350f 100644 --- a/xen/arch/arm/pci/pci-host-common.c +++ b/xen/arch/arm/pci/pci-host-common.c @@ -243,10 +243,9 @@ err_exit: /* * Get host bridge node given a device attached to it. */ -struct dt_device_node *pci_find_host_bridge_node(struct device *dev)+struct dt_device_node *pci_find_host_bridge_node(const struct pci_dev *pdev)
{
struct pci_host_bridge *bridge;
- struct pci_dev *pdev = dev_to_pci(dev);
bridge = pci_find_host_bridge(pdev->seg, pdev->bus);
if ( unlikely(!bridge) )
@@ -380,14 +379,13 @@ bool pci_check_bar(const struct pci_dev *pdev,
mfn_t start, mfn_t end)
{
int ret;
struct dt_device_node *dt_node;
- struct device *dev = (struct device *)pci_to_dev(pdev);
struct pdev_bar bar_data = {
.start = start,
.end = end,
.is_valid = false
};
- dt_node = pci_find_host_bridge_node(dev);
+ dt_node = pci_find_host_bridge_node(pdev);
ret = dt_for_each_range(dt_node, &is_bar_valid, &bar_data);
if ( ret < 0 )
if ( !dt_node ) return false; + + ret = dt_for_each_range(dt_node, &is_bar_valid, &bar_data); + if ( ret < 0 ) + return ret; s/return ret;/return false; + + if ( !bar_data.is_valid ) + return false; + + return true; +} /* * Local variables: * mode: C diff --git a/xen/arch/x86/include/asm/pci.h b/xen/arch/x86/include/asm/pci.h index c8e1a9ecdb..f4a58c8acf 100644 --- a/xen/arch/x86/include/asm/pci.h +++ b/xen/arch/x86/include/asm/pci.h @@ -57,4 +57,14 @@ static always_inline bool is_pci_passthrough_enabled(void)void arch_pci_init_pdev(struct pci_dev *pdev); +static inline bool pci_check_bar(const struct pci_dev *pdev, Nit: I would use simple #define instead of static inline here But I am not 100% sure that x86 maintainers would be happy.
-- Regards, Oleksandr Tyshchenko
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |