[PATCH v2 15/18] pci: Update dm_pci_bus_to_virt() parameters
Bin Meng
bmeng.cn at gmail.com
Wed Apr 13 17:03:15 CEST 2022
On Wed, Mar 30, 2022 at 12:59 AM Andrew Scull <ascull at google.com> wrote:
>
> Add mask parameter and reorder length parameter to match the other PCI
> address conversion functions. Using PCI_REGION_TYPE as the mask gives
> the old behaviour.
>
> It's converted from a macro to an inline function as the length
> parameter is now used twice, but should only be calculated once.
>
> Signed-off-by: Andrew Scull <ascull at google.com>
> ---
> drivers/bios_emulator/atibios.c | 4 ++--
> drivers/pci/pci-uclass.c | 4 ++--
> include/pci.h | 19 ++++++++++++++-----
> 3 files changed, 18 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/bios_emulator/atibios.c b/drivers/bios_emulator/atibios.c
> index 9547470a2f..cdc5ba6ad9 100644
> --- a/drivers/bios_emulator/atibios.c
> +++ b/drivers/bios_emulator/atibios.c
> @@ -368,8 +368,8 @@ void *PCI_mapBIOSImage(struct udevice *pcidev)
> return NULL;
> }
>
> - BIOSImage = dm_pci_bus_to_virt(pcidev, BIOSImageBus,
> - PCI_REGION_MEM, 0, MAP_NOCACHE);
> + BIOSImage = dm_pci_bus_to_virt(pcidev, BIOSImageBus, 0, PCI_REGION_TYPE,
> + PCI_REGION_MEM, MAP_NOCACHE);
>
> /*Change the PCI BAR registers to map it onto the bus.*/
> dm_pci_write_config32(pcidev, BIOSImageBAR, 0);
> diff --git a/drivers/pci/pci-uclass.c b/drivers/pci/pci-uclass.c
> index 5069ada66d..676052090a 100644
> --- a/drivers/pci/pci-uclass.c
> +++ b/drivers/pci/pci-uclass.c
> @@ -1602,8 +1602,8 @@ void *dm_pci_map_bar(struct udevice *dev, int bar, size_t offset, size_t len,
> * a PCI range, but a better check would be to probe for the size of
> * the bar and prevent overflow more locally.
> */
> - return dm_pci_bus_to_virt(udev, pci_bus_addr + offset, flags, len,
> - MAP_NOCACHE);
> + return dm_pci_bus_to_virt(udev, pci_bus_addr + offset, len,
> + PCI_REGION_TYPE, flags, MAP_NOCACHE);
> }
>
> static int _dm_pci_find_next_capability(struct udevice *dev, u8 pos, int cap)
> diff --git a/include/pci.h b/include/pci.h
> index 8198265269..683efcd1be 100644
> --- a/include/pci.h
> +++ b/include/pci.h
> @@ -11,6 +11,8 @@
> #ifndef _PCI_H
> #define _PCI_H
>
> +#include <asm/io.h>
> +
> #define PCI_CFG_SPACE_SIZE 256
> #define PCI_CFG_SPACE_EXP_SIZE 4096
>
> @@ -1584,9 +1586,14 @@ int dm_pci_flr(struct udevice *dev);
>
> #define dm_pci_virt_to_bus(dev, addr, flags) \
> dm_pci_phys_to_bus(dev, (virt_to_phys(addr)), 0, PCI_REGION_TYPE, (flags))
> -#define dm_pci_bus_to_virt(dev, addr, flags, len, map_flags) \
> - map_physmem(dm_pci_bus_to_phys(dev, (addr), (len), PCI_REGION_TYPE, (flags)), \
> - (len), (map_flags))
> +
> +static inline void *dm_pci_bus_to_virt(struct udevice *dev, pci_addr_t addr,
> + size_t len, unsigned long mask,
> + unsigned long flags,
> + unsigned long map_flags) {
> + return map_physmem(dm_pci_bus_to_phys(dev, addr, len, mask, flags),
> + len, map_flags);
> +}
>
> #define dm_pci_phys_to_mem(dev, addr) \
> dm_pci_phys_to_bus((dev), (addr), 0, PCI_REGION_TYPE, PCI_REGION_MEM)
> @@ -1600,11 +1607,13 @@ int dm_pci_flr(struct udevice *dev);
> #define dm_pci_virt_to_mem(dev, addr) \
> dm_pci_virt_to_bus((dev), (addr), PCI_REGION_MEM)
> #define dm_pci_mem_to_virt(dev, addr, len, map_flags) \
> - dm_pci_bus_to_virt((dev), (addr), PCI_REGION_MEM, (len), (map_flags))
> + dm_pci_bus_to_virt((dev), (addr), (len), PCI_REGION_TYPE, \
> + PCI_REGION_MEM, (map_flags))
> #define dm_pci_virt_to_io(dev, addr) \
> dm_pci_virt_to_bus((dev), (addr), PCI_REGION_IO)
> #define dm_pci_io_to_virt(dev, addr, len, map_flags) \
> - dm_pci_bus_to_virt((dev), (addr), PCI_REGION_IO, (len), (map_flags))
> + dm_pci_bus_to_virt((dev), (addr), (len), PCI_REGION_TYPE, \
> + PCI_REGION_IO, (map_flags))
>
> /**
> * dm_pci_find_device() - find a device by vendor/device ID
> --
I believe this patch should be squashed into patch #14 for bisectablitly.
Regards,
Bin
More information about the U-Boot
mailing list