From nobody Wed Nov 27 02:40:53 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1701082790; cv=none; d=zohomail.com; s=zohoarc; b=jYB7fL2uH8D1MPKQJpV6SECmFhYyFK6Gplc+XugfWZXDlI+6xyW3UCv6su8CdRyfSutmPilk1/h+Xmhm4AYNl2zH4D1pEhv9wlWv7117N7B4mu5rJSgS7mIW1e2rOUxCvTIg8qbJ1zvN1JT9nveITqH2xcMdpKbTp02OOSrGGyc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1701082790; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=LhYJOjXiM4Bj7KpsRd+A9qv7CrsEwzIsriCSWgcNzJc=; b=AavKyu2YNdBrFVfrQNlcl5xFr43+D1ZLqd/AFpCY7TSDwxty2GH0ITqij5giNrzj7+ZJTdyPkwc/k+/M/1wraihCwj4Xaz/o2e5ALS8pIG78Gqgl932sCyMIuC+JfSayL/3mOo+xftAYdT6L8E1ZiI7MDth+7ZGjHS8u6sBEo/k= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=<42.hyeyoo@gmail.com> (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 1701082790150331.86660660960797; Mon, 27 Nov 2023 02:59:50 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r7ZKI-0003ln-HN; Mon, 27 Nov 2023 05:58:54 -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 <42.hyeyoo@gmail.com>) id 1r7ZKB-0003l9-TE for qemu-devel@nongnu.org; Mon, 27 Nov 2023 05:58:48 -0500 Received: from mail-pf1-x42e.google.com ([2607:f8b0:4864:20::42e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from <42.hyeyoo@gmail.com>) id 1r7ZK8-00066N-NG for qemu-devel@nongnu.org; Mon, 27 Nov 2023 05:58:46 -0500 Received: by mail-pf1-x42e.google.com with SMTP id d2e1a72fcca58-6cd89f2af9dso928471b3a.1 for ; Mon, 27 Nov 2023 02:58:44 -0800 (PST) Received: from localhost.localdomain ([1.245.180.67]) by smtp.gmail.com with ESMTPSA id mp21-20020a17090b191500b002801ca4fad2sm7508351pjb.10.2023.11.27.02.58.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Nov 2023 02:58:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701082723; x=1701687523; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=LhYJOjXiM4Bj7KpsRd+A9qv7CrsEwzIsriCSWgcNzJc=; b=My2fX9ClIREDAqEJBZTUm+0jLv/YLLg3aaVug/4o1AVdSCXJZTMS3u7AWXVi8v6MPy rB5G5PvN8bvO6AxqMDFuG+9NjLoTiNzoPmv3btoqFSjdlAMkMKtKB0IkJ6i7NfC3e3G7 cNhkyXUdpBtYYYCFUuGkqmJkySskxzjFWDhdEGh+TPTXh1/avk/49NtDnTKnsWajJ5ol GiGGjQvMqPB4TrpY6RUMuzsRW133WEgpL1/JCU8tUEk9Olx+yT7XJOBBbVLUo/y19C0G yTrr6BQqGzFQ3GDpVZt9MgLUNQP5jkajbnFykWNe6joeg/nMq/kNcmaaMFdp3EQBNmSG Hmcg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701082723; x=1701687523; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=LhYJOjXiM4Bj7KpsRd+A9qv7CrsEwzIsriCSWgcNzJc=; b=OIfSbxxRbhqTyqv0fUhoI5/9mAGLbyYvPgHEv+pa1V9M8/momnPqVqC/S3yf2m7d8i Hx+N8GoBvowEv/D7AxrKTZLvJfpp/pggMHlKh5H1lX8Ju/iyrOrfHtTMTf6o2AzyppbC 17nlZQmPJIbJbCeee2SxLoe2FB+pq9dH0QoIDKoerVmgAaYYkjzMEKAhDCKUHgCB038u /aID8lQIZwr/VUEp39Wy+i/sJRjx3BzS02gNfNpFFaVdrusu6PqvlJ1NQa1py0mUx1Be XvlObZlCuxVMPGmyRi0I+w3gZnPNMO7G/LN9gE+3U3+KszFPIdIvCMv6XjH3Y/dZ1OEa ljNg== X-Gm-Message-State: AOJu0YyhsG2/S5KbFCjwuLopXcs5UNsYPh/p5tSw2S59oCjloeA6qUv3 Rw7QzSzQ4zQSxW2yYp4rTws= X-Google-Smtp-Source: AGHT+IEZ+MwgU+VJjGDw3ojZ0RNPwD1DqexbUg9l57CLuDVl/j0HWa2VEjfzqfGtifj7lrGBzHcLqg== X-Received: by 2002:a05:6a21:99a6:b0:18c:63cb:e86e with SMTP id ve38-20020a056a2199a600b0018c63cbe86emr7787487pzb.2.1701082723006; Mon, 27 Nov 2023 02:58:43 -0800 (PST) From: Hyeonggon Yoo <42.hyeyoo@gmail.com> To: Jonathan Cameron , Fan Ni , "Michael S . Tsirkin" Cc: linux-cxl@lore.kernel.org, qemu-devel@nongnu.org, Davidlohr Bueso , Hyeonggon Yoo <42.hyeyoo@gmail.com> Subject: [PATCH v1 1/2] hw/cxl/device: read from register values in mdev_reg_read() Date: Mon, 27 Nov 2023 19:58:29 +0900 Message-Id: <20231127105830.2104954-2-42.hyeyoo@gmail.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20231127105830.2104954-1-42.hyeyoo@gmail.com> References: <20231127105830.2104954-1-42.hyeyoo@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=2607:f8b0:4864:20::42e; envelope-from=42.hyeyoo@gmail.com; helo=mail-pf1-x42e.google.com X-Spam_score_int: 0 X-Spam_score: -0.1 X-Spam_bar: / X-Spam_report: (-0.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, FREEMAIL_FROM=0.001, HK_RANDOM_ENVFROM=1, HK_RANDOM_FROM=1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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 @gmail.com) X-ZM-MESSAGEID: 1701082791366000001 Content-Type: text/plain; charset="utf-8" In the current mdev_reg_read() implementation, it consistently returns that the Media Status is Ready (01b). This was fine until commit 25a52959f99d ("hw/cxl: Add support for device sanitation") because the media was presumed to be ready. However, as per the CXL 3.0 spec "8.2.9.8.5.1 Sanitize (Opcode 4400h)", during sanitation, the Media State should be set to Disabled (11b). The mentioned commit correctly sets it to Disabled, but mdev_reg_read() still returns Media Status as Ready. To address this, update mdev_reg_read() to read register values instead of returning dummy values. Fixes: commit 25a52959f99d ("hw/cxl: Add support for device sanitation") Signed-off-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Reviewed-by: Davidlohr Bueso --- hw/cxl/cxl-device-utils.c | 17 +++++++++++------ include/hw/cxl/cxl_device.h | 4 +++- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/hw/cxl/cxl-device-utils.c b/hw/cxl/cxl-device-utils.c index 61a3c4dc2e..f1111eb20f 100644 --- a/hw/cxl/cxl-device-utils.c +++ b/hw/cxl/cxl-device-utils.c @@ -229,12 +229,9 @@ static void mailbox_reg_write(void *opaque, hwaddr off= set, uint64_t value, =20 static uint64_t mdev_reg_read(void *opaque, hwaddr offset, unsigned size) { - uint64_t retval =3D 0; - - retval =3D FIELD_DP64(retval, CXL_MEM_DEV_STS, MEDIA_STATUS, 1); - retval =3D FIELD_DP64(retval, CXL_MEM_DEV_STS, MBOX_READY, 1); + CXLDeviceState *cxl_dstate =3D opaque; =20 - return retval; + return cxl_dstate->mbox_reg_state64[R_CXL_MEM_DEV_STS]; } =20 static void ro_reg_write(void *opaque, hwaddr offset, uint64_t value, @@ -371,7 +368,15 @@ static void mailbox_reg_init_common(CXLDeviceState *cx= l_dstate) cxl_dstate->mbox_msi_n =3D msi_n; } =20 -static void memdev_reg_init_common(CXLDeviceState *cxl_dstate) { } +static void memdev_reg_init_common(CXLDeviceState *cxl_dstate) +{ + uint64_t memdev_status_reg; + + memdev_status_reg =3D FIELD_DP64(0, CXL_MEM_DEV_STS, MEDIA_STATUS, 1); + memdev_status_reg =3D FIELD_DP64(memdev_status_reg, CXL_MEM_DEV_STS, + MBOX_READY, 1); + cxl_dstate->mbox_reg_state64[R_CXL_MEM_DEV_STS] =3D memdev_status_reg; +} =20 void cxl_device_register_init_t3(CXLType3Dev *ct3d) { diff --git a/include/hw/cxl/cxl_device.h b/include/hw/cxl/cxl_device.h index befb5f884b..873e6d6ab1 100644 --- a/include/hw/cxl/cxl_device.h +++ b/include/hw/cxl/cxl_device.h @@ -353,7 +353,9 @@ static inline void __toggle_media(CXLDeviceState *cxl_d= state, int val) { uint64_t dev_status_reg; =20 - dev_status_reg =3D FIELD_DP64(0, CXL_MEM_DEV_STS, MEDIA_STATUS, val); + dev_status_reg =3D cxl_dstate->mbox_reg_state64[R_CXL_MEM_DEV_STS]; + dev_status_reg =3D FIELD_DP64(dev_status_reg, CXL_MEM_DEV_STS, MEDIA_S= TATUS, + val); cxl_dstate->mbox_reg_state64[R_CXL_MEM_DEV_STS] =3D dev_status_reg; } #define cxl_dev_disable_media(cxlds) \ --=20 2.39.1 From nobody Wed Nov 27 02:40:53 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1701082771; cv=none; d=zohomail.com; s=zohoarc; b=giEAHrY4ojwS+9SjqnDlNx08D4McEwF9f9p3LAJTlOdGvwft5tsQtsgR0JIfutbt2ngjRUtDA/D7gbHkd8rjQp5SnwMDV7gOFMXDfc9jKnGwYdYfEgoVxSVlQqxX4UKDzvMTbujEeoLLz8Bofm3vZola6WhsNK6jMg34WqxLZ6k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1701082771; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=+0aTzAq6W7EbYaE2S8Vh4ITPH2FgfVuM24WZURH+ztM=; b=G6n4I1FLk+v55HL1FUlw28CuAYoKTBkEyPxz18AHbACz0Niy0SpUzmZg6WDHbBhvSaIgqmpljjOp2k/Dj2+K7lDJWkD0ZvrJFfDXoMiaNtmFrEjpifWzJri4l+uOi1lBt0yL7/9iOX8LkZprw/VyJUMZlsvsrb/7PERuf4hUPQI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=<42.hyeyoo@gmail.com> (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 1701082771474869.8229879357971; Mon, 27 Nov 2023 02:59:31 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r7ZKJ-0003mK-Ai; Mon, 27 Nov 2023 05:58:55 -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 <42.hyeyoo@gmail.com>) id 1r7ZKG-0003lV-59 for qemu-devel@nongnu.org; Mon, 27 Nov 2023 05:58:52 -0500 Received: from mail-pj1-x102f.google.com ([2607:f8b0:4864:20::102f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from <42.hyeyoo@gmail.com>) id 1r7ZKB-00066m-Ty for qemu-devel@nongnu.org; Mon, 27 Nov 2023 05:58:50 -0500 Received: by mail-pj1-x102f.google.com with SMTP id 98e67ed59e1d1-2857670af8cso2774588a91.0 for ; Mon, 27 Nov 2023 02:58:47 -0800 (PST) Received: from localhost.localdomain ([1.245.180.67]) by smtp.gmail.com with ESMTPSA id mp21-20020a17090b191500b002801ca4fad2sm7508351pjb.10.2023.11.27.02.58.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Nov 2023 02:58:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701082726; x=1701687526; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=+0aTzAq6W7EbYaE2S8Vh4ITPH2FgfVuM24WZURH+ztM=; b=SbIYukhwNAVd3odgbKuurNHcG8jHna+Q/0Bse2TTjZrYY2/Xjmh+uUpjAjB6XcpViR ZM4/ZFoNLfnCwBMjizZHnyrV/ZFyhxF5a11RL9iN2SZ/OOnZPwRuNQ4vqGrCL13J09d5 +6kLk9HGQaQGKkdcRtwQ7TJ0/wTdEb281PTf0+67d23uG0pUPpwkdHV0WT+s4A11QpU+ bv1yFByZCanYkWlz4wMgUtdI5LaO97tID+AZhGSrbO5uHMgWwf+Nn1JjMJ0dqbTc2UpP wWCKPzPOm6wC6AbrIXhpcqisYBmtlMUEDPWJFP86WYyTcuHRwI1O6hBLCFr59vkh/B// z/Tw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701082726; x=1701687526; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=+0aTzAq6W7EbYaE2S8Vh4ITPH2FgfVuM24WZURH+ztM=; b=DWGMvN4dBWTkOkvnHmubGTm75ksuLTI4JM8dn0TkSkgXCdOdhVhw5wSbq3BO+/+qc1 iIjBqGbNwsbi3YnxIod9W3CZrGo7j/WdLx1LWaDjGhtLXlqHyoEbSZE3GG14gRChLwrO rSyQTQRq0jx61YQepmxuGPIU82LkLc6BAz2mgRF2ANCRAbj4csBLODc/40h2COMpkY9U 86mK1sZ7w6Egbw4msvrIe4jKzpMXkxVJYvncH3biPZ/w1YYVA6kuC8dJLClfQhjMZ7ee pVJC8B2G4LTn2kRL0oTxKtlpq6SOSD2xrefjkZjcczdrPvYoLYrDoqrPRInVQrjrGA4V hqyQ== X-Gm-Message-State: AOJu0YzHiomkvYbR7OclO8oPAEA4+oFmxDFtrp2HG2mwJQldnH6t6rC4 w2pD7AL0PnTVKuPPzzDwgcQ= X-Google-Smtp-Source: AGHT+IEskGqLC84KWDvFjyr7AKZEfqK0cO/j244GUmecCVGnRDrFCgipFW1MBBPfT7zBALrOei1xlg== X-Received: by 2002:a17:90b:4a84:b0:285:b6a6:c411 with SMTP id lp4-20020a17090b4a8400b00285b6a6c411mr4026667pjb.4.1701082726429; Mon, 27 Nov 2023 02:58:46 -0800 (PST) From: Hyeonggon Yoo <42.hyeyoo@gmail.com> To: Jonathan Cameron , Fan Ni , "Michael S . Tsirkin" Cc: linux-cxl@lore.kernel.org, qemu-devel@nongnu.org, Davidlohr Bueso , Hyeonggon Yoo <42.hyeyoo@gmail.com> Subject: [PATCH v1 2/2] hw/mem/cxl_type3: allocate more vectors for MSI-X Date: Mon, 27 Nov 2023 19:58:30 +0900 Message-Id: <20231127105830.2104954-3-42.hyeyoo@gmail.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20231127105830.2104954-1-42.hyeyoo@gmail.com> References: <20231127105830.2104954-1-42.hyeyoo@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=2607:f8b0:4864:20::102f; envelope-from=42.hyeyoo@gmail.com; helo=mail-pj1-x102f.google.com X-Spam_score_int: 0 X-Spam_score: -0.1 X-Spam_bar: / X-Spam_report: (-0.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, FREEMAIL_FROM=0.001, HK_RANDOM_ENVFROM=1, HK_RANDOM_FROM=1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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 @gmail.com) X-ZM-MESSAGEID: 1701082773194000006 Content-Type: text/plain; charset="utf-8" commit 43efb0bfad2b ("hw/cxl/mbox: Wire up interrupts for background completion") enables notifying background command completion via MSI-X interrupt (vector number 9). However, the commit uses vector number 9 but the maximum number of entries is less thus resulting in error below. Fix it by passing nentries =3D 10 when calling msix_init_exclusive_bar(). # echo 1 > sanitize Background command 4400h finished: success qemu-system-x86_64: ../hw/pci/msix.c:529: msix_notify: Assertion `vector <= dev->msix_entries_nr' failed. Fixes: 43efb0bfad2b ("hw/cxl/mbox: Wire up interrupts for background comple= tion") Signed-off-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> --- hw/mem/cxl_type3.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/mem/cxl_type3.c b/hw/mem/cxl_type3.c index 52647b4ac7..72d9371347 100644 --- a/hw/mem/cxl_type3.c +++ b/hw/mem/cxl_type3.c @@ -685,7 +685,7 @@ static void ct3_realize(PCIDevice *pci_dev, Error **err= p) ComponentRegisters *regs =3D &cxl_cstate->crb; MemoryRegion *mr =3D ®s->component_registers; uint8_t *pci_conf =3D pci_dev->config; - unsigned short msix_num =3D 6; + unsigned short msix_num =3D 10; int i, rc; =20 QTAILQ_INIT(&ct3d->error_list); --=20 2.39.1