Thread (5 messages) 5 messages, 3 authors, 2021-03-22

Re: [PATCH v3 1/1] ACPI: scan: Use unique number for instance_no

From: Andy Shevchenko <hidden>
Date: 2021-03-22 16:12:55
Also in: lkml

On Mon, Mar 22, 2021 at 5:42 PM Rafael J. Wysocki [off-list ref] wrote:
On Mon, Mar 22, 2021 at 4:02 PM Andy Shevchenko
[off-list ref] wrote:
quoted
On Mon, Mar 22, 2021 at 4:57 PM Rafael J. Wysocki [off-list ref] wrote:
quoted
On Fri, Mar 19, 2021 at 8:21 PM Andy Shevchenko
[off-list ref] wrote:
quoted
The decrementation of acpi_device_bus_id->instance_no
in acpi_device_del() is incorrect, because it may cause
a duplicate instance number to be allocated next time
a device with the same acpi_device_bus_id is added.

Replace above mentioned approach by using IDA framework.
...
quoted
quoted
+       result = ida_simple_get(&acpi_device_bus_id->instance_ida, 0, 255, GFP_KERNEL);
This is ida_alloc_range(ida, start, (end) - 1, gfp), so I think it
should be 256 above, instead of 255.
Ah, good catch!

quoted
While at it, though, there can be more than 256 CPU devices easily on
contemporary systems, so I would use a greater number here.  Maybe
4096 and define a symbol for it?
I was thinking about it, but there is a problem with the device name,
since it will break a lot of code,
What problem is there?
If we have only 2 digits, but you are right, we have _at least_ two digits.
quoted
And taking into account that currently we don't change the behaviour
it is good enough per se as a fix.

That said, we may extend by an additional patch with a logic like this:

res = ida_get(4096)
if (res < 0)
  return res;
if (res >= 256)
 use %04x
else
 use %02x

Would it make sense to you?
I'm not sure why not to always use %02x ?  It doesn't truncate numbers
longer than 2 digits AFAICS.
Yeah, should work. Thanks for review, I'll send a new version soon.

-- 
With Best Regards,
Andy Shevchenko
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help