hc
2023-12-09 b22da3d8526a935aa31e086e63f60ff3246cb61c
kernel/drivers/scsi/pm8001/pm8001_ctl.c
....@@ -47,6 +47,7 @@
4747 /**
4848 * pm8001_ctl_mpi_interface_rev_show - MPI interface revision number
4949 * @cdev: pointer to embedded class device
50
+ * @attr: device attribute (unused)
5051 * @buf: the buffer returned
5152 *
5253 * A sysfs 'read-only' shost attribute.
....@@ -70,8 +71,29 @@
7071 DEVICE_ATTR(interface_rev, S_IRUGO, pm8001_ctl_mpi_interface_rev_show, NULL);
7172
7273 /**
74
+ * controller_fatal_error_show - check controller is under fatal err
75
+ * @cdev: pointer to embedded class device
76
+ * @attr: device attribute (unused)
77
+ * @buf: the buffer returned
78
+ *
79
+ * A sysfs 'read only' shost attribute.
80
+ */
81
+static ssize_t controller_fatal_error_show(struct device *cdev,
82
+ struct device_attribute *attr, char *buf)
83
+{
84
+ struct Scsi_Host *shost = class_to_shost(cdev);
85
+ struct sas_ha_struct *sha = SHOST_TO_SAS_HA(shost);
86
+ struct pm8001_hba_info *pm8001_ha = sha->lldd_ha;
87
+
88
+ return snprintf(buf, PAGE_SIZE, "%d\n",
89
+ pm8001_ha->controller_fatal_error);
90
+}
91
+static DEVICE_ATTR_RO(controller_fatal_error);
92
+
93
+/**
7394 * pm8001_ctl_fw_version_show - firmware version
7495 * @cdev: pointer to embedded class device
96
+ * @attr: device attribute (unused)
7597 * @buf: the buffer returned
7698 *
7799 * A sysfs 'read-only' shost attribute.
....@@ -102,6 +124,7 @@
102124 /**
103125 * pm8001_ctl_ila_version_show - ila version
104126 * @cdev: pointer to embedded class device
127
+ * @attr: device attribute (unused)
105128 * @buf: the buffer returned
106129 *
107130 * A sysfs 'read-only' shost attribute.
....@@ -127,6 +150,7 @@
127150 /**
128151 * pm8001_ctl_inactive_fw_version_show - Inacative firmware version number
129152 * @cdev: pointer to embedded class device
153
+ * @attr: device attribute (unused)
130154 * @buf: the buffer returned
131155 *
132156 * A sysfs 'read-only' shost attribute.
....@@ -153,6 +177,7 @@
153177 /**
154178 * pm8001_ctl_max_out_io_show - max outstanding io supported
155179 * @cdev: pointer to embedded class device
180
+ * @attr: device attribute (unused)
156181 * @buf: the buffer returned
157182 *
158183 * A sysfs 'read-only' shost attribute.
....@@ -176,6 +201,7 @@
176201 /**
177202 * pm8001_ctl_max_devices_show - max devices support
178203 * @cdev: pointer to embedded class device
204
+ * @attr: device attribute (unused)
179205 * @buf: the buffer returned
180206 *
181207 * A sysfs 'read-only' shost attribute.
....@@ -202,6 +228,7 @@
202228 * pm8001_ctl_max_sg_list_show - max sg list supported iff not 0.0 for no
203229 * hardware limitation
204230 * @cdev: pointer to embedded class device
231
+ * @attr: device attribute (unused)
205232 * @buf: the buffer returned
206233 *
207234 * A sysfs 'read-only' shost attribute.
....@@ -246,6 +273,7 @@
246273 /**
247274 * pm8001_ctl_sas_spec_support_show - sas spec supported
248275 * @cdev: pointer to embedded class device
276
+ * @attr: device attribute (unused)
249277 * @buf: the buffer returned
250278 *
251279 * A sysfs 'read-only' shost attribute.
....@@ -273,6 +301,7 @@
273301 /**
274302 * pm8001_ctl_sas_address_show - sas address
275303 * @cdev: pointer to embedded class device
304
+ * @attr: device attribute (unused)
276305 * @buf: the buffer returned
277306 *
278307 * This is the controller sas address
....@@ -294,6 +323,7 @@
294323 /**
295324 * pm8001_ctl_logging_level_show - logging level
296325 * @cdev: pointer to embedded class device
326
+ * @attr: device attribute (unused)
297327 * @buf: the buffer returned
298328 *
299329 * A sysfs 'read/write' shost attribute.
....@@ -307,6 +337,7 @@
307337
308338 return snprintf(buf, PAGE_SIZE, "%08xh\n", pm8001_ha->logging_level);
309339 }
340
+
310341 static ssize_t pm8001_ctl_logging_level_store(struct device *cdev,
311342 struct device_attribute *attr, const char *buf, size_t count)
312343 {
....@@ -327,6 +358,7 @@
327358 /**
328359 * pm8001_ctl_aap_log_show - aap1 event log
329360 * @cdev: pointer to embedded class device
361
+ * @attr: device attribute (unused)
330362 * @buf: the buffer returned
331363 *
332364 * A sysfs 'read-only' shost attribute.
....@@ -363,6 +395,7 @@
363395 /**
364396 * pm8001_ctl_ib_queue_log_show - Out bound Queue log
365397 * @cdev:pointer to embedded class device
398
+ * @attr: device attribute (unused)
366399 * @buf: the buffer returned
367400 * A sysfs 'read-only' shost attribute.
368401 */
....@@ -375,9 +408,10 @@
375408 int offset;
376409 char *str = buf;
377410 int start = 0;
411
+ u32 ib_offset = pm8001_ha->ib_offset;
378412 #define IB_MEMMAP(c) \
379413 (*(u32 *)((u8 *)pm8001_ha-> \
380
- memoryMap.region[IB].virt_ptr + \
414
+ memoryMap.region[ib_offset].virt_ptr + \
381415 pm8001_ha->evtlog_ib_offset + (c)))
382416
383417 for (offset = 0; offset < IB_OB_READ_TIMES; offset++) {
....@@ -395,6 +429,7 @@
395429 /**
396430 * pm8001_ctl_ob_queue_log_show - Out bound Queue log
397431 * @cdev:pointer to embedded class device
432
+ * @attr: device attribute (unused)
398433 * @buf: the buffer returned
399434 * A sysfs 'read-only' shost attribute.
400435 */
....@@ -408,9 +443,10 @@
408443 int offset;
409444 char *str = buf;
410445 int start = 0;
446
+ u32 ob_offset = pm8001_ha->ob_offset;
411447 #define OB_MEMMAP(c) \
412448 (*(u32 *)((u8 *)pm8001_ha-> \
413
- memoryMap.region[OB].virt_ptr + \
449
+ memoryMap.region[ob_offset].virt_ptr + \
414450 pm8001_ha->evtlog_ob_offset + (c)))
415451
416452 for (offset = 0; offset < IB_OB_READ_TIMES; offset++) {
....@@ -427,6 +463,7 @@
427463 /**
428464 * pm8001_ctl_bios_version_show - Bios version Display
429465 * @cdev:pointer to embedded class device
466
+ * @attr: device attribute (unused)
430467 * @buf:the buffer returned
431468 * A sysfs 'read-only' shost attribute.
432469 */
....@@ -444,7 +481,7 @@
444481 pm8001_ha->nvmd_completion = &completion;
445482 payload.minor_function = 7;
446483 payload.offset = 0;
447
- payload.length = 4096;
484
+ payload.rd_length = 4096;
448485 payload.func_specific = kzalloc(4096, GFP_KERNEL);
449486 if (!payload.func_specific)
450487 return -ENOMEM;
....@@ -462,8 +499,28 @@
462499 }
463500 static DEVICE_ATTR(bios_version, S_IRUGO, pm8001_ctl_bios_version_show, NULL);
464501 /**
502
+ * event_log_size_show - event log size
503
+ * @cdev: pointer to embedded class device
504
+ * @attr: device attribute (unused)
505
+ * @buf: the buffer returned
506
+ *
507
+ * A sysfs read shost attribute.
508
+ */
509
+static ssize_t event_log_size_show(struct device *cdev,
510
+ struct device_attribute *attr, char *buf)
511
+{
512
+ struct Scsi_Host *shost = class_to_shost(cdev);
513
+ struct sas_ha_struct *sha = SHOST_TO_SAS_HA(shost);
514
+ struct pm8001_hba_info *pm8001_ha = sha->lldd_ha;
515
+
516
+ return snprintf(buf, PAGE_SIZE, "%d\n",
517
+ pm8001_ha->main_cfg_tbl.pm80xx_tbl.event_log_size);
518
+}
519
+static DEVICE_ATTR_RO(event_log_size);
520
+/**
465521 * pm8001_ctl_aap_log_show - IOP event log
466522 * @cdev: pointer to embedded class device
523
+ * @attr: device attribute (unused)
467524 * @buf: the buffer returned
468525 *
469526 * A sysfs 'read-only' shost attribute.
....@@ -474,25 +531,26 @@
474531 struct Scsi_Host *shost = class_to_shost(cdev);
475532 struct sas_ha_struct *sha = SHOST_TO_SAS_HA(shost);
476533 struct pm8001_hba_info *pm8001_ha = sha->lldd_ha;
477
-#define IOP_MEMMAP(r, c) \
478
- (*(u32 *)((u8*)pm8001_ha->memoryMap.region[IOP].virt_ptr + (r) * 32 \
479
- + (c)))
480
- int i;
481534 char *str = buf;
482
- int max = 2;
483
- for (i = 0; i < max; i++) {
484
- str += sprintf(str, "0x%08x 0x%08x 0x%08x 0x%08x 0x%08x 0x%08x"
485
- "0x%08x 0x%08x\n",
486
- IOP_MEMMAP(i, 0),
487
- IOP_MEMMAP(i, 4),
488
- IOP_MEMMAP(i, 8),
489
- IOP_MEMMAP(i, 12),
490
- IOP_MEMMAP(i, 16),
491
- IOP_MEMMAP(i, 20),
492
- IOP_MEMMAP(i, 24),
493
- IOP_MEMMAP(i, 28));
535
+ u32 read_size =
536
+ pm8001_ha->main_cfg_tbl.pm80xx_tbl.event_log_size / 1024;
537
+ static u32 start, end, count;
538
+ u32 max_read_times = 32;
539
+ u32 max_count = (read_size * 1024) / (max_read_times * 4);
540
+ u32 *temp = (u32 *)pm8001_ha->memoryMap.region[IOP].virt_ptr;
541
+
542
+ if ((count % max_count) == 0) {
543
+ start = 0;
544
+ end = max_read_times;
545
+ count = 0;
546
+ } else {
547
+ start = end;
548
+ end = end + max_read_times;
494549 }
495550
551
+ for (; start < end; start++)
552
+ str += sprintf(str, "%08x ", *(temp+start));
553
+ count++;
496554 return str - buf;
497555 }
498556 static DEVICE_ATTR(iop_log, S_IRUGO, pm8001_ctl_iop_log_show, NULL);
....@@ -500,6 +558,7 @@
500558 /**
501559 ** pm8001_ctl_fatal_log_show - fatal error logging
502560 ** @cdev:pointer to embedded class device
561
+ ** @attr: device attribute
503562 ** @buf: the buffer returned
504563 **
505564 ** A sysfs 'read-only' shost attribute.
....@@ -516,12 +575,57 @@
516575
517576 static DEVICE_ATTR(fatal_log, S_IRUGO, pm8001_ctl_fatal_log_show, NULL);
518577
578
+/**
579
+ ** non_fatal_log_show - non fatal error logging
580
+ ** @cdev:pointer to embedded class device
581
+ ** @attr: device attribute
582
+ ** @buf: the buffer returned
583
+ **
584
+ ** A sysfs 'read-only' shost attribute.
585
+ **/
586
+static ssize_t non_fatal_log_show(struct device *cdev,
587
+ struct device_attribute *attr, char *buf)
588
+{
589
+ u32 count;
590
+
591
+ count = pm80xx_get_non_fatal_dump(cdev, attr, buf);
592
+ return count;
593
+}
594
+static DEVICE_ATTR_RO(non_fatal_log);
595
+
596
+static ssize_t non_fatal_count_show(struct device *cdev,
597
+ struct device_attribute *attr, char *buf)
598
+{
599
+ struct Scsi_Host *shost = class_to_shost(cdev);
600
+ struct sas_ha_struct *sha = SHOST_TO_SAS_HA(shost);
601
+ struct pm8001_hba_info *pm8001_ha = sha->lldd_ha;
602
+
603
+ return snprintf(buf, PAGE_SIZE, "%08x",
604
+ pm8001_ha->non_fatal_count);
605
+}
606
+
607
+static ssize_t non_fatal_count_store(struct device *cdev,
608
+ struct device_attribute *attr, const char *buf, size_t count)
609
+{
610
+ struct Scsi_Host *shost = class_to_shost(cdev);
611
+ struct sas_ha_struct *sha = SHOST_TO_SAS_HA(shost);
612
+ struct pm8001_hba_info *pm8001_ha = sha->lldd_ha;
613
+ int val = 0;
614
+
615
+ if (kstrtoint(buf, 16, &val) != 0)
616
+ return -EINVAL;
617
+
618
+ pm8001_ha->non_fatal_count = val;
619
+ return strlen(buf);
620
+}
621
+static DEVICE_ATTR_RW(non_fatal_count);
519622
520623 /**
521624 ** pm8001_ctl_gsm_log_show - gsm dump collection
522625 ** @cdev:pointer to embedded class device
626
+ ** @attr: device attribute (unused)
523627 ** @buf: the buffer returned
524
- **A sysfs 'read-only' shost attribute.
628
+ ** A sysfs 'read-only' shost attribute.
525629 **/
526630 static ssize_t pm8001_ctl_gsm_log_show(struct device *cdev,
527631 struct device_attribute *attr, char *buf)
....@@ -593,7 +697,7 @@
593697 payload = (struct pm8001_ioctl_payload *)ioctlbuffer;
594698 memcpy((u8 *)&payload->func_specific, (u8 *)pm8001_ha->fw_image->data,
595699 pm8001_ha->fw_image->size);
596
- payload->length = pm8001_ha->fw_image->size;
700
+ payload->wr_length = pm8001_ha->fw_image->size;
597701 payload->id = 0;
598702 payload->minor_function = 0x1;
599703 pm8001_ha->nvmd_completion = &completion;
....@@ -639,7 +743,7 @@
639743 IOCTL_BUF_SIZE);
640744 for (loopNumber = 0; loopNumber < loopcount; loopNumber++) {
641745 payload = (struct pm8001_ioctl_payload *)ioctlbuffer;
642
- payload->length = 1024*16;
746
+ payload->wr_length = 1024*16;
643747 payload->id = 0;
644748 fwControl =
645749 (struct fw_control_info *)&payload->func_specific;
....@@ -737,10 +841,9 @@
737841 pm8001_ha->dev);
738842
739843 if (ret) {
740
- PM8001_FAIL_DBG(pm8001_ha,
741
- pm8001_printk(
742
- "Failed to load firmware image file %s, error %d\n",
743
- filename_ptr, ret));
844
+ pm8001_dbg(pm8001_ha, FAIL,
845
+ "Failed to load firmware image file %s, error %d\n",
846
+ filename_ptr, ret);
744847 pm8001_ha->fw_status = FAIL_OPEN_BIOS_FILE;
745848 goto out;
746849 }
....@@ -785,17 +888,21 @@
785888 pm8001_show_update_fw, pm8001_store_update_fw);
786889 struct device_attribute *pm8001_host_attrs[] = {
787890 &dev_attr_interface_rev,
891
+ &dev_attr_controller_fatal_error,
788892 &dev_attr_fw_version,
789893 &dev_attr_update_fw,
790894 &dev_attr_aap_log,
791895 &dev_attr_iop_log,
792896 &dev_attr_fatal_log,
897
+ &dev_attr_non_fatal_log,
898
+ &dev_attr_non_fatal_count,
793899 &dev_attr_gsm_log,
794900 &dev_attr_max_out_io,
795901 &dev_attr_max_devices,
796902 &dev_attr_max_sg_list,
797903 &dev_attr_sas_spec_support,
798904 &dev_attr_logging_level,
905
+ &dev_attr_event_log_size,
799906 &dev_attr_host_sas_address,
800907 &dev_attr_bios_version,
801908 &dev_attr_ib_log,