Re: [PATCH v3 1/1] ACPI: scan: Use unique number for instance_no
From: Andy Shevchenko <hidden>
Date: 2021-03-22 15:03:35
Also in:
lkml
On Mon, Mar 22, 2021 at 4:57 PM Rafael J. Wysocki [off-list ref] wrote:
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
+ 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!
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, 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? -- With Best Regards, Andy Shevchenko