From patchwork Fri Aug 26 11:09:01 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brian King X-Patchwork-Id: 9301119 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 7C7B9607F0 for ; Fri, 26 Aug 2016 11:09:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6D0ED295F9 for ; Fri, 26 Aug 2016 11:09:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5F96D29604; Fri, 26 Aug 2016 11:09:27 +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, SUBJ_ATTENTION 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 4C256295F9 for ; Fri, 26 Aug 2016 11:09:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752985AbcHZLJY (ORCPT ); Fri, 26 Aug 2016 07:09:24 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:45691 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752872AbcHZLJW (ORCPT ); Fri, 26 Aug 2016 07:09:22 -0400 Received: from pps.filterd (m0098404.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.11/8.16.0.11) with SMTP id u7QB8jRn079388 for ; Fri, 26 Aug 2016 07:09:07 -0400 Received: from e37.co.us.ibm.com (e37.co.us.ibm.com [32.97.110.158]) by mx0a-001b2d01.pphosted.com with ESMTP id 25231t25gh-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Fri, 26 Aug 2016 07:09:07 -0400 Received: from localhost by e37.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 26 Aug 2016 05:09:06 -0600 Received: from d03dlp02.boulder.ibm.com (9.17.202.178) by e37.co.us.ibm.com (192.168.1.137) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Fri, 26 Aug 2016 05:09:03 -0600 X-IBM-Helo: d03dlp02.boulder.ibm.com X-IBM-MailFrom: brking@linux.vnet.ibm.com Received: from b03cxnp08026.gho.boulder.ibm.com (b03cxnp08026.gho.boulder.ibm.com [9.17.130.18]) by d03dlp02.boulder.ibm.com (Postfix) with ESMTP id 1894E3E4004C; Fri, 26 Aug 2016 05:09:03 -0600 (MDT) Received: from b03ledav001.gho.boulder.ibm.com (b03ledav001.gho.boulder.ibm.com [9.17.130.232]) by b03cxnp08026.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id u7QB8tv315073778; Fri, 26 Aug 2016 04:09:02 -0700 Received: from b03ledav001.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D41FE7E004; Fri, 26 Aug 2016 05:09:02 -0600 (MDT) Received: from localhost.localdomain (unknown [9.48.116.33]) by b03ledav001.gho.boulder.ibm.com (Postfix) with ESMTP id 6BF696E038; Fri, 26 Aug 2016 05:09:02 -0600 (MDT) Subject: [PATCH 1/1] ses: Retry UNIT ATTENTION for receive diagnostics To: James.Bottomley@HansenPartnership.com Cc: martin.petersen@oracle.com, linux-scsi@vger.kernel.org, brking@linux.vnet.ibm.com, stable@vger.kernel.org, wenxiong@linux.vnet.ibm.com From: Brian King Date: Fri, 26 Aug 2016 06:09:01 -0500 X-TM-AS-GCONF: 00 X-Content-Scanned: Fidelis XPS MAILER x-cbid: 16082611-0024-0000-0000-0000146AAF0A X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00005643; HX=3.00000240; KW=3.00000007; PH=3.00000004; SC=3.00000183; SDB=6.00749947; UDB=6.00354134; IPR=6.00522583; BA=6.00004676; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00012473; XFM=3.00000011; UTC=2016-08-26 11:09:05 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 16082611-0025-0000-0000-000043E86929 Message-Id: <20160826110902.6BF696E038@b03ledav001.gho.boulder.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2016-08-26_07:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=3 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1604210000 definitions=main-1608260132 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 If the ses driver receives a UNIT ATTENTION when issuing a receive diagnostics while probing a SES device, it fails to attach with messages such as: scsi 1:0:7:0: Failed to get diagnostic page 0x8000002 scsi 1:0:7:0: Failed to bind enclosure -19 Fix this by eating unit attentions for these commands. Cc: Suggested-by: Wen Xiong Signed-off-by: Brian King --- drivers/scsi/ses.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff -puN drivers/scsi/ses.c~ses_rcv_diag_retry drivers/scsi/ses.c --- linux-2.6.git/drivers/scsi/ses.c~ses_rcv_diag_retry 2016-08-25 18:28:18.720565322 -0500 +++ linux-2.6.git-bjking1/drivers/scsi/ses.c 2016-08-25 18:28:29.687496342 -0500 @@ -86,7 +86,7 @@ static void init_device_slot_control(uns static int ses_recv_diag(struct scsi_device *sdev, int page_code, void *buf, int bufflen) { - int ret; + int ret, retries = SES_RETRIES; unsigned char cmd[] = { RECEIVE_DIAGNOSTIC, 1, /* Set PCV bit */ @@ -96,11 +96,14 @@ static int ses_recv_diag(struct scsi_dev 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)) - return ret; + do { + memset(&sshdr, 0, sizeof(sshdr)); + ret = scsi_execute_req(sdev, cmd, DMA_FROM_DEVICE, buf, bufflen, + &sshdr, SES_TIMEOUT, retries, NULL); + } while (scsi_sense_valid(&sshdr) && + sshdr.sense_key == UNIT_ATTENTION && --retries); recv_page_code = ((unsigned char *)buf)[0];