Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp1636768pxu; Thu, 8 Oct 2020 17:29:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxLi1LRh7I1mYIAi5yzDisOFbPnsjptG1PmIIwG6+WgDr/UtjquY24vy42KTS9q4BCN+gb7 X-Received: by 2002:a50:d787:: with SMTP id w7mr11786800edi.296.1602203381993; Thu, 08 Oct 2020 17:29:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1602203381; cv=none; d=google.com; s=arc-20160816; b=UvHPYgGeOgZaOIYPz4YWNKz9iFanq35G3F8xuTWBVkk/2QptsurQ1y8GzHldLyIcDb k/VIs0+v7DmMRSy3m/kAWvVNkvHye5mYN6DDZz9GUn55xZXbpiFI29Ho5ey86KZovsvE myBJPRZqQ3gvGRB2ItkpM0wv2Eb3RBtNPU/Z5pNr3atrbX82jTn772VFppVBFXAipOwL sNj3PLp38CXYFxY4Kqm/vihjEvlvVxQIHjFgCwCSzpM129GBwtnu0Dn8nJQRm8wbO6PV HO3XPm74gPQUZ35h9ht9qbM7ey3zmO/4bpGn1Su+iGkqN9FfCfXqTq/ONM5H3g8nPBjW QDdg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=FdNMvCcCuXxLzDiJt9iUvAf1kgxpbOr+QNX/PxUy1tE=; b=tx8Kcek9KjXIY2NH8lldKsj4pKHdftmwqD4CIkXLVdiDVsWkMSEcbNyvtMEUQhLjBp dlEM+LOwJkwgyEUQ0gF2OtjWzlGF4cluXUdHfJ7JAOwWUUSmxLXwfy2fvuuvRwudlP6l CbU4RLysUmq7kkeEqqxei/MrXT/2YUezgdLM5pRPOElv07K4LYLCG7bF6mnVQDClzvnq jht02TZWmlqpMDtnha2hzbf+vrr2xLiTTMW38OlBRO0qTRtYg9sdR3jjcsdWAZIEcna7 kUruXiJsWBrVovD+LzMFBZ2/t7sfNbeP3bZ27MKJQnZyOAB/yM7mn3hfsSapVuZL46gU RDDA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=kfDYdrEQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dp4si1391624ejc.117.2020.10.08.17.29.19; Thu, 08 Oct 2020 17:29:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=kfDYdrEQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730763AbgJHWxF (ORCPT + 99 others); Thu, 8 Oct 2020 18:53:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49998 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730691AbgJHWxA (ORCPT ); Thu, 8 Oct 2020 18:53:00 -0400 Received: from mail-pg1-x544.google.com (mail-pg1-x544.google.com [IPv6:2607:f8b0:4864:20::544]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 44B90C0613D6 for ; Thu, 8 Oct 2020 15:53:00 -0700 (PDT) Received: by mail-pg1-x544.google.com with SMTP id o25so5578059pgm.0 for ; Thu, 08 Oct 2020 15:53:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=FdNMvCcCuXxLzDiJt9iUvAf1kgxpbOr+QNX/PxUy1tE=; b=kfDYdrEQA9wxhwwPN/a1Z5Twoej4LkSHIZvb+H9j4sp9IuIJwGp5iEW4blw9K2RV/j Bwtj60HKV0AIbAxewc3zi+h91ETQYJ1nDFkk84xmX91ctjnUWWoMwa0eaXycgXwHUUVV rtJgRSVFfuCzzDbiubtcNb08nvQ37edG/Ytd8= 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:mime-version:content-transfer-encoding; bh=FdNMvCcCuXxLzDiJt9iUvAf1kgxpbOr+QNX/PxUy1tE=; b=NAI2kGGY3cdVrSn+H7W9Z5PYs6yt45fjPGN5SwBwVj34+oqzUGvfntX/YOUlt0RleC GJinLuLY/N9S88rD3wSFBhIy3M38xPfxdmylBZ3BXhUctLd8587cV1FHV1/bj6SU6uh8 Q1VJzkWoPWEVFfx/xk84r3ABViCvvF3e45Uuu0mQFvHKzbZ2ttyb2JHWpqdgwqv7thvf 8z3BQkssiLb7JZgRfkpCkqBHoV4K6IxZn6fRcEC0ETAEcKzztXLeXU5MeCg9SxGTGUcA EgKWkKss+fm/E7lrjH+Ue2GCKyY0z4uhtlnBeQiZZBPJF2PkIsBvG38Z9j1+MsqCj16/ 4a2Q== X-Gm-Message-State: AOAM531/YB3CKmP7WYieV9TF71S6XumShdPiAsdR/LxSE1AWE2zBrvt7 0yrFvYIkL5UJ6IAxZ89UBeoEmA== X-Received: by 2002:a62:7cd4:0:b029:152:b3e8:c59f with SMTP id x203-20020a627cd40000b0290152b3e8c59fmr9288919pfc.2.1602197579826; Thu, 08 Oct 2020 15:52:59 -0700 (PDT) Received: from tictac2.mtv.corp.google.com ([2620:15c:202:1:42b0:34ff:fe3d:58e6]) by smtp.gmail.com with ESMTPSA id jx17sm8386369pjb.10.2020.10.08.15.52.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Oct 2020 15:52:59 -0700 (PDT) From: Douglas Anderson To: Bjorn Andersson , Wolfram Sang , Akash Asthana Cc: linux-arm-msm@vger.kernel.org, Stephen Boyd , linux-i2c@vger.kernel.org, Douglas Anderson , Andy Gross , linux-kernel@vger.kernel.org Subject: [PATCH 3/3] soc: qcom: geni: Optimize select fifo/dma mode Date: Thu, 8 Oct 2020 15:52:35 -0700 Message-Id: <20201008155154.3.I646736d3969dc47de8daceb379c6ba85993de9f4@changeid> X-Mailer: git-send-email 2.28.0.1011.ga647a8990f-goog In-Reply-To: <20201008225235.2035820-1-dianders@chromium.org> References: <20201008225235.2035820-1-dianders@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The functions geni_se_select_fifo_mode() and geni_se_select_fifo_mode() are a little funny. They read/write a bunch of memory mapped registers even if they don't change or aren't relevant for the current protocol. Let's make them a little more sane. NOTE: there is no evidence at all that this makes any performance difference and it fixes no bugs. However, it seems (to me) like it makes the functions a little easier to understand. Decreasing the amount of times we read/write memory mapped registers is also nice, even if we are using "relaxed" variants. Signed-off-by: Douglas Anderson --- drivers/soc/qcom/qcom-geni-se.c | 44 ++++++++++++++++++--------------- 1 file changed, 24 insertions(+), 20 deletions(-) diff --git a/drivers/soc/qcom/qcom-geni-se.c b/drivers/soc/qcom/qcom-geni-se.c index 751a49f6534f..746854745b15 100644 --- a/drivers/soc/qcom/qcom-geni-se.c +++ b/drivers/soc/qcom/qcom-geni-se.c @@ -266,49 +266,53 @@ EXPORT_SYMBOL(geni_se_init); static void geni_se_select_fifo_mode(struct geni_se *se) { u32 proto = geni_se_read_proto(se); - u32 val; + u32 val, val_old; geni_se_irq_clear(se); - val = readl_relaxed(se->base + SE_GENI_M_IRQ_EN); if (proto != GENI_SE_UART) { + val_old = val = readl_relaxed(se->base + SE_GENI_M_IRQ_EN); val |= M_CMD_DONE_EN | M_TX_FIFO_WATERMARK_EN; val |= M_RX_FIFO_WATERMARK_EN | M_RX_FIFO_LAST_EN; - } - writel_relaxed(val, se->base + SE_GENI_M_IRQ_EN); + if (val != val_old) + writel_relaxed(val, se->base + SE_GENI_M_IRQ_EN); - val = readl_relaxed(se->base + SE_GENI_S_IRQ_EN); - if (proto != GENI_SE_UART) - val |= S_CMD_DONE_EN; - writel_relaxed(val, se->base + SE_GENI_S_IRQ_EN); + val = readl_relaxed(se->base + SE_GENI_S_IRQ_EN); + if (!(val & S_CMD_DONE_EN)) + writel_relaxed(val | S_CMD_DONE_EN, + se->base + SE_GENI_S_IRQ_EN); + } val = readl_relaxed(se->base + SE_GENI_DMA_MODE_EN); - val &= ~GENI_DMA_MODE_EN; - writel_relaxed(val, se->base + SE_GENI_DMA_MODE_EN); + if (val & GENI_DMA_MODE_EN) + writel_relaxed(val & ~GENI_DMA_MODE_EN, + se->base + SE_GENI_DMA_MODE_EN); } static void geni_se_select_dma_mode(struct geni_se *se) { u32 proto = geni_se_read_proto(se); - u32 val; + u32 val, val_old; geni_se_irq_clear(se); - val = readl_relaxed(se->base + SE_GENI_M_IRQ_EN); if (proto != GENI_SE_UART) { + val_old = val = readl_relaxed(se->base + SE_GENI_M_IRQ_EN); val &= ~(M_CMD_DONE_EN | M_TX_FIFO_WATERMARK_EN); val &= ~(M_RX_FIFO_WATERMARK_EN | M_RX_FIFO_LAST_EN); - } - writel_relaxed(val, se->base + SE_GENI_M_IRQ_EN); + if (val != val_old) + writel_relaxed(val, se->base + SE_GENI_M_IRQ_EN); - val = readl_relaxed(se->base + SE_GENI_S_IRQ_EN); - if (proto != GENI_SE_UART) - val &= ~S_CMD_DONE_EN; - writel_relaxed(val, se->base + SE_GENI_S_IRQ_EN); + val = readl_relaxed(se->base + SE_GENI_S_IRQ_EN); + if (val & S_CMD_DONE_EN) + writel_relaxed(val & ~S_CMD_DONE_EN, + se->base + SE_GENI_S_IRQ_EN); + } val = readl_relaxed(se->base + SE_GENI_DMA_MODE_EN); - val |= GENI_DMA_MODE_EN; - writel_relaxed(val, se->base + SE_GENI_DMA_MODE_EN); + if (!(val & GENI_DMA_MODE_EN)) + writel_relaxed(val | GENI_DMA_MODE_EN, + se->base + SE_GENI_DMA_MODE_EN); } /** -- 2.28.0.1011.ga647a8990f-goog