From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-lf1-f42.google.com (mail-lf1-f42.google.com [209.85.167.42]) (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 D4B9B27A92D for ; Wed, 18 Feb 2026 07:03:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.42 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771398182; cv=none; b=MNPqYfTNEJjfcg0PmJ5oD9Elxi4z8xE1VqB58nOKEPJUDj5/rD8KQicLpuIwp03fbBdU7RB09QO5rxHTYMFnFis0hXlfMa4P1sNIULOO9i9sGRNHoDi4WL34Bxrp3EE+tIkDyFANCJ6LQVwI7Cpb9vxnP0MAOcSe8yYXeG5M+hg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771398182; c=relaxed/simple; bh=qjTiJxJ/J+fAiH4bcVa6aLsQLAjfzOLECOEAUlrfZjY=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=J51LXW4Tn7piSMYHwADQ4XqPHZ/ZnPAkFLRH/VWP/Tr3kZJz3sT2W2qH/vfolbFICyF2oj5VOK9gwibBOYFnpAJ80yAelXXE78tJ2gF9Sr2dVDvIdBPy/R8p+Xh5+VxbEywUqMdbEvRBUXhO2+VQmZB27NUQdugSuKlkoF8cajo= 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=SISnZoaK; arc=none smtp.client-ip=209.85.167.42 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="SISnZoaK" Received: by mail-lf1-f42.google.com with SMTP id 2adb3069b0e04-59e65b8e268so4599127e87.2 for ; Tue, 17 Feb 2026 23:03:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1771398179; x=1772002979; 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=hXXoBmrj44IUOz5Es2ozBzd5fhqRhhv5SZZDcT1xe2c=; b=SISnZoaKyPiTx3QHuB0wa/oFlVqmDYS8ICiO0hR3/6xTC23wHvpRtiXuVqBYdHwX9k dlL/8QhNkZ8BFDjonKJvAPEA29p5+9GJgyryxWV7qsbsAbL1aBCq/Ou9og6nJvleHb2v ebe9ZJviAnYZhqvyVy4WPdhjldLYqUrVRdrc4my0zLk3nu9JuuaJlHYVZjFlP2iUyrHO n7jFaeUE7qkgd4kbFeRjKyvSKvZMZ8aQsHUhrnC5YQyvUwa1sxl7kqoUf8Tc2bfdO1dj Se0IECL2LLfRDPAZhUUFlREreKz/5bWcEOYEaGkG5K8iazeZAUdOViYdZvyTDBwmVUL/ OTPA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771398179; x=1772002979; 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=hXXoBmrj44IUOz5Es2ozBzd5fhqRhhv5SZZDcT1xe2c=; b=ZWisVy+jEnEwGXhEiocVteiRFKLkln42f0VgnhEBcVnHeGIgoGxZgrCioQGvw40y9c 4X0mvTrdtfgir2Po5hgFcldaR8njTBS598Opw+Oiebo92YPySjEWlHtN2ujuauSVgxtD CPHc/uoPeAGqsu7s/URFoGPee33MzTJafxIlz9s6l99VnA4MX3aUEhbyHVGU+RQP8fcD HDEPW13kgw2zqRHJPT7Q7izcFxnfhG6kvsK10wNQlxIbG3YIx03jLbh1pWW5UW84o8JP NGevqWLhgS0DhT3PENnJqJhWj5Av4rzIhg0R6EE1nSgNEaMqOttvcAsWJyl3IJN+/LpS gYHw== X-Forwarded-Encrypted: i=1; AJvYcCXy+2SmoH333zExQWwtGmevJ16wgtu7GJguMsQhdRvgEjCM/Inu2svV4uYH55W1QFyJvEOnZ1hef0iCOJw=@vger.kernel.org X-Gm-Message-State: AOJu0YyAB80LTvKBDeBF3R5eVhEtRYu2Js8z4xpQzkpHZ3c/vIFA6nc0 QciHlucTcInEJU+S/LDF4Dn9sjsui06RJIoS1wLlPn15JsN9q5R+MOUT X-Gm-Gg: AZuq6aINCKZNl8mKl3PdC8TvCn0qKL7GeFywqwt1x043L+NcyLoJ+sL0c29M+QYHee7 7OHCHtnRgXlIYWmqobvT8YfkzWY4uAfod+jaJg/qfat7KgbTUWi0xoQdjGkyMnsE21lDpzeUptU 41DLNUOYv5L2mWod4xae8fs4aw5QPCaTQdKFZU8uRCD76Fk8jC/tTp1YP3eZQwIKrDu21X4M3KT 5w8CxX2BTQxonJkdT68j1Bj0F5IuHxigN3ueM2WHiHeCeP2fZ8rf3eFAk5ZayX+ydzRsx2X+Dta H4yTfr6g4jxK75sejEtdx0izdqN/iJDYWIS7ice93gkkmuYQivRnwYOhiLfQysQieX4ptkTiaFK nV6LAOcTTxy7THQgJBxNChoQywzXEQekHG+R2AN9vg/PDvU9BOwsoD6Le0fESEB4iKDt7kyb+po iag760MZYDtDvws1PKMO6GifE1m/VHqoQt2QqeYmcF35/P+Qh6UaP2y1K6t9L+8Ni8iO+xW/o= X-Received: by 2002:a05:6512:686:b0:59d:f71b:3608 with SMTP id 2adb3069b0e04-59f02632deamr5652870e87.31.1771398178667; Tue, 17 Feb 2026 23:02:58 -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-59e5f5acb0esm4280001e87.67.2026.02.17.23.02.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Feb 2026 23:02:57 -0800 (PST) Date: Wed, 18 Feb 2026 08:02:54 +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="BkvM8BP+41dGuZa7" Content-Disposition: inline In-Reply-To: --BkvM8BP+41dGuZa7 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hi Peter! 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_adap= ter *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. The= re > >> are other i2c_adapters with a parent besides muxes. See e.g. i2c_atr.c > >=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(). That would be a more robust solution indeed. >=20 > I guess an unlocked __i2c_adapter_set_clk_freq() is needed. >=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? 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. > Cheers, > Peter Best regards, Marcus Folkesson --BkvM8BP+41dGuZa7 Content-Type: application/pgp-signature; name=signature.asc -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEEBVGi6LZstU1kwSxliIBOb1ldUjIFAmmVZA4ACgkQiIBOb1ld UjL5kQ/9FZG4RjJZzJAb9lOuafAbwZSG92RdAK7UgHrvI6dlRPsPquhlCA1ql78G leKeilwgMiRZ4/eof6B+M89fvRgGzb+NKaJHb8epXz3BVDwdK0L3ovdj0xZntOfM RrZVy1pfKosINPCZ3+VYX3x/8hy7FiK8zuoRCdRkQSZOsIiQA+swNHjtEUL16FTa w4o5U+2zY0zBHuY0IBDPoFjzVgZa5bQHR4EtlBxV9rhj3rB9DgkLkO9olLt9LbUW D/WVAaFxt05rK2GCneAde86ABxjZ8EVBujs5U/HTBMK9CtlOM2Q45Q7yMBztVqZ6 hRyU6eEbEZztPHbJlMMuLoHDM/FqgVWKvHuDMJ5zJf2VKGncewfBBNMKbgCFG2DQ e8U8QiFyEikGoSOs7POF2V+Sg0PplbomLA7oIegxPcIrWXZVHWSUBI9tPTHNH7PO zfASvV/LHYXIUzfIXtPvPRREkh5vrMu5eIfihIdAfgrgNY8p0SMwiOeYt2v//Bq2 5n9lc1O5xVGJEa6bTo/+2Yu8wY/HTI/WAFAY/gV1oZ2Zgn0kqYcEp57F5LgNafsj Xc10LHEkl4tfuCz8FgxWUV3rMMwZhib7GEgvQaFl7fiMsnv0RJjyWcK74e/G6Z2S s0+s3v8GHBqR/g4lsEJEIfbggh6GJTrdJ9MvEwOkTiymXF/1iXM= =6mY5 -----END PGP SIGNATURE----- --BkvM8BP+41dGuZa7--