From patchwork Thu Dec 28 07:09:11 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chaitra P B X-Patchwork-Id: 10134439 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 7BF7760318 for ; Thu, 28 Dec 2017 07:09:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 71C8C2D43E for ; Thu, 28 Dec 2017 07:09:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 64ECF2D44D; Thu, 28 Dec 2017 07:09:46 +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=-7.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, 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 A99312D43E for ; Thu, 28 Dec 2017 07:09:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751103AbdL1HJp (ORCPT ); Thu, 28 Dec 2017 02:09:45 -0500 Received: from mail-qk0-f195.google.com ([209.85.220.195]:41229 "EHLO mail-qk0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750981AbdL1HJo (ORCPT ); Thu, 28 Dec 2017 02:09:44 -0500 Received: by mail-qk0-f195.google.com with SMTP id a8so11402029qkb.8 for ; Wed, 27 Dec 2017 23:09:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=from:to:cc:subject:date:message-id; bh=fEfB/jgB/4UJst2FyWFerS3u+gTdF3KeaLB8wjKr6cM=; b=Gflx7HmYytspVwcb1E2Zv9urd4Gmn4GucIoICYIVVEwyEwnU8yF1CmIoz3+zPap113 ooWOnzxAsSB0LovPcw2qXFV/e7XtabpigZBjAq/4lzsCor9t24oMxfWcTiZ6QgyIA/li kD5nYOhaUoZpituUtkFbsBXpIrCLAukfMq78Q= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=fEfB/jgB/4UJst2FyWFerS3u+gTdF3KeaLB8wjKr6cM=; b=GrWOc8My8jFWwOnIY4SGaok5U3oxfZCz0AjchHgFctHiPKwZVSJGYS1fmeqVTPSf/3 Xu6eur1JZUnh/YzOpmJHSNmSQWThzH+/FkzcI+weF4XnSfApCFUIHxI0OsKOgh7r04xV KPpVw5JxCgLGK0B8yaKjuK6N6Av0lsdnUJ48S4Cd/1oyVkkUBbge8Dsn4L2OleNw5GxC OIgiGz7Vtyr8EDjaEjdkWTXzedvLC0yXdqrlrz4F6z843Hdk7nzfKYAqgqLicUuVr0zn WpyvJsdpsz7ar0y9C96V7AXOH56dmvJFdgpx/PY4dAollBz+yEG6bpUS1CgL9Km7fFR8 gjjg== X-Gm-Message-State: AKGB3mJ1yGrpJONy49CkIjWmm9QHgzQrSgJcbL8VEnW5dHNbLBu2YurN PM/imEexHC2N9qMB4bfG9TqzQ7xB X-Google-Smtp-Source: ACJfBou9SJ0ZeIN+9ZQEgUnC1r51XpMUhKE/nwnf8ntz+fojRWPS5kXUH+KOdSsANHLtI6PfjUFnkQ== X-Received: by 10.55.87.71 with SMTP id l68mr36581151qkb.127.1514444983190; Wed, 27 Dec 2017 23:09:43 -0800 (PST) Received: from dhcp-135-24-192-103.dhcp.broadcom.net ([192.19.239.250]) by smtp.googlemail.com with ESMTPSA id g33sm21307821qkh.56.2017.12.27.23.09.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 27 Dec 2017 23:09:42 -0800 (PST) From: Chaitra P B To: linux-scsi@vger.kernel.org Cc: linux-nvme@lists.infradead.org, Sathya.Prakash@broadcom.com, sreekanth.reddy@broadcom.com, Chaitra P B , Suganath Prabu S Subject: [PATCH] mpt3sas: Proper handling of set/clear of "ATA command pending" flag. Date: Wed, 27 Dec 2017 23:09:11 -0800 Message-Id: <1514444951-9502-1-git-send-email-chaitra.basappa@broadcom.com> X-Mailer: git-send-email 2.5.5 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 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 --- drivers/scsi/mpt3sas/mpt3sas_scsih.c | 28 +++++++++++++++------------- 1 files changed, 15 insertions(+), 13 deletions(-) diff --git a/drivers/scsi/mpt3sas/mpt3sas_scsih.c b/drivers/scsi/mpt3sas/mpt3sas_scsih.c index 82d5612..74fca18 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_scsih.c +++ b/drivers/scsi/mpt3sas/mpt3sas_scsih.c @@ -4600,19 +4600,6 @@ scsih_qcmd(struct Scsi_Host *shost, struct scsi_cmnd *scmd) 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 */ @@ -4638,6 +4625,19 @@ scsih_qcmd(struct Scsi_Host *shost, struct scsi_cmnd *scmd) 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) @@ -4665,6 +4665,7 @@ scsih_qcmd(struct Scsi_Host *shost, struct scsi_cmnd *scmd) 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); @@ -4696,6 +4697,7 @@ scsih_qcmd(struct Scsi_Host *shost, struct scsi_cmnd *scmd) pcie_device = sas_target_priv_data->pcie_dev; if (ioc->build_sg_scmd(ioc, scmd, smid, pcie_device)) { mpt3sas_base_free_smid(ioc, smid); + _scsih_set_satl_pending(scmd, false); goto out; } } else