From patchwork Tue Sep 19 00:11:44 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: John Snow X-Patchwork-Id: 9957817 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 457D1601E9 for ; Tue, 19 Sep 2017 00:23:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 37CAC28DCF for ; Tue, 19 Sep 2017 00:23:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2CB0228DD5; Tue, 19 Sep 2017 00:23:02 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 96C5E28DCF for ; Tue, 19 Sep 2017 00:23:01 +0000 (UTC) Received: from localhost ([::1]:39433 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1du6JY-0004xY-RB for patchwork-qemu-devel@patchwork.kernel.org; Mon, 18 Sep 2017 20:23:00 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37091) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1du68v-0005dR-6r for qemu-devel@nongnu.org; Mon, 18 Sep 2017 20:12:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1du68u-0004Vs-0U for qemu-devel@nongnu.org; Mon, 18 Sep 2017 20:12:01 -0400 Received: from mx1.redhat.com ([209.132.183.28]:38482) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1du68t-0004VA-ND for qemu-devel@nongnu.org; Mon, 18 Sep 2017 20:11:59 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C6DAF4FD; Tue, 19 Sep 2017 00:11:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com C6DAF4FD Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=jsnow@redhat.com Received: from probe.bos.redhat.com (dhcp-17-130.bos.redhat.com [10.18.17.130]) by smtp.corp.redhat.com (Postfix) with ESMTP id 58B7B6060A; Tue, 19 Sep 2017 00:11:58 +0000 (UTC) From: John Snow To: qemu-devel@nongnu.org Date: Mon, 18 Sep 2017 20:11:44 -0400 Message-Id: <20170919001147.23182-12-jsnow@redhat.com> In-Reply-To: <20170919001147.23182-1-jsnow@redhat.com> References: <20170919001147.23182-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Tue, 19 Sep 2017 00:11:58 +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] [PULL 10/13] AHCI: pretty-print FIS to buffer instead of stderr 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: peter.maydell@linaro.org, jsnow@redhat.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP The current FIS printing routines dump the FIS to screen. adjust this such that it dumps to buffer instead, then use this ability to have FIS dump mechanisms via trace-events instead of compiled defines. Signed-off-by: John Snow Reviewed-by: Stefan Hajnoczi Reviewed-by: Eric Blake Reviewed-by: Philippe Mathieu-Daudé Message-id: 20170901001502.29915-9-jsnow@redhat.com Signed-off-by: John Snow --- hw/ide/ahci.c | 28 ++++++++++++++++++---------- hw/ide/trace-events | 4 ++++ 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/hw/ide/ahci.c b/hw/ide/ahci.c index 2dfcab9..dfc05be 100644 --- a/hw/ide/ahci.c +++ b/hw/ide/ahci.c @@ -644,20 +644,21 @@ static void ahci_reset_port(AHCIState *s, int port) ahci_init_d2h(d); } -static void debug_print_fis(uint8_t *fis, int cmd_len) +/* Buffer pretty output based on a raw FIS structure. */ +static char *ahci_pretty_buffer_fis(uint8_t *fis, int cmd_len) { -#if DEBUG_AHCI int i; + GString *s = g_string_new("FIS:"); - fprintf(stderr, "fis:"); for (i = 0; i < cmd_len; i++) { if ((i & 0xf) == 0) { - fprintf(stderr, "\n%02x:",i); + g_string_append_printf(s, "\n0x%02x: ", i); } - fprintf(stderr, "%02x ",fis[i]); + g_string_append_printf(s, "%02x ", fis[i]); } - fprintf(stderr, "\n"); -#endif + g_string_append_c(s, '\n'); + + return g_string_free(s, FALSE); } static bool ahci_map_fis_address(AHCIDevice *ad) @@ -1201,7 +1202,11 @@ static void handle_reg_h2d_fis(AHCIState *s, int port, * table to ide_state->io_buffer */ if (opts & AHCI_CMD_ATAPI) { memcpy(ide_state->io_buffer, &cmd_fis[AHCI_COMMAND_TABLE_ACMD], 0x10); - debug_print_fis(ide_state->io_buffer, 0x10); + if (trace_event_get_state_backends(TRACE_HANDLE_REG_H2D_FIS_DUMP)) { + char *pretty_fis = ahci_pretty_buffer_fis(ide_state->io_buffer, 0x10); + trace_handle_reg_h2d_fis_dump(s, port, pretty_fis); + g_free(pretty_fis); + } s->dev[port].done_atapi_packet = false; /* XXX send PIO setup FIS */ } @@ -1256,8 +1261,11 @@ static int handle_cmd(AHCIState *s, int port, uint8_t slot) trace_handle_cmd_badmap(s, port, cmd_len); goto out; } - debug_print_fis(cmd_fis, 0x80); - + if (trace_event_get_state_backends(TRACE_HANDLE_CMD_FIS_DUMP)) { + char *pretty_fis = ahci_pretty_buffer_fis(cmd_fis, 0x80); + trace_handle_cmd_fis_dump(s, port, pretty_fis); + g_free(pretty_fis); + } switch (cmd_fis[0]) { case SATA_FIS_TYPE_REGISTER_H2D: handle_reg_h2d_fis(s, port, slot, cmd_fis); diff --git a/hw/ide/trace-events b/hw/ide/trace-events index e15fd77..601bd97 100644 --- a/hw/ide/trace-events +++ b/hw/ide/trace-events @@ -105,3 +105,7 @@ ahci_cmd_done(void *s, int port) "ahci(%p)[%d]: cmd done" ahci_reset(void *s) "ahci(%p): HBA reset" allwinner_ahci_mem_read(void *s, void *a, uint64_t addr, uint64_t val, unsigned size) "ahci(%p): read a=%p addr=0x%"HWADDR_PRIx" val=0x%"PRIx64", size=%d" allwinner_ahci_mem_write(void *s, void *a, uint64_t addr, uint64_t val, unsigned size) "ahci(%p): write a=%p addr=0x%"HWADDR_PRIx" val=0x%"PRIx64", size=%d" + +# Warning: Verbose +handle_reg_h2d_fis_dump(void *s, int port, const char *fis) "ahci(%p)[%d]: %s" +handle_cmd_fis_dump(void *s, int port, const char *fis) "ahci(%p)[%d]: %s"