This is the mail archive of the
ecos-patches@sources.redhat.com
mailing list for the eCos project.
RLTK 8139 - better handling of ISR critical sections
- From: Gary Thomas <gary at mlbassoc dot com>
- To: eCos patches <ecos-patches at ecos dot sourceware dot org>
- Date: 21 Nov 2003 10:33:37 -0700
- Subject: RLTK 8139 - better handling of ISR critical sections
- Organization: MLB Associates
Calling cyg_interrupt_enable()/cyg_interrupt_disable() directly should
never be done in drivers.
--
Gary Thomas <gary@mlbassoc.com>
MLB Associates
Index: devs/eth/rltk/8139/current/ChangeLog
===================================================================
RCS file: /misc/cvsfiles/ecos/packages/devs/eth/rltk/8139/current/ChangeLog,v
retrieving revision 1.1
diff -u -5 -p -r1.1 ChangeLog
--- devs/eth/rltk/8139/current/ChangeLog 13 Nov 2003 13:39:08 -0000 1.1
+++ devs/eth/rltk/8139/current/ChangeLog 21 Nov 2003 17:30:25 -0000
@@ -1,5 +1,11 @@
+2003-11-21 Gary Thomas <gary@mlbassoc.com>
+
+ * src/if_8139.c: Use cyg_drv_isr_lock/unlock functions for ISR
+ critical sections - much better than calling cyg_interrupt_enable
+ directly.
+
2003-07-09 Eric Doenges <Eric.Doenges@DynaPel.com>
* src/if_8139.h:
* src/if_8139.c:
* doc/README:
Index: devs/eth/rltk/8139/current/src/if_8139.c
===================================================================
RCS file: /misc/cvsfiles/ecos/packages/devs/eth/rltk/8139/current/src/if_8139.c,v
retrieving revision 1.1
diff -u -5 -p -r1.1 if_8139.c
--- devs/eth/rltk/8139/current/src/if_8139.c 13 Nov 2003 13:39:08 -0000 1.1
+++ devs/eth/rltk/8139/current/src/if_8139.c 21 Nov 2003 17:27:27 -0000
@@ -868,11 +868,10 @@ rltk8139_send(struct eth_drv_sc *sc, str
Rltk8139_t *rltk8139_info;
cyg_uint8 *tx_buffer;
struct eth_drv_sg *last_sg;
int desc;
-
rltk8139_info = (Rltk8139_t *)(sc->driver_private);
#ifdef DEBUG_RLTK8139_DRIVER
diag_printf("rltk8139_send(%s, %08x, %d, %d, %08lx)\n",
sc->dev_name, sg_list, sg_len, total_len, key);
@@ -888,22 +887,18 @@ rltk8139_send(struct eth_drv_sc *sc, str
* IMPORTANT NOTE: the RealTek data sheet does not really make this clear,
* but when they talk about a 'ring' of transmit descriptors, they
* _really_ mean it, i.e. you _must_ use descriptor #1 after descriptor
* #0 even if transmission of descriptor #0 has already completed.
*/
-#ifndef CYGPKG_IO_ETH_DRIVERS_STAND_ALONE
- cyg_interrupt_disable();
-#endif
+ cyg_drv_isr_lock();
/*
* Sanity check to see if '_send' was called even though there is no free
* descriptor. This is probably unnecessary.
*/
if (rltk8139_info->tx_num_free_desc == 0) {
-#ifndef CYGPKG_IO_ETH_DRIVERS_STAND_ALONE
- cyg_interrupt_enable();
-#endif
+ cyg_drv_isr_unlock();
#ifdef DEBUG_RLTK8139_DRIVER
diag_printf("rltk8139_send(%s): no free descriptor available\n",
sc->dev_name);
#endif
return;
@@ -918,14 +913,12 @@ rltk8139_send(struct eth_drv_sc *sc, str
& (NUM_TX_DESC - 1);
/* Decrement the number of free descriptors */
rltk8139_info->tx_num_free_desc -= 1;
-#ifndef CYGPKG_IO_ETH_DRIVERS_STAND_ALONE
/* Reenable interrupts at this point */
- cyg_interrupt_enable();
-#endif
+ cyg_drv_isr_unlock();
/*
* Determine the buffer memory to use and tell the hardware about it.
* Since we use fixed buffer addresses, we do not need to set up TSADx.
* Memorize the key so we can call the tx_done callback correctly.
@@ -1062,28 +1055,23 @@ rltk8139_deliver(struct eth_drv_sc *sc)
* Figure out which descriptors' status must be checked. We lock out
* interrupts while manipulating the descriptor list because we do not
* want to be interrupted at this point.
*/
while (1) {
-#ifndef CYGPKG_IO_ETH_DRIVERS_STAND_ALONE
- cyg_interrupt_disable();
-#endif
+ cyg_drv_isr_lock();
/* Check if all descriptors are ready, in which case we are done. */
if (rltk8139_info->tx_num_free_desc >= NUM_TX_DESC) {
-#ifndef CYGPKG_IO_ETH_DRIVERS_STAND_ALONE
- cyg_interrupt_enable();
-#endif
+ cyg_drv_isr_unlock();
break;
}
desc = (rltk8139_info->tx_free_desc
- (NUM_TX_DESC - rltk8139_info->tx_num_free_desc))
& (NUM_TX_DESC - 1);
-#ifndef CYGPKG_IO_ETH_DRIVERS_STAND_ALONE
- cyg_interrupt_enable();
-#endif
+ cyg_drv_isr_unlock();
+
/* Get the current status of the descriptor */
tsd = INL(rltk8139_info->base_address + TSD0 + (desc<<2));
/*
* If a transmit FIFO underrun occurred, increment the threshold
@@ -1128,17 +1116,13 @@ rltk8139_deliver(struct eth_drv_sc *sc)
/*
* Increment the free descriptor count and go through the loop again
* to see if more descriptors are ready.
*/
-#ifndef CYGPKG_IO_ETH_DRIVERS_STAND_ALONE
- cyg_interrupt_disable();
-#endif
+ cyg_drv_isr_lock();
rltk8139_info->tx_num_free_desc += 1;
-#ifndef CYGPKG_IO_ETH_DRIVERS_STAND_ALONE
- cyg_interrupt_enable();
-#endif
+ cyg_drv_isr_unlock();
}
}
if (status & IR_ROK) {
/*