Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp855655rwe; Thu, 1 Sep 2022 08:35:36 -0700 (PDT) X-Google-Smtp-Source: AA6agR69HKWBYdFz/IVqsHjHbPY+br0FF/B6q8I4bf2DONHqENl1GC0zEoqSPkkejFMv7LQ8YZqx X-Received: by 2002:a17:90a:c095:b0:1fd:5bee:8a17 with SMTP id o21-20020a17090ac09500b001fd5bee8a17mr9484478pjs.147.1662046536200; Thu, 01 Sep 2022 08:35:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662046536; cv=none; d=google.com; s=arc-20160816; b=CyIbVvM4JPs5fgTlpRBsUJ9saV+Pma1uAotnBlT/bAPLpncsk/aXlOMWG4odt8VLoO kMqpgxRjwTRDxKkS5NRc0XAcd7NoG4TDiFO1U1LDmlr86scdTQs9cashWe3p/BqVNW1s k8AWX+CD8PlJR5yGbzVn3e4l3KuF6fETVSOWeBjKbHzwavj44wyFvJQ3jB37xNaEgxOv M0iDB/jKJr5/SnPpoy2OvkzBHdfvMXx9HeIY27FuZmT/3vRY5Q/Fu30bokM7qSu7kMGk 1vE0KI5m+a8fJV2pRP8AG3lav3Urf8OHur+13NG0HFC/Be3aViN57QkHw3wjrdfqMsZK CX6w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=oGpl7pItr3EHWOEnJY9fD38ZGuHllIQRNMyk8Qf83dw=; b=lWPm1cdUec21KCYUrjF9kdNZqXViVsZoVTpX6N+NIB+DIOcdMcd+dwIB/MiB0grd+9 UzN1BxowLtxDwgLMMvJvJN9S5rd0hIZ+Vr8ty2z4ozR7x6iyL0rb7AaxE66O3PhMd4Z1 HBCUFbLe2PtPsPTssWflLrwQNwQJq/1p71xSzYleJmSj86iXDZ88txcpI4OylrIIzG6T LWdN6dj1o03Hwt6pfC44iLqqddBIn5SOE05ujt/Lxgwg7yXy9+4rmTxTI8Cs1mXF1NIv cYNwBTyljjdLHkinu9Q/x1mZ7ZPNpus2AhNaysjcXYr7JStUtdW9VbV8tr3VeLxeZY9N QWDg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=N1FwxgN9; 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 z14-20020a170902ccce00b00172eb499315si17596616ple.517.2022.09.01.08.35.00; Thu, 01 Sep 2022 08:35:36 -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=N1FwxgN9; 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 S234933AbiIAOlC (ORCPT + 99 others); Thu, 1 Sep 2022 10:41:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38076 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234982AbiIAOkk (ORCPT ); Thu, 1 Sep 2022 10:40:40 -0400 Received: from mail-ej1-x62a.google.com (mail-ej1-x62a.google.com [IPv6:2a00:1450:4864:20::62a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D40E1286F9; Thu, 1 Sep 2022 07:40:25 -0700 (PDT) Received: by mail-ej1-x62a.google.com with SMTP id bj12so35118782ejb.13; Thu, 01 Sep 2022 07:40:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=user-agent:in-reply-to:content-disposition:mime-version:references :message-id:subject:cc:to:from:date:from:to:cc:subject:date; bh=oGpl7pItr3EHWOEnJY9fD38ZGuHllIQRNMyk8Qf83dw=; b=N1FwxgN9415RIK+wBsTxPPtNnGwIPbgqlexuoTp0gTyyukByY5D4/sBDFaGeTlPYxR lOOhvFtuA+XrSCqIdLuIy948cFPddOMSkwMeeySAYhUbhZOYMWnbYCwysHXk0JsuG2oe bjiJho+SAZ15MgrYG5g3xdxtjaCgG/2UGqF6XNbKrQD4GvPoKKyNEYrLLaWypSs0tE2c 6ydDKOelKqv/oB1+eC29Wr1gXl+d06QkhCbIv4bPGwda2G7FaME+L7l7Genx+GWwSw3h l3GEL4XWP0aCHEeKT/IBP3Qa5ke3lC+4Te207qzJd7aFeuQLm3AZOZSHKDdOl8DN3yIV DSvw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=user-agent:in-reply-to:content-disposition:mime-version:references :message-id:subject:cc:to:from:date:x-gm-message-state:from:to:cc :subject:date; bh=oGpl7pItr3EHWOEnJY9fD38ZGuHllIQRNMyk8Qf83dw=; b=bRzLrkGeILM7oQ3pAPiChf6QXT+BUm0Iwa5u0bEVBdi/OUa7lnYQ34YisCg2c+jRyM BCSDjZreGFTAu/SuKyEdo21hr8MsER8YWW7GzsVhXzcH03chpNGIOT5QHqH4p+IjuZ7K 7nIHbXUfYig8RVOgNduMdeo4xhQuzl5PoL3XcRUhLGoE3OMInNAh9iDJx+0E13Qa2VWO kPqRuLa9XHJcizqVzfrJz3jGEb0aBZvqkKoUAHwFZ1qPCvuBZCCCP7bZUxRGMVEsHHtt mSLLwqGvrUkfHrHZRpupsAl9bGeiqNQEEDaNWB9D/F66pWF+Vt9q5qg0C06Fh1blU17s C1eA== X-Gm-Message-State: ACgBeo0YiVuBVXSEpw+mXueC0AGteJvsf/njzXuj8mA5c+sApWAQsV4b b+I4KNdN77enzaO2tZ7nOAo= X-Received: by 2002:a17:907:2cea:b0:741:6251:3a22 with SMTP id hz10-20020a1709072cea00b0074162513a22mr15534680ejc.6.1662043223741; Thu, 01 Sep 2022 07:40:23 -0700 (PDT) Received: from orome (p200300e41f12c800f22f74fffe1f3a53.dip0.t-ipconnect.de. [2003:e4:1f12:c800:f22f:74ff:fe1f:3a53]) by smtp.gmail.com with ESMTPSA id kx3-20020a170907774300b0073d9630cbafsm8045006ejc.126.2022.09.01.07.40.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Sep 2022 07:40:22 -0700 (PDT) Date: Thu, 1 Sep 2022 16:40:21 +0200 From: Thierry Reding To: Dmitry Osipenko Cc: Akhil R , Dmitry Osipenko , Jonathan Hunter , Laxman Dewangan , "linux-i2c@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "linux-tegra@vger.kernel.org" , "wsa@kernel.org" , "robh+dt@kernel.org" , "devicetree@vger.kernel.org" , "christian.koenig@amd.com" , "sumit.semwal@linaro.org" , "Kartik ." Subject: Re: [PATCH RESEND 1/2] i2c: tegra: Add GPCDMA support Message-ID: References: <4f791065-e0dd-6ed5-f152-86d7be683490@collabora.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="6EXBlDW1rh4vcfOw" Content-Disposition: inline In-Reply-To: <4f791065-e0dd-6ed5-f152-86d7be683490@collabora.com> User-Agent: Mutt/2.2.7 (2022-08-07) X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 --6EXBlDW1rh4vcfOw Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, Aug 23, 2022 at 04:32:11PM +0300, Dmitry Osipenko wrote: > On 8/23/22 15:55, Akhil R wrote: > ... > >>>> What I am trying for is to have a mechanism that doesn't halt the i2c > >> transfers > >>>> till DMA is available. Also, I do not want to drop DMA because it was > >> unavailable > >>>> during probe(). > >>> > >>> Why is it unavailable? Sounds like you're not packaging kernel proper= ly. > > Unavailable until initramfs or systemd is started since the module has = to be > > loaded from either of it. > >=20 > >>> > >>>> This situation is sure to hit if we have I2C driver as built in and = DMA driver as a > >>>> module. In such cases, I2C will never be able to use the DMA. > >>> > >>> For Tegra I2C built-in + DMA driver module you should add the dma.ko = to > >>> initramfs and then it will work. This is a common practice for many > >>> kernel drivers. > >>> > >>> It's also similar to a problem with firmware files that must be > >>> available to drivers during boot, > >=20 > > Isn't the initramfs loaded after the driver initcalls? Wasn't very much= clear for me > > from the code and docs. We did try adding the module in initramfs initi= ally, but > > couldn't find much of a difference from when it is loaded by systemd in= rootfs. > > Will explore more on this if this really helps. >=20 > It doesn't matter when initramfs is loaded. Tegra I2C should be > re-probed once DMA driver is ready, that's the point of deferred > probing. I'd assume that your DMA driver module isn't loading. One problem we have with this, and it's another part of the reason why we have the TEGRA20_APB_DMA conditional in there, is that if no DMA driver is enabled, then the I2C driver will essentially defer probe indefinitely. The same would happen if for whatever reason someone was to disable the DMA engine via status =3D "disabled" in device tree. And that's not something we can easily discover, as far as I can tell. Although perhaps code could be added to discover these kinds of situations. Both of the above scenarios could also be considered as bugs, I suppose, and in that case the fix would be to update the configuration and/or the device tree. > >>>> Another option I thought about was to request and free DMA channel f= or > >> each > >>>> transfer, which many serial drivers already do. But I am a bit anxio= us if that > >> will > >>>> increase the latency of transfer. > >>> > >>> Perhaps all you need to do is to add MODULE_SOFTDEP to Tegra I2C driv= er > >>> like we did it for the EMC driver [1]. > >>> > >>> [1] > >>> https://git.kernel.org/pub/scm/linux/kernel/git/next/linux- > >> next.git/commit/?id=3D14b43c20c283de36131da0cb44f3170b9ffa7630 > >>> > >> > >> Although, probably MODULE_SOFTDEP won't work for a built-in driver. In > >> that case, change Tegra I2C kconfig to depend on the DMA driver. > >=20 > > Since I2C can work without DMA, wouldn't it limit the flexibility of I2= C driver. >=20 > There are kernel configurations that are not worthwhile to support > because nobody use them in practice. I think this is exactly the case > here. The TEGRA20_APB_DMA driver dependency created troubles for a long > time. >=20 > If DMA driver is enabled in kernel config, then you should provide the > driver module to kernel and it will work. >=20 > If DMA driver is disabled in kernel config, then Tegra I2C driver should > take that into account. I'm now recalling that this was the reason of > "!IS_ENABLED(CONFIG_TEGRA20_APB_DMA)" in the code. >=20 > Since all h/w gens now provide DMA support for Tegra I2C, then should be > better and easier to make DMA a dependency for Tegra I2C and don't > maintain kernel build configurations that nobody cares about. This is a suboptimal solution because we have APB DMA for Tegra20 through Tegra210 and GPC DMA for Tegra186 and later. So we'd need to depend on two drivers and that would then pull in GPC DMA basically on all generations. One potential workaround would be to have a fairly elaborate check in the driver to make sure that for SoC generations that support APB DMA that that driver is enabled, and for SoC generations that have GPC DMA that the corresponding driver is enabled. That's quite ugly and it doesn't solve the status =3D "disabled" problem, so we'd need that as well. Another thing that I've been thinking about is to use the deferred probe timeout to remedy this. driver_deferred_probe_check_state() can be used by subsystems to help figure out these kinds of situations. Basically if we integrated that into dma_request_channel(), this would at some point (fairly) late into boot return -ETIMEDOUT (or -ENODEV if modules are disabled). So this would help with status =3D "disabled" and allow us to avoid Kconfig dependencies/conditionals. Unfortunately it seems like that is in the process of being removed, so not sure if that's a long- term option. What that doesn't help with is the potentially long delay that probe deferral can cause, so it means that all I2C devices may not get a chance to probe until very late into the boot process. We may need to survey what exactly that means to better judge what to do about it. I do agree that probe deferral is the right tool for the job, but it may be prohibitively slow to get I2C working with that. Another mitigation would be for the driver to keep probing for the DMA channels in the background. Sort of like an asynchronous probe deferral of that subset. Similar things were discussed at some point when the whole fw_devlink and such were hashed out, though at the time I think the preferred proposal was a notification mechanism. Thierry --6EXBlDW1rh4vcfOw Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCAAdFiEEiOrDCAFJzPfAjcif3SOs138+s6EFAmMQxFIACgkQ3SOs138+ s6FH5xAAqTlqEFg0v+RseYBA6ke9pT/l555czmR5Tgl7x8KBcPhZEzL/SXIW8JLL 45No62nZBKM6Wk5WmXhbaq3xrH4xj339PKYg2gN2ZJ+E/eMDsF/ruFZK5LGpQ7vs DQI2vK1ER1ms2vVTdRjIceW0X9IfkLsgP8Xk97yPY2s7sABMYoaxjjD98GFXyInn 6ZjiPKJlDLH2PZI7WQmGMGpd5ct1m29xyO2G7unVeHONavngBtA3nzTx4RadK/CK sKaH3Ixy8MpnFvncSrSF+Wp4B7u+TDdVybB3GdLhn6P85IfuVPYw1UJp0XdgnkNH viJ9Mbond5VOOy+5zv/wrA29i8xQZt/4Fym/pmyDjgbSNw3qhN2XV3nn//W+0c26 Vgyti6rZDW6O6W1SXKHjAL2CG2cnJorv3nYPnF4eiPzPikWdq2m6YD3hxb2eHl8G DaPsDpd+1eagoYgewipROyIcaY4w+OygphDUXYQkz76pTOOh90RruQ5wvgUSOUyX ENxJpku0xO/MQv+Nt6LlxzcW8WiY4nltpDljFXzqDCXIiShfAXYrlKO3nIajMvyi 7Rtul601MsvO+h6jCXFo2GayPHWntY4kLXt2NnAnUDgEZbqadO/72vphKJ0RsST+ fHH8Y1KC62G+O0Et4GAbUX4gGJ4PTQGAkEl4VeHyyoqUTR8pqp0= =hUEH -----END PGP SIGNATURE----- --6EXBlDW1rh4vcfOw--