Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp4185359pxk; Tue, 8 Sep 2020 12:56:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwgW/CsPnWDz8RGQasLNzidvRMM4xySE1huTc2g/tkFEX9ksIQ8lm8vl9Z+njB5THhXnAmz X-Received: by 2002:aa7:d043:: with SMTP id n3mr642612edo.243.1599595019441; Tue, 08 Sep 2020 12:56:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599595019; cv=none; d=google.com; s=arc-20160816; b=nstDKVXw8jRVjPs6AnSPj1gqirDZiXhapK7+MfEPb1ab54OmcIPUlsR9TjIw35SNpF Cw/JkZBCRPiNayytOUBI3yqO0RPhiLdBBJ1mBz+xtoqqIlKIdG2FCUN4Xhfe/ICdEboE 2vAOMNdH4F3ceqFxGebY5UsKHZGQ3aSBZCtyf7BzpEkXD8RET9WKZtqtU+kNBS9UqlIJ x/pCMMW4t6T2gRPRFpQTEfOmqtD1Lox7CzvQ7cjo13XAbqNPI5tyPSTWI1V5tqepRWCM E7gxw/rnYnpR25AI3YR+s7LofX+2ywcVR7c/Xj8S6iheKGx00AghRJ0CIcBodVwpsEQL 2ngA== 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:organization:from:references:cc:to:subject:ironport-sdr :ironport-sdr; bh=bKAxWcBGeItgxEJitcBbX0zWzwUxdSe1MC1pzcqsvno=; b=yOjvjlaKbZuWue7WKtTDnvvHQRkzQUFq8V/CPon2ODIv9qmExUh9CcGfAiPNcqxvyO p0FCBtDbJDfvInC1hATFBqhUNzW4NJ2A47IwTiMQu5ppoYYkjy5j/nQ7xUpOh7k9PYO7 2I2PTkNbTLjYcw/s86LeKI42XLhlPzuJH8klOxhy0tZiZBSSyXG/pefW4T7KLYo3DpRO sPwl8CTRkJLA3w/k/qyEnH+0AE2cUd4DGm7Ql/urgSiAOVITXoldHUB5cyfmo2m9q9OJ poQgIopZm9z/bi7qzqREbwMuQ28nBOpAfOjB2x8ugLuAMNtnalIQi2Vi0sDBSHhRjhdy v8vw== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k3si54844eds.225.2020.09.08.12.56.36; Tue, 08 Sep 2020 12:56:59 -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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732114AbgIHTyD (ORCPT + 99 others); Tue, 8 Sep 2020 15:54:03 -0400 Received: from mga09.intel.com ([134.134.136.24]:45227 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729935AbgIHPh4 (ORCPT ); Tue, 8 Sep 2020 11:37:56 -0400 IronPort-SDR: Vk1a8Xp01oHqi3a6rxgficaRMRGr8uTq6Dp/08L+148x0hEhYgnTroXXPB0ja9+tz03LOoCo35 xddhQ16YHyvw== X-IronPort-AV: E=McAfee;i="6000,8403,9738"; a="159124946" X-IronPort-AV: E=Sophos;i="5.76,406,1592895600"; d="scan'208";a="159124946" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Sep 2020 08:28:50 -0700 IronPort-SDR: OqiPE0Cn/mbaoFglvyhAf2rWnLm6JquwW+AKzi6KXAQYqzMCNSFdbI9D+UGi2vd+sJzRv/8Kvj Oe6qN0U8cxmQ== X-IronPort-AV: E=Sophos;i="5.76,406,1592895600"; d="scan'208";a="480068519" Received: from sderix-mobl1.ger.corp.intel.com (HELO [10.214.213.131]) ([10.214.213.131]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Sep 2020 08:28:38 -0700 Subject: Re: [Intel-gfx] [PATCH 0/8] Convert the intel iommu driver to the dma-iommu api To: Logan Gunthorpe , Tom Murphy Cc: kvm@vger.kernel.org, David Airlie , dri-devel@lists.freedesktop.org, Bjorn Andersson , linux-tegra@vger.kernel.org, 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 , linux-arm-kernel@lists.infradead.org, linux-s390@vger.kernel.org, linux-arm-msm@vger.kernel.org, intel-gfx@lists.freedesktop.org, linux-mediatek@lists.infradead.org, Matthias Brugger , Thomas Gleixner , virtualization@lists.linux-foundation.org, Gerald Schaefer , David Woodhouse , Cornelia Huck , Linux Kernel Mailing List , iommu@lists.linux-foundation.org, Kukjin Kim , Robin Murphy 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> From: Tvrtko Ursulin Organization: Intel Corporation UK Plc Message-ID: <60a82319-cbee-4cd1-0d5e-3c407cc51330@linux.intel.com> Date: Tue, 8 Sep 2020 16:28:35 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <766525c3-4da9-6db7-cd90-fb4b82cd8083@deltatee.com> 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 Hi, On 27/08/2020 22:36, Logan Gunthorpe wrote: > On 2020-08-23 6:04 p.m., Tom Murphy wrote: >> I have added a check for the sg_dma_len == 0 : >> """ >> } __sgt_iter(struct scatterlist *sgl, bool dma) { >> struct sgt_iter s = { .sgp = sgl }; >> >> + if (sgl && sg_dma_len(sgl) == 0) >> + s.sgp = NULL; >> >> if (s.sgp) { >> ..... >> """ >> at location [1]. >> but it doens't fix the problem. > > Based on my read of the code, it looks like we also need to change usage > of sgl->length... Something like the rough patch below, maybe? This thread was brought to my attention and I initially missed this reply. Essentially I came to the same conclusion about the need to use sg_dma_len. One small correction below: > Also, Tom, do you have an updated version of the patchset to convert the > Intel IOMMU to dma-iommu available? The last one I've found doesn't > apply cleanly (I'm assuming parts of it have been merged in slightly > modified forms). > > Thanks, > > Logan > > -- > > 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)) > + 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.) Regards, Tvrtko