Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp1969842pxb; Sat, 14 Nov 2020 08:24:47 -0800 (PST) X-Google-Smtp-Source: ABdhPJy1wWDfi5Nj6Ycd4IN6MjlUxi6F0Ck2y6zlbPtkpdFtNMhx0NlOI1+C8J0VFjry6cZrn8Rq X-Received: by 2002:a17:906:8142:: with SMTP id z2mr6966333ejw.30.1605371087301; Sat, 14 Nov 2020 08:24:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605371087; cv=none; d=google.com; s=arc-20160816; b=BSDdaGMe8l7feFnPJbAUUCLQHZp0Fwk8CTwDjBWA0kJ+Y6ZhRhSjkDc1XipCOl13l7 YbpK9HNqfmDDzaRt9AUHEwGNy3kmmgzUVyfxCFv/vfUgRNQ4JU/hpkoot0beRpzCXVBW lX2/f2MVfC69HXsXZtxk7QspOQO0Ou3k3hWaArIy/gluaAKS6nopuDUeWEM9e3UiUf5t M3FZaVXJW95kdZSNuTfSARqPmbnLjtMNTlX1bSkUsnh95KCE4lDkUXMYPPxAexkRPpCH iBRVI55bkHf/+x26j/HWPtDQ4T32J8jUkqA3ieSzyh//Jq9bM+ctXq0qv859crJnlIYJ +e6g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=fHip5fQTnTSvBBHFhQMGXD1G2FfwiW1kViDP75ZHA64=; b=f/ciSo958LifbneBoX+5I6WafgrukKU0H79xN3aWTf9h1PhTKSR02PBLzsohcTEvA0 8VwHwqKuwF/c+sVRXh4Y4SGCB1+VAGWuqCptYTNF2uijA3b8PyxOGyD19NMV86bj6UsF T6N+Cd1VBoUpmCP4kPjsxp4JQpJtUA+op57eBxOqhFnmro78qBB3481FaflWTWmHkM0u j2NWsKk2LFw97MuNyRCUH+oBZj4iAEy7cuZuafr4Yh5zAkrElXSadoM+IjnnQaJHQ3p7 1mi+fS5g+i7LNUItBbH8MoeOMPfqRQQGBnPsG+hKT0EBZdXU4PM9rTTtnEneXNxdtunh wM4g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n12si8043848eje.452.2020.11.14.08.24.23; Sat, 14 Nov 2020 08:24:47 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727014AbgKNQVN (ORCPT + 99 others); Sat, 14 Nov 2020 11:21:13 -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.