From patchwork Sat Sep 12 21:07:59 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 11772071 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 971641580 for ; Sat, 12 Sep 2020 21:08:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7B582207FB for ; Sat, 12 Sep 2020 21:08:50 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="n+aUgG/R" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725956AbgILVIr (ORCPT ); Sat, 12 Sep 2020 17:08:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53674 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725918AbgILVIT (ORCPT ); Sat, 12 Sep 2020 17:08:19 -0400 Received: from mail-pg1-x541.google.com (mail-pg1-x541.google.com [IPv6:2607:f8b0:4864:20::541]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BD839C061573 for ; Sat, 12 Sep 2020 14:08:17 -0700 (PDT) Received: by mail-pg1-x541.google.com with SMTP id s65so7630532pgb.0 for ; Sat, 12 Sep 2020 14:08:17 -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:mime-version :content-transfer-encoding; bh=hkdmHZJNcU+7N2ujCFsZPcv/unm2Wh+tx7Rkz6iTuF0=; b=n+aUgG/RdRP686huE3p5uz0c0aoEJ5mJl26a3jq1Q33zTy4H3FB4bwCKZF5u6wdJgO zz7he6IVgc5ADax0REzyDDWXGHQF2QSqLHbsS/vPCNZ+dpOV+5WeTNMXJbt0lS0nWWgE NCFVo40UENKFCM99tOaWb/pynEAIUh28jH3kU= 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 :content-transfer-encoding; bh=hkdmHZJNcU+7N2ujCFsZPcv/unm2Wh+tx7Rkz6iTuF0=; b=sW6rOQ3Wr93kHs74wo5is4mg84TccKA4PhXlg282S8av27mTO/9c3x4PV8M2ozzQ04 7lZmMzQ4eQHx0eoW4SYnwR1LeKpVTfrraZn+z9S14j4zUtUG1D3UFsCtBZgOFreX8ulQ jjLe/op1tUW55nI5+WUiRa1iqCqor9pIvzlYemi7zL5RW742ebIn7hw/1nGdZDIFi5LC /xCBqCnWxzJtPiv4lsXOhEaLgawMrQMxPD7M+8o25wBFLL98ZOq0kki/Q+8CFL9HU3V0 Ni+dAbYYNKKr0auYbzaKB1irrfwMfhMa3d6hHgHTFYKYKpdBbyGPz27PK7EKkEvZf8sm D2vA== X-Gm-Message-State: AOAM530jquD1LtFZ/1K4L7+ugSJTc1zSJhfmLvxZrdPhY92nKMluMbW+ qwVbKK4pR7ELQxIlpapOozJBp9coguT+pQ== X-Google-Smtp-Source: ABdhPJz22rwSO4QjmaRCwJE0H6ZOVP9TpnHWSmb2igzOtjxEis+mUFk/egFXQj1mz3ang7qDeLgZ7g== X-Received: by 2002:a63:29c7:: with SMTP id p190mr5938653pgp.292.1599944897297; Sat, 12 Sep 2020 14:08:17 -0700 (PDT) Received: from tictac2.mtv.corp.google.com ([2620:15c:202:1:42b0:34ff:fe3d:58e6]) by smtp.gmail.com with ESMTPSA id e10sm3369020pgb.45.2020.09.12.14.08.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 12 Sep 2020 14:08:16 -0700 (PDT) From: Douglas Anderson To: Mark Brown Cc: Akash Asthana , swboyd@chromium.org, Douglas Anderson , Andy Gross , Bjorn Andersson , linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-spi@vger.kernel.org Subject: [PATCH 1/3] spi: spi-geni-qcom: Use the FIFO even more Date: Sat, 12 Sep 2020 14:07:59 -0700 Message-Id: <20200912140730.1.Ie67fa32009b94702d56232c064f1d89065ee8836@changeid> X-Mailer: git-send-email 2.28.0.618.gf4bc123cb7-goog MIME-Version: 1.0 Sender: linux-spi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org In commit 902481a78ee4 ("spi: spi-geni-qcom: Actually use our FIFO") I explained that the maximum size we could program the FIFO was "mas->tx_fifo_depth - 3" but that I chose "mas->tx_fifo_depth()" because I was worried about decreased bandwidth. Since that time: * All the interconnect patches have landed, making things run at the proper speed. * I've done more measurements. This lets me confirm that there's really no downside of using the FIFO more. Specifically I did "flashrom -p ec -r /tmp/foo.bin" on a Chromebook and averaged over several runs. Before: It took 6.66 seconds and 59669 interrupts fired. After: It took 6.66 seconds and 47992 interrupts fired. Signed-off-by: Douglas Anderson Reviewed-by: Bjorn Andersson Reviewed-by: Akash Asthana --- drivers/spi/spi-geni-qcom.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/spi/spi-geni-qcom.c b/drivers/spi/spi-geni-qcom.c index 0dc3f4c55b0b..7f0bf0dec466 100644 --- a/drivers/spi/spi-geni-qcom.c +++ b/drivers/spi/spi-geni-qcom.c @@ -308,7 +308,7 @@ static int spi_geni_init(struct spi_geni_master *mas) * Hardware programming guide suggests to configure * RX FIFO RFR level to fifo_depth-2. */ - geni_se_init(se, mas->tx_fifo_depth / 2, mas->tx_fifo_depth - 2); + geni_se_init(se, mas->tx_fifo_depth - 3, mas->tx_fifo_depth - 2); /* Transmit an entire FIFO worth of data per IRQ */ mas->tx_wm = 1; ver = geni_se_get_qup_hw_version(se); From patchwork Sat Sep 12 21:08:00 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 11772053 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8C9F059D for ; Sat, 12 Sep 2020 21:08:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 718A521775 for ; Sat, 12 Sep 2020 21:08:31 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="H7l8JzFp" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725934AbgILVIZ (ORCPT ); Sat, 12 Sep 2020 17:08:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53688 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725919AbgILVIT (ORCPT ); Sat, 12 Sep 2020 17:08:19 -0400 Received: from mail-pf1-x444.google.com (mail-pf1-x444.google.com [IPv6:2607:f8b0:4864:20::444]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AB212C061795 for ; Sat, 12 Sep 2020 14:08:18 -0700 (PDT) Received: by mail-pf1-x444.google.com with SMTP id b124so9574923pfg.13 for ; Sat, 12 Sep 2020 14:08:18 -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=nT97JuHeIYEYuVntShwpzBJaTAHIXhzgnidrheouJoQ=; b=H7l8JzFpvQ98TLFd8MPo4am/gruKkYODBqBTRy+4TWWz1HuEQ64Y/vb/Of/CJoeV5g /4BtxCx2BpegSKNkdkI6DUiM+tG4vNjzxEod4JGU/TQZm9bBnda8PRUS8JNgor6Yxlxw zvnsl+nxifZtZRCk5kypYL8Cs0T9Xlw0LtuqI= 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=nT97JuHeIYEYuVntShwpzBJaTAHIXhzgnidrheouJoQ=; b=WmXaMuPIbi20T8QJ/qR7SN29Bu7rm8XthZJFc8pflYFQoi8x28ClKATcxjGO2sPL7Q T2XUI4MpIBomJwD4+Tg20FaE2odr9vjIKedUeZde5Hm/JXsRfjm6ySUSVkEYdzkuTzzo PMC09Inyt5SF5TF7P+FIFnVqviir/V95zKhnnglBkMV4xtrbLsfyfk0J30WgP5q6oSql 3mArus/mh227i+mdEFBOguRGnJTp9sn2ldmGnrVZGX7bIz6srlWKnF7oPvHtDzvyaHcX 5mv7kIwRJ7eF/5Tmk4sRQ+Y9MpwSqugG7iOMf4I2WOTyBEY4uOMDugjalKU1yE/NNXRb ahuw== X-Gm-Message-State: AOAM532Yxl6DbgzhnyHtLHFC3Gy4nmpDfibWJztZvH56CDZ87R05jxf/ hiQ+2mUd8OelqmLMpf26MvcpHg== X-Google-Smtp-Source: ABdhPJzxE9TcIeDb6yHHRDq49CWtiiptA89EirhaSk6k7v+xw7TfDzUfpYKHZwjkx+Pxbz/o8kG2oQ== X-Received: by 2002:a62:bd0d:: with SMTP id a13mr7570502pff.39.1599944898254; Sat, 12 Sep 2020 14:08:18 -0700 (PDT) Received: from tictac2.mtv.corp.google.com ([2620:15c:202:1:42b0:34ff:fe3d:58e6]) by smtp.gmail.com with ESMTPSA id e10sm3369020pgb.45.2020.09.12.14.08.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 12 Sep 2020 14:08:17 -0700 (PDT) From: Douglas Anderson To: Mark Brown Cc: Akash Asthana , swboyd@chromium.org, Douglas Anderson , Andy Gross , Bjorn Andersson , linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-spi@vger.kernel.org Subject: [PATCH 2/3] spi: spi-geni-qcom: Don't program CS_TOGGLE again and again Date: Sat, 12 Sep 2020 14:08:00 -0700 Message-Id: <20200912140730.2.I33e571179986850b4ec17042e813d0b08fb1b9c1@changeid> X-Mailer: git-send-email 2.28.0.618.gf4bc123cb7-goog In-Reply-To: <20200912140730.1.Ie67fa32009b94702d56232c064f1d89065ee8836@changeid> References: <20200912140730.1.Ie67fa32009b94702d56232c064f1d89065ee8836@changeid> MIME-Version: 1.0 Sender: linux-spi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org We always toggle the chip select manually in spi-geni-qcom so that we can properly implement the Linux API. There's no reason to program this to the hardware on every transfer. Program it once at init and be done with it. This saves some part of a microsecond of overhead on each transfer. While not really noticeable on any real world benchmarks, we might as well save the time. Signed-off-by: Douglas Anderson Reviewed-by: Bjorn Andersson Reviewed-by: Akash Asthana --- drivers/spi/spi-geni-qcom.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/drivers/spi/spi-geni-qcom.c b/drivers/spi/spi-geni-qcom.c index 7f0bf0dec466..92d88bf85a90 100644 --- a/drivers/spi/spi-geni-qcom.c +++ b/drivers/spi/spi-geni-qcom.c @@ -290,6 +290,7 @@ static int spi_geni_init(struct spi_geni_master *mas) { struct geni_se *se = &mas->se; unsigned int proto, major, minor, ver; + u32 spi_tx_cfg; pm_runtime_get_sync(mas->dev); @@ -322,6 +323,11 @@ static int spi_geni_init(struct spi_geni_master *mas) geni_se_select_mode(se, GENI_SE_FIFO); + /* We always control CS manually */ + spi_tx_cfg = readl(se->base + SE_SPI_TRANS_CFG); + spi_tx_cfg &= ~CS_TOGGLE; + writel(spi_tx_cfg, se->base + SE_SPI_TRANS_CFG); + pm_runtime_put(mas->dev); return 0; } @@ -331,7 +337,7 @@ static void setup_fifo_xfer(struct spi_transfer *xfer, u16 mode, struct spi_master *spi) { u32 m_cmd = 0; - u32 spi_tx_cfg, len; + u32 len; struct geni_se *se = &mas->se; int ret; @@ -350,7 +356,6 @@ static void setup_fifo_xfer(struct spi_transfer *xfer, spin_lock_irq(&mas->lock); spin_unlock_irq(&mas->lock); - spi_tx_cfg = readl(se->base + SE_SPI_TRANS_CFG); if (xfer->bits_per_word != mas->cur_bits_per_word) { spi_setup_word_len(mas, mode, xfer->bits_per_word); mas->cur_bits_per_word = xfer->bits_per_word; @@ -364,8 +369,6 @@ static void setup_fifo_xfer(struct spi_transfer *xfer, mas->tx_rem_bytes = 0; mas->rx_rem_bytes = 0; - spi_tx_cfg &= ~CS_TOGGLE; - if (!(mas->cur_bits_per_word % MIN_WORD_LEN)) len = xfer->len * BITS_PER_BYTE / mas->cur_bits_per_word; else @@ -384,7 +387,6 @@ static void setup_fifo_xfer(struct spi_transfer *xfer, writel(len, se->base + SE_SPI_RX_TRANS_LEN); mas->rx_rem_bytes = xfer->len; } - writel(spi_tx_cfg, se->base + SE_SPI_TRANS_CFG); /* * Lock around right before we start the transfer since our From patchwork Sat Sep 12 21:08:01 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 11772075 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A607759D for ; Sat, 12 Sep 2020 21:08:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8A5F42151B for ; Sat, 12 Sep 2020 21:08:51 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="HY13hSv3" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725952AbgILVIq (ORCPT ); Sat, 12 Sep 2020 17:08:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53694 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725925AbgILVIU (ORCPT ); Sat, 12 Sep 2020 17:08:20 -0400 Received: from mail-pg1-x542.google.com (mail-pg1-x542.google.com [IPv6:2607:f8b0:4864:20::542]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C866BC061757 for ; Sat, 12 Sep 2020 14:08:19 -0700 (PDT) Received: by mail-pg1-x542.google.com with SMTP id 34so8675037pgo.13 for ; Sat, 12 Sep 2020 14:08:19 -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=lNyBzqYxhNLfRyzcGYVhpsNYZE01k6vdArIGmMCZyP4=; b=HY13hSv3vsmDbVwvsXcGM1uwa9ssg1EaF0jrXqrOxFlN9zlWG928ZYfHs81NzfcTzB M2M6AgkZ5clA0Vw+h0s8afCY+On1qQfAcpHnOOz/Kj7rY+9H3WBU996zkr9qy9t/T3T2 Sb146Z4Fh3WT70BYQuGvrkIzyVAd7UGgJ4rfg= 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=lNyBzqYxhNLfRyzcGYVhpsNYZE01k6vdArIGmMCZyP4=; b=rg7EXyOt+wRpG66fC+TqzMJvOQNtRsjOKhmYGmpLT3oXTCGzG1UDaJ5/gYyiep/+os MQ56TZmow7GGvqBPD0s50DbS5RUT9rzKoVFNcD/TIGG2QPOdp1wqmGEFiTqji952Uw0s SHbVgwnoO1/SBEQ9JVTZzpMu0L1ZUUG8CFA3l5xg8AmI8Lisq8v/aqo65D5FBTqoRvgJ unxz1XdndjA/ko3xZIZV4SgkZm/WRv1Dy4VQ3Zlgn6ipALnmJmsk4hWuRChZKVkM1Kt0 h0IqBpH9GkWpsxblsbUKpB/JSwHlGv8M7jDOADKh9rt/mgZg2tz7vckPHEqCmoDe8+86 +ncw== X-Gm-Message-State: AOAM531FlKyJdARqLbZR0NHrh5llFvoWvzaT/hJFbg9gd2jF1J3gnnw5 9XImRHIGeDzT6pfUYGTfwe+rEA== X-Google-Smtp-Source: ABdhPJw7Hcc5QSI5JuRjeZo+HyHcn5RCuI7pIwHNcKnmRxgH6mJMLxHWdY8tE5JD+7KF58ozETdhvA== X-Received: by 2002:a63:4418:: with SMTP id r24mr5829295pga.8.1599944899358; Sat, 12 Sep 2020 14:08:19 -0700 (PDT) Received: from tictac2.mtv.corp.google.com ([2620:15c:202:1:42b0:34ff:fe3d:58e6]) by smtp.gmail.com with ESMTPSA id e10sm3369020pgb.45.2020.09.12.14.08.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 12 Sep 2020 14:08:18 -0700 (PDT) From: Douglas Anderson To: Mark Brown Cc: Akash Asthana , swboyd@chromium.org, Douglas Anderson , Andy Gross , Bjorn Andersson , linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-spi@vger.kernel.org Subject: [PATCH 3/3] spi: spi-geni-qcom: Slightly optimize setup of bidirectional xfters Date: Sat, 12 Sep 2020 14:08:01 -0700 Message-Id: <20200912140730.3.Ided778fb4cd078e36c6b240d1b279cd7a534a313@changeid> X-Mailer: git-send-email 2.28.0.618.gf4bc123cb7-goog In-Reply-To: <20200912140730.1.Ie67fa32009b94702d56232c064f1d89065ee8836@changeid> References: <20200912140730.1.Ie67fa32009b94702d56232c064f1d89065ee8836@changeid> MIME-Version: 1.0 Sender: linux-spi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org When setting up a bidirectional transfer we need to program both the TX and RX lengths. We don't need a memory barrier between those two writes. Factor out the __iowmb() and use writel_relaxed(). This saves a fraction of a microsecond of setup overhead on bidirectional transfers. Signed-off-by: Douglas Anderson Reviewed-by: Bjorn Andersson Reported-by: kernel test robot Reported-by: kernel test robot --- drivers/spi/spi-geni-qcom.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/drivers/spi/spi-geni-qcom.c b/drivers/spi/spi-geni-qcom.c index 92d88bf85a90..6c7e12b68bf0 100644 --- a/drivers/spi/spi-geni-qcom.c +++ b/drivers/spi/spi-geni-qcom.c @@ -376,15 +376,22 @@ static void setup_fifo_xfer(struct spi_transfer *xfer, len &= TRANS_LEN_MSK; mas->cur_xfer = xfer; + + /* + * Factor out the __iowmb() so that we can use writel_relaxed() for + * both writes below and thus only incur the overhead once even if + * we execute both of them. + */ + __iowmb(); + if (xfer->tx_buf) { m_cmd |= SPI_TX_ONLY; mas->tx_rem_bytes = xfer->len; - writel(len, se->base + SE_SPI_TX_TRANS_LEN); + writel_relaxed(len, se->base + SE_SPI_TX_TRANS_LEN); } - if (xfer->rx_buf) { m_cmd |= SPI_RX_ONLY; - writel(len, se->base + SE_SPI_RX_TRANS_LEN); + writel_relaxed(len, se->base + SE_SPI_RX_TRANS_LEN); mas->rx_rem_bytes = xfer->len; }