From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5560028B7DB for ; Tue, 29 Jul 2025 10:51:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753786307; cv=none; b=S0rM+mdBvnZWoK+MCcbNODJUV+fBPi087wzbdDwcj+YeSB2YtP9oGEkg9n19pHiBlxDdOOt14IljzBNTUtOX2iemRPJrs90Eh+9ihJZpFUrJeWmZdg5JLhZBf1suxo+7QkehwFboZLjQxtzYUxboncdp+1zK88ZtHb6bhmgWweQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753786307; c=relaxed/simple; bh=7+juqtOXpL1Gd1u2gp2HFGDof2wKe6EUUDxj9qDimCs=; h=Mime-Version:Content-Type:Date:Message-Id:Cc:To:From:Subject: References:In-Reply-To; b=PaLYlszwGK+/o05d2Lq6ptywJ5XcnQfEHWy3r+zycmamSGG1/WqVLDPNU/rZ3yUy1zs72w/djPCDWBNmDMEnD+IPA9WEdv7auOwrYP6iLctwsJMblwU8sGp4iDqjA47Ih+bL68E8wPDziG6CsHagSobVlAoxke2Z+gmxxugjAtM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Vf6idapY; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Vf6idapY" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 661C2C4CEEF; Tue, 29 Jul 2025 10:51:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1753786305; bh=7+juqtOXpL1Gd1u2gp2HFGDof2wKe6EUUDxj9qDimCs=; h=Date:Cc:To:From:Subject:References:In-Reply-To:From; b=Vf6idapYZdlWakSDJj8q/5uVFHI/KEqxUrVuhtkZ1p8rUTapb53kHAJmsbyuVrq0Z xGQ8VLZS7gcWk7KkrV8QzOoC1qXgRTP5nU96dIh/SjrC/4GQ/JmKioerliWHMWVvxg dswVhkwILIOcK0eOSoyt4iPjNm8QwDKOtLosKVlQcdZwK/ZfY+vxFFjO+ZdOuU0hvE xOWiqSBI/bY3UnLhXgbVAgVFMCBbjroMDSE+ay4mVXDaqNp4ldoxJtN/D8apfFThz1 CP3qKNlx97jqsQQ6sJsq0w6NFY1VUyF/8lznfcklNgevnPvV9T7zEQv+sUEOMySoOF A7lOo8VjmdPIA== Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 Date: Tue, 29 Jul 2025 12:51:42 +0200 Message-Id: Cc: "Sean Anderson" , "Greg Kroah-Hartman" , "Ira Weiny" , , "Rafael J . Wysocki" , "Dave Ertman" To: "Leon Romanovsky" From: "Danilo Krummrich" Subject: Re: [PATCH] auxiliary: Automatically generate id References: <20250728211022.9165-1-sean.anderson@linux.dev> <20250729100132.GH402218@unreal> In-Reply-To: <20250729100132.GH402218@unreal> On Tue Jul 29, 2025 at 12:01 PM CEST, Leon Romanovsky wrote: > On Tue, Jul 29, 2025 at 11:36:27AM +0200, Danilo Krummrich wrote: >> On Mon Jul 28, 2025 at 11:10 PM CEST, Sean Anderson wrote: >> > As it turns out, ids are not allowed to have semantic meaning. Their >> > only purpose is to prevent sysfs collisions. To simplify things, just >> > generate a unique id for each auxiliary device. Remove all references = to >> > filling in the id member of the device. >> > >> > Signed-off-by: Sean Anderson >> > --- >> > >> > drivers/base/auxiliary.c | 32 +++++++++++++++++++++++--------- >> > include/linux/auxiliary_bus.h | 26 ++++++++------------------ >> > 2 files changed, 31 insertions(+), 27 deletions(-) >> > >> > diff --git a/drivers/base/auxiliary.c b/drivers/base/auxiliary.c >> > index dba7c8e13a53..f66067df03ad 100644 >> > --- a/drivers/base/auxiliary.c >> > +++ b/drivers/base/auxiliary.c >> > @@ -264,6 +264,8 @@ static const struct bus_type auxiliary_bus_type = =3D { >> > .pm =3D &auxiliary_dev_pm_ops, >> > }; >> > =20 >> > +static DEFINE_IDA(auxiliary_id); >>=20 >> I think this is the correct thing to do, even though the per device IDA = drivers >> typically went for so far produces IDs that are easier to handle when de= bugging >> things. >>=20 >> > + >> > /** >> > * auxiliary_device_init - check auxiliary_device and initialize >> > * @auxdev: auxiliary device struct >> > @@ -331,20 +333,37 @@ int __auxiliary_device_add(struct auxiliary_devi= ce *auxdev, const char *modname) >> > return -EINVAL; >> > } >> > =20 >> > + ret =3D ida_alloc(&auxiliary_id, GFP_KERNEL); >> > + if (ret < 0) { >> > + dev_err(dev, "auxiliary device id_alloc fauiled: %d\n", ret); >> > + return ret; >> > + } >> > + auxdev->id =3D ret; >>=20 >> This overwrites the ID number set by various drivers that (still) use th= e >> auxiliary_device_init() and auxiliary_device_add() pair. >>=20 >> While I agree with the general intent, I think it's a very bad idea to j= ust >> perform this change silently leaving drivers with their IDA instances no= t >> knowing that the set ID numbers do not have an effect anymore. >>=20 >> I think this should be multiple steps: >>=20 >> (1) Remove the id parameter and force an internal ID only for >> auxiliary_device_create(). >>=20 >> (2) Convert applicable drivers (and the Rust abstraction) to use >> auxiliary_device_create() rather than auxiliary_device_init() and >> auxiliary_device_add(). >>=20 >> (3) Treewide change to force an internal ID for all auxiliary devices >> considering this change in all affected drivers. > > I would suggest easier approach. > 1. Add to the proposal patch, the sed generated line which removes auxdev= ->id > assignment in the drivers. > Something like this from mlx5: > - sf_dev->adev.id =3D id; > > 2. Add standalone patches to remove not used ida_alloc/ida_free calls > from the drivers. I assume you suggest this as an alternative to (3) above? If so, that's wha= t I meant in (3), I should have written "treewide series" instead of "treewide change". Technically (2) is orthogonal, yet I think it's a bit better to do the desi= red change right away. Otherwise we end up converting all applicable drivers to implement the auxiliary device release callback (which we need for a common ida_free()) first, just to remove it later on when we convert to auxiliary_device_create().