From patchwork Tue Mar 30 10:51:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sreekanth Reddy X-Patchwork-Id: 412155 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,MIME_NO_TEXT, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6E813C433C1 for ; Tue, 30 Mar 2021 10:48:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 45DAE617ED for ; Tue, 30 Mar 2021 10:48:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231370AbhC3Ks1 (ORCPT ); Tue, 30 Mar 2021 06:48:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53812 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231856AbhC3KsD (ORCPT ); Tue, 30 Mar 2021 06:48:03 -0400 Received: from mail-pl1-x633.google.com (mail-pl1-x633.google.com [IPv6:2607:f8b0:4864:20::633]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5E172C061574 for ; Tue, 30 Mar 2021 03:48:03 -0700 (PDT) Received: by mail-pl1-x633.google.com with SMTP id v23so5952470ple.9 for ; Tue, 30 Mar 2021 03:48:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=from:to:cc:subject:date:message-id:mime-version; bh=V3E4t1U6B+dq+WBaXgxXN69/HMP4D9ucOZWaHFwkh/Y=; b=aVQ45YRU66TaoryHqvaAFc+1VDaubXDIJkXeCKZ51Mynlat5m/Ptcim9J2dgD4g0ES KWxWIG8DYsKwStifnj21cZ701hRstJRLvOvDFm8KpmYC1i/o1I/pYs0Ae5LBKpnykcVP RAYRVZY0dVCfU5Pfo3qaFi3+DyTehscNEiXrE= 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:mime-version; bh=V3E4t1U6B+dq+WBaXgxXN69/HMP4D9ucOZWaHFwkh/Y=; b=GcxcQs/bn+Al36Vrk0jrXw6j99zoPHSdQcpuXdNXVmSmG1LlwGky6LjGuqz8nhd4r6 VHPHpMT2a0PBOOoWlTXu1r0tfafKzLGizR5iPTsU8biqmRT9qQt5cCRgAc+TDAS0H+MG KIdHRCLtbgXtF9wvbVIkrn/XFybfflOfQevAaNJXGOa12DYCdHefm7d2NHVpJ7qOiGVH dnB9EiR3u11NYbS24F1miK9+/Q4GYWApZsmIwmShwvczw0tdPxZCyC7+f+0312PHrBPu b5vG+a5AZwepYHTcyLjQUidoNTs1lmXXeCM4vI3BbPsF3NUwuS1HU3RQCcqrHDDi/tDz iwgA== X-Gm-Message-State: AOAM533V7T962CT+D4navxQCLv9sqh9yptDLX5PgUuKk0846yuxeeXvy +VPe+mq0Hk5B61v+aBZANx21Sw== X-Google-Smtp-Source: ABdhPJxecfUoDK8ZCVyMZzfOMwxP/hKPXONENST2UZbgnx7+M9IqSAlH9jk6rkWuhVEcu3bftAibTw== X-Received: by 2002:a17:90a:e516:: with SMTP id t22mr3668624pjy.39.1617101282803; Tue, 30 Mar 2021 03:48:02 -0700 (PDT) Received: from dhcp-10-123-20-36.dhcp.broadcom.net ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id i13sm19324912pgi.3.2021.03.30.03.47.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Mar 2021 03:48:02 -0700 (PDT) From: Sreekanth Reddy To: martin.petersen@oracle.com Cc: linux-scsi@vger.kernel.org, sathya.prakash@broadcom.com, suganath-prabu.subramani@broadcom.com, Sreekanth Reddy , stable@vger.kernel.org Subject: [PATCH] mpt3sas: Block PCI cfg access from userspace during reset Date: Tue, 30 Mar 2021 16:21:37 +0530 Message-Id: <20210330105137.20728-1-sreekanth.reddy@broadcom.com> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org While diag reset is in progress, there is short duration where all access to controller's PCI config space from the host needs to be blocked. This is due to a hardware limitation of IOC controllers. With this patch, driver will block all access to controller's config space from userland applications by calling pci_cfg_access_lock() while diag reset is in progress and unlocking after controller comes back to ready state. Cc: stable@vger.kernel.org #v5.4.108+ Signed-off-by: Sreekanth Reddy --- drivers/scsi/mpt3sas/mpt3sas_base.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/scsi/mpt3sas/mpt3sas_base.c b/drivers/scsi/mpt3sas/mpt3sas_base.c index ac0eef975f17..b6beacfd0f62 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_base.c +++ b/drivers/scsi/mpt3sas/mpt3sas_base.c @@ -7252,6 +7252,8 @@ _base_diag_reset(struct MPT3SAS_ADAPTER *ioc) ioc_info(ioc, "sending diag reset !!\n"); + pci_cfg_access_lock(ioc->pdev); + drsprintk(ioc, ioc_info(ioc, "clear interrupts\n")); count = 0; @@ -7342,10 +7344,12 @@ _base_diag_reset(struct MPT3SAS_ADAPTER *ioc) goto out; } + pci_cfg_access_unlock(ioc->pdev); ioc_info(ioc, "diag reset: SUCCESS\n"); return 0; out: + pci_cfg_access_unlock(ioc->pdev); ioc_err(ioc, "diag reset: FAILED\n"); return -EFAULT; }