From: John Garry <john.garry@huawei.com>
To: <damien.lemoal@opensource.wdc.com>, <jejb@linux.ibm.com>,
<martin.petersen@oracle.com>, <hare@suse.de>, <hch@lst.de>
Cc: <linux-ide@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
<linux-scsi@vger.kernel.org>, <brking@us.ibm.com>,
John Garry <john.garry@huawei.com>
Subject: [PATCH RFC 6/6] ata: libata-scsi: Allocate sdev early in port probe
Date: Tue, 20 Sep 2022 18:27:10 +0800 [thread overview]
Message-ID: <1663669630-21333-7-git-send-email-john.garry@huawei.com> (raw)
In-Reply-To: <1663669630-21333-1-git-send-email-john.garry@huawei.com>
Currently the per-ata device sdev is allocated as part of the scsi target
scan, which is after the ata port probe.
However it is useful to have the sdev available in the port probe. As an
example of an advantage, if the request queue is available in the probe
(which it would be if the sdev is available), then it is possible to use
a SCSI cmnd for ATA internal commands. The benefit of this is then we can
put the ATA qc structure in the SCSI cmnd private data. It will also be
useful if we want to send ATA internal commands as requests.
Signed-off-by: John Garry <john.garry@huawei.com>
---
drivers/ata/libata-eh.c | 4 ++++
drivers/ata/libata-scsi.c | 20 ++++++--------------
2 files changed, 10 insertions(+), 14 deletions(-)
diff --git a/drivers/ata/libata-eh.c b/drivers/ata/libata-eh.c
index 7c128c89b454..35375873a464 100644
--- a/drivers/ata/libata-eh.c
+++ b/drivers/ata/libata-eh.c
@@ -2971,6 +2971,10 @@ static int ata_eh_revalidate_and_attach(struct ata_link *link,
*/
dev->class = ehc->classes[dev->devno];
+ rc = ata_scsi_setup_sdev(dev);
+ if (rc)
+ goto err;
+
if (dev->class == ATA_DEV_PMP)
rc = sata_pmp_attach(dev);
else
diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
index 88f39ab10a92..0e26860a82e2 100644
--- a/drivers/ata/libata-scsi.c
+++ b/drivers/ata/libata-scsi.c
@@ -1111,7 +1111,9 @@ int ata_scsi_dev_config(struct scsi_device *sdev, struct ata_device *dev)
if (dev->flags & ATA_DFLAG_TRUSTED)
sdev->security_supported = 1;
- dev->sdev = sdev;
+ /* Put extra reference which we get when allocating the starget initially */
+ scsi_target_reap(scsi_target(sdev));
+
return 0;
}
@@ -4279,6 +4281,7 @@ int ata_scsi_setup_sdev(struct ata_device *dev)
if (!sdev)
return -ENODEV;
dev->sdev = sdev;
+ ata_scsi_assign_ofnode(dev, ap);
return 0;
}
@@ -4292,26 +4295,15 @@ void ata_scsi_scan_host(struct ata_port *ap, int sync)
repeat:
ata_for_each_link(link, ap, EDGE) {
ata_for_each_dev(dev, link, ENABLED) {
- struct scsi_device *sdev;
+ struct Scsi_Host *shost = ap->scsi_host;
int channel = 0, id = 0;
- if (dev->sdev)
- continue;
-
if (ata_is_host_link(link))
id = dev->devno;
else
channel = link->pmp;
- sdev = __scsi_add_device(ap->scsi_host, channel, id, 0,
- NULL);
- if (!IS_ERR(sdev)) {
- dev->sdev = sdev;
- ata_scsi_assign_ofnode(dev, ap);
- scsi_device_put(sdev);
- } else {
- dev->sdev = NULL;
- }
+ scsi_scan_target(&shost->shost_gendev, channel, id, 0, SCSI_SCAN_INITIAL);
}
}
--
2.35.3
next prev parent reply other threads:[~2022-09-20 10:36 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-20 10:27 [PATCH RFC 0/6] libata/scsi/libsas: Allocate SCSI device earlier for ata " John Garry
2022-09-20 10:27 ` [PATCH 1/6] scsi: core: Use SCSI_SCAN_RESCAN in __scsi_add_device() John Garry
2022-09-20 22:03 ` Damien Le Moal
2022-09-20 10:27 ` [PATCH RFC 2/6] scsi: scsi_transport_sas: Allocate end device target id in the rphy alloc John Garry
2022-09-20 22:02 ` Damien Le Moal
2022-09-21 9:21 ` John Garry
2022-09-20 10:27 ` [PATCH RFC 3/6] scsi: core: Add scsi_get_dev() John Garry
2022-09-20 21:58 ` Damien Le Moal
2022-09-21 9:17 ` John Garry
2022-09-20 10:27 ` [PATCH RFC 4/6] ata: libata-scsi: Add ata_scsi_setup_sdev() John Garry
2022-09-20 10:27 ` [PATCH RFC 5/6] scsi: libsas: Add sas_ata_setup_device() John Garry
2022-09-20 10:27 ` John Garry [this message]
2022-09-21 4:04 ` [PATCH RFC 0/6] libata/scsi/libsas: Allocate SCSI device earlier for ata port probe Damien Le Moal
2022-09-21 8:24 ` John Garry
2022-09-21 8:31 ` Damien Le Moal
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1663669630-21333-7-git-send-email-john.garry@huawei.com \
--to=john.garry@huawei.com \
--cc=brking@us.ibm.com \
--cc=damien.lemoal@opensource.wdc.com \
--cc=hare@suse.de \
--cc=hch@lst.de \
--cc=jejb@linux.ibm.com \
--cc=linux-ide@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®