From patchwork Sat Jun 22 12:06:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 806701 Delivered-To: patch@linaro.org Received: by 2002:a5d:508d:0:b0:362:4979:7f74 with SMTP id a13csp1151212wrt; Sat, 22 Jun 2024 05:07:46 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXtJi2A73zs1CE377PPuksmqZXK2jBkMiUGxDXeMsNDpdtxNBCpHSq1Oz9bIfNB7M8gd6JqrLVkxHZE7W6a0Qq0 X-Google-Smtp-Source: AGHT+IHs36vK1Ekjx28Ybl5A7+C/TuzNeSgzeYTIBS3LuA8T9y/EAjW9zhlPNzQCEn+kmBvA3JCE X-Received: by 2002:a05:620a:430f:b0:798:d882:2ac9 with SMTP id af79cd13be357-79bb3e1bedbmr1015779085a.8.1719058066228; Sat, 22 Jun 2024 05:07:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719058066; cv=none; d=google.com; s=arc-20160816; b=MlXbPpHCPOwnCddNBubz+IxdtEIqD5TnISoBvF6Kc0dFcJCnJXaGsrnkfIFZyoyWdw KsNqEK6mE7q6/4YpGRgKlPX8XMqOpwozzX5nTQ23qY/+WOe/RYbKEwEvR+5695ru7gGn 8z6b0kaA1U0NqPOBeknCX+iPZ0qqTkjV/BoqyirZDnhVowq6c5tcnxDJIJpiGuKfr8QH 0ZXTImeXzW04KzFXoGvswRJg6sqXFAng9acBonzsHEmlfr37czM3Eq6TyGfR8ggGaaDw ls0TZBDSXodjXGqOSKui+tV1biDx//jd22VeMctANrO03cOGh+xMT8b31JEnAPeVTGRM 8zFw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=eWHSPGQ4OpgUOQnB0NTDT0+Cwh6MYZ+vbNYocaAOsiE=; fh=PnYt+qEB9tAfMKoqBm2xjKOFpYyFFGPudh5cVIoieJM=; b=PP+HTOzOgeaET99mqLMxIF0WZKjA0SUnBRXSVMhk8KovdKfAsRroRRylubh1ep/Syy yBLO7uiTNJ8IXbCIzMUsAqEFQCDpGUOBUNK84a1p3GAyxEw9hYsU3nuUtX6XK8OumyDn xMZGUDPKwXjJcNYLBOQ29s82O/wKGm2k2YxzwLfrApyCwDjzHtO7dec5i8XYu7625yCq 3fYpTzPate1jWO/Q+PGpBeM47i1HuyLHkUqUzAyuXlZkd4nAW+MzT1f2ZiPSte67SOMP iE4Rjc6jjSZtsHChLGyYUEhpDpmovK2VflpuQU7RGd50aJgNNeDD/ufsvWG84m8G06DB IVjw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="zGA/CoOk"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id af79cd13be357-79bce92c9d5si398809285a.408.2024.06.22.05.07.45 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sat, 22 Jun 2024 05:07:46 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="zGA/CoOk"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sKzWB-0007lw-CP; Sat, 22 Jun 2024 08:06:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sKzW6-0007k4-Lp for qemu-devel@nongnu.org; Sat, 22 Jun 2024 08:06:50 -0400 Received: from mail-wr1-x432.google.com ([2a00:1450:4864:20::432]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sKzW4-0000JB-2A for qemu-devel@nongnu.org; Sat, 22 Jun 2024 08:06:49 -0400 Received: by mail-wr1-x432.google.com with SMTP id ffacd0b85a97d-35f2c9e23d3so2442389f8f.0 for ; Sat, 22 Jun 2024 05:06:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719058006; x=1719662806; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=eWHSPGQ4OpgUOQnB0NTDT0+Cwh6MYZ+vbNYocaAOsiE=; b=zGA/CoOkJLs6A3+/Ziuajk72PZbmKI4HXTpAhQBqIas2U1ROZeMjoBhpGM98bdZ4eB 92aiGZSRVt2pJrXMwXH217QjsLLa/Za/8DXQNPTVuGTHHCBqK40Ox+IlpE2c6n6Z/huW EhMltvx9xHXVX3OzMg/M3E/5pp9qs21CHqNVstGxMRCOTmqmb3CrXAETvtc2tN77g/1X l1xsDHOMSOcaP1X+2EK2fdtxY8DSI4T8YxJdqvmmyQAkfX4bis2QgwhgxAD/Z0CTLWix cmxR8K8nv0Sz/NH5xvqqwxdayKF+23O6Ku6bp2NhL11KGSJ3vC3gDnHz3wc5kWIm1vqc aaNw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719058006; x=1719662806; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=eWHSPGQ4OpgUOQnB0NTDT0+Cwh6MYZ+vbNYocaAOsiE=; b=cclfhpwb6nfbiP2GWjgbIM1v15mv71JpR2Q2RlrmI8uXwURjELuP37SD6eY18zOAwl M3Ugxro0JC3ltG50TCxHdRsHErCrJP0sTcHxhPPRT3cd7ryl9w+VzaT3Mzz3ARAGpyFw uZmPXl7mQ5AzwE+Q+P3VSZAeq1uXngvQz1qFeXGXFcsilDLWPjCJtn4B/XZM4jBudgI1 skRxa1VhIn1AB6STwirXEx96Kjo1BPH20jaHFgJ29Xdbt0ezic9IQUdpg/cyr+k6D+i/ Ln47MpeFd789X6r+27MqH8frfcZx6O5hKbk8zUnTxYJSdlYCRUxL5JmLme2Q/ef0khsF JtRQ== X-Gm-Message-State: AOJu0YxbSH7+QFPBHE7Gmh+fYdcT03DOxKVoR8JjoXFDJs/id/rH7+dx /YyzD4ENLbcx4iGf/9vKUP3tAsKdQ+7KMKSIT/930WHwivsUid2b2tzH2KHqOEq96n9eztt/lcE JKog= X-Received: by 2002:a05:6000:1a8c:b0:360:728d:8439 with SMTP id ffacd0b85a97d-366e36491b7mr1214622f8f.2.1719058005778; Sat, 22 Jun 2024 05:06:45 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3663a2f698dsm4393006f8f.70.2024.06.22.05.06.45 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 22 Jun 2024 05:06:45 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 01/18] hw/net/can/xlnx-versal-canfd: Fix sorting of the tx queue Date: Sat, 22 Jun 2024 13:06:26 +0100 Message-Id: <20240622120643.3797539-2-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240622120643.3797539-1-peter.maydell@linaro.org> References: <20240622120643.3797539-1-peter.maydell@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::432; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x432.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Shiva sagar Myana 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. Signed-off-by: Shiva sagar Myana Reviewed-by: Francisco Iglesias Message-id: 20240603051732.3334571-1-Shivasagar.Myana@amd.com Signed-off-by: Peter Maydell --- hw/net/can/xlnx-versal-canfd.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/hw/net/can/xlnx-versal-canfd.c b/hw/net/can/xlnx-versal-canfd.c index 47a14cfe633..5f083c21e93 100644 --- a/hw/net/can/xlnx-versal-canfd.c +++ b/hw/net/can/xlnx-versal-canfd.c @@ -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)