From owner-dev-commits-src-branches@freebsd.org Fri Jul 23 11:30:35 2021 Return-Path: Delivered-To: dev-commits-src-branches@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 4DAA2670B27; Fri, 23 Jul 2021 11:30:35 +0000 (UTC) (envelope-from git@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GWRvb1mrBz4RbQ; Fri, 23 Jul 2021 11:30:35 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 22661242B4; Fri, 23 Jul 2021 11:30:35 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 16NBUZlV057560; Fri, 23 Jul 2021 11:30:35 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 16NBUZX9057559; Fri, 23 Jul 2021 11:30:35 GMT (envelope-from git) Date: Fri, 23 Jul 2021 11:30:35 GMT Message-Id: <202107231130.16NBUZX9057559@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Leandro Lupori Subject: git: 572e3575dba5 - stable/13 - aacraid: reduce max I/O size to avoid DMA issues MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: luporl X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 572e3575dba591f372633a38d76ce7904d1a1b2e Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 23 Jul 2021 11:30:35 -0000 The branch stable/13 has been updated by luporl: URL: https://cgit.FreeBSD.org/src/commit/?id=572e3575dba591f372633a38d76ce7904d1a1b2e commit 572e3575dba591f372633a38d76ce7904d1a1b2e Author: Leandro Lupori AuthorDate: 2021-06-21 18:04:43 +0000 Commit: Leandro Lupori CommitDate: 2021-07-23 11:28:58 +0000 aacraid: reduce max I/O size to avoid DMA issues Reserve one page for the DMA subsystem, that may need it when the I/O buffer is not page aligned. Without this change, writes with the maximum allowed size failed, if: - physical memory was fragmented, making it necessary to use one DMA segment for each page - the buffer to be written was not page aligned, causing the DMA subsystem to need one extra segment In the scenario above, the DMA subsystem would run out of segments, resulting in a write with no SG segments, that would fail. Reviewed by: imp Sponsored by: Instituto de Pesquisas Eldorado (eldorado.org.br) Differential Revision: https://reviews.freebsd.org/D30798 (cherry picked from commit 9c2c6353193b53deb337777c2a06a2648b364f8b) --- sys/dev/aacraid/aacraid.c | 4 ++-- sys/dev/aacraid/aacraid_cam.c | 2 +- sys/dev/aacraid/aacraid_var.h | 8 ++++++++ 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/sys/dev/aacraid/aacraid.c b/sys/dev/aacraid/aacraid.c index 65c585269b78..51a633e70515 100644 --- a/sys/dev/aacraid/aacraid.c +++ b/sys/dev/aacraid/aacraid.c @@ -579,7 +579,7 @@ aac_alloc(struct aac_softc *sc) BUS_SPACE_MAXADDR_32BIT, /* lowaddr */ BUS_SPACE_MAXADDR, /* highaddr */ NULL, NULL, /* filter, filterarg */ - sc->aac_max_sectors << 9, /* maxsize */ + AAC_MAXIO_SIZE(sc), /* maxsize */ sc->aac_sg_tablesize, /* nsegments */ BUS_SPACE_MAXSIZE_32BIT, /* maxsegsize */ BUS_DMA_ALLOCNOW, /* flags */ @@ -1807,7 +1807,7 @@ aac_init(struct aac_softc *sc) } ip->MaxIoCommands = sc->aac_max_fibs; - ip->MaxIoSize = sc->aac_max_sectors << 9; + ip->MaxIoSize = AAC_MAXIO_SIZE(sc); ip->MaxFibSize = sc->aac_max_fib_size; aac_adapter_init_tole(ip); diff --git a/sys/dev/aacraid/aacraid_cam.c b/sys/dev/aacraid/aacraid_cam.c index 48da7e8d757f..9c73248472bd 100644 --- a/sys/dev/aacraid/aacraid_cam.c +++ b/sys/dev/aacraid/aacraid_cam.c @@ -1011,7 +1011,7 @@ aac_cam_action(struct cam_sim *sim, union ccb *ccb) cpi->max_lun = 7; /* Per the controller spec */ cpi->initiator_id = camsc->inf->InitiatorBusId; cpi->bus_id = camsc->inf->BusNumber; - cpi->maxio = sc->aac_max_sectors << 9; + cpi->maxio = AAC_MAXIO_SIZE(sc); /* * Resetting via the passthrough or parallel bus scan diff --git a/sys/dev/aacraid/aacraid_var.h b/sys/dev/aacraid/aacraid_var.h index 4fed21b1356b..bbafdafb8840 100644 --- a/sys/dev/aacraid/aacraid_var.h +++ b/sys/dev/aacraid/aacraid_var.h @@ -470,6 +470,14 @@ struct aac_softc u_int32_t FwDebugBufferSize; /* FW Debug Buffer size */ }; +/* + * Max. I/O size in bytes. + * Reserve one page for the DMA subsystem, that may need it when the + * I/O buffer is not page aligned. + */ +#define AAC_MAXIO_SIZE(sc) MIN(((sc)->aac_max_sectors << 9) - PAGE_SIZE, \ + maxphys) + /* * Event callback mechanism for the driver */