diff mbox series

[Very,RFC,11/46] powerpc/eeh: Convert various printfs to use edev, not pci_dn

Message ID 20191120012859.23300-12-oohall@gmail.com (mailing list archive)
State RFC
Headers show
Series [Very,RFC,01/46] powerpc/eeh: Don't attempt to restore VF config space after reset | expand

Commit Message

Oliver O'Halloran Nov. 20, 2019, 1:28 a.m. UTC
We use the pci_dn to retrieve the domain, bus, device, and function numbers for
an EEH device. We now have that in the eeh_dev so covert the various printk()s
we have around the place to source that information from the eeh_dev.

Signed-off-by: Oliver O'Halloran <oohall@gmail.com>
---
 arch/powerpc/kernel/eeh.c    | 14 ++++----------
 arch/powerpc/kernel/eeh_pe.c | 14 ++++++--------
 2 files changed, 10 insertions(+), 18 deletions(-)

Comments

Alexey Kardashevskiy Nov. 22, 2019, 4:55 a.m. UTC | #1
On 20/11/2019 12:28, Oliver O'Halloran wrote:
> We use the pci_dn to retrieve the domain, bus, device, and function numbers for
> an EEH device. We now have that in the eeh_dev so covert the various printk()s
> we have around the place to source that information from the eeh_dev.
> 
> Signed-off-by: Oliver O'Halloran <oohall@gmail.com>
> ---
>  arch/powerpc/kernel/eeh.c    | 14 ++++----------
>  arch/powerpc/kernel/eeh_pe.c | 14 ++++++--------
>  2 files changed, 10 insertions(+), 18 deletions(-)
> 
> diff --git a/arch/powerpc/kernel/eeh.c b/arch/powerpc/kernel/eeh.c
> index 63500e34e329..c8039fdb23ba 100644
> --- a/arch/powerpc/kernel/eeh.c
> +++ b/arch/powerpc/kernel/eeh.c
> @@ -167,23 +167,17 @@ void eeh_show_enabled(void)
>   */
>  static size_t eeh_dump_dev_log(struct eeh_dev *edev, char *buf, size_t len)
>  {
> -	struct pci_dn *pdn = eeh_dev_to_pdn(edev);
>  	u32 cfg;
>  	int cap, i;
>  	int n = 0, l = 0;
>  	char buffer[128];
>  
> -	if (!pdn) {
> -		pr_warn("EEH: Note: No error log for absent device.\n");
> -		return 0;
> -	}
> -
>  	n += scnprintf(buf+n, len-n, "%04x:%02x:%02x.%01x\n",
> -		       pdn->phb->global_number, pdn->busno,
> -		       PCI_SLOT(pdn->devfn), PCI_FUNC(pdn->devfn));
> +			edev->pe->phb->global_number, edev->bdfn >> 8,
> +			PCI_SLOT(edev->bdfn), PCI_FUNC(edev->bdfn));
>  	pr_warn("EEH: of node=%04x:%02x:%02x.%01x\n",
> -		pdn->phb->global_number, pdn->busno,
> -		PCI_SLOT(pdn->devfn), PCI_FUNC(pdn->devfn));
> +		edev->pe->phb->global_number, edev->bdfn >> 8,
> +		PCI_SLOT(edev->bdfn), PCI_FUNC(edev->bdfn));
>  
>  	eeh_ops->read_config(edev, PCI_VENDOR_ID, 4, &cfg);
>  	n += scnprintf(buf+n, len-n, "dev/vend:%08x\n", cfg);
> diff --git a/arch/powerpc/kernel/eeh_pe.c b/arch/powerpc/kernel/eeh_pe.c
> index 634963aa4a77..831f363f1732 100644
> --- a/arch/powerpc/kernel/eeh_pe.c
> +++ b/arch/powerpc/kernel/eeh_pe.c
> @@ -366,9 +366,8 @@ static struct eeh_pe *eeh_pe_get_parent(struct eeh_dev *edev)
>   */
>  int eeh_add_to_parent_pe(struct eeh_dev *edev)
>  {
> +	int config_addr = edev->bdfn;
>  	struct eeh_pe *pe, *parent;
> -	struct pci_dn *pdn = eeh_dev_to_pdn(edev);
> -	int config_addr = (pdn->busno << 8) | (pdn->devfn);
>  
>  	/* Check if the PE number is valid */
>  	if (!eeh_has_flag(EEH_VALID_PE_ZERO) && !edev->pe_config_addr) {
> @@ -382,7 +381,7 @@ int eeh_add_to_parent_pe(struct eeh_dev *edev)
>  	 * PE should be composed of PCI bus and its subordinate
>  	 * components.
>  	 */
> -	pe = eeh_pe_get(pdn->phb, edev->pe_config_addr, config_addr);
> +	pe = eeh_pe_get(edev->controller, edev->pe_config_addr, config_addr);
>  	if (pe) {
>  		if (pe->type & EEH_PE_INVALID) {
>  			list_add_tail(&edev->entry, &pe->edevs);
> @@ -416,9 +415,9 @@ int eeh_add_to_parent_pe(struct eeh_dev *edev)
>  
>  	/* Create a new EEH PE */
>  	if (edev->physfn)
> -		pe = eeh_pe_alloc(pdn->phb, EEH_PE_VF);
> +		pe = eeh_pe_alloc(edev->controller, EEH_PE_VF);
>  	else
> -		pe = eeh_pe_alloc(pdn->phb, EEH_PE_DEVICE);
> +		pe = eeh_pe_alloc(edev->controller, EEH_PE_DEVICE);
>  	if (!pe) {
>  		pr_err("%s: out of memory!\n", __func__);
>  		return -ENOMEM;
> @@ -434,10 +433,10 @@ int eeh_add_to_parent_pe(struct eeh_dev *edev)
>  	 */
>  	parent = eeh_pe_get_parent(edev);
>  	if (!parent) {
> -		parent = eeh_phb_pe_get(pdn->phb);
> +		parent = eeh_phb_pe_get(edev->controller);
>  		if (!parent) {
>  			pr_err("%s: No PHB PE is found (PHB Domain=%d)\n",
> -				__func__, pdn->phb->global_number);
> +				__func__, edev->controller->global_number);
>  			edev->pe = NULL;
>  			kfree(pe);
>  			return -EEXIST;
> @@ -698,7 +697,6 @@ void eeh_pe_state_clear(struct eeh_pe *root, int state, bool include_passed)
>   */
>  static void eeh_bridge_check_link(struct eeh_dev *edev)
>  {
> -	struct pci_dn *pdn = eeh_dev_to_pdn(edev);


This belongs to 09/46. Or just merge them.


>  	int cap;
>  	uint32_t val;
>  	int timeout = 0;
>
diff mbox series

Patch

diff --git a/arch/powerpc/kernel/eeh.c b/arch/powerpc/kernel/eeh.c
index 63500e34e329..c8039fdb23ba 100644
--- a/arch/powerpc/kernel/eeh.c
+++ b/arch/powerpc/kernel/eeh.c
@@ -167,23 +167,17 @@  void eeh_show_enabled(void)
  */
 static size_t eeh_dump_dev_log(struct eeh_dev *edev, char *buf, size_t len)
 {
-	struct pci_dn *pdn = eeh_dev_to_pdn(edev);
 	u32 cfg;
 	int cap, i;
 	int n = 0, l = 0;
 	char buffer[128];
 
-	if (!pdn) {
-		pr_warn("EEH: Note: No error log for absent device.\n");
-		return 0;
-	}
-
 	n += scnprintf(buf+n, len-n, "%04x:%02x:%02x.%01x\n",
-		       pdn->phb->global_number, pdn->busno,
-		       PCI_SLOT(pdn->devfn), PCI_FUNC(pdn->devfn));
+			edev->pe->phb->global_number, edev->bdfn >> 8,
+			PCI_SLOT(edev->bdfn), PCI_FUNC(edev->bdfn));
 	pr_warn("EEH: of node=%04x:%02x:%02x.%01x\n",
-		pdn->phb->global_number, pdn->busno,
-		PCI_SLOT(pdn->devfn), PCI_FUNC(pdn->devfn));
+		edev->pe->phb->global_number, edev->bdfn >> 8,
+		PCI_SLOT(edev->bdfn), PCI_FUNC(edev->bdfn));
 
 	eeh_ops->read_config(edev, PCI_VENDOR_ID, 4, &cfg);
 	n += scnprintf(buf+n, len-n, "dev/vend:%08x\n", cfg);
diff --git a/arch/powerpc/kernel/eeh_pe.c b/arch/powerpc/kernel/eeh_pe.c
index 634963aa4a77..831f363f1732 100644
--- a/arch/powerpc/kernel/eeh_pe.c
+++ b/arch/powerpc/kernel/eeh_pe.c
@@ -366,9 +366,8 @@  static struct eeh_pe *eeh_pe_get_parent(struct eeh_dev *edev)
  */
 int eeh_add_to_parent_pe(struct eeh_dev *edev)
 {
+	int config_addr = edev->bdfn;
 	struct eeh_pe *pe, *parent;
-	struct pci_dn *pdn = eeh_dev_to_pdn(edev);
-	int config_addr = (pdn->busno << 8) | (pdn->devfn);
 
 	/* Check if the PE number is valid */
 	if (!eeh_has_flag(EEH_VALID_PE_ZERO) && !edev->pe_config_addr) {
@@ -382,7 +381,7 @@  int eeh_add_to_parent_pe(struct eeh_dev *edev)
 	 * PE should be composed of PCI bus and its subordinate
 	 * components.
 	 */
-	pe = eeh_pe_get(pdn->phb, edev->pe_config_addr, config_addr);
+	pe = eeh_pe_get(edev->controller, edev->pe_config_addr, config_addr);
 	if (pe) {
 		if (pe->type & EEH_PE_INVALID) {
 			list_add_tail(&edev->entry, &pe->edevs);
@@ -416,9 +415,9 @@  int eeh_add_to_parent_pe(struct eeh_dev *edev)
 
 	/* Create a new EEH PE */
 	if (edev->physfn)
-		pe = eeh_pe_alloc(pdn->phb, EEH_PE_VF);
+		pe = eeh_pe_alloc(edev->controller, EEH_PE_VF);
 	else
-		pe = eeh_pe_alloc(pdn->phb, EEH_PE_DEVICE);
+		pe = eeh_pe_alloc(edev->controller, EEH_PE_DEVICE);
 	if (!pe) {
 		pr_err("%s: out of memory!\n", __func__);
 		return -ENOMEM;
@@ -434,10 +433,10 @@  int eeh_add_to_parent_pe(struct eeh_dev *edev)
 	 */
 	parent = eeh_pe_get_parent(edev);
 	if (!parent) {
-		parent = eeh_phb_pe_get(pdn->phb);
+		parent = eeh_phb_pe_get(edev->controller);
 		if (!parent) {
 			pr_err("%s: No PHB PE is found (PHB Domain=%d)\n",
-				__func__, pdn->phb->global_number);
+				__func__, edev->controller->global_number);
 			edev->pe = NULL;
 			kfree(pe);
 			return -EEXIST;
@@ -698,7 +697,6 @@  void eeh_pe_state_clear(struct eeh_pe *root, int state, bool include_passed)
  */
 static void eeh_bridge_check_link(struct eeh_dev *edev)
 {
-	struct pci_dn *pdn = eeh_dev_to_pdn(edev);
 	int cap;
 	uint32_t val;
 	int timeout = 0;