From patchwork Tue Apr 18 05:28:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joy Chakraborty X-Patchwork-Id: 84575 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2597382vqo; Mon, 17 Apr 2023 22:30:59 -0700 (PDT) X-Google-Smtp-Source: AKy350aca94BxWpy0IaqmkYAsSl7r8j7OY+Lf3HQFI508VocceQUZh/qJdgek777jUEC9FE8yF18 X-Received: by 2002:a05:6a20:6a0c:b0:ee:f25e:925f with SMTP id p12-20020a056a206a0c00b000eef25e925fmr12401849pzk.53.1681795859003; Mon, 17 Apr 2023 22:30:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681795858; cv=none; d=google.com; s=arc-20160816; b=LKmOTPsJ2CDz/yfvIzfU5H0dfPWEeNqK1I6dtOidP1EpXKGZoKBJPGIXKVQA2I1rP6 A+LTmfkGO1acNmKSf1YTiyMXqujymQCQBuXRS0ecZs0hWYgY9W+/YRjs2ttYjpaL/SSH rWfv72lFV+cFUM1/FM0rLyHPjZpxPw23QjVTueQQw3lKqcoDWFVHlD65lpyceKh6ks/1 G1pDstmwbG5FGF8tk2+Auxw12J5/HKm0uFs1QZpOoMXMLAekSRgb7DPCKooafX8FcGPs gnT/8XFg0l5Izv+4djpLzZrnTpe0h4o7e/yWXIrFieZ5R9PmkozU/JO8X44d4+Z7tsHq uCfw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:dkim-signature; bh=nKDaeGp5EKkZDqIsokus1OmDmfvkWgZNrRNY08uRrUc=; b=q+lIdgxcE+qEo+P1VZ0R0Ps+ZDzFlv/03hCfUtS/6rzEd5V5BnIsMdezsZlK+z1CcR ngATpXBZMQiX+nXLsYq4SGS41jstB+eOurpQ5jDma4JgeCPsxDOY9E8E9wNUZlIqQ+Er z/ZIRyvbsDlLypQ31hoKd7Vfk74XNwAbwcZE6YGejKv7knbmgywo5dh7i3DLbDaUBGxm IcK+5U71a713VjfKgWpQBn0MS4xoqJw9pHjJbwrxKM2jCtEiCr4Vdi+UJIRoxbKdRo54 usOScAxGn8o9BwM84yEIo4Ye2k7N8WtVdkLAk4334XkTkoiqy5J43aG0hYzPPg1prmb2 6g2A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=FYeN9SBM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l12-20020a654c4c000000b00514477c4416si13399942pgr.801.2023.04.17.22.30.44; Mon, 17 Apr 2023 22:30:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=FYeN9SBM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230349AbjDRF3V (ORCPT + 99 others); Tue, 18 Apr 2023 01:29:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59320 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229714AbjDRF3O (ORCPT ); Tue, 18 Apr 2023 01:29:14 -0400 Received: from mail-yw1-x114a.google.com (mail-yw1-x114a.google.com [IPv6:2607:f8b0:4864:20::114a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 70B0E5245 for ; Mon, 17 Apr 2023 22:29:13 -0700 (PDT) Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-552f169d85eso27237227b3.13 for ; Mon, 17 Apr 2023 22:29:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1681795752; x=1684387752; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=nKDaeGp5EKkZDqIsokus1OmDmfvkWgZNrRNY08uRrUc=; b=FYeN9SBMek5PY0NUGiKB4PDLSCJlT+j7HehxrNt6HMPnXxkb2hDFelKYyUgKjiziLJ tVL1u6x5vxXSoC1takibB3sIH8S5a4H/zcAlUkmwd/KdiZUbajfB7BLtA9HeauREN51e nXpSIgJ6Rhyfs8s9UE+1sdCU+RjVrt24eppqDajoloeN9DjHFI1gZzPGdoKCX21oevkM 7BV4SlPWznZ6RPNiZJQNSzTfqp5FCxtuyrMusF6mbwi3CATBxDGXZAtz2m1Bj2gtnO1D rn6UAwLmvLFoSrIo1NjxrVFRxc7oNUiE8XEtQ3ICRudfANtgmGOv/eB+zA6LPING2H7J jDGA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681795752; x=1684387752; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=nKDaeGp5EKkZDqIsokus1OmDmfvkWgZNrRNY08uRrUc=; b=dALqd+OYa5KhdCJ4l9bO8MFBfL4Rf2Huoh7cbITabWYfnWc46hsGTWpNlLZnGCZXai bh46ajGmebyD6tJNUwFdzwZfhxH7gyTPZP60czBs3zyjL6Ggcp5Okw0lCZ4GHRweA4Rw QvwmMQlJyig5QfWXgloU5lC2thU29DXNqQmSqHbRYx2Oub9NmIh0iuJwc04DbAKw8fI0 dlb2v0CixSHjcDjz5qxb5KfetRF9XEhtVQqw6PqGonLcW74PU/eZ8whjqu4Iq399k0fM iqqQ1jp/bonBjj3fSu8UOXMICVrUHS/Mh9O6rrPpDpq9+0HuxQTi4dM3ABpO7iMpBOrA yNxw== X-Gm-Message-State: AAQBX9ezczfHePAA/98mZ0nOwtMuE72y5ooqaJhU+uhQRuMOy5eHhni4 RzLME+OQv3te4hCiqWtm2MkT0iTU7/L26g== X-Received: from joychakr.c.googlers.com ([fda3:e722:ac3:cc00:4f:4b78:c0a8:6ea]) (user=joychakr job=sendgmr) by 2002:a81:ac57:0:b0:54d:3afc:d503 with SMTP id z23-20020a81ac57000000b0054d3afcd503mr11607964ywj.8.1681795752753; Mon, 17 Apr 2023 22:29:12 -0700 (PDT) Date: Tue, 18 Apr 2023 05:28:58 +0000 In-Reply-To: <20230418052902.1336866-1-joychakr@google.com> Mime-Version: 1.0 References: <20230418052902.1336866-1-joychakr@google.com> X-Mailer: git-send-email 2.40.0.634.g4ca3ef3211-goog Message-ID: <20230418052902.1336866-2-joychakr@google.com> Subject: [PATCH v7 1/5] spi: dw: Add 32 bpw support to SPI DW DMA driver From: Joy Chakraborty To: Serge Semin , Mark Brown , Andy Shevchenko Cc: linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org, manugautam@google.com, rohitner@google.com, Joy Chakraborty X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1763490774598486342?= X-GMAIL-MSGID: =?utf-8?q?1763490774598486342?= Add Support for AxSize = 4 bytes configuration from dw dma driver if n_bytes i.e. number of bytes per write to fifo is 4. Number of bytes written to fifo per write is depended on the bits/word configuration being used which the DW core driver translates to n_bytes. Hence, for bits per word values between 17 and 32 n_bytes should be equal to 4. Signed-off-by: Joy Chakraborty --- drivers/spi/spi-dw-dma.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/drivers/spi/spi-dw-dma.c b/drivers/spi/spi-dw-dma.c index ababb910b391..c1b42cb59965 100644 --- a/drivers/spi/spi-dw-dma.c +++ b/drivers/spi/spi-dw-dma.c @@ -208,12 +208,16 @@ static bool dw_spi_can_dma(struct spi_controller *master, static enum dma_slave_buswidth dw_spi_dma_convert_width(u8 n_bytes) { - if (n_bytes == 1) + switch (n_bytes) { + case 1: return DMA_SLAVE_BUSWIDTH_1_BYTE; - else if (n_bytes == 2) + case 2: return DMA_SLAVE_BUSWIDTH_2_BYTES; - - return DMA_SLAVE_BUSWIDTH_UNDEFINED; + case 4: + return DMA_SLAVE_BUSWIDTH_4_BYTES; + default: + return DMA_SLAVE_BUSWIDTH_UNDEFINED; + } } static int dw_spi_dma_wait(struct dw_spi *dws, unsigned int len, u32 speed) From patchwork Tue Apr 18 05:28:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joy Chakraborty X-Patchwork-Id: 84580 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2599729vqo; Mon, 17 Apr 2023 22:36:29 -0700 (PDT) X-Google-Smtp-Source: AKy350agVlYwl+zFaMS4zVkESAX+c1WxTrMET4c+z7PjuN15NkEBj/oF1WK2OmAhDYCi4Xw5FXCF X-Received: by 2002:a05:6a00:148c:b0:63b:89a2:d624 with SMTP id v12-20020a056a00148c00b0063b89a2d624mr11254852pfu.12.1681796189397; Mon, 17 Apr 2023 22:36:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681796189; cv=none; d=google.com; s=arc-20160816; b=fitSbEs9jPnFYG8ma4GqQvXbxt9ZOTotWMyBgaa6MD+1S5aiy9nnI/2qt/wqJuc1L4 8/cBmPB1hE6cRQc9haN/ylbB6jg4THYjBWE4e2fGqOIW5hLVuvkx8vvoY3pMptWZo9fl i75LH8jlHgQ9LlHoPJ90fiNQshFgW3LzepJPcvzZKqJEsCVIIXRq7hkDPFLtyyRgCu18 +3VbwDXX+QIfCTo6y4r9gMJ1K7mAxUTzAXRTM8CrKRY8q6ljebT3BZjgJNu3HIj6Xarw 4gS+BSKvbSE2fBYD230aA82t5rmsX2DwuQaSBsRdrDyjKq+696CC8ZJajJmfXodtUFbK WlRg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:dkim-signature; bh=8xCBVt+yTzL9gm6ligFFQCFbRni90/tGiHt7eRsjBtY=; b=SqB8sZC5StSDSgLp0SL0LoYJknUL3Ih+6KZ3y27oICfOsAc2vauSGQKj8Tkw9mOXZL vzcXRBMxFG/p9pXCbhg/O12ClYZaHHt4NyBEieewoZ1j8dB4uQagYBqQgt+EwkRE1vU/ +LGdTTIir0sWQtBQskHgl2pgDcbs25BUTMwukZMVMOt6CH3OXyBYP3ZwXV0L8DhdMHFh hRyEMS4dxMdNxlOT0ONmUNkSiONYpFNSpXDpEakXwcdZ419YLRGYB/fBQUF0MM8BL3qB 8INHc4ao8mKL9WjZ18CXNDWW+8nBxuMzWN4H/VKn9G7kp/6CAESbBk9cY36FTjQDoRXM j/BQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=6XqlMtOx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g5-20020a625205000000b0063b72bd28absi9639092pfb.135.2023.04.17.22.36.14; Mon, 17 Apr 2023 22:36:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=6XqlMtOx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230337AbjDRF3Y (ORCPT + 99 others); Tue, 18 Apr 2023 01:29:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59382 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230298AbjDRF3U (ORCPT ); Tue, 18 Apr 2023 01:29:20 -0400 Received: from mail-yw1-x1149.google.com (mail-yw1-x1149.google.com [IPv6:2607:f8b0:4864:20::1149]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C353159FE for ; Mon, 17 Apr 2023 22:29:17 -0700 (PDT) Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-54f8d4f1ca1so159228537b3.20 for ; Mon, 17 Apr 2023 22:29:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1681795757; x=1684387757; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=8xCBVt+yTzL9gm6ligFFQCFbRni90/tGiHt7eRsjBtY=; b=6XqlMtOxsqrT/1r2wZChHQ9ZpRkAmrUq+OgSX89spFBhvd/cSZJLUdWgaOp8WIePRa PSSby6xBdcgXm6GSBJtUxdkkVhgbn76OAIzMm/qb3Jd3d3cOI/DxQZSDVfK1Gyavudy/ gqGBDA5QaQlZ1Vag2qsySvdPZlBZncqqptuZ3ZzRaiuuiXqI4vaA20IgbcB3lKGE8YfK IWIj5XP+2e2gi0GQshi/crBqMcV5H1AueWiSPrem+/BxIPu7Wrn2sn6kXDbbyHttpmfW 1NpPO6KsFIIaezfKaU82RfGgYofxQzOg3y5qII5BkT2eSoKsN3e77Y/Fesk/40vFvwX4 PwhQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681795757; x=1684387757; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=8xCBVt+yTzL9gm6ligFFQCFbRni90/tGiHt7eRsjBtY=; b=MUXVda2Ep5z9XG95kMb793gu3aKQLKe3hy4qoZgtdINXsiBcAQa9ZhsChF7waDwVud 8yt7pKg33tc6KHr0y1Jf3yBiztne4nBj7kq5XbYnh8D2GpBMBdgvNeEmp0KTAfhEiMNX cryTXGUhVFT+rVhmLYlr7HFnq6WcTcUJejKoeLPXTatLIvi3NRFATo7M1bycRXIiXgvO 94HALt8Tbfx0pvb1bYG9+tC1Cs8MsTrDrIejoAOgTjUc1ujVj8Zgs+hQqTU7Jk9ynpKu exlK/0IB+zbkPY3oeZGWyGsfNTds9v6y8SSrPX6aZv6DFXnT1l6ILJc/JJIx2lVkmjk9 I9LQ== X-Gm-Message-State: AAQBX9eghqB05ZziVMVm38YcDKrGkSURUnnm6zzed+Hvzg6E2UEXChAk sBrtRTCcPS+7PCoime7wHS35Bm58xqbxDg== X-Received: from joychakr.c.googlers.com ([fda3:e722:ac3:cc00:4f:4b78:c0a8:6ea]) (user=joychakr job=sendgmr) by 2002:a05:690c:706:b0:545:5f92:f7ee with SMTP id bs6-20020a05690c070600b005455f92f7eemr11663447ywb.2.1681795757018; Mon, 17 Apr 2023 22:29:17 -0700 (PDT) Date: Tue, 18 Apr 2023 05:28:59 +0000 In-Reply-To: <20230418052902.1336866-1-joychakr@google.com> Mime-Version: 1.0 References: <20230418052902.1336866-1-joychakr@google.com> X-Mailer: git-send-email 2.40.0.634.g4ca3ef3211-goog Message-ID: <20230418052902.1336866-3-joychakr@google.com> Subject: [PATCH v7 2/5] spi: dw: Move dw_spi_can_dma() From: Joy Chakraborty To: Serge Semin , Mark Brown , Andy Shevchenko Cc: linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org, manugautam@google.com, rohitner@google.com, Joy Chakraborty X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1763491121263728300?= X-GMAIL-MSGID: =?utf-8?q?1763491121263728300?= Move dw_spi_can_dma() implementation below dw_spi_dma_convert_width() for handing compile dependency in future patches. Signed-off-by: Joy Chakraborty --- drivers/spi/spi-dw-dma.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/spi/spi-dw-dma.c b/drivers/spi/spi-dw-dma.c index c1b42cb59965..f19c092920a1 100644 --- a/drivers/spi/spi-dw-dma.c +++ b/drivers/spi/spi-dw-dma.c @@ -198,14 +198,6 @@ static irqreturn_t dw_spi_dma_transfer_handler(struct dw_spi *dws) return IRQ_HANDLED; } -static bool dw_spi_can_dma(struct spi_controller *master, - struct spi_device *spi, struct spi_transfer *xfer) -{ - struct dw_spi *dws = spi_controller_get_devdata(master); - - return xfer->len > dws->fifo_len; -} - static enum dma_slave_buswidth dw_spi_dma_convert_width(u8 n_bytes) { switch (n_bytes) { @@ -220,6 +212,14 @@ static enum dma_slave_buswidth dw_spi_dma_convert_width(u8 n_bytes) } } +static bool dw_spi_can_dma(struct spi_controller *master, + struct spi_device *spi, struct spi_transfer *xfer) +{ + struct dw_spi *dws = spi_controller_get_devdata(master); + + return xfer->len > dws->fifo_len; +} + static int dw_spi_dma_wait(struct dw_spi *dws, unsigned int len, u32 speed) { unsigned long long ms; From patchwork Tue Apr 18 05:29:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joy Chakraborty X-Patchwork-Id: 84576 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2597627vqo; Mon, 17 Apr 2023 22:31:30 -0700 (PDT) X-Google-Smtp-Source: AKy350a1OcSKydiOhpg73esR5y+u9t70q9IUG+iHpCgWmvzPYanZATzFuK4+EorB6yXJTWaYa+/p X-Received: by 2002:a05:6a20:6a0d:b0:ec:628d:582 with SMTP id p13-20020a056a206a0d00b000ec628d0582mr22908186pzk.21.1681795890489; Mon, 17 Apr 2023 22:31:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681795890; cv=none; d=google.com; s=arc-20160816; b=qFiaUTyNIm+xMap4r4taLxRpA3QkRvnXmSGbirUMSUPIbn+9ZR6vGNwC1TpE7J4oop 6iBvWWZvt+Fku8HNgRJJhn/v4ROQN3XsKyHKFZFJXEK1vTSfVq8eh6KBHJAdWiy1EMKQ TMrMlXpsemSB0IEJgbfnYi8aboVPeCxjQX1mdm3Nk5ESDvR9T5NshTnfCbIlGcx6ik4T KgYKreB+L6E0MryxpIhzM9A+8ZM2SnkMnhparLcUdBiOZQmPpNRoxAF03lTl9nXkWda8 h836YBZOZSs0oa8bC3slm5o8w6MqYXiZVNgnpDTgvGwC9dy0GfPaA3LKEiU/VbsP3V6b bpRg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:dkim-signature; bh=Suw/5ECmRYhQu6IA1gmyYkwu6OL87LNt9wtEORwfKxU=; b=E0frM6EbZaq1PvFApYjo7VwewTPodUPaoHjvMn1m1J9Z9birRcKoCgpSYMbAcHrm85 ViOUk6r2H+01iMIoT3+GOAlz+T6iYzTSVep2DPpZZZPo5b+aiPdWC+BayjdlJ1ulK83f x6887KZqngwzaqWEittcp1N3kNeo4r7JRRQYT8kKEMQfpfCgP3z2Gm/t9b4NVYeRK90Q SZfEhGAC5YV22qPVdEC3tM2OlwJtrkbpe4KM06UvmhNX2nDYA4weoz/c3NQA0agewvOH pWSu2ZL1gG15VepujP+ulVatVXwO0/iFXnHdiLNYJ8lLEGUVpjXwA55YTDdA/4DDEwYE wzPA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=Evar251c; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s185-20020a632cc2000000b0051aeaf666dfsi13613133pgs.668.2023.04.17.22.31.18; Mon, 17 Apr 2023 22:31:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=Evar251c; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230336AbjDRF3e (ORCPT + 99 others); Tue, 18 Apr 2023 01:29:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59502 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230298AbjDRF30 (ORCPT ); Tue, 18 Apr 2023 01:29:26 -0400 Received: from mail-yb1-xb49.google.com (mail-yb1-xb49.google.com [IPv6:2607:f8b0:4864:20::b49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9E43A59FE for ; Mon, 17 Apr 2023 22:29:22 -0700 (PDT) Received: by mail-yb1-xb49.google.com with SMTP id 62-20020a250341000000b00b9505f220d4so1217745ybd.20 for ; Mon, 17 Apr 2023 22:29:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1681795762; x=1684387762; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=Suw/5ECmRYhQu6IA1gmyYkwu6OL87LNt9wtEORwfKxU=; b=Evar251cw7DqRlp2ye27lHI+fpqOTsgpuJ5EmMqcMu6vFnAQvjd8vRQPafVAuV+pUU J2gDRGws2FhQtxwmAVgYn/+yz1oYsqfNDJkIvo8HwMnXZb/FI9EHTNAaWP8Z8/rQtuOk lfNDeAL1EX8aW9Q2we5U0Xq6YapVOgmzdX+K9NyirqsdwN3Lk6JCcx+XZdS8sFZwOs11 HVjrLfYUJxIi8RF4yEGYVZtdXt2oOFdFfzSPudGkt0cd/XJeymVQv87HCSQpMfIOlU3q DPXh2lQc59Pukf8ZWzFSKjV9pwyTrVRGas2/uFK2oPt1c2M9dAxBiBiTJcOmj4CGViVX AVUw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681795762; x=1684387762; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Suw/5ECmRYhQu6IA1gmyYkwu6OL87LNt9wtEORwfKxU=; b=PvyGTjC6RIXiABGuiZwxkdYZkAJ7+4OWbAPOBxDexP5qejSN8W1qV153HRQndufyVn zq4BhgB1Jva8N5/ZEi2BOyO6UFgZk2iVczr2WZoYMWJ4fX2Kxnip0yZsy1/0L7gPmd07 sjtSGhqjukeq6PSToc60mrLrJ/uvJLMmuJogXZVpET1D05moDzDjCnLTrVznBkWD4PNN XgXBYeRdlPJs8OVcNu4gEMRYsQF+0WRK8ItlDXv7Q01WwsJJ6ywQi2Qzf+bIrNoBcIgj uHd4Q1UJY7eyzCzHU/NHPgbyHI/ekSlZ7HJpXsfxBmni5/IQi6g+9IlVbuQbg5z6FK77 NH/A== X-Gm-Message-State: AAQBX9foR2jF5bg9GQOjoPdRviV7JlY9yHyOfpbEr0vigViS57sy02Dz hWh14bqFfTEWEGJF5/PVGf3Ci0mKDKwRCw== X-Received: from joychakr.c.googlers.com ([fda3:e722:ac3:cc00:4f:4b78:c0a8:6ea]) (user=joychakr job=sendgmr) by 2002:a81:4524:0:b0:54f:aa4b:100c with SMTP id s36-20020a814524000000b0054faa4b100cmr10637678ywa.8.1681795761848; Mon, 17 Apr 2023 22:29:21 -0700 (PDT) Date: Tue, 18 Apr 2023 05:29:00 +0000 In-Reply-To: <20230418052902.1336866-1-joychakr@google.com> Mime-Version: 1.0 References: <20230418052902.1336866-1-joychakr@google.com> X-Mailer: git-send-email 2.40.0.634.g4ca3ef3211-goog Message-ID: <20230418052902.1336866-4-joychakr@google.com> Subject: [PATCH v7 3/5] spi: dw: Add DMA directional capability check From: Joy Chakraborty To: Serge Semin , Mark Brown , Andy Shevchenko Cc: linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org, manugautam@google.com, rohitner@google.com, Joy Chakraborty X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1763490807761830067?= X-GMAIL-MSGID: =?utf-8?q?1763490807761830067?= Check capabilities of DMA controller during init to make sure it is capable of handling MEM2DEV for tx channel, DEV2MEM for rx channel. Current DW DMA driver requires both tx and rx channel to be configured and functional for any kind of transfers to take effect including half duplex. Hence, check for both tx and rx direction and fail on unavailbility of either. Signed-off-by: Joy Chakraborty --- drivers/spi/spi-dw-dma.c | 39 ++++++++++++++++++++++++++++++--------- 1 file changed, 30 insertions(+), 9 deletions(-) diff --git a/drivers/spi/spi-dw-dma.c b/drivers/spi/spi-dw-dma.c index f19c092920a1..22d0727a3789 100644 --- a/drivers/spi/spi-dw-dma.c +++ b/drivers/spi/spi-dw-dma.c @@ -72,12 +72,22 @@ static void dw_spi_dma_maxburst_init(struct dw_spi *dws) dw_writel(dws, DW_SPI_DMATDLR, dws->txburst); } -static void dw_spi_dma_sg_burst_init(struct dw_spi *dws) +static int dw_spi_dma_caps_init(struct dw_spi *dws) { - struct dma_slave_caps tx = {0}, rx = {0}; + struct dma_slave_caps tx, rx; + int ret; + + ret = dma_get_slave_caps(dws->txchan, &tx); + if (ret) + return ret; + + ret = dma_get_slave_caps(dws->rxchan, &rx); + if (ret) + return ret; - dma_get_slave_caps(dws->txchan, &tx); - dma_get_slave_caps(dws->rxchan, &rx); + if (!(tx.directions & BIT(DMA_MEM_TO_DEV) && + rx.directions & BIT(DMA_DEV_TO_MEM))) + return -ENXIO; if (tx.max_sg_burst > 0 && rx.max_sg_burst > 0) dws->dma_sg_burst = min(tx.max_sg_burst, rx.max_sg_burst); @@ -95,6 +105,7 @@ static int dw_spi_dma_init_mfld(struct device *dev, struct dw_spi *dws) struct dw_dma_slave dma_rx = { .src_id = 0 }, *rx = &dma_rx; struct pci_dev *dma_dev; dma_cap_mask_t mask; + int ret = -EBUSY; /* * Get pci device for DMA controller, currently it could only @@ -124,20 +135,25 @@ static int dw_spi_dma_init_mfld(struct device *dev, struct dw_spi *dws) init_completion(&dws->dma_completion); - dw_spi_dma_maxburst_init(dws); + ret = dw_spi_dma_caps_init(dws); + if (ret) + goto free_txchan; - dw_spi_dma_sg_burst_init(dws); + dw_spi_dma_maxburst_init(dws); pci_dev_put(dma_dev); return 0; +free_txchan: + dma_release_channel(dws->txchan); + dws->txchan = NULL; free_rxchan: dma_release_channel(dws->rxchan); dws->rxchan = NULL; err_exit: pci_dev_put(dma_dev); - return -EBUSY; + return ret; } static int dw_spi_dma_init_generic(struct device *dev, struct dw_spi *dws) @@ -163,12 +179,17 @@ static int dw_spi_dma_init_generic(struct device *dev, struct dw_spi *dws) init_completion(&dws->dma_completion); - dw_spi_dma_maxburst_init(dws); + ret = dw_spi_dma_caps_init(dws); + if (ret) + goto free_txchan; - dw_spi_dma_sg_burst_init(dws); + dw_spi_dma_maxburst_init(dws); return 0; +free_txchan: + dma_release_channel(dws->txchan); + dws->txchan = NULL; free_rxchan: dma_release_channel(dws->rxchan); dws->rxchan = NULL; From patchwork Tue Apr 18 05:29:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joy Chakraborty X-Patchwork-Id: 84578 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2598261vqo; Mon, 17 Apr 2023 22:33:01 -0700 (PDT) X-Google-Smtp-Source: AKy350YueqwnejUhNSx7FIbumw/p5JzBZIdDthHcSKfPxJitBJkQK9wxmDcl/lIfmNtBWrVNyy/D X-Received: by 2002:a05:6a20:12c6:b0:f0:154c:5104 with SMTP id v6-20020a056a2012c600b000f0154c5104mr4588628pzg.18.1681795981210; Mon, 17 Apr 2023 22:33:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681795981; cv=none; d=google.com; s=arc-20160816; b=zynXEIq8Sk60A3oFwHSLVzm2nixxA1l341zqf++nGUsAmTgXcAnCoh6mfcu+qovY3o TRKSy6X/pB6Eh3fQ/nKva3F2LUefXhga8TTEZL5u9ajxcECUde99paVIrtL1i7CPY9OC JHTCq+HP+/szE+uJaDpcgSeILawIHl68loQZ57Vmz2iJmrHQ5Cxg6FpoEhIzoYBsDXV1 D7HEF4rFk9zYppD/EunTDLyFfxo2wKpyhB/KTlnrm1042kj/yhnpWeZSaP0l1YnUIRzh tSJxyoROq6+TcMRalxx6HBeylzrCPrk9D6lA6/pRDz28SRnWyo0b9Xm8btrftQSQrVWr DamA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:dkim-signature; bh=ULD/pG+rE68BAxC1WDHgKiKZL8SDfWGnG2YjCeWvC3k=; b=yFuxGeG0nP+nIqNCygR67WbIz6gPsjHHzg4LxFnay+uZnAKyqh/4mntk+MCE2kXves qyntnrDDMAZ9v5wU9UcoZILGNsJ9xYowJ65UA/Rt6pWc0UopdqYrVDtYDJV3BOzBq69o LMFGjeknLI2wO3ehYr7e3voaIWhaezYl4FQJkD6z6N3f7AS+IObEawmlVEoOBYEUpRZa tbOoFFPE7MYphG7gCjegkxfNn1vJ+mw2hF6JPtTl+hFcH8HCrlqSKiU0d88eD/3le9fD Zqdc3rTdb5EY1khf0SPXQghM/6AItdH+/EJk6rk9yOChmn/kSaoFUKRA1wW4J46mBBCX 3uog== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=qwjLzEiu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k15-20020aa7972f000000b0063b734b856asi9168464pfg.61.2023.04.17.22.32.46; Mon, 17 Apr 2023 22:33:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=qwjLzEiu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230384AbjDRF3i (ORCPT + 99 others); Tue, 18 Apr 2023 01:29:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59454 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229662AbjDRF3c (ORCPT ); Tue, 18 Apr 2023 01:29:32 -0400 Received: from mail-yb1-xb49.google.com (mail-yb1-xb49.google.com [IPv6:2607:f8b0:4864:20::b49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 99321658C for ; Mon, 17 Apr 2023 22:29:27 -0700 (PDT) Received: by mail-yb1-xb49.google.com with SMTP id 8-20020a250f08000000b00b880000325bso1286731ybp.3 for ; Mon, 17 Apr 2023 22:29:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1681795766; x=1684387766; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=ULD/pG+rE68BAxC1WDHgKiKZL8SDfWGnG2YjCeWvC3k=; b=qwjLzEiux581S2bwXnijENgLs2i3vekPUCQxMzop5Vx0D89HCDCPGFyxAs2bVC5zK6 jZUx8em8Gl0+gyvoF1TWJqxt1mPYUOoO1z3B+XnY/vXbVEuq0m5wTSUJHI4yipjdpX1t t3yoTSirJxVGnzV+L0hOlNUCbBErO5LgN3RatdWdCHSHqmQgrtxUs7ml06v2YFRBytDe 7DtgyepGhLyY/Qc99jM1r5asfItKZ+1Ti+g7B3O1JUln4fDvjTNxNE6ePefnwQwNSjex qcNAJRM0ypXCInn8v1b9tFMflu2LbAhHn9kmCnEFg484BSiEitHf6CPsLcbOLchhp8SE JNyg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681795766; x=1684387766; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=ULD/pG+rE68BAxC1WDHgKiKZL8SDfWGnG2YjCeWvC3k=; b=ln90ntjZjNo9vXxVkn/X/aTx9Mc7UhaaHy47MuRGA6P0n12BiyFGBxLiHgED87q4Xc lwMHzkZiwG9AcaspAQu95kDHkd5WBn5wZfVvtJOoIi3cMmbSsMyZB/Ss/4YJewJQXm5a qTo8VqibPgVrHbt0qM3YQu/KLiduCRjlZYntQjWiF6QFRfPcnoM2MmuBUeAUpEpp2Oo+ EGT7SryG6nqjydO9DUuKOlVs5P8heYkpBJMrX8nsVFWynC1Nr8epuOLfood+pW8elpoJ OiSwNDKzzFazmVC3OjSmq44X5nYqHIEXdFrOat2gJ+cs3XhpQGYipwVQhuVIYJ5at41X SsvQ== X-Gm-Message-State: AAQBX9e1maX8azkElp+SNEtGGyDSFajjO4YPfDBxPGj8Vi8tI7ohDYQp /9+R4UvbOKCesGH7gcpQIwiJzs8GzSFnnA== X-Received: from joychakr.c.googlers.com ([fda3:e722:ac3:cc00:4f:4b78:c0a8:6ea]) (user=joychakr job=sendgmr) by 2002:a81:4411:0:b0:54f:93c0:4ba8 with SMTP id r17-20020a814411000000b0054f93c04ba8mr11022458ywa.2.1681795766496; Mon, 17 Apr 2023 22:29:26 -0700 (PDT) Date: Tue, 18 Apr 2023 05:29:01 +0000 In-Reply-To: <20230418052902.1336866-1-joychakr@google.com> Mime-Version: 1.0 References: <20230418052902.1336866-1-joychakr@google.com> X-Mailer: git-send-email 2.40.0.634.g4ca3ef3211-goog Message-ID: <20230418052902.1336866-5-joychakr@google.com> Subject: [PATCH v7 4/5] spi: dw: Add DMA address widths capability check From: Joy Chakraborty To: Serge Semin , Mark Brown , Andy Shevchenko Cc: linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org, manugautam@google.com, rohitner@google.com, Joy Chakraborty X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1763490902480403370?= X-GMAIL-MSGID: =?utf-8?q?1763490902480403370?= Store address width capabilities of DMA controller during init and check the same per transfer to make sure the bits/word requirement can be met. Current DW DMA driver requires both tx and rx channel to be configured and functional hence a subset of both tx and rx channel address width capability is checked with the width requirement(n_bytes) for a transfer. Signed-off-by: Joy Chakraborty --- drivers/spi/spi-dw-dma.c | 16 +++++++++++++++- drivers/spi/spi-dw.h | 1 + 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/drivers/spi/spi-dw-dma.c b/drivers/spi/spi-dw-dma.c index 22d0727a3789..45980c46946d 100644 --- a/drivers/spi/spi-dw-dma.c +++ b/drivers/spi/spi-dw-dma.c @@ -97,6 +97,14 @@ static int dw_spi_dma_caps_init(struct dw_spi *dws) dws->dma_sg_burst = rx.max_sg_burst; else dws->dma_sg_burst = 0; + + /* + * Assuming both channels belong to the same DMA controller hence the + * address width capabilities most likely would be the same. + */ + dws->dma_addr_widths = tx.dst_addr_widths & rx.src_addr_widths; + + return 0; } static int dw_spi_dma_init_mfld(struct device *dev, struct dw_spi *dws) @@ -237,8 +245,14 @@ static bool dw_spi_can_dma(struct spi_controller *master, struct spi_device *spi, struct spi_transfer *xfer) { struct dw_spi *dws = spi_controller_get_devdata(master); + enum dma_slave_buswidth dma_bus_width; + + if (xfer->len <= dws->fifo_len) + return false; + + dma_bus_width = dw_spi_dma_convert_width(dws->n_bytes); - return xfer->len > dws->fifo_len; + return dws->dma_addr_widths & BIT(dma_bus_width); } static int dw_spi_dma_wait(struct dw_spi *dws, unsigned int len, u32 speed) diff --git a/drivers/spi/spi-dw.h b/drivers/spi/spi-dw.h index 9e8eb2b52d5c..3962e6dcf880 100644 --- a/drivers/spi/spi-dw.h +++ b/drivers/spi/spi-dw.h @@ -190,6 +190,7 @@ struct dw_spi { struct dma_chan *rxchan; u32 rxburst; u32 dma_sg_burst; + u32 dma_addr_widths; unsigned long dma_chan_busy; dma_addr_t dma_addr; /* phy address of the Data register */ const struct dw_spi_dma_ops *dma_ops; From patchwork Tue Apr 18 05:29:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joy Chakraborty X-Patchwork-Id: 84577 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2597958vqo; Mon, 17 Apr 2023 22:32:16 -0700 (PDT) X-Google-Smtp-Source: AKy350a8+P9mwpgo1XLTYIhWgJQftw4qZnGM9zGE1jt3wtq6FfKQpLbqjsGisPaiv0i6n4emJa5t X-Received: by 2002:a05:6a20:431a:b0:ef:e240:b562 with SMTP id h26-20020a056a20431a00b000efe240b562mr6044650pzk.39.1681795935782; Mon, 17 Apr 2023 22:32:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681795935; cv=none; d=google.com; s=arc-20160816; b=CTVOv6X19MkcO/mS06c9mcOyh2YTCACMKVfukaIjC3ToVjT9iYEo6tEHfio9yyxLLW QIHLD81Hf7i3FRBltCl7gamvI62+eTcyyUQuzgSv+83ccZc2Gtq3aNgGkvSZK57gjeY6 V6P6304iQKH0ZE9pkpAYTtPOrOUz1KTwn5I6fnTHLvBOKIXoXbZ+iQK3H9GcxF7mU3IC NvQO8563kWps+MerRiyF9jlc5iu5gm6eoWR7EG4JCu2yhCvSYLlHkSlxv15M65jhb+JS 1eB8Zzya955gxbQL5fLEgMdGnxGOXJV2J9BYeUsPR4Syk7sY48+UXld9AzmHb+gwaUnf zA8Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:dkim-signature; bh=Fmf17OkL5SCBMBWD99k+zYNzeo76qcWOQzqTUdEaNA4=; b=e6ozf9vH2VJxg9lQ1GdaDEeS66gzsZpUKT4BMkFTRgO5WrO+Ym36kXUUTVjM854Zl1 3/0SRx8P8G+y7l+YyLV9l1ZFUeAvVFs12poZoM+V8R4+djREG2CeCmFSv7rKVQPZNBob JX0dG0kY/HX2boPjIpdx1NxknJpsHEmYrsmbDB5GLcSU+cMGL02uz4y6CGimapAYsDRb dk24PFdbTX9reaaKD/CRV2VE6WC3gLrdxm0vJOo0HESqUiQDSJrG6CM/6qNMsI26DZ/v EQxHK8j2hW80QmY3S7kx8l1ZN2xm5gyDX1NjkRyYd10u24QX41AM3BY4E/42TWt2QUYX QYUA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=ZLGNlq1P; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d1-20020a63d641000000b004fc2f19bacasi14225061pgj.120.2023.04.17.22.32.00; Mon, 17 Apr 2023 22:32:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=ZLGNlq1P; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230371AbjDRF3t (ORCPT + 99 others); Tue, 18 Apr 2023 01:29:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59500 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229662AbjDRF3p (ORCPT ); Tue, 18 Apr 2023 01:29:45 -0400 Received: from mail-pj1-x104a.google.com (mail-pj1-x104a.google.com [IPv6:2607:f8b0:4864:20::104a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0C44465A4 for ; Mon, 17 Apr 2023 22:29:31 -0700 (PDT) Received: by mail-pj1-x104a.google.com with SMTP id 98e67ed59e1d1-24763adb145so713532a91.2 for ; Mon, 17 Apr 2023 22:29:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1681795771; x=1684387771; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=Fmf17OkL5SCBMBWD99k+zYNzeo76qcWOQzqTUdEaNA4=; b=ZLGNlq1PGDuNXmKXCLEpwmCrcSVfz8bJTIn49O4DCgqv4BhkDZPhhsZZqXBoVChY4+ Ra4LogSmWM4SDLlCF7CSa4DPJ5nSCBspbm82HDOGzaGkTlGaNSBT0E1ZSB7aNab3llYn Ix7lWThLXLkhH0eOr+JohXRTjVQUdlA++00RQl2KVy784t6G/WBvEmUXA7+NnFt8AP18 xCt2KWflMpoZkec7CqL5XH/aZXVICoNiD+ymyHfhXbGnazme9J1wWTxmpnZLXlF7GlMy QsJ7TbF3vu4Y9erMH8vv+2tqX9teQG0ilKR6CUhtZFSnnEYffZj5ANb6hn7OBDEqBP7x ZTtA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681795771; x=1684387771; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Fmf17OkL5SCBMBWD99k+zYNzeo76qcWOQzqTUdEaNA4=; b=C8/MHgCb50LU/oy3KZo7aGe0UqFXTUUDV1QN9bAtpX8F5CtI3KI5urKq2OuVHysoC9 HyMDH0jxRrmQM8BJ5CkYltIy8Jwo+u9oNzlm52I0BnesXPkFQChjK2srRU/FDQq5S5xv vSxy8i/lBITikLOO96ftCnMCtd9tFyykwvfYQaEd46VbmobUymnyQzTDRLnJdGl/q/Wn wmkkblrVJq/CJmq17WE5IqtlxAUBB2hrQ2UdJkbxji6zVkVR8aY6eOvtw32e8qLYtzg8 TB4XNYy+sq1skluxLV2CYKzWpOpMda4gF3nYjfte8bOySkuAudfoocQBDQYZQiR9kg8L AdtQ== X-Gm-Message-State: AAQBX9c9wDWFhgcFKPTTYTr+R067e7njJAXSMxpvrH4zvYNfEWbhHkNh f7ZqMy7hDBqM+eQ3sCxWsXzR+5duCJVCOQ== X-Received: from joychakr.c.googlers.com ([fda3:e722:ac3:cc00:4f:4b78:c0a8:6ea]) (user=joychakr job=sendgmr) by 2002:a17:90a:2b07:b0:240:c13d:1325 with SMTP id x7-20020a17090a2b0700b00240c13d1325mr280814pjc.5.1681795771097; Mon, 17 Apr 2023 22:29:31 -0700 (PDT) Date: Tue, 18 Apr 2023 05:29:02 +0000 In-Reply-To: <20230418052902.1336866-1-joychakr@google.com> Mime-Version: 1.0 References: <20230418052902.1336866-1-joychakr@google.com> X-Mailer: git-send-email 2.40.0.634.g4ca3ef3211-goog Message-ID: <20230418052902.1336866-6-joychakr@google.com> Subject: [PATCH v7 5/5] spi: dw: Round of n_bytes to power of 2 From: Joy Chakraborty To: Serge Semin , Mark Brown , Andy Shevchenko Cc: linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org, manugautam@google.com, rohitner@google.com, Joy Chakraborty X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1763490855486048600?= X-GMAIL-MSGID: =?utf-8?q?1763490855486048600?= n_bytes variable in the driver represents the number of bytes per word that needs to be sent/copied to fifo. Bits/word can be between 8 and 32 bits from the client but in memory they are a power of 2, same is mentioned in spi.h header: " * @bits_per_word: Data transfers involve one or more words; word sizes * like eight or 12 bits are common. In-memory wordsizes are * powers of two bytes (e.g. 20 bit samples use 32 bits). * This may be changed by the device's driver, or left at the * default (0) indicating protocol words are eight bit bytes. * The spi_transfer.bits_per_word can override this for each transfer. " Hence, round of n_bytes to a power of 2 to avoid values like 3 which would generate unalligned/odd accesses to memory/fifo. Fixes: a51acc2400d4 ("spi: dw: Add support for 32-bits max xfer size") Suggested-by: Andy Shevchenko Signed-off-by: Joy Chakraborty --- drivers/spi/spi-dw-core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/spi/spi-dw-core.c b/drivers/spi/spi-dw-core.c index c3bfb6c84cab..a6486db46c61 100644 --- a/drivers/spi/spi-dw-core.c +++ b/drivers/spi/spi-dw-core.c @@ -426,7 +426,7 @@ static int dw_spi_transfer_one(struct spi_controller *master, int ret; dws->dma_mapped = 0; - dws->n_bytes = DIV_ROUND_UP(transfer->bits_per_word, BITS_PER_BYTE); + dws->n_bytes = roundup_pow_of_two(DIV_ROUND_UP(transfer->bits_per_word, BITS_PER_BYTE)); dws->tx = (void *)transfer->tx_buf; dws->tx_len = transfer->len / dws->n_bytes; dws->rx = transfer->rx_buf;