Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp5603869rwl; Tue, 11 Apr 2023 07:40:44 -0700 (PDT) X-Google-Smtp-Source: AKy350aejm0YGldragOqmoYIcUfUmz0zO+2aDCajDu5JW5GjN6y4T5Be1zhaYaJA/WfRNzkutiCM X-Received: by 2002:a17:906:3a45:b0:949:ab5c:f10c with SMTP id a5-20020a1709063a4500b00949ab5cf10cmr8399137ejf.63.1681224044266; Tue, 11 Apr 2023 07:40:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681224044; cv=none; d=google.com; s=arc-20160816; b=Z7jn/yDVpHBCRRkCboNRce5Pdt6s5ic7kc1+5bGnpe64b/Odnu/P+pbw32opCYTieq MqatXrRvEJbBWQ1yjEagJOA0BLw2CU02TYDDcEMYotecH4ozDSGBD9nDuNcU2EMDLGxf 0y3FuyGIFq1anKtVjnx9J2rYOzhwhOWbTStxITcywCFX8dGVwNid2M/8g++CUblUD0fU XAOqOOy3yt/E1NYOqNLqcGaABAtPzBEB+7hr0UwhvQRLGcHvLKCTzE7ttqdW5uSlUep8 f+JwvPsRP04IGP8j+W/Ne/6WSVShdfSPKA+DmopyQeL0juz2bmR2EuV9MslqP64vI4b7 pkjQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=6HfxwgTBgQXWC6fG+aiC6jOWHTPMJBQRX3DVcb99zZo=; b=jwSRUSKchca5y9rVibWhwPbKIIXfSGN13SKtcuwnONYS9jn8QWMez4FQan7oMflatn Hjj81fhWMkvngsnhbErzMTb9dO3jYmHbN5YPDCJ/gZ4LlDQZhTzJk6ZS7Y23Q3gRPRKC 4tLon1kuBaERkNgfiqAovNYLT4YzkmPW+9pqQ0kCJ76ENRdDg1CePI/Rrlas9fi3D9dk V2IiAjsRUMzWcsBDBkw8U610bgwKevfUO3GthU6ifLlbjVTSchD/o29fY3d/GXli/QQ7 cF/f2ZyH2yiRmeDFfSM7JjD33jH1TpEZcfUU9LjCxawKgvVPQbL1pZhhTn1KeVCDLu3m R0YA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=i7pz3ot8; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w7-20020a170906130700b0094a434289a9si7568813ejb.897.2023.04.11.07.40.05; Tue, 11 Apr 2023 07:40: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=@gmail.com header.s=20210112 header.b=i7pz3ot8; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229961AbjDKOic (ORCPT + 99 others); Tue, 11 Apr 2023 10:38:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53506 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229801AbjDKOiL (ORCPT ); Tue, 11 Apr 2023 10:38:11 -0400 Received: from mail-lf1-x12e.google.com (mail-lf1-x12e.google.com [IPv6:2a00:1450:4864:20::12e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 80738448E; Tue, 11 Apr 2023 07:38:03 -0700 (PDT) Received: by mail-lf1-x12e.google.com with SMTP id h12so5752456lfj.8; Tue, 11 Apr 2023 07:38:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1681223881; x=1683815881; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=6HfxwgTBgQXWC6fG+aiC6jOWHTPMJBQRX3DVcb99zZo=; b=i7pz3ot8hLcJhgDkQjOjtEL+XNljQTYUxvVad/zSVIzphX3Mi7AuYMpDd3Ud1Jwuph 1ppkuxwFfT0rqm4iIT1MpHRI35IgZw6tGEGrQkf+wPHOyqQs4rsNEb6hzIpP1yXJf+ki buLMyVfbyJjs2f1lW4f2JP8pEHcNISDpCk/X8ECycwTcRST8asczc39pYomv3b7Uast/ 64NMZc40Lin7VCqNRQGFGeZO9B2cR5XXB2r53Zwl3zQgP9N2Nyza4hr+uCyjDgZAqNZU ovO3LsNvn5Q23kuC3JlpEQeBZg0qK7etFzGzKdplRLoIws4icx9EYOKbWxUxCWk1So82 Ru2w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1681223881; x=1683815881; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=6HfxwgTBgQXWC6fG+aiC6jOWHTPMJBQRX3DVcb99zZo=; b=DM0AGuNgKFD5hxHxBzhAQO5HUDxJrGIUUqF0iYKLE40dtwZUCn9X/V/jg+3ck3wEMA Bx4MmHu7xOz+LKYx7InoLqjHMXeua7qHrOlpYRLKIubr0sqav+dKGfgYAS0olxWgmJlI 9jAfkS1PxUK8AQREtJi12X3eW87PDtEze6dQbhggFcjkWNPzjz3pYZtvMvs0mZH9Bq1R DFR5qEsDTB89WM6XefsCnq1B1j8kv5tWYl8ErC2Ozu6HvxU113pryyaZxwnq02xQYCEk mxYwuhx59o8RliDV9jOiagvfc9kqMKSV/JDW98lgMbaoQrEvt6wFCNrr9kUdl/jBATcB wLGw== X-Gm-Message-State: AAQBX9dR/jiJdIs2oWAtNr+kuectBwE0S1s/ljCcZsFfORx43cQkGNL8 Ckd0tcz/HwsAs71isjoJ36c= X-Received: by 2002:ac2:4883:0:b0:4ec:5607:9055 with SMTP id x3-20020ac24883000000b004ec56079055mr3976585lfc.31.1681223881090; Tue, 11 Apr 2023 07:38:01 -0700 (PDT) Received: from mobilestation ([95.79.140.35]) by smtp.gmail.com with ESMTPSA id l29-20020ac24a9d000000b004eae73a0530sm2593770lfp.39.2023.04.11.07.38.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Apr 2023 07:38:00 -0700 (PDT) Date: Tue, 11 Apr 2023 17:37:58 +0300 From: Serge Semin To: Andy Shevchenko Cc: Joy Chakraborty , Mark Brown , linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org, manugautam@google.com, rohitner@google.com Subject: Re: [PATCH v5 2/2] spi: dw: Add dma controller capability checks Message-ID: <20230411143758.2rpaxux6esiln26q@mobilestation> References: <20230330063450.2289058-1-joychakr@google.com> <20230330063450.2289058-3-joychakr@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS 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 On Tue, Apr 11, 2023 at 03:18:34PM +0300, Andy Shevchenko wrote: > On Thu, Mar 30, 2023 at 06:34:50AM +0000, Joy Chakraborty wrote: > > Check capabilities of DMA controller during init to make sure it is > > capable of handling MEM2DEV for tx channel, DEV2MEM for rx channel > > and store addr_width capabilities to check per transfer to make sure the > > bits/word requirement can be met for that transfer. > > ... > > > +static enum dma_slave_buswidth dw_spi_dma_convert_width(u8 n_bytes); > > Can we avoid forward declarations please? > > ... > > > + if (!(tx.directions & BIT(DMA_MEM_TO_DEV) && > > + rx.directions & BIT(DMA_DEV_TO_MEM))) > > + return -ENXIO; > > What about simplex transfers where we only care about sending or receiving data > and using dummy data for the other channel? Doesn't this make a regression for > that types of transfers? (Or, if we don't support such, this should be explained > in the commit message at least.) I don't think the code above is that much relevant for the half-duplex transfers. The DW APB SSI-DMA driver requires both Tx and Rx channels being specified thus supporting the Full-duplex transfers at least in case of the TxRx and Rx-only SPI-transfers (the later case relies on having the dummy buffers supplied by the SPI-core). Thus the channels must support the corresponding DMA-directions. Indeed the Tx-only DMA-based SPI-transfers implementation in the driver implies not using the Rx DMA-channel, but even in that case the Rx-channel still needs to be specified otherwise the DW APB SSI-DMA setup methods will halt with error returned. So unless there are cases with dummy Rx DMA-channels (which I very much doubt there is) I don't see the suggested update causing a regression. Am I missing something? > > ... > > > + /* > > + * 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; > > I don't think so this is correct. > > Theoretically it's possible to have simplex transfers on which the one of > the channel is simply ignored / not used. See above. Please see my explanation above. To cut it short even in case of the half-duplex SPI-xfers both channels need to be specified with the respective capabilities. It's implied by the DW APB SSI-DMA setup methods design (see dw_spi_dma_init_mfld() and dw_spi_dma_init_generic()). So until the DW APB SSI-DMA driver is re-developed to supporting true Tx-only and Rx-only transfers with no requirement one of the channels being specified I don't see any problem with the code above. Do you still think otherwise? -Serge(y) > > -- > With Best Regards, > Andy Shevchenko > >