From patchwork Fri Dec 7 07:28:33 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suganath Prabu S X-Patchwork-Id: 10717569 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 622FF109C for ; Fri, 7 Dec 2018 07:29:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 48D092EA61 for ; Fri, 7 Dec 2018 07:29:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 394EB2EA6D; Fri, 7 Dec 2018 07:29:09 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,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 C7CEF2EA61 for ; Fri, 7 Dec 2018 07:29:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726067AbeLGH3I (ORCPT ); Fri, 7 Dec 2018 02:29:08 -0500 Received: from mail-wm1-f66.google.com ([209.85.128.66]:53109 "EHLO mail-wm1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725998AbeLGH3I (ORCPT ); Fri, 7 Dec 2018 02:29:08 -0500 Received: by mail-wm1-f66.google.com with SMTP id r11-v6so3309660wmb.2 for ; Thu, 06 Dec 2018 23:29:07 -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:in-reply-to:references; bh=LIVNocUhSGdbhkR5q1azXuG8Cb7cGN4S1iYMW//3lWA=; b=WgaD6SyJDKejrMFdTOCJAGYrDYXZVmHqvvw8pJowZnBwH62eLTK6ahfUdik3QtMa0v ZBvRKIbGFsjrINpW/F1E4a62u9GeT0lLScXOKvHRDBGvnnZ8ji9M3r0/excDg6qdBDfo 42UxU/5GBlsHQZBRBZ8FDmTznZ79zG2q2vnzA= 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:in-reply-to :references; bh=LIVNocUhSGdbhkR5q1azXuG8Cb7cGN4S1iYMW//3lWA=; b=sVTG3c08lEk3ZGrzqwMMQmquSbJhzxMRtidotysCPN484t5n88nerJbfzVs8Ch9Chg ihdBjzGxw1ySmwHOpry1XYqMAzUahCrkiPGhQEvd0d3rC3Iw3d9cld577pPBGNtPHC62 5Rg2csI6vtIreud6wK6WDZn14MGVnWwxjHzws2xUuvdxmVXszHZmWoGBdakOr9H6jr0n YlEVFqezy+rJHbFuFefhgvkqkhBt6hiApIieRivWvRnYGZTUKO5lThIIpdY/r87RmAaB XrVMDWSR9ZND8eWG5vbjwNkzNB1ppKLv07aokbi5a76d8gO1lzYlz2ggXThVZOD0XQio RySQ== X-Gm-Message-State: AA+aEWbEOwilHXnV4dGo+3YQT8ezJFgA8u0vH9w3JowdDHJdxn1yn8lm YT2o3/JXXDNrpXY+TzXQc0ty8A== X-Google-Smtp-Source: AFSGD/WIUNOCtmgvUuCd7gN7nmjXXahfy4Tr5qUk0Zww47kzd1sfjbLXHyd5+YvTBgSO+irFyoqaSg== X-Received: by 2002:a1c:a4c3:: with SMTP id n186mr1143310wme.89.1544167746757; Thu, 06 Dec 2018 23:29:06 -0800 (PST) Received: from dhcp-10-123-74-106.dhcp.broadcom.net ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id b16sm1589317wrm.41.2018.12.06.23.29.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 06 Dec 2018 23:29:06 -0800 (PST) From: Suganath Prabu To: martin.petersen@oracle.com, linux-scsi@vger.kernel.org Cc: sathya.prakash@broadcom.com, suganath-prabu.subramani@broadcom.com Subject: [PATCH 2/4] mpt3sas: Add separate function for aero doorbell reads. Date: Fri, 7 Dec 2018 12:58:33 +0530 Message-Id: <1544167715-5595-3-git-send-email-suganath-prabu.subramani@broadcom.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1544167715-5595-1-git-send-email-suganath-prabu.subramani@broadcom.com> References: <1544167715-5595-1-git-send-email-suganath-prabu.subramani@broadcom.com> 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 Sometimes Aero controllers appears to be returning bad data (0) for doorbell register read and if retries are performed immediately after the bad read, they return good data. Workaround is added to retry read from doorbell registers for maximum three times if driver get the zero. Added functions base_readl_aero for Aero IOC and base_readl for gen35 and other controllers. Signed-off-by: Suganath Prabu --- drivers/scsi/mpt3sas/mpt3sas_base.c | 30 ++++++++++++++++++++++++++++++ drivers/scsi/mpt3sas/mpt3sas_base.h | 2 ++ 2 files changed, 32 insertions(+) diff --git a/drivers/scsi/mpt3sas/mpt3sas_base.c b/drivers/scsi/mpt3sas/mpt3sas_base.c index 9254b52..d371c8e 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_base.c +++ b/drivers/scsi/mpt3sas/mpt3sas_base.c @@ -157,6 +157,32 @@ module_param_call(mpt3sas_fwfault_debug, _scsih_set_fwfault_debug, param_get_int, &mpt3sas_fwfault_debug, 0644); /** + * _base_readl_aero - retry readl for max three times. + * @addr - MPT Fusion system interface register address + * + * Retry the readl() for max three times if it gets zero value + * while reading the system interface register. + */ +static inline u32 +_base_readl_aero(const volatile void __iomem *addr) +{ + u32 i = 0, ret_val; + + do { + ret_val = readl(addr); + i++; + } while (ret_val == 0 && i < 3); + + return ret_val; +} + +static inline u32 +_base_readl(const volatile void __iomem *addr) +{ + return readl(addr); +} + +/** * _base_clone_reply_to_sys_mem - copies reply to reply free iomem * in BAR0 space. * @@ -6398,6 +6424,10 @@ mpt3sas_base_attach(struct MPT3SAS_ADAPTER *ioc) ioc->rdpq_array_enable_assigned = 0; ioc->dma_mask = 0; + if (ioc->is_aero_ioc) + ioc->base_readl = &_base_readl_aero; + else + ioc->base_readl = &_base_readl; r = mpt3sas_base_map_resources(ioc); if (r) goto out_free_resources; diff --git a/drivers/scsi/mpt3sas/mpt3sas_base.h b/drivers/scsi/mpt3sas/mpt3sas_base.h index f200929..3a294b9 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_base.h +++ b/drivers/scsi/mpt3sas/mpt3sas_base.h @@ -912,6 +912,7 @@ typedef void (*NVME_BUILD_PRP)(struct MPT3SAS_ADAPTER *ioc, u16 smid, typedef void (*PUT_SMID_IO_FP_HIP) (struct MPT3SAS_ADAPTER *ioc, u16 smid, u16 funcdep); typedef void (*PUT_SMID_DEFAULT) (struct MPT3SAS_ADAPTER *ioc, u16 smid); +typedef u32 (*BASE_READ_REG) (const volatile void __iomem *addr); /* IOC Facts and Port Facts converted from little endian to cpu */ union mpi3_version_union { @@ -1392,6 +1393,7 @@ struct MPT3SAS_ADAPTER { u8 hide_drives; spinlock_t diag_trigger_lock; u8 diag_trigger_active; + BASE_READ_REG base_readl; struct SL_WH_MASTER_TRIGGER_T diag_trigger_master; struct SL_WH_EVENT_TRIGGERS_T diag_trigger_event; struct SL_WH_SCSI_TRIGGERS_T diag_trigger_scsi;