Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp4820589ybe; Mon, 9 Sep 2019 15:23:11 -0700 (PDT) X-Google-Smtp-Source: APXvYqzSW176KbGXhISCIey587HFUFUNEHcAPJfqiZLzi/Q68ezEyYXjZRIKC523uBC5wh/TRpSC X-Received: by 2002:a50:e001:: with SMTP id e1mr27224794edl.177.1568067791381; Mon, 09 Sep 2019 15:23:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568067791; cv=none; d=google.com; s=arc-20160816; b=YdvcjctKgw8OfNCfRXKe6jxOjcUe8eloTJ7pGPB4nwvuitPxwNPublq2NnRYMqkRXN WhypEEsvA9Y/mk7qNWg8IOa7ve8ebZv4DyyYYvGcfo87UPVRNKFMOdhIGoVaVzr+dyun wJmc8ii7vam6SKCF3geuT1sqCft27pmoLV+rbQF9YTUzZbendB4+Udagl8H2iyq8Ewtt NC9zpG9i0xwknsBB0HJLPhaiafXKNloO/X+1B6ZDe5E8bHtchM87b2dEHP9+cPgP4sBi OB0LrfTG8B4powmcgLcK4IsiapIH+fSqJAGqUha4Vm/KPfV1Myez88crqAx03opF89iv KzMA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=pyRlf6J6SeLPnu9Whyc1Nj9AIOW/l9jhOwCQblbLi7c=; b=E97+1WM+RtRhrCwTGOdUntu7CGmMewcxF+hdFr9QjcVaVtRCbQ037qQcokq3mInX4R XrpBbf2eV4v7ca+udBY6BfQERfkZfqrWTrUtDlyMoWco36eblOtttIRDj8FQZLgA0ezs 4smA3MPDk3bxx4PqtcUFX7zhLK/glRi6warDcwMO7XNaIPfV7Dd9zg7aB4lhgsly2va2 GJtgDdCdzAv6MWofaGI1uF4bGyLlPL4FhnoY83tjGS4pc31D98YLacyiSzDF1tzGH+Zh +FoBida/5qTG4rXVHC0tFUL6z6/iRIiBwpWWfM/TQUzmLetpASuTpba0eFJBhn12L4fm XkVg== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c54si9215586edb.230.2019.09.09.15.22.46; Mon, 09 Sep 2019 15:23:11 -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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389971AbfIIKG4 (ORCPT + 99 others); Mon, 9 Sep 2019 06:06:56 -0400 Received: from mx1.redhat.com ([209.132.183.28]:48224 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728993AbfIIKGz (ORCPT ); Mon, 9 Sep 2019 06:06:55 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 56B3F3090FC2; Mon, 9 Sep 2019 10:06:55 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-117-59.ams2.redhat.com [10.36.117.59]) by smtp.corp.redhat.com (Postfix) with ESMTP id E8DAA10018F8; Mon, 9 Sep 2019 10:06:54 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 0588916E19; Mon, 9 Sep 2019 12:06:54 +0200 (CEST) Date: Mon, 9 Sep 2019 12:06:53 +0200 From: Gerd Hoffmann To: Daniel Vetter Cc: dri-devel , Thomas Zimmermann , Maarten Lankhorst , Maxime Ripard , Sean Paul , David Airlie , open list Subject: Re: [PATCH v4 05/17] drm: add mmap() to drm_gem_object_funcs Message-ID: <20190909100653.hyo4psakt3ccfwjk@sirius.home.kraxel.org> References: <20190808134417.10610-1-kraxel@redhat.com> <20190808134417.10610-6-kraxel@redhat.com> <20190903094859.GQ2112@phenom.ffwll.local> <20190906121318.r4nvoacazvwukuun@sirius.home.kraxel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20180716 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.43]); Mon, 09 Sep 2019 10:06:55 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, > > + vma->vm_flags |= VM_IO | VM_PFNMAP | VM_DONTEXPAND | VM_DONTDUMP; > > + vma->vm_page_prot = pgprot_writecombine(vm_get_page_prot(vma->vm_flags)); > > + vma->vm_page_prot = pgprot_decrypted(vma->vm_page_prot); > > + } > > Totally unrelated discussion around HMM lead me to a bit a chase, and > realizing that we probably want a > > WARN_ON(!(vma->vm_flags & VM_SPECIAL)); > > here, to make sure drivers set at least one of the "this is a special > vma, don't try to treat it like pagecache/anon memory". Just to be on > the safe side. Maybe we also want to keep the entire vma->vm_flags > assignment in the common code, but at least the WARN_ON would be a > good check I think. Maybe also check for VM_DONTEXPAND while at it Hmm. VM_SPECIAL is this: #define VM_SPECIAL (VM_IO | VM_DONTEXPAND | VM_PFNMAP | VM_MIXEDMAP) Requiring VM_DONTEXPAND makes sense for sure. Dunno about the other ones. For drm_gem_vram_helper VM_IO + VM_PFNMAP are needed. But we also have drm_gem_shmem_helper which backs objects with normal pages. In fact drm_gem_shmem_mmap does this: /* VM_PFNMAP was set by drm_gem_mmap() */ vma->vm_flags &= ~VM_PFNMAP; vma->vm_flags |= VM_MIXEDMAP; include/linux/mm.h isn't very helpful in explaining how VM_MIXEDMAP should be used, only saying can be both "struct page" and pfnmap, so I'm not sure why VM_MIXEDMAP is set here, it should always be "struct page" for shmem, no? cheers, Gerd