From nobody Thu May 8 16:30:19 2025 Delivered-To: importer@patchew.org Received-SPF: 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; Authentication-Results: mx.zohomail.com; dkim=pass; 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; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1579802064; cv=none; d=zohomail.com; s=zohoarc; b=d9jkfTORhar6fE9t17sAhGHufJ4vVNg/S4q3qq5fa52VVPugwPXzCqxskP4qjJQXsR+TZoXWpbBbwlymt2ZltT63LpioBtHhyo7IuU3sjO85gOMY88OLTktMVtnPYe+P6IEnlI8IYtk1gW/pxHcBIO0iHmSBaisga3UdginMh3w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1579802064; h=Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=3M0DtLx0sP95WhjPX2VrG6MMgvUeMRuumjeaeKyOkwk=; b=R2UG42QYAv3CgOywt0vC90vYukja5OVCqjdRdOiLdhB4PZhCjmbXpFH5jxpIaCdVbyTZrRPnqZobzIxuUpBcZXYb2QlbrMxy5S8rpxrL1uLNblK6hOirw6gwL1rxOuxiu/YffIN1jqBUoKClf/6oueJmIicso1iDrCsS19LUFKs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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; dmarc=pass header.from=<peter.maydell@linaro.org> (p=none dis=none) header.from=<peter.maydell@linaro.org> Return-Path: <qemu-devel-bounces+importer=patchew.org@nongnu.org> Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1579802064227968.1821252592537; Thu, 23 Jan 2020 09:54:24 -0800 (PST) Received: from localhost ([::1]:34034 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from <qemu-devel-bounces+importer=patchew.org@nongnu.org>) id 1iuggQ-0001NQ-6X for importer@patchew.org; Thu, 23 Jan 2020 12:54:22 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:48442) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from <peter.maydell@linaro.org>) id 1iueRi-0000So-1y for qemu-devel@nongnu.org; Thu, 23 Jan 2020 10:31:03 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from <peter.maydell@linaro.org>) id 1iueRf-0003qM-6v for qemu-devel@nongnu.org; Thu, 23 Jan 2020 10:31:01 -0500 Received: from mail-wm1-x32b.google.com ([2a00:1450:4864:20::32b]:52890) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from <peter.maydell@linaro.org>) id 1iueRe-0003na-Tv for qemu-devel@nongnu.org; Thu, 23 Jan 2020 10:30:59 -0500 Received: by mail-wm1-x32b.google.com with SMTP id p9so3017264wmc.2 for <qemu-devel@nongnu.org>; Thu, 23 Jan 2020 07:30:58 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id s139sm2903592wme.35.2020.01.23.07.30.56 for <qemu-devel@nongnu.org> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Jan 2020 07:30:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=3M0DtLx0sP95WhjPX2VrG6MMgvUeMRuumjeaeKyOkwk=; b=BWMqJP9jrHzB7NBokm7LgesFstUO656MIyfeCEFRbY3AAoxxM16ZKBwjXBTVgvviL5 e8RW9Y6JwBFzeUtkptLPwaqWjasDerg+3GsFX/lCS8dSxCi6jdo459PGqZrTd2V1SA+/ eHuulrDbUeatUxNySqQD0UHmEllrE7800lzHUof+q5Vdz9c+jG5PLxsRPVlG881M1t5h 8GkBZlBJNqqCkRj2KaU4H5xE18U78+DKUhY/VHAB8He9R2UX44ykXCaNmINPmaPsHunJ 5dDi+lQ8Mkq2TnD5iUdUAFEfep95a7KZDMmgc+m5elxbJKyRbwW8n1NGvzvRw1FPCxRG ClDg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=3M0DtLx0sP95WhjPX2VrG6MMgvUeMRuumjeaeKyOkwk=; b=JCoecvk4XH8Esn9yo+w0gKPR2uCsJbj+xn0VNNTMtiemvoM28yfV7F6ap39ZxtzZuh f2qiVJcGUlyozhYzkcpQWrT22XCj3OmGQGKmFs5p9gzgnu4ZMFg5y5OvwmdTnuQDCTmd KMZ5bLOSa8YSR9Yg4Sj0NClqQXPe9tLB/tZX3eoUYJV/y2cnOBT14bwp3EdiUmU0E1xw GqERZ4wvgqrgCjQzcJA6vdxrulpPjE50cOuxcEt7lsV71VToZIVkfKxeFPb9787xLf+P WteB/Sr9dezH6NWAY1yObg/hghIGX4Q7Tq4HYS3dNV7/Y9p/1JeZMa5xCez1dx5/3w6T 3tkw== X-Gm-Message-State: APjAAAUuep8E8gIF+ziO78Ex1T/O6z9JXD5u9aalssB1v+GHtogSCgP5 RvhC1zRhVtE2sHfhLDD/ultvKg/2XWndRw== X-Google-Smtp-Source: APXvYqwM3ZAS8KIB4Wrk2MAKdu75PKobP8/Fqa+gKdJTsqVFU0jzAeu5F8DKODfSZjHagYUJmS3maw== X-Received: by 2002:a1c:b7c4:: with SMTP id h187mr5029505wmf.105.1579793457540; Thu, 23 Jan 2020 07:30:57 -0800 (PST) From: Peter Maydell <peter.maydell@linaro.org> To: qemu-devel@nongnu.org Subject: [PULL 13/20] dma/pl330: Convert to support tracing Date: Thu, 23 Jan 2020 15:30:34 +0000 Message-Id: <20200123153041.4248-14-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200123153041.4248-1-peter.maydell@linaro.org> References: <20200123153041.4248-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::32b X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: <qemu-devel.nongnu.org> List-Unsubscribe: <https://lists.nongnu.org/mailman/options/qemu-devel>, <mailto:qemu-devel-request@nongnu.org?subject=unsubscribe> List-Archive: <https://lists.nongnu.org/archive/html/qemu-devel> List-Post: <mailto:qemu-devel@nongnu.org> List-Help: <mailto:qemu-devel-request@nongnu.org?subject=help> List-Subscribe: <https://lists.nongnu.org/mailman/listinfo/qemu-devel>, <mailto:qemu-devel-request@nongnu.org?subject=subscribe> Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" <qemu-devel-bounces+importer=patchew.org@nongnu.org> X-ZohoMail-DKIM: pass (identity @linaro.org) Content-Type: text/plain; charset="utf-8" From: Guenter Roeck <linux@roeck-us.net> Replace debug logging code with tracing. Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Guenter Roeck <linux@roeck-us.net> Message-id: 20200123052540.6132-2-linux@roeck-us.net Signed-off-by: Peter Maydell <peter.maydell@linaro.org> --- hw/dma/pl330.c | 88 ++++++++++++++++++++++++--------------------- hw/dma/trace-events | 24 +++++++++++++ 2 files changed, 72 insertions(+), 40 deletions(-) diff --git a/hw/dma/pl330.c b/hw/dma/pl330.c index f2bb2d9ac16..64519971ef9 100644 --- a/hw/dma/pl330.c +++ b/hw/dma/pl330.c @@ -25,19 +25,12 @@ #include "sysemu/dma.h" #include "qemu/log.h" #include "qemu/module.h" +#include "trace.h" =20 #ifndef PL330_ERR_DEBUG #define PL330_ERR_DEBUG 0 #endif =20 -#define DB_PRINT_L(lvl, fmt, args...) do {\ - if (PL330_ERR_DEBUG >=3D lvl) {\ - fprintf(stderr, "PL330: %s:" fmt, __func__, ## args);\ - } \ -} while (0) - -#define DB_PRINT(fmt, args...) DB_PRINT_L(1, fmt, ## args) - #define PL330_PERIPH_NUM 32 #define PL330_MAX_BURST_LEN 128 #define PL330_INSN_MAXSIZE 6 @@ -319,6 +312,26 @@ typedef struct PL330InsnDesc { void (*exec)(PL330Chan *, uint8_t opcode, uint8_t *args, int len); } PL330InsnDesc; =20 +static void pl330_hexdump(uint8_t *buf, size_t size) +{ + unsigned int b, i, len; + char tmpbuf[80]; + + for (b =3D 0; b < size; b +=3D 16) { + len =3D size - b; + if (len > 16) { + len =3D 16; + } + tmpbuf[0] =3D '\0'; + for (i =3D 0; i < len; i++) { + if ((i % 4) =3D=3D 0) { + strcat(tmpbuf, " "); + } + sprintf(tmpbuf + strlen(tmpbuf), " %02x", buf[b + i]); + } + trace_pl330_hexdump(b, tmpbuf); + } +} =20 /* MFIFO Implementation * @@ -582,7 +595,7 @@ static inline void pl330_queue_remove_tagged(PL330Queue= *s, uint8_t tag) =20 static inline void pl330_fault(PL330Chan *ch, uint32_t flags) { - DB_PRINT("ch: %p, flags: %" PRIx32 "\n", ch, flags); + trace_pl330_fault(ch, flags); ch->fault_type |=3D flags; if (ch->state =3D=3D pl330_chan_fault) { return; @@ -590,7 +603,7 @@ static inline void pl330_fault(PL330Chan *ch, uint32_t = flags) ch->state =3D pl330_chan_fault; ch->parent->num_faulting++; if (ch->parent->num_faulting =3D=3D 1) { - DB_PRINT("abort interrupt raised\n"); + trace_pl330_fault_abort(); qemu_irq_raise(ch->parent->irq_abort); } } @@ -648,7 +661,7 @@ static void pl330_dmaend(PL330Chan *ch, uint8_t opcode, return; } } - DB_PRINT("DMA ending!\n"); + trace_pl330_dmaend(); pl330_fifo_tagged_remove(&s->fifo, ch->tag); pl330_queue_remove_tagged(&s->read_queue, ch->tag); pl330_queue_remove_tagged(&s->write_queue, ch->tag); @@ -683,7 +696,7 @@ static void pl330_dmago(PL330Chan *ch, uint8_t opcode, = uint8_t *args, int len) uint32_t pc; PL330Chan *s; =20 - DB_PRINT("\n"); + trace_pl330_dmago(); =20 if (!ch->is_manager) { pl330_fault(ch, PL330_FAULT_UNDEF_INSTR); @@ -740,9 +753,7 @@ static void pl330_dmald(PL330Chan *ch, uint8_t opcode, = uint8_t *args, int len) ch->stall =3D pl330_queue_put_insn(&ch->parent->read_queue, ch->src, size, num, inc, 0, ch->tag); if (!ch->stall) { - DB_PRINT("channel:%" PRId8 " address:%08" PRIx32 " size:%" PRIx32 - " num:%" PRId32 " %c\n", - ch->tag, ch->src, size, num, inc ? 'Y' : 'N'); + trace_pl330_dmald(ch->tag, ch->src, size, num, inc ? 'Y' : 'N'); ch->src +=3D inc ? size * num - (ch->src & (size - 1)) : 0; } } @@ -782,7 +793,7 @@ static void pl330_dmakill(PL330Chan *ch, uint8_t opcode= , uint8_t *args, int len) ch->fault_type =3D 0; ch->parent->num_faulting--; if (ch->parent->num_faulting =3D=3D 0) { - DB_PRINT("abort interrupt lowered\n"); + trace_pl330_dmakill(); qemu_irq_lower(ch->parent->irq_abort); } } @@ -800,6 +811,8 @@ static void pl330_dmalpend(PL330Chan *ch, uint8_t opcod= e, uint8_t bs =3D opcode & 3; uint8_t lc =3D (opcode & 4) >> 2; =20 + trace_pl330_dmalpend(nf, bs, lc, ch->lc[lc], ch->request_flag); + if (bs =3D=3D 2) { pl330_fault(ch, PL330_FAULT_OPERAND_INVALID); return; @@ -813,12 +826,12 @@ static void pl330_dmalpend(PL330Chan *ch, uint8_t opc= ode, if (nf) { ch->lc[lc]--; } - DB_PRINT("loop reiteration\n"); + trace_pl330_dmalpiter(); ch->pc -=3D args[0]; ch->pc -=3D len + 1; /* "ch->pc -=3D args[0] + len + 1" is incorrect when args[0] =3D= =3D 256 */ } else { - DB_PRINT("loop fallthrough\n"); + trace_pl330_dmalpfallthrough(); } } =20 @@ -886,10 +899,10 @@ static void pl330_dmasev(PL330Chan *ch, uint8_t opcod= e, uint8_t *args, int len) } if (ch->parent->inten & (1 << ev_id)) { ch->parent->int_status |=3D (1 << ev_id); - DB_PRINT("event interrupt raised %" PRId8 "\n", ev_id); + trace_pl330_dmasev_evirq(ev_id); qemu_irq_raise(ch->parent->irq[ev_id]); } - DB_PRINT("event raised %" PRId8 "\n", ev_id); + trace_pl330_dmasev_event(ev_id); ch->parent->ev_status |=3D (1 << ev_id); } =20 @@ -914,9 +927,7 @@ static void pl330_dmast(PL330Chan *ch, uint8_t opcode, = uint8_t *args, int len) ch->stall =3D pl330_queue_put_insn(&ch->parent->write_queue, ch->dst, size, num, inc, 0, ch->tag); if (!ch->stall) { - DB_PRINT("channel:%" PRId8 " address:%08" PRIx32 " size:%" PRIx32 - " num:%" PRId32 " %c\n", - ch->tag, ch->dst, size, num, inc ? 'Y' : 'N'); + trace_pl330_dmast(ch->tag, ch->dst, size, num, inc ? 'Y' : 'N'); ch->dst +=3D inc ? size * num - (ch->dst & (size - 1)) : 0; } } @@ -992,7 +1003,7 @@ static void pl330_dmawfe(PL330Chan *ch, uint8_t opcode, } } ch->parent->ev_status &=3D ~(1 << ev_id); - DB_PRINT("event lowered %" PRIx8 "\n", ev_id); + trace_pl330_dmawfe(ev_id); } else { ch->stall =3D 1; } @@ -1135,7 +1146,7 @@ static int pl330_chan_exec(PL330Chan *ch) ch->stall =3D 0; insn =3D pl330_fetch_insn(ch); if (!insn) { - DB_PRINT("pl330 undefined instruction\n"); + trace_pl330_chan_exec_undef(); pl330_fault(ch, PL330_FAULT_UNDEF_INSTR); return 0; } @@ -1175,10 +1186,9 @@ static int pl330_exec_cycle(PL330Chan *channel) int len =3D q->len - (q->addr & (q->len - 1)); =20 dma_memory_read(&address_space_memory, q->addr, buf, len); - if (PL330_ERR_DEBUG > 1) { - DB_PRINT("PL330 read from memory @%08" PRIx32 " (size =3D %08x= ):\n", - q->addr, len); - qemu_hexdump((char *)buf, stderr, "", len); + trace_pl330_exec_cycle(q->addr, len); + if (trace_event_get_state_backends(TRACE_PL330_HEXDUMP)) { + pl330_hexdump(buf, len); } fifo_res =3D pl330_fifo_push(&s->fifo, buf, len, q->tag); if (fifo_res =3D=3D PL330_FIFO_OK) { @@ -1207,10 +1217,9 @@ static int pl330_exec_cycle(PL330Chan *channel) } if (fifo_res =3D=3D PL330_FIFO_OK || q->z) { dma_memory_write(&address_space_memory, q->addr, buf, len); - if (PL330_ERR_DEBUG > 1) { - DB_PRINT("PL330 read from memory @%08" PRIx32 - " (size =3D %08x):\n", q->addr, len); - qemu_hexdump((char *)buf, stderr, "", len); + trace_pl330_exec_cycle(q->addr, len); + if (trace_event_get_state_backends(TRACE_PL330_HEXDUMP)) { + pl330_hexdump(buf, len); } if (q->inc) { q->addr +=3D len; @@ -1252,8 +1261,8 @@ static int pl330_exec_channel(PL330Chan *channel) =20 static inline void pl330_exec(PL330State *s) { - DB_PRINT("\n"); int i, insr_exec; + trace_pl330_exec(); do { insr_exec =3D pl330_exec_channel(&s->manager); =20 @@ -1298,7 +1307,7 @@ static void pl330_debug_exec(PL330State *s) args[2] =3D (s->dbg[1] >> 8) & 0xff; args[3] =3D (s->dbg[1] >> 16) & 0xff; args[4] =3D (s->dbg[1] >> 24) & 0xff; - DB_PRINT("chan id: %" PRIx8 "\n", chan_id); + trace_pl330_debug_exec(chan_id); if (s->dbg[0] & 1) { ch =3D &s->chan[chan_id]; } else { @@ -1320,6 +1329,7 @@ static void pl330_debug_exec(PL330State *s) ch->fault_type |=3D PL330_FAULT_DBG_INSTR; } if (ch->stall) { + trace_pl330_debug_exec_stall(); qemu_log_mask(LOG_UNIMP, "pl330: stall of debug instruction not " "implemented\n"); } @@ -1334,7 +1344,7 @@ static void pl330_iomem_write(void *opaque, hwaddr of= fset, PL330State *s =3D (PL330State *) opaque; int i; =20 - DB_PRINT("addr: %08x data: %08x\n", (unsigned)offset, (unsigned)value); + trace_pl330_iomem_write((unsigned)offset, (unsigned)value); =20 switch (offset) { case PL330_REG_INTEN: @@ -1343,7 +1353,7 @@ static void pl330_iomem_write(void *opaque, hwaddr of= fset, case PL330_REG_INTCLR: for (i =3D 0; i < s->num_events; i++) { if (s->int_status & s->inten & value & (1 << i)) { - DB_PRINT("event interrupt lowered %d\n", i); + trace_pl330_iomem_write_clr(i); qemu_irq_lower(s->irq[i]); } } @@ -1361,11 +1371,9 @@ static void pl330_iomem_write(void *opaque, hwaddr o= ffset, } break; case PL330_REG_DBGINST0: - DB_PRINT("s->dbg[0] =3D %08x\n", (unsigned)value); s->dbg[0] =3D value; break; case PL330_REG_DBGINST1: - DB_PRINT("s->dbg[1] =3D %08x\n", (unsigned)value); s->dbg[1] =3D value; break; default: @@ -1489,7 +1497,7 @@ static uint64_t pl330_iomem_read(void *opaque, hwaddr= offset, unsigned size) { uint32_t ret =3D pl330_iomem_read_imp(opaque, offset); - DB_PRINT("addr: %08" HWADDR_PRIx " data: %08" PRIx32 "\n", offset, ret= ); + trace_pl330_iomem_read((uint32_t)offset, ret); return ret; } =20 diff --git a/hw/dma/trace-events b/hw/dma/trace-events index e4498428c52..5902ac5969d 100644 --- a/hw/dma/trace-events +++ b/hw/dma/trace-events @@ -20,3 +20,27 @@ sparc32_dma_enable_lower(void) "Lower DMA enable" =20 # i8257.c i8257_unregistered_dma(int nchan, int dma_pos, int dma_len) "unregistered = DMA channel used nchan=3D%d dma_pos=3D%d dma_len=3D%d" + +# pl330.c +pl330_fault(void *ptr, uint32_t flags) "ch: %p, flags: 0x%"PRIx32 +pl330_fault_abort(void) "abort interrupt raised" +pl330_dmaend(void) "DMA ending" +pl330_dmago(void) "DMA run" +pl330_dmald(uint32_t chan, uint32_t addr, uint32_t size, uint32_t num, uin= t32_t ch) "channel:%"PRId8" address:0x%08"PRIx32" size:0x%"PRIx32" num:%"PR= Id32"%c" +pl330_dmakill(void) "abort interrupt lowered" +pl330_dmalpend(uint8_t nf, uint8_t bs, uint8_t lc, uint8_t ch, uint8_t fla= g) "nf=3D0x%02x bs=3D0x%02x lc=3D0x%02x ch=3D0x%02x flag=3D0x%02x" +pl330_dmalpiter(void) "loop reiteration" +pl330_dmalpfallthrough(void) "loop fallthrough" +pl330_dmasev_evirq(uint8_t ev_id) "event interrupt raised %"PRId8 +pl330_dmasev_event(uint8_t ev_id) "event raised %"PRId8 +pl330_dmast(uint32_t chn, uint32_t addr, uint32_t sz, uint32_t num, uint32= _t c) "channel:%"PRId8" address:0x%08"PRIx32" size:0x%"PRIx32" num:%"PRId32= " %c" +pl330_dmawfe(uint8_t ev_id) "event lowered 0x%"PRIx8 +pl330_chan_exec_undef(void) "undefined instruction" +pl330_exec_cycle(uint32_t addr, uint32_t size) "PL330 read from memory @0x= %08"PRIx32" (size =3D 0x%08"PRIx32")" +pl330_hexdump(uint32_t offset, char *str) " 0x%04"PRIx32":%s" +pl330_exec(void) "pl330_exec" +pl330_debug_exec(uint8_t ch) "chan id: 0x%"PRIx8 +pl330_debug_exec_stall(void) "stall of debug instruction not implemented" +pl330_iomem_write(uint32_t offset, uint32_t value) "addr: 0x%08"PRIx32" da= ta: 0x%08"PRIx32 +pl330_iomem_write_clr(int i) "event interrupt lowered %d" +pl330_iomem_read(uint32_t addr, uint32_t data) "addr: 0x%08"PRIx32" data: = 0x%08"PRIx32 --=20 2.20.1