Received: by 2002:ac0:8c8e:0:0:0:0:0 with SMTP id r14csp1120443ima; Wed, 6 Feb 2019 14:09:40 -0800 (PST) X-Google-Smtp-Source: AHgI3IY8bjfZ3fyMt9j0G5Es3vf0+vE0deNB4E55ndQbbRD9pP9ZSlR5GVauCjOGLmZ63i9bQWSp X-Received: by 2002:aa7:80d7:: with SMTP id a23mr12622569pfn.86.1549490980790; Wed, 06 Feb 2019 14:09:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549490980; cv=none; d=google.com; s=arc-20160816; b=S/TBzfOp8q7z+ADyv4eccH1ARsT+6AlNS1waed3awSWb1DvUpQIAovzbRMwe1ky2g9 FuITEKexewHVGpaS843UDG0YVQnr1JILmX2NDkG92TNNA//Th0vvYnUvsjF3UObXqM2t Wn27D4a64ynx9p3VDSq1OUN3KzVL/O1gxndfbJ74ycj0Jsi0cUPsx/JWGo5nbssheUCY RcBaN+uYlPMOpIvPSMubVb4EeCJkfJYRmlvIcAZ1kH2IinTch4o8B1i5B15e2HT5D6e1 zHHzBfd+brSDqWvNsObh4qLPpZRwG9OtTxKSZk2hRvHsZNDOrXt7aKWWvz/kzkGdympC 4gcQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:content-disposition :mime-version:message-id:subject:cc:to:from:date:dkim-signature; bh=DH1GMO7ONcewLD5Iwy3rwHZsxjWkQFcnRV0dI8v2FAY=; b=MSC2oG+RuOd2i8nz4Ck1pHeN1v55BU7jTDJiSgvaTG72Y/9RJxFgZYu6brJnHqFrxi NjDWKxuoQ3yEi+V60/+8AWwyjToIwWMA6UGrtGvDXr9DaA0BoEBuoCTxuegHLOmFTHJm LDxg/tbxVHbbhjQOsPDNZ892ifPx9fS4Nd3tD+3NyWEHUbvmNzK+Y9u8Qj9gFLrhNyuc MMN6l8L/CNZ+sy9OuYa/FuPc0ymLWVVrmvre0RAHwKarYOHxvTj37f7ZpfVP3BHDR139 U28ZNAps/aXOWJoN+9rgh8/8uBFIf9pxHQD7dik4IHY5En/dG+JPwp11TGMoWsvfFRWf fcmA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=bAb3R2pz; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f8si6817362pgb.364.2019.02.06.14.09.13; Wed, 06 Feb 2019 14:09:40 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=bAb3R2pz; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726716AbfBFWIh (ORCPT + 99 others); Wed, 6 Feb 2019 17:08:37 -0500 Received: from mail-pl1-f193.google.com ([209.85.214.193]:44987 "EHLO mail-pl1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726393AbfBFWIg (ORCPT ); Wed, 6 Feb 2019 17:08:36 -0500 Received: by mail-pl1-f193.google.com with SMTP id p4so3753097plq.11 for ; Wed, 06 Feb 2019 14:08:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:date:from:to:cc:subject:message-id:mime-version :content-disposition:user-agent; bh=DH1GMO7ONcewLD5Iwy3rwHZsxjWkQFcnRV0dI8v2FAY=; b=bAb3R2pzhlaZVEi2ZtuYpSPkafehJ9X2H+B5lbllR0bCYCb9ep9Kzy9cY7faI4Ul6G kvgyVwSWGenY3Z8keeJ/6dSxOFiyMLoXF7/4cg08ApAB5pGSZaIe/dfPGqi8Tmde4Bqh Z6TTA4YbRotltk0RfIO+eO2E5RcGlqWWJ+XbGhjISowWNhkGpJPsPa5aqz4amHOPNZxU Q15ruPJYNmHE47FiNv93c6w3iBmzohKq8N+hYXtAqsby0Z0gGfqXCW9VhRHXY2Gn3Wk/ cT+01Smh9QPrJT71xtBiK7RDzdPnI8H9UpcmhF+01KtrN6ErIVew2Nk4POEGMx73twnn gYvw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :mime-version:content-disposition:user-agent; bh=DH1GMO7ONcewLD5Iwy3rwHZsxjWkQFcnRV0dI8v2FAY=; b=eD2PiASfGABxD655CGtnxPsVWd9qNDb6KL2R+n2WbErMTo/Y0WN+P7pAG1e4R0hLAG kBXkaNL4/ovEu+2wJQ/FecayHOiJ9mcnDSiWAbt1UqmG15g7/QRSEYynWadV5xDe5oBu xTfplvTgY7e6pCrjbXzk/xZuWml7003hq2pWDuUM1w71svUJ1WQdfccTOao120pXlPuw QmAK3p/hXuVck2lwIxhkcfjaR3SnTGfzAakR4rbRiTWXoXPfB0JNUTzM7bFpUinE80mu Z0kPbA6StZCcolUhz1/6MSJfMuUh6HApNf5acL65yqHlarNcTzIg/dNV/E+qV/GgiW+x cpLw== X-Gm-Message-State: AHQUAuYWuot+VCcYI8eTvrJRKV+fLmi2RThZgJVnTHpUNQRYGShro33O qlsZb1S4n7MturZeGcExakXo2Npu X-Received: by 2002:a17:902:c05:: with SMTP id 5mr13065787pls.155.1549490916065; Wed, 06 Feb 2019 14:08:36 -0800 (PST) Received: from localhost ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id h128sm9285846pgc.15.2019.02.06.14.08.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 06 Feb 2019 14:08:34 -0800 (PST) Date: Wed, 6 Feb 2019 14:08:33 -0800 From: Guenter Roeck To: Thierry Reding Cc: linux-kernel@vger.kernel.org Subject: Re: [PATCH] gpu: host1x: Use direct DMA with IOMMU API usage Message-ID: <20190206220833.GA20747@roeck-us.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Feb 01, 2019 at 02:28:26PM +0100, Thierry Reding wrote: > If we use the IOMMU API directly to map buffers into host1x' IOVA space, > we must make sure that the DMA API doesn't already set up a mapping, or > else translation will fail. > > The direct DMA API allows us to allocate memory that will not be mapped > through an IOMMU automatically. > > Reviewed-by: Dmitry Osipenko > Signed-off-by: Thierry Reding arm64:defconfig: ERROR: "dma_direct_free" [drivers/gpu/host1x/host1x.ko] undefined! ERROR: "dma_direct_alloc" [drivers/gpu/host1x/host1x.ko] undefined! Guenter > --- > drivers/gpu/host1x/cdma.c | 11 ++++++++--- > 1 file changed, 8 insertions(+), 3 deletions(-) > > diff --git a/drivers/gpu/host1x/cdma.c b/drivers/gpu/host1x/cdma.c > index 64099cc1964b..e22c1133a4c5 100644 > --- a/drivers/gpu/host1x/cdma.c > +++ b/drivers/gpu/host1x/cdma.c > @@ -19,6 +19,7 @@ > > #include > #include > +#include > #include > #include > #include > @@ -70,6 +71,7 @@ static void host1x_pushbuffer_destroy(struct push_buffer *pb) > */ > static int host1x_pushbuffer_init(struct push_buffer *pb) > { > + unsigned long attrs = DMA_ATTR_WRITE_COMBINE; > struct host1x_cdma *cdma = pb_to_cdma(pb); > struct host1x *host1x = cdma_to_host1x(cdma); > struct iova *alloc; > @@ -91,8 +93,8 @@ static int host1x_pushbuffer_init(struct push_buffer *pb) > > size = iova_align(&host1x->iova, size); > > - pb->mapped = dma_alloc_wc(host1x->dev, size, &pb->phys, > - GFP_KERNEL); > + pb->mapped = dma_direct_alloc(host1x->dev, size, &pb->phys, > + GFP_KERNEL, attrs); > if (!pb->mapped) > return -ENOMEM; > > @@ -127,7 +129,10 @@ static int host1x_pushbuffer_init(struct push_buffer *pb) > iommu_free_iova: > __free_iova(&host1x->iova, alloc); > iommu_free_mem: > - dma_free_wc(host1x->dev, size, pb->mapped, pb->phys); > + if (host1x->domain) > + dma_direct_free(host1x->dev, size, pb->mapped, pb->phys, attrs); > + else > + dma_free_wc(host1x->dev, size, pb->mapped, pb->phys); > > return err; > } > -- > 2.7.4