From owner-svn-src-stable-12@freebsd.org Mon Jan 6 01:12:16 2020 Return-Path: Delivered-To: svn-src-stable-12@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 7E5A11EC945; Mon, 6 Jan 2020 01:12:16 +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 47rctS2pqtz40xm; Mon, 6 Jan 2020 01:12:16 +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 4354C6918; Mon, 6 Jan 2020 01:12:16 +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 0061CGmP010443; Mon, 6 Jan 2020 01:12:16 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0061CGnb010442; Mon, 6 Jan 2020 01:12:16 GMT (envelope-from mav@FreeBSD.org) Message-Id: <202001060112.0061CGnb010442@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:12:16 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r356390 - stable/12/sys/cam X-SVN-Group: stable-12 X-SVN-Commit-Author: mav X-SVN-Commit-Paths: stable/12/sys/cam X-SVN-Commit-Revision: 356390 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 06 Jan 2020 01:12:16 -0000 Author: mav Date: Mon Jan 6 01:12:15 2020 New Revision: 356390 URL: https://svnweb.freebsd.org/changeset/base/356390 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/12/sys/cam/cam_periph.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/cam/cam_periph.c ============================================================================== --- stable/12/sys/cam/cam_periph.c Sun Jan 5 22:54:25 2020 (r356389) +++ stable/12/sys/cam/cam_periph.c Mon Jan 6 01:12:15 2020 (r356390) @@ -786,6 +786,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) @@ -897,6 +898,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 @@ -906,15 +913,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); } /* @@ -938,7 +938,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]) && ccb->ccb_h.func_code != XPT_MMC_IO) { *data_ptrs[i] = malloc(lengths[i], M_CAMPERIPH, M_WAITOK);