Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp1405434pxk; Thu, 10 Sep 2020 14:38:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwWBG8T8+A/Mwt3q093qkGYHdY4ShRBqCHSYK5+KA/rHOcxngStkEHAIo7LmO/JX2GBkvi6 X-Received: by 2002:a05:6402:2d9:: with SMTP id b25mr11640358edx.131.1599773915688; Thu, 10 Sep 2020 14:38:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599773915; cv=none; d=google.com; s=arc-20160816; b=ILVBoCpwL6VXWitCD3UrYo9QE30mS0c0a+c79YbwLgz1LURqx8zxe+AMnHxoOLxSwt YLAOVmzQsljY6YPSGUTr40sgCwhTGf4q/zR4gzQFAs2udVPXCsa5CnjqnY/8mGjhDL3t B/QoaC8XgZgfihB32mcZUivBz2nELClNS74HzYOLNKEVoRvKIcLMH8ydUvnXRNTYI06O Wv2Kq+6IQ4r7sQ1IeKtzqq4RV2sXek++3SqJDCcKNFVQcJYDEtJCSwqSEe/TmqZd9fFy pzSBpLYtMg/Jcd35DkLTZ9tRQ4V1+oLme4QsGEl0+bPpthqmyaUnrbOAQlJLb4n72L6Y SQtg== 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=h8Tpj5wYSQjiK+TAJfFO0Tf9jiEY5yGG/m2aEP5Z4pw=; b=HFgPYcdU7A0Gv+jt1rvYL+Zv5cVA8wt1wCaGYEyKbinsyQ3f689v9Mu7LLo0L/4Ym/ uD96YnQhKrGBI/GuxnC0y8AOkUxLM+XNgIicu+Dscx91NqShKhTYu+0qz+cCwWRFkqK0 PB0L3lxOyNlyGRWmIAGDsGH6HShyDrugOQ35cBdoEifMa8iYaHPN72JYpGoWvfOpr8N9 /W6kGq9ByOiw3LLbHG3UhextBKnsGtgcd90wKwgbwpHBGgpthCMNXjVCATmKxhKAcIcs nGBws7IaO3RnpFWIjUFfShExjYJskYZAVZyQTRRJ6QY3nA/NjoG66OSK/GdUGiEOlnrM C6Tg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@tcd-ie.20150623.gappssmtp.com header.s=20150623 header.b=YqA5PLut; 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 gw6si4427272ejb.240.2020.09.10.14.38.12; Thu, 10 Sep 2020 14:38:35 -0700 (PDT) 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; dkim=pass header.i=@tcd-ie.20150623.gappssmtp.com header.s=20150623 header.b=YqA5PLut; 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 S1728332AbgIJVhF (ORCPT + 99 others); Thu, 10 Sep 2020 17:37:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47342 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730187AbgIJNfH (ORCPT ); Thu, 10 Sep 2020 09:35:07 -0400 Received: from mail-io1-xd43.google.com (mail-io1-xd43.google.com [IPv6:2607:f8b0:4864:20::d43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 02F14C06179A for ; Thu, 10 Sep 2020 06:34:50 -0700 (PDT) Received: by mail-io1-xd43.google.com with SMTP id b6so7051819iof.6 for ; Thu, 10 Sep 2020 06:34:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tcd-ie.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=h8Tpj5wYSQjiK+TAJfFO0Tf9jiEY5yGG/m2aEP5Z4pw=; b=YqA5PLut0xGMj0S2JsZ1nqoWnAI87qW2iB6rBuyzlNr/i8p2GIELK1QX+lKWUsTwzK J2dSARVPeG4IwzzuA8pE1P+5OVAa2eHFRKGaWb7NjIZv2LfVgNFdgO/O5efipKLRnyRj 59Ivydb0yd96322f4OP7eAyli9gq1bJJqNWwr7UQp7WOJw13CiHGa50UV4LiwaciCZ54 rPVab7PqDAVXapxusuMo+bEb8iCDOteeaNoCp92DVDajkbd2ofZmMkGtoG3Skprhh9uL /U8Q1jK9UaeuY5X3L97dgHkQYmRrGLYCXPbuv3z5NyjgpChQ4n/amkDeY/PGFcsIM7Fy bAqg== 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=h8Tpj5wYSQjiK+TAJfFO0Tf9jiEY5yGG/m2aEP5Z4pw=; b=r0TtAK1mIEqQAx0JgsFjPg46XpDYnvxVVXAramPYsR62iSCKUxdRdx0YZUZh1CLmTL Fjp0U3pRAK50iE759SFpo+gkoseLKPcyYGsnrcJQedpq5cQjapsRYX2v6W03Yo5LGfbd o2my9jY0IC5Ohh3f2GSV43C0ehc+NoBo1RfsfjZw8FxmdrI9OrPsMvIJLzt/gTczP3ZY fdRSud8u+qGKWSDysNw19h4TWWP2ufj6uv3veUp1zL5/rmey3J9hkNQP6+ocr+Zww6DI SPCjV+c6k+p4yzD+E0bby8pQTt68WjQxmBHodNlP7/uL9z7nwUVNWlKOkN2VeyowteDP 2uWw== X-Gm-Message-State: AOAM531Db/gO+er0STPPEQCkrHwY8zawvExquF2Pwhco52I7+mC+qnjn JZlAU3m21DzkmOjWEh9qAdr8Me+58u5KOUqqfdvEAQ== X-Received: by 2002:a02:b199:: with SMTP id t25mr8370395jah.124.1599744889300; Thu, 10 Sep 2020 06:34:49 -0700 (PDT) MIME-Version: 1.0 References: <20191221150402.13868-1-murphyt7@tcd.ie> <465815ae-9292-f37a-59b9-03949cb68460@deltatee.com> <20200529124523.GA11817@infradead.org> <33137cfb-603c-86e8-1091-f36117ecfaf3@deltatee.com> <766525c3-4da9-6db7-cd90-fb4b82cd8083@deltatee.com> <60a82319-cbee-4cd1-0d5e-3c407cc51330@linux.intel.com> <7106602a-9964-851e-9c4e-d8acf4033b89@linux.intel.com> In-Reply-To: From: Tom Murphy Date: Thu, 10 Sep 2020 14:34:38 +0100 Message-ID: Subject: Re: [Intel-gfx] [PATCH 0/8] Convert the intel iommu driver to the dma-iommu api To: Tvrtko Ursulin Cc: kvm@vger.kernel.org, David Airlie , dri-devel@lists.freedesktop.org, Bjorn Andersson , Matthias Brugger , Julien Grall , Will Deacon , Marek Szyprowski , Jean-Philippe Brucker , linux-samsung-soc@vger.kernel.org, Marc Zyngier , Krzysztof Kozlowski , Jonathan Hunter , Christoph Hellwig , linux-rockchip@lists.infradead.org, Andy Gross , Gerald Schaefer , linux-s390@vger.kernel.org, linux-arm-msm@vger.kernel.org, intel-gfx@lists.freedesktop.org, Robin Murphy , linux-mediatek@lists.infradead.org, linux-tegra@vger.kernel.org, Thomas Gleixner , virtualization@lists.linux-foundation.org, linux-arm-kernel@lists.infradead.org, David Woodhouse , Cornelia Huck , Linux Kernel Mailing List , iommu@lists.linux-foundation.org, Kukjin Kim , Logan Gunthorpe 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, 10 Sep 2020 at 14:33, Tom Murphy wrote: > > On Wed, 9 Sep 2020 at 13:56, Tvrtko Ursulin > wrote: > > > > > > On 09/09/2020 10:16, Tvrtko Ursulin wrote: > > > On 08/09/2020 23:43, Tom Murphy wrote: > > >> On Tue, 8 Sep 2020 at 16:56, Tvrtko Ursulin > > >> wrote: > > >>> On 08/09/2020 16:44, Logan Gunthorpe wrote: > > >>>> On 2020-09-08 9:28 a.m., Tvrtko Ursulin wrote: > > >>>>>> > > >>>>>> diff --git a/drivers/gpu/drm/i915/i915_scatterlist.h > > >>>>>> b/drivers/gpu/drm/i915/i915 > > >>>>>> index b7b59328cb76..9367ac801f0c 100644 > > >>>>>> --- a/drivers/gpu/drm/i915/i915_scatterlist.h > > >>>>>> +++ b/drivers/gpu/drm/i915/i915_scatterlist.h > > >>>>>> @@ -27,13 +27,19 @@ static __always_inline struct sgt_iter { > > >>>>>> } __sgt_iter(struct scatterlist *sgl, bool dma) { > > >>>>>> struct sgt_iter s = { .sgp = sgl }; > > >>>>>> > > >>>>>> + if (sgl && !sg_dma_len(s.sgp)) > > >>>>> > > >>>>> I'd extend the condition to be, just to be safe: > > >>>>> if (dma && sgl && !sg_dma_len(s.sgp)) > > >>>>> > > >>>> > > >>>> Right, good catch, that's definitely necessary. > > >>>> > > >>>>>> + s.sgp = NULL; > > >>>>>> + > > >>>>>> if (s.sgp) { > > >>>>>> s.max = s.curr = s.sgp->offset; > > >>>>>> - s.max += s.sgp->length; > > >>>>>> - if (dma) > > >>>>>> + > > >>>>>> + if (dma) { > > >>>>>> + s.max += sg_dma_len(s.sgp); > > >>>>>> s.dma = sg_dma_address(s.sgp); > > >>>>>> - else > > >>>>>> + } else { > > >>>>>> + s.max += s.sgp->length; > > >>>>>> s.pfn = page_to_pfn(sg_page(s.sgp)); > > >>>>>> + } > > >>>>> > > >>>>> Otherwise has this been tested or alternatively how to test it? > > >>>>> (How to > > >>>>> repro the issue.) > > >>>> > > >>>> It has not been tested. To test it, you need Tom's patch set without > > >>>> the > > >>>> last "DO NOT MERGE" patch: > > >>>> > > >>>> https://lkml.kernel.org/lkml/20200907070035.GA25114@infradead.org/T/ > > >>> > > >>> Tom, do you have a branch somewhere I could pull from? (Just being lazy > > >>> about downloading a bunch of messages from the archives.) > > >> > > >> I don't unfortunately. I'm working locally with poor internet. > > >> > > >>> > > >>> What GPU is in your Lenovo x1 carbon 5th generation and what > > >>> graphical/desktop setup I need to repro? > > >> > > >> > > >> Is this enough info?: > > >> > > >> $ lspci -vnn | grep VGA -A 12 > > >> 00:02.0 VGA compatible controller [0300]: Intel Corporation HD > > >> Graphics 620 [8086:5916] (rev 02) (prog-if 00 [VGA controller]) > > >> Subsystem: Lenovo ThinkPad X1 Carbon 5th Gen [17aa:224f] > > >> Flags: bus master, fast devsel, latency 0, IRQ 148 > > >> Memory at eb000000 (64-bit, non-prefetchable) [size=16M] > > >> Memory at 60000000 (64-bit, prefetchable) [size=256M] > > >> I/O ports at e000 [size=64] > > >> [virtual] Expansion ROM at 000c0000 [disabled] [size=128K] > > >> Capabilities: [40] Vendor Specific Information: Len=0c > > >> Capabilities: [70] Express Root Complex Integrated Endpoint, MSI 00 > > >> Capabilities: [ac] MSI: Enable+ Count=1/1 Maskable- 64bit- > > >> Capabilities: [d0] Power Management version 2 > > >> Capabilities: [100] Process Address Space ID (PASID) > > >> Capabilities: [200] Address Translation Service (ATS) > > > > > > Works for a start. What about the steps to repro? Any desktop > > > environment and it is just visual corruption, no hangs/stalls or such? > > > > > > I've submitted a series consisting of what I understood are the patches > > > needed to repro the issue to our automated CI here: > > > > > > https://patchwork.freedesktop.org/series/81489/ > > > > > > So will see if it will catch something, or more targeted testing will be > > > required. Hopefully it does trip over in which case I can add the patch > > > suggested by Logan on top and see if that fixes it. Or I'll need to > > > write a new test case. > > > > > > If you could glance over my series to check I identified the patches > > > correctly it would be appreciated. > > > > Our CI was more than capable at catching the breakage so I've copied you > > on a patch (https://patchwork.freedesktop.org/series/81497/) which has a > > good potential to fix this. (Or improve the robustness of our sg walks, > > depends how you look at it.) > > > > Would you be able to test it in your environment by any chance? If it > > works I understand it unblocks your IOMMU work, right? And yes this does unblock the iommu work > > I tested your latest patch set ([PATCH 1/2] drm/i915: Fix DMA mapped > scatterlist walks) and it fixes the issue. great work! > > > > > Regards, > > > > Tvrtko