From owner-svn-src-all@freebsd.org Mon Jan 6 01:15:36 2020 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 5F08F1ECA53; Mon, 6 Jan 2020 01:15:36 +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 47rcyJ1q0Zz415v; Mon, 6 Jan 2020 01:15:36 +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 20B856932; Mon, 6 Jan 2020 01:15:36 +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 0061FaW0011777; Mon, 6 Jan 2020 01:15:36 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0061Fasi011776; Mon, 6 Jan 2020 01:15:36 GMT (envelope-from mav@FreeBSD.org) Message-Id: <202001060115.0061Fasi011776@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Mon, 6 Jan 2020 01:15:35 +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: r356391 - stable/11/sys/cam X-SVN-Group: stable-11 X-SVN-Commit-Author: mav X-SVN-Commit-Paths: stable/11/sys/cam X-SVN-Commit-Revision: 356391 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: Mon, 06 Jan 2020 01:15:36 -0000 Author: mav Date: Mon Jan 6 01:15:35 2020 New Revision: 356391 URL: https://svnweb.freebsd.org/changeset/base/356391 Log: MFC r356042: Make pass(4) handle misaligned buffers of MAXPHYS size. Since we are already using malloc()+copyin()/copyout() for smaller data blocks, and since new asynchronous API does it always, I see no reason to keep this ugly artificial size/alignment limitation in old API. Tape applications suffer enough from the MAXPHYS limitations by itself, and additional alignment requirement, often halving effectively usable block size, does not help. It would be good to use unmapped I/O here instead, but it require some HBA drivers polishing first to support non-BIO unmapped buffers. Modified: stable/11/sys/cam/cam_periph.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/cam/cam_periph.c ============================================================================== --- stable/11/sys/cam/cam_periph.c Mon Jan 6 01:12:15 2020 (r356390) +++ stable/11/sys/cam/cam_periph.c Mon Jan 6 01:15:35 2020 (r356391) @@ -770,6 +770,7 @@ cam_periph_mapmem(union ccb *ccb, struct cam_periph_ma u_int8_t **data_ptrs[CAM_PERIPH_MAXMAPS]; u_int32_t lengths[CAM_PERIPH_MAXMAPS]; u_int32_t dirs[CAM_PERIPH_MAXMAPS]; + bool misaligned[CAM_PERIPH_MAXMAPS]; bzero(mapinfo, sizeof(*mapinfo)); if (maxmap == 0) @@ -869,6 +870,12 @@ cam_periph_mapmem(union ccb *ccb, struct cam_periph_ma * have to unmap any previously mapped buffers. */ for (i = 0; i < numbufs; i++) { + if (lengths[i] > maxmap) { + printf("cam_periph_mapmem: attempt to map %lu bytes, " + "which is greater than %lu\n", + (long)(lengths[i]), (u_long)maxmap); + return (E2BIG); + } /* * The userland data pointer passed in may not be page @@ -878,15 +885,8 @@ cam_periph_mapmem(union ccb *ccb, struct cam_periph_ma * whatever extra space is necessary to make it to the page * boundary. */ - if ((lengths[i] + - (((vm_offset_t)(*data_ptrs[i])) & PAGE_MASK)) > maxmap){ - printf("cam_periph_mapmem: attempt to map %lu bytes, " - "which is greater than %lu\n", - (long)(lengths[i] + - (((vm_offset_t)(*data_ptrs[i])) & PAGE_MASK)), - (u_long)maxmap); - return(E2BIG); - } + misaligned[i] = (lengths[i] + + (((vm_offset_t)(*data_ptrs[i])) & PAGE_MASK) > MAXPHYS); } /* @@ -910,7 +910,7 @@ cam_periph_mapmem(union ccb *ccb, struct cam_periph_ma * small allocations malloc is backed by UMA, and so much * cheaper on SMP systems. */ - if (lengths[i] <= periph_mapmem_thresh) { + if (lengths[i] <= periph_mapmem_thresh || misaligned[i]) { *data_ptrs[i] = malloc(lengths[i], M_CAMPERIPH, M_WAITOK); if (dirs[i] != CAM_DIR_IN) {