aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/hisi_sas
diff options
context:
space:
mode:
authorJohn Garry <john.garry@huawei.com>2015-11-17 11:50:52 -0500
committerMartin K. Petersen <martin.petersen@oracle.com>2015-11-25 22:13:04 -0500
commit184a4635340be6e0e804240ff889c3c82d6e4745 (patch)
tree310a09872105222eb2267a42d77a4af0d9d76b3a /drivers/scsi/hisi_sas
parentabda97c2fe874cd8826fe25a77f66c75bcc7b5cd (diff)
hisi_sas: Add abnormal irq handler
Add abnormal irq handler. This handler is concerned with phy down event. Also add port formed and port deformed handlers. Signed-off-by: John Garry <john.garry@huawei.com> Reviewed-by: Arnd Bergmann <arnd@arndb.de> Reviewed-by: Hannes Reinecke <hare@suse.de> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Diffstat (limited to 'drivers/scsi/hisi_sas')
-rw-r--r--drivers/scsi/hisi_sas/hisi_sas.h2
-rw-r--r--drivers/scsi/hisi_sas/hisi_sas_main.c118
-rw-r--r--drivers/scsi/hisi_sas/hisi_sas_v1_hw.c70
3 files changed, 190 insertions, 0 deletions
diff --git a/drivers/scsi/hisi_sas/hisi_sas.h b/drivers/scsi/hisi_sas/hisi_sas.h
index 999f31955bee..e5ee3c90f7b5 100644
--- a/drivers/scsi/hisi_sas/hisi_sas.h
+++ b/drivers/scsi/hisi_sas/hisi_sas.h
@@ -136,6 +136,7 @@ struct hisi_sas_hw {
136 struct hisi_sas_slot *slot, int abort); 136 struct hisi_sas_slot *slot, int abort);
137 void (*free_device)(struct hisi_hba *hisi_hba, 137 void (*free_device)(struct hisi_hba *hisi_hba,
138 struct hisi_sas_device *dev); 138 struct hisi_sas_device *dev);
139 int (*get_wideport_bitmap)(struct hisi_hba *hisi_hba, int port_id);
139 int complete_hdr_size; 140 int complete_hdr_size;
140}; 141};
141 142
@@ -330,6 +331,7 @@ extern int hisi_sas_probe(struct platform_device *pdev,
330 const struct hisi_sas_hw *ops); 331 const struct hisi_sas_hw *ops);
331extern int hisi_sas_remove(struct platform_device *pdev); 332extern int hisi_sas_remove(struct platform_device *pdev);
332 333
334extern void hisi_sas_phy_down(struct hisi_hba *hisi_hba, int phy_no, int rdy);
333extern void hisi_sas_slot_task_free(struct hisi_hba *hisi_hba, 335extern void hisi_sas_slot_task_free(struct hisi_hba *hisi_hba,
334 struct sas_task *task, 336 struct sas_task *task,
335 struct hisi_sas_slot *slot); 337 struct hisi_sas_slot *slot);
diff --git a/drivers/scsi/hisi_sas/hisi_sas_main.c b/drivers/scsi/hisi_sas/hisi_sas_main.c
index d8af4c64cd51..17978510c4f2 100644
--- a/drivers/scsi/hisi_sas/hisi_sas_main.c
+++ b/drivers/scsi/hisi_sas/hisi_sas_main.c
@@ -431,6 +431,72 @@ static void hisi_sas_phy_init(struct hisi_hba *hisi_hba, int phy_no)
431 INIT_WORK(&phy->phyup_ws, hisi_sas_phyup_work); 431 INIT_WORK(&phy->phyup_ws, hisi_sas_phyup_work);
432} 432}
433 433
434static void hisi_sas_port_notify_formed(struct asd_sas_phy *sas_phy)
435{
436 struct sas_ha_struct *sas_ha = sas_phy->ha;
437 struct hisi_hba *hisi_hba = sas_ha->lldd_ha;
438 struct hisi_sas_phy *phy = sas_phy->lldd_phy;
439 struct asd_sas_port *sas_port = sas_phy->port;
440 struct hisi_sas_port *port = &hisi_hba->port[sas_phy->id];
441 unsigned long flags;
442
443 if (!sas_port)
444 return;
445
446 spin_lock_irqsave(&hisi_hba->lock, flags);
447 port->port_attached = 1;
448 port->id = phy->port_id;
449 phy->port = port;
450 sas_port->lldd_port = port;
451 spin_unlock_irqrestore(&hisi_hba->lock, flags);
452}
453
454static void hisi_sas_do_release_task(struct hisi_hba *hisi_hba, int phy_no,
455 struct domain_device *device)
456{
457 struct hisi_sas_phy *phy;
458 struct hisi_sas_port *port;
459 struct hisi_sas_slot *slot, *slot2;
460 struct device *dev = &hisi_hba->pdev->dev;
461
462 phy = &hisi_hba->phy[phy_no];
463 port = phy->port;
464 if (!port)
465 return;
466
467 list_for_each_entry_safe(slot, slot2, &port->list, entry) {
468 struct sas_task *task;
469
470 task = slot->task;
471 if (device && task->dev != device)
472 continue;
473
474 dev_info(dev, "Release slot [%d:%d], task [%p]:\n",
475 slot->dlvry_queue, slot->dlvry_queue_slot, task);
476 hisi_hba->hw->slot_complete(hisi_hba, slot, 1);
477 }
478}
479
480static void hisi_sas_port_notify_deformed(struct asd_sas_phy *sas_phy)
481{
482 struct domain_device *device;
483 struct hisi_sas_phy *phy = sas_phy->lldd_phy;
484 struct asd_sas_port *sas_port = sas_phy->port;
485
486 list_for_each_entry(device, &sas_port->dev_list, dev_list_node)
487 hisi_sas_do_release_task(phy->hisi_hba, sas_phy->id, device);
488}
489
490static void hisi_sas_release_task(struct hisi_hba *hisi_hba,
491 struct domain_device *device)
492{
493 struct asd_sas_port *port = device->port;
494 struct asd_sas_phy *sas_phy;
495
496 list_for_each_entry(sas_phy, &port->phy_list, port_phy_el)
497 hisi_sas_do_release_task(hisi_hba, sas_phy->id, device);
498}
499
434static void hisi_sas_dev_gone(struct domain_device *device) 500static void hisi_sas_dev_gone(struct domain_device *device)
435{ 501{
436 struct hisi_sas_device *sas_dev = device->lldd_dev; 502 struct hisi_sas_device *sas_dev = device->lldd_dev;
@@ -454,6 +520,56 @@ static int hisi_sas_queue_command(struct sas_task *task, gfp_t gfp_flags)
454 return hisi_sas_task_exec(task, gfp_flags, 0, NULL); 520 return hisi_sas_task_exec(task, gfp_flags, 0, NULL);
455} 521}
456 522
523
524static void hisi_sas_port_formed(struct asd_sas_phy *sas_phy)
525{
526 hisi_sas_port_notify_formed(sas_phy);
527}
528
529static void hisi_sas_port_deformed(struct asd_sas_phy *sas_phy)
530{
531 hisi_sas_port_notify_deformed(sas_phy);
532}
533
534static void hisi_sas_phy_disconnected(struct hisi_sas_phy *phy)
535{
536 phy->phy_attached = 0;
537 phy->phy_type = 0;
538 phy->port = NULL;
539}
540
541void hisi_sas_phy_down(struct hisi_hba *hisi_hba, int phy_no, int rdy)
542{
543 struct hisi_sas_phy *phy = &hisi_hba->phy[phy_no];
544 struct asd_sas_phy *sas_phy = &phy->sas_phy;
545 struct sas_ha_struct *sas_ha = &hisi_hba->sha;
546
547 if (rdy) {
548 /* Phy down but ready */
549 hisi_sas_bytes_dmaed(hisi_hba, phy_no);
550 hisi_sas_port_notify_formed(sas_phy);
551 } else {
552 struct hisi_sas_port *port = phy->port;
553
554 /* Phy down and not ready */
555 sas_ha->notify_phy_event(sas_phy, PHYE_LOSS_OF_SIGNAL);
556 sas_phy_disconnected(sas_phy);
557
558 if (port) {
559 if (phy->phy_type & PORT_TYPE_SAS) {
560 int port_id = port->id;
561
562 if (!hisi_hba->hw->get_wideport_bitmap(hisi_hba,
563 port_id))
564 port->port_attached = 0;
565 } else if (phy->phy_type & PORT_TYPE_SATA)
566 port->port_attached = 0;
567 }
568 hisi_sas_phy_disconnected(phy);
569 }
570}
571EXPORT_SYMBOL_GPL(hisi_sas_phy_down);
572
457static struct scsi_transport_template *hisi_sas_stt; 573static struct scsi_transport_template *hisi_sas_stt;
458 574
459static struct scsi_host_template hisi_sas_sht = { 575static struct scsi_host_template hisi_sas_sht = {
@@ -479,6 +595,8 @@ static struct sas_domain_function_template hisi_sas_transport_ops = {
479 .lldd_dev_found = hisi_sas_dev_found, 595 .lldd_dev_found = hisi_sas_dev_found,
480 .lldd_dev_gone = hisi_sas_dev_gone, 596 .lldd_dev_gone = hisi_sas_dev_gone,
481 .lldd_execute_task = hisi_sas_queue_command, 597 .lldd_execute_task = hisi_sas_queue_command,
598 .lldd_port_formed = hisi_sas_port_formed,
599 .lldd_port_deformed = hisi_sas_port_deformed,
482}; 600};
483 601
484static int hisi_sas_alloc(struct hisi_hba *hisi_hba, struct Scsi_Host *shost) 602static int hisi_sas_alloc(struct hisi_hba *hisi_hba, struct Scsi_Host *shost)
diff --git a/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c
index 530e77152bc6..1723dd453e06 100644
--- a/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c
+++ b/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c
@@ -810,6 +810,18 @@ static void sl_notify_v1_hw(struct hisi_hba *hisi_hba, int phy_no)
810 hisi_sas_phy_write32(hisi_hba, phy_no, SL_CONTROL, sl_control); 810 hisi_sas_phy_write32(hisi_hba, phy_no, SL_CONTROL, sl_control);
811} 811}
812 812
813static int get_wideport_bitmap_v1_hw(struct hisi_hba *hisi_hba, int port_id)
814{
815 int i, bitmap = 0;
816 u32 phy_port_num_ma = hisi_sas_read32(hisi_hba, PHY_PORT_NUM_MA);
817
818 for (i = 0; i < hisi_hba->n_phy; i++)
819 if (((phy_port_num_ma >> (i * 4)) & 0xf) == port_id)
820 bitmap |= 1 << i;
821
822 return bitmap;
823}
824
813/** 825/**
814 * This function allocates across all queues to load balance. 826 * This function allocates across all queues to load balance.
815 * Slots are allocated from queues in a round-robin fashion. 827 * Slots are allocated from queues in a round-robin fashion.
@@ -1321,6 +1333,61 @@ end:
1321 return res; 1333 return res;
1322} 1334}
1323 1335
1336static irqreturn_t int_abnormal_v1_hw(int irq, void *p)
1337{
1338 struct hisi_sas_phy *phy = p;
1339 struct hisi_hba *hisi_hba = phy->hisi_hba;
1340 struct device *dev = &hisi_hba->pdev->dev;
1341 struct asd_sas_phy *sas_phy = &phy->sas_phy;
1342 u32 irq_value, irq_mask_old;
1343 int phy_no = sas_phy->id;
1344
1345 /* mask_int0 */
1346 irq_mask_old = hisi_sas_phy_read32(hisi_hba, phy_no, CHL_INT0_MSK);
1347 hisi_sas_phy_write32(hisi_hba, phy_no, CHL_INT0_MSK, 0x3fffff);
1348
1349 /* read int0 */
1350 irq_value = hisi_sas_phy_read32(hisi_hba, phy_no, CHL_INT0);
1351
1352 if (irq_value & CHL_INT0_PHYCTRL_NOTRDY_MSK) {
1353 u32 phy_state = hisi_sas_read32(hisi_hba, PHY_STATE);
1354
1355 hisi_sas_phy_down(hisi_hba, phy_no,
1356 (phy_state & 1 << phy_no) ? 1 : 0);
1357 }
1358
1359 if (irq_value & CHL_INT0_ID_TIMEOUT_MSK)
1360 dev_dbg(dev, "abnormal: ID_TIMEOUT phy%d identify timeout\n",
1361 phy_no);
1362
1363 if (irq_value & CHL_INT0_DWS_LOST_MSK)
1364 dev_dbg(dev, "abnormal: DWS_LOST phy%d dws lost\n", phy_no);
1365
1366 if (irq_value & CHL_INT0_SN_FAIL_NGR_MSK)
1367 dev_dbg(dev, "abnormal: SN_FAIL_NGR phy%d sn fail ngr\n",
1368 phy_no);
1369
1370 if (irq_value & CHL_INT0_SL_IDAF_FAIL_MSK ||
1371 irq_value & CHL_INT0_SL_OPAF_FAIL_MSK)
1372 dev_dbg(dev, "abnormal: SL_ID/OPAF_FAIL phy%d check adr frm err\n",
1373 phy_no);
1374
1375 if (irq_value & CHL_INT0_SL_PS_FAIL_OFF)
1376 dev_dbg(dev, "abnormal: SL_PS_FAIL phy%d fail\n", phy_no);
1377
1378 /* write to zero */
1379 hisi_sas_phy_write32(hisi_hba, phy_no, CHL_INT0, irq_value);
1380
1381 if (irq_value & CHL_INT0_PHYCTRL_NOTRDY_MSK)
1382 hisi_sas_phy_write32(hisi_hba, phy_no, CHL_INT0_MSK,
1383 0x3fffff & ~CHL_INT0_MSK_PHYCTRL_NOTRDY_MSK);
1384 else
1385 hisi_sas_phy_write32(hisi_hba, phy_no, CHL_INT0_MSK,
1386 irq_mask_old);
1387
1388 return IRQ_HANDLED;
1389}
1390
1324static irqreturn_t cq_interrupt_v1_hw(int irq, void *p) 1391static irqreturn_t cq_interrupt_v1_hw(int irq, void *p)
1325{ 1392{
1326 struct hisi_sas_cq *cq = p; 1393 struct hisi_sas_cq *cq = p;
@@ -1372,11 +1439,13 @@ static irqreturn_t cq_interrupt_v1_hw(int irq, void *p)
1372 1439
1373static const char phy_int_names[HISI_SAS_PHY_INT_NR][32] = { 1440static const char phy_int_names[HISI_SAS_PHY_INT_NR][32] = {
1374 {"Phy Up"}, 1441 {"Phy Up"},
1442 {"Abnormal"},
1375}; 1443};
1376 1444
1377static const char cq_int_name[32] = "cq"; 1445static const char cq_int_name[32] = "cq";
1378static irq_handler_t phy_interrupts[HISI_SAS_PHY_INT_NR] = { 1446static irq_handler_t phy_interrupts[HISI_SAS_PHY_INT_NR] = {
1379 int_phyup_v1_hw, 1447 int_phyup_v1_hw,
1448 int_abnormal_v1_hw
1380}; 1449};
1381 1450
1382static int interrupt_init_v1_hw(struct hisi_hba *hisi_hba) 1451static int interrupt_init_v1_hw(struct hisi_hba *hisi_hba)
@@ -1499,6 +1568,7 @@ static const struct hisi_sas_hw hisi_sas_v1_hw = {
1499 .get_free_slot = get_free_slot_v1_hw, 1568 .get_free_slot = get_free_slot_v1_hw,
1500 .start_delivery = start_delivery_v1_hw, 1569 .start_delivery = start_delivery_v1_hw,
1501 .slot_complete = slot_complete_v1_hw, 1570 .slot_complete = slot_complete_v1_hw,
1571 .get_wideport_bitmap = get_wideport_bitmap_v1_hw,
1502 .complete_hdr_size = sizeof(struct hisi_sas_complete_v1_hdr), 1572 .complete_hdr_size = sizeof(struct hisi_sas_complete_v1_hdr),
1503}; 1573};
1504 1574