From patchwork Fri Sep 16 21:06:06 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brian King X-Patchwork-Id: 9336763 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 E00176077F for ; Fri, 16 Sep 2016 21:06:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D010F2A08A for ; Fri, 16 Sep 2016 21:06:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C44182A0B7; Fri, 16 Sep 2016 21:06:15 +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 6D2772A08A for ; Fri, 16 Sep 2016 21:06:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753600AbcIPVGO (ORCPT ); Fri, 16 Sep 2016 17:06:14 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:38739 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752986AbcIPVGM (ORCPT ); Fri, 16 Sep 2016 17:06:12 -0400 Received: from pps.filterd (m0098399.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.17/8.16.0.17) with SMTP id u8GL2acq057356 for ; Fri, 16 Sep 2016 17:06:12 -0400 Received: from e36.co.us.ibm.com (e36.co.us.ibm.com [32.97.110.154]) by mx0a-001b2d01.pphosted.com with ESMTP id 25fu1g9nsu-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Fri, 16 Sep 2016 17:06:11 -0400 Received: from localhost by e36.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 16 Sep 2016 15:06:11 -0600 Received: from d03dlp01.boulder.ibm.com (9.17.202.177) by e36.co.us.ibm.com (192.168.1.136) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Fri, 16 Sep 2016 15:06:08 -0600 Received: from b01cxnp22033.gho.pok.ibm.com (b01cxnp22033.gho.pok.ibm.com [9.57.198.23]) by d03dlp01.boulder.ibm.com (Postfix) with ESMTP id 433BA1FF0046; Fri, 16 Sep 2016 15:05:49 -0600 (MDT) Received: from b01ledav002.gho.pok.ibm.com (b01ledav002.gho.pok.ibm.com [9.57.199.107]) by b01cxnp22033.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id u8GL67SX8913302; Fri, 16 Sep 2016 21:06:07 GMT Received: from b01ledav002.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 6225A124037; Fri, 16 Sep 2016 17:06:07 -0400 (EDT) Received: from localhost.localdomain (unknown [9.10.86.21]) by b01ledav002.gho.pok.ibm.com (Postfix) with ESMTP id 054BF124047; Fri, 16 Sep 2016 17:06:06 -0400 (EDT) Subject: [RESEND] [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, krisman@linux.vnet.ibm.com, wenxiong@linux.vnet.ibm.com, brking@linux.vnet.ibm.com, stable@vger.kernel.org From: Brian King Date: Fri, 16 Sep 2016 16:06:06 -0500 X-TM-AS-GCONF: 00 X-Content-Scanned: Fidelis XPS MAILER x-cbid: 16091621-0020-0000-0000-000009D1CF87 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00005773; HX=3.00000240; KW=3.00000007; PH=3.00000004; SC=3.00000185; SDB=6.00758430; UDB=6.00360000; IPR=6.00532166; BA=6.00004731; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00012696; XFM=3.00000011; UTC=2016-09-16 21:06:10 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 16091621-0021-0000-0000-000055AD7022 Message-Id: <20160916210607.054BF124047@b01ledav002.gho.pok.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2016-09-16_11:, , 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-1609020000 definitions=main-1609160267 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 Reviewed-by: Gabriel Krisman Bertazi --- 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];