[PW_SID:1100296] acpi/riscv: use a dedicated insertion point in riscv_acpi_register_ext_intc()#2007
[PW_SID:1100296] acpi/riscv: use a dedicated insertion point in riscv_acpi_register_ext_intc()#2007linux-riscv-bot wants to merge 1 commit into
Conversation
…t_intc()
riscv_acpi_register_ext_intc() inserts into ext_intc_list, which
is sorted with the largest gsi_base first. It walks the list
until it finds the first entry with a smaller gsi_base, then
inserts the new entry before that entry. After the loop it also
caps the predecessor's nr_irqs if that predecessor was registered
as PENDING.
The current code uses the loop cursor for both jobs:
list_for_each_entry(node, &ext_intc_list, list) {
if (node->gsi_base < ext_intc_element->gsi_base)
break;
}
prev = list_prev_entry(node, list);
if (!list_entry_is_head(prev, &ext_intc_list, list)) {
...
}
list_add_tail(&ext_intc_element->list, &node->list);
If the loop falls through (no entry has a smaller gsi_base),
node ends up past the end of the list. `&node->list` resolves
to `&ext_intc_list` via container_of() offset cancellation. So
list_prev_entry() lands on the last real entry, and
list_add_tail() inserts at the tail. The code works today.
It is fragile though. Any future change that reads another field
of node will hit memory before the ext_intc_list global.
Track the insertion point with a dedicated list_head pointer.
Initialise pos to `&ext_intc_list`. Set it to `&node->list` on
early break. Use pos->prev for the PENDING adjustment, and pos
for list_add_tail(). The cursor is no longer touched after the
loop. Behaviour is unchanged.
Same shape as the Koschel cleanups from 2022 (e.g. 99d8ae4
tracing, 2966a99 clockevents, dc1acd5 dlm).
Signed-off-by: Maoyi Xie <maoyixie.tju@gmail.com>
Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
|
Patch 1: "acpi/riscv: use a dedicated insertion point in riscv_acpi_register_ext_intc()" |
|
Patch 1: "acpi/riscv: use a dedicated insertion point in riscv_acpi_register_ext_intc()" |
|
Patch 1: "acpi/riscv: use a dedicated insertion point in riscv_acpi_register_ext_intc()" |
|
Patch 1: "acpi/riscv: use a dedicated insertion point in riscv_acpi_register_ext_intc()" |
|
Patch 1: "acpi/riscv: use a dedicated insertion point in riscv_acpi_register_ext_intc()" |
|
Patch 1: "acpi/riscv: use a dedicated insertion point in riscv_acpi_register_ext_intc()" |
|
Patch 1: "acpi/riscv: use a dedicated insertion point in riscv_acpi_register_ext_intc()" |
|
Patch 1: "acpi/riscv: use a dedicated insertion point in riscv_acpi_register_ext_intc()" |
|
Patch 1: "acpi/riscv: use a dedicated insertion point in riscv_acpi_register_ext_intc()" |
|
Patch 1: "acpi/riscv: use a dedicated insertion point in riscv_acpi_register_ext_intc()" |
|
Patch 1: "acpi/riscv: use a dedicated insertion point in riscv_acpi_register_ext_intc()" |
|
Patch 1: "acpi/riscv: use a dedicated insertion point in riscv_acpi_register_ext_intc()" |
PR for series 1100296 applied to workflow__riscv__fixes
Name: acpi/riscv: use a dedicated insertion point in riscv_acpi_register_ext_intc()
URL: https://patchwork.kernel.org/project/linux-riscv/list/?series=1100296
Version: 1