linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/3] powernv/pci: Use pnv_phb as the private data for debugfs entries
@ 2019-09-12  5:29 Oliver O'Halloran
  2019-09-12  5:29 ` [PATCH 2/3] powernv/pci: Allow any write trigger the diag dump Oliver O'Halloran
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Oliver O'Halloran @ 2019-09-12  5:29 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: Oliver O'Halloran

Use the pnv_phb structure as the private data pointer for the debugfs
files.  This lets us delete some code and an open-coded use of
hose->private_data.

Signed-off-by: Oliver O'Halloran <oohall@gmail.com>
---
 arch/powerpc/platforms/powernv/pci-ioda.c | 11 ++---------
 1 file changed, 2 insertions(+), 9 deletions(-)

diff --git a/arch/powerpc/platforms/powernv/pci-ioda.c b/arch/powerpc/platforms/powernv/pci-ioda.c
index 2f650e1..b24339b 100644
--- a/arch/powerpc/platforms/powernv/pci-ioda.c
+++ b/arch/powerpc/platforms/powernv/pci-ioda.c
@@ -3044,19 +3044,12 @@ static void pnv_ioda_setup_pe_seg(struct pnv_ioda_pe *pe)
 #ifdef CONFIG_DEBUG_FS
 static int pnv_pci_diag_data_set(void *data, u64 val)
 {
-	struct pci_controller *hose;
-	struct pnv_phb *phb;
+	struct pnv_phb *phb = data;
 	s64 ret;
 
 	if (val != 1ULL)
 		return -EINVAL;
 
-	hose = (struct pci_controller *)data;
-	if (!hose || !hose->private_data)
-		return -ENODEV;
-
-	phb = hose->private_data;
-
 	/* Retrieve the diag data from firmware */
 	ret = opal_pci_get_phb_diag_data2(phb->opal_id, phb->diag_data,
 					  phb->diag_data_size);
@@ -3094,7 +3087,7 @@ static void pnv_pci_ioda_create_dbgfs(void)
 			continue;
 		}
 
-		debugfs_create_file("dump_diag_regs", 0200, phb->dbgfs, hose,
+		debugfs_create_file("dump_diag_regs", 0200, phb->dbgfs, phb,
 				    &pnv_pci_diag_data_fops);
 	}
 #endif /* CONFIG_DEBUG_FS */
-- 
2.9.5


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 2/3] powernv/pci: Allow any write trigger the diag dump
  2019-09-12  5:29 [PATCH 1/3] powernv/pci: Use pnv_phb as the private data for debugfs entries Oliver O'Halloran
@ 2019-09-12  5:29 ` Oliver O'Halloran
  2019-09-12  5:29 ` [PATCH 3/3] powernv/pci: Add a debugfs entry to dump PHB's IODA PE state Oliver O'Halloran
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 6+ messages in thread
From: Oliver O'Halloran @ 2019-09-12  5:29 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: Oliver O'Halloran

Make the dump trigger off any input rather than just '1'. This allows you
to write "echo 1> dump_diag_data" and it'll do what you want rather than
erroring out pointlessly.

Signed-off-by: Oliver O'Halloran <oohall@gmail.com>
---
 arch/powerpc/platforms/powernv/pci-ioda.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/arch/powerpc/platforms/powernv/pci-ioda.c b/arch/powerpc/platforms/powernv/pci-ioda.c
index b24339b..f684d3a 100644
--- a/arch/powerpc/platforms/powernv/pci-ioda.c
+++ b/arch/powerpc/platforms/powernv/pci-ioda.c
@@ -3047,9 +3047,6 @@ static int pnv_pci_diag_data_set(void *data, u64 val)
 	struct pnv_phb *phb = data;
 	s64 ret;
 
-	if (val != 1ULL)
-		return -EINVAL;
-
 	/* Retrieve the diag data from firmware */
 	ret = opal_pci_get_phb_diag_data2(phb->opal_id, phb->diag_data,
 					  phb->diag_data_size);
-- 
2.9.5


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 3/3] powernv/pci: Add a debugfs entry to dump PHB's IODA PE state
  2019-09-12  5:29 [PATCH 1/3] powernv/pci: Use pnv_phb as the private data for debugfs entries Oliver O'Halloran
  2019-09-12  5:29 ` [PATCH 2/3] powernv/pci: Allow any write trigger the diag dump Oliver O'Halloran
@ 2019-09-12  5:29 ` Oliver O'Halloran
  2019-09-23  8:10   ` Alexey Kardashevskiy
  2019-09-23  8:08 ` [PATCH 1/3] powernv/pci: Use pnv_phb as the private data for debugfs entries Alexey Kardashevskiy
  2020-01-29  5:17 ` Michael Ellerman
  3 siblings, 1 reply; 6+ messages in thread
From: Oliver O'Halloran @ 2019-09-12  5:29 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: Oliver O'Halloran

Add a debugfs entry to dump the state of the active IODA PEs. The IODA PE
state reflects how the PHB's internal concept of a PE is configured. This
is separate to the EEH PE state and is managed power the PowerNV PCI
backend rather than the EEH core.

Signed-off-by: Oliver O'Halloran <oohall@gmail.com>
---
 arch/powerpc/platforms/powernv/pci-ioda.c | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)

diff --git a/arch/powerpc/platforms/powernv/pci-ioda.c b/arch/powerpc/platforms/powernv/pci-ioda.c
index f684d3a..941902b 100644
--- a/arch/powerpc/platforms/powernv/pci-ioda.c
+++ b/arch/powerpc/platforms/powernv/pci-ioda.c
@@ -3061,6 +3061,33 @@ static int pnv_pci_diag_data_set(void *data, u64 val)
 DEFINE_SIMPLE_ATTRIBUTE(pnv_pci_diag_data_fops, NULL,
 			pnv_pci_diag_data_set, "%llu\n");
 
+static int pnv_pci_ioda_pe_dump(void *data, u64 val)
+{
+	struct pnv_phb *phb = data;
+	int pe_num;
+
+	for (pe_num = 0; pe_num < phb->ioda.total_pe_num; pe_num++) {
+		struct pnv_ioda_pe *pe = &phb->ioda.pe_array[pe_num];
+
+		if (!test_bit(pe_num, phb->ioda.pe_alloc))
+			continue;
+
+		pe_warn(pe, "rid: %04x dev count: %2d flags: %s%s%s%s%s%s\n",
+			pe->rid, pe->device_count,
+			(pe->flags & PNV_IODA_PE_DEV) ? "dev " : "",
+			(pe->flags & PNV_IODA_PE_BUS) ? "bus " : "",
+			(pe->flags & PNV_IODA_PE_BUS_ALL) ? "all " : "",
+			(pe->flags & PNV_IODA_PE_MASTER) ? "master " : "",
+			(pe->flags & PNV_IODA_PE_SLAVE) ? "slave " : "",
+			(pe->flags & PNV_IODA_PE_VF) ? "vf " : "");
+	}
+
+	return 0;
+}
+
+DEFINE_SIMPLE_ATTRIBUTE(pnv_pci_ioda_pe_dump_fops, NULL,
+			pnv_pci_ioda_pe_dump, "%llu\n");
+
 #endif /* CONFIG_DEBUG_FS */
 
 static void pnv_pci_ioda_create_dbgfs(void)
@@ -3086,6 +3113,8 @@ static void pnv_pci_ioda_create_dbgfs(void)
 
 		debugfs_create_file("dump_diag_regs", 0200, phb->dbgfs, phb,
 				    &pnv_pci_diag_data_fops);
+		debugfs_create_file("dump_ioda_pe_state", 0200, phb->dbgfs, phb,
+				    &pnv_pci_ioda_pe_dump_fops);
 	}
 #endif /* CONFIG_DEBUG_FS */
 }
-- 
2.9.5


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/3] powernv/pci: Use pnv_phb as the private data for debugfs entries
  2019-09-12  5:29 [PATCH 1/3] powernv/pci: Use pnv_phb as the private data for debugfs entries Oliver O'Halloran
  2019-09-12  5:29 ` [PATCH 2/3] powernv/pci: Allow any write trigger the diag dump Oliver O'Halloran
  2019-09-12  5:29 ` [PATCH 3/3] powernv/pci: Add a debugfs entry to dump PHB's IODA PE state Oliver O'Halloran
@ 2019-09-23  8:08 ` Alexey Kardashevskiy
  2020-01-29  5:17 ` Michael Ellerman
  3 siblings, 0 replies; 6+ messages in thread
From: Alexey Kardashevskiy @ 2019-09-23  8:08 UTC (permalink / raw)
  To: Oliver O'Halloran, linuxppc-dev



On 12/09/2019 15:29, Oliver O'Halloran wrote:
> Use the pnv_phb structure as the private data pointer for the debugfs
> files.  This lets us delete some code and an open-coded use of
> hose->private_data.
> 
> Signed-off-by: Oliver O'Halloran <oohall@gmail.com>


Reviewed-by: Alexey Kardashevskiy <aik@ozlabs.ru>



> ---
>  arch/powerpc/platforms/powernv/pci-ioda.c | 11 ++---------
>  1 file changed, 2 insertions(+), 9 deletions(-)
> 
> diff --git a/arch/powerpc/platforms/powernv/pci-ioda.c b/arch/powerpc/platforms/powernv/pci-ioda.c
> index 2f650e1..b24339b 100644
> --- a/arch/powerpc/platforms/powernv/pci-ioda.c
> +++ b/arch/powerpc/platforms/powernv/pci-ioda.c
> @@ -3044,19 +3044,12 @@ static void pnv_ioda_setup_pe_seg(struct pnv_ioda_pe *pe)
>  #ifdef CONFIG_DEBUG_FS
>  static int pnv_pci_diag_data_set(void *data, u64 val)
>  {
> -	struct pci_controller *hose;
> -	struct pnv_phb *phb;
> +	struct pnv_phb *phb = data;
>  	s64 ret;
>  
>  	if (val != 1ULL)
>  		return -EINVAL;
>  
> -	hose = (struct pci_controller *)data;
> -	if (!hose || !hose->private_data)
> -		return -ENODEV;
> -
> -	phb = hose->private_data;
> -
>  	/* Retrieve the diag data from firmware */
>  	ret = opal_pci_get_phb_diag_data2(phb->opal_id, phb->diag_data,
>  					  phb->diag_data_size);
> @@ -3094,7 +3087,7 @@ static void pnv_pci_ioda_create_dbgfs(void)
>  			continue;
>  		}
>  
> -		debugfs_create_file("dump_diag_regs", 0200, phb->dbgfs, hose,
> +		debugfs_create_file("dump_diag_regs", 0200, phb->dbgfs, phb,
>  				    &pnv_pci_diag_data_fops);
>  	}
>  #endif /* CONFIG_DEBUG_FS */
> 

-- 
Alexey

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 3/3] powernv/pci: Add a debugfs entry to dump PHB's IODA PE state
  2019-09-12  5:29 ` [PATCH 3/3] powernv/pci: Add a debugfs entry to dump PHB's IODA PE state Oliver O'Halloran
@ 2019-09-23  8:10   ` Alexey Kardashevskiy
  0 siblings, 0 replies; 6+ messages in thread
From: Alexey Kardashevskiy @ 2019-09-23  8:10 UTC (permalink / raw)
  To: Oliver O'Halloran, linuxppc-dev



On 12/09/2019 15:29, Oliver O'Halloran wrote:
> Add a debugfs entry to dump the state of the active IODA PEs. The IODA PE
> state reflects how the PHB's internal concept of a PE is configured. This
> is separate to the EEH PE state and is managed power the PowerNV PCI
> backend rather than the EEH core.
> 
> Signed-off-by: Oliver O'Halloran <oohall@gmail.com>
> ---
>  arch/powerpc/platforms/powernv/pci-ioda.c | 29 +++++++++++++++++++++++++++++
>  1 file changed, 29 insertions(+)
> 
> diff --git a/arch/powerpc/platforms/powernv/pci-ioda.c b/arch/powerpc/platforms/powernv/pci-ioda.c
> index f684d3a..941902b 100644
> --- a/arch/powerpc/platforms/powernv/pci-ioda.c
> +++ b/arch/powerpc/platforms/powernv/pci-ioda.c
> @@ -3061,6 +3061,33 @@ static int pnv_pci_diag_data_set(void *data, u64 val)
>  DEFINE_SIMPLE_ATTRIBUTE(pnv_pci_diag_data_fops, NULL,
>  			pnv_pci_diag_data_set, "%llu\n");
>  
> +static int pnv_pci_ioda_pe_dump(void *data, u64 val)
> +{
> +	struct pnv_phb *phb = data;
> +	int pe_num;
> +
> +	for (pe_num = 0; pe_num < phb->ioda.total_pe_num; pe_num++) {
> +		struct pnv_ioda_pe *pe = &phb->ioda.pe_array[pe_num];
> +
> +		if (!test_bit(pe_num, phb->ioda.pe_alloc))
> +			continue;
> +
> +		pe_warn(pe, "rid: %04x dev count: %2d flags: %s%s%s%s%s%s\n",
> +			pe->rid, pe->device_count,
> +			(pe->flags & PNV_IODA_PE_DEV) ? "dev " : "",
> +			(pe->flags & PNV_IODA_PE_BUS) ? "bus " : "",
> +			(pe->flags & PNV_IODA_PE_BUS_ALL) ? "all " : "",
> +			(pe->flags & PNV_IODA_PE_MASTER) ? "master " : "",
> +			(pe->flags & PNV_IODA_PE_SLAVE) ? "slave " : "",
> +			(pe->flags & PNV_IODA_PE_VF) ? "vf " : "");


Printing raw flags value would hurt imho, just in case (we add some
later and forget about debugfs? memory corruption?). Or not :)


Reviewed-by: Alexey Kardashevskiy <aik@ozlabs.ru>




> +	}
> +
> +	return 0;
> +}
> +
> +DEFINE_SIMPLE_ATTRIBUTE(pnv_pci_ioda_pe_dump_fops, NULL,
> +			pnv_pci_ioda_pe_dump, "%llu\n");
> +
>  #endif /* CONFIG_DEBUG_FS */
>  
>  static void pnv_pci_ioda_create_dbgfs(void)
> @@ -3086,6 +3113,8 @@ static void pnv_pci_ioda_create_dbgfs(void)
>  
>  		debugfs_create_file("dump_diag_regs", 0200, phb->dbgfs, phb,
>  				    &pnv_pci_diag_data_fops);
> +		debugfs_create_file("dump_ioda_pe_state", 0200, phb->dbgfs, phb,
> +				    &pnv_pci_ioda_pe_dump_fops);
>  	}
>  #endif /* CONFIG_DEBUG_FS */
>  }
> 

-- 
Alexey

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/3] powernv/pci: Use pnv_phb as the private data for debugfs entries
  2019-09-12  5:29 [PATCH 1/3] powernv/pci: Use pnv_phb as the private data for debugfs entries Oliver O'Halloran
                   ` (2 preceding siblings ...)
  2019-09-23  8:08 ` [PATCH 1/3] powernv/pci: Use pnv_phb as the private data for debugfs entries Alexey Kardashevskiy
@ 2020-01-29  5:17 ` Michael Ellerman
  3 siblings, 0 replies; 6+ messages in thread
From: Michael Ellerman @ 2020-01-29  5:17 UTC (permalink / raw)
  To: Oliver O'Halloran, linuxppc-dev; +Cc: Oliver O'Halloran

On Thu, 2019-09-12 at 05:29:43 UTC, Oliver O'Halloran wrote:
> Use the pnv_phb structure as the private data pointer for the debugfs
> files.  This lets us delete some code and an open-coded use of
> hose->private_data.
> 
> Signed-off-by: Oliver O'Halloran <oohall@gmail.com>

Series applied to powerpc next, thanks.

https://git.kernel.org/powerpc/c/22ba7289079be12c85895fee41602139e9553c93

cheers

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2020-01-29  5:28 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-12  5:29 [PATCH 1/3] powernv/pci: Use pnv_phb as the private data for debugfs entries Oliver O'Halloran
2019-09-12  5:29 ` [PATCH 2/3] powernv/pci: Allow any write trigger the diag dump Oliver O'Halloran
2019-09-12  5:29 ` [PATCH 3/3] powernv/pci: Add a debugfs entry to dump PHB's IODA PE state Oliver O'Halloran
2019-09-23  8:10   ` Alexey Kardashevskiy
2019-09-23  8:08 ` [PATCH 1/3] powernv/pci: Use pnv_phb as the private data for debugfs entries Alexey Kardashevskiy
2020-01-29  5:17 ` Michael Ellerman

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).