From mboxrd@z Thu Jan 1 00:00:00 1970 Content-Type: multipart/mixed; boundary="===============7757675959827493044==" MIME-Version: 1.0 From: kelvin.cao@microchip.com To: kbuild-all@lists.01.org Subject: [PATCH 5/5] PCI/switchtec: Add check of event support Date: Fri, 24 Sep 2021 10:24:44 +0000 Message-ID: <20210924102444.4684-6-kelvin.cao@microchip.com> In-Reply-To: <20210924102444.4684-1-kelvin.cao@microchip.com> List-Id: --===============7757675959827493044== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Logan Gunthorpe 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. Signed-off-by: Logan Gunthorpe Signed-off-by: Kelvin Cao --- drivers/pci/switch/switchtec.c | 8 +++++++- include/linux/switchtec.h | 1 + 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/pci/switch/switchtec.c b/drivers/pci/switch/switchtec.c index 20cec2367084..739e063a6b85 100644 --- a/drivers/pci/switch/switchtec.c +++ b/drivers/pci/switch/switchtec.c @@ -1016,6 +1016,9 @@ static int event_ctl(struct switchtec_dev *stdev, return PTR_ERR(reg); = hdr =3D ioread32(reg); + if (hdr & SWITCHTEC_EVENT_NOT_SUPP) + return -EOPNOTSUPP; + for (i =3D 0; i < ARRAY_SIZE(ctl->data); i++) ctl->data[i] =3D ioread32(®[i + 1]); = @@ -1088,7 +1091,7 @@ static int ioctl_event_ctl(struct switchtec_dev *stde= v, for (ctl.index =3D 0; ctl.index < nr_idxs; ctl.index++) { ctl.flags =3D event_flags; ret =3D event_ctl(stdev, &ctl); - if (ret < 0) + if (ret < 0 && ret !=3D -EOPNOTSUPP) return ret; } } else { @@ -1395,6 +1398,9 @@ static int mask_event(struct switchtec_dev *stdev, in= t eid, int idx) hdr_reg =3D event_regs[eid].map_reg(stdev, off, idx); hdr =3D ioread32(hdr_reg); = + if (hdr & SWITCHTEC_EVENT_NOT_SUPP) + return 0; + if (!(hdr & SWITCHTEC_EVENT_OCCURRED && hdr & SWITCHTEC_EVENT_EN_IRQ)) return 0; = diff --git a/include/linux/switchtec.h b/include/linux/switchtec.h index 082f1d51957a..be24056ac00f 100644 --- a/include/linux/switchtec.h +++ b/include/linux/switchtec.h @@ -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) = -- = 2.25.1 --===============7757675959827493044==--