perf/x86/intel/uncore: locate spesific box by checking full device info
Subsystems (2)
PATCH 1/1 perf/x86/intel/uncore: locate spesific box by checking full device info
From: Kan Liang <[email protected]>
Some platforms, e.g. Knights Landing, use a common PCI device ID for multiple instances of an uncore PMU device type. So it is impossible to locate to specific instances only by PCI device ID. Current code specially handle Knights Landing by arbitrarily point an instance to an unused uncore box. However, we still have no idea which uncore device is mapped to which box. Furthermore, there could be more platforms which use a common PCI device ID for uncore devices. We have to specially handle them one by one.
This patch records full device information (slot, func, and device ID) in id_table. So the probe function can point the instance to specific uncore box by checking full device information.
--- arch/x86/events/intel/uncore.c | 43 +++++++++++----- arch/x86/events/intel/uncore.h | 4 ++ arch/x86/events/intel/uncore_snbep.c | 96 +++++++++++++++++++++++++++++++++--- 3 files changed, 122 insertions(+), 21 deletions(-)
arch/x86/events/intel/uncore.c +30 -13
@@ -882,7 +882,7 @@ uncore_types_init(struct intel_uncore_type **types, bool setid)static int uncore_pci_probe (struct pci_dev *pdev,const struct pci_device_id *id) {struct intel_uncore_type *type; -struct intel_uncore_pmu *pmu; +struct intel_uncore_pmu *pmu =NULL ;struct intel_uncore_box *box;int phys_id, pkg, ret;
@@ -903,20 +903,37 @@ static int uncore_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id } type = uncore_pci_uncores[UNCORE_PCI_DEV_TYPE (id->driver_data)]; +/* -* for performance monitoring unit with multiple boxes, -* each box has a different function id. +* Some platforms, e.g. Knights Landing, use a common PCI device ID +* for multiple instances of an uncore PMU device type. We should check +* PCI slot and func to indicate the uncore box. */ - pmu = &type->pmus[UNCORE_PCI_DEV_IDX (id->driver_data)]; -/* Knights Landing uses a common PCI device ID for multiple instances of -* an uncore PMU device type. There is only one entry per device type in -* the knl_uncore_pci_ids table inspite of multiple devices present for -* some device types. Hence PCI device idx would be 0 for all devices. -* So increment pmu pointer to point to an unused array element. -*/ -if (boot_cpu_data.x86_model ==87 ) { -while (pmu->func_id >=0 ) - pmu++; +if (id->driver_data & ~0xffff ) { +struct pci_driver *pci_drv = pdev->driver; +const struct pci_device_id *ids = pci_drv->id_table; +unsigned int devfn; + +while (ids && ids->vendor) { +if ((ids->vendor == pdev->vendor) && + (ids->device == pdev->device)) { + devfn =PCI_DEVFN (UNCORE_PCI_DEV_DEV (ids->driver_data), +UNCORE_PCI_DEV_FUNC (ids->driver_data)); +if (devfn == pdev->devfn) { + pmu = &type->pmus[UNCORE_PCI_DEV_IDX (ids->driver_data)]; +break ; + } + } + ids++; + } +if (pmu ==NULL ) +return -ENODEV ; + }else { +/* +* for performance monitoring unit with multiple boxes, +* each box has a different function id. +*/ + pmu = &type->pmus[UNCORE_PCI_DEV_IDX (id->driver_data)]; }if (WARN_ON_ONCE (pmu->boxes[pkg] !=NULL ))
arch/x86/events/intel/uncore.h +4 -0
@@ -15,7 +15,11 @@#define UNCORE_PMC_IDX_FIXED UNCORE_PMC_IDX_MAX_GENERIC#define UNCORE_PMC_IDX_MAX (UNCORE_PMC_IDX_FIXED + 1) +#define UNCORE_PCI_DEV_FULL_DATA (dev, func, type, idx) \ + ((dev << 24) | (func << 16) | (type << 8) | idx)#define UNCORE_PCI_DEV_DATA (type, idx) ((type << 8) | idx) +#define UNCORE_PCI_DEV_DEV (data) ((data >> 24) & 0xff) +#define UNCORE_PCI_DEV_FUNC (data) ((data >> 16) & 0xff)#define UNCORE_PCI_DEV_TYPE (data) ((data >> 8) & 0xff)#define UNCORE_PCI_DEV_IDX (data) (data & 0xff)#define UNCORE_EXTRA_PCI_DEV 0xff
arch/x86/events/intel/uncore_snbep.c +88 -8
109 lines not on this page · raw message
Signature · 1 line
2.5.0
tip-bot for Kan Liang
merge bot[tip:perf/core] perf/x86/intel/uncore: Locate specific box by checking full device info
perf/x86/intel/uncore: Locate specific box by checking full device info
Commit-ID: a54fa07930c0f7db55ecb4cc16b86d74101332c0 Gitweb: http://git.kernel.org/tip/a54fa07930c0f7db55ecb4cc16b86d74101332c0 Author: Kan Liang <[email protected]> AuthorDate: Sun, 15 May 2016 23:18:24 -0700 Committer: Ingo Molnar <[email protected]> CommitDate: Fri, 3 Jun 2016 09:40:18 +0200
perf/x86/intel/uncore: Locate specific box by checking full device info
Some platforms, e.g. Knights Landing, use a common PCI device ID for multiple instances of an uncore PMU device type. So it is impossible to locate the specific instances only by PCI device ID.
The current code specially handles Knights Landing by arbitrarily pointing an instance to an unused uncore box. However, we still have no idea which uncore device is mapped to which box.
Furthermore, there could be more platforms which use a common PCI device ID for uncore devices. We have to specially handle them one by one.
This patch records full device information (slot, func, and device ID) in id_table[]. So the probe function can point the instance to a specific uncore box by checking the full device information.
--- arch/x86/events/intel/uncore.c | 43 +++++++++++----- arch/x86/events/intel/uncore.h | 4 ++ arch/x86/events/intel/uncore_snbep.c | 96 +++++++++++++++++++++++++++++++++--- 3 files changed, 122 insertions(+), 21 deletions(-)
arch/x86/events/intel/uncore.c +30 -13
@@ -882,7 +882,7 @@ uncore_types_init(struct intel_uncore_type **types, bool setid)static int uncore_pci_probe (struct pci_dev *pdev,const struct pci_device_id *id) {struct intel_uncore_type *type; -struct intel_uncore_pmu *pmu; +struct intel_uncore_pmu *pmu =NULL ;struct intel_uncore_box *box;int phys_id, pkg, ret;
@@ -903,20 +903,37 @@ static int uncore_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id } type = uncore_pci_uncores[UNCORE_PCI_DEV_TYPE (id->driver_data)]; +/* -* for performance monitoring unit with multiple boxes, -* each box has a different function id. +* Some platforms, e.g. Knights Landing, use a common PCI device ID +* for multiple instances of an uncore PMU device type. We should check +* PCI slot and func to indicate the uncore box. */ - pmu = &type->pmus[UNCORE_PCI_DEV_IDX (id->driver_data)]; -/* Knights Landing uses a common PCI device ID for multiple instances of -* an uncore PMU device type. There is only one entry per device type in -* the knl_uncore_pci_ids table inspite of multiple devices present for -* some device types. Hence PCI device idx would be 0 for all devices. -* So increment pmu pointer to point to an unused array element. -*/ -if (boot_cpu_data.x86_model ==87 ) { -while (pmu->func_id >=0 ) - pmu++; +if (id->driver_data & ~0xffff ) { +struct pci_driver *pci_drv = pdev->driver; +const struct pci_device_id *ids = pci_drv->id_table; +unsigned int devfn; + +while (ids && ids->vendor) { +if ((ids->vendor == pdev->vendor) && + (ids->device == pdev->device)) { + devfn =PCI_DEVFN (UNCORE_PCI_DEV_DEV (ids->driver_data), +UNCORE_PCI_DEV_FUNC (ids->driver_data)); +if (devfn == pdev->devfn) { + pmu = &type->pmus[UNCORE_PCI_DEV_IDX (ids->driver_data)]; +break ; + } + } + ids++; + } +if (pmu ==NULL ) +return -ENODEV ; + }else { +/* +* for performance monitoring unit with multiple boxes, +* each box has a different function id. +*/ + pmu = &type->pmus[UNCORE_PCI_DEV_IDX (id->driver_data)]; }if (WARN_ON_ONCE (pmu->boxes[pkg] !=NULL ))
arch/x86/events/intel/uncore.h +4 -0
@@ -15,7 +15,11 @@#define UNCORE_PMC_IDX_FIXED UNCORE_PMC_IDX_MAX_GENERIC#define UNCORE_PMC_IDX_MAX (UNCORE_PMC_IDX_FIXED + 1) +#define UNCORE_PCI_DEV_FULL_DATA (dev, func, type, idx) \ + ((dev << 24) | (func << 16) | (type << 8) | idx)#define UNCORE_PCI_DEV_DATA (type, idx) ((type << 8) | idx) +#define UNCORE_PCI_DEV_DEV (data) ((data >> 24) & 0xff) +#define UNCORE_PCI_DEV_FUNC (data) ((data >> 16) & 0xff)#define UNCORE_PCI_DEV_TYPE (data) ((data >> 8) & 0xff)#define UNCORE_PCI_DEV_IDX (data) (data & 0xff)#define UNCORE_EXTRA_PCI_DEV 0xff
arch/x86/events/intel/uncore_snbep.c +88 -8
109 lines not on this page · raw message