2005-01-08 17:03:50

by James Nelson

[permalink] [raw]
Subject: [RESEND] [PATCH 0/7] ppc: remove cli()/sti() from arch/ppc/*

This series of patches is to remove the last cli()/sti() function calls in
arch/ppc, and add spinlocks where necessary.

These are the only instances in active code that grep could find.


2005-01-08 17:05:29

by James Nelson

[permalink] [raw]
Subject: [RESEND] [PATCH 2/7] ppc: remove cli()/sti() in arch/ppc/8xx_io/cs4218_tdm.c

Replace save_flags()/resore_flags() with spin_lock_irqsave()/spin_unlock_irqrestore()
and document reasons for locking.

Signed-off-by: James Nelson <[email protected]>

diff -urN --exclude='*~' linux-2.6.10-mm1-original/arch/ppc/8xx_io/cs4218_tdm.c linux-2.6.10-mm1/arch/ppc/8xx_io/cs4218_tdm.c
--- linux-2.6.10-mm1-original/arch/ppc/8xx_io/cs4218_tdm.c 2004-12-24 16:33:51.000000000 -0500
+++ linux-2.6.10-mm1/arch/ppc/8xx_io/cs4218_tdm.c 2005-01-07 19:46:23.267111848 -0500
@@ -55,6 +55,8 @@
static char **sound_buffers = NULL;
static char **sound_read_buffers = NULL;

+static spinlock_t cs4218_lock = SPIN_LOCK_UNLOCKED;
+
/* Local copies of things we put in the control register. Output
* volume, like most codecs is really attenuation.
*/
@@ -1206,7 +1208,8 @@
volatile cbd_t *bdp;
volatile cpm8xx_t *cp;

- save_flags(flags); cli();
+ /* Protect buffer */
+ spin_lock_irqsave(&cs4218_lock, flags);
#if 0
if (awacs_beep_state) {
/* sound takes precedence over beeps */
@@ -1263,7 +1266,7 @@

++sq.active;
}
- restore_flags(flags);
+ spin_unlock_irqrestore(&cs4218_lock, flags);
}


@@ -1275,7 +1278,8 @@
if (read_sq.active)
return;

- save_flags(flags); cli();
+ /* Protect buffer */
+ spin_lock_irqsave(&cs4218_lock, flags);

/* This is all we have to do......Just start it up.
*/
@@ -1284,7 +1288,7 @@

read_sq.active = 1;

- restore_flags(flags);
+ spin_unlock_irqrestore(&cs4218_lock, flags);
}


@@ -1365,14 +1369,15 @@
{
unsigned long flags;

- save_flags(flags); cli();
+ /* not sure if this is needed, since hardware command is #if 0'd */
+ spin_lock_irqsave(&cs4218_lock, flags);
if (beep_playing) {
#if 0
st_le16(&beep_dbdma_cmd->command, DBDMA_STOP);
#endif
beep_playing = 0;
}
- restore_flags(flags);
+ spin_unlock_irqrestore(&cs4218_lock, flags);
}

static struct timer_list beep_timer = TIMER_INITIALIZER(cs_nosound, 0, 0);
@@ -1401,21 +1406,22 @@
return;
#endif
}
- save_flags(flags); cli();
+ /* lock while modifying beep_timer */
+ spin_lock_irqsave(&cs4218_lock, flags);
del_timer(&beep_timer);
if (ticks) {
beep_timer.expires = jiffies + ticks;
add_timer(&beep_timer);
}
if (beep_playing || sq.active || beep_buf == NULL) {
- restore_flags(flags);
+ spin_unlock_irqrestore(&cs4218_lock, flags);
return; /* too hard, sorry :-( */
}
beep_playing = 1;
#if 0
st_le16(&beep_dbdma_cmd->command, OUTPUT_MORE + BR_ALWAYS);
#endif
- restore_flags(flags);
+ spin_unlock_irqrestore(&cs4218_lock, flags);

if (hz == beep_hz_cache && beep_volume == beep_volume_cache) {
nsamples = beep_nsamples_cache;
@@ -1442,7 +1448,7 @@
st_le32(&beep_dbdma_cmd->phy_addr, virt_to_bus(beep_buf));
awacs_beep_state = 1;

- save_flags(flags); cli();
+ spin_lock_irqsave(&cs4218_lock, flags);
if (beep_playing) { /* i.e. haven't been terminated already */
out_le32(&awacs_txdma->control, (RUN|WAKE|FLUSH|PAUSE) << 16);
out_le32(&awacs->control,
@@ -1452,8 +1458,8 @@
out_le32(&awacs_txdma->cmdptr, virt_to_bus(beep_dbdma_cmd));
out_le32(&awacs_txdma->control, RUN | (RUN << 16));
}
+ spin_unlock_irqrestore(&cs4218_lock, flags);
#endif
- restore_flags(flags);
}

static MACHINE mach_cs4218 = {

2005-01-08 17:04:53

by James Nelson

[permalink] [raw]
Subject: [RESEND] [PATCH 1/7] ppc: remove cli()/sti() in arch/ppc/4xx_io/serial_sicc.c

Replace save_flags()/restore_flags() with spin_lock_irqsave()/spin_unlock_irqrestore()
and document reasons for using spinlocks.

Signed-off-by: James Nelson <[email protected]>

diff -urN --exclude='*~' linux-2.6.10-mm1-original/arch/ppc/4xx_io/serial_sicc.c linux-2.6.10-mm1/arch/ppc/4xx_io/serial_sicc.c
--- linux-2.6.10-mm1-original/arch/ppc/4xx_io/serial_sicc.c 2004-12-24 16:33:49.000000000 -0500
+++ linux-2.6.10-mm1/arch/ppc/4xx_io/serial_sicc.c 2005-01-07 19:12:42.043984196 -0500
@@ -264,6 +264,7 @@
unsigned int flags;
int count;
struct SICC_info *info;
+ spinlock_t sicc_lock;
};

#define SICC_XMIT_SIZE 1024
@@ -385,9 +386,10 @@
struct SICC_info *info = tty->driver_data;
unsigned long flags;

- save_flags(flags); cli();
+ /* disable interrupts while stopping serial port interrupts */
+ spin_lock_irqsave(&info->state->sicc_lock,flags);
siccuart_disable_tx_interrupt(info);
- restore_flags(flags);
+ spin_unlock_irqrestore(&info->state->sicc_lock,flags);
}

static void siccuart_start(struct tty_struct *tty)
@@ -395,11 +397,12 @@
struct SICC_info *info = tty->driver_data;
unsigned long flags;

- save_flags(flags); cli();
+ /* disable interrupts while starting serial port interrupts */
+ spin_lock_irqsave(&info->state->sicc_lock,flags);
if (info->xmit.head != info->xmit.tail
&& info->xmit.buf)
siccuart_enable_tx_interrupt(info);
- restore_flags(flags);
+ spin_unlock_irqrestore(&info->state->sicc_lock,flags);
}


@@ -604,7 +607,8 @@
return -ENOMEM;
}

- save_flags(flags); cli();
+ /* lock access to info while doing setup */
+ spin_lock_irqsave(&info->state->sicc_lock,flags);

if (info->xmit.buf)
free_page(page);
@@ -688,12 +692,12 @@
siccuart_enable_rx_interrupt(info);

info->flags |= ASYNC_INITIALIZED;
- restore_flags(flags);
+ spin_unlock_irqrestore(&info->state->sicc_lock,flags);
return 0;


errout:
- restore_flags(flags);
+ spin_unlock_irqrestore(&info->state->sicc_lock,flags);
return retval;
}

@@ -708,7 +712,8 @@
if (!(info->flags & ASYNC_INITIALIZED))
return;

- save_flags(flags); cli(); /* Disable interrupts */
+ /* lock while shutting down port */
+ spin_lock_irqsave(&info->state->sicc_lock,flags); /* Disable interrupts */

/*
* clear delta_msr_wait queue to avoid mem leaks: we may free the irq
@@ -746,7 +751,7 @@

info->flags &= ~ASYNC_INITIALIZED;

- restore_flags(flags);
+ spin_unlock_irqrestore(&info->state->sicc_lock,flags);
}


@@ -868,8 +873,8 @@
info->ignore_status_mask |= _LSR_OE_MASK;
}

- /* first, disable everything */
- save_flags(flags); cli();
+ /* disable interrupts while reading and clearing registers */
+ spin_lock_irqsave(&info->state->sicc_lock,flags);

old_rcr = readb(info->port->uart_base + BL_SICC_RCR);
old_tcr = readb(info->port->uart_base + BL_SICC_TxCR);
@@ -881,7 +886,7 @@
/*RLBtrace (&ppc403Chan0, 0x2000000c, 0, 0);*/


- restore_flags(flags);
+ spin_unlock_irqrestore(&info->state->sicc_lock,flags);


/* Set baud rate */
@@ -909,12 +914,13 @@
if (!tty || !info->xmit.buf)
return;

- save_flags(flags); cli();
+ /* lock info->xmit while adding character to tx buffer */
+ spin_lock_irqsave(&info->state->sicc_lock,flags);
if (CIRC_SPACE(info->xmit.head, info->xmit.tail, SICC_XMIT_SIZE) != 0) {
info->xmit.buf[info->xmit.head] = ch;
info->xmit.head = (info->xmit.head + 1) & (SICC_XMIT_SIZE - 1);
}
- restore_flags(flags);
+ spin_unlock_irqrestore(&info->state->sicc_lock,flags);
}

static void siccuart_flush_chars(struct tty_struct *tty)
@@ -928,9 +934,10 @@
|| !info->xmit.buf)
return;

- save_flags(flags); cli();
+ /* disable interrupts while transmitting characters */
+ spin_lock_irqsave(&info->state->sicc_lock,flags);
siccuart_enable_tx_interrupt(info);
- restore_flags(flags);
+ spin_unlock_irqrestore(&info->state->sicc_lock,flags);
}

static int siccuart_write(struct tty_struct *tty,
@@ -943,8 +950,8 @@
if (!tty || !info->xmit.buf || !tmp_buf)
return 0;

- save_flags(flags);
- cli();
+ /* lock info->xmit while removing characters from buffer */
+ spin_lock_irqsave(&info->state->sicc_lock,flags);
while (1) {
c = CIRC_SPACE_TO_END(info->xmit.head,
info->xmit.tail,
@@ -960,11 +967,11 @@
count -= c;
ret += c;
}
- restore_flags(flags);
if (info->xmit.head != info->xmit.tail
&& !tty->stopped
&& !tty->hw_stopped)
siccuart_enable_tx_interrupt(info);
+ spin_unlock_irqrestore(&info->state->sicc_lock,flags);
return ret;
}

@@ -988,9 +995,10 @@
unsigned long flags;

pr_debug("siccuart_flush_buffer(%d) called\n", tty->index);
- save_flags(flags); cli();
+ /* lock info->xmit while zeroing buffer counts */
+ spin_lock_irqsave(&info->state->sicc_lock,flags);
info->xmit.head = info->xmit.tail = 0;
- restore_flags(flags);
+ spin_unlock_irqrestore(&info->state->sicc_lock,flags);
wake_up_interruptible(&tty->write_wait);
if ((tty->flags & (1 << TTY_DO_WRITE_WAKEUP)) &&
tty->ldisc.write_wakeup)
@@ -1019,10 +1027,11 @@
siccuart_send_xchar(tty, STOP_CHAR(tty));

if (tty->termios->c_cflag & CRTSCTS) {
- save_flags(flags); cli();
+ /* disable interrupts while setting modem control lines */
+ spin_lock_irqsave(&info->state->sicc_lock,flags);
info->mctrl &= ~TIOCM_RTS;
info->port->set_mctrl(info->port, info->mctrl);
- restore_flags(flags);
+ spin_unlock_irqrestore(&info->state->sicc_lock,flags);
}
}

@@ -1039,10 +1048,11 @@
}

if (tty->termios->c_cflag & CRTSCTS) {
- save_flags(flags); cli();
+ /* disable interrupts while setting modem control lines */
+ spin_lock_irqsave(&info->state->sicc_lock,flags);
info->mctrl |= TIOCM_RTS;
info->port->set_mctrl(info->port, info->mctrl);
- restore_flags(flags);
+ spin_unlock_irqrestore(&info->state->sicc_lock,flags);
}
}

@@ -1181,9 +1191,10 @@
unsigned int result, status;
unsigned long flags;

- save_flags(flags); cli();
+ /* disable interrupts while reading status from port */
+ spin_lock_irqsave(&info->state->sicc_lock,flags);
status = readb(info->port->uart_base + BL_SICC_LSR);
- restore_flags(flags);
+ spin_unlock_irqrestore(&info->state->sicc_lock,flags);
result = status & _LSR_TSR_EMPTY ? TIOCSER_TEMT : 0;

/*
@@ -1234,10 +1245,11 @@
default:
return -EINVAL;
}
- save_flags(flags); cli();
+ /* disable interrupts while setting modem control lines */
+ spin_lock_irqsave(&info->state->sicc_lock,flags);
if (old != info->mctrl)
info->port->set_mctrl(info->port, info->mctrl);
- restore_flags(flags);
+ spin_unlock_irqrestore(&info->state->sicc_lock,flags);
return 0;
}

@@ -1248,14 +1260,15 @@
unsigned int lcr_h;


- save_flags(flags); cli();
+ /* disable interrupts while setting break state */
+ spin_lock_irqsave(&info->state->sicc_lock,flags);
lcr_h = readb(info->port + BL_SICC_LSR);
if (break_state == -1)
lcr_h |= _LSR_LB_MASK;
else
lcr_h &= ~_LSR_LB_MASK;
writeb(lcr_h, info->port + BL_SICC_LSRS);
- restore_flags(flags);
+ spin_unlock_irqrestore(&info->state->sicc_lock,flags);
}

static int siccuart_ioctl(struct tty_struct *tty, struct file *file,
@@ -1303,9 +1316,10 @@
* RI where only 0->1 is counted.
*/
case TIOCGICOUNT:
- save_flags(flags); cli();
+ /* disable interrupts while getting interrupt count */
+ spin_lock_irqsave(&info->state->sicc_lock,flags);
cnow = info->state->icount;
- restore_flags(flags);
+ spin_unlock_irqrestore(&info->state->sicc_lock,flags);
icount.cts = cnow.cts;
icount.dsr = cnow.dsr;
icount.rng = cnow.rng;
@@ -1342,22 +1356,24 @@
/* Handle transition to B0 status */
if ((old_termios->c_cflag & CBAUD) &&
!(cflag & CBAUD)) {
- save_flags(flags); cli();
+ /* disable interrupts while setting break state */
+ spin_lock_irqsave(&info->state->sicc_lock,flags);
info->mctrl &= ~(TIOCM_RTS | TIOCM_DTR);
info->port->set_mctrl(info->port, info->mctrl);
- restore_flags(flags);
+ spin_unlock_irqrestore(&info->state->sicc_lock,flags);
}

/* Handle transition away from B0 status */
if (!(old_termios->c_cflag & CBAUD) &&
(cflag & CBAUD)) {
- save_flags(flags); cli();
+ /* disable interrupts while setting break state */
+ spin_lock_irqsave(&info->state->sicc_lock,flags);
info->mctrl |= TIOCM_DTR;
if (!(cflag & CRTSCTS) ||
!test_bit(TTY_THROTTLED, &tty->flags))
info->mctrl |= TIOCM_RTS;
info->port->set_mctrl(info->port, info->mctrl);
- restore_flags(flags);
+ spin_unlock_irqrestore(&info->state->sicc_lock,flags);
}

/* Handle turning off CRTSCTS */
@@ -1393,11 +1409,11 @@

//pr_debug("siccuart_close() called\n");

- save_flags(flags); cli();
+ /* lock tty->driver_data while closing port */
+ spin_lock_irqsave(&info->state->sicc_lock,flags);

if (tty_hung_up_p(filp)) {
- restore_flags(flags);
- return;
+ goto quick_close;
}

if ((tty->count == 1) && (state->count != 1)) {
@@ -1416,11 +1432,10 @@
state->count = 0;
}
if (state->count) {
- restore_flags(flags);
- return;
+ goto quick_close;
}
info->flags |= ASYNC_CLOSING;
- restore_flags(flags);
+ spin_unlock_irqrestore(&info->state->sicc_lock,flags);
/*
* Now we wait for the transmit buffer to clear; and we notify
* the line discipline to only process XON/XOFF characters.
@@ -1458,6 +1473,11 @@
}
info->flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CLOSING);
wake_up_interruptible(&info->close_wait);
+ return;
+
+quick_close:
+ spin_unlock_irqrestore(&info->state->sicc_lock,flags);
+ return;
}

static void siccuart_wait_until_sent(struct tty_struct *tty, int timeout)
@@ -1569,20 +1589,22 @@
*/
retval = 0;
add_wait_queue(&info->open_wait, &wait);
- save_flags(flags); cli();
+ /* lock while decrementing state->count */
+ spin_lock_irqsave(&info->state->sicc_lock,flags);
if (!tty_hung_up_p(filp)) {
extra_count = 1;
state->count--;
}
- restore_flags(flags);
+ spin_unlock_irqrestore(&info->state->sicc_lock,flags);
info->blocked_open++;
while (1) {
- save_flags(flags); cli();
+ /* disable interrupts while setting modem control lines */
+ spin_lock_irqsave(&info->state->sicc_lock,flags);
if (tty->termios->c_cflag & CBAUD) {
info->mctrl = TIOCM_DTR | TIOCM_RTS;
info->port->set_mctrl(info->port, info->mctrl);
}
- restore_flags(flags);
+ spin_unlock_irqrestore(&info->state->sicc_lock,flags);
set_current_state(TASK_INTERRUPTIBLE);
if (tty_hung_up_p(filp) ||
!(info->flags & ASYNC_INITIALIZED)) {
@@ -1753,6 +1775,7 @@
state->line = i;
state->close_delay = 5 * HZ / 10;
state->closing_wait = 30 * HZ;
+ spin_lock_init(&state->sicc_lock);
}


2005-01-08 17:08:46

by James Nelson

[permalink] [raw]
Subject: [RESEND] [PATCH 7/7] ppc: remove cli()/sti() in arch/ppc/syslib/qspan_pci.c

Replace save_flags()/resore_flags() with spin_lock_irqsave()/spin_unlock_irqrestore()
and document reasons for locking.

Signed-off-by: James Nelson <[email protected]>

diff -urN --exclude='*~' linux-2.6.10-mm1-original/arch/ppc/syslib/qspan_pci.c linux-2.6.10-mm1/arch/ppc/syslib/qspan_pci.c
--- linux-2.6.10-mm1-original/arch/ppc/syslib/qspan_pci.c 2004-12-24 16:34:26.000000000 -0500
+++ linux-2.6.10-mm1/arch/ppc/syslib/qspan_pci.c 2005-01-07 19:47:51.355219639 -0500
@@ -94,6 +94,8 @@
#define mk_config_type1(bus, dev, offset) \
mk_config_addr(bus, dev, offset) | 1;

+static spinlock_t pcibios_lock = SPIN_LOCK_UNLOCKED;
+
int qspan_pcibios_read_config_byte(unsigned char bus, unsigned char dev_fn,
unsigned char offset, unsigned char *val)
{
@@ -109,8 +111,8 @@
}

#ifdef CONFIG_RPXCLASSIC
- save_flags(flags);
- cli();
+ /* disable interrupts */
+ spin_lock_irqsave(&pcibios_lock, flags);
*((uint *)RPX_CSR_ADDR) &= ~BCSR2_QSPACESEL;
eieio();
#endif
@@ -124,7 +126,7 @@
#ifdef CONFIG_RPXCLASSIC
*((uint *)RPX_CSR_ADDR) |= BCSR2_QSPACESEL;
eieio();
- restore_flags(flags);
+ spin_unlock_irqrestore(&pcibios_lock, flags);
#endif

offset ^= 0x03;
@@ -148,8 +150,8 @@
}

#ifdef CONFIG_RPXCLASSIC
- save_flags(flags);
- cli();
+ /* disable interrupts */
+ spin_lock_irqsave(&pcibios_lock, flags);
*((uint *)RPX_CSR_ADDR) &= ~BCSR2_QSPACESEL;
eieio();
#endif
@@ -164,7 +166,7 @@
#ifdef CONFIG_RPXCLASSIC
*((uint *)RPX_CSR_ADDR) |= BCSR2_QSPACESEL;
eieio();
- restore_flags(flags);
+ spin_unlock_irqrestore(&pcibios_lock, flags);
#endif

sp = ((ushort *)&temp) + ((offset >> 1) & 1);
@@ -185,8 +187,8 @@
}

#ifdef CONFIG_RPXCLASSIC
- save_flags(flags);
- cli();
+ /* disable interrupts */
+ spin_lock_irqsave(&pcibios_lock, flags);
*((uint *)RPX_CSR_ADDR) &= ~BCSR2_QSPACESEL;
eieio();
#endif
@@ -200,7 +202,7 @@
#ifdef CONFIG_RPXCLASSIC
*((uint *)RPX_CSR_ADDR) |= BCSR2_QSPACESEL;
eieio();
- restore_flags(flags);
+ spin_unlock_irqrestore(&pcibios_lock, flags);
#endif

return PCIBIOS_SUCCESSFUL;
@@ -225,8 +227,8 @@
*cp = val;

#ifdef CONFIG_RPXCLASSIC
- save_flags(flags);
- cli();
+ /* disable interrupts */
+ spin_lock_irqsave(&pcibios_lock, flags);
*((uint *)RPX_CSR_ADDR) &= ~BCSR2_QSPACESEL;
eieio();
#endif
@@ -240,7 +242,7 @@
#ifdef CONFIG_RPXCLASSIC
*((uint *)RPX_CSR_ADDR) |= BCSR2_QSPACESEL;
eieio();
- restore_flags(flags);
+ spin_unlock_irqrestore(&pcibios_lock, flags);
#endif

return PCIBIOS_SUCCESSFUL;
@@ -265,8 +267,8 @@
*sp = val;

#ifdef CONFIG_RPXCLASSIC
- save_flags(flags);
- cli();
+ /* disable interrupts */
+ spin_lock_irqsave(&pcibios_lock, flags);
*((uint *)RPX_CSR_ADDR) &= ~BCSR2_QSPACESEL;
eieio();
#endif
@@ -280,7 +282,7 @@
#ifdef CONFIG_RPXCLASSIC
*((uint *)RPX_CSR_ADDR) |= BCSR2_QSPACESEL;
eieio();
- restore_flags(flags);
+ spin_unlock_irqrestore(&pcibios_lock, flags);
#endif

return PCIBIOS_SUCCESSFUL;
@@ -297,8 +299,8 @@
return PCIBIOS_DEVICE_NOT_FOUND;

#ifdef CONFIG_RPXCLASSIC
- save_flags(flags);
- cli();
+ /* disable interrupts */
+ spin_lock_irqsave(&pcibios_lock, flags);
*((uint *)RPX_CSR_ADDR) &= ~BCSR2_QSPACESEL;
eieio();
#endif
@@ -312,7 +314,7 @@
#ifdef CONFIG_RPXCLASSIC
*((uint *)RPX_CSR_ADDR) |= BCSR2_QSPACESEL;
eieio();
- restore_flags(flags);
+ spin_unlock_irqrestore(&pcibios_lock, flags);
#endif

return PCIBIOS_SUCCESSFUL;

2005-01-08 17:08:47

by James Nelson

[permalink] [raw]
Subject: [RESEND] [PATCH 6/7] ppc: remove cli()/sti() in arch/ppc/syslib/m8xx_setup.c

Replace cli() function call with local_irq_disable() in shutdown code.

Signed-off-by: James Nelson <[email protected]>

diff -urN --exclude='*~' linux-2.6.10-mm1-original/arch/ppc/syslib/m8xx_setup.c linux-2.6.10-mm1/arch/ppc/syslib/m8xx_setup.c
--- linux-2.6.10-mm1-original/arch/ppc/syslib/m8xx_setup.c 2004-12-24 16:34:32.000000000 -0500
+++ linux-2.6.10-mm1/arch/ppc/syslib/m8xx_setup.c 2005-01-03 19:26:53.224307353 -0500
@@ -238,7 +238,7 @@
{
__volatile__ unsigned char dummy;

- cli();
+ local_irq_disable();
((immap_t *)IMAP_ADDR)->im_clkrst.car_plprcr |= 0x00000080;

/* Clear the ME bit in MSR to cause checkstop on machine check

2005-01-08 17:13:12

by James Nelson

[permalink] [raw]
Subject: [RESEND] [PATCH 3/7] ppc: remove cli()/sti() in arch/ppc/8xx_io/fec.c

Replace save_flags()/resore_flags() with spin_lock_irqsave()/spin_unlock_irqrestore()
and document reasons for locking.

Signed-off-by: James Nelson <[email protected]>

diff -urN --exclude='*~' linux-2.6.10-mm1-original/arch/ppc/8xx_io/fec.c linux-2.6.10-mm1/arch/ppc/8xx_io/fec.c
--- linux-2.6.10-mm1-original/arch/ppc/8xx_io/fec.c 2004-12-24 16:35:28.000000000 -0500
+++ linux-2.6.10-mm1/arch/ppc/8xx_io/fec.c 2005-01-07 19:58:55.806516338 -0500
@@ -389,6 +389,7 @@
flush_dcache_range((unsigned long)skb->data,
(unsigned long)skb->data + skb->len);

+ /* disable interrupts while triggering transmit */
spin_lock_irq(&fep->lock);

/* Send it on its way. Tell FEC its ready, interrupt when done,
@@ -539,6 +540,7 @@
struct sk_buff *skb;

fep = dev->priv;
+ /* lock while transmitting */
spin_lock(&fep->lock);
bdp = fep->dirty_tx;

@@ -799,6 +801,7 @@

if ((mip = mii_head) != NULL) {
ep->fec_mii_data = mip->mii_regval;
+
}
}

@@ -817,8 +820,8 @@

retval = 0;

- save_flags(flags);
- cli();
+ /* lock while modifying mii_list */
+ spin_lock_irqsave(&fep->lock, flags);

if ((mip = mii_free) != NULL) {
mii_free = mip->mii_next;
@@ -836,7 +839,7 @@
retval = 1;
}

- restore_flags(flags);
+ spin_unlock_irqrestore(&fep->lock, flags);

return(retval);
}

2005-01-08 17:13:11

by James Nelson

[permalink] [raw]
Subject: [RESEND] [PATCH 5/7] ppc: remove cli()/sti() in arch/ppc/platforms/pal4_setup.c

Replace cli() function calls with local_irq_disable() in shutdown/restart code.

Signed-off-by: James Nelson <[email protected]>

diff -urN --exclude='*~' linux-2.6.10-mm1-original/arch/ppc/platforms/pal4_setup.c linux-2.6.10-mm1/arch/ppc/platforms/pal4_setup.c
--- linux-2.6.10-mm1-original/arch/ppc/platforms/pal4_setup.c 2004-12-24 16:35:28.000000000 -0500
+++ linux-2.6.10-mm1/arch/ppc/platforms/pal4_setup.c 2005-01-03 19:49:42.123501068 -0500
@@ -81,7 +81,7 @@
static void
pal4_restart(char *cmd)
{
- __cli();
+ local_irq_disable();
__asm__ __volatile__("lis 3,0xfff0\n \
ori 3,3,0x100\n \
mtspr 26,3\n \
@@ -95,7 +95,7 @@
static void
pal4_power_off(void)
{
- __cli();
+ local_irq_disable();
for(;;);
}

2005-01-08 17:13:11

by James Nelson

[permalink] [raw]
Subject: [RESEND] [PATCH 4/7] ppc: remove cli()/sti() in arch/ppc/platforms/apus_setup.c

Replace cli() function call with local_irq_disable() in restart code.

Signed-off-by: James Nelson <[email protected]>

diff -urN --exclude='*~' linux-2.6.10-mm1-original/arch/ppc/platforms/apus_setup.c linux-2.6.10-mm1/arch/ppc/platforms/apus_setup.c
--- linux-2.6.10-mm1-original/arch/ppc/platforms/apus_setup.c 2004-12-24 16:34:58.000000000 -0500
+++ linux-2.6.10-mm1/arch/ppc/platforms/apus_setup.c 2005-01-03 19:29:40.720694742 -0500
@@ -480,7 +480,7 @@
void
apus_restart(char *cmd)
{
- cli();
+ local_irq_disable();

APUS_WRITE(APUS_REG_LOCK,
REGLOCK_BLACKMAGICK1|REGLOCK_BLACKMAGICK2);

2005-01-10 14:52:45

by Marcelo Tosatti

[permalink] [raw]
Subject: Re: [RESEND] [PATCH 3/7] ppc: remove cli()/sti() in arch/ppc/8xx_io/fec.c


Looks OK to me.

Dan, Tom, this should be applied to the linuxppc-2.5 IMO.

On Sat, Jan 08, 2005 at 11:04:15AM -0600, James Nelson wrote:
> Replace save_flags()/resore_flags() with spin_lock_irqsave()/spin_unlock_irqrestore()
> and document reasons for locking.
>
> Signed-off-by: James Nelson <[email protected]>
>
> diff -urN --exclude='*~' linux-2.6.10-mm1-original/arch/ppc/8xx_io/fec.c linux-2.6.10-mm1/arch/ppc/8xx_io/fec.c
> --- linux-2.6.10-mm1-original/arch/ppc/8xx_io/fec.c 2004-12-24 16:35:28.000000000 -0500
> +++ linux-2.6.10-mm1/arch/ppc/8xx_io/fec.c 2005-01-07 19:58:55.806516338 -0500
> @@ -389,6 +389,7 @@
> flush_dcache_range((unsigned long)skb->data,
> (unsigned long)skb->data + skb->len);
>
> + /* disable interrupts while triggering transmit */
> spin_lock_irq(&fep->lock);
>
> /* Send it on its way. Tell FEC its ready, interrupt when done,
> @@ -539,6 +540,7 @@
> struct sk_buff *skb;
>
> fep = dev->priv;
> + /* lock while transmitting */
> spin_lock(&fep->lock);
> bdp = fep->dirty_tx;
>
> @@ -799,6 +801,7 @@
>
> if ((mip = mii_head) != NULL) {
> ep->fec_mii_data = mip->mii_regval;
> +
> }
> }
>
> @@ -817,8 +820,8 @@
>
> retval = 0;
>
> - save_flags(flags);
> - cli();
> + /* lock while modifying mii_list */
> + spin_lock_irqsave(&fep->lock, flags);
>
> if ((mip = mii_free) != NULL) {
> mii_free = mip->mii_next;
> @@ -836,7 +839,7 @@
> retval = 1;
> }
>
> - restore_flags(flags);
> + spin_unlock_irqrestore(&fep->lock, flags);
>
> return(retval);
> }

2005-01-11 22:49:50

by Tom Rini

[permalink] [raw]
Subject: Re: [RESEND] [PATCH 0/7] ppc: remove cli()/sti() from arch/ppc/*

On Sat, Jan 08, 2005 at 11:03:49AM -0600, James Nelson wrote:

> This series of patches is to remove the last cli()/sti() function calls in
> arch/ppc, and add spinlocks where necessary.

I'll push this to Andrew and hope they move from there, thanks.

--
Tom Rini
http://gate.crashing.org/~trini/