From patchwork Tue May 9 08:22:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joy Chakraborty X-Patchwork-Id: 91450 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2710878vqo; Tue, 9 May 2023 01:25:59 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4IKXPrrE9EOOrJ0FiBBeD8cLFUcKUrHhUb7zQK79G41OzDCDP+Lz6K4cuB1C1EgTM5K3hO X-Received: by 2002:a17:90b:4c4f:b0:246:85ec:d816 with SMTP id np15-20020a17090b4c4f00b0024685ecd816mr13434576pjb.3.1683620759526; Tue, 09 May 2023 01:25:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683620759; cv=none; d=google.com; s=arc-20160816; b=m5n9Y64NLVd8wtBp5CqZ9vvLqi10Q001P/SRm8E/DelJdh+xwCmZWF+1DewkrGj4Ae bqG13mKX7TqlVd0gi0NhWfH1MvbGeXKH046Kud1J3EXpPkyqhsHmNOOdV+VBGiFFJCL0 iZ2oO83fLprMj07h7pjQE2YgtFvSZwo77S0HCxfZuCSLcVFSfwCxlqKeTgodG39pJe/J FP6wRdSQNJAhDoheV7ULU6AW5X4+QAw2KAmaNhQnAxbITvXaFBOnML/e9cvbSIZHp7Sf pEyeBO/0Nwi0+ZyFYZM/XotBfqZ3pPSR+4Ub6DPqUg5nPXNM6Ie6irxSjyGeZdpj7C1b YoDg== 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=P/eUVtluKbHYoh34+9oF2eiC1PMtH+2gVKFzulzf0Dc=; b=VVXgfJG+j7jYxvJ/Cqd0JnKiy1IPsqsmPjJSudKt6oBHJnMiyrO775O3G8IfGf0YC+ BeE36alFsJgn6jh3ANmzgjreNollW8U+MtCXBUszatn6RSWHG3Xe1k+WP6eCsn/UvGQI 4a2IVlkt3MeX2mufAg6YFjw7wRVEmW/goFoEb+CUgMutIzh7A5s4koRea+rLFU+E+AGb EncpcniQk0Ep7JdbXZqJI9Y9UzvoaNh7Ovz5IympZnnxEIxFjeLvIbpiSig/sbzto/3z nm6/iDSW8CTRiyqAz0jEBuEYRpads6XOKEiBNzjtyrSYX3jMTa7FVgYRBHRXXwZzqqko qqyw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b="MOl/ueia"; 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 my8-20020a17090b4c8800b0025069d02778si6406879pjb.28.2023.05.09.01.25.47; Tue, 09 May 2023 01:25:59 -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="MOl/ueia"; 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 S234814AbjEIIXB (ORCPT + 99 others); Tue, 9 May 2023 04:23:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39286 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229615AbjEIIW5 (ORCPT ); Tue, 9 May 2023 04:22:57 -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 D83285FD2 for ; Tue, 9 May 2023 01:22:55 -0700 (PDT) Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-55a42c22300so91021157b3.2 for ; Tue, 09 May 2023 01:22:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1683620575; x=1686212575; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=P/eUVtluKbHYoh34+9oF2eiC1PMtH+2gVKFzulzf0Dc=; b=MOl/ueia/VczvDyjT3T7HYTqdbT3tGq7e/qZgsdHLgfTJc6xduTdB70L6CR+tIEKXC 6EXTVk126gPItF25Of5O7fVF6UVJFXoeDtJSh85kNratW2ypIYLNIcEJhsWOoD3DwPIA 73gEFnRt9TduebE6GB+/AE02x6hmYT/i305jrOYJ7/i8E2Ts0HH5E1K8nZgHMVItEzpm rWj/3GYLmUzCBiQi1vnGi9jxqMp/fjSVJvegrBlGq8b/qE3OUi6WL2s6MTPgOlrKkeu6 rHrumiATgCHtZa5kExrL9Vu39ZtlDuG8EJJ4C58nMpDZBxy66RKeTFPDH7GkKELaTrDC 9Qdw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683620575; x=1686212575; 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=P/eUVtluKbHYoh34+9oF2eiC1PMtH+2gVKFzulzf0Dc=; b=c1yZD/rtJh50444cbmS/Yek/xto4kjPRlxR6FESnXk1Rkm/QXsSa+AYFEu7/A+lUHm L6DkBvONalLVpu7IJPet8s814waTdY32H0YZPdVJ2z5GgBJYfGShihqMVGTzKelxUO8Z KB5HvxijJO9K+7Rg+zHdXdy6IRXiVy5+jtK7PXqtfMseWHTvvfHPN8W3Npk3PR36ejsA M+IlqML0Gt8/5ZIBj+O8gRdpf1gH4eGhW8BNQFacZLj7TZ23ob37IIRi/MsjNHxR6Qne mMYgr4l9xUfh55Bikgm+u2/3BC9ZVlLiTP20vvRqxhVfkoONT5+e52uJxJJZ7E67h411 PX6w== X-Gm-Message-State: AC+VfDz3Tp227gCUzIuRWrbw3IkJ7hS+STDL1RQmHC5lRKtznozsEx3N h+2Nlg3Z+Dqurbnw7loyX265s/zvFOKBow== X-Received: from joychakr.c.googlers.com ([fda3:e722:ac3:cc00:4f:4b78:c0a8:6ea]) (user=joychakr job=sendgmr) by 2002:a81:b65a:0:b0:55a:8e39:57a7 with SMTP id h26-20020a81b65a000000b0055a8e3957a7mr7726750ywk.6.1683620575080; Tue, 09 May 2023 01:22:55 -0700 (PDT) Date: Tue, 9 May 2023 08:22:40 +0000 In-Reply-To: <20230509082244.1069623-1-joychakr@google.com> Mime-Version: 1.0 References: <20230509082244.1069623-1-joychakr@google.com> X-Mailer: git-send-email 2.40.1.521.gf1e218fcd8-goog Message-ID: <20230509082244.1069623-2-joychakr@google.com> Subject: [PATCH v10 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?1765404321524979567?= X-GMAIL-MSGID: =?utf-8?q?1765404321524979567?= 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 Reviewed-by: Serge Semin Tested-by: Serge Semin * tested on Baikal-T1 based system with DW SPI-looped back interface transferring a chunk of data with DFS:8,12,16. --- 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 May 9 08:22:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joy Chakraborty X-Patchwork-Id: 91454 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2720262vqo; Tue, 9 May 2023 01:47:56 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7q2I8nk8JtbEBh6gvSVbgnkJEmJmacWiPthTsmXxSrj0AUnY4aOnh8FBUKqELbpSPURZy1 X-Received: by 2002:a17:90a:6349:b0:24e:246e:6454 with SMTP id v9-20020a17090a634900b0024e246e6454mr13760209pjs.33.1683622075855; Tue, 09 May 2023 01:47:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683622075; cv=none; d=google.com; s=arc-20160816; b=IOyitgr7Ud2fGfhaZ4vJTFdSImcq59Vlvziu3SK6Qgke3OvjgU/QNFTbM7WqTAhV2t etETSpjqk0JgZ2SawC8As1iyUb0reTHpN46TNkDEU8N1PLhqnGBOz4n+wUysjSS/in7n HOR5fGBXoHpdMMhXCnUtRpku1QDPJGERBJ0B1BFEcb2KMG0zuTlC/0GmveUUXsgAUaAQ 89oCO6uNRAhmiL4E1e8U1AstwoDwa52b1oqZ92Qviy8AYF4TTGTrzyQzAZcjuXvOQYSo GBFEsT5ffr5gunX+7TEEA5brHMAjlx5AfrahAgS2/kJiCUlUH3pHhk52qkiCLgIKpgri DRnQ== 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=/nzvqAVbvzYABlQomy5DkIxe057QBPgKkXg3X4iNsvg=; b=ppz1OPX9K6xBE9yN6wiHBrcDnCt3eWU45tC5HraO6bD9jBdeL4OahqMvzhGWhZA+wW JtjxcMGrTV/1ETrjcbQ18URrbm2+id/O6E/MsthR4c/F6eB7SQ/KhwgO9Y5QcvFQH2eA q2hEELGLb669GhrnFDR/k3vjBbikF8MESq7efnRgc9S9XC0TmU4Z5P9bRk6ea/colEpr yJuSHRCjlMwCnmJSgn83PwuH0Pd1PpsRMnp2R6w+u1e9j16DVdfD8iGeAYsS7X90xCJG QQY2qcsRNntVbK52FtIympkUsyUTyqQNRKbbUNtBAWBOjKV39gsaW6V5UpTeXdyMi9bv 0Jcw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=74iCI0aY; 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 qe2-20020a17090b4f8200b00250a4d72bc9si2338379pjb.108.2023.05.09.01.47.35; Tue, 09 May 2023 01:47:55 -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=74iCI0aY; 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 S229557AbjEIIXH (ORCPT + 99 others); Tue, 9 May 2023 04:23:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39396 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234818AbjEIIXD (ORCPT ); Tue, 9 May 2023 04:23:03 -0400 Received: from mail-yb1-xb4a.google.com (mail-yb1-xb4a.google.com [IPv6:2607:f8b0:4864:20::b4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2D20CE74 for ; Tue, 9 May 2023 01:23:00 -0700 (PDT) Received: by mail-yb1-xb4a.google.com with SMTP id 3f1490d57ef6-ba2b9ecfadaso4133167276.2 for ; Tue, 09 May 2023 01:23:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1683620579; x=1686212579; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=/nzvqAVbvzYABlQomy5DkIxe057QBPgKkXg3X4iNsvg=; b=74iCI0aYEzxSweD/pJ6VE2M74d5b5ftirpEnpTpbs9MEwCxIV/Tu6pihyaVK9ctw0r fHXB7XWQLlttYkPQt2ql0qbKubqogTjwIqG7j+4rvdYp+wr+JrZ4adA+xZHBQSuGAARz nmtROMY+GjM40ZR/6YUQLcxFKZfjjXZTxiQVSt78NNV4x5veI/j7gqeBvjpd6h5e1TQE zwzfmqBvLrIOSXDy2iB6gvgtyhdVxG2q4o6wrNzXcXjQ/aBbSbSUGzdlASXO+/IHgtVM GhfyjN358hfST2G6VdFiRSURlpG4a+WxmhcG7YpCiUZLnffGa3Ws0MYsBbfKQ1SJVmPF NoIg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683620579; x=1686212579; 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=/nzvqAVbvzYABlQomy5DkIxe057QBPgKkXg3X4iNsvg=; b=hedOAtzefDxr1JijgPb6nwb22D+PDWKRO2EEF+3nsuwn3s6co91qIUxjpBwNiOSLK4 52oHdX+dwM6Dv3etMvIGQNzwIv8uDSNGUU4AGrTxdBEeqQHCHCUd302XmjIDyyA5ikV+ it2j2eR48BmM17jWhxXYjtMjHCqsTDfrRqgKvoUeafYb9EMwAc4azGE5yb4G8U7N5VRT nhQVb+pFIABIhyrWdASSA9CGOQTFqJbiGJgBEJ7EIeDRDBPPR8NWtYp/TxbiqQFrl7yW cWsKbop6Hs8Y/FV6Z/7LKONcgrYtrBufIqHAPE5Sr+H1t1Aa6Sj+CVoqn0RkeDc7l/SO v9kQ== X-Gm-Message-State: AC+VfDyqyhCu2/SJ9tpzxAHvV7BnMe5FQgsr4r4/GE2N6NexCq9cBvoy Tm2RwgTM9HNFBBpw11fnVM9RUOV7kNNFnw== X-Received: from joychakr.c.googlers.com ([fda3:e722:ac3:cc00:4f:4b78:c0a8:6ea]) (user=joychakr job=sendgmr) by 2002:a25:d34b:0:b0:b8f:47c4:58ed with SMTP id e72-20020a25d34b000000b00b8f47c458edmr8460356ybf.9.1683620579716; Tue, 09 May 2023 01:22:59 -0700 (PDT) Date: Tue, 9 May 2023 08:22:41 +0000 In-Reply-To: <20230509082244.1069623-1-joychakr@google.com> Mime-Version: 1.0 References: <20230509082244.1069623-1-joychakr@google.com> X-Mailer: git-send-email 2.40.1.521.gf1e218fcd8-goog Message-ID: <20230509082244.1069623-3-joychakr@google.com> Subject: [PATCH v10 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=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?1765405701590873183?= X-GMAIL-MSGID: =?utf-8?q?1765405701590873183?= Move dw_spi_can_dma() implementation below dw_spi_dma_convert_width() for handing compile dependency in future patches. Signed-off-by: Joy Chakraborty Reviewed-by: Serge Semin Tested-by: Serge Semin * tested on Baikal-T1 based system with DW SPI-looped back interface transferring a chunk of data with DFS:8,12,16. --- 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 May 9 08:22:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joy Chakraborty X-Patchwork-Id: 91453 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2715815vqo; Tue, 9 May 2023 01:37:33 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6XY1v6WWDAO1atHu0n+gQDwGCWKtjbWYh6o5ultSt245ncjjoCiWedBZActzZ280v4pKcl X-Received: by 2002:a05:6a20:918c:b0:100:28e0:6854 with SMTP id v12-20020a056a20918c00b0010028e06854mr9589223pzd.45.1683621452822; Tue, 09 May 2023 01:37:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683621452; cv=none; d=google.com; s=arc-20160816; b=WmCT9YiDaw2aaccmCgvJNQY/44ZuS/r2zHY6zeWpMPI3CwMLaPobopW7Ab0hIY/h4B kgHUhNN/NzYzp2YtqCn7oPCxtGVIe+IX8j/+RcJV2V+eCf/bYjXmrimILju0v+g0rRAa w+VrQo92W17ykOzaLRx3f9wBjMLK6lEniVY8wHJAnbV+90pEHobtkLMH12d7wYk+t63U Rdy/hDmq5rgMVQ0/K5rfYYKiKsRynmcBj5H2AcnqptXogX1n92AGKHKAc5wulrt92Jr1 GUUUvQazVtlFytRV0mdyc4TgiZ31tBzoTrO7JuqQR4v34F/mzE6TwIga8iU78yv7RlXU dILQ== 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=dcm1xpxsxE4LsssubrxTulCcSjnntMYzhlXL+xNXQmE=; b=Mu8XG1LsGaCjGaVW4dl7zrkUP/fcBJKKP2hAn95pJYddj01DmKUyaELHtq8x4jiIyj MekaxXP0stO7CHfYZwSBB6jnAe69jnAlb5UjZor5hc9kyD2Z8+3a3zOBsccEaVaHJ7si vi0SgKsfH8FmSRr5mWdO3XZCDCDS3yFxVzu3OJC6tzM5BIqUf7Vfi+yaBb7roKq6MhMn dOkpu7lLylzVPZL3BOiMEYIHi6hKy9BkOgtd1FontFF42P/XwFjuMfhIB4VZwmckV1S1 drKMjsZng/qb78a8Lf4i0Ndun6+ST2TJOCvGLxIqShBncxbH+RRS0uJyfQShby4KRvNV Sd1A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=SC2w1S+a; 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 d12-20020a63360c000000b0052cbf501db2si1126236pga.68.2023.05.09.01.37.13; Tue, 09 May 2023 01:37:32 -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=SC2w1S+a; 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 S233827AbjEIIXW (ORCPT + 99 others); Tue, 9 May 2023 04:23:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39608 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234852AbjEIIXK (ORCPT ); Tue, 9 May 2023 04:23:10 -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 EC5CDD87C for ; Tue, 9 May 2023 01:23:04 -0700 (PDT) Received: by mail-yb1-xb49.google.com with SMTP id 3f1490d57ef6-ba2526a8918so5459744276.1 for ; Tue, 09 May 2023 01:23:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1683620584; x=1686212584; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=dcm1xpxsxE4LsssubrxTulCcSjnntMYzhlXL+xNXQmE=; b=SC2w1S+a9UIFvlzG/TtznNrQM+SlztRpmqJCYhUvVl3bP2kqiZJcBIq0kELz0fcd6F lpHQOcplW4pxPwsm08WZ+PusejT5ou5sP7zuDP6CZ34i4FJePoNuzvqzn5sjkToZew9g yyXZmWogXOtCvOn336dxqH7oVGlk3eNt3udoThPp+93HOv+EaQIl7EBnaPGhewnQO2gW omPB3iQ/g8cmfJuDdSe2MpCVPFZtt8ymh1Q0eg9jntvPRvczEmU+Q+u0nolSgnCBEqT4 MI7PpWyia0BQe7RjZ9VisNlwJgDjIVk3l+6OTlwWB9phoNHq7gW4mTmEhsztDcRXvcJM saTQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683620584; x=1686212584; 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=dcm1xpxsxE4LsssubrxTulCcSjnntMYzhlXL+xNXQmE=; b=CtoqYBSwazQ0UVg9+Vr4qd4f0DwbnvkSEQX+isIs5WljTZK86vpK5crwIChvQgcTum fjD4gGNKQp75r6cKUXLSqYZiZZKeKk8eCg0wW4yvTdH7iXunUKSYLSR0iKeAgmEVRBAE Pef+yItAhx3HOClq6b8jdUq6z25LXqbQ4qooxSQgY7k+AhMLDjAVWCm9k0gPB/IZDWof fIguEKw75F2vttl4ncUGFS2UBIfOn/XYL777fUCmk10/bTb9LTnNPIbiK4WGFYNXIdb8 DWQTAWZbC953cJ4DMpWqIe+gprKLzR87k8ff7muYZ8Xjxg/EK2JK4qDgqdzfponKxmn6 Fxcw== X-Gm-Message-State: AC+VfDziBMaQEbMm33itS8m9X5dIgqVi8ZGdWl9/QtcaJMoMTKIlRlEt HdoccNhSizlSJQb+kl3OS4yZ7dV7sNlf7Q== X-Received: from joychakr.c.googlers.com ([fda3:e722:ac3:cc00:4f:4b78:c0a8:6ea]) (user=joychakr job=sendgmr) by 2002:a5b:ed1:0:b0:b9a:6508:1b5f with SMTP id a17-20020a5b0ed1000000b00b9a65081b5fmr5769008ybs.11.1683620584172; Tue, 09 May 2023 01:23:04 -0700 (PDT) Date: Tue, 9 May 2023 08:22:42 +0000 In-Reply-To: <20230509082244.1069623-1-joychakr@google.com> Mime-Version: 1.0 References: <20230509082244.1069623-1-joychakr@google.com> X-Mailer: git-send-email 2.40.1.521.gf1e218fcd8-goog Message-ID: <20230509082244.1069623-4-joychakr@google.com> Subject: [PATCH v10 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=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?1765405048317488855?= X-GMAIL-MSGID: =?utf-8?q?1765405048317488855?= 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 Reviewed-by: Serge Semin Tested-by: Serge Semin * tested on Baikal-T1 based system with DW SPI-looped back interface transferring a chunk of data with DFS:8,12,16. --- drivers/spi/spi-dw-dma.c | 41 +++++++++++++++++++++++++++++++--------- 1 file changed, 32 insertions(+), 9 deletions(-) diff --git a/drivers/spi/spi-dw-dma.c b/drivers/spi/spi-dw-dma.c index f19c092920a1..2363317a0dca 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; - dma_get_slave_caps(dws->txchan, &tx); - dma_get_slave_caps(dws->rxchan, &rx); + ret = dma_get_slave_caps(dws->rxchan, &rx); + if (ret) + return ret; + + 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); @@ -87,6 +97,8 @@ static void dw_spi_dma_sg_burst_init(struct dw_spi *dws) dws->dma_sg_burst = rx.max_sg_burst; else dws->dma_sg_burst = 0; + + return 0; } static int dw_spi_dma_init_mfld(struct device *dev, struct dw_spi *dws) @@ -95,6 +107,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 +137,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 +181,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 May 9 08:22:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joy Chakraborty X-Patchwork-Id: 91459 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2722049vqo; Tue, 9 May 2023 01:52:40 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7qQeqXSBmb+mgYl2WIpRDX8+22XkwpaaY2KsL5dfQWinARk9o6eyqTsRJJRv7IWI2o0S29 X-Received: by 2002:a05:6a00:2e98:b0:63d:2382:4948 with SMTP id fd24-20020a056a002e9800b0063d23824948mr15379201pfb.25.1683622360111; Tue, 09 May 2023 01:52:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683622360; cv=none; d=google.com; s=arc-20160816; b=DnBUUq6wUjnMBhICu3Cojwqznmsg7RPrpx5TDVsvjIVA6Id1QzCXJnWCczYGBSe9Yn fawIm4xIqKT9kFJkqIWZCJWaavTCatHZWMBAcTcXiLoiRtNgKymTmaUTzR7MjaLkUrPf 3BwvRltUOnKD6uHgHEyBXsxcCSlJyhbrBKQQY7gPzhibj6ChHqsUHNOKdIl4D0kX2bJB GqtlH/mBYVLZ96kVo8vN0PBlmiXlSQmgd/sg6WCcvdXUtE8jIaGNdQGNCU5j6jgCGbsf JZnz96d+QgAKZpiEYb2I71OydVkVgRV+x/ZzsVDzMg2VCNjDWtybgcIAf3NhTKn/ddBR JzVw== 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=HEl/ebklkKS4o01vG1eIpzniBnuA2urT/Tj2wNhU8Co=; b=fTgHdXl9pfnOHUvudqSuWDOy02UKHsSPMGczgjHyVHNz2E2pYec5JqUzu5l+iJhH1i snoucujKiCM6QQwJQrWTR6T+CLLz/MTD4aVbWANd+fTRWChXm8QYu2loosHmJjCOQo0X TJax+KJYuUQOt2C36kHNphIZb2zhiLTQmJCCmd7sgckeY7XU4a/FVvQSkBQkW6QPtR9/ V39Bjsu+hKs2C81moao+EeMygdqVyeHIHU4lLz0gEtsk+wSvEp2H8LStJX/UoGMDJ4lj UJZFEM0GVtYyyA9oZ1KApAC1Vh1sG2IXpCUEjuQN7lHjI8vzN9ftaFGZFhnVgqdRScDI BaJQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=qMMaRgFk; 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 f144-20020a623896000000b0064105588e53si1876488pfa.359.2023.05.09.01.52.28; Tue, 09 May 2023 01:52:40 -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=qMMaRgFk; 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 S235037AbjEIIXn (ORCPT + 99 others); Tue, 9 May 2023 04:23:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39628 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234983AbjEIIXU (ORCPT ); Tue, 9 May 2023 04:23:20 -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 C14F7A244 for ; Tue, 9 May 2023 01:23:09 -0700 (PDT) Received: by mail-yb1-xb49.google.com with SMTP id 3f1490d57ef6-ba2b9ecfadaso4133359276.2 for ; Tue, 09 May 2023 01:23:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1683620589; x=1686212589; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=HEl/ebklkKS4o01vG1eIpzniBnuA2urT/Tj2wNhU8Co=; b=qMMaRgFkwtCu3WTiH6Xcj3y05BVLosur4TdWR4cdbWaK8Yeo6AzJvfnwVOZObtkgIh lvB5saSwuLoXmapUFLdMuCrCRSeqgr/kvsHm8khWp10DIMzb3Ssgeo6mr7SZDTY5hsf3 5f5OO0unt09oLnbBKqb+wF/4DjCbAiXIA46f0Nh51pbQflCT4aQ4EZo0y8zlUON8cM/x LLv3WxLJLOR4IR+qUGenK5KcM5RFfU+uKpedI5QIy6TdrtW+7xfhDl+dfamVCOR2IX0l V9vdXIAl0kq63Qpse1lBDC8oEI4+8ykXxve/MYcd+LXtmhCLUFe3iocFXISnhKRi17cJ zQbA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683620589; x=1686212589; 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=HEl/ebklkKS4o01vG1eIpzniBnuA2urT/Tj2wNhU8Co=; b=NVYD0tIGCr0MhMW7aax4rs1ZO59MmRtQoL4Nn6LIHcPwU/3fVGRsPVCkiQQTDPPnaf LkfEEELeEcgUoMv+eL9qeZyHSeo/S+QF1zhMRrX0uIcrgF+LBBBQPN8CWydCn/UwT4Vv pAN7k4/T0lFqN7bflLvcfu3786wVlmzl+WHTQIz7IkibiA+ZtLhkAbA9yTeNLFgwRDpd t/z1p2RGw+xey4Dtczjts9XpYOCLlzzpVjt4uKJhdI+7RHLbhuRKhdSRe3xUK1TzXSmP +3rxiV8V8XFKms/vgXsCY1O8aKg1jpt5lQAayWY7SsBe3sYAbQGR4oqBtmy2p3wlQjrR XCIQ== X-Gm-Message-State: AC+VfDzn8VAITcgtjxpVvmzg/CquUiTVtb/+IK2d+M60AvCIIPm5h132 3kXBPXekTwlhLbOgfZyhoVT0HU9sxn2JFw== X-Received: from joychakr.c.googlers.com ([fda3:e722:ac3:cc00:4f:4b78:c0a8:6ea]) (user=joychakr job=sendgmr) by 2002:a25:12d5:0:b0:ba1:af7b:b88d with SMTP id 204-20020a2512d5000000b00ba1af7bb88dmr8574837ybs.2.1683620589048; Tue, 09 May 2023 01:23:09 -0700 (PDT) Date: Tue, 9 May 2023 08:22:43 +0000 In-Reply-To: <20230509082244.1069623-1-joychakr@google.com> Mime-Version: 1.0 References: <20230509082244.1069623-1-joychakr@google.com> X-Mailer: git-send-email 2.40.1.521.gf1e218fcd8-goog Message-ID: <20230509082244.1069623-5-joychakr@google.com> Subject: [PATCH v10 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?1765405999864047512?= X-GMAIL-MSGID: =?utf-8?q?1765405999864047512?= 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 Reviewed-by: Serge Semin Tested-by: Serge Semin * tested on Baikal-T1 based system with DW SPI-looped back interface transferring a chunk of data with DFS:8,12,16. --- drivers/spi/spi-dw-dma.c | 15 ++++++++++++++- drivers/spi/spi-dw.h | 1 + 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/drivers/spi/spi-dw-dma.c b/drivers/spi/spi-dw-dma.c index 2363317a0dca..df819652901a 100644 --- a/drivers/spi/spi-dw-dma.c +++ b/drivers/spi/spi-dw-dma.c @@ -98,6 +98,13 @@ static int dw_spi_dma_caps_init(struct dw_spi *dws) else dws->dma_sg_burst = 0; + /* + * Assuming both channels belong to the same DMA controller hence the + * peripheral side address width capabilities most likely would be + * the same. + */ + dws->dma_addr_widths = tx.dst_addr_widths & rx.src_addr_widths; + return 0; } @@ -239,8 +246,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 May 9 08:22:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joy Chakraborty X-Patchwork-Id: 91456 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2721719vqo; Tue, 9 May 2023 01:51:44 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4YvHozwRbVVcOknVDyYjXue50GPVaoFNe0j/pX3rp1nrWC1qgDEeUmeG6PxufGr65Qjymd X-Received: by 2002:a05:6a20:841c:b0:100:52f4:986b with SMTP id c28-20020a056a20841c00b0010052f4986bmr7786051pzd.58.1683622304284; Tue, 09 May 2023 01:51:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683622304; cv=none; d=google.com; s=arc-20160816; b=la9IV2Fb6e7O+DRKN2lJPquqjohDHFg6uqgllb4xZUlaZJCLBE02XpEIy/se3tVACc kd+rLvXiXUgX/NjDS8x99y+BFQ/7LUpGBHcGm14iY694cIf+OMbMxhRf4sJlfY6Y9Mmg h1RYHJYR2Ksi0nFo+C8evoozMaLK5/IxSja5bN5wKJxKe6ts93hewuhQZey4Y0xR2lSc Ebc0kz7l//vGA+t6a2ImWuPS6yS8OkwKe8KmyOv+5bHaRQhktdtHx8tDivsqeoHMKka4 ydx77xjZKct/fbihFinrTJkJcCLdJKvZL6D7BYh9YzI1mPrkz/89bNkRstG+OxKaPx+g LkpA== 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=EOqtouxRu25HRRsWlk2RLw7lnYbQ6zK+okIr8VJZgWs=; b=Ul3Y96TUjiPuTZ4W07fecNaIUL+N4/ogpUKfn5fB3mViexu2Sf0k3pHG/l8Qx11PlN BWKOODiIZxPoDd4sJB4ikDAmkHOc+4F2d2sgUSVmJjI5cUP2BtYsXiHpSzpe3HNZL/ig ei47A1QBYC1uKMBR7gjQg8ty6sQAq+I26qcmImjOZp3/1svo3R4B1dV8r6iormKqlEYm +1FSeIb3SBq4dx5JF46L2xzwO9zQw42lOTNn04Ma83pFUBj6OfWb0do7NBumvXI6awPE WN8A/+KCdDhns5tkSv6rEQYOrXGvCoJM++qqu2ezM9ZaHyPiI87hyzRazK8pPi7/BHxG UTHA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=DzKDPmME; 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 i188-20020a626dc5000000b0063b7812639bsi1828514pfc.312.2023.05.09.01.51.29; Tue, 09 May 2023 01:51:44 -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=DzKDPmME; 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 S231468AbjEIIXv (ORCPT + 99 others); Tue, 9 May 2023 04:23:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40188 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229615AbjEIIX1 (ORCPT ); Tue, 9 May 2023 04:23:27 -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 7F85CD2EF for ; Tue, 9 May 2023 01:23:14 -0700 (PDT) Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-559ea6b1065so96637187b3.0 for ; Tue, 09 May 2023 01:23:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1683620593; x=1686212593; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=EOqtouxRu25HRRsWlk2RLw7lnYbQ6zK+okIr8VJZgWs=; b=DzKDPmMEpZHjb9GuaKoRNMsHWMhtL9oVCv0krVFeDx3758tICEhyUNkOrse8cAKqLS 3phGAD7as5/VjeDKqJAc7r8JScHrf9QIQ7hPFdfbPNXYOcxXP/tbUqeP3SroM2IMIQ+j W3MS7WdHxLXxKFyWDF7s5buuMqpLjryFJIERteQbjNtAyssZK7P30HxanRG2FtHfj6rA irmKx5af8Dixewafm4ngw2zEVpyeTMGddd7k7xTzTRfboRUySqZXbhhyODBkVUyijzMc l5+Gxi2eM95Vv29rd/EqJ3jOzqxQKIyVcEV+qDRUEkRS0El5b6Nov5RxWB6vh9eA3pVy RDzQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683620593; x=1686212593; 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=EOqtouxRu25HRRsWlk2RLw7lnYbQ6zK+okIr8VJZgWs=; b=ESSHKKhtmNTCX1ghdHNsPu96P4g4lDhvQxt5IpQgycs7e65WsfVl8FksjMazltx6Qz Q/BgWqRA8LBpf/ldDPQllkDsuFbqmFSNV95vaceMym8GOEHoT76EQe9tJHmCYZ2UnzWB MX0eNKvcv8rizThjEzycsjXJgBOLRyiUigZvU70Z41v1lFpUL2cwf8Vrqukx3r/SIicf dD/HaNC5AB2sJRvPczrllO1X9rirNEfX9jfBdUOV+XLDuUd+2PNfKimkqfHjmLbK4kHB 5/iB2RASpaj6ET+Cluk/m0T9CJLy4/Wf0Euq47g+84U6a+VTwSJaPZQwZLFZ6hKbQ6N1 2Fhw== X-Gm-Message-State: AC+VfDyPDxWzF8yuWULkgT5JUcuQr8xaupH96+FxfepQr2vdS07zx6Qg 61mHCFFVuy6AqLeZHWS1ZF8gwf1oHmqgSQ== X-Received: from joychakr.c.googlers.com ([fda3:e722:ac3:cc00:4f:4b78:c0a8:6ea]) (user=joychakr job=sendgmr) by 2002:a81:af0e:0:b0:55a:5641:54be with SMTP id n14-20020a81af0e000000b0055a564154bemr8245389ywh.6.1683620593763; Tue, 09 May 2023 01:23:13 -0700 (PDT) Date: Tue, 9 May 2023 08:22:44 +0000 In-Reply-To: <20230509082244.1069623-1-joychakr@google.com> Mime-Version: 1.0 References: <20230509082244.1069623-1-joychakr@google.com> X-Mailer: git-send-email 2.40.1.521.gf1e218fcd8-goog Message-ID: <20230509082244.1069623-6-joychakr@google.com> Subject: [PATCH v10 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=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?1765405941611161968?= X-GMAIL-MSGID: =?utf-8?q?1765405941611161968?= 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 Reviewed-by: Serge Semin Tested-by: Serge Semin * tested on Baikal-T1 based system with DW SPI-looped back interface transferring a chunk of data with DFS:8,12,16. --- drivers/spi/spi-dw-core.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/spi/spi-dw-core.c b/drivers/spi/spi-dw-core.c index c3bfb6c84cab..4976e3b8923e 100644 --- a/drivers/spi/spi-dw-core.c +++ b/drivers/spi/spi-dw-core.c @@ -426,7 +426,10 @@ 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;