From patchwork Fri Feb 9 12:32:19 2024 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: 771316 Delivered-To: patch@linaro.org Received: by 2002:adf:9dca:0:b0:33b:4db1:f5b3 with SMTP id q10csp823871wre; Fri, 9 Feb 2024 04:33:42 -0800 (PST) X-Google-Smtp-Source: AGHT+IGqRCvm2MEJW7+kBCo2RuV8yLyQp0qRd1VUukAly0U9vJ7x6obmkUm9vvNcMVAJiLsJaidC X-Received: by 2002:a0c:ca0b:0:b0:68c:9b53:8eb6 with SMTP id c11-20020a0cca0b000000b0068c9b538eb6mr1454314qvk.43.1707482021953; Fri, 09 Feb 2024 04:33:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1707482021; cv=none; d=google.com; s=arc-20160816; b=wRExJfmbCbGscLOnqyvt++BC4z/KER90WrHF6Hu/0m4DqknXXb+CTmEa/fjOBe3O1T 3ndglbxHqC/0BE82uitwL8NUa2ZE639AWyeS/uRavYbZXQHXpG4rsofmvNaSUDtIF+jP mCDhNxjWjGgJ5fYx314VyQWczMwVljyKB/D/3w4LC5g5umpp47qGc3yRaiDskTx9BaYU Sr13xMIXKNr+Jug6J83qCAUxkGmOYSQPadD2IvlZ5FHcHVYL5LrBfHvwqogq4VURRzwN iYAr++Br1eQHQw2+UrUPriBLy0LSTw0+bDQf0RO6nxYVcCd3q8NtufRk7paz+2yNlKRF dzFw== 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=D/EF0ukeLn1gu/zaqcDjARqMaoRLvmGATkelLRoHEzw=; fh=b4tN4WcEU40+ZNS4BF0BqykdAyDMoWHosKiY/Q9/cD0=; b=kzSchP4XUTf6xZSTEbJMH7RlkZ+2kzmltUoxv88Fa4+249n8MhRWaGoV1hTdOQI8VQ LQ/AVpIUnC4JIurh7qgzcpyviIEJSzL6YNciyC66GVzRGY2aDxGJ2s7Cz+s3SuiYOMNF xoQRt+LswTj+XEwUnOR9pPoCaGaCCuKG2k9tDWpHTCXh6gF27dKhBbynsQ2CyF3ET+pC YNR3IIJZakPTLMbAyY0e+rNaE4OTwCFeJFuhYZ49QlxeHJenGF3ws/R8bn5mlxN37xAk LzAses1KnMvZrHcSuX49if8u2VlQXP6zX2BXuurAeVBzvx9v4fJOvzkQ9sPjmkYkbKWn m4kQ==; darn=linaro.org ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=wT9dB7Rh; 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 X-Forwarded-Encrypted: i=1; AJvYcCXSLE0JLvHE9FPd8OHHQV4WOKHBz6+gblUQ79raXEPn4bOFKxCDcTRKtNK/0Syqo6O4rNa6ZlVO1/fcZQBXqTMa Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id jo12-20020a056214500c00b0068cc0ed1f88si1847487qvb.326.2024.02.09.04.33.41 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 09 Feb 2024 04:33:41 -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=wT9dB7Rh; 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 1rYQ3e-0007kC-Gx; Fri, 09 Feb 2024 07:32:42 -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 1rYQ3c-0007ix-H5 for qemu-devel@nongnu.org; Fri, 09 Feb 2024 07:32:40 -0500 Received: from mail-lf1-x131.google.com ([2a00:1450:4864:20::131]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rYQ3Z-0001pS-BW for qemu-devel@nongnu.org; Fri, 09 Feb 2024 07:32:40 -0500 Received: by mail-lf1-x131.google.com with SMTP id 2adb3069b0e04-5116b017503so1145525e87.1 for ; Fri, 09 Feb 2024 04:32:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1707481955; x=1708086755; 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=D/EF0ukeLn1gu/zaqcDjARqMaoRLvmGATkelLRoHEzw=; b=wT9dB7Rhhr4feEQsUkJWsAoMzDnk41S7aB+GfGEB3NbzKbD0wHCMFP13HKpJbtgAA0 ghkiupFWJVmKDTUiONufcOStB4jeLiq1EWrXTS2j55bKa7+ZLHxk9U/dz5WYTVCuX/Uv lYu1BAj2L/Paw9V27JHKe5cGTMCDsr9dE3wKpwTF16RcyzAxOX01yBOWmcNnJAWxP5pZ em4qyLDBvRLHEGUzft2q2lrBXGebRz1T4+WpI1SyOvc+pDkN6sCoQrYeuFfl2TVR62bF fQyc5TV+vgHtOi4trnfnU53dGldDnTCbKkc8EQlUCc3WN2O6yzYb1QTdUjBgIL1E/SGb x7mQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707481955; x=1708086755; 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=D/EF0ukeLn1gu/zaqcDjARqMaoRLvmGATkelLRoHEzw=; b=rxI7jjhf2aLhuNCaS7fIfe4QLD5fqEkWXm+vtERA7DeoS7PyNcA3iplubWxjmnweEv yYjXxNX9MLsQe0e1/2bxGt8BEoDIWmStFbxE/Vi4trjY8ENejrc+kCNLEzohUxHxilCu zx8K8nSOyW2NjEZC9kvZqL4DckC2gHBQINie26Bn5P0yIC6RHySEgo9tJz7+Rfh5o0yM vDbnWDUTtZEZJrrX0C4ZkN3KZGCiXkPhWK4asFbZCL+XPGjo22QqkdDVG/NcCNSRD76E YnF3j4+UntQbAms3xXuCAWN94E+1DguEespzXGstSn6/mDTnsj0PtBFn1rtlxlLLG93A lpSQ== X-Gm-Message-State: AOJu0YxvwrLVjbckowGudeApXBBQrjqaXHlM43omR/ef0DiIUf823lay Y8uMTLGGKJ9tpqa62wBZpi4efXwzO5on3/yv7p0ppK6XGnJrIC6BaOFnocAUTDtV4rKpQ5hxPQ3 A X-Received: by 2002:ac2:5213:0:b0:511:78bb:a9da with SMTP id a19-20020ac25213000000b0051178bba9damr1050764lfl.39.1707481955364; Fri, 09 Feb 2024 04:32:35 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCWOxnzVCCy/U/2x4P2+0KM350C3xhqnQsKdrTEyWhR73+BTmRLGIr6ib1IOOGp8wKrXY3m5Ew8fI8vgpaeHbL58EZ67MtBtC8SAyviYbCiAEUENUfRQfJ/P6+oCFZ/SDCVW+jowkVVQpahRotlAHzlXntDPh+V4kyIcFvk2fn9NtyDKRB1tfyPkL2iUgnumUkj0dmzIw9NHNuupSJoQnAW9MvqNWNXQVEAvkvRqi7Pp17CIMioFku4/J5iKUM/eOpuP6FHQIxOdTXf7szYJBcdmc9CU4p+y1aFO6F22dVzl7X07kreNMoNiJs/pN42aV3jh7DXLWNuh3FE= Received: from m1x-phil.lan ([176.187.218.105]) by smtp.gmail.com with ESMTPSA id 7-20020a05600c248700b0040fddaf9ff4sm482987wms.40.2024.02.09.04.32.33 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 09 Feb 2024 04:32:34 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Paolo Bonzini , BALATON Zoltan , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Laurent Vivier , Jiaxun Yang , qemu-block@nongnu.org, John Snow , qemu-ppc@nongnu.org, Eduardo Habkost , "Michael S. Tsirkin" Subject: [RFC PATCH 1/7] hw/qdev: Introduce DeviceClass::[un]wire() handlers Date: Fri, 9 Feb 2024 13:32:19 +0100 Message-ID: <20240209123226.32576-2-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240209123226.32576-1-philmd@linaro.org> References: <20240209123226.32576-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::131; envelope-from=philmd@linaro.org; helo=mail-lf1-x131.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, T_SCC_BODY_TEXT_LINE=-0.01 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 Signed-off-by: Philippe Mathieu-Daudé --- include/hw/qdev-core.h | 8 +++++++- hw/core/qdev.c | 21 ++++++++++++++++++++- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h index d47536eadb..2ca33aea3b 100644 --- a/include/hw/qdev-core.h +++ b/include/hw/qdev-core.h @@ -101,8 +101,12 @@ typedef void (*BusUnrealize)(BusState *bus); * @props: Properties accessing state fields. * @realize: Callback function invoked when the #DeviceState:realized * property is changed to %true. + * @wire: Callback function called after @realize to connect IRQs, + * clocks and map memories. Can not fail. + * @unwire: Callback function to undo @wire. Called before @unrealize. + * Can not fail. * @unrealize: Callback function invoked when the #DeviceState:realized - * property is changed to %false. + * property is changed to %false. Can not fail. * @hotpluggable: indicates if #DeviceClass is hotpluggable, available * as readonly "hotpluggable" property of #DeviceState instance * @@ -161,6 +165,8 @@ struct DeviceClass { */ DeviceReset reset; DeviceRealize realize; + void (*wire)(DeviceState *dev); + void (*unwire)(DeviceState *dev); DeviceUnrealize unrealize; /** diff --git a/hw/core/qdev.c b/hw/core/qdev.c index c68d0f7c51..1d399aae71 100644 --- a/hw/core/qdev.c +++ b/hw/core/qdev.c @@ -303,6 +303,16 @@ bool qdev_realize_and_unref(DeviceState *dev, BusState *bus, Error **errp) void qdev_unrealize(DeviceState *dev) { + DeviceClass *dc = DEVICE_GET_CLASS(dev); + + if (dc->unwire) { + if (!dc->wire) { + error_report("disconnect() without connect() for type '%s'", + object_get_typename(OBJECT(dev))); + abort(); + } + dc->unwire(dev); + } object_property_set_bool(OBJECT(dev), "realized", false, &error_abort); } @@ -601,8 +611,17 @@ static void device_set_realized(Object *obj, bool value, Error **errp) dev->pending_deleted_event = true; DEVICE_LISTENER_CALL(unrealize, Reverse, dev); } - assert(local_err == NULL); + + if (dc->wire) { + if (!dc->unwire) { + warn_report_once("wire() without unwire() for type '%s'", + object_get_typename(OBJECT(dev))); + } + dc->wire(dev); + } + + /* At this point the device is "guest visible". */ return; child_realize_fail: From patchwork Fri Feb 9 12:32:20 2024 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: 771320 Delivered-To: patch@linaro.org Received: by 2002:adf:9dca:0:b0:33b:4db1:f5b3 with SMTP id q10csp824314wre; Fri, 9 Feb 2024 04:34:36 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCXUzY4TGz2cay53ucnu978hd8k4sthQcVyj9tA1CmKZnDGcIBVcngN2fwY/U/cdfy9BU9YfcZlKwcj3s0TWXppo X-Google-Smtp-Source: AGHT+IGQRrkuwMUPzMpLLL6oPal0rM/JmfZ4reLeeNLT9gNoMxqI5ibapFrU23lSYQsGbRLToXzY X-Received: by 2002:a0c:dd8c:0:b0:681:35b:ff6f with SMTP id v12-20020a0cdd8c000000b00681035bff6fmr922790qvk.29.1707482076018; Fri, 09 Feb 2024 04:34:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1707482075; cv=none; d=google.com; s=arc-20160816; b=EVIYOTwfHeZxJ61cHnt0nWjVvWP9cUsdrjbweujNsTrEaquUhO9TL9SOc5nFfo1h// 0743875ibkmZSVFBqs7UN3k7nPihLZ7R2fFFHVpDEvSB7Fl6nu72uJTCPRYCyhveAt1Z ed80n/JvcdVxnvz5TOS3KwznztKcz0ZqHRr7lkhx1gC8/gN80SJdwBGSjhY+qEaGyvLi DcDmGe+mpfchwZ2AcHO6H3A7gvOhOZoYNvnbAnDh5fyqtv6/RNAwwHzrqlihKIRL6lDx 1bZ9P3rrsrKsfjqE49Ui3tW+ryOJwvUYz+H2K0Gxr0v9jEYQj+qHojDHatf1LzdVUPLh YDww== 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=69j+RQz2yVIlaeXDXqDQZrASP/0yIinBEEqkOClQG7M=; fh=HMU2gY9Yf8KLGDa0PIwTYNHAWT4UwBX+N8aIyfVOn8E=; b=j3h/YgWcGm9jrZ0YT/rVdNNnS7x3mmgvIwJNo3+uwWOxU85j2wL9d5yKjEYTz8mmBs 6pMPORNtW8XXjeGzjLgN4aV23DoehseFCDoaAI7BHXlz8jwqt2dbwKATBWfP5eIS27um F5C3i3lrJgKRHLmKWKh2v9oKBmoaa+OkKkKtcmgrsFRnV4Tk/WeMa8+nMMh4emooY5s+ VwHOznXPupLFr72Hx7i2og7Haux2aFNgaaivhRSOMIEayZFSXKWx24Hb08HNVLNKx7DO CA4Kd56tdYBBkmQEQ2aDmVwDCynLDKjiZYNN16NfATWRU/6wjz+wkeR5oHwkpN+Shls7 K/aw==; darn=linaro.org ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=P4wzSV+a; 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 X-Forwarded-Encrypted: i=1; AJvYcCVt+988mWJ2g+gdS5XCg2l4G+gUSy17xi5o7FvN9sDShFOV4z5c5R+LTcmAz5WuJkMNL5OaqyagMCmWaOfvnB9w Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id gv1-20020a056214262100b0068c805ee350si1882427qvb.190.2024.02.09.04.34.35 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 09 Feb 2024 04:34:35 -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=P4wzSV+a; 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 1rYQ3u-0007vj-Rl; Fri, 09 Feb 2024 07:32:58 -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 1rYQ3h-0007mx-AO for qemu-devel@nongnu.org; Fri, 09 Feb 2024 07:32:46 -0500 Received: from mail-wr1-x434.google.com ([2a00:1450:4864:20::434]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rYQ3f-0001qe-9N for qemu-devel@nongnu.org; Fri, 09 Feb 2024 07:32:45 -0500 Received: by mail-wr1-x434.google.com with SMTP id ffacd0b85a97d-33b6489b593so368792f8f.3 for ; Fri, 09 Feb 2024 04:32:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1707481961; x=1708086761; 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=69j+RQz2yVIlaeXDXqDQZrASP/0yIinBEEqkOClQG7M=; b=P4wzSV+a6sgmuzRwokbfT6ciRLCDEo8QN2qpDkMLMpLZBhDi/0cmCuKNyGLa/atwVM ksTwrrLX5O7b/dzPsQ/eOmZBb/UQDSB1TE5RBBTkrpvZAm3FVU0fp/5OX98n8vasSKnw i96RVyNWmubCz3HRaQHw0+VadVgae994EY02SqTJHZ5IYxqF6a/1VS+Xx1fUB4+n+8n8 thksn+dGt72By4gDIZDl67Qyq3mAUSk8Gi2VbkSXwAecjzZRz/lr4YBXGCCLbANY/UCH W56K6r1ZJFadbuRfMM6mC6znZ/cFrSC8PAof4XUBoldZWU2S1G7SRrk7jPssL4FU2Yar M2fQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707481961; x=1708086761; 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=69j+RQz2yVIlaeXDXqDQZrASP/0yIinBEEqkOClQG7M=; b=GdxaAoXTuEXwF1PjLcAPvBLeRSYB7+G5zf+wl0Jdeg89xcEIImSnJqphZoP36Uzl9c FBsnb+Pp1Jew/EXWIygQtrOGKVXvI+BwtvaUbNuDmRpUfI16ioSnusNH2eTV1hE3Wgee vI5tIdBFwzFDJ+qCi75xGmo3ruNoY9REV03WFTP+CP1fTlzIVcocf2HcNYCgabQh9ctM 7P369oUjrLXK/Q9XC2gweYbJLDWe+ey71mtAqQ0gIeAJX8XBf+nZrRMabGPo93d6GnYH zJvN2D1HfhoeH8f9HJrsvUzuIjXh8Q+H31jd7Kj7Naykv3r4vzRjfIkiRzrhkIWOegOT PVvw== X-Gm-Message-State: AOJu0YxhBuRH3uDVHecnF/5/EXHViA95gNNt15TNCL1orV1KhVcjK49d 9vRjgPpV35aYKmiqFGrdiCMS0olCjai7vhMvFZRKnBxHUR1R/y1/hhYGyLcDymUwbIItCXhPogk 0 X-Received: by 2002:adf:fec6:0:b0:33b:2fba:1eab with SMTP id q6-20020adffec6000000b0033b2fba1eabmr1153828wrs.30.1707481961213; Fri, 09 Feb 2024 04:32:41 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCWKpUTsflMN6iBfwhdcCPB7CZWVS28YAPQUX5KuMdLc6vQUFRlw1ZEbpa9mXhNLkTOgl+4BDQfy04mgkEVY5W6yfOlUiFVDo6iAZ26OCVWeGW7bGfdBLk5FiRL5d0920LEYFWgK8WBwBrebO1U5bP8pmbvxEyYUH9udoA1f/84+D4AvwzO6Pae760UO4YCGD8R/46vh2kCQz2jek0u1AvfShDr1eFTod5RBIFt35Hxq537j85RrunFND8Hmput79yJLeM2ykzNQZEYJnL0hpYNk+D30bQM3HQCvmMh7S3Jn689lKLJ56MqBCf672h+nMmPAS07URRIXpCc= Received: from m1x-phil.lan ([176.187.218.105]) by smtp.gmail.com with ESMTPSA id dw8-20020a0560000dc800b0033b0d2ba3a1sm1703790wrb.63.2024.02.09.04.32.39 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 09 Feb 2024 04:32:40 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Paolo Bonzini , BALATON Zoltan , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Laurent Vivier , Jiaxun Yang , qemu-block@nongnu.org, John Snow , qemu-ppc@nongnu.org, Eduardo Habkost , "Michael S. Tsirkin" Subject: [RFC PATCH 2/7] hw/input/pckbd: Connect i8042 GPIOs once mouse/keyboard are realized Date: Fri, 9 Feb 2024 13:32:20 +0100 Message-ID: <20240209123226.32576-3-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240209123226.32576-1-philmd@linaro.org> References: <20240209123226.32576-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::434; envelope-from=philmd@linaro.org; helo=mail-wr1-x434.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, T_SCC_BODY_TEXT_LINE=-0.01 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 While a device is not realized, we shouldn't call: - qdev_get_gpio_in_named() - qdev_connect_gpio_out() - isa_connect_gpio_out() Signed-off-by: Philippe Mathieu-Daudé --- Probably better would be to declare the ISA wiring handlers in ISADeviceClass, but such class doesn't exist yet. --- hw/input/pckbd.c | 38 +++++++++++++++++++++++++++----------- 1 file changed, 27 insertions(+), 11 deletions(-) diff --git a/hw/input/pckbd.c b/hw/input/pckbd.c index 90a4d9eb40..76175f6fe8 100644 --- a/hw/input/pckbd.c +++ b/hw/input/pckbd.c @@ -707,6 +707,12 @@ static void i8042_mmio_realize(DeviceState *dev, Error **errp) if (!sysbus_realize(SYS_BUS_DEVICE(&ks->ps2mouse), errp)) { return; } +} + +static void i8042_mmio_wire(DeviceState *dev) +{ + MMIOKBDState *s = I8042_MMIO(dev); + KBDState *ks = &s->kbd; qdev_connect_gpio_out(DEVICE(&ks->ps2kbd), PS2_DEVICE_IRQ, qdev_get_gpio_in_named(dev, "ps2-kbd-input-irq", @@ -756,6 +762,7 @@ static void i8042_mmio_class_init(ObjectClass *klass, void *data) DeviceClass *dc = DEVICE_CLASS(klass); dc->realize = i8042_mmio_realize; + dc->wire = i8042_mmio_wire; dc->reset = i8042_mmio_reset; dc->vmsd = &vmstate_kbd_mmio; device_class_set_props(dc, i8042_mmio_properties); @@ -878,9 +885,6 @@ static void i8042_realizefn(DeviceState *dev, Error **errp) return; } - isa_connect_gpio_out(isadev, I8042_KBD_IRQ, isa_s->kbd_irq); - isa_connect_gpio_out(isadev, I8042_MOUSE_IRQ, isa_s->mouse_irq); - isa_register_ioport(isadev, isa_s->io + 0, 0x60); isa_register_ioport(isadev, isa_s->io + 1, 0x64); @@ -888,18 +892,10 @@ static void i8042_realizefn(DeviceState *dev, Error **errp) return; } - qdev_connect_gpio_out(DEVICE(&s->ps2kbd), PS2_DEVICE_IRQ, - qdev_get_gpio_in_named(dev, "ps2-kbd-input-irq", - 0)); - if (!sysbus_realize(SYS_BUS_DEVICE(&s->ps2mouse), errp)) { return; } - qdev_connect_gpio_out(DEVICE(&s->ps2mouse), PS2_DEVICE_IRQ, - qdev_get_gpio_in_named(dev, "ps2-mouse-input-irq", - 0)); - if (isa_s->kbd_throttle && !isa_s->kbd.extended_state) { warn_report(TYPE_I8042 ": can't enable kbd-throttle without" " extended-state, disabling kbd-throttle"); @@ -909,6 +905,25 @@ static void i8042_realizefn(DeviceState *dev, Error **errp) } } +static void i8042_wire(DeviceState *dev) +{ + ISADevice *isadev = ISA_DEVICE(dev); + ISAKBDState *i8042 = I8042(dev); + KBDState *s = &i8042->kbd; + + isa_connect_gpio_out(isadev, I8042_KBD_IRQ, i8042->kbd_irq); + isa_connect_gpio_out(isadev, I8042_MOUSE_IRQ, i8042->mouse_irq); + + + qdev_connect_gpio_out(DEVICE(&s->ps2kbd), PS2_DEVICE_IRQ, + qdev_get_gpio_in_named(dev, "ps2-kbd-input-irq", + 0)); + + qdev_connect_gpio_out(DEVICE(&s->ps2mouse), PS2_DEVICE_IRQ, + qdev_get_gpio_in_named(dev, "ps2-mouse-input-irq", + 0)); +} + static void i8042_build_aml(AcpiDevAmlIf *adev, Aml *scope) { ISAKBDState *isa_s = I8042(adev); @@ -954,6 +969,7 @@ static void i8042_class_initfn(ObjectClass *klass, void *data) device_class_set_props(dc, i8042_properties); dc->reset = i8042_reset; dc->realize = i8042_realizefn; + dc->wire = i8042_wire; dc->vmsd = &vmstate_kbd_isa; adevc->build_dev_aml = i8042_build_aml; set_bit(DEVICE_CATEGORY_INPUT, dc->categories); From patchwork Fri Feb 9 12:32:21 2024 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: 771315 Delivered-To: patch@linaro.org Received: by 2002:adf:9dca:0:b0:33b:4db1:f5b3 with SMTP id q10csp823856wre; Fri, 9 Feb 2024 04:33:40 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCXLkNftu9krDRRgqzlDyc2WuLozgVWG7XNbytDW5rEoLZNXBnlHaWlKuGAOcoaCOIjR3vmDpoafRVq7DOJTZ7Cr X-Google-Smtp-Source: AGHT+IFHKO1LDv+fLj6kOts1AqaI2r91dDaaTQ9EtlzHvZYsFV/qghchIUcz8ifUJ/s1L4wJibOg X-Received: by 2002:a05:6808:bd5:b0:3be:b5f6:f354 with SMTP id o21-20020a0568080bd500b003beb5f6f354mr1778618oik.13.1707482020011; Fri, 09 Feb 2024 04:33:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1707482019; cv=none; d=google.com; s=arc-20160816; b=fxs3ezOLr94L5HkwbXegltsz3O7PDANb6PtGSnMdQyXWLbiW0mDChQGQyDmIv1fyG+ cpKClXo4/jH7/Rs6D4OQNWa62RYJYzJtZcVc7tATmPRMeiOhrHPC/luBRpxRaIldBqGp X3TNsKACXXl9uwKjSxYWp0WDRiiAtdjklWW9CIi90TuJCY0T4jCynOmdOUnabIn+W/vB pl7rA2aNODHjv6jwXt8JGoX5oA1e9H9tq8BrGSXt9j82ikfXFHtSI1d6esuqy8DZgC39 hPOzUKh5WRGqUedlzh/5mxZYHMNk2QdbaoQBfU1O5FVXZnXjyVsxsDQQUlQBI4QT7qNy s2mg== 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=DoeBrV+EEZMMsB2lJU5mfdts4xYAcXXfL7ZG+bYHvck=; fh=3YGy94ESPi9VmDnetGfqupKplcGyICyxp1utnQtzwJ8=; b=lSim+9i5zsL2LO8BgMkAqF77pC100jh6KAruzJ00zuuimaOBpSgi9UVDlc/jmjvv1Z eFKtKA9LZEyA204+i57d8nWhBYKhYYBhu4D7XBOFykDRNFneynFIVAIso5IrWtChXo5l kNz+aG27qmUn5WPngNSD5OUVVC3+mxHe7JNuaCF3AaF6rZ3/Xl/eh9q8EFIs1Mtj1MtT Ua+s0DdSSEHOTDvbY344mvo/+zbvBLAYZJrU9OQveRiLiRHDT0pmU2OVl9HWPtlTB5BX sRXFcgv1I7B3pILDSUraZ8F2Geyo9vEWNOKplCj6wPQUeVvQ3d0Frb0fWN3W0j5r7ZNr bRBw==; darn=linaro.org ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=mwVIjU74; 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 X-Forwarded-Encrypted: i=1; AJvYcCVmQX5azAUK42GiuF/8SzFwimj+FfRDXA4d1DQSk0v4XFo53CQ8KqP7sVUGzrgrth7EkaeXjMlyV+59/FcoxhbT Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id m11-20020a05620a24cb00b00783ab5f86adsi2049610qkn.265.2024.02.09.04.33.39 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 09 Feb 2024 04:33:39 -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=mwVIjU74; 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 1rYQ3w-0007zN-Lk; Fri, 09 Feb 2024 07:33:00 -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 1rYQ3m-0007rx-Jn for qemu-devel@nongnu.org; Fri, 09 Feb 2024 07:32:58 -0500 Received: from mail-wr1-x432.google.com ([2a00:1450:4864:20::432]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rYQ3k-0001sz-Gm for qemu-devel@nongnu.org; Fri, 09 Feb 2024 07:32:50 -0500 Received: by mail-wr1-x432.google.com with SMTP id ffacd0b85a97d-33b401fd72bso495714f8f.3 for ; Fri, 09 Feb 2024 04:32:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1707481967; x=1708086767; 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=DoeBrV+EEZMMsB2lJU5mfdts4xYAcXXfL7ZG+bYHvck=; b=mwVIjU74L8EpSrWA9GC+FnmdAzyXxTT+Lmx3qbxkNBpXeQNry7PU83htKlu1nn7i9H 1r7eYgQtRMlPOJLy8llHaVrF6xz/76bzXwk4XNw4OFmcnP9/KT13MKipzjidpP8N69RQ OXTQmLmy2hcMeuDpCw9U7t3TjJYDNmXVFLYskXvsV4OfvjhGUR3vgFiWmWnacJbMBJ2/ fO+ZlLNoqGThDsntD1pI5UnH1jB6GDhBW9vWXjmU9aHoAkRgpAC7Kgw6gm4eRhqBJ1KU 6S9Hcm8GHebNSjsVzpmCMsw8jMijph3XdtGHkRJ4TBlIHeJQvwSVoEn4xJQXEC2PYMSq o/Pg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707481967; x=1708086767; 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=DoeBrV+EEZMMsB2lJU5mfdts4xYAcXXfL7ZG+bYHvck=; b=gQE94tbzNMowQ6OT1nhldu8pprgMFZmnmfVxT3Jv9BAHaOngRZov17L2OlH4iIqsms YdCSRTIINiFPYrF211VKO3dQ+QIH82/8ce0AVGo0wwgyb73PryQ7xo1CjealweQPkCNo 47GkQEt5tydtQQKa+M87PqC80nzhG0BLTZU7ISO1kl9fxgTEafhdLibFRpqeZfHpEd52 XejBtMSsMmzVoQ9h4sJ5X0jadQaN7URMZz8Whc8CmwZP6x1/pUJsjU6KRLxS/3mpBfR+ wPChhNn/wEg/rxnblDzJhWTVysLVKpa01yXsMj3FW3TA4W83tWRZV63uSohCD8tNiKyI 4uzQ== X-Gm-Message-State: AOJu0YxAfyVcSnL3iHe/J/wJcl2wlW+y6x7pubmfbwz/+VAvLUTct93x 1SJp65f7QLFVZakQkVhVZxy/vd/5R/+mzHi8LDfo4z+qOpkOMx77FJr0lJkPkj8F8B0yUu5w28h Y X-Received: by 2002:adf:a442:0:b0:33b:61ed:b899 with SMTP id e2-20020adfa442000000b0033b61edb899mr892320wra.56.1707481966785; Fri, 09 Feb 2024 04:32:46 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCXzfgXHMN47aQ/KCNhBxpV4Z3YyKPRl2YquyCugn1MlusU6NZEj5P66bCUgW3gpussgOGP+xANi+EeuF+NG8em8JEZKUh2yttWi4MnxBqiDLxQXopMjKPdXDU+90V/3v1NeIbXhr7cdmnh+hWKmOxADeH7HtF5hNd7e76gOgYou3cfEjEDdRk0c+QcWPz3/262htCsWFmn+KBJU1JLprRzmorl+uwiCJUo2oI/k3WcCdoAjeAQItdLyJ/52aEZiEzRw9bBmS3lOoAqbutHOB55EsKbgx5dz8wxZghUYOmrRhr5bCp5lQMfS68bjY1wAAGbWm/bDS0GNpFc= Received: from m1x-phil.lan ([176.187.218.105]) by smtp.gmail.com with ESMTPSA id d23-20020adfa357000000b0033ae50e2c6asm1712299wrb.83.2024.02.09.04.32.45 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 09 Feb 2024 04:32:46 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Paolo Bonzini , BALATON Zoltan , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Laurent Vivier , Jiaxun Yang , qemu-block@nongnu.org, John Snow , qemu-ppc@nongnu.org, Eduardo Habkost , "Michael S. Tsirkin" Subject: [RFC PATCH 3/7] hw/ide/cmd646: Configure IDE bus IRQs after realization Date: Fri, 9 Feb 2024 13:32:21 +0100 Message-ID: <20240209123226.32576-4-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240209123226.32576-1-philmd@linaro.org> References: <20240209123226.32576-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::432; envelope-from=philmd@linaro.org; helo=mail-wr1-x432.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, T_SCC_BODY_TEXT_LINE=-0.01 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 We shouldn't call qdev_get_gpio_in() on unrealized devices. Signed-off-by: Philippe Mathieu-Daudé --- Ideally we should rework the current IDE bus model to really use QOM and not globals. Left for later. --- hw/ide/cmd646.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/hw/ide/cmd646.c b/hw/ide/cmd646.c index c0bcfa4414..92e1e7a4fc 100644 --- a/hw/ide/cmd646.c +++ b/hw/ide/cmd646.c @@ -291,9 +291,18 @@ static void pci_cmd646_ide_realize(PCIDevice *dev, Error **errp) /* TODO: RST# value should be 0 */ pci_conf[PCI_INTERRUPT_PIN] = 0x01; // interrupt on pin 1 - qdev_init_gpio_in(ds, cmd646_set_irq, 2); for (i = 0; i < 2; i++) { ide_bus_init(&d->bus[i], sizeof(d->bus[i]), ds, i, 2); + } +} + +static void pci_cmd646_ide_wire(DeviceState *dev) +{ + PCIIDEState *d = PCI_IDE(dev); + DeviceState *ds = DEVICE(dev); + + qdev_init_gpio_in(ds, cmd646_set_irq, 2); + for (unsigned i = 0; i < 2; i++) { ide_bus_init_output_irq(&d->bus[i], qdev_get_gpio_in(ds, i)); bmdma_init(&d->bus[i], &d->bmdma[i], d); @@ -324,6 +333,7 @@ static void cmd646_ide_class_init(ObjectClass *klass, void *data) dc->reset = cmd646_reset; dc->vmsd = &vmstate_ide_pci; + dc->wire = pci_cmd646_ide_wire; k->realize = pci_cmd646_ide_realize; k->exit = pci_cmd646_ide_exitfn; k->vendor_id = PCI_VENDOR_ID_CMD; From patchwork Fri Feb 9 12:32:22 2024 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: 771319 Delivered-To: patch@linaro.org Received: by 2002:adf:9dca:0:b0:33b:4db1:f5b3 with SMTP id q10csp824224wre; Fri, 9 Feb 2024 04:34:25 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCW1v6SPwUmtDD9YWRTVqMgj4GyOwC4K0lN+1CF9Tckj0e+buDv0pohmfKXLKRxF6dm93SmzMLtTV1wjwcBgxPJn X-Google-Smtp-Source: AGHT+IGESULh6yucyD6Z8CXJ+iLbGLLDEpcbqW2msTxKILXUzpy1GRvWui2XZGmsHrrLLvKhHEVq X-Received: by 2002:a05:6808:144c:b0:3bf:dc22:be18 with SMTP id x12-20020a056808144c00b003bfdc22be18mr1735285oiv.40.1707482065202; Fri, 09 Feb 2024 04:34:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1707482065; cv=none; d=google.com; s=arc-20160816; b=QjFwp0CGq9xChXvTW0ODpNJ6glbQ66mfrNQsA/KgwFyCSwUBbq4arQCaKxuYMIYJup pjafmK1XGMvoGh9l1i1lik/ZD9/PqpD917G98qOAnKaltfksbXgXwAXMc0DoOTaC+mts fC6Pjt58xvexdHF3tfjvWJ0WfaAZ2IK1bI3eOU6GlTKO+6WqcEWrmPol1sGrz6ctFV3s zsMmB4j8auXZM5QFESxbRQLofDE6TB1u4rokXnrERmuQ+kE2vIKLDs3v+i324WBPZm0f zs+jbAUDknX22QlYfBqIAHM7XZLltOV1OLi98yFJDO+gQ6qIXx7zk/idmwqAeW8aE2fP Xd1A== 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=iars+m6ELdOmlbrG1ApaqWkxoTlLYosuewWqu/opFsQ=; fh=8UsGEZS72RS1ssRCwxNgfEiOmHS3CEWocF65X+wajb8=; b=vzPMqK1rZtuAAhKTKBihDF5W+qyBA4ikN9535CM8hPjy96DeG+b2L788i02yivcJo1 bomoopPqVf0q71QyBHrfuzx5+4IRXgMd1emwzTDXL5WLgcIgEB4Vuv97v8OpYPe5oKUv TL/0Glb1An/E0JXdQMRME0CUT4roFQfRJH142voETeKv3kH36PlOVAWo8zm9WI+1vClG 7HW0dawqrPQsbbNE4j1av2apcjflL8tznEknm8/t2oH1/pLjZC0zzuemK/Bkuk1l26t7 VSrvn6dpbHte3QxWKNohWJCVgBTe72s2Im1pX3fcslv8XKlJJD1sumhYOKYHl4o6QamE 9Pjw==; darn=linaro.org ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=inoq6me7; 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 X-Forwarded-Encrypted: i=1; AJvYcCWAWWFuGsxbGHWWyf/icUOFQNfGZM6U7Jywra2LK6Iim20Rmxns1MUZQaxfhb+3lHsFQCE4XesLQbNmMzpIq5ee Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id v6-20020a05620a122600b00785999544e9si1915302qkj.290.2024.02.09.04.34.25 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 09 Feb 2024 04:34:25 -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=inoq6me7; 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 1rYQ40-00081A-A3; Fri, 09 Feb 2024 07:33:04 -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 1rYQ3v-0007xT-3q for qemu-devel@nongnu.org; Fri, 09 Feb 2024 07:32:59 -0500 Received: from mail-wm1-x332.google.com ([2a00:1450:4864:20::332]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rYQ3s-0001uM-PW for qemu-devel@nongnu.org; Fri, 09 Feb 2024 07:32:58 -0500 Received: by mail-wm1-x332.google.com with SMTP id 5b1f17b1804b1-4105f6fbdd9so6211055e9.1 for ; Fri, 09 Feb 2024 04:32:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1707481973; x=1708086773; 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=iars+m6ELdOmlbrG1ApaqWkxoTlLYosuewWqu/opFsQ=; b=inoq6me77vw5qAZRQtT5UskNoUiUJO6C4DKkv69ve9TubZm1XAiyBtHnty1sB2utqB 8+f4v+J/M3fAy9GV+QqSkscNO3PVgUULkFmU+B6cYOTFg7+tSTM+8mST3Ltn3cM9SZQv ZCltmOvZflBKFKiCVkz1yJoHcL8acCMXoLglOiyAgIY1Gm2p1mLymprXo88dyaSXOTgW hF2kT0dHz06YdszZA1/zvYZDTkcBZ9jPmGrSB8IE27NopdbmTe2maOratqQtiagadXa+ +Z/cV/mf3apej1sznwNlJrcanwOx5WkskNcyGdvnHmsvBjsKBlJzRAbf4l2T6ge33JxG Kj8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707481973; x=1708086773; 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=iars+m6ELdOmlbrG1ApaqWkxoTlLYosuewWqu/opFsQ=; b=m8RDynQiBxhz9AoP7k6oerkrb/r/BKXba7BOzaW8o/88yKXbVTSWWFlznmpA3IifvU ghIiDL2Z5zbILvw1zp41MDVdbbkcSQpc5ajKjd53Y5UWYUMFXiW91Hmt2FFZ6BoGV1En TsfgLJMehND1Ikd2wO0bxGIPEjMnpj6Pe1W7NS+Bi6xAwp4Vf42u1eka9SszT6I4tMvC BEJTsUq0Pge25Fnqmc9C/J4l4R3WEBnRIE0OQmoCs95h4h6/LhTECqpU8gTGJDIFwt+C aJj2OU8/hV2dodFvLonwbMYJh7wyK19tK9ILMlhPUHgwTF65EVQjUwj9rQ55ahSRgQgm V62g== X-Gm-Message-State: AOJu0Ywo/CQzcKTqlQjPiJcFSyraq9Gyt5n65eZscmN4n4aUblQu3z+p grRyfu/uUuF9mB8874MQqLXQKbOnmwcY6qghNxsPyl8GA1odp88Zx6W+1NnoEjxJ+KU6/S0CFod S X-Received: by 2002:a05:600c:3545:b0:410:5897:1d85 with SMTP id i5-20020a05600c354500b0041058971d85mr1062496wmq.14.1707481972821; Fri, 09 Feb 2024 04:32:52 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCUkodP0uPw5GgjrxDbnO38ZL0XQOV/5NjIwLOhSQUdCDFrIpY9pKjTPdXb42aWbI0QlLCzr5JWcrc5/M0vfkI62DUAGJThJVo3/kdz0QBkevIpi/1asmsD6DHK3pebHsTO3U1zt6X/0K3DfoYCUcPBbmmFCM8Wmruni64mw0VKzZdiKhslJhxfsCLW49VJPYanSMK7l92ybrSoHDh5rEyKHV7sTJaW5dA/I7TiRLu3bc2MDsuGaVucFMg0x2CKZOjSEX4A9PEQhE06TTAVNzpC1ukcM2LPswe3Y7/G2UMTXAYuGL9m3KtHmEOo7vJqeJX63VEYuecYzJYM= Received: from m1x-phil.lan ([176.187.218.105]) by smtp.gmail.com with ESMTPSA id bw26-20020a0560001f9a00b0033b5b6a186dsm1717121wrb.69.2024.02.09.04.32.51 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 09 Feb 2024 04:32:52 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Paolo Bonzini , BALATON Zoltan , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Laurent Vivier , Jiaxun Yang , qemu-block@nongnu.org, John Snow , qemu-ppc@nongnu.org, Eduardo Habkost , "Michael S. Tsirkin" Subject: [RFC PATCH 4/7] hw/ide/sii3112: Configure IDE bus IRQs after realization Date: Fri, 9 Feb 2024 13:32:22 +0100 Message-ID: <20240209123226.32576-5-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240209123226.32576-1-philmd@linaro.org> References: <20240209123226.32576-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::332; envelope-from=philmd@linaro.org; helo=mail-wm1-x332.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, T_SCC_BODY_TEXT_LINE=-0.01 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 We shouldn't call qdev_get_gpio_in() on unrealized devices. Signed-off-by: Philippe Mathieu-Daudé --- Ideally we should rework the current IDE bus model to really use QOM and not globals. Left for later. --- hw/ide/sii3112.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/hw/ide/sii3112.c b/hw/ide/sii3112.c index 63dc4a0494..8b6e931f27 100644 --- a/hw/ide/sii3112.c +++ b/hw/ide/sii3112.c @@ -282,6 +282,15 @@ static void sii3112_pci_realize(PCIDevice *dev, Error **errp) qdev_init_gpio_in(ds, sii3112_set_irq, 2); for (i = 0; i < 2; i++) { ide_bus_init(&s->bus[i], sizeof(s->bus[i]), ds, i, 1); + } +} + +static void sii3112_pci_wire(DeviceState *dev) +{ + PCIIDEState *s = PCI_IDE(dev); + DeviceState *ds = DEVICE(dev); + + for (unsigned i = 0; i < 2; i++) { ide_bus_init_output_irq(&s->bus[i], qdev_get_gpio_in(ds, i)); bmdma_init(&s->bus[i], &s->bmdma[i], s); @@ -299,6 +308,7 @@ static void sii3112_pci_class_init(ObjectClass *klass, void *data) pd->class_id = PCI_CLASS_STORAGE_RAID; pd->revision = 1; pd->realize = sii3112_pci_realize; + dc->wire = sii3112_pci_wire; dc->reset = sii3112_reset; dc->desc = "SiI3112A SATA controller"; set_bit(DEVICE_CATEGORY_STORAGE, dc->categories); From patchwork Fri Feb 9 12:32:23 2024 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: 771317 Delivered-To: patch@linaro.org Received: by 2002:adf:9dca:0:b0:33b:4db1:f5b3 with SMTP id q10csp824108wre; Fri, 9 Feb 2024 04:34:09 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCU/7qpfmOmbhW5oxzbsa4ApjSqe87Z1aanOkYJMH4F8/BqDEcSFotXiA2vTk0+roanPLLD8P/WM0hqZdu/W9cBt X-Google-Smtp-Source: AGHT+IFAGy5RAmJJyJAJx+6NHN4z6Vwr6BkEw89bm5cYWf993LaOq7/bAu7YpIOWGavhbLQDaqK1 X-Received: by 2002:ac8:110c:0:b0:42c:5c0d:5f79 with SMTP id c12-20020ac8110c000000b0042c5c0d5f79mr851641qtj.36.1707482049673; Fri, 09 Feb 2024 04:34:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1707482049; cv=none; d=google.com; s=arc-20160816; b=bYzJ15j8ouJW4N93I62BYqndPlWP79FtLIxIsdaQazco56S2vA1cIe8hmi26+5ndhy tW6eHqVWmWOkAzXfb3gMQdpPOeDByGEUwpisCx709RrlswbA+ncf3k+LDZ8U9IcOlFW+ Ru+lsiIaC8FHdWyF9lZPC2ysh5msYnBlwce53JNcR6O6wBw0jdm5MgE33bvjaGJpSkE+ JZhMaiCf8IIIOKq89iEAHusSB+fhd30VAHjXOZquVbwEKrIGfGNndwPPtDeq621E6q2u XOO6RUgZrAU+6ZWK2l+C+to3S7Q5Q/yT+7vtncm1O56/65odb/xfNpYlv3WAu9azOJZT CKZQ== 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=663egtvXUtLR9ZdYJglQVLyO0fSnzktyc0JFemad5jI=; fh=kws2JOXARFZGR8d8ikPt3y/UbLEcWKfJpsfEE+D5zaQ=; b=cKFr1loodKLzEA+/x1BNsibCIUAVrqYky8gZeBBbSS8dpg5KnNc0Y+YJourCL1DaAN Vnty2lqLvlmTkDwHCmE452knpMp7t+2QXZrTiyMmfks1ATQkyGNOn0YKrdAlG2ck3/Bx YgSvcrwQM4PD5LngzoX1ZWj+JaKvtWXaoBWLzqq6vdK+LHc5B5I0zsPR+5nzXIzmi0UV NAS93Oc1qju/MqK/9Fd9YqxuxWCQQHkzXyYkUY3v7lOs7gmara5re0TScEnpgRMOFyAv AzYotB+hpY4IXq9ftz7loJLQWjQEr0OvdOedeX9s/x/hRA1HVx2Fk6fnWZpgkMlY1xG1 9pDA==; darn=linaro.org ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=VkZgDstH; 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 X-Forwarded-Encrypted: i=1; AJvYcCUdqEn5crJGyB9UJP8wVtx7hW7kYDgpvnk/zMf1N/0y8i/DV/sZFZaDE1lKZzBtrKAkQppcdHhz/bOfap3wJeEP Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id j13-20020ac85c4d000000b0042c39fbe77esi1798733qtj.53.2024.02.09.04.34.09 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 09 Feb 2024 04:34:09 -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=VkZgDstH; 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 1rYQ43-000826-12; Fri, 09 Feb 2024 07:33:07 -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 1rYQ3z-000814-LF for qemu-devel@nongnu.org; Fri, 09 Feb 2024 07:33:03 -0500 Received: from mail-wm1-x32f.google.com ([2a00:1450:4864:20::32f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rYQ3w-0001vb-Be for qemu-devel@nongnu.org; Fri, 09 Feb 2024 07:33:01 -0500 Received: by mail-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-4102f273c46so8076925e9.2 for ; Fri, 09 Feb 2024 04:32:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1707481978; x=1708086778; 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=663egtvXUtLR9ZdYJglQVLyO0fSnzktyc0JFemad5jI=; b=VkZgDstHkxnn2B8fKe0kSgjsWIpARPYbWkRqnwtBnTW2OvQ6jOkp87I8tY9HDRzzOG mlSrr5ENvYdjWZRY1YBN5HFhEyxtjc3sLLSYJZOAVvNKZampmi5tkPN8TficGfQj6J9b kvoJCqHukPN4Z2BphXB3t0hfhjljopKDKY6XZSYuPZWRhn696AtLrsPTUi3rGPOOPZEG CYoSwXA9953ZPm2AhN+XLw2AeSV9ci08nXqC+POTHk++zh1SbM3O9MQo9E8Q/fD68nAL dSdtS0Ea3qZlvGHhW+UnsMux2hBRpPeNk7HksoV93wq/kKf4N838SKxhQw3SCYErGrOu vE8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707481978; x=1708086778; 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=663egtvXUtLR9ZdYJglQVLyO0fSnzktyc0JFemad5jI=; b=LVxTY1opMbh/N+ZUhSZJWaVqpVMIIUcpesqe+Vz27krqylK4A9aWPPwXZ9PcpAbUyA YksvCcXlZekQIUGxYWKSow2QnzE5J2Ue1HvKjd7yjWQn3r3jkDs3QIAgP50inIdIm4eV 8AADtzc8ERDBt2BFPKHxELtI9DwtoXS31Wo9cAqZuox4nosj7pkQ7YbVtZ5mbqyhwSiT 6IQXbFE/9novL++FEuz1aO4RUZ5UhFUJ5AHoeMOdA4sevCdkeodVwwkbe8adLqjJVxOy fyf9ph2i1tauh3LbLU9UzhbUCR6t+Yg5u+JMy2CiI5+v+onkoCfeW7F0mJ04m4njws1o UWGg== X-Gm-Message-State: AOJu0YwJzmPlnyP2qcbWW9WyaFD5NZsbR+NGFMPwZH16kIAvQ13/ozqU wVHLYrI9ccUiXoaaR/8Am68PrZuz1i0JIPBY1GkdwQgb8LHgT6sKEHEosssxy9alh4Nc123Ej/m x X-Received: by 2002:a05:600c:5490:b0:40e:f9f4:eeb3 with SMTP id iv16-20020a05600c549000b0040ef9f4eeb3mr1183393wmb.39.1707481978515; Fri, 09 Feb 2024 04:32:58 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCWLFp56gSVTcUfodr1Rna4sVxwxJhyecQssHGjTR7aBYKt+0e/yCFmFwPuM26IDC7BcQRETgc63keWsPYTk88MiGyK1fJK0FzqyxsItQdgx3710dmTLiGkhWgjNo7zZqqDXp4iSLR9uf7CKQWqdBIUgBqqiYoa1je5VtPHBzhCC4xUvriq8lbswPuzTOiBrOh7WeLlR1eUrtf8x0xPtmUjyyltScyNs186w7avU8M4ZlRmopOkY6b86CM4brYlCAuPl6NimMbB1dqMIKjVFuJAqSBECDJprDgQvAj5PAQy+tSlm34l/Cdc8V0c8cH/jpQMe3MKApeMR0PE= Received: from m1x-phil.lan ([176.187.218.105]) by smtp.gmail.com with ESMTPSA id n2-20020a05600c294200b0040e3635ca65sm509303wmd.2.2024.02.09.04.32.57 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 09 Feb 2024 04:32:58 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Paolo Bonzini , BALATON Zoltan , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Laurent Vivier , Jiaxun Yang , qemu-block@nongnu.org, John Snow , qemu-ppc@nongnu.org, Eduardo Habkost , "Michael S. Tsirkin" Subject: [RFC PATCH 5/7] hw/ide/via: Configure IDE bus IRQs after realization Date: Fri, 9 Feb 2024 13:32:23 +0100 Message-ID: <20240209123226.32576-6-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240209123226.32576-1-philmd@linaro.org> References: <20240209123226.32576-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32f; envelope-from=philmd@linaro.org; helo=mail-wm1-x32f.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, T_SCC_BODY_TEXT_LINE=-0.01 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 We shouldn't call qdev_get_gpio_in() on unrealized devices. Signed-off-by: Philippe Mathieu-Daudé --- Ideally we should rework the current IDE bus model to really use QOM and not globals. Left for later. --- hw/ide/via.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/hw/ide/via.c b/hw/ide/via.c index 3f3c484253..caf1b69bd4 100644 --- a/hw/ide/via.c +++ b/hw/ide/via.c @@ -226,6 +226,15 @@ static void via_ide_realize(PCIDevice *dev, Error **errp) qdev_init_gpio_in(ds, via_ide_set_irq, ARRAY_SIZE(d->bus)); for (i = 0; i < ARRAY_SIZE(d->bus); i++) { ide_bus_init(&d->bus[i], sizeof(d->bus[i]), ds, i, MAX_IDE_DEVS); + } +} + +static void via_ide_wire(DeviceState *dev) +{ + PCIIDEState *d = PCI_IDE(dev); + DeviceState *ds = DEVICE(dev); + + for (unsigned i = 0; i < ARRAY_SIZE(d->bus); i++) { ide_bus_init_output_irq(&d->bus[i], qdev_get_gpio_in(ds, i)); bmdma_init(&d->bus[i], &d->bmdma[i], d); @@ -249,6 +258,7 @@ static void via_ide_class_init(ObjectClass *klass, void *data) DeviceClass *dc = DEVICE_CLASS(klass); PCIDeviceClass *k = PCI_DEVICE_CLASS(klass); + dc->wire = via_ide_wire; dc->reset = via_ide_reset; dc->vmsd = &vmstate_ide_pci; /* Reason: only works as function of VIA southbridge */ From patchwork Fri Feb 9 12:32:24 2024 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: 771318 Delivered-To: patch@linaro.org Received: by 2002:adf:9dca:0:b0:33b:4db1:f5b3 with SMTP id q10csp824209wre; Fri, 9 Feb 2024 04:34:22 -0800 (PST) X-Google-Smtp-Source: AGHT+IH4swqn3knRZ3LpksHHx3z94tz0BmyDD+4YQE4lXiXmpbn41r7l1Uig8k9ehnyP1VTY/iXR X-Received: by 2002:a05:620a:1002:b0:783:ae14:9ee5 with SMTP id z2-20020a05620a100200b00783ae149ee5mr1620596qkj.5.1707482062469; Fri, 09 Feb 2024 04:34:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1707482062; cv=none; d=google.com; s=arc-20160816; b=nLy5bW4p6kKGsQzpkQpcogDivpcT1lJ8hpGKPBaCycx7tfBg6EMz3iAt3LXHoCJvzN 791ShOQnCATmUzcFhczY6rxxQzaIxd13bcKADcL4QokX6juUj5ky6Qt7z1gKvePStufN 15uJreTrZe70Io0Y+4Wsa4z9seKWfC8iWV0glgKZ2FtWneLaYtw/wdKqgK5mwFceU95o jjSh1Q7Kcb4c5JDYq5rs4+DQtJEomnnGvIYGqnfUfZWyOE4SQYovbxYTlLWRCy3lqamB Cpd8beaZwFHOqj92t453GsdpjW8cPz4sXX2NXmb6eGvffT4t0DvtsdJhm6KIxFcCcIZD 9KQw== 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=EzmCAZqDnP2GixBxkCB+iCs3cLSrfN0BzrHq0xGFwRw=; fh=ZD2Mf1xm54EYZ95jruX+tWZYzdu86dDRrBHojjevNy0=; b=TmFZZRW5jXBpGlR4YSYo+MZP+vSqGgDcCFeZOWs2ArGMSBd5+/00O25B/Ns7i8ZknB zVQRzIVcP1ndlA2X7vPC8hlRPo9vmjbqvQqAZXS2TwQwK//54UJaDekCeuFF0TYJPAY5 OZQygT4HcdQEHl681dop2n57famIg80UbZ/S7jbs+fhu1XbFTpsrbS+0J0loe0R9gdqh WoKG6nL/0+N/923PTVTmwUo5M74a1b9wp7d+fXvSETiM/HNgY3FVfXC6Tc6MB2aHrxOe d9fG60rZAxAjuSRv1hirovWk9jlNGDTvx3RdcV+1PAEas/Opnftpqvljw+gPn7+zBsO7 ySRQ==; darn=linaro.org ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=O3StNvGa; 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 X-Forwarded-Encrypted: i=1; AJvYcCVo1Wubu/AetzAH5fIjqcRJ8cbzZZ5UsmGfpkg0Yl2J0pebtNVPMaLBy+kS+d++dCpJaezIuqWYRFElbV/AKHei Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id e30-20020a05620a209e00b0078591341b5asi1784493qka.556.2024.02.09.04.34.22 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 09 Feb 2024 04:34:22 -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=O3StNvGa; 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 1rYQ4R-0008DV-4r; Fri, 09 Feb 2024 07:33:31 -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 1rYQ45-00086K-CD for qemu-devel@nongnu.org; Fri, 09 Feb 2024 07:33:09 -0500 Received: from mail-wm1-x334.google.com ([2a00:1450:4864:20::334]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rYQ42-0001wg-SP for qemu-devel@nongnu.org; Fri, 09 Feb 2024 07:33:08 -0500 Received: by mail-wm1-x334.google.com with SMTP id 5b1f17b1804b1-4107ed0c536so766095e9.2 for ; Fri, 09 Feb 2024 04:33:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1707481984; x=1708086784; 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=EzmCAZqDnP2GixBxkCB+iCs3cLSrfN0BzrHq0xGFwRw=; b=O3StNvGaCW5pR50S+3/8bugspf+NpvrYo2inwabPaLaGhb1D0NR0E2UfPzXgRTKjQz C2jw26s7AMjngnf9v6Tmm73YiaxJHPZbzP58LFQS6Fut6ZqFn+yL8ie50h8Mywd2PN90 FXPE5wCgPO7QUaSyNzE/Lg+ug4Mw+V+NnlJZCNwxDO9jmwJkwGrlrACgau0Vb7Bv8yn1 2wO+cR0lIQJeoSriyfJj/HedoqdMBoR+lxtxppnjjsyKrbPEsjPtE9I8Ogyf1KJnVw3T NkdviWAf2qDHpTqzt5hy72fTnqJKuz4OSqxWvC8X1CrfRMIWyw7db9oBxzUD4WSIMZ3W D6xA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707481984; x=1708086784; 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=EzmCAZqDnP2GixBxkCB+iCs3cLSrfN0BzrHq0xGFwRw=; b=HAmRrk+axQx65guHkqtV3RkLl8hVmfRFnZlMmX44R1duoNX6Ts8Gtdgis6uyKEugF0 3cMc/fiaI3x97I65KRnzxPxjlRVp7hqPhk1e8ua0E0MFeiNjqjB2vM+VgQ1YySj09Qsm eUnYu3B/pBgdAhK0v9bp0vdnmlpJprhNG4SlRfnhhXgcLrqILJ8ZM/fwzvNBEomAG4oJ rXG6IQ1oYBeXuinJHkLekno3fxljKbHgl96V5e+AdW+qbpnUtc4Yy/FuKd/ifb13xqzX toU7+YG7EH1Bbw3oMw7PLcUDl/uGAGfD/bo2ZFSsfwKriQsmk5/76avb6giu8O/doJo1 JOaA== X-Gm-Message-State: AOJu0YwdC3IcOUE32uerljMpz281NPrBN8kNoi+yR/e76F/nwd/1/UhT R+hK8lZvgBDrK5pXeA6vWE4F0wo8ky0d65LxY414JsxKx840sG4egSUbOfRMv/42n+Z4yFNrzBM Z X-Received: by 2002:a05:600c:35cc:b0:40f:dc50:aea5 with SMTP id r12-20020a05600c35cc00b0040fdc50aea5mr1230765wmq.22.1707481984432; Fri, 09 Feb 2024 04:33:04 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCWXEEO6MR0jNSBaQ5p3sBdVfhNDOQv+N8rvHqTksw8HLNFUba8y0enrZEmMbRvtARpx8UGiGpZ9GoGHaQSXrLcMd78ZhvjzYc/2CmKvvVspbTDqsZEEiq+A8Xv6/Fi2PGsILNbSfLGVlU0KZzW3h/9SgoQ6X4h+W/9/rHyo8ix8162J5gbvi+Gj+xO7c8rCiIjvS7yH0BOOu50owsAcS83l0F2cO91lIt5B0wONiwUZyd8ZhZEL4kPDJZrrzkhoqhr1S1BpF2e5xmjUWAtm7p30SS4GZ6ZMkgZlzC/akWb53O6Wy1R85E8wi03gXRa6eEiqm49eRzWSPZY= Received: from m1x-phil.lan ([176.187.218.105]) by smtp.gmail.com with ESMTPSA id jr6-20020a05600c560600b0041079d336c7sm484051wmb.39.2024.02.09.04.33.02 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 09 Feb 2024 04:33:04 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Paolo Bonzini , BALATON Zoltan , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Laurent Vivier , Jiaxun Yang , qemu-block@nongnu.org, John Snow , qemu-ppc@nongnu.org, Eduardo Habkost , "Michael S. Tsirkin" Subject: [RFC PATCH 6/7] hw/intc/mips_gic: Initialize IRQ array once device is realized Date: Fri, 9 Feb 2024 13:32:24 +0100 Message-ID: <20240209123226.32576-7-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240209123226.32576-1-philmd@linaro.org> References: <20240209123226.32576-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::334; envelope-from=philmd@linaro.org; helo=mail-wm1-x334.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, T_SCC_BODY_TEXT_LINE=-0.01 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 We shouldn't call qdev_get_gpio_in() on unrealized devices. Signed-off-by: Philippe Mathieu-Daudé --- hw/intc/mips_gic.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/hw/intc/mips_gic.c b/hw/intc/mips_gic.c index 77ba7348a3..05c8b8f4c4 100644 --- a/hw/intc/mips_gic.c +++ b/hw/intc/mips_gic.c @@ -419,7 +419,6 @@ static void mips_gic_realize(DeviceState *dev, Error **errp) return; } s->vps = g_new(MIPSGICVPState, s->num_vps); - s->irq_state = g_new(MIPSGICIRQState, s->num_irq); /* Register the env for all VPs with the GIC */ for (i = 0; i < s->num_vps; i++) { if (cs != NULL) { @@ -433,7 +432,14 @@ static void mips_gic_realize(DeviceState *dev, Error **errp) } s->gic_timer = mips_gictimer_init(s, s->num_vps, gic_timer_expire_cb); qdev_init_gpio_in(dev, gic_set_irq, s->num_irq); - for (i = 0; i < s->num_irq; i++) { +} + +static void mips_gic_wire(DeviceState *dev) +{ + MIPSGICState *s = MIPS_GIC(dev); + + s->irq_state = g_new(MIPSGICIRQState, s->num_irq); + for (unsigned i = 0; i < s->num_irq; i++) { s->irq_state[i].irq = qdev_get_gpio_in(dev, i); } } @@ -450,6 +456,7 @@ static void mips_gic_class_init(ObjectClass *klass, void *data) device_class_set_props(dc, mips_gic_properties); dc->realize = mips_gic_realize; + dc->wire = mips_gic_wire; } static const TypeInfo mips_gic_info = { From patchwork Fri Feb 9 12:32:25 2024 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: 771321 Delivered-To: patch@linaro.org Received: by 2002:adf:9dca:0:b0:33b:4db1:f5b3 with SMTP id q10csp824351wre; Fri, 9 Feb 2024 04:34:40 -0800 (PST) X-Google-Smtp-Source: AGHT+IFWgkxIEVVKXfkBcYiYmI2G3i46slGZovJuxZaQnYGBGSDYGANERFfu/w86AqsBUdxhDbf8 X-Received: by 2002:a05:6830:44ac:b0:6dd:dbda:539e with SMTP id r44-20020a05683044ac00b006dddbda539emr1711415otv.16.1707482079815; Fri, 09 Feb 2024 04:34:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1707482079; cv=none; d=google.com; s=arc-20160816; b=shA3NEcQgbpm2Ym2j5MIdsHxaHVgdRt2P3MtRo1r5QCd6Cp38GfGXsI7hbY6TWyNUm H1aJHxjtJr3Buw6nNHhmKtlG2x5m91ulCf6kxai0mZN7VTkqrlqyCq7Z19RWHUYYJiS4 4iZyQFPUN+0h7I2Np3+KCKnoG12a6mVSdt2jAxfhzpufoWALSyfkr5phFmsR5kMO6bUb lu/API5y4GlhFdMH/n2lrT+pVi4BgmL8W5rUWvjGpW3RNZALfCkKv3b9zipgIYDpz4bx tBvpJBan/vGtkS/C5S2NI4VWeTh6VsvE4mClwqqKWyKiTP4oHs7l3IMoAFH2e01+odzf RceQ== 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=JcayKF0S5fuq4dnazv16i3De/3X7znpGdXMiaRyrsN4=; fh=MxdIzl23z48eTTu70dMwaaJQIRneWHduQxwRvo3xwhg=; b=GWKA/Dw8RaW8F4UNxuw7VGbxFlf69zLkB8b2Gt7iWU0ut8iCwODfqPF8vp+ZY35Z7A SlJFT7HATnuMxdXPkFR0yfBwSD1yhTK4akrWmYgiuuY6UNOtleuvlXfQ/mczHQ6cOPI9 YuW2UAl0Bq/+G6Qi69F8PK1JlL1DPq4x71nsWxwtBO7qhcaVK8/rpqL3kfSfawjIfg7J F3jbc6Qw4j4b2k827HB7pwQxoMy2IuXraf8dZapabiW3u3T24+0qEd4QiLjIOubv1lOV UqGJMr/ZjxLMPdVz+uPJH/9oXQ80RxX6/jbqT2DdWgEC6nS7LNK4g7zHZTion7kxawp4 SRCw==; darn=linaro.org ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=XCRm0pow; 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 X-Forwarded-Encrypted: i=1; AJvYcCWGbok3aVPXU2uuM5IcIhS6TgomZ0XmQgMfDZPgXQrg3uLd50y1dbe6xkw/Y/iQKUjnmzWKnZqztPQU5z25JJg0 Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id o15-20020a05622a008f00b0042c446997d0si1771089qtw.379.2024.02.09.04.34.39 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 09 Feb 2024 04:34:39 -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=XCRm0pow; 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 1rYQ4T-0008T0-5G; Fri, 09 Feb 2024 07:33:33 -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 1rYQ49-00087O-OP for qemu-devel@nongnu.org; Fri, 09 Feb 2024 07:33:18 -0500 Received: from mail-wm1-x334.google.com ([2a00:1450:4864:20::334]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rYQ47-0001xg-DJ for qemu-devel@nongnu.org; Fri, 09 Feb 2024 07:33:13 -0500 Received: by mail-wm1-x334.google.com with SMTP id 5b1f17b1804b1-4107d76dfa8so1174745e9.0 for ; Fri, 09 Feb 2024 04:33:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1707481990; x=1708086790; 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=JcayKF0S5fuq4dnazv16i3De/3X7znpGdXMiaRyrsN4=; b=XCRm0powtD18ImmQOnuaDlzHAu+kJi3KZG8PWL/Qsk528rduJwThTRRXKaJT9sTYrc Tqrl4w7LGWypUE4C9UiH7x6TFfTOqyCYwwgXuSZzZhes50mF3heweyWE1jxOXUn15aYa iRclmcF3hb7vFlVe4lFirDQrL6p1B6qlQBrcQd3EZbhqabzbMeH0YD8BVuXZnx/an8Z2 oIzdMdUMFN6FHTjOsblg2HZ6wLw0YraEefbFLuN+InA49Jx6+2gRw6vJYKVTHO9dlQBQ +d8QBSISALzvLKaKNJWUH3/YICE//sjsva+ZML1fIIxYMyfF3T1IfpLtDYQubQih6c8I e9CA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707481990; x=1708086790; 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=JcayKF0S5fuq4dnazv16i3De/3X7znpGdXMiaRyrsN4=; b=Al2v4tp5wgv5xFfmLkJ+R973D3Xfrg/zomZQ6a9K8WpoaFUgnwxFCgaSp+lJe0Phhi 6F3Z4ny9OdZY3Amzj+yyjVYrLWhLUZhm5S48dxBr5JFOz6ugaYVw3MXHiIy+YuY2fRxQ WBth+qB217G4Om3IFjurHNVRvqH+TCDWelbIB5y9rHf4BMkdk3tZIjBURjsTPu0zP39d 8Uq/E81o/9WRxKycJz6KsHgEcLX/KfrqQPxuPeRxEUG5kEVq4KSyIqm8Fgm5fV5IxIJ1 H7hA/rDJUeJlx3SU7gHe7zxdAm8RaUGsmqkZi3iyY12GtyTMGYBwSaSGUwCtpXvl5jiX V29Q== X-Gm-Message-State: AOJu0YzvjD4iIgsiKPmnQmeBwRv0XFKh1rmoshfdmHgZrpdNbxg6jiF2 AU5AFi80bWJOeR7KRLEAycA/AhnlTekiAiVo8Q7QIOwsF6Zh1kbWyAOnnuX95aqlrIVnFAu7YhG y X-Received: by 2002:a05:600c:474a:b0:40e:f632:494c with SMTP id w10-20020a05600c474a00b0040ef632494cmr1082594wmo.30.1707481989975; Fri, 09 Feb 2024 04:33:09 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCWm7AlHq26PilrZzGO+lwC+lnCRy4B0mshbZq/Z/Vz/tNNgW7nFvgHSEn3NR4kNBb1QD1bYsB9sbTCQkuIplJZ2vp9wxhLxJ2K3GM700Ez9NaVI54aJS8pvb27MxRewqDqmPyV6XX8JX6NJR4CFxRuIk0nKUBCz9Tu73w0MVJP/g/uTEy2H8/Q29lGIP3sPfaP5lHgQAq28YDAttTHR8JOJsF9QPi8M916fOKpYfk+PGy7LswYbdFiAG4IFdlY/lQ+jYeehao+iI7x1u/l3AZxsOrPT38dPcNvKFKcyYfMGHcHS51TINF0/9eO8AGsu08buzgh7OtDd/xs= Received: from m1x-phil.lan ([176.187.218.105]) by smtp.gmail.com with ESMTPSA id l4-20020a05600c4f0400b0040ecdd672fasm540810wmq.13.2024.02.09.04.33.08 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 09 Feb 2024 04:33:09 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Paolo Bonzini , BALATON Zoltan , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Laurent Vivier , Jiaxun Yang , qemu-block@nongnu.org, John Snow , qemu-ppc@nongnu.org, Eduardo Habkost , "Michael S. Tsirkin" Subject: [RFC PATCH 7/7] hw/misc/mac_via: Have VIA1 child access parent IRQ once realized Date: Fri, 9 Feb 2024 13:32:25 +0100 Message-ID: <20240209123226.32576-8-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240209123226.32576-1-philmd@linaro.org> References: <20240209123226.32576-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::334; envelope-from=philmd@linaro.org; helo=mail-wm1-x334.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, T_SCC_BODY_TEXT_LINE=-0.01 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 We shouldn't call qdev_get_gpio_in() on unrealized devices. Signed-off-by: Philippe Mathieu-Daudé --- hw/misc/mac_via.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/hw/misc/mac_via.c b/hw/misc/mac_via.c index db6142b5f4..67e51430bf 100644 --- a/hw/misc/mac_via.c +++ b/hw/misc/mac_via.c @@ -1246,7 +1246,6 @@ static void mos6522_q800_via1_realize(DeviceState *dev, Error **errp) v1s->tick_offset = (uint32_t)mktimegm(&tm) + RTC_OFFSET; adb_register_autopoll_callback(adb_bus, adb_via_poll, v1s); - v1s->adb_data_ready = qdev_get_gpio_in(dev, VIA1_IRQ_ADB_READY_BIT); if (v1s->blk) { int64_t len = blk_getlength(v1s->blk); @@ -1270,6 +1269,13 @@ static void mos6522_q800_via1_realize(DeviceState *dev, Error **errp) } } +static void mos6522_q800_via1_wire(DeviceState *dev) +{ + MOS6522Q800VIA1State *v1s = MOS6522_Q800_VIA1(dev); + + v1s->adb_data_ready = qdev_get_gpio_in(dev, VIA1_IRQ_ADB_READY_BIT); +} + static void mos6522_q800_via1_init(Object *obj) { MOS6522Q800VIA1State *v1s = MOS6522_Q800_VIA1(obj); @@ -1336,6 +1342,7 @@ static void mos6522_q800_via1_class_init(ObjectClass *oc, void *data) MOS6522DeviceClass *mdc = MOS6522_CLASS(oc); dc->realize = mos6522_q800_via1_realize; + dc->wire = mos6522_q800_via1_wire; resettable_class_set_parent_phases(rc, NULL, mos6522_q800_via1_reset_hold, NULL, &mdc->parent_phases); dc->vmsd = &vmstate_q800_via1;