Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp4455794imu; Fri, 30 Nov 2018 18:08:24 -0800 (PST) X-Google-Smtp-Source: AFSGD/XItW8qdg7UitRCBVHvxirND79CBzp6T9iTH1rjf2Bmd41FiXwKY5AH2SviNeSJODhkGmgR X-Received: by 2002:a17:902:34a:: with SMTP id 68mr8068637pld.268.1543630104663; Fri, 30 Nov 2018 18:08:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543630104; cv=none; d=google.com; s=arc-20160816; b=gQPxxOlTwumnTZzw7z5iwdzbqd1abf/9Lq+H82NBPJa838va5QFv+oQ7/m/vAEdkKV 844UiR3M3oqYEN/HuIkMzegUMdEtxAbTKqMt5IkisGOaAeGdrJ6IMzen5P7jk2jZEEEm Rm5N8leqAs6Uhwv4aVXNo+JGozVdkXXQ7yc8yV3MjiiMlRocuZPy7rIXUJKgb36rsFGi LNQIQqjx/fZlRo8DgLsyibi5COk4dF0/E6XXp1lgFFQaMP10NLHjpyjMMWw4+YRcO5DF 5NbO3vCcapdAft/q6sy8urN8r2TN1ERq0bT06QzQEzxhhLGNJ0bRduhEQeByxJsxm1nq T2ng== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=J3x8S3yC1yslH6TBAB26mUQf3aiheiLPm8MrLJeLAhY=; b=lB1YB5UGDp3Lshp+nKx2pd3CKmEUfaQpDIIfybLaj/ZQ6Ua+xFAwbbwzRzbxiq7uE6 2qvK+vZzYFmO10HJe8VenJnN0PVNiOnJggZBfBrqeD3saFaQIr/GwMlllg+llxmE2AVU Wr1j/UbWoHOvxERf0CWxa36u5cMcN4f1ajCkFGdiejR7DG6rSpvVDMainrMCDPSxs/hw iRrYkGAPYq5ztfv2zhWh3kjZbda+g3QFFTWn8VwDASF8YDoCeVN8B0NSiv7yvOJYFT7T YZbIglCD7RbNG/uta/WR2LBQNjPZLQg4ALGeOBU1/Ik2VfHHl6rZtzCbQSh4qKcMvfYz Zr5Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=CcNKhgan; 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=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q24si7282833pls.325.2018.11.30.18.08.09; Fri, 30 Nov 2018 18:08:24 -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=pass header.i=@chromium.org header.s=google header.b=CcNKhgan; 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=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726801AbeLANQs (ORCPT + 99 others); Sat, 1 Dec 2018 08:16:48 -0500 Received: from mail-yw1-f65.google.com ([209.85.161.65]:35810 "EHLO mail-yw1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726014AbeLANQs (ORCPT ); Sat, 1 Dec 2018 08:16:48 -0500 Received: by mail-yw1-f65.google.com with SMTP id h32so3130065ywk.2 for ; Fri, 30 Nov 2018 18:05:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=J3x8S3yC1yslH6TBAB26mUQf3aiheiLPm8MrLJeLAhY=; b=CcNKhganF4G2np3CWuR5bcbnVDl9fCM8iDXOpB+eGZKN7ofpMB3S8m5yvq6fBDxc3a JwJCHNksayTP+7CvyE02Mgsj8jWj9ne85c9OLceTiAikgLvSubwIzeSOkUHbNrYctYt7 +DHlDagr6ReBt/RhM0WvFijP4jK/6rkdNHMPM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=J3x8S3yC1yslH6TBAB26mUQf3aiheiLPm8MrLJeLAhY=; b=FaRT9GEvvAT+Om0J1uRkW9r4eMtWHjjp0Hz3r/PT46tjZ8VYbodpZ5nlR/YCFyCbs5 m9yeFsyRMGb0C/w12ULhGqF+SG0ev2eTcGPpzAvYgQfVrMyoyrrHf+fNK4jf+ACrrDo/ yaUjva9RPVo7LN0lenvjwMIRCUkPzPeFmmF9IqdvzuLUSStbjH//jPedyNS2BJmLMWw3 5rmYztH4cGYwD4vKJjuoAmFp1a9dNhM93jKQIit9y/2xUtokcZkmS3A/3QILA2wf8pll 0HlJ8N7X5AVYt9H6Hx5aVfn57d2JXMEq1Uu27oIy4tVgg14TeZuGN4hB5yx6d4jcJR3E otQw== X-Gm-Message-State: AA+aEWZwXSvubNdsTDvd344Wp8uFusmDYL93+lwQAYrYJAwZ1Isc1O0y obxI59gAOTcCAHikAibJF5NVxCi+m2A= X-Received: by 2002:a81:1b09:: with SMTP id b9-v6mr8070705ywb.248.1543629926773; Fri, 30 Nov 2018 18:05:26 -0800 (PST) Received: from mail-yw1-f51.google.com (mail-yw1-f51.google.com. [209.85.161.51]) by smtp.gmail.com with ESMTPSA id v191sm2114310ywc.102.2018.11.30.18.05.24 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 30 Nov 2018 18:05:25 -0800 (PST) Received: by mail-yw1-f51.google.com with SMTP id j6so3119227ywj.6 for ; Fri, 30 Nov 2018 18:05:24 -0800 (PST) X-Received: by 2002:a0d:e0c5:: with SMTP id j188mr8528170ywe.164.1543629924251; Fri, 30 Nov 2018 18:05:24 -0800 (PST) MIME-Version: 1.0 References: <20181129140315.28476-1-vivek.gautam@codeaurora.org> <20181129141429.GA22638@lst.de> <20181129155418.GB26537@lst.de> <20181129194029.GE17663@jcrouse-lnx.qualcomm.com> <06747338-b0fb-eef6-634a-0641e81ed3c1@arm.com> In-Reply-To: From: Tomasz Figa Date: Fri, 30 Nov 2018 18:05:12 -0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v3 1/1] drm: msm: Replace dma_map_sg with dma_sync_sg* To: Rob Clark , Christoph Hellwig , Robin Murphy , Vivek Gautam Cc: David Airlie , dri-devel , Linux Kernel Mailing List , freedreno , Archit Taneja , linux-arm-msm , Sean Paul Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Nov 29, 2018 at 4:23 PM Tomasz Figa wrote: > > On Thu, Nov 29, 2018 at 12:03 PM Robin Murphy wrote: > > > > On 29/11/2018 19:57, Tomasz Figa wrote: > > > On Thu, Nov 29, 2018 at 11:40 AM Jordan Crouse wrote: > > >> > > >> On Thu, Nov 29, 2018 at 01:48:15PM -0500, Rob Clark wrote: > > >>> On Thu, Nov 29, 2018 at 10:54 AM Christoph Hellwig wrote: > > >>>> > > >>>> On Thu, Nov 29, 2018 at 09:42:50AM -0500, Rob Clark wrote: > > >>>>> Maybe the thing we need to do is just implement a blacklist of > > >>>>> compatible strings for devices which should skip the automatic > > >>>>> iommu/dma hookup. Maybe a bit ugly, but it would also solve a problem > > >>>>> preventing us from enabling per-process pagetables for a5xx (where we > > >>>>> need to control the domain/context-bank that is allocated by the dma > > >>>>> api). > > >>>> > > >>>> You can detach from the dma map attachment using arm_iommu_detach_device, > > >>>> which a few drm drivers do, but I don't think this is the problem. > > >>> > > >>> I think even with detach, we wouldn't end up with the context-bank > > >>> that the gpu firmware was hard-coded to expect, and so it would > > >>> overwrite the incorrect page table address register. (I could be > > >>> mis-remembering that, Jordan spent more time looking at that. But it > > >>> was something along those lines.) > > >> > > >> Right - basically the DMA domain steals context bank 0 and the GPU is hard coded > > >> to use that context bank for pagetable switching. > > >> > > >> I believe the Tegra guys also had a similar problem with a hard coded context > > >> bank. > > > > AIUI, they don't need a specific hardware context, they just need to > > know which one they're actually using, which the domain abstraction hides. > > > > > Wait, if we detach the GPU/display struct device from the default > > > domain and attach it to a newly allocated domain, wouldn't the newly > > > allocated domain use the context bank we need? Note that we're already > > > > The arm-smmu driver doesn't, but there's no fundamental reason it > > couldn't. That should just need code to refcount domain users and > > release hardware contexts for domains with no devices currently attached. > > > > Robin. > > > > > doing that, except that we're doing it behind the back of the DMA > > > mapping subsystem, so that it keeps using the IOMMU version of the DMA > > > ops for the device and doing any mapping operations on the default > > > domain. If we ask the DMA mapping to detach, wouldn't it essentially > > > solve the problem? > > Thanks Robin. > > Still, my point is that the MSM DRM driver attaches the GPU struct > device to a new domain it allocates using iommu_domain_alloc() and it > seems to work fine, so I believe it's not the problem we're looking > into with this patch. Could we just make the MSM DRM call arch_teardown_dma_ops() and then arch_setup_dma_ops() with the `iommu` argument set to NULL and be done with it? Best regards, Tomasz