From nobody Tue Nov 4 16:01:31 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1504040271524738.4308017566913; Tue, 29 Aug 2017 13:57:51 -0700 (PDT) Received: from localhost ([::1]:46935 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmna1-0002SL-5l for importer@patchew.org; Tue, 29 Aug 2017 16:57:49 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50094) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmnSG-0003cG-Rh for qemu-devel@nongnu.org; Tue, 29 Aug 2017 16:49:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dmnSF-0001v2-4r for qemu-devel@nongnu.org; Tue, 29 Aug 2017 16:49:48 -0400 Received: from mx1.redhat.com ([209.132.183.28]:57122) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dmnS9-0001r0-RJ; Tue, 29 Aug 2017 16:49:42 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C75595F7B1; Tue, 29 Aug 2017 20:49:40 +0000 (UTC) Received: from probe.bos.redhat.com (dhcp-17-231.bos.redhat.com [10.18.17.231]) by smtp.corp.redhat.com (Postfix) with ESMTP id CFE2A6268F; Tue, 29 Aug 2017 20:49:39 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com C75595F7B1 Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=jsnow@redhat.com From: John Snow To: qemu-block@nongnu.org Date: Tue, 29 Aug 2017 16:49:26 -0400 Message-Id: <20170829204934.9039-2-jsnow@redhat.com> In-Reply-To: <20170829204934.9039-1-jsnow@redhat.com> References: <20170829204934.9039-1-jsnow@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Tue, 29 Aug 2017 20:49:40 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 1/9] IDE: replace DEBUG_IDE with tracing system X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: John Snow , qemu-devel@nongnu.org, f4bug@amsat.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Remove the DEBUG_IDE preprocessor definition with something more appropriately flexible, using the trace-events subsystem. This will be less prone to bitrot and will more effectively allow us to target just the functions we care about. Signed-off-by: John Snow Reviewed-by: Eric Blake --- Makefile.objs | 1 + hw/ide/cmd646.c | 10 +++----- hw/ide/core.c | 65 +++++++++++++++++++------------------------= ---- hw/ide/pci.c | 17 ++++--------- hw/ide/piix.c | 11 ++++---- hw/ide/trace-events | 35 +++++++++++++++++++++++++ hw/ide/via.c | 10 +++----- include/hw/ide/internal.h | 1 - 8 files changed, 80 insertions(+), 70 deletions(-) create mode 100644 hw/ide/trace-events diff --git a/Makefile.objs b/Makefile.objs index 24a4ea0..967c092 100644 --- a/Makefile.objs +++ b/Makefile.objs @@ -153,6 +153,7 @@ trace-events-subdirs +=3D hw/acpi trace-events-subdirs +=3D hw/arm trace-events-subdirs +=3D hw/alpha trace-events-subdirs +=3D hw/xen +trace-events-subdirs +=3D hw/ide trace-events-subdirs +=3D ui trace-events-subdirs +=3D audio trace-events-subdirs +=3D net diff --git a/hw/ide/cmd646.c b/hw/ide/cmd646.c index 9ebb8d4..86b2a8f 100644 --- a/hw/ide/cmd646.c +++ b/hw/ide/cmd646.c @@ -32,6 +32,7 @@ #include "sysemu/dma.h" =20 #include "hw/ide/pci.h" +#include "trace.h" =20 /* CMD646 specific */ #define CFR 0x50 @@ -195,9 +196,8 @@ static uint64_t bmdma_read(void *opaque, hwaddr addr, val =3D 0xff; break; } -#ifdef DEBUG_IDE - printf("bmdma: readb " TARGET_FMT_plx " : 0x%02x\n", addr, val); -#endif + + trace_bmdma_read_cmd646(addr, val); return val; } =20 @@ -211,9 +211,7 @@ static void bmdma_write(void *opaque, hwaddr addr, return; } =20 -#ifdef DEBUG_IDE - printf("bmdma: writeb " TARGET_FMT_plx " : 0x%" PRIx64 "\n", addr, val= ); -#endif + trace_bmdma_write_cmd646(addr, val); switch(addr & 3) { case 0: bmdma_cmd_writeb(bm, val); diff --git a/hw/ide/core.c b/hw/ide/core.c index bea3953..31fd593 100644 --- a/hw/ide/core.c +++ b/hw/ide/core.c @@ -36,6 +36,7 @@ #include "qemu/cutils.h" =20 #include "hw/ide/internal.h" +#include "trace.h" =20 /* These values were based on a Seagate ST3500418AS but have been modified to make more sense in QEMU */ @@ -656,10 +657,7 @@ void ide_cancel_dma_sync(IDEState *s) * write requests) pending and we can avoid to drain. */ QLIST_FOREACH(req, &s->buffered_requests, list) { if (!req->orphaned) { -#ifdef DEBUG_IDE - printf("%s: invoking cb %p of buffered request %p with" - " -ECANCELED\n", __func__, req->original_cb, req); -#endif + trace_ide_cancel_dma_sync_buffered(req->original_cb, req); req->original_cb(req->original_opaque, -ECANCELED); } req->orphaned =3D true; @@ -678,9 +676,7 @@ void ide_cancel_dma_sync(IDEState *s) * aio operation with preadv/pwritev. */ if (s->bus->dma->aiocb) { -#ifdef DEBUG_IDE - printf("%s: draining all remaining requests", __func__); -#endif + trace_ide_cancel_dma_sync_remaining(); blk_drain(s->blk); assert(s->bus->dma->aiocb =3D=3D NULL); } @@ -741,9 +737,7 @@ static void ide_sector_read(IDEState *s) n =3D s->req_nb_sectors; } =20 -#if defined(DEBUG_IDE) - printf("sector=3D%" PRId64 "\n", sector_num); -#endif + trace_ide_sector_read(sector_num, n); =20 if (!ide_sect_range_ok(s, sector_num, n)) { ide_rw_error(s); @@ -1005,14 +999,14 @@ static void ide_sector_write(IDEState *s) =20 s->status =3D READY_STAT | SEEK_STAT | BUSY_STAT; sector_num =3D ide_get_sector(s); -#if defined(DEBUG_IDE) - printf("sector=3D%" PRId64 "\n", sector_num); -#endif + n =3D s->nsector; if (n > s->req_nb_sectors) { n =3D s->req_nb_sectors; } =20 + trace_ide_sector_write(sector_num, n); + if (!ide_sect_range_ok(s, sector_num, n)) { ide_rw_error(s); block_acct_invalid(blk_get_stats(s->blk), BLOCK_ACCT_WRITE); @@ -1194,18 +1188,17 @@ static void ide_clear_hob(IDEBus *bus) void ide_ioport_write(void *opaque, uint32_t addr, uint32_t val) { IDEBus *bus =3D opaque; + IDEState *s =3D idebus_active_if(bus); + int reg_num =3D addr & 7; =20 -#ifdef DEBUG_IDE - printf("IDE: write addr=3D0x%x val=3D0x%02x\n", addr, val); -#endif - - addr &=3D 7; + trace_ide_ioport_write(addr, val, bus, s); =20 /* ignore writes to command block while busy with previous command */ - if (addr !=3D 7 && (idebus_active_if(bus)->status & (BUSY_STAT|DRQ_STA= T))) + if (reg_num !=3D 7 && (s->status & (BUSY_STAT|DRQ_STAT))) { return; + } =20 - switch(addr) { + switch (reg_num) { case 0: break; case 1: @@ -1261,9 +1254,7 @@ void ide_ioport_write(void *opaque, uint32_t addr, ui= nt32_t val) =20 static void ide_reset(IDEState *s) { -#ifdef DEBUG_IDE - printf("ide: reset\n"); -#endif + trace_ide_reset(s); =20 if (s->pio_aiocb) { blk_aio_cancel(s->pio_aiocb); @@ -2021,10 +2012,9 @@ void ide_exec_cmd(IDEBus *bus, uint32_t val) IDEState *s; bool complete; =20 -#if defined(DEBUG_IDE) - printf("ide: CMD=3D%02x\n", val); -#endif s =3D idebus_active_if(bus); + trace_ide_exec_cmd(bus, s, val); + /* ignore commands to non existent slave */ if (s !=3D bus->ifs && !s->blk) { return; @@ -2062,18 +2052,18 @@ void ide_exec_cmd(IDEBus *bus, uint32_t val) } } =20 -uint32_t ide_ioport_read(void *opaque, uint32_t addr1) +uint32_t ide_ioport_read(void *opaque, uint32_t addr) { IDEBus *bus =3D opaque; IDEState *s =3D idebus_active_if(bus); - uint32_t addr; + uint32_t reg_num; int ret, hob; =20 - addr =3D addr1 & 7; + reg_num =3D addr & 7; /* FIXME: HOB readback uses bit 7, but it's always set right now */ //hob =3D s->select & (1 << 7); hob =3D 0; - switch(addr) { + switch (reg_num) { case 0: ret =3D 0xff; break; @@ -2141,9 +2131,8 @@ uint32_t ide_ioport_read(void *opaque, uint32_t addr1) qemu_irq_lower(bus->irq); break; } -#ifdef DEBUG_IDE - printf("ide: read addr=3D0x%x val=3D%02x\n", addr1, ret); -#endif + + trace_ide_ioport_read(addr, ret, bus, s); return ret; } =20 @@ -2159,9 +2148,8 @@ uint32_t ide_status_read(void *opaque, uint32_t addr) } else { ret =3D s->status; } -#ifdef DEBUG_IDE - printf("ide: read status addr=3D0x%x val=3D%02x\n", addr, ret); -#endif + + trace_ide_status_read(addr, ret, bus, s); return ret; } =20 @@ -2171,9 +2159,8 @@ void ide_cmd_write(void *opaque, uint32_t addr, uint3= 2_t val) IDEState *s; int i; =20 -#ifdef DEBUG_IDE - printf("ide: write control addr=3D0x%x val=3D%02x\n", addr, val); -#endif + trace_ide_cmd_write(addr, val, bus); + /* common for both drives */ if (!(bus->cmd & IDE_CMD_RESET) && (val & IDE_CMD_RESET)) { diff --git a/hw/ide/pci.c b/hw/ide/pci.c index 3cfb510..f2dcc0e 100644 --- a/hw/ide/pci.c +++ b/hw/ide/pci.c @@ -31,6 +31,7 @@ #include "sysemu/dma.h" #include "qemu/error-report.h" #include "hw/ide/pci.h" +#include "trace.h" =20 #define BMDMA_PAGE_SIZE 4096 =20 @@ -196,9 +197,7 @@ static void bmdma_reset(IDEDMA *dma) { BMDMAState *bm =3D DO_UPCAST(BMDMAState, dma, dma); =20 -#ifdef DEBUG_IDE - printf("ide: dma_reset\n"); -#endif + trace_bmdma_reset(); bmdma_cancel(bm); bm->cmd =3D 0; bm->status =3D 0; @@ -227,9 +226,7 @@ static void bmdma_irq(void *opaque, int n, int level) =20 void bmdma_cmd_writeb(BMDMAState *bm, uint32_t val) { -#ifdef DEBUG_IDE - printf("%s: 0x%08x\n", __func__, val); -#endif + trace_bmdma_cmd_writeb(val); =20 /* Ignore writes to SSBM if it keeps the old value */ if ((val & BM_CMD_START) !=3D (bm->cmd & BM_CMD_START)) { @@ -258,9 +255,7 @@ static uint64_t bmdma_addr_read(void *opaque, hwaddr ad= dr, uint64_t data; =20 data =3D (bm->addr >> (addr * 8)) & mask; -#ifdef DEBUG_IDE - printf("%s: 0x%08x\n", __func__, (unsigned)data); -#endif + trace_bmdma_addr_read(data); return data; } =20 @@ -271,9 +266,7 @@ static void bmdma_addr_write(void *opaque, hwaddr addr, int shift =3D addr * 8; uint32_t mask =3D (1ULL << (width * 8)) - 1; =20 -#ifdef DEBUG_IDE - printf("%s: 0x%08x\n", __func__, (unsigned)data); -#endif + trace_bmdma_addr_write(data); bm->addr &=3D ~(mask << shift); bm->addr |=3D ((data & mask) << shift) & ~3; } diff --git a/hw/ide/piix.c b/hw/ide/piix.c index 7e2d767..dfb21f6 100644 --- a/hw/ide/piix.c +++ b/hw/ide/piix.c @@ -33,6 +33,7 @@ #include "sysemu/dma.h" =20 #include "hw/ide/pci.h" +#include "trace.h" =20 static uint64_t bmdma_read(void *opaque, hwaddr addr, unsigned size) { @@ -54,9 +55,8 @@ static uint64_t bmdma_read(void *opaque, hwaddr addr, uns= igned size) val =3D 0xff; break; } -#ifdef DEBUG_IDE - printf("bmdma: readb 0x%02x : 0x%02x\n", (uint8_t)addr, val); -#endif + + trace_bmdma_read(addr, val); return val; } =20 @@ -69,9 +69,8 @@ static void bmdma_write(void *opaque, hwaddr addr, return; } =20 -#ifdef DEBUG_IDE - printf("bmdma: writeb 0x%02x : 0x%02x\n", (uint8_t)addr, (uint8_t)val); -#endif + trace_bmdma_write(addr, val); + switch(addr & 3) { case 0: bmdma_cmd_writeb(bm, val); diff --git a/hw/ide/trace-events b/hw/ide/trace-events new file mode 100644 index 0000000..b9792812 --- /dev/null +++ b/hw/ide/trace-events @@ -0,0 +1,35 @@ +# See docs/devel/tracing.txt for syntax documentation. + +# hw/ide/core.c +# portio +ide_ioport_read(uint32_t addr, uint32_t val, void *bus, void *s) "IDE PIO= rd @ 0x%"PRIx32"; val 0x%02"PRIx32"; bus %p IDEState %p" +ide_ioport_write(uint32_t addr, uint32_t val, void *bus, void *s) "IDE PIO= wr @ 0x%"PRIx32"; val 0x%02"PRIx32"; bus %p IDEState %p" +ide_status_read(uint32_t addr, uint32_t val, void *bus, void *s) "IDE PIO= rd @ 0x%"PRIx32" (Alt Status); val 0x%02"PRIx32"; bus %p; IDEState %p" +ide_cmd_write(uint32_t addr, uint32_t val, void *bus) "IDE PIO= wr @ 0x%"PRIx32" (Device Control); val 0x%02"PRIx32"; bus %p" +# misc +ide_exec_cmd(void *bus, void *state, uint32_t cmd) "IDE exec cmd: bus %p; = state %p; cmd 0x%02x" +ide_cancel_dma_sync_buffered(void *fn, void *req) "invoking cb %p of buffe= red request %p with -ECANCELED" +ide_cancel_dma_sync_remaining(void) "draining all remaining requests" +ide_sector_read(int64_t sector_num, int nsectors) "sector=3D%"PRId64" nsec= tors=3D%d" +ide_sector_write(int64_t sector_num, int nsectors) "sector=3D%"PRId64" nse= ctors=3D%d" +ide_reset(void *s) "IDEstate %p" + +# BMDMA HBAs: + +# hw/ide/cmd646.c +bmdma_read_cmd646(uint64_t addr, uint32_t val) "bmdma: readb 0x%"PRIx64" := 0x%02x" +bmdma_write_cmd646(uint64_t addr, uint64_t val) "bmdma: writeb 0x%"PRIx64"= : 0x%02"PRIx64 + +# hw/ide/pci.c +bmdma_reset(void) "" +bmdma_cmd_writeb(uint32_t val) "val: 0x%08x" +bmdma_addr_read(uint64_t data) "data: 0x%016"PRIx64 +bmdma_addr_write(uint64_t data) "data: 0x%016"PRIx64 + +# hw/ide/piix.c +bmdma_read(uint64_t addr, uint8_t val) "bmdma: readb 0x%"PRIx64" : 0x%02x" +bmdma_write(uint64_t addr, uint64_t val) "bmdma: writeb 0x%"PRIx64" : 0x%0= 2"PRIx64 + +# hw/ide/via.c +bmdma_read_via(uint64_t addr, uint32_t val) "bmdma: readb 0x%"PRIx64" : 0x= %02x" +bmdma_write_via(uint64_t addr, uint64_t val) "bmdma: writeb 0x%"PRIx64" : = 0x%02"PRIx64 diff --git a/hw/ide/via.c b/hw/ide/via.c index 5b32ecb..35c3059 100644 --- a/hw/ide/via.c +++ b/hw/ide/via.c @@ -33,6 +33,7 @@ #include "sysemu/dma.h" =20 #include "hw/ide/pci.h" +#include "trace.h" =20 static uint64_t bmdma_read(void *opaque, hwaddr addr, unsigned size) @@ -55,9 +56,8 @@ static uint64_t bmdma_read(void *opaque, hwaddr addr, val =3D 0xff; break; } -#ifdef DEBUG_IDE - printf("bmdma: readb 0x%02x : 0x%02x\n", addr, val); -#endif + + trace_bmdma_read_via(addr, val); return val; } =20 @@ -70,9 +70,7 @@ static void bmdma_write(void *opaque, hwaddr addr, return; } =20 -#ifdef DEBUG_IDE - printf("bmdma: writeb 0x%02x : 0x%02x\n", addr, val); -#endif + trace_bmdma_write_via(addr, val); switch (addr & 3) { case 0: bmdma_cmd_writeb(bm, val); diff --git a/include/hw/ide/internal.h b/include/hw/ide/internal.h index 482a951..4a92f0a 100644 --- a/include/hw/ide/internal.h +++ b/include/hw/ide/internal.h @@ -14,7 +14,6 @@ #include "block/scsi.h" =20 /* debug IDE devices */ -//#define DEBUG_IDE //#define DEBUG_IDE_ATAPI //#define DEBUG_AIO #define USE_DMA_CDROM --=20 2.9.5