From patchwork Fri Apr 14 12:05:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joy Chakraborty X-Patchwork-Id: 83384 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp342292vqo; Fri, 14 Apr 2023 05:28:22 -0700 (PDT) X-Google-Smtp-Source: AKy350ZG32YQgibLVSm+kPhxb7OyrlGZN/23UQXkseweh8/xk9KMfLXDAM3CUhxSMHpaK0UjbTzR X-Received: by 2002:a05:6a00:174c:b0:5a8:abd2:2beb with SMTP id j12-20020a056a00174c00b005a8abd22bebmr8737437pfc.30.1681475301789; Fri, 14 Apr 2023 05:28:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681475301; cv=none; d=google.com; s=arc-20160816; b=LnQpePNhd/YNXhnuuYO6b/ICS0mVQlaTPC/vgWBbpk2uP79/cxILrRXeG1tX3JrrgB C+fbpio8jKlYe7hVDXz6s0nx7GGA4dtKeABkASbDMfT7XfhnwxQorCpU/Plo4Qu5Lixc dbYmq2If+05i5exb+q6uZrytn1ly7M/FNFL1Uvt6R2MeeEd0cundqPWyGSwhV2FXmGDI f9x2EKvk7K0M3tVwbhN27vfCiwmWK5UhI0drHnheqcDKxIJoUV8QzOtl7xKi1LARyKLd PU7sWcWvuaklqywRQOTVywlgiBNx17TrFIuPqq9aSeBLWacE6uXUABsPIagmjOWRuJzo K0jQ== 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=NnTNZz0HKpMcPljGIpuaqZSpTasLn3NJcZagdul5jvf/I5HpnNbVqieCbZad+YQp/U NHujaJu86WatCrHBSCTy8Ezq4ty8hUXD326AIKMt9LsZ76OIlvsS1BtHvlvqvtRqfBRO HqApOe+ukSkUeJOLq0MBOw9VhKbLF7eKn0D0/Vflx8gKqJdEYm0WBmHIhau2N2fQbwhI Ac1/4zYnfeq2EQzU4c89s2VbRgG3NX0LJQnVKL1DppTxhRjCWQLSQ0MTS3fJU7E4Lfn5 6e+T4MMlBh6BqSHkHYkD1q+mWsBWJBrKLRCQ1lKJdipIhupvNOg4cNApHeBJlX403sbf BIqg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=MileTBwt; 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 x3-20020aa79ac3000000b00639e52424a6si4315318pfp.146.2023.04.14.05.28.08; Fri, 14 Apr 2023 05:28:21 -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=MileTBwt; 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 S230167AbjDNMFf (ORCPT + 99 others); Fri, 14 Apr 2023 08:05:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56912 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229950AbjDNMFd (ORCPT ); Fri, 14 Apr 2023 08:05:33 -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 EDCB7127 for ; Fri, 14 Apr 2023 05:05:31 -0700 (PDT) Received: by mail-yb1-xb4a.google.com with SMTP id j193-20020a2523ca000000b00b8f6b82ec94so2504129ybj.18 for ; Fri, 14 Apr 2023 05:05:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1681473931; x=1684065931; 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=MileTBwtlL0qqRT9AiQfm9JMqrnFA9bJsAcMj7ZZ9KppF1hAzoRuBJa+Y6TzrKhNh9 0zpRMfy7KoXKTtjw/1phr1Ju8Q7MUC3Pv2KXsUmij4naENHQWdy5ESjF2rESYm0/J1nH ZnXqByO+tcKc/Uosx35Kpn+fCdC0j9wB2QkGB8bZgQAQQ0gPupXYv3MWdmOAItIRdjlp wtWbEs8sADYLMeffdzvE/pty1M/x1pgUZbGEUahJgaG3Q4TzOWLa8UGhJfh4ER628TTZ M7K0CE9thwSsjjvv6lkLhAR6VG4lMylReBNHP7mHOm+66jtDweWML0O0f9DBsbI3hIWD HkAw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681473931; x=1684065931; 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=Z7K41qR3JqJUIr5OjM+7ZuNgi3cPxtJ1vNL/pfv6svvk5Tpnq/ROauM/feBgQX0Orm KipAKag1XNWy5t2lV+y6Fs5PJJQLjExu9UkvaZw94VBGUC/Zkp7SiE6mm06Ix4c4OtqP wPBfmSRiZ+rpiP8o6jdWD7TSs5ioQm7x+ZYUsx+gdk051e6BXRLjwGYB/VA4aZswgL0A Yd+rWY7iHQOaF2su7MuxQ7bAacc4iDQhvBAT6G3lv5j2VD9DDQTWqAL0z1Tso3cNK6uH uzrR+QfMPBDRp1awApezpdf4IRhS1OhfxW5Gpl8rSRh1AX981hGX/aCw3XgfwYM2avGE zu5A== X-Gm-Message-State: AAQBX9fJ8i4opiv0QfmYZJdJ5kjjI/6e6sXekykAQYZNKrK4gSqEOP7K 9lKbwPSRYUOZUaSEQQkT3B/8pyeGY2hrsA== X-Received: from joychakr.c.googlers.com ([fda3:e722:ac3:cc00:4f:4b78:c0a8:6ea]) (user=joychakr job=sendgmr) by 2002:a25:73d1:0:b0:b92:1f57:8d03 with SMTP id o200-20020a2573d1000000b00b921f578d03mr355881ybc.9.1681473931261; Fri, 14 Apr 2023 05:05:31 -0700 (PDT) Date: Fri, 14 Apr 2023 12:05:16 +0000 In-Reply-To: <20230414120520.360291-1-joychakr@google.com> Mime-Version: 1.0 References: <20230414120520.360291-1-joychakr@google.com> X-Mailer: git-send-email 2.40.0.634.g4ca3ef3211-goog Message-ID: <20230414120520.360291-2-joychakr@google.com> Subject: [PATCH v6 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?1763154645722041612?= X-GMAIL-MSGID: =?utf-8?q?1763154645722041612?= 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 Fri Apr 14 12:05:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joy Chakraborty X-Patchwork-Id: 83380 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp337470vqo; Fri, 14 Apr 2023 05:20:12 -0700 (PDT) X-Google-Smtp-Source: AKy350azENlq3w4pOLsqcKHXn9P4Fdb1cDtGxSxvY9OXa4dlagzMDY98Q8caje1PRtTsdOCWcogR X-Received: by 2002:a05:6a20:7345:b0:ed:2657:8860 with SMTP id v5-20020a056a20734500b000ed26578860mr3946705pzc.6.1681474812020; Fri, 14 Apr 2023 05:20:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681474812; cv=none; d=google.com; s=arc-20160816; b=g43moPeyHbf25ByqaPNP6QX9tMV2N9qvW0qxmnRDOnsgPLd4dhaBcaqRI2Fu9BN+Hi QW7fg12lmNwzuN/stS+0ZcvkpxnjfuDjCeY2Z0G74Qy0gq7fnB4PgV9GUOjiEwc711ad RIicdwiP3jFAdVzfK7i0neoIuGfkuf1Fw7S69SgodqgqTsbI29N7Fzf2fd7F9euxH1PP QlECDAs+gfNpcp0Ux7FMxy2duErdkusElHLv62Nwr3McWzJraYTVwfNU1i6D9rn4U8eS zRcQWwwJeJpkuJ6pqvQrs0O5sk0QdsMG558wNUzMasCweK/MHuJaGVVzg/+YchyP75F5 rk2A== 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=65uwjwswhP+aUopNhPv3UiA4NcKEqdUIfoVkzM6bAyo=; b=yKQWQOna1l/ohIJQBDweJMR27O3L2L+13q68M+PSterUup2AJe4B6ZZ+bEbToWBpYx KrRX8LL83f4k9hg1a/i5pAcCqt2BGYHy6yFdyUStOZmO+xD+xCNqYV7aI/IoUz84ElpG 7u1eklX0DtyTyklv2P7SPSixwCqa1hycFBYzbDiuhUFsFS4JMVZ3idevRHRDx4fhGJsa 9CBlq0xOdPSNo00B+lSkSm9xDEF2UGLoAj/KgK+YlDSLkd8i43MDlJSURb58ex9EwiFg YaLhYAXYdyq0XMJpRofYWbd/ZqcV13DrY0ErsGgUSkMnO7yi0VtzZtKwAoiOU32ZHTDQ QhTA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=uQubCHw7; 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 r20-20020a6560d4000000b005181ce23024si4446937pgv.896.2023.04.14.05.19.59; Fri, 14 Apr 2023 05:20:11 -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=uQubCHw7; 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 S230209AbjDNMFj (ORCPT + 99 others); Fri, 14 Apr 2023 08:05:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57058 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229950AbjDNMFh (ORCPT ); Fri, 14 Apr 2023 08:05:37 -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 3D3E59EE3 for ; Fri, 14 Apr 2023 05:05:36 -0700 (PDT) Received: by mail-yb1-xb4a.google.com with SMTP id j193-20020a2523ca000000b00b8f6b82ec94so2504384ybj.18 for ; Fri, 14 Apr 2023 05:05:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1681473936; x=1684065936; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=65uwjwswhP+aUopNhPv3UiA4NcKEqdUIfoVkzM6bAyo=; b=uQubCHw71w6O5XUQutjA0LoDpSL+v+TuXE7SpijzhdY0JXfM0e0pQaW2iEN6icIOIn /s75BK6Tjvx1t0KMTqBurrQfuw3f6vYbuyu4tcYmsAXpvsr0nZKk1831iznXGpFKYWYJ UcftyaBaMnZ4i2G6zZJTBSS7QWCMH3Al34GMKx8XLeB2UrazIZsFWXpLrzEKvADfMYyX nuvtJjH8kJ9QMIgrJ17Rn0gQ+Dy+EVO6Yo8R0ZOaQ9LNL4i/jynn5CGsLzwBkafmpoa4 r4PdLkG5fgB0AJfp++xDofE0gCar0kFtZRO88adxNRP//ldNAki3n3toqaKsW0p/WsnZ fGKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681473936; x=1684065936; 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=65uwjwswhP+aUopNhPv3UiA4NcKEqdUIfoVkzM6bAyo=; b=hM9vp/0N/gA93x3MTrK88DacqwLJmaH6xDITRTjZZ/U60ZZKcXdZU0YNNfur/yFRlL QA24tDZ88cyLczs+o6rnjQAmXyZ5QZx/7d8icndalWYxuz54Rf4cThd3vsk8UQWrCjg5 rqyvGvhb2DbiZaCuBhWPn3J5EcCguTuD4os7jK9Y6YQXgkuGGUQM+3dZa3IKbvHfQjJV lc+nfxsIdQ344BTGh2dQXXwdaOaw2O0O0oDfyMVFAVFj2ey2Ngpq6yN3XqZ8SDSCxvPg 8NWuXYe6IrSQQ4mBCErDng8kMVfiHrmVEa4JI7SRFbcZ5iKTSld2y3GE8fJr+xojYTjL POsg== X-Gm-Message-State: AAQBX9doImSSfihsFPy8iupbXwVwP49IiIL7j1g6jVDzb6iWgWwP2Y9D ch/lixGkaVrWqIoykZnKvEAJC/jKp9+o0w== X-Received: from joychakr.c.googlers.com ([fda3:e722:ac3:cc00:4f:4b78:c0a8:6ea]) (user=joychakr job=sendgmr) by 2002:a81:b303:0:b0:545:1d7f:abfe with SMTP id r3-20020a81b303000000b005451d7fabfemr3555808ywh.7.1681473935975; Fri, 14 Apr 2023 05:05:35 -0700 (PDT) Date: Fri, 14 Apr 2023 12:05:17 +0000 In-Reply-To: <20230414120520.360291-1-joychakr@google.com> Mime-Version: 1.0 References: <20230414120520.360291-1-joychakr@google.com> X-Mailer: git-send-email 2.40.0.634.g4ca3ef3211-goog Message-ID: <20230414120520.360291-3-joychakr@google.com> Subject: [PATCH v6 2/5] spi: dw: Move "dw_spi_can_dma" function 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?1763154132484769225?= X-GMAIL-MSGID: =?utf-8?q?1763154132484769225?= Move "dw_spi_can_dma" function implementation below "dw_spi_dma_convert_width" function for handing compile dependency in future patches. Signed-off-by: Joy Chakraborty --- drivers/spi/spi-dw-dma.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/drivers/spi/spi-dw-dma.c b/drivers/spi/spi-dw-dma.c index c1b42cb59965..75e1b11af7c9 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,15 @@ 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 Fri Apr 14 12:05:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joy Chakraborty X-Patchwork-Id: 83378 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp336006vqo; Fri, 14 Apr 2023 05:17:55 -0700 (PDT) X-Google-Smtp-Source: AKy350anikxesPvvommWvNwkWE+XkIr0ClM2yYjdx/m5T8jCIAqZIRDNyh2eHa1PwTAyLUXUNf98 X-Received: by 2002:a17:903:32c4:b0:1a4:f7c9:33e7 with SMTP id i4-20020a17090332c400b001a4f7c933e7mr3053493plr.1.1681474675314; Fri, 14 Apr 2023 05:17:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681474675; cv=none; d=google.com; s=arc-20160816; b=keVwx8luHP5mGc5leFDLc7oKGCZAVReHOqPy5LwSHUAO2WZ7QE/rHc3/l5DGPDnesA fdN/YrvoCTvddYqZUF+SyPbWuGKfoSYHBqfdVYBDiOxpt5oKbGhqH5d7EkGQmiu2syHi 3fiqvchgBL59M3zKxBHk8DzerZN+C0NyEYFCc+0rrBsHhWfBfQk2Q3XIv3BREQ+lh9cN Us6TedCcOzLl3MgM5/MKYhpODW7sQ9x67xrskgI0xR2hDj2QBrZef+FTMs//EFZfO54e +V2iPK5KpBxmIuxVHvGtlqPndOi5HdrJUR9Or0i5s6KPSlzxB478rSc+5rbAQaIeTkf/ IQqQ== 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=mmE5jy/83AbiExum2uWOlw9WgET/yaio4sgA6DKa4Xo=; b=SMEXjzjIwrhqi5ZqjrKqK34cky33qR+8tpLbVRy9tftYOZ9LGhDMzNZt5IZ+HD1ckB pBJk/ahDyFM+dT2EJQvpQD6ZqvGO4tnKLcX/yNwwXMhnILhbpVJ5/mfr7y9Ze6QF0veT Q/9wleO9gBXWB/PCzLQHbHiiTW4Vf8miRkotn1b7nZJ35JuD/AQRpcrPZYj4H4iz5oX6 ieJWm8WV43Yx85uY62w3p3lpgC5K3AT1crnqNaXd3q9p/xmqJHf8bc5MgzafgY0ZEiKU iqpL9tWuugEIICy58bQ88QcOTvBGaUF24f5a8pQ+P8/ISFnJJgn+aM9wcaZHwSzomkwR g/mA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=CRnOvexc; 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 jh1-20020a170903328100b001a50ede507csi4432347plb.171.2023.04.14.05.17.41; Fri, 14 Apr 2023 05:17: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=CRnOvexc; 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 S230183AbjDNMGA (ORCPT + 99 others); Fri, 14 Apr 2023 08:06:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57004 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230294AbjDNMFq (ORCPT ); Fri, 14 Apr 2023 08:05:46 -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 18019AD27 for ; Fri, 14 Apr 2023 05:05:41 -0700 (PDT) Received: by mail-yb1-xb4a.google.com with SMTP id 188-20020a2504c5000000b00b8f6f5dca5dso1638002ybe.7 for ; Fri, 14 Apr 2023 05:05:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1681473940; x=1684065940; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=mmE5jy/83AbiExum2uWOlw9WgET/yaio4sgA6DKa4Xo=; b=CRnOvexc4uGaJtlXBpBxwAWjNrG2u375+vOuoxlfqXISvkbR4BgeLVDUT99nIw2Uy6 mwS8LAsYjm1VzgPyAPlrQt+NEim2Bcw48d1C0xYxN6Eq3+zRRfDdmD20DFxn6eRMPzgv klohmurUf0OZJ9ZGBoNOdxSkQFMHRqt7VFZ7YG6sTclCI43BYxTvdApYKOHOuGNe0Uuc jvI94OIMQBVfv5hzMM+bDRy4FB9sEtW2FR5WHn3nRNcYzVsnvBTnHNpWgRculEvIwbs/ 0LEnvMaNJJQDN5W0n7z7r88h8q67/zikyGBNTl7BbSTxp7GwtHe7dSuzswJ9GKyzkigo nVZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681473940; x=1684065940; 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=mmE5jy/83AbiExum2uWOlw9WgET/yaio4sgA6DKa4Xo=; b=VxzvLG2KPQvBq638J2fojUTuFvEhQq5BozJ/oMAfpN29l4wiZU+MNwHqZeSxtPY0iU EuxymaM8P1GAaeQzr8gqWKKuh8THSGCckFicIxOie1bnMJh0iBTKhBobIbySGqhr0pSh 2v2NbUaRsSCneiEO4A6EGHj7FgJPFwpGUn49cFBEll0I5GXKR+NS6Huv9oMecA3OvVBX oXn8rsfhnt+2UrxNuSH6ux87jynRpqT6+rFYjfTHlkMJqyvVBs1fMrV1mipLVFc/U2Rp UKpeO+WXZWDzIZbB0y/sb5fQWmHloiIwXb8D1rtyQcqLh9j+ocdQPA6chyPz4dm/uToa Bzjg== X-Gm-Message-State: AAQBX9cpE4ZMfMo36nlMkKyOyCeqrZ748r5siV0qihcOhKm7bNgSSdmL E1Jw6kqImL5TQBVXFyLc58rCcLbt5q9pIg== X-Received: from joychakr.c.googlers.com ([fda3:e722:ac3:cc00:4f:4b78:c0a8:6ea]) (user=joychakr job=sendgmr) by 2002:a25:da43:0:b0:b8a:7b2d:6556 with SMTP id n64-20020a25da43000000b00b8a7b2d6556mr3624830ybf.8.1681473940307; Fri, 14 Apr 2023 05:05:40 -0700 (PDT) Date: Fri, 14 Apr 2023 12:05:18 +0000 In-Reply-To: <20230414120520.360291-1-joychakr@google.com> Mime-Version: 1.0 References: <20230414120520.360291-1-joychakr@google.com> X-Mailer: git-send-email 2.40.0.634.g4ca3ef3211-goog Message-ID: <20230414120520.360291-4-joychakr@google.com> Subject: [PATCH v6 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?1763153989130875417?= X-GMAIL-MSGID: =?utf-8?q?1763153989130875417?= 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 75e1b11af7c9..e1dd13fe4fd0 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 Fri Apr 14 12:05:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joy Chakraborty X-Patchwork-Id: 83377 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp334766vqo; Fri, 14 Apr 2023 05:16:02 -0700 (PDT) X-Google-Smtp-Source: AKy350bszkuNJ9Uzkn4dB7K3i3ugIpK8H0dCvGiu0wfUV6Nfzgnh0mK2IjW3EhV/hWyb+XJR3fN/ X-Received: by 2002:a05:6870:2216:b0:184:8536:ce54 with SMTP id i22-20020a056870221600b001848536ce54mr3714174oaf.28.1681474561773; Fri, 14 Apr 2023 05:16:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681474561; cv=none; d=google.com; s=arc-20160816; b=sIyVSTlNIeyhWtwX4MiEfXSyrFOv9HSmix2eKEncA+MBpLI+gLYgfCfRTwS3xh8Uzr ndXebS3K6zfBVPJmh4cP35b6eGby1nFaNX9BjGTMlsVotpjwN7l4z4J2KVVleccYxU+u gfoURnTwi8FaiLRTCkhf3IY51gpGSJ5l66RgpCYbEfWdeTTrDGLnznmVAew3wRQhbPES ucrnd8n4In8hfLfL+RQFpd7c0+ZHQ+olB8lr+dOey/ACOehvkd36iCmv5FpMmNumCy7X OSHxbRJsy1FiXEtnW24ouwahQcx/qmZU62WMVOL7JEQWu6fWIYTK1k2iL9Hqd71VtUxE Cniw== 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=9Z3uzwpPzb9VI4QQ6yS9D24bwvkUC2CAvsehyf1JMvE=; b=DWykDGpoFfRftFzkP4afrqGqEJ20vezUCq1gEGHdoxWMKjttQ0JOhH5GTKPcpnfNij Fut2VmjYwyR6kHSqXvcedVw2BFejOjv+xdw8nizcPVAtLPWSNDy9wvqrUqxBt3Hg/gn5 L2lJhS93zZihxltYWs+IwORdir3V5iqu6sC0+wAHEz8NdsJ+tuwT1lFU4A0NVVKjK4e+ cV7ueEFieJrDDPTAW246g8tsilyj+OT+Op6uXi1wRVeJb5ELqi6kp3zizFoVa7r9rVCy zQNuoeEQnBM5ZFwOQ41GA29yNKnyzjgv3N4RwkUGNOgy/arUn8wixovRjorLF5pzsIJd DqIQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=Ou1uK5F2; 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 b30-20020a056870471e00b0017f17a1a81esi4038811oaq.208.2023.04.14.05.15.47; Fri, 14 Apr 2023 05:16: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=Ou1uK5F2; 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 S230020AbjDNMGH (ORCPT + 99 others); Fri, 14 Apr 2023 08:06:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57094 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230371AbjDNMFx (ORCPT ); Fri, 14 Apr 2023 08:05:53 -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 B5AD2B472 for ; Fri, 14 Apr 2023 05:05:45 -0700 (PDT) Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-54f810e01f5so100022177b3.0 for ; Fri, 14 Apr 2023 05:05:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1681473944; x=1684065944; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=9Z3uzwpPzb9VI4QQ6yS9D24bwvkUC2CAvsehyf1JMvE=; b=Ou1uK5F20L6r3e7SB7x5q5L0CnE5r9AV4LcR+uW9hQU807GkWv51UdfdG7hInhv4sM TNNn+GqUjNNfnHNcELyJ6nNkzMU/nFDuGtm7ka9C/fJFayqz1Y9IeoJA4Te8fjpMEk8y PWPDwfq3O/CTnzodGfkYJu2s7O42iceHNvs/hU1pMm+Dd1PFsUJUsbWWLEgpNOvvmq2+ c3kRMzcKSmWAj/UehpADE7vtrRG+TBX247ste/8w8NdDB49ftji2AUEcHCQ5HMny19sS C50QI8ZkJ022JaYREQbDb/jiIK4AVfkK4mI7aG1lYSrkGVnGDwTFheR4qlrcgPMGmHBy KycA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681473944; x=1684065944; 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=9Z3uzwpPzb9VI4QQ6yS9D24bwvkUC2CAvsehyf1JMvE=; b=PjRNf6WuWzaK5Drf79hyUjlz0cZPCbS6KNop7KD6Aq+pP9YhPh0l2WdfM4tf6quuOx 0p9T3ilxaJWbW4Fzjse4DYWP8cAFqFOIWwRcHrjsPbaFZxSvFGKMb7mLMqlATAuDE8VT bmpKRulXD5hYsQofqUq7Htrpyuz5J90Zfv8D8uIpI4St9T0hmRdkOyL4Q4wZaevZiiji 3Ldra/rSD3WQvb1Gz1PbZn7qgjK0Y4d+rAm4kF5L313o8NBOowrn1RSpD+8hKQ/M+x2w MAI80uLd8ryn8o94IFbnbtJo98Ukr7ejgYMxLc9L+Apl0NeqxsVKZEAW35NDHrAkjYuD +yiw== X-Gm-Message-State: AAQBX9eOiB/tw9ujm6qS43ZseVILcSgkDqVr7RLmnDHWwUB018sWInrH 8RzseOqzl+033bzC+LXpjNjB2maQw4ScVw== X-Received: from joychakr.c.googlers.com ([fda3:e722:ac3:cc00:4f:4b78:c0a8:6ea]) (user=joychakr job=sendgmr) by 2002:a81:af1e:0:b0:52e:e095:d840 with SMTP id n30-20020a81af1e000000b0052ee095d840mr3677516ywh.0.1681473944443; Fri, 14 Apr 2023 05:05:44 -0700 (PDT) Date: Fri, 14 Apr 2023 12:05:19 +0000 In-Reply-To: <20230414120520.360291-1-joychakr@google.com> Mime-Version: 1.0 References: <20230414120520.360291-1-joychakr@google.com> X-Mailer: git-send-email 2.40.0.634.g4ca3ef3211-goog Message-ID: <20230414120520.360291-5-joychakr@google.com> Subject: [PATCH v6 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=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?1763153869933167152?= X-GMAIL-MSGID: =?utf-8?q?1763153869933167152?= 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 | 17 +++++++++++++++-- drivers/spi/spi-dw.h | 1 + 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/drivers/spi/spi-dw-dma.c b/drivers/spi/spi-dw-dma.c index e1dd13fe4fd0..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,10 +245,15 @@ 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; - return xfer->len > dws->fifo_len; -} + if (xfer->len <= dws->fifo_len) + return false; + dma_bus_width = dw_spi_dma_convert_width(dws->n_bytes); + + 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 Fri Apr 14 12:05:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joy Chakraborty X-Patchwork-Id: 83381 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp337573vqo; Fri, 14 Apr 2023 05:20:20 -0700 (PDT) X-Google-Smtp-Source: AKy350Z+ORRG1NdJiukucJgoJLiwpIeLcq1tcKrnvjEjkbn4npECFmzTunpACO9lN11CuPFlA45h X-Received: by 2002:a05:6a00:a05:b0:5e0:a86:a76f with SMTP id p5-20020a056a000a0500b005e00a86a76fmr8028246pfh.0.1681474820421; Fri, 14 Apr 2023 05:20:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681474820; cv=none; d=google.com; s=arc-20160816; b=mf66+vhlE4H1a1T83d4+XeMDshbU35Tv9wsK0G1ucMOdf7ZsAeCPc9Db1BPvsE03Qj nKAet4d1A5/Yb8baiZbZD4ASiomUADz2qldpQD/ggVFK3jOuQPQzWsUarPTMHYm3WpZl m5EYljiVbch1qjZRx94O7lKIhzrdOPjc35DIRtc//czIxGu7UlD667eLS5WUmyyItUO7 SmvVS2v06bAQNlM1OyNGdBEQOYVom8/HvgnaTcOM7sQtdetLUe7ZppVrEOgMgZB8mXId 9wK9/hSE3QO4bvrCxt8XhUNCKEiX/eU0kgLZVRHWG3PciAzYI0FpDXuTzf1ALyAXZpGk 60Jg== 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=eOOvcTL7f+f1mVpgahzfJtujlaTXydyVpOAlXkjulkzodz3Y05FWUxturpidUZX4+u G1lWuXSzimUTSvKBNtG2IVOAoKvQ1x64uWUPomCcGWRtG8BF8gEo9W3VQRV8IR23DCNT LnwgyIYM8SFwtGWkJJzdc49KakcQbNQ5dbdBqbnjE0IAXM1C5FRqPG6Mb5flIOJjrSnX ulv46ImirOVMEx3G/Hg30z1Y2vvyLRQ/JfNpCfeF+By8PBEwbEIQ0jMqCJaJE/gJIrGE INw92e102g8z6eduacYAoF3+Zuh0GpRD44i4JXGAmmiv66nplh4N2VHWmsN0HH1KQrIq rDhg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=BjBk4IFf; 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 n8-20020aa79848000000b0063b13efdd06si4233946pfq.345.2023.04.14.05.20.07; Fri, 14 Apr 2023 05:20:20 -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=BjBk4IFf; 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 S230267AbjDNMGS (ORCPT + 99 others); Fri, 14 Apr 2023 08:06:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57798 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230265AbjDNMGN (ORCPT ); Fri, 14 Apr 2023 08:06:13 -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 C884FA272 for ; Fri, 14 Apr 2023 05:05:49 -0700 (PDT) Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-54be7584b28so301391887b3.16 for ; Fri, 14 Apr 2023 05:05:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1681473949; x=1684065949; 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=BjBk4IFfphPEvkF6oNu0FALs6uDTF7SOGFv3xTJX9fN+uejADR6Jzn/lNLnIuNHVaS 7rK0a+DvjrxnYz2Nc6HcVasynWLHhIY2+xJw9uGOOQYkxclfiVPQrYrB/7tyIMsM04j0 tt/ToVH+x2LAv0Zk66w7fjuo571bhxyaYUbq4r3r0No8bHmqgiZz0sTryCw7bvu85vKX WIF4wo+llgaXEzmoubYyqe5rHKGjcJ7q3xmHdwAyoWE7mITNRmDV990wb4UToHE6vdJB 7nNI62LjTFqAyebdPa+uMh8n7u5b7PWA+50T1QrAiKnlYZctziaSErhec27QXUPE+JXD iK9w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681473949; x=1684065949; 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=M3JFk8GJ8dL680NGeKttMNtukxY3kLSk9K2L+OpiTIgoycNCE2daPMVCizs0JKkojO RwYULKPs1h8/f90SK6W28b2R4u/mR4wdOALAuMQIvdM56FHxYeOtMPNpa6KIQtqwdH+1 JdoUIBXLkxZ44sRTPY4xt3+2udU8TPLeihRj+XaBi6wFo/VP1j+TqHBfzOV85turNqni 5u/juuF+LhzMVEKb/jlKEkLxZ6BKAkK6igXHbvRgrzU61uqfpDghtyoJ23G0MFCxjmQi gXAdKzqQIkoDyfyVWZ2jNWz230NFdM2QUUWJR4qbreB7Ud1ZJoTlx6b5cSPDWnp7yPcc vzOQ== X-Gm-Message-State: AAQBX9dEA6ZQ9p5DFMUQUZZGdnyaOtpuHR4jybarZYwYQMB5CzTsDESZ Zt6FoTf7PYE4ZX3fM4+TS4luc8l3s9dhpQ== X-Received: from joychakr.c.googlers.com ([fda3:e722:ac3:cc00:4f:4b78:c0a8:6ea]) (user=joychakr job=sendgmr) by 2002:a25:ca83:0:b0:b8f:6944:afeb with SMTP id a125-20020a25ca83000000b00b8f6944afebmr1727314ybg.3.1681473948816; Fri, 14 Apr 2023 05:05:48 -0700 (PDT) Date: Fri, 14 Apr 2023 12:05:20 +0000 In-Reply-To: <20230414120520.360291-1-joychakr@google.com> Mime-Version: 1.0 References: <20230414120520.360291-1-joychakr@google.com> X-Mailer: git-send-email 2.40.0.634.g4ca3ef3211-goog Message-ID: <20230414120520.360291-6-joychakr@google.com> Subject: [PATCH v6 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?1763154141303777433?= X-GMAIL-MSGID: =?utf-8?q?1763154141303777433?= 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;