From owner-svn-src-all@freebsd.org Mon Dec 23 20:41:56 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 495271D0043; Mon, 23 Dec 2019 20:41:56 +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 47hWVX1GsPz42pZ; Mon, 23 Dec 2019 20:41:56 +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 0C5CE1D592; Mon, 23 Dec 2019 20:41:56 +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 xBNKfttJ038447; Mon, 23 Dec 2019 20:41:55 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id xBNKft9X038446; Mon, 23 Dec 2019 20:41:55 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201912232041.xBNKft9X038446@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Mon, 23 Dec 2019 20:41:55 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r356042 - head/sys/cam X-SVN-Group: head X-SVN-Commit-Author: mav X-SVN-Commit-Paths: head/sys/cam X-SVN-Commit-Revision: 356042 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, 23 Dec 2019 20:41:56 -0000 Author: mav Date: Mon Dec 23 20:41:55 2019 New Revision: 356042 URL: https://svnweb.freebsd.org/changeset/base/356042 Log: 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. MFC after: 2 weeks Sponsored by: iXsystems, Inc. Modified: head/sys/cam/cam_periph.c Modified: head/sys/cam/cam_periph.c ============================================================================== --- head/sys/cam/cam_periph.c Mon Dec 23 20:23:02 2019 (r356041) +++ head/sys/cam/cam_periph.c Mon Dec 23 20:41:55 2019 (r356042) @@ -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);