Skip to contentSkip to conversation

axi: add AXI bus driver

RFC PATCH Superseded Rafał Miłecki 5 participants 13 messages Apr 8, 2011 – Apr 11, 2011 Kbuild

v2 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

RFC PATCH v2 1/1 axi: add AXI bus driver

Cc Michael Büsch <[email protected]>
Cc Larry Finger <[email protected]>
Cc George Kashperko <[email protected]>
Cc Arend van Spriel <[email protected]>
Cc Russell King <[email protected]>
Cc Arnd Bergmann <[email protected]>
Cc linuxdriverproject <[email protected]>

---
This is second try for introducing new bus driver.
V2: Rename to axi
Use DEFINE_PCI_DEVICE_TABLE in bridge Make use of pr_fmt and pr_*
Store core class
Rename bridge to not b43 specific Replace magic 0x1000 with BCMAI_CORE_SIZE Remove some old "ssb" names and defines Move BCMAI_ADDR_BASE def
Add drvdata field
TODO:
- Interrupts
- Reloading driver

---
 drivers/Kconfig                           |    2 +
 drivers/Makefile                          |    1 +
 drivers/axi/Kconfig                       |   30 +++
 drivers/axi/Makefile                      |    5 +
 drivers/axi/axi_pci_bridge.c              |   33 +++
 drivers/axi/axi_private.h                 |   45 ++++
 drivers/axi/core.c                        |   52 ++++
 drivers/axi/driver_chipcommon.c           |   87 +++++++
 drivers/axi/driver_chipcommon_pmu.c       |  134 ++++++++++
 drivers/axi/driver_pci.c                  |  191 ++++++++++++++
 drivers/axi/host_pci.c                    |  177 +++++++++++++
 drivers/axi/main.c                        |  256 +++++++++++++++++++
 drivers/axi/scan.c                        |  393 +++++++++++++++++++++++++++++
 drivers/axi/scan.h                        |   56 ++++
 include/linux/axi/axi.h                   |  221 ++++++++++++++++
 include/linux/axi/axi_driver_chipcommon.h |  308 ++++++++++++++++++++++
 include/linux/axi/axi_driver_pci.h        |   85 +++++++
 include/linux/axi/axi_regs.h              |   34 +++
 include/linux/mod_devicetable.h           |   17 ++
 scripts/mod/file2alias.c                  |   21 ++
 20 files changed, 2148 insertions(+), 0 deletions(-)
 create mode 100644 drivers/axi/Kconfig
 create mode 100644 drivers/axi/Makefile
 create mode 100644 drivers/axi/axi_pci_bridge.c
 create mode 100644 drivers/axi/axi_private.h
 create mode 100644 drivers/axi/core.c
 create mode 100644 drivers/axi/driver_chipcommon.c
 create mode 100644 drivers/axi/driver_chipcommon_pmu.c
 create mode 100644 drivers/axi/driver_pci.c
 create mode 100644 drivers/axi/host_pci.c
 create mode 100644 drivers/axi/main.c
 create mode 100644 drivers/axi/scan.c
 create mode 100644 drivers/axi/scan.h
 create mode 100644 include/linux/axi/axi.h
 create mode 100644 include/linux/axi/axi_driver_chipcommon.h
 create mode 100644 include/linux/axi/axi_driver_pci.h
 create mode 100644 include/linux/axi/axi_regs.h
drivers/Kconfig +2 -0
index 177c7d1..1244e8c 100644
@@ -68,6 +68,8 @@ source "drivers/watchdog/Kconfig"
 
 source "drivers/ssb/Kconfig"
 
+source "drivers/axi/Kconfig"
+
 source "drivers/mfd/Kconfig"
 
 source "drivers/regulator/Kconfig"
drivers/Makefile +1 -0
index 3f135b6..6e1979b 100644
@@ -110,6 +110,7 @@ obj-$(CONFIG_HID)		+= hid/
 obj-$(CONFIG_PPC_PS3)		+= ps3/
 obj-$(CONFIG_OF)		+= of/
 obj-$(CONFIG_SSB)		+= ssb/
+obj-$(CONFIG_AXI)		+= axi/
 obj-$(CONFIG_VHOST_NET)		+= vhost/
 obj-$(CONFIG_VLYNQ)		+= vlynq/
 obj-$(CONFIG_STAGING)		+= staging/
drivers/axi/Kconfig new file +30 -0
new file mode 100644
index 0000000..f4f58f5
@@ -0,0 +1,30 @@
+config AXI_POSSIBLE
+	bool
+	depends on HAS_IOMEM && HAS_DMA
+	default y
+
+menu "AMBA AXI"
+	depends on AXI_POSSIBLE
+
+config AXI
+	tristate "AXI support"
+	depends on AXI_POSSIBLE
+
+config AXI_HOST_PCI_POSSIBLE
+	bool
+	depends on AXI && PCI = y
+	default y
+
+config AXI_HOST_PCI
+	bool "Support for AI on PCI-host bus"
+	depends on AXI_HOST_PCI_POSSIBLE
+
+config AXI_DEBUG
+	bool "AXI debugging"
+	depends on AXI
+	help
+	  This turns on additional debugging messages.
+
+	  If unsure, say N
+
+endmenu
drivers/axi/Makefile new file +5 -0
new file mode 100644
index 0000000..e649c51
@@ -0,0 +1,5 @@
+axi-y					+= main.o scan.o core.o
+axi-y					+= driver_chipcommon.o driver_chipcommon_pmu.o
+axi-y					+= driver_pci.o
+axi-$(CONFIG_AXI_HOST_PCI)		+= host_pci.o axi_pci_bridge.o
+obj-$(CONFIG_AXI)			+= axi.o
drivers/axi/axi_pci_bridge.c new file +33 -0
new file mode 100644
index 0000000..7ecc59f
@@ -0,0 +1,33 @@
+/*
+ * AXI PCI bridge module
+ *
+ * Licensed under the GNU/GPL. See COPYING for details.
+ */
+
+#include "axi_private.h"
+
+#include <linux/axi/axi.h>
+#include <linux/axi/axi_regs.h>
+#include <linux/pci.h>
+
+static DEFINE_PCI_DEVICE_TABLE(axi_pci_bridge_tbl) = {
+	{ PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4353) },
+	{ PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4727) },
+	{ 0, },
+};
+MODULE_DEVICE_TABLE(pci, axi_pci_bridge_tbl);
+
+static struct pci_driver axi_pci_bridge_driver = {
+	.name = "axi-pci-bridge",
+	.id_table = axi_pci_bridge_tbl,
+};
+
+int __init axi_pci_bridge_init(void)
+{
+	return axi_host_pci_register(&axi_pci_bridge_driver);
+}
+
+void __exit axi_pci_bridge_exit(void)
+{
+	axi_host_pci_unregister(&axi_pci_bridge_driver);
+}
drivers/axi/axi_private.h new file +45 -0

45 lines not on this page · raw message

drivers/axi/core.c new file +52 -0

52 lines not on this page · raw message

drivers/axi/driver_chipcommon.c new file +87 -0

87 lines not on this page · raw message

drivers/axi/driver_chipcommon_pmu.c new file +134 -0

134 lines not on this page · raw message

drivers/axi/driver_pci.c new file +191 -0

191 lines not on this page · raw message

drivers/axi/host_pci.c new file +177 -0

177 lines not on this page · raw message

drivers/axi/main.c new file +256 -0

256 lines not on this page · raw message

drivers/axi/scan.c new file +393 -0

393 lines not on this page · raw message

drivers/axi/scan.h new file +56 -0

56 lines not on this page · raw message

include/linux/axi/axi.h new file +221 -0

221 lines not on this page · raw message

include/linux/axi/axi_driver_chipcommon.h new file +308 -0

308 lines not on this page · raw message

include/linux/axi/axi_driver_pci.h new file +85 -0

85 lines not on this page · raw message

include/linux/axi/axi_regs.h new file +34 -0
new file mode 100644
index 0000000..3bfb1d0
@@ -0,0 +1,34 @@
+#ifndef LINUX_AXI_REGS_H_
+#define LINUX_AXI_REGS_H_
+
+/* Agent registers (common for every core) */
+#define AXI_IOCTL			0x0408
+#define  AXI_IOCTL_CORE_BITS		0x3FFC
+#define  AXI_IOCTL_CLK			0x0001
+#define  AXI_IOCTL_FGC			0x0002
+#define  AXI_IOCTL_PME_EN		0x4000
+#define  AXI_IOCTL_BIST_EN		0x8000
+#define AXI_RESET_CTL			0x0800
+#define  AXI_RESET_CTL_RESET		0x0001
+
+/* AXI PCI config space registers. */
+#define AXI_PCI_PMCSR			0x44
+#define  AXI_PCI_PE			0x100
+#define	AXI_PCI_BAR0_WIN		0x80	/* Backplane address space 0 */
+#define	AXI_PCI_BAR1_WIN		0x84	/* Backplane address space 1 */
+#define	AXI_PCI_SPROMCTL		0x88	/* SPROM control */
+#define  AXI_PCI_SPROMCTL_WE		0x10	/* SPROM write enable */
+#define	AXI_PCI_BAR1_CONTROL		0x8c	/* Address space 1 burst control */
+#define AXI_PCI_IRQS			0x90	/* PCI interrupts */
+#define AXI_PCI_IRQMASK			0x94	/* PCI IRQ control and mask (pcirev >= 6 only) */
+#define AXI_PCI_BACKPLANE_IRQS		0x98	/* Backplane Interrupts */
+#define AXI_PCI_BAR0_WIN2		0xAC
+#define AXI_PCI_GPIO_IN			0xB0	/* GPIO Input (pcirev >= 3 only) */
+#define AXI_PCI_GPIO_OUT		0xB4	/* GPIO Output (pcirev >= 3 only) */
+#define AXI_PCI_GPIO_OUT_ENABLE		0xB8	/* GPIO Output Enable/Disable (pcirev >= 3 only) */
+#define  AXI_PCI_GPIO_SCS		0x10	/* PCI config space bit 4 for 4306c0 slow clock source */
+#define  AXI_PCI_GPIO_HWRAD		0x20	/* PCI config space GPIO 13 for hw radio disable */
+#define  AXI_PCI_GPIO_XTAL		0x40	/* PCI config space GPIO 14 for Xtal powerup */
+#define  AXI_PCI_GPIO_PLL		0x80	/* PCI config space GPIO 15 for PLL powerdown */
+
+#endif /* LINUX_AXI_REGS_H_ */
include/linux/mod_devicetable.h +17 -0
index 48c007d..b3b6424 100644
@@ -382,6 +382,23 @@ struct ssb_device_id {
 #define SSB_ANY_ID		0xFFFF
 #define SSB_ANY_REV		0xFF
 
+/* AMBA AXI core, see drivers/axi/ */
+struct axi_device_id {
+	__u16	manuf;
+	__u16	id;
+	__u8	rev;
+	__u8	class;
+};
+#define AXI_CORE(_manuf, _id, _rev, _class)  \
+	{ .manuf = _manuf, .id = _id, .rev = _rev, .class = _class, }
+#define AXI_CORETABLE_END  \
+	{ 0, },
+
+#define AXI_ANY_MANUF		0xFFFF
+#define AXI_ANY_ID		0xFFFF
+#define AXI_ANY_REV		0xFF
+#define AXI_ANY_CLASS		0xFF
+
 struct virtio_device_id {
 	__u32 device;
 	__u32 vendor;
scripts/mod/file2alias.c +21 -0
index 88f3f07..d9eebd0 100644
@@ -702,6 +702,23 @@ static int do_ssb_entry(const char *filename,
 	return 1;
 }
 
+/* Looks like: axi:mNidNrevNclN. */
+static int do_axi_entry(const char *filename,
+			struct axi_device_id *id, char *alias)
+{
+	id->manuf = TO_NATIVE(id->manuf);
+	id->id = TO_NATIVE(id->id);
+	id->rev = TO_NATIVE(id->rev);
+
+	strcpy(alias, "axi:");
+	ADD(alias, "m", id->manuf != AXI_ANY_MANUF, id->manuf);
+	ADD(alias, "id", id->id != AXI_ANY_ID, id->id);
+	ADD(alias, "rev", id->rev != AXI_ANY_REV, id->rev);
+	ADD(alias, "cl", id->class != AXI_ANY_CLASS, id->class);
+	add_wildcard(alias);
+	return 1;
+}
+
 /* Looks like: virtio:dNvN */
 static int do_virtio_entry(const char *filename, struct virtio_device_id *id,
 			   char *alias)
@@ -968,6 +985,10 @@ void handle_moddevtable(struct module *mod, struct elf_info *info,
 		do_table(symval, sym->st_size,
 			 sizeof(struct ssb_device_id), "ssb",
 			 do_ssb_entry, mod);
+	else if (sym_is(symname, "__mod_axi_device_table"))
+		do_table(symval, sym->st_size,
+			 sizeof(struct axi_device_id), "axi",
+			 do_axi_entry, mod);
 	else if (sym_is(symname, "__mod_virtio_device_table"))
 		do_table(symval, sym->st_size,
 			 sizeof(struct virtio_device_id), "virtio",
Signature · 1 line
1.7.3.4
#1 lore raw

include/linux/axi/axi.h

Quoted 1 line · Rafa? Mi?ecki
include/linux/axi/axi.h +0 -0

[]

include/linux/axi/axi.h line 14

Quoted 7 lines
include/linux/axi/axi.h +7 -0
+#define axi_info	pr_info
+#ifdef CONFIG_AXI_DEBUG
+#define axi_debug	pr_debug
+#else
+#define axi_debug	do { } while (0)
+#endif
+#define axi_err		pr_err

I think redefining standard functionality like
this doesn't gain anything and loses some basic
grep capability.

#2 lore raw

2011/4/8 Joe Perches <[email protected]>:

Quoted 14 lines · Rafa? Mi?ecki

include/linux/axi/axi.h

Quoted 1 line
include/linux/axi/axi.h +0 -0

[]

include/linux/axi/axi.h

Quoted 7 lines
include/linux/axi/axi.h +7 -0
+#define axi_info ? ? pr_info
+#ifdef CONFIG_AXI_DEBUG
+#define axi_debug ? ?pr_debug
+#else
+#define axi_debug ? ?do { } while (0)
+#endif
+#define axi_err ? ? ? ? ? ? ?pr_err

I think redefining standard functionality like
this doesn't gain anything and loses some basic
grep capability.

But on the other hand using:
pr_info, pr_err, BUT axi_debug
can easily lead to mistakes.

Or is this possible to re-define pr_debug locally?

Signature · 1 line
Rafa?
#3 lore raw
Quoted 16 lines · Rafa? Mi?ecki

2011/4/8 Joe Perches <[email protected]>:

Quoted 14 lines · Rafa? Mi?ecki

include/linux/axi/axi.h

Quoted 1 line
include/linux/axi/axi.h +0 -0

[]

include/linux/axi/axi.h line 14

Quoted 7 lines
include/linux/axi/axi.h +7 -0
+#define axi_info     pr_info
+#ifdef CONFIG_AXI_DEBUG
+#define axi_debug    pr_debug
+#else
+#define axi_debug    do { } while (0)
+#endif
+#define axi_err              pr_err

I think redefining standard functionality like
this doesn't gain anything and loses some basic
grep capability.

Quoted 5 lines

But on the other hand using:
pr_info, pr_err, BUT axi_debug
can easily lead to mistakes.

Or is this possible to re-define pr_debug locally?

It is, but is that CONFIG_AXI_DEBUG actually
worthwhile?

If you think so, doesn't adding this to the Makefile give you the same capability?

ccflags-$(CONFIG_CONFIG_AXI_DEBUG) := -DDEBUG

#6 lore raw
In reply to Rafał Miłecki
Quoted 103 lines · Rafa? Mi?ecki
Cc Michael B?sch <[email protected]>
Cc Larry Finger <[email protected]>
Cc George Kashperko <[email protected]>
Cc Arend van Spriel <[email protected]>
Cc linux-arm-kernel at lists.infradead.org <[email protected]>
Cc Russell King <[email protected]>
Cc Arnd Bergmann <[email protected]>
Cc linuxdriverproject <[email protected]>
Cc linux-kernel at vger.kernel.org <[email protected]>

---
This is second try for introducing new bus driver.
V2: Rename to axi
? ?Use DEFINE_PCI_DEVICE_TABLE in bridge
? ?Make use of pr_fmt and pr_*
? ?Store core class
? ?Rename bridge to not b43 specific
? ?Replace magic 0x1000 with BCMAI_CORE_SIZE ? ?Remove some old "ssb" names and defines ? ?Move BCMAI_ADDR_BASE def
? ?Add drvdata field
TODO:
- Interrupts
- Reloading driver
---

?drivers/Kconfig ? ? ? ? ? ? ? ? ? ? ? ? ? | ? ?2 +
?drivers/Makefile ? ? ? ? ? ? ? ? ? ? ? ? ?| ? ?1 +
?drivers/axi/Kconfig ? ? ? ? ? ? ? ? ? ? ? | ? 30 +++
?drivers/axi/Makefile ? ? ? ? ? ? ? ? ? ? ?| ? ?5 +
?drivers/axi/axi_pci_bridge.c ? ? ? ? ? ? ?| ? 33 +++
?drivers/axi/axi_private.h ? ? ? ? ? ? ? ? | ? 45 ++++
?drivers/axi/core.c ? ? ? ? ? ? ? ? ? ? ? ?| ? 52 ++++
?drivers/axi/driver_chipcommon.c ? ? ? ? ? | ? 87 +++++++
?drivers/axi/driver_chipcommon_pmu.c ? ? ? | ?134 ++++++++++
?drivers/axi/driver_pci.c ? ? ? ? ? ? ? ? ?| ?191 ++++++++++++++
?drivers/axi/host_pci.c ? ? ? ? ? ? ? ? ? ?| ?177 +++++++++++++
?drivers/axi/main.c ? ? ? ? ? ? ? ? ? ? ? ?| ?256 +++++++++++++++++++
?drivers/axi/scan.c ? ? ? ? ? ? ? ? ? ? ? ?| ?393 +++++++++++++++++++++++++++++
?drivers/axi/scan.h ? ? ? ? ? ? ? ? ? ? ? ?| ? 56 ++++
?include/linux/axi/axi.h ? ? ? ? ? ? ? ? ? | ?221 ++++++++++++++++
?include/linux/axi/axi_driver_chipcommon.h | ?308 ++++++++++++++++++++++
?include/linux/axi/axi_driver_pci.h ? ? ? ?| ? 85 +++++++
?include/linux/axi/axi_regs.h ? ? ? ? ? ? ?| ? 34 +++
?include/linux/mod_devicetable.h ? ? ? ? ? | ? 17 ++
?scripts/mod/file2alias.c ? ? ? ? ? ? ? ? ?| ? 21 ++

?20 files changed, 2148 insertions(+), 0 deletions(-) ?create mode 100644 drivers/axi/Kconfig
?create mode 100644 drivers/axi/Makefile
?create mode 100644 drivers/axi/axi_pci_bridge.c ?create mode 100644 drivers/axi/axi_private.h ?create mode 100644 drivers/axi/core.c
?create mode 100644 drivers/axi/driver_chipcommon.c ?create mode 100644 drivers/axi/driver_chipcommon_pmu.c ?create mode 100644 drivers/axi/driver_pci.c ?create mode 100644 drivers/axi/host_pci.c
?create mode 100644 drivers/axi/main.c
?create mode 100644 drivers/axi/scan.c
?create mode 100644 drivers/axi/scan.h
?create mode 100644 include/linux/axi/axi.h
?create mode 100644 include/linux/axi/axi_driver_chipcommon.h ?create mode 100644 include/linux/axi/axi_driver_pci.h ?create mode 100644 include/linux/axi/axi_regs.h

drivers/Kconfig +0 -0
index 177c7d1..1244e8c 100644
@@ -68,6 +68,8 @@ source "drivers/watchdog/Kconfig"
 

?source "drivers/ssb/Kconfig"

drivers/Kconfig +2 -0
+source "drivers/axi/Kconfig"
+

?source "drivers/mfd/Kconfig"

?source "drivers/regulator/Kconfig"

drivers/Makefile +0 -0
index 3f135b6..6e1979b 100644
@@ -110,6 +110,7 @@ obj-$(CONFIG_HID) ? ? ? ? ? += hid/

?obj-$(CONFIG_PPC_PS3) ? ? ? ? ?+= ps3/
?obj-$(CONFIG_OF) ? ? ? ? ? ? ? += of/
?obj-$(CONFIG_SSB) ? ? ? ? ? ? ?+= ssb/
+obj-$(CONFIG_AXI) ? ? ? ? ? ? ?+= axi/
?obj-$(CONFIG_VHOST_NET) ? ? ? ? ? ? ? ?+= vhost/
?obj-$(CONFIG_VLYNQ) ? ? ? ? ? ?+= vlynq/
?obj-$(CONFIG_STAGING) ? ? ? ? ?+= staging/

drivers/axi/Kconfig new file +9 -0
new file mode 100644
index 0000000..f4f58f5
@@ -0,0 +1,30 @@
+config AXI_POSSIBLE
+ ? ? ? bool
+ ? ? ? depends on HAS_IOMEM && HAS_DMA
+ ? ? ? default y
+
+menu "AMBA AXI"
+ ? ? ? depends on AXI_POSSIBLE
+
+config AXI

drivers/axi/Kconfig line 19

Quoted 10 lines
drivers/axi/Kconfig new file +10 -0
+ ? ? ? tristate "AXI support"
+ ? ? ? depends on AXI_POSSIBLE
+
+config AXI_HOST_PCI_POSSIBLE
+ ? ? ? bool
+ ? ? ? depends on AXI && PCI = y
+ ? ? ? default y
+
+config AXI_HOST_PCI
+ ? ? ? bool "Support for AI on PCI-host bus"

Shouldn't this say AXI?

Quoted 11 lines
drivers/axi/Kconfig new file +11 -0
+ ? ? ? depends on AXI_HOST_PCI_POSSIBLE
+
+config AXI_DEBUG
+ ? ? ? bool "AXI debugging"
+ ? ? ? depends on AXI
+ ? ? ? help
+ ? ? ? ? This turns on additional debugging messages.
+
+ ? ? ? ? If unsure, say N
+
+endmenu
#7 lore raw
In reply to Rafał Miłecki
Quoted 10 lines · Rafał Miłecki
Cc Michael Büsch <[email protected]>
Cc Larry Finger <[email protected]>
Cc George Kashperko <[email protected]>
Cc Arend van Spriel <[email protected]>
Cc Russell King <[email protected]>
Cc Arnd Bergmann <[email protected]>
Cc linuxdriverproject <[email protected]>
Quoted 14 lines

---
This is second try for introducing new bus driver.
V2: Rename to axi
Use DEFINE_PCI_DEVICE_TABLE in bridge Make use of pr_fmt and pr_*
Store core class
Rename bridge to not b43 specific Replace magic 0x1000 with BCMAI_CORE_SIZE Remove some old "ssb" names and defines Move BCMAI_ADDR_BASE def
Add drvdata field
TODO:
- Interrupts
- Reloading driver

Please add to the TODO list:
- Documentation/ABI entries for new sysfs files
- proper Kconfig entry documentation for the different options
- remove unneeded pcicore_write* wrapper functions that do nothing.

drivers/axi/main.c line 74

Quoted 4 lines
drivers/axi/main.c new file +4 -0
+static void axi_release_core_dev(struct device *dev)
+{
+	kfree(dev);
+}

This is wrong, unless you are really only creating a 'struct device'. Why are you doing that instead of embedding struct device in your structure?

thanks,

greg k-h

#8 lore raw

2011/4/9 Greg KH <[email protected]>:

Quoted 8 lines

drivers/axi/main.c line 74

Quoted 4 lines
drivers/axi/main.c new file +4 -0
+static void axi_release_core_dev(struct device *dev)
+{
+ ? ? kfree(dev);
+}

This is wrong, unless you are really only creating a 'struct device'. Why are you doing that instead of embedding struct device in your structure?

Hm, I think Greg found explanation why we can not reload axi driver successfully :)

I'll take care of your comment after weekend, thank you everybody.

Signature · 1 line
Rafa?
#4 lore raw
In reply to Joe Perches

2011/4/8 Joe Perches <[email protected]>:

Quoted 23 lines · Rafa? Mi?ecki
Quoted 16 lines

2011/4/8 Joe Perches <[email protected]>:

Quoted 14 lines · Rafa? Mi?ecki

include/linux/axi/axi.h

Quoted 1 line
include/linux/axi/axi.h +0 -0

[]

include/linux/axi/axi.h

Quoted 7 lines
include/linux/axi/axi.h +7 -0
+#define axi_info ? ? pr_info
+#ifdef CONFIG_AXI_DEBUG
+#define axi_debug ? ?pr_debug
+#else
+#define axi_debug ? ?do { } while (0)
+#endif
+#define axi_err ? ? ? ? ? ? ?pr_err

I think redefining standard functionality like
this doesn't gain anything and loses some basic
grep capability.

Quoted 5 lines

But on the other hand using:
pr_info, pr_err, BUT axi_debug
can easily lead to mistakes.

Or is this possible to re-define pr_debug locally?

Quoted 7 lines

It is, but is that CONFIG_AXI_DEBUG actually
worthwhile?

If you think so, doesn't adding this to the Makefile give you the same capability?

ccflags-$(CONFIG_CONFIG_AXI_DEBUG) := -DDEBUG

But pr_debug does not depend on DEBUG define:
http://lxr.free-electrons.com/source/tools/perf/util/include/linux/kernel.h#L94

How do you expect -DDEBUG to affect pr_debug? Could you explain this to me, please?

Signature · 1 line
Rafa?
#5 lore raw
Quoted 25 lines · Rafa? Mi?ecki

2011/4/8 Joe Perches <[email protected]>:

Quoted 24 lines · Rafa? Mi?ecki
Quoted 14 lines

2011/4/8 Joe Perches <[email protected]>:

Quoted 13 lines · Rafa? Mi?ecki

include/linux/axi/axi.h

Quoted 1 line
include/linux/axi/axi.h +0 -0

[]

include/linux/axi/axi.h line 14

Quoted 7 lines
include/linux/axi/axi.h +7 -0
+#define axi_info     pr_info
+#ifdef CONFIG_AXI_DEBUG
+#define axi_debug    pr_debug
+#else
+#define axi_debug    do { } while (0)
+#endif
+#define axi_err              pr_err

I think redefining standard functionality like
this doesn't gain anything and loses some basic
grep capability.

Quoted 4 lines

But on the other hand using:
pr_info, pr_err, BUT axi_debug
can easily lead to mistakes.
Or is this possible to re-define pr_debug locally?

It is, but is that CONFIG_AXI_DEBUG actually worthwhile?
If you think so, doesn't adding this to the Makefile give you the same capability? ccflags-$(CONFIG_CONFIG_AXI_DEBUG) := -DDEBUG

Just CONFIG_AXI_DEBUG of course.

Quoted 4 lines

But pr_debug does not depend on DEBUG define:
http://lxr.free-electrons.com/source/tools/perf/util/include/linux/kernel.h#L94
How do you expect -DDEBUG to affect pr_debug? Could you explain this to me, please?

Sure. You're not looking at the right place.

Look instead at include/linux/printk.h

/* If you are writing a driver, please use dev_dbg instead */ #if defined(DEBUG)

#define pr_debug(fmt, ...) \
	printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
#elif defined(CONFIG_DYNAMIC_DEBUG)
/* dynamic_pr_debug() uses pr_fmt() internally so we don't need it here */
#define pr_debug(fmt, ...) \
	dynamic_pr_debug(fmt, ##__VA_ARGS__)
#else
#define pr_debug(fmt, ...) \
	no_printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)

#endif

cheers, Joe

#9 lore raw
In reply to Greg KH

2011/4/9 Greg KH <[email protected]>:

Quoted 8 lines · Rafa? Mi?ecki
Quoted 3 lines

TODO:
- Interrupts
- Reloading driver

Please add to the TODO list:
? ? ? ?- Documentation/ABI entries for new sysfs files
? ? ? ?- proper Kconfig entry documentation for the different options

Could you tell me sth more about this? How am I expected to document this stuff?

Should I create Documentation/ABI/testing/sysfs-bus-axi or what?

Of course you can just point me to some place where I can read about proper documenting.

Signature · 1 line
Rafa?
#10 lore raw
Quoted 10 lines · Rafał Miłecki

2011/4/9 Greg KH <[email protected]>:

Quoted 8 lines · Rafał Miłecki
Quoted 3 lines

TODO:
- Interrupts
- Reloading driver

Please add to the TODO list:
       - Documentation/ABI entries for new sysfs files
       - proper Kconfig entry documentation for the different options

Quoted 6 lines

Could you tell me sth more about this? How am I expected to document this stuff?

Should I create Documentation/ABI/testing/sysfs-bus-axi or what?

Of course you can just point me to some place where I can read about proper documenting.

Documentation/ABI/README

#11 lore raw
In reply to Rafał Miłecki
Quoted 25 lines · Rafa? Mi?ecki

Cc: Michael B?sch <[email protected]>
Cc: Larry Finger <[email protected]>
Cc: George Kashperko <[email protected]>
Cc: Arend van Spriel <[email protected]>
Cc: linux-arm-kernel at lists.infradead.org
<[email protected]>

Cc Russell King <[email protected]>
Cc Arnd Bergmann <[email protected]>
Cc linuxdriverproject <[email protected]>
Cc linux-kernel at vger.kernel.org <[email protected]>

---
This is second try for introducing new bus driver.
V2: Rename to axi
Use DEFINE_PCI_DEVICE_TABLE in bridge Make use of pr_fmt and pr_*
Store core class
Rename bridge to not b43 specific Replace magic 0x1000 with BCMAI_CORE_SIZE Remove some old "ssb" names and defines Move BCMAI_ADDR_BASE def
Add drvdata field
TODO:
- Interrupts
- Reloading driver

Quoted 5 lines
---
 drivers/Kconfig                           |    2 +
 drivers/Makefile                          |    1 +
 include/linux/mod_devicetable.h           |   17 ++
 scripts/mod/file2alias.c                  |   21 ++

Hi Rafa?,

I tried to apply this patch, but it failed as well. I did the 4 files above manually and applied partial patch for the new files.

When I load the module it seems to have succeeded once, but every insmod attempt I do now fails with following trace:

Apr 11 16:43:43 arend-laptop kernel: [   61.249239] axi-pci-bridge
0000:03:00.0: PCI INT A -> GSI 17 (level, low) -> IRQ 17
Apr 11 16:43:43 arend-laptop kernel: [   61.249312] Core 0 found:
ChipCommon (manuf 0x4BF, id 0x800, rev 0x22, class 0x0)
Apr 11 16:43:43 arend-laptop kernel: [   61.249339] Core 1 found: IEEE
802.11 (manuf 0x4BF, id 0x812, rev 0x17, class 0x0)
Apr 11 16:43:43 arend-laptop kernel: [   61.249400] Core 2 found: PCIe
(manuf 0x4BF, id 0x820, rev 0x0F, class 0x0)
Apr 11 16:43:43 arend-laptop kernel: [   61.279913] Modules linked in:

axi(+) binfmt_misc nouveau ttm drm_kms_helper drm i2c_algo_bit snd_hda_codec_hdmi snd_hda_codec_idt snd_hda_intel snd_hda_codec snd_seq_midi snd_hwdep ppdev snd_rawmidi snd_pcm snd_seq_midi_event parport_pc snd_seq snd_timer snd_seq_device lp pcmcia snd uvcvideo soundcore snd_page_alloc dell_laptop videodev dell_wmi dcdbas sparse_keymap intel_ips yenta_socket video pcmcia_rsrc pcmcia_core parport intel_agp intel_gtt agpgart psmouse btusb bluetooth joydev serio_raw usbhid hid mmc_block ahci sdhci_pci firewire_ohci sdhci e1000e firewire_core mmc_core libahci crc_itu_t

Apr 11 16:43:43 arend-laptop kernel: [   61.280052]
Apr 11 16:43:43 arend-laptop kernel: [   61.280366] Pid: 2008, comm:
insmod Not tainted 2.6.39-rc1-staging-next-09270-gb905e26 #1 Dell Inc.
Latitude E6410/07XJP9
Apr 11 16:43:43 arend-laptop kernel: [   61.281090] EIP: 0060:[<c0213d3d>]
EFLAGS: 00010246 CPU: 1
Apr 11 16:43:43 arend-laptop kernel: [   61.281812] EIP is at
kfree+0x10d/0x120
Apr 11 16:43:43 arend-laptop kernel: [   61.282523] EAX: 40000000 EBX:
f726bc40 ECX: f2ea6910 EDX: 0000002f
Apr 11 16:43:43 arend-laptop kernel: [   61.283234] ESI: f57d2d60 EDI:
00000000 EBP: f726bd70 ESP: f726bd4c
Apr 11 16:43:43 arend-laptop kernel: [   61.283947]  DS: 007b ES: 007b FS:
00d8 GS: 00e0 SS: 0068
Apr 11 16:43:43 arend-laptop kernel: [   61.286071]  f726bd98 f848be2a
f726bd70 c036dea3 f726bda0 00000007 f3aae18c f726bc40
Apr 11 16:43:43 arend-laptop kernel: [   61.286797]  f3aae000 f726bd80
c03642c4 f3aae16c 00000001 f726bd88 c0410639 f726bdb4
Apr 11 16:43:43 arend-laptop kernel: [   61.287522]  f848a326 f3aae184
f848be2a 00000000 00000000 f3aae184 00000000 f39eb800
Apr 11 16:43:43 arend-laptop kernel: [   61.288957]  [<c036dea3>] ?
kvasprintf+0x43/0x60
Apr 11 16:43:43 arend-laptop kernel: [   61.289660]  [<c03642c4>]
kobject_set_name_vargs+0x64/0x70
Apr 11 16:43:43 arend-laptop kernel: [   61.290357]  [<c0410639>]
dev_set_name+0x19/0x20
Apr 11 16:43:43 arend-laptop kernel: [   61.291050]  [<f848a326>]
axi_bus_register+0x106/0x220 [axi]
Apr 11 16:43:43 arend-laptop kernel: [   61.291738]  [<f848bd1a>]
axi_host_pci_probe+0xfa/0x168 [axi]
Apr 11 16:43:43 arend-laptop kernel: [   61.292419]  [<c0381497>]
local_pci_probe+0x47/0xb0
Apr 11 16:43:43 arend-laptop kernel: [   61.293091]  [<c0382388>]
pci_device_probe+0x68/0x90
Apr 11 16:43:43 arend-laptop kernel: [   61.293755]  [<c04138af>]
driver_probe_device+0x7f/0x190
Apr 11 16:43:43 arend-laptop kernel: [   61.294417]  [<c0413a41>]
__driver_attach+0x81/0x90
Apr 11 16:43:43 arend-laptop kernel: [   61.295070]  [<c0412ec3>]
bus_for_each_dev+0x53/0x80
Apr 11 16:43:43 arend-laptop kernel: [   61.295720]  [<c041372e>]
driver_attach+0x1e/0x20
Apr 11 16:43:43 arend-laptop kernel: [   61.296371]  [<c04139c0>] ?
driver_probe_device+0x190/0x190
Apr 11 16:43:43 arend-laptop kernel: [   61.297015]  [<c0413140>]
bus_add_driver+0xc0/0x240
Apr 11 16:43:43 arend-laptop kernel: [   61.297661]  [<c0382200>] ?
pci_dev_put+0x20/0x20
Apr 11 16:43:43 arend-laptop kernel: [   61.298308]  [<c041406a>]
driver_register+0x6a/0x130
Apr 11 16:43:43 arend-laptop kernel: [   61.298958]  [<c0412897>] ?
bus_put+0x17/0x20
Apr 11 16:43:43 arend-laptop kernel: [   61.299608]  [<c041306e>] ?
bus_create_file+0x3e/0x50
Apr 11 16:43:43 arend-laptop kernel: [   61.300259]  [<c03825c5>]
__pci_register_driver+0x45/0xb0
Apr 11 16:43:43 arend-laptop kernel: [   61.300900]  [<f848bbb5>]
axi_host_pci_register+0x25/0x30 [axi]
Apr 11 16:43:43 arend-laptop kernel: [   61.301539]  [<f83bb03f>]
axi_pci_bridge_init+0xd/0xf [axi]
Apr 11 16:43:43 arend-laptop kernel: [   61.302172]  [<f83bb01c>]
axi_modinit+0x1c/0x32 [axi]
Apr 11 16:43:43 arend-laptop kernel: [   61.302810]  [<c0101125>]
do_one_initcall+0x35/0x170
Apr 11 16:43:43 arend-laptop kernel: [   61.303445]  [<f83bb000>] ?
0xf83bafff
Apr 11 16:43:43 arend-laptop kernel: [   61.304078]  [<c0181e46>]
sys_init_module+0x116/0x1090
Apr 11 16:43:43 arend-laptop kernel: [   61.304716]  [<c05e3e5f>]
sysenter_do_call+0x12/0x28
Apr 11 16:43:43 arend-laptop kernel: [   61.307475] ---[ end trace

9219745721068e61 ]---

Is this what you indicate with reloading driver in the TODO remark? I rebooted the system and power-cycled it but I still get this failure. I did not futher look into this so hopefully you can enlighten me on this.

Gr. AvS

Signature · 1 line
"The world is indeed comic, but the joke is on mankind." ? H.P. Lovecraft
#12 lore raw

2011/4/11 Arend van Spriel <[email protected]>:

Quoted 59 lines · Rafa? Mi?ecki
Quoted 27 lines

Cc: Michael B?sch <[email protected]>
Cc: Larry Finger <[email protected]>
Cc: George Kashperko <[email protected]>
Cc: Arend van Spriel <[email protected]>
Cc: linux-arm-kernel at lists.infradead.org
<[email protected]>

Cc Russell King <[email protected]>
Cc Arnd Bergmann <[email protected]>
Cc linuxdriverproject <[email protected]>
Cc linux-kernel at vger.kernel.org <[email protected]>

---
This is second try for introducing new bus driver.
V2: Rename to axi
? ?Use DEFINE_PCI_DEVICE_TABLE in bridge
? ?Make use of pr_fmt and pr_*
? ?Store core class
? ?Rename bridge to not b43 specific
? ?Replace magic 0x1000 with BCMAI_CORE_SIZE ? ?Remove some old "ssb" names and defines ? ?Move BCMAI_ADDR_BASE def
? ?Add drvdata field
TODO:
- Interrupts
- Reloading driver
---

Quoted 4 lines
?drivers/Kconfig ? ? ? ? ? ? ? ? ? ? ? ? ? | ? ?2 +
?drivers/Makefile ? ? ? ? ? ? ? ? ? ? ? ? ?| ? ?1 +
?include/linux/mod_devicetable.h ? ? ? ? ? | ? 17 ++
?scripts/mod/file2alias.c ? ? ? ? ? ? ? ? ?| ? 21 ++

Hi Rafa?,

I tried to apply this patch, but it failed as well. I did the 4 files above manually and applied partial patch for the new files.

When I load the module it seems to have succeeded once, but every insmod attempt I do now fails with following trace:

Apr 11 16:43:43 arend-laptop kernel: [ ? 61.249239] axi-pci-bridge
0000:03:00.0: PCI INT A -> GSI 17 (level, low) -> IRQ 17
Apr 11 16:43:43 arend-laptop kernel: [ ? 61.249312] Core 0 found:
ChipCommon (manuf 0x4BF, id 0x800, rev 0x22, class 0x0)
Apr 11 16:43:43 arend-laptop kernel: [ ? 61.249339] Core 1 found: IEEE
802.11 (manuf 0x4BF, id 0x812, rev 0x17, class 0x0)
Apr 11 16:43:43 arend-laptop kernel: [ ? 61.249400] Core 2 found: PCIe
(manuf 0x4BF, id 0x820, rev 0x0F, class 0x0)
Apr 11 16:43:43 arend-laptop kernel: [ ? 61.279913] Modules linked in:

axi(+) binfmt_misc nouveau ttm drm_kms_helper drm i2c_algo_bit snd_hda_codec_hdmi snd_hda_codec_idt snd_hda_intel snd_hda_codec snd_seq_midi snd_hwdep ppdev snd_rawmidi snd_pcm snd_seq_midi_event parport_pc snd_seq snd_timer snd_seq_device lp pcmcia snd uvcvideo soundcore snd_page_alloc dell_laptop videodev dell_wmi dcdbas sparse_keymap intel_ips yenta_socket video pcmcia_rsrc pcmcia_core parport intel_agp intel_gtt agpgart psmouse btusb bluetooth joydev serio_raw usbhid hid mmc_block ahci sdhci_pci firewire_ohci sdhci e1000e firewire_core mmc_core libahci crc_itu_t

Quoted 8 lines
Apr 11 16:43:43 arend-laptop kernel: [ ? 61.280052]
Apr 11 16:43:43 arend-laptop kernel: [ ? 61.280366] Pid: 2008, comm:
insmod Not tainted 2.6.39-rc1-staging-next-09270-gb905e26 #1 Dell Inc.
Latitude E6410/07XJP9
Apr 11 16:43:43 arend-laptop kernel: [ ? 61.281090] EIP: 0060:[<c0213d3d>]
EFLAGS: 00010246 CPU: 1
Apr 11 16:43:43 arend-laptop kernel: [ ? 61.281812] EIP is at

kfree+0x10d/0x120

Thank you Arend for testing.

What you see is some issue with kfree I do not understand. Please take a look at:
"Crash with kfree(null) on MacBook? kobject_set_name_vargs"
https://lkml.org/lkml/2011/4/10/71

When I call dev_set_name result with new name for device, internal implementation performs "kfree" on *old name*. Of course there was not old name, so kfree is being called on * char pointing to NULL. On my device it does not crash, but on yours and on Andy's it does.

We got suggestion to enable SLUB/SLAB debugging. Andy didn't try it yet. Could you spend a moment trying to debug this?

Signature · 1 line
Rafa?