All of lore.kernel.org
 help / color / mirror / Atom feed
From: tip-bot for Thomas Gleixner <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: eranian@google.com, kan.liang@intel.com,
	torvalds@linux-foundation.org, jolsa@redhat.com, hpa@zytor.com,
	acme@redhat.com, bp@alien8.de, mingo@kernel.org,
	vincent.weaver@maine.edu, andi.kleen@intel.com,
	harish.chegondi@intel.com, tglx@linutronix.de,
	linux-kernel@vger.kernel.org, jacob.jun.pan@linux.intel.com,
	peterz@infradead.org
Subject: [tip:perf/core] perf/x86/intel/uncore: Clean up hardware on exit
Date: Mon, 29 Feb 2016 03:05:13 -0800	[thread overview]
Message-ID: <tip-a46195f1782e94ad07e7485fb15b80db7e60e7aa@git.kernel.org> (raw)
In-Reply-To: <20160222221011.023930023@linutronix.de>

Commit-ID:  a46195f1782e94ad07e7485fb15b80db7e60e7aa
Gitweb:     http://git.kernel.org/tip/a46195f1782e94ad07e7485fb15b80db7e60e7aa
Author:     Thomas Gleixner <tglx@linutronix.de>
AuthorDate: Mon, 22 Feb 2016 22:19:11 +0000
Committer:  Ingo Molnar <mingo@kernel.org>
CommitDate: Mon, 29 Feb 2016 09:35:15 +0100

perf/x86/intel/uncore: Clean up hardware on exit

When tearing down the boxes nothing undoes the hardware state which was setup
by box->init_box(). Add a box->exit_box() callback and implement it for the
uncores which have an init_box() callback.

This misses the cleanup in the error exit pathes, but I cannot be bothered to
implement it before cleaning up the rest of the driver, which makes that task
way simpler.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: Andi Kleen <andi.kleen@intel.com>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Harish Chegondi <harish.chegondi@intel.com>
Cc: Jacob Pan <jacob.jun.pan@linux.intel.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Kan Liang <kan.liang@intel.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Cc: Vince Weaver <vincent.weaver@maine.edu>
Cc: linux-kernel@vger.kernel.org
Link: http://lkml.kernel.org/r/20160222221011.023930023@linutronix.de
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 arch/x86/events/intel/uncore.c       |  6 +++++-
 arch/x86/events/intel/uncore.h       |  9 +++++++++
 arch/x86/events/intel/uncore_nhmex.c |  6 ++++++
 arch/x86/events/intel/uncore_snb.c   | 13 +++++++++++++
 4 files changed, 33 insertions(+), 1 deletion(-)

diff --git a/arch/x86/events/intel/uncore.c b/arch/x86/events/intel/uncore.c
index 42ea435..c3d1cbb 100644
--- a/arch/x86/events/intel/uncore.c
+++ b/arch/x86/events/intel/uncore.c
@@ -937,6 +937,7 @@ static int uncore_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id
 		raw_spin_lock(&uncore_box_lock);
 		list_del(&box->list);
 		raw_spin_unlock(&uncore_box_lock);
+		uncore_box_exit(box);
 		kfree(box);
 	}
 	return ret;
@@ -982,6 +983,7 @@ static void uncore_pci_remove(struct pci_dev *pdev)
 	}
 
 	WARN_ON_ONCE(atomic_read(&box->refcnt) != 1);
+	uncore_box_exit(box);
 	kfree(box);
 
 	if (last_box)
@@ -1091,8 +1093,10 @@ static void uncore_cpu_dying(int cpu)
 			pmu = &type->pmus[j];
 			box = *per_cpu_ptr(pmu->box, cpu);
 			*per_cpu_ptr(pmu->box, cpu) = NULL;
-			if (box && atomic_dec_and_test(&box->refcnt))
+			if (box && atomic_dec_and_test(&box->refcnt)) {
 				list_add(&box->list, &boxes_to_free);
+				uncore_box_exit(box);
+			}
 		}
 	}
 }
diff --git a/arch/x86/events/intel/uncore.h b/arch/x86/events/intel/uncore.h
index a18cc7f..cf2cb1f 100644
--- a/arch/x86/events/intel/uncore.h
+++ b/arch/x86/events/intel/uncore.h
@@ -61,6 +61,7 @@ struct intel_uncore_type {
 
 struct intel_uncore_ops {
 	void (*init_box)(struct intel_uncore_box *);
+	void (*exit_box)(struct intel_uncore_box *);
 	void (*disable_box)(struct intel_uncore_box *);
 	void (*enable_box)(struct intel_uncore_box *);
 	void (*disable_event)(struct intel_uncore_box *, struct perf_event *);
@@ -306,6 +307,14 @@ static inline void uncore_box_init(struct intel_uncore_box *box)
 	}
 }
 
+static inline void uncore_box_exit(struct intel_uncore_box *box)
+{
+	if (test_and_clear_bit(UNCORE_BOX_FLAG_INITIATED, &box->flags)) {
+		if (box->pmu->type->ops->exit_box)
+			box->pmu->type->ops->exit_box(box);
+	}
+}
+
 static inline bool uncore_box_is_fake(struct intel_uncore_box *box)
 {
 	return (box->phys_id < 0);
diff --git a/arch/x86/events/intel/uncore_nhmex.c b/arch/x86/events/intel/uncore_nhmex.c
index e89bf5c..cda5693 100644
--- a/arch/x86/events/intel/uncore_nhmex.c
+++ b/arch/x86/events/intel/uncore_nhmex.c
@@ -201,6 +201,11 @@ static void nhmex_uncore_msr_init_box(struct intel_uncore_box *box)
 	wrmsrl(NHMEX_U_MSR_PMON_GLOBAL_CTL, NHMEX_U_PMON_GLOBAL_EN_ALL);
 }
 
+static void nhmex_uncore_msr_exit_box(struct intel_uncore_box *box)
+{
+	wrmsrl(NHMEX_U_MSR_PMON_GLOBAL_CTL, 0);
+}
+
 static void nhmex_uncore_msr_disable_box(struct intel_uncore_box *box)
 {
 	unsigned msr = uncore_msr_box_ctl(box);
@@ -250,6 +255,7 @@ static void nhmex_uncore_msr_enable_event(struct intel_uncore_box *box, struct p
 
 #define NHMEX_UNCORE_OPS_COMMON_INIT()				\
 	.init_box	= nhmex_uncore_msr_init_box,		\
+	.exit_box	= nhmex_uncore_msr_exit_box,		\
 	.disable_box	= nhmex_uncore_msr_disable_box,		\
 	.enable_box	= nhmex_uncore_msr_enable_box,		\
 	.disable_event	= nhmex_uncore_msr_disable_event,	\
diff --git a/arch/x86/events/intel/uncore_snb.c b/arch/x86/events/intel/uncore_snb.c
index 2049d26..120e106 100644
--- a/arch/x86/events/intel/uncore_snb.c
+++ b/arch/x86/events/intel/uncore_snb.c
@@ -95,6 +95,12 @@ static void snb_uncore_msr_init_box(struct intel_uncore_box *box)
 	}
 }
 
+static void snb_uncore_msr_exit_box(struct intel_uncore_box *box)
+{
+	if (box->pmu->pmu_idx == 0)
+		wrmsrl(SNB_UNC_PERF_GLOBAL_CTL, 0);
+}
+
 static struct uncore_event_desc snb_uncore_events[] = {
 	INTEL_UNCORE_EVENT_DESC(clockticks, "event=0xff,umask=0x00"),
 	{ /* end: all zeroes */ },
@@ -116,6 +122,7 @@ static struct attribute_group snb_uncore_format_group = {
 
 static struct intel_uncore_ops snb_uncore_msr_ops = {
 	.init_box	= snb_uncore_msr_init_box,
+	.exit_box	= snb_uncore_msr_exit_box,
 	.disable_event	= snb_uncore_msr_disable_event,
 	.enable_event	= snb_uncore_msr_enable_event,
 	.read_counter	= uncore_msr_read_counter,
@@ -231,6 +238,11 @@ static void snb_uncore_imc_init_box(struct intel_uncore_box *box)
 	box->hrtimer_duration = UNCORE_SNB_IMC_HRTIMER_INTERVAL;
 }
 
+static void snb_uncore_imc_exit_box(struct intel_uncore_box *box)
+{
+	iounmap(box->io_addr);
+}
+
 static void snb_uncore_imc_enable_box(struct intel_uncore_box *box)
 {}
 
@@ -458,6 +470,7 @@ static struct pmu snb_uncore_imc_pmu = {
 
 static struct intel_uncore_ops snb_uncore_imc_ops = {
 	.init_box	= snb_uncore_imc_init_box,
+	.exit_box	= snb_uncore_imc_exit_box,
 	.enable_box	= snb_uncore_imc_enable_box,
 	.disable_box	= snb_uncore_imc_disable_box,
 	.disable_event	= snb_uncore_imc_disable_event,

  reply	other threads:[~2016-02-29 11:06 UTC|newest]

Thread overview: 58+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-22 22:19 [patch V3 00/28] x86/perf/intel/uncore|rapl: Fix error handling and sanitize pmu management Thomas Gleixner
2016-02-22 22:19 ` [patch V3 01/28] x86/perf/intel/uncore: Remove pointless mask check Thomas Gleixner
2016-02-29 11:03   ` [tip:perf/core] perf/x86/intel/uncore: " tip-bot for Thomas Gleixner
2016-02-22 22:19 ` [patch V3 02/28] x86/perf/intel/uncore: Simplify error rollback Thomas Gleixner
2016-02-29 11:03   ` [tip:perf/core] perf/x86/intel/uncore: " tip-bot for Thomas Gleixner
2016-02-22 22:19 ` [patch V3 03/28] x86/perf/intel/uncore: Fix error handling Thomas Gleixner
2016-02-29 11:04   ` [tip:perf/core] perf/x86/intel/uncore: " tip-bot for Thomas Gleixner
2016-02-22 22:19 ` [patch V3 04/28] x86/perf/intel/uncore: Add sanity checks for pci dev package id Thomas Gleixner
2016-02-29 11:04   ` [tip:perf/core] perf/x86/intel/uncore: Add sanity checks for PCI " tip-bot for Thomas Gleixner
2016-02-22 22:19 ` [patch V3 05/28] x86/perf/intel_uncore: Cleanup hardware on exit Thomas Gleixner
2016-02-29 11:05   ` tip-bot for Thomas Gleixner [this message]
2016-02-22 22:19 ` [patch V3 06/28] x86/perf/intel/uncore: Drop pointless hotplug priority Thomas Gleixner
2016-02-22 22:19 ` [patch V3 07/28] x86/perf/intel_uncore: Make code readable Thomas Gleixner
2016-02-29 11:05   ` [tip:perf/core] perf/x86/intel/uncore: Make code more readable tip-bot for Thomas Gleixner
2016-02-22 22:19 ` [patch V3 08/28] x86/perf/uncore: Make uncore_pcibus_to_physid static Thomas Gleixner
2016-02-29 11:06   ` [tip:perf/core] perf/x86/uncore: Make uncore_pcibus_to_physid() static tip-bot for Thomas Gleixner
2016-02-22 22:19 ` [patch V3 09/28] perf: Allow storage of pmu private data in event Thomas Gleixner
2016-02-29 11:06   ` [tip:perf/core] perf: Allow storage of PMU " tip-bot for Thomas Gleixner
2016-02-22 22:19 ` [patch V3 10/28] x86/perf/intel_uncore: Store box in event->pmu_private Thomas Gleixner
2016-02-29 11:06   ` [tip:perf/core] perf/x86/intel/uncore: " tip-bot for Thomas Gleixner
2016-02-22 22:19 ` [patch V3 11/28] x86/topology: Create logical package id Thomas Gleixner
2016-02-29 11:07   ` [tip:perf/core] " tip-bot for Thomas Gleixner
2016-02-22 22:19 ` [patch V3 12/28] x86/perf/uncore: Track packages not per cpu data Thomas Gleixner
2016-02-29 11:07   ` [tip:perf/core] perf/x86/uncore: Track packages, not per CPU data tip-bot for Thomas Gleixner
2016-02-22 22:19 ` [patch V3 13/28] x86/perf/intel_uncore: Clear all hardware state on exit Thomas Gleixner
2016-02-29 11:08   ` [tip:perf/core] perf/x86/intel/uncore: " tip-bot for Thomas Gleixner
2016-02-22 22:19 ` [patch V3 14/28] x86/perf/intel_uncore: Make PCI and MSR uncore independent Thomas Gleixner
2016-02-29 11:08   ` [tip:perf/core] perf/x86/intel/uncore: " tip-bot for Thomas Gleixner
2016-02-22 22:19 ` [patch V3 15/28] cpumask: Export cpumask_any_but Thomas Gleixner
2016-02-29 11:08   ` [tip:perf/core] cpumask: Export cpumask_any_but() tip-bot for Thomas Gleixner
2016-02-22 22:19 ` [patch V3 16/28] x86/perf/intel_uncore: Make it modular Thomas Gleixner
2016-02-22 22:19 ` [patch V3 17/28] x86/perf/cqm: Get rid of the silly for_each_cpu lookups Thomas Gleixner
2016-02-29 11:09   ` [tip:perf/core] perf/x86/intel/cqm: Get rid of the silly for_each_cpu() lookups tip-bot for Thomas Gleixner
2016-02-22 22:19 ` [patch V3 18/28] x86/perf/intel_rapl: Make Knights Landings support functional Thomas Gleixner
2016-02-29 11:09   ` [tip:perf/core] perf/x86/intel/rapl: " tip-bot for Thomas Gleixner
2016-02-22 22:19 ` [patch V3 19/28] x86/perf/intel/rapl: Add proper error handling Thomas Gleixner
2016-02-29 11:10   ` [tip:perf/core] perf/x86/intel/rapl: " tip-bot for Thomas Gleixner
2016-02-22 22:19 ` [patch V3 21/28] x86/perf/intel/rapl: Calculate timing once Thomas Gleixner
2016-02-29 11:10   ` [tip:perf/core] perf/x86/intel/rapl: " tip-bot for Thomas Gleixner
2016-02-22 22:19 ` [patch V3 20/28] x86/perf/intel/rapl: Sanitize the quirk handling Thomas Gleixner
2016-02-29 11:10   ` [tip:perf/core] perf/x86/intel/rapl: " tip-bot for Thomas Gleixner
2016-03-04 17:49     ` Borislav Petkov
2016-03-08 16:04       ` Ingo Molnar
2016-03-08 16:40         ` [PATCH] perf/x86/intel/rapl: Simplify quirk handling even more Borislav Petkov
2016-03-08 17:36           ` [tip:perf/core] " tip-bot for Borislav Petkov
2016-02-22 22:19 ` [patch V3 22/28] x86/perf/intel/rapl: Cleanup the printk output Thomas Gleixner
2016-02-29 11:11   ` [tip:perf/core] perf/x86/intel/rapl: Clean up " tip-bot for Thomas Gleixner
2016-02-22 22:19 ` [patch V3 23/28] x86/perf/intel/rapl: Refactor code some more Thomas Gleixner
2016-02-29 11:11   ` [tip:perf/core] perf/x86/intel/rapl: Refactor the " tip-bot for Thomas Gleixner
2016-02-22 22:19 ` [patch V3 25/28] x86/perf/intel/rapl: Utilize event->pmu_private Thomas Gleixner
2016-02-29 11:12   ` [tip:perf/core] perf/x86/intel/rapl: " tip-bot for Thomas Gleixner
2016-02-22 22:19 ` [patch V3 24/28] x86/perf/intel/rapl: Make pmu lock raw Thomas Gleixner
2016-02-29 11:12   ` [tip:perf/core] perf/x86/intel/rapl: Make PMU " tip-bot for Thomas Gleixner
2016-02-22 22:19 ` [patch V3 26/28] x86/perf/intel/rapl: Convert it to a per package facility Thomas Gleixner
2016-02-29 11:12   ` [tip:perf/core] perf/x86/intel/rapl: " tip-bot for Thomas Gleixner
2016-02-22 22:19 ` [patch V3 27/28] perf: Export perf_event_sysfs_show Thomas Gleixner
2016-02-29 11:13   ` [tip:perf/core] perf: Export perf_event_sysfs_show() tip-bot for Thomas Gleixner
2016-02-22 22:19 ` [patch V3 28/28] x86/perf/intel/rapl: Make it modular Thomas Gleixner

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=tip-a46195f1782e94ad07e7485fb15b80db7e60e7aa@git.kernel.org \
    --to=tipbot@zytor.com \
    --cc=acme@redhat.com \
    --cc=andi.kleen@intel.com \
    --cc=bp@alien8.de \
    --cc=eranian@google.com \
    --cc=harish.chegondi@intel.com \
    --cc=hpa@zytor.com \
    --cc=jacob.jun.pan@linux.intel.com \
    --cc=jolsa@redhat.com \
    --cc=kan.liang@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=peterz@infradead.org \
    --cc=tglx@linutronix.de \
    --cc=torvalds@linux-foundation.org \
    --cc=vincent.weaver@maine.edu \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.