Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp840678pxb; Thu, 21 Jan 2021 23:58:35 -0800 (PST) X-Google-Smtp-Source: ABdhPJyRWqNWl3Ol80qejAQH8U6nJHgj3HkoZzOdECg/eT/yNcwa0oaq/VsJFVdyP3aaAa2ErGZx X-Received: by 2002:aa7:cf90:: with SMTP id z16mr2275551edx.218.1611302315299; Thu, 21 Jan 2021 23:58:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611302315; cv=none; d=google.com; s=arc-20160816; b=tcYrnbb24WDe+4GKHUijmbMJa8aw1PSc8F7B9PR/UBt3wvqVucaFoA9xL4DzkadMvk 5ELZ5qwKSYWCUcXM5lp0mwpJH6iggf0/5Zk/+pBGvxed0Y/OGDom7q3IRLb39rNmpWGB GLpsMl77cq9QDP/WypDQdWCrR5vbMJHE2BaZ0BA6Luj32NB60VP4tA3D2Jb156EOzV9Z 2KdsitYCAORI1uDWMEVAF6EjoAWK0LvnAh438Ivj1gu9dJ1f4fHTfkdkZ6CKZnS4xVRH P5mpI7UNaqpc/aG9SLwtSMbT54x8COv4QQQYHEp86O8NR+QB16xXNLTUyf4PtznCgtQH x7Ng== 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=f2zRDUhBwnVP7tCaaBYDyBHO3WlC21+sK4f4qAGJOCI=; b=FkIIsgmXLmENkm+Awnnfr2qm+TXJu1uGDIQFjWgcdOjooPC7c8hh9da2TgxBq/5aPX 2JiY/C5HPU1KLdJEhnEJFVkS67iI25HEuZ5X2nkJprKOO7JJ9zIkZn16ebMi4Zvuiv9h 3tIqi+F30EXB/5qry7nXVgMNcP+kH0IZWEcF0qdGtrT3YHmgYNDEVuUIjgqPxVAUHBgg PAWhQowxziLFj2G60eDZpy6PVwDmtUW1vFB045+NfMl6F1VbB4WzD1OeR/buxpF2U3wE 4Vd4a675+buI2LNz4H9ulKQhu+UTh+LGBOCrLvZ8Reo0d2UBO0fPstkDcqZ7Xc/DxL6s XaFw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ooLdJkAT; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j15si3270834edv.474.2021.01.21.23.58.11; Thu, 21 Jan 2021 23:58:35 -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=@linaro.org header.s=google header.b=ooLdJkAT; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726351AbhAVH53 (ORCPT + 99 others); Fri, 22 Jan 2021 02:57:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52102 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726704AbhAVH50 (ORCPT ); Fri, 22 Jan 2021 02:57:26 -0500 Received: from mail-lf1-x134.google.com (mail-lf1-x134.google.com [IPv6:2a00:1450:4864:20::134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E02EDC06174A for ; Thu, 21 Jan 2021 23:56:41 -0800 (PST) Received: by mail-lf1-x134.google.com with SMTP id o17so6296160lfg.4 for ; Thu, 21 Jan 2021 23:56:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=f2zRDUhBwnVP7tCaaBYDyBHO3WlC21+sK4f4qAGJOCI=; b=ooLdJkATi6/2fEB5idp2CRg5f3UiIOidhHf3ayOHeKjzppxkT0HkFh1Qpt0+cx2scW 9TRsscg8UxCHBswLJk3rlH+y2AU+wqUJbRDxCcs2PU6F/Fl9Q1XghsLC0Im+Yb4S2H5I n1s6qqC3k+2t6r/GL0itPdpmTPBXjXfxS1UWz908azcwM1jJHQFBYOqmnhqBUGBw0HD9 J0CSEqdsJAOvna2Q56Y9w9g91cBA18gOe/aXbr/RVSEVgzlWiM5lvWlFY2alEyykArkq JcBiUItzm89cgvg5yLmWhiUajU/rFsvwNxy7Iv1d5gT5s08tweA4y6yqT9ErV1YVjCaw x6nQ== 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=f2zRDUhBwnVP7tCaaBYDyBHO3WlC21+sK4f4qAGJOCI=; b=JXbAiN+xooReFlGGyLSMMCFTUJm5qHiv0gxGOF2IHhiIBFckyXChZkKNy23wq3zgZE igwDsh3OhUdYa5BVGYdvmaCNg3UuBVQDdtQxxVOGNlhp/B8LOTDijgb6K8sVTyV+4OzL 2r7plko2RMv7LUa53SmSPQj+KL8GI4Hg7z1uye//8Ab5szaOxqqNrQj5u9At6r8zav+m 3bOxnIadViOAfklhkFcBChJCEsuGRu2S9Z436ruoXP/0/zSSZwxInX5eB1LNLLZggAkI 9SUmzuB6riePAEASvo//Imc+/5zMeFLZXC/p7g1s5Tf6fRYeJmzPhFaLKdyqoRA/qu2k Hx+w== X-Gm-Message-State: AOAM533ANXdxcP+hN3x31/9AWZN0ITPveaO6QhX8r4QYhiAhX88+c3sM RdBuFwKceDMBICueqqhT7oNk5RpKLqjNHxQHjj7u6w== X-Received: by 2002:a19:7616:: with SMTP id c22mr25218lff.550.1611302200416; Thu, 21 Jan 2021 23:56:40 -0800 (PST) MIME-Version: 1.0 References: <20210119204508.9256-1-john.stultz@linaro.org> <20210119204508.9256-2-john.stultz@linaro.org> In-Reply-To: <20210119204508.9256-2-john.stultz@linaro.org> From: Sumit Semwal Date: Fri, 22 Jan 2021 13:26:29 +0530 Message-ID: Subject: Re: [RESEND][PATCH 2/3] dma-buf: heaps: Add a WARN_ON should the vmap_cnt go negative To: John Stultz Cc: lkml , Liam Mark , Laura Abbott , Brian Starkey , Hridya Valsaraju , Suren Baghdasaryan , Sandeep Patil , Daniel Mentz , Chris Goldsworthy , =?UTF-8?Q?=C3=98rjan_Eide?= , Robin Murphy , Ezequiel Garcia , Simon Ser , James Jones , "open list:DMA BUFFER SHARING FRAMEWORK" , DRI mailing list Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi John, Suren, On Wed, 20 Jan 2021 at 02:15, John Stultz wrote: > > We shouldn't vunmap more then we vmap, but if we do, make > sure we complain loudly. I was checking the general usage of vunmap in the kernel, and I couldn't find many instances where we need to WARN_ON for the vunmap count more than vmap count. Is there a specific need for this in the heaps? Best, Sumit. > > Cc: Sumit Semwal > Cc: Liam Mark > Cc: Laura Abbott > Cc: Brian Starkey > Cc: Hridya Valsaraju > Cc: Suren Baghdasaryan > Cc: Sandeep Patil > Cc: Daniel Mentz > Cc: Chris Goldsworthy > 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 > Suggested-by: Suren Baghdasaryan > Signed-off-by: John Stultz > --- > drivers/dma-buf/heaps/cma_heap.c | 1 + > drivers/dma-buf/heaps/system_heap.c | 1 + > 2 files changed, 2 insertions(+) > > diff --git a/drivers/dma-buf/heaps/cma_heap.c b/drivers/dma-buf/heaps/cma= _heap.c > index 364fc2f3e499..0c76cbc3fb11 100644 > --- a/drivers/dma-buf/heaps/cma_heap.c > +++ b/drivers/dma-buf/heaps/cma_heap.c > @@ -232,6 +232,7 @@ static void cma_heap_vunmap(struct dma_buf *dmabuf, s= truct dma_buf_map *map) > struct cma_heap_buffer *buffer =3D dmabuf->priv; > > mutex_lock(&buffer->lock); > + WARN_ON(buffer->vmap_cnt =3D=3D 0); > if (!--buffer->vmap_cnt) { > vunmap(buffer->vaddr); > buffer->vaddr =3D NULL; > diff --git a/drivers/dma-buf/heaps/system_heap.c b/drivers/dma-buf/heaps/= system_heap.c > index 405351aad2a8..2321c91891f6 100644 > --- a/drivers/dma-buf/heaps/system_heap.c > +++ b/drivers/dma-buf/heaps/system_heap.c > @@ -273,6 +273,7 @@ static void system_heap_vunmap(struct dma_buf *dmabuf= , struct dma_buf_map *map) > struct system_heap_buffer *buffer =3D dmabuf->priv; > > mutex_lock(&buffer->lock); > + WARN_ON(buffer->vmap_cnt =3D=3D 0); > if (!--buffer->vmap_cnt) { > vunmap(buffer->vaddr); > buffer->vaddr =3D NULL; > -- > 2.17.1 >