diff options
author | Krzysztof Hałasa <khc@pm.waw.pl> | 2008-12-21 18:26:38 -0500 |
---|---|---|
committer | Krzysztof Hałasa <khc@pm.waw.pl> | 2008-12-21 18:48:00 -0500 |
commit | e6da96ace859dad966fe85cc9552b89f48bbc930 (patch) | |
tree | c022b49ee22b355eec92d627fd45160f89406cf0 /arch | |
parent | 9251ce959cab704eb0e4910860b06b18e7083474 (diff) |
IXP4xx: move common debugging from network drivers to QMGR module.
Signed-off-by: Krzysztof Hałasa <khc@pm.waw.pl>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/arm/mach-ixp4xx/include/mach/qmgr.h | 35 | ||||
-rw-r--r-- | arch/arm/mach-ixp4xx/ixp4xx_qmgr.c | 41 |
2 files changed, 62 insertions, 14 deletions
diff --git a/arch/arm/mach-ixp4xx/include/mach/qmgr.h b/arch/arm/mach-ixp4xx/include/mach/qmgr.h index 1e52b95cede5..0cbe6ceb67c5 100644 --- a/arch/arm/mach-ixp4xx/include/mach/qmgr.h +++ b/arch/arm/mach-ixp4xx/include/mach/qmgr.h | |||
@@ -12,6 +12,8 @@ | |||
12 | #include <linux/io.h> | 12 | #include <linux/io.h> |
13 | #include <linux/kernel.h> | 13 | #include <linux/kernel.h> |
14 | 14 | ||
15 | #define DEBUG_QMGR 0 | ||
16 | |||
15 | #define HALF_QUEUES 32 | 17 | #define HALF_QUEUES 32 |
16 | #define QUEUES 64 /* only 32 lower queues currently supported */ | 18 | #define QUEUES 64 /* only 32 lower queues currently supported */ |
17 | #define MAX_QUEUE_LENGTH 4 /* in dwords */ | 19 | #define MAX_QUEUE_LENGTH 4 /* in dwords */ |
@@ -61,22 +63,51 @@ void qmgr_enable_irq(unsigned int queue); | |||
61 | void qmgr_disable_irq(unsigned int queue); | 63 | void qmgr_disable_irq(unsigned int queue); |
62 | 64 | ||
63 | /* request_ and release_queue() must be called from non-IRQ context */ | 65 | /* request_ and release_queue() must be called from non-IRQ context */ |
66 | |||
67 | #if DEBUG_QMGR | ||
68 | extern char qmgr_queue_descs[QUEUES][32]; | ||
69 | |||
64 | int qmgr_request_queue(unsigned int queue, unsigned int len /* dwords */, | 70 | int qmgr_request_queue(unsigned int queue, unsigned int len /* dwords */, |
65 | unsigned int nearly_empty_watermark, | 71 | unsigned int nearly_empty_watermark, |
66 | unsigned int nearly_full_watermark); | 72 | unsigned int nearly_full_watermark, |
73 | const char *desc_format, const char* name); | ||
74 | #else | ||
75 | int __qmgr_request_queue(unsigned int queue, unsigned int len /* dwords */, | ||
76 | unsigned int nearly_empty_watermark, | ||
77 | unsigned int nearly_full_watermark); | ||
78 | #define qmgr_request_queue(queue, len, nearly_empty_watermark, \ | ||
79 | nearly_full_watermark, desc_format, name) \ | ||
80 | __qmgr_request_queue(queue, len, nearly_empty_watermark, \ | ||
81 | nearly_full_watermark) | ||
82 | #endif | ||
83 | |||
67 | void qmgr_release_queue(unsigned int queue); | 84 | void qmgr_release_queue(unsigned int queue); |
68 | 85 | ||
69 | 86 | ||
70 | static inline void qmgr_put_entry(unsigned int queue, u32 val) | 87 | static inline void qmgr_put_entry(unsigned int queue, u32 val) |
71 | { | 88 | { |
72 | extern struct qmgr_regs __iomem *qmgr_regs; | 89 | extern struct qmgr_regs __iomem *qmgr_regs; |
90 | #if DEBUG_QMGR | ||
91 | BUG_ON(!qmgr_queue_descs[queue]); /* not yet requested */ | ||
92 | |||
93 | printk(KERN_DEBUG "Queue %s(%i) put %X\n", | ||
94 | qmgr_queue_descs[queue], queue, val); | ||
95 | #endif | ||
73 | __raw_writel(val, &qmgr_regs->acc[queue][0]); | 96 | __raw_writel(val, &qmgr_regs->acc[queue][0]); |
74 | } | 97 | } |
75 | 98 | ||
76 | static inline u32 qmgr_get_entry(unsigned int queue) | 99 | static inline u32 qmgr_get_entry(unsigned int queue) |
77 | { | 100 | { |
101 | u32 val; | ||
78 | extern struct qmgr_regs __iomem *qmgr_regs; | 102 | extern struct qmgr_regs __iomem *qmgr_regs; |
79 | return __raw_readl(&qmgr_regs->acc[queue][0]); | 103 | val = __raw_readl(&qmgr_regs->acc[queue][0]); |
104 | #if DEBUG_QMGR | ||
105 | BUG_ON(!qmgr_queue_descs[queue]); /* not yet requested */ | ||
106 | |||
107 | printk(KERN_DEBUG "Queue %s(%i) get %X\n", | ||
108 | qmgr_queue_descs[queue], queue, val); | ||
109 | #endif | ||
110 | return val; | ||
80 | } | 111 | } |
81 | 112 | ||
82 | static inline int qmgr_get_stat1(unsigned int queue) | 113 | static inline int qmgr_get_stat1(unsigned int queue) |
diff --git a/arch/arm/mach-ixp4xx/ixp4xx_qmgr.c b/arch/arm/mach-ixp4xx/ixp4xx_qmgr.c index 444c2ae21db4..bfddc73d0a20 100644 --- a/arch/arm/mach-ixp4xx/ixp4xx_qmgr.c +++ b/arch/arm/mach-ixp4xx/ixp4xx_qmgr.c | |||
@@ -14,8 +14,6 @@ | |||
14 | #include <linux/module.h> | 14 | #include <linux/module.h> |
15 | #include <mach/qmgr.h> | 15 | #include <mach/qmgr.h> |
16 | 16 | ||
17 | #define DEBUG 0 | ||
18 | |||
19 | struct qmgr_regs __iomem *qmgr_regs; | 17 | struct qmgr_regs __iomem *qmgr_regs; |
20 | static struct resource *mem_res; | 18 | static struct resource *mem_res; |
21 | static spinlock_t qmgr_lock; | 19 | static spinlock_t qmgr_lock; |
@@ -23,6 +21,10 @@ static u32 used_sram_bitmap[4]; /* 128 16-dword pages */ | |||
23 | static void (*irq_handlers[HALF_QUEUES])(void *pdev); | 21 | static void (*irq_handlers[HALF_QUEUES])(void *pdev); |
24 | static void *irq_pdevs[HALF_QUEUES]; | 22 | static void *irq_pdevs[HALF_QUEUES]; |
25 | 23 | ||
24 | #if DEBUG_QMGR | ||
25 | char qmgr_queue_descs[QUEUES][32]; | ||
26 | #endif | ||
27 | |||
26 | void qmgr_set_irq(unsigned int queue, int src, | 28 | void qmgr_set_irq(unsigned int queue, int src, |
27 | void (*handler)(void *pdev), void *pdev) | 29 | void (*handler)(void *pdev), void *pdev) |
28 | { | 30 | { |
@@ -82,9 +84,16 @@ static inline void shift_mask(u32 *mask) | |||
82 | mask[0] <<= 1; | 84 | mask[0] <<= 1; |
83 | } | 85 | } |
84 | 86 | ||
87 | #if DEBUG_QMGR | ||
85 | int qmgr_request_queue(unsigned int queue, unsigned int len /* dwords */, | 88 | int qmgr_request_queue(unsigned int queue, unsigned int len /* dwords */, |
86 | unsigned int nearly_empty_watermark, | 89 | unsigned int nearly_empty_watermark, |
87 | unsigned int nearly_full_watermark) | 90 | unsigned int nearly_full_watermark, |
91 | const char *desc_format, const char* name) | ||
92 | #else | ||
93 | int __qmgr_request_queue(unsigned int queue, unsigned int len /* dwords */, | ||
94 | unsigned int nearly_empty_watermark, | ||
95 | unsigned int nearly_full_watermark) | ||
96 | #endif | ||
88 | { | 97 | { |
89 | u32 cfg, addr = 0, mask[4]; /* in 16-dwords */ | 98 | u32 cfg, addr = 0, mask[4]; /* in 16-dwords */ |
90 | int err; | 99 | int err; |
@@ -152,12 +161,13 @@ int qmgr_request_queue(unsigned int queue, unsigned int len /* dwords */, | |||
152 | used_sram_bitmap[2] |= mask[2]; | 161 | used_sram_bitmap[2] |= mask[2]; |
153 | used_sram_bitmap[3] |= mask[3]; | 162 | used_sram_bitmap[3] |= mask[3]; |
154 | __raw_writel(cfg | (addr << 14), &qmgr_regs->sram[queue]); | 163 | __raw_writel(cfg | (addr << 14), &qmgr_regs->sram[queue]); |
155 | spin_unlock_irq(&qmgr_lock); | 164 | #if DEBUG_QMGR |
156 | 165 | snprintf(qmgr_queue_descs[queue], sizeof(qmgr_queue_descs[0]), | |
157 | #if DEBUG | 166 | desc_format, name); |
158 | printk(KERN_DEBUG "qmgr: requested queue %i, addr = 0x%02X\n", | 167 | printk(KERN_DEBUG "qmgr: requested queue %s(%i) addr = 0x%02X\n", |
159 | queue, addr); | 168 | qmgr_queue_descs[queue], queue, addr); |
160 | #endif | 169 | #endif |
170 | spin_unlock_irq(&qmgr_lock); | ||
161 | return 0; | 171 | return 0; |
162 | 172 | ||
163 | err: | 173 | err: |
@@ -190,6 +200,11 @@ void qmgr_release_queue(unsigned int queue) | |||
190 | while (addr--) | 200 | while (addr--) |
191 | shift_mask(mask); | 201 | shift_mask(mask); |
192 | 202 | ||
203 | #if DEBUG_QMGR | ||
204 | printk(KERN_DEBUG "qmgr: releasing queue %s(%i)\n", | ||
205 | qmgr_queue_descs[queue], queue); | ||
206 | qmgr_queue_descs[queue][0] = '\x0'; | ||
207 | #endif | ||
193 | __raw_writel(0, &qmgr_regs->sram[queue]); | 208 | __raw_writel(0, &qmgr_regs->sram[queue]); |
194 | 209 | ||
195 | used_sram_bitmap[0] &= ~mask[0]; | 210 | used_sram_bitmap[0] &= ~mask[0]; |
@@ -202,11 +217,8 @@ void qmgr_release_queue(unsigned int queue) | |||
202 | module_put(THIS_MODULE); | 217 | module_put(THIS_MODULE); |
203 | 218 | ||
204 | while ((addr = qmgr_get_entry(queue))) | 219 | while ((addr = qmgr_get_entry(queue))) |
205 | printk(KERN_ERR "qmgr: released queue %d not empty: 0x%08X\n", | 220 | printk(KERN_ERR "qmgr: released queue %i not empty: 0x%08X\n", |
206 | queue, addr); | 221 | queue, addr); |
207 | #if DEBUG | ||
208 | printk(KERN_DEBUG "qmgr: released queue %i\n", queue); | ||
209 | #endif | ||
210 | } | 222 | } |
211 | 223 | ||
212 | static int qmgr_init(void) | 224 | static int qmgr_init(void) |
@@ -277,5 +289,10 @@ EXPORT_SYMBOL(qmgr_regs); | |||
277 | EXPORT_SYMBOL(qmgr_set_irq); | 289 | EXPORT_SYMBOL(qmgr_set_irq); |
278 | EXPORT_SYMBOL(qmgr_enable_irq); | 290 | EXPORT_SYMBOL(qmgr_enable_irq); |
279 | EXPORT_SYMBOL(qmgr_disable_irq); | 291 | EXPORT_SYMBOL(qmgr_disable_irq); |
292 | #if DEBUG_QMGR | ||
293 | EXPORT_SYMBOL(qmgr_queue_descs); | ||
280 | EXPORT_SYMBOL(qmgr_request_queue); | 294 | EXPORT_SYMBOL(qmgr_request_queue); |
295 | #else | ||
296 | EXPORT_SYMBOL(__qmgr_request_queue); | ||
297 | #endif | ||
281 | EXPORT_SYMBOL(qmgr_release_queue); | 298 | EXPORT_SYMBOL(qmgr_release_queue); |