From patchwork Thu Dec 21 11:22:34 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hannes Reinecke X-Patchwork-Id: 10127495 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 B4C676019C 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 8179429BB1 for ; Thu, 21 Dec 2017 11:22:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 768E829BCF; Thu, 21 Dec 2017 11:22:48 +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 21A1C29BB1 for ; Thu, 21 Dec 2017 11:22:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752663AbdLULWp (ORCPT ); Thu, 21 Dec 2017 06:22:45 -0500 Received: from mx2.suse.de ([195.135.220.15]:60781 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752088AbdLULWi (ORCPT ); Thu, 21 Dec 2017 06:22:38 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 906CDACFB; 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 3/3] ses: Retry Power-on-reset check condition Date: Thu, 21 Dec 2017 12:22:34 +0100 Message-Id: <1513855354-86603-4-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 During startup any SCSI request might encounter a 'Power-on/reset' sense code, which just can be retried. In the case of ses it needs to be retried, otherwise ses will errorneously detect this as a failure and not attach the driver. Signed-off-by: Hannes Reinecke --- drivers/scsi/ses.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/drivers/scsi/ses.c b/drivers/scsi/ses.c index c1f96b0..9c8b3db 100644 --- a/drivers/scsi/ses.c +++ b/drivers/scsi/ses.c @@ -110,14 +110,20 @@ static int ses_recv_diag(struct scsi_device *sdev, int page_code, 0 }; unsigned char recv_page_code; + int retries = SES_RETRIES; struct scsi_sense_hdr sshdr; +retry: ret = scsi_execute_req(sdev, cmd, DMA_FROM_DEVICE, buf, bufflen, - &sshdr, SES_TIMEOUT, SES_RETRIES, NULL); + &sshdr, SES_TIMEOUT, retries, NULL); if (unlikely(ret)) { - if (status_byte(ret) == CHECK_CONDITION && - sshdr.asc == 0x25 && sshdr.ascq == 0x00) { - ret = -ENODEV; + if (status_byte(ret) == CHECK_CONDITION) { + if (sshdr.asc == 0x29) { + retries--; + goto retry; + } + if (sshdr.asc == 0x25 && sshdr.ascq == 0x00) + ret = -ENODEV; } return ret; }