Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1016056pxb; Thu, 25 Feb 2021 23:41:47 -0800 (PST) X-Google-Smtp-Source: ABdhPJwIKEi8wWuDLfeWY+b207x71JllMfgX5tcuFZhKQqbB2MYAcWsFTkpNmSnjoslVS05pba9B X-Received: by 2002:a50:e80c:: with SMTP id e12mr1861412edn.229.1614325306914; Thu, 25 Feb 2021 23:41:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614325306; cv=none; d=google.com; s=arc-20160816; b=U5bxNXQJS2lAlg9udomaHLqqc/KVqxsp+VhM+acY1FrMs27a7LvLR5kddiqGZ0Y6n0 BumBifuxAq/uiVWGmpxnC0eM/FVhWU0jgdYD+zYh3cWQwGZ5AoegEWzIBS45KQJT63s7 auWp9DrpR9yM+oYLilMOx1gMDVe4jgHLcF+lF6Lxo32ylDf2Unuflk4xLDTInWOC8zAN LP8R7+oheQLoRttgzaUIXH+R2Uo0rciZSPmY1oLBtrcaQ7HCdsTxYWhI3AR3+2yNdRQu PxLHgEFEeQL48BlN4XQkNn77AQiDGPnMz1WNyuImMqXYy89mTR8QYghzfqfx6IjrGu7D vCtA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=VQgZEeHJdf6Bfk1LIoWC2HIkTuWyVFZe6jHDYc9nISE=; b=zvcQfhXCPaVGxJ/4kKiLedN9IHDxBiM9gTb3BjmjULlFK+NQdq0OwAZpsE38+oCTRc 22qASodh0igrnuD12JShRf1aoi2DobAgw1WOTLYdhAeRm9WiXfkhZRKbvbXTJT2kJzo0 35NFyQ2I8ToyqJcXemirpKn3/GNwt1uBZmYfCHEiKU/CIrTwWHawsTgQKkNnc0FhBS/e TJxkgh9XpZaoe9ODJKzA3/N+iG2A4gTqbDDtbTqmR6S3iB92kJ6nY622dlY+NkvSKI2r arPzJBUvZKgrIxYfiNzB2yFhAkli4FygoU8PKt1CRAwG86ZQ5Paxn5cz9H0UwUr6FR0Z TLCQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ffwll.ch header.s=google header.b="MTOO3T/7"; 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 c11si5137344edy.117.2021.02.25.23.41.24; Thu, 25 Feb 2021 23:41:46 -0800 (PST) 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; dkim=pass header.i=@ffwll.ch header.s=google header.b="MTOO3T/7"; 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 S229449AbhBZHiQ (ORCPT + 99 others); Fri, 26 Feb 2021 02:38:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47878 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230179AbhBZHhr (ORCPT ); Fri, 26 Feb 2021 02:37:47 -0500 Received: from mail-ot1-x334.google.com (mail-ot1-x334.google.com [IPv6:2607:f8b0:4864:20::334]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 306C4C06174A for ; Thu, 25 Feb 2021 23:37:07 -0800 (PST) Received: by mail-ot1-x334.google.com with SMTP id g8so4647473otk.4 for ; Thu, 25 Feb 2021 23:37:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=VQgZEeHJdf6Bfk1LIoWC2HIkTuWyVFZe6jHDYc9nISE=; b=MTOO3T/7o4+Kk3jwJNeTNrbRnWQRL6blOAlspjkX9zFyM6aHksKTw5L9lX8ZhG//Ke MRbs9dmfhRppCWYeENEHFnKToI3YNcFN0GTIaqMRgzaxHF+ARvRFMEEGLbEG7gIWgJyn 82/AghDRLileNUQNudm9qZHISDiEwDDqdF4Bw= 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=VQgZEeHJdf6Bfk1LIoWC2HIkTuWyVFZe6jHDYc9nISE=; b=skK/3IGVZJCLMuAta0eRPRawdwEW3Lv8p/jqjVo6WEyygHvmGskVz2Qfh1/Zvor+gU +gisTdL8v3ZFWZP8gPwMjd3e7/jrbUoyDbV5v1/0bHzorEN3sI0+hYQppsLGDviSY3T8 fofosqyFl7owz4ZKJFCuj8zgcpENrwRpj88umFhE4jCjmepWkWwvThFfjhyjq5hWmT7s RfnxA0uSWzPKe9Ek1t+uj8wNbcRx36LmvyLjSu1LiHZHGvBThDeBFTi4uBJ/HJBrYmsA US9yGqLdNkOkpPeFuLokSYSS4x/WG3oG5DEdcfmXGjESZP/Hhrqq/pMpvnX4Gv5fk6sn VUQQ== X-Gm-Message-State: AOAM533r9xTmde8MNqqQmAI20QUtP9gOFc5mxxJlo43OPmWSo9Rnw90C 6h7mX/5Us68IIpxlbOVPw3KZr35q0Pn8NtYzOjUrTA== X-Received: by 2002:a9d:46e:: with SMTP id 101mr1053650otc.303.1614325026472; Thu, 25 Feb 2021 23:37:06 -0800 (PST) MIME-Version: 1.0 References: <20210226040908.3274666-1-john.stultz@linaro.org> In-Reply-To: <20210226040908.3274666-1-john.stultz@linaro.org> From: Daniel Vetter Date: Fri, 26 Feb 2021 08:36:55 +0100 Message-ID: Subject: Re: [PATCH] dma-buf: heaps: Set VM_PFNMAP in mmap for system and cma heaps To: John Stultz Cc: lkml , Jason Gunthorpe , Christian Koenig , Sumit Semwal , Liam Mark , Chris Goldsworthy , Laura Abbott , Brian Starkey , Hridya Valsaraju , Suren Baghdasaryan , Sandeep Patil , Daniel Mentz , =?UTF-8?Q?=C3=98rjan_Eide?= , Robin Murphy , Ezequiel Garcia , Simon Ser , James Jones , "open list:DMA BUFFER SHARING FRAMEWORK" , dri-devel Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Feb 26, 2021 at 5:09 AM John Stultz wrote: > > Per discussion and patches here: > https://lore.kernel.org/dri-devel/20210223105951.912577-1-daniel.vetter= @ffwll.ch/ > > Daniel is planning on making VM_PFNMAP required on dmabufs. > > Thus to avoid the warn_on noise, set the VM_PFNMAP in the > system and cma heap's mmap handler. > > Cc: Daniel Vetter > Cc: Jason Gunthorpe > Cc: Christian Koenig > Cc: Sumit Semwal > Cc: Liam Mark > Cc: Chris Goldsworthy > Cc: Laura Abbott > Cc: Brian Starkey > Cc: Hridya Valsaraju > Cc: Suren Baghdasaryan > Cc: Sandeep Patil > Cc: Daniel Mentz > Cc: =C3=98rjan Eide > Cc: Robin Murphy > Cc: Ezequiel Garcia > Cc: Simon Ser > Cc: James Jones > Cc: linux-media@vger.kernel.org > Cc: dri-devel@lists.freedesktop.org > Signed-off-by: John Stultz System heap uses remap_pfn_range so looks fine, but cma heap inserts pages, and that's not fine for VM_PFNMAP. You need to use vm_insert_pfn or remap_pfn_range or one of the related pfn mapping functions for that too. I think this should splat when you run it. Also note that remap_pfn_range updates the vma flags already correctly for you, so you probably don't want to do that. Also given that both deal with struct page there's a ton of divergence between these two that doesn't make much sense. Maybe could even share the code fully, aside from how you allocate the struct pages. -Daniel > --- > drivers/dma-buf/heaps/cma_heap.c | 1 + > drivers/dma-buf/heaps/system_heap.c | 4 +++- > 2 files changed, 4 insertions(+), 1 deletion(-) > > diff --git a/drivers/dma-buf/heaps/cma_heap.c b/drivers/dma-buf/heaps/cma= _heap.c > index 364fc2f3e499..34bc3987f942 100644 > --- a/drivers/dma-buf/heaps/cma_heap.c > +++ b/drivers/dma-buf/heaps/cma_heap.c > @@ -185,6 +185,7 @@ static int cma_heap_mmap(struct dma_buf *dmabuf, stru= ct vm_area_struct *vma) > > vma->vm_ops =3D &dma_heap_vm_ops; > vma->vm_private_data =3D buffer; > + vma->vm_flags |=3D VM_PFNMAP; > > return 0; > } > diff --git a/drivers/dma-buf/heaps/system_heap.c b/drivers/dma-buf/heaps/= system_heap.c > index 3548b20cb98c..8995e3cbfcaf 100644 > --- a/drivers/dma-buf/heaps/system_heap.c > +++ b/drivers/dma-buf/heaps/system_heap.c > @@ -228,8 +228,10 @@ static int system_heap_mmap(struct dma_buf *dmabuf, = struct vm_area_struct *vma) > return ret; > addr +=3D PAGE_SIZE; > if (addr >=3D vma->vm_end) > - return 0; > + break; > } > + > + vma->vm_flags |=3D VM_PFNMAP; > return 0; > } > > -- > 2.25.1 > --=20 Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch