From: Alexander Graf <agraf@suse.de>
To: "qemu-devel@nongnu.org Developers" <qemu-devel@nongnu.org>
Cc: Blue Swirl <blauwirbel@gmail.com>,
Michael Ellerman <michael@ellerman.id.au>,
Aurelien Jarno <aurelien@aurel32.net>,
David Gibson <david@gibson.dropbear.id.au>
Subject: [Qemu-devel] [PATCH 09/10] pseries: Check for duplicate addresses on the spapr-vio bus
Date: Tue, 3 Jan 2012 16:08:21 +0100 [thread overview]
Message-ID: <1325603302-12412-10-git-send-email-agraf@suse.de> (raw)
In-Reply-To: <1325603302-12412-1-git-send-email-agraf@suse.de>
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>
Signed-off-by: Alexander Graf <agraf@suse.de>
---
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 cd03416..7a86dc8 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.6.0.2
next prev parent reply other threads:[~2012-01-03 14:54 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-01-03 15:08 [Qemu-devel] [PULL 00/10] ppc patch queue 2012-01-03 Alexander Graf
2012-01-03 15:08 ` [Qemu-devel] [PATCH 01/10] PPC: monitor: add ability to dump SLB entries Alexander Graf
2012-01-03 15:08 ` [Qemu-devel] [PATCH 02/10] console: Fix segfault on screendump without VGA adapter Alexander Graf
2012-01-03 15:08 ` [Qemu-devel] [PATCH 03/10] kvm-ppc: halt secondary cpus when guest reset Alexander Graf
2012-01-03 15:08 ` [Qemu-devel] [PATCH 04/10] pseries: Remove hcalls callback Alexander Graf
2012-01-03 15:08 ` [Qemu-devel] [PATCH 05/10] pseries: FDT NUMA extensions to support multi-node guests Alexander Graf
2012-01-03 15:08 ` [Qemu-devel] [PATCH 06/10] pseries: Emit device tree nodes in reg order Alexander Graf
2012-01-03 15:08 ` [Qemu-devel] [PATCH 07/10] pseries: Add a routine to find a stable "default" vty and use it Alexander Graf
2012-01-03 15:08 ` [Qemu-devel] [PATCH 08/10] pseries: Populate "/chosen/linux, stdout-path" in the FDT Alexander Graf
2012-01-03 15:08 ` Alexander Graf [this message]
2012-01-03 15:08 ` [Qemu-devel] [PATCH 10/10] PPC: Add description for the Freescale e500mc core Alexander Graf
2012-01-07 21:04 ` [Qemu-devel] [PULL 00/10] ppc patch queue 2012-01-03 Aurelien Jarno
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=1325603302-12412-10-git-send-email-agraf@suse.de \
--to=agraf@suse.de \
--cc=aurelien@aurel32.net \
--cc=blauwirbel@gmail.com \
--cc=david@gibson.dropbear.id.au \
--cc=michael@ellerman.id.au \
--cc=qemu-devel@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).