From patchwork Tue Mar 20 02:50:02 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sinan Kaya X-Patchwork-Id: 10296183 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 9AC84602BD for ; Tue, 20 Mar 2018 03:12:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8A4C1291E3 for ; Tue, 20 Mar 2018 03:12:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7EDB62920A; Tue, 20 Mar 2018 03:12:57 +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=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 1267D291E3 for ; Tue, 20 Mar 2018 03:12:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Cetp2OXeqCScoV0l/VllmXKGMRkK7c/cuyv2uc0er3Y=; b=ggPcSR7HMl5ODG YFryBAC7WqaGhdgPM0k6GTJ9eT8XNntBb3hOBjiVAWvAu30st1FixOLbB27WZ0XDwm2yxZbP+UV8G gLTiHWmReWKv+/dlWTuhN0xZlWwf7dGkrMv6NsO7gMp0Lh6LefYNGsN32Mwbdke+eH2NjNE0vBHgI DBFh0rJ/MVNI1nLoTgrm1v+/Dr6ZD3D0h3n5hlo8XXATNEGBg+9EICeiHBCa8u79FFN2YREsD+DJi CvpJGPQ/H7hM3uoamuIpueWcHkzd5LXqUSx9mO/QSkbP7gX/nDMYKn4e0VIfULNc/bROGt+aHjkx8 n046fTXzIIqOb3VfRaVA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1ey7hj-00041v-LZ; Tue, 20 Mar 2018 03:12:51 +0000 Received: from merlin.infradead.org ([2001:8b0:10b:1231::1]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1ey7ej-0001B2-JE for linux-arm-kernel@bombadil.infradead.org; Tue, 20 Mar 2018 03:09:45 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=mPVZr3BciEmcVY0R531smMqaVakVxmnav7vdRsEvH/o=; b=EYVfPZaJVb0SbqvgbQ1DKV1Wvz 5V+BhEd09GjoIzu90ASnLAZJAzVaenMCpysfvYLsQfRQiFZEMjSz8i3BagZ9mo84V6w4tAw7peQR5 rJ6vYfEyv/s0V2z7S3ylxNQskTd0Ln//fo0rmNN4E5QEgFf82u38Ax5oEgmUDgbon6pyi580VqMAs tDOw6E5Vgo2hcf4SCtvBysSddXbAkZzlRu/hNTMIoBX2O+Sb3qfK/57ngwEq4jhTLmBcwpr4U4h7j AfOK7y1uFnQWkpMh+NvOuUA9xP8kvRzVDu5e5G/Yn7e64gVyxC2+s9JrFT0+GNvKQY7Kuje+NA+Rx 6ziFwgVA==; Received: from smtp.codeaurora.org ([198.145.29.96]) by merlin.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1ey7M9-0002Kn-Kp for linux-arm-kernel@lists.infradead.org; Tue, 20 Mar 2018 02:50:34 +0000 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id EB6F860F5C; Tue, 20 Mar 2018 02:50:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1521514222; bh=NPpAJHwpF07dHrF7OMG/e508EUHQ50U5ewrsWJALEB0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=etqpfy8E4rswgfSotlGesL9kw85eLR9WU8E0PQ+vAgTJQUwb5d93LP0BbEFRVy9xM TA1NZm0DIwOO6bLCKKWJPS0bMwO73dSP0XQCF0S/bJZqiXQr16ZyEVGDe7Lbs7lmqM NVeBu6Axqjb1FBOUCJuL6arhmJrzALeAQrr0PYSY= Received: from drakthul.qualcomm.com (global_nat1_iad_fw.qualcomm.com [129.46.232.65]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: okaya@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id E47B960C54; Tue, 20 Mar 2018 02:50:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1521514216; bh=NPpAJHwpF07dHrF7OMG/e508EUHQ50U5ewrsWJALEB0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ezeNWk9WDe57hF3e2bgGwT5qyQUQZTMbGUvyv0oFrZTbpqCtZSHyXJA1Lx1wcydXZ oIhr5tDgV3VjTLg3h+uI0ub65YvoRdItEmXR4EhoiL7PALIe4YizmVezfPeXA5G960 A9VZcQqN/fYDV19OcQxkQ+u6Gb6NlFUl65+B8tUA= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org E47B960C54 Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=okaya@codeaurora.org From: Sinan Kaya To: linux-scsi@vger.kernel.org, timur@codeaurora.org, sulrich@codeaurora.org Subject: [PATCH v4 2/7] scsi: megaraid: eliminate duplicate barriers on weakly-ordered archs Date: Mon, 19 Mar 2018 22:50:02 -0400 Message-Id: <1521514207-10695-3-git-send-email-okaya@codeaurora.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1521514207-10695-1-git-send-email-okaya@codeaurora.org> References: <1521514207-10695-1-git-send-email-okaya@codeaurora.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180319_225033_832215_068F6D78 X-CRM114-Status: GOOD ( 15.03 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "James E.J. Bottomley" , "Martin K. Petersen" , Shivasharan S , linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, Kashyap Desai , Sinan Kaya , Sumit Saxena , megaraidlinux.pdl@broadcom.com, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Code includes barrier() followed by writel(). writel() already has a barrier on some architectures like arm64. This ends up CPU observing two barriers back to back before executing the register write. Create a new wrapper function with relaxed write operator. Use the new wrapper when a write is following a barrier(). Since code already has an explicit barrier call, changing writel() to writel_relaxed(). Signed-off-by: Sinan Kaya --- drivers/scsi/megaraid/megaraid_mbox.c | 8 ++++---- drivers/scsi/megaraid/megaraid_mbox.h | 2 ++ drivers/scsi/megaraid/megaraid_sas_fusion.c | 4 ++-- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/drivers/scsi/megaraid/megaraid_mbox.c b/drivers/scsi/megaraid/megaraid_mbox.c index 530358c..8c4fc6e 100644 --- a/drivers/scsi/megaraid/megaraid_mbox.c +++ b/drivers/scsi/megaraid/megaraid_mbox.c @@ -1439,7 +1439,7 @@ mbox_post_cmd(adapter_t *adapter, scb_t *scb) mbox->ack = 0; wmb(); - WRINDOOR(raid_dev, raid_dev->mbox_dma | 0x1); + WRINDOOR_RELAXED(raid_dev, raid_dev->mbox_dma | 0x1); spin_unlock_irqrestore(MAILBOX_LOCK(raid_dev), flags); @@ -2752,7 +2752,7 @@ mbox_post_sync_cmd(adapter_t *adapter, uint8_t raw_mbox[]) mbox->status = 0xFF; wmb(); - WRINDOOR(raid_dev, raid_dev->mbox_dma | 0x1); + WRINDOOR_RELAXED(raid_dev, raid_dev->mbox_dma | 0x1); // wait for maximum 1 second for status to post. If the status is not // available within 1 second, assume FW is initializing and wait @@ -2877,7 +2877,7 @@ mbox_post_sync_cmd_fast(adapter_t *adapter, uint8_t raw_mbox[]) mbox->status = 0xFF; wmb(); - WRINDOOR(raid_dev, raid_dev->mbox_dma | 0x1); + WRINDOOR_RELAXED(raid_dev, raid_dev->mbox_dma | 0x1); for (i = 0; i < MBOX_SYNC_WAIT_CNT; i++) { if (mbox->numstatus != 0xFF) break; @@ -3329,7 +3329,7 @@ megaraid_mbox_fire_sync_cmd(adapter_t *adapter) mbox->status = 0; wmb(); - WRINDOOR(raid_dev, raid_dev->mbox_dma | 0x1); + WRINDOOR_RELAXED(raid_dev, raid_dev->mbox_dma | 0x1); /* Wait for maximum 1 min for status to post. * If the Firmware SUPPORTS the ABOVE COMMAND, diff --git a/drivers/scsi/megaraid/megaraid_mbox.h b/drivers/scsi/megaraid/megaraid_mbox.h index c1d86d9..641cbd4 100644 --- a/drivers/scsi/megaraid/megaraid_mbox.h +++ b/drivers/scsi/megaraid/megaraid_mbox.h @@ -230,6 +230,8 @@ typedef struct { #define RDINDOOR(rdev) readl((rdev)->baseaddr + 0x20) #define RDOUTDOOR(rdev) readl((rdev)->baseaddr + 0x2C) +#define WRINDOOR_RELAXED(rdev, value) \ + writel_relaxed(value, (rdev)->baseaddr + 0x20) #define WRINDOOR(rdev, value) writel(value, (rdev)->baseaddr + 0x20) #define WROUTDOOR(rdev, value) writel(value, (rdev)->baseaddr + 0x2C) diff --git a/drivers/scsi/megaraid/megaraid_sas_fusion.c b/drivers/scsi/megaraid/megaraid_sas_fusion.c index 073ced0..f560496 100644 --- a/drivers/scsi/megaraid/megaraid_sas_fusion.c +++ b/drivers/scsi/megaraid/megaraid_sas_fusion.c @@ -3479,11 +3479,11 @@ complete_cmd_fusion(struct megasas_instance *instance, u32 MSIxIndex) wmb(); if (instance->msix_combined) - writel(((MSIxIndex & 0x7) << 24) | + writel_relaxed(((MSIxIndex & 0x7) << 24) | fusion->last_reply_idx[MSIxIndex], instance->reply_post_host_index_addr[MSIxIndex/8]); else - writel((MSIxIndex << 24) | + writel_relaxed((MSIxIndex << 24) | fusion->last_reply_idx[MSIxIndex], instance->reply_post_host_index_addr[0]); megasas_check_and_restore_queue_depth(instance);