diff mbox series

[1/3] libpdbg: Move P9 chiplet definition into FAPI targets

Message ID 20200312012507.9052-1-alistair@popple.id.au
State Accepted
Headers show
Series [1/3] libpdbg: Move P9 chiplet definition into FAPI targets | expand

Checks

Context Check Description
snowpatch_ozlabs/apply_patch warning Failed to apply on branch master (8b4611b5d8e7e2279fe4aa80c892fcfe10aa398d)
snowpatch_ozlabs/apply_patch fail Failed to apply to any branch

Commit Message

Alistair Popple March 12, 2020, 1:25 a.m. UTC
The chiplets are being treated like FAPI targets for address
translation now so move the definition into the same file as the rest
of the FAPI targets.

Signed-off-by: Alistair Popple <alistair@popple.id.au>
---
 libpdbg/p9_fapi_targets.c | 100 ++++++++++++++++++++++++++++++++++++++
 libpdbg/p9chip.c          |  98 -------------------------------------
 2 files changed, 100 insertions(+), 98 deletions(-)

Comments

Amitay Isaacs March 12, 2020, 1:45 a.m. UTC | #1
Reviewed-by: Amitay Isaacs <amitay@ozlabs.org>

On Thu, 2020-03-12 at 12:25 +1100, Alistair Popple wrote:
> The chiplets are being treated like FAPI targets for address
> translation now so move the definition into the same file as the rest
> of the FAPI targets.
> 
> Signed-off-by: Alistair Popple <alistair@popple.id.au>
> ---
>  libpdbg/p9_fapi_targets.c | 100
> ++++++++++++++++++++++++++++++++++++++
>  libpdbg/p9chip.c          |  98 ------------------------------------
> -
>  2 files changed, 100 insertions(+), 98 deletions(-)
> 
> diff --git a/libpdbg/p9_fapi_targets.c b/libpdbg/p9_fapi_targets.c
> index 94c58ea..9ff35d9 100644
> --- a/libpdbg/p9_fapi_targets.c
> +++ b/libpdbg/p9_fapi_targets.c
> @@ -608,6 +608,105 @@ struct pauc p9_pauc = {
>  };
>  DECLARE_HW_UNIT(p9_pauc);
>  
> +#define HEADER_CHECK_DATA ((uint64_t) 0xc0ffee03 << 32)
> +
> +static int p9_chiplet_getring(struct chiplet *chiplet, uint64_t
> ring_addr, int64_t ring_len, uint32_t result[])
> +{
> +	uint64_t scan_type_addr;
> +	uint64_t scan_data_addr;
> +	uint64_t scan_header_addr;
> +	uint64_t scan_type_data;
> +	uint64_t set_pulse = 1;
> +	uint64_t bits = 32;
> +	uint64_t data;
> +
> +	/* We skip the first word in the results so we can write it
> later as it
> +	 * should contain the header read out at the end */
> +	int i = 0;
> +
> +	scan_type_addr = (ring_addr & 0x7fff0000) | 0x7;
> +	scan_data_addr = (scan_type_addr & 0xffff0000) | 0x8000;
> +	scan_header_addr = scan_data_addr & 0xffffe000;
> +
> +	scan_type_data = (ring_addr & 0xfff0) << 13;
> +	scan_type_data |= 0x800 >> (ring_addr & 0xf);
> +	scan_type_data <<= 32;
> +
> +	pib_write(&chiplet->target, scan_type_addr, scan_type_data);
> +	pib_write(&chiplet->target, scan_header_addr,
> HEADER_CHECK_DATA);
> +
> +	/* The final 32 bit read is the header which we do at the end
> */
> +	ring_len -= 32;
> +	i = 1;
> +
> +	while (ring_len > 0) {
> +		ring_len -= bits;
> +		if (set_pulse) {
> +			scan_data_addr |= 0x4000;
> +			set_pulse = 0;
> +		} else
> +			scan_data_addr &= ~0x4000ULL;
> +
> +		scan_data_addr &= ~0xffull;
> +		scan_data_addr |= bits;
> +		pib_read(&chiplet->target, scan_data_addr, &data);
> +
> +		/* Discard lower 32 bits */
> +		/* TODO: We always read 64-bits from the ring on P9 so
> we could
> +		 * optimise here by reading 64-bits at a time, but I'm
> not
> +		 * confident I've figured that out and 32-bits is what
> Hostboot
> +		 * does and seems to work. */
> +		data >>= 32;
> +
> +		/* Left-align data */
> +		data <<= 32 - bits;
> +		result[i++] = data;
> +		if (ring_len > 0 && (ring_len < bits))
> +			bits = ring_len;
> +	}
> +
> +	pib_read(&chiplet->target, scan_header_addr | 0x20, &data);
> +	data &= 0xffffffff00000000;
> +	result[0] = data >> 32;
> +	if (data != HEADER_CHECK_DATA)
> +		printf("WARNING: Header check failed. Make sure you
> specified the right ring length!\n"
> +		       "Ring data is probably corrupt now.\n");
> +
> +	return 0;
> +}
> +
> +#define NET_CTRL0	0xf0040
> +#define  NET_CTRL0_CHIPLET_ENABLE	PPC_BIT(0)
> +static int p9_chiplet_probe(struct pdbg_target *target)
> +{
> +        uint64_t value;
> +
> +        if (pib_read(target, NET_CTRL0, &value))
> +                return -1;
> +
> +        if (!(value & NET_CTRL0_CHIPLET_ENABLE))
> +                return -1;
> +
> +        return 0;
> +}
> +
> +static uint64_t p9_chiplet_translate(struct pdbg_target *target,
> uint64_t addr)
> +{
> +	return (addr & 0xffffffffc0ffffffULL) +
> pdbg_target_address(target, NULL);
> +}
> +
> +static struct chiplet p9_chiplet = {
> +        .target = {
> +                .name = "POWER9 Chiplet",
> +                .compatible = "ibm,power9-chiplet",
> +                .class = "chiplet",
> +                .probe = p9_chiplet_probe,
> +		.translate = p9_chiplet_translate,
> +        },
> +	.getring = p9_chiplet_getring,
> +};
> +DECLARE_HW_UNIT(p9_chiplet);
> +
>  __attribute__((constructor))
>  static void register_p9_fapi_targets(void)
>  {
> @@ -635,4 +734,5 @@ static void register_p9_fapi_targets(void)
>  	pdbg_hwunit_register(&p9_iohs_hw_unit);
>  	pdbg_hwunit_register(&p9_fc_hw_unit);
>  	pdbg_hwunit_register(&p9_pauc_hw_unit);
> +	pdbg_hwunit_register(&p9_chiplet_hw_unit);
>  }
> diff --git a/libpdbg/p9chip.c b/libpdbg/p9chip.c
> index 8f76295..e5169ab 100644
> --- a/libpdbg/p9chip.c
> +++ b/libpdbg/p9chip.c
> @@ -443,73 +443,6 @@ static struct thread p9_thread = {
>  };
>  DECLARE_HW_UNIT(p9_thread);
>  
> -#define HEADER_CHECK_DATA ((uint64_t) 0xc0ffee03 << 32)
> -
> -static int p9_chiplet_getring(struct chiplet *chiplet, uint64_t
> ring_addr, int64_t ring_len, uint32_t result[])
> -{
> -	uint64_t scan_type_addr;
> -	uint64_t scan_data_addr;
> -	uint64_t scan_header_addr;
> -	uint64_t scan_type_data;
> -	uint64_t set_pulse = 1;
> -	uint64_t bits = 32;
> -	uint64_t data;
> -
> -	/* We skip the first word in the results so we can write it
> later as it
> -	 * should contain the header read out at the end */
> -	int i = 0;
> -
> -	scan_type_addr = (ring_addr & 0x7fff0000) | 0x7;
> -	scan_data_addr = (scan_type_addr & 0xffff0000) | 0x8000;
> -	scan_header_addr = scan_data_addr & 0xffffe000;
> -
> -	scan_type_data = (ring_addr & 0xfff0) << 13;
> -	scan_type_data |= 0x800 >> (ring_addr & 0xf);
> -	scan_type_data <<= 32;
> -
> -	pib_write(&chiplet->target, scan_type_addr, scan_type_data);
> -	pib_write(&chiplet->target, scan_header_addr,
> HEADER_CHECK_DATA);
> -
> -	/* The final 32 bit read is the header which we do at the end
> */
> -	ring_len -= 32;
> -	i = 1;
> -
> -	while (ring_len > 0) {
> -		ring_len -= bits;
> -		if (set_pulse) {
> -			scan_data_addr |= 0x4000;
> -			set_pulse = 0;
> -		} else
> -			scan_data_addr &= ~0x4000ULL;
> -
> -		scan_data_addr &= ~0xffull;
> -		scan_data_addr |= bits;
> -		pib_read(&chiplet->target, scan_data_addr, &data);
> -
> -		/* Discard lower 32 bits */
> -		/* TODO: We always read 64-bits from the ring on P9 so
> we could
> -		 * optimise here by reading 64-bits at a time, but I'm
> not
> -		 * confident I've figured that out and 32-bits is what
> Hostboot
> -		 * does and seems to work. */
> -		data >>= 32;
> -
> -		/* Left-align data */
> -		data <<= 32 - bits;
> -		result[i++] = data;
> -		if (ring_len > 0 && (ring_len < bits))
> -			bits = ring_len;
> -	}
> -
> -	pib_read(&chiplet->target, scan_header_addr | 0x20, &data);
> -	data &= 0xffffffff00000000;
> -	result[0] = data >> 32;
> -	if (data != HEADER_CHECK_DATA)
> -		printf("WARNING: Header check failed. Make sure you
> specified the right ring length!\n"
> -		       "Ring data is probably corrupt now.\n");
> -
> -	return 0;
> -}
> -
>  static int p9_core_probe(struct pdbg_target *target)
>  {
>  	struct core *core = target_to_core(target);
> @@ -584,40 +517,9 @@ static struct core p9_core = {
>  };
>  DECLARE_HW_UNIT(p9_core);
>  
> -static int p9_chiplet_probe(struct pdbg_target *target)
> -{
> -        uint64_t value;
> -
> -        if (pib_read(target, NET_CTRL0, &value))
> -                return -1;
> -
> -        if (!(value & NET_CTRL0_CHIPLET_ENABLE))
> -                return -1;
> -
> -        return 0;
> -}
> -
> -static uint64_t p9_chiplet_translate(struct pdbg_target *target,
> uint64_t addr)
> -{
> -	return (addr & 0xffffffffc0ffffffULL) +
> pdbg_target_address(target, NULL);
> -}
> -
> -static struct chiplet p9_chiplet = {
> -        .target = {
> -                .name = "POWER9 Chiplet",
> -                .compatible = "ibm,power9-chiplet",
> -                .class = "chiplet",
> -                .probe = p9_chiplet_probe,
> -		.translate = p9_chiplet_translate,
> -        },
> -	.getring = p9_chiplet_getring,
> -};
> -DECLARE_HW_UNIT(p9_chiplet);
> -
>  __attribute__((constructor))
>  static void register_p9chip(void)
>  {
>  	pdbg_hwunit_register(&p9_thread_hw_unit);
>  	pdbg_hwunit_register(&p9_core_hw_unit);
> -	pdbg_hwunit_register(&p9_chiplet_hw_unit);
>  }
> -- 
> 2.20.1
> 

Amitay.
diff mbox series

Patch

diff --git a/libpdbg/p9_fapi_targets.c b/libpdbg/p9_fapi_targets.c
index 94c58ea..9ff35d9 100644
--- a/libpdbg/p9_fapi_targets.c
+++ b/libpdbg/p9_fapi_targets.c
@@ -608,6 +608,105 @@  struct pauc p9_pauc = {
 };
 DECLARE_HW_UNIT(p9_pauc);
 
+#define HEADER_CHECK_DATA ((uint64_t) 0xc0ffee03 << 32)
+
+static int p9_chiplet_getring(struct chiplet *chiplet, uint64_t ring_addr, int64_t ring_len, uint32_t result[])
+{
+	uint64_t scan_type_addr;
+	uint64_t scan_data_addr;
+	uint64_t scan_header_addr;
+	uint64_t scan_type_data;
+	uint64_t set_pulse = 1;
+	uint64_t bits = 32;
+	uint64_t data;
+
+	/* We skip the first word in the results so we can write it later as it
+	 * should contain the header read out at the end */
+	int i = 0;
+
+	scan_type_addr = (ring_addr & 0x7fff0000) | 0x7;
+	scan_data_addr = (scan_type_addr & 0xffff0000) | 0x8000;
+	scan_header_addr = scan_data_addr & 0xffffe000;
+
+	scan_type_data = (ring_addr & 0xfff0) << 13;
+	scan_type_data |= 0x800 >> (ring_addr & 0xf);
+	scan_type_data <<= 32;
+
+	pib_write(&chiplet->target, scan_type_addr, scan_type_data);
+	pib_write(&chiplet->target, scan_header_addr, HEADER_CHECK_DATA);
+
+	/* The final 32 bit read is the header which we do at the end */
+	ring_len -= 32;
+	i = 1;
+
+	while (ring_len > 0) {
+		ring_len -= bits;
+		if (set_pulse) {
+			scan_data_addr |= 0x4000;
+			set_pulse = 0;
+		} else
+			scan_data_addr &= ~0x4000ULL;
+
+		scan_data_addr &= ~0xffull;
+		scan_data_addr |= bits;
+		pib_read(&chiplet->target, scan_data_addr, &data);
+
+		/* Discard lower 32 bits */
+		/* TODO: We always read 64-bits from the ring on P9 so we could
+		 * optimise here by reading 64-bits at a time, but I'm not
+		 * confident I've figured that out and 32-bits is what Hostboot
+		 * does and seems to work. */
+		data >>= 32;
+
+		/* Left-align data */
+		data <<= 32 - bits;
+		result[i++] = data;
+		if (ring_len > 0 && (ring_len < bits))
+			bits = ring_len;
+	}
+
+	pib_read(&chiplet->target, scan_header_addr | 0x20, &data);
+	data &= 0xffffffff00000000;
+	result[0] = data >> 32;
+	if (data != HEADER_CHECK_DATA)
+		printf("WARNING: Header check failed. Make sure you specified the right ring length!\n"
+		       "Ring data is probably corrupt now.\n");
+
+	return 0;
+}
+
+#define NET_CTRL0	0xf0040
+#define  NET_CTRL0_CHIPLET_ENABLE	PPC_BIT(0)
+static int p9_chiplet_probe(struct pdbg_target *target)
+{
+        uint64_t value;
+
+        if (pib_read(target, NET_CTRL0, &value))
+                return -1;
+
+        if (!(value & NET_CTRL0_CHIPLET_ENABLE))
+                return -1;
+
+        return 0;
+}
+
+static uint64_t p9_chiplet_translate(struct pdbg_target *target, uint64_t addr)
+{
+	return (addr & 0xffffffffc0ffffffULL) + pdbg_target_address(target, NULL);
+}
+
+static struct chiplet p9_chiplet = {
+        .target = {
+                .name = "POWER9 Chiplet",
+                .compatible = "ibm,power9-chiplet",
+                .class = "chiplet",
+                .probe = p9_chiplet_probe,
+		.translate = p9_chiplet_translate,
+        },
+	.getring = p9_chiplet_getring,
+};
+DECLARE_HW_UNIT(p9_chiplet);
+
 __attribute__((constructor))
 static void register_p9_fapi_targets(void)
 {
@@ -635,4 +734,5 @@  static void register_p9_fapi_targets(void)
 	pdbg_hwunit_register(&p9_iohs_hw_unit);
 	pdbg_hwunit_register(&p9_fc_hw_unit);
 	pdbg_hwunit_register(&p9_pauc_hw_unit);
+	pdbg_hwunit_register(&p9_chiplet_hw_unit);
 }
diff --git a/libpdbg/p9chip.c b/libpdbg/p9chip.c
index 8f76295..e5169ab 100644
--- a/libpdbg/p9chip.c
+++ b/libpdbg/p9chip.c
@@ -443,73 +443,6 @@  static struct thread p9_thread = {
 };
 DECLARE_HW_UNIT(p9_thread);
 
-#define HEADER_CHECK_DATA ((uint64_t) 0xc0ffee03 << 32)
-
-static int p9_chiplet_getring(struct chiplet *chiplet, uint64_t ring_addr, int64_t ring_len, uint32_t result[])
-{
-	uint64_t scan_type_addr;
-	uint64_t scan_data_addr;
-	uint64_t scan_header_addr;
-	uint64_t scan_type_data;
-	uint64_t set_pulse = 1;
-	uint64_t bits = 32;
-	uint64_t data;
-
-	/* We skip the first word in the results so we can write it later as it
-	 * should contain the header read out at the end */
-	int i = 0;
-
-	scan_type_addr = (ring_addr & 0x7fff0000) | 0x7;
-	scan_data_addr = (scan_type_addr & 0xffff0000) | 0x8000;
-	scan_header_addr = scan_data_addr & 0xffffe000;
-
-	scan_type_data = (ring_addr & 0xfff0) << 13;
-	scan_type_data |= 0x800 >> (ring_addr & 0xf);
-	scan_type_data <<= 32;
-
-	pib_write(&chiplet->target, scan_type_addr, scan_type_data);
-	pib_write(&chiplet->target, scan_header_addr, HEADER_CHECK_DATA);
-
-	/* The final 32 bit read is the header which we do at the end */
-	ring_len -= 32;
-	i = 1;
-
-	while (ring_len > 0) {
-		ring_len -= bits;
-		if (set_pulse) {
-			scan_data_addr |= 0x4000;
-			set_pulse = 0;
-		} else
-			scan_data_addr &= ~0x4000ULL;
-
-		scan_data_addr &= ~0xffull;
-		scan_data_addr |= bits;
-		pib_read(&chiplet->target, scan_data_addr, &data);
-
-		/* Discard lower 32 bits */
-		/* TODO: We always read 64-bits from the ring on P9 so we could
-		 * optimise here by reading 64-bits at a time, but I'm not
-		 * confident I've figured that out and 32-bits is what Hostboot
-		 * does and seems to work. */
-		data >>= 32;
-
-		/* Left-align data */
-		data <<= 32 - bits;
-		result[i++] = data;
-		if (ring_len > 0 && (ring_len < bits))
-			bits = ring_len;
-	}
-
-	pib_read(&chiplet->target, scan_header_addr | 0x20, &data);
-	data &= 0xffffffff00000000;
-	result[0] = data >> 32;
-	if (data != HEADER_CHECK_DATA)
-		printf("WARNING: Header check failed. Make sure you specified the right ring length!\n"
-		       "Ring data is probably corrupt now.\n");
-
-	return 0;
-}
-
 static int p9_core_probe(struct pdbg_target *target)
 {
 	struct core *core = target_to_core(target);
@@ -584,40 +517,9 @@  static struct core p9_core = {
 };
 DECLARE_HW_UNIT(p9_core);
 
-static int p9_chiplet_probe(struct pdbg_target *target)
-{
-        uint64_t value;
-
-        if (pib_read(target, NET_CTRL0, &value))
-                return -1;
-
-        if (!(value & NET_CTRL0_CHIPLET_ENABLE))
-                return -1;
-
-        return 0;
-}
-
-static uint64_t p9_chiplet_translate(struct pdbg_target *target, uint64_t addr)
-{
-	return (addr & 0xffffffffc0ffffffULL) + pdbg_target_address(target, NULL);
-}
-
-static struct chiplet p9_chiplet = {
-        .target = {
-                .name = "POWER9 Chiplet",
-                .compatible = "ibm,power9-chiplet",
-                .class = "chiplet",
-                .probe = p9_chiplet_probe,
-		.translate = p9_chiplet_translate,
-        },
-	.getring = p9_chiplet_getring,
-};
-DECLARE_HW_UNIT(p9_chiplet);
-
 __attribute__((constructor))
 static void register_p9chip(void)
 {
 	pdbg_hwunit_register(&p9_thread_hw_unit);
 	pdbg_hwunit_register(&p9_core_hw_unit);
-	pdbg_hwunit_register(&p9_chiplet_hw_unit);
 }