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=-5.3 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_1 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 75461C5519F for ; Sat, 14 Nov 2020 16:21:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4429F206E3 for ; Sat, 14 Nov 2020 16:21:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727026AbgKNQVO (ORCPT ); Sat, 14 Nov 2020 11:21:14 -0500 Received: from verein.lst.de ([213.95.11.211]:50538 "EHLO verein.lst.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726265AbgKNQVN (ORCPT ); Sat, 14 Nov 2020 11:21:13 -0500 Received: by verein.lst.de (Postfix, from userid 2407) id 5B36B67373; Sat, 14 Nov 2020 17:21:10 +0100 (CET) Date: Sat, 14 Nov 2020 17:21:09 +0100 From: Christoph Hellwig To: Jonathan Marek Cc: freedreno@lists.freedesktop.org, hch@lst.de, Marek Szyprowski , Robin Murphy , "open list:DMA MAPPING HELPERS" , open list Subject: Re: [RESEND PATCH v2 2/5] dma-direct: add dma_direct_bypass() to force direct ops Message-ID: <20201114162109.GA24411@lst.de> References: <20201114151717.5369-1-jonathan@marek.ca> <20201114151717.5369-3-jonathan@marek.ca> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201114151717.5369-3-jonathan@marek.ca> User-Agent: Mutt/1.5.17 (2007-11-01) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Nov 14, 2020 at 10:17:10AM -0500, Jonathan Marek wrote: > Add a function to force direct ops and disable swiotlb for a deivce. s/deivce/device/ > +#if IS_ENABLED(CONFIG_DMA_OPS_BYPASS) && !IS_ENABLED(CONFIG_ARCH_HAS_FORCE_DMA_UNENCRYPTED) overly long line. > +#if IS_ENABLED(CONFIG_DMA_OPS_BYPASS) && !IS_ENABLED(CONFIG_ARCH_HAS_FORCE_DMA_UNENCRYPTED) Again. > +int dma_direct_bypass(struct device *dev) > +{ > + int ret; > + > + ret = dma_set_mask_and_coherent(dev, DMA_BIT_MASK(64)); > + if (ret) > + return ret; > + > + dev->bus_dma_limit = DMA_BIT_MASK(64); > + dev->dma_ops_bypass = true; > + return 0; > +} > +EXPORT_SYMBOL_GPL(dma_direct_bypass); But more importantly ARCH_HAS_FORCE_DMA_UNENCRYPTED is just a compile time flag. With this you disable the functionality for all the usual x86, s390 and powerpc configs, while only a tiny number of systems for bounce buffering. But I think you can just trivialy check force_dma_unencrypted instead. We do not need an extra Kconfig symbol symbol for this trivial helper. Also the helper is misnamed and misplaced. The semantics have nothing to do with dma-direct, the fact that is uses the ops bypass is an implementation detail. It really fits into the iommu code, as it allows the driver to use the IOMMU API for IOVA management, while using the DMA API for cache management. So it should be named to reflect that, and also grow a kerneldoc comment explaining how it will be used. 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=-5.3 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_1 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 C6656C5519F for ; Sat, 14 Nov 2020 16:21:20 +0000 (UTC) Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 191F52054F for ; Sat, 14 Nov 2020 16:21:19 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 191F52054F Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=lst.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=iommu-bounces@lists.linux-foundation.org Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id A696186A1E; Sat, 14 Nov 2020 16:21:19 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id rIF8Vw46G04t; Sat, 14 Nov 2020 16:21:17 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by whitealder.osuosl.org (Postfix) with ESMTP id B9F0B869C3; Sat, 14 Nov 2020 16:21:17 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id AB7FCC088E; Sat, 14 Nov 2020 16:21:17 +0000 (UTC) Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) by lists.linuxfoundation.org (Postfix) with ESMTP id 51979C0800 for ; Sat, 14 Nov 2020 16:21:16 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 405EF869D8 for ; Sat, 14 Nov 2020 16:21:16 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Ndr8l5prmaXg for ; Sat, 14 Nov 2020 16:21:14 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from verein.lst.de (verein.lst.de [213.95.11.211]) by whitealder.osuosl.org (Postfix) with ESMTPS id AEFC9869C3 for ; Sat, 14 Nov 2020 16:21:14 +0000 (UTC) Received: by verein.lst.de (Postfix, from userid 2407) id 5B36B67373; Sat, 14 Nov 2020 17:21:10 +0100 (CET) Date: Sat, 14 Nov 2020 17:21:09 +0100 From: Christoph Hellwig To: Jonathan Marek Subject: Re: [RESEND PATCH v2 2/5] dma-direct: add dma_direct_bypass() to force direct ops Message-ID: <20201114162109.GA24411@lst.de> References: <20201114151717.5369-1-jonathan@marek.ca> <20201114151717.5369-3-jonathan@marek.ca> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20201114151717.5369-3-jonathan@marek.ca> User-Agent: Mutt/1.5.17 (2007-11-01) Cc: freedreno@lists.freedesktop.org, open list , "open list:DMA MAPPING HELPERS" , Robin Murphy , hch@lst.de X-BeenThere: iommu@lists.linux-foundation.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Development issues for Linux IOMMU support List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: iommu-bounces@lists.linux-foundation.org Sender: "iommu" On Sat, Nov 14, 2020 at 10:17:10AM -0500, Jonathan Marek wrote: > Add a function to force direct ops and disable swiotlb for a deivce. s/deivce/device/ > +#if IS_ENABLED(CONFIG_DMA_OPS_BYPASS) && !IS_ENABLED(CONFIG_ARCH_HAS_FORCE_DMA_UNENCRYPTED) overly long line. > +#if IS_ENABLED(CONFIG_DMA_OPS_BYPASS) && !IS_ENABLED(CONFIG_ARCH_HAS_FORCE_DMA_UNENCRYPTED) Again. > +int dma_direct_bypass(struct device *dev) > +{ > + int ret; > + > + ret = dma_set_mask_and_coherent(dev, DMA_BIT_MASK(64)); > + if (ret) > + return ret; > + > + dev->bus_dma_limit = DMA_BIT_MASK(64); > + dev->dma_ops_bypass = true; > + return 0; > +} > +EXPORT_SYMBOL_GPL(dma_direct_bypass); But more importantly ARCH_HAS_FORCE_DMA_UNENCRYPTED is just a compile time flag. With this you disable the functionality for all the usual x86, s390 and powerpc configs, while only a tiny number of systems for bounce buffering. But I think you can just trivialy check force_dma_unencrypted instead. We do not need an extra Kconfig symbol symbol for this trivial helper. Also the helper is misnamed and misplaced. The semantics have nothing to do with dma-direct, the fact that is uses the ops bypass is an implementation detail. It really fits into the iommu code, as it allows the driver to use the IOMMU API for IOVA management, while using the DMA API for cache management. So it should be named to reflect that, and also grow a kerneldoc comment explaining how it will be used. _______________________________________________ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu