[PATCH 2/3] ses: skip error messages for invalid LUNs

Hannes Reinecke
2017-12-21T11:22:37Z

Some storage array set the 'Embedded enclosure' bit even though
no LUN is present, causing the first RECEIVE DIAGNOSTIC call to
be returned with sense code 'LOGICAL UNIT NOT SUPPORTED'.
This patch skips the annoying 'Failed to get diagnostic page 0x1'
messages for those cases.

Signed-off-by: Hannes Reinecke <hare@suse.com>
---
drivers/scsi/ses.c | 20 +++++++++++++++-----
1 file changed, 15 insertions(+), 5 deletions(-)

diff --git a/drivers/scsi/ses.c b/drivers/scsi/ses.c
index e8ffee1..c1f96b0 100644
--- a/drivers/scsi/ses.c
+++ b/drivers/scsi/ses.c
@@ -110,12 +110,17 @@ static int ses_recv_diag(struct scsi_device *sdev, int page_code,
0
};
unsigned char recv_page_code;
+ struct scsi_sense_hdr sshdr;

ret = scsi_execute_req(sdev, cmd, DMA_FROM_DEVICE, buf, bufflen,
- NULL, SES_TIMEOUT, SES_RETRIES, NULL);
- if (unlikely(ret))
+ &sshdr, SES_TIMEOUT, SES_RETRIES, NULL);
+ if (unlikely(ret)) {
+ if (status_byte(ret) == CHECK_CONDITION &&
+ sshdr.asc == 0x25 && sshdr.ascq == 0x00) {
+ ret = -ENODEV;
+ }
return ret;
-
+ }
recv_page_code = ((unsigned char *)buf)[0];

if (likely(recv_page_code == page_code))
@@ -674,9 +679,14 @@ static int ses_intf_add(struct device *cdev,

page = 1;
result = ses_recv_diag(sdev, page, hdr_buf, ses_alloc_size);
- if (result)
+ if (result) {
+ if (result == -ENODEV &&
+ sdev->inq_periph_qual != 0) {
+ kfree(hdr_buf);
+ return result;
+ }
goto recv_failed;
-
+ }
len = (hdr_buf[2] << 8) + hdr_buf[3] + 4;
buf = kzalloc(len, GFP_KERNEL);
if (!buf)
--
1.8.5.6