From: Alexander Shishkin <alexander.shishkin@linux.intel.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: linux-kernel@vger.kernel.org,
Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>
Subject: [PATCH v1 4/5] intel_th: msu: Prevent freeing buffers while locked windows exist
Date: Fri, 5 Jul 2019 17:14:24 +0300 [thread overview]
Message-ID: <20190705141425.19894-5-alexander.shishkin@linux.intel.com> (raw)
In-Reply-To: <20190705141425.19894-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 a6c0eb09c515..b200d9d1c7a0 100644
--- a/drivers/hwtracing/intel_th/msu.c
+++ b/drivers/hwtracing/intel_th/msu.c
@@ -724,6 +724,11 @@ static int msc_win_set_lockout(struct msc_window *win,
win->lockout = new;
+ 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);
+
unlock:
spin_unlock_irqrestore(&win->lo_lock, flags);
--
2.20.1
next prev parent reply other threads:[~2019-07-05 14:14 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-07-05 14:14 [PATCH v1 0/5] intel_th: The remainder of the updates for v5.3 Alexander Shishkin
2019-07-05 14:14 ` [PATCH v1 1/5] intel_th: msu: Introduce buffer interface Alexander Shishkin
2019-07-05 14:14 ` [PATCH v1 2/5] intel_th: msu-sink: An example msu buffer "sink" Alexander Shishkin
2019-07-05 14:14 ` [PATCH v1 3/5] intel_th: msu: Get rid of the window size limit Alexander Shishkin
2019-07-05 14:14 ` Alexander Shishkin [this message]
2019-07-05 14:14 ` [PATCH v1 5/5] 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=20190705141425.19894-5-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
all inboxes | Powered by JetHome®