hc
2024-12-19 9370bb92b2d16684ee45cf24e879c93c509162da
kernel/drivers/ata/libata-core.c
....@@ -3051,7 +3051,7 @@
30513051 */
30523052 if (spd > 1)
30533053 mask &= (1 << (spd - 1)) - 1;
3054
- else
3054
+ else if (link->sata_spd)
30553055 return -EINVAL;
30563056
30573057 /* were we already at the bottom? */
....@@ -4974,17 +4974,19 @@
49744974 struct ata_link *link;
49754975 unsigned long flags;
49764976
4977
- /* Previous resume operation might still be in
4978
- * progress. Wait for PM_PENDING to clear.
4979
- */
4980
- if (ap->pflags & ATA_PFLAG_PM_PENDING) {
4981
- ata_port_wait_eh(ap);
4982
- WARN_ON(ap->pflags & ATA_PFLAG_PM_PENDING);
4983
- }
4984
-
4985
- /* request PM ops to EH */
49864977 spin_lock_irqsave(ap->lock, flags);
49874978
4979
+ /*
4980
+ * A previous PM operation might still be in progress. Wait for
4981
+ * ATA_PFLAG_PM_PENDING to clear.
4982
+ */
4983
+ if (ap->pflags & ATA_PFLAG_PM_PENDING) {
4984
+ spin_unlock_irqrestore(ap->lock, flags);
4985
+ ata_port_wait_eh(ap);
4986
+ spin_lock_irqsave(ap->lock, flags);
4987
+ }
4988
+
4989
+ /* Request PM operation to EH */
49884990 ap->pm_mesg = mesg;
49894991 ap->pflags |= ATA_PFLAG_PM_PENDING;
49904992 ata_for_each_link(link, ap, HOST_FIRST) {
....@@ -4996,10 +4998,8 @@
49964998
49974999 spin_unlock_irqrestore(ap->lock, flags);
49985000
4999
- if (!async) {
5001
+ if (!async)
50005002 ata_port_wait_eh(ap);
5001
- WARN_ON(ap->pflags & ATA_PFLAG_PM_PENDING);
5002
- }
50035003 }
50045004
50055005 /*
....@@ -5167,7 +5167,7 @@
51675167 #endif
51685168
51695169 const struct device_type ata_port_type = {
5170
- .name = "ata_port",
5170
+ .name = ATA_PORT_TYPE_NAME,
51715171 #ifdef CONFIG_PM
51725172 .pm = &ata_port_pm_ops,
51735173 #endif
....@@ -5915,11 +5915,30 @@
59155915 if (!ap->ops->error_handler)
59165916 goto skip_eh;
59175917
5918
- /* tell EH we're leaving & flush EH */
5918
+ /* Wait for any ongoing EH */
5919
+ ata_port_wait_eh(ap);
5920
+
5921
+ mutex_lock(&ap->scsi_scan_mutex);
59195922 spin_lock_irqsave(ap->lock, flags);
5923
+
5924
+ /* Remove scsi devices */
5925
+ ata_for_each_link(link, ap, HOST_FIRST) {
5926
+ ata_for_each_dev(dev, link, ALL) {
5927
+ if (dev->sdev) {
5928
+ spin_unlock_irqrestore(ap->lock, flags);
5929
+ scsi_remove_device(dev->sdev);
5930
+ spin_lock_irqsave(ap->lock, flags);
5931
+ dev->sdev = NULL;
5932
+ }
5933
+ }
5934
+ }
5935
+
5936
+ /* Tell EH to disable all devices */
59205937 ap->pflags |= ATA_PFLAG_UNLOADING;
59215938 ata_port_schedule_eh(ap);
5939
+
59225940 spin_unlock_irqrestore(ap->lock, flags);
5941
+ mutex_unlock(&ap->scsi_scan_mutex);
59235942
59245943 /* wait till EH commits suicide */
59255944 ata_port_wait_eh(ap);