From patchwork Thu Apr 20 05:51:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joy Chakraborty X-Patchwork-Id: 85723 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp103138vqo; Wed, 19 Apr 2023 23:02:49 -0700 (PDT) X-Google-Smtp-Source: AKy350Yc12kDcmzIBkLx2QL/8qvkQ08cGcy700dNK1plRMPd2q9nD2EEYkqODotj95RTcEkgCT0c X-Received: by 2002:a05:6870:468f:b0:18a:ff22:1fa9 with SMTP id a15-20020a056870468f00b0018aff221fa9mr400002oap.3.1681970569431; Wed, 19 Apr 2023 23:02:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681970569; cv=none; d=google.com; s=arc-20160816; b=0NmugqKS+2dtwOS9Q3L8lj9mOd6FW9wXi8p0lOa0NxKPp0CGQbVAfvcoWAs6+J5pA8 9Gz554NoSWXbLbeBWB7XbRGA3NlEihN7pMAHmyFFZ1a+S8OqPjb+75xEdnojm+9wRM5x GyT4EcXetDU6TlQGy+a22pK7iyy53HIyxwpjOyXfNoTYggxLyVvfpimeu3fhKjtlkQPm a5DR1M0lbxm2wTbdocx2yj4+se2VLa6bWdIXANHsSGuUKumlTX3WnqmAdWwxGKxT+PcL +VwEQu2q+iwufve6JYHr1ruJ8RXahLdJ5Iw0dz+46C1dr6m9DpVN5CDlzOeMEZIDYdp3 yJkg== 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=AMVB0sESvzih2o0A5qBbjpwsdbdXSmMhD+zUx2VIaa8ReFYM/K+GKPheTpisVnRoGV azg3GxvGb9ubUyZnNo9aCDeP0AjTJyHsX7i/ZcDcL0++tE1qR7w3N9jnyXHwHFXSOvsz Wp0pn2vbqMYE194idwGbos2ONtihZQ+ZoOAanw22XGWxVeWOk8J2x2RrHHU4I0o8gRf1 ylEJmfCScGoL6fczzTJwBiJogspiFxicu4nchSe5EKFTWl6X/1MtVKhKBxlRofs4rQIW fl+tzpxN0pjJCy2gxCku8Qd3Sf3Q6Ptuj6baBYZPlfDHxUzzsEMX7Di7C95CfXM88Rmq sIkQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=hBdio5Hu; 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 p23-20020a056870831700b0017262d9baa0si1133047oae.67.2023.04.19.23.02.35; Wed, 19 Apr 2023 23:02:49 -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=hBdio5Hu; 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 S233748AbjDTFw4 (ORCPT + 99 others); Thu, 20 Apr 2023 01:52:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48748 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229496AbjDTFwx (ORCPT ); Thu, 20 Apr 2023 01:52: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 58C9240D5 for ; Wed, 19 Apr 2023 22:52:52 -0700 (PDT) Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-552e3233b26so14706277b3.9 for ; Wed, 19 Apr 2023 22:52:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1681969971; x=1684561971; 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=hBdio5Hud+tuSe+ZQm4GoT0N6QYKFYKojEcyGL/qjoyc/axMq0gDkSpE/VFgh26tbc 9q8iGkzUfuitRECTe5d1TJDHxKIm68sYk9FF+2MLlGf8ehbAadYIXFn7QdnMecMeY5Fj LRSXD3aAKe5FaJ/yWBXcVwVpasAaWJ1hXi4lkvhtQFsmrlluih/cIQc+YesdMJaAPopG p4ZeKe5wK2visIca0s9Uq53oKncjovWGL61aF0nIW5v3YmpZuniZF0+u3C6jjLrI23Bj 1EzesEb/RvRHXb2DfDm5DByZUrgffeA8os1m2UO1GM0n12djtpg2+3JkRZCaF+HnRb5K jqlw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681969971; x=1684561971; 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=WZZPf2rqWl7L9L+JCKgWFm8mDuVSx+A/0vQTVjXu4AMhn06MZj9oaVtBJmOPla5u/u wJZSlBK7cAFYYxp1c6DNP9Re9JObA+LOyEuzXuz7QhxcQHpILPSIakf2xGZxR2pcIMmr S/FkhAs4U3PpVqsp+6cbBLD0mvui1POKYyaGibAJkTBPhf4vS+VVTDv+eb8dPbWedLcL FBG08x9QPZH4qYyGNpdlIKDgi+GMa9P4RRzgkeigmi3+U0UjDP1WGjHQv786AGYHIoiK 41p7wLnX9BUgPX+yFOyjMs2Kit4OMokt1I3JFw870rNNqArpLMTulqRDsdxyAo1tQNSP Kstw== X-Gm-Message-State: AAQBX9c/i6ClpFW8kxh3oE4fKEOMmxxHEBAMLeudKvvBFDBKTu91k6cX u+GTAIQjhylV0QvsBNkGhL9JEzmhOAyj0w== X-Received: from joychakr.c.googlers.com ([fda3:e722:ac3:cc00:4f:4b78:c0a8:6ea]) (user=joychakr job=sendgmr) by 2002:a25:d284:0:b0:b92:2c78:1481 with SMTP id j126-20020a25d284000000b00b922c781481mr308871ybg.12.1681969971649; Wed, 19 Apr 2023 22:52:51 -0700 (PDT) Date: Thu, 20 Apr 2023 05:51:27 +0000 In-Reply-To: <20230420055131.2048959-1-joychakr@google.com> Mime-Version: 1.0 References: <20230420055131.2048959-1-joychakr@google.com> X-Mailer: git-send-email 2.40.0.634.g4ca3ef3211-goog Message-ID: <20230420055131.2048959-2-joychakr@google.com> Subject: [PATCH v8 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?1763673971847903185?= X-GMAIL-MSGID: =?utf-8?q?1763673971847903185?= 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 Thu Apr 20 05:51:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joy Chakraborty X-Patchwork-Id: 85722 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp103139vqo; Wed, 19 Apr 2023 23:02:49 -0700 (PDT) X-Google-Smtp-Source: AKy350a9OgUtg88QMc76NC+muKvcMZbKQT5V4y/rmYpuvWscG1kuzT/ronK46fna3VF7uYKcsIdO X-Received: by 2002:a05:6830:1309:b0:6a5:df69:f73a with SMTP id p9-20020a056830130900b006a5df69f73amr40949otq.16.1681970569561; Wed, 19 Apr 2023 23:02:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681970569; cv=none; d=google.com; s=arc-20160816; b=UkDjD8HRIHbqEtuVeyhe2ku7iKY1hLyK5IhvwhMpmN+G1k44ctO/tE+7kSQZHGntxO nxqNEoRMqR7+NSUIP5KOzO29rodDJ3Ue4L9Dqm0ndJILZwyuBUVwjXZ64np1Ao9s/mds p4NguW4ZqPj1Oxcs9B+voy23BpGzam9cN+vVy7L9hHsH0q9GFrl5fbwByNYk9u+lJu5b koLsLQT9a0FAwZqgqY1nTVoacZHPt/TJGpS+lLlPHgt9clAF9CRZvzQG0BKOJgEfoxci IN8Vwl30ygx1qtwwajxC6kdygMJf2KDomkfHh41rUVbtsYVYKxlXl7HFUbrZvqLR3a/T Q9XA== 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=jAMNlsrbtxU/IuToBPyI5BFmKXFg9RkPtVH3j+DJcRDBgsdSTBeeyqXllz75c9OV43 p5/NgDeDzkYm5C7Pi2ibjrm/8iEzOYBw5Pi5XR9hZHudXoVZBPmYAypCX2r4KatdQU9p G3kRuA2339DLX7QSuVdqCNi33K0RcC3cPHycrPwScJDaTOyX5PVyiERWNsYj3Dp4s5X9 BRpYy1JiUTNp7DXfahQBxxYOnhe9kRz/4NFBkmzWV1gYqTlr55QKxqQnxgGKI6ekwd3g j6uSQYPuzS88oB/0dnhXRp2qwzo7gyE2RoLzbb3euFPA8e14KsWmSHdUg4z2/qZrD3zV 0KdQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=GYjayEHT; 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 y7-20020a056830070700b006a5e24fadaasi1245081ots.125.2023.04.19.23.02.34; Wed, 19 Apr 2023 23:02:49 -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=GYjayEHT; 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 S229496AbjDTFxF (ORCPT + 99 others); Thu, 20 Apr 2023 01:53:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48970 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233794AbjDTFxB (ORCPT ); Thu, 20 Apr 2023 01:53:01 -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 E599840EC for ; Wed, 19 Apr 2023 22:52:56 -0700 (PDT) Received: by mail-yb1-xb49.google.com with SMTP id e63-20020a255042000000b00b953ca0cf4eso1384141ybb.12 for ; Wed, 19 Apr 2023 22:52:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1681969976; x=1684561976; 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=GYjayEHTH0DTFM7kLY9bVfMA2J7m/p62X4TtHqIrE81LrGEdzUtYqYo+3PqkGKe/PP xFKTLUmHAalIQMGpb5k7bntgsjNGP0pZPo4Na5+8sawig3szQDTNnx25Aq31dRhf41we m7XlLrEnhZfXFcS1Rwj1lnrvIoGm+j9yPTsQLQjZmDtx6mRbmAxSM2Pr+g3zYCQYPp2X MktbbEevw9lhMaNqnpy0Q4NgotUlEfww8ij7NuvbU2VHsEwHYKFhdpL/nipcBOvMGYwq SsQZO0hFLViLjndPQObcqY7+eZq9kXkjCRunkR5OxygH+N2I7Y9DYlohfTWdLtcRcvqx fcJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681969976; x=1684561976; 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=GDdQGwpHEY6rYeyt+m3YA9xLSUHDJDSTWy1XvP3V0my8hawBl6ahltzQ+zl8tqgLPm NMnyHyciwiXTRcmOcOMobr4C2Hix+ms3GhbUYrEKdeiYRxdHyjg6FoGCvlhY52/+aUP7 h4JZdxfQLUgC7o8JG/SLeHj0SiXMyUkGSJVjUJtYMvs7RPGs6BOOESZffBwX61N+8PPJ QrgfUJvIHCdTVNlyfzjdTgZ3S3Pr7H+HRBYpN6eJmcUOcQNuFtQAnBqMitibtVF8YP/P kjVzio7RKP40u03jPMELQguog91TeTFDYEIBYDhJG3E00qriBosSlu2xN8DSgbkMgPcJ 4c4A== X-Gm-Message-State: AAQBX9dDCF55aJaR0Hr1Q7dGT3hV66NKVDQpvN8KzElfX+pN2qYJ1PUy kX7zWvuRshWn/9YQjSwmae4mz8Wg9iekAA== X-Received: from joychakr.c.googlers.com ([fda3:e722:ac3:cc00:4f:4b78:c0a8:6ea]) (user=joychakr job=sendgmr) by 2002:a05:6902:1241:b0:b92:238b:574a with SMTP id t1-20020a056902124100b00b92238b574amr1547530ybu.0.1681969976120; Wed, 19 Apr 2023 22:52:56 -0700 (PDT) Date: Thu, 20 Apr 2023 05:51:28 +0000 In-Reply-To: <20230420055131.2048959-1-joychakr@google.com> Mime-Version: 1.0 References: <20230420055131.2048959-1-joychakr@google.com> X-Mailer: git-send-email 2.40.0.634.g4ca3ef3211-goog Message-ID: <20230420055131.2048959-3-joychakr@google.com> Subject: [PATCH v8 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?1763673972048665887?= X-GMAIL-MSGID: =?utf-8?q?1763673972048665887?= 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 Thu Apr 20 05:51:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joy Chakraborty X-Patchwork-Id: 85721 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp102697vqo; Wed, 19 Apr 2023 23:02:12 -0700 (PDT) X-Google-Smtp-Source: AKy350YmDRxNmUPeuyDtUpiH7tdU4HCR9gmOTA751tNFni6PtFwd+exepmJL5L5NnXc221gp0NpT X-Received: by 2002:a05:6a00:2d14:b0:63d:254a:3909 with SMTP id fa20-20020a056a002d1400b0063d254a3909mr7228787pfb.32.1681970532005; Wed, 19 Apr 2023 23:02:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681970531; cv=none; d=google.com; s=arc-20160816; b=Aa74EAUmXJtlEmRdeF1O97LJNdjFW+kxXZAVSNILW/4KDQYYpnUFcDBmcs2sLKyGMf dQv3ILWXHjxdsjkEaeChTwGkhOZ345Jhh/x8ofcE55WfHcG7PCqC4tLqS1NaLBVOrinr 2uR3E/4A+vz21IwCAh3/ND9ac3eX7KsQtnqBEBLY5262QeByBd5ev/JQirTpB6ymTSQH hS9GkI8P0ossIWef6BGDxie31LFSPrefXkMoKHd6ssx+TaqZWyvvkBhIyFSlW+S7U19o WTLdHBdKqK6b3xon/2FCBFNGyJ9IN22pAM3wG4ZSgMdSRyEllcNZoDR2nOe0H/PF/KBX HOOA== 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=pfnmxeQLY8BSs/Pe5XQtCYiloq4k8IVfaiu+km6dCYuvxDW+nlMYK7/sFyXESZgEfT fnkVvle4eQjxOd+bRnv2ePHfHHMQ18tpkUV71O3O7H4hvl9nUlLRWUiV4FCHBgVjpHAM 6kg22HMBdoLw/PfqKWQ+muLz0uwsVm21vPzzQGDSK2kN7T5Y5zGPogq657BfyOJsU1MB 6DYgj1Xf8HyKhNulG9+1sKfLAU8g13wWvwC8MaMJXgDnX8ylru/zBxhRB4XN9sD7VdcI yY2SN23zrTJZlTRhc1NlnyZn82g8JZQZhGwSLgVt/uWVgth0rJwRVsO2VAFEAfGOLSnM z4Gg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=Nic2FQHT; 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 x62-20020a638641000000b00520a879b9cesi855352pgd.3.2023.04.19.23.01.57; Wed, 19 Apr 2023 23:02: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=Nic2FQHT; 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 S233812AbjDTFxK (ORCPT + 99 others); Thu, 20 Apr 2023 01:53:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49132 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233777AbjDTFxH (ORCPT ); Thu, 20 Apr 2023 01:53:07 -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 214334200 for ; Wed, 19 Apr 2023 22:53:01 -0700 (PDT) Received: by mail-yb1-xb49.google.com with SMTP id 188-20020a2504c5000000b00b8f6f5dca5dso1393198ybe.7 for ; Wed, 19 Apr 2023 22:53:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1681969981; x=1684561981; 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=Nic2FQHT1rZcir8AOnmbrVQPU6NAfnIjYV4nIHCfkVKQ/GoGbaNkbxtwGkF5Om1bYv V6+uX0yYKgWBiNd9F78J/n+s6PyxBNJXg4LkdJcVUPRmgGAEBmeqIC+zwvTTD5D5M181 ZlTGroz/DAtZMujsWNJ983a47tVbO9qmPah4pS3s9yldeH2ZWuq6rVgQo6RdfcAqtzY1 bHnv7Alw7+AnTco490Jm5j0ql4RFj27sUppjmdlMYnTHjF3wkGFanlbRuPMwlHWV84ZY 4rjkPUeogytWmy9OebXbApw2ftvCJty+sqj4lF1H2tD+fYAumBWj/H9o+OBlMa7fpyfX kNYA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681969981; x=1684561981; 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=ld4PciWqxLt+oUYa0UmMIQJ81hLvooFDO9AgsigLxf01u8D3EWSwTxJ9lSo/r/NX7S 4/QBeOO8pH9tb5uzp38AaDcGhhW3rbA8dRR6Xlpb4WV2naIcClCNUctmzp5873GNkekB xMz2YuvtMOvipGZ8/bK2qcidYg6R/9mcyTOuBDXbfdk+kCIoVfbBfBRdFDtcA/7Nd9ov ByjM5Ey+xo6fRHK6wsBWz2zgimzw1Udc6rmXdGdBkvnQx82ctOuPBZA/zOfqSKRtEyeU ujeSXoNYsE+If4oxhfVUGFzb5lJ48y4zPwWVvpTW1otxHUaRjucjbzHUJ9cldLtRahC2 7pfQ== X-Gm-Message-State: AAQBX9eJsqXjRd4OBVsYXdrnsbjctJ7HJP4bTH1DJV5kvdjS7W9+quVX zTpfEN3CnoH+Tmx225JXYy9JcFvKScFOTg== X-Received: from joychakr.c.googlers.com ([fda3:e722:ac3:cc00:4f:4b78:c0a8:6ea]) (user=joychakr job=sendgmr) by 2002:a81:b625:0:b0:541:693f:cdd1 with SMTP id u37-20020a81b625000000b00541693fcdd1mr3450551ywh.9.1681969981044; Wed, 19 Apr 2023 22:53:01 -0700 (PDT) Date: Thu, 20 Apr 2023 05:51:29 +0000 In-Reply-To: <20230420055131.2048959-1-joychakr@google.com> Mime-Version: 1.0 References: <20230420055131.2048959-1-joychakr@google.com> X-Mailer: git-send-email 2.40.0.634.g4ca3ef3211-goog Message-ID: <20230420055131.2048959-4-joychakr@google.com> Subject: [PATCH v8 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?1763673932899566189?= X-GMAIL-MSGID: =?utf-8?q?1763673932899566189?= 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 Thu Apr 20 05:51:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joy Chakraborty X-Patchwork-Id: 85724 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp103193vqo; Wed, 19 Apr 2023 23:02:57 -0700 (PDT) X-Google-Smtp-Source: AKy350Y6t1UvQqdbhXdEXHJFQOxrC5QgYJCJAhXWu4lioiBPSGKEJ9J2MPdMQp/jjaY92l/lHlI5 X-Received: by 2002:a92:c0ce:0:b0:32a:a16c:d28d with SMTP id t14-20020a92c0ce000000b0032aa16cd28dmr557095ilf.12.1681970577672; Wed, 19 Apr 2023 23:02:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681970577; cv=none; d=google.com; s=arc-20160816; b=gJOiva1Eg+lI3dsPfnKgmYPlfTQzPWdVG/GgY/suzN/WuV+6c2UFwSDO733Ehu3AtT KRtq2yr0sBwhVQCQLI2qlItL8oNVy3BLfcp0iaLVFb9iaLtGyV89bvsGxTeYB4uQFytX qFyP3I71/ARtz9Z1gC5zkUKAPj17Huc+FpdqZFp5agL3j68w9WzU7XodhszvZDqD9QcF kCQNpowY0jHitolTKyyvXQJntn8KWLS/rrfeEbDx2wILytylgAeVItewyySeDYkN18F1 HS8mTTqUJEKtasHh9h21n+3DnQytuzC3tTVXP03PFnyAq0Rj7y6SSUGKKKuR4qYmf+6S zXHA== 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=1Pw11IJF74xsEjxmIFJb01azmaJEP3MTEgikPdGTfV0=; b=p8Be1ITZYvwoRuzJujwNaLkbgMcdQ7dkLXgKZuTrD6ZVEo0woxI3DrtClB7XtSOp7U OOf/UvEa9PCoRoEohq8s79NYe0haMk+/nL6whfOjvZy0kGNZT9ljCA8UQA18DsvW1ba9 ABVXxvc56fDbcGakiHPlNQ22b2eScdFix6AqyACKB86/gchSr0ZXTgD9HaQWfKzgHVAT d/QhwRH+1OsxwWu9F4DLvdfyLlVQSjuoeb9qt3tka78Ha28jAFvuqrAHFW8NApnjp+cl 2wYxCNocxOIFxkkuPrFbUr44SvjUalrfm/Gd0XI41q1vKCzh1XkTS7jq71mX86NwgBU3 Yy5A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=Ghdjh7vA; 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 l9-20020a922809000000b00315586ac107si1012630ilf.168.2023.04.19.23.02.43; Wed, 19 Apr 2023 23:02:57 -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=Ghdjh7vA; 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 S233824AbjDTFxY (ORCPT + 99 others); Thu, 20 Apr 2023 01:53:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49468 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233838AbjDTFxT (ORCPT ); Thu, 20 Apr 2023 01:53:19 -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 B4CC559DA for ; Wed, 19 Apr 2023 22:53:07 -0700 (PDT) Received: by mail-yb1-xb4a.google.com with SMTP id 84-20020a251457000000b00b8f59a09e1fso1394739ybu.5 for ; Wed, 19 Apr 2023 22:53:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1681969985; x=1684561985; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=1Pw11IJF74xsEjxmIFJb01azmaJEP3MTEgikPdGTfV0=; b=Ghdjh7vA1YPqlAZpZKBCngCnmwyCqEnfPR3DWXDkkfIn5X9nZY7Cm2lQCb5PBIXRma nBj2ld7j3BXfFLqsWYVXAVfuRaBlCLDXVsDiem8dshSSwvY+DOvGotlqaer6eF3ujaao V9pGdoJqZp1yvMmDhnNzv8b1aWngib70WDj0h77MgymbkKIFESsdG3019rClpkpWj53v 7jRDPe1+eNJHSyNSyz5sDRVRrXs8ueAQy/l1+pN0aKlr/e66XCA+RdiMxCyR8TTVueFi wM9QojpXSDE9EaXtMNllPxU3HTe/hbe82gr6VtjUromEji66LTWH3RfFrX1/++liNklN gyIw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681969985; x=1684561985; 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=1Pw11IJF74xsEjxmIFJb01azmaJEP3MTEgikPdGTfV0=; b=AHHuItYNUYM70I+CxEX/QUdszBqZfMM1sB6zEhAb/kdRTuTuMQOz6atoaCQakdYIJn zffJ4LTho21SoaO8rtYqUF5husBShK1EGqJ9wo4WF2avMhKraYVFhlDYVbsWd/+rNbI2 34+RdYjYmqxbDLwkTd8YwCyAkK+DkI2jwXcnWooGyVZkAVDu2PFuRfzE3bsGVqsea00M UNbqmxPuNkHTd187S+Og0ZETKum5FFtzrdw1P2cGoD89FeCmPvqE2pLhAn2DXlwUQW8J jALmgtMC9yn4ZCAhatnCT6N0aY6v9bTRl4BIEmaiB7yw0KeptOfY9hrNK2sMAkMbHdNl siWw== X-Gm-Message-State: AAQBX9cIoWj5BuJnF7Jrm3u2O3C48C+xtOWIi5bmWYKEYhMdkIWoBorV Q5stRxEYdvtn1N7geqiiQ3ZiswKaOuoacw== X-Received: from joychakr.c.googlers.com ([fda3:e722:ac3:cc00:4f:4b78:c0a8:6ea]) (user=joychakr job=sendgmr) by 2002:a25:ca4a:0:b0:b96:7fb0:f927 with SMTP id a71-20020a25ca4a000000b00b967fb0f927mr309752ybg.12.1681969985826; Wed, 19 Apr 2023 22:53:05 -0700 (PDT) Date: Thu, 20 Apr 2023 05:51:30 +0000 In-Reply-To: <20230420055131.2048959-1-joychakr@google.com> Mime-Version: 1.0 References: <20230420055131.2048959-1-joychakr@google.com> X-Mailer: git-send-email 2.40.0.634.g4ca3ef3211-goog Message-ID: <20230420055131.2048959-5-joychakr@google.com> Subject: [PATCH v8 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?1763673980327409662?= X-GMAIL-MSGID: =?utf-8?q?1763673980327409662?= 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, 17 insertions(+), 1 deletion(-) diff --git a/drivers/spi/spi-dw-dma.c b/drivers/spi/spi-dw-dma.c index 22d0727a3789..df819652901a 100644 --- a/drivers/spi/spi-dw-dma.c +++ b/drivers/spi/spi-dw-dma.c @@ -97,6 +97,15 @@ 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 + * 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; } static int dw_spi_dma_init_mfld(struct device *dev, struct dw_spi *dws) @@ -237,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 Thu Apr 20 05:51:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joy Chakraborty X-Patchwork-Id: 85725 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp103353vqo; Wed, 19 Apr 2023 23:03:13 -0700 (PDT) X-Google-Smtp-Source: AKy350ZgO8qFiLTrzPvAlntsGc74NQSrklaLzOKco1o3WmdY1Eo2/Vqk8AE4FQPxu6lsQQR4YnGI X-Received: by 2002:aca:280a:0:b0:389:234:6107 with SMTP id 10-20020aca280a000000b0038902346107mr326941oix.25.1681970593282; Wed, 19 Apr 2023 23:03:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681970593; cv=none; d=google.com; s=arc-20160816; b=HLIxbesEyut8vO4w6a3xRvkzA2qIDj8IIfuIsHfAIx9qJLEsP3mYug76U/RuXt4iSz c5UoNuk0qtekzPs6a2IX0577QrPVRslMgixKOgQRsP3NZd1DXvr1G/PIR1HzeFcBZJSF UeQg0hs8C7YEcyeUpaCszDa0YkuhuhLdAslwbi96iMXHPlyv9p8z0IjlY8TYss0YkcSq iGq9njTQur8/ZYjpWn1iycd4iEWxumcOoumOeZRgMZhN9SQ4FCzWXlWFFzFlm+djoqCZ mG5SKx5BXyIxNbcFSW0PwcZMeclQXSc+XF2d9V7Onf6LSoTyCMZvzAx1zyXBwTlYg8vv wIgA== 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=iO/fEp/BsQC41PC1QuH2cxT7T+9h9UhwnMxo1CRSG0GQIRSjgTUn23iNa2+v8RgrKH CRPnhhnkAVcluP/JnzCrpCYlAbbZW9t2owwi5g69QZfvg0OF6JE4iLilim7HJI5Rn4Xv gnXrRLpLplgMkJPtYpQf3XWqil1Gu4PaEhfm0PR05eNu6kCBZ1MZNilvL75rzNA4gYAU nktswA3iY2FhbtFx8yaB/MrswD/OxE3HGJ+3fkKlA68Lutni4e0KJ+CyOZzN4G/QL1W8 +qrARC7k/85lpUcQMQ/QHjFF7UqCw9K3s9rU0jANSVEvoV8J/14IqwofS1DIiTAVJvsn 33Lg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=wP4LdQuS; 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 r8-20020acaa808000000b0038cabdbe3a0si821463oie.7.2023.04.19.23.02.59; Wed, 19 Apr 2023 23:03:13 -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=wP4LdQuS; 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 S233822AbjDTFx2 (ORCPT + 99 others); Thu, 20 Apr 2023 01:53:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49424 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233823AbjDTFxY (ORCPT ); Thu, 20 Apr 2023 01:53:24 -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 31C8C40CA for ; Wed, 19 Apr 2023 22:53:12 -0700 (PDT) Received: by mail-yb1-xb4a.google.com with SMTP id 188-20020a250ac5000000b00b9265c9a5e9so1359998ybk.11 for ; Wed, 19 Apr 2023 22:53:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1681969990; x=1684561990; 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=wP4LdQuSoesNvn/B4nq+v65j9QBURAtfrTfJclyIGQZl/zwlfdNdJk9rDvE+kJen70 KrMp944AeYP1jG4zsWJL8KqCjL7ehlImk2NQGbHDJXbKlV6ksBUb5Szyn63HVFN15p9X ZdZTIiKtAlOSw04ORDBVFNr9N1YF6VreBh6brM47mSF8r2T7YO9s872kdz6IUsOraA4B XZgr783K4qPobQTNyib+UTF9lzfKpDUudWPLkzkgdi8XDkeEqfoRkm4OIRbSCRjYB5cN sG+wM4RZqUlfjFPfWoc2QLvy/yXVDJxN9SM2P3SkKfFV6DTfkbKBDuZe8XiaDjpKhDr0 4u5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681969990; x=1684561990; 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=QdehQp/+queeEZwM3FT0oPtYK3VnNOsCfXlIpSFbOjO902VPIn2lsydTe/RvrsdO1N gYk14MaDfvziK68vKBJbg0drDa09UQhKf46gOjS8wQZ1pYbvmoyl0UCl3YvpztycUpg0 0lft2TQhsENJhc8/xRzeYVOPRiAQRrCa6vvlPNTGJoZ5a2FMu9GdXUfl21bAIDFckZ1n b+FAhyH318Jt+HtrB6SdM1xmNpdSsu0YBysI14tiL3m2UEGGmxRi0Rvq58geqhcNhycS GN9rJdR+kW8UgRG+m8fRV3MmKGFSwdF4t8EfAt7zQpaFzgNiGnTRYLiIbpnBDxeQdrpW NXJg== X-Gm-Message-State: AAQBX9efWW39yooRBPPStHQ9IZuALf/WMjea6zbtnVgrhXw5QGefUdl7 amXetZxynsdOwlFQV0xnKHvUAJ4AfGQNmw== X-Received: from joychakr.c.googlers.com ([fda3:e722:ac3:cc00:4f:4b78:c0a8:6ea]) (user=joychakr job=sendgmr) by 2002:a25:3157:0:b0:b8f:3647:d757 with SMTP id x84-20020a253157000000b00b8f3647d757mr310587ybx.11.1681969990443; Wed, 19 Apr 2023 22:53:10 -0700 (PDT) Date: Thu, 20 Apr 2023 05:51:31 +0000 In-Reply-To: <20230420055131.2048959-1-joychakr@google.com> Mime-Version: 1.0 References: <20230420055131.2048959-1-joychakr@google.com> X-Mailer: git-send-email 2.40.0.634.g4ca3ef3211-goog Message-ID: <20230420055131.2048959-6-joychakr@google.com> Subject: [PATCH v8 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?1763673996733485139?= X-GMAIL-MSGID: =?utf-8?q?1763673996733485139?= 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;