npu: Fix device binding error message
diff mbox series

Message ID 1565198244-29339-1-git-send-email-arbab@linux.ibm.com
State Accepted
Headers show
Series
  • npu: Fix device binding error message
Related show

Checks

Context Check Description
snowpatch_ozlabs/snowpatch_job_snowpatch-skiboot-dco success Signed-off-by present
snowpatch_ozlabs/snowpatch_job_snowpatch-skiboot success Test snowpatch/job/snowpatch-skiboot on branch master
snowpatch_ozlabs/apply_patch success Successfully applied on branch master (0e1db80c70477d89a73c7f2a1a7e19c7d8292c5f)

Commit Message

Reza Arbab Aug. 7, 2019, 5:17 p.m. UTC
Helping someone troubleshoot a Garrison machine, I noticed some of the
BDFs printed here are wrong:

npu_dev_bind_pci_dev: No PCI device for NPU device 0004:00:00.0 to bind to. If you expect a GPU to be there, this is a problem.
npu_dev_bind_pci_dev: No PCI device for NPU device 0004:00:01.0 to bind to. If you expect a GPU to be there, this is a problem.
npu_dev_bind_pci_dev: No PCI device for NPU device 0004:00:04.0 to bind to. If you expect a GPU to be there, this is a problem.
npu_dev_bind_pci_dev: No PCI device for NPU device 0004:00:05.0 to bind to. If you expect a GPU to be there, this is a problem.

Change the prlog() call to print them correctly.

Signed-off-by: Reza Arbab <arbab@linux.ibm.com>
---
 hw/npu.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

Comments

Alexey Kardashevskiy Aug. 8, 2019, 7:35 a.m. UTC | #1
On 08/08/2019 03:17, Reza Arbab wrote:
> Helping someone troubleshoot a Garrison machine, I noticed some of the
> BDFs printed here are wrong:
> 
> npu_dev_bind_pci_dev: No PCI device for NPU device 0004:00:00.0 to bind to. If you expect a GPU to be there, this is a problem.
> npu_dev_bind_pci_dev: No PCI device for NPU device 0004:00:01.0 to bind to. If you expect a GPU to be there, this is a problem.
> npu_dev_bind_pci_dev: No PCI device for NPU device 0004:00:04.0 to bind to. If you expect a GPU to be there, this is a problem.
> npu_dev_bind_pci_dev: No PCI device for NPU device 0004:00:05.0 to bind to. If you expect a GPU to be there, this is a problem.
> 
> Change the prlog() call to print them correctly.
> 
> Signed-off-by: Reza Arbab <arbab@linux.ibm.com>
> ---
>   hw/npu.c | 8 ++++++--
>   1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/hw/npu.c b/hw/npu.c
> index b0c23f76d53d..2466614ad95f 100644
> --- a/hw/npu.c
> +++ b/hw/npu.c
> @@ -385,8 +385,12 @@ static void npu_dev_bind_pci_dev(struct npu_dev *dev)
>   		}
>   	}
>   
> -	prlog(PR_INFO, "%s: No PCI device for NPU device %04x:00:%02x.0 to bind to. If you expect a GPU to be there, this is a problem.\n",
> -	      __func__, dev->npu->phb.opal_id, dev->index);
> +	prlog(PR_INFO, "%s: No PCI device for NPU device %04x:%02x:%02x.%x to bind to. If you expect a GPU to be there, this is a problem.\n",
> +	      __func__, dev->npu->phb.opal_id,
> +	      dev->pvd->bdfn >> 8 & 0xff,
> +	      dev->pvd->bdfn >> 3 & 0x1f,
> +	      dev->pvd->bdfn & 0x7);
> +

I wanted to suggest using PCI_BUS_NUM/PCI_SLOT/PCI_FUNC instead and then 
realized that skiboot simply does not have these or similar (copied from 
qemu):

#define PCI_BUS_NUM(x)          (((x) >> 8) & 0xff)
#define PCI_SLOT(devfn)         (((devfn) >> 3) & 0x1f)
#define PCI_FUNC(devfn)         ((devfn) & 0x07)

Oh well, the patch is absolutely correct then


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




>   }
>   
>   static struct lock pci_npu_phandle_lock = LOCK_UNLOCKED;
>
Oliver O'Halloran Aug. 8, 2019, 1:41 p.m. UTC | #2
On Thu, Aug 8, 2019 at 5:36 PM Alexey Kardashevskiy <aik@ozlabs.ru> wrote:
>
> I wanted to suggest using PCI_BUS_NUM/PCI_SLOT/PCI_FUNC instead and then
> realized that skiboot simply does not have these or similar (copied from
> qemu):
>
> #define PCI_BUS_NUM(x)          (((x) >> 8) & 0xff)
> #define PCI_SLOT(devfn)         (((devfn) >> 3) & 0x1f)
> #define PCI_FUNC(devfn)         ((devfn) & 0x07)
>
> Oh well, the patch is absolutely correct then

I wouldn't complain if someone added those.

Patch
diff mbox series

diff --git a/hw/npu.c b/hw/npu.c
index b0c23f76d53d..2466614ad95f 100644
--- a/hw/npu.c
+++ b/hw/npu.c
@@ -385,8 +385,12 @@  static void npu_dev_bind_pci_dev(struct npu_dev *dev)
 		}
 	}
 
-	prlog(PR_INFO, "%s: No PCI device for NPU device %04x:00:%02x.0 to bind to. If you expect a GPU to be there, this is a problem.\n",
-	      __func__, dev->npu->phb.opal_id, dev->index);
+	prlog(PR_INFO, "%s: No PCI device for NPU device %04x:%02x:%02x.%x to bind to. If you expect a GPU to be there, this is a problem.\n",
+	      __func__, dev->npu->phb.opal_id,
+	      dev->pvd->bdfn >> 8 & 0xff,
+	      dev->pvd->bdfn >> 3 & 0x1f,
+	      dev->pvd->bdfn & 0x7);
+
 }
 
 static struct lock pci_npu_phandle_lock = LOCK_UNLOCKED;