From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-lf1-f54.google.com (mail-lf1-f54.google.com [209.85.167.54]) (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 BBF62355020 for ; Fri, 13 Feb 2026 10:59:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.54 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770980351; cv=none; b=fbgzLTafNlvG18clb7e6m8wapD0CF8VKKAChPolrrLqPNmR1JGlvF5kpQ6kEw2phIA/sseLgG33NZxchQQRTExTeQnOWqt3KVD3ETiW6bMJ3WMLoFhxw7qUh7sSIWmhvSL2QPC41Dz7UGtP9I+QEmVtoyEhrUh1O2ZJLw1JPjzI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770980351; c=relaxed/simple; bh=PC0XhXcGA5PB7/p4XiApV7wHd+gbBqWWky3OF/ZvMnI=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=J+5NvhqnKbXrAVtc/NXmaVVxJ/ZYuypPGfwvDv55PZ7G31gYD6HKxV2DzWyTTWRb/vzchC4y7QC8Zc10cBX9AnsqG8InLW/nFH2oRwWAzieKsNE3X7qsQrtDymJnYBf95wXdPWzKf098F4uZiBmdjB+77VrnXaXJWwUG3vDaDnk= 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=M3/L3F/G; arc=none smtp.client-ip=209.85.167.54 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="M3/L3F/G" Received: by mail-lf1-f54.google.com with SMTP id 2adb3069b0e04-59e4a04f059so965481e87.2 for ; Fri, 13 Feb 2026 02:59:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1770980348; x=1771585148; darn=vger.kernel.org; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to; bh=+T4GI3Ari/F68CoDGesyTms8wzhDFFZmgjFqbgJPCOE=; b=M3/L3F/GebPv2gwLhcthVL76WgA0euGEgRSW4YLEXJa0UbTTl7nTUV90yqRn56GffO Cv2CNA28Btul0tVVStd4191M6V/DEx+ZKgX/3YwQpi4RL5M6M/wy9TM+tOc0ujKsaQeq oWNzITJVYhH6/81us3cbQZRUb2ahK6eUyN/laUHJFqwkvCan3Xk6OGmzfEL6I8y1alku GXMbx2QyBmUXts6bl6CynwFmRGESFuiKmJXZvk0dQ64k53aycyqHVH77T9wRAEmI5J20 gJ6dVNTcMgke+2JaxvEUKjlS42ZZwWqPNZ/LGx9QXGexocNJqyDUPhUcQgm6u+PqmFhB ukjw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1770980348; x=1771585148; h=in-reply-to:content-transfer-encoding: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=+T4GI3Ari/F68CoDGesyTms8wzhDFFZmgjFqbgJPCOE=; b=mf4NLa+/ClhMB5+zDTd+OvtC4aUFqgPPQe5t+ukj92r6EoR8Q6T909rjGDuKKomOSr UcurHNeMCM1X52J4W7Ht92Np6okkwPltI8kimIC1PCz+pwXsuZ0R7CXLVVsqDpOn2Sem kNn+dMyAx/veVTXF/M9HXqZW8WerEt3GLibSI1XJl+zilQh9QYwG0G7uLH8fOfFV7V6U r8GkqDSlCxzHHViR0sTgCZH5xgtXFxiRJo+6Y07NTl5/jTzoGxqJyNGxDQf2X1axr0p0 eAHVbJluwlQ8UZnwRQn/gdQGl1ed327V0APSR0UmJP/FM5M08rQELjidAopMgDOT0saH HWFw== X-Forwarded-Encrypted: i=1; AJvYcCXNu2c53oKOAnDoDnNQ1914hCBmCqRhDcxzGYC0Q291NkRclVJrsfcwgTdX1skN17eqTbNdjqybXouN+nw=@vger.kernel.org X-Gm-Message-State: AOJu0Yz4akHg2Xmai6RUBIn9DcCCZdgMttLLuSZ/hGV9dtUVbcKWuKCL 7s4TMKqMiN87T7RPB1i2jLGXeeLq6BpKcYgH4Rz0u8Uf0QFWoEj3gSsB X-Gm-Gg: AZuq6aJIhsrIBS0cSbwQEZpqPUjh9ZpBmb5fKeUJu69VAj40nwBiSYz7044wzn+eOXe HI3Md31zPEt/twn3oeoUurhE1Z2WNr8SQ+NiJUhuGxpXuhYBS+nY5aEYSmPoJzbl3Tbco134E3X KwJj4w9uEJ96hp7uqrtZMcy12S/zVTQIREt6kREfPDrjEoFQmfhR+I6Dgxhqkb9JMJXpYWzfptY VgDRnlcEHPx6ejT7/7uhJqxVboWY3cFYSKngaRO6tb+NigdTVX420G+wI0aRoHdIOshhRs7C3pa 1oNHOwbT1TLzzmjVjvR3OZocucgd0SF7Irwa+BBEAi5FVrVH0fYDj00tAir9euQVtGGrOPVcFmn kUxCE7vHkkbOeWEk43jupyuYTFrw+lNbLM0ZM56mQA5DXRI8mAa/UP1n80e6sgmQvxbcxpMnupE kjoLeFu//zijkOeaiPKMnyCLWKCGDWis3SqbM8remqQPEINfxAj/XHmum9NbB3p14OCTnA+lw= X-Received: by 2002:a05:6512:3a82:b0:59e:44fd:8066 with SMTP id 2adb3069b0e04-59f69c5bb66mr598242e87.33.1770980347610; Fri, 13 Feb 2026 02:59:07 -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-59e5f5ad79bsm1495543e87.70.2026.02.13.02.59.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Feb 2026 02:59:06 -0800 (PST) Date: Fri, 13 Feb 2026 11:59:05 +0100 From: Marcus Folkesson To: Peter Rosin Cc: Wolfram Sang , Michael Hennerich , Bartosz Golaszewski , Andi Shyti , Bartosz Golaszewski , linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH v4 2/5] i2c: mux: add support for per channel bus frequency Message-ID: References: <20260128-i2c-mux-v4-0-dee49ce276c0@gmail.com> <20260128-i2c-mux-v4-2-dee49ce276c0@gmail.com> <2ecbebd8-0842-34fa-a593-25168c91aa6b@axentia.se> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable In-Reply-To: Hi Peter, On Thu, Feb 12, 2026 at 10:47:36PM +0100, Marcus Folkesson wrote: > Hi Peter! >=20 > Thank you so much for your thoughs! >=20 > On Thu, Feb 12, 2026 at 04:02:16PM +0100, Peter Rosin wrote: > > Hi! > >=20 >=20 > [...] >=20 > > > +static int i2c_mux_select_chan(struct i2c_adapter *adap, u32 chan_id) > > > +{ > > > + struct i2c_mux_priv *priv =3D adap->algo_data; > > > + struct i2c_mux_core *muxc =3D priv->muxc; > > > + struct i2c_adapter *parent =3D muxc->parent; > > > + struct i2c_adapter *root; > > > + int ret; > > > + > > > + if (priv->adap.clock_hz && priv->adap.clock_hz !=3D parent->clock_h= z) { > > > + root =3D i2c_root_adapter(&adap->dev); > > > + > > > + /* if we are parent-locked and the root adapter is our parent, > > > + * we already have the lock we need. Otherwise take the bus lock f= or the root > > > + * adapter before changing bus clock. > > > + */ > >=20 > > The assumptions made for the "otherwise" case is wrong, I think. >=20 > I think you are right. >=20 > > Consider e.g. the case where we are parent-locket, our parent is > > another parent-locked mux and our grand-parent is the root adapter. > > In that case we also have all the locks we need. Trying to grab > > them again will be a deadlock. > >=20 > > The more correct approach is to do the parent walk in search of > > the first ancestor mux that is not parent-locked and then call >=20 > Hrm, does it not apply for all mutex-locked ancestors? >=20 > Consider the following chain: > Root - P1 - M1 - M2 - P2 - D1 >=20 > P - Parent locked > M - Mux locked > D - Device >=20 > In this case we need to lock both M1 and M2, not just M2 ? > I'm not completely sure though, I need to refresh myself on the code > base. Okay, after a good night's sleep, I think it should lock not the first but topmost not parent-locked mux only, IOW, M1 in the example above. Then the locking would be propageted up to the root adapter. I will send out a v5 for this soon. Best regards, Marcus Folkesson