Date: Thu, 22 Oct 2015 23:03:33 +0000 (UTC) From: "Conrad E. Meyer" <cem@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r289776 - head/sys/dev/ioat Message-ID: <201510222303.t9MN3XIm094043@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
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 <dev/pci/pcivar.h> #include <machine/bus.h> #include <machine/resource.h> +#include <machine/stdarg.h> #include <vm/vm.h> #include <vm/pmap.h> @@ -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); +}
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201510222303.t9MN3XIm094043>