From patchwork Tue Jan 19 20:45:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 366217 Delivered-To: patches@linaro.org Received: by 2002:a02:a60d:0:0:0:0:0 with SMTP id c13csp1100503jam; Tue, 19 Jan 2021 12:45:14 -0800 (PST) X-Received: by 2002:a17:90a:b284:: with SMTP id c4mr1591295pjr.183.1611089114110; Tue, 19 Jan 2021 12:45:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611089114; cv=none; d=google.com; s=arc-20160816; b=jH42pX28qrDLr8z8gvTL6XDZ8A3krj8gAncjPgl5coijkWgq8tsVov9DcDatlLzDJX 8dTTA4Xgq9Re3HR3FHzUsKttlZngmsKbzLAAzlvCJhz4sTtt2G3PRvkp8JKkq8o6T4vW 1NDrDLq3Rq/XCNh11wyJQIKpGCfg00utD+T+UoN6jtA062+FyoNpYYiHPUfRir/Basdh JoEfzrafI31fDidCltbGItBT4FzSsd/NXZbY2Aorj+UBq4m2OtOSaOi31ZiTuU0Wtglz BjFKZSVW7jr4FjnGqrHJnBdADYmjYRR327pSNsunhHGVpV4aPOWgBZ5Ndk+bf/eXoK8a eVJw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=+HPHLTIbnqvyYqZakEN0yW6023R2vX5SvJvHEGRsu88=; b=0ygS5Ei6CaPF0gAAtQ07gc4EbEq1EGKLOqmKd1xEgHKpXEHaxYDDzqPwn6cJTI+Eff ODhmhyHRp6urme+KUa7YuedMRJN7lUQmLZwufomeHwstha08pLLrgJ0AT3Dw1mloy2La M0uQpp9O7eO8H6/RqYR6TBXe3qN+C4sG0SDWSTX9N50hxO4smfD6rjUx0wgCk5dpo9ez k+zZdPJgpc+YXdjpVCxdBbgn/p3cgsl0z42yTwhfSZsPnBbDO/gYZnfA0hdE2kUOwlsX 1k0Ohl7NuYnR6Sm+l8jLz4AjQePGGKpNnG89FF+ZjtidJVNZw23pUXIC/YhfJd9P2wyF gIJw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=rVY83dpi; spf=pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.41 as permitted sender) smtp.mailfrom=john.stultz@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f41.google.com (mail-sor-f41.google.com. [209.85.220.41]) by mx.google.com with SMTPS id b5sor19945pfa.14.2021.01.19.12.45.14 for (Google Transport Security); Tue, 19 Jan 2021 12:45:14 -0800 (PST) Received-SPF: pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=rVY83dpi; spf=pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.41 as permitted sender) smtp.mailfrom=john.stultz@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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=rVY83dpi8ReoTmjM5P+oExiEZYsinMGkbYee1lkK/ULznES2ZNsQayfBScXWTZxwHT xzR9TWfOeB0CMtADGKZkF8TcwHODZPc1u4AMryo79Zq9NNv2fP2u7rpmstz007F5Nwzb fYc/mdbBQq3n41ctal8AiQZluORE84aHZh48bd34Zb95cR6VzRRKiIQtqtWHSWK5Ql/Z 37MtMXfQhlWisjAseq7aB5u02jTDZwCwRQhmEw5cye33lLvuVq6TSjWkKCFJCnRio0sf Jg4mseBZ0ILUNtu46AlrTKRbSYK79YX03tEGKvAoDHj4I2D3x6wz8PcifiCFUrwR00mS hKXA== 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=i+gCUpeXFoUB5YALFExcsT5KDbFMRI60Rm6Ly3whey6t6Ku1o6v+Y60IDg2T2whuXn GsZnsn9z3xb22bXFse/siLnjXYUx0VhmleIhW5TDCzglEUlhnjCbfj3yC6OUXvbkSiKU ynr7ZqtUFYxi545AyASaoWgZpfffWiPAf4ocZ2DA6YPO0j3ojvWpRCgIluT//DSKpnh1 FnpG2DgEu8qbaVEXqF0d2J99IwcY+8/561RFDHRmcVOyRzgu444UzPp/fsyinU7tkGxj QNBxhHa6DF5k3zuKGQQyBFAqNQM6fQ8YwaMixhLlCcQcXGR2/cfTE9BX5A2SHVufiWUQ dofw== X-Gm-Message-State: AOAM530beQh+LEvwKiC4ec7z+qJvJp/AwqXbrxM1CYb3XJ7YFopE8ZqI yqIhccwpVvBzRGBwW6M314muGSDb X-Google-Smtp-Source: ABdhPJx7XqKFUvEfxsZUM/yPecJslI2EJghoNxHC6weKaxS/Wdl7E5UFXQpws/ka9g4TjNc2jaAWIA== X-Received: by 2002:a62:5b07:0:b029:1ae:177d:69e1 with SMTP id p7-20020a625b070000b02901ae177d69e1mr5644437pfb.25.1611089113811; Tue, 19 Jan 2021 12:45:13 -0800 (PST) Return-Path: Received: from localhost.localdomain ([2601:1c2:680:1319:692:26ff:feda:3a81]) by smtp.gmail.com with ESMTPSA id md7sm4129838pjb.52.2021.01.19.12.45.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Jan 2021 12:45:12 -0800 (PST) From: John Stultz To: lkml Cc: John Stultz , Sumit Semwal , 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 , linux-media@vger.kernel.org, dri-devel@lists.freedesktop.org Subject: [RESEND][PATCH 2/3] dma-buf: heaps: Add a WARN_ON should the vmap_cnt go negative Date: Tue, 19 Jan 2021 20:45:07 +0000 Message-Id: <20210119204508.9256-2-john.stultz@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210119204508.9256-1-john.stultz@linaro.org> References: <20210119204508.9256-1-john.stultz@linaro.org> MIME-Version: 1.0 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(+) -- 2.17.1 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;