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: 358297 Delivered-To: patches@linaro.org Received: by 2002:a02:85a7:0:0:0:0:0 with SMTP id d36csp812981jai; Thu, 7 Jan 2021 13:15:31 -0800 (PST) X-Received: by 2002:a65:5244:: with SMTP id q4mr3757309pgp.50.1610054131372; Thu, 07 Jan 2021 13:15:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610054131; cv=none; d=google.com; s=arc-20160816; b=tYYN1kuSlCA6wFy6UHsh7uBAN2VT6p0zh8ddbvu9t2vt3A1dzuCYhXJNtZ+vrVGpIU 6gX2/nn2IgLIjVQgVFPbytJUihAqdsLDbUdLxm4qywp+XZWNfW0KgUWlrjz3Ztm2jq8N STfNvcqzK0tpy7lVfqBfRcsQJdtPsvxGea+qMPB3CR39aRT9bjOK/lB+6MxTyMmkiHTq npWUSNGGQgKbkX6UOEndswdTTOi/aXN5ETy8u5bWl2JUxMMsln0q8N1aZoLMwnFiXzty a0sYULIEFlrB+WBjg5n0Txi0T17JCl+3tWPqMCnOf57gs5pCCDc9FHNsf5/d90e4qXCx CmjA== 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=asRy932HT705wl7auqiZreOm/Tf6xZMTwgSgKPXXz2b/5tRqnGqbfDJJrZ6Ff9sHGo jbig1s+6VdDXR8EOmFUpIDkp+RPcdk0HVIUgFZfcPglopR/7F4an7Rd0aQjGvnEYQGox +6fkO+E+YU+s+26PsWUPoDABHosNbJoa78VbWY992DHx0dqfI6qdhNawU2qOZZQS6WVC cqosmc4kMEwWhNVoh38kKnsclmHvBpgrqQanM57UFRT96R6zhqPcT82TNBavlbaJHiNp /f3Dg/52bwy4kUcpw6518eNQhZfJ22fNA2JROGcm+TTUdcybPD9xql22Z7107F8JrxRy OcAA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=cHSZgqcz; 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 c9sor3260944pfj.15.2021.01.07.13.15.31 for (Google Transport Security); Thu, 07 Jan 2021 13:15:31 -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=cHSZgqcz; 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=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=Y1XlYiV3mpzOJKWqWwhI65FnVvXx2Q35kYBIMw9vPuWPmU6R88yXSfQAbk7g39HTXH 1ENxz2NVIWUKAmyiDayweHWOmiBjNHgoK/twufbdANU1ApVmc7E0aaMDCWJ4S+tdWvpY Xo3b8MstcWKUZm0uq4TFiGo5SjmN9g3CjB5XHLEajMQHtWv4xDPiCkCClxnwLtIqKFHQ OJS0h1iylgnnqcaLxjBhHZIF92kgVpGqtfb9puIkwXFY9nbLR+qXR4intPbIQuWTsO7Y zEZC4jNvubtp6Iwlf38U6yGHgQagImbmfX2uenXFohM0eDdqA1yNCXr+oXfbHsby35Vq Zygg== X-Gm-Message-State: AOAM530sw0OO/VfPewoxvFhkR5C3ErOXz1bmmGdamQOXX7dJ3F7QAHuD ZoCVDfvag05uSaTdOcU1kuuQOFFf 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) Return-Path: 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 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: [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 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;