On 22/02/2021 13:23, Hannes Reinecke wrote:
void scsi_forget_host(struct Scsi_Host *shost)
{
- struct scsi_device *sdev;
+ struct scsi_device *sdev, *host_sdev = NULL;
unsigned long flags;
restart:
spin_lock_irqsave(shost->host_lock, flags);
list_for_each_entry(sdev, &shost->__devices, siblings) {
+ if (scsi_device_is_host_dev(sdev)) {
+ host_sdev = sdev;
Is there actually a limit of 1x host_sdev always?
+ continue;
+ }
if (sdev->sdev_state == SDEV_DEL)
continue;
spin_unlock_irqrestore(shost->host_lock, flags);
@@ -1889,10 +1905,13 @@ void scsi_forget_host(struct Scsi_Host *shost)
goto restart;
}
spin_unlock_irqrestore(shost->host_lock, flags);
+ /* Remove host device last, might be needed to send commands */
+ if (host_sdev)
+ __scsi_remove_device(host_sdev);
}