From patchwork Fri Dec 13 16:06:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Phil Dennis-Jordan X-Patchwork-Id: 13907416 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 3E150E7717F for ; Fri, 13 Dec 2024 16:07:06 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) 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 ) 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 ) 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 ; 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=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) 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) From: Phil Dennis-Jordan 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 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 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: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org 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 --- 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, bool level) } if (msi_enabled(pci_dev) && level) { + n %= msi_nr_vectors_allocated(pci_dev); msi_notify(pci_dev, n); return true; } From patchwork Fri Dec 13 16:06:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Phil Dennis-Jordan X-Patchwork-Id: 13907418 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 59712E7717D for ; Fri, 13 Dec 2024 16:07:36 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) 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 ) 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 ) 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 ; 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=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) 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) From: Phil Dennis-Jordan 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 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 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: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org 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 Reviewed-by: Philippe Mathieu-Daudé --- 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 { }; static Property nec_xhci_properties[] = { - 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); } +static Property xhci_pci_properties[] = { + 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 = PCI_DEVICE_CLASS(klass); @@ -209,6 +215,7 @@ static void xhci_class_init(ObjectClass *klass, void *data) k->realize = usb_xhci_pci_realize; k->exit = usb_xhci_pci_exit; k->class_id = PCI_CLASS_SERIAL_USB; + device_class_set_props(dc, xhci_pci_properties); } static const TypeInfo xhci_pci_info = { From patchwork Fri Dec 13 16:06:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Phil Dennis-Jordan X-Patchwork-Id: 13907420 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C5FF2E7717D for ; Fri, 13 Dec 2024 16:08:01 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) 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 ) 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 ) 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 ; 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=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) 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) From: Phil Dennis-Jordan 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 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 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: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org 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 --- 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 *event, int v) dma_addr_t erdp; unsigned int dp_idx; + if (xhci->numintrs == 1) { + v = 0; + } + if (v >= xhci->numintrs) { DPRINTF("intr nr out of range (%d >= %d)\n", v, xhci->numintrs); return; From patchwork Fri Dec 13 16:06:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Phil Dennis-Jordan X-Patchwork-Id: 13907421 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 94F63E7717F for ; Fri, 13 Dec 2024 16:08:08 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) 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 ) 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 ) 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 ; 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=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) 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) From: Phil Dennis-Jordan 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 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 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: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org 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 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; } +static bool xhci_pci_intr_mapping_conditional(XHCIState *xhci) +{ + XHCIPciState *s = container_of(xhci, XHCIPciState, xhci); + PCIDevice *pci_dev = PCI_DEVICE(s); + + /* + * Implementation of the "conditional-intr-mapping" property, which only + * enables interrupter mapping if MSI or MSI-X is available and active. + * Forces all events onto interrupter/event ring 0 in pin-based IRQ mode. + * 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 = 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 = xhci_pci_intr_update; s->xhci.intr_raise = xhci_pci_intr_raise; + if (s->conditional_intr_mapping) { + s->xhci.intr_mapping_supported = xhci_pci_intr_mapping_conditional; + } 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[] = { 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(), }; @@ -216,6 +236,10 @@ static void xhci_class_init(ObjectClass *klass, void *data) k->exit = usb_xhci_pci_exit; k->class_id = 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 behaviour, " + "such as macOS's."); } static const TypeInfo xhci_pci_info = { 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; #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 *event, int v) dma_addr_t erdp; unsigned int dp_idx; - if (xhci->numintrs == 1) { + if (xhci->numintrs == 1 || + (xhci->intr_mapping_supported && !xhci->intr_mapping_supported(xhci))) { v = 0; } 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 most + * implementations, for defaulting to enabled mapping unless numintrs == 1. + */ + bool (*intr_mapping_supported)(XHCIState *s); DeviceState *hostOpaque; /* Operational Registers */ From patchwork Fri Dec 13 16:06:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Phil Dennis-Jordan X-Patchwork-Id: 13907419 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id BF7CCE7717D for ; Fri, 13 Dec 2024 16:07:38 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) 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 ) 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 ) 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 ; Fri, 13 Dec 2024 08:06:30 -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) 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) From: Phil Dennis-Jordan 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 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 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: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Fixes number of spaces used for indentation on one line. Signed-off-by: Phil Dennis-Jordan --- 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 = PCI_DEVICE(s); int intr; - for (intr = 0; intr < s->xhci.numintrs; intr++) { + for (intr = 0; intr < s->xhci.numintrs; intr++) { if (s->xhci.intr[intr].msix_used) { msix_vector_use(pci_dev, intr); } else { From patchwork Fri Dec 13 16:06:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Phil Dennis-Jordan X-Patchwork-Id: 13907422 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D2E63E7717D for ; Fri, 13 Dec 2024 16:08:26 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) 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 ) 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 ) 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 ; Fri, 13 Dec 2024 08:06:32 -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) 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) From: Phil Dennis-Jordan 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 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 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: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org 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 --- 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); +static GlobalProperty vmapple_compat_defaults[] = { + /* + * macOS XHCI driver attempts to schedule events onto even rings 1 & 2 + * even when (as here) there is no MSI(-X) support. Disabling interrupter + * 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)