From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id D2296C77B75 for ; Mon, 15 May 2023 16:08:53 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 242E9900004; Mon, 15 May 2023 12:08:53 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1F304900002; Mon, 15 May 2023 12:08:53 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0E29D900004; Mon, 15 May 2023 12:08:53 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id E8216900002 for ; Mon, 15 May 2023 12:08:52 -0400 (EDT) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id A4DF2AF264 for ; Mon, 15 May 2023 16:08:52 +0000 (UTC) X-FDA: 80792972904.15.853CCA8 Received: from eu-smtp-delivery-151.mimecast.com (eu-smtp-delivery-151.mimecast.com [185.58.86.151]) by imf26.hostedemail.com (Postfix) with ESMTP id 687DC14008F for ; Mon, 15 May 2023 16:07:12 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=none; spf=pass (imf26.hostedemail.com: domain of david.laight@aculab.com designates 185.58.86.151 as permitted sender) smtp.mailfrom=david.laight@aculab.com; dmarc=pass (policy=none) header.from=aculab.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1684166835; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=VeRP4PkOmik3IDu1LLw/NX+fm1rfvIDsU/WNwg/iXAo=; b=rmMfxG7l7S8rDZVpgnddnBUfwzkMHu4+EM+f8itO1+OH3749Bp3QlL2jw+1gDDaXOpZAlH f9BkqX6Dqw1PA2f2SgSmCCz1PTEOlaVM2fflLDMyd85zVzbVUvGNrOqzbqjibqJxQsRKUU rUc2zZMcpt2rb4G8ILSofuF0h0T1VpY= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=none; spf=pass (imf26.hostedemail.com: domain of david.laight@aculab.com designates 185.58.86.151 as permitted sender) smtp.mailfrom=david.laight@aculab.com; dmarc=pass (policy=none) header.from=aculab.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1684166835; a=rsa-sha256; cv=none; b=fvOC/QABOVV+XJLCm1dfsO/+GyA1n5Fy2GCfTfUjPT1idRlqP9Ioah1PCLpL9Z23xxl5CK mF6oxLrVwwJchh8GUH+oUBFam2VIMBRdcbyTSaTMYBUac6EeXbe4vjwBX+npwQF/0EVk6h 1oIR/M0OnS6uHVT4ez+KwcRbnLnJRrE= Received: from AcuMS.aculab.com (156.67.243.121 [156.67.243.121]) by relay.mimecast.com with ESMTP with both STARTTLS and AUTH (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id uk-mta-143-uRU4qE7IPxOBaj4CStDw6Q-1; Mon, 15 May 2023 17:07:06 +0100 X-MC-Unique: uRU4qE7IPxOBaj4CStDw6Q-1 Received: from AcuMS.Aculab.com (10.202.163.6) by AcuMS.aculab.com (10.202.163.6) with Microsoft SMTP Server (TLS) id 15.0.1497.48; Mon, 15 May 2023 17:07:01 +0100 Received: from AcuMS.Aculab.com ([::1]) by AcuMS.aculab.com ([::1]) with mapi id 15.00.1497.048; Mon, 15 May 2023 17:07:01 +0100 From: David Laight To: 'Ruihan Li' , "linux-mm@kvack.org" , "linux-usb@vger.kernel.org" CC: "linux-kernel@vger.kernel.org" , "Pasha Tatashin" , David Hildenbrand , Matthew Wilcox , Andrew Morton , Christoph Hellwig , "Alan Stern" , Greg Kroah-Hartman , "stable@vger.kernel.org" Subject: RE: [PATCH v2 2/4] usb: usbfs: Use consistent mmap functions Thread-Topic: [PATCH v2 2/4] usb: usbfs: Use consistent mmap functions Thread-Index: AQHZhy64xAEf6PI6fk2CO41aswORIq9be+FQ Date: Mon, 15 May 2023 16:07:01 +0000 Message-ID: <2b6cb73d2cd14a46b7e4553566030b22@AcuMS.aculab.com> References: <20230515130958.32471-1-lrh2000@pku.edu.cn> <20230515130958.32471-3-lrh2000@pku.edu.cn> In-Reply-To: <20230515130958.32471-3-lrh2000@pku.edu.cn> Accept-Language: en-GB, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [10.202.205.107] MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: aculab.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Rspam-User: X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: 687DC14008F X-Stat-Signature: trp1tbbcgrtmy7xt1hnfx6ce53por5of X-HE-Tag: 1684166832-45126 X-HE-Meta: U2FsdGVkX1+EiBmrkL1VCxakiU0ZttiA28Oo71MehEzxJK554rU1WQsJWDgP4vft7HVmcOqsXM1jQYUiIC2JBfsmXi9ULPe+M16ewDkIOzSkJJSD6DBH3VWozR9wtFGPfqplHH5rtpXAUCWwXS1qBSx+alTfrRCYlMZofXCMjLLrqCCkWnNjU1IyaVqWFDjYCD86Orf00wGiWcTItERpfJ5ulbAjndNkkCDV59wboFAYkgOy5H1vkX53NkwZfF4xkRWb0I5ktbCeE9CPUt9QX+7e46CXZt43K7LzU4jBELZ3iyRLsL3ki9nfS4WgYTAXae7nBtbFxDFuyOwYpoTHCRywqip4xJjHE2CYHwZVcyuy48EcyzlMK0lYZMlBrm1TIYSWH8aUwBSofWjh2fDCQVj14D7rqduQGkIz0gSpsR77GHQUF3vQCNKzIVYK2LDhxX+/A6ClGOMl0Ka/uerPL4aWN+uXSsRDmPMco0fo8+TOtNiy3jmYe0PgC2dGM1MlsGTMRPn8Jute1lydDoX0WXyv0SJ3ty+a9I7OFDo8W9EuDvcys4TsBxQBw74wZ6cnpC2vEde8jWYwVY7rXrgCMQfth04iNW6Od5FPnZrUbbSDjxxBf1bdUTlu2lGYdcdWWSqw/CadLNZ7lRwUefUc5+/pEkQ9e4tEUDS9D2zKySUJM7Tt3fU6M7qvcOP2OO7sb9G3FQiNfJP3a1DrmF0VrDSEnVjhaUO9cG3VdSxQVeBcyc5mhloq83o+OVZvFdJceVPgi7Ghe42aQ5LfCfHV3Dgi8XfpI4gedsWAQbUaJXpRyF/r8t2DAWCM0lh7+poVoboh+/thbVD7itsYQZzHNcdymE4nuRzY15siC/w/1V+2Hts8SFrMReR0cFiXP179/VgX95fBycj738y+SY+IfOlYCRaNss2m+E8HZNx9NUCQ/sRe1CTYBdzHJKEM481e374a5g3H1rzIjcRt529 ZrPuJmKJ wujN/GX7itCzQWJZW2odXww3yc/Np0WMrkRaSKhmhY1imbtlizQN4UNNBRlsd0I2GBO/OF+bvfZ+80dMsjyk+TvuWVZv7vI0z/GYSSkOCmM4Vf6n4Gcz111pNSOGqvzJcBPSUBsmovTyVcujS5tJ4JeaK0RTLq54g98x1VYod16108WyR6AH88JNstFmcvqFw7/K2/7+3l7qnF0CUZ0/enfmTWW4PR/7GqBtmyx6zTGir1dM= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: From: Ruihan Li > Sent: 15 May 2023 14:10 >=20 > When hcd->localmem_pool is non-null, localmem_pool is used to allocate > DMA memory. In this case, the dma address will be properly returned (in > dma_handle), and dma_mmap_coherent should be used to map this memory > into the user space. However, the current implementation uses > pfn_remap_range, which is supposed to map normal pages. I've an (out of tree) driver that does the same. Am I right in thinking that this does still work? I can't change the driver to use dma_map_coherent() because it doesn't let me mmap from a page offset within a 16k allocation. In this case the memory area is an 8MB shared transfer area to an FPGA PCIe target sparsely filled with 16kB allocation (max 512 allocs). The discontinuous physical memory blocks appear as logically contiguous to both the FPGA logic and when mapped to userspace. (But not to driver code.) I don't really want to expose the 16k allocation size to userspace. If we need more than 8MB then the allocation size would need changing. =09David - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1= PT, UK Registration No: 1397386 (Wales)