From patchwork Mon Feb 20 08:00:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 655043 Delivered-To: patch@linaro.org Received: by 2002:adf:9bcd:0:0:0:0:0 with SMTP id e13csp1267746wrc; Mon, 20 Feb 2023 00:01:14 -0800 (PST) X-Google-Smtp-Source: AK7set+udf3va6NcvKZguOfL4KXLw3raUuRUcAt0kzmh6psdp3/QWYMEFnP6m1g1NKkM7lM7N26y X-Received: by 2002:a05:6214:2a8d:b0:53c:dac5:45e1 with SMTP id jr13-20020a0562142a8d00b0053cdac545e1mr5121472qvb.16.1676880074634; Mon, 20 Feb 2023 00:01:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676880074; cv=none; d=google.com; s=arc-20160816; b=FyZnzFtbssPwkVneQc17b3eCQkr8f/RBkk5wQlfoSPnebqwPrtbk1UfQyAtB2gWyoT 7YAt+VuvuPYvFdVjOj0+TQKlPZrQpEmgEPZwiHQTCilZ0YmkD4JVz7fadep+z+WHiHzY 1dxkS5N371wZeO66wfozRI4u/75v9qQDfnBEhRMw/0Bsk7WIsIeeX4XLquOvyw9xBNot gp//Hjg1yb11wsci/NzryNrSJnc7w0p4xTvGdYcViEPtfLygFxXBzqvtTteOxHDOXjMI OdPCQ9qA5VQ/zf2cUyjeprrcgUXTyOLArgiq/wnx/zyoJ4uKUjvRfSqgqluziLieDFvL EltA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=yfAOCbOrpz6J6Wxsrdg+3kMQlvdMfu+E0+Y8RNVdPuE=; b=OBQtcp2XfQ+n8/RHLKwZ6EEGauBb9QoAHQk/RhKZggTlbKuwD9eAWp378ONbRBBAFI 0ARY/B10BTPi/6EgXpMrv49vGG6rrnFb6Dl5ngEbqgHmhILNo1qZgkl0zm0sohFrkED1 bzoB1nqnSNB9BYpiPmKae0xkX5D2YaJjLaRGcBN1y1/YMaYIxF9gtIfeCKmTKdiaj/fD 3AoqRFSRmB1aYKRkxRMxCO2/FD5QukuiEPRspfVE3joVB3UciFnC369EH0PHXhgYYfGW R6dpofH6j+wLkzmvPJWVmiggvQwmSs2RKbXv9LQwa8g32fW4sOA1c1zm7righr8Uv8TY o9sA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="MZBvc/eP"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id i124-20020a378682000000b0071d42f4676esi9037223qkd.361.2023.02.20.00.01.14 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 20 Feb 2023 00:01:14 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="MZBvc/eP"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pU16X-0007OF-Do; Mon, 20 Feb 2023 03:00:59 -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 1pU16R-0007Lr-Q0 for qemu-devel@nongnu.org; Mon, 20 Feb 2023 03:00:51 -0500 Received: from mail-wm1-x330.google.com ([2a00:1450:4864:20::330]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pU16P-0007J6-Az for qemu-devel@nongnu.org; Mon, 20 Feb 2023 03:00:50 -0500 Received: by mail-wm1-x330.google.com with SMTP id az11-20020a05600c600b00b003dc4fd6e61dso267371wmb.5 for ; Mon, 20 Feb 2023 00:00:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; 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=yfAOCbOrpz6J6Wxsrdg+3kMQlvdMfu+E0+Y8RNVdPuE=; b=MZBvc/ePri99FNYVQiOdAXW3PTCRPuqmM+LKoXF+tkmqwD3oVf9ewenOPfRmgfozwf IjU2LAOk5pEPnblsbeb5srpGlMIi4z8wzOSAjVI0ubdqm0zzeHqguIWZAFKrN8o2PwNE fimFgOHV58Ndc67mbHNmIK1imqdvGLSEG4EKko3m3A6T9ZfIFMVadpoGORSESPrfwPje 6uCmKkH/fV8lMhkTwCbSuoDTv9PYdbhWShZDOrS++1zMyaz267II7GlnfuzuAWcU3kgh z5y7QlBfQQcS23k8CwwwqioWx5S6GqESgp8IpjdvD4wp2qqddo8F87DejKuuNSafZ562 KdIQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=yfAOCbOrpz6J6Wxsrdg+3kMQlvdMfu+E0+Y8RNVdPuE=; b=UaoFRNLxUs9BkwU2TwO4sNd3NtIHE6JYu7f9wPCzwqPp6hkZPuANpTjuHCrOR3VUMS uPnDf+/qjqBNkZV0fsWDiBsIvVTWqOfoETEKLid4vEKcVyLTNBqV/LnGLO0eGj0oAGwu u1Qc0Y6hbNgQ1c2A5G8C7CEYssw3Ml5sPUJPfYr0llJ+WSGUs/wJM/B+1sfQzLtEHGf6 mfr+QmJH8Rdi3ePNoxFnvX7Mbg7e6+qIfXXzyLr/896tX+tijHO3xa5UPm5IZN4pjAvz uH35Pw8qkBiY8YDOGcryscxsz+PHoibqtjhcVu3pnlEcE8O+ec6PgHoJn1d7JkqfoYT+ +SEQ== X-Gm-Message-State: AO0yUKULKTcVQG7FurEpU11rROLRHsPD4A6CNdnzCgj3CSfxbrVVBvf/ i179KxNWQ7UxIeOCtKZwzIEz1yamEU3y4rym X-Received: by 2002:a05:600c:4e41:b0:3e1:feb9:5a2f with SMTP id e1-20020a05600c4e4100b003e1feb95a2fmr11261731wmq.2.1676880047575; Mon, 20 Feb 2023 00:00:47 -0800 (PST) Received: from localhost.localdomain ([81.0.6.76]) by smtp.gmail.com with ESMTPSA id 1-20020a05600c028100b003e200dc15f5sm13314808wmk.42.2023.02.20.00.00.46 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 20 Feb 2023 00:00:47 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-ppc@nongnu.org, hreitz@redhat.com, kwolf@redhat.com, kraxel@redhat.com, mst@redhat.com, qemu-block@nongnu.org, hpoussin@reactos.org, richard.henderson@linaro.org, eduardo@habkost.net, John Snow , pbonzini@redhat.com, =?utf-8?q?Philippe_Mathi?= =?utf-8?q?eu-Daud=C3=A9?= , Bernhard Beschow Subject: [PATCH v2 06.5/18] hw/ide/piix: Allow using PIIX3-IDE as standalone PCI function Date: Mon, 20 Feb 2023 09:00:44 +0100 Message-Id: <20230220080044.4646-1-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230215161641.32663-1-philmd@linaro.org> References: <20230215161641.32663-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::330; envelope-from=philmd@linaro.org; helo=mail-wm1-x330.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org In order to allow Frankenstein uses such plugging a PIIX3 IDE function on a ICH9 chipset (which already exposes AHCI ports...) as: $ qemu-system-x86_64 -M q35 -device piix3-ide add a kludge to automatically wires the IDE IRQs on an ISA bus exposed by a PCI-to-ISA bridge (usually function #0). Restrict this kludge to the PIIX3. Reported-by: Bernhard Beschow Signed-off-by: Philippe Mathieu-Daudé --- hw/ide/piix.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/hw/ide/piix.c b/hw/ide/piix.c index 9d876dd4a7..50975a16b3 100644 --- a/hw/ide/piix.c +++ b/hw/ide/piix.c @@ -170,6 +170,17 @@ static void pci_piix_ide_realize(PCIDevice *dev, Error **errp) vmstate_register(VMSTATE_IF(dev), 0, &vmstate_ide_pci, d); + if (!d->irq[0] && !d->irq[1] && DEVICE_GET_CLASS(d)->user_creatable) { + /* kludge specific to TYPE_PIIX3_IDE */ + Object *isabus = object_resolve_path_type("", TYPE_ISA_BUS, NULL); + + if (!isabus) { + error_setg(errp, "Unable to find a unique ISA bus"); + return; + } + d->irq[0] = isa_bus_get_irq(ISA_BUS(isabus), 14); + d->irq[1] = isa_bus_get_irq(ISA_BUS(isabus), 15); + } for (unsigned i = 0; i < ARRAY_SIZE(d->irq); i++) { if (!pci_piix_init_bus(d, i, errp)) { return; @@ -202,6 +213,13 @@ static void piix3_ide_class_init(ObjectClass *klass, void *data) k->class_id = PCI_CLASS_STORAGE_IDE; set_bit(DEVICE_CATEGORY_STORAGE, dc->categories); dc->hotpluggable = false; + /* + * This function is part of a Super I/O chip and shouldn't be user + * creatable. However QEMU accepts impossible hardware setups such + * plugging a PIIX IDE function on a ICH ISA bridge. + * Keep this Frankenstein (ab)use working. + */ + dc->user_creatable = true; } static const TypeInfo piix3_ide_info = { @@ -225,6 +243,8 @@ static void piix4_ide_class_init(ObjectClass *klass, void *data) k->class_id = PCI_CLASS_STORAGE_IDE; set_bit(DEVICE_CATEGORY_STORAGE, dc->categories); dc->hotpluggable = false; + /* Reason: Part of a Super I/O chip */ + dc->user_creatable = false; } static const TypeInfo piix4_ide_info = {