From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51192) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aYv14-00022s-RV for qemu-devel@nongnu.org; Thu, 25 Feb 2016 07:27:35 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aYv0r-0000Za-6H for qemu-devel@nongnu.org; Thu, 25 Feb 2016 07:27:34 -0500 References: <1456401731-10672-1-git-send-email-hpoussin@reactos.org> From: Thomas Huth Message-ID: <56CEF324.40303@redhat.com> Date: Thu, 25 Feb 2016 13:27:16 +0100 MIME-Version: 1.0 In-Reply-To: <1456401731-10672-1-git-send-email-hpoussin@reactos.org> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH] dbdma: warn when using unassigned channel List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: =?UTF-8?Q?Herv=c3=a9_Poussineau?= , qemu-devel@nongnu.org Cc: "open list:Old World" , Alexander Graf On 25.02.2016 13:02, Herv=C3=A9 Poussineau wrote: > With this, it's easier to know if a guest uses an invalid and/or unimpl= emented > DMA channel. >=20 > Signed-off-by: Herv=C3=A9 Poussineau > --- > hw/misc/macio/mac_dbdma.c | 25 +++++++++++++++++++++++-- > 1 file changed, 23 insertions(+), 2 deletions(-) >=20 > diff --git a/hw/misc/macio/mac_dbdma.c b/hw/misc/macio/mac_dbdma.c > index d81dea7..6051f17 100644 > --- a/hw/misc/macio/mac_dbdma.c > +++ b/hw/misc/macio/mac_dbdma.c > @@ -557,11 +557,13 @@ void DBDMA_register_channel(void *dbdma, int ncha= n, qemu_irq irq, > =20 > DBDMA_DPRINTF("DBDMA_register_channel 0x%x\n", nchan); > =20 > + assert(rw); > + assert(flush); > + > ch->irq =3D irq; > ch->rw =3D rw; > ch->flush =3D flush; > ch->io.opaque =3D opaque; > - ch->io.channel =3D ch; > } > =20 > static void > @@ -775,6 +777,20 @@ static void dbdma_reset(void *opaque) > memset(s->channels[i].regs, 0, DBDMA_SIZE); > } > =20 > +static void dbdma_unassigned_rw(DBDMA_io *io) > +{ > + DBDMA_channel *ch =3D io->channel; > + qemu_log_mask(LOG_GUEST_ERROR, "%s: use of unassigned channel %d\n= ", > + __func__, ch->channel); > +} > + > +static void dbdma_unassigned_flush(DBDMA_io *io) > +{ > + DBDMA_channel *ch =3D io->channel; > + qemu_log_mask(LOG_GUEST_ERROR, "%s: use of unassigned channel %d\n= ", > + __func__, ch->channel); > +} > + > void* DBDMA_init (MemoryRegion **dbdma_mem) > { > DBDMAState *s; > @@ -784,8 +800,13 @@ void* DBDMA_init (MemoryRegion **dbdma_mem) > =20 > for (i =3D 0; i < DBDMA_CHANNELS; i++) { > DBDMA_io *io =3D &s->channels[i].io; > + DBDMA_channel *ch =3D &s->channels[i]; > qemu_iovec_init(&io->iov, 1); > - s->channels[i].channel =3D i; > + > + ch->rw =3D dbdma_unassigned_rw; > + ch->flush =3D dbdma_unassigned_flush; > + ch->channel =3D i; > + ch->io.channel =3D ch; > } > =20 > memory_region_init_io(&s->mem, NULL, &dbdma_ops, s, "dbdma", 0x100= 0); >=20 Looks reasonable. Reviewed-by: Thomas Huth