@@ -65,14 +65,6 @@ struct omap_mbox_fifo {
65
65
u32 intr_bit ;
66
66
};
67
67
68
- struct omap_mbox_queue {
69
- spinlock_t lock ;
70
- struct kfifo fifo ;
71
- struct work_struct work ;
72
- struct omap_mbox * mbox ;
73
- bool full ;
74
- };
75
-
76
68
struct omap_mbox_match_data {
77
69
u32 intr_type ;
78
70
};
@@ -90,7 +82,6 @@ struct omap_mbox_device {
90
82
struct omap_mbox {
91
83
const char * name ;
92
84
int irq ;
93
- struct omap_mbox_queue * rxq ;
94
85
struct omap_mbox_device * parent ;
95
86
struct omap_mbox_fifo tx_fifo ;
96
87
struct omap_mbox_fifo rx_fifo ;
@@ -99,10 +90,6 @@ struct omap_mbox {
99
90
bool send_no_irq ;
100
91
};
101
92
102
- static unsigned int mbox_kfifo_size = CONFIG_OMAP_MBOX_KFIFO_SIZE ;
103
- module_param (mbox_kfifo_size , uint , S_IRUGO );
104
- MODULE_PARM_DESC (mbox_kfifo_size , "Size of omap's mailbox kfifo (bytes)" );
105
-
106
93
static inline
107
94
unsigned int mbox_read_reg (struct omap_mbox_device * mdev , size_t ofs )
108
95
{
@@ -202,30 +189,6 @@ static void omap_mbox_disable_irq(struct omap_mbox *mbox, omap_mbox_irq_t irq)
202
189
mbox_write_reg (mbox -> parent , bit , irqdisable );
203
190
}
204
191
205
- /*
206
- * Message receiver(workqueue)
207
- */
208
- static void mbox_rx_work (struct work_struct * work )
209
- {
210
- struct omap_mbox_queue * mq =
211
- container_of (work , struct omap_mbox_queue , work );
212
- u32 msg ;
213
- int len ;
214
-
215
- while (kfifo_len (& mq -> fifo ) >= sizeof (msg )) {
216
- len = kfifo_out (& mq -> fifo , (unsigned char * )& msg , sizeof (msg ));
217
- WARN_ON (len != sizeof (msg ));
218
-
219
- mbox_chan_received_data (mq -> mbox -> chan , (void * )(uintptr_t )msg );
220
- spin_lock_irq (& mq -> lock );
221
- if (mq -> full ) {
222
- mq -> full = false;
223
- omap_mbox_enable_irq (mq -> mbox , IRQ_RX );
224
- }
225
- spin_unlock_irq (& mq -> lock );
226
- }
227
- }
228
-
229
192
/*
230
193
* Mailbox interrupt handler
231
194
*/
@@ -238,27 +201,15 @@ static void __mbox_tx_interrupt(struct omap_mbox *mbox)
238
201
239
202
static void __mbox_rx_interrupt (struct omap_mbox * mbox )
240
203
{
241
- struct omap_mbox_queue * mq = mbox -> rxq ;
242
204
u32 msg ;
243
- int len ;
244
205
245
206
while (!mbox_fifo_empty (mbox )) {
246
- if (unlikely (kfifo_avail (& mq -> fifo ) < sizeof (msg ))) {
247
- omap_mbox_disable_irq (mbox , IRQ_RX );
248
- mq -> full = true;
249
- goto nomem ;
250
- }
251
-
252
207
msg = mbox_fifo_read (mbox );
253
-
254
- len = kfifo_in (& mq -> fifo , (unsigned char * )& msg , sizeof (msg ));
255
- WARN_ON (len != sizeof (msg ));
208
+ mbox_chan_received_data (mbox -> chan , (void * )(uintptr_t )msg );
256
209
}
257
210
258
- /* no more messages in the fifo. clear IRQ source. */
211
+ /* clear IRQ source. */
259
212
ack_mbox_irq (mbox , IRQ_RX );
260
- nomem :
261
- schedule_work (& mbox -> rxq -> work );
262
213
}
263
214
264
215
static irqreturn_t mbox_interrupt (int irq , void * p )
@@ -274,57 +225,15 @@ static irqreturn_t mbox_interrupt(int irq, void *p)
274
225
return IRQ_HANDLED ;
275
226
}
276
227
277
- static struct omap_mbox_queue * mbox_queue_alloc (struct omap_mbox * mbox ,
278
- void (* work )(struct work_struct * ))
279
- {
280
- struct omap_mbox_queue * mq ;
281
- unsigned int size ;
282
-
283
- if (!work )
284
- return NULL ;
285
-
286
- mq = kzalloc (sizeof (* mq ), GFP_KERNEL );
287
- if (!mq )
288
- return NULL ;
289
-
290
- spin_lock_init (& mq -> lock );
291
-
292
- /* kfifo size sanity check: alignment and minimal size */
293
- size = ALIGN (mbox_kfifo_size , sizeof (u32 ));
294
- size = max_t (unsigned int , size , sizeof (u32 ));
295
- if (kfifo_alloc (& mq -> fifo , size , GFP_KERNEL ))
296
- goto error ;
297
-
298
- INIT_WORK (& mq -> work , work );
299
- return mq ;
300
-
301
- error :
302
- kfree (mq );
303
- return NULL ;
304
- }
305
-
306
- static void mbox_queue_free (struct omap_mbox_queue * q )
307
- {
308
- kfifo_free (& q -> fifo );
309
- kfree (q );
310
- }
311
-
312
228
static int omap_mbox_startup (struct omap_mbox * mbox )
313
229
{
314
230
int ret = 0 ;
315
- struct omap_mbox_queue * mq ;
316
-
317
- mq = mbox_queue_alloc (mbox , mbox_rx_work );
318
- if (!mq )
319
- return - ENOMEM ;
320
- mbox -> rxq = mq ;
321
- mq -> mbox = mbox ;
322
231
323
- ret = request_irq (mbox -> irq , mbox_interrupt , IRQF_SHARED ,
324
- mbox -> name , mbox );
232
+ ret = request_threaded_irq (mbox -> irq , NULL , mbox_interrupt ,
233
+ IRQF_ONESHOT , mbox -> name , mbox );
325
234
if (unlikely (ret )) {
326
235
pr_err ("failed to register mailbox interrupt:%d\n" , ret );
327
- goto fail_request_irq ;
236
+ return ret ;
328
237
}
329
238
330
239
if (mbox -> send_no_irq )
@@ -333,18 +242,12 @@ static int omap_mbox_startup(struct omap_mbox *mbox)
333
242
omap_mbox_enable_irq (mbox , IRQ_RX );
334
243
335
244
return 0 ;
336
-
337
- fail_request_irq :
338
- mbox_queue_free (mbox -> rxq );
339
- return ret ;
340
245
}
341
246
342
247
static void omap_mbox_fini (struct omap_mbox * mbox )
343
248
{
344
249
omap_mbox_disable_irq (mbox , IRQ_RX );
345
250
free_irq (mbox -> irq , mbox );
346
- flush_work (& mbox -> rxq -> work );
347
- mbox_queue_free (mbox -> rxq );
348
251
}
349
252
350
253
static int omap_mbox_chan_startup (struct mbox_chan * chan )
0 commit comments