From: David Gibson <david@gibson.dropbear.id.au>
To: agraf@suse.de
Cc: qemu-ppc@nongnu.org, qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH 8/8] pseries: Check for duplicate addresses on the spapr-vio bus
Date: Tue, 13 Dec 2011 15:24:35 +1100 [thread overview]
Message-ID: <1323750275-947-9-git-send-email-david@gibson.dropbear.id.au> (raw)
In-Reply-To: <1323750275-947-1-git-send-email-david@gibson.dropbear.id.au>
From: Michael Ellerman <michael@ellerman.id.au>
Check that devices on the spapr vio bus aren't given duplicate
addresses. Currently we will not run with duplicate devices, the
fdt code will spot it, but the error reporting is not great. With
this patch we can report the error nicely in terms of the device
names given by the user.
Signed-off-by: Michael Ellerman <michael@ellerman.id.au>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
---
hw/spapr_vio.c | 32 ++++++++++++++++++++++++++++++++
1 files changed, 32 insertions(+), 0 deletions(-)
diff --git a/hw/spapr_vio.c b/hw/spapr_vio.c
index b188a71..0e5581c 100644
--- a/hw/spapr_vio.c
+++ b/hw/spapr_vio.c
@@ -621,11 +621,43 @@ static void rtas_quiesce(sPAPREnvironment *spapr, uint32_t token,
rtas_st(rets, 0, 0);
}
+static int spapr_vio_check_reg(VIOsPAPRDevice *sdev, VIOsPAPRDeviceInfo *info)
+{
+ VIOsPAPRDevice *other_sdev;
+ DeviceState *qdev;
+ VIOsPAPRBus *sbus;
+
+ sbus = DO_UPCAST(VIOsPAPRBus, bus, sdev->qdev.parent_bus);
+
+ /*
+ * Check two device aren't given clashing addresses by the user (or some
+ * other mechanism). We have to open code this because we have to check
+ * for matches with devices other than us.
+ */
+ QTAILQ_FOREACH(qdev, &sbus->bus.children, sibling) {
+ other_sdev = DO_UPCAST(VIOsPAPRDevice, qdev, qdev);
+
+ if (other_sdev != sdev && other_sdev->reg == sdev->reg) {
+ fprintf(stderr, "vio: %s and %s devices conflict at address %#x\n",
+ info->qdev.name, other_sdev->qdev.info->name, sdev->reg);
+ return -EEXIST;
+ }
+ }
+
+ return 0;
+}
+
static int spapr_vio_busdev_init(DeviceState *qdev, DeviceInfo *qinfo)
{
VIOsPAPRDeviceInfo *info = (VIOsPAPRDeviceInfo *)qinfo;
VIOsPAPRDevice *dev = (VIOsPAPRDevice *)qdev;
char *id;
+ int ret;
+
+ ret = spapr_vio_check_reg(dev, info);
+ if (ret) {
+ return ret;
+ }
/* Don't overwrite ids assigned on the command line */
if (!dev->qdev.id) {
--
1.7.7.3
next prev parent reply other threads:[~2011-12-13 4:24 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-12-13 4:24 [Qemu-devel] [0/8] Assorted pseries updates David Gibson
2011-12-13 4:24 ` [Qemu-devel] [PATCH 1/8] pseries: Remove hcalls callback David Gibson
2011-12-13 4:24 ` [Qemu-devel] [PATCH 2/8] monitor: add ability to dump SLB entries David Gibson
2011-12-20 15:28 ` Alexander Graf
2011-12-21 0:33 ` [Qemu-devel] [Qemu-ppc] " David Gibson
2011-12-13 4:24 ` [Qemu-devel] [PATCH 3/8] pseries: FDT NUMA extensions to support multi-node guests David Gibson
2011-12-13 4:24 ` [Qemu-devel] [PATCH 5/8] pseries: Emit device tree nodes in reg order David Gibson
2011-12-13 4:24 ` [Qemu-devel] [PATCH 6/8] pseries: Add a routine to find a stable "default" vty and use it David Gibson
2011-12-13 4:24 ` [Qemu-devel] [PATCH 7/8] pseries: Populate "/chosen/linux, stdout-path" in the FDT David Gibson
2011-12-13 4:24 ` David Gibson [this message]
2011-12-20 15:41 ` [Qemu-devel] [0/8] Assorted pseries updates Alexander Graf
2011-12-21 0:34 ` [Qemu-devel] [Qemu-ppc] " David Gibson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1323750275-947-9-git-send-email-david@gibson.dropbear.id.au \
--to=david@gibson.dropbear.id.au \
--cc=agraf@suse.de \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).