hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/drivers/scsi/scsi.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * scsi.c Copyright (C) 1992 Drew Eckhardt
34 * Copyright (C) 1993, 1994, 1995, 1999 Eric Youngdale
....@@ -85,32 +86,13 @@
8586 EXPORT_SYMBOL(scsi_logging_level);
8687 #endif
8788
88
-/* sd, scsi core and power management need to coordinate flushing async actions */
89
-ASYNC_DOMAIN(scsi_sd_probe_domain);
90
-EXPORT_SYMBOL(scsi_sd_probe_domain);
91
-
9289 /*
93
- * Separate domain (from scsi_sd_probe_domain) to maximize the benefit of
94
- * asynchronous system resume operations. It is marked 'exclusive' to avoid
95
- * being included in the async_synchronize_full() that is invoked by
96
- * dpm_resume()
90
+ * Domain for asynchronous system resume operations. It is marked 'exclusive'
91
+ * to avoid being included in the async_synchronize_full() that is invoked by
92
+ * dpm_resume().
9793 */
9894 ASYNC_DOMAIN_EXCLUSIVE(scsi_sd_pm_domain);
9995 EXPORT_SYMBOL(scsi_sd_pm_domain);
100
-
101
-/**
102
- * scsi_put_command - Free a scsi command block
103
- * @cmd: command block to free
104
- *
105
- * Returns: Nothing.
106
- *
107
- * Notes: The command must not belong to any lists.
108
- */
109
-void scsi_put_command(struct scsi_cmnd *cmd)
110
-{
111
- scsi_del_cmd_from_list(cmd);
112
- BUG_ON(delayed_work_pending(&cmd->abort_work));
113
-}
11496
11597 #ifdef CONFIG_SCSI_LOGGING
11698 void scsi_log_send(struct scsi_cmnd *cmd)
....@@ -175,22 +157,6 @@
175157 #endif
176158
177159 /**
178
- * scsi_cmd_get_serial - Assign a serial number to a command
179
- * @host: the scsi host
180
- * @cmd: command to assign serial number to
181
- *
182
- * Description: a serial number identifies a request for error recovery
183
- * and debugging purposes. Protected by the Host_Lock of host.
184
- */
185
-void scsi_cmd_get_serial(struct Scsi_Host *host, struct scsi_cmnd *cmd)
186
-{
187
- cmd->serial_number = host->cmd_serial_number++;
188
- if (cmd->serial_number == 0)
189
- cmd->serial_number = host->cmd_serial_number++;
190
-}
191
-EXPORT_SYMBOL(scsi_cmd_get_serial);
192
-
193
-/**
194160 * scsi_finish_command - cleanup and pass command back to upper layer
195161 * @cmd: the command
196162 *
....@@ -206,7 +172,7 @@
206172 struct scsi_driver *drv;
207173 unsigned int good_bytes;
208174
209
- scsi_device_unbusy(sdev);
175
+ scsi_device_unbusy(sdev, cmd);
210176
211177 /*
212178 * Clear the flags that say that the device/target/host is no longer
....@@ -351,11 +317,18 @@
351317 if (result)
352318 return -EIO;
353319
354
- /* Sanity check that we got the page back that we asked for */
320
+ /*
321
+ * Sanity check that we got the page back that we asked for and that
322
+ * the page size is not 0.
323
+ */
355324 if (buffer[1] != page)
356325 return -EIO;
357326
358
- return get_unaligned_be16(&buffer[2]) + 4;
327
+ result = get_unaligned_be16(&buffer[2]);
328
+ if (!result)
329
+ return -EIO;
330
+
331
+ return result + 4;
359332 }
360333
361334 /**
....@@ -454,8 +427,8 @@
454427 return;
455428
456429 mutex_lock(&sdev->inquiry_mutex);
457
- rcu_swap_protected(*sdev_vpd_buf, vpd_buf,
458
- lockdep_is_held(&sdev->inquiry_mutex));
430
+ vpd_buf = rcu_replace_pointer(*sdev_vpd_buf, vpd_buf,
431
+ lockdep_is_held(&sdev->inquiry_mutex));
459432 mutex_unlock(&sdev->inquiry_mutex);
460433
461434 if (vpd_buf)
....@@ -485,10 +458,14 @@
485458 return;
486459
487460 for (i = 4; i < vpd_buf->len; i++) {
461
+ if (vpd_buf->data[i] == 0x0)
462
+ scsi_update_vpd_page(sdev, 0x0, &sdev->vpd_pg0);
488463 if (vpd_buf->data[i] == 0x80)
489464 scsi_update_vpd_page(sdev, 0x80, &sdev->vpd_pg80);
490465 if (vpd_buf->data[i] == 0x83)
491466 scsi_update_vpd_page(sdev, 0x83, &sdev->vpd_pg83);
467
+ if (vpd_buf->data[i] == 0x89)
468
+ scsi_update_vpd_page(sdev, 0x89, &sdev->vpd_pg89);
492469 }
493470 kfree(vpd_buf);
494471 }
....@@ -782,20 +759,10 @@
782759 module_param(scsi_logging_level, int, S_IRUGO|S_IWUSR);
783760 MODULE_PARM_DESC(scsi_logging_level, "a bit mask of logging levels");
784761
785
-#ifdef CONFIG_SCSI_MQ_DEFAULT
786
-bool scsi_use_blk_mq = true;
787
-#else
788
-bool scsi_use_blk_mq = false;
789
-#endif
790
-module_param_named(use_blk_mq, scsi_use_blk_mq, bool, S_IWUSR | S_IRUGO);
791
-
792762 static int __init init_scsi(void)
793763 {
794764 int error;
795765
796
- error = scsi_init_queue();
797
- if (error)
798
- return error;
799766 error = scsi_init_procfs();
800767 if (error)
801768 goto cleanup_queue;
....@@ -841,7 +808,6 @@
841808 scsi_exit_devinfo();
842809 scsi_exit_procfs();
843810 scsi_exit_queue();
844
- async_unregister_domain(&scsi_sd_probe_domain);
845811 }
846812
847813 subsys_initcall(init_scsi);