From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1161061AbcBQSSM (ORCPT ); Wed, 17 Feb 2016 13:18:12 -0500 Received: from www.linutronix.de ([62.245.132.108]:45329 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965145AbcBQSSK (ORCPT ); Wed, 17 Feb 2016 13:18:10 -0500 Date: Wed, 17 Feb 2016 19:16:54 +0100 (CET) From: Thomas Gleixner To: "Liang, Kan" cc: LKML , Peter Zijlstra , Ingo Molnar , Borislav Petkov , Stephane Eranian , "Chegondi, Harish" , "Kleen, Andi" Subject: RE: [patch 04/11] x86/perf/intel_uncore: Cleanup hardware on exit In-Reply-To: <37D7C6CF3E00A74B8858931C1DB2F0770588AF38@shsmsx102.ccr.corp.intel.com> Message-ID: References: <20160217132903.767990400@linutronix.de> <20160217133932.018288722@linutronix.de> <37D7C6CF3E00A74B8858931C1DB2F0770588AF38@shsmsx102.ccr.corp.intel.com> User-Agent: Alpine 2.11 (DEB 23 2013-08-11) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Linutronix-Spam-Score: -1.0 X-Linutronix-Spam-Level: - X-Linutronix-Spam-Status: No , -1.0 points, 5.0 required, ALL_TRUSTED=-1,SHORTCIRCUIT=-0.0001 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 17 Feb 2016, Liang, Kan wrote: > > 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. > > I don't think we need exit_box. > Because in disable_box we already freezes the box. init_box() != enable_box() exit_box() != disable_box() And we certainly want to clear stuff which enables things at a different msr/config word location than what you do with the enable/disable callbacks. I'm not a fan of leaving hardware in some random state. > Also, writing 0 cannot clear hardware state. It will unfreeze the box. > The counter will start to count. Nonsense. > > @@ -201,6 +201,11 @@ static void nhmex_uncore_msr_init_box(st > > 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); } The reset value for this register is 0. So how is that wrong? > > +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); > > +} Ditto. > > +static void snb_uncore_imc_exit_box(struct intel_uncore_box *box) { > > + iounmap(box->io_addr); That's definitely required, because it would leak a mapping. I know Intel folks do not care about error handling and a few reference leaks, but I care very much. If there is a single instance of exit_box() in that patch which flips the wrong bits, then please point it out with the proper reference in the manual and not with such half baken statements as above. Thanks, tglx