All of lore.kernel.org
 help / color / mirror / Atom feed
* [patch] More defines for dma-mapping-broken.h
@ 2007-02-10 11:43 Heiko Carstens
  2007-02-10 17:43 ` [PATCH] iomap: make PCI iomap stuff excluded when PCI isn't configured Tejun Heo
  2007-02-11 15:49 ` [patch] More defines for dma-mapping-broken.h Jeff Garzik
  0 siblings, 2 replies; 13+ messages in thread
From: Heiko Carstens @ 2007-02-10 11:43 UTC (permalink / raw)
  To: Andrew Morton, Linus Torvalds
  Cc: Martin Schwidefsky, Tejun Heo, Jeff Garzik, linux-kernel, linux-s390

From: Heiko Carstens <heiko.carstens@de.ibm.com>

9ac7849e35f705830f7b016ff272b0ff1f7ff759 causes this on s390.
Since we don't support DMA extend dma-mapping-broken.h a bit.

drivers/base/dma-mapping.c: In function `dmam_noncoherent_release':
drivers/base/dma-mapping.c:32:
	warning: implicit declaration of function `dma_free_noncoherent'
drivers/base/dma-mapping.c: In function `dmam_alloc_noncoherent':
drivers/base/dma-mapping.c:129:
	warning: implicit declaration of function `dma_alloc_noncoherent'
drivers/base/dma-mapping.c:129:
	warning: assignment makes pointer from integer without a cast

Cc: Tejun Heo <htejun@gmail.com>
Cc: Jeff Garzik <jeff@garzik.org>
Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
---
 include/asm-generic/dma-mapping-broken.h |    4 +++-
 1 files changed, 3 insertions(+), 1 deletion(-)

Index: linux-2.6/include/asm-generic/dma-mapping-broken.h
===================================================================
--- linux-2.6.orig/include/asm-generic/dma-mapping-broken.h
+++ linux-2.6/include/asm-generic/dma-mapping-broken.h
@@ -3,7 +3,6 @@
 
 /* This is used for archs that do not support DMA */
 
-
 static inline void *
 dma_alloc_coherent(struct device *dev, size_t size, dma_addr_t *dma_handle,
 		   gfp_t flag)
@@ -19,4 +18,7 @@ dma_free_coherent(struct device *dev, si
 	BUG();
 }
 
+#define dma_alloc_noncoherent(d, s, h, f) dma_alloc_coherent(d, s, h, f)
+#define dma_free_noncoherent(d, s, v, h) dma_free_coherent(d, s, v, h)
+
 #endif /* _ASM_GENERIC_DMA_MAPPING_H */

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

* [PATCH] iomap: make PCI iomap stuff excluded when PCI isn't configured
  2007-02-10 11:43 [patch] More defines for dma-mapping-broken.h Heiko Carstens
@ 2007-02-10 17:43 ` Tejun Heo
  2007-02-10 19:46   ` Heiko Carstens
  2007-02-11  2:41   ` Randy Dunlap
  2007-02-11 15:49 ` [patch] More defines for dma-mapping-broken.h Jeff Garzik
  1 sibling, 2 replies; 13+ messages in thread
From: Tejun Heo @ 2007-02-10 17:43 UTC (permalink / raw)
  To: Heiko Carstens
  Cc: Andrew Morton, Linus Torvalds, Martin Schwidefsky, Jeff Garzik,
	linux-kernel, linux-s390

devres iomap made lib/iomap.c always built and added several
arch-indep PCI routines to include/linux/io.h and lib/iomap.c without
wrapping them inside CONFIG_PCI.  This breaks configurations where PCI
is not configured.  Wrap pci_iomap() in CONFIG_PCI and move managed
PCI iomap functions into include/linux/pci.h and drivers/pci/pci.c.

Signed-off-by: Tejun Heo <htejun@gmail.com>
Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
---
Heiko, how about this?  Does it fix s390?

diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index 8b44cff..d6ec47a 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -1314,6 +1314,158 @@ int pci_select_bars(struct pci_dev *dev, unsigned long flags)
 	return bars;
 }
 
+/*
+ * PCI iomap devres
+ */
+#define PCIM_IOMAP_MAX	PCI_ROM_RESOURCE
+
+struct pcim_iomap_devres {
+	void __iomem *table[PCIM_IOMAP_MAX];
+};
+
+static void pcim_iomap_release(struct device *gendev, void *res)
+{
+	struct pci_dev *dev = container_of(gendev, struct pci_dev, dev);
+	struct pcim_iomap_devres *this = res;
+	int i;
+
+	for (i = 0; i < PCIM_IOMAP_MAX; i++)
+		if (this->table[i])
+			pci_iounmap(dev, this->table[i]);
+}
+
+/**
+ * pcim_iomap_table - access iomap allocation table
+ * @pdev: PCI device to access iomap table for
+ *
+ * Access iomap allocation table for @dev.  If iomap table doesn't
+ * exist and @pdev is managed, it will be allocated.  All iomaps
+ * recorded in the iomap table are automatically unmapped on driver
+ * detach.
+ *
+ * This function might sleep when the table is first allocated but can
+ * be safely called without context and guaranteed to succed once
+ * allocated.
+ */
+void __iomem * const * pcim_iomap_table(struct pci_dev *pdev)
+{
+	struct pcim_iomap_devres *dr, *new_dr;
+
+	dr = devres_find(&pdev->dev, pcim_iomap_release, NULL, NULL);
+	if (dr)
+		return dr->table;
+
+	new_dr = devres_alloc(pcim_iomap_release, sizeof(*new_dr), GFP_KERNEL);
+	if (!new_dr)
+		return NULL;
+	dr = devres_get(&pdev->dev, new_dr, NULL, NULL);
+	return dr->table;
+}
+EXPORT_SYMBOL(pcim_iomap_table);
+
+/**
+ * pcim_iomap - Managed pcim_iomap()
+ * @pdev: PCI device to iomap for
+ * @bar: BAR to iomap
+ * @maxlen: Maximum length of iomap
+ *
+ * Managed pci_iomap().  Map is automatically unmapped on driver
+ * detach.
+ */
+void __iomem * pcim_iomap(struct pci_dev *pdev, int bar, unsigned long maxlen)
+{
+	void __iomem **tbl;
+
+	BUG_ON(bar >= PCIM_IOMAP_MAX);
+
+	tbl = (void __iomem **)pcim_iomap_table(pdev);
+	if (!tbl || tbl[bar])	/* duplicate mappings not allowed */
+		return NULL;
+
+	tbl[bar] = pci_iomap(pdev, bar, maxlen);
+	return tbl[bar];
+}
+EXPORT_SYMBOL(pcim_iomap);
+
+/**
+ * pcim_iounmap - Managed pci_iounmap()
+ * @pdev: PCI device to iounmap for
+ * @addr: Address to unmap
+ *
+ * Managed pci_iounmap().  @addr must have been mapped using pcim_iomap().
+ */
+void pcim_iounmap(struct pci_dev *pdev, void __iomem *addr)
+{
+	void __iomem **tbl;
+	int i;
+
+	pci_iounmap(pdev, addr);
+
+	tbl = (void __iomem **)pcim_iomap_table(pdev);
+	BUG_ON(!tbl);
+
+	for (i = 0; i < PCIM_IOMAP_MAX; i++)
+		if (tbl[i] == addr) {
+			tbl[i] = NULL;
+			return;
+		}
+	WARN_ON(1);
+}
+EXPORT_SYMBOL(pcim_iounmap);
+
+/**
+ * pcim_iomap_regions - Request and iomap PCI BARs
+ * @pdev: PCI device to map IO resources for
+ * @mask: Mask of BARs to request and iomap
+ * @name: Name used when requesting regions
+ *
+ * Request and iomap regions specified by @mask.
+ */
+int pcim_iomap_regions(struct pci_dev *pdev, u16 mask, const char *name)
+{
+	void __iomem * const *iomap;
+	int i, rc;
+
+	iomap = pcim_iomap_table(pdev);
+	if (!iomap)
+		return -ENOMEM;
+
+	for (i = 0; i < DEVICE_COUNT_RESOURCE; i++) {
+		unsigned long len;
+
+		if (!(mask & (1 << i)))
+			continue;
+
+		rc = -EINVAL;
+		len = pci_resource_len(pdev, i);
+		if (!len)
+			goto err_inval;
+
+		rc = pci_request_region(pdev, i, name);
+		if (rc)
+			goto err_region;
+
+		rc = -ENOMEM;
+		if (!pcim_iomap(pdev, i, 0))
+			goto err_iomap;
+	}
+
+	return 0;
+
+ err_iomap:
+	pcim_iounmap(pdev, iomap[i]);
+ err_region:
+	pci_release_region(pdev, i);
+ err_inval:
+	while (--i >= 0) {
+		pcim_iounmap(pdev, iomap[i]);
+		pci_release_region(pdev, i);
+	}
+
+	return rc;
+}
+EXPORT_SYMBOL(pcim_iomap_regions);
+
 static int __devinit pci_init(void)
 {
 	struct pci_dev *dev = NULL;
diff --git a/include/linux/io.h b/include/linux/io.h
index 9e419eb..c244a0c 100644
--- a/include/linux/io.h
+++ b/include/linux/io.h
@@ -43,12 +43,6 @@ void __iomem * devm_ioremap_nocache(struct device *dev, unsigned long offset,
 				    unsigned long size);
 void devm_iounmap(struct device *dev, void __iomem *addr);
 
-void __iomem * pcim_iomap(struct pci_dev *pdev, int bar, unsigned long maxlen);
-void pcim_iounmap(struct pci_dev *pdev, void __iomem *addr);
-void __iomem * const * pcim_iomap_table(struct pci_dev *pdev);
-
-int pcim_iomap_regions(struct pci_dev *pdev, u16 mask, const char *name);
-
 /**
  *	check_signature		-	find BIOS signatures
  *	@io_addr: mmio address to check
diff --git a/include/linux/pci.h b/include/linux/pci.h
index 9e3042e..c8f4b84 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -611,6 +611,12 @@ void pci_walk_bus(struct pci_bus *top, void (*cb)(struct pci_dev *, void *),
 int pci_cfg_space_size(struct pci_dev *dev);
 unsigned char pci_bus_max_busnr(struct pci_bus* bus);
 
+/* PCI managed iomap interface */
+void __iomem * pcim_iomap(struct pci_dev *pdev, int bar, unsigned long maxlen);
+void pcim_iounmap(struct pci_dev *pdev, void __iomem *addr);
+void __iomem * const * pcim_iomap_table(struct pci_dev *pdev);
+int pcim_iomap_regions(struct pci_dev *pdev, u16 mask, const char *name);
+
 /* kmem_cache style wrapper around pci_alloc_consistent() */
 
 #include <linux/dmapool.h>
diff --git a/lib/iomap.c b/lib/iomap.c
index 4990c73..bdf31ba 100644
--- a/lib/iomap.c
+++ b/lib/iomap.c
@@ -228,6 +228,8 @@ void ioport_unmap(void __iomem *addr)
 EXPORT_SYMBOL(ioport_map);
 EXPORT_SYMBOL(ioport_unmap);
 
+#ifdef CONFIG_PCI
+
 /* Create a virtual mapping cookie for a PCI BAR (memory or IO) */
 void __iomem *pci_iomap(struct pci_dev *dev, int bar, unsigned long maxlen)
 {
@@ -257,6 +259,7 @@ void pci_iounmap(struct pci_dev *dev, void __iomem * addr)
 EXPORT_SYMBOL(pci_iomap);
 EXPORT_SYMBOL(pci_iounmap);
 
+#endif /* CONFIG_PCI */
 #endif /* CONFIG_GENERIC_IOMAP */
 
 /*
@@ -399,155 +402,3 @@ void devm_iounmap(struct device *dev, void __iomem *addr)
 			       (void *)addr));
 }
 EXPORT_SYMBOL(devm_iounmap);
-
-/*
- * PCI iomap devres
- */
-#define PCIM_IOMAP_MAX	PCI_ROM_RESOURCE
-
-struct pcim_iomap_devres {
-	void __iomem *table[PCIM_IOMAP_MAX];
-};
-
-static void pcim_iomap_release(struct device *gendev, void *res)
-{
-	struct pci_dev *dev = container_of(gendev, struct pci_dev, dev);
-	struct pcim_iomap_devres *this = res;
-	int i;
-
-	for (i = 0; i < PCIM_IOMAP_MAX; i++)
-		if (this->table[i])
-			pci_iounmap(dev, this->table[i]);
-}
-
-/**
- * pcim_iomap_table - access iomap allocation table
- * @pdev: PCI device to access iomap table for
- *
- * Access iomap allocation table for @dev.  If iomap table doesn't
- * exist and @pdev is managed, it will be allocated.  All iomaps
- * recorded in the iomap table are automatically unmapped on driver
- * detach.
- *
- * This function might sleep when the table is first allocated but can
- * be safely called without context and guaranteed to succed once
- * allocated.
- */
-void __iomem * const * pcim_iomap_table(struct pci_dev *pdev)
-{
-	struct pcim_iomap_devres *dr, *new_dr;
-
-	dr = devres_find(&pdev->dev, pcim_iomap_release, NULL, NULL);
-	if (dr)
-		return dr->table;
-
-	new_dr = devres_alloc(pcim_iomap_release, sizeof(*new_dr), GFP_KERNEL);
-	if (!new_dr)
-		return NULL;
-	dr = devres_get(&pdev->dev, new_dr, NULL, NULL);
-	return dr->table;
-}
-EXPORT_SYMBOL(pcim_iomap_table);
-
-/**
- * pcim_iomap - Managed pcim_iomap()
- * @pdev: PCI device to iomap for
- * @bar: BAR to iomap
- * @maxlen: Maximum length of iomap
- *
- * Managed pci_iomap().  Map is automatically unmapped on driver
- * detach.
- */
-void __iomem * pcim_iomap(struct pci_dev *pdev, int bar, unsigned long maxlen)
-{
-	void __iomem **tbl;
-
-	BUG_ON(bar >= PCIM_IOMAP_MAX);
-
-	tbl = (void __iomem **)pcim_iomap_table(pdev);
-	if (!tbl || tbl[bar])	/* duplicate mappings not allowed */
-		return NULL;
-
-	tbl[bar] = pci_iomap(pdev, bar, maxlen);
-	return tbl[bar];
-}
-EXPORT_SYMBOL(pcim_iomap);
-
-/**
- * pcim_iounmap - Managed pci_iounmap()
- * @pdev: PCI device to iounmap for
- * @addr: Address to unmap
- *
- * Managed pci_iounmap().  @addr must have been mapped using pcim_iomap().
- */
-void pcim_iounmap(struct pci_dev *pdev, void __iomem *addr)
-{
-	void __iomem **tbl;
-	int i;
-
-	pci_iounmap(pdev, addr);
-
-	tbl = (void __iomem **)pcim_iomap_table(pdev);
-	BUG_ON(!tbl);
-
-	for (i = 0; i < PCIM_IOMAP_MAX; i++)
-		if (tbl[i] == addr) {
-			tbl[i] = NULL;
-			return;
-		}
-	WARN_ON(1);
-}
-EXPORT_SYMBOL(pcim_iounmap);
-
-/**
- * pcim_iomap_regions - Request and iomap PCI BARs
- * @pdev: PCI device to map IO resources for
- * @mask: Mask of BARs to request and iomap
- * @name: Name used when requesting regions
- *
- * Request and iomap regions specified by @mask.
- */
-int pcim_iomap_regions(struct pci_dev *pdev, u16 mask, const char *name)
-{
-	void __iomem * const *iomap;
-	int i, rc;
-
-	iomap = pcim_iomap_table(pdev);
-	if (!iomap)
-		return -ENOMEM;
-
-	for (i = 0; i < DEVICE_COUNT_RESOURCE; i++) {
-		unsigned long len;
-
-		if (!(mask & (1 << i)))
-			continue;
-
-		rc = -EINVAL;
-		len = pci_resource_len(pdev, i);
-		if (!len)
-			goto err_inval;
-
-		rc = pci_request_region(pdev, i, name);
-		if (rc)
-			goto err_region;
-
-		rc = -ENOMEM;
-		if (!pcim_iomap(pdev, i, 0))
-			goto err_iomap;
-	}
-
-	return 0;
-
- err_iomap:
-	pcim_iounmap(pdev, iomap[i]);
- err_region:
-	pci_release_region(pdev, i);
- err_inval:
-	while (--i >= 0) {
-		pcim_iounmap(pdev, iomap[i]);
-		pci_release_region(pdev, i);
-	}
-
-	return rc;
-}
-EXPORT_SYMBOL(pcim_iomap_regions);

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

* Re: [PATCH] iomap: make PCI iomap stuff excluded when PCI isn't configured
  2007-02-10 17:43 ` [PATCH] iomap: make PCI iomap stuff excluded when PCI isn't configured Tejun Heo
@ 2007-02-10 19:46   ` Heiko Carstens
  2007-02-10 22:14     ` Tejun Heo
  2007-02-11  2:41   ` Randy Dunlap
  1 sibling, 1 reply; 13+ messages in thread
From: Heiko Carstens @ 2007-02-10 19:46 UTC (permalink / raw)
  To: Tejun Heo
  Cc: Andrew Morton, Linus Torvalds, Martin Schwidefsky, Jeff Garzik,
	linux-kernel, linux-s390

On Sat, Feb 10, 2007 at 12:43:16PM -0500, Tejun Heo wrote:
> devres iomap made lib/iomap.c always built and added several
> arch-indep PCI routines to include/linux/io.h and lib/iomap.c without
> wrapping them inside CONFIG_PCI.  This breaks configurations where PCI
> is not configured.  Wrap pci_iomap() in CONFIG_PCI and move managed
> PCI iomap functions into include/linux/pci.h and drivers/pci/pci.c.
> 
> Signed-off-by: Tejun Heo <htejun@gmail.com>
> Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
> ---
> Heiko, how about this?  Does it fix s390?

Unfortunately not. Now I get

  CC      lib/iomap.o
lib/iomap.c: In function 'devm_ioport_map_release':
lib/iomap.c:270: warning: implicit declaration of function 'ioport_unmap'
lib/iomap.c: In function 'devm_ioport_map':
lib/iomap.c:297: warning: implicit declaration of function 'ioport_map'
lib/iomap.c:297: warning: assignment makes pointer from integer without a cast

and

lib/built-in.o: In function `devm_ioport_unmap': undefined reference to `ioport_unmap'
lib/built-in.o: In function `devm_ioport_map_release':iomap.c:(.text+0xf20): undefined reference to `ioport_unmap'
lib/built-in.o: In function `devm_ioport_map': undefined reference to `ioport_map'
drivers/built-in.o: In function `dmam_noncoherent_release':dma-mapping.c:(.text+0x15238): undefined reference to `dma_free_noncoherent'
drivers/built-in.o: In function `dmam_free_noncoherent': undefined reference to `dma_free_noncoherent'
drivers/built-in.o: In function `dmam_alloc_noncoherent': undefined reference to `dma_alloc_noncoherent'
make: *** [.tmp_vmlinux1] Error 1

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

* Re: [PATCH] iomap: make PCI iomap stuff excluded when PCI isn't configured
  2007-02-10 19:46   ` Heiko Carstens
@ 2007-02-10 22:14     ` Tejun Heo
  2007-02-10 22:25       ` Linus Torvalds
                         ` (2 more replies)
  0 siblings, 3 replies; 13+ messages in thread
From: Tejun Heo @ 2007-02-10 22:14 UTC (permalink / raw)
  To: Heiko Carstens
  Cc: Andrew Morton, Linus Torvalds, Martin Schwidefsky, Jeff Garzik,
	linux-kernel, linux-s390

Heiko Carstens wrote:
> On Sat, Feb 10, 2007 at 12:43:16PM -0500, Tejun Heo wrote:
\>> Heiko, how about this?  Does it fix s390?
> 
> Unfortunately not. Now I get
> 
>   CC      lib/iomap.o
> lib/iomap.c: In function 'devm_ioport_map_release':
> lib/iomap.c:270: warning: implicit declaration of function 'ioport_unmap'
> lib/iomap.c: In function 'devm_ioport_map':
> lib/iomap.c:297: warning: implicit declaration of function 'ioport_map'
> lib/iomap.c:297: warning: assignment makes pointer from integer without a cast

I think an arch needs to support ioport_map/unmap and noncoherent dma 
(just alias to coherent interface on x86/amd64) interface whether PCI is 
implemented or not.  No?

-- 
tejun

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

* Re: [PATCH] iomap: make PCI iomap stuff excluded when PCI isn't configured
  2007-02-10 22:14     ` Tejun Heo
@ 2007-02-10 22:25       ` Linus Torvalds
  2007-02-10 22:50         ` Al Viro
  2007-02-11  0:15       ` Heiko Carstens
  2007-02-11  5:20       ` Al Viro
  2 siblings, 1 reply; 13+ messages in thread
From: Linus Torvalds @ 2007-02-10 22:25 UTC (permalink / raw)
  To: Tejun Heo
  Cc: Heiko Carstens, Andrew Morton, Martin Schwidefsky, Jeff Garzik,
	linux-kernel, linux-s390



On Sat, 10 Feb 2007, Tejun Heo wrote:
> 
> I think an arch needs to support ioport_map/unmap and noncoherent dma (just
> alias to coherent interface on x86/amd64) interface whether PCI is implemented
> or not.  No?

We haven't required ioport implementations in the past, afaik.

		Linus

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

* Re: [PATCH] iomap: make PCI iomap stuff excluded when PCI isn't configured
  2007-02-10 22:25       ` Linus Torvalds
@ 2007-02-10 22:50         ` Al Viro
  2007-02-10 23:55           ` Al Viro
  0 siblings, 1 reply; 13+ messages in thread
From: Al Viro @ 2007-02-10 22:50 UTC (permalink / raw)
  To: Linus Torvalds
  Cc: Tejun Heo, Heiko Carstens, Andrew Morton, Martin Schwidefsky,
	Jeff Garzik, linux-kernel, linux-s390

On Sat, Feb 10, 2007 at 02:25:53PM -0800, Linus Torvalds wrote:
> 
> 
> On Sat, 10 Feb 2007, Tejun Heo wrote:
> > 
> > I think an arch needs to support ioport_map/unmap and noncoherent dma (just
> > alias to coherent interface on x86/amd64) interface whether PCI is implemented
> > or not.  No?
> 
> We haven't required ioport implementations in the past, afaik.

We don't even require ioremap().  What the hell could it possibly mean on
e.g. UML?  The same goes for DMA.  And yes, of course it means that a lot
of drivers are not buildable on it - hardly a surprise, that...

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

* Re: [PATCH] iomap: make PCI iomap stuff excluded when PCI isn't configured
  2007-02-10 22:50         ` Al Viro
@ 2007-02-10 23:55           ` Al Viro
  2007-02-11 16:45             ` Martin Schwidefsky
  0 siblings, 1 reply; 13+ messages in thread
From: Al Viro @ 2007-02-10 23:55 UTC (permalink / raw)
  To: Linus Torvalds
  Cc: Tejun Heo, Heiko Carstens, Andrew Morton, Martin Schwidefsky,
	Jeff Garzik, linux-kernel, linux-s390

On Sat, Feb 10, 2007 at 10:50:33PM +0000, Al Viro wrote:
> We don't even require ioremap().  What the hell could it possibly mean on
> e.g. UML?  The same goes for DMA.  And yes, of course it means that a lot
> of drivers are not buildable on it - hardly a surprise, that...

FWIW, the current picture wrt io-related stuff looks so:

alpha frv i386 ia64 mips parisc powerpc sparc64 x86_64: full set
s390: no ioport_map, no ioread*/iowrite*, no port IO except for (in|out)b(_p|)
sparc: insl() and friends are not there unless we have PCI, ioremap() is
not exported unless on PCI.
um: odd stubs for inb()/outb(), no other port IO; no ioremap(), no
memcpy_..io(), for some reason read[bwlq]()/write[bwlq]() are there,
but never used.  No ioread*/iowrite*.
arm: depends on subarchitecture.  E.g. 32bit port access might be a sham
(causes fun problems with e.g. modular ide-core on some subarchitectures -
it doesn't _use_ insl(), but the reference is there no matter what, so the
lack of export => missing symbol).
m68k: as if.  No ioread/iowrite, ioremap() only for hp300, availability of
any IO accessor depends on config in rather weird ways.
m32r: no ioread/iowrite/ioport_map
the rest of embedded stuff: no idea, never played with those targets.

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

* Re: [PATCH] iomap: make PCI iomap stuff excluded when PCI isn't configured
  2007-02-10 22:14     ` Tejun Heo
  2007-02-10 22:25       ` Linus Torvalds
@ 2007-02-11  0:15       ` Heiko Carstens
  2007-02-11  5:20       ` Al Viro
  2 siblings, 0 replies; 13+ messages in thread
From: Heiko Carstens @ 2007-02-11  0:15 UTC (permalink / raw)
  To: Tejun Heo
  Cc: Andrew Morton, Linus Torvalds, Martin Schwidefsky, Jeff Garzik,
	linux-kernel, linux-s390

On Sat, Feb 10, 2007 at 05:14:13PM -0500, Tejun Heo wrote:
> Heiko Carstens wrote:
> >On Sat, Feb 10, 2007 at 12:43:16PM -0500, Tejun Heo wrote:
> \>> Heiko, how about this?  Does it fix s390?
> >Unfortunately not. Now I get
> >  CC      lib/iomap.o
> >lib/iomap.c: In function 'devm_ioport_map_release':
> >lib/iomap.c:270: warning: implicit declaration of function 'ioport_unmap'
> >lib/iomap.c: In function 'devm_ioport_map':
> >lib/iomap.c:297: warning: implicit declaration of function 'ioport_map'
> >lib/iomap.c:297: warning: assignment makes pointer from integer without a cast
> 
> I think an arch needs to support ioport_map/unmap and noncoherent dma
> (just alias to coherent interface on x86/amd64) interface whether PCI is
> implemented or not.  No?

I sent a patch earlier which "fixes" at least the dma stuff by adding some
more defines to asm-generic/dma-mapping-broken.h
The patch below (on top of your latest one) makes sure s390 builds at
least again until all this got sorted out.
---

Hack to make s390 build again.

Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
---
 include/asm-s390/io.h |   14 ++++++++++++++
 1 file changed, 14 insertions(+)

Index: linux-2.6/include/asm-s390/io.h
===================================================================
--- linux-2.6.orig/include/asm-s390/io.h
+++ linux-2.6/include/asm-s390/io.h
@@ -61,6 +61,20 @@ static inline void * ioremap_nocache (un
 extern void iounmap(void *addr);
 
 /*
+ * FIXME: remove ioport stuff asap again.
+ */
+static inline void __iomem *ioport_map(unsigned long port, unsigned int size)
+{
+	BUG();
+	return NULL;
+}
+
+static inline void ioport_unmap(void __iomem *addr)
+{
+	BUG();
+}
+
+/*
  * IO bus memory addresses are also 1:1 with the physical address
  */
 #define virt_to_bus virt_to_phys

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

* Re: [PATCH] iomap: make PCI iomap stuff excluded when PCI isn't configured
  2007-02-10 17:43 ` [PATCH] iomap: make PCI iomap stuff excluded when PCI isn't configured Tejun Heo
  2007-02-10 19:46   ` Heiko Carstens
@ 2007-02-11  2:41   ` Randy Dunlap
  1 sibling, 0 replies; 13+ messages in thread
From: Randy Dunlap @ 2007-02-11  2:41 UTC (permalink / raw)
  To: Tejun Heo
  Cc: Heiko Carstens, Andrew Morton, Linus Torvalds,
	Martin Schwidefsky, Jeff Garzik, linux-kernel, linux-s390

On Sat, 10 Feb 2007 12:43:16 -0500 Tejun Heo wrote:

> devres iomap made lib/iomap.c always built and added several
> arch-indep PCI routines to include/linux/io.h and lib/iomap.c without
> wrapping them inside CONFIG_PCI.  This breaks configurations where PCI
> is not configured.  Wrap pci_iomap() in CONFIG_PCI and move managed
> PCI iomap functions into include/linux/pci.h and drivers/pci/pci.c.
> 
> Signed-off-by: Tejun Heo <htejun@gmail.com>
> Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
> ---
> Heiko, how about this?  Does it fix s390?

At least it fixes allnoconfig on x86_64, which was also broken
by this.  <see sig :>


> diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
> index 8b44cff..d6ec47a 100644
> --- a/drivers/pci/pci.c
> +++ b/drivers/pci/pci.c
> @@ -1314,6 +1314,158 @@ int pci_select_bars(struct pci_dev *dev, unsigned long flags)
>  	return bars;
>  }
>  
> +/*
> + * PCI iomap devres
> + */
> +#define PCIM_IOMAP_MAX	PCI_ROM_RESOURCE
> +
> +struct pcim_iomap_devres {
> +	void __iomem *table[PCIM_IOMAP_MAX];
> +};
> +
> +static void pcim_iomap_release(struct device *gendev, void *res)
> +{
> +	struct pci_dev *dev = container_of(gendev, struct pci_dev, dev);
> +	struct pcim_iomap_devres *this = res;
> +	int i;
> +
> +	for (i = 0; i < PCIM_IOMAP_MAX; i++)
> +		if (this->table[i])
> +			pci_iounmap(dev, this->table[i]);
> +}
> +
> +/**
> + * pcim_iomap_table - access iomap allocation table
> + * @pdev: PCI device to access iomap table for
> + *
> + * Access iomap allocation table for @dev.  If iomap table doesn't
> + * exist and @pdev is managed, it will be allocated.  All iomaps
> + * recorded in the iomap table are automatically unmapped on driver
> + * detach.
> + *
> + * This function might sleep when the table is first allocated but can
> + * be safely called without context and guaranteed to succed once
> + * allocated.
> + */
> +void __iomem * const * pcim_iomap_table(struct pci_dev *pdev)
> +{
> +	struct pcim_iomap_devres *dr, *new_dr;
> +
> +	dr = devres_find(&pdev->dev, pcim_iomap_release, NULL, NULL);
> +	if (dr)
> +		return dr->table;
> +
> +	new_dr = devres_alloc(pcim_iomap_release, sizeof(*new_dr), GFP_KERNEL);
> +	if (!new_dr)
> +		return NULL;
> +	dr = devres_get(&pdev->dev, new_dr, NULL, NULL);
> +	return dr->table;
> +}
> +EXPORT_SYMBOL(pcim_iomap_table);
> +
> +/**
> + * pcim_iomap - Managed pcim_iomap()
> + * @pdev: PCI device to iomap for
> + * @bar: BAR to iomap
> + * @maxlen: Maximum length of iomap
> + *
> + * Managed pci_iomap().  Map is automatically unmapped on driver
> + * detach.
> + */
> +void __iomem * pcim_iomap(struct pci_dev *pdev, int bar, unsigned long maxlen)
> +{
> +	void __iomem **tbl;
> +
> +	BUG_ON(bar >= PCIM_IOMAP_MAX);
> +
> +	tbl = (void __iomem **)pcim_iomap_table(pdev);
> +	if (!tbl || tbl[bar])	/* duplicate mappings not allowed */
> +		return NULL;
> +
> +	tbl[bar] = pci_iomap(pdev, bar, maxlen);
> +	return tbl[bar];
> +}
> +EXPORT_SYMBOL(pcim_iomap);
> +
> +/**
> + * pcim_iounmap - Managed pci_iounmap()
> + * @pdev: PCI device to iounmap for
> + * @addr: Address to unmap
> + *
> + * Managed pci_iounmap().  @addr must have been mapped using pcim_iomap().
> + */
> +void pcim_iounmap(struct pci_dev *pdev, void __iomem *addr)
> +{
> +	void __iomem **tbl;
> +	int i;
> +
> +	pci_iounmap(pdev, addr);
> +
> +	tbl = (void __iomem **)pcim_iomap_table(pdev);
> +	BUG_ON(!tbl);
> +
> +	for (i = 0; i < PCIM_IOMAP_MAX; i++)
> +		if (tbl[i] == addr) {
> +			tbl[i] = NULL;
> +			return;
> +		}
> +	WARN_ON(1);
> +}
> +EXPORT_SYMBOL(pcim_iounmap);
> +
> +/**
> + * pcim_iomap_regions - Request and iomap PCI BARs
> + * @pdev: PCI device to map IO resources for
> + * @mask: Mask of BARs to request and iomap
> + * @name: Name used when requesting regions
> + *
> + * Request and iomap regions specified by @mask.
> + */
> +int pcim_iomap_regions(struct pci_dev *pdev, u16 mask, const char *name)
> +{
> +	void __iomem * const *iomap;
> +	int i, rc;
> +
> +	iomap = pcim_iomap_table(pdev);
> +	if (!iomap)
> +		return -ENOMEM;
> +
> +	for (i = 0; i < DEVICE_COUNT_RESOURCE; i++) {
> +		unsigned long len;
> +
> +		if (!(mask & (1 << i)))
> +			continue;
> +
> +		rc = -EINVAL;
> +		len = pci_resource_len(pdev, i);
> +		if (!len)
> +			goto err_inval;
> +
> +		rc = pci_request_region(pdev, i, name);
> +		if (rc)
> +			goto err_region;
> +
> +		rc = -ENOMEM;
> +		if (!pcim_iomap(pdev, i, 0))
> +			goto err_iomap;
> +	}
> +
> +	return 0;
> +
> + err_iomap:
> +	pcim_iounmap(pdev, iomap[i]);
> + err_region:
> +	pci_release_region(pdev, i);
> + err_inval:
> +	while (--i >= 0) {
> +		pcim_iounmap(pdev, iomap[i]);
> +		pci_release_region(pdev, i);
> +	}
> +
> +	return rc;
> +}
> +EXPORT_SYMBOL(pcim_iomap_regions);
> +
>  static int __devinit pci_init(void)
>  {
>  	struct pci_dev *dev = NULL;
> diff --git a/include/linux/io.h b/include/linux/io.h
> index 9e419eb..c244a0c 100644
> --- a/include/linux/io.h
> +++ b/include/linux/io.h
> @@ -43,12 +43,6 @@ void __iomem * devm_ioremap_nocache(struct device *dev, unsigned long offset,
>  				    unsigned long size);
>  void devm_iounmap(struct device *dev, void __iomem *addr);
>  
> -void __iomem * pcim_iomap(struct pci_dev *pdev, int bar, unsigned long maxlen);
> -void pcim_iounmap(struct pci_dev *pdev, void __iomem *addr);
> -void __iomem * const * pcim_iomap_table(struct pci_dev *pdev);
> -
> -int pcim_iomap_regions(struct pci_dev *pdev, u16 mask, const char *name);
> -
>  /**
>   *	check_signature		-	find BIOS signatures
>   *	@io_addr: mmio address to check
> diff --git a/include/linux/pci.h b/include/linux/pci.h
> index 9e3042e..c8f4b84 100644
> --- a/include/linux/pci.h
> +++ b/include/linux/pci.h
> @@ -611,6 +611,12 @@ void pci_walk_bus(struct pci_bus *top, void (*cb)(struct pci_dev *, void *),
>  int pci_cfg_space_size(struct pci_dev *dev);
>  unsigned char pci_bus_max_busnr(struct pci_bus* bus);
>  
> +/* PCI managed iomap interface */
> +void __iomem * pcim_iomap(struct pci_dev *pdev, int bar, unsigned long maxlen);
> +void pcim_iounmap(struct pci_dev *pdev, void __iomem *addr);
> +void __iomem * const * pcim_iomap_table(struct pci_dev *pdev);
> +int pcim_iomap_regions(struct pci_dev *pdev, u16 mask, const char *name);
> +
>  /* kmem_cache style wrapper around pci_alloc_consistent() */
>  
>  #include <linux/dmapool.h>
> diff --git a/lib/iomap.c b/lib/iomap.c
> index 4990c73..bdf31ba 100644
> --- a/lib/iomap.c
> +++ b/lib/iomap.c
> @@ -228,6 +228,8 @@ void ioport_unmap(void __iomem *addr)
>  EXPORT_SYMBOL(ioport_map);
>  EXPORT_SYMBOL(ioport_unmap);
>  
> +#ifdef CONFIG_PCI
> +
>  /* Create a virtual mapping cookie for a PCI BAR (memory or IO) */
>  void __iomem *pci_iomap(struct pci_dev *dev, int bar, unsigned long maxlen)
>  {
> @@ -257,6 +259,7 @@ void pci_iounmap(struct pci_dev *dev, void __iomem * addr)
>  EXPORT_SYMBOL(pci_iomap);
>  EXPORT_SYMBOL(pci_iounmap);
>  
> +#endif /* CONFIG_PCI */
>  #endif /* CONFIG_GENERIC_IOMAP */
>  
>  /*
> @@ -399,155 +402,3 @@ void devm_iounmap(struct device *dev, void __iomem *addr)
>  			       (void *)addr));
>  }
>  EXPORT_SYMBOL(devm_iounmap);
> -
> -/*
> - * PCI iomap devres
> - */
> -#define PCIM_IOMAP_MAX	PCI_ROM_RESOURCE
> -
> -struct pcim_iomap_devres {
> -	void __iomem *table[PCIM_IOMAP_MAX];
> -};
> -
> -static void pcim_iomap_release(struct device *gendev, void *res)
> -{
> -	struct pci_dev *dev = container_of(gendev, struct pci_dev, dev);
> -	struct pcim_iomap_devres *this = res;
> -	int i;
> -
> -	for (i = 0; i < PCIM_IOMAP_MAX; i++)
> -		if (this->table[i])
> -			pci_iounmap(dev, this->table[i]);
> -}
> -
> -/**
> - * pcim_iomap_table - access iomap allocation table
> - * @pdev: PCI device to access iomap table for
> - *
> - * Access iomap allocation table for @dev.  If iomap table doesn't
> - * exist and @pdev is managed, it will be allocated.  All iomaps
> - * recorded in the iomap table are automatically unmapped on driver
> - * detach.
> - *
> - * This function might sleep when the table is first allocated but can
> - * be safely called without context and guaranteed to succed once
> - * allocated.
> - */
> -void __iomem * const * pcim_iomap_table(struct pci_dev *pdev)
> -{
> -	struct pcim_iomap_devres *dr, *new_dr;
> -
> -	dr = devres_find(&pdev->dev, pcim_iomap_release, NULL, NULL);
> -	if (dr)
> -		return dr->table;
> -
> -	new_dr = devres_alloc(pcim_iomap_release, sizeof(*new_dr), GFP_KERNEL);
> -	if (!new_dr)
> -		return NULL;
> -	dr = devres_get(&pdev->dev, new_dr, NULL, NULL);
> -	return dr->table;
> -}
> -EXPORT_SYMBOL(pcim_iomap_table);
> -
> -/**
> - * pcim_iomap - Managed pcim_iomap()
> - * @pdev: PCI device to iomap for
> - * @bar: BAR to iomap
> - * @maxlen: Maximum length of iomap
> - *
> - * Managed pci_iomap().  Map is automatically unmapped on driver
> - * detach.
> - */
> -void __iomem * pcim_iomap(struct pci_dev *pdev, int bar, unsigned long maxlen)
> -{
> -	void __iomem **tbl;
> -
> -	BUG_ON(bar >= PCIM_IOMAP_MAX);
> -
> -	tbl = (void __iomem **)pcim_iomap_table(pdev);
> -	if (!tbl || tbl[bar])	/* duplicate mappings not allowed */
> -		return NULL;
> -
> -	tbl[bar] = pci_iomap(pdev, bar, maxlen);
> -	return tbl[bar];
> -}
> -EXPORT_SYMBOL(pcim_iomap);
> -
> -/**
> - * pcim_iounmap - Managed pci_iounmap()
> - * @pdev: PCI device to iounmap for
> - * @addr: Address to unmap
> - *
> - * Managed pci_iounmap().  @addr must have been mapped using pcim_iomap().
> - */
> -void pcim_iounmap(struct pci_dev *pdev, void __iomem *addr)
> -{
> -	void __iomem **tbl;
> -	int i;
> -
> -	pci_iounmap(pdev, addr);
> -
> -	tbl = (void __iomem **)pcim_iomap_table(pdev);
> -	BUG_ON(!tbl);
> -
> -	for (i = 0; i < PCIM_IOMAP_MAX; i++)
> -		if (tbl[i] == addr) {
> -			tbl[i] = NULL;
> -			return;
> -		}
> -	WARN_ON(1);
> -}
> -EXPORT_SYMBOL(pcim_iounmap);
> -
> -/**
> - * pcim_iomap_regions - Request and iomap PCI BARs
> - * @pdev: PCI device to map IO resources for
> - * @mask: Mask of BARs to request and iomap
> - * @name: Name used when requesting regions
> - *
> - * Request and iomap regions specified by @mask.
> - */
> -int pcim_iomap_regions(struct pci_dev *pdev, u16 mask, const char *name)
> -{
> -	void __iomem * const *iomap;
> -	int i, rc;
> -
> -	iomap = pcim_iomap_table(pdev);
> -	if (!iomap)
> -		return -ENOMEM;
> -
> -	for (i = 0; i < DEVICE_COUNT_RESOURCE; i++) {
> -		unsigned long len;
> -
> -		if (!(mask & (1 << i)))
> -			continue;
> -
> -		rc = -EINVAL;
> -		len = pci_resource_len(pdev, i);
> -		if (!len)
> -			goto err_inval;
> -
> -		rc = pci_request_region(pdev, i, name);
> -		if (rc)
> -			goto err_region;
> -
> -		rc = -ENOMEM;
> -		if (!pcim_iomap(pdev, i, 0))
> -			goto err_iomap;
> -	}
> -
> -	return 0;
> -
> - err_iomap:
> -	pcim_iounmap(pdev, iomap[i]);
> - err_region:
> -	pci_release_region(pdev, i);
> - err_inval:
> -	while (--i >= 0) {
> -		pcim_iounmap(pdev, iomap[i]);
> -		pci_release_region(pdev, i);
> -	}
> -
> -	return rc;
> -}
> -EXPORT_SYMBOL(pcim_iomap_regions);
> -

---
~Randy
*** Remember to use Documentation/SubmitChecklist when testing your code ***

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

* Re: [PATCH] iomap: make PCI iomap stuff excluded when PCI isn't configured
  2007-02-10 22:14     ` Tejun Heo
  2007-02-10 22:25       ` Linus Torvalds
  2007-02-11  0:15       ` Heiko Carstens
@ 2007-02-11  5:20       ` Al Viro
  2 siblings, 0 replies; 13+ messages in thread
From: Al Viro @ 2007-02-11  5:20 UTC (permalink / raw)
  To: Tejun Heo
  Cc: Heiko Carstens, Andrew Morton, Linus Torvalds,
	Martin Schwidefsky, Jeff Garzik, linux-kernel, linux-s390

On Sat, Feb 10, 2007 at 05:14:13PM -0500, Tejun Heo wrote:
> Heiko Carstens wrote:
> >On Sat, Feb 10, 2007 at 12:43:16PM -0500, Tejun Heo wrote:
> \>> Heiko, how about this?  Does it fix s390?
> >
> >Unfortunately not. Now I get
> >
> >  CC      lib/iomap.o
> >lib/iomap.c: In function 'devm_ioport_map_release':
> >lib/iomap.c:270: warning: implicit declaration of function 'ioport_unmap'
> >lib/iomap.c: In function 'devm_ioport_map':
> >lib/iomap.c:297: warning: implicit declaration of function 'ioport_map'
> >lib/iomap.c:297: warning: assignment makes pointer from integer without a 
> >cast
> 
> I think an arch needs to support ioport_map/unmap and noncoherent dma 
> (just alias to coherent interface on x86/amd64) interface whether PCI is 
> implemented or not.  No?

Another source of breakage: you get devm_request_irq() only if you have
GENERIC_HARDIRQS.  Otherwise kernel/irq/ is simply not built.  Again,
you are mixing default implementation of primitives with the
implementation-agnostic stuff around those primitives.  I'd split
kernel/irq/manage.c in two files and have the places providing
alternative implementations (e.g. arch/sparc/kernel) refer to new
file in their makefiles...

I'm mostly done with that stuff, modulo noncoherent_dma breakage.  Will
send patch once the irq crap is dealt with...

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

* Re: [patch] More defines for dma-mapping-broken.h
  2007-02-10 11:43 [patch] More defines for dma-mapping-broken.h Heiko Carstens
  2007-02-10 17:43 ` [PATCH] iomap: make PCI iomap stuff excluded when PCI isn't configured Tejun Heo
@ 2007-02-11 15:49 ` Jeff Garzik
  1 sibling, 0 replies; 13+ messages in thread
From: Jeff Garzik @ 2007-02-11 15:49 UTC (permalink / raw)
  To: Heiko Carstens
  Cc: Andrew Morton, Linus Torvalds, Martin Schwidefsky, Tejun Heo,
	linux-kernel, linux-s390

Heiko Carstens wrote:
> From: Heiko Carstens <heiko.carstens@de.ibm.com>
> 
> 9ac7849e35f705830f7b016ff272b0ff1f7ff759 causes this on s390.
> Since we don't support DMA extend dma-mapping-broken.h a bit.
> 
> drivers/base/dma-mapping.c: In function `dmam_noncoherent_release':
> drivers/base/dma-mapping.c:32:
> 	warning: implicit declaration of function `dma_free_noncoherent'
> drivers/base/dma-mapping.c: In function `dmam_alloc_noncoherent':
> drivers/base/dma-mapping.c:129:
> 	warning: implicit declaration of function `dma_alloc_noncoherent'
> drivers/base/dma-mapping.c:129:
> 	warning: assignment makes pointer from integer without a cast
> 
> Cc: Tejun Heo <htejun@gmail.com>
> Cc: Jeff Garzik <jeff@garzik.org>
> Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
> Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
> ---
>  include/asm-generic/dma-mapping-broken.h |    4 +++-
>  1 files changed, 3 insertions(+), 1 deletion(-)

ACK



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

* Re: [PATCH] iomap: make PCI iomap stuff excluded when PCI isn't configured
  2007-02-10 23:55           ` Al Viro
@ 2007-02-11 16:45             ` Martin Schwidefsky
  2007-02-11 18:15               ` Al Viro
  0 siblings, 1 reply; 13+ messages in thread
From: Martin Schwidefsky @ 2007-02-11 16:45 UTC (permalink / raw)
  To: Al Viro
  Cc: Linus Torvalds, Tejun Heo, Heiko Carstens, Andrew Morton,
	Jeff Garzik, linux-kernel, linux-s390

On Sat, 2007-02-10 at 23:55 +0000, Al Viro wrote: 
> FWIW, the current picture wrt io-related stuff looks so:
> 
> s390: no ioport_map, no ioread*/iowrite*, no port IO except for (in|out)b(_p|)

s390 does not even need (in|out)b(_p|). I wondered what else from io.h
do we not need. The answer is: almost nothing. With the devres patch
from Al and the dma-mapping patch from Heiko we can get rid of iomem and
all associated definitions.

-- 
blue skies,
  Martin.

Martin Schwidefsky
Linux for zSeries Development & Services
IBM Deutschland Entwicklung GmbH

"Reality continues to ruin my life." - Calvin.

--
From: Martin Schwidefsky <schwidefsky@de.ibm.com>

[S390] cleanup io.h

Remove code to access I/O memory. There is no such thing on s390.

Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
---
 arch/s390/Kconfig      |    3 ++
 arch/s390/mm/Makefile  |    2 -
 arch/s390/mm/ioremap.c |   58 --------------------------------------------
 include/asm-s390/io.h  |   64 -------------------------------------------------
 4 files changed, 5 insertions(+), 122 deletions(-)

diff -urpN linux-2.6/arch/s390/Kconfig linux-2.6-patched/arch/s390/Kconfig
--- linux-2.6/arch/s390/Kconfig	2007-02-11 17:24:37.000000000 +0100
+++ linux-2.6-patched/arch/s390/Kconfig	2007-02-11 17:25:30.000000000 +0100
@@ -40,6 +40,9 @@ config GENERIC_TIME
 config NO_IOPORT
 	def_bool y
 
+config NO_IOMEM
+	def_bool y
+
 mainmenu "Linux Kernel Configuration"
 
 config S390
diff -urpN linux-2.6/arch/s390/mm/ioremap.c linux-2.6-patched/arch/s390/mm/ioremap.c
--- linux-2.6/arch/s390/mm/ioremap.c	2006-12-09 21:08:18.000000000 +0100
+++ linux-2.6-patched/arch/s390/mm/ioremap.c	1970-01-01 01:00:00.000000000 +0100
@@ -1,58 +0,0 @@
-/*
- *  arch/s390/mm/ioremap.c
- *
- *  S390 version
- *    Copyright (C) 1999 IBM Deutschland Entwicklung GmbH, IBM Corporation
- *    Author(s): Hartmut Penner (hp@de.ibm.com)
- *
- *  Derived from "arch/i386/mm/extable.c"
- *    (C) Copyright 1995 1996 Linus Torvalds
- *
- * Re-map IO memory to kernel address space so that we can access it.
- * This is needed for high PCI addresses that aren't mapped in the
- * 640k-1MB IO memory area on PC's
- */
-
-#include <linux/vmalloc.h>
-#include <linux/mm.h>
-#include <linux/io.h>
-#include <asm/pgalloc.h>
-
-/*
- * Generic mapping function (not visible outside):
- */
-
-/*
- * Remap an arbitrary physical address space into the kernel virtual
- * address space. Needed when the kernel wants to access high addresses
- * directly.
- */
-void * __ioremap(unsigned long phys_addr, unsigned long size, unsigned long flags)
-{
-	void * addr;
-	struct vm_struct * area;
-
-	if (phys_addr < virt_to_phys(high_memory))
-		return phys_to_virt(phys_addr);
-	if (phys_addr & ~PAGE_MASK)
-		return NULL;
-	size = PAGE_ALIGN(size);
-	if (!size || size > phys_addr + size)
-		return NULL;
-	area = get_vm_area(size, VM_IOREMAP);
-	if (!area)
-		return NULL;
-	addr = area->addr;
-	if (ioremap_page_range((unsigned long)addr, (unsigned long)addr + size,
-			       phys_addr, __pgprot(flags))) {
-		vfree(addr);
-		return NULL;
-	}
-	return addr;
-}
-
-void iounmap(void *addr)
-{
-	if (addr > high_memory)
-		vfree(addr);
-}
diff -urpN linux-2.6/arch/s390/mm/Makefile linux-2.6-patched/arch/s390/mm/Makefile
--- linux-2.6/arch/s390/mm/Makefile	2006-12-09 21:08:18.000000000 +0100
+++ linux-2.6-patched/arch/s390/mm/Makefile	2007-02-11 17:23:02.000000000 +0100
@@ -2,6 +2,6 @@
 # Makefile for the linux s390-specific parts of the memory manager.
 #
 
-obj-y	 := init.o fault.o ioremap.o extmem.o mmap.o vmem.o
+obj-y	 := init.o fault.o extmem.o mmap.o vmem.o
 obj-$(CONFIG_CMM) += cmm.o
 
diff -urpN linux-2.6/include/asm-s390/io.h linux-2.6-patched/include/asm-s390/io.h
--- linux-2.6/include/asm-s390/io.h	2007-02-07 15:42:46.000000000 +0100
+++ linux-2.6-patched/include/asm-s390/io.h	2007-02-11 17:19:32.000000000 +0100
@@ -18,8 +18,6 @@
 
 #define IO_SPACE_LIMIT 0xffffffff
 
-#define __io_virt(x)            ((void *)(PAGE_OFFSET | (unsigned long)(x)))
-
 /*
  * Change virtual addresses to physical addresses and vv.
  * These are pretty trivial
@@ -38,28 +36,9 @@ static inline unsigned long virt_to_phys
 
 static inline void * phys_to_virt(unsigned long address)
 {
-        return __io_virt(address);
-}
-
-extern void * __ioremap(unsigned long offset, unsigned long size, unsigned long flags);
-
-static inline void * ioremap (unsigned long offset, unsigned long size)
-{
-        return __ioremap(offset, size, 0);
-}
-
-/*
- * This one maps high address device memory and turns off caching for that area.
- * it's useful if some control registers are in such an area and write combining
- * or read caching is not desirable:
- */
-static inline void * ioremap_nocache (unsigned long offset, unsigned long size)
-{
-        return __ioremap(offset, size, 0);
+        return (void *) address;
 }
 
-extern void iounmap(void *addr);
-
 /*
  * IO bus memory addresses are also 1:1 with the physical address
  */
@@ -67,47 +46,6 @@ extern void iounmap(void *addr);
 #define bus_to_virt phys_to_virt
 
 /*
- * readX/writeX() are used to access memory mapped devices. On some
- * architectures the memory mapped IO stuff needs to be accessed
- * differently.
- */
-
-#define readb(addr) (*(volatile unsigned char *) __io_virt(addr))
-#define readw(addr) (*(volatile unsigned short *) __io_virt(addr))
-#define readl(addr) (*(volatile unsigned int *) __io_virt(addr))
-#define readq(addr) (*(volatile unsigned long long *) __io_virt(addr))
-
-#define readb_relaxed(addr) readb(addr)
-#define readw_relaxed(addr) readw(addr)
-#define readl_relaxed(addr) readl(addr)
-#define readq_relaxed(addr) readq(addr)
-#define __raw_readb readb
-#define __raw_readw readw
-#define __raw_readl readl
-#define __raw_readq readq
-
-#define writeb(b,addr) (*(volatile unsigned char *) __io_virt(addr) = (b))
-#define writew(b,addr) (*(volatile unsigned short *) __io_virt(addr) = (b))
-#define writel(b,addr) (*(volatile unsigned int *) __io_virt(addr) = (b))
-#define writeq(b,addr) (*(volatile unsigned long long *) __io_virt(addr) = (b))
-#define __raw_writeb writeb
-#define __raw_writew writew
-#define __raw_writel writel
-#define __raw_writeq writeq
-
-#define memset_io(a,b,c)        memset(__io_virt(a),(b),(c))
-#define memcpy_fromio(a,b,c)    memcpy((a),__io_virt(b),(c))
-#define memcpy_toio(a,b,c)      memcpy(__io_virt(a),(b),(c))
-
-#define inb_p(addr) readb(addr)
-#define inb(addr) readb(addr)
-
-#define outb(x,addr) ((void) writeb(x,addr))
-#define outb_p(x,addr) outb(x,addr)
-
-#define mmiowb()	do { } while (0)
-
-/*
  * Convert a physical pointer to a virtual kernel pointer for /dev/mem
  * access
  */



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

* Re: [PATCH] iomap: make PCI iomap stuff excluded when PCI isn't configured
  2007-02-11 16:45             ` Martin Schwidefsky
@ 2007-02-11 18:15               ` Al Viro
  0 siblings, 0 replies; 13+ messages in thread
From: Al Viro @ 2007-02-11 18:15 UTC (permalink / raw)
  To: Martin Schwidefsky
  Cc: Linus Torvalds, Tejun Heo, Heiko Carstens, Andrew Morton,
	Jeff Garzik, linux-kernel, linux-s390

On Sun, Feb 11, 2007 at 05:45:33PM +0100, Martin Schwidefsky wrote:
> On Sat, 2007-02-10 at 23:55 +0000, Al Viro wrote: 
> > FWIW, the current picture wrt io-related stuff looks so:
> > 
> > s390: no ioport_map, no ioread*/iowrite*, no port IO except for (in|out)b(_p|)
> 
> s390 does not even need (in|out)b(_p|). I wondered what else from io.h
> do we not need. The answer is: almost nothing. With the devres patch
> from Al and the dma-mapping patch from Heiko we can get rid of iomem and
> all associated definitions.

Then we'll just need to replace NO_IOPORT with NO_IOMEM in Kconfig and
kill arch/s390/mm/ioremap.c.

BTW, there's an annoying bit of junk in there - IO_SPACE_LIMIT.  We
only need it for /proc/ioports, which AFAICS shouldn't even be there
on s390 (or uml).  OTOH, removing that thing would mean a user-visible
change - we go from "empty file in /proc" to "no such file in /proc"...

Anyway, switch to NO_IOMEM follows (on top of patches mentioned above).

>From cb57d59e45f97f1134c65f77e8dd6423e5ed9a47 Mon Sep 17 00:00:00 2001
From: Al Viro <viro@zeniv.linux.org.uk>
Date: Sun, 11 Feb 2007 13:10:19 -0500
Subject: [PATCH] s390 has no iomem

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
---
 arch/s390/Kconfig      |    2 +-
 arch/s390/mm/Makefile  |    2 +-
 arch/s390/mm/ioremap.c |   58 ------------------------------------------
 include/asm-s390/io.h  |   65 ------------------------------------------------
 4 files changed, 2 insertions(+), 125 deletions(-)
 delete mode 100644 arch/s390/mm/ioremap.c

diff --git a/arch/s390/Kconfig b/arch/s390/Kconfig
index c4366aa..1013808 100644
--- a/arch/s390/Kconfig
+++ b/arch/s390/Kconfig
@@ -37,7 +37,7 @@ config GENERIC_HWEIGHT
 config GENERIC_TIME
 	def_bool y
 
-config NO_IOPORT
+config NO_IOMEM
 	def_bool y
 
 mainmenu "Linux Kernel Configuration"
diff --git a/arch/s390/mm/Makefile b/arch/s390/mm/Makefile
index 8e09db1..f95449b 100644
--- a/arch/s390/mm/Makefile
+++ b/arch/s390/mm/Makefile
@@ -2,6 +2,6 @@
 # Makefile for the linux s390-specific parts of the memory manager.
 #
 
-obj-y	 := init.o fault.o ioremap.o extmem.o mmap.o vmem.o
+obj-y	 := init.o fault.o extmem.o mmap.o vmem.o
 obj-$(CONFIG_CMM) += cmm.o
 
diff --git a/arch/s390/mm/ioremap.c b/arch/s390/mm/ioremap.c
deleted file mode 100644
index 3d2100a..0000000
--- a/arch/s390/mm/ioremap.c
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- *  arch/s390/mm/ioremap.c
- *
- *  S390 version
- *    Copyright (C) 1999 IBM Deutschland Entwicklung GmbH, IBM Corporation
- *    Author(s): Hartmut Penner (hp@de.ibm.com)
- *
- *  Derived from "arch/i386/mm/extable.c"
- *    (C) Copyright 1995 1996 Linus Torvalds
- *
- * Re-map IO memory to kernel address space so that we can access it.
- * This is needed for high PCI addresses that aren't mapped in the
- * 640k-1MB IO memory area on PC's
- */
-
-#include <linux/vmalloc.h>
-#include <linux/mm.h>
-#include <linux/io.h>
-#include <asm/pgalloc.h>
-
-/*
- * Generic mapping function (not visible outside):
- */
-
-/*
- * Remap an arbitrary physical address space into the kernel virtual
- * address space. Needed when the kernel wants to access high addresses
- * directly.
- */
-void * __ioremap(unsigned long phys_addr, unsigned long size, unsigned long flags)
-{
-	void * addr;
-	struct vm_struct * area;
-
-	if (phys_addr < virt_to_phys(high_memory))
-		return phys_to_virt(phys_addr);
-	if (phys_addr & ~PAGE_MASK)
-		return NULL;
-	size = PAGE_ALIGN(size);
-	if (!size || size > phys_addr + size)
-		return NULL;
-	area = get_vm_area(size, VM_IOREMAP);
-	if (!area)
-		return NULL;
-	addr = area->addr;
-	if (ioremap_page_range((unsigned long)addr, (unsigned long)addr + size,
-			       phys_addr, __pgprot(flags))) {
-		vfree(addr);
-		return NULL;
-	}
-	return addr;
-}
-
-void iounmap(void *addr)
-{
-	if (addr > high_memory)
-		vfree(addr);
-}
diff --git a/include/asm-s390/io.h b/include/asm-s390/io.h
index a4c2d55..dca6a6c 100644
--- a/include/asm-s390/io.h
+++ b/include/asm-s390/io.h
@@ -13,7 +13,6 @@
 
 #ifdef __KERNEL__
 
-#include <linux/vmalloc.h>
 #include <asm/page.h>
 
 #define IO_SPACE_LIMIT 0xffffffff
@@ -41,70 +40,6 @@ static inline void * phys_to_virt(unsigned long address)
         return __io_virt(address);
 }
 
-extern void * __ioremap(unsigned long offset, unsigned long size, unsigned long flags);
-
-static inline void * ioremap (unsigned long offset, unsigned long size)
-{
-        return __ioremap(offset, size, 0);
-}
-
-/*
- * This one maps high address device memory and turns off caching for that area.
- * it's useful if some control registers are in such an area and write combining
- * or read caching is not desirable:
- */
-static inline void * ioremap_nocache (unsigned long offset, unsigned long size)
-{
-        return __ioremap(offset, size, 0);
-}
-
-extern void iounmap(void *addr);
-
-/*
- * IO bus memory addresses are also 1:1 with the physical address
- */
-#define virt_to_bus virt_to_phys
-#define bus_to_virt phys_to_virt
-
-/*
- * readX/writeX() are used to access memory mapped devices. On some
- * architectures the memory mapped IO stuff needs to be accessed
- * differently.
- */
-
-#define readb(addr) (*(volatile unsigned char *) __io_virt(addr))
-#define readw(addr) (*(volatile unsigned short *) __io_virt(addr))
-#define readl(addr) (*(volatile unsigned int *) __io_virt(addr))
-#define readq(addr) (*(volatile unsigned long long *) __io_virt(addr))
-
-#define readb_relaxed(addr) readb(addr)
-#define readw_relaxed(addr) readw(addr)
-#define readl_relaxed(addr) readl(addr)
-#define readq_relaxed(addr) readq(addr)
-#define __raw_readb readb
-#define __raw_readw readw
-#define __raw_readl readl
-#define __raw_readq readq
-
-#define writeb(b,addr) (*(volatile unsigned char *) __io_virt(addr) = (b))
-#define writew(b,addr) (*(volatile unsigned short *) __io_virt(addr) = (b))
-#define writel(b,addr) (*(volatile unsigned int *) __io_virt(addr) = (b))
-#define writeq(b,addr) (*(volatile unsigned long long *) __io_virt(addr) = (b))
-#define __raw_writeb writeb
-#define __raw_writew writew
-#define __raw_writel writel
-#define __raw_writeq writeq
-
-#define memset_io(a,b,c)        memset(__io_virt(a),(b),(c))
-#define memcpy_fromio(a,b,c)    memcpy((a),__io_virt(b),(c))
-#define memcpy_toio(a,b,c)      memcpy(__io_virt(a),(b),(c))
-
-#define inb_p(addr) readb(addr)
-#define inb(addr) readb(addr)
-
-#define outb(x,addr) ((void) writeb(x,addr))
-#define outb_p(x,addr) outb(x,addr)
-
 #define mmiowb()	do { } while (0)
 
 /*
-- 
1.5.0-rc2.GIT


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

end of thread, other threads:[~2007-02-11 18:15 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-02-10 11:43 [patch] More defines for dma-mapping-broken.h Heiko Carstens
2007-02-10 17:43 ` [PATCH] iomap: make PCI iomap stuff excluded when PCI isn't configured Tejun Heo
2007-02-10 19:46   ` Heiko Carstens
2007-02-10 22:14     ` Tejun Heo
2007-02-10 22:25       ` Linus Torvalds
2007-02-10 22:50         ` Al Viro
2007-02-10 23:55           ` Al Viro
2007-02-11 16:45             ` Martin Schwidefsky
2007-02-11 18:15               ` Al Viro
2007-02-11  0:15       ` Heiko Carstens
2007-02-11  5:20       ` Al Viro
2007-02-11  2:41   ` Randy Dunlap
2007-02-11 15:49 ` [patch] More defines for dma-mapping-broken.h Jeff Garzik

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.