public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Alexander Shishkin <alexander.shishkin@linux.intel.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: linux-kernel@vger.kernel.org,
	Alexander Shishkin <alexander.shishkin@linux.intel.com>,
	Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Subject: [GIT PULL 6/9] intel_th: msu: Prevent freeing buffers while locked windows exist
Date: Thu, 27 Jun 2019 15:51:49 +0300	[thread overview]
Message-ID: <20190627125152.54905-7-alexander.shishkin@linux.intel.com> (raw)
In-Reply-To: <20190627125152.54905-1-alexander.shishkin@linux.intel.com>

We already prevent freeing buffers via sysfs interface in case there are
existing users or if trace is active. Treat the existence of locked windows
similarly and return -EBUSY on attempts to free the buffer. When the last
window is unlocked, the freeing will succeed.

Signed-off-by: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/hwtracing/intel_th/msu.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/hwtracing/intel_th/msu.c b/drivers/hwtracing/intel_th/msu.c
index fc9890e56e5b..f2d52c025528 100644
--- a/drivers/hwtracing/intel_th/msu.c
+++ b/drivers/hwtracing/intel_th/msu.c
@@ -703,6 +703,11 @@ static int msc_win_set_lockout(struct msc_window *win, int expect, int new)
 	if (expect == WIN_LOCKED && old == new)
 		return 0;
 
+	if (old == expect && new == WIN_LOCKED)
+		atomic_inc(&win->msc->user_count);
+	else if (old == expect && old == WIN_LOCKED)
+		atomic_dec(&win->msc->user_count);
+
 	if (WARN_ONCE(old != expect, "expected lockout state %d, got %d\n",
 		      expect, old))
 		return -EINVAL;
-- 
2.20.1


  parent reply	other threads:[~2019-06-27 12:52 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-27 12:51 [GIT PULL 0/9] intel_th: Updates for v5.3 Alexander Shishkin
2019-06-27 12:51 ` [GIT PULL 1/9] intel_th: msu: Fix unused variable warning on arm64 platform Alexander Shishkin
2019-07-03 15:45   ` Greg Kroah-Hartman
2019-07-03 15:45   ` Greg Kroah-Hartman
2019-07-03 15:54     ` Alexander Shishkin
2019-07-03 15:58       ` Greg Kroah-Hartman
2019-07-03 16:03         ` Alexander Shishkin
2019-06-27 12:51 ` [GIT PULL 2/9] intel_th: msu: Support multipage blocks Alexander Shishkin
2019-06-27 12:51 ` [GIT PULL 3/9] intel_th: msu: Split sgt array and pointer in multiwindow mode Alexander Shishkin
2019-06-27 12:51 ` [GIT PULL 4/9] intel_th: msu: Start read iterator from a non-empty window Alexander Shishkin
2019-06-27 12:51 ` [GIT PULL 5/9] intel_th: msu: Introduce buffer driver interface Alexander Shishkin
2019-07-03 15:55   ` Greg Kroah-Hartman
2019-07-03 16:33     ` Alexander Shishkin
2019-07-03 16:49       ` Greg Kroah-Hartman
2019-07-05 15:08     ` Alexander Shishkin
2019-06-27 12:51 ` Alexander Shishkin [this message]
2019-06-27 12:51 ` [GIT PULL 7/9] intel_th: msu: Get rid of the window size limit Alexander Shishkin
2019-06-27 12:51 ` [GIT PULL 8/9] intel_th: msu-sink: An example msu buffer driver Alexander Shishkin
2019-07-03 15:56   ` Greg Kroah-Hartman
2019-06-27 12:51 ` [GIT PULL 9/9] intel_th: msu: Preserve pre-existing buffer configuration Alexander Shishkin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190627125152.54905-7-alexander.shishkin@linux.intel.com \
    --to=alexander.shishkin@linux.intel.com \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox