From patchwork Thu Jul 1 06:51:26 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 1499349 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4GFpmn5D0Xz9sX5; Thu, 1 Jul 2021 16:52:25 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1lyqYd-00022F-N9; Thu, 01 Jul 2021 06:52:19 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1lyqYG-0001jT-FR for kernel-team@lists.ubuntu.com; Thu, 01 Jul 2021 06:51:56 +0000 Received: from mail-ed1-f72.google.com ([209.85.208.72]) by youngberry.canonical.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.93) (envelope-from ) id 1lyqYF-0007KB-EM for kernel-team@lists.ubuntu.com; Thu, 01 Jul 2021 06:51:55 +0000 Received: by mail-ed1-f72.google.com with SMTP id s6-20020a0564020146b029039578926b8cso2493536edu.20 for ; Wed, 30 Jun 2021 23:51:55 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=8JBSMBA36M+d/px+sP0MoJd4pe/zP/fxd55PlV/C3B8=; b=Bs+FBZhN2bLYJ1a0ESgI8mFPFQ2yrzhRzjm7nBmJDsT4EHX1zH7RYemjsCP00ik/9Q rP1s65daNxG/TtZ11OG+HMD7s9zv72qKGgjQR6tDhBF8QR1HX01Uavk2twPC1DL/h0wE KEsydWJ155zh8RB5bb1eAfcaw0B6jr44hi6eSPgJ88AArDW9veSfQy+aZ6TGa0l6gi/p izdKHzVbGkrhlt6C4uVrSmREPaZlS20HTvGCj7kUf4/rWaalZ892Ta18mmwktwzalhIp hl3LegD73eTaIzvuQ/UCkStTx/Gp01CMPBoLtFwzT1E3i3eAJg63Ugr2ha6fjvz8eyQq 59Sg== X-Gm-Message-State: AOAM5337MANXc4RA/jZzeCWuf0488YBtbKGIKqvH/xWiepDLDN1qi2Dp rmz8eDkjDc/OuJES+MpNrss3zVJ3IVCzF3nk7vYzGlODgyYg9nT+nVuZOx/4tMDjais+cFN9i9i w3CaQOLhMJhfIcxToB2j5EcC7FzfW8R+1kER3Rhs0cA== X-Received: by 2002:a17:907:3e8a:: with SMTP id hs10mr29045004ejc.359.1625122314950; Wed, 30 Jun 2021 23:51:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz9LKnXAsJFrt8DAudNgPVF1AfFN1knl5SSsZQ4PtFtyhK+TPF2RcpyO7ucK3zK+KuSA/fshQ== X-Received: by 2002:a17:907:3e8a:: with SMTP id hs10mr29044992ejc.359.1625122314731; Wed, 30 Jun 2021 23:51:54 -0700 (PDT) Received: from localhost.localdomain (xdsl-188-155-177-222.adslplus.ch. [188.155.177.222]) by smtp.gmail.com with ESMTPSA id t15sm10394144ejf.119.2021.06.30.23.51.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Jun 2021 23:51:54 -0700 (PDT) From: Krzysztof Kozlowski To: kernel-team@lists.ubuntu.com Subject: [PATCH][SRU][F-hwe-5.11 15/30] scsi: smartpqi: Synchronize device resets with mutex Date: Thu, 1 Jul 2021 08:51:26 +0200 Message-Id: <20210701065141.6018-16-krzysztof.kozlowski@canonical.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210701065141.6018-1-krzysztof.kozlowski@canonical.com> References: <20210701065141.6018-1-krzysztof.kozlowski@canonical.com> MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Kevin Barnett BugLink: https://bugs.launchpad.net/bugs/1933518 Remove some flags used to check for device resets already in progress. Allow only 1 reset operation at a time for the host. Link: https://lore.kernel.org/r/161549379810.25025.10194117431886743795.stgit@brunhilda Reviewed-by: Scott Benesh Reviewed-by: Mike McGowen Reviewed-by: Scott Teel Signed-off-by: Kevin Barnett Signed-off-by: Don Brace Signed-off-by: Martin K. Petersen (cherry picked from commit 37f3318199ce31122c389bafb092ee72a6123d9d) Signed-off-by: Krzysztof Kozlowski --- drivers/scsi/smartpqi/smartpqi.h | 1 - drivers/scsi/smartpqi/smartpqi_init.c | 48 ++++++++------------------- 2 files changed, 13 insertions(+), 36 deletions(-) diff --git a/drivers/scsi/smartpqi/smartpqi.h b/drivers/scsi/smartpqi/smartpqi.h index c575a5173110..966cc1dc2edc 100644 --- a/drivers/scsi/smartpqi/smartpqi.h +++ b/drivers/scsi/smartpqi/smartpqi.h @@ -1286,7 +1286,6 @@ struct pqi_ctrl_info { struct mutex ofa_mutex; /* serialize ofa */ bool controller_online; bool block_requests; - bool block_device_reset; bool in_ofa; bool in_shutdown; u8 inbound_spanning_supported : 1; diff --git a/drivers/scsi/smartpqi/smartpqi_init.c b/drivers/scsi/smartpqi/smartpqi_init.c index dc4dee4fc60f..157990260dd7 100644 --- a/drivers/scsi/smartpqi/smartpqi_init.c +++ b/drivers/scsi/smartpqi/smartpqi_init.c @@ -247,12 +247,12 @@ static inline void pqi_save_ctrl_mode(struct pqi_ctrl_info *ctrl_info, static inline void pqi_ctrl_block_device_reset(struct pqi_ctrl_info *ctrl_info) { - ctrl_info->block_device_reset = true; + mutex_lock(&ctrl_info->lun_reset_mutex); } -static inline bool pqi_device_reset_blocked(struct pqi_ctrl_info *ctrl_info) +static inline void pqi_ctrl_unblock_device_reset(struct pqi_ctrl_info *ctrl_info) { - return ctrl_info->block_device_reset; + mutex_unlock(&ctrl_info->lun_reset_mutex); } static inline bool pqi_ctrl_blocked(struct pqi_ctrl_info *ctrl_info) @@ -297,16 +297,6 @@ static inline bool pqi_device_offline(struct pqi_scsi_dev *device) return device->device_offline; } -static inline void pqi_device_reset_start(struct pqi_scsi_dev *device) -{ - device->in_reset = true; -} - -static inline void pqi_device_reset_done(struct pqi_scsi_dev *device) -{ - device->in_reset = false; -} - static inline bool pqi_device_in_reset(struct pqi_scsi_dev *device) { return device->in_reset; @@ -6098,7 +6088,7 @@ static int pqi_lun_reset(struct pqi_ctrl_info *ctrl_info, #define PQI_LUN_RESET_RETRY_INTERVAL_MSECS 10000 #define PQI_LUN_RESET_PENDING_IO_TIMEOUT_SECS 120 -static int _pqi_device_reset(struct pqi_ctrl_info *ctrl_info, +static int pqi_lun_reset_with_retries(struct pqi_ctrl_info *ctrl_info, struct pqi_scsi_dev *device) { int rc; @@ -6124,23 +6114,15 @@ static int pqi_device_reset(struct pqi_ctrl_info *ctrl_info, { int rc; - mutex_lock(&ctrl_info->lun_reset_mutex); - pqi_ctrl_block_requests(ctrl_info); pqi_ctrl_wait_until_quiesced(ctrl_info); pqi_fail_io_queued_for_device(ctrl_info, device); rc = pqi_wait_until_inbound_queues_empty(ctrl_info); - pqi_device_reset_start(device); - pqi_ctrl_unblock_requests(ctrl_info); - if (rc) rc = FAILED; else - rc = _pqi_device_reset(ctrl_info, device); - - pqi_device_reset_done(device); - - mutex_unlock(&ctrl_info->lun_reset_mutex); + rc = pqi_lun_reset_with_retries(ctrl_info, device); + pqi_ctrl_unblock_requests(ctrl_info); return rc; } @@ -6156,29 +6138,25 @@ static int pqi_eh_device_reset_handler(struct scsi_cmnd *scmd) ctrl_info = shost_to_hba(shost); device = scmd->device->hostdata; + mutex_lock(&ctrl_info->lun_reset_mutex); + dev_err(&ctrl_info->pci_dev->dev, "resetting scsi %d:%d:%d:%d\n", shost->host_no, device->bus, device->target, device->lun); pqi_check_ctrl_health(ctrl_info); - if (pqi_ctrl_offline(ctrl_info) || - pqi_device_reset_blocked(ctrl_info)) { + if (pqi_ctrl_offline(ctrl_info)) rc = FAILED; - goto out; - } - - pqi_wait_until_ofa_finished(ctrl_info); - - atomic_inc(&ctrl_info->sync_cmds_outstanding); - rc = pqi_device_reset(ctrl_info, device); - atomic_dec(&ctrl_info->sync_cmds_outstanding); + else + rc = pqi_device_reset(ctrl_info, device); -out: dev_err(&ctrl_info->pci_dev->dev, "reset of scsi %d:%d:%d:%d: %s\n", shost->host_no, device->bus, device->target, device->lun, rc == SUCCESS ? "SUCCESS" : "FAILED"); + mutex_unlock(&ctrl_info->lun_reset_mutex); + return rc; }