From patchwork Thu Dec 21 11:22:33 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hannes Reinecke X-Patchwork-Id: 10127493 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 1FC486019C for ; Thu, 21 Dec 2017 11:22:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E045D29BB1 for ; Thu, 21 Dec 2017 11:22:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D558529BCF; Thu, 21 Dec 2017 11:22:47 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3D8A129BB1 for ; Thu, 21 Dec 2017 11:22:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752683AbdLULWq (ORCPT ); Thu, 21 Dec 2017 06:22:46 -0500 Received: from mx2.suse.de ([195.135.220.15]:60778 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752066AbdLULWh (ORCPT ); Thu, 21 Dec 2017 06:22:37 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 90429ACA6; Thu, 21 Dec 2017 11:22:36 +0000 (UTC) From: Hannes Reinecke To: "Martin K. Petersen" Cc: Christoph Hellwig , James Bottomley , linux-scsi@vger.kernel.org, Hannes Reinecke , Hannes Reinecke Subject: [PATCH 2/3] ses: skip error messages for invalid LUNs Date: Thu, 21 Dec 2017 12:22:33 +0100 Message-Id: <1513855354-86603-3-git-send-email-hare@suse.de> X-Mailer: git-send-email 1.8.5.6 In-Reply-To: <1513855354-86603-1-git-send-email-hare@suse.de> References: <1513855354-86603-1-git-send-email-hare@suse.de> Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- 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)