From patchwork Thu Jan 7 21:15:24 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 12004907 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BD6DDC433E0 for ; Thu, 7 Jan 2021 21:15:34 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 840A923441 for ; Thu, 7 Jan 2021 21:15:34 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 840A923441 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B1BC16E422; Thu, 7 Jan 2021 21:15:32 +0000 (UTC) Received: from mail-pg1-x52d.google.com (mail-pg1-x52d.google.com [IPv6:2607:f8b0:4864:20::52d]) by gabe.freedesktop.org (Postfix) with ESMTPS id 759116E422 for ; Thu, 7 Jan 2021 21:15:31 +0000 (UTC) Received: by mail-pg1-x52d.google.com with SMTP id 15so5995018pgx.7 for ; Thu, 07 Jan 2021 13:15:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=+HPHLTIbnqvyYqZakEN0yW6023R2vX5SvJvHEGRsu88=; b=cHSZgqczj464Vf520gWeFxP2skBA26Gc4qDuq1k8SZeOGcfiiKTsmZsKBzVJdyquDP AwP7iEXEk3FUyf7L5lc4NpelRvFLZEqi6kU8c4hrfifAl04y8vtm7TNoDnKC63HO5SWh lvZZyVDoTP+zd7oHSx0sgJu/5FP0Do/q4vTVgiaLwFYflQVgzzvQt/kR9/i31MISy4tq LbZLvEw+G5rucP4QbGOC20BkR+d3pP9e1EqPfafczaD7SUTW8Q7US+QdpxgtZQPx7nXU sKm0TId7I+tNjCMRk2+nJ9OV9f/iHF9+aoyoW0ijSIp6Kfox+9TUooajqLsw5KAD6xDw p5Nw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=+HPHLTIbnqvyYqZakEN0yW6023R2vX5SvJvHEGRsu88=; b=bS3sB6X1/yreX2Lzlnx6qXbm2WgH0A/4iYYwzgODNaBBeD703fbEpb/yoOk0C8rUY6 xIktMo7IiumqWVHd2J0RNbaKqjp1jbVxEXNc8lM7yya4uN1d87dek1d5DsUUlE4pYNCp Eo7PyXBOd3P++W5JLTWDFBIeCC4MVukWW82/mkcMoFq2upe3jAJZYxLenssAtXFUPBmk fO+Up8LNQgheAR4MNeRcg9lQPhaSZnPwJr8aQsVOj/p1StBSZGr5x0jpgjgolpL3Iuoc v0dSxUAYKe3yCUnj4ndRNlXCfqng9ygxetxDlIIjmcMB5Jvu4m6mb/0lq3Yr0VDmg3Nb 3bHA== X-Gm-Message-State: AOAM530DKK2ZqtRUQcY5rAkoN6RaTfJyw5phezYOb3g2INThCzR6x8p0 la9eIDig7BwZlm/bedZIJ/2MEQ== X-Google-Smtp-Source: ABdhPJy9pko8exsJmRsYgHZWzS6HB4ShY5PboCyRW7n6CbWSr9ryNiq7i9X3M83nJXNVn5LYJ0D45Q== X-Received: by 2002:aa7:97bc:0:b029:19e:18c7:76b with SMTP id d28-20020aa797bc0000b029019e18c7076bmr501704pfq.23.1610054131037; Thu, 07 Jan 2021 13:15:31 -0800 (PST) Received: from localhost.localdomain ([2601:1c2:680:1319:692:26ff:feda:3a81]) by smtp.gmail.com with ESMTPSA id b6sm6574055pfd.43.2021.01.07.13.15.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Jan 2021 13:15:30 -0800 (PST) From: John Stultz To: lkml Subject: [PATCH 2/3] dma-buf: heaps: Add a WARN_ON should the vmap_cnt go negative Date: Thu, 7 Jan 2021 21:15:24 +0000 Message-Id: <20210107211525.75951-2-john.stultz@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210107211525.75951-1-john.stultz@linaro.org> References: <20210107211525.75951-1-john.stultz@linaro.org> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Sandeep Patil , dri-devel@lists.freedesktop.org, Ezequiel Garcia , Robin Murphy , James Jones , Liam Mark , Laura Abbott , Chris Goldsworthy , Hridya Valsaraju , =?utf-8?q?=C3=98rjan_Eide?= , linux-media@vger.kernel.org, Suren Baghdasaryan , Daniel Mentz Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" We shouldn't vunmap more then we vmap, but if we do, make sure we complain loudly. 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: Ørjan 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, struct dma_buf_map *map) struct cma_heap_buffer *buffer = dmabuf->priv; mutex_lock(&buffer->lock); + WARN_ON(buffer->vmap_cnt == 0); if (!--buffer->vmap_cnt) { vunmap(buffer->vaddr); buffer->vaddr = 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 = dmabuf->priv; mutex_lock(&buffer->lock); + WARN_ON(buffer->vmap_cnt == 0); if (!--buffer->vmap_cnt) { vunmap(buffer->vaddr); buffer->vaddr = NULL;