hw/intc/riscv_aplic: Remove redundant masking of hart_idx in riscv_aplic_msi_send()
PATCH 1/1 hw/intc/riscv_aplic: Remove redundant masking of hart_idx in riscv_aplic_msi_send()
The line "hart_idx &= APLIC_xMSICFGADDR_PPN_LHX_MASK(lhxw);" was removed because the same operation is performed later in the address calculation. This change improves code clarity and avoids unnecessary operations.
--- hw/intc/riscv_aplic.c | 1 - 1 file changed, 1 deletion(-)
hw/intc/riscv_aplic.c +0 -1
@@ -421,7 +421,6 @@ static void riscv_aplic_msi_send(RISCVAPLICState *aplic, APLIC_xMSICFGADDRH_HHXW_MASK; group_idx = hart_idx >> lhxw; - hart_idx &=APLIC_xMSICFGADDR_PPN_LHX_MASK (lhxw); addr = msicfgaddr; addr |= ((uint64_t )(msicfgaddrH & APLIC_xMSICFGADDRH_BAPPN_MASK)) <<32 ;
Signature · 1 line
2.34.1
Quoted 14 lines · Huang Borong
The line "
hart_idx&=APLIC_xMSICFGADDR_PPN_LHX_MASK(lhxw);" was removed because the same operation is performed later in the address calculation. This change improves code clarity and avoids unnecessary operations.Signed-off-by Huang Borong <[email protected]>--- hw/intc/riscv_aplic.c | 1 - 1 file changed, 1 deletion(-)hw/intc/riscv_aplic.c +0
-0
hw/intc/riscv_aplic.c static void riscv_aplic_msi_send(RISCVAPLICState *aplic, · line 424
Quoted 4 lines
hw/intc/riscv_aplic.c +0
-1@@ -421,7 +421,6 @@ static void riscv_aplic_msi_send(RISCVAPLICState *aplic, APLIC_xMSICFGADDRH_HHXW_MASK; group_idx = hart_idx >> lhxw; - hart_idx &=APLIC_xMSICFGADDR_PPN_LHX_MASK (lhxw);
It is worth noticing that this will change 'hart_idx' in the qemu_log_mask() in the end:
if (result != MEMTX_OK) {
qemu_log_mask(LOG_GUEST_ERROR, "%s: MSI write failed for "
"hart_index=%d guest_index=%d eiid=%d\n",
__func__, hart_idx, guest_idx, eiid);
}But I believe 'hart_idx' in that context should be the original 'hart_idx' parameter, not the masked value like we're doing today.
Quoted 3 lines
hw/intc/riscv_aplic.c +0
-0addr = msicfgaddr; addr |= ((uint64_t )(msicfgaddrH & APLIC_xMSICFGADDRH_BAPPN_MASK)) <<32 ;
Drop "in riscv_aplic_msi_send()" from the patch summary to make it more concise.
Quoted 1 line · Huang Borong
The line "
hart_idx&=APLIC_xMSICFGADDR_PPN_LHX_MASK(lhxw);" was removed
This just states what we can easily read from the patch.
Quoted 1 line
because the same operation is performed later in the address calculation.
This is useful information that should stay in the commit message.
Quoted 1 line
This change improves code clarity and avoids unnecessary operations.
You don't need to justify removing redundant lines of code, you just need to justify that they're actually redundant.
Daniel's point about the log message is important and should be pointed out in the commit message.
Thanks,
drew
Quoted 22 lines
Signed-off-by Huang Borong <[email protected]>--- hw/intc/riscv_aplic.c | 1 - 1 file changed, 1 deletion(-)hw/intc/riscv_aplic.c +0
-1@@ -421,7 +421,6 @@ static void riscv_aplic_msi_send(RISCVAPLICState *aplic, APLIC_xMSICFGADDRH_HHXW_MASK; group_idx = hart_idx >> lhxw; - hart_idx &=APLIC_xMSICFGADDR_PPN_LHX_MASK (lhxw); addr = msicfgaddr; addr |= ((uint64_t )(msicfgaddrH & APLIC_xMSICFGADDRH_BAPPN_MASK)) <<32 ;Signature · 1 line
2.34.1