Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp6457772rwr; Tue, 2 May 2023 00:13:20 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4xqfygQDPu0NW9fWQIZLImEWl3ZZnmwdomjLRlTkPda67QscqleUJusnCj53h+ZdgsNvYH X-Received: by 2002:a17:903:2345:b0:1a9:72d7:785 with SMTP id c5-20020a170903234500b001a972d70785mr18503213plh.10.1683011599946; Tue, 02 May 2023 00:13:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683011599; cv=none; d=google.com; s=arc-20160816; b=ibNAd6fGhFxfKfDbbnyJisd8rIIcu6QoBFtl7IxvG16+dDiWy/it7FBoDpzz3anJYY FHYDgtP/LJJhlagvPpDEOzVJiPn50bwXUfha6H1cJ87JGsd6LobGKYJ4EtjAPqst9bP+ Q4rpmiZo3uQLUjdHAz8tjjHzXjpVR2mHz5ui5Ria5ExpM+SaDVl3N9sqhT7u1k6RlNXF cJjUadxyKO9WGBpwi/XCbHpAiXvWtmIDOdpsVzu0iCbQZ1jkZ78dPQzHLMVFy48146bJ MY1HYu4y3HFAasPFKEFF9EgtT+7SCxK4bnEtz9u1lO50o0lAB2RzCREZhhjnM/o5a5c7 CXMA== 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; bh=oZO3Rn0U5loaH+0C394rD+myw/ZbA6J4mfQ/51aBSyA=; b=eh4xB7vwFqmby6dvuFHqEZZNj5qVgDkby4q1/YUHDkhgdaxUM8gOCHsgy32lukWmfJ olKjZbbldUM5NCY03alasD9tMq2Ptl7Z2h15P0xlwh9JM23+HWvqeeWWrDf4Bj3ev2dE ZS7Fqw1X/k31fSX3bRxOnDwT7ukjeEFKtOMjjf4srURx/Zp3VgcQdVsluK74IZkCpgRV o2nCr1hm4XAmvTKZ0DiVzM86Sqcqqk6Pt/+1C+0R+bSxjQTFCeL8H3Tfar6WHMbBFSWP fjQK1hM+UlV+6OtdS2wrg112Udido0vYRmkAq4NTVWgQKE1vTJ45YHpsnyn+iGNSjgd5 zQmQ== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n64-20020a17090a2cc600b0024e229fcb5bsi1502568pjd.11.2023.05.02.00.13.04; Tue, 02 May 2023 00:13:19 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233018AbjEBHDz (ORCPT + 99 others); Tue, 2 May 2023 03:03:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33460 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230004AbjEBHDx (ORCPT ); Tue, 2 May 2023 03:03:53 -0400 Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3AD1C1FDE for ; Tue, 2 May 2023 00:03:52 -0700 (PDT) Received: from moin.white.stw.pengutronix.de ([2a0a:edc0:0:b01:1d::7b] helo=bjornoya.blackshift.org) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ptk33-0001uP-Lo; Tue, 02 May 2023 09:03:41 +0200 Received: from pengutronix.de (unknown [172.20.34.65]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (prime256v1) server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) (Authenticated sender: mkl-all@blackshift.org) by smtp.blackshift.org (Postfix) with ESMTPSA id 104711BBEE2; Tue, 2 May 2023 07:03:40 +0000 (UTC) Date: Tue, 2 May 2023 09:03:39 +0200 From: Marc Kleine-Budde To: Alexander Stein Cc: Wolfram Sang , NXP Linux Team , "A. Sverdlin" , Dong Aisheng , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , linux-i2c@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v3] i2c: lpi2c: cache peripheral clock rate Message-ID: <20230502-grueling-plural-694f7fc7c9ff-mkl@pengutronix.de> References: <20230310130815.562418-1-alexander.sverdlin@siemens.com> <4797405.GXAFRqVoOG@steina-w> <2143344.irdbgypaU6@steina-w> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="ywzxrng3y4nbcxxf" Content-Disposition: inline In-Reply-To: <2143344.irdbgypaU6@steina-w> X-SA-Exim-Connect-IP: 2a0a:edc0:0:b01:1d::7b X-SA-Exim-Mail-From: mkl@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, 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 --ywzxrng3y4nbcxxf Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On 02.05.2023 08:50:06, Alexander Stein wrote: > Hello Wolfgang, >=20 > Am Sonntag, 30. April 2023, 09:05:55 CEST schrieb Wolfram Sang: > > * PGP Signed by an unknown key > >=20 > > > > IIRC this is a general problem^w limitation of the clock framework, > > > > clock providers cannot use clocks themselves in certain callback, e= =2Eg. > > > > set_rate. > > >=20 > > > Well, that's essentially impossible when this clock provider is attac= hed > > > via i2c. i2c transfers potentially need to change or prepare clocks. > >=20 > > So, as I get it, this is not a specific lpi2c problem but affecting any > > I2C controller driver which uses get_rate() to setup a transfer to a > > remote I2C clock provider? And this lockdep warning is a false-positive? >=20 > Yes, IMHO this could potentially occur on every I2C controller driver, if= a=20 > clock provider while holding the clk_prepare_lock, e.g. during registrati= on,=20 > issues an i2c transfer. > I'm not so sure if this is a false-positive, but more like trying to do a= =20 > nested lock. It's a general limitation of the clock framework. The clk_prepare_lock() is taken by clk_prepare() and by clk_get_rate(). So if you implement a clock provider driver that uses I2C, which might use clk_get_rate() it might deadlock. However there's a workaround for nested I2C calls: 533ddeb1e86f "(clk: allow reentrant calls into the clk framework, 2013-03-28)". This doesn't work for SPI, as it's using a worker thread. | https://elixir.bootlin.com/linux/v6.3/source/drivers/clk/clk.c#L128 regards, Marc --=20 Pengutronix e.K. | Marc Kleine-Budde | Embedded Linux | https://www.pengutronix.de | Vertretung N=C3=BCrnberg | Phone: +49-5121-206917-129 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-9 | --ywzxrng3y4nbcxxf Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAABCgAdFiEEDs2BvajyNKlf9TJQvlAcSiqKBOgFAmRQtckACgkQvlAcSiqK BOhPxwgAr5nYSNP4JEu7xo76JeUQGHdeOk6wmcHDpSmhFJje5gaXzU1knRdxynwV OM+EkIYxbuDzvdRwpgg+cdyGUmprQxPiUHMjYasDOR9lv4lSKVKKomDqPXyLBI/r jbRkiuslJF6Hrk9y7qxDEo6oGlh86UlNEvwKO4ImFJWDBDTovgjxUXk1wTyP8HPm ANOYQMWy+LY1OM3+oR0h/VOAFfRtAr1zrPnhcY6vk1/ZlG8gNzg8r/WSwez4qYKB NBxZdcKtGxuuFAl+T8y9aoKa4i2r8YmJtMY0HBDhAcZHQ2MPFyR9wzpAC7rXpKKO BQkb/3bMwJ0/XuXcapo2sJrUK7jxSw== =1qAJ -----END PGP SIGNATURE----- --ywzxrng3y4nbcxxf--