Skip to contentSkip to conversation

pcifront for ia64

PATCH Tristan Gingold 2 participants 3 messages Jul 27, 2006

lore
Share & tools
lore
#0 lore raw

Hi,

this patch ports pcifont to ia64. pciback compiles without any change.

I had to make a few change because pcifront use its own structure (struct pcifront_sd) for sysdata while ia64 wants it own (at least for pcibios_fixup_bus). My solution is to reuse the ia64 sysdata structure for pcifront, at the cost of a few ugly #ifdef.

Comments and ideas are welcome to improve this.

Also the patch fix a compile-time warning for xenbus.c.

Using this patch I was able to use an ethernet card in domU. This is the good news.

Tristan.

# HG changeset patch
# User gingold@virtu10
# Node ID 1ffb1200700b08420a1656b817171798ff45bad4 # Parent 64fd80e1b24f94d2c9de520c5c113b9566997bd4 Pcifront for ia64.

Added in Kconfig.
Use ia64 sysdate instead of pcifront genuine one.
Fix a warning on xenbus.c

linux-2.6-xen-sparse/arch/ia64/Kconfig +15 -0
diff -r 64fd80e1b24f -r 1ffb1200700b linux-2.6-xen-sparse/arch/ia64/Kconfig
@@ -438,6 +438,21 @@ config PCI_DOMAINS
 	bool
 	default PCI
 
+config XEN_PCIDEV_FRONTEND
+	bool "Xen PCI Frontend"
+	depends on PCI && XEN
+	default y
+	help
+	  The PCI device frontend driver allows the kernel to import arbitrary
+	  PCI devices from a PCI backend to support PCI driver domains.
+
+config XEN_PCIDEV_FE_DEBUG
+	bool "Xen PCI Frontend Debugging"
+	depends on XEN_PCIDEV_FRONTEND
+	default n
+	help
+	  Enables some debug statements within the PCI Frontend.
+
 source "drivers/pci/Kconfig"
 
 source "drivers/pci/hotplug/Kconfig"
linux-2.6-xen-sparse/drivers/xen/pcifront/pci_op.c +11 -2
diff -r 64fd80e1b24f -r 1ffb1200700b linux-2.6-xen-sparse/drivers/xen/pcifront/pci_op.c
@@ -105,7 +105,7 @@ static int pcifront_bus_read(struct pci_
 		.size   = size,
 	};
 	struct pcifront_sd *sd = bus->sysdata;
-	struct pcifront_device *pdev = sd->pdev;
+	struct pcifront_device *pdev = pcifront_get_pdev(sd);
 
 	if (verbose_request)
 		dev_info(&pdev->xdev->dev,
@@ -144,7 +144,7 @@ static int pcifront_bus_write(struct pci
 		.value  = val,
 	};
 	struct pcifront_sd *sd = bus->sysdata;
-	struct pcifront_device *pdev = sd->pdev;
+	struct pcifront_device *pdev = pcifront_get_pdev(sd);
 
 	if (verbose_request)
 		dev_info(&pdev->xdev->dev,
@@ -207,8 +207,17 @@ int pcifront_scan_root(struct pcifront_d
 		err = -ENOMEM;
 		goto err_out;
 	}
+#ifdef __ia64__
+	sd->segment = domain;
+	sd->acpi_handle = NULL;
+	sd->iommu = NULL;
+	sd->windows = 0;
+	sd->window = NULL;
+	sd->platform_data = pdev;
+#else
 	sd->domain = domain;
 	sd->pdev = pdev;
+#endif
 
 	b = pci_scan_bus_parented(&pdev->xdev->dev, bus, &pcifront_bus_ops, sd);
 	if (!b) {
linux-2.6-xen-sparse/drivers/xen/pcifront/xenbus.c +1 -0
diff -r 64fd80e1b24f -r 1ffb1200700b linux-2.6-xen-sparse/drivers/xen/pcifront/xenbus.c
@@ -7,6 +7,7 @@
 #include <linux/init.h>
 #include <linux/mm.h>
 #include <xen/xenbus.h>
+#include <xen/gnttab.h>
 #include "pcifront.h"
 
 #define INVALID_GRANT_REF (0)
linux-2.6-xen-sparse/include/xen/pcifront.h +19 -1
diff -r 64fd80e1b24f -r 1ffb1200700b linux-2.6-xen-sparse/include/xen/pcifront.h
@@ -11,6 +11,7 @@
 
 #ifdef __KERNEL__
 
+#ifndef __ia64__
 struct pcifront_device;
 
 struct pcifront_sd {
@@ -20,7 +21,13 @@ struct pcifront_sd {
 
 struct pci_bus;
 
-#ifdef CONFIG_PCI_DOMAINS
+static inline struct pcifront_device *
+pcifront_get_pdev (struct pcifront_sd *sd)
+{
+	return sd->pdev;
+}
+
+#if defined(CONFIG_PCI_DOMAINS)
 static inline int pci_domain_nr(struct pci_bus *bus)
 {
 	struct pcifront_sd *sd = bus->sysdata;
@@ -31,6 +38,17 @@ static inline int pci_proc_domain(struct
 	return pci_domain_nr(bus);
 }
 #endif /* CONFIG_PCI_DOMAINS */
+#else
+#include <asm/pci.h>
+#define pcifront_sd pci_controller
+
+static inline struct pcifront_device *
+pcifront_get_pdev (struct pcifront_sd *sd)
+{
+	return (struct pcifront_device *)sd->platform_data;
+}
+
+#endif /* __ia64__ */
 
 extern spinlock_t pci_bus_lock;
 

# HG changeset patch
# User gingold@virtu10
# Node ID 1ffb1200700b08420a1656b817171798ff45bad4 # Parent 64fd80e1b24f94d2c9de520c5c113b9566997bd4 Pcifront for ia64.

Added in Kconfig.
Use ia64 sysdate instead of pcifront genuine one.
Fix a warning on xenbus.c

linux-2.6-xen-sparse/arch/ia64/Kconfig +15 -0
diff -r 64fd80e1b24f -r 1ffb1200700b linux-2.6-xen-sparse/arch/ia64/Kconfig
@@ -438,6 +438,21 @@ config PCI_DOMAINS
 	bool
 	default PCI
 
+config XEN_PCIDEV_FRONTEND
+	bool "Xen PCI Frontend"
+	depends on PCI && XEN
+	default y
+	help
+	  The PCI device frontend driver allows the kernel to import arbitrary
+	  PCI devices from a PCI backend to support PCI driver domains.
+
+config XEN_PCIDEV_FE_DEBUG
+	bool "Xen PCI Frontend Debugging"
+	depends on XEN_PCIDEV_FRONTEND
+	default n
+	help
+	  Enables some debug statements within the PCI Frontend.
+
 source "drivers/pci/Kconfig"
 
 source "drivers/pci/hotplug/Kconfig"
linux-2.6-xen-sparse/drivers/xen/pcifront/pci_op.c +11 -2
diff -r 64fd80e1b24f -r 1ffb1200700b linux-2.6-xen-sparse/drivers/xen/pcifront/pci_op.c
@@ -105,7 +105,7 @@ static int pcifront_bus_read(struct pci_
 		.size   = size,
 	};
 	struct pcifront_sd *sd = bus->sysdata;
-	struct pcifront_device *pdev = sd->pdev;
+	struct pcifront_device *pdev = pcifront_get_pdev(sd);
 
 	if (verbose_request)
 		dev_info(&pdev->xdev->dev,
@@ -144,7 +144,7 @@ static int pcifront_bus_write(struct pci
 		.value  = val,
 	};
 	struct pcifront_sd *sd = bus->sysdata;
-	struct pcifront_device *pdev = sd->pdev;
+	struct pcifront_device *pdev = pcifront_get_pdev(sd);
 
 	if (verbose_request)
 		dev_info(&pdev->xdev->dev,
@@ -207,8 +207,17 @@ int pcifront_scan_root(struct pcifront_d
 		err = -ENOMEM;
 		goto err_out;
 	}
+#ifdef __ia64__
+	sd->segment = domain;
+	sd->acpi_handle = NULL;
+	sd->iommu = NULL;
+	sd->windows = 0;
+	sd->window = NULL;
+	sd->platform_data = pdev;
+#else
 	sd->domain = domain;
 	sd->pdev = pdev;
+#endif
 
 	b = pci_scan_bus_parented(&pdev->xdev->dev, bus, &pcifront_bus_ops, sd);
 	if (!b) {
linux-2.6-xen-sparse/drivers/xen/pcifront/xenbus.c +1 -0
diff -r 64fd80e1b24f -r 1ffb1200700b linux-2.6-xen-sparse/drivers/xen/pcifront/xenbus.c
@@ -7,6 +7,7 @@
 #include <linux/init.h>
 #include <linux/mm.h>
 #include <xen/xenbus.h>
+#include <xen/gnttab.h>
 #include "pcifront.h"
 
 #define INVALID_GRANT_REF (0)
linux-2.6-xen-sparse/include/xen/pcifront.h +19 -1
diff -r 64fd80e1b24f -r 1ffb1200700b linux-2.6-xen-sparse/include/xen/pcifront.h
@@ -11,6 +11,7 @@
 
 #ifdef __KERNEL__
 
+#ifndef __ia64__
 struct pcifront_device;
 
 struct pcifront_sd {
@@ -20,7 +21,13 @@ struct pcifront_sd {
 
 struct pci_bus;
 
-#ifdef CONFIG_PCI_DOMAINS
+static inline struct pcifront_device *
+pcifront_get_pdev (struct pcifront_sd *sd)
+{
+	return sd->pdev;
+}
+
+#if defined(CONFIG_PCI_DOMAINS)
 static inline int pci_domain_nr(struct pci_bus *bus)
 {
 	struct pcifront_sd *sd = bus->sysdata;
@@ -31,6 +38,17 @@ static inline int pci_proc_domain(struct
 	return pci_domain_nr(bus);
 }
 #endif /* CONFIG_PCI_DOMAINS */
+#else
+#include <asm/pci.h>
+#define pcifront_sd pci_controller
+
+static inline struct pcifront_device *
+pcifront_get_pdev (struct pcifront_sd *sd)
+{
+	return (struct pcifront_device *)sd->platform_data;
+}
+
+#endif /* __ia64__ */
 
 extern spinlock_t pci_bus_lock;
 

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#1 lore raw
Quoted 7 lines · Tristan Gingold

this patch ports pcifont to ia64. pciback compiles without any change.

I had to make a few change because pcifront use its own structure (struct pcifront_sd) for sysdata while ia64 wants it own (at least for pcibios_fixup_bus). My solution is to reuse the ia64 sysdata structure for pcifront, at the cost of a few ugly #ifdef.

Quoted 6 lines

Comments and ideas are welcome to improve this.

Also the patch fix a compile-time warning for xenbus.c.

Using this patch I was able to use an ethernet card in domU. This is the good news.

Move the sysdata initialisation to static inline functions in pcifront.h. That means you only have a single big ifdef in the header, and none in the main C files. With that change this will be fine to check in.

-- Keir

#2 lore raw
Quoted 12 lines · Keir Fraser
Quoted 11 lines · Tristan Gingold

this patch ports pcifont to ia64. pciback compiles without any change.

I had to make a few change because pcifront use its own structure (struct pcifront_sd) for sysdata while ia64 wants it own (at least for pcibios_fixup_bus). My solution is to reuse the ia64 sysdata structure for pcifront, at the cost of a few ugly #ifdef.

Comments and ideas are welcome to improve this.

Also the patch fix a compile-time warning for xenbus.c.

Quoted 7 lines
Quoted 2 lines

Using this patch I was able to use an ethernet card in domU. This is the good news.

Move the sysdata initialisation to static inline functions in pcifront.h. That means you only have a single big ifdef in the header, and none in the main C files. With that change this will be fine to check in.

Thank you for your quick reply.
Here is the updated patch.

Tristan.

# HG changeset patch
# User gingold@virtu10
# Node ID 4519e440e05c4083ce28187dd771416a31fbeda1 # Parent 254c090854de353cf9859575c2bed0549d0ff5dd Pcifront for ia64.

Added in Kconfig.
On ia64, use ia64 sysdata instead of pcifront genuine one. Fix a warning on xenbus.c

linux-2.6-xen-sparse/arch/ia64/Kconfig +15 -0
diff -r 254c090854de -r 4519e440e05c linux-2.6-xen-sparse/arch/ia64/Kconfig
@@ -438,6 +438,21 @@ config PCI_DOMAINS
 	bool
 	default PCI
 
+config XEN_PCIDEV_FRONTEND
+	bool "Xen PCI Frontend"
+	depends on PCI && XEN
+	default y
+	help
+	  The PCI device frontend driver allows the kernel to import arbitrary
+	  PCI devices from a PCI backend to support PCI driver domains.
+
+config XEN_PCIDEV_FE_DEBUG
+	bool "Xen PCI Frontend Debugging"
+	depends on XEN_PCIDEV_FRONTEND
+	default n
+	help
+	  Enables some debug statements within the PCI Frontend.
+
 source "drivers/pci/Kconfig"
 
 source "drivers/pci/hotplug/Kconfig"
linux-2.6-xen-sparse/drivers/xen/pcifront/pci_op.c +3 -4
diff -r 254c090854de -r 4519e440e05c linux-2.6-xen-sparse/drivers/xen/pcifront/pci_op.c
@@ -105,7 +105,7 @@ static int pcifront_bus_read(struct pci_
 		.size   = size,
 	};
 	struct pcifront_sd *sd = bus->sysdata;
-	struct pcifront_device *pdev = sd->pdev;
+	struct pcifront_device *pdev = pcifront_get_pdev(sd);
 
 	if (verbose_request)
 		dev_info(&pdev->xdev->dev,
@@ -144,7 +144,7 @@ static int pcifront_bus_write(struct pci
 		.value  = val,
 	};
 	struct pcifront_sd *sd = bus->sysdata;
-	struct pcifront_device *pdev = sd->pdev;
+	struct pcifront_device *pdev = pcifront_get_pdev(sd);
 
 	if (verbose_request)
 		dev_info(&pdev->xdev->dev,
@@ -207,8 +207,7 @@ int pcifront_scan_root(struct pcifront_d
 		err = -ENOMEM;
 		goto err_out;
 	}
-	sd->domain = domain;
-	sd->pdev = pdev;
+	pcifront_init_sd (sd, domain, pdev);
 
 	b = pci_scan_bus_parented(&pdev->xdev->dev, bus, &pcifront_bus_ops, sd);
 	if (!b) {
linux-2.6-xen-sparse/drivers/xen/pcifront/xenbus.c +1 -0
diff -r 254c090854de -r 4519e440e05c linux-2.6-xen-sparse/drivers/xen/pcifront/xenbus.c
@@ -7,6 +7,7 @@
 #include <linux/init.h>
 #include <linux/mm.h>
 #include <xen/xenbus.h>
+#include <xen/gnttab.h>
 #include "pcifront.h"
 
 #define INVALID_GRANT_REF (0)
linux-2.6-xen-sparse/include/xen/pcifront.h +37 -1
diff -r 254c090854de -r 4519e440e05c linux-2.6-xen-sparse/include/xen/pcifront.h
@@ -11,6 +11,7 @@
 
 #ifdef __KERNEL__
 
+#ifndef __ia64__
 struct pcifront_device;
 
 struct pcifront_sd {
@@ -20,7 +21,20 @@ struct pcifront_sd {
 
 struct pci_bus;
 
-#ifdef CONFIG_PCI_DOMAINS
+static inline struct pcifront_device *
+pcifront_get_pdev (struct pcifront_sd *sd)
+{
+	return sd->pdev;
+}
+
+static inline void pcifront_init_sd (struct pcifront_sd *sd, int domain,
+				     struct pcifront_device *pdev)
+{
+	sd->domain = domain;
+	sd->pdev = pdev;
+}
+
+#if defined(CONFIG_PCI_DOMAINS)
 static inline int pci_domain_nr(struct pci_bus *bus)
 {
 	struct pcifront_sd *sd = bus->sysdata;
@@ -31,6 +45,28 @@ static inline int pci_proc_domain(struct
 	return pci_domain_nr(bus);
 }
 #endif /* CONFIG_PCI_DOMAINS */
+#else
+#include <asm/pci.h>
+#define pcifront_sd pci_controller
+
+static inline struct pcifront_device *
+pcifront_get_pdev (struct pcifront_sd *sd)
+{
+	return (struct pcifront_device *)sd->platform_data;
+}
+
+static inline void pcifront_init_sd (struct pcifront_sd *sd, int domain,
+				     struct pcifront_device *pdev)
+{
+	sd->segment = domain;
+	sd->acpi_handle = NULL;
+	sd->iommu = NULL;
+	sd->windows = 0;
+	sd->window = NULL;
+	sd->platform_data = pdev;
+}
+
+#endif /* __ia64__ */
 
 extern spinlock_t pci_bus_lock;
 

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel