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 X-Spam-Level: X-Spam-Status: No, score=-3.9 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 48900C47420 for ; Tue, 29 Sep 2020 18:12:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B7EC9208B8 for ; Tue, 29 Sep 2020 18:12:07 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="ADeTkLTg" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728113AbgI2SMG (ORCPT ); Tue, 29 Sep 2020 14:12:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43234 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727360AbgI2SMG (ORCPT ); Tue, 29 Sep 2020 14:12:06 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3D964C061755; Tue, 29 Sep 2020 11:12:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=kKuFgIMHQLymhIGJfdBnN4wchNjf3ZHyGsYgV56ZYWc=; b=ADeTkLTgeref0mmQLdfO0194Of bG9x+IaW5kPSYNfGXVes/ecKvgg0JcFkRTmAORScLPOM0GJs48fncPUKk3TfT9f2dRZId5JgvAg85 KI5Z7cWTV4IeJ5mtPXkjBaQKOBoxd5W57e37y2XcCAhaSL5muSxsPNap+DhZ/cah8V8zGiX77y4fZ aWmnTVKtoS2soBsjj06Chw3/KOL1pEeWddGIijThkZUAMe9prOZNnmYVAtY9u+KEToW8H3CGxn+ER fqnkJznTcNA9OHbmSKx2dzPb5sKGYkKGgzAnwjTwhtecC9ZyC8v0BpR23+vjRGEVjQfsXAuZEg0C0 fM4Ld4jQ==; Received: from hch by casper.infradead.org with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1kNK6W-0001zr-IN; Tue, 29 Sep 2020 18:11:56 +0000 Date: Tue, 29 Sep 2020 19:11:56 +0100 From: Christoph Hellwig To: Sherry Sun Cc: Christoph Hellwig , "sudeep.dutt@intel.com" , "ashutosh.dixit@intel.com" , "arnd@arndb.de" , "gregkh@linuxfoundation.org" , "kishon@ti.com" , "lorenzo.pieralisi@arm.com" , "linux-kernel@vger.kernel.org" , "linux-pci@vger.kernel.org" , dl-linux-imx Subject: Re: [PATCH V2 3/4] misc: vop: simply return the saved dma address instead of virt_to_phys Message-ID: <20200929181156.GA7516@infradead.org> References: <20200929084425.24052-1-sherry.sun@nxp.com> <20200929084425.24052-4-sherry.sun@nxp.com> <20200929102643.GC7784@infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Sep 29, 2020 at 01:10:12PM +0000, Sherry Sun wrote: > > > if (!offset) { > > > - *pa = virt_to_phys(vpdev->hw_ops->get_dp(vpdev)); > > > + if (vpdev->hw_ops->get_dp_dma) > > > + *pa = vpdev->hw_ops->get_dp_dma(vpdev); > > > + else { > > > + dev_err(vop_dev(vdev), "can't get device page > > physical address\n"); > > > + return -EINVAL; > > > + } > > > > I don't think we need the NULL check here. Wouldn't it also make sense to > > return the virtual and DMA address from ->get_dp instead of adding another > > method? > > Do you mean that we should only change the original ->get_dp callback to return virtual > and DMA address at the same time, instead of adding the ->get_dp_dma callback? That was my intention when writing it, yes. But it seems like most other callers don't care. Maybe move the invocation of dma_mmap_coherent into a new ->mmap helper, that way it seems like the calling code doesn't need to know about the dma_addr_t at all. That being said the layering in the code keeps puzzling me. As far as I can tell only a single instance of struct vop_driver even exists, so we might be able to kill all the indirections entirely.