lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Z6DVn8u-2EwMaMR4@smile.fi.intel.com>
Date: Mon, 3 Feb 2025 16:41:35 +0200
From: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
To: Sunil V L <sunilvl@...tanamicro.com>
Cc: Mika Westerberg <mika.westerberg@...ux.intel.com>,
	Anup Patel <apatel@...tanamicro.com>,
	Michael Turquette <mturquette@...libre.com>,
	Stephen Boyd <sboyd@...nel.org>, Rob Herring <robh@...nel.org>,
	Krzysztof Kozlowski <krzk+dt@...nel.org>,
	Conor Dooley <conor+dt@...nel.org>,
	Jassi Brar <jassisinghbrar@...il.com>,
	Thomas Gleixner <tglx@...utronix.de>,
	"Rafael J . Wysocki" <rafael@...nel.org>,
	Linus Walleij <linus.walleij@...aro.org>,
	Bartosz Golaszewski <brgl@...ev.pl>,
	Uwe Kleine-König <ukleinek@...nel.org>,
	Palmer Dabbelt <palmer@...belt.com>,
	Paul Walmsley <paul.walmsley@...ive.com>,
	Len Brown <lenb@...nel.org>,
	Rahul Pathak <rpathak@...tanamicro.com>,
	Leyfoon Tan <leyfoon.tan@...rfivetech.com>,
	Atish Patra <atishp@...shpatra.org>,
	Andrew Jones <ajones@...tanamicro.com>,
	Samuel Holland <samuel.holland@...ive.com>,
	Anup Patel <anup@...infault.org>, linux-clk@...r.kernel.org,
	devicetree@...r.kernel.org, linux-riscv@...ts.infradead.org,
	linux-kernel@...r.kernel.org
Subject: Re: [RFC PATCH v2 12/17] ACPI: property: Add support for nargs_prop
 in acpi_fwnode_get_reference_args()

On Mon, Feb 03, 2025 at 04:39:11PM +0200, Andy Shevchenko wrote:
> On Mon, Feb 03, 2025 at 07:21:50PM +0530, Sunil V L wrote:
> > On Mon, Feb 03, 2025 at 02:36:58PM +0200, Mika Westerberg wrote:
> > > On Mon, Feb 03, 2025 at 05:54:18PM +0530, Sunil V L wrote:
> > > > On Mon, Feb 03, 2025 at 12:58:40PM +0200, Mika Westerberg wrote:
> > > > > On Mon, Feb 03, 2025 at 11:43:26AM +0200, Andy Shevchenko wrote:
> > > > > > On Mon, Feb 03, 2025 at 02:19:01PM +0530, Anup Patel wrote:
> > > > > > > From: Sunil V L <sunilvl@...tanamicro.com>
> > > > > > > 
> > > > > > > fwnode_get_reference_args() which is common for both DT and ACPI passes
> > > > > > > a property name like #mbox-cells which needs to be fetched from the
> > > > > > > reference node to determine the number of arguments needed for the
> > > > > > > property. However, the ACPI version of this function doesn't support
> > > > > > > this and simply ignores the parameter passed from the wrapper function.
> > > > > > > Add support for dynamically finding number of arguments by reading the
> > > > > > > nargs property value. Update the callers to pass extra parameter.
> > > > > > 
> > > > > > I don't like this (implementation).
> > > > > 
> > > > > Agree.
> > > > > 
> > > > > > It seems that we basically have two parameters which values are duplicating
> > > > > > each other. This is error prone API and confusing in the cases when both are
> > > > > > defined. If you want property, add a new API that takes const char *nargs
> > > > > > and relies on the property be present.
> > > > > 
> > > > > Also this is not really needed for ACPI case because it has types so it can
> > > > > distinguish references from integer. Having separate property for this just
> > > > > makes things more complex than they need to be IMHO.
> > > > 
> > > > Thanks! Andy and Mika for your kind feedback. I agree that having both
> > > > property name and nargs is confusing and also ACPI would not need
> > > > nargs_prop. In fact, I think ACPI doesn't need even nargs integer value
> > > > as well from the caller since all integers after the reference are
> > > > counted as arguments.  However, the issue is acpi_get_ref_args() assumes
> > > > that caller passes valid num_args. But typically the common
> > > > fwnode_property_get_reference_args() doesn't usually pass both valid
> > > > values. So, should fwnode_property_get_reference_args() pass both
> > > > nargs_prop (for DT) and nargs (for ACPI). Or do you mean it is better to
> > > > remove the check for num_args in the loop inside acpi_get_ref_args()
> > > > function?
> > > 
> > > Can you show an example of a case you are trying to solve with this? So far
> > > we have been able to go with the current implementation so why this is
> > > needed now?
> > 
> > Basically one can call fwnode_property_get_reference_args()
> > irrespective of DT/ACPI. The case we are trying is like below.
> > 
> > if (fwnode_property_get_reference_args(dev->fwnode, "mboxes",
> > 					       "#mbox-cells", 0, index, &fwspec)) {
> > ...
> > }
> > 
> > As you can see this works for DT since OF interface handles
> > "#mbox-cells". But since nargs is passed as 0, it won't work for ACPI
> > due to the reason I mentioned earlier.
> > 
> > Mandating to pass both "#mbox-cell" and valid nargs count looks
> > redundant to me.
> 
> Ah, interesting. The original change that introduces this 3e3119d3088f ("device
> property: Introduce fwnode_property_get_reference_args") hadn't been reviewed
> by Mika or me, that's probably why we are not familiar with.
> 
> Since interface is already established, I would recommend to fix
> this as proposed, i.e. with a new API. This is the way to match
> how OF seems to be doing.

For the reference see implementation of of_fwnode_get_reference_args()

	if (nargs_prop)
		ret = of_parse_phandle_with_args(to_of_node(fwnode), prop,
						 nargs_prop, index, &of_args);
	else
		ret = of_parse_phandle_with_fixed_args(to_of_node(fwnode), prop,
						       nargs, index, &of_args);


-- 
With Best Regards,
Andy Shevchenko



Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ