Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

PCI/switchtec: Add check of event support

Not all events are supported by every gen/variant of the Switchtec
firmware. To solve this, since Gen4, a new bit in each event header
is introduced to indicate if an event is supported by the firmware.

Link: https://lore.kernel.org/r/20211014141859.11444-6-kelvin.cao@microchip.com
Signed-off-by: Logan Gunthorpe <logang@deltatee.com>
Signed-off-by: Kelvin Cao <kelvin.cao@microchip.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>

authored by

Logan Gunthorpe and committed by
Bjorn Helgaas
9f37ab04 67116444

+8 -1
+7 -1
drivers/pci/switch/switchtec.c
··· 1024 1024 return PTR_ERR(reg); 1025 1025 1026 1026 hdr = ioread32(reg); 1027 + if (hdr & SWITCHTEC_EVENT_NOT_SUPP) 1028 + return -EOPNOTSUPP; 1029 + 1027 1030 for (i = 0; i < ARRAY_SIZE(ctl->data); i++) 1028 1031 ctl->data[i] = ioread32(&reg[i + 1]); 1029 1032 ··· 1099 1096 for (ctl.index = 0; ctl.index < nr_idxs; ctl.index++) { 1100 1097 ctl.flags = event_flags; 1101 1098 ret = event_ctl(stdev, &ctl); 1102 - if (ret < 0) 1099 + if (ret < 0 && ret != -EOPNOTSUPP) 1103 1100 return ret; 1104 1101 } 1105 1102 } else { ··· 1405 1402 1406 1403 hdr_reg = event_regs[eid].map_reg(stdev, off, idx); 1407 1404 hdr = ioread32(hdr_reg); 1405 + 1406 + if (hdr & SWITCHTEC_EVENT_NOT_SUPP) 1407 + return 0; 1408 1408 1409 1409 if (!(hdr & SWITCHTEC_EVENT_OCCURRED && hdr & SWITCHTEC_EVENT_EN_IRQ)) 1410 1410 return 0;
+1
include/linux/switchtec.h
··· 19 19 #define SWITCHTEC_EVENT_EN_CLI BIT(2) 20 20 #define SWITCHTEC_EVENT_EN_IRQ BIT(3) 21 21 #define SWITCHTEC_EVENT_FATAL BIT(4) 22 + #define SWITCHTEC_EVENT_NOT_SUPP BIT(31) 22 23 23 24 #define SWITCHTEC_DMA_MRPC_EN BIT(0) 24 25