diff options
author | Alan Cox <alan@linux.intel.com> | 2010-06-01 16:52:41 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2010-08-10 16:47:40 -0400 |
commit | b4eda9cb48eac1b7369ad33e5d015c33b4376431 (patch) | |
tree | 0faa2f1af52804731765b3793436c0b00956fe2e /drivers | |
parent | 8fd4bd22350784d5b2fe9274f6790ba353976415 (diff) |
stallion: prune lock_kernel calls
Remove unneeded tty layer lock kernel bits. Relock the needed bits using the
port mutex. The istallion still has brd state races but those are not new
or introduced by the removal of the lock_kernel logic.
Signed-off-by: Alan Cox <alan@linux.intel.com>
Cc: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/char/istallion.c | 22 | ||||
-rw-r--r-- | drivers/char/stallion.c | 20 |
2 files changed, 25 insertions, 17 deletions
diff --git a/drivers/char/istallion.c b/drivers/char/istallion.c index 4e395c956a09..750650cbac11 100644 --- a/drivers/char/istallion.c +++ b/drivers/char/istallion.c | |||
@@ -14,6 +14,7 @@ | |||
14 | * the Free Software Foundation; either version 2 of the License, or | 14 | * the Free Software Foundation; either version 2 of the License, or |
15 | * (at your option) any later version. | 15 | * (at your option) any later version. |
16 | * | 16 | * |
17 | * FIXME: brdp->state needs proper locking. | ||
17 | */ | 18 | */ |
18 | 19 | ||
19 | /*****************************************************************************/ | 20 | /*****************************************************************************/ |
@@ -4011,6 +4012,7 @@ static int stli_getbrdstats(combrd_t __user *bp) | |||
4011 | return -ENODEV; | 4012 | return -ENODEV; |
4012 | 4013 | ||
4013 | memset(&stli_brdstats, 0, sizeof(combrd_t)); | 4014 | memset(&stli_brdstats, 0, sizeof(combrd_t)); |
4015 | |||
4014 | stli_brdstats.brd = brdp->brdnr; | 4016 | stli_brdstats.brd = brdp->brdnr; |
4015 | stli_brdstats.type = brdp->brdtype; | 4017 | stli_brdstats.type = brdp->brdtype; |
4016 | stli_brdstats.hwid = 0; | 4018 | stli_brdstats.hwid = 0; |
@@ -4076,10 +4078,13 @@ static int stli_portcmdstats(struct tty_struct *tty, struct stliport *portp) | |||
4076 | if (brdp == NULL) | 4078 | if (brdp == NULL) |
4077 | return -ENODEV; | 4079 | return -ENODEV; |
4078 | 4080 | ||
4081 | mutex_lock(&portp->port.mutex); | ||
4079 | if (brdp->state & BST_STARTED) { | 4082 | if (brdp->state & BST_STARTED) { |
4080 | if ((rc = stli_cmdwait(brdp, portp, A_GETSTATS, | 4083 | if ((rc = stli_cmdwait(brdp, portp, A_GETSTATS, |
4081 | &stli_cdkstats, sizeof(asystats_t), 1)) < 0) | 4084 | &stli_cdkstats, sizeof(asystats_t), 1)) < 0) { |
4085 | mutex_unlock(&portp->port.mutex); | ||
4082 | return rc; | 4086 | return rc; |
4087 | } | ||
4083 | } else { | 4088 | } else { |
4084 | memset(&stli_cdkstats, 0, sizeof(asystats_t)); | 4089 | memset(&stli_cdkstats, 0, sizeof(asystats_t)); |
4085 | } | 4090 | } |
@@ -4124,6 +4129,7 @@ static int stli_portcmdstats(struct tty_struct *tty, struct stliport *portp) | |||
4124 | stli_comstats.modem = stli_cdkstats.dcdcnt; | 4129 | stli_comstats.modem = stli_cdkstats.dcdcnt; |
4125 | stli_comstats.hwid = stli_cdkstats.hwid; | 4130 | stli_comstats.hwid = stli_cdkstats.hwid; |
4126 | stli_comstats.signals = stli_mktiocm(stli_cdkstats.signals); | 4131 | stli_comstats.signals = stli_mktiocm(stli_cdkstats.signals); |
4132 | mutex_unlock(&portp->port.mutex); | ||
4127 | 4133 | ||
4128 | return 0; | 4134 | return 0; |
4129 | } | 4135 | } |
@@ -4186,15 +4192,20 @@ static int stli_clrportstats(struct stliport *portp, comstats_t __user *cp) | |||
4186 | if (!brdp) | 4192 | if (!brdp) |
4187 | return -ENODEV; | 4193 | return -ENODEV; |
4188 | 4194 | ||
4195 | mutex_lock(&portp->port.mutex); | ||
4196 | |||
4189 | if (brdp->state & BST_STARTED) { | 4197 | if (brdp->state & BST_STARTED) { |
4190 | if ((rc = stli_cmdwait(brdp, portp, A_CLEARSTATS, NULL, 0, 0)) < 0) | 4198 | if ((rc = stli_cmdwait(brdp, portp, A_CLEARSTATS, NULL, 0, 0)) < 0) { |
4199 | mutex_unlock(&portp->port.mutex); | ||
4191 | return rc; | 4200 | return rc; |
4201 | } | ||
4192 | } | 4202 | } |
4193 | 4203 | ||
4194 | memset(&stli_comstats, 0, sizeof(comstats_t)); | 4204 | memset(&stli_comstats, 0, sizeof(comstats_t)); |
4195 | stli_comstats.brd = portp->brdnr; | 4205 | stli_comstats.brd = portp->brdnr; |
4196 | stli_comstats.panel = portp->panelnr; | 4206 | stli_comstats.panel = portp->panelnr; |
4197 | stli_comstats.port = portp->portnr; | 4207 | stli_comstats.port = portp->portnr; |
4208 | mutex_unlock(&portp->port.mutex); | ||
4198 | 4209 | ||
4199 | if (copy_to_user(cp, &stli_comstats, sizeof(comstats_t))) | 4210 | if (copy_to_user(cp, &stli_comstats, sizeof(comstats_t))) |
4200 | return -EFAULT; | 4211 | return -EFAULT; |
@@ -4266,8 +4277,6 @@ static long stli_memioctl(struct file *fp, unsigned int cmd, unsigned long arg) | |||
4266 | done = 0; | 4277 | done = 0; |
4267 | rc = 0; | 4278 | rc = 0; |
4268 | 4279 | ||
4269 | lock_kernel(); | ||
4270 | |||
4271 | switch (cmd) { | 4280 | switch (cmd) { |
4272 | case COM_GETPORTSTATS: | 4281 | case COM_GETPORTSTATS: |
4273 | rc = stli_getportstats(NULL, NULL, argp); | 4282 | rc = stli_getportstats(NULL, NULL, argp); |
@@ -4290,8 +4299,6 @@ static long stli_memioctl(struct file *fp, unsigned int cmd, unsigned long arg) | |||
4290 | done++; | 4299 | done++; |
4291 | break; | 4300 | break; |
4292 | } | 4301 | } |
4293 | unlock_kernel(); | ||
4294 | |||
4295 | if (done) | 4302 | if (done) |
4296 | return rc; | 4303 | return rc; |
4297 | 4304 | ||
@@ -4308,8 +4315,6 @@ static long stli_memioctl(struct file *fp, unsigned int cmd, unsigned long arg) | |||
4308 | if (brdp->state == 0) | 4315 | if (brdp->state == 0) |
4309 | return -ENODEV; | 4316 | return -ENODEV; |
4310 | 4317 | ||
4311 | lock_kernel(); | ||
4312 | |||
4313 | switch (cmd) { | 4318 | switch (cmd) { |
4314 | case STL_BINTR: | 4319 | case STL_BINTR: |
4315 | EBRDINTR(brdp); | 4320 | EBRDINTR(brdp); |
@@ -4332,7 +4337,6 @@ static long stli_memioctl(struct file *fp, unsigned int cmd, unsigned long arg) | |||
4332 | rc = -ENOIOCTLCMD; | 4337 | rc = -ENOIOCTLCMD; |
4333 | break; | 4338 | break; |
4334 | } | 4339 | } |
4335 | unlock_kernel(); | ||
4336 | return rc; | 4340 | return rc; |
4337 | } | 4341 | } |
4338 | 4342 | ||
diff --git a/drivers/char/stallion.c b/drivers/char/stallion.c index 6049fd731924..f2167f8e5aab 100644 --- a/drivers/char/stallion.c +++ b/drivers/char/stallion.c | |||
@@ -807,7 +807,6 @@ static void stl_waituntilsent(struct tty_struct *tty, int timeout) | |||
807 | timeout = HZ; | 807 | timeout = HZ; |
808 | tend = jiffies + timeout; | 808 | tend = jiffies + timeout; |
809 | 809 | ||
810 | lock_kernel(); | ||
811 | while (stl_datastate(portp)) { | 810 | while (stl_datastate(portp)) { |
812 | if (signal_pending(current)) | 811 | if (signal_pending(current)) |
813 | break; | 812 | break; |
@@ -815,7 +814,6 @@ static void stl_waituntilsent(struct tty_struct *tty, int timeout) | |||
815 | if (time_after_eq(jiffies, tend)) | 814 | if (time_after_eq(jiffies, tend)) |
816 | break; | 815 | break; |
817 | } | 816 | } |
818 | unlock_kernel(); | ||
819 | } | 817 | } |
820 | 818 | ||
821 | /*****************************************************************************/ | 819 | /*****************************************************************************/ |
@@ -1029,6 +1027,8 @@ static int stl_getserial(struct stlport *portp, struct serial_struct __user *sp) | |||
1029 | pr_debug("stl_getserial(portp=%p,sp=%p)\n", portp, sp); | 1027 | pr_debug("stl_getserial(portp=%p,sp=%p)\n", portp, sp); |
1030 | 1028 | ||
1031 | memset(&sio, 0, sizeof(struct serial_struct)); | 1029 | memset(&sio, 0, sizeof(struct serial_struct)); |
1030 | |||
1031 | mutex_lock(&portp->port.mutex); | ||
1032 | sio.line = portp->portnr; | 1032 | sio.line = portp->portnr; |
1033 | sio.port = portp->ioaddr; | 1033 | sio.port = portp->ioaddr; |
1034 | sio.flags = portp->port.flags; | 1034 | sio.flags = portp->port.flags; |
@@ -1048,6 +1048,7 @@ static int stl_getserial(struct stlport *portp, struct serial_struct __user *sp) | |||
1048 | brdp = stl_brds[portp->brdnr]; | 1048 | brdp = stl_brds[portp->brdnr]; |
1049 | if (brdp != NULL) | 1049 | if (brdp != NULL) |
1050 | sio.irq = brdp->irq; | 1050 | sio.irq = brdp->irq; |
1051 | mutex_unlock(&portp->port.mutex); | ||
1051 | 1052 | ||
1052 | return copy_to_user(sp, &sio, sizeof(struct serial_struct)) ? -EFAULT : 0; | 1053 | return copy_to_user(sp, &sio, sizeof(struct serial_struct)) ? -EFAULT : 0; |
1053 | } | 1054 | } |
@@ -1069,12 +1070,15 @@ static int stl_setserial(struct tty_struct *tty, struct serial_struct __user *sp | |||
1069 | 1070 | ||
1070 | if (copy_from_user(&sio, sp, sizeof(struct serial_struct))) | 1071 | if (copy_from_user(&sio, sp, sizeof(struct serial_struct))) |
1071 | return -EFAULT; | 1072 | return -EFAULT; |
1073 | mutex_lock(&portp->port.mutex); | ||
1072 | if (!capable(CAP_SYS_ADMIN)) { | 1074 | if (!capable(CAP_SYS_ADMIN)) { |
1073 | if ((sio.baud_base != portp->baud_base) || | 1075 | if ((sio.baud_base != portp->baud_base) || |
1074 | (sio.close_delay != portp->close_delay) || | 1076 | (sio.close_delay != portp->close_delay) || |
1075 | ((sio.flags & ~ASYNC_USR_MASK) != | 1077 | ((sio.flags & ~ASYNC_USR_MASK) != |
1076 | (portp->port.flags & ~ASYNC_USR_MASK))) | 1078 | (portp->port.flags & ~ASYNC_USR_MASK))) { |
1079 | mutex_unlock(&portp->port.mutex); | ||
1077 | return -EPERM; | 1080 | return -EPERM; |
1081 | } | ||
1078 | } | 1082 | } |
1079 | 1083 | ||
1080 | portp->port.flags = (portp->port.flags & ~ASYNC_USR_MASK) | | 1084 | portp->port.flags = (portp->port.flags & ~ASYNC_USR_MASK) | |
@@ -1083,6 +1087,7 @@ static int stl_setserial(struct tty_struct *tty, struct serial_struct __user *sp | |||
1083 | portp->close_delay = sio.close_delay; | 1087 | portp->close_delay = sio.close_delay; |
1084 | portp->closing_wait = sio.closing_wait; | 1088 | portp->closing_wait = sio.closing_wait; |
1085 | portp->custom_divisor = sio.custom_divisor; | 1089 | portp->custom_divisor = sio.custom_divisor; |
1090 | mutex_unlock(&portp->port.mutex); | ||
1086 | stl_setport(portp, tty->termios); | 1091 | stl_setport(portp, tty->termios); |
1087 | return 0; | 1092 | return 0; |
1088 | } | 1093 | } |
@@ -1147,8 +1152,6 @@ static int stl_ioctl(struct tty_struct *tty, struct file *file, unsigned int cmd | |||
1147 | 1152 | ||
1148 | rc = 0; | 1153 | rc = 0; |
1149 | 1154 | ||
1150 | lock_kernel(); | ||
1151 | |||
1152 | switch (cmd) { | 1155 | switch (cmd) { |
1153 | case TIOCGSERIAL: | 1156 | case TIOCGSERIAL: |
1154 | rc = stl_getserial(portp, argp); | 1157 | rc = stl_getserial(portp, argp); |
@@ -1173,7 +1176,6 @@ static int stl_ioctl(struct tty_struct *tty, struct file *file, unsigned int cmd | |||
1173 | rc = -ENOIOCTLCMD; | 1176 | rc = -ENOIOCTLCMD; |
1174 | break; | 1177 | break; |
1175 | } | 1178 | } |
1176 | unlock_kernel(); | ||
1177 | return rc; | 1179 | return rc; |
1178 | } | 1180 | } |
1179 | 1181 | ||
@@ -2327,6 +2329,7 @@ static int stl_getportstats(struct tty_struct *tty, struct stlport *portp, comst | |||
2327 | return -ENODEV; | 2329 | return -ENODEV; |
2328 | } | 2330 | } |
2329 | 2331 | ||
2332 | mutex_lock(&portp->port.mutex); | ||
2330 | portp->stats.state = portp->istate; | 2333 | portp->stats.state = portp->istate; |
2331 | portp->stats.flags = portp->port.flags; | 2334 | portp->stats.flags = portp->port.flags; |
2332 | portp->stats.hwid = portp->hwid; | 2335 | portp->stats.hwid = portp->hwid; |
@@ -2358,6 +2361,7 @@ static int stl_getportstats(struct tty_struct *tty, struct stlport *portp, comst | |||
2358 | (STL_TXBUFSIZE - (tail - head)); | 2361 | (STL_TXBUFSIZE - (tail - head)); |
2359 | 2362 | ||
2360 | portp->stats.signals = (unsigned long) stl_getsignals(portp); | 2363 | portp->stats.signals = (unsigned long) stl_getsignals(portp); |
2364 | mutex_unlock(&portp->port.mutex); | ||
2361 | 2365 | ||
2362 | return copy_to_user(cp, &portp->stats, | 2366 | return copy_to_user(cp, &portp->stats, |
2363 | sizeof(comstats_t)) ? -EFAULT : 0; | 2367 | sizeof(comstats_t)) ? -EFAULT : 0; |
@@ -2382,10 +2386,12 @@ static int stl_clrportstats(struct stlport *portp, comstats_t __user *cp) | |||
2382 | return -ENODEV; | 2386 | return -ENODEV; |
2383 | } | 2387 | } |
2384 | 2388 | ||
2389 | mutex_lock(&portp->port.mutex); | ||
2385 | memset(&portp->stats, 0, sizeof(comstats_t)); | 2390 | memset(&portp->stats, 0, sizeof(comstats_t)); |
2386 | portp->stats.brd = portp->brdnr; | 2391 | portp->stats.brd = portp->brdnr; |
2387 | portp->stats.panel = portp->panelnr; | 2392 | portp->stats.panel = portp->panelnr; |
2388 | portp->stats.port = portp->portnr; | 2393 | portp->stats.port = portp->portnr; |
2394 | mutex_unlock(&portp->port.mutex); | ||
2389 | return copy_to_user(cp, &portp->stats, | 2395 | return copy_to_user(cp, &portp->stats, |
2390 | sizeof(comstats_t)) ? -EFAULT : 0; | 2396 | sizeof(comstats_t)) ? -EFAULT : 0; |
2391 | } | 2397 | } |
@@ -2451,7 +2457,6 @@ static long stl_memioctl(struct file *fp, unsigned int cmd, unsigned long arg) | |||
2451 | return -ENODEV; | 2457 | return -ENODEV; |
2452 | rc = 0; | 2458 | rc = 0; |
2453 | 2459 | ||
2454 | lock_kernel(); | ||
2455 | switch (cmd) { | 2460 | switch (cmd) { |
2456 | case COM_GETPORTSTATS: | 2461 | case COM_GETPORTSTATS: |
2457 | rc = stl_getportstats(NULL, NULL, argp); | 2462 | rc = stl_getportstats(NULL, NULL, argp); |
@@ -2472,7 +2477,6 @@ static long stl_memioctl(struct file *fp, unsigned int cmd, unsigned long arg) | |||
2472 | rc = -ENOIOCTLCMD; | 2477 | rc = -ENOIOCTLCMD; |
2473 | break; | 2478 | break; |
2474 | } | 2479 | } |
2475 | unlock_kernel(); | ||
2476 | return rc; | 2480 | return rc; |
2477 | } | 2481 | } |
2478 | 2482 | ||