Received: by 10.192.165.156 with SMTP id m28csp1072282imm; Wed, 11 Apr 2018 11:55:07 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/JG/VTGIdpTduTRrjseUmm4qyqAG6iZTAccm9i/EdAaVDFLdm1WaEwChCLdShXH9N1wFzU X-Received: by 2002:a17:902:d20b:: with SMTP id t11-v6mr6236282ply.381.1523472907611; Wed, 11 Apr 2018 11:55:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523472907; cv=none; d=google.com; s=arc-20160816; b=eSzp7/KjQwwfpF6mtz0PzZ2g2AF/v+yMAE0Iuz/7tc/eTolqATTM4Nj/uU1G/FaMOp WK40B1F5HOajUmXR6H3NfFQsbNThrFOBl919rT6VMzblTHdy1VRjV22T1bogTRRRyFgX KKdulu0/VYY3XH27tEINsiMhXMiSgrfNAv9FBFaffQ4MDL1Ff35Ngqz7kPuNHDYBeRRo mjsgQpwzWvOxs4xJ087mKrmE/U9pnxQJTtebeq/vLv5mqAWfMXuaU4Td8JjlEDu5usZD UoOqMeduL64+LMzTPc0ZbknFtD8xw4pbBBVOiibOtPfSw5kYDgmhYWTIOyBLJa1pA6Zj dFLQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=699n0GVG9iWYZWo8UWfGwa0/MRx9/NyFpczcdzdySDI=; b=YSE13JVWBIo5IOy+lhp7qAlw1VTlKKfTzvB4PXSTTbEF0/aeonuliSxynUYSvk294g Y0UZOjjX8sAbTYWOE13//y+jRHgLK6WkekeAoVXkWMMipiTI1yx1Erjq3CK1llaf0wWc encRu7cXfOnjlIV6G1D5QkmTb8EtnKsns0WCyd+1tzu/HHbKX+vszw+er0VfJVB14Zdu 8lWVLN6c3Dk+rxDExSmaAU0sDzA0yhG8fGqGGWQuUT9inlKEWgYDgsZEqhXYTThupO5z TwwGLKHw/w27hlmk7o2fgAj1qE5U31f7GGtPVeLRWN40dOx1+VguXBgNsiwEZc8Rafzc iSMQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q10-v6si158911pli.419.2018.04.11.11.54.30; Wed, 11 Apr 2018 11:55:07 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755936AbeDKSrc (ORCPT + 99 others); Wed, 11 Apr 2018 14:47:32 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:59332 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755922AbeDKSr3 (ORCPT ); Wed, 11 Apr 2018 14:47:29 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 7B0A4E08; Wed, 11 Apr 2018 18:47:28 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Chaitra P B , Suganath Prabu S , "Martin K. Petersen" , Sasha Levin Subject: [PATCH 4.4 090/190] scsi: mpt3sas: Proper handling of set/clear of "ATA command pending" flag. Date: Wed, 11 Apr 2018 20:35:36 +0200 Message-Id: <20180411183555.884616955@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180411183550.114495991@linuxfoundation.org> References: <20180411183550.114495991@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: Chaitra P B [ Upstream commit f49d4aed1315a7b766d855f1367142e682b0cc87 ] 1. In IO path, setting of "ATA command pending" flag early before device removal, invalid device handle etc., checks causes any new commands to be always returned with SAM_STAT_BUSY and when the driver removes the drive the SML issues SYNC Cache command and that command is always returned with SAM_STAT_BUSY and thus making SYNC Cache command to requeued. 2. If the driver gets an ATA PT command for a SATA drive then the driver set "ATA command pending" flag in device specific data structure not to allow any further commands until the ATA PT command is completed. However, after setting the flag if the driver decides to return the command back to upper layers without actually issuing to the firmware (i.e., returns from qcmd failure return paths) then the corresponding flag is not cleared and this prevents the driver from sending any new commands to the drive. This patch fixes above two issues by setting of "ATA command pending" flag after checking for whether device deleted, invalid device handle, device busy with task management. And by setting "ATA command pending" flag to false in all of the qcmd failure return paths after setting the flag. Signed-off-by: Chaitra P B Signed-off-by: Suganath Prabu S Signed-off-by: Martin K. Petersen Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/scsi/mpt3sas/mpt3sas_scsih.c | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) --- a/drivers/scsi/mpt3sas/mpt3sas_scsih.c +++ b/drivers/scsi/mpt3sas/mpt3sas_scsih.c @@ -3886,19 +3886,6 @@ scsih_qcmd(struct Scsi_Host *shost, stru return 0; } - /* - * Bug work around for firmware SATL handling. The loop - * is based on atomic operations and ensures consistency - * since we're lockless at this point - */ - do { - if (test_bit(0, &sas_device_priv_data->ata_command_pending)) { - scmd->result = SAM_STAT_BUSY; - scmd->scsi_done(scmd); - return 0; - } - } while (_scsih_set_satl_pending(scmd, true)); - sas_target_priv_data = sas_device_priv_data->sas_target; /* invalid device handle */ @@ -3924,6 +3911,19 @@ scsih_qcmd(struct Scsi_Host *shost, stru sas_device_priv_data->block) return SCSI_MLQUEUE_DEVICE_BUSY; + /* + * Bug work around for firmware SATL handling. The loop + * is based on atomic operations and ensures consistency + * since we're lockless at this point + */ + do { + if (test_bit(0, &sas_device_priv_data->ata_command_pending)) { + scmd->result = SAM_STAT_BUSY; + scmd->scsi_done(scmd); + return 0; + } + } while (_scsih_set_satl_pending(scmd, true)); + if (scmd->sc_data_direction == DMA_FROM_DEVICE) mpi_control = MPI2_SCSIIO_CONTROL_READ; else if (scmd->sc_data_direction == DMA_TO_DEVICE) @@ -3945,6 +3945,7 @@ scsih_qcmd(struct Scsi_Host *shost, stru if (!smid) { pr_err(MPT3SAS_FMT "%s: failed obtaining a smid\n", ioc->name, __func__); + _scsih_set_satl_pending(scmd, false); goto out; } mpi_request = mpt3sas_base_get_msg_frame(ioc, smid); @@ -3975,6 +3976,7 @@ scsih_qcmd(struct Scsi_Host *shost, stru if (mpi_request->DataLength) { if (ioc->build_sg_scmd(ioc, scmd, smid)) { mpt3sas_base_free_smid(ioc, smid); + _scsih_set_satl_pending(scmd, false); goto out; } } else