hc
2023-12-11 d2ccde1c8e90d38cee87a1b0309ad2827f3fd30d
kernel/drivers/scsi/libsas/sas_scsi_host.c
....@@ -1,26 +1,9 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * Serial Attached SCSI (SAS) class SCSI Host glue.
34 *
45 * Copyright (C) 2005 Adaptec, Inc. All rights reserved.
56 * 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
- *
247 */
258
269 #include <linux/kthread.h>
....@@ -93,9 +76,8 @@
9376 hs = DID_ERROR;
9477 break;
9578 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);
9981 break;
10082 case SAS_ABORTED_TASK:
10183 hs = DID_ABORT;
....@@ -132,12 +114,12 @@
132114
133115 if (unlikely(!task)) {
134116 /* task will be completed by the error handler */
135
- SAS_DPRINTK("task done but aborted\n");
117
+ pr_debug("task done but aborted\n");
136118 return;
137119 }
138120
139121 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");
141123 sas_free_task(task);
142124 return;
143125 }
....@@ -208,7 +190,7 @@
208190 return 0;
209191
210192 out_free_task:
211
- SAS_DPRINTK("lldd_execute_task returned: %d\n", res);
193
+ pr_debug("lldd_execute_task returned: %d\n", res);
212194 ASSIGN_SAS_TASK(cmd, NULL);
213195 sas_free_task(task);
214196 if (res == -SAS_QUEUE_FULL)
....@@ -301,40 +283,38 @@
301283 to_sas_internal(task->dev->port->ha->core.shost->transportt);
302284
303285 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);
305287 res = si->dft->lldd_abort_task(task);
306288
307289 spin_lock_irqsave(&task->task_state_lock, flags);
308290 if (task->task_state_flags & SAS_TASK_STATE_DONE) {
309291 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);
312293 return TASK_IS_DONE;
313294 }
314295 spin_unlock_irqrestore(&task->task_state_lock, flags);
315296
316297 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);
319300 return TASK_IS_ABORTED;
320301 } 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);
323303 res = si->dft->lldd_query_task(task);
324304 switch (res) {
325305 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);
328308 return TASK_IS_AT_LU;
329309 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);
332312 return TASK_IS_NOT_AT_LU;
333313 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
+ }
338318
339319 }
340320 }
....@@ -350,9 +330,9 @@
350330
351331 int_to_scsilun(cmd->device->lun, &lun);
352332
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);
356336
357337 if (i->dft->lldd_abort_task_set)
358338 res = i->dft->lldd_abort_task_set(dev, lun.scsi_lun);
....@@ -376,8 +356,8 @@
376356 struct sas_internal *i =
377357 to_sas_internal(dev->port->ha->core.shost->transportt);
378358
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));
381361
382362 if (i->dft->lldd_I_T_nexus_reset)
383363 res = i->dft->lldd_I_T_nexus_reset(dev);
....@@ -434,7 +414,6 @@
434414 goto retry;
435415 }
436416 }
437
-EXPORT_SYMBOL(sas_wait_eh);
438417
439418 static int sas_queue_reset(struct domain_device *dev, int reset_type,
440419 u64 lun, int wait)
....@@ -471,9 +450,9 @@
471450 return SUCCESS;
472451 }
473452
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));
477456
478457 return FAILED;
479458 }
....@@ -501,7 +480,7 @@
501480 if (task)
502481 res = i->dft->lldd_abort_task(task);
503482 else
504
- SAS_DPRINTK("no task to abort\n");
483
+ pr_notice("no task to abort\n");
505484 if (res == TMF_RESP_FUNC_SUCC || res == TMF_RESP_FUNC_COMPLETE)
506485 return SUCCESS;
507486
....@@ -612,49 +591,48 @@
612591 spin_unlock_irqrestore(&task->task_state_lock, flags);
613592
614593 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);
617596 goto reset;
618597 }
619598
620
- SAS_DPRINTK("trying to find task 0x%p\n", task);
599
+ pr_debug("trying to find task 0x%p\n", task);
621600 res = sas_scsi_find_task(task);
622601
623602 switch (res) {
624603 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__,
626605 task);
627606 sas_eh_finish_cmd(cmd);
628607 continue;
629608 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);
632611 sas_eh_finish_cmd(cmd);
633612 continue;
634613 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);
636615 reset:
637616 tmf_resp = sas_recover_lu(task->dev, cmd);
638617 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);
643621 sas_eh_finish_cmd(cmd);
644622 sas_scsi_clear_queue_lu(work_q, cmd);
645623 goto Again;
646624 }
647
- /* fallthrough */
625
+ fallthrough;
648626 case TASK_IS_NOT_AT_LU:
649627 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);
652630 tmf_resp = sas_recover_I_T(task->dev);
653631 if (tmf_resp == TMF_RESP_FUNC_COMPLETE ||
654632 tmf_resp == -ENODEV) {
655633 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));
658636 sas_eh_finish_cmd(cmd);
659637 sas_scsi_clear_queue_I_T(work_q, dev);
660638 goto Again;
....@@ -663,12 +641,12 @@
663641 try_to_reset_cmd_device(cmd);
664642 if (i->dft->lldd_clear_nexus_port) {
665643 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);
668646 res = i->dft->lldd_clear_nexus_port(port);
669647 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);
672650 sas_eh_finish_cmd(cmd);
673651 sas_scsi_clear_queue_port(work_q,
674652 port);
....@@ -676,11 +654,10 @@
676654 }
677655 }
678656 if (i->dft->lldd_clear_nexus_ha) {
679
- SAS_DPRINTK("clear nexus ha\n");
657
+ pr_debug("clear nexus ha\n");
680658 res = i->dft->lldd_clear_nexus_ha(ha);
681659 if (res == TMF_RESP_FUNC_COMPLETE) {
682
- SAS_DPRINTK("clear nexus ha "
683
- "succeeded\n");
660
+ pr_notice("clear nexus ha succeeded\n");
684661 sas_eh_finish_cmd(cmd);
685662 goto clear_q;
686663 }
....@@ -689,10 +666,9 @@
689666 * of effort could recover from errors. Quite
690667 * possibly the HA just disappeared.
691668 */
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);
696672
697673 sas_eh_finish_cmd(cmd);
698674 goto clear_q;
....@@ -704,7 +680,7 @@
704680 return;
705681
706682 clear_q:
707
- SAS_DPRINTK("--- Exit %s -- clear_q\n", __func__);
683
+ pr_debug("--- Exit %s -- clear_q\n", __func__);
708684 list_for_each_entry_safe(cmd, n, work_q, eh_entry)
709685 sas_eh_finish_cmd(cmd);
710686 goto out;
....@@ -758,8 +734,8 @@
758734 list_splice_init(&shost->eh_cmd_q, &eh_work_q);
759735 spin_unlock_irq(shost->host_lock);
760736
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);
763739 /*
764740 * Deal with commands that still have SAS tasks (i.e. they didn't
765741 * complete via the normal sas_task completion mechanism),
....@@ -800,12 +776,12 @@
800776 if (retry)
801777 goto retry;
802778
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);
806782 }
807783
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)
809785 {
810786 struct domain_device *dev = sdev_to_domain_dev(sdev);
811787
....@@ -875,9 +851,8 @@
875851 if (scsi_dev->tagged_supported) {
876852 scsi_change_queue_depth(scsi_dev, SAS_DEF_QD);
877853 } 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);
881856 scsi_change_queue_depth(scsi_dev, 1);
882857 }
883858
....@@ -930,16 +905,10 @@
930905 return;
931906 }
932907
933
- if (dev_is_sata(task->dev)) {
908
+ if (dev_is_sata(task->dev))
934909 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
940911 blk_abort_request(sc->request);
941
- spin_unlock_irqrestore(q->queue_lock, flags);
942
- }
943912 }
944913
945914 int sas_slave_alloc(struct scsi_device *sdev)