Paul Menzel 0afecdf95a sb/intel/common/rcba_pirq: Use correct size_t length modifier
Building an image for the Lenovo T60 with `x86_64-linux-gnu-gcc-11`
fails with the format warning below.

        CC         ramstage/southbridge/intel/common/rcba_pirq.o
    src/southbridge/intel/common/rcba_pirq.c: In function 'intel_acpi_gen_def_acpi_pirq':
    src/southbridge/intel/common/rcba_pirq.c:86:69: error: format '%ld' expects argument of type 'long int', but argument 5 has type 'size_t' {aka 'unsigned int'} [-Werror=format=]
       86 |                 printk(BIOS_SPEW, "ACPI_PIRQ_GEN: %s: pin=%d pirq=%ld\n",
          |                                                                   ~~^
          |                                                                     |
          |                                                                     long int
          |                                                                   %d
       87 |                        dev_path(dev), int_pin - PCI_INT_A,
       88 |                        pirq_idx(pin_irq_map[map_count].pic_pirq));
          |                        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          |                        |
          |                        size_t {aka unsigned int}

The return value of `pirq_idx()` is of type `size_t`, so use the
appropriate length modifier `z`.

Change-Id: I7af24cee536b81e4825b77942bcac75afeb9f476
Found-by: gcc (Debian 11.2.0-13) 11.2.0
Signed-off-by: Paul Menzel <pmenzel@molgen.mpg.de>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/60194
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Tim Wawrzynczak <twawrzynczak@chromium.org>
2021-12-23 14:33:50 +00:00

96 lines
2.7 KiB
C

/* SPDX-License-Identifier: GPL-2.0-only */
#include <acpi/acpi_device.h>
#include <console/console.h>
#include <device/device.h>
#include <device/pci.h>
#include <stdlib.h>
#include <southbridge/intel/common/acpi_pirq_gen.h>
#include <southbridge/intel/common/rcba_pirq.h>
#include <southbridge/intel/common/rcba.h>
#define MAX_SLOT 31
#define MIN_SLOT 19
static const u32 pirq_dir_route_reg[MAX_SLOT - MIN_SLOT + 1] = {
D19IR, D20IR, D21IR, D22IR, D23IR, 0, D25IR,
D26IR, D27IR, D28IR, D29IR, D30IR, D31IR,
};
static enum pirq map_pirq(const struct device *dev, const enum pci_pin pci_pin)
{
u8 slot = PCI_SLOT(dev->path.pci.devfn);
u8 shift = 4 * (pci_pin - PCI_INT_A);
u8 pirq;
u16 reg;
if (pci_pin < PCI_INT_A || pci_pin > PCI_INT_D) {
printk(BIOS_ERR, "ACPI_PIRQ_GEN: Slot %d PCI pin %d out of bounds\n",
slot, pci_pin);
return PIRQ_INVALID;
}
/* Slot 24 should not exist and has no D24IR but better be safe here */
if (slot < MIN_SLOT || slot > MAX_SLOT || slot == 24) {
/* non-PCH devices use 1:1 mapping. */
return (enum pirq)pci_pin;
}
reg = pirq_dir_route_reg[slot - MIN_SLOT];
pirq = (RCBA16(reg) >> shift) & 0x7;
return (enum pirq)(pirq + PIRQ_A);
}
void intel_acpi_gen_def_acpi_pirq(const struct device *lpc)
{
struct slot_pin_irq_map *pin_irq_map;
const char *lpcb_path = acpi_device_path(lpc);
struct pic_pirq_map pirq_map = {0};
unsigned int map_count = 0;
int i;
if (!lpcb_path) {
printk(BIOS_ERR, "ACPI_PIRQ_GEN: Missing LPCB ACPI path\n");
return;
}
printk(BIOS_DEBUG, "Generating ACPI PIRQ entries\n");
pin_irq_map = calloc(sizeof(struct slot_pin_irq_map), MAX_SLOTS * PCI_INT_MAX);
pirq_map.type = PIRQ_SOURCE_PATH;
for (i = 0; i < PIRQ_COUNT; i++)
snprintf(pirq_map.source_path[i], sizeof(pirq_map.source_path[i]),
"%s.LNK%c", lpcb_path, 'A' + i);
for (struct device *dev = pcidev_on_root(0, 0); dev; dev = dev->sibling) {
const u8 pci_dev = PCI_SLOT(dev->path.pci.devfn);
const u8 int_pin = pci_read_config8(dev, PCI_INTERRUPT_PIN);
if (int_pin < PCI_INT_A || int_pin > PCI_INT_D)
continue;
if (is_slot_pin_assigned(pin_irq_map, map_count, pci_dev, int_pin))
continue;
enum pirq pirq = map_pirq(dev, int_pin);
if (pirq == PIRQ_INVALID)
continue;
pin_irq_map[map_count].slot = pci_dev;
pin_irq_map[map_count].pin = (enum pci_pin)int_pin;
pin_irq_map[map_count].pic_pirq = pirq;
/* PIRQs are mapped to GSIs starting at 16 */
pin_irq_map[map_count].apic_gsi = 16 + pirq_idx(pirq);
printk(BIOS_SPEW, "ACPI_PIRQ_GEN: %s: pin=%d pirq=%zd\n",
dev_path(dev), int_pin - PCI_INT_A,
pirq_idx(pin_irq_map[map_count].pic_pirq));
map_count++;
}
intel_write_pci0_PRT(pin_irq_map, map_count, &pirq_map);
free(pin_irq_map);
}