All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] iommu/amd - Use dev_err to send events to the system log
@ 2018-01-31  1:04 ` Gary R Hook
  0 siblings, 0 replies; 10+ messages in thread
From: Gary R Hook @ 2018-01-31  1:04 UTC (permalink / raw)
  To: iommu; +Cc: joro, linux-kernel

Remove printk and use a more preferable error logging function.

Signed-off-by: Gary R Hook <gary.hook@amd.com>
---
 drivers/iommu/amd_iommu.c |   56 +++++++++++++++++++++++----------------------
 1 file changed, 29 insertions(+), 27 deletions(-)

diff --git a/drivers/iommu/amd_iommu.c b/drivers/iommu/amd_iommu.c
index b58e0a745b7f..90a61f546bac 100644
--- a/drivers/iommu/amd_iommu.c
+++ b/drivers/iommu/amd_iommu.c
@@ -546,6 +546,8 @@ static void amd_iommu_report_page_fault(u16 devid, u16 domain_id,
 
 static void iommu_print_event(struct amd_iommu *iommu, void *__evt)
 {
+	struct pci_dev *pdev = iommu->dev;
+	struct device *dev = &pdev->dev;
 	int type, devid, domid, flags;
 	volatile u32 *event = __evt;
 	int count = 0;
@@ -572,53 +574,53 @@ static void iommu_print_event(struct amd_iommu *iommu, void *__evt)
 		amd_iommu_report_page_fault(devid, domid, address, flags);
 		return;
 	} else {
-		printk(KERN_ERR "AMD-Vi: Event logged [");
+		dev_err(dev, "AMD-Vi: Event logged [");
 	}
 
 	switch (type) {
 	case EVENT_TYPE_ILL_DEV:
-		printk("ILLEGAL_DEV_TABLE_ENTRY device=%02x:%02x.%x "
-		       "address=0x%016llx flags=0x%04x]\n",
-		       PCI_BUS_NUM(devid), PCI_SLOT(devid), PCI_FUNC(devid),
-		       address, flags);
+		dev_err(dev, "ILLEGAL_DEV_TABLE_ENTRY device=%02x:%02x.%x "
+			"address=0x%016llx flags=0x%04x]\n",
+			PCI_BUS_NUM(devid), PCI_SLOT(devid), PCI_FUNC(devid),
+			address, flags);
 		dump_dte_entry(devid);
 		break;
 	case EVENT_TYPE_DEV_TAB_ERR:
-		printk("DEV_TAB_HARDWARE_ERROR device=%02x:%02x.%x "
-		       "address=0x%016llx flags=0x%04x]\n",
-		       PCI_BUS_NUM(devid), PCI_SLOT(devid), PCI_FUNC(devid),
-		       address, flags);
+		dev_err(dev, "DEV_TAB_HARDWARE_ERROR device=%02x:%02x.%x "
+			"address=0x%016llx flags=0x%04x]\n",
+			PCI_BUS_NUM(devid), PCI_SLOT(devid), PCI_FUNC(devid),
+			address, flags);
 		break;
 	case EVENT_TYPE_PAGE_TAB_ERR:
-		printk("PAGE_TAB_HARDWARE_ERROR device=%02x:%02x.%x "
-		       "domain=0x%04x address=0x%016llx flags=0x%04x]\n",
-		       PCI_BUS_NUM(devid), PCI_SLOT(devid), PCI_FUNC(devid),
-		       domid, address, flags);
+		dev_err(dev, "PAGE_TAB_HARDWARE_ERROR device=%02x:%02x.%x "
+			"domain=0x%04x address=0x%016llx flags=0x%04x]\n",
+			PCI_BUS_NUM(devid), PCI_SLOT(devid), PCI_FUNC(devid),
+			domid, address, flags);
 		break;
 	case EVENT_TYPE_ILL_CMD:
-		printk("ILLEGAL_COMMAND_ERROR address=0x%016llx]\n", address);
+		dev_err(dev, "ILLEGAL_COMMAND_ERROR address=0x%016llx]\n", address);
 		dump_command(address);
 		break;
 	case EVENT_TYPE_CMD_HARD_ERR:
-		printk("COMMAND_HARDWARE_ERROR address=0x%016llx "
-		       "flags=0x%04x]\n", address, flags);
+		dev_err(dev, "COMMAND_HARDWARE_ERROR address=0x%016llx "
+			"flags=0x%04x]\n", address, flags);
 		break;
 	case EVENT_TYPE_IOTLB_INV_TO:
-		printk("IOTLB_INV_TIMEOUT device=%02x:%02x.%x "
-		       "address=0x%016llx]\n",
-		       PCI_BUS_NUM(devid), PCI_SLOT(devid), PCI_FUNC(devid),
-		       address);
+		dev_err(dev, "IOTLB_INV_TIMEOUT device=%02x:%02x.%x "
+			"address=0x%016llx]\n",
+			PCI_BUS_NUM(devid), PCI_SLOT(devid), PCI_FUNC(devid),
+			address);
 		break;
 	case EVENT_TYPE_INV_DEV_REQ:
-		printk("INVALID_DEVICE_REQUEST device=%02x:%02x.%x "
-		       "address=0x%016llx flags=0x%04x]\n",
-		       PCI_BUS_NUM(devid), PCI_SLOT(devid), PCI_FUNC(devid),
-		       address, flags);
+		dev_err(dev, "INVALID_DEVICE_REQUEST device=%02x:%02x.%x "
+			"address=0x%016llx flags=0x%04x]\n",
+			PCI_BUS_NUM(devid), PCI_SLOT(devid), PCI_FUNC(devid),
+			address, flags);
 		break;
 	default:
-		printk(KERN_ERR "UNKNOWN type=0x%02x event[0]=0x%08x "
-		       "event[1]=0x%08x event[2]=0x%08x event[3]=0x%08x\n",
-		       type, event[0], event[1], event[2], event[3]);
+		dev_err(dev, KERN_ERR "UNKNOWN event[0]=0x%08x event[1]=0x%08x "
+			"event[2]=0x%08x event[3]=0x%08x\n",
+			event[0], event[1], event[2], event[3]);
 	}
 
 	memset(__evt, 0, 4 * sizeof(u32));

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

* [PATCH] iommu/amd - Use dev_err to send events to the system log
@ 2018-01-31  1:04 ` Gary R Hook
  0 siblings, 0 replies; 10+ messages in thread
From: Gary R Hook @ 2018-01-31  1:04 UTC (permalink / raw)
  To: iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA
  Cc: linux-kernel-u79uwXL29TY76Z2rM5mHXA

Remove printk and use a more preferable error logging function.

Signed-off-by: Gary R Hook <gary.hook-5C7GfCeVMHo@public.gmane.org>
---
 drivers/iommu/amd_iommu.c |   56 +++++++++++++++++++++++----------------------
 1 file changed, 29 insertions(+), 27 deletions(-)

diff --git a/drivers/iommu/amd_iommu.c b/drivers/iommu/amd_iommu.c
index b58e0a745b7f..90a61f546bac 100644
--- a/drivers/iommu/amd_iommu.c
+++ b/drivers/iommu/amd_iommu.c
@@ -546,6 +546,8 @@ static void amd_iommu_report_page_fault(u16 devid, u16 domain_id,
 
 static void iommu_print_event(struct amd_iommu *iommu, void *__evt)
 {
+	struct pci_dev *pdev = iommu->dev;
+	struct device *dev = &pdev->dev;
 	int type, devid, domid, flags;
 	volatile u32 *event = __evt;
 	int count = 0;
@@ -572,53 +574,53 @@ static void iommu_print_event(struct amd_iommu *iommu, void *__evt)
 		amd_iommu_report_page_fault(devid, domid, address, flags);
 		return;
 	} else {
-		printk(KERN_ERR "AMD-Vi: Event logged [");
+		dev_err(dev, "AMD-Vi: Event logged [");
 	}
 
 	switch (type) {
 	case EVENT_TYPE_ILL_DEV:
-		printk("ILLEGAL_DEV_TABLE_ENTRY device=%02x:%02x.%x "
-		       "address=0x%016llx flags=0x%04x]\n",
-		       PCI_BUS_NUM(devid), PCI_SLOT(devid), PCI_FUNC(devid),
-		       address, flags);
+		dev_err(dev, "ILLEGAL_DEV_TABLE_ENTRY device=%02x:%02x.%x "
+			"address=0x%016llx flags=0x%04x]\n",
+			PCI_BUS_NUM(devid), PCI_SLOT(devid), PCI_FUNC(devid),
+			address, flags);
 		dump_dte_entry(devid);
 		break;
 	case EVENT_TYPE_DEV_TAB_ERR:
-		printk("DEV_TAB_HARDWARE_ERROR device=%02x:%02x.%x "
-		       "address=0x%016llx flags=0x%04x]\n",
-		       PCI_BUS_NUM(devid), PCI_SLOT(devid), PCI_FUNC(devid),
-		       address, flags);
+		dev_err(dev, "DEV_TAB_HARDWARE_ERROR device=%02x:%02x.%x "
+			"address=0x%016llx flags=0x%04x]\n",
+			PCI_BUS_NUM(devid), PCI_SLOT(devid), PCI_FUNC(devid),
+			address, flags);
 		break;
 	case EVENT_TYPE_PAGE_TAB_ERR:
-		printk("PAGE_TAB_HARDWARE_ERROR device=%02x:%02x.%x "
-		       "domain=0x%04x address=0x%016llx flags=0x%04x]\n",
-		       PCI_BUS_NUM(devid), PCI_SLOT(devid), PCI_FUNC(devid),
-		       domid, address, flags);
+		dev_err(dev, "PAGE_TAB_HARDWARE_ERROR device=%02x:%02x.%x "
+			"domain=0x%04x address=0x%016llx flags=0x%04x]\n",
+			PCI_BUS_NUM(devid), PCI_SLOT(devid), PCI_FUNC(devid),
+			domid, address, flags);
 		break;
 	case EVENT_TYPE_ILL_CMD:
-		printk("ILLEGAL_COMMAND_ERROR address=0x%016llx]\n", address);
+		dev_err(dev, "ILLEGAL_COMMAND_ERROR address=0x%016llx]\n", address);
 		dump_command(address);
 		break;
 	case EVENT_TYPE_CMD_HARD_ERR:
-		printk("COMMAND_HARDWARE_ERROR address=0x%016llx "
-		       "flags=0x%04x]\n", address, flags);
+		dev_err(dev, "COMMAND_HARDWARE_ERROR address=0x%016llx "
+			"flags=0x%04x]\n", address, flags);
 		break;
 	case EVENT_TYPE_IOTLB_INV_TO:
-		printk("IOTLB_INV_TIMEOUT device=%02x:%02x.%x "
-		       "address=0x%016llx]\n",
-		       PCI_BUS_NUM(devid), PCI_SLOT(devid), PCI_FUNC(devid),
-		       address);
+		dev_err(dev, "IOTLB_INV_TIMEOUT device=%02x:%02x.%x "
+			"address=0x%016llx]\n",
+			PCI_BUS_NUM(devid), PCI_SLOT(devid), PCI_FUNC(devid),
+			address);
 		break;
 	case EVENT_TYPE_INV_DEV_REQ:
-		printk("INVALID_DEVICE_REQUEST device=%02x:%02x.%x "
-		       "address=0x%016llx flags=0x%04x]\n",
-		       PCI_BUS_NUM(devid), PCI_SLOT(devid), PCI_FUNC(devid),
-		       address, flags);
+		dev_err(dev, "INVALID_DEVICE_REQUEST device=%02x:%02x.%x "
+			"address=0x%016llx flags=0x%04x]\n",
+			PCI_BUS_NUM(devid), PCI_SLOT(devid), PCI_FUNC(devid),
+			address, flags);
 		break;
 	default:
-		printk(KERN_ERR "UNKNOWN type=0x%02x event[0]=0x%08x "
-		       "event[1]=0x%08x event[2]=0x%08x event[3]=0x%08x\n",
-		       type, event[0], event[1], event[2], event[3]);
+		dev_err(dev, KERN_ERR "UNKNOWN event[0]=0x%08x event[1]=0x%08x "
+			"event[2]=0x%08x event[3]=0x%08x\n",
+			event[0], event[1], event[2], event[3]);
 	}
 
 	memset(__evt, 0, 4 * sizeof(u32));

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

* Re: [PATCH] iommu/amd - Use dev_err to send events to the system log
  2018-01-31  1:04 ` Gary R Hook
  (?)
@ 2018-02-13 13:22 ` Joerg Roedel
  2018-02-13 15:47   ` Hook, Gary
  -1 siblings, 1 reply; 10+ messages in thread
From: Joerg Roedel @ 2018-02-13 13:22 UTC (permalink / raw)
  To: Gary R Hook; +Cc: iommu, linux-kernel

On Tue, Jan 30, 2018 at 07:04:27PM -0600, Gary R Hook wrote:
> +		dev_err(dev, "ILLEGAL_DEV_TABLE_ENTRY device=%02x:%02x.%x "
> +			"address=0x%016llx flags=0x%04x]\n",
> +			PCI_BUS_NUM(devid), PCI_SLOT(devid), PCI_FUNC(devid),
> +			address, flags);

That prints the PCI device-name of the IOMMU in front of the message. Is
that actually helpful?

If at all, we should print the name of the iommu-device in front of the
message, not the PCI device that hosts the IOMMU.


Thanks,

	Joerg

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

* Re: [PATCH] iommu/amd - Use dev_err to send events to the system log
  2018-02-13 13:22 ` Joerg Roedel
@ 2018-02-13 15:47   ` Hook, Gary
  2018-02-13 16:00     ` Joerg Roedel
  0 siblings, 1 reply; 10+ messages in thread
From: Hook, Gary @ 2018-02-13 15:47 UTC (permalink / raw)
  To: Joerg Roedel, Gary R Hook; +Cc: iommu, linux-kernel

On 2/13/2018 8:22 AM, Joerg Roedel wrote:
> On Tue, Jan 30, 2018 at 07:04:27PM -0600, Gary R Hook wrote:
>> +		dev_err(dev, "ILLEGAL_DEV_TABLE_ENTRY device=%02x:%02x.%x "
>> +			"address=0x%016llx flags=0x%04x]\n",
>> +			PCI_BUS_NUM(devid), PCI_SLOT(devid), PCI_FUNC(devid),
>> +			address, flags);
> 
> That prints the PCI device-name of the IOMMU in front of the message. Is
> that actually helpful?
> 
> If at all, we should print the name of the iommu-device in front of the
> message, not the PCI device that hosts the IOMMU.

so (e.g.):

         dev_err(&iommu->dev->dev, "ILLEGAL...

?

I'm okay with that. It does make more sense.

Gary

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

* Re: [PATCH] iommu/amd - Use dev_err to send events to the system log
  2018-02-13 15:47   ` Hook, Gary
@ 2018-02-13 16:00     ` Joerg Roedel
  2018-02-13 19:24       ` Hook, Gary
  0 siblings, 1 reply; 10+ messages in thread
From: Joerg Roedel @ 2018-02-13 16:00 UTC (permalink / raw)
  To: Hook, Gary; +Cc: Gary R Hook, iommu, linux-kernel

On Tue, Feb 13, 2018 at 10:47:55AM -0500, Hook, Gary wrote:
> 
>         dev_err(&iommu->dev->dev, "ILLEGAL...

I think its more something like iommu->iommu->dev.


	Joerg

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

* Re: [PATCH] iommu/amd - Use dev_err to send events to the system log
  2018-02-13 16:00     ` Joerg Roedel
@ 2018-02-13 19:24       ` Hook, Gary
  2018-02-14 11:49           ` Joerg Roedel
  0 siblings, 1 reply; 10+ messages in thread
From: Hook, Gary @ 2018-02-13 19:24 UTC (permalink / raw)
  To: Joerg Roedel; +Cc: Gary R Hook, iommu, linux-kernel

On 2/13/2018 11:00 AM, Joerg Roedel wrote:
> On Tue, Feb 13, 2018 at 10:47:55AM -0500, Hook, Gary wrote:
>>
>>          dev_err(&iommu->dev->dev, "ILLEGAL...
> 
> I think its more something like iommu->iommu->dev.
> 
> 


Without actually running a driver and getting some debug info, I'll just
say that my example compiled, the amd_iommu structure points to a 
pci_dev which contains a device, and the two possibilities are likely 
equivalent.

I'll vet that, of course, but working under the assumption that they are 
equivalent, the question becomes, do you have a preference?

Thanks,
Gary

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

* Re: [PATCH] iommu/amd - Use dev_err to send events to the system log
@ 2018-02-14 11:49           ` Joerg Roedel
  0 siblings, 0 replies; 10+ messages in thread
From: Joerg Roedel @ 2018-02-14 11:49 UTC (permalink / raw)
  To: Hook, Gary; +Cc: Gary R Hook, iommu, linux-kernel

On Tue, Feb 13, 2018 at 02:24:56PM -0500, Hook, Gary wrote:
> Without actually running a driver and getting some debug info, I'll just
> say that my example compiled, the amd_iommu structure points to a pci_dev
> which contains a device, and the two possibilities are likely equivalent.
> 
> I'll vet that, of course, but working under the assumption that they are
> equivalent, the question becomes, do you have a preference?

They are not equivalent, your version points to the pci_dev containing
the IOMMU, my version points to the (virtual) iommu-device for that
particular iommu in the kernel.

So the difference in the prefix is:

	your version: '0000:00:00.2:'

	vs. my version: 'ivhd0:'

The latter is the better prefix, because it points to the iommu. A
pci_dev can contain more than one iommu, so that prefix is not specific
enough. I know that there is currently no hardware implementing multiple
iommus on one pci_dev, but it is allowed according to the spec.


Regards,

	Joerg

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

* Re: [PATCH] iommu/amd - Use dev_err to send events to the system log
@ 2018-02-14 11:49           ` Joerg Roedel
  0 siblings, 0 replies; 10+ messages in thread
From: Joerg Roedel @ 2018-02-14 11:49 UTC (permalink / raw)
  To: Hook, Gary
  Cc: iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA

On Tue, Feb 13, 2018 at 02:24:56PM -0500, Hook, Gary wrote:
> Without actually running a driver and getting some debug info, I'll just
> say that my example compiled, the amd_iommu structure points to a pci_dev
> which contains a device, and the two possibilities are likely equivalent.
> 
> I'll vet that, of course, but working under the assumption that they are
> equivalent, the question becomes, do you have a preference?

They are not equivalent, your version points to the pci_dev containing
the IOMMU, my version points to the (virtual) iommu-device for that
particular iommu in the kernel.

So the difference in the prefix is:

	your version: '0000:00:00.2:'

	vs. my version: 'ivhd0:'

The latter is the better prefix, because it points to the iommu. A
pci_dev can contain more than one iommu, so that prefix is not specific
enough. I know that there is currently no hardware implementing multiple
iommus on one pci_dev, but it is allowed according to the spec.


Regards,

	Joerg

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

* Re: [PATCH] iommu/amd - Use dev_err to send events to the system log
@ 2018-02-14 14:58             ` Hook, Gary
  0 siblings, 0 replies; 10+ messages in thread
From: Hook, Gary @ 2018-02-14 14:58 UTC (permalink / raw)
  To: Joerg Roedel; +Cc: Gary R Hook, iommu, linux-kernel

On 2/14/2018 6:49 AM, Joerg Roedel wrote:
> On Tue, Feb 13, 2018 at 02:24:56PM -0500, Hook, Gary wrote:
>> Without actually running a driver and getting some debug info, I'll just
>> say that my example compiled, the amd_iommu structure points to a pci_dev
>> which contains a device, and the two possibilities are likely equivalent.
>>
>> I'll vet that, of course, but working under the assumption that they are
>> equivalent, the question becomes, do you have a preference?
> 
> They are not equivalent, your version points to the pci_dev containing
> the IOMMU, my version points to the (virtual) iommu-device for that
> particular iommu in the kernel.
> 
> So the difference in the prefix is:
> 
> 	your version: '0000:00:00.2:'
> 
> 	vs. my version: 'ivhd0:'
> 
> The latter is the better prefix, because it points to the iommu. A
> pci_dev can contain more than one iommu, so that prefix is not specific
> enough. I know that there is currently no hardware implementing multiple
> iommus on one pci_dev, but it is allowed according to the spec.

Excellent; specificity is good. I'll crank a new version using that
device.

Thank you!

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

* Re: [PATCH] iommu/amd - Use dev_err to send events to the system log
@ 2018-02-14 14:58             ` Hook, Gary
  0 siblings, 0 replies; 10+ messages in thread
From: Hook, Gary @ 2018-02-14 14:58 UTC (permalink / raw)
  To: Joerg Roedel
  Cc: iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA

On 2/14/2018 6:49 AM, Joerg Roedel wrote:
> On Tue, Feb 13, 2018 at 02:24:56PM -0500, Hook, Gary wrote:
>> Without actually running a driver and getting some debug info, I'll just
>> say that my example compiled, the amd_iommu structure points to a pci_dev
>> which contains a device, and the two possibilities are likely equivalent.
>>
>> I'll vet that, of course, but working under the assumption that they are
>> equivalent, the question becomes, do you have a preference?
> 
> They are not equivalent, your version points to the pci_dev containing
> the IOMMU, my version points to the (virtual) iommu-device for that
> particular iommu in the kernel.
> 
> So the difference in the prefix is:
> 
> 	your version: '0000:00:00.2:'
> 
> 	vs. my version: 'ivhd0:'
> 
> The latter is the better prefix, because it points to the iommu. A
> pci_dev can contain more than one iommu, so that prefix is not specific
> enough. I know that there is currently no hardware implementing multiple
> iommus on one pci_dev, but it is allowed according to the spec.

Excellent; specificity is good. I'll crank a new version using that
device.

Thank you!

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

end of thread, other threads:[~2018-02-14 15:00 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-01-31  1:04 [PATCH] iommu/amd - Use dev_err to send events to the system log Gary R Hook
2018-01-31  1:04 ` Gary R Hook
2018-02-13 13:22 ` Joerg Roedel
2018-02-13 15:47   ` Hook, Gary
2018-02-13 16:00     ` Joerg Roedel
2018-02-13 19:24       ` Hook, Gary
2018-02-14 11:49         ` Joerg Roedel
2018-02-14 11:49           ` Joerg Roedel
2018-02-14 14:58           ` Hook, Gary
2018-02-14 14:58             ` Hook, Gary

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.