From nobody Tue Feb 10 12:59:22 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1632908111378477.8484959052855; Wed, 29 Sep 2021 02:35:11 -0700 (PDT) Received: from localhost ([::1]:47958 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mVVza-0000hd-AE for importer@patchew.org; Wed, 29 Sep 2021 05:35:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44928) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mVVtX-0001qg-9A for qemu-devel@nongnu.org; Wed, 29 Sep 2021 05:28:55 -0400 Received: from mout.kundenserver.de ([212.227.126.187]:37851) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mVVtS-0005kr-9p for qemu-devel@nongnu.org; Wed, 29 Sep 2021 05:28:55 -0400 Received: from quad ([82.142.21.142]) by mrelayeu.kundenserver.de (mreue010 [212.227.15.167]) with ESMTPSA (Nemesis) id 1MRTAj-1m8kDT451Z-00NUpC; Wed, 29 Sep 2021 11:28:47 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 05/20] nubus: move slot bitmap checks from NubusDevice realize() to BusClass check_address() Date: Wed, 29 Sep 2021 11:28:28 +0200 Message-Id: <20210929092843.2686234-6-laurent@vivier.eu> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210929092843.2686234-1-laurent@vivier.eu> References: <20210929092843.2686234-1-laurent@vivier.eu> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:C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pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=212.227.126.187; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Cave-Ayland , Laurent Vivier , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZM-MESSAGEID: 1632908113253100001 From: Mark Cave-Ayland Allow Nubus to manage the slot allocations itself using the BusClass check_= address() virtual function rather than managing this during NubusDevice realize(). Signed-off-by: Mark Cave-Ayland Reviewed-by: Laurent Vivier Reviewed-by: Philippe Mathieu-Daud=C3=A9 Message-Id: <20210924073808.1041-6-mark.cave-ayland@ilande.co.uk> Signed-off-by: Laurent Vivier --- hw/nubus/nubus-bus.c | 29 +++++++++++++++++++++++++++++ hw/nubus/nubus-device.c | 21 --------------------- 2 files changed, 29 insertions(+), 21 deletions(-) diff --git a/hw/nubus/nubus-bus.c b/hw/nubus/nubus-bus.c index 3cd75348646b..96ef027bad26 100644 --- a/hw/nubus/nubus-bus.c +++ b/hw/nubus/nubus-bus.c @@ -96,11 +96,40 @@ static void nubus_init(Object *obj) NUBUS_SLOT_NB); } =20 +static bool nubus_check_address(BusState *bus, DeviceState *dev, Error **e= rrp) +{ + NubusDevice *nd =3D NUBUS_DEVICE(dev); + NubusBus *nubus =3D NUBUS_BUS(bus); + + if (nd->slot =3D=3D -1) { + /* No slot specified, find first available free slot */ + int s =3D ctz32(nubus->slot_available_mask); + if (s !=3D 32) { + nd->slot =3D s; + } else { + error_setg(errp, "Cannot register nubus card, no free slot " + "available"); + return false; + } + } else { + /* Slot specified, make sure the slot is available */ + if (!(nubus->slot_available_mask & BIT(nd->slot))) { + error_setg(errp, "Cannot register nubus card, slot %d is " + "unavailable or already occupied", nd->slot); + return false; + } + } + + nubus->slot_available_mask &=3D ~BIT(nd->slot); + return true; +} + static void nubus_class_init(ObjectClass *oc, void *data) { BusClass *bc =3D BUS_CLASS(oc); =20 bc->realize =3D nubus_realize; + bc->check_address =3D nubus_check_address; } =20 static const TypeInfo nubus_bus_info =3D { diff --git a/hw/nubus/nubus-device.c b/hw/nubus/nubus-device.c index 2e96d6b4fc39..516b13d2d53d 100644 --- a/hw/nubus/nubus-device.c +++ b/hw/nubus/nubus-device.c @@ -161,27 +161,6 @@ static void nubus_device_realize(DeviceState *dev, Err= or **errp) char *name; hwaddr slot_offset; =20 - if (nd->slot =3D=3D -1) { - /* No slot specified, find first available free slot */ - int s =3D ctz32(nubus->slot_available_mask); - if (s !=3D 32) { - nd->slot =3D s; - } else { - error_setg(errp, "Cannot register nubus card, no free slot " - "available"); - return; - } - } else { - /* Slot specified, make sure the slot is available */ - if (!(nubus->slot_available_mask & BIT(nd->slot))) { - error_setg(errp, "Cannot register nubus card, slot %d is " - "unavailable or already occupied", nd->slot); - return; - } - } - - nubus->slot_available_mask &=3D ~BIT(nd->slot); - /* Super */ slot_offset =3D nd->slot * NUBUS_SUPER_SLOT_SIZE; =20 --=20 2.31.1