* [PATCH] perf/x86/intel/uncore: Make uncore_discovery clean for 64 bit addresses
@ 2022-02-18 17:54 Steve Wahl
2022-02-22 16:11 ` Liang, Kan
2022-03-01 15:24 ` [tip: perf/core] " tip-bot2 for Steve Wahl
0 siblings, 2 replies; 3+ messages in thread
From: Steve Wahl @ 2022-02-18 17:54 UTC (permalink / raw)
To: Steve Wahl, Peter Zijlstra, Ingo Molnar,
Arnaldo Carvalho de Melo, Mark Rutland, Alexander Shishkin,
Jiri Olsa, Namhyung Kim, Thomas Gleixner, Borislav Petkov,
Dave Hansen, x86, H. Peter Anvin, linux-perf-users, linux-kernel
Cc: Liang, Kan
Support 64-bit BAR size for discovery, and do not truncate return from
generic_uncore_mmio_box_ctl() to 32 bits.
Signed-off-by: Steve Wahl <steve.wahl@hpe.com>
---
arch/x86/events/intel/uncore_discovery.c | 16 +++++++++++-----
arch/x86/events/intel/uncore_discovery.h | 2 --
2 files changed, 11 insertions(+), 7 deletions(-)
diff --git a/arch/x86/events/intel/uncore_discovery.c b/arch/x86/events/intel/uncore_discovery.c
index 3049c646fa20..141a540e7403 100644
--- a/arch/x86/events/intel/uncore_discovery.c
+++ b/arch/x86/events/intel/uncore_discovery.c
@@ -210,15 +210,21 @@ static int parse_discovery_table(struct pci_dev *dev, int die,
void __iomem *io_addr;
resource_size_t addr;
unsigned long size;
- u32 val;
+ u32 val, val2;
int i;
pci_read_config_dword(dev, bar_offset, &val);
- if (val & UNCORE_DISCOVERY_MASK)
+ if (val & ~PCI_BASE_ADDRESS_MEM_MASK & ~PCI_BASE_ADDRESS_MEM_TYPE_64)
return -EINVAL;
- addr = (resource_size_t)(val & ~UNCORE_DISCOVERY_MASK);
+ addr = (resource_size_t)(val & PCI_BASE_ADDRESS_MEM_MASK);
+#ifdef CONFIG_PHYS_ADDR_T_64BIT
+ if ((val & PCI_BASE_ADDRESS_MEM_TYPE_MASK) == PCI_BASE_ADDRESS_MEM_TYPE_64) {
+ pci_read_config_dword(dev, bar_offset + 4, &val2);
+ addr |= ((resource_size_t)val2) << 32;
+ }
+#endif
size = UNCORE_DISCOVERY_GLOBAL_MAP_SIZE;
io_addr = ioremap(addr, size);
if (!io_addr)
@@ -444,7 +450,7 @@ static struct intel_uncore_ops generic_uncore_pci_ops = {
#define UNCORE_GENERIC_MMIO_SIZE 0x4000
-static unsigned int generic_uncore_mmio_box_ctl(struct intel_uncore_box *box)
+static u64 generic_uncore_mmio_box_ctl(struct intel_uncore_box *box)
{
struct intel_uncore_type *type = box->pmu->type;
@@ -456,7 +462,7 @@ static unsigned int generic_uncore_mmio_box_ctl(struct intel_uncore_box *box)
void intel_generic_uncore_mmio_init_box(struct intel_uncore_box *box)
{
- unsigned int box_ctl = generic_uncore_mmio_box_ctl(box);
+ u64 box_ctl = generic_uncore_mmio_box_ctl(box);
struct intel_uncore_type *type = box->pmu->type;
resource_size_t addr;
diff --git a/arch/x86/events/intel/uncore_discovery.h b/arch/x86/events/intel/uncore_discovery.h
index 6d735611c281..22d40e7afbf1 100644
--- a/arch/x86/events/intel/uncore_discovery.h
+++ b/arch/x86/events/intel/uncore_discovery.h
@@ -18,8 +18,6 @@
#define UNCORE_DISCOVERY_BIR_BASE 0x10
/* Discovery table BAR step */
#define UNCORE_DISCOVERY_BIR_STEP 0x4
-/* Mask of the discovery table offset */
-#define UNCORE_DISCOVERY_MASK 0xf
/* Global discovery table size */
#define UNCORE_DISCOVERY_GLOBAL_MAP_SIZE 0x20
--
2.26.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] perf/x86/intel/uncore: Make uncore_discovery clean for 64 bit addresses
2022-02-18 17:54 [PATCH] perf/x86/intel/uncore: Make uncore_discovery clean for 64 bit addresses Steve Wahl
@ 2022-02-22 16:11 ` Liang, Kan
2022-03-01 15:24 ` [tip: perf/core] " tip-bot2 for Steve Wahl
1 sibling, 0 replies; 3+ messages in thread
From: Liang, Kan @ 2022-02-22 16:11 UTC (permalink / raw)
To: Steve Wahl, Peter Zijlstra, Ingo Molnar,
Arnaldo Carvalho de Melo, Mark Rutland, Alexander Shishkin,
Jiri Olsa, Namhyung Kim, Thomas Gleixner, Borislav Petkov,
Dave Hansen, x86, H. Peter Anvin, linux-perf-users, linux-kernel
Cc: Liang, Kan
On 2/18/2022 12:54 PM, Steve Wahl wrote:
> Support 64-bit BAR size for discovery, and do not truncate return from
> generic_uncore_mmio_box_ctl() to 32 bits.
>
> Signed-off-by: Steve Wahl <steve.wahl@hpe.com>
Thanks for the patch.
Reviewed-by: Kan Liang <kan.liang@linux.intel.com>
Thanks,
Kan
> ---
> arch/x86/events/intel/uncore_discovery.c | 16 +++++++++++-----
> arch/x86/events/intel/uncore_discovery.h | 2 --
> 2 files changed, 11 insertions(+), 7 deletions(-)
>
> diff --git a/arch/x86/events/intel/uncore_discovery.c b/arch/x86/events/intel/uncore_discovery.c
> index 3049c646fa20..141a540e7403 100644
> --- a/arch/x86/events/intel/uncore_discovery.c
> +++ b/arch/x86/events/intel/uncore_discovery.c
> @@ -210,15 +210,21 @@ static int parse_discovery_table(struct pci_dev *dev, int die,
> void __iomem *io_addr;
> resource_size_t addr;
> unsigned long size;
> - u32 val;
> + u32 val, val2;
> int i;
>
> pci_read_config_dword(dev, bar_offset, &val);
>
> - if (val & UNCORE_DISCOVERY_MASK)
> + if (val & ~PCI_BASE_ADDRESS_MEM_MASK & ~PCI_BASE_ADDRESS_MEM_TYPE_64)
> return -EINVAL;
>
> - addr = (resource_size_t)(val & ~UNCORE_DISCOVERY_MASK);
> + addr = (resource_size_t)(val & PCI_BASE_ADDRESS_MEM_MASK);
> +#ifdef CONFIG_PHYS_ADDR_T_64BIT
> + if ((val & PCI_BASE_ADDRESS_MEM_TYPE_MASK) == PCI_BASE_ADDRESS_MEM_TYPE_64) {
> + pci_read_config_dword(dev, bar_offset + 4, &val2);
> + addr |= ((resource_size_t)val2) << 32;
> + }
> +#endif
> size = UNCORE_DISCOVERY_GLOBAL_MAP_SIZE;
> io_addr = ioremap(addr, size);
> if (!io_addr)
> @@ -444,7 +450,7 @@ static struct intel_uncore_ops generic_uncore_pci_ops = {
>
> #define UNCORE_GENERIC_MMIO_SIZE 0x4000
>
> -static unsigned int generic_uncore_mmio_box_ctl(struct intel_uncore_box *box)
> +static u64 generic_uncore_mmio_box_ctl(struct intel_uncore_box *box)
> {
> struct intel_uncore_type *type = box->pmu->type;
>
> @@ -456,7 +462,7 @@ static unsigned int generic_uncore_mmio_box_ctl(struct intel_uncore_box *box)
>
> void intel_generic_uncore_mmio_init_box(struct intel_uncore_box *box)
> {
> - unsigned int box_ctl = generic_uncore_mmio_box_ctl(box);
> + u64 box_ctl = generic_uncore_mmio_box_ctl(box);
> struct intel_uncore_type *type = box->pmu->type;
> resource_size_t addr;
>
> diff --git a/arch/x86/events/intel/uncore_discovery.h b/arch/x86/events/intel/uncore_discovery.h
> index 6d735611c281..22d40e7afbf1 100644
> --- a/arch/x86/events/intel/uncore_discovery.h
> +++ b/arch/x86/events/intel/uncore_discovery.h
> @@ -18,8 +18,6 @@
> #define UNCORE_DISCOVERY_BIR_BASE 0x10
> /* Discovery table BAR step */
> #define UNCORE_DISCOVERY_BIR_STEP 0x4
> -/* Mask of the discovery table offset */
> -#define UNCORE_DISCOVERY_MASK 0xf
> /* Global discovery table size */
> #define UNCORE_DISCOVERY_GLOBAL_MAP_SIZE 0x20
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* [tip: perf/core] perf/x86/intel/uncore: Make uncore_discovery clean for 64 bit addresses
2022-02-18 17:54 [PATCH] perf/x86/intel/uncore: Make uncore_discovery clean for 64 bit addresses Steve Wahl
2022-02-22 16:11 ` Liang, Kan
@ 2022-03-01 15:24 ` tip-bot2 for Steve Wahl
1 sibling, 0 replies; 3+ messages in thread
From: tip-bot2 for Steve Wahl @ 2022-03-01 15:24 UTC (permalink / raw)
To: linux-tip-commits
Cc: Steve Wahl, Peter Zijlstra (Intel), Kan Liang, x86, linux-kernel
The following commit has been merged into the perf/core branch of tip:
Commit-ID: 71a412ed4c104bcc239b1a8e06f90b58a4aee0bb
Gitweb: https://git.kernel.org/tip/71a412ed4c104bcc239b1a8e06f90b58a4aee0bb
Author: Steve Wahl <steve.wahl@hpe.com>
AuthorDate: Fri, 18 Feb 2022 11:54:18 -06:00
Committer: Peter Zijlstra <peterz@infradead.org>
CommitterDate: Tue, 01 Mar 2022 16:19:01 +01:00
perf/x86/intel/uncore: Make uncore_discovery clean for 64 bit addresses
Support 64-bit BAR size for discovery, and do not truncate return from
generic_uncore_mmio_box_ctl() to 32 bits.
Signed-off-by: Steve Wahl <steve.wahl@hpe.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: Kan Liang <kan.liang@linux.intel.com>
Link: https://lore.kernel.org/r/20220218175418.421268-1-steve.wahl@hpe.com
---
arch/x86/events/intel/uncore_discovery.c | 16 +++++++++++-----
arch/x86/events/intel/uncore_discovery.h | 2 --
2 files changed, 11 insertions(+), 7 deletions(-)
diff --git a/arch/x86/events/intel/uncore_discovery.c b/arch/x86/events/intel/uncore_discovery.c
index 6ddadb4..61185d1 100644
--- a/arch/x86/events/intel/uncore_discovery.c
+++ b/arch/x86/events/intel/uncore_discovery.c
@@ -210,15 +210,21 @@ static int parse_discovery_table(struct pci_dev *dev, int die,
void __iomem *io_addr;
resource_size_t addr;
unsigned long size;
- u32 val;
+ u32 val, val2;
int i;
pci_read_config_dword(dev, bar_offset, &val);
- if (val & UNCORE_DISCOVERY_MASK)
+ if (val & ~PCI_BASE_ADDRESS_MEM_MASK & ~PCI_BASE_ADDRESS_MEM_TYPE_64)
return -EINVAL;
- addr = (resource_size_t)(val & ~UNCORE_DISCOVERY_MASK);
+ addr = (resource_size_t)(val & PCI_BASE_ADDRESS_MEM_MASK);
+#ifdef CONFIG_PHYS_ADDR_T_64BIT
+ if ((val & PCI_BASE_ADDRESS_MEM_TYPE_MASK) == PCI_BASE_ADDRESS_MEM_TYPE_64) {
+ pci_read_config_dword(dev, bar_offset + 4, &val2);
+ addr |= ((resource_size_t)val2) << 32;
+ }
+#endif
size = UNCORE_DISCOVERY_GLOBAL_MAP_SIZE;
io_addr = ioremap(addr, size);
if (!io_addr)
@@ -444,7 +450,7 @@ static struct intel_uncore_ops generic_uncore_pci_ops = {
#define UNCORE_GENERIC_MMIO_SIZE 0x4000
-static unsigned int generic_uncore_mmio_box_ctl(struct intel_uncore_box *box)
+static u64 generic_uncore_mmio_box_ctl(struct intel_uncore_box *box)
{
struct intel_uncore_type *type = box->pmu->type;
@@ -456,7 +462,7 @@ static unsigned int generic_uncore_mmio_box_ctl(struct intel_uncore_box *box)
void intel_generic_uncore_mmio_init_box(struct intel_uncore_box *box)
{
- unsigned int box_ctl = generic_uncore_mmio_box_ctl(box);
+ u64 box_ctl = generic_uncore_mmio_box_ctl(box);
struct intel_uncore_type *type = box->pmu->type;
resource_size_t addr;
diff --git a/arch/x86/events/intel/uncore_discovery.h b/arch/x86/events/intel/uncore_discovery.h
index cfaf558..f443935 100644
--- a/arch/x86/events/intel/uncore_discovery.h
+++ b/arch/x86/events/intel/uncore_discovery.h
@@ -18,8 +18,6 @@
#define UNCORE_DISCOVERY_BIR_BASE 0x10
/* Discovery table BAR step */
#define UNCORE_DISCOVERY_BIR_STEP 0x4
-/* Mask of the discovery table offset */
-#define UNCORE_DISCOVERY_MASK 0xf
/* Global discovery table size */
#define UNCORE_DISCOVERY_GLOBAL_MAP_SIZE 0x20
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-03-01 15:24 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-18 17:54 [PATCH] perf/x86/intel/uncore: Make uncore_discovery clean for 64 bit addresses Steve Wahl
2022-02-22 16:11 ` Liang, Kan
2022-03-01 15:24 ` [tip: perf/core] " tip-bot2 for Steve Wahl
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).