From nobody Tue Feb 10 23:35:17 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1674711490; cv=none; d=zohomail.com; s=zohoarc; b=L3Djc/2QIIWkuN8VhxRa5T5CssHzbHaIAFVhGoQawAEFdxna6g1lOSvWGXf3tG2zflcYONwLYvhihcvwrTESxQkZRp+2si6LfWun0ta1+99zQaJwnlddXFFq9MvKCiVBKS8iS5wa/niGQGHn0VH2p6ETGzKd4BvybcYEjmaJaIk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1674711490; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=DpVmVp2CdLG8ivcBWVWvctT3+OQnPUMaa+iBvctdVyg=; b=k3Ey8RRk3IYKsVLtNAZ/1KZMGTMxwIq3xnSF+qJjtcfpnekHSAXuJ2gtfTitAdCEBKR35RgT7CejRGhrLFy/X8ttJUxHfMeiWZ7V/MYO8HVgnlXfGwaEHC15GltHp/Pokeg3CBVXOXkBIv2OcCczyrXL8YmpTFPlBoXc4pAFPiA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1674711490636171.62290648750297; Wed, 25 Jan 2023 21:38:10 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pKuxE-0003vg-Nq; Thu, 26 Jan 2023 00:37:44 -0500 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 1pKuxD-0003vO-F9 for qemu-devel@nongnu.org; Thu, 26 Jan 2023 00:37:43 -0500 Received: from mga18.intel.com ([134.134.136.126]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pKuxB-00066H-Dt for qemu-devel@nongnu.org; Thu, 26 Jan 2023 00:37:42 -0500 Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Jan 2023 21:37:31 -0800 Received: from iweiny-mobl.amr.corp.intel.com (HELO localhost) ([10.212.115.122]) by orsmga004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Jan 2023 21:37:30 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1674711461; x=1706247461; h=from:date:subject:mime-version:content-transfer-encoding: message-id:references:in-reply-to:to:cc; bh=wbtXIUSQfh3quDpVU0waBxAZRw2Bard66Q1jLzQ6/v4=; b=MmN0kr+3rSsQVDl2dgVi4LqPMJGggFm1VJ6mJEGkVZnqMrhmiwKBwrcb usxgEYfyYFn6y9TpRfCbI2l4k6jKuRI8iU55DONmNPoyezrjOekNZ7yGh BbIHBaSjZVleI9VuKRdc6lHrQKeHpS4wLZJpI/loYBcEHrxk2BlWqlL+U O0b/OWuWmyTn+xSNdtbZwlAdwlyTnmLEacSanWbELbxz9hNn/9nV322oH bry5zmDcE1Xi5OLqiyk0E7STgcqcQ3QoKavltTcPFAS5FJCwGwXEZe0oT K5ZX5WjghVj9+RSzWBx/X2yI76hyXi/6IHIfIVSYordHpGYMMQFn4g/uA Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10601"; a="310328967" X-IronPort-AV: E=Sophos;i="5.97,247,1669104000"; d="scan'208";a="310328967" X-IronPort-AV: E=McAfee;i="6500,9779,10601"; a="786704008" X-IronPort-AV: E=Sophos;i="5.97,247,1669104000"; d="scan'208";a="786704008" From: Ira Weiny Date: Wed, 25 Jan 2023 21:37:27 -0800 Subject: [PATCH 1/2] hw/cxl: Fix event log time stamp fields MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20230125-ira-cxl-events-fixups-2023-01-11-v1-1-1931378515f5@intel.com> References: <20230125-ira-cxl-events-fixups-2023-01-11-v1-0-1931378515f5@intel.com> In-Reply-To: <20230125-ira-cxl-events-fixups-2023-01-11-v1-0-1931378515f5@intel.com> To: Jonathan Cameron Cc: Michael Tsirkin , Ben Widawsky , Peter Maydell , qemu-devel@nongnu.org, linux-cxl@vger.kernel.org, Ira Weiny , Jonathan Cameron X-Mailer: b4 0.12-dev-cc11a X-Developer-Signature: v=1; a=ed25519-sha256; t=1674711449; l=4001; i=ira.weiny@intel.com; s=20221211; h=from:subject:message-id; bh=wbtXIUSQfh3quDpVU0waBxAZRw2Bard66Q1jLzQ6/v4=; b=JpcOxvvrvGTjf1ozWyWNB8NAoCkavbUxwTNnrwrTW2etv+OTwmsLyC1AIdK3RSrHAyhHDeJi2uX2 W+v3cP5pDMx3sWgkF4r1iPVz2StVtOHh+YNn+81GTRBQVWZkiR4f X-Developer-Key: i=ira.weiny@intel.com; a=ed25519; pk=noldbkG+Wp1qXRrrkfY1QJpDf7QsOEthbOT7vm0PqsE= Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=134.134.136.126; envelope-from=ira.weiny@intel.com; helo=mga18.intel.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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @intel.com) X-ZM-MESSAGEID: 1674711493104100001 CXL 3.0 8.2.9.4.2 Set Timestamp and 8.2.9.4.1 Get Timestamp define the way for software to set and get the time stamp of a device. Events should use a time stamp consistent with the Get Timestamp mailbox command. In addition avoid setting the time stamp twice. Fixes: fb64c5661d5f ("hw/cxl/events: Wire up get/clear event mailbox comman= ds") Reported-by: Jonathan Cameron Signed-off-by: Ira Weiny --- hw/cxl/cxl-device-utils.c | 15 +++++++++++++++ hw/cxl/cxl-events.c | 4 +++- hw/cxl/cxl-mailbox-utils.c | 11 +---------- hw/mem/cxl_type3.c | 1 - include/hw/cxl/cxl_device.h | 2 ++ 5 files changed, 21 insertions(+), 12 deletions(-) diff --git a/hw/cxl/cxl-device-utils.c b/hw/cxl/cxl-device-utils.c index 7f29d40be04a..5876a3703e85 100644 --- a/hw/cxl/cxl-device-utils.c +++ b/hw/cxl/cxl-device-utils.c @@ -325,3 +325,18 @@ void cxl_device_register_init_swcci(CXLDeviceState *cx= l_dstate) =20 cxl_initialize_mailbox(cxl_dstate, true); } + +uint64_t cxl_device_get_timestamp(CXLDeviceState *cxl_dstate) +{ + uint64_t time, delta; + uint64_t final_time =3D 0; + + if (cxl_dstate->timestamp.set) { + /* First find the delta from the last time the host set the time. = */ + time =3D qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL); + delta =3D time - cxl_dstate->timestamp.last_set; + final_time =3D cxl_dstate->timestamp.host_set + delta; + } + + return final_time; +} diff --git a/hw/cxl/cxl-events.c b/hw/cxl/cxl-events.c index 08fd52b66188..2536aafc55fb 100644 --- a/hw/cxl/cxl-events.c +++ b/hw/cxl/cxl-events.c @@ -100,7 +100,7 @@ bool cxl_event_insert(CXLDeviceState *cxlds, enum cxl_event_log_type log_type, struct cxl_event_record_raw *event) { - uint64_t time =3D qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL); + uint64_t time; struct cxl_event_log *log; CXLEvent *entry; =20 @@ -108,6 +108,8 @@ bool cxl_event_insert(CXLDeviceState *cxlds, return false; } =20 + time =3D cxl_device_get_timestamp(cxlds); + log =3D &cxlds->event_logs[log_type]; =20 QEMU_LOCK_GUARD(&log->lock); diff --git a/hw/cxl/cxl-mailbox-utils.c b/hw/cxl/cxl-mailbox-utils.c index 75703023434b..0e64873c2395 100644 --- a/hw/cxl/cxl-mailbox-utils.c +++ b/hw/cxl/cxl-mailbox-utils.c @@ -394,17 +394,8 @@ static CXLRetCode cmd_timestamp_get(struct cxl_cmd *cm= d, CXLDeviceState *cxl_dstate, uint16_t *len) { - uint64_t time, delta; - uint64_t final_time =3D 0; - - if (cxl_dstate->timestamp.set) { - /* First find the delta from the last time the host set the time. = */ - time =3D qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL); - delta =3D time - cxl_dstate->timestamp.last_set; - final_time =3D cxl_dstate->timestamp.host_set + delta; - } + uint64_t final_time =3D cxl_device_get_timestamp(cxl_dstate); =20 - /* Then adjust the actual time */ stq_le_p(cmd->payload, final_time); *len =3D 8; =20 diff --git a/hw/mem/cxl_type3.c b/hw/mem/cxl_type3.c index a7b587780af2..42e291dd9f76 100644 --- a/hw/mem/cxl_type3.c +++ b/hw/mem/cxl_type3.c @@ -1291,7 +1291,6 @@ static void cxl_assign_event_header(struct cxl_event_= record_hdr *hdr, hdr->flags[0] =3D flags; hdr->length =3D length; memcpy(&hdr->id, uuid, sizeof(hdr->id)); - hdr->timestamp =3D qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL); } =20 static const QemuUUID gen_media_uuid =3D { diff --git a/include/hw/cxl/cxl_device.h b/include/hw/cxl/cxl_device.h index cbb37c541c44..31579af342f1 100644 --- a/include/hw/cxl/cxl_device.h +++ b/include/hw/cxl/cxl_device.h @@ -426,4 +426,6 @@ CXLRetCode cxl_event_clear_records(CXLDeviceState *cxld= s, =20 void cxl_event_irq_assert(CXLType3Dev *ct3d); =20 +uint64_t cxl_device_get_timestamp(CXLDeviceState *cxlds); + #endif --=20 2.39.1 From nobody Tue Feb 10 23:35:17 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1674711505; cv=none; d=zohomail.com; s=zohoarc; b=GeXz9e9ExtPs66tSZXR60VDR8Xo8HUkd/lMnpfEsqY90n+BvkS6XNHwsqRbiF2VQFX+ZUuBivhRHEwKxEI+lmf9UPg/KBhi5EFTEZ4fPoR2IKSWnCkc1L+6iDuYcECdWqrgQ89WSTURWW5Pgl0vyusVIZAiu1FFUKsaN/MHqyMU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1674711505; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=YbNKTsmx/bQVybS4V5nB9CqILEfLLadGocp+IaHclac=; b=Skr/INyBWbHfUxt7dKVTGYmACStc9+2Fr4cIvYPmUujpuhi+G98bw30IdaqDxxhcmd+3OsvD4Ll8qpTegA4EIJiPH94dxBOoDEm1ZoCs5sj/fC8bxHaDzZlBzWa+bk9tuStSBoAGruoqbv49IhKxHawzQHwg9YltAK39G2wH8cI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1674711505079169.70434379814958; Wed, 25 Jan 2023 21:38:25 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pKuxF-0003vi-BH; Thu, 26 Jan 2023 00:37:45 -0500 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 1pKuxD-0003vX-Qi for qemu-devel@nongnu.org; Thu, 26 Jan 2023 00:37:43 -0500 Received: from mga18.intel.com ([134.134.136.126]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pKuxC-00067B-AZ for qemu-devel@nongnu.org; Thu, 26 Jan 2023 00:37:43 -0500 Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Jan 2023 21:37:32 -0800 Received: from iweiny-mobl.amr.corp.intel.com (HELO localhost) ([10.212.115.122]) by orsmga004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Jan 2023 21:37:31 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1674711462; x=1706247462; h=from:date:subject:mime-version:content-transfer-encoding: message-id:references:in-reply-to:to:cc; bh=TmttUS7xwD55ClAuoEUKjKv5YzYGUkVO9chKYEHMpSM=; b=TjjNwCj/ERBVx6DSui6x6sWJE+Vs5zjamqEGBe/Pb4noC74tNPRY6HbY DprvSP/QyX+TAvRb4QlEtodLn2GJK1C1ixVxqEDFZG9vwlCXS+g8u8mOA RxTnvgdQkl92Ra1EYvgMxgpEmXqmg9xGMwjXnepvrVMkRpSWu+fogvvvf aLgr3AuSwYY2JHg02c60K7+zk792FTkdnCRT3qNLCC+QPz/5VVAbno1QI MXA19lkK+rpDLtRFjsDfSo4eoYZ+Oz3HIsgTZ7jPcwjTey6pd538PFsL7 Lm66ut1nlSCyEK7x6wmURwqhMmsDcyBniMl6rqvs2O0SJRnnGB0k92YRX A==; X-IronPort-AV: E=McAfee;i="6500,9779,10601"; a="310328974" X-IronPort-AV: E=Sophos;i="5.97,247,1669104000"; d="scan'208";a="310328974" X-IronPort-AV: E=McAfee;i="6500,9779,10601"; a="786704012" X-IronPort-AV: E=Sophos;i="5.97,247,1669104000"; d="scan'208";a="786704012" From: Ira Weiny Date: Wed, 25 Jan 2023 21:37:28 -0800 Subject: [PATCH 2/2] hw/cxl: Remove check for g_new0() failure MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20230125-ira-cxl-events-fixups-2023-01-11-v1-2-1931378515f5@intel.com> References: <20230125-ira-cxl-events-fixups-2023-01-11-v1-0-1931378515f5@intel.com> In-Reply-To: <20230125-ira-cxl-events-fixups-2023-01-11-v1-0-1931378515f5@intel.com> To: Jonathan Cameron Cc: Michael Tsirkin , Ben Widawsky , Peter Maydell , qemu-devel@nongnu.org, linux-cxl@vger.kernel.org, Ira Weiny , Jonathan Cameron X-Mailer: b4 0.12-dev-cc11a X-Developer-Signature: v=1; a=ed25519-sha256; t=1674711449; l=923; i=ira.weiny@intel.com; s=20221211; h=from:subject:message-id; bh=TmttUS7xwD55ClAuoEUKjKv5YzYGUkVO9chKYEHMpSM=; b=SjGQo8fu61yc0Hc9DTQNnWEmFHvaMA+6yZUN5MNbr+XC/5Y4Y9tYlIYgSAF92Whod51le4rB/Lcu QWYpyEVjCThrmtlIlECwrqzdZobehQV/tJuhyHNkq75KK8DlcxkY X-Developer-Key: i=ira.weiny@intel.com; a=ed25519; pk=noldbkG+Wp1qXRrrkfY1QJpDf7QsOEthbOT7vm0PqsE= Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=134.134.136.126; envelope-from=ira.weiny@intel.com; helo=mga18.intel.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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @intel.com) X-ZM-MESSAGEID: 1674711506522100001 g_new0() will terminate the application if it fails. Remove the check. Fixes: fb64c5661d5f ("hw/cxl/events: Wire up get/clear event mailbox comman= ds") Reported-by: Jonathan Cameron Signed-off-by: Ira Weiny --- hw/cxl/cxl-events.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/hw/cxl/cxl-events.c b/hw/cxl/cxl-events.c index 2536aafc55fb..4cbc838e8ff4 100644 --- a/hw/cxl/cxl-events.c +++ b/hw/cxl/cxl-events.c @@ -124,13 +124,7 @@ bool cxl_event_insert(CXLDeviceState *cxlds, } =20 entry =3D g_new0(CXLEvent, 1); - if (!entry) { - error_report("Failed to allocate memory for event log entry"); - return false; - } - memcpy(&entry->data, event, sizeof(*event)); - entry->data.hdr.handle =3D cpu_to_le16(log->next_handle); log->next_handle++; /* 0 handle is never valid */ --=20 2.39.1