From owner-svn-src-all@freebsd.org Tue Oct 15 18:42:07 2019 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 0924515116D; Tue, 15 Oct 2019 18:42:07 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 46t4666Srhz4fg8; Tue, 15 Oct 2019 18:42:06 +0000 (UTC) (envelope-from mav@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 mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id C161622E09; Tue, 15 Oct 2019 18:42:06 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x9FIg6f1066319; Tue, 15 Oct 2019 18:42:06 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x9FIg6q6066318; Tue, 15 Oct 2019 18:42:06 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201910151842.x9FIg6q6066318@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Tue, 15 Oct 2019 18:42:06 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r353581 - stable/11/sys/dev/ioat X-SVN-Group: stable-11 X-SVN-Commit-Author: mav X-SVN-Commit-Paths: stable/11/sys/dev/ioat X-SVN-Commit-Revision: 353581 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 15 Oct 2019 18:42:07 -0000 Author: mav Date: Tue Oct 15 18:42:06 2019 New Revision: 353581 URL: https://svnweb.freebsd.org/changeset/base/353581 Log: MFC r352787: Replace argument checks with assertions. Those functions are used by kernel, and we can't check all possible argument errors in production kernel. Plus according to docs many of those errors are checked by hardware. Assertions should just help with code debugging. Modified: stable/11/sys/dev/ioat/ioat.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/ioat/ioat.c ============================================================================== --- stable/11/sys/dev/ioat/ioat.c Tue Oct 15 18:39:32 2019 (r353580) +++ stable/11/sys/dev/ioat/ioat.c Tue Oct 15 18:42:06 2019 (r353581) @@ -1002,17 +1002,14 @@ ioat_op_generic(struct ioat_softc *ioat, uint8_t op, KASSERT((flags & ~_DMA_GENERIC_FLAGS) == 0, ("Unrecognized flag(s): %#x", flags & ~_DMA_GENERIC_FLAGS)); + KASSERT(size <= ioat->max_xfer_size, ("%s: size too big (%u > %u)", + __func__, (unsigned)size, ioat->max_xfer_size)); + if ((flags & DMA_NO_WAIT) != 0) mflags = M_NOWAIT; else mflags = M_WAITOK; - if (size > ioat->max_xfer_size) { - ioat_log_message(0, "%s: max_xfer_size = %d, requested = %u\n", - __func__, ioat->max_xfer_size, (unsigned)size); - return (NULL); - } - if (ioat_reserve_space(ioat, 1, mflags) != 0) return (NULL); @@ -1070,11 +1067,8 @@ ioat_copy(bus_dmaengine_t dmaengine, bus_addr_t dst, ioat = to_ioat_softc(dmaengine); - if (((src | dst) & (0xffffull << 48)) != 0) { - ioat_log_message(0, "%s: High 16 bits of src/dst invalid\n", - __func__); - return (NULL); - } + KASSERT(((src | dst) & (0xffffull << 48)) == 0, + ("%s: high 16 bits of src/dst are not zero", __func__)); desc = ioat_op_generic(ioat, IOAT_OP_COPY, len, src, dst, callback_fn, callback_arg, flags); @@ -1103,16 +1097,10 @@ ioat_copy_8k_aligned(bus_dmaengine_t dmaengine, bus_ad ioat = to_ioat_softc(dmaengine); CTR2(KTR_IOAT, "%s channel=%u", __func__, ioat->chan_idx); - if (((src1 | src2 | dst1 | dst2) & (0xffffull << 48)) != 0) { - ioat_log_message(0, "%s: High 16 bits of src/dst invalid\n", - __func__); - return (NULL); - } - if (((src1 | src2 | dst1 | dst2) & PAGE_MASK) != 0) { - ioat_log_message(0, "%s: Addresses must be page-aligned\n", - __func__); - return (NULL); - } + KASSERT(((src1 | src2 | dst1 | dst2) & (0xffffull << 48)) == 0, + ("%s: high 16 bits of src/dst are not zero", __func__)); + KASSERT(((src1 | src2 | dst1 | dst2) & PAGE_MASK) == 0, + ("%s: addresses are not page-aligned", __func__)); desc = ioat_op_generic(ioat, IOAT_OP_COPY, 2 * PAGE_SIZE, src1, dst1, callback_fn, callback_arg, flags); @@ -1150,26 +1138,15 @@ ioat_copy_crc(bus_dmaengine_t dmaengine, bus_addr_t ds ioat = to_ioat_softc(dmaengine); CTR2(KTR_IOAT, "%s channel=%u", __func__, ioat->chan_idx); - if ((ioat->capabilities & IOAT_DMACAP_MOVECRC) == 0) { - ioat_log_message(0, "%s: Device lacks MOVECRC capability\n", - __func__); - return (NULL); - } - if (((src | dst) & (0xffffffull << 40)) != 0) { - ioat_log_message(0, "%s: High 24 bits of src/dst invalid\n", - __func__); - return (NULL); - } + KASSERT((ioat->capabilities & IOAT_DMACAP_MOVECRC) != 0, + ("%s: device lacks MOVECRC capability", __func__)); + KASSERT(((src | dst) & (0xffffffull << 40)) == 0, + ("%s: high 24 bits of src/dst are not zero", __func__)); teststore = (flags & _DMA_CRC_TESTSTORE); - if (teststore == _DMA_CRC_TESTSTORE) { - ioat_log_message(0, "%s: TEST and STORE invalid\n", __func__); - return (NULL); - } - if (teststore == 0 && (flags & DMA_CRC_INLINE) != 0) { - ioat_log_message(0, "%s: INLINE invalid without TEST or STORE\n", - __func__); - return (NULL); - } + KASSERT(teststore != _DMA_CRC_TESTSTORE, + ("%s: TEST and STORE invalid", __func__)); + KASSERT(teststore != 0 || (flags & DMA_CRC_INLINE) == 0, + ("%s: INLINE invalid without TEST or STORE", __func__)); switch (teststore) { case DMA_CRC_STORE: @@ -1184,12 +1161,9 @@ ioat_copy_crc(bus_dmaengine_t dmaengine, bus_addr_t ds break; } - if ((flags & DMA_CRC_INLINE) == 0 && - (crcptr & (0xffffffull << 40)) != 0) { - ioat_log_message(0, - "%s: High 24 bits of crcptr invalid\n", __func__); - return (NULL); - } + KASSERT((flags & DMA_CRC_INLINE) != 0 || + (crcptr & (0xffffffull << 40)) == 0, + ("%s: high 24 bits of crcptr are not zero", __func__)); desc = ioat_op_generic(ioat, op, len, src, dst, callback_fn, callback_arg, flags & ~_DMA_CRC_FLAGS); @@ -1229,26 +1203,15 @@ ioat_crc(bus_dmaengine_t dmaengine, bus_addr_t src, bu ioat = to_ioat_softc(dmaengine); CTR2(KTR_IOAT, "%s channel=%u", __func__, ioat->chan_idx); - if ((ioat->capabilities & IOAT_DMACAP_CRC) == 0) { - ioat_log_message(0, "%s: Device lacks CRC capability\n", - __func__); - return (NULL); - } - if ((src & (0xffffffull << 40)) != 0) { - ioat_log_message(0, "%s: High 24 bits of src invalid\n", - __func__); - return (NULL); - } + KASSERT((ioat->capabilities & IOAT_DMACAP_CRC) != 0, + ("%s: device lacks CRC capability", __func__)); + KASSERT((src & (0xffffffull << 40)) == 0, + ("%s: high 24 bits of src are not zero", __func__)); teststore = (flags & _DMA_CRC_TESTSTORE); - if (teststore == _DMA_CRC_TESTSTORE) { - ioat_log_message(0, "%s: TEST and STORE invalid\n", __func__); - return (NULL); - } - if (teststore == 0 && (flags & DMA_CRC_INLINE) != 0) { - ioat_log_message(0, "%s: INLINE invalid without TEST or STORE\n", - __func__); - return (NULL); - } + KASSERT(teststore != _DMA_CRC_TESTSTORE, + ("%s: TEST and STORE invalid", __func__)); + KASSERT(teststore != 0 || (flags & DMA_CRC_INLINE) == 0, + ("%s: INLINE invalid without TEST or STORE", __func__)); switch (teststore) { case DMA_CRC_STORE: @@ -1263,12 +1226,9 @@ ioat_crc(bus_dmaengine_t dmaengine, bus_addr_t src, bu break; } - if ((flags & DMA_CRC_INLINE) == 0 && - (crcptr & (0xffffffull << 40)) != 0) { - ioat_log_message(0, - "%s: High 24 bits of crcptr invalid\n", __func__); - return (NULL); - } + KASSERT((flags & DMA_CRC_INLINE) != 0 || + (crcptr & (0xffffffull << 40)) == 0, + ("%s: high 24 bits of crcptr are not zero", __func__)); desc = ioat_op_generic(ioat, op, len, src, 0, callback_fn, callback_arg, flags & ~_DMA_CRC_FLAGS); @@ -1306,18 +1266,11 @@ ioat_blockfill(bus_dmaengine_t dmaengine, bus_addr_t d ioat = to_ioat_softc(dmaengine); CTR2(KTR_IOAT, "%s channel=%u", __func__, ioat->chan_idx); - if ((ioat->capabilities & IOAT_DMACAP_BFILL) == 0) { - ioat_log_message(0, "%s: Device lacks BFILL capability\n", - __func__); - return (NULL); - } + KASSERT((ioat->capabilities & IOAT_DMACAP_BFILL) != 0, + ("%s: device lacks BFILL capability", __func__)); + KASSERT((dst & (0xffffull << 48)) == 0, + ("%s: high 16 bits of crcptr are not zero", __func__)); - if ((dst & (0xffffull << 48)) != 0) { - ioat_log_message(0, "%s: High 16 bits of dst invalid\n", - __func__); - return (NULL); - } - desc = ioat_op_generic(ioat, IOAT_OP_FILL, len, fillpattern, dst, callback_fn, callback_arg, flags); if (desc == NULL) @@ -1473,7 +1426,7 @@ ioat_poll_timer_callback(void *arg) struct ioat_softc *ioat; ioat = arg; - ioat_log_message(3, "%s\n", __func__); + CTR1(KTR_IOAT, "%s", __func__); ioat_process_events(ioat, FALSE);