diff mbox

scsi: libsas: add transport class for ATA devices

Message ID 20180326092741.22716-1-yanaijie@huawei.com (mailing list archive)
State Accepted
Headers show

Commit Message

Jason Yan March 26, 2018, 9:27 a.m. UTC
Now ata devices attached with sas controller do not have transport
class, so that we can not see any information of these ata devices in
/sys/class/ata_port(or ata_link or ata_device).

Add transport class for the ata devices attached with sas controller.
The /sys/class directory will show the infomation of the ata devices
as follows:

localhost:/sys/class # ls ata*
ata_device:
dev1.0  dev2.0

ata_link:
link1  link2

ata_port:
ata1  ata2

No functional change of the device scanning and io path. The ata
transport class was deleted when destroying the sas devices.

Signed-off-by: Jason Yan <yanaijie@huawei.com>
CC: Dan Williams <dan.j.williams@intel.com>
CC: Tejun Heo <tj@kernel.org>
---
 drivers/ata/libata-scsi.c          | 12 ++++++++++++
 drivers/scsi/libsas/sas_ata.c      |  5 +++++
 drivers/scsi/libsas/sas_discover.c |  1 +
 include/linux/libata.h             |  2 ++
 4 files changed, 20 insertions(+)

Comments

Tejun Heo March 26, 2018, 2:10 p.m. UTC | #1
On Mon, Mar 26, 2018 at 05:27:41PM +0800, Jason Yan wrote:
> Now ata devices attached with sas controller do not have transport
> class, so that we can not see any information of these ata devices in
> /sys/class/ata_port(or ata_link or ata_device).
> 
> Add transport class for the ata devices attached with sas controller.
> The /sys/class directory will show the infomation of the ata devices
> as follows:
> 
> localhost:/sys/class # ls ata*
> ata_device:
> dev1.0  dev2.0
> 
> ata_link:
> link1  link2
> 
> ata_port:
> ata1  ata2
> 
> No functional change of the device scanning and io path. The ata
> transport class was deleted when destroying the sas devices.
> 
> Signed-off-by: Jason Yan <yanaijie@huawei.com>
> CC: Dan Williams <dan.j.williams@intel.com>
> CC: Tejun Heo <tj@kernel.org>

Looks good to me on the ata side.

 Acked-by: Tejun Heo <tj@kernel.org>

Thanks.
Dan Williams March 26, 2018, 2:38 p.m. UTC | #2
On Mon, Mar 26, 2018 at 2:27 AM, Jason Yan <yanaijie@huawei.com> wrote:
> Now ata devices attached with sas controller do not have transport
> class, so that we can not see any information of these ata devices in
> /sys/class/ata_port(or ata_link or ata_device).
>
> Add transport class for the ata devices attached with sas controller.
> The /sys/class directory will show the infomation of the ata devices
> as follows:
>
> localhost:/sys/class # ls ata*
> ata_device:
> dev1.0  dev2.0
>
> ata_link:
> link1  link2
>
> ata_port:
> ata1  ata2
>
> No functional change of the device scanning and io path. The ata
> transport class was deleted when destroying the sas devices.

Have you tested this with suspend / resume power management? I believe
that is what stopped me from going down this path, when I first
evaluated it.
Jason Yan March 27, 2018, 12:53 a.m. UTC | #3
On 2018/3/26 22:38, Dan Williams wrote:
> On Mon, Mar 26, 2018 at 2:27 AM, Jason Yan <yanaijie@huawei.com> wrote:
>> Now ata devices attached with sas controller do not have transport
>> class, so that we can not see any information of these ata devices in
>> /sys/class/ata_port(or ata_link or ata_device).
>>
>> Add transport class for the ata devices attached with sas controller.
>> The /sys/class directory will show the infomation of the ata devices
>> as follows:
>>
>> localhost:/sys/class # ls ata*
>> ata_device:
>> dev1.0  dev2.0
>>
>> ata_link:
>> link1  link2
>>
>> ata_port:
>> ata1  ata2
>>
>> No functional change of the device scanning and io path. The ata
>> transport class was deleted when destroying the sas devices.
>
> Have you tested this with suspend / resume power management? I believe
> that is what stopped me from going down this path, when I first
> evaluated it.
>

Thanks a lot, I will test it with suspend/resume power management later.

>
Jason Yan March 28, 2018, 12:49 a.m. UTC | #4
Hi, Dan

On 2018/3/26 22:38, Dan Williams wrote:
> On Mon, Mar 26, 2018 at 2:27 AM, Jason Yan <yanaijie@huawei.com> wrote:
>> Now ata devices attached with sas controller do not have transport
>> class, so that we can not see any information of these ata devices in
>> /sys/class/ata_port(or ata_link or ata_device).
>>
>> Add transport class for the ata devices attached with sas controller.
>> The /sys/class directory will show the infomation of the ata devices
>> as follows:
>>
>> localhost:/sys/class # ls ata*
>> ata_device:
>> dev1.0  dev2.0
>>
>> ata_link:
>> link1  link2
>>
>> ata_port:
>> ata1  ata2
>>
>> No functional change of the device scanning and io path. The ata
>> transport class was deleted when destroying the sas devices.
>
> Have you tested this with suspend / resume power management? I believe
> that is what stopped me from going down this path, when I first
> evaluated it.
>

I tested this patch with suspend/resume power management and did not
see any regressions. I don't know if this test is enough. The log is
as below:

[ 1098.226768] hns-nic HISI00C2:01 eth1: link up
[ 1183.162762] PM: suspend entry (s2idle)
[ 1183.162766] PM: Syncing filesystems ... done.
[ 1183.163224] Freezing user space processes ... (elapsed 0.001 seconds) 
done.
[ 1183.164710] OOM killer disabled.
[ 1183.164711] Freezing remaining freezable tasks ... (elapsed 0.001 
seconds) done.
[ 1183.166415] Suspending console(s) (use no_console_suspend to debug)
[ 1183.166733] pci_bus 0004:88: 2-byte config write to 0004:88:00.0 
offset 0x44 may corrupt adjacent RW1C bits
[ 1183.166741] pci_bus 0005:00: 2-byte config write to 0005:00:00.0 
offset 0x44 may corrupt adjacent RW1C bits
[ 1183.166748] pci_bus 0006:c0: 2-byte config write to 0006:c0:00.0 
offset 0x44 may corrupt adjacent RW1C bits
[ 1183.166758] pci_bus 000a:10: 2-byte config write to 000a:10:00.0 
offset 0x44 may corrupt adjacent RW1C bits
[ 1183.166765] pci_bus 000c:20: 2-byte config write to 000c:20:00.0 
offset 0x44 may corrupt adjacent RW1C bits
[ 1183.166774] pci_bus 000d:30: 2-byte config write to 000d:30:00.0 
offset 0x44 may corrupt adjacent RW1C bits
[ 1183.242586] sd 0:0:11:0: [sdl] Synchronizing SCSI cache
[ 1183.258568] sd 0:0:10:0: [sdk] Synchronizing SCSI cache
[ 1183.258699] sd 0:0:10:0: [sdk] Stopping disk
[ 1183.922568] sd 0:0:9:0: [sdj] Synchronizing SCSI cache
[ 1183.922690] sd 0:0:9:0: [sdj] Stopping disk
[ 1184.610567] sd 0:0:8:0: [sdi] Synchronizing SCSI cache
[ 1184.626567] sd 0:0:7:0: [sdh] Synchronizing SCSI cache
[ 1184.642564] sd 0:0:6:0: [sdg] Synchronizing SCSI cache
[ 1184.658567] sd 0:0:5:0: [sdf] Synchronizing SCSI cache
[ 1184.674565] sd 0:0:4:0: [sde] Synchronizing SCSI cache
[ 1184.690567] sd 0:0:3:0: [sdd] Synchronizing SCSI cache
[ 1184.706564] sd 0:0:2:0: [sdc] Synchronizing SCSI cache
[ 1184.722566] sd 0:0:1:0: [sdb] Synchronizing SCSI cache
[ 1184.738563] sd 0:0:0:0: [sda] Synchronizing SCSI cache
[ 1184.738844] sas: Enter sas_scsi_recover_host busy: 0 failed: 0
[ 1184.738857] sas: ata1: end_device-0:0:9: dev error handler
[ 1184.738860] sas: ata2: end_device-0:0:10: dev error handler
[ 1184.738877] sas: --- Exit sas_scsi_recover_host: busy: 0 failed: 0 
tries: 1
[ 1184.739169] pci_bus 000d:30: 2-byte config write to 000d:30:00.0 
offset 0x44 may corrupt adjacent RW1C bits
[ 1184.739179] pci_bus 000c:20: 2-byte config write to 000c:20:00.0 
offset 0x44 may corrupt adjacent RW1C bits
[ 1184.739188] pci_bus 000a:10: 2-byte config write to 000a:10:00.0 
offset 0x44 may corrupt adjacent RW1C bits
[ 1184.739214] pci_bus 0006:c0: 2-byte config write to 0006:c0:00.0 
offset 0x44 may corrupt adjacent RW1C bits
[ 1184.739334] pcieport 0002:80:00.0: can't derive routing for PCI INT A
[ 1184.739336] ixgbe 0002:81:00.0: PCI INT A: no GSI
[ 1184.758563] PM: suspend debug: Waiting for 5 second(s).
[ 1189.809010] sas: Enter sas_scsi_recover_host busy: 0 failed: 0
[ 1189.811180] sas: ata1: end_device-0:0:9: dev error handler
[ 1189.811185] sas: ata1: end_device-0:0:9: Unable to reset ata device?
[ 1189.811223] sas: ata2: end_device-0:0:10: dev error handler
[ 1189.811226] sas: ata2: end_device-0:0:10: Unable to reset ata device?
[ 1189.811474] sd 0:0:9:0: [sdj] Starting disk
[ 1189.888654] ixgbe 0002:81:00.0: Multiqueue Enabled: Rx Queue count = 
63, Tx Queue count = 63 XDP Queue count = 0
[ 1189.974214] ata2.00: configured for UDMA/133
[ 1189.974285] ata1.00: configured for UDMA/133
[ 1189.974295] sas: --- Exit sas_scsi_recover_host: busy: 0 failed: 0 
tries: 1
[ 1197.991137] sd 0:0:10:0: [sdk] Starting disk
[ 1210.019736] pci_generic_config_write32: 2 callbacks suppressed
[ 1210.019740] pci_bus 000d:30: 2-byte config write to 000d:30:00.0 
offset 0x44 may corrupt adjacent RW1C bits
[ 1210.019748] pci_bus 000c:20: 2-byte config write to 000c:20:00.0 
offset 0x44 may corrupt adjacent RW1C bits
[ 1210.019755] pci_bus 000a:10: 2-byte config write to 000a:10:00.0 
offset 0x44 may corrupt adjacent RW1C bits
[ 1210.019764] pci_bus 0006:c0: 2-byte config write to 0006:c0:00.0 
offset 0x44 may corrupt adjacent RW1C bits
[ 1210.019770] pci_bus 0005:00: 2-byte config write to 0005:00:00.0 
offset 0x44 may corrupt adjacent RW1C bits
[ 1210.019775] pci_bus 0004:88: 2-byte config write to 0004:88:00.0 
offset 0x44 may corrupt adjacent RW1C bits
[ 1210.019888] OOM killer enabled.
[ 1210.019889] Restarting tasks ... done.
[ 1210.021064] PM: suspend exit


localhost:/sys/power # ls /sys/class/ata*
/sys/class/ata_device:
dev1.0  dev2.0

/sys/class/ata_link:
link1  link2

/sys/class/ata_port:
ata1  ata2
localhost:/sys/power #
localhost:/sys/power # lsscsi
[0:0:0:0]    disk    SEAGATE  ST3600057SS      0008  /dev/sda
[0:0:1:0]    disk    SEAGATE  ST3600057SS      0008  /dev/sdb
[0:0:2:0]    disk    SEAGATE  ST3600057SS      0008  /dev/sdc
[0:0:3:0]    disk    SEAGATE  ST3600057SS      0008  /dev/sdd
[0:0:4:0]    disk    SEAGATE  ST3600057SS      0008  /dev/sde
[0:0:5:0]    disk    SEAGATE  ST3600057SS      0008  /dev/sdf
[0:0:6:0]    disk    SEAGATE  ST3600057SS      0008  /dev/sdg
[0:0:7:0]    disk    SEAGATE  ST3600057SS      0008  /dev/sdh
[0:0:8:0]    disk    SEAGATE  ST3600057SS      0008  /dev/sdi
[0:0:9:0]    disk    ATA      HGST HUS724040AL A8B0  /dev/sdj
[0:0:10:0]   disk    ATA      HGST HUS724040AL A8B0  /dev/sdk
[0:0:11:0]   disk    SEAGATE  ST3600057SS      0008  /dev/sdl
[0:0:12:0]   enclosu 12G SAS  Expander         RevB  -


Jason

>
Martin K. Petersen April 10, 2018, 2:58 a.m. UTC | #5
Jason,

> Now ata devices attached with sas controller do not have transport
> class, so that we can not see any information of these ata devices in
> /sys/class/ata_port(or ata_link or ata_device).
>
> Add transport class for the ata devices attached with sas controller.
> The /sys/class directory will show the infomation of the ata devices
> as follows:

Applied to 4.18/scsi-queue. Thank you!
diff mbox

Patch

diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
index 89a9d4a2efc8..1c9f80fbc51c 100644
--- a/drivers/ata/libata-scsi.c
+++ b/drivers/ata/libata-scsi.c
@@ -5051,6 +5051,18 @@  int ata_sas_port_init(struct ata_port *ap)
 }
 EXPORT_SYMBOL_GPL(ata_sas_port_init);
 
+int ata_sas_tport_add(struct device *parent, struct ata_port *ap)
+{
+	return ata_tport_add(parent, ap);
+}
+EXPORT_SYMBOL_GPL(ata_sas_tport_add);
+
+void ata_sas_tport_delete(struct ata_port *ap)
+{
+	ata_tport_delete(ap);
+}
+EXPORT_SYMBOL_GPL(ata_sas_tport_delete);
+
 /**
  *	ata_sas_port_destroy - Destroy a SATA port allocated by ata_sas_port_alloc
  *	@ap: SATA port to destroy
diff --git a/drivers/scsi/libsas/sas_ata.c b/drivers/scsi/libsas/sas_ata.c
index 2b3637b40dde..2457f12c7953 100644
--- a/drivers/scsi/libsas/sas_ata.c
+++ b/drivers/scsi/libsas/sas_ata.c
@@ -577,6 +577,11 @@  int sas_ata_init(struct domain_device *found_dev)
 		ata_sas_port_destroy(ap);
 		return rc;
 	}
+	rc = ata_sas_tport_add(found_dev->sata_dev.ata_host.dev, ap);
+	if (rc) {
+		ata_sas_port_destroy(ap);
+		return rc;
+	}
 	found_dev->sata_dev.ap = ap;
 
 	return 0;
diff --git a/drivers/scsi/libsas/sas_discover.c b/drivers/scsi/libsas/sas_discover.c
index e4fd078e4175..1ed47ccfc280 100644
--- a/drivers/scsi/libsas/sas_discover.c
+++ b/drivers/scsi/libsas/sas_discover.c
@@ -314,6 +314,7 @@  void sas_free_device(struct kref *kref)
 		kfree(dev->ex_dev.ex_phy);
 
 	if (dev_is_sata(dev) && dev->sata_dev.ap) {
+		ata_sas_tport_delete(dev->sata_dev.ap);
 		ata_sas_port_destroy(dev->sata_dev.ap);
 		dev->sata_dev.ap = NULL;
 	}
diff --git a/include/linux/libata.h b/include/linux/libata.h
index ed9826b21c5e..86858d0a372c 100644
--- a/include/linux/libata.h
+++ b/include/linux/libata.h
@@ -1129,6 +1129,8 @@  extern void ata_sas_async_probe(struct ata_port *ap);
 extern int ata_sas_sync_probe(struct ata_port *ap);
 extern int ata_sas_port_init(struct ata_port *);
 extern int ata_sas_port_start(struct ata_port *ap);
+extern int ata_sas_tport_add(struct device *parent, struct ata_port *ap);
+extern void ata_sas_tport_delete(struct ata_port *ap);
 extern void ata_sas_port_stop(struct ata_port *ap);
 extern int ata_sas_slave_configure(struct scsi_device *, struct ata_port *);
 extern int ata_sas_queuecmd(struct scsi_cmnd *cmd, struct ata_port *ap);