diff --git a/[refs] b/[refs] index 4d8ea3239ee1..add42b7308a4 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: adfc76419bff33542d4fd53dc7f24818f846f194 +refs/heads/master: d936cfc72032fb4af03d1edd99596d18ea1f081c diff --git a/trunk/Documentation/CodingStyle b/trunk/Documentation/CodingStyle index ce780ef648f1..ce5d2c038cf5 100644 --- a/trunk/Documentation/CodingStyle +++ b/trunk/Documentation/CodingStyle @@ -199,7 +199,7 @@ The rationale is: modifications are prevented - saves the compiler work to optimize redundant code away ;) -int fun(int ) +int fun(int a) { int result = 0; char *buffer = kmalloc(SIZE); diff --git a/trunk/Documentation/DocBook/.gitignore b/trunk/Documentation/DocBook/.gitignore new file mode 100644 index 000000000000..c102c02ecf89 --- /dev/null +++ b/trunk/Documentation/DocBook/.gitignore @@ -0,0 +1,6 @@ +*.xml +*.ps +*.pdf +*.html +*.9.gz +*.9 diff --git a/trunk/Documentation/DocBook/kernel-api.tmpl b/trunk/Documentation/DocBook/kernel-api.tmpl index 3c47a3f0dc55..8c9c6704e85b 100644 --- a/trunk/Documentation/DocBook/kernel-api.tmpl +++ b/trunk/Documentation/DocBook/kernel-api.tmpl @@ -53,6 +53,11 @@ !Iinclude/linux/sched.h !Ekernel/sched.c !Ekernel/timer.c + + High-resolution timers +!Iinclude/linux/ktime.h +!Iinclude/linux/hrtimer.h +!Ekernel/hrtimer.c Internal Functions !Ikernel/exit.c diff --git a/trunk/Documentation/applying-patches.txt b/trunk/Documentation/applying-patches.txt index 05a08c2c1889..a083ba35d1ad 100644 --- a/trunk/Documentation/applying-patches.txt +++ b/trunk/Documentation/applying-patches.txt @@ -3,8 +3,7 @@ ------------------------------------ Original by: Jesper Juhl, August 2005 - Last update: 2005-12-02 - + Last update: 2006-01-05 A frequently asked question on the Linux Kernel Mailing List is how to apply @@ -77,7 +76,7 @@ instead: If you wish to uncompress the patch file by hand first before applying it (what I assume you've done in the examples below), then you simply run -gunzip or bunzip2 on the file - like this: +gunzip or bunzip2 on the file -- like this: gunzip patch-x.y.z.gz bunzip2 patch-x.y.z.bz2 @@ -95,7 +94,7 @@ Common errors when patching --- When patch applies a patch file it attempts to verify the sanity of the file in different ways. -Checking that the file looks like a valid patch file, checking the code +Checking that the file looks like a valid patch file & checking the code around the bits being modified matches the context provided in the patch are just two of the basic sanity checks patch does. @@ -122,7 +121,7 @@ outright and leaves a file with a .rej extension (a reject file). You can read this file to see exactly what change couldn't be applied, so you can go fix it up by hand if you wish. -If you don't have any third party patches applied to your kernel source, but +If you don't have any third-party patches applied to your kernel source, but only patches from kernel.org and you apply the patches in the correct order, and have made no modifications yourself to the source files, then you should never see a fuzz or reject message from patch. If you do see such messages @@ -137,7 +136,7 @@ If patch stops and presents a "File to patch:" prompt, then patch could not find a file to be patched. Most likely you forgot to specify -p1 or you are in the wrong directory. Less often, you'll find patches that need to be applied with -p0 instead of -p1 (reading the patch file should reveal if -this is the case - if so, then this is an error by the person who created +this is the case -- if so, then this is an error by the person who created the patch but is not fatal). If you get "Hunk #2 succeeded at 1887 with fuzz 2 (offset 7 lines)." or a @@ -168,13 +167,17 @@ the patch will in fact apply it. A message similar to "patch: **** unexpected end of file in patch" or "patch unexpectedly ends in middle of line" means that patch could make no sense of -the file you fed to it. Either your download is broken or you tried to feed -patch a compressed patch file without uncompressing it first. +the file you fed to it. Either your download is broken, you tried to feed +patch a compressed patch file without uncompressing it first, or the patch +file that you are using has been mangled by a mail client or mail transfer +agent along the way somewhere, e.g., by splitting a long line into two lines. +Often these warnings can easily be fixed by joining (concatenating) the +two lines that had been split. As I already mentioned above, these errors should never happen if you apply a patch from kernel.org to the correct version of an unmodified source tree. So if you get these errors with kernel.org patches then you should probably -assume that either your patch file or your tree is broken and I'd advice you +assume that either your patch file or your tree is broken and I'd advise you to start over with a fresh download of a full kernel tree and the patch you wish to apply. @@ -200,10 +203,10 @@ do the additional steps since interdiff can get things wrong in some cases. Another alternative is `ketchup', which is a python script for automatic downloading and applying of patches (http://www.selenic.com/ketchup/). - Other nice tools are diffstat which shows a summary of changes made by a -patch, lsdiff which displays a short listing of affected files in a patch -file, along with (optionally) the line numbers of the start of each patch -and grepdiff which displays a list of the files modified by a patch where + Other nice tools are diffstat, which shows a summary of changes made by a +patch; lsdiff, which displays a short listing of affected files in a patch +file, along with (optionally) the line numbers of the start of each patch; +and grepdiff, which displays a list of the files modified by a patch where the patch contains a given regular expression. @@ -228,8 +231,8 @@ The -mm kernels live at In place of ftp.kernel.org you can use ftp.cc.kernel.org, where cc is a country code. This way you'll be downloading from a mirror site that's most likely geographically closer to you, resulting in faster downloads for you, -less bandwidth used globally and less load on the main kernel.org servers - -these are good things, do use mirrors when possible. +less bandwidth used globally and less load on the main kernel.org servers -- +these are good things, so do use mirrors when possible. The 2.6.x kernels @@ -237,14 +240,14 @@ The 2.6.x kernels These are the base stable releases released by Linus. The highest numbered release is the most recent. -If regressions or other serious flaws are found then a -stable fix patch +If regressions or other serious flaws are found, then a -stable fix patch will be released (see below) on top of this base. Once a new 2.6.x base kernel is released, a patch is made available that is a delta between the previous 2.6.x kernel and the new one. -To apply a patch moving from 2.6.11 to 2.6.12 you'd do the following (note +To apply a patch moving from 2.6.11 to 2.6.12, you'd do the following (note that such patches do *NOT* apply on top of 2.6.x.y kernels but on top of the -base 2.6.x kernel - if you need to move from 2.6.x.y to 2.6.x+1 you need to +base 2.6.x kernel -- if you need to move from 2.6.x.y to 2.6.x+1 you need to first revert the 2.6.x.y patch). Here are some examples: @@ -266,7 +269,7 @@ $ mv linux-2.6.11.1 linux-2.6.12 # rename source dir The 2.6.x.y kernels --- - Kernels with 4 digit versions are -stable kernels. They contain small(ish) + Kernels with 4-digit versions are -stable kernels. They contain small(ish) critical fixes for security problems or significant regressions discovered in a given 2.6.x kernel. @@ -277,9 +280,14 @@ versions. If no 2.6.x.y kernel is available, then the highest numbered 2.6.x kernel is the current stable kernel. + note: the -stable team usually do make incremental patches available as well + as patches against the latest mainline release, but I only cover the + non-incremental ones below. The incremental ones can be found at + ftp://ftp.kernel.org/pub/linux/kernel/v2.6/incr/ + These patches are not incremental, meaning that for example the 2.6.12.3 patch does not apply on top of the 2.6.12.2 kernel source, but rather on top -of the base 2.6.12 kernel source. +of the base 2.6.12 kernel source . So, in order to apply the 2.6.12.3 patch to your existing 2.6.12.2 kernel source you have to first back out the 2.6.12.2 patch (so you are left with a base 2.6.12 kernel source) and then apply the new 2.6.12.3 patch. @@ -345,12 +353,12 @@ The -git kernels repository, hence the name). These patches are usually released daily and represent the current state of -Linus' tree. They are more experimental than -rc kernels since they are +Linus's tree. They are more experimental than -rc kernels since they are generated automatically without even a cursory glance to see if they are sane. -git patches are not incremental and apply either to a base 2.6.x kernel or -a base 2.6.x-rc kernel - you can see which from their name. +a base 2.6.x-rc kernel -- you can see which from their name. A patch named 2.6.12-git1 applies to the 2.6.12 kernel source and a patch named 2.6.13-rc3-git2 applies to the source of the 2.6.13-rc3 kernel. @@ -393,12 +401,12 @@ You should generally strive to get your patches into mainline via -mm to ensure maximum testing. This branch is in constant flux and contains many experimental features, a -lot of debugging patches not appropriate for mainline etc and is the most +lot of debugging patches not appropriate for mainline etc., and is the most experimental of the branches described in this document. These kernels are not appropriate for use on systems that are supposed to be stable and they are more risky to run than any of the other branches (make -sure you have up-to-date backups - that goes for any experimental kernel but +sure you have up-to-date backups -- that goes for any experimental kernel but even more so for -mm kernels). These kernels in addition to all the other experimental patches they contain diff --git a/trunk/Documentation/filesystems/ext3.txt b/trunk/Documentation/filesystems/ext3.txt index 22e4040564d5..f4d0de6bac63 100644 --- a/trunk/Documentation/filesystems/ext3.txt +++ b/trunk/Documentation/filesystems/ext3.txt @@ -2,11 +2,11 @@ Ext3 Filesystem =============== -ext3 was originally released in September 1999. Written by Stephen Tweedie -for 2.2 branch, and ported to 2.4 kernels by Peter Braam, Andreas Dilger, +Ext3 was originally released in September 1999. Written by Stephen Tweedie +for the 2.2 branch, and ported to 2.4 kernels by Peter Braam, Andreas Dilger, Andrew Morton, Alexander Viro, Ted Ts'o and Stephen Tweedie. -ext3 is ext2 filesystem enhanced with journalling capabilities. +Ext3 is the ext2 filesystem enhanced with journalling capabilities. Options ======= @@ -14,69 +14,71 @@ Options When mounting an ext3 filesystem, the following option are accepted: (*) == default -jounal=update Update the ext3 file system's journal to the - current format. +journal=update Update the ext3 file system's journal to the current + format. -journal=inum When a journal already exists, this option is - ignored. Otherwise, it specifies the number of - the inode which will represent the ext3 file - system's journal file. +journal=inum When a journal already exists, this option is ignored. + Otherwise, it specifies the number of the inode which + will represent the ext3 file system's journal file. journal_dev=devnum When the external journal device's major/minor numbers - have changed, this option allows to specify the new - journal location. The journal device is identified - through its new major/minor numbers encoded in devnum. + have changed, this option allows the user to specify + the new journal location. The journal device is + identified through its new major/minor numbers encoded + in devnum. noload Don't load the journal on mounting. -data=journal All data are committed into the journal prior - to being written into the main file system. +data=journal All data are committed into the journal prior to being + written into the main file system. data=ordered (*) All data are forced directly out to the main file - system prior to its metadata being committed to - the journal. + system prior to its metadata being committed to the + journal. -data=writeback Data ordering is not preserved, data may be - written into the main file system after its - metadata has been committed to the journal. +data=writeback Data ordering is not preserved, data may be written + into the main file system after its metadata has been + committed to the journal. commit=nrsec (*) Ext3 can be told to sync all its data and metadata every 'nrsec' seconds. The default value is 5 seconds. - This means that if you lose your power, you will lose, - as much, the latest 5 seconds of work (your filesystem - will not be damaged though, thanks to journaling). This - default value (or any low value) will hurt performance, - but it's good for data-safety. Setting it to 0 will - have the same effect than leaving the default 5 sec. + This means that if you lose your power, you will lose + as much as the latest 5 seconds of work (your + filesystem will not be damaged though, thanks to the + journaling). This default value (or any low value) + will hurt performance, but it's good for data-safety. + Setting it to 0 will have the same effect as leaving + it at the default (5 seconds). Setting it to very large values will improve performance. -barrier=1 This enables/disables barriers. barrier=0 disables it, - barrier=1 enables it. +barrier=1 This enables/disables barriers. barrier=0 disables + it, barrier=1 enables it. -orlov (*) This enables the new Orlov block allocator. It's enabled - by default. +orlov (*) This enables the new Orlov block allocator. It is + enabled by default. -oldalloc This disables the Orlov block allocator and enables the - old block allocator. Orlov should have better performance, - we'd like to get some feedback if it's the contrary for - you. +oldalloc This disables the Orlov block allocator and enables + the old block allocator. Orlov should have better + performance - we'd like to get some feedback if it's + the contrary for you. -user_xattr Enables Extended User Attributes. Additionally, you need - to have extended attribute support enabled in the kernel - configuration (CONFIG_EXT3_FS_XATTR). See the attr(5) - manual page and http://acl.bestbits.at to learn more - about extended attributes. +user_xattr Enables Extended User Attributes. Additionally, you + need to have extended attribute support enabled in the + kernel configuration (CONFIG_EXT3_FS_XATTR). See the + attr(5) manual page and http://acl.bestbits.at/ to + learn more about extended attributes. nouser_xattr Disables Extended User Attributes. -acl Enables POSIX Access Control Lists support. Additionally, - you need to have ACL support enabled in the kernel - configuration (CONFIG_EXT3_FS_POSIX_ACL). See the acl(5) - manual page and http://acl.bestbits.at for more - information. +acl Enables POSIX Access Control Lists support. + Additionally, you need to have ACL support enabled in + the kernel configuration (CONFIG_EXT3_FS_POSIX_ACL). + See the acl(5) manual page and http://acl.bestbits.at/ + for more information. -noacl This option disables POSIX Access Control List support. +noacl This option disables POSIX Access Control List + support. reservation @@ -88,7 +90,7 @@ bsddf (*) Make 'df' act like BSD. minixdf Make 'df' act like Minix. check=none Don't do extra checking of bitmaps on mount. -nocheck +nocheck debug Extra debugging information is sent to syslog. @@ -97,7 +99,7 @@ errors=continue Keep going on a filesystem error. errors=panic Panic and halt the machine if an error occurs. grpid Give objects the same group ID as their creator. -bsdgroups +bsdgroups nogrpid (*) New objects have the group ID of their creator. sysvgroups @@ -108,81 +110,81 @@ resuid=n The user ID which may use the reserved blocks. sb=n Use alternate superblock at this location. -quota Quota options are currently silently ignored. -noquota (see fs/ext3/super.c, line 594) +quota +noquota grpquota usrquota Specification ============= -ext3 shares all disk implementation with ext2 filesystem, and add -transactions capabilities to ext2. Journaling is done by the -Journaling block device layer. +Ext3 shares all disk implementation with the ext2 filesystem, and adds +transactions capabilities to ext2. Journaling is done by the Journaling Block +Device layer. Journaling Block Device layer ----------------------------- -The Journaling Block Device layer (JBD) isn't ext3 specific. It was -design to add journaling capabilities on a block device. The ext3 -filesystem code will inform the JBD of modifications it is performing -(Call a transaction). the journal support the transactions start and -stop, and in case of crash, the journal can replayed the transactions -to put the partition on a consistent state fastly. +The Journaling Block Device layer (JBD) isn't ext3 specific. It was design to +add journaling capabilities on a block device. The ext3 filesystem code will +inform the JBD of modifications it is performing (called a transaction). The +journal supports the transactions start and stop, and in case of crash, the +journal can replayed the transactions to put the partition back in a +consistent state fast. -handles represent a single atomic update to a filesystem. JBD can -handle external journal on a block device. +Handles represent a single atomic update to a filesystem. JBD can handle an +external journal on a block device. Data Mode --------- -There's 3 different data modes: +There are 3 different data modes: * writeback mode -In data=writeback mode, ext3 does not journal data at all. This mode -provides a similar level of journaling as XFS, JFS, and ReiserFS in its -default mode - metadata journaling. A crash+recovery can cause -incorrect data to appear in files which were written shortly before the -crash. This mode will typically provide the best ext3 performance. +In data=writeback mode, ext3 does not journal data at all. This mode provides +a similar level of journaling as that of XFS, JFS, and ReiserFS in its default +mode - metadata journaling. A crash+recovery can cause incorrect data to +appear in files which were written shortly before the crash. This mode will +typically provide the best ext3 performance. * ordered mode -In data=ordered mode, ext3 only officially journals metadata, but it -logically groups metadata and data blocks into a single unit called a -transaction. When it's time to write the new metadata out to disk, the -associated data blocks are written first. In general, this mode -perform slightly slower than writeback but significantly faster than -journal mode. +In data=ordered mode, ext3 only officially journals metadata, but it logically +groups metadata and data blocks into a single unit called a transaction. When +it's time to write the new metadata out to disk, the associated data blocks +are written first. In general, this mode performs slightly slower than +writeback but significantly faster than journal mode. * journal mode -data=journal mode provides full data and metadata journaling. All new -data is written to the journal first, and then to its final location. -In the event of a crash, the journal can be replayed, bringing both -data and metadata into a consistent state. This mode is the slowest -except when data needs to be read from and written to disk at the same -time where it outperform all others mode. +data=journal mode provides full data and metadata journaling. All new data is +written to the journal first, and then to its final location. +In the event of a crash, the journal can be replayed, bringing both data and +metadata into a consistent state. This mode is the slowest except when data +needs to be read from and written to disk at the same time where it +outperforms all others modes. Compatibility ------------- Ext2 partitions can be easily convert to ext3, with `tune2fs -j `. -Ext3 is fully compatible with Ext2. Ext3 partitions can easily be -mounted as Ext2. +Ext3 is fully compatible with Ext2. Ext3 partitions can easily be mounted as +Ext2. + External Tools ============== -see manual pages to know more. +See manual pages to learn more. + +tune2fs: create a ext3 journal on a ext2 partition with the -j flag. +mke2fs: create a ext3 partition with the -j flag. +debugfs: ext2 and ext3 file system debugger. -tune2fs: create a ext3 journal on a ext2 partition with the -j flags -mke2fs: create a ext3 partition with the -j flags -debugfs: ext2 and ext3 file system debugger References ========== -kernel source: file:/usr/src/linux/fs/ext3 - file:/usr/src/linux/fs/jbd +kernel source: + -programs: http://e2fsprogs.sourceforge.net +programs: http://e2fsprogs.sourceforge.net/ -useful link: - http://www.zip.com.au/~akpm/linux/ext3/ext3-usage.html +useful links: http://www.zip.com.au/~akpm/linux/ext3/ext3-usage.html http://www-106.ibm.com/developerworks/linux/library/l-fs7/ http://www-106.ibm.com/developerworks/linux/library/l-fs8/ diff --git a/trunk/Documentation/hrtimers.txt b/trunk/Documentation/hrtimers.txt new file mode 100644 index 000000000000..7620ff735faf --- /dev/null +++ b/trunk/Documentation/hrtimers.txt @@ -0,0 +1,178 @@ + +hrtimers - subsystem for high-resolution kernel timers +---------------------------------------------------- + +This patch introduces a new subsystem for high-resolution kernel timers. + +One might ask the question: we already have a timer subsystem +(kernel/timers.c), why do we need two timer subsystems? After a lot of +back and forth trying to integrate high-resolution and high-precision +features into the existing timer framework, and after testing various +such high-resolution timer implementations in practice, we came to the +conclusion that the timer wheel code is fundamentally not suitable for +such an approach. We initially didnt believe this ('there must be a way +to solve this'), and spent a considerable effort trying to integrate +things into the timer wheel, but we failed. In hindsight, there are +several reasons why such integration is hard/impossible: + +- the forced handling of low-resolution and high-resolution timers in + the same way leads to a lot of compromises, macro magic and #ifdef + mess. The timers.c code is very "tightly coded" around jiffies and + 32-bitness assumptions, and has been honed and micro-optimized for a + relatively narrow use case (jiffies in a relatively narrow HZ range) + for many years - and thus even small extensions to it easily break + the wheel concept, leading to even worse compromises. The timer wheel + code is very good and tight code, there's zero problems with it in its + current usage - but it is simply not suitable to be extended for + high-res timers. + +- the unpredictable [O(N)] overhead of cascading leads to delays which + necessiate a more complex handling of high resolution timers, which + in turn decreases robustness. Such a design still led to rather large + timing inaccuracies. Cascading is a fundamental property of the timer + wheel concept, it cannot be 'designed out' without unevitably + degrading other portions of the timers.c code in an unacceptable way. + +- the implementation of the current posix-timer subsystem on top of + the timer wheel has already introduced a quite complex handling of + the required readjusting of absolute CLOCK_REALTIME timers at + settimeofday or NTP time - further underlying our experience by + example: that the timer wheel data structure is too rigid for high-res + timers. + +- the timer wheel code is most optimal for use cases which can be + identified as "timeouts". Such timeouts are usually set up to cover + error conditions in various I/O paths, such as networking and block + I/O. The vast majority of those timers never expire and are rarely + recascaded because the expected correct event arrives in time so they + can be removed from the timer wheel before any further processing of + them becomes necessary. Thus the users of these timeouts can accept + the granularity and precision tradeoffs of the timer wheel, and + largely expect the timer subsystem to have near-zero overhead. + Accurate timing for them is not a core purpose - in fact most of the + timeout values used are ad-hoc. For them it is at most a necessary + evil to guarantee the processing of actual timeout completions + (because most of the timeouts are deleted before completion), which + should thus be as cheap and unintrusive as possible. + +The primary users of precision timers are user-space applications that +utilize nanosleep, posix-timers and itimer interfaces. Also, in-kernel +users like drivers and subsystems which require precise timed events +(e.g. multimedia) can benefit from the availability of a seperate +high-resolution timer subsystem as well. + +While this subsystem does not offer high-resolution clock sources just +yet, the hrtimer subsystem can be easily extended with high-resolution +clock capabilities, and patches for that exist and are maturing quickly. +The increasing demand for realtime and multimedia applications along +with other potential users for precise timers gives another reason to +separate the "timeout" and "precise timer" subsystems. + +Another potential benefit is that such a seperation allows even more +special-purpose optimization of the existing timer wheel for the low +resolution and low precision use cases - once the precision-sensitive +APIs are separated from the timer wheel and are migrated over to +hrtimers. E.g. we could decrease the frequency of the timeout subsystem +from 250 Hz to 100 HZ (or even smaller). + +hrtimer subsystem implementation details +---------------------------------------- + +the basic design considerations were: + +- simplicity + +- data structure not bound to jiffies or any other granularity. All the + kernel logic works at 64-bit nanoseconds resolution - no compromises. + +- simplification of existing, timing related kernel code + +another basic requirement was the immediate enqueueing and ordering of +timers at activation time. After looking at several possible solutions +such as radix trees and hashes, we chose the red black tree as the basic +data structure. Rbtrees are available as a library in the kernel and are +used in various performance-critical areas of e.g. memory management and +file systems. The rbtree is solely used for time sorted ordering, while +a separate list is used to give the expiry code fast access to the +queued timers, without having to walk the rbtree. + +(This seperate list is also useful for later when we'll introduce +high-resolution clocks, where we need seperate pending and expired +queues while keeping the time-order intact.) + +Time-ordered enqueueing is not purely for the purposes of +high-resolution clocks though, it also simplifies the handling of +absolute timers based on a low-resolution CLOCK_REALTIME. The existing +implementation needed to keep an extra list of all armed absolute +CLOCK_REALTIME timers along with complex locking. In case of +settimeofday and NTP, all the timers (!) had to be dequeued, the +time-changing code had to fix them up one by one, and all of them had to +be enqueued again. The time-ordered enqueueing and the storage of the +expiry time in absolute time units removes all this complex and poorly +scaling code from the posix-timer implementation - the clock can simply +be set without having to touch the rbtree. This also makes the handling +of posix-timers simpler in general. + +The locking and per-CPU behavior of hrtimers was mostly taken from the +existing timer wheel code, as it is mature and well suited. Sharing code +was not really a win, due to the different data structures. Also, the +hrtimer functions now have clearer behavior and clearer names - such as +hrtimer_try_to_cancel() and hrtimer_cancel() [which are roughly +equivalent to del_timer() and del_timer_sync()] - so there's no direct +1:1 mapping between them on the algorithmical level, and thus no real +potential for code sharing either. + +Basic data types: every time value, absolute or relative, is in a +special nanosecond-resolution type: ktime_t. The kernel-internal +representation of ktime_t values and operations is implemented via +macros and inline functions, and can be switched between a "hybrid +union" type and a plain "scalar" 64bit nanoseconds representation (at +compile time). The hybrid union type optimizes time conversions on 32bit +CPUs. This build-time-selectable ktime_t storage format was implemented +to avoid the performance impact of 64-bit multiplications and divisions +on 32bit CPUs. Such operations are frequently necessary to convert +between the storage formats provided by kernel and userspace interfaces +and the internal time format. (See include/linux/ktime.h for further +details.) + +hrtimers - rounding of timer values +----------------------------------- + +the hrtimer code will round timer events to lower-resolution clocks +because it has to. Otherwise it will do no artificial rounding at all. + +one question is, what resolution value should be returned to the user by +the clock_getres() interface. This will return whatever real resolution +a given clock has - be it low-res, high-res, or artificially-low-res. + +hrtimers - testing and verification +---------------------------------- + +We used the high-resolution clock subsystem ontop of hrtimers to verify +the hrtimer implementation details in praxis, and we also ran the posix +timer tests in order to ensure specification compliance. We also ran +tests on low-resolution clocks. + +The hrtimer patch converts the following kernel functionality to use +hrtimers: + + - nanosleep + - itimers + - posix-timers + +The conversion of nanosleep and posix-timers enabled the unification of +nanosleep and clock_nanosleep. + +The code was successfully compiled for the following platforms: + + i386, x86_64, ARM, PPC, PPC64, IA64 + +The code was run-tested on the following platforms: + + i386(UP/SMP), x86_64(UP/SMP), ARM, PPC + +hrtimers were also integrated into the -rt tree, along with a +hrtimers-based high-resolution clock implementation, so the hrtimers +code got a healthy amount of testing and use in practice. + + Thomas Gleixner, Ingo Molnar diff --git a/trunk/Documentation/kbuild/makefiles.txt b/trunk/Documentation/kbuild/makefiles.txt index d802ce88bedc..443230b43e09 100644 --- a/trunk/Documentation/kbuild/makefiles.txt +++ b/trunk/Documentation/kbuild/makefiles.txt @@ -1033,9 +1033,9 @@ When kbuild executes the following steps are followed (roughly): Example: #arch/i386/Makefile - GCC_VERSION := $(call cc-version) cflags-y += $(shell \ - if [ $(GCC_VERSION) -ge 0300 ] ; then echo "-mregparm=3"; fi ;) + if [ $(call cc-version) -ge 0300 ] ; then \ + echo "-mregparm=3"; fi ;) In the above example -mregparm=3 is only used for gcc version greater than or equal to gcc 3.0. diff --git a/trunk/Documentation/kdump/kdump.txt b/trunk/Documentation/kdump/kdump.txt index 5f08f9ce6046..212cf3c21abf 100644 --- a/trunk/Documentation/kdump/kdump.txt +++ b/trunk/Documentation/kdump/kdump.txt @@ -4,10 +4,10 @@ Documentation for kdump - the kexec-based crash dumping solution DESIGN ====== -Kdump uses kexec to reboot to a second kernel whenever a dump needs to be taken. -This second kernel is booted with very little memory. The first kernel reserves -the section of memory that the second kernel uses. This ensures that on-going -DMA from the first kernel does not corrupt the second kernel. +Kdump uses kexec to reboot to a second kernel whenever a dump needs to be +taken. This second kernel is booted with very little memory. The first kernel +reserves the section of memory that the second kernel uses. This ensures that +on-going DMA from the first kernel does not corrupt the second kernel. All the necessary information about Core image is encoded in ELF format and stored in reserved area of memory before crash. Physical address of start of @@ -35,77 +35,82 @@ In the second kernel, "old memory" can be accessed in two ways. SETUP ===== -1) Download http://www.xmission.com/~ebiederm/files/kexec/kexec-tools-1.101.tar.gz - and apply http://lse.sourceforge.net/kdump/patches/kexec-tools-1.101-kdump.patch - and after that build the source. +1) Download the upstream kexec-tools userspace package from + http://www.xmission.com/~ebiederm/files/kexec/kexec-tools-1.101.tar.gz. -2) Download and build the appropriate (2.6.13-rc1 onwards) vanilla kernel. + Apply the latest consolidated kdump patch on top of kexec-tools-1.101 + from http://lse.sourceforge.net/kdump/. This arrangment has been made + till all the userspace patches supporting kdump are integrated with + upstream kexec-tools userspace. +2) Download and build the appropriate (2.6.13-rc1 onwards) vanilla kernels. Two kernels need to be built in order to get this feature working. + Following are the steps to properly configure the two kernels specific + to kexec and kdump features: - A) First kernel: + A) First kernel or regular kernel: + ---------------------------------- a) Enable "kexec system call" feature (in Processor type and features). - CONFIG_KEXEC=y - b) This kernel's physical load address should be the default value of - 0x100000 (0x100000, 1 MB) (in Processor type and features). - CONFIG_PHYSICAL_START=0x100000 - c) Enable "sysfs file system support" (in Pseudo filesystems). - CONFIG_SYSFS=y + CONFIG_KEXEC=y + b) Enable "sysfs file system support" (in Pseudo filesystems). + CONFIG_SYSFS=y + c) make d) Boot into first kernel with the command line parameter "crashkernel=Y@X". Use appropriate values for X and Y. Y denotes how much memory to reserve - for the second kernel, and X denotes at what physical address the reserved - memory section starts. For example: "crashkernel=64M@16M". - - B) Second kernel: - a) Enable "kernel crash dumps" feature (in Processor type and features). - CONFIG_CRASH_DUMP=y - b) Specify a suitable value for "Physical address where the kernel is - loaded" (in Processor type and features). Typically this value - should be same as X (See option d) above, e.g., 16 MB or 0x1000000. - CONFIG_PHYSICAL_START=0x1000000 - c) Enable "/proc/vmcore support" (Optional, in Pseudo filesystems). - CONFIG_PROC_VMCORE=y - d) Disable SMP support and build a UP kernel (Until it is fixed). - CONFIG_SMP=n - e) Enable "Local APIC support on uniprocessors". - CONFIG_X86_UP_APIC=y - f) Enable "IO-APIC support on uniprocessors" - CONFIG_X86_UP_IOAPIC=y - - Note: i) Options a) and b) depend upon "Configure standard kernel features - (for small systems)" (under General setup). - ii) Option a) also depends on CONFIG_HIGHMEM (under Processor - type and features). - iii) Both option a) and b) are under "Processor type and features". - -3) Boot into the first kernel. You are now ready to try out kexec-based crash - dumps. - -4) Load the second kernel to be booted using: + for the second kernel, and X denotes at what physical address the + reserved memory section starts. For example: "crashkernel=64M@16M". + + + B) Second kernel or dump capture kernel: + --------------------------------------- + a) For i386 architecture enable Highmem support + CONFIG_HIGHMEM=y + b) Enable "kernel crash dumps" feature (under "Processor type and features") + CONFIG_CRASH_DUMP=y + c) Make sure a suitable value for "Physical address where the kernel is + loaded" (under "Processor type and features"). By default this value + is 0x1000000 (16MB) and it should be same as X (See option d above), + e.g., 16 MB or 0x1000000. + CONFIG_PHYSICAL_START=0x1000000 + d) Enable "/proc/vmcore support" (Optional, under "Pseudo filesystems"). + CONFIG_PROC_VMCORE=y + +3) After booting to regular kernel or first kernel, load the second kernel + using the following command: kexec -p --args-linux --elf32-core-headers - --append="root= init 1 irqpoll" - - Note: i) has to be a vmlinux image. bzImage will not work, - as of now. - ii) By default ELF headers are stored in ELF64 format. Option - --elf32-core-headers forces generation of ELF32 headers. gdb can - not open ELF64 headers on 32 bit systems. So creating ELF32 - headers can come handy for users who have got non-PAE systems and - hence have memory less than 4GB. - iii) Specify "irqpoll" as command line parameter. This reduces driver - initialization failures in second kernel due to shared interrupts. - iv) needs to be specified in a format corresponding to - the root device name in the output of mount command. - v) If you have built the drivers required to mount root file - system as modules in , then, specify - --initrd=. - -5) System reboots into the second kernel when a panic occurs. A module can be - written to force the panic or "ALT-SysRq-c" can be used initiate a crash - dump for testing purposes. - -6) Write out the dump file using + --append="root= init 1 irqpoll maxcpus=1" + + Notes: + ====== + i) has to be a vmlinux image ie uncompressed elf image. + bzImage will not work, as of now. + ii) --args-linux has to be speicfied as if kexec it loading an elf image, + it needs to know that the arguments supplied are of linux type. + iii) By default ELF headers are stored in ELF64 format to support systems + with more than 4GB memory. Option --elf32-core-headers forces generation + of ELF32 headers. The reason for this option being, as of now gdb can + not open vmcore file with ELF64 headers on a 32 bit systems. So ELF32 + headers can be used if one has non-PAE systems and hence memory less + than 4GB. + iv) Specify "irqpoll" as command line parameter. This reduces driver + initialization failures in second kernel due to shared interrupts. + v) needs to be specified in a format corresponding to the root + device name in the output of mount command. + vi) If you have built the drivers required to mount root file system as + modules in , then, specify + --initrd=. + vii) Specify maxcpus=1 as, if during first kernel run, if panic happens on + non-boot cpus, second kernel doesn't seem to be boot up all the cpus. + The other option is to always built the second kernel without SMP + support ie CONFIG_SMP=n + +4) After successfully loading the second kernel as above, if a panic occurs + system reboots into the second kernel. A module can be written to force + the panic or "ALT-SysRq-c" can be used initiate a crash dump for testing + purposes. + +5) Once the second kernel has booted, write out the dump file using cp /proc/vmcore @@ -119,9 +124,9 @@ SETUP Entire memory: dd if=/dev/oldmem of=oldmem.001 + ANALYSIS ======== - Limited analysis can be done using gdb on the dump file copied out of /proc/vmcore. Use vmlinux built with -g and run @@ -132,15 +137,19 @@ work fine. Note: gdb cannot analyse core files generated in ELF64 format for i386. +Latest "crash" (crash-4.0-2.18) as available on Dave Anderson's site +http://people.redhat.com/~anderson/ works well with kdump format. + + TODO ==== - 1) Provide a kernel pages filtering mechanism so that core file size is not insane on systems having huge memory banks. -2) Modify "crash" tool to make it recognize this dump. +2) Relocatable kernel can help in maintaining multiple kernels for crashdump + and same kernel as the first kernel can be used to capture the dump. + CONTACT ======= - Vivek Goyal (vgoyal@in.ibm.com) Maneesh Soni (maneesh@in.ibm.com) diff --git a/trunk/Documentation/kernel-parameters.txt b/trunk/Documentation/kernel-parameters.txt index 0dc848bf0b56..dd0bfc291a68 100644 --- a/trunk/Documentation/kernel-parameters.txt +++ b/trunk/Documentation/kernel-parameters.txt @@ -475,10 +475,11 @@ running once the system is up. See Documentation/block/as-iosched.txt and Documentation/block/deadline-iosched.txt for details. - elfcorehdr= [IA-32] + elfcorehdr= [IA-32, X86_64] Specifies physical address of start of kernel core - image elf header. - See Documentation/kdump.txt for details. + image elf header. Generally kexec loader will + pass this option to capture kernel. + See Documentation/kdump/kdump.txt for details. enforcing [SELINUX] Set initial enforcing status. Format: {"0" | "1"} @@ -832,7 +833,7 @@ running once the system is up. mem=nopentium [BUGS=IA-32] Disable usage of 4MB pages for kernel memory. - memmap=exactmap [KNL,IA-32] Enable setting of an exact + memmap=exactmap [KNL,IA-32,X86_64] Enable setting of an exact E820 memory map, as specified by the user. Such memmap=exactmap lines can be constructed based on BIOS output or other requirements. See the memmap=nn@ss diff --git a/trunk/Documentation/locks.txt b/trunk/Documentation/locks.txt index ce1be79edfb8..e3b402ef33bd 100644 --- a/trunk/Documentation/locks.txt +++ b/trunk/Documentation/locks.txt @@ -65,20 +65,3 @@ The default is to disallow mandatory locking. The intention is that mandatory locking only be enabled on a local filesystem as the specific need arises. -Until an updated version of mount(8) becomes available you may have to apply -this patch to the mount sources (based on the version distributed with Rick -Faith's util-linux-2.5 package): - -*** mount.c.orig Sat Jun 8 09:14:31 1996 ---- mount.c Sat Jun 8 09:13:02 1996 -*************** -*** 100,105 **** ---- 100,107 ---- - { "noauto", 0, MS_NOAUTO }, /* Can only be mounted explicitly */ - { "user", 0, MS_USER }, /* Allow ordinary user to mount */ - { "nouser", 1, MS_USER }, /* Forbid ordinary user to mount */ -+ { "mand", 0, MS_MANDLOCK }, /* Allow mandatory locks on this FS */ -+ { "nomand", 1, MS_MANDLOCK }, /* Forbid mandatory locks on this FS */ - /* add new options here */ - #ifdef MS_NOSUB - { "sub", 1, MS_NOSUB }, /* allow submounts */ diff --git a/trunk/Documentation/stable_kernel_rules.txt b/trunk/Documentation/stable_kernel_rules.txt index 2c81305090df..e409e5d07486 100644 --- a/trunk/Documentation/stable_kernel_rules.txt +++ b/trunk/Documentation/stable_kernel_rules.txt @@ -1,58 +1,56 @@ Everything you ever wanted to know about Linux 2.6 -stable releases. -Rules on what kind of patches are accepted, and what ones are not, into -the "-stable" tree: +Rules on what kind of patches are accepted, and which ones are not, into the +"-stable" tree: - It must be obviously correct and tested. - - It can not bigger than 100 lines, with context. + - It can not be bigger than 100 lines, with context. - It must fix only one thing. - It must fix a real bug that bothers people (not a, "This could be a - problem..." type thing.) + problem..." type thing). - It must fix a problem that causes a build error (but not for things marked CONFIG_BROKEN), an oops, a hang, data corruption, a real - security issue, or some "oh, that's not good" issue. In short, - something critical. - - No "theoretical race condition" issues, unless an explanation of how - the race can be exploited. + security issue, or some "oh, that's not good" issue. In short, something + critical. + - No "theoretical race condition" issues, unless an explanation of how the + race can be exploited is also provided. - It can not contain any "trivial" fixes in it (spelling changes, - whitespace cleanups, etc.) + whitespace cleanups, etc). - It must be accepted by the relevant subsystem maintainer. - - It must follow Documentation/SubmittingPatches rules. + - It must follow the Documentation/SubmittingPatches rules. Procedure for submitting patches to the -stable tree: - Send the patch, after verifying that it follows the above rules, to stable@kernel.org. - - The sender will receive an ack when the patch has been accepted into - the queue, or a nak if the patch is rejected. This response might - take a few days, according to the developer's schedules. - - If accepted, the patch will be added to the -stable queue, for review - by other developers. + - The sender will receive an ACK when the patch has been accepted into the + queue, or a NAK if the patch is rejected. This response might take a few + days, according to the developer's schedules. + - If accepted, the patch will be added to the -stable queue, for review by + other developers. - Security patches should not be sent to this alias, but instead to the - documented security@kernel.org. + documented security@kernel.org address. Review cycle: - - When the -stable maintainers decide for a review cycle, the patches - will be sent to the review committee, and the maintainer of the - affected area of the patch (unless the submitter is the maintainer of - the area) and CC: to the linux-kernel mailing list. - - The review committee has 48 hours in which to ack or nak the patch. + - When the -stable maintainers decide for a review cycle, the patches will be + sent to the review committee, and the maintainer of the affected area of + the patch (unless the submitter is the maintainer of the area) and CC: to + the linux-kernel mailing list. + - The review committee has 48 hours in which to ACK or NAK the patch. - If the patch is rejected by a member of the committee, or linux-kernel - members object to the patch, bringing up issues that the maintainers - and members did not realize, the patch will be dropped from the - queue. - - At the end of the review cycle, the acked patches will be added to - the latest -stable release, and a new -stable release will happen. - - Security patches will be accepted into the -stable tree directly from - the security kernel team, and not go through the normal review cycle. + members object to the patch, bringing up issues that the maintainers and + members did not realize, the patch will be dropped from the queue. + - At the end of the review cycle, the ACKed patches will be added to the + latest -stable release, and a new -stable release will happen. + - Security patches will be accepted into the -stable tree directly from the + security kernel team, and not go through the normal review cycle. Contact the kernel security team for more details on this procedure. Review committe: - - This will be made up of a number of kernel developers who have - volunteered for this task, and a few that haven't. - + - This is made up of a number of kernel developers who have volunteered for + this task, and a few that haven't. diff --git a/trunk/Kbuild b/trunk/Kbuild index 79003918f37f..95d6a00bace0 100644 --- a/trunk/Kbuild +++ b/trunk/Kbuild @@ -22,8 +22,6 @@ sed-$(CONFIG_MIPS) := "/^@@@/s///p" quiet_cmd_offsets = GEN $@ define cmd_offsets - mkdir -p $(dir $@); \ - cat $< | \ (set -e; \ echo "#ifndef __ASM_OFFSETS_H__"; \ echo "#define __ASM_OFFSETS_H__"; \ @@ -34,7 +32,7 @@ define cmd_offsets echo " *"; \ echo " */"; \ echo ""; \ - sed -ne $(sed-y); \ + sed -ne $(sed-y) $<; \ echo ""; \ echo "#endif" ) > $@ endef @@ -45,5 +43,6 @@ arch/$(ARCH)/kernel/asm-offsets.s: arch/$(ARCH)/kernel/asm-offsets.c FORCE $(call if_changed_dep,cc_s_c) $(obj)/$(offsets-file): arch/$(ARCH)/kernel/asm-offsets.s Kbuild + $(Q)mkdir -p $(dir $@) $(call cmd,offsets) diff --git a/trunk/MAINTAINERS b/trunk/MAINTAINERS index 07420161e669..090e10b65b09 100644 --- a/trunk/MAINTAINERS +++ b/trunk/MAINTAINERS @@ -804,6 +804,7 @@ S: Maintained DOCBOOK FOR DOCUMENTATION P: Martin Waitz M: tali@admingilde.org +T: git http://tali.admingilde.org/git/linux-docbook.git S: Maintained DOUBLETALK DRIVER diff --git a/trunk/Makefile b/trunk/Makefile index fb497ea8bc74..deedaf79cdca 100644 --- a/trunk/Makefile +++ b/trunk/Makefile @@ -141,24 +141,6 @@ VPATH := $(srctree) export srctree objtree VPATH TOPDIR -nullstring := -space := $(nullstring) # end of line - -# Take the contents of any files called localversion* and the config -# variable CONFIG_LOCALVERSION and append them to KERNELRELEASE. Be -# careful not to include files twice if building in the source -# directory. LOCALVERSION from the command line override all of this - -localver := $(objtree)/localversion* $(srctree)/localversion* -localver := $(sort $(wildcard $(localver))) -# skip backup files (containing '~') -localver := $(foreach f, $(localver), $(if $(findstring ~, $(f)),,$(f))) - -LOCALVERSION = $(subst $(space),, \ - $(shell cat /dev/null $(localver)) \ - $(patsubst "%",%,$(CONFIG_LOCALVERSION))) - -KERNELRELEASE=$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)$(LOCALVERSION) # SUBARCH tells the usermode build what the underlying arch is. That is set # first, and if a usermode build is happening, the "ARCH=um" on the command @@ -353,7 +335,10 @@ CFLAGS := -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \ -ffreestanding AFLAGS := -D__ASSEMBLY__ -export VERSION PATCHLEVEL SUBLEVEL EXTRAVERSION LOCALVERSION KERNELRELEASE \ +# Read KERNELRELEASE from .kernelrelease (if it exists) +KERNELRELEASE = $(shell cat .kernelrelease 2> /dev/null) + +export VERSION PATCHLEVEL SUBLEVEL KERNELRELEASE \ ARCH CONFIG_SHELL HOSTCC HOSTCFLAGS CROSS_COMPILE AS LD CC \ CPP AR NM STRIP OBJCOPY OBJDUMP MAKE AWK GENKSYMS PERL UTS_MACHINE \ HOSTCXX HOSTCXXFLAGS LDFLAGS_MODULE CHECK CHECKFLAGS @@ -551,26 +536,6 @@ export KBUILD_IMAGE ?= vmlinux # images. Default is /boot, but you can set it to other values export INSTALL_PATH ?= /boot -# If CONFIG_LOCALVERSION_AUTO is set, we automatically perform some tests -# and try to determine if the current source tree is a release tree, of any sort, -# or if is a pure development tree. -# -# A 'release tree' is any tree with a git TAG associated -# with it. The primary goal of this is to make it safe for a native -# git/CVS/SVN user to build a release tree (i.e, 2.6.9) and also to -# continue developing against the current Linus tree, without having the Linus -# tree overwrite the 2.6.9 tree when installed. -# -# Currently, only git is supported. -# Other SCMs can edit scripts/setlocalversion and add the appropriate -# checks as needed. - - -ifdef CONFIG_LOCALVERSION_AUTO - localversion-auto := $(shell $(PERL) $(srctree)/scripts/setlocalversion $(srctree)) - LOCALVERSION := $(LOCALVERSION)$(localversion-auto) -endif - # # INSTALL_MOD_PATH specifies a prefix to MODLIB for module directory # relocations required by build roots. This is not defined in the @@ -782,6 +747,50 @@ $(sort $(vmlinux-init) $(vmlinux-main)) $(vmlinux-lds): $(vmlinux-dirs) ; $(vmlinux-dirs): prepare scripts $(Q)$(MAKE) $(build)=$@ +# Build the kernel release string +# The KERNELRELEASE is stored in a file named .kernelrelease +# to be used when executing for example make install or make modules_install +# +# Take the contents of any files called localversion* and the config +# variable CONFIG_LOCALVERSION and append them to KERNELRELEASE. +# LOCALVERSION from the command line override all of this + +nullstring := +space := $(nullstring) # end of line + +___localver = $(objtree)/localversion* $(srctree)/localversion* +__localver = $(sort $(wildcard $(___localver))) +# skip backup files (containing '~') +_localver = $(foreach f, $(__localver), $(if $(findstring ~, $(f)),,$(f))) + +localver = $(subst $(space),, \ + $(shell cat /dev/null $(_localver)) \ + $(patsubst "%",%,$(CONFIG_LOCALVERSION))) + +# If CONFIG_LOCALVERSION_AUTO is set scripts/setlocalversion is called +# and if the SCM is know a tag from the SCM is appended. +# The appended tag is determinded by the SCM used. +# +# Currently, only git is supported. +# Other SCMs can edit scripts/setlocalversion and add the appropriate +# checks as needed. +ifdef CONFIG_LOCALVERSION_AUTO + _localver-auto = $(shell $(CONFIG_SHELL) \ + $(srctree)/scripts/setlocalversion $(srctree)) + localver-auto = $(LOCALVERSION)$(_localver-auto) +endif + +localver-full = $(localver)$(localver-auto) + +# Store (new) KERNELRELASE string in .kernelrelease +kernelrelease = \ + $(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)$(localver-full) +.kernelrelease: FORCE + $(Q)rm -f .kernelrelease + $(Q)echo $(kernelrelease) > .kernelrelease + $(Q)echo " Building kernel $(kernelrelease)" + + # Things we need to do before we recursively start building the kernel # or the modules are listed in "prepare". # A multi level approach is used. prepareN is processed before prepareN-1. @@ -798,8 +807,7 @@ $(vmlinux-dirs): prepare scripts # and if so do: # 1) Check that make has not been executed in the kernel src $(srctree) # 2) Create the include2 directory, used for the second asm symlink - -prepare3: +prepare3: .kernelrelease ifneq ($(KBUILD_SRC),) @echo ' Using $(srctree) as source for kernel' $(Q)if [ -f $(srctree)/.config ]; then \ @@ -984,9 +992,9 @@ CLEAN_FILES += vmlinux System.map \ # Directories & files removed with 'make mrproper' MRPROPER_DIRS += include/config include2 -MRPROPER_FILES += .config .config.old include/asm .version \ +MRPROPER_FILES += .config .config.old include/asm .version .old_version \ include/linux/autoconf.h include/linux/version.h \ - Module.symvers tags TAGS cscope* + .kernelrelease Module.symvers tags TAGS cscope* # clean - Delete most, but leave enough to build external modules # @@ -1072,6 +1080,7 @@ help: @echo ' tags/TAGS - Generate tags file for editors' @echo ' cscope - Generate cscope index' @echo ' kernelrelease - Output the release version string' + @echo ' kernelversion - Output the version stored in Makefile' @echo '' @echo 'Static analysers' @echo ' buildcheck - List dangling references to vmlinux discarded sections' @@ -1293,6 +1302,8 @@ checkstack: kernelrelease: @echo $(KERNELRELEASE) +kernelversion: + @echo $(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION) # FIXME Should go into a make.lib or something # =========================================================================== diff --git a/trunk/arch/alpha/kernel/alpha_ksyms.c b/trunk/arch/alpha/kernel/alpha_ksyms.c index f3e98f837784..1898ea79d0e2 100644 --- a/trunk/arch/alpha/kernel/alpha_ksyms.c +++ b/trunk/arch/alpha/kernel/alpha_ksyms.c @@ -40,7 +40,6 @@ #include extern struct hwrpb_struct *hwrpb; -extern void dump_thread(struct pt_regs *, struct user *); extern spinlock_t rtc_lock; /* these are C runtime functions with special calling conventions: */ diff --git a/trunk/arch/alpha/mm/init.c b/trunk/arch/alpha/mm/init.c index 90752f6d8867..486d7945583d 100644 --- a/trunk/arch/alpha/mm/init.c +++ b/trunk/arch/alpha/mm/init.c @@ -7,6 +7,7 @@ /* 2.3.x zone allocator, 1999 Andrea Arcangeli */ #include +#include #include #include #include diff --git a/trunk/arch/arm/plat-omap/dma.c b/trunk/arch/arm/plat-omap/dma.c index f5cc21ad0956..a4e5ac77f6df 100644 --- a/trunk/arch/arm/plat-omap/dma.c +++ b/trunk/arch/arm/plat-omap/dma.c @@ -64,7 +64,7 @@ static int dma_chan_count; static spinlock_t dma_chan_lock; static struct omap_dma_lch dma_chan[OMAP_LOGICAL_DMA_CH_COUNT]; -const static u8 omap1_dma_irq[OMAP_LOGICAL_DMA_CH_COUNT] = { +static const u8 omap1_dma_irq[OMAP_LOGICAL_DMA_CH_COUNT] = { INT_DMA_CH0_6, INT_DMA_CH1_7, INT_DMA_CH2_8, INT_DMA_CH3, INT_DMA_CH4, INT_DMA_CH5, INT_1610_DMA_CH6, INT_1610_DMA_CH7, INT_1610_DMA_CH8, INT_1610_DMA_CH9, INT_1610_DMA_CH10, diff --git a/trunk/arch/arm26/kernel/armksyms.c b/trunk/arch/arm26/kernel/armksyms.c index 35514b398e2e..811a6376c624 100644 --- a/trunk/arch/arm26/kernel/armksyms.c +++ b/trunk/arch/arm26/kernel/armksyms.c @@ -35,7 +35,6 @@ #include #include -extern void dump_thread(struct pt_regs *, struct user *); extern int dump_fpu(struct pt_regs *, struct user_fp_struct *); extern void inswb(unsigned int port, void *to, int len); extern void outswb(unsigned int port, const void *to, int len); diff --git a/trunk/arch/cris/kernel/crisksyms.c b/trunk/arch/cris/kernel/crisksyms.c index 85833d704ebb..de39725da920 100644 --- a/trunk/arch/cris/kernel/crisksyms.c +++ b/trunk/arch/cris/kernel/crisksyms.c @@ -21,7 +21,6 @@ #include #include -extern void dump_thread(struct pt_regs *, struct user *); extern unsigned long get_cmos_time(void); extern void __Udiv(void); extern void __Umod(void); @@ -33,7 +32,6 @@ extern void __lshrdi3(void); extern void iounmap(volatile void * __iomem); /* Platform dependent support */ -EXPORT_SYMBOL(dump_thread); EXPORT_SYMBOL(kernel_thread); EXPORT_SYMBOL(get_cmos_time); EXPORT_SYMBOL(loops_per_usec); diff --git a/trunk/arch/cris/kernel/process.c b/trunk/arch/cris/kernel/process.c index 7c80afb10460..4ab3e87115b6 100644 --- a/trunk/arch/cris/kernel/process.c +++ b/trunk/arch/cris/kernel/process.c @@ -257,34 +257,6 @@ void flush_thread(void) { } -/* - * fill in the user structure for a core dump.. - */ -void dump_thread(struct pt_regs * regs, struct user * dump) -{ -#if 0 - int i; - - /* changed the size calculations - should hopefully work better. lbt */ - dump->magic = CMAGIC; - dump->start_code = 0; - dump->start_stack = regs->esp & ~(PAGE_SIZE - 1); - dump->u_tsize = ((unsigned long) current->mm->end_code) >> PAGE_SHIFT; - dump->u_dsize = ((unsigned long) (current->mm->brk + (PAGE_SIZE-1))) >> PAGE_SHIFT; - dump->u_dsize -= dump->u_tsize; - dump->u_ssize = 0; - for (i = 0; i < 8; i++) - dump->u_debugreg[i] = current->debugreg[i]; - - if (dump->start_stack < TASK_SIZE) - dump->u_ssize = ((unsigned long) (TASK_SIZE - dump->start_stack)) >> PAGE_SHIFT; - - dump->regs = *regs; - - dump->u_fpvalid = dump_fpu (regs, &dump->i387); -#endif -} - /* Fill in the fpu structure for a core dump. */ int dump_fpu(struct pt_regs *regs, elf_fpregset_t *fpu) { diff --git a/trunk/arch/frv/Kconfig b/trunk/arch/frv/Kconfig index 61261b78ced7..60a617aff8ba 100644 --- a/trunk/arch/frv/Kconfig +++ b/trunk/arch/frv/Kconfig @@ -6,10 +6,6 @@ config FRV bool default y -config UID16 - bool - default y - config RWSEM_GENERIC_SPINLOCK bool default y diff --git a/trunk/arch/frv/boot/Makefile b/trunk/arch/frv/boot/Makefile index d75e0d771366..5dfc93fd945a 100644 --- a/trunk/arch/frv/boot/Makefile +++ b/trunk/arch/frv/boot/Makefile @@ -57,10 +57,10 @@ initrd: # installation # install: $(CONFIGURE) Image - sh ./install.sh $(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION) Image $(TOPDIR)/System.map "$(INSTALL_PATH)" + sh ./install.sh $(KERNELRELEASE) Image $(TOPDIR)/System.map "$(INSTALL_PATH)" zinstall: $(CONFIGURE) zImage - sh ./install.sh $(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION) zImage $(TOPDIR)/System.map "$(INSTALL_PATH)" + sh ./install.sh $(KERNELRELEASE) zImage $(TOPDIR)/System.map "$(INSTALL_PATH)" # # miscellany diff --git a/trunk/arch/frv/kernel/frv_ksyms.c b/trunk/arch/frv/kernel/frv_ksyms.c index 5f118c89d091..0f1c6cbc4f50 100644 --- a/trunk/arch/frv/kernel/frv_ksyms.c +++ b/trunk/arch/frv/kernel/frv_ksyms.c @@ -18,7 +18,6 @@ #include #include -extern void dump_thread(struct pt_regs *, struct user *); extern long __memcpy_user(void *dst, const void *src, size_t count); extern long __memset_user(void *dst, const void *src, size_t count); @@ -27,7 +26,6 @@ extern long __memset_user(void *dst, const void *src, size_t count); EXPORT_SYMBOL(__ioremap); EXPORT_SYMBOL(iounmap); -EXPORT_SYMBOL(dump_thread); EXPORT_SYMBOL(strnlen); EXPORT_SYMBOL(strrchr); EXPORT_SYMBOL(strstr); diff --git a/trunk/arch/frv/kernel/process.c b/trunk/arch/frv/kernel/process.c index 54a452136f00..c4488379ac3b 100644 --- a/trunk/arch/frv/kernel/process.c +++ b/trunk/arch/frv/kernel/process.c @@ -243,28 +243,6 @@ int copy_thread(int nr, unsigned long clone_flags, return 0; } /* end copy_thread() */ -/* - * fill in the user structure for a core dump.. - */ -void dump_thread(struct pt_regs *regs, struct user *dump) -{ -#if 0 - /* changed the size calculations - should hopefully work better. lbt */ - dump->magic = CMAGIC; - dump->start_code = 0; - dump->start_stack = user_stack(regs) & ~(PAGE_SIZE - 1); - dump->u_tsize = ((unsigned long) current->mm->end_code) >> PAGE_SHIFT; - dump->u_dsize = ((unsigned long) (current->mm->brk + (PAGE_SIZE-1))) >> PAGE_SHIFT; - dump->u_dsize -= dump->u_tsize; - dump->u_ssize = 0; - - if (dump->start_stack < TASK_SIZE) - dump->u_ssize = ((unsigned long) (TASK_SIZE - dump->start_stack)) >> PAGE_SHIFT; - - dump->regs = *(struct user_context *) regs; -#endif -} - /* * sys_execve() executes a new program. */ diff --git a/trunk/arch/h8300/kernel/gpio.c b/trunk/arch/h8300/kernel/gpio.c index 795682b873e2..d195568ca8a2 100644 --- a/trunk/arch/h8300/kernel/gpio.c +++ b/trunk/arch/h8300/kernel/gpio.c @@ -122,7 +122,7 @@ int h8300_get_gpio_dir(int port_bit) static char *port_status(int portno) { static char result[10]; - const static char io[2]={'I','O'}; + static const char io[2]={'I','O'}; char *rp; int c; unsigned char used,ddr; @@ -143,7 +143,7 @@ static int gpio_proc_read(char *buf, char **start, off_t offset, int len, int *unused_i, void *unused_v) { int c,outlen; - const static char port_name[]="123456789ABCDEFGH"; + static const char port_name[]="123456789ABCDEFGH"; outlen = 0; for (c = 0; c < MAX_PORT; c++) { if (ddrs[c] == NULL) diff --git a/trunk/arch/h8300/kernel/h8300_ksyms.c b/trunk/arch/h8300/kernel/h8300_ksyms.c index 5a630233112f..3e0d80ea4464 100644 --- a/trunk/arch/h8300/kernel/h8300_ksyms.c +++ b/trunk/arch/h8300/kernel/h8300_ksyms.c @@ -22,11 +22,8 @@ //asmlinkage long long __lshrdi3 (long long, int); extern char h8300_debug_device[]; -extern void dump_thread(struct pt_regs *, struct user *); - /* platform dependent support */ -EXPORT_SYMBOL(dump_thread); EXPORT_SYMBOL(strnlen); EXPORT_SYMBOL(strrchr); EXPORT_SYMBOL(strstr); diff --git a/trunk/arch/h8300/kernel/process.c b/trunk/arch/h8300/kernel/process.c index fe21adf3e75e..585ed5efd0f7 100644 --- a/trunk/arch/h8300/kernel/process.c +++ b/trunk/arch/h8300/kernel/process.c @@ -207,34 +207,6 @@ int copy_thread(int nr, unsigned long clone_flags, return 0; } -/* - * fill in the user structure for a core dump.. - */ -void dump_thread(struct pt_regs * regs, struct user * dump) -{ -/* changed the size calculations - should hopefully work better. lbt */ - dump->magic = CMAGIC; - dump->start_code = 0; - dump->start_stack = rdusp() & ~(PAGE_SIZE - 1); - dump->u_tsize = ((unsigned long) current->mm->end_code) >> PAGE_SHIFT; - dump->u_dsize = ((unsigned long) (current->mm->brk + - (PAGE_SIZE-1))) >> PAGE_SHIFT; - dump->u_dsize -= dump->u_tsize; - dump->u_ssize = 0; - - dump->u_ar0 = (struct user_regs_struct *)(((int)(&dump->regs)) -((int)(dump))); - dump->regs.er0 = regs->er0; - dump->regs.er1 = regs->er1; - dump->regs.er2 = regs->er2; - dump->regs.er3 = regs->er3; - dump->regs.er4 = regs->er4; - dump->regs.er5 = regs->er5; - dump->regs.er6 = regs->er6; - dump->regs.orig_er0 = regs->orig_er0; - dump->regs.ccr = regs->ccr; - dump->regs.pc = regs->pc; -} - /* * sys_execve() executes a new program. */ diff --git a/trunk/arch/h8300/platform/h8300h/ptrace_h8300h.c b/trunk/arch/h8300/platform/h8300h/ptrace_h8300h.c index 6ac93c05a1ae..746b1ae672a1 100644 --- a/trunk/arch/h8300/platform/h8300h/ptrace_h8300h.c +++ b/trunk/arch/h8300/platform/h8300h/ptrace_h8300h.c @@ -98,7 +98,7 @@ struct optable { .type = jmp, \ } -const static struct optable optable_0[] = { +static const struct optable optable_0[] = { OPTABLE(0x00,0xff, 1,none), /* 0x00 */ OPTABLE(0x01,0xff,-1,none), /* 0x01 */ OPTABLE(0x02,0xfe, 1,none), /* 0x02-0x03 */ @@ -131,31 +131,31 @@ const static struct optable optable_0[] = { OPTABLE(0x80,0x80, 1,none), /* 0x80-0xff */ }; -const static struct optable optable_1[] = { +static const struct optable optable_1[] = { OPTABLE(0x00,0xff,-3,none), /* 0x0100 */ OPTABLE(0x40,0xf0,-3,none), /* 0x0140-0x14f */ OPTABLE(0x80,0xf0, 1,none), /* 0x0180-0x018f */ OPTABLE(0xc0,0xc0, 2,none), /* 0x01c0-0x01ff */ }; -const static struct optable optable_2[] = { +static const struct optable optable_2[] = { OPTABLE(0x00,0x20, 2,none), /* 0x6a0?/0x6a8?/0x6b0?/0x6b8? */ OPTABLE(0x20,0x20, 3,none), /* 0x6a2?/0x6aa?/0x6b2?/0x6ba? */ }; -const static struct optable optable_3[] = { +static const struct optable optable_3[] = { OPTABLE(0x69,0xfb, 2,none), /* 0x010069/0x01006d/014069/0x01406d */ OPTABLE(0x6b,0xff,-4,none), /* 0x01006b/0x01406b */ OPTABLE(0x6f,0xff, 3,none), /* 0x01006f/0x01406f */ OPTABLE(0x78,0xff, 5,none), /* 0x010078/0x014078 */ }; -const static struct optable optable_4[] = { +static const struct optable optable_4[] = { OPTABLE(0x00,0x78, 3,none), /* 0x0100690?/0x01006d0?/0140690/0x01406d0?/0x0100698?/0x01006d8?/0140698?/0x01406d8? */ OPTABLE(0x20,0x78, 4,none), /* 0x0100692?/0x01006d2?/0140692/0x01406d2?/0x010069a?/0x01006da?/014069a?/0x01406da? */ }; -const static struct optables_list { +static const struct optables_list { const struct optable *ptr; int size; } optables[] = { diff --git a/trunk/arch/h8300/platform/h8s/ints.c b/trunk/arch/h8300/platform/h8s/ints.c index 5441cdd12a39..f6ed663bdde0 100644 --- a/trunk/arch/h8300/platform/h8s/ints.c +++ b/trunk/arch/h8300/platform/h8s/ints.c @@ -52,7 +52,7 @@ struct irq_pins { unsigned char bit_no; }; /* ISTR = 0 */ -const static struct irq_pins irq_assign_table0[16]={ +static const struct irq_pins irq_assign_table0[16]={ {H8300_GPIO_P5,H8300_GPIO_B0},{H8300_GPIO_P5,H8300_GPIO_B1}, {H8300_GPIO_P5,H8300_GPIO_B2},{H8300_GPIO_P5,H8300_GPIO_B3}, {H8300_GPIO_P5,H8300_GPIO_B4},{H8300_GPIO_P5,H8300_GPIO_B5}, @@ -63,7 +63,7 @@ const static struct irq_pins irq_assign_table0[16]={ {H8300_GPIO_PF,H8300_GPIO_B1},{H8300_GPIO_PF,H8300_GPIO_B2}, }; /* ISTR = 1 */ -const static struct irq_pins irq_assign_table1[16]={ +static const struct irq_pins irq_assign_table1[16]={ {H8300_GPIO_P8,H8300_GPIO_B0},{H8300_GPIO_P8,H8300_GPIO_B1}, {H8300_GPIO_P8,H8300_GPIO_B2},{H8300_GPIO_P8,H8300_GPIO_B3}, {H8300_GPIO_P8,H8300_GPIO_B4},{H8300_GPIO_P8,H8300_GPIO_B5}, diff --git a/trunk/arch/h8300/platform/h8s/ints_h8s.c b/trunk/arch/h8300/platform/h8s/ints_h8s.c index f53de493e3e8..8268dfd12f1f 100644 --- a/trunk/arch/h8300/platform/h8s/ints_h8s.c +++ b/trunk/arch/h8300/platform/h8s/ints_h8s.c @@ -42,7 +42,7 @@ struct irq_pins { unsigned char bit_no; } __attribute__((aligned(1),packed)); /* ISTR = 0 */ -const static struct irq_pins irq_assign_table0[16]={ +static const struct irq_pins irq_assign_table0[16]={ {H8300_GPIO_P5,H8300_GPIO_B0},{H8300_GPIO_P5,H8300_GPIO_B1}, {H8300_GPIO_P5,H8300_GPIO_B2},{H8300_GPIO_P5,H8300_GPIO_B3}, {H8300_GPIO_P5,H8300_GPIO_B4},{H8300_GPIO_P5,H8300_GPIO_B5}, @@ -53,7 +53,7 @@ const static struct irq_pins irq_assign_table0[16]={ {H8300_GPIO_PF,H8300_GPIO_B1},{H8300_GPIO_PF,H8300_GPIO_B2}, }; /* ISTR = 1 */ -const static struct irq_pins irq_assign_table1[16]={ +static const struct irq_pins irq_assign_table1[16]={ {H8300_GPIO_P8,H8300_GPIO_B0},{H8300_GPIO_P8,H8300_GPIO_B1}, {H8300_GPIO_P8,H8300_GPIO_B2},{H8300_GPIO_P8,H8300_GPIO_B3}, {H8300_GPIO_P8,H8300_GPIO_B4},{H8300_GPIO_P8,H8300_GPIO_B5}, diff --git a/trunk/arch/i386/Kconfig b/trunk/arch/i386/Kconfig index d849c6870e3a..815878ebd30f 100644 --- a/trunk/arch/i386/Kconfig +++ b/trunk/arch/i386/Kconfig @@ -645,17 +645,6 @@ config SECCOMP source kernel/Kconfig.hz -config PHYSICAL_START - hex "Physical address where the kernel is loaded" if EMBEDDED - default "0x100000" - help - This gives the physical address where the kernel is loaded. - Primarily used in the case of kexec on panic where the - fail safe kernel needs to run at a different address than - the panic-ed kernel. - - Don't change this unless you know what you are doing. - config KEXEC bool "kexec system call (EXPERIMENTAL)" depends on EXPERIMENTAL @@ -675,11 +664,31 @@ config KEXEC config CRASH_DUMP bool "kernel crash dumps (EXPERIMENTAL)" - depends on EMBEDDED depends on EXPERIMENTAL depends on HIGHMEM help Generate crash dump after being started by kexec. + +config PHYSICAL_START + hex "Physical address where the kernel is loaded" if (EMBEDDED || CRASH_DUMP) + + default "0x1000000" if CRASH_DUMP + default "0x100000" + help + This gives the physical address where the kernel is loaded. Normally + for regular kernels this value is 0x100000 (1MB). But in the case + of kexec on panic the fail safe kernel needs to run at a different + address than the panic-ed kernel. This option is used to set the load + address for kernels used to capture crash dump on being kexec'ed + after panic. The default value for crash dump kernels is + 0x1000000 (16MB). This can also be set based on the "X" value as + specified in the "crashkernel=YM@XM" command line boot parameter + passed to the panic-ed kernel. Typically this parameter is set as + crashkernel=64M@16M. Please take a look at + Documentation/kdump/kdump.txt for more details about crash dumps. + + Don't change this unless you know what you are doing. + endmenu @@ -1051,3 +1060,7 @@ config X86_TRAMPOLINE bool depends on X86_SMP || (X86_VOYAGER && SMP) default y + +config KTIME_SCALAR + bool + default y diff --git a/trunk/arch/i386/Makefile b/trunk/arch/i386/Makefile index b84119f9cc63..d3c0409d201c 100644 --- a/trunk/arch/i386/Makefile +++ b/trunk/arch/i386/Makefile @@ -37,7 +37,10 @@ CFLAGS += $(call cc-option,-mpreferred-stack-boundary=2) # CPU-specific tuning. Anything which can be shared with UML should go here. include $(srctree)/arch/i386/Makefile.cpu -cflags-$(CONFIG_REGPARM) += -mregparm=3 +# -mregparm=3 works ok on gcc-3.0 and later +# +cflags-$(CONFIG_REGPARM) += $(shell if [ $(call cc-version) -ge 0300 ] ; then \ + echo "-mregparm=3"; fi ;) # Disable unit-at-a-time mode, it makes gcc use a lot more stack # due to the lack of sharing of stacklots. @@ -100,7 +103,7 @@ AFLAGS += $(mflags-y) boot := arch/i386/boot .PHONY: zImage bzImage compressed zlilo bzlilo \ - zdisk bzdisk fdimage fdimage144 fdimage288 install kernel_install + zdisk bzdisk fdimage fdimage144 fdimage288 install all: bzImage @@ -122,8 +125,7 @@ zdisk bzdisk: vmlinux fdimage fdimage144 fdimage288: vmlinux $(Q)$(MAKE) $(build)=$(boot) BOOTIMAGE=$(KBUILD_IMAGE) $@ -install: vmlinux -install kernel_install: +install: $(Q)$(MAKE) $(build)=$(boot) BOOTIMAGE=$(KBUILD_IMAGE) install archclean: diff --git a/trunk/arch/i386/boot/Makefile b/trunk/arch/i386/boot/Makefile index 1e71382d413a..0fea75dd4e31 100644 --- a/trunk/arch/i386/boot/Makefile +++ b/trunk/arch/i386/boot/Makefile @@ -100,5 +100,5 @@ zlilo: $(BOOTIMAGE) cp System.map $(INSTALL_PATH)/ if [ -x /sbin/lilo ]; then /sbin/lilo; else /etc/lilo/install; fi -install: $(BOOTIMAGE) +install: sh $(srctree)/$(src)/install.sh $(KERNELRELEASE) $< System.map "$(INSTALL_PATH)" diff --git a/trunk/arch/i386/boot/install.sh b/trunk/arch/i386/boot/install.sh index f17b40dfc0f4..5e44c736eea8 100644 --- a/trunk/arch/i386/boot/install.sh +++ b/trunk/arch/i386/boot/install.sh @@ -19,6 +19,20 @@ # $4 - default install path (blank if root directory) # +verify () { + if [ ! -f "$1" ]; then + echo "" 1>&2 + echo " *** Missing file: $1" 1>&2 + echo ' *** You need to run "make" before "make install".' 1>&2 + echo "" 1>&2 + exit 1 + fi +} + +# Make sure the files actually exist +verify "$2" +verify "$3" + # User may have a custom install script if [ -x ~/bin/${CROSS_COMPILE}installkernel ]; then exec ~/bin/${CROSS_COMPILE}installkernel "$@"; fi diff --git a/trunk/arch/i386/boot/video.S b/trunk/arch/i386/boot/video.S index 92f669470142..2ac40c8244c4 100644 --- a/trunk/arch/i386/boot/video.S +++ b/trunk/arch/i386/boot/video.S @@ -97,7 +97,6 @@ #define PARAM_VESAPM_OFF 0x30 #define PARAM_LFB_PAGES 0x32 #define PARAM_VESA_ATTRIB 0x34 -#define PARAM_CAPABILITIES 0x36 /* Define DO_STORE according to CONFIG_VIDEO_RETAIN */ #ifdef CONFIG_VIDEO_RETAIN @@ -234,10 +233,6 @@ mopar_gr: movw 18(%di), %ax movl %eax, %fs:(PARAM_LFB_SIZE) -# store mode capabilities - movl 10(%di), %eax - movl %eax, %fs:(PARAM_CAPABILITIES) - # switching the DAC to 8-bit is for <= 8 bpp only movw %fs:(PARAM_LFB_DEPTH), %ax cmpw $8, %ax diff --git a/trunk/arch/i386/kernel/Makefile b/trunk/arch/i386/kernel/Makefile index be1880bb75b4..60c3f76dfca4 100644 --- a/trunk/arch/i386/kernel/Makefile +++ b/trunk/arch/i386/kernel/Makefile @@ -25,6 +25,7 @@ obj-$(CONFIG_X86_LOCAL_APIC) += apic.o nmi.o obj-$(CONFIG_X86_IO_APIC) += io_apic.o obj-$(CONFIG_X86_REBOOTFIXUPS) += reboot_fixups.o obj-$(CONFIG_KEXEC) += machine_kexec.o relocate_kernel.o crash.o +obj-$(CONFIG_CRASH_DUMP) += crash_dump.o obj-$(CONFIG_X86_NUMAQ) += numaq.o obj-$(CONFIG_X86_SUMMIT_NUMA) += summit.o obj-$(CONFIG_KPROBES) += kprobes.o diff --git a/trunk/arch/i386/kernel/crash.c b/trunk/arch/i386/kernel/crash.c index 0248e084017c..d49dbe8dc96b 100644 --- a/trunk/arch/i386/kernel/crash.c +++ b/trunk/arch/i386/kernel/crash.c @@ -25,7 +25,6 @@ #include -note_buf_t crash_notes[NR_CPUS]; /* This keeps a track of which one is crashing cpu. */ static int crashing_cpu; @@ -72,7 +71,9 @@ static void crash_save_this_cpu(struct pt_regs *regs, int cpu) * squirrelled away. ELF notes happen to provide * all of that that no need to invent something new. */ - buf = &crash_notes[cpu][0]; + buf = (u32*)per_cpu_ptr(crash_notes, cpu); + if (!buf) + return; memset(&prstatus, 0, sizeof(prstatus)); prstatus.pr_pid = current->pid; elf_core_copy_regs(&prstatus.pr_reg, regs); @@ -81,51 +82,12 @@ static void crash_save_this_cpu(struct pt_regs *regs, int cpu) final_note(buf); } -static void crash_get_current_regs(struct pt_regs *regs) -{ - __asm__ __volatile__("movl %%ebx,%0" : "=m"(regs->ebx)); - __asm__ __volatile__("movl %%ecx,%0" : "=m"(regs->ecx)); - __asm__ __volatile__("movl %%edx,%0" : "=m"(regs->edx)); - __asm__ __volatile__("movl %%esi,%0" : "=m"(regs->esi)); - __asm__ __volatile__("movl %%edi,%0" : "=m"(regs->edi)); - __asm__ __volatile__("movl %%ebp,%0" : "=m"(regs->ebp)); - __asm__ __volatile__("movl %%eax,%0" : "=m"(regs->eax)); - __asm__ __volatile__("movl %%esp,%0" : "=m"(regs->esp)); - __asm__ __volatile__("movw %%ss, %%ax;" :"=a"(regs->xss)); - __asm__ __volatile__("movw %%cs, %%ax;" :"=a"(regs->xcs)); - __asm__ __volatile__("movw %%ds, %%ax;" :"=a"(regs->xds)); - __asm__ __volatile__("movw %%es, %%ax;" :"=a"(regs->xes)); - __asm__ __volatile__("pushfl; popl %0" :"=m"(regs->eflags)); - - regs->eip = (unsigned long)current_text_addr(); -} - -/* CPU does not save ss and esp on stack if execution is already - * running in kernel mode at the time of NMI occurrence. This code - * fixes it. - */ -static void crash_setup_regs(struct pt_regs *newregs, struct pt_regs *oldregs) -{ - memcpy(newregs, oldregs, sizeof(*newregs)); - newregs->esp = (unsigned long)&(oldregs->esp); - __asm__ __volatile__("xorl %eax, %eax;"); - __asm__ __volatile__ ("movw %%ss, %%ax;" :"=a"(newregs->xss)); -} - -/* We may have saved_regs from where the error came from - * or it is NULL if via a direct panic(). - */ -static void crash_save_self(struct pt_regs *saved_regs) +static void crash_save_self(struct pt_regs *regs) { - struct pt_regs regs; int cpu; cpu = smp_processor_id(); - if (saved_regs) - crash_setup_regs(®s, saved_regs); - else - crash_get_current_regs(®s); - crash_save_this_cpu(®s, cpu); + crash_save_this_cpu(regs, cpu); } #ifdef CONFIG_SMP @@ -144,7 +106,7 @@ static int crash_nmi_callback(struct pt_regs *regs, int cpu) local_irq_disable(); if (!user_mode(regs)) { - crash_setup_regs(&fixed_regs, regs); + crash_fixup_ss_esp(&fixed_regs, regs); regs = &fixed_regs; } crash_save_this_cpu(regs, cpu); diff --git a/trunk/arch/i386/kernel/crash_dump.c b/trunk/arch/i386/kernel/crash_dump.c new file mode 100644 index 000000000000..3f532df488bc --- /dev/null +++ b/trunk/arch/i386/kernel/crash_dump.c @@ -0,0 +1,74 @@ +/* + * kernel/crash_dump.c - Memory preserving reboot related code. + * + * Created by: Hariprasad Nellitheertha (hari@in.ibm.com) + * Copyright (C) IBM Corporation, 2004. All rights reserved + */ + +#include +#include +#include + +#include + +static void *kdump_buf_page; + +/** + * copy_oldmem_page - copy one page from "oldmem" + * @pfn: page frame number to be copied + * @buf: target memory address for the copy; this can be in kernel address + * space or user address space (see @userbuf) + * @csize: number of bytes to copy + * @offset: offset in bytes into the page (based on pfn) to begin the copy + * @userbuf: if set, @buf is in user address space, use copy_to_user(), + * otherwise @buf is in kernel address space, use memcpy(). + * + * Copy a page from "oldmem". For this page, there is no pte mapped + * in the current kernel. We stitch up a pte, similar to kmap_atomic. + * + * Calling copy_to_user() in atomic context is not desirable. Hence first + * copying the data to a pre-allocated kernel page and then copying to user + * space in non-atomic context. + */ +ssize_t copy_oldmem_page(unsigned long pfn, char *buf, + size_t csize, unsigned long offset, int userbuf) +{ + void *vaddr; + + if (!csize) + return 0; + + vaddr = kmap_atomic_pfn(pfn, KM_PTE0); + + if (!userbuf) { + memcpy(buf, (vaddr + offset), csize); + kunmap_atomic(vaddr, KM_PTE0); + } else { + if (!kdump_buf_page) { + printk(KERN_WARNING "Kdump: Kdump buffer page not" + " allocated\n"); + return -EFAULT; + } + copy_page(kdump_buf_page, vaddr); + kunmap_atomic(vaddr, KM_PTE0); + if (copy_to_user(buf, (kdump_buf_page + offset), csize)) + return -EFAULT; + } + + return csize; +} + +static int __init kdump_buf_page_init(void) +{ + int ret = 0; + + kdump_buf_page = kmalloc(PAGE_SIZE, GFP_KERNEL); + if (!kdump_buf_page) { + printk(KERN_WARNING "Kdump: Failed to allocate kdump buffer" + " page\n"); + ret = -ENOMEM; + } + + return ret; +} +arch_initcall(kdump_buf_page_init); diff --git a/trunk/arch/i386/kernel/kprobes.c b/trunk/arch/i386/kernel/kprobes.c index 19edcd526ba4..2f372dbd34fd 100644 --- a/trunk/arch/i386/kernel/kprobes.c +++ b/trunk/arch/i386/kernel/kprobes.c @@ -57,14 +57,10 @@ static inline int is_IF_modifier(kprobe_opcode_t opcode) } int __kprobes arch_prepare_kprobe(struct kprobe *p) -{ - return 0; -} - -void __kprobes arch_copy_kprobe(struct kprobe *p) { memcpy(p->ainsn.insn, p->addr, MAX_INSN_SIZE * sizeof(kprobe_opcode_t)); p->opcode = *p->addr; + return 0; } void __kprobes arch_arm_kprobe(struct kprobe *p) @@ -81,10 +77,6 @@ void __kprobes arch_disarm_kprobe(struct kprobe *p) (unsigned long) p->addr + sizeof(kprobe_opcode_t)); } -void __kprobes arch_remove_kprobe(struct kprobe *p) -{ -} - static inline void save_previous_kprobe(struct kprobe_ctlblk *kcb) { kcb->prev_kprobe.kp = kprobe_running(); diff --git a/trunk/arch/i386/kernel/setup.c b/trunk/arch/i386/kernel/setup.c index 27c956db0461..f685637a100d 100644 --- a/trunk/arch/i386/kernel/setup.c +++ b/trunk/arch/i386/kernel/setup.c @@ -898,7 +898,7 @@ static void __init parse_cmdline_early (char ** cmdline_p) } } #endif -#ifdef CONFIG_CRASH_DUMP +#ifdef CONFIG_PROC_VMCORE /* elfcorehdr= specifies the location of elf core header * stored by the crashed kernel. */ diff --git a/trunk/arch/i386/kernel/traps.c b/trunk/arch/i386/kernel/traps.c index 53ad954e3ba4..b9f0030a2ebb 100644 --- a/trunk/arch/i386/kernel/traps.c +++ b/trunk/arch/i386/kernel/traps.c @@ -120,7 +120,7 @@ static inline unsigned long print_context_stack(struct thread_info *tinfo, #ifdef CONFIG_FRAME_POINTER while (valid_stack_ptr(tinfo, (void *)ebp)) { addr = *(unsigned long *)(ebp + 4); - printk(" [<%08lx>] ", addr); + printk(KERN_EMERG " [<%08lx>] ", addr); print_symbol("%s", addr); printk("\n"); ebp = *(unsigned long *)ebp; @@ -129,7 +129,7 @@ static inline unsigned long print_context_stack(struct thread_info *tinfo, while (valid_stack_ptr(tinfo, stack)) { addr = *stack++; if (__kernel_text_address(addr)) { - printk(" [<%08lx>]", addr); + printk(KERN_EMERG " [<%08lx>]", addr); print_symbol(" %s", addr); printk("\n"); } @@ -161,7 +161,7 @@ void show_trace(struct task_struct *task, unsigned long * stack) stack = (unsigned long*)context->previous_esp; if (!stack) break; - printk(" =======================\n"); + printk(KERN_EMERG " =======================\n"); } } @@ -178,14 +178,15 @@ void show_stack(struct task_struct *task, unsigned long *esp) } stack = esp; + printk(KERN_EMERG); for(i = 0; i < kstack_depth_to_print; i++) { if (kstack_end(stack)) break; if (i && ((i % 8) == 0)) - printk("\n "); + printk("\n" KERN_EMERG " "); printk("%08lx ", *stack++); } - printk("\nCall Trace:\n"); + printk("\n" KERN_EMERG "Call Trace:\n"); show_trace(task, esp); } @@ -216,18 +217,18 @@ void show_registers(struct pt_regs *regs) ss = regs->xss & 0xffff; } print_modules(); - printk("CPU: %d\nEIP: %04x:[<%08lx>] %s VLI\nEFLAGS: %08lx" - " (%s) \n", + printk(KERN_EMERG "CPU: %d\nEIP: %04x:[<%08lx>] %s VLI\n" + "EFLAGS: %08lx (%s) \n", smp_processor_id(), 0xffff & regs->xcs, regs->eip, print_tainted(), regs->eflags, system_utsname.release); - print_symbol("EIP is at %s\n", regs->eip); - printk("eax: %08lx ebx: %08lx ecx: %08lx edx: %08lx\n", + print_symbol(KERN_EMERG "EIP is at %s\n", regs->eip); + printk(KERN_EMERG "eax: %08lx ebx: %08lx ecx: %08lx edx: %08lx\n", regs->eax, regs->ebx, regs->ecx, regs->edx); - printk("esi: %08lx edi: %08lx ebp: %08lx esp: %08lx\n", + printk(KERN_EMERG "esi: %08lx edi: %08lx ebp: %08lx esp: %08lx\n", regs->esi, regs->edi, regs->ebp, esp); - printk("ds: %04x es: %04x ss: %04x\n", + printk(KERN_EMERG "ds: %04x es: %04x ss: %04x\n", regs->xds & 0xffff, regs->xes & 0xffff, ss); - printk("Process %s (pid: %d, threadinfo=%p task=%p)", + printk(KERN_EMERG "Process %s (pid: %d, threadinfo=%p task=%p)", current->comm, current->pid, current_thread_info(), current); /* * When in-kernel, we also print out the stack and code at the @@ -236,10 +237,10 @@ void show_registers(struct pt_regs *regs) if (in_kernel) { u8 __user *eip; - printk("\nStack: "); + printk("\n" KERN_EMERG "Stack: "); show_stack(NULL, (unsigned long*)esp); - printk("Code: "); + printk(KERN_EMERG "Code: "); eip = (u8 __user *)regs->eip - 43; for (i = 0; i < 64; i++, eip++) { @@ -280,15 +281,15 @@ static void handle_BUG(struct pt_regs *regs) (unsigned long)file < PAGE_OFFSET || __get_user(c, file)) file = ""; - printk("------------[ cut here ]------------\n"); - printk(KERN_ALERT "kernel BUG at %s:%d!\n", file, line); + printk(KERN_EMERG "------------[ cut here ]------------\n"); + printk(KERN_EMERG "kernel BUG at %s:%d!\n", file, line); no_bug: return; /* Here we know it was a BUG but file-n-line is unavailable */ bug: - printk("Kernel BUG\n"); + printk(KERN_EMERG "Kernel BUG\n"); } /* This is gone through when something in the kernel @@ -321,16 +322,20 @@ void die(const char * str, struct pt_regs * regs, long err) if (++die.lock_owner_depth < 3) { int nl = 0; handle_BUG(regs); - printk(KERN_ALERT "%s: %04lx [#%d]\n", str, err & 0xffff, ++die_counter); + printk(KERN_EMERG "%s: %04lx [#%d]\n", str, err & 0xffff, ++die_counter); #ifdef CONFIG_PREEMPT - printk("PREEMPT "); + printk(KERN_EMERG "PREEMPT "); nl = 1; #endif #ifdef CONFIG_SMP + if (!nl) + printk(KERN_EMERG); printk("SMP "); nl = 1; #endif #ifdef CONFIG_DEBUG_PAGEALLOC + if (!nl) + printk(KERN_EMERG); printk("DEBUG_PAGEALLOC"); nl = 1; #endif @@ -339,7 +344,7 @@ void die(const char * str, struct pt_regs * regs, long err) notify_die(DIE_OOPS, (char *)str, regs, err, 255, SIGSEGV); show_registers(regs); } else - printk(KERN_ERR "Recursive die() failure, output suppressed\n"); + printk(KERN_EMERG "Recursive die() failure, output suppressed\n"); bust_spinlocks(0); die.lock_owner = -1; @@ -527,8 +532,10 @@ fastcall void __kprobes do_general_protection(struct pt_regs * regs, static void mem_parity_error(unsigned char reason, struct pt_regs * regs) { - printk("Uhhuh. NMI received. Dazed and confused, but trying to continue\n"); - printk("You probably have a hardware problem with your RAM chips\n"); + printk(KERN_EMERG "Uhhuh. NMI received. Dazed and confused, but trying " + "to continue\n"); + printk(KERN_EMERG "You probably have a hardware problem with your RAM " + "chips\n"); /* Clear and disable the memory parity error line. */ clear_mem_error(reason); @@ -538,7 +545,7 @@ static void io_check_error(unsigned char reason, struct pt_regs * regs) { unsigned long i; - printk("NMI: IOCK error (debug interrupt?)\n"); + printk(KERN_EMERG "NMI: IOCK error (debug interrupt?)\n"); show_registers(regs); /* Re-enable the IOCK line, wait for a few seconds */ @@ -580,11 +587,11 @@ void die_nmi (struct pt_regs *regs, const char *msg) * to get a message out. */ bust_spinlocks(1); - printk(msg); + printk(KERN_EMERG "%s", msg); printk(" on CPU%d, eip %08lx, registers:\n", smp_processor_id(), regs->eip); show_registers(regs); - printk("console shuts up ...\n"); + printk(KERN_EMERG "console shuts up ...\n"); console_silent(); spin_unlock(&nmi_print_lock); bust_spinlocks(0); @@ -990,8 +997,8 @@ asmlinkage void math_state_restore(struct pt_regs regs) asmlinkage void math_emulate(long arg) { - printk("math-emulation not enabled and no coprocessor found.\n"); - printk("killing %s.\n",current->comm); + printk(KERN_EMERG "math-emulation not enabled and no coprocessor found.\n"); + printk(KERN_EMERG "killing %s.\n",current->comm); force_sig(SIGFPE,current); schedule(); } diff --git a/trunk/arch/ia64/Makefile b/trunk/arch/ia64/Makefile index 57b047c27e46..f722e1a25948 100644 --- a/trunk/arch/ia64/Makefile +++ b/trunk/arch/ia64/Makefile @@ -25,7 +25,6 @@ cflags-y := -pipe $(EXTRA) -ffixed-r13 -mfixed-range=f12-f15,f32-f127 \ -falign-functions=32 -frename-registers -fno-optimize-sibling-calls CFLAGS_KERNEL := -mconstant-gp -GCC_VERSION := $(call cc-version) GAS_STATUS = $(shell $(srctree)/arch/ia64/scripts/check-gas "$(CC)" "$(OBJDUMP)") CPPFLAGS += $(shell $(srctree)/arch/ia64/scripts/toolchain-flags "$(CC)" "$(OBJDUMP)" "$(READELF)") @@ -37,7 +36,7 @@ $(error Sorry, you need a newer version of the assember, one that is built from ftp://ftp.hpl.hp.com/pub/linux-ia64/gas-030124.tar.gz) endif -ifeq ($(GCC_VERSION),0304) +ifeq ($(call cc-version),0304) cflags-$(CONFIG_ITANIUM) += -mtune=merced cflags-$(CONFIG_MCKINLEY) += -mtune=mckinley endif diff --git a/trunk/arch/ia64/ia32/Makefile b/trunk/arch/ia64/ia32/Makefile index 2ed90da81166..61cb60affd95 100644 --- a/trunk/arch/ia64/ia32/Makefile +++ b/trunk/arch/ia64/ia32/Makefile @@ -2,11 +2,9 @@ # Makefile for the ia32 kernel emulation subsystem. # -obj-y := ia32_entry.o sys_ia32.o ia32_ioctl.o ia32_signal.o \ +obj-y := ia32_entry.o sys_ia32.o ia32_signal.o \ ia32_support.o ia32_traps.o binfmt_elf32.o ia32_ldt.o -CFLAGS_ia32_ioctl.o += -Ifs/ - # Don't let GCC uses f16-f31 so that save_ia32_fpstate_live() and # restore_ia32_fpstate_live() can be sure the live register contain user-level state. CFLAGS_ia32_signal.o += -mfixed-range=f16-f31 diff --git a/trunk/arch/ia64/ia32/ia32_entry.S b/trunk/arch/ia64/ia32/ia32_entry.S index 494fad6bf376..95fe04400f6b 100644 --- a/trunk/arch/ia64/ia32/ia32_entry.S +++ b/trunk/arch/ia64/ia32/ia32_entry.S @@ -469,7 +469,7 @@ ia32_syscall_table: data8 sys32_epoll_wait data8 sys_remap_file_pages data8 sys_set_tid_address - data8 sys32_timer_create + data8 compat_sys_timer_create data8 compat_sys_timer_settime /* 260 */ data8 compat_sys_timer_gettime data8 sys_timer_getoverrun diff --git a/trunk/arch/ia64/ia32/ia32_ioctl.c b/trunk/arch/ia64/ia32/ia32_ioctl.c deleted file mode 100644 index 88739394f6df..000000000000 --- a/trunk/arch/ia64/ia32/ia32_ioctl.c +++ /dev/null @@ -1,45 +0,0 @@ -/* - * IA32 Architecture-specific ioctl shim code - * - * Copyright (C) 2000 VA Linux Co - * Copyright (C) 2000 Don Dugger - * Copyright (C) 2001-2003 Hewlett-Packard Co - * David Mosberger-Tang - */ - -#include /* argh, msdos_fs.h isn't self-contained... */ -#include -#include "ia32priv.h" - -#define INCLUDES -#include "compat_ioctl.c" - -#define IOCTL_NR(a) ((a) & ~(_IOC_SIZEMASK << _IOC_SIZESHIFT)) - -#define DO_IOCTL(fd, cmd, arg) ({ \ - int _ret; \ - mm_segment_t _old_fs = get_fs(); \ - \ - set_fs(KERNEL_DS); \ - _ret = sys_ioctl(fd, cmd, (unsigned long)arg); \ - set_fs(_old_fs); \ - _ret; \ -}) - -#define CODE -#include "compat_ioctl.c" - -#define COMPATIBLE_IOCTL(cmd) HANDLE_IOCTL((cmd),sys_ioctl) -#define HANDLE_IOCTL(cmd,handler) { (cmd), (ioctl_trans_handler_t)(handler), NULL }, -#define IOCTL_TABLE_START \ - struct ioctl_trans ioctl_start[] = { -#define IOCTL_TABLE_END \ - }; - -IOCTL_TABLE_START -#define DECLARES -#include "compat_ioctl.c" -#include -IOCTL_TABLE_END - -int ioctl_table_size = ARRAY_SIZE(ioctl_start); diff --git a/trunk/arch/ia64/ia32/sys_ia32.c b/trunk/arch/ia64/ia32/sys_ia32.c index 9f8e8d558873..5ea38286d8d5 100644 --- a/trunk/arch/ia64/ia32/sys_ia32.c +++ b/trunk/arch/ia64/ia32/sys_ia32.c @@ -2553,34 +2553,6 @@ sys32_get_thread_area (struct ia32_user_desc __user *u_info) return 0; } -asmlinkage long -sys32_timer_create(u32 clock, struct compat_sigevent __user *se32, timer_t __user *timer_id) -{ - struct sigevent se; - mm_segment_t oldfs; - timer_t t; - long err; - - if (se32 == NULL) - return sys_timer_create(clock, NULL, timer_id); - - if (get_compat_sigevent(&se, se32)) - return -EFAULT; - - if (!access_ok(VERIFY_WRITE,timer_id,sizeof(timer_t))) - return -EFAULT; - - oldfs = get_fs(); - set_fs(KERNEL_DS); - err = sys_timer_create(clock, (struct sigevent __user *) &se, (timer_t __user *) &t); - set_fs(oldfs); - - if (!err) - err = __put_user (t, timer_id); - - return err; -} - long sys32_fadvise64_64(int fd, __u32 offset_low, __u32 offset_high, __u32 len_low, __u32 len_high, int advice) { diff --git a/trunk/arch/ia64/kernel/kprobes.c b/trunk/arch/ia64/kernel/kprobes.c index 89a70400c4f6..4de7f6759093 100644 --- a/trunk/arch/ia64/kernel/kprobes.c +++ b/trunk/arch/ia64/kernel/kprobes.c @@ -467,10 +467,6 @@ void __kprobes arch_disarm_kprobe(struct kprobe *p) flush_icache_range(arm_addr, arm_addr + sizeof(bundle_t)); } -void __kprobes arch_remove_kprobe(struct kprobe *p) -{ -} - /* * We are resuming execution after a single step fault, so the pt_regs * structure reflects the register state after we executed the instruction diff --git a/trunk/arch/m32r/Kconfig b/trunk/arch/m32r/Kconfig index fae67bbb52f6..a3dcc3fab4b7 100644 --- a/trunk/arch/m32r/Kconfig +++ b/trunk/arch/m32r/Kconfig @@ -12,10 +12,6 @@ config M32R config SBUS bool -config UID16 - bool - default n - config GENERIC_ISA_DMA bool default y diff --git a/trunk/arch/m32r/kernel/m32r_ksyms.c b/trunk/arch/m32r/kernel/m32r_ksyms.c index e5ec134d81d9..dbc8a392105f 100644 --- a/trunk/arch/m32r/kernel/m32r_ksyms.c +++ b/trunk/arch/m32r/kernel/m32r_ksyms.c @@ -18,8 +18,6 @@ #include #include -extern void dump_thread(struct pt_regs *, struct user *); - #if defined(CONFIG_BLK_DEV_IDE) || defined(CONFIG_BLK_DEV_HD) || defined(CONFIG_BLK_DEV_IDE_MODULE) || defined(CONFIG_BLK_DEV_HD_MODULE) extern struct drive_info_struct drive_info; EXPORT_SYMBOL(drive_info); @@ -27,7 +25,6 @@ EXPORT_SYMBOL(drive_info); /* platform dependent support */ EXPORT_SYMBOL(boot_cpu_data); -EXPORT_SYMBOL(dump_thread); EXPORT_SYMBOL(dump_fpu); EXPORT_SYMBOL(__ioremap); EXPORT_SYMBOL(iounmap); diff --git a/trunk/arch/m32r/kernel/process.c b/trunk/arch/m32r/kernel/process.c index 3bf55d92933f..2a1f250349b7 100644 --- a/trunk/arch/m32r/kernel/process.c +++ b/trunk/arch/m32r/kernel/process.c @@ -260,14 +260,6 @@ int copy_thread(int nr, unsigned long clone_flags, unsigned long spu, return 0; } -/* - * fill in the user structure for a core dump.. - */ -void dump_thread(struct pt_regs * regs, struct user * dump) -{ - /* M32R_FIXME */ -} - /* * Capture the user space registers if the task is not running (in user space) */ diff --git a/trunk/arch/m68k/kernel/m68k_ksyms.c b/trunk/arch/m68k/kernel/m68k_ksyms.c index 73e2f5e168dd..3d7f2000b714 100644 --- a/trunk/arch/m68k/kernel/m68k_ksyms.c +++ b/trunk/arch/m68k/kernel/m68k_ksyms.c @@ -23,8 +23,6 @@ asmlinkage long long __lshrdi3 (long long, int); asmlinkage long long __muldi3 (long long, long long); extern char m68k_debug_device[]; -extern void dump_thread(struct pt_regs *, struct user *); - /* platform dependent support */ EXPORT_SYMBOL(m68k_machtype); diff --git a/trunk/arch/m68knommu/kernel/m68k_ksyms.c b/trunk/arch/m68knommu/kernel/m68k_ksyms.c index b2c62eeb3bab..eddb8d3e130a 100644 --- a/trunk/arch/m68knommu/kernel/m68k_ksyms.c +++ b/trunk/arch/m68knommu/kernel/m68k_ksyms.c @@ -18,7 +18,6 @@ #include #include -extern void dump_thread(struct pt_regs *, struct user *); extern int dump_fpu(struct pt_regs *, elf_fpregset_t *); /* platform dependent support */ @@ -26,7 +25,6 @@ extern int dump_fpu(struct pt_regs *, elf_fpregset_t *); EXPORT_SYMBOL(__ioremap); EXPORT_SYMBOL(iounmap); EXPORT_SYMBOL(dump_fpu); -EXPORT_SYMBOL(dump_thread); EXPORT_SYMBOL(strnlen); EXPORT_SYMBOL(strrchr); EXPORT_SYMBOL(strstr); diff --git a/trunk/arch/m68knommu/kernel/process.c b/trunk/arch/m68knommu/kernel/process.c index 82e7ec888806..8b3cf57ba706 100644 --- a/trunk/arch/m68knommu/kernel/process.c +++ b/trunk/arch/m68knommu/kernel/process.c @@ -275,52 +275,6 @@ int dump_fpu(struct pt_regs *regs, struct user_m68kfp_struct *fpu) return 1; } -/* - * fill in the user structure for a core dump.. - */ -void dump_thread(struct pt_regs * regs, struct user * dump) -{ - struct switch_stack *sw; - - /* changed the size calculations - should hopefully work better. lbt */ - dump->magic = CMAGIC; - dump->start_code = 0; - dump->start_stack = rdusp() & ~(PAGE_SIZE - 1); - dump->u_tsize = ((unsigned long) current->mm->end_code) >> PAGE_SHIFT; - dump->u_dsize = ((unsigned long) (current->mm->brk + - (PAGE_SIZE-1))) >> PAGE_SHIFT; - dump->u_dsize -= dump->u_tsize; - dump->u_ssize = 0; - - if (dump->start_stack < TASK_SIZE) - dump->u_ssize = ((unsigned long) (TASK_SIZE - dump->start_stack)) >> PAGE_SHIFT; - - dump->u_ar0 = (struct user_regs_struct *)((int)&dump->regs - (int)dump); - sw = ((struct switch_stack *)regs) - 1; - dump->regs.d1 = regs->d1; - dump->regs.d2 = regs->d2; - dump->regs.d3 = regs->d3; - dump->regs.d4 = regs->d4; - dump->regs.d5 = regs->d5; - dump->regs.d6 = sw->d6; - dump->regs.d7 = sw->d7; - dump->regs.a0 = regs->a0; - dump->regs.a1 = regs->a1; - dump->regs.a2 = regs->a2; - dump->regs.a3 = sw->a3; - dump->regs.a4 = sw->a4; - dump->regs.a5 = sw->a5; - dump->regs.a6 = sw->a6; - dump->regs.d0 = regs->d0; - dump->regs.orig_d0 = regs->orig_d0; - dump->regs.stkadj = regs->stkadj; - dump->regs.sr = regs->sr; - dump->regs.pc = regs->pc; - dump->regs.fmtvec = (regs->format << 12) | regs->vector; - /* dump floating point stuff */ - dump->u_fpvalid = dump_fpu (regs, &dump->m68kfp); -} - /* * Generic dumping code. Used for panic and debug. */ diff --git a/trunk/arch/mips/kernel/Makefile b/trunk/arch/mips/kernel/Makefile index 72f2126ad19d..f36c4f20ee8a 100644 --- a/trunk/arch/mips/kernel/Makefile +++ b/trunk/arch/mips/kernel/Makefile @@ -50,7 +50,7 @@ obj-$(CONFIG_MIPS_BOARDS_GEN) += irq-msc01.o obj-$(CONFIG_32BIT) += scall32-o32.o obj-$(CONFIG_64BIT) += scall64-64.o obj-$(CONFIG_BINFMT_IRIX) += binfmt_irix.o -obj-$(CONFIG_MIPS32_COMPAT) += ioctl32.o linux32.o signal32.o +obj-$(CONFIG_MIPS32_COMPAT) += linux32.o signal32.o obj-$(CONFIG_MIPS32_N32) += binfmt_elfn32.o scall64-n32.o signal_n32.o obj-$(CONFIG_MIPS32_O32) += binfmt_elfo32.o scall64-o32.o ptrace32.o @@ -60,6 +60,5 @@ obj-$(CONFIG_PROC_FS) += proc.o obj-$(CONFIG_64BIT) += cpu-bugs64.o CFLAGS_cpu-bugs64.o = $(shell if $(CC) $(CFLAGS) -Wa,-mdaddi -c -o /dev/null -xc /dev/null >/dev/null 2>&1; then echo "-DHAVE_AS_SET_DADDI"; fi) -CFLAGS_ioctl32.o += -Ifs/ EXTRA_AFLAGS := $(CFLAGS) diff --git a/trunk/arch/mips/kernel/ioctl32.c b/trunk/arch/mips/kernel/ioctl32.c deleted file mode 100644 index 9ea1fc748864..000000000000 --- a/trunk/arch/mips/kernel/ioctl32.c +++ /dev/null @@ -1,50 +0,0 @@ -/* - * ioctl32.c: Conversion between 32bit and 64bit native ioctls. - * - * Copyright (C) 2000 Silicon Graphics, Inc. - * Written by Ulf Carlsson (ulfc@engr.sgi.com) - * Copyright (C) 2000, 2004 Ralf Baechle - * Copyright (C) 2002, 2003 Maciej W. Rozycki - */ -#define INCLUDES -#include "compat_ioctl.c" - -#include -#include -#include -#include -#include - -#ifdef CONFIG_SIBYTE_TBPROF -#include -#endif - -#define A(__x) ((unsigned long)(__x)) - -long sys_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg); - -#define CODE -#include "compat_ioctl.c" - -#define COMPATIBLE_IOCTL(cmd) HANDLE_IOCTL((cmd),sys_ioctl) -#define HANDLE_IOCTL(cmd,handler) { (cmd), (ioctl_trans_handler_t)(handler), NULL }, -#define IOCTL_TABLE_START \ - struct ioctl_trans ioctl_start[] = { -#define IOCTL_TABLE_END \ - }; - -IOCTL_TABLE_START - -#include -#define DECLARES -#include "compat_ioctl.c" - -/*HANDLE_IOCTL(RTC_IRQP_READ, w_long) -COMPATIBLE_IOCTL(RTC_IRQP_SET) -HANDLE_IOCTL(RTC_EPOCH_READ, w_long) -COMPATIBLE_IOCTL(RTC_EPOCH_SET) -*/ - -IOCTL_TABLE_END - -int ioctl_table_size = ARRAY_SIZE(ioctl_start); diff --git a/trunk/arch/parisc/kernel/Makefile b/trunk/arch/parisc/kernel/Makefile index 171f9c239f60..27827bc3717e 100644 --- a/trunk/arch/parisc/kernel/Makefile +++ b/trunk/arch/parisc/kernel/Makefile @@ -6,7 +6,6 @@ extra-y := init_task.o head.o vmlinux.lds AFLAGS_entry.o := -traditional AFLAGS_pacache.o := -traditional -CFLAGS_ioctl32.o := -Ifs/ obj-y := cache.o pacache.o setup.o traps.o time.o irq.o \ pa7300lc.o syscall.o entry.o sys_parisc.o firmware.o \ @@ -19,6 +18,6 @@ obj-$(CONFIG_SMP) += smp.o obj-$(CONFIG_PA11) += pci-dma.o obj-$(CONFIG_PCI) += pci.o obj-$(CONFIG_MODULES) += module.o -obj-$(CONFIG_64BIT) += binfmt_elf32.o sys_parisc32.o ioctl32.o signal32.o +obj-$(CONFIG_64BIT) += binfmt_elf32.o sys_parisc32.o signal32.o # only supported for PCX-W/U in 64-bit mode at the moment obj-$(CONFIG_64BIT) += perf.o perf_asm.o diff --git a/trunk/arch/parisc/kernel/ioctl32.c b/trunk/arch/parisc/kernel/ioctl32.c deleted file mode 100644 index 4eada1bb27f0..000000000000 --- a/trunk/arch/parisc/kernel/ioctl32.c +++ /dev/null @@ -1,60 +0,0 @@ -/* $Id: ioctl32.c,v 1.5 2002/10/18 00:21:43 varenet Exp $ - * ioctl32.c: Conversion between 32bit and 64bit native ioctls. - * - * Copyright (C) 1997-2000 Jakub Jelinek (jakub@redhat.com) - * Copyright (C) 1998 Eddie C. Dost (ecd@skynet.be) - * - * These routines maintain argument size conversion between 32bit and 64bit - * ioctls. - */ - -#include - -#define INCLUDES -#include "compat_ioctl.c" - -#include -#include - -#define CODE -#include "compat_ioctl.c" - -#define HANDLE_IOCTL(cmd, handler) { cmd, (ioctl_trans_handler_t)handler, NULL }, -#define COMPATIBLE_IOCTL(cmd) HANDLE_IOCTL(cmd, sys_ioctl) - -#define IOCTL_TABLE_START struct ioctl_trans ioctl_start[] = { -#define IOCTL_TABLE_END }; - -IOCTL_TABLE_START -#include - -#define DECLARES -#include "compat_ioctl.c" - -/* And these ioctls need translation */ -HANDLE_IOCTL(SIOCGPPPSTATS, dev_ifsioc) -HANDLE_IOCTL(SIOCGPPPCSTATS, dev_ifsioc) -HANDLE_IOCTL(SIOCGPPPVER, dev_ifsioc) - -#if defined(CONFIG_GEN_RTC) -COMPATIBLE_IOCTL(RTC_AIE_ON) -COMPATIBLE_IOCTL(RTC_AIE_OFF) -COMPATIBLE_IOCTL(RTC_UIE_ON) -COMPATIBLE_IOCTL(RTC_UIE_OFF) -COMPATIBLE_IOCTL(RTC_PIE_ON) -COMPATIBLE_IOCTL(RTC_PIE_OFF) -COMPATIBLE_IOCTL(RTC_WIE_ON) -COMPATIBLE_IOCTL(RTC_WIE_OFF) -COMPATIBLE_IOCTL(RTC_ALM_SET) /* struct rtc_time only has ints */ -COMPATIBLE_IOCTL(RTC_ALM_READ) /* struct rtc_time only has ints */ -COMPATIBLE_IOCTL(RTC_RD_TIME) /* struct rtc_time only has ints */ -COMPATIBLE_IOCTL(RTC_SET_TIME) /* struct rtc_time only has ints */ -HANDLE_IOCTL(RTC_IRQP_READ, w_long) -COMPATIBLE_IOCTL(RTC_IRQP_SET) -HANDLE_IOCTL(RTC_EPOCH_READ, w_long) -COMPATIBLE_IOCTL(RTC_EPOCH_SET) -#endif - -IOCTL_TABLE_END - -int ioctl_table_size = ARRAY_SIZE(ioctl_start); diff --git a/trunk/arch/powerpc/Kconfig b/trunk/arch/powerpc/Kconfig index 28004f002ec9..935d96571515 100644 --- a/trunk/arch/powerpc/Kconfig +++ b/trunk/arch/powerpc/Kconfig @@ -275,6 +275,7 @@ config PPC_PSERIES select PPC_I8259 select PPC_RTAS select RTAS_ERROR_LOGGING + select PPC_UDBG_16550 default y config PPC_CHRP @@ -284,6 +285,7 @@ config PPC_CHRP select PPC_INDIRECT_PCI select PPC_RTAS select PPC_MPC106 + select PPC_UDBG_16550 default y config PPC_PMAC @@ -306,6 +308,7 @@ config PPC_PREP depends on PPC_MULTIPLATFORM && PPC32 && BROKEN select PPC_I8259 select PPC_INDIRECT_PCI + select PPC_UDBG_16550 default y config PPC_MAPLE @@ -314,6 +317,7 @@ config PPC_MAPLE select U3_DART select MPIC_BROKEN_U3 select GENERIC_TBSYNC + select PPC_UDBG_16550 default n help This option enables support for the Maple 970FX Evaluation Board. @@ -324,6 +328,7 @@ config PPC_CELL depends on PPC_MULTIPLATFORM && PPC64 select PPC_RTAS select MMIO_NVRAM + select PPC_UDBG_16550 config PPC_OF def_bool y @@ -370,6 +375,10 @@ config MPIC_BROKEN_U3 depends on PPC_MAPLE default y +config PPC_UDBG_16550 + bool + default n + config CELL_IIC depends on PPC_CELL bool @@ -403,7 +412,7 @@ config PPC_MPC106 config GENERIC_TBSYNC bool - default y if CONFIG_PPC32 && CONFIG_SMP + default y if PPC32 && SMP default n source "drivers/cpufreq/Kconfig" diff --git a/trunk/arch/powerpc/Makefile b/trunk/arch/powerpc/Makefile index 5f80e58e5cb3..d3654a264ef7 100644 --- a/trunk/arch/powerpc/Makefile +++ b/trunk/arch/powerpc/Makefile @@ -76,8 +76,7 @@ LINUXINCLUDE += $(LINUXINCLUDE-y) CHECKFLAGS += -m$(SZ) -D__powerpc__ -D__powerpc$(SZ)__ ifeq ($(CONFIG_PPC64),y) -GCC_VERSION := $(call cc-version) -GCC_BROKEN_VEC := $(shell if [ $(GCC_VERSION) -lt 0400 ] ; then echo "y"; fi) +GCC_BROKEN_VEC := $(shell if [ $(call cc-version) -lt 0400 ] ; then echo "y"; fi) ifeq ($(CONFIG_POWER4_ONLY),y) ifeq ($(CONFIG_ALTIVEC),y) @@ -189,10 +188,9 @@ TOUT := .tmp_gas_check # Ensure this is binutils 2.12.1 (or 2.12.90.0.7) or later for altivec # instructions. # gcc-3.4 and binutils-2.14 are a fatal combination. -GCC_VERSION := $(call cc-version) checkbin: - @if test "$(GCC_VERSION)" = "0304" ; then \ + @if test "$(call cc-version)" = "0304" ; then \ if ! /bin/echo mftb 5 | $(AS) -v -mppc -many -o $(TOUT) >/dev/null 2>&1 ; then \ echo -n '*** ${VERSION}.${PATCHLEVEL} kernels no longer build '; \ echo 'correctly with gcc-3.4 and your version of binutils.'; \ diff --git a/trunk/arch/powerpc/configs/ppc64_defconfig b/trunk/arch/powerpc/configs/ppc64_defconfig index 509399eab6f5..347f4391db8d 100644 --- a/trunk/arch/powerpc/configs/ppc64_defconfig +++ b/trunk/arch/powerpc/configs/ppc64_defconfig @@ -861,7 +861,7 @@ CONFIG_SERIAL_CORE=y CONFIG_SERIAL_CORE_CONSOLE=y # CONFIG_SERIAL_PMACZILOG is not set CONFIG_SERIAL_ICOM=m -CONFIG_SERIAL_JSM=m +# CONFIG_SERIAL_JSM is not set CONFIG_UNIX98_PTYS=y CONFIG_LEGACY_PTYS=y CONFIG_LEGACY_PTY_COUNT=256 diff --git a/trunk/arch/powerpc/kernel/Makefile b/trunk/arch/powerpc/kernel/Makefile index 6e03b595b6c8..144e284d21dd 100644 --- a/trunk/arch/powerpc/kernel/Makefile +++ b/trunk/arch/powerpc/kernel/Makefile @@ -4,7 +4,6 @@ ifeq ($(CONFIG_PPC64),y) EXTRA_CFLAGS += -mno-minimal-toc -CFLAGS_ioctl32.o += -Ifs/ endif ifeq ($(CONFIG_PPC32),y) CFLAGS_prom_init.o += -fPIC @@ -16,7 +15,7 @@ obj-y := semaphore.o cputable.o ptrace.o syscalls.o \ obj-y += vdso32/ obj-$(CONFIG_PPC64) += setup_64.o binfmt_elf32.o sys_ppc32.o \ signal_64.o ptrace32.o systbl.o \ - paca.o ioctl32.o cpu_setup_power4.o \ + paca.o cpu_setup_power4.o \ firmware.o sysfs.o idle_64.o obj-$(CONFIG_PPC64) += vdso64/ obj-$(CONFIG_ALTIVEC) += vecemu.o vector.o @@ -55,7 +54,7 @@ obj-$(CONFIG_BOOTX_TEXT) += btext.o obj-$(CONFIG_6xx) += idle_6xx.o obj-$(CONFIG_SMP) += smp.o obj-$(CONFIG_KPROBES) += kprobes.o -obj-$(CONFIG_SERIAL_8250) += legacy_serial.o udbg_16550.o +obj-$(CONFIG_PPC_UDBG_16550) += legacy_serial.o udbg_16550.o module-$(CONFIG_PPC64) += module_64.o obj-$(CONFIG_MODULES) += $(module-y) diff --git a/trunk/arch/powerpc/kernel/ioctl32.c b/trunk/arch/powerpc/kernel/ioctl32.c deleted file mode 100644 index 0fa3d27fef01..000000000000 --- a/trunk/arch/powerpc/kernel/ioctl32.c +++ /dev/null @@ -1,45 +0,0 @@ -/* - * ioctl32.c: Conversion between 32bit and 64bit native ioctls. - * - * Based on sparc64 ioctl32.c by: - * - * Copyright (C) 1997-2000 Jakub Jelinek (jakub@redhat.com) - * Copyright (C) 1998 Eddie C. Dost (ecd@skynet.be) - * - * ppc64 changes: - * - * Copyright (C) 2000 Ken Aaker (kdaaker@rchland.vnet.ibm.com) - * Copyright (C) 2001 Anton Blanchard (antonb@au.ibm.com) - * - * These routines maintain argument size conversion between 32bit and 64bit - * ioctls. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version - * 2 of the License, or (at your option) any later version. - */ - -#define INCLUDES -#include "compat_ioctl.c" -#include - -#define CODE -#include "compat_ioctl.c" - -#define HANDLE_IOCTL(cmd,handler) { cmd, (ioctl_trans_handler_t)handler, NULL }, -#define COMPATIBLE_IOCTL(cmd) HANDLE_IOCTL(cmd,sys_ioctl) - -#define IOCTL_TABLE_START \ - struct ioctl_trans ioctl_start[] = { -#define IOCTL_TABLE_END \ - }; - -IOCTL_TABLE_START -#include -#define DECLARES -#include "compat_ioctl.c" - -IOCTL_TABLE_END - -int ioctl_table_size = ARRAY_SIZE(ioctl_start); diff --git a/trunk/arch/powerpc/kernel/kprobes.c b/trunk/arch/powerpc/kernel/kprobes.c index 5368f9c2e6bf..27b0c40601fb 100644 --- a/trunk/arch/powerpc/kernel/kprobes.c +++ b/trunk/arch/powerpc/kernel/kprobes.c @@ -35,7 +35,6 @@ #include #include -static DECLARE_MUTEX(kprobe_mutex); DEFINE_PER_CPU(struct kprobe *, current_kprobe) = NULL; DEFINE_PER_CPU(struct kprobe_ctlblk, kprobe_ctlblk); @@ -54,19 +53,17 @@ int __kprobes arch_prepare_kprobe(struct kprobe *p) /* insn must be on a special executable page on ppc64 */ if (!ret) { - down(&kprobe_mutex); p->ainsn.insn = get_insn_slot(); - up(&kprobe_mutex); if (!p->ainsn.insn) ret = -ENOMEM; } - return ret; -} -void __kprobes arch_copy_kprobe(struct kprobe *p) -{ - memcpy(p->ainsn.insn, p->addr, MAX_INSN_SIZE * sizeof(kprobe_opcode_t)); - p->opcode = *p->addr; + if (!ret) { + memcpy(p->ainsn.insn, p->addr, MAX_INSN_SIZE * sizeof(kprobe_opcode_t)); + p->opcode = *p->addr; + } + + return ret; } void __kprobes arch_arm_kprobe(struct kprobe *p) diff --git a/trunk/arch/powerpc/kernel/pci_64.c b/trunk/arch/powerpc/kernel/pci_64.c index fc60a773af7d..ba21a6c4f467 100644 --- a/trunk/arch/powerpc/kernel/pci_64.c +++ b/trunk/arch/powerpc/kernel/pci_64.c @@ -381,7 +381,7 @@ struct pci_dev *of_create_pci_dev(struct device_node *node, dev->subsystem_vendor = get_int_prop(node, "subsystem-vendor-id", 0); dev->subsystem_device = get_int_prop(node, "subsystem-id", 0); - dev->cfg_size = 256; /*pci_cfg_space_size(dev);*/ + dev->cfg_size = pci_cfg_space_size(dev); sprintf(pci_name(dev), "%04x:%02x:%02x.%d", pci_domain_nr(bus), dev->bus->number, PCI_SLOT(devfn), PCI_FUNC(devfn)); diff --git a/trunk/arch/powerpc/kernel/ppc_ksyms.c b/trunk/arch/powerpc/kernel/ppc_ksyms.c index b2758148a0de..16d9a904f3cb 100644 --- a/trunk/arch/powerpc/kernel/ppc_ksyms.c +++ b/trunk/arch/powerpc/kernel/ppc_ksyms.c @@ -244,7 +244,6 @@ EXPORT_SYMBOL(set_context); extern long mol_trampoline; EXPORT_SYMBOL(mol_trampoline); /* For MOL */ EXPORT_SYMBOL(flush_hash_pages); /* For MOL */ -EXPORT_SYMBOL_GPL(__handle_mm_fault); /* For MOL */ #ifdef CONFIG_SMP extern int mmu_hash_lock; EXPORT_SYMBOL(mmu_hash_lock); /* For MOL */ diff --git a/trunk/arch/powerpc/kernel/rtas_pci.c b/trunk/arch/powerpc/kernel/rtas_pci.c index 45b8109951fe..5579f6559912 100644 --- a/trunk/arch/powerpc/kernel/rtas_pci.c +++ b/trunk/arch/powerpc/kernel/rtas_pci.c @@ -72,7 +72,7 @@ static int of_device_available(struct device_node * dn) return 0; } -static int rtas_read_config(struct pci_dn *pdn, int where, int size, u32 *val) +int rtas_read_config(struct pci_dn *pdn, int where, int size, u32 *val) { int returnval = -1; unsigned long buid, addr; diff --git a/trunk/arch/powerpc/kernel/setup_32.c b/trunk/arch/powerpc/kernel/setup_32.c index e5d285adb496..db72a92943bf 100644 --- a/trunk/arch/powerpc/kernel/setup_32.c +++ b/trunk/arch/powerpc/kernel/setup_32.c @@ -299,9 +299,7 @@ void __init setup_arch(char **cmdline_p) if (ppc_md.init_early) ppc_md.init_early(); -#ifdef CONFIG_SERIAL_8250 find_legacy_serial_ports(); -#endif finish_device_tree(); smp_setup_cpu_maps(); diff --git a/trunk/arch/powerpc/kernel/setup_64.c b/trunk/arch/powerpc/kernel/setup_64.c index 81567e931260..c4b76961d6de 100644 --- a/trunk/arch/powerpc/kernel/setup_64.c +++ b/trunk/arch/powerpc/kernel/setup_64.c @@ -472,9 +472,7 @@ void __init setup_system(void) * hash table management for us, thus ioremap works. We do that early * so that further code can be debugged */ -#ifdef CONFIG_SERIAL_8250 find_legacy_serial_ports(); -#endif /* * "Finish" the device-tree, that is do the actual parsing of diff --git a/trunk/arch/powerpc/kernel/sys_ppc32.c b/trunk/arch/powerpc/kernel/sys_ppc32.c index 9c921d1c4084..475249dc2350 100644 --- a/trunk/arch/powerpc/kernel/sys_ppc32.c +++ b/trunk/arch/powerpc/kernel/sys_ppc32.c @@ -552,30 +552,6 @@ asmlinkage long compat_sys_sched_rr_get_interval(u32 pid, struct compat_timespec return ret; } -asmlinkage int compat_sys_pciconfig_read(u32 bus, u32 dfn, u32 off, u32 len, u32 ubuf) -{ - return sys_pciconfig_read((unsigned long) bus, - (unsigned long) dfn, - (unsigned long) off, - (unsigned long) len, - compat_ptr(ubuf)); -} - -asmlinkage int compat_sys_pciconfig_write(u32 bus, u32 dfn, u32 off, u32 len, u32 ubuf) -{ - return sys_pciconfig_write((unsigned long) bus, - (unsigned long) dfn, - (unsigned long) off, - (unsigned long) len, - compat_ptr(ubuf)); -} - -asmlinkage int compat_sys_pciconfig_iobase(u32 which, u32 in_bus, u32 in_devfn) -{ - return sys_pciconfig_iobase(which, in_bus, in_devfn); -} - - /* Note: it is necessary to treat mode as an unsigned int, * with the corresponding cast to a signed int to insure that the * proper conversion (sign extension) between the register representation of a signed int (msr in 32-bit mode) @@ -956,38 +932,6 @@ long ppc32_fadvise64(int fd, u32 unused, u32 offset_high, u32 offset_low, advice); } -long ppc32_timer_create(clockid_t clock, - struct compat_sigevent __user *ev32, - timer_t __user *timer_id) -{ - sigevent_t event; - timer_t t; - long err; - mm_segment_t savefs; - - if (ev32 == NULL) - return sys_timer_create(clock, NULL, timer_id); - - if (get_compat_sigevent(&event, ev32)) - return -EFAULT; - - if (!access_ok(VERIFY_WRITE, timer_id, sizeof(timer_t))) - return -EFAULT; - - savefs = get_fs(); - set_fs(KERNEL_DS); - /* The __user pointer casts are valid due to the set_fs() */ - err = sys_timer_create(clock, - (sigevent_t __user *) &event, - (timer_t __user *) &t); - set_fs(savefs); - - if (err == 0) - err = __put_user(t, timer_id); - - return err; -} - asmlinkage long compat_sys_add_key(const char __user *_type, const char __user *_description, const void __user *_payload, diff --git a/trunk/arch/powerpc/kernel/systbl.S b/trunk/arch/powerpc/kernel/systbl.S index 65463a1076e8..68013179a503 100644 --- a/trunk/arch/powerpc/kernel/systbl.S +++ b/trunk/arch/powerpc/kernel/systbl.S @@ -239,9 +239,9 @@ SYS32ONLY(ftruncate64) SYSX(sys_ni_syscall,sys_stat64,sys_stat64) SYSX(sys_ni_syscall,sys_lstat64,sys_lstat64) SYSX(sys_ni_syscall,sys_fstat64,sys_fstat64) -COMPAT_SYS(pciconfig_read) -COMPAT_SYS(pciconfig_write) -COMPAT_SYS(pciconfig_iobase) +SYSCALL(pciconfig_read) +SYSCALL(pciconfig_write) +SYSCALL(pciconfig_iobase) SYSCALL(ni_syscall) SYSCALL(getdents64) SYSCALL(pivot_root) @@ -281,7 +281,7 @@ SYSCALL(epoll_create) SYSCALL(epoll_ctl) SYSCALL(epoll_wait) SYSCALL(remap_file_pages) -SYSX(sys_timer_create,ppc32_timer_create,sys_timer_create) +SYSX(sys_timer_create,compat_sys_timer_create,sys_timer_create) COMPAT_SYS(timer_settime) COMPAT_SYS(timer_gettime) SYSCALL(timer_getoverrun) diff --git a/trunk/arch/powerpc/mm/pgtable_64.c b/trunk/arch/powerpc/mm/pgtable_64.c index 2ffca63602c5..7b278d83739e 100644 --- a/trunk/arch/powerpc/mm/pgtable_64.c +++ b/trunk/arch/powerpc/mm/pgtable_64.c @@ -174,7 +174,7 @@ void __iomem * __ioremap(unsigned long addr, unsigned long size, pa = addr & PAGE_MASK; size = PAGE_ALIGN(addr + size) - pa; - if (size == 0) + if ((size == 0) || (pa == 0)) return NULL; if (mem_init_done) { diff --git a/trunk/arch/powerpc/platforms/cell/spufs/inode.c b/trunk/arch/powerpc/platforms/cell/spufs/inode.c index d2ba358c6e38..b3962c3a0348 100644 --- a/trunk/arch/powerpc/platforms/cell/spufs/inode.c +++ b/trunk/arch/powerpc/platforms/cell/spufs/inode.c @@ -138,7 +138,7 @@ static void spufs_prune_dir(struct dentry *dir) { struct dentry *dentry, *tmp; mutex_lock(&dir->d_inode->i_mutex); - list_for_each_entry_safe(dentry, tmp, &dir->d_subdirs, d_child) { + list_for_each_entry_safe(dentry, tmp, &dir->d_subdirs, d_u.d_child) { spin_lock(&dcache_lock); spin_lock(&dentry->d_lock); if (!(d_unhashed(dentry)) && dentry->d_inode) { diff --git a/trunk/arch/powerpc/platforms/maple/setup.c b/trunk/arch/powerpc/platforms/maple/setup.c index dd73e38bfb7d..a1cb4d236720 100644 --- a/trunk/arch/powerpc/platforms/maple/setup.c +++ b/trunk/arch/powerpc/platforms/maple/setup.c @@ -71,9 +71,6 @@ #define DBG(fmt...) #endif -extern void generic_find_legacy_serial_ports(u64 *physport, - unsigned int *default_speed); - static void maple_restart(char *cmd) { unsigned int maple_nvram_base; diff --git a/trunk/arch/powerpc/platforms/pseries/Makefile b/trunk/arch/powerpc/platforms/pseries/Makefile index 6accdd155505..61616d144072 100644 --- a/trunk/arch/powerpc/platforms/pseries/Makefile +++ b/trunk/arch/powerpc/platforms/pseries/Makefile @@ -4,7 +4,7 @@ obj-$(CONFIG_SMP) += smp.o obj-$(CONFIG_IBMVIO) += vio.o obj-$(CONFIG_XICS) += xics.o obj-$(CONFIG_SCANLOG) += scanlog.o -obj-$(CONFIG_EEH) += eeh.o eeh_event.o +obj-$(CONFIG_EEH) += eeh.o eeh_cache.o eeh_driver.o eeh_event.o obj-$(CONFIG_HVC_CONSOLE) += hvconsole.o obj-$(CONFIG_HVCS) += hvcserver.o diff --git a/trunk/arch/powerpc/platforms/pseries/eeh.c b/trunk/arch/powerpc/platforms/pseries/eeh.c index 7fbfd16d72b7..17cea7f2afd3 100644 --- a/trunk/arch/powerpc/platforms/pseries/eeh.c +++ b/trunk/arch/powerpc/platforms/pseries/eeh.c @@ -76,15 +76,14 @@ */ #define EEH_MAX_FAILS 100000 -/* Misc forward declaraions */ -static void eeh_save_bars(struct pci_dev * pdev, struct pci_dn *pdn); - /* RTAS tokens */ static int ibm_set_eeh_option; static int ibm_set_slot_reset; static int ibm_read_slot_reset_state; static int ibm_read_slot_reset_state2; static int ibm_slot_error_detail; +static int ibm_get_config_addr_info; +static int ibm_configure_bridge; int eeh_subsystem_enabled; EXPORT_SYMBOL(eeh_subsystem_enabled); @@ -98,308 +97,23 @@ static DEFINE_SPINLOCK(slot_errbuf_lock); static int eeh_error_buf_size; /* System monitoring statistics */ -static DEFINE_PER_CPU(unsigned long, no_device); -static DEFINE_PER_CPU(unsigned long, no_dn); -static DEFINE_PER_CPU(unsigned long, no_cfg_addr); -static DEFINE_PER_CPU(unsigned long, ignored_check); -static DEFINE_PER_CPU(unsigned long, total_mmio_ffs); -static DEFINE_PER_CPU(unsigned long, false_positives); -static DEFINE_PER_CPU(unsigned long, ignored_failures); -static DEFINE_PER_CPU(unsigned long, slot_resets); - -/** - * The pci address cache subsystem. This subsystem places - * PCI device address resources into a red-black tree, sorted - * according to the address range, so that given only an i/o - * address, the corresponding PCI device can be **quickly** - * found. It is safe to perform an address lookup in an interrupt - * context; this ability is an important feature. - * - * Currently, the only customer of this code is the EEH subsystem; - * thus, this code has been somewhat tailored to suit EEH better. - * In particular, the cache does *not* hold the addresses of devices - * for which EEH is not enabled. - * - * (Implementation Note: The RB tree seems to be better/faster - * than any hash algo I could think of for this problem, even - * with the penalty of slow pointer chases for d-cache misses). - */ -struct pci_io_addr_range -{ - struct rb_node rb_node; - unsigned long addr_lo; - unsigned long addr_hi; - struct pci_dev *pcidev; - unsigned int flags; -}; - -static struct pci_io_addr_cache -{ - struct rb_root rb_root; - spinlock_t piar_lock; -} pci_io_addr_cache_root; - -static inline struct pci_dev *__pci_get_device_by_addr(unsigned long addr) -{ - struct rb_node *n = pci_io_addr_cache_root.rb_root.rb_node; - - while (n) { - struct pci_io_addr_range *piar; - piar = rb_entry(n, struct pci_io_addr_range, rb_node); - - if (addr < piar->addr_lo) { - n = n->rb_left; - } else { - if (addr > piar->addr_hi) { - n = n->rb_right; - } else { - pci_dev_get(piar->pcidev); - return piar->pcidev; - } - } - } - - return NULL; -} - -/** - * pci_get_device_by_addr - Get device, given only address - * @addr: mmio (PIO) phys address or i/o port number - * - * Given an mmio phys address, or a port number, find a pci device - * that implements this address. Be sure to pci_dev_put the device - * when finished. I/O port numbers are assumed to be offset - * from zero (that is, they do *not* have pci_io_addr added in). - * It is safe to call this function within an interrupt. - */ -static struct pci_dev *pci_get_device_by_addr(unsigned long addr) -{ - struct pci_dev *dev; - unsigned long flags; - - spin_lock_irqsave(&pci_io_addr_cache_root.piar_lock, flags); - dev = __pci_get_device_by_addr(addr); - spin_unlock_irqrestore(&pci_io_addr_cache_root.piar_lock, flags); - return dev; -} - -#ifdef DEBUG -/* - * Handy-dandy debug print routine, does nothing more - * than print out the contents of our addr cache. - */ -static void pci_addr_cache_print(struct pci_io_addr_cache *cache) -{ - struct rb_node *n; - int cnt = 0; - - n = rb_first(&cache->rb_root); - while (n) { - struct pci_io_addr_range *piar; - piar = rb_entry(n, struct pci_io_addr_range, rb_node); - printk(KERN_DEBUG "PCI: %s addr range %d [%lx-%lx]: %s\n", - (piar->flags & IORESOURCE_IO) ? "i/o" : "mem", cnt, - piar->addr_lo, piar->addr_hi, pci_name(piar->pcidev)); - cnt++; - n = rb_next(n); - } -} -#endif - -/* Insert address range into the rb tree. */ -static struct pci_io_addr_range * -pci_addr_cache_insert(struct pci_dev *dev, unsigned long alo, - unsigned long ahi, unsigned int flags) -{ - struct rb_node **p = &pci_io_addr_cache_root.rb_root.rb_node; - struct rb_node *parent = NULL; - struct pci_io_addr_range *piar; - - /* Walk tree, find a place to insert into tree */ - while (*p) { - parent = *p; - piar = rb_entry(parent, struct pci_io_addr_range, rb_node); - if (ahi < piar->addr_lo) { - p = &parent->rb_left; - } else if (alo > piar->addr_hi) { - p = &parent->rb_right; - } else { - if (dev != piar->pcidev || - alo != piar->addr_lo || ahi != piar->addr_hi) { - printk(KERN_WARNING "PIAR: overlapping address range\n"); - } - return piar; - } - } - piar = (struct pci_io_addr_range *)kmalloc(sizeof(struct pci_io_addr_range), GFP_ATOMIC); - if (!piar) - return NULL; +static unsigned long no_device; +static unsigned long no_dn; +static unsigned long no_cfg_addr; +static unsigned long ignored_check; +static unsigned long total_mmio_ffs; +static unsigned long false_positives; +static unsigned long ignored_failures; +static unsigned long slot_resets; - piar->addr_lo = alo; - piar->addr_hi = ahi; - piar->pcidev = dev; - piar->flags = flags; - -#ifdef DEBUG - printk(KERN_DEBUG "PIAR: insert range=[%lx:%lx] dev=%s\n", - alo, ahi, pci_name (dev)); -#endif - - rb_link_node(&piar->rb_node, parent, p); - rb_insert_color(&piar->rb_node, &pci_io_addr_cache_root.rb_root); - - return piar; -} - -static void __pci_addr_cache_insert_device(struct pci_dev *dev) -{ - struct device_node *dn; - struct pci_dn *pdn; - int i; - int inserted = 0; - - dn = pci_device_to_OF_node(dev); - if (!dn) { - printk(KERN_WARNING "PCI: no pci dn found for dev=%s\n", pci_name(dev)); - return; - } - - /* Skip any devices for which EEH is not enabled. */ - pdn = PCI_DN(dn); - if (!(pdn->eeh_mode & EEH_MODE_SUPPORTED) || - pdn->eeh_mode & EEH_MODE_NOCHECK) { -#ifdef DEBUG - printk(KERN_INFO "PCI: skip building address cache for=%s - %s\n", - pci_name(dev), pdn->node->full_name); -#endif - return; - } - - /* The cache holds a reference to the device... */ - pci_dev_get(dev); - - /* Walk resources on this device, poke them into the tree */ - for (i = 0; i < DEVICE_COUNT_RESOURCE; i++) { - unsigned long start = pci_resource_start(dev,i); - unsigned long end = pci_resource_end(dev,i); - unsigned int flags = pci_resource_flags(dev,i); - - /* We are interested only bus addresses, not dma or other stuff */ - if (0 == (flags & (IORESOURCE_IO | IORESOURCE_MEM))) - continue; - if (start == 0 || ~start == 0 || end == 0 || ~end == 0) - continue; - pci_addr_cache_insert(dev, start, end, flags); - inserted = 1; - } - - /* If there was nothing to add, the cache has no reference... */ - if (!inserted) - pci_dev_put(dev); -} - -/** - * pci_addr_cache_insert_device - Add a device to the address cache - * @dev: PCI device whose I/O addresses we are interested in. - * - * In order to support the fast lookup of devices based on addresses, - * we maintain a cache of devices that can be quickly searched. - * This routine adds a device to that cache. - */ -static void pci_addr_cache_insert_device(struct pci_dev *dev) -{ - unsigned long flags; - - spin_lock_irqsave(&pci_io_addr_cache_root.piar_lock, flags); - __pci_addr_cache_insert_device(dev); - spin_unlock_irqrestore(&pci_io_addr_cache_root.piar_lock, flags); -} - -static inline void __pci_addr_cache_remove_device(struct pci_dev *dev) -{ - struct rb_node *n; - int removed = 0; - -restart: - n = rb_first(&pci_io_addr_cache_root.rb_root); - while (n) { - struct pci_io_addr_range *piar; - piar = rb_entry(n, struct pci_io_addr_range, rb_node); - - if (piar->pcidev == dev) { - rb_erase(n, &pci_io_addr_cache_root.rb_root); - removed = 1; - kfree(piar); - goto restart; - } - n = rb_next(n); - } - - /* The cache no longer holds its reference to this device... */ - if (removed) - pci_dev_put(dev); -} - -/** - * pci_addr_cache_remove_device - remove pci device from addr cache - * @dev: device to remove - * - * Remove a device from the addr-cache tree. - * This is potentially expensive, since it will walk - * the tree multiple times (once per resource). - * But so what; device removal doesn't need to be that fast. - */ -static void pci_addr_cache_remove_device(struct pci_dev *dev) -{ - unsigned long flags; - - spin_lock_irqsave(&pci_io_addr_cache_root.piar_lock, flags); - __pci_addr_cache_remove_device(dev); - spin_unlock_irqrestore(&pci_io_addr_cache_root.piar_lock, flags); -} - -/** - * pci_addr_cache_build - Build a cache of I/O addresses - * - * Build a cache of pci i/o addresses. This cache will be used to - * find the pci device that corresponds to a given address. - * This routine scans all pci busses to build the cache. - * Must be run late in boot process, after the pci controllers - * have been scaned for devices (after all device resources are known). - */ -void __init pci_addr_cache_build(void) -{ - struct device_node *dn; - struct pci_dev *dev = NULL; - - if (!eeh_subsystem_enabled) - return; - - spin_lock_init(&pci_io_addr_cache_root.piar_lock); - - while ((dev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, dev)) != NULL) { - /* Ignore PCI bridges ( XXX why ??) */ - if ((dev->class >> 16) == PCI_BASE_CLASS_BRIDGE) { - continue; - } - pci_addr_cache_insert_device(dev); - - /* Save the BAR's; firmware doesn't restore these after EEH reset */ - dn = pci_device_to_OF_node(dev); - eeh_save_bars(dev, PCI_DN(dn)); - } - -#ifdef DEBUG - /* Verify tree built up above, echo back the list of addrs. */ - pci_addr_cache_print(&pci_io_addr_cache_root); -#endif -} +#define IS_BRIDGE(class_code) (((class_code)<<16) == PCI_BASE_CLASS_BRIDGE) /* --------------------------------------------------------------- */ -/* Above lies the PCI Address Cache. Below lies the EEH event infrastructure */ +/* Below lies the EEH event infrastructure */ void eeh_slot_error_detail (struct pci_dn *pdn, int severity) { + int config_addr; unsigned long flags; int rc; @@ -407,8 +121,13 @@ void eeh_slot_error_detail (struct pci_dn *pdn, int severity) spin_lock_irqsave(&slot_errbuf_lock, flags); memset(slot_errbuf, 0, eeh_error_buf_size); + /* Use PE configuration address, if present */ + config_addr = pdn->eeh_config_addr; + if (pdn->eeh_pe_config_addr) + config_addr = pdn->eeh_pe_config_addr; + rc = rtas_call(ibm_slot_error_detail, - 8, 1, NULL, pdn->eeh_config_addr, + 8, 1, NULL, config_addr, BUID_HI(pdn->phb->buid), BUID_LO(pdn->phb->buid), NULL, 0, virt_to_phys(slot_errbuf), @@ -428,6 +147,7 @@ void eeh_slot_error_detail (struct pci_dn *pdn, int severity) static int read_slot_reset_state(struct pci_dn *pdn, int rets[]) { int token, outputs; + int config_addr; if (ibm_read_slot_reset_state2 != RTAS_UNKNOWN_SERVICE) { token = ibm_read_slot_reset_state2; @@ -438,7 +158,12 @@ static int read_slot_reset_state(struct pci_dn *pdn, int rets[]) outputs = 3; } - return rtas_call(token, 3, outputs, rets, pdn->eeh_config_addr, + /* Use PE configuration address, if present */ + config_addr = pdn->eeh_config_addr; + if (pdn->eeh_pe_config_addr) + config_addr = pdn->eeh_pe_config_addr; + + return rtas_call(token, 3, outputs, rets, config_addr, BUID_HI(pdn->phb->buid), BUID_LO(pdn->phb->buid)); } @@ -462,7 +187,7 @@ static inline unsigned long eeh_token_to_phys(unsigned long token) /** * Return the "partitionable endpoint" (pe) under which this device lies */ -static struct device_node * find_device_pe(struct device_node *dn) +struct device_node * find_device_pe(struct device_node *dn) { while ((dn->parent) && PCI_DN(dn->parent) && (PCI_DN(dn->parent)->eeh_mode & EEH_MODE_SUPPORTED)) { @@ -485,6 +210,11 @@ static void __eeh_mark_slot (struct device_node *dn, int mode_flag) if (PCI_DN(dn)) { PCI_DN(dn)->eeh_mode |= mode_flag; + /* Mark the pci device driver too */ + struct pci_dev *dev = PCI_DN(dn)->pcidev; + if (dev && dev->driver) + dev->error_state = pci_channel_io_frozen; + if (dn->child) __eeh_mark_slot (dn->child, mode_flag); } @@ -495,6 +225,11 @@ static void __eeh_mark_slot (struct device_node *dn, int mode_flag) void eeh_mark_slot (struct device_node *dn, int mode_flag) { dn = find_device_pe (dn); + + /* Back up one, since config addrs might be shared */ + if (PCI_DN(dn) && PCI_DN(dn)->eeh_pe_config_addr) + dn = dn->parent; + PCI_DN(dn)->eeh_mode |= mode_flag; __eeh_mark_slot (dn->child, mode_flag); } @@ -516,7 +251,13 @@ void eeh_clear_slot (struct device_node *dn, int mode_flag) { unsigned long flags; spin_lock_irqsave(&confirm_error_lock, flags); + dn = find_device_pe (dn); + + /* Back up one, since config addrs might be shared */ + if (PCI_DN(dn) && PCI_DN(dn)->eeh_pe_config_addr) + dn = dn->parent; + PCI_DN(dn)->eeh_mode &= ~mode_flag; PCI_DN(dn)->eeh_check_count = 0; __eeh_clear_slot (dn->child, mode_flag); @@ -544,15 +285,16 @@ int eeh_dn_check_failure(struct device_node *dn, struct pci_dev *dev) int rets[3]; unsigned long flags; struct pci_dn *pdn; + enum pci_channel_state state; int rc = 0; - __get_cpu_var(total_mmio_ffs)++; + total_mmio_ffs++; if (!eeh_subsystem_enabled) return 0; if (!dn) { - __get_cpu_var(no_dn)++; + no_dn++; return 0; } pdn = PCI_DN(dn); @@ -560,7 +302,7 @@ int eeh_dn_check_failure(struct device_node *dn, struct pci_dev *dev) /* Access to IO BARs might get this far and still not want checking. */ if (!(pdn->eeh_mode & EEH_MODE_SUPPORTED) || pdn->eeh_mode & EEH_MODE_NOCHECK) { - __get_cpu_var(ignored_check)++; + ignored_check++; #ifdef DEBUG printk ("EEH:ignored check (%x) for %s %s\n", pdn->eeh_mode, pci_name (dev), dn->full_name); @@ -568,8 +310,8 @@ int eeh_dn_check_failure(struct device_node *dn, struct pci_dev *dev) return 0; } - if (!pdn->eeh_config_addr) { - __get_cpu_var(no_cfg_addr)++; + if (!pdn->eeh_config_addr && !pdn->eeh_pe_config_addr) { + no_cfg_addr++; return 0; } @@ -611,7 +353,7 @@ int eeh_dn_check_failure(struct device_node *dn, struct pci_dev *dev) if (ret != 0) { printk(KERN_WARNING "EEH: read_slot_reset_state() failed; rc=%d dn=%s\n", ret, dn->full_name); - __get_cpu_var(false_positives)++; + false_positives++; rc = 0; goto dn_unlock; } @@ -620,14 +362,14 @@ int eeh_dn_check_failure(struct device_node *dn, struct pci_dev *dev) if (rets[1] != 1) { printk(KERN_WARNING "EEH: event on unsupported device, rc=%d dn=%s\n", ret, dn->full_name); - __get_cpu_var(false_positives)++; + false_positives++; rc = 0; goto dn_unlock; } /* If not the kind of error we know about, punt. */ if (rets[0] != 2 && rets[0] != 4 && rets[0] != 5) { - __get_cpu_var(false_positives)++; + false_positives++; rc = 0; goto dn_unlock; } @@ -635,12 +377,12 @@ int eeh_dn_check_failure(struct device_node *dn, struct pci_dev *dev) /* Note that config-io to empty slots may fail; * we recognize empty because they don't have children. */ if ((rets[0] == 5) && (dn->child == NULL)) { - __get_cpu_var(false_positives)++; + false_positives++; rc = 0; goto dn_unlock; } - __get_cpu_var(slot_resets)++; + slot_resets++; /* Avoid repeated reports of this failure, including problems * with other functions on this device, and functions under @@ -648,8 +390,13 @@ int eeh_dn_check_failure(struct device_node *dn, struct pci_dev *dev) eeh_mark_slot (dn, EEH_MODE_ISOLATED); spin_unlock_irqrestore(&confirm_error_lock, flags); - eeh_send_failure_event (dn, dev, rets[0], rets[2]); - + state = pci_channel_io_normal; + if ((rets[0] == 2) || (rets[0] == 4)) + state = pci_channel_io_frozen; + if (rets[0] == 5) + state = pci_channel_io_perm_failure; + eeh_send_failure_event (dn, dev, state, rets[2]); + /* Most EEH events are due to device driver bugs. Having * a stack trace will help the device-driver authors figure * out what happened. So print that out. */ @@ -685,7 +432,7 @@ unsigned long eeh_check_failure(const volatile void __iomem *token, unsigned lon addr = eeh_token_to_phys((unsigned long __force) token); dev = pci_get_device_by_addr(addr); if (!dev) { - __get_cpu_var(no_device)++; + no_device++; return val; } @@ -716,11 +463,16 @@ eeh_slot_availability(struct pci_dn *pdn) if (rc) return rc; if (rets[1] == 0) return -1; /* EEH is not supported */ - if (rets[0] == 0) return 0; /* Oll Korrect */ + if (rets[0] == 0) return 0; /* Oll Korrect */ if (rets[0] == 5) { if (rets[2] == 0) return -1; /* permanently unavailable */ return rets[2]; /* number of millisecs to wait */ } + if (rets[0] == 1) + return 250; + + printk (KERN_ERR "EEH: Slot unavailable: rc=%d, rets=%d %d %d\n", + rc, rets[0], rets[1], rets[2]); return -1; } @@ -737,6 +489,7 @@ eeh_slot_availability(struct pci_dn *pdn) static void rtas_pci_slot_reset(struct pci_dn *pdn, int state) { + int config_addr; int rc; BUG_ON (pdn==NULL); @@ -747,8 +500,13 @@ rtas_pci_slot_reset(struct pci_dn *pdn, int state) return; } + /* Use PE configuration address, if present */ + config_addr = pdn->eeh_config_addr; + if (pdn->eeh_pe_config_addr) + config_addr = pdn->eeh_pe_config_addr; + rc = rtas_call(ibm_set_slot_reset,4,1, NULL, - pdn->eeh_config_addr, + config_addr, BUID_HI(pdn->phb->buid), BUID_LO(pdn->phb->buid), state); @@ -761,9 +519,11 @@ rtas_pci_slot_reset(struct pci_dn *pdn, int state) /** rtas_set_slot_reset -- assert the pci #RST line for 1/4 second * dn -- device node to be reset. + * + * Return 0 if success, else a non-zero value. */ -void +int rtas_set_slot_reset(struct pci_dn *pdn) { int i, rc; @@ -793,10 +553,21 @@ rtas_set_slot_reset(struct pci_dn *pdn) * ready to be used; if not, wait for recovery. */ for (i=0; i<10; i++) { rc = eeh_slot_availability (pdn); - if (rc <= 0) break; + if (rc < 0) + printk (KERN_ERR "EEH: failed (%d) to reset slot %s\n", rc, pdn->node->full_name); + if (rc == 0) + return 0; + if (rc < 0) + return -1; msleep (rc+100); } + + rc = eeh_slot_availability (pdn); + if (rc) + printk (KERN_ERR "EEH: timeout resetting slot %s\n", pdn->node->full_name); + + return rc; } /* ------------------------------------------------------- */ @@ -851,7 +622,7 @@ void eeh_restore_bars(struct pci_dn *pdn) if (!pdn) return; - if (! pdn->eeh_is_bridge) + if ((pdn->eeh_mode & EEH_MODE_SUPPORTED) && !IS_BRIDGE(pdn->class_code)) __restore_bars (pdn); dn = pdn->node->child; @@ -869,30 +640,30 @@ void eeh_restore_bars(struct pci_dn *pdn) * PCI devices are added individuallly; but, for the restore, * an entire slot is reset at a time. */ -static void eeh_save_bars(struct pci_dev * pdev, struct pci_dn *pdn) +static void eeh_save_bars(struct pci_dn *pdn) { int i; - if (!pdev || !pdn ) + if (!pdn ) return; for (i = 0; i < 16; i++) - pci_read_config_dword(pdev, i * 4, &pdn->config_space[i]); - - if (pdev->hdr_type == PCI_HEADER_TYPE_BRIDGE) - pdn->eeh_is_bridge = 1; + rtas_read_config(pdn, i * 4, 4, &pdn->config_space[i]); } void rtas_configure_bridge(struct pci_dn *pdn) { - int token = rtas_token ("ibm,configure-bridge"); + int config_addr; int rc; - if (token == RTAS_UNKNOWN_SERVICE) - return; - rc = rtas_call(token,3,1, NULL, - pdn->eeh_config_addr, + /* Use PE configuration address, if present */ + config_addr = pdn->eeh_config_addr; + if (pdn->eeh_pe_config_addr) + config_addr = pdn->eeh_pe_config_addr; + + rc = rtas_call(ibm_configure_bridge,3,1, NULL, + config_addr, BUID_HI(pdn->phb->buid), BUID_LO(pdn->phb->buid)); if (rc) { @@ -927,6 +698,7 @@ static void *early_enable_eeh(struct device_node *dn, void *data) int enable; struct pci_dn *pdn = PCI_DN(dn); + pdn->class_code = 0; pdn->eeh_mode = 0; pdn->eeh_check_count = 0; pdn->eeh_freeze_count = 0; @@ -943,6 +715,7 @@ static void *early_enable_eeh(struct device_node *dn, void *data) pdn->eeh_mode |= EEH_MODE_NOCHECK; return NULL; } + pdn->class_code = *class_code; /* * Now decide if we are going to "Disable" EEH checking @@ -953,8 +726,10 @@ static void *early_enable_eeh(struct device_node *dn, void *data) * But there are a few cases like display devices that make sense. */ enable = 1; /* i.e. we will do checking */ +#if 0 if ((*class_code >> 16) == PCI_BASE_CLASS_DISPLAY) enable = 0; +#endif if (!enable) pdn->eeh_mode |= EEH_MODE_NOCHECK; @@ -973,8 +748,22 @@ static void *early_enable_eeh(struct device_node *dn, void *data) eeh_subsystem_enabled = 1; pdn->eeh_mode |= EEH_MODE_SUPPORTED; pdn->eeh_config_addr = regs[0]; + + /* If the newer, better, ibm,get-config-addr-info is supported, + * then use that instead. */ + pdn->eeh_pe_config_addr = 0; + if (ibm_get_config_addr_info != RTAS_UNKNOWN_SERVICE) { + unsigned int rets[2]; + ret = rtas_call (ibm_get_config_addr_info, 4, 2, rets, + pdn->eeh_config_addr, + info->buid_hi, info->buid_lo, + 0); + if (ret == 0) + pdn->eeh_pe_config_addr = rets[0]; + } #ifdef DEBUG - printk(KERN_DEBUG "EEH: %s: eeh enabled\n", dn->full_name); + printk(KERN_DEBUG "EEH: %s: eeh enabled, config=%x pe_config=%x\n", + dn->full_name, pdn->eeh_config_addr, pdn->eeh_pe_config_addr); #endif } else { @@ -993,6 +782,7 @@ static void *early_enable_eeh(struct device_node *dn, void *data) dn->full_name); } + eeh_save_bars(pdn); return NULL; } @@ -1026,6 +816,8 @@ void __init eeh_init(void) ibm_read_slot_reset_state2 = rtas_token("ibm,read-slot-reset-state2"); ibm_read_slot_reset_state = rtas_token("ibm,read-slot-reset-state"); ibm_slot_error_detail = rtas_token("ibm,slot-error-detail"); + ibm_get_config_addr_info = rtas_token("ibm,get-config-addr-info"); + ibm_configure_bridge = rtas_token ("ibm,configure-bridge"); if (ibm_set_eeh_option == RTAS_UNKNOWN_SERVICE) return; @@ -1080,12 +872,10 @@ void eeh_add_device_early(struct device_node *dn) if (!dn || !PCI_DN(dn)) return; phb = PCI_DN(dn)->phb; - if (NULL == phb || 0 == phb->buid) { - printk(KERN_WARNING "EEH: Expected buid but found none for %s\n", - dn->full_name); - dump_stack(); + + /* USB Bus children of PCI devices will not have BUID's */ + if (NULL == phb || 0 == phb->buid) return; - } info.buid_hi = BUID_HI(phb->buid); info.buid_lo = BUID_LO(phb->buid); @@ -1127,7 +917,6 @@ void eeh_add_device_late(struct pci_dev *dev) pdn->pcidev = dev; pci_addr_cache_insert_device (dev); - eeh_save_bars(dev, pdn); } EXPORT_SYMBOL_GPL(eeh_add_device_late); @@ -1175,25 +964,9 @@ EXPORT_SYMBOL_GPL(eeh_remove_bus_device); static int proc_eeh_show(struct seq_file *m, void *v) { - unsigned int cpu; - unsigned long ffs = 0, positives = 0, failures = 0; - unsigned long resets = 0; - unsigned long no_dev = 0, no_dn = 0, no_cfg = 0, no_check = 0; - - for_each_cpu(cpu) { - ffs += per_cpu(total_mmio_ffs, cpu); - positives += per_cpu(false_positives, cpu); - failures += per_cpu(ignored_failures, cpu); - resets += per_cpu(slot_resets, cpu); - no_dev += per_cpu(no_device, cpu); - no_dn += per_cpu(no_dn, cpu); - no_cfg += per_cpu(no_cfg_addr, cpu); - no_check += per_cpu(ignored_check, cpu); - } - if (0 == eeh_subsystem_enabled) { seq_printf(m, "EEH Subsystem is globally disabled\n"); - seq_printf(m, "eeh_total_mmio_ffs=%ld\n", ffs); + seq_printf(m, "eeh_total_mmio_ffs=%ld\n", total_mmio_ffs); } else { seq_printf(m, "EEH Subsystem is enabled\n"); seq_printf(m, @@ -1205,8 +978,10 @@ static int proc_eeh_show(struct seq_file *m, void *v) "eeh_false_positives=%ld\n" "eeh_ignored_failures=%ld\n" "eeh_slot_resets=%ld\n", - no_dev, no_dn, no_cfg, no_check, - ffs, positives, failures, resets); + no_device, no_dn, no_cfg_addr, + ignored_check, total_mmio_ffs, + false_positives, ignored_failures, + slot_resets); } return 0; diff --git a/trunk/arch/powerpc/platforms/pseries/eeh_cache.c b/trunk/arch/powerpc/platforms/pseries/eeh_cache.c new file mode 100644 index 000000000000..d4a402c5866c --- /dev/null +++ b/trunk/arch/powerpc/platforms/pseries/eeh_cache.c @@ -0,0 +1,316 @@ +/* + * eeh_cache.c + * PCI address cache; allows the lookup of PCI devices based on I/O address + * + * Copyright (C) 2004 Linas Vepstas IBM Corporation + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include +#include +#include +#include +#include +#include +#include + +#undef DEBUG + +/** + * The pci address cache subsystem. This subsystem places + * PCI device address resources into a red-black tree, sorted + * according to the address range, so that given only an i/o + * address, the corresponding PCI device can be **quickly** + * found. It is safe to perform an address lookup in an interrupt + * context; this ability is an important feature. + * + * Currently, the only customer of this code is the EEH subsystem; + * thus, this code has been somewhat tailored to suit EEH better. + * In particular, the cache does *not* hold the addresses of devices + * for which EEH is not enabled. + * + * (Implementation Note: The RB tree seems to be better/faster + * than any hash algo I could think of for this problem, even + * with the penalty of slow pointer chases for d-cache misses). + */ +struct pci_io_addr_range +{ + struct rb_node rb_node; + unsigned long addr_lo; + unsigned long addr_hi; + struct pci_dev *pcidev; + unsigned int flags; +}; + +static struct pci_io_addr_cache +{ + struct rb_root rb_root; + spinlock_t piar_lock; +} pci_io_addr_cache_root; + +static inline struct pci_dev *__pci_get_device_by_addr(unsigned long addr) +{ + struct rb_node *n = pci_io_addr_cache_root.rb_root.rb_node; + + while (n) { + struct pci_io_addr_range *piar; + piar = rb_entry(n, struct pci_io_addr_range, rb_node); + + if (addr < piar->addr_lo) { + n = n->rb_left; + } else { + if (addr > piar->addr_hi) { + n = n->rb_right; + } else { + pci_dev_get(piar->pcidev); + return piar->pcidev; + } + } + } + + return NULL; +} + +/** + * pci_get_device_by_addr - Get device, given only address + * @addr: mmio (PIO) phys address or i/o port number + * + * Given an mmio phys address, or a port number, find a pci device + * that implements this address. Be sure to pci_dev_put the device + * when finished. I/O port numbers are assumed to be offset + * from zero (that is, they do *not* have pci_io_addr added in). + * It is safe to call this function within an interrupt. + */ +struct pci_dev *pci_get_device_by_addr(unsigned long addr) +{ + struct pci_dev *dev; + unsigned long flags; + + spin_lock_irqsave(&pci_io_addr_cache_root.piar_lock, flags); + dev = __pci_get_device_by_addr(addr); + spin_unlock_irqrestore(&pci_io_addr_cache_root.piar_lock, flags); + return dev; +} + +#ifdef DEBUG +/* + * Handy-dandy debug print routine, does nothing more + * than print out the contents of our addr cache. + */ +static void pci_addr_cache_print(struct pci_io_addr_cache *cache) +{ + struct rb_node *n; + int cnt = 0; + + n = rb_first(&cache->rb_root); + while (n) { + struct pci_io_addr_range *piar; + piar = rb_entry(n, struct pci_io_addr_range, rb_node); + printk(KERN_DEBUG "PCI: %s addr range %d [%lx-%lx]: %s\n", + (piar->flags & IORESOURCE_IO) ? "i/o" : "mem", cnt, + piar->addr_lo, piar->addr_hi, pci_name(piar->pcidev)); + cnt++; + n = rb_next(n); + } +} +#endif + +/* Insert address range into the rb tree. */ +static struct pci_io_addr_range * +pci_addr_cache_insert(struct pci_dev *dev, unsigned long alo, + unsigned long ahi, unsigned int flags) +{ + struct rb_node **p = &pci_io_addr_cache_root.rb_root.rb_node; + struct rb_node *parent = NULL; + struct pci_io_addr_range *piar; + + /* Walk tree, find a place to insert into tree */ + while (*p) { + parent = *p; + piar = rb_entry(parent, struct pci_io_addr_range, rb_node); + if (ahi < piar->addr_lo) { + p = &parent->rb_left; + } else if (alo > piar->addr_hi) { + p = &parent->rb_right; + } else { + if (dev != piar->pcidev || + alo != piar->addr_lo || ahi != piar->addr_hi) { + printk(KERN_WARNING "PIAR: overlapping address range\n"); + } + return piar; + } + } + piar = (struct pci_io_addr_range *)kmalloc(sizeof(struct pci_io_addr_range), GFP_ATOMIC); + if (!piar) + return NULL; + + piar->addr_lo = alo; + piar->addr_hi = ahi; + piar->pcidev = dev; + piar->flags = flags; + +#ifdef DEBUG + printk(KERN_DEBUG "PIAR: insert range=[%lx:%lx] dev=%s\n", + alo, ahi, pci_name (dev)); +#endif + + rb_link_node(&piar->rb_node, parent, p); + rb_insert_color(&piar->rb_node, &pci_io_addr_cache_root.rb_root); + + return piar; +} + +static void __pci_addr_cache_insert_device(struct pci_dev *dev) +{ + struct device_node *dn; + struct pci_dn *pdn; + int i; + int inserted = 0; + + dn = pci_device_to_OF_node(dev); + if (!dn) { + printk(KERN_WARNING "PCI: no pci dn found for dev=%s\n", pci_name(dev)); + return; + } + + /* Skip any devices for which EEH is not enabled. */ + pdn = PCI_DN(dn); + if (!(pdn->eeh_mode & EEH_MODE_SUPPORTED) || + pdn->eeh_mode & EEH_MODE_NOCHECK) { +#ifdef DEBUG + printk(KERN_INFO "PCI: skip building address cache for=%s - %s\n", + pci_name(dev), pdn->node->full_name); +#endif + return; + } + + /* The cache holds a reference to the device... */ + pci_dev_get(dev); + + /* Walk resources on this device, poke them into the tree */ + for (i = 0; i < DEVICE_COUNT_RESOURCE; i++) { + unsigned long start = pci_resource_start(dev,i); + unsigned long end = pci_resource_end(dev,i); + unsigned int flags = pci_resource_flags(dev,i); + + /* We are interested only bus addresses, not dma or other stuff */ + if (0 == (flags & (IORESOURCE_IO | IORESOURCE_MEM))) + continue; + if (start == 0 || ~start == 0 || end == 0 || ~end == 0) + continue; + pci_addr_cache_insert(dev, start, end, flags); + inserted = 1; + } + + /* If there was nothing to add, the cache has no reference... */ + if (!inserted) + pci_dev_put(dev); +} + +/** + * pci_addr_cache_insert_device - Add a device to the address cache + * @dev: PCI device whose I/O addresses we are interested in. + * + * In order to support the fast lookup of devices based on addresses, + * we maintain a cache of devices that can be quickly searched. + * This routine adds a device to that cache. + */ +void pci_addr_cache_insert_device(struct pci_dev *dev) +{ + unsigned long flags; + + spin_lock_irqsave(&pci_io_addr_cache_root.piar_lock, flags); + __pci_addr_cache_insert_device(dev); + spin_unlock_irqrestore(&pci_io_addr_cache_root.piar_lock, flags); +} + +static inline void __pci_addr_cache_remove_device(struct pci_dev *dev) +{ + struct rb_node *n; + int removed = 0; + +restart: + n = rb_first(&pci_io_addr_cache_root.rb_root); + while (n) { + struct pci_io_addr_range *piar; + piar = rb_entry(n, struct pci_io_addr_range, rb_node); + + if (piar->pcidev == dev) { + rb_erase(n, &pci_io_addr_cache_root.rb_root); + removed = 1; + kfree(piar); + goto restart; + } + n = rb_next(n); + } + + /* The cache no longer holds its reference to this device... */ + if (removed) + pci_dev_put(dev); +} + +/** + * pci_addr_cache_remove_device - remove pci device from addr cache + * @dev: device to remove + * + * Remove a device from the addr-cache tree. + * This is potentially expensive, since it will walk + * the tree multiple times (once per resource). + * But so what; device removal doesn't need to be that fast. + */ +void pci_addr_cache_remove_device(struct pci_dev *dev) +{ + unsigned long flags; + + spin_lock_irqsave(&pci_io_addr_cache_root.piar_lock, flags); + __pci_addr_cache_remove_device(dev); + spin_unlock_irqrestore(&pci_io_addr_cache_root.piar_lock, flags); +} + +/** + * pci_addr_cache_build - Build a cache of I/O addresses + * + * Build a cache of pci i/o addresses. This cache will be used to + * find the pci device that corresponds to a given address. + * This routine scans all pci busses to build the cache. + * Must be run late in boot process, after the pci controllers + * have been scaned for devices (after all device resources are known). + */ +void __init pci_addr_cache_build(void) +{ + struct device_node *dn; + struct pci_dev *dev = NULL; + + spin_lock_init(&pci_io_addr_cache_root.piar_lock); + + while ((dev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, dev)) != NULL) { + /* Ignore PCI bridges */ + if ((dev->class >> 16) == PCI_BASE_CLASS_BRIDGE) + continue; + + pci_addr_cache_insert_device(dev); + + dn = pci_device_to_OF_node(dev); + pci_dev_get (dev); /* matching put is in eeh_remove_device() */ + PCI_DN(dn)->pcidev = dev; + } + +#ifdef DEBUG + /* Verify tree built up above, echo back the list of addrs. */ + pci_addr_cache_print(&pci_io_addr_cache_root); +#endif +} + diff --git a/trunk/arch/powerpc/platforms/pseries/eeh_driver.c b/trunk/arch/powerpc/platforms/pseries/eeh_driver.c new file mode 100644 index 000000000000..6373372932ba --- /dev/null +++ b/trunk/arch/powerpc/platforms/pseries/eeh_driver.c @@ -0,0 +1,376 @@ +/* + * PCI Error Recovery Driver for RPA-compliant PPC64 platform. + * Copyright (C) 2004, 2005 Linas Vepstas + * + * All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or (at + * your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or + * NON INFRINGEMENT. See the GNU General Public License for more + * details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * Send feedback to + * + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +static inline const char * pcid_name (struct pci_dev *pdev) +{ + if (pdev->dev.driver) + return pdev->dev.driver->name; + return ""; +} + +#ifdef DEBUG +static void print_device_node_tree (struct pci_dn *pdn, int dent) +{ + int i; + if (!pdn) return; + for (i=0;inode->name, pdn->eeh_mode, pdn->eeh_config_addr, + pdn->eeh_pe_config_addr, pdn->node->full_name); + dent += 3; + struct device_node *pc = pdn->node->child; + while (pc) { + print_device_node_tree(PCI_DN(pc), dent); + pc = pc->sibling; + } +} +#endif + +/** + * irq_in_use - return true if this irq is being used + */ +static int irq_in_use(unsigned int irq) +{ + int rc = 0; + unsigned long flags; + struct irq_desc *desc = irq_desc + irq; + + spin_lock_irqsave(&desc->lock, flags); + if (desc->action) + rc = 1; + spin_unlock_irqrestore(&desc->lock, flags); + return rc; +} + +/* ------------------------------------------------------- */ +/** eeh_report_error - report an EEH error to each device, + * collect up and merge the device responses. + */ + +static void eeh_report_error(struct pci_dev *dev, void *userdata) +{ + enum pci_ers_result rc, *res = userdata; + struct pci_driver *driver = dev->driver; + + dev->error_state = pci_channel_io_frozen; + + if (!driver) + return; + + if (irq_in_use (dev->irq)) { + struct device_node *dn = pci_device_to_OF_node(dev); + PCI_DN(dn)->eeh_mode |= EEH_MODE_IRQ_DISABLED; + disable_irq_nosync(dev->irq); + } + if (!driver->err_handler) + return; + if (!driver->err_handler->error_detected) + return; + + rc = driver->err_handler->error_detected (dev, pci_channel_io_frozen); + if (*res == PCI_ERS_RESULT_NONE) *res = rc; + if (*res == PCI_ERS_RESULT_NEED_RESET) return; + if (*res == PCI_ERS_RESULT_DISCONNECT && + rc == PCI_ERS_RESULT_NEED_RESET) *res = rc; +} + +/** eeh_report_reset -- tell this device that the pci slot + * has been reset. + */ + +static void eeh_report_reset(struct pci_dev *dev, void *userdata) +{ + struct pci_driver *driver = dev->driver; + struct device_node *dn = pci_device_to_OF_node(dev); + + if (!driver) + return; + + if ((PCI_DN(dn)->eeh_mode) & EEH_MODE_IRQ_DISABLED) { + PCI_DN(dn)->eeh_mode &= ~EEH_MODE_IRQ_DISABLED; + enable_irq(dev->irq); + } + if (!driver->err_handler) + return; + if (!driver->err_handler->slot_reset) + return; + + driver->err_handler->slot_reset(dev); +} + +static void eeh_report_resume(struct pci_dev *dev, void *userdata) +{ + struct pci_driver *driver = dev->driver; + + dev->error_state = pci_channel_io_normal; + + if (!driver) + return; + if (!driver->err_handler) + return; + if (!driver->err_handler->resume) + return; + + driver->err_handler->resume(dev); +} + +static void eeh_report_failure(struct pci_dev *dev, void *userdata) +{ + struct pci_driver *driver = dev->driver; + + dev->error_state = pci_channel_io_perm_failure; + + if (!driver) + return; + + if (irq_in_use (dev->irq)) { + struct device_node *dn = pci_device_to_OF_node(dev); + PCI_DN(dn)->eeh_mode |= EEH_MODE_IRQ_DISABLED; + disable_irq_nosync(dev->irq); + } + if (!driver->err_handler) + return; + if (!driver->err_handler->error_detected) + return; + driver->err_handler->error_detected(dev, pci_channel_io_perm_failure); +} + +/* ------------------------------------------------------- */ +/** + * handle_eeh_events -- reset a PCI device after hard lockup. + * + * pSeries systems will isolate a PCI slot if the PCI-Host + * bridge detects address or data parity errors, DMA's + * occuring to wild addresses (which usually happen due to + * bugs in device drivers or in PCI adapter firmware). + * Slot isolations also occur if #SERR, #PERR or other misc + * PCI-related errors are detected. + * + * Recovery process consists of unplugging the device driver + * (which generated hotplug events to userspace), then issuing + * a PCI #RST to the device, then reconfiguring the PCI config + * space for all bridges & devices under this slot, and then + * finally restarting the device drivers (which cause a second + * set of hotplug events to go out to userspace). + */ + +/** + * eeh_reset_device() -- perform actual reset of a pci slot + * Args: bus: pointer to the pci bus structure corresponding + * to the isolated slot. A non-null value will + * cause all devices under the bus to be removed + * and then re-added. + * pe_dn: pointer to a "Partionable Endpoint" device node. + * This is the top-level structure on which pci + * bus resets can be performed. + */ + +static int eeh_reset_device (struct pci_dn *pe_dn, struct pci_bus *bus) +{ + int rc; + if (bus) + pcibios_remove_pci_devices(bus); + + /* Reset the pci controller. (Asserts RST#; resets config space). + * Reconfigure bridges and devices. Don't try to bring the system + * up if the reset failed for some reason. */ + rc = rtas_set_slot_reset(pe_dn); + if (rc) + return rc; + + /* New-style config addrs might be shared across multiple devices, + * Walk over all functions on this device */ + if (pe_dn->eeh_pe_config_addr) { + struct device_node *pe = pe_dn->node; + pe = pe->parent->child; + while (pe) { + struct pci_dn *ppe = PCI_DN(pe); + if (pe_dn->eeh_pe_config_addr == ppe->eeh_pe_config_addr) { + rtas_configure_bridge(ppe); + eeh_restore_bars(ppe); + } + pe = pe->sibling; + } + } else { + rtas_configure_bridge(pe_dn); + eeh_restore_bars(pe_dn); + } + + /* Give the system 5 seconds to finish running the user-space + * hotplug shutdown scripts, e.g. ifdown for ethernet. Yes, + * this is a hack, but if we don't do this, and try to bring + * the device up before the scripts have taken it down, + * potentially weird things happen. + */ + if (bus) { + ssleep (5); + pcibios_add_pci_devices(bus); + } + + return 0; +} + +/* The longest amount of time to wait for a pci device + * to come back on line, in seconds. + */ +#define MAX_WAIT_FOR_RECOVERY 15 + +void handle_eeh_events (struct eeh_event *event) +{ + struct device_node *frozen_dn; + struct pci_dn *frozen_pdn; + struct pci_bus *frozen_bus; + int rc = 0; + enum pci_ers_result result = PCI_ERS_RESULT_NONE; + + frozen_dn = find_device_pe(event->dn); + frozen_bus = pcibios_find_pci_bus(frozen_dn); + + if (!frozen_dn) { + printk(KERN_ERR "EEH: Error: Cannot find partition endpoint for %s\n", + pci_name(event->dev)); + return; + } + + /* There are two different styles for coming up with the PE. + * In the old style, it was the highest EEH-capable device + * which was always an EADS pci bridge. In the new style, + * there might not be any EADS bridges, and even when there are, + * the firmware marks them as "EEH incapable". So another + * two-step is needed to find the pci bus.. */ + if (!frozen_bus) + frozen_bus = pcibios_find_pci_bus (frozen_dn->parent); + + if (!frozen_bus) { + printk(KERN_ERR "EEH: Cannot find PCI bus for %s\n", + frozen_dn->full_name); + return; + } + +#if 0 + /* We may get "permanent failure" messages on empty slots. + * These are false alarms. Empty slots have no child dn. */ + if ((event->state == pci_channel_io_perm_failure) && (frozen_device == NULL)) + return; +#endif + + frozen_pdn = PCI_DN(frozen_dn); + frozen_pdn->eeh_freeze_count++; + + if (frozen_pdn->eeh_freeze_count > EEH_MAX_ALLOWED_FREEZES) + goto hard_fail; + + /* If the reset state is a '5' and the time to reset is 0 (infinity) + * or is more then 15 seconds, then mark this as a permanent failure. + */ + if ((event->state == pci_channel_io_perm_failure) && + ((event->time_unavail <= 0) || + (event->time_unavail > MAX_WAIT_FOR_RECOVERY*1000))) + goto hard_fail; + + eeh_slot_error_detail(frozen_pdn, 1 /* Temporary Error */); + printk(KERN_WARNING + "EEH: This PCI device has failed %d times since last reboot: %s - %s\n", + frozen_pdn->eeh_freeze_count, + pci_name (frozen_pdn->pcidev), + pcid_name(frozen_pdn->pcidev)); + + /* Walk the various device drivers attached to this slot through + * a reset sequence, giving each an opportunity to do what it needs + * to accomplish the reset. Each child gets a report of the + * status ... if any child can't handle the reset, then the entire + * slot is dlpar removed and added. + */ + pci_walk_bus(frozen_bus, eeh_report_error, &result); + + /* If all device drivers were EEH-unaware, then shut + * down all of the device drivers, and hope they + * go down willingly, without panicing the system. + */ + if (result == PCI_ERS_RESULT_NONE) { + rc = eeh_reset_device(frozen_pdn, frozen_bus); + if (rc) + goto hard_fail; + } + + /* If any device called out for a reset, then reset the slot */ + if (result == PCI_ERS_RESULT_NEED_RESET) { + rc = eeh_reset_device(frozen_pdn, NULL); + if (rc) + goto hard_fail; + pci_walk_bus(frozen_bus, eeh_report_reset, 0); + } + + /* If all devices reported they can proceed, the re-enable PIO */ + if (result == PCI_ERS_RESULT_CAN_RECOVER) { + /* XXX Not supported; we brute-force reset the device */ + rc = eeh_reset_device(frozen_pdn, NULL); + if (rc) + goto hard_fail; + pci_walk_bus(frozen_bus, eeh_report_reset, 0); + } + + /* Tell all device drivers that they can resume operations */ + pci_walk_bus(frozen_bus, eeh_report_resume, 0); + + return; + +hard_fail: + /* + * About 90% of all real-life EEH failures in the field + * are due to poorly seated PCI cards. Only 10% or so are + * due to actual, failed cards. + */ + printk(KERN_ERR + "EEH: PCI device %s - %s has failed %d times \n" + "and has been permanently disabled. Please try reseating\n" + "this device or replacing it.\n", + pci_name (frozen_pdn->pcidev), + pcid_name(frozen_pdn->pcidev), + frozen_pdn->eeh_freeze_count); + + eeh_slot_error_detail(frozen_pdn, 2 /* Permanent Error */); + + /* Notify all devices that they're about to go down. */ + pci_walk_bus(frozen_bus, eeh_report_failure, 0); + + /* Shut down the device drivers for good. */ + pcibios_remove_pci_devices(frozen_bus); +} + +/* ---------- end of file ---------- */ diff --git a/trunk/arch/powerpc/platforms/pseries/eeh_event.c b/trunk/arch/powerpc/platforms/pseries/eeh_event.c index 92497333c2b6..9a9961f27480 100644 --- a/trunk/arch/powerpc/platforms/pseries/eeh_event.c +++ b/trunk/arch/powerpc/platforms/pseries/eeh_event.c @@ -21,6 +21,7 @@ #include #include #include +#include /** Overview: * EEH error states may be detected within exception handlers; @@ -36,31 +37,6 @@ LIST_HEAD(eeh_eventlist); static void eeh_thread_launcher(void *); DECLARE_WORK(eeh_event_wq, eeh_thread_launcher, NULL); -/** - * eeh_panic - call panic() for an eeh event that cannot be handled. - * The philosophy of this routine is that it is better to panic and - * halt the OS than it is to risk possible data corruption by - * oblivious device drivers that don't know better. - * - * @dev pci device that had an eeh event - * @reset_state current reset state of the device slot - */ -static void eeh_panic(struct pci_dev *dev, int reset_state) -{ - /* - * Since the panic_on_oops sysctl is used to halt the system - * in light of potential corruption, we can use it here. - */ - if (panic_on_oops) { - panic("EEH: MMIO failure (%d) on device:%s\n", reset_state, - pci_name(dev)); - } - else { - printk(KERN_INFO "EEH: Ignored MMIO failure (%d) on device:%s\n", - reset_state, pci_name(dev)); - } -} - /** * eeh_event_handler - dispatch EEH events. The detection of a frozen * slot can occur inside an interrupt, where it can be hard to do @@ -82,10 +58,16 @@ static int eeh_event_handler(void * dummy) spin_lock_irqsave(&eeh_eventlist_lock, flags); event = NULL; + + /* Unqueue the event, get ready to process. */ if (!list_empty(&eeh_eventlist)) { event = list_entry(eeh_eventlist.next, struct eeh_event, list); list_del(&event->list); } + + if (event) + eeh_mark_slot(event->dn, EEH_MODE_RECOVERING); + spin_unlock_irqrestore(&eeh_eventlist_lock, flags); if (event == NULL) break; @@ -93,8 +75,11 @@ static int eeh_event_handler(void * dummy) printk(KERN_INFO "EEH: Detected PCI bus error on device %s\n", pci_name(event->dev)); - eeh_panic (event->dev, event->state); + handle_eeh_events(event); + + eeh_clear_slot(event->dn, EEH_MODE_RECOVERING); + pci_dev_put(event->dev); kfree(event); } @@ -122,7 +107,7 @@ static void eeh_thread_launcher(void *dummy) */ int eeh_send_failure_event (struct device_node *dn, struct pci_dev *dev, - int state, + enum pci_channel_state state, int time_unavail) { unsigned long flags; diff --git a/trunk/arch/ppc/Makefile b/trunk/arch/ppc/Makefile index e719a4933af1..98e940beeb3b 100644 --- a/trunk/arch/ppc/Makefile +++ b/trunk/arch/ppc/Makefile @@ -128,10 +128,9 @@ TOUT := .tmp_gas_check # Ensure this is binutils 2.12.1 (or 2.12.90.0.7) or later for altivec # instructions. # gcc-3.4 and binutils-2.14 are a fatal combination. -GCC_VERSION := $(call cc-version) checkbin: - @if test "$(GCC_VERSION)" = "0304" ; then \ + @if test "$(call cc-version)" = "0304" ; then \ if ! /bin/echo mftb 5 | $(AS) -v -mppc -many -o $(TOUT) >/dev/null 2>&1 ; then \ echo -n '*** ${VERSION}.${PATCHLEVEL} kernels no longer build '; \ echo 'correctly with gcc-3.4 and your version of binutils.'; \ diff --git a/trunk/arch/ppc/kernel/machine_kexec.c b/trunk/arch/ppc/kernel/machine_kexec.c index a882b0dbe8de..84d65a87191e 100644 --- a/trunk/arch/ppc/kernel/machine_kexec.c +++ b/trunk/arch/ppc/kernel/machine_kexec.c @@ -28,12 +28,6 @@ typedef NORET_TYPE void (*relocate_new_kernel_t)( const extern unsigned char relocate_new_kernel[]; const extern unsigned int relocate_new_kernel_size; -/* - * Provide a dummy crash_notes definition while crash dump arrives to ppc. - * This prevents breakage of crash_notes attribute in kernel/ksysfs.c. - */ -note_buf_t crash_notes[NR_CPUS]; - void machine_shutdown(void) { if (ppc_md.machine_shutdown) diff --git a/trunk/arch/s390/Kconfig b/trunk/arch/s390/Kconfig index 6fe532d82417..b66602ad7b33 100644 --- a/trunk/arch/s390/Kconfig +++ b/trunk/arch/s390/Kconfig @@ -27,11 +27,6 @@ config S390 bool default y -config UID16 - bool - default y - depends on !64BIT - source "init/Kconfig" menu "Base setup" diff --git a/trunk/arch/s390/kernel/Makefile b/trunk/arch/s390/kernel/Makefile index 4865e4b49464..9269b5788fac 100644 --- a/trunk/arch/s390/kernel/Makefile +++ b/trunk/arch/s390/kernel/Makefile @@ -17,8 +17,7 @@ obj-$(CONFIG_MODULES) += s390_ksyms.o module.o obj-$(CONFIG_SMP) += smp.o obj-$(CONFIG_COMPAT) += compat_linux.o compat_signal.o \ - compat_ioctl.o compat_wrapper.o \ - compat_exec_domain.o + compat_wrapper.o compat_exec_domain.o obj-$(CONFIG_BINFMT_ELF32) += binfmt_elf32.o obj-$(CONFIG_VIRT_TIMER) += vtime.o diff --git a/trunk/arch/s390/kernel/compat_ioctl.c b/trunk/arch/s390/kernel/compat_ioctl.c deleted file mode 100644 index 6504c4e69986..000000000000 --- a/trunk/arch/s390/kernel/compat_ioctl.c +++ /dev/null @@ -1,81 +0,0 @@ -/* - * ioctl32.c: Conversion between 32bit and 64bit native ioctls. - * - * S390 version - * Copyright (C) 2000-2003 IBM Deutschland Entwicklung GmbH, IBM Corporation - * Author(s): Gerhard Tonn (ton@de.ibm.com) - * Arnd Bergmann (arndb@de.ibm.com) - * - * Original implementation from 32-bit Sparc compat code which is - * Copyright (C) 2000 Silicon Graphics, Inc. - * Written by Ulf Carlsson (ulfc@engr.sgi.com) - */ - -#include "compat_linux.h" -#define INCLUDES -#define CODE -#include "../../../fs/compat_ioctl.c" -#include -#include -#include -#include -#include "../../../drivers/s390/char/raw3270.h" - -static int do_ioctl32_pointer(unsigned int fd, unsigned int cmd, - unsigned long arg, struct file *f) -{ - return sys_ioctl(fd, cmd, (unsigned long)compat_ptr(arg)); -} - -static int do_ioctl32_ulong(unsigned int fd, unsigned int cmd, - unsigned long arg, struct file *f) -{ - return sys_ioctl(fd, cmd, arg); -} - -#define COMPATIBLE_IOCTL(cmd) HANDLE_IOCTL((cmd),(ioctl_trans_handler_t)do_ioctl32_pointer) -#define ULONG_IOCTL(cmd) HANDLE_IOCTL((cmd),(ioctl_trans_handler_t)do_ioctl32_ulong) -#define HANDLE_IOCTL(cmd,handler) { (cmd), (ioctl_trans_handler_t)(handler), NULL }, - -struct ioctl_trans ioctl_start[] = { -/* architecture independent ioctls */ -#include -#define DECLARES -#include "../../../fs/compat_ioctl.c" - -/* s390 only ioctls */ -COMPATIBLE_IOCTL(DASDAPIVER) -COMPATIBLE_IOCTL(BIODASDDISABLE) -COMPATIBLE_IOCTL(BIODASDENABLE) -COMPATIBLE_IOCTL(BIODASDRSRV) -COMPATIBLE_IOCTL(BIODASDRLSE) -COMPATIBLE_IOCTL(BIODASDSLCK) -COMPATIBLE_IOCTL(BIODASDINFO) -COMPATIBLE_IOCTL(BIODASDINFO2) -COMPATIBLE_IOCTL(BIODASDFMT) -COMPATIBLE_IOCTL(BIODASDPRRST) -COMPATIBLE_IOCTL(BIODASDQUIESCE) -COMPATIBLE_IOCTL(BIODASDRESUME) -COMPATIBLE_IOCTL(BIODASDPRRD) -COMPATIBLE_IOCTL(BIODASDPSRD) -COMPATIBLE_IOCTL(BIODASDGATTR) -COMPATIBLE_IOCTL(BIODASDSATTR) -COMPATIBLE_IOCTL(BIODASDCMFENABLE) -COMPATIBLE_IOCTL(BIODASDCMFDISABLE) -COMPATIBLE_IOCTL(BIODASDREADALLCMB) - -COMPATIBLE_IOCTL(TUBICMD) -COMPATIBLE_IOCTL(TUBOCMD) -COMPATIBLE_IOCTL(TUBGETI) -COMPATIBLE_IOCTL(TUBGETO) -COMPATIBLE_IOCTL(TUBSETMOD) -COMPATIBLE_IOCTL(TUBGETMOD) - -COMPATIBLE_IOCTL(TAPE390_DISPLAY) - -/* s390 doesn't need handlers here */ -COMPATIBLE_IOCTL(TIOCGSERIAL) -COMPATIBLE_IOCTL(TIOCSSERIAL) -}; - -int ioctl_table_size = ARRAY_SIZE(ioctl_start); diff --git a/trunk/arch/s390/kernel/compat_linux.c b/trunk/arch/s390/kernel/compat_linux.c index 41b197a3f3a3..cd3b3c3e7a9f 100644 --- a/trunk/arch/s390/kernel/compat_linux.c +++ b/trunk/arch/s390/kernel/compat_linux.c @@ -1013,38 +1013,6 @@ asmlinkage long sys32_clone(struct pt_regs regs) parent_tidptr, child_tidptr); } -/* - * Wrapper function for sys_timer_create. - */ -extern asmlinkage long -sys_timer_create(clockid_t, struct sigevent *, timer_t *); - -asmlinkage long -sys32_timer_create(clockid_t which_clock, struct compat_sigevent *se32, - timer_t *timer_id) -{ - struct sigevent se; - timer_t ktimer_id; - mm_segment_t old_fs; - long ret; - - if (se32 == NULL) - return sys_timer_create(which_clock, NULL, timer_id); - - if (get_compat_sigevent(&se, se32)) - return -EFAULT; - - old_fs = get_fs(); - set_fs(KERNEL_DS); - ret = sys_timer_create(which_clock, &se, &ktimer_id); - set_fs(old_fs); - - if (!ret) - ret = put_user (ktimer_id, timer_id); - - return ret; -} - /* * 31 bit emulation wrapper functions for sys_fadvise64/fadvise64_64. * These need to rewrite the advise values for POSIX_FADV_{DONTNEED,NOREUSE} diff --git a/trunk/arch/s390/kernel/compat_wrapper.S b/trunk/arch/s390/kernel/compat_wrapper.S index 23fe94e58688..cfde1905d07d 100644 --- a/trunk/arch/s390/kernel/compat_wrapper.S +++ b/trunk/arch/s390/kernel/compat_wrapper.S @@ -1289,7 +1289,7 @@ sys32_timer_create_wrapper: lgfr %r2,%r2 # timer_t (int) llgtr %r3,%r3 # struct compat_sigevent * llgtr %r4,%r4 # timer_t * - jg sys32_timer_create + jg compat_sys_timer_create .globl sys32_timer_settime_wrapper sys32_timer_settime_wrapper: diff --git a/trunk/arch/s390/kernel/crash.c b/trunk/arch/s390/kernel/crash.c index 7bd169c58b0c..926cceeae0fa 100644 --- a/trunk/arch/s390/kernel/crash.c +++ b/trunk/arch/s390/kernel/crash.c @@ -10,8 +10,6 @@ #include #include -note_buf_t crash_notes[NR_CPUS]; - void machine_crash_shutdown(struct pt_regs *regs) { } diff --git a/trunk/arch/s390/kernel/process.c b/trunk/arch/s390/kernel/process.c index a942bf2d58e9..7dd58f8ac6b5 100644 --- a/trunk/arch/s390/kernel/process.c +++ b/trunk/arch/s390/kernel/process.c @@ -352,27 +352,6 @@ int dump_fpu (struct pt_regs * regs, s390_fp_regs *fpregs) return 1; } -/* - * fill in the user structure for a core dump.. - */ -void dump_thread(struct pt_regs * regs, struct user * dump) -{ - -/* changed the size calculations - should hopefully work better. lbt */ - dump->magic = CMAGIC; - dump->start_code = 0; - dump->start_stack = regs->gprs[15] & ~(PAGE_SIZE - 1); - dump->u_tsize = current->mm->end_code >> PAGE_SHIFT; - dump->u_dsize = (current->mm->brk + PAGE_SIZE - 1) >> PAGE_SHIFT; - dump->u_dsize -= dump->u_tsize; - dump->u_ssize = 0; - if (dump->start_stack < TASK_SIZE) - dump->u_ssize = (TASK_SIZE - dump->start_stack) >> PAGE_SHIFT; - memcpy(&dump->regs, regs, sizeof(s390_regs)); - dump_fpu (regs, &dump->regs.fp_regs); - dump->regs.per_info = current->thread.per_info; -} - unsigned long get_wchan(struct task_struct *p) { struct stack_frame *sf, *low, *high; diff --git a/trunk/arch/s390/kernel/s390_ksyms.c b/trunk/arch/s390/kernel/s390_ksyms.c index bee654abb6d3..4176c77670c4 100644 --- a/trunk/arch/s390/kernel/s390_ksyms.c +++ b/trunk/arch/s390/kernel/s390_ksyms.c @@ -10,7 +10,6 @@ #include #include #include -#include #include #include #include diff --git a/trunk/arch/sh/kernel/process.c b/trunk/arch/sh/kernel/process.c index fd4f240b833d..8a2bea34ddd2 100644 --- a/trunk/arch/sh/kernel/process.c +++ b/trunk/arch/sh/kernel/process.c @@ -305,26 +305,6 @@ int copy_thread(int nr, unsigned long clone_flags, unsigned long usp, return 0; } -/* - * fill in the user structure for a core dump.. - */ -void dump_thread(struct pt_regs * regs, struct user * dump) -{ - dump->magic = CMAGIC; - dump->start_code = current->mm->start_code; - dump->start_data = current->mm->start_data; - dump->start_stack = regs->regs[15] & ~(PAGE_SIZE - 1); - dump->u_tsize = (current->mm->end_code - dump->start_code) >> PAGE_SHIFT; - dump->u_dsize = (current->mm->brk + (PAGE_SIZE-1) - dump->start_data) >> PAGE_SHIFT; - dump->u_ssize = (current->mm->start_stack - dump->start_stack + - PAGE_SIZE - 1) >> PAGE_SHIFT; - /* Debug registers will come here. */ - - dump->regs = *regs; - - dump->u_fpvalid = dump_fpu(regs, &dump->fpu); -} - /* Tracing by user break controller. */ static void ubc_set_tracing(int asid, unsigned long pc) diff --git a/trunk/arch/sh/kernel/sh_ksyms.c b/trunk/arch/sh/kernel/sh_ksyms.c index 6954fd62470a..1cf94a618be3 100644 --- a/trunk/arch/sh/kernel/sh_ksyms.c +++ b/trunk/arch/sh/kernel/sh_ksyms.c @@ -21,14 +21,12 @@ #include #include -extern void dump_thread(struct pt_regs *, struct user *); extern int dump_fpu(struct pt_regs *, elf_fpregset_t *); extern struct hw_interrupt_type no_irq_type; EXPORT_SYMBOL(sh_mv); /* platform dependent support */ -EXPORT_SYMBOL(dump_thread); EXPORT_SYMBOL(dump_fpu); EXPORT_SYMBOL(iounmap); EXPORT_SYMBOL(enable_irq); diff --git a/trunk/arch/sh64/Kconfig b/trunk/arch/sh64/Kconfig index fb35b45dc130..07b172deb872 100644 --- a/trunk/arch/sh64/Kconfig +++ b/trunk/arch/sh64/Kconfig @@ -17,10 +17,6 @@ config MMU bool default y -config UID16 - bool - default y - config RWSEM_GENERIC_SPINLOCK bool default y diff --git a/trunk/arch/sh64/kernel/process.c b/trunk/arch/sh64/kernel/process.c index b95d04141855..419b5a710441 100644 --- a/trunk/arch/sh64/kernel/process.c +++ b/trunk/arch/sh64/kernel/process.c @@ -775,26 +775,6 @@ int copy_thread(int nr, unsigned long clone_flags, unsigned long usp, return 0; } -/* - * fill in the user structure for a core dump.. - */ -void dump_thread(struct pt_regs * regs, struct user * dump) -{ - dump->magic = CMAGIC; - dump->start_code = current->mm->start_code; - dump->start_data = current->mm->start_data; - dump->start_stack = regs->regs[15] & ~(PAGE_SIZE - 1); - dump->u_tsize = (current->mm->end_code - dump->start_code) >> PAGE_SHIFT; - dump->u_dsize = (current->mm->brk + (PAGE_SIZE-1) - dump->start_data) >> PAGE_SHIFT; - dump->u_ssize = (current->mm->start_stack - dump->start_stack + - PAGE_SIZE - 1) >> PAGE_SHIFT; - /* Debug registers will come here. */ - - dump->regs = *regs; - - dump->u_fpvalid = dump_fpu(regs, &dump->fpu); -} - asmlinkage int sys_fork(unsigned long r2, unsigned long r3, unsigned long r4, unsigned long r5, unsigned long r6, unsigned long r7, diff --git a/trunk/arch/sh64/kernel/sh_ksyms.c b/trunk/arch/sh64/kernel/sh_ksyms.c index 0b5497d70bd3..472b450e61be 100644 --- a/trunk/arch/sh64/kernel/sh_ksyms.c +++ b/trunk/arch/sh64/kernel/sh_ksyms.c @@ -29,7 +29,6 @@ #include #include -extern void dump_thread(struct pt_regs *, struct user *); extern int dump_fpu(struct pt_regs *, elf_fpregset_t *); #if 0 @@ -41,7 +40,6 @@ EXPORT_SYMBOL(drive_info); #endif /* platform dependent support */ -EXPORT_SYMBOL(dump_thread); EXPORT_SYMBOL(dump_fpu); EXPORT_SYMBOL(iounmap); EXPORT_SYMBOL(enable_irq); diff --git a/trunk/arch/sparc/kernel/sparc_ksyms.c b/trunk/arch/sparc/kernel/sparc_ksyms.c index 1c8fd0fd9305..0b0d492c953b 100644 --- a/trunk/arch/sparc/kernel/sparc_ksyms.c +++ b/trunk/arch/sparc/kernel/sparc_ksyms.c @@ -82,8 +82,6 @@ extern int __lshrdi3(int, int); extern int __muldi3(int, int); extern int __divdi3(int, int); -extern void dump_thread(struct pt_regs *, struct user *); - /* Private functions with odd calling conventions. */ extern void ___atomic24_add(void); extern void ___atomic24_sub(void); diff --git a/trunk/arch/sparc64/kernel/Makefile b/trunk/arch/sparc64/kernel/Makefile index 6f00ab8b9d23..83d67eb18895 100644 --- a/trunk/arch/sparc64/kernel/Makefile +++ b/trunk/arch/sparc64/kernel/Makefile @@ -16,7 +16,7 @@ obj-y := process.o setup.o cpu.o idprom.o \ obj-$(CONFIG_PCI) += ebus.o isa.o pci_common.o pci_iommu.o \ pci_psycho.o pci_sabre.o pci_schizo.o obj-$(CONFIG_SMP) += smp.o trampoline.o -obj-$(CONFIG_SPARC32_COMPAT) += sys32.o sys_sparc32.o signal32.o ioctl32.o +obj-$(CONFIG_SPARC32_COMPAT) += sys32.o sys_sparc32.o signal32.o obj-$(CONFIG_BINFMT_ELF32) += binfmt_elf32.o obj-$(CONFIG_BINFMT_AOUT32) += binfmt_aout32.o obj-$(CONFIG_MODULES) += module.o @@ -40,5 +40,3 @@ endif head.o: head.S ttable.S itlb_base.S dtlb_base.S dtlb_backend.S dtlb_prot.S \ etrap.S rtrap.S winfixup.S entry.S - -CFLAGS_ioctl32.o += -Ifs/ diff --git a/trunk/arch/sparc64/kernel/binfmt_aout32.c b/trunk/arch/sparc64/kernel/binfmt_aout32.c index edf52d06b280..202a80c24b6f 100644 --- a/trunk/arch/sparc64/kernel/binfmt_aout32.c +++ b/trunk/arch/sparc64/kernel/binfmt_aout32.c @@ -36,8 +36,6 @@ static int load_aout32_binary(struct linux_binprm *, struct pt_regs * regs); static int load_aout32_library(struct file*); static int aout32_core_dump(long signr, struct pt_regs * regs, struct file *file); -extern void dump_thread(struct pt_regs *, struct user *); - static struct linux_binfmt aout32_format = { NULL, THIS_MODULE, load_aout32_binary, load_aout32_library, aout32_core_dump, PAGE_SIZE diff --git a/trunk/arch/sparc64/kernel/ioctl32.c b/trunk/arch/sparc64/kernel/ioctl32.c deleted file mode 100644 index 196b208665a2..000000000000 --- a/trunk/arch/sparc64/kernel/ioctl32.c +++ /dev/null @@ -1,39 +0,0 @@ -/* $Id: ioctl32.c,v 1.136 2002/01/14 09:49:52 davem Exp $ - * ioctl32.c: Conversion between 32bit and 64bit native ioctls. - * - * Copyright (C) 1997-2000 Jakub Jelinek (jakub@redhat.com) - * Copyright (C) 1998 Eddie C. Dost (ecd@skynet.be) - * Copyright (C) 2003 Pavel Machek (pavel@suse.cz) - * - * These routines maintain argument size conversion between 32bit and 64bit - * ioctls. - */ - -#define INCLUDES -#include "compat_ioctl.c" -#include - -#define CODE -#include "compat_ioctl.c" - -#define COMPATIBLE_IOCTL(cmd) HANDLE_IOCTL((cmd),sys_ioctl) -#define HANDLE_IOCTL(cmd,handler) { (cmd), (ioctl_trans_handler_t)(handler), NULL }, -#define IOCTL_TABLE_START \ - struct ioctl_trans ioctl_start[] = { -#define IOCTL_TABLE_END \ - }; - -IOCTL_TABLE_START -#include -#define DECLARES -#include "compat_ioctl.c" -#if 0 -HANDLE_IOCTL(RTC32_IRQP_READ, do_rtc_ioctl) -HANDLE_IOCTL(RTC32_IRQP_SET, do_rtc_ioctl) -HANDLE_IOCTL(RTC32_EPOCH_READ, do_rtc_ioctl) -HANDLE_IOCTL(RTC32_EPOCH_SET, do_rtc_ioctl) -#endif -/* take care of sizeof(sizeof()) breakage */ -IOCTL_TABLE_END - -int ioctl_table_size = ARRAY_SIZE(ioctl_start); diff --git a/trunk/arch/sparc64/kernel/kprobes.c b/trunk/arch/sparc64/kernel/kprobes.c index a97b0f0727ab..ff5e9d5cad50 100644 --- a/trunk/arch/sparc64/kernel/kprobes.c +++ b/trunk/arch/sparc64/kernel/kprobes.c @@ -42,15 +42,11 @@ DEFINE_PER_CPU(struct kprobe *, current_kprobe) = NULL; DEFINE_PER_CPU(struct kprobe_ctlblk, kprobe_ctlblk); int __kprobes arch_prepare_kprobe(struct kprobe *p) -{ - return 0; -} - -void __kprobes arch_copy_kprobe(struct kprobe *p) { p->ainsn.insn[0] = *p->addr; p->ainsn.insn[1] = BREAKPOINT_INSTRUCTION_2; p->opcode = *p->addr; + return 0; } void __kprobes arch_arm_kprobe(struct kprobe *p) @@ -65,10 +61,6 @@ void __kprobes arch_disarm_kprobe(struct kprobe *p) flushi(p->addr); } -void __kprobes arch_remove_kprobe(struct kprobe *p) -{ -} - static inline void save_previous_kprobe(struct kprobe_ctlblk *kcb) { kcb->prev_kprobe.kp = kprobe_running(); diff --git a/trunk/arch/sparc64/kernel/sparc64_ksyms.c b/trunk/arch/sparc64/kernel/sparc64_ksyms.c index fb7a5370dbfc..d177d7e5c9d3 100644 --- a/trunk/arch/sparc64/kernel/sparc64_ksyms.c +++ b/trunk/arch/sparc64/kernel/sparc64_ksyms.c @@ -94,7 +94,6 @@ extern void (*prom_palette)(int); extern int __ashrdi3(int, int); -extern void dump_thread(struct pt_regs *, struct user *); extern int dump_fpu (struct pt_regs * regs, elf_fpregset_t * fpregs); extern unsigned long phys_base; @@ -241,7 +240,6 @@ EXPORT_SYMBOL(io_remap_pfn_range); EXPORT_SYMBOL(_sigpause_common); EXPORT_SYMBOL(verify_compat_iovec); -EXPORT_SYMBOL(dump_thread); EXPORT_SYMBOL(dump_fpu); EXPORT_SYMBOL(pte_alloc_one_kernel); #ifndef CONFIG_SMP diff --git a/trunk/arch/sparc64/kernel/sys_sparc32.c b/trunk/arch/sparc64/kernel/sys_sparc32.c index 7f6239ed2521..de342ee3116b 100644 --- a/trunk/arch/sparc64/kernel/sys_sparc32.c +++ b/trunk/arch/sparc64/kernel/sys_sparc32.c @@ -1120,39 +1120,3 @@ long sys32_lookup_dcookie(unsigned long cookie_high, return sys_lookup_dcookie((cookie_high << 32) | cookie_low, buf, len); } - -extern asmlinkage long -sys_timer_create(clockid_t which_clock, - struct sigevent __user *timer_event_spec, - timer_t __user *created_timer_id); - -long -sys32_timer_create(u32 clock, struct compat_sigevent __user *se32, - timer_t __user *timer_id) -{ - struct sigevent se; - mm_segment_t oldfs; - timer_t t; - long err; - - if (se32 == NULL) - return sys_timer_create(clock, NULL, timer_id); - - if (get_compat_sigevent(&se, se32)) - return -EFAULT; - - if (!access_ok(VERIFY_WRITE,timer_id,sizeof(timer_t))) - return -EFAULT; - - oldfs = get_fs(); - set_fs(KERNEL_DS); - err = sys_timer_create(clock, - (struct sigevent __user *) &se, - (timer_t __user *) &t); - set_fs(oldfs); - - if (!err) - err = __put_user (t, timer_id); - - return err; -} diff --git a/trunk/arch/sparc64/kernel/systbls.S b/trunk/arch/sparc64/kernel/systbls.S index 53eaf2345fe9..98d24bc00044 100644 --- a/trunk/arch/sparc64/kernel/systbls.S +++ b/trunk/arch/sparc64/kernel/systbls.S @@ -73,7 +73,7 @@ sys_call_table32: /*250*/ .word sys32_mremap, sys32_sysctl, sys32_getsid, sys_fdatasync, sys32_nfsservctl .word sys_ni_syscall, sys32_clock_settime, compat_sys_clock_gettime, compat_sys_clock_getres, sys32_clock_nanosleep /*260*/ .word compat_sys_sched_getaffinity, compat_sys_sched_setaffinity, sys32_timer_settime, compat_sys_timer_gettime, sys_timer_getoverrun - .word sys_timer_delete, sys32_timer_create, sys_ni_syscall, compat_sys_io_setup, sys_io_destroy + .word sys_timer_delete, compat_sys_timer_create, sys_ni_syscall, compat_sys_io_setup, sys_io_destroy /*270*/ .word sys32_io_submit, sys_io_cancel, compat_sys_io_getevents, sys32_mq_open, sys_mq_unlink .word compat_sys_mq_timedsend, compat_sys_mq_timedreceive, compat_sys_mq_notify, compat_sys_mq_getsetattr, compat_sys_waitid /*280*/ .word sys_ni_syscall, sys_add_key, sys_request_key, sys_keyctl @@ -98,7 +98,7 @@ sys_call_table: .word sys_umount, sys_setgid, sys_getgid, sys_signal, sys_geteuid /*50*/ .word sys_getegid, sys_acct, sys_memory_ordering, sys_nis_syscall, sys_ioctl .word sys_reboot, sys_nis_syscall, sys_symlink, sys_readlink, sys_execve -/*60*/ .word sys_umask, sys_chroot, sys_newfstat, sys_stat64, sys_getpagesize +/*60*/ .word sys_umask, sys_chroot, sys_newfstat, sys_fstat64, sys_getpagesize .word sys_msync, sys_vfork, sys_pread64, sys_pwrite64, sys_nis_syscall /*70*/ .word sys_nis_syscall, sys_mmap, sys_nis_syscall, sys64_munmap, sys_mprotect .word sys_madvise, sys_vhangup, sys_nis_syscall, sys_mincore, sys_getgroups diff --git a/trunk/arch/um/drivers/chan_kern.c b/trunk/arch/um/drivers/chan_kern.c index cd13b91b9ff6..ab0d0b170816 100644 --- a/trunk/arch/um/drivers/chan_kern.c +++ b/trunk/arch/um/drivers/chan_kern.c @@ -186,9 +186,6 @@ static void tty_receive_char(struct tty_struct *tty, char ch) } } - if((tty->flip.flag_buf_ptr == NULL) || - (tty->flip.char_buf_ptr == NULL)) - return; tty_insert_flip_char(tty, ch, TTY_NORMAL); } @@ -653,8 +650,7 @@ void chan_interrupt(struct list_head *chans, struct work_struct *task, chan = list_entry(ele, struct chan, list); if(!chan->input || (chan->ops->read == NULL)) continue; do { - if((tty != NULL) && - (tty->flip.count >= TTY_FLIPBUF_SIZE)){ + if (tty && !tty_buffer_request_room(tty, 1)) { schedule_delayed_work(task, 1); goto out; } diff --git a/trunk/arch/um/kernel/time.c b/trunk/arch/um/kernel/time.c index 11f518a7e156..8fa2ae7f3026 100644 --- a/trunk/arch/um/kernel/time.c +++ b/trunk/arch/um/kernel/time.c @@ -99,7 +99,8 @@ void uml_idle_timer(void) set_interval(ITIMER_REAL); } -extern int do_posix_clock_monotonic_gettime(struct timespec *tp); +extern void ktime_get_ts(struct timespec *ts); +#define do_posix_clock_monotonic_gettime(ts) ktime_get_ts(ts) void time_init(void) { @@ -114,8 +115,8 @@ void time_init(void) wall_to_monotonic.tv_nsec = -now.tv_nsec; } -/* Declared in linux/time.h, which can't be included here */ -extern void clock_was_set(void); +/* Defined in linux/ktimer.h, which can't be included here */ +#define clock_was_set() do { } while (0) void do_gettimeofday(struct timeval *tv) { diff --git a/trunk/arch/v850/kernel/process.c b/trunk/arch/v850/kernel/process.c index 39cf247cdae4..062ffa0a9998 100644 --- a/trunk/arch/v850/kernel/process.c +++ b/trunk/arch/v850/kernel/process.c @@ -163,30 +163,6 @@ int copy_thread (int nr, unsigned long clone_flags, return 0; } -/* - * fill in the user structure for a core dump.. - */ -void dump_thread (struct pt_regs *regs, struct user *dump) -{ -#if 0 /* Later. XXX */ - dump->magic = CMAGIC; - dump->start_code = 0; - dump->start_stack = regs->gpr[GPR_SP]; - dump->u_tsize = ((unsigned long) current->mm->end_code) >> PAGE_SHIFT; - dump->u_dsize = ((unsigned long) (current->mm->brk + - (PAGE_SIZE-1))) >> PAGE_SHIFT; - dump->u_dsize -= dump->u_tsize; - dump->u_ssize = 0; - - if (dump->start_stack < TASK_SIZE) - dump->u_ssize = ((unsigned long) (TASK_SIZE - dump->start_stack)) >> PAGE_SHIFT; - - dump->u_ar0 = (struct user_regs_struct *)((int)&dump->regs - (int)dump); - dump->regs = *regs; - dump->u_fpvalid = 0; -#endif -} - /* * sys_execve() executes a new program. */ diff --git a/trunk/arch/v850/kernel/v850_ksyms.c b/trunk/arch/v850/kernel/v850_ksyms.c index 0ca64900dd91..8ffc29c1c89d 100644 --- a/trunk/arch/v850/kernel/v850_ksyms.c +++ b/trunk/arch/v850/kernel/v850_ksyms.c @@ -21,8 +21,6 @@ extern void *trap_table; EXPORT_SYMBOL (trap_table); /* platform dependent support */ -extern void dump_thread (struct pt_regs *, struct user *); -EXPORT_SYMBOL (dump_thread); EXPORT_SYMBOL (kernel_thread); EXPORT_SYMBOL (enable_irq); EXPORT_SYMBOL (disable_irq); diff --git a/trunk/arch/x86_64/Kconfig b/trunk/arch/x86_64/Kconfig index 4f3e925962c3..348b4a0d0d6f 100644 --- a/trunk/arch/x86_64/Kconfig +++ b/trunk/arch/x86_64/Kconfig @@ -399,17 +399,6 @@ config X86_MCE_AMD Additional support for AMD specific MCE features such as the DRAM Error Threshold. -config PHYSICAL_START - hex "Physical address where the kernel is loaded" if EMBEDDED - default "0x100000" - help - This gives the physical address where the kernel is loaded. - Primarily used in the case of kexec on panic where the - fail safe kernel needs to run at a different address than - the panic-ed kernel. - - Don't change this unless you know what you are doing. - config KEXEC bool "kexec system call (EXPERIMENTAL)" depends on EXPERIMENTAL @@ -427,6 +416,31 @@ config KEXEC support. As of this writing the exact hardware interface is strongly in flux, so no good recommendation can be made. +config CRASH_DUMP + bool "kernel crash dumps (EXPERIMENTAL)" + depends on EXPERIMENTAL + help + Generate crash dump after being started by kexec. + +config PHYSICAL_START + hex "Physical address where the kernel is loaded" if (EMBEDDED || CRASH_DUMP) + default "0x1000000" if CRASH_DUMP + default "0x100000" + help + This gives the physical address where the kernel is loaded. Normally + for regular kernels this value is 0x100000 (1MB). But in the case + of kexec on panic the fail safe kernel needs to run at a different + address than the panic-ed kernel. This option is used to set the load + address for kernels used to capture crash dump on being kexec'ed + after panic. The default value for crash dump kernels is + 0x1000000 (16MB). This can also be set based on the "X" value as + specified in the "crashkernel=YM@XM" command line boot parameter + passed to the panic-ed kernel. Typically this parameter is set as + crashkernel=64M@16M. Please take a look at + Documentation/kdump/kdump.txt for more details about crash dumps. + + Don't change this unless you know what you are doing. + config SECCOMP bool "Enable seccomp to safely compute untrusted bytecode" depends on PROC_FS diff --git a/trunk/arch/x86_64/Makefile b/trunk/arch/x86_64/Makefile index a9cd42e61828..51d83288d62b 100644 --- a/trunk/arch/x86_64/Makefile +++ b/trunk/arch/x86_64/Makefile @@ -80,9 +80,12 @@ bzlilo: vmlinux bzdisk: vmlinux $(Q)$(MAKE) $(build)=$(boot) BOOTIMAGE=$(BOOTIMAGE) zdisk -install fdimage fdimage144 fdimage288: vmlinux +fdimage fdimage144 fdimage288: vmlinux $(Q)$(MAKE) $(build)=$(boot) BOOTIMAGE=$(BOOTIMAGE) $@ +install: + $(Q)$(MAKE) $(build)=$(boot) BOOTIMAGE=$(BOOTIMAGE) $@ + archclean: $(Q)$(MAKE) $(clean)=$(boot) diff --git a/trunk/arch/x86_64/boot/Makefile b/trunk/arch/x86_64/boot/Makefile index 18c6e915d69b..29f8396ed151 100644 --- a/trunk/arch/x86_64/boot/Makefile +++ b/trunk/arch/x86_64/boot/Makefile @@ -98,5 +98,5 @@ zlilo: $(BOOTIMAGE) cp System.map $(INSTALL_PATH)/ if [ -x /sbin/lilo ]; then /sbin/lilo; else /etc/lilo/install; fi -install: $(BOOTIMAGE) +install: sh $(srctree)/$(src)/install.sh $(KERNELRELEASE) $(BOOTIMAGE) System.map "$(INSTALL_PATH)" diff --git a/trunk/arch/x86_64/boot/install.sh b/trunk/arch/x86_64/boot/install.sh index 198af15a7758..baaa2369bdb8 100644 --- a/trunk/arch/x86_64/boot/install.sh +++ b/trunk/arch/x86_64/boot/install.sh @@ -1,40 +1,2 @@ #!/bin/sh -# -# arch/x86_64/boot/install.sh -# -# This file is subject to the terms and conditions of the GNU General Public -# License. See the file "COPYING" in the main directory of this archive -# for more details. -# -# Copyright (C) 1995 by Linus Torvalds -# -# Adapted from code in arch/i386/boot/Makefile by H. Peter Anvin -# -# "make install" script for i386 architecture -# -# Arguments: -# $1 - kernel version -# $2 - kernel image file -# $3 - kernel map file -# $4 - default install path (blank if root directory) -# - -# User may have a custom install script - -if [ -x ~/bin/${CROSS_COMPILE}installkernel ]; then exec ~/bin/${CROSS_COMPILE}installkernel "$@"; fi -if [ -x /sbin/${CROSS_COMPILE}installkernel ]; then exec /sbin/${CROSS_COMPILE}installkernel "$@"; fi - -# Default install - same as make zlilo - -if [ -f $4/vmlinuz ]; then - mv $4/vmlinuz $4/vmlinuz.old -fi - -if [ -f $4/System.map ]; then - mv $4/System.map $4/System.old -fi - -cat $2 > $4/vmlinuz -cp $3 $4/System.map - -if [ -x /sbin/lilo ]; then /sbin/lilo; else /etc/lilo/install; fi +. $srctree/arch/i386/boot/install.sh diff --git a/trunk/arch/x86_64/ia32/Makefile b/trunk/arch/x86_64/ia32/Makefile index f76217d8f579..051608d55920 100644 --- a/trunk/arch/x86_64/ia32/Makefile +++ b/trunk/arch/x86_64/ia32/Makefile @@ -2,8 +2,7 @@ # Makefile for the ia32 kernel emulation subsystem. # -obj-$(CONFIG_IA32_EMULATION) := ia32entry.o sys_ia32.o ia32_ioctl.o \ - ia32_signal.o tls32.o \ +obj-$(CONFIG_IA32_EMULATION) := ia32entry.o sys_ia32.o ia32_signal.o tls32.o \ ia32_binfmt.o fpu32.o ptrace32.o syscall32.o syscall32_syscall.o sysv-$(CONFIG_SYSVIPC) := ipc32.o @@ -29,4 +28,3 @@ $(obj)/vsyscall-%.so: $(src)/vsyscall.lds $(obj)/vsyscall-%.o FORCE AFLAGS_vsyscall-sysenter.o = -m32 AFLAGS_vsyscall-syscall.o = -m32 -CFLAGS_ia32_ioctl.o += -Ifs/ diff --git a/trunk/arch/x86_64/ia32/ia32_ioctl.c b/trunk/arch/x86_64/ia32/ia32_ioctl.c deleted file mode 100644 index e335bd0b637d..000000000000 --- a/trunk/arch/x86_64/ia32/ia32_ioctl.c +++ /dev/null @@ -1,79 +0,0 @@ -/* $Id: ia32_ioctl.c,v 1.25 2002/10/11 07:17:06 ak Exp $ - * ioctl32.c: Conversion between 32bit and 64bit native ioctls. - * - * Copyright (C) 1997-2000 Jakub Jelinek (jakub@redhat.com) - * Copyright (C) 1998 Eddie C. Dost (ecd@skynet.be) - * Copyright (C) 2001,2002 Andi Kleen, SuSE Labs - * - * These routines maintain argument size conversion between 32bit and 64bit - * ioctls. - */ - -#define INCLUDES -#include -#include "compat_ioctl.c" -#include - -#define CODE -#include "compat_ioctl.c" - -#define RTC_IRQP_READ32 _IOR('p', 0x0b, unsigned int) /* Read IRQ rate */ -#define RTC_IRQP_SET32 _IOW('p', 0x0c, unsigned int) /* Set IRQ rate */ -#define RTC_EPOCH_READ32 _IOR('p', 0x0d, unsigned) /* Read epoch */ -#define RTC_EPOCH_SET32 _IOW('p', 0x0e, unsigned) /* Set epoch */ - -static int rtc32_ioctl(unsigned fd, unsigned cmd, unsigned long arg) -{ - unsigned long val; - mm_segment_t oldfs = get_fs(); - int ret; - - switch (cmd) { - case RTC_IRQP_READ32: - set_fs(KERNEL_DS); - ret = sys_ioctl(fd, RTC_IRQP_READ, (unsigned long)&val); - set_fs(oldfs); - if (!ret) - ret = put_user(val, (unsigned int __user *) arg); - return ret; - - case RTC_IRQP_SET32: - cmd = RTC_IRQP_SET; - break; - - case RTC_EPOCH_READ32: - set_fs(KERNEL_DS); - ret = sys_ioctl(fd, RTC_EPOCH_READ, (unsigned long) &val); - set_fs(oldfs); - if (!ret) - ret = put_user(val, (unsigned int __user *) arg); - return ret; - - case RTC_EPOCH_SET32: - cmd = RTC_EPOCH_SET; - break; - } - return sys_ioctl(fd,cmd,arg); -} - - -#define HANDLE_IOCTL(cmd,handler) { (cmd), (ioctl_trans_handler_t)(handler) }, -#define COMPATIBLE_IOCTL(cmd) HANDLE_IOCTL(cmd,sys_ioctl) - -struct ioctl_trans ioctl_start[] = { -#include -#define DECLARES -#include "compat_ioctl.c" - -/* And these ioctls need translation */ -/* realtime device */ -HANDLE_IOCTL(RTC_IRQP_READ, rtc32_ioctl) -HANDLE_IOCTL(RTC_IRQP_READ32,rtc32_ioctl) -HANDLE_IOCTL(RTC_IRQP_SET32, rtc32_ioctl) -HANDLE_IOCTL(RTC_EPOCH_READ32, rtc32_ioctl) -HANDLE_IOCTL(RTC_EPOCH_SET32, rtc32_ioctl) -/* take care of sizeof(sizeof()) breakage */ -}; - -int ioctl_table_size = ARRAY_SIZE(ioctl_start); - diff --git a/trunk/arch/x86_64/ia32/ia32entry.S b/trunk/arch/x86_64/ia32/ia32entry.S index 1f0ff5adc80e..2ff07b47ea9c 100644 --- a/trunk/arch/x86_64/ia32/ia32entry.S +++ b/trunk/arch/x86_64/ia32/ia32entry.S @@ -608,7 +608,7 @@ ia32_sys_call_table: .quad sys_epoll_wait .quad sys_remap_file_pages .quad sys_set_tid_address - .quad sys32_timer_create + .quad compat_sys_timer_create .quad compat_sys_timer_settime /* 260 */ .quad compat_sys_timer_gettime .quad sys_timer_getoverrun diff --git a/trunk/arch/x86_64/ia32/sys_ia32.c b/trunk/arch/x86_64/ia32/sys_ia32.c index 5389df610e78..54481af5344a 100644 --- a/trunk/arch/x86_64/ia32/sys_ia32.c +++ b/trunk/arch/x86_64/ia32/sys_ia32.c @@ -969,25 +969,6 @@ long sys32_kill(int pid, int sig) return sys_kill(pid, sig); } -extern asmlinkage long -sys_timer_create(clockid_t which_clock, - struct sigevent __user *timer_event_spec, - timer_t __user * created_timer_id); - -long -sys32_timer_create(u32 clock, struct compat_sigevent __user *se32, timer_t __user *timer_id) -{ - struct sigevent __user *p = NULL; - if (se32) { - struct sigevent se; - p = compat_alloc_user_space(sizeof(struct sigevent)); - if (get_compat_sigevent(&se, se32) || - copy_to_user(p, &se, sizeof(se))) - return -EFAULT; - } - return sys_timer_create(clock, p, timer_id); -} - long sys32_fadvise64_64(int fd, __u32 offset_low, __u32 offset_high, __u32 len_low, __u32 len_high, int advice) { diff --git a/trunk/arch/x86_64/kernel/Makefile b/trunk/arch/x86_64/kernel/Makefile index fe4cbd1c4b2f..12bc54005e2f 100644 --- a/trunk/arch/x86_64/kernel/Makefile +++ b/trunk/arch/x86_64/kernel/Makefile @@ -22,6 +22,7 @@ obj-$(CONFIG_X86_LOCAL_APIC) += apic.o nmi.o obj-$(CONFIG_X86_IO_APIC) += io_apic.o mpparse.o \ genapic.o genapic_cluster.o genapic_flat.o obj-$(CONFIG_KEXEC) += machine_kexec.o relocate_kernel.o crash.o +obj-$(CONFIG_CRASH_DUMP) += crash_dump.o obj-$(CONFIG_PM) += suspend.o obj-$(CONFIG_SOFTWARE_SUSPEND) += suspend_asm.o obj-$(CONFIG_CPU_FREQ) += cpufreq/ diff --git a/trunk/arch/x86_64/kernel/crash.c b/trunk/arch/x86_64/kernel/crash.c index 535e04466079..4e6c3b729e39 100644 --- a/trunk/arch/x86_64/kernel/crash.c +++ b/trunk/arch/x86_64/kernel/crash.c @@ -11,19 +11,156 @@ #include #include #include +#include #include #include +#include +#include +#include #include #include #include #include +#include -note_buf_t crash_notes[NR_CPUS]; +/* This keeps a track of which one is crashing cpu. */ +static int crashing_cpu; + +static u32 *append_elf_note(u32 *buf, char *name, unsigned type, + void *data, size_t data_len) +{ + struct elf_note note; + + note.n_namesz = strlen(name) + 1; + note.n_descsz = data_len; + note.n_type = type; + memcpy(buf, ¬e, sizeof(note)); + buf += (sizeof(note) +3)/4; + memcpy(buf, name, note.n_namesz); + buf += (note.n_namesz + 3)/4; + memcpy(buf, data, note.n_descsz); + buf += (note.n_descsz + 3)/4; + + return buf; +} + +static void final_note(u32 *buf) +{ + struct elf_note note; + + note.n_namesz = 0; + note.n_descsz = 0; + note.n_type = 0; + memcpy(buf, ¬e, sizeof(note)); +} + +static void crash_save_this_cpu(struct pt_regs *regs, int cpu) +{ + struct elf_prstatus prstatus; + u32 *buf; + + if ((cpu < 0) || (cpu >= NR_CPUS)) + return; + + /* Using ELF notes here is opportunistic. + * I need a well defined structure format + * for the data I pass, and I need tags + * on the data to indicate what information I have + * squirrelled away. ELF notes happen to provide + * all of that that no need to invent something new. + */ + + buf = (u32*)per_cpu_ptr(crash_notes, cpu); + + if (!buf) + return; + + memset(&prstatus, 0, sizeof(prstatus)); + prstatus.pr_pid = current->pid; + elf_core_copy_regs(&prstatus.pr_reg, regs); + buf = append_elf_note(buf, "CORE", NT_PRSTATUS, &prstatus, + sizeof(prstatus)); + final_note(buf); +} + +static void crash_save_self(struct pt_regs *regs) +{ + int cpu; + + cpu = smp_processor_id(); + crash_save_this_cpu(regs, cpu); +} + +#ifdef CONFIG_SMP +static atomic_t waiting_for_crash_ipi; + +static int crash_nmi_callback(struct pt_regs *regs, int cpu) +{ + /* + * Don't do anything if this handler is invoked on crashing cpu. + * Otherwise, system will completely hang. Crashing cpu can get + * an NMI if system was initially booted with nmi_watchdog parameter. + */ + if (cpu == crashing_cpu) + return 1; + local_irq_disable(); + + crash_save_this_cpu(regs, cpu); + disable_local_APIC(); + atomic_dec(&waiting_for_crash_ipi); + /* Assume hlt works */ + for(;;) + asm("hlt"); + + return 1; +} + +static void smp_send_nmi_allbutself(void) +{ + send_IPI_allbutself(APIC_DM_NMI); +} + +/* + * This code is a best effort heuristic to get the + * other cpus to stop executing. So races with + * cpu hotplug shouldn't matter. + */ + +static void nmi_shootdown_cpus(void) +{ + unsigned long msecs; + + atomic_set(&waiting_for_crash_ipi, num_online_cpus() - 1); + set_nmi_callback(crash_nmi_callback); + + /* + * Ensure the new callback function is set before sending + * out the NMI + */ + wmb(); + + smp_send_nmi_allbutself(); + + msecs = 1000; /* Wait at most a second for the other cpus to stop */ + while ((atomic_read(&waiting_for_crash_ipi) > 0) && msecs) { + mdelay(1); + msecs--; + } + /* Leave the nmi callback set */ + disable_local_APIC(); +} +#else +static void nmi_shootdown_cpus(void) +{ + /* There are no cpus to shootdown */ +} +#endif void machine_crash_shutdown(struct pt_regs *regs) { - /* This function is only called after the system + /* + * This function is only called after the system * has paniced or is otherwise in a critical state. * The minimum amount of code to allow a kexec'd kernel * to run successfully needs to happen here. @@ -31,4 +168,19 @@ void machine_crash_shutdown(struct pt_regs *regs) * In practice this means shooting down the other cpus in * an SMP system. */ + /* The kernel is broken so disable interrupts */ + local_irq_disable(); + + /* Make a note of crashing cpu. Will be used in NMI callback.*/ + crashing_cpu = smp_processor_id(); + nmi_shootdown_cpus(); + + if(cpu_has_apic) + disable_local_APIC(); + +#if defined(CONFIG_X86_IO_APIC) + disable_IO_APIC(); +#endif + + crash_save_self(regs); } diff --git a/trunk/kernel/crash_dump.c b/trunk/arch/x86_64/kernel/crash_dump.c similarity index 60% rename from trunk/kernel/crash_dump.c rename to trunk/arch/x86_64/kernel/crash_dump.c index fccb27dbc623..942deac4d43a 100644 --- a/trunk/kernel/crash_dump.c +++ b/trunk/arch/x86_64/kernel/crash_dump.c @@ -5,21 +5,12 @@ * Copyright (C) IBM Corporation, 2004. All rights reserved */ -#include #include -#include -#include -#include #include -#include #include -#include - -/* Stores the physical address of elf header of crash image. */ -unsigned long long elfcorehdr_addr = ELFCORE_ADDR_MAX; +#include -#ifndef HAVE_ARCH_COPY_OLDMEM_PAGE /** * copy_oldmem_page - copy one page from "oldmem" * @pfn: page frame number to be copied @@ -34,31 +25,23 @@ unsigned long long elfcorehdr_addr = ELFCORE_ADDR_MAX; * in the current kernel. We stitch up a pte, similar to kmap_atomic. */ ssize_t copy_oldmem_page(unsigned long pfn, char *buf, - size_t csize, unsigned long offset, int userbuf) + size_t csize, unsigned long offset, int userbuf) { - void *page, *vaddr; + void *vaddr; if (!csize) return 0; - page = kmalloc(PAGE_SIZE, GFP_KERNEL); - if (!page) - return -ENOMEM; - - vaddr = kmap_atomic_pfn(pfn, KM_PTE0); - copy_page(page, vaddr); - kunmap_atomic(vaddr, KM_PTE0); + vaddr = ioremap(pfn << PAGE_SHIFT, PAGE_SIZE); if (userbuf) { - if (copy_to_user(buf, (page + offset), csize)) { - kfree(page); + if (copy_to_user(buf, (vaddr + offset), csize)) { + iounmap(vaddr); return -EFAULT; } - } else { - memcpy(buf, (page + offset), csize); - } + } else + memcpy(buf, (vaddr + offset), csize); - kfree(page); + iounmap(vaddr); return csize; } -#endif diff --git a/trunk/arch/x86_64/kernel/e820.c b/trunk/arch/x86_64/kernel/e820.c index 17579a1a174b..293cd71a266a 100644 --- a/trunk/arch/x86_64/kernel/e820.c +++ b/trunk/arch/x86_64/kernel/e820.c @@ -559,6 +559,27 @@ void __init parse_memopt(char *p, char **from) end_user_pfn >>= PAGE_SHIFT; } +void __init parse_memmapopt(char *p, char **from) +{ + unsigned long long start_at, mem_size; + + mem_size = memparse(p, from); + p = *from; + if (*p == '@') { + start_at = memparse(p+1, from); + add_memory_region(start_at, mem_size, E820_RAM); + } else if (*p == '#') { + start_at = memparse(p+1, from); + add_memory_region(start_at, mem_size, E820_ACPI); + } else if (*p == '$') { + start_at = memparse(p+1, from); + add_memory_region(start_at, mem_size, E820_RESERVED); + } else { + end_user_pfn = (mem_size >> PAGE_SHIFT); + } + p = *from; +} + unsigned long pci_mem_start = 0xaeedbabe; /* diff --git a/trunk/arch/x86_64/kernel/kprobes.c b/trunk/arch/x86_64/kernel/kprobes.c index afe11f4fbd1d..b7dc1f816d13 100644 --- a/trunk/arch/x86_64/kernel/kprobes.c +++ b/trunk/arch/x86_64/kernel/kprobes.c @@ -42,8 +42,8 @@ #include #include -static DECLARE_MUTEX(kprobe_mutex); void jprobe_return_end(void); +static void __kprobes arch_copy_kprobe(struct kprobe *p); DEFINE_PER_CPU(struct kprobe *, current_kprobe) = NULL; DEFINE_PER_CPU(struct kprobe_ctlblk, kprobe_ctlblk); @@ -69,12 +69,11 @@ static inline int is_IF_modifier(kprobe_opcode_t *insn) int __kprobes arch_prepare_kprobe(struct kprobe *p) { /* insn: must be on special executable page on x86_64. */ - down(&kprobe_mutex); p->ainsn.insn = get_insn_slot(); - up(&kprobe_mutex); if (!p->ainsn.insn) { return -ENOMEM; } + arch_copy_kprobe(p); return 0; } @@ -181,7 +180,7 @@ static inline s32 *is_riprel(u8 *insn) return NULL; } -void __kprobes arch_copy_kprobe(struct kprobe *p) +static void __kprobes arch_copy_kprobe(struct kprobe *p) { s32 *ripdisp; memcpy(p->ainsn.insn, p->addr, MAX_INSN_SIZE); diff --git a/trunk/arch/x86_64/kernel/setup.c b/trunk/arch/x86_64/kernel/setup.c index 64c4534b930c..a0e0c9ca8f10 100644 --- a/trunk/arch/x86_64/kernel/setup.c +++ b/trunk/arch/x86_64/kernel/setup.c @@ -35,6 +35,7 @@ #include #include #include +#include #include #include #include @@ -275,6 +276,7 @@ static __init void parse_cmdline_early (char ** cmdline_p) { char c = ' ', *to = command_line, *from = COMMAND_LINE; int len = 0; + int userdef = 0; /* Save unparsed command line copy for /proc/cmdline */ memcpy(saved_command_line, COMMAND_LINE, COMMAND_LINE_SIZE); @@ -357,6 +359,28 @@ static __init void parse_cmdline_early (char ** cmdline_p) if (!memcmp(from, "mem=", 4)) parse_memopt(from+4, &from); + if (!memcmp(from, "memmap=", 7)) { + /* exactmap option is for used defined memory */ + if (!memcmp(from+7, "exactmap", 8)) { +#ifdef CONFIG_CRASH_DUMP + /* If we are doing a crash dump, we + * still need to know the real mem + * size before original memory map is + * reset. + */ + saved_max_pfn = e820_end_of_ram(); +#endif + from += 8+7; + end_pfn_map = 0; + e820.nr_map = 0; + userdef = 1; + } + else { + parse_memmapopt(from+7, &from); + userdef = 1; + } + } + #ifdef CONFIG_NUMA if (!memcmp(from, "numa=", 5)) numa_setup(from+5); @@ -395,6 +419,14 @@ static __init void parse_cmdline_early (char ** cmdline_p) } #endif +#ifdef CONFIG_PROC_VMCORE + /* elfcorehdr= specifies the location of elf core header + * stored by the crashed kernel. This option will be passed + * by kexec loader to the capture kernel. + */ + else if(!memcmp(from, "elfcorehdr=", 11)) + elfcorehdr_addr = memparse(from+11, &from); +#endif next_char: c = *(from++); if (!c) @@ -403,6 +435,10 @@ static __init void parse_cmdline_early (char ** cmdline_p) break; *(to++) = c; } + if (userdef) { + printk(KERN_INFO "user-defined physical RAM map:\n"); + e820_print_map("user"); + } *to = '\0'; *cmdline_p = command_line; } diff --git a/trunk/arch/x86_64/kernel/x8664_ksyms.c b/trunk/arch/x86_64/kernel/x8664_ksyms.c index 4a54221e10bc..b7fd6681c629 100644 --- a/trunk/arch/x86_64/kernel/x8664_ksyms.c +++ b/trunk/arch/x86_64/kernel/x8664_ksyms.c @@ -13,7 +13,6 @@ #include #include #include -#include #include #include diff --git a/trunk/arch/xtensa/Kconfig b/trunk/arch/xtensa/Kconfig index 7e841aa2a4aa..7ee4a14ec3b1 100644 --- a/trunk/arch/xtensa/Kconfig +++ b/trunk/arch/xtensa/Kconfig @@ -18,10 +18,6 @@ config XTENSA with reasonable minimum requirements. The Xtensa Linux project has a home page at . -config UID16 - bool - default n - config RWSEM_XCHGADD_ALGORITHM bool default y diff --git a/trunk/drivers/base/core.c b/trunk/drivers/base/core.c index fd8059920dbf..6b355bd7816d 100644 --- a/trunk/drivers/base/core.c +++ b/trunk/drivers/base/core.c @@ -161,8 +161,8 @@ static ssize_t store_uevent(struct device *dev, struct device_attribute *attr, return count; } -/** - * device_subsys - structure to be registered with kobject core. +/* + * devices_subsys - structure to be registered with kobject core. */ decl_subsys(devices, &ktype_device, &device_uevent_ops); diff --git a/trunk/drivers/base/cpu.c b/trunk/drivers/base/cpu.c index 281d26784d25..07a7f97e1de9 100644 --- a/trunk/drivers/base/cpu.c +++ b/trunk/drivers/base/cpu.c @@ -83,6 +83,31 @@ static inline void register_cpu_control(struct cpu *cpu) } #endif /* CONFIG_HOTPLUG_CPU */ +#ifdef CONFIG_KEXEC +#include + +static ssize_t show_crash_notes(struct sys_device *dev, char *buf) +{ + struct cpu *cpu = container_of(dev, struct cpu, sysdev); + ssize_t rc; + unsigned long long addr; + int cpunum; + + cpunum = cpu->sysdev.id; + + /* + * Might be reading other cpu's data based on which cpu read thread + * has been scheduled. But cpu data (memory) is allocated once during + * boot up and this data does not change there after. Hence this + * operation should be safe. No locking required. + */ + addr = __pa(per_cpu_ptr(crash_notes, cpunum)); + rc = sprintf(buf, "%Lx\n", addr); + return rc; +} +static SYSDEV_ATTR(crash_notes, 0400, show_crash_notes, NULL); +#endif + /* * register_cpu - Setup a driverfs device for a CPU. * @cpu - Callers can set the cpu->no_control field to 1, to indicate not to @@ -108,6 +133,11 @@ int __devinit register_cpu(struct cpu *cpu, int num, struct node *root) register_cpu_control(cpu); if (!error) cpu_sys_devices[num] = &cpu->sysdev; + +#ifdef CONFIG_KEXEC + if (!error) + error = sysdev_create_file(&cpu->sysdev, &attr_crash_notes); +#endif return error; } diff --git a/trunk/drivers/bluetooth/hci_ldisc.c b/trunk/drivers/bluetooth/hci_ldisc.c index 573ff6c1be5f..613673b12fa6 100644 --- a/trunk/drivers/bluetooth/hci_ldisc.c +++ b/trunk/drivers/bluetooth/hci_ldisc.c @@ -279,6 +279,7 @@ static int hci_uart_tty_open(struct tty_struct *tty) tty->disc_data = hu; hu->tty = tty; + tty->receive_room = 65536; spin_lock_init(&hu->rx_lock); @@ -348,20 +349,6 @@ static void hci_uart_tty_wakeup(struct tty_struct *tty) hci_uart_tx_wakeup(hu); } -/* hci_uart_tty_room() - * - * Callback function from tty driver. Return the amount of - * space left in the receiver's buffer to decide if remote - * transmitter is to be throttled. - * - * Arguments: tty pointer to associated tty instance data - * Return Value: number of bytes left in receive buffer - */ -static int hci_uart_tty_room (struct tty_struct *tty) -{ - return 65536; -} - /* hci_uart_tty_receive() * * Called by tty low level driver when receive data is @@ -544,7 +531,6 @@ static int __init hci_uart_init(void) hci_uart_ldisc.write = hci_uart_tty_write; hci_uart_ldisc.ioctl = hci_uart_tty_ioctl; hci_uart_ldisc.poll = hci_uart_tty_poll; - hci_uart_ldisc.receive_room = hci_uart_tty_room; hci_uart_ldisc.receive_buf = hci_uart_tty_receive; hci_uart_ldisc.write_wakeup = hci_uart_tty_wakeup; hci_uart_ldisc.owner = THIS_MODULE; diff --git a/trunk/drivers/cdrom/cdrom.c b/trunk/drivers/cdrom/cdrom.c index 153960348414..879bbc26ce96 100644 --- a/trunk/drivers/cdrom/cdrom.c +++ b/trunk/drivers/cdrom/cdrom.c @@ -1131,7 +1131,7 @@ int open_for_data(struct cdrom_device_info * cdi) This ensures that the drive gets unlocked after a mount fails. This is a goto to avoid bloating the driver with redundant code. */ clean_up_and_return: - cdinfo(CD_WARNING, "open failed.\n"); + cdinfo(CD_OPEN, "open failed.\n"); if (CDROM_CAN(CDC_LOCK) && cdi->options & CDO_LOCK) { cdo->lock_door(cdi, 0); cdinfo(CD_OPEN, "door unlocked.\n"); diff --git a/trunk/drivers/char/Kconfig b/trunk/drivers/char/Kconfig index dd7e6901c575..d6fcd0a36f9f 100644 --- a/trunk/drivers/char/Kconfig +++ b/trunk/drivers/char/Kconfig @@ -80,7 +80,7 @@ config SERIAL_NONSTANDARD config COMPUTONE tristate "Computone IntelliPort Plus serial support" - depends on SERIAL_NONSTANDARD && BROKEN_ON_SMP + depends on SERIAL_NONSTANDARD ---help--- This driver supports the entire family of Intelliport II/Plus controllers with the exception of the MicroChannel controllers and @@ -153,7 +153,7 @@ config DIGIEPCA config ESPSERIAL tristate "Hayes ESP serial port support" - depends on SERIAL_NONSTANDARD && ISA && BROKEN_ON_SMP && ISA_DMA_API + depends on SERIAL_NONSTANDARD && ISA && ISA_DMA_API help This is a driver which supports Hayes ESP serial ports. Both single port cards and multiport cards are supported. Make sure to read @@ -166,7 +166,7 @@ config ESPSERIAL config MOXA_INTELLIO tristate "Moxa Intellio support" - depends on SERIAL_NONSTANDARD && BROKEN_ON_SMP + depends on SERIAL_NONSTANDARD help Say Y here if you have a Moxa Intellio multiport serial card. @@ -290,7 +290,7 @@ config SX config RIO tristate "Specialix RIO system support" - depends on SERIAL_NONSTANDARD && BROKEN_ON_SMP + depends on SERIAL_NONSTANDARD && BROKEN_ON_SMP && !64BIT help This is a driver for the Specialix RIO, a smart serial card which drives an outboard box that can support up to 128 ports. Product @@ -936,6 +936,15 @@ config SCx200_GPIO If compiled as a module, it will be called scx200_gpio. +config CS5535_GPIO + tristate "AMD CS5535/CS5536 GPIO (Geode Companion Device)" + depends on X86_32 + help + Give userspace access to the GPIO pins on the AMD CS5535 and + CS5536 Geode companion devices. + + If compiled as a module, it will be called cs5535_gpio. + config GPIO_VR41XX tristate "NEC VR4100 series General-purpose I/O Unit support" depends on CPU_VR41XX diff --git a/trunk/drivers/char/Makefile b/trunk/drivers/char/Makefile index d973d14d8f7f..503dd901d406 100644 --- a/trunk/drivers/char/Makefile +++ b/trunk/drivers/char/Makefile @@ -81,6 +81,7 @@ obj-$(CONFIG_PPDEV) += ppdev.o obj-$(CONFIG_NWBUTTON) += nwbutton.o obj-$(CONFIG_NWFLASH) += nwflash.o obj-$(CONFIG_SCx200_GPIO) += scx200_gpio.o +obj-$(CONFIG_CS5535_GPIO) += cs5535_gpio.o obj-$(CONFIG_GPIO_VR41XX) += vr41xx_giu.o obj-$(CONFIG_TANBAC_TB0219) += tb0219.o obj-$(CONFIG_TELCLOCK) += tlclk.o diff --git a/trunk/drivers/char/amiserial.c b/trunk/drivers/char/amiserial.c index a124f8c5d062..869518e4035f 100644 --- a/trunk/drivers/char/amiserial.c +++ b/trunk/drivers/char/amiserial.c @@ -116,7 +116,7 @@ static void rs_wait_until_sent(struct tty_struct *tty, int timeout); static struct serial_state rs_table[1]; -#define NR_PORTS (sizeof(rs_table)/sizeof(struct serial_state)) +#define NR_PORTS ARRAY_SIZE(rs_table) /* * tmp_buf is used as a temporary buffer by serial_write. We need to @@ -265,8 +265,9 @@ static _INLINE_ void receive_chars(struct async_struct *info) int status; int serdatr; struct tty_struct *tty = info->tty; - unsigned char ch; + unsigned char ch, flag; struct async_icount *icount; + int oe = 0; icount = &info->state->icount; @@ -282,15 +283,12 @@ static _INLINE_ void receive_chars(struct async_struct *info) status |= UART_LSR_OE; ch = serdatr & 0xff; - if (tty->flip.count >= TTY_FLIPBUF_SIZE) - goto ignore_char; - *tty->flip.char_buf_ptr = ch; icount->rx++; #ifdef SERIAL_DEBUG_INTR printk("DR%02x:%02x...", ch, status); #endif - *tty->flip.flag_buf_ptr = 0; + flag = TTY_NORMAL; /* * We don't handle parity or frame errors - but I have left @@ -319,7 +317,7 @@ static _INLINE_ void receive_chars(struct async_struct *info) * should be ignored. */ if (status & info->ignore_status_mask) - goto ignore_char; + goto out; status &= info->read_status_mask; @@ -327,33 +325,28 @@ static _INLINE_ void receive_chars(struct async_struct *info) #ifdef SERIAL_DEBUG_INTR printk("handling break...."); #endif - *tty->flip.flag_buf_ptr = TTY_BREAK; + flag = TTY_BREAK; if (info->flags & ASYNC_SAK) do_SAK(tty); } else if (status & UART_LSR_PE) - *tty->flip.flag_buf_ptr = TTY_PARITY; + flag = TTY_PARITY; else if (status & UART_LSR_FE) - *tty->flip.flag_buf_ptr = TTY_FRAME; + flag = TTY_FRAME; if (status & UART_LSR_OE) { /* * Overrun is special, since it's * reported immediately, and doesn't * affect the current character */ - if (tty->flip.count < TTY_FLIPBUF_SIZE) { - tty->flip.count++; - tty->flip.flag_buf_ptr++; - tty->flip.char_buf_ptr++; - *tty->flip.flag_buf_ptr = TTY_OVERRUN; - } + oe = 1; } } - tty->flip.flag_buf_ptr++; - tty->flip.char_buf_ptr++; - tty->flip.count++; - ignore_char: - + tty_insert_flip_char(tty, ch, flag); + if (oe == 1) + tty_insert_flip_char(tty, 0, TTY_OVERRUN); tty_flip_buffer_push(tty); +out: + return; } static _INLINE_ void transmit_chars(struct async_struct *info) diff --git a/trunk/drivers/char/cs5535_gpio.c b/trunk/drivers/char/cs5535_gpio.c new file mode 100644 index 000000000000..5d72f50de1ac --- /dev/null +++ b/trunk/drivers/char/cs5535_gpio.c @@ -0,0 +1,250 @@ +/* + * AMD CS5535/CS5536 GPIO driver. + * Allows a user space process to play with the GPIO pins. + * + * Copyright (c) 2005 Ben Gardner + * + * This program is free software; you can redistribute it and/or modify + * it under the smems of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +#define NAME "cs5535_gpio" + +MODULE_AUTHOR("Ben Gardner "); +MODULE_DESCRIPTION("AMD CS5535/CS5536 GPIO Pin Driver"); +MODULE_LICENSE("GPL"); + +static int major; +module_param(major, int, 0); +MODULE_PARM_DESC(major, "Major device number"); + +static ulong mask; +module_param(mask, ulong, 0); +MODULE_PARM_DESC(mask, "GPIO channel mask"); + +#define MSR_LBAR_GPIO 0x5140000C + +static u32 gpio_base; + +static struct pci_device_id divil_pci[] = { + { PCI_DEVICE(PCI_VENDOR_ID_NS, PCI_DEVICE_ID_NS_CS5535_ISA) }, + { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_CS5536_ISA) }, + { } /* NULL entry */ +}; + +static struct cdev cs5535_gpio_cdev; + +/* reserve 32 entries even though some aren't usable */ +#define CS5535_GPIO_COUNT 32 + +/* IO block size */ +#define CS5535_GPIO_SIZE 256 + +struct gpio_regmap { + u32 rd_offset; + u32 wr_offset; + char on; + char off; +}; +static struct gpio_regmap rm[] = +{ + { 0x30, 0x00, '1', '0' }, /* GPIOx_READ_BACK / GPIOx_OUT_VAL */ + { 0x20, 0x20, 'I', 'i' }, /* GPIOx_IN_EN */ + { 0x04, 0x04, 'O', 'o' }, /* GPIOx_OUT_EN */ + { 0x08, 0x08, 't', 'T' }, /* GPIOx_OUT_OD_EN */ + { 0x18, 0x18, 'P', 'p' }, /* GPIOx_OUT_PU_EN */ + { 0x1c, 0x1c, 'D', 'd' }, /* GPIOx_OUT_PD_EN */ +}; + + +/** + * Gets the register offset for the GPIO bank. + * Low (0-15) starts at 0x00, high (16-31) starts at 0x80 + */ +static inline u32 cs5535_lowhigh_base(int reg) +{ + return (reg & 0x10) << 3; +} + +static ssize_t cs5535_gpio_write(struct file *file, const char __user *data, + size_t len, loff_t *ppos) +{ + u32 m = iminor(file->f_dentry->d_inode); + int i, j; + u32 base = gpio_base + cs5535_lowhigh_base(m); + u32 m0, m1; + char c; + + /** + * Creates the mask for atomic bit programming. + * The high 16 bits and the low 16 bits are used to set the mask. + * For example, GPIO 15 maps to 31,15: 0,1 => On; 1,0=> Off + */ + m1 = 1 << (m & 0x0F); + m0 = m1 << 16; + + for (i = 0; i < len; ++i) { + if (get_user(c, data+i)) + return -EFAULT; + + for (j = 0; j < ARRAY_SIZE(rm); j++) { + if (c == rm[j].on) { + outl(m1, base + rm[j].wr_offset); + break; + } else if (c == rm[j].off) { + outl(m0, base + rm[j].wr_offset); + break; + } + } + } + *ppos = 0; + return len; +} + +static ssize_t cs5535_gpio_read(struct file *file, char __user *buf, + size_t len, loff_t *ppos) +{ + u32 m = iminor(file->f_dentry->d_inode); + u32 base = gpio_base + cs5535_lowhigh_base(m); + int rd_bit = 1 << (m & 0x0f); + int i; + char ch; + ssize_t count = 0; + + if (*ppos >= ARRAY_SIZE(rm)) + return 0; + + for (i = *ppos; (i < (*ppos + len)) && (i < ARRAY_SIZE(rm)); i++) { + ch = (inl(base + rm[i].rd_offset) & rd_bit) ? + rm[i].on : rm[i].off; + + if (put_user(ch, buf+count)) + return -EFAULT; + + count++; + } + + /* add a line-feed if there is room */ + if ((i == ARRAY_SIZE(rm)) && (count < len)) { + put_user('\n', buf + count); + count++; + } + + *ppos += count; + return count; +} + +static int cs5535_gpio_open(struct inode *inode, struct file *file) +{ + u32 m = iminor(inode); + + /* the mask says which pins are usable by this driver */ + if ((mask & (1 << m)) == 0) + return -EINVAL; + + return nonseekable_open(inode, file); +} + +static struct file_operations cs5535_gpio_fops = { + .owner = THIS_MODULE, + .write = cs5535_gpio_write, + .read = cs5535_gpio_read, + .open = cs5535_gpio_open +}; + +static int __init cs5535_gpio_init(void) +{ + dev_t dev_id; + u32 low, hi; + int retval; + + if (pci_dev_present(divil_pci) == 0) { + printk(KERN_WARNING NAME ": DIVIL not found\n"); + return -ENODEV; + } + + /* Grab the GPIO I/O range */ + rdmsr(MSR_LBAR_GPIO, low, hi); + + /* Check the mask and whether GPIO is enabled (sanity check) */ + if (hi != 0x0000f001) { + printk(KERN_WARNING NAME ": GPIO not enabled\n"); + return -ENODEV; + } + + /* Mask off the IO base address */ + gpio_base = low & 0x0000ff00; + + /** + * Some GPIO pins + * 31-29,23 : reserved (always mask out) + * 28 : Power Button + * 26 : PME# + * 22-16 : LPC + * 14,15 : SMBus + * 9,8 : UART1 + * 7 : PCI INTB + * 3,4 : UART2/DDC + * 2 : IDE_IRQ0 + * 0 : PCI INTA + * + * If a mask was not specified, be conservative and only allow: + * 1,2,5,6,10-13,24,25,27 + */ + if (mask != 0) + mask &= 0x1f7fffff; + else + mask = 0x0b003c66; + + if (request_region(gpio_base, CS5535_GPIO_SIZE, NAME) == 0) { + printk(KERN_ERR NAME ": can't allocate I/O for GPIO\n"); + return -ENODEV; + } + + if (major) { + dev_id = MKDEV(major, 0); + retval = register_chrdev_region(dev_id, CS5535_GPIO_COUNT, + NAME); + } else { + retval = alloc_chrdev_region(&dev_id, 0, CS5535_GPIO_COUNT, + NAME); + major = MAJOR(dev_id); + } + + if (retval) { + release_region(gpio_base, CS5535_GPIO_SIZE); + return -1; + } + + printk(KERN_DEBUG NAME ": base=%#x mask=%#lx major=%d\n", + gpio_base, mask, major); + + cdev_init(&cs5535_gpio_cdev, &cs5535_gpio_fops); + cdev_add(&cs5535_gpio_cdev, dev_id, CS5535_GPIO_COUNT); + + return 0; +} + +static void __exit cs5535_gpio_cleanup(void) +{ + dev_t dev_id = MKDEV(major, 0); + unregister_chrdev_region(dev_id, CS5535_GPIO_COUNT); + if (gpio_base != 0) + release_region(gpio_base, CS5535_GPIO_SIZE); +} + +module_init(cs5535_gpio_init); +module_exit(cs5535_gpio_cleanup); diff --git a/trunk/drivers/char/cyclades.c b/trunk/drivers/char/cyclades.c index c7f818cd7b02..39c61a71176e 100644 --- a/trunk/drivers/char/cyclades.c +++ b/trunk/drivers/char/cyclades.c @@ -641,6 +641,7 @@ static char rcsid[] = #include #include #include +#include #include #include #include @@ -723,7 +724,7 @@ static unsigned int cy_isa_addresses[] = { 0xDE000, 0,0,0,0,0,0,0,0 }; -#define NR_ISA_ADDRS (sizeof(cy_isa_addresses)/sizeof(unsigned char*)) +#define NR_ISA_ADDRS ARRAY_SIZE(cy_isa_addresses) #ifdef MODULE static long maddr[NR_CARDS] = { 0, }; @@ -1086,7 +1087,7 @@ cyy_interrupt(int irq, void *dev_id, struct pt_regs *regs) int had_work; int mdm_change; int mdm_status; - + int len; if((cinfo = (struct cyclades_card *)dev_id) == 0){ #ifdef CY_DEBUG_INTERRUPTS printk("cyy_interrupt: spurious interrupt %d\n\r", irq); @@ -1163,63 +1164,43 @@ cyy_interrupt(int irq, void *dev_id, struct pt_regs *regs) info->icount.rx++; continue; } - if (tty->flip.count < TTY_FLIPBUF_SIZE){ - tty->flip.count++; + if (tty_buffer_request_room(tty, 1)) { if (data & info->read_status_mask){ if(data & CyBREAK){ - *tty->flip.flag_buf_ptr++ = - TTY_BREAK; - *tty->flip.char_buf_ptr++ = - cy_readb(base_addr+(CyRDSR<icount.rx++; if (info->flags & ASYNC_SAK){ do_SAK(tty); } }else if(data & CyFRAME){ - *tty->flip.flag_buf_ptr++ = - TTY_FRAME; - *tty->flip.char_buf_ptr++ = - cy_readb(base_addr+(CyRDSR<icount.rx++; info->idle_stats.frame_errs++; }else if(data & CyPARITY){ - *tty->flip.flag_buf_ptr++ = - TTY_PARITY; - *tty->flip.char_buf_ptr++ = - cy_readb(base_addr+(CyRDSR<icount.rx++; info->idle_stats.parity_errs++; }else if(data & CyOVERRUN){ - *tty->flip.flag_buf_ptr++ = - TTY_OVERRUN; - *tty->flip.char_buf_ptr++ = 0; + tty_insert_flip_char(tty, 0, TTY_OVERRUN); info->icount.rx++; /* If the flip buffer itself is overflowing, we still lose the next incoming character. */ - if(tty->flip.count - < TTY_FLIPBUF_SIZE){ - tty->flip.count++; - *tty->flip.flag_buf_ptr++ = - TTY_NORMAL; - *tty->flip.char_buf_ptr++ = - cy_readb(base_addr+(CyRDSR<icount.rx++; - } + tty_insert_flip_char(tty, cy_readb(base_addr+(CyRDSR<icount.rx++; info->idle_stats.overruns++; /* These two conditions may imply */ /* a normal read should be done. */ /* }else if(data & CyTIMEOUT){ */ /* }else if(data & CySPECHAR){ */ - }else{ - *tty->flip.flag_buf_ptr++ = 0; - *tty->flip.char_buf_ptr++ = 0; - info->icount.rx++; + }else { + tty_insert_flip_char(tty, 0, TTY_NORMAL); + info->icount.rx++; } }else{ - *tty->flip.flag_buf_ptr++ = 0; - *tty->flip.char_buf_ptr++ = 0; + tty_insert_flip_char(tty, 0, TTY_NORMAL); info->icount.rx++; } }else{ @@ -1240,14 +1221,10 @@ cyy_interrupt(int irq, void *dev_id, struct pt_regs *regs) info->mon.char_max = char_count; info->mon.char_last = char_count; #endif - while(char_count--){ - if (tty->flip.count >= TTY_FLIPBUF_SIZE){ - break; - } - tty->flip.count++; + len = tty_buffer_request_room(tty, char_count); + while(len--){ data = cy_readb(base_addr+(CyRDSR<flip.flag_buf_ptr++ = TTY_NORMAL; - *tty->flip.char_buf_ptr++ = data; + tty_insert_flip_char(tty, data, TTY_NORMAL); info->idle_stats.recv_bytes++; info->icount.rx++; #ifdef CY_16Y_HACK @@ -1256,7 +1233,7 @@ cyy_interrupt(int irq, void *dev_id, struct pt_regs *regs) } info->idle_stats.recv_idle = jiffies; } - schedule_delayed_work(&tty->flip.work, 1); + schedule_delayed_work(&tty->buf.work, 1); } /* end of service */ cy_writeb(base_addr+(CyRIR<card]; struct tty_struct *tty = info->tty; volatile int char_count; + int len; #ifdef BLOCKMOVE int small_count; #else @@ -1606,18 +1584,11 @@ cyz_handle_rx(struct cyclades_port *info, tty->flip.count += small_count; } #else - while(char_count--){ - if (tty->flip.count >= N_TTY_BUF_SIZE - tty->read_cnt) - break; - - if (tty->flip.count >= TTY_FLIPBUF_SIZE) - break; - + len = tty_buffer_request_room(tty, char_count); + while(len--){ data = cy_readb(cinfo->base_addr + rx_bufaddr + new_rx_get); new_rx_get = (new_rx_get + 1) & (rx_bufsize - 1); - tty->flip.count++; - *tty->flip.flag_buf_ptr++ = TTY_NORMAL; - *tty->flip.char_buf_ptr++ = data; + tty_insert_flip_char(tty, data, TTY_NORMAL); info->idle_stats.recv_bytes++; info->icount.rx++; } @@ -1635,7 +1606,7 @@ cyz_handle_rx(struct cyclades_port *info, } #endif info->idle_stats.recv_idle = jiffies; - schedule_delayed_work(&tty->flip.work, 1); + schedule_delayed_work(&tty->buf.work, 1); } /* Update rx_get */ cy_writel(&buf_ctrl->rx_get, new_rx_get); @@ -1763,23 +1734,17 @@ cyz_handle_cmd(struct cyclades_card *cinfo) switch(cmd) { case C_CM_PR_ERROR: - tty->flip.count++; - *tty->flip.flag_buf_ptr++ = TTY_PARITY; - *tty->flip.char_buf_ptr++ = 0; + tty_insert_flip_char(tty, 0, TTY_PARITY); info->icount.rx++; special_count++; break; case C_CM_FR_ERROR: - tty->flip.count++; - *tty->flip.flag_buf_ptr++ = TTY_FRAME; - *tty->flip.char_buf_ptr++ = 0; + tty_insert_flip_char(tty, 0, TTY_FRAME); info->icount.rx++; special_count++; break; case C_CM_RXBRK: - tty->flip.count++; - *tty->flip.flag_buf_ptr++ = TTY_BREAK; - *tty->flip.char_buf_ptr++ = 0; + tty_insert_flip_char(tty, 0, TTY_BREAK); info->icount.rx++; special_count++; break; @@ -1844,7 +1809,7 @@ cyz_handle_cmd(struct cyclades_card *cinfo) if(delta_count) cy_sched_event(info, Cy_EVENT_DELTA_WAKEUP); if(special_count) - schedule_delayed_work(&tty->flip.work, 1); + schedule_delayed_work(&tty->buf.work, 1); } } diff --git a/trunk/drivers/char/drm/drm_ioc32.c b/trunk/drivers/char/drm/drm_ioc32.c index dd91ff6b474c..e9e2db18952d 100644 --- a/trunk/drivers/char/drm/drm_ioc32.c +++ b/trunk/drivers/char/drm/drm_ioc32.c @@ -28,7 +28,6 @@ * IN THE SOFTWARE. */ #include -#include #include "drmP.h" #include "drm_core.h" diff --git a/trunk/drivers/char/drm/i915_ioc32.c b/trunk/drivers/char/drm/i915_ioc32.c index 2218a946ec87..296248cdc767 100644 --- a/trunk/drivers/char/drm/i915_ioc32.c +++ b/trunk/drivers/char/drm/i915_ioc32.c @@ -30,7 +30,6 @@ * IN THE SOFTWARE. */ #include -#include #include "drmP.h" #include "drm.h" diff --git a/trunk/drivers/char/drm/mga_ioc32.c b/trunk/drivers/char/drm/mga_ioc32.c index 24a9d4e86af0..54a18eb2fc04 100644 --- a/trunk/drivers/char/drm/mga_ioc32.c +++ b/trunk/drivers/char/drm/mga_ioc32.c @@ -31,7 +31,6 @@ * IN THE SOFTWARE. */ #include -#include #include "drmP.h" #include "drm.h" diff --git a/trunk/drivers/char/drm/r128_ioc32.c b/trunk/drivers/char/drm/r128_ioc32.c index 1e2e367b8b82..9dd6d4116e47 100644 --- a/trunk/drivers/char/drm/r128_ioc32.c +++ b/trunk/drivers/char/drm/r128_ioc32.c @@ -30,7 +30,6 @@ * IN THE SOFTWARE. */ #include -#include #include "drmP.h" #include "drm.h" diff --git a/trunk/drivers/char/drm/radeon_ioc32.c b/trunk/drivers/char/drm/radeon_ioc32.c index fef4a2b84c1e..0ccfd3618ff1 100644 --- a/trunk/drivers/char/drm/radeon_ioc32.c +++ b/trunk/drivers/char/drm/radeon_ioc32.c @@ -28,7 +28,6 @@ * IN THE SOFTWARE. */ #include -#include #include "drmP.h" #include "drm.h" diff --git a/trunk/drivers/char/epca.c b/trunk/drivers/char/epca.c index 407708a001e4..765c5c108bf4 100644 --- a/trunk/drivers/char/epca.c +++ b/trunk/drivers/char/epca.c @@ -1786,9 +1786,7 @@ static void doevent(int crd) if (tty) { /* Begin if valid tty */ if (event & BREAK_IND) { /* Begin if BREAK_IND */ /* A break has been indicated */ - tty->flip.count++; - *tty->flip.flag_buf_ptr++ = TTY_BREAK; - *tty->flip.char_buf_ptr++ = 0; + tty_insert_flip_char(tty, 0, TTY_BREAK); tty_schedule_flip(tty); } else if (event & LOWTX_IND) { /* Begin LOWTX_IND */ if (ch->statusflags & LOWWAIT) @@ -2124,7 +2122,6 @@ static void receive_data(struct channel *ch) int dataToRead, wrapgap, bytesAvailable; unsigned int tail, head; unsigned int wrapmask; - int rc; /* --------------------------------------------------------------- This routine is called by doint when a receive data event @@ -2162,16 +2159,15 @@ static void receive_data(struct channel *ch) return; } - if (tty->flip.count == TTY_FLIPBUF_SIZE) + if (tty_buffer_request_room(tty, bytesAvailable + 1) == 0) return; if (readb(&bc->orun)) { writeb(0, &bc->orun); printk(KERN_WARNING "epca; overrun! DigiBoard device %s\n",tty->name); + tty_insert_flip_char(tty, 0, TTY_OVERRUN); } rxwinon(ch); - rptr = tty->flip.char_buf_ptr; - rc = tty->flip.count; while (bytesAvailable > 0) { /* Begin while there is data on the card */ wrapgap = (head >= tail) ? head - tail : ch->rxbufsize - tail; /* --------------------------------------------------------------- @@ -2183,8 +2179,7 @@ static void receive_data(struct channel *ch) /* -------------------------------------------------------------- Make sure we don't overflow the buffer ----------------------------------------------------------------- */ - if ((rc + dataToRead) > TTY_FLIPBUF_SIZE) - dataToRead = TTY_FLIPBUF_SIZE - rc; + dataToRead = tty_prepare_flip_string(tty, &rptr, dataToRead); if (dataToRead == 0) break; /* --------------------------------------------------------------- @@ -2192,13 +2187,9 @@ static void receive_data(struct channel *ch) for translation if necessary. ------------------------------------------------------------------ */ memcpy_fromio(rptr, ch->rxptr + tail, dataToRead); - rc += dataToRead; - rptr += dataToRead; tail = (tail + dataToRead) & wrapmask; bytesAvailable -= dataToRead; } /* End while there is data on the card */ - tty->flip.count = rc; - tty->flip.char_buf_ptr = rptr; globalwinon(ch); writew(tail, &bc->rout); /* Must be called with global data */ diff --git a/trunk/drivers/char/esp.c b/trunk/drivers/char/esp.c index 9f53d2fcc360..e469f641c728 100644 --- a/trunk/drivers/char/esp.c +++ b/trunk/drivers/char/esp.c @@ -345,26 +345,22 @@ static inline void receive_chars_pio(struct esp_struct *info, int num_bytes) for (i = 0; i < num_bytes; i++) { if (!(err_buf->data[i] & status_mask)) { - *(tty->flip.char_buf_ptr++) = pio_buf->data[i]; + int flag = 0; if (err_buf->data[i] & 0x04) { - *(tty->flip.flag_buf_ptr++) = TTY_BREAK; - + flag = TTY_BREAK; if (info->flags & ASYNC_SAK) do_SAK(tty); } else if (err_buf->data[i] & 0x02) - *(tty->flip.flag_buf_ptr++) = TTY_FRAME; + flag = TTY_FRAME; else if (err_buf->data[i] & 0x01) - *(tty->flip.flag_buf_ptr++) = TTY_PARITY; - else - *(tty->flip.flag_buf_ptr++) = 0; - - tty->flip.count++; + flag = TTY_PARITY; + tty_insert_flip_char(tty, pio_buf->data[i], flag); } } - schedule_delayed_work(&tty->flip.work, 1); + schedule_delayed_work(&tty->buf.work, 1); info->stat_flags &= ~ESP_STAT_RX_TIMEOUT; release_pio_buffer(pio_buf); @@ -397,7 +393,6 @@ static inline void receive_chars_dma_done(struct esp_struct *info, int num_bytes; unsigned long flags; - flags=claim_dma_lock(); disable_dma(dma); clear_dma_ff(dma); @@ -408,38 +403,31 @@ static inline void receive_chars_dma_done(struct esp_struct *info, info->icount.rx += num_bytes; - memcpy(tty->flip.char_buf_ptr, dma_buffer, num_bytes); - tty->flip.char_buf_ptr += num_bytes; - tty->flip.count += num_bytes; - memset(tty->flip.flag_buf_ptr, 0, num_bytes); - tty->flip.flag_buf_ptr += num_bytes; - if (num_bytes > 0) { - tty->flip.flag_buf_ptr--; + tty_insert_flip_string(tty, dma_buffer, num_bytes - 1); status &= (0x1c & info->read_status_mask); + + /* Is the status significant or do we throw the last byte ? */ + if (!(status & info->ignore_status_mask)) { + int statflag = 0; - if (status & info->ignore_status_mask) { - tty->flip.count--; - tty->flip.char_buf_ptr--; - tty->flip.flag_buf_ptr--; - } else if (status & 0x10) { - *tty->flip.flag_buf_ptr = TTY_BREAK; - (info->icount.brk)++; - if (info->flags & ASYNC_SAK) - do_SAK(tty); - } else if (status & 0x08) { - *tty->flip.flag_buf_ptr = TTY_FRAME; - (info->icount.frame)++; - } - else if (status & 0x04) { - *tty->flip.flag_buf_ptr = TTY_PARITY; - (info->icount.parity)++; + if (status & 0x10) { + statflag = TTY_BREAK; + (info->icount.brk)++; + if (info->flags & ASYNC_SAK) + do_SAK(tty); + } else if (status & 0x08) { + statflag = TTY_FRAME; + (info->icount.frame)++; + } + else if (status & 0x04) { + statflag = TTY_PARITY; + (info->icount.parity)++; + } + tty_insert_flip_char(tty, dma_buffer[num_bytes - 1], statflag); } - - tty->flip.flag_buf_ptr++; - - schedule_delayed_work(&tty->flip.work, 1); + schedule_delayed_work(&tty->buf.work, 1); } if (dma_bytes != num_bytes) { @@ -693,8 +681,7 @@ static irqreturn_t rs_interrupt_single(int irq, void *dev_id, num_bytes = serial_in(info, UART_ESI_STAT1) << 8; num_bytes |= serial_in(info, UART_ESI_STAT2); - if (num_bytes > (TTY_FLIPBUF_SIZE - info->tty->flip.count)) - num_bytes = TTY_FLIPBUF_SIZE - info->tty->flip.count; + num_bytes = tty_buffer_request_room(info->tty, num_bytes); if (num_bytes) { if (dma_bytes || diff --git a/trunk/drivers/char/hvc_console.c b/trunk/drivers/char/hvc_console.c index f92177634677..1994a92d4733 100644 --- a/trunk/drivers/char/hvc_console.c +++ b/trunk/drivers/char/hvc_console.c @@ -597,9 +597,7 @@ static int hvc_poll(struct hvc_struct *hp) /* Read data if any */ for (;;) { - int count = N_INBUF; - if (count > (TTY_FLIPBUF_SIZE - tty->flip.count)) - count = TTY_FLIPBUF_SIZE - tty->flip.count; + int count = tty_buffer_request_room(tty, N_INBUF); /* If flip is full, just reschedule a later read */ if (count == 0) { @@ -635,7 +633,7 @@ static int hvc_poll(struct hvc_struct *hp) tty_insert_flip_char(tty, buf[i], 0); } - if (tty->flip.count) + if (count) tty_schedule_flip(tty); /* diff --git a/trunk/drivers/char/hvcs.c b/trunk/drivers/char/hvcs.c index 53dc77c760fc..831eb4e8d9d3 100644 --- a/trunk/drivers/char/hvcs.c +++ b/trunk/drivers/char/hvcs.c @@ -456,12 +456,11 @@ static int hvcs_io(struct hvcs_struct *hvcsd) /* remove the read masks */ hvcsd->todo_mask &= ~(HVCS_READ_MASK); - if ((tty->flip.count + HVCS_BUFF_LEN) < TTY_FLIPBUF_SIZE) { + if (tty_buffer_request_room(tty, HVCS_BUFF_LEN) >= HVCS_BUFF_LEN) { got = hvc_get_chars(unit_address, &buf[0], HVCS_BUFF_LEN); - for (i=0;got && itodo_mask |= HVCS_QUICK_READ; spin_unlock_irqrestore(&hvcsd->lock, flags); - if (tty->flip.count) { - /* This is synch because tty->low_latency == 1 */ + /* This is synch because tty->low_latency == 1 */ + if(got) tty_flip_buffer_push(tty); - } if (!got) { /* Do this _after_ the flip_buffer_push */ diff --git a/trunk/drivers/char/hvsi.c b/trunk/drivers/char/hvsi.c index a22aa940e01e..a9522189fc9e 100644 --- a/trunk/drivers/char/hvsi.c +++ b/trunk/drivers/char/hvsi.c @@ -197,7 +197,7 @@ static inline void print_state(struct hvsi_struct *hp) }; const char *name = state_names[hp->state]; - if (hp->state > (sizeof(state_names)/sizeof(char*))) + if (hp->state > ARRAY_SIZE(state_names)) name = "UNKNOWN"; pr_debug("hvsi%i: state = %s\n", hp->index, name); diff --git a/trunk/drivers/char/ip2/i2lib.c b/trunk/drivers/char/ip2/i2lib.c index ba85eb1b6ec7..fc944d375be7 100644 --- a/trunk/drivers/char/ip2/i2lib.c +++ b/trunk/drivers/char/ip2/i2lib.c @@ -854,7 +854,7 @@ i2Input(i2ChanStrPtr pCh) count += IBUF_SIZE; } // Don't give more than can be taken by the line discipline - amountToMove = pCh->pTTY->ldisc.receive_room( pCh->pTTY ); + amountToMove = pCh->pTTY->receive_room; if (count > amountToMove) { count = amountToMove; } diff --git a/trunk/drivers/char/ip2main.c b/trunk/drivers/char/ip2main.c index d815d197dc3e..56e93a5a1e24 100644 --- a/trunk/drivers/char/ip2main.c +++ b/trunk/drivers/char/ip2main.c @@ -172,7 +172,7 @@ static int Fip_firmware_size; /* Private (static) functions */ static int ip2_open(PTTY, struct file *); static void ip2_close(PTTY, struct file *); -static int ip2_write(PTTY, int, const unsigned char *, int); +static int ip2_write(PTTY, const unsigned char *, int); static void ip2_putchar(PTTY, unsigned char); static void ip2_flush_chars(PTTY); static int ip2_write_room(PTTY); @@ -1713,7 +1713,7 @@ ip2_hangup ( PTTY tty ) /* */ /******************************************************************************/ static int -ip2_write( PTTY tty, int user, const unsigned char *pData, int count) +ip2_write( PTTY tty, const unsigned char *pData, int count) { i2ChanStrPtr pCh = tty->driver_data; int bytesSent = 0; @@ -1726,7 +1726,7 @@ ip2_write( PTTY tty, int user, const unsigned char *pData, int count) /* This is the actual move bit. Make sure it does what we need!!!!! */ WRITE_LOCK_IRQSAVE(&pCh->Pbuf_spinlock,flags); - bytesSent = i2Output( pCh, pData, count, user ); + bytesSent = i2Output( pCh, pData, count, 0 ); WRITE_UNLOCK_IRQRESTORE(&pCh->Pbuf_spinlock,flags); ip2trace (CHANN, ITRC_WRITE, ITRC_RETURN, 1, bytesSent ); @@ -2001,7 +2001,9 @@ ip2_stop ( PTTY tty ) static int ip2_tiocmget(struct tty_struct *tty, struct file *file) { i2ChanStrPtr pCh = DevTable[tty->index]; +#ifdef ENABLE_DSSNOW wait_queue_t wait; +#endif if (pCh == NULL) return -ENODEV; @@ -2089,15 +2091,17 @@ ip2_ioctl ( PTTY tty, struct file *pFile, UINT cmd, ULONG arg ) { wait_queue_t wait; i2ChanStrPtr pCh = DevTable[tty->index]; + i2eBordStrPtr pB; struct async_icount cprev, cnow; /* kernel counter temps */ struct serial_icounter_struct __user *p_cuser; int rc = 0; unsigned long flags; void __user *argp = (void __user *)arg; - if ( pCh == NULL ) { + if ( pCh == NULL ) return -ENODEV; - } + + pB = pCh->pMyBord; ip2trace (CHANN, ITRC_IOCTL, ITRC_ENTER, 2, cmd, arg ); @@ -2206,9 +2210,9 @@ ip2_ioctl ( PTTY tty, struct file *pFile, UINT cmd, ULONG arg ) * for masking). Caller should use TIOCGICOUNT to see which one it was */ case TIOCMIWAIT: - save_flags(flags);cli(); + WRITE_LOCK_IRQSAVE(&pB->read_fifo_spinlock, flags); cprev = pCh->icount; /* note the counters on entry */ - restore_flags(flags); + WRITE_UNLOCK_IRQRESTORE(&pB->read_fifo_spinlock, flags); i2QueueCommands(PTYPE_BYPASS, pCh, 100, 4, CMD_DCD_REP, CMD_CTS_REP, CMD_DSR_REP, CMD_RI_REP); init_waitqueue_entry(&wait, current); @@ -2228,9 +2232,9 @@ ip2_ioctl ( PTTY tty, struct file *pFile, UINT cmd, ULONG arg ) rc = -ERESTARTSYS; break; } - save_flags(flags);cli(); + WRITE_LOCK_IRQSAVE(&pB->read_fifo_spinlock, flags); cnow = pCh->icount; /* atomic copy */ - restore_flags(flags); + WRITE_UNLOCK_IRQRESTORE(&pB->read_fifo_spinlock, flags); if (cnow.rng == cprev.rng && cnow.dsr == cprev.dsr && cnow.dcd == cprev.dcd && cnow.cts == cprev.cts) { rc = -EIO; /* no change => rc */ @@ -2268,9 +2272,9 @@ ip2_ioctl ( PTTY tty, struct file *pFile, UINT cmd, ULONG arg ) case TIOCGICOUNT: ip2trace (CHANN, ITRC_IOCTL, 11, 1, rc ); - save_flags(flags);cli(); + WRITE_LOCK_IRQSAVE(&pB->read_fifo_spinlock, flags); cnow = pCh->icount; - restore_flags(flags); + WRITE_UNLOCK_IRQRESTORE(&pB->read_fifo_spinlock, flags); p_cuser = argp; rc = put_user(cnow.cts, &p_cuser->cts); rc = put_user(cnow.dsr, &p_cuser->dsr); diff --git a/trunk/drivers/char/ipmi/ipmi_msghandler.c b/trunk/drivers/char/ipmi/ipmi_msghandler.c index 561430ed94af..0097f06fa67b 100644 --- a/trunk/drivers/char/ipmi/ipmi_msghandler.c +++ b/trunk/drivers/char/ipmi/ipmi_msghandler.c @@ -57,6 +57,7 @@ static int initialized = 0; #ifdef CONFIG_PROC_FS struct proc_dir_entry *proc_ipmi_root = NULL; +EXPORT_SYMBOL(proc_ipmi_root); #endif /* CONFIG_PROC_FS */ #define MAX_EVENTS_IN_QUEUE 25 @@ -3295,6 +3296,5 @@ EXPORT_SYMBOL(ipmi_get_my_address); EXPORT_SYMBOL(ipmi_set_my_LUN); EXPORT_SYMBOL(ipmi_get_my_LUN); EXPORT_SYMBOL(ipmi_smi_add_proc_entry); -EXPORT_SYMBOL(proc_ipmi_root); EXPORT_SYMBOL(ipmi_user_set_run_to_completion); EXPORT_SYMBOL(ipmi_free_recv_msg); diff --git a/trunk/drivers/char/ipmi/ipmi_poweroff.c b/trunk/drivers/char/ipmi/ipmi_poweroff.c index e053eade0366..49c09ae004bf 100644 --- a/trunk/drivers/char/ipmi/ipmi_poweroff.c +++ b/trunk/drivers/char/ipmi/ipmi_poweroff.c @@ -612,11 +612,14 @@ static int ipmi_poweroff_init (void) #endif rv = ipmi_smi_watcher_register(&smi_watcher); + +#ifdef CONFIG_PROC_FS if (rv) { unregister_sysctl_table(ipmi_table_header); printk(KERN_ERR PFX "Unable to register SMI watcher: %d\n", rv); goto out_err; } +#endif out_err: return rv; diff --git a/trunk/drivers/char/isicom.c b/trunk/drivers/char/isicom.c index 1bbf507adda5..e9ebabaf8cb0 100644 --- a/trunk/drivers/char/isicom.c +++ b/trunk/drivers/char/isicom.c @@ -20,7 +20,7 @@ * 3/9/99 sameer Added support for ISI4616 cards. * * 16/9/99 sameer We do not force RTS low anymore. - * This is to prevent the firmware + * This is to prevent the firmware * from getting confused. * * 26/10/99 sameer Cosmetic changes:The driver now @@ -31,28 +31,28 @@ * * 10/5/00 sameer Fixed isicom_shutdown_board() * to not lower DTR on all the ports - * when the last port on the card is + * when the last port on the card is * closed. * * 10/5/00 sameer Signal mask setup command added - * to isicom_setup_port and + * to isicom_setup_port and * isicom_shutdown_port. * * 24/5/00 sameer The driver is now SMP aware. - * - * + * + * * 27/11/00 Vinayak P Risbud Fixed the Driver Crash Problem - * - * + * + * * 03/01/01 anil .s Added support for resetting the * internal modems on ISI cards. * * 08/02/01 anil .s Upgraded the driver for kernel * 2.4.x * - * 11/04/01 Kevin Fixed firmware load problem with + * 11/04/01 Kevin Fixed firmware load problem with * ISIHP-4X card - * + * * 30/04/01 anil .s Fixed the remote login through * ISI port problem. Now the link * does not go down before password @@ -62,9 +62,9 @@ * among ISI-PCI cards. * * 03/05/01 anil .s Added support to display the version - * info during insmod as well as module + * info during insmod as well as module * listing by lsmod. - * + * * 10/05/01 anil .s Done the modifications to the source * file and Install script so that the * same installation can be used for @@ -73,19 +73,19 @@ * 06/06/01 anil .s Now we drop both dtr and rts during * shutdown_port as well as raise them * during isicom_config_port. - * + * * 09/06/01 acme@conectiva.com.br use capable, not suser, do * restore_flags on failure in * isicom_send_break, verify put_user * result * - * 11/02/03 ranjeeth Added support for 230 Kbps and 460 Kbps - * Baud index extended to 21 - * - * 20/03/03 ranjeeth Made to work for Linux Advanced server. - * Taken care of license warning. - * - * 10/12/03 Ravindra Made to work for Fedora Core 1 of + * 11/02/03 ranjeeth Added support for 230 Kbps and 460 Kbps + * Baud index extended to 21 + * + * 20/03/03 ranjeeth Made to work for Linux Advanced server. + * Taken care of license warning. + * + * 10/12/03 Ravindra Made to work for Fedora Core 1 of * Red Hat Distribution * * 06/01/05 Alan Cox Merged the ISI and base kernel strands @@ -93,10 +93,10 @@ * * *********************************************************** * - * To use this driver you also need the support package. You + * To use this driver you also need the support package. You * can find this in RPM format on * ftp://ftp.linux.org.uk/pub/linux/alan - * + * * You can find the original tools for this direct from Multitech * ftp://ftp.multitech.com/ISI-Cards/ * @@ -107,20 +107,20 @@ * Omit those entries for boards you don't have installed. * * TODO - * Hotplug * Merge testing * 64-bit verification */ #include +#include #include #include +#include #include #include #include #include #include -#include #include #include #include @@ -134,50 +134,62 @@ #include +#define InterruptTheCard(base) outw(0, (base) + 0xc) +#define ClearInterrupt(base) inw((base) + 0x0a) + +#ifdef DEBUG +#define pr_dbg(str...) printk(KERN_DEBUG "ISICOM: " str) +#define isicom_paranoia_check(a, b, c) __isicom_paranoia_check((a), (b), (c)) +#else +#define pr_dbg(str...) do { } while (0) +#define isicom_paranoia_check(a, b, c) 0 +#endif + +static int isicom_probe(struct pci_dev *, const struct pci_device_id *); +static void __devexit isicom_remove(struct pci_dev *); + static struct pci_device_id isicom_pci_tbl[] = { - { VENDOR_ID, 0x2028, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, - { VENDOR_ID, 0x2051, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, - { VENDOR_ID, 0x2052, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, - { VENDOR_ID, 0x2053, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, - { VENDOR_ID, 0x2054, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, - { VENDOR_ID, 0x2055, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, - { VENDOR_ID, 0x2056, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, - { VENDOR_ID, 0x2057, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, - { VENDOR_ID, 0x2058, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, + { PCI_DEVICE(VENDOR_ID, 0x2028) }, + { PCI_DEVICE(VENDOR_ID, 0x2051) }, + { PCI_DEVICE(VENDOR_ID, 0x2052) }, + { PCI_DEVICE(VENDOR_ID, 0x2053) }, + { PCI_DEVICE(VENDOR_ID, 0x2054) }, + { PCI_DEVICE(VENDOR_ID, 0x2055) }, + { PCI_DEVICE(VENDOR_ID, 0x2056) }, + { PCI_DEVICE(VENDOR_ID, 0x2057) }, + { PCI_DEVICE(VENDOR_ID, 0x2058) }, { 0 } }; MODULE_DEVICE_TABLE(pci, isicom_pci_tbl); +static struct pci_driver isicom_driver = { + .name = "isicom", + .id_table = isicom_pci_tbl, + .probe = isicom_probe, + .remove = __devexit_p(isicom_remove) +}; + static int prev_card = 3; /* start servicing isi_card[0] */ static struct tty_driver *isicom_normal; static struct timer_list tx; static char re_schedule = 1; -#ifdef ISICOM_DEBUG -static unsigned long tx_count = 0; -#endif - -static int ISILoad_ioctl(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg); static void isicom_tx(unsigned long _data); -static void isicom_start(struct tty_struct * tty); - -static unsigned char * tmp_buf; -static DECLARE_MUTEX(tmp_buf_sem); +static void isicom_start(struct tty_struct *tty); /* baud index mappings from linux defns to isi */ static signed char linuxb_to_isib[] = { - -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 13, 15, 16, 17, - 18, 19 + -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 13, 15, 16, 17, 18, 19 }; struct isi_board { - unsigned short base; + unsigned long base; unsigned char irq; unsigned char port_count; unsigned short status; - unsigned short port_status; /* each bit represents a single port */ + unsigned short port_status; /* each bit for each port */ unsigned short shift_count; struct isi_port * ports; signed char count; @@ -192,9 +204,9 @@ struct isi_port { int count; int blocked_open; int close_delay; - unsigned short channel; - unsigned short status; - unsigned short closing_wait; + u16 channel; + u16 status; + u16 closing_wait; struct isi_board * card; struct tty_struct * tty; wait_queue_head_t close_wait; @@ -215,35 +227,37 @@ static struct isi_port isi_ports[PORT_COUNT]; * the kernel lock for the card and have the card in a position that * it wants to talk. */ - + static int lock_card(struct isi_board *card) { char retries; - unsigned short base = card->base; + unsigned long base = card->base; for (retries = 0; retries < 100; retries++) { spin_lock_irqsave(&card->card_lock, card->flags); if (inw(base + 0xe) & 0x1) { - return 1; + return 1; } else { spin_unlock_irqrestore(&card->card_lock, card->flags); udelay(1000); /* 1ms */ } } - printk(KERN_WARNING "ISICOM: Failed to lock Card (0x%x)\n", card->base); + printk(KERN_WARNING "ISICOM: Failed to lock Card (0x%lx)\n", + card->base); + return 0; /* Failed to aquire the card! */ } static int lock_card_at_interrupt(struct isi_board *card) { unsigned char retries; - unsigned short base = card->base; + unsigned long base = card->base; for (retries = 0; retries < 200; retries++) { spin_lock_irqsave(&card->card_lock, card->flags); if (inw(base + 0xe) & 0x1) - return 1; + return 1; else spin_unlock_irqrestore(&card->card_lock, card->flags); } @@ -259,373 +273,141 @@ static void unlock_card(struct isi_board *card) /* * ISI Card specific ops ... */ - -static void raise_dtr(struct isi_port * port) + +static void raise_dtr(struct isi_port *port) { - struct isi_board * card = port->card; - unsigned short base = card->base; - unsigned char channel = port->channel; + struct isi_board *card = port->card; + unsigned long base = card->base; + u16 channel = port->channel; if (!lock_card(card)) return; - outw(0x8000 | (channel << card->shift_count) | 0x02 , base); + outw(0x8000 | (channel << card->shift_count) | 0x02, base); outw(0x0504, base); InterruptTheCard(base); port->status |= ISI_DTR; unlock_card(card); } -static inline void drop_dtr(struct isi_port * port) -{ - struct isi_board * card = port->card; - unsigned short base = card->base; - unsigned char channel = port->channel; +static inline void drop_dtr(struct isi_port *port) +{ + struct isi_board *card = port->card; + unsigned long base = card->base; + u16 channel = port->channel; if (!lock_card(card)) return; - outw(0x8000 | (channel << card->shift_count) | 0x02 , base); + outw(0x8000 | (channel << card->shift_count) | 0x02, base); outw(0x0404, base); - InterruptTheCard(base); + InterruptTheCard(base); port->status &= ~ISI_DTR; unlock_card(card); } -static inline void raise_rts(struct isi_port * port) +static inline void raise_rts(struct isi_port *port) { - struct isi_board * card = port->card; - unsigned short base = card->base; - unsigned char channel = port->channel; + struct isi_board *card = port->card; + unsigned long base = card->base; + u16 channel = port->channel; if (!lock_card(card)) return; - outw(0x8000 | (channel << card->shift_count) | 0x02 , base); + outw(0x8000 | (channel << card->shift_count) | 0x02, base); outw(0x0a04, base); - InterruptTheCard(base); + InterruptTheCard(base); port->status |= ISI_RTS; unlock_card(card); } -static inline void drop_rts(struct isi_port * port) +static inline void drop_rts(struct isi_port *port) { - struct isi_board * card = port->card; - unsigned short base = card->base; - unsigned char channel = port->channel; + struct isi_board *card = port->card; + unsigned long base = card->base; + u16 channel = port->channel; if (!lock_card(card)) return; - outw(0x8000 | (channel << card->shift_count) | 0x02 , base); + outw(0x8000 | (channel << card->shift_count) | 0x02, base); outw(0x0804, base); - InterruptTheCard(base); + InterruptTheCard(base); port->status &= ~ISI_RTS; unlock_card(card); } -static inline void raise_dtr_rts(struct isi_port * port) +static inline void raise_dtr_rts(struct isi_port *port) { - struct isi_board * card = port->card; - unsigned short base = card->base; - unsigned char channel = port->channel; + struct isi_board *card = port->card; + unsigned long base = card->base; + u16 channel = port->channel; if (!lock_card(card)) return; - outw(0x8000 | (channel << card->shift_count) | 0x02 , base); + outw(0x8000 | (channel << card->shift_count) | 0x02, base); outw(0x0f04, base); InterruptTheCard(base); port->status |= (ISI_DTR | ISI_RTS); unlock_card(card); } -static void drop_dtr_rts(struct isi_port * port) +static void drop_dtr_rts(struct isi_port *port) { - struct isi_board * card = port->card; - unsigned short base = card->base; - unsigned char channel = port->channel; + struct isi_board *card = port->card; + unsigned long base = card->base; + u16 channel = port->channel; if (!lock_card(card)) return; - outw(0x8000 | (channel << card->shift_count) | 0x02 , base); + outw(0x8000 | (channel << card->shift_count) | 0x02, base); outw(0x0c04, base); - InterruptTheCard(base); + InterruptTheCard(base); port->status &= ~(ISI_RTS | ISI_DTR); unlock_card(card); } -static inline void kill_queue(struct isi_port * port, short queue) +static inline void kill_queue(struct isi_port *port, short queue) { - struct isi_board * card = port->card; - unsigned short base = card->base; - unsigned char channel = port->channel; + struct isi_board *card = port->card; + unsigned long base = card->base; + u16 channel = port->channel; if (!lock_card(card)) return; - outw(0x8000 | (channel << card->shift_count) | 0x02 , base); + outw(0x8000 | (channel << card->shift_count) | 0x02, base); outw((queue << 8) | 0x06, base); - InterruptTheCard(base); + InterruptTheCard(base); unlock_card(card); } - -/* - * Firmware loader driver specific routines. This needs to mostly die - * and be replaced with request_firmware. - */ - -static struct file_operations ISILoad_fops = { - .owner = THIS_MODULE, - .ioctl = ISILoad_ioctl, -}; - -static struct miscdevice isiloader_device = { - ISILOAD_MISC_MINOR, "isictl", &ISILoad_fops -}; - - -static inline int WaitTillCardIsFree(unsigned short base) -{ - unsigned long count=0; - while( (!(inw(base+0xe) & 0x1)) && (count++ < 6000000)); - if (inw(base+0xe)&0x1) - return 0; - else - return 1; -} - -static int ISILoad_ioctl(struct inode *inode, struct file *filp, - unsigned int cmd, unsigned long arg) -{ - unsigned int card, i, j, signature, status, portcount = 0; - unsigned long t; - unsigned short word_count, base; - bin_frame frame; - void __user *argp = (void __user *)arg; - /* exec_record exec_rec; */ - - if(get_user(card, (int __user *)argp)) - return -EFAULT; - - if(card < 0 || card >= BOARD_COUNT) - return -ENXIO; - - base=isi_card[card].base; - - if(base==0) - return -ENXIO; /* disabled or not used */ - - switch(cmd) { - case MIOCTL_RESET_CARD: - if (!capable(CAP_SYS_ADMIN)) - return -EPERM; - printk(KERN_DEBUG "ISILoad:Resetting Card%d at 0x%x ",card+1,base); - - inw(base+0x8); - - for(t=jiffies+HZ/100;time_before(jiffies, t);); - - outw(0,base+0x8); /* Reset */ - - for(j=1;j<=3;j++) { - for(t=jiffies+HZ;time_before(jiffies, t);); - printk("."); - } - signature=(inw(base+0x4)) & 0xff; - if (isi_card[card].isa) { - - if (!(inw(base+0xe) & 0x1) || (inw(base+0x2))) { -#ifdef ISICOM_DEBUG - printk("\nbase+0x2=0x%x , base+0xe=0x%x",inw(base+0x2),inw(base+0xe)); -#endif - printk("\nISILoad:ISA Card%d reset failure (Possible bad I/O Port Address 0x%x).\n",card+1,base); - return -EIO; - } - } - else { - portcount = inw(base+0x2); - if (!(inw(base+0xe) & 0x1) || ((portcount!=0) && (portcount!=4) && (portcount!=8))) { -#ifdef ISICOM_DEBUG - printk("\nbase+0x2=0x%x , base+0xe=0x%x",inw(base+0x2),inw(base+0xe)); -#endif - printk("\nISILoad:PCI Card%d reset failure (Possible bad I/O Port Address 0x%x).\n",card+1,base); - return -EIO; - } - } - switch(signature) { - case 0xa5: - case 0xbb: - case 0xdd: - if (isi_card[card].isa) - isi_card[card].port_count = 8; - else { - if (portcount == 4) - isi_card[card].port_count = 4; - else - isi_card[card].port_count = 8; - } - isi_card[card].shift_count = 12; - break; - - case 0xcc: isi_card[card].port_count = 16; - isi_card[card].shift_count = 11; - break; - - default: printk("ISILoad:Card%d reset failure (Possible bad I/O Port Address 0x%x).\n",card+1,base); -#ifdef ISICOM_DEBUG - printk("Sig=0x%x\n",signature); -#endif - return -EIO; - } - printk("-Done\n"); - return put_user(signature,(unsigned __user *)argp); - - case MIOCTL_LOAD_FIRMWARE: - if (!capable(CAP_SYS_ADMIN)) - return -EPERM; - - if(copy_from_user(&frame, argp, sizeof(bin_frame))) - return -EFAULT; - - if (WaitTillCardIsFree(base)) - return -EIO; - - outw(0xf0,base); /* start upload sequence */ - outw(0x00,base); - outw((frame.addr), base);/* lsb of adderess */ - - word_count=(frame.count >> 1) + frame.count % 2; - outw(word_count, base); - InterruptTheCard(base); - - for(i=0;i<=0x2f;i++); /* a wee bit of delay */ - - if (WaitTillCardIsFree(base)) - return -EIO; - - if ((status=inw(base+0x4))!=0) { - printk(KERN_WARNING "ISILoad:Card%d rejected load header:\nAddress:0x%x \nCount:0x%x \nStatus:0x%x \n", - card+1, frame.addr, frame.count, status); - return -EIO; - } - outsw(base, (void *) frame.bin_data, word_count); - - InterruptTheCard(base); - - for(i=0;i<=0x0f;i++); /* another wee bit of delay */ - - if (WaitTillCardIsFree(base)) - return -EIO; - - if ((status=inw(base+0x4))!=0) { - printk(KERN_ERR "ISILoad:Card%d got out of sync.Card Status:0x%x\n",card+1, status); - return -EIO; - } - return 0; - - case MIOCTL_READ_FIRMWARE: - if (!capable(CAP_SYS_ADMIN)) - return -EPERM; - - if(copy_from_user(&frame, argp, sizeof(bin_header))) - return -EFAULT; - - if (WaitTillCardIsFree(base)) - return -EIO; - - outw(0xf1,base); /* start download sequence */ - outw(0x00,base); - outw((frame.addr), base);/* lsb of adderess */ - - word_count=(frame.count >> 1) + frame.count % 2; - outw(word_count+1, base); - InterruptTheCard(base); - - for(i=0;i<=0xf;i++); /* a wee bit of delay */ - - if (WaitTillCardIsFree(base)) - return -EIO; - - if ((status=inw(base+0x4))!=0) { - printk(KERN_WARNING "ISILoad:Card%d rejected verify header:\nAddress:0x%x \nCount:0x%x \nStatus:0x%x \n", - card+1, frame.addr, frame.count, status); - return -EIO; - } - - inw(base); - insw(base, frame.bin_data, word_count); - InterruptTheCard(base); - - for(i=0;i<=0x0f;i++); /* another wee bit of delay */ - - if (WaitTillCardIsFree(base)) - return -EIO; - - if ((status=inw(base+0x4))!=0) { - printk(KERN_ERR "ISILoad:Card%d verify got out of sync.Card Status:0x%x\n",card+1, status); - return -EIO; - } - - if(copy_to_user(argp, &frame, sizeof(bin_frame))) - return -EFAULT; - return 0; - - case MIOCTL_XFER_CTRL: - if (!capable(CAP_SYS_ADMIN)) - return -EPERM; - if (WaitTillCardIsFree(base)) - return -EIO; - - outw(0xf2, base); - outw(0x800, base); - outw(0x0, base); - outw(0x0, base); - InterruptTheCard(base); - outw(0x0, base+0x4); /* for ISI4608 cards */ - - isi_card[card].status |= FIRMWARE_LOADED; - return 0; - - default: -#ifdef ISICOM_DEBUG - printk(KERN_DEBUG "ISILoad: Received Ioctl cmd 0x%x.\n", cmd); -#endif - return -ENOIOCTLCMD; - - } - -} - - /* * ISICOM Driver specific routines ... * */ - -static inline int isicom_paranoia_check(struct isi_port const * port, char *name, - const char * routine) + +static inline int __isicom_paranoia_check(struct isi_port const *port, + char *name, const char *routine) { -#ifdef ISICOM_DEBUG - static const char * badmagic = - KERN_WARNING "ISICOM: Warning: bad isicom magic for dev %s in %s.\n"; - static const char * badport = - KERN_WARNING "ISICOM: Warning: NULL isicom port for dev %s in %s.\n"; if (!port) { - printk(badport, name, routine); + printk(KERN_WARNING "ISICOM: Warning: bad isicom magic for " + "dev %s in %s.\n", name, routine); return 1; } if (port->magic != ISICOM_MAGIC) { - printk(badmagic, name, routine); + printk(KERN_WARNING "ISICOM: Warning: NULL isicom port for " + "dev %s in %s.\n", name, routine); return 1; - } -#endif + } + return 0; } - + /* - * Transmitter. + * Transmitter. * * We shovel data into the card buffers on a regular basis. The card * will do the rest of the work for us. @@ -635,25 +417,21 @@ static void isicom_tx(unsigned long _data) { short count = (BOARD_COUNT-1), card, base; short txcount, wrd, residue, word_count, cnt; - struct isi_port * port; - struct tty_struct * tty; - -#ifdef ISICOM_DEBUG - ++tx_count; -#endif - + struct isi_port *port; + struct tty_struct *tty; + /* find next active board */ card = (prev_card + 1) & 0x0003; while(count-- > 0) { - if (isi_card[card].status & BOARD_ACTIVE) + if (isi_card[card].status & BOARD_ACTIVE) break; - card = (card + 1) & 0x0003; + card = (card + 1) & 0x0003; } if (!(isi_card[card].status & BOARD_ACTIVE)) goto sched_again; - + prev_card = card; - + count = isi_card[card].port_count; port = isi_card[card].ports; base = isi_card[card].base; @@ -662,18 +440,18 @@ static void isicom_tx(unsigned long _data) continue; /* port not active or tx disabled to force flow control */ if (!(port->flags & ASYNC_INITIALIZED) || - !(port->status & ISI_TXOK)) + !(port->status & ISI_TXOK)) unlock_card(&isi_card[card]); continue; - + tty = port->tty; - - - if(tty == NULL) { + + + if (tty == NULL) { unlock_card(&isi_card[card]); continue; } - + txcount = min_t(short, TX_SIZE, port->xmit_cnt); if (txcount <= 0 || tty->stopped || tty->hw_stopped) { unlock_card(&isi_card[card]); @@ -681,44 +459,45 @@ static void isicom_tx(unsigned long _data) } if (!(inw(base + 0x02) & (1 << port->channel))) { unlock_card(&isi_card[card]); - continue; + continue; } -#ifdef ISICOM_DEBUG - printk(KERN_DEBUG "ISICOM: txing %d bytes, port%d.\n", - txcount, port->channel+1); -#endif - outw((port->channel << isi_card[card].shift_count) | txcount - , base); + pr_dbg("txing %d bytes, port%d.\n", txcount, + port->channel + 1); + outw((port->channel << isi_card[card].shift_count) | txcount, + base); residue = NO; - wrd = 0; + wrd = 0; while (1) { - cnt = min_t(int, txcount, (SERIAL_XMIT_SIZE - port->xmit_tail)); + cnt = min_t(int, txcount, (SERIAL_XMIT_SIZE + - port->xmit_tail)); if (residue == YES) { residue = NO; if (cnt > 0) { - wrd |= (port->xmit_buf[port->xmit_tail] << 8); - port->xmit_tail = (port->xmit_tail + 1) & (SERIAL_XMIT_SIZE - 1); + wrd |= (port->xmit_buf[port->xmit_tail] + << 8); + port->xmit_tail = (port->xmit_tail + 1) + & (SERIAL_XMIT_SIZE - 1); port->xmit_cnt--; txcount--; cnt--; - outw(wrd, base); - } - else { + outw(wrd, base); + } else { outw(wrd, base); break; } - } + } if (cnt <= 0) break; word_count = cnt >> 1; - outsw(base, port->xmit_buf+port->xmit_tail, word_count); - port->xmit_tail = (port->xmit_tail + (word_count << 1)) & - (SERIAL_XMIT_SIZE - 1); + outsw(base, port->xmit_buf+port->xmit_tail,word_count); + port->xmit_tail = (port->xmit_tail + + (word_count << 1)) & (SERIAL_XMIT_SIZE - 1); txcount -= (word_count << 1); port->xmit_cnt -= (word_count << 1); if (cnt & 0x0001) { residue = YES; wrd = port->xmit_buf[port->xmit_tail]; - port->xmit_tail = (port->xmit_tail + 1) & (SERIAL_XMIT_SIZE - 1); + port->xmit_tail = (port->xmit_tail + 1) + & (SERIAL_XMIT_SIZE - 1); port->xmit_cnt--; txcount--; } @@ -730,81 +509,82 @@ static void isicom_tx(unsigned long _data) if (port->xmit_cnt <= WAKEUP_CHARS) schedule_work(&port->bh_tqueue); unlock_card(&isi_card[card]); - } + } + + /* schedule another tx for hopefully in about 10ms */ +sched_again: + if (!re_schedule) { + re_schedule = 2; + return; + } - /* schedule another tx for hopefully in about 10ms */ -sched_again: - if (!re_schedule) - return; init_timer(&tx); tx.expires = jiffies + HZ/100; tx.data = 0; tx.function = isicom_tx; add_timer(&tx); - - return; -} - + + return; +} + /* Interrupt handlers */ - -static void isicom_bottomhalf(void * data) + +static void isicom_bottomhalf(void *data) { - struct isi_port * port = (struct isi_port *) data; - struct tty_struct * tty = port->tty; - + struct isi_port *port = (struct isi_port *) data; + struct tty_struct *tty = port->tty; + if (!tty) return; - tty_wakeup(tty); + tty_wakeup(tty); wake_up_interruptible(&tty->write_wait); -} - +} + /* - * Main interrupt handler routine + * Main interrupt handler routine */ - -static irqreturn_t isicom_interrupt(int irq, void *dev_id, - struct pt_regs *regs) + +static irqreturn_t isicom_interrupt(int irq, void *dev_id, struct pt_regs *regs) { - struct isi_board * card; - struct isi_port * port; - struct tty_struct * tty; - unsigned short base, header, word_count, count; - unsigned char channel; + struct isi_board *card = dev_id; + struct isi_port *port; + struct tty_struct *tty; + unsigned long base; + u16 header, word_count, count, channel; short byte_count; - - card = (struct isi_board *) dev_id; + unsigned char *rp; if (!card || !(card->status & FIRMWARE_LOADED)) return IRQ_NONE; - + base = card->base; spin_lock(&card->card_lock); - + if (card->isa == NO) { /* - * disable any interrupts from the PCI card and lower the - * interrupt line + * disable any interrupts from the PCI card and lower the + * interrupt line */ outw(0x8000, base+0x04); ClearInterrupt(base); } - + inw(base); /* get the dummy word out */ header = inw(base); channel = (header & 0x7800) >> card->shift_count; byte_count = header & 0xff; if (channel + 1 > card->port_count) { - printk(KERN_WARNING "ISICOM: isicom_interrupt(0x%x): %d(channel) > port_count.\n", - base, channel+1); + printk(KERN_WARNING "ISICOM: isicom_interrupt(0x%lx): " + "%d(channel) > port_count.\n", base, channel+1); if (card->isa) ClearInterrupt(base); else - outw(0x0000, base+0x04); /* enable interrupts */ + outw(0x0000, base+0x04); /* enable interrupts */ spin_unlock(&card->card_lock); - return IRQ_HANDLED; + return IRQ_HANDLED; } port = card->ports + channel; if (!(port->flags & ASYNC_INITIALIZED)) { @@ -813,8 +593,8 @@ static irqreturn_t isicom_interrupt(int irq, void *dev_id, else outw(0x0000, base+0x04); /* enable interrupts */ return IRQ_HANDLED; - } - + } + tty = port->tty; if (tty == NULL) { word_count = byte_count >> 1; @@ -831,224 +611,204 @@ static irqreturn_t isicom_interrupt(int irq, void *dev_id, spin_unlock(&card->card_lock); return IRQ_HANDLED; } - + if (header & 0x8000) { /* Status Packet */ header = inw(base); switch(header & 0xff) { - case 0: /* Change in EIA signals */ - - if (port->flags & ASYNC_CHECK_CD) { - if (port->status & ISI_DCD) { - if (!(header & ISI_DCD)) { - /* Carrier has been lost */ -#ifdef ISICOM_DEBUG - printk(KERN_DEBUG "ISICOM: interrupt: DCD->low.\n"); -#endif - port->status &= ~ISI_DCD; - schedule_work(&port->hangup_tq); - } - } - else { - if (header & ISI_DCD) { - /* Carrier has been detected */ -#ifdef ISICOM_DEBUG - printk(KERN_DEBUG "ISICOM: interrupt: DCD->high.\n"); -#endif - port->status |= ISI_DCD; - wake_up_interruptible(&port->open_wait); - } - } - } - else { - if (header & ISI_DCD) - port->status |= ISI_DCD; - else + case 0: /* Change in EIA signals */ + if (port->flags & ASYNC_CHECK_CD) { + if (port->status & ISI_DCD) { + if (!(header & ISI_DCD)) { + /* Carrier has been lost */ + pr_dbg("interrupt: DCD->low.\n" + ); port->status &= ~ISI_DCD; - } - - if (port->flags & ASYNC_CTS_FLOW) { - if (port->tty->hw_stopped) { - if (header & ISI_CTS) { - port->tty->hw_stopped = 0; - /* start tx ing */ - port->status |= (ISI_TXOK | ISI_CTS); - schedule_work(&port->bh_tqueue); - } - } - else { - if (!(header & ISI_CTS)) { - port->tty->hw_stopped = 1; - /* stop tx ing */ - port->status &= ~(ISI_TXOK | ISI_CTS); - } + schedule_work(&port->hangup_tq); } + } else if (header & ISI_DCD) { + /* Carrier has been detected */ + pr_dbg("interrupt: DCD->high.\n"); + port->status |= ISI_DCD; + wake_up_interruptible(&port->open_wait); } - else { - if (header & ISI_CTS) - port->status |= ISI_CTS; - else - port->status &= ~ISI_CTS; - } - - if (header & ISI_DSR) - port->status |= ISI_DSR; + } else { + if (header & ISI_DCD) + port->status |= ISI_DCD; else - port->status &= ~ISI_DSR; - - if (header & ISI_RI) - port->status |= ISI_RI; + port->status &= ~ISI_DCD; + } + + if (port->flags & ASYNC_CTS_FLOW) { + if (port->tty->hw_stopped) { + if (header & ISI_CTS) { + port->tty->hw_stopped = 0; + /* start tx ing */ + port->status |= (ISI_TXOK + | ISI_CTS); + schedule_work(&port->bh_tqueue); + } + } else if (!(header & ISI_CTS)) { + port->tty->hw_stopped = 1; + /* stop tx ing */ + port->status &= ~(ISI_TXOK | ISI_CTS); + } + } else { + if (header & ISI_CTS) + port->status |= ISI_CTS; else - port->status &= ~ISI_RI; - - break; - - case 1: /* Received Break !!! */ - if (tty->flip.count >= TTY_FLIPBUF_SIZE) - break; - *tty->flip.flag_buf_ptr++ = TTY_BREAK; - *tty->flip.char_buf_ptr++ = 0; - tty->flip.count++; - if (port->flags & ASYNC_SAK) - do_SAK(tty); - schedule_delayed_work(&tty->flip.work, 1); - break; - - case 2: /* Statistics */ - printk(KERN_DEBUG "ISICOM: isicom_interrupt: stats!!!.\n"); - break; - - default: - printk(KERN_WARNING "ISICOM: Intr: Unknown code in status packet.\n"); - break; - } - } - else { /* Data Packet */ - count = min_t(unsigned short, byte_count, (TTY_FLIPBUF_SIZE - tty->flip.count)); -#ifdef ISICOM_DEBUG - printk(KERN_DEBUG "ISICOM: Intr: Can rx %d of %d bytes.\n", - count, byte_count); -#endif + port->status &= ~ISI_CTS; + } + + if (header & ISI_DSR) + port->status |= ISI_DSR; + else + port->status &= ~ISI_DSR; + + if (header & ISI_RI) + port->status |= ISI_RI; + else + port->status &= ~ISI_RI; + + break; + + case 1: /* Received Break !!! */ + tty_insert_flip_char(tty, 0, TTY_BREAK); + if (port->flags & ASYNC_SAK) + do_SAK(tty); + tty_flip_buffer_push(tty); + break; + + case 2: /* Statistics */ + pr_dbg("isicom_interrupt: stats!!!.\n"); + break; + + default: + pr_dbg("Intr: Unknown code in status packet.\n"); + break; + } + } else { /* Data Packet */ + + count = tty_prepare_flip_string(tty, &rp, byte_count & ~1); + pr_dbg("Intr: Can rx %d of %d bytes.\n", count, byte_count); word_count = count >> 1; - insw(base, tty->flip.char_buf_ptr, word_count); - tty->flip.char_buf_ptr += (word_count << 1); + insw(base, rp, word_count); byte_count -= (word_count << 1); if (count & 0x0001) { - *tty->flip.char_buf_ptr++ = (char)(inw(base) & 0xff); + tty_insert_flip_char(tty, inw(base) & 0xff, + TTY_NORMAL); byte_count -= 2; - } - memset(tty->flip.flag_buf_ptr, 0, count); - tty->flip.flag_buf_ptr += count; - tty->flip.count += count; - + } if (byte_count > 0) { - printk(KERN_DEBUG "ISICOM: Intr(0x%x:%d): Flip buffer overflow! dropping bytes...\n", - base, channel+1); + pr_dbg("Intr(0x%lx:%d): Flip buffer overflow! dropping " + "bytes...\n", base, channel + 1); while(byte_count > 0) { /* drain out unread xtra data */ inw(base); byte_count -= 2; } } - schedule_delayed_work(&tty->flip.work, 1); + tty_flip_buffer_push(tty); } if (card->isa == YES) ClearInterrupt(base); else - outw(0x0000, base+0x04); /* enable interrupts */ + outw(0x0000, base+0x04); /* enable interrupts */ + return IRQ_HANDLED; -} +} -static void isicom_config_port(struct isi_port * port) +static void isicom_config_port(struct isi_port *port) { - struct isi_board * card = port->card; - struct tty_struct * tty; + struct isi_board *card = port->card; + struct tty_struct *tty; unsigned long baud; - unsigned short channel_setup, base = card->base; - unsigned short channel = port->channel, shift_count = card->shift_count; + unsigned long base = card->base; + u16 channel_setup, channel = port->channel, + shift_count = card->shift_count; unsigned char flow_ctrl; - + if (!(tty = port->tty) || !tty->termios) return; baud = C_BAUD(tty); if (baud & CBAUDEX) { baud &= ~CBAUDEX; - + /* if CBAUDEX bit is on and the baud is set to either 50 or 75 * then the card is programmed for 57.6Kbps or 115Kbps * respectively. - */ - + */ + if (baud < 1 || baud > 2) port->tty->termios->c_cflag &= ~CBAUDEX; else baud += 15; - } + } if (baud == 15) { - - /* the ASYNC_SPD_HI and ASYNC_SPD_VHI options are set + + /* the ASYNC_SPD_HI and ASYNC_SPD_VHI options are set * by the set_serial_info ioctl ... this is done by * the 'setserial' utility. - */ - + */ + if ((port->flags & ASYNC_SPD_MASK) == ASYNC_SPD_HI) - baud++; /* 57.6 Kbps */ + baud++; /* 57.6 Kbps */ if ((port->flags & ASYNC_SPD_MASK) == ASYNC_SPD_VHI) - baud +=2; /* 115 Kbps */ + baud +=2; /* 115 Kbps */ } if (linuxb_to_isib[baud] == -1) { /* hang up */ - drop_dtr(port); - return; - } - else + drop_dtr(port); + return; + } + else raise_dtr(port); - + if (lock_card(card)) { outw(0x8000 | (channel << shift_count) |0x03, base); outw(linuxb_to_isib[baud] << 8 | 0x03, base); channel_setup = 0; switch(C_CSIZE(tty)) { - case CS5: - channel_setup |= ISICOM_CS5; - break; - case CS6: - channel_setup |= ISICOM_CS6; - break; - case CS7: - channel_setup |= ISICOM_CS7; - break; - case CS8: - channel_setup |= ISICOM_CS8; - break; + case CS5: + channel_setup |= ISICOM_CS5; + break; + case CS6: + channel_setup |= ISICOM_CS6; + break; + case CS7: + channel_setup |= ISICOM_CS7; + break; + case CS8: + channel_setup |= ISICOM_CS8; + break; } - + if (C_CSTOPB(tty)) channel_setup |= ISICOM_2SB; if (C_PARENB(tty)) { channel_setup |= ISICOM_EVPAR; if (C_PARODD(tty)) - channel_setup |= ISICOM_ODPAR; + channel_setup |= ISICOM_ODPAR; } - outw(channel_setup, base); + outw(channel_setup, base); InterruptTheCard(base); - unlock_card(card); - } + unlock_card(card); + } if (C_CLOCAL(tty)) port->flags &= ~ASYNC_CHECK_CD; else - port->flags |= ASYNC_CHECK_CD; - + port->flags |= ASYNC_CHECK_CD; + /* flow control settings ...*/ flow_ctrl = 0; port->flags &= ~ASYNC_CTS_FLOW; if (C_CRTSCTS(tty)) { port->flags |= ASYNC_CTS_FLOW; flow_ctrl |= ISICOM_CTSRTS; - } - if (I_IXON(tty)) + } + if (I_IXON(tty)) flow_ctrl |= ISICOM_RESPOND_XONXOFF; if (I_IXOFF(tty)) - flow_ctrl |= ISICOM_INITIATE_XONXOFF; - + flow_ctrl |= ISICOM_INITIATE_XONXOFF; + if (lock_card(card)) { outw(0x8000 | (channel << shift_count) |0x04, base); outw(flow_ctrl << 8 | 0x05, base); @@ -1056,22 +816,22 @@ static void isicom_config_port(struct isi_port * port) InterruptTheCard(base); unlock_card(card); } - + /* rx enabled -> enable port for rx on the card */ if (C_CREAD(tty)) { card->port_status |= (1 << channel); outw(card->port_status, base + 0x02); } } - -/* open et all */ -static inline void isicom_setup_board(struct isi_board * bp) +/* open et all */ + +static inline void isicom_setup_board(struct isi_board *bp) { int channel; - struct isi_port * port; + struct isi_port *port; unsigned long flags; - + spin_lock_irqsave(&bp->card_lock, flags); if (bp->status & BOARD_ACTIVE) { spin_unlock_irqrestore(&bp->card_lock, flags); @@ -1080,53 +840,54 @@ static inline void isicom_setup_board(struct isi_board * bp) port = bp->ports; bp->status |= BOARD_ACTIVE; spin_unlock_irqrestore(&bp->card_lock, flags); - for(channel = 0; channel < bp->port_count; channel++, port++) + for (channel = 0; channel < bp->port_count; channel++, port++) drop_dtr_rts(port); return; } - -static int isicom_setup_port(struct isi_port * port) + +static int isicom_setup_port(struct isi_port *port) { - struct isi_board * card = port->card; + struct isi_board *card = port->card; unsigned long flags; - + if (port->flags & ASYNC_INITIALIZED) { return 0; } if (!port->xmit_buf) { unsigned long page; - + if (!(page = get_zeroed_page(GFP_KERNEL))) return -ENOMEM; - + if (port->xmit_buf) { free_page(page); return -ERESTARTSYS; } - port->xmit_buf = (unsigned char *) page; - } + port->xmit_buf = (unsigned char *) page; + } spin_lock_irqsave(&card->card_lock, flags); if (port->tty) clear_bit(TTY_IO_ERROR, &port->tty->flags); if (port->count == 1) card->count++; - + port->xmit_cnt = port->xmit_head = port->xmit_tail = 0; - + /* discard any residual data */ kill_queue(port, ISICOM_KILLTX | ISICOM_KILLRX); - + isicom_config_port(port); port->flags |= ASYNC_INITIALIZED; spin_unlock_irqrestore(&card->card_lock, flags); - - return 0; -} - -static int block_til_ready(struct tty_struct * tty, struct file * filp, struct isi_port * port) + + return 0; +} + +static int block_til_ready(struct tty_struct *tty, struct file *filp, + struct isi_port *port) { - struct isi_board * card = port->card; + struct isi_board *card = port->card; int do_clocal = 0, retval; unsigned long flags; DECLARE_WAITQUEUE(wait, current); @@ -1134,30 +895,27 @@ static int block_til_ready(struct tty_struct * tty, struct file * filp, struct i /* block if port is in the process of being closed */ if (tty_hung_up_p(filp) || port->flags & ASYNC_CLOSING) { -#ifdef ISICOM_DEBUG - printk(KERN_DEBUG "ISICOM: block_til_ready: close in progress.\n"); -#endif + pr_dbg("block_til_ready: close in progress.\n"); interruptible_sleep_on(&port->close_wait); if (port->flags & ASYNC_HUP_NOTIFY) return -EAGAIN; else return -ERESTARTSYS; } - + /* if non-blocking mode is set ... */ - - if ((filp->f_flags & O_NONBLOCK) || (tty->flags & (1 << TTY_IO_ERROR))) { -#ifdef ISICOM_DEBUG - printk(KERN_DEBUG "ISICOM: block_til_ready: non-block mode.\n"); -#endif + + if ((filp->f_flags & O_NONBLOCK) || + (tty->flags & (1 << TTY_IO_ERROR))) { + pr_dbg("block_til_ready: non-block mode.\n"); port->flags |= ASYNC_NORMAL_ACTIVE; - return 0; - } - + return 0; + } + if (C_CLOCAL(tty)) do_clocal = 1; - - /* block waiting for DCD to be asserted, and while + + /* block waiting for DCD to be asserted, and while callout dev is busy */ retval = 0; add_wait_queue(&port->open_wait, &wait); @@ -1167,27 +925,27 @@ static int block_til_ready(struct tty_struct * tty, struct file * filp, struct i port->count--; port->blocked_open++; spin_unlock_irqrestore(&card->card_lock, flags); - + while (1) { raise_dtr_rts(port); set_current_state(TASK_INTERRUPTIBLE); - if (tty_hung_up_p(filp) || !(port->flags & ASYNC_INITIALIZED)) { + if (tty_hung_up_p(filp) || !(port->flags & ASYNC_INITIALIZED)) { if (port->flags & ASYNC_HUP_NOTIFY) retval = -EAGAIN; else retval = -ERESTARTSYS; break; - } + } if (!(port->flags & ASYNC_CLOSING) && - (do_clocal || (port->status & ISI_DCD))) { + (do_clocal || (port->status & ISI_DCD))) { break; - } + } if (signal_pending(current)) { retval = -ERESTARTSYS; break; } - schedule(); + schedule(); } set_current_state(TASK_RUNNING); remove_wait_queue(&port->open_wait, &wait); @@ -1201,11 +959,11 @@ static int block_til_ready(struct tty_struct * tty, struct file * filp, struct i port->flags |= ASYNC_NORMAL_ACTIVE; return 0; } - -static int isicom_open(struct tty_struct * tty, struct file * filp) + +static int isicom_open(struct tty_struct *tty, struct file *filp) { - struct isi_port * port; - struct isi_board * card; + struct isi_port *port; + struct isi_board *card; unsigned int line, board; int error; @@ -1214,20 +972,20 @@ static int isicom_open(struct tty_struct * tty, struct file * filp) return -ENODEV; board = BOARD(line); card = &isi_card[board]; - + if (!(card->status & FIRMWARE_LOADED)) return -ENODEV; - + /* open on a port greater than the port count for the card !!! */ if (line > ((board * 16) + card->port_count - 1)) return -ENODEV; - port = &isi_ports[line]; + port = &isi_ports[line]; if (isicom_paranoia_check(port, tty->name, "isicom_open")) return -ENODEV; - - isicom_setup_board(card); - + + isicom_setup_board(card); + port->count++; tty->driver_data = port; port->tty = tty; @@ -1236,12 +994,12 @@ static int isicom_open(struct tty_struct * tty, struct file * filp) if ((error = block_til_ready(tty, filp, port))!=0) return error; - return 0; + return 0; } - + /* close et all */ -static inline void isicom_shutdown_board(struct isi_board * bp) +static inline void isicom_shutdown_board(struct isi_board *bp) { unsigned long flags; @@ -1252,15 +1010,15 @@ static inline void isicom_shutdown_board(struct isi_board * bp) spin_unlock_irqrestore(&bp->card_lock, flags); } -static void isicom_shutdown_port(struct isi_port * port) +static void isicom_shutdown_port(struct isi_port *port) { - struct isi_board * card = port->card; - struct tty_struct * tty; + struct isi_board *card = port->card; + struct tty_struct *tty; unsigned long flags; - + tty = port->tty; - spin_lock_irqsave(&card->card_lock, flags); + spin_lock_irqsave(&card->card_lock, flags); if (!(port->flags & ASYNC_INITIALIZED)) { spin_unlock_irqrestore(&card->card_lock, flags); return; @@ -1268,93 +1026,91 @@ static void isicom_shutdown_port(struct isi_port * port) if (port->xmit_buf) { free_page((unsigned long) port->xmit_buf); port->xmit_buf = NULL; - } + } port->flags &= ~ASYNC_INITIALIZED; /* 3rd October 2000 : Vinayak P Risbud */ port->tty = NULL; spin_unlock_irqrestore(&card->card_lock, flags); - + /*Fix done by Anil .S on 30-04-2001 remote login through isi port has dtr toggle problem due to which the carrier drops before the password prompt - appears on the remote end. Now we drop the dtr only if the + appears on the remote end. Now we drop the dtr only if the HUPCL(Hangup on close) flag is set for the tty*/ - - if (C_HUPCL(tty)) + + if (C_HUPCL(tty)) /* drop dtr on this port */ drop_dtr(port); - - /* any other port uninits */ + + /* any other port uninits */ if (tty) set_bit(TTY_IO_ERROR, &tty->flags); - + if (--card->count < 0) { - printk(KERN_DEBUG "ISICOM: isicom_shutdown_port: bad board(0x%x) count %d.\n", + pr_dbg("isicom_shutdown_port: bad board(0x%lx) count %d.\n", card->base, card->count); - card->count = 0; + card->count = 0; } - - /* last port was closed , shutdown that boad too */ - if(C_HUPCL(tty)) { + + /* last port was closed, shutdown that boad too */ + if (C_HUPCL(tty)) { if (!card->count) isicom_shutdown_board(card); } } -static void isicom_close(struct tty_struct * tty, struct file * filp) +static void isicom_close(struct tty_struct *tty, struct file *filp) { - struct isi_port * port = (struct isi_port *) tty->driver_data; - struct isi_board * card = port->card; + struct isi_port *port = tty->driver_data; + struct isi_board *card = port->card; unsigned long flags; - + if (!port) return; if (isicom_paranoia_check(port, tty->name, "isicom_close")) return; - -#ifdef ISICOM_DEBUG - printk(KERN_DEBUG "ISICOM: Close start!!!.\n"); -#endif - + + pr_dbg("Close start!!!.\n"); + spin_lock_irqsave(&card->card_lock, flags); if (tty_hung_up_p(filp)) { spin_unlock_irqrestore(&card->card_lock, flags); return; } - + if (tty->count == 1 && port->count != 1) { - printk(KERN_WARNING "ISICOM:(0x%x) isicom_close: bad port count" - "tty->count = 1 port count = %d.\n", + printk(KERN_WARNING "ISICOM:(0x%lx) isicom_close: bad port " + "count tty->count = 1 port count = %d.\n", card->base, port->count); port->count = 1; } if (--port->count < 0) { - printk(KERN_WARNING "ISICOM:(0x%x) isicom_close: bad port count for" - "channel%d = %d", card->base, port->channel, + printk(KERN_WARNING "ISICOM:(0x%lx) isicom_close: bad port " + "count for channel%d = %d", card->base, port->channel, port->count); - port->count = 0; + port->count = 0; } - + if (port->count) { spin_unlock_irqrestore(&card->card_lock, flags); return; - } + } port->flags |= ASYNC_CLOSING; tty->closing = 1; spin_unlock_irqrestore(&card->card_lock, flags); - + if (port->closing_wait != ASYNC_CLOSING_WAIT_NONE) tty_wait_until_sent(tty, port->closing_wait); - /* indicate to the card that no more data can be received + /* indicate to the card that no more data can be received on this port */ spin_lock_irqsave(&card->card_lock, flags); - if (port->flags & ASYNC_INITIALIZED) { + if (port->flags & ASYNC_INITIALIZED) { card->port_status &= ~(1 << port->channel); outw(card->port_status, card->base + 0x02); - } + } isicom_shutdown_port(port); spin_unlock_irqrestore(&card->card_lock, flags); - + if (tty->driver->flush_buffer) tty->driver->flush_buffer(tty); tty_ldisc_flush(tty); @@ -1365,65 +1121,65 @@ static void isicom_close(struct tty_struct * tty, struct file * filp) if (port->blocked_open) { spin_unlock_irqrestore(&card->card_lock, flags); if (port->close_delay) { -#ifdef ISICOM_DEBUG - printk(KERN_DEBUG "ISICOM: scheduling until time out.\n"); -#endif - msleep_interruptible(jiffies_to_msecs(port->close_delay)); + pr_dbg("scheduling until time out.\n"); + msleep_interruptible( + jiffies_to_msecs(port->close_delay)); } spin_lock_irqsave(&card->card_lock, flags); wake_up_interruptible(&port->open_wait); - } + } port->flags &= ~(ASYNC_NORMAL_ACTIVE | ASYNC_CLOSING); wake_up_interruptible(&port->close_wait); spin_unlock_irqrestore(&card->card_lock, flags); } /* write et all */ -static int isicom_write(struct tty_struct * tty, - const unsigned char * buf, int count) +static int isicom_write(struct tty_struct *tty, const unsigned char *buf, + int count) { - struct isi_port * port = (struct isi_port *) tty->driver_data; - struct isi_board * card = port->card; + struct isi_port *port = tty->driver_data; + struct isi_board *card = port->card; unsigned long flags; int cnt, total = 0; if (isicom_paranoia_check(port, tty->name, "isicom_write")) return 0; - - if (!tty || !port->xmit_buf || !tmp_buf) + + if (!tty || !port->xmit_buf) return 0; - + spin_lock_irqsave(&card->card_lock, flags); - - while(1) { - cnt = min_t(int, count, min(SERIAL_XMIT_SIZE - port->xmit_cnt - 1, - SERIAL_XMIT_SIZE - port->xmit_head)); - if (cnt <= 0) + + while(1) { + cnt = min_t(int, count, min(SERIAL_XMIT_SIZE - port->xmit_cnt + - 1, SERIAL_XMIT_SIZE - port->xmit_head)); + if (cnt <= 0) break; - + memcpy(port->xmit_buf + port->xmit_head, buf, cnt); - port->xmit_head = (port->xmit_head + cnt) & (SERIAL_XMIT_SIZE - 1); + port->xmit_head = (port->xmit_head + cnt) & (SERIAL_XMIT_SIZE + - 1); port->xmit_cnt += cnt; buf += cnt; count -= cnt; total += cnt; - } + } if (port->xmit_cnt && !tty->stopped && !tty->hw_stopped) port->status |= ISI_TXOK; spin_unlock_irqrestore(&card->card_lock, flags); - return total; + return total; } /* put_char et all */ -static void isicom_put_char(struct tty_struct * tty, unsigned char ch) +static void isicom_put_char(struct tty_struct *tty, unsigned char ch) { - struct isi_port * port = (struct isi_port *) tty->driver_data; - struct isi_board * card = port->card; + struct isi_port *port = tty->driver_data; + struct isi_board *card = port->card; unsigned long flags; - + if (isicom_paranoia_check(port, tty->name, "isicom_put_char")) return; - + if (!tty || !port->xmit_buf) return; @@ -1432,7 +1188,7 @@ static void isicom_put_char(struct tty_struct * tty, unsigned char ch) spin_unlock_irqrestore(&card->card_lock, flags); return; } - + port->xmit_buf[port->xmit_head++] = ch; port->xmit_head &= (SERIAL_XMIT_SIZE - 1); port->xmit_cnt++; @@ -1440,30 +1196,31 @@ static void isicom_put_char(struct tty_struct * tty, unsigned char ch) } /* flush_chars et all */ -static void isicom_flush_chars(struct tty_struct * tty) +static void isicom_flush_chars(struct tty_struct *tty) { - struct isi_port * port = (struct isi_port *) tty->driver_data; - + struct isi_port *port = tty->driver_data; + if (isicom_paranoia_check(port, tty->name, "isicom_flush_chars")) return; - - if (port->xmit_cnt <= 0 || tty->stopped || tty->hw_stopped || !port->xmit_buf) + + if (port->xmit_cnt <= 0 || tty->stopped || tty->hw_stopped || + !port->xmit_buf) return; - + /* this tells the transmitter to consider this port for data output to the card ... that's the best we can do. */ - port->status |= ISI_TXOK; + port->status |= ISI_TXOK; } /* write_room et all */ -static int isicom_write_room(struct tty_struct * tty) +static int isicom_write_room(struct tty_struct *tty) { - struct isi_port * port = (struct isi_port *) tty->driver_data; + struct isi_port *port = tty->driver_data; int free; if (isicom_paranoia_check(port, tty->name, "isicom_write_room")) return 0; - + free = SERIAL_XMIT_SIZE - port->xmit_cnt - 1; if (free < 0) free = 0; @@ -1471,23 +1228,24 @@ static int isicom_write_room(struct tty_struct * tty) } /* chars_in_buffer et all */ -static int isicom_chars_in_buffer(struct tty_struct * tty) +static int isicom_chars_in_buffer(struct tty_struct *tty) { - struct isi_port * port = (struct isi_port *) tty->driver_data; + struct isi_port *port = tty->driver_data; if (isicom_paranoia_check(port, tty->name, "isicom_chars_in_buffer")) return 0; return port->xmit_cnt; } /* ioctl et all */ -static inline void isicom_send_break(struct isi_port * port, unsigned long length) +static inline void isicom_send_break(struct isi_port *port, + unsigned long length) { - struct isi_board * card = port->card; - unsigned short base = card->base; - - if(!lock_card(card)) + struct isi_board *card = port->card; + unsigned long base = card->base; + + if (!lock_card(card)) return; - + outw(0x8000 | ((port->channel) << (card->shift_count)) | 0x3, base); outw((length & 0xff) << 8 | 0x00, base); outw((length & 0xff00), base); @@ -1498,13 +1256,13 @@ static inline void isicom_send_break(struct isi_port * port, unsigned long lengt static int isicom_tiocmget(struct tty_struct *tty, struct file *file) { - struct isi_port * port = (struct isi_port *) tty->driver_data; + struct isi_port *port = tty->driver_data; /* just send the port status */ - unsigned short status = port->status; + u16 status = port->status; if (isicom_paranoia_check(port, tty->name, "isicom_ioctl")) return -ENODEV; - + return ((status & ISI_RTS) ? TIOCM_RTS : 0) | ((status & ISI_DTR) ? TIOCM_DTR : 0) | ((status & ISI_DCD) ? TIOCM_CAR : 0) | @@ -1514,13 +1272,13 @@ static int isicom_tiocmget(struct tty_struct *tty, struct file *file) } static int isicom_tiocmset(struct tty_struct *tty, struct file *file, - unsigned int set, unsigned int clear) + unsigned int set, unsigned int clear) { - struct isi_port * port = (struct isi_port *) tty->driver_data; - + struct isi_port *port = tty->driver_data; + if (isicom_paranoia_check(port, tty->name, "isicom_ioctl")) return -ENODEV; - + if (set & TIOCM_RTS) raise_rts(port); if (set & TIOCM_DTR) @@ -1532,46 +1290,46 @@ static int isicom_tiocmset(struct tty_struct *tty, struct file *file, drop_dtr(port); return 0; -} +} -static int isicom_set_serial_info(struct isi_port * port, - struct serial_struct __user *info) +static int isicom_set_serial_info(struct isi_port *port, + struct serial_struct __user *info) { struct serial_struct newinfo; int reconfig_port; - if(copy_from_user(&newinfo, info, sizeof(newinfo))) + if (copy_from_user(&newinfo, info, sizeof(newinfo))) return -EFAULT; - - reconfig_port = ((port->flags & ASYNC_SPD_MASK) != - (newinfo.flags & ASYNC_SPD_MASK)); - + + reconfig_port = ((port->flags & ASYNC_SPD_MASK) != + (newinfo.flags & ASYNC_SPD_MASK)); + if (!capable(CAP_SYS_ADMIN)) { if ((newinfo.close_delay != port->close_delay) || - (newinfo.closing_wait != port->closing_wait) || - ((newinfo.flags & ~ASYNC_USR_MASK) != - (port->flags & ~ASYNC_USR_MASK))) + (newinfo.closing_wait != port->closing_wait) || + ((newinfo.flags & ~ASYNC_USR_MASK) != + (port->flags & ~ASYNC_USR_MASK))) return -EPERM; port->flags = ((port->flags & ~ ASYNC_USR_MASK) | (newinfo.flags & ASYNC_USR_MASK)); - } + } else { port->close_delay = newinfo.close_delay; - port->closing_wait = newinfo.closing_wait; - port->flags = ((port->flags & ~ASYNC_FLAGS) | + port->closing_wait = newinfo.closing_wait; + port->flags = ((port->flags & ~ASYNC_FLAGS) | (newinfo.flags & ASYNC_FLAGS)); } if (reconfig_port) { isicom_config_port(port); } - return 0; -} + return 0; +} -static int isicom_get_serial_info(struct isi_port * port, - struct serial_struct __user *info) +static int isicom_get_serial_info(struct isi_port *port, + struct serial_struct __user *info) { struct serial_struct out_info; - + memset(&out_info, 0, sizeof(out_info)); /* out_info.type = ? */ out_info.line = port - isi_ports; @@ -1581,15 +1339,15 @@ static int isicom_get_serial_info(struct isi_port * port, /* out_info.baud_base = ? */ out_info.close_delay = port->close_delay; out_info.closing_wait = port->closing_wait; - if(copy_to_user(info, &out_info, sizeof(out_info))) + if (copy_to_user(info, &out_info, sizeof(out_info))) return -EFAULT; return 0; -} +} -static int isicom_ioctl(struct tty_struct * tty, struct file * filp, - unsigned int cmd, unsigned long arg) +static int isicom_ioctl(struct tty_struct *tty, struct file *filp, + unsigned int cmd, unsigned long arg) { - struct isi_port * port = (struct isi_port *) tty->driver_data; + struct isi_port *port = tty->driver_data; void __user *argp = (void __user *)arg; int retval; @@ -1597,139 +1355,141 @@ static int isicom_ioctl(struct tty_struct * tty, struct file * filp, return -ENODEV; switch(cmd) { - case TCSBRK: - retval = tty_check_change(tty); - if (retval) - return retval; - tty_wait_until_sent(tty, 0); - if (!arg) - isicom_send_break(port, HZ/4); - return 0; - - case TCSBRKP: - retval = tty_check_change(tty); - if (retval) - return retval; - tty_wait_until_sent(tty, 0); - isicom_send_break(port, arg ? arg * (HZ/10) : HZ/4); - return 0; - - case TIOCGSOFTCAR: - return put_user(C_CLOCAL(tty) ? 1 : 0, (unsigned long __user *)argp); - - case TIOCSSOFTCAR: - if(get_user(arg, (unsigned long __user *) argp)) - return -EFAULT; - tty->termios->c_cflag = - ((tty->termios->c_cflag & ~CLOCAL) | - (arg ? CLOCAL : 0)); - return 0; - - case TIOCGSERIAL: - return isicom_get_serial_info(port, argp); - - case TIOCSSERIAL: - return isicom_set_serial_info(port, argp); - - default: - return -ENOIOCTLCMD; + case TCSBRK: + retval = tty_check_change(tty); + if (retval) + return retval; + tty_wait_until_sent(tty, 0); + if (!arg) + isicom_send_break(port, HZ/4); + return 0; + + case TCSBRKP: + retval = tty_check_change(tty); + if (retval) + return retval; + tty_wait_until_sent(tty, 0); + isicom_send_break(port, arg ? arg * (HZ/10) : HZ/4); + return 0; + + case TIOCGSOFTCAR: + return put_user(C_CLOCAL(tty) ? 1 : 0, + (unsigned long __user *)argp); + + case TIOCSSOFTCAR: + if (get_user(arg, (unsigned long __user *) argp)) + return -EFAULT; + tty->termios->c_cflag = + ((tty->termios->c_cflag & ~CLOCAL) | + (arg ? CLOCAL : 0)); + return 0; + + case TIOCGSERIAL: + return isicom_get_serial_info(port, argp); + + case TIOCSSERIAL: + return isicom_set_serial_info(port, argp); + + default: + return -ENOIOCTLCMD; } return 0; } /* set_termios et all */ -static void isicom_set_termios(struct tty_struct * tty, struct termios * old_termios) +static void isicom_set_termios(struct tty_struct *tty, + struct termios *old_termios) { - struct isi_port * port = (struct isi_port *) tty->driver_data; - + struct isi_port *port = tty->driver_data; + if (isicom_paranoia_check(port, tty->name, "isicom_set_termios")) return; - + if (tty->termios->c_cflag == old_termios->c_cflag && - tty->termios->c_iflag == old_termios->c_iflag) + tty->termios->c_iflag == old_termios->c_iflag) return; - + isicom_config_port(port); - + if ((old_termios->c_cflag & CRTSCTS) && - !(tty->termios->c_cflag & CRTSCTS)) { + !(tty->termios->c_cflag & CRTSCTS)) { tty->hw_stopped = 0; - isicom_start(tty); - } + isicom_start(tty); + } } /* throttle et all */ -static void isicom_throttle(struct tty_struct * tty) +static void isicom_throttle(struct tty_struct *tty) { - struct isi_port * port = (struct isi_port *) tty->driver_data; - struct isi_board * card = port->card; - + struct isi_port *port = tty->driver_data; + struct isi_board *card = port->card; + if (isicom_paranoia_check(port, tty->name, "isicom_throttle")) return; - + /* tell the card that this port cannot handle any more data for now */ card->port_status &= ~(1 << port->channel); outw(card->port_status, card->base + 0x02); } /* unthrottle et all */ -static void isicom_unthrottle(struct tty_struct * tty) +static void isicom_unthrottle(struct tty_struct *tty) { - struct isi_port * port = (struct isi_port *) tty->driver_data; - struct isi_board * card = port->card; - + struct isi_port *port = tty->driver_data; + struct isi_board *card = port->card; + if (isicom_paranoia_check(port, tty->name, "isicom_unthrottle")) return; - + /* tell the card that this port is ready to accept more data */ card->port_status |= (1 << port->channel); outw(card->port_status, card->base + 0x02); } /* stop et all */ -static void isicom_stop(struct tty_struct * tty) +static void isicom_stop(struct tty_struct *tty) { - struct isi_port * port = (struct isi_port *) tty->driver_data; + struct isi_port *port = tty->driver_data; if (isicom_paranoia_check(port, tty->name, "isicom_stop")) return; - + /* this tells the transmitter not to consider this port for data output to the card. */ port->status &= ~ISI_TXOK; } /* start et all */ -static void isicom_start(struct tty_struct * tty) +static void isicom_start(struct tty_struct *tty) { - struct isi_port * port = (struct isi_port *) tty->driver_data; - + struct isi_port *port = tty->driver_data; + if (isicom_paranoia_check(port, tty->name, "isicom_start")) return; - + /* this tells the transmitter to consider this port for data output to the card. */ port->status |= ISI_TXOK; } /* hangup et all */ -static void do_isicom_hangup(void * data) +static void do_isicom_hangup(void *data) { - struct isi_port * port = (struct isi_port *) data; - struct tty_struct * tty; - + struct isi_port *port = data; + struct tty_struct *tty; + tty = port->tty; if (tty) tty_hangup(tty); } -static void isicom_hangup(struct tty_struct * tty) +static void isicom_hangup(struct tty_struct *tty) { - struct isi_port * port = (struct isi_port *) tty->driver_data; - + struct isi_port *port = tty->driver_data; + if (isicom_paranoia_check(port, tty->name, "isicom_hangup")) return; - + isicom_shutdown_port(port); port->count = 0; port->flags &= ~ASYNC_NORMAL_ACTIVE; @@ -1738,342 +1498,540 @@ static void isicom_hangup(struct tty_struct * tty) } /* flush_buffer et all */ -static void isicom_flush_buffer(struct tty_struct * tty) +static void isicom_flush_buffer(struct tty_struct *tty) { - struct isi_port * port = (struct isi_port *) tty->driver_data; - struct isi_board * card = port->card; + struct isi_port *port = tty->driver_data; + struct isi_board *card = port->card; unsigned long flags; - + if (isicom_paranoia_check(port, tty->name, "isicom_flush_buffer")) return; - + spin_lock_irqsave(&card->card_lock, flags); port->xmit_cnt = port->xmit_head = port->xmit_tail = 0; spin_unlock_irqrestore(&card->card_lock, flags); - + wake_up_interruptible(&tty->write_wait); tty_wakeup(tty); } +/* + * Driver init and deinit functions + */ -static int __devinit register_ioregion(void) +static int __devinit isicom_register_ioregion(struct pci_dev *pdev, + const unsigned int index) { - int count, done=0; - for (count=0; count < BOARD_COUNT; count++ ) { - if (isi_card[count].base) - if (!request_region(isi_card[count].base,16,ISICOM_NAME)) { - printk(KERN_DEBUG "ISICOM: I/O Region 0x%x-0x%x is busy. Card%d will be disabled.\n", - isi_card[count].base,isi_card[count].base+15,count+1); - isi_card[count].base=0; - done++; - } - } - return done; + struct isi_board *board = pci_get_drvdata(pdev); + + if (!board->base) + return -EINVAL; + + if (!request_region(board->base, 16, ISICOM_NAME)) { + dev_dbg(&pdev->dev, "I/O Region 0x%lx-0x%lx is busy. Card%d " + "will be disabled.\n", board->base, board->base + 15, + index + 1); + return -EBUSY; + } + + return 0; } -static void unregister_ioregion(void) +static void isicom_unregister_ioregion(struct pci_dev *pdev) { - int count; - for (count=0; count < BOARD_COUNT; count++ ) - if (isi_card[count].base) { - release_region(isi_card[count].base,16); -#ifdef ISICOM_DEBUG - printk(KERN_DEBUG "ISICOM: I/O Region 0x%x-0x%x released for Card%d.\n",isi_card[count].base,isi_card[count].base+15,count+1); -#endif - } + struct isi_board *board = pci_get_drvdata(pdev); + + if (!board->base) + return; + + release_region(board->base, 16); + dev_dbg(&pdev->dev, "I/O Region 0x%lx-0x%lx released.\n", + board->base, board->base + 15); + board->base = 0; } static struct tty_operations isicom_ops = { - .open = isicom_open, - .close = isicom_close, - .write = isicom_write, - .put_char = isicom_put_char, - .flush_chars = isicom_flush_chars, - .write_room = isicom_write_room, + .open = isicom_open, + .close = isicom_close, + .write = isicom_write, + .put_char = isicom_put_char, + .flush_chars = isicom_flush_chars, + .write_room = isicom_write_room, .chars_in_buffer = isicom_chars_in_buffer, - .ioctl = isicom_ioctl, - .set_termios = isicom_set_termios, - .throttle = isicom_throttle, - .unthrottle = isicom_unthrottle, - .stop = isicom_stop, - .start = isicom_start, - .hangup = isicom_hangup, - .flush_buffer = isicom_flush_buffer, - .tiocmget = isicom_tiocmget, - .tiocmset = isicom_tiocmset, + .ioctl = isicom_ioctl, + .set_termios = isicom_set_termios, + .throttle = isicom_throttle, + .unthrottle = isicom_unthrottle, + .stop = isicom_stop, + .start = isicom_start, + .hangup = isicom_hangup, + .flush_buffer = isicom_flush_buffer, + .tiocmget = isicom_tiocmget, + .tiocmset = isicom_tiocmset, }; -static int __devinit register_drivers(void) +static int __devinit isicom_register_tty_driver(void) { - int error; + int error = -ENOMEM; /* tty driver structure initialization */ isicom_normal = alloc_tty_driver(PORT_COUNT); if (!isicom_normal) - return -ENOMEM; - - isicom_normal->owner = THIS_MODULE; - isicom_normal->name = "ttyM"; - isicom_normal->devfs_name = "isicom/"; - isicom_normal->major = ISICOM_NMAJOR; - isicom_normal->minor_start = 0; - isicom_normal->type = TTY_DRIVER_TYPE_SERIAL; - isicom_normal->subtype = SERIAL_TYPE_NORMAL; - isicom_normal->init_termios = tty_std_termios; - isicom_normal->init_termios.c_cflag = - B9600 | CS8 | CREAD | HUPCL |CLOCAL; - isicom_normal->flags = TTY_DRIVER_REAL_RAW; + goto end; + + isicom_normal->owner = THIS_MODULE; + isicom_normal->name = "ttyM"; + isicom_normal->devfs_name = "isicom/"; + isicom_normal->major = ISICOM_NMAJOR; + isicom_normal->minor_start = 0; + isicom_normal->type = TTY_DRIVER_TYPE_SERIAL; + isicom_normal->subtype = SERIAL_TYPE_NORMAL; + isicom_normal->init_termios = tty_std_termios; + isicom_normal->init_termios.c_cflag = B9600 | CS8 | CREAD | HUPCL | + CLOCAL; + isicom_normal->flags = TTY_DRIVER_REAL_RAW; tty_set_operations(isicom_normal, &isicom_ops); - - if ((error=tty_register_driver(isicom_normal))!=0) { - printk(KERN_DEBUG "ISICOM: Couldn't register the dialin driver, error=%d\n", + + if ((error = tty_register_driver(isicom_normal))) { + pr_dbg("Couldn't register the dialin driver, error=%d\n", error); put_tty_driver(isicom_normal); - return error; } - return 0; +end: + return error; } -static void unregister_drivers(void) +static void isicom_unregister_tty_driver(void) { - int error = tty_unregister_driver(isicom_normal); - if (error) - printk(KERN_DEBUG "ISICOM: couldn't unregister normal driver error=%d.\n",error); + int error; + + if ((error = tty_unregister_driver(isicom_normal))) + pr_dbg("couldn't unregister normal driver, error=%d.\n", error); + put_tty_driver(isicom_normal); } -static int __devinit register_isr(void) +static int __devinit isicom_register_isr(struct pci_dev *pdev, + const unsigned int index) { - int count, done=0; - unsigned long irqflags; - - for (count=0; count < BOARD_COUNT; count++ ) { - if (isi_card[count].base) { - irqflags = (isi_card[count].isa == YES) ? - SA_INTERRUPT : - (SA_INTERRUPT | SA_SHIRQ); - - if (request_irq(isi_card[count].irq, - isicom_interrupt, - irqflags, - ISICOM_NAME, &isi_card[count])) { - - printk(KERN_WARNING "ISICOM: Could not" - " install handler at Irq %d." - " Card%d will be disabled.\n", - isi_card[count].irq, count+1); - - release_region(isi_card[count].base,16); - isi_card[count].base=0; - } - else - done++; - } - } - return done; + struct isi_board *board = pci_get_drvdata(pdev); + unsigned long irqflags = SA_INTERRUPT; + int retval = -EINVAL; + + if (!board->base) + goto end; + + if (board->isa == NO) + irqflags |= SA_SHIRQ; + + retval = request_irq(board->irq, isicom_interrupt, irqflags, + ISICOM_NAME, board); + if (retval < 0) + dev_warn(&pdev->dev, "Could not install handler at Irq %d. " + "Card%d will be disabled.\n", board->irq, index + 1); + else + retval = 0; +end: + return retval; } -static void __exit unregister_isr(void) +static int __devinit reset_card(struct pci_dev *pdev, + const unsigned int card, unsigned int *signature) { - int count; + struct isi_board *board = pci_get_drvdata(pdev); + unsigned long base = board->base; + unsigned int portcount = 0; + int retval = 0; + + dev_dbg(&pdev->dev, "ISILoad:Resetting Card%d at 0x%lx\n", card + 1, + base); - for (count=0; count < BOARD_COUNT; count++ ) { - if (isi_card[count].base) - free_irq(isi_card[count].irq, &isi_card[count]); + inw(base + 0x8); + + mdelay(10); + + outw(0, base + 0x8); /* Reset */ + + msleep(3000); + + *signature = inw(base + 0x4) & 0xff; + + if (board->isa == YES) { + if (!(inw(base + 0xe) & 0x1) || (inw(base + 0x2))) { + dev_dbg(&pdev->dev, "base+0x2=0x%lx, base+0xe=0x%lx\n", + inw(base + 0x2), inw(base + 0xe)); + dev_err(&pdev->dev, "ISILoad:ISA Card%d reset failure " + "(Possible bad I/O Port Address 0x%lx).\n", + card + 1, base); + retval = -EIO; + goto end; + } + } else { + portcount = inw(base + 0x2); + if (!(inw(base + 0xe) & 0x1) || ((portcount != 0) && + (portcount != 4) && (portcount != 8))) { + dev_dbg(&pdev->dev, "base+0x2=0x%lx, base+0xe=0x%lx\n", + inw(base + 0x2), inw(base + 0xe)); + dev_err(&pdev->dev, "ISILoad:PCI Card%d reset failure " + "(Possible bad I/O Port Address 0x%lx).\n", + card + 1, base); + retval = -EIO; + goto end; + } } + + switch (*signature) { + case 0xa5: + case 0xbb: + case 0xdd: + board->port_count = (board->isa == NO && portcount == 4) ? 4 : + 8; + board->shift_count = 12; + break; + case 0xcc: + board->port_count = 16; + board->shift_count = 11; + break; + default: + dev_warn(&pdev->dev, "ISILoad:Card%d reset failure (Possible " + "bad I/O Port Address 0x%lx).\n", card + 1, base); + dev_dbg(&pdev->dev, "Sig=0x%lx\n", signature); + retval = -EIO; + } + dev_info(&pdev->dev, "-Done\n"); + +end: + return retval; } -static int __devinit isicom_init(void) +static inline int WaitTillCardIsFree(u16 base) { - int card, channel, base; - struct isi_port * port; - unsigned long page; - - if (!tmp_buf) { - page = get_zeroed_page(GFP_KERNEL); - if (!page) { -#ifdef ISICOM_DEBUG - printk(KERN_DEBUG "ISICOM: Couldn't allocate page for tmp_buf.\n"); -#else - printk(KERN_ERR "ISICOM: Not enough memory...\n"); -#endif - return 0; - } - tmp_buf = (unsigned char *) page; - } - - if (!register_ioregion()) - { - printk(KERN_ERR "ISICOM: All required I/O space found busy.\n"); - free_page((unsigned long)tmp_buf); - return 0; - } - if (register_drivers()) - { - unregister_ioregion(); - free_page((unsigned long)tmp_buf); - return 0; - } - if (!register_isr()) - { - unregister_drivers(); - /* ioports already uregistered in register_isr */ - free_page((unsigned long)tmp_buf); - return 0; + unsigned long count = 0; + + while (!(inw(base + 0xe) & 0x1) && count++ < 100) + msleep(5); + + return !(inw(base + 0xe) & 0x1); +} + +static int __devinit load_firmware(struct pci_dev *pdev, + const unsigned int index, const unsigned int signature) +{ + struct isi_board *board = pci_get_drvdata(pdev); + const struct firmware *fw; + unsigned long base = board->base; + unsigned int a; + u16 word_count, status; + int retval = -EIO; + char *name; + u8 *data; + + struct stframe { + u16 addr; + u16 count; + u8 data[0]; + } *frame; + + switch (signature) { + case 0xa5: + name = "isi608.bin"; + break; + case 0xbb: + name = "isi608em.bin"; + break; + case 0xcc: + name = "isi616em.bin"; + break; + case 0xdd: + name = "isi4608.bin"; + break; + case 0xee: + name = "isi4616.bin"; + break; + default: + dev_err(&pdev->dev, "Unknown signature.\n"); + goto end; + } + + retval = request_firmware(&fw, name, &pdev->dev); + if (retval) + goto end; + + for (frame = (struct stframe *)fw->data; + frame < (struct stframe *)(fw->data + fw->size); + frame++) { + if (WaitTillCardIsFree(base)) + goto errrelfw; + + outw(0xf0, base); /* start upload sequence */ + outw(0x00, base); + outw(frame->addr, base); /* lsb of address */ + + word_count = frame->count / 2 + frame->count % 2; + outw(word_count, base); + InterruptTheCard(base); + + udelay(100); /* 0x2f */ + + if (WaitTillCardIsFree(base)) + goto errrelfw; + + if ((status = inw(base + 0x4)) != 0) { + dev_warn(&pdev->dev, "Card%d rejected load header:\n" + "Address:0x%x\nCount:0x%x\nStatus:0x%x\n", + index + 1, frame->addr, frame->count, status); + goto errrelfw; + } + outsw(base, frame->data, word_count); + + InterruptTheCard(base); + + udelay(50); /* 0x0f */ + + if (WaitTillCardIsFree(base)) + goto errrelfw; + + if ((status = inw(base + 0x4)) != 0) { + dev_err(&pdev->dev, "Card%d got out of sync.Card " + "Status:0x%x\n", index + 1, status); + goto errrelfw; + } + } + + retval = -EIO; + + if (WaitTillCardIsFree(base)) + goto errrelfw; + + outw(0xf2, base); + outw(0x800, base); + outw(0x0, base); + outw(0x0, base); + InterruptTheCard(base); + outw(0x0, base + 0x4); /* for ISI4608 cards */ + +/* XXX: should we test it by reading it back and comparing with original like + * in load firmware package? */ + for (frame = (struct stframe*)fw->data; + frame < (struct stframe*)(fw->data + fw->size); + frame++) { + if (WaitTillCardIsFree(base)) + goto errrelfw; + + outw(0xf1, base); /* start download sequence */ + outw(0x00, base); + outw(frame->addr, base); /* lsb of address */ + + word_count = (frame->count >> 1) + frame->count % 2; + outw(word_count + 1, base); + InterruptTheCard(base); + + udelay(50); /* 0xf */ + + if (WaitTillCardIsFree(base)) + goto errrelfw; + + if ((status = inw(base + 0x4)) != 0) { + dev_warn(&pdev->dev, "Card%d rejected verify header:\n" + "Address:0x%x\nCount:0x%x\nStatus: 0x%x\n", + index + 1, frame->addr, frame->count, status); + goto errrelfw; + } + + data = kmalloc(word_count * 2, GFP_KERNEL); + inw(base); + insw(base, data, word_count); + InterruptTheCard(base); + + for (a = 0; a < frame->count; a++) + if (data[a] != frame->data[a]) { + kfree(data); + dev_err(&pdev->dev, "Card%d, firmware upload " + "failed\n", index + 1); + goto errrelfw; + } + kfree(data); + + udelay(50); /* 0xf */ + + if (WaitTillCardIsFree(base)) + goto errrelfw; + + if ((status = inw(base + 0x4)) != 0) { + dev_err(&pdev->dev, "Card%d verify got out of sync. " + "Card Status:0x%x\n", index + 1, status); + goto errrelfw; + } } - - memset(isi_ports, 0, sizeof(isi_ports)); - for (card = 0; card < BOARD_COUNT; card++) { - port = &isi_ports[card * 16]; - isi_card[card].ports = port; - spin_lock_init(&isi_card[card].card_lock); - base = isi_card[card].base; - for (channel = 0; channel < 16; channel++, port++) { - port->magic = ISICOM_MAGIC; - port->card = &isi_card[card]; - port->channel = channel; - port->close_delay = 50 * HZ/100; - port->closing_wait = 3000 * HZ/100; - INIT_WORK(&port->hangup_tq, do_isicom_hangup, port); - INIT_WORK(&port->bh_tqueue, isicom_bottomhalf, port); - port->status = 0; - init_waitqueue_head(&port->open_wait); - init_waitqueue_head(&port->close_wait); - /* . . . */ - } - } - - return 1; + + board->status |= FIRMWARE_LOADED; + retval = 0; + +errrelfw: + release_firmware(fw); +end: + return retval; } /* * Insmod can set static symbols so keep these static */ - static int io[4]; static int irq[4]; +static int card; -MODULE_AUTHOR("MultiTech"); -MODULE_DESCRIPTION("Driver for the ISI series of cards by MultiTech"); -MODULE_LICENSE("GPL"); -module_param_array(io, int, NULL, 0); -MODULE_PARM_DESC(io, "I/O ports for the cards"); -module_param_array(irq, int, NULL, 0); -MODULE_PARM_DESC(irq, "Interrupts for the cards"); +static int __devinit isicom_probe(struct pci_dev *pdev, + const struct pci_device_id *ent) +{ + unsigned int ioaddr, signature, index; + int retval = -EPERM; + u8 pciirq; + struct isi_board *board = NULL; + + if (card >= BOARD_COUNT) + goto err; + + ioaddr = pci_resource_start(pdev, 3); + /* i.e at offset 0x1c in the PCI configuration register space. */ + pciirq = pdev->irq; + dev_info(&pdev->dev, "ISI PCI Card(Device ID 0x%x)\n", ent->device); + + /* allot the first empty slot in the array */ + for (index = 0; index < BOARD_COUNT; index++) + if (isi_card[index].base == 0) { + board = &isi_card[index]; + break; + } + + board->base = ioaddr; + board->irq = pciirq; + board->isa = NO; + card++; + + pci_set_drvdata(pdev, board); + + retval = isicom_register_ioregion(pdev, index); + if (retval < 0) + goto err; + + retval = isicom_register_isr(pdev, index); + if (retval < 0) + goto errunrr; + + retval = reset_card(pdev, index, &signature); + if (retval < 0) + goto errunri; + + retval = load_firmware(pdev, index, signature); + if (retval < 0) + goto errunri; + + return 0; + +errunri: + free_irq(board->irq, board); +errunrr: + isicom_unregister_ioregion(pdev); +err: + board->base = 0; + return retval; +} + +static void __devexit isicom_remove(struct pci_dev *pdev) +{ + struct isi_board *board = pci_get_drvdata(pdev); + + free_irq(board->irq, board); + isicom_unregister_ioregion(pdev); +} static int __devinit isicom_setup(void) { - struct pci_dev *dev = NULL; - int retval, card, idx, count; - unsigned char pciirq; - unsigned int ioaddr; - + int retval, idx, channel; + struct isi_port *port; + card = 0; - for(idx=0; idx < BOARD_COUNT; idx++) { - if (io[idx]) { - isi_card[idx].base=io[idx]; - isi_card[idx].irq=irq[idx]; - isi_card[idx].isa=YES; - card++; - } - else { - isi_card[idx].base = 0; - isi_card[idx].irq = 0; - } - } - - for (idx=0 ;idx < card; idx++) { - if (!((isi_card[idx].irq==2)||(isi_card[idx].irq==3)|| - (isi_card[idx].irq==4)||(isi_card[idx].irq==5)|| - (isi_card[idx].irq==7)||(isi_card[idx].irq==10)|| - (isi_card[idx].irq==11)||(isi_card[idx].irq==12)|| - (isi_card[idx].irq==15))) { - - if (isi_card[idx].base) { - printk(KERN_ERR "ISICOM: Irq %d unsupported. Disabling Card%d...\n", - isi_card[idx].irq, idx+1); - isi_card[idx].base=0; - card--; - } - } - } - - if (card < BOARD_COUNT) { - for (idx=0; idx < DEVID_COUNT; idx++) { - dev = NULL; - for (;;){ - if (!(dev = pci_find_device(VENDOR_ID, isicom_pci_tbl[idx].device, dev))) - break; - if (card >= BOARD_COUNT) - break; - - if (pci_enable_device(dev)) - break; + memset(isi_ports, 0, sizeof(isi_ports)); - /* found a PCI ISI card! */ - ioaddr = pci_resource_start (dev, 3); /* i.e at offset 0x1c in the - * PCI configuration register - * space. - */ - pciirq = dev->irq; - printk(KERN_INFO "ISI PCI Card(Device ID 0x%x)\n", isicom_pci_tbl[idx].device); - /* - * allot the first empty slot in the array - */ - for (count=0; count < BOARD_COUNT; count++) { - if (isi_card[count].base == 0) { - isi_card[count].base = ioaddr; - isi_card[count].irq = pciirq; - isi_card[count].isa = NO; - card++; - break; - } - } - } - if (card >= BOARD_COUNT) break; - } + for(idx = 0; idx < BOARD_COUNT; idx++) { + port = &isi_ports[idx * 16]; + isi_card[idx].ports = port; + spin_lock_init(&isi_card[idx].card_lock); + for (channel = 0; channel < 16; channel++, port++) { + port->magic = ISICOM_MAGIC; + port->card = &isi_card[idx]; + port->channel = channel; + port->close_delay = 50 * HZ/100; + port->closing_wait = 3000 * HZ/100; + INIT_WORK(&port->hangup_tq, do_isicom_hangup, port); + INIT_WORK(&port->bh_tqueue, isicom_bottomhalf, port); + port->status = 0; + init_waitqueue_head(&port->open_wait); + init_waitqueue_head(&port->close_wait); + /* . . . */ + } + isi_card[idx].base = 0; + isi_card[idx].irq = 0; + + if (!io[idx]) + continue; + + if (irq[idx] == 2 || irq[idx] == 3 || irq[idx] == 4 || + irq[idx] == 5 || irq[idx] == 7 || + irq[idx] == 10 || irq[idx] == 11 || + irq[idx] == 12 || irq[idx] == 15) { + printk(KERN_ERR "ISICOM: ISA not supported yet.\n"); + retval = -EINVAL; + goto error; + } else + printk(KERN_ERR "ISICOM: Irq %d unsupported. " + "Disabling Card%d...\n", irq[idx], idx + 1); } - - if (!(isi_card[0].base || isi_card[1].base || isi_card[2].base || isi_card[3].base)) { - printk(KERN_ERR "ISICOM: No valid card configuration. Driver cannot be initialized...\n"); - return -EIO; - } - retval = misc_register(&isiloader_device); + retval = isicom_register_tty_driver(); + if (retval < 0) + goto error; + + retval = pci_register_driver(&isicom_driver); if (retval < 0) { - printk(KERN_ERR "ISICOM: Unable to register firmware loader driver.\n"); - return retval; - } - - if (!isicom_init()) { - if (misc_deregister(&isiloader_device)) - printk(KERN_ERR "ISICOM: Unable to unregister Firmware Loader driver\n"); - return -EIO; + printk(KERN_ERR "ISICOM: Unable to register pci driver.\n"); + goto errtty; } - + init_timer(&tx); tx.expires = jiffies + 1; tx.data = 0; tx.function = isicom_tx; re_schedule = 1; add_timer(&tx); - + return 0; +errtty: + isicom_unregister_tty_driver(); +error: + return retval; } static void __exit isicom_exit(void) { + unsigned int index = 0; + re_schedule = 0; - /* FIXME */ - msleep(1000); - unregister_isr(); - unregister_drivers(); - unregister_ioregion(); - if(tmp_buf) - free_page((unsigned long)tmp_buf); - if (misc_deregister(&isiloader_device)) - printk(KERN_ERR "ISICOM: Unable to unregister Firmware Loader driver\n"); + + while (re_schedule != 2 && index++ < 100) + msleep(10); + + pci_unregister_driver(&isicom_driver); + isicom_unregister_tty_driver(); } module_init(isicom_setup); module_exit(isicom_exit); + +MODULE_AUTHOR("MultiTech"); +MODULE_DESCRIPTION("Driver for the ISI series of cards by MultiTech"); +MODULE_LICENSE("GPL"); +module_param_array(io, int, NULL, 0); +MODULE_PARM_DESC(io, "I/O ports for the cards"); +module_param_array(irq, int, NULL, 0); +MODULE_PARM_DESC(irq, "Interrupts for the cards"); diff --git a/trunk/drivers/char/istallion.c b/trunk/drivers/char/istallion.c index ce3bc0d45f1f..28c5a3193b81 100644 --- a/trunk/drivers/char/istallion.c +++ b/trunk/drivers/char/istallion.c @@ -135,7 +135,7 @@ static stlconf_t stli_brdconf[] = { /*{ BRD_ECP, 0x2a0, 0, 0xcc000, 0, 0 },*/ }; -static int stli_nrbrds = sizeof(stli_brdconf) / sizeof(stlconf_t); +static int stli_nrbrds = ARRAY_SIZE(stli_brdconf); /* * There is some experimental EISA board detection code in this driver. @@ -406,7 +406,7 @@ static unsigned long stli_eisamemprobeaddrs[] = { 0xff000000, 0xff010000, 0xff020000, 0xff030000, }; -static int stli_eisamempsize = sizeof(stli_eisamemprobeaddrs) / sizeof(unsigned long); +static int stli_eisamempsize = ARRAY_SIZE(stli_eisamemprobeaddrs); /* * Define the Stallion PCI vendor and device IDs. @@ -899,15 +899,13 @@ static void stli_argbrds(void) { stlconf_t conf; stlibrd_t *brdp; - int nrargs, i; + int i; #ifdef DEBUG printk("stli_argbrds()\n"); #endif - nrargs = sizeof(stli_brdsp) / sizeof(char **); - - for (i = stli_nrbrds; (i < nrargs); i++) { + for (i = stli_nrbrds; i < ARRAY_SIZE(stli_brdsp); i++) { memset(&conf, 0, sizeof(conf)); if (stli_parsebrd(&conf, stli_brdsp[i]) == 0) continue; @@ -967,7 +965,7 @@ static unsigned long stli_atol(char *str) static int stli_parsebrd(stlconf_t *confp, char **argp) { char *sp; - int nrbrdnames, i; + int i; #ifdef DEBUG printk("stli_parsebrd(confp=%x,argp=%x)\n", (int) confp, (int) argp); @@ -979,14 +977,13 @@ static int stli_parsebrd(stlconf_t *confp, char **argp) for (sp = argp[0], i = 0; ((*sp != 0) && (i < 25)); sp++, i++) *sp = TOLOWER(*sp); - nrbrdnames = sizeof(stli_brdstr) / sizeof(stlibrdtype_t); - for (i = 0; (i < nrbrdnames); i++) { + for (i = 0; i < ARRAY_SIZE(stli_brdstr); i++) { if (strcmp(stli_brdstr[i].name, argp[0]) == 0) break; } - if (i >= nrbrdnames) { + if (i == ARRAY_SIZE(stli_brdstr)) { printk("STALLION: unknown board name, %s?\n", argp[0]); - return(0); + return 0; } confp->brdtype = stli_brdstr[i].type; @@ -2714,17 +2711,13 @@ static void stli_read(stlibrd_t *brdp, stliport_t *portp) stlen = size - tail; } - len = MIN(len, (TTY_FLIPBUF_SIZE - tty->flip.count)); + len = tty_buffer_request_room(tty, len); + /* FIXME : iomap ? */ shbuf = (volatile char *) EBRDGETMEMPTR(brdp, portp->rxoffset); while (len > 0) { stlen = MIN(len, stlen); - memcpy(tty->flip.char_buf_ptr, (char *) (shbuf + tail), stlen); - memset(tty->flip.flag_buf_ptr, 0, stlen); - tty->flip.char_buf_ptr += stlen; - tty->flip.flag_buf_ptr += stlen; - tty->flip.count += stlen; - + tty_insert_flip_string(tty, (char *)(shbuf + tail), stlen); len -= stlen; tail += stlen; if (tail >= size) { @@ -2909,16 +2902,12 @@ static int stli_hostcmd(stlibrd_t *brdp, stliport_t *portp) if ((nt.data & DT_RXBREAK) && (portp->rxmarkmsk & BRKINT)) { if (tty != (struct tty_struct *) NULL) { - if (tty->flip.count < TTY_FLIPBUF_SIZE) { - tty->flip.count++; - *tty->flip.flag_buf_ptr++ = TTY_BREAK; - *tty->flip.char_buf_ptr++ = 0; - if (portp->flags & ASYNC_SAK) { - do_SAK(tty); - EBRDENABLE(brdp); - } - tty_schedule_flip(tty); + tty_insert_flip_char(tty, 0, TTY_BREAK); + if (portp->flags & ASYNC_SAK) { + do_SAK(tty); + EBRDENABLE(brdp); } + tty_schedule_flip(tty); } } @@ -4943,7 +4932,7 @@ static int stli_portcmdstats(stliport_t *portp) if (portp->tty != (struct tty_struct *) NULL) { if (portp->tty->driver_data == portp) { stli_comstats.ttystate = portp->tty->flags; - stli_comstats.rxbuffered = portp->tty->flip.count; + stli_comstats.rxbuffered = -1 /*portp->tty->flip.count*/; if (portp->tty->termios != (struct termios *) NULL) { stli_comstats.cflags = portp->tty->termios->c_cflag; stli_comstats.iflags = portp->tty->termios->c_iflag; diff --git a/trunk/drivers/char/moxa.c b/trunk/drivers/char/moxa.c index 79e490ef2cf2..5e3ef5522194 100644 --- a/trunk/drivers/char/moxa.c +++ b/trunk/drivers/char/moxa.c @@ -269,7 +269,7 @@ static int MoxaPortDCDChange(int); static int MoxaPortDCDON(int); static void MoxaPortFlushData(int, int); static int MoxaPortWriteData(int, unsigned char *, int); -static int MoxaPortReadData(int, unsigned char *, int); +static int MoxaPortReadData(int, struct tty_struct *tty); static int MoxaPortTxQueue(int); static int MoxaPortRxQueue(int); static int MoxaPortTxFree(int); @@ -301,6 +301,8 @@ static struct tty_operations moxa_ops = { .tiocmset = moxa_tiocmset, }; +static spinlock_t moxa_lock = SPIN_LOCK_UNLOCKED; + #ifdef CONFIG_PCI static int moxa_get_PCI_conf(struct pci_dev *p, int board_type, moxa_board_conf * board) { @@ -448,7 +450,7 @@ static int __init moxa_init(void) #ifdef CONFIG_PCI { struct pci_dev *p = NULL; - int n = (sizeof(moxa_pcibrds) / sizeof(moxa_pcibrds[0])) - 1; + int n = ARRAY_SIZE(moxa_pcibrds) - 1; i = 0; while (i < n) { while ((p = pci_get_device(moxa_pcibrds[i].vendor, moxa_pcibrds[i].device, p))!=NULL) @@ -645,10 +647,10 @@ static int moxa_write(struct tty_struct *tty, if (ch == NULL) return (0); port = ch->port; - save_flags(flags); - cli(); + + spin_lock_irqsave(&moxa_lock, flags); len = MoxaPortWriteData(port, (unsigned char *) buf, count); - restore_flags(flags); + spin_unlock_irqrestore(&moxa_lock, flags); /********************************************* if ( !(ch->statusflags & LOWWAIT) && @@ -723,11 +725,10 @@ static void moxa_put_char(struct tty_struct *tty, unsigned char c) if (ch == NULL) return; port = ch->port; - save_flags(flags); - cli(); + spin_lock_irqsave(&moxa_lock, flags); moxaXmitBuff[0] = c; MoxaPortWriteData(port, moxaXmitBuff, 1); - restore_flags(flags); + spin_unlock_irqrestore(&moxa_lock, flags); /************************************************ if ( !(ch->statusflags & LOWWAIT) && (MoxaPortTxFree(port) <= 100) ) *************************************************/ @@ -1030,12 +1031,12 @@ static int block_till_ready(struct tty_struct *tty, struct file *filp, printk("block_til_ready before block: ttys%d, count = %d\n", ch->line, ch->count); #endif - save_flags(flags); - cli(); + spin_lock_irqsave(&moxa_lock, flags); if (!tty_hung_up_p(filp)) ch->count--; - restore_flags(flags); ch->blocked_open++; + spin_unlock_irqrestore(&moxa_lock, flags); + while (1) { set_current_state(TASK_INTERRUPTIBLE); if (tty_hung_up_p(filp) || @@ -1062,17 +1063,21 @@ static int block_till_ready(struct tty_struct *tty, struct file *filp, } set_current_state(TASK_RUNNING); remove_wait_queue(&ch->open_wait, &wait); + + spin_lock_irqsave(&moxa_lock, flags); if (!tty_hung_up_p(filp)) ch->count++; ch->blocked_open--; + spin_unlock_irqrestore(&moxa_lock, flags); #ifdef SERIAL_DEBUG_OPEN printk("block_til_ready after blocking: ttys%d, count = %d\n", ch->line, ch->count); #endif if (retval) return (retval); + /* FIXME: review to see if we need to use set_bit on these */ ch->asyncflags |= ASYNC_NORMAL_ACTIVE; - return (0); + return 0; } static void setup_empty_event(struct tty_struct *tty) @@ -1080,15 +1085,14 @@ static void setup_empty_event(struct tty_struct *tty) struct moxa_str *ch = tty->driver_data; unsigned long flags; - save_flags(flags); - cli(); + spin_lock_irqsave(&moxa_lock, flags); ch->statusflags |= EMPTYWAIT; moxaEmptyTimer_on[ch->port] = 0; del_timer(&moxaEmptyTimer[ch->port]); moxaEmptyTimer[ch->port].expires = jiffies + HZ; moxaEmptyTimer_on[ch->port] = 1; add_timer(&moxaEmptyTimer[ch->port]); - restore_flags(flags); + spin_unlock_irqrestore(&moxa_lock, flags); } static void check_xmit_empty(unsigned long data) @@ -1135,8 +1139,6 @@ static void receive_data(struct moxa_str *ch) { struct tty_struct *tp; struct termios *ts; - int i, count, rc, space; - unsigned char *charptr, *flagptr; unsigned long flags; ts = NULL; @@ -1150,24 +1152,10 @@ static void receive_data(struct moxa_str *ch) MoxaPortFlushData(ch->port, 0); return; } - space = TTY_FLIPBUF_SIZE - tp->flip.count; - if (space <= 0) - return; - charptr = tp->flip.char_buf_ptr; - flagptr = tp->flip.flag_buf_ptr; - rc = tp->flip.count; - save_flags(flags); - cli(); - count = MoxaPortReadData(ch->port, charptr, space); - restore_flags(flags); - for (i = 0; i < count; i++) - *flagptr++ = 0; - charptr += count; - rc += count; - tp->flip.count = rc; - tp->flip.char_buf_ptr = charptr; - tp->flip.flag_buf_ptr = flagptr; - tty_schedule_flip(ch->tty); + spin_lock_irqsave(&moxa_lock, flags); + MoxaPortReadData(ch->port, tp); + spin_unlock_irqrestore(&moxa_lock, flags); + tty_schedule_flip(tp); } #define Magic_code 0x404 @@ -1774,7 +1762,7 @@ int MoxaPortsOfCard(int cardno) * 14. MoxaPortDCDON(int port); * * 15. MoxaPortFlushData(int port, int mode); * * 16. MoxaPortWriteData(int port, unsigned char * buffer, int length); * - * 17. MoxaPortReadData(int port, unsigned char * buffer, int length); * + * 17. MoxaPortReadData(int port, struct tty_struct *tty); * * 18. MoxaPortTxBufSize(int port); * * 19. MoxaPortRxBufSize(int port); * * 20. MoxaPortTxQueue(int port); * @@ -2003,10 +1991,9 @@ int MoxaPortsOfCard(int cardno) * * Function 21: Read data. * Syntax: - * int MoxaPortReadData(int port, unsigned char * buffer, int length); + * int MoxaPortReadData(int port, struct tty_struct *tty); * int port : port number (0 - 127) - * unsigned char * buffer : pointer to read data buffer. - * int length : read data buffer length + * struct tty_struct *tty : tty for data * * return: 0 - length : real read data length * @@ -2504,7 +2491,7 @@ int MoxaPortWriteData(int port, unsigned char * buffer, int len) return (total); } -int MoxaPortReadData(int port, unsigned char * buffer, int space) +int MoxaPortReadData(int port, struct tty_struct *tty) { register ushort head, pageofs; int i, count, cnt, len, total, remain; @@ -2522,9 +2509,9 @@ int MoxaPortReadData(int port, unsigned char * buffer, int space) count = (tail >= head) ? (tail - head) : (tail - head + rx_mask + 1); if (count == 0) - return (0); + return 0; - total = (space > count) ? count : space; + total = count; remain = count - total; moxaLog.rxcnt[port] += total; count = total; @@ -2539,7 +2526,7 @@ int MoxaPortReadData(int port, unsigned char * buffer, int space) len = (count > len) ? len : count; ofs = baseAddr + DynPage_addr + bufhead + head; for (i = 0; i < len; i++) - *buffer++ = readb(ofs + i); + tty_insert_flip_char(tty, readb(ofs + i), TTY_NORMAL); head = (head + len) & rx_mask; count -= len; } @@ -2556,7 +2543,7 @@ int MoxaPortReadData(int port, unsigned char * buffer, int space) writew(pageno, baseAddr + Control_reg); ofs = baseAddr + DynPage_addr + pageofs; for (i = 0; i < cnt; i++) - *buffer++ = readb(ofs + i); + tty_insert_flip_char(tty, readb(ofs + i), TTY_NORMAL); if (count == 0) { writew((head + len) & rx_mask, ofsAddr + RXrptr); break; diff --git a/trunk/drivers/char/mxser.c b/trunk/drivers/char/mxser.c index 26448f176803..ea725a9964e2 100644 --- a/trunk/drivers/char/mxser.c +++ b/trunk/drivers/char/mxser.c @@ -813,7 +813,7 @@ static int mxser_init(void) /* start finding PCI board here */ #ifdef CONFIG_PCI - n = (sizeof(mxser_pcibrds) / sizeof(mxser_pcibrds[0])) - 1; + n = ARRAY_SIZE(mxser_pcibrds) - 1; index = 0; b = 0; while (b < n) { @@ -1982,7 +1982,7 @@ static void mxser_receive_chars(struct mxser_struct *info, int *status) spin_lock_irqsave(&info->slock, flags); - recv_room = tty->ldisc.receive_room(tty); + recv_room = tty->receive_room; if ((recv_room == 0) && (!info->ldisc_stop_rx)) { //mxser_throttle(tty); mxser_stoprx(tty); diff --git a/trunk/drivers/char/n_hdlc.c b/trunk/drivers/char/n_hdlc.c index a133a62f3d55..9f54733f1623 100644 --- a/trunk/drivers/char/n_hdlc.c +++ b/trunk/drivers/char/n_hdlc.c @@ -191,7 +191,6 @@ static unsigned int n_hdlc_tty_poll(struct tty_struct *tty, struct file *filp, poll_table *wait); static int n_hdlc_tty_open(struct tty_struct *tty); static void n_hdlc_tty_close(struct tty_struct *tty); -static int n_hdlc_tty_room(struct tty_struct *tty); static void n_hdlc_tty_receive(struct tty_struct *tty, const __u8 *cp, char *fp, int count); static void n_hdlc_tty_wakeup(struct tty_struct *tty); @@ -212,7 +211,6 @@ static struct tty_ldisc n_hdlc_ldisc = { .ioctl = n_hdlc_tty_ioctl, .poll = n_hdlc_tty_poll, .receive_buf = n_hdlc_tty_receive, - .receive_room = n_hdlc_tty_room, .write_wakeup = n_hdlc_tty_wakeup, }; @@ -337,6 +335,7 @@ static int n_hdlc_tty_open (struct tty_struct *tty) tty->disc_data = n_hdlc; n_hdlc->tty = tty; + tty->receive_room = 65536; #if defined(TTY_NO_WRITE_SPLIT) /* change tty_io write() to not split large writes into 8K chunks */ @@ -477,22 +476,6 @@ static void n_hdlc_tty_wakeup(struct tty_struct *tty) } /* end of n_hdlc_tty_wakeup() */ -/** - * n_hdlc_tty_room - Return the amount of space left in the receiver's buffer - * @tty - pointer to associated tty instance data - * - * Callback function from tty driver. Return the amount of space left in the - * receiver's buffer to decide if remote transmitter is to be throttled. - */ -static int n_hdlc_tty_room(struct tty_struct *tty) -{ - if (debuglevel >= DEBUG_LEVEL_INFO) - printk("%s(%d)n_hdlc_tty_room() called\n",__FILE__,__LINE__); - /* always return a larger number to prevent */ - /* throttling of remote transmitter. */ - return 65536; -} /* end of n_hdlc_tty_root() */ - /** * n_hdlc_tty_receive - Called by tty driver when receive data is available * @tty - pointer to tty instance data diff --git a/trunk/drivers/char/n_r3964.c b/trunk/drivers/char/n_r3964.c index 853c98cee64f..c48de09d68f0 100644 --- a/trunk/drivers/char/n_r3964.c +++ b/trunk/drivers/char/n_r3964.c @@ -147,7 +147,6 @@ static unsigned int r3964_poll(struct tty_struct * tty, struct file * file, struct poll_table_struct *wait); static void r3964_receive_buf(struct tty_struct *tty, const unsigned char *cp, char *fp, int count); -static int r3964_receive_room(struct tty_struct *tty); static struct tty_ldisc tty_ldisc_N_R3964 = { .owner = THIS_MODULE, @@ -161,7 +160,6 @@ static struct tty_ldisc tty_ldisc_N_R3964 = { .set_termios = r3964_set_termios, .poll = r3964_poll, .receive_buf = r3964_receive_buf, - .receive_room = r3964_receive_room, }; @@ -1119,6 +1117,7 @@ static int r3964_open(struct tty_struct *tty) pInfo->nRetry = 0; tty->disc_data = pInfo; + tty->receive_room = 65536; init_timer(&pInfo->tmr); pInfo->tmr.data = (unsigned long)pInfo; @@ -1405,12 +1404,5 @@ static void r3964_receive_buf(struct tty_struct *tty, const unsigned char *cp, } } -static int r3964_receive_room(struct tty_struct *tty) -{ - TRACE_L("receive_room"); - return -1; -} - - MODULE_LICENSE("GPL"); MODULE_ALIAS_LDISC(N_R3964); diff --git a/trunk/drivers/char/n_tty.c b/trunk/drivers/char/n_tty.c index c556f4d3ccd7..ccad7ae94541 100644 --- a/trunk/drivers/char/n_tty.c +++ b/trunk/drivers/char/n_tty.c @@ -78,7 +78,32 @@ static inline void free_buf(unsigned char *buf) free_page((unsigned long) buf); } -static inline void put_tty_queue_nolock(unsigned char c, struct tty_struct *tty) +/** + * n_tty_set__room - receive space + * @tty: terminal + * + * Called by the driver to find out how much data it is + * permitted to feed to the line discipline without any being lost + * and thus to manage flow control. Not serialized. Answers for the + * "instant". + */ + +static void n_tty_set_room(struct tty_struct *tty) +{ + int left = N_TTY_BUF_SIZE - tty->read_cnt - 1; + + /* + * If we are doing input canonicalization, and there are no + * pending newlines, let characters through without limit, so + * that erase characters will be handled. Other excess + * characters will be beeped. + */ + if (left <= 0) + left = tty->icanon && !tty->canon_data; + tty->receive_room = left; +} + +static void put_tty_queue_nolock(unsigned char c, struct tty_struct *tty) { if (tty->read_cnt < N_TTY_BUF_SIZE) { tty->read_buf[tty->read_head] = c; @@ -87,7 +112,7 @@ static inline void put_tty_queue_nolock(unsigned char c, struct tty_struct *tty) } } -static inline void put_tty_queue(unsigned char c, struct tty_struct *tty) +static void put_tty_queue(unsigned char c, struct tty_struct *tty) { unsigned long flags; /* @@ -136,6 +161,7 @@ static void reset_buffer_flags(struct tty_struct *tty) spin_unlock_irqrestore(&tty->read_lock, flags); tty->canon_head = tty->canon_data = tty->erasing = 0; memset(&tty->read_flags, 0, sizeof tty->read_flags); + n_tty_set_room(tty); check_unthrottle(tty); } @@ -838,30 +864,6 @@ static inline void n_tty_receive_char(struct tty_struct *tty, unsigned char c) put_tty_queue(c, tty); } -/** - * n_tty_receive_room - receive space - * @tty: terminal - * - * Called by the driver to find out how much data it is - * permitted to feed to the line discipline without any being lost - * and thus to manage flow control. Not serialized. Answers for the - * "instant". - */ - -static int n_tty_receive_room(struct tty_struct *tty) -{ - int left = N_TTY_BUF_SIZE - tty->read_cnt - 1; - - /* - * If we are doing input canonicalization, and there are no - * pending newlines, let characters through without limit, so - * that erase characters will be handled. Other excess - * characters will be beeped. - */ - if (left <= 0) - left = tty->icanon && !tty->canon_data; - return left; -} /** * n_tty_write_wakeup - asynchronous I/O notifier @@ -953,6 +955,8 @@ static void n_tty_receive_buf(struct tty_struct *tty, const unsigned char *cp, tty->driver->flush_chars(tty); } + n_tty_set_room(tty); + if (!tty->icanon && (tty->read_cnt >= tty->minimum_to_wake)) { kill_fasync(&tty->fasync, SIGIO, POLL_IN); if (waitqueue_active(&tty->read_wait)) @@ -964,7 +968,7 @@ static void n_tty_receive_buf(struct tty_struct *tty, const unsigned char *cp, * mode. We don't want to throttle the driver if we're in * canonical mode and don't have a newline yet! */ - if (n_tty_receive_room(tty) < TTY_THRESHOLD_THROTTLE) { + if (tty->receive_room < TTY_THRESHOLD_THROTTLE) { /* check TTY_THROTTLED first so it indicates our state */ if (!test_and_set_bit(TTY_THROTTLED, &tty->flags) && tty->driver->throttle) @@ -999,6 +1003,7 @@ static void n_tty_set_termios(struct tty_struct *tty, struct termios * old) if (test_bit(TTY_HW_COOK_IN, &tty->flags)) { tty->raw = 1; tty->real_raw = 1; + n_tty_set_room(tty); return; } if (I_ISTRIP(tty) || I_IUCLC(tty) || I_IGNCR(tty) || @@ -1051,6 +1056,7 @@ static void n_tty_set_termios(struct tty_struct *tty, struct termios * old) else tty->real_raw = 0; } + n_tty_set_room(tty); } /** @@ -1130,7 +1136,7 @@ static inline int input_available_p(struct tty_struct *tty, int amt) * */ -static inline int copy_from_read_buf(struct tty_struct *tty, +static int copy_from_read_buf(struct tty_struct *tty, unsigned char __user **b, size_t *nr) @@ -1308,6 +1314,7 @@ static ssize_t read_chan(struct tty_struct *tty, struct file *file, retval = -ERESTARTSYS; break; } + n_tty_set_room(tty); clear_bit(TTY_DONT_FLIP, &tty->flags); timeout = schedule_timeout(timeout); set_bit(TTY_DONT_FLIP, &tty->flags); @@ -1401,6 +1408,8 @@ static ssize_t read_chan(struct tty_struct *tty, struct file *file, } else if (test_and_clear_bit(TTY_PUSH, &tty->flags)) goto do_it_again; + n_tty_set_room(tty); + return retval; } @@ -1553,7 +1562,6 @@ struct tty_ldisc tty_ldisc_N_TTY = { normal_poll, /* poll */ NULL, /* hangup */ n_tty_receive_buf, /* receive_buf */ - n_tty_receive_room, /* receive_room */ n_tty_write_wakeup /* write_wakeup */ }; diff --git a/trunk/drivers/char/nvram.c b/trunk/drivers/char/nvram.c index 1af733d07321..3556ccd77570 100644 --- a/trunk/drivers/char/nvram.c +++ b/trunk/drivers/char/nvram.c @@ -557,13 +557,13 @@ pc_proc_infos(unsigned char *nvram, char *buffer, int *len, (nvram[6] & 1) ? (nvram[6] >> 6) + 1 : 0); PRINT_PROC("Floppy 0 type : "); type = nvram[2] >> 4; - if (type < sizeof (floppy_types) / sizeof (*floppy_types)) + if (type < ARRAY_SIZE(floppy_types)) PRINT_PROC("%s\n", floppy_types[type]); else PRINT_PROC("%d (unknown)\n", type); PRINT_PROC("Floppy 1 type : "); type = nvram[2] & 0x0f; - if (type < sizeof (floppy_types) / sizeof (*floppy_types)) + if (type < ARRAY_SIZE(floppy_types)) PRINT_PROC("%s\n", floppy_types[type]); else PRINT_PROC("%d (unknown)\n", type); @@ -843,8 +843,6 @@ static char *colors[] = { "2", "4", "16", "256", "65536", "??", "??", "??" }; -#define fieldsize(a) (sizeof(a)/sizeof(*a)) - static int atari_proc_infos(unsigned char *nvram, char *buffer, int *len, off_t *begin, off_t offset, int size) @@ -856,7 +854,7 @@ atari_proc_infos(unsigned char *nvram, char *buffer, int *len, PRINT_PROC("Checksum status : %svalid\n", checksum ? "" : "not "); PRINT_PROC("Boot preference : "); - for (i = fieldsize(boot_prefs) - 1; i >= 0; --i) { + for (i = ARRAY_SIZE(boot_prefs) - 1; i >= 0; --i) { if (nvram[1] == boot_prefs[i].val) { PRINT_PROC("%s\n", boot_prefs[i].name); break; @@ -878,12 +876,12 @@ atari_proc_infos(unsigned char *nvram, char *buffer, int *len, return 1; PRINT_PROC("OS language : "); - if (nvram[6] < fieldsize(languages)) + if (nvram[6] < ARRAY_SIZE(languages)) PRINT_PROC("%s\n", languages[nvram[6]]); else PRINT_PROC("%u (undefined)\n", nvram[6]); PRINT_PROC("Keyboard language: "); - if (nvram[7] < fieldsize(languages)) + if (nvram[7] < ARRAY_SIZE(languages)) PRINT_PROC("%s\n", languages[nvram[7]]); else PRINT_PROC("%u (undefined)\n", nvram[7]); diff --git a/trunk/drivers/char/pcmcia/synclink_cs.c b/trunk/drivers/char/pcmcia/synclink_cs.c index cf45b100eff1..8a8ca32822ba 100644 --- a/trunk/drivers/char/pcmcia/synclink_cs.c +++ b/trunk/drivers/char/pcmcia/synclink_cs.c @@ -1007,8 +1007,9 @@ static void rx_ready_hdlc(MGSLPC_INFO *info, int eom) static void rx_ready_async(MGSLPC_INFO *info, int tcd) { - unsigned char data, status; + unsigned char data, status, flag; int fifo_count; + int work = 0; struct tty_struct *tty = info->tty; struct mgsl_icount *icount = &info->icount; @@ -1023,20 +1024,16 @@ static void rx_ready_async(MGSLPC_INFO *info, int tcd) fifo_count = 32; } else fifo_count = 32; - + + tty_buffer_request_room(tty, fifo_count); /* Flush received async data to receive data buffer. */ while (fifo_count) { data = read_reg(info, CHA + RXFIFO); status = read_reg(info, CHA + RXFIFO); fifo_count -= 2; - if (tty->flip.count >= TTY_FLIPBUF_SIZE) - break; - - *tty->flip.char_buf_ptr = data; icount->rx++; - - *tty->flip.flag_buf_ptr = 0; + flag = TTY_NORMAL; // if no frameing/crc error then save data // BIT7:parity error @@ -1055,26 +1052,23 @@ static void rx_ready_async(MGSLPC_INFO *info, int tcd) status &= info->read_status_mask; if (status & BIT7) - *tty->flip.flag_buf_ptr = TTY_PARITY; + flag = TTY_PARITY; else if (status & BIT6) - *tty->flip.flag_buf_ptr = TTY_FRAME; + flag = TTY_FRAME; } - - tty->flip.flag_buf_ptr++; - tty->flip.char_buf_ptr++; - tty->flip.count++; + work += tty_insert_flip_char(tty, data, flag); } issue_command(info, CHA, CMD_RXFIFO); if (debug_level >= DEBUG_LEVEL_ISR) { - printk("%s(%d):rx_ready_async count=%d\n", - __FILE__,__LINE__,tty->flip.count); + printk("%s(%d):rx_ready_async", + __FILE__,__LINE__); printk("%s(%d):rx=%d brk=%d parity=%d frame=%d overrun=%d\n", __FILE__,__LINE__,icount->rx,icount->brk, icount->parity,icount->frame,icount->overrun); } - if (tty->flip.count) + if (work) tty_flip_buffer_push(tty); } @@ -4005,7 +3999,7 @@ BOOLEAN register_test(MGSLPC_INFO *info) { static unsigned char patterns[] = { 0x00, 0xff, 0xaa, 0x55, 0x69, 0x96, 0x0f }; - static unsigned int count = sizeof(patterns) / sizeof(patterns[0]); + static unsigned int count = ARRAY_SIZE(patterns); unsigned int i; BOOLEAN rc = TRUE; unsigned long flags; @@ -4016,7 +4010,7 @@ BOOLEAN register_test(MGSLPC_INFO *info) for (i = 0; i < count; i++) { write_reg(info, XAD1, patterns[i]); write_reg(info, XAD2, patterns[(i + 1) % count]); - if ((read_reg(info, XAD1) != patterns[i]) || + if ((read_reg(info, XAD1) != patterns[i]) || (read_reg(info, XAD2) != patterns[(i + 1) % count])) { rc = FALSE; break; diff --git a/trunk/drivers/char/pty.c b/trunk/drivers/char/pty.c index 49f3997fd251..9b5a2c0e7008 100644 --- a/trunk/drivers/char/pty.c +++ b/trunk/drivers/char/pty.c @@ -111,7 +111,7 @@ static int pty_write(struct tty_struct * tty, const unsigned char *buf, int coun if (!to || tty->stopped) return 0; - c = to->ldisc.receive_room(to); + c = to->receive_room; if (c > count) c = count; to->ldisc.receive_buf(to, buf, NULL, c); @@ -126,7 +126,7 @@ static int pty_write_room(struct tty_struct *tty) if (!to || tty->stopped) return 0; - return to->ldisc.receive_room(to); + return to->receive_room; } /* diff --git a/trunk/drivers/char/rio/rio_linux.c b/trunk/drivers/char/rio/rio_linux.c index d7d484024e2b..7085a38532b3 100644 --- a/trunk/drivers/char/rio/rio_linux.c +++ b/trunk/drivers/char/rio/rio_linux.c @@ -56,10 +56,6 @@ #include #include -#if BITS_PER_LONG != 32 -# error FIXME: this driver only works on 32-bit platforms -#endif - #include "linux_compat.h" #include "typdef.h" #include "pkt.h" @@ -215,7 +211,7 @@ static int rio_poll = 1; or less.... */ static int rio_probe_addrs[]= {0xc0000, 0xd0000, 0xe0000}; -#define NR_RIO_ADDRS (sizeof(rio_probe_addrs)/sizeof (int)) +#define NR_RIO_ADDRS ARRAY_SIZE(rio_probe_addrs) /* Set the mask to all-ones. This alas, only supports 32 interrupts. diff --git a/trunk/drivers/char/rio/riointr.c b/trunk/drivers/char/rio/riointr.c index e42e7b50bf6b..ddda9c14e059 100644 --- a/trunk/drivers/char/rio/riointr.c +++ b/trunk/drivers/char/rio/riointr.c @@ -38,6 +38,7 @@ static char *_riointr_c_sccs_ = "@(#)riointr.c 1.2"; #include #include #include +#include #include #include #include @@ -560,6 +561,7 @@ struct Port * PortP; struct PKT *PacketP; register uint DataCnt; uchar * ptr; + unsigned char *buf; int copied =0; static int intCount, RxIntCnt; @@ -657,8 +659,7 @@ struct Port * PortP; ** and available space. */ - transCount = min_t(unsigned int, PacketP->len & PKT_LEN_MASK, - TTY_FLIPBUF_SIZE - TtyP->flip.count); + transCount = tty_buffer_request_room(TtyP, PacketP->len & PKT_LEN_MASK); rio_dprintk (RIO_DEBUG_REC, "port %d: Copy %d bytes\n", PortP->PortNum, transCount); /* @@ -678,9 +679,8 @@ struct Port * PortP; #endif ptr = (uchar *) PacketP->data + PortP->RxDataStart; - rio_memcpy_fromio (TtyP->flip.char_buf_ptr, ptr, transCount); - memset(TtyP->flip.flag_buf_ptr, TTY_NORMAL, transCount); - + tty_prepare_flip_string(TtyP, &buf, transCount); + rio_memcpy_fromio (buf, ptr, transCount); #ifdef STATS /* ** keep a count for statistical purposes @@ -690,9 +690,6 @@ struct Port * PortP; PortP->RxDataStart += transCount; PacketP->len -= transCount; copied += transCount; - TtyP->flip.count += transCount; - TtyP->flip.char_buf_ptr += transCount; - TtyP->flip.flag_buf_ptr += transCount; #ifdef ___DEBUG_IT___ diff --git a/trunk/drivers/char/riscom8.c b/trunk/drivers/char/riscom8.c index 55a3a0188eda..050e70ee5920 100644 --- a/trunk/drivers/char/riscom8.c +++ b/trunk/drivers/char/riscom8.c @@ -46,6 +46,7 @@ #include #include #include +#include #include @@ -107,15 +108,15 @@ static struct riscom_port rc_port[RC_NBOARD * RC_NPORT]; /* RISCom/8 I/O ports addresses (without address translation) */ static unsigned short rc_ioport[] = { -#if 1 +#if 1 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x09, 0x0a, 0x0b, 0x0c, -#else +#else 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x09, 0x0a, 0x0b, 0x0c, 0x10, 0x11, 0x12, 0x18, 0x28, 0x31, 0x32, 0x39, 0x3a, 0x40, 0x41, 0x61, 0x62, 0x63, 0x64, 0x6b, 0x70, 0x71, 0x78, 0x7a, 0x7b, 0x7f, 0x100, 0x101 -#endif +#endif }; -#define RC_NIOPORT (sizeof(rc_ioport) / sizeof(rc_ioport[0])) +#define RC_NIOPORT ARRAY_SIZE(rc_ioport) static inline int rc_paranoia_check(struct riscom_port const * port, @@ -354,28 +355,17 @@ static inline void rc_receive_exc(struct riscom_board const * bp) struct riscom_port *port; struct tty_struct *tty; unsigned char status; - unsigned char ch; + unsigned char ch, flag; if (!(port = rc_get_port(bp, "Receive"))) return; tty = port->tty; - if (tty->flip.count >= TTY_FLIPBUF_SIZE) { - printk(KERN_WARNING "rc%d: port %d: Working around flip " - "buffer overflow.\n", - board_No(bp), port_No(port)); - return; - } #ifdef RC_REPORT_OVERRUN status = rc_in(bp, CD180_RCSR); - if (status & RCSR_OE) { + if (status & RCSR_OE) port->overrun++; -#if 0 - printk(KERN_ERR "rc%d: port %d: Overrun. Total %ld overruns\n", - board_No(bp), port_No(port), port->overrun); -#endif - } status &= port->mark_mask; #else status = rc_in(bp, CD180_RCSR) & port->mark_mask; @@ -393,25 +383,24 @@ static inline void rc_receive_exc(struct riscom_board const * bp) } else if (status & RCSR_BREAK) { printk(KERN_INFO "rc%d: port %d: Handling break...\n", board_No(bp), port_No(port)); - *tty->flip.flag_buf_ptr++ = TTY_BREAK; + flag = TTY_BREAK; if (port->flags & ASYNC_SAK) do_SAK(tty); } else if (status & RCSR_PE) - *tty->flip.flag_buf_ptr++ = TTY_PARITY; + flag = TTY_PARITY; else if (status & RCSR_FE) - *tty->flip.flag_buf_ptr++ = TTY_FRAME; + flag = TTY_FRAME; else if (status & RCSR_OE) - *tty->flip.flag_buf_ptr++ = TTY_OVERRUN; + flag = TTY_OVERRUN; else - *tty->flip.flag_buf_ptr++ = 0; + flag = TTY_NORMAL; - *tty->flip.char_buf_ptr++ = ch; - tty->flip.count++; - schedule_delayed_work(&tty->flip.work, 1); + tty_insert_flip_char(tty, ch, flag); + tty_flip_buffer_push(tty); } static inline void rc_receive(struct riscom_board const * bp) @@ -432,17 +421,15 @@ static inline void rc_receive(struct riscom_board const * bp) #endif while (count--) { - if (tty->flip.count >= TTY_FLIPBUF_SIZE) { + if (tty_buffer_request_room(tty, 1) == 0) { printk(KERN_WARNING "rc%d: port %d: Working around " "flip buffer overflow.\n", board_No(bp), port_No(port)); break; } - *tty->flip.char_buf_ptr++ = rc_in(bp, CD180_RDR); - *tty->flip.flag_buf_ptr++ = 0; - tty->flip.count++; + tty_insert_flip_char(tty, rc_in(bp, CD180_RDR), TTY_NORMAL); } - schedule_delayed_work(&tty->flip.work, 1); + tty_flip_buffer_push(tty); } static inline void rc_transmit(struct riscom_board const * bp) diff --git a/trunk/drivers/char/rocket.c b/trunk/drivers/char/rocket.c index d3bc731fbb27..0949dcef0697 100644 --- a/trunk/drivers/char/rocket.c +++ b/trunk/drivers/char/rocket.c @@ -325,19 +325,16 @@ static void rp_do_receive(struct r_port *info, { unsigned int CharNStat; int ToRecv, wRecv, space = 0, count; - unsigned char *cbuf; - char *fbuf; + unsigned char *cbuf, *chead; + char *fbuf, *fhead; struct tty_ldisc *ld; ld = tty_ldisc_ref(tty); ToRecv = sGetRxCnt(cp); - if (ld) - space = ld->receive_room(tty); + space = tty->receive_room; if (space > 2 * TTY_FLIPBUF_SIZE) space = 2 * TTY_FLIPBUF_SIZE; - cbuf = tty->flip.char_buf; - fbuf = tty->flip.flag_buf; count = 0; #ifdef ROCKET_DEBUG_INTR printk(KERN_INFO "rp_do_receive(%d, %d)...", ToRecv, space); @@ -350,9 +347,13 @@ static void rp_do_receive(struct r_port *info, if (ToRecv > space) ToRecv = space; + ToRecv = tty_prepare_flip_string_flags(tty, &chead, &fhead, ToRecv); if (ToRecv <= 0) goto done; + cbuf = chead; + fbuf = fhead; + /* * if status indicates there are errored characters in the * FIFO, then enter status mode (a word in FIFO holds @@ -399,7 +400,7 @@ static void rp_do_receive(struct r_port *info, else if (CharNStat & STMRCVROVRH) *fbuf++ = TTY_OVERRUN; else - *fbuf++ = 0; + *fbuf++ = TTY_NORMAL; *cbuf++ = CharNStat & 0xff; count++; ToRecv--; @@ -426,13 +427,13 @@ static void rp_do_receive(struct r_port *info, sInStrW(sGetTxRxDataIO(cp), (unsigned short *) cbuf, wRecv); if (ToRecv & 1) cbuf[ToRecv - 1] = sInB(sGetTxRxDataIO(cp)); - memset(fbuf, 0, ToRecv); + memset(fbuf, TTY_NORMAL, ToRecv); cbuf += ToRecv; fbuf += ToRecv; count += ToRecv; } /* Push the data up to the tty layer */ - ld->receive_buf(tty, tty->flip.char_buf, tty->flip.flag_buf, count); + ld->receive_buf(tty, cbuf, fbuf, count); done: tty_ldisc_deref(ld); } diff --git a/trunk/drivers/char/selection.c b/trunk/drivers/char/selection.c index 5b187c895c18..71093a9fc462 100644 --- a/trunk/drivers/char/selection.c +++ b/trunk/drivers/char/selection.c @@ -275,7 +275,8 @@ int set_selection(const struct tiocl_selection __user *sel, struct tty_struct *t int paste_selection(struct tty_struct *tty) { struct vc_data *vc = (struct vc_data *)tty->driver_data; - int pasted = 0, count; + int pasted = 0; + unsigned int count; struct tty_ldisc *ld; DECLARE_WAITQUEUE(wait, current); @@ -293,7 +294,7 @@ int paste_selection(struct tty_struct *tty) continue; } count = sel_buffer_lth - pasted; - count = min(count, tty->ldisc.receive_room(tty)); + count = min(count, tty->receive_room); tty->ldisc.receive_buf(tty, sel_buffer + pasted, NULL, count); pasted += count; } diff --git a/trunk/drivers/char/ser_a2232.c b/trunk/drivers/char/ser_a2232.c index dda30e42ec79..80a5b840e22f 100644 --- a/trunk/drivers/char/ser_a2232.c +++ b/trunk/drivers/char/ser_a2232.c @@ -194,11 +194,6 @@ static inline void a2232_receive_char(struct a2232_port *port, int ch, int err) */ struct tty_struct *tty = port->gs.tty; - if (tty->flip.count >= TTY_FLIPBUF_SIZE) - return; - - tty->flip.count++; - #if 0 switch(err) { case TTY_BREAK: @@ -212,8 +207,7 @@ static inline void a2232_receive_char(struct a2232_port *port, int ch, int err) } #endif - *tty->flip.flag_buf_ptr++ = err; - *tty->flip.char_buf_ptr++ = ch; + tty_insert_flip_char(tty, ch, err); tty_flip_buffer_push(tty); } diff --git a/trunk/drivers/char/serial167.c b/trunk/drivers/char/serial167.c index c2deac968bdd..f36342ae8e7e 100644 --- a/trunk/drivers/char/serial167.c +++ b/trunk/drivers/char/serial167.c @@ -117,7 +117,7 @@ struct cyclades_port cy_port[] = { {-1 }, /* ttyS2 */ {-1 }, /* ttyS3 */ }; -#define NR_PORTS (sizeof(cy_port)/sizeof(struct cyclades_port)) +#define NR_PORTS ARRAY_SIZE(cy_port) /* * tmp_buf is used as a temporary buffer by serial_write. We need to @@ -422,45 +422,35 @@ cd2401_rxerr_interrupt(int irq, void *dev_id, struct pt_regs *fp) base_addr[CyREOIR] = rfoc ? 0 : CyNOTRANS; return IRQ_HANDLED; } - if (tty->flip.count < TTY_FLIPBUF_SIZE){ - tty->flip.count++; + if (tty_buffer_request_room(tty, 1) != 0){ if (err & info->read_status_mask){ if(err & CyBREAK){ - *tty->flip.flag_buf_ptr++ = TTY_BREAK; - *tty->flip.char_buf_ptr++ = data; + tty_insert_flip_char(tty, data, TTY_BREAK); if (info->flags & ASYNC_SAK){ do_SAK(tty); } }else if(err & CyFRAME){ - *tty->flip.flag_buf_ptr++ = TTY_FRAME; - *tty->flip.char_buf_ptr++ = data; + tty_insert_flip_char(tty, data, TTY_FRAME); }else if(err & CyPARITY){ - *tty->flip.flag_buf_ptr++ = TTY_PARITY; - *tty->flip.char_buf_ptr++ = data; + tty_insert_flip_char(tty, data, TTY_PARITY); }else if(err & CyOVERRUN){ - *tty->flip.flag_buf_ptr++ = TTY_OVERRUN; - *tty->flip.char_buf_ptr++ = 0; + tty_insert_flip_char(tty, 0, TTY_OVERRUN); /* If the flip buffer itself is overflowing, we still loose the next incoming character. */ - if(tty->flip.count < TTY_FLIPBUF_SIZE){ - tty->flip.count++; - *tty->flip.flag_buf_ptr++ = TTY_NORMAL; - *tty->flip.char_buf_ptr++ = data; - } + tty_insert_flip_char(tty, data, TTY_NORMAL); + } /* These two conditions may imply */ /* a normal read should be done. */ /* else if(data & CyTIMEOUT) */ /* else if(data & CySPECHAR) */ }else{ - *tty->flip.flag_buf_ptr++ = 0; - *tty->flip.char_buf_ptr++ = 0; + tty_insert_flip_char(tty, 0, TTY_NORMAL); } }else{ - *tty->flip.flag_buf_ptr++ = 0; - *tty->flip.char_buf_ptr++ = 0; + tty_insert_flip_char(tty, data, TTY_NORMAL); } }else{ /* there was a software buffer overrun @@ -692,12 +682,7 @@ cd2401_rx_interrupt(int irq, void *dev_id, struct pt_regs *fp) #endif while(char_count--){ data = base_addr[CyRDR]; - if (tty->flip.count >= TTY_FLIPBUF_SIZE){ - continue; - } - tty->flip.count++; - *tty->flip.flag_buf_ptr++ = TTY_NORMAL; - *tty->flip.char_buf_ptr++ = data; + tty_insert_flip_char(tty, data, TTY_NORMAL); #ifdef CYCLOM_16Y_HACK udelay(10L); #endif diff --git a/trunk/drivers/char/specialix.c b/trunk/drivers/char/specialix.c index 0bbfce43031c..0a574bdbce36 100644 --- a/trunk/drivers/char/specialix.c +++ b/trunk/drivers/char/specialix.c @@ -85,6 +85,7 @@ #include #include #include +#include #include #include #include @@ -665,7 +666,7 @@ static inline void sx_receive_exc(struct specialix_board * bp) struct specialix_port *port; struct tty_struct *tty; unsigned char status; - unsigned char ch; + unsigned char ch, flag; func_enter(); @@ -676,8 +677,6 @@ static inline void sx_receive_exc(struct specialix_board * bp) return; } tty = port->tty; - dprintk (SX_DEBUG_RX, "port: %p count: %d BUFF_SIZE: %d\n", - port, tty->flip.count, TTY_FLIPBUF_SIZE); status = sx_in(bp, CD186x_RCSR); @@ -691,7 +690,7 @@ static inline void sx_receive_exc(struct specialix_board * bp) /* This flip buffer check needs to be below the reading of the status register to reset the chip's IRQ.... */ - if (tty->flip.count >= TTY_FLIPBUF_SIZE) { + if (tty_buffer_request_room(tty, 1) == 0) { dprintk(SX_DEBUG_FIFO, "sx%d: port %d: Working around flip buffer overflow.\n", board_No(bp), port_No(port)); func_exit(); @@ -712,26 +711,24 @@ static inline void sx_receive_exc(struct specialix_board * bp) } else if (status & RCSR_BREAK) { dprintk(SX_DEBUG_RX, "sx%d: port %d: Handling break...\n", board_No(bp), port_No(port)); - *tty->flip.flag_buf_ptr++ = TTY_BREAK; + flag = TTY_BREAK; if (port->flags & ASYNC_SAK) do_SAK(tty); } else if (status & RCSR_PE) - *tty->flip.flag_buf_ptr++ = TTY_PARITY; + flag = TTY_PARITY; else if (status & RCSR_FE) - *tty->flip.flag_buf_ptr++ = TTY_FRAME; + flag = TTY_FRAME; else if (status & RCSR_OE) - *tty->flip.flag_buf_ptr++ = TTY_OVERRUN; + flag = TTY_OVERRUN; else - *tty->flip.flag_buf_ptr++ = 0; - - *tty->flip.char_buf_ptr++ = ch; - tty->flip.count++; - schedule_delayed_work(&tty->flip.work, 1); + flag = TTY_NORMAL; + if(tty_insert_flip_char(tty, ch, flag)) + tty_flip_buffer_push(tty); func_exit(); } @@ -755,18 +752,11 @@ static inline void sx_receive(struct specialix_board * bp) dprintk (SX_DEBUG_RX, "port: %p: count: %d\n", port, count); port->hits[count > 8 ? 9 : count]++; - while (count--) { - if (tty->flip.count >= TTY_FLIPBUF_SIZE) { - printk(KERN_INFO "sx%d: port %d: Working around flip buffer overflow.\n", - board_No(bp), port_No(port)); - break; - } - *tty->flip.char_buf_ptr++ = sx_in(bp, CD186x_RDR); - *tty->flip.flag_buf_ptr++ = 0; - tty->flip.count++; - } - schedule_delayed_work(&tty->flip.work, 1); + tty_buffer_request_room(tty, count); + while (count--) + tty_insert_flip_char(tty, sx_in(bp, CD186x_RDR), TTY_NORMAL); + tty_flip_buffer_push(tty); func_exit(); } diff --git a/trunk/drivers/char/stallion.c b/trunk/drivers/char/stallion.c index 95af2a941595..0e20780d4a29 100644 --- a/trunk/drivers/char/stallion.c +++ b/trunk/drivers/char/stallion.c @@ -103,7 +103,7 @@ static stlconf_t stl_brdconf[] = { /*{ BRD_EASYIO, 0x2a0, 0, 0, 10, 0 },*/ }; -static int stl_nrbrds = sizeof(stl_brdconf) / sizeof(stlconf_t); +static int stl_nrbrds = ARRAY_SIZE(stl_brdconf); /*****************************************************************************/ @@ -424,7 +424,7 @@ static stlpcibrd_t stl_pcibrds[] = { { PCI_VENDOR_ID_NS, PCI_DEVICE_ID_NS_87410, BRD_ECHPCI }, }; -static int stl_nrpcibrds = sizeof(stl_pcibrds) / sizeof(stlpcibrd_t); +static int stl_nrpcibrds = ARRAY_SIZE(stl_pcibrds); #endif @@ -704,7 +704,7 @@ static unsigned int sc26198_baudtable[] = { 230400, 460800, 921600 }; -#define SC26198_NRBAUDS (sizeof(sc26198_baudtable) / sizeof(unsigned int)) +#define SC26198_NRBAUDS ARRAY_SIZE(sc26198_baudtable) /*****************************************************************************/ @@ -901,7 +901,7 @@ static unsigned long stl_atol(char *str) static int stl_parsebrd(stlconf_t *confp, char **argp) { char *sp; - int nrbrdnames, i; + int i; #ifdef DEBUG printk("stl_parsebrd(confp=%x,argp=%x)\n", (int) confp, (int) argp); @@ -913,14 +913,13 @@ static int stl_parsebrd(stlconf_t *confp, char **argp) for (sp = argp[0], i = 0; ((*sp != 0) && (i < 25)); sp++, i++) *sp = TOLOWER(*sp); - nrbrdnames = sizeof(stl_brdstr) / sizeof(stlbrdtype_t); - for (i = 0; (i < nrbrdnames); i++) { + for (i = 0; i < ARRAY_SIZE(stl_brdstr); i++) { if (strcmp(stl_brdstr[i].name, argp[0]) == 0) break; } - if (i >= nrbrdnames) { + if (i == ARRAY_SIZE(stl_brdstr)) { printk("STALLION: unknown board name, %s?\n", argp[0]); - return(0); + return 0; } confp->brdtype = stl_brdstr[i].type; @@ -2902,7 +2901,8 @@ static int stl_getportstats(stlport_t *portp, comstats_t __user *cp) if (portp->tty != (struct tty_struct *) NULL) { if (portp->tty->driver_data == portp) { portp->stats.ttystate = portp->tty->flags; - portp->stats.rxbuffered = portp->tty->flip.count; + /* No longer available as a statistic */ + portp->stats.rxbuffered = 1; /*portp->tty->flip.count; */ if (portp->tty->termios != (struct termios *) NULL) { portp->stats.cflags = portp->tty->termios->c_cflag; portp->stats.iflags = portp->tty->termios->c_iflag; @@ -4046,9 +4046,7 @@ static void stl_cd1400rxisr(stlpanel_t *panelp, int ioaddr) if ((ioack & ACK_TYPMASK) == ACK_TYPRXGOOD) { outb((RDCR + portp->uartaddr), ioaddr); len = inb(ioaddr + EREG_DATA); - if ((tty == (struct tty_struct *) NULL) || - (tty->flip.char_buf_ptr == (char *) NULL) || - ((buflen = TTY_FLIPBUF_SIZE - tty->flip.count) == 0)) { + if (tty == NULL || (buflen = tty_buffer_request_room(tty, len)) == 0) { len = MIN(len, sizeof(stl_unwanted)); outb((RDSR + portp->uartaddr), ioaddr); insb((ioaddr + EREG_DATA), &stl_unwanted[0], len); @@ -4057,12 +4055,10 @@ static void stl_cd1400rxisr(stlpanel_t *panelp, int ioaddr) } else { len = MIN(len, buflen); if (len > 0) { + unsigned char *ptr; outb((RDSR + portp->uartaddr), ioaddr); - insb((ioaddr + EREG_DATA), tty->flip.char_buf_ptr, len); - memset(tty->flip.flag_buf_ptr, 0, len); - tty->flip.flag_buf_ptr += len; - tty->flip.char_buf_ptr += len; - tty->flip.count += len; + tty_prepare_flip_string(tty, &ptr, len); + insb((ioaddr + EREG_DATA), ptr, len); tty_schedule_flip(tty); portp->stats.rxtotal += len; } @@ -4086,8 +4082,7 @@ static void stl_cd1400rxisr(stlpanel_t *panelp, int ioaddr) portp->stats.txxoff++; goto stl_rxalldone; } - if ((tty != (struct tty_struct *) NULL) && - ((portp->rxignoremsk & status) == 0)) { + if (tty != NULL && (portp->rxignoremsk & status) == 0) { if (portp->rxmarkmsk & status) { if (status & ST_BREAK) { status = TTY_BREAK; @@ -4107,14 +4102,8 @@ static void stl_cd1400rxisr(stlpanel_t *panelp, int ioaddr) } else { status = 0; } - if (tty->flip.char_buf_ptr != (char *) NULL) { - if (tty->flip.count < TTY_FLIPBUF_SIZE) { - *tty->flip.flag_buf_ptr++ = status; - *tty->flip.char_buf_ptr++ = ch; - tty->flip.count++; - } - tty_schedule_flip(tty); - } + tty_insert_flip_char(tty, ch, status); + tty_schedule_flip(tty); } } else { printk("STALLION: bad RX interrupt ack value=%x\n", ioack); @@ -5013,9 +5002,7 @@ static void stl_sc26198rxisr(stlport_t *portp, unsigned int iack) len = inb(ioaddr + XP_DATA) + 1; if ((iack & IVR_TYPEMASK) == IVR_RXDATA) { - if ((tty == (struct tty_struct *) NULL) || - (tty->flip.char_buf_ptr == (char *) NULL) || - ((buflen = TTY_FLIPBUF_SIZE - tty->flip.count) == 0)) { + if (tty == NULL || (buflen = tty_buffer_request_room(tty, len)) == 0) { len = MIN(len, sizeof(stl_unwanted)); outb(GRXFIFO, (ioaddr + XP_ADDR)); insb((ioaddr + XP_DATA), &stl_unwanted[0], len); @@ -5024,12 +5011,10 @@ static void stl_sc26198rxisr(stlport_t *portp, unsigned int iack) } else { len = MIN(len, buflen); if (len > 0) { + unsigned char *ptr; outb(GRXFIFO, (ioaddr + XP_ADDR)); - insb((ioaddr + XP_DATA), tty->flip.char_buf_ptr, len); - memset(tty->flip.flag_buf_ptr, 0, len); - tty->flip.flag_buf_ptr += len; - tty->flip.char_buf_ptr += len; - tty->flip.count += len; + tty_prepare_flip_string(tty, &ptr, len); + insb((ioaddr + XP_DATA), ptr, len); tty_schedule_flip(tty); portp->stats.rxtotal += len; } @@ -5097,14 +5082,8 @@ static inline void stl_sc26198rxbadch(stlport_t *portp, unsigned char status, ch status = 0; } - if (tty->flip.char_buf_ptr != (char *) NULL) { - if (tty->flip.count < TTY_FLIPBUF_SIZE) { - *tty->flip.flag_buf_ptr++ = status; - *tty->flip.char_buf_ptr++ = ch; - tty->flip.count++; - } - tty_schedule_flip(tty); - } + tty_insert_flip_char(tty, ch, status); + tty_schedule_flip(tty); if (status == 0) portp->stats.rxtotal++; diff --git a/trunk/drivers/char/sx.c b/trunk/drivers/char/sx.c index 3ad758a9a1dc..64bf89cb574f 100644 --- a/trunk/drivers/char/sx.c +++ b/trunk/drivers/char/sx.c @@ -345,9 +345,9 @@ static int si_probe_addrs[]= {0xc0000, 0xd0000, 0xe0000, 0xc8000, 0xd8000, 0xe8000, 0xa0000}; static int si1_probe_addrs[]= { 0xd0000}; -#define NR_SX_ADDRS (sizeof(sx_probe_addrs)/sizeof (int)) -#define NR_SI_ADDRS (sizeof(si_probe_addrs)/sizeof (int)) -#define NR_SI1_ADDRS (sizeof(si1_probe_addrs)/sizeof (int)) +#define NR_SX_ADDRS ARRAY_SIZE(sx_probe_addrs) +#define NR_SI_ADDRS ARRAY_SIZE(si_probe_addrs) +#define NR_SI1_ADDRS ARRAY_SIZE(si1_probe_addrs) /* Set the mask to all-ones. This alas, only supports 32 interrupts. @@ -1085,6 +1085,7 @@ static inline void sx_receive_chars (struct sx_port *port) int rx_op; struct tty_struct *tty; int copied=0; + unsigned char *rp; func_enter2 (); tty = port->gs.tty; @@ -1095,8 +1096,8 @@ static inline void sx_receive_chars (struct sx_port *port) sx_dprintk (SX_DEBUG_RECEIVE, "rxop=%d, c = %d.\n", rx_op, c); /* Don't copy more bytes than there is room for in the buffer */ - if (tty->flip.count + c > TTY_FLIPBUF_SIZE) - c = TTY_FLIPBUF_SIZE - tty->flip.count; + + c = tty_prepare_flip_string(tty, &rp, c); sx_dprintk (SX_DEBUG_RECEIVE, "c = %d.\n", c); @@ -1111,14 +1112,8 @@ static inline void sx_receive_chars (struct sx_port *port) sx_dprintk (SX_DEBUG_RECEIVE , "Copying over %d chars. First is %d at %lx\n", c, read_sx_byte (port->board, CHAN_OFFSET(port,hi_rxbuf) + rx_op), CHAN_OFFSET(port, hi_rxbuf)); - memcpy_fromio (tty->flip.char_buf_ptr, + memcpy_fromio (rp, port->board->base + CHAN_OFFSET(port,hi_rxbuf) + rx_op, c); - memset(tty->flip.flag_buf_ptr, TTY_NORMAL, c); - - /* Update the kernel buffer end */ - tty->flip.count += c; - tty->flip.char_buf_ptr += c; - tty->flip.flag_buf_ptr += c; /* This one last. ( Not essential.) It allows the card to start putting more data into the buffer! diff --git a/trunk/drivers/char/synclink.c b/trunk/drivers/char/synclink.c index 62aa0e534a6d..9f1b466c4f84 100644 --- a/trunk/drivers/char/synclink.c +++ b/trunk/drivers/char/synclink.c @@ -1467,6 +1467,7 @@ static void mgsl_isr_receive_data( struct mgsl_struct *info ) { int Fifocount; u16 status; + int work = 0; unsigned char DataByte; struct tty_struct *tty = info->tty; struct mgsl_icount *icount = &info->icount; @@ -1487,6 +1488,8 @@ static void mgsl_isr_receive_data( struct mgsl_struct *info ) /* flush the receive FIFO */ while( (Fifocount = (usc_InReg(info,RICR) >> 8)) ) { + int flag; + /* read one byte from RxFIFO */ outw( (inw(info->io_base + CCAR) & 0x0780) | (RDR+LSBONLY), info->io_base + CCAR ); @@ -1498,13 +1501,9 @@ static void mgsl_isr_receive_data( struct mgsl_struct *info ) RXSTATUS_OVERRUN + RXSTATUS_BREAK_RECEIVED) ) usc_UnlatchRxstatusBits(info,RXSTATUS_ALL); - if (tty->flip.count >= TTY_FLIPBUF_SIZE) - continue; - - *tty->flip.char_buf_ptr = DataByte; icount->rx++; - *tty->flip.flag_buf_ptr = 0; + flag = 0; if ( status & (RXSTATUS_FRAMING_ERROR + RXSTATUS_PARITY_ERROR + RXSTATUS_OVERRUN + RXSTATUS_BREAK_RECEIVED) ) { printk("rxerr=%04X\n",status); @@ -1530,41 +1529,31 @@ static void mgsl_isr_receive_data( struct mgsl_struct *info ) status &= info->read_status_mask; if (status & RXSTATUS_BREAK_RECEIVED) { - *tty->flip.flag_buf_ptr = TTY_BREAK; + flag = TTY_BREAK; if (info->flags & ASYNC_SAK) do_SAK(tty); } else if (status & RXSTATUS_PARITY_ERROR) - *tty->flip.flag_buf_ptr = TTY_PARITY; + flag = TTY_PARITY; else if (status & RXSTATUS_FRAMING_ERROR) - *tty->flip.flag_buf_ptr = TTY_FRAME; - if (status & RXSTATUS_OVERRUN) { - /* Overrun is special, since it's - * reported immediately, and doesn't - * affect the current character - */ - if (tty->flip.count < TTY_FLIPBUF_SIZE) { - tty->flip.count++; - tty->flip.flag_buf_ptr++; - tty->flip.char_buf_ptr++; - *tty->flip.flag_buf_ptr = TTY_OVERRUN; - } - } + flag = TTY_FRAME; } /* end of if (error) */ - - tty->flip.flag_buf_ptr++; - tty->flip.char_buf_ptr++; - tty->flip.count++; + tty_insert_flip_char(tty, DataByte, flag); + if (status & RXSTATUS_OVERRUN) { + /* Overrun is special, since it's + * reported immediately, and doesn't + * affect the current character + */ + work += tty_insert_flip_char(tty, 0, TTY_OVERRUN); + } } if ( debug_level >= DEBUG_LEVEL_ISR ) { - printk("%s(%d):mgsl_isr_receive_data flip count=%d\n", - __FILE__,__LINE__,tty->flip.count); printk("%s(%d):rx=%d brk=%d parity=%d frame=%d overrun=%d\n", __FILE__,__LINE__,icount->rx,icount->brk, icount->parity,icount->frame,icount->overrun); } - if ( tty->flip.count ) + if(work) tty_flip_buffer_push(tty); } @@ -7058,7 +7047,7 @@ static BOOLEAN mgsl_register_test( struct mgsl_struct *info ) { static unsigned short BitPatterns[] = { 0x0000, 0xffff, 0xaaaa, 0x5555, 0x1234, 0x6969, 0x9696, 0x0f0f }; - static unsigned int Patterncount = sizeof(BitPatterns)/sizeof(unsigned short); + static unsigned int Patterncount = ARRAY_SIZE(BitPatterns); unsigned int i; BOOLEAN rc = TRUE; unsigned long flags; @@ -7501,9 +7490,9 @@ static int mgsl_adapter_test( struct mgsl_struct *info ) */ static BOOLEAN mgsl_memory_test( struct mgsl_struct *info ) { - static unsigned long BitPatterns[] = { 0x0, 0x55555555, 0xaaaaaaaa, - 0x66666666, 0x99999999, 0xffffffff, 0x12345678 }; - unsigned long Patterncount = sizeof(BitPatterns)/sizeof(unsigned long); + static unsigned long BitPatterns[] = + { 0x0, 0x55555555, 0xaaaaaaaa, 0x66666666, 0x99999999, 0xffffffff, 0x12345678 }; + unsigned long Patterncount = ARRAY_SIZE(BitPatterns); unsigned long i; unsigned long TestLimit = SHARED_MEM_ADDRESS_SIZE/sizeof(unsigned long); unsigned long * TestAddr; diff --git a/trunk/drivers/char/synclink_gt.c b/trunk/drivers/char/synclink_gt.c index 2b9cde94e2f7..79c81def4104 100644 --- a/trunk/drivers/char/synclink_gt.c +++ b/trunk/drivers/char/synclink_gt.c @@ -75,7 +75,6 @@ #include #include -#include #include #include #include @@ -1750,6 +1749,9 @@ static void rx_async(struct slgt_info *info) unsigned char status; struct slgt_desc *bufs = info->rbufs; int i, count; + int chars = 0; + int stat; + unsigned char ch; start = end = info->rbuf_current; @@ -1761,16 +1763,15 @@ static void rx_async(struct slgt_info *info) DBGDATA(info, p, count, "rx"); for(i=0 ; i < count; i+=2, p+=2) { - if (tty) { - if (tty->flip.count >= TTY_FLIPBUF_SIZE) - tty_flip_buffer_push(tty); - if (tty->flip.count >= TTY_FLIPBUF_SIZE) - break; - *tty->flip.char_buf_ptr = *p; - *tty->flip.flag_buf_ptr = 0; + if (tty && chars) { + tty_flip_buffer_push(tty); + chars = 0; } + ch = *p; icount->rx++; + stat = 0; + if ((status = *(p+1) & (BIT9 + BIT8))) { if (status & BIT9) icount->parity++; @@ -1779,17 +1780,14 @@ static void rx_async(struct slgt_info *info) /* discard char if tty control flags say so */ if (status & info->ignore_status_mask) continue; - if (tty) { - if (status & BIT9) - *tty->flip.flag_buf_ptr = TTY_PARITY; - else if (status & BIT8) - *tty->flip.flag_buf_ptr = TTY_FRAME; - } + if (status & BIT9) + stat = TTY_PARITY; + else if (status & BIT8) + stat = TTY_FRAME; } if (tty) { - tty->flip.flag_buf_ptr++; - tty->flip.char_buf_ptr++; - tty->flip.count++; + tty_insert_flip_char(tty, ch, stat); + chars++; } } @@ -1812,7 +1810,7 @@ static void rx_async(struct slgt_info *info) break; } - if (tty && tty->flip.count) + if (tty && chars) tty_flip_buffer_push(tty); } @@ -2030,7 +2028,7 @@ static void isr_serial(struct slgt_info *info) if (info->tty) { if (!(status & info->ignore_status_mask)) { if (info->read_status_mask & MASK_BREAK) { - *info->tty->flip.flag_buf_ptr = TTY_BREAK; + tty_insert_flip_char(info->tty, 0, TTY_BREAK); if (info->flags & ASYNC_SAK) do_SAK(info->tty); } diff --git a/trunk/drivers/char/synclinkmp.c b/trunk/drivers/char/synclinkmp.c index ee5a40be9f99..960adb256fbb 100644 --- a/trunk/drivers/char/synclinkmp.c +++ b/trunk/drivers/char/synclinkmp.c @@ -2196,7 +2196,7 @@ void isr_rxint(SLMP_INFO * info) if ( tty ) { if (!(status & info->ignore_status_mask1)) { if (info->read_status_mask1 & BRKD) { - *tty->flip.flag_buf_ptr = TTY_BREAK; + tty_insert_flip_char(tty, 0, TTY_BREAK); if (info->flags & ASYNC_SAK) do_SAK(tty); } @@ -2240,16 +2240,10 @@ void isr_rxrdy(SLMP_INFO * info) while((status = read_reg(info,CST0)) & BIT0) { + int flag = 0; + int over = 0; DataByte = read_reg(info,TRB); - if ( tty ) { - if (tty->flip.count >= TTY_FLIPBUF_SIZE) - continue; - - *tty->flip.char_buf_ptr = DataByte; - *tty->flip.flag_buf_ptr = 0; - } - icount->rx++; if ( status & (PE + FRME + OVRN) ) { @@ -2272,42 +2266,34 @@ void isr_rxrdy(SLMP_INFO * info) if ( tty ) { if (status & PE) - *tty->flip.flag_buf_ptr = TTY_PARITY; + flag = TTY_PARITY; else if (status & FRME) - *tty->flip.flag_buf_ptr = TTY_FRAME; + flag = TTY_FRAME; if (status & OVRN) { /* Overrun is special, since it's * reported immediately, and doesn't * affect the current character */ - if (tty->flip.count < TTY_FLIPBUF_SIZE) { - tty->flip.count++; - tty->flip.flag_buf_ptr++; - tty->flip.char_buf_ptr++; - *tty->flip.flag_buf_ptr = TTY_OVERRUN; - } + over = 1; } } } /* end of if (error) */ if ( tty ) { - tty->flip.flag_buf_ptr++; - tty->flip.char_buf_ptr++; - tty->flip.count++; + tty_insert_flip_char(tty, DataByte, flag); + if (over) + tty_insert_flip_char(tty, 0, TTY_OVERRUN); } } if ( debug_level >= DEBUG_LEVEL_ISR ) { - printk("%s(%d):%s isr_rxrdy() flip count=%d\n", - __FILE__,__LINE__,info->device_name, - tty ? tty->flip.count : 0); printk("%s(%d):%s rx=%d brk=%d parity=%d frame=%d overrun=%d\n", __FILE__,__LINE__,info->device_name, icount->rx,icount->brk,icount->parity, icount->frame,icount->overrun); } - if ( tty && tty->flip.count ) + if ( tty ) tty_flip_buffer_push(tty); } @@ -5104,7 +5090,7 @@ void tx_load_dma_buffer(SLMP_INFO *info, const char *buf, unsigned int count) int register_test(SLMP_INFO *info) { static unsigned char testval[] = {0x00, 0xff, 0xaa, 0x55, 0x69, 0x96}; - static unsigned int count = sizeof(testval)/sizeof(unsigned char); + static unsigned int count = ARRAY_SIZE(testval); unsigned int i; int rc = TRUE; unsigned long flags; @@ -5422,7 +5408,7 @@ int memory_test(SLMP_INFO *info) { static unsigned long testval[] = { 0x0, 0x55555555, 0xaaaaaaaa, 0x66666666, 0x99999999, 0xffffffff, 0x12345678 }; - unsigned long count = sizeof(testval)/sizeof(unsigned long); + unsigned long count = ARRAY_SIZE(testval); unsigned long i; unsigned long limit = SCA_MEM_SIZE/sizeof(unsigned long); unsigned long * addr = (unsigned long *)info->memory_base; diff --git a/trunk/drivers/char/tty_io.c b/trunk/drivers/char/tty_io.c index 4b1eef51ec59..1eda82b31a61 100644 --- a/trunk/drivers/char/tty_io.c +++ b/trunk/drivers/char/tty_io.c @@ -166,9 +166,12 @@ static struct tty_struct *alloc_tty_struct(void) return tty; } +static void tty_buffer_free_all(struct tty_struct *); + static inline void free_tty_struct(struct tty_struct *tty) { kfree(tty->write_buf); + tty_buffer_free_all(tty); kfree(tty); } @@ -230,6 +233,201 @@ static int check_tty_count(struct tty_struct *tty, const char *routine) return 0; } +/* + * Tty buffer allocation management + */ + +static void tty_buffer_free_all(struct tty_struct *tty) +{ + struct tty_buffer *thead; + while((thead = tty->buf.head) != NULL) { + tty->buf.head = thead->next; + kfree(thead); + } + while((thead = tty->buf.free) != NULL) { + tty->buf.free = thead->next; + kfree(thead); + } + tty->buf.tail = NULL; +} + +static void tty_buffer_init(struct tty_struct *tty) +{ + tty->buf.head = NULL; + tty->buf.tail = NULL; + tty->buf.free = NULL; +} + +static struct tty_buffer *tty_buffer_alloc(size_t size) +{ + struct tty_buffer *p = kmalloc(sizeof(struct tty_buffer) + 2 * size, GFP_ATOMIC); + if(p == NULL) + return NULL; + p->used = 0; + p->size = size; + p->next = NULL; + p->char_buf_ptr = (char *)(p->data); + p->flag_buf_ptr = (unsigned char *)p->char_buf_ptr + size; +/* printk("Flip create %p\n", p); */ + return p; +} + +/* Must be called with the tty_read lock held. This needs to acquire strategy + code to decide if we should kfree or relink a given expired buffer */ + +static void tty_buffer_free(struct tty_struct *tty, struct tty_buffer *b) +{ + /* Dumb strategy for now - should keep some stats */ +/* printk("Flip dispose %p\n", b); */ + if(b->size >= 512) + kfree(b); + else { + b->next = tty->buf.free; + tty->buf.free = b; + } +} + +static struct tty_buffer *tty_buffer_find(struct tty_struct *tty, size_t size) +{ + struct tty_buffer **tbh = &tty->buf.free; + while((*tbh) != NULL) { + struct tty_buffer *t = *tbh; + if(t->size >= size) { + *tbh = t->next; + t->next = NULL; + t->used = 0; + /* DEBUG ONLY */ + memset(t->data, '*', size); +/* printk("Flip recycle %p\n", t); */ + return t; + } + tbh = &((*tbh)->next); + } + /* Round the buffer size out */ + size = (size + 0xFF) & ~ 0xFF; + return tty_buffer_alloc(size); + /* Should possibly check if this fails for the largest buffer we + have queued and recycle that ? */ +} + +int tty_buffer_request_room(struct tty_struct *tty, size_t size) +{ + struct tty_buffer *b = tty->buf.head, *n; + int left = 0; + + /* OPTIMISATION: We could keep a per tty "zero" sized buffer to + remove this conditional if its worth it. This would be invisible + to the callers */ + if(b != NULL) + left = b->size - b->used; + if(left >= size) + return size; + /* This is the slow path - looking for new buffers to use */ + n = tty_buffer_find(tty, size); + if(n == NULL) + return left; + n->next = b; + if(b != NULL) + b->next = n; + else + tty->buf.head = n; + tty->buf.tail = n; + return size; +} + +EXPORT_SYMBOL_GPL(tty_buffer_request_room); + +int tty_insert_flip_string(struct tty_struct *tty, unsigned char *chars, size_t size) +{ + int copied = 0; + do { + int space = tty_buffer_request_room(tty, size - copied); + struct tty_buffer *tb = tty->buf.tail; + /* If there is no space then tb may be NULL */ + if(unlikely(space == 0)) + break; + memcpy(tb->char_buf_ptr + tb->used, chars, space); + memset(tb->flag_buf_ptr + tb->used, TTY_NORMAL, space); + tb->used += space; + copied += space; + chars += space; +/* printk("Flip insert %d.\n", space); */ + } + /* There is a small chance that we need to split the data over + several buffers. If this is the case we must loop */ + while (unlikely(size > copied)); + return copied; +} + +EXPORT_SYMBOL_GPL(tty_insert_flip_string); + +int tty_insert_flip_string_flags(struct tty_struct *tty, unsigned char *chars, char *flags, size_t size) +{ + int copied = 0; + do { + int space = tty_buffer_request_room(tty, size - copied); + struct tty_buffer *tb = tty->buf.tail; + /* If there is no space then tb may be NULL */ + if(unlikely(space == 0)) + break; + memcpy(tb->char_buf_ptr + tb->used, chars, space); + memcpy(tb->flag_buf_ptr + tb->used, flags, space); + tb->used += space; + copied += space; + chars += space; + flags += space; + } + /* There is a small chance that we need to split the data over + several buffers. If this is the case we must loop */ + while (unlikely(size > copied)); + return copied; +} + +EXPORT_SYMBOL_GPL(tty_insert_flip_string_flags); + + +/* + * Prepare a block of space in the buffer for data. Returns the length + * available and buffer pointer to the space which is now allocated and + * accounted for as ready for normal characters. This is used for drivers + * that need their own block copy routines into the buffer. There is no + * guarantee the buffer is a DMA target! + */ + +int tty_prepare_flip_string(struct tty_struct *tty, unsigned char **chars, size_t size) +{ + int space = tty_buffer_request_room(tty, size); + struct tty_buffer *tb = tty->buf.tail; + *chars = tb->char_buf_ptr + tb->used; + memset(tb->flag_buf_ptr + tb->used, TTY_NORMAL, space); + tb->used += space; + return space; +} + +EXPORT_SYMBOL_GPL(tty_prepare_flip_string); + +/* + * Prepare a block of space in the buffer for data. Returns the length + * available and buffer pointer to the space which is now allocated and + * accounted for as ready for characters. This is used for drivers + * that need their own block copy routines into the buffer. There is no + * guarantee the buffer is a DMA target! + */ + +int tty_prepare_flip_string_flags(struct tty_struct *tty, unsigned char **chars, char **flags, size_t size) +{ + int space = tty_buffer_request_room(tty, size); + struct tty_buffer *tb = tty->buf.tail; + *chars = tb->char_buf_ptr + tb->used; + *flags = tb->flag_buf_ptr + tb->used; + tb->used += space; + return space; +} + +EXPORT_SYMBOL_GPL(tty_prepare_flip_string_flags); + + + /* * This is probably overkill for real world processors but * they are not on hot paths so a little discipline won't do @@ -492,6 +690,17 @@ static int tty_set_ldisc(struct tty_struct *tty, int ldisc) if (ld == NULL) return -EINVAL; + /* + * No more input please, we are switching. The new ldisc + * will update this value in the ldisc open function + */ + + tty->receive_room = 0; + + /* + * Problem: What do we do if this blocks ? + */ + tty_wait_until_sent(tty, 0); if (tty->ldisc.num == ldisc) { @@ -560,9 +769,9 @@ static int tty_set_ldisc(struct tty_struct *tty, int ldisc) * we say so later on. */ - work = cancel_delayed_work(&tty->flip.work); + work = cancel_delayed_work(&tty->buf.work); /* - * Wait for ->hangup_work and ->flip.work handlers to terminate + * Wait for ->hangup_work and ->buf.work handlers to terminate */ flush_scheduled_work(); @@ -616,7 +825,7 @@ static int tty_set_ldisc(struct tty_struct *tty, int ldisc) /* Restart it in case no characters kick it off. Safe if already running */ if (work) - schedule_delayed_work(&tty->flip.work, 1); + schedule_delayed_work(&tty->buf.work, 1); return retval; } @@ -1721,10 +1930,10 @@ static void release_dev(struct file * filp) */ clear_bit(TTY_LDISC, &tty->flags); clear_bit(TTY_DONT_FLIP, &tty->flags); - cancel_delayed_work(&tty->flip.work); + cancel_delayed_work(&tty->buf.work); /* - * Wait for ->hangup_work and ->flip.work handlers to terminate + * Wait for ->hangup_work and ->buf.work handlers to terminate */ flush_scheduled_work(); @@ -2518,17 +2727,15 @@ EXPORT_SYMBOL(do_SAK); /* * This routine is called out of the software interrupt to flush data - * from the flip buffer to the line discipline. + * from the buffer chain to the line discipline. */ static void flush_to_ldisc(void *private_) { struct tty_struct *tty = (struct tty_struct *) private_; - unsigned char *cp; - char *fp; - int count; unsigned long flags; struct tty_ldisc *disc; + struct tty_buffer *tbuf; disc = tty_ldisc_ref(tty); if (disc == NULL) /* !TTY_LDISC */ @@ -2538,28 +2745,22 @@ static void flush_to_ldisc(void *private_) /* * Do it after the next timer tick: */ - schedule_delayed_work(&tty->flip.work, 1); + schedule_delayed_work(&tty->buf.work, 1); goto out; } spin_lock_irqsave(&tty->read_lock, flags); - if (tty->flip.buf_num) { - cp = tty->flip.char_buf + TTY_FLIPBUF_SIZE; - fp = tty->flip.flag_buf + TTY_FLIPBUF_SIZE; - tty->flip.buf_num = 0; - tty->flip.char_buf_ptr = tty->flip.char_buf; - tty->flip.flag_buf_ptr = tty->flip.flag_buf; - } else { - cp = tty->flip.char_buf; - fp = tty->flip.flag_buf; - tty->flip.buf_num = 1; - tty->flip.char_buf_ptr = tty->flip.char_buf + TTY_FLIPBUF_SIZE; - tty->flip.flag_buf_ptr = tty->flip.flag_buf + TTY_FLIPBUF_SIZE; - } - count = tty->flip.count; - tty->flip.count = 0; + while((tbuf = tty->buf.head) != NULL) { + tty->buf.head = tbuf->next; + spin_unlock_irqrestore(&tty->read_lock, flags); + /* printk("Process buffer %p for %d\n", tbuf, tbuf->used); */ + disc->receive_buf(tty, tbuf->char_buf_ptr, + tbuf->flag_buf_ptr, + tbuf->used); + spin_lock_irqsave(&tty->read_lock, flags); + tty_buffer_free(tty, tbuf); + } + tty->buf.tail = NULL; spin_unlock_irqrestore(&tty->read_lock, flags); - - disc->receive_buf(tty, cp, fp, count); out: tty_ldisc_deref(disc); } @@ -2654,11 +2855,12 @@ void tty_flip_buffer_push(struct tty_struct *tty) if (tty->low_latency) flush_to_ldisc((void *) tty); else - schedule_delayed_work(&tty->flip.work, 1); + schedule_delayed_work(&tty->buf.work, 1); } EXPORT_SYMBOL(tty_flip_buffer_push); + /* * This subroutine initializes a tty structure. */ @@ -2669,10 +2871,10 @@ static void initialize_tty_struct(struct tty_struct *tty) tty_ldisc_assign(tty, tty_ldisc_get(N_TTY)); tty->pgrp = -1; tty->overrun_time = jiffies; - tty->flip.char_buf_ptr = tty->flip.char_buf; - tty->flip.flag_buf_ptr = tty->flip.flag_buf; - INIT_WORK(&tty->flip.work, flush_to_ldisc, tty); - init_MUTEX(&tty->flip.pty_sem); + tty->buf.head = tty->buf.tail = NULL; + tty_buffer_init(tty); + INIT_WORK(&tty->buf.work, flush_to_ldisc, tty); + init_MUTEX(&tty->buf.pty_sem); init_MUTEX(&tty->termios_sem); init_waitqueue_head(&tty->write_wait); init_waitqueue_head(&tty->read_wait); diff --git a/trunk/drivers/char/viocons.c b/trunk/drivers/char/viocons.c index 4d75c261f98a..cb82ebf4cb07 100644 --- a/trunk/drivers/char/viocons.c +++ b/trunk/drivers/char/viocons.c @@ -993,11 +993,10 @@ static void vioHandleData(struct HvLpEvent *event) * Don't attempt to copy more data into the buffer than we * have room for because it would fail without indication. */ - if ((tty->flip.count + 1) > TTY_FLIPBUF_SIZE) { + if(tty_insert_flip_char(tty, cevent->data[index], TTY_NORMAL) == 0) { printk(VIOCONS_KERN_WARN "input buffer overflow!\n"); break; } - tty_insert_flip_char(tty, cevent->data[index], TTY_NORMAL); } /* if cevent->len == 0 then no data was added to the buffer and flip.count == 0 */ diff --git a/trunk/drivers/char/vme_scc.c b/trunk/drivers/char/vme_scc.c index 19ba83635dd7..d9325281e482 100644 --- a/trunk/drivers/char/vme_scc.c +++ b/trunk/drivers/char/vme_scc.c @@ -434,13 +434,7 @@ static irqreturn_t scc_rx_int(int irq, void *data, struct pt_regs *fp) SCCwrite_NB(COMMAND_REG, CR_HIGHEST_IUS_RESET); return IRQ_HANDLED; } - if (tty->flip.count < TTY_FLIPBUF_SIZE) { - *tty->flip.char_buf_ptr = ch; - *tty->flip.flag_buf_ptr = 0; - tty->flip.flag_buf_ptr++; - tty->flip.char_buf_ptr++; - tty->flip.count++; - } + tty_insert_flip_char(tty, ch, 0); /* Check if another character is already ready; in that case, the * spcond_int() function must be used, because this character may have an @@ -487,13 +481,7 @@ static irqreturn_t scc_spcond_int(int irq, void *data, struct pt_regs *fp) else err = 0; - if (tty->flip.count < TTY_FLIPBUF_SIZE) { - *tty->flip.char_buf_ptr = ch; - *tty->flip.flag_buf_ptr = err; - tty->flip.flag_buf_ptr++; - tty->flip.char_buf_ptr++; - tty->flip.count++; - } + tty_insert_flip_char(tty, ch, err); /* ++TeSche: *All* errors have to be cleared manually, * else the condition persists for the next chars @@ -875,13 +863,13 @@ static int scc_open (struct tty_struct * tty, struct file * filp) local_irq_save(flags); #if defined(CONFIG_MVME147_SCC) || defined(CONFIG_MVME162_SCC) if (MACH_IS_MVME147 || MACH_IS_MVME16x) { - for (i=0; ivc_sw->con_blank(c, VESA_VSYNC_SUSPEND+1, 0); - break; - case VESA_VSYNC_SUSPEND: - case VESA_HSYNC_SUSPEND: - c->vc_sw->con_blank(c, VESA_POWERDOWN+1, 0); - break; - } -} - void do_blank_screen(int entering_gfx) { struct vc_data *vc = vc_cons[fg_console].d; @@ -2791,8 +2768,7 @@ void do_blank_screen(int entering_gfx) if (console_blanked) { if (blank_state == blank_vesa_wait) { blank_state = blank_off; - vesa_powerdown(); - + vc->vc_sw->con_blank(vc, vesa_blank_mode + 1, 0); } return; } @@ -2822,7 +2798,7 @@ void do_blank_screen(int entering_gfx) save_screen(vc); /* In case we need to reset origin, blanking hook returns 1 */ - i = vc->vc_sw->con_blank(vc, 1, 0); + i = vc->vc_sw->con_blank(vc, vesa_off_interval ? 1 : (vesa_blank_mode + 1), 0); console_blanked = fg_console + 1; if (i) set_origin(vc); @@ -2830,13 +2806,10 @@ void do_blank_screen(int entering_gfx) if (console_blank_hook && console_blank_hook(1)) return; - if (vesa_off_interval) { + if (vesa_off_interval && vesa_blank_mode) { blank_state = blank_vesa_wait; mod_timer(&console_timer, jiffies + vesa_off_interval); } - - if (vesa_blank_mode) - vc->vc_sw->con_blank(vc, vesa_blank_mode + 1, 0); } EXPORT_SYMBOL(do_blank_screen); diff --git a/trunk/drivers/connector/cn_proc.c b/trunk/drivers/connector/cn_proc.c index 385e52930c02..4b4d7db1ff7b 100644 --- a/trunk/drivers/connector/cn_proc.c +++ b/trunk/drivers/connector/cn_proc.c @@ -24,6 +24,7 @@ #include #include +#include #include #include @@ -56,7 +57,7 @@ void proc_fork_connector(struct task_struct *task) msg = (struct cn_msg*)buffer; ev = (struct proc_event*)msg->data; get_seq(&msg->seq, &ev->cpu); - getnstimestamp(&ev->timestamp); + ktime_get_ts(&ev->timestamp); /* get high res monotonic timestamp */ ev->what = PROC_EVENT_FORK; ev->event_data.fork.parent_pid = task->real_parent->pid; ev->event_data.fork.parent_tgid = task->real_parent->tgid; @@ -82,7 +83,7 @@ void proc_exec_connector(struct task_struct *task) msg = (struct cn_msg*)buffer; ev = (struct proc_event*)msg->data; get_seq(&msg->seq, &ev->cpu); - getnstimestamp(&ev->timestamp); + ktime_get_ts(&ev->timestamp); ev->what = PROC_EVENT_EXEC; ev->event_data.exec.process_pid = task->pid; ev->event_data.exec.process_tgid = task->tgid; @@ -116,7 +117,7 @@ void proc_id_connector(struct task_struct *task, int which_id) } else return; get_seq(&msg->seq, &ev->cpu); - getnstimestamp(&ev->timestamp); + ktime_get_ts(&ev->timestamp); memcpy(&msg->id, &cn_proc_event_id, sizeof(msg->id)); msg->ack = 0; /* not used */ @@ -136,7 +137,7 @@ void proc_exit_connector(struct task_struct *task) msg = (struct cn_msg*)buffer; ev = (struct proc_event*)msg->data; get_seq(&msg->seq, &ev->cpu); - getnstimestamp(&ev->timestamp); + ktime_get_ts(&ev->timestamp); ev->what = PROC_EVENT_EXIT; ev->event_data.exit.process_pid = task->pid; ev->event_data.exit.process_tgid = task->tgid; @@ -169,7 +170,7 @@ static void cn_proc_ack(int err, int rcvd_seq, int rcvd_ack) msg = (struct cn_msg*)buffer; ev = (struct proc_event*)msg->data; msg->seq = rcvd_seq; - getnstimestamp(&ev->timestamp); + ktime_get_ts(&ev->timestamp); ev->cpu = -1; ev->what = PROC_EVENT_NONE; ev->event_data.ack.err = err; diff --git a/trunk/drivers/ide/ide-cd.c b/trunk/drivers/ide/ide-cd.c index e4d55ad32d2f..9b2ebd219ad0 100644 --- a/trunk/drivers/ide/ide-cd.c +++ b/trunk/drivers/ide/ide-cd.c @@ -2895,6 +2895,8 @@ static int ide_cdrom_register (ide_drive_t *drive, int nslots) devinfo->mask |= CDC_CLOSE_TRAY; if (!CDROM_CONFIG_FLAGS(drive)->mo_drive) devinfo->mask |= CDC_MO_DRIVE; + if (!CDROM_CONFIG_FLAGS(drive)->ram) + devinfo->mask |= CDC_RAM; devinfo->disk = info->disk; return register_cdrom(devinfo); diff --git a/trunk/drivers/ide/ide-io.c b/trunk/drivers/ide/ide-io.c index dea2d4dcc698..bcbaeb50bb93 100644 --- a/trunk/drivers/ide/ide-io.c +++ b/trunk/drivers/ide/ide-io.c @@ -60,10 +60,10 @@ void ide_softirq_done(struct request *rq) request_queue_t *q = rq->q; add_disk_randomness(rq->rq_disk); - end_that_request_chunk(rq, rq->errors, rq->data_len); + end_that_request_chunk(rq, 1, rq->data_len); spin_lock_irq(q->queue_lock); - end_that_request_last(rq, rq->errors); + end_that_request_last(rq, 1); spin_unlock_irq(q->queue_lock); } @@ -96,11 +96,12 @@ int __ide_end_request(ide_drive_t *drive, struct request *rq, int uptodate, /* * For partial completions (or non fs/pc requests), use the regular - * direct completion path. + * direct completion path. Same thing for requests that failed, to + * preserve the ->errors value we use the normal completion path + * for those */ nbytes = nr_sectors << 9; - if (rq_all_done(rq, nbytes)) { - rq->errors = uptodate; + if (!rq->errors && rq_all_done(rq, nbytes)) { rq->data_len = nbytes; blkdev_dequeue_request(rq); HWGROUP(drive)->rq = NULL; diff --git a/trunk/drivers/ide/pci/pdc202xx_new.c b/trunk/drivers/ide/pci/pdc202xx_new.c index 211641a54398..fe06ebb0e5bf 100644 --- a/trunk/drivers/ide/pci/pdc202xx_new.c +++ b/trunk/drivers/ide/pci/pdc202xx_new.c @@ -39,7 +39,7 @@ #define PDC202_DEBUG_CABLE 0 -const static char *pdc_quirk_drives[] = { +static const char *pdc_quirk_drives[] = { "QUANTUM FIREBALLlct08 08", "QUANTUM FIREBALLP KA6.4", "QUANTUM FIREBALLP KA9.1", diff --git a/trunk/drivers/ide/pci/via82cxxx.c b/trunk/drivers/ide/pci/via82cxxx.c index 86fb1e0286d3..c85b87cb59d1 100644 --- a/trunk/drivers/ide/pci/via82cxxx.c +++ b/trunk/drivers/ide/pci/via82cxxx.c @@ -439,7 +439,7 @@ static void __devinit init_hwif_via82cxxx(ide_hwif_t *hwif) hwif->speedproc = &via_set_drive; -#if defined(CONFIG_PPC_MULTIPLATFORM) && defined(CONFIG_PPC32) +#if defined(CONFIG_PPC_CHRP) && defined(CONFIG_PPC32) if(_machine == _MACH_chrp && _chrp_type == _CHRP_Pegasos) { hwif->irq = hwif->channel ? 15 : 14; } diff --git a/trunk/drivers/ieee1394/amdtp.c b/trunk/drivers/ieee1394/amdtp.c index 75897509c401..17390d762cf7 100644 --- a/trunk/drivers/ieee1394/amdtp.c +++ b/trunk/drivers/ieee1394/amdtp.c @@ -80,7 +80,6 @@ #include #include #include -#include #include #include #include diff --git a/trunk/drivers/ieee1394/dv1394.c b/trunk/drivers/ieee1394/dv1394.c index 196db7439272..efeaa944bd0a 100644 --- a/trunk/drivers/ieee1394/dv1394.c +++ b/trunk/drivers/ieee1394/dv1394.c @@ -108,7 +108,6 @@ #include #include #include -#include #include #include diff --git a/trunk/drivers/ieee1394/video1394.c b/trunk/drivers/ieee1394/video1394.c index 608479b2df14..39fb88309e8e 100644 --- a/trunk/drivers/ieee1394/video1394.c +++ b/trunk/drivers/ieee1394/video1394.c @@ -48,7 +48,6 @@ #include #include #include -#include #include #include diff --git a/trunk/drivers/input/input.c b/trunk/drivers/input/input.c index ef5824c8846b..fe33ff334e27 100644 --- a/trunk/drivers/input/input.c +++ b/trunk/drivers/input/input.c @@ -477,8 +477,8 @@ static int __init input_proc_init(void) entry->owner = THIS_MODULE; input_fileops = *entry->proc_fops; + input_fileops.poll = input_devices_poll; entry->proc_fops = &input_fileops; - entry->proc_fops->poll = input_devices_poll; entry = create_proc_read_entry("handlers", 0, proc_bus_input_dir, input_handlers_read, NULL); if (!entry) diff --git a/trunk/drivers/input/joystick/grip_mp.c b/trunk/drivers/input/joystick/grip_mp.c index 51a912222e85..62438944a69a 100644 --- a/trunk/drivers/input/joystick/grip_mp.c +++ b/trunk/drivers/input/joystick/grip_mp.c @@ -53,17 +53,8 @@ struct grip_port { struct grip_mp { struct gameport *gameport; struct grip_port *port[GRIP_MAX_PORTS]; -// struct input_dev *dev[4]; -// int mode[4]; -// int registered[4]; int reads; int bads; - - /* individual gamepad states */ -// int buttons[4]; -// int xaxes[4]; -// int yaxes[4]; -// int dirty[4]; /* has the state been updated? */ }; /* diff --git a/trunk/drivers/input/keyboard/Kconfig b/trunk/drivers/input/keyboard/Kconfig index 4a917748fd9f..3b0ac3b43c54 100644 --- a/trunk/drivers/input/keyboard/Kconfig +++ b/trunk/drivers/input/keyboard/Kconfig @@ -143,16 +143,6 @@ config KEYBOARD_SPITZ To compile this driver as a module, choose M here: the module will be called spitzkbd. -config KEYBOARD_MAPLE - tristate "Maple bus keyboard" - depends on SH_DREAMCAST && MAPLE - help - Say Y here if you have a DreamCast console running Linux and have - a keyboard attached to its Maple bus. - - To compile this driver as a module, choose M here: the - module will be called maple_keyb. - config KEYBOARD_AMIGA tristate "Amiga keyboard" depends on AMIGA diff --git a/trunk/drivers/input/keyboard/Makefile b/trunk/drivers/input/keyboard/Makefile index 9ce0b87f2fac..6e0afbb22383 100644 --- a/trunk/drivers/input/keyboard/Makefile +++ b/trunk/drivers/input/keyboard/Makefile @@ -5,7 +5,6 @@ # Each configuration option enables a list of files. obj-$(CONFIG_KEYBOARD_ATKBD) += atkbd.o -obj-$(CONFIG_KEYBOARD_MAPLE) += maple_keyb.o obj-$(CONFIG_KEYBOARD_SUNKBD) += sunkbd.o obj-$(CONFIG_KEYBOARD_LKKBD) += lkkbd.o obj-$(CONFIG_KEYBOARD_XTKBD) += xtkbd.o diff --git a/trunk/drivers/input/misc/wistron_btns.c b/trunk/drivers/input/misc/wistron_btns.c index a05b8557842f..4b415d9b0123 100644 --- a/trunk/drivers/input/misc/wistron_btns.c +++ b/trunk/drivers/input/misc/wistron_btns.c @@ -92,11 +92,11 @@ static void call_bios(struct regs *regs) preempt_enable(); } -static size_t __init locate_wistron_bios(void __iomem *base) +static ssize_t __init locate_wistron_bios(void __iomem *base) { static const unsigned char __initdata signature[] = { 0x42, 0x21, 0x55, 0x30 }; - size_t offset; + ssize_t offset; for (offset = 0; offset < 0x10000; offset += 0x10) { if (check_signature(base + offset, signature, @@ -109,7 +109,7 @@ static size_t __init locate_wistron_bios(void __iomem *base) static int __init map_bios(void) { void __iomem *base; - size_t offset; + ssize_t offset; u32 entry_point; base = ioremap(0xF0000, 0x10000); /* Can't fail */ diff --git a/trunk/drivers/input/mouse/Kconfig b/trunk/drivers/input/mouse/Kconfig index 574b18a523af..f15ccf781688 100644 --- a/trunk/drivers/input/mouse/Kconfig +++ b/trunk/drivers/input/mouse/Kconfig @@ -86,16 +86,6 @@ config MOUSE_PC110PAD To compile this driver as a module, choose M here: the module will be called pc110pad. -config MOUSE_MAPLE - tristate "Maple bus mouse" - depends on SH_DREAMCAST && MAPLE - help - Say Y if you have a DreamCast console and a mouse attached to - its Maple bus. - - To compile this driver as a module, choose M here: the - module will be called maplemouse. - config MOUSE_AMIGA tristate "Amiga mouse" depends on AMIGA diff --git a/trunk/drivers/input/mouse/Makefile b/trunk/drivers/input/mouse/Makefile index 82b330bbf068..21a1de61a79b 100644 --- a/trunk/drivers/input/mouse/Makefile +++ b/trunk/drivers/input/mouse/Makefile @@ -8,7 +8,6 @@ obj-$(CONFIG_MOUSE_AMIGA) += amimouse.o obj-$(CONFIG_MOUSE_RISCPC) += rpcmouse.o obj-$(CONFIG_MOUSE_INPORT) += inport.o obj-$(CONFIG_MOUSE_LOGIBM) += logibm.o -obj-$(CONFIG_MOUSE_MAPLE) += maplemouse.o obj-$(CONFIG_MOUSE_PC110PAD) += pc110pad.o obj-$(CONFIG_MOUSE_PS2) += psmouse.o obj-$(CONFIG_MOUSE_SERIAL) += sermouse.o diff --git a/trunk/drivers/input/mouse/maplemouse.c b/trunk/drivers/input/mouse/maplemouse.c deleted file mode 100644 index b5b34fe4fee8..000000000000 --- a/trunk/drivers/input/mouse/maplemouse.c +++ /dev/null @@ -1,101 +0,0 @@ -/* - * $Id: maplemouse.c,v 1.2 2004/03/22 01:18:15 lethal Exp $ - * SEGA Dreamcast mouse driver - * Based on drivers/usb/usbmouse.c - */ - -#include -#include -#include -#include -#include -#include -#include - -MODULE_AUTHOR("YAEGASHI Takeshi "); -MODULE_DESCRIPTION("SEGA Dreamcast mouse driver"); - -static void dc_mouse_callback(struct mapleq *mq) -{ - int buttons, relx, rely, relz; - struct maple_device *mapledev = mq->dev; - struct input_dev *dev = mapledev->private_data; - unsigned char *res = mq->recvbuf; - - buttons = ~res[8]; - relx = *(unsigned short *)(res + 12) - 512; - rely = *(unsigned short *)(res + 14) - 512; - relz = *(unsigned short *)(res + 16) - 512; - - input_report_key(dev, BTN_LEFT, buttons & 4); - input_report_key(dev, BTN_MIDDLE, buttons & 9); - input_report_key(dev, BTN_RIGHT, buttons & 2); - input_report_rel(dev, REL_X, relx); - input_report_rel(dev, REL_Y, rely); - input_report_rel(dev, REL_WHEEL, relz); - input_sync(dev); -} - -static int dc_mouse_connect(struct maple_device *dev) -{ - unsigned long data = be32_to_cpu(dev->devinfo.function_data[0]); - struct input_dev *input_dev; - - dev->private_data = input_dev = input_allocate_device(); - if (!input_dev) - return -ENOMEM; - - dev->private_data = input_dev; - - input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REL); - input_dev->keybit[LONG(BTN_MOUSE)] = BIT(BTN_LEFT) | BIT(BTN_RIGHT) | BIT(BTN_MIDDLE); - input_dev->relbit[0] = BIT(REL_X) | BIT(REL_Y) | BIT(REL_WHEEL); - - input_dev->name = dev->product_name; - input_dev->id.bustype = BUS_MAPLE; - - input_register_device(input_dev); - - maple_getcond_callback(dev, dc_mouse_callback, 1, MAPLE_FUNC_MOUSE); - - return 0; -} - - -static void dc_mouse_disconnect(struct maple_device *dev) -{ - struct input_dev *input_dev = dev->private_data; - - input_unregister_device(input_dev); -} - - -static struct maple_driver dc_mouse_driver = { - .function = MAPLE_FUNC_MOUSE, - .name = "Dreamcast mouse", - .connect = dc_mouse_connect, - .disconnect = dc_mouse_disconnect, -}; - - -static int __init dc_mouse_init(void) -{ - maple_register_driver(&dc_mouse_driver); - return 0; -} - - -static void __exit dc_mouse_exit(void) -{ - maple_unregister_driver(&dc_mouse_driver); -} - - -module_init(dc_mouse_init); -module_exit(dc_mouse_exit); - -/* - * Local variables: - * c-basic-offset: 8 - * End: - */ diff --git a/trunk/drivers/input/serio/serport.c b/trunk/drivers/input/serio/serport.c index 1bd88fca0542..54a680cc704d 100644 --- a/trunk/drivers/input/serio/serport.c +++ b/trunk/drivers/input/serio/serport.c @@ -96,6 +96,7 @@ static int serport_ldisc_open(struct tty_struct *tty) init_waitqueue_head(&serport->wait); tty->disc_data = serport; + tty->receive_room = 256; set_bit(TTY_DO_WRITE_WAKEUP, &tty->flags); return 0; @@ -139,17 +140,6 @@ static void serport_ldisc_receive(struct tty_struct *tty, const unsigned char *c spin_unlock_irqrestore(&serport->lock, flags); } -/* - * serport_ldisc_room() reports how much room we do have for receiving data. - * Although we in fact have infinite room, we need to specify some value - * here, and 256 seems to be reasonable. - */ - -static int serport_ldisc_room(struct tty_struct *tty) -{ - return 256; -} - /* * serport_ldisc_read() just waits indefinitely if everything goes well. * However, when the serio driver closes the serio port, it finishes, @@ -237,7 +227,6 @@ static struct tty_ldisc serport_ldisc = { .read = serport_ldisc_read, .ioctl = serport_ldisc_ioctl, .receive_buf = serport_ldisc_receive, - .receive_room = serport_ldisc_room, .write_wakeup = serport_ldisc_write_wakeup }; diff --git a/trunk/drivers/isdn/capi/capi.c b/trunk/drivers/isdn/capi/capi.c index 11ae0fddea04..623adbb0d13a 100644 --- a/trunk/drivers/isdn/capi/capi.c +++ b/trunk/drivers/isdn/capi/capi.c @@ -463,8 +463,7 @@ static int handle_recv_skb(struct capiminor *mp, struct sk_buff *skb) #endif goto bad; } - if (ld->receive_room && - ld->receive_room(mp->tty) < datalen) { + if (mp->tty->receive_room < datalen) { #if defined(_DEBUG_DATAFLOW) || defined(_DEBUG_TTYFUNCS) printk(KERN_DEBUG "capi: no room in tty\n"); #endif diff --git a/trunk/drivers/isdn/i4l/isdn_common.c b/trunk/drivers/isdn/i4l/isdn_common.c index 4643df097bfe..22759c01746a 100644 --- a/trunk/drivers/isdn/i4l/isdn_common.c +++ b/trunk/drivers/isdn/i4l/isdn_common.c @@ -857,6 +857,118 @@ isdn_readbchan(int di, int channel, u_char * buf, u_char * fp, int len, wait_que return count; } +/* + * isdn_readbchan_tty() tries to get data from the read-queue. + * It MUST be called with interrupts off. + * + * Be aware that this is not an atomic operation when sleep != 0, even though + * interrupts are turned off! Well, like that we are currently only called + * on behalf of a read system call on raw device files (which are documented + * to be dangerous and for for debugging purpose only). The inode semaphore + * takes care that this is not called for the same minor device number while + * we are sleeping, but access is not serialized against simultaneous read() + * from the corresponding ttyI device. Can other ugly events, like changes + * of the mapping (di,ch)<->minor, happen during the sleep? --he + */ +int +isdn_readbchan_tty(int di, int channel, struct tty_struct *tty, int cisco_hack) +{ + int count; + int count_pull; + int count_put; + int dflag; + struct sk_buff *skb; + char last = 0; + int len; + + if (!dev->drv[di]) + return 0; + if (skb_queue_empty(&dev->drv[di]->rpqueue[channel])) + return 0; + + len = tty_buffer_request_room(tty, dev->drv[di]->rcvcount[channel]); + if(len == 0) + return len; + + count = 0; + while (len) { + if (!(skb = skb_peek(&dev->drv[di]->rpqueue[channel]))) + break; +#ifdef CONFIG_ISDN_AUDIO + if (ISDN_AUDIO_SKB_LOCK(skb)) + break; + ISDN_AUDIO_SKB_LOCK(skb) = 1; + if ((ISDN_AUDIO_SKB_DLECOUNT(skb)) || (dev->drv[di]->DLEflag & (1 << channel))) { + char *p = skb->data; + unsigned long DLEmask = (1 << channel); + + dflag = 0; + count_pull = count_put = 0; + while ((count_pull < skb->len) && (len > 0)) { + len--; + if (dev->drv[di]->DLEflag & DLEmask) { + last = DLE; + dev->drv[di]->DLEflag &= ~DLEmask; + } else { + last = *p; + if (last == DLE) { + dev->drv[di]->DLEflag |= DLEmask; + (ISDN_AUDIO_SKB_DLECOUNT(skb))--; + } + p++; + count_pull++; + } + count_put++; + } + if (count_pull >= skb->len) + dflag = 1; + } else { +#endif + /* No DLE's in buff, so simply copy it */ + dflag = 1; + if ((count_pull = skb->len) > len) { + count_pull = len; + dflag = 0; + } + count_put = count_pull; + if(count_put > 1) + tty_insert_flip_string(tty, skb->data, count_put - 1); + last = skb->data[count_put] - 1; + len -= count_put; +#ifdef CONFIG_ISDN_AUDIO + } +#endif + count += count_put; + if (dflag) { + /* We got all the data in this buff. + * Now we can dequeue it. + */ + if(cisco_hack) + tty_insert_flip_char(tty, last, 0xFF); + else + tty_insert_flip_char(tty, last, TTY_NORMAL); +#ifdef CONFIG_ISDN_AUDIO + ISDN_AUDIO_SKB_LOCK(skb) = 0; +#endif + skb = skb_dequeue(&dev->drv[di]->rpqueue[channel]); + dev_kfree_skb(skb); + } else { + tty_insert_flip_char(tty, last, TTY_NORMAL); + /* Not yet emptied this buff, so it + * must stay in the queue, for further calls + * but we pull off the data we got until now. + */ + skb_pull(skb, count_pull); +#ifdef CONFIG_ISDN_AUDIO + ISDN_AUDIO_SKB_LOCK(skb) = 0; +#endif + } + dev->drv[di]->rcvcount[channel] -= count_put; + } + return count; +} + + static __inline int isdn_minor2drv(int minor) { diff --git a/trunk/drivers/isdn/i4l/isdn_common.h b/trunk/drivers/isdn/i4l/isdn_common.h index e27e9c3a81ed..082735dbb412 100644 --- a/trunk/drivers/isdn/i4l/isdn_common.h +++ b/trunk/drivers/isdn/i4l/isdn_common.h @@ -37,6 +37,7 @@ extern void isdn_timer_ctrl(int tf, int onoff); extern void isdn_unexclusive_channel(int di, int ch); extern int isdn_getnum(char **); extern int isdn_readbchan(int, int, u_char *, u_char *, int, wait_queue_head_t *); +extern int isdn_readbchan_tty(int, int, struct tty_struct *, int); extern int isdn_get_free_channel(int, int, int, int, int, char *); extern int isdn_writebuf_skb_stub(int, int, int, struct sk_buff *); extern int register_isdn(isdn_if * i); diff --git a/trunk/drivers/isdn/i4l/isdn_tty.c b/trunk/drivers/isdn/i4l/isdn_tty.c index 8c404b4e2482..f190a99604f0 100644 --- a/trunk/drivers/isdn/i4l/isdn_tty.c +++ b/trunk/drivers/isdn/i4l/isdn_tty.c @@ -64,37 +64,42 @@ isdn_tty_try_read(modem_info * info, struct sk_buff *skb) int c; int len; struct tty_struct *tty; + char last; if (info->online) { if ((tty = info->tty)) { if (info->mcr & UART_MCR_RTS) { - c = TTY_FLIPBUF_SIZE - tty->flip.count; len = skb->len #ifdef CONFIG_ISDN_AUDIO + ISDN_AUDIO_SKB_DLECOUNT(skb) #endif ; + + c = tty_buffer_request_room(tty, len); if (c >= len) { #ifdef CONFIG_ISDN_AUDIO - if (ISDN_AUDIO_SKB_DLECOUNT(skb)) - while (skb->len--) { + if (ISDN_AUDIO_SKB_DLECOUNT(skb)) { + int l = skb->len; + unsigned char *dp = skb->data; + while (--l) { if (*skb->data == DLE) tty_insert_flip_char(tty, DLE, 0); - tty_insert_flip_char(tty, *skb->data++, 0); + tty_insert_flip_char(tty, *dp++, 0); + } + last = *dp; } else { #endif - memcpy(tty->flip.char_buf_ptr, - skb->data, len); - tty->flip.count += len; - tty->flip.char_buf_ptr += len; - memset(tty->flip.flag_buf_ptr, 0, len); - tty->flip.flag_buf_ptr += len; + if(len > 1) + tty_insert_flip_string(tty, skb->data, len - 1); + last = skb->data[len - 1]; #ifdef CONFIG_ISDN_AUDIO } #endif if (info->emu.mdmreg[REG_CPPP] & BIT_CPPP) - tty->flip.flag_buf_ptr[len - 1] = 0xff; - schedule_delayed_work(&tty->flip.work, 1); + tty_insert_flip_char(tty, last, 0xFF); + else + tty_insert_flip_char(tty, last, TTY_NORMAL); + tty_flip_buffer_push(tty); kfree_skb(skb); return 1; } @@ -114,7 +119,6 @@ isdn_tty_readmodem(void) int resched = 0; int midx; int i; - int c; int r; struct tty_struct *tty; modem_info *info; @@ -131,20 +135,13 @@ isdn_tty_readmodem(void) #endif if ((tty = info->tty)) { if (info->mcr & UART_MCR_RTS) { - c = TTY_FLIPBUF_SIZE - tty->flip.count; - if (c > 0) { - r = isdn_readbchan(info->isdn_driver, info->isdn_channel, - tty->flip.char_buf_ptr, - tty->flip.flag_buf_ptr, c, NULL); - /* CISCO AsyncPPP Hack */ - if (!(info->emu.mdmreg[REG_CPPP] & BIT_CPPP)) - memset(tty->flip.flag_buf_ptr, 0, r); - tty->flip.count += r; - tty->flip.flag_buf_ptr += r; - tty->flip.char_buf_ptr += r; - if (r) - schedule_delayed_work(&tty->flip.work, 1); - } + /* CISCO AsyncPPP Hack */ + if (!(info->emu.mdmreg[REG_CPPP] & BIT_CPPP)) + r = isdn_readbchan_tty(info->isdn_driver, info->isdn_channel, tty, 0); + else + r = isdn_readbchan_tty(info->isdn_driver, info->isdn_channel, tty, 1); + if (r) + tty_flip_buffer_push(tty); } else r = 1; } else @@ -249,7 +246,7 @@ isdn_tty_rcv_skb(int i, int di, int channel, struct sk_buff *skb) } #endif #endif - /* Try to deliver directly via tty-flip-buf if queue is empty */ + /* Try to deliver directly via tty-buf if queue is empty */ spin_lock_irqsave(&info->readlock, flags); if (skb_queue_empty(&dev->drv[di]->rpqueue[channel])) if (isdn_tty_try_read(info, skb)) { @@ -534,7 +531,7 @@ isdn_tty_senddown(modem_info * info) /* The next routine is called once from within timer-interrupt * triggered within isdn_tty_modem_ncarrier(). It calls * isdn_tty_modem_result() to stuff a "NO CARRIER" Message - * into the tty's flip-buffer. + * into the tty's buffer. */ static void isdn_tty_modem_do_ncarrier(unsigned long data) @@ -2347,6 +2344,7 @@ isdn_tty_at_cout(char *msg, modem_info * info) u_long flags; struct sk_buff *skb = NULL; char *sp = NULL; + int l = strlen(msg); if (!msg) { printk(KERN_WARNING "isdn_tty: Null-Message in isdn_tty_at_cout\n"); @@ -2359,16 +2357,16 @@ isdn_tty_at_cout(char *msg, modem_info * info) return; } - /* use queue instead of direct flip, if online and */ - /* data is in queue or flip buffer is full */ - if ((info->online) && (((tty->flip.count + strlen(msg)) >= TTY_FLIPBUF_SIZE) || - (!skb_queue_empty(&dev->drv[info->isdn_driver]->rpqueue[info->isdn_channel])))) { - skb = alloc_skb(strlen(msg), GFP_ATOMIC); + /* use queue instead of direct, if online and */ + /* data is in queue or buffer is full */ + if ((info->online && tty_buffer_request_room(tty, l) < l) || + (!skb_queue_empty(&dev->drv[info->isdn_driver]->rpqueue[info->isdn_channel]))) { + skb = alloc_skb(l, GFP_ATOMIC); if (!skb) { spin_unlock_irqrestore(&info->readlock, flags); return; } - sp = skb_put(skb, strlen(msg)); + sp = skb_put(skb, l); #ifdef CONFIG_ISDN_AUDIO ISDN_AUDIO_SKB_DLECOUNT(skb) = 0; ISDN_AUDIO_SKB_LOCK(skb) = 0; @@ -2392,9 +2390,8 @@ isdn_tty_at_cout(char *msg, modem_info * info) if (skb) { *sp++ = c; } else { - if (tty->flip.count >= TTY_FLIPBUF_SIZE) + if(tty_insert_flip_char(tty, c, TTY_NORMAL) == 0) break; - tty_insert_flip_char(tty, c, 0); } } if (skb) { @@ -2402,12 +2399,12 @@ isdn_tty_at_cout(char *msg, modem_info * info) dev->drv[info->isdn_driver]->rcvcount[info->isdn_channel] += skb->len; spin_unlock_irqrestore(&info->readlock, flags); /* Schedule dequeuing */ - if ((dev->modempoll) && (info->rcvsched)) + if (dev->modempoll && info->rcvsched) isdn_timer_ctrl(ISDN_TIMER_MODEMREAD, 1); } else { spin_unlock_irqrestore(&info->readlock, flags); - schedule_delayed_work(&tty->flip.work, 1); + tty_flip_buffer_push(tty); } } diff --git a/trunk/drivers/md/dm.c b/trunk/drivers/md/dm.c index 5c210b0a4cb0..097d1e540090 100644 --- a/trunk/drivers/md/dm.c +++ b/trunk/drivers/md/dm.c @@ -768,6 +768,7 @@ static struct mapped_device *alloc_dev(unsigned int minor, int persistent) md->queue->backing_dev_info.congested_fn = dm_any_congested; md->queue->backing_dev_info.congested_data = md; blk_queue_make_request(md->queue, dm_request); + blk_queue_bounce_limit(md->queue, BLK_BOUNCE_ANY); md->queue->unplug_fn = dm_unplug_all; md->queue->issue_flush_fn = dm_flush_all; diff --git a/trunk/drivers/md/multipath.c b/trunk/drivers/md/multipath.c index e6aa309a66d7..96f7af4ae400 100644 --- a/trunk/drivers/md/multipath.c +++ b/trunk/drivers/md/multipath.c @@ -303,6 +303,7 @@ static void print_multipath_conf (multipath_conf_t *conf) static int multipath_add_disk(mddev_t *mddev, mdk_rdev_t *rdev) { multipath_conf_t *conf = mddev->private; + struct request_queue *q; int found = 0; int path; struct multipath_info *p; @@ -311,8 +312,8 @@ static int multipath_add_disk(mddev_t *mddev, mdk_rdev_t *rdev) for (path=0; pathraid_disks; path++) if ((p=conf->multipaths+path)->rdev == NULL) { - blk_queue_stack_limits(mddev->queue, - rdev->bdev->bd_disk->queue); + q = rdev->bdev->bd_disk->queue; + blk_queue_stack_limits(mddev->queue, q); /* as we don't honour merge_bvec_fn, we must never risk * violating it, so limit ->max_sector to one PAGE, as @@ -320,7 +321,7 @@ static int multipath_add_disk(mddev_t *mddev, mdk_rdev_t *rdev) * (Note: it is very unlikely that a device with * merge_bvec_fn will be involved in multipath.) */ - if (rdev->bdev->bd_disk->queue->merge_bvec_fn && + if (q->merge_bvec_fn && mddev->queue->max_sectors > (PAGE_SIZE>>9)) blk_queue_max_sectors(mddev->queue, PAGE_SIZE>>9); diff --git a/trunk/drivers/media/radio/radio-maestro.c b/trunk/drivers/media/radio/radio-maestro.c index c30effdf711f..36c9f5bf8cdd 100644 --- a/trunk/drivers/media/radio/radio-maestro.c +++ b/trunk/drivers/media/radio/radio-maestro.c @@ -27,34 +27,30 @@ #include #include -#define DRIVER_VERSION "0.04" +#define DRIVER_VERSION "0.05" -#define PCI_VENDOR_ESS 0x125D -#define PCI_DEVICE_ID_ESS_ESS1968 0x1968 /* Maestro 2 */ -#define PCI_DEVICE_ID_ESS_ESS1978 0x1978 /* Maestro 2E */ - -#define GPIO_DATA 0x60 /* port offset from ESS_IO_BASE */ +#define GPIO_DATA 0x60 /* port offset from ESS_IO_BASE */ #define IO_MASK 4 /* mask register offset from GPIO_DATA bits 1=unmask write to given bit */ #define IO_DIR 8 /* direction register offset from GPIO_DATA bits 0/1=read/write direction */ -#define GPIO6 0x0040 /* mask bits for GPIO lines */ -#define GPIO7 0x0080 -#define GPIO8 0x0100 -#define GPIO9 0x0200 +#define GPIO6 0x0040 /* mask bits for GPIO lines */ +#define GPIO7 0x0080 +#define GPIO8 0x0100 +#define GPIO9 0x0200 -#define STR_DATA GPIO6 /* radio TEA5757 pins and GPIO bits */ -#define STR_CLK GPIO7 -#define STR_WREN GPIO8 -#define STR_MOST GPIO9 +#define STR_DATA GPIO6 /* radio TEA5757 pins and GPIO bits */ +#define STR_CLK GPIO7 +#define STR_WREN GPIO8 +#define STR_MOST GPIO9 #define FREQ_LO 50*16000 #define FREQ_HI 150*16000 -#define FREQ_IF 171200 /* 10.7*16000 */ -#define FREQ_STEP 200 /* 12.5*16 */ +#define FREQ_IF 171200 /* 10.7*16000 */ +#define FREQ_STEP 200 /* 12.5*16 */ #define FREQ2BITS(x) ((((unsigned int)(x)+FREQ_IF+(FREQ_STEP<<1))\ /(FREQ_STEP<<2))<<2) /* (x==fmhz*16*1000) -> bits */ @@ -65,7 +61,27 @@ static int radio_nr = -1; module_param(radio_nr, int, 0); static int radio_ioctl(struct inode *inode, struct file *file, - unsigned int cmd, unsigned long arg); + unsigned int cmd, unsigned long arg); +static int maestro_probe(struct pci_dev *pdev, const struct pci_device_id *ent); +static void maestro_remove(struct pci_dev *pdev); + +static struct pci_device_id maestro_r_pci_tbl[] = { + { PCI_DEVICE(PCI_VENDOR_ID_ESS, PCI_DEVICE_ID_ESS_ESS1968), + .class = PCI_CLASS_MULTIMEDIA_AUDIO << 8, + .class_mask = 0xffff00 }, + { PCI_DEVICE(PCI_VENDOR_ID_ESS, PCI_DEVICE_ID_ESS_ESS1978), + .class = PCI_CLASS_MULTIMEDIA_AUDIO << 8, + .class_mask = 0xffff00 }, + { 0 } +}; +MODULE_DEVICE_TABLE(pci, maestro_r_pci_tbl); + +static struct pci_driver maestro_r_driver = { + .name = "maestro_radio", + .id_table = maestro_r_pci_tbl, + .probe = maestro_probe, + .remove = __devexit_p(maestro_remove), +}; static struct file_operations maestro_fops = { .owner = THIS_MODULE, @@ -76,29 +92,27 @@ static struct file_operations maestro_fops = { .llseek = no_llseek, }; -static struct video_device maestro_radio= -{ - .owner = THIS_MODULE, +static struct video_device maestro_radio = { .name = "Maestro radio", .type = VID_TYPE_TUNER, .hardware = VID_HARDWARE_SF16MI, - .fops = &maestro_fops, + .fops = &maestro_fops, }; -static struct radio_device -{ - __u16 io, /* base of Maestro card radio io (GPIO_DATA)*/ +struct radio_device { + u16 io, /* base of Maestro card radio io (GPIO_DATA)*/ muted, /* VIDEO_AUDIO_MUTE */ stereo, /* VIDEO_TUNER_STEREO_ON */ tuned; /* signal strength (0 or 0xffff) */ - struct semaphore lock; -} radio_unit = {0, 0, 0, 0, }; + struct semaphore lock; +}; -static __u32 radio_bits_get(struct radio_device *dev) +static u32 radio_bits_get(struct radio_device *dev) { - register __u16 io=dev->io, l, rdata; - register __u32 data=0; - __u16 omask; + register u16 io=dev->io, l, rdata; + register u32 data=0; + u16 omask; + omask = inw(io + IO_MASK); outw(~(STR_CLK | STR_WREN), io + IO_MASK); outw(0, io); @@ -121,17 +135,21 @@ static __u32 radio_bits_get(struct radio_device *dev) data++; udelay(2); } + if(dev->muted) outw(STR_WREN, io); + udelay(4); outw(omask, io + IO_MASK); + return data & 0x3ffe; } -static void radio_bits_set(struct radio_device *dev, __u32 data) +static void radio_bits_set(struct radio_device *dev, u32 data) { - register __u16 io=dev->io, l, bits; - __u16 omask, odir; + register u16 io=dev->io, l, bits; + u16 omask, odir; + omask = inw(io + IO_MASK); odir = (inw(io + IO_DIR) & ~STR_DATA) | (STR_CLK | STR_WREN); outw(odir | STR_DATA, io + IO_DIR); @@ -147,8 +165,10 @@ static void radio_bits_set(struct radio_device *dev, __u32 data) outw(bits, io); /* LO level */ udelay(4); } + if(!dev->muted) outw(0, io); + udelay(4); outw(omask, io + IO_MASK); outw(odir, io + IO_DIR); @@ -156,141 +176,103 @@ static void radio_bits_set(struct radio_device *dev, __u32 data) } static inline int radio_function(struct inode *inode, struct file *file, - unsigned int cmd, void *arg) + unsigned int cmd, void *arg) { struct video_device *dev = video_devdata(file); - struct radio_device *card=dev->priv; - - switch(cmd) { - case VIDIOCGCAP: { - struct video_capability *v = arg; - memset(v,0,sizeof(*v)); - strcpy(v->name, "Maestro radio"); - v->type=VID_TYPE_TUNER; - v->channels=v->audios=1; - return 0; - } - case VIDIOCGTUNER: { - struct video_tuner *v = arg; - if(v->tuner) - return -EINVAL; - (void)radio_bits_get(card); - v->flags = VIDEO_TUNER_LOW | card->stereo; - v->signal = card->tuned; - strcpy(v->name, "FM"); - v->rangelow = FREQ_LO; - v->rangehigh = FREQ_HI; - v->mode = VIDEO_MODE_AUTO; - return 0; - } - case VIDIOCSTUNER: { - struct video_tuner *v = arg; - if(v->tuner!=0) - return -EINVAL; - return 0; - } - case VIDIOCGFREQ: { - unsigned long *freq = arg; - *freq = BITS2FREQ(radio_bits_get(card)); - return 0; - } - case VIDIOCSFREQ: { - unsigned long *freq = arg; - if (*freqFREQ_HI ) - return -EINVAL; - radio_bits_set(card, FREQ2BITS(*freq)); + struct radio_device *card = video_get_drvdata(dev); + + switch (cmd) { + case VIDIOCGCAP: { + struct video_capability *v = arg; + memset(v, 0, sizeof(*v)); + strcpy(v->name, "Maestro radio"); + v->type = VID_TYPE_TUNER; + v->channels = v->audios = 1; + return 0; + } case VIDIOCGTUNER: { + struct video_tuner *v = arg; + if (v->tuner) + return -EINVAL; + (void)radio_bits_get(card); + v->flags = VIDEO_TUNER_LOW | card->stereo; + v->signal = card->tuned; + strcpy(v->name, "FM"); + v->rangelow = FREQ_LO; + v->rangehigh = FREQ_HI; + v->mode = VIDEO_MODE_AUTO; + return 0; + } case VIDIOCSTUNER: { + struct video_tuner *v = arg; + if (v->tuner != 0) + return -EINVAL; + return 0; + } case VIDIOCGFREQ: { + unsigned long *freq = arg; + *freq = BITS2FREQ(radio_bits_get(card)); + return 0; + } case VIDIOCSFREQ: { + unsigned long *freq = arg; + if (*freq < FREQ_LO || *freq > FREQ_HI) + return -EINVAL; + radio_bits_set(card, FREQ2BITS(*freq)); + return 0; + } case VIDIOCGAUDIO: { + struct video_audio *v = arg; + memset(v, 0, sizeof(*v)); + strcpy(v->name, "Radio"); + v->flags = VIDEO_AUDIO_MUTABLE | card->muted; + v->mode = VIDEO_SOUND_STEREO; + return 0; + } case VIDIOCSAUDIO: { + struct video_audio *v = arg; + if (v->audio) + return -EINVAL; + { + register u16 io = card->io; + register u16 omask = inw(io + IO_MASK); + outw(~STR_WREN, io + IO_MASK); + outw((card->muted = v->flags & VIDEO_AUDIO_MUTE) ? + STR_WREN : 0, io); + udelay(4); + outw(omask, io + IO_MASK); + msleep(125); return 0; } - case VIDIOCGAUDIO: { - struct video_audio *v = arg; - memset(v,0,sizeof(*v)); - strcpy(v->name, "Radio"); - v->flags=VIDEO_AUDIO_MUTABLE | card->muted; - v->mode=VIDEO_SOUND_STEREO; - return 0; - } - case VIDIOCSAUDIO: { - struct video_audio *v = arg; - if(v->audio) - return -EINVAL; - { - register __u16 io=card->io; - register __u16 omask = inw(io + IO_MASK); - outw(~STR_WREN, io + IO_MASK); - outw((card->muted = v->flags & VIDEO_AUDIO_MUTE) - ? STR_WREN : 0, io); - udelay(4); - outw(omask, io + IO_MASK); - msleep(125); - return 0; - } - } - case VIDIOCGUNIT: { - struct video_unit *v = arg; - v->video=VIDEO_NO_UNIT; - v->vbi=VIDEO_NO_UNIT; - v->radio=dev->minor; - v->audio=0; - v->teletext=VIDEO_NO_UNIT; - return 0; - } - default: return -ENOIOCTLCMD; + } case VIDIOCGUNIT: { + struct video_unit *v = arg; + v->video = VIDEO_NO_UNIT; + v->vbi = VIDEO_NO_UNIT; + v->radio = dev->minor; + v->audio = 0; + v->teletext = VIDEO_NO_UNIT; + return 0; + } default: + return -ENOIOCTLCMD; } } static int radio_ioctl(struct inode *inode, struct file *file, - unsigned int cmd, unsigned long arg) + unsigned int cmd, unsigned long arg) { struct video_device *dev = video_devdata(file); - struct radio_device *card=dev->priv; + struct radio_device *card = video_get_drvdata(dev); int ret; down(&card->lock); ret = video_usercopy(inode, file, cmd, arg, radio_function); up(&card->lock); - return ret; -} -static __u16 radio_install(struct pci_dev *pcidev); - -MODULE_AUTHOR("Adam Tlalka, atlka@pg.gda.pl"); -MODULE_DESCRIPTION("Radio driver for the Maestro PCI sound card radio."); -MODULE_LICENSE("GPL"); - -static void __exit maestro_radio_exit(void) -{ - video_unregister_device(&maestro_radio); + return ret; } -static int __init maestro_radio_init(void) +static u16 __devinit radio_power_on(struct radio_device *dev) { - register __u16 found=0; - struct pci_dev *pcidev = NULL; - while(!found && (pcidev = pci_find_device(PCI_VENDOR_ESS, - PCI_DEVICE_ID_ESS_ESS1968, - pcidev))) - found |= radio_install(pcidev); - while(!found && (pcidev = pci_find_device(PCI_VENDOR_ESS, - PCI_DEVICE_ID_ESS_ESS1978, - pcidev))) - found |= radio_install(pcidev); - if(!found) { - printk(KERN_INFO "radio-maestro: no devices found.\n"); - return -ENODEV; - } - return 0; -} + register u16 io = dev->io; + register u32 ofreq; + u16 omask, odir; -module_init(maestro_radio_init); -module_exit(maestro_radio_exit); - -static inline __u16 radio_power_on(struct radio_device *dev) -{ - register __u16 io=dev->io; - register __u32 ofreq; - __u16 omask, odir; omask = inw(io + IO_MASK); - odir = (inw(io + IO_DIR) & ~STR_DATA) | (STR_CLK | STR_WREN); + odir = (inw(io + IO_DIR) & ~STR_DATA) | (STR_CLK | STR_WREN); outw(odir & ~STR_WREN, io + IO_DIR); dev->muted = inw(io) & STR_WREN ? 0 : VIDEO_AUDIO_MUTE; outw(odir, io + IO_DIR); @@ -299,35 +281,101 @@ static inline __u16 radio_power_on(struct radio_device *dev) udelay(16); outw(omask, io + IO_MASK); ofreq = radio_bits_get(dev); - if((ofreqFREQ2BITS(FREQ_HI))) + + if ((ofreq < FREQ2BITS(FREQ_LO)) || (ofreq > FREQ2BITS(FREQ_HI))) ofreq = FREQ2BITS(FREQ_LO); radio_bits_set(dev, ofreq); + return (ofreq == radio_bits_get(dev)); } -static __u16 radio_install(struct pci_dev *pcidev) +static int __devinit maestro_probe(struct pci_dev *pdev, + const struct pci_device_id *ent) { - if(((pcidev->class >> 8) & 0xffff) != PCI_CLASS_MULTIMEDIA_AUDIO) - return 0; - - radio_unit.io = pcidev->resource[0].start + GPIO_DATA; - maestro_radio.priv = &radio_unit; - init_MUTEX(&radio_unit.lock); - - if(radio_power_on(&radio_unit)) { - if(video_register_device(&maestro_radio, VFL_TYPE_RADIO, radio_nr)==-1) { - printk("radio-maestro: can't register device!"); - return 0; - } - printk(KERN_INFO "radio-maestro: version " - DRIVER_VERSION - " time " - __TIME__ " " - __DATE__ - "\n"); - printk(KERN_INFO "radio-maestro: radio chip initialized\n"); - return 1; - } else - return 0; + struct radio_device *radio_unit; + struct video_device *maestro_radio_inst; + int retval; + + retval = pci_enable_device(pdev); + if (retval) { + dev_err(&pdev->dev, "enabling pci device failed!\n"); + goto err; + } + + retval = -ENOMEM; + + radio_unit = kzalloc(sizeof(*radio_unit), GFP_KERNEL); + if (radio_unit == NULL) { + dev_err(&pdev->dev, "not enough memory\n"); + goto err; + } + + radio_unit->io = pci_resource_start(pdev, 0) + GPIO_DATA; + init_MUTEX(&radio_unit->lock); + + maestro_radio_inst = video_device_alloc(); + if (maestro_radio_inst == NULL) { + dev_err(&pdev->dev, "not enough memory\n"); + goto errfr; + } + + memcpy(maestro_radio_inst, &maestro_radio, sizeof(maestro_radio)); + video_set_drvdata(maestro_radio_inst, radio_unit); + pci_set_drvdata(pdev, maestro_radio_inst); + + retval = video_register_device(maestro_radio_inst, VFL_TYPE_RADIO, + radio_nr); + if (retval) { + printk(KERN_ERR "can't register video device!\n"); + goto errfr1; + } + + if (!radio_power_on(radio_unit)) { + retval = -EIO; + goto errunr; + } + + dev_info(&pdev->dev, "version " DRIVER_VERSION " time " __TIME__ " " + __DATE__ "\n"); + dev_info(&pdev->dev, "radio chip initialized\n"); + + return 0; +errunr: + video_unregister_device(maestro_radio_inst); +errfr1: + kfree(maestro_radio_inst); +errfr: + kfree(radio_unit); +err: + return retval; + +} + +static void __devexit maestro_remove(struct pci_dev *pdev) +{ + struct video_device *vdev = pci_get_drvdata(pdev); + + video_unregister_device(vdev); } +static int __init maestro_radio_init(void) +{ + int retval = pci_register_driver(&maestro_r_driver); + + if (retval) + printk(KERN_ERR "error during registration pci driver\n"); + + return retval; +} + +static void __exit maestro_radio_exit(void) +{ + pci_unregister_driver(&maestro_r_driver); +} + +module_init(maestro_radio_init); +module_exit(maestro_radio_exit); + +MODULE_AUTHOR("Adam Tlalka, atlka@pg.gda.pl"); +MODULE_DESCRIPTION("Radio driver for the Maestro PCI sound card radio."); +MODULE_LICENSE("GPL"); diff --git a/trunk/drivers/message/fusion/mptctl.c b/trunk/drivers/message/fusion/mptctl.c index 959d2c5951b8..7c340240a50e 100644 --- a/trunk/drivers/message/fusion/mptctl.c +++ b/trunk/drivers/message/fusion/mptctl.c @@ -2585,8 +2585,6 @@ static struct miscdevice mptctl_miscdev = { #ifdef CONFIG_COMPAT -#include - static int compat_mptfwxfer_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) diff --git a/trunk/drivers/misc/ibmasm/remote.c b/trunk/drivers/misc/ibmasm/remote.c index 1abd0c58ae27..0f9e3aa34d07 100644 --- a/trunk/drivers/misc/ibmasm/remote.c +++ b/trunk/drivers/misc/ibmasm/remote.c @@ -270,6 +270,7 @@ int ibmasm_init_remote_input_dev(struct service_processor *sp) err_unregister_mouse_dev: input_unregister_device(mouse_dev); + mouse_dev = NULL; /* so we don't try to free it again below */ err_free_devices: input_free_device(mouse_dev); input_free_device(keybd_dev); diff --git a/trunk/drivers/mtd/nand/au1550nd.c b/trunk/drivers/mtd/nand/au1550nd.c index 9c5945d6df88..201e1362da14 100644 --- a/trunk/drivers/mtd/nand/au1550nd.c +++ b/trunk/drivers/mtd/nand/au1550nd.c @@ -43,7 +43,7 @@ static int nand_width = 1; /* default x8*/ /* * Define partitions for flash device */ -const static struct mtd_partition partition_info[] = { +static const struct mtd_partition partition_info[] = { { .name = "NAND FS 0", .offset = 0, diff --git a/trunk/drivers/mtd/nand/rtc_from4.c b/trunk/drivers/mtd/nand/rtc_from4.c index 3a5841c9d950..4129c03dfd90 100644 --- a/trunk/drivers/mtd/nand/rtc_from4.c +++ b/trunk/drivers/mtd/nand/rtc_from4.c @@ -96,7 +96,7 @@ static struct mtd_info *rtc_from4_mtd = NULL; */ static void __iomem *rtc_from4_fio_base = (void *)P2SEGADDR(RTC_FROM4_FIO_BASE); -const static struct mtd_partition partition_info[] = { +static const struct mtd_partition partition_info[] = { { .name = "Renesas flash partition 1", .offset = 0, diff --git a/trunk/drivers/mtd/nand/spia.c b/trunk/drivers/mtd/nand/spia.c index 32541cbb0103..9cf1ce718ec1 100644 --- a/trunk/drivers/mtd/nand/spia.c +++ b/trunk/drivers/mtd/nand/spia.c @@ -67,7 +67,7 @@ module_param(spia_peddr, int, 0); /* * Define partitions for flash device */ -const static struct mtd_partition partition_info[] = { +static const struct mtd_partition partition_info[] = { { .name = "SPIA flash partition 1", .offset = 0, diff --git a/trunk/drivers/net/8139too.c b/trunk/drivers/net/8139too.c index d2102a27d307..adfba44dac5a 100644 --- a/trunk/drivers/net/8139too.c +++ b/trunk/drivers/net/8139too.c @@ -505,7 +505,7 @@ enum chip_flags { #define HW_REVID_MASK HW_REVID(1, 1, 1, 1, 1, 1, 1) /* directly indexed by chip_t, above */ -const static struct { +static const struct { const char *name; u32 version; /* from RTL8139C/RTL8139D docs */ u32 flags; diff --git a/trunk/drivers/net/hamradio/6pack.c b/trunk/drivers/net/hamradio/6pack.c index 90999867a32c..102c1f0b90da 100644 --- a/trunk/drivers/net/hamradio/6pack.c +++ b/trunk/drivers/net/hamradio/6pack.c @@ -456,11 +456,6 @@ static void sixpack_write_wakeup(struct tty_struct *tty) /* ----------------------------------------------------------------------- */ -static int sixpack_receive_room(struct tty_struct *tty) -{ - return 65536; /* We can handle an infinite amount of data. :-) */ -} - /* * Handle the 'receiver data ready' interrupt. * This function is called by the 'tty_io' module in the kernel when @@ -671,6 +666,7 @@ static int sixpack_open(struct tty_struct *tty) /* Done. We have linked the TTY line to a channel. */ tty->disc_data = sp; + tty->receive_room = 65536; /* Now we're ready to register. */ if (register_netdev(dev)) @@ -802,7 +798,6 @@ static struct tty_ldisc sp_ldisc = { .close = sixpack_close, .ioctl = sixpack_ioctl, .receive_buf = sixpack_receive_buf, - .receive_room = sixpack_receive_room, .write_wakeup = sixpack_write_wakeup, }; diff --git a/trunk/drivers/net/hamradio/mkiss.c b/trunk/drivers/net/hamradio/mkiss.c index f4424cf886c5..dc5e9d59deed 100644 --- a/trunk/drivers/net/hamradio/mkiss.c +++ b/trunk/drivers/net/hamradio/mkiss.c @@ -753,6 +753,7 @@ static int mkiss_open(struct tty_struct *tty) ax->tty = tty; tty->disc_data = ax; + tty->receive_room = 65535; if (tty->driver->flush_buffer) tty->driver->flush_buffer(tty); @@ -940,11 +941,6 @@ static void mkiss_receive_buf(struct tty_struct *tty, const unsigned char *cp, tty->driver->unthrottle(tty); } -static int mkiss_receive_room(struct tty_struct *tty) -{ - return 65536; /* We can handle an infinite amount of data. :-) */ -} - /* * Called by the driver when there's room for more data. If we have * more packets to send, we send them here. @@ -983,7 +979,6 @@ static struct tty_ldisc ax_ldisc = { .close = mkiss_close, .ioctl = mkiss_ioctl, .receive_buf = mkiss_receive_buf, - .receive_room = mkiss_receive_room, .write_wakeup = mkiss_write_wakeup }; diff --git a/trunk/drivers/net/irda/irport.c b/trunk/drivers/net/irda/irport.c index 3d016a498e1d..6070195b87bd 100644 --- a/trunk/drivers/net/irda/irport.c +++ b/trunk/drivers/net/irda/irport.c @@ -284,19 +284,6 @@ static void irport_start(struct irport_cb *self) outb(UART_IER_RLSI | UART_IER_RDI |UART_IER_THRI, iobase+UART_IER); } -/* - * Function irport_probe (void) - * - * Start IO port - * - */ -int irport_probe(int iobase) -{ - IRDA_DEBUG(4, "%s(), iobase=%#x\n", __FUNCTION__, iobase); - - return 0; -} - /* * Function irport_get_fcr (speed) * @@ -382,7 +369,7 @@ static void irport_change_speed(void *priv, __u32 speed) * we cannot use schedule_timeout() when we are in interrupt context * */ -int __irport_change_speed(struct irda_task *task) +static int __irport_change_speed(struct irda_task *task) { struct irport_cb *self; __u32 speed = (__u32) task->param; diff --git a/trunk/drivers/net/irda/irtty-sir.c b/trunk/drivers/net/irda/irtty-sir.c index b8d112348ba4..101750bf210f 100644 --- a/trunk/drivers/net/irda/irtty-sir.c +++ b/trunk/drivers/net/irda/irtty-sir.c @@ -288,22 +288,6 @@ static void irtty_receive_buf(struct tty_struct *tty, const unsigned char *cp, sirdev_receive(dev, cp, count); } -/* - * Function irtty_receive_room (tty) - * - * Used by the TTY to find out how much data we can receive at a time - * -*/ -static int irtty_receive_room(struct tty_struct *tty) -{ - struct sirtty_cb *priv = tty->disc_data; - - IRDA_ASSERT(priv != NULL, return 0;); - IRDA_ASSERT(priv->magic == IRTTY_MAGIC, return 0;); - - return 65536; /* We can handle an infinite amount of data. :-) */ -} - /* * Function irtty_write_wakeup (tty) * @@ -534,6 +518,7 @@ static int irtty_open(struct tty_struct *tty) dev->priv = priv; tty->disc_data = priv; + tty->receive_room = 65536; up(&irtty_sem); @@ -605,7 +590,6 @@ static struct tty_ldisc irda_ldisc = { .ioctl = irtty_ioctl, .poll = NULL, .receive_buf = irtty_receive_buf, - .receive_room = irtty_receive_room, .write_wakeup = irtty_write_wakeup, .owner = THIS_MODULE, }; diff --git a/trunk/drivers/net/pci-skeleton.c b/trunk/drivers/net/pci-skeleton.c index a1ac4bd1696e..a7bb54df75a8 100644 --- a/trunk/drivers/net/pci-skeleton.c +++ b/trunk/drivers/net/pci-skeleton.c @@ -415,7 +415,7 @@ typedef enum { /* directly indexed by chip_t, above */ -const static struct { +static const struct { const char *name; u8 version; /* from RTL8139C docs */ u32 RxConfigMask; /* should clear the bits supported by this chip */ diff --git a/trunk/drivers/net/ppp_async.c b/trunk/drivers/net/ppp_async.c index 400f652282d7..aa6540b39466 100644 --- a/trunk/drivers/net/ppp_async.c +++ b/trunk/drivers/net/ppp_async.c @@ -189,7 +189,7 @@ ppp_asynctty_open(struct tty_struct *tty) goto out_free; tty->disc_data = ap; - + tty->receive_room = 65536; return 0; out_free: @@ -343,12 +343,6 @@ ppp_asynctty_poll(struct tty_struct *tty, struct file *file, poll_table *wait) return 0; } -static int -ppp_asynctty_room(struct tty_struct *tty) -{ - return 65535; -} - /* * This can now be called from hard interrupt level as well * as soft interrupt level or mainline. @@ -398,7 +392,6 @@ static struct tty_ldisc ppp_ldisc = { .write = ppp_asynctty_write, .ioctl = ppp_asynctty_ioctl, .poll = ppp_asynctty_poll, - .receive_room = ppp_asynctty_room, .receive_buf = ppp_asynctty_receive, .write_wakeup = ppp_asynctty_wakeup, }; diff --git a/trunk/drivers/net/ppp_synctty.c b/trunk/drivers/net/ppp_synctty.c index 4d51c0c8023d..33cb8254e79d 100644 --- a/trunk/drivers/net/ppp_synctty.c +++ b/trunk/drivers/net/ppp_synctty.c @@ -237,7 +237,7 @@ ppp_sync_open(struct tty_struct *tty) goto out_free; tty->disc_data = ap; - + tty->receive_room = 65536; return 0; out_free: @@ -384,12 +384,6 @@ ppp_sync_poll(struct tty_struct *tty, struct file *file, poll_table *wait) return 0; } -static int -ppp_sync_room(struct tty_struct *tty) -{ - return 65535; -} - /* * This can now be called from hard interrupt level as well * as soft interrupt level or mainline. @@ -439,7 +433,6 @@ static struct tty_ldisc ppp_sync_ldisc = { .write = ppp_sync_write, .ioctl = ppp_synctty_ioctl, .poll = ppp_sync_poll, - .receive_room = ppp_sync_room, .receive_buf = ppp_sync_receive, .write_wakeup = ppp_sync_wakeup, }; diff --git a/trunk/drivers/net/r8169.c b/trunk/drivers/net/r8169.c index 14a76f7cf900..2e1bed153c39 100644 --- a/trunk/drivers/net/r8169.c +++ b/trunk/drivers/net/r8169.c @@ -170,7 +170,7 @@ enum phy_version { #define _R(NAME,MAC,MASK) \ { .name = NAME, .mac_version = MAC, .RxConfigMask = MASK } -const static struct { +static const struct { const char *name; u8 mac_version; u32 RxConfigMask; /* Clears the bits supported by this chip */ diff --git a/trunk/drivers/net/sis190.c b/trunk/drivers/net/sis190.c index 478791e09bf7..b420182eec4b 100644 --- a/trunk/drivers/net/sis190.c +++ b/trunk/drivers/net/sis190.c @@ -329,7 +329,7 @@ static struct mii_chip_info { { NULL, } }; -const static struct { +static const struct { const char *name; } sis_chip_info[] = { { "SiS 190 PCI Fast Ethernet adapter" }, diff --git a/trunk/drivers/net/slip.c b/trunk/drivers/net/slip.c index 404ea4297e32..b2e18d28850d 100644 --- a/trunk/drivers/net/slip.c +++ b/trunk/drivers/net/slip.c @@ -651,11 +651,6 @@ static void sl_setup(struct net_device *dev) ******************************************/ -static int slip_receive_room(struct tty_struct *tty) -{ - return 65536; /* We can handle an infinite amount of data. :-) */ -} - /* * Handle the 'receiver data ready' interrupt. * This function is called by the 'tty_io' module in the kernel when @@ -869,10 +864,6 @@ static int slip_open(struct tty_struct *tty) sl->line = tty_devnum(tty); sl->pid = current->pid; - /* FIXME: already done before we were called - seems this can go */ - if (tty->driver->flush_buffer) - tty->driver->flush_buffer(tty); - if (!test_bit(SLF_INUSE, &sl->flags)) { /* Perform the low-level SLIP initialization. */ if ((err = sl_alloc_bufs(sl, SL_MTU)) != 0) @@ -897,6 +888,7 @@ static int slip_open(struct tty_struct *tty) /* Done. We have linked the TTY line to a channel. */ rtnl_unlock(); + tty->receive_room = 65536; /* We don't flow control */ return sl->dev->base_addr; err_free_bufs: @@ -1329,7 +1321,6 @@ static struct tty_ldisc sl_ldisc = { .close = slip_close, .ioctl = slip_ioctl, .receive_buf = slip_receive_buf, - .receive_room = slip_receive_room, .write_wakeup = slip_write_wakeup, }; diff --git a/trunk/drivers/net/wan/pc300_tty.c b/trunk/drivers/net/wan/pc300_tty.c index 52f26b9c69d2..931cbdf6d791 100644 --- a/trunk/drivers/net/wan/pc300_tty.c +++ b/trunk/drivers/net/wan/pc300_tty.c @@ -689,7 +689,7 @@ static void cpc_tty_rx_work(void * data) } } cpc_tty->buf_rx.first = cpc_tty->buf_rx.first->next; - kfree(buf); + kfree((void *)buf); buf = cpc_tty->buf_rx.first; flg_rx = 1; } diff --git a/trunk/drivers/net/wan/x25_asy.c b/trunk/drivers/net/wan/x25_asy.c index bdf672c48182..9c3ccc669143 100644 --- a/trunk/drivers/net/wan/x25_asy.c +++ b/trunk/drivers/net/wan/x25_asy.c @@ -515,11 +515,6 @@ static int x25_asy_close(struct net_device *dev) return 0; } -static int x25_asy_receive_room(struct tty_struct *tty) -{ - return 65536; /* We can handle an infinite amount of data. :-) */ -} - /* * Handle the 'receiver data ready' interrupt. * This function is called by the 'tty_io' module in the kernel when @@ -573,6 +568,7 @@ static int x25_asy_open_tty(struct tty_struct *tty) sl->tty = tty; tty->disc_data = sl; + tty->receive_room = 65536; if (tty->driver->flush_buffer) { tty->driver->flush_buffer(tty); } @@ -779,7 +775,6 @@ static struct tty_ldisc x25_ldisc = { .close = x25_asy_close_tty, .ioctl = x25_asy_ioctl, .receive_buf = x25_asy_receive_buf, - .receive_room = x25_asy_receive_room, .write_wakeup = x25_asy_write_wakeup, }; diff --git a/trunk/drivers/net/wireless/strip.c b/trunk/drivers/net/wireless/strip.c index d25264ba0c0e..18baacfc5a2c 100644 --- a/trunk/drivers/net/wireless/strip.c +++ b/trunk/drivers/net/wireless/strip.c @@ -1675,11 +1675,6 @@ static int strip_rebuild_header(struct sk_buff *skb) /************************************************************************/ /* Receiving routines */ -static int strip_receive_room(struct tty_struct *tty) -{ - return 0x10000; /* We can handle an infinite amount of data. :-) */ -} - /* * This function parses the response to the ATS300? command, * extracting the radio version and serial number. @@ -2424,7 +2419,7 @@ static struct net_device_stats *strip_get_stats(struct net_device *dev) /* * Here's the order things happen: * When the user runs "slattach -p strip ..." - * 1. The TTY module calls strip_open + * 1. The TTY module calls strip_open;; * 2. strip_open calls strip_alloc * 3. strip_alloc calls register_netdev * 4. register_netdev calls strip_dev_init @@ -2652,6 +2647,8 @@ static int strip_open(struct tty_struct *tty) strip_info->tty = tty; tty->disc_data = strip_info; + tty->receive_room = 65536; + if (tty->driver->flush_buffer) tty->driver->flush_buffer(tty); @@ -2762,7 +2759,6 @@ static struct tty_ldisc strip_ldisc = { .close = strip_close, .ioctl = strip_ioctl, .receive_buf = strip_receive_buf, - .receive_room = strip_receive_room, .write_wakeup = strip_write_some_more, }; diff --git a/trunk/drivers/s390/block/dasd.c b/trunk/drivers/s390/block/dasd.c index 2472fa1a1be1..9c25654b1e75 100644 --- a/trunk/drivers/s390/block/dasd.c +++ b/trunk/drivers/s390/block/dasd.c @@ -1751,6 +1751,7 @@ dasd_device_operations = { .open = dasd_open, .release = dasd_release, .ioctl = dasd_ioctl, + .compat_ioctl = dasd_compat_ioctl, .getgeo = dasd_getgeo, }; diff --git a/trunk/drivers/s390/block/dasd_int.h b/trunk/drivers/s390/block/dasd_int.h index 2fb05c4a528c..e4b401500b01 100644 --- a/trunk/drivers/s390/block/dasd_int.h +++ b/trunk/drivers/s390/block/dasd_int.h @@ -527,6 +527,7 @@ void dasd_ioctl_exit(void); int dasd_ioctl_no_register(struct module *, int, dasd_ioctl_fn_t); int dasd_ioctl_no_unregister(struct module *, int, dasd_ioctl_fn_t); int dasd_ioctl(struct inode *, struct file *, unsigned int, unsigned long); +long dasd_compat_ioctl(struct file *, unsigned int, unsigned long); /* externals in dasd_proc.c */ int dasd_proc_init(void); diff --git a/trunk/drivers/s390/block/dasd_ioctl.c b/trunk/drivers/s390/block/dasd_ioctl.c index 8e4dcd58599e..9396fcacb8f8 100644 --- a/trunk/drivers/s390/block/dasd_ioctl.c +++ b/trunk/drivers/s390/block/dasd_ioctl.c @@ -118,6 +118,18 @@ dasd_ioctl(struct inode *inp, struct file *filp, return -EINVAL; } +long +dasd_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) +{ + int rval; + + lock_kernel(); + rval = dasd_ioctl(filp->f_dentry->d_inode, filp, cmd, arg); + unlock_kernel(); + + return (rval == -EINVAL) ? -ENOIOCTLCMD : rval; +} + static int dasd_ioctl_api_version(struct block_device *bdev, int no, long args) { diff --git a/trunk/drivers/s390/char/con3215.c b/trunk/drivers/s390/char/con3215.c index 75419cf9d353..1f060914cfa4 100644 --- a/trunk/drivers/s390/char/con3215.c +++ b/trunk/drivers/s390/char/con3215.c @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include @@ -432,8 +433,6 @@ raw3215_irq(struct ccw_device *cdev, unsigned long intparm, struct irb *irb) if (count > slen) count = slen; } else - if (count >= TTY_FLIPBUF_SIZE - tty->flip.count) - count = TTY_FLIPBUF_SIZE - tty->flip.count - 1; EBCASC(raw->inbuf, count); cchar = ctrlchar_handle(raw->inbuf, count, tty); switch (cchar & CTRLCHAR_MASK) { @@ -441,28 +440,20 @@ raw3215_irq(struct ccw_device *cdev, unsigned long intparm, struct irb *irb) break; case CTRLCHAR_CTRL: - tty->flip.count++; - *tty->flip.flag_buf_ptr++ = TTY_NORMAL; - *tty->flip.char_buf_ptr++ = cchar; + tty_insert_flip_char(tty, cchar, TTY_NORMAL); tty_flip_buffer_push(raw->tty); break; case CTRLCHAR_NONE: - memcpy(tty->flip.char_buf_ptr, - raw->inbuf, count); if (count < 2 || - (strncmp(raw->inbuf+count-2, "^n", 2) && - strncmp(raw->inbuf+count-2, "\252n", 2)) ) { - /* don't add the auto \n */ - tty->flip.char_buf_ptr[count] = '\n'; - memset(tty->flip.flag_buf_ptr, - TTY_NORMAL, count + 1); + (strncmp(raw->inbuf+count-2, "\252n", 2) && + strncmp(raw->inbuf+count-2, "^n", 2)) ) { + /* add the auto \n */ + raw->inbuf[count] = '\n'; count++; } else - count-=2; - tty->flip.char_buf_ptr += count; - tty->flip.flag_buf_ptr += count; - tty->flip.count += count; + count -= 2; + tty_insert_flip_string(tty, raw->inbuf, count); tty_flip_buffer_push(raw->tty); break; } diff --git a/trunk/drivers/s390/char/fs3270.c b/trunk/drivers/s390/char/fs3270.c index 735a7fcdeff5..5f6fa4c67843 100644 --- a/trunk/drivers/s390/char/fs3270.c +++ b/trunk/drivers/s390/char/fs3270.c @@ -319,9 +319,8 @@ fs3270_write(struct file *filp, const char *data, size_t count, loff_t *off) /* * process ioctl commands for the tube driver */ -static int -fs3270_ioctl(struct inode *inode, struct file *filp, - unsigned int cmd, unsigned long arg) +static long +fs3270_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) { struct fs3270 *fp; struct raw3270_iocb iocb; @@ -331,6 +330,7 @@ fs3270_ioctl(struct inode *inode, struct file *filp, if (!fp) return -ENODEV; rc = 0; + lock_kernel(); switch (cmd) { case TUBICMD: fp->read_command = arg; @@ -356,6 +356,7 @@ fs3270_ioctl(struct inode *inode, struct file *filp, rc = -EFAULT; break; } + unlock_kernel(); return rc; } @@ -491,12 +492,13 @@ fs3270_close(struct inode *inode, struct file *filp) } static struct file_operations fs3270_fops = { - .owner = THIS_MODULE, /* owner */ - .read = fs3270_read, /* read */ - .write = fs3270_write, /* write */ - .ioctl = fs3270_ioctl, /* ioctl */ - .open = fs3270_open, /* open */ - .release = fs3270_close, /* release */ + .owner = THIS_MODULE, /* owner */ + .read = fs3270_read, /* read */ + .write = fs3270_write, /* write */ + .unlocked_ioctl = fs3270_ioctl, /* ioctl */ + .compat_ioctl = fs3270_ioctl, /* ioctl */ + .open = fs3270_open, /* open */ + .release = fs3270_close, /* release */ }; /* diff --git a/trunk/drivers/s390/char/sclp_tty.c b/trunk/drivers/s390/char/sclp_tty.c index a20d7c89341d..6cbf067f1a8f 100644 --- a/trunk/drivers/s390/char/sclp_tty.c +++ b/trunk/drivers/s390/char/sclp_tty.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -496,25 +497,19 @@ sclp_tty_input(unsigned char* buf, unsigned int count) case CTRLCHAR_SYSRQ: break; case CTRLCHAR_CTRL: - sclp_tty->flip.count++; - *sclp_tty->flip.flag_buf_ptr++ = TTY_NORMAL; - *sclp_tty->flip.char_buf_ptr++ = cchar; + tty_insert_flip_char(sclp_tty, cchar, TTY_NORMAL); tty_flip_buffer_push(sclp_tty); break; case CTRLCHAR_NONE: /* send (normal) input to line discipline */ - memcpy(sclp_tty->flip.char_buf_ptr, buf, count); if (count < 2 || - (strncmp ((const char *) buf + count - 2, "^n", 2) && - strncmp ((const char *) buf + count - 2, "\0252n", 2))) { - sclp_tty->flip.char_buf_ptr[count] = '\n'; - count++; + (strncmp((const char *) buf + count - 2, "^n", 2) && + strncmp((const char *) buf + count - 2, "\252n", 2))) { + /* add the auto \n */ + tty_insert_flip_string(sclp_tty, buf, count); + tty_insert_flip_char(sclp_tty, '\n', TTY_NORMAL); } else - count -= 2; - memset(sclp_tty->flip.flag_buf_ptr, TTY_NORMAL, count); - sclp_tty->flip.char_buf_ptr += count; - sclp_tty->flip.flag_buf_ptr += count; - sclp_tty->flip.count += count; + tty_insert_flip_string(sclp_tty, buf, count - 2); tty_flip_buffer_push(sclp_tty); break; } diff --git a/trunk/drivers/s390/char/sclp_vt220.c b/trunk/drivers/s390/char/sclp_vt220.c index 06bd85824d7b..9e02625c82cf 100644 --- a/trunk/drivers/s390/char/sclp_vt220.c +++ b/trunk/drivers/s390/char/sclp_vt220.c @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include @@ -482,16 +483,7 @@ sclp_vt220_receiver_fn(struct evbuf_header *evbuf) /* Send input to line discipline */ buffer++; count--; - /* Prevent buffer overrun by discarding input. Note that - * because buffer_push works asynchronously, we cannot wait - * for the buffer to be emptied. */ - if (count + sclp_vt220_tty->flip.count > TTY_FLIPBUF_SIZE) - count = TTY_FLIPBUF_SIZE - sclp_vt220_tty->flip.count; - memcpy(sclp_vt220_tty->flip.char_buf_ptr, buffer, count); - memset(sclp_vt220_tty->flip.flag_buf_ptr, TTY_NORMAL, count); - sclp_vt220_tty->flip.char_buf_ptr += count; - sclp_vt220_tty->flip.flag_buf_ptr += count; - sclp_vt220_tty->flip.count += count; + tty_insert_flip_string(sclp_vt220_tty, buffer, count); tty_flip_buffer_push(sclp_vt220_tty); break; } diff --git a/trunk/drivers/s390/char/tape_char.c b/trunk/drivers/s390/char/tape_char.c index 86262a13f7c6..5ce7ca38ace0 100644 --- a/trunk/drivers/s390/char/tape_char.c +++ b/trunk/drivers/s390/char/tape_char.c @@ -37,6 +37,8 @@ static int tapechar_open(struct inode *,struct file *); static int tapechar_release(struct inode *,struct file *); static int tapechar_ioctl(struct inode *, struct file *, unsigned int, unsigned long); +static long tapechar_compat_ioctl(struct file *, unsigned int, + unsigned long); static struct file_operations tape_fops = { @@ -44,6 +46,7 @@ static struct file_operations tape_fops = .read = tapechar_read, .write = tapechar_write, .ioctl = tapechar_ioctl, + .compat_ioctl = tapechar_compat_ioctl, .open = tapechar_open, .release = tapechar_release, }; @@ -463,6 +466,23 @@ tapechar_ioctl(struct inode *inp, struct file *filp, return device->discipline->ioctl_fn(device, no, data); } +static long +tapechar_compat_ioctl(struct file *filp, unsigned int no, unsigned long data) +{ + struct tape_device *device = filp->private_data; + int rval = -ENOIOCTLCMD; + + if (device->discipline->ioctl_fn) { + lock_kernel(); + rval = device->discipline->ioctl_fn(device, no, data); + unlock_kernel(); + if (rval == -EINVAL) + rval = -ENOIOCTLCMD; + } + + return rval; +} + /* * Initialize character device frontend. */ diff --git a/trunk/drivers/s390/crypto/z90main.c b/trunk/drivers/s390/crypto/z90main.c index 135ae04e6e75..2f54d033d7cf 100644 --- a/trunk/drivers/s390/crypto/z90main.c +++ b/trunk/drivers/s390/crypto/z90main.c @@ -30,7 +30,6 @@ #include // mdelay #include #include // for tasklets -#include #include #include #include diff --git a/trunk/drivers/s390/net/ctctty.c b/trunk/drivers/s390/net/ctctty.c index 968f2c113efe..93d1725eb79b 100644 --- a/trunk/drivers/s390/net/ctctty.c +++ b/trunk/drivers/s390/net/ctctty.c @@ -25,6 +25,7 @@ #include #include #include +#include #include #include #include @@ -101,25 +102,17 @@ static spinlock_t ctc_tty_lock; static int ctc_tty_try_read(ctc_tty_info * info, struct sk_buff *skb) { - int c; int len; struct tty_struct *tty; DBF_TEXT(trace, 5, __FUNCTION__); if ((tty = info->tty)) { if (info->mcr & UART_MCR_RTS) { - c = TTY_FLIPBUF_SIZE - tty->flip.count; len = skb->len; - if (c >= len) { - memcpy(tty->flip.char_buf_ptr, skb->data, len); - memset(tty->flip.flag_buf_ptr, 0, len); - tty->flip.count += len; - tty->flip.char_buf_ptr += len; - tty->flip.flag_buf_ptr += len; - tty_flip_buffer_push(tty); - kfree_skb(skb); - return 1; - } + tty_insert_flip_string(tty, skb->data, len); + tty_flip_buffer_push(tty); + kfree_skb(skb); + return 1; } } return 0; @@ -138,19 +131,12 @@ ctc_tty_readmodem(ctc_tty_info *info) DBF_TEXT(trace, 5, __FUNCTION__); if ((tty = info->tty)) { if (info->mcr & UART_MCR_RTS) { - int c = TTY_FLIPBUF_SIZE - tty->flip.count; struct sk_buff *skb; - if ((c > 0) && (skb = skb_dequeue(&info->rx_queue))) { + if ((skb = skb_dequeue(&info->rx_queue))) { int len = skb->len; - if (len > c) - len = c; - memcpy(tty->flip.char_buf_ptr, skb->data, len); + tty_insert_flip_string(tty, skb->data, len); skb_pull(skb, len); - memset(tty->flip.flag_buf_ptr, 0, len); - tty->flip.count += len; - tty->flip.char_buf_ptr += len; - tty->flip.flag_buf_ptr += len; tty_flip_buffer_push(tty); if (skb->len > 0) skb_queue_head(&info->rx_queue, skb); diff --git a/trunk/drivers/scsi/aacraid/linit.c b/trunk/drivers/scsi/aacraid/linit.c index 3cb68af90456..9b9062f02462 100644 --- a/trunk/drivers/scsi/aacraid/linit.c +++ b/trunk/drivers/scsi/aacraid/linit.c @@ -46,7 +46,6 @@ #include #include #include -#include #include #include #include diff --git a/trunk/drivers/scsi/ch.c b/trunk/drivers/scsi/ch.c index 0920220f3313..4299fabca554 100644 --- a/trunk/drivers/scsi/ch.c +++ b/trunk/drivers/scsi/ch.c @@ -20,7 +20,6 @@ #include #include #include -#include #include #include /* here are all the ioctls */ diff --git a/trunk/drivers/scsi/megaraid/megaraid_mm.h b/trunk/drivers/scsi/megaraid/megaraid_mm.h index eb8c390a0fa3..3d9e67d6849d 100644 --- a/trunk/drivers/scsi/megaraid/megaraid_mm.h +++ b/trunk/drivers/scsi/megaraid/megaraid_mm.h @@ -22,7 +22,6 @@ #include #include #include -#include #include "mbox_defs.h" #include "megaraid_ioctl.h" diff --git a/trunk/drivers/serial/21285.c b/trunk/drivers/serial/21285.c index b5cf39468d18..221999bcf8fe 100644 --- a/trunk/drivers/serial/21285.c +++ b/trunk/drivers/serial/21285.c @@ -94,15 +94,6 @@ static irqreturn_t serial21285_rx_chars(int irq, void *dev_id, struct pt_regs *r status = *CSR_UARTFLG; while (!(status & 0x10) && max_count--) { - if (tty->flip.count >= TTY_FLIPBUF_SIZE) { - if (tty->low_latency) - tty_flip_buffer_push(tty); - /* - * If this failed then we will throw away the - * bytes but must do so to clear interrupts - */ - } - ch = *CSR_UARTDR; flag = TTY_NORMAL; port->icount.rx++; diff --git a/trunk/drivers/serial/68328serial.c b/trunk/drivers/serial/68328serial.c index 67e9afa000c1..4dd5c3f98167 100644 --- a/trunk/drivers/serial/68328serial.c +++ b/trunk/drivers/serial/68328serial.c @@ -294,7 +294,7 @@ static _INLINE_ void receive_chars(struct m68k_serial *info, struct pt_regs *reg { struct tty_struct *tty = info->tty; m68328_uart *uart = &uart_addr[info->line]; - unsigned char ch; + unsigned char ch, flag; /* * This do { } while() loop will get ALL chars out of Rx FIFO @@ -332,26 +332,24 @@ static _INLINE_ void receive_chars(struct m68k_serial *info, struct pt_regs *reg /* * Make sure that we do not overflow the buffer */ - if (tty->flip.count >= TTY_FLIPBUF_SIZE) { + if (tty_request_buffer_room(tty, 1) == 0) { schedule_work(&tty->flip.work); return; } + flag = TTY_NORMAL; + if(rx & URX_PARITY_ERROR) { - *tty->flip.flag_buf_ptr++ = TTY_PARITY; + flag = TTY_PARITY; status_handle(info, rx); } else if(rx & URX_OVRUN) { - *tty->flip.flag_buf_ptr++ = TTY_OVERRUN; + flag = TTY_OVERRUN; status_handle(info, rx); } else if(rx & URX_FRAME_ERROR) { - *tty->flip.flag_buf_ptr++ = TTY_FRAME; + flag = TTY_FRAME; status_handle(info, rx); - } else { - *tty->flip.flag_buf_ptr++ = 0; /* XXX */ } - *tty->flip.char_buf_ptr++ = ch; - tty->flip.count++; - + tty_insert_flip_char(tty, ch, flag); #ifndef CONFIG_XCOPILOT_BUGS } while((rx = uart->urx.w) & URX_DATA_READY); #endif diff --git a/trunk/drivers/serial/68360serial.c b/trunk/drivers/serial/68360serial.c index 170c9d2a749c..60f5a5dc17f1 100644 --- a/trunk/drivers/serial/68360serial.c +++ b/trunk/drivers/serial/68360serial.c @@ -394,7 +394,7 @@ static void rs_360_start(struct tty_struct *tty) static _INLINE_ void receive_chars(ser_info_t *info) { struct tty_struct *tty = info->tty; - unsigned char ch, *cp; + unsigned char ch, flag, *cp; /*int ignored = 0;*/ int i; ushort status; @@ -438,24 +438,15 @@ static _INLINE_ void receive_chars(ser_info_t *info) cp = (char *)bdp->buf; status = bdp->status; - /* Check to see if there is room in the tty buffer for - * the characters in our BD buffer. If not, we exit - * now, leaving the BD with the characters. We'll pick - * them up again on the next receive interrupt (which could - * be a timeout). - */ - if ((tty->flip.count + i) >= TTY_FLIPBUF_SIZE) - break; - while (i-- > 0) { ch = *cp++; - *tty->flip.char_buf_ptr = ch; icount->rx++; #ifdef SERIAL_DEBUG_INTR printk("DR%02x:%02x...", ch, status); #endif - *tty->flip.flag_buf_ptr = 0; + flag = TTY_NORMAL; + if (status & (BD_SC_BR | BD_SC_FR | BD_SC_PR | BD_SC_OV)) { /* @@ -490,30 +481,18 @@ static _INLINE_ void receive_chars(ser_info_t *info) if (info->flags & ASYNC_SAK) do_SAK(tty); } else if (status & BD_SC_PR) - *tty->flip.flag_buf_ptr = TTY_PARITY; + flag = TTY_PARITY; else if (status & BD_SC_FR) - *tty->flip.flag_buf_ptr = TTY_FRAME; - if (status & BD_SC_OV) { - /* - * Overrun is special, since it's - * reported immediately, and doesn't - * affect the current character - */ - if (tty->flip.count < TTY_FLIPBUF_SIZE) { - tty->flip.count++; - tty->flip.flag_buf_ptr++; - tty->flip.char_buf_ptr++; - *tty->flip.flag_buf_ptr = - TTY_OVERRUN; - } - } + flag = TTY_FRAME; } - if (tty->flip.count >= TTY_FLIPBUF_SIZE) - break; - - tty->flip.flag_buf_ptr++; - tty->flip.char_buf_ptr++; - tty->flip.count++; + tty_insert_flip_char(tty, ch, flag); + if (status & BD_SC_OV) + /* + * Overrun is special, since it's + * reported immediately, and doesn't + * affect the current character + */ + tty_insert_flip_char(tty, 0, TTY_OVERRUN); } /* This BD is ready to be used again. Clear status. @@ -541,12 +520,7 @@ static _INLINE_ void receive_break(ser_info_t *info) /* Check to see if there is room in the tty buffer for * the break. If not, we exit now, losing the break. FIXME */ - if ((tty->flip.count + 1) >= TTY_FLIPBUF_SIZE) - return; - *(tty->flip.flag_buf_ptr++) = TTY_BREAK; - *(tty->flip.char_buf_ptr++) = 0; - tty->flip.count++; - + tty_insert_flip_char(tty, 0, TTY_BREAK); schedule_work(&tty->flip.work); } diff --git a/trunk/drivers/serial/8250.c b/trunk/drivers/serial/8250.c index e8454611cb65..54e5cc0dd5f8 100644 --- a/trunk/drivers/serial/8250.c +++ b/trunk/drivers/serial/8250.c @@ -1142,19 +1142,6 @@ receive_chars(struct uart_8250_port *up, int *status, struct pt_regs *regs) char flag; do { - /* The following is not allowed by the tty layer and - unsafe. It should be fixed ASAP */ - if (unlikely(tty->flip.count >= TTY_FLIPBUF_SIZE)) { - if (tty->low_latency) { - spin_unlock(&up->port.lock); - tty_flip_buffer_push(tty); - spin_lock(&up->port.lock); - } - /* - * If this failed then we will throw away the - * bytes but must do so to clear interrupts - */ - } ch = serial_inp(up, UART_RX); flag = TTY_NORMAL; up->port.icount.rx++; diff --git a/trunk/drivers/serial/Kconfig b/trunk/drivers/serial/Kconfig index 1bae26a8a503..698cb76819d9 100644 --- a/trunk/drivers/serial/Kconfig +++ b/trunk/drivers/serial/Kconfig @@ -860,7 +860,7 @@ config SERIAL_VR41XX_CONSOLE config SERIAL_JSM tristate "Digi International NEO PCI Support" - depends on PCI + depends on PCI && BROKEN select SERIAL_CORE help This is a driver for Digi International's Neo series diff --git a/trunk/drivers/serial/amba-pl010.c b/trunk/drivers/serial/amba-pl010.c index 48f6e872314b..3490022e9fdc 100644 --- a/trunk/drivers/serial/amba-pl010.c +++ b/trunk/drivers/serial/amba-pl010.c @@ -154,15 +154,6 @@ pl010_rx_chars(struct uart_port *port) status = UART_GET_FR(port); while (UART_RX_DATA(status) && max_count--) { - if (tty->flip.count >= TTY_FLIPBUF_SIZE) { - if (tty->low_latency) - tty_flip_buffer_push(tty); - /* - * If this failed then we will throw away the - * bytes but must do so to clear interrupts. - */ - } - ch = UART_GET_CHAR(port); flag = TTY_NORMAL; diff --git a/trunk/drivers/serial/amba-pl011.c b/trunk/drivers/serial/amba-pl011.c index 129670556162..034a029e356e 100644 --- a/trunk/drivers/serial/amba-pl011.c +++ b/trunk/drivers/serial/amba-pl011.c @@ -120,15 +120,6 @@ pl011_rx_chars(struct uart_amba_port *uap) status = readw(uap->port.membase + UART01x_FR); while ((status & UART01x_FR_RXFE) == 0 && max_count--) { - if (tty->flip.count >= TTY_FLIPBUF_SIZE) { - if (tty->low_latency) - tty_flip_buffer_push(tty); - /* - * If this failed then we will throw away the - * bytes but must do so to clear interrupts - */ - } - ch = readw(uap->port.membase + UART01x_DR) | UART_DUMMY_DR_RX; flag = TTY_NORMAL; uap->port.icount.rx++; diff --git a/trunk/drivers/serial/au1x00_uart.c b/trunk/drivers/serial/au1x00_uart.c index a274ebf256a1..ceb5d7f37bbd 100644 --- a/trunk/drivers/serial/au1x00_uart.c +++ b/trunk/drivers/serial/au1x00_uart.c @@ -241,18 +241,12 @@ static _INLINE_ void receive_chars(struct uart_8250_port *up, int *status, struct pt_regs *regs) { struct tty_struct *tty = up->port.info->tty; - unsigned char ch; + unsigned char ch, flag; int max_count = 256; do { - if (unlikely(tty->flip.count >= TTY_FLIPBUF_SIZE)) { - tty->flip.work.func((void *)tty); - if (tty->flip.count >= TTY_FLIPBUF_SIZE) - return; // if TTY_DONT_FLIP is set - } ch = serial_inp(up, UART_RX); - *tty->flip.char_buf_ptr = ch; - *tty->flip.flag_buf_ptr = TTY_NORMAL; + flag = TTY_NORMAL; up->port.icount.rx++; if (unlikely(*status & (UART_LSR_BI | UART_LSR_PE | @@ -292,30 +286,23 @@ receive_chars(struct uart_8250_port *up, int *status, struct pt_regs *regs) #endif if (*status & UART_LSR_BI) { DEBUG_INTR("handling break...."); - *tty->flip.flag_buf_ptr = TTY_BREAK; + flag = TTY_BREAK; } else if (*status & UART_LSR_PE) - *tty->flip.flag_buf_ptr = TTY_PARITY; + flag = TTY_PARITY; else if (*status & UART_LSR_FE) - *tty->flip.flag_buf_ptr = TTY_FRAME; + flag = TTY_FRAME; } if (uart_handle_sysrq_char(&up->port, ch, regs)) goto ignore_char; - if ((*status & up->port.ignore_status_mask) == 0) { - tty->flip.flag_buf_ptr++; - tty->flip.char_buf_ptr++; - tty->flip.count++; - } - if ((*status & UART_LSR_OE) && - tty->flip.count < TTY_FLIPBUF_SIZE) { + if ((*status & up->port.ignore_status_mask) == 0) + tty_insert_flip_char(tty, ch, flag); + if (*status & UART_LSR_OE) /* * Overrun is special, since it's reported * immediately, and doesn't affect the current * character. */ - *tty->flip.flag_buf_ptr = TTY_OVERRUN; - tty->flip.flag_buf_ptr++; - tty->flip.char_buf_ptr++; - tty->flip.count++; + tty_insert_flip_char(tty, 0, TTY_OVERRUN); } ignore_char: *status = serial_inp(up, UART_LSR); diff --git a/trunk/drivers/serial/clps711x.c b/trunk/drivers/serial/clps711x.c index 87ef368384fb..8ef999481f93 100644 --- a/trunk/drivers/serial/clps711x.c +++ b/trunk/drivers/serial/clps711x.c @@ -104,8 +104,6 @@ static irqreturn_t clps711xuart_int_rx(int irq, void *dev_id, struct pt_regs *re while (!(status & SYSFLG_URXFE)) { ch = clps_readl(UARTDR(port)); - if (tty->flip.count >= TTY_FLIPBUF_SIZE) - goto ignore_char; port->icount.rx++; flg = TTY_NORMAL; diff --git a/trunk/drivers/serial/dz.c b/trunk/drivers/serial/dz.c index 4d8516d1bb71..a64ba26a94e8 100644 --- a/trunk/drivers/serial/dz.c +++ b/trunk/drivers/serial/dz.c @@ -216,8 +216,6 @@ static inline void dz_receive_chars(struct dz_port *dport) if (!tty) break; - if (tty->flip.count >= TTY_FLIPBUF_SIZE) - break; icount->rx++; diff --git a/trunk/drivers/serial/icom.c b/trunk/drivers/serial/icom.c index eb31125c6a30..144a7a352b28 100644 --- a/trunk/drivers/serial/icom.c +++ b/trunk/drivers/serial/icom.c @@ -729,19 +729,20 @@ static void recv_interrupt(u16 port_int_reg, struct icom_port *icom_port) unsigned short int status; struct uart_icount *icount; unsigned long offset; + unsigned char flag; trace(icom_port, "RCV_COMPLETE", 0); rcv_buff = icom_port->next_rcv; status = cpu_to_le16(icom_port->statStg->rcv[rcv_buff].flags); while (status & SA_FL_RCV_DONE) { + int first = -1; trace(icom_port, "FID_STATUS", status); count = cpu_to_le16(icom_port->statStg->rcv[rcv_buff].leLength); + count = tty_buffer_request_room(tty, count); trace(icom_port, "RCV_COUNT", count); - if (count > (TTY_FLIPBUF_SIZE - tty->flip.count)) - count = TTY_FLIPBUF_SIZE - tty->flip.count; trace(icom_port, "REAL_COUNT", count); @@ -749,15 +750,10 @@ static void recv_interrupt(u16 port_int_reg, struct icom_port *icom_port) cpu_to_le32(icom_port->statStg->rcv[rcv_buff].leBuffer) - icom_port->recv_buf_pci; - memcpy(tty->flip.char_buf_ptr,(unsigned char *) - ((unsigned long)icom_port->recv_buf + offset), count); - + /* Block copy all but the last byte as this may have status */ if (count > 0) { - tty->flip.count += count - 1; - tty->flip.char_buf_ptr += count - 1; - - memset(tty->flip.flag_buf_ptr, 0, count); - tty->flip.flag_buf_ptr += count - 1; + first = icom_port->recv_buf[offset]; + tty_insert_flip_string(tty, icom_port->recv_buf + offset, count - 1); } icount = &icom_port->uart_port.icount; @@ -765,12 +761,14 @@ static void recv_interrupt(u16 port_int_reg, struct icom_port *icom_port) /* Break detect logic */ if ((status & SA_FLAGS_FRAME_ERROR) - && (tty->flip.char_buf_ptr[0] == 0x00)) { + && first == 0) { status &= ~SA_FLAGS_FRAME_ERROR; status |= SA_FLAGS_BREAK_DET; trace(icom_port, "BREAK_DET", 0); } + flag = TTY_NORMAL; + if (status & (SA_FLAGS_BREAK_DET | SA_FLAGS_PARITY_ERROR | SA_FLAGS_FRAME_ERROR | SA_FLAGS_OVERRUN)) { @@ -797,33 +795,26 @@ static void recv_interrupt(u16 port_int_reg, struct icom_port *icom_port) status &= icom_port->read_status_mask; if (status & SA_FLAGS_BREAK_DET) { - *tty->flip.flag_buf_ptr = TTY_BREAK; + flag = TTY_BREAK; } else if (status & SA_FLAGS_PARITY_ERROR) { trace(icom_port, "PARITY_ERROR", 0); - *tty->flip.flag_buf_ptr = TTY_PARITY; + flag = TTY_PARITY; } else if (status & SA_FLAGS_FRAME_ERROR) - *tty->flip.flag_buf_ptr = TTY_FRAME; - - if (status & SA_FLAGS_OVERRUN) { - /* - * Overrun is special, since it's - * reported immediately, and doesn't - * affect the current character - */ - if (tty->flip.count < TTY_FLIPBUF_SIZE) { - tty->flip.count++; - tty->flip.flag_buf_ptr++; - tty->flip.char_buf_ptr++; - *tty->flip.flag_buf_ptr = TTY_OVERRUN; - } - } + flag = TTY_FRAME; + } - tty->flip.flag_buf_ptr++; - tty->flip.char_buf_ptr++; - tty->flip.count++; - ignore_char: - icom_port->statStg->rcv[rcv_buff].flags = 0; + tty_insert_flip_char(tty, *(icom_port->recv_buf + offset + count - 1), flag); + + if (status & SA_FLAGS_OVERRUN) + /* + * Overrun is special, since it's + * reported immediately, and doesn't + * affect the current character + */ + tty_insert_flip_char(tty, 0, TTY_OVERRUN); +ignore_char: + icom_port->statStg->rcv[rcv_buff].flags = 0; icom_port->statStg->rcv[rcv_buff].leLength = 0; icom_port->statStg->rcv[rcv_buff].WorkingLength = (unsigned short int) cpu_to_le16(RCV_BUFF_SZ); diff --git a/trunk/drivers/serial/imx.c b/trunk/drivers/serial/imx.c index 83c4c1216587..5c098be9346b 100644 --- a/trunk/drivers/serial/imx.c +++ b/trunk/drivers/serial/imx.c @@ -256,9 +256,6 @@ static irqreturn_t imx_rxint(int irq, void *dev_id, struct pt_regs *regs) error_return: tty_insert_flip_char(tty, rx, flg); - if (tty->flip.count >= TTY_FLIPBUF_SIZE) - goto out; - ignore_char: rx = URXD0((u32)sport->port.membase); } while(rx & URXD_CHARRDY); diff --git a/trunk/drivers/serial/ioc4_serial.c b/trunk/drivers/serial/ioc4_serial.c index 771676abee60..1d85533d46d2 100644 --- a/trunk/drivers/serial/ioc4_serial.c +++ b/trunk/drivers/serial/ioc4_serial.c @@ -2327,19 +2327,13 @@ static void receive_chars(struct uart_port *the_port) spin_lock_irqsave(&the_port->lock, pflags); tty = info->tty; - if (request_count > TTY_FLIPBUF_SIZE - tty->flip.count) - request_count = TTY_FLIPBUF_SIZE - tty->flip.count; + request_count = tty_buffer_request_room(tty, IOC4_MAX_CHARS - 2); if (request_count > 0) { icount = &the_port->icount; read_count = do_read(the_port, ch, request_count); if (read_count > 0) { - flip = 1; - memcpy(tty->flip.char_buf_ptr, ch, read_count); - memset(tty->flip.flag_buf_ptr, TTY_NORMAL, read_count); - tty->flip.char_buf_ptr += read_count; - tty->flip.flag_buf_ptr += read_count; - tty->flip.count += read_count; + tty_insert_flip_string(tty, ch, read_count); icount->rx += read_count; } } diff --git a/trunk/drivers/serial/ip22zilog.c b/trunk/drivers/serial/ip22zilog.c index ef132349f310..66f117d15065 100644 --- a/trunk/drivers/serial/ip22zilog.c +++ b/trunk/drivers/serial/ip22zilog.c @@ -259,13 +259,7 @@ static void ip22zilog_receive_chars(struct uart_ip22zilog_port *up, struct tty_struct *tty = up->port.info->tty; /* XXX info==NULL? */ while (1) { - unsigned char ch, r1; - - if (unlikely(tty->flip.count >= TTY_FLIPBUF_SIZE)) { - tty->flip.work.func((void *)tty); - if (tty->flip.count >= TTY_FLIPBUF_SIZE) - return; /* XXX Ignores SysRq when we need it most. Fix. */ - } + unsigned char ch, r1, flag; r1 = read_zsreg(channel, R1); if (r1 & (PAR_ERR | Rx_OVR | CRC_ERR)) { @@ -303,8 +297,7 @@ static void ip22zilog_receive_chars(struct uart_ip22zilog_port *up, } /* A real serial line, record the character and status. */ - *tty->flip.char_buf_ptr = ch; - *tty->flip.flag_buf_ptr = TTY_NORMAL; + flag = TTY_NORMAL; up->port.icount.rx++; if (r1 & (BRK_ABRT | PAR_ERR | Rx_OVR | CRC_ERR)) { if (r1 & BRK_ABRT) { @@ -321,28 +314,21 @@ static void ip22zilog_receive_chars(struct uart_ip22zilog_port *up, up->port.icount.overrun++; r1 &= up->port.read_status_mask; if (r1 & BRK_ABRT) - *tty->flip.flag_buf_ptr = TTY_BREAK; + flag = TTY_BREAK; else if (r1 & PAR_ERR) - *tty->flip.flag_buf_ptr = TTY_PARITY; + flag = TTY_PARITY; else if (r1 & CRC_ERR) - *tty->flip.flag_buf_ptr = TTY_FRAME; + flag = TTY_FRAME; } if (uart_handle_sysrq_char(&up->port, ch, regs)) goto next_char; if (up->port.ignore_status_mask == 0xff || - (r1 & up->port.ignore_status_mask) == 0) { - tty->flip.flag_buf_ptr++; - tty->flip.char_buf_ptr++; - tty->flip.count++; - } - if ((r1 & Rx_OVR) && - tty->flip.count < TTY_FLIPBUF_SIZE) { - *tty->flip.flag_buf_ptr = TTY_OVERRUN; - tty->flip.flag_buf_ptr++; - tty->flip.char_buf_ptr++; - tty->flip.count++; - } + (r1 & up->port.ignore_status_mask) == 0) + tty_insert_flip_char(tty, ch, flag); + + if (r1 & Rx_OVR) + tty_insert_flip_char(tty, 0, TTY_OVERRUN); next_char: ch = readb(&channel->control); ZSDELAY(); diff --git a/trunk/drivers/serial/m32r_sio.c b/trunk/drivers/serial/m32r_sio.c index b0ecc7537ce5..b48066a64a7d 100644 --- a/trunk/drivers/serial/m32r_sio.c +++ b/trunk/drivers/serial/m32r_sio.c @@ -331,17 +331,12 @@ static _INLINE_ void receive_chars(struct uart_sio_port *up, int *status, { struct tty_struct *tty = up->port.info->tty; unsigned char ch; + unsigned char flag; int max_count = 256; do { - if (unlikely(tty->flip.count >= TTY_FLIPBUF_SIZE)) { - tty->flip.work.func((void *)tty); - if (tty->flip.count >= TTY_FLIPBUF_SIZE) - return; // if TTY_DONT_FLIP is set - } ch = sio_in(up, SIORXB); - *tty->flip.char_buf_ptr = ch; - *tty->flip.flag_buf_ptr = TTY_NORMAL; + flag = TTY_NORMAL; up->port.icount.rx++; if (unlikely(*status & (UART_LSR_BI | UART_LSR_PE | @@ -380,30 +375,24 @@ static _INLINE_ void receive_chars(struct uart_sio_port *up, int *status, if (*status & UART_LSR_BI) { DEBUG_INTR("handling break...."); - *tty->flip.flag_buf_ptr = TTY_BREAK; + flag = TTY_BREAK; } else if (*status & UART_LSR_PE) - *tty->flip.flag_buf_ptr = TTY_PARITY; + flag = TTY_PARITY; else if (*status & UART_LSR_FE) - *tty->flip.flag_buf_ptr = TTY_FRAME; + flag = TTY_FRAME; } if (uart_handle_sysrq_char(&up->port, ch, regs)) goto ignore_char; - if ((*status & up->port.ignore_status_mask) == 0) { - tty->flip.flag_buf_ptr++; - tty->flip.char_buf_ptr++; - tty->flip.count++; - } - if ((*status & UART_LSR_OE) && - tty->flip.count < TTY_FLIPBUF_SIZE) { + if ((*status & up->port.ignore_status_mask) == 0) + tty_insert_flip_char(tty, ch, flag); + + if (*status & UART_LSR_OE) { /* * Overrun is special, since it's reported * immediately, and doesn't affect the current * character. */ - *tty->flip.flag_buf_ptr = TTY_OVERRUN; - tty->flip.flag_buf_ptr++; - tty->flip.char_buf_ptr++; - tty->flip.count++; + tty_insert_flip_char(tty, 0, TTY_OVERRUN); } ignore_char: *status = serial_in(up, UART_LSR); diff --git a/trunk/drivers/serial/mcfserial.c b/trunk/drivers/serial/mcfserial.c index 47f7404cb045..f2a51e61eec7 100644 --- a/trunk/drivers/serial/mcfserial.c +++ b/trunk/drivers/serial/mcfserial.c @@ -313,7 +313,7 @@ static inline void receive_chars(struct mcf_serial *info) { volatile unsigned char *uartp; struct tty_struct *tty = info->tty; - unsigned char status, ch; + unsigned char status, ch, flag; if (!tty) return; @@ -321,10 +321,6 @@ static inline void receive_chars(struct mcf_serial *info) uartp = info->addr; while ((status = uartp[MCFUART_USR]) & MCFUART_USR_RXREADY) { - - if (tty->flip.count >= TTY_FLIPBUF_SIZE) - break; - ch = uartp[MCFUART_URB]; info->stats.rx++; @@ -335,29 +331,24 @@ static inline void receive_chars(struct mcf_serial *info) } #endif - tty->flip.count++; + flag = TTY_NORMAL; if (status & MCFUART_USR_RXERR) { uartp[MCFUART_UCR] = MCFUART_UCR_CMDRESETERR; if (status & MCFUART_USR_RXBREAK) { info->stats.rxbreak++; - *tty->flip.flag_buf_ptr++ = TTY_BREAK; + flag = TTY_BREAK; } else if (status & MCFUART_USR_RXPARITY) { info->stats.rxparity++; - *tty->flip.flag_buf_ptr++ = TTY_PARITY; + flag = TTY_PARITY; } else if (status & MCFUART_USR_RXOVERRUN) { info->stats.rxoverrun++; - *tty->flip.flag_buf_ptr++ = TTY_OVERRUN; + flag = TTY_OVERRUN; } else if (status & MCFUART_USR_RXFRAMING) { info->stats.rxframing++; - *tty->flip.flag_buf_ptr++ = TTY_FRAME; - } else { - /* This should never happen... */ - *tty->flip.flag_buf_ptr++ = 0; + flag = TTY_FRAME; } - } else { - *tty->flip.flag_buf_ptr++ = 0; } - *tty->flip.char_buf_ptr++ = ch; + tty_insert_flip_char(tty, ch, flag); } schedule_work(&tty->flip.work); diff --git a/trunk/drivers/serial/mpc52xx_uart.c b/trunk/drivers/serial/mpc52xx_uart.c index 1288d6203e94..61dd17d7bace 100644 --- a/trunk/drivers/serial/mpc52xx_uart.c +++ b/trunk/drivers/serial/mpc52xx_uart.c @@ -405,17 +405,13 @@ static inline int mpc52xx_uart_int_rx_chars(struct uart_port *port, struct pt_regs *regs) { struct tty_struct *tty = port->info->tty; - unsigned char ch; + unsigned char ch, flag; unsigned short status; /* While we can read, do so ! */ while ( (status = in_be16(&PSC(port)->mpc52xx_psc_status)) & MPC52xx_PSC_SR_RXRDY) { - /* If we are full, just stop reading */ - if (tty->flip.count >= TTY_FLIPBUF_SIZE) - break; - /* Get the char */ ch = in_8(&PSC(port)->mpc52xx_psc_buffer_8); @@ -428,45 +424,35 @@ mpc52xx_uart_int_rx_chars(struct uart_port *port, struct pt_regs *regs) #endif /* Store it */ - *tty->flip.char_buf_ptr = ch; - *tty->flip.flag_buf_ptr = 0; + + flag = TTY_NORMAL; port->icount.rx++; if ( status & (MPC52xx_PSC_SR_PE | MPC52xx_PSC_SR_FE | - MPC52xx_PSC_SR_RB | - MPC52xx_PSC_SR_OE) ) { + MPC52xx_PSC_SR_RB) ) { if (status & MPC52xx_PSC_SR_RB) { - *tty->flip.flag_buf_ptr = TTY_BREAK; + flag = TTY_BREAK; uart_handle_break(port); } else if (status & MPC52xx_PSC_SR_PE) - *tty->flip.flag_buf_ptr = TTY_PARITY; + flag = TTY_PARITY; else if (status & MPC52xx_PSC_SR_FE) - *tty->flip.flag_buf_ptr = TTY_FRAME; - if (status & MPC52xx_PSC_SR_OE) { - /* - * Overrun is special, since it's - * reported immediately, and doesn't - * affect the current character - */ - if (tty->flip.count < (TTY_FLIPBUF_SIZE-1)) { - tty->flip.flag_buf_ptr++; - tty->flip.char_buf_ptr++; - tty->flip.count++; - } - *tty->flip.flag_buf_ptr = TTY_OVERRUN; - } + flag = TTY_FRAME; /* Clear error condition */ out_8(&PSC(port)->command,MPC52xx_PSC_RST_ERR_STAT); } - - tty->flip.char_buf_ptr++; - tty->flip.flag_buf_ptr++; - tty->flip.count++; - + tty_insert_flip_char(tty, ch, flag); + if (status & MPC52xx_PSC_SR_OE) { + /* + * Overrun is special, since it's + * reported immediately, and doesn't + * affect the current character + */ + tty_insert_flip_char(tty, 0, TTY_OVERRUN); + } } tty_flip_buffer_push(tty); diff --git a/trunk/drivers/serial/mpsc.c b/trunk/drivers/serial/mpsc.c index 8f83e4007ecd..0ca83ac31d07 100644 --- a/trunk/drivers/serial/mpsc.c +++ b/trunk/drivers/serial/mpsc.c @@ -769,12 +769,12 @@ mpsc_rx_intr(struct mpsc_port_info *pi, struct pt_regs *regs) bytes_in = be16_to_cpu(rxre->bytecnt); /* Following use of tty struct directly is deprecated */ - if (unlikely((tty->flip.count + bytes_in) >= TTY_FLIPBUF_SIZE)){ + if (unlikely(tty_buffer_request_room(tty, bytes_in) < bytes_in)) { if (tty->low_latency) tty_flip_buffer_push(tty); /* - * If this failed then we will throw awa the bytes - * but mst do so to clear interrupts. + * If this failed then we will throw away the bytes + * but must do so to clear interrupts. */ } diff --git a/trunk/drivers/serial/mux.c b/trunk/drivers/serial/mux.c index 7633132a10aa..4e49168c3176 100644 --- a/trunk/drivers/serial/mux.c +++ b/trunk/drivers/serial/mux.c @@ -223,11 +223,6 @@ static void mux_read(struct uart_port *port) if (MUX_EOFIFO(data)) break; - if (tty->flip.count >= TTY_FLIPBUF_SIZE) - continue; - - *tty->flip.char_buf_ptr = data & 0xffu; - *tty->flip.flag_buf_ptr = TTY_NORMAL; port->icount.rx++; if (MUX_BREAK(data)) { @@ -239,9 +234,7 @@ static void mux_read(struct uart_port *port) if (uart_handle_sysrq_char(port, data & 0xffu, NULL)) continue; - tty->flip.flag_buf_ptr++; - tty->flip.char_buf_ptr++; - tty->flip.count++; + tty_insert_flip_char(tty, data & 0xFF, TTY_NORMAL); } if (start_count != port->icount.rx) { diff --git a/trunk/drivers/serial/pmac_zilog.c b/trunk/drivers/serial/pmac_zilog.c index ea24129eb6b9..f330d6c0e0df 100644 --- a/trunk/drivers/serial/pmac_zilog.c +++ b/trunk/drivers/serial/pmac_zilog.c @@ -210,10 +210,9 @@ static struct tty_struct *pmz_receive_chars(struct uart_pmac_port *uap, struct pt_regs *regs) { struct tty_struct *tty = NULL; - unsigned char ch, r1, drop, error; + unsigned char ch, r1, drop, error, flag; int loops = 0; - retry: /* The interrupt can be enabled when the port isn't open, typically * that happens when using one port is open and the other closed (stale * interrupt) or when one port is used as a console. @@ -246,20 +245,6 @@ static struct tty_struct *pmz_receive_chars(struct uart_pmac_port *uap, error = 0; drop = 0; - if (unlikely(tty->flip.count >= TTY_FLIPBUF_SIZE)) { - /* Have to drop the lock here */ - pmz_debug("pmz: flip overflow\n"); - spin_unlock(&uap->port.lock); - tty->flip.work.func((void *)tty); - spin_lock(&uap->port.lock); - if (tty->flip.count >= TTY_FLIPBUF_SIZE) - drop = 1; - if (ZS_IS_ASLEEP(uap)) - return NULL; - if (!ZS_IS_OPEN(uap)) - goto retry; - } - r1 = read_zsreg(uap, R1); ch = read_zsdata(uap); @@ -295,8 +280,7 @@ static struct tty_struct *pmz_receive_chars(struct uart_pmac_port *uap, if (drop) goto next_char; - *tty->flip.char_buf_ptr = ch; - *tty->flip.flag_buf_ptr = TTY_NORMAL; + flag = TTY_NORMAL; uap->port.icount.rx++; if (r1 & (PAR_ERR | Rx_OVR | CRC_ERR | BRK_ABRT)) { @@ -316,26 +300,19 @@ static struct tty_struct *pmz_receive_chars(struct uart_pmac_port *uap, uap->port.icount.overrun++; r1 &= uap->port.read_status_mask; if (r1 & BRK_ABRT) - *tty->flip.flag_buf_ptr = TTY_BREAK; + flag = TTY_BREAK; else if (r1 & PAR_ERR) - *tty->flip.flag_buf_ptr = TTY_PARITY; + flag = TTY_PARITY; else if (r1 & CRC_ERR) - *tty->flip.flag_buf_ptr = TTY_FRAME; + flag = TTY_FRAME; } if (uap->port.ignore_status_mask == 0xff || (r1 & uap->port.ignore_status_mask) == 0) { - tty->flip.flag_buf_ptr++; - tty->flip.char_buf_ptr++; - tty->flip.count++; - } - if ((r1 & Rx_OVR) && - tty->flip.count < TTY_FLIPBUF_SIZE) { - *tty->flip.flag_buf_ptr = TTY_OVERRUN; - tty->flip.flag_buf_ptr++; - tty->flip.char_buf_ptr++; - tty->flip.count++; + tty_insert_flip_char(tty, ch, flag); } + if (r1 & Rx_OVR) + tty_insert_flip_char(tty, 0, TTY_OVERRUN); next_char: /* We can get stuck in an infinite loop getting char 0 when the * line is in a wrong HW state, we break that here. diff --git a/trunk/drivers/serial/pxa.c b/trunk/drivers/serial/pxa.c index cc998b99a19f..10535f00301f 100644 --- a/trunk/drivers/serial/pxa.c +++ b/trunk/drivers/serial/pxa.c @@ -107,14 +107,6 @@ receive_chars(struct uart_pxa_port *up, int *status, struct pt_regs *regs) int max_count = 256; do { - if (unlikely(tty->flip.count >= TTY_FLIPBUF_SIZE)) { - if (tty->low_latency) - tty_flip_buffer_push(tty); - /* - * If this failed then we will throw away the - * bytes but must do so to clear interrupts - */ - } ch = serial_in(up, UART_RX); flag = TTY_NORMAL; up->port.icount.rx++; diff --git a/trunk/drivers/serial/s3c2410.c b/trunk/drivers/serial/s3c2410.c index fe83ce6fef52..eb4883efb7c6 100644 --- a/trunk/drivers/serial/s3c2410.c +++ b/trunk/drivers/serial/s3c2410.c @@ -323,16 +323,6 @@ s3c24xx_serial_rx_chars(int irq, void *dev_id, struct pt_regs *regs) if (s3c24xx_serial_rx_fifocnt(ourport, ufstat) == 0) break; - if (tty->flip.count >= TTY_FLIPBUF_SIZE) { - if (tty->low_latency) - tty_flip_buffer_push(tty); - - /* - * If this failed then we will throw away the - * bytes but must do so to clear interrupts - */ - } - uerstat = rd_regl(port, S3C2410_UERSTAT); ch = rd_regb(port, S3C2410_URXH); diff --git a/trunk/drivers/serial/sa1100.c b/trunk/drivers/serial/sa1100.c index 25a086458ab9..1bd93168f504 100644 --- a/trunk/drivers/serial/sa1100.c +++ b/trunk/drivers/serial/sa1100.c @@ -201,8 +201,6 @@ sa1100_rx_chars(struct sa1100_port *sport, struct pt_regs *regs) while (status & UTSR1_TO_SM(UTSR1_RNE)) { ch = UART_GET_CHAR(sport); - if (tty->flip.count >= TTY_FLIPBUF_SIZE) - goto ignore_char; sport->port.icount.rx++; flg = TTY_NORMAL; diff --git a/trunk/drivers/serial/serial_lh7a40x.c b/trunk/drivers/serial/serial_lh7a40x.c index d01dbe5da3b9..d4a1f0e798c1 100644 --- a/trunk/drivers/serial/serial_lh7a40x.c +++ b/trunk/drivers/serial/serial_lh7a40x.c @@ -148,15 +148,6 @@ lh7a40xuart_rx_chars (struct uart_port* port) unsigned int data, flag;/* Received data and status */ while (!(UR (port, UART_R_STATUS) & nRxRdy) && --cbRxMax) { - if (tty->flip.count >= TTY_FLIPBUF_SIZE) { - if (tty->low_latency) - tty_flip_buffer_push(tty); - /* - * If this failed then we will throw away the - * bytes but must do so to clear interrupts - */ - } - data = UR (port, UART_R_DATA); flag = TTY_NORMAL; ++port->icount.rx; diff --git a/trunk/drivers/serial/serial_txx9.c b/trunk/drivers/serial/serial_txx9.c index 995d9dd9ddd5..fdd1f1915a42 100644 --- a/trunk/drivers/serial/serial_txx9.c +++ b/trunk/drivers/serial/serial_txx9.c @@ -303,17 +303,6 @@ receive_chars(struct uart_txx9_port *up, unsigned int *status, struct pt_regs *r char flag; do { - /* The following is not allowed by the tty layer and - unsafe. It should be fixed ASAP */ - if (unlikely(tty->flip.count >= TTY_FLIPBUF_SIZE)) { - if (tty->low_latency) { - spin_unlock(&up->port.lock); - tty_flip_buffer_push(tty); - spin_lock(&up->port.lock); - } - /* If this failed then we will throw away the - bytes but must do so to clear interrupts */ - } ch = sio_in(up, TXX9_SIRFIFO); flag = TTY_NORMAL; up->port.icount.rx++; diff --git a/trunk/drivers/serial/sh-sci.c b/trunk/drivers/serial/sh-sci.c index 430754ebac8a..a9e070759628 100644 --- a/trunk/drivers/serial/sh-sci.c +++ b/trunk/drivers/serial/sh-sci.c @@ -482,6 +482,7 @@ static inline void sci_receive_chars(struct uart_port *port, struct tty_struct *tty = port->info->tty; int i, count, copied = 0; unsigned short status; + unsigned char flag; status = sci_in(port, SCxSR); if (!(status & SCxSR_RDxF(port))) @@ -499,8 +500,7 @@ static inline void sci_receive_chars(struct uart_port *port, #endif /* Don't copy more bytes than there is room for in the buffer */ - if (tty->flip.count + count > TTY_FLIPBUF_SIZE) - count = TTY_FLIPBUF_SIZE - tty->flip.count; + count = tty_buffer_request_room(tty, count); /* If for any reason we can't copy more data, we're done! */ if (count == 0) @@ -512,8 +512,7 @@ static inline void sci_receive_chars(struct uart_port *port, || uart_handle_sysrq_char(port, c, regs)) { count = 0; } else { - tty->flip.char_buf_ptr[0] = c; - tty->flip.flag_buf_ptr[0] = TTY_NORMAL; + tty_insert_flip_char(tty, c, TTY_NORMAL); } } else { for (i=0; iflip.char_buf_ptr[i] = c; if (status&SCxSR_FER(port)) { - tty->flip.flag_buf_ptr[i] = TTY_FRAME; + flag = TTY_FRAME; pr_debug("sci: frame error\n"); } else if (status&SCxSR_PER(port)) { - tty->flip.flag_buf_ptr[i] = TTY_PARITY; + flag = TTY_PARITY; pr_debug("sci: parity error\n"); - } else { - tty->flip.flag_buf_ptr[i] = TTY_NORMAL; - } + } else + flag = TTY_NORMAL; + tty_insert_flip_char(tty, c, flag); } } sci_in(port, SCxSR); /* dummy read */ sci_out(port, SCxSR, SCxSR_RDxF_CLEAR(port)); - /* Update the kernel buffer end */ - tty->flip.count += count; - tty->flip.char_buf_ptr += count; - tty->flip.flag_buf_ptr += count; copied += count; port->icount.rx += count; } @@ -608,48 +602,45 @@ static inline int sci_handle_errors(struct uart_port *port) unsigned short status = sci_in(port, SCxSR); struct tty_struct *tty = port->info->tty; - if (status&SCxSR_ORER(port) && tty->flip.countflip.flag_buf_ptr++ = TTY_OVERRUN; + if(tty_insert_flip_char(tty, 0, TTY_OVERRUN)) + copied++; pr_debug("sci: overrun error\n"); } - if (status&SCxSR_FER(port) && tty->flip.countbreak_flag) { - sci_port->break_flag = 1; - sci_schedule_break_timer((struct sci_port *)port); + if(!sci_port->break_flag) { + sci_port->break_flag = 1; + sci_schedule_break_timer((struct sci_port *)port); /* Do sysrq handling. */ - if(uart_handle_break(port)) { + if(uart_handle_break(port)) return 0; - } pr_debug("sci: BREAK detected\n"); - copied++; - *tty->flip.flag_buf_ptr++ = TTY_BREAK; + if(tty_insert_flip_char(tty, 0, TTY_BREAK)) + copied++; } } else { /* frame error */ - copied++; - *tty->flip.flag_buf_ptr++ = TTY_FRAME; + if(tty_insert_flip_char(tty, 0, TTY_FRAME)) + copied++; pr_debug("sci: frame error\n"); } } - if (status&SCxSR_PER(port) && tty->flip.countflip.flag_buf_ptr++ = TTY_PARITY; pr_debug("sci: parity error\n"); } - if (copied) { - tty->flip.count += copied; + if (copied) tty_flip_buffer_push(tty); - } return copied; } @@ -661,15 +652,14 @@ static inline int sci_handle_breaks(struct uart_port *port) struct tty_struct *tty = port->info->tty; struct sci_port *s = &sci_ports[port->line]; - if (!s->break_flag && status & SCxSR_BRK(port) && - tty->flip.count < TTY_FLIPBUF_SIZE) { + if (!s->break_flag && status & SCxSR_BRK(port)) #if defined(CONFIG_CPU_SH3) /* Debounce break */ s->break_flag = 1; #endif /* Notify of BREAK */ - copied++; - *tty->flip.flag_buf_ptr++ = TTY_BREAK; + if(tty_insert_flip_char(tty, 0, TTY_BREAK)) + copied++; pr_debug("sci: BREAK detected\n"); } @@ -677,19 +667,15 @@ static inline int sci_handle_breaks(struct uart_port *port) /* XXX: Handle SCIF overrun error */ if (port->type == PORT_SCIF && (sci_in(port, SCLSR) & SCIF_ORER) != 0) { sci_out(port, SCLSR, 0); - if(tty->flip.countflip.flag_buf_ptr++ = TTY_OVERRUN; pr_debug("sci: overrun error\n"); } } #endif - if (copied) { - tty->flip.count += copied; + if (copied) tty_flip_buffer_push(tty); - } - return copied; } @@ -732,12 +718,9 @@ static irqreturn_t sci_er_interrupt(int irq, void *ptr, struct pt_regs *regs) struct tty_struct *tty = port->info->tty; sci_out(port, SCLSR, 0); - if(tty->flip.countflip.flag_buf_ptr++ = TTY_OVERRUN; - tty->flip.count++; - tty_flip_buffer_push(tty); - pr_debug("scif: overrun error\n"); - } + tty_insert_flip_char(tty, 0, TTY_OVERRUN); + tty_flip_buffer_push(tty); + pr_debug("scif: overrun error\n"); } #endif sci_rx_interrupt(irq, ptr, regs); diff --git a/trunk/drivers/serial/sn_console.c b/trunk/drivers/serial/sn_console.c index 313f9df24a2d..5468e5a767e2 100644 --- a/trunk/drivers/serial/sn_console.c +++ b/trunk/drivers/serial/sn_console.c @@ -519,11 +519,7 @@ sn_receive_chars(struct sn_cons_port *port, struct pt_regs *regs, /* record the character to pass up to the tty layer */ if (tty) { - *tty->flip.char_buf_ptr = ch; - *tty->flip.flag_buf_ptr = TTY_NORMAL; - tty->flip.char_buf_ptr++; - tty->flip.count++; - if (tty->flip.count == TTY_FLIPBUF_SIZE) + if(tty_insert_flip_char(tty, ch, TTY_NORMAL) == 0) break; } port->sc_port.icount.rx++; diff --git a/trunk/drivers/serial/sunsab.c b/trunk/drivers/serial/sunsab.c index ba9381fd3f2d..7e773ff76c61 100644 --- a/trunk/drivers/serial/sunsab.c +++ b/trunk/drivers/serial/sunsab.c @@ -159,21 +159,14 @@ receive_chars(struct uart_sunsab_port *up, saw_console_brk = 1; for (i = 0; i < count; i++) { - unsigned char ch = buf[i]; + unsigned char ch = buf[i], flag; if (tty == NULL) { uart_handle_sysrq_char(&up->port, ch, regs); continue; } - if (unlikely(tty->flip.count >= TTY_FLIPBUF_SIZE)) { - tty->flip.work.func((void *)tty); - if (tty->flip.count >= TTY_FLIPBUF_SIZE) - return tty; // if TTY_DONT_FLIP is set - } - - *tty->flip.char_buf_ptr = ch; - *tty->flip.flag_buf_ptr = TTY_NORMAL; + flag = TTY_NORMAL; up->port.icount.rx++; if (unlikely(stat->sreg.isr0 & (SAB82532_ISR0_PERR | @@ -209,34 +202,21 @@ receive_chars(struct uart_sunsab_port *up, stat->sreg.isr1 &= ((up->port.read_status_mask >> 8) & 0xff); if (stat->sreg.isr1 & SAB82532_ISR1_BRK) { - *tty->flip.flag_buf_ptr = TTY_BREAK; + flag = TTY_BREAK; } else if (stat->sreg.isr0 & SAB82532_ISR0_PERR) - *tty->flip.flag_buf_ptr = TTY_PARITY; + flag = TTY_PARITY; else if (stat->sreg.isr0 & SAB82532_ISR0_FERR) - *tty->flip.flag_buf_ptr = TTY_FRAME; + flag = TTY_FRAME; } if (uart_handle_sysrq_char(&up->port, ch, regs)) continue; if ((stat->sreg.isr0 & (up->port.ignore_status_mask & 0xff)) == 0 && - (stat->sreg.isr1 & ((up->port.ignore_status_mask >> 8) & 0xff)) == 0){ - tty->flip.flag_buf_ptr++; - tty->flip.char_buf_ptr++; - tty->flip.count++; - } - if ((stat->sreg.isr0 & SAB82532_ISR0_RFO) && - tty->flip.count < TTY_FLIPBUF_SIZE) { - /* - * Overrun is special, since it's reported - * immediately, and doesn't affect the current - * character. - */ - *tty->flip.flag_buf_ptr = TTY_OVERRUN; - tty->flip.flag_buf_ptr++; - tty->flip.char_buf_ptr++; - tty->flip.count++; - } + (stat->sreg.isr1 & ((up->port.ignore_status_mask >> 8) & 0xff)) == 0) + tty_insert_flip_char(tty, ch, flag); + if (stat->sreg.isr0 & SAB82532_ISR0_RFO) + tty_insert_flip_char(tty, 0, TTY_OVERRUN); } if (saw_console_brk) diff --git a/trunk/drivers/serial/sunsu.c b/trunk/drivers/serial/sunsu.c index f0738533f39a..9a3665b34d97 100644 --- a/trunk/drivers/serial/sunsu.c +++ b/trunk/drivers/serial/sunsu.c @@ -323,19 +323,13 @@ static _INLINE_ struct tty_struct * receive_chars(struct uart_sunsu_port *up, unsigned char *status, struct pt_regs *regs) { struct tty_struct *tty = up->port.info->tty; - unsigned char ch; + unsigned char ch, flag; int max_count = 256; int saw_console_brk = 0; do { - if (unlikely(tty->flip.count >= TTY_FLIPBUF_SIZE)) { - tty->flip.work.func((void *)tty); - if (tty->flip.count >= TTY_FLIPBUF_SIZE) - return tty; // if TTY_DONT_FLIP is set - } ch = serial_inp(up, UART_RX); - *tty->flip.char_buf_ptr = ch; - *tty->flip.flag_buf_ptr = TTY_NORMAL; + flag = TTY_NORMAL; up->port.icount.rx++; if (unlikely(*status & (UART_LSR_BI | UART_LSR_PE | @@ -377,31 +371,23 @@ receive_chars(struct uart_sunsu_port *up, unsigned char *status, struct pt_regs } if (*status & UART_LSR_BI) { - *tty->flip.flag_buf_ptr = TTY_BREAK; + flag = TTY_BREAK; } else if (*status & UART_LSR_PE) - *tty->flip.flag_buf_ptr = TTY_PARITY; + flag = TTY_PARITY; else if (*status & UART_LSR_FE) - *tty->flip.flag_buf_ptr = TTY_FRAME; + flag = TTY_FRAME; } if (uart_handle_sysrq_char(&up->port, ch, regs)) goto ignore_char; - if ((*status & up->port.ignore_status_mask) == 0) { - tty->flip.flag_buf_ptr++; - tty->flip.char_buf_ptr++; - tty->flip.count++; - } - if ((*status & UART_LSR_OE) && - tty->flip.count < TTY_FLIPBUF_SIZE) { + if ((*status & up->port.ignore_status_mask) == 0) + tty_insert_flip_char(tty, ch, flag); + if (*status & UART_LSR_OE) /* * Overrun is special, since it's reported * immediately, and doesn't affect the current * character. */ - *tty->flip.flag_buf_ptr = TTY_OVERRUN; - tty->flip.flag_buf_ptr++; - tty->flip.char_buf_ptr++; - tty->flip.count++; - } + tty_insert_flip_char(tty, 0, TTY_OVERRUN); ignore_char: *status = serial_inp(up, UART_LSR); } while ((*status & UART_LSR_DR) && (max_count-- > 0)); diff --git a/trunk/drivers/serial/sunzilog.c b/trunk/drivers/serial/sunzilog.c index 7653d6cf05af..3c72484adea7 100644 --- a/trunk/drivers/serial/sunzilog.c +++ b/trunk/drivers/serial/sunzilog.c @@ -319,7 +319,7 @@ sunzilog_receive_chars(struct uart_sunzilog_port *up, struct pt_regs *regs) { struct tty_struct *tty; - unsigned char ch, r1; + unsigned char ch, r1, flag; tty = NULL; if (up->port.info != NULL && /* Unopened serial console */ @@ -362,19 +362,8 @@ sunzilog_receive_chars(struct uart_sunzilog_port *up, continue; } - if (unlikely(tty->flip.count >= TTY_FLIPBUF_SIZE)) { - tty->flip.work.func((void *)tty); - /* - * The 8250 bails out of the loop here, - * but we need to read everything, or die. - */ - if (tty->flip.count >= TTY_FLIPBUF_SIZE) - continue; - } - /* A real serial line, record the character and status. */ - *tty->flip.char_buf_ptr = ch; - *tty->flip.flag_buf_ptr = TTY_NORMAL; + flag = TTY_NORMAL; up->port.icount.rx++; if (r1 & (BRK_ABRT | PAR_ERR | Rx_OVR | CRC_ERR)) { if (r1 & BRK_ABRT) { @@ -391,28 +380,21 @@ sunzilog_receive_chars(struct uart_sunzilog_port *up, up->port.icount.overrun++; r1 &= up->port.read_status_mask; if (r1 & BRK_ABRT) - *tty->flip.flag_buf_ptr = TTY_BREAK; + flag = TTY_BREAK; else if (r1 & PAR_ERR) - *tty->flip.flag_buf_ptr = TTY_PARITY; + flag = TTY_PARITY; else if (r1 & CRC_ERR) - *tty->flip.flag_buf_ptr = TTY_FRAME; + flag = TTY_FRAME; } if (uart_handle_sysrq_char(&up->port, ch, regs)) continue; if (up->port.ignore_status_mask == 0xff || (r1 & up->port.ignore_status_mask) == 0) { - tty->flip.flag_buf_ptr++; - tty->flip.char_buf_ptr++; - tty->flip.count++; - } - if ((r1 & Rx_OVR) && - tty->flip.count < TTY_FLIPBUF_SIZE) { - *tty->flip.flag_buf_ptr = TTY_OVERRUN; - tty->flip.flag_buf_ptr++; - tty->flip.char_buf_ptr++; - tty->flip.count++; + tty_insert_flip_char(tty, ch, flag); } + if (r1 & Rx_OVR) + tty_insert_flip_char(tty, 0, TTY_OVERRUN); } return tty; diff --git a/trunk/drivers/serial/vr41xx_siu.c b/trunk/drivers/serial/vr41xx_siu.c index 4a3005fdd019..d61494d185cd 100644 --- a/trunk/drivers/serial/vr41xx_siu.c +++ b/trunk/drivers/serial/vr41xx_siu.c @@ -371,11 +371,6 @@ static inline void receive_chars(struct uart_port *port, uint8_t *status, lsr = *status; do { - if (unlikely(tty->flip.count >= TTY_FLIPBUF_SIZE)) { - if (tty->low_latency) - tty_flip_buffer_push(tty); - } - ch = siu_read(port, UART_RX); port->icount.rx++; flag = TTY_NORMAL; diff --git a/trunk/drivers/usb/atm/speedtch.c b/trunk/drivers/usb/atm/speedtch.c index b28336148658..c1b47d74e206 100644 --- a/trunk/drivers/usb/atm/speedtch.c +++ b/trunk/drivers/usb/atm/speedtch.c @@ -532,9 +532,9 @@ static void speedtch_handle_int(struct urb *int_urb, struct pt_regs *regs) int ret = int_urb->status; /* The magic interrupt for "up state" */ - const static unsigned char up_int[6] = { 0xa1, 0x00, 0x01, 0x00, 0x00, 0x00 }; + static const unsigned char up_int[6] = { 0xa1, 0x00, 0x01, 0x00, 0x00, 0x00 }; /* The magic interrupt for "down state" */ - const static unsigned char down_int[6] = { 0xa1, 0x00, 0x00, 0x00, 0x00, 0x00 }; + static const unsigned char down_int[6] = { 0xa1, 0x00, 0x00, 0x00, 0x00, 0x00 }; atm_dbg(usbatm, "%s entered\n", __func__); diff --git a/trunk/drivers/usb/class/cdc-acm.c b/trunk/drivers/usb/class/cdc-acm.c index 248279e44c99..b9fd39fd1b5b 100644 --- a/trunk/drivers/usb/class/cdc-acm.c +++ b/trunk/drivers/usb/class/cdc-acm.c @@ -335,14 +335,9 @@ static void acm_rx_tasklet(unsigned long _acm) dbg("acm_rx_tasklet: procesing buf 0x%p, size = %d\n", buf, buf->size); - for (i = 0; i < buf->size && !acm->throttle; i++) { - /* if we insert more than TTY_FLIPBUF_SIZE characters, - we drop them. */ - if (tty->flip.count >= TTY_FLIPBUF_SIZE) { - tty_flip_buffer_push(tty); - } - tty_insert_flip_char(tty, buf->base[i], 0); - } + tty_buffer_request_room(tty, buf->size); + if (!acm->throttle) + tty_insert_flip_string(tty, buf->base, buf->size); tty_flip_buffer_push(tty); spin_lock(&acm->throttle_lock); diff --git a/trunk/drivers/usb/gadget/serial.c b/trunk/drivers/usb/gadget/serial.c index 65e084a2c87e..2e6926b33455 100644 --- a/trunk/drivers/usb/gadget/serial.c +++ b/trunk/drivers/usb/gadget/serial.c @@ -1271,6 +1271,7 @@ static int gs_recv_packet(struct gs_dev *dev, char *packet, unsigned int size) unsigned int len; struct gs_port *port; int ret; + struct tty_struct *tty; /* TEMPORARY -- only port 0 is supported right now */ port = dev->dev_port[0]; @@ -1290,7 +1291,10 @@ static int gs_recv_packet(struct gs_dev *dev, char *packet, unsigned int size) goto exit; } - if (port->port_tty == NULL) { + + tty = port->port_tty; + + if (tty == NULL) { printk(KERN_ERR "gs_recv_packet: port=%d, NULL tty pointer\n", port->port_num); ret = -EIO; @@ -1304,20 +1308,13 @@ static int gs_recv_packet(struct gs_dev *dev, char *packet, unsigned int size) goto exit; } - len = (unsigned int)(TTY_FLIPBUF_SIZE - port->port_tty->flip.count); - if (len < size) - size = len; - - if (size > 0) { - memcpy(port->port_tty->flip.char_buf_ptr, packet, size); - port->port_tty->flip.char_buf_ptr += size; - port->port_tty->flip.count += size; + len = tty_buffer_request_room(tty, size); + if (len > 0) { + tty_insert_flip_string(tty, packet, len); tty_flip_buffer_push(port->port_tty); wake_up_interruptible(&port->port_tty->read_wait); } - ret = 0; - exit: spin_unlock(&port->port_lock); return ret; diff --git a/trunk/drivers/usb/image/microtek.c b/trunk/drivers/usb/image/microtek.c index 458f2acdeb0a..28538db9eaf3 100644 --- a/trunk/drivers/usb/image/microtek.c +++ b/trunk/drivers/usb/image/microtek.c @@ -674,7 +674,7 @@ struct vendor_product /* These are taken from the msmUSB.inf file on the Windows driver CD */ -const static struct vendor_product mts_supported_products[] = +static const struct vendor_product mts_supported_products[] = { { "Phantom 336CX", mts_sup_unknown}, { "Phantom 336CX", mts_sup_unknown}, diff --git a/trunk/drivers/usb/serial/Kconfig b/trunk/drivers/usb/serial/Kconfig index 14f55fd26a64..be5dc80836c3 100644 --- a/trunk/drivers/usb/serial/Kconfig +++ b/trunk/drivers/usb/serial/Kconfig @@ -84,7 +84,7 @@ config USB_SERIAL_BELKIN config USB_SERIAL_WHITEHEAT tristate "USB ConnectTech WhiteHEAT Serial Driver" - depends on USB_SERIAL && BROKEN_ON_SMP + depends on USB_SERIAL help Say Y here if you want to use a ConnectTech WhiteHEAT 4 port USB to serial converter device. diff --git a/trunk/drivers/usb/serial/cyberjack.c b/trunk/drivers/usb/serial/cyberjack.c index 6d18d4eaba35..2357b1d102d7 100644 --- a/trunk/drivers/usb/serial/cyberjack.c +++ b/trunk/drivers/usb/serial/cyberjack.c @@ -364,7 +364,6 @@ static void cyberjack_read_bulk_callback (struct urb *urb, struct pt_regs *regs) struct tty_struct *tty; unsigned char *data = urb->transfer_buffer; short todo; - int i; int result; dbg("%s - port %d", __FUNCTION__, port->number); @@ -381,14 +380,8 @@ static void cyberjack_read_bulk_callback (struct urb *urb, struct pt_regs *regs) return; } if (urb->actual_length) { - for (i = 0; i < urb->actual_length ; ++i) { - /* if we insert more than TTY_FLIPBUF_SIZE characters, we drop them. */ - if(tty->flip.count >= TTY_FLIPBUF_SIZE) { - tty_flip_buffer_push(tty); - } - /* this doesn't actually push the data through unless tty->low_latency is set */ - tty_insert_flip_char(tty, data[i], 0); - } + tty_buffer_request_room(tty, urb->actual_length); + tty_insert_flip_string(tty, data, urb->actual_length); tty_flip_buffer_push(tty); } diff --git a/trunk/drivers/usb/serial/cypress_m8.c b/trunk/drivers/usb/serial/cypress_m8.c index 4e9637eb6137..68067fe117a4 100644 --- a/trunk/drivers/usb/serial/cypress_m8.c +++ b/trunk/drivers/usb/serial/cypress_m8.c @@ -1263,12 +1263,10 @@ static void cypress_read_int_callback(struct urb *urb, struct pt_regs *regs) /* process read if there is data other than line status */ if (tty && (bytes > i)) { + bytes = tty_buffer_request_room(tty, bytes); for (; i < bytes ; ++i) { dbg("pushing byte number %d - %d - %c", i, data[i], data[i]); - if(tty->flip.count >= TTY_FLIPBUF_SIZE) { - tty_flip_buffer_push(tty); - } tty_insert_flip_char(tty, data[i], tty_flag); } tty_flip_buffer_push(port->tty); diff --git a/trunk/drivers/usb/serial/digi_acceleport.c b/trunk/drivers/usb/serial/digi_acceleport.c index 8fc414bd5b24..b3f776a90c93 100644 --- a/trunk/drivers/usb/serial/digi_acceleport.c +++ b/trunk/drivers/usb/serial/digi_acceleport.c @@ -946,13 +946,10 @@ dbg( "digi_rx_unthrottle: TOP: port=%d", priv->dp_port_num ); spin_lock_irqsave( &priv->dp_port_lock, flags ); /* send any buffered chars from throttle time on to tty subsystem */ - len = min(priv->dp_in_buf_len, TTY_FLIPBUF_SIZE - tty->flip.count ); + + len = tty_buffer_request_room(tty, priv->dp_in_buf_len); if( len > 0 ) { - memcpy( tty->flip.char_buf_ptr, priv->dp_in_buf, len ); - memcpy( tty->flip.flag_buf_ptr, priv->dp_in_flag_buf, len ); - tty->flip.char_buf_ptr += len; - tty->flip.flag_buf_ptr += len; - tty->flip.count += len; + tty_insert_flip_string_flags(tty, priv->dp_in_buf, priv->dp_in_flag_buf, len); tty_flip_buffer_push( tty ); } @@ -1827,6 +1824,7 @@ static int digi_read_inb_callback( struct urb *urb ) int status = ((unsigned char *)urb->transfer_buffer)[2]; unsigned char *data = ((unsigned char *)urb->transfer_buffer)+3; int flag,throttled; + int i; /* do not process callbacks on closed ports */ /* but do continue the read chain */ @@ -1885,20 +1883,18 @@ static int digi_read_inb_callback( struct urb *urb ) } } else { - - len = min( len, TTY_FLIPBUF_SIZE - tty->flip.count ); - + len = tty_buffer_request_room(tty, len); if( len > 0 ) { - memcpy( tty->flip.char_buf_ptr, data, len ); - memset( tty->flip.flag_buf_ptr, flag, len ); - tty->flip.char_buf_ptr += len; - tty->flip.flag_buf_ptr += len; - tty->flip.count += len; + /* Hot path */ + if(flag == TTY_NORMAL) + tty_insert_flip_string(tty, data, len); + else { + for(i = 0; i < len; i++) + tty_insert_flip_char(tty, data[i], flag); + } tty_flip_buffer_push( tty ); } - } - } spin_unlock( &priv->dp_port_lock ); diff --git a/trunk/drivers/usb/serial/empeg.c b/trunk/drivers/usb/serial/empeg.c index 79a766e9ca23..63f7c78a1152 100644 --- a/trunk/drivers/usb/serial/empeg.c +++ b/trunk/drivers/usb/serial/empeg.c @@ -344,7 +344,6 @@ static void empeg_read_bulk_callback (struct urb *urb, struct pt_regs *regs) struct usb_serial_port *port = (struct usb_serial_port *)urb->context; struct tty_struct *tty; unsigned char *data = urb->transfer_buffer; - int i; int result; dbg("%s - port %d", __FUNCTION__, port->number); @@ -359,19 +358,8 @@ static void empeg_read_bulk_callback (struct urb *urb, struct pt_regs *regs) tty = port->tty; if (urb->actual_length) { - for (i = 0; i < urb->actual_length ; ++i) { - /* gb - 2000/11/13 - * If we insert too many characters we'll overflow the buffer. - * This means we'll lose bytes - Decidedly bad. - */ - if(tty->flip.count >= TTY_FLIPBUF_SIZE) { - tty_flip_buffer_push(tty); - } - tty_insert_flip_char(tty, data[i], 0); - } - /* gb - 2000/11/13 - * Goes straight through instead of scheduling - if tty->low_latency is set. - */ + tty_buffer_request_room(tty, urb->actual_length); + tty_insert_flip_string(tty, data, urb->actual_length); tty_flip_buffer_push(tty); bytes_in += urb->actual_length; } diff --git a/trunk/drivers/usb/serial/ftdi_sio.c b/trunk/drivers/usb/serial/ftdi_sio.c index eb863b3f2d79..10bc1bf23b35 100644 --- a/trunk/drivers/usb/serial/ftdi_sio.c +++ b/trunk/drivers/usb/serial/ftdi_sio.c @@ -1610,24 +1610,11 @@ static void ftdi_process_read (void *param) length = 0; } - /* have to make sure we don't overflow the buffer - with tty_insert_flip_char's */ - if (tty->flip.count+length > TTY_FLIPBUF_SIZE) { - tty_flip_buffer_push(tty); - need_flip = 0; - - if (tty->flip.count != 0) { - /* flip didn't work, this happens when ftdi_process_read() is - * called from ftdi_unthrottle, because TTY_DONT_FLIP is set */ - dbg("%s - flip buffer push failed", __FUNCTION__); - break; - } - } if (priv->rx_flags & THROTTLED) { dbg("%s - throttled", __FUNCTION__); break; } - if (tty->ldisc.receive_room(tty)-tty->flip.count < length) { + if (tty_buffer_request_room(tty, length) < length) { /* break out & wait for throttling/unthrottling to happen */ dbg("%s - receive room low", __FUNCTION__); break; diff --git a/trunk/drivers/usb/serial/garmin_gps.c b/trunk/drivers/usb/serial/garmin_gps.c index 452efce72714..d6f55e9dccae 100644 --- a/trunk/drivers/usb/serial/garmin_gps.c +++ b/trunk/drivers/usb/serial/garmin_gps.c @@ -275,23 +275,14 @@ static void send_to_tty(struct usb_serial_port *port, char *data, unsigned int actual_length) { struct tty_struct *tty = port->tty; - int i; if (tty && actual_length) { usb_serial_debug_data(debug, &port->dev, __FUNCTION__, actual_length, data); - for (i = 0; i < actual_length ; ++i) { - /* if we insert more than TTY_FLIPBUF_SIZE characters, - we drop them. */ - if(tty->flip.count >= TTY_FLIPBUF_SIZE) { - tty_flip_buffer_push(tty); - } - /* this doesn't actually push the data through unless - tty->low_latency is set */ - tty_insert_flip_char(tty, data[i], 0); - } + tty_buffer_request_room(tty, actual_length); + tty_insert_flip_string(tty, data, actual_length); tty_flip_buffer_push(tty); } } diff --git a/trunk/drivers/usb/serial/generic.c b/trunk/drivers/usb/serial/generic.c index 4ddac620fc0c..476cda107f4f 100644 --- a/trunk/drivers/usb/serial/generic.c +++ b/trunk/drivers/usb/serial/generic.c @@ -254,7 +254,6 @@ void usb_serial_generic_read_bulk_callback (struct urb *urb, struct pt_regs *reg struct usb_serial *serial = port->serial; struct tty_struct *tty; unsigned char *data = urb->transfer_buffer; - int i; int result; dbg("%s - port %d", __FUNCTION__, port->number); @@ -268,14 +267,8 @@ void usb_serial_generic_read_bulk_callback (struct urb *urb, struct pt_regs *reg tty = port->tty; if (tty && urb->actual_length) { - for (i = 0; i < urb->actual_length ; ++i) { - /* if we insert more than TTY_FLIPBUF_SIZE characters, we drop them. */ - if(tty->flip.count >= TTY_FLIPBUF_SIZE) { - tty_flip_buffer_push(tty); - } - /* this doesn't actually push the data through unless tty->low_latency is set */ - tty_insert_flip_char(tty, data[i], 0); - } + tty_buffer_request_room(tty, urb->actual_length); + tty_insert_flip_string(tty, data, urb->actual_length); tty_flip_buffer_push(tty); } diff --git a/trunk/drivers/usb/serial/io_edgeport.c b/trunk/drivers/usb/serial/io_edgeport.c index faedbeb6ba49..3f29e6b0fd19 100644 --- a/trunk/drivers/usb/serial/io_edgeport.c +++ b/trunk/drivers/usb/serial/io_edgeport.c @@ -1965,20 +1965,14 @@ static void edge_tty_recv(struct device *dev, struct tty_struct *tty, unsigned c int cnt; do { - if (tty->flip.count >= TTY_FLIPBUF_SIZE) { - tty_flip_buffer_push(tty); - if (tty->flip.count >= TTY_FLIPBUF_SIZE) { - dev_err(dev, "%s - dropping data, %d bytes lost\n", - __FUNCTION__, length); - return; - } + cnt = tty_buffer_request_room(tty, length); + if (cnt < length) { + dev_err(dev, "%s - dropping data, %d bytes lost\n", + __FUNCTION__, length - cnt); + if(cnt == 0) + break; } - cnt = min(length, TTY_FLIPBUF_SIZE - tty->flip.count); - memcpy(tty->flip.char_buf_ptr, data, cnt); - memset(tty->flip.flag_buf_ptr, 0, cnt); - tty->flip.char_buf_ptr += cnt; - tty->flip.flag_buf_ptr += cnt; - tty->flip.count += cnt; + tty_insert_flip_string(tty, data, cnt); data += cnt; length -= cnt; } while (length > 0); diff --git a/trunk/drivers/usb/serial/io_ti.c b/trunk/drivers/usb/serial/io_ti.c index 2edf9cabad20..afc0f34b3a46 100644 --- a/trunk/drivers/usb/serial/io_ti.c +++ b/trunk/drivers/usb/serial/io_ti.c @@ -1865,20 +1865,14 @@ static void edge_tty_recv(struct device *dev, struct tty_struct *tty, unsigned c int cnt; do { - if (tty->flip.count >= TTY_FLIPBUF_SIZE) { - tty_flip_buffer_push(tty); - if (tty->flip.count >= TTY_FLIPBUF_SIZE) { - dev_err(dev, "%s - dropping data, %d bytes lost\n", - __FUNCTION__, length); - return; - } + cnt = tty_buffer_request_room(tty, length); + if (cnt < length) { + dev_err(dev, "%s - dropping data, %d bytes lost\n", + __FUNCTION__, length - cnt); + if(cnt == 0) + break; } - cnt = min(length, TTY_FLIPBUF_SIZE - tty->flip.count); - memcpy(tty->flip.char_buf_ptr, data, cnt); - memset(tty->flip.flag_buf_ptr, 0, cnt); - tty->flip.char_buf_ptr += cnt; - tty->flip.flag_buf_ptr += cnt; - tty->flip.count += cnt; + tty_insert_flip_string(tty, data, cnt); data += cnt; length -= cnt; } while (length > 0); diff --git a/trunk/drivers/usb/serial/ipaq.c b/trunk/drivers/usb/serial/ipaq.c index 06d07cea0b70..9a5c97989562 100644 --- a/trunk/drivers/usb/serial/ipaq.c +++ b/trunk/drivers/usb/serial/ipaq.c @@ -711,7 +711,7 @@ static void ipaq_read_bulk_callback(struct urb *urb, struct pt_regs *regs) struct usb_serial_port *port = (struct usb_serial_port *)urb->context; struct tty_struct *tty; unsigned char *data = urb->transfer_buffer; - int i, result; + int result; dbg("%s - port %d", __FUNCTION__, port->number); @@ -724,14 +724,8 @@ static void ipaq_read_bulk_callback(struct urb *urb, struct pt_regs *regs) tty = port->tty; if (tty && urb->actual_length) { - for (i = 0; i < urb->actual_length ; ++i) { - /* if we insert more than TTY_FLIPBUF_SIZE characters, we drop them. */ - if(tty->flip.count >= TTY_FLIPBUF_SIZE) { - tty_flip_buffer_push(tty); - } - /* this doesn't actually push the data through unless tty->low_latency is set */ - tty_insert_flip_char(tty, data[i], 0); - } + tty_buffer_request_room(tty, urb->actual_length); + tty_insert_flip_string(tty, data, urb->actual_length); tty_flip_buffer_push(tty); bytes_in += urb->actual_length; } diff --git a/trunk/drivers/usb/serial/ipw.c b/trunk/drivers/usb/serial/ipw.c index 2dd191f5fe76..e760a70242c1 100644 --- a/trunk/drivers/usb/serial/ipw.c +++ b/trunk/drivers/usb/serial/ipw.c @@ -166,7 +166,6 @@ static void ipw_read_bulk_callback(struct urb *urb, struct pt_regs *regs) struct usb_serial_port *port = urb->context; unsigned char *data = urb->transfer_buffer; struct tty_struct *tty; - int i; int result; dbg("%s - port %d", __FUNCTION__, port->number); @@ -180,14 +179,8 @@ static void ipw_read_bulk_callback(struct urb *urb, struct pt_regs *regs) tty = port->tty; if (tty && urb->actual_length) { - for (i = 0; i < urb->actual_length ; ++i) { - /* if we insert more than TTY_FLIPBUF_SIZE characters, we drop them. */ - if(tty->flip.count >= TTY_FLIPBUF_SIZE) { - tty_flip_buffer_push(tty); - } - /* this doesn't actually push the data through unless tty->low_latency is set */ - tty_insert_flip_char(tty, data[i], 0); - } + tty_buffer_request_room(tty, urb->actual_length); + tty_insert_flip_string(tty, data, urb->actual_length); tty_flip_buffer_push(tty); } diff --git a/trunk/drivers/usb/serial/kl5kusb105.c b/trunk/drivers/usb/serial/kl5kusb105.c index 4e2f7dfb58b2..78335a5f7743 100644 --- a/trunk/drivers/usb/serial/kl5kusb105.c +++ b/trunk/drivers/usb/serial/kl5kusb105.c @@ -648,7 +648,6 @@ static void klsi_105_read_bulk_callback (struct urb *urb, struct pt_regs *regs) usb_serial_debug_data(debug, &port->dev, __FUNCTION__, urb->actual_length, data); } else { - int i; int bytes_sent = ((__u8 *) data)[0] + ((unsigned int) ((__u8 *) data)[1] << 8); tty = port->tty; @@ -669,16 +668,8 @@ static void klsi_105_read_bulk_callback (struct urb *urb, struct pt_regs *regs) bytes_sent = urb->actual_length - 2; } - for (i = 2; i < 2+bytes_sent; i++) { - /* if we insert more than TTY_FLIPBUF_SIZE characters, - * we drop them. */ - if(tty->flip.count >= TTY_FLIPBUF_SIZE) { - tty_flip_buffer_push(tty); - } - /* this doesn't actually push the data through unless - * tty->low_latency is set */ - tty_insert_flip_char(tty, ((__u8*) data)[i], 0); - } + tty_buffer_request_room(tty, bytes_sent); + tty_insert_flip_string(tty, data + 2, bytes_sent); tty_flip_buffer_push(tty); /* again lockless, but debug info only */ diff --git a/trunk/drivers/usb/serial/kobil_sct.c b/trunk/drivers/usb/serial/kobil_sct.c index d9c21e275130..b8b213185d0f 100644 --- a/trunk/drivers/usb/serial/kobil_sct.c +++ b/trunk/drivers/usb/serial/kobil_sct.c @@ -365,7 +365,6 @@ static void kobil_close (struct usb_serial_port *port, struct file *filp) static void kobil_read_int_callback( struct urb *purb, struct pt_regs *regs) { - int i; int result; struct usb_serial_port *port = (struct usb_serial_port *) purb->context; struct tty_struct *tty; @@ -397,14 +396,8 @@ static void kobil_read_int_callback( struct urb *purb, struct pt_regs *regs) */ // END DEBUG - for (i = 0; i < purb->actual_length; ++i) { - // if we insert more than TTY_FLIPBUF_SIZE characters, we drop them. - if(tty->flip.count >= TTY_FLIPBUF_SIZE) { - tty_flip_buffer_push(tty); - } - // this doesn't actually push the data through unless tty->low_latency is set - tty_insert_flip_char(tty, data[i], 0); - } + tty_buffer_request_room(tty, purb->actual_length); + tty_insert_flip_string(tty, data, purb->actual_length); tty_flip_buffer_push(tty); } diff --git a/trunk/drivers/usb/serial/option.c b/trunk/drivers/usb/serial/option.c index 3fd2405304fd..52bdf6fe46f2 100644 --- a/trunk/drivers/usb/serial/option.c +++ b/trunk/drivers/usb/serial/option.c @@ -321,7 +321,7 @@ static int option_write(struct usb_serial_port *port, static void option_indat_callback(struct urb *urb, struct pt_regs *regs) { - int i, err; + int err; int endpoint; struct usb_serial_port *port; struct tty_struct *tty; @@ -338,11 +338,8 @@ static void option_indat_callback(struct urb *urb, struct pt_regs *regs) } else { tty = port->tty; if (urb->actual_length) { - for (i = 0; i < urb->actual_length ; ++i) { - if (tty->flip.count >= TTY_FLIPBUF_SIZE) - tty_flip_buffer_push(tty); - tty_insert_flip_char(tty, data[i], 0); - } + tty_buffer_request_room(tty, urb->actual_length); + tty_insert_flip_string(tty, data, urb->actual_length); tty_flip_buffer_push(tty); } else { dbg("%s: empty read urb received", __FUNCTION__); diff --git a/trunk/drivers/usb/serial/pl2303.c b/trunk/drivers/usb/serial/pl2303.c index f03721056190..9ffff1938239 100644 --- a/trunk/drivers/usb/serial/pl2303.c +++ b/trunk/drivers/usb/serial/pl2303.c @@ -924,16 +924,12 @@ static void pl2303_read_bulk_callback (struct urb *urb, struct pt_regs *regs) tty = port->tty; if (tty && urb->actual_length) { + tty_buffer_request_room(tty, urb->actual_length + 1); /* overrun is special, not associated with a char */ if (status & UART_OVERRUN_ERROR) tty_insert_flip_char(tty, 0, TTY_OVERRUN); - - for (i = 0; i < urb->actual_length; ++i) { - if (tty->flip.count >= TTY_FLIPBUF_SIZE) { - tty_flip_buffer_push(tty); - } + for (i = 0; i < urb->actual_length; ++i) tty_insert_flip_char (tty, data[i], tty_flag); - } tty_flip_buffer_push (tty); } diff --git a/trunk/drivers/usb/serial/ti_usb_3410_5052.c b/trunk/drivers/usb/serial/ti_usb_3410_5052.c index abb830cb77bd..c18db3257073 100644 --- a/trunk/drivers/usb/serial/ti_usb_3410_5052.c +++ b/trunk/drivers/usb/serial/ti_usb_3410_5052.c @@ -1280,24 +1280,18 @@ static void ti_recv(struct device *dev, struct tty_struct *tty, int cnt; do { - if (tty->flip.count >= TTY_FLIPBUF_SIZE) { - tty_flip_buffer_push(tty); - if (tty->flip.count >= TTY_FLIPBUF_SIZE) { - dev_err(dev, "%s - dropping data, %d bytes lost\n", __FUNCTION__, length); - return; - } + cnt = tty_buffer_request_room(tty, length); + if (cnt < length) { + dev_err(dev, "%s - dropping data, %d bytes lost\n", __FUNCTION__, length - cnt); + if(cnt == 0) + break; } - cnt = min(length, TTY_FLIPBUF_SIZE - tty->flip.count); - memcpy(tty->flip.char_buf_ptr, data, cnt); - memset(tty->flip.flag_buf_ptr, 0, cnt); - tty->flip.char_buf_ptr += cnt; - tty->flip.flag_buf_ptr += cnt; - tty->flip.count += cnt; + tty_insert_flip_string(tty, data, cnt); + tty_flip_buffer_push(tty); data += cnt; length -= cnt; } while (length > 0); - tty_flip_buffer_push(tty); } diff --git a/trunk/drivers/usb/serial/visor.c b/trunk/drivers/usb/serial/visor.c index 49b1fbe61f25..bce3d55affd8 100644 --- a/trunk/drivers/usb/serial/visor.c +++ b/trunk/drivers/usb/serial/visor.c @@ -488,7 +488,6 @@ static void visor_read_bulk_callback (struct urb *urb, struct pt_regs *regs) unsigned char *data = urb->transfer_buffer; struct tty_struct *tty; unsigned long flags; - int i; int throttled; int result; @@ -503,14 +502,8 @@ static void visor_read_bulk_callback (struct urb *urb, struct pt_regs *regs) tty = port->tty; if (tty && urb->actual_length) { - for (i = 0; i < urb->actual_length ; ++i) { - /* if we insert more than TTY_FLIPBUF_SIZE characters, we drop them. */ - if(tty->flip.count >= TTY_FLIPBUF_SIZE) { - tty_flip_buffer_push(tty); - } - /* this doesn't actually push the data through unless tty->low_latency is set */ - tty_insert_flip_char(tty, data[i], 0); - } + tty_buffer_request_room(tty, urb->actual_length); + tty_insert_flip_string(tty, data, urb->actual_length); tty_flip_buffer_push(tty); } spin_lock_irqsave(&priv->lock, flags); diff --git a/trunk/drivers/usb/serial/whiteheat.c b/trunk/drivers/usb/serial/whiteheat.c index a7c3c4734d83..557411c6e7c7 100644 --- a/trunk/drivers/usb/serial/whiteheat.c +++ b/trunk/drivers/usb/serial/whiteheat.c @@ -1434,7 +1434,9 @@ static void rx_data_softint(void *private) urb = wrap->urb; if (tty && urb->actual_length) { - if (urb->actual_length > TTY_FLIPBUF_SIZE - tty->flip.count) { + int len = tty_buffer_request_room(tty, urb->actual_length); + /* This stuff can go away now I suspect */ + if (unlikely(len < urb->actual_length)) { spin_lock_irqsave(&info->lock, flags); list_add(tmp, &info->rx_urb_q); spin_unlock_irqrestore(&info->lock, flags); @@ -1442,11 +1444,8 @@ static void rx_data_softint(void *private) schedule_work(&info->rx_work); return; } - - memcpy(tty->flip.char_buf_ptr, urb->transfer_buffer, urb->actual_length); - tty->flip.char_buf_ptr += urb->actual_length; - tty->flip.count += urb->actual_length; - sent += urb->actual_length; + tty_insert_flip_string(tty, urb->transfer_buffer, len); + sent += len; } urb->dev = port->serial->dev; diff --git a/trunk/drivers/video/Kconfig b/trunk/drivers/video/Kconfig index 3f04427c9026..3e153d313bb0 100644 --- a/trunk/drivers/video/Kconfig +++ b/trunk/drivers/video/Kconfig @@ -993,12 +993,6 @@ config FB_ATY_GENERIC_LCD Say Y if you have a laptop with an ATI Rage LT PRO, Rage Mobility, Rage XC, or Rage XL chipset. -config FB_ATY_XL_INIT - bool "Rage XL No-BIOS Init support" - depends on FB_ATY_CT - help - Say Y here to support booting a Rage XL without BIOS support. - config FB_ATY_GX bool "Mach64 GX support" if PCI depends on FB_ATY @@ -1376,7 +1370,7 @@ config FB_PXA This driver is also available as a module ( = code which can be inserted and removed from the running kernel whenever you want). The - module will be called vfb. If you want to compile it as a module, + module will be called pxafb. If you want to compile it as a module, say M here and read . If unsure, say N. @@ -1409,7 +1403,7 @@ config FB_W100 This driver is also available as a module ( = code which can be inserted and removed from the running kernel whenever you want). The - module will be called vfb. If you want to compile it as a module, + module will be called w100fb. If you want to compile it as a module, say M here and read . If unsure, say N. diff --git a/trunk/drivers/video/arcfb.c b/trunk/drivers/video/arcfb.c index 2784f0a9d693..89060b2db8e5 100644 --- a/trunk/drivers/video/arcfb.c +++ b/trunk/drivers/video/arcfb.c @@ -366,7 +366,8 @@ static void arcfb_lcd_update(struct arcfb_par *par, unsigned int dx, } } -void arcfb_fillrect(struct fb_info *info, const struct fb_fillrect *rect) +static void arcfb_fillrect(struct fb_info *info, + const struct fb_fillrect *rect) { struct arcfb_par *par = info->par; @@ -376,7 +377,8 @@ void arcfb_fillrect(struct fb_info *info, const struct fb_fillrect *rect) arcfb_lcd_update(par, rect->dx, rect->dy, rect->width, rect->height); } -void arcfb_copyarea(struct fb_info *info, const struct fb_copyarea *area) +static void arcfb_copyarea(struct fb_info *info, + const struct fb_copyarea *area) { struct arcfb_par *par = info->par; @@ -386,7 +388,7 @@ void arcfb_copyarea(struct fb_info *info, const struct fb_copyarea *area) arcfb_lcd_update(par, area->dx, area->dy, area->width, area->height); } -void arcfb_imageblit(struct fb_info *info, const struct fb_image *image) +static void arcfb_imageblit(struct fb_info *info, const struct fb_image *image) { struct arcfb_par *par = info->par; diff --git a/trunk/drivers/video/asiliantfb.c b/trunk/drivers/video/asiliantfb.c index c64de59398f4..69f75547865d 100644 --- a/trunk/drivers/video/asiliantfb.c +++ b/trunk/drivers/video/asiliantfb.c @@ -549,7 +549,7 @@ asiliantfb_pci_init(struct pci_dev *dp, const struct pci_device_id *ent) if (!request_mem_region(addr, size, "asiliantfb")) return -EBUSY; - p = framebuffer_alloc(sizeof(u32) * 256, &dp->dev); + p = framebuffer_alloc(sizeof(u32) * 16, &dp->dev); if (!p) { release_mem_region(addr, size); return -ENOMEM; diff --git a/trunk/drivers/video/aty/Makefile b/trunk/drivers/video/aty/Makefile index 9dec96249ffb..18521397a6e3 100644 --- a/trunk/drivers/video/aty/Makefile +++ b/trunk/drivers/video/aty/Makefile @@ -5,7 +5,6 @@ obj-$(CONFIG_FB_RADEON) += radeonfb.o atyfb-y := atyfb_base.o mach64_accel.o mach64_cursor.o atyfb-$(CONFIG_FB_ATY_GX) += mach64_gx.o atyfb-$(CONFIG_FB_ATY_CT) += mach64_ct.o -atyfb-$(CONFIG_FB_ATY_XL_INIT) += xlinit.o atyfb-objs := $(atyfb-y) diff --git a/trunk/drivers/video/aty/atyfb.h b/trunk/drivers/video/aty/atyfb.h index 09de173c1164..e9b7a64c1ac4 100644 --- a/trunk/drivers/video/aty/atyfb.h +++ b/trunk/drivers/video/aty/atyfb.h @@ -50,6 +50,7 @@ struct pll_info { int sclk, mclk, mclk_pm, xclk; int ref_div; int ref_clk; + int ecp_max; }; typedef struct { @@ -354,6 +355,5 @@ static inline void wait_for_idle(struct atyfb_par *par) extern void aty_reset_engine(const struct atyfb_par *par); extern void aty_init_engine(struct atyfb_par *par, struct fb_info *info); -extern int atyfb_xl_init(struct fb_info *info); extern void aty_st_pll_ct(int offset, u8 val, const struct atyfb_par *par); extern u8 aty_ld_pll_ct(int offset, const struct atyfb_par *par); diff --git a/trunk/drivers/video/aty/atyfb_base.c b/trunk/drivers/video/aty/atyfb_base.c index 3fefdb0cbf07..e370125e4fbc 100644 --- a/trunk/drivers/video/aty/atyfb_base.c +++ b/trunk/drivers/video/aty/atyfb_base.c @@ -109,9 +109,18 @@ #define GUI_RESERVE (1 * PAGE_SIZE) /* FIXME: remove the FAIL definition */ -#define FAIL(msg) do { printk(KERN_CRIT "atyfb: " msg "\n"); return -EINVAL; } while (0) -#define FAIL_MAX(msg, x, _max_) do { if(x > _max_) { printk(KERN_CRIT "atyfb: " msg " %x(%x)\n", x, _max_); return -EINVAL; } } while (0) - +#define FAIL(msg) do { \ + if (!(var->activate & FB_ACTIVATE_TEST)) \ + printk(KERN_CRIT "atyfb: " msg "\n"); \ + return -EINVAL; \ +} while (0) +#define FAIL_MAX(msg, x, _max_) do { \ + if (x > _max_) { \ + if (!(var->activate & FB_ACTIVATE_TEST)) \ + printk(KERN_CRIT "atyfb: " msg " %x(%x)\n", x, _max_); \ + return -EINVAL; \ + } \ +} while (0) #ifdef DEBUG #define DPRINTK(fmt, args...) printk(KERN_DEBUG "atyfb: " fmt, ## args) #else @@ -340,6 +349,7 @@ static unsigned long phys_guiregbase[FB_MAX] __initdata = { 0, }; #define ATI_CHIP_264VT3 (M64F_VT | M64F_INTEGRATED | M64F_VT_BUS | M64F_GTB_DSP | M64F_SDRAM_MAGIC_PLL) #define ATI_CHIP_264VT4 (M64F_VT | M64F_INTEGRATED | M64F_GTB_DSP) +/* FIXME what is this chip? */ #define ATI_CHIP_264LT (M64F_GT | M64F_INTEGRATED | M64F_GTB_DSP) /* make sets shorter */ @@ -359,58 +369,60 @@ static unsigned long phys_guiregbase[FB_MAX] __initdata = { 0, }; static struct { u16 pci_id; const char *name; - int pll, mclk, xclk; + int pll, mclk, xclk, ecp_max; u32 features; } aty_chips[] __devinitdata = { #ifdef CONFIG_FB_ATY_GX /* Mach64 GX */ - { PCI_CHIP_MACH64GX, "ATI888GX00 (Mach64 GX)", 135, 50, 50, ATI_CHIP_88800GX }, - { PCI_CHIP_MACH64CX, "ATI888CX00 (Mach64 CX)", 135, 50, 50, ATI_CHIP_88800CX }, + { PCI_CHIP_MACH64GX, "ATI888GX00 (Mach64 GX)", 135, 50, 50, 0, ATI_CHIP_88800GX }, + { PCI_CHIP_MACH64CX, "ATI888CX00 (Mach64 CX)", 135, 50, 50, 0, ATI_CHIP_88800CX }, #endif /* CONFIG_FB_ATY_GX */ #ifdef CONFIG_FB_ATY_CT - { PCI_CHIP_MACH64CT, "ATI264CT (Mach64 CT)", 135, 60, 60, ATI_CHIP_264CT }, - { PCI_CHIP_MACH64ET, "ATI264ET (Mach64 ET)", 135, 60, 60, ATI_CHIP_264ET }, - { PCI_CHIP_MACH64VT, "ATI264VT? (Mach64 VT)", 170, 67, 67, ATI_CHIP_264VT }, - { PCI_CHIP_MACH64GT, "3D RAGE (Mach64 GT)", 135, 63, 63, ATI_CHIP_264GT }, - /* FIXME { ...ATI_264GU, maybe ATI_CHIP_264GTDVD }, */ - { PCI_CHIP_MACH64GU, "3D RAGE II+ (Mach64 GTB)", 200, 67, 67, ATI_CHIP_264GTB }, - { PCI_CHIP_MACH64VU, "ATI264VTB (Mach64 VU)", 200, 67, 67, ATI_CHIP_264VT3 }, - - { PCI_CHIP_MACH64LT, "3D RAGE LT (Mach64 LT)", 135, 63, 63, ATI_CHIP_264LT }, - /* FIXME chipset maybe ATI_CHIP_264LTPRO ? */ - { PCI_CHIP_MACH64LG, "3D RAGE LT-G (Mach64 LG)", 230, 63, 63, ATI_CHIP_264LTG | M64F_LT_LCD_REGS | M64F_G3_PB_1024x768 }, - - { PCI_CHIP_MACH64VV, "ATI264VT4 (Mach64 VV)", 230, 83, 83, ATI_CHIP_264VT4 }, - - { PCI_CHIP_MACH64GV, "3D RAGE IIC (Mach64 GV, PCI)", 230, 83, 83, ATI_CHIP_264GT2C }, - { PCI_CHIP_MACH64GW, "3D RAGE IIC (Mach64 GW, AGP)", 230, 83, 83, ATI_CHIP_264GT2C }, - { PCI_CHIP_MACH64GY, "3D RAGE IIC (Mach64 GY, PCI)", 230, 83, 83, ATI_CHIP_264GT2C }, - { PCI_CHIP_MACH64GZ, "3D RAGE IIC (Mach64 GZ, AGP)", 230, 83, 83, ATI_CHIP_264GT2C }, - - { PCI_CHIP_MACH64GB, "3D RAGE PRO (Mach64 GB, BGA, AGP)", 230, 100, 100, ATI_CHIP_264GTPRO }, - { PCI_CHIP_MACH64GD, "3D RAGE PRO (Mach64 GD, BGA, AGP 1x)", 230, 100, 100, ATI_CHIP_264GTPRO }, - { PCI_CHIP_MACH64GI, "3D RAGE PRO (Mach64 GI, BGA, PCI)", 230, 100, 100, ATI_CHIP_264GTPRO | M64F_MAGIC_VRAM_SIZE }, - { PCI_CHIP_MACH64GP, "3D RAGE PRO (Mach64 GP, PQFP, PCI)", 230, 100, 100, ATI_CHIP_264GTPRO }, - { PCI_CHIP_MACH64GQ, "3D RAGE PRO (Mach64 GQ, PQFP, PCI, limited 3D)", 230, 100, 100, ATI_CHIP_264GTPRO }, - - { PCI_CHIP_MACH64LB, "3D RAGE LT PRO (Mach64 LB, AGP)", 236, 75, 100, ATI_CHIP_264LTPRO }, - { PCI_CHIP_MACH64LD, "3D RAGE LT PRO (Mach64 LD, AGP)", 230, 100, 100, ATI_CHIP_264LTPRO }, - { PCI_CHIP_MACH64LI, "3D RAGE LT PRO (Mach64 LI, PCI)", 230, 100, 100, ATI_CHIP_264LTPRO | M64F_G3_PB_1_1 | M64F_G3_PB_1024x768 }, - { PCI_CHIP_MACH64LP, "3D RAGE LT PRO (Mach64 LP, PCI)", 230, 100, 100, ATI_CHIP_264LTPRO }, - { PCI_CHIP_MACH64LQ, "3D RAGE LT PRO (Mach64 LQ, PCI)", 230, 100, 100, ATI_CHIP_264LTPRO }, - - { PCI_CHIP_MACH64GM, "3D RAGE XL (Mach64 GM, AGP)", 230, 83, 63, ATI_CHIP_264XL }, - { PCI_CHIP_MACH64GN, "3D RAGE XL (Mach64 GN, AGP)", 230, 83, 63, ATI_CHIP_264XL }, - { PCI_CHIP_MACH64GO, "3D RAGE XL (Mach64 GO, PCI-66/BGA)", 230, 83, 63, ATI_CHIP_264XL }, - { PCI_CHIP_MACH64GR, "3D RAGE XL (Mach64 GR, PCI-33MHz)", 235, 83, 63, ATI_CHIP_264XL | M64F_SDRAM_MAGIC_PLL }, - { PCI_CHIP_MACH64GL, "3D RAGE XL (Mach64 GL, PCI)", 230, 83, 63, ATI_CHIP_264XL }, - { PCI_CHIP_MACH64GS, "3D RAGE XL (Mach64 GS, PCI)", 230, 83, 63, ATI_CHIP_264XL }, - - { PCI_CHIP_MACH64LM, "3D RAGE Mobility P/M (Mach64 LM, AGP 2x)", 230, 83, 125, ATI_CHIP_MOBILITY }, - { PCI_CHIP_MACH64LN, "3D RAGE Mobility L (Mach64 LN, AGP 2x)", 230, 83, 125, ATI_CHIP_MOBILITY }, - { PCI_CHIP_MACH64LR, "3D RAGE Mobility P/M (Mach64 LR, PCI)", 230, 83, 125, ATI_CHIP_MOBILITY }, - { PCI_CHIP_MACH64LS, "3D RAGE Mobility L (Mach64 LS, PCI)", 230, 83, 125, ATI_CHIP_MOBILITY }, + { PCI_CHIP_MACH64CT, "ATI264CT (Mach64 CT)", 135, 60, 60, 0, ATI_CHIP_264CT }, + { PCI_CHIP_MACH64ET, "ATI264ET (Mach64 ET)", 135, 60, 60, 0, ATI_CHIP_264ET }, + + /* FIXME what is this chip? */ + { PCI_CHIP_MACH64LT, "ATI264LT (Mach64 LT)", 135, 63, 63, 0, ATI_CHIP_264LT }, + + { PCI_CHIP_MACH64VT, "ATI264VT (Mach64 VT)", 170, 67, 67, 80, ATI_CHIP_264VT }, + { PCI_CHIP_MACH64GT, "3D RAGE (Mach64 GT)", 135, 63, 63, 80, ATI_CHIP_264GT }, + + { PCI_CHIP_MACH64VU, "ATI264VT3 (Mach64 VU)", 200, 67, 67, 80, ATI_CHIP_264VT3 }, + { PCI_CHIP_MACH64GU, "3D RAGE II+ (Mach64 GU)", 200, 67, 67, 100, ATI_CHIP_264GTB }, + + { PCI_CHIP_MACH64LG, "3D RAGE LT (Mach64 LG)", 230, 63, 63, 100, ATI_CHIP_264LTG | M64F_LT_LCD_REGS | M64F_G3_PB_1024x768 }, + + { PCI_CHIP_MACH64VV, "ATI264VT4 (Mach64 VV)", 230, 83, 83, 100, ATI_CHIP_264VT4 }, + + { PCI_CHIP_MACH64GV, "3D RAGE IIC (Mach64 GV, PCI)", 230, 83, 83, 100, ATI_CHIP_264GT2C }, + { PCI_CHIP_MACH64GW, "3D RAGE IIC (Mach64 GW, AGP)", 230, 83, 83, 100, ATI_CHIP_264GT2C }, + { PCI_CHIP_MACH64GY, "3D RAGE IIC (Mach64 GY, PCI)", 230, 83, 83, 100, ATI_CHIP_264GT2C }, + { PCI_CHIP_MACH64GZ, "3D RAGE IIC (Mach64 GZ, AGP)", 230, 83, 83, 100, ATI_CHIP_264GT2C }, + + { PCI_CHIP_MACH64GB, "3D RAGE PRO (Mach64 GB, BGA, AGP)", 230, 100, 100, 125, ATI_CHIP_264GTPRO }, + { PCI_CHIP_MACH64GD, "3D RAGE PRO (Mach64 GD, BGA, AGP 1x)", 230, 100, 100, 125, ATI_CHIP_264GTPRO }, + { PCI_CHIP_MACH64GI, "3D RAGE PRO (Mach64 GI, BGA, PCI)", 230, 100, 100, 125, ATI_CHIP_264GTPRO | M64F_MAGIC_VRAM_SIZE }, + { PCI_CHIP_MACH64GP, "3D RAGE PRO (Mach64 GP, PQFP, PCI)", 230, 100, 100, 125, ATI_CHIP_264GTPRO }, + { PCI_CHIP_MACH64GQ, "3D RAGE PRO (Mach64 GQ, PQFP, PCI, limited 3D)", 230, 100, 100, 125, ATI_CHIP_264GTPRO }, + + { PCI_CHIP_MACH64LB, "3D RAGE LT PRO (Mach64 LB, AGP)", 236, 75, 100, 135, ATI_CHIP_264LTPRO }, + { PCI_CHIP_MACH64LD, "3D RAGE LT PRO (Mach64 LD, AGP)", 230, 100, 100, 135, ATI_CHIP_264LTPRO }, + { PCI_CHIP_MACH64LI, "3D RAGE LT PRO (Mach64 LI, PCI)", 230, 100, 100, 135, ATI_CHIP_264LTPRO | M64F_G3_PB_1_1 | M64F_G3_PB_1024x768 }, + { PCI_CHIP_MACH64LP, "3D RAGE LT PRO (Mach64 LP, PCI)", 230, 100, 100, 135, ATI_CHIP_264LTPRO }, + { PCI_CHIP_MACH64LQ, "3D RAGE LT PRO (Mach64 LQ, PCI)", 230, 100, 100, 135, ATI_CHIP_264LTPRO }, + + { PCI_CHIP_MACH64GM, "3D RAGE XL (Mach64 GM, AGP 2x)", 230, 83, 63, 135, ATI_CHIP_264XL }, + { PCI_CHIP_MACH64GN, "3D RAGE XC (Mach64 GN, AGP 2x)", 230, 83, 63, 135, ATI_CHIP_264XL }, + { PCI_CHIP_MACH64GO, "3D RAGE XL (Mach64 GO, PCI-66)", 230, 83, 63, 135, ATI_CHIP_264XL }, + { PCI_CHIP_MACH64GL, "3D RAGE XC (Mach64 GL, PCI-66)", 230, 83, 63, 135, ATI_CHIP_264XL }, + { PCI_CHIP_MACH64GR, "3D RAGE XL (Mach64 GR, PCI-33)", 230, 83, 63, 135, ATI_CHIP_264XL | M64F_SDRAM_MAGIC_PLL }, + { PCI_CHIP_MACH64GS, "3D RAGE XC (Mach64 GS, PCI-33)", 230, 83, 63, 135, ATI_CHIP_264XL }, + + { PCI_CHIP_MACH64LM, "3D RAGE Mobility P/M (Mach64 LM, AGP 2x)", 230, 83, 125, 135, ATI_CHIP_MOBILITY }, + { PCI_CHIP_MACH64LN, "3D RAGE Mobility L (Mach64 LN, AGP 2x)", 230, 83, 125, 135, ATI_CHIP_MOBILITY }, + { PCI_CHIP_MACH64LR, "3D RAGE Mobility P/M (Mach64 LR, PCI)", 230, 83, 125, 135, ATI_CHIP_MOBILITY }, + { PCI_CHIP_MACH64LS, "3D RAGE Mobility L (Mach64 LS, PCI)", 230, 83, 125, 135, ATI_CHIP_MOBILITY }, #endif /* CONFIG_FB_ATY_CT */ }; @@ -431,6 +443,7 @@ static int __devinit correct_chipset(struct atyfb_par *par) par->pll_limits.pll_max = aty_chips[i].pll; par->pll_limits.mclk = aty_chips[i].mclk; par->pll_limits.xclk = aty_chips[i].xclk; + par->pll_limits.ecp_max = aty_chips[i].ecp_max; par->features = aty_chips[i].features; chip_id = aty_ld_le32(CONFIG_CHIP_ID, par); @@ -450,39 +463,63 @@ static int __devinit correct_chipset(struct atyfb_par *par) #endif #ifdef CONFIG_FB_ATY_CT case PCI_CHIP_MACH64VT: - rev &= 0xc7; - if(rev == 0x00) { - name = "ATI264VTA3 (Mach64 VT)"; - par->pll_limits.pll_max = 170; - par->pll_limits.mclk = 67; - par->pll_limits.xclk = 67; - par->features = ATI_CHIP_264VT; - } else if(rev == 0x40) { - name = "ATI264VTA4 (Mach64 VT)"; + switch (rev & 0x07) { + case 0x00: + switch (rev & 0xc0) { + case 0x00: + name = "ATI264VT (A3) (Mach64 VT)"; + par->pll_limits.pll_max = 170; + par->pll_limits.mclk = 67; + par->pll_limits.xclk = 67; + par->pll_limits.ecp_max = 80; + par->features = ATI_CHIP_264VT; + break; + case 0x40: + name = "ATI264VT2 (A4) (Mach64 VT)"; + par->pll_limits.pll_max = 200; + par->pll_limits.mclk = 67; + par->pll_limits.xclk = 67; + par->pll_limits.ecp_max = 80; + par->features = ATI_CHIP_264VT | M64F_MAGIC_POSTDIV; + break; + } + break; + case 0x01: + name = "ATI264VT3 (B1) (Mach64 VT)"; par->pll_limits.pll_max = 200; par->pll_limits.mclk = 67; par->pll_limits.xclk = 67; - par->features = ATI_CHIP_264VT | M64F_MAGIC_POSTDIV; - } else { - name = "ATI264VTB (Mach64 VT)"; + par->pll_limits.ecp_max = 80; + par->features = ATI_CHIP_264VTB; + break; + case 0x02: + name = "ATI264VT3 (B2) (Mach64 VT)"; par->pll_limits.pll_max = 200; par->pll_limits.mclk = 67; par->pll_limits.xclk = 67; - par->features = ATI_CHIP_264VTB; + par->pll_limits.ecp_max = 80; + par->features = ATI_CHIP_264VT3; + break; } break; case PCI_CHIP_MACH64GT: - rev &= 0x07; - if(rev == 0x01) { + switch (rev & 0x07) { + case 0x01: + name = "3D RAGE II (Mach64 GT)"; par->pll_limits.pll_max = 170; par->pll_limits.mclk = 67; par->pll_limits.xclk = 67; + par->pll_limits.ecp_max = 80; par->features = ATI_CHIP_264GTB; - } else if(rev == 0x02) { + break; + case 0x02: + name = "3D RAGE II+ (Mach64 GT)"; par->pll_limits.pll_max = 200; par->pll_limits.mclk = 67; par->pll_limits.xclk = 67; + par->pll_limits.ecp_max = 100; par->features = ATI_CHIP_264GTB; + break; } break; #endif @@ -692,7 +729,7 @@ static void aty_set_crtc(const struct atyfb_par *par, const struct crtc *crtc) aty_st_lcd(LCD_GEN_CNTL, (crtc->lcd_gen_cntl & ~CRTC_RW_SELECT) | (SHADOW_EN | SHADOW_RW_EN), par); - DPRINTK("set secondary CRT to %ix%i %c%c\n", + DPRINTK("set shadow CRT to %ix%i %c%c\n", ((((crtc->shadow_h_tot_disp>>16) & 0xff) + 1)<<3), (((crtc->shadow_v_tot_disp>>16) & 0x7ff) + 1), (crtc->shadow_h_sync_strt_wid & 0x200000)?'N':'P', (crtc->shadow_v_sync_strt_wid & 0x200000)?'N':'P'); @@ -840,11 +877,14 @@ static int aty_var_to_crtc(const struct fb_info *info, know if one is connected. So it's better to fail then. */ if (crtc->lcd_gen_cntl & CRT_ON) { - PRINTKI("Disable lcd panel, because video mode does not fit.\n"); + if (!(var->activate & FB_ACTIVATE_TEST)) + PRINTKI("Disable LCD panel, because video mode does not fit.\n"); crtc->lcd_gen_cntl &= ~LCD_ON; /*aty_st_lcd(LCD_GEN_CNTL, crtc->lcd_gen_cntl, par);*/ } else { - FAIL("Video mode exceeds size of lcd panel.\nConnect this computer to a conventional monitor if you really need this mode."); + if (!(var->activate & FB_ACTIVATE_TEST)) + PRINTKE("Video mode exceeds size of LCD panel.\nConnect this computer to a conventional monitor if you really need this mode.\n"); + return -EINVAL; } } } @@ -858,9 +898,9 @@ static int aty_var_to_crtc(const struct fb_info *info, vmode &= ~(FB_VMODE_DOUBLE | FB_VMODE_INTERLACED); /* This is horror! When we simulate, say 640x480 on an 800x600 - lcd monitor, the CRTC should be programmed 800x600 values for + LCD monitor, the CRTC should be programmed 800x600 values for the non visible part, but 640x480 for the visible part. - This code has been tested on a laptop with it's 1400x1050 lcd + This code has been tested on a laptop with it's 1400x1050 LCD monitor and a conventional monitor both switched on. Tested modes: 1280x1024, 1152x864, 1024x768, 800x600, works with little glitches also with DOUBLESCAN modes @@ -955,16 +995,6 @@ static int aty_var_to_crtc(const struct fb_info *info, vdisplay = yres; if(vmode & FB_VMODE_DOUBLE) vdisplay <<= 1; - if(vmode & FB_VMODE_INTERLACED) { - vdisplay >>= 1; - - /* The prefered mode for the lcd is not interlaced, so disable it if - it was enabled. For doublescan there is no problem, because we can - compensate for it in the hardware stretching (we stretch half as much) - */ - vmode &= ~FB_VMODE_INTERLACED; - /*crtc->gen_cntl &= ~CRTC_INTERLACE_EN;*/ - } crtc->gen_cntl &= ~(CRTC2_EN | CRTC2_PIX_WIDTH); crtc->lcd_gen_cntl &= ~(HORZ_DIVBY2_EN | DIS_HOR_CRT_DIVBY2 | /*TVCLK_PM_EN | VCLK_DAC_PM_EN |*/ @@ -980,7 +1010,7 @@ static int aty_var_to_crtc(const struct fb_info *info, crtc->horz_stretching &= ~(HORZ_STRETCH_RATIO | HORZ_STRETCH_LOOP | AUTO_HORZ_RATIO | HORZ_STRETCH_MODE | HORZ_STRETCH_EN); - if (xres < par->lcd_width) { + if (xres < par->lcd_width && crtc->lcd_gen_cntl & LCD_ON) { do { /* * The horizontal blender misbehaves when HDisplay is less than a @@ -1042,7 +1072,7 @@ static int aty_var_to_crtc(const struct fb_info *info, } while (0); } - if (vdisplay < par->lcd_height) { + if (vdisplay < par->lcd_height && crtc->lcd_gen_cntl & LCD_ON) { crtc->vert_stretching = (VERT_STRETCH_USE0 | VERT_STRETCH_EN | (((vdisplay * (VERT_STRETCH_RATIO0 + 1)) / par->lcd_height) & VERT_STRETCH_RATIO0)); @@ -1065,9 +1095,8 @@ static int aty_var_to_crtc(const struct fb_info *info, #endif /* CONFIG_FB_ATY_GENERIC_LCD */ if (M64_HAS(MAGIC_FIFO)) { - /* Not VTB/GTB */ - /* FIXME: magic FIFO values */ - crtc->gen_cntl |= (aty_ld_le32(CRTC_GEN_CNTL, par) & CRTC2_PIX_WIDTH); + /* FIXME: display FIFO low watermark values */ + crtc->gen_cntl |= (aty_ld_le32(CRTC_GEN_CNTL, par) & CRTC_FIFO_LWM); } crtc->dp_pix_width = dp_pix_width; crtc->dp_chain_mask = dp_chain_mask; @@ -1184,7 +1213,8 @@ static int aty_crtc_to_var(const struct crtc *crtc, struct fb_var_screeninfo *va var->transp.length = 8; break; default: - FAIL("Invalid pixel width"); + PRINTKE("Invalid pixel width\n"); + return -EINVAL; } /* output */ @@ -1241,7 +1271,8 @@ static int atyfb_set_par(struct fb_info *info) pixclock = atyfb_get_pixclock(var, par); if (pixclock == 0) { - FAIL("Invalid pixclock"); + PRINTKE("Invalid pixclock\n"); + return -EINVAL; } else { if((err = par->pll_ops->var_to_pll(info, pixclock, var->bits_per_pixel, &par->pll))) return err; @@ -1446,7 +1477,9 @@ static int atyfb_check_var(struct fb_var_screeninfo *var, struct fb_info *info) pixclock = atyfb_get_pixclock(var, par); if (pixclock == 0) { - FAIL("Invalid pixclock"); + if (!(var->activate & FB_ACTIVATE_TEST)) + PRINTKE("Invalid pixclock\n"); + return -EINVAL; } else { if((err = par->pll_ops->var_to_pll(info, pixclock, var->bits_per_pixel, &pll))) return err; @@ -2291,10 +2324,6 @@ static int __init aty_init(struct fb_info *info, const char *name) par->dac_ops = &aty_dac_ct; par->pll_ops = &aty_pll_ct; par->bus_type = PCI; -#ifdef CONFIG_FB_ATY_XL_INIT - if (IS_XL(par->pci_id)) - atyfb_xl_init(info); -#endif par->ram_type = (aty_ld_le32(CONFIG_STAT0, par) & 0x07); ramname = aty_ct_ram[par->ram_type]; /* for many chips, the mclk is 67 MHz for SDRAM, 63 MHz otherwise */ @@ -2638,16 +2667,16 @@ static int __init store_video_par(char *video_str, unsigned char m64_num) static int atyfb_blank(int blank, struct fb_info *info) { struct atyfb_par *par = (struct atyfb_par *) info->par; - u8 gen_cntl; + u32 gen_cntl; if (par->lock_blank || par->asleep) return 0; #ifdef CONFIG_PMAC_BACKLIGHT - if ((_machine == _MACH_Pmac) && blank) + if ((_machine == _MACH_Pmac) && blank > FB_BLANK_NORMAL) set_backlight_enable(0); #elif defined(CONFIG_FB_ATY_GENERIC_LCD) - if (par->lcd_table && blank && + if (par->lcd_table && blank > FB_BLANK_NORMAL && (aty_ld_lcd(LCD_GEN_CNTL, par) & LCD_ON)) { u32 pm = aty_ld_lcd(POWER_MANAGEMENT, par); pm &= ~PWR_BLON; @@ -2655,31 +2684,31 @@ static int atyfb_blank(int blank, struct fb_info *info) } #endif - gen_cntl = aty_ld_8(CRTC_GEN_CNTL, par); + gen_cntl = aty_ld_le32(CRTC_GEN_CNTL, par); switch (blank) { case FB_BLANK_UNBLANK: - gen_cntl &= ~(0x4c); + gen_cntl &= ~0x400004c; break; case FB_BLANK_NORMAL: - gen_cntl |= 0x40; + gen_cntl |= 0x4000040; break; case FB_BLANK_VSYNC_SUSPEND: - gen_cntl |= 0x8; + gen_cntl |= 0x4000048; break; case FB_BLANK_HSYNC_SUSPEND: - gen_cntl |= 0x4; + gen_cntl |= 0x4000044; break; case FB_BLANK_POWERDOWN: - gen_cntl |= 0x4c; + gen_cntl |= 0x400004c; break; } - aty_st_8(CRTC_GEN_CNTL, gen_cntl, par); + aty_st_le32(CRTC_GEN_CNTL, gen_cntl, par); #ifdef CONFIG_PMAC_BACKLIGHT - if ((_machine == _MACH_Pmac) && !blank) + if ((_machine == _MACH_Pmac) && blank <= FB_BLANK_NORMAL) set_backlight_enable(1); #elif defined(CONFIG_FB_ATY_GENERIC_LCD) - if (par->lcd_table && !blank && + if (par->lcd_table && blank <= FB_BLANK_NORMAL && (aty_ld_lcd(LCD_GEN_CNTL, par) & LCD_ON)) { u32 pm = aty_ld_lcd(POWER_MANAGEMENT, par); pm |= PWR_BLON; @@ -3157,15 +3186,15 @@ static void aty_init_lcd(struct atyfb_par *par, u32 bios_base) refresh_rates_buf, lcd_refresh_rates[default_refresh_rate]); par->lcd_refreshrate = lcd_refresh_rates[default_refresh_rate]; /* We now need to determine the crtc parameters for the - * lcd monitor. This is tricky, because they are not stored + * LCD monitor. This is tricky, because they are not stored * individually in the BIOS. Instead, the BIOS contains a * table of display modes that work for this monitor. * * The idea is that we search for a mode of the same dimensions - * as the dimensions of the lcd monitor. Say our lcd monitor + * as the dimensions of the LCD monitor. Say our LCD monitor * is 800x600 pixels, we search for a 800x600 monitor. * The CRTC parameters we find here are the ones that we need - * to use to simulate other resolutions on the lcd screen. + * to use to simulate other resolutions on the LCD screen. */ lcdmodeptr = (u16 *)(par->lcd_table + 64); while (*lcdmodeptr != 0) { @@ -3692,9 +3721,7 @@ static int __init atyfb_init(void) atyfb_setup(option); #endif -#ifdef CONFIG_PCI pci_register_driver(&atyfb_driver); -#endif #ifdef CONFIG_ATARI atyfb_atari_probe(); #endif @@ -3703,9 +3730,7 @@ static int __init atyfb_init(void) static void __exit atyfb_exit(void) { -#ifdef CONFIG_PCI pci_unregister_driver(&atyfb_driver); -#endif } module_init(atyfb_init); diff --git a/trunk/drivers/video/aty/mach64_ct.c b/trunk/drivers/video/aty/mach64_ct.c index 9bdb2aab01aa..e7056934c6a8 100644 --- a/trunk/drivers/video/aty/mach64_ct.c +++ b/trunk/drivers/video/aty/mach64_ct.c @@ -206,9 +206,7 @@ static int aty_valid_pll_ct(const struct fb_info *info, u32 vclk_per, struct pll { u32 q; struct atyfb_par *par = (struct atyfb_par *) info->par; -#ifdef DEBUG int pllvclk; -#endif /* FIXME: use the VTB/GTB /{3,6,12} post dividers if they're better suited */ q = par->ref_clk_per * pll->pll_ref_div * 4 / vclk_per; @@ -223,13 +221,26 @@ static int aty_valid_pll_ct(const struct fb_info *info, u32 vclk_per, struct pll pll->vclk_post_div_real = postdividers[pll->vclk_post_div]; // pll->vclk_post_div <<= 6; pll->vclk_fb_div = q * pll->vclk_post_div_real / 8; -#ifdef DEBUG pllvclk = (1000000 * 2 * pll->vclk_fb_div) / (par->ref_clk_per * pll->pll_ref_div); +#ifdef DEBUG printk("atyfb(%s): pllvclk=%d MHz, vclk=%d MHz\n", __FUNCTION__, pllvclk, pllvclk / pll->vclk_post_div_real); #endif pll->pll_vclk_cntl = 0x03; /* VCLK = PLL_VCLK/VCLKx_POST */ + + /* Set ECP (scaler/overlay clock) divider */ + if (par->pll_limits.ecp_max) { + int ecp = pllvclk / pll->vclk_post_div_real; + int ecp_div = 0; + + while (ecp > par->pll_limits.ecp_max && ecp_div < 2) { + ecp >>= 1; + ecp_div++; + } + pll->pll_vclk_cntl |= ecp_div << 4; + } + return 0; } diff --git a/trunk/drivers/video/aty/xlinit.c b/trunk/drivers/video/aty/xlinit.c deleted file mode 100644 index a085cbf74ecb..000000000000 --- a/trunk/drivers/video/aty/xlinit.c +++ /dev/null @@ -1,359 +0,0 @@ -/* - * ATI Rage XL Initialization. Support for Xpert98 and Victoria - * PCI cards. - * - * Copyright (C) 2002 MontaVista Software Inc. - * Author: MontaVista Software, Inc. - * stevel@mvista.com or source@mvista.com - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN - * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 675 Mass Ave, Cambridge, MA 02139, USA. - */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include