From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-lj1-f178.google.com (mail-lj1-f178.google.com [209.85.208.178]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B989F349B1D for ; Mon, 23 Feb 2026 07:29:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.178 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771831756; cv=none; b=SYmWbyX2csSPACj4MOrc2kU05BSk2iNda8n2tKrL7sQA8cBZzuqsxmac3hkcDW9O9MXovCmLSBe6x12/X2FBLo75ONTQ120uJqW/Eif3xBSVViVWwiV9THPMu5hI78jNpPRrBOUjpByt27Kq21HCTTRbXrJEIsqNqZXLIjS9/bI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771831756; c=relaxed/simple; bh=bFi8UYq+Jz7bZ8mRheKvygjYVrr12Us6LVK+gr5p+RY=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=Qz9s1cUDeMRu6FSsoqQBZe9hXQUgtTCaKAm4s6iSqt/wfvwLRA/H/aTJzIsglRlDROTujc3gNPSCQ421I0mkY5V1+JUkX3Jx9nDTP5qFAIaXzU1yqUYYt64lpOOqBwkqCt3/PbJ4ssrtmpYSjmtul23tc+j6EbIYyXYQKnoM7Go= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=PAi108jF; arc=none smtp.client-ip=209.85.208.178 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="PAi108jF" Received: by mail-lj1-f178.google.com with SMTP id 38308e7fff4ca-387114fdbedso32619381fa.2 for ; Sun, 22 Feb 2026 23:29:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1771831753; x=1772436553; darn=vger.kernel.org; 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=hbZ5b7ao+DiagEDcdfKn3Bm3NVsuaQOHTS0dAlMskSs=; b=PAi108jFDs0oGTTkZTYAfZaQI7PJDC7H7NlS5HaX3uYKPuAChkyGhBDnYYVy5QMF5w 3/6FtPa7rBGIltxetI6c7TRlv1DlLMklzg6McuVe2jGk8vRtAGLFh2GarMvKy2L08a/E 7MNwa+xOl2kICE3nggfhQ87812exOEn7+DMh8r8AmhXZiw+4zMHAqAbdTYptkhR1W3/b FTEAh4nHBoQ3wdI3e88bS38+FiZGFkFSSIB6P7F6LXE6VeuDNprApLsFlkZLfOn1GCDp 5LHpym0CitHcc/EuRPMVMD6X+ziIZ6pt1z7rFPy4FMzAinro61YHRgmKwhpwxtazsGmL QPnQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771831753; x=1772436553; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=hbZ5b7ao+DiagEDcdfKn3Bm3NVsuaQOHTS0dAlMskSs=; b=X+azVcUo4yAKlXxhR3hpL2O05zvE9Y0TV2waf1eMzalKlJ8sH57cnU66Sngi1wPk42 31Jlk7tUY/XH2EF2nLhSyG2UMmnTrTRseQjUinaOGxwZbeSsxpBMh9OlYN8y03R3pBYf 8dRfOLYvPOPJWJcVfTDZ5dfsD/wO8RWHgtz7ZGSDR9PE8gbzVFAJTnYQEeZAt8/qL42a NQO56whbmgXrdx4HVb8qJHwZfJy0ArOtUtCWdFaDees2qJSYC3wZiA5tLwjkXZrb+vJo E5HTOhryxvXixnNMf1+nQ7+NPLTY78vSb/D65oXV2EcEV4vCVG5O5TtQbY6U+u5DC1ZS bQGQ== X-Forwarded-Encrypted: i=1; AJvYcCXPJ8JQtpRgTKqXoPmiOemLq3sTekYI11hbaMheolrIRGLKIivOerryDk8Mpn+EgUda95Nc4vhWqYVmp+E=@vger.kernel.org X-Gm-Message-State: AOJu0Yw4RXT15mdbanYFV/NeFaR0dj27URzbmtA/DCJJjllIZkkz5OLm OUsAKq5wTDe9aCAks7DoFanfROfZgRIwHJdavwP8RLkPkkUTUH9TvneO X-Gm-Gg: AZuq6aJ66r1Hy5OXOC11TbKB/ZVkKNEP30NqUiuDTRJKgr7N8VyBGV4KQflvU4WeYM2 t3FLtoclT1QrVcJxBcv2Bw5oGYe8oIzPBJe8kuEtnJ72nWF9ww8m9ne1eH8cxCzAsI1Wve8Jj4Y oD1kbgjXrjE6G0bPjfoSRkfgW7iPTUARw28OQjKJ3/voh/4eSy2iopt6hrfZYb4EPhwLuD7JAfh QfVK5UkIoB5RS+Hkhxd5UAzFZ5U8HWiCoYgb6tps5GTWizEJuUb60qvLULKO6Ar5UclyJ1nFjxp taHmiLS30oAuL2CwAX4a9SoR9tb0zHQzrK/6148icb092uRZGFzgHRWhfD35rFmRVXjCdQp0HOe wJ/zphoBhveVh1GmO90uzmTgDX8HnziCjFBhABEqqNSzbDGkyMij0KvFDobtcVZNs/dU7CI2UCf ks7Lk7YxSKrVQJVa0dR83zXZyZIFTJ/9G5RjH64ZXPVPIeDl7p9vKEH8ki3Udi X-Received: by 2002:a05:6512:1599:b0:59e:645d:192c with SMTP id 2adb3069b0e04-5a0ed99c6admr2114208e87.24.1771831752661; Sun, 22 Feb 2026 23:29:12 -0800 (PST) Received: from gmail.com (83-233-6-197.cust.bredband2.com. [83.233.6.197]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-5a0eeb45813sm1367725e87.64.2026.02.22.23.29.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 22 Feb 2026 23:29:10 -0800 (PST) Date: Mon, 23 Feb 2026 08:29:07 +0100 From: Marcus Folkesson To: Peter Rosin Cc: Wolfram Sang , Michael Hennerich , Bartosz Golaszewski , Andi Shyti , Andy Shevchenko , Bartosz Golaszewski , linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH v6 2/5] i2c: mux: add support for per channel bus frequency Message-ID: References: <20260216-i2c-mux-v6-0-9be28ecfd7e3@gmail.com> <20260216-i2c-mux-v6-2-9be28ecfd7e3@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="MoMPLdIF9j3bHqVN" Content-Disposition: inline In-Reply-To: --MoMPLdIF9j3bHqVN Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hi Peter, On Wed, Feb 18, 2026 at 08:02:54AM +0100, Marcus Folkesson wrote: > Hi Peter! >=20 > On Tue, Feb 17, 2026 at 10:37:39AM +0100, Peter Rosin wrote: > > Hi! > >=20 > > 2026-02-16 at 19:50, Marcus Folkesson wrote: > > > Hi Peter! > > >=20 > > > On Mon, Feb 16, 2026 at 05:40:37PM +0100, Peter Rosin wrote: > > >> Hi! > > >> > > >>> +static struct i2c_mux_core *i2c_mux_first_mux_locked(struct i2c_ad= apter *adap) > > >>> +{ > > >>> + struct i2c_adapter *parent; > > >>> + > > >>> + while ((parent =3D i2c_parent_is_i2c_adapter(adap)) !=3D NULL) { > > >>> + struct i2c_mux_priv *priv =3D adap->algo_data; > > >> > > >> This assumption does not hold, making the cast pretty wild indeed. T= here > > >> are other i2c_adapters with a parent besides muxes. See e.g. i2c_atr= =2Ec > > >=20 > > > I see. Hrm, not sure how to decide if it is a mux or not. The best I > > > could come up with is to look at the i2c_adapter.lock_ops. E.g. > > >=20 > > >=20 > > > while ((parent =3D i2c_parent_is_i2c_adapter(adap)) !=3D NULL) { > > > /* > > > * Check if this adapter is a mux channel by verifying its > > > * lock_ops. Only mux channels use these specific lock operations. > > > */ > > > if (adap->lock_ops =3D=3D &i2c_mux_lock_ops || > > > adap->lock_ops =3D=3D &i2c_parent_lock_ops) { > > > struct i2c_mux_priv *priv =3D adap->algo_data; > > >=20 > > > if (priv->muxc->mux_locked) > > > return priv->muxc; > > > } > > > adap =3D parent; > > > } > > >=20 > > > Or do you have a better idea? > >=20 > > That looks fragile. My recommendation would be to avoid trying to > > guess how a potentially diverse adapter tree should be handled > > locally in the mux code. To me, it would feel better to introduce > > locking/recursion in i2c_adapter_set_clk_freq() for muxes (and > > address translators), i.e. take inspiration from i2c_transfer() > > and i2c_smbus_xfer(). >=20 > That would be a more robust solution indeed. >=20 > >=20 > > I guess an unlocked __i2c_adapter_set_clk_freq() is needed. > >=20 >=20 > Rethinking the whole locking approach; > If I follow the same locking logic as in i2c_transfer/__i2c_transfer, do I > really need do take any more locks than the root adapter with > I2C_LOCK_ROOT_ADAPTER? > As the frequency can only be lowered, an intermediate i2c message will > not mess anything up? >=20 > If so, do you think i2c_root_adapter() should be moved to i2c-core-base.= c? > Then i2c_adapter_set(_root?)_clk_freq() could lookup the root adapter > and take the lock there. I've reworked this during the weekend and think I've got some my answers. I will send out a new version later today. Thanks! Best regards, Marcus Folkesson --MoMPLdIF9j3bHqVN Content-Type: application/pgp-signature; name=signature.asc -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEEBVGi6LZstU1kwSxliIBOb1ldUjIFAmmcAb4ACgkQiIBOb1ld UjKEDg/+IBFMAKiHUARtHOWdNvNXagaezYzxvlG9U7d8nSHCg+2eZpqJYyjyBb1j WGlrRz1xUjCVcP46qy0OOMof5l0tyra6E2+bVwBJ2V8Rg4msHLQ6Fq4mQZ0H2bKG sGQyy0YOVzi3OppgDVthHyEbYB6h1PPKpGzyzHfdCoAbU2vlbhoK5ta/SNu49Hsj RG7XoX66PCKEi8VIMmb+RbUHgzOVVmBe6Ycv7IvvDjMze92oudNu3BhUJugi6y7A 45WsilJKAC2SR6Wc6lWQPSZ/JH6bii9vCCealITbv1xdOGRWG7AJtnGXB0T86jPP JyB0wguefWE8O1WmR+wZ+MFBdUQZyQ54fr3LNBcX3gkze82Yay3zhMCNbDToqYHl o2aWR2LjMW0skWna3a6FlhEDh/reoNavq7ARKv+ANEP7VrZYEXZgrAfMSQZ0iy0p AVZOEPVPilfnoaGo7DD40v6Gd41yHqjLuabIEfvb/A6VdTq/MZcV30eBeV/EyqVe wdGTLFY+Ivm/GNJ2MMak/ju6zmfWzzVRj1ibZjEq5KtWaxiPSCY/ewxNWXXh+yQu XQRqo643UB3plS3w4oTWGO4JtKDZ3B6vJKPKLlT4D4nUjOCCO70mxENNnfoSGOwn DjPonu0VeDuVcASuSOJQ4/9bJaQ6sBWCtqn/EHWfKzi0mcfx2e8= =514b -----END PGP SIGNATURE----- --MoMPLdIF9j3bHqVN--