From patchwork Thu Oct 19 07:16:06 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: 735524 Delivered-To: patch@linaro.org Received: by 2002:adf:f0cd:0:b0:32d:baff:b0ca with SMTP id x13csp1378489wro; Thu, 19 Oct 2023 00:19:39 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEqKf/DFZPxhhRj6Rbn0ir7dMLIFXn7IxFuWctjkveffmWgKjUufq/I3iUrBImigCJ8aX2k X-Received: by 2002:a05:620a:9d0:b0:76c:d5ac:66d7 with SMTP id y16-20020a05620a09d000b0076cd5ac66d7mr1206274qky.43.1697699979149; Thu, 19 Oct 2023 00:19:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697699979; cv=none; d=google.com; s=arc-20160816; b=vkRT9/6ffiGyJsATpy2FhHEeFXFOU9MQGc57a2aWC9ovp3KmHpdqK+fPg5A7ZyUXhi aR2qt/vPvh3KXQt1ptAhaKmb3wCJJbh2UOEn4dTuprS+tmfK+l7Re67+vrjyw2SDz2O3 qy8NJc6SNIq31ZtwR2BDPn5S0FVckOYVlAfTLzEyVJq2Ze+9/RCzfmW88vDJwMHw4X+a 4V1fOfcp9cgHSTmJoLZWfvZtrvAHKfLErseFoeYZdHuiJPWSD8J8JXPN8MCIKB1MN6Q9 BgFhMPxVCGVzIkuqQp/Jbs5Ln5kY03X5QkY+rFSpkgftcKUzRpbv5ZZxb2g+G9HgCcUZ 823g== 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=+HC0X9fTzvHDBaGKX3SssvMlymhei2jKRNiniE4txSs=; fh=6jYKO1R8PvzdW4tN+W/XYlQifBf+lht0eG+bQc5OUAg=; b=JJiaEhkSczbYcXYyzrvFDE/uzCWcrhTje/tGUpxONdBYTWQPjINfo5TaRwJ7w1nhYj o2asksVKBBio4PfBhQEoeyM/6Mk1c/xiELxbmOP4vfVZo4mIGx15DwYnwHb8qACjjtoQ yRNXelDp6Ze6gBAmEIAOz38rp1s+YanKtB+tAWqjRP7NfDtyLNkTkH5bFNfrCajleDrt /aEH971d61zrKfNR0nHUa1BOJpEpFPnaCaDYTwDZdfo42GaZiGfqM7b0kAheI/dWchAK WGCXJSAk5hGWArif9L/yqxX8Zi1LLh8ckK1y0imE0+6N2+c2oIfiTQ0G+8ek8yUtngR0 clvw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=LmmhiZIP; 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 j15-20020a05620a288f00b0077762436ea5si1148020qkp.758.2023.10.19.00.19.38 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 19 Oct 2023 00:19:39 -0700 (PDT) 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=LmmhiZIP; 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 1qtNIs-00079L-Oc; Thu, 19 Oct 2023 03:18:46 -0400 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 1qtNHs-0005yt-VY for qemu-devel@nongnu.org; Thu, 19 Oct 2023 03:17:47 -0400 Received: from mail-wr1-x42f.google.com ([2a00:1450:4864:20::42f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qtNHq-0003KD-Fl for qemu-devel@nongnu.org; Thu, 19 Oct 2023 03:17:44 -0400 Received: by mail-wr1-x42f.google.com with SMTP id ffacd0b85a97d-32d834ec222so6642494f8f.0 for ; Thu, 19 Oct 2023 00:17:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1697699859; x=1698304659; 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=+HC0X9fTzvHDBaGKX3SssvMlymhei2jKRNiniE4txSs=; b=LmmhiZIP3SB4h9gPr9iOZ3/9T5jtEatvnLI7nUOux5gKefeXUfCo99zFl2mvHToNpe yc77PjqinmEvFBa6dJKVXGAwuVMfp1++KhGwJX1m/Repkz7ZElgVLPw1O4MKwYiuHzLH KGjhb+SsKhJE0lfl0orp5ZqBhQEWmSOSJn1RDItjg6S1eSuU1FNr1GCGEyvL9HIxLw5Z QU4o+oEg6+2mNEmtyUoNV1bDWqVdV6J7HGcNVvuTB/zOZbVP5a1exv05x13vgGHZ/fnH kcWERlnTxkVwY/WFcmLRiWl7jcuOdMqkeTLBbQt9fp2UAH+Nk2PPZFDRd/yuUU3eQqFr pBNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697699859; x=1698304659; 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=+HC0X9fTzvHDBaGKX3SssvMlymhei2jKRNiniE4txSs=; b=iFNhJKFF7rrKd1yps5xIFIWta9dePil7l9HG9aQQWnPCpfkC4DQWxL4avlSqKbTluq akrnC0km6WgsjY9TFqFNDtPCpt0ih6+arITsMoSVBbCbItbywarmO3BSv4CV6dwbBf7z TPhSzHGmIoLnpDMkmsiauYBllNpSwcdy2De02xn+E0IKv/yi+9u7sNxVQxntgR63RQLX L/QS8SDtQ/4OMHgUElo4MOa5a04DUB33s3zAXOCdaKFtnLag6h28EyBTymx8yXIyfOTz HBzSEdfkzja7eP09VSFmj6FbLDAjGOaLrauGqdemgL06YeLJCu1XNCE+Qps2A60jfwv1 LC+Q== X-Gm-Message-State: AOJu0YyN8gg2vv1aj/9O8O/+/uR8eeZVCIr+MeXGwRMjYtl3olpceIE2 9vO9mRPQ+k5yAllZg4Give/dOV1Mf/0wY1aa3LFvDg== X-Received: by 2002:adf:ed0e:0:b0:327:e073:d5fe with SMTP id a14-20020adfed0e000000b00327e073d5femr854081wro.38.1697699859542; Thu, 19 Oct 2023 00:17:39 -0700 (PDT) Received: from localhost.localdomain (92.red-88-28-12.dynamicip.rima-tde.net. [88.28.12.92]) by smtp.gmail.com with ESMTPSA id a15-20020a056000100f00b0032d9337e7d1sm3775457wrx.11.2023.10.19.00.17.35 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 19 Oct 2023 00:17:39 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Ilya Leoshkevich , Halil Pasic , Huacai Chen , Beniamino Galvani , Thomas Huth , Jiaxun Yang , Marcel Apfelbaum , qemu-arm@nongnu.org, Mark Cave-Ayland , Eric Farman , Paolo Bonzini , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , qemu-s390x@nongnu.org, Strahinja Jankovic , Richard Henderson , Markus Armbruster , Song Gao , Eduardo Habkost , Peter Xu , Sergio Lopez , Christian Borntraeger , David Hildenbrand , Peter Maydell , "Michael S. Tsirkin" , Jason Wang Subject: [PATCH v2 08/12] hw/isa: Realize ISA BUS sysbus device before accessing it Date: Thu, 19 Oct 2023 09:16:06 +0200 Message-ID: <20231019071611.98885-9-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231019071611.98885-1-philmd@linaro.org> References: <20231019071611.98885-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42f; envelope-from=philmd@linaro.org; helo=mail-wr1-x42f.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=unavailable 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 qbus_new() should not be called on unrealized device. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Michael S. Tsirkin --- hw/isa/isa-bus.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/hw/isa/isa-bus.c b/hw/isa/isa-bus.c index a289eccfb1..f1e0f14007 100644 --- a/hw/isa/isa-bus.c +++ b/hw/isa/isa-bus.c @@ -52,18 +52,25 @@ static const TypeInfo isa_bus_info = { ISABus *isa_bus_new(DeviceState *dev, MemoryRegion* address_space, MemoryRegion *address_space_io, Error **errp) { + DeviceState *bridge = NULL; + if (isabus) { error_setg(errp, "Can't create a second ISA bus"); return NULL; } if (!dev) { - dev = qdev_new("isabus-bridge"); - sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal); + bridge = qdev_new("isabus-bridge"); + dev = bridge; } isabus = ISA_BUS(qbus_new(TYPE_ISA_BUS, dev, NULL)); isabus->address_space = address_space; isabus->address_space_io = address_space_io; + + if (bridge) { + sysbus_realize_and_unref(SYS_BUS_DEVICE(bridge), &error_fatal); + } + return isabus; }