From nobody Tue May 13 03:56:29 2025
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
ARC-Seal: i=1; a=rsa-sha256; t=1734106026; cv=none;
	d=zohomail.com; s=zohoarc;
	b=nmbbmchnXnCQdqlnDlMoygQriPgaYSkMGH/hVbAwGefD49cLpkBiwBE1eYqmoD1E9Ge+acouKms2fWVUf+Yjj5+9mH5pdKi9GAhGnqgqlRC1TSmwMHVRQXa/Z3QCOVqbjZh9dqikbUaHLQGwlKgqjRXhr/rMD6FlhOSVO3PjvG4=
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com;
 s=zohoarc;
	t=1734106026;
 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=ZEHyHCnolAD/eFAXqMw+MQuU1GhJUTNe2rn5XFdxHBc=;
	b=lG7CweWHm785wf6MSFS61nvkDAisFU03H5S3PWfa9b2um162mfJt8Q1TiNLqnujx+hQP0LdCSqIUInfhK95d6Vxo5FPbWTrQ+hDjprJWRRs0UUazor6ATwMxPXKumrWAPXl47L+WoEyM/H3OdTsYZzoTPqeHQaYrEhQJ1Ax1ME8=
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
Return-Path: <qemu-devel-bounces+importer=patchew.org@nongnu.org>
Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by
 mx.zohomail.com
	with SMTPS id 1734106026731290.6376064988498;
 Fri, 13 Dec 2024 08:07:06 -0800 (PST)
Received: from localhost ([::1] helo=lists1p.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.90_1)
	(envelope-from <qemu-devel-bounces@nongnu.org>)
	id 1tM8Bc-0001hP-R8; Fri, 13 Dec 2024 11:06:40 -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 <phil@philjordan.eu>)
 id 1tM8BT-0001gp-0T
 for qemu-devel@nongnu.org; Fri, 13 Dec 2024 11:06:31 -0500
Received: from mail-ej1-x62c.google.com ([2a00:1450:4864:20::62c])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
 (Exim 4.90_1) (envelope-from <phil@philjordan.eu>)
 id 1tM8BQ-0006ep-Dh
 for qemu-devel@nongnu.org; Fri, 13 Dec 2024 11:06:30 -0500
Received: by mail-ej1-x62c.google.com with SMTP id
 a640c23a62f3a-a9ec267b879so283270866b.2
 for <qemu-devel@nongnu.org>; Fri, 13 Dec 2024 08:06:27 -0800 (PST)
Received: from localhost.localdomain (h082218084190.host.wavenet.at.
 [82.218.84.190]) by smtp.gmail.com with ESMTPSA id
 a640c23a62f3a-aa667843413sm916683166b.24.2024.12.13.08.06.24
 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256);
 Fri, 13 Dec 2024 08:06:24 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=philjordan-eu.20230601.gappssmtp.com; s=20230601; t=1734105985;
 x=1734710785;
 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=ZEHyHCnolAD/eFAXqMw+MQuU1GhJUTNe2rn5XFdxHBc=;
 b=JKGH5/9mMxlWPFmkzFL0qiqtMh453gwzeBeT6U+gglSLP3eBpJLraSs8zHBrhF1WmG
 gs9dA0ReuCWwuTWDOiF6LpT0xTsG78AUaeuVzPQ84pZVyGcRz1TNiOiQENm5NX/CVRiy
 BOiPpe5qxu15J8OZuYiu1GEeCrd41gKKZMB2K/Wtop16bx7Nf2xQg8GyecNa16q35PMV
 ndN5Swv3G4QXcXdJtw+Dsj7mLkn1vCXat/c8QLeS30JBxdGwCBD4zG6TTuHW2zXpFf9E
 Njjq19BcKIsv9KoAYfxNjPxpKwzx/+7C7UEiGSpdmoz2RB2550MPiGtihoPLjk32VWJr
 Njkw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1734105985; x=1734710785;
 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=ZEHyHCnolAD/eFAXqMw+MQuU1GhJUTNe2rn5XFdxHBc=;
 b=ZBVae+1VPtZG4+ITu4v9DnCyNewx+o0mI2T9rGeLzSLP37tWNdjRFL6qAsZxp+em4B
 BHfsG2G385nRJselmUo8JKy606zlMNdQmXT21f/ujYnzP232r1MKnIFSnH87d9KERoVO
 TzsvtVGKFyhU9dihU7YEn8CF/StuMZAs3T2vI2C7MmoxocLxJ49XNkf+YuGAEUBSGPkz
 to5VIRZkJrhYVO1F+Xf0Uzb/VtSLAezNky2QF1tNb2zjtbdLvmwpNt9acZYVxls+nHLw
 S3AiX8Z0q75FgIhuf+hIKM6ixmic29Tfdmg7f0WzHZ51ePWua1zUEjeEwbYSVvif4CRn
 LI5w==
X-Gm-Message-State: AOJu0Yy4MWyKfXHQkR1WmouLmDeoPdTXpVkb1nAQRLbvxgLrqn9Q5Yz8
 b1KtHCbrrz3+BEC+D5SN0lKIocrJno1OJIiTJGHGz2c3SY6S4+NUgMLiuxqIfVsRxM6exlg3lQh
 cew==
X-Gm-Gg: ASbGncvla82T4ZYhLYb0zQ0OEA9rY1AZkNvFDDxQ2CXiyAoZgs11fF+Y0Wge5xEzoaI
 zbM6IVnGSIp/WYHD5zGHj/aYiEIj0duFU6YOC0/x/PZMQ/denr0gWZnJjz+rGB69r+LGE2fmM6K
 d5eJH3gfcUZc2lttRYj+CIARYNhTGS6+9IkgS71GXAiLiT6ZbDHKwcG8HHhKpZIH7Ekx5fCj4NG
 RjryymC2zau8w5AbUxS7T0QeymzON12/+nOEwR9R1hHo8+TAXxcCOFrnIJjhzOOOs0Al5bQNiXG
 o5S1FqwyoyF1kFmlmzx9C+bSbeIA7roB
X-Google-Smtp-Source: 
 AGHT+IFnhUSMC2MDBgVGiO9BUSL86lUWIFX+wCSYYiYDY8EZ21rwqxJ/h86kxYcbDr3GQqYYDxJOIw==
X-Received: by 2002:a17:907:9557:b0:aa6:7107:db00 with SMTP id
 a640c23a62f3a-aab77eab9d3mr248603666b.50.1734105985016;
 Fri, 13 Dec 2024 08:06:25 -0800 (PST)
From: Phil Dennis-Jordan <phil@philjordan.eu>
To: qemu-devel@nongnu.org
Cc: richard.henderson@linaro.org, philmd@linaro.org, thuth@redhat.com,
 zhao1.liu@intel.com, imammedo@redhat.com, akihiko.odaki@daynix.com,
 Phil Dennis-Jordan <phil@philjordan.eu>
Subject: [PATCH v2 1/6] hw/usb/hcd-xhci-pci: Use modulo to select MSI vector
 as per spec
Date: Fri, 13 Dec 2024 17:06:14 +0100
Message-Id: <20241213160619.66509-2-phil@philjordan.eu>
X-Mailer: git-send-email 2.39.5 (Apple Git-154)
In-Reply-To: <20241213160619.66509-1-phil@philjordan.eu>
References: <20241213160619.66509-1-phil@philjordan.eu>
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: neutral client-ip=2a00:1450:4864:20::62c;
 envelope-from=phil@philjordan.eu; helo=mail-ej1-x62c.google.com
X-Spam_score_int: -10
X-Spam_score: -1.1
X-Spam_bar: -
X-Spam_report: (-1.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1,
 DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001,
 SPF_NEUTRAL=0.779 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: <qemu-devel.nongnu.org>
List-Unsubscribe: <https://lists.nongnu.org/mailman/options/qemu-devel>,
 <mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>
List-Archive: <https://lists.nongnu.org/archive/html/qemu-devel>
List-Post: <mailto:qemu-devel@nongnu.org>
List-Help: <mailto:qemu-devel-request@nongnu.org?subject=help>
List-Subscribe: <https://lists.nongnu.org/mailman/listinfo/qemu-devel>,
 <mailto:qemu-devel-request@nongnu.org?subject=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 @philjordan-eu.20230601.gappssmtp.com)
X-ZM-MESSAGEID: 1734106027548116600
Content-Type: text/plain; charset="utf-8"

QEMU would crash with a failed assertion if the XHCI controller
attempted to raise the interrupt on a higher vector than the
highest configured for the device by the guest driver.

It turns out the XHCI spec (Implementation Note in section 4.17,
"Interrupters") requires that the host controller signal the MSI
vector with the number computed by taking the interrupter number
modulo the number of enabled MSI vectors.

This change introduces that modulo calculation, fixing the
failed assertion and making the device work correctly in MSI mode
with macOS's XHCI driver.

Signed-off-by: Phil Dennis-Jordan <phil@philjordan.eu>
---

v2:

 * Switch to modulo arithmetic for MSI vector number rather than dropping,
   as per spec.

 hw/usb/hcd-xhci-pci.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/hw/usb/hcd-xhci-pci.c b/hw/usb/hcd-xhci-pci.c
index a039f5778a6..516e6909d20 100644
--- a/hw/usb/hcd-xhci-pci.c
+++ b/hw/usb/hcd-xhci-pci.c
@@ -74,6 +74,7 @@ static bool xhci_pci_intr_raise(XHCIState *xhci, int n, b=
ool level)
     }
=20
     if (msi_enabled(pci_dev) && level) {
+        n %=3D msi_nr_vectors_allocated(pci_dev);
         msi_notify(pci_dev, n);
         return true;
     }
--=20
2.39.5 (Apple Git-154)
From nobody Tue May 13 03:56:29 2025
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
ARC-Seal: i=1; a=rsa-sha256; t=1734106056; cv=none;
	d=zohomail.com; s=zohoarc;
	b=nZHF6L8oxo2K0FnHxTc8StwOCsx2E9E63EoB533pX7AXZ2mw0ydz2oRLE3+g4uS8BDHzQvj9Jo4pe73U+X5xeXnW+wHQ63lGw+CBrfxMt8ShPxp+4kgtxc9kFhaGiIMI8QZCNKjZx9cazvTIvDLC1+RVCZHWF53+C5GH+j8fgNs=
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com;
 s=zohoarc;
	t=1734106056;
 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=jRHJVPywLGuIe9/mffxsEcUXl8cWfA9NHuC9ZmkCOio=;
	b=F9c7ZgzkkQL0QuRb/hPEubROEV001Qyyjlb6e2u8flAc+kRUIKOWha+el6EVxZ6cQXAi0qL4ML035LteQ4/EcXDooTBcJ+NNFl6geFMOsya/zKUoX42eDYfuox2r77tGg316Vhd0ZE8JpZO1ZDqhkyjQR5YP+wa/H/AggZ+bOHQ=
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
Return-Path: <qemu-devel-bounces+importer=patchew.org@nongnu.org>
Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by
 mx.zohomail.com
	with SMTPS id 1734106056564882.4074218311632;
 Fri, 13 Dec 2024 08:07:36 -0800 (PST)
Received: from localhost ([::1] helo=lists1p.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.90_1)
	(envelope-from <qemu-devel-bounces@nongnu.org>)
	id 1tM8Bm-0001nU-KL; Fri, 13 Dec 2024 11:06:50 -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 <phil@philjordan.eu>)
 id 1tM8BV-0001hN-PU
 for qemu-devel@nongnu.org; Fri, 13 Dec 2024 11:06:35 -0500
Received: from mail-ej1-x62b.google.com ([2a00:1450:4864:20::62b])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
 (Exim 4.90_1) (envelope-from <phil@philjordan.eu>)
 id 1tM8BS-0006f4-2E
 for qemu-devel@nongnu.org; Fri, 13 Dec 2024 11:06:33 -0500
Received: by mail-ej1-x62b.google.com with SMTP id
 a640c23a62f3a-aa692211331so373676266b.1
 for <qemu-devel@nongnu.org>; Fri, 13 Dec 2024 08:06:28 -0800 (PST)
Received: from localhost.localdomain (h082218084190.host.wavenet.at.
 [82.218.84.190]) by smtp.gmail.com with ESMTPSA id
 a640c23a62f3a-aa667843413sm916683166b.24.2024.12.13.08.06.25
 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256);
 Fri, 13 Dec 2024 08:06:25 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=philjordan-eu.20230601.gappssmtp.com; s=20230601; t=1734105987;
 x=1734710787;
 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=jRHJVPywLGuIe9/mffxsEcUXl8cWfA9NHuC9ZmkCOio=;
 b=rSEacpD31vbCPVqUR+7g/X4YWEeUb9yhR0dFMIscCvrnF0+T+o/aToqA4Uq3RJVHSp
 ugX4kMBqVyFrxYcwPZU2D4292msz7T1/RzDDtzm6YmZbV5j4d4Y7JnImu3dWF0Wos2kB
 YLn6lfZFa70hHst6cV24lvQ9K1RAVZljqltq+R4iH7ZZfkMJdRMifePndLR4Zr58zGuy
 gDKcJ6W+L4qO8U7uLjvKoOpsuQtkU3D+6hkg+7vafYpWrJefTkUXB3ig6T1fFgP6aF0S
 FLYBA3uCIszlkmDGPXYUY0MEW3bOWT00ys9E+yX4zttCFOSmu7x5Q3OwbLmJjeOftqA5
 aaYg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1734105987; x=1734710787;
 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=jRHJVPywLGuIe9/mffxsEcUXl8cWfA9NHuC9ZmkCOio=;
 b=EOvYYOne5jmzd1QCBTlakkxw6awzNh/uzxfJoaCDQLrtRlZBDBQXkZshFIT79x/XQ0
 06XO6+V9/MpEopeYCKJgeF2JdxKHMNz4bUc5Ye5HqG3lEFG9a9YYA/qZk00hC5N8731m
 K0dhsyQ30ptrNvS0WHjvpyc8o+XM1cfFK2biGzd/7ym/LEYkTnbSsYWUWDHJESR67Qiw
 w37K+opxwFHY+mtQsFU+LKnNgZnUDo0dYmOyoBhVaQCwcX5zPTR7770VM5+7DZUnZZXZ
 f47+ea7bEfk8K9nrrsGlD5CjO9LlQLnAb+pskE5h6R4DComZmKx+OD1yG/dj2Un191L6
 I+Dw==
X-Gm-Message-State: AOJu0YywESfc3F+Ln/LsaCaOOrL/IfGcUpXPxf9FuI1pjcjHQ6cPosKf
 8rbnwNKDqYphofQePYyjFO85XFvgG3MvxXQnrE32EcEV7Z9zZnqaDcnVGwWZVltmxi/dDyiGdcr
 15Q==
X-Gm-Gg: ASbGncsQ+tBiaqSYt66rhYwjKnWvx/7ULBPy9f7cTaDp1X/oAHyYNCmrPxDFeqljTal
 7qcMNVJl6HlBw22YWhgSI1eazBKVKVxsp9t80IlqVruWYYR8Z03sTLBQddnh1BsKp2SxRXtack6
 PS6X/2kYYMIHnRZ6MShnvnmZbgJBNbVgcPzcVruPYe45vBdEnHXssABxbqShyIY6gqqXm14tGPK
 4k8AAz3rxqTZ1gU6pR/4TMYlZ0Ep0fonOP27gZHZlOHichjwxoZPcnRyD06nvEkpAMmYttNwB4o
 oFw7q4Ft7/7TZV3ZzApwHH+NOd+9cyQE
X-Google-Smtp-Source: 
 AGHT+IGYTDh2abbXkhDKixrPRTb0iMB6Hr2e1jrwj4SdyViS695Qp5O496VJwB7HuqNIWNbOF3A4Dg==
X-Received: by 2002:a17:907:1c9e:b0:aa6:489e:5848 with SMTP id
 a640c23a62f3a-aab7b8485admr241965266b.25.1734105985939;
 Fri, 13 Dec 2024 08:06:25 -0800 (PST)
From: Phil Dennis-Jordan <phil@philjordan.eu>
To: qemu-devel@nongnu.org
Cc: richard.henderson@linaro.org, philmd@linaro.org, thuth@redhat.com,
 zhao1.liu@intel.com, imammedo@redhat.com, akihiko.odaki@daynix.com,
 Phil Dennis-Jordan <phil@philjordan.eu>
Subject: [PATCH v2 2/6] hw/usb/hcd-xhci-pci: Move msi/msix properties from NEC
 to superclass
Date: Fri, 13 Dec 2024 17:06:15 +0100
Message-Id: <20241213160619.66509-3-phil@philjordan.eu>
X-Mailer: git-send-email 2.39.5 (Apple Git-154)
In-Reply-To: <20241213160619.66509-1-phil@philjordan.eu>
References: <20241213160619.66509-1-phil@philjordan.eu>
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: neutral client-ip=2a00:1450:4864:20::62b;
 envelope-from=phil@philjordan.eu; helo=mail-ej1-x62b.google.com
X-Spam_score_int: -10
X-Spam_score: -1.1
X-Spam_bar: -
X-Spam_report: (-1.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1,
 DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001,
 SPF_NEUTRAL=0.779 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: <qemu-devel.nongnu.org>
List-Unsubscribe: <https://lists.nongnu.org/mailman/options/qemu-devel>,
 <mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>
List-Archive: <https://lists.nongnu.org/archive/html/qemu-devel>
List-Post: <mailto:qemu-devel@nongnu.org>
List-Help: <mailto:qemu-devel-request@nongnu.org?subject=help>
List-Subscribe: <https://lists.nongnu.org/mailman/listinfo/qemu-devel>,
 <mailto:qemu-devel-request@nongnu.org?subject=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 @philjordan-eu.20230601.gappssmtp.com)
X-ZM-MESSAGEID: 1734106057659116600
Content-Type: text/plain; charset="utf-8"

The NEC XHCI controller exposes the underlying PCI device's msi and
msix properties, but the superclass and thus the qemu-xhci device do
not. There does not seem to be any obvious reason for this limitation.
This change moves these properties to the superclass so they are
exposed by both PCI XHCI device variants.

Signed-off-by: Phil Dennis-Jordan <phil@philjordan.eu>
Reviewed-by: Philippe Mathieu-Daud=C3=A9 <philmd@linaro.org>
---
 hw/usb/hcd-xhci-nec.c | 2 --
 hw/usb/hcd-xhci-pci.c | 7 +++++++
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/hw/usb/hcd-xhci-nec.c b/hw/usb/hcd-xhci-nec.c
index 0c063b3697d..408bf065e5a 100644
--- a/hw/usb/hcd-xhci-nec.c
+++ b/hw/usb/hcd-xhci-nec.c
@@ -39,8 +39,6 @@ struct XHCINecState {
 };
=20
 static Property nec_xhci_properties[] =3D {
-    DEFINE_PROP_ON_OFF_AUTO("msi", XHCIPciState, msi, ON_OFF_AUTO_AUTO),
-    DEFINE_PROP_ON_OFF_AUTO("msix", XHCIPciState, msix, ON_OFF_AUTO_AUTO),
     DEFINE_PROP_UINT32("intrs", XHCINecState, intrs, XHCI_MAXINTRS),
     DEFINE_PROP_UINT32("slots", XHCINecState, slots, XHCI_MAXSLOTS),
     DEFINE_PROP_END_OF_LIST(),
diff --git a/hw/usb/hcd-xhci-pci.c b/hw/usb/hcd-xhci-pci.c
index 516e6909d20..35f02132bb4 100644
--- a/hw/usb/hcd-xhci-pci.c
+++ b/hw/usb/hcd-xhci-pci.c
@@ -198,6 +198,12 @@ static void xhci_instance_init(Object *obj)
     qdev_alias_all_properties(DEVICE(&s->xhci), obj);
 }
=20
+static Property xhci_pci_properties[] =3D {
+    DEFINE_PROP_ON_OFF_AUTO("msi", XHCIPciState, msi, ON_OFF_AUTO_AUTO),
+    DEFINE_PROP_ON_OFF_AUTO("msix", XHCIPciState, msix, ON_OFF_AUTO_AUTO),
+    DEFINE_PROP_END_OF_LIST(),
+};
+
 static void xhci_class_init(ObjectClass *klass, void *data)
 {
     PCIDeviceClass *k =3D PCI_DEVICE_CLASS(klass);
@@ -209,6 +215,7 @@ static void xhci_class_init(ObjectClass *klass, void *d=
ata)
     k->realize      =3D usb_xhci_pci_realize;
     k->exit         =3D usb_xhci_pci_exit;
     k->class_id     =3D PCI_CLASS_SERIAL_USB;
+    device_class_set_props(dc, xhci_pci_properties);
 }
=20
 static const TypeInfo xhci_pci_info =3D {
--=20
2.39.5 (Apple Git-154)
From nobody Tue May 13 03:56:29 2025
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
ARC-Seal: i=1; a=rsa-sha256; t=1734106082; cv=none;
	d=zohomail.com; s=zohoarc;
	b=QmWVp9LZONRd56Z+Jx8ilgqIj3fzUjRzpsrsl/TdWkX+SslMo8DfBgEBt+T/W2+yYMeOJnrugE3OCl3DJMxcvDTuZvE7l3WpjDzeto120ot2I4HiWeUqOuqFhjPh1mDXkuHUYTl+H5QTE+2Vhw41tXL97OQ4vkV+aYRDPOar9GE=
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com;
 s=zohoarc;
	t=1734106082;
 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=acRq5wtuEZY6qfWLgIt8kj488PEzJr2oq6KQkbWz1tc=;
	b=MoDMJ+1wPhGu2tBgEjg7Vp8vs0tCa7nFkFGcjuc8eI55yci5nwlOPeTE9tnehGmEu1YA0bqB7/gEmqqqJCpzyghRcRIOvMYk6P/UtimJqz2qGM8ro2BLplLe59Py06Wno082sba9BFBnhSZwkscb4MNWWY1l3/TU8Dmv32ogOtY=
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
Return-Path: <qemu-devel-bounces+importer=patchew.org@nongnu.org>
Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by
 mx.zohomail.com
	with SMTPS id 1734106082310692.6210380176979;
 Fri, 13 Dec 2024 08:08:02 -0800 (PST)
Received: from localhost ([::1] helo=lists1p.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.90_1)
	(envelope-from <qemu-devel-bounces@nongnu.org>)
	id 1tM8Bn-0001q9-QG; Fri, 13 Dec 2024 11:06:51 -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 <phil@philjordan.eu>)
 id 1tM8BV-0001hL-N6
 for qemu-devel@nongnu.org; Fri, 13 Dec 2024 11:06:35 -0500
Received: from mail-ej1-x635.google.com ([2a00:1450:4864:20::635])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
 (Exim 4.90_1) (envelope-from <phil@philjordan.eu>)
 id 1tM8BR-0006ey-Gq
 for qemu-devel@nongnu.org; Fri, 13 Dec 2024 11:06:31 -0500
Received: by mail-ej1-x635.google.com with SMTP id
 a640c23a62f3a-aa66e4d1d5aso305031966b.2
 for <qemu-devel@nongnu.org>; Fri, 13 Dec 2024 08:06:28 -0800 (PST)
Received: from localhost.localdomain (h082218084190.host.wavenet.at.
 [82.218.84.190]) by smtp.gmail.com with ESMTPSA id
 a640c23a62f3a-aa667843413sm916683166b.24.2024.12.13.08.06.26
 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256);
 Fri, 13 Dec 2024 08:06:26 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=philjordan-eu.20230601.gappssmtp.com; s=20230601; t=1734105987;
 x=1734710787;
 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=acRq5wtuEZY6qfWLgIt8kj488PEzJr2oq6KQkbWz1tc=;
 b=Juo99WLdbB8NPlYsW98ipotd+LJLFeeEphSmCnUdikcz2DP8qBI2jBEQUClMT0510M
 kPvPpZiKjz+g1eegTcymCjfy/hA5p2IoWErd3QYo1kR9jnOlQopUlzWCQYtOOFwtCNrN
 ky7A11Sv8q108zRQtBfFFlu9o5F7hRMboYltOwat3+fqJ4UTFmdaaAxoLnF3buLm4bzk
 1hJMAldgVTBLOLDsoNNWIiPFBT7YaSe5ZhV+z83rBLKhcKIX/PbQph6ow3LvC9jeSYr8
 9UabU7IHr57k2ETWvR9oXTdU9SmMF2PmpKJZslsAeyRwUs7BecAC+yzTiX0UF735gMu7
 LbAA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1734105987; x=1734710787;
 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=acRq5wtuEZY6qfWLgIt8kj488PEzJr2oq6KQkbWz1tc=;
 b=dh73de4NDKLh/jd0rpbXtRSXR1IEeLNeXVB3jEZFRj0ZqfHwmz5uOvyYcJOI9sRDo9
 aHLwtQYgApCMaHcHy5eBmrxEwx62gGNK5UP0nHzIWWGkWyqoivvh7+POwbeN++FHZlo/
 iLnHVnERlOCi5CUBrkc5LqnYyY8rXuahZ0eEHAnpP/mpCpCTmVAVIk8tNsWOsIV7bjDt
 pjzf1uOFLukrcZSpMeUBhXDq4OHBrlkwxwz/x9juElPJG8gMCpSIoVzx14o1k1T2AlIl
 CRtSf0rQxq/ni2qkzABo7YPedR365uDJ0h/Kt/Zdp+VBR+kgWWA1lf+qmU7+TPe+Gieg
 LMIw==
X-Gm-Message-State: AOJu0Ywg+9vAMFUGe4asq/aYm0p1n6fqBwF0Riq9/Ejn+HLqkC3jHajm
 u/LD1MWTO4JHJBqsDsZ2e0MVQGj/1SNx+tAA6EL0G2TfnK+0MQdn0Ejt2J1TwG/g0Sk6pf8vXVB
 /zg==
X-Gm-Gg: ASbGnctCd3Bj1ePgEfLNQyXePs+zlzd997qwBH+aAAC4OR6IVJKfCOHTmoyx/ROPI3H
 qY9wZRY7XeKQX2gOz+eFT51qszyDmoXLxHsHR85W4w9E7cQ5WrB743yi8U3HH62xgRbP4Mfj1cP
 D+0JhBYb1KuPAb2R93ttpIrOYR5L6n7gP3i1GXZUq1W8NUkdijsQcQMaCxzeX5prMdC38W4I+Rm
 qcoB2rVbAwYMQ/W4GCoGHn8KUMvuDwR8OQRqdBfBHmNyFpa5vLbUmlajqqRs7JHO+FmIeSIGRRD
 jHlkIfwfA1BA/LJIuvTAgHI5QX7CYP5o
X-Google-Smtp-Source: 
 AGHT+IFISrcJgZSd7pbDNX+2Mk3hdeXSTSjPHDrcG41VfJMZ3t6J5GTJ5qNn7x2NoGV4TUZER6HYIg==
X-Received: by 2002:a17:906:7314:b0:aa6:74a9:ce6e with SMTP id
 a640c23a62f3a-aab77909d56mr332290666b.16.1734105986885;
 Fri, 13 Dec 2024 08:06:26 -0800 (PST)
From: Phil Dennis-Jordan <phil@philjordan.eu>
To: qemu-devel@nongnu.org
Cc: richard.henderson@linaro.org, philmd@linaro.org, thuth@redhat.com,
 zhao1.liu@intel.com, imammedo@redhat.com, akihiko.odaki@daynix.com,
 Phil Dennis-Jordan <phil@philjordan.eu>
Subject: [PATCH v2 3/6] hw/usb/hcd-xhci-pci: Use event ring 0 if mapping
 unsupported
Date: Fri, 13 Dec 2024 17:06:16 +0100
Message-Id: <20241213160619.66509-4-phil@philjordan.eu>
X-Mailer: git-send-email 2.39.5 (Apple Git-154)
In-Reply-To: <20241213160619.66509-1-phil@philjordan.eu>
References: <20241213160619.66509-1-phil@philjordan.eu>
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: neutral client-ip=2a00:1450:4864:20::635;
 envelope-from=phil@philjordan.eu; helo=mail-ej1-x635.google.com
X-Spam_score_int: -10
X-Spam_score: -1.1
X-Spam_bar: -
X-Spam_report: (-1.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1,
 DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001,
 SPF_NEUTRAL=0.779 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: <qemu-devel.nongnu.org>
List-Unsubscribe: <https://lists.nongnu.org/mailman/options/qemu-devel>,
 <mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>
List-Archive: <https://lists.nongnu.org/archive/html/qemu-devel>
List-Post: <mailto:qemu-devel@nongnu.org>
List-Help: <mailto:qemu-devel-request@nongnu.org?subject=help>
List-Subscribe: <https://lists.nongnu.org/mailman/listinfo/qemu-devel>,
 <mailto:qemu-devel-request@nongnu.org?subject=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 @philjordan-eu.20230601.gappssmtp.com)
X-ZM-MESSAGEID: 1734106083782116600
Content-Type: text/plain; charset="utf-8"

The XHCI specification, section 4.17.1 specifies that "If Interrupter
Mapping is not supported, the Interrupter Target field shall be
ignored by the xHC and all Events targeted at Interrupter 0."

QEMU's XHCI device has so far not specially addressed this case,
so we add a check to xhci_event() to redirect to event ring and
interrupt 0 if mapping is disabled.

Signed-off-by: Phil Dennis-Jordan <phil@philjordan.eu>
---
 hw/usb/hcd-xhci.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/hw/usb/hcd-xhci.c b/hw/usb/hcd-xhci.c
index d85adaca0dc..5fb140c2382 100644
--- a/hw/usb/hcd-xhci.c
+++ b/hw/usb/hcd-xhci.c
@@ -644,6 +644,10 @@ static void xhci_event(XHCIState *xhci, XHCIEvent *eve=
nt, int v)
     dma_addr_t erdp;
     unsigned int dp_idx;
=20
+    if (xhci->numintrs =3D=3D 1) {
+        v =3D 0;
+    }
+
     if (v >=3D xhci->numintrs) {
         DPRINTF("intr nr out of range (%d >=3D %d)\n", v, xhci->numintrs);
         return;
--=20
2.39.5 (Apple Git-154)
From nobody Tue May 13 03:56:29 2025
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
ARC-Seal: i=1; a=rsa-sha256; t=1734106088; cv=none;
	d=zohomail.com; s=zohoarc;
	b=KnGy0K93jcCZHIP439toaoaQ5RMKrzw9uxmLKaii5zn7qdp+U42ALw+D/50sQo9GdRN/u24m/H8IzHkW6J0pyI3txN8lBy7g59OXZak1xwGWPLDNIucC/d0Uufro5kxLwOSOguC/hQe1CXxJ7S84q8Pks8SFKEIGSliNuM8oJ0w=
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com;
 s=zohoarc;
	t=1734106088;
 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=fihiqrNtU1lwhsHeAONN51DAQcAharB3DZgDkSerMcA=;
	b=GOFRmkijUs9uGH+ZVS58U8h7MpkPkntG/l94q/OPt6MPpImx8523Ef+MRRdZWIW+jl+/z/HUp/wUq2mXYGJbzpa7q+4qhJovozi0hnsVIozbkSzeI7xibyIZMJLua4/jqTakfPSxQhE+JLb9JM18TfUSBtwyei7MLRgteH7mNMQ=
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
Return-Path: <qemu-devel-bounces+importer=patchew.org@nongnu.org>
Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by
 mx.zohomail.com
	with SMTPS id 1734106088804499.9993387469822;
 Fri, 13 Dec 2024 08:08:08 -0800 (PST)
Received: from localhost ([::1] helo=lists1p.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.90_1)
	(envelope-from <qemu-devel-bounces@nongnu.org>)
	id 1tM8Bo-0001qa-1f; Fri, 13 Dec 2024 11:06:52 -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 <phil@philjordan.eu>)
 id 1tM8BV-0001hO-Py
 for qemu-devel@nongnu.org; Fri, 13 Dec 2024 11:06:35 -0500
Received: from mail-ej1-x634.google.com ([2a00:1450:4864:20::634])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
 (Exim 4.90_1) (envelope-from <phil@philjordan.eu>)
 id 1tM8BS-0006fC-2w
 for qemu-devel@nongnu.org; Fri, 13 Dec 2024 11:06:32 -0500
Received: by mail-ej1-x634.google.com with SMTP id
 a640c23a62f3a-aa6a618981eso305146366b.3
 for <qemu-devel@nongnu.org>; Fri, 13 Dec 2024 08:06:29 -0800 (PST)
Received: from localhost.localdomain (h082218084190.host.wavenet.at.
 [82.218.84.190]) by smtp.gmail.com with ESMTPSA id
 a640c23a62f3a-aa667843413sm916683166b.24.2024.12.13.08.06.26
 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256);
 Fri, 13 Dec 2024 08:06:27 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=philjordan-eu.20230601.gappssmtp.com; s=20230601; t=1734105988;
 x=1734710788;
 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=fihiqrNtU1lwhsHeAONN51DAQcAharB3DZgDkSerMcA=;
 b=O82mEmU5wgtM0/rxInRCjPUGWmP7NOJgEqYwmO+qH63jHrhjsC8Q2osWnqKB7EvINz
 Lcsae9bmzFDrcZB2bWQ33l+YO3DpUzTiHFJt68rHGVCqnzJJ0x/bApzup1FOBfW+ILqN
 IOnKQ57WPVvrrh4GwoeMqXn7kTzgMRYegvlz6BbjfobYpGbEeaWB5npmiQxUgzkkF2xs
 3qKnZ8NFVsbxjai5VhSpckoxkAq/Jz8JkmZj6kemtJ6U7m07WYSuOrypd0TBTv+8qPio
 qGbtbbiRJoCT2d23ygJeRAU1Gu1ggDSElon835+k0NWflIE0H7lNva1oOdefVr6QBcxZ
 Dnvg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1734105988; x=1734710788;
 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=fihiqrNtU1lwhsHeAONN51DAQcAharB3DZgDkSerMcA=;
 b=UkRx33DI+yS+T0c5+JRhskErXx0NVRCvF8bZoi6rGtkXdLajCc3aSzhKLyEFoWzQ/d
 /m153bGWZedjzs1us0952OAIsi5hXE0kaJ6dk5urFn46Uija/mmbCVOsJNO6yhaufk6a
 a7eFF1VWZMdSeOl507VlXzGyvrLxVJsqjn4uzBR0iNQIMxN6+Vqmvj0w2QcbWl98bHrO
 YE4Pt9TG+LXsC/1IQ722VLHrq7Mw59eTD2aC+obyFmdDrDC8y1xIEzvjcdFr/NoUSard
 TcqqAe3MsCx5nOZctCAqdbJpmXmAe0yPNZT6ko9XPaQwmgpZXnAVLjWhlcnj9Is0r2do
 J/MQ==
X-Gm-Message-State: AOJu0YxUSP0lqpc04HfoE+YmiqWF6Rx4fCylP+CumdDwXLRA2+XrJitG
 HYkJSnPcxezczLErh26/ZxM00MHKL9CsoLs1Yj6iAxmLV0/NzP9UrzIxLjoUnOGyw+9C4zj/uh4
 Ffg==
X-Gm-Gg: ASbGncsLj+4yLKBEOA/b+NJRToZBOmIPBb4syJS4wf009Iqa1slpOXJU+mTJwzDmU/B
 B9rfMJNtFD1NlM4wiioSbs2mvu8TZ7iFeVYK9TctNrgZTKl0VcbBcf320lIzL6Dh+RbuZn7eNeN
 oczZ6h9fW/I64oN6DNMxFV2849I0gZTq+xH9796JcamCXLqesEG95Af6If6jNTpENlW2CuPlddo
 J0YlROGYYkzlWxVpaUq9oVOtx08AeTMNABvYLfeUBp5NUIZD2jE9EK4aGnBy0FPSln+a0yGr9SG
 DBuCLeUPXKHArEZ2gUPYKJojY1v7v5x8
X-Google-Smtp-Source: 
 AGHT+IGbLr4aTsymNfaH75Z2bJMqEr3EOhZyD6GFUrKB2s+aUZk/p8xc8VKloIeb2T2o2FQGihY4DQ==
X-Received: by 2002:a17:906:c102:b0:aa6:6885:e2f6 with SMTP id
 a640c23a62f3a-aab779b7968mr350830766b.36.1734105987948;
 Fri, 13 Dec 2024 08:06:27 -0800 (PST)
From: Phil Dennis-Jordan <phil@philjordan.eu>
To: qemu-devel@nongnu.org
Cc: richard.henderson@linaro.org, philmd@linaro.org, thuth@redhat.com,
 zhao1.liu@intel.com, imammedo@redhat.com, akihiko.odaki@daynix.com,
 Phil Dennis-Jordan <phil@philjordan.eu>
Subject: [PATCH v2 4/6] hw/usb/hcd-xhci-pci: Adds property for disabling
 mapping in IRQ mode
Date: Fri, 13 Dec 2024 17:06:17 +0100
Message-Id: <20241213160619.66509-5-phil@philjordan.eu>
X-Mailer: git-send-email 2.39.5 (Apple Git-154)
In-Reply-To: <20241213160619.66509-1-phil@philjordan.eu>
References: <20241213160619.66509-1-phil@philjordan.eu>
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: neutral client-ip=2a00:1450:4864:20::634;
 envelope-from=phil@philjordan.eu; helo=mail-ej1-x634.google.com
X-Spam_score_int: -10
X-Spam_score: -1.1
X-Spam_bar: -
X-Spam_report: (-1.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1,
 DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001,
 SPF_NEUTRAL=0.779 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: <qemu-devel.nongnu.org>
List-Unsubscribe: <https://lists.nongnu.org/mailman/options/qemu-devel>,
 <mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>
List-Archive: <https://lists.nongnu.org/archive/html/qemu-devel>
List-Post: <mailto:qemu-devel@nongnu.org>
List-Help: <mailto:qemu-devel-request@nongnu.org?subject=help>
List-Subscribe: <https://lists.nongnu.org/mailman/listinfo/qemu-devel>,
 <mailto:qemu-devel-request@nongnu.org?subject=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 @philjordan-eu.20230601.gappssmtp.com)
X-ZM-MESSAGEID: 1734106089943116600
Content-Type: text/plain; charset="utf-8"

This change addresses an edge case that trips up macOS guest drivers
for PCI based XHCI controllers. The guest driver would attempt to
schedule events to XHCI event rings 1 and 2 even when using PCI
pin-based interrupts. Interrupts would therefore be dropped, and events
only handled on timeout.

So, in addition to disabling interrupter mapping if numintrs is 1, a
callback is added to xhci to check whether interrupter mapping should be
enabled. The PCI XHCI device type now provides an implementation of
this callback if the new "conditional-intr-mapping" property is enabled.
(default: disabled) When enabled, interrupter mapping is only enabled
when MSI-X or MSI is active.

This means that when using pin-based interrupts, events are only
submitted to interrupter 0 regardless of selected target. This allows
the macOS guest drivers to work with the device in those configurations.

Signed-off-by: Phil Dennis-Jordan <phil@philjordan.eu>
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2705
---
 hw/usb/hcd-xhci-pci.c | 24 ++++++++++++++++++++++++
 hw/usb/hcd-xhci-pci.h |  1 +
 hw/usb/hcd-xhci.c     |  3 ++-
 hw/usb/hcd-xhci.h     |  5 +++++
 4 files changed, 32 insertions(+), 1 deletion(-)

diff --git a/hw/usb/hcd-xhci-pci.c b/hw/usb/hcd-xhci-pci.c
index 35f02132bb4..6027eed2d26 100644
--- a/hw/usb/hcd-xhci-pci.c
+++ b/hw/usb/hcd-xhci-pci.c
@@ -82,6 +82,21 @@ static bool xhci_pci_intr_raise(XHCIState *xhci, int n, =
bool level)
     return false;
 }
=20
+static bool xhci_pci_intr_mapping_conditional(XHCIState *xhci)
+{
+    XHCIPciState *s =3D container_of(xhci, XHCIPciState, xhci);
+    PCIDevice *pci_dev =3D PCI_DEVICE(s);
+
+    /*
+     * Implementation of the "conditional-intr-mapping" property, which on=
ly
+     * enables interrupter mapping if MSI or MSI-X is available and active.
+     * Forces all events onto interrupter/event ring 0 in pin-based IRQ mo=
de.
+     * Provides compatibility with macOS guests on machine types where MSI=
(-X)
+     * is not available.
+     */
+    return msix_enabled(pci_dev) || msi_enabled(pci_dev);
+}
+
 static void xhci_pci_reset(DeviceState *dev)
 {
     XHCIPciState *s =3D XHCI_PCI(dev);
@@ -119,6 +134,9 @@ static void usb_xhci_pci_realize(struct PCIDevice *dev,=
 Error **errp)
     object_property_set_link(OBJECT(&s->xhci), "host", OBJECT(s), NULL);
     s->xhci.intr_update =3D xhci_pci_intr_update;
     s->xhci.intr_raise =3D xhci_pci_intr_raise;
+    if (s->conditional_intr_mapping) {
+        s->xhci.intr_mapping_supported =3D xhci_pci_intr_mapping_condition=
al;
+    }
     if (!qdev_realize(DEVICE(&s->xhci), NULL, errp)) {
         return;
     }
@@ -201,6 +219,8 @@ static void xhci_instance_init(Object *obj)
 static Property xhci_pci_properties[] =3D {
     DEFINE_PROP_ON_OFF_AUTO("msi", XHCIPciState, msi, ON_OFF_AUTO_AUTO),
     DEFINE_PROP_ON_OFF_AUTO("msix", XHCIPciState, msix, ON_OFF_AUTO_AUTO),
+    DEFINE_PROP_BOOL("conditional-intr-mapping", XHCIPciState,
+                     conditional_intr_mapping, false),
     DEFINE_PROP_END_OF_LIST(),
 };
=20
@@ -216,6 +236,10 @@ static void xhci_class_init(ObjectClass *klass, void *=
data)
     k->exit         =3D usb_xhci_pci_exit;
     k->class_id     =3D PCI_CLASS_SERIAL_USB;
     device_class_set_props(dc, xhci_pci_properties);
+    object_class_property_set_description(klass, "conditional-intr-mapping=
",
+        "When true, disables interrupter mapping for pin-based IRQ mode. "
+        "Intended to be used with guest drivers with questionable behaviou=
r, "
+        "such as macOS's.");
 }
=20
 static const TypeInfo xhci_pci_info =3D {
diff --git a/hw/usb/hcd-xhci-pci.h b/hw/usb/hcd-xhci-pci.h
index 08f70ce97cc..5b61ae84555 100644
--- a/hw/usb/hcd-xhci-pci.h
+++ b/hw/usb/hcd-xhci-pci.h
@@ -40,6 +40,7 @@ typedef struct XHCIPciState {
     XHCIState xhci;
     OnOffAuto msi;
     OnOffAuto msix;
+    bool conditional_intr_mapping;
 } XHCIPciState;
=20
 #endif
diff --git a/hw/usb/hcd-xhci.c b/hw/usb/hcd-xhci.c
index 5fb140c2382..b607ddd1a93 100644
--- a/hw/usb/hcd-xhci.c
+++ b/hw/usb/hcd-xhci.c
@@ -644,7 +644,8 @@ static void xhci_event(XHCIState *xhci, XHCIEvent *even=
t, int v)
     dma_addr_t erdp;
     unsigned int dp_idx;
=20
-    if (xhci->numintrs =3D=3D 1) {
+    if (xhci->numintrs =3D=3D 1 ||
+        (xhci->intr_mapping_supported && !xhci->intr_mapping_supported(xhc=
i))) {
         v =3D 0;
     }
=20
diff --git a/hw/usb/hcd-xhci.h b/hw/usb/hcd-xhci.h
index fe16d7ad055..fdaa21ba7f6 100644
--- a/hw/usb/hcd-xhci.h
+++ b/hw/usb/hcd-xhci.h
@@ -193,6 +193,11 @@ typedef struct XHCIState {
     uint32_t max_pstreams_mask;
     void (*intr_update)(XHCIState *s, int n, bool enable);
     bool (*intr_raise)(XHCIState *s, int n, bool level);
+    /*
+     * Callback for special-casing interrupter mapping support. NULL for m=
ost
+     * implementations, for defaulting to enabled mapping unless numintrs =
=3D=3D 1.
+     */
+    bool (*intr_mapping_supported)(XHCIState *s);
     DeviceState *hostOpaque;
=20
     /* Operational Registers */
--=20
2.39.5 (Apple Git-154)
From nobody Tue May 13 03:56:29 2025
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
ARC-Seal: i=1; a=rsa-sha256; t=1734106058; cv=none;
	d=zohomail.com; s=zohoarc;
	b=GliG53rTe5IN4OnTTz+3DcJ6Mkq/1tXiw9D5yMcW4nkDFln7L+Mb+q7Imsdzc43iHZVsk00Amw8pmVs4AzokH4vD7lWmyR2FcNFQxDlcKWTZB/86TD90Jiyyt670JTpREkM95wttuvAjfXpEuXQ3Zu30kCVDCNudyiT64EgvDvQ=
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com;
 s=zohoarc;
	t=1734106058;
 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=k2w4i3aj6eKVqpqsdiYKqEe8MFNmhXhqYUKlcsHv298=;
	b=OfnJnIHv2YUhJMyVtos1vTqdwqS4Xu395wsl8xHN4fqVERhHjvxVDuIo6yqBS2x8OsNJX/ihq/1rwj6s7G0x7LH5/L9ArzFvkClkWy01TAd0CyBb1h4Bua538jUn91yeZxi1Z1nm7xhzzG6vVsZNtJFR60cyDwWxd5TLiEGQOBY=
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
Return-Path: <qemu-devel-bounces+importer=patchew.org@nongnu.org>
Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by
 mx.zohomail.com
	with SMTPS id 1734106058881636.7967789751974;
 Fri, 13 Dec 2024 08:07:38 -0800 (PST)
Received: from localhost ([::1] helo=lists1p.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.90_1)
	(envelope-from <qemu-devel-bounces@nongnu.org>)
	id 1tM8Bm-0001nK-E8; Fri, 13 Dec 2024 11:06:50 -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 <phil@philjordan.eu>)
 id 1tM8BV-0001hM-N0
 for qemu-devel@nongnu.org; Fri, 13 Dec 2024 11:06:35 -0500
Received: from mail-ej1-x62c.google.com ([2a00:1450:4864:20::62c])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
 (Exim 4.90_1) (envelope-from <phil@philjordan.eu>)
 id 1tM8BS-0006fQ-V4
 for qemu-devel@nongnu.org; Fri, 13 Dec 2024 11:06:32 -0500
Received: by mail-ej1-x62c.google.com with SMTP id
 a640c23a62f3a-aa6a3c42400so326860366b.0
 for <qemu-devel@nongnu.org>; Fri, 13 Dec 2024 08:06:30 -0800 (PST)
Received: from localhost.localdomain (h082218084190.host.wavenet.at.
 [82.218.84.190]) by smtp.gmail.com with ESMTPSA id
 a640c23a62f3a-aa667843413sm916683166b.24.2024.12.13.08.06.28
 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256);
 Fri, 13 Dec 2024 08:06:28 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=philjordan-eu.20230601.gappssmtp.com; s=20230601; t=1734105989;
 x=1734710789;
 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=k2w4i3aj6eKVqpqsdiYKqEe8MFNmhXhqYUKlcsHv298=;
 b=X9FWKWUB8Zm+jtvk+iahKuYIBwSkX/37CVKhD2RQns9eqMyx6CUi5xhe08Kr99mrZF
 FKDrLTXcdc5qjsehpydE9fGoh2MWxp+9y7VCopUOTG5fqKt6v6sTKT3Rr46pUlw/aCH0
 FNZiaykroaKqd8JtVpz2RpgWVGv/9PeMLsi0TR6hBBdooDN7enTiGLQiKEUzFBFJFW6f
 UWwNAjn6ip1GejKY3YJ3Q/E7mTmTba8c/ER99i1uY8BeVma8v8JrIhLfdv2R6wvSD/nI
 EwwP5PRvKUo6fO4w7yAc9v2EMkAD85KpCP9BXnk2skAeUbgmK2CcMHyvW/Y8rLQDwt3J
 gMGA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1734105989; x=1734710789;
 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=k2w4i3aj6eKVqpqsdiYKqEe8MFNmhXhqYUKlcsHv298=;
 b=XCUXjfb6xZeokQGDBzsIAPD5aPDZWnZU1b5hp3xX4p5FAHJepY7hs1EmL3uXVbxBLe
 CgHW1lNDpKdPdQgG3pPfVOgPEe+l+j2R+LqNKFiZTvV8D+rAl3JTEHpq4LX7liEMogbv
 /095inxAmu5OJN3TfJOtltvP02RyRpyef4j2V2aT8Qq/qe8IIgzOercQNP+yHUAvW8H1
 AZdegbSXnLccXgudD1tYmbvmBHHXk8HcVP57s2b+MtgSnJVOwYHk1cRTHvwfCe5NzdES
 5D+XYXS2nO/kaAynNOYLBMC34SupXDhsE7WidG9zdPMBNcYGENuHDexk0jAd+zzHw1T9
 nrqA==
X-Gm-Message-State: AOJu0Yxkc8k3kO1dMVWXL7Dpcm5auP2nLnWxNngdeW7fkl8VRX/mzsq5
 cRs7h5URYqa70V5qmndCmWdOFaeM4+tD1mqiQ9/DDC9QKgftZMXM/Jqmop8hkKRWPa0iLTlsvrx
 cTQ==
X-Gm-Gg: ASbGncu17IcAtUgozd/BXfnWZdlK3i397tOkxc9CCTuC2+ozO+QEZjClGLwxdGF89PO
 Zsui3fhw6qYD2Ljx3negNtR8Wt4yYx+JQbgufi1J42Ex9OexQJTUGwywhkZULlNR0G4KJqOgmZr
 Op5N0pnlqoFuNyBYiub64kvTh/TNyChrFrc50FsS+qBhFl1/cDDDXugh7rx/7YwQYOYrKDYgwpu
 Ut3kM/n49j7YHRd5qyyn24B6oG0a7OJTftL0PQwdFOH8w3ELIvoVqfJfqc1U7b9nazi1OnU1KNH
 y/GrrzkfgjTb96t6MB/1gnP0asj/nw9v
X-Google-Smtp-Source: 
 AGHT+IEn28kXYjHsxKaPpfWIgBim38t5ITEIG5MMFosEpQleX5BVsdl2Y9BI/UB34FWqk10ze7DULw==
X-Received: by 2002:a17:907:d92:b0:aa6:ade8:2d8c with SMTP id
 a640c23a62f3a-aa6c40ba702mr883586066b.5.1734105988956;
 Fri, 13 Dec 2024 08:06:28 -0800 (PST)
From: Phil Dennis-Jordan <phil@philjordan.eu>
To: qemu-devel@nongnu.org
Cc: richard.henderson@linaro.org, philmd@linaro.org, thuth@redhat.com,
 zhao1.liu@intel.com, imammedo@redhat.com, akihiko.odaki@daynix.com,
 Phil Dennis-Jordan <phil@philjordan.eu>
Subject: [PATCH v2 5/6] hw/usb/hcd-xhci-pci: Indentation fix
Date: Fri, 13 Dec 2024 17:06:18 +0100
Message-Id: <20241213160619.66509-6-phil@philjordan.eu>
X-Mailer: git-send-email 2.39.5 (Apple Git-154)
In-Reply-To: <20241213160619.66509-1-phil@philjordan.eu>
References: <20241213160619.66509-1-phil@philjordan.eu>
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: neutral client-ip=2a00:1450:4864:20::62c;
 envelope-from=phil@philjordan.eu; helo=mail-ej1-x62c.google.com
X-Spam_score_int: -10
X-Spam_score: -1.1
X-Spam_bar: -
X-Spam_report: (-1.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1,
 DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001,
 SPF_NEUTRAL=0.779 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: <qemu-devel.nongnu.org>
List-Unsubscribe: <https://lists.nongnu.org/mailman/options/qemu-devel>,
 <mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>
List-Archive: <https://lists.nongnu.org/archive/html/qemu-devel>
List-Post: <mailto:qemu-devel@nongnu.org>
List-Help: <mailto:qemu-devel-request@nongnu.org?subject=help>
List-Subscribe: <https://lists.nongnu.org/mailman/listinfo/qemu-devel>,
 <mailto:qemu-devel-request@nongnu.org?subject=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 @philjordan-eu.20230601.gappssmtp.com)
X-ZM-MESSAGEID: 1734106059665116600
Content-Type: text/plain; charset="utf-8"

Fixes number of spaces used for indentation on one line.

Signed-off-by: Phil Dennis-Jordan <phil@philjordan.eu>
---
 hw/usb/hcd-xhci-pci.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hw/usb/hcd-xhci-pci.c b/hw/usb/hcd-xhci-pci.c
index 6027eed2d26..2ac0fd0bf1a 100644
--- a/hw/usb/hcd-xhci-pci.c
+++ b/hw/usb/hcd-xhci-pci.c
@@ -110,7 +110,7 @@ static int xhci_pci_vmstate_post_load(void *opaque, int=
 version_id)
     PCIDevice *pci_dev =3D PCI_DEVICE(s);
     int intr;
=20
-   for (intr =3D 0; intr < s->xhci.numintrs; intr++) {
+    for (intr =3D 0; intr < s->xhci.numintrs; intr++) {
         if (s->xhci.intr[intr].msix_used) {
             msix_vector_use(pci_dev, intr);
         } else {
--=20
2.39.5 (Apple Git-154)
From nobody Tue May 13 03:56:29 2025
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
ARC-Seal: i=1; a=rsa-sha256; t=1734106107; cv=none;
	d=zohomail.com; s=zohoarc;
	b=eV+mlZKcE6EJUFGgeQW40mI6RgbfuNIhuZ1p1/uX3RFuIvekWS4yBtQNoENi9nwRl3dw+w845uezRThN8ZvqPI8eMvA/jAP4JEaiaqSmgsGElSp+uTT2FbgR9TdeWdeiXagExQTo1CdTMo2SjhOmiClFM4aqoWIwB2s73zYwed0=
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com;
 s=zohoarc;
	t=1734106107;
 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=TLgf/hBtKPWGX+IefC929iFjKjT8oYxXZ2UyNeVgI20=;
	b=SICeOmQxah2Rl0HJEDKWjjmWhGgO/FD7P1drHPWJ8ICbeN1npN+D2KYNLADI5g6LRt7A9Cy9oL2fGFMzjm/KaTcaenLbMtyI/cH+XgtAkXuAkvNJZYYy0f+HBrZX5SrchB8+1ehPBABS+YwDB8EtXGJKdMfjah0FqM2+W3G41/A=
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
Return-Path: <qemu-devel-bounces+importer=patchew.org@nongnu.org>
Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by
 mx.zohomail.com
	with SMTPS id 1734106107176793.192161510376;
 Fri, 13 Dec 2024 08:08:27 -0800 (PST)
Received: from localhost ([::1] helo=lists1p.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.90_1)
	(envelope-from <qemu-devel-bounces@nongnu.org>)
	id 1tM8Bn-0001o3-4u; Fri, 13 Dec 2024 11:06:51 -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 <phil@philjordan.eu>)
 id 1tM8BY-0001k5-A1
 for qemu-devel@nongnu.org; Fri, 13 Dec 2024 11:06:38 -0500
Received: from mail-ej1-x62a.google.com ([2a00:1450:4864:20::62a])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
 (Exim 4.90_1) (envelope-from <phil@philjordan.eu>)
 id 1tM8BV-0006fx-G8
 for qemu-devel@nongnu.org; Fri, 13 Dec 2024 11:06:35 -0500
Received: by mail-ej1-x62a.google.com with SMTP id
 a640c23a62f3a-aa67ac42819so318099866b.0
 for <qemu-devel@nongnu.org>; Fri, 13 Dec 2024 08:06:32 -0800 (PST)
Received: from localhost.localdomain (h082218084190.host.wavenet.at.
 [82.218.84.190]) by smtp.gmail.com with ESMTPSA id
 a640c23a62f3a-aa667843413sm916683166b.24.2024.12.13.08.06.29
 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256);
 Fri, 13 Dec 2024 08:06:29 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=philjordan-eu.20230601.gappssmtp.com; s=20230601; t=1734105991;
 x=1734710791;
 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=TLgf/hBtKPWGX+IefC929iFjKjT8oYxXZ2UyNeVgI20=;
 b=eMnDd/fBJkNxhXDWMwQpyChErFwycheJWR0E7Dz98qXlPk8FarZjK9inBfsZtVd27q
 zd1FJJCtZ+MUXnWijrXF5JeYN4mhzrB1ZuMN33xGauwPQ5/kSKRtjs8VD7pvhxJYS4J9
 /3ek37sxWQGNEql1NTY0KLkJBT6dDXHRyFGL9QDXoXMud5cuVtL+qWUzOsn/Wqr/h1l1
 2YLHL9S1LI7y9sQnwteBPMnfSPoG1mctqUYzRB0Hhdz4LaIYRIVOEMrdvcYtx7Dt/BlQ
 hiyov/z2bmyZGYlCqYoquSFY62DeBcqti7KdRzmUxmmC1J0wO1M5tMdw+OS+1A1WF/+X
 FgWA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1734105991; x=1734710791;
 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=TLgf/hBtKPWGX+IefC929iFjKjT8oYxXZ2UyNeVgI20=;
 b=J2jYnhVfFOlntf1Clvcppajzb2gdswQ0nMEhaH4g6Endcr8aICti5ApcDQW/VSn5yi
 ek4oIdeDf/x0C0wmwwtlXNXO2/uSjKBfnLDarS0/OSRH/YlMh40u2AwkeQlOOD2HL70z
 JFTBBTPMlbl3pr8lappZHTUXhFPiLKj21HoLkGCPlfiORCcPJGqkx3TeltAYhu4XIoks
 oU9oFzA6yMuMl97JKuEFHqEZ8VP/NvvmCxnLGbBHwH0e3hnkPktfbMkesJivku0wZznW
 I7LpoQDvLL8Fh6YLmqwxQeBIKmc95rzR7GzIX/lDHvSrMD681XT64xhHUEJcKgXn7Gt/
 XdSA==
X-Gm-Message-State: AOJu0YxmXV6MwIXStxR/l1xxTiWQRHfMKtNNBchVtcADufRss6Q6bkzj
 6Xib9UqepieQKRkjce6RSJvBhPb65dBer9EXO2fYm+FXQ3RtLPki5lbgrKyLA0j6LH0Zxh3ogIB
 m9Q==
X-Gm-Gg: ASbGncv+9EIELw3OJzXmfsxR9sm7nl9kCrpu/hY8DrXHOqxscTvj2WGg7vefss4m2aX
 +lTtCk4Xrj/z21Tk45JJr92ySXjwIYTHdKJtOoDAG4EuUvlgwH2XKYRwsOPuabedb8ubdObEo+c
 sC1rYv1dGSznaptPIiORt5IW7+BC2brRlHUPB5mq4o9mEvlqHhtLQhP25hvMd1npKiVnbxmkiHc
 WaISUR8cS+t3hqBb48xKIt5qK13147cIRBv1NfVVn+5eqf5UFivA5zATW0Wa1PW4nBBqxuQvdU7
 J5fMV5vi9ubLDVhGt1VsU6vbAbMaOMYR
X-Google-Smtp-Source: 
 AGHT+IHaw3W3f56M3kqBelZ34InNyOfGln+ODqqA2m0ooUtMCs6A1BxKnzI5uO0CA8otU6vZGdEHiA==
X-Received: by 2002:a17:906:a3cc:b0:aab:92bd:1a8f with SMTP id
 a640c23a62f3a-aab92bd1acamr41468066b.26.1734105989884;
 Fri, 13 Dec 2024 08:06:29 -0800 (PST)
From: Phil Dennis-Jordan <phil@philjordan.eu>
To: qemu-devel@nongnu.org
Cc: richard.henderson@linaro.org, philmd@linaro.org, thuth@redhat.com,
 zhao1.liu@intel.com, imammedo@redhat.com, akihiko.odaki@daynix.com,
 Phil Dennis-Jordan <phil@philjordan.eu>
Subject: [PATCH v2 6/6] hw/vmapple: XHCI controller's interrupt mapping
 workaround for macOS
Date: Fri, 13 Dec 2024 17:06:19 +0100
Message-Id: <20241213160619.66509-7-phil@philjordan.eu>
X-Mailer: git-send-email 2.39.5 (Apple Git-154)
In-Reply-To: <20241213160619.66509-1-phil@philjordan.eu>
References: <20241213160619.66509-1-phil@philjordan.eu>
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: neutral client-ip=2a00:1450:4864:20::62a;
 envelope-from=phil@philjordan.eu; helo=mail-ej1-x62a.google.com
X-Spam_score_int: -10
X-Spam_score: -1.1
X-Spam_bar: -
X-Spam_report: (-1.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1,
 DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001,
 SPF_NEUTRAL=0.779 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: <qemu-devel.nongnu.org>
List-Unsubscribe: <https://lists.nongnu.org/mailman/options/qemu-devel>,
 <mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>
List-Archive: <https://lists.nongnu.org/archive/html/qemu-devel>
List-Post: <mailto:qemu-devel@nongnu.org>
List-Help: <mailto:qemu-devel-request@nongnu.org?subject=help>
List-Subscribe: <https://lists.nongnu.org/mailman/listinfo/qemu-devel>,
 <mailto:qemu-devel-request@nongnu.org?subject=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 @philjordan-eu.20230601.gappssmtp.com)
X-ZM-MESSAGEID: 1734106107931116600
Content-Type: text/plain; charset="utf-8"

This change enables the new conditional interrupt mapping support
property on the vmapple machine type's integrated XHCI controller
using compat_props.

The macOS guest driver attempts to use event rings 1 and 2 on the XHCI
controller, despite there being only one (PCI pin) interrupt channel
available. With conditional interrupt mapping enabled, the XHCI
controller will only schedule events on interrupter 0 in PCI pin mode.

Signed-off-by: Phil Dennis-Jordan <phil@philjordan.eu>
---

v2:

 * Set the "conditional-intr-mapping" property via compat_props, not
   directly on the created XHCI controller object.

 hw/vmapple/vmapple.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/hw/vmapple/vmapple.c b/hw/vmapple/vmapple.c
index 66336942c8d..1732334c779 100644
--- a/hw/vmapple/vmapple.c
+++ b/hw/vmapple/vmapple.c
@@ -641,8 +641,19 @@ static void machvmapple_machine_init(void)
 }
 type_init(machvmapple_machine_init);
=20
+static GlobalProperty vmapple_compat_defaults[] =3D {
+    /*
+     * macOS XHCI driver attempts to schedule events onto even rings 1 & 2
+     * even when (as here) there is no MSI(-X) support. Disabling interrup=
ter
+     * mapping in the XHCI controller works around the problem.
+     */
+    { TYPE_QEMU_XHCI, "conditional-intr-mapping", "on" },
+};
+
 static void vmapple_machine_10_0_options(MachineClass *mc)
 {
+    compat_props_add(mc->compat_props, vmapple_compat_defaults,
+                     G_N_ELEMENTS(vmapple_compat_defaults));
 }
 DEFINE_VMAPPLE_MACHINE_AS_LATEST(10, 0)
=20
--=20
2.39.5 (Apple Git-154)