Received: by 2002:a05:7412:3784:b0:e2:908c:2ebd with SMTP id jk4csp613947rdb; Sat, 30 Sep 2023 20:00:44 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEY7NHc1gmh6s0OsB7JJioiGumgvXxJHKVO813NakICVkud1fk45/dCg4ayPU9Ocx1cASs/ X-Received: by 2002:a92:ca45:0:b0:34d:ec9c:7321 with SMTP id q5-20020a92ca45000000b0034dec9c7321mr10176843ilo.3.1696129244567; Sat, 30 Sep 2023 20:00:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696129244; cv=none; d=google.com; s=arc-20160816; b=NAYK1KKeUWT5Obbt8/2xyuQY/1vQEGAsK6fsdFzT2LdMq5/+fp8syA034rdRkrBTFx PqE3uZPuLmdFU6k6VwptmpAKWJNFrx6qhpCMPLmpAEjea67MYR2QnnFedzJMKJ8bCSa5 azj2EixMkSP5EKweEVpYeUF50LvuvAJKUj878SGkMeRNSb6NmxCUhHkpx+potjhp1T80 EQXMrRjpbzXRfom/5BAzRb7PyvXwlIxiEzs7trkXYckoeWcRUS3TCKY0BmpZj2c5WDiV SItjsj6VUJ68zqf6nod93ONRX7ZADnUw4DIZj7bNTQgANpv23dQZa5ZEPy3TcWCjWQSZ G6YQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=qEvNfukS8XFHJKyDM3HGupHgXxrIY8XArA1Ea/F/uuE=; fh=sJcVcYHFkkIXnw78k44Q5BWD0R8rvf2C09Vw+M88s1U=; b=RVZFGOnG+QSYD6QBIydbwdy3eeo98uQhJw+Rfz7gHx1jNzVHcSYMLLGcjpvBK/ocqu Rk5GTGi2zs+jwqpxibLr6mRkIZd0AUIXwBcWETJGA5n+ReTl31as817el/c12r4DKgwt gTn33InbrnFSneDreYs3CHjuwD+6ZNk0z900zKLO+9f5/VJNw1kNl2OEMUe0s5yKYirK yTx0PKa5879R81TDOFO0CpG1KKPIDdxZefB2bn7+X0NM0D6m119OLUv7d0WML81cFui5 YtRpMZn7JxTca/Pp71ZdyHw5j0ncwARpS+coBVhv+Ak5G3i82ASYWU2OJaQrl9zH6LUZ Uisg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="i1gFBl/G"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id e21-20020a637455000000b00563f72935e3si12623085pgn.608.2023.09.30.20.00.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 30 Sep 2023 20:00:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="i1gFBl/G"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id EE76682A39AC; Sat, 30 Sep 2023 11:09:44 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234627AbjI3SJi (ORCPT + 99 others); Sat, 30 Sep 2023 14:09:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46482 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233050AbjI3SJh (ORCPT ); Sat, 30 Sep 2023 14:09:37 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 14AD9D3 for ; Sat, 30 Sep 2023 11:08:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1696097328; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=qEvNfukS8XFHJKyDM3HGupHgXxrIY8XArA1Ea/F/uuE=; b=i1gFBl/Ga0pafdNvwP0k62DwoeCeYYpOg7s2agk1U3x6VYVN84pQlauPQo8zQeygv5K/zi XQAx32BL6B6YA4gnHyOI4y41vn09OLMaJWPJcuih0ofj/NmaW4Qu9SjpXt60zR4yauywp/ vUQn92ooVa+Xs3PKemJWRZXDulhijbA= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-517-aReA7aLXMOyNU78VQoQCNw-1; Sat, 30 Sep 2023 14:08:44 -0400 X-MC-Unique: aReA7aLXMOyNU78VQoQCNw-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 4F21385A5BA; Sat, 30 Sep 2023 18:08:43 +0000 (UTC) Received: from rhel-developer-toolbox (unknown [10.2.16.53]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9CED2170E4; Sat, 30 Sep 2023 18:08:41 +0000 (UTC) Date: Sat, 30 Sep 2023 11:08:39 -0700 From: Chris Leech To: Greg Kroah-Hartman Cc: Christoph Hellwig , Rasesh Mody , Ariel Elior , Sudarsana Kalluru , Manish Chopra , Nilesh Javali , Manish Rangankar , Jerry Snitselaar , John Meneghini , Lee Duncan , Mike Christie , Hannes Reinecke , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 1/3] uio: introduce UIO_DMA_COHERENT type Message-ID: References: <20230929170023.1020032-1-cleech@redhat.com> <20230929170023.1020032-2-cleech@redhat.com> <2023093037-onion-backroom-b4ef@gregkh> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <2023093037-onion-backroom-b4ef@gregkh> X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL, SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Sat, 30 Sep 2023 11:09:45 -0700 (PDT) On Sat, Sep 30, 2023 at 09:10:10AM +0200, Greg Kroah-Hartman wrote: > On Fri, Sep 29, 2023 at 10:00:21AM -0700, Chris Leech wrote: > > Add a UIO memtype specificially for sharing dma_alloc_coherent > > memory with userspace, backed by dma_mmap_coherent. > > Are you sure that you can share this type of memory with userspace > safely? And you are saying what you are doing here, but not why you > want to do it and who will use it. > > What are the userspace implications for accessing this type of memory? Thanks for taking the time to look at this Greg. I'm trying to help Marvell fix a regression with these drivers, by figuring out what the right way to handle this type of mmap is. The dma_mmap_coherent API exists for exactly this, so I thought making the uio interface aware of it made sense. There are uio drivers sharing dma_alloc_coherent memory (uio_dmem_genirq, uio_pruss) using UIO_MEM_PHYS, but that falls apart in the face of an iommu. > > struct uio_mem { > > const char *name; > > - phys_addr_t addr; > > + union { > > + phys_addr_t addr; > > + dma_addr_t dma_addr; > > + }; > > unsigned long offs; > > resource_size_t size; > > int memtype; > > - void __iomem *internal_addr; > > + union { > > + void __iomem *internal_addr; > > + void *virtual_addr; > > + }; > > + struct device *dma_device; > > Why are you adding a new struct device here? dma_mmap_coherent wants it. > And why the unions? How are you going to verify that they are being > used correctly? What space savings are you attempting to do here and > why? I should have expected that would be questioned, I was being paranoid about mixing different pointer and address types. I can remove the unions if putting a dma_addr_t in addr going to be OK. - Chris