Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751477AbdILOIo (ORCPT ); Tue, 12 Sep 2017 10:08:44 -0400 Received: from mail-bn3nam01on0069.outbound.protection.outlook.com ([104.47.33.69]:60864 "EHLO NAM01-BN3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751332AbdILOIm (ORCPT ); Tue, 12 Sep 2017 10:08:42 -0400 Authentication-Results: spf=pass (sender IP is 204.128.141.23) smtp.mailfrom=infinera.com; linuxfoundation.org; dkim=none (message not signed) header.d=none;linuxfoundation.org; dmarc=bestguesspass action=none header.from=infinera.com; From: Joakim Tjernlund To: "gregkh@linuxfoundation.org" CC: "linux-kernel@vger.kernel.org" Subject: Re: uio_dmem_genirq.c and DMA mapping to user space ? Thread-Topic: uio_dmem_genirq.c and DMA mapping to user space ? Thread-Index: AQHTK8E8HLPFFLcg7UGmHa5JtgT7eKKxpZEAgAAZd4A= Date: Tue, 12 Sep 2017 14:08:27 +0000 Message-ID: <1505225305.31322.113.camel@infinera.com> References: <1505218705.31322.108.camel@infinera.com> <20170912123716.GA19626@kroah.com> In-Reply-To: <20170912123716.GA19626@kroah.com> Accept-Language: en-GB, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-messagesentrepresentingtype: 1 x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [10.100.99.93] Content-Type: text/plain; charset="iso-8859-15" Content-ID: MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-Forefront-Antispam-Report: CIP:204.128.141.23;IPV:NLI;CTRY:US;EFV:NLI;SFV:NSPM;SFS:(10009020)(6009001)(2980300002)(438002)(199003)(24454002)(377424004)(189002)(4326008)(50986999)(305945005)(50466002)(246002)(77096006)(72206003)(7636002)(7736002)(1730700003)(8676002)(6116002)(86362001)(23756003)(5660300001)(189998001)(3846002)(316002)(356003)(54356999)(76176999)(2900100001)(102836003)(478600001)(47776003)(14454004)(2950100002)(6916009)(6246003)(103116003)(36756003)(53416004)(106466001)(2351001)(5640700003)(229853002)(33646002)(8936002)(8746002)(110136004)(2906002)(2501003);DIR:OUT;SFP:1101;SCL:1;SRVR:BY2PR10MB0535;H:owa.infinera.com;FPR:;SPF:Pass;PTR:outgoingmail1.infinera.com;A:1;MX:1;LANG:en; X-Microsoft-Exchange-Diagnostics: 1;BY2NAM03FT035;1:9+k9SFX90l40pOCd6Q3z2BiKHoJkY4soioMj/r96RgLqRe5xwfFyvZVAqHVpXyxtnULedfnr9LwudETACYQGIqxeswQh1rRGhDV6iIZXuRaV3c12Iq/y36EqczGIa6Bn X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 560197d3-a7f2-4432-737e-08d4f9e7bde6 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(22001)(300000502095)(300135100095)(2017030254152)(8251501002)(300000503095)(300135400095)(2017052603199)(201703131423075)(201703031133081)(201702281549075)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095);SRVR:BY2PR10MB0535; X-Microsoft-Exchange-Diagnostics: 1;BY2PR10MB0535;3:5i2024Z5ilzRmGMYKVE1DOfNsArmlOtyWlFu1zBCGODPmwhZEO+TcxVcbNf6td5xMSq3MqOrV6SiFiuW9Zuv0uxED/QLlnT+W4rSmNwrrXLLT40clczBZzfHtY801JHVgdJSUmTEJdXUTvdGnfj6MOaQYnA/IVAmDr3Dh/K/ifOmfY8YmvdcgiS17tDx05vqv+xgo8MXFoud5Wy5QYgjCALV1VjQ8w/Kb9vLP99KFMAuy2GU2WsFcmNCDpsSIOEUfpuyp0or6t3wvqU2Rn0hf8GNXT8bU1wQZRcP6oDtA04m6P5PoCm1zw2y12OVy9EPy/7G6xU4ejiui6tvRSlBkYyI3f+afcrrbr63So+w+IY=;25:AypOb4rqt2dipRR4R9ldL2DkrPILkHz/tM+X0yi/XIFOyGcYCK31G3rYHgoytntKHk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ztKBWCnIdQQtCdaIzA1BQbCXrqO3GFaFT6AZ64n8Ztmzj7PYgxfPt8jWelJPwRxefe+F/5fGR7M+nSED6LQt/iptM9h0HO6TYC/INyJZ5BaQF5XQWKr9PswlDKGpKvDXMur5EoLtjVIB6+Gx6Ss52gOoi7wDqsgaiSDPZAkEJZY1/+JAMpy7+rxzWb3w2yoMYYrRm5vy X-Exchange-Antispam-Report-Test: UriScan:; X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(2401047)(8121501046)(5005006)(10201501046)(100000703101)(100105400095)(3002001)(93006095)(93004095)(6041248)(20161123564025)(20161123558100)(20161123555025)(20161123560025)(20161123562025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095);SRVR:BY2PR10MB0535;BCL:0;PCL:0;RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095);SRVR:BY2PR10MB0535; X-Forefront-PRVS: 042857DBB5 X-Microsoft-Exchange-Diagnostics: =?iso-8859-15?Q?1;BY2PR10MB0535;23:wBcuiHo9R17ojzyshFG/x38/JbZRGCPjHlmwFA?= =?iso-8859-15?Q?N9AJRdE0JKkL+VgiTDZgD6Yxv5TyTNlnM1l30AEO8O2/RmKzIMUzBu7MV?= =?iso-8859-15?Q?IUOGoH68JV5Y4Ux3Md1r7+31HqvPDnWP2qexx3epJ5aKWAezdhGw8QqrK?= =?iso-8859-15?Q?NyUtNPU6PrNAyEAEZVva+KuBZI+udZofDqmc2Ll3T5EXpXisKERSJL+68?= =?iso-8859-15?Q?HzvSAlIDfc1T1S3nRC8dHXO6Nm1aJp1/uovn67/LToQ82/4PmXG6ar//Q?= =?iso-8859-15?Q?iUzxp1erKHn+B2HUoOqd2ECP/f0J9bVNiKUc2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Aem6QbRxIpGk06+FpyuN?= X-Microsoft-Exchange-Diagnostics: 1;BY2PR10MB0535;6:8fUaY2V0tIxlwxiPkfELxIec2sgNW5lCERTx5id/RmUNQMNstIA/qpQBjvlt2n22hDw3ENGJpuoDkYwem1BVLtMbKp0Kd7WdyQEAYvsdLryei8YkyIoTnGCnuqx1dZ+MKfQkJxhrSLB3C43zTj1ua/5w5ytd5YFQwrJBTsBOG8Yk14GmbPhYgzlaIqYAOeCmwf8Zm84k9PIS1Wxgra9B8d2WiSaloBQauftFBZMkGjBowNXiWlaaZvh3s5JcboR7poWtZQhA6b6og6XNy+FlPVwcDMqhkbEcCZwDa9HHMFoD4NOhlDsnT58BAF4sk0XGsfHgx6SU1+x3cLMOLhdE8g==;5:/lzAlcQFEoE2dn6lJvmNDq7fakf2IIXx/0AWvLlsQYbfjl9gIvDZnuYeVHlNES20jsuQPMkf+m81fg/0uUWCRHj8AyBkQKIO8A1PEmJqLyBYDsvyEaY6406NzfbpPStZzz6ov+NJelKzoUzG+V5+dQ==;24:fdx7gKN65yoGjqHkQOeez41LCH3379a4zDSjyo0F0H4hAjctiomvxLWHxMRN0zTbscx21x/rlQ/FWmCH4hwO0Yrsjb66VFhapQQdeaBg7ak=;7:wkHg3i/YX4vZAM3+r4+jVz376DzmgwZcyEfFEW+kh9NNMZYHnADPkWNMRciVHcCMFr5n8PqunIiWyVxjnJiGpUS+ozoxOcxYEWRo3bAhXkdGqKU5+0qrPBcfMl5+FeTmu8Ov8yNxp0AzNVjoukS6kho7dBzFaReBx8d/FuuF7cxsuDjlJ3N7UUM+s7JHh5Gn5GsSyoC86xyocLefakcbYcr2BKudzoB16f1cTGz9VBQ= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: infinera.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Sep 2017 14:08:28.4528 (UTC) X-MS-Exchange-CrossTenant-Id: 285643de-5f5b-4b03-a153-0ae2dc8aaf77 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=285643de-5f5b-4b03-a153-0ae2dc8aaf77;Ip=[204.128.141.23];Helo=[owa.infinera.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY2PR10MB0535 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by nfs id v8CE8ofA031105 Content-Length: 2187 Lines: 48 On Tue, 2017-09-12 at 05:37 -0700, gregkh@linuxfoundation.org wrote: > On Tue, Sep 12, 2017 at 12:18:27PM +0000, Joakim Tjernlund wrote: > > Hi > > > > I am trying to use the uio_dmem_genirq.c driver for allocating DMA memory to a PCI device > > using the uio_pci_generic.c driver. > > > > I got as far as defining an UIO dev containing only Dynamic DMA memory and > > now I am stuck. > > I can see how DMA memory is allocated when opening the /dev/uio device but I cannot > > figure out how to mmap this memory to User space as well so I can share this > > memory with the PCI device and my user space driver. > > > > What am I missing? > > Why can't you call mmap() on the fd you created when you opened > /dev/uio? What happens when you do that? Haven't tried that as I figured it had to be something similar as UIO PCI where you can have several memory regions and therefore must mmap one of the resource files under sys: # > pwd /sys/bus/pci/drivers/uio_pci_generic/0000:01:00.0/uio/uio8/device leipzig device # cat /sys/devices/platform/ffe250000.pcie/pci0000:00/0000:00:00.0/0000:01:00.0/resource 0x0000000c10000000 0x0000000c11ffffff 0x0000000000140204 0x0000000000000000 0x0000000000000000 0x0000000000000000 0x0000000000000000 0x0000000000000000 0x0000000000000000 0x0000000000000000 0x0000000000000000 0x0000000000000000 0x0000000000000000 0x0000000000000000 0x0000000000000000 0x0000000000000000 0x0000000000000000 0x0000000000000000 0x0000000000000000 0x0000000000000000 0x0000000000000000 leipzig device # pwd /sys/bus/pci/drivers/uio_pci_generic/0000:01:00.0/uio/uio8/device leipzig device # cat resource 0x0000000c10000000 0x0000000c11ffffff 0x0000000000140204 0x0000000000000000 0x0000000000000000 0x0000000000000000 0x0000000000000000 0x0000000000000000 0x0000000000000000 0x0000000000000000 0x0000000000000000 0x0000000000000000 0x0000000000000000 0x0000000000000000 0x0000000000000000 0x0000000000000000 0x0000000000000000 0x0000000000000000 0x0000000000000000 0x0000000000000000 0x0000000000000000 leipzig device # ls resource* resource resource0 Here one opens and mmaps resource0 to get at 0x0000000c10000000 0x0000000c11ffffff 0x0000000000140204 Jocke