[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [UNIKRAFT PATCH RFCv3 22/32] plat/pci_ecam: Fix a lot compilation warnings in pci_ecam
This fixes the compilation warnings when introducing pci_ecam Signed-off-by: Jia He <justin.he@xxxxxxx> --- plat/common/arm/pci_bus_arm64.c | 22 ++++++--------- plat/common/include/pci/pci_bus.h | 2 +- plat/common/include/pci/pci_ecam.h | 2 +- plat/common/pci_ecam.c | 44 +++++++++++++++--------------- plat/drivers/include/ofw/fdt.h | 11 ++++++++ 5 files changed, 44 insertions(+), 37 deletions(-) diff --git a/plat/common/arm/pci_bus_arm64.c b/plat/common/arm/pci_bus_arm64.c index 1dfaeb3..4386d55 100644 --- a/plat/common/arm/pci_bus_arm64.c +++ b/plat/common/arm/pci_bus_arm64.c @@ -75,7 +75,6 @@ static inline int arch_pci_driver_add_device(struct pci_driver *drv, { struct pci_device *dev; int ret; - __u32 val; UK_ASSERT(drv != NULL); UK_ASSERT(drv->add_dev != NULL); @@ -97,7 +96,7 @@ static inline int arch_pci_driver_add_device(struct pci_driver *drv, dev->base = base; dev->irq = irq; - uk_pr_info("pci dev base(0x%llx) irq(%d)\n", dev->base, dev->irq); + uk_pr_info("pci dev base(0x%lx) irq(%ld)\n", dev->base, dev->irq); if (drv->add_dev) ret = drv->add_dev(dev); //virtio pci @@ -119,7 +118,6 @@ int arch_pci_probe(struct uk_alloc *pha) struct pci_driver *drv; uint32_t bus; uint8_t dev; - int err; int irq, pin = 0; __u64 base; int found_pci_device = 0; @@ -137,7 +135,7 @@ int arch_pci_probe(struct uk_alloc *pha) /* TODO: Retrieve the function bus, dev << PCI_DEV_BIT_NBR*/ addr.function = 0x0; - pci_generic_config_read(bus, DEVFN(dev, 0), PCI_VENDOR_ID, 2, &devid.vendor_id); + pci_generic_config_read(bus, DEVFN(dev, 0), PCI_VENDOR_ID, 2, (void *)&devid.vendor_id); if (devid.vendor_id == PCI_INVALID_ID) { /* Device doesn't exist */ continue; @@ -146,11 +144,11 @@ int arch_pci_probe(struct uk_alloc *pha) /* mark we found any pci device */ found_pci_device = 1; - pci_generic_config_read(bus, DEVFN(dev, 0), PCI_CLASS_REVISION, 4, &devid.class_id); - pci_generic_config_read(bus, DEVFN(dev, 0), PCI_VENDOR_ID, 2, &devid.vendor_id); - pci_generic_config_read(bus, DEVFN(dev, 0), PCI_DEV_ID, 2, &devid.device_id); - pci_generic_config_read(bus, DEVFN(dev, 0), PCI_SUBSYSTEM_VID, 2, &devid.subsystem_vendor_id); - pci_generic_config_read(bus, DEVFN(dev, 0), PCI_SUBSYSTEM_ID, 2, &devid.subsystem_device_id); + pci_generic_config_read(bus, DEVFN(dev, 0), PCI_CLASS_REVISION, 4, (void *)&devid.class_id); + pci_generic_config_read(bus, DEVFN(dev, 0), PCI_VENDOR_ID, 2, (void *)&devid.vendor_id); + pci_generic_config_read(bus, DEVFN(dev, 0), PCI_DEV_ID, 2, (void *)&devid.device_id); + pci_generic_config_read(bus, DEVFN(dev, 0), PCI_SUBSYSTEM_VID, 2, (void *)&devid.subsystem_vendor_id); + pci_generic_config_read(bus, DEVFN(dev, 0), PCI_SUBSYSTEM_ID, 2, (void *)&devid.subsystem_device_id); uk_pr_info("PCI %02x:%02x.%02x (%04x %04x:%04x): sb=%d,sv=%4x\n", (int) addr.bus, (int) addr.devid, @@ -175,14 +173,14 @@ int arch_pci_probe(struct uk_alloc *pha) drv = pci_find_driver(&devid); if (!drv) { - uk_pr_info("<no driver> for dev id=%d\n", devid); + uk_pr_info("<no driver> for dev id=%d\n", devid.device_id); continue; } uk_pr_info("driver %p\n", drv); /* probe the irq info*/ - pci_generic_config_read(bus, DEVFN(dev, 0), PCI_INTERRUPT_PIN, 1, &pin); + pci_generic_config_read(bus, DEVFN(dev, 0), PCI_INTERRUPT_PIN, 1, (void *)&pin); out_irq.args_count = 1; out_irq.args[0] = pin; fdtaddr[0] = cpu_to_fdt32((bus << 16) | (DEVFN(dev,0) << 8)); @@ -192,8 +190,6 @@ int arch_pci_probe(struct uk_alloc *pha) irq = gic_irq_translate(0, out_irq.args[1]); arch_pci_driver_add_device(drv, &addr, &devid, irq, base, pha); - - uk_pr_info("pci dev base(0x%llx) irq(%d)\n"); } } diff --git a/plat/common/include/pci/pci_bus.h b/plat/common/include/pci/pci_bus.h index 78ca977..3b6d863 100644 --- a/plat/common/include/pci/pci_bus.h +++ b/plat/common/include/pci/pci_bus.h @@ -181,7 +181,7 @@ struct pci_bus_handler { struct uk_list_head drv_list; /**< List of PCI drivers */ struct uk_list_head dev_list; /**< List of PCI devices */ }; -static struct pci_bus_handler ph; +static struct pci_bus_handler ph __unused; #define PCI_INVALID_ID (0xFFFF) #define PCI_DEVICE_ID_MASK (0xFFFF) diff --git a/plat/common/include/pci/pci_ecam.h b/plat/common/include/pci/pci_ecam.h index f325a14..e2a42e2 100644 --- a/plat/common/include/pci/pci_ecam.h +++ b/plat/common/include/pci/pci_ecam.h @@ -92,7 +92,7 @@ struct fdt_phandle_args { int pci_generic_config_read(__u8 bus, __u8 devfn, - int where, int size, __u32 *val); + int where, int size, void *val); int pci_generic_config_write(__u8 bus, __u8 devfn, int where, int size, __u32 val); diff --git a/plat/common/pci_ecam.c b/plat/common/pci_ecam.c index b97a580..d07ff1d 100644 --- a/plat/common/pci_ecam.c +++ b/plat/common/pci_ecam.c @@ -89,7 +89,7 @@ static void *pci_ecam_map_bus(__u8 bus, __u8 devfn, int where) } int pci_generic_config_read(__u8 bus, __u8 devfn, - int where, int size, __u32 *val) + int where, int size, void *val) { void *addr; @@ -97,16 +97,16 @@ int pci_generic_config_read(__u8 bus, __u8 devfn, rmb(); addr = pci_ecam_map_bus(bus, devfn, where); if (!addr) { - *val = ~0; + *(int *)val = ~0; return -1; } if (size == 1) - *val = ioreg_read8(addr); + *(uint8_t *)val = ioreg_read8(addr); else if (size == 2) - *val = ioreg_read16(addr); + *(uint16_t *)val = ioreg_read16(addr); else if (size == 4) - *val = ioreg_read32(addr); + *(uint32_t *)val = ioreg_read32(addr); else uk_pr_err("not support size pci config read\n"); @@ -117,7 +117,6 @@ int pci_generic_config_write(__u8 bus, __u8 devfn, int where, int size, __u32 val) { void *addr; - __u32 mask, tmp; addr = pci_ecam_map_bus(bus, devfn, where); if (!addr) @@ -206,7 +205,7 @@ static int irq_find_parent(const void *fdt, int child) { int p; int plen; - fdt32_t *prop; + const fdt32_t *prop; fdt32_t parent; do { @@ -234,7 +233,7 @@ int gen_pci_irq_parse(const fdt32_t *addr, struct fdt_phandle_args *out_irq) int addrsize, newaddrsize = 0; int imaplen, match, i, rc = -EINVAL; int plen; - int *prop; + const fdt32_t *prop; ipar = gen_pci_fdt; @@ -255,7 +254,7 @@ int gen_pci_irq_parse(const fdt32_t *addr, struct fdt_phandle_args *out_irq) } intsize = fdt32_to_cpu(prop[0]); - uk_pr_info("irq_parse_raw: ipar=%p, size=%d\n", ipar, intsize); + uk_pr_info("irq_parse_raw: ipar=%x, size=%d\n", ipar, intsize); if (out_irq->args_count != intsize) goto fail; @@ -385,7 +384,7 @@ int gen_pci_irq_parse(const fdt32_t *addr, struct fdt_phandle_args *out_irq) skiplevel: /* Iterate again with new parent */ out_irq->np = newpar; - uk_pr_info(" -> new parent: %pOF\n", newpar); + uk_pr_info(" -> new parent: %x\n", newpar); ipar = newpar; newpar = 0; @@ -398,17 +397,15 @@ fail: } -static int gen_pci_probe(struct pf_device *pfdev) +static int gen_pci_probe(struct pf_device *pfdev __unused) { const fdt32_t *prop; int prop_len; __u64 reg_base; __u64 reg_size; - int err; struct pci_range range; struct pci_range_parser parser; - struct fdt_phandle_args out_irq; - fdt32_t laddr[3]; + int err; /* 1.Get the base and size of config space */ gen_pci_fdt = fdt_node_offset_by_compatible(fdt_start, -1, @@ -434,7 +431,7 @@ static int gen_pci_probe(struct pf_device *pfdev) pcw.config_base = reg_base; pcw.config_space_size = reg_size; - uk_pr_info("generic pci config base(0x%llx),size(0x%llx)\n", + uk_pr_info("generic pci config base(0x%lx),size(0x%lx)\n", reg_base, reg_size); /* 2.Get the bus range of pci controller */ @@ -456,6 +453,11 @@ static int gen_pci_probe(struct pf_device *pfdev) /* 3.Get the pci addr base and limit size for pci devices */ err = gen_pci_parser_range(&parser, gen_pci_fdt); + if (err < 0) { + uk_pr_err("bus-range detect error in fdt\n"); + goto error_exit; + } + do { pci_range_parser_one(&parser, &range, gen_pci_fdt); if (range.flags == IORESOURCE_IO) { @@ -465,7 +467,7 @@ static int gen_pci_probe(struct pf_device *pfdev) } parser.range += parser.np; } while (parser.range + parser.np <= parser.end); - uk_pr_info("generic pci range base(0x%llx),size(0x%llx)\n", + uk_pr_info("generic pci range base(0x%lx),size(0x%lx)\n", pcw.pci_device_base, pcw.pci_device_limit); return 0; @@ -492,18 +494,16 @@ static int gen_pci_add_dev(struct pf_device *pfdev __unused) static const struct device_match_table gen_pci_match_table[]; -static struct pf_device_id *gen_pci_id_match_compatible(const char *compatible) +static int gen_pci_id_match_compatible(const char *compatible) { - int i; - for (int i = 0; gen_pci_match_table[i].compatible != NULL; i++) if (strcmp(gen_pci_match_table[i].compatible, compatible) == 0) - return gen_pci_match_table[i].id; + return gen_pci_match_table[i].id->device_id; - return NULL; + return -1; } -static const struct pf_device_id gen_pci_ids = { +static struct pf_device_id gen_pci_ids = { .device_id = GEN_PCI_ID }; diff --git a/plat/drivers/include/ofw/fdt.h b/plat/drivers/include/ofw/fdt.h index a3896ff..13dfdc2 100644 --- a/plat/drivers/include/ofw/fdt.h +++ b/plat/drivers/include/ofw/fdt.h @@ -200,4 +200,15 @@ int fdt_get_interrupt(const void *fdt, int nodeoffset, */ bool fdt_prop_read_bool(const void *fdt, int start_offset, const char *propname); + +/** + * fdt_translate_address_by_ranges - Translate an address from the + * device-tree into a CPU physical address, this walks up the tree and + * applies the various bus mappings on the way. + * @fdt: pointer to the device tree blob + * @node_offset: start offset of the node to find the address for + * @regs regs in device-tree + */ +uint64_t fdt_translate_address_by_ranges(const void *fdt, + int node_offset, const fdt32_t *regs); #endif -- 2.17.1
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |