From mboxrd@z Thu Jan 1 00:00:00 1970 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=-8.7 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,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 F0B6CC48BD7 for ; Thu, 27 Jun 2019 12:52:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C4D6F214DA for ; Thu, 27 Jun 2019 12:52:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727025AbfF0MwM (ORCPT ); Thu, 27 Jun 2019 08:52:12 -0400 Received: from mga04.intel.com ([192.55.52.120]:36562 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727000AbfF0MwK (ORCPT ); Thu, 27 Jun 2019 08:52:10 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 27 Jun 2019 05:52:10 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.63,423,1557212400"; d="scan'208";a="245805992" Received: from black.fi.intel.com (HELO black.fi.intel.com.) ([10.237.72.28]) by orsmga001.jf.intel.com with ESMTP; 27 Jun 2019 05:52:09 -0700 From: Alexander Shishkin To: Greg Kroah-Hartman Cc: linux-kernel@vger.kernel.org, Alexander Shishkin , Andy Shevchenko Subject: [GIT PULL 6/9] intel_th: msu: Prevent freeing buffers while locked windows exist Date: Thu, 27 Jun 2019 15:51:49 +0300 Message-Id: <20190627125152.54905-7-alexander.shishkin@linux.intel.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190627125152.54905-1-alexander.shishkin@linux.intel.com> References: <20190627125152.54905-1-alexander.shishkin@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 Reviewed-by: Andy Shevchenko --- 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