| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * Serial Attached SCSI (SAS) class SCSI Host glue. |
|---|
| 3 | 4 | * |
|---|
| 4 | 5 | * Copyright (C) 2005 Adaptec, Inc. All rights reserved. |
|---|
| 5 | 6 | * Copyright (C) 2005 Luben Tuikov <luben_tuikov@adaptec.com> |
|---|
| 6 | | - * |
|---|
| 7 | | - * This file is licensed under GPLv2. |
|---|
| 8 | | - * |
|---|
| 9 | | - * This program is free software; you can redistribute it and/or |
|---|
| 10 | | - * modify it under the terms of the GNU General Public License as |
|---|
| 11 | | - * published by the Free Software Foundation; either version 2 of the |
|---|
| 12 | | - * License, or (at your option) any later version. |
|---|
| 13 | | - * |
|---|
| 14 | | - * This program is distributed in the hope that it will be useful, but |
|---|
| 15 | | - * WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 16 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|---|
| 17 | | - * General Public License for more details. |
|---|
| 18 | | - * |
|---|
| 19 | | - * You should have received a copy of the GNU General Public License |
|---|
| 20 | | - * along with this program; if not, write to the Free Software |
|---|
| 21 | | - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 |
|---|
| 22 | | - * USA |
|---|
| 23 | | - * |
|---|
| 24 | 7 | */ |
|---|
| 25 | 8 | |
|---|
| 26 | 9 | #include <linux/kthread.h> |
|---|
| .. | .. |
|---|
| 93 | 76 | hs = DID_ERROR; |
|---|
| 94 | 77 | break; |
|---|
| 95 | 78 | case SAS_PROTO_RESPONSE: |
|---|
| 96 | | - SAS_DPRINTK("LLDD:%s sent SAS_PROTO_RESP for an SSP " |
|---|
| 97 | | - "task; please report this\n", |
|---|
| 98 | | - task->dev->port->ha->sas_ha_name); |
|---|
| 79 | + pr_notice("LLDD:%s sent SAS_PROTO_RESP for an SSP task; please report this\n", |
|---|
| 80 | + task->dev->port->ha->sas_ha_name); |
|---|
| 99 | 81 | break; |
|---|
| 100 | 82 | case SAS_ABORTED_TASK: |
|---|
| 101 | 83 | hs = DID_ABORT; |
|---|
| .. | .. |
|---|
| 132 | 114 | |
|---|
| 133 | 115 | if (unlikely(!task)) { |
|---|
| 134 | 116 | /* task will be completed by the error handler */ |
|---|
| 135 | | - SAS_DPRINTK("task done but aborted\n"); |
|---|
| 117 | + pr_debug("task done but aborted\n"); |
|---|
| 136 | 118 | return; |
|---|
| 137 | 119 | } |
|---|
| 138 | 120 | |
|---|
| 139 | 121 | if (unlikely(!sc)) { |
|---|
| 140 | | - SAS_DPRINTK("task_done called with non existing SCSI cmnd!\n"); |
|---|
| 122 | + pr_debug("task_done called with non existing SCSI cmnd!\n"); |
|---|
| 141 | 123 | sas_free_task(task); |
|---|
| 142 | 124 | return; |
|---|
| 143 | 125 | } |
|---|
| .. | .. |
|---|
| 208 | 190 | return 0; |
|---|
| 209 | 191 | |
|---|
| 210 | 192 | out_free_task: |
|---|
| 211 | | - SAS_DPRINTK("lldd_execute_task returned: %d\n", res); |
|---|
| 193 | + pr_debug("lldd_execute_task returned: %d\n", res); |
|---|
| 212 | 194 | ASSIGN_SAS_TASK(cmd, NULL); |
|---|
| 213 | 195 | sas_free_task(task); |
|---|
| 214 | 196 | if (res == -SAS_QUEUE_FULL) |
|---|
| .. | .. |
|---|
| 301 | 283 | to_sas_internal(task->dev->port->ha->core.shost->transportt); |
|---|
| 302 | 284 | |
|---|
| 303 | 285 | for (i = 0; i < 5; i++) { |
|---|
| 304 | | - SAS_DPRINTK("%s: aborting task 0x%p\n", __func__, task); |
|---|
| 286 | + pr_notice("%s: aborting task 0x%p\n", __func__, task); |
|---|
| 305 | 287 | res = si->dft->lldd_abort_task(task); |
|---|
| 306 | 288 | |
|---|
| 307 | 289 | spin_lock_irqsave(&task->task_state_lock, flags); |
|---|
| 308 | 290 | if (task->task_state_flags & SAS_TASK_STATE_DONE) { |
|---|
| 309 | 291 | spin_unlock_irqrestore(&task->task_state_lock, flags); |
|---|
| 310 | | - SAS_DPRINTK("%s: task 0x%p is done\n", __func__, |
|---|
| 311 | | - task); |
|---|
| 292 | + pr_debug("%s: task 0x%p is done\n", __func__, task); |
|---|
| 312 | 293 | return TASK_IS_DONE; |
|---|
| 313 | 294 | } |
|---|
| 314 | 295 | spin_unlock_irqrestore(&task->task_state_lock, flags); |
|---|
| 315 | 296 | |
|---|
| 316 | 297 | if (res == TMF_RESP_FUNC_COMPLETE) { |
|---|
| 317 | | - SAS_DPRINTK("%s: task 0x%p is aborted\n", |
|---|
| 318 | | - __func__, task); |
|---|
| 298 | + pr_notice("%s: task 0x%p is aborted\n", |
|---|
| 299 | + __func__, task); |
|---|
| 319 | 300 | return TASK_IS_ABORTED; |
|---|
| 320 | 301 | } else if (si->dft->lldd_query_task) { |
|---|
| 321 | | - SAS_DPRINTK("%s: querying task 0x%p\n", |
|---|
| 322 | | - __func__, task); |
|---|
| 302 | + pr_notice("%s: querying task 0x%p\n", __func__, task); |
|---|
| 323 | 303 | res = si->dft->lldd_query_task(task); |
|---|
| 324 | 304 | switch (res) { |
|---|
| 325 | 305 | case TMF_RESP_FUNC_SUCC: |
|---|
| 326 | | - SAS_DPRINTK("%s: task 0x%p at LU\n", |
|---|
| 327 | | - __func__, task); |
|---|
| 306 | + pr_notice("%s: task 0x%p at LU\n", __func__, |
|---|
| 307 | + task); |
|---|
| 328 | 308 | return TASK_IS_AT_LU; |
|---|
| 329 | 309 | case TMF_RESP_FUNC_COMPLETE: |
|---|
| 330 | | - SAS_DPRINTK("%s: task 0x%p not at LU\n", |
|---|
| 331 | | - __func__, task); |
|---|
| 310 | + pr_notice("%s: task 0x%p not at LU\n", |
|---|
| 311 | + __func__, task); |
|---|
| 332 | 312 | return TASK_IS_NOT_AT_LU; |
|---|
| 333 | 313 | case TMF_RESP_FUNC_FAILED: |
|---|
| 334 | | - SAS_DPRINTK("%s: task 0x%p failed to abort\n", |
|---|
| 335 | | - __func__, task); |
|---|
| 336 | | - return TASK_ABORT_FAILED; |
|---|
| 337 | | - } |
|---|
| 314 | + pr_notice("%s: task 0x%p failed to abort\n", |
|---|
| 315 | + __func__, task); |
|---|
| 316 | + return TASK_ABORT_FAILED; |
|---|
| 317 | + } |
|---|
| 338 | 318 | |
|---|
| 339 | 319 | } |
|---|
| 340 | 320 | } |
|---|
| .. | .. |
|---|
| 350 | 330 | |
|---|
| 351 | 331 | int_to_scsilun(cmd->device->lun, &lun); |
|---|
| 352 | 332 | |
|---|
| 353 | | - SAS_DPRINTK("eh: device %llx LUN %llx has the task\n", |
|---|
| 354 | | - SAS_ADDR(dev->sas_addr), |
|---|
| 355 | | - cmd->device->lun); |
|---|
| 333 | + pr_notice("eh: device %016llx LUN 0x%llx has the task\n", |
|---|
| 334 | + SAS_ADDR(dev->sas_addr), |
|---|
| 335 | + cmd->device->lun); |
|---|
| 356 | 336 | |
|---|
| 357 | 337 | if (i->dft->lldd_abort_task_set) |
|---|
| 358 | 338 | res = i->dft->lldd_abort_task_set(dev, lun.scsi_lun); |
|---|
| .. | .. |
|---|
| 376 | 356 | struct sas_internal *i = |
|---|
| 377 | 357 | to_sas_internal(dev->port->ha->core.shost->transportt); |
|---|
| 378 | 358 | |
|---|
| 379 | | - SAS_DPRINTK("I_T nexus reset for dev %016llx\n", |
|---|
| 380 | | - SAS_ADDR(dev->sas_addr)); |
|---|
| 359 | + pr_notice("I_T nexus reset for dev %016llx\n", |
|---|
| 360 | + SAS_ADDR(dev->sas_addr)); |
|---|
| 381 | 361 | |
|---|
| 382 | 362 | if (i->dft->lldd_I_T_nexus_reset) |
|---|
| 383 | 363 | res = i->dft->lldd_I_T_nexus_reset(dev); |
|---|
| .. | .. |
|---|
| 434 | 414 | goto retry; |
|---|
| 435 | 415 | } |
|---|
| 436 | 416 | } |
|---|
| 437 | | -EXPORT_SYMBOL(sas_wait_eh); |
|---|
| 438 | 417 | |
|---|
| 439 | 418 | static int sas_queue_reset(struct domain_device *dev, int reset_type, |
|---|
| 440 | 419 | u64 lun, int wait) |
|---|
| .. | .. |
|---|
| 471 | 450 | return SUCCESS; |
|---|
| 472 | 451 | } |
|---|
| 473 | 452 | |
|---|
| 474 | | - SAS_DPRINTK("%s reset of %s failed\n", |
|---|
| 475 | | - reset_type == SAS_DEV_LU_RESET ? "LUN" : "Bus", |
|---|
| 476 | | - dev_name(&dev->rphy->dev)); |
|---|
| 453 | + pr_warn("%s reset of %s failed\n", |
|---|
| 454 | + reset_type == SAS_DEV_LU_RESET ? "LUN" : "Bus", |
|---|
| 455 | + dev_name(&dev->rphy->dev)); |
|---|
| 477 | 456 | |
|---|
| 478 | 457 | return FAILED; |
|---|
| 479 | 458 | } |
|---|
| .. | .. |
|---|
| 501 | 480 | if (task) |
|---|
| 502 | 481 | res = i->dft->lldd_abort_task(task); |
|---|
| 503 | 482 | else |
|---|
| 504 | | - SAS_DPRINTK("no task to abort\n"); |
|---|
| 483 | + pr_notice("no task to abort\n"); |
|---|
| 505 | 484 | if (res == TMF_RESP_FUNC_SUCC || res == TMF_RESP_FUNC_COMPLETE) |
|---|
| 506 | 485 | return SUCCESS; |
|---|
| 507 | 486 | |
|---|
| .. | .. |
|---|
| 612 | 591 | spin_unlock_irqrestore(&task->task_state_lock, flags); |
|---|
| 613 | 592 | |
|---|
| 614 | 593 | if (need_reset) { |
|---|
| 615 | | - SAS_DPRINTK("%s: task 0x%p requests reset\n", |
|---|
| 616 | | - __func__, task); |
|---|
| 594 | + pr_notice("%s: task 0x%p requests reset\n", |
|---|
| 595 | + __func__, task); |
|---|
| 617 | 596 | goto reset; |
|---|
| 618 | 597 | } |
|---|
| 619 | 598 | |
|---|
| 620 | | - SAS_DPRINTK("trying to find task 0x%p\n", task); |
|---|
| 599 | + pr_debug("trying to find task 0x%p\n", task); |
|---|
| 621 | 600 | res = sas_scsi_find_task(task); |
|---|
| 622 | 601 | |
|---|
| 623 | 602 | switch (res) { |
|---|
| 624 | 603 | case TASK_IS_DONE: |
|---|
| 625 | | - SAS_DPRINTK("%s: task 0x%p is done\n", __func__, |
|---|
| 604 | + pr_notice("%s: task 0x%p is done\n", __func__, |
|---|
| 626 | 605 | task); |
|---|
| 627 | 606 | sas_eh_finish_cmd(cmd); |
|---|
| 628 | 607 | continue; |
|---|
| 629 | 608 | case TASK_IS_ABORTED: |
|---|
| 630 | | - SAS_DPRINTK("%s: task 0x%p is aborted\n", |
|---|
| 631 | | - __func__, task); |
|---|
| 609 | + pr_notice("%s: task 0x%p is aborted\n", |
|---|
| 610 | + __func__, task); |
|---|
| 632 | 611 | sas_eh_finish_cmd(cmd); |
|---|
| 633 | 612 | continue; |
|---|
| 634 | 613 | case TASK_IS_AT_LU: |
|---|
| 635 | | - SAS_DPRINTK("task 0x%p is at LU: lu recover\n", task); |
|---|
| 614 | + pr_info("task 0x%p is at LU: lu recover\n", task); |
|---|
| 636 | 615 | reset: |
|---|
| 637 | 616 | tmf_resp = sas_recover_lu(task->dev, cmd); |
|---|
| 638 | 617 | if (tmf_resp == TMF_RESP_FUNC_COMPLETE) { |
|---|
| 639 | | - SAS_DPRINTK("dev %016llx LU %llx is " |
|---|
| 640 | | - "recovered\n", |
|---|
| 641 | | - SAS_ADDR(task->dev), |
|---|
| 642 | | - cmd->device->lun); |
|---|
| 618 | + pr_notice("dev %016llx LU 0x%llx is recovered\n", |
|---|
| 619 | + SAS_ADDR(task->dev), |
|---|
| 620 | + cmd->device->lun); |
|---|
| 643 | 621 | sas_eh_finish_cmd(cmd); |
|---|
| 644 | 622 | sas_scsi_clear_queue_lu(work_q, cmd); |
|---|
| 645 | 623 | goto Again; |
|---|
| 646 | 624 | } |
|---|
| 647 | | - /* fallthrough */ |
|---|
| 625 | + fallthrough; |
|---|
| 648 | 626 | case TASK_IS_NOT_AT_LU: |
|---|
| 649 | 627 | case TASK_ABORT_FAILED: |
|---|
| 650 | | - SAS_DPRINTK("task 0x%p is not at LU: I_T recover\n", |
|---|
| 651 | | - task); |
|---|
| 628 | + pr_notice("task 0x%p is not at LU: I_T recover\n", |
|---|
| 629 | + task); |
|---|
| 652 | 630 | tmf_resp = sas_recover_I_T(task->dev); |
|---|
| 653 | 631 | if (tmf_resp == TMF_RESP_FUNC_COMPLETE || |
|---|
| 654 | 632 | tmf_resp == -ENODEV) { |
|---|
| 655 | 633 | struct domain_device *dev = task->dev; |
|---|
| 656 | | - SAS_DPRINTK("I_T %016llx recovered\n", |
|---|
| 657 | | - SAS_ADDR(task->dev->sas_addr)); |
|---|
| 634 | + pr_notice("I_T %016llx recovered\n", |
|---|
| 635 | + SAS_ADDR(task->dev->sas_addr)); |
|---|
| 658 | 636 | sas_eh_finish_cmd(cmd); |
|---|
| 659 | 637 | sas_scsi_clear_queue_I_T(work_q, dev); |
|---|
| 660 | 638 | goto Again; |
|---|
| .. | .. |
|---|
| 663 | 641 | try_to_reset_cmd_device(cmd); |
|---|
| 664 | 642 | if (i->dft->lldd_clear_nexus_port) { |
|---|
| 665 | 643 | struct asd_sas_port *port = task->dev->port; |
|---|
| 666 | | - SAS_DPRINTK("clearing nexus for port:%d\n", |
|---|
| 667 | | - port->id); |
|---|
| 644 | + pr_debug("clearing nexus for port:%d\n", |
|---|
| 645 | + port->id); |
|---|
| 668 | 646 | res = i->dft->lldd_clear_nexus_port(port); |
|---|
| 669 | 647 | if (res == TMF_RESP_FUNC_COMPLETE) { |
|---|
| 670 | | - SAS_DPRINTK("clear nexus port:%d " |
|---|
| 671 | | - "succeeded\n", port->id); |
|---|
| 648 | + pr_notice("clear nexus port:%d succeeded\n", |
|---|
| 649 | + port->id); |
|---|
| 672 | 650 | sas_eh_finish_cmd(cmd); |
|---|
| 673 | 651 | sas_scsi_clear_queue_port(work_q, |
|---|
| 674 | 652 | port); |
|---|
| .. | .. |
|---|
| 676 | 654 | } |
|---|
| 677 | 655 | } |
|---|
| 678 | 656 | if (i->dft->lldd_clear_nexus_ha) { |
|---|
| 679 | | - SAS_DPRINTK("clear nexus ha\n"); |
|---|
| 657 | + pr_debug("clear nexus ha\n"); |
|---|
| 680 | 658 | res = i->dft->lldd_clear_nexus_ha(ha); |
|---|
| 681 | 659 | if (res == TMF_RESP_FUNC_COMPLETE) { |
|---|
| 682 | | - SAS_DPRINTK("clear nexus ha " |
|---|
| 683 | | - "succeeded\n"); |
|---|
| 660 | + pr_notice("clear nexus ha succeeded\n"); |
|---|
| 684 | 661 | sas_eh_finish_cmd(cmd); |
|---|
| 685 | 662 | goto clear_q; |
|---|
| 686 | 663 | } |
|---|
| .. | .. |
|---|
| 689 | 666 | * of effort could recover from errors. Quite |
|---|
| 690 | 667 | * possibly the HA just disappeared. |
|---|
| 691 | 668 | */ |
|---|
| 692 | | - SAS_DPRINTK("error from device %llx, LUN %llx " |
|---|
| 693 | | - "couldn't be recovered in any way\n", |
|---|
| 694 | | - SAS_ADDR(task->dev->sas_addr), |
|---|
| 695 | | - cmd->device->lun); |
|---|
| 669 | + pr_err("error from device %016llx, LUN 0x%llx couldn't be recovered in any way\n", |
|---|
| 670 | + SAS_ADDR(task->dev->sas_addr), |
|---|
| 671 | + cmd->device->lun); |
|---|
| 696 | 672 | |
|---|
| 697 | 673 | sas_eh_finish_cmd(cmd); |
|---|
| 698 | 674 | goto clear_q; |
|---|
| .. | .. |
|---|
| 704 | 680 | return; |
|---|
| 705 | 681 | |
|---|
| 706 | 682 | clear_q: |
|---|
| 707 | | - SAS_DPRINTK("--- Exit %s -- clear_q\n", __func__); |
|---|
| 683 | + pr_debug("--- Exit %s -- clear_q\n", __func__); |
|---|
| 708 | 684 | list_for_each_entry_safe(cmd, n, work_q, eh_entry) |
|---|
| 709 | 685 | sas_eh_finish_cmd(cmd); |
|---|
| 710 | 686 | goto out; |
|---|
| .. | .. |
|---|
| 758 | 734 | list_splice_init(&shost->eh_cmd_q, &eh_work_q); |
|---|
| 759 | 735 | spin_unlock_irq(shost->host_lock); |
|---|
| 760 | 736 | |
|---|
| 761 | | - SAS_DPRINTK("Enter %s busy: %d failed: %d\n", |
|---|
| 762 | | - __func__, scsi_host_busy(shost), shost->host_failed); |
|---|
| 737 | + pr_notice("Enter %s busy: %d failed: %d\n", |
|---|
| 738 | + __func__, scsi_host_busy(shost), shost->host_failed); |
|---|
| 763 | 739 | /* |
|---|
| 764 | 740 | * Deal with commands that still have SAS tasks (i.e. they didn't |
|---|
| 765 | 741 | * complete via the normal sas_task completion mechanism), |
|---|
| .. | .. |
|---|
| 800 | 776 | if (retry) |
|---|
| 801 | 777 | goto retry; |
|---|
| 802 | 778 | |
|---|
| 803 | | - SAS_DPRINTK("--- Exit %s: busy: %d failed: %d tries: %d\n", |
|---|
| 804 | | - __func__, scsi_host_busy(shost), |
|---|
| 805 | | - shost->host_failed, tries); |
|---|
| 779 | + pr_notice("--- Exit %s: busy: %d failed: %d tries: %d\n", |
|---|
| 780 | + __func__, scsi_host_busy(shost), |
|---|
| 781 | + shost->host_failed, tries); |
|---|
| 806 | 782 | } |
|---|
| 807 | 783 | |
|---|
| 808 | | -int sas_ioctl(struct scsi_device *sdev, int cmd, void __user *arg) |
|---|
| 784 | +int sas_ioctl(struct scsi_device *sdev, unsigned int cmd, void __user *arg) |
|---|
| 809 | 785 | { |
|---|
| 810 | 786 | struct domain_device *dev = sdev_to_domain_dev(sdev); |
|---|
| 811 | 787 | |
|---|
| .. | .. |
|---|
| 875 | 851 | if (scsi_dev->tagged_supported) { |
|---|
| 876 | 852 | scsi_change_queue_depth(scsi_dev, SAS_DEF_QD); |
|---|
| 877 | 853 | } else { |
|---|
| 878 | | - SAS_DPRINTK("device %llx, LUN %llx doesn't support " |
|---|
| 879 | | - "TCQ\n", SAS_ADDR(dev->sas_addr), |
|---|
| 880 | | - scsi_dev->lun); |
|---|
| 854 | + pr_notice("device %016llx, LUN 0x%llx doesn't support TCQ\n", |
|---|
| 855 | + SAS_ADDR(dev->sas_addr), scsi_dev->lun); |
|---|
| 881 | 856 | scsi_change_queue_depth(scsi_dev, 1); |
|---|
| 882 | 857 | } |
|---|
| 883 | 858 | |
|---|
| .. | .. |
|---|
| 930 | 905 | return; |
|---|
| 931 | 906 | } |
|---|
| 932 | 907 | |
|---|
| 933 | | - if (dev_is_sata(task->dev)) { |
|---|
| 908 | + if (dev_is_sata(task->dev)) |
|---|
| 934 | 909 | sas_ata_task_abort(task); |
|---|
| 935 | | - } else { |
|---|
| 936 | | - struct request_queue *q = sc->device->request_queue; |
|---|
| 937 | | - unsigned long flags; |
|---|
| 938 | | - |
|---|
| 939 | | - spin_lock_irqsave(q->queue_lock, flags); |
|---|
| 910 | + else |
|---|
| 940 | 911 | blk_abort_request(sc->request); |
|---|
| 941 | | - spin_unlock_irqrestore(q->queue_lock, flags); |
|---|
| 942 | | - } |
|---|
| 943 | 912 | } |
|---|
| 944 | 913 | |
|---|
| 945 | 914 | int sas_slave_alloc(struct scsi_device *sdev) |
|---|