Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp3685296pxb; Wed, 13 Oct 2021 10:48:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwyEVANtcGfX5W/KF5uEV/+CcN10IEfOq1VdKkIRcIOy3QuoZj6LsNA8dV1Dn3FHz9J0J/B X-Received: by 2002:a05:6a00:22d1:b0:44c:f752:a216 with SMTP id f17-20020a056a0022d100b0044cf752a216mr373516pfj.45.1634147294347; Wed, 13 Oct 2021 10:48:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634147294; cv=none; d=google.com; s=arc-20160816; b=ro0LjErVSWvXPe2lJSK+Gvdri0OaCYu+WXuSRCq+3wHfg5WEEsrnPL1YJQdpQZ6gx4 1atLu50ZzlPWyu/+xtll4kyXUrcTWxy9drsVTFJElgg3whPa3iBhtqG6Nq5+DsyUoJGX 4mnE4ZX+UcP0pdO8BA+kzRLtjk7HCxtVJgYw2vGa3sGrnM+tQttH3daNgZGJQ/yhAyp+ ajE1Hvc3DeMv0Um1eFb4VrrGBsd8fr3y9H81x2r5AeeKdR8DxNk4gtelF72aZBGhtcst q0pMwYHRwKgRSPTLZ5gLlx+yyOD2YmvKwUiuBEDsLL2YgoJQihC8Y8qR+w0NlKxB7kaL YDPA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:to:from:date; bh=WPSXiYPEc5Ot+2kbrCIK6zMFLRyHmwRbYVXQzOtfThs=; b=uauZ92r1K7nm3HSGexOmkIa41p8Pa3siUGqYLBg0X0J9p366d46FAdt1nLxmoIW79D tT9kzmCp4Gh5A4REJ5Xa0Q0NSe0g5Qd8hzzTv1pBlvYU5cfGRcYPAp8OvxY6IjhBIg0O 8ysVeJ+OtbPAcUQ8N5yXwC2MctfC8bXZJ7biJW6eM2yn2y4vfKzq3uSXCvckGs9eTWFy Sm49vmsnnXuTcFp4L+NDGnW4g0AB9ctHKHbU4ZvQG3cgWdQHT1LiWXcsGE1hw92UV/rQ v66iobrRypcfn16xrcbjAwvezefcPOab+j1GJM1bPBPuw1Z5ddEZ/YwHzeIXDtkJ7xsZ 6jew== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 12si10405024pjl.32.2021.10.13.10.48.00; Wed, 13 Oct 2021 10:48:14 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229814AbhJMRr6 (ORCPT + 99 others); Wed, 13 Oct 2021 13:47:58 -0400 Received: from rosenzweig.io ([138.197.143.207]:46982 "EHLO rosenzweig.io" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229714AbhJMRrz (ORCPT ); Wed, 13 Oct 2021 13:47:55 -0400 Date: Wed, 13 Oct 2021 13:45:43 -0400 From: Alyssa Rosenzweig To: dri-devel@lists.freedesktop.org, Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , linux-kernel@vger.kernel.org, Robin Murphy Subject: Re: [PATCH v2] drm/cma-helper: Set VM_DONTEXPAND for mmap Message-ID: References: <20211013143654.39031-1-alyssa@rosenzweig.io> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > > From: Robin Murphy > > > > drm_gem_cma_mmap() cannot assume every implementation of dma_mmap_wc() > > will end up calling remap_pfn_range() (which happens to set the relevant > > vma flag, among others), so in order to make sure expectations around > > VM_DONTEXPAND are met, let it explicitly set the flag like most other > > GEM mmap implementations do. > > > > This avoids repeated warnings on a small minority of systems where the > > display is behind an IOMMU, and has a simple driver which does not > > override drm_gem_cma_default_funcs. Arm hdlcd is an in-tree affected > > driver. Out-of-tree, the Apple DCP driver is affected; this fix is > > required for DCP to be mainlined. > > How/where does this warn? Also there should be a lot more drivers than > just these two which have an iommu for the display block, so this not > working is definitely a more wide-spread issue. To summarize our discussion on IRC: This fails `WARN_ON(!(vma->vm_flags & VM_DONTEXPAND))` in drm_gem_mmap_obj. This warning was introduced in Oct 2019. For a driver to hit this code path, it must use the CMA helpers without overriding dem_gem_cma_default_funcs, but use CMA backed by a hardware IOMMU instead of a physical carveout. This means popular drivers don't hit this warning: normal drivers that use CMA do so with a carveout instead of an IOMMU, and normal drivers with an IOMMU do not use the default CMA helpers. hdlcd is one of the few drivers hitting this, but hdlcd gets very little testing. Seeing as the last significant change to hdlcd was in May 2019, it's believable that nobody noticed until Robin hit this WARN and typed out this patch, especially as the driver still works despite the WARN.