hw/net/can/xlnx-versal-canfd: Fix sorting of the tx queue
PATCH v3 1/1 hw/net/can/xlnx-versal-canfd: Fix sorting of the tx queue
Returning an uint32_t casted to a gint from g_cmp_ids causes the tx queue to become wrongly sorted when executing g_slist_sort. Fix this by always returning -1 or 1 from g_cmp_ids based on the ID comparison instead. Also, if two message IDs are the same, sort them by using their index and transmit the message at the lowest index first.
---
Changelog:
v1 -> v2 : subject line is modified.
v2 -> v3 : subject line is modified from "[QEMU][master][PATCH" to "[QEMU][PATCH".
hw/net/can/xlnx-versal-canfd.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
hw/net/can/xlnx-versal-canfd.c +4 -1
@@ -1312,7 +1312,10 @@ static gint g_cmp_ids(gconstpointer data1, gconstpointer data2)tx_ready_reg_info *tx_reg_1 = (tx_ready_reg_info *) data1;tx_ready_reg_info *tx_reg_2 = (tx_ready_reg_info *) data2; -return tx_reg_1->can_id - tx_reg_2->can_id; +if (tx_reg_1->can_id == tx_reg_2->can_id) { +return (tx_reg_1->reg_num < tx_reg_2->reg_num) ?-1 :1 ; + } +return (tx_reg_1->can_id < tx_reg_2->can_id) ?-1 :1 ; }static void free_list (GSList *list)
Signature · 1 line
2.34.1
Peter Maydell
AppliedQuoted 7 lines · Shiva sagar Myana
Returning an
uint32_tcasted to a gint fromg_cmp_idscauses the tx queue to become wrongly sorted when executingg_slist_sort. Fix this by always returning -1 or 1 fromg_cmp_idsbased on the ID comparison instead. Also, if two message IDs are the same, sort them by using their index and transmit the message at the lowest index first.
Quoted 7 lines
Signed-off-by Shiva sagar Myana <[email protected]>Reviewed-by Francisco Iglesias <[email protected]>---
Changelog:
v1 -> v2 : subject line is modified.
v2 -> v3 : subject line is modified from "[QEMU][master][PATCH" to "[QEMU][PATCH".
The usual prefix is just "[PATCH]" (with optional 'vX' etc); it's implicit that it's a QEMU patch because you sent it to the QEMU mailing lists. But you didn't need to respin just for that -- the patch application tools strip off all the [] prefixes regardless.
Applied to target-arm.next, thanks.
-- PMM