Received: by 10.213.65.68 with SMTP id h4csp67001imn; Mon, 19 Mar 2018 19:52:58 -0700 (PDT) X-Google-Smtp-Source: AG47ELs25mCcwtTtO2TwtSAzKT9Qx3mzaQBIBNSYIM1U+jG8WkrkE+ofvtV1ykFpHDYEgji5kx1o X-Received: by 10.101.86.70 with SMTP id m6mr11061535pgs.349.1521514378422; Mon, 19 Mar 2018 19:52:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521514378; cv=none; d=google.com; s=arc-20160816; b=QkjAROECn+GLCs2leER9R7VbUOa1y4dXXJZY3FoPjtnd+Xw/sADmA0eU94kV6nqPoS A8Hb1cSgjujoz+zuFz7DvujAsJGfM+ymqKCdoqfzNZ5I6x9Bsht+HLgn657oLfq4cOjf J9Eel97ZF+bOh+Gry76HltI4WV04NOCw0O0LmHAKx4wKJlYhRdjFvYfzpjJRaAtIODPu KYYSrVRrB8JDpxHPoNxpt6ZWpH4qoFPPzVqwHtZncpg/f6dCnsPioCl1DcK1ikyNdPpd kvq5+g4NMnrQ916+K7dTqcW3WR4oAiROlbsD0NdCAcbGmKKuxDuv3qaXl0h97qiU3P79 yv5w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dmarc-filter:dkim-signature:dkim-signature :arc-authentication-results; bh=mPVZr3BciEmcVY0R531smMqaVakVxmnav7vdRsEvH/o=; b=Y6YBp/6pDgDZIVdvMuOtKrLHognrqj70UV0VRHEWA0461kofYeWKr08kxo1OPylxOq fr9d+Rr7GO/6geGzF6mBizq/2eiYPNvs2TYQ5aDH/YKpxfMc/dIsL+mJ6p604ncEge8J dftsdInZgUGE2exalc/K4sAzos48/4vFp9u2utNS85BJj+fneXH4Rxk06BML1VPb/z4q qbeiHwFST3mZXGweaSPXlsVn013GJCVQGtX4LmbULIkMROMPD8V847nEKrMJS97hSBzX msbjFIK0hj3J6SK68wy7Us9lXmyTlbbglAM4VlaK9BVPdl8pS42WVqaW1c8YNoWoFens RLJA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=W/MBSJkY; dkim=pass header.i=@codeaurora.org header.s=default header.b=ezeNWk9W; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f188si513051pfc.316.2018.03.19.19.52.44; Mon, 19 Mar 2018 19:52:58 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=W/MBSJkY; dkim=pass header.i=@codeaurora.org header.s=default header.b=ezeNWk9W; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752478AbeCTCvg (ORCPT + 99 others); Mon, 19 Mar 2018 22:51:36 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:35528 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751915AbeCTCuZ (ORCPT ); Mon, 19 Mar 2018 22:50:25 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id A0A0F6110D; 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=1521514224; bh=NPpAJHwpF07dHrF7OMG/e508EUHQ50U5ewrsWJALEB0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=W/MBSJkYCqYy8y9HgFlImlQfhzNn+2AumdQw05q9cv1PREviz0G8BUHJjTfeSsjmn xYY6tBzfB8598bte35Fe2x9rRnttIev9kSlNbbQlUhnmfhmsukaHyD6sp/hZwEg+t0 WL1CLI1mT5bswnwSY1tyBkPu/sycBTM+TnzMzHns= X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on pdx-caf-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.8 required=2.0 tests=ALL_TRUSTED,BAYES_00, DKIM_SIGNED,T_DKIM_INVALID autolearn=no autolearn_force=no version=3.4.0 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 Cc: linux-arm-msm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Sinan Kaya , Kashyap Desai , Sumit Saxena , Shivasharan S , "James E.J. Bottomley" , "Martin K. Petersen" , megaraidlinux.pdl@broadcom.com, linux-kernel@vger.kernel.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 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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); -- 2.7.4