linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Kroening, Gary" <gary.kroening@hpe.com>
To: "mingo@redhat.com" <mingo@redhat.com>,
	"hpa@zytor.com" <hpa@zytor.com>,
	"tglx@linutronix.de" <tglx@linutronix.de>,
	"peterz@infradead.org" <peterz@infradead.org>
Cc: "Kroening, Gary" <gary.kroening@hpe.com>,
	"Travis, Mike" <mike.travis@hpe.com>,
	"Banman, Andrew" <abanman@hpe.com>,
	"Sivanich, Dimitri" <dimitri.sivanich@hpe.com>,
	"Anderson, Russ" <russ.anderson@hpe.com>,
	"x86@kernel.org" <x86@kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: [PATCH 1/1] x86/platform/x86: Fix count of CHas on multi-pci-segment arches
Date: Wed, 7 Mar 2018 20:33:09 +0000	[thread overview]
Message-ID: <CS1PR84MB01182561B15688095C4DBF30F6D80@CS1PR84MB0118.NAMPRD84.PROD.OUTLOOK.COM> (raw)

For systems with a single PCI segment, it is sufficient to look for the
bus number to change in order to determine that all of the CHa's have
been counted for a single socket.

However, for multi PCI segment systems, each socket is given a new
segment and the bus number does NOT change.  So looking only for the
bus number to change ends up counting all of the CHa's on all sockets
in the system.  This leads to writing CPU MSRs beyond a valid range and
causes an error in ivbep_uncore_msr_init_box().

The fix is to check for either the bus number or segment number to change.

Signed-off-by: Gary Kroening <gary.kroening@hpe.com>
Signed-off-by: Mike Travis <mike.travis@hpe.com>
Reviewed-by: Dimitri Sivanich <dimitri.sivanich@hpe.com>
---
 arch/x86/kernel/cpu/perf_event_intel_uncore_snbep.c |   10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

--- linux-4.4.orig/arch/x86/kernel/cpu/perf_event_intel_uncore_snbep.c
+++ linux-4.4/arch/x86/kernel/cpu/perf_event_intel_uncore_snbep.c
@@ -3525,15 +3525,19 @@ static struct intel_uncore_type *skx_msr
 static int skx_count_chabox(void)
 {
 	struct pci_dev *chabox_dev = NULL;
-	int bus, count = 0;
+	int bus, seg, count = 0;
 
 	while (1) {
 		chabox_dev = pci_get_device(PCI_VENDOR_ID_INTEL, 0x208d, chabox_dev);
 		if (!chabox_dev)
 			break;
-		if (count == 0)
+		if (count == 0) {
 			bus = chabox_dev->bus->number;
-		if (bus != chabox_dev->bus->number)
+			seg = pci_domain_nr(chabox_dev->bus);
+		}
+		/* check for change in both bus and domain/segment */
+		if (bus != chabox_dev->bus->number ||
+		    seg != pci_domain_nr(chabox_dev->bus))
 			break;
 		count++;
 	}

             reply	other threads:[~2018-03-07 20:33 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-07 20:33 Kroening, Gary [this message]
2018-03-13  1:42 ` [PATCH 1/1] x86/platform/x86: Fix count of CHas on multi-pci-segment arches Liang, Kan
2018-03-13  5:06   ` Kroening, Gary
2018-03-13 12:28     ` Liang, Kan
2018-03-13  5:24   ` Kroening, Gary
2018-03-13 15:58   ` Andy Shevchenko
2018-03-13 16:00     ` Andy Shevchenko
2018-03-13 17:15       ` Liang, Kan
2018-03-13 17:22         ` Andy Shevchenko
2018-03-13 17:28           ` Liang, Kan
2018-03-13 17:31             ` Andy Shevchenko
2018-03-13 17:16     ` Liang, Kan
2018-03-13 17:42       ` Liang, Kan
2018-03-13 17:46         ` Andy Shevchenko
2018-03-13 17:49           ` Andy Shevchenko
2018-03-13 17:50             ` Andy Shevchenko

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=CS1PR84MB01182561B15688095C4DBF30F6D80@CS1PR84MB0118.NAMPRD84.PROD.OUTLOOK.COM \
    --to=gary.kroening@hpe.com \
    --cc=abanman@hpe.com \
    --cc=dimitri.sivanich@hpe.com \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mike.travis@hpe.com \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=russ.anderson@hpe.com \
    --cc=tglx@linutronix.de \
    --cc=x86@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;
as well as URLs for NNTP newsgroup(s).