[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1654770559-101375-6-git-send-email-john.garry@huawei.com>
Date: Thu, 9 Jun 2022 18:29:06 +0800
From: John Garry <john.garry@...wei.com>
To: <axboe@...nel.dk>, <damien.lemoal@...nsource.wdc.com>,
<jejb@...ux.ibm.com>, <martin.petersen@...cle.com>,
<brking@...ibm.com>, <hare@...e.de>, <hch@....de>
CC: <linux-block@...r.kernel.org>, <linux-ide@...r.kernel.org>,
<linux-kernel@...r.kernel.org>, <linux-scsi@...r.kernel.org>,
<chenxiang66@...ilicon.com>, John Garry <john.garry@...wei.com>
Subject: [PATCH RFC v2 05/18] scsi: core: Allocate SCSI host sdev when required
When the shost supports reserved commands then allocate the SCSI host sdev.
As noted later, we need to use this for libata internal commands.
Signed-off-by: John Garry <john.garry@...wei.com>
---
drivers/scsi/hosts.c | 5 +++++
include/scsi/scsi_host.h | 1 +
2 files changed, 6 insertions(+)
diff --git a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c
index 5c9b05a8fec8..67930a61b222 100644
--- a/drivers/scsi/hosts.c
+++ b/drivers/scsi/hosts.c
@@ -298,6 +298,8 @@ int scsi_add_host_with_dma(struct Scsi_Host *shost, struct device *dev,
scsi_proc_host_add(shost);
scsi_autopm_put_host(shost);
+ if (shost->nr_reserved_cmds)
+ shost->sdev = scsi_get_host_dev(shost); // TODO: Add error handling
return error;
/*
@@ -360,6 +362,9 @@ static void scsi_host_dev_release(struct device *dev)
if (shost->shost_state != SHOST_CREATED)
put_device(parent);
+ if (shost->sdev)
+ scsi_free_host_dev(shost->sdev);
+
kfree(shost);
}
diff --git a/include/scsi/scsi_host.h b/include/scsi/scsi_host.h
index 88c8504395c8..2e14d65b7444 100644
--- a/include/scsi/scsi_host.h
+++ b/include/scsi/scsi_host.h
@@ -566,6 +566,7 @@ struct Scsi_Host {
wait_queue_head_t host_wait;
struct scsi_host_template *hostt;
struct scsi_transport_template *transportt;
+ struct scsi_device *sdev;
/* Area to keep a shared tag map */
struct blk_mq_tag_set tag_set;
--
2.26.2
Powered by blists - more mailing lists