<feed xmlns='http://www.w3.org/2005/Atom'>
<title>kernel.git/drivers/scsi/ses.c, branch linux-4.16.y</title>
<subtitle>Hosts the 0x221E linux distro kernel.
</subtitle>
<id>https://git.0xinfinity.dev/distro/kernel.git/atom?h=linux-4.16.y</id>
<link rel='self' href='https://git.0xinfinity.dev/distro/kernel.git/atom?h=linux-4.16.y'/>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/'/>
<updated>2017-12-05T03:55:59Z</updated>
<entry>
<title>scsi: ses: don't ask for diagnostic pages repeatedly during probe</title>
<updated>2017-12-05T03:55:59Z</updated>
<author>
<name>Li Dongyang</name>
</author>
<published>2017-11-13T23:48:04Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=9c0a50022b8ac7e863e6ec8342fa476fe5d1d75c'/>
<id>urn:sha1:9c0a50022b8ac7e863e6ec8342fa476fe5d1d75c</id>
<content type='text'>
We are testing if there is a match with the ses device in a loop by
calling ses_match_to_enclosure(), which will issue scsi receive
diagnostics commands to the ses device for every device on the same
host.  On one of our boxes with 840 disks, it takes a long time to load
the driver:

[root@g1b-oss06 ~]# time modprobe ses

real	40m48.247s
user	0m0.001s
sys	0m0.196s

With the patch:

[root@g1b-oss06 ~]# time modprobe ses

real	0m17.915s
user	0m0.008s
sys	0m0.053s

Note that we still need to refresh page 10 when we see a new disk to
create the link.

Signed-off-by: Li Dongyang &lt;dongyang.li@anu.edu.au&gt;
Tested-by: Jason Ozolins &lt;jason.ozolins@hpe.com&gt;
Signed-off-by: Martin K. Petersen &lt;martin.petersen@oracle.com&gt;
</content>
</entry>
<entry>
<title>Merge branch 'fixes' into misc</title>
<updated>2017-09-07T19:12:43Z</updated>
<author>
<name>James Bottomley</name>
</author>
<published>2017-09-07T19:12:43Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=2441500a41a9b17ff657626eb81972f62bc8cc5a'/>
<id>urn:sha1:2441500a41a9b17ff657626eb81972f62bc8cc5a</id>
<content type='text'>
</content>
</entry>
<entry>
<title>scsi: ses: Fix racy cleanup of /sys in remove_dev()</title>
<updated>2017-08-25T21:35:40Z</updated>
<author>
<name>Calvin Owens</name>
</author>
<published>2017-08-24T13:13:52Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=a5a039b01729e729ee4cf1e11200f002af787f6e'/>
<id>urn:sha1:a5a039b01729e729ee4cf1e11200f002af787f6e</id>
<content type='text'>
Currently we free the resources backing the enclosure device before we
call device_unregister(). This is racy: during rmmod of low-level SCSI
drivers that hook into enclosure, we end up with a small window of time
during which writing to /sys can OOPS. Example trace with mpt3sas:

  general protection fault: 0000 [#1] SMP KASAN
  Modules linked in: mpt3sas(-) &lt;...&gt;
  RIP: [&lt;ffffffffa0388a98&gt;] ses_get_page2_descriptor.isra.6+0x38/0x220 [ses]
  Call Trace:
   [&lt;ffffffffa0389d14&gt;] ses_set_fault+0xf4/0x400 [ses]
   [&lt;ffffffffa0361069&gt;] set_component_fault+0xa9/0xf0 [enclosure]
   [&lt;ffffffff8205bffc&gt;] dev_attr_store+0x3c/0x70
   [&lt;ffffffff81677df5&gt;] sysfs_kf_write+0x115/0x180
   [&lt;ffffffff81675725&gt;] kernfs_fop_write+0x275/0x3a0
   [&lt;ffffffff8151f810&gt;] __vfs_write+0xe0/0x3e0
   [&lt;ffffffff8152281f&gt;] vfs_write+0x13f/0x4a0
   [&lt;ffffffff81526731&gt;] SyS_write+0x111/0x230
   [&lt;ffffffff828b401b&gt;] entry_SYSCALL_64_fastpath+0x13/0x94

Fortunately the solution is extremely simple: call device_unregister()
before we free the resources, and the race no longer exists. The driver
core holds a reference over -&gt;remove_dev(), so AFAICT this is safe.

Signed-off-by: Calvin Owens &lt;calvinowens@fb.com&gt;
Acked-by: Hannes Reinecke &lt;hare@suse.com&gt;
Signed-off-by: Martin K. Petersen &lt;martin.petersen@oracle.com&gt;
</content>
</entry>
<entry>
<title>scsi: ses: make page2 support optional</title>
<updated>2017-08-25T02:28:59Z</updated>
<author>
<name>Hannes Reinecke</name>
</author>
<published>2017-08-15T08:21:43Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=dc56ce12d50c0adc1243bd3d080133bc6b63f403'/>
<id>urn:sha1:dc56ce12d50c0adc1243bd3d080133bc6b63f403</id>
<content type='text'>
Simple subenclosures do not need to support SES page 2, so make it
optional.

Signed-off-by: Hannes Reinecke &lt;hare@suse.com&gt;
Signed-off-by: Martin K. Petersen &lt;martin.petersen@oracle.com&gt;
</content>
</entry>
<entry>
<title>scsi: ses: Fixup error message 'failed to get diagnostic page 0xffffffea'</title>
<updated>2017-08-25T02:28:58Z</updated>
<author>
<name>Hannes Reinecke</name>
</author>
<published>2017-08-15T08:21:42Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=81b59d7565b8703dfdf738e81e6dc0a417818000'/>
<id>urn:sha1:81b59d7565b8703dfdf738e81e6dc0a417818000</id>
<content type='text'>
The printk was using the result as argument, leading to a slightly
confusing log message.

Signed-off-by: Hannes Reinecke &lt;hare@suse.com&gt;
Signed-off-by: Martin K. Petersen &lt;martin.petersen@oracle.com&gt;
</content>
</entry>
<entry>
<title>scsi: ses: check return code from ses_recv_diag()</title>
<updated>2017-08-25T02:28:58Z</updated>
<author>
<name>Hannes Reinecke</name>
</author>
<published>2017-08-15T08:21:41Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=acf8ab9a85bfd6ead185a59c4cfe26b25d5a082f'/>
<id>urn:sha1:acf8ab9a85bfd6ead185a59c4cfe26b25d5a082f</id>
<content type='text'>
We should be checking the return code from ses_recv_diag() to avoid
accessing invalid data.

Signed-off-by: Hannes Reinecke &lt;hare@suse.com&gt;
Signed-off-by: Martin K. Petersen &lt;martin.petersen@oracle.com&gt;
</content>
</entry>
<entry>
<title>scsi: ses: Fix wrong page error</title>
<updated>2017-08-08T15:49:52Z</updated>
<author>
<name>Brian King</name>
</author>
<published>2017-08-01T18:45:36Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=424f727b94132a4193af401dd823c44612d1d59f'/>
<id>urn:sha1:424f727b94132a4193af401dd823c44612d1d59f</id>
<content type='text'>
If a SES device returns an error on a requested diagnostic page, we are
currently printing an error indicating the wrong page was received. Fix
this up to simply return a failure and only check the returned page when
the diagnostic page buffer was populated by the device.

Signed-off-by: Brian King &lt;brking@linux.vnet.ibm.com&gt;
Signed-off-by: Martin K. Petersen &lt;martin.petersen@oracle.com&gt;
</content>
</entry>
<entry>
<title>scsi: ses: don't get power status of SES device slot on probe</title>
<updated>2017-04-06T16:48:05Z</updated>
<author>
<name>Mauricio Faria de Oliveira</name>
</author>
<published>2017-04-05T15:18:19Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=75106523f39751390b5789b36ee1d213b3af1945'/>
<id>urn:sha1:75106523f39751390b5789b36ee1d213b3af1945</id>
<content type='text'>
The commit 08024885a2a3 ("ses: Add power_status to SES device slot")
introduced the 'power_status' attribute to enclosure components and
the associated callbacks.

There are 2 callbacks available to get the power status of a device:
1) ses_get_power_status() for 'struct enclosure_component_callbacks'
2) get_component_power_status() for the sysfs device attribute
(these are available for kernel-space and user-space, respectively.)

However, despite both methods being available to get power status
on demand, that commit also introduced a call to get power status
in ses_enclosure_data_process().

This dramatically increased the total probe time for SCSI devices
on larger configurations, because ses_enclosure_data_process() is
called several times during the SCSI devices probe and loops over
the component devices (but that is another problem, another patch).

That results in a tremendous continuous hammering of SCSI Receive
Diagnostics commands to the enclosure-services device, which does
delay the total probe time for the SCSI devices __significantly__:

  Originally, ~34 minutes on a system attached to ~170 disks:

    [ 9214.490703] mpt3sas version 13.100.00.00 loaded
    ...
    [11256.580231] scsi 17:0:177:0: qdepth(16), tagged(1), simple(0),
                   ordered(0), scsi_level(6), cmd_que(1)

  With this patch, it decreased to ~2.5 minutes -- a 13.6x faster

    [ 1002.992533] mpt3sas version 13.100.00.00 loaded
    ...
    [ 1151.978831] scsi 11:0:177:0: qdepth(16), tagged(1), simple(0),
                   ordered(0), scsi_level(6), cmd_que(1)

Back to the commit discussion.. on the ses_get_power_status() call
introduced in ses_enclosure_data_process(): impact of removing it.

That may possibly be in place to initialize the power status value
on device probe.  However, those 2 functions available to retrieve
that value _do_ automatically refresh/update it.  So the potential
benefit would be a direct access of the 'power_status' field which
does not use the callbacks...

But the only reader of 'struct enclosure_component::power_status'
is the get_component_power_status() callback for sysfs attribute,
and it _does_ check for and call the .get_power_status callback,
(which indeed is defined and implemented by that commit), so the
power status value is, again, automatically updated.

So, the remaining potential for a direct/non-callback access to
the power_status attribute would be out-of-tree modules -- well,
for those, if they are for whatever reason interested in values
that are set during device probe and not up-to-date by the time
they need it.. well, that would be curious.

Well, to handle that more properly, set the initial power state
value to '-1' (i.e., uninitialized) instead of '1' (power 'on'),
and check for it in that callback which may do an direct access
to the field value _if_ a callback function is not defined.

Signed-off-by: Mauricio Faria de Oliveira &lt;mauricfo@linux.vnet.ibm.com&gt;
Fixes: 08024885a2a3 ("ses: Add power_status to SES device slot")
Reviewed-by: Dan Williams &lt;dan.j.williams@intel.com&gt;
Reviewed-by: Song Liu &lt;songliubraving@fb.com&gt;
Signed-off-by: Martin K. Petersen &lt;martin.petersen@oracle.com&gt;
</content>
</entry>
<entry>
<title>scsi: ses: Fix SAS device detection in enclosure</title>
<updated>2017-01-17T18:58:57Z</updated>
<author>
<name>Ewan D. Milne</name>
</author>
<published>2017-01-09T21:33:36Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=9373eba6cfae48911b977d14323032cd5d161aae'/>
<id>urn:sha1:9373eba6cfae48911b977d14323032cd5d161aae</id>
<content type='text'>
The call to scsi_is_sas_rphy() needs to be made on the SAS end_device,
not on the SCSI device.

Fixes: 835831c57e9b ("ses: use scsi_is_sas_rphy instead of is_sas_attached")
Signed-off-by: Ewan D. Milne &lt;emilne@redhat.com&gt;
Reviewed-by: Johannes Thumshirn &lt;jthumshirn@suse.de&gt;
Reviewed-by: James Bottomley &lt;James.Bottomley@HansenPartnership.com&gt;
Signed-off-by: Martin K. Petersen &lt;martin.petersen@oracle.com&gt;
</content>
</entry>
<entry>
<title>scsi: ses: use scsi_is_sas_rphy instead of is_sas_attached</title>
<updated>2016-08-19T02:22:19Z</updated>
<author>
<name>Johannes Thumshirn</name>
</author>
<published>2016-08-17T09:46:17Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=835831c57e9b0cccc24e96a812542875471d75b5'/>
<id>urn:sha1:835831c57e9b0cccc24e96a812542875471d75b5</id>
<content type='text'>
Use scsi_is_sas_rphy() instead of is_sas_attached() to decide whether we
should obtain the SAS address from a scsi device or not. This will
prevent us from tripping on the BUG_ON() in sas_sdev_to_rdev() if the
rphy isn't attached to the SAS transport class, like it is with hpsa's
logical devices.

Fixes: 3f8d6f2a0 ('ses: fix discovery of SATA devices in SAS enclosures')
Signed-off-by: Johannes Thumshirn &lt;jthumshirn@suse.de&gt;
Reviewed-by: James E.J. Bottomley &lt;jejb@linux.vnet.ibm.com&gt;
Signed-off-by: Martin K. Petersen &lt;martin.petersen@oracle.com&gt;
</content>
</entry>
</feed>
