Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp340429ybb; Thu, 19 Mar 2020 23:29:20 -0700 (PDT) X-Google-Smtp-Source: ADFU+vuA9FaN+kbLMUucCSFr1Fp9cfO2bgr/OHkzlMsHSswBz4hDsq2wK8owjKSbYb4JmQsugXP0 X-Received: by 2002:a54:448c:: with SMTP id v12mr5376794oiv.107.1584685760023; Thu, 19 Mar 2020 23:29:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584685760; cv=none; d=google.com; s=arc-20160816; b=DM+xDF6sgkLIpxTWdtAl3vEnxItPTDlrBrYQ8XJJ05IsiZGq+WH956ojEiwHCZ6CuP Mr1LZ5HYZqSazBw+bDUjkn8couOdlsQ81YuYqJ5ilLVwrmDZ5xmV3JHGbNI6SVdhwX7w QTEBVm7dSz+U1cP+uPoplEKXMij+fRQ/jOoPS0OxIKYviQfW2LjIqHNJYKkUu1MH15S/ KD+Vj2CtlZfi/Vfg8d6KLJki8GoMysTtGeDF4dKiS+sqc/8C/8Hi3CIk41cdhT1CvKup yB8flg5HjksDSlkJtoBK2ikNEppvFvaJyRGMWSFgJEA0OE4lbyPyDVnbDcLoM9jO5lDq G8mg== 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:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=iNXs70iQMmbCeWom+A/Tg16i/IbQyXAZI0Q/ppb6028=; b=K8Ppyrlc1x+xjOmLt6zJIwp5BJdIs5/iXyVN6NAA03xLME94RSqL8llsJ1t1WAGEVQ UBBXXYIBKea/HHphVWsMylH2IjODJrU1gZH7ZIqNzcl2uWGa0JOTLJUvQ5H7FJ4VDtfo 4BYArY3fq6QcYLnTCQ0adUL9UTVBjh5LiExMN/0s1m1taLj9Ea1+qlWFHFTpul+zG4Lt T9k6lIW903p/9B6H8Muia4FWhKv9M9/tLE3hoozd8TWIMstQ0HOPix5Qp8KfDvpyDjjJ aeUlv1BjXTdO+5ew4PehB+ylFby0cmr/cwqjIO7Xl2PkgvMKLaUWiX98yZP87X7B0xVX KZWw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@tcd-ie.20150623.gappssmtp.com header.s=20150623 header.b=mlwq4CYA; 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 y65si2141743oie.92.2020.03.19.23.29.06; Thu, 19 Mar 2020 23:29:19 -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; dkim=pass header.i=@tcd-ie.20150623.gappssmtp.com header.s=20150623 header.b=mlwq4CYA; 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 S1726796AbgCTG2X (ORCPT + 99 others); Fri, 20 Mar 2020 02:28:23 -0400 Received: from mail-il1-f196.google.com ([209.85.166.196]:45389 "EHLO mail-il1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726030AbgCTG2X (ORCPT ); Fri, 20 Mar 2020 02:28:23 -0400 Received: by mail-il1-f196.google.com with SMTP id m9so4559395ilq.12 for ; Thu, 19 Mar 2020 23:28:21 -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:content-transfer-encoding; bh=iNXs70iQMmbCeWom+A/Tg16i/IbQyXAZI0Q/ppb6028=; b=mlwq4CYA+23qP9sIb47R10WlCGq2DIeqg0u1nZRI7nIlEwzdaBM16J0diAb1hlohhx 6DmTCrAETojeuHxXASGkurUqmDfwjHRaPO4za7UkVii+FhFKjU1p/Uh7mi3KFwpjPhsb iUmifGiws8WLlb2N+d2f8DAIA3I+MwtdSl7QMUdRy6dZmidqOFzKWaoRrSqr4hGVvYFe lxvu2QhZ23+aceqTRPs5AhP4qiprkvMy5v6UfWHtbzwVFjivSqy8raQEj8IKp649aRSz OzRNio30MUjHUatFuFBVrSm+4Q22qFcnN1y399wmFgi4y40WUSo1BlDO9PO4lb7z5YMG C1tA== 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:content-transfer-encoding; bh=iNXs70iQMmbCeWom+A/Tg16i/IbQyXAZI0Q/ppb6028=; b=BikTlpvFksScp2u/5lVpDLl6Xfrj9WgbTKIesBst/Hn+vVtM1L6Mihdup3ubT745pd JFcQm7WjUzOw/XTUUYgA0Uu948xNRxjlAl5B2rJrKR3M8kzHodzHog86hPIQ+sXaesc9 vwBfV2qpBFo0gCKzrvPc+sDdNPlroFCxN53grlbJ+AlIxKjerepmIrpARnPhCcyiCrK5 PQH+y7mu780PiKCOCRcrgWzDVYxyGpJyW8k49DdWuogET39BIzHswjdLdoM1MnhV5Fmd AXxlFtvYBaptLNZNLP/V/2UW9uAKfwXmDRXkJvGY/w5y8cgtule4zPvC01XEuzAQfeeZ uK2w== X-Gm-Message-State: ANhLgQ1FZ7KP7NRcQVBxUUlDYAIVLSOP6xtdr9hPUaeM9G0hjiBuRnMt LahQkhOLt6b/MEp+d6WuA3Qr5Y6DX7LRMOCoUzh2Uw== X-Received: by 2002:a92:41c7:: with SMTP id o190mr6554977ila.11.1584685701013; Thu, 19 Mar 2020 23:28:21 -0700 (PDT) MIME-Version: 1.0 References: <20191221150402.13868-1-murphyt7@tcd.ie> <87blrzwcn8.fsf@intel.com> <432d306c-fe9f-75b2-f0f7-27698f1467ad@arm.com> <87o8vzuv4i.fsf@intel.com> In-Reply-To: <87o8vzuv4i.fsf@intel.com> From: Tom Murphy Date: Thu, 19 Mar 2020 23:28:09 -0700 Message-ID: Subject: Re: [PATCH 0/8] Convert the intel iommu driver to the dma-iommu api To: Jani Nikula Cc: Robin Murphy , iommu@lists.linux-foundation.org, 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 Mailing List , 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 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Any news on this? Is there anyone who wants to try and fix this possible bu= g? On Mon, 23 Dec 2019 at 03:41, Jani Nikula wro= te: > > On Mon, 23 Dec 2019, Robin Murphy wrote: > > 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_22= 5922.jpg > >>> > >>> This issue is most likely in the i915 driver and is most likely cause= d > >>> 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/7e0165b2f1a912a06e381e91f0f4e4= 95f4ac3736/drivers/gpu/drm/i915/gem/i915_gem_dmabuf.c#L51 > >>> > >>> Previously this didn=E2=80=99t 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=E2=80=99t 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 strictl= y > > 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 retu= rn > >> 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. > > Thanks for the clarification. > > BR, > Jani. > > > > > 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 > >> > >> > > -- > Jani Nikula, Intel Open Source Graphics Center