History

Merge branch 'pci/switchtec'

- Support all 255 PFF ports in switchtec driver (Wesley Sheng) - Fix unintentional switchtec MRPC event masking that degraded firmware update speed (Wesley Sheng) * pci/switchtec: switchtec: Fix unintended mask of MRPC event switchtec: Increase PFF limit from 48 to 255

Bjorn Helgaas committed 7 years ago

Commit da33ae02 parents db9d639 083c1b53 files · +42 −15Browse files

Unified · Split

3 files
  1. drivers/pci/switch/switchtec.c +29 −13
  2. include/linux/switchtec.h +1 −1
  3. include/uapi/linux/switchtec_ioctl.h +12 −1
drivers/pci/switch/switchtec.c+29−13
@@ -658,19 +658,25 @@ static int ioctl_flash_part_info(struct switchtec_dev *stdev, · 657 unmodified lines
658658
659659 static int ioctl_event_summary(struct switchtec_dev *stdev,
660660 struct switchtec_user *stuser,
661− struct switchtec_ioctl_event_summary __user *usum)
661+ struct switchtec_ioctl_event_summary __user *usum,
662+ size_t size)
662663 {
663− struct switchtec_ioctl_event_summary s = {0};
664+ struct switchtec_ioctl_event_summary *s;
664665 int i;
665666 u32 reg;
667+ int ret = 0;
666668
667− s.global = ioread32(&stdev->mmio_sw_event->global_summary);
668− s.part_bitmap = ioread32(&stdev->mmio_sw_event->part_event_bitmap);
669− s.local_part = ioread32(&stdev->mmio_part_cfg->part_event_summary);
669+ s = kzalloc(sizeof(*s), GFP_KERNEL);
670+ if (!s)
671+ return -ENOMEM;
672+
673+ s->global = ioread32(&stdev->mmio_sw_event->global_summary);
674+ s->part_bitmap = ioread32(&stdev->mmio_sw_event->part_event_bitmap);
675+ s->local_part = ioread32(&stdev->mmio_part_cfg->part_event_summary);
670676
671677 for (i = 0; i < stdev->partition_count; i++) {
672678 reg = ioread32(&stdev->mmio_part_cfg_all[i].part_event_summary);
673− s.part[i] = reg;
679+ s->part[i] = reg;
674680 }
675681
676682 for (i = 0; i < SWITCHTEC_MAX_PFF_CSR; i++) {
@@ -679,15 +685,19 @@ static int ioctl_event_summary(struct switchtec_dev *stdev, · 2 unmodified lines
679685 break;
680686
681687 reg = ioread32(&stdev->mmio_pff_csr[i].pff_event_summary);
682− s.pff[i] = reg;
688+ s->pff[i] = reg;
683689 }
684690
685− if (copy_to_user(usum, &s, sizeof(s)))
686− return -EFAULT;
691+ if (copy_to_user(usum, s, size)) {
692+ ret = -EFAULT;
693+ goto error_case;
694+ }
687695
688696 stuser->event_cnt = atomic_read(&stdev->event_cnt);
689697
690− return 0;
698+error_case:
699+ kfree(s);
700+ return ret;
691701 }
692702
693703 static u32 __iomem *global_ev_reg(struct switchtec_dev *stdev,
@@ -977,8 +987,9 @@ static long switchtec_dev_ioctl(struct file *filp, unsigned int cmd, · 283 unmodified lines
977987 case SWITCHTEC_IOCTL_FLASH_PART_INFO:
978988 rc = ioctl_flash_part_info(stdev, argp);
979989 break;
980− case SWITCHTEC_IOCTL_EVENT_SUMMARY:
981− rc = ioctl_event_summary(stdev, stuser, argp);
990+ case SWITCHTEC_IOCTL_EVENT_SUMMARY_LEGACY:
991+ rc = ioctl_event_summary(stdev, stuser, argp,
992+ sizeof(struct switchtec_ioctl_event_summary_legacy));
982993 break;
983994 case SWITCHTEC_IOCTL_EVENT_CTL:
984995 rc = ioctl_event_ctl(stdev, argp);
@@ -989,6 +1000,10 @@ static long switchtec_dev_ioctl(struct file *filp, unsigned int cmd, · 4 unmodified lines
9891000 case SWITCHTEC_IOCTL_PORT_TO_PFF:
9901001 rc = ioctl_port_to_pff(stdev, argp);
9911002 break;
1003+ case SWITCHTEC_IOCTL_EVENT_SUMMARY:
1004+ rc = ioctl_event_summary(stdev, stuser, argp,
1005+ sizeof(struct switchtec_ioctl_event_summary));
1006+ break;
9921007 default:
9931008 rc = -ENOTTY;
9941009 break;
@@ -1162,7 +1177,8 @@ static int mask_event(struct switchtec_dev *stdev, int eid, int idx) · 167 unmodified lines
11621177 if (!(hdr & SWITCHTEC_EVENT_OCCURRED && hdr & SWITCHTEC_EVENT_EN_IRQ))
11631178 return 0;
11641179
1165− if (eid == SWITCHTEC_IOCTL_EVENT_LINK_STATE)
1180+ if (eid == SWITCHTEC_IOCTL_EVENT_LINK_STATE ||
1181+ eid == SWITCHTEC_IOCTL_EVENT_MRPC_COMP)
11661182 return 0;
11671183
11681184 dev_dbg(&stdev->dev, "%s: %d %d %x\n", __func__, eid, idx, hdr);
include/linux/switchtec.h+1−1
@@ -20,7 +20,7 @@ · 19 unmodified lines
2020 #include <linux/cdev.h>
2121
2222 #define SWITCHTEC_MRPC_PAYLOAD_SIZE 1024
23−#define SWITCHTEC_MAX_PFF_CSR 48
23+#define SWITCHTEC_MAX_PFF_CSR 255
2424
2525 #define SWITCHTEC_EVENT_OCCURRED BIT(0)
2626 #define SWITCHTEC_EVENT_CLEAR BIT(0)
include/uapi/linux/switchtec_ioctl.h+12−1
@@ -50,7 +50,7 @@ struct switchtec_ioctl_flash_part_info { · 49 unmodified lines
5050 __u32 active;
5151 };
5252
53−struct switchtec_ioctl_event_summary {
53+struct switchtec_ioctl_event_summary_legacy {
5454 __u64 global;
5555 __u64 part_bitmap;
5656 __u32 local_part;
@@ -59,6 +59,15 @@ struct switchtec_ioctl_event_summary { · 2 unmodified lines
5959 __u32 pff[48];
6060 };
6161
62+struct switchtec_ioctl_event_summary {
63+ __u64 global;
64+ __u64 part_bitmap;
65+ __u32 local_part;
66+ __u32 padding;
67+ __u32 part[48];
68+ __u32 pff[255];
69+};
70+
6271 #define SWITCHTEC_IOCTL_EVENT_STACK_ERROR 0
6372 #define SWITCHTEC_IOCTL_EVENT_PPU_ERROR 1
6473 #define SWITCHTEC_IOCTL_EVENT_ISP_ERROR 2
@@ -127,6 +136,8 @@ struct switchtec_ioctl_pff_port { · 62 unmodified lines
127136 _IOWR('W', 0x41, struct switchtec_ioctl_flash_part_info)
128137 #define SWITCHTEC_IOCTL_EVENT_SUMMARY \
129138 _IOR('W', 0x42, struct switchtec_ioctl_event_summary)
139+#define SWITCHTEC_IOCTL_EVENT_SUMMARY_LEGACY \
140+ _IOR('W', 0x42, struct switchtec_ioctl_event_summary_legacy)
130141 #define SWITCHTEC_IOCTL_EVENT_CTL \
131142 _IOWR('W', 0x43, struct switchtec_ioctl_event_ctl)
132143 #define SWITCHTEC_IOCTL_PFF_TO_PORT \

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t