Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp6287501ybl; Mon, 23 Dec 2019 03:30:27 -0800 (PST) X-Google-Smtp-Source: APXvYqyoQ0Xfckcg4eMZVHbPrDbfZhW4LJTCaEq+zVikh/XT3T8XbNiKhDdnNFU+rb+j9GWPms86 X-Received: by 2002:a9d:369:: with SMTP id 96mr26515462otv.228.1577100627286; Mon, 23 Dec 2019 03:30:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1577100627; cv=none; d=google.com; s=arc-20160816; b=UE+o6eCJguuAnnpK2slYvo8fhY3DglG4mPU1LUBxASFpK3abrSiXut//PojLrRBJAV 4hLORi+5KcmTDpiYN5zVadjsg5/iJn9iTkbQizAIbqAly+ulLlxC1o7oTrpGwDwwNv1b pJE08AkjNryuXtypVjd+ms7XxZMWI7zrd/nep378faQaVXKfjrVPGW/uR6tyf/6UwZl/ hiCj9uZf81inPdfZfT79Halu2jztEPsPyn8MyqWLz1BNn8uyQuS6PUrJrSvRv8WhtWcF bFIW56B7mWWWp3sUSQecjvccQrPxmTcKI9rilvfT3HtG9/SctrTJALLUCsfT9HDfq3pV BKDw== 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=PUFo+2j1qDr3laHW3tjxsNvwa9cgeC3hQocENFpo7GM=; b=ms9zSHlDXovLw14Iwxiq5hr7ZX+imueREgqS9FLzd83eo5qfPH91xiSMo/QbFc9U0r StRpePIm8Au+vs9NC1JfgXGnFpsPJSt49ms4dmKq9SfA0eNdKetcrmpjJbwS03hrjHSl GFXIthoi1iv/bDeQEUBiGa1EtxOQs9O335BBhckMzyxfcGtJijOAzix9Y0p5uZHXQqE8 ZY/Wvem5vX32Zb4hYp6ZL6ypSbTrnKjX8scHIFDmo7KdYbqP75QIKv/qwBF0s9zlrqFU pfyv4Sb5mUpdo96wfkdLLg84OXpzKF1HdJQ+n41lhZiLjUMnC9XgX09wEtULrZc3/g4H 9xGg== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i15si8985368otl.247.2019.12.23.03.30.14; Mon, 23 Dec 2019 03:30:27 -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; 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 S1726798AbfLWL3d (ORCPT + 99 others); Mon, 23 Dec 2019 06:29:33 -0500 Received: from foss.arm.com ([217.140.110.172]:43030 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726679AbfLWL3c (ORCPT ); Mon, 23 Dec 2019 06:29:32 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 9F7EC328; Mon, 23 Dec 2019 03:29:31 -0800 (PST) Received: from [192.168.1.123] (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id EE2493F68F; Mon, 23 Dec 2019 03:29:25 -0800 (PST) Subject: Re: [PATCH 0/8] Convert the intel iommu driver to the dma-iommu api To: Jani Nikula , Tom Murphy , iommu@lists.linux-foundation.org Cc: Joonas Lahtinen , Rodrigo Vivi , David Airlie , Daniel Vetter , Joerg Roedel , Will Deacon , Marek Szyprowski , Kukjin Kim , Krzysztof Kozlowski , David Woodhouse , Lu Baolu , Andy Gross , Bjorn Andersson , Matthias Brugger , Rob Clark , Heiko Stuebner , Gerald Schaefer , Thierry Reding , Jonathan Hunter , Jean-Philippe Brucker , Alex Williamson , Cornelia Huck , Julien Grall , Marc Zyngier , Eric Auger , Thomas Gleixner , intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-mediatek@lists.infradead.org, linux-rockchip@lists.infradead.org, linux-s390@vger.kernel.org, linux-tegra@vger.kernel.org, virtualization@lists.linux-foundation.org, kvm@vger.kernel.org References: <20191221150402.13868-1-murphyt7@tcd.ie> <87blrzwcn8.fsf@intel.com> From: Robin Murphy Message-ID: <432d306c-fe9f-75b2-f0f7-27698f1467ad@arm.com> Date: Mon, 23 Dec 2019 11:29:17 +0000 User-Agent: Mozilla/5.0 (Windows NT 10.0; rv:68.0) Gecko/20100101 Thunderbird/68.3.0 MIME-Version: 1.0 In-Reply-To: <87blrzwcn8.fsf@intel.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-GB Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2019-12-23 10:37 am, Jani Nikula wrote: > On Sat, 21 Dec 2019, Tom Murphy wrote: >> This patchset converts the intel iommu driver to the dma-iommu api. >> >> While converting the driver I exposed a bug in the intel i915 driver >> which causes a huge amount of artifacts on the screen of my >> laptop. You can see a picture of it here: >> https://github.com/pippy360/kernelPatches/blob/master/IMG_20191219_225922.jpg >> >> This issue is most likely in the i915 driver and is most likely caused >> by the driver not respecting the return value of the >> dma_map_ops::map_sg function. You can see the driver ignoring the >> return value here: >> https://github.com/torvalds/linux/blob/7e0165b2f1a912a06e381e91f0f4e495f4ac3736/drivers/gpu/drm/i915/gem/i915_gem_dmabuf.c#L51 >> >> Previously this didn’t cause issues because the intel map_sg always >> returned the same number of elements as the input scatter gather list >> but with the change to this dma-iommu api this is no longer the >> case. I wasn’t able to track the bug down to a specific line of code >> unfortunately. >> >> Could someone from the intel team look at this? > > Let me get this straight. There is current API that on success always > returns the same number of elements as the input scatter gather > list. You propose to change the API so that this is no longer the case? No, the API for dma_map_sg() has always been that it may return fewer DMA segments than nents - see Documentation/DMA-API.txt (and otherwise, the return value would surely be a simple success/fail condition). Relying on a particular implementation behaviour has never been strictly correct, even if it does happen to be a very common behaviour. > A quick check of various dma_map_sg() calls in the kernel seems to > indicate checking for 0 for errors and then ignoring the non-zero return > is a common pattern. Are you sure it's okay to make the change you're > proposing? Various code uses tricks like just iterating the mapped list until the first segment with zero sg_dma_len(). Others may well simply have bugs. Robin. > Anyway, due to the time of year and all, I'd like to ask you to file a > bug against i915 at [1] so this is not forgotten, and please let's not > merge the changes before this is resolved. > > > Thanks, > Jani. > > > [1] https://gitlab.freedesktop.org/drm/intel/issues/new > >