Received: by 2002:ac0:aa62:0:0:0:0:0 with SMTP id w31-v6csp994122ima; Sun, 21 Oct 2018 02:14:22 -0700 (PDT) X-Google-Smtp-Source: ACcGV61zcg9pbgQRHgoTjoHXNGPj4FWzYo9DHjx/+FF22HMqtcv+MdfG9oHlOT3v9UEmjn86dWBA X-Received: by 2002:a62:8f0c:: with SMTP id n12-v6mr41744962pfd.172.1540113262459; Sun, 21 Oct 2018 02:14:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540113262; cv=none; d=google.com; s=arc-20160816; b=Pv1RRbQHH/8T8+pFS1j2Td24NQTLdGLeNvLptsLvHfsFgj/1RQUCl3OIS8YjwxSCiu bCy2Vrt09V5P6UdcLO8CjzQREgY9H01xL86wh/ZJaBMwXGT05BHd0IwA5NQm6Ncx86L9 u7rJZ8CGWqVe6+FPcbmYdKAlgjBc9FTFS0nEq6ATLbVEUOxXDK6c931gsyjFK5Dukgvd I3Cj2Ud6jae5Fs0EKa7gn69vpW5Xo4B9j5fyDJNT6/BwQ7WphGtdPHTXItkctMxlLh9i noRNpkqtjVvan2MEKGiFw3PHGx1M2G9Q1gbLIGkVBwlbsREakaAV8aHQaJ1QlRS9/z54 ZMkA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=ypOBQ+Gghb4wLXXda8zoXqcy68uCnJ8ENt0OaSW5seY=; b=0klhuqLWnd26uabtdrDMFUr9Mvzk5UV9HcDQ12UXyd7KQovtY7k3YoW8sdoNH/U+p5 1cXIr5uLMUfNTQmd/RQZXzC5y95c8zPx9cyjCw03X1rATyvdcwMEvc/RkCrBsN7qSguB r2yPh+JjxIqSLGRDJY6xHDTwfH1rY8kVHB/mmacSVDXhtnwgTqW0N7+/PN+Z1N75Uf2v T1xA5ltf0yaS9KCq+liCMKGWKWbb74P8MlrINp7d9h1diyw28saaJ5kH4ropFZzt96vO bGKvP0q+5WL+ChfNTLcHFk+lQBx/x2YQEB9x7TR4JspsdWULv053f3JLGfTTxlqmsCNY FmKw== ARC-Authentication-Results: i=1; mx.google.com; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b27-v6si32056281pgb.156.2018.10.21.02.14.04; Sun, 21 Oct 2018 02:14:22 -0700 (PDT) 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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727336AbeJUR1V (ORCPT + 99 others); Sun, 21 Oct 2018 13:27:21 -0400 Received: from mail-wr1-f66.google.com ([209.85.221.66]:45103 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726980AbeJUR1V (ORCPT ); Sun, 21 Oct 2018 13:27:21 -0400 Received: by mail-wr1-f66.google.com with SMTP id f17-v6so9891788wrs.12 for ; Sun, 21 Oct 2018 02:13:41 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=ypOBQ+Gghb4wLXXda8zoXqcy68uCnJ8ENt0OaSW5seY=; b=APQpdL9cfZ5TG7G394GIDUdHCcyfGsS/We4iCA4R8JJswo/dyZQWVxCUN+eLCXagLj 4h0WloDHXQXnR0JEzhiik1GqDfc8lfCPr747Df3LZb9qc9bQg5KQiYkZKHFgzqszIdnk r1LCbWVqF56mR5igbgUdL2EktkvGjiwMr8fFQPcV2t714FPKhy+Oln2qw+fRcZdPijdZ qbQEFepcRHRG1mc6CaTkEASEo4Dh50tZHYoT4Z6Hc9DVZQvoBIShYkvrrR5AqrrPu0QG i3zRJ2a/+cU0sGgHAxfZTUjJWgrFwAG0mvLEsUroemDoiJ0/d9tFr+JTXWI4aeFEYOPQ HmHw== X-Gm-Message-State: ABuFfojMbvf2x6IZxj5bRkoXhrCxQITnsebvVnoDaDqEptgcIwbX8h7x gQqVH1DsZra1ovrvKyZgeiTRHg== X-Received: by 2002:adf:e94b:: with SMTP id m11-v6mr41708621wrn.126.1540113221258; Sun, 21 Oct 2018 02:13:41 -0700 (PDT) Received: from [10.15.242.27] ([109.144.221.236]) by smtp.gmail.com with ESMTPSA id k12-v6sm1378645wro.42.2018.10.21.02.13.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 21 Oct 2018 02:13:40 -0700 (PDT) Subject: Re: [PATCH] staging: ion: Rework ion_map_dma_buf() to minimize re-mapping To: John Stultz Cc: lkml , Beata Michalska , Matt Szczesiak , Anders Pedersen , John Reitan , Liam Mark , Sumit Semwal , Greg Kroah-Hartman , Todd Kjos , Martijn Coenen , dri-devel References: <1539214413-26173-1-git-send-email-john.stultz@linaro.org> <7534ca1d-f874-7809-6125-d9fc72f70e39@redhat.com> From: Laura Abbott Message-ID: Date: Sun, 21 Oct 2018 02:13:39 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 10/17/2018 07:53 PM, John Stultz wrote: > On Fri, Oct 12, 2018 at 10:51 AM, Laura Abbott wrote: >> >> I suspect most of the cost of the dma_map/dma_unmap is from the >> cache flushing and not the actual mapping operations. If this >> is the case, another option might be to figure out how to >> incorporate dma_attrs so drivers can use DMA_ATTR_SKIP_CPU_SYNC >> to decide when they actually want to sync. > > So just to confirm on this point, I basically tested the following > change (whitespace corrupt, sorry): > > diff --git a/drivers/staging/android/ion/ion.c > b/drivers/staging/android/ion/ion.c > index 24cb666..e76b0e2 100644 > --- a/drivers/staging/android/ion/ion.c > +++ b/drivers/staging/android/ion/ion.c > @@ -273,8 +273,8 @@ static struct sg_table *ion_map_dma_buf(struct > dma_buf_attachment *attachment, > > table = a->table; > > - if (!dma_map_sg(attachment->dev, table->sgl, table->nents, > - direction)) > + if (!dma_map_sg_attrs(attachment->dev, table->sgl, table->nents, > + direction, DMA_ATTR_SKIP_CPU_SYNC)) > return ERR_PTR(-ENOMEM); > > return table; > @@ -284,7 +284,7 @@ static void ion_unmap_dma_buf(struct > dma_buf_attachment *attachment, > struct sg_table *table, > enum dma_data_direction direction) > { > - dma_unmap_sg(attachment->dev, table->sgl, table->nents, direction); > + dma_unmap_sg_attrs(attachment->dev, table->sgl, table->nents, > direction, DMA_ATTR_SKIP_CPU_SYNC); > } > > static int ion_mmap(struct dma_buf *dmabuf, struct vm_area_struct *vma) > > > And indeed, that performed similarly to the pre 4.12 ION code (and it > also had some of the same image caching error garbage we've seen w/ > 4.9 era kernels, which my earlier patch didn't have). > > So yes, it seems having some way to conditionally skip cpu sync would > be good. Though I'm not sure what sort of interface to using this you > might have in mind? > I hadn't quite gotten anything fully formed but I think solving this will require changes at the dma-buf layer. One idea I had was allowing dma_attrs to be set per attachment, the other was extending the dma_buf_map_attachment to take an attrs argument. I'm at OSSEU this week but I didn't want to forget about this. I'll see if I can turn this into a more coherent proposal unless you get to it first. Thanks, Laura > thanks > -john >