.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
---|
1 | 2 | /* |
---|
2 | 3 | * Copyright (c) 2016 Linaro Ltd. |
---|
3 | 4 | * Copyright (c) 2016 Hisilicon Limited. |
---|
4 | | - * |
---|
5 | | - * This program is free software; you can redistribute it and/or modify |
---|
6 | | - * it under the terms of the GNU General Public License as published by |
---|
7 | | - * the Free Software Foundation; either version 2 of the License, or |
---|
8 | | - * (at your option) any later version. |
---|
9 | | - * |
---|
10 | 5 | */ |
---|
11 | 6 | |
---|
12 | 7 | #include "hisi_sas.h" |
---|
.. | .. |
---|
427 | 422 | .irq_msk = BIT(SAS_ECC_INTR_DQE_ECC_1B_OFF), |
---|
428 | 423 | .msk = HGC_DQE_ECC_1B_ADDR_MSK, |
---|
429 | 424 | .shift = HGC_DQE_ECC_1B_ADDR_OFF, |
---|
430 | | - .msg = "hgc_dqe_acc1b_intr found: Ram address is 0x%08X\n", |
---|
| 425 | + .msg = "hgc_dqe_ecc1b_intr", |
---|
431 | 426 | .reg = HGC_DQE_ECC_ADDR, |
---|
432 | 427 | }, |
---|
433 | 428 | { |
---|
434 | 429 | .irq_msk = BIT(SAS_ECC_INTR_IOST_ECC_1B_OFF), |
---|
435 | 430 | .msk = HGC_IOST_ECC_1B_ADDR_MSK, |
---|
436 | 431 | .shift = HGC_IOST_ECC_1B_ADDR_OFF, |
---|
437 | | - .msg = "hgc_iost_acc1b_intr found: Ram address is 0x%08X\n", |
---|
| 432 | + .msg = "hgc_iost_ecc1b_intr", |
---|
438 | 433 | .reg = HGC_IOST_ECC_ADDR, |
---|
439 | 434 | }, |
---|
440 | 435 | { |
---|
441 | 436 | .irq_msk = BIT(SAS_ECC_INTR_ITCT_ECC_1B_OFF), |
---|
442 | 437 | .msk = HGC_ITCT_ECC_1B_ADDR_MSK, |
---|
443 | 438 | .shift = HGC_ITCT_ECC_1B_ADDR_OFF, |
---|
444 | | - .msg = "hgc_itct_acc1b_intr found: am address is 0x%08X\n", |
---|
| 439 | + .msg = "hgc_itct_ecc1b_intr", |
---|
445 | 440 | .reg = HGC_ITCT_ECC_ADDR, |
---|
446 | 441 | }, |
---|
447 | 442 | { |
---|
448 | 443 | .irq_msk = BIT(SAS_ECC_INTR_IOSTLIST_ECC_1B_OFF), |
---|
449 | 444 | .msk = HGC_LM_DFX_STATUS2_IOSTLIST_MSK, |
---|
450 | 445 | .shift = HGC_LM_DFX_STATUS2_IOSTLIST_OFF, |
---|
451 | | - .msg = "hgc_iostl_acc1b_intr found: memory address is 0x%08X\n", |
---|
| 446 | + .msg = "hgc_iostl_ecc1b_intr", |
---|
452 | 447 | .reg = HGC_LM_DFX_STATUS2, |
---|
453 | 448 | }, |
---|
454 | 449 | { |
---|
455 | 450 | .irq_msk = BIT(SAS_ECC_INTR_ITCTLIST_ECC_1B_OFF), |
---|
456 | 451 | .msk = HGC_LM_DFX_STATUS2_ITCTLIST_MSK, |
---|
457 | 452 | .shift = HGC_LM_DFX_STATUS2_ITCTLIST_OFF, |
---|
458 | | - .msg = "hgc_itctl_acc1b_intr found: memory address is 0x%08X\n", |
---|
| 453 | + .msg = "hgc_itctl_ecc1b_intr", |
---|
459 | 454 | .reg = HGC_LM_DFX_STATUS2, |
---|
460 | 455 | }, |
---|
461 | 456 | { |
---|
462 | 457 | .irq_msk = BIT(SAS_ECC_INTR_CQE_ECC_1B_OFF), |
---|
463 | 458 | .msk = HGC_CQE_ECC_1B_ADDR_MSK, |
---|
464 | 459 | .shift = HGC_CQE_ECC_1B_ADDR_OFF, |
---|
465 | | - .msg = "hgc_cqe_acc1b_intr found: Ram address is 0x%08X\n", |
---|
| 460 | + .msg = "hgc_cqe_ecc1b_intr", |
---|
466 | 461 | .reg = HGC_CQE_ECC_ADDR, |
---|
467 | 462 | }, |
---|
468 | 463 | { |
---|
469 | 464 | .irq_msk = BIT(SAS_ECC_INTR_NCQ_MEM0_ECC_1B_OFF), |
---|
470 | 465 | .msk = HGC_RXM_DFX_STATUS14_MEM0_MSK, |
---|
471 | 466 | .shift = HGC_RXM_DFX_STATUS14_MEM0_OFF, |
---|
472 | | - .msg = "rxm_mem0_acc1b_intr found: memory address is 0x%08X\n", |
---|
| 467 | + .msg = "rxm_mem0_ecc1b_intr", |
---|
473 | 468 | .reg = HGC_RXM_DFX_STATUS14, |
---|
474 | 469 | }, |
---|
475 | 470 | { |
---|
476 | 471 | .irq_msk = BIT(SAS_ECC_INTR_NCQ_MEM1_ECC_1B_OFF), |
---|
477 | 472 | .msk = HGC_RXM_DFX_STATUS14_MEM1_MSK, |
---|
478 | 473 | .shift = HGC_RXM_DFX_STATUS14_MEM1_OFF, |
---|
479 | | - .msg = "rxm_mem1_acc1b_intr found: memory address is 0x%08X\n", |
---|
| 474 | + .msg = "rxm_mem1_ecc1b_intr", |
---|
480 | 475 | .reg = HGC_RXM_DFX_STATUS14, |
---|
481 | 476 | }, |
---|
482 | 477 | { |
---|
483 | 478 | .irq_msk = BIT(SAS_ECC_INTR_NCQ_MEM2_ECC_1B_OFF), |
---|
484 | 479 | .msk = HGC_RXM_DFX_STATUS14_MEM2_MSK, |
---|
485 | 480 | .shift = HGC_RXM_DFX_STATUS14_MEM2_OFF, |
---|
486 | | - .msg = "rxm_mem2_acc1b_intr found: memory address is 0x%08X\n", |
---|
| 481 | + .msg = "rxm_mem2_ecc1b_intr", |
---|
487 | 482 | .reg = HGC_RXM_DFX_STATUS14, |
---|
488 | 483 | }, |
---|
489 | 484 | { |
---|
490 | 485 | .irq_msk = BIT(SAS_ECC_INTR_NCQ_MEM3_ECC_1B_OFF), |
---|
491 | 486 | .msk = HGC_RXM_DFX_STATUS15_MEM3_MSK, |
---|
492 | 487 | .shift = HGC_RXM_DFX_STATUS15_MEM3_OFF, |
---|
493 | | - .msg = "rxm_mem3_acc1b_intr found: memory address is 0x%08X\n", |
---|
| 488 | + .msg = "rxm_mem3_ecc1b_intr", |
---|
494 | 489 | .reg = HGC_RXM_DFX_STATUS15, |
---|
495 | 490 | }, |
---|
496 | 491 | }; |
---|
.. | .. |
---|
500 | 495 | .irq_msk = BIT(SAS_ECC_INTR_DQE_ECC_MB_OFF), |
---|
501 | 496 | .msk = HGC_DQE_ECC_MB_ADDR_MSK, |
---|
502 | 497 | .shift = HGC_DQE_ECC_MB_ADDR_OFF, |
---|
503 | | - .msg = "hgc_dqe_accbad_intr (0x%x) found: Ram address is 0x%08X\n", |
---|
| 498 | + .msg = "hgc_dqe_eccbad_intr", |
---|
504 | 499 | .reg = HGC_DQE_ECC_ADDR, |
---|
505 | 500 | }, |
---|
506 | 501 | { |
---|
507 | 502 | .irq_msk = BIT(SAS_ECC_INTR_IOST_ECC_MB_OFF), |
---|
508 | 503 | .msk = HGC_IOST_ECC_MB_ADDR_MSK, |
---|
509 | 504 | .shift = HGC_IOST_ECC_MB_ADDR_OFF, |
---|
510 | | - .msg = "hgc_iost_accbad_intr (0x%x) found: Ram address is 0x%08X\n", |
---|
| 505 | + .msg = "hgc_iost_eccbad_intr", |
---|
511 | 506 | .reg = HGC_IOST_ECC_ADDR, |
---|
512 | 507 | }, |
---|
513 | 508 | { |
---|
514 | 509 | .irq_msk = BIT(SAS_ECC_INTR_ITCT_ECC_MB_OFF), |
---|
515 | 510 | .msk = HGC_ITCT_ECC_MB_ADDR_MSK, |
---|
516 | 511 | .shift = HGC_ITCT_ECC_MB_ADDR_OFF, |
---|
517 | | - .msg = "hgc_itct_accbad_intr (0x%x) found: Ram address is 0x%08X\n", |
---|
| 512 | + .msg = "hgc_itct_eccbad_intr", |
---|
518 | 513 | .reg = HGC_ITCT_ECC_ADDR, |
---|
519 | 514 | }, |
---|
520 | 515 | { |
---|
521 | 516 | .irq_msk = BIT(SAS_ECC_INTR_IOSTLIST_ECC_MB_OFF), |
---|
522 | 517 | .msk = HGC_LM_DFX_STATUS2_IOSTLIST_MSK, |
---|
523 | 518 | .shift = HGC_LM_DFX_STATUS2_IOSTLIST_OFF, |
---|
524 | | - .msg = "hgc_iostl_accbad_intr (0x%x) found: memory address is 0x%08X\n", |
---|
| 519 | + .msg = "hgc_iostl_eccbad_intr", |
---|
525 | 520 | .reg = HGC_LM_DFX_STATUS2, |
---|
526 | 521 | }, |
---|
527 | 522 | { |
---|
528 | 523 | .irq_msk = BIT(SAS_ECC_INTR_ITCTLIST_ECC_MB_OFF), |
---|
529 | 524 | .msk = HGC_LM_DFX_STATUS2_ITCTLIST_MSK, |
---|
530 | 525 | .shift = HGC_LM_DFX_STATUS2_ITCTLIST_OFF, |
---|
531 | | - .msg = "hgc_itctl_accbad_intr (0x%x) found: memory address is 0x%08X\n", |
---|
| 526 | + .msg = "hgc_itctl_eccbad_intr", |
---|
532 | 527 | .reg = HGC_LM_DFX_STATUS2, |
---|
533 | 528 | }, |
---|
534 | 529 | { |
---|
535 | 530 | .irq_msk = BIT(SAS_ECC_INTR_CQE_ECC_MB_OFF), |
---|
536 | 531 | .msk = HGC_CQE_ECC_MB_ADDR_MSK, |
---|
537 | 532 | .shift = HGC_CQE_ECC_MB_ADDR_OFF, |
---|
538 | | - .msg = "hgc_cqe_accbad_intr (0x%x) found: Ram address is 0x%08X\n", |
---|
| 533 | + .msg = "hgc_cqe_eccbad_intr", |
---|
539 | 534 | .reg = HGC_CQE_ECC_ADDR, |
---|
540 | 535 | }, |
---|
541 | 536 | { |
---|
542 | 537 | .irq_msk = BIT(SAS_ECC_INTR_NCQ_MEM0_ECC_MB_OFF), |
---|
543 | 538 | .msk = HGC_RXM_DFX_STATUS14_MEM0_MSK, |
---|
544 | 539 | .shift = HGC_RXM_DFX_STATUS14_MEM0_OFF, |
---|
545 | | - .msg = "rxm_mem0_accbad_intr (0x%x) found: memory address is 0x%08X\n", |
---|
| 540 | + .msg = "rxm_mem0_eccbad_intr", |
---|
546 | 541 | .reg = HGC_RXM_DFX_STATUS14, |
---|
547 | 542 | }, |
---|
548 | 543 | { |
---|
549 | 544 | .irq_msk = BIT(SAS_ECC_INTR_NCQ_MEM1_ECC_MB_OFF), |
---|
550 | 545 | .msk = HGC_RXM_DFX_STATUS14_MEM1_MSK, |
---|
551 | 546 | .shift = HGC_RXM_DFX_STATUS14_MEM1_OFF, |
---|
552 | | - .msg = "rxm_mem1_accbad_intr (0x%x) found: memory address is 0x%08X\n", |
---|
| 547 | + .msg = "rxm_mem1_eccbad_intr", |
---|
553 | 548 | .reg = HGC_RXM_DFX_STATUS14, |
---|
554 | 549 | }, |
---|
555 | 550 | { |
---|
556 | 551 | .irq_msk = BIT(SAS_ECC_INTR_NCQ_MEM2_ECC_MB_OFF), |
---|
557 | 552 | .msk = HGC_RXM_DFX_STATUS14_MEM2_MSK, |
---|
558 | 553 | .shift = HGC_RXM_DFX_STATUS14_MEM2_OFF, |
---|
559 | | - .msg = "rxm_mem2_accbad_intr (0x%x) found: memory address is 0x%08X\n", |
---|
| 554 | + .msg = "rxm_mem2_eccbad_intr", |
---|
560 | 555 | .reg = HGC_RXM_DFX_STATUS14, |
---|
561 | 556 | }, |
---|
562 | 557 | { |
---|
563 | 558 | .irq_msk = BIT(SAS_ECC_INTR_NCQ_MEM3_ECC_MB_OFF), |
---|
564 | 559 | .msk = HGC_RXM_DFX_STATUS15_MEM3_MSK, |
---|
565 | 560 | .shift = HGC_RXM_DFX_STATUS15_MEM3_OFF, |
---|
566 | | - .msg = "rxm_mem3_accbad_intr (0x%x) found: memory address is 0x%08X\n", |
---|
| 561 | + .msg = "rxm_mem3_eccbad_intr", |
---|
567 | 562 | .reg = HGC_RXM_DFX_STATUS15, |
---|
568 | 563 | }, |
---|
569 | 564 | }; |
---|
.. | .. |
---|
770 | 765 | |
---|
771 | 766 | /* This function needs to be protected from pre-emption. */ |
---|
772 | 767 | static int |
---|
773 | | -slot_index_alloc_quirk_v2_hw(struct hisi_hba *hisi_hba, int *slot_idx, |
---|
| 768 | +slot_index_alloc_quirk_v2_hw(struct hisi_hba *hisi_hba, |
---|
774 | 769 | struct domain_device *device) |
---|
775 | 770 | { |
---|
776 | 771 | int sata_dev = dev_is_sata(device); |
---|
.. | .. |
---|
801 | 796 | end = 64 * (sata_idx + 2); |
---|
802 | 797 | } |
---|
803 | 798 | |
---|
| 799 | + spin_lock(&hisi_hba->lock); |
---|
804 | 800 | while (1) { |
---|
805 | 801 | start = find_next_zero_bit(bitmap, |
---|
806 | 802 | hisi_hba->slot_index_count, start); |
---|
807 | | - if (start >= end) |
---|
| 803 | + if (start >= end) { |
---|
| 804 | + spin_unlock(&hisi_hba->lock); |
---|
808 | 805 | return -SAS_QUEUE_FULL; |
---|
| 806 | + } |
---|
809 | 807 | /* |
---|
810 | 808 | * SAS IPTT bit0 should be 1, and SATA IPTT bit0 should be 0. |
---|
811 | 809 | */ |
---|
.. | .. |
---|
815 | 813 | } |
---|
816 | 814 | |
---|
817 | 815 | set_bit(start, bitmap); |
---|
818 | | - *slot_idx = start; |
---|
819 | | - return 0; |
---|
| 816 | + spin_unlock(&hisi_hba->lock); |
---|
| 817 | + return start; |
---|
820 | 818 | } |
---|
821 | 819 | |
---|
822 | 820 | static bool sata_index_alloc_v2_hw(struct hisi_hba *hisi_hba, int *idx) |
---|
.. | .. |
---|
844 | 842 | struct hisi_sas_device *sas_dev = NULL; |
---|
845 | 843 | int i, sata_dev = dev_is_sata(device); |
---|
846 | 844 | int sata_idx = -1; |
---|
847 | | - unsigned long flags; |
---|
848 | 845 | |
---|
849 | | - spin_lock_irqsave(&hisi_hba->lock, flags); |
---|
| 846 | + spin_lock(&hisi_hba->lock); |
---|
850 | 847 | |
---|
851 | 848 | if (sata_dev) |
---|
852 | 849 | if (!sata_index_alloc_v2_hw(hisi_hba, &sata_idx)) |
---|
.. | .. |
---|
864 | 861 | |
---|
865 | 862 | hisi_hba->devices[i].device_id = i; |
---|
866 | 863 | sas_dev = &hisi_hba->devices[i]; |
---|
867 | | - sas_dev->dev_status = HISI_SAS_DEV_NORMAL; |
---|
| 864 | + sas_dev->dev_status = HISI_SAS_DEV_INIT; |
---|
868 | 865 | sas_dev->dev_type = device->dev_type; |
---|
869 | 866 | sas_dev->hisi_hba = hisi_hba; |
---|
870 | 867 | sas_dev->sas_device = device; |
---|
871 | 868 | sas_dev->sata_idx = sata_idx; |
---|
872 | 869 | sas_dev->dq = dq; |
---|
| 870 | + spin_lock_init(&sas_dev->lock); |
---|
873 | 871 | INIT_LIST_HEAD(&hisi_hba->devices[i].list); |
---|
874 | 872 | break; |
---|
875 | 873 | } |
---|
876 | 874 | } |
---|
877 | 875 | |
---|
878 | 876 | out: |
---|
879 | | - spin_unlock_irqrestore(&hisi_hba->lock, flags); |
---|
| 877 | + spin_unlock(&hisi_hba->lock); |
---|
880 | 878 | |
---|
881 | 879 | return sas_dev; |
---|
882 | 880 | } |
---|
.. | .. |
---|
930 | 928 | struct domain_device *parent_dev = device->parent; |
---|
931 | 929 | struct asd_sas_port *sas_port = device->port; |
---|
932 | 930 | struct hisi_sas_port *port = to_hisi_sas_port(sas_port); |
---|
| 931 | + u64 sas_addr; |
---|
933 | 932 | |
---|
934 | 933 | memset(itct, 0, sizeof(*itct)); |
---|
935 | 934 | |
---|
.. | .. |
---|
943 | 942 | break; |
---|
944 | 943 | case SAS_SATA_DEV: |
---|
945 | 944 | case SAS_SATA_PENDING: |
---|
946 | | - if (parent_dev && DEV_IS_EXPANDER(parent_dev->dev_type)) |
---|
| 945 | + if (parent_dev && dev_is_expander(parent_dev->dev_type)) |
---|
947 | 946 | qw0 = HISI_SAS_DEV_TYPE_STP << ITCT_HDR_DEV_TYPE_OFF; |
---|
948 | 947 | else |
---|
949 | 948 | qw0 = HISI_SAS_DEV_TYPE_SATA << ITCT_HDR_DEV_TYPE_OFF; |
---|
.. | .. |
---|
962 | 961 | itct->qw0 = cpu_to_le64(qw0); |
---|
963 | 962 | |
---|
964 | 963 | /* qw1 */ |
---|
965 | | - memcpy(&itct->sas_addr, device->sas_addr, SAS_ADDR_SIZE); |
---|
966 | | - itct->sas_addr = __swab64(itct->sas_addr); |
---|
| 964 | + memcpy(&sas_addr, device->sas_addr, SAS_ADDR_SIZE); |
---|
| 965 | + itct->sas_addr = cpu_to_le64(__swab64(sas_addr)); |
---|
967 | 966 | |
---|
968 | 967 | /* qw2 */ |
---|
969 | 968 | if (!dev_is_sata(device)) |
---|
.. | .. |
---|
973 | 972 | (0x1ULL << ITCT_HDR_RTOLT_OFF)); |
---|
974 | 973 | } |
---|
975 | 974 | |
---|
976 | | -static void clear_itct_v2_hw(struct hisi_hba *hisi_hba, |
---|
977 | | - struct hisi_sas_device *sas_dev) |
---|
| 975 | +static int clear_itct_v2_hw(struct hisi_hba *hisi_hba, |
---|
| 976 | + struct hisi_sas_device *sas_dev) |
---|
978 | 977 | { |
---|
979 | 978 | DECLARE_COMPLETION_ONSTACK(completion); |
---|
980 | 979 | u64 dev_id = sas_dev->device_id; |
---|
981 | 980 | struct hisi_sas_itct *itct = &hisi_hba->itct[dev_id]; |
---|
982 | 981 | u32 reg_val = hisi_sas_read32(hisi_hba, ENT_INT_SRC3); |
---|
| 982 | + struct device *dev = hisi_hba->dev; |
---|
983 | 983 | int i; |
---|
984 | 984 | |
---|
985 | 985 | sas_dev->completion = &completion; |
---|
.. | .. |
---|
989 | 989 | hisi_sas_write32(hisi_hba, ENT_INT_SRC3, |
---|
990 | 990 | ENT_INT_SRC3_ITC_INT_MSK); |
---|
991 | 991 | |
---|
| 992 | + /* need to set register twice to clear ITCT for v2 hw */ |
---|
992 | 993 | for (i = 0; i < 2; i++) { |
---|
993 | 994 | reg_val = ITCT_CLR_EN_MSK | (dev_id & ITCT_DEV_MSK); |
---|
994 | 995 | hisi_sas_write32(hisi_hba, ITCT_CLR, reg_val); |
---|
995 | | - wait_for_completion(sas_dev->completion); |
---|
| 996 | + if (!wait_for_completion_timeout(sas_dev->completion, |
---|
| 997 | + CLEAR_ITCT_TIMEOUT * HZ)) { |
---|
| 998 | + dev_warn(dev, "failed to clear ITCT\n"); |
---|
| 999 | + return -ETIMEDOUT; |
---|
| 1000 | + } |
---|
996 | 1001 | |
---|
997 | 1002 | memset(itct, 0, sizeof(struct hisi_sas_itct)); |
---|
998 | 1003 | } |
---|
| 1004 | + return 0; |
---|
999 | 1005 | } |
---|
1000 | 1006 | |
---|
1001 | 1007 | static void free_device_v2_hw(struct hisi_sas_device *sas_dev) |
---|
.. | .. |
---|
1196 | 1202 | hisi_sas_write32(hisi_hba, ENT_INT_SRC_MSK3, 0x7ffe20fe); |
---|
1197 | 1203 | hisi_sas_write32(hisi_hba, SAS_ECC_INTR_MSK, 0xfff00c30); |
---|
1198 | 1204 | for (i = 0; i < hisi_hba->queue_count; i++) |
---|
1199 | | - hisi_sas_write32(hisi_hba, OQ0_INT_SRC_MSK+0x4*i, 0); |
---|
| 1205 | + hisi_sas_write32(hisi_hba, OQ0_INT_SRC_MSK + 0x4 * i, 0); |
---|
1200 | 1206 | |
---|
1201 | 1207 | hisi_sas_write32(hisi_hba, AXI_AHB_CLK_CFG, 1); |
---|
1202 | 1208 | hisi_sas_write32(hisi_hba, HYPER_STREAM_ID_EN_CFG, 1); |
---|
.. | .. |
---|
1376 | 1382 | |
---|
1377 | 1383 | rc = reset_hw_v2_hw(hisi_hba); |
---|
1378 | 1384 | if (rc) { |
---|
1379 | | - dev_err(dev, "hisi_sas_reset_hw failed, rc=%d", rc); |
---|
| 1385 | + dev_err(dev, "hisi_sas_reset_hw failed, rc=%d\n", rc); |
---|
1380 | 1386 | return rc; |
---|
1381 | 1387 | } |
---|
1382 | 1388 | |
---|
.. | .. |
---|
1540 | 1546 | struct hisi_sas_phy *phy = &hisi_hba->phy[phy_no]; |
---|
1541 | 1547 | u32 txid_auto; |
---|
1542 | 1548 | |
---|
1543 | | - disable_phy_v2_hw(hisi_hba, phy_no); |
---|
| 1549 | + hisi_sas_phy_enable(hisi_hba, phy_no, 0); |
---|
1544 | 1550 | if (phy->identify.device_type == SAS_END_DEVICE) { |
---|
1545 | 1551 | txid_auto = hisi_sas_phy_read32(hisi_hba, phy_no, TXID_AUTO); |
---|
1546 | 1552 | hisi_sas_phy_write32(hisi_hba, phy_no, TXID_AUTO, |
---|
1547 | 1553 | txid_auto | TX_HARDRST_MSK); |
---|
1548 | 1554 | } |
---|
1549 | 1555 | msleep(100); |
---|
1550 | | - start_phy_v2_hw(hisi_hba, phy_no); |
---|
| 1556 | + hisi_sas_phy_enable(hisi_hba, phy_no, 1); |
---|
1551 | 1557 | } |
---|
1552 | 1558 | |
---|
1553 | 1559 | static void phy_get_events_v2_hw(struct hisi_hba *hisi_hba, int phy_no) |
---|
.. | .. |
---|
1580 | 1586 | if (!sas_phy->phy->enabled) |
---|
1581 | 1587 | continue; |
---|
1582 | 1588 | |
---|
1583 | | - start_phy_v2_hw(hisi_hba, i); |
---|
| 1589 | + hisi_sas_phy_enable(hisi_hba, i, 1); |
---|
1584 | 1590 | } |
---|
1585 | 1591 | } |
---|
1586 | 1592 | |
---|
.. | .. |
---|
1634 | 1640 | } |
---|
1635 | 1641 | |
---|
1636 | 1642 | return bitmap; |
---|
1637 | | -} |
---|
1638 | | - |
---|
1639 | | -/* |
---|
1640 | | - * The callpath to this function and upto writing the write |
---|
1641 | | - * queue pointer should be safe from interruption. |
---|
1642 | | - */ |
---|
1643 | | -static int |
---|
1644 | | -get_free_slot_v2_hw(struct hisi_hba *hisi_hba, struct hisi_sas_dq *dq) |
---|
1645 | | -{ |
---|
1646 | | - struct device *dev = hisi_hba->dev; |
---|
1647 | | - int queue = dq->id; |
---|
1648 | | - u32 r, w; |
---|
1649 | | - |
---|
1650 | | - w = dq->wr_point; |
---|
1651 | | - r = hisi_sas_read32_relaxed(hisi_hba, |
---|
1652 | | - DLVRY_Q_0_RD_PTR + (queue * 0x14)); |
---|
1653 | | - if (r == (w+1) % HISI_SAS_QUEUE_SLOTS) { |
---|
1654 | | - dev_warn(dev, "full queue=%d r=%d w=%d\n", |
---|
1655 | | - queue, r, w); |
---|
1656 | | - return -EAGAIN; |
---|
1657 | | - } |
---|
1658 | | - |
---|
1659 | | - dq->wr_point = (dq->wr_point + 1) % HISI_SAS_QUEUE_SLOTS; |
---|
1660 | | - |
---|
1661 | | - return w; |
---|
1662 | 1643 | } |
---|
1663 | 1644 | |
---|
1664 | 1645 | /* DQ lock must be taken here */ |
---|
.. | .. |
---|
2040 | 2021 | struct task_status_struct *ts = &task->task_status; |
---|
2041 | 2022 | struct hisi_sas_err_record_v2 *err_record = |
---|
2042 | 2023 | hisi_sas_status_buf_addr_mem(slot); |
---|
2043 | | - u32 trans_tx_fail_type = cpu_to_le32(err_record->trans_tx_fail_type); |
---|
2044 | | - u32 trans_rx_fail_type = cpu_to_le32(err_record->trans_rx_fail_type); |
---|
2045 | | - u16 dma_tx_err_type = cpu_to_le16(err_record->dma_tx_err_type); |
---|
2046 | | - u16 sipc_rx_err_type = cpu_to_le16(err_record->sipc_rx_err_type); |
---|
2047 | | - u32 dma_rx_err_type = cpu_to_le32(err_record->dma_rx_err_type); |
---|
| 2024 | + u32 trans_tx_fail_type = le32_to_cpu(err_record->trans_tx_fail_type); |
---|
| 2025 | + u32 trans_rx_fail_type = le32_to_cpu(err_record->trans_rx_fail_type); |
---|
| 2026 | + u16 dma_tx_err_type = le16_to_cpu(err_record->dma_tx_err_type); |
---|
| 2027 | + u16 sipc_rx_err_type = le16_to_cpu(err_record->sipc_rx_err_type); |
---|
| 2028 | + u32 dma_rx_err_type = le32_to_cpu(err_record->dma_rx_err_type); |
---|
| 2029 | + struct hisi_sas_complete_v2_hdr *complete_queue = |
---|
| 2030 | + hisi_hba->complete_hdr[slot->cmplt_queue]; |
---|
| 2031 | + struct hisi_sas_complete_v2_hdr *complete_hdr = |
---|
| 2032 | + &complete_queue[slot->cmplt_queue_slot]; |
---|
| 2033 | + u32 dw0 = le32_to_cpu(complete_hdr->dw0); |
---|
2048 | 2034 | int error = -1; |
---|
2049 | 2035 | |
---|
2050 | 2036 | if (err_phase == 1) { |
---|
.. | .. |
---|
2055 | 2041 | trans_tx_fail_type); |
---|
2056 | 2042 | } else if (err_phase == 2) { |
---|
2057 | 2043 | /* error in RX phase, the priority is: DW1 > DW3 > DW2 */ |
---|
2058 | | - error = parse_trans_rx_err_code_v2_hw( |
---|
2059 | | - trans_rx_fail_type); |
---|
| 2044 | + error = parse_trans_rx_err_code_v2_hw(trans_rx_fail_type); |
---|
2060 | 2045 | if (error == -1) { |
---|
2061 | 2046 | error = parse_dma_rx_err_code_v2_hw( |
---|
2062 | 2047 | dma_rx_err_type); |
---|
.. | .. |
---|
2188 | 2173 | } |
---|
2189 | 2174 | break; |
---|
2190 | 2175 | case SAS_PROTOCOL_SMP: |
---|
2191 | | - ts->stat = SAM_STAT_CHECK_CONDITION; |
---|
| 2176 | + ts->stat = SAS_SAM_STAT_CHECK_CONDITION; |
---|
2192 | 2177 | break; |
---|
2193 | 2178 | |
---|
2194 | 2179 | case SAS_PROTOCOL_SATA: |
---|
.. | .. |
---|
2330 | 2315 | break; |
---|
2331 | 2316 | } |
---|
2332 | 2317 | } |
---|
2333 | | - hisi_sas_sata_done(task, slot); |
---|
| 2318 | + if (dw0 & CMPLT_HDR_RSPNS_XFRD_MSK) |
---|
| 2319 | + hisi_sas_sata_done(task, slot); |
---|
2334 | 2320 | } |
---|
2335 | 2321 | break; |
---|
2336 | 2322 | default: |
---|
.. | .. |
---|
2338 | 2324 | } |
---|
2339 | 2325 | } |
---|
2340 | 2326 | |
---|
2341 | | -static int |
---|
2342 | | -slot_complete_v2_hw(struct hisi_hba *hisi_hba, struct hisi_sas_slot *slot) |
---|
| 2327 | +static void slot_complete_v2_hw(struct hisi_hba *hisi_hba, |
---|
| 2328 | + struct hisi_sas_slot *slot) |
---|
2343 | 2329 | { |
---|
2344 | 2330 | struct sas_task *task = slot->task; |
---|
2345 | 2331 | struct hisi_sas_device *sas_dev; |
---|
.. | .. |
---|
2347 | 2333 | struct task_status_struct *ts; |
---|
2348 | 2334 | struct domain_device *device; |
---|
2349 | 2335 | struct sas_ha_struct *ha; |
---|
2350 | | - enum exec_status sts; |
---|
2351 | 2336 | struct hisi_sas_complete_v2_hdr *complete_queue = |
---|
2352 | 2337 | hisi_hba->complete_hdr[slot->cmplt_queue]; |
---|
2353 | 2338 | struct hisi_sas_complete_v2_hdr *complete_hdr = |
---|
2354 | 2339 | &complete_queue[slot->cmplt_queue_slot]; |
---|
2355 | 2340 | unsigned long flags; |
---|
2356 | 2341 | bool is_internal = slot->is_internal; |
---|
| 2342 | + u32 dw0; |
---|
2357 | 2343 | |
---|
2358 | 2344 | if (unlikely(!task || !task->lldd_task || !task->dev)) |
---|
2359 | | - return -EINVAL; |
---|
| 2345 | + return; |
---|
2360 | 2346 | |
---|
2361 | 2347 | ts = &task->task_status; |
---|
2362 | 2348 | device = task->dev; |
---|
.. | .. |
---|
2378 | 2364 | } |
---|
2379 | 2365 | |
---|
2380 | 2366 | /* Use SAS+TMF status codes */ |
---|
2381 | | - switch ((complete_hdr->dw0 & CMPLT_HDR_ABORT_STAT_MSK) |
---|
2382 | | - >> CMPLT_HDR_ABORT_STAT_OFF) { |
---|
| 2367 | + dw0 = le32_to_cpu(complete_hdr->dw0); |
---|
| 2368 | + switch ((dw0 & CMPLT_HDR_ABORT_STAT_MSK) >> |
---|
| 2369 | + CMPLT_HDR_ABORT_STAT_OFF) { |
---|
2383 | 2370 | case STAT_IO_ABORTED: |
---|
2384 | 2371 | /* this io has been aborted by abort command */ |
---|
2385 | 2372 | ts->stat = SAS_ABORTED_TASK; |
---|
.. | .. |
---|
2404 | 2391 | break; |
---|
2405 | 2392 | } |
---|
2406 | 2393 | |
---|
2407 | | - if ((complete_hdr->dw0 & CMPLT_HDR_ERX_MSK) && |
---|
2408 | | - (!(complete_hdr->dw0 & CMPLT_HDR_RSPNS_XFRD_MSK))) { |
---|
2409 | | - u32 err_phase = (complete_hdr->dw0 & CMPLT_HDR_ERR_PHASE_MSK) |
---|
| 2394 | + if ((dw0 & CMPLT_HDR_ERX_MSK) && (!(dw0 & CMPLT_HDR_RSPNS_XFRD_MSK))) { |
---|
| 2395 | + u32 err_phase = (dw0 & CMPLT_HDR_ERR_PHASE_MSK) |
---|
2410 | 2396 | >> CMPLT_HDR_ERR_PHASE_OFF; |
---|
2411 | 2397 | u32 *error_info = hisi_sas_status_buf_addr_mem(slot); |
---|
2412 | 2398 | |
---|
.. | .. |
---|
2417 | 2403 | slot_err_v2_hw(hisi_hba, task, slot, 2); |
---|
2418 | 2404 | |
---|
2419 | 2405 | if (ts->stat != SAS_DATA_UNDERRUN) |
---|
2420 | | - dev_info(dev, "erroneous completion iptt=%d task=%p dev id=%d " |
---|
2421 | | - "CQ hdr: 0x%x 0x%x 0x%x 0x%x " |
---|
2422 | | - "Error info: 0x%x 0x%x 0x%x 0x%x\n", |
---|
2423 | | - slot->idx, task, sas_dev->device_id, |
---|
2424 | | - complete_hdr->dw0, complete_hdr->dw1, |
---|
2425 | | - complete_hdr->act, complete_hdr->dw3, |
---|
2426 | | - error_info[0], error_info[1], |
---|
2427 | | - error_info[2], error_info[3]); |
---|
| 2406 | + dev_info(dev, "erroneous completion iptt=%d task=%pK dev id=%d CQ hdr: 0x%x 0x%x 0x%x 0x%x Error info: 0x%x 0x%x 0x%x 0x%x\n", |
---|
| 2407 | + slot->idx, task, sas_dev->device_id, |
---|
| 2408 | + complete_hdr->dw0, complete_hdr->dw1, |
---|
| 2409 | + complete_hdr->act, complete_hdr->dw3, |
---|
| 2410 | + error_info[0], error_info[1], |
---|
| 2411 | + error_info[2], error_info[3]); |
---|
2428 | 2412 | |
---|
2429 | | - if (unlikely(slot->abort)) |
---|
2430 | | - return ts->stat; |
---|
| 2413 | + if (unlikely(slot->abort)) { |
---|
| 2414 | + sas_task_abort(task); |
---|
| 2415 | + return; |
---|
| 2416 | + } |
---|
2431 | 2417 | goto out; |
---|
2432 | 2418 | } |
---|
2433 | 2419 | |
---|
.. | .. |
---|
2445 | 2431 | case SAS_PROTOCOL_SMP: |
---|
2446 | 2432 | { |
---|
2447 | 2433 | struct scatterlist *sg_resp = &task->smp_task.smp_resp; |
---|
2448 | | - void *to; |
---|
| 2434 | + void *to = page_address(sg_page(sg_resp)); |
---|
2449 | 2435 | |
---|
2450 | | - ts->stat = SAM_STAT_GOOD; |
---|
2451 | | - to = kmap_atomic(sg_page(sg_resp)); |
---|
| 2436 | + ts->stat = SAS_SAM_STAT_GOOD; |
---|
2452 | 2437 | |
---|
2453 | | - dma_unmap_sg(dev, &task->smp_task.smp_resp, 1, |
---|
2454 | | - DMA_FROM_DEVICE); |
---|
2455 | 2438 | dma_unmap_sg(dev, &task->smp_task.smp_req, 1, |
---|
2456 | 2439 | DMA_TO_DEVICE); |
---|
2457 | 2440 | memcpy(to + sg_resp->offset, |
---|
2458 | 2441 | hisi_sas_status_buf_addr_mem(slot) + |
---|
2459 | 2442 | sizeof(struct hisi_sas_err_record), |
---|
2460 | | - sg_dma_len(sg_resp)); |
---|
2461 | | - kunmap_atomic(to); |
---|
| 2443 | + sg_resp->length); |
---|
2462 | 2444 | break; |
---|
2463 | 2445 | } |
---|
2464 | 2446 | case SAS_PROTOCOL_SATA: |
---|
2465 | 2447 | case SAS_PROTOCOL_STP: |
---|
2466 | 2448 | case SAS_PROTOCOL_SATA | SAS_PROTOCOL_STP: |
---|
2467 | 2449 | { |
---|
2468 | | - ts->stat = SAM_STAT_GOOD; |
---|
2469 | | - hisi_sas_sata_done(task, slot); |
---|
| 2450 | + ts->stat = SAS_SAM_STAT_GOOD; |
---|
| 2451 | + if (dw0 & CMPLT_HDR_RSPNS_XFRD_MSK) |
---|
| 2452 | + hisi_sas_sata_done(task, slot); |
---|
2470 | 2453 | break; |
---|
2471 | 2454 | } |
---|
2472 | 2455 | default: |
---|
2473 | | - ts->stat = SAM_STAT_CHECK_CONDITION; |
---|
| 2456 | + ts->stat = SAS_SAM_STAT_CHECK_CONDITION; |
---|
2474 | 2457 | break; |
---|
2475 | 2458 | } |
---|
2476 | 2459 | |
---|
.. | .. |
---|
2481 | 2464 | } |
---|
2482 | 2465 | |
---|
2483 | 2466 | out: |
---|
2484 | | - sts = ts->stat; |
---|
2485 | 2467 | spin_lock_irqsave(&task->task_state_lock, flags); |
---|
2486 | 2468 | if (task->task_state_flags & SAS_TASK_STATE_ABORTED) { |
---|
2487 | 2469 | spin_unlock_irqrestore(&task->task_state_lock, flags); |
---|
2488 | | - dev_info(dev, "slot complete: task(%p) aborted\n", task); |
---|
2489 | | - return SAS_ABORTED_TASK; |
---|
| 2470 | + dev_info(dev, "slot complete: task(%pK) aborted\n", task); |
---|
| 2471 | + return; |
---|
2490 | 2472 | } |
---|
2491 | 2473 | task->task_state_flags |= SAS_TASK_STATE_DONE; |
---|
2492 | 2474 | spin_unlock_irqrestore(&task->task_state_lock, flags); |
---|
.. | .. |
---|
2496 | 2478 | spin_lock_irqsave(&device->done_lock, flags); |
---|
2497 | 2479 | if (test_bit(SAS_HA_FROZEN, &ha->state)) { |
---|
2498 | 2480 | spin_unlock_irqrestore(&device->done_lock, flags); |
---|
2499 | | - dev_info(dev, "slot complete: task(%p) ignored\n ", |
---|
| 2481 | + dev_info(dev, "slot complete: task(%pK) ignored\n", |
---|
2500 | 2482 | task); |
---|
2501 | | - return sts; |
---|
| 2483 | + return; |
---|
2502 | 2484 | } |
---|
2503 | 2485 | spin_unlock_irqrestore(&device->done_lock, flags); |
---|
2504 | 2486 | } |
---|
2505 | 2487 | |
---|
2506 | 2488 | if (task->task_done) |
---|
2507 | 2489 | task->task_done(task); |
---|
2508 | | - |
---|
2509 | | - return sts; |
---|
2510 | 2490 | } |
---|
2511 | 2491 | |
---|
2512 | 2492 | static void prep_ata_v2_hw(struct hisi_hba *hisi_hba, |
---|
.. | .. |
---|
2522 | 2502 | struct hisi_sas_tmf_task *tmf = slot->tmf; |
---|
2523 | 2503 | u8 *buf_cmd; |
---|
2524 | 2504 | int has_data = 0, hdr_tag = 0; |
---|
2525 | | - u32 dw1 = 0, dw2 = 0; |
---|
| 2505 | + u32 dw0, dw1 = 0, dw2 = 0; |
---|
2526 | 2506 | |
---|
2527 | 2507 | /* create header */ |
---|
2528 | 2508 | /* dw0 */ |
---|
2529 | | - hdr->dw0 = cpu_to_le32(port->id << CMD_HDR_PORT_OFF); |
---|
2530 | | - if (parent_dev && DEV_IS_EXPANDER(parent_dev->dev_type)) |
---|
2531 | | - hdr->dw0 |= cpu_to_le32(3 << CMD_HDR_CMD_OFF); |
---|
| 2509 | + dw0 = port->id << CMD_HDR_PORT_OFF; |
---|
| 2510 | + if (parent_dev && dev_is_expander(parent_dev->dev_type)) |
---|
| 2511 | + dw0 |= 3 << CMD_HDR_CMD_OFF; |
---|
2532 | 2512 | else |
---|
2533 | | - hdr->dw0 |= cpu_to_le32(4 << CMD_HDR_CMD_OFF); |
---|
| 2513 | + dw0 |= 4 << CMD_HDR_CMD_OFF; |
---|
2534 | 2514 | |
---|
2535 | 2515 | if (tmf && tmf->force_phy) { |
---|
2536 | | - hdr->dw0 |= CMD_HDR_FORCE_PHY_MSK; |
---|
2537 | | - hdr->dw0 |= cpu_to_le32((1 << tmf->phy_id) |
---|
2538 | | - << CMD_HDR_PHY_ID_OFF); |
---|
| 2516 | + dw0 |= CMD_HDR_FORCE_PHY_MSK; |
---|
| 2517 | + dw0 |= (1 << tmf->phy_id) << CMD_HDR_PHY_ID_OFF; |
---|
2539 | 2518 | } |
---|
| 2519 | + |
---|
| 2520 | + hdr->dw0 = cpu_to_le32(dw0); |
---|
2540 | 2521 | |
---|
2541 | 2522 | /* dw1 */ |
---|
2542 | 2523 | switch (task->data_dir) { |
---|
.. | .. |
---|
2563 | 2544 | hdr->dw1 = cpu_to_le32(dw1); |
---|
2564 | 2545 | |
---|
2565 | 2546 | /* dw2 */ |
---|
2566 | | - if (task->ata_task.use_ncq && hisi_sas_get_ncq_tag(task, &hdr_tag)) { |
---|
| 2547 | + if (task->ata_task.use_ncq) { |
---|
| 2548 | + struct ata_queued_cmd *qc = task->uldd_task; |
---|
| 2549 | + |
---|
| 2550 | + hdr_tag = qc->tag; |
---|
2567 | 2551 | task->ata_task.fis.sector_count |= (u8) (hdr_tag << 3); |
---|
2568 | 2552 | dw2 |= hdr_tag << CMD_HDR_NCQ_TAG_OFF; |
---|
2569 | 2553 | } |
---|
.. | .. |
---|
2671 | 2655 | if (is_sata_phy_v2_hw(hisi_hba, phy_no)) |
---|
2672 | 2656 | goto end; |
---|
2673 | 2657 | |
---|
| 2658 | + del_timer(&phy->timer); |
---|
| 2659 | + |
---|
2674 | 2660 | if (phy_no == 8) { |
---|
2675 | 2661 | u32 port_state = hisi_sas_read32(hisi_hba, PORT_STATE); |
---|
2676 | 2662 | |
---|
.. | .. |
---|
2750 | 2736 | struct hisi_sas_port *port = phy->port; |
---|
2751 | 2737 | struct device *dev = hisi_hba->dev; |
---|
2752 | 2738 | |
---|
| 2739 | + del_timer(&phy->timer); |
---|
2753 | 2740 | hisi_sas_phy_write32(hisi_hba, phy_no, PHYCTRL_NOT_RDY_MSK, 1); |
---|
2754 | 2741 | |
---|
2755 | 2742 | phy_state = hisi_sas_read32(hisi_hba, PHY_STATE); |
---|
.. | .. |
---|
2838 | 2825 | { |
---|
2839 | 2826 | struct hisi_sas_phy *phy = &hisi_hba->phy[phy_no]; |
---|
2840 | 2827 | struct asd_sas_phy *sas_phy = &phy->sas_phy; |
---|
2841 | | - struct sas_ha_struct *sas_ha = &hisi_hba->sha; |
---|
2842 | 2828 | u32 bcast_status; |
---|
2843 | 2829 | |
---|
2844 | 2830 | hisi_sas_phy_write32(hisi_hba, phy_no, SL_RX_BCAST_CHK_MSK, 1); |
---|
2845 | 2831 | bcast_status = hisi_sas_phy_read32(hisi_hba, phy_no, RX_PRIMS_STATUS); |
---|
2846 | 2832 | if ((bcast_status & RX_BCAST_CHG_MSK) && |
---|
2847 | 2833 | !test_bit(HISI_SAS_RESET_BIT, &hisi_hba->flags)) |
---|
2848 | | - sas_ha->notify_port_event(sas_phy, PORTE_BROADCAST_RCVD); |
---|
| 2834 | + sas_notify_port_event(sas_phy, PORTE_BROADCAST_RCVD); |
---|
2849 | 2835 | hisi_sas_phy_write32(hisi_hba, phy_no, CHL_INT0, |
---|
2850 | 2836 | CHL_INT0_SL_RX_BCST_ACK_MSK); |
---|
2851 | 2837 | hisi_sas_phy_write32(hisi_hba, phy_no, SL_RX_BCAST_CHK_MSK, 0); |
---|
.. | .. |
---|
2925 | 2911 | |
---|
2926 | 2912 | if (irq_value2 & BIT(CHL_INT2_SL_IDAF_TOUT_CONF_OFF)) { |
---|
2927 | 2913 | dev_warn(dev, "phy%d identify timeout\n", |
---|
2928 | | - phy_no); |
---|
| 2914 | + phy_no); |
---|
2929 | 2915 | hisi_sas_notify_phy_event(phy, |
---|
2930 | 2916 | HISI_PHYE_LINK_RESET); |
---|
2931 | 2917 | } |
---|
.. | .. |
---|
2937 | 2923 | if ((irq_msk & (1 << phy_no)) && irq_value0) { |
---|
2938 | 2924 | if (irq_value0 & CHL_INT0_SL_RX_BCST_ACK_MSK) |
---|
2939 | 2925 | phy_bcast_v2_hw(phy_no, hisi_hba); |
---|
| 2926 | + |
---|
| 2927 | + if (irq_value0 & CHL_INT0_PHY_RDY_MSK) |
---|
| 2928 | + hisi_sas_phy_oob_ready(hisi_hba, phy_no); |
---|
2940 | 2929 | |
---|
2941 | 2930 | hisi_sas_phy_write32(hisi_hba, phy_no, |
---|
2942 | 2931 | CHL_INT0, irq_value0 |
---|
.. | .. |
---|
2967 | 2956 | val = hisi_sas_read32(hisi_hba, ecc_error->reg); |
---|
2968 | 2957 | val &= ecc_error->msk; |
---|
2969 | 2958 | val >>= ecc_error->shift; |
---|
2970 | | - dev_warn(dev, ecc_error->msg, val); |
---|
| 2959 | + dev_warn(dev, "%s found: mem addr is 0x%08X\n", |
---|
| 2960 | + ecc_error->msg, val); |
---|
2971 | 2961 | } |
---|
2972 | 2962 | } |
---|
2973 | 2963 | } |
---|
.. | .. |
---|
2986 | 2976 | val = hisi_sas_read32(hisi_hba, ecc_error->reg); |
---|
2987 | 2977 | val &= ecc_error->msk; |
---|
2988 | 2978 | val >>= ecc_error->shift; |
---|
2989 | | - dev_err(dev, ecc_error->msg, irq_value, val); |
---|
| 2979 | + dev_err(dev, "%s (0x%x) found: mem addr is 0x%08X\n", |
---|
| 2980 | + ecc_error->msg, irq_value, val); |
---|
2990 | 2981 | queue_work(hisi_hba->wq, &hisi_hba->rst_work); |
---|
2991 | 2982 | } |
---|
2992 | 2983 | } |
---|
.. | .. |
---|
3023 | 3014 | { .msk = BIT(5), .msg = "SATA_AXI_R_ERR" }, |
---|
3024 | 3015 | { .msk = BIT(6), .msg = "DQE_AXI_R_ERR" }, |
---|
3025 | 3016 | { .msk = BIT(7), .msg = "CQE_AXI_W_ERR" }, |
---|
3026 | | - {}, |
---|
| 3017 | + {} |
---|
3027 | 3018 | }; |
---|
3028 | 3019 | |
---|
3029 | 3020 | static const struct hisi_sas_hw_error fifo_error[] = { |
---|
.. | .. |
---|
3032 | 3023 | { .msk = BIT(10), .msg = "GETDQE_FIFO" }, |
---|
3033 | 3024 | { .msk = BIT(11), .msg = "CMDP_FIFO" }, |
---|
3034 | 3025 | { .msk = BIT(12), .msg = "AWTCTRL_FIFO" }, |
---|
3035 | | - {}, |
---|
| 3026 | + {} |
---|
3036 | 3027 | }; |
---|
3037 | 3028 | |
---|
3038 | 3029 | static const struct hisi_sas_hw_error fatal_axi_errors[] = { |
---|
.. | .. |
---|
3096 | 3087 | if (!(err_value & sub->msk)) |
---|
3097 | 3088 | continue; |
---|
3098 | 3089 | dev_err(dev, "%s (0x%x) found!\n", |
---|
3099 | | - sub->msg, irq_value); |
---|
| 3090 | + sub->msg, irq_value); |
---|
3100 | 3091 | queue_work(hisi_hba->wq, &hisi_hba->rst_work); |
---|
3101 | 3092 | } |
---|
3102 | 3093 | } else { |
---|
3103 | 3094 | dev_err(dev, "%s (0x%x) found!\n", |
---|
3104 | | - axi_error->msg, irq_value); |
---|
| 3095 | + axi_error->msg, irq_value); |
---|
3105 | 3096 | queue_work(hisi_hba->wq, &hisi_hba->rst_work); |
---|
3106 | 3097 | } |
---|
3107 | 3098 | } |
---|
.. | .. |
---|
3122 | 3113 | return IRQ_HANDLED; |
---|
3123 | 3114 | } |
---|
3124 | 3115 | |
---|
3125 | | -static void cq_tasklet_v2_hw(unsigned long val) |
---|
| 3116 | +static irqreturn_t cq_thread_v2_hw(int irq_no, void *p) |
---|
3126 | 3117 | { |
---|
3127 | | - struct hisi_sas_cq *cq = (struct hisi_sas_cq *)val; |
---|
| 3118 | + struct hisi_sas_cq *cq = p; |
---|
3128 | 3119 | struct hisi_hba *hisi_hba = cq->hisi_hba; |
---|
3129 | 3120 | struct hisi_sas_slot *slot; |
---|
3130 | 3121 | struct hisi_sas_itct *itct; |
---|
.. | .. |
---|
3148 | 3139 | |
---|
3149 | 3140 | /* Check for NCQ completion */ |
---|
3150 | 3141 | if (complete_hdr->act) { |
---|
3151 | | - u32 act_tmp = complete_hdr->act; |
---|
| 3142 | + u32 act_tmp = le32_to_cpu(complete_hdr->act); |
---|
3152 | 3143 | int ncq_tag_count = ffs(act_tmp); |
---|
| 3144 | + u32 dw1 = le32_to_cpu(complete_hdr->dw1); |
---|
3153 | 3145 | |
---|
3154 | | - dev_id = (complete_hdr->dw1 & CMPLT_HDR_DEV_ID_MSK) >> |
---|
| 3146 | + dev_id = (dw1 & CMPLT_HDR_DEV_ID_MSK) >> |
---|
3155 | 3147 | CMPLT_HDR_DEV_ID_OFF; |
---|
3156 | 3148 | itct = &hisi_hba->itct[dev_id]; |
---|
3157 | 3149 | |
---|
3158 | 3150 | /* The NCQ tags are held in the itct header */ |
---|
3159 | 3151 | while (ncq_tag_count) { |
---|
3160 | | - __le64 *ncq_tag = &itct->qw4_15[0]; |
---|
| 3152 | + __le64 *_ncq_tag = &itct->qw4_15[0], __ncq_tag; |
---|
| 3153 | + u64 ncq_tag; |
---|
3161 | 3154 | |
---|
3162 | | - ncq_tag_count -= 1; |
---|
3163 | | - iptt = (ncq_tag[ncq_tag_count / 5] |
---|
3164 | | - >> (ncq_tag_count % 5) * 12) & 0xfff; |
---|
| 3155 | + ncq_tag_count--; |
---|
| 3156 | + __ncq_tag = _ncq_tag[ncq_tag_count / 5]; |
---|
| 3157 | + ncq_tag = le64_to_cpu(__ncq_tag); |
---|
| 3158 | + iptt = (ncq_tag >> (ncq_tag_count % 5) * 12) & |
---|
| 3159 | + 0xfff; |
---|
3165 | 3160 | |
---|
3166 | 3161 | slot = &hisi_hba->slot_info[iptt]; |
---|
3167 | 3162 | slot->cmplt_queue_slot = rd_point; |
---|
.. | .. |
---|
3172 | 3167 | ncq_tag_count = ffs(act_tmp); |
---|
3173 | 3168 | } |
---|
3174 | 3169 | } else { |
---|
3175 | | - iptt = (complete_hdr->dw1) & CMPLT_HDR_IPTT_MSK; |
---|
| 3170 | + u32 dw1 = le32_to_cpu(complete_hdr->dw1); |
---|
| 3171 | + |
---|
| 3172 | + iptt = dw1 & CMPLT_HDR_IPTT_MSK; |
---|
3176 | 3173 | slot = &hisi_hba->slot_info[iptt]; |
---|
3177 | 3174 | slot->cmplt_queue_slot = rd_point; |
---|
3178 | 3175 | slot->cmplt_queue = queue; |
---|
.. | .. |
---|
3186 | 3183 | /* update rd_point */ |
---|
3187 | 3184 | cq->rd_point = rd_point; |
---|
3188 | 3185 | hisi_sas_write32(hisi_hba, COMPL_Q_0_RD_PTR + (0x14 * queue), rd_point); |
---|
| 3186 | + |
---|
| 3187 | + return IRQ_HANDLED; |
---|
3189 | 3188 | } |
---|
3190 | 3189 | |
---|
3191 | 3190 | static irqreturn_t cq_interrupt_v2_hw(int irq_no, void *p) |
---|
.. | .. |
---|
3196 | 3195 | |
---|
3197 | 3196 | hisi_sas_write32(hisi_hba, OQ_INT_SRC, 1 << queue); |
---|
3198 | 3197 | |
---|
3199 | | - tasklet_schedule(&cq->tasklet); |
---|
3200 | | - |
---|
3201 | | - return IRQ_HANDLED; |
---|
| 3198 | + return IRQ_WAKE_THREAD; |
---|
3202 | 3199 | } |
---|
3203 | 3200 | |
---|
3204 | 3201 | static irqreturn_t sata_int_v2_hw(int irq_no, void *p) |
---|
.. | .. |
---|
3214 | 3211 | u8 attached_sas_addr[SAS_ADDR_SIZE] = {0}; |
---|
3215 | 3212 | unsigned long flags; |
---|
3216 | 3213 | int phy_no, offset; |
---|
| 3214 | + |
---|
| 3215 | + del_timer(&phy->timer); |
---|
3217 | 3216 | |
---|
3218 | 3217 | phy_no = sas_phy->id; |
---|
3219 | 3218 | initial_fis = &hisi_hba->initial_fis[phy_no]; |
---|
.. | .. |
---|
3237 | 3236 | /* check ERR bit of Status Register */ |
---|
3238 | 3237 | if (fis->status & ATA_ERR) { |
---|
3239 | 3238 | dev_warn(dev, "sata int: phy%d FIS status: 0x%x\n", phy_no, |
---|
3240 | | - fis->status); |
---|
| 3239 | + fis->status); |
---|
3241 | 3240 | hisi_sas_notify_phy_event(phy, HISI_PHYE_LINK_RESET); |
---|
3242 | 3241 | res = IRQ_NONE; |
---|
3243 | 3242 | goto end; |
---|
.. | .. |
---|
3309 | 3308 | fatal_axi_int_v2_hw |
---|
3310 | 3309 | }; |
---|
3311 | 3310 | |
---|
3312 | | -/** |
---|
| 3311 | +/* |
---|
3313 | 3312 | * There is a limitation in the hip06 chipset that we need |
---|
3314 | 3313 | * to map in all mbigen interrupts, even if they are not used. |
---|
3315 | 3314 | */ |
---|
.. | .. |
---|
3317 | 3316 | { |
---|
3318 | 3317 | struct platform_device *pdev = hisi_hba->platform_dev; |
---|
3319 | 3318 | struct device *dev = &pdev->dev; |
---|
3320 | | - int irq, rc, irq_map[128]; |
---|
3321 | | - int i, phy_no, fatal_no, queue_no, k; |
---|
| 3319 | + int irq, rc = 0, irq_map[128]; |
---|
| 3320 | + int i, phy_no, fatal_no, queue_no; |
---|
3322 | 3321 | |
---|
3323 | 3322 | for (i = 0; i < 128; i++) |
---|
3324 | 3323 | irq_map[i] = platform_get_irq(pdev, i); |
---|
.. | .. |
---|
3328 | 3327 | rc = devm_request_irq(dev, irq, phy_interrupts[i], 0, |
---|
3329 | 3328 | DRV_NAME " phy", hisi_hba); |
---|
3330 | 3329 | if (rc) { |
---|
3331 | | - dev_err(dev, "irq init: could not request " |
---|
3332 | | - "phy interrupt %d, rc=%d\n", |
---|
| 3330 | + dev_err(dev, "irq init: could not request phy interrupt %d, rc=%d\n", |
---|
3333 | 3331 | irq, rc); |
---|
3334 | 3332 | rc = -ENOENT; |
---|
3335 | | - goto free_phy_int_irqs; |
---|
| 3333 | + goto err_out; |
---|
3336 | 3334 | } |
---|
3337 | 3335 | } |
---|
3338 | 3336 | |
---|
.. | .. |
---|
3343 | 3341 | rc = devm_request_irq(dev, irq, sata_int_v2_hw, 0, |
---|
3344 | 3342 | DRV_NAME " sata", phy); |
---|
3345 | 3343 | if (rc) { |
---|
3346 | | - dev_err(dev, "irq init: could not request " |
---|
3347 | | - "sata interrupt %d, rc=%d\n", |
---|
| 3344 | + dev_err(dev, "irq init: could not request sata interrupt %d, rc=%d\n", |
---|
3348 | 3345 | irq, rc); |
---|
3349 | 3346 | rc = -ENOENT; |
---|
3350 | | - goto free_sata_int_irqs; |
---|
| 3347 | + goto err_out; |
---|
3351 | 3348 | } |
---|
3352 | 3349 | } |
---|
3353 | 3350 | |
---|
.. | .. |
---|
3356 | 3353 | rc = devm_request_irq(dev, irq, fatal_interrupts[fatal_no], 0, |
---|
3357 | 3354 | DRV_NAME " fatal", hisi_hba); |
---|
3358 | 3355 | if (rc) { |
---|
3359 | | - dev_err(dev, |
---|
3360 | | - "irq init: could not request fatal interrupt %d, rc=%d\n", |
---|
| 3356 | + dev_err(dev, "irq init: could not request fatal interrupt %d, rc=%d\n", |
---|
3361 | 3357 | irq, rc); |
---|
3362 | 3358 | rc = -ENOENT; |
---|
3363 | | - goto free_fatal_int_irqs; |
---|
| 3359 | + goto err_out; |
---|
3364 | 3360 | } |
---|
3365 | 3361 | } |
---|
3366 | 3362 | |
---|
3367 | 3363 | for (queue_no = 0; queue_no < hisi_hba->queue_count; queue_no++) { |
---|
3368 | 3364 | struct hisi_sas_cq *cq = &hisi_hba->cq[queue_no]; |
---|
3369 | | - struct tasklet_struct *t = &cq->tasklet; |
---|
3370 | 3365 | |
---|
3371 | | - irq = irq_map[queue_no + 96]; |
---|
3372 | | - rc = devm_request_irq(dev, irq, cq_interrupt_v2_hw, 0, |
---|
3373 | | - DRV_NAME " cq", cq); |
---|
| 3366 | + cq->irq_no = irq_map[queue_no + 96]; |
---|
| 3367 | + rc = devm_request_threaded_irq(dev, cq->irq_no, |
---|
| 3368 | + cq_interrupt_v2_hw, |
---|
| 3369 | + cq_thread_v2_hw, IRQF_ONESHOT, |
---|
| 3370 | + DRV_NAME " cq", cq); |
---|
3374 | 3371 | if (rc) { |
---|
3375 | | - dev_err(dev, |
---|
3376 | | - "irq init: could not request cq interrupt %d, rc=%d\n", |
---|
| 3372 | + dev_err(dev, "irq init: could not request cq interrupt %d, rc=%d\n", |
---|
3377 | 3373 | irq, rc); |
---|
3378 | 3374 | rc = -ENOENT; |
---|
3379 | | - goto free_cq_int_irqs; |
---|
| 3375 | + goto err_out; |
---|
3380 | 3376 | } |
---|
3381 | | - tasklet_init(t, cq_tasklet_v2_hw, (unsigned long)cq); |
---|
3382 | 3377 | } |
---|
3383 | 3378 | |
---|
3384 | | - return 0; |
---|
| 3379 | + hisi_hba->cq_nvecs = hisi_hba->queue_count; |
---|
3385 | 3380 | |
---|
3386 | | -free_cq_int_irqs: |
---|
3387 | | - for (k = 0; k < queue_no; k++) { |
---|
3388 | | - struct hisi_sas_cq *cq = &hisi_hba->cq[k]; |
---|
3389 | | - |
---|
3390 | | - free_irq(irq_map[k + 96], cq); |
---|
3391 | | - tasklet_kill(&cq->tasklet); |
---|
3392 | | - } |
---|
3393 | | -free_fatal_int_irqs: |
---|
3394 | | - for (k = 0; k < fatal_no; k++) |
---|
3395 | | - free_irq(irq_map[k + 81], hisi_hba); |
---|
3396 | | -free_sata_int_irqs: |
---|
3397 | | - for (k = 0; k < phy_no; k++) { |
---|
3398 | | - struct hisi_sas_phy *phy = &hisi_hba->phy[k]; |
---|
3399 | | - |
---|
3400 | | - free_irq(irq_map[k + 72], phy); |
---|
3401 | | - } |
---|
3402 | | -free_phy_int_irqs: |
---|
3403 | | - for (k = 0; k < i; k++) |
---|
3404 | | - free_irq(irq_map[k + 1], hisi_hba); |
---|
| 3381 | +err_out: |
---|
3405 | 3382 | return rc; |
---|
3406 | 3383 | } |
---|
3407 | 3384 | |
---|
.. | .. |
---|
3457 | 3434 | |
---|
3458 | 3435 | interrupt_disable_v2_hw(hisi_hba); |
---|
3459 | 3436 | hisi_sas_write32(hisi_hba, DLVRY_QUEUE_ENABLE, 0x0); |
---|
3460 | | - hisi_sas_kill_tasklets(hisi_hba); |
---|
3461 | 3437 | |
---|
3462 | 3438 | hisi_sas_stop_phys(hisi_hba); |
---|
3463 | 3439 | |
---|
.. | .. |
---|
3523 | 3499 | break; |
---|
3524 | 3500 | default: |
---|
3525 | 3501 | dev_err(dev, "write gpio: unsupported or bad reg type %d\n", |
---|
3526 | | - reg_type); |
---|
| 3502 | + reg_type); |
---|
3527 | 3503 | return -EINVAL; |
---|
3528 | 3504 | } |
---|
3529 | 3505 | |
---|
.. | .. |
---|
3545 | 3521 | msleep(delay_ms); |
---|
3546 | 3522 | } |
---|
3547 | 3523 | |
---|
| 3524 | + if (time >= timeout_ms) { |
---|
| 3525 | + dev_dbg(dev, "Wait commands complete timeout!\n"); |
---|
| 3526 | + return; |
---|
| 3527 | + } |
---|
| 3528 | + |
---|
3548 | 3529 | dev_dbg(dev, "wait commands complete %dms\n", time); |
---|
| 3530 | + |
---|
3549 | 3531 | } |
---|
| 3532 | + |
---|
| 3533 | +static struct device_attribute *host_attrs_v2_hw[] = { |
---|
| 3534 | + &dev_attr_phy_event_threshold, |
---|
| 3535 | + NULL |
---|
| 3536 | +}; |
---|
3550 | 3537 | |
---|
3551 | 3538 | static struct scsi_host_template sht_v2_hw = { |
---|
3552 | 3539 | .name = DRV_NAME, |
---|
| 3540 | + .proc_name = DRV_NAME, |
---|
3553 | 3541 | .module = THIS_MODULE, |
---|
3554 | 3542 | .queuecommand = sas_queuecommand, |
---|
| 3543 | + .dma_need_drain = ata_scsi_dma_need_drain, |
---|
3555 | 3544 | .target_alloc = sas_target_alloc, |
---|
3556 | 3545 | .slave_configure = hisi_sas_slave_configure, |
---|
3557 | 3546 | .scan_finished = hisi_sas_scan_finished, |
---|
3558 | 3547 | .scan_start = hisi_sas_scan_start, |
---|
3559 | 3548 | .change_queue_depth = sas_change_queue_depth, |
---|
3560 | 3549 | .bios_param = sas_bios_param, |
---|
3561 | | - .can_queue = 1, |
---|
3562 | 3550 | .this_id = -1, |
---|
3563 | | - .sg_tablesize = SG_ALL, |
---|
| 3551 | + .sg_tablesize = HISI_SAS_SGE_PAGE_CNT, |
---|
3564 | 3552 | .max_sectors = SCSI_DEFAULT_MAX_SECTORS, |
---|
3565 | | - .use_clustering = ENABLE_CLUSTERING, |
---|
3566 | 3553 | .eh_device_reset_handler = sas_eh_device_reset_handler, |
---|
3567 | 3554 | .eh_target_reset_handler = sas_eh_target_reset_handler, |
---|
3568 | 3555 | .slave_alloc = sas_slave_alloc, |
---|
3569 | 3556 | .target_destroy = sas_target_destroy, |
---|
3570 | 3557 | .ioctl = sas_ioctl, |
---|
3571 | | - .shost_attrs = host_attrs, |
---|
| 3558 | +#ifdef CONFIG_COMPAT |
---|
| 3559 | + .compat_ioctl = sas_ioctl, |
---|
| 3560 | +#endif |
---|
| 3561 | + .shost_attrs = host_attrs_v2_hw, |
---|
| 3562 | + .host_reset = hisi_sas_host_reset, |
---|
3572 | 3563 | }; |
---|
3573 | 3564 | |
---|
3574 | 3565 | static const struct hisi_sas_hw hisi_sas_v2_hw = { |
---|
.. | .. |
---|
3584 | 3575 | .prep_ssp = prep_ssp_v2_hw, |
---|
3585 | 3576 | .prep_stp = prep_ata_v2_hw, |
---|
3586 | 3577 | .prep_abort = prep_abort_v2_hw, |
---|
3587 | | - .get_free_slot = get_free_slot_v2_hw, |
---|
3588 | 3578 | .start_delivery = start_delivery_v2_hw, |
---|
3589 | | - .slot_complete = slot_complete_v2_hw, |
---|
3590 | 3579 | .phys_init = phys_init_v2_hw, |
---|
3591 | 3580 | .phy_start = start_phy_v2_hw, |
---|
3592 | 3581 | .phy_disable = disable_phy_v2_hw, |
---|
.. | .. |
---|
3594 | 3583 | .get_events = phy_get_events_v2_hw, |
---|
3595 | 3584 | .phy_set_linkrate = phy_set_linkrate_v2_hw, |
---|
3596 | 3585 | .phy_get_max_linkrate = phy_get_max_linkrate_v2_hw, |
---|
3597 | | - .max_command_entries = HISI_SAS_COMMAND_ENTRIES_V2_HW, |
---|
3598 | 3586 | .complete_hdr_size = sizeof(struct hisi_sas_complete_v2_hdr), |
---|
3599 | 3587 | .soft_reset = soft_reset_v2_hw, |
---|
3600 | 3588 | .get_phys_state = get_phys_state_v2_hw, |
---|
.. | .. |
---|
3622 | 3610 | |
---|
3623 | 3611 | static int hisi_sas_v2_remove(struct platform_device *pdev) |
---|
3624 | 3612 | { |
---|
3625 | | - struct sas_ha_struct *sha = platform_get_drvdata(pdev); |
---|
3626 | | - struct hisi_hba *hisi_hba = sha->lldd_ha; |
---|
3627 | | - |
---|
3628 | | - hisi_sas_kill_tasklets(hisi_hba); |
---|
3629 | | - |
---|
3630 | 3613 | return hisi_sas_remove(pdev); |
---|
3631 | 3614 | } |
---|
3632 | 3615 | |
---|