From owner-svn-src-head@freebsd.org Thu Oct 22 23:03:35 2015 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 0F91DA1C42C; Thu, 22 Oct 2015 23:03:35 +0000 (UTC) (envelope-from cem@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id C7762895; Thu, 22 Oct 2015 23:03:34 +0000 (UTC) (envelope-from cem@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id t9MN3XoM094046; Thu, 22 Oct 2015 23:03:33 GMT (envelope-from cem@FreeBSD.org) Received: (from cem@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id t9MN3XIm094043; Thu, 22 Oct 2015 23:03:33 GMT (envelope-from cem@FreeBSD.org) Message-Id: <201510222303.t9MN3XIm094043@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: cem set sender to cem@FreeBSD.org using -f From: "Conrad E. Meyer" Date: Thu, 22 Oct 2015 23:03:33 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r289776 - head/sys/dev/ioat X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 22 Oct 2015 23:03:35 -0000 Author: cem Date: Thu Oct 22 23:03:33 2015 New Revision: 289776 URL: https://svnweb.freebsd.org/changeset/base/289776 Log: ioat: Clean up logging Replace custom Linux-like logging with a thin shim around device_printf(), when the softc is available. In ioat_test, shim around printf(9) instead. Sponsored by: EMC / Isilon Storage Division Modified: head/sys/dev/ioat/ioat.c head/sys/dev/ioat/ioat_internal.h head/sys/dev/ioat/ioat_test.c Modified: head/sys/dev/ioat/ioat.c ============================================================================== --- head/sys/dev/ioat/ioat.c Thu Oct 22 23:03:24 2015 (r289775) +++ head/sys/dev/ioat/ioat.c Thu Oct 22 23:03:33 2015 (r289776) @@ -80,6 +80,12 @@ static void ioat_comp_update_map(void *a static int ioat_reset_hw(struct ioat_softc *ioat); static void ioat_setup_sysctl(device_t device); +#define ioat_log_message(v, ...) do { \ + if ((v) <= g_ioat_debug_level) { \ + device_printf(ioat->device, __VA_ARGS__); \ + } \ +} while (0) + MALLOC_DEFINE(M_IOAT, "ioat", "ioat driver memory allocations"); SYSCTL_NODE(_hw, OID_AUTO, ioat, CTLFLAG_RD, 0, "ioat node"); @@ -87,7 +93,7 @@ static int g_force_legacy_interrupts; SYSCTL_INT(_hw_ioat, OID_AUTO, force_legacy_interrupts, CTLFLAG_RDTUN, &g_force_legacy_interrupts, 0, "Set to non-zero to force MSI-X disabled"); -static int g_ioat_debug_level = 0; +int g_ioat_debug_level = 0; SYSCTL_INT(_hw_ioat, OID_AUTO, debug_level, CTLFLAG_RWTUN, &g_ioat_debug_level, 0, "Set log level (0-3) for ioat(4). Higher is more verbose."); @@ -614,8 +620,8 @@ ioat_release(bus_dmaengine_t dmaengine) { struct ioat_softc *ioat; - ioat_log_message(3, "%s\n", __func__); ioat = to_ioat_softc(dmaengine); + ioat_log_message(3, "%s\n", __func__); ioat_write_2(ioat, IOAT_DMACOUNT_OFFSET, (uint16_t)ioat->head); mtx_unlock(&ioat->submit_lock); } @@ -1035,21 +1041,3 @@ ioat_setup_sysctl(device_t device) "tail", CTLFLAG_RD, &ioat->tail, 0, "HW descriptor tail pointer index"); } - -void -ioat_log_message(int verbosity, char *fmt, ...) -{ - va_list argp; - char buffer[512]; - struct timeval tv; - - if (verbosity > g_ioat_debug_level) - return; - - va_start(argp, fmt); - vsnprintf(buffer, sizeof(buffer) - 1, fmt, argp); - va_end(argp); - microuptime(&tv); - - printf("[%d:%06d] ioat: %s", (int)tv.tv_sec, (int)tv.tv_usec, buffer); -} Modified: head/sys/dev/ioat/ioat_internal.h ============================================================================== --- head/sys/dev/ioat/ioat_internal.h Thu Oct 22 23:03:24 2015 (r289775) +++ head/sys/dev/ioat/ioat_internal.h Thu Oct 22 23:03:33 2015 (r289776) @@ -119,7 +119,7 @@ MALLOC_DECLARE(M_IOAT); SYSCTL_DECL(_hw_ioat); -void ioat_log_message(int verbosity, char *fmt, ...); +extern int g_ioat_debug_level; struct ioat_dma_hw_descriptor { uint32_t size; Modified: head/sys/dev/ioat/ioat_test.c ============================================================================== --- head/sys/dev/ioat/ioat_test.c Thu Oct 22 23:03:24 2015 (r289775) +++ head/sys/dev/ioat/ioat_test.c Thu Oct 22 23:03:33 2015 (r289776) @@ -43,6 +43,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include @@ -76,6 +77,9 @@ MTX_SYSINIT(ioat_test_lk, &ioat_test_lk, static int g_thread_index = 1; static struct cdev *g_ioat_cdev = NULL; +#define ioat_test_log(v, ...) _ioat_test_log((v), "ioat " __VA_ARGS__) +static inline void _ioat_test_log(int verbosity, const char *fmt, ...); + static void ioat_test_transaction_destroy(struct test_transaction *tx) { @@ -138,7 +142,7 @@ ioat_dma_test_callback(void *arg) test = tx->test; if (test->verify && !ioat_compare_ok(tx)) { - ioat_log_message(0, "miscompare found\n"); + ioat_test_log(0, "miscompare found\n"); atomic_add_32(&test->status[IOAT_TEST_MISCOMPARE], tx->depth); } else if (!test->too_late) atomic_add_32(&test->status[IOAT_TEST_OK], tx->depth); @@ -160,7 +164,7 @@ ioat_test_prealloc_memory(struct ioat_te tx = ioat_test_transaction_create(test->chain_depth * 2, test->buffer_size); if (tx == NULL) { - ioat_log_message(0, "tx == NULL - memory exhausted\n"); + ioat_test_log(0, "tx == NULL - memory exhausted\n"); test->status[IOAT_TEST_NO_MEMORY]++; return (ENOMEM); } @@ -248,13 +252,13 @@ ioat_dma_test(void *arg) memset(__DEVOLATILE(void *, test->status), 0, sizeof(test->status)); if (test->buffer_size > 1024 * 1024) { - ioat_log_message(0, "Buffer size too large >1MB\n"); + ioat_test_log(0, "Buffer size too large >1MB\n"); test->status[IOAT_TEST_NO_MEMORY]++; return; } if (test->chain_depth * 2 > IOAT_MAX_BUFS) { - ioat_log_message(0, "Depth too large (> %u)\n", + ioat_test_log(0, "Depth too large (> %u)\n", (unsigned)IOAT_MAX_BUFS / 2); test->status[IOAT_TEST_NO_MEMORY]++; return; @@ -262,14 +266,14 @@ ioat_dma_test(void *arg) if (btoc((uint64_t)test->buffer_size * test->chain_depth * test->transactions) > (physmem / 4)) { - ioat_log_message(0, "Sanity check failed -- test would " + ioat_test_log(0, "Sanity check failed -- test would " "use more than 1/4 of phys mem.\n"); test->status[IOAT_TEST_NO_MEMORY]++; return; } if ((uint64_t)test->transactions * test->chain_depth > (1<<16)) { - ioat_log_message(0, "Sanity check failed -- test would " + ioat_test_log(0, "Sanity check failed -- test would " "use more than available IOAT ring space.\n"); test->status[IOAT_TEST_NO_MEMORY]++; return; @@ -277,7 +281,7 @@ ioat_dma_test(void *arg) dmaengine = ioat_get_dmaengine(test->channel_index); if (dmaengine == NULL) { - ioat_log_message(0, "Couldn't acquire dmaengine\n"); + ioat_test_log(0, "Couldn't acquire dmaengine\n"); test->status[IOAT_TEST_NO_DMA_ENGINE]++; return; } @@ -287,14 +291,14 @@ ioat_dma_test(void *arg) TAILQ_INIT(&test->pend_q); if (test->duration == 0) - ioat_log_message(1, "Thread %d: num_loops remaining: 0x%08x\n", + ioat_test_log(1, "Thread %d: num_loops remaining: 0x%08x\n", index, test->transactions); else - ioat_log_message(1, "Thread %d: starting\n", index); + ioat_test_log(1, "Thread %d: starting\n", index); rc = ioat_test_prealloc_memory(test, index); if (rc != 0) { - ioat_log_message(0, "prealloc_memory: %d\n", rc); + ioat_test_log(0, "prealloc_memory: %d\n", rc); return; } wmb(); @@ -314,7 +318,7 @@ ioat_dma_test(void *arg) ioat_test_submit_1_tx(test, dmaengine); } - ioat_log_message(1, "Test Elapsed: %d ticks (overrun %d), %d sec.\n", + ioat_test_log(1, "Test Elapsed: %d ticks (overrun %d), %d sec.\n", ticks - start, ticks - end, (ticks - start) / hz); IT_LOCK(); @@ -322,7 +326,7 @@ ioat_dma_test(void *arg) msleep(&test->free_q, &ioat_test_lk, 0, "ioattestcompl", hz); IT_UNLOCK(); - ioat_log_message(1, "Test Elapsed2: %d ticks (overrun %d), %d sec.\n", + ioat_test_log(1, "Test Elapsed2: %d ticks (overrun %d), %d sec.\n", ticks - start, ticks - end, (ticks - start) / hz); ioat_test_release_memory(test); @@ -421,3 +425,16 @@ ioat_test_detach(void) enable_ioat_test(false); mtx_unlock(&Giant); } + +static inline void +_ioat_test_log(int verbosity, const char *fmt, ...) +{ + va_list argp; + + if (verbosity > g_ioat_debug_level) + return; + + va_start(argp, fmt); + vprintf(fmt, argp); + va_end(argp); +}