Skip to content

Commit

Permalink
PCI/switchtec: Add check of event support
Browse files Browse the repository at this point in the history
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/[email protected]
Signed-off-by: Logan Gunthorpe <[email protected]>
Signed-off-by: Kelvin Cao <[email protected]>
Signed-off-by: Bjorn Helgaas <[email protected]>
  • Loading branch information
lsgunth authored and bjorn-helgaas committed Oct 14, 2021
1 parent 6711644 commit 9f37ab0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
8 changes: 7 additions & 1 deletion drivers/pci/switch/switchtec.c
Original file line number Diff line number Diff line change
Expand Up @@ -1024,6 +1024,9 @@ static int event_ctl(struct switchtec_dev *stdev,
return PTR_ERR(reg);

hdr = ioread32(reg);
if (hdr & SWITCHTEC_EVENT_NOT_SUPP)
return -EOPNOTSUPP;

for (i = 0; i < ARRAY_SIZE(ctl->data); i++)
ctl->data[i] = ioread32(&reg[i + 1]);

Expand Down Expand Up @@ -1096,7 +1099,7 @@ static int ioctl_event_ctl(struct switchtec_dev *stdev,
for (ctl.index = 0; ctl.index < nr_idxs; ctl.index++) {
ctl.flags = event_flags;
ret = event_ctl(stdev, &ctl);
if (ret < 0)
if (ret < 0 && ret != -EOPNOTSUPP)
return ret;
}
} else {
Expand Down Expand Up @@ -1403,6 +1406,9 @@ static int mask_event(struct switchtec_dev *stdev, int eid, int idx)
hdr_reg = event_regs[eid].map_reg(stdev, off, idx);
hdr = ioread32(hdr_reg);

if (hdr & SWITCHTEC_EVENT_NOT_SUPP)
return 0;

if (!(hdr & SWITCHTEC_EVENT_OCCURRED && hdr & SWITCHTEC_EVENT_EN_IRQ))
return 0;

Expand Down
1 change: 1 addition & 0 deletions include/linux/switchtec.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#define SWITCHTEC_EVENT_EN_CLI BIT(2)
#define SWITCHTEC_EVENT_EN_IRQ BIT(3)
#define SWITCHTEC_EVENT_FATAL BIT(4)
#define SWITCHTEC_EVENT_NOT_SUPP BIT(31)

#define SWITCHTEC_DMA_MRPC_EN BIT(0)

Expand Down

0 comments on commit 9f37ab0

Please sign in to comment.