diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/CREDITS linux-2.5/CREDITS --- linux-2.5.1/CREDITS Wed Dec 5 21:02:14 2001 +++ linux-2.5/CREDITS Thu Dec 27 16:32:30 2001 @@ -527,6 +527,16 @@ S: Bellevue, Washington 98007 S: USA +N: Christopher L. Cheney +E: ccheney@debian.org +E: ccheney@cheney.cx +W: http://www.cheney.cx +P: 1024D/8E384AF2 2D31 1927 87D7 1F24 9FF9 1BC5 D106 5AB3 8E38 4AF2 +D: Vista Imaging usb webcam driver +S: 314 Prince of Wales +S: Conroe, TX 77304 +S: USA + N: Stuart Cheshire E: cheshire@cs.stanford.edu D: Author of Starmode Radio IP (STRIP) driver @@ -1267,6 +1277,13 @@ D: bug toaster (A1 sauce makes all the difference) D: Random linux hacker +N: Tim Hockin +E: thockin@hockin.org +W: http://www.hockin.org/~thockin +D: Natsemi ethernet +D: Cobalt Networks (x86) support +D: This-and-That + N: Dirk Hohndel E: hohndel@suse.de D: The XFree86[tm] Project @@ -1646,6 +1663,13 @@ S: 80-283 Gdansk S: Poland +N: Jakob Kemi +E: jakob.kemi@telia.com +D: V4L W9966 Webcam driver +S: Forsbyvägen 33 +S: 74143 Knivsta +S: Sweden + N: Gero Kuhlmann E: gero@gkminix.han.de D: mounting root via NFS @@ -2507,7 +2531,7 @@ S: Australia N: Gerard Roudier -E: groudier@iplus.fr +E: groudier@free.fr D: Contributed to asynchronous read-ahead improvement S: 21 Rue Carnot S: 95170 Deuil La Barre diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/Documentation/Changes linux-2.5/Documentation/Changes --- linux-2.5.1/Documentation/Changes Fri Nov 30 16:53:20 2001 +++ linux-2.5/Documentation/Changes Thu Dec 13 16:32:35 2001 @@ -53,7 +53,7 @@ o binutils 2.9.5.0.24 # ld -v o util-linux 2.10o # fdformat --version o modutils 2.4.2 # insmod -V -o e2fsprogs 1.19 # tune2fs +o e2fsprogs 1.25 # tune2fs o reiserfsprogs 3.x.0j # reiserfsck 2>&1|grep reiserfsprogs o pcmcia-cs 3.1.21 # cardmgr -V o PPP 2.4.0 # pppd --version @@ -304,8 +304,7 @@ E2fsprogs --------- -o -o +o Reiserfsprogs ------------- diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/Documentation/Configure.help linux-2.5/Documentation/Configure.help --- linux-2.5.1/Documentation/Configure.help Fri Nov 30 21:25:10 2001 +++ linux-2.5/Documentation/Configure.help Sun Dec 30 21:30:12 2001 @@ -2,7 +2,7 @@ # Eric S. Raymond # Steven Cole # -# Merged version 2.61: current with 2.4.16/2.5.1-pre1. +# Merged version 2.73: current with 2.4.17-rc1/2.5.1-pre11. # # This version of the Linux kernel configuration help texts # corresponds to kernel versions 2.4.x and 2.5.x. @@ -69,7 +69,7 @@ # Explain why someone configuring a kernel might want to select your # option. # -# All this was shamelessly stolen from several different sources. Many +# All this was shamelessly stolen from numerous different sources. Many # thanks to all the contributors. Feel free to use these help texts in # your own kernel configuration tools. The texts are copyrighted (c) # 1995-2000 by Axel Boldt and many others and are governed by the GNU @@ -235,13 +235,13 @@ Multiquad support for NUMA systems CONFIG_MULTIQUAD - This option is used for getting Linux to run on a (IBM/Sequent) NUMA + This option is used for getting Linux to run on a (IBM/Sequent) NUMA multiquad box. This changes the way that processors are bootstrapped, - and uses Clustered Logical APIC addressing mode instead of Flat Logical. - You will need a new lynxer.elf file to flash your firmware with - send - email to Martin.Bligh@us.ibm.com + and uses Clustered Logical APIC addressing mode instead of Flat + Logical. You will need a new lynxer.elf file to flash your firmware + with - send email to . -IO-APIC Support on Uniprocessors +IO-APIC support on uniprocessors CONFIG_X86_UP_IOAPIC An IO-APIC (I/O Advanced Programmable Interrupt Controller) is an SMP-capable replacement for PC-style interrupt controllers. Most @@ -257,11 +257,12 @@ CONFIG_X86_UP_APIC A local APIC (Advanced Programmable Interrupt Controller) is an integrated interrupt controller in the CPU. If you have a single-CPU - system which has a processor with a local APIC, you can say Y here to - enable and use it. If you say Y here even though your machine doesn't - have a local APIC, then the kernel will still run with no slowdown at - all. The local APIC supports CPU-generated self-interrupts (timer, - performance counters), and the NMI watchdog which detects hard lockups. + system which has a processor with a local APIC, you can say Y here + to enable and use it. If you say Y here even though your machine + doesn't have a local APIC, then the kernel will still run with no + slowdown at all. The local APIC supports CPU-generated + self-interrupts (timer, performance counters), and the NMI watchdog + which detects hard lockups. If you have a system with several CPUs, you do not need to say Y here: the local APIC will be used automatically. @@ -280,9 +281,9 @@ be used nevertheless. (This behavior can be changed with the kernel command line option "no387", which comes handy if your coprocessor is broken. Try "man bootparam" or see the documentation of your boot - loader (lilo or loadlin) about how to pass options to the kernel at - boot time.) This means that it is a good idea to say Y here if you - intend to use this kernel on different machines. + loader (grub, lilo or loadlin) about how to pass options to the + kernel at boot time.) This means that it is a good idea to say Y + here if you intend to use this kernel on different machines. More information about the internals of the Linux math coprocessor emulation can be found in . @@ -341,12 +342,12 @@ "high memory". If you are compiling a kernel which will never run on a machine with - more than 1 Gigabyte total physical RAM, answer "off" here (default - choice and suitable for most users). This will result in a "3GB/1GB" - split: 3GB are mapped so that each process sees a 3GB virtual memory - space and the remaining part of the 4GB virtual memory space is used - by the kernel to permanently map as much physical memory as - possible. + more than 960 megabytes of total physical RAM, answer "off" here + (default choice and suitable for most users). This will result in a + "3GB/1GB" split: 3GB are mapped so that each process sees a 3GB + virtual memory space and the remaining part of the 4GB virtual memory + space is used by the kernel to permanently map as much physical memory + as possible. If the machine has between 1 and 4 Gigabytes physical RAM, then answer "4GB" here. @@ -358,10 +359,10 @@ processors (Pentium Pro and better). NOTE: If you say "64GB" here, then the kernel will not boot on CPUs that don't support PAE! - The actual amount of total physical memory will either be - auto detected or can be forced by using a kernel command line option - such as "mem=256M". (Try "man bootparam" or see the documentation of - your boot loader (lilo or loadlin) about how to pass options to the + The actual amount of total physical memory will either be auto + detected or can be forced by using a kernel command line option such + as "mem=256M". (Try "man bootparam" or see the documentation of your + boot loader (grub, lilo or loadlin) about how to pass options to the kernel at boot time.) If unsure, say "off". @@ -376,7 +377,7 @@ Select this if you have a 32-bit processor and more than 4 gigabytes of physical RAM. -Normal PC floppy disk support +Normal floppy disk support CONFIG_BLK_DEV_FD If you want to use the floppy disk drive(s) of your PC under Linux, say Y. Information about this driver, especially important for IBM @@ -390,18 +391,6 @@ The module will be called floppy.o. If you want to compile it as a module, say M here and read . -iSeries Virtual I/O Disk Support -CONFIG_VIODASD - If you are running on an iSeries system and you want to use - virtual disks created and managed by OS/400, say Y. - -iSeries Virtual I/O Disk IDE Emulation -CONFIG_VIODASD_IDE - This causes the iSeries virtual disks to look like IDE disks. - If you have programs or utilities that only support certain - kinds of disks, this option will cause iSeries virtual disks - to pretend to be IDE disks, which may satisfy the program. - Support for PowerMac floppy CONFIG_MAC_FLOPPY If you have a SWIM-3 (Super Woz Integrated Machine 3; from Apple) @@ -839,6 +828,7 @@ If in doubt, say N. +# Currently commented out Attempt to HACK around Chipsets that TIMEOUT (WIP) CONFIG_BLK_DEV_IDEDMA_TIMEOUT If you say Y here, this is a NASTY UGLY HACK! @@ -911,10 +901,6 @@ Please read the comments at the top of . -Pacific Digital A-DMA support (EXPERIMENTAL) -CONFIG_BLK_DEV_PDC_ADMA - Please read the comments at the top of . - 3ware Hardware ATA-RAID support CONFIG_BLK_DEV_3W_XXXX_RAID 3ware is the only hardware ATA-Raid product in Linux to date. @@ -972,7 +958,7 @@ SAY N! -AMD Viper support +AMD Viper (7401/7409/7411) chipset support CONFIG_BLK_DEV_AMD74XX This driver ensures (U)DMA support for the AMD756/760 Viper chipsets. @@ -983,7 +969,7 @@ If unsure, say N. -AMD Viper ATA-66 Override (WIP) +AMD Viper ATA-66 Override support (WIP) CONFIG_AMD74XX_OVERRIDE This option auto-forces the ata66 flag. This effect can be also invoked by calling "idex=ata66" @@ -1092,6 +1078,18 @@ If unsure, say N. +IT8172 IDE support +CONFIG_BLK_DEV_IT8172 + Say Y here to support the on-board IDE controller on the Integrated + Technology Express, Inc. ITE8172 SBC. Vendor page at + ; picture of the + board at . + +IT8172 IDE Tuning support +CONFIG_IT8172_TUNING + Say Y here to support tuning the ITE8172's IDE interface. This makes + it possible to set DMA channel or PIO opration and the transfer rate. + PROMISE PDC20246/PDC20262/PDC20265/PDC20267/PDC20268 support CONFIG_BLK_DEV_PDC202XX Promise Ultra33 or PDC20246 @@ -1285,9 +1283,10 @@ Amiga Buddha/Catweasel/X-Surf IDE interface support (EXPERIMENTAL) CONFIG_BLK_DEV_BUDDHA - This is the IDE driver for the IDE interfaces on the Buddha, - Catweasel and X-Surf expansion boards. It supports up to two interfaces - on the Buddha, three on the Catweasel and two on the X-Surf. + This is the IDE driver for the IDE interfaces on the Buddha, + Catweasel and X-Surf expansion boards. It supports up to two + interfaces on the Buddha, three on the Catweasel and two on the + X-Surf. Say Y if you have a Buddha or Catweasel expansion board and want to use IDE devices (hard disks, CD-ROM drives, etc.) that are connected @@ -1595,7 +1594,7 @@ (low speed) adapter that is used in some portable hard drives. If you chose to build PARIDE support into your kernel, you may answer Y here to build in the protocol driver, otherwise you should answer M - to build it as a loadable module. The module will be called ktti.o. + to build it as a loadable module. The module will be called fit2.o. You must also have a high-level driver for the type of device that you want to support. @@ -1876,20 +1875,6 @@ otherwise choose R3000. -Support for Cobalt Micro Server -CONFIG_COBALT_MICRO_SERVER - Support for MIPS-based Cobalt boxes (they have been bought by Sun - and are now the "Server Appliance Business Unit") including the 2700 - series -- versions 1 of the Qube and Raq. To compile a Linux kernel - for this hardware, say Y here. - -Support for Cobalt 2800 -CONFIG_COBALT_28 - Support for the second generation of MIPS-based Cobalt boxes (they - have been bought by Sun and are now the "Server Appliance Business - Unit") including the 2800 series -- versions 2 of the Qube and Raq. - To compile a Linux kernel for this hardware, say Y here. - Support for the Momentum Computer Ocelot SBC CONFIG_MOMENCO_OCELOT The Ocelot is a MIPS-based Single Board Computer (SBC) made by @@ -1929,14 +1914,6 @@ This enables support for the VR5000-based MIPS Malta evaluation board. -Support for Galileo Evaluation board or CoSine Orion -CONFIG_ORION - Say Y if configuring for the Galileo evaluation board - or CoSine Orion. More information is available at - . - - Otherwise, say N. - Support for Mips Magnum 4000 CONFIG_MIPS_MAGNUM_4000 This is a machine with a R4000 100 MHz CPU. To compile a Linux @@ -1949,6 +1926,27 @@ Images of Qtronix keyboards are at . +Support for older IT8172 (Rev C) +CONFIG_IT8172_REVC + Say Y here to support the older, Revision C version of the Integrated + Technology Express, Inc. ITE8172 SBC. Vendor page at + ; picture of the + board at . + +Enable Smart Card Reader 0 Support +CONFIG_IT8172_SCR0 + Say Y here to support smart-card reader 0 (SCR0) on the Integrated + Technology Express, Inc. ITE8172 SBC. Vendor page at + ; picture of the + board at . + +Enable Smart Card Reader 1 Support +CONFIG_IT8172_SCR1 + Say Y here to support smart-card reader 1 (SCR1) on the Integrated + Technology Express, Inc. ITE8172 SBC. Vendor page at + ; picture of the + board at . + Support for Olivetti M700 CONFIG_OLIVETTI_M700 This is a machine with a R4000 100 MHz CPU. To compile a Linux @@ -1963,13 +1961,13 @@ Technology and now in turn merged with Fujitsu. Say Y here to support this machine type. -Support for SGI IP22 +Support for SGI-IP22 (Indy/Indigo2) CONFIG_SGI_IP22 This are the SGI Indy, Challenge S and Indigo2, as well as certain OEM variants like the Tandem CMN B006S. To compile a Linux kernel that runs on these, say Y here. -Support for SGI IP27 +Support for SGI IP27 (Origin200/2000) CONFIG_SGI_IP27 This are the SGI Origin 200, Origin 2000 and Onyx 2 Graphics workstations. To compile a Linux kernel that runs on these, say Y @@ -2016,6 +2014,13 @@ the way floating point works you should always enable this option unless you exactly know what you're doing. +ARC console support +CONFIG_ARC_CONSOLE + Support for the PROM-based console on MIPS machines built according + to the Advanced Risc Computing specification, which is now (2001) + dead. These included boxes from Deskstation, Acer, Olivetti and + NEC. There is a history at . + SGI PROM Console Support CONFIG_SGI_PROM_CONSOLE Say Y here to set up the boot console on serial port 0. @@ -2025,13 +2030,27 @@ DZ11-family serial controllers for VAXstations, including the DC7085, M7814, and M7819. - TURBOchannel support CONFIG_TC - TurboChannel is a DEC (now Compaq) bus for Alpha and MIPS processors. - Documentation on writing device drivers for TurboChannel is available at: + TurboChannel is a DEC (now Compaq) bus for Alpha and MIPS + processors. Documentation on writing device drivers for + TurboChannel is available at: . +# Choice: galileo_clock +75 +CONFIG_SYSCLK_75 + Configure the kernel for clock speed of your Galileo board. + The choices are 75MHz, 83.3MHz, and 100MHz. + +83.3 +CONFIG_SYSCLK_83 + Configure the Galileo kernel for a clock speed of 83.3 MHz. + +100 +CONFIG_SYSCLK_100 + Configure the Galileo kernel for a clock speed of 100 MHz. + Z85C30 Serial Support CONFIG_ZS Documentation on the Zilog 85C350 serial communications controller @@ -2047,16 +2066,6 @@ kernel: saying N will just cause the configurator to skip all the questions PCMCIA SCSI host adapters. -Adaptec APA1480 CardBus support -CONFIG_PCMCIA_APA1480 - Say Y here if you intend to attach this type of CardBus SCSI host - adapter to your computer. - - This driver is also available as a module called apa1480_cb.o ( = - code which can be inserted in and removed from the running kernel - whenever you want). If you want to compile it as a module, say M - here and read . - NinjaSCSI-3 / NinjaSCSI-32Bi (16bit) PCMCIA support CONFIG_PCMCIA_NINJA_SCSI If you intend to attach this type of PCMCIA SCSI host adapter to @@ -2186,7 +2195,7 @@ Access). This option is for configuring high-end multiprocessor server machines. If in doubt, say N. -CPU type +R41xx CONFIG_CPU_VR41XX The options selects support for the NEC VR41xx series of processors. Only choose this option if you have one of these processors as a @@ -2198,7 +2207,7 @@ Saying yes here allows you to select support for various features your CPU may or may not have. Most people should say N here. -ll/sc Instructions available +ll and sc instructions available CONFIG_CPU_HAS_LLSC MIPS R4000 series and later provide the Load Linked (ll) and Store Conditional (sc) instructions. More information is @@ -2208,7 +2217,7 @@ for better performance, N if you don't know. You must say Y here for multiprocessor machines. -lld and scd instructions +lld and scd instructions available CONFIG_CPU_HAS_LLDSCD Say Y here if your CPU has the lld and scd instructions, the 64-bit equivalents of ll and sc. Say Y here for better performance, N if @@ -2341,7 +2350,7 @@ If you want to compile it as a module, say M here and read . If unsure, say `N'. -IRC Send/Chat support +IRC Send/Chat protocol support CONFIG_IP_NF_IRC There is a commonly-used extension to IRC called Direct Client-to-Client Protocol (DCC). This enables users to send @@ -2425,7 +2434,7 @@ If you want to compile it as a module, say M here and read Documentation/modules.txt. If unsure, say `N'. -length match support +LENGTH match support CONFIG_IP_NF_MATCH_LENGTH This option allows you to match the length of a packet against a specific value or range of values. @@ -2773,14 +2782,6 @@ If unsure, say N. -HCI EMU (virtual device) driver -CONFIG_BLUEZ_HCIEMU - Bluetooth Virtual HCI device driver. - This driver is required if you want to use HCI Emulation software. - - Say Y here to compile support for Virtual HCI devices into the - kernel or say M to compile it as module (hci_usb.o). - # Choice: alphatype Alpha system type CONFIG_ALPHA_GENERIC @@ -2811,8 +2812,10 @@ Noname AXPpci33, UDB (Multia) Noritake AS 1000A, AS 600A, AS 800 PC164 AlphaPC164 + P2K Platform2000 Rawhide AS 1200, AS 4000, AS 4100 Ruffian RPX164-2, AlphaPC164-UX, AlphaPC164-BX + RX164 An obscure EV5-based motherboard SX164 AlphaPC164-SX Sable AS 2000, AS 2100 Shark DS 20L @@ -2938,6 +2941,13 @@ AlphaServer 1000A, AlphaServer 600A, and AlphaServer 800-based systems. +Platform2000 +CONFIG_ALPHA_P2K + The Platform2000 is a modular motherboard that can accept `engine + cards' featuring various processors, including the Alpha. Info + page, with link to picture, at + . + Rawhide CONFIG_ALPHA_RAWHIDE AlphaServer 1200, AlphaServer 4000 and AlphaServer 4100 machines. @@ -2949,6 +2959,11 @@ Samsung APC164UX. There is a page on known problems and workarounds at . +PC164 +CONFIG_ALPHA_PC164 + Digital Alpha PC164. Product brief page from a reseller ast: + + Sable CONFIG_ALPHA_SABLE Digital AlphaServer 2000 and 2100-based systems. @@ -2969,6 +2984,11 @@ CONFIG_ALPHA_GAMMA Say Y if you have an AS 2000 5/xxx or an AS 2100 5/xxx. +EV67 (or later) CPU (speed > 600MHz)? +CONFIG_ALPHA_EV67 + Is this a machine based on the EV67 core? If in doubt, select N here + and the machine will be treated as an EV6. + Use SRM as bootloader CONFIG_ALPHA_SRM There are two different types of booting firmware on Alphas: SRM, @@ -3056,9 +3076,9 @@ Support for serial ports defined by ACPI tables CONFIG_SERIAL_ACPI - Legacy free machines may not have serial ports at the legacy COM1, + Legacy free machines may not have serial ports at the legacy COM1, COM2 etc addresses. Serial ports on such machines are described by - the ACPI tables SPCR (Serial Port Console Redirection) table and + the ACPI tables SPCR (Serial Port Console Redirection) table and DBGP (Debug Port) table. Say Y here if you want to include support for these serial ports. @@ -3132,9 +3152,9 @@ ACP Modem (Mwave) support CONFIG_MWAVE The ACP modem (Mwave) for Linux is a WinModem. It is composed of a - kernel driver and a user level application. Together these components - support direct attachment to public switched telephone networks (PSTNs) - and support selected world wide countries. + kernel driver and a user level application. Together these + components support direct attachment to public switched telephone + networks (PSTNs) and support selected world wide countries. This version of the ACP Modem driver supports the IBM Thinkpad 600E, 600, and 770 that include on board ACP modem hardware. @@ -3182,16 +3202,17 @@ Intel 440LX/BX/GX/815/820/830/840/845/850/860 support CONFIG_AGP_INTEL This option gives you AGP support for the GLX component of the - XFree86 4.x on Intel 440LX/BX/GX, 815, 820, 830, 840, 845, 850 and 860 chipsets. + XFree86 4.x on Intel 440LX/BX/GX, 815, 820, 830, 840, 845, 850 and 860 + chipsets. You should say Y here if you use XFree86 3.3.6 or 4.x and want to use GLX or DRI. If unsure, say N. -Intel I810/I815 DC100/I810e support +Intel I810/I815/I830M (on board) support CONFIG_AGP_I810 This option gives you AGP support for the Xserver on the Intel 810 - 815 and 830m chipset boards for their on-board integrated graphics. This - is required to do any useful video modes with these boards. + 815 and 830m chipset boards for their on-board integrated graphics. + This is required to do any useful video modes with these boards. VIA chipset support CONFIG_AGP_VIA @@ -3222,7 +3243,7 @@ Serverworks LE/HE support CONFIG_AGP_SWORKS - Say Y here to support the Serverworks AGP card. See + Say Y here to support the Serverworks AGP card. See for product descriptions and images. ALI chipset support @@ -3261,18 +3282,6 @@ information about which PCI hardware does work under Linux and which doesn't. -PCI support -CONFIG_PCI_INTEGRATOR - Find out whether you have a PCI motherboard. PCI is the name of a - bus system, i.e. the way the CPU talks to the other stuff inside - your box. Other bus systems are ISA, EISA, MicroChannel (MCA) or - VESA. If you have PCI, say Y, otherwise N. - - The PCI-HOWTO, available from - , contains valuable - information about which PCI hardware does work under Linux and which - doesn't. - QSpan PCI CONFIG_PCI_QSPAN Find out whether you have a PCI motherboard. PCI is the name of a @@ -3314,7 +3323,7 @@ When in doubt, say Y. -PCI Hotplug support +Generic PCI hotplug support CONFIG_HOTPLUG_PCI Say Y here if you have a motherboard with a PCI Hotplug controller. This allows you to add and remove PCI cards while the machine is @@ -3328,7 +3337,7 @@ When in doubt, say N. -PCI Compaq Hotplug controller +Compaq PCI Hotplug driver CONFIG_HOTPLUG_PCI_COMPAQ Say Y here if you have a motherboard with a Compaq PCI Hotplug controller. @@ -3340,7 +3349,7 @@ When in doubt, say N. -PCI Compaq Hotplug controller NVRAM support +Save configuration into NVRAM on Compaq servers CONFIG_HOTPLUG_PCI_COMPAQ_NVRAM Say Y here if you have a Compaq server that has a PCI Hotplug controller. This will allow the PCI Hotplug driver to store the PCI @@ -3563,9 +3572,9 @@ i82092 compatible bridge support CONFIG_I82092 - This provides support for the Intel I82092AA PCI-to-PCMCIA bridge device, - found in some older laptops and more commonly in evaluation boards for the - chip. + This provides support for the Intel I82092AA PCI-to-PCMCIA bridge + device, found in some older laptops and more commonly in evaluation + boards for the chip. i82365 compatible host bridge support CONFIG_I82365 @@ -3645,8 +3654,7 @@ don't understand what this means or are not a kernel hacker, just leave it at its default value ELF. -# Choice: kcore -Select a.out format for /proc/kcore +a.out CONFIG_KCORE_AOUT Not necessary unless you're using a very out-of-date binutils version. You probably want KCORE_ELF. @@ -3692,13 +3700,13 @@ warrant removing support. However its removal is a good idea if you wish to ensure that absolutely none of your programs will use this older executable format. If you don't know what to answer at this - point then answer Y. If someone told you "You need a kernel with - QMAGIC support" then you'll have to say Y here. You may answer M to - compile a.out support as a module and later load the module when you - want to use a program or library in a.out format. The module will be - called binfmt_aout.o. Saying M or N here is dangerous though, - because some crucial programs on your system might still be in A.OUT - format. + point then answer Y. If someone told you you will need a kernel with + support for the QMAGIC executable format, then you will have to say + Y here. You may answer M to compile a.out support as a module and + later load the module when you want to use a program or library in + a.out format. The module will be called binfmt_aout.o. Saying M or N + here is dangerous though, because some crucial programs on your + system might still be in A.OUT format. Kernel support for Linux/Intel ELF binaries CONFIG_BINFMT_EM86 @@ -3768,7 +3776,7 @@ The module will be called envctrl.o. If you want to compile it as a module, say M here and read . -# Choice: x86 +# Choice: x86type Processor family CONFIG_M386 This is the processor type of your CPU. This information is used for @@ -3786,7 +3794,7 @@ will run on a 386 class machine. - "486" for the AMD/Cyrix/IBM/Intel 486DX/DX2/DX4 or SL/SLC/SLC2/SLC3/SX/SX2 and UMC U5D or U5S. - - "586" for generic Pentium CPUs, possibly lacking the TSC + - "586" for generic Pentium CPUs lacking the TSC (time stamp counter) register. - "Pentium-Classic" for the Intel Pentium. - "Pentium-MMX" for the Intel Pentium MMX. @@ -3815,23 +3823,80 @@ CONFIG_M586 Select this for an x586 or x686 processor such as the AMD K5, the Intel 5x86 or 6x86, or the Intel 6x86MX. This choice does not - assume the RDTSC instruction. + assume the RDTSC (Read Time Stamp Counter) instruction. Pentium Classic CONFIG_M586TSC Select this for a Pentium Classic processor with the RDTSC (Read Time Stamp Counter) instruction for benchmarking. -32-bit PDC -CONFIG_PDC_NARROW - Saying Y here will allow developers with a C180, C200, C240, C360, - J200, J210, and/or a J2240 to test 64-bit kernels by providing a - wrapper for the 32-bit PDC calls. Since the machines which require - this option do not support over 4G of RAM, this option is targeted - for developers of these machines wishing to test changes on both - 32-bit and 64-bit configurations. - - If unsure, say N. +Pentium MMX +CONFIG_M586MMX + Select this for a Pentium with the MMX graphics/multimedia + extended instructions. + +Pentium Pro/Celeron/Pentium II +CONFIG_M686 + Select this for a Pro/Celeron/Pentium II. This enables the use of + Pentium Pro extended instructions, and disables the init-time guard + against the f00f bug found in earlier Pentiums. + +Pentium-III/Celeron-Coppermine +CONFIG_MPENTIUMIII + Select this for Intel chips based on the Pentium-III and + Celeron-Coppermine core. Enables use of some extended prefetch + instructions, in addition to the Pentium II extensions. + +Pentium-4 +CONFIG_MPENTIUM4 + Select this for Intel Pentium 4 chips. Presently these are + treated almost like Pentium IIIs, but with a different cache + shift. + +Crusoe +CONFIG_MCRUSOE + Select this for Transmeta Crusoe processor. Treats the processor + like a 586 with TSC, and sets some GCC optimization flags (like a + Pentium Pro with no alignment requirements). + +K6/K6-II/K6-III +CONFIG_MK6 + Select this for an AMD K6-family processor. Enables use of + some extended instructions, and passes appropriate optimization + flags to GCC. + +Athlon/Duron/K7 +CONFIG_MK7 + Select this for an AMD Athlon K7-family processor. Enables use of + some extended instructions, and passes appropriate optimization + flags to GCC. + +CyrixIII/C3 +CONFIG_MCYRIXIII + Select this for a Cyrix III or C3 chip. Presently Linux and GCC + treat this chip as a generic 586. Whilst the CPU is 686 class, + it lacks the cmov extension which gcc assumes is present when + generating 686 code. + +Winchip-C6 +CONFIG_MWINCHIPC6 + Select this for a IDT Winchip C6 chip. Linux and GCC + treat this chip as a 586TSC with some extended instructions + and alignment requirements. + +Winchip-2 +CONFIG_MWINCHIP2 + Select this for a IDT Winchip-2. Linux and GCC + treat this chip as a 586TSC with some extended instructions + and alignment requirements. + +Winchip-2A/Winchip-3 +CONFIG_MWINCHIP3D + Select this for a IDT Winchip-2A or 3. Linux and GCC + treat this chip as a 586TSC with some extended instructions + and alignment reqirements. Development kernels also enable + out of order memory stores for this CPU, which can increase + performance of some operations. VGA text console CONFIG_VGA_CONSOLE @@ -4077,7 +4142,8 @@ CONFIG_FB_MAXINE Say Y here to directly support the on-board framebuffer in the Maxine (5000/20, /25, /33) version of the DECstation. There is a - page dedicated to Linux on DECstations at . + page dedicated to Linux on DECstations at + . PMAG-BA TURBOchannel framebuffer support CONFIG_FB_PMAG_BA @@ -4098,8 +4164,9 @@ ANAKIN Vehicle Telematics Platform CONFIG_ARCH_ANAKIN - The Anakin is a StrongArm based SA110 - 2 DIN Vehicle Telematics Platform. - 64MB SDRAM - 4 Mb Flash - Compact Flash Interface - 1 MB VRAM + The Anakin is a StrongArm based SA110 - 2 DIN Vehicle Telematics + Platform. 64MB SDRAM - 4 Mb Flash - Compact Flash Interface - 1 MB + VRAM On board peripherals: * Front display: 400x234 16 bit TFT touchscreen @@ -4123,11 +4190,6 @@ If you would like to build your kernel to run on one of these boards then you must say 'Y' here. Otherwise say 'N' -Link-Up Systems LCD support -CONFIG_FB_L7200 - This driver supports the L7200 Color LCD. - Say Y if you want graphics support. - PowerMac "control" frame buffer device support CONFIG_FB_CONTROL This driver supports a frame buffer for the graphics adapter in the @@ -4461,10 +4523,10 @@ 3Dfx Voodoo Graphics / Voodoo2 frame buffer support CONFIG_FB_VOODOO1 - Say Y here if you have a 3Dfx Voodoo Graphics (Voodoo1/sst1) or + Say Y here if you have a 3Dfx Voodoo Graphics (Voodoo1/sst1) or Voodoo2 (cvg) based graphics card. - This driver is also available as a module ( = code which can be + 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 sstfb.o. If you want to compile it as a module, say M here and read Documentation/modules.txt. @@ -4541,7 +4603,7 @@ This is the frame buffer device driver for the Hitachi HD64461 LCD frame buffer card. -SIS 630/540 display support +SIS acceleration CONFIG_FB_SIS This is the frame buffer device driver for the SiS 630 and 640 Super Socket 7 UMA cards. Specs available at . @@ -4587,16 +4649,6 @@ framebuffer device. The ATI product support page for these boards is at . -Sony Vaio Picturebook laptop LCD panel support -CONFIG_FB_ATY_CT_VAIO_LCD - Say Y here if you want to use the full width of the Sony Vaio - Picturebook laptops LCD panels (you will get a 128x30 console). - - Note that you need to activate this mode using the 'vga=0x301' - option from your boot loader (lilo or loadlin). See the - documentation of your boot loader about how to pass options to the - kernel. - Mach64 GX support CONFIG_FB_ATY_GX Say Y here to support use of the ATI Mach64 Graphics Expression @@ -4764,7 +4816,7 @@ If unsure, say Y. -Parallel+serial PCI card support +Parallel+serial PCI multi-IO card support CONFIG_PARPORT_SERIAL This adds support for multi-IO PCI cards that have parallel and serial ports. You should say Y or M here. If you say M, the module @@ -5189,6 +5241,7 @@ It is safe to say N here for now. +# 2.5 tree only IPv6: routing messages via old netlink CONFIG_IPV6_NETLINK You can say Y here to receive routing messages from the IPv6 code @@ -5459,8 +5512,9 @@ Amateur Radio support CONFIG_HAMRADIO If you want to connect your Linux box to an amateur radio, answer Y - here. You want to read and - the AX25-HOWTO, available from . + here. You want to read + and the AX25-HOWTO, available from + . Note that the answer to this question won't directly affect the kernel: saying N will just cause the configurator to skip all @@ -5505,6 +5559,7 @@ configuration. (Linux cannot yet act as a DAMA server.) If unsure, say N. +# Currently commented out AX.25 DAMA Master support CONFIG_AX25_DAMA_MASTER DAMA is a mechanism to prevent collisions when doing AX.25 @@ -5949,6 +6004,7 @@ If unsure, say N. +# 2.5 tree only Kernel/User network link driver CONFIG_NETLINK This driver allows for two-way communication between the kernel and @@ -5967,6 +6023,7 @@ If unsure, say Y. +# 2.5 tree only Routing messages CONFIG_RTNETLINK If you say Y here, user space programs can receive some network @@ -6280,6 +6337,13 @@ speed of the driver, and the size of your syslog files! When inactive, they will have only a modest impact on performance. +Efficient Networks Speedstream 3010 +CONFIG_ATM_LANAI + Supports ATM cards based on the Efficient Networks "Lanai" + chipset such as the Speedstream 3010 and the ENI-25p. The + Speedstream 3060 is currently not supported since we don't + have the code to drive the on-board Alcatel DSL chipset (yet). + Linux telephony support CONFIG_PHONE Say Y here if you have a telephony card, which for example allows @@ -6318,6 +6382,12 @@ If you do not have any Quicknet telephony cards, you can safely say N here. +QuickNet Internet LineJack/PhoneJack PCMCIA support +CONFIG_PHONE_IXJ_PCMCIA + Say Y here to configure in PCMCIA service support for the Quicknet + cards manufactured by Quicknet Technologies, Inc. This changes the + card initialization code to work with the card manager daemon. + FORE Systems 200E-series CONFIG_ATM_FORE200E_MAYBE This is a driver for the FORE Systems 200E-series ATM adapter @@ -6398,6 +6468,13 @@ the performances of the driver, and the size of your syslog files! Keep the debugging level to 0 during normal operations. +PPP over ATM +CONFIG_PPPOATM + Support PPP (Point to Point Protocol) encapsulated in ATM frames. + This implementation does not yet comply with section 8 of RFC2364, + which can lead to bad results idf the ATM peer loses state and + changes its encapsulation unilaterally. + Fusion MPT device support CONFIG_FUSION LSI Logic Fusion(TM) Message Passing Technology (MPT) device support @@ -6452,24 +6529,24 @@ returns a SCSI check condition on a I/O. Without this module loaded you might see: - SCSI Error Report =-=-= (ioc0,scsi5:0) - SCSI_Status=02h (CHECK_CONDITION) - Original_CDB[]: 2A 00 00 00 00 41 00 00 02 00 - SenseData[12h]: 70 00 02 00 00 00 00 0A 00 00 00 00 04 02 02 00 00 00 - SenseKey=2h (NOT READY); FRU=02h - ASC/ASCQ=29h/00h + SCSI Error Report =-=-= (ioc0,scsi5:0) + SCSI_Status=02h (CHECK_CONDITION) + Original_CDB[]: 2A 00 00 00 00 41 00 00 02 00 + SenseData[12h]: 70 00 02 00 00 00 00 0A 00 00 00 00 04 02 02 00 00 00 + SenseKey=2h (NOT READY); FRU=02h + ASC/ASCQ=29h/00h Where otherwise, if this module had been loaded, you would see: - SCSI Error Report =-=-= (ioc0,scsi5:0) - SCSI_Status=02h (CHECK_CONDITION) - Original_CDB[]: 2A 00 00 00 00 41 00 00 02 00 - "WRITE(10)" - SenseData[12h]: 70 00 02 00 00 00 00 0A 00 00 00 00 04 02 02 00 00 00 - SenseKey=2h (NOT READY); FRU=02h - ASC/ASCQ=29h/00h "LOGICAL UNIT NOT READY, INITIALIZING CMD. REQUIRED" + SCSI Error Report =-=-= (ioc0,scsi5:0) + SCSI_Status=02h (CHECK_CONDITION) + Original_CDB[]: 2A 00 00 00 00 41 00 00 02 00 - "WRITE(10)" + SenseData[12h]: 70 00 02 00 00 00 00 0A 00 00 00 00 04 02 02 00 00 00 + SenseKey=2h (NOT READY); FRU=02h + ASC/ASCQ=29h/00h "LOGICAL UNIT NOT READY, INITIALIZING CMD. REQUIRED" - Say M for "Enhanced SCSI error reporting" to compile this optional module, - creating a driver named: isense.o. + Say M for "Enhanced SCSI error reporting" to compile this optional + module, creating a driver named: isense.o. NOTE: Support for building this feature into the kernel is not available, due to kernel size considerations. @@ -6668,8 +6745,8 @@ If you want to compile this as a module ( = code which can be inserted in and removed from the running kernel whenever you want), say M here and read and - . The module will be called sg.o. If unsure, - say N. + . The module will be called sg.o. If + unsure, say N. Probe all LUNs on each SCSI device CONFIG_SCSI_MULTI_LUN @@ -6784,9 +6861,9 @@ intended to replace the previous aic7xxx driver maintained by Doug Ledford since Doug is no longer maintaining that driver. -Adaptec I2O RAID controllers +Adaptec I2O RAID support CONFIG_SCSI_DPT_I2O - This driver supports all of Adaptec's I2O based RAID controllers as + This driver supports all of Adaptec's I2O based RAID controllers as well as the DPT SmartRaid V cards. This is an Adaptec maintained driver by Deanna Bonds. See . @@ -6944,7 +7021,7 @@ See for more information. If this driver does not work correctly without modification please contact the author by email at - ipslinux@us.ibm.com. + . You can build this driver as a module ( = code which can be inserted in and removed from the running kernel whenever you want), @@ -6960,7 +7037,8 @@ and for more information. If this driver does not work correctly without modification, please contact - the author, Leonard N. Zubkoff, by email to lnz@dandelion.com. + the author, Leonard N. Zubkoff, by email to + . You can also build this driver as a module ( = code which can be inserted in and removed from the running kernel whenever you want), @@ -7137,7 +7215,7 @@ Unless you have an NCR manufactured machine, the chances are that you do not have this SCSI card, so say N. -HP LASI SCSI support for 53c700 +HP LASI SCSI support for 53c700/710 CONFIG_SCSI_LASI700 This is a driver for the lasi baseboard in some parisc machines which is based on the 53c700 chip. Will also support LASI subsystems @@ -7193,10 +7271,10 @@ SYM53C8XX Version 2 SCSI support CONFIG_SCSI_SYM53C8XX_2 - This driver supports the whole NCR53C8XX/SYM53C8XX family of - PCI-SCSI controllers. It also supports the subset of LSI53C10XX - Ultra-160 controllers that are based on the SYM53C8XX SCRIPTS - language. It does not support LSI53C10XX Ultra-320 PCI-X SCSI + This driver supports the whole NCR53C8XX/SYM53C8XX family of + PCI-SCSI controllers. It also supports the subset of LSI53C10XX + Ultra-160 controllers that are based on the SYM53C8XX SCRIPTS + language. It does not support LSI53C10XX Ultra-320 PCI-X SCSI controllers. If your system has problems using this new major version of the @@ -7207,32 +7285,32 @@ PCI DMA addressing mode CONFIG_SCSI_SYM53C8XX_DMA_ADDRESSING_MODE - This option only applies to PCI-SCSI chip that are PCI DAC capable + This option only applies to PCI-SCSI chip that are PCI DAC capable (875A, 895A, 896, 1010-33, 1010-66, 1000). When set to 0, only PCI 32 bit DMA addressing (SAC) will be performed. - When set to 1, 40 bit DMA addressing (with upper 24 bits of address + When set to 1, 40 bit DMA addressing (with upper 24 bits of address set to zero) is supported. The addressable range is here 1 TB. When set to 2, full 64 bits of address for DMA are supported, but only - 16 segments of 4 GB can be addressed. The addressable range is so + 16 segments of 4 GB can be addressed. The addressable range is so limited to 64 GB. - The safest value is 0 (32 bit DMA addressing) that is guessed to still + The safest value is 0 (32 bit DMA addressing) that is guessed to still fit most of real machines. - The preferred value 1 (40 bit DMA addressing) should make happy + The preferred value 1 (40 bit DMA addressing) should make happy properly engineered PCI DAC capable host bridges. You may configure this option for Intel platforms with more than 4 GB of memory. - The still experimental value 2 (64 bit DMA addressing with 16 x 4GB - segments limitation) can be used on systems that require PCI address - bits past bit 39 to be set for the addressing of memory using PCI + The still experimental value 2 (64 bit DMA addressing with 16 x 4GB + segments limitation) can be used on systems that require PCI address + bits past bit 39 to be set for the addressing of memory using PCI DAC cycles. use normal IO CONFIG_SCSI_SYM53C8XX_IOMAPPED - If you say Y here, the driver will preferently use normal IO rather than - memory mapped IO. + If you say Y here, the driver will preferently use normal IO rather + than memory mapped IO. maximum number of queued commands CONFIG_SCSI_SYM53C8XX_MAX_TAGS @@ -7243,10 +7321,11 @@ default tagged command queue depth CONFIG_SCSI_SYM53C8XX_DEFAULT_TAGS - This is the default value of the command queue depth the driver will - announce to the generic SCSI layer for devices that support tagged - command queueing. This value can be changed from the boot command line. - This is a soft limit that cannot exceed CONFIG_SCSI_SYM53C8XX_MAX_TAGS. + This is the default value of the command queue depth the driver will + announce to the generic SCSI layer for devices that support tagged + command queueing. This value can be changed from the boot command + line. This is a soft limit that cannot exceed + CONFIG_SCSI_SYM53C8XX_MAX_TAGS. NCR53C8XX SCSI support CONFIG_SCSI_NCR53C8XX @@ -7629,6 +7708,12 @@ The module will be called qla1280.o. If you want to compile it as a module, say M here and read . +Include loadable firmware in driver +CONFIG_SCSI_QLOGIC_FC_FIRMWARE + Say Y to include ISP2100 Fabric Initiator/Target Firmware, with + expanded LUN addressing and FcTape (FCP-2) support, in the + Qlogic QLA 1280 driver. + Seagate ST-02 and Future Domain TMC-8xx SCSI support CONFIG_SCSI_SEAGATE These are 8-bit SCSI controllers; the ST-01 is also supported by @@ -7849,11 +7934,11 @@ say M here and read . The module will be called megaraid.o. -Intel/ICP (former GDT SCSI Disk Array) RAID Controller Support +Intel/ICP (former GDT SCSI Disk Array) RAID Controller support CONFIG_SCSI_GDTH Formerly called GDT SCSI Disk Array Controller Support. - - This is a driver for RAID/SCSI Disk Array Controllers (EISA/ISA/PCI) + + This is a driver for RAID/SCSI Disk Array Controllers (EISA/ISA/PCI) manufactured by Intel/ICP vortex (an Intel Company). It is documented in the kernel source in and @@ -8128,18 +8213,7 @@ If unsure, say N. -#Adaptec AIC-5800 IEEE 1394 support -#CONFIG_IEEE1394_AIC5800 -# Say Y here if you have a IEEE 1394 controller using the Adaptec -# AIC-5800 chip. All Adaptec host adapters (89xx series) use this -# chip, as well as miro's DV boards. -# -# If you want to compile this as a module ( = code which can be -# inserted in and removed from the running kernel whenever you want), -# say M here and read . The module -# will be called aic5800.o. -# -OHCI-1394 support +OHCI-1394 (Open Host Controller Interface) support CONFIG_IEEE1394_OHCI1394 Enable this driver if you have an IEEE 1394 controller based on the OHCI-1394 specification. The current driver is only tested with OHCI @@ -8523,7 +8597,7 @@ Aironet 4500/4800 series adapters CONFIG_AIRONET4500 www.aironet.com (recently bought by Cisco) makes these 802.11 DS - adapters. Driver by Elmer Joandi (elmer@ylenurme.ee). + adapters. Driver by Elmer Joandi (). Say Y here if you have such an adapter, and then say Y below to the option that applies to your particular type of card (PCI, ISA, @@ -8701,6 +8775,19 @@ a module, say M here and read . If unsure, say N. +Asix AX88190 PCMCIA support +CONFIG_PCMCIA_AXNET + Say Y here if you intend to attach an Asix AX88190-based PCMCIA + (PC-card) Fast Ethernet card to your computer. These cards are + nearly NE2000 compatible but need a separate driver due to a few + misfeatures. + + This driver is also available as a module ( = code which can be + inserted in and removed from the running kernel whenever you want). + The module will be called axnet_cs.o. If you want to compile it as + a module, say M here and read . If + unsure, say N. + New Media PCMCIA support CONFIG_PCMCIA_NMCLAN Say Y here if you intend to attach a New Media Ethernet or LiveWire @@ -8756,7 +8843,7 @@ The module will be called ibmtr_cs.o. If you want to compile it as a module, say M here and read . -Xircom Tulip-like CardBus support +Xircom Tulip-like CardBus support (old driver) CONFIG_PCMCIA_XIRTULIP This driver is for the Digital "Tulip" Ethernet CardBus adapters. It should work with most DEC 21*4*-based chips/ethercards, as well @@ -8769,6 +8856,19 @@ it as a module, say M here and read . If unsure, say N. +Xircom CardBus support (new driver) +CONFIG_PCMCIA_XIRCOM + This driver is for the Digital "Tulip" Ethernet CardBus adapters. + It should work with most DEC 21*4*-based chips/ethercards, as well + as with work-alike chips from Lite-On (PNIC) and Macronix (MXIC) and + ASIX. + + This driver is also available as a module ( = code which can be + inserted in and removed from the running kernel whenever you want). + The module will be called xircom_tulip_cb.o. If you want to compile + it as a module, say M here and read + . If unsure, say N. + PCMCIA Wireless LAN CONFIG_NET_PCMCIA_RADIO Say Y here if you would like to use a PCMCIA (PC-card) device to @@ -8794,27 +8894,27 @@ This option includes the guts of the driver, but in order to actually use a card you will also need to enable support for PCMCIA - Hermes cards, PLX9052 based PCI adaptors or the Apple Airport below. + Hermes cards, PLX9052 based PCI adapters or the Apple Airport below. You will also very likely also need the Wireless Tools in order to configure your card and that /etc/pcmcia/wireless.opts works : -Hermes 802.11b in PLX9052 based PCI adaptor support +Hermes in PLX9052 based PCI adapter support (Netgear MA301 etc.) CONFIG_PLX_HERMES Enable support for PCMCIA cards supported by the "Hermes" (aka - orinoco_cs) driver when used in PLX9052 based PCI adaptors. These - adaptors are not a full PCMCIA controller but act as a more limited - PCI <-> PCMCIA bridge. Several vendors sell such adaptors so that + orinoco_cs) driver when used in PLX9052 based PCI adapters. These + adapters are not a full PCMCIA controller but act as a more limited + PCI <-> PCMCIA bridge. Several vendors sell such adapters so that 802.11b PCMCIA cards can be used in desktop machines. The Netgear - MA301 is such an adaptor. + MA301 is such an adapter. - Support for these adaptors is so far still incomplete and buggy. + Support for these adapters is so far still incomplete and buggy. You have been warned. Hermes support (Orinoco/WavelanIEEE/PrismII/Symbol 802.11b cards) CONFIG_PCMCIA_HERMES - A driver for "Hermes" chipset based PCMCIA wireless adaptors, such + A driver for "Hermes" chipset based PCMCIA wireless adapters, such as the Lucent WavelanIEEE/Orinoco cards and their OEM (Cabletron/ EnteraSys RoamAbout 802.11, ELSA Airlancer, Melco Buffalo and others). It should also be usable on various Prism II based cards @@ -8881,7 +8981,7 @@ CONFIG_APPLE_AIRPORT Say Y here to support the Airport 802.11b wireless Ethernet hardware built into the Macintosh iBook and other recent PowerPC-based - Macintosh machines. This is essentially a Lucent Orinoco card with + Macintosh machines. This is essentially a Lucent Orinoco card with a non-standard interface Xircom Netwave AirSurfer wireless support @@ -9027,7 +9127,7 @@ of the Cisco HDLC/PPP driver (syncppp.c). The SyncLink WAN driver (in character devices) must also be enabled. -FarSync T-Series support +FarSync T-Series X.21 (and V.35/V.24) cards CONFIG_FARSYNC This driver supports the FarSync T-Series X.21 (and V.35/V.24) cards from FarSite Communications Ltd. @@ -9174,6 +9274,13 @@ However, do not say Y here if you did not experience any serious problems. +802.1Q VLAN Support +CONFIG_VLAN_8021Q + Support Ben Greear's VLAN (Virtual LAN) option code, which multiplexes + any number of logical Ethernets over a single physical Ethernet link + according to the 902.1Q standard. There is a website on the Linux + implementation at . + QoS and/or fair queueing CONFIG_NET_SCHED When the kernel has several packets to send out over a network @@ -9512,8 +9619,8 @@ up. Look at the for more information about the cards (including the pointer to the user-space utilities). You can also read the comment at the top of the - for details about the cards and the driver - itself. + for details about the cards and the + driver itself. The driver will be compiled as a module ( = code which can be inserted in and removed from the running kernel whenever you want). @@ -9565,13 +9672,13 @@ intended to replace SCSI. If you intend to use Fibre Channel, you need to have a Fibre channel - adaptor card in your computer; say Y here and to the driver for your - adaptor below. You also should have said Y to "SCSI support" and + adapter card in your computer; say Y here and to the driver for your + adapter below. You also should have said Y to "SCSI support" and "SCSI generic support". -Interphase 5526 Tachyon chipset based adaptor support +Interphase 5526 Tachyon chipset based adapter support CONFIG_IPHASE5526 - Say Y here if you have a Fibre Channel adaptor of this kind. + Say Y here if you have a Fibre Channel adapter of this kind. The driver is also available as a module ( = code which can be inserted in and removed from the running kernel whenever you want). @@ -9597,11 +9704,11 @@ You can find more information and last versions of drivers and utilities at . If you have any question you - can send email to sbni@granch.ru. + can send email to . Say N if unsure. -SBNI Adapters Multiline feature +SBNI multiple-line feature support CONFIG_SBNI_MULTILINE Schedule traffic for some parallel lines, via SBNI12 adapters. If you have two computers connected with two parallel lines it's @@ -9716,7 +9823,7 @@ Read for help on configuring and using COMX interfaces. Further info on these cards - can be found at or . + can be found at or . You must say Y to "/proc file system support" (CONFIG_PROC_FS) to use this driver. @@ -9826,9 +9933,10 @@ ). Feel free to contact me or the cycsyn-devel mailing list at - acme@conectiva.com.br and cycsyn-devel@bazar.conectiva.com.br for - additional details, I hope to have documentation available as soon - as possible. (Cyclades Brazil is writing the Documentation). + and + for additional details, + I hope to have documentation available as soon as + possible. (Cyclades Brazil is writing the Documentation). The driver will be compiled as a module ( = code which can be inserted in and removed from the running kernel whenever you want). @@ -9854,34 +9962,6 @@ If unsure, say N here. -Raw HDLC support -CONFIG_HDLC_RAW - Say Y to this option if you want generic HDLC driver to support - raw HDLC over WAN (Wide Area Network) connections. - - If unsure, say N here. - -Cisco HDLC support -CONFIG_HDLC_CISCO - Say Y to this option if you want generic HDLC driver to support - Cisco HDLC over WAN (Wide Area Network) connections. - - If unsure, say N here. - -Frame-Relay HDLC support -CONFIG_HDLC_FR - Say Y to this option if you want generic HDLC driver to support - Frame-Relay protocol over WAN (Wide Area Network) connections. - - If unsure, say N here. - -Frame-Relay bridging support -CONFIG_HDLC_FR_BRIDGE - Say Y to this option if you want generic HDLC driver to support - bridging LAN frames over Frame-Relay links. - - If unsure, say N here. - Synchronous Point-to-Point Protocol (PPP) support CONFIG_HDLC_PPP Say Y to this option if you want generic HDLC driver to support @@ -9914,7 +9994,7 @@ If unsure, say N here. -Ethernet (10 or 100Mbit) +Ethernet support CONFIG_NET_ETHERNET Ethernet (also called IEEE 802.3 or ISO 8802-2) is the most common type of Local Area Network (LAN) in universities and companies. @@ -10242,7 +10322,7 @@ for information about optional driver parameters. Questions concerning this driver may be addressed to: - linux@syskonnect.de + If you want to compile this driver as a module ( = code which can be inserted in and removed from the running kernel whenever you want), @@ -10533,7 +10613,7 @@ This is yet another chipset driver for the COM90xx cards, but this time only using memory-mapped mode, and no IO ports at all. This driver is completely untested, so if you have one of these cards, - please mail dwmw2@infradead.org, especially if it works! + please mail , especially if it works! This driver is also available as a module ( = code which can be inserted in and removed from the running kernel whenever you @@ -10724,6 +10804,12 @@ . The module will be called hp100.o. +LP486E on board Ethernet +CONFIG_LP486E + Say Y here to support the 82596-based on-board Ethernet controller + for the Panther motherboard, which is one of the two shipped in the + Intel Professional Workstation. + NE2000/NE1000 support CONFIG_NE2000 If you have a network (Ethernet) card of this type, say Y and read @@ -10798,6 +10884,7 @@ boards with this driver should be possible, but has not been tested up to now due to lack of hardware. +# This symbol is a derived one in CML2 EISA, VLB, PCI and on board controllers CONFIG_NET_PCI This is another class of network cards which attach directly to the @@ -10887,17 +10974,36 @@ module, say M here and read as well as . -DECchip Tulip (dc21x4x) PCI support +Early DECchip Tulip (dc2104x) PCI support +CONFIG_DE2104X + This driver is developed for the SMC EtherPower series Ethernet + cards and also works with cards based on the DECchip + 21040 (Tulip series) chips. Some LinkSys PCI cards are + of this type. (If your card is NOT SMC EtherPower 10/100 PCI + (smc9332dst), you can also try the driver for "Generic DECchip" + cards, above. However, most people with a network card of this type + will say Y here.) Do read the Ethernet-HOWTO, available from + . More specific + information is contained in + . + + This driver is also available as a module ( = code which can be + inserted in and removed from the running kernel whenever you want). + The module will be called tulip.o. If you want to compile it as a + module, say M here and read as well + as . + +DECchip Tulip (dc2114x) PCI support CONFIG_TULIP This driver is developed for the SMC EtherPower series Ethernet - cards and also works with cards based on the DECchip - 21040/21041/21140 (Tulip series) chips. Some LinkSys PCI cards are + cards and also works with cards based on the DECchip + 21041/21140 (Tulip series) chips. Some LinkSys PCI cards are of this type. (If your card is NOT SMC EtherPower 10/100 PCI (smc9332dst), you can also try the driver for "Generic DECchip" cards, above. However, most people with a network card of this type will say Y here.) Do read the Ethernet-HOWTO, available from . More specific - information is contained in + information is contained in . This driver is also available as a module ( = code which can be @@ -10907,7 +11013,7 @@ as . New Tulip bus configuration -CONFIG_TULIP_MWI +CONFIG_TULIP_MWI This configures your Tulip card specifically for the card and system cache line size type you are using. @@ -10915,6 +11021,13 @@ If unsure, say N. +Use PCI shared memory for NIC registers +CONFIG_TULIP_MMIO + Use PCI shared memory for the NIC registers, rather than going through + the Tulip's PIO (programmed I/O ports). Faster, but could produce + obscure bugs if your mainboard has memory controller timing issues. + If in doubt, say N. + Digi Intl. RightSwitch SE-X support CONFIG_DGRS This is support for the Digi International RightSwitch series of @@ -10942,18 +11055,6 @@ a module, say M here and read as well as . -Enable Power Management -CONFIG_EEPRO100_PM - Many Intel EtherExpress PRO/100 PCI network cards are capable - of providing power management capabilities. To make use of these - capabilities, say Y. - - WARNING: This option is intended for kernel developers and testers. - It is still very experimental, with some people reporting complete - lockups. - - It is recommended to say N here. - Myson MTD-8xx PCI Ethernet support CONFIG_FEALNX Say Y here to support the Mysom MTD-800 family of PCI-based Ethernet @@ -10989,7 +11090,7 @@ module, say M here and read as well as . - Please email feedback to torben.mathiasen@compaq.com. + Please email feedback to . VIA Rhine support CONFIG_VIA_RHINE @@ -11002,6 +11103,17 @@ a module, say M here and read as well as . +VIA Rhine MMIO support (EXPERIMENTAL) +CONFIG_VIA_RHINE_MMIO + This instructs the driver to use PCI shared memory (MMIO) instead of + programmed I/O ports (PIO). Enabling this gives an improvement in + processing time in parts of the driver. + + It is not known if this works reliably on all "rhine" based cards, + but it has been tested successfully on some DFE-530TX adapters. + + If unsure, say N. + Davicom DM910x/DM980x support CONFIG_DM9102 This driver is for DM9102(A)/DM9132/DM9801 compatible PCI cards from @@ -11404,7 +11516,7 @@ the driver. Questions concerning this driver can be addressed to: - linux@syskonnect.de + If you want to compile this driver as a module ( = code which can be inserted in and removed from the running kernel whenever you want), @@ -11460,6 +11572,16 @@ If you wish to compile a kernel for the EBSA-110, then you should always answer Y to this. +Support CPU clock change +CONFIG_CPU_FREQ + CPU clock scaling allows you to change the clock speed of the + running CPU on the fly. This is a nice method to save battery power, + because the lower the clock speed, the less power the CPU + consumes. Note that this driver doesn't automatically change the CPU + clock speed, you need some userland tools (which still have to be + written) to implement the policy. If you don't understand what this + is all about, it's safe to say 'N'. + Support Thumb instructions CONFIG_ARM_THUMB Say Y if you want to have kernel support for ARM Thumb instructions, @@ -11742,11 +11864,6 @@ The module will be called isp16.o. If you want to compile it as a module, say M here and read . -iSeries Virtual I/O CD Support -CONFIG_VIOCD - If you are running Linux on an IBM iSeries system and you want to - read a CD drive owned by OS/400, say Y here. - Quota support CONFIG_QUOTA If you say Y here, you will be able to set per user limits for disk @@ -11763,8 +11880,10 @@ will provide the generic support for MTD drivers to register themselves with the kernel and for potential users of MTD devices to enumerate the devices which are present and obtain a handle on - them. It will also allow you to select individual drivers for - particular hardware and users of MTD devices. If unsure, say N. + them. It will also allow you to select individual drivers for + particular hardware and users of MTD devices; in many cases, + selecting this feature will be sufficient to ensure that MTD + support is configured into the kernel. If unsure, say N. MTD debugging support CONFIG_MTD_DEBUG @@ -11810,8 +11929,8 @@ this option. You will still need the parsing functions to be called by the driver - for your particular device. It won't happen automatically. The - SA1100 map driver (CONFIG_MTD_SA1100) has an option for this, for + for your particular device. It won't happen automatically. The + SA1100 map driver (CONFIG_MTD_SA1100) has an option for this, for example. ARM Firmware Suite flash layout / partition parsing @@ -11825,8 +11944,7 @@ enable this option. You will still need the parsing functions to be called by the driver - for your particular device. It won't happen automatically. The - 'armflash' map driver (CONFIG_MTD_ARMFLASH) does this, for example. + for your particular device. It won't happen automatically. MTD debugging verbosity (0 = quiet, 3 = noisy) CONFIG_MTD_DEBUG_VERBOSE @@ -11900,10 +12018,10 @@ CONFIG_NFTL_RW If you're lucky, this will actually work. Don't whinge if it doesn't. Send mail to the MTD mailing list - if you want to help to make it more - reliable. + if you want to help to make + it more reliable. -Common Flash Interface (CFI) support +Detect flash chips by Common Flash Interface (CFI) probe CONFIG_MTD_CFI The Common Flash Interface specification was developed by Intel, AMD and other flash manufactures that provides a universal method @@ -11917,17 +12035,17 @@ If you need to specify a specific endianness for access to flash chips, or if you wish to reduce the size of the kernel by including support for only specific arrangements of flash chips, say 'Y'. This - option does not directly affect the code, but will enable other + option does not directly affect the code, but will enable other configuration options which allow you to do so. If unsure, say 'N'. Specific CFI Flash geometry selection CONFIG_MTD_CFI_GEOMETRY - This option does not affect the code directly, but will enable + This option does not affect the code directly, but will enable some other configuration options which would allow you to reduce - the size of the kernel by including support for only certain - arrangements of CFI chips. If unsure, say 'N' and all options + the size of the kernel by including support for only certain + arrangements of CFI chips. If unsure, say 'N' and all options which are supported by the current code will be enabled. Support 8-bit buswidth @@ -11960,14 +12078,14 @@ If your flash chips are interleaved in fours - i.e. you have four flash chips addressed by each bus cycle, then say 'Y'. -# Choice: mtd_swap_data +# Choice: mtd_data_swap Flash cmd/query data swapping CONFIG_MTD_CFI_NOSWAP This option defines the way in which the CPU attempts to arrange data bits when writing the 'magic' commands to the chips. Saying 'NO', which is the default when CONFIG_MTD_CFI_ADV_OPTIONS isn't enabled, means that the CPU will not do any swapping; the chips - are expected to be wired to the CPU in 'host-endian' form. + are expected to be wired to the CPU in 'host-endian' form. Specific arrangements are possible with the BIG_ENDIAN_BYTE and LITTLE_ENDIAN_BYTE, if the bytes are reversed. @@ -11989,37 +12107,31 @@ CONFIG_MTD_CFI_AMDSTD The Common Flash Interface defines a number of different command sets which a CFI-compliant chip may claim to implement. This code - provides support for one of those command sets, used on chips + provides support for one of those command sets, used on chips chips including the AMD Am29LV320. -CFI support for Intel/Sharp Standard Commands -CONFIG_MTD_CFI_INTELSTD - The Common Flash Interface defines a number of different command - sets which a CFI-compliant chip may claim to implement. This code - provides support for one of those command sets. - pre-CFI Sharp chip support CONFIG_MTD_SHARP This option enables support for flash chips using Sharp-compatible - commands, including some which are not CFI-compatible and hence - cannot be used with the CONFIG_MTD_CFI_INTELxxx options. + commands, including some which are not CFI-compatible and hence + cannot be used with the MTD_CFI_* options. AMD compatible flash chip support (non-CFI) CONFIG_MTD_AMDSTD This option enables support for flash chips using AMD-compatible - commands, including some which are not CFI-compatible and hence + commands, including some which are not CFI-compatible and hence cannot be used with the CONFIG_MTD_CFI_AMDSTD option. It also works on AMD compatible chips that do conform to CFI. Support for RAM chips in bus mapping CONFIG_MTD_RAM - This option enables basic support for RAM chips accessed through + This option enables basic support for RAM chips accessed through a bus mapping driver. Support for ROM chips in bus mapping CONFIG_MTD_ROM - This option enables basic support for ROM chips accessed through + This option enables basic support for ROM chips accessed through a bus mapping driver. JEDEC device support @@ -12038,18 +12150,10 @@ If you have such a board, say 'Y'. Support for Compaq bootldr partition tables on SA11x0 -CONFIG_MTD_SA1100_REDBOOT_PARTITIONS - Enabling this option will cause the kernel to look for a RedBoot - FIS (Flash Image System) table in the last erase block of the flash - chips detected. If you are using RedBoot on your SA11x0-based board - and want Linux to present 'partitions' matching the images which - RedBoot has listed, say 'Y'. - -Support for Compaq bootldr partition tables on SA11x0 CONFIG_MTD_SA1100_BOOTLDR_PARTITIONS Enabling this option will cause the kernel to look for a Compaq bootldr partition table on the flash chips detected. If you are - using the Compaq bootldr on your SA11x0-based board and want Linux + using the Compaq bootldr on your SA11x0-based board and want Linux to present 'partitions' matching the images which the bootldr has listed, say 'Y'. @@ -12086,9 +12190,9 @@ Flash chip mapping on Sun Microsystems boardsets CONFIG_MTD_SUN_UFLASH - This provides a 'mapping' driver which supports the way in - which user-programmable flash chips are connected on various - Sun Microsystems boardsets. This driver will require CFI support + This provides a 'mapping' driver which supports the way in + which user-programmable flash chips are connected on various + Sun Microsystems boardsets. This driver will require CFI support in the kernel, so if you did not enable CFI previously, do that now. Flash chip mapping on Nora @@ -12100,7 +12204,7 @@ PNC-2000 is the name of Network Camera product from PHOTRON Ltd. in Japan. It uses CFI-compliant flash. -Flash chip mapping on RPXlite PPC board +Flash chip mapping on RPXlite or CLLF PPC board CONFIG_MTD_RPXLITE The RPXLite PowerPC board has CFI-compliant chips mapped in a strange sparse mapping. This 'mapping' driver supports that @@ -12132,13 +12236,13 @@ CFI Flash device mapped on the XScale IQ80310 board CONFIG_MTD_IQ80310 This enables access routines for the flash chips on the Intel XScale - IQ80310 evaluation board. If you have one of these boards and would + IQ80310 evaluation board. If you have one of these boards and would like to use the flash chips on it, say 'Y'. CFI Flash device mapped on AMD NetSc520 CONFIG_MTD_NETSC520 This enables access routines for the flash chips on the AMD NetSc520 - demonstration board. If you have one of these boards and would like + demonstration board. If you have one of these boards and would like to use the flash chips on it, say 'Y'. Flash chip mapping on Arcom Control Systems ELAN-104NC @@ -12150,13 +12254,6 @@ . Flash chip mapping on Compaq iPAQ/Bitsy -CONFIG_MTD_BITSY - This provides a driver for the on-board flash found in Compaq's - iPAQ Palm PC and their research prototype the Itsy. iPAQ info at - and the - Itsy . - -Flash chip mapping on Compaq iPAQ/Bitsy CONFIG_MTD_DC21285 This provides a driver for the flash accessed using Intel's 21285 bridge used with Intel's StrongARM processors. More info at @@ -12176,26 +12273,26 @@ allow a window into the flash. Both CFI and JEDEC probes are called. -Physical start location of flash mapping +Physical start location of flash chip mapping CONFIG_MTD_CSTM_MIPS_IXX_START This is the physical memory location that the MTD driver will - use for the flash chips on your particular target board. - Refer to the memory map which should hopefully be in the + use for the flash chips on your particular target board. + Refer to the memory map which should hopefully be in the documentation for your board. -Physical length of flash mapping +Physical length of flash chip mapping CONFIG_MTD_CSTM_MIPS_IXX_LEN - This is the total length that the MTD driver will use for the + This is the total length that the MTD driver will use for the flash chips on your particular board. Refer to the memory map which should hopefully be in the documentation for your board. -Physical bus width of flash mapping +Physical bus width of flash mapping in bytes CONFIG_MTD_CSTM_MIPS_IXX_BUSWIDTH This is the total bus width of the mapping of the flash chips on your particular board. -Flash chip mapping on Mixcom piggyback card +JEDEC Flash device mapped on Mixcom piggyback card CONFIG_MTD_MIXMEM This supports the paging arrangement for access to flash chips on the MixCOM piggyback card, allowing the flash chip drivers @@ -12204,14 +12301,14 @@ you probably want to enable this mapping driver. More info is at . -Flash chip mapping on Octagon 5066 SBC +JEDEC Flash device mapped on Octagon 5066 SBC CONFIG_MTD_OCTAGON This provides a 'mapping' driver which supports the way in which the flash chips are connected in the Octagon-5066 Single Board Computer. More information on the board is available at . -Flash chip mapping on Tempustech VMAX SBC301 +JEDEC Flash device mapped on Tempustech VMAX SBC301 CONFIG_MTD_VMAX This provides a 'mapping' driver which supports the way in which the flash chips are connected in the Tempustech VMAX SBC301 Single @@ -12265,7 +12362,7 @@ Alternative Disk-On-Chip Millennium support CONFIG_MTD_DOC2001 - This provides an alternative MTD device driver for the M-Systems + This provides an alternative MTD device driver for the M-Systems DiskOnChip Millennium devices. Use this if you have problems with the combined DiskOnChip 2000 and Millennium driver above. To get the DiskOnChip probe code to load and use this driver instead of @@ -12379,10 +12476,10 @@ If you have system RAM accessible by the CPU but not used by Linux in normal operation, you can give the physical address at which the available RAM starts, and the MTDRAM driver will use it instead of - allocating space from Linux's available memory. Otherwise, leave + allocating space from Linux's available memory. Otherwise, leave this set to zero. Most people will want to leave this as zero. -Flash chip mapping on the Flaga Digital Module +CFI Flash device mapping on the Flaga Digital Module CONFIG_MTD_CFI_FLAGADM Mapping for the Flaga digital module. If you don´t have one, ignore this setting. @@ -12402,7 +12499,7 @@ the system regardless of media presence. Device nodes created with this driver will return -ENODEV upon access. -MTD Emulation using block device +MTD emulation using block device CONFIG_MTD_BLKMTD This driver allows a block device to appear as an MTD. It would generally be used in the following cases: @@ -12415,7 +12512,9 @@ Cirrus CDB89712 evaluation board mappings CONFIG_MTD_CDB89712 This enables access to the flash or ROM chips on the CDB89712 board. - If you have such a board, say 'Y'. + (This board has 8 MB of Intel Strataflash, a 128 byte boot ROM, and + 48 KB of internal SRAM. This driver provides MTD devices for all + three components.) If you have such a board, say 'Y'. Detect non-CFI AMD/JEDEC-compatible flash chips CONFIG_MTD_JEDECPROBE @@ -12423,9 +12522,9 @@ compatible with the Common Flash Interface, but will use the common CFI-targetted flash drivers for any chips which are identified which are in fact compatible in all but the probe method. This actually - covers most AMD/Fujitsu-compatible chips, and will shortly cover also - non-CFI Intel chips (that code is in MTD CVS and should shortly be sent - for inclusion in Linus' tree) + covers most AMD/Fujitsu-compatible chips, and will shortly cover + also non-CFI Intel chips (that code is in MTD CVS and should shortly + be sent for inclusion in Linus' tree) BIOS flash chip on Intel L440GX boards CONFIG_MTD_L440GX @@ -12444,18 +12543,20 @@ CONFIG_MTD_OBSOLETE_CHIPS This option does not enable any code directly, but will allow you to select some other chip drivers which are now considered obsolete, - because the generic CONFIG_JEDEC_PROBE code above should now detect - the chips which are supported by these drivers, and allow the generic - CFI-compatible drivers to drive the chips. Say 'N' here unless you have - already tried the CONFIG_JEDEC_PROBE method and reported its failure - to the MTD mailing list at + because the generic CONFIG_MTD_JEDECPROBE code above should now + detect the chips which are supported by these drivers, and allow the + generic CFI-compatible drivers to drive the chips. Say 'N' here + unless you have already tried the CONFIG_MTD_JEDECPROBE method and + reported its failure to the MTD mailing list at + CFI Flash device mapped on Hitachi SolutionEngine CONFIG_MTD_SOLUTIONENGINE - This enables access to the flash chips on the Hitachi SolutionEngine and - similar boards. Say 'Y' if you are building a kernel for such a board. + This enables access to the flash chips on the Hitachi SolutionEngine + and similar boards. Say 'Y' if you are building a kernel for such a + board. -Flash chip mapping on TQM8xxL PPC board +CFI Flash device mapped on TQM8XXL PPC board CONFIG_MTD_TQM8XXL The TQM8xxL PowerPC board has up to two banks of CFI-compliant chips, currently uses AMD one. This 'mapping' driver supports @@ -12469,7 +12570,6 @@ Therefore, I conclude that you do not exist - go away. There is a grue here. - Physical memory size CONFIG_MEMORY_SIZE This sets the default memory size assumed by your SH kernel. It can @@ -12519,19 +12619,7 @@ of debug messages to the system log. Select this if you are having a problem with USB support and want to see more of what is going on. -USB fetch large config -CONFIG_USB_LARGE_CONFIG - This option changes the initial request for a config descriptor so - that some poorly designed devices will still work. Some APC UPSes - need it. Basically, the usb subsystem sends a request for a short - (8 byte) config, just to find out how large the real config is. - Incorrectly implemented devices may choke on this small config - request. This option make the initial request for a quite large - config (1009 bytes), and things just work. - - If you have an APC UPS, say Y; otherwise say N. - -USB long timeout +USB long timeout for slow-responding devices (some MGE Ellipse UPSes) CONFIG_USB_LONG_TIMEOUT This option makes the standard time out a bit longer. Basically, some devices are just slow to respond, so this makes usb more @@ -12663,17 +12751,6 @@ The module will be called wacom.o. If you want to compile it as a module, say M here and read . -Aiptek 8000U tablet support -CONFIG_USB_AIPTEK - Say Y here if you want to use the USB version of the Aiptek 8000U - tablet. Make sure to say Y to "Event interface support" - (CONFIG_INPUT_EVDEV) as well. - - This driver is also available as a module ( = code which can be - inserted in and removed from the running kernel whenever you want). - The module will be called aiptek.o. If you want to compile it as a - module, say M here and read . - Use input layer for ADB devices CONFIG_INPUT_ADBHID Say Y here if you want to have ADB (Apple Desktop Bus) HID devices @@ -12765,16 +12842,6 @@ The module will be called scanner.o. If you want to compile it as a module, say M here and read . -HP 5300C scanner support -CONFIG_USB_HP5300 - Say Y here if you want to connect a HP5300C scanner to your - computer's USB port. - - This code is also available as a module ( = code which can be - inserted in and removed from the running kernel whenever you want). - The module will be called hp5300.o. If you want to compile it as - a module, say M here and read . - USB Audio support CONFIG_USB_AUDIO Say Y here if you want to connect USB audio equipment such as @@ -12841,15 +12908,15 @@ The module will be called visor.o. If you want to compile it as a module, say M here and read . -USB IR Dongle Serial Driver -CONFIG_USB_SERIAL_IR - Say Y here if you want to enable simple serial support for USB IrDA - devices. This is useful if you do not want to use the full IrDA - stack. - +USB Compaq iPAQ Driver +CONFIG_USB_SERIAL_IPAQ + Say Y here if you want to connect to your Compaq iPAQ running + Windows CE 3.0 using a USB autosync cable. For information on using + the driver, read . + This code is also available as a module ( = code which can be inserted in and removed from the running kernel whenever you want). - The module will be called ir-usb.o. If you want to compile it as a + The module will be called ipaq.o. If you want to compile it as a module, say M here and read . USB IR Dongle Serial Driver @@ -12857,7 +12924,7 @@ Say Y here if you want to enable simple serial support for USB IrDA devices. This is useful if you do not want to use the full IrDA stack. - + This code is also available as a module ( = code which can be inserted in and removed from the running kernel whenever you want). The module will be called ir-usb.o. If you want to compile it as a @@ -12866,7 +12933,7 @@ USB Belkin and Paracom Single Port Serial Driver CONFIG_USB_SERIAL_BELKIN Say Y here if you want to use a Belkin USB Serial single port - adaptor (F5U103 is one of the model numbers) or the Peracom single + adapter (F5U103 is one of the model numbers) or the Peracom single port USB to serial adapter. This code is also available as a module ( = code which can be @@ -13061,6 +13128,22 @@ The module will be called io_edgeport.o. If you want to compile it as a module, say M here and read . +USB PalmConnect (and other KL5KUSB105-based) Single Port Serial Driver +CONFIG_USB_SERIAL_KLSI + Say Y here if you want to use a KL5KUSB105 - based single port + serial adapter. The most widely known -- and currently the only + tested -- device in this category is the PalmConnect USB Serial + adapter sold by Palm Inc. for use with their Palm III and Palm V + series PDAs. + + Please read for more + information. + + This code is also available as a module ( = code which can be + inserted in and removed from the running kernel whenever you want). + The module will be called kl5kusb105.o. If you want to compile it as + a module, say M here and read . + USB Serial Converter verbose debug CONFIG_USB_SERIAL_DEBUG Say Y here if you want verbose debug messages from the USB Serial @@ -13112,7 +13195,7 @@ The module will be called ov511.o. If you want to compile it as a module, say M here and read . -USB Communication Class Ethernet driver +USB Communication Class Ethernet device support CONFIG_USB_CDCETHER This driver supports devices conforming to the Communication Device Class Ethernet Control Model. This is used in some cable modems. @@ -13167,21 +13250,20 @@ The module will be called pwc.o. If you want to compile it as a module, say M here and read . -Pegasus/Pegasus II based USB-Ethernet device support +USB ADMtek Pegasus-based USB-Ethernet device support CONFIG_USB_PEGASUS Say Y here if you know you have Pegasus or Pegasus II based adapter. - If in doubt then look at linux/drivers/usb/pegasus.h for the complete - list of supported devices. - If your particular adapter is not in the list and you are _sure_ it - is Pegasus or Pegasus II based then send me (pmanolov@lnxw.com) vendor - and device IDs. + If in doubt then look at linux/drivers/usb/pegasus.h for the + complete list of supported devices. If your particular adapter is + not in the list and you are _sure_ it is Pegasus or Pegasus II based + then send me () vendor and device IDs. This code is also available as a module ( = code which can be inserted in and removed from the running kernel whenever you want). The module will be called pegasus.o. If you want to compile it as a module, say M here and read . -USB KLSI KL5USB101-based Ethernet device support ' +USB KLSI KL5USB101-based Ethernet device support CONFIG_USB_KAWETH Say Y here if you want to use one of the following 10Mbps only USB Ethernet adapters based on the KLSI KL5KUSB101B chipset: @@ -13279,7 +13361,7 @@ Say Y here in order to have the USB Mass Storage code generate verbose debugging messages. -ISD-200 USB/ATA driver +ISD-200 USB/ATA Bridge support CONFIG_USB_STORAGE_ISD200 Say Y here if you want to use USB Mass Store devices based on the In-Systems Design ISD-200 USB/ATA bridge. @@ -13390,7 +13472,7 @@ Freecom USB/ATAPI Bridge support CONFIG_USB_STORAGE_FREECOM - Support for the Freecom USB to IDE/ATAPI adaptor. + Support for the Freecom USB to IDE/ATAPI adapter. Freecom has a web page at . Microtech CompactFlash/SmartMedia reader @@ -13399,7 +13481,7 @@ reader, details at . This driver treats the flash card as a removable storage device. -Sandisk SDDR-09 SmartMedia reader support +SanDisk SDDR-09 (and other SmartMedia) support CONFIG_USB_STORAGE_SDDR09 Say Y here to include additional code to support the Sandisk SDDR-09 SmartMedia reader in the USB Mass Storage driver. @@ -13453,12 +13535,6 @@ wise choice too. In all other cases (for example, if you're just playing around with User-Mode Linux) you can choose N. -Enable ptrace proxy -CONFIG_PT_PROXY - This option enables a debugging interface which allows gdb to debug - the kernel without needing to actually attach to kernel threads. - If you want to do kernel debugging, say Y here; otherwise say N. - Management console CONFIG_MCONSOLE The user mode linux management console is a low-level interface to @@ -13523,7 +13599,7 @@ For more information, see . - If you'd like to be able to work with files stored on the host, + If you'd like to be able to work with files stored on the host, say Y or M here; otherwise say N. Example IO Memory driver @@ -13602,7 +13678,7 @@ link with the host. To use this, your host kernel must have support for Ethertap - devices. Also, if your host kernel is 2.4.x, it must have + devices. Also, if your host kernel is 2.4.x, it must have CONFIG_NETLINK_DEV configured as Y or M. For more information, see @@ -13611,7 +13687,7 @@ networking. If you'd like to set up an IP network with the host and/or the - outside world, say Y to this, the Daemon Transport and/or the + outside world, say Y to this, the Daemon Transport and/or the Slip Transport. You'll need at least one of them, but may choose more than one without conflict. If you don't need UML networking, say N. @@ -13665,7 +13741,7 @@ The Ethertap Transport is preferred over Slip because of its limitation. If you prefer Slip, however, say Y here. Otherwise - choose the Multicast transport (to network multiple UMLs on + choose the Multicast transport (to network multiple UMLs on multiple hosts), Ethertap (to network with the host and the outside world), and/or the Daemon transport (to network multiple UMLs on a single host). You may choose more than one without @@ -13682,7 +13758,7 @@ and work. SANE 1.0.4 or newer is needed to make use of your scanner. This driver can be compiled as a module. -HP 53xx and Minolta Dual Scanner support +HP53xx and Minolta Dual Scanner support CONFIG_USB_HPUSBSCSI Say Y here if you want support for the HP 53xx series of scanners and the Minolta Scan Dual. This driver is experimental. @@ -13721,7 +13797,7 @@ Reiserfs support CONFIG_REISERFS_FS Stores not just filenames but the files themselves in a balanced - tree. Uses journaling. + tree. Uses journalling. Balanced trees are more efficient than traditional file system architectural foundations. @@ -13810,13 +13886,13 @@ be compiled as a module, and so this could be dangerous. Most everyone wants to say Y here. -Ext3 journaling file system support (EXPERIMENTAL) +Ext3 journalling file system support (EXPERIMENTAL) CONFIG_EXT3_FS - This is the journaling version of the Second extended file system - (often called ext3), the de facto standard Linux file system + This is the journalling version of the Second extended file system + (often called ext2), the de facto standard Linux file system (method to organize files on a storage device) for hard disks. - The journaling code included in this driver means you do not have + The journalling code included in this driver means you do not have to run e2fsck (file system checker) on your file systems after a crash. The journal keeps track of any changes that were being made at the time the system crashed, and can ensure that your file system @@ -13844,7 +13920,7 @@ Journal Block Device support (JBD for ext3) (EXPERIMENTAL) CONFIG_JBD - This is a generic journaling layer for block devices. It is + This is a generic journalling layer for block devices. It is currently used by the ext3 file system, but it could also be used to add journal support to other file systems or block devices such as RAID or LVM. @@ -13872,7 +13948,7 @@ generated. To turn debugging off again, do "echo 0 > /proc/sys/fs/jbd-debug". -Buffer Head tracing (DEBUG) +Buffer Head tracing CONFIG_BUFFER_DEBUG If you are a kernel developer working with file systems or in the block device layer, this buffer head tracing may help you to track @@ -13924,15 +14000,14 @@ If unsure, say N. -CMS file system support -CONFIG_CMS_FS - Read only support for CMS minidisk file systems found on IBM - mainframe systems. Only the basic format is supported so far. If - you don't know what CMS is you probably don't want to know any more. - +# When the 2.5 version of configure.help goes away, the part of this that +# duplicates Documentation/filesystems/tmpfs.txt can drop out. Virtual memory file system support CONFIG_TMPFS Tmpfs is a file system which keeps all files in virtual memory. + Everything in tmpfs is temporary in the sense that no files will be + created on your hard drive. If you reboot, everything in tmpfs will + be lost. In contrast to RAM disks, which get allocated a fixed amount of physical RAM, tmpfs grows and shrinks to accommodate the files it @@ -13959,6 +14034,8 @@ The initial permissions of the root directory can be set with the mount option "mode". + See for details. + Simple RAM-based file system support CONFIG_RAMFS Ramfs is a file system which keeps all files in RAM. It allows @@ -14313,7 +14390,7 @@ If you would like to include the NFSv3 server as well as the NFSv2 server, say Y here. If unsure, say Y. -Provide NFS over TCP server support DEVELOPER ONLY +Provide NFS over TCP server support (DEVELOPER ONLY) CONFIG_NFSD_TCP If you are a developer and want to work on fixing problems with NFS server over TCP support, say Y here. If unsure, say N. @@ -14541,7 +14618,7 @@ Journalling Flash File System (JFFS) support CONFIG_JFFS_FS - JFFS is the Journaling Flash File System developed by Axis + JFFS is the Journalling Flash File System developed by Axis Communications in Sweden, aimed at providing a crash/powerdown-safe file system for disk-less embedded devices. Further information is available at (). @@ -14576,8 +14653,9 @@ JFFS stats available in /proc filesystem CONFIG_JFFS_PROC_FS - Enabling this option will cause statistics from mounted JFFS file systems - to be made available to the user in the /proc/fs/jffs/ directory. + Enabling this option will cause statistics from mounted JFFS file + systems to be made available to the user in the /proc/fs/jffs/ + directory. UFS file system support (read-only) CONFIG_UFS_FS @@ -14663,7 +14741,7 @@ Say Y here if you would like to use hard disks under Linux which were partitioned on a Macintosh. -Windows' Logical Disk Manager (Dynamic Disk) support (EXPERIMENTAL) +Windows Logical Disk Manager (Dynamic Disk) support (EXPERIMENTAL) CONFIG_LDM_PARTITION Say Y here if you would like to use hard disks under Linux which were partitioned using Windows 2000's or XP's Logical Disk Manager. @@ -14683,7 +14761,7 @@ If unsure, say N. -Windows' LDM extra logging +Windows LDM extra logging CONFIG_LDM_DEBUG Say Y here if you would like LDM to log verbosely. This could be helpful if the driver doesn't work as expected and you'd like to @@ -14823,7 +14901,7 @@ inserted in and removed from the running kernel whenever you want). The module is called freevxfs.o. If you want to compile it as a module, say M here and read . If - unsure, say N. + unsure, say N. UnixWare slices support CONFIG_UNIXWARE_DISKLABEL @@ -14915,7 +14993,7 @@ whenever you want), say M here and read . The module will be called coda.o. -InterMezzo file system support (experimental, replicating fs) +InterMezzo file system support (replicating fs) CONFIG_INTERMEZZO_FS InterMezzo is a networked file system with disconnected operation and kernel level write back caching. It is most often used for @@ -15345,6 +15423,7 @@ set, and it replaces the rarely needed Icelandic letters in Latin 1 with the Turkish ones. Useful in Turkey. +# This is not actually used. NLS ISO 8859-10 (Latin 6; Nordic) CONFIG_NLS_ISO8859_10 If you want to display filenames with native language characters @@ -15495,6 +15574,7 @@ Enable Ethernet support via the Motorola MPC8xx serial commmunications controller. +# Choice: scc_ethernet Ethernet on SCC1 CONFIG_SCC1_ENET Use MPC8xx serial communications controller 1 to drive Ethernet @@ -15557,21 +15637,6 @@ If you use an ADB keyboard (4 pin connector), say Y here. If you use a PS/2 keyboard (6 pin connector), say N here. -HIL keyboard support -CONFIG_HIL - The "Human Interface Loop" is a older, 8-channel USB-like controller - used in Hewlette Packard PA-RISC based machines. There are a few - cases where it is seen on PC/MAC architectures as well, usually also - manufactured by HP. This driver is based off MACH and BSD drivers, - and implements support for a keyboard attached to the HIL port. - Full support for the USB-like functions and non-keyboard channels of - the HIL is not provided for in this driver. There are vestiges of - mouse support in the driver, but it is probably not working. The - necessary hardware documentation to fully support the HIL controller - and interface it to the linux-input API is lacking. - - Enable this option if you intend to use a HIL keyboard. - Include IOP (IIfx/Quadra 9x0) ADB driver CONFIG_ADB_IOP The I/O Processor (IOP) is an Apple custom IC designed to provide @@ -15716,6 +15781,23 @@ If unsure, say N. +Enable protocol mode for the L1 console +CONFIG_SERIAL_SGI_L1_PROTOCOL + Saying Y here will build support for SGI L1 system controllers. + + The L1 system controller is used as a console device as well as + for various system management tasks (e.g. power on/off, reset, + fan control, etc.). You'll want to say Y here unless you have + special needs. + +Enable autotest (llsc). Option to run cache test instead of booting +CONFIG_IA64_SGI_AUTOTEST + Build a kernel used for hardware validation. If you include the + keyword "autotest" on the boot command line, the kernel does NOT boot. + Instead, it starts all cpus and runs cache coherency tests instead. + + If unsure, say N. + Support for PowerMac serial ports CONFIG_MAC_SERIAL If you have Macintosh style serial ports (8 pin mini-DIN), say Y @@ -16044,123 +16126,6 @@ If unsure, say N. -Cobalt Networks support -CONFIG_COBALT - Support for Cobalt Networks x86-based servers. - -Gen III (3000 series) system support -CONFIG_COBALT_GEN_III - This option enables support for the 3000 series of Cobalt Networks - systems. This includes the RaQ 3, RaQ 4, and Qube 3 product lines. - - This platform uses an AMD K6-2 processor, an ALI M1541/1533 chipset, - an optional NCR 53c875 SCSI controller, and two Intel 82559ER or - National Semiconductor DP83815 NICs. - - Getting this option wrong will likely result in a kernel that does - not boot. Selecting support for more than 1 system series will add - bloat to your kernel, but will not cause anything bad to happen. - - If you have a Cobalt Networks System, but aren't sure what kind, - say Y here. - -Gen V (5000 series) system support -CONFIG_COBALT_GEN_V - This option enables support for the 5000 series of Cobalt Networks - systems. This includes the RaQ XTR product line. - - This platform uses Intel Pentium III Coppermine FCPGA CPUs, the - ServerWorks LE chipset (with registered ECC DIMMs only!), two - HighPoint HPT370 IDE controllers, and two National Semiconductor - DP83815 NICs. - - Getting this option wrong will likely result in a kernel that does - not boot. Selecting support for more than 1 system series will add - bloat to your kernel, but will not cause anything bad to happen. - - If you have a Cobalt Networks System, but aren't sure what kind, - say Y here. - -Create legacy /proc files -CONFIG_COBALT_OLDPROC - This option forces some Cobalt Networks drivers to support legacy - files in /proc. Older versions of these drivers exported files - directly in /proc, as opposed to the newer /proc/cobalt. If you say - N to this option, the old filenames will no longer be exported. - Regardless of your selection here, files in /proc/cobalt will be - exported. Of course, you have to include support for /proc fs, too. - - It is safe to say Y here. - -Front panel LCD support -CONFIG_COBALT_LCD - This enables support for the Cobalt Networks front panel. This is - for the LCD panel and buttons. The primary method for connection is - via the parallel port (IO base 0x370), but newer systems use an - I2C bus. - - If you have a Cobalt Networks system, you should say Y here. - -Software controlled LED support -CONFIG_COBALT_LED - This enables support for the software-controlled LEDs on Cobalt - Networks systems. This includes the fault light and front panel - LEDs on the RaQ XTR, the lightbar on the Qube 3, and others. - - If you have a Cobalt Networks system, you should say Y here. - -Silicon serial number support -CONFIG_COBALT_SERNUM - This enables support for the on-board serial number on Cobalt - Networks systems. This is a universally-unique 64-bit serial - number. Some systems use a Dallas DS2401 chip, others have an I2C - based EEPROM. - - If you select Y here, the files /proc/cobalt/hostid and - /proc/cobalt/serialnumber will be created. The hostid file contains - a 32 bit integer generated from the serial number, in binary form. - The serialnumber file contains the hexadecimal representation of the - serial number, in ASCII. - - If you have a Cobalt Networks system, you should say Y here. - -Chipset watchdog timer support -CONFIG_COBALT_WDT - This enables support for the watchdog timer built into Cobalt - chipsets. The timer wakes up periodically, to make find out if - system has hung, or disabled interrupts too long. The result of - detecting a hang is a hard reboot. - - If you have a Cobalt Networks system, you should say Y here. - -Thermal sensor support -CONFIG_COBALT_THERMAL - This enables support for the thermal sensor(s) built into Cobalt - Networks systems. This driver exports /proc/cobalt/thermal_sensors. - - If you have a Cobalt Networks system, you should say Y here. - -Fan tachometer support -CONFIG_COBALT_FANS - This enables support for the fan tachometers built into some Cobalt - Networks systems. This driver exports /proc/cobalt/faninfo. Some - Cobalt software depends on this feature, and enabling it does not - cause any risks. - - If you have a Cobalt Networks system, you should say Y here, unless - you are absolutely sure. - -Disk drive ruler support -CONFIG_COBALT_RULER - This enables support for the cobalt hard drive ruler, found on some - Cobalt systems, including the RaQ XTR. This is the device that - enables swapping of drives. It is not needed for basic disk - operation. Enabling this on a system with no ruler will have no - adverse effects. - - If you have a Cobalt Networks system, you should say Y here, - unless you are absolutely sure. - I2C support CONFIG_I2C I2C (pronounce: I-square-C) is a slow serial bus protocol used in @@ -16185,7 +16150,7 @@ . The module will be called i2c-core.o. -UltraSPARC-III bootbus i2c controller driver +UltraSPARC-III bootbus I2C controller driver CONFIG_BBC_I2C The BBC devices on the UltraSPARC III have two I2C controllers. The first I2C controller connects mainly to configuration PROMs (NVRAM, @@ -16194,6 +16159,29 @@ temperature sensors. The second controller also connects to the smartcard reader, if present. Say Y to enable support for these. +# This should turn into a derivation from ITE8172 and I2C_ALGOBIT +MIPS ITE8172 I2C driver algorithm +CONFIG_ITE_I2C_ALGO + This supports the use the ITE8172 I2C interface found on some MIPS + systems. Say Y if you have one of these. You should also say Y for + the ITE I2C peripheral driver support below. + + This support is also available as a module. If you want to compile + it as a modules, say M here and read + . + The module will be called i2c-algo-ite.o. + +MIPS ITE8172 I2C peripheral driver +CONFIG_ITE_I2C_ADAP + This supports the ITE8172 I2C peripheral found on some MIPS + systems. Say Y if you have one of these. You should also say Y for + the ITE I2C driver algorithm support above. + + This support is also available as a module. If you want to compile + it as a module, say M here and read + . + The module will be called i2c-adap-ite.o. + I2C bit-banging interfaces CONFIG_I2C_ALGOBIT This allows you to use a range of I2C adapters called bit-banging @@ -16271,7 +16259,7 @@ . The module will be called i2c-dev.o. -I2C /proc support +I2C /proc interface (required for hardware sensors) CONFIG_I2C_PROC This provides support for i2c device entries in the /proc filesystem. The entries will be found in /proc/sys/dev/sensors. @@ -16285,7 +16273,7 @@ Say Y here if your machine has a bus mouse as opposed to a serial mouse. Most people have a regular serial MouseSystem or Microsoft mouse (made by Logitech) that plugs into a COM port - (rectangular with 9 or 25 pins). These people say N here. + (rectangular with 9 or 25 pins). These people say N here. If you have a laptop, you either have to check the documentation or experiment a bit to find out whether the trackball is a serial mouse @@ -16424,11 +16412,6 @@ and read . The module will be called tpqic02.o. -iSeries Virtual Tape Support -CONFIG_VIOTAPE - If you are running Linux on an iSeries system and you want Linux - to read and/or write a tape drive owned by OS/400, say Y here. - Do you want runtime configuration for QIC-02 CONFIG_QIC02_DYNCONF You can either configure this driver once and for all by editing a @@ -16641,6 +16624,25 @@ PCI-bus based system, please read the file . +MACH-2 +CONFIG_FT_MACH2 + Choose "MACH-2" if you have a Mountain Mach-2 tape controller. + +FC-10/FC-20 +CONFIG_FT_PROBE_FC10 + Choose "FC-10/FC-20" if you have a Colorado FC-10 or FC-20 + tape controller. + +Alt/82078 +CONFIG_FT_ALT_FDC + Choose "Alt/82078" if you have another controller that is located at + an IO base address different from the standard floppy drive + controller's base address of `0x3f0', or uses an IRQ (interrupt) + channel different from `6', or a DMA channel different from + `2'. This is necessary for any controller card that is based on + Intel's 82078 FDC such as Seagate's, Exabyte's and Iomega's "high + speed" controllers. + IO base for the floppy disk controller used with Ftape CONFIG_FT_FDC_BASE You don't need to specify a value if the following default @@ -16753,12 +16755,6 @@ details. You should also select and configure AGP (/dev/agpgart) support. -Build drivers for new (XFree 4.1) DRM -CONFIG_DRM_NEW - If you set this option, the new DRM version needed by XFree86 4.1 - will be used. Otherwise, the old DRM version will be used, - appropriate for XFree86 4.0. - 3dfx Banshee/Voodoo3+ CONFIG_DRM_TDFX Choose this option if you have a 3dfx Banshee or Voodoo3 (or later), @@ -16795,42 +16791,6 @@ card. If M is selected, the module will be called mga.o. AGP support is required for this driver to work. -3dfx Banshee/Voodoo3+ -CONFIG_DRM40_TDFX - Choose this option if you have a 3dfx Banshee or Voodoo3 (or later), - graphics card. If M is selected, the module will be called tdfx.o. - -3dlabs GMX 2000 -CONFIG_DRM40_GAMMA - Choose this option if you have a 3dlabs GMX 2000 graphics card. - If M is selected, the module will be called gamma.o. - -ATI Rage 128 -CONFIG_DRM40_R128 - Choose this option if you have an ATI Rage 128 graphics card. If M - is selected, the module will be called r128.o. AGP support for - this card is strongly suggested (unless you have a PCI version). - -ATI Radeon -CONFIG_DRM40_RADEON - Choose this option if you have an ATI Radeon graphics card. There - are both PCI and AGP versions. You don't need to choose this to - run the Radeon in plain VGA mode. There is a product page at - . - If M is selected, the module will be called radeon.o. - -Intel I810 -CONFIG_DRM40_I810 - Choose this option if you have an Intel I810 graphics card. If M is - selected, the module will be called i810.o. AGP support is required - for this driver to work. - -Matrox G200/G400/G450 -CONFIG_DRM40_MGA - Choose this option if you have a Matrox G200, G400 or G450 graphics - card. If M is selected, the module will be called mga.o. AGP - support is required for this driver to work. - Creator/Creator3D/Elite3D CONFIG_DRM_FFB Choose this option if you have one of Sun's Creator3D-based graphics @@ -16904,7 +16864,7 @@ fieldbus cards made by Applicom International. More information about these cards can be found on the WWW at the address , or by email from David Woodhouse - . + . To compile this driver as a module ( = code which can be inserted in and removed from the running kernel whenever you want), say M here @@ -16961,22 +16921,6 @@ will issue the hlt instruction if nothing is to be done, thereby sending the processor to sleep and saving power. -USB SE401 Camera support -CONFIG_USB_SE401 - Say Y here if you want to connect this type of camera to your - computer's USB port. See for more - information and for a list of supported cameras. - - This driver uses the Video For Linux API. You must say Y or M to - "Video For Linux" (under Multimedia Devices) to use this driver. - Information on this API and pointers to "v4l" programs may be found - on the WWW at . - - This code is also available as a module ( = code which can be - inserted in and removed from the running kernel whenever you want). - The module will be called se401.o. If you want to compile it as a - module, say M here and read . - ACPI support CONFIG_ACPI ACPI/OSPM support for Linux is currently under development. As such, @@ -17007,11 +16951,6 @@ The ACPI Sourceforge project may also be of interest: -Enable ACPI 2.0 with errata 1.3 -CONFIG_ACPI20 - Enable support for the 2.0 version of the ACPI interpreter. See the - help for ACPI for caveats and discussion. - ACPI kernel configuration manager CONFIG_ACPI_KERNEL_CONFIG If you say `Y' here, Linux's ACPI support will use the @@ -17214,11 +17153,11 @@ your computer. For details, read in the kernel source. - The watchdog is usually used together with the watchdog daemon - which is available from - . This daemon can - also monitor NFS connections and can reboot the machine when the process - table is full. + The watchdog is usually used together with the watchdog daemon which + is available from + . This daemon + can also monitor NFS connections and can reboot the machine when the + process table is full. If unsure, say N. @@ -17282,7 +17221,7 @@ inserted in and removed from the running kernel whenever you want). If you want to compile it as a module, say M here and read . The module will be called - softdog.o. + softdog.o. Berkshire Products PC Watchdog CONFIG_PCWATCHDOG @@ -17337,11 +17276,13 @@ IB700 SBC Watchdog Timer CONFIG_IB700_WDT This is the driver for the hardware watchdog on the IB700 Single - Board Computer produced by TMC Technology (www.tmc-uk.com). This watchdog - simply watches your kernel to make sure it doesn't freeze, and if - it does, it reboots your computer after a certain amount of time. + Board Computer produced by TMC Technology (www.tmc-uk.com). This + watchdog simply watches your kernel to make sure it doesn't freeze, + and if it does, it reboots your computer after a certain amount of + time. - This driver is like the WDT501 driver but for slightly different hardware. + This driver is like the WDT501 driver but for slightly different + hardware. This driver is also available as a module ( = code which can be inserted in and removed from the running kernel whenever you want). @@ -17375,7 +17316,7 @@ The module is called machzwd.o. If you want to compile it as a module, say M here and read . -SuperH 3/4 Watchdog +SuperH 3/4 on-chip Watchdog support CONFIG_SH_WDT This driver adds watchdog support for the integrated watchdog in the SuperH 3 and 4 processors. If you have one of these processors, say Y, @@ -17385,7 +17326,7 @@ inserted in and removed from the running kernel whenever you want). The module is called shwdt.o. If you want to compile it as a module, say M here and read Documentation/modules.txt. - + Toshiba Laptop support CONFIG_TOSHIBA This adds a driver to safely access the System Management Mode of @@ -17400,23 +17341,24 @@ Say Y if you intend to run this kernel on a Toshiba portable. Say N otherwise. -Dell Inspiron 8000 support +Dell laptop support CONFIG_I8K This adds a driver to safely access the System Management Mode - of the CPU on the Dell Inspiron 8000. The System Management Mode - is used to read cpu temperature and cooling fan status and to - control the fans on the I8K portables. - - This driver has been tested only on the Inspiron 8000 but it may - also work with other Dell laptops. You can force loading on other - models by passing the parameter `force=1' to the module. Use at - your own risk. + of the CPU on the Dell Inspiron and Latitude laptops. The System + Management Mode is used to read cpu temperature, cooling fan + status and Fn-keys status on Dell laptops. It can also be used + to switch the fans on and off. + + The driver has been developed and tested on an Inspiron 8000 + but it should work on any Dell Inspiron or Latitude laptop. + You can force loading on unsupported models by passing the + parameter `force=1' to the module. Use at your own risk. + + For more information on this driver and for utilities that make + use of the module see the I8K Linux Utilities web site at: + . - For information on utilities to make use of this driver see the - I8K Linux utilities web site at: - - - Say Y if you intend to run this kernel on a Dell Inspiron 8000. + Say Y if you intend to run this kernel on a Dell laptop. Say N otherwise. /dev/cpu/microcode - Intel IA32 CPU microcode support @@ -17466,6 +17408,12 @@ You can compile this driver directly into the kernel, or use it as a module. The module will be called sbc60xxwdt.o. +Eurotech CPU-1220/1410 Watchdog Timer +CONFIG_EUROTECH_WDT + Enable support for the watchdog timer on the Eurotech CPU-1220 and + CPU-1410 cards. These are PC/104 SBCs. Spec sheets and product + information are at . + Enhanced Real Time Clock Support CONFIG_RTC If you say Y here and create a character special file /dev/rtc with @@ -17575,8 +17523,8 @@ Crystal SoundFusion gameports CONFIG_INPUT_CS461X - Say Y here if you have a Cirrus CS461x aka "Crystal SoundFusion" - PCI audio accelerator. A product page for the CS4614 is at + Say Y here if you have a Cirrus CS461x aka "Crystal SoundFusion" PCI + audio accelerator. A product page for the CS4614 is at . This driver is also available as a module ( = code which can be @@ -17680,7 +17628,8 @@ CONFIG_INPUT_INTERACT Say Y hereif you have an InterAct gameport or joystick communicating digitally over the gameport. For more information on - how to use the driver please read . + how to use the driver please read + . This driver is also available as a module ( = code which can be inserted in and removed from the running kernel whenever you want). @@ -17748,7 +17697,8 @@ CONFIG_INPUT_MAGELLAN Say Y here if you have a Magellan or Space Mouse 6DOF controller connected to your computer's serial port. For more information on - how to use the driver please read . + how to use the driver please read + . This driver is also available as a module ( = code which can be inserted in and removed from the running kernel whenever you want). @@ -17771,7 +17721,8 @@ CONFIG_INPUT_SPACEBALL Say Y here if you have a SpaceTec SpaceBall 4000 FLX controller connected to your computer's serial port. For more information on - how to use the driver please read . + how to use the driver please read + . This driver is also available as a module ( = code which can be inserted in and removed from the running kernel whenever you want). @@ -18493,6 +18444,41 @@ chips is available at . +Enable legacy FM +CONFIG_SOUND_CMPCI_FM + Say Y here to enable the legacy FM (frequency-modulation) synthesis + support on a card using the CMI8338 or CMI8378 chipset. + +FM I/O (388, 3C8, 3E0, 3E8) +CONFIG_SOUND_CMPCI_FMIO + Set the base I/O address for FM synthesis control on a card using + the CMI8338 or CMI8378 chipset. + +Enable legacy MPU-401 +CONFIG_SOUND_CMPCI_MIDI + Say Y here to enable the legacy MP401 MIDI synthesis support on a + card using the CMI8338 or CMI8378 chipset. + +MPU-401 I/O (330, 320, 310, 300) +CONFIG_SOUND_CMPCI_MPUIO + Set the base I/O address for MP401 MIDI synthesis control on a card + using the CMI8338 or CMI8378 chipset. + +Inverse S/PDIF in for CMI8738 +CONFIG_SOUND_CMPCI_SPDIFINVERSE + Say Y here to have the driver invert the signal presented on SPDIF IN + of s card using the CMI8338 or CMI8378 chipset. + +Use Line-in as Rear-out +CONFIG_SOUND_CMPCI_LINE_REAR + Say Y here to enable using line-in jack as an output jack for a rear + speaker. + +Use Line-in as Bass +CONFIG_SOUND_CMPCI_LINE_BASS + Say Y here to enable using line-in jack as an output jack for a bass + speaker. + Support CMI8738 based audio cards CONFIG_SOUND_CMPCI_CM8738 Say Y or M if you have a PCI sound card using the CMI8338 @@ -18523,7 +18509,7 @@ A userspace utility to control even more internal registers of these chips is available at . - This package will among other things help you enable SPDIF + This package will among other things help you enable SPDIF out/in/loop/monitor. Creative SBLive! (EMU10K1) based PCI sound cards @@ -18541,7 +18527,7 @@ Userspace tools to create new patches and load/unload them can be found at . -Creative EMU10K1 MIDI +Creative SBLive! (EMU10K1) MIDI CONFIG_MIDI_EMU10K1 Say Y if you want to be able to use the OSS /dev/sequencer interface. This code is still experimental. @@ -18592,6 +18578,12 @@ differs slightly from OSS/Free, so PLEASE READ . +NEC Vrc5477 AC97 sound +CONFIG_SOUND_VRC5477 + Say Y here to enable sound support for the NEC Vrc5477 chip, an + integrated, multi-function controller chip for MIPS CPUs. Works + with the AC97 codec. + Trident 4DWave DX/NX, SiS 7018 or ALi 5451 PCI Audio Core CONFIG_SOUND_TRIDENT Say Y or M if you have a PCI sound card utilizing the Trident @@ -18708,6 +18700,13 @@ Support for audio mixer facilities on the BT848 TV frame-grabber card. +IT8172G Sound +CONFIG_SOUND_IT8172 + Say Y here to support the on-board sound generator on the Integrated + Technology Express, Inc. ITE8172 SBC. Vendor page at + ; picture of the + board at . + VIDC 16-bit sound CONFIG_SOUND_VIDC 16-bit support for the VIDC onboard sound hardware found on Acorn @@ -18794,20 +18793,21 @@ website at will have more information. -Model-500/510 -CONFIG_NINO_16MB - Say Y here to build a kernel specifically for Nino 500/501 color - Palm PCs from Philips (INCOMPLETE). +# Choice: nino_model +CONFIG_NINO_4MB + Say Y here to build a kernel specifically for Nino Palm PCs with + 4MB of memory. These include models 300/301/302/319. Model-200/210/312/320/325/350/390 CONFIG_NINO_8MB Say Y here to build a kernel specifically for Nino Palm PCs with 8MB of memory. These include models 200/210/312/320/325/350/390. +Model-500/510 +CONFIG_NINO_16MB + Say Y here to build a kernel specifically for Nino 500/501 color + Palm PCs from Philips (INCOMPLETE). Model-300/301/302/319 -CONFIG_NINO_4MB - Say Y here to build a kernel specifically for Nino Palm PCs with - 4MB of memory. These include models 300/301/302/319. Low-level debugging CONFIG_LL_DEBUG @@ -18831,6 +18831,44 @@ hardware debugging with a logic analyzer and need to see all traffic on the bus. +Enable AU1000 serial console +CONFIG_AU1000_SERIAL_CONSOLE + If you have an Alchemy AU1000 processor (MIPS based) and you want + to use a console on a serial port, say Y. Otherwise, say N. + +Enable AU1000 serial support +CONFIG_AU1000_UART + If you have an Alchemy AU1000 processor (MIPS based) and you want + to use serial ports, say Y. Otherwise, say N. + +AU1000 ethernet controller on SGI MIPS system +CONFIG_MIPS_AU1000_ENET + If you have an Alchemy Semi AU1000 ethernet controller + on an SGI MIPS system, say Y. Otherwise, say N. + +TMPTX3912/PR31700 serial port support +CONFIG_SERIAL_TX3912 + The TX3912 is a Toshiba RISC processor based o the MIPS 3900 core; + see . + Say Y here to enable kernel support for the on-board serial port. + +Console on TMPTX3912/PR31700 serial port +CONFIG_SERIAL_TX3912_CONSOLE + The TX3912 is a Toshiba RISC processor based o the MIPS 3900 core; + see . + Say Y here to direct console I/O to the on-board serial port. + +TMPTX3912/PR31700 frame buffer support +CONFIG_FB_TX3912 + The TX3912 is a Toshiba RISC processor based o the MIPS 3900 core; + see . + Say Y here to enable kernel support for the on-board framebebuffer. + +SGI WD93C93 SCSI Driver +CONFIG_SGIWD93_SCSI + If you have a Western Digital WD93 SCSI controller on + an SGI MIPS system, say Y. Otherwise, say N. + Magic System Request Key support CONFIG_MAGIC_SYSRQ If you say Y here, you will have some control over the system even @@ -18905,11 +18943,11 @@ CONFIG_ISDN_AUDIO If you say Y here, the modem-emulator will support a subset of the EIA Class 8 Voice commands. Using a getty with voice-support - (mgetty+sendfax by gert@greenie.muc.de with an extension, available - with the ISDN utility package for example), you will be able to use - your Linux box as an ISDN-answering machine. Of course, this must be - supported by the lowlevel driver also. Currently, the HiSax driver - is the only voice-supporting driver. See + (mgetty+sendfax by with an extension, + available with the ISDN utility package for example), you will be + able to use your Linux box as an ISDN-answering machine. Of course, + this must be supported by the lowlevel driver also. Currently, the + HiSax driver is the only voice-supporting driver. See for more information. X.25 PLP on top of ISDN @@ -19024,6 +19062,12 @@ Enable this if you like to use ISDN in US on a NI1 basic rate interface. +# 2.4 tree only +Maximum number of cards supported by HiSax +CONFIG_HISAX_MAX_CARDS + This is used to allocate a driver-internal structure array with one + entry for each HiSax card on your system. + Teles 16.0/8.0 CONFIG_HISAX_16_0 This enables HiSax support for the Teles ISDN-cards S0-16.0, S0-8 @@ -19240,7 +19284,7 @@ HiSax debugging CONFIG_HISAX_DEBUG This enables debugging code in the new-style HiSax drivers, i.e. - the ST5481 USB driver currently. + the ST5481 USB driver currently. If in doubt, say yes. ELSA PCMCIA MicroLink cards @@ -19253,7 +19297,7 @@ This enables the PCMCIA client driver for the Sedlbauer Speed Star and Speed Star II cards. -ST5481 USB ISDN adapter +ST5481 USB ISDN modem CONFIG_HISAX_ST5481 This enables the driver for ST5481 based USB ISDN adapters, e.g. the BeWan Gazel 128 USB @@ -19423,7 +19467,8 @@ to be downloaded into the card using a utility which is distributed separately from the Auvertech's web site: . - Please redirect all support questions to support@auvertech.fr. + Please redirect all support questions to + . If you want to compile this as a module ( = code which can be inserted in and removed from the running kernel whenever you want), @@ -19688,9 +19733,9 @@ # Choice: cf_area CompactFlash Connection Area CONFIG_CF_AREA5 - If your board has "Directly Connected" CompactFlash, You should + If your SuperH board has "Directly Connected" CompactFlash, you should select the area where your CF is connected to. - + - "Area5" if CompactFlash is connected to Area 5 (0x14000000) - "Area6" if it is connected to Area 6 (0x18000000) @@ -19767,6 +19812,12 @@ Q60. Select your CPU below. For 68LC060 don't forget to enable FPU emulation. +Q40/Q60 IDE interface support +CONFIG_BLK_DEV_Q40IDE + Enable the on-board IDE controller in the Q40/Q60. This should + normally be on; disable it only if you are running a custom hard + drive subsystem through an expansion card. + Sun 3 support CONFIG_SUN3 This option enables support for the Sun 3 series of workstations. @@ -19799,7 +19850,7 @@ CONFIG_SUN_KEYBOARD Say Y here to support the keyboard found on Sun 3 and 3x workstations. It can also be used support Sun Type-5 keyboards - through an adaptor. See + through an adapter. See and for details on the latter. @@ -20131,6 +20182,11 @@ want). The module is called hydra.o. If you want to compile it as a module, say M here and read . +Lasi ethernet +CONFIG_LASI_82596 + Say Y here to support the on-board Intel 82596 ethernet controller + built into Hewlett-Packard PA-RISC machines. + Sun3 NCR5380 SCSI CONFIG_SUN3_SCSI This option will enable support for the OBIO (onboard io) NCR5380 @@ -20375,7 +20431,7 @@ If in doubt, say N. -# Choice: Machine type +# Choice: ppc4xxtype Oak CONFIG_OAK Select Oak if you have an IBM 403GCX "Oak" Evaluation Board. @@ -20420,13 +20476,14 @@ If in doubt, say N here. -MPC8xx IDE support +MPC8xx direct IDE support on PCMCIA port CONFIG_BLK_DEV_MPC8xx_IDE This option provides support for IDE on Motorola MPC8xx Systems. Please see 'Type of MPC8xx IDE interface' for details. If unsure, say N. +# Choice: mpc8xxtype Type of MPC8xx IDE interface CONFIG_IDE_8xx_PCCARD Select how the IDE devices are connected to the MPC8xx system: @@ -20501,7 +20558,7 @@ More information is available at: . -AltiVec Kernel Support +AltiVec kernel support CONFIG_ALTIVEC This option enables kernel support for the Altivec extensions to the PowerPC processor. The kernel currently supports saving and restoring @@ -20542,11 +20599,12 @@ Average high and low temp CONFIG_TAU_AVERAGE - The TAU hardware can compare the temperature to an upper and lower bound. - The default behavior is to show both the upper and lower bound in - /proc/cpuinfo. If the range is large, the temperature is either changing - a lot, or the TAU hardware is broken (likely on some G4's). If the range - is small (around 4 degrees), the temperature is relatively stable. + The TAU hardware can compare the temperature to an upper and lower + bound. The default behavior is to show both the upper and lower + bound in /proc/cpuinfo. If the range is large, the temperature is + either changing a lot, or the TAU hardware is broken (likely on some + G4's). If the range is small (around 4 degrees), the temperature is + relatively stable. Power management support for PowerBooks CONFIG_PMAC_PBOOK @@ -20583,10 +20641,10 @@ Embedded Planet RPX Lite. PC104 form-factor SBC based on the MPC823. RPX-Classic: - Embedded Planet RPX Classic Low-fat. Credit-card-size SBC based on + Embedded Planet RPX Classic Low-fat. Credit-card-size SBC based on the MPC 860 - BSE-IP: + BSE-IP: Bright Star Engineering ip-Engine. TQM823L: @@ -20628,7 +20686,7 @@ URL: IVML24: - MPC860 based board used in the "Integrated Voice Mail System", + MPC860 based board used in the "Integrated Voice Mail System", Large Version (24 voice channels) Manufacturer: Speech Design, Date of Release: March 2001 (?) @@ -20637,7 +20695,8 @@ SM850: Service Module (based on TQM850L) - Manufacturer: Dependable Computer Systems, + Manufacturer: Dependable Computer Systems, + Date of Release: end 2000 (?) End of life: mid 2001 (?) URL: @@ -20659,8 +20718,11 @@ PCU_E: PCU = Peripheral Controller Unit, Extended - Manufacturer: Siemens AG, ICN (Information and Communication Networks) - + + Manufacturer: Siemens AG, ICN (Information and Communication + Networks) + + Date of Release: April 2001 End of life: August 2001 URL: n. a. @@ -20680,6 +20742,11 @@ 26MB DRAM, 4MB flash, Ethernet, a 16K-gate FPGA, USB, an LCD/video controller, and two RS232 ports. +FADS +CONFIG_FADS + Say Y here to support the PPC860-based FADS (Family Application + Development System) evaluation boards from Motorola. + TQM823L CONFIG_TQM823L Say Y here to support the TQM823L, one of an MPC8xx-based family of @@ -20716,8 +20783,8 @@ , and an image at . -FPS850 -CONFIG_FPS850 +FPS850L +CONFIG_FPS850L Say Y here to support the FingerPrint Sensor from AKENDI IG, based on the TQ Components TQM850L module, released November 1999 and discontinued a year later. @@ -20725,7 +20792,7 @@ TQM860 CONFIG_TQM860 Say Y here to support the TQM860, one of an MPC8xx-based family of - SBCs (credit-card size) from TQ Components first released in + SBCs (credit-card size) from TQ Components first released in mid-1999 and discontinued mid-2000. SM850 @@ -20767,7 +20834,7 @@ thin-client machines. Say Y to support it directly. # More systems that will be supported soon, according to -# Wolfgang Denk : +# Wolfgang Denk : # # TQM8260: # MPC8260 based module @@ -20857,11 +20924,11 @@ If unsure, say Y here. I2C/SPI Microcode Patch -UCODE_PATCH +CONFIG_UCODE_PATCH Motorola releases microcode updates for their 8xx CPM modules. The - microcode update file has updates for IIC, SMC and USB. Currently only - the USB update is available by default, if the MPC8xx USB option is - enabled. If in doubt, say 'N' here. + microcode update file has updates for IIC, SMC and USB. Currently + only the USB update is available by default, if the MPC8xx USB + option is enabled. If in doubt, say 'N' here. Mouse button 2+3 emulation support CONFIG_MAC_EMUMOUSEBTN @@ -20922,16 +20989,16 @@ MESH (Power Mac internal SCSI) support CONFIG_SCSI_MESH Many Power Macintoshes and clones have a MESH (Macintosh Enhanced - SCSI Hardware) SCSI bus adaptor (the 7200 doesn't, but all of the + SCSI Hardware) SCSI bus adapter (the 7200 doesn't, but all of the other Power Macintoshes do). Say Y to include support for this SCSI - adaptor. This driver is also available as a module called mesh.o + adapter. This driver is also available as a module called mesh.o ( = code which can be inserted in and removed from the running kernel whenever you want). If you want to compile it as a module, say M here and read . Maximum synchronous transfer rate (MB/s) (0 = async) CONFIG_SCSI_MESH_SYNC_RATE - On Power Macintoshes (and clones) where the MESH SCSI bus adaptor + On Power Macintoshes (and clones) where the MESH SCSI bus adapter drives a bus which is entirely internal to the machine (such as the 7500, 7600, 8500, etc.), the MESH is capable of synchronous operation at up to 10 MB/s. On machines where the SCSI bus @@ -20943,7 +21010,7 @@ 53C94 (Power Mac external SCSI) support CONFIG_SCSI_MAC53C94 On Power Macintoshes (and clones) with two SCSI buses, the external - SCSI bus is usually controlled by a 53C94 SCSI bus adaptor. Older + SCSI bus is usually controlled by a 53C94 SCSI bus adapter. Older machines which only have one SCSI bus, such as the 7200, also use the 53C94. Say Y to include support for the 53C94. @@ -21246,7 +21313,7 @@ Guillemot MAXI Radio FM 2000 Radio Card CONFIG_RADIO_MAXIRADIO Choose Y here if you have this radio card. This card may also be - found as Gemtek PCI FM. + found as GemTek PCI FM. In order to control your radio card, you will need to use programs that are compatible with the Video For Linux API. Information on @@ -21277,15 +21344,15 @@ CONFIG_RADIO_GEMTEK_PORT Enter either 0x20c, 0x30c, 0x24c or 0x34c here. The card default is 0x34c, if you haven't changed the jumper setting on the card. On - Sound Vision 16 Gold PnP with FM Radio (ESS1869+FM Gemtek), the I/O + Sound Vision 16 Gold PnP with FM Radio (ESS1869+FM GemTek), the I/O port is 0x28c. -Gemtek PCI Radio +GemTek PCI Radio Card support CONFIG_RADIO_GEMTEK_PCI Choose Y here if you have this PCI FM radio card. In order to control your radio card, you will need to use programs - that are compatible with the Video for Linux API. Information on + that are compatible with the Video for Linux API. Information on this API and pointers to "v4l" programs may be found on the WWW at . @@ -21312,7 +21379,7 @@ frequency control and muting works at least for me, but unfortunately I have not found anybody who wants to use this card with Linux. So if it is this what YOU are trying to do right now, - PLEASE DROP ME A NOTE!! Rolf Offermanns (rolf@offermanns.de) + PLEASE DROP ME A NOTE!! Rolf Offermanns () In order to control your radio card, you will need to use programs that are compatible with the Video For Linux API. Information on @@ -21358,7 +21425,7 @@ whenever you want). If you want to compile it as a module, say M here and read . -BT878 Audio DMA +BT878 audio DMA CONFIG_SOUND_BT878 Audio DMA support for bt878 based grabber boards. As you might have already noticed, bt878 is listed with two functions in /proc/pci. @@ -21396,6 +21463,18 @@ Say Y here to include support for the Iomega Buz video card. There is a Buz/Linux homepage at . +Miro DC10(+) support +CONFIG_VIDEO_ZORAN_DC10 + Say Y to support the Pinnacle Systems Studio DC10 plus TV/Video + card. Linux page at + . Vendor + page at . + +Linux Media Labs LML33 support +CONFIG_VIDEO_ZORAN_LML33 + Say Y here to support the Linux Media Labs LML33 TV/Video card. + Resources page is at . + Zoran ZR36120/36125 Video For Linux CONFIG_VIDEO_ZR36120 Support for ZR36120/ZR36125 based frame grabber/overlay boards. @@ -21437,7 +21516,7 @@ as a module (c-qcam.o). Read for more information. -Winbond W9966CF Webcam Video For Linux +Winbond W9966CF Webcam (FlyCam Supra and others) Video For Linux CONFIG_VIDEO_W9966 Video4linux driver for Winbond's w9966 based Webcams. Currently tested with the LifeView FlyCam Supra. @@ -21445,8 +21524,8 @@ otherwise say N. This driver is also available as a module (w9966.o). - Check out for more - information. + Check out and + for more information. CPiA Video For Linux CONFIG_VIDEO_CPIA @@ -21485,7 +21564,7 @@ it as a module, say M here and read . -Sony Vaio Picturebook Motion Eye Video for Linux +Sony Vaio Picturebook Motion Eye Video For Linux CONFIG_VIDEO_MEYE This is the video4linux driver for the Motion Eye camera found in the Vaio Picturebook laptops. Please read the material in @@ -21505,6 +21584,25 @@ mainframes of the S/390 generation. You should have installed the s390-compiler released by IBM (based on gcc-2.95.1) before. +VM pseudo page fault handling support using PFAULT +CONFIG_PFAULT + Select this option, if you want to use PFAULT pseudo page fault + handling under VM. If running native or in LPAR, this option + has no effect. If your VM does not support PFAULT, PAGEEX + pseudo page fault handling will be used. + Note that VM 4.2 supports PFAULT but has a bug in its + implementation that causes some problems. + Everybody who wants to run Linux under VM != VM4.2 should select + this option. + +VM shared kernel support +CONFIG_SHARED_KERNEL + Select this option, if you want to share the text segment of the + Linux kernel between different VM guests. This reduces memory + usage with lots of guests but greatly increases kernel size. + You should only select this option if you know what you are + doing and want to exploit this feature. + Merge some code into the kernel to make the image IPLable CONFIG_IPL If you want to use the produced kernel to IPL directly from a @@ -21518,56 +21616,34 @@ Select this option if you want to IPL the image from a Tape. IPL from a virtual card reader emulated by VM/ESA -CONFIG_IPL_RDR_VM +CONFIG_IPL_VM Select this option if you are running under VM/ESA and want to IPL the image from the emulated card reader. -IPL from a real card reader -CONFIG_IPL_RDR - Select this option if you want to IPL the image from a real - card reader. Maybe you still got one and want to try. We didn't - test. - Support for DASD hard disks CONFIG_DASD Enable this option if you want to access DASDs directly utilizing S/390s channel subsystem commands. This is necessary for running natively on a single image or an LPAR. -Enable DASD fast write -CONFIG_DASD_FAST_IO - Enable fast I/O for DASDs. That means that the next I/O command - is already issued at interrupt time, if an I/O request is pending. - This option gives significant speedup of I/O, because we don't - schedule the bottom-halves as often as Intel. - -Support for IBM-style disk-labels (S/390) -CONFIG_S390_PARTITION - Enable this option to assure standard IBM labels on the DASDs. - You must enable it, if you are planning to access DASDs also - attached to another IBM mainframe operation system (OS/390, - VM/ESA, VSE/ESA). - -ECKD devices +Support for ECKD hard disks CONFIG_DASD_ECKD - ECKD devices are the most commonly used devices. you should enable - this option unless you are very sure to have no ECKD device. + ECKD devices are the most commonly used devices. You should enable + this option unless you are very sure you have no ECKD device. -CKD devices -CONFIG_DASD_CKD - CKD devices are currently unsupported. +Automatic activation of ECKD module on DASD driver startup +CONFIG_DASD_AUTO_ECKD + Enable this option if you want your ECKD discipline module loaded + on DASD driver startup. -FBA devices +Support for FBA hard disks CONFIG_DASD_FBA FBA devices are currently unsupported. -Merge some code into the kernel to make the image IPLable -CONFIG_IPLABLE - If you want to use the produced kernel to IPL directly from a - device, you have to merge a bootsector specific to the device - into the first bytes of the kernel. You will have to select the - IPL device on another question, that pops up, when you select - CONFIG_IPLABE. +Automatic activation of FBA module on DASD driver startup +CONFIG_DASD_AUTO_FBA + Enable this option if you want your FBA discipline module loaded + on DASD driver startup. Support for 3215 line mode terminal CONFIG_TN3215 @@ -21592,6 +21668,16 @@ CONFIG_HWC Include support for IBM HWC line-mode terminals. +HWC Control-Program Identification +CONFIG_HWC_CPI + This option enables the hardware console interface for system + identification This is commonly used for workload management and + gives you a nice name for the system on the service element. + Please select this option as a module since built-in operation is + completely untested. + You should only select this option if you know what you are doing, + need this feature and intend to run your kernel in LPAR. + Console on HWC line mode terminal CONFIG_HWC_CONSOLE Include support for using an IBM HWC line-mode terminal as the Linux @@ -21651,6 +21737,11 @@ with the Diagnose250 command. If you are not running under VM or unsure what it is, say "N". +Automatic activation of DIAG module on DASD driver startup +CONFIG_DASD_AUTO_DIAG + Enable this option if you want your DIAG discipline module loaded + on DASD driver startup. + XPRAM disk support CONFIG_BLK_DEV_XPRAM Select this option if you want to use your expanded storage on S/390 @@ -21801,6 +21892,12 @@ Saying N will reduce the size of the Footbridge kernel. +Integrator +CONFIG_ARCH_INTEGRATOR + The ARM Integrator family is a line of SBCs for embedded systems + designed by Bluewater Systems; home page, with board pictures, at + + LinkUp Systems L7200 SDB CONFIG_ARCH_L7200 Say Y here if you intend to run this kernel on a LinkUp Systems @@ -21810,7 +21907,7 @@ If you have any questions or comments about the Linux kernel port - to this board, send e-mail to sjhill@cotw.com. + to this board, send e-mail to . NetWinder CONFIG_ARCH_NETWINDER @@ -21840,7 +21937,26 @@ If you have any questions or comments about the Compaq Personal - Server, send e-mail to skiff@crl.dec.com. + Server, send e-mail to . + +Cirrus Logic EDB-7211 evaluation board +CONFIG_ARCH_EDB7211 + Say Y here if you intend to run this kernel on a Cirrus Logic EDB-7211 + evaluation board. + +EP7211 infrared support +CONFIG_EP7211_IR + Say Y here if you wish to use the infrared port on the EP7211. Note + that you can't use the first UART and the infrared port at the same + time, and that the EP7211 only supports SIR mode, at speeds up to + 115.2 kbps. To use the I/R port, you will need to get the source to + irda-utils and apply the patch at + . + +SA1100 Internal IR +CONFIG_SA1100_FIR + Say Y here to enable the on-board IRDA device on a Intel(R) + StrongARM(R) SA-1110 based microporocessor. Assabet CONFIG_SA1100_ASSABET @@ -21877,23 +21993,85 @@ CONFIG_SA1100_GRAPHICSCLIENT Say Y here if you are using an Applied Data Systems Intel(R) StrongARM(R) SA-1100 based Graphics Client SBC. See - for information on this system. + for information on this system. + +GraphicsMaster +CONFIG_SA1100_GRAPHICSMASTER + Say Y here if you are using an Applied Data Systems Intel(R) + StrongARM(R) SA-1100 based Graphics Master SBC with SA-1111 + StrongARM companion chip. See + for information + on this system. + +ADS Bitsy +CONFIG_SA1100_ADSBITSY + Say Y here if you are using Applied Data Systems Intel(R) + StrongARM(R) 1110 based Bitsy, 3 x 5 inches in size, Compaq - IPAQ - + like platform. See + for more + information. + +Itsy +CONFIG_SA1100_ITSY + Say Y here if you are using the Compaq Itsy experimental pocket + computer. See for + more information. + +HuW WebPanel +CONFIG_SA1100_HUW_WEBPANEL + Say Y here to support the HuW Webpanel produced by Hoeft & Wessel + AG. English-language website is at + ; credits and build instructions + at . + +PLEB +CONFIG_SA1100_PLEB + Say Y here if you are using a Portable Linux Embedded Board + (also known as PLEB). See + for more information. + +Sherman +CONFIG_SA1100_SHERMAN + Say Y here to support the Blazie Engineering `Sherman' StrongARM + 1110-based SBC, used primarily in assistance products for the + visually impaired. The company is now Freedom Scientific, with + a website at . The + Sherman product, however, appears to have been discontinued. + +Yopy +CONFIG_SA1100_YOPY + Say Y here to support the Yopy PDA. Product information at + . See + for more. CerfBoard CONFIG_SA1100_CERF The Intrinsyc CerfBoard is based on the StrongARM 1110. More information is available at: . + Build instructions at . Say Y if configuring for an Intrinsyc CerfBoard. Say N otherwise. +Cerf w/CPLD support (CerfPDA) +CONFIG_SA1100_CERF_CPLD + Say Y here to support the Linux CerfPDA development kit from + Intrinsyc. This is a StrongARM-1110-based reference platform for + designing custom PDAs. Product info is at + . + FlexaNet CONFIG_SA1100_FLEXANET Say Y here if you intend to run this kernel on the FlexaNet handheld instruments. Information about this machine can be found at: . +FreeBird-v1.1 +CONFIG_SA1100_FREEBIRD + Support the FreeBird board used in Coventive embedded products. See + . + nanoEngine CONFIG_SA1100_NANOENGINE The nanoEngine is a StrongARM 1110-based single board computer @@ -21920,6 +22098,38 @@ for information on this system. +# Choice: cerf_ram +Cerf on-board RAM size +CONFIG_SA1100_CERF_8MB + Declare the size of the CerfBoard's on-board RAM. + Alternatives are 8, 16, 32, and 64MB. + +16MB +CONFIG_SA1100_CERF_16MB + Declare that the CerfBoard has 16MB RAM. + +32MB +CONFIG_SA1100_CERF_32MB + Declare that the CerfBoard has 32MB RAM. + +64MB +CONFIG_SA1100_CERF_64MB + Declare that the CerfBoard has 64MB RAM. + +# Choice: cerf_flash +Cerf flash memory size +CONFIG_SA1100_CERF_FLASH_8MB + Tell the Cerf kernel the size of on-board memory. The choices + are 8MB, 16MB, or 32MB. + +16MB +CONFIG_SA1100_CERF_FLASH_16MB + Configure the Cerf kernel to expect 16MB of flash memory. + +32MB +CONFIG_SA1100_CERF_FLASH_32MB + Configure the Cerf kernel to expect 32MB of flash memory. + Support ARM610 processor CONFIG_CPU_ARM610 The ARM610 is the successor to the ARM3 processor @@ -21955,6 +22165,15 @@ Say Y if you want support for the ARM920T processor. Otherwise, say N. +Support ARM926T processor +CONFIG_CPU_ARM926T + This is a variant of the ARM920. It has slightly different + instruction sequences for cache and TLB operations. Curiously, + there is no documentation on it at the ARM corporate website. + + Say Y if you want support for the ARM926T processor. + Otherwise, say N. + Support ARM1020 processor CONFIG_CPU_ARM1020 The ARM1020 is the cached version of the ARM10 processor, @@ -21963,6 +22182,81 @@ Say Y if you want support for the ARM1020 processor. Otherwise, say N. +Enable ARM920T instruction cache +CONFIG_CPU_ARM920_I_CACHE_ON + Say Y here to enable the processor instruction cache. Unless + you have a reason not to, say Y. + +Enable ARM920T data cache +CONFIG_CPU_ARM920_D_CACHE_ON + Say Y here to enable the processor data cache. Unless + you have a reason not to, say Y. + +Use ARM920T data cache in writethrough mode +CONFIG_CPU_ARM920_WRITETHROUGH + Say Y here to use the data cache in writethough mode. Unless you + specifically require this, say N. + +Enable ARM926T instruction cache +CONFIG_CPU_ARM926_I_CACHE_ON + Say Y here to enable the processor instruction cache. Unless + you have a reason not to, say Y. + +Enable ARM926T data cache +CONFIG_CPU_ARM926_D_CACHE_ON + Say Y here to enable the processor data cache. Unless + you have a reason not to, say Y. + +Use ARM926T data cache in writethrough mode +CONFIG_CPU_ARM926_WRITETHROUGH + Say Y here to use the data cache in writethough mode. Unless you + specifically require this, say N. + +Enable ARM1020T instruction cache +CONFIG_CPU_ARM1020_I_CACHE_ON + Say Y here to enable the processor instruction cache. Unless + you have a reason not to, say Y. + +Enable ARM1020T data cache +CONFIG_CPU_ARM1020_D_CACHE_ON + Say Y here to enable the processor data cache. Unless + you have a reason not to, say Y. + +Use ARM1020T data cache in writethrough mode +CONFIG_CPU_ARM1020_FORCE_WRITE_THROUGH + Say Y here to use the data cache in writethough mode. Unless you + specifically require this, say N. + +ARM920T CPU idle +CONFIG_CPU_ARM920_CPU_IDLE + Say Y to allow the idle task to power down an ARM920T CPU until the + next interrupt from a peripheral or the timer. This saves power, + and you should normally enable it. + +ARM926T CPU idle +CONFIG_CPU_ARM926_CPU_IDLE + Say Y to allow the idle task to power down an ARM926T CPU until the + next interrupt from a peripheral or the timer. This saves power, + and you should normally enable it. + +ARM1020 CPU idle +CONFIG_CPU_ARM1020_CPU_IDLE + Say Y to allow the idle task to power down an ARM1020T CPU until the + next interrupt from a peripheral or the timer. This saves power, + and you should normally enable it. + +Round robin I and D cache replacement algorithm +CONFIG_CPU_ARM926_ROUND_ROBIN + Disable the normal speculative caching (non-blocking + "hit-under-miss" operation) and fall back to a round-robin + cache-replenishment algorithm. + +Round robin I and D cache replacement algorithm +CONFIG_CPU_ARM1020_ROUND_ROBIN + Disable the normal speculative caching (non-blocking + "hit-under-miss" operation) and fall back to a round-robin + cache-replenishment algorithm. + Support StrongARM SA-110 processor CONFIG_CPU_SA110 The Intel StrongARM(R) SA-110 is a 32-bit microprocessor and @@ -21973,6 +22267,59 @@ Say Y if you want support for the SA-110 processor. Otherwise, say N. +Tulsa +CONFIG_SA1100_PFS168 + The Radisys Corp. PFS-168 (aka Tulsa) is an Intel® StrongArm® + SA-1110 based computer which includes the SA-1111 Microprocessor + Companion Chip and other custom I/O designed to add connectivity and + multimedia features for vending and business machine + applications. Say Y here if you require support for this target. + +HP Jornada 720 +CONFIG_SA1100_JORNADA720 + Say Y here if you want to build a kernel for the HP Jornada 720 + handheld computer. See + for details. + +InHand Electronics OmniMeter +CONFIG_SA1100_OMNIMETER + Say Y here if you are using the inhand electronics OmniMeter. See + for details. + +SIMpad +CONFIG_SA1100_SIMPAD + The SIEMENS webpad SIMpad is based on the StrongARM 1110. There + are two different versions CL4 and SL4. CL4 has 32MB RAM and 16MB + FLASH. The SL4 version got 64 MB RAM and 32 MB FLASH and a + PCMCIA-Slot. The version for the Germany Telecom (DTAG) is the same + like CL4 in additional it has a PCMCIA-Slot. For more information + visit . + +Load kernel using Angel Debug Monitor +CONFIG_ANGELBOOT + Say Y if you plan to load the kernel using Angel, ARM Ltd's target + debug stub. If you are not using Angel, you must say N. It is + important to get this setting correct. + +CDB89712 +CONFIG_ARCH_CDB89712 + This is an evaluation board from Cirrus for the CS89712 processor. + The board includes 2 serial ports, Ethernet, IRDA, and expansion + headers. It comes with 16 MB SDRAM and 8 MB flash ROM. + +CLPS-711X internal ROM bootstrap +CONFIG_EP72XX_ROM_BOOT + If you say Y here, your CLPS711x-based kernel will use the bootstrap + mode memory map instead of the normal memory map. + + Processors derived from the Cirrus CLPS-711X core support two boot + modes. Normal mode boots from the external memory device at CS0. + Bootstrap mode rearranges parts of the memory map, placing an + internal 128 byte bootstrap ROM at CS0. This option performs the + address map changes required to support booting in this mode. + + You almost surely want to say N here. + Math emulation CONFIG_FPE_NWFPE Say Y to include the NWFPE floating point emulator in the kernel. @@ -22117,76 +22464,6 @@ If you have enabled the serial port on the 21285 footbridge you can make it the console by answering Y to this option. -SA1100 serial port support -CONFIG_SERIAL_SA1100 - * Orphaned entry retained 20 April 2001 by Russell King * - * If you read this note from the configurator, please contact * - * the Configure.help maintainers. * - If you have a machine based on a SA1100/SA1110 StrongARM CPU you can - enable its onboard serial port by enabling this option. - Please read for further - info. - -Console on SA1100 serial port -CONFIG_SERIAL_SA1100_CONSOLE - * Orphaned entry retained 20 April 2001 by Russell King * - * If you read this note from the configurator, please contact * - * the Configure.help maintainers. * - If you have enabled the serial port on the SA1100/SA1110 StrongARM - CPU you can make it the console by answering Y to this option. - -L7200 serial port support -CONFIG_SERIAL_L7200 - * Orphaned entry retained 20 April 2001 by Russell King * - * If you read this note from the configurator, please contact * - * the Configure.help maintainers. * - If you have a LinkUp Systems L7200 board you can enable its two - onboard serial ports by enabling this option. The device numbers - are major ID 4 with minor 64 and 65 respectively. - -Console on L7200 serial port -CONFIG_SERIAL_L7200_CONSOLE - * Orphaned entry retained 20 April 2001 by Russell King * - * If you read this note from the configurator, please contact * - * the Configure.help maintainers. * - If you have enabled the serial ports on the L7200 development board - you can make the first serial port the console by answering Y to - this option. - -L7200 SDB keyboard support -CONFIG_KEYBOARD_L7200 - * Orphaned entry retained 20 April 2001 by Russell King * - * If you read this note from the configurator, please contact * - * the Configure.help maintainers. * - Enable this option if you would like to be able to use a keyboard - on a LinkUp Systems L7200 board. - -L7200 SDB Fujitsu keyboard support -CONFIG_KEYBOARD_L7200_NORM - * Orphaned entry retained 20 April 2001 by Russell King * - * If you read this note from the configurator, please contact * - * the Configure.help maintainers. * - Select the Fujitsu keyboard if you want a normal QWERTY style - keyboard on the LinkUp SDB. - -L7200 SDB Prototype keyboard support -CONFIG_KEYBOARD_L7200_DEMO - * Orphaned entry retained 20 April 2001 by Russell King * - * If you read this note from the configurator, please contact * - * the Configure.help maintainers. * - Select the prototype keyboard if you want to play with the - LCD/keyboard combination on the LinkUp SDB. - -Footbridge Mode -CONFIG_HOST_FOOTBRIDGE - * Orphaned entry retained 20 April 2001 by Russell King * - * If you read this note from the configurator, please contact * - * the Configure.help maintainers. * - The 21285 Footbridge chip can operate in either `host mode' or - `add-in' mode. Say Y if your 21285 is in host mode, and therefore - is the configuration master, otherwise say N. This must not be - set to Y if the card is used in 'add-in' mode. - MFM hard disk support CONFIG_BLK_DEV_MFM Support the MFM hard drives on the Acorn Archimedes both @@ -22275,11 +22552,11 @@ Ultra (connectionless) protocol CONFIG_IRDA_ULTRA - Say Y here to support the connectionless Ultra IRDA protocol. - Ultra allows to exchange data over IrDA with really simple devices - (watch, beacon) without the overhead of the IrDA protocol (no handshaking, - no management frames, simple fixed header). - Ultra is available as a special socket : socket(AF_IRDA, SOCK_DGRAM, 1); + Say Y here to support the connectionless Ultra IRDA protocol. Ultra + allows to exchange data over IrDA with really simple devices (watch, + beacon) without the overhead of the IrDA protocol (no handshaking, + no management frames, simple fixed header). Ultra is available as a + special socket: socket(AF_IRDA, SOCK_DGRAM, 1); IrDA cache last LSAP CONFIG_IRDA_CACHE_LAST_LSAP @@ -22314,10 +22591,9 @@ CONFIG_IRDA_DEBUG Say Y here if you want the IrDA subsystem to write debug information to your syslog. You can change the debug level in - /proc/sys/net/irda/debug . - When this option is enabled, the IrDA also perform many extra internal - verifications which will usually prevent the kernel to crash in case of - bugs. + /proc/sys/net/irda/debug . When this option is enabled, the IrDA + also perform many extra internal verifications which will usually + prevent the kernel to crash in case of bugs. If unsure, say Y (since it makes it easier to find the bugs). @@ -22397,6 +22673,27 @@ Please note that the driver is still experimental. And of course, you will need both USB and IrDA support in your kernel... +Datafab MDCFE-B Compact Flash Reader support +CONFIG_USB_STORAGE_DATAFAB + This option enables a sub-driver of the USB Mass Storage driver. + These sub-drivers are considered experimental, and should only be + used by very brave people. System crashes and other bad things are + likely to occur if you use this driver. If in doubt, select N. + +HP CD-Writer 82xx support +CONFIG_USB_STORAGE_HP8200e + This option enables a sub-driver of the USB Mass Storage driver. + These sub-drivers are considered experimental, and should only be + used by very brave people. System crashes and other bad things are + likely to occur if you use this driver. If in doubt, select N. + +Lexar Jumpshot Compact Flash Reader +CONFIG_USB_STORAGE_JUMPSHOT + This option enables a sub-driver of the USB Mass Storage driver. + These sub-drivers are considered experimental, and should only be + used by very brave people. System crashes and other bad things are + likely to occur if you use this driver. If in doubt, select N. + Winbond W83977AF IrDA Device Driver CONFIG_WINBOND_FIR Say Y here if you want to build IrDA support for the Winbond @@ -22418,13 +22715,18 @@ . The module will be called nsc-ircc.o. -National Semiconductor DP83820 series driver +National Semiconductor DP83820 support CONFIG_NS83820 This is a driver for the National Semiconductor DP83820 series - of gigabit ethernet MACs. Cards using this chipset include - the D-Link DGE-500T, PureData's PDP8023Z-TG, SMC's SMC9462TX, - SOHO-GA2000T, SOHO-GA2500T. The driver supports the use of - zero copy. + of gigabit ethernet MACs. Cards using this chipset include: + + SMC 9452TX SMC SMC9462TX + D-Link DGE-500T PureData PDP8023Z-TG + SOHO-GA2000T SOHO-GA2500T. + NetGear GA621 + + This driver supports the use of zero copy on tx, checksum + validation on rx, and 64 bit addressing. Toshiba Type-O IR Port device driver CONFIG_TOSHIBA_FIR @@ -22442,7 +22744,7 @@ here and read . The module will be called smc-ircc.o. -ALi M5123 FIR Controller Driver +ALi M5123 FIR controller driver CONFIG_ALI_FIR Say Y here if you want to build support for the ALi M5123 FIR Controller. The ALi M5123 FIR Controller is embedded in ALi M1543C, @@ -22453,7 +22755,7 @@ . The module will be called ali-ircc.o. -VLSI 82C147 PCI-IrDA Controller Driver +VLSI 82C147 PCI-IrDA SIR/MIR/FIR Controller driver CONFIG_VLSI_FIR Say Y here if you want to build support for the VLSI 82C147 PCI-IrDA Controller. This controller is used by the HP OmniBook 800 @@ -22664,6 +22966,15 @@ CONFIG_ETRAX_FLASH_BUSWIDTH Width in bytes of the Flash bus (1, 2 or 4). Is usually 2. +Root filesystem device +CONFIG_ETRAX_ROOT_DEVICE + Specifies the device that should be mounted as root filesystem + when booting from flash. The axisflashmap driver adds an additional + mtd partition for the appended root filesystem image, so this option + should normally be the mtdblock device for the partition after the + last partition in the partition table. + +# Choice: crisleds LED configuration on PA CONFIG_ETRAX_PA_LEDS The Etrax network driver is responsible for flashing LED's when @@ -22812,14 +23123,27 @@ For products with only one or two controllable LEDs, set this to same as CONFIG_ETRAX_LED1G (normally 2). -Flash LED off during activity -CONFIG_ETRAX_LED_OFF_DURING_ACTIVITY - This option allows you to decide whether the network LED (and - Bluetooth LED in case you use Bluetooth) will be on or off when - the network is connected, and whether it should flash off or on - when there is activity. If you say y to this option the network - LED will be lit when there is a connection, and will flash off - when there is activity. +LED on when link +CONFIG_ETRAX_NETWORK_LED_ON_WHEN_LINK + Selecting LED_on_when_link will light the LED when there is a + connection and will flash off when there is activity. + + Selecting LED_on_when_activity will light the LED only when + there is activity. + + This setting will also affect the behaviour of other activity LEDs + e.g. Bluetooth. + +LED on when activity +CONFIG_ETRAX_NETWORK_LED_ON_WHEN_ACTIVITY + Selecting LED_on_when_link will light the LED when there is a + connection and will flash off when there is activity. + + Selecting LED_on_when_activity will light the LED only when + there is activity. + + This setting will also affect the behaviour of other activity LEDs + e.g. Bluetooth. PA button configuration CONFIG_ETRAX_PA_BUTTON_BITMASK @@ -22945,9 +23269,24 @@ Etrax General port B data CONFIG_ETRAX_DEF_R_PORT_PB_DATA - Configures the initial data for the general port A bits. Most + Configures the initial data for the general port B bits. Most products should use FF here. +Software Shutdown Support +CONFIG_ETRAX_SOFT_SHUTDOWN + Enable this if Etrax is used with a power-supply that can be turned + off and on with PS_ON signal. Gives the possibility to detect + powerbutton and then do a power off after unmounting disks. + +Shutdown bit on port CSP0 +CONFIG_ETRAX_SHUTDOWN_BIT + Configure what pin on CSPO-port that is used for controlling power + supply. + +Power button bit on port G +CONFIG_ETRAX_POWERBUTTON_BIT + Configure where power button is connected. + Etrax General port device CONFIG_ETRAX_GPIO Enables the Etrax general port device (major 120, minors 0 and 1). @@ -22961,28 +23300,11 @@ Remember that you need to setup the port directions appropriately in the General configuration. -Etrax parallel data support -CONFIG_ETRAX_PARDATA - Adds support for writing data to the parallel port par0 of the ETRAX - 100. If you create a character special file with major number 126, - you can write to the data bits of par0. - Note: you need to disable Etrax100 parallel port support. - -Etrax parallel LCD (HD44780) Driver -CONFIG_ETRAX_LCD_HD44780 - Adds support for a HD44780 controlled LCD connected to the parallel - port par0 of the Etrax. - Etrax Serial port ser0 support CONFIG_ETRAX_SERIAL Enables the ETRAX 100 serial driver for ser0 (ttyS0) You probably want this enabled. -/proc/serial entry -CONFIG_ETRAX_SERIAL_PROC_ENTRY - Enables /proc/serial entry where errors and statistics can be - viewed. CONFIG_PROC_FS must also be set for this to work. - Etrax Serial port fast flush of DMA using fast timer API CONFIG_ETRAX_SERIAL_FAST_TIMER Select this to have the serial DMAs flushed at a higher rate than @@ -22990,20 +23312,26 @@ approx. 4 character times. If unsure, say N. -Etrax Serial port fast flush of DMA +Fast serial port DMA flush CONFIG_ETRAX_SERIAL_FLUSH_DMA_FAST Select this to have the serial DMAs flushed at a higher rate than normally possible through a fast timer interrupt (currently at 15360 Hz). If unsure, say N. -Etrax Serial port receive flush timeout +Etrax serial port receive flush timeout (ticks) CONFIG_ETRAX_SERIAL_RX_TIMEOUT_TICKS Number of timer ticks between flush of receive fifo (1 tick = 10ms). Try 0-3 for low latency applications. Approx 5 for high load applications (e.g. PPP). Maybe this should be more adaptive some day... +Etrax Serial port ser0 support +CONFIG_ETRAX_SERIAL_PORT0 + Enables the ETRAX 100 serial driver for ser0 (ttyS0) + Normally you want this on, unless you use external DMA 1 that uses + the same DMA channels. + Etrax Serial port ser0 DTR, RI, DSR and CD support on PB CONFIG_ETRAX_SER0_DTR_RI_DSR_CD_ON_PB Enables the status and control signals DTR, RI, DSR and CD on PB for @@ -23148,6 +23476,7 @@ CONFIG_ETRAX_I2C_EEPROM_8KB Use a 8kB EEPROM. +# Choice: etrax_eeprom Etrax100 I2C EEPROM (NVRAM) size/probe CONFIG_ETRAX_I2C_EEPROM_PROBE Specifies size or auto probe of the EEPROM size. @@ -23187,22 +23516,25 @@ This is the bit number for the SDA signal line of the DS1302 RTC on Port PB. This is probably best left at 2. -Etrax 100 IDE Reset -CONFIG_ETRAX_IDE_CSP0_8_RESET - Configures the pin used to reset the IDE bus. +Etrax 100 ATA/IDE support +CONFIG_ETRAX_IDE + Enable this to get support for ATA/IDE. You can't use parallel + ports or SCSI ports at the same time. + +Delay for IDE drives to regain consciousness +CONFIG_ETRAX_IDE_DELAY + Number of seconds to wait for IDE drives to spin up after an IDE + reset. Etrax 100 IDE Reset -CONFIG_ETRAX_IDE_CSPE1_16_RESET +CONFIG_ETRAX_IDE_CSP0_8_RESET Configures the pin used to reset the IDE bus. -Etrax 100 ATA/IDE support -CONFIG_ETRAX_IDE_DELAY - Sets the time to wait for disks to regain consciousness after reset. - Etrax 100 IDE Reset CONFIG_ETRAX_IDE_G27_RESET Configures the pin used to reset the IDE bus. +# Choice: ide_reset IDE reset on PB Bit 7 CONFIG_ETRAX_IDE_PB7_RESET Configures the pin used to reset the IDE bus. @@ -23227,6 +23559,16 @@ This option enables the ETRAX 100LX built-in 10/100Mbit Ethernet controller. +Etrax Ethernet slave support (over lp0/1) +CONFIG_ETRAX_ETHERNET_LPSLAVE + This option enables a slave ETRAX 100 or ETRAX 100LX, connected to a + master ETRAX 100 or ETRAX 100LX through par0 and par1, to act as an + Ethernet controller. + +ETRAX 100 Ethernet slave controller LEDS +CONFIG_ETRAX_ETHERNET_LPSLAVE_HAS_LEDS + Enable if the slave has it's own LEDs. + ETRAX 100LX Synchronous serial ports CONFIG_ETRAX_SYNCHRONOUS_SERIAL This option enables support for the ETRAX 100LX built-in @@ -23251,11 +23593,6 @@ CONFIG_ETRAX_SYNCHRONOUS_SERIAL1_DMA Makes synchronous serial port 1 use DMA. -Delay for drives to regain consciousness -CONFIG_IDE_DELAY - Number of seconds to wait for IDE drives to spin up after an IDE - reset. - ARTPEC-1 support CONFIG_JULIETTE The ARTPEC-1 is a video-compression chip used in the AXIS 2100 @@ -23411,42 +23748,6 @@ with a B-step CPU. You have a B-step CPU if the "revision" field in /proc/cpuinfo has a value in the range from 1 to 4. -Enable Itanium B0-step specific code -CONFIG_ITANIUM_B0_SPECIFIC - Select this option to build a kernel for an Itanium prototype system - with a B0-step CPU. You have a B0-step CPU if the "revision" field - in /proc/cpuinfo is 1. - -Enable Itanium C-step specific code -CONFIG_ITANIUM_CSTEP_SPECIFIC - Select this option to build a kernel for an Itanium prototype system - with a C-step CPU. You have a C-step CPU if the "revision" field in - /proc/cpuinfo is in the range of 5 to 8. - -Enable Itanium B1-step specific code -CONFIG_ITANIUM_B1_SPECIFIC - Select this option to build a kernel for an Itanium prototype system - with a B1-step CPU. You have a B1-step CPU if the "revision" field - in /proc/cpuinfo is 2. - -Enable Itanium B2-step specific code -CONFIG_ITANIUM_B2_SPECIFIC - Select this option to build a kernel for an Itanium prototype system - with a B2-step CPU. You have a B2-step CPU if the "revision" field - in /proc/cpuinfo is 3. - -Enable Itanium C0-step specific code -CONFIG_ITANIUM_C0_SPECIFIC - Select this option to build a kernel for an Itanium prototype system - with a C0-step CPU. You have a C0-step CPU if the "revision" field - in /proc/cpuinfo is 5. - -Force interrupt redirection -CONFIG_IA64_HAVE_IRQREDIR - Select this option if you know that your system has the ability to - redirect interrupts to different CPUs. Select N here if you're - unsure. - Enable IA-64 Machine Check Abort CONFIG_IA64_MCA Say Y here to enable machine check support for IA-64. If you're @@ -23529,6 +23830,44 @@ To use this option, you have to check that the "/proc file system support" (CONFIG_PROC_FS) is enabled, too. +16MB granules +CONFIG_IA64_GRANULE_16MB + IA64 identity-mapped regions use a large page size. We'll call such + large pages "granules". If you can think of a better name that's + unambiguous, let us know... Unless your identity-mapped regions are + very large, select a granule size of 16MB. + +64MB granules +CONFIG_IA64_GRANULE_64MB + IA64 identity-mapped regions use a large page size. We'll call such + large pages "granules". If you can think of a better name that's + unambiguous, let us know... Unless your identity-mapped regions are + very large, select a granule size of 16MB. (This is the "large" + choice.) + +Enable SGI SN extra debugging code +CONFIG_IA64_SGI_SN_DEBUG + Turns on extra debugging code in the SGI SN (Scalable NUMA) platform + for IA64. Unless you are debugging problems on an SGI SN IA64 box, + say N. + +Enable SGI Medusa Simulator Support +CONFIG_IA64_SGI_SN_SIM + If you are compiling a kernel that will run under SGI's IA64 + simulator (Medusa) then say Y, otherwise say N. + +PCIBA support +CONFIG_PCIBA + IRIX PCIBA-inspired user mode PCI interface for the SGI SN (Scalable + NUMA) platform for IA64. Unless you are compiling a kernel for an + SGI SN IA64 box, say N. + +Enable protocol mode for the L1 console +SERIAL_SGI_L1_PROTOCOL + Uses protocol mode instead of raw mode for the level 1 console on the + SGI SN (Scalable NUMA) platform for IA64. If you are compiling for + an SGI SN box then Y is the recommended value, otherwise say N. + Directly Connected Compact Flash support CONFIG_CF_ENABLER Compact Flash is a small, removable mass storage device introduced @@ -23554,7 +23893,7 @@ allocation as well as poisoning memory on free to catch use of freed memory. -Memory mapped I/O debug support +Memory mapped I/O debugging CONFIG_DEBUG_IOVIRT Say Y here to get warned whenever an attempt is made to do I/O on obviously invalid addresses such as those generated when ioremap() @@ -23570,6 +23909,19 @@ best used in conjunction with the NMI watchdog so that spinlock deadlocks are also debuggable. +Read-write spinlock debugging +CONFIG_DEBUG_RWLOCK + If you say Y here then read-write lock processing will count how many + times it has tried to get the lock and issue an error message after + too many attempts. If you suspect a rwlock problem or a kernel + hacker asks for this option then say Y. Otherwise say N. + +Semaphore debugging +CONFIG_DEBUG_SEMAPHORE + If you say Y here then semaphore processing will issue lots of + verbose debugging messages. If you suspect a semaphore problem or a + kernel hacker asks for this option then say Y. Otherwise say N. + Verbose BUG() reporting (adds 70K) CONFIG_DEBUG_BUGVERBOSE Say Y here to make BUG() panics output the file name and line number @@ -23726,18 +24078,12 @@ SolutionEngine CONFIG_SH_SOLUTION_ENGINE Select SolutionEngine if configuring for a Hitachi SH7709 - or SH7750 evalutation board. + or SH7750 evaluation board. 7751 SolutionEngine CONFIG_SH_7751_SOLUTION_ENGINE Select 7751 SolutionEngine if configuring for a Hitachi SH7751 - evalutation board. - -Overdrive -CONFIG_SH_OVERDRIVE - Select Overdrive if configuring for a ST407750 Overdrive board. - More information at - . + evaluation board. HP620 CONFIG_SH_HP620 @@ -23827,7 +24173,7 @@ CONFIG_MEMORY_START Computers built with Hitachi SuperH processors always map the ROM starting at address zero. But the processor - does not specify the range that RAM takes. + does not specify the range that RAM takes. The physical memory (RAM) start address will be automatically set to 08000000, unless you selected one of the following @@ -23887,7 +24233,7 @@ The default setting of the HD64465 IO base address is 0xb0000000. Do not change this unless you know what you are doing. - + Early printk support CONFIG_SH_EARLY_PRINTK Say Y here to redirect kernel printk messages to the serial port @@ -24258,5 +24604,6 @@ # case-fold-search:nil # fill-prefix:" " # adaptive-fill:nil +# compile-command: "egrep -n '^ .{71,}' Configure.help /dev/null" # fill-column:70 # End: diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/Documentation/DMA-mapping.txt linux-2.5/Documentation/DMA-mapping.txt --- linux-2.5.1/Documentation/DMA-mapping.txt Fri Oct 12 22:35:53 2001 +++ linux-2.5/Documentation/DMA-mapping.txt Thu Dec 27 16:32:30 2001 @@ -686,6 +686,97 @@ This is possible with the DAC interfaces purely because they are not translated in any way. + Optimizing Unmap State Space Consumption + +On many platforms, pci_unmap_{single,page}() is simply a nop. +Therefore, keeping track of the mapping address and length is a waste +of space. Instead of filling your drivers up with ifdefs and the like +to "work around" this (which would defeat the whole purpose of a +portable API) the following facilities are provided. + +Actually, instead of describing the macros one by one, we'll +transform some example code. + +1) Use DECLARE_PCI_UNMAP_{ADDR,LEN} in state saving structures. + Example, before: + + struct ring_state { + struct sk_buff *skb; + dma_addr_t mapping; + __u32 len; + }; + + after: + + struct ring_state { + struct sk_buff *skb; + DECLARE_PCI_UNMAP_ADDR(mapping) + DECLARE_PCI_UNMAP_LEN(len) + }; + + NOTE: DO NOT put a semicolon at the end of the DECLARE_*() + macro. + +2) Use PCI_UNMAP_{ADDR,LEN}_SET to set these values. + Example, before: + + ringp->mapping = FOO; + ringp->len = BAR; + + after: + + PCI_UNMAP_ADDR_SET(ringp, mapping, FOO); + PCI_UNMAP_LEN_SET(ringp, len, BAR); + +3) Use PCI_UNMAP_{ADDR,LEN} to access these values. + Example, before: + + pci_unmap_single(pdev, ringp->mapping, ringp->len, + PCI_DMA_FROMDEVICE); + + after: + + pci_unmap_single(pdev, + PCI_UNMAP_ADDR(ringp, mapping), + PCI_UNMAP_LEN(ringp, len), + PCI_DMA_FROMDEVICE); + +It really should be self-explanatory. We treat the ADDR and LEN +seperately, because it is possible for an implementation to only +need the address in order to perform the unmap operation. + + Platform Issues + +If you are just writing drivers for Linux and do not maintain +an architecture port for the kernel, you can safely skip down +to "Closing". + +1) Struct scatterlist requirements. + + Struct scatterlist must contain, at a minimum, the following + members: + + char *address; + struct page *page; + unsigned int offset; + unsigned int length; + + The "address" member will disappear in 2.5.x + + This means that your pci_{map,unmap}_sg() and all other + interfaces dealing with scatterlists must be able to cope + properly with page being non NULL. + + A scatterlist is in one of two states. The base address is + either specified by "address" or by a "page+offset" pair. + If "address" is NULL, then "page+offset" is being used. + If "page" is NULL, then "address" is being used. + + In 2.5.x, all scatterlists will use "page+offset". But during + 2.4.x we still have to support the old method. + +2) More to come... + Closing This document, and the API itself, would not be in it's current diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/Documentation/DocBook/kernel-hacking.tmpl linux-2.5/Documentation/DocBook/kernel-hacking.tmpl --- linux-2.5.1/Documentation/DocBook/kernel-hacking.tmpl Fri Oct 5 19:06:51 2001 +++ linux-2.5/Documentation/DocBook/kernel-hacking.tmpl Thu Dec 20 19:14:29 2001 @@ -18,8 +18,8 @@ - 2000 - Paul Russell + 2001 + Rusty Russell @@ -651,6 +651,29 @@ + + <function>cpu_to_be32()</function>/<function>be32_to_cpu()</function>/<function>cpu_to_le32()</function>/<function>le32_to_cpu()</function> + <filename class=headerfile>include/asm/byteorder.h</filename> + + + + The cpu_to_be32() family (where the "32" can + be replaced by 64 or 16, and the "be" can be replaced by "le") are + the general way to do endian conversions in the kernel: they + return the converted value. All variations supply the reverse as + well: be32_to_cpu(), etc. + + + + There are two major variations of these functions: the pointer + variation, such as cpu_to_be32p(), which take + a pointer to the given type, and return the converted value. The + other variation is the "in-situ" family, such as + cpu_to_be32s(), which convert value referred + to by the pointer, and return void. + + + <function>local_irq_save()</function>/<function>local_irq_restore()</function> <filename class=headerfile>include/asm/system.h</filename> diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/Documentation/IRQ-affinity.txt linux-2.5/Documentation/IRQ-affinity.txt --- linux-2.5.1/Documentation/IRQ-affinity.txt Fri Feb 25 06:41:16 2000 +++ linux-2.5/Documentation/IRQ-affinity.txt Sat Dec 22 22:20:24 2001 @@ -8,7 +8,7 @@ affinity then the value will not change from the default 0xffffffff. Here is an example of restricting IRQ44 (eth1) to CPU0-3 then restricting -the IRQ to CPU4-8 (this is an 8-CPU SMP box): +the IRQ to CPU4-7 (this is an 8-CPU SMP box): [root@moon 44]# cat smp_affinity ffffffff diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/Documentation/cachetlb.txt linux-2.5/Documentation/cachetlb.txt --- linux-2.5.1/Documentation/cachetlb.txt Sun Oct 21 17:40:36 2001 +++ linux-2.5/Documentation/cachetlb.txt Thu Dec 13 16:32:35 2001 @@ -275,7 +275,7 @@ for example, uses this technique. The "address" parameter tells the virtual address where the - user will ultimately this page mapped. + user will ultimately have this page mapped. If D-cache aliasing is not an issue, these two routines may simply call memcpy/memset directly and do nothing more. diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/Documentation/filesystems/Locking linux-2.5/Documentation/filesystems/Locking --- linux-2.5.1/Documentation/filesystems/Locking Fri Feb 16 23:53:08 2001 +++ linux-2.5/Documentation/filesystems/Locking Thu Dec 13 16:32:35 2001 @@ -123,6 +123,10 @@ int (*prepare_write)(struct file *, struct page *, unsigned, unsigned); int (*commit_write)(struct file *, struct page *, unsigned, unsigned); int (*bmap)(struct address_space *, long); + int (*flushpage) (struct page *, unsigned long); + int (*releasepage) (struct page *, int); + int (*direct_IO)(int, struct inode *, struct kiobuf *, unsigned long, int); + locking rules: All may block BKL PageLocked(page) @@ -132,6 +136,8 @@ prepare_write: no yes commit_write: no yes bmap: yes +flushpage: no yes +releasepage: no yes ->prepare_write(), ->commit_write(), ->sync_page() and ->readpage() may be called from the request handler (/dev/loop). @@ -144,6 +150,15 @@ filesystems and by the swapper. The latter will eventually go away. All instances do not actually need the BKL. Please, keep it that way and don't breed new callers. + ->flushpage() is called when the filesystem must attempt to drop +some or all of the buffers from the page when it is being truncated. It +returns zero on success. If ->flushpage is zero, the kernel uses +block_flushpage() instead. + ->releasepage() is called when the kernel is about to try to drop the +buffers from the page in preparation for freeing it. It returns zero to +indicate that the buffers are (or may be) freeable. If ->flushpage is zero, +the kernel assumes that the fs has no private interest in the buffers. + Note: currently almost all instances of address_space methods are using BKL for internal serialization and that's one of the worst sources of contention. Normally they are calling library functions (in fs/buffer.c) diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/Documentation/filesystems/devfs/ChangeLog linux-2.5/Documentation/filesystems/devfs/ChangeLog --- linux-2.5.1/Documentation/filesystems/devfs/ChangeLog Sat Nov 24 21:06:43 2001 +++ linux-2.5/Documentation/filesystems/devfs/ChangeLog Thu Dec 27 21:24:25 2001 @@ -1794,3 +1794,72 @@ - Use "existing" directory in <_devfs_make_parent_for_leaf> - Use slab cache rather than fixed buffer for devfsd events +=============================================================================== +Changes for patch v199 + +- Removed obsolete usage of DEVFS_FL_NO_PERSISTENCE + +- Send DEVFSD_NOTIFY_REGISTERED events in <devfs_mk_dir> + +- Fixed locking bug in <devfs_d_revalidate_wait> due to typo + +- Do not send CREATE, CHANGE, ASYNC_OPEN or DELETE events from devfsd + or children +=============================================================================== +Changes for patch v200 + +- Ported to kernel 2.5.1-pre2 +=============================================================================== +Changes for patch v201 + +- Fixed bug in <devfsd_read>: was dereferencing freed pointer +=============================================================================== +Changes for patch v202 + +- Fixed bug in <devfsd_close>: was dereferencing freed pointer + +- Added process group check for devfsd privileges +=============================================================================== +Changes for patch v203 + +- Use SLAB_ATOMIC in <devfsd_notify_de> from <devfs_d_delete> +=============================================================================== +Changes for patch v204 + +- Removed long obsolete rc.devfs + +- Return old entry in <devfs_mk_dir> for 2.4.x kernels + +- Updated README from master HTML file + +- Increment refcount on module in <check_disc_changed> + +- Created <devfs_get_handle> and exported <devfs_put> + +- Increment refcount on module in <devfs_get_ops> + +- Created <devfs_put_ops> and used where needed to fix races + +- Added clarifying comments in response to preliminary EMC code review + +- Added poisoning to <devfs_put> + +- Improved debugging messages + +- Fixed unregister bugs in drivers/md/lvm-fs.c +=============================================================================== +Changes for patch v205 + +- Corrected (made useful) debugging message in <unregister> + +- Moved <kmem_cache_create> in <mount_devfs_fs> to <init_devfs_fs> + +- Fixed drivers/md/lvm-fs.c to create "lvm" entry + +- Added magic number to guard against scribbling drivers + +- Only return old entry in <devfs_mk_dir> if a directory + +- Defined macros for error and debug messages + +- Updated README from master HTML file diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/Documentation/filesystems/devfs/README linux-2.5/Documentation/filesystems/devfs/README --- linux-2.5.1/Documentation/filesystems/devfs/README Sat Nov 24 21:06:43 2001 +++ linux-2.5/Documentation/filesystems/devfs/README Thu Dec 27 21:24:26 2001 @@ -3,7 +3,7 @@ Linux Devfs (Device File System) FAQ Richard Gooch -9-NOV-2001 +21-DEC-2001 ----------------------------------------------------------------------------- @@ -66,6 +66,9 @@ Making things work Alternatives to devfs +What I don't like about devfs +How to report bugs +Strange kernel messages Other resources @@ -557,8 +560,10 @@ Devfsd OK, if you're reading this, I assume you want to play with -devfs. First you need to compile devfsd, the device management daemon, -available at +devfs. First you should ensure that /usr/src/linux contains a +recent kernel source tree. Then you need to compile devfsd, the device +management daemon, available at + http://www.atnf.csiro.au/~rgooch/linux/. Because the kernel has a naming scheme which is quite different from the old naming scheme, you need to @@ -1470,6 +1475,8 @@ Making things work Alternatives to devfs What I don't like about devfs +How to report bugs +Strange kernel messages @@ -1733,6 +1740,93 @@ This is not even remotely true. As shown above, both code and data size are quite modest. + + +How to report bugs + +If you have (or think you have) a bug with devfs, please follow the +steps below: + + + +please make sure you have the latest devfs patches applied. The +latest kernel version might not have the latest devfs patches applied +yet (Linus is very busy) + + +save a copy of your complete kernel logs (preferably by +using the dmesg programme) for later inclusion in your bug +report. You may need to use the -s switch to increase the +internal buffer size so you can capture all the boot messages + + +try booting with devfs=dall passed to the kernel boot +command line (read the documentation on your bootloader on how to do +this), and save the result to a file. This may be quite verbose, and +it may overflow the messages buffer, but try to get as much of it as +you can + + +if you get an Oops, run ksymoops to decode it so that the +names of the offending functions are provided. A non-decoded Oops is +pretty useless + + +send a copy of your devfsd configuration file(s) + +send the bug report to me first. +Don't expect that I will see it if you post it to the linux-kernel +mailing list. Include all the information listed above, plus +anything else that you think might be relevant. Put the string +devfs somewhere in the subject line, so my mail filters mark +it as urgent + + + + +Here is a general guide on how to ask questions in a way that greatly +improves your chances of getting a reply: + +http://www.tuxedo.org/~esr/faqs/smart-questions.html. If you have +a bug to report, you should also read + +http://www.chiark.greenend.org.uk/~sgtatham/bugs.html. + + +Strange kernel messages + +You may see devfs-related messages in your kernel logs. Below are some +messages and what they mean (and what you should do about them, if +anything). + + + +devfs_register(fred): could not append to parent, err: -17 + +You need to check what the error code means, but usually 17 means +EEXIST. This means that a driver attempted to create an entry +fred in a directory, but there already was an entry with that +name. This is often caused by flawed boot scripts which untar a bunch +of inodes into /dev, as a way to restore permissions. This +message is harmless, as the device nodes will still +provide access to the driver (unless you use the devfs=only +boot option, which is only for dedicated souls:-). If you want to get +rid of these annoying messages, upgrade to devfsd-v1.3.20 and use the +recommended RESTORE directive to restore permissions. + + +devfs_mk_dir(bill): using old entry in dir: c1808724 "" + +This is similar to the message above, except that a driver attempted +to create a directory named bill, and the parent directory +has an entry with the same name. In this case, to ensure that drivers +continue to work properly, the old entry is re-used and given to the +driver. In 2.5 kernels, the driver is given a NULL entry, and thus, +under rare circumstances, may not create the require device nodes. +The solution is the same as above. + + + ----------------------------------------------------------------------------- diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/Documentation/filesystems/devfs/rc.devfs linux-2.5/Documentation/filesystems/devfs/rc.devfs --- linux-2.5.1/Documentation/filesystems/devfs/rc.devfs Wed Feb 16 23:42:05 2000 +++ linux-2.5/Documentation/filesystems/devfs/rc.devfs Thu Jan 1 00:00:00 1970 @@ -1,104 +0,0 @@ -#! /bin/sh -# -# /etc/rc.d/rc.devfs -# -# Linux Boot Scripts by Richard Gooch <rgooch@atnf.csiro.au> -# Copyright 1993-1999 under GNU Copyleft version 2.0. See /etc/rc for -# copyright notice. -# -# Save and restore devfs ownerships and permissions -# -# Written by Richard Gooch 11-JAN-1998 -# -# Updated by Richard Gooch 23-JAN-1998: Added "start" and "stop". -# -# Updated by Richard Gooch 5-AUG-1998: Robustness improvements by -# Roderich Schupp. -# -# Updated by Richard Gooch 9-AUG-1998: Took account of change from -# ".epoch" to ".devfsd". -# -# Updated by Richard Gooch 19-AUG-1998: Test and tty pattern patch -# by Roderich Schupp. -# -# Updated by Richard Gooch 24-MAY-1999: Use sed instead of tr. -# -# Last updated by Richard Gooch 25-MAY-1999: Don't save /dev/log. -# -# -# Usage: rc.devfs save|restore [savedir] [devfsdir] -# -# Note: "start" is a synonym for "restore" and "stop" is a synonym for "save". - -# Set VERBOSE to "no" if you would like a more quiet operation. -VERBOSE=yes - -# Set TAROPTS to "v" or even "vv" to see which files get saved/restored. -TAROPTS= - -option="$1" - -case "$option" in - save|restore) ;; - start) option=restore ;; - stop) option=save ;; - *) echo "No save or restore option given" ; exit 1 ;; -esac - -if [ "$2" = "" ]; then - savedir=/var/state -else - savedir=$2 -fi - -if [ ! -d $savedir ]; then - echo "Directory: $savedir does not exist" - exit 1 -fi - -if [ "$3" = "" ]; then - if [ -d /devfs ]; then - devfs=/devfs - else - devfs=/dev - fi -else - devfs=$3 -fi - -grep devfs /proc/filesystems >/dev/null || exit 0 - -if [ ! -d $devfs ]; then - echo "Directory: $devfs does not exist" - exit 1 -elif [ ! -c $devfs/.devfsd ]; then - echo "Directory: $devfs is not the root of a devfs filesystem" - exit 1 -fi - -savefile=`echo $devfs | sed 's*/*_*g'` -tarfile=${savedir}/devfssave.${savefile}.tar.gz - -cd $devfs - -case "$option" in - save) - [ "$VERBOSE" != no ] && echo "Saving $devfs permissions..." - - # You might want to adjust the pattern below to control - # which file's permissions will be saved. - # The sample pattern exludes all virtual consoles - # as well as old and new style pseudo terminals. - files=`find * -noleaf -cnewer .devfsd \ - ! -regex 'tty[0-9]+\|vc/.*\|vcsa?[0-9]+\|vcc/.*\|[pt]ty[a-z][0-9a-f]\|pt[ms]/.*\|log' -print` - rm -f $tarfile - [ -n "$files" ] && tar cz${TAROPTS}f $tarfile $files - ;; - - restore) - [ "$VERBOSE" != no ] && echo "Restoring $devfs permissions..." - [ -f $tarfile ] && tar xpz${TAROPTS}f $tarfile - ;; -esac - -exit 0 diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/Documentation/filesystems/tmpfs.txt linux-2.5/Documentation/filesystems/tmpfs.txt --- linux-2.5.1/Documentation/filesystems/tmpfs.txt Thu Jan 1 00:00:00 1970 +++ linux-2.5/Documentation/filesystems/tmpfs.txt Thu Dec 13 16:32:35 2001 @@ -0,0 +1,102 @@ +Tmpfs is a file system which keeps all files in virtual memory. + + +Everything in tmpfs is temporary in the sense that no files will be +created on your hard drive. If you unmount a tmpfs instance, +everything stored therein is lost. + +tmpfs puts everything into the kernel internal caches and grows and +shrinks to accommodate the files it contains and is able to swap +unneeded pages out to swap space. It has maximum size limits which can +be adjusted on the fly via 'mount -o remount ...' + +If you compare it to ramfs (which was the template to create tmpfs) +you gain swapping and limit checking. Another similar thing is the RAM +disk (/dev/ram*), which simulates a fixed size hard disk in physical +RAM, where you have to create an ordinary filesystem on top. Ramdisks +cannot swap and you do not have the possibility to resize them. + +Since tmpfs lives completely in the page cache and on swap, all tmpfs +pages currently in memory will show up as cached. It will not show up +as shared or something like that. Further on you can check the actual +RAM+swap use of a tmpfs instance with df(1) and du(1). + + +tmpfs has the following uses: + +1) There is always a kernel internal mount which you will not see at + all. This is used for shared anonymous mappings and SYSV shared + memory. + + This mount does not depend on CONFIG_TMPFS. If CONFIG_TMPFS is not + set, the user visible part of tmpfs is not build. But the internal + mechanisms are always present. + +2) glibc 2.2 and above expects tmpfs to be mounted at /dev/shm for + POSIX shared memory (shm_open, shm_unlink). Adding the following + line to /etc/fstab should take care of this: + + tmpfs /dev/shm tmpfs defaults 0 0 + + Remember to create the directory that you intend to mount tmpfs on + if necessary (/dev/shm is automagically created if you use devfs). + + This mount is _not_ needed for SYSV shared memory. The internal + mount is used for that. (In the 2.3 kernel versions it was + necessary to mount the predecessor of tmpfs (shm fs) to use SYSV + shared memory) + +3) Some people (including me) find it very convenient to mount it + e.g. on /tmp and /var/tmp and have a big swap partition. But be + aware: loop mounts of tmpfs files do not work due to the internal + design. So mkinitrd shipped by most distributions will fail with a + tmpfs /tmp. + +4) And probably a lot more I do not know about :-) + + +tmpfs has a couple of mount options: + +size: The limit of allocated bytes for this tmpfs instance. The + default is half of your physical RAM without swap. If you + oversize your tmpfs instances the machine will deadlock + since the OOM handler will not be able to free that memory. +nr_blocks: The same as size, but in blocks of PAGECACHE_SIZE. +nr_inodes: The maximum number of inodes for this instance. The default + is half of the number of your physical RAM pages. + +These parameters accept a suffix k, m or g for kilo, mega and giga and +can be changed on remount. + +To specify the initial root directory you can use the following mount +options: + +mode: The permissions as an octal number +uid: The user id +gid: The group id + +These options do not have any effect on remount. You can change these +parameters with chmod(1), chown(1) and chgrp(1) on a mounted filesystem. + + +So 'mount -t tmpfs -o size=10G,nr_inodes=10k,mode=700 tmpfs /mytmpfs' +will give you tmpfs instance on /mytmpfs which can allocate 10GB +RAM/SWAP in 10240 inodes and it is only accessible by root. + + +TODOs: + +1) give the size option a percent semantic: If you give a mount option + size=50% the tmpfs instance should be able to grow to 50 percent of + RAM + swap. So the instance should adapt automatically if you add + or remove swap space. +2) loop mounts: This is difficult since loop.c relies on the readpage + operation. This operation gets a page from the caller to be filled + with the content of the file at that position. But tmpfs always has + the page and thus cannot copy the content to the given page. So it + cannot provide this operation. The VM had to be changed seriously + to achieve this. +3) Show the number of tmpfs RAM pages. (As shared?) + +Author: + Christoph Rohland <cr@sap.com>, 1.12.01 diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/Documentation/i386/boot.txt linux-2.5/Documentation/i386/boot.txt --- linux-2.5.1/Documentation/i386/boot.txt Wed Nov 7 22:46:01 2001 +++ linux-2.5/Documentation/i386/boot.txt Thu Dec 27 16:32:30 2001 @@ -2,7 +2,7 @@ ---------------------------- H. Peter Anvin <hpa@zytor.com> - Last update 2000-10-29 + Last update 2001-12-11 On the i386 platform, the Linux kernel uses a rather complicated boot convention. This has evolved partially due to historical aspects, as @@ -31,6 +31,9 @@ BIOS entry points. zImage deprecated but still supported. +Protocol 2.03: (???) Explicitly makes the highest possible initrd address + available to the bootloader. + **** MEMORY LAYOUT @@ -45,7 +48,7 @@ 098000 +------------------------+ | Kernel setup | The kernel real-mode code. 090200 +------------------------+ - | Kernel boot sector | The kernel legacy boot sector. + | Kernel boot sector | The kernel legacy boot sector. 090000 +------------------------+ | Protected-mode kernel | The bulk of the kernel image. 010000 +------------------------+ @@ -123,6 +126,7 @@ 0224/2 2.01+ heap_end_ptr Free memory after setup end 0226/2 N/A pad1 Unused 0228/4 2.02+ cmd_line_ptr 32-bit pointer to the kernel command line +022C/4 2.03+ initrd_addr_max Highest legal initrd address For backwards compatibility, if the setup_sects field contains 0, the real value is 4. @@ -181,8 +185,8 @@ The initrd should typically be located as high in memory as possible, as it may otherwise get overwritten by the early kernel initialization sequence. However, it must never be - located above address 0x3C000000 if you want all kernels to - read it. + located above the address specified in the initrd_addr_max + field. The initrd should be at least 4K page aligned. cmd_line_ptr: If the protocol version is 2.02 or higher, this is a 32-bit @@ -192,7 +196,15 @@ command line, in which case you can point this to an empty string (or better yet, to the string "auto".) If this field is left at zero, the kernel will assume that your boot loader - does not support the 2.02 protocol. + does not support the 2.02+ protocol. + + ramdisk_max: + The maximum address that may be occupied by the initrd + contents. For boot protocols 2.02 or earlier, this field is + not present, and the maximum address is 0x37FFFFFF. (This + address is defined as the address of the highest safe byte, so + if your ramdisk is exactly 131072 bytes long and this field is + 0x37FFFFFF, you can start your ramdisk at 0x37FE0000.) **** THE KERNEL COMMAND LINE @@ -254,14 +266,14 @@ if ( protocol >= 0x0202 ) { cmd_line_ptr = base_ptr + 0x9000; } else { - cmd_line_magic = 0xA33F; + cmd_line_magic = 0xA33F; cmd_line_offset = 0x9000; setup_move_size = 0x9100; } } else { /* Very old kernel */ - cmd_line_magic = 0xA33F; + cmd_line_magic = 0xA33F; cmd_line_offset = 0x9000; /* A very old kernel MUST have its real-mode code @@ -411,4 +423,3 @@ After completing your hook, you should jump to the address that was in this field before your boot loader overwrote it. - diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/Documentation/isdn/INTERFACE linux-2.5/Documentation/isdn/INTERFACE --- linux-2.5.1/Documentation/isdn/INTERFACE Mon Mar 26 23:38:19 2001 +++ linux-2.5/Documentation/isdn/INTERFACE Thu Dec 13 16:32:35 2001 @@ -1,4 +1,4 @@ -$Id: INTERFACE,v 1.15.8.2 2001/03/13 16:17:07 kai Exp $ +$Id: INTERFACE,v 1.1.4.1 2001/11/20 14:19:33 kai Exp $ Description of the Interface between Linklevel and Hardwarelevel of isdn4linux: diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/Documentation/isdn/INTERFACE.fax linux-2.5/Documentation/isdn/INTERFACE.fax --- linux-2.5.1/Documentation/isdn/INTERFACE.fax Tue Nov 28 00:53:43 2000 +++ linux-2.5/Documentation/isdn/INTERFACE.fax Thu Dec 13 16:32:35 2001 @@ -1,4 +1,4 @@ -$Id: INTERFACE.fax,v 1.2 2000/08/06 09:22:50 armin Exp $ +$Id: INTERFACE.fax,v 1.1.4.1 2001/11/20 14:19:33 kai Exp $ Description of the fax-subinterface between linklevel and hardwarelevel of diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/Documentation/isdn/README.act2000 linux-2.5/Documentation/isdn/README.act2000 --- linux-2.5.1/Documentation/isdn/README.act2000 Sun Nov 12 02:58:02 2000 +++ linux-2.5/Documentation/isdn/README.act2000 Thu Dec 13 16:32:35 2001 @@ -1,4 +1,4 @@ -$Id: README.act2000,v 1.3 2000/08/06 09:22:51 armin Exp $ +$Id: README.act2000,v 1.1.4.1 2001/11/20 14:19:33 kai Exp $ This document describes the ACT2000 driver for the IBM Active 2000 ISDN card. diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/Documentation/isdn/README.audio linux-2.5/Documentation/isdn/README.audio --- linux-2.5.1/Documentation/isdn/README.audio Thu Aug 12 16:42:33 1999 +++ linux-2.5/Documentation/isdn/README.audio Thu Dec 13 16:32:35 2001 @@ -1,4 +1,4 @@ -$Id: README.audio,v 1.8 1999/07/11 17:17:29 armin Exp $ +$Id: README.audio,v 1.1.4.1 2001/11/20 14:19:33 kai Exp $ ISDN subsystem for Linux. Description of audio mode. diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/Documentation/isdn/README.eicon linux-2.5/Documentation/isdn/README.eicon --- linux-2.5.1/Documentation/isdn/README.eicon Mon Mar 26 23:38:19 2001 +++ linux-2.5/Documentation/isdn/README.eicon Thu Dec 13 16:32:35 2001 @@ -1,4 +1,4 @@ -$Id: README.eicon,v 1.10.6.1 2001/02/19 10:04:59 armin Exp $ +$Id: README.eicon,v 1.1.4.1 2001/11/20 14:19:33 kai Exp $ (c) 1999,2000 Armin Schindler (mac@melware.de) (c) 1999,2000 Cytronics & Melware (info@melware.de) diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/Documentation/isdn/README.hysdn linux-2.5/Documentation/isdn/README.hysdn --- linux-2.5.1/Documentation/isdn/README.hysdn Fri Mar 2 19:12:12 2001 +++ linux-2.5/Documentation/isdn/README.hysdn Thu Dec 13 16:32:35 2001 @@ -1,4 +1,4 @@ -$Id: README.hysdn,v 1.3.6.1 2001/02/10 14:41:19 kai Exp $ +$Id: README.hysdn,v 1.1.4.1 2001/11/20 14:19:33 kai Exp $ The hysdn driver has been written by by Werner Cornelius (werner@isdn4linux.de or werner@titro.de) for Hypercope GmbH Aachen Germany. Hypercope agreed to publish this driver diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/Documentation/isdn/README.icn linux-2.5/Documentation/isdn/README.icn --- linux-2.5.1/Documentation/isdn/README.icn Sun Nov 12 02:58:03 2000 +++ linux-2.5/Documentation/isdn/README.icn Thu Dec 13 16:32:35 2001 @@ -1,4 +1,4 @@ -$Id: README.icn,v 1.7 2000/08/06 09:22:51 armin Exp $ +$Id: README.icn,v 1.1.4.1 2001/11/20 14:19:33 kai Exp $ You can get the ICN-ISDN-card from: diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/Documentation/kernel-parameters.txt linux-2.5/Documentation/kernel-parameters.txt --- linux-2.5.1/Documentation/kernel-parameters.txt Wed Jun 20 18:21:33 2001 +++ linux-2.5/Documentation/kernel-parameters.txt Sat Dec 29 11:37:48 2001 @@ -125,6 +125,13 @@ BusLogic= [HW,SCSI] + cachesize= [BUGS=ix86] Override level 2 CPU cache size detection. + Sometimes CPU hardware bugs make them report the cache + size incorrectly. The kernel will attempt work arounds + to fix known problems, but for some CPUs it is not + possible to determine what the correct size should be. + This option provides an override for these situations. + cdu31a= [HW,CD] chandev= [HW,NET] diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/Documentation/networking/decnet.txt linux-2.5/Documentation/networking/decnet.txt --- linux-2.5.1/Documentation/networking/decnet.txt Fri Feb 16 23:53:08 2001 +++ linux-2.5/Documentation/networking/decnet.txt Thu Dec 13 16:32:35 2001 @@ -4,20 +4,9 @@ 1) Other documentation.... o Project Home Pages - http://www.sucs.swan.ac.uk/~rohan/DECnet/index.html - Kernel info + http://www.chygwyn.com/DECnet/ - Kernel info http://linux-decnet.sourceforge.net/ - Userland tools - - o FTP sites - ftp://ftp.sucs.swan.ac.uk/pub/Linux/DECnet/ - - Swansea University Computer Society DECnet Archive - (contains kernel patches and info) - - Mirror of userland tools on ftp.dreamtime.org - - Mirror of Alexey Kuznetsov's iproute2 package and - other utilities - - ftp://linux-decnet.sourceforge.net/pub/linux-decnet/ - - Patrick Caulfield's archive of userland tools and - Eduardo Serrat's kernel patches + http://www.sourceforge.net/projects/linux-decnet/ - Status page 2) Configuring the kernel @@ -31,9 +20,13 @@ you'll need the following options as well... CONFIG_DECNET_ROUTER (to be able to add/delete routes) - CONFIG_NETLINK (to allow rtnetlink) - CONFIG_RTNETLINK (for communication with the kernel routing layer) CONFIG_NETFILTER (will be required for the DECnet routing daemon) + + CONFIG_DECNET_ROUTE_FWMARK is optional + +Don't turn on SIOCGIFCONF support for DECnet unless you are really sure +that you need it, in general you won't and it can cause ifconfig to +malfunction. 3) Command line options diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/Documentation/networking/dl2k.txt linux-2.5/Documentation/networking/dl2k.txt --- linux-2.5.1/Documentation/networking/dl2k.txt Mon Nov 19 23:19:42 2001 +++ linux-2.5/Documentation/networking/dl2k.txt Thu Dec 27 16:32:30 2001 @@ -1,7 +1,7 @@ D-Link DL2000-based Gigabit Ethernet Adapter Installation for Linux - Nov 12, 2001 + Nov 21, 2001 Contents ======== @@ -195,8 +195,8 @@ 2 10Mbps full duplex. 3 100Mbps half duplex. 4 100Mbps full duplex. - 5 1000Mbps full duplex. - 6 1000Mbps half duplex. + 5 1000Mbps half duplex. + 6 1000Mbps full duplex. By default, the NIC operates at autosense. Note that only 1000mbps_fd and 1000mbps_hd @@ -212,11 +212,24 @@ Jumbo frame usually improve the performance int gigabit. -int_count - Rx frame count each interrupt. -int_timeout - Rx DMA wait time for an interrupt. Proper - values of int_count and int_timeout bring - a conspicuous performance in the fast machine. - Ex. int_count=5 and int_timeout=750 +rx_coalesce - Rx frame count each interrupt. +rx_timeout - Rx DMA wait time for an interrupt. Proper + values of rx_coalesce and rx_timeout bring + a conspicuous performance in the fast machine. + Ex. rx_coalesce=5 and rx_timeout=750 + +tx_coalesce - Tx transmit count each TxComp interrupt. + Setting value larger than 1 will improve + performance, but this is possible to lower + stability in slow UP machines. By default, + tx_coalesce=8. (dl2k) + +tx_flow - Specifies the Tx flow control. If tx_flow=1, + the Tx flow control enable. + +rx_flow - Specifies the Rx flow control. If rx_flow=1, + the Rx flow control enable. + Configuration Script Sample =========================== diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/Documentation/pci.txt linux-2.5/Documentation/pci.txt --- linux-2.5.1/Documentation/pci.txt Sun Nov 4 17:31:57 2001 +++ linux-2.5/Documentation/pci.txt Thu Dec 13 16:32:35 2001 @@ -104,6 +104,10 @@ If you are sure the driver is not a hotplug driver then use only __init/exit __initdata/exitdata. + Pointers to functions marked as __devexit must be created using + __devexit_p(function_name). That will generate the function + name or NULL if the __devexit function will be discarded. + 2. How to find PCI devices manually (the old style) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/Documentation/s390/Debugging390.txt linux-2.5/Documentation/s390/Debugging390.txt --- linux-2.5.1/Documentation/s390/Debugging390.txt Wed Nov 7 22:46:01 2001 +++ linux-2.5/Documentation/s390/Debugging390.txt Thu Dec 27 16:32:30 2001 @@ -237,9 +237,10 @@ On 390 our limitations & strengths make us slightly different. -For backward compatibility we are only allowed use 31 bits (2GB) -of our 32 bit addresses,however, we use entirely separate address -spaces for the user & kernel. +For backward compatibility ( because of the psw address hi bit which +indicates whether we are in 31 or 64 bit mode ) we are only allowed +use 31 bits (2GB) of our 32 bit addresses. However, +we use entirely separate address spaces for the user & kernel. This means we can support 2GB of non Extended RAM on s/390, & more with the Extended memory managment swap device & @@ -2123,6 +2124,12 @@ now do p/x (*(**$sp+56))&0x7fffffff & so on. + +Another good trick to look at addresses on the stack if you've somehow lost +the backchain is. +x/500xa $sp +This displays anything the name of any known functions above the stack pointer +for 500 bytes. Disassembling instructions without debug info --------------------------------------------- diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/Documentation/usb/usb-serial.txt linux-2.5/Documentation/usb/usb-serial.txt --- linux-2.5.1/Documentation/usb/usb-serial.txt Mon Nov 12 17:50:39 2001 +++ linux-2.5/Documentation/usb/usb-serial.txt Thu Dec 27 16:32:30 2001 @@ -95,6 +95,66 @@ Kroah-Hartman at greg@kroah.com +Compaq iPAQ driver + + This driver can be used to connect to Compaq iPAQ PDAs running + Windows CE 3.0 using a USB autosync cable. It has been tested only on + the Compaq H3135. It should work with the H3600 and later models too. + It may work with other CE based handhelds as well. + + The driver presents a serial interface (usually on /dev/ttyUSB0) over + which one may run ppp and establish a TCP/IP link to the iPAQ. Once this + is done, you can transfer files, backup, download email etc. The most + significant advantage of using USB is speed - you can get 73 to 113 + kbytes/sec for download/upload to the iPAQ. + + The driver works intermittently with the usb-uhci driver but quite + reliably with the uhci driver. Make sure you have the right driver + loaded - usb-uhci is often the default. + + You must setup hotplug to invoke pppd as soon as the iPAQ is connected. + A ppp script like the one below may be used: + + #!/bin/bash + + MYIP=linux.box.ip + REMOTEIP=ipaq.ip + MYDNS=my.dns.server + killall -9 pppd + /usr/sbin/pppd /dev/ttyUSB0 \ + connect "/usr/sbin/chat -v TIMEOUT 60 CLIENT 'CLIENTSERVER\c'" \ + nocrtscts local debug passive $MYIP:$REMOTEIP ms-dns $MYDNS noauth \ + proxyarp + + You must also download and install asyncd from http://synce.sourceforge.net + This is required to emulate keep-alive packets which are exchanged by + ActiveSync and the iPAQ. + + On connecting the cable, you should see the usual "Device Connected", + "User Authenticated" messages flash by on your iPAQ. Once connected, + you can use Win CE programs like ftpView, Pocket Outlook from the iPAQ + and other synce utilities from the Linux side. Remember to enable IP + forwarding. + + To use Pocket IE, follow the instructions given at + http://www.tekguru.co.uk/EM500/usbtonet.htm to achieve the same thing + on Win98. Omit the proxy server part; Linux is quite capable of forwarding + packets unlike Win98. Another modification is required at least for the + iPAQ - disable autosync by going to the Start/Settings/Connections menu + and unchecking the "Automatically synchronize ..." box. Go to + Start/Programs/Connections, connect the cable and select "usbdial" (or + whatever you named your new USB connection). You should finally wind + up with a "Connected to usbdial" window with status shown as connected. + Now start up PIE and browse away. + + If it doesn't work for some reason, load both the usbserial and ipaq module + with the module parameter "debug" set to 1 and examine the system log. + You can also try soft-resetting your iPAQ before attempting a connection. + + For any questions or problems with the driver, please contact Ganesh + Varadarajan <ganesh@veritas.com> + + Keyspan PDA Serial Adapter Single port DB-9 serial adapter, pushed as a PDA adapter for iMacs (mostly @@ -301,6 +361,32 @@ For any questions or problems with this driver, please contact Greg Kroah-Hartman at greg@kroah.com + +KL5KUSB105 chipset / PalmConnect USB single-port adapter + +Current status: + The driver was put together by looking at the usb bus transactions + done by Palm's driver under Windows, so a lot of functionality is + still missing. Notably, serial ioctls are sometimes faked or not yet + implemented. Support for finding out about DSR and CTS line status is + however implemented (though not nicely), so your favorite autopilot(1) + and pilot-manager -daemon calls will work. Baud rates up to 115200 + are supported, but handshaking (software or hardware) is not, which is + why it is wise to cut down on the rate used is wise for large + transfers until this is settled. + +Options supported: + If this driver is compiled as a module you can pass the following + options to it: + debug - extra verbose debugging info + (default: 0; nonzero enables) + use_lowlatency - use low_latency flag to speed up tty layer + when reading from from the device. + (default: 0; nonzero enables) + + See http://www.uuhaus.de/linux/palmconnect.html for up-to-date + information on this driver. + Generic Serial driver diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/Documentation/video4linux/Zoran linux-2.5/Documentation/video4linux/Zoran --- linux-2.5.1/Documentation/video4linux/Zoran Wed Jul 4 21:41:33 2001 +++ linux-2.5/Documentation/video4linux/Zoran Thu Dec 13 16:32:35 2001 @@ -160,9 +160,9 @@ set aside the necessary memory during boot time. There seem to be several versions of this patch against various kernel versions floating around in the net, you may obtain one e.g. from: - http://www.polyware.nl/~middelin/patch/bigphysarea-2.2.1.tar.gz You - also have to compile your driver AFTER installing that patch in order - to get it working + http://www.polyware.nl/~middelin/hob-v4l.html#bigphysarea + You also have to compile your driver AFTER installing that patch in + order to get it working or diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/Documentation/video4linux/w9966.txt linux-2.5/Documentation/video4linux/w9966.txt --- linux-2.5.1/Documentation/video4linux/w9966.txt Wed Jul 4 21:41:33 2001 +++ linux-2.5/Documentation/video4linux/w9966.txt Thu Dec 13 16:32:35 2001 @@ -1,37 +1,33 @@ +W9966 Camera driver, written by Jakob Kemi (jakob.kemi@telia.com) -W9966 Camera driver, written by Jakob Kemi (jakob.kemi@post.utfors.se) +After a lot of work in softice & wdasm, reading .pdf-files and tiresome +trial-and-error work I've finally got everything to work. I needed vision for a +robotics project so I borrowed this camera from a friend and started hacking. +Anyway I've converted my original code from the AVR 8bit RISC C/ASM code into +a working Linux driver. -Ok, after a lot of work in softice, wdasm, reading pdf-files -and trial-and-error work I've finally got everything to work. -Since I needed some vision for a robotics project I borrowed -this camera from a friend and started hacking. Anyway I've -converted my original code from the AVR 8bit RISC C/asm -into a working linux driver. I would really appreciate _any_ -kind of feedback regarding this driver. - -To get it working quickly configure your kernel -to support parport, ieee1284, video4linux, experimental drivers -and w9966 +To get it working simply configure your kernel to support +parport, ieee1284, video4linux and w9966 -If w9966 is statically linked it will perform aggressive probing -for the camera. If built as a module you'll have more configuration options. +If w9966 is statically linked it will always perform aggressive probing for +the camera. If built as a module you'll have more configuration options. Options: -modprobe w9966.o pardev=parport0(or whatever) parmode=0 (0=auto, 1=ecp, 2=epp) - + modprobe w9966.o pardev=parport0(or whatever) parmode=0 (0=auto, 1=ecp, 2=epp) voila! you can also type 'modinfo -p w9966.o' for option usage (or checkout w9966.c) -I've only tested it with custom built testprograms -(http://hem.fyristorg.com/mogul/w9966.html) and with gqcam. -(you'll need to tweak the code to qcam a bit to make it work, -dimensions and such) +The only thing to keep in mind is that the image format is in Y-U-Y-V format +where every two pixels take 4 bytes. In SDL (www.libsdl.org) this format +is called VIDEO_PALETTE_YUV422 (16 bpp). + +A minimal test application (with source) is available from: + http://hem.fyristorg.com/mogul/w9966.html The slow framerate is due to missing DMA ECP read support in the parport drivers. I might add working EPP support later. Good luck! - - /Jakob + /Jakob Kemi diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/MAINTAINERS linux-2.5/MAINTAINERS --- linux-2.5.1/MAINTAINERS Mon Dec 10 18:39:20 2001 +++ linux-2.5/MAINTAINERS Fri Dec 28 11:21:15 2001 @@ -412,6 +412,12 @@ L: linux-decnet-user@lists.sourceforge.net S: Maintained +DELL LAPTOP SMM DRIVER +P: Massimo Dal Zotto +M: dz@debian.org +W: http://www.debian.org/~dz/i8k/ +S: Maintained + DEVICE NUMBER REGISTRY P: H. Peter Anvin M: hpa@zytor.com @@ -843,7 +849,7 @@ M: vojtech@suse.cz L: linux-joystick@atrey.karlin.mff.cuni.cz W: http://www.suse.cz/development/joystick/ -S: Supported +S: Maintained KERNEL AUTOMOUNTER (AUTOFS) P: H. Peter Anvin @@ -926,6 +932,12 @@ W: http://www.sistina.com/lvm S: Maintained +LSILOGIC/SYMBIOS/NCR 53C8XX and 53C1010 PCI-SCSI drivers +P: Gerard Roudier +M: groudier@free.fr +L: linux-scsi@vger.kernel.org +S: Maintained + M68K P: Jes Sorensen M: jes@trained-monkey.org @@ -1010,6 +1022,11 @@ M: andrewtv@usa.net S: Maintained +NATSEMI ETHERNET DRIVER (DP8381x) +P: Tim Hockin +M: thockin@hockin.org +S: Maintained + NCP FILESYSTEM P: Petr Vandrovec M: vandrove@vc.cvut.cz @@ -1133,8 +1150,8 @@ S: Maintained OPL3-SA2, SA3, and SAx DRIVER -P: Scott Murray -M: scott@spiteful.org +P: Zwane Mwaikambo +M: zwane@commfireservices.com L: linux-sound@vger.kernel.org S: Maintained @@ -1322,8 +1339,10 @@ S: Maintained SCSI SUBSYSTEM +P: Jens Axboe +M: axboe@suse.de L: linux-scsi@vger.kernel.org -S: Unmaintained +S: Maintained SCSI TAPE DRIVER P: Kai Mäkisara @@ -1538,7 +1557,7 @@ M: vojtech@suse.cz L: linux-usb-users@lists.sourceforge.net L: linux-usb-devel@lists.sourceforge.net -S: Supported +S: Maintained USB BLUETOOTH DRIVER P: Greg Kroah-Hartman @@ -1561,7 +1580,7 @@ L: linux-usb-users@lists.sourceforge.net L: linux-usb-devel@lists.sourceforge.net W: http://www.suse.cz/development/input/ -S: Supported +S: Maintained USB HUB P: Johannes Erdfelt @@ -1612,7 +1631,7 @@ M: vojtech@suse.cz L: linux-usb-users@lists.sourceforge.net L: linux-usb-devel@lists.sourceforge.net -S: Supported +S: Maintained USB SE401 DRIVER P: Jeroen Vreeken diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/Makefile linux-2.5/Makefile --- linux-2.5.1/Makefile Sun Dec 16 23:53:11 2001 +++ linux-2.5/Makefile Sun Dec 30 21:40:47 2001 @@ -1,7 +1,7 @@ VERSION = 2 PATCHLEVEL = 5 SUBLEVEL = 1 -EXTRAVERSION = +EXTRAVERSION =-dj10 KERNELRELEASE=$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION) @@ -169,7 +169,7 @@ DRIVERS-$(CONFIG_FC4) += drivers/fc4/fc4.a DRIVERS-$(CONFIG_ALL_PPC) += drivers/macintosh/macintosh.o DRIVERS-$(CONFIG_MAC) += drivers/macintosh/macintosh.o -DRIVERS-$(CONFIG_ISAPNP) += drivers/pnp/pnp.o +DRIVERS-$(CONFIG_PNP) += drivers/pnp/pnp.o DRIVERS-$(CONFIG_SGI_IP22) += drivers/sgi/sgi.a DRIVERS-$(CONFIG_VT) += drivers/video/video.o DRIVERS-$(CONFIG_PARIDE) += drivers/block/paride/paride.a @@ -329,11 +329,13 @@ @echo '#define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))' >>.ver @mv -f .ver $@ +comma := , + init/version.o: init/version.c include/linux/compile.h include/config/MARKER - $(CC) $(CFLAGS) $(CFLAGS_KERNEL) -DUTS_MACHINE='"$(ARCH)"' -c -o init/version.o init/version.c + $(CC) $(CFLAGS) $(CFLAGS_KERNEL) -DUTS_MACHINE='"$(ARCH)"' -DKBUILD_BASENAME=$(subst $(comma),_,$(subst -,_,$(*F))) -c -o init/version.o init/version.c init/main.o: init/main.c include/config/MARKER - $(CC) $(CFLAGS) $(CFLAGS_KERNEL) $(PROFILING) -c -o $*.o $< + $(CC) $(CFLAGS) $(CFLAGS_KERNEL) $(PROFILING) -DKBUILD_BASENAME=$(subst $(comma),_,$(subst -,_,$(*F))) -c -o $*.o $< init/do_mounts.o: init/do_mounts.c include/config/MARKER $(CC) $(CFLAGS) $(CFLAGS_KERNEL) $(PROFILING) -c -o $*.o $< diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/Rules.make linux-2.5/Rules.make --- linux-2.5.1/Rules.make Wed Mar 7 03:31:01 2001 +++ linux-2.5/Rules.make Sat Dec 29 11:10:40 2001 @@ -31,6 +31,8 @@ unexport subdir-n unexport subdir- +comma := , + # # Get things started. # @@ -54,7 +56,7 @@ $(CPP) $(CFLAGS) $(EXTRA_CFLAGS) $(CFLAGS_$@) $< > $@ %.o: %.c - $(CC) $(CFLAGS) $(EXTRA_CFLAGS) $(CFLAGS_$@) -c -o $@ $< + $(CC) $(CFLAGS) $(EXTRA_CFLAGS) -DKBUILD_BASENAME=$(subst $(comma),_,$(subst -,_,$(*F))) $(CFLAGS_$@) -c -o $@ $< @ ( \ echo 'ifeq ($(strip $(subst $(comma),:,$(CFLAGS) $(EXTRA_CFLAGS) $(CFLAGS_$@))),$$(strip $$(subst $$(comma),:,$$(CFLAGS) $$(EXTRA_CFLAGS) $$(CFLAGS_$@))))' ; \ echo 'FILES_FLAGS_UP_TO_DATE += $@' ; \ @@ -270,7 +272,7 @@ ifneq "$(strip $(export-objs))" "" $(export-objs): $(export-objs:.o=.c) $(TOPDIR)/include/linux/modversions.h - $(CC) $(CFLAGS) $(EXTRA_CFLAGS) $(CFLAGS_$@) -DEXPORT_SYMTAB -c $(@:.o=.c) + $(CC) $(CFLAGS) $(EXTRA_CFLAGS) -DKBUILD_BASENAME=$(subst $(comma),_,$(subst -,_,$(*F))) $(CFLAGS_$@) -DEXPORT_SYMTAB -c $(@:.o=.c) @ ( \ echo 'ifeq ($(strip $(subst $(comma),:,$(CFLAGS) $(EXTRA_CFLAGS) $(CFLAGS_$@) -DEXPORT_SYMTAB)),$$(strip $$(subst $$(comma),:,$$(CFLAGS) $$(EXTRA_CFLAGS) $$(CFLAGS_$@) -DEXPORT_SYMTAB)))' ; \ echo 'FILES_FLAGS_UP_TO_DATE += $@' ; \ diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/alpha/kernel/alpha_ksyms.c linux-2.5/arch/alpha/kernel/alpha_ksyms.c --- linux-2.5.1/arch/alpha/kernel/alpha_ksyms.c Sun Nov 25 17:45:10 2001 +++ linux-2.5/arch/alpha/kernel/alpha_ksyms.c Sat Dec 22 00:11:28 2001 @@ -259,3 +259,8 @@ EXPORT_SYMBOL_NOVERS(memchr); EXPORT_SYMBOL(get_wchan); + +#ifdef CONFIG_ALPHA_IRONGATE +EXPORT_SYMBOL(irongate_ioremap); +EXPORT_SYMBOL(irongate_iounmap); +#endif diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/alpha/kernel/pci-noop.c linux-2.5/arch/alpha/kernel/pci-noop.c --- linux-2.5.1/arch/alpha/kernel/pci-noop.c Thu Sep 13 22:21:32 2001 +++ linux-2.5/arch/alpha/kernel/pci-noop.c Tue Dec 18 15:29:09 2001 @@ -104,21 +104,21 @@ } /* stubs for the routines in pci_iommu.c */ void * -pci_alloc_consistent(struct pci_dev *pdev, long size, dma_addr_t *dma_addrp) +pci_alloc_consistent(struct pci_dev *pdev, size_t size, dma_addr_t *dma_addrp) { } void -pci_free_consistent(struct pci_dev *pdev, long size, void *cpu_addr, +pci_free_consistent(struct pci_dev *pdev, size_t size, void *cpu_addr, dma_addr_t dma_addr) { } dma_addr_t -pci_map_single(struct pci_dev *pdev, void *cpu_addr, long size, +pci_map_single(struct pci_dev *pdev, void *cpu_addr, size_t size, int direction) { } void -pci_unmap_single(struct pci_dev *pdev, dma_addr_t dma_addr, long size, +pci_unmap_single(struct pci_dev *pdev, dma_addr_t dma_addr, size_t size, int direction) { } diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/alpha/kernel/process.c linux-2.5/arch/alpha/kernel/process.c --- linux-2.5.1/arch/alpha/kernel/process.c Sun Sep 30 19:26:08 2001 +++ linux-2.5/arch/alpha/kernel/process.c Thu Dec 27 22:10:28 2001 @@ -75,7 +75,6 @@ { /* An endless idle loop with no priority at all. */ current->nice = 20; - current->counter = -100; while (1) { /* FIXME -- EV6 and LCA45 know how to power down diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/alpha/kernel/setup.c linux-2.5/arch/alpha/kernel/setup.c --- linux-2.5.1/arch/alpha/kernel/setup.c Sat Nov 17 02:38:39 2001 +++ linux-2.5/arch/alpha/kernel/setup.c Thu Dec 27 15:56:12 2001 @@ -440,12 +440,6 @@ return MKDEV(TTY_MAJOR, 64 + c->index); } -static int srm_console_wait_key(struct console *co) -{ - /* Huh? */ - return 1; -} - static int __init srm_console_setup(struct console *co, char *options) { return 1; @@ -455,7 +449,6 @@ name: "srm0", write: srm_console_write, device: srm_console_device, - wait_key: srm_console_wait_key, setup: srm_console_setup, flags: CON_PRINTBUFFER | CON_ENABLED, /* fake it out */ index: -1, diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/alpha/kernel/smp.c linux-2.5/arch/alpha/kernel/smp.c --- linux-2.5.1/arch/alpha/kernel/smp.c Wed Nov 21 18:31:09 2001 +++ linux-2.5/arch/alpha/kernel/smp.c Thu Dec 13 16:32:35 2001 @@ -23,6 +23,7 @@ #include <linux/delay.h> #include <linux/spinlock.h> #include <linux/irq.h> +#include <linux/cache.h> #include <asm/hwrpb.h> #include <asm/ptrace.h> @@ -65,7 +66,7 @@ IPI_CPU_STOP, }; -spinlock_t kernel_flag = SPIN_LOCK_UNLOCKED; +spinlock_t kernel_flag __cacheline_aligned_in_smp = SPIN_LOCK_UNLOCKED; /* Set to a secondary's cpuid when it comes online. */ static unsigned long smp_secondary_alive; diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/arm/kernel/entry-common.S linux-2.5/arch/arm/kernel/entry-common.S --- linux-2.5.1/arch/arm/kernel/entry-common.S Thu Oct 11 16:04:57 2001 +++ linux-2.5/arch/arm/kernel/entry-common.S Sat Dec 29 11:10:40 2001 @@ -22,12 +22,10 @@ * Our do_softirq out of line code. See include/asm-arm/softirq.h for * the calling assembly. */ - .section ".text.lock","ax" ENTRY(__do_softirq) stmfd sp!, {r0 - r3, ip, lr} bl do_softirq ldmfd sp!, {r0 - r3, ip, pc} - .previous .align 5 /* diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/arm/kernel/process.c linux-2.5/arch/arm/kernel/process.c --- linux-2.5.1/arch/arm/kernel/process.c Sun Sep 30 19:26:08 2001 +++ linux-2.5/arch/arm/kernel/process.c Thu Dec 27 22:10:28 2001 @@ -85,7 +85,6 @@ /* endless idle loop with no priority at all */ init_idle(); current->nice = 20; - current->counter = -100; while (1) { void (*idle)(void) = pm_idle; diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/arm/kernel/semaphore.c linux-2.5/arch/arm/kernel/semaphore.c --- linux-2.5.1/arch/arm/kernel/semaphore.c Fri Apr 27 21:11:59 2001 +++ linux-2.5/arch/arm/kernel/semaphore.c Sat Dec 29 11:10:40 2001 @@ -177,8 +177,7 @@ * value in some cases.. */ #ifdef CONFIG_CPU_26 -asm(" .section .text.lock, \"ax\" - .align 5 +asm(" .align 5 .globl __down_failed __down_failed: stmfd sp!, {r0 - r3, lr} @@ -212,13 +211,11 @@ bl __up ldmfd sp!, {r0 - r3, pc}^ - .previous "); #else /* 32 bit version */ -asm(" .section .text.lock, \"ax\" - .align 5 +asm(" .align 5 .globl __down_failed __down_failed: stmfd sp!, {r0 - r3, lr} @@ -252,7 +249,6 @@ bl __up ldmfd sp!, {r0 - r3, pc} - .previous "); #endif diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/arm/lib/changebit.S linux-2.5/arch/arm/lib/changebit.S --- linux-2.5.1/arch/arm/lib/changebit.S Mon Sep 18 22:15:25 2000 +++ linux-2.5/arch/arm/lib/changebit.S Thu Dec 27 22:10:28 2001 @@ -14,7 +14,9 @@ /* Purpose : Function to change a bit * Prototype: int change_bit(int bit, void *addr) */ -ENTRY(change_bit) +ENTRY(_change_bit_be) + eor r0, r0, #0x18 @ big endian byte ordering +ENTRY(_change_bit_le) and r2, r0, #7 mov r3, #1 mov r3, r3, lsl r2 diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/arm/lib/clearbit.S linux-2.5/arch/arm/lib/clearbit.S --- linux-2.5.1/arch/arm/lib/clearbit.S Mon Sep 18 22:15:25 2000 +++ linux-2.5/arch/arm/lib/clearbit.S Thu Dec 27 22:10:28 2001 @@ -15,8 +15,9 @@ * Purpose : Function to clear a bit * Prototype: int clear_bit(int bit, void *addr) */ - -ENTRY(clear_bit) +ENTRY(_clear_bit_be) + eor r0, r0, #0x18 @ big endian byte ordering +ENTRY(_clear_bit_le) and r2, r0, #7 mov r3, #1 mov r3, r3, lsl r2 diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/arm/lib/findbit.S linux-2.5/arch/arm/lib/findbit.S --- linux-2.5.1/arch/arm/lib/findbit.S Mon Sep 18 22:15:25 2000 +++ linux-2.5/arch/arm/lib/findbit.S Thu Dec 27 22:10:28 2001 @@ -15,14 +15,14 @@ * Purpose : Find a 'zero' bit * Prototype: int find_first_zero_bit(void *addr, int maxbit); */ -ENTRY(find_first_zero_bit) +ENTRY(_find_first_zero_bit_le) mov r2, #0 -.bytelp: ldrb r3, [r0, r2, lsr #3] +1: ldrb r3, [r0, r2, lsr #3] eors r3, r3, #0xff @ invert bits bne .found @ any now set - found zero bit add r2, r2, #8 @ next bit pointer cmp r2, r1 @ any more? - bcc .bytelp + bcc 1b add r0, r1, #1 @ no free bits RETINSTR(mov,pc,lr) @@ -30,15 +30,43 @@ * Purpose : Find next 'zero' bit * Prototype: int find_next_zero_bit(void *addr, int maxbit, int offset) */ -ENTRY(find_next_zero_bit) +ENTRY(_find_next_zero_bit_le) ands ip, r2, #7 - beq .bytelp @ If new byte, goto old routine + beq 1b @ If new byte, goto old routine ldrb r3, [r0, r2, lsr#3] eor r3, r3, #0xff @ now looking for a 1 bit movs r3, r3, lsr ip @ shift off unused bits + bne .found + orr r2, r2, #7 @ if zero, then no bits here + add r2, r2, #1 @ align bit pointer + b 1b @ loop for next bit + +#ifdef __ARMEB__ + +ENTRY(_find_first_zero_bit_be) + mov r2, #0 +1: eor r3, r2, #0x18 @ big endian byte ordering + ldrb r3, [r0, r3, lsr #3] + eors r3, r3, #0xff @ invert bits + bne .found @ any now set - found zero bit + add r2, r2, #8 @ next bit pointer + cmp r2, r1 @ any more? + bcc 1b + add r0, r1, #1 @ no free bits + RETINSTR(mov,pc,lr) + +ENTRY(_find_next_zero_bit_be) + ands ip, r2, #7 + beq 1b @ If new byte, goto old routine + eor r3, r2, #0x18 @ big endian byte ordering + ldrb r3, [r0, r3, lsr#3] + eor r3, r3, #0xff @ now looking for a 1 bit + movs r3, r3, lsr ip @ shift off unused bits orreq r2, r2, #7 @ if zero, then no bits here addeq r2, r2, #1 @ align bit pointer - beq .bytelp @ loop for next bit + beq 1b @ loop for next bit + +#endif /* * One or more bits in the LSB of r3 are assumed to be set. diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/arm/lib/setbit.S linux-2.5/arch/arm/lib/setbit.S --- linux-2.5.1/arch/arm/lib/setbit.S Mon Sep 18 22:15:25 2000 +++ linux-2.5/arch/arm/lib/setbit.S Thu Dec 27 22:10:28 2001 @@ -9,22 +9,21 @@ */ #include <linux/linkage.h> #include <asm/assembler.h> - .text + .text /* * Purpose : Function to set a bit * Prototype: int set_bit(int bit, void *addr) */ - -ENTRY(set_bit) - and r2, r0, #7 - mov r3, #1 - mov r3, r3, lsl r2 +ENTRY(_set_bit_be) + eor r0, r0, #0x18 @ big endian byte ordering +ENTRY(_set_bit_le) + and r2, r0, #7 + mov r3, #1 + mov r3, r3, lsl r2 save_and_disable_irqs ip, r2 ldrb r2, [r1, r0, lsr #3] orr r2, r2, r3 strb r2, [r1, r0, lsr #3] restore_irqs ip RETINSTR(mov,pc,lr) - - diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/arm/lib/testchangebit.S linux-2.5/arch/arm/lib/testchangebit.S --- linux-2.5.1/arch/arm/lib/testchangebit.S Mon Sep 18 22:15:25 2000 +++ linux-2.5/arch/arm/lib/testchangebit.S Thu Dec 27 22:10:28 2001 @@ -11,7 +11,9 @@ #include <asm/assembler.h> .text -ENTRY(test_and_change_bit) +ENTRY(_test_and_change_bit_be) + eor r0, r0, #0x18 @ big endian byte ordering +ENTRY(_test_and_change_bit_le) add r1, r1, r0, lsr #3 and r3, r0, #7 mov r0, #1 diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/arm/lib/testclearbit.S linux-2.5/arch/arm/lib/testclearbit.S --- linux-2.5.1/arch/arm/lib/testclearbit.S Mon Sep 18 22:15:25 2000 +++ linux-2.5/arch/arm/lib/testclearbit.S Thu Dec 27 22:10:28 2001 @@ -11,7 +11,9 @@ #include <asm/assembler.h> .text -ENTRY(test_and_clear_bit) +ENTRY(_test_and_clear_bit_be) + eor r0, r0, #0x18 @ big endian byte ordering +ENTRY(_test_and_clear_bit_le) add r1, r1, r0, lsr #3 @ Get byte offset and r3, r0, #7 @ Get bit offset mov r0, #1 diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/arm/lib/testsetbit.S linux-2.5/arch/arm/lib/testsetbit.S --- linux-2.5.1/arch/arm/lib/testsetbit.S Mon Sep 18 22:15:25 2000 +++ linux-2.5/arch/arm/lib/testsetbit.S Thu Dec 27 22:10:28 2001 @@ -11,7 +11,9 @@ #include <asm/assembler.h> .text -ENTRY(test_and_set_bit) +ENTRY(_test_and_set_bit_be) + eor r0, r0, #0x18 @ big endian byte ordering +ENTRY(_test_and_set_bit_le) add r1, r1, r0, lsr #3 @ Get byte offset and r3, r0, #7 @ Get bit offset mov r0, #1 diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/arm/nwfpe/ARM-gcc.h linux-2.5/arch/arm/nwfpe/ARM-gcc.h --- linux-2.5.1/arch/arm/nwfpe/ARM-gcc.h Thu Jun 17 08:11:35 1999 +++ linux-2.5/arch/arm/nwfpe/ARM-gcc.h Thu Dec 27 22:10:28 2001 @@ -1,11 +1,3 @@ - -/* -------------------------------------------------------------------------------- -One of the macros `BIGENDIAN' or `LITTLEENDIAN' must be defined. -------------------------------------------------------------------------------- -*/ -#define LITTLEENDIAN - /* ------------------------------------------------------------------------------- The macro `BITS64' can be defined to indicate that 64-bit integer types are diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/arm/nwfpe/entry.S linux-2.5/arch/arm/nwfpe/entry.S --- linux-2.5.1/arch/arm/nwfpe/entry.S Sun Aug 12 18:13:59 2001 +++ linux-2.5/arch/arm/nwfpe/entry.S Thu Dec 27 22:10:28 2001 @@ -50,11 +50,10 @@ This routine does three things: -1) It saves SP into a variable called userRegisters. The kernel has -created a struct pt_regs on the stack and saved the user registers -into it. See /usr/include/asm/proc/ptrace.h for details. The -emulator code uses userRegisters as the base of an array of words from -which the contents of the registers can be extracted. +1) The kernel has created a struct pt_regs on the stack and saved the +user registers into it. See /usr/include/asm/proc/ptrace.h for details. +The emulator code uses userRegisters as the base of an array of words +from which the contents of the registers can be extracted. 2) It calls EmulateAll to emulate a floating point instruction. EmulateAll returns 1 if the emulation was successful, or 0 if not. @@ -78,16 +77,18 @@ of stealing two regs from the register allocator. Not sure if it's worth it. */ str sp, [r10] @ Store the user registers pointer in the fpa11 structure. - mov r4, sp @ use r4 for local pointer - mov r10, lr @ save the failure-return addresses + mov r4, lr @ save the failure-return addresses - ldr r5, [r4, #60] @ get contents of PC; + mov r0, r10 + bl FPA11_CheckInit @ check to see if we are initialised + + ldr r5, [sp, #60] @ get contents of PC; sub r8, r5, #4 .Lx2: ldrt r0, [r8] @ get actual instruction into r0 emulate: bl EmulateAll @ emulate the instruction cmp r0, #0 @ was emulation successful - moveq pc, r10 @ no, return failure + moveq pc, r4 @ no, return failure next: .Lx1: ldrt r6, [r5], #4 @ get the next instruction and @@ -99,10 +100,10 @@ teqne r2, #0x0E000000 movne pc, r9 @ return ok if not a fp insn - str r5, [r4, #60] @ update PC copy in regs + str r5, [sp, #60] @ update PC copy in regs mov r0, r6 @ save a copy - ldr r1, [r4, #64] @ fetch the condition codes + ldr r1, [sp, #64] @ fetch the condition codes bl checkCondition @ check the condition cmp r0, #0 @ r0 = 0 ==> condition failed diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/arm/nwfpe/fpa11.c linux-2.5/arch/arm/nwfpe/fpa11.c --- linux-2.5.1/arch/arm/nwfpe/fpa11.c Sun Aug 12 18:13:59 2001 +++ linux-2.5/arch/arm/nwfpe/fpa11.c Thu Dec 27 22:10:28 2001 @@ -18,7 +18,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ - +#include <linux/compiler.h> #include <asm/system.h> #include "fpa11.h" @@ -123,47 +123,58 @@ } } -/* Emulate the instruction in the opcode. */ -unsigned int EmulateAll(unsigned int opcode) +void FPA11_CheckInit(FPA11 *fpa11) { - unsigned int nRc = 0; - unsigned long flags; - FPA11 *fpa11; - save_flags(flags); sti(); - - fpa11 = GET_FPA11(); - - if (fpa11->initflag == 0) /* good place for __builtin_expect */ + if (unlikely(fpa11->initflag == 0)) { resetFPA11(); SetRoundingMode(ROUND_TO_NEAREST); SetRoundingPrecision(ROUND_EXTENDED); fpa11->initflag = 1; } +} - if (TEST_OPCODE(opcode,MASK_CPRT)) - { - /* Emulate conversion opcodes. */ - /* Emulate register transfer opcodes. */ - /* Emulate comparison opcodes. */ - nRc = EmulateCPRT(opcode); - } - else if (TEST_OPCODE(opcode,MASK_CPDO)) - { - /* Emulate monadic arithmetic opcodes. */ - /* Emulate dyadic arithmetic opcodes. */ - nRc = EmulateCPDO(opcode); - } - else if (TEST_OPCODE(opcode,MASK_CPDT)) - { - /* Emulate load/store opcodes. */ - /* Emulate load/store multiple opcodes. */ - nRc = EmulateCPDT(opcode); - } - else +/* Emulate the instruction in the opcode. */ +unsigned int EmulateAll(unsigned int opcode) +{ + unsigned int nRc = 1, code; + unsigned long flags; + FPA11 *fpa11; + + save_flags(flags); sti(); + + code = opcode & 0x00000f00; + if (code == 0x00000100 || code == 0x00000200) { - /* Invalid instruction detected. Return FALSE. */ - nRc = 0; + /* For coprocessor 1 or 2 (FPA11) */ + code = opcode & 0x0e000000; + if (code == 0x0e000000) + { + if (opcode & 0x00000010) + { + /* Emulate conversion opcodes. */ + /* Emulate register transfer opcodes. */ + /* Emulate comparison opcodes. */ + nRc = EmulateCPRT(opcode); + } + else + { + /* Emulate monadic arithmetic opcodes. */ + /* Emulate dyadic arithmetic opcodes. */ + nRc = EmulateCPDO(opcode); + } + } + else if (code == 0x0c000000) + { + /* Emulate load/store opcodes. */ + /* Emulate load/store multiple opcodes. */ + nRc = EmulateCPDT(opcode); + } + else + { + /* Invalid instruction detected. Return FALSE. */ + nRc = 0; + } } restore_flags(flags); diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/arm/nwfpe/fpa11_cpdt.c linux-2.5/arch/arm/nwfpe/fpa11_cpdt.c --- linux-2.5.1/arch/arm/nwfpe/fpa11_cpdt.c Sun Aug 12 18:13:59 2001 +++ linux-2.5/arch/arm/nwfpe/fpa11_cpdt.c Thu Dec 27 22:10:28 2001 @@ -45,7 +45,7 @@ fpa11->fType[Fn] = typeDouble; get_user(p[0], &pMem[1]); get_user(p[1], &pMem[0]); /* sign & exponent */ -} +} static inline void loadExtended(const unsigned int Fn,const unsigned int *pMem) @@ -57,7 +57,7 @@ get_user(p[0], &pMem[0]); /* sign & exponent */ get_user(p[1], &pMem[2]); /* ls bits */ get_user(p[2], &pMem[1]); /* ms bits */ -} +} static inline void loadMultiple(const unsigned int Fn,const unsigned int *pMem) @@ -69,7 +69,7 @@ p = (unsigned int*)&(fpa11->fpreg[Fn]); get_user(x, &pMem[0]); fpa11->fType[Fn] = (x >> 14) & 0x00000003; - + switch (fpa11->fType[Fn]) { case typeSingle: @@ -79,13 +79,13 @@ get_user(p[1], &pMem[1]); /* double msw */ p[2] = 0; /* empty */ } - break; - + break; + case typeExtended: { get_user(p[1], &pMem[2]); get_user(p[2], &pMem[1]); /* msw */ - p[0] = (x & 0x80003fff); + p[0] = (x & 0x80003fff); } break; } @@ -95,82 +95,92 @@ void storeSingle(const unsigned int Fn,unsigned int *pMem) { FPA11 *fpa11 = GET_FPA11(); - float32 val; - register unsigned int *p = (unsigned int*)&val; - + union + { + float32 f; + unsigned int i[1]; + } val; + switch (fpa11->fType[Fn]) { - case typeDouble: - val = float64_to_float32(fpa11->fpreg[Fn].fDouble); + case typeDouble: + val.f = float64_to_float32(fpa11->fpreg[Fn].fDouble); break; - case typeExtended: - val = floatx80_to_float32(fpa11->fpreg[Fn].fExtended); + case typeExtended: + val.f = floatx80_to_float32(fpa11->fpreg[Fn].fExtended); break; - default: val = fpa11->fpreg[Fn].fSingle; + default: val.f = fpa11->fpreg[Fn].fSingle; } - - put_user(p[0], pMem); -} + + put_user(val.i[0], pMem); +} static inline void storeDouble(const unsigned int Fn,unsigned int *pMem) { FPA11 *fpa11 = GET_FPA11(); - float64 val; - register unsigned int *p = (unsigned int*)&val; + union + { + float64 f; + unsigned int i[2]; + } val; switch (fpa11->fType[Fn]) { - case typeSingle: - val = float32_to_float64(fpa11->fpreg[Fn].fSingle); + case typeSingle: + val.f = float32_to_float64(fpa11->fpreg[Fn].fSingle); break; case typeExtended: - val = floatx80_to_float64(fpa11->fpreg[Fn].fExtended); + val.f = floatx80_to_float64(fpa11->fpreg[Fn].fExtended); break; - default: val = fpa11->fpreg[Fn].fDouble; + default: val.f = fpa11->fpreg[Fn].fDouble; } - put_user(p[1], &pMem[0]); /* msw */ - put_user(p[0], &pMem[1]); /* lsw */ -} + + put_user(val.i[1], &pMem[0]); /* msw */ + put_user(val.i[0], &pMem[1]); /* lsw */ +} static inline void storeExtended(const unsigned int Fn,unsigned int *pMem) { FPA11 *fpa11 = GET_FPA11(); - floatx80 val; - register unsigned int *p = (unsigned int*)&val; - + union + { + floatx80 f; + unsigned int i[3]; + } val; + switch (fpa11->fType[Fn]) { - case typeSingle: - val = float32_to_floatx80(fpa11->fpreg[Fn].fSingle); + case typeSingle: + val.f = float32_to_floatx80(fpa11->fpreg[Fn].fSingle); break; - case typeDouble: - val = float64_to_floatx80(fpa11->fpreg[Fn].fDouble); + case typeDouble: + val.f = float64_to_floatx80(fpa11->fpreg[Fn].fDouble); break; - default: val = fpa11->fpreg[Fn].fExtended; + default: val.f = fpa11->fpreg[Fn].fExtended; } - - put_user(p[0], &pMem[0]); /* sign & exp */ - put_user(p[1], &pMem[2]); - put_user(p[2], &pMem[1]); /* msw */ -} + + put_user(val.i[0], &pMem[0]); /* sign & exp */ + put_user(val.i[1], &pMem[2]); + put_user(val.i[2], &pMem[1]); /* msw */ +} static inline void storeMultiple(const unsigned int Fn,unsigned int *pMem) { FPA11 *fpa11 = GET_FPA11(); register unsigned int nType, *p; - + p = (unsigned int*)&(fpa11->fpreg[Fn]); nType = fpa11->fType[Fn]; - + switch (nType) { case typeSingle: @@ -180,8 +190,8 @@ put_user(p[1], &pMem[1]); /* double msw */ put_user(nType << 14, &pMem[0]); } - break; - + break; + case typeExtended: { put_user(p[2], &pMem[1]); /* msw */ @@ -221,7 +231,7 @@ case TRANSFER_EXTENDED: loadExtended(getFd(opcode),pAddress); break; default: nRc = 0; } - + if (write_back) writeRegister(getRn(opcode),(unsigned int)pFinal); return nRc; } @@ -230,10 +240,10 @@ { unsigned int *pBase, *pAddress, *pFinal, nRc = 1, write_back = WRITE_BACK(opcode); - + //printk("PerformSTF(0x%08x), Fd = 0x%08x\n",opcode,getFd(opcode)); SetRoundingMode(ROUND_TO_NEAREST); - + pBase = (unsigned int*)readRegister(getRn(opcode)); if (REG_PC == getRn(opcode)) { @@ -256,7 +266,7 @@ case TRANSFER_EXTENDED: storeExtended(getFd(opcode),pAddress); break; default: nRc = 0; } - + if (write_back) writeRegister(getRn(opcode),(unsigned int)pFinal); return nRc; } @@ -297,14 +307,14 @@ { unsigned int i, Fd, *pBase, *pAddress, *pFinal, write_back = WRITE_BACK(opcode); - + pBase = (unsigned int*)readRegister(getRn(opcode)); if (REG_PC == getRn(opcode)) { pBase += 2; write_back = 0; } - + pFinal = pBase; if (BIT_UP_SET(opcode)) pFinal += getOffset(opcode); @@ -331,7 +341,7 @@ unsigned int nRc = 0; //printk("EmulateCPDT(0x%08x)\n",opcode); - + if (LDF_OP(opcode)) { nRc = PerformLDF(opcode); @@ -343,7 +353,7 @@ else if (STF_OP(opcode)) { nRc = PerformSTF(opcode); - } + } else if (SFM_OP(opcode)) { nRc = PerformSFM(opcode); @@ -352,7 +362,7 @@ { nRc = 0; } - + return nRc; } #endif diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/arm/vmlinux-armo.lds.in linux-2.5/arch/arm/vmlinux-armo.lds.in --- linux-2.5.1/arch/arm/vmlinux-armo.lds.in Sun Aug 12 18:13:59 2001 +++ linux-2.5/arch/arm/vmlinux-armo.lds.in Sat Dec 29 11:10:40 2001 @@ -48,7 +48,6 @@ *(.text) *(.fixup) *(.gnu.warning) - *(.text.lock) /* out-of-line lock text */ *(.rodata) *(.rodata.*) *(.glue_7) diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/arm/vmlinux-armv.lds.in linux-2.5/arch/arm/vmlinux-armv.lds.in --- linux-2.5.1/arch/arm/vmlinux-armv.lds.in Sun Aug 12 18:13:59 2001 +++ linux-2.5/arch/arm/vmlinux-armv.lds.in Sat Dec 29 11:10:40 2001 @@ -43,7 +43,6 @@ *(.text) *(.fixup) *(.gnu.warning) - *(.text.lock) /* out-of-line lock text */ *(.rodata) *(.rodata.*) *(.glue_7) diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/cris/cris.ld linux-2.5/arch/cris/cris.ld --- linux-2.5.1/arch/cris/cris.ld Mon Oct 8 18:43:54 2001 +++ linux-2.5/arch/cris/cris.ld Sat Dec 29 11:10:40 2001 @@ -24,7 +24,6 @@ *(.fixup) *(.text.__*) } - .text.lock : { *(.text.lock) } /* out-of-line lock text */ _etext = . ; /* End of text section */ __etext = .; diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/cris/kernel/process.c linux-2.5/arch/cris/kernel/process.c --- linux-2.5.1/arch/cris/kernel/process.c Fri Nov 9 21:58:02 2001 +++ linux-2.5/arch/cris/kernel/process.c Thu Dec 27 22:10:28 2001 @@ -119,7 +119,6 @@ int cpu_idle(void *unused) { while(1) { - current->counter = -100; schedule(); } } diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/i386/boot/compressed/Makefile linux-2.5/arch/i386/boot/compressed/Makefile --- linux-2.5.1/arch/i386/boot/compressed/Makefile Wed Sep 12 06:08:12 2001 +++ linux-2.5/arch/i386/boot/compressed/Makefile Sat Dec 29 11:10:40 2001 @@ -32,8 +32,10 @@ head.o: head.S $(CC) $(AFLAGS) -traditional -c head.S +comma := , + misc.o: misc.c - $(CC) $(CFLAGS) -c misc.c + $(CC) $(CFLAGS) -DKBUILD_BASENAME=$(subst $(comma),_,$(subst -,_,$(*F))) -c misc.c piggy.o: $(SYSTEM) tmppiggy=_tmp_$$$$piggy; \ diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/i386/boot/setup.S linux-2.5/arch/i386/boot/setup.S --- linux-2.5.1/arch/i386/boot/setup.S Wed Nov 28 18:24:33 2001 +++ linux-2.5/arch/i386/boot/setup.S Thu Dec 27 16:32:30 2001 @@ -50,7 +50,8 @@ #include <linux/compile.h> #include <asm/boot.h> #include <asm/e820.h> - +#include <asm/page.h> + /* Signature words to ensure LILO loaded us right */ #define SIG1 0xAA55 #define SIG2 0x5A5A @@ -79,7 +80,7 @@ # This is the setup header, and it must start at %cs:2 (old 0x9020:2) .ascii "HdrS" # header signature - .word 0x0202 # header version number (>= 0x0105) + .word 0x0203 # header version number (>= 0x0105) # or else old loadlin-1.5 will fail) realmode_swtch: .word 0, 0 # default_switch, SETUPSEG start_sys_seg: .word SYSSEG @@ -152,6 +153,10 @@ # 0x90000 segment; the setup # can be located anywhere in # low memory 0x10000 or higher. + +ramdisk_max: .long __MAXMEM-1 # (Header version 0x0203 or later) + # The highest safe address for + # the contents of an initrd trampoline: call start_of_setup .space 1024 diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/i386/config.in linux-2.5/arch/i386/config.in --- linux-2.5.1/arch/i386/config.in Mon Nov 12 19:58:08 2001 +++ linux-2.5/arch/i386/config.in Mon Dec 31 00:19:52 2001 @@ -52,6 +52,7 @@ define_int CONFIG_X86_L1_CACHE_SHIFT 4 define_bool CONFIG_RWSEM_GENERIC_SPINLOCK y define_bool CONFIG_RWSEM_XCHGADD_ALGORITHM n + define_bool CONFIG_X86_PPRO_FENCE y else define_bool CONFIG_X86_WP_WORKS_OK y define_bool CONFIG_X86_INVLPG y @@ -66,17 +67,20 @@ define_int CONFIG_X86_L1_CACHE_SHIFT 4 define_bool CONFIG_X86_USE_STRING_486 y define_bool CONFIG_X86_ALIGNMENT_16 y + define_bool CONFIG_X86_PPRO_FENCE y fi if [ "$CONFIG_M586" = "y" ]; then define_int CONFIG_X86_L1_CACHE_SHIFT 5 define_bool CONFIG_X86_USE_STRING_486 y define_bool CONFIG_X86_ALIGNMENT_16 y + define_bool CONFIG_X86_PPRO_FENCE y fi if [ "$CONFIG_M586TSC" = "y" ]; then define_int CONFIG_X86_L1_CACHE_SHIFT 5 define_bool CONFIG_X86_USE_STRING_486 y define_bool CONFIG_X86_ALIGNMENT_16 y define_bool CONFIG_X86_TSC y + define_bool CONFIG_X86_PPRO_FENCE y fi if [ "$CONFIG_M586MMX" = "y" ]; then define_int CONFIG_X86_L1_CACHE_SHIFT 5 @@ -84,6 +88,7 @@ define_bool CONFIG_X86_ALIGNMENT_16 y define_bool CONFIG_X86_TSC y define_bool CONFIG_X86_GOOD_APIC y + define_bool CONFIG_X86_PPRO_FENCE y fi if [ "$CONFIG_M686" = "y" ]; then define_int CONFIG_X86_L1_CACHE_SHIFT 5 @@ -91,6 +96,7 @@ define_bool CONFIG_X86_GOOD_APIC y define_bool CONFIG_X86_PGE y define_bool CONFIG_X86_USE_PPRO_CHECKSUM y + define_bool CONFIG_X86_PPRO_FENCE y fi if [ "$CONFIG_MPENTIUMIII" = "y" ]; then define_int CONFIG_X86_L1_CACHE_SHIFT 5 @@ -135,21 +141,24 @@ define_int CONFIG_X86_L1_CACHE_SHIFT 5 define_bool CONFIG_X86_ALIGNMENT_16 y define_bool CONFIG_X86_USE_PPRO_CHECKSUM y + define_bool CONFIG_X86_OOSTORE y fi if [ "$CONFIG_MWINCHIP2" = "y" ]; then define_int CONFIG_X86_L1_CACHE_SHIFT 5 define_bool CONFIG_X86_ALIGNMENT_16 y define_bool CONFIG_X86_TSC y define_bool CONFIG_X86_USE_PPRO_CHECKSUM y + define_bool CONFIG_X86_OOSTORE y fi if [ "$CONFIG_MWINCHIP3D" = "y" ]; then define_int CONFIG_X86_L1_CACHE_SHIFT 5 define_bool CONFIG_X86_ALIGNMENT_16 y define_bool CONFIG_X86_TSC y define_bool CONFIG_X86_USE_PPRO_CHECKSUM y + define_bool CONFIG_X86_OOSTORE y fi tristate 'Toshiba Laptop support' CONFIG_TOSHIBA -tristate 'Dell Inspiron 8000 support' CONFIG_I8K +tristate 'Dell laptop support' CONFIG_I8K tristate '/dev/cpu/microcode - Intel IA32 CPU microcode support' CONFIG_MICROCODE tristate '/dev/cpu/*/msr - Model-specific register support' CONFIG_X86_MSR @@ -407,6 +416,7 @@ bool ' Magic SysRq key' CONFIG_MAGIC_SYSRQ bool ' Spinlock debugging' CONFIG_DEBUG_SPINLOCK bool ' Verbose BUG() reporting (adds 70K)' CONFIG_DEBUG_BUGVERBOSE + bool ' Debug 486 string copies' CONFIG_DEBUG_486_STRING fi endmenu diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/i386/kernel/Makefile linux-2.5/arch/i386/kernel/Makefile --- linux-2.5.1/arch/i386/kernel/Makefile Fri Nov 9 22:21:21 2001 +++ linux-2.5/arch/i386/kernel/Makefile Fri Dec 28 18:47:41 2001 @@ -18,7 +18,8 @@ obj-y := process.o semaphore.o signal.o entry.o traps.o irq.o vm86.o \ ptrace.o i8259.o ioport.o ldt.o setup.o time.o sys_i386.o \ - pci-dma.o i386_ksyms.o i387.o bluesmoke.o dmi_scan.o + pci-dma.o i386_ksyms.o i387.o bluesmoke.o dmi_scan.o \ + bootflag.o ifdef CONFIG_PCI @@ -39,6 +40,9 @@ obj-$(CONFIG_SMP) += smp.o smpboot.o trampoline.o obj-$(CONFIG_X86_LOCAL_APIC) += mpparse.o apic.o nmi.o obj-$(CONFIG_X86_IO_APIC) += io_apic.o acpitable.o +ifdef CONFIG_VISWS +obj-y += setup-visws.o obj-$(CONFIG_X86_VISWS_APIC) += visws_apic.o +endif include $(TOPDIR)/Rules.make diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/i386/kernel/apic.c linux-2.5/arch/i386/kernel/apic.c --- linux-2.5.1/arch/i386/kernel/apic.c Fri Nov 9 22:12:55 2001 +++ linux-2.5/arch/i386/kernel/apic.c Thu Dec 27 22:10:28 2001 @@ -56,6 +56,14 @@ maxlvt = get_maxlvt(); /* + * Masking an LVT entry on a P6 can trigger a local APIC error + * if the vector is zero. Mask LVTERR first to prevent this. + */ + if (maxlvt >= 3) { + v = ERROR_APIC_VECTOR; /* any non-zero vector will do */ + apic_write_around(APIC_LVTERR, v | APIC_LVT_MASKED); + } + /* * Careful: we have to set masks only first to deassert * any level-triggered sources. */ @@ -65,10 +73,6 @@ apic_write_around(APIC_LVT0, v | APIC_LVT_MASKED); v = apic_read(APIC_LVT1); apic_write_around(APIC_LVT1, v | APIC_LVT_MASKED); - if (maxlvt >= 3) { - v = apic_read(APIC_LVTERR); - apic_write_around(APIC_LVTERR, v | APIC_LVT_MASKED); - } if (maxlvt >= 4) { v = apic_read(APIC_LVTPC); apic_write_around(APIC_LVTPC, v | APIC_LVT_MASKED); @@ -84,6 +88,8 @@ apic_write_around(APIC_LVTERR, APIC_LVT_MASKED); if (maxlvt >= 4) apic_write_around(APIC_LVTPC, APIC_LVT_MASKED); + apic_write(APIC_ESR, 0); + v = apic_read(APIC_ESR); } void __init connect_bsp_APIC(void) @@ -480,6 +486,7 @@ l &= ~MSR_IA32_APICBASE_BASE; l |= MSR_IA32_APICBASE_ENABLE | APIC_DEFAULT_PHYS_BASE; wrmsr(MSR_IA32_APICBASE, l, h); + apic_write(APIC_LVTERR, ERROR_APIC_VECTOR | APIC_LVT_MASKED); apic_write(APIC_ID, apic_pm_state.apic_id); apic_write(APIC_DFR, apic_pm_state.apic_dfr); apic_write(APIC_LDR, apic_pm_state.apic_ldr); @@ -487,15 +494,15 @@ apic_write(APIC_SPIV, apic_pm_state.apic_spiv); apic_write(APIC_LVT0, apic_pm_state.apic_lvt0); apic_write(APIC_LVT1, apic_pm_state.apic_lvt1); + apic_write(APIC_LVTPC, apic_pm_state.apic_lvtpc); + apic_write(APIC_LVTT, apic_pm_state.apic_lvtt); + apic_write(APIC_TDCR, apic_pm_state.apic_tdcr); + apic_write(APIC_TMICT, apic_pm_state.apic_tmict); apic_write(APIC_ESR, 0); apic_read(APIC_ESR); apic_write(APIC_LVTERR, apic_pm_state.apic_lvterr); apic_write(APIC_ESR, 0); apic_read(APIC_ESR); - apic_write(APIC_LVTPC, apic_pm_state.apic_lvtpc); - apic_write(APIC_LVTT, apic_pm_state.apic_lvtt); - apic_write(APIC_TDCR, apic_pm_state.apic_tdcr); - apic_write(APIC_TMICT, apic_pm_state.apic_tmict); __restore_flags(flags); if (apic_pm_state.perfctr_pmdev) pm_send(apic_pm_state.perfctr_pmdev, PM_RESUME, data); diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/i386/kernel/bootflag.c linux-2.5/arch/i386/kernel/bootflag.c --- linux-2.5.1/arch/i386/kernel/bootflag.c Thu Jan 1 00:00:00 1970 +++ linux-2.5/arch/i386/kernel/bootflag.c Mon Dec 31 18:32:31 2001 @@ -0,0 +1,253 @@ +/* + * Implement 'Simple Boot Flag Specification 1.0' + * + */ + + +#include <linux/config.h> +#include <linux/types.h> +#include <linux/kernel.h> +#include <linux/init.h> +#include <linux/string.h> +#include <linux/slab.h> +#include <linux/spinlock.h> +#include <asm/io.h> + +#include <linux/mc146818rtc.h> + + +#define SBF_RESERVED (0x78) +#define SBF_PNPOS (1<<0) +#define SBF_BOOTING (1<<1) +#define SBF_DIAG (1<<2) +#define SBF_PARITY (1<<7) + + +struct sbf_boot +{ + u8 sbf_signature[4]; + u32 sbf_len; + u8 sbf_revision __attribute((packed)); + u8 sbf_csum __attribute((packed)); + u8 sbf_oemid[6] __attribute((packed)); + u8 sbf_oemtable[8] __attribute((packed)); + u8 sbf_revdata[4] __attribute((packed)); + u8 sbf_creator[4] __attribute((packed)); + u8 sbf_crearev[4] __attribute((packed)); + u8 sbf_cmos __attribute((packed)); + u8 sbf_spare[3] __attribute((packed)); +}; + + +static int sbf_port __initdata = -1; + +static int __init sbf_struct_valid(unsigned long tptr) +{ + u8 *ap; + u8 v; + unsigned int i; + struct sbf_boot sb; + + memcpy_fromio(&sb, tptr, sizeof(sb)); + + if(sb.sbf_len != 40 && sb.sbf_len != 39) + // 39 on IBM ThinkPad A21m, BIOS version 1.02b (KXET24WW; 2000-12-19). + return 0; + + ap = (u8 *)&sb; + v= 0; + + for(i=0;i<sb.sbf_len;i++) + v+=*ap++; + + if(v) + return 0; + + if(memcmp(sb.sbf_signature, "BOOT", 4)) + return 0; + + if (sb.sbf_len == 39) + printk (KERN_WARNING "SBF: ACPI BOOT descriptor is wrong length (%d)\n", + sb.sbf_len); + + sbf_port = sb.sbf_cmos; /* Save CMOS port */ + return 1; +} + +static int __init parity(u8 v) +{ + int x = 0; + int i; + + for(i=0;i<8;i++) + { + x^=(v&1); + v>>=1; + } + return x; +} + +static void __init sbf_write(u8 v) +{ + unsigned long flags; + if(sbf_port != -1) + { + v &= ~SBF_PARITY; + if(!parity(v)) + v|=SBF_PARITY; + + printk(KERN_INFO "SBF: Setting boot flags 0x%x\n",v); + + spin_lock_irqsave(&rtc_lock, flags); + CMOS_WRITE(v, sbf_port); + spin_unlock_irqrestore(&rtc_lock, flags); + } +} + +static u8 __init sbf_read(void) +{ + u8 v; + unsigned long flags; + if(sbf_port == -1) + return 0; + spin_lock_irqsave(&rtc_lock, flags); + v = CMOS_READ(sbf_port); + spin_unlock_irqrestore(&rtc_lock, flags); + return v; +} + +static int __init sbf_value_valid(u8 v) +{ + if(v&SBF_RESERVED) /* Reserved bits */ + return 0; + if(!parity(v)) + return 0; + return 1; +} + + +static void __init sbf_bootup(void) +{ + u8 v; + if(sbf_port == -1) + return; + v = sbf_read(); + if(!sbf_value_valid(v)) + printk(KERN_WARNING "SBF: Simple boot flag value 0x%x read from CMOS RAM was invalid\n",v); + v &= ~SBF_RESERVED; + v &= ~SBF_BOOTING; + v &= ~SBF_DIAG; +#if defined(CONFIG_ISAPNP) + v |= SBF_PNPOS; +#endif + sbf_write(v); +} + +static int __init sbf_init(void) +{ + unsigned int i; + void *rsdt; + u32 rsdtlen = 0; + u32 rsdtbase = 0; + u8 sum = 0; + int n; + + u8 *p; + + for(i=0xE0000; i <= 0xFFFE0; i+=16) + { + p = phys_to_virt(i); + + if(memcmp(p, "RSD PTR ", 8)) + continue; + + sum = 0; + for(n=0; n<20; n++) + sum+=p[n]; + + if(sum != 0) + continue; + + /* So it says RSD PTR and it checksums... */ + + /* + * Process the RDSP pointer + */ + + rsdtbase = *(u32 *)(p+16); + + /* + * RSDT length is ACPI 2 only, for ACPI 1 we must map + * and remap. + */ + + if(p[15]>1) + rsdtlen = *(u32 *)(p+20); + else + rsdtlen = 36; + + if(rsdtlen < 36 || rsdtlen > 1024) + continue; + break; + } + if(i>0xFFFE0) + return 0; + + + rsdt = ioremap(rsdtbase, rsdtlen); + if(rsdt == 0) + return 0; + + i = readl(rsdt + 4); + + /* + * Remap if needed + */ + + if(i > rsdtlen) + { + rsdtlen = i; + iounmap(rsdt); + rsdt = ioremap(rsdtbase, rsdtlen); + if(rsdt == 0) + return 0; + } + + for(n = 0; n < i; n++) + sum += readb(rsdt + n); + + if(sum) + { + iounmap(rsdt); + return 0; + } + + /* Ok the RSDT checksums too */ + + for(n = 36; n+3 < i; n += 4) + { + unsigned long rp = readl(rsdt+n); + int len = 4096; + + if(rp > 0xFFFFFFFFUL - len) + len = 0xFFFFFFFFUL - rp; + + /* Too close to the end!! */ + if(len < 20) + continue; + rp = (unsigned long)ioremap(rp, 4096); + if(rp == 0) + continue; + if(sbf_struct_valid(rp)) + { + /* Found the BOOT table and processed it */ + printk(KERN_INFO "SBF: Simple Boot Flag extension found and enabled.\n"); + } + iounmap((void *)rp); + } + iounmap(rsdt); + sbf_bootup(); + return 0; +} + +module_init(sbf_init); diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/i386/kernel/dmi_scan.c linux-2.5/arch/i386/kernel/dmi_scan.c --- linux-2.5.1/arch/i386/kernel/dmi_scan.c Thu Dec 6 22:01:17 2001 +++ linux-2.5/arch/i386/kernel/dmi_scan.c Thu Dec 13 16:32:35 2001 @@ -572,6 +572,11 @@ MATCH(DMI_BIOS_VERSION,"L440GX0.86B.0094.P10"), NO_MATCH, NO_MATCH } }, + { broken_pirq, "l44GX Bios", { /* Bad $PIR */ + MATCH(DMI_BIOS_VENDOR, "Intel Corporation"), + MATCH(DMI_BIOS_VERSION,"L440GX0.86B.0120.P12"), + NO_MATCH, NO_MATCH + } }, { broken_pirq, "l44GX Bios", { /* Bad $PIR */ MATCH(DMI_BIOS_VENDOR, "Intel Corporation"), MATCH(DMI_BIOS_VERSION,"L440GX0.86B.0125.P13"), diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/i386/kernel/head.S linux-2.5/arch/i386/kernel/head.S --- linux-2.5.1/arch/i386/kernel/head.S Wed Jun 20 18:00:53 2001 +++ linux-2.5/arch/i386/kernel/head.S Sat Dec 29 12:07:12 2001 @@ -445,13 +445,14 @@ .quad 0x00409a0000000000 /* 0x48 APM CS code */ .quad 0x00009a0000000000 /* 0x50 APM CS 16 code (16 bit) */ .quad 0x0040920000000000 /* 0x58 APM DS data */ + /* Segments used for calling PnP BIOS */ + .quad 0x00c09a0000000000 /* 0x60 32-bit code */ + .quad 0x00809a0000000000 /* 0x68 16-bit code */ + .quad 0x0080920000000000 /* 0x70 16-bit data */ + .quad 0x0080920000000000 /* 0x78 16-bit data */ + .quad 0x0080920000000000 /* 0x80 16-bit data */ + .quad 0x0000000000000000 /* 0x88 not used */ + .quad 0x0000000000000000 /* 0x90 not used */ + .quad 0x0000000000000000 /* 0x98 not used */ + /* Per CPU segments */ .fill NR_CPUS*4,8,0 /* space for TSS's and LDT's */ - -/* - * This is to aid debugging, the various locking macros will be putting - * code fragments here. When an oops occurs we'd rather know that it's - * inside the .text.lock section rather than as some offset from whatever - * function happens to be last in the .text segment. - */ -.section .text.lock -ENTRY(stext_lock) diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/i386/kernel/i386_ksyms.c linux-2.5/arch/i386/kernel/i386_ksyms.c --- linux-2.5.1/arch/i386/kernel/i386_ksyms.c Tue Nov 13 17:13:20 2001 +++ linux-2.5/arch/i386/kernel/i386_ksyms.c Fri Dec 28 18:07:07 2001 @@ -51,9 +51,7 @@ /* platform dependent support */ EXPORT_SYMBOL(boot_cpu_data); -#ifdef CONFIG_EISA EXPORT_SYMBOL(EISA_bus); -#endif EXPORT_SYMBOL(MCA_bus); EXPORT_SYMBOL(__verify_write); EXPORT_SYMBOL(dump_thread); diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/i386/kernel/ldt.c linux-2.5/arch/i386/kernel/ldt.c --- linux-2.5.1/arch/i386/kernel/ldt.c Wed Oct 17 21:46:29 2001 +++ linux-2.5/arch/i386/kernel/ldt.c Fri Dec 28 00:00:30 2001 @@ -12,37 +12,137 @@ #include <linux/smp.h> #include <linux/smp_lock.h> #include <linux/vmalloc.h> +#include <linux/slab.h> #include <asm/uaccess.h> #include <asm/system.h> #include <asm/ldt.h> #include <asm/desc.h> +#ifdef CONFIG_SMP /* avoids "defined but not used" warnig */ +static void flush_ldt(void *mm) +{ + if (current->mm) + load_LDT(¤t->mm->context); +} +#endif + +static int alloc_ldt(mm_context_t *pc, int mincount, int reload) +{ + void *oldldt; + void *newldt; + int oldsize; + + if (mincount <= pc->size) + return 0; + oldsize = pc->size; + mincount = (mincount+511)&(~511); + if (mincount*LDT_ENTRY_SIZE > PAGE_SIZE) + newldt = vmalloc(mincount*LDT_ENTRY_SIZE); + else + newldt = kmalloc(mincount*LDT_ENTRY_SIZE, GFP_KERNEL); + + if (!newldt) + return -ENOMEM; + + if (oldsize) + memcpy(newldt, pc->ldt, oldsize*LDT_ENTRY_SIZE); + oldldt = pc->ldt; + memset(newldt+oldsize*LDT_ENTRY_SIZE, 0, (mincount-oldsize)*LDT_ENTRY_SIZE); + wmb(); + pc->ldt = newldt; + pc->size = mincount; + if (reload) { + load_LDT(pc); +#ifdef CONFIG_SMP + if (current->mm->cpu_vm_mask != (1<<smp_processor_id())) + smp_call_function(flush_ldt, 0, 1, 1); +#endif + } + wmb(); + if (oldsize) { + if (oldsize*LDT_ENTRY_SIZE > PAGE_SIZE) + vfree(oldldt); + else + kfree(oldldt); + } + return 0; +} + +static inline int copy_ldt(mm_context_t *new, mm_context_t *old) +{ + int err = alloc_ldt(new, old->size, 0); + if (err < 0) { + printk(KERN_WARNING "ldt allocation failed\n"); + new->size = 0; + return err; + } + memcpy(new->ldt, old->ldt, old->size*LDT_ENTRY_SIZE); + return 0; +} + /* - * read_ldt() is not really atomic - this is not a problem since - * synchronization of reads and writes done to the LDT has to be - * assured by user-space anyway. Writes are atomic, to protect - * the security checks done on new descriptors. + * we do not have to muck with descriptors here, that is + * done in switch_mm() as needed. */ +int init_new_context(struct task_struct *tsk, struct mm_struct *mm) +{ + struct mm_struct * old_mm; + int retval = 0; + + init_MUTEX(&mm->context.sem); + mm->context.size = 0; + old_mm = current->mm; + if (old_mm && old_mm->context.size > 0) { + down(&old_mm->context.sem); + retval = copy_ldt(&mm->context, &old_mm->context); + up(&old_mm->context.sem); + } + return retval; +} + +/* + * No need to lock the MM as we are the last user + */ +void release_segments(struct mm_struct *mm) +{ + if (mm->context.size) { + clear_LDT(); + if (mm->context.size*LDT_ENTRY_SIZE > PAGE_SIZE) + vfree(mm->context.ldt); + else + kfree(mm->context.ldt); + mm->context.size = 0; + } +} + static int read_ldt(void * ptr, unsigned long bytecount) { int err; unsigned long size; struct mm_struct * mm = current->mm; - err = 0; - if (!mm->context.segments) - goto out; + if (!mm->context.size) + return 0; + if (bytecount > LDT_ENTRY_SIZE*LDT_ENTRIES) + bytecount = LDT_ENTRY_SIZE*LDT_ENTRIES; - size = LDT_ENTRIES*LDT_ENTRY_SIZE; + down(&mm->context.sem); + size = mm->context.size*LDT_ENTRY_SIZE; if (size > bytecount) size = bytecount; - err = size; - if (copy_to_user(ptr, mm->context.segments, size)) + err = 0; + if (copy_to_user(ptr, mm->context.ldt, size)) err = -EFAULT; -out: - return err; + up(&mm->context.sem); + if (err < 0) + return err; + if (size != bytecount) { + /* zero-fill the rest */ + clear_user(ptr+size, bytecount-size); + } + return bytecount; } static int read_default_ldt(void * ptr, unsigned long bytecount) @@ -53,7 +153,7 @@ err = 0; address = &default_ldt[0]; - size = sizeof(struct desc_struct); + size = 5*sizeof(struct desc_struct); if (size > bytecount) size = bytecount; @@ -88,24 +188,14 @@ goto out; } - /* - * the GDT index of the LDT is allocated dynamically, and is - * limited by MAX_LDT_DESCRIPTORS. - */ - down_write(&mm->mmap_sem); - if (!mm->context.segments) { - void * segments = vmalloc(LDT_ENTRIES*LDT_ENTRY_SIZE); - error = -ENOMEM; - if (!segments) + down(&mm->context.sem); + if (ldt_info.entry_number >= mm->context.size) { + error = alloc_ldt(¤t->mm->context, ldt_info.entry_number+1, 1); + if (error < 0) goto out_unlock; - memset(segments, 0, LDT_ENTRIES*LDT_ENTRY_SIZE); - wmb(); - mm->context.segments = segments; - mm->context.cpuvalid = 1UL << smp_processor_id(); - load_LDT(mm); } - lp = (__u32 *) ((ldt_info.entry_number << 3) + (char *) mm->context.segments); + lp = (__u32 *) ((ldt_info.entry_number << 3) + (char *) mm->context.ldt); /* Allow LDTs to be cleared by the user. */ if (ldt_info.base_addr == 0 && ldt_info.limit == 0) { @@ -143,7 +233,7 @@ error = 0; out_unlock: - up_write(&mm->mmap_sem); + up(&mm->context.sem); out: return error; } diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/i386/kernel/mpparse.c linux-2.5/arch/i386/kernel/mpparse.c --- linux-2.5.1/arch/i386/kernel/mpparse.c Fri Nov 9 22:58:18 2001 +++ linux-2.5/arch/i386/kernel/mpparse.c Fri Dec 28 11:27:00 2001 @@ -799,11 +799,13 @@ * trustworthy, simply because the SMP table may have been * stomped on during early boot. These loaders are buggy and * should be fixed. + * + * MP1.4 SPEC states to only scan first 1K of 4K EBDA. */ address = *(unsigned short *)phys_to_virt(0x40E); address <<= 4; - smp_scan_config(address, 0x1000); + smp_scan_config(address, 0x400); if (smp_found_config) printk(KERN_WARNING "WARNING: MP table in the EBDA can be UNSAFE, contact linux-smp@vger.kernel.org if you experience SMP problems!\n"); } diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/i386/kernel/pci-pc.c linux-2.5/arch/i386/kernel/pci-pc.c --- linux-2.5.1/arch/i386/kernel/pci-pc.c Sat Dec 8 00:26:13 2001 +++ linux-2.5/arch/i386/kernel/pci-pc.c Thu Dec 27 16:05:22 2001 @@ -30,7 +30,7 @@ * This interrupt-safe spinlock protects all accesses to PCI * configuration space. */ -spinlock_t pci_config_lock = SPIN_LOCK_UNLOCKED; +static spinlock_t pci_config_lock = SPIN_LOCK_UNLOCKED; /* @@ -1109,17 +1109,15 @@ } /* - * Nobody seems to know what this does. Damn. - * - * But it does seem to fix some unspecified problem - * with 'movntq' copies on Athlons. + * Addresses issues with problems in the memory write queue timer in + * certain VIA Northbridges. This bugfix is per VIA's specifications. * * VIA 8363,8622,8361 Northbridges: * - bits 5, 6, 7 at offset 0x55 need to be turned off * VIA 8367 (KT266x) Northbridges: * - bits 5, 6, 7 at offset 0x95 need to be turned off */ -static void __init pci_fixup_via_athlon_bug(struct pci_dev *d) +static void __init pci_fixup_via_northbridge_bug(struct pci_dev *d) { u8 v; int where = 0x55; @@ -1131,7 +1129,7 @@ pci_read_config_byte(d, where, &v); if (v & 0xe0) { - printk("Trying to stomp on Athlon bug...\n"); + printk("Disabling broken memory write queue.\n"); v &= 0x1f; /* clear bits 5, 6, 7 */ pci_write_config_byte(d, where, v); } @@ -1146,10 +1144,10 @@ { PCI_FIXUP_HEADER, PCI_VENDOR_ID_SI, PCI_DEVICE_ID_SI_5597, pci_fixup_latency }, { PCI_FIXUP_HEADER, PCI_VENDOR_ID_SI, PCI_DEVICE_ID_SI_5598, pci_fixup_latency }, { PCI_FIXUP_HEADER, PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82371AB_3, pci_fixup_piix4_acpi }, - { PCI_FIXUP_HEADER, PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_8363_0, pci_fixup_via_athlon_bug }, - { PCI_FIXUP_HEADER, PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_8622, pci_fixup_via_athlon_bug }, - { PCI_FIXUP_HEADER, PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_8361, pci_fixup_via_athlon_bug }, - { PCI_FIXUP_HEADER, PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_8367_0, pci_fixup_via_athlon_bug }, + { PCI_FIXUP_HEADER, PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_8363_0, pci_fixup_via_northbridge_bug }, + { PCI_FIXUP_HEADER, PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_8622, pci_fixup_via_northbridge_bug }, + { PCI_FIXUP_HEADER, PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_8361, pci_fixup_via_northbridge_bug }, + { PCI_FIXUP_HEADER, PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_8367_0, pci_fixup_via_northbridge_bug }, { 0 } }; diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/i386/kernel/process.c linux-2.5/arch/i386/kernel/process.c --- linux-2.5.1/arch/i386/kernel/process.c Fri Oct 5 01:42:54 2001 +++ linux-2.5/arch/i386/kernel/process.c Fri Dec 28 00:00:30 2001 @@ -125,7 +125,6 @@ /* endless idle loop with no priority at all */ init_idle(); current->nice = 20; - current->counter = -100; while (1) { void (*idle)(void) = pm_idle; @@ -465,23 +464,6 @@ } /* - * No need to lock the MM as we are the last user - */ -void release_segments(struct mm_struct *mm) -{ - void * ldt = mm->context.segments; - - /* - * free the LDT - */ - if (ldt) { - mm->context.segments = NULL; - clear_LDT(); - vfree(ldt); - } -} - -/* * Create a kernel thread */ int kernel_thread(int (*fn)(void *), void * arg, unsigned long flags) @@ -533,40 +515,15 @@ void release_thread(struct task_struct *dead_task) { if (dead_task->mm) { - void * ldt = dead_task->mm->context.segments; - // temporary debugging check - if (ldt) { - printk("WARNING: dead process %8s still has LDT? <%p>\n", - dead_task->comm, ldt); + if (dead_task->mm->context.size) { + printk("WARNING: dead process %8s still has LDT? <%p/%d>\n", + dead_task->comm, + dead_task->mm->context.ldt, + dead_task->mm->context.size); BUG(); } } -} - -/* - * we do not have to muck with descriptors here, that is - * done in switch_mm() as needed. - */ -void copy_segments(struct task_struct *p, struct mm_struct *new_mm) -{ - struct mm_struct * old_mm; - void *old_ldt, *ldt; - - ldt = NULL; - old_mm = current->mm; - if (old_mm && (old_ldt = old_mm->context.segments) != NULL) { - /* - * Completely new LDT, we initialize it from the parent: - */ - ldt = vmalloc(LDT_ENTRIES*LDT_ENTRY_SIZE); - if (!ldt) - printk(KERN_WARNING "ldt allocation failed\n"); - else - memcpy(ldt, old_ldt, LDT_ENTRIES*LDT_ENTRY_SIZE); - } - new_mm->context.segments = ldt; - new_mm->context.cpuvalid = ~0UL; /* valid on all CPU's - they can't have stale data */ } /* diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/i386/kernel/setup-visws.c linux-2.5/arch/i386/kernel/setup-visws.c --- linux-2.5.1/arch/i386/kernel/setup-visws.c Thu Jan 1 00:00:00 1970 +++ linux-2.5/arch/i386/kernel/setup-visws.c Fri Dec 28 18:52:20 2001 @@ -0,0 +1,126 @@ +/* + * Unmaintained SGI Visual Workstation support. + * Split out from setup.c by davej@suse.de + */ + +char visws_board_type = -1; +char visws_board_rev = -1; + +#define PIIX_PM_START 0x0F80 + +#define SIO_GPIO_START 0x0FC0 + +#define SIO_PM_START 0x0FC8 + +#define PMBASE PIIX_PM_START +#define GPIREG0 (PMBASE+0x30) +#define GPIREG(x) (GPIREG0+((x)/8)) +#define PIIX_GPI_BD_ID1 18 +#define PIIX_GPI_BD_REG GPIREG(PIIX_GPI_BD_ID1) + +#define PIIX_GPI_BD_SHIFT (PIIX_GPI_BD_ID1 % 8) + +#define SIO_INDEX 0x2e +#define SIO_DATA 0x2f + +#define SIO_DEV_SEL 0x7 +#define SIO_DEV_ENB 0x30 +#define SIO_DEV_MSB 0x60 +#define SIO_DEV_LSB 0x61 + +#define SIO_GP_DEV 0x7 + +#define SIO_GP_BASE SIO_GPIO_START +#define SIO_GP_MSB (SIO_GP_BASE>>8) +#define SIO_GP_LSB (SIO_GP_BASE&0xff) + +#define SIO_GP_DATA1 (SIO_GP_BASE+0) + +#define SIO_PM_DEV 0x8 + +#define SIO_PM_BASE SIO_PM_START +#define SIO_PM_MSB (SIO_PM_BASE>>8) +#define SIO_PM_LSB (SIO_PM_BASE&0xff) +#define SIO_PM_INDEX (SIO_PM_BASE+0) +#define SIO_PM_DATA (SIO_PM_BASE+1) + +#define SIO_PM_FER2 0x1 + +#define SIO_PM_GP_EN 0x80 + +void __init visws_get_board_type_and_rev(void) +{ + int raw; + + visws_board_type = (char)(inb_p(PIIX_GPI_BD_REG) & PIIX_GPI_BD_REG) + >> PIIX_GPI_BD_SHIFT; +/* + * Get Board rev. + * First, we have to initialize the 307 part to allow us access + * to the GPIO registers. Let's map them at 0x0fc0 which is right + * after the PIIX4 PM section. + */ + outb_p(SIO_DEV_SEL, SIO_INDEX); + outb_p(SIO_GP_DEV, SIO_DATA); /* Talk to GPIO regs. */ + + outb_p(SIO_DEV_MSB, SIO_INDEX); + outb_p(SIO_GP_MSB, SIO_DATA); /* MSB of GPIO base address */ + + outb_p(SIO_DEV_LSB, SIO_INDEX); + outb_p(SIO_GP_LSB, SIO_DATA); /* LSB of GPIO base address */ + + outb_p(SIO_DEV_ENB, SIO_INDEX); + outb_p(1, SIO_DATA); /* Enable GPIO registers. */ + +/* + * Now, we have to map the power management section to write + * a bit which enables access to the GPIO registers. + * What lunatic came up with this shit? + */ + outb_p(SIO_DEV_SEL, SIO_INDEX); + outb_p(SIO_PM_DEV, SIO_DATA); /* Talk to GPIO regs. */ + + outb_p(SIO_DEV_MSB, SIO_INDEX); + outb_p(SIO_PM_MSB, SIO_DATA); /* MSB of PM base address */ + + outb_p(SIO_DEV_LSB, SIO_INDEX); + outb_p(SIO_PM_LSB, SIO_DATA); /* LSB of PM base address */ + + outb_p(SIO_DEV_ENB, SIO_INDEX); + outb_p(1, SIO_DATA); /* Enable PM registers. */ + +/* + * Now, write the PM register which enables the GPIO registers. + */ + outb_p(SIO_PM_FER2, SIO_PM_INDEX); + outb_p(SIO_PM_GP_EN, SIO_PM_DATA); + +/* + * Now, initialize the GPIO registers. + * We want them all to be inputs which is the + * power on default, so let's leave them alone. + * So, let's just read the board rev! + */ + raw = inb_p(SIO_GP_DATA1); + raw &= 0x7f; /* 7 bits of valid board revision ID. */ + + if (visws_board_type == VISWS_320) { + if (raw < 0x6) { + visws_board_rev = 4; + } else if (raw < 0xc) { + visws_board_rev = 5; + } else { + visws_board_rev = 6; + } + } else if (visws_board_type == VISWS_540) { + visws_board_rev = 2; + } else { + visws_board_rev = raw; + } + + printk(KERN_INFO "Silicon Graphics %s (rev %d)\n", + visws_board_type == VISWS_320 ? "320" : + (visws_board_type == VISWS_540 ? "540" : + "unknown"), visws_board_rev); + } +} diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/i386/kernel/setup.c linux-2.5/arch/i386/kernel/setup.c --- linux-2.5.1/arch/i386/kernel/setup.c Tue Nov 27 17:23:27 2001 +++ linux-2.5/arch/i386/kernel/setup.c Sun Dec 30 13:35:25 2001 @@ -125,9 +125,8 @@ /* * Bus types .. */ -#ifdef CONFIG_EISA + int EISA_bus; -#endif int MCA_bus; /* for MCA, but anyone else can use it if they want */ @@ -158,6 +157,7 @@ extern int root_mountflags; extern char _text, _etext, _edata, _end; extern int blk_nohighio; +void __init visws_get_board_type_and_rev(void); static int disable_x86_serial_nr __initdata = 1; static int disable_x86_fxsr __initdata = 0; @@ -191,131 +191,6 @@ #define RAMDISK_PROMPT_FLAG 0x8000 #define RAMDISK_LOAD_FLAG 0x4000 -#ifdef CONFIG_VISWS -char visws_board_type = -1; -char visws_board_rev = -1; - -#define PIIX_PM_START 0x0F80 - -#define SIO_GPIO_START 0x0FC0 - -#define SIO_PM_START 0x0FC8 - -#define PMBASE PIIX_PM_START -#define GPIREG0 (PMBASE+0x30) -#define GPIREG(x) (GPIREG0+((x)/8)) -#define PIIX_GPI_BD_ID1 18 -#define PIIX_GPI_BD_REG GPIREG(PIIX_GPI_BD_ID1) - -#define PIIX_GPI_BD_SHIFT (PIIX_GPI_BD_ID1 % 8) - -#define SIO_INDEX 0x2e -#define SIO_DATA 0x2f - -#define SIO_DEV_SEL 0x7 -#define SIO_DEV_ENB 0x30 -#define SIO_DEV_MSB 0x60 -#define SIO_DEV_LSB 0x61 - -#define SIO_GP_DEV 0x7 - -#define SIO_GP_BASE SIO_GPIO_START -#define SIO_GP_MSB (SIO_GP_BASE>>8) -#define SIO_GP_LSB (SIO_GP_BASE&0xff) - -#define SIO_GP_DATA1 (SIO_GP_BASE+0) - -#define SIO_PM_DEV 0x8 - -#define SIO_PM_BASE SIO_PM_START -#define SIO_PM_MSB (SIO_PM_BASE>>8) -#define SIO_PM_LSB (SIO_PM_BASE&0xff) -#define SIO_PM_INDEX (SIO_PM_BASE+0) -#define SIO_PM_DATA (SIO_PM_BASE+1) - -#define SIO_PM_FER2 0x1 - -#define SIO_PM_GP_EN 0x80 - -static void __init visws_get_board_type_and_rev(void) -{ - int raw; - - visws_board_type = (char)(inb_p(PIIX_GPI_BD_REG) & PIIX_GPI_BD_REG) - >> PIIX_GPI_BD_SHIFT; -/* - * Get Board rev. - * First, we have to initialize the 307 part to allow us access - * to the GPIO registers. Let's map them at 0x0fc0 which is right - * after the PIIX4 PM section. - */ - outb_p(SIO_DEV_SEL, SIO_INDEX); - outb_p(SIO_GP_DEV, SIO_DATA); /* Talk to GPIO regs. */ - - outb_p(SIO_DEV_MSB, SIO_INDEX); - outb_p(SIO_GP_MSB, SIO_DATA); /* MSB of GPIO base address */ - - outb_p(SIO_DEV_LSB, SIO_INDEX); - outb_p(SIO_GP_LSB, SIO_DATA); /* LSB of GPIO base address */ - - outb_p(SIO_DEV_ENB, SIO_INDEX); - outb_p(1, SIO_DATA); /* Enable GPIO registers. */ - -/* - * Now, we have to map the power management section to write - * a bit which enables access to the GPIO registers. - * What lunatic came up with this shit? - */ - outb_p(SIO_DEV_SEL, SIO_INDEX); - outb_p(SIO_PM_DEV, SIO_DATA); /* Talk to GPIO regs. */ - - outb_p(SIO_DEV_MSB, SIO_INDEX); - outb_p(SIO_PM_MSB, SIO_DATA); /* MSB of PM base address */ - - outb_p(SIO_DEV_LSB, SIO_INDEX); - outb_p(SIO_PM_LSB, SIO_DATA); /* LSB of PM base address */ - - outb_p(SIO_DEV_ENB, SIO_INDEX); - outb_p(1, SIO_DATA); /* Enable PM registers. */ - -/* - * Now, write the PM register which enables the GPIO registers. - */ - outb_p(SIO_PM_FER2, SIO_PM_INDEX); - outb_p(SIO_PM_GP_EN, SIO_PM_DATA); - -/* - * Now, initialize the GPIO registers. - * We want them all to be inputs which is the - * power on default, so let's leave them alone. - * So, let's just read the board rev! - */ - raw = inb_p(SIO_GP_DATA1); - raw &= 0x7f; /* 7 bits of valid board revision ID. */ - - if (visws_board_type == VISWS_320) { - if (raw < 0x6) { - visws_board_rev = 4; - } else if (raw < 0xc) { - visws_board_rev = 5; - } else { - visws_board_rev = 6; - - } - } else if (visws_board_type == VISWS_540) { - visws_board_rev = 2; - } else { - visws_board_rev = raw; - } - - printk(KERN_INFO "Silicon Graphics %s (rev %d)\n", - visws_board_type == VISWS_320 ? "320" : - (visws_board_type == VISWS_540 ? "540" : - "unknown"), - visws_board_rev); - } -#endif - static char command_line[COMMAND_LINE_SIZE]; char saved_command_line[COMMAND_LINE_SIZE]; @@ -828,10 +703,8 @@ #define PFN_PHYS(x) ((x) << PAGE_SHIFT) /* - * 128MB for vmalloc and initrd + * Reserved space for vmalloc and iomap - defined in asm/page.h */ -#define VMALLOC_RESERVE (unsigned long)(128 << 20) -#define MAXMEM (unsigned long)(-PAGE_OFFSET-VMALLOC_RESERVE) #define MAXMEM_PFN PFN_DOWN(MAXMEM) #define MAX_NONPAE_PFN (1 << 20) @@ -1289,9 +1162,24 @@ } break; - case 6: /* An Athlon/Duron. We can trust the BIOS probably */ - mcheck_init(c); - break; + case 6: /* An Athlon/Duron */ + + /* Bit 15 of Athlon specific MSR 15, needs to be 0 + * to enable SSE on Palomino/Morgan CPU's. + * If the BIOS didn't enable it already, enable it + * here. + */ + if (c->x86_model == 6 || c->x86_model == 7) { + if (!test_bit(X86_FEATURE_XMM, &c->x86_capability)) { + printk(KERN_INFO "Enabling disabled K7/SSE Support.\n"); + rdmsr(MSR_K7_HWCR, l, h); + l &= ~0x00008000; + wrmsr(MSR_K7_HWCR, l, h); + set_bit(X86_FEATURE_XMM, &c->x86_capability); + } + } + break; + } display_cacheinfo(c); @@ -1361,40 +1249,6 @@ static char cyrix_model_mult1[] __initdata = "12??43"; static char cyrix_model_mult2[] __initdata = "12233445"; -/* - * Reset the slow-loop (SLOP) bit on the 686(L) which is set by some old - * BIOSes for compatability with DOS games. This makes the udelay loop - * work correctly, and improves performance. - * - * FIXME: our newer udelay uses the tsc. We dont need to frob with SLOP - */ - -extern void calibrate_delay(void) __init; - -static void __init check_cx686_slop(struct cpuinfo_x86 *c) -{ - unsigned long flags; - - if (Cx86_dir0_msb == 3) { - unsigned char ccr3, ccr5; - - local_irq_save(flags); - ccr3 = getCx86(CX86_CCR3); - setCx86(CX86_CCR3, (ccr3 & 0x0f) | 0x10); /* enable MAPEN */ - ccr5 = getCx86(CX86_CCR5); - if (ccr5 & 2) - setCx86(CX86_CCR5, ccr5 & 0xfd); /* reset SLOP */ - setCx86(CX86_CCR3, ccr3); /* disable MAPEN */ - local_irq_restore(flags); - - if (ccr5 & 2) { /* possible wrong calibration done */ - printk(KERN_INFO "Recalibrating delay loop with SLOP bit reset\n"); - calibrate_delay(); - c->loops_per_jiffy = loops_per_jiffy; - } - } -} - static void __init init_cyrix(struct cpuinfo_x86 *c) { unsigned char dir0, dir0_msn, dir0_lsn, dir1 = 0; @@ -1413,8 +1267,6 @@ do_cyrix_devid(&dir0, &dir1); - check_cx686_slop(c); - Cx86_dir0_msb = dir0_msn = dir0 >> 4; /* identifies CPU "family" */ dir0_lsn = dir0 & 0xf; /* model or clock multiplier */ @@ -1471,7 +1323,7 @@ same. The MediaGX has deep magic SMM stuff that handles the SB emulation. It thows away the fifo on disable_dma() which is wrong and ruins the audio. - + Bug2: VSA1 has a wrap bug so that using maximum sized DMA causes bad things. According to NatSemi VSA2 has another bug to do with 'hlt'. I've not seen any boards using VSA2 @@ -1512,7 +1364,7 @@ tmp = (!(dir0_lsn & 7) || dir0_lsn & 1) ? 2 : 0; Cx86_cb[tmp] = cyrix_model_mult2[dir0_lsn & 7]; p = Cx86_cb+tmp; - if (((dir1 & 0x0f) > 4) || ((dir1 & 0xf0) == 0x20)) + if (((dir1 & 0x0f) > 4) || ((dir1 & 0xf0) == 0x20)) (c->x86_model)++; /* Emulate MTRRs using Cyrix's ARRs. */ set_bit(X86_FEATURE_CYRIX_ARR, &c->x86_capability); @@ -1918,7 +1770,6 @@ c->x86_cache_size = (cc>>24)+(dd>>24); } sprintf( c->x86_model_id, "WinChip %s", name ); - mcheck_init(c); break; case 6: @@ -2157,7 +2008,7 @@ } if ( l1i || l1d ) printk(KERN_INFO "CPU: L1 I cache: %dK, L1 D cache: %dK\n", - l1i, l1d); + l1i, l1d); if ( l2 ) printk(KERN_INFO "CPU: L2 cache: %dK\n", l2); if ( l3 ) @@ -2202,9 +2053,56 @@ if ( p ) strcpy(c->x86_model_id, p); + +#ifdef CONFIG_SMP + if (test_bit(X86_FEATURE_HT, &c->x86_capability)) { + extern int phys_proc_id[NR_CPUS]; + + u32 eax, ebx, ecx, edx; + int index_lsb, index_msb, tmp; + int initial_apic_id; + int cpu = smp_processor_id(); + + cpuid(1, &eax, &ebx, &ecx, &edx); + smp_num_siblings = (ebx & 0xff0000) >> 16; + + if (smp_num_siblings == 1) { + printk(KERN_INFO "CPU: Hyper-Threading is disabled\n"); + } else if (smp_num_siblings > 1 ) { + index_lsb = 0; + index_msb = 31; + /* + * At this point we only support two siblings per + * processor package. + */ +#define NR_SIBLINGS 2 + if (smp_num_siblings != NR_SIBLINGS) { + printk(KERN_WARNING "CPU: Unsupported number of the siblings %d", smp_num_siblings); + smp_num_siblings = 1; + goto too_many_siblings; + } + tmp = smp_num_siblings; + while ((tmp & 1) == 0) { + tmp >>=1 ; + index_lsb++; + } + tmp = smp_num_siblings; + while ((tmp & 0x80000000 ) == 0) { + tmp <<=1 ; + index_msb--; + } + if (index_lsb != index_msb ) + index_msb++; + initial_apic_id = ebx >> 24 & 0xff; + phys_proc_id[cpu] = initial_apic_id >> index_msb; - /* Enable MCA if available */ - mcheck_init(c); + printk(KERN_INFO "CPU: Physical Processor ID: %d\n", + phys_proc_id[cpu]); + } + + } +too_many_siblings: +#endif } void __init get_cpu_vendor(struct cpuinfo_x86 *c) @@ -2584,7 +2482,7 @@ init_rise(c); break; } - + printk(KERN_DEBUG "CPU: After vendor init, caps: %08x %08x %08x %08x\n", c->x86_capability[0], c->x86_capability[1], @@ -2611,6 +2509,9 @@ /* Disable the PN if appropriate */ squash_the_stupid_serial_number(c); + /* Init Machine Check Exception if available. */ + mcheck_init(c); + /* If the model name is still unset, do table lookup. */ if ( !c->x86_model_id[0] ) { char *p; @@ -2708,7 +2609,7 @@ "fpu", "vme", "de", "pse", "tsc", "msr", "pae", "mce", "cx8", "apic", NULL, "sep", "mtrr", "pge", "mca", "cmov", "pat", "pse36", "pn", "clflush", NULL, "dts", "acpi", "mmx", - "fxsr", "sse", "sse2", "ss", NULL, "tm", "ia64", NULL, + "fxsr", "sse", "sse2", "ss", "ht", "tm", "ia64", NULL, /* AMD-defined */ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, @@ -2862,7 +2763,7 @@ set_tss_desc(nr,t); gdt_table[__TSS(nr)].b &= 0xfffffdff; load_TR(nr); - load_LDT(&init_mm); + load_LDT(&init_mm.context); /* * Clear all 6 debug registers: diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/i386/kernel/signal.c linux-2.5/arch/i386/kernel/signal.c --- linux-2.5.1/arch/i386/kernel/signal.c Fri Sep 14 21:15:40 2001 +++ linux-2.5/arch/i386/kernel/signal.c Thu Dec 20 19:14:29 2001 @@ -28,7 +28,7 @@ #define _BLOCKABLE (~(sigmask(SIGKILL) | sigmask(SIGSTOP))) -asmlinkage int FASTCALL(do_signal(struct pt_regs *regs, sigset_t *oldset)); +int FASTCALL(do_signal(struct pt_regs *regs, sigset_t *oldset)); int copy_siginfo_to_user(siginfo_t *to, siginfo_t *from) { diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/i386/kernel/smp.c linux-2.5/arch/i386/kernel/smp.c --- linux-2.5.1/arch/i386/kernel/smp.c Tue Oct 23 21:17:10 2001 +++ linux-2.5/arch/i386/kernel/smp.c Thu Dec 13 16:32:35 2001 @@ -17,6 +17,7 @@ #include <linux/smp_lock.h> #include <linux/kernel_stat.h> #include <linux/mc146818rtc.h> +#include <linux/cache.h> #include <asm/mtrr.h> #include <asm/pgalloc.h> @@ -102,7 +103,7 @@ */ /* The 'big kernel lock' */ -spinlock_t kernel_flag = SPIN_LOCK_UNLOCKED; +spinlock_t kernel_flag __cacheline_aligned_in_smp = SPIN_LOCK_UNLOCKED; struct tlb_state cpu_tlbstate[NR_CPUS] = {[0 ... NR_CPUS-1] = { &init_mm, 0 }}; diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/i386/kernel/smpboot.c linux-2.5/arch/i386/kernel/smpboot.c --- linux-2.5.1/arch/i386/kernel/smpboot.c Wed Nov 21 18:35:48 2001 +++ linux-2.5/arch/i386/kernel/smpboot.c Thu Dec 13 16:32:35 2001 @@ -56,6 +56,10 @@ /* Total count of live CPUs */ int smp_num_cpus = 1; +/* Number of siblings per CPU package */ +int smp_num_siblings = 1; +int __initdata phys_proc_id[NR_CPUS]; /* Package ID of each logical CPU */ + /* Bitmask of currently online CPUs */ unsigned long cpu_online_map; @@ -971,6 +975,8 @@ /* Where the IO area was mapped on multiquad, always 0 otherwise */ void *xquad_portio = NULL; +int cpu_sibling_map[NR_CPUS] __cacheline_aligned; + void __init smp_boot_cpus(void) { int apicid, cpu, bit; @@ -1162,6 +1168,34 @@ printk(KERN_WARNING "WARNING: SMP operation may be unreliable with B stepping processors.\n"); Dprintk("Boot done.\n"); + /* + * If Hyper-Threading is avaialble, construct cpu_sibling_map[], so + * that we can tell the sibling CPU efficiently. + */ + if (test_bit(X86_FEATURE_HT, boot_cpu_data.x86_capability) + && smp_num_siblings > 1) { + for (cpu = 0; cpu < NR_CPUS; cpu++) + cpu_sibling_map[cpu] = NO_PROC_ID; + + for (cpu = 0; cpu < smp_num_cpus; cpu++) { + int i; + + for (i = 0; i < smp_num_cpus; i++) { + if (i == cpu) + continue; + if (phys_proc_id[cpu] == phys_proc_id[i]) { + cpu_sibling_map[cpu] = i; + printk("cpu_sibling_map[%d] = %d\n", cpu, cpu_sibling_map[cpu]); + break; + } + } + if (cpu_sibling_map[cpu] == NO_PROC_ID) { + smp_num_siblings = 1; + printk(KERN_WARNING "WARNING: No sibling found for CPU %d.\n", cpu); + } + } + } + #ifndef CONFIG_VISWS /* * Here we can be sure that there is an IO-APIC in the system. Let's diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/i386/kernel/traps.c linux-2.5/arch/i386/kernel/traps.c --- linux-2.5.1/arch/i386/kernel/traps.c Sun Nov 25 17:48:47 2001 +++ linux-2.5/arch/i386/kernel/traps.c Sat Dec 29 12:07:19 2001 @@ -271,6 +271,22 @@ { if (vm86 && regs->eflags & VM_MASK) goto vm86_trap; + +#ifdef CONFIG_PNPBIOS + if (regs->xcs == 0x60 || regs->xcs == 0x68) + { + extern u32 pnp_bios_fault_eip, pnp_bios_fault_esp; + extern u32 pnp_bios_is_utter_crap; + pnp_bios_is_utter_crap = 1; + printk(KERN_CRIT "PNPBIOS fault.. attempting recovery.\n"); + __asm__ volatile( + "movl %0, %%esp\n\t" + "jmp %1\n\t" + : "=a" (pnp_bios_fault_esp), "=b" (pnp_bios_fault_eip)); + panic("do_trap: can't hit this"); + } +#endif + if (!(regs->xcs & 3)) goto kernel_trap; diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/i386/kernel/vm86.c linux-2.5/arch/i386/kernel/vm86.c --- linux-2.5.1/arch/i386/kernel/vm86.c Sat Jul 7 00:05:07 2001 +++ linux-2.5/arch/i386/kernel/vm86.c Thu Dec 20 19:14:29 2001 @@ -62,7 +62,7 @@ ( (unsigned)( & (((struct kernel_vm86_regs *)0)->VM86_REGS_PART2) ) ) #define VM86_REGS_SIZE2 (sizeof(struct kernel_vm86_regs) - VM86_REGS_SIZE1) -asmlinkage struct pt_regs * FASTCALL(save_v86_state(struct kernel_vm86_regs * regs)); +struct pt_regs * FASTCALL(save_v86_state(struct kernel_vm86_regs * regs)); struct pt_regs * save_v86_state(struct kernel_vm86_regs * regs) { struct tss_struct *tss; diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/i386/math-emu/fpu_system.h linux-2.5/arch/i386/math-emu/fpu_system.h --- linux-2.5.1/arch/i386/math-emu/fpu_system.h Fri Dec 29 22:07:20 2000 +++ linux-2.5/arch/i386/math-emu/fpu_system.h Sat Dec 29 02:13:06 2001 @@ -20,7 +20,9 @@ of the stack frame of math_emulate() */ #define SETUP_DATA_AREA(arg) FPU_info = (struct info *) &arg -#define LDT_DESCRIPTOR(s) (((struct desc_struct *)current->mm->context.segments)[(s) >> 3]) +/* s is always from a cpu register, and the cpu does bounds checking + * during register load --> no further bounds checks needed */ +#define LDT_DESCRIPTOR(s) (((struct desc_struct *)current->mm->context.ldt)[(s) >> 3]) #define SEG_D_SIZE(x) ((x).b & (3 << 21)) #define SEG_G_BIT(x) ((x).b & (1 << 23)) #define SEG_GRANULARITY(x) (((x).b & (1 << 23)) ? 4096 : 1) diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/i386/mm/fault.c linux-2.5/arch/i386/mm/fault.c --- linux-2.5.1/arch/i386/mm/fault.c Tue Oct 9 22:13:03 2001 +++ linux-2.5/arch/i386/mm/fault.c Thu Dec 27 16:32:30 2001 @@ -27,8 +27,6 @@ extern void die(const char *,struct pt_regs *,long); -extern int console_loglevel; - /* * Ugly, ugly, but the goto's result in better assembly.. */ diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/i386/vmlinux.lds linux-2.5/arch/i386/vmlinux.lds --- linux-2.5.1/arch/i386/vmlinux.lds Mon Jul 2 21:40:14 2001 +++ linux-2.5/arch/i386/vmlinux.lds Sat Dec 29 11:10:40 2001 @@ -13,7 +13,6 @@ *(.fixup) *(.gnu.warning) } = 0x9090 - .text.lock : { *(.text.lock) } /* out-of-line lock text */ _etext = .; /* End of text section */ diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/ia64/hp/hpsim_console.c linux-2.5/arch/ia64/hp/hpsim_console.c --- linux-2.5.1/arch/ia64/hp/hpsim_console.c Thu Oct 12 21:20:48 2000 +++ linux-2.5/arch/ia64/hp/hpsim_console.c Thu Dec 27 15:56:12 2001 @@ -24,14 +24,12 @@ static int simcons_init (struct console *, char *); static void simcons_write (struct console *, const char *, unsigned); -static int simcons_wait_key (struct console *); static kdev_t simcons_console_device (struct console *); struct console hpsim_cons = { name: "simcons", write: simcons_write, device: simcons_console_device, - wait_key: simcons_wait_key, setup: simcons_init, flags: CON_PRINTBUFFER, index: -1, @@ -54,17 +52,6 @@ if (ch == '\n') ia64_ssc('\r', 0, 0, 0, SSC_PUTCHAR); } -} - -static int -simcons_wait_key (struct console *cons) -{ - char ch; - - do { - ch = ia64_ssc(0, 0, 0, 0, SSC_GETCHAR); - } while (ch == '\0'); - return ch; } static kdev_t diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/ia64/kernel/process.c linux-2.5/arch/ia64/kernel/process.c --- linux-2.5.1/arch/ia64/kernel/process.c Fri Nov 9 22:26:17 2001 +++ linux-2.5/arch/ia64/kernel/process.c Thu Dec 27 22:10:28 2001 @@ -114,8 +114,6 @@ /* endless idle loop with no priority at all */ init_idle(); current->nice = 20; - current->counter = -100; - while (1) { #ifdef CONFIG_SMP diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/ia64/kernel/smp.c linux-2.5/arch/ia64/kernel/smp.c --- linux-2.5.1/arch/ia64/kernel/smp.c Fri Nov 9 22:26:17 2001 +++ linux-2.5/arch/ia64/kernel/smp.c Thu Dec 13 16:32:35 2001 @@ -30,6 +30,7 @@ #include <linux/kernel_stat.h> #include <linux/mm.h> #include <linux/delay.h> +#include <linux/cache.h> #include <asm/atomic.h> #include <asm/bitops.h> @@ -51,7 +52,7 @@ #include <asm/mca.h> /* The 'big kernel lock' */ -spinlock_t kernel_flag = SPIN_LOCK_UNLOCKED; +spinlock_t kernel_flag __cacheline_aligned_in_smp = SPIN_LOCK_UNLOCKED; /* * Structure and data for smp_call_function(). This is designed to minimise static memory diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/ia64/sn/fprom/Makefile linux-2.5/arch/ia64/sn/fprom/Makefile --- linux-2.5.1/arch/ia64/sn/fprom/Makefile Thu Apr 5 19:51:47 2001 +++ linux-2.5/arch/ia64/sn/fprom/Makefile Sat Dec 29 11:10:40 2001 @@ -18,10 +18,12 @@ fprom: $(OBJ) $(LD) -static -Tfprom.lds -o fprom $(OBJ) $(LIB) +comma := , + .S.o: $(CC) -D__ASSEMBLY__ $(AFLAGS) $(AFLAGS_KERNEL) -c -o $*.o $< .c.o: - $(CC) $(CFLAGS) $(CFLAGS_KERNEL) -c -o $*.o $< + $(CC) $(CFLAGS) -DKBUILD_BASENAME=$(subst $(comma),_,$(subst -,_,$(*F))) $(CFLAGS_KERNEL) -c -o $*.o $< clean: rm -f *.o fprom diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/ia64/sn/io/hcl.c linux-2.5/arch/ia64/sn/io/hcl.c --- linux-2.5.1/arch/ia64/sn/io/hcl.c Thu Apr 5 19:51:47 2001 +++ linux-2.5/arch/ia64/sn/io/hcl.c Mon Dec 17 17:16:14 2001 @@ -1049,16 +1049,22 @@ struct file_operations * hwgraph_cdevsw_get(devfs_handle_t de) { - return(devfs_get_ops(de)); + struct file_operations *fops = devfs_get_ops(de); + + devfs_put_ops(de); /* FIXME: this may need to be moved to callers */ + return(fops); } /* * hwgraph_bdevsw_get - returns the fops of the given devfs entry. */ -struct file_operations * +struct file_operations * /* FIXME: shouldn't this be a blkdev? */ hwgraph_bdevsw_get(devfs_handle_t de) { - return(devfs_get_ops(de)); + struct file_operations *fops = devfs_get_ops(de); + + devfs_put_ops(de); /* FIXME: this may need to be moved to callers */ + return(fops); } /* diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/ia64/tools/Makefile linux-2.5/arch/ia64/tools/Makefile --- linux-2.5.1/arch/ia64/tools/Makefile Tue Oct 10 00:54:57 2000 +++ linux-2.5/arch/ia64/tools/Makefile Sat Dec 29 11:10:40 2001 @@ -31,8 +31,10 @@ offsets.h: print_offsets ./print_offsets > offsets.h +comma := , + print_offsets: print_offsets.c FORCE_RECOMPILE - $(CC) $(CFLAGS) print_offsets.c -o $@ + $(CC) $(CFLAGS) -DKBUILD_BASENAME=$(subst $(comma),_,$(subst -,_,$(*F))) print_offsets.c -o $@ FORCE_RECOMPILE: @@ -42,7 +44,7 @@ $(AWK) -f print_offsets.awk $^ > $@ print_offsets.s: print_offsets.c - $(CC) $(CFLAGS) -S print_offsets.c -o $@ + $(CC) $(CFLAGS) -DKBUILD_BASENAME=$(subst $(comma),_,$(subst -,_,$(*F))) -S print_offsets.c -o $@ endif diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/m68k/amiga/config.c linux-2.5/arch/m68k/amiga/config.c --- linux-2.5.1/arch/m68k/amiga/config.c Wed Nov 28 21:22:25 2001 +++ linux-2.5/arch/m68k/amiga/config.c Thu Dec 27 15:56:12 2001 @@ -98,7 +98,6 @@ extern void amiga_floppy_setup(char *, int *); #endif static void amiga_reset (void); -static int amiga_wait_key (struct console *co); extern void amiga_init_sound(void); static void amiga_savekmsg_init(void); static void amiga_mem_console_write(struct console *co, const char *b, @@ -112,7 +111,6 @@ static struct console amiga_console_driver = { name: "debug", - wait_key: amiga_wait_key, flags: CON_PRINTBUFFER, index: -1, }; @@ -740,33 +738,6 @@ } return 0; -} - -static int amiga_wait_key (struct console *co) -{ - int i; - - while (1) { - while (ciaa.pra & 0x40); - - /* debounce */ - for (i = 0; i < 1000; i++); - - if (!(ciaa.pra & 0x40)) - break; - } - - /* wait for button up */ - while (1) { - while (!(ciaa.pra & 0x40)); - - /* debounce */ - for (i = 0; i < 1000; i++); - - if (ciaa.pra & 0x40) - break; - } - return 0; } static NORET_TYPE void amiga_reset( void ) diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/m68k/kernel/process.c linux-2.5/arch/m68k/kernel/process.c --- linux-2.5.1/arch/m68k/kernel/process.c Sun Sep 30 19:26:08 2001 +++ linux-2.5/arch/m68k/kernel/process.c Thu Dec 27 22:10:28 2001 @@ -81,7 +81,6 @@ /* endless idle loop with no priority at all */ init_idle(); current->nice = 20; - current->counter = -100; idle(); } diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/m68k/mac/debug.c linux-2.5/arch/m68k/mac/debug.c --- linux-2.5.1/arch/m68k/mac/debug.c Tue Jun 12 02:15:27 2001 +++ linux-2.5/arch/m68k/mac/debug.c Thu Dec 27 15:56:12 2001 @@ -248,17 +248,6 @@ return( scc.cha_b_data ); } -int mac_scca_console_wait_key(struct console *co) -{ - int i; - do { - for( i = uSEC; i > 0; --i ) - barrier(); - } while( !(scc.cha_a_ctrl & 0x01) ); /* wait for rx buf filled */ - for( i = uSEC; i > 0; --i ) - barrier(); - return( scc.cha_a_data ); -} #endif /* The following two functions do a quick'n'dirty initialization of the MFP or @@ -395,9 +384,6 @@ /* Mac modem port */ mac_init_scc_port( B9600|CS8, 0 ); mac_console_driver.write = mac_scca_console_write; -#ifdef CONFIG_SERIAL_CONSOLE - mac_console_driver.wait_key = mac_scca_console_wait_key; -#endif scc_port = 0; } else if (!strcmp( m68k_debug_device, "ser2" )) { diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/m68k/mvme147/config.c linux-2.5/arch/m68k/mvme147/config.c --- linux-2.5.1/arch/m68k/mvme147/config.c Wed Nov 28 21:22:25 2001 +++ linux-2.5/arch/m68k/mvme147/config.c Thu Dec 27 15:56:12 2001 @@ -241,31 +241,7 @@ restore_flags(flags); } - -static int m147_scc_wait_key (struct console *co) -{ - volatile unsigned char *p = (volatile char *)M147_SCC_A_ADDR; - unsigned long flags; - int c; - - /* wait for rx buf filled */ - while ((*p & 0x01) == 0) - ; - - save_flags(flags); - cli(); - - *p = 8; - scc_delay(); - c = *p; - - restore_flags(flags); - return c; -} - - void mvme147_init_console_port (struct console *co, int cflag) { co->write = m147_scc_write; - co->wait_key = m147_scc_wait_key; } diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/m68k/q40/config.c linux-2.5/arch/m68k/q40/config.c --- linux-2.5.1/arch/m68k/q40/config.c Sun Dec 16 20:23:05 2001 +++ linux-2.5/arch/m68k/q40/config.c Thu Dec 27 15:56:12 2001 @@ -72,10 +72,8 @@ extern int ql_ticks; -static int q40_wait_key(struct console *co){return 0;} static struct console q40_console_driver = { name: "debug", - wait_key: q40_wait_key, flags: CON_PRINTBUFFER, index: -1, }; diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/m68k/sun3x/prom.c linux-2.5/arch/m68k/sun3x/prom.c --- linux-2.5.1/arch/m68k/sun3x/prom.c Tue Jun 12 02:15:27 2001 +++ linux-2.5/arch/m68k/sun3x/prom.c Thu Dec 27 15:56:12 2001 @@ -96,7 +96,6 @@ sun3x_prom_write, /* write */ NULL, /* read */ NULL, /* device */ - NULL, /* wait_key */ NULL, /* unblank */ NULL, /* setup */ CON_PRINTBUFFER, diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/m68k/vmlinux-sun3.lds linux-2.5/arch/m68k/vmlinux-sun3.lds --- linux-2.5.1/arch/m68k/vmlinux-sun3.lds Mon Jul 2 21:40:14 2001 +++ linux-2.5/arch/m68k/vmlinux-sun3.lds Sat Dec 29 11:10:40 2001 @@ -10,7 +10,6 @@ *(.head) *(.text) *(.fixup) - *(.text.lock) /* out-of-line lock text */ *(.gnu.warning) } = 0x4e75 .kstrtab : { *(.kstrtab) } diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/m68k/vmlinux.lds linux-2.5/arch/m68k/vmlinux.lds --- linux-2.5.1/arch/m68k/vmlinux.lds Mon Jul 2 21:40:14 2001 +++ linux-2.5/arch/m68k/vmlinux.lds Sat Dec 29 11:10:40 2001 @@ -9,7 +9,6 @@ .text : { *(.text) *(.fixup) - *(.text.lock) /* out-of-line lock text */ *(.gnu.warning) } = 0x4e75 .rodata : { *(.rodata) *(.rodata.*) } diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/mips/au1000/common/serial.c linux-2.5/arch/mips/au1000/common/serial.c --- linux-2.5.1/arch/mips/au1000/common/serial.c Fri Oct 5 19:06:51 2001 +++ linux-2.5/arch/mips/au1000/common/serial.c Sun Dec 30 13:55:22 2001 @@ -2606,7 +2606,9 @@ serial_driver.table = serial_table; serial_driver.termios = serial_termios; serial_driver.termios_locked = serial_termios_locked; - +#ifdef CONFIG_AU1000_SERIAL_CONSOLE + serial_driver.console = &sercons; +#endif serial_driver.open = rs_open; serial_driver.close = rs_close; serial_driver.write = rs_write; @@ -2922,35 +2924,6 @@ serial_out(info, UART_IER, ier); } -/* - * Receive character from the serial port - */ -static int serial_console_wait_key(struct console *co) -{ - static struct async_struct *info; - int ier, c; - - info = &async_sercons; - - /* - * First save the IER then disable the interrupts so - * that the real driver for the port does not get the - * character. - */ - ier = serial_in(info, UART_IER); - serial_out(info, UART_IER, 0x00); - - while ((serial_in(info, UART_LSR) & UART_LSR_DR) == 0); - c = serial_in(info, UART_RX); - - /* - * Restore the interrupts - */ - serial_out(info, UART_IER, ier); - - return c; -} - static kdev_t serial_console_device(struct console *c) { return MKDEV(TTY_MAJOR, 64 + c->index); @@ -3075,7 +3048,6 @@ name: "ttyS", write: serial_console_write, device: serial_console_device, - wait_key: serial_console_wait_key, setup: serial_console_setup, flags: CON_PRINTBUFFER, index: -1, diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/mips/baget/vacserial.c linux-2.5/arch/mips/baget/vacserial.c --- linux-2.5.1/arch/mips/baget/vacserial.c Sun Sep 9 17:43:01 2001 +++ linux-2.5/arch/mips/baget/vacserial.c Sun Dec 30 13:55:22 2001 @@ -2373,7 +2373,9 @@ serial_driver.table = serial_table; serial_driver.termios = serial_termios; serial_driver.termios_locked = serial_termios_locked; - +#ifdef CONFIG_SERIAL_CONSOLE + serial_driver.console = &sercons; +#endif serial_driver.open = rs_open; serial_driver.close = rs_close; serial_driver.write = rs_write; @@ -2622,43 +2624,6 @@ serial_outp(&scr_info, VAC_UART_INT_MASK, ier); } -/* - * Receive character from the serial port - */ -static int serial_console_wait_key(struct console *co) -{ - struct serial_state *ser; - int ier; - int lsr; - int c; - struct async_struct scr_info; /* serial_{in,out} because HUB6 */ - - ser = rs_table + co->index; - scr_info.magic = SERIAL_MAGIC; - scr_info.port = ser->port; - scr_info.flags = ser->flags; - - /* - * First save the IER then disable the interrupts so - * that the real driver for the port does not get the - * character. - */ - ier = serial_inp(&scr_info, VAC_UART_INT_MASK); - serial_outp(&scr_info, VAC_UART_INT_MASK, 0x00); - - do { - lsr = serial_inp(&scr_info, VAC_UART_INT_STATUS); - } while (!(lsr & VAC_UART_STATUS_RX_READY)); - c = serial_inp(&scr_info, VAC_UART_RX); - - /* - * Restore the interrupts - */ - serial_outp(&scr_info, VAC_UART_INT_MASK, ier); - - return c; -} - static kdev_t serial_console_device(struct console *c) { return MKDEV(TTY_MAJOR, 64 + c->index); @@ -2812,7 +2777,6 @@ name: "ttyS", write: serial_console_write, device: serial_console_device, - wait_key: serial_console_wait_key, setup: serial_console_setup, flags: CON_PRINTBUFFER, index: -1, diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/mips/dec/promcon.c linux-2.5/arch/mips/dec/promcon.c --- linux-2.5.1/arch/mips/dec/promcon.c Thu Oct 12 21:20:48 2000 +++ linux-2.5/arch/mips/dec/promcon.c Thu Dec 27 15:56:12 2001 @@ -30,11 +30,6 @@ } } -static int prom_console_wait_key(struct console *co) -{ - return prom_getchar(); -} - static int __init prom_console_setup(struct console *co, char *options) { return 0; @@ -50,7 +45,6 @@ name: "ttyS", write: prom_console_write, device: prom_console_device, - wait_key: prom_console_wait_key, setup: prom_console_setup, flags: CON_PRINTBUFFER, index: -1, diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/mips/kernel/process.c linux-2.5/arch/mips/kernel/process.c --- linux-2.5.1/arch/mips/kernel/process.c Sun Sep 9 17:43:01 2001 +++ linux-2.5/arch/mips/kernel/process.c Thu Dec 27 22:10:28 2001 @@ -36,7 +36,6 @@ { /* endless idle loop with no priority at all */ current->nice = 20; - current->counter = -100; init_idle(); while (1) { diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/mips/kernel/smp.c linux-2.5/arch/mips/kernel/smp.c --- linux-2.5.1/arch/mips/kernel/smp.c Wed Nov 21 18:31:09 2001 +++ linux-2.5/arch/mips/kernel/smp.c Thu Dec 13 16:32:35 2001 @@ -31,6 +31,7 @@ #include <linux/timex.h> #include <linux/sched.h> #include <linux/interrupt.h> +#include <linux/cache.h> #include <asm/atomic.h> #include <asm/processor.h> @@ -52,7 +53,7 @@ /* Ze Big Kernel Lock! */ -spinlock_t kernel_flag = SPIN_LOCK_UNLOCKED; +spinlock_t kernel_flag __cacheline_aligned_in_smp = SPIN_LOCK_UNLOCKED; int smp_threads_ready; /* Not used */ int smp_num_cpus; int global_irq_holder = NO_PROC_ID; diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/mips64/kernel/process.c linux-2.5/arch/mips64/kernel/process.c --- linux-2.5.1/arch/mips64/kernel/process.c Fri Feb 9 19:29:44 2001 +++ linux-2.5/arch/mips64/kernel/process.c Thu Dec 27 22:10:28 2001 @@ -34,7 +34,6 @@ /* endless idle loop with no priority at all */ init_idle(); current->nice = 20; - current->counter = -100; while (1) { while (!current->need_resched) if (wait_available) diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/mips64/kernel/smp.c linux-2.5/arch/mips64/kernel/smp.c --- linux-2.5.1/arch/mips64/kernel/smp.c Wed Jul 4 18:50:39 2001 +++ linux-2.5/arch/mips64/kernel/smp.c Thu Dec 13 16:32:35 2001 @@ -5,6 +5,7 @@ #include <linux/time.h> #include <linux/timex.h> #include <linux/sched.h> +#include <linux/cache.h> #include <asm/atomic.h> #include <asm/processor.h> @@ -52,7 +53,7 @@ #endif /* CONFIG_SGI_IP27 */ /* The 'big kernel lock' */ -spinlock_t kernel_flag = SPIN_LOCK_UNLOCKED; +spinlock_t kernel_flag __cacheline_aligned_in_smp = SPIN_LOCK_UNLOCKED; int smp_threads_ready; /* Not used */ atomic_t smp_commenced = ATOMIC_INIT(0); struct cpuinfo_mips cpu_data[NR_CPUS]; diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/parisc/kernel/pdc_cons.c linux-2.5/arch/parisc/kernel/pdc_cons.c --- linux-2.5.1/arch/parisc/kernel/pdc_cons.c Mon Sep 17 04:23:15 2001 +++ linux-2.5/arch/parisc/kernel/pdc_cons.c Thu Dec 27 15:56:12 2001 @@ -105,10 +105,6 @@ static struct console pdc_cons = { name: "ttyB", write: pdc_console_write, - read: NULL, - device: NULL, - wait_key: pdc_console_wait_key, - unblank: NULL, setup: pdc_console_setup, flags: CON_PRINTBUFFER|CON_ENABLED, // |CON_CONSDEV, index: -1, diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/parisc/kernel/process.c linux-2.5/arch/parisc/kernel/process.c --- linux-2.5.1/arch/parisc/kernel/process.c Fri Feb 9 19:29:44 2001 +++ linux-2.5/arch/parisc/kernel/process.c Thu Dec 27 22:10:28 2001 @@ -71,7 +71,6 @@ /* endless idle loop with no priority at all */ init_idle(); current->nice = 20; - current->counter = -100; while (1) { while (!current->need_resched) { diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/parisc/kernel/traps.c linux-2.5/arch/parisc/kernel/traps.c --- linux-2.5.1/arch/parisc/kernel/traps.c Sun Sep 30 19:26:08 2001 +++ linux-2.5/arch/parisc/kernel/traps.c Thu Dec 27 16:32:30 2001 @@ -43,7 +43,6 @@ static inline void console_verbose(void) { - extern int console_loglevel; console_loglevel = 15; } diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/ppc/8260_io/uart.c linux-2.5/arch/ppc/8260_io/uart.c --- linux-2.5.1/arch/ppc/8260_io/uart.c Tue May 22 00:04:46 2001 +++ linux-2.5/arch/ppc/8260_io/uart.c Sun Dec 30 13:55:22 2001 @@ -1,5 +1,5 @@ /* - * BK Id: SCCS/s.uart.c 1.6 05/17/01 18:14:20 cort + * BK Id: SCCS/s.uart.c 1.11 12/13/01 16:53:53 trini */ /* * UART driver for MPC8260 CPM SCC or SMC @@ -1732,7 +1732,7 @@ printk("lsr = %d (jiff=%lu)...", lsr, jiffies); #endif current->state = TASK_INTERRUPTIBLE; -/* current->counter = 0; make us low-priority */ +/* current->dyn_prio = 0; make us low-priority */ schedule_timeout(char_time); if (signal_pending(current)) break; @@ -2216,54 +2216,6 @@ info->tx_cur = (cbd_t *)bdp; } -/* - * Receive character from the serial port. This only works well - * before the port is initialize for real use. - */ -static int serial_console_wait_key(struct console *co) -{ - struct serial_state *ser; - u_char c, *cp; - ser_info_t *info; - volatile cbd_t *bdp; - volatile smc_uart_t *up; - - ser = rs_table + co->index; - - /* Pointer to UART in parameter ram. - */ - up = (smc_uart_t *)&immr->im_dprambase[ser->port]; - - /* Get the address of the host memory buffer. - * If the port has been initialized for general use, we must - * use information from the port structure. - */ - if ((info = (ser_info_t *)ser->info)) - bdp = info->rx_cur; - else - bdp = (cbd_t *)&immr->im_dprambase[up->smc_rbase]; - - /* - * We need to gracefully shut down the receiver, disable - * interrupts, then read the input. - */ - while (bdp->cbd_sc & BD_SC_EMPTY); /* Wait for a character */ - cp = __va(bdp->cbd_bufaddr); - - if (info) { - if (bdp->cbd_sc & BD_SC_WRAP) { - bdp = info->rx_bd_base; - } - else { - bdp++; - } - info->rx_cur = (cbd_t *)bdp; - } - - c = *cp; - return((int)c); -} - static kdev_t serial_console_device(struct console *c) { return MKDEV(TTYAUX_MAJOR, 64 + c->index); @@ -2274,7 +2226,6 @@ name: "ttyS", write: serial_console_write, device: serial_console_device, - wait_key: serial_console_wait_key, setup: serial_console_setup, flags: CON_PRINTBUFFER, index: CONFIG_SERIAL_CONSOLE_PORT, @@ -2325,7 +2276,11 @@ __clear_user(&serial_driver,sizeof(struct tty_driver)); serial_driver.magic = TTY_DRIVER_MAGIC; serial_driver.driver_name = "serial"; +#ifdef CONFIG_DEVFS_FS + serial_driver.name = "tts/%d"; +#else serial_driver.name = "ttyS"; +#endif serial_driver.major = TTY_MAJOR; serial_driver.minor_start = 64; serial_driver.num = NR_PORTS; @@ -2339,7 +2294,9 @@ serial_driver.table = serial_table; serial_driver.termios = serial_termios; serial_driver.termios_locked = serial_termios_locked; - +#ifdef CONFIG_SERIAL_CONSOLE + serial_driver.console = &sercons; +#endif serial_driver.open = rs_8xx_open; serial_driver.close = rs_8xx_close; serial_driver.write = rs_8xx_write; @@ -2363,7 +2320,11 @@ * major number and the subtype code. */ callout_driver = serial_driver; +#ifdef CONFIG_DEVFS_FS + callout_driver.name = "cua/%d"; +#else callout_driver.name = "cua"; +#endif callout_driver.major = TTYAUX_MAJOR; callout_driver.subtype = SERIAL_TYPE_CALLOUT; callout_driver.read_proc = 0; diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/ppc/8xx_io/uart.c linux-2.5/arch/ppc/8xx_io/uart.c --- linux-2.5.1/arch/ppc/8xx_io/uart.c Sat Nov 3 01:43:54 2001 +++ linux-2.5/arch/ppc/8xx_io/uart.c Sun Dec 30 13:55:22 2001 @@ -1,5 +1,5 @@ /* - * BK Id: SCCS/s.uart.c 1.19 10/26/01 09:59:32 trini + * BK Id: SCCS/s.uart.c 1.21 12/13/01 16:53:53 trini */ /* * UART driver for MPC860 CPM SCC or SMC @@ -97,7 +97,6 @@ static void serial_console_write(struct console *c, const char *s, unsigned count); static kdev_t serial_console_device(struct console *c); -static int serial_console_wait_key(struct console *co); #if defined(CONFIG_SERIAL_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ) static unsigned long break_pressed; /* break, really ... */ @@ -218,7 +217,6 @@ name: "ttyS", write: serial_console_write, device: serial_console_device, - wait_key: serial_console_wait_key, setup: serial_console_setup, flags: CON_PRINTBUFFER, index: CONFIG_SERIAL_CONSOLE_PORT, @@ -1798,7 +1796,7 @@ printk("lsr = %d (jiff=%lu)...", lsr, jiffies); #endif current->state = TASK_INTERRUPTIBLE; -/* current->counter = 0; make us low-priority */ +/* current->dyn_prio = 0; make us low-priority */ schedule_timeout(char_time); if (signal_pending(current)) break; @@ -2402,11 +2400,6 @@ return((int)c); } -static int serial_console_wait_key(struct console *co) -{ - return(my_console_wait_key(co->index, 0, NULL)); -} - #ifdef CONFIG_XMON int xmon_8xx_read_poll(void) @@ -2529,7 +2522,11 @@ __clear_user(&serial_driver,sizeof(struct tty_driver)); serial_driver.magic = TTY_DRIVER_MAGIC; serial_driver.driver_name = "serial"; +#ifdef CONFIG_DEVFS_FS + serial_driver.name = "tts/%d"; +#else serial_driver.name = "ttyS"; +#endif serial_driver.major = TTY_MAJOR; serial_driver.minor_start = 64; serial_driver.num = NR_PORTS; @@ -2543,7 +2540,9 @@ serial_driver.table = serial_table; serial_driver.termios = serial_termios; serial_driver.termios_locked = serial_termios_locked; - +#ifdef CONFIG_SERIAL_CONSOLE + serial_driver.console = &sercons; +#endif serial_driver.open = rs_8xx_open; serial_driver.close = rs_8xx_close; serial_driver.write = rs_8xx_write; @@ -2567,7 +2566,11 @@ * major number and the subtype code. */ callout_driver = serial_driver; +#ifdef CONFIG_DEVFS_FS + callout_driver.name = "cua/%d"; +#else callout_driver.name = "cua"; +#endif callout_driver.major = TTYAUX_MAJOR; callout_driver.subtype = SERIAL_TYPE_CALLOUT; callout_driver.read_proc = 0; diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/ppc/amiga/config.c linux-2.5/arch/ppc/amiga/config.c --- linux-2.5.1/arch/ppc/amiga/config.c Wed Nov 28 21:22:26 2001 +++ linux-2.5/arch/ppc/amiga/config.c Thu Dec 27 15:56:12 2001 @@ -104,7 +104,6 @@ extern void amiga_floppy_setup(char *, int *); #endif static void amiga_reset (void); -static int amiga_wait_key (struct console *co); extern void amiga_init_sound(void); static void amiga_savekmsg_init(void); static void amiga_mem_console_write(struct console *co, const char *b, @@ -118,7 +117,6 @@ static struct console amiga_console_driver = { name: "debug", - wait_key: amiga_wait_key, flags: CON_PRINTBUFFER, index: -1, }; @@ -734,33 +732,6 @@ } return 0; -} - -static int amiga_wait_key (struct console *co) -{ - int i; - - while (1) { - while (ciaa.pra & 0x40); - - /* debounce */ - for (i = 0; i < 1000; i++); - - if (!(ciaa.pra & 0x40)) - break; - } - - /* wait for button up */ - while (1) { - while (!(ciaa.pra & 0x40)); - - /* debounce */ - for (i = 0; i < 1000; i++); - - if (ciaa.pra & 0x40) - break; - } - return 0; } static NORET_TYPE void amiga_reset( void ) diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/ppc/boot/common/misc-simple.c linux-2.5/arch/ppc/boot/common/misc-simple.c --- linux-2.5.1/arch/ppc/boot/common/misc-simple.c Tue Aug 28 13:58:33 2001 +++ linux-2.5/arch/ppc/boot/common/misc-simple.c Thu Dec 27 16:32:30 2001 @@ -45,6 +45,15 @@ char *cmd_line = cmd_buf; unsigned long initrd_start = 0, initrd_end = 0; + +/* These values must be variables. If not, the compiler optimizer + * will remove some code, causing the size of the code to vary + * when these values are zero. This is bad because we first + * compile with these zero to determine the size and offsets + * in an image, than compile again with these set to the proper + * discovered value. + */ +unsigned int initrd_offset, initrd_size; char *zimage_start; int zimage_size; @@ -69,7 +78,8 @@ * were relocated to. */ puts("loaded at: "); puthex(load_addr); - puts(" "); puthex((unsigned long)(load_addr + (4*num_words))); puts("\n"); + puts(" "); puthex((unsigned long)(load_addr + (4*num_words))); + puts("\n"); if ( (unsigned long)load_addr != (unsigned long)&start ) { puts("relocated to: "); puthex((unsigned long)&start); @@ -82,45 +92,38 @@ the size of the elf header which we strip -- Cort */ zimage_start = (char *)(load_addr - 0x10000 + ZIMAGE_OFFSET); zimage_size = ZIMAGE_SIZE; + initrd_offset = INITRD_OFFSET; + initrd_size = INITRD_SIZE; - if ( INITRD_OFFSET ) - initrd_start = load_addr - 0x10000 + INITRD_OFFSET; + if ( initrd_offset ) + initrd_start = load_addr - 0x10000 + initrd_offset; else initrd_start = 0; - initrd_end = INITRD_SIZE + initrd_start; + initrd_end = initrd_size + initrd_start; - /* - * Find a place to stick the zimage and initrd and - * relocate them if we have to. -- Cort - */ + /* Relocate the zImage */ avail_ram = (char *)PAGE_ALIGN((unsigned long)_end); puts("zimage at: "); puthex((unsigned long)zimage_start); - puts(" "); puthex((unsigned long)(zimage_size+zimage_start)); puts("\n"); - if ( (unsigned long)zimage_start <= 0x00800000 ) - { - memcpy( (void *)avail_ram, (void *)zimage_start, zimage_size ); - zimage_start = (char *)avail_ram; - puts("relocated to: "); puthex((unsigned long)zimage_start); - puts(" "); - puthex((unsigned long)zimage_size+(unsigned long)zimage_start); - puts("\n"); + puts(" "); puthex((unsigned long)(zimage_size+zimage_start)); + puts("\n"); + memcpy( (void *)avail_ram, (void *)zimage_start, zimage_size ); + zimage_start = (char *)avail_ram; + puts("relocated to: "); puthex((unsigned long)zimage_start); + puts(" "); + puthex((unsigned long)zimage_size+(unsigned long)zimage_start); + puts("\n"); - /* relocate initrd */ - if ( initrd_start ) - { - puts("initrd at: "); puthex(initrd_start); - puts(" "); puthex(initrd_end); puts("\n"); - avail_ram = (char *)PAGE_ALIGN( - (unsigned long)zimage_size+(unsigned long)zimage_start); - memcpy ((void *)avail_ram, (void *)initrd_start, INITRD_SIZE ); - initrd_start = (unsigned long)avail_ram; - initrd_end = initrd_start + INITRD_SIZE; - puts("relocated to: "); puthex(initrd_start); - puts(" "); puthex(initrd_end); puts("\n"); - } - } else if ( initrd_start ) { + if ( initrd_start ) { puts("initrd at: "); puthex(initrd_start); puts(" "); puthex(initrd_end); puts("\n"); + /* relocate initrd */ + avail_ram = (char *)PAGE_ALIGN((unsigned long)zimage_size + + (unsigned long)zimage_start); + memcpy( (void *)avail_ram, (void *)initrd_start, initrd_size ); + initrd_start = (unsigned long)avail_ram; + initrd_end = initrd_start + initrd_size; + puts("relocated to: "); puthex(initrd_start); + puts(" "); puthex(initrd_end); puts("\n"); } avail_ram = (char *)0x00400000; @@ -161,11 +164,9 @@ puts("\n"); /* mappings on early boot can only handle 16M */ - if ( (int)(cmd_line[0]) > (16<<20)) + if ( (u32)(cmd_line) > (16<<20)) puts("cmd_line located > 16M\n"); - if ( initrd_start > (16<<20)) - puts("initrd_start located > 16M\n"); - + puts("Uncompressing Linux..."); gunzip(0, 0x400000, zimage_start, &zimage_size); diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/ppc/boot/common/ns16550.c linux-2.5/arch/ppc/boot/common/ns16550.c --- linux-2.5.1/arch/ppc/boot/common/ns16550.c Tue Aug 28 13:58:33 2001 +++ linux-2.5/arch/ppc/boot/common/ns16550.c Thu Dec 27 16:32:30 2001 @@ -1,5 +1,5 @@ /* - * BK Id: SCCS/s.ns16550.c 1.9 07/30/01 17:19:40 trini + * BK Id: SCCS/s.ns16550.c 1.12 10/08/01 17:16:50 paulus */ /* * COM1 NS16550 support @@ -10,6 +10,9 @@ #include <linux/serial_reg.h> #include <asm/serial.h> +/* Default serial baud rate */ +#define SERIAL_BAUD 9600 + extern void outb(int port, unsigned char val); extern unsigned char inb(int port); extern unsigned long ISA_io; @@ -46,13 +49,20 @@ outb(com_port + (UART_IER << shift), 0x00); /* Access baud rate */ outb(com_port + (UART_LCR << shift), 0x80); -#ifdef CONFIG_SERIAL_CONSOLE_NONSTD - /* Input clock. */ - outb(com_port + (UART_DLL << shift), - (BASE_BAUD / CONFIG_SERIAL_CONSOLE_BAUD)); - outb(com_port + (UART_DLM << shift), - (BASE_BAUD / CONFIG_SERIAL_CONSOLE_BAUD) >> 8); -#endif + /* + * Test if serial port is unconfigured. + * We assume that no-one uses less than 110 baud or + * less than 7 bits per character these days. + * -- paulus. + */ + if (inb(com_port + (UART_DLM << shift)) > 4 + || (inb(com_port + (UART_LCR << shift)) & 2) == 0) { + /* Input clock. */ + outb(com_port + (UART_DLL << shift), + (BASE_BAUD / SERIAL_BAUD)); + outb(com_port + (UART_DLM << shift), + (BASE_BAUD / SERIAL_BAUD) >> 8); + } /* 8 data, 1 stop, no parity */ outb(com_port + (UART_LCR << shift), 0x03); /* RTS/DTR */ diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/ppc/boot/images/Makefile linux-2.5/arch/ppc/boot/images/Makefile --- linux-2.5.1/arch/ppc/boot/images/Makefile Thu May 24 22:02:06 2001 +++ linux-2.5/arch/ppc/boot/images/Makefile Thu Dec 27 16:32:30 2001 @@ -9,4 +9,4 @@ gzip -vf9 vmlinux clean: - rm -f sImage vmapus vmlinux.* miboot.image* zImage* zvmlinux.* + rm -f sImage vmapus vmlinux* miboot* zImage* zvmlinux* diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/ppc/boot/mbx/Makefile linux-2.5/arch/ppc/boot/mbx/Makefile --- linux-2.5.1/arch/ppc/boot/mbx/Makefile Tue Jun 12 02:15:27 2001 +++ linux-2.5/arch/ppc/boot/mbx/Makefile Thu Dec 27 16:32:30 2001 @@ -1,4 +1,4 @@ -# BK Id: SCCS/s.Makefile 1.7 06/05/01 20:20:05 paulus +# BK Id: SCCS/s.Makefile 1.9 10/15/01 10:53:29 trini # # # arch/ppc/mbxboot/Makefile @@ -73,6 +73,12 @@ -DZIMAGE_SIZE=0 -c -o $@ $*.c zvmlinux.initrd: $(OBJECTS) $(LIBS) ../images/vmlinux.gz +# +# Recompile misc.o again with more 'correct' bogus offsets +# + $(CC) $(CFLAGS) -DINITRD_OFFSET=0x0008c8e3 -DINITRD_SIZE=0x0000111a \ + -DZIMAGE_OFFSET=0x00018000 -DZIMAGE_SIZE=0x000748e2 \ + -c -o misc.o misc.c $(LD) $(ZLINKFLAGS) -o $@.tmp $(OBJECTS) $(LIBS) $(OBJCOPY) $(OBJCOPY_ARGS) -R .comment \ --add-section=initrd=../images/ramdisk.image.gz \ @@ -88,6 +94,8 @@ --add-section=initrd=../images/ramdisk.image.gz \ --add-section=image=../images/vmlinux.gz \ $@.tmp ../images/$@.embedded +# Remove zvmlinux and zvmlinux.temp, we have ../images/zvmlinux.embedded + rm -f $@.tmp $@ zImage: zvmlinux ifeq ($(CONFIG_RPXCLASSIC),y) @@ -104,6 +112,12 @@ endif zvmlinux: $(OBJECTS) $(LIBS) ../images/vmlinux.gz +# +# Recompile misc.o again with more 'correct' bogus offsets +# + $(CC) $(CFLAGS) -DINITRD_OFFSET=0 -DINITRD_SIZE=0 \ + -DZIMAGE_OFFSET=0x00018000 -DZIMAGE_SIZE=0x000748e2 \ + -c -o misc.o misc.c # # build the boot loader image and then compute the offset into it # for the kernel image diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/ppc/boot/mbx/misc.c linux-2.5/arch/ppc/boot/mbx/misc.c --- linux-2.5.1/arch/ppc/boot/mbx/misc.c Tue Aug 28 13:58:33 2001 +++ linux-2.5/arch/ppc/boot/mbx/misc.c Thu Dec 27 16:32:30 2001 @@ -1,5 +1,5 @@ /* - * BK Id: SCCS/s.misc.c 1.13 07/27/01 11:44:37 trini + * BK Id: SCCS/s.misc.c 1.15 10/15/01 10:53:29 trini */ /* * Adapted for PowerPC by Gary Thomas @@ -44,10 +44,6 @@ char *avail_ram; char *end_avail; -/* See comment below..... -*/ -unsigned int initrd_offset, initrd_size; - /* Because of the limited amount of memory on embedded, it presents * loading problems. The biggest is that we load this boot program * into a relatively low memory address, and the Linux kernel Bss often @@ -75,14 +71,13 @@ bd_t *hold_residual = &hold_resid_buf; unsigned long initrd_start = 0, initrd_end = 0; char *zimage_start; -int zimage_size; extern void gunzip(void *, int, unsigned char *, int *); unsigned long decompress_kernel(unsigned long load_addr, int num_words, unsigned long cksum, bd_t *bp) { - int timer; + int timer, zimage_size = ZIMAGE_SIZE; extern unsigned long start; char *cp, ch; @@ -93,17 +88,6 @@ serial_init(bp); #endif - /* These values must be variables. If not, the compiler optimizer - * will remove some code, causing the size of the code to vary - * when these values are zero. This is bad because we first - * compile with these zero to determine the size and offsets - * in an image, than compile again with these set to the proper - * discovered value.....Ya know, we used to read these from the - * header a long time ago..... - */ - initrd_offset = INITRD_OFFSET; - initrd_size = INITRD_SIZE; - /* Grab some space for the command line and board info. Since * we no longer use the ELF header, but it was loaded, grab * that space. @@ -154,13 +138,12 @@ /* we have to subtract 0x10000 here to correct for objdump including the size of the elf header which we strip -- Cort */ zimage_start = (char *)(load_addr - 0x10000 + ZIMAGE_OFFSET); - zimage_size = ZIMAGE_SIZE; - if ( initrd_offset ) - initrd_start = load_addr - 0x10000 + initrd_offset; + if ( INITRD_OFFSET ) + initrd_start = load_addr - 0x10000 + INITRD_OFFSET; else initrd_start = 0; - initrd_end = initrd_size + initrd_start; + initrd_end = INITRD_SIZE + initrd_start; /* * setup avail_ram - this is the first part of ram usable @@ -201,9 +184,9 @@ if ((unsigned long)initrd_start > 0x01000000) { memcpy ((void *)PAGE_ALIGN(-PAGE_SIZE+(unsigned long)end_avail-INITRD_SIZE), (void *)initrd_start, - initrd_size ); + INITRD_SIZE ); initrd_start = PAGE_ALIGN(-PAGE_SIZE+(unsigned long)end_avail-INITRD_SIZE); - initrd_end = initrd_start + initrd_size; + initrd_end = initrd_start + INITRD_SIZE; end_avail = (char *)initrd_start; puts("relocated to: "); puthex(initrd_start); puts(" "); puthex(initrd_end); puts("\n"); diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/ppc/boot/pmac/Makefile linux-2.5/arch/ppc/boot/pmac/Makefile --- linux-2.5.1/arch/ppc/boot/pmac/Makefile Tue Aug 28 13:58:33 2001 +++ linux-2.5/arch/ppc/boot/pmac/Makefile Thu Dec 27 16:32:30 2001 @@ -1,4 +1,4 @@ -# BK Id: SCCS/s.Makefile 1.14 07/27/01 20:24:17 trini +# BK Id: SCCS/s.Makefile 1.16 09/28/01 07:39:37 trini # # Makefile for making XCOFF bootable images for booting on PowerMacs # using Open Firmware. @@ -48,9 +48,9 @@ cp ../images/vmlinux.coff $(TFTPIMAGE) cp ../images/vmlinux.elf-pmac $(TFTPIMAGE).elf -znetboot.initrd: vmlinux.coff.initrd vmlinux.initrd.elf-pmac - cp ../images/vmlinux.coff.initrd $(TFTPIMAGE) - cp ../images/vmlinux.elf-pmac.initrd $(TFTPIMAGE).elf +znetboot.initrd: vmlinux.initrd.coff vmlinux.initrd.elf-pmac + cp ../images/vmlinux.initrd.coff $(TFTPIMAGE) + cp ../images/vmlinux.initrd.elf-pmac $(TFTPIMAGE).elf #floppy: zImage # mount -t hfs /dev/fd0 /mnt @@ -61,7 +61,7 @@ $(OBJCOPY) $(OBJCOPY_ARGS) --add-section=image=../images/vmlinux.gz \ dummy.o ../images/$@ -miboot.image.initrd: miboot.image ../images/ramdisk.image.gz +miboot.initrd.image: miboot.image ../images/ramdisk.image.gz $(OBJCOPY) $(OBJCOPY_ARGS) --add-section=initrd=../images/ramdisk.image.gz \ ../images/miboot.image ../images/$@ @@ -83,11 +83,11 @@ rm -f coffboot ln -sf vmlinux.coff ../images/zImage.pmac -vmlinux.coff.initrd: coffboot.initrd $(HACKCOFF) +vmlinux.initrd.coff: coffboot.initrd $(HACKCOFF) $(OBJCOPY) $(OBJCOPY_ARGS) coffboot.initrd ../images/$@ $(HACKCOFF) ../images/$@ rm -f coffboot.initrd - ln -sf vmlinux.coff.initrd ../images/zImage.initrd.pmac + ln -sf vmlinux.initrd.coff ../images/zImage.initrd.pmac vmlinux.elf-pmac: $(CHRPOBJS) $(LIBS) ../common/no_initrd.o $(MKNOTE) ../images/vmlinux.gz $(LD) $(CHRP_LD_ARGS) -o ../images/$@ $(CHRPOBJS) ../common/no_initrd.o $(LIBS) @@ -110,6 +110,6 @@ zImage: vmlinux.coff vmlinux.elf-pmac miboot.image -zImage.initrd: vmlinux.coff.initrd vmlinux.initrd.elf-pmac miboot.image.initrd +zImage.initrd: vmlinux.initrd.coff vmlinux.initrd.elf-pmac miboot.initrd.image include $(TOPDIR)/Rules.make diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/ppc/boot/prep/Makefile linux-2.5/arch/ppc/boot/prep/Makefile --- linux-2.5.1/arch/ppc/boot/prep/Makefile Mon Oct 8 18:43:01 2001 +++ linux-2.5/arch/ppc/boot/prep/Makefile Thu Dec 27 16:32:30 2001 @@ -1,4 +1,4 @@ -# BK Id: SCCS/s.Makefile 1.26 09/25/01 07:54:40 trini +# BK Id: SCCS/s.Makefile 1.28 10/21/01 20:47:58 trini # # arch/ppc/boot/Makefile # @@ -45,6 +45,12 @@ -DZIMAGE_SIZE=0 -c -o $@ $*.c zvmlinux.initrd: $(obj-y) $(LIBS) ../images/vmlinux.gz +# +# Recompile misc.oagain with more 'correct' bogus offsets +# + $(CC) $(CFLAGS) -DINITRD_OFFSET=0x00138466 -DINITRD_SIZE=0x0000111a \ + -DZIMAGE_OFFSET=0x0001b000 -DZIMAGE_SIZE=0x0011d460 \ + -c -o misc.o misc.c $(LD) $(ZLINKFLAGS) -o $@.tmp $(obj-y) $(LIBS) $(OBJCOPY) $(OBJCOPY_ARGS) -R .comment \ --add-section=initrd=../images/ramdisk.image.gz \ @@ -60,7 +66,7 @@ --add-section=initrd=../images/ramdisk.image.gz \ --add-section=image=../images/vmlinux.gz \ $@.tmp $@ - rm -f $@.tmp zvmlinux + rm -f $@.tmp zImage: zvmlinux $(MKPREP) $(MKPREP) -pbp zvmlinux ../images/$@.prep @@ -72,6 +78,12 @@ zvmlinux: $(obj-y) $(LIBS) ../images/vmlinux.gz # +# Recompile misc.oagain with more 'correct' bogus offsets +# + $(CC) $(CFLAGS) -DINITRD_OFFSET=0 -DINITRD_SIZE=0 \ + -DZIMAGE_OFFSET=0x0001b000 -DZIMAGE_SIZE=0x0011d460 \ + -c -o misc.o misc.c +# # build the boot loader image and then compute the offset into it # for the kernel image # @@ -88,7 +100,7 @@ $(LD) $(ZLINKFLAGS) -o zvmlinux.tmp $(obj-y) $(LIBS) $(OBJCOPY) $(OBJCOPY_ARGS) -R .comment \ --add-section=image=../images/vmlinux.gz $@.tmp $@ - rm $@.tmp + rm -f $@.tmp floppy: zImage dd if=../images/zImage.prep of=/dev/fd0H1440 bs=64b diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/ppc/boot/prep/misc.c linux-2.5/arch/ppc/boot/prep/misc.c --- linux-2.5.1/arch/ppc/boot/prep/misc.c Mon Oct 15 20:35:26 2001 +++ linux-2.5/arch/ppc/boot/prep/misc.c Thu Dec 27 16:32:30 2001 @@ -1,5 +1,5 @@ /* - * BK Id: SCCS/s.misc.c 1.20 09/24/01 18:42:54 trini + * BK Id: SCCS/s.misc.c 1.22 10/15/01 17:46:21 trini * * arch/ppc/boot/prep/misc.c * @@ -48,14 +48,6 @@ RESIDUAL *hold_residual = &hold_resid_buf; unsigned long initrd_start = 0, initrd_end = 0; -/* These values must be variables. If not, the compiler optimizer - * will remove some code, causing the size of the code to vary - * when these values are zero. This is bad because we first - * compile with these zero to determine the size and offsets - * in an image, than compile again with these set to the proper - * discovered value. - */ -unsigned int initrd_offset, initrd_size; char *zimage_start; int zimage_size; @@ -311,14 +303,12 @@ size of the elf header which we strip -- Cort */ zimage_start = (char *)(load_addr - 0x10000 + ZIMAGE_OFFSET); zimage_size = ZIMAGE_SIZE; - initrd_offset = INITRD_OFFSET; - initrd_size = INITRD_SIZE; - if ( initrd_offset ) - initrd_start = load_addr - 0x10000 + initrd_offset; + if ( INITRD_OFFSET ) + initrd_start = load_addr - 0x10000 + INITRD_OFFSET; else initrd_start = 0; - initrd_end = initrd_size + initrd_start; + initrd_end = INITRD_SIZE + initrd_start; /* * Find a place to stick the zimage and initrd and @@ -343,9 +333,9 @@ puts(" "); puthex(initrd_end); puts("\n"); avail_ram = (char *)PAGE_ALIGN( (unsigned long)zimage_size+(unsigned long)zimage_start); - memcpy ((void *)avail_ram, (void *)initrd_start, initrd_size ); + memcpy ((void *)avail_ram, (void *)initrd_start, INITRD_SIZE ); initrd_start = (unsigned long)avail_ram; - initrd_end = initrd_start + initrd_size; + initrd_end = initrd_start + INITRD_SIZE; puts("relocated to: "); puthex(initrd_start); puts(" "); puthex(initrd_end); puts("\n"); } @@ -395,7 +385,7 @@ puts("\n"); /* mappings on early boot can only handle 16M */ - if ( (int)(cmd_line[0]) > (16<<20)) + if ( (int)(cmd_line) > (16<<20)) puts("cmd_line located > 16M\n"); if ( (int)hold_residual > (16<<20)) puts("hold_residual located > 16M\n"); diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/ppc/boot/utils/mksimage.c linux-2.5/arch/ppc/boot/utils/mksimage.c --- linux-2.5.1/arch/ppc/boot/utils/mksimage.c Thu May 24 22:02:07 2001 +++ linux-2.5/arch/ppc/boot/utils/mksimage.c Thu Dec 27 16:32:30 2001 @@ -1,5 +1,5 @@ /* - * BK Id: SCCS/s.mksimage.c 1.6 05/18/01 15:16:42 cort + * BK Id: SCCS/s.mksimage.c 1.7 10/11/01 11:59:05 trini */ /* * @@ -96,7 +96,7 @@ die("can't open loader: %s", strerror(errno)); copy_blocks(fd, ofd, &ld_off, &ld_size); - len = sprintf(buffer, "bootloader: %x %x\n", ld_off, ld_size); + len = sprintf(buffer, "bootloader: %lx %lx\n", ld_off, ld_size); close(fd); fd = open(kernel, O_RDONLY); @@ -104,7 +104,7 @@ die("can't open kernel: %s", strerror(errno)); copy_blocks(fd, ofd, &kern_off, &kern_size); - len += sprintf(buffer+len, "zimage: %x %x\n", kern_off, kern_size); + len += sprintf(buffer+len, "zimage: %lx %lx\n", kern_off, kern_size); close(fd); if (rdimage) { @@ -116,7 +116,7 @@ close(fd); } - len += sprintf(buffer+len, "initrd: %x %x", rd_off, rd_size); + len += sprintf(buffer+len, "initrd: %lx %lx", rd_off, rd_size); close(ofd); diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/ppc/boot/utils/offset linux-2.5/arch/ppc/boot/utils/offset --- linux-2.5.1/arch/ppc/boot/utils/offset Thu May 24 22:02:07 2001 +++ linux-2.5/arch/ppc/boot/utils/offset Thu Dec 27 16:32:30 2001 @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh -OFFSET=`$1 -h $2 | grep $3 | grep -v zvmlinux| awk '{print $6}'` +OFFSET=`$1 -h $2 | grep $3 | grep -v zvmlinux | awk '{print $6}'` echo "0x"$OFFSET diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/ppc/boot/utils/sioffset linux-2.5/arch/ppc/boot/utils/sioffset --- linux-2.5.1/arch/ppc/boot/utils/sioffset Thu May 24 22:02:07 2001 +++ linux-2.5/arch/ppc/boot/utils/sioffset Thu Dec 27 16:32:30 2001 @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh OFFSET=`grep $1 sImage.map | awk '{print $2}'` echo "0x"$OFFSET diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/ppc/boot/utils/sisize linux-2.5/arch/ppc/boot/utils/sisize --- linux-2.5.1/arch/ppc/boot/utils/sisize Thu May 24 22:02:07 2001 +++ linux-2.5/arch/ppc/boot/utils/sisize Thu Dec 27 16:32:30 2001 @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh OFFSET=`grep $1 sImage.map | awk '{print $3}'` echo "0x"$OFFSET diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/ppc/boot/utils/size linux-2.5/arch/ppc/boot/utils/size --- linux-2.5.1/arch/ppc/boot/utils/size Thu May 24 22:02:07 2001 +++ linux-2.5/arch/ppc/boot/utils/size Thu Dec 27 16:32:30 2001 @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh -OFFSET=`$1 -h $2 | grep $3 | grep -v zvmlinux | awk '{print $3}'` +OFFSET=`$1 -h $2 | grep $3 | grep -v zvmlinux | awk '{print $3}'` echo "0x"$OFFSET diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/ppc/config.in linux-2.5/arch/ppc/config.in --- linux-2.5.1/arch/ppc/config.in Fri Nov 16 18:10:08 2001 +++ linux-2.5/arch/ppc/config.in Thu Dec 27 16:32:30 2001 @@ -1,4 +1,4 @@ -# BK Id: SCCS/s.config.in 1.45 11/08/01 07:57:40 paulus +# BK Id: SCCS/s.config.in 1.47 12/01/01 20:09:06 benh # # For a description of the syntax of this configuration file, # see Documentation/kbuild/config-language.txt. @@ -328,6 +328,10 @@ bool 'Support for PMU based PowerMacs' CONFIG_ADB_PMU if [ "$CONFIG_ADB_PMU" = "y" ]; then bool ' Power management support for PowerBooks' CONFIG_PMAC_PBOOK + if [ "$CONFIG_PMAC_PBOOK" = "y" ]; then + define_bool CONFIG_PM y + tristate ' APM emulation' CONFIG_PMAC_APM_EMU + fi # made a separate option since backlight may end up beeing used # on non-powerbook machines (but only on PMU based ones AFAIK) bool ' Backlight control for LCD screens' CONFIG_PMAC_BACKLIGHT @@ -352,6 +356,9 @@ # layer is used. if [ "$CONFIG_INPUT" != "n" ]; then define_bool CONFIG_MAC_HID y + fi + if [ "$CONFIG_ADB_CUDA" != "n" ]; then + bool 'Support for ANS LCD display' CONFIG_ANSLCD fi fi endmenu diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/ppc/configs/common_defconfig linux-2.5/arch/ppc/configs/common_defconfig --- linux-2.5.1/arch/ppc/configs/common_defconfig Sat Nov 3 01:43:54 2001 +++ linux-2.5/arch/ppc/configs/common_defconfig Thu Dec 27 16:32:30 2001 @@ -4,6 +4,7 @@ # CONFIG_UID16 is not set # CONFIG_RWSEM_GENERIC_SPINLOCK is not set CONFIG_RWSEM_XCHGADD_ALGORITHM=y +CONFIG_HAVE_DEC_LOCK=y # # Code maturity level options @@ -119,8 +120,6 @@ # CONFIG_PACKET=y # CONFIG_PACKET_MMAP is not set -CONFIG_NETLINK=y -# CONFIG_RTNETLINK is not set # CONFIG_NETLINK_DEV is not set CONFIG_NETFILTER=y # CONFIG_NETFILTER_DEBUG is not set @@ -133,6 +132,7 @@ # CONFIG_NET_IPIP is not set # CONFIG_NET_IPGRE is not set # CONFIG_IP_MROUTE is not set +# CONFIG_ARPD is not set # CONFIG_INET_ECN is not set CONFIG_SYN_COOKIES=y @@ -343,15 +343,11 @@ # CONFIG_SCSI_INIA100 is not set # CONFIG_SCSI_NCR53C406A is not set # CONFIG_SCSI_NCR53C7xx is not set -CONFIG_SCSI_NCR53C8XX=y -CONFIG_SCSI_SYM53C8XX=y -CONFIG_SCSI_NCR53C8XX_DEFAULT_TAGS=8 -CONFIG_SCSI_NCR53C8XX_MAX_TAGS=32 -CONFIG_SCSI_NCR53C8XX_SYNC=20 -# CONFIG_SCSI_NCR53C8XX_PROFILE is not set -# CONFIG_SCSI_NCR53C8XX_IOMAPPED is not set -# CONFIG_SCSI_NCR53C8XX_PQS_PDS is not set -# CONFIG_SCSI_NCR53C8XX_SYMBIOS_COMPAT is not set +CONFIG_SCSI_SYM53C8XX_2=y +CONFIG_SCSI_SYM53C8XX_DMA_ADDRESSING_MODE=0 +CONFIG_SCSI_SYM53C8XX_DEFAULT_TAGS=16 +CONFIG_SCSI_SYM53C8XX_MAX_TAGS=64 +# CONFIG_SCSI_SYM53C8XX_IOMAPPED is not set # CONFIG_SCSI_PAS16 is not set # CONFIG_SCSI_PCI2000 is not set # CONFIG_SCSI_PCI2220I is not set @@ -388,7 +384,9 @@ # # Appletalk devices # -# CONFIG_APPLETALK is not set +# CONFIG_LTPC is not set +# CONFIG_COPS is not set +# CONFIG_IPDDP is not set # CONFIG_DUMMY is not set # CONFIG_BONDING is not set # CONFIG_EQUALIZER is not set @@ -443,6 +441,7 @@ # CONFIG_SUNDANCE is not set # CONFIG_TLAN is not set # CONFIG_VIA_RHINE is not set +# CONFIG_VIA_RHINE_MMIO is not set # CONFIG_WINBOND_840 is not set # CONFIG_NET_POCKET is not set @@ -544,6 +543,7 @@ CONFIG_FB_MATROX_MILLENIUM=y CONFIG_FB_MATROX_MYSTIQUE=y # CONFIG_FB_MATROX_G100 is not set +# CONFIG_FB_MATROX_I2C is not set # CONFIG_FB_MATROX_G450 is not set # CONFIG_FB_MATROX_MULTIHEAD is not set CONFIG_FB_ATY=y @@ -597,6 +597,7 @@ CONFIG_MAC_ADBKEYCODES=y CONFIG_MAC_EMUMOUSEBTN=y CONFIG_MAC_HID=y +# CONFIG_ANSLCD is not set # # Character devices @@ -612,7 +613,12 @@ # # I2C support # -# CONFIG_I2C is not set +CONFIG_I2C=m +# CONFIG_I2C_ALGOBIT is not set +# CONFIG_I2C_ALGOPCF is not set +CONFIG_I2C_KEYWEST=m +CONFIG_I2C_CHARDEV=m +CONFIG_I2C_PROC=m # # Mice @@ -693,11 +699,15 @@ # CONFIG_AUTOFS4_FS is not set # CONFIG_REISERFS_FS is not set # CONFIG_REISERFS_CHECK is not set +# CONFIG_REISERFS_PROC_INFO is not set # CONFIG_ADFS_FS is not set # CONFIG_ADFS_FS_RW is not set # CONFIG_AFFS_FS is not set CONFIG_HFS_FS=m # CONFIG_BFS_FS is not set +# CONFIG_EXT3_FS is not set +# CONFIG_JBD is not set +# CONFIG_JBD_DEBUG is not set CONFIG_FAT_FS=m CONFIG_MSDOS_FS=m # CONFIG_UMSDOS_FS is not set @@ -710,6 +720,7 @@ # CONFIG_RAMFS is not set CONFIG_ISO9660_FS=y # CONFIG_JOLIET is not set +# CONFIG_ZISOFS is not set # CONFIG_MINIX_FS is not set # CONFIG_VXFS_FS is not set # CONFIG_NTFS_FS is not set @@ -734,6 +745,7 @@ # Network File Systems # # CONFIG_CODA_FS is not set +# CONFIG_INTERMEZZO_FS is not set CONFIG_NFS_FS=y # CONFIG_NFS_V3 is not set # CONFIG_ROOT_NFS is not set @@ -751,6 +763,8 @@ # CONFIG_NCPFS_SMALLDOS is not set # CONFIG_NCPFS_NLS is not set # CONFIG_NCPFS_EXTRAS is not set +# CONFIG_ZISOFS_FS is not set +# CONFIG_ZLIB_FS_INFLATE is not set # # Partition Types @@ -818,8 +832,10 @@ # Sound # CONFIG_SOUND=m -CONFIG_DMASOUND_AWACS=m +CONFIG_DMASOUND_PMAC=m CONFIG_DMASOUND=m +CONFIG_I2C=m +CONFIG_I2C_KEYWEST=m # CONFIG_SOUND_BT878 is not set # CONFIG_SOUND_CMPCI is not set # CONFIG_SOUND_EMU10K1 is not set @@ -854,7 +870,6 @@ CONFIG_USB_DEVICEFS=y # CONFIG_USB_BANDWIDTH is not set # CONFIG_USB_LONG_TIMEOUT is not set -# CONFIG_USB_LARGE_CONFIG is not set # # USB Controllers diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/ppc/configs/gemini_defconfig linux-2.5/arch/ppc/configs/gemini_defconfig --- linux-2.5.1/arch/ppc/configs/gemini_defconfig Sat Nov 3 01:43:54 2001 +++ linux-2.5/arch/ppc/configs/gemini_defconfig Thu Dec 27 16:32:30 2001 @@ -4,6 +4,7 @@ # CONFIG_UID16 is not set # CONFIG_RWSEM_GENERIC_SPINLOCK is not set CONFIG_RWSEM_XCHGADD_ALGORITHM=y +CONFIG_HAVE_DEC_LOCK=y # # Code maturity level options @@ -109,8 +110,6 @@ # CONFIG_PACKET=y # CONFIG_PACKET_MMAP is not set -CONFIG_NETLINK=y -# CONFIG_RTNETLINK is not set # CONFIG_NETLINK_DEV is not set CONFIG_NETFILTER=y # CONFIG_NETFILTER_DEBUG is not set @@ -122,6 +121,7 @@ # CONFIG_IP_PNP is not set # CONFIG_NET_IPIP is not set # CONFIG_NET_IPGRE is not set +# CONFIG_ARPD is not set # CONFIG_INET_ECN is not set # CONFIG_SYN_COOKIES is not set @@ -221,15 +221,11 @@ # CONFIG_SCSI_INIA100 is not set # CONFIG_SCSI_NCR53C406A is not set # CONFIG_SCSI_NCR53C7xx is not set -# CONFIG_SCSI_NCR53C8XX is not set -CONFIG_SCSI_SYM53C8XX=y -CONFIG_SCSI_NCR53C8XX_DEFAULT_TAGS=8 -CONFIG_SCSI_NCR53C8XX_MAX_TAGS=32 -CONFIG_SCSI_NCR53C8XX_SYNC=20 -# CONFIG_SCSI_NCR53C8XX_PROFILE is not set -# CONFIG_SCSI_NCR53C8XX_IOMAPPED is not set -# CONFIG_SCSI_NCR53C8XX_PQS_PDS is not set -# CONFIG_SCSI_NCR53C8XX_SYMBIOS_COMPAT is not set +CONFIG_SCSI_SYM53C8XX_2=y +CONFIG_SCSI_SYM53C8XX_DMA_ADDRESSING_MODE=0 +CONFIG_SCSI_SYM53C8XX_DEFAULT_TAGS=16 +CONFIG_SCSI_SYM53C8XX_MAX_TAGS=64 +# CONFIG_SCSI_SYM53C8XX_IOMAPPED is not set # CONFIG_SCSI_PAS16 is not set # CONFIG_SCSI_PCI2000 is not set # CONFIG_SCSI_PCI2220I is not set @@ -432,11 +428,15 @@ # CONFIG_AUTOFS4_FS is not set # CONFIG_REISERFS_FS is not set # CONFIG_REISERFS_CHECK is not set +# CONFIG_REISERFS_PROC_INFO is not set # CONFIG_ADFS_FS is not set # CONFIG_ADFS_FS_RW is not set # CONFIG_AFFS_FS is not set # CONFIG_HFS_FS is not set # CONFIG_BFS_FS is not set +# CONFIG_EXT3_FS is not set +# CONFIG_JBD is not set +# CONFIG_JBD_DEBUG is not set # CONFIG_FAT_FS is not set # CONFIG_MSDOS_FS is not set # CONFIG_UMSDOS_FS is not set @@ -449,6 +449,7 @@ # CONFIG_RAMFS is not set CONFIG_ISO9660_FS=y # CONFIG_JOLIET is not set +# CONFIG_ZISOFS is not set # CONFIG_MINIX_FS is not set # CONFIG_VXFS_FS is not set # CONFIG_NTFS_FS is not set @@ -473,6 +474,7 @@ # Network File Systems # # CONFIG_CODA_FS is not set +# CONFIG_INTERMEZZO_FS is not set CONFIG_NFS_FS=y # CONFIG_NFS_V3 is not set # CONFIG_ROOT_NFS is not set @@ -490,6 +492,8 @@ # CONFIG_NCPFS_SMALLDOS is not set # CONFIG_NCPFS_NLS is not set # CONFIG_NCPFS_EXTRAS is not set +# CONFIG_ZISOFS_FS is not set +# CONFIG_ZLIB_FS_INFLATE is not set # # Partition Types diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/ppc/configs/ibmchrp_defconfig linux-2.5/arch/ppc/configs/ibmchrp_defconfig --- linux-2.5.1/arch/ppc/configs/ibmchrp_defconfig Sat Nov 3 01:43:54 2001 +++ linux-2.5/arch/ppc/configs/ibmchrp_defconfig Thu Dec 27 16:32:30 2001 @@ -4,6 +4,7 @@ # CONFIG_UID16 is not set # CONFIG_RWSEM_GENERIC_SPINLOCK is not set CONFIG_RWSEM_XCHGADD_ALGORITHM=y +CONFIG_HAVE_DEC_LOCK=y # # Code maturity level options @@ -112,8 +113,6 @@ # CONFIG_PACKET=y # CONFIG_PACKET_MMAP is not set -CONFIG_NETLINK=y -# CONFIG_RTNETLINK is not set # CONFIG_NETLINK_DEV is not set CONFIG_NETFILTER=y # CONFIG_NETFILTER_DEBUG is not set @@ -126,6 +125,7 @@ # CONFIG_NET_IPIP is not set # CONFIG_NET_IPGRE is not set # CONFIG_IP_MROUTE is not set +# CONFIG_ARPD is not set # CONFIG_INET_ECN is not set CONFIG_SYN_COOKIES=y @@ -252,15 +252,11 @@ # CONFIG_SCSI_INIA100 is not set # CONFIG_SCSI_NCR53C406A is not set # CONFIG_SCSI_NCR53C7xx is not set -# CONFIG_SCSI_NCR53C8XX is not set -CONFIG_SCSI_SYM53C8XX=y -CONFIG_SCSI_NCR53C8XX_DEFAULT_TAGS=8 -CONFIG_SCSI_NCR53C8XX_MAX_TAGS=32 -CONFIG_SCSI_NCR53C8XX_SYNC=20 -# CONFIG_SCSI_NCR53C8XX_PROFILE is not set -# CONFIG_SCSI_NCR53C8XX_IOMAPPED is not set -# CONFIG_SCSI_NCR53C8XX_PQS_PDS is not set -# CONFIG_SCSI_NCR53C8XX_SYMBIOS_COMPAT is not set +CONFIG_SCSI_SYM53C8XX_2=y +CONFIG_SCSI_SYM53C8XX_DMA_ADDRESSING_MODE=0 +CONFIG_SCSI_SYM53C8XX_DEFAULT_TAGS=16 +CONFIG_SCSI_SYM53C8XX_MAX_TAGS=64 +# CONFIG_SCSI_SYM53C8XX_IOMAPPED is not set # CONFIG_SCSI_PAS16 is not set # CONFIG_SCSI_PCI2000 is not set # CONFIG_SCSI_PCI2220I is not set @@ -343,6 +339,7 @@ # CONFIG_SUNDANCE is not set # CONFIG_TLAN is not set # CONFIG_VIA_RHINE is not set +# CONFIG_VIA_RHINE_MMIO is not set # CONFIG_WINBOND_840 is not set # CONFIG_NET_POCKET is not set @@ -546,7 +543,7 @@ # CONFIG_WATCHDOG is not set # CONFIG_INTEL_RNG is not set CONFIG_NVRAM=y -CONFIG_RTC=y +# CONFIG_RTC is not set # CONFIG_DTLK is not set # CONFIG_R3964 is not set # CONFIG_APPLICOM is not set @@ -571,11 +568,15 @@ # CONFIG_AUTOFS4_FS is not set # CONFIG_REISERFS_FS is not set # CONFIG_REISERFS_CHECK is not set +# CONFIG_REISERFS_PROC_INFO is not set # CONFIG_ADFS_FS is not set # CONFIG_ADFS_FS_RW is not set # CONFIG_AFFS_FS is not set # CONFIG_HFS_FS is not set # CONFIG_BFS_FS is not set +# CONFIG_EXT3_FS is not set +# CONFIG_JBD is not set +# CONFIG_JBD_DEBUG is not set CONFIG_FAT_FS=m CONFIG_MSDOS_FS=m # CONFIG_UMSDOS_FS is not set @@ -588,6 +589,7 @@ # CONFIG_RAMFS is not set CONFIG_ISO9660_FS=y # CONFIG_JOLIET is not set +# CONFIG_ZISOFS is not set # CONFIG_MINIX_FS is not set # CONFIG_VXFS_FS is not set # CONFIG_NTFS_FS is not set @@ -612,6 +614,7 @@ # Network File Systems # # CONFIG_CODA_FS is not set +# CONFIG_INTERMEZZO_FS is not set # CONFIG_NFS_FS is not set # CONFIG_NFS_V3 is not set # CONFIG_ROOT_NFS is not set @@ -629,6 +632,8 @@ # CONFIG_NCPFS_SMALLDOS is not set # CONFIG_NCPFS_NLS is not set # CONFIG_NCPFS_EXTRAS is not set +# CONFIG_ZISOFS_FS is not set +# CONFIG_ZLIB_FS_INFLATE is not set # # Partition Types @@ -677,7 +682,7 @@ # CONFIG_NLS_CODEPAGE_874 is not set # CONFIG_NLS_ISO8859_8 is not set # CONFIG_NLS_CODEPAGE_1251 is not set -# CONFIG_NLS_ISO8859_1 is not set +CONFIG_NLS_ISO8859_1=m # CONFIG_NLS_ISO8859_2 is not set # CONFIG_NLS_ISO8859_3 is not set # CONFIG_NLS_ISO8859_4 is not set diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/ppc/configs/pmac_defconfig linux-2.5/arch/ppc/configs/pmac_defconfig --- linux-2.5.1/arch/ppc/configs/pmac_defconfig Thu Jan 1 00:00:00 1970 +++ linux-2.5/arch/ppc/configs/pmac_defconfig Thu Dec 27 16:32:30 2001 @@ -0,0 +1,1076 @@ +# +# Automatically generated make config: don't edit +# +# CONFIG_UID16 is not set +# CONFIG_RWSEM_GENERIC_SPINLOCK is not set +CONFIG_RWSEM_XCHGADD_ALGORITHM=y +CONFIG_HAVE_DEC_LOCK=y + +# +# Code maturity level options +# +CONFIG_EXPERIMENTAL=y + +# +# Loadable module support +# +CONFIG_MODULES=y +CONFIG_MODVERSIONS=y +CONFIG_KMOD=y + +# +# Platform support +# +CONFIG_PPC=y +CONFIG_PPC32=y +CONFIG_6xx=y +# CONFIG_4xx is not set +# CONFIG_POWER3 is not set +# CONFIG_POWER4 is not set +# CONFIG_8xx is not set +# CONFIG_8260 is not set +CONFIG_PPC_STD_MMU=y +CONFIG_ALL_PPC=y +# CONFIG_APUS is not set +# CONFIG_GEMINI is not set +# CONFIG_SMP is not set +CONFIG_ALTIVEC=y +CONFIG_TAU=y +# CONFIG_TAU_INT is not set +# CONFIG_TAU_AVERAGE is not set + +# +# General setup +# +# CONFIG_HIGHMEM is not set +# CONFIG_ISA is not set +# CONFIG_EISA is not set +# CONFIG_SBUS is not set +# CONFIG_MCA is not set +CONFIG_PCI=y +CONFIG_NET=y +CONFIG_SYSCTL=y +CONFIG_SYSVIPC=y +# CONFIG_BSD_PROCESS_ACCT is not set +CONFIG_KCORE_ELF=y +CONFIG_BINFMT_ELF=y +CONFIG_KERNEL_ELF=y +CONFIG_BINFMT_MISC=m +CONFIG_PCI_NAMES=y +CONFIG_HOTPLUG=y + +# +# PCMCIA/CardBus support +# +CONFIG_PCMCIA=m +CONFIG_CARDBUS=y +CONFIG_I82092=y +CONFIG_I82365=y +CONFIG_TCIC=y + +# +# Parallel port support +# +# CONFIG_PARPORT is not set +CONFIG_PPC_RTC=y +CONFIG_PPC601_SYNC_FIX=y +CONFIG_PROC_DEVICETREE=y +CONFIG_PPC_RTAS=y +CONFIG_BOOTX_TEXT=y +# CONFIG_PREP_RESIDUAL is not set +# CONFIG_CMDLINE_BOOL is not set + +# +# Memory Technology Devices (MTD) +# +# CONFIG_MTD is not set + +# +# Plug and Play configuration +# +# CONFIG_PNP is not set +# CONFIG_ISAPNP is not set + +# +# Block devices +# +CONFIG_BLK_DEV_FD=m +# CONFIG_BLK_DEV_XD is not set +# CONFIG_PARIDE is not set +# CONFIG_BLK_CPQ_DA is not set +# CONFIG_BLK_CPQ_CISS_DA is not set +# CONFIG_BLK_DEV_DAC960 is not set +CONFIG_BLK_DEV_LOOP=y +# CONFIG_BLK_DEV_NBD is not set +CONFIG_BLK_DEV_RAM=y +CONFIG_BLK_DEV_RAM_SIZE=4096 +CONFIG_BLK_DEV_INITRD=y + +# +# Multi-device support (RAID and LVM) +# +# CONFIG_MD is not set +# CONFIG_BLK_DEV_MD is not set +# CONFIG_MD_LINEAR is not set +# CONFIG_MD_RAID0 is not set +# CONFIG_MD_RAID1 is not set +# CONFIG_MD_RAID5 is not set +# CONFIG_MD_MULTIPATH is not set +# CONFIG_BLK_DEV_LVM is not set + +# +# Networking options +# +CONFIG_PACKET=y +# CONFIG_PACKET_MMAP is not set +# CONFIG_NETLINK_DEV is not set +CONFIG_NETFILTER=y +# CONFIG_NETFILTER_DEBUG is not set +CONFIG_FILTER=y +CONFIG_UNIX=y +CONFIG_INET=y +CONFIG_IP_MULTICAST=y +# CONFIG_IP_ADVANCED_ROUTER is not set +# CONFIG_IP_PNP is not set +# CONFIG_NET_IPIP is not set +# CONFIG_NET_IPGRE is not set +# CONFIG_IP_MROUTE is not set +# CONFIG_ARPD is not set +# CONFIG_INET_ECN is not set +CONFIG_SYN_COOKIES=y + +# +# IP: Netfilter Configuration +# +CONFIG_IP_NF_CONNTRACK=m +CONFIG_IP_NF_FTP=m +CONFIG_IP_NF_IRC=m +# CONFIG_IP_NF_QUEUE is not set +CONFIG_IP_NF_IPTABLES=m +CONFIG_IP_NF_MATCH_LIMIT=m +CONFIG_IP_NF_MATCH_MAC=m +CONFIG_IP_NF_MATCH_MARK=m +CONFIG_IP_NF_MATCH_MULTIPORT=m +CONFIG_IP_NF_MATCH_TOS=m +CONFIG_IP_NF_MATCH_LENGTH=m +CONFIG_IP_NF_MATCH_TTL=m +CONFIG_IP_NF_MATCH_TCPMSS=m +CONFIG_IP_NF_MATCH_STATE=m +CONFIG_IP_NF_MATCH_UNCLEAN=m +CONFIG_IP_NF_MATCH_OWNER=m +CONFIG_IP_NF_FILTER=m +CONFIG_IP_NF_TARGET_REJECT=m +CONFIG_IP_NF_TARGET_MIRROR=m +CONFIG_IP_NF_NAT=m +CONFIG_IP_NF_NAT_NEEDED=y +CONFIG_IP_NF_TARGET_MASQUERADE=m +CONFIG_IP_NF_TARGET_REDIRECT=m +CONFIG_IP_NF_NAT_SNMP_BASIC=m +CONFIG_IP_NF_NAT_IRC=m +CONFIG_IP_NF_NAT_FTP=m +# CONFIG_IP_NF_MANGLE is not set +# CONFIG_IP_NF_TARGET_LOG is not set +CONFIG_IP_NF_TARGET_TCPMSS=m +CONFIG_IP_NF_COMPAT_IPCHAINS=m +CONFIG_IP_NF_NAT_NEEDED=y +# CONFIG_IP_NF_COMPAT_IPFWADM is not set +# CONFIG_IPV6 is not set +# CONFIG_KHTTPD is not set +# CONFIG_ATM is not set +# CONFIG_VLAN_8021Q is not set + +# +# +# +# CONFIG_IPX is not set +CONFIG_ATALK=m +# CONFIG_DECNET is not set +# CONFIG_BRIDGE is not set +# CONFIG_X25 is not set +# CONFIG_LAPB is not set +# CONFIG_LLC is not set +# CONFIG_NET_DIVERT is not set +# CONFIG_ECONET is not set +# CONFIG_WAN_ROUTER is not set +# CONFIG_NET_FASTROUTE is not set +# CONFIG_NET_HW_FLOWCONTROL is not set + +# +# QoS and/or fair queueing +# +# CONFIG_NET_SCHED is not set + +# +# ATA/IDE/MFM/RLL support +# +CONFIG_IDE=y + +# +# IDE, ATA and ATAPI Block devices +# +CONFIG_BLK_DEV_IDE=y + +# +# Please see Documentation/ide.txt for help/info on IDE drives +# +# CONFIG_BLK_DEV_HD_IDE is not set +# CONFIG_BLK_DEV_HD is not set +CONFIG_BLK_DEV_IDEDISK=y +# CONFIG_IDEDISK_MULTI_MODE is not set +# CONFIG_BLK_DEV_IDEDISK_VENDOR is not set +# CONFIG_BLK_DEV_IDEDISK_FUJITSU is not set +# CONFIG_BLK_DEV_IDEDISK_IBM is not set +# CONFIG_BLK_DEV_IDEDISK_MAXTOR is not set +# CONFIG_BLK_DEV_IDEDISK_QUANTUM is not set +# CONFIG_BLK_DEV_IDEDISK_SEAGATE is not set +# CONFIG_BLK_DEV_IDEDISK_WD is not set +# CONFIG_BLK_DEV_COMMERIAL is not set +# CONFIG_BLK_DEV_TIVO is not set +CONFIG_BLK_DEV_IDECS=m +CONFIG_BLK_DEV_IDECD=y +# CONFIG_BLK_DEV_IDETAPE is not set +CONFIG_BLK_DEV_IDEFLOPPY=y +CONFIG_BLK_DEV_IDESCSI=y + +# +# IDE chipset support/bugfixes +# +# CONFIG_BLK_DEV_CMD640 is not set +# CONFIG_BLK_DEV_CMD640_ENHANCED is not set +# CONFIG_BLK_DEV_ISAPNP is not set +# CONFIG_BLK_DEV_RZ1000 is not set +CONFIG_BLK_DEV_IDEPCI=y +CONFIG_IDEPCI_SHARE_IRQ=y +CONFIG_BLK_DEV_IDEDMA_PCI=y +CONFIG_BLK_DEV_ADMA=y +# CONFIG_BLK_DEV_OFFBOARD is not set +CONFIG_IDEDMA_PCI_AUTO=y +CONFIG_BLK_DEV_IDEDMA=y +# CONFIG_IDEDMA_PCI_WIP is not set +# CONFIG_IDEDMA_NEW_DRIVE_LISTINGS is not set +# CONFIG_BLK_DEV_AEC62XX is not set +# CONFIG_AEC62XX_TUNING is not set +# CONFIG_BLK_DEV_ALI15X3 is not set +# CONFIG_WDC_ALI15X3 is not set +# CONFIG_BLK_DEV_AMD74XX is not set +# CONFIG_AMD74XX_OVERRIDE is not set +CONFIG_BLK_DEV_CMD64X=y +# CONFIG_BLK_DEV_CY82C693 is not set +# CONFIG_BLK_DEV_CS5530 is not set +# CONFIG_BLK_DEV_HPT34X is not set +# CONFIG_HPT34X_AUTODMA is not set +# CONFIG_BLK_DEV_HPT366 is not set +# CONFIG_BLK_DEV_NS87415 is not set +# CONFIG_BLK_DEV_OPTI621 is not set +# CONFIG_BLK_DEV_PDC202XX is not set +# CONFIG_PDC202XX_BURST is not set +# CONFIG_PDC202XX_FORCE is not set +# CONFIG_BLK_DEV_SVWKS is not set +# CONFIG_BLK_DEV_SIS5513 is not set +# CONFIG_BLK_DEV_SLC90E66 is not set +# CONFIG_BLK_DEV_TRM290 is not set +# CONFIG_BLK_DEV_VIA82CXXX is not set +CONFIG_BLK_DEV_SL82C105=y +CONFIG_BLK_DEV_IDE_PMAC=y +CONFIG_BLK_DEV_IDEDMA_PMAC=y +CONFIG_BLK_DEV_IDEDMA_PMAC_AUTO=y +CONFIG_BLK_DEV_IDEDMA=y +CONFIG_BLK_DEV_IDEPCI=y +# CONFIG_IDE_CHIPSETS is not set +CONFIG_IDEDMA_AUTO=y +# CONFIG_IDEDMA_IVB is not set +# CONFIG_DMA_NONPCI is not set +CONFIG_BLK_DEV_IDE_MODES=y +# CONFIG_BLK_DEV_ATARAID is not set +# CONFIG_BLK_DEV_ATARAID_PDC is not set +# CONFIG_BLK_DEV_ATARAID_HPT is not set + +# +# SCSI support +# +CONFIG_SCSI=y + +# +# SCSI support type (disk, tape, CD-ROM) +# +CONFIG_BLK_DEV_SD=y +CONFIG_SD_EXTRA_DEVS=40 +CONFIG_CHR_DEV_ST=y +# CONFIG_CHR_DEV_OSST is not set +CONFIG_BLK_DEV_SR=y +CONFIG_BLK_DEV_SR_VENDOR=y +CONFIG_SR_EXTRA_DEVS=2 +CONFIG_CHR_DEV_SG=y + +# +# Some SCSI devices (e.g. CD jukebox) support multiple LUNs +# +# CONFIG_SCSI_DEBUG_QUEUES is not set +# CONFIG_SCSI_MULTI_LUN is not set +CONFIG_SCSI_CONSTANTS=y +# CONFIG_SCSI_LOGGING is not set + +# +# SCSI low-level drivers +# +# CONFIG_BLK_DEV_3W_XXXX_RAID is not set +# CONFIG_SCSI_7000FASST is not set +# CONFIG_SCSI_ACARD is not set +# CONFIG_SCSI_AHA152X is not set +# CONFIG_SCSI_AHA1542 is not set +# CONFIG_SCSI_AHA1740 is not set +CONFIG_SCSI_AIC7XXX=m +CONFIG_AIC7XXX_CMDS_PER_DEVICE=253 +CONFIG_AIC7XXX_RESET_DELAY_MS=15000 +# CONFIG_AIC7XXX_BUILD_FIRMWARE is not set +CONFIG_SCSI_AIC7XXX_OLD=m +# CONFIG_AIC7XXX_OLD_TCQ_ON_BY_DEFAULT is not set +CONFIG_AIC7XXX_OLD_CMDS_PER_DEVICE=8 +CONFIG_AIC7XXX_OLD_PROC_STATS=y +# CONFIG_SCSI_DPT_I2O is not set +CONFIG_SCSI_ADVANSYS=m +# CONFIG_SCSI_IN2000 is not set +# CONFIG_SCSI_AM53C974 is not set +# CONFIG_SCSI_MEGARAID is not set +# CONFIG_SCSI_BUSLOGIC is not set +# CONFIG_SCSI_CPQFCTS is not set +# CONFIG_SCSI_DMX3191D is not set +# CONFIG_SCSI_DTC3280 is not set +# CONFIG_SCSI_EATA is not set +# CONFIG_SCSI_EATA_DMA is not set +# CONFIG_SCSI_EATA_PIO is not set +# CONFIG_SCSI_FUTURE_DOMAIN is not set +# CONFIG_SCSI_GDTH is not set +# CONFIG_SCSI_GENERIC_NCR5380 is not set +# CONFIG_SCSI_INITIO is not set +# CONFIG_SCSI_INIA100 is not set +# CONFIG_SCSI_NCR53C406A is not set +# CONFIG_SCSI_NCR53C7xx is not set +CONFIG_SCSI_SYM53C8XX_2=y +CONFIG_SCSI_SYM53C8XX_DMA_ADDRESSING_MODE=0 +CONFIG_SCSI_SYM53C8XX_DEFAULT_TAGS=16 +CONFIG_SCSI_SYM53C8XX_MAX_TAGS=64 +# CONFIG_SCSI_SYM53C8XX_IOMAPPED is not set +# CONFIG_SCSI_PAS16 is not set +# CONFIG_SCSI_PCI2000 is not set +# CONFIG_SCSI_PCI2220I is not set +# CONFIG_SCSI_PSI240I is not set +# CONFIG_SCSI_QLOGIC_FAS is not set +# CONFIG_SCSI_QLOGIC_ISP is not set +# CONFIG_SCSI_QLOGIC_FC is not set +# CONFIG_SCSI_QLOGIC_1280 is not set +# CONFIG_SCSI_SIM710 is not set +# CONFIG_SCSI_SYM53C416 is not set +# CONFIG_SCSI_DC390T is not set +# CONFIG_SCSI_T128 is not set +# CONFIG_SCSI_U14_34F is not set +# CONFIG_SCSI_DEBUG is not set +CONFIG_SCSI_MESH=y +CONFIG_SCSI_MESH_SYNC_RATE=5 +CONFIG_SCSI_MAC53C94=y + +# +# PCMCIA SCSI adapter support +# +# CONFIG_SCSI_PCMCIA is not set + +# +# IEEE 1394 (FireWire) support (EXPERIMENTAL) +# +CONFIG_IEEE1394=m + +# +# Device Drivers +# +CONFIG_IEEE1394_PCILYNX=m +# CONFIG_IEEE1394_PCILYNX_LOCALRAM is not set +# CONFIG_IEEE1394_PCILYNX_PORTS is not set +CONFIG_IEEE1394_OHCI1394=m + +# +# Protocol Drivers +# +CONFIG_IEEE1394_VIDEO1394=m +CONFIG_IEEE1394_SBP2=m +CONFIG_IEEE1394_RAWIO=m +# CONFIG_IEEE1394_VERBOSEDEBUG is not set + +# +# Network device support +# +CONFIG_NETDEVICES=y + +# +# ARCnet devices +# +# CONFIG_ARCNET is not set + +# +# Appletalk devices +# +# CONFIG_LTPC is not set +# CONFIG_COPS is not set +# CONFIG_IPDDP is not set +# CONFIG_DUMMY is not set +# CONFIG_BONDING is not set +# CONFIG_EQUALIZER is not set +# CONFIG_TUN is not set +# CONFIG_ETHERTAP is not set + +# +# Ethernet (10 or 100Mbit) +# +CONFIG_NET_ETHERNET=y +CONFIG_MACE=y +# CONFIG_MACE_AAUI_PORT is not set +CONFIG_BMAC=y +# CONFIG_GMAC is not set +# CONFIG_SUNLANCE is not set +# CONFIG_HAPPYMEAL is not set +# CONFIG_SUNBMAC is not set +# CONFIG_SUNQE is not set +# CONFIG_SUNLANCE is not set +CONFIG_SUNGEM=y +# CONFIG_NET_VENDOR_3COM is not set +# CONFIG_LANCE is not set +# CONFIG_NET_VENDOR_SMC is not set +# CONFIG_NET_VENDOR_RACAL is not set +# CONFIG_HP100 is not set +# CONFIG_NET_ISA is not set +CONFIG_NET_PCI=y +CONFIG_PCNET32=y +# CONFIG_ADAPTEC_STARFIRE is not set +# CONFIG_APRICOT is not set +# CONFIG_CS89x0 is not set +CONFIG_TULIP=y +# CONFIG_TULIP_MWI is not set +CONFIG_TULIP_MMIO=y +CONFIG_DE4X5=m +# CONFIG_DGRS is not set +# CONFIG_DM9102 is not set +# CONFIG_EEPRO100 is not set +# CONFIG_LNE390 is not set +# CONFIG_FEALNX is not set +# CONFIG_NATSEMI is not set +# CONFIG_NE2K_PCI is not set +# CONFIG_NE3210 is not set +# CONFIG_ES3210 is not set +# CONFIG_8139CP is not set +# CONFIG_8139TOO is not set +# CONFIG_8139TOO_PIO is not set +# CONFIG_8139TOO_TUNE_TWISTER is not set +# CONFIG_8139TOO_8129 is not set +# CONFIG_SIS900 is not set +# CONFIG_EPIC100 is not set +# CONFIG_SUNDANCE is not set +# CONFIG_TLAN is not set +# CONFIG_VIA_RHINE is not set +# CONFIG_VIA_RHINE_MMIO is not set +# CONFIG_WINBOND_840 is not set +# CONFIG_NET_POCKET is not set + +# +# Ethernet (1000 Mbit) +# +# CONFIG_ACENIC is not set +# CONFIG_DL2K is not set +# CONFIG_MYRI_SBUS is not set +# CONFIG_NS83820 is not set +# CONFIG_HAMACHI is not set +# CONFIG_YELLOWFIN is not set +# CONFIG_SK98LIN is not set +# CONFIG_FDDI is not set +# CONFIG_HIPPI is not set +# CONFIG_PLIP is not set +CONFIG_PPP=y +CONFIG_PPP_MULTILINK=y +# CONFIG_PPP_FILTER is not set +CONFIG_PPP_ASYNC=y +CONFIG_PPP_SYNC_TTY=m +CONFIG_PPP_DEFLATE=y +CONFIG_PPP_BSDCOMP=m +# CONFIG_PPPOE is not set +# CONFIG_SLIP is not set + +# +# Wireless LAN (non-hamradio) +# +CONFIG_NET_RADIO=y +# CONFIG_STRIP is not set +# CONFIG_WAVELAN is not set +# CONFIG_ARLAN is not set +# CONFIG_AIRONET4500 is not set +# CONFIG_AIRONET4500_NONCS is not set +# CONFIG_AIRONET4500_PROC is not set +# CONFIG_AIRO is not set +CONFIG_HERMES=m +CONFIG_APPLE_AIRPORT=m +# CONFIG_PLX_HERMES is not set + +# +# Wireless Pcmcia cards support +# +CONFIG_PCMCIA_HERMES=m +# CONFIG_AIRO_CS is not set +CONFIG_NET_WIRELESS=y + +# +# Token Ring devices +# +# CONFIG_TR is not set +# CONFIG_NET_FC is not set +# CONFIG_RCPCI is not set +# CONFIG_SHAPER is not set + +# +# Wan interfaces +# +# CONFIG_WAN is not set + +# +# PCMCIA network device support +# +CONFIG_NET_PCMCIA=y +# CONFIG_PCMCIA_3C589 is not set +# CONFIG_PCMCIA_3C574 is not set +# CONFIG_PCMCIA_FMVJ18X is not set +# CONFIG_PCMCIA_PCNET is not set +# CONFIG_PCMCIA_AXNET is not set +# CONFIG_PCMCIA_NMCLAN is not set +# CONFIG_PCMCIA_SMC91C92 is not set +# CONFIG_PCMCIA_XIRC2PS is not set +# CONFIG_ARCNET_COM20020_CS is not set +# CONFIG_PCMCIA_IBMTR is not set +# CONFIG_PCMCIA_XIRCOM is not set +# CONFIG_PCMCIA_XIRTULIP is not set +CONFIG_NET_PCMCIA_RADIO=y +# CONFIG_PCMCIA_RAYCS is not set +# CONFIG_PCMCIA_NETWAVE is not set +# CONFIG_PCMCIA_WAVELAN is not set +# CONFIG_AIRONET4500_CS is not set + +# +# Amateur Radio support +# +# CONFIG_HAMRADIO is not set + +# +# IrDA (infrared) support +# +CONFIG_IRDA=m + +# +# IrDA protocols +# +CONFIG_IRLAN=m +CONFIG_IRNET=m +CONFIG_IRCOMM=m +# CONFIG_IRDA_ULTRA is not set +# CONFIG_IRDA_OPTIONS is not set + +# +# Infrared-port device drivers +# + +# +# SIR device drivers +# +CONFIG_IRTTY_SIR=m +# CONFIG_IRPORT_SIR is not set + +# +# Dongle support +# +# CONFIG_DONGLE is not set + +# +# FIR device drivers +# +# CONFIG_USB_IRDA is not set +# CONFIG_NSC_FIR is not set +# CONFIG_WINBOND_FIR is not set +# CONFIG_TOSHIBA_FIR is not set +# CONFIG_SMC_IRCC_FIR is not set +# CONFIG_ALI_FIR is not set +# CONFIG_VLSI_FIR is not set + +# +# ISDN subsystem +# +# CONFIG_ISDN is not set + +# +# Old CD-ROM drivers (not SCSI, not IDE) +# +# CONFIG_CD_NO_IDESCSI is not set + +# +# Console drivers +# +# CONFIG_VGA_CONSOLE is not set + +# +# Frame-buffer support +# +CONFIG_FB=y +CONFIG_DUMMY_CONSOLE=y +# CONFIG_FB_RIVA is not set +# CONFIG_FB_CLGEN is not set +# CONFIG_FB_PM2 is not set +# CONFIG_FB_CYBER2000 is not set +CONFIG_FB_OF=y +CONFIG_FB_CONTROL=y +CONFIG_FB_PLATINUM=y +CONFIG_FB_VALKYRIE=y +CONFIG_FB_CT65550=y +CONFIG_FB_IMSTT=y +# CONFIG_FB_S3TRIO is not set +# CONFIG_FB_VGA16 is not set +CONFIG_FB_MATROX=y +CONFIG_FB_MATROX_MILLENIUM=y +CONFIG_FB_MATROX_MYSTIQUE=y +# CONFIG_FB_MATROX_G100 is not set +# CONFIG_FB_MATROX_I2C is not set +# CONFIG_FB_MATROX_G450 is not set +# CONFIG_FB_MATROX_MULTIHEAD is not set +CONFIG_FB_ATY=y +CONFIG_FB_ATY_GX=y +CONFIG_FB_ATY_CT=y +CONFIG_FB_RADEON=y +CONFIG_FB_ATY128=y +# CONFIG_FB_SIS is not set +CONFIG_FB_3DFX=y +# CONFIG_FB_VOODOO1 is not set +# CONFIG_FB_VIRTUAL is not set +# CONFIG_FBCON_ADVANCED is not set +CONFIG_FBCON_CFB8=y +CONFIG_FBCON_CFB16=y +CONFIG_FBCON_CFB24=y +CONFIG_FBCON_CFB32=y +# CONFIG_FBCON_FONTWIDTH8_ONLY is not set +CONFIG_FBCON_FONTS=y +# CONFIG_FONT_8x8 is not set +CONFIG_FONT_8x16=y +CONFIG_FONT_SUN8x16=y +CONFIG_FONT_SUN12x22=y +# CONFIG_FONT_6x11 is not set +# CONFIG_FONT_PEARL_8x8 is not set +# CONFIG_FONT_ACORN_8x8 is not set +CONFIG_FB_COMPAT_XPMAC=y + +# +# Input core support +# +CONFIG_INPUT=y +CONFIG_INPUT_KEYBDEV=y +CONFIG_INPUT_MOUSEDEV=y +CONFIG_INPUT_MOUSEDEV_SCREEN_X=1024 +CONFIG_INPUT_MOUSEDEV_SCREEN_Y=768 +# CONFIG_INPUT_JOYDEV is not set +CONFIG_INPUT_EVDEV=y + +# +# Macintosh device drivers +# +CONFIG_ADB_CUDA=y +CONFIG_ADB_PMU=y +CONFIG_PMAC_PBOOK=y +CONFIG_PM=y +CONFIG_PMAC_APM_EMU=y +CONFIG_PMAC_BACKLIGHT=y +CONFIG_MAC_FLOPPY=y +CONFIG_MAC_SERIAL=y +# CONFIG_SERIAL_CONSOLE is not set +CONFIG_ADB=y +CONFIG_ADB_MACIO=y +CONFIG_INPUT_ADBHID=y +CONFIG_MAC_ADBKEYCODES=y +CONFIG_MAC_EMUMOUSEBTN=y +CONFIG_MAC_HID=y +# CONFIG_ANSLCD is not set + +# +# Character devices +# +CONFIG_VT=y +CONFIG_VT_CONSOLE=y +CONFIG_SERIAL=m +# CONFIG_SERIAL_EXTENDED is not set +# CONFIG_SERIAL_NONSTANDARD is not set +CONFIG_UNIX98_PTYS=y +CONFIG_UNIX98_PTY_COUNT=256 + +# +# I2C support +# +CONFIG_I2C=m +# CONFIG_I2C_ALGOBIT is not set +# CONFIG_I2C_ALGOPCF is not set +CONFIG_I2C_KEYWEST=m +CONFIG_I2C_CHARDEV=m +CONFIG_I2C_PROC=m + +# +# Mice +# +CONFIG_BUSMOUSE=y +# CONFIG_ATIXL_BUSMOUSE is not set +# CONFIG_LOGIBUSMOUSE is not set +# CONFIG_MS_BUSMOUSE is not set +CONFIG_MOUSE=y +CONFIG_PSMOUSE=y +# CONFIG_82C710_MOUSE is not set +# CONFIG_PC110_PAD is not set + +# +# Joysticks +# +# CONFIG_INPUT_GAMEPORT is not set +# CONFIG_INPUT_NS558 is not set +# CONFIG_INPUT_LIGHTNING is not set +# CONFIG_INPUT_PCIGAME is not set +# CONFIG_INPUT_CS461X is not set +# CONFIG_INPUT_EMU10K1 is not set +# CONFIG_INPUT_SERIO is not set +# CONFIG_INPUT_SERPORT is not set + +# +# Joysticks +# +# CONFIG_INPUT_ANALOG is not set +# CONFIG_INPUT_A3D is not set +# CONFIG_INPUT_ADI is not set +# CONFIG_INPUT_COBRA is not set +# CONFIG_INPUT_GF2K is not set +# CONFIG_INPUT_GRIP is not set +# CONFIG_INPUT_INTERACT is not set +# CONFIG_INPUT_TMDC is not set +# CONFIG_INPUT_SIDEWINDER is not set +# CONFIG_INPUT_IFORCE_USB is not set +# CONFIG_INPUT_IFORCE_232 is not set +# CONFIG_INPUT_WARRIOR is not set +# CONFIG_INPUT_MAGELLAN is not set +# CONFIG_INPUT_SPACEORB is not set +# CONFIG_INPUT_SPACEBALL is not set +# CONFIG_INPUT_STINGER is not set +# CONFIG_INPUT_DB9 is not set +# CONFIG_INPUT_GAMECON is not set +# CONFIG_INPUT_TURBOGRAFX is not set +# CONFIG_QIC02_TAPE is not set + +# +# Watchdog Cards +# +# CONFIG_WATCHDOG is not set +# CONFIG_INTEL_RNG is not set +CONFIG_NVRAM=y +# CONFIG_RTC is not set +# CONFIG_DTLK is not set +# CONFIG_R3964 is not set +# CONFIG_APPLICOM is not set + +# +# Ftape, the floppy tape device driver +# +# CONFIG_FTAPE is not set +# CONFIG_AGP is not set +# CONFIG_DRM is not set + +# +# PCMCIA character devices +# +# CONFIG_PCMCIA_SERIAL_CS is not set + +# +# Multimedia devices +# +# CONFIG_VIDEO_DEV is not set + +# +# File systems +# +# CONFIG_QUOTA is not set +# CONFIG_AUTOFS_FS is not set +# CONFIG_AUTOFS4_FS is not set +# CONFIG_REISERFS_FS is not set +# CONFIG_REISERFS_CHECK is not set +# CONFIG_REISERFS_PROC_INFO is not set +# CONFIG_ADFS_FS is not set +# CONFIG_ADFS_FS_RW is not set +# CONFIG_AFFS_FS is not set +CONFIG_HFS_FS=m +# CONFIG_BFS_FS is not set +CONFIG_EXT3_FS=y +CONFIG_JBD=y +# CONFIG_JBD_DEBUG is not set +CONFIG_FAT_FS=m +CONFIG_MSDOS_FS=m +# CONFIG_UMSDOS_FS is not set +CONFIG_VFAT_FS=m +# CONFIG_EFS_FS is not set +# CONFIG_JFFS_FS is not set +# CONFIG_JFFS2_FS is not set +# CONFIG_CRAMFS is not set +CONFIG_TMPFS=y +# CONFIG_RAMFS is not set +CONFIG_ISO9660_FS=y +# CONFIG_JOLIET is not set +# CONFIG_ZISOFS is not set +# CONFIG_MINIX_FS is not set +# CONFIG_VXFS_FS is not set +# CONFIG_NTFS_FS is not set +# CONFIG_NTFS_RW is not set +# CONFIG_HPFS_FS is not set +CONFIG_PROC_FS=y +CONFIG_DEVFS_FS=y +# CONFIG_DEVFS_MOUNT is not set +# CONFIG_DEVFS_DEBUG is not set +CONFIG_DEVPTS_FS=y +# CONFIG_QNX4FS_FS is not set +# CONFIG_QNX4FS_RW is not set +# CONFIG_ROMFS_FS is not set +CONFIG_EXT2_FS=y +# CONFIG_SYSV_FS is not set +# CONFIG_UDF_FS is not set +# CONFIG_UDF_RW is not set +# CONFIG_UFS_FS is not set +# CONFIG_UFS_FS_WRITE is not set + +# +# Network File Systems +# +# CONFIG_CODA_FS is not set +# CONFIG_INTERMEZZO_FS is not set +CONFIG_NFS_FS=y +# CONFIG_NFS_V3 is not set +# CONFIG_ROOT_NFS is not set +CONFIG_NFSD=y +# CONFIG_NFSD_V3 is not set +CONFIG_SUNRPC=y +CONFIG_LOCKD=y +CONFIG_SMB_FS=m +# CONFIG_SMB_NLS_DEFAULT is not set +# CONFIG_NCP_FS is not set +# CONFIG_NCPFS_PACKET_SIGNING is not set +# CONFIG_NCPFS_IOCTL_LOCKING is not set +# CONFIG_NCPFS_STRONG is not set +# CONFIG_NCPFS_NFS_NS is not set +# CONFIG_NCPFS_OS2_NS is not set +# CONFIG_NCPFS_SMALLDOS is not set +# CONFIG_NCPFS_NLS is not set +# CONFIG_NCPFS_EXTRAS is not set +# CONFIG_ZISOFS_FS is not set +# CONFIG_ZLIB_FS_INFLATE is not set + +# +# Partition Types +# +CONFIG_PARTITION_ADVANCED=y +# CONFIG_ACORN_PARTITION is not set +# CONFIG_OSF_PARTITION is not set +# CONFIG_AMIGA_PARTITION is not set +# CONFIG_ATARI_PARTITION is not set +CONFIG_MAC_PARTITION=y +CONFIG_MSDOS_PARTITION=y +# CONFIG_BSD_DISKLABEL is not set +# CONFIG_MINIX_SUBPARTITION is not set +# CONFIG_SOLARIS_X86_PARTITION is not set +# CONFIG_UNIXWARE_DISKLABEL is not set +# CONFIG_LDM_PARTITION is not set +# CONFIG_SGI_PARTITION is not set +# CONFIG_ULTRIX_PARTITION is not set +# CONFIG_SUN_PARTITION is not set +CONFIG_SMB_NLS=y +CONFIG_NLS=y + +# +# Native Language Support +# +CONFIG_NLS_DEFAULT="iso8859-1" +# CONFIG_NLS_CODEPAGE_437 is not set +# CONFIG_NLS_CODEPAGE_737 is not set +# CONFIG_NLS_CODEPAGE_775 is not set +# CONFIG_NLS_CODEPAGE_850 is not set +# CONFIG_NLS_CODEPAGE_852 is not set +# CONFIG_NLS_CODEPAGE_855 is not set +# CONFIG_NLS_CODEPAGE_857 is not set +# CONFIG_NLS_CODEPAGE_860 is not set +# CONFIG_NLS_CODEPAGE_861 is not set +# CONFIG_NLS_CODEPAGE_862 is not set +# CONFIG_NLS_CODEPAGE_863 is not set +# CONFIG_NLS_CODEPAGE_864 is not set +# CONFIG_NLS_CODEPAGE_865 is not set +# CONFIG_NLS_CODEPAGE_866 is not set +# CONFIG_NLS_CODEPAGE_869 is not set +# CONFIG_NLS_CODEPAGE_936 is not set +# CONFIG_NLS_CODEPAGE_950 is not set +# CONFIG_NLS_CODEPAGE_932 is not set +# CONFIG_NLS_CODEPAGE_949 is not set +# CONFIG_NLS_CODEPAGE_874 is not set +# CONFIG_NLS_ISO8859_8 is not set +# CONFIG_NLS_CODEPAGE_1251 is not set +CONFIG_NLS_ISO8859_1=m +# CONFIG_NLS_ISO8859_2 is not set +# CONFIG_NLS_ISO8859_3 is not set +# CONFIG_NLS_ISO8859_4 is not set +# CONFIG_NLS_ISO8859_5 is not set +# CONFIG_NLS_ISO8859_6 is not set +# CONFIG_NLS_ISO8859_7 is not set +# CONFIG_NLS_ISO8859_9 is not set +# CONFIG_NLS_ISO8859_13 is not set +# CONFIG_NLS_ISO8859_14 is not set +# CONFIG_NLS_ISO8859_15 is not set +# CONFIG_NLS_KOI8_R is not set +# CONFIG_NLS_KOI8_U is not set +# CONFIG_NLS_UTF8 is not set + +# +# Sound +# +CONFIG_SOUND=m +CONFIG_DMASOUND_PMAC=m +CONFIG_DMASOUND=m +CONFIG_I2C=m +CONFIG_I2C_KEYWEST=m +# CONFIG_SOUND_BT878 is not set +# CONFIG_SOUND_CMPCI is not set +# CONFIG_SOUND_EMU10K1 is not set +# CONFIG_MIDI_EMU10K1 is not set +# CONFIG_SOUND_FUSION is not set +# CONFIG_SOUND_CS4281 is not set +# CONFIG_SOUND_ES1370 is not set +# CONFIG_SOUND_ES1371 is not set +# CONFIG_SOUND_ESSSOLO1 is not set +# CONFIG_SOUND_MAESTRO is not set +# CONFIG_SOUND_MAESTRO3 is not set +# CONFIG_SOUND_ICH is not set +# CONFIG_SOUND_RME96XX is not set +# CONFIG_SOUND_SONICVIBES is not set +# CONFIG_SOUND_TRIDENT is not set +# CONFIG_SOUND_MSNDCLAS is not set +# CONFIG_SOUND_MSNDPIN is not set +# CONFIG_SOUND_VIA82CXXX is not set +# CONFIG_MIDI_VIA82CXXX is not set +# CONFIG_SOUND_OSS is not set +# CONFIG_SOUND_TVMIXER is not set + +# +# USB support +# +CONFIG_USB=y +# CONFIG_USB_DEBUG is not set + +# +# Miscellaneous USB options +# +CONFIG_USB_DEVICEFS=y +# CONFIG_USB_BANDWIDTH is not set +# CONFIG_USB_LONG_TIMEOUT is not set + +# +# USB Controllers +# +# CONFIG_USB_UHCI is not set +# CONFIG_USB_UHCI_ALT is not set +CONFIG_USB_OHCI=y + +# +# USB Device Class drivers +# +# CONFIG_USB_AUDIO is not set +# CONFIG_USB_BLUETOOTH is not set +# CONFIG_USB_STORAGE is not set +# CONFIG_USB_STORAGE_DEBUG is not set +# CONFIG_USB_STORAGE_DATAFAB is not set +# CONFIG_USB_STORAGE_FREECOM is not set +# CONFIG_USB_STORAGE_ISD200 is not set +# CONFIG_USB_STORAGE_DPCM is not set +# CONFIG_USB_STORAGE_HP8200e is not set +# CONFIG_USB_STORAGE_SDDR09 is not set +# CONFIG_USB_STORAGE_JUMPSHOT is not set +CONFIG_USB_ACM=m +CONFIG_USB_PRINTER=m + +# +# USB Human Interface Devices (HID) +# +CONFIG_USB_HID=y +# CONFIG_USB_HIDDEV is not set +# CONFIG_USB_WACOM is not set + +# +# USB Imaging devices +# +# CONFIG_USB_DC2XX is not set +# CONFIG_USB_MDC800 is not set +CONFIG_USB_SCANNER=m +# CONFIG_USB_MICROTEK is not set +# CONFIG_USB_HPUSBSCSI is not set + +# +# USB Multimedia devices +# + +# +# Video4Linux support is needed for USB Multimedia device support +# + +# +# USB Network adaptors +# +# CONFIG_USB_PEGASUS is not set +# CONFIG_USB_KAWETH is not set +# CONFIG_USB_CATC is not set +# CONFIG_USB_CDCETHER is not set +# CONFIG_USB_USBNET is not set + +# +# USB port drivers +# +# CONFIG_USB_USS720 is not set + +# +# USB Serial Converter support +# +CONFIG_USB_SERIAL=m +# CONFIG_USB_SERIAL_GENERIC is not set +# CONFIG_USB_SERIAL_BELKIN is not set +# CONFIG_USB_SERIAL_WHITEHEAT is not set +# CONFIG_USB_SERIAL_DIGI_ACCELEPORT is not set +# CONFIG_USB_SERIAL_EMPEG is not set +# CONFIG_USB_SERIAL_FTDI_SIO is not set +CONFIG_USB_SERIAL_VISOR=m +# CONFIG_USB_SERIAL_IR is not set +# CONFIG_USB_SERIAL_EDGEPORT is not set +# CONFIG_USB_SERIAL_KEYSPAN_PDA is not set +# CONFIG_USB_SERIAL_KEYSPAN is not set +# CONFIG_USB_SERIAL_KEYSPAN_USA28 is not set +# CONFIG_USB_SERIAL_KEYSPAN_USA28X is not set +# CONFIG_USB_SERIAL_KEYSPAN_USA28XA is not set +# CONFIG_USB_SERIAL_KEYSPAN_USA28XB is not set +# CONFIG_USB_SERIAL_KEYSPAN_USA19 is not set +# CONFIG_USB_SERIAL_KEYSPAN_USA18X is not set +# CONFIG_USB_SERIAL_KEYSPAN_USA19W is not set +# CONFIG_USB_SERIAL_KEYSPAN_USA49W is not set +# CONFIG_USB_SERIAL_MCT_U232 is not set +# CONFIG_USB_SERIAL_PL2303 is not set +# CONFIG_USB_SERIAL_CYBERJACK is not set +# CONFIG_USB_SERIAL_XIRCOM is not set +# CONFIG_USB_SERIAL_OMNINET is not set + +# +# USB Miscellaneous drivers +# +# CONFIG_USB_RIO500 is not set + +# +# Bluetooth support +# +# CONFIG_BLUEZ is not set + +# +# Kernel hacking +# +CONFIG_MAGIC_SYSRQ=y +# CONFIG_KGDB is not set +CONFIG_XMON=y diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/ppc/configs/power3_defconfig linux-2.5/arch/ppc/configs/power3_defconfig --- linux-2.5.1/arch/ppc/configs/power3_defconfig Sat Nov 3 01:43:54 2001 +++ linux-2.5/arch/ppc/configs/power3_defconfig Thu Dec 27 16:32:30 2001 @@ -4,6 +4,7 @@ # CONFIG_UID16 is not set # CONFIG_RWSEM_GENERIC_SPINLOCK is not set CONFIG_RWSEM_XCHGADD_ALGORITHM=y +CONFIG_HAVE_DEC_LOCK=y # # Code maturity level options @@ -66,6 +67,7 @@ # CONFIG_PARPORT_AMIGA is not set # CONFIG_PARPORT_MFC3 is not set # CONFIG_PARPORT_ATARI is not set +# CONFIG_PARPORT_GSC is not set # CONFIG_PARPORT_SUNBPP is not set # CONFIG_PARPORT_OTHER is not set # CONFIG_PARPORT_1284 is not set @@ -119,8 +121,6 @@ # CONFIG_PACKET=y # CONFIG_PACKET_MMAP is not set -CONFIG_NETLINK=y -# CONFIG_RTNETLINK is not set # CONFIG_NETLINK_DEV is not set # CONFIG_NETFILTER is not set # CONFIG_FILTER is not set @@ -132,6 +132,7 @@ # CONFIG_NET_IPIP is not set # CONFIG_NET_IPGRE is not set # CONFIG_IP_MROUTE is not set +# CONFIG_ARPD is not set # CONFIG_INET_ECN is not set CONFIG_SYN_COOKIES=y # CONFIG_IPV6 is not set @@ -224,15 +225,11 @@ # CONFIG_SCSI_IMM is not set # CONFIG_SCSI_NCR53C406A is not set # CONFIG_SCSI_NCR53C7xx is not set -# CONFIG_SCSI_NCR53C8XX is not set -CONFIG_SCSI_SYM53C8XX=y -CONFIG_SCSI_NCR53C8XX_DEFAULT_TAGS=8 -CONFIG_SCSI_NCR53C8XX_MAX_TAGS=32 -CONFIG_SCSI_NCR53C8XX_SYNC=20 -# CONFIG_SCSI_NCR53C8XX_PROFILE is not set -# CONFIG_SCSI_NCR53C8XX_IOMAPPED is not set -# CONFIG_SCSI_NCR53C8XX_PQS_PDS is not set -# CONFIG_SCSI_NCR53C8XX_SYMBIOS_COMPAT is not set +CONFIG_SCSI_SYM53C8XX_2=y +CONFIG_SCSI_SYM53C8XX_DMA_ADDRESSING_MODE=0 +CONFIG_SCSI_SYM53C8XX_DEFAULT_TAGS=16 +CONFIG_SCSI_SYM53C8XX_MAX_TAGS=64 +# CONFIG_SCSI_SYM53C8XX_IOMAPPED is not set # CONFIG_SCSI_PAS16 is not set # CONFIG_SCSI_PCI2000 is not set # CONFIG_SCSI_PCI2220I is not set @@ -315,6 +312,7 @@ # CONFIG_SUNDANCE is not set # CONFIG_TLAN is not set # CONFIG_VIA_RHINE is not set +# CONFIG_VIA_RHINE_MMIO is not set # CONFIG_WINBOND_840 is not set # CONFIG_NET_POCKET is not set @@ -474,6 +472,7 @@ # CONFIG_I2C_VELLEMAN is not set CONFIG_I2C_ALGOPCF=y # CONFIG_I2C_ELEKTOR is not set +# CONFIG_I2C_KEYWEST is not set CONFIG_I2C_CHARDEV=y # CONFIG_I2C_PROC is not set @@ -553,11 +552,15 @@ # CONFIG_AUTOFS4_FS is not set # CONFIG_REISERFS_FS is not set # CONFIG_REISERFS_CHECK is not set +# CONFIG_REISERFS_PROC_INFO is not set # CONFIG_ADFS_FS is not set # CONFIG_ADFS_FS_RW is not set # CONFIG_AFFS_FS is not set # CONFIG_HFS_FS is not set # CONFIG_BFS_FS is not set +# CONFIG_EXT3_FS is not set +# CONFIG_JBD is not set +# CONFIG_JBD_DEBUG is not set CONFIG_FAT_FS=y CONFIG_MSDOS_FS=y # CONFIG_UMSDOS_FS is not set @@ -570,6 +573,7 @@ # CONFIG_RAMFS is not set CONFIG_ISO9660_FS=y CONFIG_JOLIET=y +# CONFIG_ZISOFS is not set # CONFIG_MINIX_FS is not set # CONFIG_VXFS_FS is not set # CONFIG_NTFS_FS is not set @@ -594,6 +598,7 @@ # Network File Systems # # CONFIG_CODA_FS is not set +# CONFIG_INTERMEZZO_FS is not set CONFIG_NFS_FS=y # CONFIG_NFS_V3 is not set # CONFIG_ROOT_NFS is not set @@ -611,6 +616,8 @@ # CONFIG_NCPFS_SMALLDOS is not set # CONFIG_NCPFS_NLS is not set # CONFIG_NCPFS_EXTRAS is not set +# CONFIG_ZISOFS_FS is not set +# CONFIG_ZLIB_FS_INFLATE is not set # # Partition Types @@ -665,7 +672,7 @@ # Sound # CONFIG_SOUND=y -# CONFIG_DMASOUND_AWACS is not set +# CONFIG_DMASOUND_PMAC is not set # CONFIG_SOUND_BT878 is not set # CONFIG_SOUND_CMPCI is not set # CONFIG_SOUND_EMU10K1 is not set diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/ppc/defconfig linux-2.5/arch/ppc/defconfig --- linux-2.5.1/arch/ppc/defconfig Sat Nov 3 01:43:54 2001 +++ linux-2.5/arch/ppc/defconfig Thu Dec 27 16:32:30 2001 @@ -4,6 +4,7 @@ # CONFIG_UID16 is not set # CONFIG_RWSEM_GENERIC_SPINLOCK is not set CONFIG_RWSEM_XCHGADD_ALGORITHM=y +CONFIG_HAVE_DEC_LOCK=y # # Code maturity level options @@ -119,8 +120,6 @@ # CONFIG_PACKET=y # CONFIG_PACKET_MMAP is not set -CONFIG_NETLINK=y -# CONFIG_RTNETLINK is not set # CONFIG_NETLINK_DEV is not set CONFIG_NETFILTER=y # CONFIG_NETFILTER_DEBUG is not set @@ -133,6 +132,7 @@ # CONFIG_NET_IPIP is not set # CONFIG_NET_IPGRE is not set # CONFIG_IP_MROUTE is not set +# CONFIG_ARPD is not set # CONFIG_INET_ECN is not set CONFIG_SYN_COOKIES=y @@ -343,15 +343,11 @@ # CONFIG_SCSI_INIA100 is not set # CONFIG_SCSI_NCR53C406A is not set # CONFIG_SCSI_NCR53C7xx is not set -CONFIG_SCSI_NCR53C8XX=y -CONFIG_SCSI_SYM53C8XX=y -CONFIG_SCSI_NCR53C8XX_DEFAULT_TAGS=8 -CONFIG_SCSI_NCR53C8XX_MAX_TAGS=32 -CONFIG_SCSI_NCR53C8XX_SYNC=20 -# CONFIG_SCSI_NCR53C8XX_PROFILE is not set -# CONFIG_SCSI_NCR53C8XX_IOMAPPED is not set -# CONFIG_SCSI_NCR53C8XX_PQS_PDS is not set -# CONFIG_SCSI_NCR53C8XX_SYMBIOS_COMPAT is not set +CONFIG_SCSI_SYM53C8XX_2=y +CONFIG_SCSI_SYM53C8XX_DMA_ADDRESSING_MODE=0 +CONFIG_SCSI_SYM53C8XX_DEFAULT_TAGS=16 +CONFIG_SCSI_SYM53C8XX_MAX_TAGS=64 +# CONFIG_SCSI_SYM53C8XX_IOMAPPED is not set # CONFIG_SCSI_PAS16 is not set # CONFIG_SCSI_PCI2000 is not set # CONFIG_SCSI_PCI2220I is not set @@ -388,7 +384,9 @@ # # Appletalk devices # -# CONFIG_APPLETALK is not set +# CONFIG_LTPC is not set +# CONFIG_COPS is not set +# CONFIG_IPDDP is not set # CONFIG_DUMMY is not set # CONFIG_BONDING is not set # CONFIG_EQUALIZER is not set @@ -443,6 +441,7 @@ # CONFIG_SUNDANCE is not set # CONFIG_TLAN is not set # CONFIG_VIA_RHINE is not set +# CONFIG_VIA_RHINE_MMIO is not set # CONFIG_WINBOND_840 is not set # CONFIG_NET_POCKET is not set @@ -544,6 +543,7 @@ CONFIG_FB_MATROX_MILLENIUM=y CONFIG_FB_MATROX_MYSTIQUE=y # CONFIG_FB_MATROX_G100 is not set +# CONFIG_FB_MATROX_I2C is not set # CONFIG_FB_MATROX_G450 is not set # CONFIG_FB_MATROX_MULTIHEAD is not set CONFIG_FB_ATY=y @@ -597,6 +597,7 @@ CONFIG_MAC_ADBKEYCODES=y CONFIG_MAC_EMUMOUSEBTN=y CONFIG_MAC_HID=y +# CONFIG_ANSLCD is not set # # Character devices @@ -612,7 +613,12 @@ # # I2C support # -# CONFIG_I2C is not set +CONFIG_I2C=m +# CONFIG_I2C_ALGOBIT is not set +# CONFIG_I2C_ALGOPCF is not set +CONFIG_I2C_KEYWEST=m +CONFIG_I2C_CHARDEV=m +CONFIG_I2C_PROC=m # # Mice @@ -693,11 +699,15 @@ # CONFIG_AUTOFS4_FS is not set # CONFIG_REISERFS_FS is not set # CONFIG_REISERFS_CHECK is not set +# CONFIG_REISERFS_PROC_INFO is not set # CONFIG_ADFS_FS is not set # CONFIG_ADFS_FS_RW is not set # CONFIG_AFFS_FS is not set CONFIG_HFS_FS=m # CONFIG_BFS_FS is not set +# CONFIG_EXT3_FS is not set +# CONFIG_JBD is not set +# CONFIG_JBD_DEBUG is not set CONFIG_FAT_FS=m CONFIG_MSDOS_FS=m # CONFIG_UMSDOS_FS is not set @@ -710,6 +720,7 @@ # CONFIG_RAMFS is not set CONFIG_ISO9660_FS=y # CONFIG_JOLIET is not set +# CONFIG_ZISOFS is not set # CONFIG_MINIX_FS is not set # CONFIG_VXFS_FS is not set # CONFIG_NTFS_FS is not set @@ -734,6 +745,7 @@ # Network File Systems # # CONFIG_CODA_FS is not set +# CONFIG_INTERMEZZO_FS is not set CONFIG_NFS_FS=y # CONFIG_NFS_V3 is not set # CONFIG_ROOT_NFS is not set @@ -751,6 +763,8 @@ # CONFIG_NCPFS_SMALLDOS is not set # CONFIG_NCPFS_NLS is not set # CONFIG_NCPFS_EXTRAS is not set +# CONFIG_ZISOFS_FS is not set +# CONFIG_ZLIB_FS_INFLATE is not set # # Partition Types @@ -818,8 +832,10 @@ # Sound # CONFIG_SOUND=m -CONFIG_DMASOUND_AWACS=m +CONFIG_DMASOUND_PMAC=m CONFIG_DMASOUND=m +CONFIG_I2C=m +CONFIG_I2C_KEYWEST=m # CONFIG_SOUND_BT878 is not set # CONFIG_SOUND_CMPCI is not set # CONFIG_SOUND_EMU10K1 is not set @@ -854,7 +870,6 @@ CONFIG_USB_DEVICEFS=y # CONFIG_USB_BANDWIDTH is not set # CONFIG_USB_LONG_TIMEOUT is not set -# CONFIG_USB_LARGE_CONFIG is not set # # USB Controllers diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/ppc/kernel/Makefile linux-2.5/arch/ppc/kernel/Makefile --- linux-2.5.1/arch/ppc/kernel/Makefile Sat Nov 3 01:43:54 2001 +++ linux-2.5/arch/ppc/kernel/Makefile Thu Dec 27 16:32:30 2001 @@ -1,4 +1,4 @@ -# BK Id: SCCS/s.Makefile 1.34 10/16/01 15:58:42 trini +# BK Id: SCCS/s.Makefile 1.36 12/01/01 20:09:06 benh # # # Makefile for the linux kernel. @@ -56,7 +56,7 @@ obj-$(CONFIG_PCI) += apus_pci.o endif obj-$(CONFIG_ALL_PPC) += pmac_pic.o pmac_setup.o pmac_time.o prom.o \ - feature.o pmac_pci.o chrp_setup.o \ + pmac_feature.o pmac_pci.o chrp_setup.o \ chrp_time.o chrp_pci.o open_pic.o \ indirect_pci.o i8259.o prep_pci.o \ prep_time.o prep_nvram.o prep_setup.o diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/ppc/kernel/btext.c linux-2.5/arch/ppc/kernel/btext.c --- linux-2.5.1/arch/ppc/kernel/btext.c Sat Sep 8 19:38:41 2001 +++ linux-2.5/arch/ppc/kernel/btext.c Thu Dec 27 16:32:30 2001 @@ -133,14 +133,19 @@ { unsigned long offset = reloc_offset(); boot_infos_t* bi = PTRRELOC(RELOC(disp_bi)); - unsigned long addr = (unsigned long)bi->dispDeviceBase; unsigned long vaddr = KERNELBASE + 0x10000000; + unsigned long addr; unsigned long lowbits; if (!RELOC(disp_bi)) { RELOC(boot_text_mapped) = 0; return; } + addr = (unsigned long)bi->dispDeviceBase; + if (!addr) { + RELOC(boot_text_mapped) = 0; + return; + } if (PVR_VER(mfspr(PVR)) != 1) { /* 603, 604, G3, G4, ... */ lowbits = addr & ~0xFF000000UL; @@ -231,10 +236,10 @@ { if (disp_bi == 0) return; - /* check it's the same frame buffer (within 64MB) */ - if ((phys ^ (unsigned long)disp_bi->dispDeviceBase) & 0xfc000000) { + + /* check it's the same frame buffer (within 256MB) */ + if ((phys ^ (unsigned long)disp_bi->dispDeviceBase) & 0xf0000000) return; - } disp_bi->dispDeviceBase = (__u8 *) phys; disp_bi->dispDeviceRect[0] = 0; @@ -423,9 +428,11 @@ int rb = bi->dispDeviceRowBytes; switch(bi->dispDeviceDepth) { + case 24: case 32: draw_byte_32(font, (unsigned long *)base, rb); break; + case 15: case 16: draw_byte_16(font, (unsigned long *)base, rb); break; diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/ppc/kernel/chrp_setup.c linux-2.5/arch/ppc/kernel/chrp_setup.c --- linux-2.5.1/arch/ppc/kernel/chrp_setup.c Fri Nov 16 18:10:08 2001 +++ linux-2.5/arch/ppc/kernel/chrp_setup.c Thu Dec 27 16:32:30 2001 @@ -1,5 +1,5 @@ /* - * BK Id: SCCS/s.chrp_setup.c 1.38 11/13/01 21:26:07 paulus + * BK Id: SCCS/s.chrp_setup.c 1.40 12/19/01 09:45:54 trini */ /* * linux/arch/ppc/kernel/setup.c @@ -374,7 +374,7 @@ openpic_init(1, NUM_8259_INTERRUPTS, chrp_int_ack_special, nmi_irq); for ( i = 0 ; i < NUM_8259_INTERRUPTS ; i++ ) irq_desc[i].handler = &i8259_pic; - i8259_init(); + i8259_init(NULL); #if defined(CONFIG_VT) && defined(CONFIG_ADB_KEYBOARD) && defined(XMON) /* see if there is a keyboard in the device tree with a parent of type "adb" */ diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/ppc/kernel/chrp_smp.c linux-2.5/arch/ppc/kernel/chrp_smp.c --- linux-2.5.1/arch/ppc/kernel/chrp_smp.c Sat Sep 8 19:38:41 2001 +++ linux-2.5/arch/ppc/kernel/chrp_smp.c Thu Dec 27 16:32:30 2001 @@ -36,7 +36,6 @@ #include <asm/prom.h> #include <asm/smp.h> #include <asm/residual.h> -#include <asm/feature.h> #include <asm/time.h> #include "open_pic.h" diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/ppc/kernel/cputable.c linux-2.5/arch/ppc/kernel/cputable.c --- linux-2.5.1/arch/ppc/kernel/cputable.c Mon Oct 8 18:40:13 2001 +++ linux-2.5/arch/ppc/kernel/cputable.c Thu Dec 27 16:32:30 2001 @@ -26,6 +26,7 @@ extern void __setup_cpu_604(int cpu_nr); extern void __setup_cpu_750(int cpu_nr); extern void __setup_cpu_7400(int cpu_nr); +extern void __setup_cpu_7410(int cpu_nr); extern void __setup_cpu_7450(int cpu_nr); extern void __setup_cpu_power3(int cpu_nr); extern void __setup_cpu_power4(int cpu_nr); @@ -113,14 +114,22 @@ 32, 32, __setup_cpu_604 }, - { /* 750 (0x4202, don't support TAU ?) */ - 0xffffffff, 0x00084202, "750", + { /* 740/750 (0x4202, don't support TAU ?) */ + 0xffffffff, 0x00084202, "740/750", CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_CAN_DOZE | CPU_FTR_USE_TB | CPU_FTR_L2CR | CPU_FTR_HPTE_TABLE, COMMON_PPC, 32, 32, __setup_cpu_750 }, + { /* 745/755 */ + 0xfffff000, 0x00083000, "745/755", + CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_CAN_DOZE | CPU_FTR_USE_TB | + CPU_FTR_L2CR | CPU_FTR_TAU | CPU_FTR_HPTE_TABLE, + COMMON_PPC, + 32, 32, + __setup_cpu_750 + }, { /* 750CX */ 0xffffff00, 0x00082200, "750CX", CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_CAN_DOZE | CPU_FTR_USE_TB | @@ -159,9 +168,18 @@ CPU_FTR_L2CR | CPU_FTR_TAU | CPU_FTR_ALTIVEC_COMP | CPU_FTR_HPTE_TABLE, COMMON_PPC | PPC_FEATURE_HAS_ALTIVEC, 32, 32, - __setup_cpu_7400 + __setup_cpu_7410 + }, + { /* 7450 2.0 - no doze/nap */ + 0xffffffff, 0x80000200, "7450", + CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_USE_TB | + CPU_FTR_L2CR | CPU_FTR_TAU | CPU_FTR_ALTIVEC_COMP | + CPU_FTR_HPTE_TABLE | CPU_FTR_SPEC7450, + COMMON_PPC | PPC_FEATURE_HAS_ALTIVEC, + 32, 32, + __setup_cpu_7450 }, - { /* 7450 */ + { /* 7450 others */ 0xffff0000, 0x80000000, "7450", CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_CAN_DOZE | CPU_FTR_USE_TB | CPU_FTR_L2CR | CPU_FTR_TAU | CPU_FTR_ALTIVEC_COMP | diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/ppc/kernel/head.S linux-2.5/arch/ppc/kernel/head.S --- linux-2.5.1/arch/ppc/kernel/head.S Sat Nov 3 01:43:54 2001 +++ linux-2.5/arch/ppc/kernel/head.S Thu Dec 27 16:32:30 2001 @@ -1,5 +1,5 @@ /* - * BK Id: SCCS/s.head.S 1.31 10/18/01 15:02:09 trini + * BK Id: SCCS/s.head.S 1.34 12/02/01 11:35:27 benh */ /* * PowerPC version @@ -1347,7 +1347,19 @@ bl setup_750_7400_hid0 mtlr r4 blr +_GLOBAL(__setup_cpu_7410) + mflr r4 + bl setup_common_caches + bl setup_750_7400_hid0 + li r3,0 + mtspr SPRN_L2CR2,r3 + mtlr r4 + blr _GLOBAL(__setup_cpu_7450) + mflr r4 + bl setup_common_caches + bl setup_7450_hid0 + mtlr r4 blr _GLOBAL(__setup_cpu_power3) blr @@ -1400,6 +1412,47 @@ li r3,HID0_SPD andc r11,r11,r3 /* clear SPD: enable speculative */ li r3,0 + mtspr ICTC,r3 /* Instruction Cache Throttling off */ + isync + mtspr HID0,r11 + sync + isync + blr + +/* 7450 + * Enable Store Gathering (SGE), Branch Folding (FOLD) + * Branch History Table (BHTE), Branch Target ICache (BTIC) + * Dynamic Power Management (DPM), Speculative (SPD) + * Ensure our data cache instructions really operate. + * Timebase has to be running or we wouldn't have made it here, + * just ensure we don't disable it. + * Clear Instruction cache throttling (ICTC) + */ +setup_7450_hid0: + /* We check for the presence of an L3 cache setup by + * the firmware. If any, we disable DOZE capability + */ + mfspr r11,SPRN_L3CR + andis. r11,r11,L3CR_L3E@h + beq 1f + li r7,CPU_FTR_CAN_DOZE + lwz r6,CPU_SPEC_FEATURES(r5) + andc r6,r6,r7 + stw r6,CPU_SPEC_FEATURES(r5) +1: + mfspr r11,HID0 + + /* All of the bits we have to set..... + */ + ori r11,r11,HID0_SGE | HID0_FOLD | HID0_BHTE | HID0_BTIC + oris r11,r11,HID0_DPM@h /* enable dynamic power mgmt */ + + /* All of the bits we have to clear.... + */ + li r3,HID0_SPD | HID0_NOPDST | HID0_NOPTI + andc r11,r11,r3 /* clear SPD: enable speculative */ + li r3,0 + mtspr ICTC,r3 /* Instruction Cache Throttling off */ isync mtspr HID0,r11 diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/ppc/kernel/i8259.c linux-2.5/arch/ppc/kernel/i8259.c --- linux-2.5.1/arch/ppc/kernel/i8259.c Mon Dec 10 21:52:53 2001 +++ linux-2.5/arch/ppc/kernel/i8259.c Thu Dec 27 16:32:30 2001 @@ -1,14 +1,18 @@ /* - * BK Id: SCCS/s.i8259.c 1.7 05/17/01 18:14:21 cort + * BK Id: SCCS/s.i8259.c 1.11 12/19/01 09:45:54 trini */ #include <linux/stddef.h> #include <linux/init.h> +#include <linux/irq.h> +#include <linux/ioport.h> #include <linux/sched.h> #include <linux/signal.h> #include <asm/io.h> #include "i8259.h" +static volatile char *pci_intack; /* RO, gives us the irq vector */ + unsigned char cached_8259[2] = { 0xff, 0xff }; #define cached_A1 (cached_8259[0]) #define cached_21 (cached_8259[1]) @@ -17,32 +21,56 @@ int i8259_pic_irq_offset; -int i8259_irq(int cpu) +/* Acknowledge the irq using the PCI host bridge's interrupt acknowledge + * feature. (Polling is somehow broken on some IBM and Motorola PReP boxes.) + */ +int i8259_irq(void) +{ + int irq; + + spin_lock/*_irqsave*/(&i8259_lock/*, flags*/); + + irq = *pci_intack & 0xff; + if (irq==7) { + /* + * This may be a spurious interrupt. + * + * Read the interrupt status register (ISR). If the most + * significant bit is not set then there is no valid + * interrupt. + */ + if(~inb(0x20)&0x80) { + irq = -1; + } + } + spin_unlock/*_irqrestore*/(&i8259_lock/*, flags*/); + return irq; +} + +/* Poke the 8259's directly using poll commands. */ +int i8259_poll(void) { int irq; - + spin_lock/*_irqsave*/(&i8259_lock/*, flags*/); - /* - * Perform an interrupt acknowledge cycle on controller 1 - */ - outb(0x0C, 0x20); - irq = inb(0x20) & 7; - if (irq == 2) - { - /* - * Interrupt is cascaded so perform interrupt - * acknowledge on controller 2 - */ - outb(0x0C, 0xA0); - irq = (inb(0xA0) & 7) + 8; - } - else if (irq==7) - { - /* - * This may be a spurious interrupt - * - * Read the interrupt status register. If the most - * significant bit is not set then there is no valid + /* + * Perform an interrupt acknowledge cycle on controller 1 + */ + outb(0x0C, 0x20); /* prepare for poll */ + irq = inb(0x20) & 7; + if (irq == 2) { + /* + * Interrupt is cascaded so perform interrupt + * acknowledge on controller 2 + */ + outb(0x0C, 0xA0); /* prepare for poll */ + irq = (inb(0xA0) & 7) + 8; + } else if (irq==7) { + /* + * This may be a spurious interrupt + * + * Read the interrupt status register. If the most + * significant bit is not set then there is no valid * interrupt */ outb(0x0b, 0x20); @@ -58,44 +86,44 @@ static void i8259_mask_and_ack_irq(unsigned int irq_nr) { unsigned long flags; - + spin_lock_irqsave(&i8259_lock, flags); - if ( irq_nr >= i8259_pic_irq_offset ) - irq_nr -= i8259_pic_irq_offset; + if ( irq_nr >= i8259_pic_irq_offset ) + irq_nr -= i8259_pic_irq_offset; - if (irq_nr > 7) { - cached_A1 |= 1 << (irq_nr-8); - inb(0xA1); /* DUMMY */ - outb(cached_A1,0xA1); - outb(0x20,0xA0); /* Non-specific EOI */ - outb(0x20,0x20); /* Non-specific EOI to cascade */ - } else { - cached_21 |= 1 << irq_nr; - inb(0x21); /* DUMMY */ - outb(cached_21,0x21); - outb(0x20,0x20); /* Non-specific EOI */ - } + if (irq_nr > 7) { + cached_A1 |= 1 << (irq_nr-8); + inb(0xA1); /* DUMMY */ + outb(cached_A1,0xA1); + outb(0x20,0xA0); /* Non-specific EOI */ + outb(0x20,0x20); /* Non-specific EOI to cascade */ + } else { + cached_21 |= 1 << irq_nr; + inb(0x21); /* DUMMY */ + outb(cached_21,0x21); + outb(0x20,0x20); /* Non-specific EOI */ + } spin_unlock_irqrestore(&i8259_lock, flags); } static void i8259_set_irq_mask(int irq_nr) { - outb(cached_A1,0xA1); - outb(cached_21,0x21); + outb(cached_A1,0xA1); + outb(cached_21,0x21); } - + static void i8259_mask_irq(unsigned int irq_nr) { unsigned long flags; spin_lock_irqsave(&i8259_lock, flags); - if ( irq_nr >= i8259_pic_irq_offset ) - irq_nr -= i8259_pic_irq_offset; - if ( irq_nr < 8 ) - cached_21 |= 1 << irq_nr; - else - cached_A1 |= 1 << (irq_nr-8); - i8259_set_irq_mask(irq_nr); + if ( irq_nr >= i8259_pic_irq_offset ) + irq_nr -= i8259_pic_irq_offset; + if ( irq_nr < 8 ) + cached_21 |= 1 << irq_nr; + else + cached_A1 |= 1 << (irq_nr-8); + i8259_set_irq_mask(irq_nr); spin_unlock_irqrestore(&i8259_lock, flags); } @@ -104,13 +132,13 @@ unsigned long flags; spin_lock_irqsave(&i8259_lock, flags); - if ( irq_nr >= i8259_pic_irq_offset ) - irq_nr -= i8259_pic_irq_offset; - if ( irq_nr < 8 ) - cached_21 &= ~(1 << irq_nr); - else - cached_A1 &= ~(1 << (irq_nr-8)); - i8259_set_irq_mask(irq_nr); + if ( irq_nr >= i8259_pic_irq_offset ) + irq_nr -= i8259_pic_irq_offset; + if ( irq_nr < 8 ) + cached_21 &= ~(1 << irq_nr); + else + cached_A1 &= ~(1 << (irq_nr-8)); + i8259_set_irq_mask(irq_nr); spin_unlock_irqrestore(&i8259_lock, flags); } @@ -121,36 +149,62 @@ } struct hw_interrupt_type i8259_pic = { - " i8259 ", - NULL, - NULL, - i8259_unmask_irq, - i8259_mask_irq, - i8259_mask_and_ack_irq, - i8259_end_irq, - NULL + " i8259 ", + NULL, + NULL, + i8259_unmask_irq, + i8259_mask_irq, + i8259_mask_and_ack_irq, + i8259_end_irq, + NULL +}; + +static struct resource pic1_iores = { + "8259 (master)", 0x20, 0x21, IORESOURCE_BUSY }; -void __init i8259_init(void) +static struct resource pic2_iores = { + "8259 (slave)", 0xa0, 0xa1, IORESOURCE_BUSY +}; + +static struct resource pic_edgectrl_iores = { + "8259 edge control", 0x4d0, 0x4d1, IORESOURCE_BUSY +}; + +void __init i8259_init(long intack_addr) { unsigned long flags; - + spin_lock_irqsave(&i8259_lock, flags); - /* init master interrupt controller */ - outb(0x11, 0x20); /* Start init sequence */ - outb(0x00, 0x21); /* Vector base */ - outb(0x04, 0x21); /* edge tiggered, Cascade (slave) on IRQ2 */ - outb(0x01, 0x21); /* Select 8086 mode */ - outb(0xFF, 0x21); /* Mask all */ - /* init slave interrupt controller */ - outb(0x11, 0xA0); /* Start init sequence */ - outb(0x08, 0xA1); /* Vector base */ - outb(0x02, 0xA1); /* edge triggered, Cascade (slave) on IRQ2 */ - outb(0x01, 0xA1); /* Select 8086 mode */ - outb(0xFF, 0xA1); /* Mask all */ - outb(cached_A1, 0xA1); - outb(cached_21, 0x21); + /* init master interrupt controller */ + outb(0x11, 0x20); /* Start init sequence */ + outb(0x00, 0x21); /* Vector base */ + outb(0x04, 0x21); /* edge tiggered, Cascade (slave) on IRQ2 */ + outb(0x01, 0x21); /* Select 8086 mode */ + + /* init slave interrupt controller */ + outb(0x11, 0xA0); /* Start init sequence */ + outb(0x08, 0xA1); /* Vector base */ + outb(0x02, 0xA1); /* edge triggered, Cascade (slave) on IRQ2 */ + outb(0x01, 0xA1); /* Select 8086 mode */ + + /* always read ISR */ + outb(0x0B, 0x20); + outb(0x0B, 0xA0); + + /* Mask all interrupts */ + outb(cached_A1, 0xA1); + outb(cached_21, 0x21); + spin_unlock_irqrestore(&i8259_lock, flags); - request_irq( i8259_pic_irq_offset + 2, no_action, SA_INTERRUPT, - "82c59 secondary cascade", NULL ); + + /* reserve our resources */ + request_irq( i8259_pic_irq_offset + 2, no_action, SA_INTERRUPT, + "82c59 secondary cascade", NULL ); + request_resource(&ioport_resource, &pic1_iores); + request_resource(&ioport_resource, &pic2_iores); + request_resource(&ioport_resource, &pic_edgectrl_iores); + + if (intack_addr) + pci_intack = ioremap(intack_addr, 1); } diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/ppc/kernel/i8259.h linux-2.5/arch/ppc/kernel/i8259.h --- linux-2.5.1/arch/ppc/kernel/i8259.h Tue May 22 00:04:47 2001 +++ linux-2.5/arch/ppc/kernel/i8259.h Thu Dec 27 16:32:30 2001 @@ -1,5 +1,5 @@ /* - * BK Id: SCCS/s.i8259.h 1.5 05/17/01 18:14:21 cort + * BK Id: SCCS/s.i8259.h 1.8 12/19/01 09:45:54 trini */ #ifndef _PPC_KERNEL_i8259_H @@ -9,7 +9,8 @@ extern struct hw_interrupt_type i8259_pic; -void i8259_init(void); -int i8259_irq(int); +void i8259_init(long); +int i8259_irq(void); +int i8259_poll(void); #endif /* _PPC_KERNEL_i8259_H */ diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/ppc/kernel/idle.c linux-2.5/arch/ppc/kernel/idle.c --- linux-2.5.1/arch/ppc/kernel/idle.c Sat Nov 3 01:43:54 2001 +++ linux-2.5/arch/ppc/kernel/idle.c Thu Dec 27 22:10:28 2001 @@ -1,5 +1,5 @@ /* - * BK Id: SCCS/s.idle.c 1.16 10/16/01 15:58:42 trini + * BK Id: SCCS/s.idle.c 1.18 12/01/01 20:09:06 benh */ /* * Idle daemon for PowerPC. Idle daemon will handle any action @@ -54,11 +54,9 @@ /* endless loop with no priority at all */ current->nice = 20; - current->counter = -100; init_idle(); for (;;) { #ifdef CONFIG_SMP - if (!do_power_save) { /* * Deal with another CPU just having chosen a thread to @@ -231,6 +229,13 @@ void power_save(void) { unsigned long hid0; + int nap = powersave_nap; + + /* 7450 has no DOZE mode mode, we return if powersave_nap + * isn't enabled + */ + if (!nap && cur_cpu_spec[smp_processor_id()]->cpu_features & CPU_FTR_SPEC7450) + return; /* * Disable interrupts to prevent a lost wakeup * when going to sleep. This is necessary even with diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/ppc/kernel/irq.c linux-2.5/arch/ppc/kernel/irq.c --- linux-2.5.1/arch/ppc/kernel/irq.c Wed Nov 28 21:22:26 2001 +++ linux-2.5/arch/ppc/kernel/irq.c Thu Dec 27 16:32:30 2001 @@ -1,5 +1,5 @@ /* - * BK Id: SCCS/s.irq.c 1.32 08/24/01 20:07:37 paulus + * BK Id: SCCS/s.irq.c 1.34 12/01/01 20:09:06 benh */ /* * arch/ppc/kernel/irq.c @@ -538,21 +538,29 @@ int do_IRQ(struct pt_regs *regs) { int cpu = smp_processor_id(); - int irq; - hardirq_enter(cpu); + int irq, first = 1; + hardirq_enter( cpu ); - /* every arch is required to have a get_irq -- Cort */ - irq = ppc_md.get_irq(regs); + for (;;) { + /* + * Every arch is required to implement ppc_md.get_irq. + * This function will either return an irq number or -1 to + * indicate there are no more pending. But the first time + * through the loop this means there wasn't and IRQ pending. + * The value -2 is for buggy hardware and means that this IRQ + * has already been handled. -- Tom + */ + irq = ppc_md.get_irq( regs ); - if (irq >= 0) { - ppc_irq_dispatch_handler( regs, irq ); - } else if (irq != -2) { - /* -2 means ignore, already handled */ - if (ppc_spurious_interrupts < 10) - printk(KERN_DEBUG "Bogus interrupt %d from PC = %lx\n", - irq, regs->nip); - /* That's not SMP safe ... but who cares ? */ - ppc_spurious_interrupts++; + if (irq >= 0) + ppc_irq_dispatch_handler( regs, irq ); + else { + if (irq != -2 && first) + /* That's not SMP safe ... but who cares ? */ + ppc_spurious_interrupts++; + break; + } + first = 0; } hardirq_exit( cpu ); diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/ppc/kernel/l2cr.S linux-2.5/arch/ppc/kernel/l2cr.S --- linux-2.5.1/arch/ppc/kernel/l2cr.S Tue Aug 28 13:58:33 2001 +++ linux-2.5/arch/ppc/kernel/l2cr.S Thu Dec 27 16:32:30 2001 @@ -30,6 +30,12 @@ *********** Thu, July 13, 2000. - Terry: Added isync to correct for an errata. + + 22 August 2001. + - DanM: Finally added the 7450 patch I've had for the past + several months. The L2CR is similar, but I'm going + to assume the user of this functions knows what they + are doing. Author: Terry Greeniaus (tgree@phys.ualberta.ca) Please e-mail updates to this file to me, thanks! @@ -71,6 +77,15 @@ features, such as L2DO which caches only data, or L2TS which causes cache pushes from the L1 cache to go to the L2 cache instead of to main memory. + +IMPORTANT: + Starting with the 7450, the bits in this register have moved + or behave differently. The Enable, Parity Enable, Size, + and L2 Invalidate are the only bits that have not moved. + The size is read-only for these processors with internal L2 + cache, and the invalidate is a control as well as status. + -- Dan + */ /* * Summary: this procedure ignores the L2I bit in the value passed in, @@ -115,6 +130,8 @@ /**** Might be a good idea to set L2DO here - to prevent instructions from getting into the cache. But since we invalidate the next time we enable the cache it doesn't really matter. + Don't do this unless you accomodate all processor variations. + The bit moved on the 7450..... ****/ lis r4,0x0002 @@ -159,12 +176,21 @@ sync isync /* For errata */ +BEGIN_FTR_SECTION + /* On the 7450, we wait for the L2I bit to clear...... + */ +10: mfspr r3,L2CR + andis. r4,r3,0x0020 + bne 10b + b 11f +END_FTR_SECTION_IFSET(CPU_FTR_SPEC7450) + /* Wait for the invalidation to complete */ 3: mfspr r3,L2CR rlwinm. r4,r3,0,31,31 bne 3b - rlwinm r3,r3,0,11,9 /* Turn off the L2I bit */ +11: rlwinm r3,r3,0,11,9 /* Turn off the L2I bit */ sync mtspr L2CR,r3 sync diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/ppc/kernel/m8xx_setup.c linux-2.5/arch/ppc/kernel/m8xx_setup.c --- linux-2.5.1/arch/ppc/kernel/m8xx_setup.c Fri Nov 16 18:10:08 2001 +++ linux-2.5/arch/ppc/kernel/m8xx_setup.c Thu Dec 20 19:14:29 2001 @@ -55,12 +55,6 @@ extern void m8xx_ide_init(void); -#ifdef CONFIG_BLK_DEV_RAM -extern int rd_doload; /* 1 = load ramdisk, 0 = don't load */ -extern int rd_prompt; /* 1 = prompt for ramdisk, 0 = don't prompt */ -extern int rd_image_start; /* starting block # of image */ -#endif - extern unsigned long find_available_memory(void); extern void m8xx_cpm_reset(uint); diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/ppc/kernel/misc.S linux-2.5/arch/ppc/kernel/misc.S --- linux-2.5.1/arch/ppc/kernel/misc.S Sat Nov 3 01:43:54 2001 +++ linux-2.5/arch/ppc/kernel/misc.S Thu Dec 27 16:32:30 2001 @@ -1,5 +1,5 @@ /* - * BK Id: SCCS/s.misc.S 1.32 10/18/01 17:29:53 trini + * BK Id: SCCS/s.misc.S 1.36 12/01/01 20:09:06 benh */ /* * This file contains miscellaneous low-level functions. @@ -128,6 +128,9 @@ /* * call_setup_cpu - call the setup_cpu function for this cpu * r3 = data offset, r24 = cpu number + * + * Don't change register layout, the setup function may rely + * on r5 containing a relocated pointer to the current cpu spec. */ _GLOBAL(call_setup_cpu) addis r5,r3,cur_cpu_spec@ha @@ -866,10 +869,8 @@ sc cmpi 0,r3,0 /* parent or child? */ bnelr /* return if parent */ - li r0,0 /* clear out p->thread.regs */ - stw r0,THREAD+PT_REGS(r2) /* since we don't have user ctx */ - addi r1,r2,TASK_UNION_SIZE-STACK_FRAME_OVERHEAD - stw r0,0(r1) + li r0,0 /* make top-level stack frame */ + stwu r0,-16(r1) mtlr r6 /* fn addr in lr */ mr r3,r4 /* load arg and call fn */ blrl diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/ppc/kernel/open_pic.c linux-2.5/arch/ppc/kernel/open_pic.c --- linux-2.5.1/arch/ppc/kernel/open_pic.c Sat Nov 3 01:43:54 2001 +++ linux-2.5/arch/ppc/kernel/open_pic.c Thu Dec 27 16:32:30 2001 @@ -1,5 +1,5 @@ /* - * BK Id: SCCS/s.open_pic.c 1.31 10/11/01 12:09:11 trini + * BK Id: SCCS/s.open_pic.c 1.33 12/19/01 09:45:54 trini */ /* * arch/ppc/kernel/open_pic.c -- OpenPIC Interrupt Handling @@ -28,6 +28,7 @@ #include "local_irq.h" #include "open_pic.h" #include "open_pic_defs.h" +#include "i8259.h" void* OpenPIC_Addr; static volatile struct OpenPIC *OpenPIC = NULL; @@ -784,9 +785,6 @@ /* * Clean up needed. -VAL */ -#ifndef CONFIG_GEMINI - extern int i8259_irq(int cpu); -#endif int irq = openpic_irq(); /* Management of the cascade should be moved out of here */ @@ -801,7 +799,7 @@ irq = *chrp_int_ack_special; #ifndef CONFIG_GEMINI else - irq = i8259_irq( smp_processor_id() ); + irq = i8259_poll(); #endif openpic_eoi(); } diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/ppc/kernel/pci.c linux-2.5/arch/ppc/kernel/pci.c --- linux-2.5.1/arch/ppc/kernel/pci.c Fri Nov 16 18:10:08 2001 +++ linux-2.5/arch/ppc/kernel/pci.c Thu Dec 27 16:32:30 2001 @@ -1,5 +1,5 @@ /* - * BK Id: SCCS/s.pci.c 1.35 11/13/01 08:19:57 trini + * BK Id: SCCS/s.pci.c 1.38 12/11/01 14:57:05 benh */ /* * Common pmac/prep/chrp pci routines. -- Cort @@ -19,6 +19,7 @@ #include <asm/processor.h> #include <asm/io.h> #include <asm/prom.h> +#include <asm/sections.h> #include <asm/pci-bridge.h> #include <asm/residual.h> #include <asm/byteorder.h> @@ -66,7 +67,7 @@ { PCI_FIXUP_HEADER, PCI_ANY_ID, PCI_ANY_ID, pcibios_fixup_resources }, #ifdef CONFIG_ALL_PPC /* We should add per-machine fixup support in xxx_setup.c or xxx_pci.c */ - { PCI_FIXUP_FINAL, PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_1211, pcibios_fixup_cardbus }, + { PCI_FIXUP_FINAL, PCI_VENDOR_ID_TI, PCI_ANY_ID, pcibios_fixup_cardbus }, #endif /* CONFIG_ALL_PPC */ { 0 } }; @@ -175,18 +176,25 @@ static void pcibios_fixup_cardbus(struct pci_dev* dev) { + if (_machine != _MACH_Pmac) + return; /* * Fix the interrupt routing on the TI1211 chip on the 1999 * G3 powerbook, which doesn't get initialized properly by OF. + * Same problem with the 1410 of the new titanium pbook which + * has the same register. */ if (dev->vendor == PCI_VENDOR_ID_TI - && dev->device == PCI_DEVICE_ID_TI_1211) { - u32 val; + && (dev->device == PCI_DEVICE_ID_TI_1211 || + dev->device == PCI_DEVICE_ID_TI_1410)) { + u8 val; /* 0x8c == TI122X_IRQMUX, 2 says to route the INTA signal out the MFUNC0 pin */ - if (pci_read_config_dword(dev, 0x8c, &val) == 0 - && val == 0) - pci_write_config_dword(dev, 0x8c, 2); + if (pci_read_config_byte(dev, 0x8c, &val) == 0) + pci_write_config_byte(dev, 0x8c, (val & ~0x0f) | 2); + /* Disable ISA interrupt mode */ + if (pci_read_config_byte(dev, 0x92, &val) == 0) + pci_write_config_byte(dev, 0x92, val & ~0x06); } } #endif /* CONFIG_ALL_PPC */ @@ -438,7 +446,7 @@ /* * Functions below are used on OpenFirmware machines. */ -static void +static void __openfirmware make_one_node_map(struct device_node* node, u8 pci_bus) { int *bus_range; @@ -472,7 +480,7 @@ } } -void +void __openfirmware pcibios_make_OF_bus_map(void) { int i; @@ -512,17 +520,17 @@ #endif } -static struct device_node* -scan_OF_childs_for_device(struct device_node* node, u8 bus, u8 dev_fn) +typedef int (*pci_OF_scan_iterator)(struct device_node* node, void* data); + +static struct device_node* __openfirmware +scan_OF_pci_childs(struct device_node* node, pci_OF_scan_iterator filter, void* data) { struct device_node* sub_node; for (; node != 0;node = node->sibling) { - unsigned int *class_code, *reg; + unsigned int *class_code; - reg = (unsigned int *) get_property(node, "reg", 0); - if (reg && ((reg[0] >> 8) & 0xff) == dev_fn - && ((reg[0] >> 16) & 0xff) == bus) + if (filter(node, data)) return node; /* For PCI<->PCI bridges or CardBus bridges, we go down @@ -535,13 +543,34 @@ (*class_code >> 8) != PCI_CLASS_BRIDGE_CARDBUS)) && strcmp(node->name, "multifunc-device")) continue; - sub_node = scan_OF_childs_for_device(node->child, bus, dev_fn); + sub_node = scan_OF_pci_childs(node->child, filter, data); if (sub_node) return sub_node; } return NULL; } +static int +scan_OF_pci_childs_iterator(struct device_node* node, void* data) +{ + unsigned int *reg; + u8* fdata = (u8*)data; + + reg = (unsigned int *) get_property(node, "reg", 0); + if (reg && ((reg[0] >> 8) & 0xff) == fdata[1] + && ((reg[0] >> 16) & 0xff) == fdata[0]) + return 1; + return 0; +} + +static struct device_node* __openfirmware +scan_OF_childs_for_device(struct device_node* node, u8 bus, u8 dev_fn) +{ + u8 filter_data[2] = {bus, dev_fn}; + + return scan_OF_pci_childs(node, scan_OF_pci_childs_iterator, filter_data); +} + /* * Scans the OF tree for a device node matching a PCI device */ @@ -598,6 +627,12 @@ return NULL; } +static int __openfirmware +find_OF_pci_device_filter(struct device_node* node, void* data) +{ + return ((void *)node == data); +} + /* * Returns the PCI device matching a given OF node */ @@ -605,21 +640,40 @@ pci_device_from_OF_node(struct device_node* node, u8* bus, u8* devfn) { unsigned int *reg; - int i; + struct pci_controller* hose; + struct pci_dev* dev; if (!have_of) return -ENODEV; + /* Make sure it's really a PCI device */ + hose = pci_find_hose_for_OF_device(node); + if (!hose || !hose->arch_data) + return -ENODEV; + if (!scan_OF_pci_childs(((struct device_node*)hose->arch_data)->child, + find_OF_pci_device_filter, (void *)node)) + return -ENODEV; reg = (unsigned int *) get_property(node, "reg", 0); if (!reg) return -ENODEV; *bus = (reg[0] >> 16) & 0xff; - for (i=0; pci_to_OF_bus_map && i<pci_bus_count; i++) - if (pci_to_OF_bus_map[i] == *bus) { - *bus = i; - break; - } *devfn = ((reg[0] >> 8) & 0xff); - return 0; + + /* Ok, here we need some tweak. If we have already renumbered + * all busses, we can't rely on the OF bus number any more. + * the pci_to_OF_bus_map is not enough as several PCI busses + * may match the same OF bus number. + */ + if (!pci_to_OF_bus_map) + return 0; + pci_for_each_dev(dev) { + if (pci_to_OF_bus_map[dev->bus->number] != *bus) + continue; + if (dev->devfn != *devfn) + continue; + *bus = dev->bus->number; + return 0; + } + return -ENODEV; } void __init diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/ppc/kernel/pmac_backlight.c linux-2.5/arch/ppc/kernel/pmac_backlight.c --- linux-2.5.1/arch/ppc/kernel/pmac_backlight.c Sat Sep 8 19:38:41 2001 +++ linux-2.5/arch/ppc/kernel/pmac_backlight.c Thu Dec 27 16:32:30 2001 @@ -1,5 +1,5 @@ /* - * BK Id: SCCS/s.pmac_backlight.c 1.8 09/08/01 15:47:42 paulus + * BK Id: SCCS/s.pmac_backlight.c 1.10 12/01/01 20:09:06 benh */ /* * Miscellaneous procedures for dealing with the PowerMac hardware. @@ -78,7 +78,7 @@ pmu_request(&req, NULL, 2, 0xd9, 0); while (!req.complete) pmu_poll(); - backlight_level = req.reply[1] >> 4; + backlight_level = req.reply[0] >> 4; } #endif if (!backlighter->set_enable(1, backlight_level, data)) diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/ppc/kernel/pmac_feature.c linux-2.5/arch/ppc/kernel/pmac_feature.c --- linux-2.5.1/arch/ppc/kernel/pmac_feature.c Thu Jan 1 00:00:00 1970 +++ linux-2.5/arch/ppc/kernel/pmac_feature.c Thu Dec 27 16:32:30 2001 @@ -0,0 +1,2075 @@ +/* + * BK Id: %F% %I% %G% %U% %#% + */ +/* + * arch/ppc/kernel/pmac_feature.c + * + * Copyright (C) 1996-2001 Paul Mackerras (paulus@cs.anu.edu.au) + * Ben. Herrenschmidt (benh@kernel.crashing.org) + * + * 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. + * + * TODO: + * + * - Replace mdelay with some schedule loop if possible + * - Shorten some obfuscated delays on some routines (like modem + * power) + * + */ +#include <linux/config.h> +#include <linux/types.h> +#include <linux/init.h> +#include <linux/delay.h> +#include <linux/kernel.h> +#include <linux/sched.h> +#include <linux/spinlock.h> +#include <linux/adb.h> +#include <linux/pmu.h> +#include <asm/sections.h> +#include <asm/errno.h> +#include <asm/ohare.h> +#include <asm/heathrow.h> +#include <asm/keylargo.h> +#include <asm/uninorth.h> +#include <asm/io.h> +#include <asm/prom.h> +#include <asm/machdep.h> +#include <asm/pmac_feature.h> +#include <asm/dbdma.h> + +#undef DEBUG_FEATURE + +#ifdef DEBUG_FEATURE +#define DBG(fmt,...) printk(KERN_DEBUG fmt) +#else +#define DBG(fmt,...) +#endif + +/* Exported from arch/ppc/kernel/idle.c */ +extern unsigned long powersave_nap; + +/* + * We use a single global lock to protect accesses. Each driver has + * to take care of it's own locking + */ +static spinlock_t feature_lock __pmacdata = SPIN_LOCK_UNLOCKED; + +#define LOCK(flags) spin_lock_irqsave(&feature_lock, flags); +#define UNLOCK(flags) spin_unlock_irqrestore(&feature_lock, flags); + +/* + * Helper functions regarding the various flavors of mac-io + */ + +#define MAX_MACIO_CHIPS 2 + +enum { + macio_unknown = 0, + macio_grand_central, + macio_ohare, + macio_ohareII, + macio_heathrow, + macio_gatwick, + macio_paddington, + macio_keylargo, + macio_pangea +}; + +static const char* macio_names[] __pmacdata = +{ + "Unknown", + "Grand Central", + "OHare", + "OHareII", + "Heathrow", + "Gatwick", + "Paddington", + "Keylargo", + "Pangea" +}; + +static struct macio_chip +{ + struct device_node* of_node; + int type; + int rev; + volatile u32* base; + unsigned long flags; +} macio_chips[MAX_MACIO_CHIPS] __pmacdata; + +#define MACIO_FLAG_SCCA_ON 0x00000001 +#define MACIO_FLAG_SCCB_ON 0x00000002 +#define MACIO_FLAG_SCC_LOCKED 0x00000004 +#define MACIO_FLAG_AIRPORT_ON 0x00000010 +#define MACIO_FLAG_FW_SUPPORTED 0x00000020 + +static struct macio_chip* __pmac +macio_find(struct device_node* child, int type) +{ + while(child) { + int i; + + for (i=0; i < MAX_MACIO_CHIPS && macio_chips[i].of_node; i++) + if (child == macio_chips[i].of_node && + (!type || macio_chips[i].type == type)) + return &macio_chips[i]; + child = child->parent; + } + return NULL; +} + +#define MACIO_FCR32(macio, r) ((macio)->base + ((r) >> 2)) +#define MACIO_FCR8(macio, r) (((volatile u8*)((macio)->base)) + (r)) + +#define MACIO_IN32(r) (in_le32(MACIO_FCR32(macio,r))) +#define MACIO_OUT32(r,v) (out_le32(MACIO_FCR32(macio,r), (v))) +#define MACIO_BIS(r,v) (MACIO_OUT32((r), MACIO_IN32(r) | (v))) +#define MACIO_BIC(r,v) (MACIO_OUT32((r), MACIO_IN32(r) & ~(v))) +#define MACIO_IN8(r) (in_8(MACIO_FCR8(macio,r))) +#define MACIO_OUT8(r,v) (out_8(MACIO_FCR8(macio,r), (v))) + +/* + * Uninorth reg. access. Note that Uni-N regs are big endian + */ + +#define UN_REG(r) (uninorth_base + ((r) >> 2)) +#define UN_IN(r) (in_be32(UN_REG(r))) +#define UN_OUT(r,v) (out_be32(UN_REG(r), (v))) +#define UN_BIS(r,v) (UN_OUT((r), UN_IN(r) | (v))) +#define UN_BIC(r,v) (UN_OUT((r), UN_IN(r) & ~(v))) + +static struct device_node* uninorth_node __pmacdata; +static u32* uninorth_base __pmacdata; +static u32 uninorth_rev __pmacdata; + + +/* + * For each motherboard family, we have a table of functions pointers + * that handle the various features. + */ + +typedef int (*feature_call)(struct device_node* node, int param, int value); + +struct feature_table_entry { + unsigned int selector; + feature_call function; +}; + +struct pmac_mb_def +{ + const char* model_string; + const char* model_name; + int model_id; + struct feature_table_entry* features; + unsigned long board_flags; +}; +static struct pmac_mb_def pmac_mb __pmacdata; + +/* + * Here are the chip specific feature functions + */ + +static inline int __pmac +simple_feature_tweak(struct device_node* node, int type, int reg, u32 mask, int value) +{ + struct macio_chip* macio; + unsigned long flags; + + macio = macio_find(node, type); + if (!macio) + return -ENODEV; + LOCK(flags); + if (value) + MACIO_BIS(reg, mask); + else + MACIO_BIC(reg, mask); + (void)MACIO_IN32(reg); + UNLOCK(flags); + + return 0; +} + +static int __pmac +generic_scc_enable(struct device_node* node, u32 enable_mask, u32 reset_mask, + int param, int value) +{ + struct macio_chip* macio; + unsigned long chan_mask; + unsigned long fcr; + unsigned long flags; + + macio = macio_find(node, 0); + if (!macio) + return -ENODEV; + if (!strcmp(node->name, "ch-a")) + chan_mask = MACIO_FLAG_SCCA_ON; + else if (!strcmp(node->name, "ch-b")) + chan_mask = MACIO_FLAG_SCCB_ON; + else + return -ENODEV; + + if (value) { + LOCK(flags); + fcr = MACIO_IN32(OHARE_FCR); + /* Check if scc cell need enabling */ + if (!(fcr & OH_SCC_ENABLE)) { + fcr |= enable_mask; + MACIO_OUT32(OHARE_FCR, fcr); + fcr |= reset_mask; + MACIO_OUT32(OHARE_FCR, fcr); + UNLOCK(flags); + (void)MACIO_IN32(OHARE_FCR); + mdelay(15); + LOCK(flags); + fcr &= ~reset_mask; + MACIO_OUT32(OHARE_FCR, fcr); + } + if (chan_mask & MACIO_FLAG_SCCA_ON) + fcr |= OH_SCCA_IO; + if (chan_mask & MACIO_FLAG_SCCB_ON) + fcr |= OH_SCCB_IO; + MACIO_OUT32(OHARE_FCR, fcr); + macio->flags |= chan_mask; + UNLOCK(flags); + if (param & PMAC_SCC_FLAG_XMON) + macio->flags |= MACIO_FLAG_SCC_LOCKED; + } else { + if (macio->flags & MACIO_FLAG_SCC_LOCKED) + return -EPERM; + LOCK(flags); + fcr = MACIO_IN32(OHARE_FCR); + if (chan_mask & MACIO_FLAG_SCCA_ON) + fcr &= ~OH_SCCA_IO; + if (chan_mask & MACIO_FLAG_SCCB_ON) + fcr &= ~OH_SCCB_IO; + MACIO_OUT32(OHARE_FCR, fcr); + if ((fcr & (OH_SCCA_IO | OH_SCCB_IO)) == 0) { + fcr &= ~enable_mask; + MACIO_OUT32(OHARE_FCR, fcr); + } + macio->flags &= ~(chan_mask); + UNLOCK(flags); + mdelay(10); + } + return 0; +} + +static int __pmac +ohare_scc_enable(struct device_node* node, int param, int value) +{ + int rc; + +#ifdef CONFIG_ADB_PMU + if (value && (param & 0xfff) == PMAC_SCC_IRDA) + pmu_enable_irled(1); +#endif /* CONFIG_ADB_PMU */ + rc = generic_scc_enable(node, OH_SCC_ENABLE, OH_SCC_RESET, param, value); +#ifdef CONFIG_ADB_PMU + if ((param & 0xfff) == PMAC_SCC_IRDA && (rc || !value)) + pmu_enable_irled(0); +#endif /* CONFIG_ADB_PMU */ + return rc; +} + +static int __pmac +ohare_floppy_enable(struct device_node* node, int param, int value) +{ + return simple_feature_tweak(node, macio_ohare, + OHARE_FCR, OH_FLOPPY_ENABLE, value); +} + +static int __pmac +ohare_mesh_enable(struct device_node* node, int param, int value) +{ + return simple_feature_tweak(node, macio_ohare, + OHARE_FCR, OH_MESH_ENABLE, value); +} + +static int __pmac +ohare_ide_enable(struct device_node* node, int param, int value) +{ + switch(param) { + case 0: + /* For some reason, setting the bit in set_initial_features() + * doesn't stick. I'm still investigating... --BenH. + */ + if (value) + simple_feature_tweak(node, macio_ohare, + OHARE_FCR, OH_IOBUS_ENABLE, 1); + return simple_feature_tweak(node, macio_ohare, + OHARE_FCR, OH_IDE0_ENABLE, value); + case 1: + return simple_feature_tweak(node, macio_ohare, + OHARE_FCR, OH_BAY_IDE_ENABLE, value); + default: + return -ENODEV; + } +} + +static int __pmac +ohare_ide_reset(struct device_node* node, int param, int value) +{ + switch(param) { + case 0: + return simple_feature_tweak(node, macio_ohare, + OHARE_FCR, OH_IDE0_RESET_N, !value); + case 1: + return simple_feature_tweak(node, macio_ohare, + OHARE_FCR, OH_IDE1_RESET_N, !value); + default: + return -ENODEV; + } +} + +static int __pmac +ohare_sleep_state(struct device_node* node, int param, int value) +{ + struct macio_chip* macio = &macio_chips[0]; + + if ((pmac_mb.board_flags & PMAC_MB_CAN_SLEEP) == 0) + return -EPERM; + if (value) { + MACIO_BIC(OHARE_FCR, OH_IOBUS_ENABLE); + } else { + MACIO_BIS(OHARE_FCR, OH_IOBUS_ENABLE); + } + + return 0; +} + +static int __pmac +heathrow_scc_enable(struct device_node* node, int param, int value) +{ + int rc; + +#ifdef CONFIG_ADB_PMU + if (value && param == PMAC_SCC_IRDA) + pmu_enable_irled(1); +#endif /* CONFIG_ADB_PMU */ + /* Fixme: It's possible that wallstreet (heathrow) is different + * than other paddington machines. I still have to figure that + * out exactly, for now, the paddington values are used + */ + rc = generic_scc_enable(node, HRW_SCC_ENABLE, PADD_RESET_SCC, param, value); +#ifdef CONFIG_ADB_PMU + if (param == PMAC_SCC_IRDA && (rc || !value)) + pmu_enable_irled(0); +#endif /* CONFIG_ADB_PMU */ + return rc; +} + +static int __pmac +heathrow_modem_enable(struct device_node* node, int param, int value) +{ + struct macio_chip* macio; + u8 gpio; + unsigned long flags; + + macio = macio_find(node, macio_unknown); + if (!macio) + return -ENODEV; + gpio = MACIO_IN8(HRW_GPIO_MODEM_RESET) & ~1; + if (!value) { + LOCK(flags); + MACIO_OUT8(HRW_GPIO_MODEM_RESET, gpio); + UNLOCK(flags); + (void)MACIO_IN8(HRW_GPIO_MODEM_RESET); + mdelay(250); + } + if (pmac_mb.model_id != PMAC_TYPE_YOSEMITE && + pmac_mb.model_id != PMAC_TYPE_YIKES) { + LOCK(flags); + /* We use the paddington values as they seem to work properly + * on the wallstreet (heathrow) as well. I can't tell why we + * had to flip them on older feature.c, the fact is that new + * code uses the paddington values which are also the ones used + * in Darwin, and that works on wallstreet ! + */ + if (value) + MACIO_BIC(HEATHROW_FCR, PADD_MODEM_POWER_N); + else + MACIO_BIS(HEATHROW_FCR, PADD_MODEM_POWER_N); + UNLOCK(flags); + (void)MACIO_IN32(HEATHROW_FCR); + mdelay(250); + } + if (value) { + LOCK(flags); + MACIO_OUT8(HRW_GPIO_MODEM_RESET, gpio | 1); + (void)MACIO_IN8(HRW_GPIO_MODEM_RESET); + UNLOCK(flags); mdelay(250); LOCK(flags); + MACIO_OUT8(HRW_GPIO_MODEM_RESET, gpio); + (void)MACIO_IN8(HRW_GPIO_MODEM_RESET); + UNLOCK(flags); mdelay(250); LOCK(flags); + MACIO_OUT8(HRW_GPIO_MODEM_RESET, gpio | 1); + (void)MACIO_IN8(HRW_GPIO_MODEM_RESET); + UNLOCK(flags); mdelay(250); LOCK(flags); + } + return 0; +} + +static int __pmac +heathrow_floppy_enable(struct device_node* node, int param, int value) +{ + return simple_feature_tweak(node, macio_unknown, + HEATHROW_FCR, + HRW_SWIM_ENABLE|HRW_BAY_FLOPPY_ENABLE, + value); +} + +static int __pmac +heathrow_mesh_enable(struct device_node* node, int param, int value) +{ + struct macio_chip* macio; + unsigned long flags; + + macio = macio_find(node, macio_unknown); + if (!macio) + return -ENODEV; + LOCK(flags); + /* Set clear mesh cell enable */ + if (value) + MACIO_BIS(HEATHROW_FCR, HRW_MESH_ENABLE); + else + MACIO_BIC(HEATHROW_FCR, HRW_MESH_ENABLE); + (void)MACIO_IN32(HEATHROW_FCR); + udelay(10); + /* Set/Clear termination power (todo: test ! the bit value + * used by Darwin doesn't seem to match what we used so + * far. If you experience problems, turn #if 1 into #if 0 + * and tell me about it --BenH. + */ +#if 1 + if (value) + MACIO_BIC(HEATHROW_MBCR, 0x00000004); + else + MACIO_BIS(HEATHROW_MBCR, 0x00000004); +#else + if (value) + MACIO_BIC(HEATHROW_MBCR, 0x00040000); + else + MACIO_BIS(HEATHROW_MBCR, 0x00040000); +#endif + (void)MACIO_IN32(HEATHROW_MBCR); + udelay(10); + UNLOCK(flags); + + return 0; +} + +static int __pmac +heathrow_ide_enable(struct device_node* node, int param, int value) +{ + switch(param) { + case 0: + return simple_feature_tweak(node, macio_unknown, + HEATHROW_FCR, HRW_IDE0_ENABLE, value); + case 1: + return simple_feature_tweak(node, macio_unknown, + HEATHROW_FCR, HRW_BAY_IDE_ENABLE, value); + default: + return -ENODEV; + } +} + +static int __pmac +heathrow_ide_reset(struct device_node* node, int param, int value) +{ + switch(param) { + case 0: + return simple_feature_tweak(node, macio_unknown, + HEATHROW_FCR, HRW_IDE0_RESET_N, !value); + case 1: + return simple_feature_tweak(node, macio_unknown, + HEATHROW_FCR, HRW_IDE1_RESET_N, !value); + default: + return -ENODEV; + } +} + +static int __pmac +heathrow_bmac_enable(struct device_node* node, int param, int value) +{ + struct macio_chip* macio; + unsigned long flags; + + macio = macio_find(node, 0); + if (!macio) + return -ENODEV; + if (value) { + LOCK(flags); + MACIO_BIS(HEATHROW_FCR, HRW_BMAC_IO_ENABLE); + MACIO_BIS(HEATHROW_FCR, HRW_BMAC_RESET); + UNLOCK(flags); + (void)MACIO_IN32(HEATHROW_FCR); + mdelay(10); + LOCK(flags); + MACIO_BIC(HEATHROW_FCR, HRW_BMAC_RESET); + UNLOCK(flags); + (void)MACIO_IN32(HEATHROW_FCR); + mdelay(10); + } else { + LOCK(flags); + MACIO_BIC(HEATHROW_FCR, HRW_BMAC_IO_ENABLE); + UNLOCK(flags); + } + return 0; +} + +static int __pmac +heathrow_sound_enable(struct device_node* node, int param, int value) +{ + struct macio_chip* macio; + unsigned long flags; + + /* B&W G3 and Yikes don't support that properly (the + * sound appear to never come back after beeing shut down). + */ + if (pmac_mb.model_id == PMAC_TYPE_YOSEMITE || + pmac_mb.model_id == PMAC_TYPE_YIKES) + return 0; + + macio = macio_find(node, 0); + if (!macio) + return -ENODEV; + if (value) { + LOCK(flags); + MACIO_BIS(HEATHROW_FCR, HRW_SOUND_CLK_ENABLE); + MACIO_BIC(HEATHROW_FCR, HRW_SOUND_POWER_N); + UNLOCK(flags); + (void)MACIO_IN32(HEATHROW_FCR); + } else { + LOCK(flags); + MACIO_BIS(HEATHROW_FCR, HRW_SOUND_POWER_N); + MACIO_BIC(HEATHROW_FCR, HRW_SOUND_CLK_ENABLE); + UNLOCK(flags); + } + return 0; +} + +static u32 save_fcr[5] __pmacdata; +static u32 save_mbcr __pmacdata; +static u32 save_gpio_levels[2] __pmacdata; +static u8 save_gpio_extint[KEYLARGO_GPIO_EXTINT_CNT] __pmacdata; +static u8 save_gpio_normal[KEYLARGO_GPIO_CNT] __pmacdata; +static u32 save_unin_clock_ctl __pmacdata; +static struct dbdma_regs save_dbdma[13] __pmacdata; +static struct dbdma_regs save_alt_dbdma[13] __pmacdata; + +static void __pmac +dbdma_save(struct macio_chip* macio, struct dbdma_regs* save) +{ + int i; + + /* Save state & config of DBDMA channels */ + for (i=0; i<13; i++) { + volatile struct dbdma_regs* chan = (volatile struct dbdma_regs*) + (macio->base + ((0x8000+i*0x100)>>2)); + save[i].cmdptr_hi = in_le32(&chan->cmdptr_hi); + save[i].cmdptr = in_le32(&chan->cmdptr); + save[i].intr_sel = in_le32(&chan->intr_sel); + save[i].br_sel = in_le32(&chan->br_sel); + save[i].wait_sel = in_le32(&chan->wait_sel); + } +} + +static void __pmac +dbdma_restore(struct macio_chip* macio, struct dbdma_regs* save) +{ + int i; + + /* Save state & config of DBDMA channels */ + for (i=0; i<13; i++) { + volatile struct dbdma_regs* chan = (volatile struct dbdma_regs*) + (macio->base + ((0x8000+i*0x100)>>2)); + out_le32(&chan->control, (ACTIVE|DEAD|WAKE|FLUSH|PAUSE|RUN)<<16); + while (in_le32(&chan->status) & ACTIVE) + mb(); + out_le32(&chan->cmdptr_hi, save[i].cmdptr_hi); + out_le32(&chan->cmdptr, save[i].cmdptr); + out_le32(&chan->intr_sel, save[i].intr_sel); + out_le32(&chan->br_sel, save[i].br_sel); + out_le32(&chan->wait_sel, save[i].wait_sel); + } +} + +static void __pmac +heathrow_sleep(struct macio_chip* macio, int secondary) +{ + if (secondary) { + dbdma_save(macio, save_alt_dbdma); + save_fcr[2] = MACIO_IN32(0x38); + save_fcr[3] = MACIO_IN32(0x3c); + } else { + dbdma_save(macio, save_dbdma); + save_fcr[0] = MACIO_IN32(0x38); + save_fcr[1] = MACIO_IN32(0x3c); + save_mbcr = MACIO_IN32(0x34); + /* Make sure sound is shut down */ + MACIO_BIS(HEATHROW_FCR, HRW_SOUND_POWER_N); + MACIO_BIC(HEATHROW_FCR, HRW_SOUND_CLK_ENABLE); + /* This seems to be necessary as well or the fan + * keeps coming up and battery drains fast */ + MACIO_BIC(HEATHROW_FCR, HRW_IOBUS_ENABLE); + } + /* Make sure modem is shut down */ + MACIO_OUT8(HRW_GPIO_MODEM_RESET, + MACIO_IN8(HRW_GPIO_MODEM_RESET) & ~1); + MACIO_BIS(HEATHROW_FCR, PADD_MODEM_POWER_N); + MACIO_BIC(HEATHROW_FCR, OH_SCCA_IO|OH_SCCB_IO|HRW_SCC_ENABLE); + + /* Let things settle */ + (void)MACIO_IN32(HEATHROW_FCR); + mdelay(1); +} + +static void __pmac +heathrow_wakeup(struct macio_chip* macio, int secondary) +{ + if (secondary) { + MACIO_OUT32(0x38, save_fcr[2]); + (void)MACIO_IN32(0x38); + mdelay(1); + MACIO_OUT32(0x3c, save_fcr[3]); + (void)MACIO_IN32(0x38); + mdelay(10); + dbdma_restore(macio, save_alt_dbdma); + } else { + MACIO_OUT32(0x38, save_fcr[0] | HRW_IOBUS_ENABLE); + (void)MACIO_IN32(0x38); + mdelay(1); + MACIO_OUT32(0x3c, save_fcr[1]); + (void)MACIO_IN32(0x38); + mdelay(1); + MACIO_OUT32(0x34, save_mbcr); + (void)MACIO_IN32(0x38); + mdelay(10); + dbdma_restore(macio, save_dbdma); + } +} + +static int __pmac +heathrow_sleep_state(struct device_node* node, int param, int value) +{ + if ((pmac_mb.board_flags & PMAC_MB_CAN_SLEEP) == 0) + return -EPERM; + if (value == 1) { + if (macio_chips[1].type == macio_gatwick) + heathrow_sleep(&macio_chips[0], 1); + heathrow_sleep(&macio_chips[0], 0); + } else if (value == 0) { + heathrow_wakeup(&macio_chips[0], 0); + if (macio_chips[1].type == macio_gatwick) + heathrow_wakeup(&macio_chips[0], 1); + } + return 0; +} + +static int __pmac +core99_scc_enable(struct device_node* node, int param, int value) +{ + struct macio_chip* macio; + unsigned long flags; + unsigned long chan_mask; + u32 fcr; + + macio = macio_find(node, 0); + if (!macio) + return -ENODEV; + if (!strcmp(node->name, "ch-a")) + chan_mask = MACIO_FLAG_SCCA_ON; + else if (!strcmp(node->name, "ch-b")) + chan_mask = MACIO_FLAG_SCCB_ON; + else + return -ENODEV; + + if (value) { + int need_reset_scc = 0; + int need_reset_irda = 0; + + LOCK(flags); + fcr = MACIO_IN32(KEYLARGO_FCR0); + /* Check if scc cell need enabling */ + if (!(fcr & KL0_SCC_CELL_ENABLE)) { + fcr |= KL0_SCC_CELL_ENABLE; + need_reset_scc = 1; + } + if (chan_mask & MACIO_FLAG_SCCA_ON) { + fcr |= KL0_SCCA_ENABLE; + /* Don't enable line drivers for I2S modem */ + if ((param & 0xfff) == PMAC_SCC_I2S1) + fcr &= ~KL0_SCC_A_INTF_ENABLE; + else + fcr |= KL0_SCC_A_INTF_ENABLE; + } + if (chan_mask & MACIO_FLAG_SCCB_ON) { + fcr |= KL0_SCCB_ENABLE; + /* Perform irda specific inits */ + if ((param & 0xfff) == PMAC_SCC_IRDA) { + fcr &= ~KL0_SCC_B_INTF_ENABLE; + fcr |= KL0_IRDA_ENABLE; + fcr |= KL0_IRDA_CLK32_ENABLE | KL0_IRDA_CLK19_ENABLE; + fcr |= KL0_IRDA_SOURCE1_SEL; + fcr &= ~(KL0_IRDA_FAST_CONNECT|KL0_IRDA_DEFAULT1|KL0_IRDA_DEFAULT0); + fcr &= ~(KL0_IRDA_SOURCE2_SEL|KL0_IRDA_HIGH_BAND); + need_reset_irda = 1; + } else + fcr |= KL0_SCC_B_INTF_ENABLE; + } + MACIO_OUT32(KEYLARGO_FCR0, fcr); + macio->flags |= chan_mask; + if (need_reset_scc) { + MACIO_BIS(KEYLARGO_FCR0, KL0_SCC_RESET); + (void)MACIO_IN32(KEYLARGO_FCR0); + UNLOCK(flags); + mdelay(15); + LOCK(flags); + MACIO_BIC(KEYLARGO_FCR0, KL0_SCC_RESET); + } + if (need_reset_irda) { + MACIO_BIS(KEYLARGO_FCR0, KL0_IRDA_RESET); + (void)MACIO_IN32(KEYLARGO_FCR0); + UNLOCK(flags); + mdelay(15); + LOCK(flags); + MACIO_BIC(KEYLARGO_FCR0, KL0_IRDA_RESET); + } + UNLOCK(flags); + if (param & PMAC_SCC_FLAG_XMON) + macio->flags |= MACIO_FLAG_SCC_LOCKED; + } else { + if (macio->flags & MACIO_FLAG_SCC_LOCKED) + return -EPERM; + LOCK(flags); + fcr = MACIO_IN32(KEYLARGO_FCR0); + if (chan_mask & MACIO_FLAG_SCCA_ON) + fcr &= ~KL0_SCCA_ENABLE; + if (chan_mask & MACIO_FLAG_SCCB_ON) { + fcr &= ~KL0_SCCB_ENABLE; + /* Perform irda specific clears */ + if ((param & 0xfff) == PMAC_SCC_IRDA) { + fcr &= ~KL0_IRDA_ENABLE; + fcr &= ~(KL0_IRDA_CLK32_ENABLE | KL0_IRDA_CLK19_ENABLE); + fcr &= ~(KL0_IRDA_FAST_CONNECT|KL0_IRDA_DEFAULT1|KL0_IRDA_DEFAULT0); + fcr &= ~(KL0_IRDA_SOURCE1_SEL|KL0_IRDA_SOURCE2_SEL|KL0_IRDA_HIGH_BAND); + } + } + MACIO_OUT32(KEYLARGO_FCR0, fcr); + if ((fcr & (KL0_SCCA_ENABLE | KL0_SCCB_ENABLE)) == 0) { + fcr &= ~KL0_SCC_CELL_ENABLE; + MACIO_OUT32(KEYLARGO_FCR0, fcr); + } + macio->flags &= ~(chan_mask); + UNLOCK(flags); + mdelay(10); + } + return 0; +} + +static int __pmac +core99_modem_enable(struct device_node* node, int param, int value) +{ + struct macio_chip* macio; + u8 gpio; + unsigned long flags; + + macio = macio_find(node, 0); + if (!macio) + return -ENODEV; + gpio = MACIO_IN8(KL_GPIO_MODEM_RESET); + gpio |= KEYLARGO_GPIO_OUTPUT_ENABLE; + gpio &= ~KEYLARGO_GPIO_OUTOUT_DATA; + + if (!value) { + LOCK(flags); + MACIO_OUT8(KL_GPIO_MODEM_RESET, gpio); + UNLOCK(flags); + (void)MACIO_IN8(KL_GPIO_MODEM_RESET); + mdelay(250); + } + LOCK(flags); + if (value) { + MACIO_BIC(KEYLARGO_FCR2, KL2_MODEM_POWER_N); + UNLOCK(flags); + (void)MACIO_IN32(KEYLARGO_FCR2); + mdelay(250); + } else { + MACIO_BIS(KEYLARGO_FCR2, KL2_MODEM_POWER_N); + UNLOCK(flags); + } + if (value) { + LOCK(flags); + MACIO_OUT8(KL_GPIO_MODEM_RESET, gpio | KEYLARGO_GPIO_OUTOUT_DATA); + (void)MACIO_IN8(KL_GPIO_MODEM_RESET); + UNLOCK(flags); mdelay(250); LOCK(flags); + MACIO_OUT8(KL_GPIO_MODEM_RESET, gpio); + (void)MACIO_IN8(KL_GPIO_MODEM_RESET); + UNLOCK(flags); mdelay(250); LOCK(flags); + MACIO_OUT8(KL_GPIO_MODEM_RESET, gpio | KEYLARGO_GPIO_OUTOUT_DATA); + (void)MACIO_IN8(KL_GPIO_MODEM_RESET); + UNLOCK(flags); mdelay(250); LOCK(flags); + } + return 0; +} + +static int __pmac +core99_ide_enable(struct device_node* node, int param, int value) +{ + switch(param) { + case 0: + return simple_feature_tweak(node, macio_unknown, + KEYLARGO_FCR1, KL1_EIDE0_ENABLE, value); + case 1: + return simple_feature_tweak(node, macio_unknown, + KEYLARGO_FCR1, KL1_EIDE1_ENABLE, value); + case 2: + return simple_feature_tweak(node, macio_unknown, + KEYLARGO_FCR1, KL1_UIDE_ENABLE, value); + default: + return -ENODEV; + } +} + +static int __pmac +core99_ide_reset(struct device_node* node, int param, int value) +{ + switch(param) { + case 0: + return simple_feature_tweak(node, macio_unknown, + KEYLARGO_FCR1, KL1_EIDE0_RESET_N, !value); + case 1: + return simple_feature_tweak(node, macio_unknown, + KEYLARGO_FCR1, KL1_EIDE1_RESET_N, !value); + case 2: + return simple_feature_tweak(node, macio_unknown, + KEYLARGO_FCR1, KL1_UIDE_RESET_N, !value); + default: + return -ENODEV; + } +} + +static int __pmac +core99_gmac_enable(struct device_node* node, int param, int value) +{ + unsigned long flags; + + LOCK(flags); + if (value) + UN_BIS(UNI_N_CLOCK_CNTL, UNI_N_CLOCK_CNTL_GMAC); + else + UN_BIC(UNI_N_CLOCK_CNTL, UNI_N_CLOCK_CNTL_GMAC); + (void)UN_IN(UNI_N_CLOCK_CNTL); + UNLOCK(flags); + udelay(20); + + return 0; +} + +static int __pmac +core99_gmac_phy_reset(struct device_node* node, int param, int value) +{ + unsigned long flags; + struct macio_chip* macio; + + macio = &macio_chips[0]; + if (macio->type != macio_keylargo && macio->type != macio_pangea) + return -ENODEV; + + LOCK(flags); + MACIO_OUT8(KL_GPIO_ETH_PHY_RESET, KEYLARGO_GPIO_OUTPUT_ENABLE); + (void)MACIO_IN8(KL_GPIO_ETH_PHY_RESET); + UNLOCK(flags); + mdelay(10); + LOCK(flags); + MACIO_OUT8(KL_GPIO_ETH_PHY_RESET, KEYLARGO_GPIO_OUTPUT_ENABLE + | KEYLARGO_GPIO_OUTOUT_DATA); + UNLOCK(flags); + mdelay(10); + + return 0; +} + +static int __pmac +core99_sound_chip_enable(struct device_node* node, int param, int value) +{ + struct macio_chip* macio; + unsigned long flags; + + macio = macio_find(node, 0); + if (!macio) + return -ENODEV; + + /* Do a better probe code, screamer G4 desktops & + * iMacs can do that too, add a recalibrate in + * the driver as well + */ + if (pmac_mb.model_id == PMAC_TYPE_PISMO || + pmac_mb.model_id == PMAC_TYPE_TITANIUM) { + LOCK(flags); + if (value) + MACIO_OUT8(KL_GPIO_SOUND_POWER, + KEYLARGO_GPIO_OUTPUT_ENABLE | + KEYLARGO_GPIO_OUTOUT_DATA); + else + MACIO_OUT8(KL_GPIO_SOUND_POWER, + KEYLARGO_GPIO_OUTPUT_ENABLE); + (void)MACIO_IN8(KL_GPIO_SOUND_POWER); + UNLOCK(flags); + } + return 0; +} + +static int __pmac +core99_airport_enable(struct device_node* node, int param, int value) +{ + struct macio_chip* macio; + unsigned long flags; + int state; + + macio = macio_find(node, 0); + if (!macio) + return -ENODEV; + + /* Hint: we allow passing of macio itself for the sake of the + * sleep code + */ + if (node != macio->of_node && + (!node->parent || node->parent != macio->of_node)) + return -ENODEV; + state = (macio->flags & MACIO_FLAG_AIRPORT_ON) != 0; + if (value == state) + return 0; + if (value) { + /* This code is a reproduction of OF enable-cardslot + * and init-wireless methods, slightly hacked until + * I got it working. + */ + LOCK(flags); + MACIO_OUT8(KEYLARGO_GPIO_0+0xf, 5); + (void)MACIO_IN8(KEYLARGO_GPIO_0+0xf); + UNLOCK(flags); + mdelay(10); + LOCK(flags); + MACIO_OUT8(KEYLARGO_GPIO_0+0xf, 4); + (void)MACIO_IN8(KEYLARGO_GPIO_0+0xf); + UNLOCK(flags); + + mdelay(10); + + LOCK(flags); + MACIO_BIC(KEYLARGO_FCR2, KL2_AIRPORT_RESET_N); + (void)MACIO_IN32(KEYLARGO_FCR2); + udelay(10); + MACIO_OUT8(KEYLARGO_GPIO_EXTINT_0+0xb, 0); + (void)MACIO_IN8(KEYLARGO_GPIO_EXTINT_0+0xb); + udelay(10); + MACIO_OUT8(KEYLARGO_GPIO_EXTINT_0+0xa, 0x28); + (void)MACIO_IN8(KEYLARGO_GPIO_EXTINT_0+0xa); + udelay(10); + MACIO_OUT8(KEYLARGO_GPIO_EXTINT_0+0xd, 0x28); + (void)MACIO_IN8(KEYLARGO_GPIO_EXTINT_0+0xd); + udelay(10); + MACIO_OUT8(KEYLARGO_GPIO_0+0xd, 0x28); + (void)MACIO_IN8(KEYLARGO_GPIO_0+0xd); + udelay(10); + MACIO_OUT8(KEYLARGO_GPIO_0+0xe, 0x28); + (void)MACIO_IN8(KEYLARGO_GPIO_0+0xe); + UNLOCK(flags); + udelay(10); + MACIO_OUT32(0x1c000, 0); + mdelay(1); + MACIO_OUT8(0x1a3e0, 0x41); + (void)MACIO_IN8(0x1a3e0); + udelay(10); + LOCK(flags); + MACIO_BIS(KEYLARGO_FCR2, KL2_AIRPORT_RESET_N); + (void)MACIO_IN32(KEYLARGO_FCR2); + UNLOCK(flags); + mdelay(100); + + macio->flags |= MACIO_FLAG_AIRPORT_ON; + } else { + LOCK(flags); + MACIO_BIC(KEYLARGO_FCR2, KL2_AIRPORT_RESET_N); + (void)MACIO_IN32(KEYLARGO_FCR2); + MACIO_OUT8(KL_GPIO_AIRPORT_0, 0); + MACIO_OUT8(KL_GPIO_AIRPORT_1, 0); + MACIO_OUT8(KL_GPIO_AIRPORT_2, 0); + MACIO_OUT8(KL_GPIO_AIRPORT_3, 0); + MACIO_OUT8(KL_GPIO_AIRPORT_4, 0); + (void)MACIO_IN8(KL_GPIO_AIRPORT_4); + UNLOCK(flags); + + macio->flags &= ~MACIO_FLAG_AIRPORT_ON; + } + return 0; +} + +#ifdef CONFIG_SMP +static int __pmac +core99_reset_cpu(struct device_node* node, int param, int value) +{ + const int reset_lines[] = { KL_GPIO_RESET_CPU0, + KL_GPIO_RESET_CPU1, + KL_GPIO_RESET_CPU2, + KL_GPIO_RESET_CPU3 }; + int reset_io; + unsigned long flags; + struct macio_chip* macio; + + macio = &macio_chips[0]; + if (macio->type != macio_keylargo && macio->type != macio_pangea) + return -ENODEV; + if (param > 3 || param < 0) + return -ENODEV; + + reset_io = reset_lines[param]; + + LOCK(flags); + MACIO_OUT8(reset_io, KEYLARGO_GPIO_OUTPUT_ENABLE); + (void)MACIO_IN8(reset_io); + udelay(1); + MACIO_OUT8(reset_io, KEYLARGO_GPIO_OUTPUT_ENABLE | KEYLARGO_GPIO_OUTOUT_DATA); + (void)MACIO_IN8(reset_io); + UNLOCK(flags); + + return 0; +} +#endif /* CONFIG_SMP */ + +static int __pmac +core99_usb_enable(struct device_node* node, int param, int value) +{ + struct macio_chip* macio; + unsigned long flags; + char* prop; + int number; + u32 reg; + + macio = &macio_chips[0]; + if (macio->type != macio_keylargo && macio->type != macio_pangea) + return -ENODEV; + + prop = (char *)get_property(node, "AAPL,clock-id", NULL); + if (!prop) + return -ENODEV; + if (strncmp(prop, "usb0u048", strlen("usb0u048")) == 0) + number = 0; + else if (strncmp(prop, "usb1u148", strlen("usb1u148")) == 0) + number = 2; + else + return -ENODEV; + + /* Sorry for the brute-force locking, but this is only used during + * sleep and the timing seem to be critical + */ + LOCK(flags); + if (value) { + /* Turn ON */ + if (number == 0) { + MACIO_BIC(KEYLARGO_FCR0, (KL0_USB0_PAD_SUSPEND0 | KL0_USB0_PAD_SUSPEND1)); + (void)MACIO_IN32(KEYLARGO_FCR0); + UNLOCK(flags); + mdelay(1); + LOCK(flags); + MACIO_BIS(KEYLARGO_FCR0, KL0_USB0_CELL_ENABLE); + } else { + MACIO_BIC(KEYLARGO_FCR0, (KL0_USB1_PAD_SUSPEND0 | KL0_USB1_PAD_SUSPEND1)); + UNLOCK(flags); + (void)MACIO_IN32(KEYLARGO_FCR0); + mdelay(1); + LOCK(flags); + MACIO_BIS(KEYLARGO_FCR0, KL0_USB1_CELL_ENABLE); + } + reg = MACIO_IN32(KEYLARGO_FCR4); + reg &= ~(KL4_SET_PORT_ENABLE(number) | KL4_SET_PORT_RESUME(number) | + KL4_SET_PORT_CONNECT(number) | KL4_SET_PORT_DISCONNECT(number)); + reg &= ~(KL4_SET_PORT_ENABLE(number+1) | KL4_SET_PORT_RESUME(number+1) | + KL4_SET_PORT_CONNECT(number+1) | KL4_SET_PORT_DISCONNECT(number+1)); + MACIO_OUT32(KEYLARGO_FCR4, reg); + (void)MACIO_IN32(KEYLARGO_FCR4); + udelay(10); + } else { + /* Turn OFF */ + reg = MACIO_IN32(KEYLARGO_FCR4); + reg |= KL4_SET_PORT_ENABLE(number) | KL4_SET_PORT_RESUME(number) | + KL4_SET_PORT_CONNECT(number) | KL4_SET_PORT_DISCONNECT(number); + reg |= KL4_SET_PORT_ENABLE(number+1) | KL4_SET_PORT_RESUME(number+1) | + KL4_SET_PORT_CONNECT(number+1) | KL4_SET_PORT_DISCONNECT(number+1); + MACIO_OUT32(KEYLARGO_FCR4, reg); + (void)MACIO_IN32(KEYLARGO_FCR4); + udelay(1); + if (number == 0) { + MACIO_BIC(KEYLARGO_FCR0, KL0_USB0_CELL_ENABLE); + (void)MACIO_IN32(KEYLARGO_FCR0); + udelay(1); + MACIO_BIS(KEYLARGO_FCR0, (KL0_USB0_PAD_SUSPEND0 | KL0_USB0_PAD_SUSPEND1)); + (void)MACIO_IN32(KEYLARGO_FCR0); + } else { + MACIO_BIC(KEYLARGO_FCR0, KL0_USB1_CELL_ENABLE); + (void)MACIO_IN32(KEYLARGO_FCR0); + udelay(1); + MACIO_BIS(KEYLARGO_FCR0, (KL0_USB1_PAD_SUSPEND0 | KL0_USB1_PAD_SUSPEND1)); + (void)MACIO_IN32(KEYLARGO_FCR0); + } + udelay(1); + } + UNLOCK(flags); + + return 0; +} + +static int __pmac +core99_firewire_enable(struct device_node* node, int param, int value) +{ + unsigned long flags; + struct macio_chip* macio; + + macio = &macio_chips[0]; + if (macio->type != macio_keylargo && macio->type != macio_pangea) + return -ENODEV; + if (!(macio->flags & MACIO_FLAG_FW_SUPPORTED)) + return -ENODEV; + + LOCK(flags); + if (value) { + UN_BIS(UNI_N_CLOCK_CNTL, UNI_N_CLOCK_CNTL_FW); + (void)UN_IN(UNI_N_CLOCK_CNTL); + } else { + UN_BIC(UNI_N_CLOCK_CNTL, UNI_N_CLOCK_CNTL_FW); + (void)UN_IN(UNI_N_CLOCK_CNTL); + } + UNLOCK(flags); + mdelay(1); + + return 0; +} + +static int __pmac +core99_firewire_cable_power(struct device_node* node, int param, int value) +{ + unsigned long flags; + struct macio_chip* macio; + + /* Trick: we allow NULL node */ + if (pmac_mb.model_id != PMAC_TYPE_FW_IBOOK && + pmac_mb.model_id != PMAC_TYPE_PISMO && + pmac_mb.model_id != PMAC_TYPE_IBOOK2) + return -ENODEV; + macio = &macio_chips[0]; + if (macio->type != macio_keylargo && macio->type != macio_pangea) + return -ENODEV; + if (!(macio->flags & MACIO_FLAG_FW_SUPPORTED)) + return -ENODEV; + + LOCK(flags); + if (value) { + MACIO_OUT8(KL_GPIO_FW_CABLE_POWER , 0); + MACIO_IN8(KL_GPIO_FW_CABLE_POWER); + udelay(10); + } else { + MACIO_OUT8(KL_GPIO_FW_CABLE_POWER , 4); + MACIO_IN8(KL_GPIO_FW_CABLE_POWER); udelay(10); + } + UNLOCK(flags); + mdelay(1); + + return 0; +} + +static int __pmac +core99_read_gpio(struct device_node* node, int param, int value) +{ + struct macio_chip* macio = &macio_chips[0]; + + return MACIO_IN8(param); +} + + +static int __pmac +core99_write_gpio(struct device_node* node, int param, int value) +{ + struct macio_chip* macio = &macio_chips[0]; + + MACIO_OUT8(param, (u8)(value & 0xff)); + return 0; +} + +static void __pmac +keylargo_shutdown(struct macio_chip* macio, int restart) +{ + u32 temp; + + mdelay(1); + MACIO_BIS(KEYLARGO_FCR0, KL0_USB_REF_SUSPEND); + (void)MACIO_IN32(KEYLARGO_FCR0); + mdelay(100); + + MACIO_BIC(KEYLARGO_FCR0,KL0_SCCA_ENABLE | KL0_SCCB_ENABLE | + KL0_SCC_CELL_ENABLE | + KL0_IRDA_ENABLE | KL0_IRDA_CLK32_ENABLE | + KL0_IRDA_CLK19_ENABLE); + + (void)MACIO_IN32(KEYLARGO_FCR0); udelay(10); + MACIO_BIC(KEYLARGO_MBCR, KL_MBCR_MB0_DEV_MASK); + (void)MACIO_IN32(KEYLARGO_MBCR); udelay(10); + + MACIO_BIC(KEYLARGO_FCR1, + KL1_AUDIO_SEL_22MCLK | KL1_AUDIO_CLK_ENABLE_BIT | + KL1_AUDIO_CLK_OUT_ENABLE | KL1_AUDIO_CELL_ENABLE | + KL1_I2S0_CELL_ENABLE | KL1_I2S0_CLK_ENABLE_BIT | + KL1_I2S0_ENABLE | KL1_I2S1_CELL_ENABLE | + KL1_I2S1_CLK_ENABLE_BIT | KL1_I2S1_ENABLE | + KL1_EIDE0_ENABLE | KL1_EIDE0_RESET_N | + KL1_EIDE1_ENABLE | KL1_EIDE1_RESET_N | + KL1_UIDE_ENABLE); + (void)MACIO_IN32(KEYLARGO_FCR1); udelay(10); + + MACIO_BIS(KEYLARGO_FCR2, KL2_MODEM_POWER_N); + udelay(10); + MACIO_BIC(KEYLARGO_FCR2, KL2_IOBUS_ENABLE); + udelay(10); + temp = MACIO_IN32(KEYLARGO_FCR3); + if (macio->rev >= 2) + temp |= (KL3_SHUTDOWN_PLL2X | KL3_SHUTDOWN_PLL_TOTAL); + + temp |= KL3_SHUTDOWN_PLLKW6 | KL3_SHUTDOWN_PLLKW4 | + KL3_SHUTDOWN_PLLKW35 | KL3_SHUTDOWN_PLLKW12; + temp &= ~(KL3_CLK66_ENABLE | KL3_CLK49_ENABLE | KL3_CLK45_ENABLE + | KL3_CLK31_ENABLE | KL3_TIMER_CLK18_ENABLE | KL3_I2S1_CLK18_ENABLE + | KL3_I2S0_CLK18_ENABLE | KL3_VIA_CLK16_ENABLE); + MACIO_OUT32(KEYLARGO_FCR3, temp); + (void)MACIO_IN32(KEYLARGO_FCR3); udelay(10); +} + +static void __pmac +pangea_shutdown(struct macio_chip* macio, int restart) +{ + u32 temp; + + MACIO_BIC(KEYLARGO_FCR0,KL0_SCCA_ENABLE | KL0_SCCB_ENABLE | + KL0_SCC_CELL_ENABLE | + KL0_USB0_CELL_ENABLE | KL0_USB1_CELL_ENABLE); + + (void)MACIO_IN32(KEYLARGO_FCR0); udelay(10); + MACIO_BIC(KEYLARGO_MBCR, KL_MBCR_MB0_DEV_MASK); + (void)MACIO_IN32(KEYLARGO_MBCR); udelay(10); + + MACIO_BIC(KEYLARGO_FCR1, + KL1_AUDIO_SEL_22MCLK | KL1_AUDIO_CLK_ENABLE_BIT | + KL1_AUDIO_CLK_OUT_ENABLE | KL1_AUDIO_CELL_ENABLE | + KL1_I2S0_CELL_ENABLE | KL1_I2S0_CLK_ENABLE_BIT | + KL1_I2S0_ENABLE | KL1_I2S1_CELL_ENABLE | + KL1_I2S1_CLK_ENABLE_BIT | KL1_I2S1_ENABLE | + KL1_UIDE_ENABLE); + (void)MACIO_IN32(KEYLARGO_FCR1); udelay(10); + + MACIO_BIS(KEYLARGO_FCR2, KL2_MODEM_POWER_N); + udelay(10); + temp = MACIO_IN32(KEYLARGO_FCR3); + temp |= KL3_SHUTDOWN_PLLKW6 | KL3_SHUTDOWN_PLLKW4 | + KL3_SHUTDOWN_PLLKW35; + temp &= ~(KL3_CLK49_ENABLE | KL3_CLK45_ENABLE + | KL3_CLK31_ENABLE | KL3_TIMER_CLK18_ENABLE | KL3_I2S1_CLK18_ENABLE + | KL3_I2S0_CLK18_ENABLE | KL3_VIA_CLK16_ENABLE); + MACIO_OUT32(KEYLARGO_FCR3, temp); + (void)MACIO_IN32(KEYLARGO_FCR3); udelay(10); +} + +static int __pmac +core99_sleep(void) +{ + struct macio_chip* macio; + int i; + + macio = &macio_chips[0]; + if (macio->type != macio_keylargo && macio->type != macio_pangea) + return -ENODEV; + + /* We power off the wireless slot in case it was not done + * by the driver. We don't power it on automatically however + */ + if (macio->flags & MACIO_FLAG_AIRPORT_ON) + core99_airport_enable(macio->of_node, 0, 0); + + /* We power off the FW cable. Should be done by the driver... */ + if (macio->flags & MACIO_FLAG_FW_SUPPORTED) { + core99_firewire_enable(NULL, 0, 0); + core99_firewire_cable_power(NULL, 0, 0); + } + + /* We make sure int. modem is off (in case driver lost it) */ + core99_modem_enable(macio->of_node, 0, 0); + /* We make sure the sound is off as well */ + core99_sound_chip_enable(macio->of_node, 0, 0); + + /* + * Save various bits of KeyLargo + */ + + /* Save the state of the various GPIOs */ + save_gpio_levels[0] = MACIO_IN32(KEYLARGO_GPIO_LEVELS0); + save_gpio_levels[1] = MACIO_IN32(KEYLARGO_GPIO_LEVELS1); + for (i=0; i<KEYLARGO_GPIO_EXTINT_CNT; i++) + save_gpio_extint[i] = MACIO_IN8(KEYLARGO_GPIO_EXTINT_0+i); + for (i=0; i<KEYLARGO_GPIO_CNT; i++) + save_gpio_normal[i] = MACIO_IN8(KEYLARGO_GPIO_0+i); + + /* Save the FCRs */ + save_mbcr = MACIO_IN32(KEYLARGO_MBCR); + save_fcr[0] = MACIO_IN32(KEYLARGO_FCR0); + save_fcr[1] = MACIO_IN32(KEYLARGO_FCR1); + save_fcr[2] = MACIO_IN32(KEYLARGO_FCR2); + save_fcr[3] = MACIO_IN32(KEYLARGO_FCR3); + save_fcr[4] = MACIO_IN32(KEYLARGO_FCR4); + + /* Save state & config of DBDMA channels */ + dbdma_save(macio, save_dbdma); + + /* + * Turn off as much as we can + */ + if (macio->type == macio_pangea) + pangea_shutdown(macio, 0); + else if (macio->type == macio_keylargo) + keylargo_shutdown(macio, 0); + + /* + * Put the host bridge to sleep + */ + + save_unin_clock_ctl = UN_IN(UNI_N_CLOCK_CNTL); + UN_OUT(UNI_N_CLOCK_CNTL, save_unin_clock_ctl & + ~(UNI_N_CLOCK_CNTL_GMAC|UNI_N_CLOCK_CNTL_FW/*|UNI_N_CLOCK_CNTL_PCI*/)); + udelay(100); + UN_OUT(UNI_N_HWINIT_STATE, UNI_N_HWINIT_STATE_SLEEPING); + UN_OUT(UNI_N_POWER_MGT, UNI_N_POWER_MGT_SLEEP); + + /* + * FIXME: A bit of black magic with OpenPIC (don't ask me why) + */ + if (pmac_mb.model_id == PMAC_TYPE_SAWTOOTH) { + MACIO_BIS(0x506e0, 0x00400000); + MACIO_BIS(0x506e0, 0x80000000); + } + return 0; +} + +static int __pmac +core99_wake_up(void) +{ + struct macio_chip* macio; + int i; + + macio = &macio_chips[0]; + if (macio->type != macio_keylargo && macio->type != macio_pangea) + return -ENODEV; + + /* + * Wakeup the host bridge + */ + UN_OUT(UNI_N_POWER_MGT, UNI_N_POWER_MGT_NORMAL); + udelay(10); + UN_OUT(UNI_N_HWINIT_STATE, UNI_N_HWINIT_STATE_RUNNING); + udelay(10); + + /* + * Restore KeyLargo + */ + + MACIO_OUT32(KEYLARGO_MBCR, save_mbcr); + (void)MACIO_IN32(KEYLARGO_MBCR); udelay(10); + MACIO_OUT32(KEYLARGO_FCR0, save_fcr[0]); + (void)MACIO_IN32(KEYLARGO_FCR0); udelay(10); + MACIO_OUT32(KEYLARGO_FCR1, save_fcr[1]); + (void)MACIO_IN32(KEYLARGO_FCR1); udelay(10); + MACIO_OUT32(KEYLARGO_FCR2, save_fcr[2]); + (void)MACIO_IN32(KEYLARGO_FCR2); udelay(10); + MACIO_OUT32(KEYLARGO_FCR3, save_fcr[3]); + (void)MACIO_IN32(KEYLARGO_FCR3); udelay(10); + MACIO_OUT32(KEYLARGO_FCR4, save_fcr[4]); + (void)MACIO_IN32(KEYLARGO_FCR4); udelay(10); + + dbdma_restore(macio, save_dbdma); + + MACIO_OUT32(KEYLARGO_GPIO_LEVELS0, save_gpio_levels[0]); + MACIO_OUT32(KEYLARGO_GPIO_LEVELS1, save_gpio_levels[1]); + for (i=0; i<KEYLARGO_GPIO_EXTINT_CNT; i++) + MACIO_OUT8(KEYLARGO_GPIO_EXTINT_0+i, save_gpio_extint[i]); + for (i=0; i<KEYLARGO_GPIO_CNT; i++) + MACIO_OUT8(KEYLARGO_GPIO_0+i, save_gpio_normal[i]); + + /* FIXME more black magic with OpenPIC ... */ + if (pmac_mb.model_id == PMAC_TYPE_SAWTOOTH) { + MACIO_BIC(0x506e0, 0x00400000); + MACIO_BIC(0x506e0, 0x80000000); + } + + UN_OUT(UNI_N_CLOCK_CNTL, save_unin_clock_ctl); + udelay(100); + + return 0; +} + +static int __pmac +core99_sleep_state(struct device_node* node, int param, int value) +{ + if ((pmac_mb.board_flags & PMAC_MB_CAN_SLEEP) == 0) + return -EPERM; + if (value == 1) + return core99_sleep(); + else if (value == 0) + return core99_wake_up(); + return 0; +} + +static int __pmac +pangea_modem_enable(struct device_node* node, int param, int value) +{ + struct macio_chip* macio; + u8 gpio; + unsigned long flags; + + macio = macio_find(node, 0); + if (!macio) + return -ENODEV; + gpio = MACIO_IN8(KL_GPIO_MODEM_RESET); + gpio |= KEYLARGO_GPIO_OUTPUT_ENABLE; + gpio &= ~KEYLARGO_GPIO_OUTOUT_DATA; + + if (!value) { + LOCK(flags); + MACIO_OUT8(KL_GPIO_MODEM_RESET, gpio); + UNLOCK(flags); + (void)MACIO_IN8(KL_GPIO_MODEM_RESET); + mdelay(250); + } + LOCK(flags); + if (value) { + MACIO_OUT8(KL_GPIO_MODEM_POWER, + KEYLARGO_GPIO_OUTPUT_ENABLE); + UNLOCK(flags); + (void)MACIO_IN32(KEYLARGO_FCR2); + mdelay(250); + } else { + MACIO_OUT8(KL_GPIO_MODEM_POWER, + KEYLARGO_GPIO_OUTPUT_ENABLE | KEYLARGO_GPIO_OUTOUT_DATA); + UNLOCK(flags); + } + if (value) { + LOCK(flags); + MACIO_OUT8(KL_GPIO_MODEM_RESET, gpio | KEYLARGO_GPIO_OUTOUT_DATA); + (void)MACIO_IN8(KL_GPIO_MODEM_RESET); + UNLOCK(flags); mdelay(250); LOCK(flags); + MACIO_OUT8(KL_GPIO_MODEM_RESET, gpio); + (void)MACIO_IN8(KL_GPIO_MODEM_RESET); + UNLOCK(flags); mdelay(250); LOCK(flags); + MACIO_OUT8(KL_GPIO_MODEM_RESET, gpio | KEYLARGO_GPIO_OUTOUT_DATA); + (void)MACIO_IN8(KL_GPIO_MODEM_RESET); + UNLOCK(flags); mdelay(250); LOCK(flags); + } + return 0; +} + + +static int __pmac +generic_get_mb_info(struct device_node* node, int param, int value) +{ + switch(param) { + case PMAC_MB_INFO_MODEL: + return pmac_mb.model_id; + case PMAC_MB_INFO_FLAGS: + return pmac_mb.board_flags; + case PMAC_MB_INFO_NAME: + /* hack hack hack... but should work */ + return (int)pmac_mb.model_name; + } + return 0; +} + + +/* + * Table definitions + */ + +/* Used on any machine + */ +static struct feature_table_entry any_features[] __pmacdata = { + { PMAC_FTR_GET_MB_INFO, generic_get_mb_info }, + { 0, NULL } +}; + +/* OHare based motherboards. Currently, we only use these on the + * 2400,3400 and 3500 series powerbooks. Some older desktops seem + * to have issues with turning on/off those asic cells + */ +static struct feature_table_entry ohare_features[] __pmacdata = { + { PMAC_FTR_SCC_ENABLE, ohare_scc_enable }, + { PMAC_FTR_SWIM3_ENABLE, ohare_floppy_enable }, + { PMAC_FTR_MESH_ENABLE, ohare_mesh_enable }, + { PMAC_FTR_IDE_ENABLE, ohare_ide_enable}, + { PMAC_FTR_IDE_RESET, ohare_ide_reset}, + { PMAC_FTR_SLEEP_STATE, ohare_sleep_state }, + { 0, NULL } +}; + +/* Heathrow desktop machines (Beige G3). + * Separated as some features couldn't be properly tested + * and the serial port control bits appear to confuse it. + */ +static struct feature_table_entry heathrow_desktop_features[] __pmacdata = { + { PMAC_FTR_SWIM3_ENABLE, heathrow_floppy_enable }, + { PMAC_FTR_MESH_ENABLE, heathrow_mesh_enable }, + { PMAC_FTR_IDE_ENABLE, heathrow_ide_enable }, + { PMAC_FTR_IDE_RESET, heathrow_ide_reset }, + { PMAC_FTR_BMAC_ENABLE, heathrow_bmac_enable }, + { 0, NULL } +}; + +/* Heathrow based laptop, that is the Wallstreet and mainstreet + * powerbooks. + */ +static struct feature_table_entry heathrow_laptop_features[] __pmacdata = { + { PMAC_FTR_SCC_ENABLE, heathrow_scc_enable }, + { PMAC_FTR_MODEM_ENABLE, heathrow_modem_enable }, + { PMAC_FTR_SWIM3_ENABLE, heathrow_floppy_enable }, + { PMAC_FTR_MESH_ENABLE, heathrow_mesh_enable }, + { PMAC_FTR_IDE_ENABLE, heathrow_ide_enable }, + { PMAC_FTR_IDE_RESET, heathrow_ide_reset }, + { PMAC_FTR_BMAC_ENABLE, heathrow_bmac_enable }, + { PMAC_FTR_SOUND_CHIP_ENABLE, heathrow_sound_enable }, + { PMAC_FTR_SLEEP_STATE, heathrow_sleep_state }, + { 0, NULL } +}; + +/* Paddington based machines + * The lombard (101) powerbook, first iMac models, B&W G3 and Yikes G4. + */ +static struct feature_table_entry paddington_features[] __pmacdata = { + { PMAC_FTR_SCC_ENABLE, heathrow_scc_enable }, + { PMAC_FTR_MODEM_ENABLE, heathrow_modem_enable }, + { PMAC_FTR_SWIM3_ENABLE, heathrow_floppy_enable }, + { PMAC_FTR_MESH_ENABLE, heathrow_mesh_enable }, + { PMAC_FTR_IDE_ENABLE, heathrow_ide_enable }, + { PMAC_FTR_IDE_RESET, heathrow_ide_reset }, + { PMAC_FTR_BMAC_ENABLE, heathrow_bmac_enable }, + { PMAC_FTR_SOUND_CHIP_ENABLE, heathrow_sound_enable }, + { PMAC_FTR_SLEEP_STATE, heathrow_sleep_state }, + { 0, NULL } +}; + +/* Core99 & MacRISC 2 machines (all machines released since the + * iBook (included), that is all AGP machines, except pangea + * chipset. The pangea chipset is the "combo" UniNorth/KeyLargo + * used on iBook2 & iMac "flow power". + */ +static struct feature_table_entry core99_features[] __pmacdata = { + { PMAC_FTR_SCC_ENABLE, core99_scc_enable }, + { PMAC_FTR_MODEM_ENABLE, core99_modem_enable }, + { PMAC_FTR_IDE_ENABLE, core99_ide_enable }, + { PMAC_FTR_IDE_RESET, core99_ide_reset }, + { PMAC_FTR_GMAC_ENABLE, core99_gmac_enable }, + { PMAC_FTR_GMAC_PHY_RESET, core99_gmac_phy_reset }, + { PMAC_FTR_SOUND_CHIP_ENABLE, core99_sound_chip_enable }, + { PMAC_FTR_AIRPORT_ENABLE, core99_airport_enable }, + { PMAC_FTR_USB_ENABLE, core99_usb_enable }, + { PMAC_FTR_1394_ENABLE, core99_firewire_enable }, + { PMAC_FTR_1394_CABLE_POWER, core99_firewire_cable_power }, + { PMAC_FTR_SLEEP_STATE, core99_sleep_state }, +#ifdef CONFIG_SMP + { PMAC_FTR_RESET_CPU, core99_reset_cpu }, +#endif /* CONFIG_SMP */ + { PMAC_FTR_READ_GPIO, core99_read_gpio }, + { PMAC_FTR_WRITE_GPIO, core99_write_gpio }, + { 0, NULL } +}; + +/* Pangea features + */ +static struct feature_table_entry pangea_features[] __pmacdata = { + { PMAC_FTR_SCC_ENABLE, core99_scc_enable }, + { PMAC_FTR_MODEM_ENABLE, pangea_modem_enable }, + { PMAC_FTR_IDE_ENABLE, core99_ide_enable }, + { PMAC_FTR_IDE_RESET, core99_ide_reset }, + { PMAC_FTR_GMAC_ENABLE, core99_gmac_enable }, + { PMAC_FTR_GMAC_PHY_RESET, core99_gmac_phy_reset }, + { PMAC_FTR_SOUND_CHIP_ENABLE, core99_sound_chip_enable }, + { PMAC_FTR_AIRPORT_ENABLE, core99_airport_enable }, + { PMAC_FTR_USB_ENABLE, core99_usb_enable }, + { PMAC_FTR_1394_ENABLE, core99_firewire_enable }, + { PMAC_FTR_1394_CABLE_POWER, core99_firewire_cable_power }, + { PMAC_FTR_SLEEP_STATE, core99_sleep_state }, + { PMAC_FTR_READ_GPIO, core99_read_gpio }, + { PMAC_FTR_WRITE_GPIO, core99_write_gpio }, + { 0, NULL } +}; + +static struct pmac_mb_def pmac_mb_defs[] __pmacdata = { + /* Warning: ordering is important as some models may claim + * beeing compatible with several types + */ + { "AAPL,8500", "PowerMac 8500/8600", + PMAC_TYPE_PSURGE, NULL, + 0 + }, + { "AAPL,9500", "PowerMac 9500/9600", + PMAC_TYPE_PSURGE, NULL, + 0 + }, + { "AAPL,7500", "PowerMac 7500", + PMAC_TYPE_PSURGE, NULL, + 0 + }, + { "AAPL,e407", "Alchemy", + PMAC_TYPE_ALCHEMY, NULL, + 0 + }, + { "AAPL,e411", "Gazelle", + PMAC_TYPE_GAZELLE, NULL, + 0 + }, + { "AAPL,3400/2400", "PowerBook 3400", + PMAC_TYPE_HOOPER, ohare_features, + PMAC_MB_CAN_SLEEP + }, + { "AAPL,3500", "PowerBook 3500", + PMAC_TYPE_KANGA, ohare_features, + PMAC_MB_CAN_SLEEP + }, + { "AAPL,Gossamer", "PowerMac G3 (Gossamer)", + PMAC_TYPE_GOSSAMER, heathrow_desktop_features, + 0 + }, + { "AAPL,PowerMac G3", "PowerMac G3 (Silk)", + PMAC_TYPE_SILK, heathrow_desktop_features, + 0 + }, + { "AAPL,PowerBook1998", "PowerBook Wallstreet", + PMAC_TYPE_WALLSTREET, heathrow_laptop_features, + PMAC_MB_CAN_SLEEP + }, + { "AAPL,PowerBook1,1", "PowerBook 101 (Lombard)", + PMAC_TYPE_101_PBOOK, paddington_features, + PMAC_MB_CAN_SLEEP + }, + { "iMac,1", "iMac (first generation)", + PMAC_TYPE_ORIG_IMAC, paddington_features, + 0 + }, + { "PowerMac4,1", "iMac \"Flower Power\"", + PMAC_TYPE_PANGEA_IMAC, pangea_features, + PMAC_MB_CAN_SLEEP + }, + { "PowerBook4,1", "iBook 2", + PMAC_TYPE_IBOOK2, pangea_features, + PMAC_MB_CAN_SLEEP + }, + { "PowerMac1,1", "Blue&White G3", + PMAC_TYPE_YOSEMITE, paddington_features, + 0 + }, + { "PowerMac1,2", "PowerMac G4 PCI Graphics", + PMAC_TYPE_YIKES, paddington_features, + 0 + }, + { "PowerBook2,1", "iBook (first generation)", + PMAC_TYPE_ORIG_IBOOK, core99_features, + PMAC_MB_CAN_SLEEP + }, + { "PowerMac3,1", "PowerMac G4 AGP Graphics", + PMAC_TYPE_SAWTOOTH, core99_features, + 0 + }, + { "PowerMac3,2", "PowerMac G4 AGP Graphics", + PMAC_TYPE_SAWTOOTH, core99_features, + 0 + }, + { "PowerMac3,3", "PowerMac G4 AGP Graphics", + PMAC_TYPE_SAWTOOTH, core99_features, + 0 + }, + { "PowerMac2,1", "iMac FireWire", + PMAC_TYPE_FW_IMAC, core99_features, + PMAC_MB_CAN_SLEEP + }, + { "PowerMac2,2", "iMac FireWire", + PMAC_TYPE_FW_IMAC, core99_features, + PMAC_MB_CAN_SLEEP + }, + { "PowerBook2,2", "iBook FireWire", + PMAC_TYPE_FW_IBOOK, core99_features, + PMAC_MB_CAN_SLEEP + }, + { "PowerMac5,1", "PowerMac G4 Cube", + PMAC_TYPE_CUBE, core99_features, + }, + { "PowerMac3,4", "PowerMac G4 Silver", + PMAC_TYPE_QUICKSILVER, core99_features, + 0 + }, + { "PowerMac3,5", "PowerMac G4 Silver", + PMAC_TYPE_QUICKSILVER, core99_features, + 0 + }, + { "PowerBook3,1", "PowerBook Pismo", + PMAC_TYPE_PISMO, core99_features, + PMAC_MB_CAN_SLEEP + }, + { "PowerBook3,2", "PowerBook Titanium", + PMAC_TYPE_TITANIUM, core99_features, + PMAC_MB_CAN_SLEEP + }, + { "PowerBook3,3", "PowerBook Titanium II", + PMAC_TYPE_TITANIUM2, core99_features, + PMAC_MB_CAN_SLEEP + }, +}; + +/* + * The toplevel feature_call callback + */ +int __pmac +pmac_do_feature_call(unsigned int selector, ...) +{ + struct device_node* node; + int param, value, i; + feature_call func = NULL; + va_list args; + + if (!pmac_mb.features) + return -ENODEV; + for (i=0; pmac_mb.features[i].function; i++) + if (pmac_mb.features[i].selector == selector) { + func = pmac_mb.features[i].function; + break; + } + if (!func) + for (i=0; any_features[i].function; i++) + if (any_features[i].selector == selector) { + func = any_features[i].function; + break; + } + if (!func) + return -ENODEV; + + va_start(args, selector); + node = (struct device_node*)va_arg(args, void*); + param = va_arg(args, int); + value = va_arg(args, int); + va_end(args); + + return func(node, param, value); +} + +static int __init +probe_motherboard(void) +{ + int i; + struct macio_chip* macio = &macio_chips[0]; + + /* Lookup known motherboard type in device-tree */ + for(i=0; i<(sizeof(pmac_mb_defs)/sizeof(struct pmac_mb_def)); i++) { + if (machine_is_compatible(pmac_mb_defs[i].model_string)) { + pmac_mb = pmac_mb_defs[i]; + goto found; + } + } + + /* Fallback to selection depending on mac-io chip type */ + switch(macio->type) { + case macio_grand_central: + pmac_mb.model_id = PMAC_TYPE_PSURGE; + pmac_mb.model_name = "Unknown PowerSurge"; + break; + case macio_ohare: + pmac_mb.model_id = PMAC_TYPE_UNKNOWN_OHARE; + pmac_mb.model_name = "Unknown OHare-based"; + break; + case macio_heathrow: + pmac_mb.model_id = PMAC_TYPE_UNKNOWN_HEATHROW; + pmac_mb.model_name = "Unknown Heathrow-based"; + pmac_mb.features = heathrow_desktop_features; + break; + case macio_paddington: + pmac_mb.model_id = PMAC_TYPE_UNKNOWN_PADDINGTON; + pmac_mb.model_name = "Unknown Paddington-based"; + pmac_mb.features = paddington_features; + break; + case macio_keylargo: + pmac_mb.model_id = PMAC_TYPE_UNKNOWN_CORE99; + pmac_mb.model_name = "Unknown Keylargo-based"; + pmac_mb.features = core99_features; + break; + case macio_pangea: + pmac_mb.model_id = PMAC_TYPE_UNKNOWN_PANGEA; + pmac_mb.model_name = "Unknown Pangea-based"; + pmac_mb.features = pangea_features; + break; + default: + return -ENODEV; + } +found: + /* Fixup Hooper vs. Comet */ + if (pmac_mb.model_id == PMAC_TYPE_HOOPER) { + u32* mach_id_ptr = (u32*)ioremap(0xf3000034, 4); + if (!mach_id_ptr) + return -ENODEV; + /* Here, I used to disable the media-bay on comet. It + * appears this is wrong, the floppy connector is actually + * a kind of media-bay and works with the current driver. + */ + if ((*mach_id_ptr) & 0x20000000UL) + pmac_mb.model_id = PMAC_TYPE_COMET; + iounmap(mach_id_ptr); + } + + /* Set default value of powersave_nap on machines that support it. + * It appears that uninorth rev 3 has a problem with it, we don't + * enable it on those. In theory, the flush-on-lock property is + * supposed to be set when not supported, but I'm not very confident + * that all Apple OF revs did it properly, I do it the paranoid way. + */ + while (uninorth_base && uninorth_rev > 3) { + struct device_node* np = find_path_device("/cpus"); + u32 pvr = mfspr(PVR); + if (!np || !np->child) { + printk(KERN_WARNING "Can't find CPU(s) in device tree !\n"); + break; + } + np = np->child; + /* Nap mode not supported on SMP */ + if (np->sibling) + break; + /* Nap mode not supported if flush-on-lock property is present */ + if (get_property(np, "flush-on-lock", NULL)) + break; + /* Some 7450 may have problem with NAP mode too ... */ + if (((pvr >> 16) == 0x8000) && ((pvr & 0xffff) < 0x0201)) + break; + powersave_nap = 1; + printk(KERN_INFO "Processor NAP mode on idle enabled.\n"); + break; + } + + printk(KERN_INFO "PowerMac motherboard: %s\n", pmac_mb.model_name); + return 0; +} + +/* Initialize the Core99 UniNorth host bridge and memory controller + */ +static void __init +probe_uninorth(void) +{ + unsigned long actrl; + + /* Locate core99 Uni-N */ + uninorth_node = find_devices("uni-n"); + if (uninorth_node && uninorth_node->n_addrs > 0) { + uninorth_base = ioremap(uninorth_node->addrs[0].address, 0x1000); + uninorth_rev = in_be32(UN_REG(UNI_N_VERSION)); + } else + uninorth_node = NULL; + + if (!uninorth_node) + return; + + printk(KERN_INFO "Found Uninorth memory controller & host bridge, revision: %d\n", + uninorth_rev); + + /* Set the arbitrer QAck delay according to what Apple does + */ + if (uninorth_rev < 0x10) { + actrl = UN_IN(UNI_N_ARB_CTRL) & ~UNI_N_ARB_CTRL_QACK_DELAY_MASK; + actrl |= ((uninorth_rev < 3) ? UNI_N_ARB_CTRL_QACK_DELAY105 : + UNI_N_ARB_CTRL_QACK_DELAY) << UNI_N_ARB_CTRL_QACK_DELAY_SHIFT; + UN_OUT(UNI_N_ARB_CTRL, actrl); + } +} + +static void __init +probe_one_macio(const char* name, const char* compat, int type) +{ + struct device_node* node; + int i; + volatile u32* base; + u32* revp; + + node = find_devices(name); + if (!node || !node->n_addrs) + return; + if (compat) + do { + if (device_is_compatible(node, compat)) + break; + node = node->next; + } while (node); + if (!node) + return; + for(i=0; i<MAX_MACIO_CHIPS; i++) { + if (!macio_chips[i].of_node) + break; + if (macio_chips[i].of_node == node) + return; + } + if (i >= MAX_MACIO_CHIPS) { + printk(KERN_ERR "pmac_feature: Please increase MAX_MACIO_CHIPS !\n"); + printk(KERN_ERR "pmac_feature: %s skipped\n", node->full_name); + return; + } + base = (volatile u32*)ioremap(node->addrs[0].address, node->addrs[0].size); + if (!base) { + printk(KERN_ERR "pmac_feature: Can't map mac-io chip !\n"); + return; + } + if (type == macio_keylargo) { + u32* did = (u32 *)get_property(node, "device-id", NULL); + if (*did == 0x00000025) + type = macio_pangea; + } + macio_chips[i].of_node = node; + macio_chips[i].type = type; + macio_chips[i].base = base; + macio_chips[i].flags = MACIO_FLAG_SCCB_ON | MACIO_FLAG_SCCB_ON; + revp = (u32 *)get_property(node, "revision-id", NULL); + if (revp) + macio_chips[i].rev = *revp; + printk(KERN_INFO "Found a %s mac-io controller, rev: %d, mapped at 0x%p\n", + macio_names[type], macio_chips[i].rev, macio_chips[i].base); +} + +static int __init +probe_macios(void) +{ + /* Warning, ordering is important */ + probe_one_macio("gc", NULL, macio_grand_central); + probe_one_macio("ohare", NULL, macio_ohare); + probe_one_macio("pci106b,7", NULL, macio_ohareII); + probe_one_macio("mac-io", "keylargo", macio_keylargo); + probe_one_macio("mac-io", "paddington", macio_paddington); + probe_one_macio("mac-io", "gatwick", macio_gatwick); + probe_one_macio("mac-io", "heathrow", macio_heathrow); + + /* Make sure the "main" macio chip appear first */ + if (macio_chips[0].type == macio_gatwick + && macio_chips[1].type == macio_heathrow) { + struct macio_chip temp = macio_chips[0]; + macio_chips[0] = macio_chips[1]; + macio_chips[1] = temp; + } + if (macio_chips[0].type == macio_ohareII + && macio_chips[1].type == macio_ohare) { + struct macio_chip temp = macio_chips[0]; + macio_chips[0] = macio_chips[1]; + macio_chips[1] = temp; + } + + return (macio_chips[0].of_node == NULL) ? -ENODEV : 0; +} + +static void __init +set_initial_features(void) +{ + struct device_node* np; + + /* That hack appears to be necessary for some StarMax motherboards + * but I'm not too sure it was audited for side-effects on other + * ohare based machines... + * Since I still have difficulties figuring the right way to + * differenciate them all and since that hack was there for a long + * time, I'll keep it around + */ + if (macio_chips[0].type == macio_ohare && !find_devices("via-pmu")) { + struct macio_chip* macio = &macio_chips[0]; + MACIO_OUT32(OHARE_FCR, STARMAX_FEATURES); + } else if (macio_chips[0].type == macio_ohare) { + struct macio_chip* macio = &macio_chips[0]; + MACIO_BIS(OHARE_FCR, OH_IOBUS_ENABLE); + } else if (macio_chips[1].type == macio_ohare) { + struct macio_chip* macio = &macio_chips[1]; + MACIO_BIS(OHARE_FCR, OH_IOBUS_ENABLE); + } + + if (macio_chips[0].type == macio_keylargo || + macio_chips[0].type == macio_pangea) { + /* Enable GMAC for now for PCI probing. It will be disabled + * later on after PCI probe + */ + np = find_devices("ethernet"); + while(np) { + if (np && device_is_compatible(np, "gmac")) + core99_gmac_enable(np, 0, 1); + np = np->next; + } + + /* Enable FW before PCI probe. Will be disabled later on + */ + np = find_devices("firewire"); + while(np) { + if (device_is_compatible(np, "pci106b,18") || + device_is_compatible(np, "pci106b,30")) { + macio_chips[0].flags |= MACIO_FLAG_FW_SUPPORTED; + core99_firewire_enable(np, 0, 1); + } + np = np->next; + } + + /* Switch airport off */ + np = find_devices("radio"); + while(np) { + if (np && np->parent == macio_chips[0].of_node) { + macio_chips[0].flags |= MACIO_FLAG_AIRPORT_ON; + core99_airport_enable(np, 0, 0); + } + np = np->next; + } + } + + /* On all machines, switch sound off */ + if (macio_chips[0].of_node) + pmac_do_feature_call(PMAC_FTR_SOUND_CHIP_ENABLE, + macio_chips[0].of_node, 0, 0); + + /* Let hardware settle down */ + mdelay(1); +} + +void __init +pmac_feature_init(void) +{ + /* Detect the UniNorth memory controller */ + probe_uninorth(); + + /* Probe mac-io controllers */ + if (probe_macios()) { + printk(KERN_WARNING "No mac-io chip found\n"); + return; + } + + /* Probe machine type */ + if (probe_motherboard()) + printk(KERN_WARNING "Unknown PowerMac !\n"); + + /* Set some initial features (turn off some chips that will + * be later turned on) + */ + set_initial_features(); +} + +void __init +pmac_feature_late_init(void) +{ + struct device_node* np; + + /* Request some resources late */ + if (uninorth_node) + request_OF_resource(uninorth_node, 0, NULL); + np = find_devices("hammerhead"); + if (np) + request_OF_resource(np, 0, NULL); + np = find_devices("interrupt-controller"); + if (np) + request_OF_resource(np, 0, NULL); +} diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/ppc/kernel/pmac_nvram.c linux-2.5/arch/ppc/kernel/pmac_nvram.c --- linux-2.5.1/arch/ppc/kernel/pmac_nvram.c Sat Sep 8 19:38:41 2001 +++ linux-2.5/arch/ppc/kernel/pmac_nvram.c Thu Dec 27 16:32:30 2001 @@ -1,5 +1,5 @@ /* - * BK Id: SCCS/s.pmac_nvram.c 1.15 09/08/01 15:47:42 paulus + * BK Id: SCCS/s.pmac_nvram.c 1.17 12/01/01 20:09:06 benh */ /* * Miscellaneous procedures for dealing with the PowerMac hardware. @@ -326,7 +326,7 @@ break; while (!req.complete) pmu_poll(); - return req.reply[1]; + return req.reply[0]; } #endif case 1: diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/ppc/kernel/pmac_pci.c linux-2.5/arch/ppc/kernel/pmac_pci.c --- linux-2.5.1/arch/ppc/kernel/pmac_pci.c Sat Sep 8 19:38:41 2001 +++ linux-2.5/arch/ppc/kernel/pmac_pci.c Thu Dec 27 16:32:30 2001 @@ -1,5 +1,5 @@ /* - * BK Id: SCCS/s.pmac_pci.c 1.27 09/08/01 15:47:42 paulus + * BK Id: SCCS/s.pmac_pci.c 1.29 12/01/01 20:09:06 benh */ /* * Support for PCI bridges found on Power Macintoshes. @@ -27,7 +27,7 @@ #include <asm/prom.h> #include <asm/pci-bridge.h> #include <asm/machdep.h> -#include <asm/feature.h> +#include <asm/pmac_feature.h> #include "pci.h" @@ -545,13 +545,13 @@ if (node && !strcmp(node->name, "firewire") && (device_is_compatible(node, "pci106b,18") || device_is_compatible(node, "pci106b,30"))) { - feature_set_firewire_cable_power(node, 1); - feature_set_firewire_power(node, 1); + pmac_call_feature(PMAC_FTR_1394_CABLE_POWER, node, 0, 1); + pmac_call_feature(PMAC_FTR_1394_ENABLE, node, 0, 1); updatecfg = 1; } if (node && !strcmp(node->name, "ethernet") && device_is_compatible(node, "gmac")) { - feature_set_gmac_power(node, 1); + pmac_call_feature(PMAC_FTR_GMAC_ENABLE, node, 0, 1); updatecfg = 1; } @@ -610,8 +610,8 @@ if (nd->parent && (device_is_compatible(nd, "pci106b,18") || device_is_compatible(nd, "pci106b,30")) && device_is_compatible(nd->parent, "uni-north")) { - feature_set_firewire_power(nd, 0); - feature_set_firewire_cable_power(nd, 0); + pmac_call_feature(PMAC_FTR_1394_ENABLE, nd, 0, 0); + pmac_call_feature(PMAC_FTR_1394_CABLE_POWER, nd, 0, 0); } nd = nd->next; } @@ -619,7 +619,7 @@ while (nd) { if (nd->parent && device_is_compatible(nd, "gmac") && device_is_compatible(nd->parent, "uni-north")) - feature_set_gmac_power(nd, 0); + pmac_call_feature(PMAC_FTR_GMAC_ENABLE, nd, 0, 0); nd = nd->next; } } diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/ppc/kernel/pmac_pic.c linux-2.5/arch/ppc/kernel/pmac_pic.c --- linux-2.5.1/arch/ppc/kernel/pmac_pic.c Mon Dec 10 21:52:53 2001 +++ linux-2.5/arch/ppc/kernel/pmac_pic.c Thu Dec 27 16:32:30 2001 @@ -1,5 +1,5 @@ /* - * BK Id: SCCS/s.pmac_pic.c 1.20 09/08/01 15:47:42 paulus + * BK Id: SCCS/s.pmac_pic.c 1.24 12/19/01 10:53:01 paulus */ #include <linux/config.h> #include <linux/stddef.h> @@ -18,44 +18,52 @@ #include "pmac_pic.h" #include "open_pic.h" -/* pmac */struct pmac_irq_hw { - unsigned int flag; +struct pmac_irq_hw { + unsigned int event; unsigned int enable; unsigned int ack; unsigned int level; }; -/* XXX these addresses should be obtained from the device tree */ -static volatile struct pmac_irq_hw *pmac_irq_hw[4] = { +/* Default addresses */ +static volatile struct pmac_irq_hw *pmac_irq_hw[4] __pmacdata = { (struct pmac_irq_hw *) 0xf3000020, (struct pmac_irq_hw *) 0xf3000010, (struct pmac_irq_hw *) 0xf4000020, (struct pmac_irq_hw *) 0xf4000010, }; -static int max_irqs; -static int max_real_irqs; +#define GC_LEVEL_MASK 0x3ff00000 +#define OHARE_LEVEL_MASK 0x1ff00000 +#define HEATHROW_LEVEL_MASK 0x1ff00000 + +static int max_irqs __pmacdata; +static int max_real_irqs __pmacdata; +static u32 level_mask[4] __pmacdata; -static spinlock_t pmac_pic_lock = SPIN_LOCK_UNLOCKED; +static spinlock_t pmac_pic_lock __pmacdata = SPIN_LOCK_UNLOCKED; #define GATWICK_IRQ_POOL_SIZE 10 -static struct interrupt_info gatwick_int_pool[GATWICK_IRQ_POOL_SIZE]; +static struct interrupt_info gatwick_int_pool[GATWICK_IRQ_POOL_SIZE] __pmacdata; /* * Mark an irq as "lost". This is only used on the pmac * since it can lose interrupts (see pmac_set_irq_mask). * -- Cort */ -void __pmac __set_lost(unsigned long irq_nr) +void __pmac +__set_lost(unsigned long irq_nr, int nokick) { if (!test_and_set_bit(irq_nr, ppc_lost_interrupts)) { atomic_inc(&ppc_n_lost_interrupts); - set_dec(1); + if (!nokick) + set_dec(1); } } -static void __pmac pmac_mask_and_ack_irq(unsigned int irq_nr) +static void __pmac +pmac_mask_and_ack_irq(unsigned int irq_nr) { unsigned long bit = 1UL << (irq_nr & 0x1f); int i = irq_nr >> 5; @@ -68,18 +76,18 @@ if (test_and_clear_bit(irq_nr, ppc_lost_interrupts)) atomic_dec(&ppc_n_lost_interrupts); spin_lock_irqsave(&pmac_pic_lock, flags); - out_le32(&pmac_irq_hw[i]->ack, bit); out_le32(&pmac_irq_hw[i]->enable, ppc_cached_irq_mask[i]); out_le32(&pmac_irq_hw[i]->ack, bit); do { /* make sure ack gets to controller before we enable interrupts */ mb(); - } while(in_le32(&pmac_irq_hw[i]->flag) & bit); + } while((in_le32(&pmac_irq_hw[i]->enable) & bit) + != (ppc_cached_irq_mask[i] & bit)); spin_unlock_irqrestore(&pmac_pic_lock, flags); } -static void __pmac pmac_set_irq_mask(unsigned int irq_nr) +static void __pmac pmac_set_irq_mask(unsigned int irq_nr, int nokicklost) { unsigned long bit = 1UL << (irq_nr & 0x1f); int i = irq_nr >> 5; @@ -104,31 +112,29 @@ * when the device interrupt is already on *doesn't* set * the bit in the flag register or request another interrupt. */ - if ((bit & ppc_cached_irq_mask[i]) - && (ld_le32(&pmac_irq_hw[i]->level) & bit) - && !(ld_le32(&pmac_irq_hw[i]->flag) & bit)) - __set_lost((ulong)irq_nr); + if (bit & ppc_cached_irq_mask[i] & in_le32(&pmac_irq_hw[i]->level)) + __set_lost((ulong)irq_nr, nokicklost); spin_unlock_irqrestore(&pmac_pic_lock, flags); } static void __pmac pmac_mask_irq(unsigned int irq_nr) { clear_bit(irq_nr, ppc_cached_irq_mask); - pmac_set_irq_mask(irq_nr); + pmac_set_irq_mask(irq_nr, 0); mb(); } static void __pmac pmac_unmask_irq(unsigned int irq_nr) { set_bit(irq_nr, ppc_cached_irq_mask); - pmac_set_irq_mask(irq_nr); + pmac_set_irq_mask(irq_nr, 0); } static void __pmac pmac_end_irq(unsigned int irq_nr) { if (!(irq_desc[irq_nr].status & (IRQ_DISABLED|IRQ_INPROGRESS))) { set_bit(irq_nr, ppc_cached_irq_mask); - pmac_set_irq_mask(irq_nr); + pmac_set_irq_mask(irq_nr, 1); } } @@ -161,8 +167,10 @@ for (irq = max_irqs; (irq -= 32) >= max_real_irqs; ) { int i = irq >> 5; - bits = ld_le32(&pmac_irq_hw[i]->flag) - | ppc_lost_interrupts[i]; + bits = in_le32(&pmac_irq_hw[i]->event) | ppc_lost_interrupts[i]; + /* We must read level interrupts from the level register */ + bits |= (in_le32(&pmac_irq_hw[i]->level) & level_mask[i]); + bits &= ppc_cached_irq_mask[i]; if (bits == 0) continue; irq += __ilog2(bits); @@ -195,8 +203,10 @@ #endif /* CONFIG_SMP */ for (irq = max_real_irqs; (irq -= 32) >= 0; ) { int i = irq >> 5; - bits = ld_le32(&pmac_irq_hw[i]->flag) - | ppc_lost_interrupts[i]; + bits = in_le32(&pmac_irq_hw[i]->event) | ppc_lost_interrupts[i]; + /* We must read level interrupts from the level register */ + bits |= (in_le32(&pmac_irq_hw[i]->level) & level_mask[i]); + bits &= ppc_cached_irq_mask[i]; if (bits == 0) continue; irq += __ilog2(bits); @@ -374,6 +384,24 @@ irqctrler = NULL; } + /* Get the level/edge settings, assume if it's not + * a Grand Central nor an OHare, then it's an Heathrow + * (or Paddington). + */ + if (find_devices("gc")) + level_mask[0] = GC_LEVEL_MASK; + else if (find_devices("ohare")) { + level_mask[0] = OHARE_LEVEL_MASK; + /* We might have a second cascaded ohare */ + level_mask[1] = OHARE_LEVEL_MASK; + } else { + level_mask[0] = HEATHROW_LEVEL_MASK; + level_mask[1] = 0; + /* We might have a second cascaded heathrow */ + level_mask[2] = HEATHROW_LEVEL_MASK; + level_mask[3] = 0; + } + /* * G3 powermacs and 1999 G3 PowerBooks have 64 interrupts, * 1998 G3 Series PowerBooks have 128, @@ -433,6 +461,10 @@ /* disable all interrupts in all controllers */ for (i = 0; i * 32 < max_irqs; ++i) out_le32(&pmac_irq_hw[i]->enable, 0); + /* mark level interrupts */ + for (i = 0; i < max_irqs; i++) + if (level_mask[i >> 5] & (1UL << (i & 0x1f))) + irq_desc[i].status = IRQ_LEVEL; /* get interrupt line of secondary interrupt controller */ if (irq_cascade >= 0) { @@ -474,7 +506,7 @@ out_le32(&pmac_irq_hw[0]->enable, ppc_cached_irq_mask[0]); if (max_real_irqs > 32) out_le32(&pmac_irq_hw[1]->enable, ppc_cached_irq_mask[1]); - (void)in_le32(&pmac_irq_hw[0]->flag); + (void)in_le32(&pmac_irq_hw[0]->event); /* make sure mask gets to controller before we return to caller */ mb(); (void)in_le32(&pmac_irq_hw[0]->enable); diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/ppc/kernel/pmac_setup.c linux-2.5/arch/ppc/kernel/pmac_setup.c --- linux-2.5.1/arch/ppc/kernel/pmac_setup.c Fri Nov 16 18:10:08 2001 +++ linux-2.5/arch/ppc/kernel/pmac_setup.c Thu Dec 27 16:32:30 2001 @@ -1,5 +1,5 @@ /* - * BK Id: SCCS/s.pmac_setup.c 1.43 11/13/01 21:26:07 paulus + * BK Id: SCCS/s.pmac_setup.c 1.45 12/01/01 20:09:06 benh */ /* * linux/arch/ppc/kernel/setup.c @@ -61,7 +61,6 @@ #include <asm/pci-bridge.h> #include <asm/ohare.h> #include <asm/mediabay.h> -#include <asm/feature.h> #include <asm/machdep.h> #include <asm/keyboard.h> #include <asm/dma.h> @@ -69,6 +68,7 @@ #include <asm/cputable.h> #include <asm/btext.h> +#include <asm/pmac_feature.h> #include <asm/time.h> #include "local_irq.h" #include "pmac_pic.h" @@ -83,6 +83,10 @@ extern void pmac_calibrate_decr(void); extern void pmac_pcibios_fixup(void); extern void pmac_find_bridges(void); +extern int pmac_ide_check_base(ide_ioreg_t base); +extern ide_ioreg_t pmac_ide_get_base(int index); +extern void pmac_ide_init_hwif_ports(hw_regs_t *hw, + ide_ioreg_t data_port, ide_ioreg_t ctrl_port, int *irq); extern int mackbd_setkeycode(unsigned int scancode, unsigned int keycode); extern int mackbd_getkeycode(unsigned int scancode); @@ -436,7 +440,8 @@ #endif #ifdef CONFIG_PMAC_PBOOK media_bay_init(); -#endif +#endif + pmac_feature_late_init(); } #ifdef CONFIG_SCSI @@ -604,14 +609,11 @@ static int __pmac pmac_ide_check_region(ide_ioreg_t from, unsigned int extent) { - /* - * We only do the check_region if `from' looks like a genuine - * I/O port number. If it actually refers to a memory-mapped - * register, it should be OK. - */ - if (from < ~_IO_BASE) - return check_region(from, extent); - return 0; +#ifdef CONFIG_BLK_DEV_IDE_PMAC + if (pmac_ide_check_base(from) >= 0) + return 0; +#endif + return check_region(from, extent); } static void __pmac @@ -619,24 +621,31 @@ unsigned int extent, const char *name) { - if (from < ~_IO_BASE) - request_region(from, extent, name); +#ifdef CONFIG_BLK_DEV_IDE_PMAC + if (pmac_ide_check_base(from) >= 0) + return; +#endif + request_region(from, extent, name); } static void __pmac pmac_ide_release_region(ide_ioreg_t from, unsigned int extent) { - if (from < ~_IO_BASE) - release_region(from, extent); +#ifdef CONFIG_BLK_DEV_IDE_PMAC + if (pmac_ide_check_base(from) >= 0) + return; +#endif + release_region(from, extent); } +#ifndef CONFIG_BLK_DEV_IDE_PMAC /* * This is only used if we have a PCI IDE controller, not * for the IDE controller in the ohare/paddington/heathrow/keylargo. */ static void __pmac -pmac_ide_init_hwif_ports(hw_regs_t *hw, ide_ioreg_t data_port, +pmac_ide_pci_init_hwif_ports(hw_regs_t *hw, ide_ioreg_t data_port, ide_ioreg_t ctrl_port, int *irq) { ide_ioreg_t reg = data_port; @@ -648,7 +657,8 @@ } hw->io_ports[IDE_CONTROL_OFFSET] = ctrl_port; } -#endif +#endif /* CONFIG_BLK_DEV_IDE_PMAC */ +#endif /* defined(CONFIG_BLK_DEV_IDE) || defined(CONFIG_BLK_DEV_IDE_MODULE) */ /* * Read in a property describing some pieces of memory. @@ -806,14 +816,21 @@ ppc_md.find_end_of_memory = pmac_find_end_of_memory; + ppc_md.feature_call = pmac_do_feature_call; + select_adb_keyboard(); -#if defined(CONFIG_BLK_DEV_IDE) && defined(CONFIG_BLK_DEV_IDE_PMAC) +#if defined(CONFIG_BLK_DEV_IDE) || defined(CONFIG_BLK_DEV_IDE_MODULE) ppc_ide_md.ide_check_region = pmac_ide_check_region; ppc_ide_md.ide_request_region = pmac_ide_request_region; ppc_ide_md.ide_release_region = pmac_ide_release_region; +#ifdef CONFIG_BLK_DEV_IDE_PMAC ppc_ide_md.ide_init_hwif = pmac_ide_init_hwif_ports; -#endif /* CONFIG_BLK_DEV_IDE && CONFIG_BLK_DEV_IDE_PMAC */ + ppc_ide_md.default_io_base = pmac_ide_get_base; +#else /* CONFIG_BLK_DEV_IDE_PMAC */ + ppc_ide_md.ide_init_hwif = pmac_ide_pci_init_hwif_ports; +#endif /* CONFIG_BLK_DEV_IDE_PMAC */ +#endif /* defined(CONFIG_BLK_DEV_IDE) || defined(CONFIG_BLK_DEV_IDE_MODULE) */ #ifdef CONFIG_BOOTX_TEXT ppc_md.progress = pmac_progress; diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/ppc/kernel/pmac_smp.c linux-2.5/arch/ppc/kernel/pmac_smp.c --- linux-2.5.1/arch/ppc/kernel/pmac_smp.c Sat Sep 8 19:38:42 2001 +++ linux-2.5/arch/ppc/kernel/pmac_smp.c Thu Dec 27 16:32:30 2001 @@ -43,7 +43,8 @@ #include <asm/prom.h> #include <asm/smp.h> #include <asm/residual.h> -#include <asm/feature.h> +#include <asm/machdep.h> +#include <asm/pmac_feature.h> #include <asm/time.h> #include <asm/gemini.h> @@ -442,7 +443,7 @@ flush_icache_range((unsigned long) vector, (unsigned long) vector + 4); /* Put some life in our friend */ - feature_core99_kick_cpu(nr); + pmac_call_feature(PMAC_FTR_RESET_CPU, NULL, nr, 0); /* FIXME: We wait a bit for the CPU to take the exception, I should * instead wait for the entry code to set something for me. Well, diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/ppc/kernel/pmac_time.c linux-2.5/arch/ppc/kernel/pmac_time.c --- linux-2.5.1/arch/ppc/kernel/pmac_time.c Sat Sep 8 19:38:42 2001 +++ linux-2.5/arch/ppc/kernel/pmac_time.c Thu Dec 27 16:32:30 2001 @@ -1,5 +1,5 @@ /* - * BK Id: SCCS/s.pmac_time.c 1.16 09/08/01 15:47:42 paulus + * BK Id: SCCS/s.pmac_time.c 1.19 12/04/01 01:24:51 benh */ /* * Support for periodic interrupts (100 per second) and for getting @@ -110,11 +110,11 @@ return 0; while (!req.complete) pmu_poll(); - if (req.reply_len != 5) + if (req.reply_len != 4) printk(KERN_ERR "pmac_get_rtc_time: got %d byte reply\n", req.reply_len); - now = (req.reply[1] << 24) + (req.reply[2] << 16) - + (req.reply[3] << 8) + req.reply[4]; + now = (req.reply[0] << 24) + (req.reply[1] << 16) + + (req.reply[2] << 8) + req.reply[3]; return now - RTC_OFFSET; #endif /* CONFIG_ADB_PMU */ default: ; @@ -228,10 +228,6 @@ case PBOOK_WAKE: write_lock_irqsave(&xtime_lock, flags); xtime.tv_sec = pmac_get_rtc_time() + time_diff; - set_dec(tb_ticks_per_jiffy); - /* No currently-supported powerbook has a 601, - so use get_tbl, not native */ - last_jiffy_stamp(0) = tb_last_stamp = get_tbl(); xtime.tv_usec = 0; last_rtc_update = xtime.tv_sec; write_unlock_irqrestore(&xtime_lock, flags); diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/ppc/kernel/ppc8xx_pic.c linux-2.5/arch/ppc/kernel/ppc8xx_pic.c --- linux-2.5.1/arch/ppc/kernel/ppc8xx_pic.c Tue May 22 00:04:47 2001 +++ linux-2.5/arch/ppc/kernel/ppc8xx_pic.c Thu Dec 27 16:32:30 2001 @@ -1,5 +1,5 @@ /* - * BK Id: SCCS/s.ppc8xx_pic.c 1.10 05/17/01 18:14:21 cort + * BK Id: SCCS/s.ppc8xx_pic.c 1.13 12/01/01 17:19:48 trini */ #include <linux/config.h> #include <linux/stddef.h> @@ -44,6 +44,21 @@ ppc_cached_irq_mask[word]; } +static void m8xx_end_irq(unsigned int irq_nr) +{ + if (!(irq_desc[irq_nr].status & (IRQ_DISABLED|IRQ_INPROGRESS))) { + int bit, word; + + bit = irq_nr & 0x1f; + word = irq_nr >> 5; + + ppc_cached_irq_mask[word] |= (1 << (31-bit)); + ((immap_t *)IMAP_ADDR)->im_siu_conf.sc_simask = + ppc_cached_irq_mask[word]; + } +} + + static void m8xx_mask_and_ack(unsigned int irq_nr) { int bit, word; @@ -64,6 +79,7 @@ m8xx_unmask_irq, m8xx_mask_irq, m8xx_mask_and_ack, + m8xx_end_irq, 0 }; @@ -97,19 +113,26 @@ #endif +/* + * We either return a valid interrupt or -1 if there is nothing pending + */ int m8xx_get_irq(struct pt_regs *regs) { int irq; - unsigned long bits = 0; - /* For MPC8xx, read the SIVEC register and shift the bits down - * to get the irq number. */ - bits = ((immap_t *)IMAP_ADDR)->im_siu_conf.sc_sivec; - irq = bits >> 26; -#if 0 - irq += ppc8xx_pic.irq_offset; -#endif + /* For MPC8xx, read the SIVEC register and shift the bits down + * to get the irq number. + */ + irq = ((immap_t *)IMAP_ADDR)->im_siu_conf.sc_sivec >> 26; + + /* + * When we read the sivec without an interrupt to process, we will + * get back SIU_LEVEL7. In this case, return -1 + */ + if (irq == SIU_LEVEL7) + return -1; + return irq; } diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/ppc/kernel/ppc_ksyms.c linux-2.5/arch/ppc/kernel/ppc_ksyms.c --- linux-2.5.1/arch/ppc/kernel/ppc_ksyms.c Fri Nov 16 18:10:08 2001 +++ linux-2.5/arch/ppc/kernel/ppc_ksyms.c Thu Dec 27 16:32:30 2001 @@ -1,5 +1,5 @@ /* - * BK Id: SCCS/s.ppc_ksyms.c 1.59 11/04/01 22:58:20 paulus + * BK Id: SCCS/s.ppc_ksyms.c 1.61 12/01/01 20:09:06 benh */ #include <linux/config.h> #include <linux/module.h> @@ -36,7 +36,7 @@ #include <asm/system.h> #include <asm/pci-bridge.h> #include <asm/irq.h> -#include <asm/feature.h> +#include <asm/pmac_feature.h> #include <asm/dma.h> #include <asm/machdep.h> #include <asm/hw_irq.h> @@ -247,6 +247,8 @@ EXPORT_SYMBOL(machine_is_compatible); EXPORT_SYMBOL(find_all_nodes); EXPORT_SYMBOL(get_property); +EXPORT_SYMBOL(request_OF_resource); +EXPORT_SYMBOL(release_OF_resource); EXPORT_SYMBOL(pci_bus_io_base); EXPORT_SYMBOL(pci_bus_io_base_phys); EXPORT_SYMBOL(pci_bus_mem_base_phys); @@ -257,16 +259,6 @@ EXPORT_SYMBOL(pci_phys_to_bus); EXPORT_SYMBOL(pci_bus_to_phys); EXPORT_SYMBOL(pmac_newworld); -EXPORT_SYMBOL(feature_set); -EXPORT_SYMBOL(feature_clear); -EXPORT_SYMBOL(feature_test); -EXPORT_SYMBOL(feature_set_gmac_power); -EXPORT_SYMBOL(feature_gmac_phy_reset); -EXPORT_SYMBOL(feature_set_usb_power); -EXPORT_SYMBOL(feature_set_firewire_power); -EXPORT_SYMBOL(feature_set_firewire_cable_power); -EXPORT_SYMBOL(feature_set_modem_power); -EXPORT_SYMBOL(feature_set_airport_power); #endif /* defined(CONFIG_ALL_PPC) */ #if defined(CONFIG_BOOTX_TEXT) EXPORT_SYMBOL(btext_update_display); @@ -319,7 +311,9 @@ EXPORT_SYMBOL(get_wchan); EXPORT_SYMBOL(console_drivers); #ifdef CONFIG_XMON +extern void xmon_printf(char *fmt, ...); EXPORT_SYMBOL(xmon); +EXPORT_SYMBOL(xmon_printf); #endif EXPORT_SYMBOL(__up); EXPORT_SYMBOL(__down); @@ -361,3 +355,8 @@ extern long *ret_from_intercept; EXPORT_SYMBOL(ret_from_intercept); EXPORT_SYMBOL(cur_cpu_spec); +#if defined(CONFIG_ALL_PPC) +extern unsigned long agp_special_page; +EXPORT_SYMBOL_NOVERS(agp_special_page); +#endif /* defined(CONFIG_ALL_PPC) */ + diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/ppc/kernel/prep_pci.c linux-2.5/arch/ppc/kernel/prep_pci.c --- linux-2.5.1/arch/ppc/kernel/prep_pci.c Mon Oct 15 20:35:26 2001 +++ linux-2.5/arch/ppc/kernel/prep_pci.c Thu Dec 27 16:32:30 2001 @@ -1,5 +1,5 @@ /* - * BK Id: SCCS/s.prep_pci.c 1.31 10/05/01 17:48:18 trini + * BK Id: SCCS/s.prep_pci.c 1.33 12/20/01 15:36:12 trini */ /* * PReP pci functions. @@ -1190,6 +1190,27 @@ } static void __init +prep_pcibios_after_init(void) +{ + struct pci_dev *dev; + + /* If there is a WD 90C, reset the IO BAR to 0x0 (it started that + * way, but the PCI layer relocated it because it thought 0x0 was + * invalid for a BAR). + * If you don't do this, the card's VGA base will be <IO BAR>+0xc0000 + * instead of 0xc0000. vgacon.c (for example) is completely unaware of + * this little quirk. + */ + dev = pci_find_device(PCI_VENDOR_ID_WD, PCI_DEVICE_ID_WD_90C, NULL); + if (dev) { + dev->resource[1].end -= dev->resource[1].start; + dev->resource[1].start = 0; + /* tell the hardware */ + pci_write_config_dword(dev, PCI_BASE_ADDRESS_1, 0x0); + } +} + +static void __init prep_init_resource(struct resource *res, unsigned long start, unsigned long end, int flags) { @@ -1246,4 +1267,5 @@ } ppc_md.pcibios_fixup = prep_pcibios_fixup; + ppc_md.pcibios_after_init = prep_pcibios_after_init; } diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/ppc/kernel/prep_setup.c linux-2.5/arch/ppc/kernel/prep_setup.c --- linux-2.5.1/arch/ppc/kernel/prep_setup.c Fri Nov 16 18:10:08 2001 +++ linux-2.5/arch/ppc/kernel/prep_setup.c Thu Dec 27 16:32:30 2001 @@ -1,5 +1,5 @@ /* - * BK Id: SCCS/s.prep_setup.c 1.44 11/13/01 21:26:07 paulus + * BK Id: SCCS/s.prep_setup.c 1.47 12/19/01 09:45:54 trini */ /* * linux/arch/ppc/kernel/setup.c @@ -111,12 +111,6 @@ extern int probingmem; extern unsigned long loops_per_jiffy; -#ifdef CONFIG_BLK_DEV_RAM -extern int rd_doload; /* 1 = load ramdisk, 0 = don't load */ -extern int rd_prompt; /* 1 = prompt for ramdisk, 0 = don't prompt */ -extern int rd_image_start; /* starting block # of image */ -#endif - #ifdef CONFIG_SOUND_MODULE EXPORT_SYMBOL(ppc_cs4232_dma); EXPORT_SYMBOL(ppc_cs4232_dma2); @@ -189,7 +183,7 @@ no_l2: #ifdef CONFIG_PREP_RESIDUAL - if (res->ResidualLength == 0) { + if (res->ResidualLength != 0) { /* print info about SIMMs */ seq_printf(m, "simms\t\t: "); for (i = 0; (res->ActualNumMemories) && (i < MAX_MEMS); i++) { @@ -645,7 +639,7 @@ static int __prep prep_get_irq(struct pt_regs *regs) { - return i8259_irq(smp_processor_id()); + return i8259_irq(); } static void __init @@ -657,7 +651,7 @@ openpic_init(1, NUM_8259_INTERRUPTS, 0, -1); for ( i = 0 ; i < NUM_8259_INTERRUPTS ; i++ ) irq_desc[i].handler = &i8259_pic; - i8259_init(); + i8259_init(0xbffffff0); /* PCI interrupt ack address for MPC105 and 106 */ } #if defined(CONFIG_BLK_DEV_IDE) || defined(CONFIG_BLK_DEV_IDE_MODULE) diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/ppc/kernel/prom.c linux-2.5/arch/ppc/kernel/prom.c --- linux-2.5.1/arch/ppc/kernel/prom.c Mon Dec 10 21:52:53 2001 +++ linux-2.5/arch/ppc/kernel/prom.c Thu Dec 27 16:32:30 2001 @@ -1,5 +1,5 @@ /* - * BK Id: SCCS/s.prom.c 1.42 09/08/01 15:47:42 paulus + * BK Id: SCCS/s.prom.c 1.48 12/19/01 10:50:58 paulus */ /* * Procedures for interfacing to the Open Firmware PROM on @@ -19,6 +19,9 @@ #include <linux/version.h> #include <linux/threads.h> #include <linux/spinlock.h> +#include <linux/ioport.h> +#include <linux/pci.h> +#include <linux/slab.h> #include <asm/sections.h> #include <asm/prom.h> @@ -34,6 +37,7 @@ #include <asm/bitops.h> #include <asm/bootinfo.h> #include <asm/btext.h> +#include <asm/pci-bridge.h> #include "open_pic.h" #ifdef CONFIG_FB @@ -371,8 +375,8 @@ btext_drawstring(RELOC(" !!! WARNING - Incompatible version of BootX !!!\n\n\n")); btext_flushscreen(); } -#endif /* CONFIG_BOOTX_TEXT */ - +#endif /* CONFIG_BOOTX_TEXT */ + /* New BootX enters kernel with MMU off, i/os are not allowed here. This hack will have been done by the boostrap anyway. */ @@ -388,7 +392,7 @@ out_le32((unsigned *)0x80880008, 1); /* XXX */ } } - + /* Move klimit to enclose device tree, args, ramdisk, etc... */ if (bi->version < 5) { space = bi->deviceTreeOffset + bi->deviceTreeSize; @@ -411,7 +415,7 @@ ptr < (unsigned long)bi + space; ptr += PAGE_SIZE) x = *(volatile unsigned long *)ptr; } - + #ifdef CONFIG_BOOTX_TEXT /* * Note that after we call prepare_disp_BAT, we can't do @@ -620,7 +624,7 @@ phys = 0; else { if ((int) call_prom(RELOC("getprop"), 4, 1, RELOC(prom_chosen), - RELOC("mmu"), &prom_mmu, sizeof(prom_mmu)) <= 0) { + RELOC("mmu"), &prom_mmu, sizeof(prom_mmu)) <= 0) { prom_print(RELOC(" no MMU found\n")); } else { int nargs; @@ -653,7 +657,8 @@ call_prom(RELOC("quiesce"), 0, 0); #ifdef CONFIG_BOOTX_TEXT - btext_prepare_BAT(); + if (RELOC(prom_disp_node) != 0) + btext_prepare_BAT(); #endif prom_print(RELOC("returning ")); @@ -793,7 +798,7 @@ for (i=1; i<RELOC(prom_num_displays); i++) { RELOC(prom_display_paths[i-1]) = RELOC(prom_display_paths[i]); RELOC(prom_display_nodes[i-1]) = RELOC(prom_display_nodes[i]); - } + } if (--RELOC(prom_num_displays) > 0) RELOC(prom_disp_node) = RELOC(prom_display_nodes[0]); else @@ -880,7 +885,7 @@ } } /* kludge for valkyrie */ - if (strcmp(name, RELOC("valkyrie")) == 0) + if (strcmp(name, RELOC("valkyrie")) == 0) address += 0x1000; btext_setup_display(width, height, depth, pitch, address); @@ -1111,10 +1116,15 @@ np->name = get_property(np, "name", 0); np->type = get_property(np, "device_type", 0); + if (!np->name) + np->name = "<NULL>"; + if (!np->type) + np->type = "<NULL>"; + /* get the device addresses and interrupts */ - if (ifunc != NULL) { + if (ifunc != NULL) mem_start = ifunc(np, mem_start, naddrc, nsizec); - } + if (use_of_interrupt_tree) mem_start = finish_node_interrupts(np, mem_start); @@ -1126,11 +1136,18 @@ if (ip != NULL) nsizec = *ip; - /* the f50 sets the name to 'display' and 'compatible' to what we - * expect for the name -- Cort + /* + * The F50 sets the name to 'display' and 'compatible' to what we + * expect for the name. -- Cort + * + * But sometimes you get a 'display' name for non-OF cards, and thus + * no compatible property. And very rarely we won't have a name + * property either. -- Tom */ if (!strcmp(np->name, "display")) np->name = get_property(np, "compatible", 0); + if (!np->name) + np->name = get_property(np, "name", 0); if (np->parent == NULL) ifunc = interpret_root_props; @@ -1145,6 +1162,8 @@ ifunc = interpret_macio_props; else if (!strcmp(np->type, "isa")) ifunc = interpret_isa_props; + else if (!strcmp(np->name, "uni-n")) + ifunc = interpret_root_props; else if (!((ifunc == interpret_dbdma_props || ifunc == interpret_macio_props) && (!strcmp(np->type, "escc") @@ -1508,7 +1527,7 @@ i = 0; adr = (struct address_range *) mem_start; while ((l -= sizeof(struct reg_property)) >= 0) { - adr[i].space = 0; + adr[i].space = 2; adr[i].address = rp[i].address + base_address; adr[i].size = rp[i].size; ++i; @@ -1544,14 +1563,13 @@ struct reg_property *rp; struct address_range *adr; unsigned long base_address; - int i, l, keylargo, *ip; + int i, l, *ip; struct device_node *db; base_address = 0; for (db = np->parent; db != NULL; db = db->parent) { if (!strcmp(db->type, "mac-io") && db->n_addrs != 0) { base_address = db->addrs[0].address; - keylargo = device_is_compatible(db, "Keylargo"); break; } } @@ -1561,7 +1579,7 @@ i = 0; adr = (struct address_range *) mem_start; while ((l -= sizeof(struct reg_property)) >= 0) { - adr[i].space = 0; + adr[i].space = 2; adr[i].address = rp[i].address + base_address; adr[i].size = rp[i].size; ++i; @@ -1616,7 +1634,7 @@ if (use_of_interrupt_tree) return mem_start; - + ip = (int *) get_property(np, "interrupts", &l); if (ip != 0) { np->intrs = (struct interrupt_info *) mem_start; @@ -1645,7 +1663,7 @@ i = 0; adr = (struct address_range *) mem_start; while ((l -= rpsize) >= 0) { - adr[i].space = (naddrc >= 2? rp[naddrc-2]: 0); + adr[i].space = (naddrc >= 2? rp[naddrc-2]: 2); adr[i].address = rp[naddrc - 1]; adr[i].size = rp[naddrc + nsizec - 1]; ++i; @@ -1786,7 +1804,7 @@ machine_is_compatible(const char *compat) { struct device_node *root; - + root = find_path_device("/"); if (root == 0) return 0; @@ -1870,10 +1888,176 @@ { struct property **next = &np->properties; - prop->next = NULL; + prop->next = NULL; while (*next) next = &(*next)->next; *next = prop; +} + +/* I quickly hacked that one, check against spec ! */ +static inline unsigned long __openfirmware +bus_space_to_resource_flags(unsigned int bus_space) +{ + u8 space = (bus_space >> 24) & 0xf; + if (space == 0) + space = 0x02; + if (space == 0x02) + return IORESOURCE_MEM; + else if (space == 0x01) + return IORESOURCE_IO; + else { + printk(KERN_WARNING "prom.c: bus_space_to_resource_flags(), space: %x\n", + bus_space); + return 0; + } +} + +static struct resource* __openfirmware +find_parent_pci_resource(struct pci_dev* pdev, struct address_range *range) +{ + unsigned long mask; + int i; + + /* Check this one */ + mask = bus_space_to_resource_flags(range->space); + for (i=0; i<DEVICE_COUNT_RESOURCE; i++) { + if ((pdev->resource[i].flags & mask) == mask && + pdev->resource[i].start <= range->address && + pdev->resource[i].end > range->address) { + if ((range->address + range->size - 1) > pdev->resource[i].end) { + /* Add better message */ + printk(KERN_WARNING "PCI/OF resource overlap !\n"); + return NULL; + } + break; + } + } + if (i == DEVICE_COUNT_RESOURCE) + return NULL; + return &pdev->resource[i]; +} + +/* + * Request an OF device resource. Currently handles child of PCI devices, + * or other nodes attached to the root node. Ultimately, put some + * link to resources in the OF node. + * WARNING: out_resource->name should be initialized before calling this + * function. + */ +struct resource* __openfirmware +request_OF_resource(struct device_node* node, int index, const char* name_postfix) +{ + struct pci_dev* pcidev; + u8 pci_bus, pci_devfn; + unsigned long iomask; + struct device_node* nd; + struct resource* parent; + struct resource *res = NULL; + int nlen, plen; + + if (index >= node->n_addrs) + goto fail; + + /* Sanity check on bus space */ + iomask = bus_space_to_resource_flags(node->addrs[index].space); + if (iomask & IORESOURCE_MEM) + parent = &iomem_resource; + else if (iomask & IORESOURCE_IO) + parent = &ioport_resource; + else + goto fail; + + /* Find a PCI parent if any */ + nd = node; + pcidev = NULL; + while(nd) { + if (!pci_device_from_OF_node(nd, &pci_bus, &pci_devfn)) + pcidev = pci_find_slot(pci_bus, pci_devfn); + if (pcidev) break; + nd = nd->parent; + } + if (pcidev) + parent = find_parent_pci_resource(pcidev, &node->addrs[index]); + if (!parent) { + printk(KERN_WARNING "request_OF_resource(%s), parent not found\n", + node->name); + goto fail; + } + + res = __request_region(parent, node->addrs[index].address, node->addrs[index].size, NULL); + if (!res) + goto fail; + nlen = strlen(node->name); + plen = name_postfix ? strlen(name_postfix) : 0; + res->name = (const char *)kmalloc(nlen+plen+1, GFP_KERNEL); + if (res->name) { + strcpy((char *)res->name, node->name); + if (plen) + strcpy((char *)res->name+nlen, name_postfix); + } + return res; +fail: + return NULL; +} + +int __openfirmware +release_OF_resource(struct device_node* node, int index) +{ + struct pci_dev* pcidev; + u8 pci_bus, pci_devfn; + unsigned long iomask; + struct device_node* nd; + struct resource* parent; + struct resource *res = NULL; + + if (index >= node->n_addrs) + return -EINVAL; + + /* Sanity check on bus space */ + iomask = bus_space_to_resource_flags(node->addrs[index].space); + if (iomask & IORESOURCE_MEM) + parent = &iomem_resource; + else if (iomask & IORESOURCE_IO) + parent = &ioport_resource; + else + return -EINVAL; + + /* Find a PCI parent if any */ + nd = node; + pcidev = NULL; + while(nd) { + if (!pci_device_from_OF_node(nd, &pci_bus, &pci_devfn)) + pcidev = pci_find_slot(pci_bus, pci_devfn); + if (pcidev) break; + nd = nd->parent; + } + if (pcidev) + parent = find_parent_pci_resource(pcidev, &node->addrs[index]); + if (!parent) { + printk(KERN_WARNING "request_OF_resource(%s), parent not found\n", + node->name); + return -ENODEV; + } + + /* Find us in the parent */ + res = parent->child; + while (res) { + if (res->start == node->addrs[index].address && + res->end == (res->start + node->addrs[index].size - 1)) + break; + res = res->sibling; + } + if (!res) + return -ENODEV; + + if (res->name) { + kfree(res->name); + res->name = NULL; + } + release_resource(res); + kfree(res); + + return 0; } #if 0 diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/ppc/kernel/setup.c linux-2.5/arch/ppc/kernel/setup.c --- linux-2.5.1/arch/ppc/kernel/setup.c Wed Nov 21 17:59:11 2001 +++ linux-2.5/arch/ppc/kernel/setup.c Thu Dec 27 16:32:30 2001 @@ -1,5 +1,5 @@ /* - * BK Id: SCCS/s.setup.c 1.65 11/18/01 20:57:25 trini + * BK Id: SCCS/s.setup.c 1.67 12/01/01 20:09:07 benh */ /* * Common prep/pmac/chrp boot and setup code. @@ -43,9 +43,9 @@ #include <asm/bootx.h> #include <asm/btext.h> #include <asm/machdep.h> -#include <asm/feature.h> #include <asm/uaccess.h> #include <asm/system.h> +#include <asm/pmac_feature.h> extern void platform_init(unsigned long r3, unsigned long r4, unsigned long r5, unsigned long r6, unsigned long r7); @@ -547,8 +547,13 @@ loops_per_jiffy = 500000000 / HZ; #ifdef CONFIG_ALL_PPC - feature_init(); -#endif + /* This could be called "early setup arch", it must be done + * now because xmon need it + */ + if (_machine == _MACH_Pmac) + pmac_feature_init(); /* New cool way */ +#endif /* CONFIG_ALL_PPC */ + #ifdef CONFIG_XMON xmon_map_scc(); if (strstr(cmd_line, "xmon")) diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/ppc/kernel/sleep.S linux-2.5/arch/ppc/kernel/sleep.S --- linux-2.5.1/arch/ppc/kernel/sleep.S Tue Aug 28 13:58:33 2001 +++ linux-2.5/arch/ppc/kernel/sleep.S Thu Dec 27 16:32:30 2001 @@ -1,5 +1,5 @@ /* - * BK Id: SCCS/s.sleep.S 1.13 08/19/01 22:23:04 paulus + * BK Id: SCCS/s.sleep.S 1.18 12/02/01 12:38:54 benh */ /* * This file contains sleep low-level functions for PowerBook G3. @@ -16,6 +16,7 @@ #include "ppc_asm.tmpl" #include <asm/processor.h> #include <asm/page.h> +#include <asm/cputable.h> #define MAGIC 0x4c617273 /* 'Lars' */ @@ -37,8 +38,15 @@ #define SL_IBAT3 0x58 #define SL_TB 0x60 #define SL_HID0 0x68 -#define SL_R2 0x6c -#define SL_R12 0x70 /* r12 to r31 */ +#define SL_HID1 0x6c +#define SL_MSSCR0 0x70 +#define SL_MSSSR0 0x74 +#define SL_ICTRL 0x78 +#define SL_LDSTCR 0x7c +#define SL_LDSTDB 0x80 +#define SL_R2 0x84 +#define SL_CR 0x88 +#define SL_R12 0x8c /* r12 to r31 */ #define SL_SIZE (SL_R12 + 80) #define tophys(rd,rs) addis rd,rs,-KERNELBASE@h @@ -56,6 +64,8 @@ mflr r0 stw r0,4(r1) stwu r1,-SL_SIZE(r1) + mfcr r0 + stw r0,SL_CR(r1) stw r2,SL_R2(r1) stmw r12,SL_R12(r1) @@ -121,7 +131,31 @@ /* Save HID0 */ mfspr r4,HID0 stw r4,SL_HID0(r1) - + + /* Save 7400/7410/7450 specific registers */ + mfspr r3,PVR + srwi r3,r3,16 + cmpli cr0,r3,0x8000 + cmpli cr1,r3,0x000c + cmpli cr2,r3,0x800c + cror 4*cr1+eq,4*cr1+eq,4*cr2+eq + cror 4*cr0+eq,4*cr0+eq,4*cr1+eq + bne 1f + mfspr r4,SPRN_MSSCR0 + stw r4,SL_MSSCR0(r1) + mfspr r4,SPRN_MSSSR0 + stw r4,SL_MSSSR0(r1) + /* Save 7450 specific registers */ + beq cr1,1f + mfspr r4,HID1 + stw r4,SL_HID1(r1) + mfspr r4,SPRN_ICTRL + stw r4,SL_ICTRL(r1) + mfspr r4,SPRN_LDSTCR + stw r4,SL_LDSTCR(r1) + mfspr r4,SPRN_LDSTDB + stw r4,SL_LDSTDB(r1) +1: /* The ROM can wake us up via 2 different vectors: * - On wallstreet & lombard, we must write a magic * value 'Lars' at address 4 and a pointer to a @@ -257,6 +291,19 @@ mtspr HID0,r3 sync + /* Restore the kernel's segment registers before + * we do any r1 memory access as we are not sure they + * are in a sane state above the first 256Mb region + */ + li r0,16 /* load up segment register values */ + mtctr r0 /* for context 0 */ + lis r3,0x2000 /* Ku = 1, VSID = 0 */ + li r4,0 +3: mtsrin r3,r4 + addi r3,r3,0x111 /* increment VSID */ + addis r4,r4,0x1000 /* address of next segment */ + bdnz 3b + /* Restore the remaining bits of the HID0 register. */ subi r1,r1,SL_PC lwz r3,SL_HID0(r1) @@ -266,17 +313,52 @@ sync isync - /* Restore the kernel's segment registers, the - BATs, and SDR1. Then we can turn on the MMU. */ - li r0,16 /* load up segment register values */ - mtctr r0 /* for context 0 */ - lis r3,0x2000 /* Ku = 1, VSID = 0 */ + /* Restore 7400/7410/7450 specific registers */ + mfspr r3,PVR + srwi r3,r3,16 + cmpli cr0,r3,0x8000 + cmpli cr1,r3,0x000c + cmpli cr2,r3,0x800c + cror 4*cr1+eq,4*cr1+eq,4*cr2+eq + cror 4*cr0+eq,4*cr0+eq,4*cr1+eq + bne 1f + lwz r4,SL_MSSCR0(r1) + sync + mtspr SPRN_MSSCR0,r4 + sync + isync + lwz r4,SL_MSSSR0(r1) + sync + mtspr SPRN_MSSSR0,r4 + sync + isync + bne cr2,1f li r4,0 -3: mtsrin r3,r4 - addi r3,r3,0x111 /* increment VSID */ - addis r4,r4,0x1000 /* address of next segment */ - bdnz 3b - + mtspr SPRN_L2CR2,r4 + /* Restore 7450 specific registers */ + beq cr1,1f + lwz r4,SL_HID1(r1) + sync + mtspr HID1,r4 + isync + sync + lwz r4,SPRN_ICTRL(r1) + sync + mtspr SPRN_ICTRL,r4 + isync + sync + lwz r4,SPRN_LDSTCR(r1) + sync + mtspr SPRN_LDSTCR,r4 + isync + sync + lwz r4,SL_LDSTDB(r1) + sync + mtspr SPRN_LDSTDB,r4 + isync + sync +1: + /* Restore the BATs, and SDR1. Then we can turn on the MMU. */ lwz r4,SL_SDR1(r1) mtsdr1 r4 lwz r4,SL_SPRG0(r1) @@ -344,6 +426,8 @@ mttbl r4 /* Restore the callee-saved registers and return */ + lwz r0,SL_CR(r1) + mtcr r0 lwz r2,SL_R2(r1) lmw r12,SL_R12(r1) addi r1,r1,SL_SIZE diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/ppc/kernel/smp.c linux-2.5/arch/ppc/kernel/smp.c --- linux-2.5.1/arch/ppc/kernel/smp.c Wed Nov 21 18:31:09 2001 +++ linux-2.5/arch/ppc/kernel/smp.c Thu Dec 13 16:32:35 2001 @@ -23,6 +23,7 @@ #include <linux/unistd.h> #include <linux/init.h> #include <linux/spinlock.h> +#include <linux/cache.h> #include <asm/ptrace.h> #include <asm/atomic.h> @@ -47,7 +48,7 @@ struct klock_info_struct klock_info = { KLOCK_CLEAR, 0 }; atomic_t ipi_recv; atomic_t ipi_sent; -spinlock_t kernel_flag __cacheline_aligned = SPIN_LOCK_UNLOCKED; +spinlock_t kernel_flag __cacheline_aligned_in_smp = SPIN_LOCK_UNLOCKED; unsigned int prof_multiplier[NR_CPUS]; unsigned int prof_counter[NR_CPUS]; cycles_t cacheflush_time; diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/ppc/kernel/time.c linux-2.5/arch/ppc/kernel/time.c --- linux-2.5.1/arch/ppc/kernel/time.c Mon Oct 8 18:43:01 2001 +++ linux-2.5/arch/ppc/kernel/time.c Thu Dec 27 16:32:30 2001 @@ -1,5 +1,5 @@ /* - * BK Id: SCCS/s.time.c 1.26 10/05/01 08:29:42 trini + * BK Id: SCCS/s.time.c 1.29 12/11/01 11:40:45 trini */ /* * Common time routines among all ppc machines. @@ -356,11 +356,10 @@ do_get_fast_time = do_gettimeofday; } -#define TICK_SIZE tick -#define FEBRUARY 2 -#define STARTOFTIME 1970 -#define SECDAY 86400L -#define SECYR (SECDAY * 365) +#define FEBRUARY 2 +#define STARTOFTIME 1970 +#define SECDAY 86400L +#define SECYR (SECDAY * 365) #define leapyear(year) ((year) % 4 == 0) #define days_in_year(a) (leapyear(a) ? 366 : 365) #define days_in_month(a) (month_days[(a) - 1]) @@ -369,55 +368,12 @@ 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; -/* - * This only works for the Gregorian calendar - i.e. after 1752 (in the UK) - */ -void GregorianDay(struct rtc_time * tm) -{ - int leapsToDate; - int lastYear; - int day; - int MonthOffset[] = { 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334 }; - - lastYear=tm->tm_year-1; - - /* - * Number of leap corrections to apply up to end of last year - */ - leapsToDate = lastYear/4 - lastYear/100 + lastYear/400; - - /* - * This year is a leap year if it is divisible by 4 except when it is - * divisible by 100 unless it is divisible by 400 - * - * e.g. 1904 was a leap year, 1900 was not, 1996 is, and 2000 will be - */ - if((tm->tm_year%4==0) && - ((tm->tm_year%100!=0) || (tm->tm_year%400==0)) && - (tm->tm_mon>2)) - { - /* - * We are past Feb. 29 in a leap year - */ - day=1; - } - else - { - day=0; - } - - day += lastYear*365 + leapsToDate + MonthOffset[tm->tm_mon-1] + - tm->tm_mday; - - tm->tm_wday=day%7; -} - void to_tm(int tim, struct rtc_time * tm) { - register int i; - register long hms, day; + register int i; + register long hms, day, gday; - day = tim / SECDAY; + gday = day = tim / SECDAY; hms = tim % SECDAY; /* Hours, minutes, seconds are easy */ @@ -442,9 +398,9 @@ tm->tm_mday = day + 1; /* - * Determine the day of week + * Determine the day of week. Jan. 1, 1970 was a Thursday. */ - GregorianDay(tm); + tm->tm_wday = (gday + 4) % 7; } /* Auxiliary function to compute scaling factors */ diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/ppc/kernel/xics.c linux-2.5/arch/ppc/kernel/xics.c --- linux-2.5.1/arch/ppc/kernel/xics.c Tue May 22 00:04:47 2001 +++ linux-2.5/arch/ppc/kernel/xics.c Thu Dec 27 16:32:30 2001 @@ -1,5 +1,5 @@ /* - * BK Id: SCCS/s.xics.c 1.5 05/17/01 18:14:22 cort + * BK Id: SCCS/s.xics.c 1.8 12/19/01 09:48:40 trini */ /* * arch/ppc/kernel/xics.c @@ -157,7 +157,7 @@ vec &= 0x00ffffff; /* for sanity, this had better be < NR_IRQS - 16 */ if( vec == XICS_IRQ_8259_CASCADE ) - irq = i8259_irq(cpu); + irq = i8259_poll(); else if( vec == XICS_IRQ_SPURIOUS ) irq = -1; else diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/ppc/mm/init.c linux-2.5/arch/ppc/mm/init.c --- linux-2.5.1/arch/ppc/mm/init.c Tue Oct 2 16:12:44 2001 +++ linux-2.5/arch/ppc/mm/init.c Thu Dec 27 16:32:30 2001 @@ -1,5 +1,5 @@ /* - * BK Id: SCCS/s.init.c 1.36 09/22/01 14:03:09 paulus + * BK Id: SCCS/s.init.c 1.38 12/01/01 20:09:07 benh */ /* * PowerPC version @@ -62,6 +62,9 @@ int boot_mapsize; unsigned long totalram_pages; unsigned long totalhigh_pages; +#ifdef CONFIG_ALL_PPC +unsigned long agp_special_page; +#endif extern char _end[]; extern char etext[], _stext[]; @@ -85,7 +88,7 @@ char *klimit = _end; struct mem_pieces phys_avail; -extern char *sysmap; +extern char *sysmap; extern unsigned long sysmap_size; /* @@ -352,9 +355,10 @@ ppc_md.progress("MMU:exit", 0x211); #ifdef CONFIG_BOOTX_TEXT - /* Must be done last, or ppc_md.progress will die */ - if (have_of) - map_boot_text(); + /* By default, we are no longer mapped */ + boot_text_mapped = 0; + /* Must be done last, or ppc_md.progress will die. */ + map_boot_text(); #endif } @@ -474,20 +478,22 @@ } #endif /* CONFIG_BLK_DEV_INITRD */ -#if defined(CONFIG_ALL_PPC) +#if defined(CONFIG_ALL_PPC) /* mark the RTAS pages as reserved */ if ( rtas_data ) for (addr = (ulong)__va(rtas_data); addr < PAGE_ALIGN((ulong)__va(rtas_data)+rtas_size) ; addr += PAGE_SIZE) SetPageReserved(virt_to_page(addr)); + if (agp_special_page) + SetPageReserved(virt_to_page(agp_special_page)); #endif /* defined(CONFIG_ALL_PPC) */ if ( sysmap ) for (addr = (unsigned long)sysmap; addr < PAGE_ALIGN((unsigned long)sysmap+sysmap_size) ; addr += PAGE_SIZE) SetPageReserved(virt_to_page(addr)); - + for (addr = PAGE_OFFSET; addr < (unsigned long)end_of_DRAM; addr += PAGE_SIZE) { if (!PageReserved(virt_to_page(addr))) @@ -526,6 +532,10 @@ if (sysmap) printk("System.map loaded at 0x%08x for debugger, size: %ld bytes\n", (unsigned int)sysmap, sysmap_size); +#if defined(CONFIG_ALL_PPC) + if (agp_special_page) + printk(KERN_INFO "AGP special page: 0x%08lx\n", agp_special_page); +#endif /* defined(CONFIG_ALL_PPC) */ mem_init_done = 1; } @@ -572,6 +582,20 @@ /* remove the sysmap pages from the available memory */ if (sysmap) mem_pieces_remove(&phys_avail, __pa(sysmap), sysmap_size, 1); + /* Because of some uninorth weirdness, we need a page of + * memory as high as possible (it must be outside of the + * bus address seen as the AGP aperture). It will be used + * by the r128 DRM driver + * + * FIXME: We need to make sure that page doesn't overlap any of the\ + * above. This could be done by improving mem_pieces_find to be able + * to do a backward search from the end of the list. + */ + if (_machine == _MACH_Pmac && find_devices("uni-north-agp")) { + agp_special_page = (total_memory - PAGE_SIZE); + mem_pieces_remove(&phys_avail, agp_special_page, PAGE_SIZE, 0); + agp_special_page = (unsigned long)__va(agp_special_page); + } #endif /* CONFIG_ALL_PPC */ } diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/ppc/xmon/nonstdio.h linux-2.5/arch/ppc/xmon/nonstdio.h --- linux-2.5.1/arch/ppc/xmon/nonstdio.h Tue May 22 00:04:47 2001 +++ linux-2.5/arch/ppc/xmon/nonstdio.h Thu Dec 27 16:32:30 2001 @@ -1,5 +1,5 @@ /* - * BK Id: SCCS/s.nonstdio.h 1.5 05/17/01 18:14:23 cort + * BK Id: SCCS/s.nonstdio.h 1.8 12/01/01 20:09:07 benh */ typedef int FILE; extern FILE *xmon_stdin, *xmon_stdout; @@ -21,5 +21,6 @@ extern void xmon_printf(const char *, ...); extern void xmon_fprintf(void *, const char *, ...); extern void xmon_sprintf(char *, const char *, ...); +extern void xmon_puts(char*); #define perror(s) printf("%s: no files!\n", (s)) diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/ppc/xmon/start.c linux-2.5/arch/ppc/xmon/start.c --- linux-2.5.1/arch/ppc/xmon/start.c Tue Aug 28 13:58:33 2001 +++ linux-2.5/arch/ppc/xmon/start.c Thu Dec 27 16:32:30 2001 @@ -1,5 +1,5 @@ /* - * BK Id: SCCS/s.start.c 1.16 08/20/01 22:17:58 paulus + * BK Id: SCCS/s.start.c 1.18 12/01/01 20:09:07 benh */ /* * Copyright (C) 1996 Paul Mackerras. @@ -13,9 +13,11 @@ #include <linux/pmu.h> #include <linux/cuda.h> #include <linux/kernel.h> +#include <linux/errno.h> #include <asm/prom.h> #include <asm/bootx.h> -#include <asm/feature.h> +#include <asm/machdep.h> +#include <asm/pmac_feature.h> #include <asm/processor.h> #include <asm/delay.h> #include <asm/btext.h> @@ -32,7 +34,7 @@ static int use_screen; static int via_modem; static int xmon_use_sccb; -static struct device_node *macio_node; +static struct device_node *channel_node; #define TB_SPEED 25000000 @@ -99,6 +101,7 @@ np = np->sibling; if (np != NULL) { /* XXX should parse this properly */ + channel_node = np; slots = get_property(np, "slot-names", &l); if (slots != NULL && l >= 10 && strcmp(slots+4, "Modem") == 0) @@ -126,10 +129,8 @@ RXRDY = 1; np = find_devices("mac-io"); - if (np && np->n_addrs) { - macio_node = np; + if (np && np->n_addrs) addr = np->addrs[0].address + 0x13020; - } base = (volatile unsigned char *) ioremap(addr & PAGE_MASK, PAGE_SIZE); sccc = base + (addr & ~PAGE_MASK); sccd = sccc + 0x10; @@ -349,12 +350,19 @@ { int i, x; - if (macio_node != 0) - feature_set(macio_node, FEATURE_Serial_enable); - if (via_modem && macio_node != 0) { + if (channel_node != 0) + pmac_call_feature( + PMAC_FTR_SCC_ENABLE, + channel_node, + PMAC_SCC_ASYNC | PMAC_SCC_FLAG_XMON, 1); + printk(KERN_INFO "Serial port locked ON by debugger !\n"); + if (via_modem && channel_node != 0) { unsigned int t0; - feature_set(macio_node, FEATURE_Modem_power); + pmac_call_feature( + PMAC_FTR_MODEM_ENABLE, + channel_node, 0, 1); + printk(KERN_INFO "Modem powered up by debugger !\n"); t0 = readtb(); while (readtb() - t0 < 3*TB_SPEED) eieio(); diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/ppc/xmon/subr_prf.c linux-2.5/arch/ppc/xmon/subr_prf.c --- linux-2.5.1/arch/ppc/xmon/subr_prf.c Tue May 22 00:04:47 2001 +++ linux-2.5/arch/ppc/xmon/subr_prf.c Thu Dec 27 16:32:30 2001 @@ -1,5 +1,5 @@ /* - * BK Id: SCCS/s.subr_prf.c 1.5 05/17/01 18:14:23 cort + * BK Id: SCCS/s.subr_prf.c 1.8 12/01/01 20:09:07 benh */ /* * Written by Cort Dougan to replace the version originally used @@ -51,3 +51,8 @@ va_end(ap); } +void +xmon_puts(char *s) +{ + xmon_write(stdout, s, strlen(s)); +} diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/ppc/xmon/xmon.c linux-2.5/arch/ppc/xmon/xmon.c --- linux-2.5.1/arch/ppc/xmon/xmon.c Mon Oct 8 18:40:13 2001 +++ linux-2.5/arch/ppc/xmon/xmon.c Thu Dec 27 16:32:30 2001 @@ -1,5 +1,5 @@ /* - * BK Id: SCCS/s.xmon.c 1.16 09/22/01 15:25:10 trini + * BK Id: SCCS/s.xmon.c 1.18 12/01/01 20:09:07 benh */ /* * Routines providing a simple monitor for use on the PowerMac. @@ -90,6 +90,7 @@ static void write_spr(int, unsigned); static void super_regs(void); static void print_sysmap(void); +static void sysmap_lookup(void); static void remove_bpts(void); static void insert_bpts(void); static struct bpt *at_breakpoint(unsigned pc); @@ -98,10 +99,7 @@ #ifdef CONFIG_SMP static void cpu_cmd(void); #endif /* CONFIG_SMP */ -#if 0 /* Makes compile with -Wall */ -static char *pretty_print_addr(unsigned long addr); -static char *lookup_name(unsigned long addr); -#endif +static int pretty_print_addr(unsigned long addr); static void csum(void); extern int print_insn_big_powerpc(FILE *, unsigned long, unsigned); @@ -112,6 +110,8 @@ extern void xmon_enter(void); extern void xmon_leave(void); +extern char* xmon_find_symbol(unsigned long addr, unsigned long* saddr); +extern unsigned long xmon_symbol_to_addr(char* symbol); #define GETWORD(v) (((v)[0] << 24) + ((v)[1] << 16) + ((v)[2] << 8) + (v)[3]) @@ -121,6 +121,7 @@ #define isalnum(c) (('0' <= (c) && (c) <= '9') \ || ('a' <= (c) && (c) <= 'z') \ || ('A' <= (c) && (c) <= 'Z')) +#define isspace(c) (c == ' ' || c == '\t' || c == 10 || c == 13 || c == 0) static char *help_string = "\ Commands:\n\ @@ -138,6 +139,8 @@ r print registers\n\ S print special registers\n\ t print backtrace\n\ + la lookup address in system.map\n\ + ls lookup symbol in system.map\n\ x exit monitor\n\ "; @@ -147,6 +150,19 @@ static struct pt_regs *xmon_regs[NR_CPUS]; +extern inline void sync(void) +{ + asm volatile("sync; isync"); +} + +extern inline void __delay(unsigned int loops) +{ + if (loops != 0) + __asm__ __volatile__("mtctr %0; 1: bdnz 1b" : : + "r" (loops) : "ctr"); +} + + void xmon(struct pt_regs *excp) { @@ -398,6 +414,9 @@ case 'd': dump(); break; + case 'l': + sysmap_lookup(); + break; case 'r': if (excp != NULL) prregs(excp); /* print regs */ @@ -464,8 +483,8 @@ if (cmd == 'i') { /* interrupt other cpu(s) */ cpu = MSG_ALL_BUT_SELF; - scanhex(&cpu); - smp_send_xmon_break(cpu); + if (scanhex(&cpu)) + smp_send_xmon_break(cpu); return; } termch = cmd; @@ -547,8 +566,10 @@ unsigned short fcs; unsigned char v; - scanhex(&adrs); - scanhex(&ncsum); + if (!scanhex(&adrs)) + return; + if (!scanhex(&ncsum)) + return; fcs = 0xffff; for (i = 0; i < ncsum; ++i) { if (mread(adrs+i, &v, 1) == 0) { @@ -580,6 +601,11 @@ mode = 6; else termch = cmd; + cmd = inchar(); + if (cmd == 'p') + mode &= ~4; + else + termch = cmd; dabr.address = 0; dabr.count = 0; dabr.enabled = scanhex(&dabr.address); @@ -588,11 +614,16 @@ dabr.address = (dabr.address & ~7) | mode; break; case 'i': + cmd = inchar(); + if (cmd == 'p') + mode = 2; + else + mode = 3; iabr.address = 0; iabr.count = 0; iabr.enabled = scanhex(&iabr.address); if (iabr.enabled) - iabr.address |= 3; + iabr.address |= mode; scanhex(&iabr.count); break; #endif @@ -625,6 +656,8 @@ printf("r"); if (dabr.address & 2) printf("w"); + if (dabr.address & 4) + printf("p"); printf("]\n"); } if (iabr.enabled) @@ -674,7 +707,8 @@ for (; sp != 0; sp = stack[0]) { if (mread(sp, stack, sizeof(stack)) != sizeof(stack)) break; - printf("%x ", stack[1]); + pretty_print_addr(stack[1]); + printf(" "); if (stack[1] == (unsigned) &ret_from_intercept || stack[1] == (unsigned) &ret_from_except || stack[1] == (unsigned) &ret_from_syscall_1 @@ -688,8 +722,8 @@ if (mread(sp, stack, sizeof(stack)) != sizeof(stack)) break; } + printf("\n"); } - printf("\n"); } int @@ -707,10 +741,11 @@ #ifdef CONFIG_SMP printf("cpu %d: ", smp_processor_id()); #endif /* CONFIG_SMP */ - printf("vector: %x at pc = %x", - fp->trap, fp->nip); - printf(", lr = %x, msr = %x, sp = %x [%x]\n", - fp->link, fp->msr, fp->gpr[1], fp); + printf("vector: %x at pc = ", fp->trap); + pretty_print_addr(fp->nip); + printf(", lr = "); + pretty_print_addr(fp->link); + printf("\nmsr = %x, sp = %x [%x]\n", fp->msr, fp->gpr[1], fp); if (fp->trap == 0x300 || fp->trap == 0x600) printf("dar = %x, dsisr = %x\n", fp->dar, fp->dsisr); if (current) @@ -795,8 +830,16 @@ print_sysmap(void) { extern char *sysmap; - if ( sysmap ) - printf("System.map: \n%s", sysmap); + if ( sysmap ) { + printf("System.map: \n"); + if( setjmp(bus_error_jmp) == 0 ) { + debugger_fault_handler = handle_fault; + sync(); + xmon_puts(sysmap); + sync(); + } + debugger_fault_handler = 0; + } else printf("No System.map\n"); } @@ -1028,17 +1071,6 @@ /* * Stuff for reading and writing memory safely */ -extern inline void sync(void) -{ - asm volatile("sync; isync"); -} - -extern inline void __delay(unsigned int loops) -{ - if (loops != 0) - __asm__ __volatile__("mtctr %0; 1: bdnz 1b" : : - "r" (loops) : "ctr"); -} int mread(unsigned adrs, void *buf, int size) @@ -1565,6 +1597,24 @@ } printf("invalid register name '%%%s'\n", regname); return 0; + } else if (c == '$') { + static char symname[64]; + int i; + for (i=0; i<63; i++) { + c = inchar(); + if (isspace(c)) { + termch = c; + break; + } + symname[i] = c; + } + symname[i++] = 0; + *vp = xmon_symbol_to_addr(symname); + if (!(*vp)) { + printf("unknown symbol\n"); + return 0; + } + return 1; } d = hexdigit(c); @@ -1652,38 +1702,169 @@ lineptr = str; } -#if 0 /* Makes compile with -Wall */ -static char *pretty_print_addr(unsigned long addr) +void +sysmap_lookup(void) { - printf("%08x", addr); - if ( lookup_name(addr) ) - printf(" %s", lookup_name(addr) ); - return NULL; + int type = inchar(); + unsigned addr; + static char tmp[64]; + char* cur; + + extern char *sysmap; + extern unsigned long sysmap_size; + if ( !sysmap || !sysmap_size ) + return; + + switch(type) { + case 'a': + if (scanhex(&addr)) { + pretty_print_addr(addr); + printf("\n"); + } + termch = 0; + break; + case 's': + getstring(tmp, 64); + if( setjmp(bus_error_jmp) == 0 ) { + debugger_fault_handler = handle_fault; + sync(); + cur = sysmap; + do { + cur = strstr(cur, tmp); + if (cur) { + static char res[64]; + char *p, *d; + p = cur; + while(p > sysmap && *p != 10) + p--; + if (*p == 10) p++; + d = res; + while(*p && p < (sysmap + sysmap_size) && *p != 10) + *(d++) = *(p++); + *(d++) = 0; + printf("%s\n", res); + cur++; + } + } while (cur); + sync(); + } + debugger_fault_handler = 0; + termch = 0; + break; + } } -#endif -#if 0 /* Makes compile with -Wall */ -static char *lookup_name(unsigned long addr) +static int +pretty_print_addr(unsigned long addr) { + char *sym; + unsigned long saddr; + + printf("%08x", addr); + sym = xmon_find_symbol(addr, &saddr); + if (sym) + printf(" (%s+0x%x)", sym, addr-saddr); + return (sym != 0); +} + +char* +xmon_find_symbol(unsigned long addr, unsigned long* saddr) +{ + static char rbuffer[64]; + char *p, *ep, *limit; + unsigned long prev, next; + char* psym; + extern char *sysmap; extern unsigned long sysmap_size; - char *c = sysmap; - unsigned long cmp; if ( !sysmap || !sysmap_size ) return NULL; -return NULL; -#if 0 - cmp = simple_strtoul(c, &c, 8); - /* XXX crap, we don't want the whole of the rest of the map - paulus */ - strcpy( last, strsep( &c, "\n")); - while ( c < (sysmap+sysmap_size) ) - { - cmp = simple_strtoul(c, &c, 8); - if ( cmp < addr ) - break; - strcpy( last, strsep( &c, "\n")); + + prev = 0; + psym = NULL; + p = sysmap; + limit = p + sysmap_size; + if( setjmp(bus_error_jmp) == 0 ) { + debugger_fault_handler = handle_fault; + sync(); + do { + next = simple_strtoul(p, &p, 16); + if (next > addr && prev <= addr) { + if (!psym) + goto bail; + ep = rbuffer; + p = psym; + while(*p && p < limit && *p == 32) + p++; + while(*p && p < limit && *p != 10 && (ep - rbuffer) < 63) + *(ep++) = *(p++); + *(ep++) = 0; + if (saddr) + *saddr = prev; + debugger_fault_handler = 0; + return rbuffer; + } + prev = next; + psym = p; + while(*p && p < limit && *p != 10) + p++; + if (*p) p++; + } while(*p && p < limit && next); +bail: + sync(); } - return last; -#endif + debugger_fault_handler = 0; + return NULL; } -#endif + +unsigned long +xmon_symbol_to_addr(char* symbol) +{ + char *p, *cur; + char *match; + int goodness = 0; + int result = 0; + + extern char *sysmap; + extern unsigned long sysmap_size; + if ( !sysmap || !sysmap_size ) + return 0; + + if( setjmp(bus_error_jmp) == 0 ) { + debugger_fault_handler = handle_fault; + sync(); + cur = sysmap; + while(cur) { + cur = strstr(cur, symbol); + if (cur) { + int gd = 1; + + /* best match if equal, better match if + * begins with + */ + if (cur == sysmap || *(cur-1) == ' ') { + gd++; + if (cur[strlen(symbol)] == 10) + gd++; + } + if (gd > goodness) { + match = cur; + goodness = gd; + if (gd == 3) + break; + } + cur++; + } + } + if (goodness) { + p = match; + while(p > sysmap && *p != 10) + p--; + if (*p == 10) p++; + result = simple_strtoul(p, &p, 16); + } + sync(); + } + debugger_fault_handler = 0; + return result; +} diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/s390/Makefile linux-2.5/arch/s390/Makefile --- linux-2.5.1/arch/s390/Makefile Thu Oct 11 16:04:57 2001 +++ linux-2.5/arch/s390/Makefile Thu Dec 27 16:32:30 2001 @@ -65,3 +65,6 @@ archdep: @$(MAKEBOOT) dep + +install: vmlinux + @$(MAKEBOOT) BOOTIMAGE=image install diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/s390/boot/Makefile linux-2.5/arch/s390/boot/Makefile --- linux-2.5.1/arch/s390/boot/Makefile Wed Jul 25 21:12:01 2001 +++ linux-2.5/arch/s390/boot/Makefile Thu Dec 27 16:32:30 2001 @@ -35,3 +35,6 @@ clean: rm -f image listing iplfba.boot ipleckd.boot ipldump.boot +install: $(CONFIGURE) $(BOOTIMAGE) + sh -x ./install.sh $(KERNELRELEASE) $(BOOTIMAGE) $(TOPDIR)/System.map $(TOPDIR)/Kerntypes "$(INSTALL_PATH)" + diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/s390/config.in linux-2.5/arch/s390/config.in --- linux-2.5.1/arch/s390/config.in Fri Nov 9 21:58:02 2001 +++ linux-2.5/arch/s390/config.in Thu Dec 27 16:32:30 2001 @@ -67,9 +67,9 @@ comment 'Kernel hacking' #bool 'Debug kmalloc/kfree' CONFIG_DEBUG_MALLOC -if [ "$CONFIG_CTC" = "y" ]; then - bool 'Remote GDB kernel debugging' CONFIG_REMOTE_DEBUG -fi +#if [ "$CONFIG_CTC" = "y" ]; then +# bool 'Remote GDB kernel debugging' CONFIG_REMOTE_DEBUG +#fi bool 'Magic SysRq key' CONFIG_MAGIC_SYSRQ endmenu diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/s390/defconfig linux-2.5/arch/s390/defconfig --- linux-2.5.1/arch/s390/defconfig Fri Nov 9 21:58:02 2001 +++ linux-2.5/arch/s390/defconfig Thu Dec 27 16:32:30 2001 @@ -7,7 +7,7 @@ CONFIG_UID16=y CONFIG_RWSEM_GENERIC_SPINLOCK=y # CONFIG_RWSEM_XCHGADD_ALGORITHM is not set -CONFIG_GENERIC_BUST_SPINLOCK=n +# CONFIG_GENERIC_BUST_SPINLOCK is not set CONFIG_ARCH_S390=y # @@ -103,8 +103,8 @@ # # S/390 tape hardware support # -CONFIG_S390_TAPE_3490=y -CONFIG_S390_TAPE_3480=y +CONFIG_S390_TAPE_3490=m +CONFIG_S390_TAPE_3480=m # # Network device drivers @@ -150,6 +150,7 @@ # CONFIG_IPV6_NETLINK is not set # CONFIG_KHTTPD is not set # CONFIG_ATM is not set +# CONFIG_VLAN_8021Q is not set # # @@ -180,12 +181,12 @@ # CONFIG_AUTOFS4_FS is not set # CONFIG_REISERFS_FS is not set # CONFIG_REISERFS_CHECK is not set +# CONFIG_REISERFS_PROC_INFO is not set # CONFIG_ADFS_FS is not set # CONFIG_ADFS_FS_RW is not set # CONFIG_AFFS_FS is not set # CONFIG_HFS_FS is not set # CONFIG_BFS_FS is not set -# CONFIG_CMS_FS is not set # CONFIG_EXT3_FS is not set # CONFIG_JBD is not set # CONFIG_JBD_DEBUG is not set @@ -203,7 +204,7 @@ # CONFIG_JOLIET is not set # CONFIG_ZISOFS is not set # CONFIG_MINIX_FS is not set -# CONFIG_FREEVXFS_FS is not set +# CONFIG_VXFS_FS is not set # CONFIG_NTFS_FS is not set # CONFIG_NTFS_RW is not set # CONFIG_HPFS_FS is not set diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/s390/kernel/debug.c linux-2.5/arch/s390/kernel/debug.c --- linux-2.5.1/arch/s390/kernel/debug.c Thu Oct 11 16:04:57 2001 +++ linux-2.5/arch/s390/kernel/debug.c Thu Dec 27 16:32:30 2001 @@ -228,8 +228,10 @@ strncpy(rc->name, name, MIN(strlen(name), (DEBUG_MAX_PROCF_LEN - 1))); rc->name[MIN(strlen(name), (DEBUG_MAX_PROCF_LEN - 1))] = 0; memset(rc->views, 0, DEBUG_MAX_VIEWS * sizeof(struct debug_view *)); +#ifdef CONFIG_PROC_FS memset(rc->proc_entries, 0 ,DEBUG_MAX_VIEWS * sizeof(struct proc_dir_entry*)); +#endif /* CONFIG_PROC_FS */ atomic_set(&(rc->ref_count), 0); return rc; @@ -346,8 +348,10 @@ if (!db_info) return; if (atomic_dec_and_test(&db_info->ref_count)) { +#ifdef DEBUG printk(KERN_INFO "debug: freeing debug area %p (%s)\n", db_info, db_info->name); +#endif for (i = 0; i < DEBUG_MAX_VIEWS; i++) { if (db_info->views[i] != NULL) debug_delete_proc_dir_entry @@ -541,14 +545,18 @@ debug_info_snapshot = debug_info_copy(debug_info); if(!debug_info_snapshot){ +#ifdef DEBUG printk(KERN_ERR "debug_open: debug_info_copy failed (out of mem)\n"); +#endif rc = -ENOMEM; goto out; } if ((file->private_data = kmalloc(sizeof(file_private_info_t), GFP_ATOMIC)) == 0) { +#ifdef DEBUG printk(KERN_ERR "debug_open: kmalloc failed\n"); +#endif debug_info_free(debug_info_snapshot); rc = -ENOMEM; goto out; @@ -602,6 +610,7 @@ { struct proc_dir_entry *rc = NULL; +#ifdef CONFIG_PROC_FS #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,3,98)) const char *fn = name; int len; @@ -634,6 +643,7 @@ #endif out: +#endif /* CONFIG_PROC_FS */ return rc; } @@ -646,12 +656,14 @@ (struct proc_dir_entry *root, struct proc_dir_entry *proc_entry) { +#ifdef CONFIG_PROC_FS #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,3,98)) proc_unregister(root, proc_entry->low_ino); kfree(proc_entry); #else remove_proc_entry(proc_entry->name, root); #endif +#endif /* CONFIG_PROC_FS */ } /* @@ -677,9 +689,11 @@ goto out; debug_register_view(rc, &debug_level_view); debug_register_view(rc, &debug_flush_view); +#ifdef DEBUG printk(KERN_INFO "debug: reserved %d areas of %d pages for debugging %s\n", nr_areas, 1 << page_order, rc->name); +#endif out: if (rc == NULL){ printk(KERN_ERR "debug: debug_register failed for %s\n",name); @@ -699,7 +713,9 @@ if (!id) goto out; down(&debug_lock); +#ifdef DEBUG printk(KERN_INFO "debug: unregistering %s\n", id->name); +#endif debug_info_put(id); up(&debug_lock); @@ -906,11 +922,13 @@ down(&debug_lock); if (!initialized) { +#ifdef CONFIG_PROC_FS debug_proc_root_entry = debug_create_proc_dir_entry(&proc_root, DEBUG_DIR_ROOT, S_IFDIR | S_IRUGO | S_IXUGO | S_IWUSR | S_IWGRP, NULL, NULL); +#endif /* CONFIG_PROC_FS */ printk(KERN_INFO "debug: Initialization complete\n"); initialized = 1; } @@ -1271,7 +1289,9 @@ #ifdef DEBUG printk("debug_cleanup_module: \n"); #endif +#ifdef CONFIG_PROC_FS debug_delete_proc_dir_entry(&proc_root, debug_proc_root_entry); +#endif /* CONFIG_PROC_FS */ return; } diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/s390/kernel/entry.S linux-2.5/arch/s390/kernel/entry.S --- linux-2.5.1/arch/s390/kernel/entry.S Fri Nov 9 21:58:02 2001 +++ linux-2.5/arch/s390/kernel/entry.S Thu Dec 27 16:32:30 2001 @@ -79,7 +79,7 @@ sigpending = 8 need_resched = 24 tsk_ptrace = 28 -processor = 56 +processor = 52 /* * Base Address of this Module --- saved in __LC_ENTRY_BASE diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/s390/kernel/init_task.c linux-2.5/arch/s390/kernel/init_task.c --- linux-2.5.1/arch/s390/kernel/init_task.c Fri Nov 9 21:58:02 2001 +++ linux-2.5/arch/s390/kernel/init_task.c Thu Dec 27 16:32:30 2001 @@ -12,7 +12,6 @@ #include <asm/uaccess.h> #include <asm/pgtable.h> -static struct vm_area_struct init_mmap = INIT_MMAP; static struct fs_struct init_fs = INIT_FS; static struct files_struct init_files = INIT_FILES; static struct signal_struct init_signals = INIT_SIGNALS; diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/s390/kernel/process.c linux-2.5/arch/s390/kernel/process.c --- linux-2.5.1/arch/s390/kernel/process.c Thu Oct 11 16:04:57 2001 +++ linux-2.5/arch/s390/kernel/process.c Thu Dec 27 22:10:28 2001 @@ -57,7 +57,6 @@ /* endless idle loop with no priority at all */ init_idle(); current->nice = 20; - current->counter = -100; wait_psw.mask = _WAIT_PSW_MASK; wait_psw.addr = (unsigned long) &&idle_wakeup | 0x80000000L; while(1) { @@ -75,173 +74,24 @@ } } -/* - As all the register will only be made displayable to the root - user ( via printk ) or checking if the uid of the user is 0 from - the /proc filesystem please god this will be secure enough DJB. - The lines are given one at a time so as not to chew stack space in - printk on a crash & also for the proc filesystem when you get - 0 returned you know you've got all the lines - */ - -static int sprintf_regs(int line, char *buff, struct task_struct *task, struct pt_regs *regs) -{ - int linelen=0; - int regno,chaincnt; - u32 backchain,prev_backchain,endchain; - u32 ksp = 0; - char *mode = "???"; - - enum - { - sp_linefeed, - sp_psw, - sp_ksp, - sp_gprs, - sp_gprs1, - sp_gprs2, - sp_gprs3, - sp_gprs4, - sp_acrs, - sp_acrs1, - sp_acrs2, - sp_acrs3, - sp_acrs4, - sp_kern_backchain, - sp_kern_backchain1 - }; - - if (task) - ksp = task->thread.ksp; - if (regs && !(regs->psw.mask & PSW_PROBLEM_STATE)) - ksp = regs->gprs[15]; - - if (regs) - mode = (regs->psw.mask & PSW_PROBLEM_STATE)? - "User" : "Kernel"; - - switch(line) - { - case sp_linefeed: - linelen=sprintf(buff,"\n"); - break; - case sp_psw: - if(regs) - linelen=sprintf(buff, "%s PSW: %08lx %08lx %s\n", mode, - (unsigned long) regs->psw.mask, - (unsigned long) regs->psw.addr, - print_tainted()); - else - linelen=sprintf(buff,"pt_regs=NULL some info unavailable\n"); - break; - case sp_ksp: - linelen=sprintf(&buff[linelen], - "task: %08x ksp: %08x pt_regs: %08x\n", - (addr_t)task, (addr_t)ksp, (addr_t)regs); - break; - case sp_gprs: - if(regs) - linelen=sprintf(buff, "%s GPRS:\n", mode); - break; - case sp_gprs1 ... sp_gprs4: - if(regs) - { - regno=(line-sp_gprs1)*4; - linelen=sprintf(buff,"%08x %08x %08x %08x\n", - regs->gprs[regno], - regs->gprs[regno+1], - regs->gprs[regno+2], - regs->gprs[regno+3]); - } - break; - case sp_acrs: - if(regs) - linelen=sprintf(buff, "%s ACRS:\n", mode); - break; - case sp_acrs1 ... sp_acrs4: - if(regs) - { - regno=(line-sp_acrs1)*4; - linelen=sprintf(buff,"%08x %08x %08x %08x\n", - regs->acrs[regno], - regs->acrs[regno+1], - regs->acrs[regno+2], - regs->acrs[regno+3]); - } - break; - case sp_kern_backchain: - if (regs && (regs->psw.mask & PSW_PROBLEM_STATE)) - break; - if (ksp) - linelen=sprintf(buff, "Kernel BackChain CallChain\n"); - break; - default: - if (ksp) - { - - backchain=ksp&PSW_ADDR_MASK; - endchain=((backchain&(-8192))+8192); - prev_backchain=backchain-1; - line-=sp_kern_backchain1; - for(chaincnt=0;;chaincnt++) - { - if((backchain==0)||(backchain>=endchain) - ||(chaincnt>=8)||(prev_backchain>=backchain)) - break; - if(chaincnt==line) - { - linelen+=sprintf(&buff[linelen]," %08x [<%08lx>]\n", - backchain, - *(u32 *)(backchain+56)&PSW_ADDR_MASK); - break; - } - prev_backchain=backchain; - backchain=(*((u32 *)backchain))&PSW_ADDR_MASK; - } - } - } - return(linelen); -} - +extern void show_registers(struct pt_regs *regs); +extern void show_trace(unsigned long *sp); void show_regs(struct pt_regs *regs) { - char buff[80]; - int i, line; + struct task_struct *tsk = current; - printk("CPU: %d\n",smp_processor_id()); - printk("Process %s (pid: %d, stackpage=%08X)\n", - current->comm, current->pid, 4096+(addr_t)current); - - for (line = 0; sprintf_regs(line, buff, current, regs); line++) - printk(buff); - - if (regs->psw.mask & PSW_PROBLEM_STATE) - { - printk("User Code:\n"); - memset(buff, 0, 20); - copy_from_user(buff, - (char *) (regs->psw.addr & PSW_ADDR_MASK), 20); - for (i = 0; i < 20; i++) - printk("%02x ", buff[i]); - printk("\n"); - } + printk("CPU: %d %s\n", tsk->processor, print_tainted()); + printk("Process %s (pid: %d, task: %08lx, ksp: %08x)\n", + current->comm, current->pid, (unsigned long) tsk, + tsk->thread.ksp); + + show_registers(regs); + /* Show stack backtrace if pt_regs is from kernel mode */ + if (!(regs->psw.mask & PSW_PROBLEM_STATE)) + show_trace((unsigned long *) regs->gprs[15]); } -char *task_show_regs(struct task_struct *task, char *buffer) -{ - int line, len; - - for (line = 0; ; line++) - { - len = sprintf_regs(line, buffer, task, task->thread.regs); - if (!len) break; - buffer += len; - } - return buffer; -} - - int kernel_thread(int (*fn)(void *), void * arg, unsigned long flags) { int clone_arg = flags | CLONE_VM; @@ -301,16 +151,10 @@ unsigned long gprs[10]; /* gprs 6 -15 */ unsigned long fprs[4]; /* fpr 4 and 6 */ unsigned long empty[4]; -#if CONFIG_REMOTE_DEBUG - struct gdb_pt_regs childregs; -#else struct pt_regs childregs; -#endif } *frame; frame = (struct stack_frame *) (2*PAGE_SIZE + (unsigned long) p) -1; - frame = (struct stack_frame *) (((unsigned long) frame)&-8L); - p->thread.regs = (struct pt_regs *)&frame->childregs; p->thread.ksp = (unsigned long) frame; memcpy(&frame->childregs,regs,sizeof(struct pt_regs)); frame->childregs.gprs[15] = new_stackp; diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/s390/kernel/ptrace.c linux-2.5/arch/s390/kernel/ptrace.c --- linux-2.5.1/arch/s390/kernel/ptrace.c Tue Sep 18 23:58:03 2001 +++ linux-2.5/arch/s390/kernel/ptrace.c Thu Dec 27 16:32:31 2001 @@ -41,7 +41,7 @@ void FixPerRegisters(struct task_struct *task) { - struct pt_regs *regs = task->thread.regs; + struct pt_regs *regs = __KSTK_PTREGS(task); per_struct *per_info= (per_struct *)&task->thread.per_info; @@ -155,7 +155,7 @@ mask=0xffffffff; if(useraddr<PT_FPC) { - realuseraddr=(addr_t)&(((u8 *)task->thread.regs)[useraddr]); + realuseraddr=((addr_t) __KSTK_PTREGS(task)) + useraddr; if(useraddr<PT_PSWMASK) { copymax=PT_PSWMASK; @@ -217,7 +217,6 @@ { struct task_struct *child; int ret = -EPERM; - unsigned long flags; unsigned long tmp; int copied; ptrace_area parea; diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/s390/kernel/s390_ksyms.c linux-2.5/arch/s390/kernel/s390_ksyms.c --- linux-2.5.1/arch/s390/kernel/s390_ksyms.c Fri Nov 9 21:58:02 2001 +++ linux-2.5/arch/s390/kernel/s390_ksyms.c Thu Dec 27 16:32:31 2001 @@ -18,8 +18,9 @@ EXPORT_SYMBOL_NOVERS(_oi_bitmap); EXPORT_SYMBOL_NOVERS(_ni_bitmap); EXPORT_SYMBOL_NOVERS(_zb_findmap); -EXPORT_SYMBOL_NOVERS(__copy_from_user_fixup); -EXPORT_SYMBOL_NOVERS(__copy_to_user_fixup); +EXPORT_SYMBOL_NOVERS(__copy_from_user_asm); +EXPORT_SYMBOL_NOVERS(__copy_to_user_asm); +EXPORT_SYMBOL_NOVERS(__clear_user_asm); /* * semaphore ops @@ -35,6 +36,7 @@ EXPORT_SYMBOL_NOVERS(memcmp); EXPORT_SYMBOL_NOVERS(memset); EXPORT_SYMBOL_NOVERS(memmove); +EXPORT_SYMBOL_NOVERS(memscan); EXPORT_SYMBOL_NOVERS(strlen); EXPORT_SYMBOL_NOVERS(strchr); EXPORT_SYMBOL_NOVERS(strcmp); @@ -57,5 +59,3 @@ EXPORT_SYMBOL(console_mode); EXPORT_SYMBOL(console_device); EXPORT_SYMBOL_NOVERS(do_call_softirq); - - diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/s390/kernel/setup.c linux-2.5/arch/s390/kernel/setup.c --- linux-2.5.1/arch/s390/kernel/setup.c Sat Nov 17 02:38:39 2001 +++ linux-2.5/arch/s390/kernel/setup.c Thu Dec 27 16:32:31 2001 @@ -439,6 +439,7 @@ lowcore->kernel_stack = ((__u32) &init_task_union) + 8192; lowcore->async_stack = (__u32) __alloc_bootmem(2*PAGE_SIZE, 2*PAGE_SIZE, 0) + 8192; + lowcore->jiffy_timer = -1LL; set_prefix((__u32) lowcore); cpu_init(); boot_cpu_addr = S390_lowcore.cpu_data.cpu_addr; @@ -485,15 +486,16 @@ static int show_cpuinfo(struct seq_file *m, void *v) { struct cpuinfo_S390 *cpuinfo; - unsigned n = v; + unsigned long n = (unsigned long) v - 1; - if (!n--) { + if (!n) { seq_printf(m, "vendor_id : IBM/S390\n" "# processors : %i\n" "bogomips per cpu: %lu.%02lu\n", smp_num_cpus, loops_per_jiffy/(500000/HZ), (loops_per_jiffy/(5000/HZ))%100); - } else if (cpu_online_map & (1 << n)) { + } + if (cpu_online_map & (1 << n)) { cpuinfo = &safe_get_cpu_lowcore(n).cpu_data; seq_printf(m, "processor %i: " "version = %02X, " @@ -508,7 +510,7 @@ static void *c_start(struct seq_file *m, loff_t *pos) { - return *pos <= NR_CPUS ? (void)(*pos+1) : NULL; + return *pos <= NR_CPUS ? (void *)((unsigned long) *pos + 1) : NULL; } static void *c_next(struct seq_file *m, void *v, loff_t *pos) { diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/s390/kernel/smp.c linux-2.5/arch/s390/kernel/smp.c --- linux-2.5.1/arch/s390/kernel/smp.c Wed Nov 21 18:31:09 2001 +++ linux-2.5/arch/s390/kernel/smp.c Thu Dec 27 16:32:31 2001 @@ -29,6 +29,7 @@ #include <linux/smp_lock.h> #include <linux/delay.h> +#include <linux/cache.h> #include <asm/sigp.h> #include <asm/pgalloc.h> @@ -48,14 +49,11 @@ static int max_cpus = NR_CPUS; /* Setup configured maximum number of CPUs to activate */ int smp_num_cpus; struct _lowcore *lowcore_ptr[NR_CPUS]; -unsigned int prof_multiplier[NR_CPUS]; -unsigned int prof_old_multiplier[NR_CPUS]; -unsigned int prof_counter[NR_CPUS]; cycles_t cacheflush_time=0; int smp_threads_ready=0; /* Set when the idlers are all forked. */ static atomic_t smp_commenced = ATOMIC_INIT(0); -spinlock_t kernel_flag = SPIN_LOCK_UNLOCKED; +spinlock_t kernel_flag __cacheline_aligned_in_smp = SPIN_LOCK_UNLOCKED; unsigned long cpu_online_map; @@ -472,7 +470,7 @@ /* * Activate a secondary processor. */ -extern void init_100hz_timer(void); +extern void init_cpu_timer(void); extern int pfault_init(void); extern int pfault_token(void); @@ -485,8 +483,8 @@ /* Wait for completion of smp startup */ while (!atomic_read(&smp_commenced)) /* nothing */ ; - /* init per CPU 100 hz timer */ - init_100hz_timer(); + /* init per CPU timer */ + init_cpu_timer(); #ifdef CONFIG_PFAULT /* Enable pfault pseudo page faults on this cpu. */ pfault_init(); @@ -539,7 +537,7 @@ cpu_lowcore=&get_cpu_lowcore(cpu); cpu_lowcore->save_area[15] = idle->thread.ksp; - cpu_lowcore->kernel_stack = (idle->thread.ksp | 8191) + 1; + cpu_lowcore->kernel_stack = (__u32) idle + 8192; __asm__ __volatile__("la 1,%0\n\t" "stctl 0,15,0(1)\n\t" "la 1,%1\n\t" @@ -590,15 +588,7 @@ /* * Initialize the logical to physical CPU number mapping - * and the per-CPU profiling counter/multiplier */ - - for (i = 0; i < NR_CPUS; i++) { - prof_counter[i] = 1; - prof_old_multiplier[i] = 1; - prof_multiplier[i] = 1; - } - print_cpu_info(&safe_get_cpu_lowcore(0).cpu_data); for(i = 0; i < smp_num_cpus; i++) @@ -645,58 +635,6 @@ int setup_profiling_timer(unsigned int multiplier) { return 0; -} - -/* - * Local timer interrupt handler. It does both profiling and - * process statistics/rescheduling. - * - * We do profiling in every local tick, statistics/rescheduling - * happen only every 'profiling multiplier' ticks. The default - * multiplier is 1 and it can be changed by writing the new multiplier - * value into /proc/profile. - */ - -void smp_local_timer_interrupt(struct pt_regs * regs) -{ - int user = (user_mode(regs) != 0); - int cpu = smp_processor_id(); - - /* - * The profiling function is SMP safe. (nothing can mess - * around with "current", and the profiling counters are - * updated with atomic operations). This is especially - * useful with a profiling multiplier != 1 - */ - if (!user_mode(regs)) - s390_do_profile(regs->psw.addr); - - if (!--prof_counter[cpu]) { - - /* - * The multiplier may have changed since the last time we got - * to this point as a result of the user writing to - * /proc/profile. In this case we need to adjust the APIC - * timer accordingly. - * - * Interrupts are already masked off at this point. - */ - prof_counter[cpu] = prof_multiplier[cpu]; - if (prof_counter[cpu] != prof_old_multiplier[cpu]) { - /* FIXME setup_APIC_timer(calibration_result/prof_counter[cpu] - ); */ - prof_old_multiplier[cpu] = prof_counter[cpu]; - } - - /* - * After doing the above, we need to make like - * a normal interrupt - otherwise timer interrupts - * ignore the global interrupt lock, which is the - * WrongThing (tm) to do. - */ - - update_process_times(user); - } } EXPORT_SYMBOL(lowcore_ptr); diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/s390/kernel/time.c linux-2.5/arch/s390/kernel/time.c --- linux-2.5.1/arch/s390/kernel/time.c Thu Oct 11 16:04:57 2001 +++ linux-2.5/arch/s390/kernel/time.c Thu Dec 27 16:32:31 2001 @@ -33,19 +33,18 @@ #include <asm/irq.h> - /* change this if you have some constant time drift */ -#define USECS_PER_JIFFY ((signed long)1000000/HZ) -#define CLK_TICKS_PER_JIFFY ((signed long)USECS_PER_JIFFY<<12) +#define USECS_PER_JIFFY ((unsigned long) 1000000/HZ) +#define CLK_TICKS_PER_JIFFY ((unsigned long) USECS_PER_JIFFY << 12) #define TICK_SIZE tick -static uint64_t init_timer_cc, last_timer_cc; +static uint64_t init_timer_cc; extern rwlock_t xtime_lock; extern unsigned long wall_jiffies; -void tod_to_timeval(uint64_t todval, struct timeval *xtime) +void tod_to_timeval(__u64 todval, struct timeval *xtime) { const int high_bit = 0x80000000L; const int c_f4240 = 0xf4240L; @@ -79,13 +78,15 @@ : "cc", "memory", "2", "3", "4" ); } -unsigned long do_gettimeoffset(void) +static inline unsigned long do_gettimeoffset(void) { - __u64 timer_cc; + __u64 now; - asm volatile ("STCK %0" : "=m" (timer_cc)); - /* We require the offset from the previous interrupt */ - return ((unsigned long)((timer_cc - last_timer_cc)>>12)); + asm ("STCK %0" : "=m" (now)); + now = (now - init_timer_cc) >> 12; + /* We require the offset from the latest update of xtime */ + now -= (__u64) wall_jiffies*USECS_PER_JIFFY; + return (unsigned long) now; } /* @@ -95,15 +96,10 @@ { unsigned long flags; unsigned long usec, sec; - unsigned long lost_ticks; read_lock_irqsave(&xtime_lock, flags); - lost_ticks = jiffies - wall_jiffies; - usec = do_gettimeoffset(); - if (lost_ticks) - usec +=(USECS_PER_JIFFY*lost_ticks); sec = xtime.tv_sec; - usec += xtime.tv_usec; + usec = xtime.tv_usec + do_gettimeoffset(); read_unlock_irqrestore(&xtime_lock, flags); while (usec >= 1000000) { @@ -149,51 +145,31 @@ extern __u16 boot_cpu_addr; #endif -void do_timer_interrupt(struct pt_regs *regs, __u16 error_code) +static void do_comparator_interrupt(struct pt_regs *regs, __u16 error_code) { int cpu = smp_processor_id(); irq_enter(cpu, 0); - /* - * reset timer to 10ms minus time already elapsed - * since timer-interrupt pending - */ + /* + * set clock comparator for next tick + */ + S390_lowcore.jiffy_timer += CLK_TICKS_PER_JIFFY; + asm volatile ("SCKC %0" : : "m" (S390_lowcore.jiffy_timer)); + #ifdef CONFIG_SMP - if(S390_lowcore.cpu_data.cpu_addr==boot_cpu_addr) { + if (S390_lowcore.cpu_data.cpu_addr == boot_cpu_addr) write_lock(&xtime_lock); - last_timer_cc = S390_lowcore.jiffy_timer_cc; - } -#else - last_timer_cc = S390_lowcore.jiffy_timer_cc; -#endif - /* set clock comparator */ - S390_lowcore.jiffy_timer_cc += CLK_TICKS_PER_JIFFY; - asm volatile ("SCKC %0" : : "m" (S390_lowcore.jiffy_timer_cc)); -/* - * In the SMP case we use the local timer interrupt to do the - * profiling, except when we simulate SMP mode on a uniprocessor - * system, in that case we have to call the local interrupt handler. - */ -#ifdef CONFIG_SMP - /* when SMP, do smp_local_timer_interrupt for *all* CPUs, - but only do the rest for the boot CPU */ - smp_local_timer_interrupt(regs); -#else - if (!user_mode(regs)) - s390_do_profile(regs->psw.addr); -#endif + update_process_times(user_mode(regs)); -#ifdef CONFIG_SMP - if(S390_lowcore.cpu_data.cpu_addr==boot_cpu_addr) -#endif - { + if (S390_lowcore.cpu_data.cpu_addr == boot_cpu_addr) { do_timer(regs); -#ifdef CONFIG_SMP write_unlock(&xtime_lock); -#endif } +#else + do_timer(regs); +#endif irq_exit(cpu, 0); } @@ -201,19 +177,17 @@ /* * Start the clock comparator on the current CPU */ -static long cr0 __attribute__ ((aligned (8))); - -void init_100hz_timer(void) +void init_cpu_timer(void) { + unsigned long cr0; + /* allow clock comparator timer interrupt */ asm volatile ("STCTL 0,0,%0" : "=m" (cr0) : : "memory"); cr0 |= 0x800; asm volatile ("LCTL 0,0,%0" : : "m" (cr0) : "memory"); - /* set clock comparator */ - /* read the TOD clock */ - asm volatile ("STCK %0" : "=m" (S390_lowcore.jiffy_timer_cc)); - S390_lowcore.jiffy_timer_cc += CLK_TICKS_PER_JIFFY; - asm volatile ("SCKC %0" : : "m" (S390_lowcore.jiffy_timer_cc)); + S390_lowcore.jiffy_timer = (__u64) jiffies * CLK_TICKS_PER_JIFFY; + S390_lowcore.jiffy_timer += init_timer_cc + CLK_TICKS_PER_JIFFY; + asm volatile ("SCKC %0" : : "m" (S390_lowcore.jiffy_timer)); } /* @@ -222,6 +196,7 @@ */ void __init time_init(void) { + __u64 set_time_cc; int cc; /* kick the TOD clock */ @@ -241,14 +216,18 @@ printk("time_init: TOD clock stopped/non-operational\n"); break; } + + /* set xtime */ + set_time_cc = init_timer_cc - 0x8126d60e46000000LL + + (0x3c26700LL*1000000*4096); + tod_to_timeval(set_time_cc, &xtime); + /* request the 0x1004 external interrupt */ - if (register_external_interrupt(0x1004, do_timer_interrupt) != 0) - panic("Couldn't request external interrupts 0x1004"); - init_100hz_timer(); - init_timer_cc = S390_lowcore.jiffy_timer_cc; - init_timer_cc -= 0x8126d60e46000000LL - - (0x3c26700LL*1000000*4096); - tod_to_timeval(init_timer_cc, &xtime); + if (register_external_interrupt(0x1004, do_comparator_interrupt) != 0) + panic("Couldn't request external interrupt 0x1004"); + + /* init CPU timer */ + init_cpu_timer(); /* Set do_get_fast_time function pointer. */ do_get_fast_time = do_gettimeofday; diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/s390/kernel/traps.c linux-2.5/arch/s390/kernel/traps.c --- linux-2.5.1/arch/s390/kernel/traps.c Fri Nov 9 21:58:02 2001 +++ linux-2.5/arch/s390/kernel/traps.c Thu Dec 27 16:32:31 2001 @@ -26,15 +26,13 @@ #include <linux/smp_lock.h> #include <linux/init.h> #include <linux/delay.h> +#include <linux/module.h> #include <asm/system.h> #include <asm/uaccess.h> #include <asm/io.h> #include <asm/atomic.h> #include <asm/mathemu.h> -#if CONFIG_REMOTE_DEBUG -#include <asm/gdb-stub.h> -#endif #include <asm/cpcmd.h> #include <asm/s390_ext.h> @@ -60,6 +58,203 @@ extern void pfault_interrupt(struct pt_regs *regs, __u16 error_code); #endif +int kstack_depth_to_print = 12; + +/* + * If the address is either in the .text section of the + * kernel, or in the vmalloc'ed module regions, it *may* + * be the address of a calling routine + */ +extern char _stext, _etext; + +#ifdef CONFIG_MODULES + +extern struct module *module_list; +extern struct module kernel_module; + +static inline int kernel_text_address(unsigned long addr) +{ + int retval = 0; + struct module *mod; + + if (addr >= (unsigned long) &_stext && + addr <= (unsigned long) &_etext) + return 1; + + for (mod = module_list; mod != &kernel_module; mod = mod->next) { + /* mod_bound tests for addr being inside the vmalloc'ed + * module area. Of course it'd be better to test only + * for the .text subset... */ + if (mod_bound(addr, 0, mod)) { + retval = 1; + break; + } + } + + return retval; +} + +#else + +static inline int kernel_text_address(unsigned long addr) +{ + return (addr >= (unsigned long) &_stext && + addr <= (unsigned long) &_etext); +} + +#endif + +void show_trace(unsigned long * stack) +{ + unsigned long backchain, low_addr, high_addr, ret_addr; + int i; + + if (!stack) + stack = (unsigned long*)&stack; + + printk("Call Trace: "); + low_addr = ((unsigned long) stack) & PSW_ADDR_MASK; + high_addr = (low_addr & (-THREAD_SIZE)) + THREAD_SIZE; + /* Skip the first frame (biased stack) */ + backchain = *((unsigned long *) low_addr) & PSW_ADDR_MASK; + /* Print up to 8 lines */ + for (i = 0; i < 8; i++) { + if (backchain < low_addr || backchain >= high_addr) + break; + ret_addr = *((unsigned long *) (backchain+56)) & PSW_ADDR_MASK; + if (!kernel_text_address(ret_addr)) + break; + if (i && ((i % 6) == 0)) + printk("\n "); + printk("[<%08lx>] ", ret_addr); + low_addr = backchain; + backchain = *((unsigned long *) backchain) & PSW_ADDR_MASK; + } + printk("\n"); +} + +void show_trace_task(struct task_struct *tsk) +{ + /* + * We can't print the backtrace of a running process. It is + * unreliable at best and can cause kernel oopses. + */ + if (task_has_cpu(tsk)) + return; + show_trace((unsigned long *) tsk->thread.ksp); +} + +void show_stack(unsigned long *sp) +{ + unsigned long *stack; + int i; + + // debugging aid: "show_stack(NULL);" prints the + // back trace for this cpu. + + if(sp == NULL) + sp = (unsigned long*) &sp; + + stack = sp; + for (i = 0; i < kstack_depth_to_print; i++) { + if (((addr_t) stack & (THREAD_SIZE-1)) == 0) + break; + if (i && ((i % 8) == 0)) + printk("\n "); + printk("%08lx ", *stack++); + } + printk("\n"); + show_trace(sp); +} + +void show_registers(struct pt_regs *regs) +{ + mm_segment_t old_fs; + char *mode; + int i; + + mode = (regs->psw.mask & PSW_PROBLEM_STATE) ? "User" : "Krnl"; + printk("%s PSW : %08lx %08lx\n", + mode, (unsigned long) regs->psw.mask, + (unsigned long) regs->psw.addr); + printk("%s GPRS: %08x %08x %08x %08x\n", mode, + regs->gprs[0], regs->gprs[1], regs->gprs[2], regs->gprs[3]); + printk(" %08x %08x %08x %08x\n", + regs->gprs[4], regs->gprs[5], regs->gprs[6], regs->gprs[7]); + printk(" %08x %08x %08x %08x\n", + regs->gprs[8], regs->gprs[9], regs->gprs[10], regs->gprs[11]); + printk(" %08x %08x %08x %08x\n", + regs->gprs[12], regs->gprs[13], regs->gprs[14], regs->gprs[15]); + printk("%s ACRS: %08x %08x %08x %08x\n", mode, + regs->acrs[0], regs->acrs[1], regs->acrs[2], regs->acrs[3]); + printk(" %08x %08x %08x %08x\n", + regs->acrs[4], regs->acrs[5], regs->acrs[6], regs->acrs[7]); + printk(" %08x %08x %08x %08x\n", + regs->acrs[8], regs->acrs[9], regs->acrs[10], regs->acrs[11]); + printk(" %08x %08x %08x %08x\n", + regs->acrs[12], regs->acrs[13], regs->acrs[14], regs->acrs[15]); + + /* + * Print the first 20 byte of the instruction stream at the + * time of the fault. + */ + old_fs = get_fs(); + if (regs->psw.mask & PSW_PROBLEM_STATE) + set_fs(USER_DS); + else + set_fs(KERNEL_DS); + printk("%s Code: ", mode); + for (i = 0; i < 20; i++) { + unsigned char c; + if (__get_user(c, (char *)(regs->psw.addr + i))) { + printk(" Bad PSW."); + break; + } + printk("%02x ", c); + } + set_fs(old_fs); + + printk("\n"); +} + +/* This is called from fs/proc/array.c */ +char *task_show_regs(struct task_struct *task, char *buffer) +{ + struct pt_regs *regs; + + regs = __KSTK_PTREGS(task); + buffer += sprintf(buffer, "task: %08lx, ksp: %08x\n", + (unsigned long) task, task->thread.ksp); + buffer += sprintf(buffer, "User PSW : %08lx %08lx\n", + (unsigned long) regs->psw.mask, + (unsigned long) regs->psw.addr); + buffer += sprintf(buffer, "User GPRS: %08x %08x %08x %08x\n", + regs->gprs[0], regs->gprs[1], + regs->gprs[2], regs->gprs[3]); + buffer += sprintf(buffer, " %08x %08x %08x %08x\n", + regs->gprs[4], regs->gprs[5], + regs->gprs[6], regs->gprs[7]); + buffer += sprintf(buffer, " %08x %08x %08x %08x\n", + regs->gprs[8], regs->gprs[9], + regs->gprs[10], regs->gprs[11]); + buffer += sprintf(buffer, " %08x %08x %08x %08x\n", + regs->gprs[12], regs->gprs[13], + regs->gprs[14], regs->gprs[15]); + buffer += sprintf(buffer, "User ACRS: %08x %08x %08x %08x\n", + regs->acrs[0], regs->acrs[1], + regs->acrs[2], regs->acrs[3]); + buffer += sprintf(buffer, " %08x %08x %08x %08x\n", + regs->acrs[4], regs->acrs[5], + regs->acrs[6], regs->acrs[7]); + buffer += sprintf(buffer, " %08x %08x %08x %08x\n", + regs->acrs[8], regs->acrs[9], + regs->acrs[10], regs->acrs[11]); + buffer += sprintf(buffer, " %08x %08x %08x %08x\n", + regs->acrs[12], regs->acrs[13], + regs->acrs[14], regs->acrs[15]); + return buffer; +} + spinlock_t die_lock = SPIN_LOCK_UNLOCKED; void die(const char * str, struct pt_regs * regs, long err) @@ -145,7 +340,7 @@ #if CONFIG_REMOTE_DEBUG if(gdb_stub_initialised) { - gdb_stub_handle_exception((struct gdb_pt_regs *)regs,signal); + gdb_stub_handle_exception(regs, signal); return 0; } #endif diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/s390/lib/uaccess.S linux-2.5/arch/s390/lib/uaccess.S --- linux-2.5.1/arch/s390/lib/uaccess.S Tue Feb 13 22:13:44 2001 +++ linux-2.5/arch/s390/lib/uaccess.S Thu Dec 27 16:32:31 2001 @@ -6,46 +6,92 @@ * Copyright (C) 2000 IBM Deutschland Entwicklung GmbH, IBM Corporation * Authors(s): Martin Schwidefsky (schwidefsky@de.ibm.com) * - * These functions have a non-standard call interface + * These functions have standard call interface */ #include <asm/lowcore.h> .text .align 4 - .globl __copy_from_user_fixup -__copy_from_user_fixup: - l 1,__LC_PGM_OLD_PSW+4 - sll 4,1 - srl 4,1 -0: lhi 3,-4096 - sll 3,1 - srl 3,1 - n 3,__LC_TRANS_EXC_ADDR - sr 3,4 - bm 4(1) -1: mvcle 2,4,0 - b 4(1) + .globl __copy_from_user_asm +__copy_from_user_asm: + lr %r5,%r3 + sacf 512 +0: mvcle %r2,%r4,0 + jo 0b + sacf 0 + lr %r2,%r5 + br %r14 +1: l %r1,__LC_PGM_OLD_PSW+4 + sll %r4,1 + srl %r4,1 +2: lhi %r3,-4096 + sll %r3,1 + srl %r3,1 + n %r3,__LC_TRANS_EXC_ADDR + sr %r3,%r4 + bm 4(%r1) +3: mvcle %r2,%r4,0 + b 4(%r1) .section __ex_table,"a" - .long 1b,0b + .long 0b,1b + .long 3b,2b .previous .align 4 .text - .globl __copy_to_user_fixup -__copy_to_user_fixup: - l 1,__LC_PGM_OLD_PSW+4 - sll 4,1 - srl 4,1 -0: lhi 5,-4096 - sll 5,1 - srl 5,1 - n 5,__LC_TRANS_EXC_ADDR - sr 5,4 - bm 4(1) -1: mvcle 4,2,0 - b 4(1) + .globl __copy_to_user_asm +__copy_to_user_asm: + lr %r5,%r3 + sacf 512 +0: mvcle %r4,%r2,0 + jo 0b + sacf 0 + lr %r2,%r3 + br %r14 +1: l %r1,__LC_PGM_OLD_PSW+4 + sll %r4,1 + srl %r4,1 +2: lhi %r5,-4096 + sll %r5,1 + srl %r5,1 + n %r5,__LC_TRANS_EXC_ADDR + sr %r5,%r4 + bm 4(%r1) +3: mvcle %r4,%r2,0 + b 4(%r1) .section __ex_table,"a" - .long 1b,0b + .long 0b,1b + .long 3b,2b + .previous + + .align 4 + .text + .globl __clear_user_asm +__clear_user_asm: + lr %r4,%r2 + lr %r5,%r3 + sr %r2,%r2 + sr %r3,%r3 + sacf 512 +0: mvcle %r4,%r2,0 + jo 0b + sacf 0 + lr %r2,%r3 + br %r14 +1: l %r1,__LC_PGM_OLD_PSW+4 + sll %r4,1 + srl %r4,1 +2: lhi %r5,-4096 + sll %r5,1 + srl %r5,1 + n %r5,__LC_TRANS_EXC_ADDR + sr %r5,%r4 + bm 4(%r1) +3: mvcle %r4,%r2,0 + b 4(%r1) + .section __ex_table,"a" + .long 0b,1b + .long 3b,2b .previous diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/s390/math-emu/math.c linux-2.5/arch/s390/math-emu/math.c --- linux-2.5.1/arch/s390/math-emu/math.c Thu Oct 11 16:04:57 2001 +++ linux-2.5/arch/s390/math-emu/math.c Thu Dec 27 16:32:31 2001 @@ -96,7 +96,7 @@ return SIGSEGV; \ } while (0) -static void display_emulation_not_implemented(char *instr) +static void display_emulation_not_implemented(struct pt_regs *regs, char *instr) { struct pt_regs *regs; __u16 *location; @@ -105,7 +105,6 @@ if(sysctl_ieee_emulation_warnings) #endif { - regs = current->thread.regs; location = (__u16 *)(regs->psw.addr-S390_lowcore.pgm_ilc); printk("%s ieee fpu instruction not emulated " "process name: %s pid: %d \n", @@ -116,10 +115,9 @@ } } -static inline void emu_set_CC (int cc) +static inline void emu_set_CC (struct pt_regs *regs, int cc) { - current->thread.regs->psw.mask = - (current->thread.regs->psw.mask & 0xFFFFCFFF) | ((cc&3) << 12); + regs->psw.mask = (regs->psw.mask & 0xFFFFCFFF) | ((cc&3) << 12); } /* @@ -129,24 +127,24 @@ * 2 : Result is greater than zero * 3 : Result is NaN or INF */ -static inline void emu_set_CC_cs(int class, int sign) +static inline void emu_set_CC_cs(struct pt_regs *regs, int class, int sign) { switch (class) { case FP_CLS_NORMAL: case FP_CLS_INF: - emu_set_CC(sign ? 1 : 2); + emu_set_CC(regs, sign ? 1 : 2); break; case FP_CLS_ZERO: - emu_set_CC(0); + emu_set_CC(regs, 0); break; case FP_CLS_NAN: - emu_set_CC(3); + emu_set_CC(regs, 3); break; } } /* Add long double */ -static int emu_axbr (int rx, int ry) { +static int emu_axbr (struct pt_regs *regs, int rx, int ry) { FP_DECL_Q(QA); FP_DECL_Q(QB); FP_DECL_Q(QR); FP_DECL_EX; mathemu_ldcv cvt; @@ -163,12 +161,12 @@ FP_PACK_QP(&cvt.ld, QR); current->thread.fp_regs.fprs[rx].ui = cvt.w.high; current->thread.fp_regs.fprs[rx+2].ui = cvt.w.low; - emu_set_CC_cs(QR_c, QR_s); + emu_set_CC_cs(regs, QR_c, QR_s); return _fex; } /* Add double */ -static int emu_adbr (int rx, int ry) { +static int emu_adbr (struct pt_regs *regs, int rx, int ry) { FP_DECL_D(DA); FP_DECL_D(DB); FP_DECL_D(DR); FP_DECL_EX; int mode; @@ -178,12 +176,12 @@ FP_UNPACK_DP(DB, ¤t->thread.fp_regs.fprs[ry].d); FP_ADD_D(DR, DA, DB); FP_PACK_DP(¤t->thread.fp_regs.fprs[rx].d, DR); - emu_set_CC_cs(DR_c, DR_s); + emu_set_CC_cs(regs, DR_c, DR_s); return _fex; } /* Add double */ -static int emu_adb (int rx, double *val) { +static int emu_adb (struct pt_regs *regs, int rx, double *val) { FP_DECL_D(DA); FP_DECL_D(DB); FP_DECL_D(DR); FP_DECL_EX; int mode; @@ -193,12 +191,12 @@ FP_UNPACK_DP(DB, val); FP_ADD_D(DR, DA, DB); FP_PACK_DP(¤t->thread.fp_regs.fprs[rx].d, DR); - emu_set_CC_cs(DR_c, DR_s); + emu_set_CC_cs(regs, DR_c, DR_s); return _fex; } /* Add float */ -static int emu_aebr (int rx, int ry) { +static int emu_aebr (struct pt_regs *regs, int rx, int ry) { FP_DECL_S(SA); FP_DECL_S(SB); FP_DECL_S(SR); FP_DECL_EX; int mode; @@ -208,12 +206,12 @@ FP_UNPACK_SP(SB, ¤t->thread.fp_regs.fprs[ry].f); FP_ADD_S(SR, SA, SB); FP_PACK_SP(¤t->thread.fp_regs.fprs[rx].f, SR); - emu_set_CC_cs(SR_c, SR_s); + emu_set_CC_cs(regs, SR_c, SR_s); return _fex; } /* Add float */ -static int emu_aeb (int rx, float *val) { +static int emu_aeb (struct pt_regs *regs, int rx, float *val) { FP_DECL_S(SA); FP_DECL_S(SB); FP_DECL_S(SR); FP_DECL_EX; int mode; @@ -223,12 +221,12 @@ FP_UNPACK_SP(SB, val); FP_ADD_S(SR, SA, SB); FP_PACK_SP(¤t->thread.fp_regs.fprs[rx].f, SR); - emu_set_CC_cs(SR_c, SR_s); + emu_set_CC_cs(regs, SR_c, SR_s); return _fex; } /* Compare long double */ -static int emu_cxbr (int rx, int ry) { +static int emu_cxbr (struct pt_regs *regs, int rx, int ry) { FP_DECL_Q(QA); FP_DECL_Q(QB); mathemu_ldcv cvt; int IR; @@ -244,12 +242,12 @@ * IR == -1 if DA < DB, IR == 0 if DA == DB, * IR == 1 if DA > DB and IR == 3 if unorderded */ - emu_set_CC((IR == -1) ? 1 : (IR == 1) ? 2 : IR); + emu_set_CC(regs, (IR == -1) ? 1 : (IR == 1) ? 2 : IR); return 0; } /* Compare double */ -static int emu_cdbr (int rx, int ry) { +static int emu_cdbr (struct pt_regs *regs, int rx, int ry) { FP_DECL_D(DA); FP_DECL_D(DB); int IR; @@ -260,12 +258,12 @@ * IR == -1 if DA < DB, IR == 0 if DA == DB, * IR == 1 if DA > DB and IR == 3 if unorderded */ - emu_set_CC((IR == -1) ? 1 : (IR == 1) ? 2 : IR); + emu_set_CC(regs, (IR == -1) ? 1 : (IR == 1) ? 2 : IR); return 0; } /* Compare double */ -static int emu_cdb (int rx, double *val) { +static int emu_cdb (struct pt_regs *regs, int rx, double *val) { FP_DECL_D(DA); FP_DECL_D(DB); int IR; @@ -276,12 +274,12 @@ * IR == -1 if DA < DB, IR == 0 if DA == DB, * IR == 1 if DA > DB and IR == 3 if unorderded */ - emu_set_CC((IR == -1) ? 1 : (IR == 1) ? 2 : IR); + emu_set_CC(regs, (IR == -1) ? 1 : (IR == 1) ? 2 : IR); return 0; } /* Compare float */ -static int emu_cebr (int rx, int ry) { +static int emu_cebr (struct pt_regs *regs, int rx, int ry) { FP_DECL_S(SA); FP_DECL_S(SB); int IR; @@ -292,12 +290,12 @@ * IR == -1 if DA < DB, IR == 0 if DA == DB, * IR == 1 if DA > DB and IR == 3 if unorderded */ - emu_set_CC((IR == -1) ? 1 : (IR == 1) ? 2 : IR); + emu_set_CC(regs, (IR == -1) ? 1 : (IR == 1) ? 2 : IR); return 0; } /* Compare float */ -static int emu_ceb (int rx, float *val) { +static int emu_ceb (struct pt_regs *regs, int rx, float *val) { FP_DECL_S(SA); FP_DECL_S(SB); int IR; @@ -308,12 +306,12 @@ * IR == -1 if DA < DB, IR == 0 if DA == DB, * IR == 1 if DA > DB and IR == 3 if unorderded */ - emu_set_CC((IR == -1) ? 1 : (IR == 1) ? 2 : IR); + emu_set_CC(regs, (IR == -1) ? 1 : (IR == 1) ? 2 : IR); return 0; } /* Compare and signal long double */ -static int emu_kxbr (int rx, int ry) { +static int emu_kxbr (struct pt_regs *regs, int rx, int ry) { FP_DECL_Q(QA); FP_DECL_Q(QB); FP_DECL_EX; mathemu_ldcv cvt; @@ -330,14 +328,14 @@ * IR == -1 if DA < DB, IR == 0 if DA == DB, * IR == 1 if DA > DB and IR == 3 if unorderded */ - emu_set_CC((IR == -1) ? 1 : (IR == 1) ? 2 : IR); + emu_set_CC(regs, (IR == -1) ? 1 : (IR == 1) ? 2 : IR); if (IR == 3) FP_SET_EXCEPTION (FP_EX_INVALID); return _fex; } /* Compare and signal double */ -static int emu_kdbr (int rx, int ry) { +static int emu_kdbr (struct pt_regs *regs, int rx, int ry) { FP_DECL_D(DA); FP_DECL_D(DB); FP_DECL_EX; int IR; @@ -349,14 +347,14 @@ * IR == -1 if DA < DB, IR == 0 if DA == DB, * IR == 1 if DA > DB and IR == 3 if unorderded */ - emu_set_CC((IR == -1) ? 1 : (IR == 1) ? 2 : IR); + emu_set_CC(regs, (IR == -1) ? 1 : (IR == 1) ? 2 : IR); if (IR == 3) FP_SET_EXCEPTION (FP_EX_INVALID); return _fex; } /* Compare and signal double */ -static int emu_kdb (int rx, double *val) { +static int emu_kdb (struct pt_regs *regs, int rx, double *val) { FP_DECL_D(DA); FP_DECL_D(DB); FP_DECL_EX; int IR; @@ -368,14 +366,14 @@ * IR == -1 if DA < DB, IR == 0 if DA == DB, * IR == 1 if DA > DB and IR == 3 if unorderded */ - emu_set_CC((IR == -1) ? 1 : (IR == 1) ? 2 : IR); + emu_set_CC(regs, (IR == -1) ? 1 : (IR == 1) ? 2 : IR); if (IR == 3) FP_SET_EXCEPTION (FP_EX_INVALID); return _fex; } /* Compare and signal float */ -static int emu_kebr (int rx, int ry) { +static int emu_kebr (struct pt_regs *regs, int rx, int ry) { FP_DECL_S(SA); FP_DECL_S(SB); FP_DECL_EX; int IR; @@ -387,14 +385,14 @@ * IR == -1 if DA < DB, IR == 0 if DA == DB, * IR == 1 if DA > DB and IR == 3 if unorderded */ - emu_set_CC((IR == -1) ? 1 : (IR == 1) ? 2 : IR); + emu_set_CC(regs, (IR == -1) ? 1 : (IR == 1) ? 2 : IR); if (IR == 3) FP_SET_EXCEPTION (FP_EX_INVALID); return _fex; } /* Compare and signal float */ -static int emu_keb (int rx, float *val) { +static int emu_keb (struct pt_regs *regs, int rx, float *val) { FP_DECL_S(SA); FP_DECL_S(SB); FP_DECL_EX; int IR; @@ -406,14 +404,14 @@ * IR == -1 if DA < DB, IR == 0 if DA == DB, * IR == 1 if DA > DB and IR == 3 if unorderded */ - emu_set_CC((IR == -1) ? 1 : (IR == 1) ? 2 : IR); + emu_set_CC(regs, (IR == -1) ? 1 : (IR == 1) ? 2 : IR); if (IR == 3) FP_SET_EXCEPTION (FP_EX_INVALID); return _fex; } /* Convert from fixed long double */ -static int emu_cxfbr (int rx, int ry) { +static int emu_cxfbr (struct pt_regs *regs, int rx, int ry) { FP_DECL_Q(QR); FP_DECL_EX; mathemu_ldcv cvt; @@ -421,7 +419,7 @@ int mode; mode = current->thread.fp_regs.fpc & 3; - si = current->thread.regs->gprs[ry]; + si = regs->gprs[ry]; FP_FROM_INT_Q(QR, si, 32, int); FP_PACK_QP(&cvt.ld, QR); current->thread.fp_regs.fprs[rx].ui = cvt.w.high; @@ -430,35 +428,35 @@ } /* Convert from fixed double */ -static int emu_cdfbr (int rx, int ry) { +static int emu_cdfbr (struct pt_regs *regs, int rx, int ry) { FP_DECL_D(DR); FP_DECL_EX; __s32 si; int mode; mode = current->thread.fp_regs.fpc & 3; - si = current->thread.regs->gprs[ry]; + si = regs->gprs[ry]; FP_FROM_INT_D(DR, si, 32, int); FP_PACK_DP(¤t->thread.fp_regs.fprs[rx].d, DR); return _fex; } /* Convert from fixed float */ -static int emu_cefbr (int rx, int ry) { +static int emu_cefbr (struct pt_regs *regs, int rx, int ry) { FP_DECL_S(SR); FP_DECL_EX; __s32 si; int mode; mode = current->thread.fp_regs.fpc & 3; - si = current->thread.regs->gprs[ry]; + si = regs->gprs[ry]; FP_FROM_INT_S(SR, si, 32, int); FP_PACK_SP(¤t->thread.fp_regs.fprs[rx].f, SR); return _fex; } /* Convert to fixed long double */ -static int emu_cfxbr (int rx, int ry, int mask) { +static int emu_cfxbr (struct pt_regs *regs, int rx, int ry, int mask) { FP_DECL_Q(QA); FP_DECL_EX; mathemu_ldcv cvt; @@ -475,13 +473,13 @@ cvt.w.low = current->thread.fp_regs.fprs[ry+2].ui; FP_UNPACK_QP(QA, &cvt.ld); FP_TO_INT_ROUND_Q(si, QA, 32, 1); - current->thread.regs->gprs[rx] = si; - emu_set_CC_cs(QA_c, QA_s); + regs->gprs[rx] = si; + emu_set_CC_cs(regs, QA_c, QA_s); return _fex; } /* Convert to fixed double */ -static int emu_cfdbr (int rx, int ry, int mask) { +static int emu_cfdbr (struct pt_regs *regs, int rx, int ry, int mask) { FP_DECL_D(DA); FP_DECL_EX; __s32 si; @@ -495,13 +493,13 @@ mode = mask - 4; FP_UNPACK_DP(DA, ¤t->thread.fp_regs.fprs[ry].d); FP_TO_INT_ROUND_D(si, DA, 32, 1); - current->thread.regs->gprs[rx] = si; - emu_set_CC_cs(DA_c, DA_s); + regs->gprs[rx] = si; + emu_set_CC_cs(regs, DA_c, DA_s); return _fex; } /* Convert to fixed float */ -static int emu_cfebr (int rx, int ry, int mask) { +static int emu_cfebr (struct pt_regs *regs, int rx, int ry, int mask) { FP_DECL_S(SA); FP_DECL_EX; __s32 si; @@ -515,13 +513,13 @@ mode = mask - 4; FP_UNPACK_SP(SA, ¤t->thread.fp_regs.fprs[ry].f); FP_TO_INT_ROUND_S(si, SA, 32, 1); - current->thread.regs->gprs[rx] = si; - emu_set_CC_cs(SA_c, SA_s); + regs->gprs[rx] = si; + emu_set_CC_cs(regs, SA_c, SA_s); return _fex; } /* Divide long double */ -static int emu_dxbr (int rx, int ry) { +static int emu_dxbr (struct pt_regs *regs, int rx, int ry) { FP_DECL_Q(QA); FP_DECL_Q(QB); FP_DECL_Q(QR); FP_DECL_EX; mathemu_ldcv cvt; @@ -542,7 +540,7 @@ } /* Divide double */ -static int emu_ddbr (int rx, int ry) { +static int emu_ddbr (struct pt_regs *regs, int rx, int ry) { FP_DECL_D(DA); FP_DECL_D(DB); FP_DECL_D(DR); FP_DECL_EX; int mode; @@ -556,7 +554,7 @@ } /* Divide double */ -static int emu_ddb (int rx, double *val) { +static int emu_ddb (struct pt_regs *regs, int rx, double *val) { FP_DECL_D(DA); FP_DECL_D(DB); FP_DECL_D(DR); FP_DECL_EX; int mode; @@ -570,7 +568,7 @@ } /* Divide float */ -static int emu_debr (int rx, int ry) { +static int emu_debr (struct pt_regs *regs, int rx, int ry) { FP_DECL_S(SA); FP_DECL_S(SB); FP_DECL_S(SR); FP_DECL_EX; int mode; @@ -584,7 +582,7 @@ } /* Divide float */ -static int emu_deb (int rx, float *val) { +static int emu_deb (struct pt_regs *regs, int rx, float *val) { FP_DECL_S(SA); FP_DECL_S(SB); FP_DECL_S(SR); FP_DECL_EX; int mode; @@ -598,25 +596,25 @@ } /* Divide to integer double */ -static int emu_didbr (int rx, int ry, int mask) { - display_emulation_not_implemented("didbr"); +static int emu_didbr (struct pt_regs *regs, int rx, int ry, int mask) { + display_emulation_not_implemented(regs, "didbr"); return 0; } /* Divide to integer float */ -static int emu_diebr (int rx, int ry, int mask) { - display_emulation_not_implemented("diebr"); +static int emu_diebr (struct pt_regs *regs, int rx, int ry, int mask) { + display_emulation_not_implemented(regs, "diebr"); return 0; } /* Extract fpc */ -static int emu_efpc (int rx, int ry) { - current->thread.regs->gprs[rx] = current->thread.fp_regs.fpc; +static int emu_efpc (struct pt_regs *regs, int rx, int ry) { + regs->gprs[rx] = current->thread.fp_regs.fpc; return 0; } /* Load and test long double */ -static int emu_ltxbr (int rx, int ry) { +static int emu_ltxbr (struct pt_regs *regs, int rx, int ry) { s390_fp_regs *fp_regs = ¤t->thread.fp_regs; mathemu_ldcv cvt; FP_DECL_Q(QA); @@ -627,36 +625,36 @@ FP_UNPACK_QP(QA, &cvt.ld); fp_regs->fprs[rx].ui = fp_regs->fprs[ry].ui; fp_regs->fprs[rx+2].ui = fp_regs->fprs[ry+2].ui; - emu_set_CC_cs(QA_c, QA_s); + emu_set_CC_cs(regs, QA_c, QA_s); return _fex; } /* Load and test double */ -static int emu_ltdbr (int rx, int ry) { +static int emu_ltdbr (struct pt_regs *regs, int rx, int ry) { s390_fp_regs *fp_regs = ¤t->thread.fp_regs; FP_DECL_D(DA); FP_DECL_EX; FP_UNPACK_DP(DA, &fp_regs->fprs[ry].d); fp_regs->fprs[rx].ui = fp_regs->fprs[ry].ui; - emu_set_CC_cs(DA_c, DA_s); + emu_set_CC_cs(regs, DA_c, DA_s); return _fex; } /* Load and test double */ -static int emu_ltebr (int rx, int ry) { +static int emu_ltebr (struct pt_regs *regs, int rx, int ry) { s390_fp_regs *fp_regs = ¤t->thread.fp_regs; FP_DECL_S(SA); FP_DECL_EX; FP_UNPACK_SP(SA, &fp_regs->fprs[ry].f); fp_regs->fprs[rx].ui = fp_regs->fprs[ry].ui; - emu_set_CC_cs(SA_c, SA_s); + emu_set_CC_cs(regs, SA_c, SA_s); return _fex; } /* Load complement long double */ -static int emu_lcxbr (int rx, int ry) { +static int emu_lcxbr (struct pt_regs *regs, int rx, int ry) { FP_DECL_Q(QA); FP_DECL_Q(QR); FP_DECL_EX; mathemu_ldcv cvt; @@ -670,12 +668,12 @@ FP_PACK_QP(&cvt.ld, QR); current->thread.fp_regs.fprs[rx].ui = cvt.w.high; current->thread.fp_regs.fprs[rx+2].ui = cvt.w.low; - emu_set_CC_cs(QR_c, QR_s); + emu_set_CC_cs(regs, QR_c, QR_s); return _fex; } /* Load complement double */ -static int emu_lcdbr (int rx, int ry) { +static int emu_lcdbr (struct pt_regs *regs, int rx, int ry) { FP_DECL_D(DA); FP_DECL_D(DR); FP_DECL_EX; int mode; @@ -684,12 +682,12 @@ FP_UNPACK_DP(DA, ¤t->thread.fp_regs.fprs[ry].d); FP_NEG_D(DR, DA); FP_PACK_DP(¤t->thread.fp_regs.fprs[rx].d, DR); - emu_set_CC_cs(DR_c, DR_s); + emu_set_CC_cs(regs, DR_c, DR_s); return _fex; } /* Load complement float */ -static int emu_lcebr (int rx, int ry) { +static int emu_lcebr (struct pt_regs *regs, int rx, int ry) { FP_DECL_S(SA); FP_DECL_S(SR); FP_DECL_EX; int mode; @@ -698,12 +696,12 @@ FP_UNPACK_SP(SA, ¤t->thread.fp_regs.fprs[ry].f); FP_NEG_S(SR, SA); FP_PACK_SP(¤t->thread.fp_regs.fprs[rx].f, SR); - emu_set_CC_cs(SR_c, SR_s); + emu_set_CC_cs(regs, SR_c, SR_s); return _fex; } /* Load floating point integer long double */ -static int emu_fixbr (int rx, int ry, int mask) { +static int emu_fixbr (struct pt_regs *regs, int rx, int ry, int mask) { s390_fp_regs *fp_regs = ¤t->thread.fp_regs; FP_DECL_Q(QA); FP_DECL_EX; @@ -728,7 +726,7 @@ } /* Load floating point integer double */ -static int emu_fidbr (int rx, int ry, int mask) { +static int emu_fidbr (struct pt_regs *regs, int rx, int ry, int mask) { /* FIXME: rounding mode !! */ s390_fp_regs *fp_regs = ¤t->thread.fp_regs; FP_DECL_D(DA); @@ -749,7 +747,7 @@ } /* Load floating point integer float */ -static int emu_fiebr (int rx, int ry, int mask) { +static int emu_fiebr (struct pt_regs *regs, int rx, int ry, int mask) { s390_fp_regs *fp_regs = ¤t->thread.fp_regs; FP_DECL_S(SA); FP_DECL_EX; @@ -769,7 +767,7 @@ } /* Load lengthened double to long double */ -static int emu_lxdbr (int rx, int ry) { +static int emu_lxdbr (struct pt_regs *regs, int rx, int ry) { FP_DECL_D(DA); FP_DECL_Q(QR); FP_DECL_EX; mathemu_ldcv cvt; @@ -785,7 +783,7 @@ } /* Load lengthened double to long double */ -static int emu_lxdb (int rx, double *val) { +static int emu_lxdb (struct pt_regs *regs, int rx, double *val) { FP_DECL_D(DA); FP_DECL_Q(QR); FP_DECL_EX; mathemu_ldcv cvt; @@ -801,7 +799,7 @@ } /* Load lengthened float to long double */ -static int emu_lxebr (int rx, int ry) { +static int emu_lxebr (struct pt_regs *regs, int rx, int ry) { FP_DECL_S(SA); FP_DECL_Q(QR); FP_DECL_EX; mathemu_ldcv cvt; @@ -817,7 +815,7 @@ } /* Load lengthened float to long double */ -static int emu_lxeb (int rx, float *val) { +static int emu_lxeb (struct pt_regs *regs, int rx, float *val) { FP_DECL_S(SA); FP_DECL_Q(QR); FP_DECL_EX; mathemu_ldcv cvt; @@ -833,7 +831,7 @@ } /* Load lengthened float to double */ -static int emu_ldebr (int rx, int ry) { +static int emu_ldebr (struct pt_regs *regs, int rx, int ry) { FP_DECL_S(SA); FP_DECL_D(DR); FP_DECL_EX; int mode; @@ -846,7 +844,7 @@ } /* Load lengthened float to double */ -static int emu_ldeb (int rx, float *val) { +static int emu_ldeb (struct pt_regs *regs, int rx, float *val) { FP_DECL_S(SA); FP_DECL_D(DR); FP_DECL_EX; int mode; @@ -859,7 +857,7 @@ } /* Load negative long double */ -static int emu_lnxbr (int rx, int ry) { +static int emu_lnxbr (struct pt_regs *regs, int rx, int ry) { FP_DECL_Q(QA); FP_DECL_Q(QR); FP_DECL_EX; mathemu_ldcv cvt; @@ -880,12 +878,12 @@ current->thread.fp_regs.fprs[rx+2].ui = current->thread.fp_regs.fprs[ry+2].ui; } - emu_set_CC_cs(QR_c, QR_s); + emu_set_CC_cs(regs, QR_c, QR_s); return _fex; } /* Load negative double */ -static int emu_lndbr (int rx, int ry) { +static int emu_lndbr (struct pt_regs *regs, int rx, int ry) { FP_DECL_D(DA); FP_DECL_D(DR); FP_DECL_EX; int mode; @@ -898,12 +896,12 @@ } else current->thread.fp_regs.fprs[rx].ui = current->thread.fp_regs.fprs[ry].ui; - emu_set_CC_cs(DR_c, DR_s); + emu_set_CC_cs(regs, DR_c, DR_s); return _fex; } /* Load negative float */ -static int emu_lnebr (int rx, int ry) { +static int emu_lnebr (struct pt_regs *regs, int rx, int ry) { FP_DECL_S(SA); FP_DECL_S(SR); FP_DECL_EX; int mode; @@ -916,12 +914,12 @@ } else current->thread.fp_regs.fprs[rx].ui = current->thread.fp_regs.fprs[ry].ui; - emu_set_CC_cs(SR_c, SR_s); + emu_set_CC_cs(regs, SR_c, SR_s); return _fex; } /* Load positive long double */ -static int emu_lpxbr (int rx, int ry) { +static int emu_lpxbr (struct pt_regs *regs, int rx, int ry) { FP_DECL_Q(QA); FP_DECL_Q(QR); FP_DECL_EX; mathemu_ldcv cvt; @@ -942,12 +940,12 @@ current->thread.fp_regs.fprs[rx+2].ui = current->thread.fp_regs.fprs[ry+2].ui; } - emu_set_CC_cs(QR_c, QR_s); + emu_set_CC_cs(regs, QR_c, QR_s); return _fex; } /* Load positive double */ -static int emu_lpdbr (int rx, int ry) { +static int emu_lpdbr (struct pt_regs *regs, int rx, int ry) { FP_DECL_D(DA); FP_DECL_D(DR); FP_DECL_EX; int mode; @@ -960,12 +958,12 @@ } else current->thread.fp_regs.fprs[rx].ui = current->thread.fp_regs.fprs[ry].ui; - emu_set_CC_cs(DR_c, DR_s); + emu_set_CC_cs(regs, DR_c, DR_s); return _fex; } /* Load positive float */ -static int emu_lpebr (int rx, int ry) { +static int emu_lpebr (struct pt_regs *regs, int rx, int ry) { FP_DECL_S(SA); FP_DECL_S(SR); FP_DECL_EX; int mode; @@ -978,12 +976,12 @@ } else current->thread.fp_regs.fprs[rx].ui = current->thread.fp_regs.fprs[ry].ui; - emu_set_CC_cs(SR_c, SR_s); + emu_set_CC_cs(regs, SR_c, SR_s); return _fex; } /* Load rounded long double to double */ -static int emu_ldxbr (int rx, int ry) { +static int emu_ldxbr (struct pt_regs *regs, int rx, int ry) { FP_DECL_Q(QA); FP_DECL_D(DR); FP_DECL_EX; mathemu_ldcv cvt; @@ -999,7 +997,7 @@ } /* Load rounded long double to float */ -static int emu_lexbr (int rx, int ry) { +static int emu_lexbr (struct pt_regs *regs, int rx, int ry) { FP_DECL_Q(QA); FP_DECL_S(SR); FP_DECL_EX; mathemu_ldcv cvt; @@ -1015,7 +1013,7 @@ } /* Load rounded double to float */ -static int emu_ledbr (int rx, int ry) { +static int emu_ledbr (struct pt_regs *regs, int rx, int ry) { FP_DECL_D(DA); FP_DECL_S(SR); FP_DECL_EX; int mode; @@ -1028,7 +1026,7 @@ } /* Multiply long double */ -static int emu_mxbr (int rx, int ry) { +static int emu_mxbr (struct pt_regs *regs, int rx, int ry) { FP_DECL_Q(QA); FP_DECL_Q(QB); FP_DECL_Q(QR); FP_DECL_EX; mathemu_ldcv cvt; @@ -1049,7 +1047,7 @@ } /* Multiply double */ -static int emu_mdbr (int rx, int ry) { +static int emu_mdbr (struct pt_regs *regs, int rx, int ry) { FP_DECL_D(DA); FP_DECL_D(DB); FP_DECL_D(DR); FP_DECL_EX; int mode; @@ -1063,7 +1061,7 @@ } /* Multiply double */ -static int emu_mdb (int rx, double *val) { +static int emu_mdb (struct pt_regs *regs, int rx, double *val) { FP_DECL_D(DA); FP_DECL_D(DB); FP_DECL_D(DR); FP_DECL_EX; int mode; @@ -1077,7 +1075,7 @@ } /* Multiply double to long double */ -static int emu_mxdbr (int rx, int ry) { +static int emu_mxdbr (struct pt_regs *regs, int rx, int ry) { FP_DECL_D(DA); FP_DECL_Q(QA); FP_DECL_Q(QB); FP_DECL_Q(QR); FP_DECL_EX; mathemu_ldcv cvt; @@ -1096,7 +1094,7 @@ } /* Multiply double to long double */ -static int emu_mxdb (int rx, long double *val) { +static int emu_mxdb (struct pt_regs *regs, int rx, long double *val) { FP_DECL_Q(QA); FP_DECL_Q(QB); FP_DECL_Q(QR); FP_DECL_EX; mathemu_ldcv cvt; @@ -1115,7 +1113,7 @@ } /* Multiply float */ -static int emu_meebr (int rx, int ry) { +static int emu_meebr (struct pt_regs *regs, int rx, int ry) { FP_DECL_S(SA); FP_DECL_S(SB); FP_DECL_S(SR); FP_DECL_EX; int mode; @@ -1129,7 +1127,7 @@ } /* Multiply float */ -static int emu_meeb (int rx, float *val) { +static int emu_meeb (struct pt_regs *regs, int rx, float *val) { FP_DECL_S(SA); FP_DECL_S(SB); FP_DECL_S(SR); FP_DECL_EX; int mode; @@ -1143,7 +1141,7 @@ } /* Multiply float to double */ -static int emu_mdebr (int rx, int ry) { +static int emu_mdebr (struct pt_regs *regs, int rx, int ry) { FP_DECL_S(SA); FP_DECL_D(DA); FP_DECL_D(DB); FP_DECL_D(DR); FP_DECL_EX; int mode; @@ -1159,7 +1157,7 @@ } /* Multiply float to double */ -static int emu_mdeb (int rx, float *val) { +static int emu_mdeb (struct pt_regs *regs, int rx, float *val) { FP_DECL_S(SA); FP_DECL_D(DA); FP_DECL_D(DB); FP_DECL_D(DR); FP_DECL_EX; int mode; @@ -1175,7 +1173,7 @@ } /* Multiply and add double */ -static int emu_madbr (int rx, int ry, int rz) { +static int emu_madbr (struct pt_regs *regs, int rx, int ry, int rz) { FP_DECL_D(DA); FP_DECL_D(DB); FP_DECL_D(DC); FP_DECL_D(DR); FP_DECL_EX; int mode; @@ -1191,7 +1189,7 @@ } /* Multiply and add double */ -static int emu_madb (int rx, double *val, int rz) { +static int emu_madb (struct pt_regs *regs, int rx, double *val, int rz) { FP_DECL_D(DA); FP_DECL_D(DB); FP_DECL_D(DC); FP_DECL_D(DR); FP_DECL_EX; int mode; @@ -1207,7 +1205,7 @@ } /* Multiply and add float */ -static int emu_maebr (int rx, int ry, int rz) { +static int emu_maebr (struct pt_regs *regs, int rx, int ry, int rz) { FP_DECL_S(SA); FP_DECL_S(SB); FP_DECL_S(SC); FP_DECL_S(SR); FP_DECL_EX; int mode; @@ -1223,7 +1221,7 @@ } /* Multiply and add float */ -static int emu_maeb (int rx, float *val, int rz) { +static int emu_maeb (struct pt_regs *regs, int rx, float *val, int rz) { FP_DECL_S(SA); FP_DECL_S(SB); FP_DECL_S(SC); FP_DECL_S(SR); FP_DECL_EX; int mode; @@ -1239,7 +1237,7 @@ } /* Multiply and subtract double */ -static int emu_msdbr (int rx, int ry, int rz) { +static int emu_msdbr (struct pt_regs *regs, int rx, int ry, int rz) { FP_DECL_D(DA); FP_DECL_D(DB); FP_DECL_D(DC); FP_DECL_D(DR); FP_DECL_EX; int mode; @@ -1255,7 +1253,7 @@ } /* Multiply and subtract double */ -static int emu_msdb (int rx, double *val, int rz) { +static int emu_msdb (struct pt_regs *regs, int rx, double *val, int rz) { FP_DECL_D(DA); FP_DECL_D(DB); FP_DECL_D(DC); FP_DECL_D(DR); FP_DECL_EX; int mode; @@ -1271,7 +1269,7 @@ } /* Multiply and subtract float */ -static int emu_msebr (int rx, int ry, int rz) { +static int emu_msebr (struct pt_regs *regs, int rx, int ry, int rz) { FP_DECL_S(SA); FP_DECL_S(SB); FP_DECL_S(SC); FP_DECL_S(SR); FP_DECL_EX; int mode; @@ -1287,7 +1285,7 @@ } /* Multiply and subtract float */ -static int emu_mseb (int rx, float *val, int rz) { +static int emu_mseb (struct pt_regs *regs, int rx, float *val, int rz) { FP_DECL_S(SA); FP_DECL_S(SB); FP_DECL_S(SC); FP_DECL_S(SR); FP_DECL_EX; int mode; @@ -1303,10 +1301,10 @@ } /* Set floating point control word */ -static int emu_sfpc (int rx, int ry) { +static int emu_sfpc (struct pt_regs *regs, int rx, int ry) { __u32 temp; - temp = current->thread.regs->gprs[rx]; + temp = regs->gprs[rx]; if ((temp & ~FPC_VALID_MASK) != 0) return SIGILL; current->thread.fp_regs.fpc = temp; @@ -1314,7 +1312,7 @@ } /* Square root long double */ -static int emu_sqxbr (int rx, int ry) { +static int emu_sqxbr (struct pt_regs *regs, int rx, int ry) { FP_DECL_Q(QA); FP_DECL_Q(QR); FP_DECL_EX; mathemu_ldcv cvt; @@ -1328,12 +1326,12 @@ FP_PACK_QP(&cvt.ld, QR); current->thread.fp_regs.fprs[rx].ui = cvt.w.high; current->thread.fp_regs.fprs[rx+2].ui = cvt.w.low; - emu_set_CC_cs(QR_c, QR_s); + emu_set_CC_cs(regs, QR_c, QR_s); return _fex; } /* Square root double */ -static int emu_sqdbr (int rx, int ry) { +static int emu_sqdbr (struct pt_regs *regs, int rx, int ry) { FP_DECL_D(DA); FP_DECL_D(DR); FP_DECL_EX; int mode; @@ -1342,12 +1340,12 @@ FP_UNPACK_DP(DA, ¤t->thread.fp_regs.fprs[ry].d); FP_SQRT_D(DR, DA); FP_PACK_DP(¤t->thread.fp_regs.fprs[rx].d, DR); - emu_set_CC_cs(DR_c, DR_s); + emu_set_CC_cs(regs, DR_c, DR_s); return _fex; } /* Square root double */ -static int emu_sqdb (int rx, double *val) { +static int emu_sqdb (struct pt_regs *regs, int rx, double *val) { FP_DECL_D(DA); FP_DECL_D(DR); FP_DECL_EX; int mode; @@ -1356,12 +1354,12 @@ FP_UNPACK_DP(DA, val); FP_SQRT_D(DR, DA); FP_PACK_DP(¤t->thread.fp_regs.fprs[rx].d, DR); - emu_set_CC_cs(DR_c, DR_s); + emu_set_CC_cs(regs, DR_c, DR_s); return _fex; } /* Square root float */ -static int emu_sqebr (int rx, int ry) { +static int emu_sqebr (struct pt_regs *regs, int rx, int ry) { FP_DECL_S(SA); FP_DECL_S(SR); FP_DECL_EX; int mode; @@ -1370,12 +1368,12 @@ FP_UNPACK_SP(SA, ¤t->thread.fp_regs.fprs[ry].f); FP_SQRT_S(SR, SA); FP_PACK_SP(¤t->thread.fp_regs.fprs[rx].f, SR); - emu_set_CC_cs(SR_c, SR_s); + emu_set_CC_cs(regs, SR_c, SR_s); return _fex; } /* Square root float */ -static int emu_sqeb (int rx, float *val) { +static int emu_sqeb (struct pt_regs *regs, int rx, float *val) { FP_DECL_S(SA); FP_DECL_S(SR); FP_DECL_EX; int mode; @@ -1384,12 +1382,12 @@ FP_UNPACK_SP(SA, val); FP_SQRT_S(SR, SA); FP_PACK_SP(¤t->thread.fp_regs.fprs[rx].f, SR); - emu_set_CC_cs(SR_c, SR_s); + emu_set_CC_cs(regs, SR_c, SR_s); return _fex; } /* Subtract long double */ -static int emu_sxbr (int rx, int ry) { +static int emu_sxbr (struct pt_regs *regs, int rx, int ry) { FP_DECL_Q(QA); FP_DECL_Q(QB); FP_DECL_Q(QR); FP_DECL_EX; mathemu_ldcv cvt; @@ -1406,12 +1404,12 @@ FP_PACK_QP(&cvt.ld, QR); current->thread.fp_regs.fprs[rx].ui = cvt.w.high; current->thread.fp_regs.fprs[rx+2].ui = cvt.w.low; - emu_set_CC_cs(QR_c, QR_s); + emu_set_CC_cs(regs, QR_c, QR_s); return _fex; } /* Subtract double */ -static int emu_sdbr (int rx, int ry) { +static int emu_sdbr (struct pt_regs *regs, int rx, int ry) { FP_DECL_D(DA); FP_DECL_D(DB); FP_DECL_D(DR); FP_DECL_EX; int mode; @@ -1421,12 +1419,12 @@ FP_UNPACK_DP(DB, ¤t->thread.fp_regs.fprs[ry].d); FP_SUB_D(DR, DA, DB); FP_PACK_DP(¤t->thread.fp_regs.fprs[rx].d, DR); - emu_set_CC_cs(DR_c, DR_s); + emu_set_CC_cs(regs, DR_c, DR_s); return _fex; } /* Subtract double */ -static int emu_sdb (int rx, double *val) { +static int emu_sdb (struct pt_regs *regs, int rx, double *val) { FP_DECL_D(DA); FP_DECL_D(DB); FP_DECL_D(DR); FP_DECL_EX; int mode; @@ -1436,12 +1434,12 @@ FP_UNPACK_DP(DB, val); FP_SUB_D(DR, DA, DB); FP_PACK_DP(¤t->thread.fp_regs.fprs[rx].d, DR); - emu_set_CC_cs(DR_c, DR_s); + emu_set_CC_cs(regs, DR_c, DR_s); return _fex; } /* Subtract float */ -static int emu_sebr (int rx, int ry) { +static int emu_sebr (struct pt_regs *regs, int rx, int ry) { FP_DECL_S(SA); FP_DECL_S(SB); FP_DECL_S(SR); FP_DECL_EX; int mode; @@ -1451,12 +1449,12 @@ FP_UNPACK_SP(SB, ¤t->thread.fp_regs.fprs[ry].f); FP_SUB_S(SR, SA, SB); FP_PACK_SP(¤t->thread.fp_regs.fprs[rx].f, SR); - emu_set_CC_cs(SR_c, SR_s); + emu_set_CC_cs(regs, SR_c, SR_s); return _fex; } /* Subtract float */ -static int emu_seb (int rx, float *val) { +static int emu_seb (struct pt_regs *regs, int rx, float *val) { FP_DECL_S(SA); FP_DECL_S(SB); FP_DECL_S(SR); FP_DECL_EX; int mode; @@ -1466,12 +1464,12 @@ FP_UNPACK_SP(SB, val); FP_SUB_S(SR, SA, SB); FP_PACK_SP(¤t->thread.fp_regs.fprs[rx].f, SR); - emu_set_CC_cs(SR_c, SR_s); + emu_set_CC_cs(regs, SR_c, SR_s); return _fex; } /* Test data class long double */ -static int emu_tcxb (int rx, long val) { +static int emu_tcxb (struct pt_regs *regs, int rx, long val) { FP_DECL_Q(QA); mathemu_ldcv cvt; int bit; @@ -1500,12 +1498,12 @@ } if (!QA_s) bit++; - emu_set_CC(((__u32) val >> bit) & 1); + emu_set_CC(regs, ((__u32) val >> bit) & 1); return 0; } /* Test data class double */ -static int emu_tcdb (int rx, long val) { +static int emu_tcdb (struct pt_regs *regs, int rx, long val) { FP_DECL_D(DA); int bit; @@ -1531,12 +1529,12 @@ } if (!DA_s) bit++; - emu_set_CC(((__u32) val >> bit) & 1); + emu_set_CC(regs, ((__u32) val >> bit) & 1); return 0; } /* Test data class float */ -static int emu_tceb (int rx, long val) { +static int emu_tceb (struct pt_regs *regs, int rx, long val) { FP_DECL_S(SA); int bit; @@ -1562,7 +1560,7 @@ } if (!SA_s) bit++; - emu_set_CC(((__u32) val >> bit) & 1); + emu_set_CC(regs, ((__u32) val >> bit) & 1); return 0; } @@ -1666,8 +1664,9 @@ emu_store_regd(opcode[3] & 15); emu_store_regd((opcode[3] & 15) + 2); /* call the emulation function */ - _fex = ((int (*)(int, int)) jump_table[opcode[1]]) - (opcode[3] >> 4, opcode[3] & 15); + _fex = ((int (*)(struct pt_regs *,int, int)) + jump_table[opcode[1]]) + (regs, opcode[3] >> 4, opcode[3] & 15); emu_load_regd((opcode[3] >> 4) & 15); emu_load_regd(((opcode[3] >> 4) & 15) + 2); emu_load_regd(opcode[3] & 15); @@ -1677,8 +1676,9 @@ emu_store_regd((opcode[3] >> 4) & 15); emu_store_regd(opcode[3] & 15); /* call the emulation function */ - _fex = ((int (*)(int, int)) jump_table[opcode[1]]) - (opcode[3] >> 4, opcode[3] & 15); + _fex = ((int (*)(struct pt_regs *, int, int)) + jump_table[opcode[1]]) + (regs, opcode[3] >> 4, opcode[3] & 15); emu_load_regd((opcode[3] >> 4) & 15); emu_load_regd(opcode[3] & 15); break; @@ -1686,8 +1686,9 @@ emu_store_rege((opcode[3] >> 4) & 15); emu_store_rege(opcode[3] & 15); /* call the emulation function */ - _fex = ((int (*)(int, int)) jump_table[opcode[1]]) - (opcode[3] >> 4, opcode[3] & 15); + _fex = ((int (*)(struct pt_regs *, int, int)) + jump_table[opcode[1]]) + (regs, opcode[3] >> 4, opcode[3] & 15); emu_load_rege((opcode[3] >> 4) & 15); emu_load_rege(opcode[3] & 15); break; @@ -1699,8 +1700,9 @@ emu_store_regd(opcode[3] & 15); emu_store_regd((opcode[3] & 15) + 2); /* call the emulation function */ - _fex = ((int (*)(int, int, int)) jump_table[opcode[1]]) - (opcode[3] >> 4, opcode[3] & 15, opcode[2] >> 4); + _fex = ((int (*)(struct pt_regs *, int, int, int)) + jump_table[opcode[1]]) + (regs, opcode[3] >> 4, opcode[3] & 15, opcode[2] >> 4); emu_load_regd((opcode[3] >> 4) & 15); emu_load_regd(((opcode[3] >> 4) & 15) + 2); emu_load_regd(opcode[3] & 15); @@ -1711,8 +1713,9 @@ emu_store_regd((opcode[3] >> 4) & 15); emu_store_regd(opcode[3] & 15); /* call the emulation function */ - _fex = ((int (*)(int, int, int)) jump_table[opcode[1]]) - (opcode[3] >> 4, opcode[3] & 15, opcode[2] >> 4); + _fex = ((int (*)(struct pt_regs *, int, int, int)) + jump_table[opcode[1]]) + (regs, opcode[3] >> 4, opcode[3] & 15, opcode[2] >> 4); emu_load_regd((opcode[2] >> 4) & 15); emu_load_regd((opcode[3] >> 4) & 15); emu_load_regd(opcode[3] & 15); @@ -1722,8 +1725,9 @@ emu_store_rege((opcode[3] >> 4) & 15); emu_store_rege(opcode[3] & 15); /* call the emulation function */ - _fex = ((int (*)(int, int, int)) jump_table[opcode[1]]) - (opcode[3] >> 4, opcode[3] & 15, opcode[2] >> 4); + _fex = ((int (*)(struct pt_regs *, int, int, int)) + jump_table[opcode[1]]) + (regs, opcode[3] >> 4, opcode[3] & 15, opcode[2] >> 4); emu_load_rege((opcode[2] >> 4) & 15); emu_load_rege((opcode[3] >> 4) & 15); emu_load_rege(opcode[3] & 15); @@ -1732,21 +1736,24 @@ /* call the emulation function */ if (opcode[3] & 0x20) return SIGILL; - _fex = ((int (*)(int, int)) jump_table[opcode[1]]) - (opcode[3] >> 4, opcode[3] & 15); + _fex = ((int (*)(struct pt_regs *, int, int)) + jump_table[opcode[1]]) + (regs, opcode[3] >> 4, opcode[3] & 15); emu_load_regd((opcode[3] >> 4) & 15); emu_load_regd(((opcode[3] >> 4) & 15) + 2); break; case 8: /* RRE format, cdfbr instruction */ /* call the emulation function */ - _fex = ((int (*)(int, int)) jump_table[opcode[1]]) - (opcode[3] >> 4, opcode[3] & 15); + _fex = ((int (*)(struct pt_regs *, int, int)) + jump_table[opcode[1]]) + (regs, opcode[3] >> 4, opcode[3] & 15); emu_load_regd((opcode[3] >> 4) & 15); break; case 9: /* RRE format, cefbr instruction */ /* call the emulation function */ - _fex = ((int (*)(int, int)) jump_table[opcode[1]]) - (opcode[3] >> 4, opcode[3] & 15); + _fex = ((int (*)(struct pt_regs *, int, int)) + jump_table[opcode[1]]) + (regs, opcode[3] >> 4, opcode[3] & 15); emu_load_rege((opcode[3] >> 4) & 15); break; case 10: /* RRF format, cfxbr instruction */ @@ -1758,8 +1765,9 @@ emu_store_regd(opcode[3] & 15); emu_store_regd((opcode[3] & 15) + 2); /* call the emulation function */ - _fex = ((int (*)(int, int, int)) jump_table[opcode[1]]) - (opcode[3] >> 4, opcode[3] & 15, opcode[2] >> 4); + _fex = ((int (*)(struct pt_regs *, int, int, int)) + jump_table[opcode[1]]) + (regs, opcode[3] >> 4, opcode[3] & 15, opcode[2] >> 4); break; case 11: /* RRF format, cfdbr instruction */ if ((opcode[2] & 128) == 128 || (opcode[2] & 96) == 32) @@ -1767,8 +1775,9 @@ return SIGILL; emu_store_regd(opcode[3] & 15); /* call the emulation function */ - _fex = ((int (*)(int, int, int)) jump_table[opcode[1]]) - (opcode[3] >> 4, opcode[3] & 15, opcode[2] >> 4); + _fex = ((int (*)(struct pt_regs *, int, int, int)) + jump_table[opcode[1]]) + (regs, opcode[3] >> 4, opcode[3] & 15, opcode[2] >> 4); break; case 12: /* RRF format, cfebr instruction */ if ((opcode[2] & 128) == 128 || (opcode[2] & 96) == 32) @@ -1776,8 +1785,9 @@ return SIGILL; emu_store_rege(opcode[3] & 15); /* call the emulation function */ - _fex = ((int (*)(int, int, int)) jump_table[opcode[1]]) - (opcode[3] >> 4, opcode[3] & 15, opcode[2] >> 4); + _fex = ((int (*)(struct pt_regs *, int, int, int)) + jump_table[opcode[1]]) + (regs, opcode[3] >> 4, opcode[3] & 15, opcode[2] >> 4); break; case 13: /* RRE format, ldxbr & mdxbr instruction */ /* double store but long double load */ @@ -1786,8 +1796,9 @@ emu_store_regd((opcode[3] >> 4) & 15); emu_store_regd(opcode[3] & 15); /* call the emulation function */ - _fex = ((int (*)(int, int)) jump_table[opcode[1]]) - (opcode[3] >> 4, opcode[3] & 15); + _fex = ((int (*)(struct pt_regs *, int, int)) + jump_table[opcode[1]]) + (regs, opcode[3] >> 4, opcode[3] & 15); emu_load_regd((opcode[3] >> 4) & 15); emu_load_regd(((opcode[3] >> 4) & 15) + 2); break; @@ -1798,8 +1809,9 @@ emu_store_rege((opcode[3] >> 4) & 15); emu_store_rege(opcode[3] & 15); /* call the emulation function */ - _fex = ((int (*)(int, int)) jump_table[opcode[1]]) - (opcode[3] >> 4, opcode[3] & 15); + _fex = ((int (*)(struct pt_regs *, int, int)) + jump_table[opcode[1]]) + (regs, opcode[3] >> 4, opcode[3] & 15); emu_load_regd((opcode[3] >> 4) & 15); emu_load_regd(((opcode[3] >> 4) & 15) + 2); break; @@ -1808,8 +1820,9 @@ emu_store_rege((opcode[3] >> 4) & 15); emu_store_rege(opcode[3] & 15); /* call the emulation function */ - _fex = ((int (*)(int, int)) jump_table[opcode[1]]) - (opcode[3] >> 4, opcode[3] & 15); + _fex = ((int (*)(struct pt_regs *, int, int)) + jump_table[opcode[1]]) + (regs, opcode[3] >> 4, opcode[3] & 15); emu_load_regd((opcode[3] >> 4) & 15); break; case 16: /* RRE format, ldxbr instruction */ @@ -1819,8 +1832,9 @@ emu_store_regd(opcode[3] & 15); emu_store_regd((opcode[3] & 15) + 2); /* call the emulation function */ - _fex = ((int (*)(int, int)) jump_table[opcode[1]]) - (opcode[3] >> 4, opcode[3] & 15); + _fex = ((int (*)(struct pt_regs *, int, int)) + jump_table[opcode[1]]) + (regs, opcode[3] >> 4, opcode[3] & 15); emu_load_regd((opcode[3] >> 4) & 15); break; case 17: /* RRE format, ldxbr instruction */ @@ -1830,22 +1844,25 @@ emu_store_regd(opcode[3] & 15); emu_store_regd((opcode[3] & 15) + 2); /* call the emulation function */ - _fex = ((int (*)(int, int)) jump_table[opcode[1]]) - (opcode[3] >> 4, opcode[3] & 15); + _fex = ((int (*)(struct pt_regs *, int, int)) + jump_table[opcode[1]]) + (regs, opcode[3] >> 4, opcode[3] & 15); emu_load_rege((opcode[3] >> 4) & 15); break; case 18: /* RRE format, ledbr instruction */ /* double store but float load */ emu_store_regd(opcode[3] & 15); /* call the emulation function */ - _fex = ((int (*)(int, int)) jump_table[opcode[1]]) - (opcode[3] >> 4, opcode[3] & 15); + _fex = ((int (*)(struct pt_regs *, int, int)) + jump_table[opcode[1]]) + (regs, opcode[3] >> 4, opcode[3] & 15); emu_load_rege((opcode[3] >> 4) & 15); break; case 19: /* RRE format, efpc & sfpc instruction */ /* call the emulation function */ - _fex = ((int (*)(int, int)) jump_table[opcode[1]]) - (opcode[3] >> 4, opcode[3] & 15); + _fex = ((int (*)(struct pt_regs *, int, int)) + jump_table[opcode[1]]) + (regs, opcode[3] >> 4, opcode[3] & 15); break; default: /* invalid operation */ return SIGILL; @@ -1904,8 +1921,9 @@ dxb = (__u64 *) calc_addr(regs, opc >> 16, opc >> 12, opc); mathemu_copy_from_user(&temp, dxb, 8); /* call the emulation function */ - _fex = ((int (*)(int, double *)) jump_table[opcode[5]]) - (opcode[1] >> 4, (double *) &temp); + _fex = ((int (*)(struct pt_regs *, int, double *)) + jump_table[opcode[5]]) + (regs, opcode[1] >> 4, (double *) &temp); emu_load_regd((opcode[1] >> 4) & 15); break; } @@ -1918,8 +1936,9 @@ dxb = (__u32 *) calc_addr(regs, opc >> 16, opc >> 12, opc); mathemu_get_user(temp, dxb); /* call the emulation function */ - _fex = ((int (*)(int, float *)) jump_table[opcode[5]]) - (opcode[1] >> 4, (float *) &temp); + _fex = ((int (*)(struct pt_regs *, int, float *)) + jump_table[opcode[5]]) + (regs, opcode[1] >> 4, (float *) &temp); emu_load_rege((opcode[1] >> 4) & 15); break; } @@ -1933,8 +1952,9 @@ dxb = (__u64 *) calc_addr(regs, opc >> 16, opc >> 12, opc); mathemu_copy_from_user(&temp, dxb, 8); /* call the emulation function */ - _fex = ((int (*)(int, double *, int)) jump_table[opcode[5]]) - (opcode[1] >> 4, (double *) &temp, opcode[4] >> 4); + _fex = ((int (*)(struct pt_regs *, int, double *, int)) + jump_table[opcode[5]]) + (regs, opcode[1] >> 4, (double *) &temp, opcode[4] >> 4); emu_load_regd((opcode[1] >> 4) & 15); break; } @@ -1948,8 +1968,9 @@ dxb = (__u32 *) calc_addr(regs, opc >> 16, opc >> 12, opc); mathemu_get_user(temp, dxb); /* call the emulation function */ - _fex = ((int (*)(int, float *, int)) jump_table[opcode[5]]) - (opcode[1] >> 4, (float *) &temp, opcode[4] >> 4); + _fex = ((int (*)(struct pt_regs *, int, float *, int)) + jump_table[opcode[5]]) + (regs, opcode[1] >> 4, (float *) &temp, opcode[4] >> 4); emu_load_rege((opcode[4] >> 4) & 15); break; } @@ -1965,8 +1986,9 @@ dxb = (__u64 *) calc_addr(regs, opc >> 16, opc >> 12, opc); mathemu_copy_from_user(&temp, dxb, 8); /* call the emulation function */ - _fex = ((int (*)(int, double *)) jump_table[opcode[5]]) - (opcode[1] >> 4, (double *) &temp); + _fex = ((int (*)(struct pt_regs *, int, double *)) + jump_table[opcode[5]]) + (regs, opcode[1] >> 4, (double *) &temp); emu_load_regd((opcode[1] >> 4) & 15); emu_load_regd(((opcode[1] >> 4) & 15) + 2); break; @@ -1981,8 +2003,9 @@ dxb = (__u32 *) calc_addr(regs, opc >> 16, opc >> 12, opc); mathemu_get_user(temp, dxb); /* call the emulation function */ - _fex = ((int (*)(int, float *)) jump_table[opcode[5]]) - (opcode[1] >> 4, (float *) &temp); + _fex = ((int (*)(struct pt_regs *, int, float *)) + jump_table[opcode[5]]) + (regs, opcode[1] >> 4, (float *) &temp); emu_load_regd((opcode[1] >> 4) & 15); break; } @@ -1998,8 +2021,9 @@ dxb = (__u32 *) calc_addr(regs, opc >> 16, opc >> 12, opc); mathemu_get_user(temp, dxb); /* call the emulation function */ - _fex = ((int (*)(int, float *)) jump_table[opcode[5]]) - (opcode[1] >> 4, (float *) &temp); + _fex = ((int (*)(struct pt_regs *, int, float *)) + jump_table[opcode[5]]) + (regs, opcode[1] >> 4, (float *) &temp); emu_load_regd((opcode[1] >> 4) & 15); emu_load_regd(((opcode[1] >> 4) & 15) + 2); break; @@ -2012,8 +2036,9 @@ opc = *((__u32 *) opcode); dxb = (__u64) calc_addr(regs, opc >> 16, opc >> 12, opc); /* call the emulation function */ - _fex = ((int (*)(int, long)) jump_table[opcode[5]]) - (opcode[1] >> 4, dxb); + _fex = ((int (*)(struct pt_regs *, int, long)) + jump_table[opcode[5]]) + (regs, opcode[1] >> 4, dxb); break; } case 9: /* RXE format, RX address used as int value */ { @@ -2024,8 +2049,9 @@ opc = *((__u32 *) opcode); dxb = (__u64) calc_addr(regs, opc >> 16, opc >> 12, opc); /* call the emulation function */ - _fex = ((int (*)(int, long)) jump_table[opcode[5]]) - (opcode[1] >> 4, dxb); + _fex = ((int (*)(struct pt_regs *, int, long)) + jump_table[opcode[5]]) + (regs, opcode[1] >> 4, dxb); break; } case 10: /* RXE format, RX address used as int value */ { @@ -2039,8 +2065,9 @@ opc = *((__u32 *) opcode); dxb = (__u64) calc_addr(regs, opc >> 16, opc >> 12, opc); /* call the emulation function */ - _fex = ((int (*)(int, long)) jump_table[opcode[5]]) - (opcode[1] >> 4, dxb); + _fex = ((int (*)(struct pt_regs *, int, long)) + jump_table[opcode[5]]) + (regs, opcode[1] >> 4, dxb); break; } default: /* invalid operation */ diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/s390/vmlinux-shared.lds linux-2.5/arch/s390/vmlinux-shared.lds --- linux-2.5.1/arch/s390/vmlinux-shared.lds Sun Aug 12 17:38:48 2001 +++ linux-2.5/arch/s390/vmlinux-shared.lds Sat Dec 29 11:10:40 2001 @@ -13,7 +13,6 @@ *(.fixup) *(.gnu.warning) } = 0x0700 - .text.lock : { *(.text.lock) } /* out-of-line lock text */ .rodata : { *(.rodata) } .kstrtab : { *(.kstrtab) } diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/s390/vmlinux.lds linux-2.5/arch/s390/vmlinux.lds --- linux-2.5.1/arch/s390/vmlinux.lds Mon Jul 2 21:40:58 2001 +++ linux-2.5/arch/s390/vmlinux.lds Sat Dec 29 11:10:40 2001 @@ -13,7 +13,6 @@ *(.fixup) *(.gnu.warning) } = 0x0700 - .text.lock : { *(.text.lock) } /* out-of-line lock text */ .rodata : { *(.rodata) *(.rodata.*) } .kstrtab : { *(.kstrtab) } diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/s390x/Makefile linux-2.5/arch/s390x/Makefile --- linux-2.5.1/arch/s390x/Makefile Thu Oct 11 16:04:57 2001 +++ linux-2.5/arch/s390x/Makefile Thu Dec 27 16:32:31 2001 @@ -55,6 +55,9 @@ image: vmlinux @$(MAKEBOOT) image +install: vmlinux + @$(MAKEBOOT) BOOTIMAGE=image install + archclean: @$(MAKEBOOT) clean diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/s390x/boot/Makefile linux-2.5/arch/s390x/boot/Makefile --- linux-2.5.1/arch/s390x/boot/Makefile Thu Apr 12 02:02:29 2001 +++ linux-2.5/arch/s390x/boot/Makefile Thu Dec 27 16:32:31 2001 @@ -35,3 +35,5 @@ clean: rm -f image listing iplfba.boot ipleckd.boot ipldump.boot +install: $(CONFIGURE) $(BOOTIMAGE) + sh -x ./install.sh $(KERNELRELEASE) $(BOOTIMAGE) $(TOPDIR)/System.map $(TOPDIR)/Kerntypes "$(INSTALL_PATH)" diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/s390x/config.in linux-2.5/arch/s390x/config.in --- linux-2.5.1/arch/s390x/config.in Thu Oct 11 16:04:57 2001 +++ linux-2.5/arch/s390x/config.in Thu Dec 27 16:32:31 2001 @@ -71,9 +71,9 @@ comment 'Kernel hacking' #bool 'Debug kmalloc/kfree' CONFIG_DEBUG_MALLOC -if [ "$CONFIG_CTC" = "y" ]; then - bool 'Remote GDB kernel debugging' CONFIG_REMOTE_DEBUG -fi +#if [ "$CONFIG_CTC" = "y" ]; then +# bool 'Remote GDB kernel debugging' CONFIG_REMOTE_DEBUG +#fi bool 'Magic SysRq key' CONFIG_MAGIC_SYSRQ endmenu diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/s390x/defconfig linux-2.5/arch/s390x/defconfig --- linux-2.5.1/arch/s390x/defconfig Fri Nov 9 21:58:02 2001 +++ linux-2.5/arch/s390x/defconfig Thu Dec 27 16:32:31 2001 @@ -6,7 +6,7 @@ # CONFIG_MCA is not set CONFIG_RWSEM_GENERIC_SPINLOCK=y # CONFIG_RWSEM_XCHGADD_ALGORITHM is not set -CONFIG_GENERIC_BUST_SPINLOCK=n +# CONFIG_GENERIC_BUST_SPINLOCK is not set CONFIG_ARCH_S390=y CONFIG_ARCH_S390X=y @@ -103,8 +103,8 @@ # # S/390 tape hardware support # -CONFIG_S390_TAPE_3490=y -CONFIG_S390_TAPE_3480=y +CONFIG_S390_TAPE_3490=m +CONFIG_S390_TAPE_3480=m # # Network device drivers @@ -150,6 +150,7 @@ # CONFIG_IPV6_NETLINK is not set # CONFIG_KHTTPD is not set # CONFIG_ATM is not set +# CONFIG_VLAN_8021Q is not set # # @@ -180,12 +181,12 @@ # CONFIG_AUTOFS4_FS is not set # CONFIG_REISERFS_FS is not set # CONFIG_REISERFS_CHECK is not set +# CONFIG_REISERFS_PROC_INFO is not set # CONFIG_ADFS_FS is not set # CONFIG_ADFS_FS_RW is not set # CONFIG_AFFS_FS is not set # CONFIG_HFS_FS is not set # CONFIG_BFS_FS is not set -# CONFIG_CMS_FS is not set # CONFIG_EXT3_FS is not set # CONFIG_JBD is not set # CONFIG_JBD_DEBUG is not set @@ -203,7 +204,7 @@ # CONFIG_JOLIET is not set # CONFIG_ZISOFS is not set # CONFIG_MINIX_FS is not set -# CONFIG_FREEVXFS_FS is not set +# CONFIG_VXFS_FS is not set # CONFIG_NTFS_FS is not set # CONFIG_NTFS_RW is not set # CONFIG_HPFS_FS is not set diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/s390x/kernel/debug.c linux-2.5/arch/s390x/kernel/debug.c --- linux-2.5.1/arch/s390x/kernel/debug.c Thu Oct 11 16:04:57 2001 +++ linux-2.5/arch/s390x/kernel/debug.c Thu Dec 27 16:32:31 2001 @@ -228,8 +228,10 @@ strncpy(rc->name, name, MIN(strlen(name), (DEBUG_MAX_PROCF_LEN - 1))); rc->name[MIN(strlen(name), (DEBUG_MAX_PROCF_LEN - 1))] = 0; memset(rc->views, 0, DEBUG_MAX_VIEWS * sizeof(struct debug_view *)); +#ifdef CONFIG_PROC_FS memset(rc->proc_entries, 0 ,DEBUG_MAX_VIEWS * sizeof(struct proc_dir_entry*)); +#endif /* CONFIG_PROC_FS */ atomic_set(&(rc->ref_count), 0); return rc; @@ -346,8 +348,10 @@ if (!db_info) return; if (atomic_dec_and_test(&db_info->ref_count)) { +#ifdef DEBUG printk(KERN_INFO "debug: freeing debug area %p (%s)\n", db_info, db_info->name); +#endif for (i = 0; i < DEBUG_MAX_VIEWS; i++) { if (db_info->views[i] != NULL) debug_delete_proc_dir_entry @@ -541,14 +545,18 @@ debug_info_snapshot = debug_info_copy(debug_info); if(!debug_info_snapshot){ +#ifdef DEBUG printk(KERN_ERR "debug_open: debug_info_copy failed (out of mem)\n"); +#endif rc = -ENOMEM; goto out; } if ((file->private_data = kmalloc(sizeof(file_private_info_t), GFP_ATOMIC)) == 0) { +#ifdef DEBUG printk(KERN_ERR "debug_open: kmalloc failed\n"); +#endif debug_info_free(debug_info_snapshot); rc = -ENOMEM; goto out; @@ -602,6 +610,7 @@ { struct proc_dir_entry *rc = NULL; +#ifdef CONFIG_PROC_FS #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,3,98)) const char *fn = name; int len; @@ -634,6 +643,7 @@ #endif out: +#endif /* CONFIG_PROC_FS */ return rc; } @@ -646,12 +656,14 @@ (struct proc_dir_entry *root, struct proc_dir_entry *proc_entry) { +#ifdef CONFIG_PROC_FS #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,3,98)) proc_unregister(root, proc_entry->low_ino); kfree(proc_entry); #else remove_proc_entry(proc_entry->name, root); #endif +#endif /* CONFIG_PROC_FS */ } /* @@ -677,9 +689,11 @@ goto out; debug_register_view(rc, &debug_level_view); debug_register_view(rc, &debug_flush_view); +#ifdef DEBUG printk(KERN_INFO "debug: reserved %d areas of %d pages for debugging %s\n", nr_areas, 1 << page_order, rc->name); +#endif out: if (rc == NULL){ printk(KERN_ERR "debug: debug_register failed for %s\n",name); @@ -699,7 +713,9 @@ if (!id) goto out; down(&debug_lock); +#ifdef DEBUG printk(KERN_INFO "debug: unregistering %s\n", id->name); +#endif debug_info_put(id); up(&debug_lock); @@ -906,11 +922,13 @@ down(&debug_lock); if (!initialized) { +#ifdef CONFIG_PROC_FS debug_proc_root_entry = debug_create_proc_dir_entry(&proc_root, DEBUG_DIR_ROOT, S_IFDIR | S_IRUGO | S_IXUGO | S_IWUSR | S_IWGRP, NULL, NULL); +#endif /* CONFIG_PROC_FS */ printk(KERN_INFO "debug: Initialization complete\n"); initialized = 1; } @@ -1271,7 +1289,9 @@ #ifdef DEBUG printk("debug_cleanup_module: \n"); #endif +#ifdef CONFIG_PROC_FS debug_delete_proc_dir_entry(&proc_root, debug_proc_root_entry); +#endif /* CONFIG_PROC_FS */ return; } diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/s390x/kernel/entry.S linux-2.5/arch/s390x/kernel/entry.S --- linux-2.5.1/arch/s390x/kernel/entry.S Fri Nov 9 21:58:02 2001 +++ linux-2.5/arch/s390x/kernel/entry.S Thu Dec 27 16:32:31 2001 @@ -79,7 +79,7 @@ sigpending = 16 need_resched = 32 tsk_ptrace = 40 -processor = 92 +processor = 88 /* * Register usage in interrupt handlers: diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/s390x/kernel/init_task.c linux-2.5/arch/s390x/kernel/init_task.c --- linux-2.5.1/arch/s390x/kernel/init_task.c Fri Nov 9 21:58:02 2001 +++ linux-2.5/arch/s390x/kernel/init_task.c Thu Dec 27 16:32:31 2001 @@ -12,7 +12,6 @@ #include <asm/uaccess.h> #include <asm/pgtable.h> -static struct vm_area_struct init_mmap = INIT_MMAP; static struct fs_struct init_fs = INIT_FS; static struct files_struct init_files = INIT_FILES; static struct signal_struct init_signals = INIT_SIGNALS; diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/s390x/kernel/ioctl32.c linux-2.5/arch/s390x/kernel/ioctl32.c --- linux-2.5.1/arch/s390x/kernel/ioctl32.c Wed Nov 7 22:39:36 2001 +++ linux-2.5/arch/s390x/kernel/ioctl32.c Thu Dec 27 16:32:31 2001 @@ -24,6 +24,7 @@ #include <linux/route.h> #include <linux/ext2_fs.h> #include <linux/hdreg.h> +#include <linux/if_bonding.h> #include <asm/types.h> #include <asm/uaccess.h> #include <asm/dasd.h> @@ -195,6 +196,58 @@ out: if(ifc.ifc_buf != NULL) kfree (ifc.ifc_buf); + return err; +} + +static int bond_ioctl(unsigned long fd, unsigned int cmd, unsigned long arg) +{ + struct ifreq ifr; + mm_segment_t old_fs; + int err, len; + u32 data; + + if (copy_from_user(&ifr, (struct ifreq32 *)arg, sizeof(struct ifreq32))) + return -EFAULT; + ifr.ifr_data = (__kernel_caddr_t)get_free_page(GFP_KERNEL); + if (!ifr.ifr_data) + return -EAGAIN; + + switch (cmd) { + case SIOCBONDENSLAVE: + case SIOCBONDRELEASE: + case SIOCBONDSETHWADDR: + case SIOCBONDCHANGEACTIVE: + len = IFNAMSIZ * sizeof(char); + break; + case SIOCBONDSLAVEINFOQUERY: + len = sizeof(struct ifslave); + break; + case SIOCBONDINFOQUERY: + len = sizeof(struct ifbond); + break; + default: + err = -EINVAL; + goto out; + }; + + __get_user(data, &(((struct ifreq32 *)arg)->ifr_ifru.ifru_data)); + if (copy_from_user(ifr.ifr_data, (char *)A(data), len)) { + err = -EFAULT; + goto out; + } + + old_fs = get_fs(); + set_fs (KERNEL_DS); + err = sys_ioctl (fd, cmd, (unsigned long)&ifr); + set_fs (old_fs); + if (!err) { + len = copy_to_user((char *)A(data), ifr.ifr_data, len); + if (len) + err = -EFAULT; + } + +out: + free_page((unsigned long)ifr.ifr_data); return err; } diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/s390x/kernel/linux32.c linux-2.5/arch/s390x/kernel/linux32.c --- linux-2.5.1/arch/s390x/kernel/linux32.c Thu Oct 11 16:04:57 2001 +++ linux-2.5/arch/s390x/kernel/linux32.c Thu Dec 27 16:32:31 2001 @@ -897,24 +897,24 @@ return sys32_fcntl(fd, cmd, arg); } -struct mem_dqblk32 { +struct dqblk32 { + __u32 dqb_bhardlimit; + __u32 dqb_bsoftlimit; + __u32 dqb_curblocks; __u32 dqb_ihardlimit; __u32 dqb_isoftlimit; __u32 dqb_curinodes; - __u32 dqb_bhardlimit; - __u32 dqb_bsoftlimit; - __u64 dqb_curspace; __kernel_time_t32 dqb_btime; __kernel_time_t32 dqb_itime; }; -extern asmlinkage long sys_quotactl(int cmd, const char *special, int id, __kernel_caddr_t addr); +extern asmlinkage int sys_quotactl(int cmd, const char *special, int id, caddr_t addr); asmlinkage int sys32_quotactl(int cmd, const char *special, int id, unsigned long addr) { int cmds = cmd >> SUBCMDSHIFT; int err; - struct mem_dqblk d; + struct dqblk d; mm_segment_t old_fs; char *spec; @@ -924,32 +924,32 @@ case Q_SETQUOTA: case Q_SETUSE: case Q_SETQLIM: - if (copy_from_user (&d, (struct mem_dqblk32 *)addr, - sizeof (struct mem_dqblk32))) + if (copy_from_user (&d, (struct dqblk32 *)addr, + sizeof (struct dqblk32))) return -EFAULT; - d.dqb_itime = ((struct mem_dqblk32 *)&d)->dqb_itime; - d.dqb_btime = ((struct mem_dqblk32 *)&d)->dqb_btime; + d.dqb_itime = ((struct dqblk32 *)&d)->dqb_itime; + d.dqb_btime = ((struct dqblk32 *)&d)->dqb_btime; break; default: return sys_quotactl(cmd, special, - id, (__kernel_caddr_t)addr); + id, (caddr_t)addr); } spec = getname (special); err = PTR_ERR(spec); if (IS_ERR(spec)) return err; old_fs = get_fs (); set_fs (KERNEL_DS); - err = sys_quotactl(cmd, (const char *)spec, id, (__kernel_caddr_t)&d); + err = sys_quotactl(cmd, (const char *)spec, id, (caddr_t)&d); set_fs (old_fs); putname (spec); if (err) return err; if (cmds == Q_GETQUOTA) { __kernel_time_t b = d.dqb_btime, i = d.dqb_itime; - ((struct mem_dqblk32 *)&d)->dqb_itime = i; - ((struct mem_dqblk32 *)&d)->dqb_btime = b; - if (copy_to_user ((struct mem_dqblk32 *)addr, &d, - sizeof (struct mem_dqblk32))) + ((struct dqblk32 *)&d)->dqb_itime = i; + ((struct dqblk32 *)&d)->dqb_btime = b; + if (copy_to_user ((struct dqblk32 *)addr, &d, + sizeof (struct dqblk32))) return -EFAULT; } return 0; diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/s390x/kernel/process.c linux-2.5/arch/s390x/kernel/process.c --- linux-2.5.1/arch/s390x/kernel/process.c Thu Oct 11 16:04:57 2001 +++ linux-2.5/arch/s390x/kernel/process.c Thu Dec 27 22:10:28 2001 @@ -57,7 +57,6 @@ /* endless idle loop with no priority at all */ init_idle(); current->nice = 20; - current->counter = -100; wait_psw.mask = _WAIT_PSW_MASK; wait_psw.addr = (unsigned long) &&idle_wakeup; while(1) { @@ -75,171 +74,22 @@ } } -/* - As all the register will only be made displayable to the root - user ( via printk ) or checking if the uid of the user is 0 from - the /proc filesystem please god this will be secure enough DJB. - The lines are given one at a time so as not to chew stack space in - printk on a crash & also for the proc filesystem when you get - 0 returned you know you've got all the lines - */ - -static int sprintf_regs(int line, char *buff, struct task_struct *task, struct pt_regs *regs) -{ - int linelen=0; - int regno,chaincnt; - u64 backchain,prev_backchain,endchain; - u64 ksp = 0; - char *mode = "???"; - - enum - { - sp_linefeed, - sp_psw, - sp_ksp, - sp_gprs, - sp_gprs1, - sp_gprs2, - sp_gprs3, - sp_gprs4, - sp_gprs5, - sp_gprs6, - sp_gprs7, - sp_gprs8, - sp_acrs, - sp_acrs1, - sp_acrs2, - sp_acrs3, - sp_acrs4, - sp_kern_backchain, - sp_kern_backchain1 - }; - - if (task) - ksp = task->thread.ksp; - if (regs && !(regs->psw.mask & PSW_PROBLEM_STATE)) - ksp = regs->gprs[15]; - - if (regs) - mode = (regs->psw.mask & PSW_PROBLEM_STATE)? - "User" : "Kernel"; - - switch(line) - { - case sp_linefeed: - linelen=sprintf(buff,"\n"); - break; - case sp_psw: - if(regs) - linelen=sprintf(buff, "%s PSW: %016lx %016lx %s\n", mode, - (unsigned long) regs->psw.mask, - (unsigned long) regs->psw.addr, - print_tainted()); - else - linelen=sprintf(buff,"pt_regs=NULL some info unavailable\n"); - break; - case sp_ksp: - linelen=sprintf(&buff[linelen], - "task: %016lx ksp: %016lx pt_regs: %016lx\n", - (addr_t)task, (addr_t)ksp, (addr_t)regs); - break; - case sp_gprs: - if(regs) - linelen=sprintf(buff, "%s GPRS:\n", mode); - break; - case sp_gprs1 ... sp_gprs8: - if(regs) - { - regno=(line-sp_gprs1)*2; - linelen = sprintf(buff,"%016lx %016lx\n", - regs->gprs[regno], - regs->gprs[regno+1]); - } - break; - case sp_acrs: - if(regs) - linelen=sprintf(buff, "%s ACRS:\n", mode); - break; - case sp_acrs1 ... sp_acrs4: - if(regs) - { - regno=(line-sp_acrs1)*4; - linelen=sprintf(buff,"%08x %08x %08x %08x\n", - regs->acrs[regno], - regs->acrs[regno+1], - regs->acrs[regno+2], - regs->acrs[regno+3]); - } - break; - case sp_kern_backchain: - if (regs && (regs->psw.mask & PSW_PROBLEM_STATE)) - break; - if (ksp) - linelen=sprintf(buff, "Kernel BackChain CallChain\n"); - break; - default: - if (ksp) - { - - backchain=ksp&PSW_ADDR_MASK; - endchain=((backchain&(-THREAD_SIZE))+THREAD_SIZE); - prev_backchain=backchain-1; - line-=sp_kern_backchain1; - for(chaincnt=0;;chaincnt++) - { - if((backchain==0)||(backchain>=endchain) - ||(chaincnt>=8)||(prev_backchain>=backchain)) - break; - if(chaincnt==line) - { - linelen+=sprintf(&buff[linelen]," %016lx [<%016lx>]\n", - backchain, - *(u64 *)(backchain+112)&PSW_ADDR_MASK); - break; - } - prev_backchain=backchain; - backchain=(*((u64 *)backchain))&PSW_ADDR_MASK; - } - } - } - return(linelen); -} +extern void show_registers(struct pt_regs *regs); +extern void show_trace(unsigned long *sp); void show_regs(struct pt_regs *regs) { - char buff[80]; - int i, line; + struct task_struct *tsk = current; - printk("CPU: %d\n",smp_processor_id()); - printk("Process %s (pid: %d, stackpage=%016lX)\n", - current->comm, current->pid, 4096+(addr_t)current); - - for (line = 0; sprintf_regs(line, buff, current, regs); line++) - printk(buff); - - if (regs->psw.mask & PSW_PROBLEM_STATE) - { - printk("User Code:\n"); - memset(buff, 0, 20); - copy_from_user(buff, - (char *) (regs->psw.addr & PSW_ADDR_MASK), 20); - for (i = 0; i < 20; i++) - printk("%02x ", buff[i]); - printk("\n"); - } -} - -char *task_show_regs(struct task_struct *task, char *buffer) -{ - int line, len; - - for (line = 0; ; line++) - { - len = sprintf_regs(line, buffer, task, NULL); - if (!len) break; - buffer += len; - } - return buffer; + printk("CPU: %d %s\n", tsk->processor, print_tainted()); + printk("Process %s (pid: %d, task: %016lx, ksp: %016lx)\n", + current->comm, current->pid, (unsigned long) tsk, + tsk->thread.ksp); + + show_registers(regs); + /* Show stack backtrace if pt_regs is from kernel mode */ + if (!(regs->psw.mask & PSW_PROBLEM_STATE)) + show_trace((unsigned long *) regs->gprs[15]); } int kernel_thread(int (*fn)(void *), void * arg, unsigned long flags) @@ -301,16 +151,10 @@ unsigned long gprs[10]; /* gprs 6 -15 */ unsigned long fprs[2]; /* fpr 4 and 6 */ unsigned long empty[2]; -#if CONFIG_REMOTE_DEBUG - struct gdb_pt_regs childregs; -#else struct pt_regs childregs; -#endif } *frame; frame = (struct stack_frame *) (4*PAGE_SIZE + (unsigned long) p) -1; - frame = (struct stack_frame *) (((unsigned long) frame)&-8L); - p->thread.regs = &frame->childregs; p->thread.ksp = (unsigned long) frame; frame->childregs = *regs; frame->childregs.gprs[15] = new_stackp; diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/s390x/kernel/ptrace.c linux-2.5/arch/s390x/kernel/ptrace.c --- linux-2.5.1/arch/s390x/kernel/ptrace.c Tue Sep 18 23:56:19 2001 +++ linux-2.5/arch/s390x/kernel/ptrace.c Thu Dec 27 16:32:31 2001 @@ -41,7 +41,7 @@ void FixPerRegisters(struct task_struct *task) { - struct pt_regs *regs = task->thread.regs; + struct pt_regs *regs = __KSTK_PTREGS(task); per_struct *per_info= (per_struct *)&task->thread.per_info; @@ -169,7 +169,7 @@ mask=PSW_ADDR_MASK; if(useraddr<PT_FPC) { - realuseraddr=(addr_t)&(((u8 *)task->thread.regs)[useraddr]); + realuseraddr=((addr_t) __KSTK_PTREGS(task)) + useraddr; if(useraddr<PT_PSWMASK) { copymax=PT_PSWMASK; diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/s390x/kernel/s390_ksyms.c linux-2.5/arch/s390x/kernel/s390_ksyms.c --- linux-2.5.1/arch/s390x/kernel/s390_ksyms.c Thu Oct 11 16:04:57 2001 +++ linux-2.5/arch/s390x/kernel/s390_ksyms.c Thu Dec 27 16:32:31 2001 @@ -21,8 +21,9 @@ EXPORT_SYMBOL_NOVERS(_oi_bitmap); EXPORT_SYMBOL_NOVERS(_ni_bitmap); EXPORT_SYMBOL_NOVERS(_zb_findmap); -EXPORT_SYMBOL_NOVERS(__copy_from_user_fixup); -EXPORT_SYMBOL_NOVERS(__copy_to_user_fixup); +EXPORT_SYMBOL_NOVERS(__copy_from_user_asm); +EXPORT_SYMBOL_NOVERS(__copy_to_user_asm); +EXPORT_SYMBOL_NOVERS(__clear_user_asm); /* * semaphore ops @@ -38,6 +39,7 @@ EXPORT_SYMBOL_NOVERS(memcmp); EXPORT_SYMBOL_NOVERS(memset); EXPORT_SYMBOL_NOVERS(memmove); +EXPORT_SYMBOL_NOVERS(memscan); EXPORT_SYMBOL_NOVERS(strlen); EXPORT_SYMBOL_NOVERS(strchr); EXPORT_SYMBOL_NOVERS(strcmp); @@ -67,4 +69,3 @@ EXPORT_SYMBOL(console_mode); EXPORT_SYMBOL(console_device); EXPORT_SYMBOL_NOVERS(do_call_softirq); - diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/s390x/kernel/setup.c linux-2.5/arch/s390x/kernel/setup.c --- linux-2.5.1/arch/s390x/kernel/setup.c Sat Nov 17 02:38:39 2001 +++ linux-2.5/arch/s390x/kernel/setup.c Thu Dec 27 16:32:31 2001 @@ -425,9 +425,10 @@ lowcore->io_new_psw.mask = _IO_PSW_MASK; lowcore->io_new_psw.addr = (addr_t) &io_int_handler; lowcore->ipl_device = S390_lowcore.ipl_device; - lowcore->kernel_stack = ((__u32) &init_task_union) + 16384; + lowcore->kernel_stack = ((__u64) &init_task_union) + 16384; lowcore->async_stack = (__u64) __alloc_bootmem(4*PAGE_SIZE, 4*PAGE_SIZE, 0) + 16384; + lowcore->jiffy_timer = -1LL; set_prefix((__u32)(__u64) lowcore); cpu_init(); boot_cpu_addr = S390_lowcore.cpu_data.cpu_addr; @@ -474,15 +475,16 @@ static int show_cpuinfo(struct seq_file *m, void *v) { struct cpuinfo_S390 *cpuinfo; - unsigned n = v; + unsigned long n = (unsigned long) v - 1; - if (!n--) { + if (!n) { seq_printf(m, "vendor_id : IBM/S390\n" "# processors : %i\n" "bogomips per cpu: %lu.%02lu\n", smp_num_cpus, loops_per_jiffy/(500000/HZ), (loops_per_jiffy/(5000/HZ))%100); - } else if (cpu_online_map & (1 << n)) { + } + if (cpu_online_map & (1 << n)) { cpuinfo = &safe_get_cpu_lowcore(n).cpu_data; seq_printf(m, "processor %i: " "version = %02X, " @@ -497,7 +499,7 @@ static void *c_start(struct seq_file *m, loff_t *pos) { - return *pos <= NR_CPUS ? (void)(*pos+1) : NULL; + return *pos <= NR_CPUS ? (void *)((unsigned long) *pos + 1) : NULL; } static void *c_next(struct seq_file *m, void *v, loff_t *pos) { diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/s390x/kernel/smp.c linux-2.5/arch/s390x/kernel/smp.c --- linux-2.5.1/arch/s390x/kernel/smp.c Wed Nov 21 18:31:09 2001 +++ linux-2.5/arch/s390x/kernel/smp.c Thu Dec 27 16:32:31 2001 @@ -29,6 +29,7 @@ #include <linux/smp_lock.h> #include <linux/delay.h> +#include <linux/cache.h> #include <asm/sigp.h> #include <asm/pgalloc.h> @@ -48,14 +49,11 @@ static int max_cpus = NR_CPUS; /* Setup configured maximum number of CPUs to activate */ int smp_num_cpus; struct _lowcore *lowcore_ptr[NR_CPUS]; -unsigned int prof_multiplier[NR_CPUS]; -unsigned int prof_old_multiplier[NR_CPUS]; -unsigned int prof_counter[NR_CPUS]; cycles_t cacheflush_time=0; int smp_threads_ready=0; /* Set when the idlers are all forked. */ static atomic_t smp_commenced = ATOMIC_INIT(0); -spinlock_t kernel_flag = SPIN_LOCK_UNLOCKED; +spinlock_t kernel_flag __cacheline_aligned_in_smp = SPIN_LOCK_UNLOCKED; unsigned long cpu_online_map; @@ -452,7 +450,7 @@ /* * Activate a secondary processor. */ -extern void init_100hz_timer(void); +extern void init_cpu_timer(void); extern int pfault_init(void); int __init start_secondary(void *cpuvoid) @@ -464,8 +462,8 @@ /* Wait for completion of smp startup */ while (!atomic_read(&smp_commenced)) /* nothing */ ; - /* init per CPU 100 hz timer */ - init_100hz_timer(); + /* init per CPU timer */ + init_cpu_timer(); #ifdef CONFIG_PFAULT /* Enable pfault pseudo page faults on this cpu. */ pfault_init(); @@ -518,7 +516,7 @@ cpu_lowcore=&get_cpu_lowcore(cpu); cpu_lowcore->save_area[15] = idle->thread.ksp; - cpu_lowcore->kernel_stack = (idle->thread.ksp | 16383) + 1; + cpu_lowcore->kernel_stack = (__u64) idle + 16384; __asm__ __volatile__("la 1,%0\n\t" "stctg 0,15,0(1)\n\t" "la 1,%1\n\t" @@ -570,15 +568,7 @@ /* * Initialize the logical to physical CPU number mapping - * and the per-CPU profiling counter/multiplier */ - - for (i = 0; i < NR_CPUS; i++) { - prof_counter[i] = 1; - prof_old_multiplier[i] = 1; - prof_multiplier[i] = 1; - } - print_cpu_info(&safe_get_cpu_lowcore(0).cpu_data); for(i = 0; i < smp_num_cpus; i++) @@ -630,56 +620,6 @@ int setup_profiling_timer(unsigned int multiplier) { return 0; -} - -/* - * Local timer interrupt handler. It does both profiling and - * process statistics/rescheduling. - * - * We do profiling in every local tick, statistics/rescheduling - * happen only every 'profiling multiplier' ticks. The default - * multiplier is 1 and it can be changed by writing the new multiplier - * value into /proc/profile. - */ - -void smp_local_timer_interrupt(struct pt_regs * regs) -{ - int user = (user_mode(regs) != 0); - int cpu = smp_processor_id(); - - /* - * The profiling function is SMP safe. (nothing can mess - * around with "current", and the profiling counters are - * updated with atomic operations). This is especially - * useful with a profiling multiplier != 1 - */ - if (!user_mode(regs)) - s390_do_profile(regs->psw.addr); - - if (!--prof_counter[cpu]) { - - /* - * The multiplier may have changed since the last time we got - * to this point as a result of the user writing to - * /proc/profile. In this case we need to adjust the APIC - * timer accordingly. - * - * Interrupts are already masked off at this point. - */ - prof_counter[cpu] = prof_multiplier[cpu]; - if (prof_counter[cpu] != prof_old_multiplier[cpu]) { - prof_old_multiplier[cpu] = prof_counter[cpu]; - } - - /* - * After doing the above, we need to make like - * a normal interrupt - otherwise timer interrupts - * ignore the global interrupt lock, which is the - * WrongThing (tm) to do. - */ - - update_process_times(user); - } } EXPORT_SYMBOL(lowcore_ptr); diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/s390x/kernel/time.c linux-2.5/arch/s390x/kernel/time.c --- linux-2.5.1/arch/s390x/kernel/time.c Thu Oct 11 16:04:57 2001 +++ linux-2.5/arch/s390x/kernel/time.c Thu Dec 27 16:32:31 2001 @@ -33,65 +33,33 @@ #include <asm/irq.h> #include <asm/s390_ext.h> - /* change this if you have some constant time drift */ -#define USECS_PER_JIFFY ((signed long)1000000/HZ) -#define CLK_TICKS_PER_JIFFY ((signed long)USECS_PER_JIFFY<<12) +#define USECS_PER_JIFFY ((unsigned long) 1000000/HZ) +#define CLK_TICKS_PER_JIFFY ((unsigned long) USECS_PER_JIFFY << 12) #define TICK_SIZE tick -static uint64_t init_timer_cc, last_timer_cc; +static uint64_t init_timer_cc; extern rwlock_t xtime_lock; extern unsigned long wall_jiffies; -void tod_to_timeval(uint64_t todval, struct timeval *xtime) +void tod_to_timeval(__u64 todval, struct timeval *xtime) { -#if 0 - const int high_bit = 0x80000000L; - const int c_f4240 = 0xf4240L; - const int c_7a120 = 0x7a120; - /* We have to divide the 64 bit value todval by 4096 - * (because the 2^12 bit is the one that changes every - * microsecond) and then split it into seconds and - * microseconds. A value of max (2^52-1) divided by - * the value 0xF4240 can yield a max result of approx - * (2^32.068). Thats to big to fit into a signed int - * ... hacking time! - */ - asm volatile ("L 2,%1\n\t" - "LR 3,2\n\t" - "SRL 2,12\n\t" - "SLL 3,20\n\t" - "L 4,%O1+4(%R1)\n\t" - "SRL 4,12\n\t" - "OR 3,4\n\t" /* now R2/R3 contain (todval >> 12) */ - "SR 4,4\n\t" - "CL 2,%2\n\t" - "JL .+12\n\t" - "S 2,%2\n\t" - "L 4,%3\n\t" - "D 2,%4\n\t" - "OR 3,4\n\t" - "ST 2,%O0+4(%R0)\n\t" - "ST 3,%0" - : "=m" (*xtime) : "m" (todval), - "m" (c_7a120), "m" (high_bit), "m" (c_f4240) - : "cc", "memory", "2", "3", "4" ); -#else - todval >>= 12; - xtime->tv_sec = todval / 1000000; - xtime->tv_usec = todval % 1000000; -#endif + todval >>= 12; + xtime->tv_sec = todval / 1000000; + xtime->tv_usec = todval % 1000000; } -unsigned long do_gettimeoffset(void) +static inline unsigned long do_gettimeoffset(void) { - __u64 timer_cc; + __u64 now; - asm volatile ("STCK %0" : "=m" (timer_cc)); - /* We require the offset from the previous interrupt */ - return ((unsigned long)((timer_cc - last_timer_cc)>>12)); + asm ("STCK %0" : "=m" (now)); + now = (now - init_timer_cc) >> 12; + /* We require the offset from the latest update of xtime */ + now -= (__u64) wall_jiffies*USECS_PER_JIFFY; + return (unsigned long) now; } /* @@ -101,15 +69,10 @@ { unsigned long flags; unsigned long usec, sec; - unsigned long lost_ticks; read_lock_irqsave(&xtime_lock, flags); - lost_ticks = jiffies - wall_jiffies; - usec = do_gettimeoffset(); - if (lost_ticks) - usec +=(USECS_PER_JIFFY*lost_ticks); sec = xtime.tv_sec; - usec += xtime.tv_usec; + usec = xtime.tv_usec + do_gettimeoffset(); read_unlock_irqrestore(&xtime_lock, flags); while (usec >= 1000000) { @@ -155,51 +118,31 @@ extern __u16 boot_cpu_addr; #endif -void do_timer_interrupt(struct pt_regs *regs, __u16 error_code) +static void do_comparator_interrupt(struct pt_regs *regs, __u16 error_code) { int cpu = smp_processor_id(); irq_enter(cpu, 0); - /* - * reset timer to 10ms minus time already elapsed - * since timer-interrupt pending - */ + /* + * set clock comparator for next tick + */ + S390_lowcore.jiffy_timer += CLK_TICKS_PER_JIFFY; + asm volatile ("SCKC %0" : : "m" (S390_lowcore.jiffy_timer)); + #ifdef CONFIG_SMP - if(S390_lowcore.cpu_data.cpu_addr==boot_cpu_addr) { + if (S390_lowcore.cpu_data.cpu_addr == boot_cpu_addr) write_lock(&xtime_lock); - last_timer_cc = S390_lowcore.jiffy_timer_cc; - } -#else - last_timer_cc = S390_lowcore.jiffy_timer_cc; -#endif - /* set clock comparator */ - S390_lowcore.jiffy_timer_cc += CLK_TICKS_PER_JIFFY; - asm volatile ("SCKC %0" : : "m" (S390_lowcore.jiffy_timer_cc)); -/* - * In the SMP case we use the local timer interrupt to do the - * profiling, except when we simulate SMP mode on a uniprocessor - * system, in that case we have to call the local interrupt handler. - */ -#ifdef CONFIG_SMP - /* when SMP, do smp_local_timer_interrupt for *all* CPUs, - but only do the rest for the boot CPU */ - smp_local_timer_interrupt(regs); -#else - if (!user_mode(regs)) - s390_do_profile(regs->psw.addr); -#endif + update_process_times(user_mode(regs)); -#ifdef CONFIG_SMP - if(S390_lowcore.cpu_data.cpu_addr==boot_cpu_addr) -#endif - { + if (S390_lowcore.cpu_data.cpu_addr == boot_cpu_addr) { do_timer(regs); -#ifdef CONFIG_SMP write_unlock(&xtime_lock); -#endif } +#else + do_timer(regs); +#endif irq_exit(cpu, 0); } @@ -207,19 +150,17 @@ /* * Start the clock comparator on the current CPU */ -static unsigned long cr0 __attribute__ ((aligned (8))); - -void init_100hz_timer(void) +void init_cpu_timer(void) { + unsigned long cr0; + /* allow clock comparator timer interrupt */ asm volatile ("STCTG 0,0,%0" : "=m" (cr0) : : "memory"); cr0 |= 0x800; asm volatile ("LCTLG 0,0,%0" : : "m" (cr0) : "memory"); - /* set clock comparator */ - /* read the TOD clock */ - asm volatile ("STCK %0" : "=m" (S390_lowcore.jiffy_timer_cc)); - S390_lowcore.jiffy_timer_cc += CLK_TICKS_PER_JIFFY; - asm volatile ("SCKC %0" : : "m" (S390_lowcore.jiffy_timer_cc)); + S390_lowcore.jiffy_timer = (__u64) jiffies * CLK_TICKS_PER_JIFFY; + S390_lowcore.jiffy_timer += init_timer_cc + CLK_TICKS_PER_JIFFY; + asm volatile ("SCKC %0" : : "m" (S390_lowcore.jiffy_timer)); } /* @@ -228,6 +169,7 @@ */ void __init time_init(void) { + __u64 set_time_cc; int cc; /* kick the TOD clock */ @@ -247,14 +189,18 @@ printk("time_init: TOD clock stopped/non-operational\n"); break; } + + /* set xtime */ + set_time_cc = init_timer_cc - 0x8126d60e46000000LL + + (0x3c26700LL*1000000*4096); + tod_to_timeval(set_time_cc, &xtime); + /* request the 0x1004 external interrupt */ - if (register_external_interrupt(0x1004, do_timer_interrupt) != 0) - panic("Couldn't request external interrupts 0x1004"); - init_100hz_timer(); - init_timer_cc = S390_lowcore.jiffy_timer_cc; - init_timer_cc -= 0x8126d60e46000000LL - - (0x3c26700LL*1000000*4096); - tod_to_timeval(init_timer_cc, &xtime); + if (register_external_interrupt(0x1004, do_comparator_interrupt) != 0) + panic("Couldn't request external interrupt 0x1004"); + + /* init CPU timer */ + init_cpu_timer(); /* Set do_get_fast_time function pointer. */ do_get_fast_time = do_gettimeofday; diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/s390x/kernel/traps.c linux-2.5/arch/s390x/kernel/traps.c --- linux-2.5.1/arch/s390x/kernel/traps.c Fri Nov 9 21:58:02 2001 +++ linux-2.5/arch/s390x/kernel/traps.c Thu Dec 27 16:32:31 2001 @@ -26,6 +26,7 @@ #include <linux/smp_lock.h> #include <linux/init.h> #include <linux/delay.h> +#include <linux/module.h> #include <asm/system.h> #include <asm/uaccess.h> @@ -58,6 +59,203 @@ extern void pfault_interrupt(struct pt_regs *regs, __u16 error_code); #endif +int kstack_depth_to_print = 20; + +/* + * If the address is either in the .text section of the + * kernel, or in the vmalloc'ed module regions, it *may* + * be the address of a calling routine + */ +extern char _stext, _etext; + +#ifdef CONFIG_MODULES + +extern struct module *module_list; +extern struct module kernel_module; + +static inline int kernel_text_address(unsigned long addr) +{ + int retval = 0; + struct module *mod; + + if (addr >= (unsigned long) &_stext && + addr <= (unsigned long) &_etext) + return 1; + + for (mod = module_list; mod != &kernel_module; mod = mod->next) { + /* mod_bound tests for addr being inside the vmalloc'ed + * module area. Of course it'd be better to test only + * for the .text subset... */ + if (mod_bound(addr, 0, mod)) { + retval = 1; + break; + } + } + + return retval; +} + +#else + +static inline int kernel_text_address(unsigned long addr) +{ + return (addr >= (unsigned long) &_stext && + addr <= (unsigned long) &_etext); +} + +#endif + +void show_trace(unsigned long * stack) +{ + unsigned long backchain, low_addr, high_addr, ret_addr; + int i; + + if (!stack) + stack = (unsigned long*)&stack; + + printk("Call Trace: "); + low_addr = ((unsigned long) stack) & PSW_ADDR_MASK; + high_addr = (low_addr & (-THREAD_SIZE)) + THREAD_SIZE; + /* Skip the first frame (biased stack) */ + backchain = *((unsigned long *) low_addr) & PSW_ADDR_MASK; + /* Print up to 8 lines */ + for (i = 0; i < 8; i++) { + if (backchain < low_addr || backchain >= high_addr) + break; + ret_addr = *((unsigned long *) (backchain+112)) & PSW_ADDR_MASK; + if (!kernel_text_address(ret_addr)) + break; + if (i && ((i % 3) == 0)) + printk("\n "); + printk("[<%016lx>] ", ret_addr); + low_addr = backchain; + backchain = *((unsigned long *) backchain) & PSW_ADDR_MASK; + } + printk("\n"); +} + +void show_trace_task(struct task_struct *tsk) +{ + /* + * We can't print the backtrace of a running process. It is + * unreliable at best and can cause kernel oopses. + */ + if (task_has_cpu(tsk)) + return; + show_trace((unsigned long *) tsk->thread.ksp); +} + +void show_stack(unsigned long *sp) +{ + unsigned long *stack; + int i; + + // debugging aid: "show_stack(NULL);" prints the + // back trace for this cpu. + + if (sp == NULL) + sp = (unsigned long*) &sp; + + stack = sp; + for (i = 0; i < kstack_depth_to_print; i++) { + if (((addr_t) stack & (THREAD_SIZE-1)) == 0) + break; + if (i && ((i % 4) == 0)) + printk("\n "); + printk("%016lx ", *stack++); + } + printk("\n"); + show_trace(sp); +} + +void show_registers(struct pt_regs *regs) +{ + mm_segment_t old_fs; + char *mode; + int i; + + mode = (regs->psw.mask & PSW_PROBLEM_STATE) ? "User" : "Krnl"; + printk("%s PSW : %016lx %016lx\n", + mode, (unsigned long) regs->psw.mask, + (unsigned long) regs->psw.addr); + printk("%s GPRS: %016lx %016lx %016lx %016lx\n", mode, + regs->gprs[0], regs->gprs[1], regs->gprs[2], regs->gprs[3]); + printk(" %016lx %016lx %016lx %016lx\n", + regs->gprs[4], regs->gprs[5], regs->gprs[6], regs->gprs[7]); + printk(" %016lx %016lx %016lx %016lx\n", + regs->gprs[8], regs->gprs[9], regs->gprs[10], regs->gprs[11]); + printk(" %016lx %016lx %016lx %016lx\n", + regs->gprs[12], regs->gprs[13], regs->gprs[14], regs->gprs[15]); + printk("%s ACRS: %08x %08x %08x %08x\n", mode, + regs->acrs[0], regs->acrs[1], regs->acrs[2], regs->acrs[3]); + printk(" %08x %08x %08x %08x\n", + regs->acrs[4], regs->acrs[5], regs->acrs[6], regs->acrs[7]); + printk(" %08x %08x %08x %08x\n", + regs->acrs[8], regs->acrs[9], regs->acrs[10], regs->acrs[11]); + printk(" %08x %08x %08x %08x\n", + regs->acrs[12], regs->acrs[13], regs->acrs[14], regs->acrs[15]); + + /* + * Print the first 20 byte of the instruction stream at the + * time of the fault. + */ + old_fs = get_fs(); + if (regs->psw.mask & PSW_PROBLEM_STATE) + set_fs(USER_DS); + else + set_fs(KERNEL_DS); + printk("%s Code: ", mode); + for (i = 0; i < 20; i++) { + unsigned char c; + if (__get_user(c, (char *)(regs->psw.addr + i))) { + printk(" Bad PSW."); + break; + } + printk("%02x ", c); + } + set_fs(old_fs); + + printk("\n"); +} + +/* This is called from fs/proc/array.c */ +char *task_show_regs(struct task_struct *task, char *buf) +{ + struct pt_regs *regs; + + regs = __KSTK_PTREGS(task); + buf += sprintf(buf, "task: %016lx, ksp: %016lx\n", + (unsigned long) task, task->thread.ksp); + buf += sprintf(buf, "User PSW : %016lx %016lx\n", + (unsigned long) regs->psw.mask, + (unsigned long) regs->psw.addr); + buf += sprintf(buf, "User GPRS: %016lx %016lx %016lx %016lx\n", + regs->gprs[0], regs->gprs[1], + regs->gprs[2], regs->gprs[3]); + buf += sprintf(buf, " %016lx %016lx %016lx %016lx\n", + regs->gprs[4], regs->gprs[5], + regs->gprs[6], regs->gprs[7]); + buf += sprintf(buf, " %016lx %016lx %016lx %016lx\n", + regs->gprs[8], regs->gprs[9], + regs->gprs[10], regs->gprs[11]); + buf += sprintf(buf, " %016lx %016lx %016lx %016lx\n", + regs->gprs[12], regs->gprs[13], + regs->gprs[14], regs->gprs[15]); + buf += sprintf(buf, "User ACRS: %08x %08x %08x %08x\n", + regs->acrs[0], regs->acrs[1], + regs->acrs[2], regs->acrs[3]); + buf += sprintf(buf, " %08x %08x %08x %08x\n", + regs->acrs[4], regs->acrs[5], + regs->acrs[6], regs->acrs[7]); + buf += sprintf(buf, " %08x %08x %08x %08x\n", + regs->acrs[8], regs->acrs[9], + regs->acrs[10], regs->acrs[11]); + buf += sprintf(buf, " %08x %08x %08x %08x\n", + regs->acrs[12], regs->acrs[13], + regs->acrs[14], regs->acrs[15]); + return buf; +} + spinlock_t die_lock = SPIN_LOCK_UNLOCKED; void die(const char * str, struct pt_regs * regs, long err) @@ -142,7 +340,7 @@ #if CONFIG_REMOTE_DEBUG if(gdb_stub_initialised) { - gdb_stub_handle_exception((gdb_pt_regs *)regs,signal); + gdb_stub_handle_exception(regs, signal); return 0; } #endif diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/s390x/kernel/wrapper32.S linux-2.5/arch/s390x/kernel/wrapper32.S --- linux-2.5.1/arch/s390x/kernel/wrapper32.S Fri Nov 9 21:58:02 2001 +++ linux-2.5/arch/s390x/kernel/wrapper32.S Thu Dec 27 16:32:31 2001 @@ -120,8 +120,8 @@ lgfr %r2,%r2 # long lgfr %r3,%r3 # long llgtr %r4,%r4 # long - lgfr %r5,%r5 # long - jg sys32_ptrace # branch to system call + llgfr %r5,%r5 # long + jg sys_ptrace # branch to system call .globl sys32_alarm_wrapper sys32_alarm_wrapper: diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/s390x/lib/uaccess.S linux-2.5/arch/s390x/lib/uaccess.S --- linux-2.5.1/arch/s390x/lib/uaccess.S Tue Feb 13 22:13:44 2001 +++ linux-2.5/arch/s390x/lib/uaccess.S Thu Dec 27 16:32:31 2001 @@ -6,40 +6,82 @@ * Copyright (C) 2000 IBM Deutschland Entwicklung GmbH, IBM Corporation * Authors(s): Martin Schwidefsky (schwidefsky@de.ibm.com) * - * These functions have a non-standard call interface + * These functions have standard call interface */ #include <asm/lowcore.h> .text .align 4 - .globl __copy_from_user_fixup -__copy_from_user_fixup: - lg 1,__LC_PGM_OLD_PSW+8 -0: lghi 3,-4096 - ng 3,__LC_TRANS_EXC_ADDR - sgr 3,4 - bm 4(1) -1: mvcle 2,4,0 - b 4(1) + .globl __copy_from_user_asm +__copy_from_user_asm: + lgr %r5,%r3 + sacf 512 +0: mvcle %r2,%r4,0 + jo 0b + sacf 0 + lgr %r2,%r5 + br %r14 +1: lg %r1,__LC_PGM_OLD_PSW+8 +2: lghi %r3,-4096 + ng %r3,__LC_TRANS_EXC_ADDR + sgr %r3,%r4 + bm 4(%r1) +3: mvcle %r2,%r4,0 + b 4(%r1) .section __ex_table,"a" - .align 8 - .quad 1b,0b + .align 8 + .quad 0b,1b + .quad 3b,2b .previous .align 4 .text - .globl __copy_to_user_fixup -__copy_to_user_fixup: - lg 1,__LC_PGM_OLD_PSW+8 -0: lghi 5,-4096 - ng 5,__LC_TRANS_EXC_ADDR - sgr 5,4 - bm 4(1) -1: mvcle 4,2,0 - b 4(1) + .globl __copy_to_user_asm +__copy_to_user_asm: + lgr %r5,%r3 + sacf 512 +0: mvcle %r4,%r2,0 + jo 0b + sacf 0 + lgr %r2,%r3 + br %r14 +1: lg %r1,__LC_PGM_OLD_PSW+8 +2: lghi %r5,-4096 + ng %r5,__LC_TRANS_EXC_ADDR + sgr %r5,%r4 + bm 4(%r1) +3: mvcle %r4,%r2,0 + b 4(%r1) .section __ex_table,"a" - .align 8 - .quad 1b,0b + .align 8 + .quad 0b,1b + .quad 3b,2b .previous + .align 4 + .text + .globl __clear_user_asm +__clear_user_asm: + lgr %r4,%r2 + lgr %r5,%r3 + sgr %r2,%r2 + sgr %r3,%r3 + sacf 512 +0: mvcle %r4,%r2,0 + jo 0b + sacf 0 + lgr %r2,%r5 + br %r14 +1: lg %r1,__LC_PGM_OLD_PSW+8 +2: lghi %r5,-4096 + ng %r5,__LC_TRANS_EXC_ADDR + sgr %r5,%r4 + bm 4(%r1) +3: mvcle %r4,%r2,0 + b 4(%r1) + .section __ex_table,"a" + .align 8 + .quad 0b,1b + .quad 3b,2b + .previous diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/s390x/vmlinux-shared.lds linux-2.5/arch/s390x/vmlinux-shared.lds --- linux-2.5.1/arch/s390x/vmlinux-shared.lds Sun Aug 12 17:38:48 2001 +++ linux-2.5/arch/s390x/vmlinux-shared.lds Sat Dec 29 11:10:40 2001 @@ -13,7 +13,6 @@ *(.fixup) *(.gnu.warning) } = 0x0700 - .text.lock : { *(.text.lock) } /* out-of-line lock text */ .rodata : { *(.rodata) } .kstrtab : { *(.kstrtab) } diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/s390x/vmlinux.lds linux-2.5/arch/s390x/vmlinux.lds --- linux-2.5.1/arch/s390x/vmlinux.lds Mon Jul 2 21:40:58 2001 +++ linux-2.5/arch/s390x/vmlinux.lds Sat Dec 29 11:10:40 2001 @@ -13,7 +13,6 @@ *(.fixup) *(.gnu.warning) } = 0x0700 - .text.lock : { *(.text.lock) } /* out-of-line lock text */ .rodata : { *(.rodata) *(.rodata.*) } .kstrtab : { *(.kstrtab) } diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/sh/kernel/process.c linux-2.5/arch/sh/kernel/process.c --- linux-2.5.1/arch/sh/kernel/process.c Mon Oct 15 20:36:48 2001 +++ linux-2.5/arch/sh/kernel/process.c Thu Dec 27 22:10:28 2001 @@ -41,7 +41,6 @@ /* endless idle loop with no priority at all */ init_idle(); current->nice = 20; - current->counter = -100; while (1) { if (hlt_counter) { diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/sh/kernel/rtc.c linux-2.5/arch/sh/kernel/rtc.c --- linux-2.5.1/arch/sh/kernel/rtc.c Wed Jun 27 20:55:29 2001 +++ linux-2.5/arch/sh/kernel/rtc.c Thu Dec 27 16:32:31 2001 @@ -46,7 +46,7 @@ } while ((ctrl_inb(RCR1) & RCR1_CF) != 0); #if RTC_BIT_INVERTED != 0 - /* Work around to avoid reading correct value. */ + /* Work around to avoid reading incorrect value. */ if (sec128 == RTC_BIT_INVERTED) { schedule_timeout(1); goto again; @@ -81,12 +81,18 @@ goto again; } +#if RTC_BIT_INVERTED != 0 + if ((sec128 & RTC_BIT_INVERTED)) + sec--; +#endif + tv->tv_sec = mktime(yr100 * 100 + yr, mon, day, hr, min, sec); - tv->tv_usec = ((sec128 ^ RTC_BIT_INVERTED) * 1000000) / 128; + tv->tv_usec = (sec128 * 1000000) / 128; } -static int set_rtc_time(unsigned long nowtime) +int sh_rtc_settimeofday(const struct timeval *tv) { + unsigned long nowtime = tv->tv_sec; int retval = 0; int real_seconds, real_minutes, cmos_minutes; @@ -122,13 +128,4 @@ ctrl_outb(RCR2_RTCEN|RCR2_START, RCR2); /* Start RTC */ return retval; -} - -int sh_rtc_settimeofday(const struct timeval *tv) -{ -#if RTC_BIT_INVERTED != 0 - /* This is not accurate, but better than nothing. */ - schedule_timeout(HZ/2); -#endif - return set_rtc_time(tv->tv_sec); } diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/sh/kernel/setup.c linux-2.5/arch/sh/kernel/setup.c --- linux-2.5.1/arch/sh/kernel/setup.c Sat Nov 17 02:38:39 2001 +++ linux-2.5/arch/sh/kernel/setup.c Thu Dec 27 15:56:12 2001 @@ -140,15 +140,6 @@ sh_bios_console_write(s, count); } -/* - * Receive character from the serial port - */ -static int sh_console_wait_key(struct console *co) -{ - /* Not implemented yet */ - return 0; -} - static kdev_t sh_console_device(struct console *c) { /* TODO: this is totally bogus */ @@ -183,7 +174,6 @@ name: "bios", write: sh_console_write, device: sh_console_device, - wait_key: sh_console_wait_key, setup: sh_console_setup, flags: CON_PRINTBUFFER, index: -1, diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/sh/vmlinux.lds.S linux-2.5/arch/sh/vmlinux.lds.S --- linux-2.5.1/arch/sh/vmlinux.lds.S Sat Sep 8 19:29:09 2001 +++ linux-2.5/arch/sh/vmlinux.lds.S Sat Dec 29 11:10:40 2001 @@ -23,7 +23,6 @@ *(.fixup) *(.gnu.warning) } = 0x0009 - .text.lock : { *(.text.lock) } /* out-of-line lock text */ .rodata : { *(.rodata) *(.rodata.*) } .kstrtab : { *(.kstrtab) } diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/sparc/defconfig linux-2.5/arch/sparc/defconfig --- linux-2.5.1/arch/sparc/defconfig Tue Nov 13 17:16:05 2001 +++ linux-2.5/arch/sparc/defconfig Thu Dec 13 16:32:35 2001 @@ -138,7 +138,7 @@ # CONFIG_PACKET=y # CONFIG_PACKET_MMAP is not set -# CONFIG_NETLINK is not set +CONFIG_NETLINK_DEV=y # CONFIG_NETFILTER is not set # CONFIG_FILTER is not set CONFIG_UNIX=y @@ -148,6 +148,7 @@ # CONFIG_IP_PNP is not set # CONFIG_NET_IPIP is not set # CONFIG_NET_IPGRE is not set +# CONFIG_ARPD is not set # CONFIG_INET_ECN is not set # CONFIG_SYN_COOKIES is not set CONFIG_IPV6=m diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/sparc/kernel/process.c linux-2.5/arch/sparc/kernel/process.c --- linux-2.5.1/arch/sparc/kernel/process.c Tue Nov 13 17:16:05 2001 +++ linux-2.5/arch/sparc/kernel/process.c Thu Dec 27 22:10:28 2001 @@ -1,4 +1,4 @@ -/* $Id: process.c,v 1.157 2001/11/13 00:57:05 davem Exp $ +/* $Id: process.c,v 1.158 2001/11/26 23:45:00 davem Exp $ * linux/arch/sparc/kernel/process.c * * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu) @@ -61,7 +61,6 @@ /* endless idle loop with no priority at all */ current->nice = 20; - current->counter = -100; init_idle(); for (;;) { @@ -110,7 +109,6 @@ { /* endless idle loop with no priority at all */ current->nice = 20; - current->counter = -100; init_idle(); while(1) { @@ -285,37 +283,29 @@ show_regwindow((struct reg_window *)regs->u_regs[14]); } -#if NOTUSED -void show_thread(struct thread_struct *thread) +void show_trace_task(struct task_struct *tsk) { - int i; - - printk("uwinmask: 0x%08lx kregs: 0x%08lx\n", thread->uwinmask, (unsigned long)thread->kregs); - show_regs(thread->kregs); - printk("ksp: 0x%08lx kpc: 0x%08lx\n", thread->ksp, thread->kpc); - printk("kpsr: 0x%08lx kwim: 0x%08lx\n", thread->kpsr, thread->kwim); - printk("fork_kpsr: 0x%08lx fork_kwim: 0x%08lx\n", thread->fork_kpsr, thread->fork_kwim); - - for (i = 0; i < NSWINS; i++) { - if (!thread->rwbuf_stkptrs[i]) - continue; - printk("reg_window[%d]:\n", i); - printk("stack ptr: 0x%08lx\n", thread->rwbuf_stkptrs[i]); - show_regwindow(&thread->reg_window[i]); - } - printk("w_saved: 0x%08lx\n", thread->w_saved); - - /* XXX missing: float_regs */ - printk("fsr: 0x%08lx fpqdepth: 0x%08lx\n", thread->fsr, thread->fpqdepth); - /* XXX missing: fpqueue */ + unsigned long pc, fp; + unsigned long task_base = (unsigned long) tsk; + struct reg_window *rw; + int count = 0; - printk("flags: 0x%08lx current_ds: 0x%08lx\n", thread->flags, thread->current_ds.seg); - - show_regwindow((struct reg_window *)thread->ksp); + if (!tsk) + return; - /* XXX missing: core_exec */ + fp = tsk->thread.ksp; + do { + /* Bogus frame pointer? */ + if (fp < (task_base + sizeof(struct task_struct)) || + fp >= (task_base + (PAGE_SIZE << 1))) + break; + rw = (struct reg_window *) fp; + pc = rw->ins[7]; + printk("[%08lx] ", pc); + fp = rw->ins[6]; + } while (++count < 16); + printk("\n"); } -#endif /* * Free current thread data structures etc.. diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/sparc/kernel/smp.c linux-2.5/arch/sparc/kernel/smp.c --- linux-2.5.1/arch/sparc/kernel/smp.c Tue Nov 13 17:16:05 2001 +++ linux-2.5/arch/sparc/kernel/smp.c Thu Dec 13 16:32:35 2001 @@ -18,6 +18,7 @@ #include <linux/mm.h> #include <linux/fs.h> #include <linux/seq_file.h> +#include <linux/cache.h> #include <asm/ptrace.h> #include <asm/atomic.h> @@ -66,7 +67,7 @@ */ /* Kernel spinlock */ -spinlock_t kernel_flag = SPIN_LOCK_UNLOCKED; +spinlock_t kernel_flag __cacheline_aligned_in_smp = SPIN_LOCK_UNLOCKED; /* Used to make bitops atomic */ unsigned char bitops_spinlock = 0; diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/sparc/mm/extable.c linux-2.5/arch/sparc/mm/extable.c --- linux-2.5.1/arch/sparc/mm/extable.c Sun Aug 12 18:23:32 2001 +++ linux-2.5/arch/sparc/mm/extable.c Thu Dec 13 16:32:35 2001 @@ -11,35 +11,49 @@ static unsigned long search_one_table(const struct exception_table_entry *start, - const struct exception_table_entry *last, + const struct exception_table_entry *end, unsigned long value, unsigned long *g2) { - const struct exception_table_entry *first = start; - const struct exception_table_entry *mid; - long diff = 0; - while (first <= last) { - mid = (last - first) / 2 + first; - diff = mid->insn - value; - if (diff == 0) { - if (!mid->fixup) { - *g2 = 0; - return (mid + 1)->fixup; - } else - return mid->fixup; - } else if (diff < 0) - first = mid+1; - else - last = mid-1; - } - if (last->insn < value && !last->fixup && last[1].insn > value) { - *g2 = (value - last->insn)/4; - return last[1].fixup; - } - if (first > start && first[-1].insn < value - && !first[-1].fixup && first->insn < value) { - *g2 = (value - first[-1].insn)/4; - return first->fixup; - } + const struct exception_table_entry *walk; + + /* Single insn entries are encoded as: + * word 1: insn address + * word 2: fixup code address + * + * Range entries are encoded as: + * word 1: first insn address + * word 2: 0 + * word 3: last insn address + 4 bytes + * word 4: fixup code address + * + * See asm/uaccess.h for more details. + */ + + /* 1. Try to find an exact match. */ + for (walk = start; walk <= end; walk++) { + if (walk->fixup == 0) { + /* A range entry, skip both parts. */ + walk++; + continue; + } + + if (walk->insn == value) + return walk->fixup; + } + + /* 2. Try to find a range match. */ + for (walk = start; walk <= (end - 1); walk++) { + if (walk->fixup) + continue; + + if (walk[0].insn <= value && + walk[1].insn > value) { + *g2 = (value - walk[0].insn) / 4; + return walk[1].fixup; + } + walk++; + } + return 0; } diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/sparc/mm/fault.c linux-2.5/arch/sparc/mm/fault.c --- linux-2.5.1/arch/sparc/mm/fault.c Tue Oct 30 23:08:11 2001 +++ linux-2.5/arch/sparc/mm/fault.c Thu Dec 13 16:32:35 2001 @@ -1,4 +1,4 @@ -/* $Id: fault.c,v 1.121 2001/10/30 04:54:22 davem Exp $ +/* $Id: fault.c,v 1.122 2001/11/17 07:19:26 davem Exp $ * fault.c: Page fault handlers for the Sparc. * * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu) @@ -155,34 +155,47 @@ asmlinkage int lookup_fault(unsigned long pc, unsigned long ret_pc, unsigned long address) { + struct pt_regs regs; unsigned long g2; + unsigned int insn; int i; - unsigned insn; - struct pt_regs regs; - i = search_exception_table (ret_pc, &g2); + i = search_exception_table(ret_pc, &g2); switch (i) { - /* load & store will be handled by fixup */ - case 3: return 3; - /* store will be handled by fixup, load will bump out */ - /* for _to_ macros */ - case 1: insn = (unsigned)pc; if ((insn >> 21) & 1) return 1; break; - /* load will be handled by fixup, store will bump out */ - /* for _from_ macros */ - case 2: insn = (unsigned)pc; - if (!((insn >> 21) & 1) || ((insn>>19)&0x3f) == 15) return 2; + case 3: + /* load & store will be handled by fixup */ + return 3; + + case 1: + /* store will be handled by fixup, load will bump out */ + /* for _to_ macros */ + insn = *((unsigned int *) pc); + if ((insn >> 21) & 1) + return 1; + break; + + case 2: + /* load will be handled by fixup, store will bump out */ + /* for _from_ macros */ + insn = *((unsigned int *) pc); + if (!((insn >> 21) & 1) || ((insn>>19)&0x3f) == 15) + return 2; break; - default: break; - } - memset (®s, 0, sizeof (regs)); + + default: + break; + }; + + memset(®s, 0, sizeof (regs)); regs.pc = pc; regs.npc = pc + 4; - __asm__ __volatile__ ( + __asm__ __volatile__( "rd %%psr, %0\n\t" "nop\n\t" "nop\n\t" "nop\n" : "=r" (regs.psr)); - unhandled_fault (address, current, ®s); + unhandled_fault(address, current, ®s); + /* Not reached */ return 0; } diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/sparc/mm/init.c linux-2.5/arch/sparc/mm/init.c --- linux-2.5.1/arch/sparc/mm/init.c Mon Oct 1 16:19:56 2001 +++ linux-2.5/arch/sparc/mm/init.c Thu Dec 13 16:32:35 2001 @@ -1,4 +1,4 @@ -/* $Id: init.c,v 1.100 2001/09/21 22:51:47 davem Exp $ +/* $Id: init.c,v 1.103 2001/11/19 19:03:08 davem Exp $ * linux/arch/sparc/mm/init.c * * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu) @@ -410,9 +410,6 @@ int datapages = 0; int initpages = 0; int i; -#ifdef CONFIG_BLK_DEV_INITRD - unsigned long addr, last; -#endif highmem_start_page = mem_map + highstart_pfn; diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/sparc64/Makefile linux-2.5/arch/sparc64/Makefile --- linux-2.5.1/arch/sparc64/Makefile Sun Oct 21 17:36:54 2001 +++ linux-2.5/arch/sparc64/Makefile Thu Dec 13 16:32:35 2001 @@ -1,4 +1,4 @@ -# $Id: Makefile,v 1.49 2001/10/17 18:26:58 davem Exp $ +# $Id: Makefile,v 1.51 2001/11/17 00:15:27 davem Exp $ # sparc64/Makefile # # Makefile for the architecture dependent flags and dependencies on the @@ -38,11 +38,6 @@ AS := $(AS) --undeclared-regs endif -# -# Uncomment the first CFLAGS if you are doing kgdb source level -# debugging of the kernel to get the proper debugging information. - -#CFLAGS := $(CFLAGS) -g -pipe -fcall-used-g5 -fcall-used-g7 ifneq ($(NEW_GCC),y) CFLAGS := $(CFLAGS) -pipe -mno-fpu -mtune=ultrasparc -mmedlow \ -ffixed-g4 -fcall-used-g5 -fcall-used-g7 -Wno-sign-compare @@ -51,25 +46,6 @@ -ffixed-g4 -fcall-used-g5 -fcall-used-g7 -Wno-sign-compare \ $(CC_UNDECL) AFLAGS += -m64 -mcpu=ultrasparc $(CC_UNDECL) -endif - -# Uncomment this to get spinlock/rwlock debugging on SMP. -# DEBUG_SPINLOCK = 1 - -ifdef CONFIG_SMP - ifdef DEBUG_SPINLOCK - CFLAGS += -DSPIN_LOCK_DEBUG - AFLAGS += -DSPIN_LOCK_DEBUG - endif -endif - -# Uncomment this to keep track of how often flush_dcache_page -# actually flushes the caches, output via /proc/cpuinfo -# -# DEBUG_DCACHE_FLUSH = 1 -ifdef DEBUG_DCACHE_FLUSH - CFLAGS += -DDCFLUSH_DEBUG - AFLAGS += -DDCFLUSH_DEBUG endif LINKFLAGS = -T arch/sparc64/vmlinux.lds diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/sparc64/config.in linux-2.5/arch/sparc64/config.in --- linux-2.5.1/arch/sparc64/config.in Tue Nov 13 17:16:05 2001 +++ linux-2.5/arch/sparc64/config.in Thu Dec 13 16:32:35 2001 @@ -1,4 +1,4 @@ -# $Id: config.in,v 1.152 2001/11/12 10:20:47 davem Exp $ +# $Id: config.in,v 1.156 2001/11/30 00:17:32 davem Exp $ # For a description of the syntax of this configuration file, # see the Configure script. # @@ -31,6 +31,8 @@ # Identify this as a Sparc64 build define_bool CONFIG_SPARC64 y +bool 'Support for hot-pluggable devices' CONFIG_HOTPLUG + # Global things across all Sun machines. define_bool CONFIG_HAVE_DEC_LOCK y define_bool CONFIG_RWSEM_GENERIC_SPINLOCK n @@ -89,7 +91,6 @@ mainmenu_option next_comment comment 'Console drivers' bool 'PROM console' CONFIG_PROM_CONSOLE -bool 'Support Frame buffer devices' CONFIG_FB source drivers/video/Config.in endmenu @@ -191,21 +192,21 @@ if [ "$CONFIG_SCSI_SYM53C8XX_2" != "y" ]; then dep_tristate 'NCR53C8XX SCSI support' CONFIG_SCSI_NCR53C8XX $CONFIG_SCSI dep_tristate 'SYM53C8XX SCSI support' CONFIG_SCSI_SYM53C8XX $CONFIG_SCSI - fi - if [ "$CONFIG_SCSI_NCR53C8XX" != "n" -o "$CONFIG_SCSI_SYM53C8XX" != "n" ]; then - int 'default tagged command queue depth' CONFIG_SCSI_NCR53C8XX_DEFAULT_TAGS 8 - int 'maximum number of queued commands' CONFIG_SCSI_NCR53C8XX_MAX_TAGS 32 - int 'synchronous transfers frequency in MHz' CONFIG_SCSI_NCR53C8XX_SYNC 10 - bool ' enable profiling' CONFIG_SCSI_NCR53C8XX_PROFILE - if [ "$CONFIG_SCSI_SYM53C8XX" != "n" ]; then - bool ' include support for the NCR PQS/PDS SCSI card' CONFIG_SCSI_NCR53C8XX_PQS_PDS + if [ "$CONFIG_SCSI_NCR53C8XX" != "n" -o "$CONFIG_SCSI_SYM53C8XX" != "n" ]; then + int 'default tagged command queue depth' CONFIG_SCSI_NCR53C8XX_DEFAULT_TAGS 8 + int 'maximum number of queued commands' CONFIG_SCSI_NCR53C8XX_MAX_TAGS 32 + int 'synchronous transfers frequency in MHz' CONFIG_SCSI_NCR53C8XX_SYNC 10 + bool ' enable profiling' CONFIG_SCSI_NCR53C8XX_PROFILE + if [ "$CONFIG_SCSI_SYM53C8XX" != "n" ]; then + bool ' include support for the NCR PQS/PDS SCSI card' CONFIG_SCSI_NCR53C8XX_PQS_PDS + fi + if [ "$CONFIG_SCSI_NCR53C8XX_DEFAULT_TAGS" = "0" ]; then + bool ' not allow targets to disconnect' CONFIG_SCSI_NCR53C8XX_NO_DISCONNECT + fi + if [ "$CONFIG_EXPERIMENTAL" = "y" ]; then + bool ' assume boards are SYMBIOS compatible (EXPERIMENTAL)' CONFIG_SCSI_NCR53C8XX_SYMBIOS_COMPAT + fi fi - if [ "$CONFIG_SCSI_NCR53C8XX_DEFAULT_TAGS" = "0" ]; then - bool ' not allow targets to disconnect' CONFIG_SCSI_NCR53C8XX_NO_DISCONNECT - fi - if [ "$CONFIG_EXPERIMENTAL" = "y" ]; then - bool ' assume boards are SYMBIOS compatible (EXPERIMENTAL)' CONFIG_SCSI_NCR53C8XX_SYMBIOS_COMPAT - fi fi dep_tristate 'Qlogic ISP SCSI support' CONFIG_SCSI_QLOGIC_ISP $CONFIG_SCSI dep_tristate 'Qlogic ISP FC SCSI support' CONFIG_SCSI_QLOGIC_FC $CONFIG_SCSI @@ -295,6 +296,13 @@ mainmenu_option next_comment comment 'Kernel hacking' -bool 'Magic SysRq key' CONFIG_MAGIC_SYSRQ -#bool 'ECache flush trap support at ta 0x72' CONFIG_EC_FLUSH_TRAP +bool 'Kernel debugging' CONFIG_DEBUG_KERNEL +if [ "$CONFIG_DEBUG_KERNEL" != "n" ]; then + bool ' Debug memory allocations' CONFIG_DEBUG_SLAB + bool ' Magic SysRq key' CONFIG_MAGIC_SYSRQ + bool ' Spinlock debugging' CONFIG_DEBUG_SPINLOCK + bool ' Verbose BUG() reporting (adds 70K)' CONFIG_DEBUG_BUGVERBOSE + bool ' D-cache flush debugging' CONFIG_DEBUG_DCFLUSH +fi + endmenu diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/sparc64/defconfig linux-2.5/arch/sparc64/defconfig --- linux-2.5.1/arch/sparc64/defconfig Tue Nov 13 17:16:05 2001 +++ linux-2.5/arch/sparc64/defconfig Thu Dec 13 16:32:35 2001 @@ -22,6 +22,7 @@ CONFIG_VT_CONSOLE=y CONFIG_SMP=y CONFIG_SPARC64=y +CONFIG_HOTPLUG=y CONFIG_HAVE_DEC_LOCK=y # CONFIG_RWSEM_GENERIC_SPINLOCK is not set CONFIG_RWSEM_XCHGADD_ALGORITHM=y @@ -84,7 +85,6 @@ # Console drivers # CONFIG_PROM_CONSOLE=y -CONFIG_FB=y # # Frame-buffer support @@ -158,15 +158,16 @@ # # Multi-device support (RAID and LVM) # -# CONFIG_MD is not set -# CONFIG_BLK_DEV_MD is not set -# CONFIG_MD_LINEAR is not set -# CONFIG_MD_RAID0 is not set -# CONFIG_MD_RAID1 is not set -# CONFIG_MD_RAID5 is not set -# CONFIG_MD_MULTIPATH is not set -# CONFIG_BLK_DEV_LVM is not set -# CONFIG_BLK_DEV_RAM is not set +CONFIG_MD=y +CONFIG_BLK_DEV_MD=m +CONFIG_MD_LINEAR=m +CONFIG_MD_RAID0=m +CONFIG_MD_RAID1=m +CONFIG_MD_RAID5=m +CONFIG_MD_MULTIPATH=m +CONFIG_BLK_DEV_LVM=m +CONFIG_BLK_DEV_RAM=m +CONFIG_BLK_DEV_RAM_SIZE=4096 # CONFIG_BLK_DEV_INITRD is not set # @@ -174,8 +175,6 @@ # CONFIG_PACKET=y CONFIG_PACKET_MMAP=y -CONFIG_NETLINK=y -CONFIG_RTNETLINK=y CONFIG_NETLINK_DEV=y # CONFIG_NETFILTER is not set # CONFIG_FILTER is not set @@ -354,15 +353,11 @@ CONFIG_AIC7XXX_OLD_TCQ_ON_BY_DEFAULT=y CONFIG_AIC7XXX_OLD_CMDS_PER_DEVICE=8 CONFIG_AIC7XXX_OLD_PROC_STATS=y -# CONFIG_SCSI_SYM53C8XX_2 is not set -CONFIG_SCSI_NCR53C8XX=m -CONFIG_SCSI_SYM53C8XX=y -CONFIG_SCSI_NCR53C8XX_DEFAULT_TAGS=4 -CONFIG_SCSI_NCR53C8XX_MAX_TAGS=32 -CONFIG_SCSI_NCR53C8XX_SYNC=40 -# CONFIG_SCSI_NCR53C8XX_PROFILE is not set -# CONFIG_SCSI_NCR53C8XX_PQS_PDS is not set -# CONFIG_SCSI_NCR53C8XX_SYMBIOS_COMPAT is not set +CONFIG_SCSI_SYM53C8XX_2=y +CONFIG_SCSI_SYM53C8XX_DMA_ADDRESSING_MODE=1 +CONFIG_SCSI_SYM53C8XX_DEFAULT_TAGS=16 +CONFIG_SCSI_SYM53C8XX_MAX_TAGS=64 +# CONFIG_SCSI_SYM53C8XX_IOMAPPED is not set CONFIG_SCSI_QLOGIC_ISP=m CONFIG_SCSI_QLOGIC_FC=y CONFIG_SCSI_QLOGIC_FC_FIRMWARE=y @@ -493,6 +488,7 @@ CONFIG_SUNDANCE=m # CONFIG_TLAN is not set CONFIG_VIA_RHINE=m +# CONFIG_VIA_RHINE_MMIO is not set CONFIG_WINBOND_840=m # CONFIG_NET_POCKET is not set @@ -539,7 +535,7 @@ CONFIG_NET_FC=y # CONFIG_IPHASE5526 is not set # CONFIG_RCPCI is not set -# CONFIG_SHAPER is not set +CONFIG_SHAPER=m # # Wan interfaces @@ -861,4 +857,9 @@ # # Kernel hacking # -# CONFIG_MAGIC_SYSRQ is not set +CONFIG_DEBUG_KERNEL=y +# CONFIG_DEBUG_SLAB is not set +CONFIG_MAGIC_SYSRQ=y +# CONFIG_DEBUG_SPINLOCK is not set +# CONFIG_DEBUG_BUGVERBOSE is not set +# CONFIG_DEBUG_DCFLUSH is not set diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/sparc64/kernel/Makefile linux-2.5/arch/sparc64/kernel/Makefile --- linux-2.5.1/arch/sparc64/kernel/Makefile Wed May 16 17:31:27 2001 +++ linux-2.5/arch/sparc64/kernel/Makefile Thu Dec 13 16:32:35 2001 @@ -1,4 +1,4 @@ -# $Id: Makefile,v 1.67 2001/05/11 04:31:55 davem Exp $ +# $Id: Makefile,v 1.69 2001/11/19 04:09:53 davem Exp $ # Makefile for the linux kernel. # # Note! Dependencies are done automagically by 'make dep', which also @@ -68,7 +68,7 @@ @echo "#include <linux/config.h>" > tmp.c @echo "#undef CONFIG_SMP" >> tmp.c @echo "#include <linux/sched.h>" >> tmp.c - $(CPP) $(CPPFLAGS) tmp.c -o tmp.i + $(CPP) $(CPPFLAGS) -P tmp.c -o tmp.i @echo "/* Automatically generated. Do not edit. */" > check_asm_data.c @echo "#include <linux/config.h>" >> check_asm_data.c @echo "#undef CONFIG_SMP" >> check_asm_data.c @@ -95,12 +95,12 @@ ./check_asm >> asm_offsets.h @rm -f check_asm check_asm.c @echo -e "\n#else /* CONFIG_SMP */\n" >> asm_offsets.h - @echo -e "#ifndef SPIN_LOCK_DEBUG\n" >>asm_offsets.h + @echo -e "#ifndef CONFIG_DEBUG_SPINLOCK\n" >>asm_offsets.h @echo "#include <linux/config.h>" > tmp.c @echo "#undef CONFIG_SMP" >> tmp.c @echo "#define CONFIG_SMP 1" >> tmp.c @echo "#include <linux/sched.h>" >> tmp.c - $(CPP) $(CPPFLAGS) tmp.c -o tmp.i + $(CPP) $(CPPFLAGS) -P tmp.c -o tmp.i @echo "/* Automatically generated. Do not edit. */" > check_asm_data.c @echo "#include <linux/config.h>" >> check_asm_data.c @echo "#undef CONFIG_SMP" >> check_asm_data.c @@ -127,9 +127,9 @@ $(HOSTCC) -o check_asm check_asm.c ./check_asm >> asm_offsets.h @rm -f check_asm check_asm.c - @echo -e "\n#else /* SPIN_LOCK_DEBUG */\n" >> asm_offsets.h + @echo -e "\n#else /* CONFIG_DEBUG_SPINLOCK */\n" >> asm_offsets.h @echo "#include <linux/sched.h>" > tmp.c - $(CPP) $(CPPFLAGS) -DSPIN_LOCK_DEBUG tmp.c -o tmp.i + $(CPP) $(CPPFLAGS) -P -DCONFIG_DEBUG_SPINLOCK tmp.c -o tmp.i @echo "/* Automatically generated. Do not edit. */" > check_asm_data.c @echo "#include <linux/config.h>" >> check_asm_data.c @echo "#undef CONFIG_SMP" >> check_asm_data.c @@ -140,7 +140,7 @@ $(SH) ./check_asm.sh -data mm tmp.i check_asm_data.c $(SH) ./check_asm.sh -data thread tmp.i check_asm_data.c @echo '};' >> check_asm_data.c - $(CC) $(CPPFLAGS) -DSPIN_LOCK_DEBUG $(CMODEL_CFLAG) -ffixed-g4 -S -o check_asm_data.s check_asm_data.c + $(CC) $(CPPFLAGS) -DCONFIG_DEBUG_SPINLOCK $(CMODEL_CFLAG) -ffixed-g4 -S -o check_asm_data.s check_asm_data.c @echo "/* Automatically generated. Do not edit. */" > check_asm.c @echo 'extern int printf(const char *fmt, ...);' >>check_asm.c @echo 'unsigned int check_asm_data[] = {' >> check_asm.c @@ -156,7 +156,7 @@ $(HOSTCC) -o check_asm check_asm.c ./check_asm >> asm_offsets.h @rm -f check_asm check_asm.c - @echo -e "#endif /* SPIN_LOCK_DEBUG */\n" >> asm_offsets.h + @echo -e "#endif /* CONFIG_DEBUG_SPINLOCK */\n" >> asm_offsets.h @echo -e "#endif /* CONFIG_SMP */\n" >> asm_offsets.h @echo "#endif /* __ASM_OFFSETS_H__ */" >> asm_offsets.h @if test -r $(HPATH)/asm/asm_offsets.h; then \ diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/sparc64/kernel/entry.S linux-2.5/arch/sparc64/kernel/entry.S --- linux-2.5.1/arch/sparc64/kernel/entry.S Sun Oct 21 17:36:54 2001 +++ linux-2.5/arch/sparc64/kernel/entry.S Thu Dec 13 16:32:35 2001 @@ -1,4 +1,4 @@ -/* $Id: entry.S,v 1.137 2001/10/18 09:06:36 davem Exp $ +/* $Id: entry.S,v 1.141 2001/12/05 23:56:32 davem Exp $ * arch/sparc64/kernel/entry.S: Sparc64 trap low-level entry points. * * Copyright (C) 1995,1997 David S. Miller (davem@caip.rutgers.edu) @@ -483,7 +483,11 @@ ldxa [%g7 + %g0] ASI_INTR_R, %g7 stxa %g0, [%g0] ASI_INTR_RECEIVE membar #Sync - jmpl %g3, %g0 + ba,pt %xcc, 1f + nop + + .align 32 +1: jmpl %g3, %g0 nop do_ivec_spurious: @@ -657,15 +661,15 @@ stx %g5, [%g1 + %lo(pdma_size)] sethi %hi(auxio_register), %g1 ldx [%g1 + %lo(auxio_register)], %g7 - ldub [%g7], %g5 + lduba [%g7] ASI_PHYS_BYPASS_EC_E, %g5 or %g5, 0xc2, %g5 - stb %g5, [%g7] + stba %g5, [%g7] ASI_PHYS_BYPASS_EC_E andn %g5, 0x02, %g5 nop; nop; nop; nop; nop; nop; nop; nop; nop; nop; nop; nop; - stb %g5, [%g7] + stba %g5, [%g7] ASI_PHYS_BYPASS_EC_E sethi %hi(doing_pdma), %g1 b,pt %xcc, floppy_dosoftint st %g0, [%g1 + %lo(doing_pdma)] @@ -678,7 +682,12 @@ sethi %hi(irq_action), %g1 or %g1, %lo(irq_action), %g1 ldx [%g1 + (11 << 3)], %g3 ! irqaction[floppy_irq] - ldx [%g3 + 0x10], %g4 ! action->mask == ino_bucket ptr + ldx [%g3 + 0x08], %g4 ! action->flags>>48==ino + sethi %hi(ivector_table), %g3 + srlx %g4, 48, %g4 + or %g3, %lo(ivector_table), %g3 + sllx %g4, 5, %g4 + ldx [%g3 + %g4], %g4 ! &ivector_table[ino] ldx [%g4 + 0x10], %g4 ! bucket->iclr stwa %g0, [%g4] ASI_PHYS_BYPASS_EC_E ! ICLR_IDLE membar #Sync ! probably not needed... @@ -1615,6 +1624,11 @@ * * Note with time_t changes to the timeval type, I must now use * nucleus atomic quad 128-bit loads. + * + * If xtime was stored recently, I've seen crap from the + * quad load on Cheetah. Putting a membar SYNC before + * the quad load seems to make the problem go away. -DaveM + * (we should nop out workarounds like this on spitfire) */ sethi %hi(timer_tick_offset), %g3 sethi %hi(xtime), %g2 @@ -1626,6 +1640,7 @@ sethi %hi(0x003e0014), %o1 srlx %o2, 32, %o2 or %o1, %lo(0x003e0014), %o1 + membar #Sync ldda [%g2] ASI_NUCLEUS_QUAD_LDD, %o4 cmp %o2, %o1 bne,pt %xcc, 2f @@ -1634,6 +1649,7 @@ rd %asr24, %o1 2: rd %tick, %o1 3: ldx [%g1], %g7 + membar #Sync ldda [%g2] ASI_NUCLEUS_QUAD_LDD, %o2 xor %o4, %o2, %o2 xor %o5, %o3, %o3 diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/sparc64/kernel/head.S linux-2.5/arch/sparc64/kernel/head.S --- linux-2.5.1/arch/sparc64/kernel/head.S Sat Oct 6 15:50:28 2001 +++ linux-2.5/arch/sparc64/kernel/head.S Thu Dec 13 16:32:35 2001 @@ -1,4 +1,4 @@ -/* $Id: head.S,v 1.82 2001/10/04 23:37:04 davem Exp $ +/* $Id: head.S,v 1.86 2001/12/05 01:02:16 davem Exp $ * head.S: Initial boot code for the Sparc64 port of Linux. * * Copyright (C) 1996,1997 David S. Miller (davem@caip.rutgers.edu) @@ -201,7 +201,7 @@ add %l0, (1 << 3), %l0 /* Now lock the TTE we created into ITLB-0 and DTLB-0, - * entry 15. + * entry 15 (and maybe 14 too). */ sethi %hi(KERNBASE), %g3 set (0 << 16) | (15 << 3), %g7 @@ -215,6 +215,29 @@ membar #Sync flush %g3 membar #Sync + sethi %hi(_end), %g3 /* Check for bigkernel case */ + or %g3, %lo(_end), %g3 + srl %g3, 23, %g3 /* Check if _end > 8M */ + brz,pt %g3, 1f + sethi %hi(KERNBASE), %g3 /* Restore for fixup code below */ + sethi %hi(0x400000), %g3 + or %g3, %lo(0x400000), %g3 + add %g5, %g3, %g5 /* New tte data */ + andn %g5, (_PAGE_G), %g5 + sethi %hi(KERNBASE+0x400000), %g3 + or %g3, %lo(KERNBASE+0x400000), %g3 + set (0 << 16) | (14 << 3), %g7 + stxa %g3, [%l7] ASI_DMMU + membar #Sync + stxa %g5, [%g7] ASI_DTLB_DATA_ACCESS + membar #Sync + stxa %g3, [%l7] ASI_IMMU + membar #Sync + stxa %g5, [%g7] ASI_ITLB_DATA_ACCESS + membar #Sync + flush %g3 + membar #Sync + sethi %hi(KERNBASE), %g3 /* Restore for fixup code below */ ba,pt %xcc, 1f nop @@ -345,7 +368,7 @@ /* PROM never puts any TLB entries into the MMU with the lock bit - * set. So we gladly use tlb entry 63 for KERNBASE. + * set. So we gladly use tlb entry 63 for KERNBASE. And maybe 62 too. */ sethi %hi(KERNBASE), %g3 @@ -358,7 +381,28 @@ membar #Sync flush %g3 membar #Sync - ba,pt %xcc, 1f + sethi %hi(_end), %g3 /* Check for bigkernel case */ + or %g3, %lo(_end), %g3 + srl %g3, 23, %g3 /* Check if _end > 8M */ + brz,pt %g3, 2f + sethi %hi(KERNBASE), %g3 /* Restore for fixup code below */ + sethi %hi(0x400000), %g3 + or %g3, %lo(0x400000), %g3 + add %g5, %g3, %g5 /* New tte data */ + andn %g5, (_PAGE_G), %g5 + sethi %hi(KERNBASE+0x400000), %g3 + or %g3, %lo(KERNBASE+0x400000), %g3 + mov (62 << 3), %g7 + stxa %g3, [%l7] ASI_DMMU + stxa %g5, [%g7] ASI_DTLB_DATA_ACCESS + membar #Sync + stxa %g3, [%l7] ASI_IMMU + stxa %g5, [%g7] ASI_ITLB_DATA_ACCESS + membar #Sync + flush %g3 + membar #Sync + sethi %hi(KERNBASE), %g3 /* Restore for fixup code below */ +2: ba,pt %xcc, 1f nop 1: set sun4u_init, %g2 diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/sparc64/kernel/ioctl32.c linux-2.5/arch/sparc64/kernel/ioctl32.c --- linux-2.5.1/arch/sparc64/kernel/ioctl32.c Tue Nov 13 17:16:05 2001 +++ linux-2.5/arch/sparc64/kernel/ioctl32.c Thu Dec 13 16:32:35 2001 @@ -1,4 +1,4 @@ -/* $Id: ioctl32.c,v 1.132 2001/11/07 05:56:19 davem Exp $ +/* $Id: ioctl32.c,v 1.133 2001/11/14 06:14:29 davem Exp $ * ioctl32.c: Conversion between 32bit and 64bit native ioctls. * * Copyright (C) 1997-2000 Jakub Jelinek (jakub@redhat.com) @@ -2421,6 +2421,7 @@ u32 pv[ABS_MAX_PV + 1]; u32 lv[ABS_MAX_LV + 1]; uint8_t vg_uuid[UUID_LEN+1]; /* volume group UUID */ + uint8_t dummy1[200]; } vg32_t; typedef struct { @@ -2462,7 +2463,7 @@ } lv_status_byindex_req32_t; typedef struct { - dev_t dev; + __kernel_dev_t32 dev; u32 lv; } lv_status_bydev_req32_t; @@ -2535,7 +2536,8 @@ lv_block_exception32_t *lbe32; lv_block_exception_t *lbe; lv32_t *ul = (lv32_t *)A(p); - lv_t *l = (lv_t *)kmalloc(sizeof(lv_t), GFP_KERNEL); + lv_t *l = (lv_t *) kmalloc(sizeof(lv_t), GFP_KERNEL); + if (!l) { *errp = -ENOMEM; return NULL; @@ -2565,12 +2567,11 @@ if (l->lv_block_exception) { lbe32 = (lv_block_exception32_t *)A(ptr2); memset(lbe, 0, size); - for (i = 0; i < l->lv_remap_end; i++, lbe++, lbe32++) { - err |= get_user(lbe->rsector_org, &lbe32->rsector_org); - err |= __get_user(lbe->rdev_org, &lbe32->rdev_org); - err |= __get_user(lbe->rsector_new, &lbe32->rsector_new); - err |= __get_user(lbe->rdev_new, &lbe32->rdev_new); - + for (i = 0; i < l->lv_remap_end; i++, lbe++, lbe32++) { + err |= get_user(lbe->rsector_org, &lbe32->rsector_org); + err |= __get_user(lbe->rdev_org, &lbe32->rdev_org); + err |= __get_user(lbe->rsector_new, &lbe32->rsector_new); + err |= __get_user(lbe->rdev_new, &lbe32->rdev_new); } } } @@ -2608,7 +2609,7 @@ static int do_lvm_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg) { - vg_t *v; + vg_t *v = NULL; union { lv_req_t lv_req; le_remap_req_t le_remap; @@ -2626,17 +2627,22 @@ switch (cmd) { case VG_STATUS: v = kmalloc(sizeof(vg_t), GFP_KERNEL); - if (!v) return -ENOMEM; + if (!v) + return -ENOMEM; karg = v; break; + + case VG_CREATE_OLD: case VG_CREATE: v = kmalloc(sizeof(vg_t), GFP_KERNEL); - if (!v) return -ENOMEM; - if (copy_from_user(v, (void *)arg, (long)&((vg32_t *)0)->proc) || - __get_user(v->proc, &((vg32_t *)arg)->proc)) { + if (!v) + return -ENOMEM; + if (copy_from_user(v, (void *)arg, (long)&((vg32_t *)0)->proc)) { kfree(v); return -EFAULT; } + /* 'proc' field is unused, just NULL it out. */ + v->proc = NULL; if (copy_from_user(v->vg_uuid, ((vg32_t *)arg)->vg_uuid, UUID_LEN+1)) { kfree(v); return -EFAULT; @@ -2648,39 +2654,46 @@ return -EPERM; for (i = 0; i < v->pv_max; i++) { err = __get_user(ptr, &((vg32_t *)arg)->pv[i]); - if (err) break; + if (err) + break; if (ptr) { v->pv[i] = kmalloc(sizeof(pv_t), GFP_KERNEL); if (!v->pv[i]) { err = -ENOMEM; break; } - err = copy_from_user(v->pv[i], (void *)A(ptr), sizeof(pv32_t) - 8 - UUID_LEN+1); + err = copy_from_user(v->pv[i], (void *)A(ptr), + sizeof(pv32_t) - 8 - UUID_LEN+1); if (err) { err = -EFAULT; break; } - err = copy_from_user(v->pv[i]->pv_uuid, ((pv32_t *)A(ptr))->pv_uuid, UUID_LEN+1); + err = copy_from_user(v->pv[i]->pv_uuid, + ((pv32_t *)A(ptr))->pv_uuid, + UUID_LEN+1); if (err) { err = -EFAULT; break; } - - v->pv[i]->pe = NULL; v->pv[i]->inode = NULL; + v->pv[i]->pe = NULL; + v->pv[i]->bd = NULL; } } if (!err) { for (i = 0; i < v->lv_max; i++) { err = __get_user(ptr, &((vg32_t *)arg)->lv[i]); - if (err) break; + if (err) + break; if (ptr) { v->lv[i] = get_lv_t(ptr, &err); - if (err) break; + if (err) + break; } } } break; + case LV_CREATE: case LV_EXTEND: case LV_REDUCE: @@ -2688,54 +2701,70 @@ case LV_RENAME: case LV_STATUS_BYNAME: err = copy_from_user(&u.pv_status, arg, sizeof(u.pv_status.pv_name)); - if (err) return -EFAULT; + if (err) + return -EFAULT; if (cmd != LV_REMOVE) { err = __get_user(ptr, &((lv_req32_t *)arg)->lv); - if (err) return err; + if (err) + return err; u.lv_req.lv = get_lv_t(ptr, &err); } else u.lv_req.lv = NULL; break; - case LV_STATUS_BYINDEX: - err = get_user(u.lv_byindex.lv_index, &((lv_status_byindex_req32_t *)arg)->lv_index); + err = get_user(u.lv_byindex.lv_index, + &((lv_status_byindex_req32_t *)arg)->lv_index); err |= __get_user(ptr, &((lv_status_byindex_req32_t *)arg)->lv); - if (err) return err; + if (err) + return err; u.lv_byindex.lv = get_lv_t(ptr, &err); break; + case LV_STATUS_BYDEV: err = get_user(u.lv_bydev.dev, &((lv_status_bydev_req32_t *)arg)->dev); + err |= __get_user(ptr, &((lv_status_bydev_req32_t *)arg)->lv); + if (err) + return err; u.lv_bydev.lv = get_lv_t(ptr, &err); - if (err) return err; - u.lv_bydev.lv = &p; - p.pe = NULL; p.inode = NULL; - break; + break; + case VG_EXTEND: err = copy_from_user(&p, (void *)arg, sizeof(pv32_t) - 8 - UUID_LEN+1); - if (err) return -EFAULT; + if (err) + return -EFAULT; err = copy_from_user(p.pv_uuid, ((pv32_t *)arg)->pv_uuid, UUID_LEN+1); - if (err) return -EFAULT; - p.pe = NULL; p.inode = NULL; + if (err) + return -EFAULT; + p.pe = NULL; + p.bd = NULL; karg = &p; break; + case PV_CHANGE: case PV_STATUS: err = copy_from_user(&u.pv_status, arg, sizeof(u.lv_req.lv_name)); - if (err) return -EFAULT; + if (err) + return -EFAULT; err = __get_user(ptr, &((pv_status_req32_t *)arg)->pv); - if (err) return err; + if (err) + return err; u.pv_status.pv = &p; if (cmd == PV_CHANGE) { - err = copy_from_user(&p, (void *)A(ptr), sizeof(pv32_t) - 8 - UUID_LEN+1); - if (err) return -EFAULT; - p.pe = NULL; p.inode = NULL; + err = copy_from_user(&p, (void *)A(ptr), + sizeof(pv32_t) - 8 - UUID_LEN+1); + if (err) + return -EFAULT; + p.pe = NULL; + p.bd = NULL; } break; - } + }; + old_fs = get_fs(); set_fs (KERNEL_DS); err = sys_ioctl (fd, cmd, (unsigned long)karg); set_fs (old_fs); + switch (cmd) { case VG_STATUS: if (!err) { @@ -2748,42 +2777,60 @@ } kfree(v); break; + + case VG_CREATE_OLD: case VG_CREATE: - for (i = 0; i < v->pv_max; i++) - if (v->pv[i]) kfree(v->pv[i]); - for (i = 0; i < v->lv_max; i++) - if (v->lv[i]) put_lv_t(v->lv[i]); + for (i = 0; i < v->pv_max; i++) { + if (v->pv[i]) + kfree(v->pv[i]); + } + for (i = 0; i < v->lv_max; i++) { + if (v->lv[i]) + put_lv_t(v->lv[i]); + } kfree(v); break; + case LV_STATUS_BYNAME: - if (!err && u.lv_req.lv) err = copy_lv_t(ptr, u.lv_req.lv); + if (!err && u.lv_req.lv) + err = copy_lv_t(ptr, u.lv_req.lv); /* Fall through */ + case LV_CREATE: case LV_EXTEND: case LV_REDUCE: - if (u.lv_req.lv) put_lv_t(u.lv_req.lv); + if (u.lv_req.lv) + put_lv_t(u.lv_req.lv); break; + case LV_STATUS_BYINDEX: if (u.lv_byindex.lv) { - if (!err) err = copy_lv_t(ptr, u.lv_byindex.lv); + if (!err) + err = copy_lv_t(ptr, u.lv_byindex.lv); put_lv_t(u.lv_byindex.lv); } break; + + case LV_STATUS_BYDEV: + if (u.lv_bydev.lv) { + if (!err) + err = copy_lv_t(ptr, u.lv_bydev.lv); + put_lv_t(u.lv_byindex.lv); + } + break; + case PV_STATUS: if (!err) { err = copy_to_user((void *)A(ptr), &p, sizeof(pv32_t) - 8 - UUID_LEN+1); - if (err) return -EFAULT; + if (err) + return -EFAULT; err = copy_to_user(((pv_t *)A(ptr))->pv_uuid, p.pv_uuid, UUID_LEN + 1); - if (err) return -EFAULT; + if (err) + return -EFAULT; } break; - case LV_STATUS_BYDEV: - if (!err) { - if (!err) err = copy_lv_t(ptr, u.lv_bydev.lv); - put_lv_t(u.lv_byindex.lv); - } - break; - } + }; + return err; } #endif @@ -4666,6 +4713,7 @@ HANDLE_IOCTL(SONET_GETFRSENSE, do_atm_ioctl) #if defined(CONFIG_BLK_DEV_LVM) || defined(CONFIG_BLK_DEV_LVM_MODULE) HANDLE_IOCTL(VG_STATUS, do_lvm_ioctl) +HANDLE_IOCTL(VG_CREATE_OLD, do_lvm_ioctl) HANDLE_IOCTL(VG_CREATE, do_lvm_ioctl) HANDLE_IOCTL(VG_EXTEND, do_lvm_ioctl) HANDLE_IOCTL(LV_CREATE, do_lvm_ioctl) @@ -4675,6 +4723,7 @@ HANDLE_IOCTL(LV_RENAME, do_lvm_ioctl) HANDLE_IOCTL(LV_STATUS_BYNAME, do_lvm_ioctl) HANDLE_IOCTL(LV_STATUS_BYINDEX, do_lvm_ioctl) +HANDLE_IOCTL(LV_STATUS_BYDEV, do_lvm_ioctl) HANDLE_IOCTL(PV_CHANGE, do_lvm_ioctl) HANDLE_IOCTL(PV_STATUS, do_lvm_ioctl) #endif /* LVM */ diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/sparc64/kernel/irq.c linux-2.5/arch/sparc64/kernel/irq.c --- linux-2.5.1/arch/sparc64/kernel/irq.c Wed Nov 28 21:22:26 2001 +++ linux-2.5/arch/sparc64/kernel/irq.c Thu Dec 13 16:32:35 2001 @@ -1,4 +1,4 @@ -/* $Id: irq.c,v 1.109 2001/11/12 22:22:37 davem Exp $ +/* $Id: irq.c,v 1.112 2001/11/16 00:04:54 kanoj Exp $ * irq.c: UltraSparc IRQ handling/init/registry. * * Copyright (C) 1997 David S. Miller (davem@caip.rutgers.edu) @@ -35,6 +35,7 @@ #include <asm/softirq.h> #include <asm/starfire.h> #include <asm/uaccess.h> +#include <asm/cache.h> #ifdef CONFIG_SMP static void distribute_irqs(void); @@ -53,10 +54,10 @@ * at the same time. */ -struct ino_bucket ivector_table[NUM_IVECS] __attribute__ ((aligned (64))); +struct ino_bucket ivector_table[NUM_IVECS] __attribute__ ((aligned (SMP_CACHE_BYTES))); #ifndef CONFIG_SMP -unsigned int __up_workvec[16] __attribute__ ((aligned (64))); +unsigned int __up_workvec[16] __attribute__ ((aligned (SMP_CACHE_BYTES))); #define irq_work(__cpu, __pil) &(__up_workvec[(void)(__cpu), (__pil)]) #else #define irq_work(__cpu, __pil) &(cpu_data[(__cpu)].irq_worklists[(__pil)]) @@ -822,6 +823,11 @@ irq_enter(cpu, irq); kstat.irqs[cpu][irq]++; + +#ifdef CONFIG_PCI + if (irq == 9) + kbd_pt_regs = regs; +#endif /* Sliiiick... */ #ifndef CONFIG_SMP diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/sparc64/kernel/pci_psycho.c linux-2.5/arch/sparc64/kernel/pci_psycho.c --- linux-2.5.1/arch/sparc64/kernel/pci_psycho.c Fri Oct 12 22:35:53 2001 +++ linux-2.5/arch/sparc64/kernel/pci_psycho.c Thu Dec 13 16:32:35 2001 @@ -1,4 +1,4 @@ -/* $Id: pci_psycho.c,v 1.29 2001/10/11 00:44:38 davem Exp $ +/* $Id: pci_psycho.c,v 1.30 2001/11/14 13:17:56 davem Exp $ * pci_psycho.c: PSYCHO/U2P specific PCI controller support. * * Copyright (C) 1997, 1998, 1999 David S. Miller (davem@caipfs.rutgers.edu) @@ -371,6 +371,7 @@ case PCI_BASE_CLASS_MULTIMEDIA: case PCI_BASE_CLASS_MEMORY: case PCI_BASE_CLASS_BRIDGE: + case PCI_BASE_CLASS_SERIAL: ret = 10; break; diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/sparc64/kernel/pci_sabre.c linux-2.5/arch/sparc64/kernel/pci_sabre.c --- linux-2.5.1/arch/sparc64/kernel/pci_sabre.c Fri Oct 12 22:35:53 2001 +++ linux-2.5/arch/sparc64/kernel/pci_sabre.c Thu Dec 13 16:32:35 2001 @@ -1,4 +1,4 @@ -/* $Id: pci_sabre.c,v 1.40 2001/10/11 00:44:38 davem Exp $ +/* $Id: pci_sabre.c,v 1.41 2001/11/14 13:17:56 davem Exp $ * pci_sabre.c: Sabre specific PCI controller support. * * Copyright (C) 1997, 1998, 1999 David S. Miller (davem@caipfs.rutgers.edu) @@ -589,6 +589,11 @@ { int ret; + if (pdev && + pdev->vendor == PCI_VENDOR_ID_SUN && + pdev->device == PCI_DEVICE_ID_SUN_RIO_USB) + return 9; + ret = sabre_pil_table[ino]; if (ret == 0 && pdev == NULL) { ret = 1; @@ -609,6 +614,7 @@ case PCI_BASE_CLASS_MULTIMEDIA: case PCI_BASE_CLASS_MEMORY: case PCI_BASE_CLASS_BRIDGE: + case PCI_BASE_CLASS_SERIAL: ret = 10; break; diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/sparc64/kernel/pci_schizo.c linux-2.5/arch/sparc64/kernel/pci_schizo.c --- linux-2.5.1/arch/sparc64/kernel/pci_schizo.c Fri Oct 12 22:35:53 2001 +++ linux-2.5/arch/sparc64/kernel/pci_schizo.c Thu Dec 13 16:32:35 2001 @@ -1,4 +1,4 @@ -/* $Id: pci_schizo.c,v 1.22 2001/10/11 00:44:38 davem Exp $ +/* $Id: pci_schizo.c,v 1.23 2001/11/14 13:17:56 davem Exp $ * pci_schizo.c: SCHIZO specific PCI controller support. * * Copyright (C) 2001 David S. Miller (davem@redhat.com) @@ -337,6 +337,11 @@ { int ret; + if (pdev && + pdev->vendor == PCI_VENDOR_ID_SUN && + pdev->device == PCI_DEVICE_ID_SUN_RIO_USB) + return 9; + ret = schizo_pil_table[ino]; if (ret == 0 && pdev == NULL) { ret = 1; @@ -357,6 +362,7 @@ case PCI_BASE_CLASS_MULTIMEDIA: case PCI_BASE_CLASS_MEMORY: case PCI_BASE_CLASS_BRIDGE: + case PCI_BASE_CLASS_SERIAL: ret = 10; break; diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/sparc64/kernel/process.c linux-2.5/arch/sparc64/kernel/process.c --- linux-2.5.1/arch/sparc64/kernel/process.c Sun Oct 21 17:36:54 2001 +++ linux-2.5/arch/sparc64/kernel/process.c Thu Dec 27 22:10:28 2001 @@ -1,4 +1,4 @@ -/* $Id: process.c,v 1.122 2001/10/18 09:06:36 davem Exp $ +/* $Id: process.c,v 1.125 2001/11/17 00:10:48 davem Exp $ * arch/sparc64/kernel/process.c * * Copyright (C) 1995, 1996 David S. Miller (davem@caip.rutgers.edu) @@ -54,7 +54,6 @@ /* endless idle loop with no priority at all */ current->nice = 20; - current->counter = -100; init_idle(); for (;;) { @@ -84,7 +83,6 @@ int cpu_idle(void) { current->nice = 20; - current->counter = -100; init_idle(); while(1) { @@ -276,7 +274,12 @@ #ifdef CONFIG_SMP unsigned long flags; - spin_lock_irqsave(®dump_lock, flags); + /* Protect against xcall ipis which might lead to livelock on the lock */ + __asm__ __volatile__("rdpr %%pstate, %0\n\t" + "wrpr %0, %1, %%pstate" + : "=r" (flags) + : "i" (PSTATE_IE)); + spin_lock(®dump_lock); printk("CPU[%d]: local_irq_count[%u] irqs_running[%d]\n", smp_processor_id(), local_irq_count(smp_processor_id()), @@ -298,7 +301,9 @@ regs->u_regs[15]); show_regwindow(regs); #ifdef CONFIG_SMP - spin_unlock_irqrestore(®dump_lock, flags); + spin_unlock(®dump_lock); + __asm__ __volatile__("wrpr %0, 0, %%pstate" + : : "r" (flags)); #endif } @@ -583,6 +588,11 @@ { struct thread_struct *t = &p->thread; char *child_trap_frame; + +#ifdef CONFIG_DEBUG_SPINLOCK + t->smp_lock_count = 0; + t->smp_lock_pc = 0; +#endif /* Calculate offset to stack_frame & pt_regs */ child_trap_frame = ((char *)p) + (THREAD_SIZE - (TRACEREG_SZ+REGWIN_SZ)); diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/sparc64/kernel/rtrap.S linux-2.5/arch/sparc64/kernel/rtrap.S --- linux-2.5.1/arch/sparc64/kernel/rtrap.S Wed Oct 17 21:16:39 2001 +++ linux-2.5/arch/sparc64/kernel/rtrap.S Thu Dec 13 16:32:35 2001 @@ -1,4 +1,4 @@ -/* $Id: rtrap.S,v 1.56 2001/10/13 00:14:34 kanoj Exp $ +/* $Id: rtrap.S,v 1.57 2001/12/06 00:16:11 davem Exp $ * rtrap.S: Preparing for return from trap on Sparc V9. * * Copyright (C) 1997,1998 Jakub Jelinek (jj@sunsite.mff.cuni.cz) @@ -18,14 +18,13 @@ #define RTRAP_PSTATE_IRQOFF (PSTATE_RMO|PSTATE_PEF|PSTATE_PRIV) #define RTRAP_PSTATE_AG_IRQOFF (PSTATE_RMO|PSTATE_PEF|PSTATE_PRIV|PSTATE_AG) -#if 0 -#define RTRAP_CHECK call rtrap_check; add %sp, (STACK_BIAS+REGWIN_SZ), %o0; -#else -#define RTRAP_CHECK -#endif + /* Register %l6 keeps track of whether we are returning + * from a system call or not. It is cleared if we call + * do_signal, and it must not be otherwise modified until + * we fully commit to returning to userspace. + */ .text - .align 32 __handle_softirq: call do_softirq @@ -34,42 +33,101 @@ nop __handle_preemption: call schedule - nop + wrpr %g0, RTRAP_PSTATE, %pstate ba,pt %xcc, __handle_preemption_continue - nop + wrpr %g0, RTRAP_PSTATE_IRQOFF, %pstate + __handle_user_windows: - wrpr %g0, RTRAP_PSTATE, %pstate call fault_in_user_windows - nop + wrpr %g0, RTRAP_PSTATE, %pstate ba,pt %xcc, __handle_user_windows_continue + wrpr %g0, RTRAP_PSTATE_IRQOFF, %pstate + /* Redo sched+sig checks */ + ldx [%g6 + AOFF_task_need_resched], %l0 + brz,pt %l0, 1f + nop + call schedule + + wrpr %g0, RTRAP_PSTATE, %pstate + wrpr %g0, RTRAP_PSTATE_IRQOFF, %pstate +1: lduw [%g6 + AOFF_task_sigpending], %l0 + brz,pt %l0, __handle_user_windows_continue nop + clr %o0 + mov %l5, %o2 + mov %l6, %o3 + + add %sp, STACK_BIAS + REGWIN_SZ, %o1 + call do_signal + wrpr %g0, RTRAP_PSTATE, %pstate + wrpr %g0, RTRAP_PSTATE_IRQOFF, %pstate + clr %l6 + /* Signal delivery can modify pt_regs tstate, so we must + * reload it. + */ + ldx [%sp + PTREGS_OFF + PT_V9_TSTATE], %l1 + sethi %hi(0xf << 20), %l4 + and %l1, %l4, %l4 + + ba,pt %xcc, __handle_user_windows_continue + andn %l1, %l4, %l1 __handle_perfctrs: - /* Don't forget to preserve user window invariants. */ - wrpr %g0, RTRAP_PSTATE, %pstate call update_perfctrs - nop + wrpr %g0, RTRAP_PSTATE, %pstate wrpr %g0, RTRAP_PSTATE_IRQOFF, %pstate ldub [%g6 + AOFF_task_thread + AOFF_thread_w_saved], %o2 - brz,pt %o2, __handle_perfctrs_continue - sethi %hi(TSTATE_PEF), %l6 - wrpr %g0, RTRAP_PSTATE, %pstate + brz,pt %o2, 1f + nop + /* Redo userwin+sched+sig checks */ call fault_in_user_windows + wrpr %g0, RTRAP_PSTATE, %pstate + wrpr %g0, RTRAP_PSTATE_IRQOFF, %pstate +1: ldx [%g6 + AOFF_task_need_resched], %l0 + brz,pt %l0, 1f nop + call schedule + wrpr %g0, RTRAP_PSTATE, %pstate + + wrpr %g0, RTRAP_PSTATE_IRQOFF, %pstate +1: lduw [%g6 + AOFF_task_sigpending], %l0 + brz,pt %l0, __handle_perfctrs_continue + sethi %hi(TSTATE_PEF), %o0 + clr %o0 + mov %l5, %o2 + mov %l6, %o3 + add %sp, STACK_BIAS + REGWIN_SZ, %o1 + + call do_signal + wrpr %g0, RTRAP_PSTATE, %pstate + wrpr %g0, RTRAP_PSTATE_IRQOFF, %pstate + clr %l6 + /* Signal delivery can modify pt_regs tstate, so we must + * reload it. + */ + ldx [%sp + PTREGS_OFF + PT_V9_TSTATE], %l1 + sethi %hi(0xf << 20), %l4 + and %l1, %l4, %l4 + andn %l1, %l4, %l1 + ba,pt %xcc, __handle_perfctrs_continue - nop + sethi %hi(TSTATE_PEF), %o0 __handle_userfpu: rd %fprs, %l5 andcc %l5, FPRS_FEF, %g0 + sethi %hi(TSTATE_PEF), %o0 be,a,pn %icc, __handle_userfpu_continue - andn %l1, %l6, %l1 + andn %l1, %o0, %l1 ba,a,pt %xcc, __handle_userfpu_continue + __handle_signal: clr %o0 mov %l5, %o2 mov %l6, %o3 + add %sp, STACK_BIAS + REGWIN_SZ, %o1 call do_signal - add %sp, STACK_BIAS + REGWIN_SZ, %o1 + wrpr %g0, RTRAP_PSTATE, %pstate + wrpr %g0, RTRAP_PSTATE_IRQOFF, %pstate clr %l6 /* Signal delivery can modify pt_regs tstate, so we must @@ -99,29 +157,43 @@ and %l1, %l4, %l4 bne,pn %icc, to_kernel andn %l1, %l4, %l1 -to_user: ldx [%g6 + AOFF_task_need_resched], %l0 - brnz,pn %l0, __handle_preemption + /* We must hold IRQs off and atomically test schedule+signal + * state, then hold them off all the way back to userspace. + * If we are returning to kernel, none of this matters. + * + * If we do not do this, there is a window where we would do + * the tests, later the signal/resched event arrives but we do + * not process it since we are still in kernel mode. It would + * take until the next local IRQ before the signal/resched + * event would be handled. + * + * This also means that if we have to deal with performance + * counters or user windows, we have to redo all of these + * sched+signal checks with IRQs disabled. + */ +to_user: wrpr %g0, RTRAP_PSTATE_IRQOFF, %pstate __handle_preemption_continue: + ldx [%g6 + AOFF_task_need_resched], %l0 + brnz,pn %l0, __handle_preemption lduw [%g6 + AOFF_task_sigpending], %l0 brnz,pn %l0, __handle_signal nop __handle_signal_continue: -check_user_wins: - wrpr %g0, RTRAP_PSTATE_IRQOFF, %pstate ldub [%g6 + AOFF_task_thread + AOFF_thread_w_saved], %o2 brnz,pn %o2, __handle_user_windows - sethi %hi(TSTATE_PEF), %l6 - + nop __handle_user_windows_continue: - RTRAP_CHECK ldub [%g6 + AOFF_task_thread + AOFF_thread_flags], %l5 andcc %l5, SPARC_FLAG_PERFCTR, %g0 + sethi %hi(TSTATE_PEF), %o0 bne,pn %xcc, __handle_perfctrs __handle_perfctrs_continue: - andcc %l1, %l6, %g0 + andcc %l1, %o0, %g0 + + /* This fpdepth clear is neccessary for non-syscall rtraps only */ bne,pn %xcc, __handle_userfpu - stb %g0, [%g6 + AOFF_task_thread + AOFF_thread_fpdepth] ! This is neccessary for non-syscall rtraps only + stb %g0, [%g6 + AOFF_task_thread + AOFF_thread_fpdepth] __handle_userfpu_continue: rt_continue: ldx [%sp + PTREGS_OFF + PT_V9_G1], %g1 diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/sparc64/kernel/semaphore.c linux-2.5/arch/sparc64/kernel/semaphore.c --- linux-2.5.1/arch/sparc64/kernel/semaphore.c Sun May 20 18:32:07 2001 +++ linux-2.5/arch/sparc64/kernel/semaphore.c Thu Dec 13 16:32:35 2001 @@ -1,4 +1,4 @@ -/* $Id: semaphore.c,v 1.8 2001/05/18 08:01:35 davem Exp $ +/* $Id: semaphore.c,v 1.9 2001/11/18 00:12:56 davem Exp $ * semaphore.c: Sparc64 semaphore implementation. * * This is basically the PPC semaphore scheme ported to use @@ -31,7 +31,7 @@ " cas [%3], %0, %1\n" " cmp %0, %1\n" " bne,pn %%icc, 1b\n" -" nop\n" +" membar #StoreLoad | #StoreStore\n" : "=&r" (old_count), "=&r" (tmp), "=m" (sem->count) : "r" (&sem->count), "r" (incr), "m" (sem->count) : "cc"); diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/sparc64/kernel/smp.c linux-2.5/arch/sparc64/kernel/smp.c --- linux-2.5.1/arch/sparc64/kernel/smp.c Wed Nov 21 18:31:09 2001 +++ linux-2.5/arch/sparc64/kernel/smp.c Thu Dec 13 16:32:35 2001 @@ -17,6 +17,7 @@ #include <linux/spinlock.h> #include <linux/fs.h> #include <linux/seq_file.h> +#include <linux/cache.h> #include <asm/head.h> #include <asm/ptrace.h> @@ -39,17 +40,17 @@ extern void calibrate_delay(void); extern unsigned prom_cpu_nodes[]; -struct cpuinfo_sparc cpu_data[NR_CPUS] __attribute__ ((aligned (64))); +cpuinfo_sparc cpu_data[NR_CPUS]; -volatile int __cpu_number_map[NR_CPUS] __attribute__ ((aligned (64))); -volatile int __cpu_logical_map[NR_CPUS] __attribute__ ((aligned (64))); +volatile int __cpu_number_map[NR_CPUS] __attribute__ ((aligned (SMP_CACHE_BYTES))); +volatile int __cpu_logical_map[NR_CPUS] __attribute__ ((aligned (SMP_CACHE_BYTES))); /* Please don't make this stuff initdata!!! --DaveM */ static unsigned char boot_cpu_id = 0; static int smp_activated = 0; /* Kernel spinlock */ -spinlock_t kernel_flag = SPIN_LOCK_UNLOCKED; +spinlock_t kernel_flag __cacheline_aligned_in_smp = SPIN_LOCK_UNLOCKED; volatile int smp_processors_ready = 0; unsigned long cpu_present_map = 0; @@ -137,6 +138,15 @@ { int cpuid = hard_smp_processor_id(); unsigned long pstate; + extern int bigkernel; + extern unsigned long kern_locked_tte_data; + + if (bigkernel) { + prom_dtlb_load(sparc64_highest_locked_tlbent()-1, + kern_locked_tte_data + 0x400000, KERNBASE + 0x400000); + prom_itlb_load(sparc64_highest_locked_tlbent()-1, + kern_locked_tte_data + 0x400000, KERNBASE + 0x400000); + } inherit_locked_prom_mappings(0); @@ -223,7 +233,6 @@ { trap_init(); init_IRQ(); - smp_callin(); return cpu_idle(); } @@ -276,7 +285,7 @@ init_tasks[cpucount] = p; p->processor = i; - p->cpus_runnable = 1 << i; /* we schedule the first task manually */ + p->cpus_runnable = 1UL << i; /* we schedule the first task manually */ del_from_runqueue(p); unhash_process(p); @@ -482,7 +491,7 @@ __asm__ __volatile__("wrpr %0, 0x0, %%pstate" : : "r" (pstate)); - if ((stuck & ~(0x5555555555555555UL)) == 0) { + if ((dispatch_stat & ~(0x5555555555555555UL)) == 0) { /* Busy bits will not clear, continue instead * of freezing up on this cpu. */ @@ -542,6 +551,9 @@ int wait; }; +static spinlock_t call_lock = SPIN_LOCK_UNLOCKED; +static struct call_data_struct *call_data; + extern unsigned long xcall_call_function; int smp_call_function(void (*func)(void *info), void *info, @@ -549,6 +561,7 @@ { struct call_data_struct data; int cpus = smp_num_cpus - 1; + long timeout; if (!cpus) return 0; @@ -558,19 +571,36 @@ atomic_set(&data.finished, 0); data.wait = wait; - smp_cross_call(&xcall_call_function, - 0, (u64) &data, 0); + spin_lock_bh(&call_lock); + + call_data = &data; + + smp_cross_call(&xcall_call_function, 0, 0, 0); + /* * Wait for other cpus to complete function or at * least snap the call data. */ - while (atomic_read(&data.finished) != cpus) + timeout = 1000000; + while (atomic_read(&data.finished) != cpus) { + if (--timeout <= 0) + goto out_timeout; barrier(); + udelay(1); + } + + spin_unlock_bh(&call_lock); + + return 0; +out_timeout: + spin_unlock_bh(&call_lock); + printk("XCALL: Remote cpus not responding, ncpus=%d finished=%d\n", + smp_num_cpus - 1, atomic_read(&data.finished)); return 0; } -void smp_call_function_client(struct call_data_struct *call_data) +void smp_call_function_client(void) { void (*func) (void *info) = call_data->func; void *info = call_data->info; @@ -597,7 +627,7 @@ extern unsigned long xcall_flush_dcache_page_cheetah; extern unsigned long xcall_flush_dcache_page_spitfire; -#ifdef DCFLUSH_DEBUG +#ifdef CONFIG_DEBUG_DCFLUSH extern atomic_t dcpage_flushes; extern atomic_t dcpage_flushes_xcall; #endif @@ -620,7 +650,7 @@ if (smp_processors_ready) { unsigned long mask = 1UL << cpu; -#ifdef DCFLUSH_DEBUG +#ifdef CONFIG_DEBUG_DCFLUSH atomic_inc(&dcpage_flushes); #endif if (cpu == smp_processor_id()) { @@ -642,7 +672,7 @@ __pa(page->virtual), 0, mask); } -#ifdef DCFLUSH_DEBUG +#ifdef CONFIG_DEBUG_DCFLUSH atomic_inc(&dcpage_flushes_xcall); #endif } diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/sparc64/kernel/sparc64_ksyms.c linux-2.5/arch/sparc64/kernel/sparc64_ksyms.c --- linux-2.5.1/arch/sparc64/kernel/sparc64_ksyms.c Tue Oct 30 23:08:11 2001 +++ linux-2.5/arch/sparc64/kernel/sparc64_ksyms.c Thu Dec 13 16:32:35 2001 @@ -1,4 +1,4 @@ -/* $Id: sparc64_ksyms.c,v 1.116 2001/10/26 15:49:21 davem Exp $ +/* $Id: sparc64_ksyms.c,v 1.119 2001/11/30 01:04:10 davem Exp $ * arch/sparc64/kernel/sparc64_ksyms.c: Sparc64 specific ksyms support. * * Copyright (C) 1996 David S. Miller (davem@caip.rutgers.edu) @@ -98,7 +98,7 @@ #ifdef CONFIG_SMP extern spinlock_t kernel_flag; extern int smp_num_cpus; -#ifdef SPIN_LOCK_DEBUG +#ifdef CONFIG_DEBUG_SPINLOCK extern void _do_spin_lock (spinlock_t *lock, char *str); extern void _do_spin_unlock (spinlock_t *lock); extern int _spin_trylock (spinlock_t *lock); @@ -113,7 +113,7 @@ /* used by various drivers */ #ifdef CONFIG_SMP -#ifndef SPIN_LOCK_DEBUG +#ifndef CONFIG_DEBUG_SPINLOCK /* Out of line rw-locking implementation. */ EXPORT_SYMBOL(__read_lock); EXPORT_SYMBOL(__read_unlock); @@ -145,7 +145,7 @@ EXPORT_SYMBOL(__cpu_logical_map); /* Spinlock debugging library, optional. */ -#ifdef SPIN_LOCK_DEBUG +#ifdef CONFIG_DEBUG_SPINLOCK EXPORT_SYMBOL(_do_spin_lock); EXPORT_SYMBOL(_do_spin_unlock); EXPORT_SYMBOL(_spin_trylock); @@ -319,7 +319,6 @@ EXPORT_SYMBOL(__memcpy); EXPORT_SYMBOL(__memset); EXPORT_SYMBOL(_clear_page); -EXPORT_SYMBOL(_copy_page); EXPORT_SYMBOL(clear_user_page); EXPORT_SYMBOL(copy_user_page); EXPORT_SYMBOL(__bzero); @@ -354,4 +353,8 @@ void VISenter(void); /* RAID code needs this */ -EXPORT_SYMBOL(VISenter); +EXPORT_SYMBOL_NOVERS(VISenter); + +#ifdef CONFIG_DEBUG_BUGVERBOSE +EXPORT_SYMBOL(do_BUG); +#endif diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/sparc64/kernel/sys_sparc.c linux-2.5/arch/sparc64/kernel/sys_sparc.c --- linux-2.5.1/arch/sparc64/kernel/sys_sparc.c Tue Oct 30 23:08:11 2001 +++ linux-2.5/arch/sparc64/kernel/sys_sparc.c Thu Dec 13 16:32:35 2001 @@ -1,4 +1,4 @@ -/* $Id: sys_sparc.c,v 1.54 2001/10/28 20:49:13 davem Exp $ +/* $Id: sys_sparc.c,v 1.55 2001/11/29 22:52:03 davem Exp $ * linux/arch/sparc64/kernel/sys_sparc.c * * This file contains various random system calls that @@ -255,27 +255,15 @@ asmlinkage int sparc64_personality(unsigned long personality) { - unsigned long ret, trying, orig_ret; + int ret; - trying = ret = personality; - - if (current->personality == PER_LINUX32 && - trying == PER_LINUX) - trying = ret = PER_LINUX32; - - /* For PER_LINUX32 we want to retain &default_exec_domain. */ - if (trying == PER_LINUX32) + if (current->personality == PER_LINUX32 && personality == PER_LINUX) + personality = PER_LINUX32; + ret = sys_personality(personality); + if (ret == PER_LINUX32) ret = PER_LINUX; - orig_ret = ret; - ret = sys_personality(ret); - - if (orig_ret == PER_LINUX && trying == PER_LINUX32) { - current->personality = PER_LINUX32; - ret = PER_LINUX; - } - - return (int) ret; + return ret; } /* Linux version of mmap */ diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/sparc64/kernel/time.c linux-2.5/arch/sparc64/kernel/time.c --- linux-2.5.1/arch/sparc64/kernel/time.c Thu Sep 20 21:11:57 2001 +++ linux-2.5/arch/sparc64/kernel/time.c Thu Dec 13 16:32:35 2001 @@ -1,4 +1,4 @@ -/* $Id: time.c,v 1.40 2001/09/06 02:44:28 davem Exp $ +/* $Id: time.c,v 1.41 2001/11/20 18:24:55 kanoj Exp $ * time.c: UltraSparc timer and TOD clock support. * * Copyright (C) 1997 David S. Miller (davem@caip.rutgers.edu) @@ -609,7 +609,6 @@ unsigned long clock; init_timers(timer_interrupt, &clock); - timer_tick_offset = clock / HZ; timer_ticks_per_usec_quotient = ((1UL<<32) / (clock / 1000020)); } diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/sparc64/kernel/trampoline.S linux-2.5/arch/sparc64/kernel/trampoline.S --- linux-2.5.1/arch/sparc64/kernel/trampoline.S Thu Sep 20 21:11:57 2001 +++ linux-2.5/arch/sparc64/kernel/trampoline.S Thu Dec 13 16:32:35 2001 @@ -1,4 +1,4 @@ -/* $Id: trampoline.S,v 1.22 2001/09/07 21:04:40 kanoj Exp $ +/* $Id: trampoline.S,v 1.24 2001/11/16 21:59:20 davem Exp $ * trampoline.S: Jump start slave processors on sparc64. * * Copyright (C) 1997 David S. Miller (davem@caip.rutgers.edu) diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/sparc64/kernel/traps.c linux-2.5/arch/sparc64/kernel/traps.c --- linux-2.5.1/arch/sparc64/kernel/traps.c Mon Oct 1 16:19:56 2001 +++ linux-2.5/arch/sparc64/kernel/traps.c Thu Dec 13 16:32:35 2001 @@ -1,4 +1,4 @@ -/* $Id: traps.c,v 1.79 2001/09/21 02:14:39 kanoj Exp $ +/* $Id: traps.c,v 1.82 2001/11/18 00:12:56 davem Exp $ * arch/sparc64/kernel/traps.c * * Copyright (C) 1995,1997 David S. Miller (davem@caip.rutgers.edu) @@ -38,16 +38,19 @@ void bad_trap (struct pt_regs *regs, long lvl) { + char buffer[32]; siginfo_t info; if (lvl < 0x100) { - char buffer[24]; - - sprintf (buffer, "Bad hw trap %lx at tl0\n", lvl); + sprintf(buffer, "Bad hw trap %lx at tl0\n", lvl); + die_if_kernel(buffer, regs); + } + + lvl -= 0x100; + if (regs->tstate & TSTATE_PRIV) { + sprintf(buffer, "Kernel bad sw trap %lx", lvl); die_if_kernel (buffer, regs); } - if (regs->tstate & TSTATE_PRIV) - die_if_kernel ("Kernel bad trap", regs); if ((current->thread.flags & SPARC_FLAG_32BIT) != 0) { regs->tpc &= 0xffffffff; regs->tnpc &= 0xffffffff; @@ -56,7 +59,7 @@ info.si_errno = 0; info.si_code = ILL_ILLTRP; info.si_addr = (void *)regs->tpc; - info.si_trapno = lvl - 0x100; + info.si_trapno = lvl; force_sig_info(SIGILL, &info, current); } @@ -68,6 +71,14 @@ die_if_kernel (buffer, regs); } +#ifdef CONFIG_DEBUG_BUGVERBOSE +void do_BUG(const char *file, int line) +{ + bust_spinlocks(1); + printk("kernel BUG at %s:%d!\n", file, line); +} +#endif + void instruction_access_exception (struct pt_regs *regs, unsigned long sfsr, unsigned long sfar) { @@ -947,6 +958,7 @@ __asm__ __volatile__("ldxa [%0] %3, %%g0\n\t" "ldxa [%1] %3, %%g0\n\t" "casxa [%2] %3, %%g0, %%g0\n\t" + "membar #StoreLoad | #StoreStore\n\t" "ldxa [%0] %3, %%g0\n\t" "ldxa [%1] %3, %%g0\n\t" "membar #Sync" diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/sparc64/kernel/ttable.S linux-2.5/arch/sparc64/kernel/ttable.S --- linux-2.5.1/arch/sparc64/kernel/ttable.S Mon Oct 1 16:19:56 2001 +++ linux-2.5/arch/sparc64/kernel/ttable.S Thu Dec 13 16:32:35 2001 @@ -1,4 +1,4 @@ -/* $Id: ttable.S,v 1.35 2001/09/21 02:14:39 kanoj Exp $ +/* $Id: ttable.S,v 1.36 2001/11/28 23:32:16 davem Exp $ * ttable.S: Sparc V9 Trap Table(s) with SpitFire/Cheetah extensions. * * Copyright (C) 1996, 2001 David S. Miller (davem@caip.rutgers.edu) @@ -15,11 +15,13 @@ sparc64_ttable_tl0: tl0_resv000: BOOT_KERNEL BTRAP(0x1) BTRAP(0x2) BTRAP(0x3) tl0_resv004: BTRAP(0x4) BTRAP(0x5) BTRAP(0x6) BTRAP(0x7) -tl0_iax: TRAP_NOSAVE(__do_instruction_access_exception) +tl0_iax: membar #Sync + TRAP_NOSAVE_7INSNS(__do_instruction_access_exception) tl0_resv009: BTRAP(0x9) tl0_iae: TRAP(do_iae) tl0_resv00b: BTRAP(0xb) BTRAP(0xc) BTRAP(0xd) BTRAP(0xe) BTRAP(0xf) -tl0_ill: TRAP(do_illegal_instruction) +tl0_ill: membar #Sync + TRAP_7INSNS(do_illegal_instruction) tl0_privop: TRAP(do_privop) tl0_resv012: BTRAP(0x12) BTRAP(0x13) BTRAP(0x14) BTRAP(0x15) BTRAP(0x16) BTRAP(0x17) tl0_resv018: BTRAP(0x18) BTRAP(0x19) BTRAP(0x1a) BTRAP(0x1b) BTRAP(0x1c) BTRAP(0x1d) diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/sparc64/lib/atomic.S linux-2.5/arch/sparc64/lib/atomic.S --- linux-2.5.1/arch/sparc64/lib/atomic.S Thu Mar 16 19:40:17 2000 +++ linux-2.5/arch/sparc64/lib/atomic.S Thu Dec 13 16:32:35 2001 @@ -1,4 +1,4 @@ -/* $Id: atomic.S,v 1.3 2000/03/16 16:44:37 davem Exp $ +/* $Id: atomic.S,v 1.4 2001/11/18 00:12:56 davem Exp $ * atomic.S: These things are too big to do inline. * * Copyright (C) 1999 David S. Miller (davem@redhat.com) @@ -19,7 +19,7 @@ cas [%o1], %g5, %g7 cmp %g5, %g7 bne,pn %icc, __atomic_add - nop + membar #StoreLoad | #StoreStore retl add %g7, %o0, %o0 @@ -30,7 +30,7 @@ cas [%o1], %g5, %g7 cmp %g5, %g7 bne,pn %icc, __atomic_sub - nop + membar #StoreLoad | #StoreStore retl sub %g7, %o0, %o0 atomic_impl_end: diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/sparc64/lib/bitops.S linux-2.5/arch/sparc64/lib/bitops.S --- linux-2.5.1/arch/sparc64/lib/bitops.S Sat Apr 14 03:15:55 2001 +++ linux-2.5/arch/sparc64/lib/bitops.S Thu Dec 13 16:32:35 2001 @@ -1,4 +1,4 @@ -/* $Id: bitops.S,v 1.2 2001/04/14 01:12:02 davem Exp $ +/* $Id: bitops.S,v 1.3 2001/11/18 00:12:56 davem Exp $ * bitops.S: Sparc64 atomic bit operations. * * Copyright (C) 2000 David S. Miller (davem@redhat.com) @@ -28,7 +28,7 @@ bne,a,pn %xcc, 1b ldx [%o1], %g7 2: retl - nop + membar #StoreLoad | #StoreStore .globl ___test_and_clear_bit ___test_and_clear_bit: /* %o0=nr, %o1=addr */ @@ -47,7 +47,7 @@ bne,a,pn %xcc, 1b ldx [%o1], %g7 2: retl - nop + membar #StoreLoad | #StoreStore .globl ___test_and_change_bit ___test_and_change_bit: /* %o0=nr, %o1=addr */ @@ -65,7 +65,7 @@ bne,a,pn %xcc, 1b ldx [%o1], %g7 2: retl - nop + membar #StoreLoad | #StoreStore nop .globl ___test_and_set_le_bit @@ -85,7 +85,7 @@ bne,a,pn %icc, 1b lduwa [%o1] ASI_PL, %g7 2: retl - nop + membar #StoreLoad | #StoreStore .globl ___test_and_clear_le_bit ___test_and_clear_le_bit: /* %o0=nr, %o1=addr */ @@ -104,7 +104,7 @@ bne,a,pn %icc, 1b lduwa [%o1] ASI_PL, %g7 2: retl - nop + membar #StoreLoad | #StoreStore .globl __bitops_end __bitops_end: diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/sparc64/lib/blockops.S linux-2.5/arch/sparc64/lib/blockops.S --- linux-2.5.1/arch/sparc64/lib/blockops.S Mon Oct 1 16:19:56 2001 +++ linux-2.5/arch/sparc64/lib/blockops.S Thu Dec 13 16:32:35 2001 @@ -1,4 +1,4 @@ -/* $Id: blockops.S,v 1.36 2001/09/24 21:44:03 davem Exp $ +/* $Id: blockops.S,v 1.41 2001/12/05 06:05:35 davem Exp $ * blockops.S: UltraSparc block zero optimized routines. * * Copyright (C) 1996, 1998, 1999, 2000 David S. Miller (davem@redhat.com) @@ -17,10 +17,9 @@ fmovd %reg4, %f56; fmovd %reg5, %f58; \ fmovd %reg6, %f60; fmovd %reg7, %f62; -#define TLBTEMP_BASE (8 * 1024 * 1024) #define DCACHE_SIZE (PAGE_SIZE * 2) -#define TLBTEMP_ENT1 (61 << 3) -#define TLBTEMP_ENT2 (62 << 3) +#define TLBTEMP_ENT1 (60 << 3) +#define TLBTEMP_ENT2 (61 << 3) #define TLBTEMP_ENTSZ (1 << 3) #if (PAGE_SHIFT == 13) || (PAGE_SHIFT == 19) @@ -34,64 +33,6 @@ .text .align 32 - .globl _copy_page - .type _copy_page,@function -_copy_page: /* %o0=dest, %o1=src */ - VISEntry - membar #LoadStore | #StoreStore | #StoreLoad - ldda [%o1] ASI_BLK_P, %f0 - add %o1, 0x40, %o1 - ldda [%o1] ASI_BLK_P, %f16 - add %o1, 0x40, %o1 - sethi %hi(PAGE_SIZE), %o2 -1: TOUCH(f0, f2, f4, f6, f8, f10, f12, f14) - ldda [%o1] ASI_BLK_P, %f32 - stda %f48, [%o0] ASI_BLK_P - add %o1, 0x40, %o1 - sub %o2, 0x40, %o2 - add %o0, 0x40, %o0 - TOUCH(f16, f18, f20, f22, f24, f26, f28, f30) - ldda [%o1] ASI_BLK_P, %f0 - stda %f48, [%o0] ASI_BLK_P - add %o1, 0x40, %o1 - sub %o2, 0x40, %o2 - add %o0, 0x40, %o0 - TOUCH(f32, f34, f36, f38, f40, f42, f44, f46) - ldda [%o1] ASI_BLK_P, %f16 - stda %f48, [%o0] ASI_BLK_P - sub %o2, 0x40, %o2 - add %o1, 0x40, %o1 - cmp %o2, PAGE_SIZE_REM - bne,pt %xcc, 1b - add %o0, 0x40, %o0 -#if (PAGE_SHIFT == 16) || (PAGE_SHIFT == 22) - TOUCH(f0, f2, f4, f6, f8, f10, f12, f14) - ldda [%o1] ASI_BLK_P, %f32 - stda %f48, [%o0] ASI_BLK_P - add %o1, 0x40, %o1 - sub %o2, 0x40, %o2 - add %o0, 0x40, %o0 - TOUCH(f16, f18, f20, f22, f24, f26, f28, f30) - ldda [%o1] ASI_BLK_P, %f0 - stda %f48, [%o0] ASI_BLK_P - add %o1, 0x40, %o1 - sub %o2, 0x40, %o2 - add %o0, 0x40, %o0 - membar #Sync - stda %f32, [%o0] ASI_BLK_P - add %o0, 0x40, %o0 - stda %f0, [%o0] ASI_BLK_P -#else - membar #Sync - stda %f0, [%o0] ASI_BLK_P - add %o0, 0x40, %o0 - stda %f16, [%o0] ASI_BLK_P -#endif - membar #Sync - VISExit - retl - nop - .globl copy_user_page .type copy_user_page,@function copy_user_page: /* %o0=dest, %o1=src, %o2=vaddr */ @@ -110,7 +51,7 @@ or %g2, %g3, %g2 add %o0, %o3, %o0 add %o0, %o1, %o1 -#define FIX_INSN_1 0x96102068 /* mov (13 << 3), %o3 */ +#define FIX_INSN_1 0x96102060 /* mov (12 << 3), %o3 */ cheetah_patch_1: mov TLBTEMP_ENT1, %o3 rdpr %pstate, %g3 @@ -134,6 +75,7 @@ stxa %g0, [%o5] ASI_DMMU membar #Sync + ldxa [%o3] ASI_DTLB_DATA_ACCESS, %g0 ldxa [%o3] ASI_DTLB_DATA_ACCESS, %o5 stxa %o0, [%o2] ASI_DMMU stxa %g1, [%o3] ASI_DTLB_DATA_ACCESS @@ -152,6 +94,7 @@ stxa %g0, [%g7] ASI_DMMU membar #Sync + ldxa [%o3] ASI_DTLB_DATA_ACCESS, %g0 ldxa [%o3] ASI_DTLB_DATA_ACCESS, %g7 stxa %o1, [%o2] ASI_DMMU stxa %g2, [%o3] ASI_DTLB_DATA_ACCESS @@ -169,9 +112,10 @@ nop cheetah_copy_user_page: - mov 121, %o2 ! A0 Group + sethi %hi((PAGE_SIZE/64)-7), %o2 ! A0 Group prefetch [%o1 + 0x000], #one_read ! MS - prefetch [%o1 + 0x040], #one_read ! MS Group + or %o2, %lo((PAGE_SIZE/64)-7), %o2 ! A1 Group + prefetch [%o1 + 0x040], #one_read ! MS prefetch [%o1 + 0x080], #one_read ! MS Group prefetch [%o1 + 0x0c0], #one_read ! MS Group ldd [%o1 + 0x000], %f0 ! MS Group @@ -402,7 +346,7 @@ or %g3, (_PAGE_CP | _PAGE_CV | _PAGE_P | _PAGE_L | _PAGE_W), %g3 or %g1, %g3, %g1 add %o0, %o3, %o0 -#define FIX_INSN_2 0x96102070 /* mov (14 << 3), %o3 */ +#define FIX_INSN_2 0x96102068 /* mov (13 << 3), %o3 */ cheetah_patch_2: mov TLBTEMP_ENT2, %o3 rdpr %pstate, %g3 @@ -420,6 +364,7 @@ stxa %g0, [%g7] ASI_DMMU membar #Sync + ldxa [%o3] ASI_DTLB_DATA_ACCESS, %g0 ldxa [%o3] ASI_DTLB_DATA_ACCESS, %g7 stxa %o0, [%o2] ASI_DMMU stxa %g1, [%o3] ASI_DTLB_DATA_ACCESS @@ -430,8 +375,9 @@ clear_page_common: membar #StoreLoad | #StoreStore | #LoadStore ! LSU Group fzero %f0 ! FPA Group - mov PAGE_SIZE/256, %o1 ! IEU0 + sethi %hi(PAGE_SIZE/256), %o1 ! IEU0 fzero %f2 ! FPA Group + or %o1, %lo(PAGE_SIZE/256), %o1 ! IEU0 faddd %f0, %f2, %f4 ! FPA Group fmuld %f0, %f2, %f6 ! FPM faddd %f0, %f2, %f8 ! FPA Group diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/sparc64/lib/debuglocks.c linux-2.5/arch/sparc64/lib/debuglocks.c --- linux-2.5.1/arch/sparc64/lib/debuglocks.c Fri Apr 27 05:17:25 2001 +++ linux-2.5/arch/sparc64/lib/debuglocks.c Thu Dec 13 16:32:35 2001 @@ -1,4 +1,4 @@ -/* $Id: debuglocks.c,v 1.6 2001/04/24 01:09:12 davem Exp $ +/* $Id: debuglocks.c,v 1.9 2001/11/17 00:10:48 davem Exp $ * debuglocks.c: Debugging versions of SMP locking primitives. * * Copyright (C) 1998 David S. Miller (davem@redhat.com) @@ -10,10 +10,7 @@ #include <linux/spinlock.h> #include <asm/system.h> -#ifdef CONFIG_SMP - -/* To enable this code, just define SPIN_LOCK_DEBUG in asm/spinlock.h */ -#ifdef SPIN_LOCK_DEBUG +#if defined(CONFIG_SMP) && defined(CONFIG_DEBUG_SPINLOCK) #define GET_CALLER(PC) __asm__ __volatile__("mov %%i7, %0" : "=r" (PC)) @@ -56,6 +53,7 @@ unsigned long caller, val; int stuck = INIT_STUCK; int cpu = smp_processor_id(); + int shown = 0; GET_CALLER(caller); again: @@ -67,7 +65,8 @@ if (val) { while (lock->lock) { if (!--stuck) { - show(str, lock, caller); + if (shown++ <= 2) + show(str, lock, caller); stuck = INIT_STUCK; } membar("#LoadLoad"); @@ -76,6 +75,8 @@ } lock->owner_pc = ((unsigned int)caller); lock->owner_cpu = cpu; + current->thread.smp_lock_count++; + current->thread.smp_lock_pc = ((unsigned int)caller); } int _spin_trylock(spinlock_t *lock) @@ -92,6 +93,8 @@ if (!val) { lock->owner_pc = ((unsigned int)caller); lock->owner_cpu = cpu; + current->thread.smp_lock_count++; + current->thread.smp_lock_pc = ((unsigned int)caller); } return val == 0; } @@ -102,6 +105,7 @@ lock->owner_cpu = NO_PROC_ID; membar("#StoreStore | #LoadStore"); lock->lock = 0; + current->thread.smp_lock_count--; } /* Keep INIT_STUCK the same... */ @@ -111,13 +115,15 @@ unsigned long caller, val; int stuck = INIT_STUCK; int cpu = smp_processor_id(); + int shown = 0; GET_CALLER(caller); wlock_again: /* Wait for any writer to go away. */ while (((long)(rw->lock)) < 0) { if (!--stuck) { - show_read(str, rw, caller); + if (shown++ <= 2) + show_read(str, rw, caller); stuck = INIT_STUCK; } membar("#LoadLoad"); @@ -137,6 +143,8 @@ if (val) goto wlock_again; rw->reader_pc[cpu] = ((unsigned int)caller); + current->thread.smp_lock_count++; + current->thread.smp_lock_pc = ((unsigned int)caller); } void _do_read_unlock (rwlock_t *rw, char *str) @@ -144,11 +152,13 @@ unsigned long caller, val; int stuck = INIT_STUCK; int cpu = smp_processor_id(); + int shown = 0; GET_CALLER(caller); /* Drop our identity _first_. */ rw->reader_pc[cpu] = 0; + current->thread.smp_lock_count--; runlock_again: /* Spin trying to decrement the counter using casx. */ __asm__ __volatile__( @@ -162,7 +172,8 @@ : "g5", "g7", "memory"); if (val) { if (!--stuck) { - show_read(str, rw, caller); + if (shown++ <= 2) + show_read(str, rw, caller); stuck = INIT_STUCK; } goto runlock_again; @@ -174,13 +185,15 @@ unsigned long caller, val; int stuck = INIT_STUCK; int cpu = smp_processor_id(); + int shown = 0; GET_CALLER(caller); wlock_again: /* Spin while there is another writer. */ while (((long)rw->lock) < 0) { if (!--stuck) { - show_write(str, rw, caller); + if (shown++ <= 2) + show_write(str, rw, caller); stuck = INIT_STUCK; } membar("#LoadLoad"); @@ -204,7 +217,8 @@ if (val) { /* We couldn't get the write bit. */ if (!--stuck) { - show_write(str, rw, caller); + if (shown++ <= 2) + show_write(str, rw, caller); stuck = INIT_STUCK; } goto wlock_again; @@ -214,7 +228,8 @@ * lock, spin, and try again. */ if (!--stuck) { - show_write(str, rw, caller); + if (shown++ <= 2) + show_write(str, rw, caller); stuck = INIT_STUCK; } __asm__ __volatile__( @@ -231,7 +246,8 @@ : "g3", "g5", "g7", "cc", "memory"); while(rw->lock != 0) { if (!--stuck) { - show_write(str, rw, caller); + if (shown++ <= 2) + show_write(str, rw, caller); stuck = INIT_STUCK; } membar("#LoadLoad"); @@ -242,18 +258,22 @@ /* We have it, say who we are. */ rw->writer_pc = ((unsigned int)caller); rw->writer_cpu = cpu; + current->thread.smp_lock_count++; + current->thread.smp_lock_pc = ((unsigned int)caller); } void _do_write_unlock(rwlock_t *rw) { unsigned long caller, val; int stuck = INIT_STUCK; + int shown = 0; GET_CALLER(caller); /* Drop our identity _first_ */ rw->writer_pc = 0; rw->writer_cpu = NO_PROC_ID; + current->thread.smp_lock_count--; wlock_again: __asm__ __volatile__( " mov 1, %%g3\n" @@ -268,12 +288,21 @@ : "g3", "g5", "g7", "memory"); if (val) { if (!--stuck) { - show_write("write_unlock", rw, caller); + if (shown++ <= 2) + show_write("write_unlock", rw, caller); stuck = INIT_STUCK; } goto wlock_again; } } -#endif /* SPIN_LOCK_DEBUG */ -#endif /* CONFIG_SMP */ +int atomic_dec_and_lock(atomic_t *atomic, spinlock_t *lock) +{ + spin_lock(lock); + if (atomic_dec_and_test(atomic)) + return 1; + spin_unlock(lock); + return 0; +} + +#endif /* CONFIG_SMP && CONFIG_DEBUG_SPINLOCK */ diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/sparc64/lib/dec_and_lock.S linux-2.5/arch/sparc64/lib/dec_and_lock.S --- linux-2.5.1/arch/sparc64/lib/dec_and_lock.S Sun Aug 13 19:01:54 2000 +++ linux-2.5/arch/sparc64/lib/dec_and_lock.S Thu Dec 13 16:32:35 2001 @@ -1,10 +1,12 @@ -/* $Id: dec_and_lock.S,v 1.2 2000/08/13 18:24:12 davem Exp $ +/* $Id: dec_and_lock.S,v 1.5 2001/11/18 00:12:56 davem Exp $ * dec_and_lock.S: Sparc64 version of "atomic_dec_and_lock()" * using cas and ldstub instructions. * * Copyright (C) 2000 David S. Miller (davem@redhat.com) */ +#include <linux/config.h> +#ifndef CONFIG_DEBUG_SPINLOCK .text .align 64 @@ -34,13 +36,15 @@ bne,pn %icc, loop1 mov 0, %g1 -out: retl +out: + membar #StoreLoad | #StoreStore + retl mov %g1, %o0 -to_zero:ldstub [%o1], %g3 +to_zero: + ldstub [%o1], %g3 brnz,pn %g3, spin_on_lock membar #StoreLoad | #StoreStore loop2: cas [%o0], %g5, %g7 /* ASSERT(g7 == 0) */ - nop cmp %g5, %g7 be,pt %icc, out @@ -61,3 +65,5 @@ ba,pt %xcc, to_zero nop nop + +#endif /* !(CONFIG_DEBUG_SPINLOCK) */ diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/sparc64/mm/extable.c linux-2.5/arch/sparc64/mm/extable.c --- linux-2.5.1/arch/sparc64/mm/extable.c Tue Aug 7 15:30:50 2001 +++ linux-2.5/arch/sparc64/mm/extable.c Thu Dec 13 16:32:35 2001 @@ -11,35 +11,49 @@ static unsigned long search_one_table(const struct exception_table_entry *start, - const struct exception_table_entry *last, + const struct exception_table_entry *end, unsigned long value, unsigned long *g2) { - const struct exception_table_entry *first = start; - const struct exception_table_entry *mid; - long diff = 0; - while (first <= last) { - mid = (last - first) / 2 + first; - diff = mid->insn - value; - if (diff == 0) { - if (!mid->fixup) { - *g2 = 0; - return (mid + 1)->fixup; - } else - return mid->fixup; - } else if (diff < 0) - first = mid+1; - else - last = mid-1; - } - if (last->insn < value && !last->fixup && last[1].insn > value) { - *g2 = (value - last->insn)/4; - return last[1].fixup; - } - if (first > start && first[-1].insn < value - && !first[-1].fixup && first->insn < value) { - *g2 = (value - first[-1].insn)/4; - return first->fixup; - } + const struct exception_table_entry *walk; + + /* Single insn entries are encoded as: + * word 1: insn address + * word 2: fixup code address + * + * Range entries are encoded as: + * word 1: first insn address + * word 2: 0 + * word 3: last insn address + 4 bytes + * word 4: fixup code address + * + * See asm/uaccess.h for more details. + */ + + /* 1. Try to find an exact match. */ + for (walk = start; walk <= end; walk++) { + if (walk->fixup == 0) { + /* A range entry, skip both parts. */ + walk++; + continue; + } + + if (walk->insn == value) + return walk->fixup; + } + + /* 2. Try to find a range match. */ + for (walk = start; walk <= (end - 1); walk++) { + if (walk->fixup) + continue; + + if (walk[0].insn <= value && + walk[1].insn > value) { + *g2 = (value - walk[0].insn) / 4; + return walk[1].fixup; + } + walk++; + } + return 0; } diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/sparc64/mm/init.c linux-2.5/arch/sparc64/mm/init.c --- linux-2.5.1/arch/sparc64/mm/init.c Tue Nov 13 17:16:05 2001 +++ linux-2.5/arch/sparc64/mm/init.c Thu Dec 13 16:32:35 2001 @@ -1,4 +1,4 @@ -/* $Id: init.c,v 1.202 2001/11/13 00:49:28 davem Exp $ +/* $Id: init.c,v 1.207 2001/11/30 06:55:39 davem Exp $ * arch/sparc64/mm/init.c * * Copyright (C) 1996-1999 David S. Miller (davem@caip.rutgers.edu) @@ -63,6 +63,8 @@ struct page *mem_map_zero; +int bigkernel = 0; + int do_check_pgt_cache(int low, int high) { int freed = 0; @@ -111,7 +113,7 @@ extern void __update_mmu_cache(struct vm_area_struct *, unsigned long, pte_t); -#ifdef DCFLUSH_DEBUG +#ifdef CONFIG_DEBUG_DCFLUSH atomic_t dcpage_flushes = ATOMIC_INIT(0); #ifdef CONFIG_SMP atomic_t dcpage_flushes_xcall = ATOMIC_INIT(0); @@ -120,7 +122,7 @@ __inline__ void flush_dcache_page_impl(struct page *page) { -#ifdef DCFLUSH_DEBUG +#ifdef CONFIG_DEBUG_DCFLUSH atomic_inc(&dcpage_flushes); #endif @@ -152,7 +154,7 @@ "casx [%2], %%g7, %%g5\n\t" "cmp %%g7, %%g5\n\t" "bne,pn %%xcc, 1b\n\t" - " nop" + " membar #StoreLoad | #StoreStore" : /* no outputs */ : "r" (mask), "r" (non_cpu_bits), "r" (&page->flags) : "g5", "g7"); @@ -172,7 +174,7 @@ "casx [%2], %%g7, %%g5\n\t" "cmp %%g7, %%g5\n\t" "bne,pn %%xcc, 1b\n\t" - " nop\n" + " membar #StoreLoad | #StoreStore\n" "2:" : /* no outputs */ : "r" (cpu), "r" (mask), "r" (&page->flags) @@ -261,14 +263,14 @@ else seq_printf(m, "MMU Type\t: ???\n"); -#ifdef DCFLUSH_DEBUG +#ifdef CONFIG_DEBUG_DCFLUSH seq_printf(m, "DCPageFlushes\t: %d\n", atomic_read(&dcpage_flushes)); #ifdef CONFIG_SMP seq_printf(m, "DCPageFlushesXC\t: %d\n", atomic_read(&dcpage_flushes_xcall)); #endif /* CONFIG_SMP */ -#endif /* DCFLUSH_DEBUG */ +#endif /* CONFIG_DEBUG_DCFLUSH */ } struct linux_prom_translation { @@ -505,6 +507,10 @@ (unsigned long) KERNBASE, prom_get_mmu_ihandle()); + if (bigkernel) + remap_func(((tte_data + 0x400000) & _PAGE_PADDR), + (unsigned long) KERNBASE + 0x400000, prom_get_mmu_ihandle()); + /* Flush out that temporary mapping. */ spitfire_flush_dtlb_nucleus_page(0x0); spitfire_flush_itlb_nucleus_page(0x0); @@ -512,6 +518,12 @@ /* Now lock us back into the TLBs via OBP. */ prom_dtlb_load(sparc64_highest_locked_tlbent(), tte_data, tte_vaddr); prom_itlb_load(sparc64_highest_locked_tlbent(), tte_data, tte_vaddr); + if (bigkernel) { + prom_dtlb_load(sparc64_highest_locked_tlbent()-1, tte_data + 0x400000, + tte_vaddr + 0x400000); + prom_itlb_load(sparc64_highest_locked_tlbent()-1, tte_data + 0x400000, + tte_vaddr + 0x400000); + } /* Re-read translations property. */ if ((n = prom_getproperty(node, "translations", (char *)trans, tsz)) == -1) { @@ -528,6 +540,8 @@ unsigned long avoid_start = (unsigned long) KERNBASE; unsigned long avoid_end = avoid_start + (4 * 1024 * 1024); + if (bigkernel) + avoid_end += (4 * 1024 * 1024); if (vaddr < avoid_start) { unsigned long top = vaddr + size; @@ -714,7 +728,8 @@ } } if (tlb_type == spitfire) { - for (i = 0; i < SPITFIRE_HIGHEST_LOCKED_TLBENT; i++) { + int high = SPITFIRE_HIGHEST_LOCKED_TLBENT - bigkernel; + for (i = 0; i < high; i++) { unsigned long data; /* Spitfire Errata #32 workaround */ @@ -752,7 +767,7 @@ } } - for (i = 0; i < SPITFIRE_HIGHEST_LOCKED_TLBENT; i++) { + for (i = 0; i < high; i++) { unsigned long data; /* Spitfire Errata #32 workaround */ @@ -790,7 +805,9 @@ } } } else if (tlb_type == cheetah) { - for (i = 0; i < CHEETAH_HIGHEST_LOCKED_TLBENT; i++) { + int high = CHEETAH_HIGHEST_LOCKED_TLBENT - bigkernel; + + for (i = 0; i < high; i++) { unsigned long data; data = cheetah_get_ldtlb_data(i); @@ -814,7 +831,7 @@ } } - for (i = 0; i < CHEETAH_HIGHEST_LOCKED_TLBENT; i++) { + for (i = 0; i < high; i++) { unsigned long data; data = cheetah_get_litlb_data(i); @@ -1282,6 +1299,8 @@ set_bit(0, mmu_context_bmap); real_end = (unsigned long)&_end; + if ((real_end > ((unsigned long)KERNBASE + 0x400000))) + bigkernel = 1; #ifdef CONFIG_BLK_DEV_INITRD if (sparc_ramdisk_image) real_end = (PAGE_ALIGN(real_end) + PAGE_ALIGN(sparc_ramdisk_size)); diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/sparc64/mm/modutil.c linux-2.5/arch/sparc64/mm/modutil.c --- linux-2.5.1/arch/sparc64/mm/modutil.c Tue Aug 28 14:09:44 2001 +++ linux-2.5/arch/sparc64/mm/modutil.c Thu Dec 13 16:32:35 2001 @@ -1,4 +1,4 @@ -/* $Id: modutil.c,v 1.9 2001/08/14 22:10:56 davem Exp $ +/* $Id: modutil.c,v 1.11 2001/12/05 06:05:35 davem Exp $ * arch/sparc64/mm/modutil.c * * Copyright (C) 1997,1998 Jakub Jelinek (jj@sunsite.mff.cuni.cz) @@ -10,10 +10,6 @@ #include <asm/uaccess.h> #include <asm/system.h> - -#define MODULES_VADDR 0x0000000001000000ULL /* Where to map modules */ -#define MODULES_LEN 0x000000007f000000ULL -#define MODULES_END 0x0000000080000000ULL static struct vm_struct * modvmlist = NULL; diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/arch/sparc64/mm/ultra.S linux-2.5/arch/sparc64/mm/ultra.S --- linux-2.5.1/arch/sparc64/mm/ultra.S Tue Nov 13 17:16:05 2001 +++ linux-2.5/arch/sparc64/mm/ultra.S Thu Dec 13 16:32:35 2001 @@ -1,4 +1,4 @@ -/* $Id: ultra.S,v 1.68 2001/11/09 14:59:19 davem Exp $ +/* $Id: ultra.S,v 1.70 2001/11/29 16:42:10 kanoj Exp $ * ultra.S: Don't expand these all over the place... * * Copyright (C) 1997, 2000 David S. Miller (davem@redhat.com) @@ -117,7 +117,7 @@ wrpr %g1, PSTATE_IE, %pstate mov TLB_TAG_ACCESS, %g3 /* XXX Spitfire dependency... */ - mov (62 << 3), %g2 + mov ((SPITFIRE_HIGHEST_LOCKED_TLBENT-1) << 3), %g2 /* Spitfire Errata #32 workaround. */ mov 0x8, %o4 @@ -642,7 +642,7 @@ stx %g0, [%g4 + %lo(errata32_hwbug)] 2: add %g2, 1, %g2 - cmp %g2, 63 + cmp %g2, SPITFIRE_HIGHEST_LOCKED_TLBENT ble,pt %icc, 1b sll %g2, 3, %g3 flush %g6 @@ -679,20 +679,15 @@ .globl xcall_call_function xcall_call_function: - mov TLB_TAG_ACCESS, %g5 ! wheee... - stxa %g1, [%g5] ASI_IMMU ! save call_data here for a bit - membar #Sync rdpr %pstate, %g2 wrpr %g2, PSTATE_IG | PSTATE_AG, %pstate - mov TLB_TAG_ACCESS, %g2 - ldxa [%g2] ASI_IMMU, %g5 rdpr %pil, %g2 wrpr %g0, 15, %pil sethi %hi(109f), %g7 b,pt %xcc, etrap_irq 109: or %g7, %lo(109b), %g7 call smp_call_function_client - mov %l5, %o0 + nop b,pt %xcc, rtrap clr %l6 diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/acorn/scsi/acornscsi.c linux-2.5/drivers/acorn/scsi/acornscsi.c --- linux-2.5.1/drivers/acorn/scsi/acornscsi.c Thu Oct 11 16:04:57 2001 +++ linux-2.5/drivers/acorn/scsi/acornscsi.c Thu Dec 27 22:10:28 2001 @@ -3142,18 +3142,17 @@ static int __init acornscsi_init(void) { - acornscsi_template.module = THIS_MODULE; - scsi_register_module(MODULE_SCSI_HA, &acornscsi_template); + scsi_register_host(&acornscsi_template); if (acornscsi_template.present) return 0; - scsi_unregister_module(MODULE_SCSI_HA, &acornscsi_template); + scsi_unregister_host(&acornscsi_template); return -ENODEV; } static void __exit acornscsi_exit(void) { - scsi_unregister_module(MODULE_SCSI_HA, &acornscsi_template); + scsi_unregister_host(&acornscsi_template); } module_init(acornscsi_init); diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/acorn/scsi/arxescsi.c linux-2.5/drivers/acorn/scsi/arxescsi.c --- linux-2.5.1/drivers/acorn/scsi/arxescsi.c Thu Oct 11 16:04:57 2001 +++ linux-2.5/drivers/acorn/scsi/arxescsi.c Thu Dec 27 22:10:28 2001 @@ -423,17 +423,17 @@ static int __init init_arxe_scsi_driver(void) { arxescsi_template.module = THIS_MODULE; - scsi_register_module(MODULE_SCSI_HA, &arxescsi_template); + scsi_register_host(&arxescsi_template); if (arxescsi_template.present) return 0; - scsi_unregister_module(MODULE_SCSI_HA, &arxescsi_template); + scsi_unregister_host(&arxescsi_template); return -ENODEV; } static void __exit exit_arxe_scsi_driver(void) { - scsi_unregister_module(MODULE_SCSI_HA, &arxescsi_template); + scsi_unregister_host(&arxescsi_template); } module_init(init_arxe_scsi_driver); diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/acorn/scsi/cumana_1.c linux-2.5/drivers/acorn/scsi/cumana_1.c --- linux-2.5.1/drivers/acorn/scsi/cumana_1.c Thu Sep 13 22:21:32 2001 +++ linux-2.5/drivers/acorn/scsi/cumana_1.c Thu Dec 27 22:10:28 2001 @@ -409,17 +409,17 @@ static int __init cumanascsi_init(void) { - scsi_register_module(MODULE_SCSI_HA, &cumanascsi_template); + scsi_register_host(&cumanascsi_template); if (cumanascsi_template.present) return 0; - scsi_unregister_module(MODULE_SCSI_HA, &cumanascsi_template); + scsi_unregister_host(&cumanascsi_template); return -ENODEV; } static void __exit cumanascsi_exit(void) { - scsi_unregister_module(MODULE_SCSI_HA, &cumanascsi_template); + scsi_unregister_host(&cumanascsi_template); } module_init(cumanascsi_init); diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/acorn/scsi/cumana_2.c linux-2.5/drivers/acorn/scsi/cumana_2.c --- linux-2.5.1/drivers/acorn/scsi/cumana_2.c Wed Nov 28 18:22:26 2001 +++ linux-2.5/drivers/acorn/scsi/cumana_2.c Thu Dec 27 22:10:28 2001 @@ -579,17 +579,17 @@ static int __init cumanascsi2_init(void) { - scsi_register_module(MODULE_SCSI_HA, &cumanascsi2_template); + scsi_register_host(&cumanascsi2_template); if (cumanascsi2_template.present) return 0; - scsi_unregister_module(MODULE_SCSI_HA, &cumanascsi2_template); + scsi_unregister_host(&cumanascsi2_template); return -ENODEV; } static void __exit cumanascsi2_exit(void) { - scsi_unregister_module(MODULE_SCSI_HA, &cumanascsi2_template); + scsi_unregister_host(&cumanascsi2_template); } module_init(cumanascsi2_init); diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/acorn/scsi/ecoscsi.c linux-2.5/drivers/acorn/scsi/ecoscsi.c --- linux-2.5.1/drivers/acorn/scsi/ecoscsi.c Thu Oct 25 20:53:46 2001 +++ linux-2.5/drivers/acorn/scsi/ecoscsi.c Thu Dec 27 22:10:28 2001 @@ -276,17 +276,17 @@ static int __init ecoscsi_init(void) { - scsi_register_module(MODULE_SCSI_HA, &ecoscsi_template); + scsi_register_host(&ecoscsi_template); if (ecoscsi_template.present) return 0; - scsi_unregister_module(MODULE_SCSI_HA, &ecoscsi_template); + scsi_unregister_host(&ecoscsi_template); return -ENODEV; } static void __exit ecoscsi_exit(void) { - scsi_unregister_module(MODULE_SCSI_HA, &ecoscsi_template); + scsi_unregister_host(&ecoscsi_template); } module_init(ecoscsi_init); diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/acorn/scsi/eesox.c linux-2.5/drivers/acorn/scsi/eesox.c --- linux-2.5.1/drivers/acorn/scsi/eesox.c Wed Nov 28 18:22:27 2001 +++ linux-2.5/drivers/acorn/scsi/eesox.c Thu Dec 27 22:10:28 2001 @@ -581,17 +581,17 @@ static int __init eesox_init(void) { - scsi_register_module(MODULE_SCSI_HA, &eesox_template); + scsi_register_host(&eesox_template); if (eesox_template.present) return 0; - scsi_unregister_module(MODULE_SCSI_HA, &eesox_template); + scsi_unregister_host(&eesox_template); return -ENODEV; } static void __exit eesox_exit(void) { - scsi_unregister_module(MODULE_SCSI_HA, &eesox_template); + scsi_unregister_host(&eesox_template); } module_init(eesox_init); diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/acorn/scsi/oak.c linux-2.5/drivers/acorn/scsi/oak.c --- linux-2.5.1/drivers/acorn/scsi/oak.c Thu Oct 11 16:04:57 2001 +++ linux-2.5/drivers/acorn/scsi/oak.c Thu Dec 27 22:10:28 2001 @@ -270,17 +270,17 @@ static int __init oakscsi_init(void) { - scsi_register_module(MODULE_SCSI_HA, &oakscsi_template); + scsi_register_host(&oakscsi_template); if (oakscsi_template.present) return 0; - scsi_unregister_module(MODULE_SCSI_HA, &oakscsi_template); + scsi_unregister_host(&oakscsi_template); return -ENODEV; } static void __exit oakscsi_exit(void) { - scsi_unregister_module(MODULE_SCSI_HA, &oakscsi_template); + scsi_unregister_host(&oakscsi_template); } module_init(oakscsi_init); diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/acorn/scsi/powertec.c linux-2.5/drivers/acorn/scsi/powertec.c --- linux-2.5.1/drivers/acorn/scsi/powertec.c Wed Nov 28 18:22:27 2001 +++ linux-2.5/drivers/acorn/scsi/powertec.c Thu Dec 27 22:10:28 2001 @@ -481,17 +481,17 @@ static int __init powertecscsi_init(void) { - scsi_register_module(MODULE_SCSI_HA, &powertecscsi_template); + scsi_register_host(&powertecscsi_template); if (powertecscsi_template.present) return 0; - scsi_unregister_module(MODULE_SCSI_HA, &powertecscsi_template); + scsi_unregister_host(&powertecscsi_template); return -ENODEV; } static void __exit powertecscsi_exit(void) { - scsi_unregister_module(MODULE_SCSI_HA, &powertecscsi_template); + scsi_unregister_host(&powertecscsi_template); } module_init(powertecscsi_init); diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/acpi/ospm/ac_adapter/ac_osl.c linux-2.5/drivers/acpi/ospm/ac_adapter/ac_osl.c --- linux-2.5.1/drivers/acpi/ospm/ac_adapter/ac_osl.c Wed Oct 24 21:06:22 2001 +++ linux-2.5/drivers/acpi/ospm/ac_adapter/ac_osl.c Sun Dec 16 03:58:15 2001 @@ -35,6 +35,7 @@ MODULE_AUTHOR("Andrew Grover"); MODULE_DESCRIPTION("ACPI Component Architecture (CA) - AC Adapter Driver"); +MODULE_LICENSE("GPL"); #define AC_PROC_ROOT "ac_adapter" diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/acpi/ospm/battery/bt_osl.c linux-2.5/drivers/acpi/ospm/battery/bt_osl.c --- linux-2.5.1/drivers/acpi/ospm/battery/bt_osl.c Wed Oct 24 21:06:22 2001 +++ linux-2.5/drivers/acpi/ospm/battery/bt_osl.c Sun Dec 16 03:58:15 2001 @@ -44,6 +44,7 @@ MODULE_AUTHOR("Andrew Grover"); MODULE_DESCRIPTION("ACPI Component Architecture (CA) - Control Method Battery Driver"); +MODULE_LICENSE("GPL"); #define BT_PROC_ROOT "battery" diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/acpi/ospm/busmgr/bm_osl.c linux-2.5/drivers/acpi/ospm/busmgr/bm_osl.c --- linux-2.5.1/drivers/acpi/ospm/busmgr/bm_osl.c Wed Oct 24 21:06:22 2001 +++ linux-2.5/drivers/acpi/ospm/busmgr/bm_osl.c Sun Dec 16 03:58:15 2001 @@ -38,6 +38,7 @@ MODULE_AUTHOR("Andrew Grover"); MODULE_DESCRIPTION("ACPI Component Architecture (CA) - ACPI Bus Manager"); +MODULE_LICENSE("GPL"); /***************************************************************************** diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/acpi/ospm/button/bn_osl.c linux-2.5/drivers/acpi/ospm/button/bn_osl.c --- linux-2.5.1/drivers/acpi/ospm/button/bn_osl.c Wed Oct 24 21:06:22 2001 +++ linux-2.5/drivers/acpi/ospm/button/bn_osl.c Sun Dec 16 03:58:15 2001 @@ -35,6 +35,7 @@ MODULE_AUTHOR("Andrew Grover"); MODULE_DESCRIPTION("ACPI Component Architecture (CA) - Button Driver"); +MODULE_LICENSE("GPL"); #define BN_PROC_ROOT "button" diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/acpi/ospm/ec/ec_osl.c linux-2.5/drivers/acpi/ospm/ec/ec_osl.c --- linux-2.5.1/drivers/acpi/ospm/ec/ec_osl.c Wed Oct 24 21:06:22 2001 +++ linux-2.5/drivers/acpi/ospm/ec/ec_osl.c Sun Dec 16 03:58:15 2001 @@ -36,6 +36,7 @@ MODULE_AUTHOR("Andrew Grover"); MODULE_DESCRIPTION("ACPI Component Architecture (CA) - Embedded Controller Driver"); +MODULE_LICENSE("GPL"); extern struct proc_dir_entry *bm_proc_root; diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/acpi/ospm/processor/pr_osl.c linux-2.5/drivers/acpi/ospm/processor/pr_osl.c --- linux-2.5.1/drivers/acpi/ospm/processor/pr_osl.c Fri Nov 9 21:58:02 2001 +++ linux-2.5/drivers/acpi/ospm/processor/pr_osl.c Sun Dec 16 03:58:15 2001 @@ -37,6 +37,7 @@ MODULE_AUTHOR("Andrew Grover"); MODULE_DESCRIPTION("ACPI Component Architecture (CA) - IA32 Processor Driver"); +MODULE_LICENSE("GPL"); #define PR_PROC_ROOT "processor" diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/acpi/ospm/system/sm_osl.c linux-2.5/drivers/acpi/ospm/system/sm_osl.c --- linux-2.5.1/drivers/acpi/ospm/system/sm_osl.c Wed Oct 24 21:06:22 2001 +++ linux-2.5/drivers/acpi/ospm/system/sm_osl.c Sun Dec 16 03:58:15 2001 @@ -42,6 +42,7 @@ MODULE_AUTHOR("Andrew Grover"); MODULE_DESCRIPTION("ACPI Component Architecture (CA) - ACPI System Driver"); +MODULE_LICENSE("GPL"); #define SM_PROC_INFO "info" diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/acpi/ospm/thermal/tz_osl.c linux-2.5/drivers/acpi/ospm/thermal/tz_osl.c --- linux-2.5.1/drivers/acpi/ospm/thermal/tz_osl.c Wed Oct 24 21:06:22 2001 +++ linux-2.5/drivers/acpi/ospm/thermal/tz_osl.c Sun Dec 16 03:58:15 2001 @@ -35,6 +35,7 @@ MODULE_AUTHOR("Andrew Grover"); MODULE_DESCRIPTION("ACPI Component Architecture (CA) - Thermal Zone Driver"); +MODULE_LICENSE("GPL"); int TZP = 0; MODULE_PARM(TZP, "i"); diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/acpi/ospm/thermal/tzpolicy.c linux-2.5/drivers/acpi/ospm/thermal/tzpolicy.c --- linux-2.5.1/drivers/acpi/ospm/thermal/tzpolicy.c Wed Oct 24 21:06:22 2001 +++ linux-2.5/drivers/acpi/ospm/thermal/tzpolicy.c Sun Dec 30 20:14:04 2001 @@ -31,6 +31,7 @@ #include <linux/proc_fs.h> #include <linux/sysctl.h> #include <linux/pm.h> +#include <linux/sched.h> #include <acpi.h> #include <bm.h> diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/atm/eni.c linux-2.5/drivers/atm/eni.c --- linux-2.5.1/drivers/atm/eni.c Fri Nov 9 21:41:42 2001 +++ linux-2.5/drivers/atm/eni.c Thu Dec 13 16:32:35 2001 @@ -2310,7 +2310,7 @@ name: DEV_LABEL, id_table: eni_pci_tbl, probe: eni_init_one, - remove: eni_remove_one, + remove: __devexit_p(eni_remove_one), }; diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/atm/firestream.c linux-2.5/drivers/atm/firestream.c --- linux-2.5.1/drivers/atm/firestream.c Fri Nov 9 21:58:03 2001 +++ linux-2.5/drivers/atm/firestream.c Thu Dec 13 16:32:35 2001 @@ -2102,7 +2102,7 @@ name: "firestream", id_table: firestream_pci_tbl, probe: firestream_init_one, - remove: firestream_remove_one, + remove: __devexit_p(firestream_remove_one), }; static int __init firestream_init_module (void) diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/atm/fore200e.c linux-2.5/drivers/atm/fore200e.c --- linux-2.5.1/drivers/atm/fore200e.c Thu Sep 13 22:21:32 2001 +++ linux-2.5/drivers/atm/fore200e.c Sun Dec 30 21:17:30 2001 @@ -39,7 +39,6 @@ #include <linux/atm_suni.h> #include <asm/io.h> #include <asm/string.h> -#include <asm/segment.h> #include <asm/page.h> #include <asm/irq.h> #include <asm/dma.h> diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/atm/idt77252.c linux-2.5/drivers/atm/idt77252.c --- linux-2.5.1/drivers/atm/idt77252.c Tue Nov 20 23:46:21 2001 +++ linux-2.5/drivers/atm/idt77252.c Thu Dec 13 16:32:35 2001 @@ -1,8 +1,8 @@ /******************************************************************* - * ident "$Id: idt77252.c,v 1.2 2001/11/11 08:13:54 ecd Exp $" + * ident "$Id: idt77252.c,v 1.3 2001/11/17 00:30:19 ecd Exp $" * * $Author: ecd $ - * $Date: 2001/11/11 08:13:54 $ + * $Date: 2001/11/17 00:30:19 $ * * Copyright (c) 2000 ATecoM GmbH * @@ -30,7 +30,7 @@ * *******************************************************************/ static char const rcsid[] = -"$Id: idt77252.c,v 1.2 2001/11/11 08:13:54 ecd Exp $"; +"$Id: idt77252.c,v 1.3 2001/11/17 00:30:19 ecd Exp $"; #include <linux/module.h> diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/block/DAC960.c linux-2.5/drivers/block/DAC960.c --- linux-2.5.1/drivers/block/DAC960.c Sun Dec 16 20:20:20 2001 +++ linux-2.5/drivers/block/DAC960.c Sun Dec 30 21:17:30 2001 @@ -45,7 +45,6 @@ #include <linux/pci.h> #include <linux/init.h> #include <asm/io.h> -#include <asm/segment.h> #include <asm/uaccess.h> #include "DAC960.h" diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/block/blkpg.c linux-2.5/drivers/block/blkpg.c --- linux-2.5.1/drivers/block/blkpg.c Thu Dec 6 22:02:56 2001 +++ linux-2.5/drivers/block/blkpg.c Thu Dec 27 22:10:28 2001 @@ -201,6 +201,7 @@ struct gendisk *g; u64 ullval = 0; int intval, *iptr; + unsigned short usval; if (!dev) return -EINVAL; @@ -247,9 +248,12 @@ return put_user(iptr[MINOR(dev)], (long *) arg); case BLKSECTGET: - if ((q = blk_get_queue(dev))) - return put_user(q->max_sectors, (unsigned short *)arg); - return -EINVAL; + if ((q = blk_get_queue(dev)) == NULL) + return -EINVAL; + + usval = q->max_sectors; + blk_put_queue(q); + return put_user(usval, (unsigned short *)arg); case BLKFLSBUF: if (!capable(CAP_SYS_ADMIN)) @@ -291,9 +295,7 @@ case BLKBSZGET: /* get the logical block size (cf. BLKSSZGET) */ - intval = BLOCK_SIZE; - if (blksize_size[MAJOR(dev)]) - intval = blksize_size[MAJOR(dev)][MINOR(dev)]; + intval = block_size(dev); return put_user(intval, (int *) arg); case BLKBSZSET: diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/block/block_ioctl.c linux-2.5/drivers/block/block_ioctl.c --- linux-2.5.1/drivers/block/block_ioctl.c Sun Dec 16 20:20:20 2001 +++ linux-2.5/drivers/block/block_ioctl.c Thu Dec 27 22:10:28 2001 @@ -35,7 +35,7 @@ DECLARE_COMPLETION(wait); int err = 0; - rq->flags |= REQ_BARRIER; + rq->flags |= REQ_NOMERGE; rq->waiting = &wait; elv_add_request(q, rq, 1); generic_unplug_device(q); @@ -76,8 +76,8 @@ err = -ENOTTY; } -#if 0 blk_put_queue(q); -#endif return err; } + +EXPORT_SYMBOL(block_ioctl); diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/block/elevator.c linux-2.5/drivers/block/elevator.c --- linux-2.5.1/drivers/block/elevator.c Sat Dec 8 00:32:26 2001 +++ linux-2.5/drivers/block/elevator.c Sun Dec 30 20:01:41 2001 @@ -53,7 +53,7 @@ * if .next is a valid request */ next = rq->queuelist.next; - if (next == head) + if (unlikely(next == head)) return 0; next_rq = list_entry(next, struct request, queuelist); @@ -101,7 +101,7 @@ */ inline int elv_rq_merge_ok(struct request *rq, struct bio *bio) { - if (!(rq->flags & REQ_CMD)) + if (!rq_mergeable(rq)) return 0; /* @@ -109,8 +109,6 @@ */ if (bio_data_dir(bio) != rq_data_dir(rq)) return 0; - if (rq->flags & REQ_NOMERGE) - return 0; /* * same device and no special stuff set, merge is ok @@ -121,49 +119,71 @@ return 0; } -int elevator_linus_merge(request_queue_t *q, struct request **req, - struct list_head *head, struct bio *bio) +inline int elv_try_merge(struct request *__rq, struct bio *bio) { unsigned int count = bio_sectors(bio); - struct list_head *entry = &q->queue_head; int ret = ELEVATOR_NO_MERGE; + + /* + * we can merge and sequence is ok, check if it's possible + */ + if (elv_rq_merge_ok(__rq, bio)) { + if (__rq->sector + __rq->nr_sectors == bio->bi_sector) { + ret = ELEVATOR_BACK_MERGE; + } else if (__rq->sector - count == bio->bi_sector) { + __rq->elevator_sequence -= count; + ret = ELEVATOR_FRONT_MERGE; + } + } + + return ret; +} + +int elevator_linus_merge(request_queue_t *q, struct request **req, + struct bio *bio) +{ + struct list_head *entry; struct request *__rq; + int ret; + + /* + * give a one-shot try to merging with the last touched + * request + */ + if (q->last_merge) { + __rq = list_entry_rq(q->last_merge); + BUG_ON(__rq->flags & REQ_STARTED); + + if ((ret = elv_try_merge(__rq, bio))) { + *req = __rq; + return ret; + } + } entry = &q->queue_head; - while ((entry = entry->prev) != head) { + ret = ELEVATOR_NO_MERGE; + while ((entry = entry->prev) != &q->queue_head) { __rq = list_entry_rq(entry); - prefetch(list_entry_rq(entry->prev)); + if (__rq->flags & (REQ_BARRIER | REQ_STARTED)) + break; /* * simply "aging" of requests in queue */ if (__rq->elevator_sequence-- <= 0) break; - if (__rq->flags & (REQ_BARRIER | REQ_STARTED)) - break; if (!(__rq->flags & REQ_CMD)) continue; + if (__rq->elevator_sequence < bio_sectors(bio)) + break; if (!*req && bio_rq_in_between(bio, __rq, &q->queue_head)) *req = __rq; - if (!elv_rq_merge_ok(__rq, bio)) - continue; - - if (__rq->elevator_sequence < count) - break; - /* - * we can merge and sequence is ok, check if it's possible - */ - if (__rq->sector + __rq->nr_sectors == bio->bi_sector) { - ret = ELEVATOR_BACK_MERGE; - *req = __rq; - break; - } else if (__rq->sector - count == bio->bi_sector) { - ret = ELEVATOR_FRONT_MERGE; - __rq->elevator_sequence -= count; + if ((ret = elv_try_merge(__rq, bio))) { *req = __rq; + q->last_merge = &__rq->queuelist; break; } } @@ -183,7 +203,6 @@ entry = &req->queuelist; while ((entry = entry->next) != &q->queue_head) { struct request *tmp; - prefetch(list_entry_rq(entry->next)); tmp = list_entry_rq(entry); tmp->elevator_sequence -= count; } @@ -199,12 +218,20 @@ struct list_head *insert_here) { list_add(&rq->queuelist, insert_here); + + /* + * new merges must not precede this barrier + */ + if (rq->flags & REQ_BARRIER) + q->last_merge = NULL; + else if (!q->last_merge) + q->last_merge = &rq->queuelist; } struct request *elv_next_request_fn(request_queue_t *q) { if (!blk_queue_empty(q)) - return list_entry(q->queue_head.next, struct request, queuelist); + return list_entry_rq(q->queue_head.next); return NULL; } @@ -222,17 +249,24 @@ * See if we can find a request that this buffer can be coalesced with. */ int elevator_noop_merge(request_queue_t *q, struct request **req, - struct list_head *head, struct bio *bio) + struct bio *bio) { - unsigned int count = bio_sectors(bio); struct list_head *entry = &q->queue_head; struct request *__rq; + int ret; - entry = &q->queue_head; - while ((entry = entry->prev) != head) { - __rq = list_entry_rq(entry); + if (q->last_merge) { + __rq = list_entry_rq(q->last_merge); + BUG_ON(__rq->flags & REQ_STARTED); + + if ((ret = elv_try_merge(__rq, bio))) { + *req = __rq; + return ret; + } + } - prefetch(list_entry_rq(entry->prev)); + while ((entry = entry->prev) != &q->queue_head) { + __rq = list_entry_rq(entry); if (__rq->flags & (REQ_BARRIER | REQ_STARTED)) break; @@ -240,18 +274,10 @@ if (!(__rq->flags & REQ_CMD)) continue; - if (!elv_rq_merge_ok(__rq, bio)) - continue; - - /* - * we can merge and sequence is ok, check if it's possible - */ - if (__rq->sector + __rq->nr_sectors == bio->bi_sector) { - *req = __rq; - return ELEVATOR_BACK_MERGE; - } else if (__rq->sector - count == bio->bi_sector) { + if ((ret = elv_try_merge(__rq, bio))) { *req = __rq; - return ELEVATOR_FRONT_MERGE; + q->last_merge = &__rq->queuelist; + return ret; } } @@ -267,6 +293,7 @@ *e = type; INIT_LIST_HEAD(&q->queue_head); + q->last_merge = NULL; if (e->elevator_init_fn) return e->elevator_init_fn(q, e); diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/block/floppy.c linux-2.5/drivers/block/floppy.c --- linux-2.5.1/drivers/block/floppy.c Sun Dec 16 20:23:05 2001 +++ linux-2.5/drivers/block/floppy.c Mon Dec 17 01:03:06 2001 @@ -4480,3 +4480,5 @@ __setup ("floppy=", floppy_setup); module_init(floppy_init) #endif + +EXPORT_NO_SYMBOLS; diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/block/ll_rw_blk.c linux-2.5/drivers/block/ll_rw_blk.c --- linux-2.5.1/drivers/block/ll_rw_blk.c Sun Dec 16 20:20:20 2001 +++ linux-2.5/drivers/block/ll_rw_blk.c Sun Dec 30 20:01:41 2001 @@ -117,6 +117,11 @@ return &blk_dev[MAJOR(dev)].request_queue; } +void blk_queue_prep_rq(request_queue_t *q, prep_rq_fn *pfn) +{ + q->prep_rq_fn = pfn; +} + /** * blk_queue_make_request - define an alternate make_request function for a device * @q: the request queue for the device to be affected @@ -150,6 +155,11 @@ blk_queue_max_sectors(q, MAX_SECTORS); blk_queue_hardsect_size(q, 512); + /* + * by default assume old behaviour and bounce for any highmem page + */ + blk_queue_bounce_limit(q, BLK_BOUNCE_HIGH); + init_waitqueue_head(&q->queue_wait); } @@ -179,7 +189,6 @@ if (dma_addr == BLK_BOUNCE_ISA) { init_emergency_isa_pool(); q->bounce_gfp = GFP_NOIO | GFP_DMA; - printk("isa pfn %lu, max low %lu, max %lu\n", bounce_pfn, blk_max_low_pfn, blk_max_pfn); } else q->bounce_gfp = GFP_NOHIGHIO; @@ -319,7 +328,7 @@ /* * standard prep_rq_fn that builds 10 byte cmds */ -static int ll_10byte_cmd_build(request_queue_t *q, struct request *rq) +int ll_10byte_cmd_build(request_queue_t *q, struct request *rq) { int hard_sect = get_hardsect_size(rq->rq_dev); sector_t block = rq->hard_sector / (hard_sect >> 9); @@ -477,7 +486,7 @@ sg[nsegs - 1].length += nbytes; } else { new_segment: - sg[nsegs].address = NULL; + memset(&sg[nsegs],0,sizeof(struct scatterlist)); sg[nsegs].page = bvec->bv_page; sg[nsegs].length = nbytes; sg[nsegs].offset = bvec->bv_offset; @@ -504,6 +513,7 @@ if (req->nr_phys_segments + nr_phys_segs > q->max_phys_segments) { req->flags |= REQ_NOMERGE; + q->last_merge = NULL; return 0; } @@ -523,6 +533,7 @@ if (req->nr_hw_segments + nr_hw_segs > q->max_hw_segments) { req->flags |= REQ_NOMERGE; + q->last_merge = NULL; return 0; } @@ -540,11 +551,11 @@ { if (req->nr_sectors + bio_sectors(bio) > q->max_sectors) { req->flags |= REQ_NOMERGE; + q->last_merge = NULL; return 0; } - if (BIOVEC_VIRT_MERGEABLE(__BVEC_END(req->biotail), - __BVEC_START(bio))) + if (BIOVEC_VIRT_MERGEABLE(__BVEC_END(req->biotail), __BVEC_START(bio))) return ll_new_mergeable(q, req, bio); return ll_new_hw_segment(q, req, bio); @@ -555,11 +566,11 @@ { if (req->nr_sectors + bio_sectors(bio) > q->max_sectors) { req->flags |= REQ_NOMERGE; + q->last_merge = NULL; return 0; } - if (BIOVEC_VIRT_MERGEABLE(__BVEC_END(bio), - __BVEC_START(req->bio))) + if (BIOVEC_VIRT_MERGEABLE(__BVEC_END(bio), __BVEC_START(req->bio))) return ll_new_mergeable(q, req, bio); return ll_new_hw_segment(q, req, bio); @@ -568,7 +579,7 @@ static int ll_merge_requests_fn(request_queue_t *q, struct request *req, struct request *next) { - int total_phys_segments = req->nr_phys_segments + next->nr_phys_segments; + int total_phys_segments = req->nr_phys_segments +next->nr_phys_segments; int total_hw_segments = req->nr_hw_segments + next->nr_hw_segments; /* @@ -799,18 +810,14 @@ q->back_merge_fn = ll_back_merge_fn; q->front_merge_fn = ll_front_merge_fn; q->merge_requests_fn = ll_merge_requests_fn; - q->prep_rq_fn = ll_10byte_cmd_build; + q->prep_rq_fn = NULL; q->plug_tq.sync = 0; q->plug_tq.routine = &generic_unplug_device; q->plug_tq.data = q; q->queue_flags = (1 << QUEUE_FLAG_CLUSTER); q->queue_lock = lock; + q->last_merge = NULL; - /* - * by default assume old behaviour and bounce for any highmem page - */ - blk_queue_bounce_limit(q, BLK_BOUNCE_HIGH); - blk_queue_segment_boundary(q, 0xffffffff); blk_queue_make_request(q, __make_request); @@ -874,11 +881,19 @@ BUG_ON(rw != READ && rw != WRITE); + spin_lock_irq(q->queue_lock); rq = get_request(q, rw); + spin_unlock_irq(q->queue_lock); if (!rq && (gfp_mask & __GFP_WAIT)) rq = get_request_wait(q, rw); + if (rq) { + rq->flags = 0; + rq->buffer = NULL; + rq->bio = rq->biotail = NULL; + rq->waiting = NULL; + } return rq; } @@ -944,13 +959,10 @@ drive_stat_acct(req, req->nr_sectors, 1); /* - * debug stuff... + * it's a bug to let this rq preempt an already started request */ - if (insert_here == &q->queue_head) { - struct request *__rq = __elv_next_request(q); - - BUG_ON(__rq && (__rq->flags & REQ_STARTED)); - } + if (insert_here->next != &q->queue_head) + BUG_ON(list_entry_rq(insert_here->next)->flags & REQ_STARTED); /* * elevator indicated where it wants this request to be @@ -965,11 +977,17 @@ void blkdev_release_request(struct request *req) { struct request_list *rl = req->rl; + request_queue_t *q = req->q; req->rq_status = RQ_INACTIVE; req->q = NULL; req->rl = NULL; + if (q) { + if (q->last_merge == &req->queuelist) + q->last_merge = NULL; + } + /* * Request may not have originated from ll_rw_blk. if not, * it didn't come out of our reserved rq pools @@ -985,14 +1003,10 @@ /* * Has to be called with the request spinlock acquired */ -static void attempt_merge(request_queue_t *q, struct request *req) +static void attempt_merge(request_queue_t *q, struct request *req, + struct request *next) { - struct request *next = blkdev_next_request(req); - - /* - * not a rw command - */ - if (!(next->flags & REQ_CMD)) + if (!rq_mergeable(req) || !rq_mergeable(next)) return; /* @@ -1001,12 +1015,6 @@ if (req->sector + req->nr_sectors != next->sector) return; - /* - * don't touch NOMERGE rq, or one that has been started by driver - */ - if (next->flags & (REQ_NOMERGE | REQ_STARTED)) - return; - if (rq_data_dir(req) != rq_data_dir(next) || req->rq_dev != next->rq_dev || req->nr_sectors + next->nr_sectors > q->max_sectors @@ -1014,10 +1022,10 @@ return; /* - * If we are not allowed to merge these requests, then - * return. If we are allowed to merge, then the count - * will have been updated to the appropriate number, - * and we shouldn't do it here too. + * If we are allowed to merge, then append bio list + * from next to rq and release next. merge_requests_fn + * will have updated segment counts, update sector + * counts here. */ if (q->merge_requests_fn(q, req, next)) { q->elevator.elevator_merge_req_fn(req, next); @@ -1035,24 +1043,18 @@ static inline void attempt_back_merge(request_queue_t *q, struct request *rq) { - if (&rq->queuelist != q->queue_head.prev) - attempt_merge(q, rq); + struct list_head *next = rq->queuelist.next; + + if (next != &q->queue_head) + attempt_merge(q, rq, list_entry_rq(next)); } -static inline void attempt_front_merge(request_queue_t *q, - struct list_head *head, - struct request *rq) +static inline void attempt_front_merge(request_queue_t *q, struct request *rq) { struct list_head *prev = rq->queuelist.prev; - if (prev != head) - attempt_merge(q, blkdev_entry_to_request(prev)); -} - -static inline void __blk_attempt_remerge(request_queue_t *q, struct request *rq) -{ - if (rq->queuelist.next != &q->queue_head) - attempt_merge(q, rq); + if (prev != &q->queue_head) + attempt_merge(q, list_entry_rq(prev), rq); } /** @@ -1073,7 +1075,7 @@ unsigned long flags; spin_lock_irqsave(q->queue_lock, flags); - __blk_attempt_remerge(q, rq); + attempt_back_merge(q, rq); spin_unlock_irqrestore(q->queue_lock, flags); } @@ -1081,7 +1083,7 @@ { struct request *req, *freereq = NULL; int el_ret, latency = 0, rw, nr_sectors, cur_nr_sectors, barrier; - struct list_head *head, *insert_here; + struct list_head *insert_here; elevator_t *elevator = &q->elevator; sector_t sector; @@ -1102,28 +1104,20 @@ latency = elevator_request_latency(elevator, rw); barrier = test_bit(BIO_RW_BARRIER, &bio->bi_rw); + spin_lock_irq(q->queue_lock); again: req = NULL; - head = &q->queue_head; - - spin_lock_irq(q->queue_lock); + insert_here = q->queue_head.prev; - insert_here = head->prev; if (blk_queue_empty(q) || barrier) { blk_plug_device(q); goto get_rq; - } else if ((req = __elv_next_request(q))) { - if (req->flags & REQ_STARTED) - head = head->next; - - req = NULL; } - el_ret = elevator->elevator_merge_fn(q, &req, head, bio); + el_ret = elevator->elevator_merge_fn(q, &req, bio); switch (el_ret) { case ELEVATOR_BACK_MERGE: - BUG_ON(req->flags & REQ_STARTED); - BUG_ON(req->flags & REQ_NOMERGE); + BUG_ON(!rq_mergeable(req)); if (!q->back_merge_fn(q, req, bio)) break; @@ -1137,8 +1131,7 @@ goto out; case ELEVATOR_FRONT_MERGE: - BUG_ON(req->flags & REQ_STARTED); - BUG_ON(req->flags & REQ_NOMERGE); + BUG_ON(!rq_mergeable(req)); if (!q->front_merge_fn(q, req, bio)) break; @@ -1157,7 +1150,7 @@ req->sector = req->hard_sector = sector; req->nr_sectors = req->hard_nr_sectors += nr_sectors; drive_stat_acct(req, nr_sectors, 0); - attempt_front_merge(q, head, req); + attempt_front_merge(q, req); goto out; /* @@ -1188,7 +1181,6 @@ req = freereq; freereq = NULL; } else if ((req = get_request(q, rw)) == NULL) { - spin_unlock_irq(q->queue_lock); /* @@ -1200,6 +1192,7 @@ } freereq = get_request_wait(q, rw); + spin_lock_irq(q->queue_lock); goto again; } @@ -1298,7 +1291,7 @@ int minor = MINOR(bio->bi_dev); request_queue_t *q; sector_t minorsize = 0; - int nr_sectors = bio_sectors(bio); + int ret, nr_sectors = bio_sectors(bio); /* Test device or partition size, when known. */ if (blk_size[major]) @@ -1352,7 +1345,10 @@ */ blk_partition_remap(bio); - } while (q->make_request_fn(q, bio)); + ret = q->make_request_fn(q, bio); + blk_put_queue(q); + + } while (ret); } /* @@ -1572,21 +1568,23 @@ inline void blk_recalc_rq_sectors(struct request *rq, int nsect) { - rq->hard_sector += nsect; - rq->hard_nr_sectors -= nsect; - rq->sector = rq->hard_sector; - rq->nr_sectors = rq->hard_nr_sectors; + if (rq->flags & REQ_CMD) { + rq->hard_sector += nsect; + rq->hard_nr_sectors -= nsect; + rq->sector = rq->hard_sector; + rq->nr_sectors = rq->hard_nr_sectors; - rq->current_nr_sectors = bio_iovec(rq->bio)->bv_len >> 9; - rq->hard_cur_sectors = rq->current_nr_sectors; + rq->current_nr_sectors = bio_iovec(rq->bio)->bv_len >> 9; + rq->hard_cur_sectors = rq->current_nr_sectors; - /* - * if total number of sectors is less than the first segment - * size, something has gone terribly wrong - */ - if (rq->nr_sectors < rq->current_nr_sectors) { - printk("blk: request botched\n"); - rq->nr_sectors = rq->current_nr_sectors; + /* + * if total number of sectors is less than the first segment + * size, something has gone terribly wrong + */ + if (rq->nr_sectors < rq->current_nr_sectors) { + printk("blk: request botched\n"); + rq->nr_sectors = rq->current_nr_sectors; + } } } @@ -1755,3 +1753,6 @@ EXPORT_SYMBOL(blk_queue_assign_lock); EXPORT_SYMBOL(blk_phys_contig_segment); EXPORT_SYMBOL(blk_hw_contig_segment); + +EXPORT_SYMBOL(ll_10byte_cmd_build); +EXPORT_SYMBOL(blk_queue_prep_rq); diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/block/loop.c linux-2.5/drivers/block/loop.c --- linux-2.5.1/drivers/block/loop.c Fri Nov 30 16:33:50 2001 +++ linux-2.5/drivers/block/loop.c Thu Dec 27 22:10:28 2001 @@ -284,14 +284,7 @@ static inline int loop_get_bs(struct loop_device *lo) { - int bs = 0; - - if (blksize_size[MAJOR(lo->lo_device)]) - bs = blksize_size[MAJOR(lo->lo_device)][MINOR(lo->lo_device)]; - if (!bs) - bs = BLOCK_SIZE; - - return bs; + return block_size(lo->lo_device); } static inline unsigned long loop_get_iv(struct loop_device *lo, @@ -559,6 +552,8 @@ atomic_inc(&lo->lo_pending); spin_unlock_irq(&lo->lo_lock); + current->flags |= PF_NOIO; + /* * up sem, we are running */ @@ -600,7 +595,6 @@ kdev_t lo_device; int lo_flags = 0; int error; - int bs; MOD_INC_USE_COUNT; @@ -621,6 +615,10 @@ if (S_ISBLK(inode->i_mode)) { lo_device = inode->i_rdev; + if (lo_device == dev) { + error = -EBUSY; + goto out; + } } else if (S_ISREG(inode->i_mode)) { struct address_space_operations *aops = inode->i_mapping->a_ops; /* @@ -656,13 +654,7 @@ lo->old_gfp_mask = inode->i_mapping->gfp_mask; inode->i_mapping->gfp_mask = GFP_NOIO; - bs = 0; - if (blksize_size[MAJOR(lo_device)]) - bs = blksize_size[MAJOR(lo_device)][MINOR(lo_device)]; - if (!bs) - bs = BLOCK_SIZE; - - set_blocksize(dev, bs); + set_blocksize(dev, block_size(lo_device)); lo->lo_bio = lo->lo_biotail = NULL; kernel_thread(loop_thread, lo, CLONE_FS | CLONE_FILES | CLONE_SIGHAND); @@ -1007,6 +999,7 @@ goto out_mem; blk_queue_make_request(BLK_DEFAULT_QUEUE(MAJOR_NR), loop_make_request); + blk_queue_bounce_limit(BLK_DEFAULT_QUEUE(MAJOR_NR), BLK_BOUNCE_HIGH); for (i = 0; i < max_loop; i++) { struct loop_device *lo = &loop_dev[i]; diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/block/nbd.c linux-2.5/drivers/block/nbd.c --- linux-2.5.1/drivers/block/nbd.c Sun Dec 16 20:20:20 2001 +++ linux-2.5/drivers/block/nbd.c Sun Dec 30 21:17:30 2001 @@ -45,7 +45,6 @@ #include <linux/devfs_fs_kernel.h> -#include <asm/segment.h> #include <asm/uaccess.h> #include <asm/types.h> diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/block/paride/Config.in linux-2.5/drivers/block/paride/Config.in --- linux-2.5.1/drivers/block/paride/Config.in Thu Oct 25 07:07:39 2001 +++ linux-2.5/drivers/block/paride/Config.in Thu Dec 13 16:32:35 2001 @@ -29,7 +29,7 @@ dep_tristate ' Shuttle EPAT/EPEZ protocol' CONFIG_PARIDE_EPAT $CONFIG_PARIDE if [ "$CONFIG_PARIDE_EPAT" != "n" ]; then if [ "$CONFIG_EXPERIMENTAL" = "y" ]; then - bool ' Support c7/c8 chips (EXPERIMENTAL)' CONFIG_PARIDE_EPATC8 $CONFIG_PARIDE + bool ' Support c7/c8 chips (EXPERIMENTAL)' CONFIG_PARIDE_EPATC8 fi fi diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/block/paride/pf.c linux-2.5/drivers/block/paride/pf.c --- linux-2.5.1/drivers/block/paride/pf.c Sun Dec 16 20:20:20 2001 +++ linux-2.5/drivers/block/paride/pf.c Sun Dec 30 19:12:33 2001 @@ -684,7 +684,8 @@ for (k=0;k<len;k++) if((buf[k+offs]!=0x20)||(buf[k+offs]!=l)) l=targ[j++]=buf[k+offs]; - if (l==0x20) j--; targ[j]=0; + if (l==0x20) j--; + targ[j]=0; } static int xl( char *buf, int offs ) diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/block/paride/pg.c linux-2.5/drivers/block/paride/pg.c --- linux-2.5.1/drivers/block/paride/pg.c Fri Nov 30 16:26:04 2001 +++ linux-2.5/drivers/block/paride/pg.c Sun Dec 30 19:12:33 2001 @@ -491,7 +491,8 @@ for (k=0;k<len;k++) if((buf[k+offs]!=0x20)||(buf[k+offs]!=l)) l=targ[j++]=buf[k+offs]; - if (l==0x20) j--; targ[j]=0; + if (l==0x20) j--; + targ[j]=0; } static int pg_identify( int unit, int log ) diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/block/paride/pseudo.h linux-2.5/drivers/block/paride/pseudo.h --- linux-2.5.1/drivers/block/paride/pseudo.h Sun Feb 4 18:05:29 2001 +++ linux-2.5/drivers/block/paride/pseudo.h Thu Dec 13 16:32:35 2001 @@ -102,7 +102,7 @@ spin_unlock_irqrestore(&ps_spinlock,flags); return; } - if (!ps_ready || ps_ready() || (jiffies >= ps_timeout)) { + if (!ps_ready || ps_ready() || time_after_eq(jiffies, ps_timeout)) { ps_continuation = NULL; spin_unlock_irqrestore(&ps_spinlock,flags); con(); @@ -131,7 +131,7 @@ spin_unlock_irqrestore(&ps_spinlock,flags); return; } - if (!ps_ready || ps_ready() || (jiffies >= ps_timeout)) { + if (!ps_ready || ps_ready() || time_after_eq(jiffies, ps_timeout)) { ps_continuation = NULL; spin_unlock_irqrestore(&ps_spinlock,flags); con(); diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/block/paride/pt.c linux-2.5/drivers/block/paride/pt.c --- linux-2.5.1/drivers/block/paride/pt.c Fri Nov 30 16:26:04 2001 +++ linux-2.5/drivers/block/paride/pt.c Sun Dec 30 19:12:33 2001 @@ -577,7 +577,8 @@ for (k=0;k<len;k++) if((buf[k+offs]!=0x20)||(buf[k+offs]!=l)) l=targ[j++]=buf[k+offs]; - if (l==0x20) j--; targ[j]=0; + if (l==0x20) j--; + targ[j]=0; } static int xn( char *buf, int offs, int size ) diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/block/ps2esdi.c linux-2.5/drivers/block/ps2esdi.c --- linux-2.5.1/drivers/block/ps2esdi.c Sun Dec 16 20:20:20 2001 +++ linux-2.5/drivers/block/ps2esdi.c Sun Dec 30 21:17:30 2001 @@ -51,7 +51,6 @@ #include <asm/system.h> #include <asm/io.h> -#include <asm/segment.h> #include <asm/dma.h> #include <asm/mca_dma.h> #include <asm/uaccess.h> @@ -953,10 +952,10 @@ break; } if(ending != -1) { - spin_lock_irqsave(ps2esdi_LOCK, flags); + spin_lock_irqsave(&ps2esdi_lock, flags); end_request(ending); do_ps2esdi_request(BLK_DEFAULT_QUEUE(MAJOR_NR)); - spin_unlock_irqrestore(ps2esdi_LOCK, flags); + spin_unlock_irqrestore(&ps2esdi_lock, flags); } } /* handle interrupts */ diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/block/rd.c linux-2.5/drivers/block/rd.c --- linux-2.5.1/drivers/block/rd.c Wed Dec 12 17:28:27 2001 +++ linux-2.5/drivers/block/rd.c Thu Dec 20 19:14:29 2001 @@ -43,26 +43,12 @@ */ #include <linux/config.h> -#include <linux/sched.h> -#include <linux/fs.h> -#include <linux/kernel.h> -#include <linux/hdreg.h> #include <linux/string.h> -#include <linux/mm.h> -#include <linux/mman.h> #include <linux/slab.h> -#include <linux/ioctl.h> -#include <linux/fd.h> #include <linux/module.h> #include <linux/init.h> #include <linux/devfs_fs_kernel.h> -#include <linux/smp_lock.h> - -#include <asm/system.h> #include <asm/uaccess.h> -#include <asm/byteorder.h> - -extern void wait_for_keypress(void); /* * 35 has been officially registered as the RAMDISK major number, but @@ -79,6 +65,8 @@ #ifdef CONFIG_BLK_DEV_INITRD static int initrd_users; static spinlock_t initrd_users_lock = SPIN_LOCK_UNLOCKED; +unsigned long initrd_start, initrd_end; +int initrd_below_start_ok; #endif /* Various static variables go here. Most are used only in the RAM disk code. @@ -99,7 +87,7 @@ */ int rd_size = CONFIG_BLK_DEV_RAM_SIZE; /* Size of the RAM disks */ /* - * It would be very desiderable to have a soft-blocksize (that in the case + * It would be very desirable to have a soft-blocksize (that in the case * of the ramdisk driver is also the hardblocksize ;) of PAGE_SIZE because * doing that we'll achieve a far better MM footprint. Using a rd_blocksize of * BLOCK_SIZE in the worst case we'll make PAGE_SIZE/BLOCK_SIZE buffer-pages @@ -111,70 +99,6 @@ */ int rd_blocksize = BLOCK_SIZE; /* blocksize of the RAM disks */ -#ifndef MODULE - -int rd_doload; /* 1 = load RAM disk, 0 = don't load */ -int rd_prompt = 1; /* 1 = prompt for RAM disk, 0 = don't prompt */ -int rd_image_start; /* starting block # of image */ -#ifdef CONFIG_BLK_DEV_INITRD -unsigned long initrd_start, initrd_end; -int mount_initrd = 1; /* zero if initrd should not be mounted */ -int initrd_below_start_ok; - -static int __init no_initrd(char *str) -{ - mount_initrd = 0; - return 1; -} - -__setup("noinitrd", no_initrd); - -#endif - -static int __init ramdisk_start_setup(char *str) -{ - rd_image_start = simple_strtol(str,NULL,0); - return 1; -} - -static int __init load_ramdisk(char *str) -{ - rd_doload = simple_strtol(str,NULL,0) & 3; - return 1; -} - -static int __init prompt_ramdisk(char *str) -{ - rd_prompt = simple_strtol(str,NULL,0) & 1; - return 1; -} - -static int __init ramdisk_size(char *str) -{ - rd_size = simple_strtol(str,NULL,0); - return 1; -} - -static int __init ramdisk_size2(char *str) -{ - return ramdisk_size(str); -} - -static int __init ramdisk_blocksize(char *str) -{ - rd_blocksize = simple_strtol(str,NULL,0); - return 1; -} - -__setup("ramdisk_start=", ramdisk_start_setup); -__setup("load_ramdisk=", load_ramdisk); -__setup("prompt_ramdisk=", prompt_ramdisk); -__setup("ramdisk=", ramdisk_size); -__setup("ramdisk_size=", ramdisk_size2); -__setup("ramdisk_blocksize=", ramdisk_blocksize); - -#endif - /* * Copyright (C) 2000 Linus Torvalds. * 2000 Transmeta Corp. @@ -492,7 +416,7 @@ } /* This is the registration and initialization section of the RAM disk driver */ -int __init rd_init (void) +static int __init rd_init (void) { int i; @@ -548,7 +472,28 @@ module_init(rd_init); module_exit(rd_cleanup); -/* loadable module support */ +/* options - nonmodular */ +#ifndef MODULE +static int __init ramdisk_size(char *str) +{ + rd_size = simple_strtol(str,NULL,0); + return 1; +} +static int __init ramdisk_size2(char *str) /* kludge */ +{ + return ramdisk_size(str); +} +static int __init ramdisk_blocksize(char *str) +{ + rd_blocksize = simple_strtol(str,NULL,0); + return 1; +} +__setup("ramdisk=", ramdisk_size); +__setup("ramdisk_size=", ramdisk_size2); +__setup("ramdisk_blocksize=", ramdisk_blocksize); +#endif + +/* options - modular */ MODULE_PARM (rd_size, "1i"); MODULE_PARM_DESC(rd_size, "Size of each RAM disk in kbytes."); MODULE_PARM (rd_blocksize, "i"); diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/block/swim3.c linux-2.5/drivers/block/swim3.c --- linux-2.5.1/drivers/block/swim3.c Sun Dec 16 20:23:05 2001 +++ linux-2.5/drivers/block/swim3.c Thu Dec 27 16:32:31 2001 @@ -29,14 +29,15 @@ #include <asm/prom.h> #include <asm/uaccess.h> #include <asm/mediabay.h> -#include <asm/feature.h> +#include <asm/machdep.h> +#include <asm/pmac_feature.h> #define MAJOR_NR FLOPPY_MAJOR #include <linux/blk.h> #include <linux/devfs_fs_kernel.h> static int floppy_blocksizes[2] = {512,512}; -static int floppy_sizes[2] = {2880,2880}; +static int floppy_sizes[2] = {1440,1440}; #define MAX_FLOPPIES 2 @@ -445,9 +446,9 @@ ++cp; init_dma(cp, OUTPUT_MORE, CURRENT->buffer, 512); ++cp; - init_dma(cp, OUTPUT_MORE, write_postamble, sizeof(write_postamble)); + init_dma(cp, OUTPUT_LAST, write_postamble, sizeof(write_postamble)); } else { - init_dma(cp, INPUT_MORE, CURRENT->buffer, n * 512); + init_dma(cp, INPUT_LAST, CURRENT->buffer, n * 512); } ++cp; out_le16(&cp->command, DBDMA_STOP); @@ -679,7 +680,10 @@ break; dr = fs->dma; cp = fs->dma_cmd; - st_le32(&dr->control, RUN << 16); + /* We must wait a bit for dbdma to complete */ + for (n=0; (in_le32(&dr->status) & ACTIVE) && n < 1000; n++) + udelay(10); + DBDMA_DO_STOP(dr); out_8(&sw->intr_enable, 0); out_8(&sw->control_bic, WRITE_SECTORS | DO_ACTION); out_8(&sw->select, RELAX); @@ -1061,9 +1065,14 @@ return -EINVAL; } + if (!request_OF_resource(swim, 0, NULL)) { + printk(KERN_INFO "swim3: can't request IO resource !\n"); + return -EINVAL; + } + mediabay = (strcasecmp(swim->parent->type, "media-bay") == 0) ? swim->parent : NULL; if (mediabay == NULL) - feature_set(swim, FEATURE_SWIM3_enable); + pmac_call_feature(PMAC_FTR_SWIM3_ENABLE, swim, 0, 1); memset(fs, 0, sizeof(*fs)); fs->state = idle; @@ -1085,14 +1094,14 @@ if (request_irq(fs->swim3_intr, swim3_interrupt, 0, "SWIM3", fs)) { printk(KERN_ERR "Couldn't get irq %d for SWIM3\n", fs->swim3_intr); - feature_clear(swim, FEATURE_SWIM3_enable); + pmac_call_feature(PMAC_FTR_SWIM3_ENABLE, swim, 0, 0); return -EBUSY; } /* if (request_irq(fs->dma_intr, fd_dma_interrupt, 0, "SWIM3-dma", fs)) { printk(KERN_ERR "Couldn't get irq %d for SWIM3 DMA", fs->dma_intr); - feature_clear(swim, FEATURE_SWIM3_enable); + pmac_call_feature(PMAC_FTR_SWIM3_ENABLE, swim, 0, 0); return -EBUSY; } */ diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/cdrom/cdrom.c linux-2.5/drivers/cdrom/cdrom.c --- linux-2.5.1/drivers/cdrom/cdrom.c Thu Dec 6 22:02:56 2001 +++ linux-2.5/drivers/cdrom/cdrom.c Sun Dec 30 21:17:30 2001 @@ -266,7 +266,6 @@ #include <linux/init.h> #include <asm/fcntl.h> -#include <asm/segment.h> #include <asm/uaccess.h> /* used to tell the module to turn on full debugging messages */ diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/cdrom/cdu31a.c linux-2.5/drivers/cdrom/cdu31a.c --- linux-2.5.1/drivers/cdrom/cdu31a.c Tue Nov 27 17:23:27 2001 +++ linux-2.5/drivers/cdrom/cdu31a.c Sun Dec 30 20:01:41 2001 @@ -237,6 +237,7 @@ static volatile unsigned short sony_cd_read_reg; static volatile unsigned short sony_cd_fifost_reg; +static spinlock_t cdu31a_lock = SPIN_LOCK_UNLOCKED; /* queue lock */ static int sony_spun_up = 0; /* Has the drive been spun up? */ @@ -1605,17 +1606,7 @@ scd_spinup(); } - /* I don't use INIT_REQUEST because it calls return, which would - return without unlocking the device. It shouldn't matter, - but just to be safe... */ - if (MAJOR(CURRENT->rq_dev) != MAJOR_NR) { - panic(DEVICE_NAME ": request list destroyed"); - } - if (CURRENT->bh) { - if (!buffer_locked(CURRENT->bh)) { - panic(DEVICE_NAME ": block not locked"); - } - } + INIT_REQUEST; block = CURRENT->sector; nblock = CURRENT->nr_sectors; @@ -1626,112 +1617,105 @@ goto cdu31a_request_startover; } - switch (CURRENT->cmd) { - case READ: - /* - * If the block address is invalid or the request goes beyond the end of - * the media, return an error. - */ -#if 0 - if ((block / 4) < sony_toc.start_track_lba) { - printk - ("CDU31A: Request before beginning of media\n"); - end_request(0); - goto cdu31a_request_startover; - } -#endif - if ((block / 4) >= sony_toc.lead_out_start_lba) { - printk - ("CDU31A: Request past end of media\n"); - end_request(0); - goto cdu31a_request_startover; - } - if (((block + nblock) / 4) >= - sony_toc.lead_out_start_lba) { - printk - ("CDU31A: Request past end of media\n"); - end_request(0); - goto cdu31a_request_startover; - } - - num_retries = 0; - - try_read_again: - while (handle_sony_cd_attention()); - - if (!sony_toc_read) { - printk("CDU31A: TOC not read\n"); - end_request(0); - goto cdu31a_request_startover; - } - - /* If no data is left to be read from the drive, start the - next request. */ - if (sony_blocks_left == 0) { - if (start_request - (block / 4, CDU31A_READAHEAD / 4, 0)) { - end_request(0); - goto cdu31a_request_startover; - } - } - /* If the requested block is not the next one waiting in - the driver, abort the current operation and start a - new one. */ - else if (block != sony_next_block) { -#if DEBUG - printk - ("CDU31A Warning: Read for block %d, expected %d\n", - block, sony_next_block); -#endif - abort_read(); - if (!sony_toc_read) { - printk("CDU31A: TOC not read\n"); + if(CURRENT->flags & REQ_CMD) { + switch (rq_data_dir(CURRENT)) { + case READ: + /* + * If the block address is invalid or the request goes beyond the end of + * the media, return an error. + */ + if ((block / 4) >= sony_toc.lead_out_start_lba) { + printk + ("CDU31A: Request past end of media\n"); end_request(0); goto cdu31a_request_startover; } - if (start_request - (block / 4, CDU31A_READAHEAD / 4, 0)) { + if (((block + nblock) / 4) >= + sony_toc.lead_out_start_lba) { printk - ("CDU31a: start request failed\n"); + ("CDU31A: Request past end of media\n"); end_request(0); goto cdu31a_request_startover; } - } - read_data_block(CURRENT->buffer, block, nblock, - res_reg, &res_size); - if (res_reg[0] == 0x20) { - if (num_retries > MAX_CDU31A_RETRIES) { + num_retries = 0; + + try_read_again: + while (handle_sony_cd_attention()); + + if (!sony_toc_read) { + printk("CDU31A: TOC not read\n"); end_request(0); goto cdu31a_request_startover; } - num_retries++; - if (res_reg[1] == SONY_NOT_SPIN_ERR) { - do_sony_cd_cmd(SONY_SPIN_UP_CMD, - NULL, 0, res_reg, - &res_size); - } else { + /* If no data is left to be read from the drive, start the + next request. */ + if (sony_blocks_left == 0) { + if (start_request + (block / 4, CDU31A_READAHEAD / 4, 0)) { + end_request(0); + goto cdu31a_request_startover; + } + } + /* If the requested block is not the next one waiting in + the driver, abort the current operation and start a + new one. */ + else if (block != sony_next_block) { +#if DEBUG printk - ("CDU31A: %s error for block %d, nblock %d\n", - translate_error(res_reg[1]), - block, nblock); + ("CDU31A Warning: Read for block %d, expected %d\n", + block, sony_next_block); +#endif + abort_read(); + if (!sony_toc_read) { + printk("CDU31A: TOC not read\n"); + end_request(0); + goto cdu31a_request_startover; + } + if (start_request + (block / 4, CDU31A_READAHEAD / 4, 0)) { + printk + ("CDU31a: start request failed\n"); + end_request(0); + goto cdu31a_request_startover; + } } - goto try_read_again; - } else { - end_request(1); - } - break; - case WRITE: - end_request(0); - break; + read_data_block(CURRENT->buffer, block, nblock, + res_reg, &res_size); + if (res_reg[0] == 0x20) { + if (num_retries > MAX_CDU31A_RETRIES) { + end_request(0); + goto cdu31a_request_startover; + } - default: - panic("CDU31A: Unknown cmd"); + num_retries++; + if (res_reg[1] == SONY_NOT_SPIN_ERR) { + do_sony_cd_cmd(SONY_SPIN_UP_CMD, + NULL, 0, res_reg, + &res_size); + } else { + printk + ("CDU31A: %s error for block %d, nblock %d\n", + translate_error(res_reg[1]), + block, nblock); + } + goto try_read_again; + } else { + end_request(1); + } + break; + + case WRITE: + end_request(0); + break; + + default: + panic("CDU31A: Unknown cmd"); + } } } - end_do_cdu31a_request: spin_lock_irq(&q->queue_lock); #if 0 @@ -3456,7 +3440,8 @@ strcmp("CD-ROM CDU31A", drive_config.product_id) == 0; blk_init_queue(BLK_DEFAULT_QUEUE(MAJOR_NR), - DEVICE_REQUEST); + DEVICE_REQUEST, + &cdu31a_lock); read_ahead[MAJOR_NR] = CDU31A_READAHEAD; cdu31a_block_size = 1024; /* 1kB default block size */ /* use 'mount -o block=2048' */ diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/char/Config.in linux-2.5/drivers/char/Config.in --- linux-2.5.1/drivers/char/Config.in Mon Nov 12 17:34:16 2001 +++ linux-2.5/drivers/char/Config.in Thu Dec 27 15:14:59 2001 @@ -16,7 +16,7 @@ tristate ' Dual serial port support' CONFIG_DUALSP_SERIAL fi fi -if [ "$CONFIG_ACPI" = "y" ]; then +if [ "$CONFIG_ACPI" = "y" -a "$CONFIG_IA64" = "y" ]; then bool ' Support for serial ports defined by ACPI tables' CONFIG_SERIAL_ACPI fi dep_mbool 'Extended dumb serial driver options' CONFIG_SERIAL_EXTENDED $CONFIG_SERIAL diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/char/agp/agpgart_be.c linux-2.5/drivers/char/agp/agpgart_be.c --- linux-2.5.1/drivers/char/agp/agpgart_be.c Fri Nov 30 16:52:41 2001 +++ linux-2.5/drivers/char/agp/agpgart_be.c Thu Dec 13 16:32:35 2001 @@ -409,8 +409,18 @@ * AGP devices and collect their data. */ - while ((device = pci_find_class(PCI_CLASS_DISPLAY_VGA << 8, - device)) != NULL) { + + pci_for_each_dev(device) + { + /* + * Enable AGP devices. Most will be VGA display but + * some may be coprocessors on non VGA devices too + */ + + if((((device->class >> 16) & 0xFF) != PCI_BASE_CLASS_DISPLAY) && + (device->class != (PCI_CLASS_PROCESSOR_CO << 8))) + continue; + pci_read_config_dword(device, 0x04, &scratch); if (!(scratch & 0x00100000)) @@ -3307,8 +3317,18 @@ * AGP devices and collect their data. */ - while ((device = pci_find_class(PCI_CLASS_DISPLAY_VGA << 8, - device)) != NULL) { + + pci_for_each_dev(device) + { + /* + * Enable AGP devices. Most will be VGA display but + * some may be coprocessors on non VGA devices too + */ + + if((((device->class >> 16) & 0xFF) != PCI_BASE_CLASS_DISPLAY) && + (device->class != (PCI_CLASS_PROCESSOR_CO << 8))) + continue; + pci_read_config_dword(device, 0x04, &scratch); if (!(scratch & 0x00100000)) diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/char/amiserial.c linux-2.5/drivers/char/amiserial.c --- linux-2.5.1/drivers/char/amiserial.c Mon Sep 17 04:22:56 2001 +++ linux-2.5/drivers/char/amiserial.c Sun Dec 30 19:12:33 2001 @@ -2143,7 +2143,9 @@ serial_driver.table = serial_table; serial_driver.termios = serial_termios; serial_driver.termios_locked = serial_termios_locked; - +#ifdef CONFIG_SERIAL_CONSOLE + serial_driver.console = &sercons; +#endif serial_driver.open = rs_open; serial_driver.close = rs_close; serial_driver.write = rs_write; diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/char/console.c linux-2.5/drivers/char/console.c --- linux-2.5.1/drivers/char/console.c Mon Oct 15 21:00:43 2001 +++ linux-2.5/drivers/char/console.c Mon Dec 31 18:25:55 2001 @@ -100,6 +100,7 @@ #include <linux/tqueue.h> #include <linux/bootmem.h> #include <linux/pm.h> +#include <linux/smp_lock.h> #include <asm/io.h> #include <asm/system.h> @@ -126,6 +127,7 @@ #define DEFAULT_BELL_DURATION (HZ/8) extern void vcs_make_devfs (unsigned int index, int unregister); +extern void console_map_init(void); #ifndef MIN #define MIN(a,b) ((a) < (b) ? (a) : (b)) @@ -2178,7 +2180,6 @@ name: "tty", write: vt_console_print, device: vt_console_device, - wait_key: keyboard_wait_for_keypress, unblank: unblank_screen, flags: CON_PRINTBUFFER, index: -1, @@ -2348,17 +2349,25 @@ set_leds(); } +/* + * we can race here against con_close, so we grab the bkl + * and check the pointer before calling set_cursor + */ static void con_flush_chars(struct tty_struct *tty) { - struct vt_struct *vt = (struct vt_struct *)tty->driver_data; + struct vt_struct *vt; if (in_interrupt()) /* from flush_to_ldisc */ return; pm_access(pm_con); + lock_kernel(); acquire_console_sem(); - set_cursor(vt->vc_num); + vt = (struct vt_struct *)tty->driver_data; + if (vt) + set_cursor(vt->vc_num); release_console_sem(); + unlock_kernel(); } /* @@ -2441,42 +2450,6 @@ return; } - memset(&console_driver, 0, sizeof(struct tty_driver)); - console_driver.magic = TTY_DRIVER_MAGIC; - console_driver.name = "vc/%d"; - console_driver.name_base = 1; - console_driver.major = TTY_MAJOR; - console_driver.minor_start = 1; - console_driver.num = MAX_NR_CONSOLES; - console_driver.type = TTY_DRIVER_TYPE_CONSOLE; - console_driver.init_termios = tty_std_termios; - console_driver.flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_RESET_TERMIOS; - /* Tell tty_register_driver() to skip consoles because they are - * registered before kmalloc() is ready. We'll patch them in later. - * See comments at console_init(); see also con_init_devfs(). - */ - console_driver.flags |= TTY_DRIVER_NO_DEVFS; - console_driver.refcount = &console_refcount; - console_driver.table = console_table; - console_driver.termios = console_termios; - console_driver.termios_locked = console_termios_locked; - - console_driver.open = con_open; - console_driver.close = con_close; - console_driver.write = con_write; - console_driver.write_room = con_write_room; - console_driver.put_char = con_put_char; - console_driver.flush_chars = con_flush_chars; - console_driver.chars_in_buffer = con_chars_in_buffer; - console_driver.ioctl = vt_ioctl; - console_driver.stop = con_stop; - console_driver.start = con_start; - console_driver.throttle = con_throttle; - console_driver.unthrottle = con_unthrottle; - - if (tty_register_driver(&console_driver)) - panic("Couldn't register console driver\n"); - init_timer(&console_timer); console_timer.function = blank_screen; if (blankinterval) { @@ -2515,6 +2488,47 @@ #endif } +int __init vty_init(void) +{ + memset(&console_driver, 0, sizeof(struct tty_driver)); + console_driver.magic = TTY_DRIVER_MAGIC; + console_driver.name = "vc/%d"; + console_driver.name_base = 1; + console_driver.major = TTY_MAJOR; + console_driver.minor_start = 1; + console_driver.num = MAX_NR_CONSOLES; + console_driver.type = TTY_DRIVER_TYPE_CONSOLE; + console_driver.init_termios = tty_std_termios; + console_driver.flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_RESET_TERMIOS; + console_driver.refcount = &console_refcount; + console_driver.table = console_table; + console_driver.termios = console_termios; + console_driver.termios_locked = console_termios_locked; +#ifdef CONFIG_VT_CONSOLE + console_driver.console = &vt_console_driver; +#endif + console_driver.open = con_open; + console_driver.close = con_close; + console_driver.write = con_write; + console_driver.write_room = con_write_room; + console_driver.put_char = con_put_char; + console_driver.flush_chars = con_flush_chars; + console_driver.chars_in_buffer = con_chars_in_buffer; + console_driver.ioctl = vt_ioctl; + console_driver.stop = con_stop; + console_driver.start = con_start; + console_driver.throttle = con_throttle; + console_driver.unthrottle = con_unthrottle; + + if (tty_register_driver(&console_driver)) + panic("Couldn't register console driver\n"); + + kbd_init(); + console_map_init(); + vcs_init(); + return 0; +} + #ifndef VT_SINGLE_DRIVER static void clear_buffer_attributes(int currcons) @@ -2599,23 +2613,10 @@ static void set_vesa_blanking(unsigned long arg) { - char *argp = (char *)arg + 1; - unsigned int mode; - get_user(mode, argp); - vesa_blank_mode = (mode < 4) ? mode : 0; -} - -/* We can't register the console with devfs during con_init(), because it - * is called before kmalloc() works. This function is called later to - * do the registration. - */ -void __init con_init_devfs (void) -{ - int i; - - for (i = 0; i < console_driver.num; i++) - tty_register_devfs (&console_driver, DEVFS_FL_AOPEN_NOTIFY, - console_driver.minor_start + i); + char *argp = (char *)arg + 1; + unsigned int mode; + get_user(mode, argp); + vesa_blank_mode = (mode < 4) ? mode : 0; } /* diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/char/cyclades.c linux-2.5/drivers/char/cyclades.c --- linux-2.5.1/drivers/char/cyclades.c Fri Sep 14 21:04:07 2001 +++ linux-2.5/drivers/char/cyclades.c Sun Dec 30 19:12:33 2001 @@ -4965,6 +4965,8 @@ uclong Ze_addr0[NR_CARDS], Ze_addr2[NR_CARDS], ZeIndex = 0; uclong Ze_phys0[NR_CARDS], Ze_phys2[NR_CARDS]; unsigned char Ze_irq[NR_CARDS]; + struct resource *resource; + unsigned long res_start, res_len; for (i = 0; i < NR_CARDS; i++) { /* look for a Cyclades card by vendor and device id */ @@ -5012,7 +5014,15 @@ /* Although we don't use this I/O region, we should request it from the kernel anyway, to avoid problems with other drivers accessing it. */ - request_region(cy_pci_phys1, CyPCI_Yctl, "Cyclom-Y"); + resource = request_region(cy_pci_phys1, + CyPCI_Yctl, "Cyclom-Y"); + if (resource == NULL) { + printk(KERN_ERR "cyclades: failed to allocate IO " + "resource at 0x%lx\n", cy_pci_phys1); + continue; + } + res_start = cy_pci_phys1; + res_len = CyPCI_Yctl; #if defined(__alpha__) if (device_id == PCI_DEVICE_ID_CYCLOM_Y_Lo) { /* below 1M? */ @@ -5083,7 +5093,11 @@ cy_card[j].bus_index = 1; cy_card[j].first_line = cy_next_channel; cy_card[j].num_chips = cy_pci_nchan/4; - + cy_card[j].resource = resource; + cy_card[j].res_start = res_start; + cy_card[j].res_len = res_len; + resource = NULL; /* For next card */ + /* enable interrupts in the PCI interface */ plx_ver = cy_readb(cy_pci_addr2 + CyPLX_VER) & 0x0f; switch (plx_ver) { @@ -5162,8 +5176,16 @@ /* Although we don't use this I/O region, we should request it from the kernel anyway, to avoid problems with other drivers accessing it. */ - request_region(cy_pci_phys1, CyPCI_Zctl, "Cyclades-Z"); - + resource = request_region(cy_pci_phys1, + CyPCI_Zctl, "Cyclades-Z"); + if (resource == NULL) { + printk(KERN_ERR "cyclades: failed ot allocate IO resource " + "at 0x%lx\n", cy_pci_phys1); + continue; + } + res_start = cy_pci_phys1; + res_len = CyPCI_Zctl; + if (mailbox == ZE_V1) { cy_pci_addr2 = (ulong)ioremap(cy_pci_phys2, CyPCI_Ze_win); if (ZeIndex == NR_CARDS) { @@ -5261,6 +5283,10 @@ cy_card[j].bus_index = 1; cy_card[j].first_line = cy_next_channel; cy_card[j].num_chips = -1; + cy_card[j].resource = resource; + cy_card[j].res_start = res_start; + cy_card[j].res_len = res_len; + resource = NULL; /* For next card */ /* print message */ #ifdef CONFIG_CYZ_INTR @@ -5279,7 +5305,7 @@ printk("%d channels starting from port %d.\n", cy_pci_nchan,cy_next_channel); cy_next_channel += cy_pci_nchan; - } + } } for (; ZeIndex != 0 && i < NR_CARDS; i++) { @@ -5787,6 +5813,8 @@ #endif /* CONFIG_CYZ_INTR */ ) free_irq(cy_card[i].irq, &cy_card[i]); + if (cy_card[i].resource) + release_region(cy_card[i].res_start, cy_card[i].res_len); } } if (tmp_buf) { diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/char/drm/Config.in linux-2.5/drivers/char/drm/Config.in --- linux-2.5.1/drivers/char/drm/Config.in Wed Aug 8 16:42:10 2001 +++ linux-2.5/drivers/char/drm/Config.in Thu Dec 13 16:32:35 2001 @@ -13,4 +13,5 @@ dep_tristate ' ATI Radeon' CONFIG_DRM_RADEON $CONFIG_AGP dep_tristate ' Intel I810' CONFIG_DRM_I810 $CONFIG_AGP dep_tristate ' Matrox g200/g400' CONFIG_DRM_MGA $CONFIG_AGP + dep_tristate ' SiS' CONFIG_DRM_SIS $CONFIG_AGP fi diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/char/drm/Makefile linux-2.5/drivers/char/drm/Makefile --- linux-2.5.1/drivers/char/drm/Makefile Thu Aug 9 21:09:38 2001 +++ linux-2.5/drivers/char/drm/Makefile Thu Dec 13 16:32:35 2001 @@ -3,7 +3,7 @@ # Direct Rendering Infrastructure (DRI) in XFree86 4.1.0 and higher. O_TARGET := drm.o -list-multi := gamma.o tdfx.o r128.o mga.o i810.o radeon.o ffb.o +list-multi := gamma.o tdfx.o r128.o mga.o i810.o radeon.o ffb.o sis.o gamma-objs := gamma_drv.o gamma_dma.o tdfx-objs := tdfx_drv.o @@ -12,6 +12,7 @@ i810-objs := i810_drv.o i810_dma.o radeon-objs := radeon_drv.o radeon_cp.o radeon_state.o ffb-objs := ffb_drv.o ffb_context.o +sis-objs := sis_drv.o sis_ds.o sis_mm.o obj-$(CONFIG_DRM_GAMMA) += gamma.o obj-$(CONFIG_DRM_TDFX) += tdfx.o @@ -20,6 +21,7 @@ obj-$(CONFIG_DRM_MGA) += mga.o obj-$(CONFIG_DRM_I810) += i810.o obj-$(CONFIG_DRM_FFB) += ffb.o +obj-$(CONFIG_DRM_SIS) += sis.o include $(TOPDIR)/Rules.make @@ -43,3 +45,6 @@ ffb.o: $(ffb-objs) $(lib) $(LD) -r -o $@ $(ffb-objs) $(lib) + +sis.o: $(sis-objs) $(lib) + $(LD) -r -o $@ $(sis-objs) $(lib) diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/char/drm/drm.h linux-2.5/drivers/char/drm/drm.h --- linux-2.5.1/drivers/char/drm/drm.h Wed Aug 8 16:52:17 2001 +++ linux-2.5/drivers/char/drm/drm.h Mon Dec 31 21:55:16 2001 @@ -104,7 +104,7 @@ #include "i810_drm.h" #include "r128_drm.h" #include "radeon_drm.h" -#ifdef CONFIG_DRM_SIS +#if defined(CONFIG_DRM_SIS) || defined(CONFIG_DRM_SIS_MODULE) #include "sis_drm.h" #endif @@ -483,7 +483,7 @@ #define DRM_IOCTL_RADEON_INDIRECT DRM_IOWR(0x4d, drm_radeon_indirect_t) #define DRM_IOCTL_RADEON_TEXTURE DRM_IOWR(0x4e, drm_radeon_texture_t) -#ifdef CONFIG_DRM_SIS +#if defined(CONFIG_DRM_SIS) || defined(CONFIG_DRM_SIS_MODULE) /* SiS specific ioctls */ #define SIS_IOCTL_FB_ALLOC DRM_IOWR(0x44, drm_sis_mem_t) #define SIS_IOCTL_FB_FREE DRM_IOW( 0x45, drm_sis_mem_t) diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/char/drm/drm_context.h linux-2.5/drivers/char/drm/drm_context.h --- linux-2.5.1/drivers/char/drm/drm_context.h Sun Dec 16 23:43:58 2001 +++ linux-2.5/drivers/char/drm/drm_context.h Mon Dec 31 21:55:16 2001 @@ -27,6 +27,10 @@ * Authors: * Rickard E. (Rik) Faith <faith@valinux.com> * Gareth Hughes <gareth@valinux.com> + * ChangeLog: + * 2001-11-16 Torsten Duwe <duwe@caldera.de> + * added context constructor/destructor hooks, + * needed by SiS driver's memory management. */ #define __NO_VERSION__ @@ -316,6 +320,10 @@ /* Should this return -EBUSY instead? */ return -ENOMEM; } +#ifdef DRIVER_CTX_CTOR + if ( ctx.handle != DRM_KERNEL_CONTEXT ) + DRIVER_CTX_CTOR(ctx.handle); /* XXX: also pass dev ? */ +#endif if ( copy_to_user( (drm_ctx_t *)arg, &ctx, sizeof(ctx) ) ) return -EFAULT; @@ -390,6 +398,9 @@ priv->remove_auth_on_close = 1; } if ( ctx.handle != DRM_KERNEL_CONTEXT ) { +#ifdef DRIVER_CTX_DTOR + DRIVER_CTX_DTOR(ctx.handle); /* XXX: also pass dev ? */ +#endif DRM(ctxbitmap_free)( dev, ctx.handle ); } diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/char/drm/sis.h linux-2.5/drivers/char/drm/sis.h --- linux-2.5.1/drivers/char/drm/sis.h Thu Jan 1 00:00:00 1970 +++ linux-2.5/drivers/char/drm/sis.h Thu Dec 13 16:32:35 2001 @@ -0,0 +1,56 @@ +/* sis_drv.h -- Private header for sis driver -*- linux-c -*- + * + * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas. + * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California. + * All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/sis.h,v 1.1 2001/05/19 18:29:22 dawes Exp $ */ + +#ifndef __SIS_H__ +#define __SIS_H__ + +/* This remains constant for all DRM template files. + * Name it sisdrv_##x as there's a conflict with sis_free/malloc in the kernel + * that's used for fb devices + */ +#define DRM(x) sisdrv_##x + +/* General customization: + */ +#define __HAVE_AGP 1 +#define __MUST_HAVE_AGP 0 +#define __HAVE_MTRR 1 +#define __HAVE_CTX_BITMAP 1 + +/* Buffer customization: + */ +#define DRIVER_AGP_BUFFERS_MAP( dev ) \ + ((drm_sis_private_t *)((dev)->dev_private))->buffers + +extern int sis_init_context(int context); +extern int sis_final_context(int context); + +#define DRIVER_CTX_CTOR sis_init_context +#define DRIVER_CTX_DTOR sis_final_context + +#endif diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/char/drm/sis_drm.h linux-2.5/drivers/char/drm/sis_drm.h --- linux-2.5.1/drivers/char/drm/sis_drm.h Thu Jan 1 00:00:00 1970 +++ linux-2.5/drivers/char/drm/sis_drm.h Thu Dec 13 16:32:35 2001 @@ -0,0 +1,36 @@ + +#ifndef _sis_drm_public_h_ +#define _sis_drm_public_h_ + +typedef struct { + int context; + unsigned int offset; + unsigned int size; + unsigned int free; +} drm_sis_mem_t; + +typedef struct { + unsigned int offset, size; +} drm_sis_agp_t; + +typedef struct { + unsigned int left, right; +} drm_sis_flip_t; + +#ifdef __KERNEL__ + +int sis_fb_alloc(struct inode *inode, struct file *filp, unsigned int cmd, + unsigned long arg); +int sis_fb_free(struct inode *inode, struct file *filp, unsigned int cmd, + unsigned long arg); + +int sisp_agp_init(struct inode *inode, struct file *filp, unsigned int cmd, + unsigned long arg); +int sisp_agp_alloc(struct inode *inode, struct file *filp, unsigned int cmd, + unsigned long arg); +int sisp_agp_free(struct inode *inode, struct file *filp, unsigned int cmd, + unsigned long arg); + +#endif + +#endif diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/char/drm/sis_drv.c linux-2.5/drivers/char/drm/sis_drv.c --- linux-2.5.1/drivers/char/drm/sis_drv.c Thu Jan 1 00:00:00 1970 +++ linux-2.5/drivers/char/drm/sis_drv.c Thu Dec 13 16:32:35 2001 @@ -0,0 +1,74 @@ +/* sis.c -- sis driver -*- linux-c -*- + * + * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas. + * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + */ + +#include <linux/config.h> +#include "sis.h" +#include "drmP.h" +#include "sis_drm.h" +#include "sis_drv.h" + +#define DRIVER_AUTHOR "SIS" +#define DRIVER_NAME "sis" +#define DRIVER_DESC "SIS 300/630/540" +#define DRIVER_DATE "20010503" +#define DRIVER_MAJOR 1 +#define DRIVER_MINOR 0 +#define DRIVER_PATCHLEVEL 0 + +#define DRIVER_IOCTLS \ + [DRM_IOCTL_NR(SIS_IOCTL_FB_ALLOC)] = { sis_fb_alloc, 1, 1 }, \ + [DRM_IOCTL_NR(SIS_IOCTL_FB_FREE)] = { sis_fb_free, 1, 1 }, \ + /* AGP Memory Management */ \ + [DRM_IOCTL_NR(SIS_IOCTL_AGP_INIT)] = { sisp_agp_init, 1, 1 }, \ + [DRM_IOCTL_NR(SIS_IOCTL_AGP_ALLOC)] = { sisp_agp_alloc, 1, 1 }, \ + [DRM_IOCTL_NR(SIS_IOCTL_AGP_FREE)] = { sisp_agp_free, 1, 1 } +#if 0 /* these don't appear to be defined */ + /* SIS Stereo */ + [DRM_IOCTL_NR(DRM_IOCTL_CONTROL)] = { sis_control, 1, 1 }, + [DRM_IOCTL_NR(SIS_IOCTL_FLIP)] = { sis_flip, 1, 1 }, + [DRM_IOCTL_NR(SIS_IOCTL_FLIP_INIT)] = { sis_flip_init, 1, 1 }, + [DRM_IOCTL_NR(SIS_IOCTL_FLIP_FINAL)] = { sis_flip_final, 1, 1 } +#endif + +#define __HAVE_COUNTERS 5 + +#include "drm_auth.h" +#include "drm_agpsupport.h" +#include "drm_bufs.h" +#include "drm_context.h" +#include "drm_dma.h" +#include "drm_drawable.h" +#include "drm_drv.h" +#include "drm_fops.h" +#include "drm_init.h" +#include "drm_ioctl.h" +#include "drm_lists.h" +#include "drm_lock.h" +#include "drm_memory.h" +#include "drm_proc.h" +#include "drm_vm.h" +#include "drm_stub.h" diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/char/drm/sis_drv.h linux-2.5/drivers/char/drm/sis_drv.h --- linux-2.5.1/drivers/char/drm/sis_drv.h Thu Jan 1 00:00:00 1970 +++ linux-2.5/drivers/char/drm/sis_drv.h Thu Dec 13 16:32:35 2001 @@ -0,0 +1,45 @@ +/* sis_drv.h -- Private header for sis driver -*- linux-c -*- + * + * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas. + * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California. + * All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + */ + +#ifndef _SIS_DRV_H_ +#define _SIS_DRV_H_ + +typedef struct drm_sis_private { + drm_map_t *buffers; +} drm_sis_private_t; + +/* Stereo ? - this was never committed */ + +int sis_flip(struct inode *inode, struct file *filp, unsigned int cmd, + unsigned long arg); +int sis_flip_init(struct inode *inode, struct file *filp, unsigned int cmd, + unsigned long arg); +int sis_flip_final(struct inode *inode, struct file *filp, unsigned int cmd, + unsigned long arg); +void flip_final(void); + +#endif diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/char/drm/sis_ds.c linux-2.5/drivers/char/drm/sis_ds.c --- linux-2.5.1/drivers/char/drm/sis_ds.c Thu Jan 1 00:00:00 1970 +++ linux-2.5/drivers/char/drm/sis_ds.c Thu Dec 13 16:32:35 2001 @@ -0,0 +1,406 @@ +/* sis_ds.c -- Private header for Direct Rendering Manager -*- linux-c -*- + * Created: Mon Jan 4 10:05:05 1999 by sclin@sis.com.tw + * + * Copyright 2000 Silicon Integrated Systems Corp, Inc., HsinChu, Taiwan. + * All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + * Authors: + * Sung-Ching Lin <sclin@sis.com.tw> + * + */ + +#define __NO_VERSION__ +#include <linux/module.h> +#include <linux/delay.h> +#include <linux/errno.h> +#include <linux/kernel.h> +#include <linux/malloc.h> +#include <linux/poll.h> +#include <asm/io.h> +#include <linux/pci.h> + +#include "sis_ds.h" + +/* Set Data Structure, not check repeated value + * temporarily used + */ + +set_t *setInit(void) +{ + int i; + set_t *set; + + set = (set_t *)MALLOC(sizeof(set_t)); + for(i = 0; i < SET_SIZE; i++){ + set->list[i].free_next = i+1; + set->list[i].alloc_next = -1; + } + set->list[SET_SIZE-1].free_next = -1; + set->free = 0; + set->alloc = -1; + set->trace = -1; + + return set; +} + +int setAdd(set_t *set, ITEM_TYPE item) +{ + int free = set->free; + + if(free != -1){ + set->list[free].val = item; + set->free = set->list[free].free_next; + } + else{ + return 0; + } + + set->list[free].alloc_next = set->alloc; + set->alloc = free; + set->list[free].free_next = -1; + + return 1; +} + +int setDel(set_t *set, ITEM_TYPE item) +{ + int alloc = set->alloc; + int prev = -1; + + while(alloc != -1){ + if(set->list[alloc].val == item){ + if(prev != -1) + set->list[prev].alloc_next = set->list[alloc].alloc_next; + else + set->alloc = set->list[alloc].alloc_next; + break; + } + prev = alloc; + alloc = set->list[alloc].alloc_next; + } + + if(alloc == -1) + return 0; + + set->list[alloc].free_next = set->free; + set->free = alloc; + set->list[alloc].alloc_next = -1; + + return 1; +} + +/* setFirst -> setAdd -> setNext is wrong */ + +int setFirst(set_t *set, ITEM_TYPE *item) +{ + if(set->alloc == -1) + return 0; + + *item = set->list[set->alloc].val; + set->trace = set->list[set->alloc].alloc_next; + + return 1; +} + +int setNext(set_t *set, ITEM_TYPE *item) +{ + if(set->trace == -1) + return 0; + + *item = set->list[set->trace].val; + set->trace = set->list[set->trace].alloc_next; + + return 1; +} + +int setDestroy(set_t *set) +{ + FREE(set); + + return 1; +} + +/* + * GLX Hardware Device Driver common code + * Copyright (C) 1999 Keith Whitwell + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * KEITH WHITWELL, OR ANY OTHER CONTRIBUTORS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR + * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE + * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + */ + +#define ISFREE(bptr) ((bptr)->free) + +#define PRINTF(fmt, arg...) do{}while(0) +#define fprintf(fmt, arg...) do{}while(0) + +static void *calloc(size_t nmemb, size_t size) +{ + void *addr; + addr = kmalloc(nmemb*size, GFP_KERNEL); + memset(addr, 0, nmemb*size); + return addr; +} +#define free(n) kfree(n) + +void mmDumpMemInfo( memHeap_t *heap ) +{ + TMemBlock *p; + + PRINTF ("Memory heap %p:\n", heap); + if (heap == 0) { + PRINTF (" heap == 0\n"); + } else { + p = (TMemBlock *)heap; + while (p) { + PRINTF (" Offset:%08x, Size:%08x, %c%c\n",p->ofs,p->size, + p->free ? '.':'U', + p->reserved ? 'R':'.'); + p = p->next; + } + } + PRINTF ("End of memory blocks\n"); +} + +memHeap_t *mmInit(int ofs, + int size) +{ + PMemBlock blocks; + + if (size <= 0) { + return 0; + } + blocks = (TMemBlock *) calloc(1,sizeof(TMemBlock)); + if (blocks) { + blocks->ofs = ofs; + blocks->size = size; + blocks->free = 1; + return (memHeap_t *)blocks; + } else + return 0; +} + +/* Kludgey workaround for existing i810 server. Remove soon. + */ +memHeap_t *mmAddRange( memHeap_t *heap, + int ofs, + int size ) +{ + PMemBlock blocks; + blocks = (TMemBlock *) calloc(2,sizeof(TMemBlock)); + if (blocks) { + blocks[0].size = size; + blocks[0].free = 1; + blocks[0].ofs = ofs; + blocks[0].next = &blocks[1]; + + /* Discontinuity - stops JoinBlock from trying to join non-adjacent + * ranges. + */ + blocks[1].size = 0; + blocks[1].free = 0; + blocks[1].ofs = ofs+size; + blocks[1].next = (PMemBlock) heap; + return (memHeap_t *)blocks; + } + else + return heap; +} + +static TMemBlock* SliceBlock(TMemBlock *p, + int startofs, int size, + int reserved, int alignment) +{ + TMemBlock *newblock; + + /* break left */ + if (startofs > p->ofs) { + newblock = (TMemBlock*) calloc(1,sizeof(TMemBlock)); + newblock->ofs = startofs; + newblock->size = p->size - (startofs - p->ofs); + newblock->free = 1; + newblock->next = p->next; + p->size -= newblock->size; + p->next = newblock; + p = newblock; + } + + /* break right */ + if (size < p->size) { + newblock = (TMemBlock*) calloc(1,sizeof(TMemBlock)); + newblock->ofs = startofs + size; + newblock->size = p->size - size; + newblock->free = 1; + newblock->next = p->next; + p->size = size; + p->next = newblock; + } + + /* p = middle block */ + p->align = alignment; + p->free = 0; + p->reserved = reserved; + return p; +} + +PMemBlock mmAllocMem( memHeap_t *heap, int size, int align2, int startSearch) +{ + int mask,startofs,endofs; + TMemBlock *p; + + if (!heap || align2 < 0 || size <= 0) + return NULL; + mask = (1 << align2)-1; + startofs = 0; + p = (TMemBlock *)heap; + while (p) { + if (ISFREE(p)) { + startofs = (p->ofs + mask) & ~mask; + if ( startofs < startSearch ) { + startofs = startSearch; + } + endofs = startofs+size; + if (endofs <= (p->ofs+p->size)) + break; + } + p = p->next; + } + if (!p) + return NULL; + p = SliceBlock(p,startofs,size,0,mask+1); + p->heap = heap; + return p; +} + +static __inline__ int Join2Blocks(TMemBlock *p) +{ + if (p->free && p->next && p->next->free) { + TMemBlock *q = p->next; + p->size += q->size; + p->next = q->next; + free(q); + return 1; + } + return 0; +} + +int mmFreeMem(PMemBlock b) +{ + TMemBlock *p,*prev; + + if (!b) + return 0; + if (!b->heap) { + fprintf(stderr, "no heap\n"); + return -1; + } + p = b->heap; + prev = NULL; + while (p && p != b) { + prev = p; + p = p->next; + } + if (!p || p->free || p->reserved) { + if (!p) + fprintf(stderr, "block not found in heap\n"); + else if (p->free) + fprintf(stderr, "block already free\n"); + else + fprintf(stderr, "block is reserved\n"); + return -1; + } + p->free = 1; + Join2Blocks(p); + if (prev) + Join2Blocks(prev); + return 0; +} + +int mmReserveMem(memHeap_t *heap, int offset,int size) +{ + int endofs; + TMemBlock *p; + + if (!heap || size <= 0) + return -1; + endofs = offset+size; + p = (TMemBlock *)heap; + while (p && p->ofs <= offset) { + if (ISFREE(p) && endofs <= (p->ofs+p->size)) { + SliceBlock(p,offset,size,1,1); + return 0; + } + p = p->next; + } + return -1; +} + +int mmFreeReserved(memHeap_t *heap, int offset) +{ + TMemBlock *p,*prev; + + if (!heap) + return -1; + p = (TMemBlock *)heap; + prev = NULL; + while (p && p->ofs != offset) { + prev = p; + p = p->next; + } + if (!p || !p->reserved) + return -1; + p->free = 1; + p->reserved = 0; + Join2Blocks(p); + if (prev) + Join2Blocks(prev); + return 0; +} + +void mmDestroy(memHeap_t *heap) +{ + TMemBlock *p,*q; + + if (!heap) + return; + p = (TMemBlock *)heap; + while (p) { + q = p->next; + free(p); + p = q; + } +} diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/char/drm/sis_ds.h linux-2.5/drivers/char/drm/sis_ds.h --- linux-2.5.1/drivers/char/drm/sis_ds.h Thu Jan 1 00:00:00 1970 +++ linux-2.5/drivers/char/drm/sis_ds.h Thu Dec 13 16:32:35 2001 @@ -0,0 +1,163 @@ +/* sis_ds.h -- Private header for Direct Rendering Manager -*- linux-c -*- + * Created: Mon Jan 4 10:05:05 1999 by sclin@sis.com.tw + * + * Copyright 2000 Silicon Integrated Systems Corp, Inc., HsinChu, Taiwan. + * All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + * Authors: + * Sung-Ching Lin <sclin@sis.com.tw> + * + */ + +#ifndef _sis_ds_h_ +#define _sis_ds_h_ + +/* Set Data Structure */ + +#define SET_SIZE 5000 +#define MALLOC(s) kmalloc(s, GFP_KERNEL) +#define FREE(s) kfree(s) + +typedef unsigned int ITEM_TYPE; + +typedef struct { + ITEM_TYPE val; + int alloc_next, free_next; +} list_item_t; + +typedef struct { + int alloc; + int free; + int trace; + list_item_t list[SET_SIZE]; +} set_t; + +set_t *setInit(void); +int setAdd(set_t *set, ITEM_TYPE item); +int setDel(set_t *set, ITEM_TYPE item); +int setFirst(set_t *set, ITEM_TYPE *item); +int setNext(set_t *set, ITEM_TYPE *item); +int setDestroy(set_t *set); + +#endif + +/* + * GLX Hardware Device Driver common code + * Copyright (C) 1999 Keith Whitwell + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * KEITH WHITWELL, OR ANY OTHER CONTRIBUTORS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR + * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE + * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + */ + +#ifndef MM_INC +#define MM_INC + +struct mem_block_t { + struct mem_block_t *next; + struct mem_block_t *heap; + int ofs,size; + int align; + int free:1; + int reserved:1; +}; +typedef struct mem_block_t TMemBlock; +typedef struct mem_block_t *PMemBlock; + +/* a heap is just the first block in a chain */ +typedef struct mem_block_t memHeap_t; + +static __inline__ int mmBlockSize(PMemBlock b) +{ return b->size; } + +static __inline__ int mmOffset(PMemBlock b) +{ return b->ofs; } + +static __inline__ void mmMarkReserved(PMemBlock b) +{ b->reserved = 1; } + +/* + * input: total size in bytes + * return: a heap pointer if OK, NULL if error + */ +memHeap_t *mmInit( int ofs, int size ); + + + +memHeap_t *mmAddRange( memHeap_t *heap, + int ofs, + int size ); + + +/* + * Allocate 'size' bytes with 2^align2 bytes alignment, + * restrict the search to free memory after 'startSearch' + * depth and back buffers should be in different 4mb banks + * to get better page hits if possible + * input: size = size of block + * align2 = 2^align2 bytes alignment + * startSearch = linear offset from start of heap to begin search + * return: pointer to the allocated block, 0 if error + */ +PMemBlock mmAllocMem( memHeap_t *heap, int size, int align2, int startSearch ); + +/* + * Free block starts at offset + * input: pointer to a block + * return: 0 if OK, -1 if error + */ +int mmFreeMem( PMemBlock b ); + +/* + * Reserve 'size' bytes block start at offset + * This is used to prevent allocation of memory already used + * by the X server for the front buffer, pixmaps, and cursor + * input: size, offset + * output: 0 if OK, -1 if error + */ +int mmReserveMem( memHeap_t *heap, int offset,int size ); +int mmFreeReserved( memHeap_t *heap, int offset ); + +/* + * destroy MM + */ +void mmDestroy( memHeap_t *mmInit ); + +/* For debuging purpose. */ +void mmDumpMemInfo( memHeap_t *mmInit ); + +#endif diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/char/drm/sis_mm.c linux-2.5/drivers/char/drm/sis_mm.c --- linux-2.5.1/drivers/char/drm/sis_mm.c Thu Jan 1 00:00:00 1970 +++ linux-2.5/drivers/char/drm/sis_mm.c Thu Dec 13 16:32:35 2001 @@ -0,0 +1,307 @@ +/* sis_mm.c -- Private header for Direct Rendering Manager -*- linux-c -*- + * Created: Mon Jan 4 10:05:05 1999 by sclin@sis.com.tw + * + * Copyright 2000 Silicon Integrated Systems Corp, Inc., HsinChu, Taiwan. + * All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + * Authors: + * Sung-Ching Lin <sclin@sis.com.tw> + * + */ + +#define __NO_VERSION__ +#include "sis.h" +#include <linux/sisfb.h> +#include "drmP.h" +#include "sis_drm.h" +#include "sis_drv.h" +#include "sis_ds.h" + +#define MAX_CONTEXT 100 +#define VIDEO_TYPE 0 +#define AGP_TYPE 1 + +typedef struct { + int used; + int context; + set_t *sets[2]; /* 0 for video, 1 for AGP */ +} sis_context_t; + +static sis_context_t global_ppriv[MAX_CONTEXT]; + +static int add_alloc_set(int context, int type, unsigned int val) +{ + int i, retval = 0; + + for(i = 0; i < MAX_CONTEXT; i++) + if(global_ppriv[i].used && global_ppriv[i].context == context){ + retval = setAdd(global_ppriv[i].sets[type], val); + break; + } + return retval; +} + +static int del_alloc_set(int context, int type, unsigned int val) +{ + int i, retval = 0; + for(i = 0; i < MAX_CONTEXT; i++) + if(global_ppriv[i].used && global_ppriv[i].context == context){ + retval = setDel(global_ppriv[i].sets[type], val); + break; + } + return retval; +} + +/* fb management via fb device */ +#if 1 +int sis_fb_alloc(struct inode *inode, struct file *filp, unsigned int cmd, + unsigned long arg) +{ + drm_sis_mem_t fb; + struct sis_memreq req; + int retval = 0; + + if (copy_from_user(&fb, (drm_sis_mem_t *)arg, sizeof(fb))) + return -EFAULT; + + req.size = fb.size; + sis_malloc(&req); + if(req.offset){ + /* TODO */ + fb.offset = req.offset; + fb.free = req.offset; + if(!add_alloc_set(fb.context, VIDEO_TYPE, fb.free)){ + DRM_DEBUG("adding to allocation set fails\n"); + sis_free(req.offset); + retval = -1; + } + } + else{ + fb.offset = 0; + fb.size = 0; + fb.free = 0; + } + + if (copy_to_user((drm_sis_mem_t *)arg, &fb, sizeof(fb))) return -EFAULT; + + DRM_DEBUG("alloc fb, size = %d, offset = %ld\n", fb.size, req.offset); + + return retval; +} + +int sis_fb_free(struct inode *inode, struct file *filp, unsigned int cmd, + unsigned long arg) +{ + drm_sis_mem_t fb; + int retval = 0; + + if (copy_from_user(&fb, (drm_sis_mem_t *)arg, sizeof(fb))) + return -EFAULT; + + if(!fb.free){ + return -1; + } + + sis_free(fb.free); + if(!del_alloc_set(fb.context, VIDEO_TYPE, fb.free)) + retval = -1; + + DRM_DEBUG("free fb, offset = %d\n", fb.free); + + return retval; +} + +#else + +int sis_fb_alloc(struct inode *inode, struct file *filp, unsigned int cmd, + unsigned long arg) +{ + return -1; +} + +int sis_fb_free(struct inode *inode, struct file *filp, unsigned int cmd, + unsigned long arg) +{ + return 0; +} + +#endif + +/* agp memory management */ +#if 1 + +static memHeap_t *AgpHeap = NULL; + +int sisp_agp_init(struct inode *inode, struct file *filp, unsigned int cmd, + unsigned long arg) +{ + drm_sis_agp_t agp; + + if (copy_from_user(&agp, (drm_sis_agp_t *)arg, sizeof(agp))) + return -EFAULT; + + AgpHeap = mmInit(agp.offset, agp.size); + + DRM_DEBUG("offset = %u, size = %u", agp.offset, agp.size); + + return 0; +} + +int sisp_agp_alloc(struct inode *inode, struct file *filp, unsigned int cmd, + unsigned long arg) +{ + drm_sis_mem_t agp; + PMemBlock block; + int retval = 0; + + if(!AgpHeap) + return -1; + + if (copy_from_user(&agp, (drm_sis_mem_t *)arg, sizeof(agp))) + return -EFAULT; + + block = mmAllocMem(AgpHeap, agp.size, 0, 0); + if(block){ + /* TODO */ + agp.offset = block->ofs; + agp.free = (unsigned int)block; + if(!add_alloc_set(agp.context, AGP_TYPE, agp.free)){ + DRM_DEBUG("adding to allocation set fails\n"); + mmFreeMem((PMemBlock)agp.free); + retval = -1; + } + } + else{ + agp.offset = 0; + agp.size = 0; + agp.free = 0; + } + + if (copy_to_user((drm_sis_mem_t *)arg, &agp, sizeof(agp))) return -EFAULT; + + DRM_DEBUG("alloc agp, size = %d, offset = %d\n", agp.size, agp.offset); + + return retval; +} + +int sisp_agp_free(struct inode *inode, struct file *filp, unsigned int cmd, + unsigned long arg) +{ + drm_sis_mem_t agp; + int retval = 0; + + if(!AgpHeap) + return -1; + + if (copy_from_user(&agp, (drm_sis_mem_t *)arg, sizeof(agp))) + return -EFAULT; + + if(!agp.free){ + return -1; + } + + mmFreeMem((PMemBlock)agp.free); + if(!del_alloc_set(agp.context, AGP_TYPE, agp.free)) + retval = -1; + + DRM_DEBUG("free agp, free = %d\n", agp.free); + + return retval; +} + +#endif + +int sis_init_context(int context) +{ + int i; + + for(i = 0; i < MAX_CONTEXT ; i++) + if(global_ppriv[i].used && (global_ppriv[i].context == context)) + break; + + if(i >= MAX_CONTEXT){ + for(i = 0; i < MAX_CONTEXT ; i++){ + if(!global_ppriv[i].used){ + global_ppriv[i].context = context; + global_ppriv[i].used = 1; + global_ppriv[i].sets[0] = setInit(); + global_ppriv[i].sets[1] = setInit(); + DRM_DEBUG("init allocation set, socket=%d, context = %d\n", + i, context); + break; + } + } + if((i >= MAX_CONTEXT) || (global_ppriv[i].sets[0] == NULL) || + (global_ppriv[i].sets[1] == NULL)){ + return 0; + } + } + + return 1; +} + +int sis_final_context(int context) +{ + int i; + + for(i=0; i<MAX_CONTEXT; i++) + if(global_ppriv[i].used && (global_ppriv[i].context == context)) + break; + + if(i < MAX_CONTEXT){ + set_t *set; + unsigned int item; + int retval; + + DRM_DEBUG("find socket %d, context = %d\n", i, context); + + /* Video Memory */ + set = global_ppriv[i].sets[0]; + retval = setFirst(set, &item); + while(retval){ + DRM_DEBUG("free video memory 0x%x\n", item); + sis_free(item); + retval = setNext(set, &item); + } + setDestroy(set); + + /* AGP Memory */ + set = global_ppriv[i].sets[1]; + retval = setFirst(set, &item); + while(retval){ + DRM_DEBUG("free agp memory 0x%x\n", item); + mmFreeMem((PMemBlock)item); + retval = setNext(set, &item); + } + setDestroy(set); + + global_ppriv[i].used = 0; + } + + /* turn-off auto-flip */ + /* TODO */ +#if defined(SIS_STEREO) + flip_final(); +#endif + + return 1; +} diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/char/dsp56k.c linux-2.5/drivers/char/dsp56k.c --- linux-2.5.1/drivers/char/dsp56k.c Mon Sep 10 15:06:32 2001 +++ linux-2.5/drivers/char/dsp56k.c Sun Dec 30 21:17:30 2001 @@ -37,7 +37,6 @@ #include <linux/devfs_fs_kernel.h> #include <linux/smp_lock.h> -#include <asm/segment.h> #include <asm/atarihw.h> #include <asm/traps.h> #include <asm/uaccess.h> /* For put_user and get_user */ diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/char/dtlk.c linux-2.5/drivers/char/dtlk.c --- linux-2.5.1/drivers/char/dtlk.c Fri Nov 30 16:26:04 2001 +++ linux-2.5/drivers/char/dtlk.c Sun Dec 30 21:17:30 2001 @@ -57,7 +57,6 @@ #include <linux/errno.h> /* for -EBUSY */ #include <linux/ioport.h> /* for check_region, request_region */ #include <linux/delay.h> /* for loops_per_jiffy */ -#include <asm/segment.h> /* for put_user_byte */ #include <asm/io.h> /* for inb_p, outb_p, inb, outb, etc. */ #include <asm/uaccess.h> /* for get_user, etc. */ #include <linux/wait.h> /* for wait_queue */ diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/char/dz.c linux-2.5/drivers/char/dz.c --- linux-2.5.1/drivers/char/dz.c Sun Sep 9 17:43:02 2001 +++ linux-2.5/drivers/char/dz.c Sun Dec 30 19:12:33 2001 @@ -67,7 +67,7 @@ extern int (*prom_printf) (char *,...); #endif - +struct console dz_sercons; #include "dz.h" @@ -75,7 +75,6 @@ DECLARE_TASK_QUEUE(tq_serial); -extern wait_queue_head_t keypress_wait; static struct dz_serial *lines[4]; static unsigned char tmp_buffer[256]; @@ -228,8 +227,6 @@ if (info->is_console) { if (ch == 0) return; /* it's a break ... */ - - wake_up (&keypress_wait); /* It is a 'keyboard interrupt' ;-) */ } #endif @@ -1356,7 +1353,9 @@ serial_driver.table = serial_table; serial_driver.termios = serial_termios; serial_driver.termios_locked = serial_termios_locked; - +#ifdef CONFIG_SERIAL_CONSOLE + serial_driver.console = &dz_sercons; +#endif serial_driver.open = dz_open; serial_driver.close = dz_close; serial_driver.write = dz_write; @@ -1509,11 +1508,6 @@ } } -static int dz_console_wait_key(struct console *co) -{ - return 0; -} - static kdev_t dz_console_device(struct console *c) { return MKDEV(TTY_MAJOR, 64 + c->index); @@ -1614,7 +1608,6 @@ name: "ttyS", write: dz_console_print, device: dz_console_device, - wait_key: dz_console_wait_key, setup: dz_console_setup, flags: CON_CONSDEV | CON_PRINTBUFFER, index: CONSOLE_LINE, diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/char/epca.c linux-2.5/drivers/char/epca.c --- linux-2.5.1/drivers/char/epca.c Fri Oct 12 20:48:42 2001 +++ linux-2.5/drivers/char/epca.c Sun Dec 30 21:17:30 2001 @@ -897,7 +897,6 @@ inline void copy_from_user(void * to, const void * from, unsigned long count); - You must include <asm/segment.h> I also think (Check hackers guide) that optimization must be turned ON. (Which sounds strange to me...) diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/char/esp.c linux-2.5/drivers/char/esp.c --- linux-2.5.1/drivers/char/esp.c Fri Nov 9 22:01:21 2001 +++ linux-2.5/drivers/char/esp.c Sun Dec 30 21:17:30 2001 @@ -60,7 +60,6 @@ #include <asm/system.h> #include <asm/io.h> -#include <asm/segment.h> #include <asm/bitops.h> #include <asm/dma.h> diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/char/ftape/lowlevel/ftape-buffer.c linux-2.5/drivers/char/ftape/lowlevel/ftape-buffer.c --- linux-2.5.1/drivers/char/ftape/lowlevel/ftape-buffer.c Fri Feb 9 19:30:22 2001 +++ linux-2.5/drivers/char/ftape/lowlevel/ftape-buffer.c Sun Dec 30 21:17:30 2001 @@ -24,7 +24,6 @@ * buffer. */ -#include <asm/segment.h> #include <linux/slab.h> #include <linux/mm.h> #include <linux/mman.h> diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/char/ftape/lowlevel/ftape-io.c linux-2.5/drivers/char/ftape/lowlevel/ftape-io.c --- linux-2.5.1/drivers/char/ftape/lowlevel/ftape-io.c Mon Oct 16 19:58:51 2000 +++ linux-2.5/drivers/char/ftape/lowlevel/ftape-io.c Sun Dec 30 21:17:30 2001 @@ -29,7 +29,6 @@ #include <linux/errno.h> #include <linux/sched.h> #include <linux/mm.h> -#include <asm/segment.h> #include <asm/system.h> #include <linux/ioctl.h> #include <linux/mtio.h> diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/char/ftape/lowlevel/ftape-read.c linux-2.5/drivers/char/ftape/lowlevel/ftape-read.c --- linux-2.5.1/drivers/char/ftape/lowlevel/ftape-read.c Tue Nov 25 22:45:27 1997 +++ linux-2.5/drivers/char/ftape/lowlevel/ftape-read.c Sun Dec 30 21:17:30 2001 @@ -29,7 +29,6 @@ #include <linux/string.h> #include <linux/errno.h> #include <linux/mm.h> -#include <asm/segment.h> #include <linux/ftape.h> #include <linux/qic117.h> diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/char/ftape/lowlevel/ftape-setup.c linux-2.5/drivers/char/ftape/lowlevel/ftape-setup.c --- linux-2.5.1/drivers/char/ftape/lowlevel/ftape-setup.c Thu Aug 12 18:53:22 1999 +++ linux-2.5/drivers/char/ftape/lowlevel/ftape-setup.c Sun Dec 30 21:17:30 2001 @@ -29,7 +29,6 @@ #include <linux/string.h> #include <linux/errno.h> #include <linux/mm.h> -#include <asm/segment.h> #include <linux/ftape.h> #if LINUX_VERSION_CODE >= KERNEL_VER(2,1,16) diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/char/ftape/lowlevel/ftape-write.c linux-2.5/drivers/char/ftape/lowlevel/ftape-write.c --- linux-2.5.1/drivers/char/ftape/lowlevel/ftape-write.c Mon Oct 16 19:58:51 2000 +++ linux-2.5/drivers/char/ftape/lowlevel/ftape-write.c Sun Dec 30 21:17:30 2001 @@ -28,7 +28,6 @@ #include <linux/string.h> #include <linux/errno.h> #include <linux/mm.h> -#include <asm/segment.h> #include <linux/ftape.h> #include <linux/qic117.h> diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/char/ftape/zftape/zftape-buffers.c linux-2.5/drivers/char/ftape/zftape/zftape-buffers.c --- linux-2.5.1/drivers/char/ftape/zftape/zftape-buffers.c Fri Feb 9 19:30:22 2001 +++ linux-2.5/drivers/char/ftape/zftape/zftape-buffers.c Sun Dec 30 21:17:30 2001 @@ -27,7 +27,6 @@ #include <linux/errno.h> #include <linux/mm.h> #include <linux/slab.h> -#include <asm/segment.h> #include <linux/zftape.h> diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/char/ftape/zftape/zftape-init.c linux-2.5/drivers/char/ftape/zftape/zftape-init.c --- linux-2.5.1/drivers/char/ftape/zftape/zftape-init.c Fri Nov 30 20:33:17 2001 +++ linux-2.5/drivers/char/ftape/zftape/zftape-init.c Sun Dec 30 21:17:30 2001 @@ -25,7 +25,6 @@ #include <linux/errno.h> #include <linux/version.h> #include <linux/fs.h> -#include <asm/segment.h> #include <linux/kernel.h> #include <linux/signal.h> #include <linux/major.h> diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/char/ftape/zftape/zftape-rw.c linux-2.5/drivers/char/ftape/zftape/zftape-rw.c --- linux-2.5.1/drivers/char/ftape/zftape/zftape-rw.c Mon Oct 16 19:58:51 2000 +++ linux-2.5/drivers/char/ftape/zftape/zftape-rw.c Sun Dec 30 21:17:30 2001 @@ -27,7 +27,6 @@ #include <linux/config.h> /* for CONFIG_ZFT_DFLT_BLK_SZ */ #include <linux/errno.h> #include <linux/mm.h> -#include <asm/segment.h> #include <linux/zftape.h> #include "../zftape/zftape-init.h" diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/char/ftape/zftape/zftape-vtbl.c linux-2.5/drivers/char/ftape/zftape/zftape-vtbl.c --- linux-2.5.1/drivers/char/ftape/zftape/zftape-vtbl.c Fri Apr 6 17:42:55 2001 +++ linux-2.5/drivers/char/ftape/zftape/zftape-vtbl.c Sun Dec 30 21:17:30 2001 @@ -31,7 +31,6 @@ #include <linux/errno.h> #include <linux/mm.h> #include <linux/slab.h> -#include <asm/segment.h> #include <linux/zftape.h> #include "../zftape/zftape-init.h" diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/char/generic_serial.c linux-2.5/drivers/char/generic_serial.c --- linux-2.5.1/drivers/char/generic_serial.c Thu Sep 13 22:21:32 2001 +++ linux-2.5/drivers/char/generic_serial.c Fri Dec 28 01:15:11 2001 @@ -143,7 +143,12 @@ /* Can't copy more? break out! */ if (c <= 0) break; if (from_user) - copy_from_user (port->xmit_buf + port->xmit_head, buf, c); + if (copy_from_user (port->xmit_buf + port->xmit_head, + buf, c)) { + up (& port->port_write_sem); + return -EFAULT; + } + else memcpy (port->xmit_buf + port->xmit_head, buf, c); @@ -214,8 +219,13 @@ while (1) { c = count; - /* This is safe because we "OWN" the "head". Noone else can - change the "head": we own the port_write_sem. */ + /* Note: This part can be done without + * interrupt routine protection since + * the interrupt routines may only modify + * shared variables in safe ways, in the worst + * case causing us to loop twice in the code + * below. See comments below. */ + /* Don't overrun the end of the buffer */ t = SERIAL_XMIT_SIZE - port->xmit_head; if (t < c) c = t; @@ -506,7 +516,7 @@ void gs_shutdown_port (struct gs_port *port) { - long flags; + unsigned long flags; func_enter(); @@ -589,6 +599,7 @@ int do_clocal = 0; int CD; struct tty_struct *tty; + unsigned long flags; func_enter (); @@ -604,7 +615,7 @@ * until it's done, and then try again. */ if (tty_hung_up_p(filp) || port->flags & ASYNC_CLOSING) { - interruptible_sleep_on(&port->close_wait); + interruptible_sleep_on(&port->close_wait); if (port->flags & ASYNC_HUP_NOTIFY) return -EAGAIN; else @@ -668,10 +679,11 @@ add_wait_queue(&port->open_wait, &wait); gs_dprintk (GS_DEBUG_BTR, "after add waitq.\n"); + save_flags(flags); cli(); if (!tty_hung_up_p(filp)) port->count--; - sti(); + restore_flags(flags); port->blocked_open++; while (1) { CD = port->rd->get_CD (port); @@ -1003,7 +1015,8 @@ { struct serial_struct sio; - copy_from_user(&sio, sp, sizeof(struct serial_struct)); + if (copy_from_user(&sio, sp, sizeof(struct serial_struct))) + return(-EFAULT); if (!capable(CAP_SYS_ADMIN)) { if ((sio.baud_base != port->baud_base) || @@ -1033,7 +1046,7 @@ * Generate the serial struct info. */ -void gs_getserial(struct gs_port *port, struct serial_struct *sp) +int gs_getserial(struct gs_port *port, struct serial_struct *sp) { struct serial_struct sio; @@ -1055,7 +1068,10 @@ if (port->rd->getserial) port->rd->getserial (port, &sio); - copy_to_user(sp, &sio, sizeof(struct serial_struct)); + if (copy_to_user(sp, &sio, sizeof(struct serial_struct))) + return -EFAULT; + return 0; + } diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/char/h8.c linux-2.5/drivers/char/h8.c --- linux-2.5.1/drivers/char/h8.c Thu Sep 13 22:21:32 2001 +++ linux-2.5/drivers/char/h8.c Sun Dec 30 21:17:30 2001 @@ -14,7 +14,6 @@ #include <linux/module.h> #include <asm/system.h> -#include <asm/segment.h> #include <asm/io.h> #include <linux/types.h> diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/char/i8k.c linux-2.5/drivers/char/i8k.c --- linux-2.5.1/drivers/char/i8k.c Sat Nov 3 01:46:47 2001 +++ linux-2.5/drivers/char/i8k.c Thu Dec 13 16:32:35 2001 @@ -1,5 +1,7 @@ /* - * i8k.c -- Linux driver for accessing the SMM BIOS on Dell I8000 laptops + * i8k.c -- Linux driver for accessing the SMM BIOS on Dell laptops. + * See http://www.debian.org/~dz/i8k/ for more information + * and for latest version of this driver. * * Copyright (C) 2001 Massimo Dal Zotto <dz@debian.org> * @@ -19,15 +21,13 @@ #include <linux/types.h> #include <linux/init.h> #include <linux/proc_fs.h> -#include <asm/io.h> +#include <linux/apm_bios.h> #include <asm/uaccess.h> +#include <asm/io.h> #include <linux/i8k.h> -#define I8K_VERSION "1.1 02/11/2001" -#define I8K_BIOS_SIGNATURE "Dell System Inspiron 8000" -#define I8K_BIOS_SIGNATURE_ADDR 0x000ec000 -#define I8K_BIOS_VERSION_OFFSET 32 +#define I8K_VERSION "1.7 21/11/2001" #define I8K_SMM_FN_STATUS 0x0025 #define I8K_SMM_POWER_STATUS 0x0069 @@ -35,31 +35,47 @@ #define I8K_SMM_GET_FAN 0x00a3 #define I8K_SMM_GET_SPEED 0x02a3 #define I8K_SMM_GET_TEMP 0x10a3 +#define I8K_SMM_GET_DELL_SIG 0xffa3 #define I8K_SMM_BIOS_VERSION 0x00a6 #define I8K_FAN_MULT 30 #define I8K_MAX_TEMP 127 -#define I8K_FN_NONE 0x08 -#define I8K_FN_UP 0x09 -#define I8K_FN_DOWN 0x0a -#define I8K_FN_MUTE 0x0c +#define I8K_FN_NONE 0x00 +#define I8K_FN_UP 0x01 +#define I8K_FN_DOWN 0x02 +#define I8K_FN_MUTE 0x04 +#define I8K_FN_MASK 0x07 +#define I8K_FN_SHIFT 8 #define I8K_POWER_AC 0x05 #define I8K_POWER_BATTERY 0x01 #define I8K_TEMPERATURE_BUG 1 -static char bios_version[4] = "?"; -static char bios_machine_id[16] = "?"; +#define DELL_SIGNATURE "Dell Computer" + +static char *supported_models[] = { + "Inspiron", + "Latitude", + NULL +}; + +static char system_vendor[48] = "?"; +static char product_name [48] = "?"; +static char bios_version [4] = "?"; +static char serial_number[16] = "?"; int force = 0; +int power_status = 0; MODULE_AUTHOR("Massimo Dal Zotto (dz@debian.org)"); -MODULE_DESCRIPTION("Driver for accessing the SMM BIOS on Dell I8000 laptops"); +MODULE_DESCRIPTION("Driver for accessing SMM BIOS on Dell laptops"); MODULE_LICENSE("GPL"); MODULE_PARM(force, "i"); -MODULE_PARM_DESC(force, "Force loading without checking for an Inspiron 8000"); +MODULE_PARM(power_status, "i"); +MODULE_PARM_DESC(force, "Force loading without checking for supported models"); +MODULE_PARM_DESC(power_status, "Report power status in /proc/i8k"); static ssize_t i8k_read(struct file *, char *, size_t, loff_t *); static int i8k_ioctl(struct inode *, struct file *, unsigned int, @@ -79,12 +95,19 @@ unsigned int edi __attribute__ ((packed)); } SMMRegisters; +typedef struct { + u8 type; + u8 length; + u16 handle; +} DMIHeader; + /* - * Call the System Management Mode BIOS. + * Call the System Management Mode BIOS. Code provided by Jonathan Buzzard. */ static int i8k_smm(SMMRegisters *regs) { int rc; + int eax = regs->eax; asm("pushl %%eax\n\t" \ "movl 0(%%eax),%%edx\n\t" \ @@ -112,7 +135,7 @@ : "a" (regs) : "%ebx", "%ecx", "%edx", "%esi", "%edi", "memory"); - if ((rc != 0) || ((regs->eax & 0xffff) == 0xffff)) { + if ((rc != 0) || ((regs->eax & 0xffff) == 0xffff) || (regs->eax == eax)) { return -EINVAL; } @@ -137,11 +160,12 @@ } /* - * Read the machine id. Not yet implemented. + * Read the machine id. */ -static int i8k_get_machine_id(unsigned char *buff) +static int i8k_get_serial_number(unsigned char *buff) { - return -EINVAL; + strncpy(buff, serial_number, 16); + return 0; } /* @@ -157,7 +181,7 @@ return rc; } - switch ((regs.eax & 0xff00) >> 8) { + switch ((regs.eax >> I8K_FN_SHIFT) & I8K_FN_MASK) { case I8K_FN_UP: return I8K_VOL_UP; case I8K_FN_DOWN: @@ -281,6 +305,23 @@ return temp; } +static int i8k_get_dell_signature(void) +{ + SMMRegisters regs = { 0, 0, 0, 0, 0, 0 }; + int rc; + + regs.eax = I8K_SMM_GET_DELL_SIG; + if ((rc=i8k_smm(®s)) < 0) { + return rc; + } + + if ((regs.eax == 1145651527) && (regs.edx == 1145392204)) { + return 0; + } else { + return -1; + } +} + static int i8k_ioctl(struct inode *ip, struct file *fp, unsigned int cmd, unsigned long arg) { @@ -299,7 +340,7 @@ case I8K_MACHINE_ID: memset(buff, 0, 16); - val = i8k_get_machine_id(buff); + val = i8k_get_serial_number(buff); break; case I8K_FN_STATUS: @@ -375,13 +416,17 @@ int n, fn_key, cpu_temp, ac_power; int left_fan, right_fan, left_speed, right_speed; - cpu_temp = i8k_get_cpu_temp(); - left_fan = i8k_get_fan_status(I8K_FAN_LEFT); - right_fan = i8k_get_fan_status(I8K_FAN_RIGHT); - left_speed = i8k_get_fan_speed(I8K_FAN_LEFT); - right_speed = i8k_get_fan_speed(I8K_FAN_RIGHT); - ac_power = i8k_get_power_status(); - fn_key = i8k_get_fn_status(); + cpu_temp = i8k_get_cpu_temp(); /* 11100 µs */ + left_fan = i8k_get_fan_status(I8K_FAN_LEFT); /* 580 µs */ + right_fan = i8k_get_fan_status(I8K_FAN_RIGHT); /* 580 µs */ + left_speed = i8k_get_fan_speed(I8K_FAN_LEFT); /* 580 µs */ + right_speed = i8k_get_fan_speed(I8K_FAN_RIGHT); /* 580 µs */ + fn_key = i8k_get_fn_status(); /* 750 µs */ + if (power_status) { + ac_power = i8k_get_power_status(); /* 14700 µs */ + } else { + ac_power = -1; + } /* * Info: @@ -400,7 +445,7 @@ n = sprintf(buffer, "%s %s %s %d %d %d %d %d %d %d\n", I8K_PROC_FMT, bios_version, - bios_machine_id, + serial_number, cpu_temp, left_fan, right_fan, @@ -438,76 +483,253 @@ return len; } +static char* __init string_trim(char *s, int size) +{ + int len; + char *p; + + if ((len = strlen(s)) > size) { + len = size; + } + + for (p=s+len-1; len && (*p==' '); len--,p--) { + *p = '\0'; + } + + return s; +} + +/* DMI code, stolen from arch/i386/kernel/dmi_scan.c */ + /* - * Probe for the presence of an Inspiron I8000. + * |<-- dmi->length -->| + * | | + * |dmi header s=N | string1,\0, ..., stringN,\0, ..., \0 + * | | + * +-----------------------+ */ -static int i8k_probe(void) +static char* __init dmi_string(DMIHeader *dmi, u8 s) { - unsigned char *buff, *p; - unsigned char bios_vers[4]; - int version; + u8 *p; + + if (!s) { + return ""; + } + s--; + + p = (u8 *)dmi + dmi->length; + while (s > 0) { + p += strlen(p); + p++; + s--; + } + + return p; +} + +static void __init dmi_decode(DMIHeader *dmi) +{ + u8 *data = (u8 *) dmi; + char *p; + +#ifdef I8K_DEBUG + int i; + printk("%08x ", (int)data); + for (i=0; i<data[1] && i<64; i++) { + printk("%02x ", data[i]); + } + printk("\n"); +#endif + + switch (dmi->type) { + case 0: /* BIOS Information */ + p = dmi_string(dmi,data[5]); + if (*p) { + strncpy(bios_version, p, sizeof(bios_version)); + string_trim(bios_version, sizeof(bios_version)); + } + break; + case 1: /* System Information */ + p = dmi_string(dmi,data[4]); + if (*p) { + strncpy(system_vendor, p, sizeof(system_vendor)); + string_trim(system_vendor, sizeof(system_vendor)); + } + p = dmi_string(dmi,data[5]); + if (*p) { + strncpy(product_name, p, sizeof(product_name)); + string_trim(product_name, sizeof(product_name)); + } + p = dmi_string(dmi,data[7]); + if (*p) { + strncpy(serial_number, p, sizeof(serial_number)); + string_trim(serial_number, sizeof(serial_number)); + } + break; + } +} + +static int __init dmi_table(u32 base, int len, int num, void (*fn)(DMIHeader*)) +{ + u8 *buf; + u8 *data; + DMIHeader *dmi; + int i = 1; + + buf = ioremap(base, len); + if (buf == NULL) { + return -1; + } + data = buf; /* - * Until Dell tell us how to reliably check for an Inspiron system - * look for a signature at a fixed location in the BIOS memory. - * Ugly but safe. + * Stop when we see al the items the table claimed to have + * or we run off the end of the table (also happens) */ - if (!force) { - buff = ioremap(I8K_BIOS_SIGNATURE_ADDR, I8K_BIOS_VERSION_OFFSET+4); - if (buff == NULL) { - printk("i8k: ioremap failed\n"); - return -ENODEV; + while ((i<num) && ((data-buf) < len)) { + dmi = (DMIHeader *)data; + /* + * Avoid misparsing crud if the length of the last + * record is crap + */ + if ((data-buf+dmi->length) >= len) { + break; + } + fn(dmi); + data += dmi->length; + /* + * Don't go off the end of the data if there is + * stuff looking like string fill past the end + */ + while (((data-buf) < len) && (*data || data[1])) { + data++; } - if (strncmp(buff,I8K_BIOS_SIGNATURE,sizeof(I8K_BIOS_SIGNATURE)) != 0) { - printk("i8k: Inspiron 8000 BIOS signature not found\n"); - iounmap(buff); - return -ENODEV; + data += 2; + i++; + } + iounmap(buf); + + return 0; +} + +static int __init dmi_iterate(void (*decode)(DMIHeader *)) +{ + unsigned char buf[20]; + long fp = 0x000e0000L; + fp -= 16; + + while (fp < 0x000fffffL) { + fp += 16; + isa_memcpy_fromio(buf, fp, 20); + if (memcmp(buf, "_DMI_", 5)==0) { + u16 num = buf[13]<<8 | buf[12]; + u16 len = buf [7]<<8 | buf [6]; + u32 base = buf[11]<<24 | buf[10]<<16 | buf[9]<<8 | buf[8]; +#ifdef I8K_DEBUG + printk(KERN_INFO "DMI %d.%d present.\n", + buf[14]>>4, buf[14]&0x0F); + printk(KERN_INFO "%d structures occupying %d bytes.\n", + buf[13]<<8 | buf[12], + buf [7]<<8 | buf[6]); + printk(KERN_INFO "DMI table at 0x%08X.\n", + buf[11]<<24 | buf[10]<<16 | buf[9]<<8 | buf[8]); +#endif + if (dmi_table(base, len, num, decode)==0) { + return 0; + } } - strncpy(bios_vers, buff+I8K_BIOS_VERSION_OFFSET, 3); - bios_vers[3] = '\0'; - iounmap(buff); - } - if (force >= 2) { - buff = ioremap(0x000c0000, 0x00100000-0x000c0000); - if (buff == NULL) { - printk("i8k: ioremap failed\n"); + } + return -1; +} +/* end of DMI code */ + +/* + * Get DMI information. + */ +static int __init i8k_dmi_probe(void) +{ + char **p; + + if (dmi_iterate(dmi_decode) != 0) { + printk(KERN_INFO "i8k: unable to get DMI information\n"); + return -ENODEV; + } + + if (strncmp(system_vendor,DELL_SIGNATURE,strlen(DELL_SIGNATURE)) != 0) { + printk(KERN_INFO "i8k: not running on a Dell system\n"); + return -ENODEV; + } + + for (p=supported_models; ; p++) { + if (!*p) { + printk(KERN_INFO "i8k: unsupported model: %s\n", product_name); return -ENODEV; } - for (p=buff; (p-buff)<(0x00100000-0x000c0000); p+=16) { - if (strncmp(p,I8K_BIOS_SIGNATURE,sizeof(I8K_BIOS_SIGNATURE))==0) { - printk("i8k: Inspiron 8000 BIOS signature found at %08x\n", - 0x000c0000+(p-buff)); - break; - } + if (strncmp(product_name,*p,strlen(*p)) == 0) { + break; } - iounmap(buff); } + return 0; +} + +/* + * Probe for the presence of a supported laptop. + */ +static int __init i8k_probe(void) +{ + char buff[4]; + int version; + int smm_found = 0; + /* - * Next try to get the BIOS version with an SMM call. If this - * fails SMM can't be reliably used on this system. + * Get DMI information */ - version = i8k_get_bios_version(); - if (version <= 0) { - printk("i8k: unable to get BIOS version\n"); - return -ENODEV; + if (i8k_dmi_probe() != 0) { + printk(KERN_INFO "i8k: vendor=%s, model=%s, version=%s\n", + system_vendor, product_name, bios_version); } - bios_version[0] = (version >> 16) & 0xff; - bios_version[1] = (version >> 8) & 0xff; - bios_version[2] = (version) & 0xff; - bios_version[3] = '\0'; /* - * Finally check if the two versions match. + * Get SMM Dell signature */ - if (!force) { - if (strncmp(bios_version,bios_vers,sizeof(bios_version)) != 0) { - printk("i8k: BIOS version mismatch: %s != %s\n", - bios_version, bios_vers); - return -ENODEV; + if (i8k_get_dell_signature() != 0) { + printk(KERN_INFO "i8k: unable to get SMM Dell signature\n"); + } else { + smm_found = 1; + } + + /* + * Get SMM BIOS version. + */ + version = i8k_get_bios_version(); + if (version <= 0) { + printk(KERN_INFO "i8k: unable to get SMM BIOS version\n"); + } else { + smm_found = 1; + buff[0] = (version >> 16) & 0xff; + buff[1] = (version >> 8) & 0xff; + buff[2] = (version) & 0xff; + buff[3] = '\0'; + /* + * If DMI BIOS version is unknown use SMM BIOS version. + */ + if (bios_version[0] == '?') { + strcpy(bios_version, buff); + } + /* + * Check if the two versions match. + */ + if (strncmp(buff,bios_version,sizeof(bios_version)) != 0) { + printk(KERN_INFO "i8k: BIOS version mismatch: %s != %s\n", + buff, bios_version); } } + if (!smm_found && !force) { + return -ENODEV; + } + return 0; } @@ -518,7 +740,7 @@ { struct proc_dir_entry *proc_i8k; - /* Are we running on an Inspiron 8000 laptop? */ + /* Are we running on an supported laptop? */ if (i8k_probe() != 0) { return -ENODEV; } @@ -532,7 +754,7 @@ SET_MODULE_OWNER(proc_i8k); printk(KERN_INFO - "Inspiron 8000 SMM driver v%s Massimo Dal Zotto (dz@debian.org)\n", + "Dell laptop SMM driver v%s Massimo Dal Zotto (dz@debian.org)\n", I8K_VERSION); return 0; diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/char/ip2/i2cmd.c linux-2.5/drivers/char/ip2/i2cmd.c --- linux-2.5.1/drivers/char/ip2/i2cmd.c Wed Oct 24 19:05:18 2001 +++ linux-2.5/drivers/char/ip2/i2cmd.c Thu Dec 13 16:32:35 2001 @@ -139,7 +139,7 @@ //static UCHAR ct86[]={ 2, BTH, 0x56,0 }; // RCV_ENABLE static UCHAR ct87[] = { 1, BYP, 0x57 }; // HW_TEST //static UCHAR ct88[]={ 3, BTH, 0x58,0,0 }; // RCV_THRESHOLD -static UCHAR ct89[]={ 1, BYP, 0x59 }; // DSS_NOW +//static UCHAR ct89[]={ 1, BYP, 0x59 }; // DSS_NOW //static UCHAR ct90[]={ 3, BYP, 0x5A,0,0 }; // Set SILO //static UCHAR ct91[]={ 2, BYP, 0x5B,0 }; // timed break diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/char/ip2.c linux-2.5/drivers/char/ip2.c --- linux-2.5.1/drivers/char/ip2.c Wed Oct 24 19:05:18 2001 +++ linux-2.5/drivers/char/ip2.c Thu Dec 13 16:32:35 2001 @@ -33,9 +33,10 @@ */ static int io[IP2_MAX_BOARDS]= { 0, 0, 0, 0 }; static int irq[IP2_MAX_BOARDS] = { -1, -1, -1, -1 }; -static int poll_only = 0; #ifdef MODULE + +static int poll_only = 0; # if LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,0) MODULE_AUTHOR("Doug McNash"); diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/char/ip2main.c linux-2.5/drivers/char/ip2main.c --- linux-2.5.1/drivers/char/ip2main.c Sat Nov 3 01:26:17 2001 +++ linux-2.5/drivers/char/ip2main.c Sun Dec 30 21:17:30 2001 @@ -142,7 +142,6 @@ // so blame them. #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,4) -# include <asm/segment.h> # define GET_USER(error,value,addr) error = get_user(value,addr) # define COPY_FROM_USER(error,dest,src,size) error = copy_from_user(dest,src,size) ? -EFAULT : 0 # define PUT_USER(error,value,addr) error = put_user(value,addr) diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/char/isicom.c linux-2.5/drivers/char/isicom.c --- linux-2.5.1/drivers/char/isicom.c Fri Nov 9 22:01:21 2001 +++ linux-2.5/drivers/char/isicom.c Sun Dec 30 21:17:30 2001 @@ -51,7 +51,6 @@ #include <linux/timer.h> #include <linux/ioport.h> -#include <asm/segment.h> #include <asm/uaccess.h> #include <asm/io.h> #include <asm/system.h> diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/char/joystick/cs461x.c linux-2.5/drivers/char/joystick/cs461x.c --- linux-2.5.1/drivers/char/joystick/cs461x.c Fri Nov 9 21:41:42 2001 +++ linux-2.5/drivers/char/joystick/cs461x.c Thu Dec 13 16:32:35 2001 @@ -313,7 +313,7 @@ name: "PCI Gameport", id_table: cs461x_pci_tbl, probe: cs461x_pci_probe, - remove: cs461x_pci_remove, + remove: __devexit_p(cs461x_pci_remove), }; int __init js_cs461x_init(void) diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/char/joystick/emu10k1-gp.c linux-2.5/drivers/char/joystick/emu10k1-gp.c --- linux-2.5.1/drivers/char/joystick/emu10k1-gp.c Fri Nov 9 21:41:42 2001 +++ linux-2.5/drivers/char/joystick/emu10k1-gp.c Thu Dec 13 16:32:35 2001 @@ -108,7 +108,7 @@ name: "Emu10k1 Gameport", id_table: emu_tbl, probe: emu_probe, - remove: emu_remove, + remove: __devexit_p(emu_remove), }; int __init emu_init(void) diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/char/joystick/pcigame.c linux-2.5/drivers/char/joystick/pcigame.c --- linux-2.5.1/drivers/char/joystick/pcigame.c Fri Nov 9 21:41:42 2001 +++ linux-2.5/drivers/char/joystick/pcigame.c Thu Dec 13 16:32:35 2001 @@ -180,7 +180,7 @@ name: "pcigame", id_table: pcigame_id_table, probe: pcigame_probe, - remove: pcigame_remove, + remove: __devexit_p(pcigame_remove), }; int __init pcigame_init(void) diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/char/keyboard.c linux-2.5/drivers/char/keyboard.c --- linux-2.5.1/drivers/char/keyboard.c Tue Sep 18 20:39:51 2001 +++ linux-2.5/drivers/char/keyboard.c Sun Dec 30 13:55:22 2001 @@ -67,15 +67,6 @@ extern void ctrl_alt_del(void); -DECLARE_WAIT_QUEUE_HEAD(keypress_wait); -struct console; - -int keyboard_wait_for_keypress(struct console *co) -{ - sleep_on(&keypress_wait); - return 0; -} - /* * global state includes the following, and various static variables * in this module: prev_scancode, shift_state, diacr, npadch, dead_key_next. @@ -334,7 +325,6 @@ void put_queue(int ch) { - wake_up(&keypress_wait); if (tty) { tty_insert_flip_char(tty, ch, 0); con_schedule_flip(tty); @@ -343,7 +333,6 @@ static void puts_queue(char *cp) { - wake_up(&keypress_wait); if (!tty) return; diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/char/mem.c linux-2.5/drivers/char/mem.c --- linux-2.5.1/drivers/char/mem.c Fri Sep 14 21:04:07 2001 +++ linux-2.5/drivers/char/mem.c Thu Dec 13 16:32:35 2001 @@ -272,6 +272,8 @@ return virtr + read; } +extern long vwrite(char *buf, char *addr, unsigned long count); + /* * This function writes to the *virtual* memory as seen by the kernel. */ @@ -279,12 +281,46 @@ size_t count, loff_t *ppos) { unsigned long p = *ppos; + ssize_t wrote = 0; + ssize_t virtr = 0; + char * kbuf; /* k-addr because vwrite() takes vmlist_lock rwlock */ + + if (p < (unsigned long) high_memory) { + wrote = count; + if (count > (unsigned long) high_memory - p) + wrote = (unsigned long) high_memory - p; + + wrote = do_write_mem(file, (void*)p, p, buf, wrote, ppos); + + p += wrote; + buf += wrote; + count -= wrote; + } + + if (count > 0) { + kbuf = (char *)__get_free_page(GFP_KERNEL); + if (!kbuf) + return -ENOMEM; + while (count > 0) { + int len = count; + + if (len > PAGE_SIZE) + len = PAGE_SIZE; + if (len && copy_from_user(kbuf, buf, len)) { + free_page((unsigned long)kbuf); + return -EFAULT; + } + len = vwrite(kbuf, (char *)p, len); + count -= len; + buf += len; + virtr += len; + p += len; + } + free_page((unsigned long)kbuf); + } - if (p >= (unsigned long) high_memory) - return 0; - if (count > (unsigned long) high_memory - p) - count = (unsigned long) high_memory - p; - return do_write_mem(file, (void*)p, p, buf, count, ppos); + *ppos = p; + return virtr + wrote; } #if !defined(__mc68000__) diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/char/moxa.c linux-2.5/drivers/char/moxa.c --- linux-2.5.1/drivers/char/moxa.c Thu Oct 25 20:53:47 2001 +++ linux-2.5/drivers/char/moxa.c Sun Dec 30 21:17:30 2001 @@ -53,7 +53,6 @@ #include <asm/system.h> #include <asm/io.h> -#include <asm/segment.h> #include <asm/bitops.h> #include <asm/uaccess.h> diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/char/mxser.c linux-2.5/drivers/char/mxser.c --- linux-2.5.1/drivers/char/mxser.c Thu Oct 25 20:53:47 2001 +++ linux-2.5/drivers/char/mxser.c Sun Dec 30 21:17:30 2001 @@ -58,7 +58,6 @@ #include <asm/system.h> #include <asm/io.h> #include <asm/irq.h> -#include <asm/segment.h> #include <asm/bitops.h> #include <asm/uaccess.h> diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/char/n_hdlc.c linux-2.5/drivers/char/n_hdlc.c --- linux-2.5.1/drivers/char/n_hdlc.c Thu Sep 13 22:21:32 2001 +++ linux-2.5/drivers/char/n_hdlc.c Sun Dec 30 21:17:30 2001 @@ -9,7 +9,7 @@ * Al Longyear <longyear@netcom.com>, Paul Mackerras <Paul.Mackerras@cs.anu.edu.au> * * Original release 01/11/99 - * $Id: n_hdlc.c,v 3.2 2000/11/06 22:34:38 paul Exp $ + * $Id: n_hdlc.c,v 3.3 2001/11/08 16:16:03 paulkf Exp $ * * This code is released under the GNU General Public License (GPL) * @@ -78,7 +78,7 @@ */ #define HDLC_MAGIC 0x239e -#define HDLC_VERSION "3.2" +#define HDLC_VERSION "$Revision: 3.3 $" #include <linux/version.h> #include <linux/config.h> @@ -112,7 +112,6 @@ #include <linux/kerneld.h> #endif -#include <asm/segment.h> #define GET_USER(error,value,addr) error = get_user(value,addr) #define COPY_FROM_USER(error,dest,src,size) error = copy_from_user(dest,src,size) ? -EFAULT : 0 #define PUT_USER(error,value,addr) error = put_user(value,addr) @@ -160,11 +159,6 @@ struct tty_struct *tty; /* ptr to TTY structure */ struct tty_struct *backup_tty; /* TTY to use if tty gets closed */ - /* Queues for select() functionality */ - wait_queue_head_t read_wait; - wait_queue_head_t write_wait; - wait_queue_head_t poll_wait; - int tbusy; /* reentrancy flag for tx wakeup code */ int woke_up; N_HDLC_BUF *tbuf; /* currently transmitting tx buffer */ @@ -235,9 +229,8 @@ printk("%s(%d)n_hdlc_release() called\n",__FILE__,__LINE__); /* Ensure that the n_hdlcd process is not hanging on select()/poll() */ - wake_up_interruptible (&n_hdlc->read_wait); - wake_up_interruptible (&n_hdlc->poll_wait); - wake_up_interruptible (&n_hdlc->write_wait); + wake_up_interruptible (&tty->read_wait); + wake_up_interruptible (&tty->write_wait); if (tty != NULL && tty->disc_data == n_hdlc) tty->disc_data = NULL; /* Break the tty->n_hdlc link */ @@ -432,8 +425,7 @@ n_hdlc->tbuf = NULL; /* wait up sleeping writers */ - wake_up_interruptible(&n_hdlc->write_wait); - wake_up_interruptible(&n_hdlc->poll_wait); + wake_up_interruptible(&tty->write_wait); /* get next pending transmit buffer */ tbuf = n_hdlc_buf_get(&n_hdlc->tx_buf_list); @@ -575,8 +567,7 @@ n_hdlc_buf_put(&n_hdlc->rx_buf_list,buf); /* wake up any blocked reads and perform async signalling */ - wake_up_interruptible (&n_hdlc->read_wait); - wake_up_interruptible (&n_hdlc->poll_wait); + wake_up_interruptible (&tty->read_wait); if (n_hdlc->tty->fasync != NULL) kill_fasync (&n_hdlc->tty->fasync, SIGIO, POLL_IN); @@ -621,6 +612,9 @@ } for (;;) { + if (test_bit(TTY_OTHER_CLOSED, &tty->flags)) + return -EIO; + n_hdlc = tty2n_hdlc (tty); if (!n_hdlc || n_hdlc->magic != HDLC_MAGIC || tty != n_hdlc->tty) @@ -634,7 +628,7 @@ if (file->f_flags & O_NONBLOCK) return -EAGAIN; - interruptible_sleep_on (&n_hdlc->read_wait); + interruptible_sleep_on (&tty->read_wait); if (signal_pending(current)) return -EINTR; } @@ -703,7 +697,7 @@ count = maxframe; } - add_wait_queue(&n_hdlc->write_wait, &wait); + add_wait_queue(&tty->write_wait, &wait); set_current_state(TASK_INTERRUPTIBLE); /* Allocate transmit buffer */ @@ -726,7 +720,7 @@ } set_current_state(TASK_RUNNING); - remove_wait_queue(&n_hdlc->write_wait, &wait); + remove_wait_queue(&tty->write_wait, &wait); if (!error) { /* Retrieve the user's buffer */ @@ -836,12 +830,14 @@ if (n_hdlc && n_hdlc->magic == HDLC_MAGIC && tty == n_hdlc->tty) { /* queue current process into any wait queue that */ /* may awaken in the future (read and write) */ - poll_wait(filp, &n_hdlc->poll_wait, wait); + + poll_wait(filp, &tty->read_wait, wait); + poll_wait(filp, &tty->write_wait, wait); /* set bits for operations that wont block */ if(n_hdlc->rx_buf_list.head) mask |= POLLIN | POLLRDNORM; /* readable */ - if(tty->flags & (1 << TTY_OTHER_CLOSED)) + if (test_bit(TTY_OTHER_CLOSED, &tty->flags)) mask |= POLLHUP; if(tty_hung_up_p(filp)) mask |= POLLHUP; @@ -895,11 +891,7 @@ /* Initialize the control block */ n_hdlc->magic = HDLC_MAGIC; - n_hdlc->flags = 0; - init_waitqueue_head(&n_hdlc->read_wait); - init_waitqueue_head(&n_hdlc->poll_wait); - init_waitqueue_head(&n_hdlc->write_wait); return n_hdlc; diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/char/pc110pad.c linux-2.5/drivers/char/pc110pad.c --- linux-2.5.1/drivers/char/pc110pad.c Thu Nov 29 05:46:03 2001 +++ linux-2.5/drivers/char/pc110pad.c Thu Dec 27 15:14:59 2001 @@ -590,7 +590,7 @@ spin_lock_irqsave(&pc110_lock, flags); if (!--active_count) outb(0x30, current_params.io+2); /* switch off digitiser */ - spin_unlock_irqrestore(&active_lock, flags); + spin_unlock_irqrestore(&pc110_lock, flags); return 0; } diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/char/pc_keyb.c linux-2.5/drivers/char/pc_keyb.c --- linux-2.5.1/drivers/char/pc_keyb.c Sat Dec 8 00:21:05 2001 +++ linux-2.5/drivers/char/pc_keyb.c Sun Dec 30 19:12:33 2001 @@ -1231,3 +1231,26 @@ } #endif /* CONFIG_PSMOUSE */ + + +/* Tell the user who may be running in X and not see the console that we have + panic'ed. This is to distingush panics from "real" lockups. + Could in theory send the panic message as morse, but that is left as an + exercise for the reader. */ +void panic_blink(void) +{ + static unsigned long last_jiffie; + static char led; + /* Roughly 1/2s frequency. KDB uses about 1s. Make sure it is + different. */ + if (jiffies - last_jiffie > HZ/2) { + led ^= 0x01 | 0x04; + while (kbd_read_status() & KBD_STAT_IBF) mdelay(1); + kbd_write_output(KBD_CMD_SET_LEDS); + mdelay(1); + while (kbd_read_status() & KBD_STAT_IBF) mdelay(1); + mdelay(1); + kbd_write_output(led); + last_jiffie = jiffies; + } +} diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/char/pcmcia/serial_cs.c linux-2.5/drivers/char/pcmcia/serial_cs.c --- linux-2.5.1/drivers/char/pcmcia/serial_cs.c Thu Sep 13 22:21:32 2001 +++ linux-2.5/drivers/char/pcmcia/serial_cs.c Thu Dec 13 16:32:35 2001 @@ -2,7 +2,7 @@ A driver for PCMCIA serial devices - serial_cs.c 1.123 2000/08/24 18:46:38 + serial_cs.c 1.128 2001/10/18 12:18:35 The contents of this file are subject to the Mozilla Public License Version 1.1 (the "License"); you may not use this file @@ -19,8 +19,8 @@ are Copyright (C) 1999 David A. Hinds. All Rights Reserved. Alternatively, the contents of this file may be used under the - terms of the GNU General Public License version 2 (the "GPL"), in which - case the provisions of the GPL are applicable instead of the + terms of the GNU General Public License version 2 (the "GPL"), in + which case the provisions of the GPL are applicable instead of the above. If you wish to allow the use of your version of this file only under the terms of the GPL and not to allow others to use your version of this file under the MPL, indicate your decision @@ -44,6 +44,7 @@ #include <linux/major.h> #include <asm/io.h> #include <asm/system.h> +#include <asm/byteorder.h> #include <pcmcia/version.h> #include <pcmcia/cs_types.h> @@ -53,30 +54,32 @@ #include <pcmcia/ds.h> #include <pcmcia/cisreg.h> -#ifdef PCMCIA_DEBUG -static int pc_debug = PCMCIA_DEBUG; -MODULE_PARM(pc_debug, "i"); -#define DEBUG(n, args...) if (pc_debug>(n)) printk(KERN_DEBUG args) -static char *version = -"serial_cs.c 1.123 2000/08/24 18:46:38 (David Hinds)"; -#else -#define DEBUG(n, args...) -#endif - /*====================================================================*/ -/* Parameters that can be set with 'insmod' */ +/* Module parameters */ + +MODULE_AUTHOR("David Hinds <dahinds@users.sourceforge.net>"); +MODULE_DESCRIPTION("PCMCIA serial card driver"); +MODULE_LICENSE("Dual MPL/GPL"); + +#define INT_MODULE_PARM(n, v) static int n = v; MODULE_PARM(n, "i") /* Bit map of interrupts to choose from */ -static u_int irq_mask = 0xdeb8; +INT_MODULE_PARM(irq_mask, 0xdeb8); static int irq_list[4] = { -1 }; +MODULE_PARM(irq_list, "1-4i"); /* Enable the speaker? */ -static int do_sound = 1; +INT_MODULE_PARM(do_sound, 1); -MODULE_PARM(irq_mask, "i"); -MODULE_PARM(irq_list, "1-4i"); -MODULE_PARM(do_sound, "i"); +#ifdef PCMCIA_DEBUG +INT_MODULE_PARM(pc_debug, PCMCIA_DEBUG); +#define DEBUG(n, args...) if (pc_debug>(n)) printk(KERN_DEBUG args) +static char *version = +"serial_cs.c 1.128 2001/10/18 12:18:35 (David Hinds)"; +#else +#define DEBUG(n, args...) +#endif /*====================================================================*/ @@ -93,6 +96,8 @@ { MANFID_QUATECH, PRODID_QUATECH_DUAL_RS232, 2 }, { MANFID_QUATECH, PRODID_QUATECH_DUAL_RS232_D1, 2 }, { MANFID_QUATECH, PRODID_QUATECH_QUAD_RS232, 4 }, + { MANFID_QUATECH, PRODID_QUATECH_DUAL_RS422, 2 }, + { MANFID_QUATECH, PRODID_QUATECH_QUAD_RS422, 4 }, { MANFID_SOCKET, PRODID_SOCKET_DUAL_RS232, 2 }, { MANFID_INTEL, PRODID_INTEL_DUAL_RS232, 2 }, { MANFID_NATINST, PRODID_NATINST_QUAD_RS232, 4 } @@ -357,7 +362,6 @@ found_port: if (i != CS_SUCCESS) { - printk(KERN_NOTICE "serial_cs: no usable port range found, giving up\n"); cs_error(link->handle, RequestIO, i); return -1; } @@ -437,7 +441,6 @@ i = CardServices(RequestIRQ, link->handle, &link->irq); if (i != CS_SUCCESS) { - printk(KERN_NOTICE "serial_cs: no usable port range found, giving up\n"); cs_error(link->handle, RequestIRQ, i); link->irq.AssignedIRQ = 0; } @@ -663,5 +666,3 @@ module_init(init_serial_cs); module_exit(exit_serial_cs); - -MODULE_LICENSE("GPL"); diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/char/pty.c linux-2.5/drivers/char/pty.c --- linux-2.5.1/drivers/char/pty.c Fri Sep 21 17:55:22 2001 +++ linux-2.5/drivers/char/pty.c Thu Dec 13 16:32:35 2001 @@ -334,8 +334,7 @@ /* Register a slave for the master */ if (tty->driver.major == PTY_MASTER_MAJOR) tty_register_devfs(&tty->link->driver, - DEVFS_FL_CURRENT_OWNER | - DEVFS_FL_NO_PERSISTENCE | DEVFS_FL_WAIT, + DEVFS_FL_CURRENT_OWNER | DEVFS_FL_WAIT, tty->link->driver.minor_start + MINOR(tty->device)-tty->driver.minor_start); retval = 0; diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/char/raw.c linux-2.5/drivers/char/raw.c --- linux-2.5.1/drivers/char/raw.c Tue Nov 27 17:23:27 2001 +++ linux-2.5/drivers/char/raw.c Thu Dec 27 22:10:28 2001 @@ -117,21 +117,8 @@ if (raw_devices[minor].inuse++) goto out; - /* - * Don't interfere with mounted devices: we cannot safely set - * the blocksize on a device which is already mounted. - */ - - sector_size = 512; - if (is_mounted(rdev)) { - if (blksize_size[MAJOR(rdev)]) - sector_size = blksize_size[MAJOR(rdev)][MINOR(rdev)]; - } else - sector_size = get_hardsect_size(rdev); - - set_blocksize(rdev, sector_size); + sector_size = get_hardsect_size(rdev); raw_devices[minor].sector_size = sector_size; - for (sector_bits = 0; !(sector_size & 1); ) sector_size>>=1, sector_bits++; raw_devices[minor].sector_bits = sector_bits; diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/char/rio/rio_linux.c linux-2.5/drivers/char/rio/rio_linux.c --- linux-2.5.1/drivers/char/rio/rio_linux.c Thu Oct 25 20:53:47 2001 +++ linux-2.5/drivers/char/rio/rio_linux.c Fri Dec 28 01:15:11 2001 @@ -742,7 +742,7 @@ case TIOCGSERIAL: if ((rc = verify_area(VERIFY_WRITE, (void *) arg, sizeof(struct serial_struct))) == 0) - gs_getserial(&PortP->gs, (struct serial_struct *) arg); + rc = gs_getserial(&PortP->gs, (struct serial_struct *) arg); break; case TCSBRK: if ( PortP->State & RIO_DELETED ) { diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/char/rtc.c linux-2.5/drivers/char/rtc.c --- linux-2.5.1/drivers/char/rtc.c Tue Nov 13 17:16:05 2001 +++ linux-2.5/drivers/char/rtc.c Sun Dec 30 19:12:33 2001 @@ -785,6 +785,9 @@ printk(KERN_INFO "rtc: %s epoch (%lu) detected\n", guess, epoch); #endif #if RTC_IRQ + if (rtc_has_irq == 0) + goto no_irq2; + init_timer(&rtc_irq_timer); rtc_irq_timer.function = rtc_dropped_irq; spin_lock_irq(&rtc_lock); @@ -792,6 +795,7 @@ CMOS_WRITE(((CMOS_READ(RTC_FREQ_SELECT) & 0xF0) | 0x06), RTC_FREQ_SELECT); spin_unlock_irq(&rtc_lock); rtc_freq = 1024; +no_irq2: #endif printk(KERN_INFO "Real Time Clock Driver v" RTC_VERSION "\n"); diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/char/serial.c linux-2.5/drivers/char/serial.c --- linux-2.5.1/drivers/char/serial.c Sun Nov 25 17:43:42 2001 +++ linux-2.5/drivers/char/serial.c Sun Dec 30 19:12:33 2001 @@ -122,11 +122,6 @@ #define ENABLE_SERIAL_ACPI #endif -#ifdef __ISAPNP__ -#ifndef ENABLE_SERIAL_PNP -#define ENABLE_SERIAL_PNP -#endif -#endif /* Set of debugging defines */ @@ -211,9 +206,14 @@ #ifdef ENABLE_SERIAL_PCI #include <linux/pci.h> #endif -#ifdef ENABLE_SERIAL_PNP + #include <linux/isapnp.h> +#ifdef __ISAPNP__ +#ifndef ENABLE_SERIAL_PNP +#define ENABLE_SERIAL_PNP +#endif #endif + #ifdef CONFIG_MAGIC_SYSRQ #include <linux/sysrq.h> #endif @@ -231,8 +231,8 @@ #include <asm/irq.h> #include <asm/bitops.h> -#ifdef CONFIG_MAC_SERIAL -#define SERIAL_DEV_OFFSET 2 +#if defined(CONFIG_MAC_SERIAL) +#define SERIAL_DEV_OFFSET ((_machine == _MACH_prep || _machine == _MACH_chrp) ? 0 : 2) #else #define SERIAL_DEV_OFFSET 0 #endif @@ -3095,36 +3095,52 @@ sstate = rs_table + line; sstate->count++; - if (sstate->info) { - *ret_info = sstate->info; - return 0; - } + info = sstate->info; + + /* + * If the async_struct is already allocated, do the fastpath. + */ + if (info) + goto out; + info = kmalloc(sizeof(struct async_struct), GFP_KERNEL); if (!info) { sstate->count--; return -ENOMEM; } + memset(info, 0, sizeof(struct async_struct)); init_waitqueue_head(&info->open_wait); init_waitqueue_head(&info->close_wait); init_waitqueue_head(&info->delta_msr_wait); info->magic = SERIAL_MAGIC; info->port = sstate->port; + info->hub6 = sstate->hub6; info->flags = sstate->flags; - info->io_type = sstate->io_type; - info->iomem_base = sstate->iomem_base; - info->iomem_reg_shift = sstate->iomem_reg_shift; info->xmit_fifo_size = sstate->xmit_fifo_size; + info->state = sstate; info->line = line; + info->iomem_base = sstate->iomem_base; + info->iomem_reg_shift = sstate->iomem_reg_shift; + info->io_type = sstate->io_type; info->tqueue.routine = do_softint; info->tqueue.data = info; - info->state = sstate; + if (sstate->info) { kfree(info); - *ret_info = sstate->info; - return 0; + info = sstate->info; + } else { + sstate->info = info; + } + +out: + /* + * If this is the first open, copy over some timeouts. + */ + if (sstate->count == 1) { + info->closing_wait = sstate->closing_wait; } - *ret_info = sstate->info = info; + *ret_info = info; return 0; } @@ -3133,6 +3149,10 @@ * enables interrupts for a serial port, linking in its async structure into * the IRQ chain. It also performs the serial-specific * initialization for the tty structure. + * + * Note that on failure, we don't decrement the module use count - the tty + * later will call rs_close, which will decrement it for us as long as + * tty->driver_data is set non-NULL. --rmk */ static int rs_open(struct tty_struct *tty, struct file * filp) { @@ -3153,10 +3173,8 @@ } tty->driver_data = info; info->tty = tty; - if (serial_paranoia_check(info, tty->device, "rs_open")) { - MOD_DEC_USE_COUNT; + if (serial_paranoia_check(info, tty->device, "rs_open")) return -ENODEV; - } #ifdef SERIAL_DEBUG_OPEN printk("rs_open %s%d, count = %d\n", tty->driver.name, info->line, @@ -3171,10 +3189,8 @@ */ if (!tmp_buf) { page = get_zeroed_page(GFP_KERNEL); - if (!page) { - MOD_DEC_USE_COUNT; + if (!page) return -ENOMEM; - } if (tmp_buf) free_page(page); else @@ -3188,7 +3204,6 @@ (info->flags & ASYNC_CLOSING)) { if (info->flags & ASYNC_CLOSING) interruptible_sleep_on(&info->close_wait); - MOD_DEC_USE_COUNT; #ifdef SERIAL_DO_RESTART return ((info->flags & ASYNC_HUP_NOTIFY) ? -EAGAIN : -ERESTARTSYS); @@ -3201,10 +3216,8 @@ * Start up serial port */ retval = startup(info); - if (retval) { - MOD_DEC_USE_COUNT; + if (retval) return retval; - } retval = block_til_ready(tty, filp, info); if (retval) { @@ -3212,7 +3225,6 @@ printk("rs_open returning after block_til_ready with %d\n", retval); #endif - MOD_DEC_USE_COUNT; return retval; } @@ -4896,7 +4908,7 @@ static struct pci_driver serial_pci_driver = { name: "serial", probe: serial_init_one, - remove: serial_remove_one, + remove: __devexit_p(serial_remove_one), id_table: serial_pci_tbl, }; @@ -5397,6 +5409,7 @@ #endif serial_driver.major = TTY_MAJOR; serial_driver.minor_start = 64 + SERIAL_DEV_OFFSET; + serial_driver.name_base = SERIAL_DEV_OFFSET; serial_driver.num = NR_PORTS; serial_driver.type = TTY_DRIVER_TYPE_SERIAL; serial_driver.subtype = SERIAL_TYPE_NORMAL; @@ -5408,7 +5421,9 @@ serial_driver.table = serial_table; serial_driver.termios = serial_termios; serial_driver.termios_locked = serial_termios_locked; - +#ifdef CONFIG_SERIAL_CONSOLE + serial_driver.console = &sercons; +#endif serial_driver.open = rs_open; serial_driver.close = rs_close; serial_driver.write = rs_write; @@ -5825,35 +5840,6 @@ serial_out(info, UART_IER, ier); } -/* - * Receive character from the serial port - */ -static int serial_console_wait_key(struct console *co) -{ - static struct async_struct *info; - int ier, c; - - info = &async_sercons; - - /* - * First save the IER then disable the interrupts so - * that the real driver for the port does not get the - * character. - */ - ier = serial_in(info, UART_IER); - serial_out(info, UART_IER, 0x00); - - while ((serial_in(info, UART_LSR) & UART_LSR_DR) == 0); - c = serial_in(info, UART_RX); - - /* - * Restore the interrupts - */ - serial_out(info, UART_IER, ier); - - return c; -} - static kdev_t serial_console_device(struct console *c) { return MKDEV(TTY_MAJOR, 64 + c->index); @@ -5994,7 +5980,6 @@ name: "ttyS", write: serial_console_write, device: serial_console_device, - wait_key: serial_console_wait_key, setup: serial_console_setup, flags: CON_PRINTBUFFER, index: -1, diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/char/serial167.c linux-2.5/drivers/char/serial167.c --- linux-2.5.1/drivers/char/serial167.c Mon Sep 17 04:23:07 2001 +++ linux-2.5/drivers/char/serial167.c Sun Dec 30 21:17:30 2001 @@ -65,7 +65,6 @@ #include <asm/system.h> #include <asm/io.h> -#include <asm/segment.h> #include <asm/bitops.h> #include <asm/mvme16xhw.h> #include <asm/bootinfo.h> @@ -103,6 +102,7 @@ DECLARE_TASK_QUEUE(tq_cyclades); struct tty_driver cy_serial_driver, cy_callout_driver; +static struct console sercons; extern int serial_console; static struct cyclades_port *serial_console_info = NULL; static unsigned int serial_console_cflag = 0; @@ -2409,6 +2409,7 @@ cy_serial_driver.table = serial_table; cy_serial_driver.termios = serial_termios; cy_serial_driver.termios_locked = serial_termios_locked; + cy_serial_driver.console = &sercons; cy_serial_driver.open = cy_open; cy_serial_driver.close = cy_close; cy_serial_driver.write = cy_write; @@ -2806,58 +2807,6 @@ restore_flags(flags); } -/* This is a hack; if there are multiple chars waiting in the chip we - * discard all but the last one, and return that. The cd2401 is not really - * designed to be driven in polled mode. - */ - -int serial167_console_wait_key(struct console *co) -{ - volatile unsigned char *base_addr = (u_char *)BASE_ADDR; - unsigned long flags; - volatile u_char sink; - u_char ier; - int port; - int keypress = 0; - - save_flags(flags); cli(); - - /* Ensure receiver is enabled! */ - - port = 0; - base_addr[CyCAR] = (u_char)port; - while (base_addr[CyCCR]) - ; - base_addr[CyCCR] = CyENB_RCVR; - ier = base_addr[CyIER]; - base_addr[CyIER] = CyRxData; - - while (!keypress) { - if (pcc2chip[PccSCCRICR] & 0x20) - { - /* We have an Rx int. Acknowledge it */ - sink = pcc2chip[PccRPIACKR]; - if ((base_addr[CyLICR] >> 2) == port) { - int cnt = base_addr[CyRFOC]; - while (cnt-- > 0) - { - keypress = base_addr[CyRDR]; - } - base_addr[CyREOIR] = 0; - } - else - base_addr[CyREOIR] = CyNOTRANS; - } - } - - base_addr[CyIER] = ier; - - restore_flags(flags); - - return keypress; -} - - static kdev_t serial167_console_device(struct console *c) { return MKDEV(TTY_MAJOR, 64 + c->index); @@ -2874,7 +2823,6 @@ name: "ttyS", write: serial167_console_write, device: serial167_console_device, - wait_key: serial167_console_wait_key, setup: serial167_console_setup, flags: CON_PRINTBUFFER, index: -1, diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/char/serial_21285.c linux-2.5/drivers/char/serial_21285.c --- linux-2.5.1/drivers/char/serial_21285.c Thu Sep 13 22:21:32 2001 +++ linux-2.5/drivers/char/serial_21285.c Sun Dec 30 19:12:33 2001 @@ -45,6 +45,7 @@ static struct termios *rs285_termios[1]; static struct termios *rs285_termios_locked[1]; +static struct console rs285_cons; static char wbuf[1000], *putp = wbuf, *getp = wbuf, x_char; static struct tty_struct *rs285_tty; @@ -312,7 +313,9 @@ rs285_driver.table = rs285_table; rs285_driver.termios = rs285_termios; rs285_driver.termios_locked = rs285_termios_locked; - +#ifdef CONFIG_SERIAL_21285_CONSOLE + rs285_driver.console = &rs285_cons; +#endif rs285_driver.open = rs285_open; rs285_driver.close = rs285_close; rs285_driver.write = rs285_write; @@ -389,17 +392,6 @@ enable_irq(IRQ_CONTX); } -static int rs285_console_wait_key(struct console *co) -{ - int c; - - disable_irq(IRQ_CONRX); - while (*CSR_UARTFLG & 0x10); - c = *CSR_UARTDR; - enable_irq(IRQ_CONRX); - return c; -} - static kdev_t rs285_console_device(struct console *c) { return MKDEV(SERIAL_21285_MAJOR, SERIAL_21285_MINOR); @@ -493,7 +485,6 @@ name: SERIAL_21285_NAME, write: rs285_console_write, device: rs285_console_device, - wait_key: rs285_console_wait_key, setup: rs285_console_setup, flags: CON_PRINTBUFFER, index: -1, diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/char/serial_amba.c linux-2.5/drivers/char/serial_amba.c --- linux-2.5.1/drivers/char/serial_amba.c Mon Sep 17 04:23:14 2001 +++ linux-2.5/drivers/char/serial_amba.c Sun Dec 30 13:55:22 2001 @@ -1789,7 +1789,9 @@ ambanormal_driver.table = ambauart_table; ambanormal_driver.termios = ambauart_termios; ambanormal_driver.termios_locked = ambauart_termios_locked; - +#ifdef CONFIG_SERIAL_AMBA_CONSOLE + ambanormal_driver.console = &ambauart_cons; +#endif ambanormal_driver.open = ambauart_open; ambanormal_driver.close = ambauart_close; ambanormal_driver.write = ambauart_write; @@ -1921,22 +1923,6 @@ UART_PUT_CR(port, old_cr); } -/* - * Receive character from the serial port - */ -static int ambauart_console_wait_key(struct console *co) -{ - struct amba_port *port = &amba_ports[co->index]; - unsigned int status; - int c; - - do { - status = UART_GET_FR(port); - } while (!UART_RX_DATA(status)); - c = UART_GET_CHAR(port); - return c; -} - static kdev_t ambauart_console_device(struct console *c) { return MKDEV(SERIAL_AMBA_MAJOR, SERIAL_AMBA_MINOR + c->index); @@ -2015,7 +2001,6 @@ read: ambauart_console_read, #endif device: ambauart_console_device, - wait_key: ambauart_console_wait_key, setup: ambauart_console_setup, flags: CON_PRINTBUFFER, index: -1, diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/char/serial_tx3912.c linux-2.5/drivers/char/serial_tx3912.c --- linux-2.5.1/drivers/char/serial_tx3912.c Fri Nov 9 22:01:21 2001 +++ linux-2.5/drivers/char/serial_tx3912.c Sun Dec 30 13:55:22 2001 @@ -673,7 +673,7 @@ case TIOCGSERIAL: if ((rc = verify_area(VERIFY_WRITE, (void *) arg, sizeof(struct serial_struct))) == 0) - gs_getserial(&port->gs, (struct serial_struct *) arg); + rc = gs_getserial(&port->gs, (struct serial_struct *) arg); break; case TIOCSSERIAL: if ((rc = verify_area(VERIFY_READ, (void *) arg, @@ -854,7 +854,9 @@ rs_driver.table = rs_table; rs_driver.termios = rs_termios; rs_driver.termios_locked = rs_termios_locked; - +#ifdef CONFIG_SERIAL_CONSOLE + rs_driver.console = &sercons; +#endif rs_driver.open = rs_open; rs_driver.close = gs_close; rs_driver.write = gs_write; @@ -993,21 +995,6 @@ IntEnable2 = int2; } -static int serial_console_wait_key(struct console *co) -{ - unsigned int int2, res; - - int2 = IntEnable2; - IntEnable2 = 0; - - while (!(UartA_Ctrl1 & UART_RX_HOLD_FULL)); - res = UartA_Data; - udelay(10); - - IntEnable2 = int2; - return res; -} - static void serial_console_write(struct console *co, const char *s, unsigned count) { @@ -1065,7 +1052,6 @@ name: "ttyS", write: serial_console_write, device: serial_console_device, - wait_key: serial_console_wait_key, setup: serial_console_setup, flags: CON_PRINTBUFFER, index: -1 diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/char/sh-sci.c linux-2.5/drivers/char/sh-sci.c --- linux-2.5.1/drivers/char/sh-sci.c Mon Oct 15 20:36:48 2001 +++ linux-2.5/drivers/char/sh-sci.c Sun Dec 30 13:55:22 2001 @@ -919,7 +919,7 @@ case TIOCGSERIAL: if ((rc = verify_area(VERIFY_WRITE, (void *) arg, sizeof(struct serial_struct))) == 0) - gs_getserial(&port->gs, (struct serial_struct *) arg); + rc = gs_getserial(&port->gs, (struct serial_struct *) arg); break; case TIOCSSERIAL: if ((rc = verify_area(VERIFY_READ, (void *) arg, @@ -1040,7 +1040,9 @@ sci_driver.table = sci_table; sci_driver.termios = sci_termios; sci_driver.termios_locked = sci_termios_locked; - +#ifdef CONFIG_SERIAL_CONSOLE + sci_driver.console = &sercons; +#endif sci_driver.open = sci_open; sci_driver.close = gs_close; sci_driver.write = gs_write; @@ -1181,15 +1183,6 @@ put_string(sercons_port, s, count); } -/* - * Receive character from the serial port - */ -static int serial_console_wait_key(struct console *co) -{ - /* Not implemented yet */ - return 0; -} - static kdev_t serial_console_device(struct console *c) { return MKDEV(SCI_MAJOR, SCI_MINOR_START + c->index); @@ -1273,7 +1266,6 @@ name: "ttySC", write: serial_console_write, device: serial_console_device, - wait_key: serial_console_wait_key, setup: serial_console_setup, flags: CON_PRINTBUFFER, index: -1, diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/char/sx.c linux-2.5/drivers/char/sx.c --- linux-2.5.1/drivers/char/sx.c Fri Nov 9 22:01:21 2001 +++ linux-2.5/drivers/char/sx.c Sun Dec 30 19:12:33 2001 @@ -1160,7 +1160,8 @@ /* DCD went UP */ if( (~(port->gs.flags & ASYNC_NORMAL_ACTIVE) || ~(port->gs.flags & ASYNC_CALLOUT_ACTIVE)) && - (sx_read_channel_byte(port, hi_hstat) != HS_IDLE_CLOSED)) { + (sx_read_channel_byte(port, hi_hstat) != HS_IDLE_CLOSED) && + !(port->gs.tty->termios->c_cflag & CLOCAL) ) { /* Are we blocking in open?*/ sx_dprintk (SX_DEBUG_MODEMSIGNALS, "DCD active, unblocking open\n"); wake_up_interruptible(&port->gs.open_wait); @@ -1170,7 +1171,8 @@ } else { /* DCD went down! */ if (!((port->gs.flags & ASYNC_CALLOUT_ACTIVE) && - (port->gs.flags & ASYNC_CALLOUT_NOHUP))) { + (port->gs.flags & ASYNC_CALLOUT_NOHUP)) && + !(port->gs.tty->termios->c_cflag & CLOCAL) ) { sx_dprintk (SX_DEBUG_MODEMSIGNALS, "DCD dropped. hanging up....\n"); tty_hangup (port->gs.tty); } else { @@ -1815,7 +1817,7 @@ case TIOCGSERIAL: if ((rc = verify_area(VERIFY_WRITE, (void *) arg, sizeof(struct serial_struct))) == 0) - gs_getserial(&port->gs, (struct serial_struct *) arg); + rc = gs_getserial(&port->gs, (struct serial_struct *) arg); break; case TIOCSSERIAL: if ((rc = verify_area(VERIFY_READ, (void *) arg, diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/char/synclink.c linux-2.5/drivers/char/synclink.c --- linux-2.5.1/drivers/char/synclink.c Fri Sep 14 21:39:59 2001 +++ linux-2.5/drivers/char/synclink.c Sun Dec 30 21:17:30 2001 @@ -114,7 +114,6 @@ #endif #endif -#include <asm/segment.h> #define GET_USER(error,value,addr) error = get_user(value,addr) #define COPY_FROM_USER(error,dest,src,size) error = copy_from_user(dest,src,size) ? -EFAULT : 0 #define PUT_USER(error,value,addr) error = put_user(value,addr) @@ -926,7 +925,7 @@ static int __init synclink_init_one (struct pci_dev *dev, const struct pci_device_id *ent); -static void __exit synclink_remove_one (struct pci_dev *dev); +static void __devexit synclink_remove_one (struct pci_dev *dev); static struct pci_device_id synclink_pci_tbl[] __devinitdata = { { PCI_VENDOR_ID_MICROGATE, PCI_DEVICE_ID_MICROGATE_USC, PCI_ANY_ID, PCI_ANY_ID, }, @@ -940,7 +939,7 @@ name: "synclink", id_table: synclink_pci_tbl, probe: synclink_init_one, - remove: synclink_remove_one, + remove: __devexit_p(synclink_remove_one), }; static struct tty_driver serial_driver, callout_driver; @@ -8219,7 +8218,7 @@ return 0; } -static void __exit synclink_remove_one (struct pci_dev *dev) +static void __devexit synclink_remove_one (struct pci_dev *dev) { } diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/char/tty_io.c linux-2.5/drivers/char/tty_io.c --- linux-2.5.1/drivers/char/tty_io.c Fri Nov 30 04:48:58 2001 +++ linux-2.5/drivers/char/tty_io.c Mon Dec 31 18:25:55 2001 @@ -597,12 +597,6 @@ read_unlock(&tasklist_lock); } -void wait_for_keypress(void) -{ - struct console *c = console_drivers; - if (c) c->wait_key(c); -} - void stop_tty(struct tty_struct *tty) { if (tty->stopped) @@ -1339,7 +1333,7 @@ set_bit(TTY_PTY_LOCK, &tty->flags); /* LOCK THE SLAVE */ minor -= driver->minor_start; devpts_pty_new(driver->other->name_base + minor, MKDEV(driver->other->major, minor + driver->other->minor_start)); - tty_register_devfs(&pts_driver[major], DEVFS_FL_NO_PERSISTENCE, + tty_register_devfs(&pts_driver[major], DEVFS_FL_DEFAULT, pts_driver[major].minor_start + minor); noctty = 1; goto init_dev_done; @@ -2188,6 +2182,11 @@ #ifdef CONFIG_SERIAL_CONSOLE #if (defined(CONFIG_8xx) || defined(CONFIG_8260)) console_8xx_init(); +#elif defined(CONFIG_MAC_SERIAL) && defined(CONFIG_SERIAL) + if (_machine == _MACH_Pmac) + mac_scc_console_init(); + else + serial_console_init(); #elif defined(CONFIG_MAC_SERIAL) mac_scc_console_init(); #elif defined(CONFIG_PARISC) @@ -2242,9 +2241,8 @@ static struct tty_driver dev_ptmx_driver; #endif #ifdef CONFIG_VT -extern void con_init_devfs (void); -extern void console_map_init(void); static struct tty_driver dev_console_driver; +extern int vty_init(void); #endif /* @@ -2284,13 +2282,6 @@ if (tty_register_driver(&dev_syscons_driver)) panic("Couldn't register /dev/console driver\n"); - /* console calls tty_register_driver() before kmalloc() works. - * Thus, we can't devfs_register() then. Do so now, instead. - */ -#ifdef CONFIG_VT - con_init_devfs(); -#endif - #ifdef CONFIG_UNIX98_PTYS dev_ptmx_driver = dev_tty_driver; dev_ptmx_driver.driver_name = "/dev/ptmx"; @@ -2314,10 +2305,7 @@ if (tty_register_driver(&dev_console_driver)) panic("Couldn't register /dev/tty0 driver\n"); - - vcs_init(); - kbd_init(); - console_map_init(); + vty_init(); #endif #ifdef CONFIG_ESPSERIAL /* init ESP before rs, so rs doesn't see the port */ diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/char/vme_scc.c linux-2.5/drivers/char/vme_scc.c --- linux-2.5.1/drivers/char/vme_scc.c Mon Sep 17 04:22:50 2001 +++ linux-2.5/drivers/char/vme_scc.c Sun Dec 30 13:55:22 2001 @@ -92,10 +92,10 @@ static void scc_break_ctl(struct tty_struct *tty, int break_state); static struct tty_driver scc_driver, scc_callout_driver; - static struct tty_struct *scc_table[2] = { NULL, }; static struct termios * scc_termios[2]; static struct termios * scc_termios_locked[2]; +static struct console sercons; struct scc_port scc_ports[2]; int scc_refcount; @@ -145,7 +145,9 @@ scc_driver.table = scc_table; scc_driver.termios = scc_termios; scc_driver.termios_locked = scc_termios_locked; - +#ifdef CONFIG_SERIAL_CONSOLE + scc_driver.console = &sercons; +#endif scc_driver.open = scc_open; scc_driver.close = gs_close; scc_driver.write = gs_write; @@ -1065,41 +1067,6 @@ restore_flags(flags); } - -static int scc_console_wait_key(struct console *co) -{ - unsigned long flags; - volatile char *p = NULL; - int c; - -#ifdef CONFIG_MVME147_SCC - if (MACH_IS_MVME147) - p = (volatile char *)M147_SCC_A_ADDR; -#endif -#ifdef CONFIG_MVME162_SCC - if (MACH_IS_MVME16x) - p = (volatile char *)MVME_SCC_A_ADDR; -#endif -#ifdef CONFIG_BVME6000_SCC - if (MACH_IS_BVME6000) - p = (volatile char *)BVME_SCC_A_ADDR; -#endif - - save_flags(flags); - cli(); - - /* wait for rx buf filled */ - while ((*p & 0x01) == 0) - ; - - *p = 8; - scc_delay(); - c = *p; - restore_flags(flags); - return c; -} - - static kdev_t scc_console_device(struct console *c) { return MKDEV(TTY_MAJOR, SCC_MINOR_BASE + c->index); @@ -1116,7 +1083,6 @@ name: "ttyS", write: scc_console_write, device: scc_console_device, - wait_key: scc_console_wait_key, setup: scc_console_setup, flags: CON_PRINTBUFFER, index: -1, diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/char/wdt_pci.c linux-2.5/drivers/char/wdt_pci.c --- linux-2.5.1/drivers/char/wdt_pci.c Fri Nov 30 16:26:04 2001 +++ linux-2.5/drivers/char/wdt_pci.c Sun Dec 16 07:00:17 2001 @@ -558,7 +558,7 @@ } -static void __exit wdtpci_remove_one (struct pci_dev *pdev) +static void __devexit wdtpci_remove_one (struct pci_dev *pdev) { /* here we assume only one device will ever have * been picked up and registered by probe function */ @@ -583,7 +583,7 @@ name: "wdt-pci", id_table: wdtpci_pci_tbl, probe: wdtpci_init_one, - remove: wdtpci_remove_one, + remove: __devexit_p(wdtpci_remove_one), }; diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/i2c/Config.in linux-2.5/drivers/i2c/Config.in --- linux-2.5.1/drivers/i2c/Config.in Thu Oct 11 15:05:47 2001 +++ linux-2.5/drivers/i2c/Config.in Thu Dec 27 16:32:31 2001 @@ -39,6 +39,10 @@ fi fi + if [ "$CONFIG_ALL_PPC" = "y" ] ; then + dep_tristate 'Keywest I2C interface in Apple Core99 machines' CONFIG_I2C_KEYWEST $CONFIG_I2C + fi + # This is needed for automatic patch generation: sensors code starts here # This is needed for automatic patch generation: sensors code ends here diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/i2c/Makefile linux-2.5/drivers/i2c/Makefile --- linux-2.5.1/drivers/i2c/Makefile Thu Oct 11 15:05:47 2001 +++ linux-2.5/drivers/i2c/Makefile Thu Dec 27 16:32:31 2001 @@ -18,6 +18,7 @@ obj-$(CONFIG_ITE_I2C_ALGO) += i2c-algo-ite.o obj-$(CONFIG_ITE_I2C_ADAP) += i2c-adap-ite.o obj-$(CONFIG_I2C_PROC) += i2c-proc.o +obj-$(CONFIG_I2C_KEYWEST) += i2c-keywest.o # This is needed for automatic patch generation: sensors code starts here # This is needed for automatic patch generation: sensors code ends here diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/i2c/i2c-keywest.c linux-2.5/drivers/i2c/i2c-keywest.c --- linux-2.5.1/drivers/i2c/i2c-keywest.c Thu Jan 1 00:00:00 1970 +++ linux-2.5/drivers/i2c/i2c-keywest.c Thu Dec 27 16:32:31 2001 @@ -0,0 +1,671 @@ +/* + i2c Support for Apple Keywest I2C Bus Controller + + Copyright (c) 2001 Benjamin Herrenschmidt <benh@kernel.crashing.org> + + Original work by + + Copyright (c) 2000 Philip Edelbrock <phil@stimpy.netroedge.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 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., 675 Mass Ave, Cambridge, MA 02139, USA. + + Changes: + + 2001/12/13 BenH New implementation + 2001/12/15 BenH Add support for "byte" and "quick" + transfers. Add i2c_xfer routine. + + ToDo: + + Figure out how to use combined mode on the chip + +*/ + +#include <linux/module.h> +#include <linux/config.h> +#include <linux/version.h> +#include <linux/kernel.h> +#include <linux/ioport.h> +#include <linux/pci.h> +#include <linux/types.h> +#include <linux/delay.h> +#include <linux/i2c.h> +#include <linux/init.h> +#include <linux/mm.h> +#include <linux/timer.h> +#include <linux/spinlock.h> +#include <linux/completion.h> + +#include <asm/io.h> +#include <asm/prom.h> +#include <asm/machdep.h> +#include <asm/pmac_feature.h> + +#include "i2c-keywest.h" + +#undef POLLED_MODE + +#define DBG(x...) do {\ + if (debug > 0) \ + printk(KERN_DEBUG "KW:" x); \ + } while(0) + + +MODULE_AUTHOR("Benjamin Herrenschmidt <benh@kernel.crashing.org>"); +MODULE_DESCRIPTION("I2C driver for Apple's Keywest"); +MODULE_LICENSE("GPL"); +MODULE_PARM(probe, "i"); +MODULE_PARM(debug, "i"); +EXPORT_NO_SYMBOLS; + +int probe = 0; +int debug = 0; + +static struct keywest_iface *ifaces = NULL; + +#ifdef POLLED_MODE +/* This isn't fast, but will go once I implement interrupt with + * proper timeout + */ +static u8 +wait_interrupt(struct keywest_iface* iface) +{ + int i; + u8 isr; + + for (i = 0; i < POLL_TIMEOUT; i++) { + isr = read_reg(reg_isr) & KW_I2C_IRQ_MASK; + if (isr != 0) + return isr; + current->state = TASK_UNINTERRUPTIBLE; + schedule_timeout(1); + } + return isr; +} +#endif /* POLLED_MODE */ + + +static void +do_stop(struct keywest_iface* iface, int result) +{ + write_reg(reg_control, read_reg(reg_control) | KW_I2C_CTL_STOP); + iface->state = state_stop; + iface->result = result; +} + +/* Main state machine for standard & standard sub mode */ +static void +handle_interrupt(struct keywest_iface *iface, u8 isr) +{ + int ack; + + DBG("handle_interrupt(), got: %x, status: %x, state: %d\n", + isr, read_reg(reg_status), iface->state); + if (isr == 0 && iface->state != state_stop) { + do_stop(iface, -1); + return; + } + if (isr & KW_I2C_IRQ_STOP && iface->state != state_stop) { + iface->result = -1; + iface->state = state_stop; + } + switch(iface->state) { + case state_addr: + if (!(isr & KW_I2C_IRQ_ADDR)) { + do_stop(iface, -1); + break; + } + ack = read_reg(reg_status); + DBG("ack on set address: %x\n", ack); + if ((ack & KW_I2C_STAT_LAST_AAK) == 0) { + do_stop(iface, -1); + break; + } + /* Handle rw "quick" mode */ + if (iface->datalen == 0) + do_stop(iface, 0); + else if (iface->read_write == I2C_SMBUS_READ) { + iface->state = state_read; + if (iface->datalen > 1) + write_reg(reg_control, read_reg(reg_control) + | KW_I2C_CTL_AAK); + } else { + iface->state = state_write; + DBG("write byte: %x\n", *(iface->data)); + write_reg(reg_data, *(iface->data++)); + iface->datalen--; + } + + break; + case state_read: + if (!(isr & KW_I2C_IRQ_DATA)) { + do_stop(iface, -1); + break; + } + *(iface->data++) = read_reg(reg_data); + DBG("read byte: %x\n", *(iface->data-1)); + iface->datalen--; + if (iface->datalen == 0) + iface->state = state_stop; + else + write_reg(reg_control, 0); + break; + case state_write: + if (!(isr & KW_I2C_IRQ_DATA)) { + do_stop(iface, -1); + break; + } + /* Check ack status */ + ack = read_reg(reg_status); + DBG("ack on data write: %x\n", ack); + if ((ack & KW_I2C_STAT_LAST_AAK) == 0) { + do_stop(iface, -1); + break; + } + if (iface->datalen) { + DBG("write byte: %x\n", *(iface->data)); + write_reg(reg_data, *(iface->data++)); + iface->datalen--; + } else + do_stop(iface, 0); + break; + + case state_stop: + if (!(isr & KW_I2C_IRQ_STOP) && (++iface->stopretry) < 10) + do_stop(iface, -1); + else { + iface->state = state_idle; + write_reg(reg_control, 0x00); + write_reg(reg_ier, 0x00); +#ifndef POLLED_MODE + complete(&iface->complete); +#endif /* POLLED_MODE */ + } + break; + } + + write_reg(reg_isr, isr); +} + +#ifndef POLLED_MODE + +/* Interrupt handler */ +static void +keywest_irq(int irq, void *dev_id, struct pt_regs *regs) +{ + struct keywest_iface *iface = (struct keywest_iface *)dev_id; + + spin_lock(&iface->lock); + del_timer(&iface->timeout_timer); + handle_interrupt(iface, read_reg(reg_isr)); + if (iface->state != state_idle) { + iface->timeout_timer.expires = jiffies + POLL_TIMEOUT; + add_timer(&iface->timeout_timer); + } + spin_unlock(&iface->lock); +} + +static void +keywest_timeout(unsigned long data) +{ + struct keywest_iface *iface = (struct keywest_iface *)data; + + DBG("timeout !\n"); + spin_lock_irq(&iface->lock); + handle_interrupt(iface, read_reg(reg_isr)); + if (iface->state != state_idle) { + iface->timeout_timer.expires = jiffies + POLL_TIMEOUT; + add_timer(&iface->timeout_timer); + } + spin_unlock(&iface->lock); +} + +#endif /* POLLED_MODE */ + +/* + * SMBUS-type transfer entrypoint + */ +static s32 +keywest_smbus_xfer( struct i2c_adapter* adap, + u16 addr, + unsigned short flags, + char read_write, + u8 command, + int size, + union i2c_smbus_data* data) +{ + struct keywest_chan* chan = (struct keywest_chan*)adap->data; + struct keywest_iface* iface = chan->iface; + int len; + u8* buffer; + u16 cur_word; + int rc = 0; + + if (iface->state == state_dead) + return -1; + + /* Prepare datas & select mode */ + iface->cur_mode &= ~KW_I2C_MODE_MODE_MASK; + switch (size) { + case I2C_SMBUS_QUICK: + len = 0; + buffer = NULL; + iface->cur_mode |= KW_I2C_MODE_STANDARD; + break; + case I2C_SMBUS_BYTE: + len = 1; + buffer = &data->byte; + iface->cur_mode |= KW_I2C_MODE_STANDARD; + break; + case I2C_SMBUS_BYTE_DATA: + len = 1; + buffer = &data->byte; + iface->cur_mode |= KW_I2C_MODE_STANDARDSUB; + break; + case I2C_SMBUS_WORD_DATA: + len = 2; + cur_word = cpu_to_le16(data->word); + buffer = (u8 *)&cur_word; + iface->cur_mode |= KW_I2C_MODE_STANDARDSUB; + break; + case I2C_SMBUS_BLOCK_DATA: + len = data->block[0]; + buffer = &data->block[1]; + iface->cur_mode |= KW_I2C_MODE_STANDARDSUB; + break; + default: + return -1; + } + + /* Original driver had this limitation */ + if (len > 32) + len = 32; + + down(&iface->sem); + + DBG("chan: %d, addr: 0x%x, transfer len: %d, read: %d\n", + chan->chan_no, addr, len, read_write == I2C_SMBUS_READ); + + iface->data = buffer; + iface->datalen = len; + iface->state = state_addr; + iface->result = 0; + iface->stopretry = 0; + iface->read_write = read_write; + + /* Setup channel & clear pending irqs */ + write_reg(reg_mode, iface->cur_mode | (chan->chan_no << 4)); + write_reg(reg_isr, read_reg(reg_isr)); + write_reg(reg_status, 0); + + /* Set up address and r/w bit */ + write_reg(reg_addr, + (addr << 1) | ((read_write == I2C_SMBUS_READ) ? 0x01 : 0x00)); + + /* Set up the sub address */ + if ((iface->cur_mode & KW_I2C_MODE_MODE_MASK) == KW_I2C_MODE_STANDARDSUB + || (iface->cur_mode & KW_I2C_MODE_MODE_MASK) == KW_I2C_MODE_COMBINED) + write_reg(reg_subaddr, command); + + /* Arm timeout */ + iface->timeout_timer.expires = jiffies + POLL_TIMEOUT; + add_timer(&iface->timeout_timer); + + /* Start sending address & enable interrupt*/ + write_reg(reg_control, read_reg(reg_control) | KW_I2C_CTL_XADDR); + write_reg(reg_ier, KW_I2C_IRQ_MASK); + +#ifdef POLLED_MODE + DBG("using polled mode...\n"); + /* State machine, to turn into an interrupt handler */ + while(iface->state != state_idle) { + u8 isr = wait_interrupt(iface); + handle_interrupt(iface, isr); + } +#else /* POLLED_MODE */ + DBG("using interrupt mode...\n"); + wait_for_completion(&iface->complete); +#endif /* POLLED_MODE */ + + rc = iface->result; + DBG("transfer done, result: %d\n", rc); + + if (rc == 0 && size == I2C_SMBUS_WORD_DATA && read_write == I2C_SMBUS_READ) + data->word = le16_to_cpu(cur_word); + + /* Release sem */ + up(&iface->sem); + + return rc; +} + +/* + * Generic i2c master transfer entrypoint + */ +static int +keywest_xfer( struct i2c_adapter *adap, + struct i2c_msg msgs[], + int num) +{ + struct keywest_chan* chan = (struct keywest_chan*)adap->data; + struct keywest_iface* iface = chan->iface; + struct i2c_msg *pmsg; + int i, completed; + int rc = 0; + + down(&iface->sem); + + /* Set adapter to standard mode */ + iface->cur_mode &= ~KW_I2C_MODE_MODE_MASK; + iface->cur_mode |= KW_I2C_MODE_STANDARD; + + completed = 0; + for (i = 0; rc >= 0 && i < num;) { + u8 addr; + + pmsg = &msgs[i++]; + addr = pmsg->addr; + if (pmsg->flags & I2C_M_TEN) { + printk(KERN_ERR "i2c-keywest: 10 bits addr not supported !\n"); + rc = -EINVAL; + break; + } + DBG("xfer: chan: %d, doing %s %d bytes to 0x%02x - %d of %d messages\n", + chan->chan_no, + pmsg->flags & I2C_M_RD ? "read" : "write", + pmsg->len, addr, i, num); + + /* Setup channel & clear pending irqs */ + write_reg(reg_mode, iface->cur_mode | (chan->chan_no << 4)); + write_reg(reg_isr, read_reg(reg_isr)); + write_reg(reg_status, 0); + + iface->data = pmsg->buf; + iface->datalen = pmsg->len; + iface->state = state_addr; + iface->result = 0; + iface->stopretry = 0; + if (pmsg->flags & I2C_M_RD) + iface->read_write = I2C_SMBUS_READ; + else + iface->read_write = I2C_SMBUS_WRITE; + + /* Set up address and r/w bit */ + if (pmsg->flags & I2C_M_REV_DIR_ADDR) + addr ^= 1; + write_reg(reg_addr, + (addr << 1) | + ((iface->read_write == I2C_SMBUS_READ) ? 0x01 : 0x00)); + + /* Arm timeout */ + iface->timeout_timer.expires = jiffies + POLL_TIMEOUT; + add_timer(&iface->timeout_timer); + + /* Start sending address & enable interrupt*/ + write_reg(reg_control, read_reg(reg_control) | KW_I2C_CTL_XADDR); + write_reg(reg_ier, KW_I2C_IRQ_MASK); + +#ifdef POLLED_MODE + DBG("using polled mode...\n"); + /* State machine, to turn into an interrupt handler */ + while(iface->state != state_idle) { + u8 isr = wait_interrupt(iface); + handle_interrupt(iface, isr); + } +#else /* POLLED_MODE */88 + DBG("using interrupt mode...\n"); + wait_for_completion(&iface->complete); +#endif /* POLLED_MODE */ + + rc = iface->result; + if (rc == 0) + completed++; + DBG("transfer done, result: %d\n", rc); + } + + /* Release sem */ + up(&iface->sem); + + return completed; +} + +static u32 +keywest_func(struct i2c_adapter * adapter) +{ + return I2C_FUNC_SMBUS_QUICK | I2C_FUNC_SMBUS_BYTE | + I2C_FUNC_SMBUS_BYTE_DATA | I2C_FUNC_SMBUS_WORD_DATA | + I2C_FUNC_SMBUS_BLOCK_DATA; +} + +static void +keywest_inc(struct i2c_adapter *adapter) +{ + MOD_INC_USE_COUNT; +} + +static void +keywest_dec(struct i2c_adapter *adapter) +{ + MOD_DEC_USE_COUNT; +} + +/* For now, we only handle combined mode (smbus) */ +static struct i2c_algorithm keywest_algorithm = { + name: "Keywest i2c", + id: I2C_ALGO_SMBUS, + smbus_xfer: keywest_smbus_xfer, + master_xfer: keywest_xfer, + functionality: keywest_func, +}; + + +static int +create_iface(struct device_node* np) +{ + unsigned long steps, *psteps, *prate; + unsigned bsteps, tsize, i, nchan, addroffset; + struct keywest_iface* iface; + int rc; + + psteps = (unsigned long *)get_property(np, "AAPL,address-step", NULL); + steps = psteps ? (*psteps) : 0x10; + + /* Hrm... maybe we can be smarter here */ + for (bsteps = 0; (steps & 0x01) == 0; bsteps++) + steps >>= 1; + + /* For now, we declare 4 channels on uninorth and 1 on keylargo */ + if (!strcmp(np->parent->name, "uni-n")) { + nchan = 4; + addroffset = 3; + } else { + nchan = 1; + addroffset = 0; + } + + tsize = sizeof(struct keywest_iface) + + (sizeof(struct keywest_chan) + 4) * nchan; + iface = (struct keywest_iface *) kmalloc(tsize, GFP_KERNEL); + if (iface == NULL) { + printk(KERN_ERR "i2c-keywest: can't allocate inteface !\n"); + return -ENOMEM; + } + memset(iface, 0, tsize); + init_MUTEX(&iface->sem); + spin_lock_init(&iface->lock); + init_completion(&iface->complete); + iface->bsteps = bsteps; + iface->chan_count = nchan; + iface->state = state_idle; + iface->irq = np->intrs[0].line; + iface->channels = (struct keywest_chan *) + (((unsigned long)(iface + 1) + 3UL) & ~3UL); + iface->base = (unsigned long)ioremap(np->addrs[0].address + addroffset, + np->addrs[0].size); + if (iface->base == 0) { + printk(KERN_ERR "i2c-keywest: can't map inteface !\n"); + kfree(iface); + return -ENOMEM; + } + + init_timer(&iface->timeout_timer); + iface->timeout_timer.function = keywest_timeout; + iface->timeout_timer.data = (unsigned long)iface; + + /* Select interface rate */ + iface->cur_mode = KW_I2C_MODE_100KHZ; + prate = (unsigned long *)get_property(np, "AAPL,i2c-rate", NULL); + if (prate) switch(*prate) { + case 100: + iface->cur_mode = KW_I2C_MODE_100KHZ; + break; + case 50: + iface->cur_mode = KW_I2C_MODE_50KHZ; + break; + case 25: + iface->cur_mode = KW_I2C_MODE_25KHZ; + break; + default: + printk(KERN_WARNING "i2c-keywest: unknown rate %ldKhz, using 100KHz\n", + *prate); + } + + /* Select standard sub mode */ + iface->cur_mode |= KW_I2C_MODE_STANDARDSUB; + + /* Write mode */ + write_reg(reg_mode, iface->cur_mode); + + /* Switch interrupts off & clear them*/ + write_reg(reg_ier, 0x00); + write_reg(reg_isr, KW_I2C_IRQ_MASK); + +#ifndef POLLED_MODE + /* Request chip interrupt */ + rc = request_irq(iface->irq, keywest_irq, 0, "keywest i2c", iface); + if (rc) { + printk(KERN_ERR "i2c-keywest: can't get IRQ %d !\n", iface->irq); + iounmap((void *)iface->base); + kfree(iface); + return -ENODEV; + } +#endif /* POLLED_MODE */ + + for (i=0; i<nchan; i++) { + struct keywest_chan* chan = &iface->channels[i]; + u8 addr; + + sprintf(chan->adapter.name, "%s %d", np->parent->name, i); + chan->iface = iface; + chan->chan_no = i; + chan->adapter.id = I2C_ALGO_SMBUS; + chan->adapter.algo = &keywest_algorithm; + chan->adapter.algo_data = NULL; + chan->adapter.inc_use = keywest_inc; + chan->adapter.dec_use = keywest_dec; + chan->adapter.client_register = NULL; + chan->adapter.client_unregister = NULL; + chan->adapter.data = chan; + + rc = i2c_add_adapter(&chan->adapter); + if (rc) { + printk("i2c-keywest.c: Adapter %s registration failed\n", + chan->adapter.name); + chan->adapter.data = NULL; + } + if (probe) { + printk("Probe: "); + for (addr = 0x00; addr <= 0x7f; addr++) { + if (i2c_smbus_xfer(&chan->adapter,addr, + 0,0,0,I2C_SMBUS_QUICK,NULL) >= 0) + printk("%02x ", addr); + } + printk("\n"); + } + } + + printk(KERN_INFO "Found KeyWest i2c on \"%s\", %d channel%s, stepping: %d bits\n", + np->parent->name, nchan, nchan > 1 ? "s" : "", bsteps); + + iface->next = ifaces; + ifaces = iface; + return 0; +} + +static void +dispose_iface(struct keywest_iface *iface) +{ + int i, rc; + + ifaces = iface->next; + + /* Make sure we stop all activity */ + down(&iface->sem); +#ifndef POLLED_MODE + spin_lock_irq(&iface->lock); + while (iface->state != state_idle) { + spin_unlock_irq(&iface->lock); + schedule(); + spin_lock_irq(&iface->lock); + } +#endif /* POLLED_MODE */ + iface->state = state_dead; +#ifndef POLLED_MODE + spin_unlock_irq(&iface->lock); + free_irq(iface->irq, iface); +#endif /* POLLED_MODE */ + up(&iface->sem); + + /* Release all channels */ + for (i=0; i<iface->chan_count; i++) { + struct keywest_chan* chan = &iface->channels[i]; + if (!chan->adapter.data) + continue; + rc = i2c_del_adapter(&chan->adapter); + chan->adapter.data = NULL; + /* We aren't that prepared to deal with this... */ + if (rc) + printk("i2c-keywest.c: i2c_del_adapter failed, that's bad !\n"); + } + iounmap((void *)iface->base); + kfree(iface); +} + +static int __init +i2c_keywest_init(void) +{ + struct device_node *np; + int rc = -ENODEV; + + np = find_compatible_devices("i2c", "keywest"); + while (np != 0) { + if (np->n_addrs >= 1 && np->n_intrs >= 1) + rc = create_iface(np); + np = np->next; + } + if (ifaces) + rc = 0; + return rc; +} + +static void __exit +i2c_keywest_cleanup(void) +{ + while(ifaces) + dispose_iface(ifaces); +} + +module_init(i2c_keywest_init); +module_exit(i2c_keywest_cleanup); diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/i2c/i2c-keywest.h linux-2.5/drivers/i2c/i2c-keywest.h --- linux-2.5.1/drivers/i2c/i2c-keywest.h Thu Jan 1 00:00:00 1970 +++ linux-2.5/drivers/i2c/i2c-keywest.h Thu Dec 27 16:32:31 2001 @@ -0,0 +1,111 @@ +#ifndef __I2C_KEYWEST_H__ +#define __I2C_KEYWEST_H__ + +/* The Tumbler audio equalizer can be really slow sometimes */ +#define POLL_TIMEOUT (2*HZ) + +/* Register indices */ +typedef enum { + reg_mode = 0, + reg_control, + reg_status, + reg_isr, + reg_ier, + reg_addr, + reg_subaddr, + reg_data +} reg_t; + + +/* Mode register */ +#define KW_I2C_MODE_100KHZ 0x00 +#define KW_I2C_MODE_50KHZ 0x01 +#define KW_I2C_MODE_25KHZ 0x02 +#define KW_I2C_MODE_DUMB 0x00 +#define KW_I2C_MODE_STANDARD 0x04 +#define KW_I2C_MODE_STANDARDSUB 0x08 +#define KW_I2C_MODE_COMBINED 0x0C +#define KW_I2C_MODE_MODE_MASK 0x0C +#define KW_I2C_MODE_CHAN_MASK 0xF0 + +/* Control register */ +#define KW_I2C_CTL_AAK 0x01 +#define KW_I2C_CTL_XADDR 0x02 +#define KW_I2C_CTL_STOP 0x04 +#define KW_I2C_CTL_START 0x08 + +/* Status register */ +#define KW_I2C_STAT_BUSY 0x01 +#define KW_I2C_STAT_LAST_AAK 0x02 +#define KW_I2C_STAT_LAST_RW 0x04 +#define KW_I2C_STAT_SDA 0x08 +#define KW_I2C_STAT_SCL 0x10 + +/* IER & ISR registers */ +#define KW_I2C_IRQ_DATA 0x01 +#define KW_I2C_IRQ_ADDR 0x02 +#define KW_I2C_IRQ_STOP 0x04 +#define KW_I2C_IRQ_START 0x08 +#define KW_I2C_IRQ_MASK 0x0F + +/* Physical interface */ +struct keywest_iface +{ + unsigned long base; + unsigned bsteps; + int irq; + struct semaphore sem; + spinlock_t lock; + struct keywest_chan* channels; + unsigned chan_count; + u8 cur_mode; + char read_write; + u8* data; + unsigned datalen; + int state; + int result; + int stopretry; + struct timer_list timeout_timer; + struct completion complete; + struct keywest_iface* next; +}; + +enum { + state_idle, + state_addr, + state_read, + state_write, + state_stop, + state_dead +}; + +/* Channel on an interface */ +struct keywest_chan +{ + struct i2c_adapter adapter; + struct keywest_iface* iface; + unsigned chan_no; +}; + +/* Register access */ + +static inline u8 __read_reg(struct keywest_iface *iface, reg_t reg) +{ + return in_8(((volatile u8 *)iface->base) + + (((unsigned)reg) << iface->bsteps)); +} + +static inline void __write_reg(struct keywest_iface *iface, reg_t reg, u8 val) +{ + out_8(((volatile u8 *)iface->base) + + (((unsigned)reg) << iface->bsteps), val); + (void)__read_reg(iface, reg); + udelay(10); +} + +#define write_reg(reg, val) __write_reg(iface, reg, val) +#define read_reg(reg) __read_reg(iface, reg) + + + +#endif /* __I2C_KEYWEST_H__ */ diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/ide/amd74xx.c linux-2.5/drivers/ide/amd74xx.c --- linux-2.5.1/drivers/ide/amd74xx.c Tue Nov 27 17:23:27 2001 +++ linux-2.5/drivers/ide/amd74xx.c Thu Dec 20 19:14:29 2001 @@ -459,6 +459,8 @@ hwif->tuneproc = &amd74xx_tune_drive; hwif->speedproc = &amd74xx_tune_chipset; + hwif->highmem = 1; + #ifndef CONFIG_BLK_DEV_IDEDMA hwif->drives[0].autotune = 1; hwif->drives[1].autotune = 1; diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/ide/hptraid.c linux-2.5/drivers/ide/hptraid.c --- linux-2.5.1/drivers/ide/hptraid.c Mon Oct 15 20:27:42 2001 +++ linux-2.5/drivers/ide/hptraid.c Thu Dec 27 22:10:28 2001 @@ -226,32 +226,20 @@ #include "hptraid.h" -static int read_disk_sb (int major, int minor, unsigned char *buffer,int bufsize) +static int __init read_disk_sb(struct block_device *bdev, + struct highpoint_raid_conf *buf) { - int ret = -EINVAL; - struct buffer_head *bh = NULL; - kdev_t dev = MKDEV(major,minor); - - if (blksize_size[major]==NULL) /* device doesn't exist */ - return -EINVAL; - - - /* Superblock is at 4096+412 bytes */ - set_blocksize (dev, 4096); - bh = bread (dev, 1, 4096); - - - if (bh) { - memcpy (buffer, bh->b_data, bufsize); - } else { - printk(KERN_ERR "hptraid: Error reading superblock.\n"); - goto abort; + /* Superblock is at 9*512 bytes */ + Sector sect; + unsigned char *p = read_dev_sector(bdev, 9, §); + + if (p) { + memcpy(buf, p, 512); + put_dev_sector(§); + return 0; } - ret = 0; -abort: - if (bh) - brelse (bh); - return ret; + printk(KERN_ERR "hptraid: Error reading superblock.\n"); + return -1; } static unsigned long maxsectors (int major,int minor) @@ -276,55 +264,58 @@ return lba; } +static struct highpoint_raid_conf __initdata prom; static void __init probedisk(int major, int minor,int device) { int i; - struct highpoint_raid_conf *prom; - static unsigned char block[4096]; - struct block_device *bdev; - - if (maxsectors(major,minor)==0) + struct block_device *bdev = bdget(MKDEV(major,minor)); + struct gendisk *gd; + + if (!bdev) return; - - if (read_disk_sb(major,minor,(unsigned char*)&block,sizeof(block))) - return; - - prom = (struct highpoint_raid_conf*)&block[512]; - - if (prom->magic!= 0x5a7816f0) - return; - if (prom->type) { + + if (blkdev_get(bdev,FMODE_READ|FMODE_WRITE,0,BDEV_RAW) < 0) + return; + + if (maxsectors(major,minor)==0) + goto out; + + if (read_disk_sb(bdev, &prom)) + goto out; + + if (prom.magic!= 0x5a7816f0) + goto out; + if (prom.type) { printk(KERN_INFO "hptraid: only RAID0 is supported currently\n"); - return; + goto out; } - i = prom->disk_number; + i = prom.disk_number; if (i<0) - return; + goto out; if (i>8) - return; + goto out; + + raid[device].disk[i].bdev = bdev; + /* This is supposed to prevent others from stealing our underlying disks */ + /* now blank the /proc/partitions table for the wrong partition table, + so that scripts don't accidentally mount it and crash the kernel */ + /* XXX: the 0 is an utter hack --hch */ + gd=get_gendisk(MKDEV(major, 0)); + if (gd!=NULL) { + int j; + for (j=1+(minor<<gd->minor_shift);j<((minor+1)<<gd->minor_shift);j++) + gd->part[j].nr_sects=0; + } - bdev = bdget(MKDEV(major,minor)); - if (bdev && blkdev_get(bdev,FMODE_READ|FMODE_WRITE,0,BDEV_RAW) == 0) { - int j=0; - struct gendisk *gd; - raid[device].disk[i].bdev = bdev; - /* This is supposed to prevent others from stealing our underlying disks */ - /* now blank the /proc/partitions table for the wrong partition table, - so that scripts don't accidentally mount it and crash the kernel */ - /* XXX: the 0 is an utter hack --hch */ - gd=get_gendisk(MKDEV(major, 0)); - if (gd!=NULL) { - for (j=1+(minor<<gd->minor_shift);j<((minor+1)<<gd->minor_shift);j++) - gd->part[j].nr_sects=0; - } - } raid[device].disk[i].device = MKDEV(major,minor); raid[device].disk[i].sectors = maxsectors(major,minor); - raid[device].stride = (1<<prom->raid0_shift); - raid[device].disks = prom->raid_disks; - raid[device].sectors = prom->total_secs; - + raid[device].stride = (1<<prom.raid0_shift); + raid[device].disks = prom.raid_disks; + raid[device].sectors = prom.total_secs; + return; +out: + blkdev_put(bdev); } static void __init fill_cutoff(int device) diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/ide/icside.c linux-2.5/drivers/ide/icside.c --- linux-2.5.1/drivers/ide/icside.c Thu Oct 25 20:53:47 2001 +++ linux-2.5/drivers/ide/icside.c Thu Dec 27 22:10:28 2001 @@ -27,6 +27,7 @@ #include <asm/io.h> extern char *ide_xfer_verbose (byte xfer_rate); +extern char *ide_dmafunc_verbose(ide_dma_action_t dmafunc); /* * Maximum number of interfaces per card @@ -225,29 +226,18 @@ static int ide_build_sglist(ide_hwif_t *hwif, struct request *rq) { - struct buffer_head *bh; + request_queue_t *q = &hwif->drives[DEVICE_NR(rq->rq_dev) & 1].queue; struct scatterlist *sg = hwif->sg_table; - int nents = 0; + int nents = blk_rq_map_sg(q, rq, sg); - if (rq->cmd == READ) + if (rq->q && nents > rq->nr_phys_segments) + printk("icside: received %d segments, build %d\n", + rq->nr_phys_segments, nents); + + if (rq_data_dir(rq) == READ) hwif->sg_dma_direction = PCI_DMA_FROMDEVICE; else hwif->sg_dma_direction = PCI_DMA_TODEVICE; - bh = rq->bh; - do { - unsigned char *virt_addr = bh->b_data; - unsigned int size = bh->b_size; - - while ((bh = bh->b_reqnext) != NULL) { - if ((virt_addr + size) != (unsigned char *)bh->b_data) - break; - size += bh->b_size; - } - memset(&sg[nents], 0, sizeof(*sg)); - sg[nents].address = virt_addr; - sg[nents].length = size; - nents++; - } while (bh != NULL); return pci_map_sg(NULL, sg, nents, hwif->sg_dma_direction); } @@ -267,39 +257,56 @@ pci_unmap_sg(NULL, sg, nents, HWIF(drive)->sg_dma_direction); } +/* + * Configure the IOMD to give the appropriate timings for the transfer + * mode being requested. We take the advice of the ATA standards, and + * calculate the cycle time based on the transfer mode, and the EIDE + * MW DMA specs that the drive provides in the IDENTIFY command. + * + * We have the following IOMD DMA modes to choose from: + * + * Type Active Recovery Cycle + * A 250 (250) 312 (550) 562 (800) + * B 187 250 437 + * C 125 (125) 125 (375) 250 (500) + * D 62 125 187 + * + * (figures in brackets are actual measured timings) + * + * However, we also need to take care of the read/write active and + * recovery timings: + * + * Read Write + * Mode Active -- Recovery -- Cycle IOMD type + * MW0 215 50 215 480 A + * MW1 80 50 50 150 C + * MW2 70 25 25 120 C + */ static int icside_config_if(ide_drive_t *drive, int xfer_mode) { int func = ide_dma_off; + int cycle_time = 0, use_dma_info = 0; switch (xfer_mode) { - case XFER_MW_DMA_2: - /* - * The cycle time is limited to 250ns by the r/w - * pulse width (90ns), however we should still - * have a maximum burst transfer rate of 8MB/s. - */ - drive->drive_data = 250; - break; - - case XFER_MW_DMA_1: - drive->drive_data = 250; - break; + case XFER_MW_DMA_2: cycle_time = 250; use_dma_info = 1; break; + case XFER_MW_DMA_1: cycle_time = 250; use_dma_info = 1; break; + case XFER_MW_DMA_0: cycle_time = 480; break; + } - case XFER_MW_DMA_0: - drive->drive_data = 480; - break; + /* + * If we're going to be doing MW_DMA_1 or MW_DMA_2, we should + * take care to note the values in the ID... + */ + if (use_dma_info && drive->id->eide_dma_time > cycle_time) + cycle_time = drive->id->eide_dma_time; - default: - drive->drive_data = 0; - break; - } + drive->drive_data = cycle_time; if (!drive->init_speed) - drive->init_speed = (byte) xfer_mode; + drive->init_speed = xfer_mode; - if (drive->drive_data && - ide_config_drive_speed(drive, (byte) xfer_mode) == 0) + if (cycle_time && ide_config_drive_speed(drive, xfer_mode) == 0) func = ide_dma_on; else drive->drive_data = 480; @@ -307,7 +314,7 @@ printk("%s: %s selected (peak %dMB/s)\n", drive->name, ide_xfer_verbose(xfer_mode), 2000 / drive->drive_data); - drive->current_speed = (byte) xfer_mode; + drive->current_speed = xfer_mode; return func; } @@ -414,7 +421,7 @@ * This is setup to be called as an extern for future support * to other special driver code. */ -static int check_drive_lists(ide_drive_t *drive, int good_bad) +static int icside_check_drive_lists(ide_drive_t *drive, int good_bad) { struct hd_driveid *id = drive->id; @@ -444,7 +451,7 @@ /* * Consult the list of known "bad" drives */ - if (check_drive_lists(drive, 0)) { + if (icside_check_drive_lists(drive, 0)) { func = ide_dma_off; goto out; } @@ -469,7 +476,7 @@ /* * Consult the list of known "good" drives */ - if (check_drive_lists(drive, 1)) { + if (icside_check_drive_lists(drive, 1)) { if (id->eide_dma_time > 150) goto out; xfer_mode = XFER_MW_DMA_1; @@ -502,6 +509,11 @@ case ide_dma_off_quietly: case ide_dma_on: + /* + * We don't need any bouncing. Yes, this looks the + * wrong way around, but it is correct. + */ + blk_queue_bounce_limit(&drive->queue, BLK_BOUNCE_ANY); drive->using_dma = (func == ide_dma_on); return 0; @@ -553,7 +565,8 @@ case ide_dma_bad_drive: case ide_dma_good_drive: - return check_drive_lists(drive, (func == ide_dma_good_drive)); + return icside_check_drive_lists(drive, (func == + ide_dma_good_drive)); case ide_dma_verbose: return icside_dma_verbose(drive); @@ -590,6 +603,15 @@ failed: printk(" -- ERROR, unable to allocate DMA table\n"); return 0; +} + +int ide_release_dma(ide_hwif_t *hwif) +{ + if (hwif->sg_table) { + kfree(hwif->sg_table); + hwif->sg_table = NULL; + } + return 1; } #endif diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/ide/ide-cd.c linux-2.5/drivers/ide/ide-cd.c --- linux-2.5.1/drivers/ide/ide-cd.c Sun Dec 9 04:02:47 2001 +++ linux-2.5/drivers/ide/ide-cd.c Thu Dec 27 16:32:31 2001 @@ -594,7 +594,7 @@ cdrom_end_request (1, drive); *startstop = ide_error (drive, "request sense failure", stat); return 1; - } else if (rq->flags & REQ_PC) { + } else if (rq->flags & (REQ_PC | REQ_BLOCK_PC)) { /* All other functions, except for READ. */ struct completion *wait = NULL; pc = (struct packet_command *) rq->special; @@ -2588,6 +2588,13 @@ if (cap.mechtype == mechtype_caddy || cap.mechtype == mechtype_popup) CDROM_CONFIG_FLAGS (drive)->close_tray = 0; + /* Some drives used by Apple don't advertise audio play + * but they do support reading TOC & audio datas + */ + if (strcmp (drive->id->model, "MATSHITADVD-ROM SR-8187") == 0 || + strcmp (drive->id->model, "MATSHITADVD-ROM SR-8186") == 0) + CDROM_CONFIG_FLAGS (drive)->audio_play = 1; + #if ! STANDARD_ATAPI if (cdi->sanyo_slot > 0) { CDROM_CONFIG_FLAGS (drive)->is_changer = 1; @@ -2674,6 +2681,8 @@ set_device_ro(MKDEV(HWIF(drive)->major, minor), 1); set_blocksize(MKDEV(HWIF(drive)->major, minor), CD_FRAMESIZE); blk_queue_hardsect_size(&drive->queue, CD_FRAMESIZE); + + blk_queue_prep_rq(&drive->queue, ll_10byte_cmd_build); drive->special.all = 0; drive->ready_stat = 0; diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/ide/ide-disk.c linux-2.5/drivers/ide/ide-disk.c --- linux-2.5.1/drivers/ide/ide-disk.c Thu Dec 6 22:02:57 2001 +++ linux-2.5/drivers/ide/ide-disk.c Thu Dec 13 16:32:35 2001 @@ -863,8 +863,10 @@ } /* We must remove proc entries defined in this module. Otherwise we oops while accessing these entries */ +#ifdef CONFIG_PROC_FS if (drive->proc) ide_remove_proc_entries(drive->proc, idedisk_proc); +#endif } ide_unregister_module(&idedisk_module); } diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/ide/ide-floppy.c linux-2.5/drivers/ide/ide-floppy.c --- linux-2.5.1/drivers/ide/ide-floppy.c Fri Nov 30 16:33:50 2001 +++ linux-2.5/drivers/ide/ide-floppy.c Fri Dec 28 01:03:55 2001 @@ -336,23 +336,7 @@ #define IDEFLOPPY_IOCTL_FORMAT_START 0x4602 #define IDEFLOPPY_IOCTL_FORMAT_GET_PROGRESS 0x4603 -/* - * Special requests for our block device strategy routine. - */ -#define IDEFLOPPY_FIRST_RQ 90 - -/* - * IDEFLOPPY_PC_RQ is used to queue a packet command in the request queue. - */ -#define IDEFLOPPY_PC_RQ 90 - -#define IDEFLOPPY_LAST_RQ 90 - -/* - * A macro which can be used to check if a given request command - * originated in the driver or in the buffer cache layer. - */ -#define IDEFLOPPY_RQ_CMD(cmd) ((cmd >= IDEFLOPPY_FIRST_RQ) && (cmd <= IDEFLOPPY_LAST_RQ)) +#define IDEFLOPPY_RQ (REQ_SPECIAL) /* * Error codes which are returned in rq->errors to the higher part @@ -696,7 +680,7 @@ /* Why does this happen? */ if (!rq) return; - if (!IDEFLOPPY_RQ_CMD (rq->cmd)) { + if (rq->flags & IDEFLOPPY_RQ) { ide_end_request (uptodate, hwgroup); return; } @@ -776,7 +760,7 @@ { ide_init_drive_cmd (rq); rq->buffer = (char *) pc; - rq->cmd = IDEFLOPPY_PC_RQ; + rq->flags = IDEFLOPPY_RQ; (void) ide_do_drive_cmd (drive, rq, ide_preempt); } @@ -1192,6 +1176,7 @@ { int block = sector / floppy->bs_factor; int blocks = rq->nr_sectors / floppy->bs_factor; + int cmd = rq_data_dir(rq); #if IDEFLOPPY_DEBUG_LOG printk ("create_rw1%d_cmd: block == %d, blocks == %d\n", @@ -1200,18 +1185,18 @@ idefloppy_init_pc (pc); if (test_bit (IDEFLOPPY_USE_READ12, &floppy->flags)) { - pc->c[0] = rq->cmd == READ ? IDEFLOPPY_READ12_CMD : IDEFLOPPY_WRITE12_CMD; + pc->c[0] = cmd == READ ? IDEFLOPPY_READ12_CMD : IDEFLOPPY_WRITE12_CMD; put_unaligned (htonl (blocks), (unsigned int *) &pc->c[6]); } else { - pc->c[0] = rq->cmd == READ ? IDEFLOPPY_READ10_CMD : IDEFLOPPY_WRITE10_CMD; + pc->c[0] = cmd == READ ? IDEFLOPPY_READ10_CMD : IDEFLOPPY_WRITE10_CMD; put_unaligned (htons (blocks), (unsigned short *) &pc->c[7]); } put_unaligned (htonl (block), (unsigned int *) &pc->c[2]); pc->callback = &idefloppy_rw_callback; pc->rq = rq; pc->b_data = rq->buffer; - pc->b_count = rq->cmd == READ ? 0 : rq->bio->bi_size; - if (rq->cmd == WRITE) + pc->b_count = cmd == READ ? 0 : rq->bio->bi_size; + if (rq->flags & REQ_RW) set_bit (PC_WRITING, &pc->flags); pc->buffer = NULL; pc->request_transfer = pc->buffer_size = blocks * floppy->block_size; @@ -1227,8 +1212,8 @@ idefloppy_pc_t *pc; #if IDEFLOPPY_DEBUG_LOG - printk (KERN_INFO "rq_status: %d, rq_dev: %u, cmd: %d, errors: %d\n",rq->rq_status,(unsigned int) rq->rq_dev,rq->cmd,rq->errors); - printk (KERN_INFO "sector: %ld, nr_sectors: %ld, current_nr_sectors: %ld\n",rq->sector,rq->nr_sectors,rq->current_nr_sectors); + printk (KERN_INFO "rq_status: %d, rq_dev: %u, flags: %lx, errors: %d\n",rq->rq_status,(unsigned int) rq->rq_dev,rq->flags,rq->errors); + printk (KERN_INFO "sector: %ld, nr_sectors: %ld, current_nr_sectors: %d\n",rq->sector,rq->nr_sectors,rq->current_nr_sectors); #endif /* IDEFLOPPY_DEBUG_LOG */ if (rq->errors >= ERROR_MAX) { @@ -1240,24 +1225,20 @@ idefloppy_end_request (0, HWGROUP(drive)); return ide_stopped; } - switch (rq->cmd) { - case READ: - case WRITE: - if (rq->sector % floppy->bs_factor || rq->nr_sectors % floppy->bs_factor) { - printk ("%s: unsupported r/w request size\n", drive->name); - idefloppy_end_request (0, HWGROUP(drive)); - return ide_stopped; - } - pc = idefloppy_next_pc_storage (drive); - idefloppy_create_rw_cmd (floppy, pc, rq, block); - break; - case IDEFLOPPY_PC_RQ: - pc = (idefloppy_pc_t *) rq->buffer; - break; - default: - printk (KERN_ERR "ide-floppy: unsupported command %x in request queue\n", rq->cmd); - idefloppy_end_request (0,HWGROUP (drive)); + if (rq->flags & REQ_CMD) { + if (rq->sector % floppy->bs_factor || rq->nr_sectors % floppy->bs_factor) { + printk ("%s: unsupported r/w request size\n", drive->name); + idefloppy_end_request (0, HWGROUP(drive)); return ide_stopped; + } + pc = idefloppy_next_pc_storage (drive); + idefloppy_create_rw_cmd (floppy, pc, rq, block); + } else if (rq->flags & IDEFLOPPY_RQ) { + pc = (idefloppy_pc_t *) rq->buffer; + } else { + blk_dump_rq_flags(rq, "ide-floppy: unsupported command in queue"); + idefloppy_end_request (0,HWGROUP (drive)); + return ide_stopped; } pc->rq = rq; return idefloppy_issue_pc (drive, pc); @@ -1273,7 +1254,7 @@ ide_init_drive_cmd (&rq); rq.buffer = (char *) pc; - rq.cmd = IDEFLOPPY_PC_RQ; + rq.flags = IDEFLOPPY_RQ; return ide_do_drive_cmd (drive, &rq, ide_wait); } @@ -2048,10 +2029,13 @@ printk ("%s: cleanup_module() called while still busy\n", drive->name); failed++; } + +#ifdef CONFIG_PROC_FS /* We must remove proc entries defined in this module. Otherwise we oops while accessing these entries */ if (drive->proc) ide_remove_proc_entries(drive->proc, idefloppy_proc); +#endif } ide_unregister_module(&idefloppy_module); } diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/ide/ide-m8xx.c linux-2.5/drivers/ide/ide-m8xx.c --- linux-2.5.1/drivers/ide/ide-m8xx.c Mon Oct 8 18:40:13 2001 +++ linux-2.5/drivers/ide/ide-m8xx.c Thu Dec 27 16:32:31 2001 @@ -1,8 +1,14 @@ /* - * - * * linux/drivers/ide/ide-m8xx.c * + * Copyright (C) 2000, 2001 Wolfgang Denk, wd@denx.de + * Modified for direct IDE interface + * by Thomas Lange, thomas@corelatus.com + * Modified for direct IDE interface on 8xx without using the PCMCIA + * controller + * by Steven.Scholz@imc-berlin.de + * Moved out of arch/ppc/kernel/m8xx_setup.c, other minor cleanups + * by Mathew Locke <mattl@mvista.com> */ #include <linux/config.h> diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/ide/ide-pmac.c linux-2.5/drivers/ide/ide-pmac.c --- linux-2.5.1/drivers/ide/ide-pmac.c Tue Oct 2 16:08:40 2001 +++ linux-2.5/drivers/ide/ide-pmac.c Thu Dec 27 16:32:31 2001 @@ -1,5 +1,5 @@ /* - * linux/drivers/ide/ide-pmac.c Version ?.?? Mar. 18, 2000 + * linux/drivers/ide/ide-pmac.c * * Support for IDE interfaces on PowerMacs. * These IDE interfaces are memory-mapped and have a DBDMA channel @@ -24,26 +24,29 @@ #include <linux/init.h> #include <linux/delay.h> #include <linux/ide.h> - +#include <linux/notifier.h> +#include <linux/reboot.h> #include <asm/prom.h> #include <asm/io.h> #include <asm/dbdma.h> #include <asm/ide.h> #include <asm/mediabay.h> -#include <asm/feature.h> +#include <asm/machdep.h> +#include <asm/pmac_feature.h> +#include <asm/sections.h> +#include <asm/irq.h> #ifdef CONFIG_PMAC_PBOOK #include <linux/adb.h> #include <linux/pmu.h> -#include <asm/irq.h> #endif #include "ide_modes.h" extern char *ide_dmafunc_verbose(ide_dma_action_t dmafunc); +extern void ide_do_request(ide_hwgroup_t *hwgroup, int masked_irq); -#undef IDE_PMAC_DEBUG +#define IDE_PMAC_DEBUG -#define IDE_SYSCLK_NS 30 -#define IDE_SYSCLK_ULTRA_PS 0x1d4c /* (15 * 1000 / 2)*/ +#define DMA_WAIT_TIMEOUT 500 struct pmac_ide_hwif { ide_ioreg_t regbase; @@ -52,12 +55,14 @@ int aapl_bus_id; struct device_node* node; u32 timings[2]; + struct resource* reg_resource; #ifdef CONFIG_BLK_DEV_IDEDMA_PMAC volatile struct dbdma_regs* dma_regs; struct dbdma_cmd* dma_table; + struct resource* dma_resource; #endif -} pmac_ide[MAX_HWIFS]; +} pmac_ide[MAX_HWIFS] __pmacdata; static int pmac_ide_count; @@ -65,33 +70,145 @@ controller_ohare, /* OHare based */ controller_heathrow, /* Heathrow/Paddington */ controller_kl_ata3, /* KeyLargo ATA-3 */ - controller_kl_ata4 /* KeyLargo ATA-4 */ + controller_kl_ata4, /* KeyLargo ATA-4 */ + controller_kl_ata4_80 /* KeyLargo ATA-4 with 80 conductor cable */ }; +/* + * Timing register definitions + */ + +/* Number of IDE_SYSCLK_NS ticks, argument is in nanoseconds */ +#define SYSCLK_TICKS(t) (((t) + IDE_SYSCLK_NS - 1) / IDE_SYSCLK_NS) +#define SYSCLK_TICKS_66(t) (((t) + IDE_SYSCLK_66_NS - 1) / IDE_SYSCLK_66_NS) +#define IDE_SYSCLK_NS 30 /* 33Mhz cell */ +#define IDE_SYSCLK_66_NS 15 /* 66Mhz cell */ + +/* 66Mhz cell, found in KeyLargo. Can do ultra mode 0 to 2 on + * 40 connector cable and to 4 on 80 connector one. + * Clock unit is 15ns (66Mhz) + * + * 3 Values can be programmed: + * - Write data setup, which appears to match the cycle time. They + * also call it DIOW setup. + * - Ready to pause time (from spec) + * - Address setup. That one is weird. I don't see where exactly + * it fits in UDMA cycles, I got it's name from an obscure piece + * of commented out code in Darwin. They leave it to 0, we do as + * well, despite a comment that would lead to think it has a + * min value of 45ns. + * Apple also add 60ns to the write data setup (or cycle time ?) on + * reads. I can't explain that, I tried it and it broke everything + * here. + */ +#define TR_66_UDMA_MASK 0xfff00000 +#define TR_66_UDMA_EN 0x00100000 /* Enable Ultra mode for DMA */ +#define TR_66_UDMA_ADDRSETUP_MASK 0xe0000000 /* Address setup */ +#define TR_66_UDMA_ADDRSETUP_SHIFT 29 +#define TR_66_UDMA_RDY2PAUS_MASK 0x1e000000 /* Ready 2 pause time */ +#define TR_66_UDMA_RDY2PAUS_SHIFT 25 +#define TR_66_UDMA_WRDATASETUP_MASK 0x01e00000 /* Write data setup time */ +#define TR_66_UDMA_WRDATASETUP_SHIFT 21 +#define TR_66_MDMA_MASK 0x000ffc00 +#define TR_66_MDMA_RECOVERY_MASK 0x000f8000 +#define TR_66_MDMA_RECOVERY_SHIFT 15 +#define TR_66_MDMA_ACCESS_MASK 0x00007c00 +#define TR_66_MDMA_ACCESS_SHIFT 10 +#define TR_66_PIO_MASK 0x000003ff +#define TR_66_PIO_RECOVERY_MASK 0x000003e0 +#define TR_66_PIO_RECOVERY_SHIFT 5 +#define TR_66_PIO_ACCESS_MASK 0x0000001f +#define TR_66_PIO_ACCESS_SHIFT 0 + +/* 33Mhz cell, found in OHare, Heathrow (& Paddington) and KeyLargo + * Can do pio & mdma modes, clock unit is 30ns (33Mhz) + * + * The access time and recovery time can be programmed. Some older + * Darwin code base limit OHare to 150ns cycle time. I decided to do + * the same here fore safety against broken old hardware ;) + * The HalfTick bit, when set, adds half a clock (15ns) to the access + * time and removes one from recovery. It's not supported on KeyLargo + * implementation afaik. The E bit appears to be set for PIO mode 0 and + * is used to reach long timings used in this mode. + */ +#define TR_33_MDMA_MASK 0x003ff800 +#define TR_33_MDMA_RECOVERY_MASK 0x001f0000 +#define TR_33_MDMA_RECOVERY_SHIFT 16 +#define TR_33_MDMA_ACCESS_MASK 0x0000f800 +#define TR_33_MDMA_ACCESS_SHIFT 11 +#define TR_33_MDMA_HALFTICK 0x00200000 +#define TR_33_PIO_MASK 0x000007ff +#define TR_33_PIO_E 0x00000400 +#define TR_33_PIO_RECOVERY_MASK 0x000003e0 +#define TR_33_PIO_RECOVERY_SHIFT 5 +#define TR_33_PIO_ACCESS_MASK 0x0000001f +#define TR_33_PIO_ACCESS_SHIFT 0 #ifdef CONFIG_BLK_DEV_IDEDMA_PMAC -typedef struct { +/* Rounded Multiword DMA timings + * + * I gave up finding a generic formula for all controller + * types and instead, built tables based on timing values + * used by Apple in Darwin's implementation. + */ +struct mdma_timings_t { int accessTime; + int recoveryTime; int cycleTime; -} pmac_ide_timing; +}; + +struct mdma_timings_t mdma_timings_33[] __pmacdata = +{ + { 240, 240, 480 }, + { 180, 180, 360 }, + { 135, 135, 270 }, + { 120, 120, 240 }, + { 105, 105, 210 }, + { 90, 90, 180 }, + { 75, 75, 150 }, + { 75, 45, 120 }, + { 0, 0, 0 } +}; -/* Multiword DMA timings */ -static pmac_ide_timing mdma_timings[] = +struct mdma_timings_t mdma_timings_33k[] __pmacdata = { - { 215, 480 }, /* Mode 0 */ - { 80, 150 }, /* 1 */ - { 70, 120 } /* 2 */ + { 240, 240, 480 }, + { 180, 180, 360 }, + { 150, 150, 300 }, + { 120, 120, 240 }, + { 90, 120, 210 }, + { 90, 90, 180 }, + { 90, 60, 150 }, + { 90, 30, 120 }, + { 0, 0, 0 } }; -/* Ultra DMA timings (for use when I know how to calculate them */ -static pmac_ide_timing udma_timings[] = +struct mdma_timings_t mdma_timings_66[] __pmacdata = { - { 0, 114 }, /* Mode 0 */ - { 0, 75 }, /* 1 */ - { 0, 55 }, /* 2 */ - { 100, 45 }, /* 3 */ - { 100, 25 } /* 4 */ + { 240, 240, 480 }, + { 180, 180, 360 }, + { 135, 135, 270 }, + { 120, 120, 240 }, + { 105, 105, 210 }, + { 90, 90, 180 }, + { 90, 75, 165 }, + { 75, 45, 120 }, + { 0, 0, 0 } +}; + +/* Ultra DMA timings (rounded) */ +struct { + int addrSetup; /* ??? */ + int rdy2pause; + int wrDataSetup; +} udma_timings[] __pmacdata = +{ + { 0, 180, 120 }, /* Mode 0 */ + { 0, 150, 90 }, /* 1 */ + { 0, 120, 60 }, /* 2 */ + { 0, 90, 45 }, /* 3 */ + { 0, 90, 30 } /* 4 */ }; /* allow up to 256 DBDMA commands per xfer */ @@ -121,7 +238,14 @@ }; #endif /* CONFIG_PMAC_PBOOK */ -static int +static int pmac_ide_notify_reboot(struct notifier_block *, unsigned long, void *); +static struct notifier_block pmac_ide_reboot_notifier = { + pmac_ide_notify_reboot, + NULL, + 0 +}; + +static int __pmac pmac_ide_find(ide_drive_t *drive) { ide_hwif_t *hwif = HWIF(drive); @@ -140,7 +264,8 @@ * N.B. this can't be an initfunc, because the media-bay task can * call ide_[un]register at any time. */ -void pmac_ide_init_hwif_ports(hw_regs_t *hw, +void __pmac +pmac_ide_init_hwif_ports(hw_regs_t *hw, ide_ioreg_t data_port, ide_ioreg_t ctrl_port, int *irq) { @@ -198,24 +323,31 @@ /* Setup timings for the selected drive (master/slave). I still need to verify if this * is enough, I beleive selectproc will be called whenever an IDE command is started, * but... */ -static void +static void __pmac pmac_ide_selectproc(ide_drive_t *drive) { int i = pmac_ide_find(drive); if (i < 0) return; - - if (drive->select.all & 0x10) + + if (drive->select.b.unit & 0x01) out_le32((unsigned *)(IDE_DATA_REG + 0x200 + _IO_BASE), pmac_ide[i].timings[1]); else out_le32((unsigned *)(IDE_DATA_REG + 0x200 + _IO_BASE), pmac_ide[i].timings[0]); + (void)in_le32((unsigned *)(IDE_DATA_REG + 0x200 + _IO_BASE)); } -/* Number of IDE_SYSCLK_NS ticks, argument is in nanoseconds */ -#define SYSCLK_TICKS(t) (((t) + IDE_SYSCLK_NS - 1) / IDE_SYSCLK_NS) -#define SYSCLK_TICKS_UDMA(t) (((t) + IDE_SYSCLK_ULTRA_PS - 1) / IDE_SYSCLK_ULTRA_PS) -static __inline__ int +/* Note: We don't use the generic routine here because for some + * yet unexplained reasons, it cause some media-bay CD-ROMs to + * lockup the bus. Strangely, this new version of the code is + * almost identical to the generic one and works, I've not yet + * managed to figure out what bit is causing the lockup in the + * generic code, possibly a timing issue... + * + * --BenH + */ +static int __pmac wait_for_ready(ide_drive_t *drive) { /* Timeout bumped for some powerbooks */ @@ -241,22 +373,14 @@ return 0; } -/* Note: We don't use the generic routine here because some of Apple's - * controller seem to be very sensitive about how things are done. - * We should probably set the NIEN bit, but that's an example of thing - * that can cause the controller to hang under some circumstances when - * done on the media-bay CD-ROM during boot. We do get occasional - * spurrious interrupts because of that. - * --BenH - */ -static int +static int __pmac pmac_ide_do_setfeature(ide_drive_t *drive, byte command) { - unsigned long flags; int result = 1; - - save_flags(flags); - cli(); + unsigned long flags; + ide_hwif_t *hwif = HWIF(drive); + + disable_irq(hwif->irq); /* disable_irq_nosync ?? */ udelay(1); SELECT_DRIVE(HWIF(drive), drive); SELECT_MASK(HWIF(drive), drive, 0); @@ -265,27 +389,34 @@ printk(KERN_ERR "pmac_ide_do_setfeature disk not ready before SET_FEATURE!\n"); goto out; } - OUT_BYTE(SETFEATURES_XFER, IDE_FEATURE_REG); + udelay(10); + OUT_BYTE(drive->ctl | 2, IDE_CONTROL_REG); OUT_BYTE(command, IDE_NSECTOR_REG); + OUT_BYTE(SETFEATURES_XFER, IDE_FEATURE_REG); OUT_BYTE(WIN_SETFEATURES, IDE_COMMAND_REG); udelay(1); + __save_flags(flags); /* local CPU only */ + ide__sti(); /* local CPU only -- for jiffies */ result = wait_for_ready(drive); + __restore_flags(flags); /* local CPU only */ + OUT_BYTE(drive->ctl, IDE_CONTROL_REG); if (result) printk(KERN_ERR "pmac_ide_do_setfeature disk not ready after SET_FEATURE !\n"); out: - restore_flags(flags); - + SELECT_MASK(HWIF(drive), drive, 0); + enable_irq(hwif->irq); return result; } /* Calculate PIO timings */ -static void +static void __pmac pmac_ide_tuneproc(ide_drive_t *drive, byte pio) { ide_pio_data_t d; int i; u32 *timings; - int accessTicks, recTicks; + unsigned accessTicks, recTicks; + unsigned accessTime, recTime; i = pmac_ide_find(drive); if (i < 0) @@ -293,27 +424,44 @@ pio = ide_get_best_pio_mode(drive, pio, 4, &d); accessTicks = SYSCLK_TICKS(ide_pio_timings[pio].active_time); - if (drive->select.all & 0x10) + if (drive->select.b.unit & 0x01) timings = &pmac_ide[i].timings[1]; else timings = &pmac_ide[i].timings[0]; - - if (pmac_ide[i].kind == controller_kl_ata4) { - /* The "ata-4" IDE controller of Core99 machines */ - accessTicks = SYSCLK_TICKS_UDMA(ide_pio_timings[pio].active_time * 1000); - recTicks = SYSCLK_TICKS_UDMA(d.cycle_time * 1000) - accessTicks; - *timings = ((*timings) & 0x1FFFFFC00) | accessTicks | (recTicks << 5); + recTime = d.cycle_time - ide_pio_timings[pio].active_time + - ide_pio_timings[pio].setup_time; + recTime = max(recTime, 150U); + accessTime = ide_pio_timings[pio].active_time; + accessTime = max(accessTime, 150U); + if (pmac_ide[i].kind == controller_kl_ata4 || + pmac_ide[i].kind == controller_kl_ata4_80) { + /* 66Mhz cell */ + accessTicks = SYSCLK_TICKS_66(accessTime); + accessTicks = min(accessTicks, 0x1fU); + recTicks = SYSCLK_TICKS_66(recTime); + recTicks = min(recTicks, 0x1fU); + *timings = ((*timings) & ~TR_66_PIO_MASK) | + (accessTicks << TR_66_PIO_ACCESS_SHIFT) | + (recTicks << TR_66_PIO_RECOVERY_SHIFT); } else { - /* The old "ata-3" IDE controller */ - accessTicks = SYSCLK_TICKS(ide_pio_timings[pio].active_time); - if (accessTicks < 4) - accessTicks = 4; - recTicks = SYSCLK_TICKS(d.cycle_time) - accessTicks - 4; - if (recTicks < 1) - recTicks = 1; - - *timings = ((*timings) & 0xFFFFFF800) | accessTicks | (recTicks << 5); + /* 33Mhz cell */ + int ebit = 0; + accessTicks = SYSCLK_TICKS(accessTime); + accessTicks = min(accessTicks, 0x1fU); + accessTicks = max(accessTicks, 4U); + recTicks = SYSCLK_TICKS(recTime); + recTicks = min(recTicks, 0x1fU); + recTicks = max(recTicks, 5U) - 4; + if (recTicks > 9) { + recTicks--; /* guess, but it's only for PIO0, so... */ + ebit = 1; + } + *timings = ((*timings) & ~TR_33_PIO_MASK) | + (accessTicks << TR_33_PIO_ACCESS_SHIFT) | + (recTicks << TR_33_PIO_RECOVERY_SHIFT); + if (ebit) + *timings |= TR_33_PIO_E; } #ifdef IDE_PMAC_DEBUG @@ -326,70 +474,134 @@ } #ifdef CONFIG_BLK_DEV_IDEDMA_PMAC -static int -set_timings_udma(int intf, u32 *timings, byte speed) +static int __pmac +set_timings_udma(u32 *timings, byte speed) { - int cycleTime, accessTime; - int rdyToPauseTicks, cycleTicks; - - if (pmac_ide[intf].kind != controller_kl_ata4) - return 1; - - cycleTime = udma_timings[speed & 0xf].cycleTime; - accessTime = udma_timings[speed & 0xf].accessTime; - - rdyToPauseTicks = SYSCLK_TICKS_UDMA(accessTime * 1000); - cycleTicks = SYSCLK_TICKS_UDMA(cycleTime * 1000); + unsigned rdyToPauseTicks, wrDataSetupTicks, addrTicks; - *timings = ((*timings) & 0xe00fffff) | - ((cycleTicks << 1) | (rdyToPauseTicks << 5) | 1) << 20; + rdyToPauseTicks = SYSCLK_TICKS_66(udma_timings[speed & 0xf].rdy2pause); + wrDataSetupTicks = SYSCLK_TICKS_66(udma_timings[speed & 0xf].wrDataSetup); + addrTicks = SYSCLK_TICKS_66(udma_timings[speed & 0xf].addrSetup); + + *timings = ((*timings) & ~(TR_66_UDMA_MASK | TR_66_MDMA_MASK)) | + (wrDataSetupTicks << TR_66_UDMA_WRDATASETUP_SHIFT) | + (rdyToPauseTicks << TR_66_UDMA_RDY2PAUS_SHIFT) | + (addrTicks <<TR_66_UDMA_ADDRSETUP_SHIFT) | + TR_66_UDMA_EN; +#ifdef IDE_PMAC_DEBUG + printk(KERN_ERR "ide_pmac: Set UDMA timing for mode %d, reg: 0x%08x\n", + speed & 0xf, *timings); +#endif return 0; } -static int -set_timings_mdma(int intf, u32 *timings, byte speed) +static int __pmac +set_timings_mdma(int intf_type, u32 *timings, byte speed, int drive_cycle_time) { - int cycleTime, accessTime; - int accessTicks, recTicks; + int cycleTime, accessTime, recTime; + unsigned accessTicks, recTicks; + struct mdma_timings_t* tm; + int i; - /* Calculate accesstime and cycle time */ - cycleTime = mdma_timings[speed & 0xf].cycleTime; - accessTime = mdma_timings[speed & 0xf].accessTime; - if ((pmac_ide[intf].kind == controller_ohare) && (cycleTime < 150)) + /* Get default cycle time for mode */ + switch(speed & 0xf) { + case 0: cycleTime = 480; break; + case 1: cycleTime = 150; break; + case 2: cycleTime = 120; break; + default: + return -1; + } + /* Adjust for drive */ + if (drive_cycle_time && drive_cycle_time > cycleTime) + cycleTime = drive_cycle_time; + /* OHare limits according to some old Apple sources */ + if ((intf_type == controller_ohare) && (cycleTime < 150)) cycleTime = 150; + /* Get the proper timing array for this controller */ + switch(intf_type) { + case controller_kl_ata4: + case controller_kl_ata4_80: + tm = mdma_timings_66; + break; + case controller_kl_ata3: + tm = mdma_timings_33k; + break; + default: + tm = mdma_timings_33; + break; + } + /* Lookup matching access & recovery times */ + i = -1; + for (;;) { + if (tm[i+1].cycleTime < cycleTime) + break; + i++; + } + if (i < 0) + return -1; + cycleTime = tm[i].cycleTime; + accessTime = tm[i].accessTime; + recTime = tm[i].recoveryTime; - /* For ata-4 controller */ - if (pmac_ide[intf].kind == controller_kl_ata4) { - accessTicks = SYSCLK_TICKS_UDMA(accessTime * 1000); - recTicks = SYSCLK_TICKS_UDMA(cycleTime * 1000) - accessTicks; - *timings = ((*timings) & 0xffe003ff) | - (accessTicks | (recTicks << 5)) << 10; +#ifdef IDE_PMAC_DEBUG + printk(KERN_ERR "ide_pmac: MDMA, cycleTime: %d, accessTime: %d, recTime: %d\n", + cycleTime, accessTime, recTime); +#endif + if (intf_type == controller_kl_ata4 || intf_type == controller_kl_ata4_80) { + /* 66Mhz cell */ + accessTicks = SYSCLK_TICKS_66(accessTime); + accessTicks = min(accessTicks, 0x1fU); + accessTicks = max(accessTicks, 0x1U); + recTicks = SYSCLK_TICKS_66(recTime); + recTicks = min(recTicks, 0x1fU); + recTicks = max(recTicks, 0x3U); + /* Clear out mdma bits and disable udma */ + *timings = ((*timings) & ~(TR_66_MDMA_MASK | TR_66_UDMA_MASK)) | + (accessTicks << TR_66_MDMA_ACCESS_SHIFT) | + (recTicks << TR_66_MDMA_RECOVERY_SHIFT); + } else if (intf_type == controller_kl_ata3) { + /* 33Mhz cell on KeyLargo */ + accessTicks = SYSCLK_TICKS(accessTime); + accessTicks = max(accessTicks, 1U); + accessTicks = min(accessTicks, 0x1fU); + accessTime = accessTicks * IDE_SYSCLK_NS; + recTicks = SYSCLK_TICKS(recTime); + recTicks = max(recTicks, 1U); + recTicks = min(recTicks, 0x1fU); + *timings = ((*timings) & ~TR_33_MDMA_MASK) | + (accessTicks << TR_33_MDMA_ACCESS_SHIFT) | + (recTicks << TR_33_MDMA_RECOVERY_SHIFT); } else { + /* 33Mhz cell on others */ int halfTick = 0; int origAccessTime = accessTime; - int origCycleTime = cycleTime; + int origRecTime = recTime; accessTicks = SYSCLK_TICKS(accessTime); - if (accessTicks < 1) - accessTicks = 1; + accessTicks = max(accessTicks, 1U); + accessTicks = min(accessTicks, 0x1fU); accessTime = accessTicks * IDE_SYSCLK_NS; - recTicks = SYSCLK_TICKS(cycleTime - accessTime) - 1; - if (recTicks < 1) - recTicks = 1; - cycleTime = (recTicks + 1 + accessTicks) * IDE_SYSCLK_NS; - - /* KeyLargo ata-3 don't support the half-tick stuff */ - if ((pmac_ide[intf].kind != controller_kl_ata3) && - (accessTicks > 1) && - ((accessTime - IDE_SYSCLK_NS/2) >= origAccessTime) && - ((cycleTime - IDE_SYSCLK_NS) >= origCycleTime)) { - halfTick = 1; - accessTicks--; - } - *timings = ((*timings) & 0x7FF) | - (accessTicks | (recTicks << 5) | (halfTick << 10)) << 11; + recTicks = SYSCLK_TICKS(recTime); + recTicks = max(recTicks, 2U) - 1; + recTicks = min(recTicks, 0x1fU); + recTime = (recTicks + 1) * IDE_SYSCLK_NS; + if ((accessTicks > 1) && + ((accessTime - IDE_SYSCLK_NS/2) >= origAccessTime) && + ((recTime - IDE_SYSCLK_NS/2) >= origRecTime)) { + halfTick = 1; + accessTicks--; + } + *timings = ((*timings) & ~TR_33_MDMA_MASK) | + (accessTicks << TR_33_MDMA_ACCESS_SHIFT) | + (recTicks << TR_33_MDMA_RECOVERY_SHIFT); + if (halfTick) + *timings |= TR_33_MDMA_HALFTICK; } +#ifdef IDE_PMAC_DEBUG + printk(KERN_ERR "ide_pmac: Set MDMA timing for mode %d, reg: 0x%08x\n", + speed & 0xf, *timings); +#endif return 0; } #endif /* #ifdef CONFIG_BLK_DEV_IDEDMA_PMAC */ @@ -397,11 +609,11 @@ /* You may notice we don't use this function on normal operation, * our, normal mdma function is supposed to be more precise */ -static int +static int __pmac pmac_ide_tune_chipset (ide_drive_t *drive, byte speed) { int intf = pmac_ide_find(drive); - int unit = (drive->select.all & 0x10) ? 1:0; + int unit = (drive->select.b.unit & 0x01); int ret = 0; u32 *timings; @@ -414,19 +626,25 @@ #ifdef CONFIG_BLK_DEV_IDEDMA_PMAC case XFER_UDMA_4: case XFER_UDMA_3: + if (pmac_ide[intf].kind != controller_kl_ata4_80) + return 1; case XFER_UDMA_2: case XFER_UDMA_1: case XFER_UDMA_0: - ret = set_timings_udma(intf, timings, speed); + if (pmac_ide[intf].kind != controller_kl_ata4 && + pmac_ide[intf].kind != controller_kl_ata4_80) + return 1; + ret = set_timings_udma(timings, speed); break; case XFER_MW_DMA_2: case XFER_MW_DMA_1: case XFER_MW_DMA_0: + ret = set_timings_mdma(pmac_ide[intf].kind, timings, speed, 0); + break; case XFER_SW_DMA_2: case XFER_SW_DMA_1: case XFER_SW_DMA_0: - ret = set_timings_mdma(intf, timings, speed); - break; + return 1; #endif /* CONFIG_BLK_DEV_IDEDMA_PMAC */ case XFER_PIO_4: case XFER_PIO_3: @@ -451,13 +669,46 @@ return 0; } -ide_ioreg_t +static void __pmac +sanitize_timings(int i) +{ + unsigned value; + + switch(pmac_ide[i].kind) { + case controller_kl_ata4: + case controller_kl_ata4_80: + value = 0x0008438c; + break; + case controller_kl_ata3: + value = 0x00084526; + break; + case controller_heathrow: + case controller_ohare: + default: + value = 0x00074526; + break; + } + pmac_ide[i].timings[0] = pmac_ide[i].timings[1] = value; +} + +ide_ioreg_t __pmac pmac_ide_get_base(int index) { return pmac_ide[index].regbase; } -int +int __pmac +pmac_ide_check_base(ide_ioreg_t base) +{ + int ix; + + for (ix = 0; ix < MAX_HWIFS; ++ix) + if (base == pmac_ide[ix].regbase) + return ix; + return -1; +} + +int __pmac pmac_ide_get_irq(ide_ioreg_t base) { int ix; @@ -468,7 +719,7 @@ return 0; } -static int ide_majors[] = { 3, 22, 33, 34, 56, 57 }; +static int ide_majors[] __pmacdata = { 3, 22, 33, 34, 56, 57 }; kdev_t __init pmac_find_ide_boot(char *bootdevice, int n) @@ -532,6 +783,7 @@ for (i = 0, np = atas; i < MAX_HWIFS && np != NULL; np = np->next) { struct device_node *tp; + struct pmac_ide_hwif* pmhw; int *bidp; int in_bay = 0; @@ -560,6 +812,22 @@ ++i; if (i >= MAX_HWIFS) break; + pmhw = &pmac_ide[i]; + + /* + * Some older OFs have bogus sizes, causing request_OF_resource + * to fail. We fix them up here + */ + if (np->addrs[0].size > 0x1000) + np->addrs[0].size = 0x1000; + if (np->n_addrs > 1 && np->addrs[1].size > 0x100) + np->addrs[1].size = 0x100; + + pmhw->reg_resource = request_OF_resource(np, 0, " (mac-io IDE IO)"); + if (!pmhw->reg_resource) { + printk(KERN_ERR "ide-pmac(%s): can't request IO resource !\n", np->name); + continue; + } base = (unsigned long) ioremap(np->addrs[0].address, 0x200) - _IO_BASE; @@ -574,21 +842,30 @@ } else { irq = np->intrs[0].line; } - pmac_ide[i].regbase = base; - pmac_ide[i].irq = irq; - pmac_ide[i].node = np; + pmhw->regbase = base; + pmhw->irq = irq; + pmhw->node = np; if (device_is_compatible(np, "keylargo-ata")) { if (strcmp(np->name, "ata-4") == 0) - pmac_ide[i].kind = controller_kl_ata4; + pmhw->kind = controller_kl_ata4; else - pmac_ide[i].kind = controller_kl_ata3; + pmhw->kind = controller_kl_ata3; } else if (device_is_compatible(np, "heathrow-ata")) - pmac_ide[i].kind = controller_heathrow; + pmhw->kind = controller_heathrow; else - pmac_ide[i].kind = controller_ohare; + pmhw->kind = controller_ohare; bidp = (int *)get_property(np, "AAPL,bus-id", NULL); - pmac_ide[i].aapl_bus_id = bidp ? *bidp : 0; + pmhw->aapl_bus_id = bidp ? *bidp : 0; + + if (pmhw->kind == controller_kl_ata4) { + char* cable = get_property(np, "cable-type", NULL); + if (cable && !strncmp(cable, "80-", 3)) + pmhw->kind = controller_kl_ata4_80; + } + + /* Make sure we have sane timings */ + sanitize_timings(i); if (np->parent && np->parent->name && strcasecmp(np->parent->name, "media-bay") == 0) { @@ -596,39 +873,22 @@ media_bay_set_ide_infos(np->parent,base,irq,i); #endif /* CONFIG_PMAC_PBOOK */ in_bay = 1; - } else if (pmac_ide[i].kind == controller_ohare) { + if (!bidp) + pmhw->aapl_bus_id = 1; + } else if (pmhw->kind == controller_ohare) { /* The code below is having trouble on some ohare machines * (timing related ?). Until I can put my hand on one of these * units, I keep the old way */ - feature_set(np, FEATURE_IDE0_enable); + ppc_md.feature_call(PMAC_FTR_IDE_ENABLE, np, 0, 1); } else { /* This is necessary to enable IDE when net-booting */ printk(KERN_INFO "pmac_ide: enabling IDE bus ID %d\n", - pmac_ide[i].aapl_bus_id); - switch(pmac_ide[i].aapl_bus_id) { - case 0: - feature_set(np, FEATURE_IDE0_reset); - mdelay(10); - feature_set(np, FEATURE_IDE0_enable); - mdelay(10); - feature_clear(np, FEATURE_IDE0_reset); - break; - case 1: - feature_set(np, FEATURE_IDE1_reset); - mdelay(10); - feature_set(np, FEATURE_IDE1_enable); - mdelay(10); - feature_clear(np, FEATURE_IDE1_reset); - break; - case 2: - /* This one exists only for KL, I don't know - about any enable bit */ - feature_set(np, FEATURE_IDE2_reset); - mdelay(10); - feature_clear(np, FEATURE_IDE2_reset); - break; - } + pmhw->aapl_bus_id); + ppc_md.feature_call(PMAC_FTR_IDE_RESET, np, pmhw->aapl_bus_id, 1); + ppc_md.feature_call(PMAC_FTR_IDE_ENABLE, np, pmhw->aapl_bus_id, 1); + mdelay(10); + ppc_md.feature_call(PMAC_FTR_IDE_RESET, np, pmhw->aapl_bus_id, 0); big_delay = 1; } @@ -658,6 +918,7 @@ #ifdef CONFIG_PMAC_PBOOK pmu_register_sleep_notifier(&idepmac_sleep_notifier); #endif /* CONFIG_PMAC_PBOOK */ + register_reboot_notifier(&pmac_ide_reboot_notifier); } #ifdef CONFIG_BLK_DEV_IDEDMA_PMAC @@ -665,6 +926,12 @@ static void __init pmac_ide_setup_dma(struct device_node *np, int ix) { + pmac_ide[ix].dma_resource = request_OF_resource(np, 1, " (mac-io IDE DMA)"); + if (!pmac_ide[ix].dma_resource) { + printk(KERN_ERR "ide-pmac(%s): can't request DMA resource !\n", np->name); + return; + } + pmac_ide[ix].dma_regs = (volatile struct dbdma_regs*)ioremap(np->addrs[1].address, 0x200); @@ -692,7 +959,7 @@ * pmac_ide_build_dmatable builds the DBDMA command list * for a transfer and sets the DBDMA channel to point to it. */ -static int +static int __pmac pmac_ide_build_dmatable(ide_drive_t *drive, int ix, int wr) { struct dbdma_cmd *table, *tstart; @@ -703,6 +970,13 @@ volatile struct dbdma_regs *dma = pmac_ide[ix].dma_regs; table = tstart = (struct dbdma_cmd *) DBDMA_ALIGN(pmac_ide[ix].dma_table); + +#ifdef IDE_PMAC_DEBUG + if (in_le32(&dma->status) & (RUN|ACTIVE)) + printk("ide-pmac: channel status not stopped ! (%x)\n", + in_le32(&dma->status)); +#endif + /* Make sure channel is stopped and all error conditions are clear */ out_le32(&dma->control, (RUN|PAUSE|FLUSH|WAKE|DEAD) << 16); while (in_le32(&dma->status) & RUN) udelay(1); @@ -734,6 +1008,10 @@ * Note that one DBDMA command can transfer * at most 65535 bytes. */ +#ifdef IDE_PMAC_DEBUG + if (size & 0x01) + printk("ide-pmac: odd size transfer ! (%d)\n", size); +#endif while (size) { unsigned int tc = (size < 0xfe00)? size: 0xfe00; @@ -782,12 +1060,14 @@ } static __inline__ unsigned char -udma_bits_to_command(unsigned char bits) +udma_bits_to_command(unsigned char bits, int high_speed) { - if(bits & 0x10) - return XFER_UDMA_4; - if(bits & 0x08) - return XFER_UDMA_3; + if (high_speed) { + if(bits & 0x10) + return XFER_UDMA_4; + if(bits & 0x08) + return XFER_UDMA_3; + } if(bits & 0x04) return XFER_UDMA_2; if(bits & 0x02) @@ -798,14 +1078,13 @@ } /* Calculate MultiWord DMA timings */ -static int +static int __pmac pmac_ide_mdma_enable(ide_drive_t *drive, int idx) { byte bits = drive->id->dma_mword & 0x07; byte feature = dma_bits_to_command(bits); u32 *timings; - int cycleTime, accessTime; - int accessTicks, recTicks; + int drive_cycle_time; struct hd_driveid *id = drive->id; int ret; @@ -821,66 +1100,30 @@ drive->init_speed = feature; /* which drive is it ? */ - if (drive->select.all & 0x10) + if (drive->select.b.unit & 0x01) timings = &pmac_ide[idx].timings[1]; else timings = &pmac_ide[idx].timings[0]; - /* Calculate accesstime and cycle time */ - cycleTime = mdma_timings[feature & 0xf].cycleTime; - accessTime = mdma_timings[feature & 0xf].accessTime; + /* Check if drive provide explicit cycle time */ if ((id->field_valid & 2) && (id->eide_dma_time)) - cycleTime = id->eide_dma_time; - if ((pmac_ide[idx].kind == controller_ohare) && (cycleTime < 150)) - cycleTime = 150; + drive_cycle_time = id->eide_dma_time; + else + drive_cycle_time = 0; + + /* Calculate controller timings */ + set_timings_mdma(pmac_ide[idx].kind, timings, feature, drive_cycle_time); - /* For ata-4 controller */ - if (pmac_ide[idx].kind == controller_kl_ata4) { - accessTicks = SYSCLK_TICKS_UDMA(accessTime * 1000); - recTicks = SYSCLK_TICKS_UDMA(cycleTime * 1000) - accessTicks; - *timings = ((*timings) & 0xffe003ff) | - (accessTicks | (recTicks << 5)) << 10; - } else { - int halfTick = 0; - int origAccessTime = accessTime; - int origCycleTime = cycleTime; - - accessTicks = SYSCLK_TICKS(accessTime); - if (accessTicks < 1) - accessTicks = 1; - accessTime = accessTicks * IDE_SYSCLK_NS; - recTicks = SYSCLK_TICKS(cycleTime - accessTime) - 1; - if (recTicks < 1) - recTicks = 1; - cycleTime = (recTicks + 1 + accessTicks) * IDE_SYSCLK_NS; - - /* KeyLargo ata-3 don't support the half-tick stuff */ - if ((pmac_ide[idx].kind != controller_kl_ata3) && - (accessTicks > 1) && - ((accessTime - IDE_SYSCLK_NS/2) >= origAccessTime) && - ((cycleTime - IDE_SYSCLK_NS) >= origCycleTime)) { - halfTick = 1; - accessTicks--; - } - *timings = ((*timings) & 0x7FF) | - (accessTicks | (recTicks << 5) | (halfTick << 10)) << 11; - } -#ifdef IDE_PMAC_DEBUG - printk(KERN_INFO "ide_pmac: Set MDMA timing for mode %d, reg: 0x%08x\n", - feature & 0xf, *timings); -#endif drive->current_speed = feature; return 1; } /* Calculate Ultra DMA timings */ -static int -pmac_ide_udma_enable(ide_drive_t *drive, int idx) +static int __pmac +pmac_ide_udma_enable(ide_drive_t *drive, int idx, int high_speed) { byte bits = drive->id->dma_ultra & 0x1f; - byte feature = udma_bits_to_command(bits); - int cycleTime, accessTime; - int rdyToPauseTicks, cycleTicks; + byte feature = udma_bits_to_command(bits, high_speed); u32 *timings; int ret; @@ -896,25 +1139,18 @@ drive->init_speed = feature; /* which drive is it ? */ - if (drive->select.all & 0x10) + if (drive->select.b.unit & 0x01) timings = &pmac_ide[idx].timings[1]; else timings = &pmac_ide[idx].timings[0]; - cycleTime = udma_timings[feature & 0xf].cycleTime; - accessTime = udma_timings[feature & 0xf].accessTime; - - rdyToPauseTicks = SYSCLK_TICKS_UDMA(accessTime * 1000); - cycleTicks = SYSCLK_TICKS_UDMA(cycleTime * 1000); - - *timings = ((*timings) & 0xe00fffff) | - ((cycleTicks << 1) | (rdyToPauseTicks << 5) | 1) << 20; + set_timings_udma(timings, feature); drive->current_speed = feature; return 1; } -static int +static int __pmac pmac_ide_check_dma(ide_drive_t *drive) { int ata4, udma, idx; @@ -935,21 +1171,20 @@ enable = 0; udma = 0; - ata4 = (pmac_ide[idx].kind == controller_kl_ata4); + ata4 = (pmac_ide[idx].kind == controller_kl_ata4 || + pmac_ide[idx].kind == controller_kl_ata4_80); if(enable) { if (ata4 && (drive->media == ide_disk) && - (id->field_valid & 0x0004) && (id->dma_ultra & 0x17)) { + (id->field_valid & 0x0004) && (id->dma_ultra & 0x1f)) { /* UltraDMA modes. */ - drive->using_dma = pmac_ide_udma_enable(drive, idx); + drive->using_dma = pmac_ide_udma_enable(drive, idx, + pmac_ide[idx].kind == controller_kl_ata4_80); } if (!drive->using_dma && (id->dma_mword & 0x0007)) { /* Normal MultiWord DMA modes. */ drive->using_dma = pmac_ide_mdma_enable(drive, idx); } - /* Without this, strange things will happen on Keylargo-based - * machines - */ OUT_BYTE(0, IDE_CONTROL_REG); /* Apply settings to controller */ pmac_ide_selectproc(drive); @@ -957,10 +1192,13 @@ return 0; } -int pmac_ide_dmaproc(ide_dma_action_t func, ide_drive_t *drive) +static int __pmac +pmac_ide_dmaproc(ide_dma_action_t func, ide_drive_t *drive) { - int ix, dstat, i; + int ix, dstat; volatile struct dbdma_regs *dma; + byte unit = (drive->select.b.unit & 0x01); + byte ata4; /* Can we stuff a pointer to our intf structure in config_data * or select_data in hwif ? @@ -969,7 +1207,9 @@ if (ix < 0) return 0; dma = pmac_ide[ix].dma_regs; - + ata4 = (pmac_ide[ix].kind == controller_kl_ata4 || + pmac_ide[ix].kind == controller_kl_ata4_80); + switch (func) { case ide_dma_off: printk(KERN_INFO "%s: DMA disabled\n", drive->name); @@ -984,6 +1224,13 @@ case ide_dma_write: if (!pmac_ide_build_dmatable(drive, ix, func==ide_dma_write)) return 1; + /* Apple adds 60ns to wrDataSetup on reads */ + if (ata4 && (pmac_ide[ix].timings[unit] & TR_66_UDMA_EN)) { + out_le32((unsigned *)(IDE_DATA_REG + 0x200 + _IO_BASE), + pmac_ide[ix].timings[unit] + + ((func == ide_dma_read) ? 0x00800000UL : 0)); + (void)in_le32((unsigned *)(IDE_DATA_REG + 0x200 + _IO_BASE)); + } drive->waiting_for_dma = 1; if (drive->media != ide_disk) return 0; @@ -992,35 +1239,56 @@ IDE_COMMAND_REG); case ide_dma_begin: out_le32(&dma->control, (RUN << 16) | RUN); + /* Make sure it gets to the controller right now */ + (void)in_le32(&dma->control); break; - case ide_dma_end: + case ide_dma_end: /* returns 1 on error, 0 otherwise */ drive->waiting_for_dma = 0; dstat = in_le32(&dma->status); out_le32(&dma->control, ((RUN|WAKE|DEAD) << 16)); /* verify good dma status */ return (dstat & (RUN|DEAD|ACTIVE)) != RUN; - case ide_dma_test_irq: - if ((in_le32(&dma->status) & (RUN|ACTIVE)) == RUN) - return 1; - /* That's a bit ugly and dangerous, but works in our case - * to workaround a problem with the channel status staying - * active if the drive returns an error + case ide_dma_test_irq: /* returns 1 if dma irq issued, 0 otherwise */ + /* We have to things to deal with here: + * + * - The dbdma won't stop if the command was started + * but completed with an error without transfering all + * datas. This happens when bad blocks are met during + * a multi-block transfer. + * + * - The dbdma fifo hasn't yet finished flushing to + * to system memory when the disk interrupt occurs. + * + * The trick here is to increment drive->waiting_for_dma, + * and return as if no interrupt occured. If the counter + * reach a certain timeout value, we then return 1. If + * we really got the interrupt, it will happen right away + * again. + * Apple's solution here may be more elegant. They issue + * a DMA channel interrupt (a separate irq line) via a DBDMA + * NOP command just before the STOP, and wait for both the + * disk and DBDMA interrupts to have completed. */ - if (IDE_CONTROL_REG) { - byte stat; - stat = GET_ALTSTAT(); - if (stat & ERR_STAT) - return 1; - } - /* In some edge cases, some datas may still be in the dbdma - * engine fifo, we wait a bit for dbdma to complete + + /* If ACTIVE is cleared, the STOP command have passed and + * transfer is complete. */ - while ((in_le32(&dma->status) & (RUN|ACTIVE)) != RUN) { - if (++i > 100) - return 0; - udelay(1); + if (!(in_le32(&dma->status) & ACTIVE)) + return 1; + if (!drive->waiting_for_dma) + printk(KERN_WARNING "ide%d, ide_dma_test_irq \ + called while not waiting\n", ix); + + /* If dbdma didn't execute the STOP command yet, the + * active bit is still set */ + drive->waiting_for_dma++; + if (drive->waiting_for_dma >= DMA_WAIT_TIMEOUT) { + printk(KERN_WARNING "ide%d, timeout waiting \ + for dbdma command stop\n", ix); + return 1; } - return 1; + udelay(1); + return 0; /* Let's implement tose just in case someone wants them */ case ide_dma_bad_drive: @@ -1041,8 +1309,8 @@ } #endif /* CONFIG_BLK_DEV_IDEDMA_PMAC */ -#ifdef CONFIG_PMAC_PBOOK -static void idepmac_sleep_device(ide_drive_t *drive, int i, unsigned base) +static void __pmac +idepmac_sleep_device(ide_drive_t *drive, int i, unsigned base) { int j; @@ -1052,7 +1320,9 @@ switch (drive->media) { case ide_disk: /* Spin down the drive */ - outb(0xa0, base+0x60); + outb(drive->select.all, base+0x60); + (void)inb(base+0x60); + udelay(100); outb(0x0, base+0x30); outb(0x0, base+0x20); outb(0x0, base+0x40); @@ -1076,8 +1346,10 @@ } } -static void idepmac_wake_device(ide_drive_t *drive, int used_dma) - { +#ifdef CONFIG_PMAC_PBOOK +static void __pmac +idepmac_wake_device(ide_drive_t *drive, int used_dma) +{ /* We force the IDE subdriver to check for a media change * This must be done first or we may lost the condition * @@ -1101,12 +1373,15 @@ HWGROUP(drive)->busy = 1; pmac_ide_check_dma(drive); HWGROUP(drive)->busy = 0; + if (!list_empty(&drive->queue.queue_head)) + ide_do_request(HWGROUP(drive), 0); spin_unlock_irq(&io_request_lock); } #endif /* CONFIG_BLK_DEV_IDEDMA_PMAC */ } -static void idepmac_sleep_interface(int i, unsigned base, int mediabay) +static void __pmac +idepmac_sleep_interface(int i, unsigned base, int mediabay) { struct device_node* np = pmac_ide[i].node; @@ -1118,73 +1393,85 @@ if (mediabay) return; - /* Disable and reset the bus */ - feature_set(np, FEATURE_IDE0_reset); - feature_clear(np, FEATURE_IDE0_enable); - switch(pmac_ide[i].aapl_bus_id) { - case 0: - feature_set(np, FEATURE_IDE0_reset); - feature_clear(np, FEATURE_IDE0_enable); - break; - case 1: - feature_set(np, FEATURE_IDE1_reset); - feature_clear(np, FEATURE_IDE1_enable); - break; - case 2: - feature_set(np, FEATURE_IDE2_reset); - break; - } + /* Disable the bus */ + ppc_md.feature_call(PMAC_FTR_IDE_ENABLE, np, pmac_ide[i].aapl_bus_id, 0); } -static void idepmac_wake_interface(int i, unsigned long base, int mediabay) +static void __pmac +idepmac_wake_interface(int i, unsigned long base, int mediabay) { struct device_node* np = pmac_ide[i].node; if (!mediabay) { /* Revive IDE disk and controller */ - switch(pmac_ide[i].aapl_bus_id) { - case 0: - feature_set(np, FEATURE_IDE0_reset); - feature_set(np, FEATURE_IOBUS_enable); - mdelay(10); - feature_set(np, FEATURE_IDE0_enable); - mdelay(10); - feature_clear(np, FEATURE_IDE0_reset); - break; - case 1: - feature_set(np, FEATURE_IDE1_reset); - feature_set(np, FEATURE_IOBUS_enable); - mdelay(10); - feature_set(np, FEATURE_IDE1_enable); - mdelay(10); - feature_clear(np, FEATURE_IDE1_reset); - break; - case 2: - /* This one exists only for KL, I don't know - about any enable bit */ - feature_set(np, FEATURE_IDE2_reset); - mdelay(10); - feature_clear(np, FEATURE_IDE2_reset); - break; - } + ppc_md.feature_call(PMAC_FTR_IDE_RESET, np, pmac_ide[i].aapl_bus_id, 1); + ppc_md.feature_call(PMAC_FTR_IDE_ENABLE, np, pmac_ide[i].aapl_bus_id, 1); + mdelay(10); + ppc_md.feature_call(PMAC_FTR_IDE_RESET, np, pmac_ide[i].aapl_bus_id, 0); + } +} + +static void +idepmac_sleep_drive(ide_drive_t *drive, int idx, unsigned long base) +{ + int unlock = 0; + + /* Wait for HW group to complete operations */ + if (ide_spin_wait_hwgroup(drive)) { + // What can we do here ? Wake drive we had already + // put to sleep and return an error ? + } else { + unlock = 1; + /* Lock HW group */ + HWGROUP(drive)->busy = 1; + /* Stop the device */ + idepmac_sleep_device(drive, idx, base); } + if (unlock) + spin_unlock_irq(&io_request_lock); +} + +static void +idepmac_wake_drive(ide_drive_t *drive, unsigned long base) +{ + unsigned long flags; + int j; /* Reset timings */ - pmac_ide_selectproc(&ide_hwifs[i].drives[0]); + pmac_ide_selectproc(drive); mdelay(10); + + /* Wait up to 20 seconds for the drive to be ready */ + for (j = 0; j < 200; j++) { + int status; + mdelay(100); + outb(drive->select.all, base + 0x60); + if (inb(base + 0x60) != drive->select.all) + continue; + status = inb(base + 0x70); + if (!(status & BUSY_STAT)) + break; + } + + /* We resume processing on the HW group */ + spin_lock_irqsave(&io_request_lock, flags); + HWGROUP(drive)->busy = 0; + if (!list_empty(&drive->queue.queue_head)) + ide_do_request(HWGROUP(drive), 0); + spin_unlock_irqrestore(&io_request_lock, flags); } /* Note: We support only master drives for now. This will have to be * improved if we want to handle sleep on the iMacDV where the CD-ROM * is a slave */ -static int idepmac_notify_sleep(struct pmu_sleep_notifier *self, int when) +static int __pmac +idepmac_notify_sleep(struct pmu_sleep_notifier *self, int when) { int i, ret; unsigned long base; - unsigned long flags; int big_delay; - + switch (when) { case PBOOK_SLEEP_REQUEST: break; @@ -1193,34 +1480,19 @@ case PBOOK_SLEEP_NOW: for (i = 0; i < pmac_ide_count; ++i) { ide_hwif_t *hwif; - ide_drive_t *drive; - int unlock = 0; + int dn; if ((base = pmac_ide[i].regbase) == 0) - continue; + continue; hwif = &ide_hwifs[i]; - drive = &hwif->drives[0]; - - if (drive->present) { - /* Wait for HW group to complete operations */ - if (ide_spin_wait_hwgroup(drive)) { - // What can we do here ? Wake drive we had already - // put to sleep and return an error ? - } else { - unlock = 1; - /* Lock HW group */ - HWGROUP(drive)->busy = 1; - - /* Stop the device */ - idepmac_sleep_device(drive, i, base); - - } + for (dn=0; dn<MAX_DRIVES; dn++) { + if (!hwif->drives[dn].present) + continue; + idepmac_sleep_drive(&hwif->drives[dn], i, base); } /* Disable irq during sleep */ disable_irq(pmac_ide[i].irq); - if (unlock) - spin_unlock_irq(&io_request_lock); /* Check if this is a media bay with an IDE device or not * a media bay. @@ -1237,6 +1509,9 @@ if ((base = pmac_ide[i].regbase) == 0) continue; + /* Make sure we have sane timings */ + sanitize_timings(i); + /* Check if this is a media bay with an IDE device or not * a media bay */ @@ -1253,46 +1528,79 @@ for (i = 0; i < pmac_ide_count; ++i) { ide_hwif_t *hwif; - ide_drive_t *drive; - int j, used_dma; + int used_dma, dn; + int irq_on = 0; if ((base = pmac_ide[i].regbase) == 0) continue; hwif = &ide_hwifs[i]; - drive = &hwif->drives[0]; - - /* Wait for the drive to come up and set it's DMA */ - if (drive->present) { - /* Wait up to 20 seconds */ - for (j = 0; j < 200; j++) { - int status; - mdelay(100); - status = inb(base + 0x70); - if (!(status & BUSY_STAT)) - break; + for (dn=0; dn<MAX_DRIVES; dn++) { + ide_drive_t *drive = &hwif->drives[dn]; + if (!drive->present) + continue; + /* We don't have re-configured DMA yet */ + used_dma = drive->using_dma; + drive->using_dma = 0; + idepmac_wake_drive(drive, base); + if (!irq_on) { + enable_irq(pmac_ide[i].irq); + irq_on = 1; } - } - - /* We don't have re-configured DMA yet */ - used_dma = drive->using_dma; - drive->using_dma = 0; - - /* We resume processing on the HW group */ - spin_lock_irqsave(&io_request_lock, flags); - enable_irq(pmac_ide[i].irq); - if (drive->present) - HWGROUP(drive)->busy = 0; - spin_unlock_irqrestore(&io_request_lock, flags); - - /* Wake the device - * We could handle the slave here - */ - if (drive->present) idepmac_wake_device(drive, used_dma); + } + if (!irq_on) + enable_irq(pmac_ide[i].irq); } break; } return PBOOK_SLEEP_OK; } #endif /* CONFIG_PMAC_PBOOK */ + +static int __pmac +pmac_ide_notify_reboot(struct notifier_block *this, unsigned long code, void *x) +{ + int i, gotone; + unsigned long base; + + if (code != SYS_HALT && code != SYS_POWER_OFF) + return 0; + + gotone = 0; + for (i = 0; i < pmac_ide_count; ++i) { + ide_hwif_t *hwif; + ide_drive_t *drive; + int unlock = 0; + int dn; + + if ((base = pmac_ide[i].regbase) == 0) + continue; + + hwif = &ide_hwifs[i]; + for (dn=0; dn<MAX_DRIVES; dn++) { + drive = &hwif->drives[dn]; + if (drive->present) { + gotone = 1; + /* Wait for HW group to complete operations */ + if (ide_spin_wait_hwgroup(drive)) { + // What can we do here ? Wake drive we had already + // put to sleep and return an error ? + } else { + unlock = 1; + /* Lock HW group */ + HWGROUP(drive)->busy = 1; + + /* Stop the device */ + idepmac_sleep_device(drive, i, base); + } + } + if (unlock) + spin_unlock_irq(&io_request_lock); + } + } + if (gotone) + mdelay(1000); + + return NOTIFY_DONE; +} diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/ide/ide-timing.h linux-2.5/drivers/ide/ide-timing.h --- linux-2.5.1/drivers/ide/ide-timing.h Sat Feb 3 19:27:43 2001 +++ linux-2.5/drivers/ide/ide-timing.h Mon Dec 31 21:56:17 2001 @@ -2,11 +2,9 @@ #define _IDE_TIMING_H /* - * $Id: ide-timing.h,v 1.5 2001/01/15 21:48:56 vojtech Exp $ + * $Id: ide-timing.h,v 1.6 2001/12/23 22:47:56 vojtech Exp $ * - * Copyright (c) 1999-2000 Vojtech Pavlik - * - * Sponsored by SuSE + * Copyright (c) 1999-2001 Vojtech Pavlik */ /* @@ -25,16 +23,14 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * Should you need to contact me, the author, you can do so either by - * e-mail - mail your message to <vojtech@suse.cz>, or by paper mail: - * Vojtech Pavlik, Ucitelska 1576, Prague 8, 182 00 Czech Republic + * e-mail - mail your message to <vojtech@ucw.cz>, or by paper mail: + * Vojtech Pavlik, Simunkova 1594, Prague 8, 182 00 Czech Republic */ #include <linux/hdreg.h> -#ifndef XFER_PIO_5 #define XFER_PIO_5 0x0d #define XFER_UDMA_SLOW 0x4f -#endif struct ide_timing { short mode; @@ -49,13 +45,15 @@ }; /* - * PIO 0-5, MWDMA 0-2 and UDMA 0-5 timings (in nanoseconds). + * PIO 0-5, MWDMA 0-2 and UDMA 0-6 timings (in nanoseconds). * These were taken from ATA/ATAPI-6 standard, rev 0a, except - * for PIO 5, which is a nonstandard extension. + * for PIO 5, which is a nonstandard extension and UDMA6, which + * is currently supported only by Maxtor drives. */ static struct ide_timing ide_timing[] = { + { XFER_UDMA_6, 0, 0, 0, 0, 0, 0, 0, 15 }, { XFER_UDMA_5, 0, 0, 0, 0, 0, 0, 0, 20 }, { XFER_UDMA_4, 0, 0, 0, 0, 0, 0, 0, 30 }, { XFER_UDMA_3, 0, 0, 0, 0, 0, 0, 0, 45 }, @@ -105,6 +103,7 @@ #define EZ(v,unit) ((v)?ENOUGH(v,unit):0) #define XFER_MODE 0xf0 +#define XFER_UDMA_133 0x48 #define XFER_UDMA_100 0x44 #define XFER_UDMA_66 0x42 #define XFER_UDMA 0x40 @@ -123,6 +122,9 @@ if ((map & XFER_UDMA) && (id->field_valid & 4)) { /* Want UDMA and UDMA bitmap valid */ + if ((map & XFER_UDMA_133) == XFER_UDMA_133) + if ((best = (id->dma_ultra & 0x0040) ? XFER_UDMA_6 : 0)) return best; + if ((map & XFER_UDMA_100) == XFER_UDMA_100) if ((best = (id->dma_ultra & 0x0020) ? XFER_UDMA_5 : 0)) return best; @@ -174,14 +176,14 @@ static void ide_timing_quantize(struct ide_timing *t, struct ide_timing *q, int T, int UT) { - q->setup = EZ(t->setup, T); - q->act8b = EZ(t->act8b, T); - q->rec8b = EZ(t->rec8b, T); - q->cyc8b = EZ(t->cyc8b, T); - q->active = EZ(t->active, T); - q->recover = EZ(t->recover, T); - q->cycle = EZ(t->cycle, T); - q->udma = EZ(t->udma, UT); + q->setup = EZ(t->setup * 1000, T); + q->act8b = EZ(t->act8b * 1000, T); + q->rec8b = EZ(t->rec8b * 1000, T); + q->cyc8b = EZ(t->cyc8b * 1000, T); + q->active = EZ(t->active * 1000, T); + q->recover = EZ(t->recover * 1000, T); + q->cycle = EZ(t->cycle * 1000, T); + q->udma = EZ(t->udma * 1000, UT); } static void ide_timing_merge(struct ide_timing *a, struct ide_timing *b, struct ide_timing *m, unsigned int what) diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/ide/ide.c linux-2.5/drivers/ide/ide.c --- linux-2.5.1/drivers/ide/ide.c Sun Dec 16 20:21:02 2001 +++ linux-2.5/drivers/ide/ide.c Thu Dec 27 16:32:31 2001 @@ -1390,7 +1390,10 @@ * will start the next request from the queue. If no more work remains, * the driver will clear the hwgroup->flags IDE_BUSY flag and exit. */ -static void ide_do_request(ide_hwgroup_t *hwgroup, int masked_irq) +/* --BenH: made non-static as ide-pmac.c uses it to kick the hwgroup back + * into life on wakeup from machine sleep. + */ +void ide_do_request(ide_hwgroup_t *hwgroup, int masked_irq) { ide_drive_t *drive; ide_hwif_t *hwif; diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/ide/pdcraid.c linux-2.5/drivers/ide/pdcraid.c --- linux-2.5.1/drivers/ide/pdcraid.c Tue Nov 13 17:19:41 2001 +++ linux-2.5/drivers/ide/pdcraid.c Thu Dec 27 22:10:28 2001 @@ -387,18 +387,14 @@ #include "pdcraid.h" -static unsigned long calc_pdcblock_offset (int major,int minor) +static unsigned long calc_pdcblock_offset(struct block_device *bdev) { unsigned long lba = 0; - kdev_t dev; - ide_drive_t *ideinfo; - - dev = MKDEV(major,minor); - ideinfo = get_info_ptr (dev); + ide_drive_t *ideinfo = get_info_ptr(to_kdev_t(bdev->bd_dev)); + if (ideinfo==NULL) return 0; - - + /* first sector of the last cluster */ if (ideinfo->head==0) return 0; @@ -412,42 +408,32 @@ } -static int read_disk_sb (int major, int minor, unsigned char *buffer,int bufsize) +static int read_disk_sb(struct block_device *bdev, struct promise_raid_conf *p) { - int ret = -EINVAL; - struct buffer_head *bh = NULL; - kdev_t dev = MKDEV(major,minor); unsigned long sb_offset; + char *buffer; + int i; - if (blksize_size[major]==NULL) /* device doesn't exist */ - return -EINVAL; - - /* * Calculate the position of the superblock, * it's at first sector of the last cylinder */ - sb_offset = calc_pdcblock_offset(major,minor)/8; - /* The /8 transforms sectors into 4Kb blocks */ + sb_offset = calc_pdcblock_offset(bdev); if (sb_offset==0) return -1; - - set_blocksize (dev, 4096); - bh = bread (dev, sb_offset, 4096); - - if (bh) { - memcpy (buffer, bh->b_data, bufsize); - } else { - printk(KERN_ERR "pdcraid: Error reading superblock.\n"); - goto abort; + for (i = 0, buffer = (char*)p; i < 4; i++, buffer += 512) { + Sector sect; + char *q = read_dev_sector(bdev, sb_offset + i, §); + if (!p) { + printk(KERN_ERR "pdcraid: Error reading superblock.\n"); + return -1; + } + memcpy(buffer, q, 512); + put_dev_sector(§); } - ret = 0; -abort: - if (bh) - brelse (bh); - return ret; + return 0; } static unsigned int calc_sb_csum (unsigned int* ptr) @@ -464,12 +450,11 @@ static int cookie = 0; +static struct promise_raid_conf __initdata prom; static void __init probedisk(int devindex,int device, int raidlevel) { int i; int major, minor; - struct promise_raid_conf *prom; - static unsigned char block[4096]; struct block_device *bdev; if (devlist[devindex].device!=-1) /* already assigned to another array */ @@ -478,44 +463,48 @@ major = devlist[devindex].major; minor = devlist[devindex].minor; - if (read_disk_sb(major,minor,(unsigned char*)&block,sizeof(block))) - return; - - prom = (struct promise_raid_conf*)&block[512]; - - /* the checksums must match */ - if (prom->checksum != calc_sb_csum((unsigned int*)prom)) - return; - if (prom->raid.type!=raidlevel) /* different raidlevel */ + bdev = bdget(MKDEV(major,minor)); + if (!bdev) return; - if ((cookie!=0) && (cookie != prom->raid.magic_1)) /* different array */ + if (blkdev_get(bdev, FMODE_READ|FMODE_WRITE, 0, BDEV_RAW) != 0) return; + + if (read_disk_sb(bdev, &prom)) + goto out; + + /* the checksums must match */ + if (prom.checksum != calc_sb_csum((unsigned int*)&prom)) + goto out; + if (prom.raid.type!=raidlevel) /* different raidlevel */ + goto out; + + if ((cookie!=0) && (cookie != prom.raid.magic_1)) /* different array */ + goto out; - cookie = prom->raid.magic_1; + cookie = prom.raid.magic_1; /* This looks evil. But basically, we have to search for our adapternumber in the arraydefinition, both of which are in the superblock */ - for (i=0;(i<prom->raid.total_disks)&&(i<8);i++) { - if ( (prom->raid.disk[i].channel== prom->raid.channel) && - (prom->raid.disk[i].device == prom->raid.device) ) { - - bdev = bdget(MKDEV(major,minor)); - if (bdev && blkdev_get(bdev, FMODE_READ|FMODE_WRITE, 0, BDEV_RAW) == 0) { - raid[device].disk[i].bdev = bdev; - } + for (i=0;(i<prom.raid.total_disks)&&(i<8);i++) { + if ( (prom.raid.disk[i].channel== prom.raid.channel) && + (prom.raid.disk[i].device == prom.raid.device) ) { + + raid[device].disk[i].bdev = bdev; raid[device].disk[i].device = MKDEV(major,minor); - raid[device].disk[i].sectors = prom->raid.disk_secs; - raid[device].stride = (1<<prom->raid.raid0_shift); - raid[device].disks = prom->raid.total_disks; - raid[device].sectors = prom->raid.total_secs; - raid[device].geom.heads = prom->raid.heads+1; - raid[device].geom.sectors = prom->raid.sectors; - raid[device].geom.cylinders = prom->raid.cylinders+1; + raid[device].disk[i].sectors = prom.raid.disk_secs; + raid[device].stride = (1<<prom.raid.raid0_shift); + raid[device].disks = prom.raid.total_disks; + raid[device].sectors = prom.raid.total_secs; + raid[device].geom.heads = prom.raid.heads+1; + raid[device].geom.sectors = prom.raid.sectors; + raid[device].geom.cylinders = prom.raid.cylinders+1; devlist[devindex].device=device; - } + return; + } } - +out: + blkdev_put(bdev, BDEV_RAW); } static void __init fill_cutoff(int device) diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/ide/via82cxxx.c linux-2.5/drivers/ide/via82cxxx.c --- linux-2.5.1/drivers/ide/via82cxxx.c Tue Nov 27 17:23:27 2001 +++ linux-2.5/drivers/ide/via82cxxx.c Thu Dec 27 22:10:28 2001 @@ -1,5 +1,5 @@ /* - * $Id: via82cxxx.c,v 3.29 2001/09/10 10:06:00 vojtech Exp $ + * $Id: via82cxxx.c,v 3.33 2001/12/23 22:46:12 vojtech Exp $ * * Copyright (c) 2000-2001 Vojtech Pavlik * @@ -7,23 +7,21 @@ * Michel Aubry * Jeff Garzik * Andre Hedrick - * - * Sponsored by SuSE */ /* * VIA IDE driver for Linux. Supports * * vt82c576, vt82c586, vt82c586a, vt82c586b, vt82c596a, vt82c596b, - * vt82c686, vt82c686a, vt82c686b, vt8231, vt8233 + * vt82c686, vt82c686a, vt82c686b, vt8231, vt8233, vt8233c, vt8233a * * southbridges, which can be found in * * VIA Apollo Master, VP, VP2, VP2/97, VP3, VPX, VPX/97, MVP3, MVP4, P6, Pro, * ProII, ProPlus, Pro133, Pro133+, Pro133A, Pro133A Dual, Pro133T, Pro133Z, * PLE133, PLE133T, Pro266, Pro266T, ProP4X266, PM601, PM133, PN133, PL133T, - * PX266, PM266, KX133, KT133, KT133A, KLE133, KT266, KX266, KM133, KM133A, - * KL133, KN133, KM266 + * PX266, PM266, KX133, KT133, KT133A, KT133E, KLE133, KT266, KX266, KM133, + * KM133A, KL133, KN133, KM266 * PC-Chips VXPro, VXPro+, VXTwo, TXPro-III, TXPro-AGP, AGPPro, ViaGra, BXToo, * BXTel, BXpert * AMD 640, 640 AGP, 750 IronGate, 760, 760MP @@ -32,9 +30,9 @@ * * chipsets. Supports * - * PIO 0-5, MWDMA 0-2, SWDMA 0-2 and UDMA 0-5 + * PIO 0-5, MWDMA 0-2, SWDMA 0-2 and UDMA 0-6 * - * (this includes UDMA33, 66 and 100) modes. UDMA66 and higher modes are + * (this includes UDMA33, 66, 100 and 133) modes. UDMA66 and higher modes are * autoenabled only in case the BIOS has detected a 80 wire cable. To ignore * the BIOS data and assume the cable is present, use 'ide0=ata66' or * 'ide1=ata66' on the kernel command line. @@ -56,8 +54,8 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * Should you need to contact me, the author, you can do so either by - * e-mail - mail your message to <vojtech@suse.cz>, or by paper mail: - * Vojtech Pavlik, Ucitelska 1576, Prague 8, 182 00 Czech Republic + * e-mail - mail your message to <vojtech@ucw.cz>, or by paper mail: + * Vojtech Pavlik, Simunkova 1594, Prague 8, 182 00 Czech Republic */ #include <linux/config.h> @@ -87,10 +85,12 @@ #define VIA_UDMA_33 0x001 #define VIA_UDMA_66 0x002 #define VIA_UDMA_100 0x003 +#define VIA_UDMA_133 0x004 #define VIA_BAD_PREQ 0x010 /* Crashes if PREQ# till DDACK# set */ #define VIA_BAD_CLK66 0x020 /* 66 MHz clock doesn't work correctly */ #define VIA_SET_FIFO 0x040 /* Needs to have FIFO split set */ #define VIA_NO_UNMASK 0x080 /* Doesn't work with IRQ unmasking on */ +#define VIA_BAD_ID 0x100 /* Has wrong vendor ID (0x1107) */ /* * VIA SouthBridge chips. @@ -104,10 +104,11 @@ unsigned short flags; } via_isa_bridges[] = { #ifdef FUTURE_BRIDGES - { "vt8237", PCI_DEVICE_ID_VIA_8237, 0x00, 0x2f, VIA_UDMA_100 }, - { "vt8235", PCI_DEVICE_ID_VIA_8235, 0x00, 0x2f, VIA_UDMA_100 }, - { "vt8233c", PCI_DEVICE_ID_VIA_8233C, 0x00, 0x2f, VIA_UDMA_100 }, + { "vt8237", PCI_DEVICE_ID_VIA_8237, 0x00, 0x2f, VIA_UDMA_133 }, + { "vt8235", PCI_DEVICE_ID_VIA_8235, 0x00, 0x2f, VIA_UDMA_133 }, #endif + { "vt8233a", PCI_DEVICE_ID_VIA_8233A, 0x00, 0x2f, VIA_UDMA_133 }, + { "vt8233c", PCI_DEVICE_ID_VIA_8233C_0, 0x00, 0x2f, VIA_UDMA_100 }, { "vt8233", PCI_DEVICE_ID_VIA_8233_0, 0x00, 0x2f, VIA_UDMA_100 }, { "vt8231", PCI_DEVICE_ID_VIA_8231, 0x00, 0x2f, VIA_UDMA_100 }, { "vt82c686b", PCI_DEVICE_ID_VIA_82C686, 0x40, 0x4f, VIA_UDMA_100 }, @@ -121,6 +122,7 @@ { "vt82c586a", PCI_DEVICE_ID_VIA_82C586_0, 0x20, 0x2f, VIA_UDMA_33 | VIA_SET_FIFO }, { "vt82c586", PCI_DEVICE_ID_VIA_82C586_0, 0x00, 0x0f, VIA_UDMA_NONE | VIA_SET_FIFO }, { "vt82c576", PCI_DEVICE_ID_VIA_82C576, 0x00, 0x2f, VIA_UDMA_NONE | VIA_SET_FIFO | VIA_NO_UNMASK }, + { "vt82c576", PCI_DEVICE_ID_VIA_82C576, 0x00, 0x2f, VIA_UDMA_NONE | VIA_SET_FIFO | VIA_NO_UNMASK | VIA_BAD_ID }, { NULL } }; @@ -128,7 +130,7 @@ static unsigned char via_enabled; static unsigned int via_80w; static unsigned int via_clock; -static char *via_dma[] = { "MWDMA16", "UDMA33", "UDMA66", "UDMA100" }; +static char *via_dma[] = { "MWDMA16", "UDMA33", "UDMA66", "UDMA100", "UDMA133" }; /* * VIA /proc entry. @@ -151,7 +153,7 @@ static int via_get_info(char *buffer, char **addr, off_t offset, int count) { - short speed[4], cycle[4], setup[4], active[4], recover[4], den[4], + int speed[4], cycle[4], setup[4], active[4], recover[4], den[4], uen[4], udma[4], umul[4], active8b[4], recover8b[4]; struct pci_dev *dev = bmide_dev; unsigned int v, u, i; @@ -161,7 +163,7 @@ via_print("----------VIA BusMastering IDE Configuration----------------"); - via_print("Driver Version: 3.29"); + via_print("Driver Version: 3.33"); via_print("South Bridge: VIA %s", via_config->name); pci_read_config_byte(isa_dev, PCI_REVISION_ID, &t); @@ -170,7 +172,7 @@ via_print("Highest DMA rate: %s", via_dma[via_config->flags & VIA_UDMA]); via_print("BM-DMA base: %#x", via_base); - via_print("PCI clock: %dMHz", via_clock); + via_print("PCI clock: %d.%dMHz", via_clock / 1000, via_clock / 100 % 10); pci_read_config_byte(dev, VIA_MISC_1, &t); via_print("Master Read Cycle IRDY: %dws", (t & 64) >> 6); @@ -218,40 +220,45 @@ uen[i] = ((u >> ((3 - i) << 3)) & 0x20); den[i] = (c & ((i & 1) ? 0x40 : 0x20) << ((i & 2) << 2)); - speed[i] = 20 * via_clock / (active[i] + recover[i]); - cycle[i] = 1000 / via_clock * (active[i] + recover[i]); + speed[i] = 2 * via_clock / (active[i] + recover[i]); + cycle[i] = 1000000 * (active[i] + recover[i]) / via_clock; if (!uen[i] || !den[i]) continue; switch (via_config->flags & VIA_UDMA) { - - case VIA_UDMA_100: - speed[i] = 60 * via_clock / udma[i]; - cycle[i] = 333 / via_clock * udma[i]; + + case VIA_UDMA_33: + speed[i] = 2 * via_clock / udma[i]; + cycle[i] = 1000000 * udma[i] / via_clock; break; case VIA_UDMA_66: - speed[i] = 40 * via_clock / (udma[i] * umul[i]); - cycle[i] = 500 / via_clock * (udma[i] * umul[i]); + speed[i] = 4 * via_clock / (udma[i] * umul[i]); + cycle[i] = 500000 * (udma[i] * umul[i]) / via_clock; break; - case VIA_UDMA_33: - speed[i] = 20 * via_clock / udma[i]; - cycle[i] = 1000 / via_clock * udma[i]; + case VIA_UDMA_100: + speed[i] = 6 * via_clock / udma[i]; + cycle[i] = 333333 * udma[i] / via_clock; + break; + + case VIA_UDMA_133: + speed[i] = 8 * via_clock / udma[i]; + cycle[i] = 250000 * udma[i] / via_clock; break; } } via_print_drive("Transfer Mode: ", "%10s", den[i] ? (uen[i] ? "UDMA" : "DMA") : "PIO"); - via_print_drive("Address Setup: ", "%8dns", (1000 / via_clock) * setup[i]); - via_print_drive("Cmd Active: ", "%8dns", (1000 / via_clock) * active8b[i]); - via_print_drive("Cmd Recovery: ", "%8dns", (1000 / via_clock) * recover8b[i]); - via_print_drive("Data Active: ", "%8dns", (1000 / via_clock) * active[i]); - via_print_drive("Data Recovery: ", "%8dns", (1000 / via_clock) * recover[i]); + via_print_drive("Address Setup: ", "%8dns", 1000000 * setup[i] / via_clock); + via_print_drive("Cmd Active: ", "%8dns", 1000000 * active8b[i] / via_clock); + via_print_drive("Cmd Recovery: ", "%8dns", 1000000 * recover8b[i] / via_clock); + via_print_drive("Data Active: ", "%8dns", 1000000 * active[i] / via_clock); + via_print_drive("Data Recovery: ", "%8dns", 1000000 * recover[i] / via_clock); via_print_drive("Cycle Time: ", "%8dns", cycle[i]); - via_print_drive("Transfer Rate: ", "%4d.%dMB/s", speed[i] / 10, speed[i] % 10); + via_print_drive("Transfer Rate: ", "%4d.%dMB/s", speed[i] / 1000, speed[i] / 100 % 10); return p - buffer; /* hoping it is less than 4K... */ } @@ -280,6 +287,7 @@ case VIA_UDMA_33: t = timing->udma ? (0xe0 | (FIT(timing->udma, 2, 5) - 2)) : 0x03; break; case VIA_UDMA_66: t = timing->udma ? (0xe8 | (FIT(timing->udma, 2, 9) - 2)) : 0x0f; break; case VIA_UDMA_100: t = timing->udma ? (0xe0 | (FIT(timing->udma, 2, 9) - 2)) : 0x07; break; + case VIA_UDMA_133: t = timing->udma ? (0xe0 | (FIT(timing->udma, 2, 9) - 2)) : 0x07; break; default: return; } @@ -296,20 +304,21 @@ { ide_drive_t *peer = HWIF(drive)->drives + (~drive->dn & 1); struct ide_timing t, p; - int T, UT; + unsigned int T, UT; if (speed != XFER_PIO_SLOW && speed != drive->current_speed) if (ide_config_drive_speed(drive, speed)) printk(KERN_WARNING "ide%d: Drive %d didn't accept speed setting. Oh, well.\n", drive->dn >> 1, drive->dn & 1); - T = 1000 / via_clock; + T = 1000000000 / via_clock; switch (via_config->flags & VIA_UDMA) { case VIA_UDMA_33: UT = T; break; case VIA_UDMA_66: UT = T/2; break; case VIA_UDMA_100: UT = T/3; break; - default: UT = T; break; + case VIA_UDMA_133: UT = T/4; break; + default: UT = T; } ide_timing_compute(drive, speed, &t, T, UT); @@ -365,7 +374,8 @@ XFER_PIO | XFER_EPIO | XFER_SWDMA | XFER_MWDMA | (via_config->flags & VIA_UDMA ? XFER_UDMA : 0) | (w80 && (via_config->flags & VIA_UDMA) >= VIA_UDMA_66 ? XFER_UDMA_66 : 0) | - (w80 && (via_config->flags & VIA_UDMA) >= VIA_UDMA_100 ? XFER_UDMA_100 : 0)); + (w80 && (via_config->flags & VIA_UDMA) >= VIA_UDMA_100 ? XFER_UDMA_100 : 0) | + (w80 && (via_config->flags & VIA_UDMA) >= VIA_UDMA_133 ? XFER_UDMA_133 : 0)); via_set_drive(drive, speed); @@ -395,14 +405,16 @@ */ for (via_config = via_isa_bridges; via_config->id; via_config++) - if ((isa = pci_find_device(PCI_VENDOR_ID_VIA, via_config->id, NULL))) { + if ((isa = pci_find_device(PCI_VENDOR_ID_VIA + + !!(via_config->flags & VIA_BAD_ID), via_config->id, NULL))) { + pci_read_config_byte(isa, PCI_REVISION_ID, &t); if (t >= via_config->rev_min && t <= via_config->rev_max) break; } if (!via_config->id) { - printk(KERN_WARNING "VP_IDE: Unknown VIA SouthBridge, contact Vojtech Pavlik <vojtech@suse.cz>\n"); + printk(KERN_WARNING "VP_IDE: Unknown VIA SouthBridge, contact Vojtech Pavlik <vojtech@ucw.cz>\n"); return -ENODEV; } @@ -412,22 +424,28 @@ switch (via_config->flags & VIA_UDMA) { - case VIA_UDMA_100: - - pci_read_config_dword(dev, VIA_UDMA_TIMING, &u); - for (i = 24; i >= 0; i -= 8) - if (((u >> i) & 0x10) || (((u >> i) & 0x20) && (((u >> i) & 7) < 3))) - via_80w |= (1 << (1 - (i >> 4))); /* BIOS 80-wire bit or UDMA w/ < 50ns/cycle */ - break; - case VIA_UDMA_66: - pci_read_config_dword(dev, VIA_UDMA_TIMING, &u); /* Enable Clk66 */ pci_write_config_dword(dev, VIA_UDMA_TIMING, u | 0x80008); for (i = 24; i >= 0; i -= 8) if (((u >> (i & 16)) & 8) && ((u >> i) & 0x20) && (((u >> i) & 7) < 2)) via_80w |= (1 << (1 - (i >> 4))); /* 2x PCI clock and UDMA w/ < 3T/cycle */ break; + + case VIA_UDMA_100: + pci_read_config_dword(dev, VIA_UDMA_TIMING, &u); + for (i = 24; i >= 0; i -= 8) + if (((u >> i) & 0x10) || (((u >> i) & 0x20) && (((u >> i) & 7) < 4))) + via_80w |= (1 << (1 - (i >> 4))); /* BIOS 80-wire bit or UDMA w/ < 60ns/cycle */ + break; + + case VIA_UDMA_133: + pci_read_config_dword(dev, VIA_UDMA_TIMING, &u); + for (i = 24; i >= 0; i -= 8) + if (((u >> i) & 0x10) || (((u >> i) & 0x20) && (((u >> i) & 7) < 8))) + via_80w |= (1 << (1 - (i >> 4))); /* BIOS 80-wire bit or UDMA w/ < 60ns/cycle */ + break; + } if (via_config->flags & VIA_BAD_CLK66) { /* Disable Clk66 */ @@ -466,10 +484,17 @@ * Determine system bus clock. */ - via_clock = system_bus_clock(); - if (via_clock < 20 || via_clock > 50) { + via_clock = system_bus_clock() * 1000; + + switch (via_clock) { + case 33000: via_clock = 33333; break; + case 37000: via_clock = 37500; break; + case 41000: via_clock = 41666; break; + } + + if (via_clock < 20000 || via_clock > 50000) { printk(KERN_WARNING "VP_IDE: User given PCI clock speed impossible (%d), using 33 MHz instead.\n", via_clock); - printk(KERN_WARNING "VP_IDE: Use ide0=ata66 if you want to force UDMA66/UDMA100.\n"); + printk(KERN_WARNING "VP_IDE: Use ide0=ata66 if you want to assume 80-wire cable.\n"); via_clock = 33; } diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/ieee1394/hosts.c linux-2.5/drivers/ieee1394/hosts.c --- linux-2.5.1/drivers/ieee1394/hosts.c Tue Oct 2 04:24:24 2001 +++ linux-2.5/drivers/ieee1394/hosts.c Thu Dec 13 16:32:35 2001 @@ -170,10 +170,10 @@ list_for_each(hlh, &tmpl->hosts) { host = list_entry(hlh, struct hpsb_host, list); if (host->initialized) { + highlevel_remove_host(host); + host->initialized = 0; abort_requests(host); - - highlevel_remove_host(host); tmpl->release_host(host); while (test_bit(0, &host->timeout_tq.sync)) { diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/ieee1394/ieee1394_core.c linux-2.5/drivers/ieee1394/ieee1394_core.c --- linux-2.5.1/drivers/ieee1394/ieee1394_core.c Wed Oct 17 21:19:20 2001 +++ linux-2.5/drivers/ieee1394/ieee1394_core.c Thu Dec 13 16:32:35 2001 @@ -318,7 +318,7 @@ void hpsb_selfid_complete(struct hpsb_host *host, int phyid, int isroot) { - host->node_id = 0xffc0 | phyid; + host->node_id = LOCAL_BUS | phyid; host->in_bus_reset = 0; host->is_root = isroot; diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/ieee1394/ieee1394_syms.c linux-2.5/drivers/ieee1394/ieee1394_syms.c --- linux-2.5.1/drivers/ieee1394/ieee1394_syms.c Sun Nov 11 18:09:32 2001 +++ linux-2.5/drivers/ieee1394/ieee1394_syms.c Thu Jan 1 00:00:00 1970 @@ -1,88 +0,0 @@ -/* - * IEEE 1394 for Linux - * - * Exported symbols for module usage. - * - * Copyright (C) 1999 Andreas E. Bombe - * - * This code is licensed under the GPL. See the file COPYING in the root - * directory of the kernel sources for details. - */ - -#include <linux/config.h> -#include <linux/module.h> -#include <linux/types.h> -#include <linux/string.h> - -#include "ieee1394_types.h" -#include "hosts.h" -#include "ieee1394_core.h" -#include "ieee1394_transactions.h" -#include "ieee1394_hotplug.h" -#include "highlevel.h" -#include "nodemgr.h" - -EXPORT_SYMBOL(hpsb_register_lowlevel); -EXPORT_SYMBOL(hpsb_unregister_lowlevel); -EXPORT_SYMBOL(hpsb_get_host); -EXPORT_SYMBOL(hpsb_inc_host_usage); -EXPORT_SYMBOL(hpsb_dec_host_usage); - -EXPORT_SYMBOL(alloc_hpsb_packet); -EXPORT_SYMBOL(free_hpsb_packet); -EXPORT_SYMBOL(hpsb_send_packet); -EXPORT_SYMBOL(hpsb_reset_bus); -EXPORT_SYMBOL(hpsb_bus_reset); -EXPORT_SYMBOL(hpsb_selfid_received); -EXPORT_SYMBOL(hpsb_selfid_complete); -EXPORT_SYMBOL(hpsb_packet_sent); -EXPORT_SYMBOL(hpsb_packet_received); - -EXPORT_SYMBOL(get_tlabel); -EXPORT_SYMBOL(free_tlabel); -EXPORT_SYMBOL(fill_async_readquad); -EXPORT_SYMBOL(fill_async_readquad_resp); -EXPORT_SYMBOL(fill_async_readblock); -EXPORT_SYMBOL(fill_async_readblock_resp); -EXPORT_SYMBOL(fill_async_writequad); -EXPORT_SYMBOL(fill_async_writeblock); -EXPORT_SYMBOL(fill_async_write_resp); -EXPORT_SYMBOL(fill_async_lock); -EXPORT_SYMBOL(fill_async_lock_resp); -EXPORT_SYMBOL(fill_iso_packet); -EXPORT_SYMBOL(fill_phy_packet); -EXPORT_SYMBOL(hpsb_make_readqpacket); -EXPORT_SYMBOL(hpsb_make_readbpacket); -EXPORT_SYMBOL(hpsb_make_writeqpacket); -EXPORT_SYMBOL(hpsb_make_writebpacket); -EXPORT_SYMBOL(hpsb_make_lockpacket); -EXPORT_SYMBOL(hpsb_make_phypacket); -EXPORT_SYMBOL(hpsb_packet_success); -EXPORT_SYMBOL(hpsb_make_packet); -EXPORT_SYMBOL(hpsb_read); -EXPORT_SYMBOL(hpsb_write); -EXPORT_SYMBOL(hpsb_lock); - -EXPORT_SYMBOL(hpsb_register_highlevel); -EXPORT_SYMBOL(hpsb_unregister_highlevel); -EXPORT_SYMBOL(hpsb_register_addrspace); -EXPORT_SYMBOL(hpsb_listen_channel); -EXPORT_SYMBOL(hpsb_unlisten_channel); -EXPORT_SYMBOL(highlevel_read); -EXPORT_SYMBOL(highlevel_write); -EXPORT_SYMBOL(highlevel_lock); -EXPORT_SYMBOL(highlevel_lock64); -EXPORT_SYMBOL(highlevel_add_host); -EXPORT_SYMBOL(highlevel_remove_host); -EXPORT_SYMBOL(highlevel_host_reset); -EXPORT_SYMBOL(highlevel_add_one_host); - -EXPORT_SYMBOL(hpsb_guid_get_entry); -EXPORT_SYMBOL(hpsb_nodeid_get_entry); -EXPORT_SYMBOL(hpsb_get_host_by_ne); -EXPORT_SYMBOL(hpsb_guid_fill_packet); -EXPORT_SYMBOL(hpsb_register_protocol); -EXPORT_SYMBOL(hpsb_unregister_protocol); -EXPORT_SYMBOL(hpsb_release_unit_directory); - -MODULE_LICENSE("GPL"); diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/ieee1394/nodemgr.c linux-2.5/drivers/ieee1394/nodemgr.c --- linux-2.5.1/drivers/ieee1394/nodemgr.c Wed Oct 17 21:19:20 2001 +++ linux-2.5/drivers/ieee1394/nodemgr.c Thu Dec 13 16:32:35 2001 @@ -359,7 +359,7 @@ kfree(buf); kfree(envp); if (value != 0) - HPSB_DEBUG("NodeMgr: hotplug policy returned 0x%x", value); + HPSB_DEBUG("NodeMgr: hotplug policy returned %d", value); } #else @@ -369,9 +369,8 @@ { #ifdef CONFIG_IEEE1394_VERBOSEDEBUG HPSB_DEBUG("NodeMgr: nodemgr_call_policy(): hotplug not enabled"); -#else - return; #endif + return; } #endif /* CONFIG_HOTPLUG */ @@ -582,13 +581,13 @@ struct hpsb_host *host, nodeid_t nodeid) { struct list_head *lh; + struct unit_directory *ud; - if (ne->nodeid != nodeid) + if (ne->nodeid != nodeid) { HPSB_DEBUG("Node " NODE_BUS_FMT " changed to " NODE_BUS_FMT, NODE_BUS_ARGS(ne->nodeid), NODE_BUS_ARGS(nodeid)); - - ne->host = host; - ne->nodeid = nodeid; + ne->nodeid = nodeid; + } if (ne->busopt.generation != ((busoptions >> 4) & 0xf)) nodemgr_process_config_rom (ne, busoptions); @@ -597,8 +596,6 @@ atomic_set(&ne->generation, get_hpsb_generation(ne->host)); list_for_each (lh, &ne->unit_directories) { - struct unit_directory *ud; - ud = list_entry (lh, struct unit_directory, node_list); if (ud->driver != NULL && ud->driver->update != NULL) ud->driver->update(ud); @@ -679,57 +676,76 @@ return; } +/* Used to schedule each nodes config rom probe */ +struct node_probe_task { + nodeid_t nodeid; + struct hpsb_host *host; + atomic_t *count; + struct tq_struct task; +}; + /* This is where we probe the nodes for their information and provided * features. */ -static void nodemgr_node_probe(void *data) +static void nodemgr_node_probe_one(void *__npt) { - struct hpsb_host *host = (struct hpsb_host *)data; - struct selfid *sid = (struct selfid *)host->topology_map; - struct list_head *lh, *next; + struct node_probe_task *npt = (struct node_probe_task *)__npt; struct node_entry *ne; - int nodecount = host->node_count; - nodeid_t nodeid = LOCAL_BUS; quadlet_t buffer[5]; octlet_t guid; - unsigned long flags; /* We need to detect when the ConfigROM's generation has changed, * so we only update the node's info when it needs to be. */ - for (; nodecount; nodecount--, nodeid++, sid++) { - /* Skip extended, and non-active node's */ - while (sid->extended) - sid++; - if (!sid->link_active) - continue; - if (read_businfo_block (host, nodeid, buffer, sizeof(buffer) >> 2)) - continue; + if (read_businfo_block (npt->host, npt->nodeid, buffer, sizeof(buffer) >> 2)) + goto probe_complete; - if (buffer[1] != IEEE1394_BUSID_MAGIC) { - /* This isn't a 1394 device */ - HPSB_ERR("Node " NODE_BUS_FMT " isn't an IEEE 1394 device", - NODE_BUS_ARGS(nodeid)); - continue; - } + if (buffer[1] != IEEE1394_BUSID_MAGIC) { + /* This isn't a 1394 device */ + HPSB_ERR("Node " NODE_BUS_FMT " isn't an IEEE 1394 device", + NODE_BUS_ARGS(npt->nodeid)); + goto probe_complete; + } + + guid = ((u64)buffer[3] << 32) | buffer[4]; + ne = hpsb_guid_get_entry(guid); + + if (!ne) + nodemgr_create_node(guid, buffer[2], npt->host, npt->nodeid); + else + nodemgr_update_node(ne, buffer[2], npt->host, npt->nodeid); + +probe_complete: + atomic_dec(npt->count); + + kfree(npt); + + return; +} - guid = ((u64)buffer[3] << 32) | buffer[4]; - ne = hpsb_guid_get_entry(guid); +static void nodemgr_node_probe_cleanup(void *__npt) +{ + struct node_probe_task *npt = (struct node_probe_task *)__npt; + unsigned long flags; + struct list_head *lh, *next; + struct node_entry *ne; + + /* If things aren't done yet, reschedule ourselves. */ + if (atomic_read(npt->count)) { + schedule_task(&npt->task); + return; + } - if (!ne) - nodemgr_create_node(guid, buffer[2], host, nodeid); - else - nodemgr_update_node(ne, buffer[2], host, nodeid); - } + kfree(npt->count); /* Now check to see if we have any nodes that aren't referenced * any longer. */ - write_lock_irqsave(&node_lock, flags); + write_lock_irqsave(&node_lock, flags); for (lh = node_list.next; lh != &node_list; lh = next) { ne = list_entry(lh, struct node_entry, list); next = lh->next; /* Only checking this host */ - if (ne->host != host) + if (ne->host != npt->host) continue; /* If the generation didn't get updated, then either the @@ -741,9 +757,70 @@ } write_unlock_irqrestore(&node_lock, flags); + kfree(npt); + return; } +static void nodemgr_node_probe(void *__host) +{ + struct hpsb_host *host = (struct hpsb_host *)__host; + int nodecount = host->node_count; + struct selfid *sid = (struct selfid *)host->topology_map; + nodeid_t nodeid = LOCAL_BUS; + struct node_probe_task *npt; + atomic_t *count; + + count = kmalloc(sizeof (*count), GFP_KERNEL); + + if (count == NULL) { + HPSB_ERR ("NodeMgr: out of memory in nodemgr_node_probe"); + return; + } + + atomic_set(count, 0); + + for (; nodecount; nodecount--, nodeid++, sid++) { + while (sid->extended) + sid++; + if (!sid->link_active || nodeid == host->node_id) + continue; + + npt = kmalloc(sizeof (*npt), GFP_KERNEL); + + if (npt == NULL) { + HPSB_ERR ("NodeMgr: out of memory in nodemgr_node_probe"); + break; + } + + INIT_TQUEUE(&npt->task, nodemgr_node_probe_one, npt); + npt->host = host; + npt->nodeid = nodeid; + npt->count = count; + + atomic_inc(count); + + schedule_task(&npt->task); + } + + /* Now schedule a task to clean things up after the node probes + * are done. */ + npt = kmalloc (sizeof (*npt), GFP_KERNEL); + + if (npt == NULL) { + HPSB_ERR ("NodeMgr: out of memory in nodemgr_node_probe"); + return; + } + + INIT_TQUEUE(&npt->task, nodemgr_node_probe_cleanup, npt); + npt->host = host; + npt->nodeid = 0; + npt->count = count; + + schedule_task(&npt->task); + + return; +} struct node_entry *hpsb_guid_get_entry(u64 guid) { @@ -864,7 +941,7 @@ write_unlock_irqrestore(&node_lock, flags); spin_lock_irqsave (&host_info_lock, flags); - list_for_each(lh, &host_info_list) { + list_for_each_safe(lh, next, &host_info_list) { struct host_info *hi = list_entry(lh, struct host_info, list); if (hi->host == host) { list_del(&hi->list); diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/ieee1394/ohci1394.c linux-2.5/drivers/ieee1394/ohci1394.c --- linux-2.5.1/drivers/ieee1394/ohci1394.c Tue Oct 2 04:24:24 2001 +++ linux-2.5/drivers/ieee1394/ohci1394.c Sun Dec 30 21:17:30 2001 @@ -99,23 +99,18 @@ #include <asm/pgtable.h> #include <asm/page.h> #include <linux/sched.h> -#include <asm/segment.h> #include <linux/types.h> #include <linux/wrapper.h> #include <linux/vmalloc.h> #include <linux/init.h> #ifdef CONFIG_ALL_PPC -#include <asm/feature.h> +#include <asm/machdep.h> +#include <asm/pmac_feature.h> #include <asm/prom.h> #include <asm/pci-bridge.h> #endif -/* Revert to old bus reset algorithm that works on my Pismo until - * the new one is fixed - */ -#undef BUSRESET_WORKAROUND - #include "ieee1394.h" #include "ieee1394_types.h" #include "hosts.h" @@ -175,7 +170,7 @@ MODULE_DEVICE_TABLE(pci, ohci1394_pci_tbl); static char version[] __devinitdata = - "v0.51 08/08/01 Ben Collins <bcollins@debian.org>"; + "$Revision: 1.80 $ Ben Collins <bcollins@debian.org>"; /* Module Parameters */ MODULE_PARM(attempt_root,"i"); @@ -516,12 +511,9 @@ /* After enabling LPS, we need to wait for the connection * between phy and link to be established. This should be * signaled by the LPS bit becoming 1, but this happens - * immediately. Instead we wait for reads from LinkControl to - * give a valid result, i.e. not 0xffffffff. */ - while (reg_read(ohci, OHCI1394_LinkControlSet) == 0xffffffff) { - DBGMSG(ohci->id, "waiting for phy-link connection"); - mdelay(2); - } + * immediately. There seems to be no consistent way to wait + * for this, but 50ms seems to be enough. */ + mdelay(50); /* Set the bus number */ reg_write(ohci, OHCI1394_NodeID, 0x0000ffc0); @@ -1131,11 +1123,7 @@ * selfIDComplete interrupt. */ spin_lock_irqsave(&ohci->event_lock, flags); event = reg_read(ohci, OHCI1394_IntEventClear); -#ifdef BUSRESET_WORKAROUND - reg_write(ohci, OHCI1394_IntEventClear, event); -#else reg_write(ohci, OHCI1394_IntEventClear, event & ~OHCI1394_busReset); -#endif spin_unlock_irqrestore(&ohci->event_lock, flags); if (!event) return; @@ -1154,11 +1142,17 @@ * selfID phase, so we disable busReset interrupts, to * avoid burying the cpu in interrupt requests. */ spin_lock_irqsave(&ohci->event_lock, flags); -#ifdef BUSRESET_WORKAROUND - reg_write(ohci, OHCI1394_IntEventClear, OHCI1394_busReset); -#else reg_write(ohci, OHCI1394_IntMaskClear, OHCI1394_busReset); -#endif + if (ohci->dev->vendor == PCI_VENDOR_ID_APPLE && + ohci->dev->device == PCI_DEVICE_ID_APPLE_UNI_N_FW) { + udelay(10); + while(reg_read(ohci, OHCI1394_IntEventSet) & OHCI1394_busReset) { + reg_write(ohci, OHCI1394_IntEventClear, OHCI1394_busReset); + spin_unlock_irqrestore(&ohci->event_lock, flags); + udelay(10); + spin_lock_irqsave(&ohci->event_lock, flags); + } + } spin_unlock_irqrestore(&ohci->event_lock, flags); if (!host->in_bus_reset) { DBGMSG(ohci->id, "irq_handler: Bus reset requested%s", @@ -1309,12 +1303,10 @@ /* Finally, we clear the busReset event and reenable * the busReset interrupt. */ -#ifndef BUSRESET_WORKAROUND spin_lock_irqsave(&ohci->event_lock, flags); reg_write(ohci, OHCI1394_IntMaskSet, OHCI1394_busReset); reg_write(ohci, OHCI1394_IntEventClear, OHCI1394_busReset); spin_unlock_irqrestore(&ohci->event_lock, flags); -#endif event &= ~OHCI1394_selfIDComplete; } @@ -1966,8 +1958,6 @@ cf_put_keyval(&cr, 0x03, 0x00005e); /* Vendor ID */ cf_put_refer(&cr, 0x81, 2); /* Textual description unit */ cf_put_keyval(&cr, 0x0c, 0x0083c0); /* Node capabilities */ - cf_put_refer(&cr, 0xd1, 3); /* IPv4 unit directory */ - cf_put_refer(&cr, 0xd1, 4); /* IPv6 unit directory */ /* NOTE: Add other unit referers here, and append at bottom */ cf_unit_end(&cr); @@ -1980,46 +1970,6 @@ cf_put_4bytes(&cr, '9', '4', 0x0, 0x0); cf_unit_end(&cr); - /* IPv4 unit directory, RFC 2734 */ - cf_unit_begin(&cr, 3); - cf_put_keyval(&cr, 0x12, 0x00005e); /* Unit spec ID */ - cf_put_refer(&cr, 0x81, 6); /* Textual description unit */ - cf_put_keyval(&cr, 0x13, 0x000001); /* Unit software version */ - cf_put_refer(&cr, 0x81, 7); /* Textual description unit */ - cf_unit_end(&cr); - - cf_unit_begin(&cr, 6); - cf_put_keyval(&cr, 0, 0); - cf_put_1quad(&cr, 0); - cf_put_4bytes(&cr, 'I', 'A', 'N', 'A'); - cf_unit_end(&cr); - - cf_unit_begin(&cr, 7); - cf_put_keyval(&cr, 0, 0); - cf_put_1quad(&cr, 0); - cf_put_4bytes(&cr, 'I', 'P', 'v', '4'); - cf_unit_end(&cr); - - /* IPv6 unit directory, draft-ietf-ipngwg-1394-01.txt */ - cf_unit_begin(&cr, 4); - cf_put_keyval(&cr, 0x12, 0x00005e); /* Unit spec ID */ - cf_put_refer(&cr, 0x81, 8); /* Textual description unit */ - cf_put_keyval(&cr, 0x13, 0x000002); /* (Proposed) Unit software version */ - cf_put_refer(&cr, 0x81, 9); /* Textual description unit */ - cf_unit_end(&cr); - - cf_unit_begin(&cr, 8); - cf_put_keyval(&cr, 0, 0); - cf_put_1quad(&cr, 0); - cf_put_4bytes(&cr, 'I', 'A', 'N', 'A'); - cf_unit_end(&cr); - - cf_unit_begin(&cr, 9); - cf_put_keyval(&cr, 0, 0); - cf_put_1quad(&cr, 0); - cf_put_4bytes(&cr, 'I', 'P', 'v', '6'); - cf_unit_end(&cr); - ohci->csr_config_rom_length = cr.data - ohci->csr_config_rom_cpu; } @@ -2309,8 +2259,8 @@ of_node = pci_device_to_OF_node(ohci->dev); if (of_node) { - feature_set_firewire_power(of_node, 0); - feature_set_firewire_cable_power(of_node, 0); + pmac_call_feature(PMAC_FTR_1394_ENABLE, of_node, 0, 0); + pmac_call_feature(PMAC_FTR_1394_CABLE_POWER, of_node, 0, 0); } } #endif /* CONFIG_ALL_PPC */ @@ -2423,7 +2373,7 @@ name: OHCI1394_DRIVER_NAME, id_table: ohci1394_pci_tbl, probe: ohci1394_add_one, - remove: ohci1394_remove_one, + remove: __devexit_p(ohci1394_remove_one), }; static void __exit ohci1394_cleanup (void) diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/ieee1394/pcilynx.c linux-2.5/drivers/ieee1394/pcilynx.c --- linux-2.5.1/drivers/ieee1394/pcilynx.c Sun Nov 11 18:20:21 2001 +++ linux-2.5/drivers/ieee1394/pcilynx.c Thu Dec 13 16:32:35 2001 @@ -1637,8 +1637,8 @@ static void __exit pcilynx_cleanup(void) { - pci_unregister_driver(&lynx_pcidriver); hpsb_unregister_lowlevel(&lynx_template); + pci_unregister_driver(&lynx_pcidriver); PRINT_G(KERN_INFO, "removed " PCILYNX_DRIVER_NAME " module"); } diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/ieee1394/sbp2.c linux-2.5/drivers/ieee1394/sbp2.c --- linux-2.5.1/drivers/ieee1394/sbp2.c Wed Oct 17 21:19:20 2001 +++ linux-2.5/drivers/ieee1394/sbp2.c Sat Dec 29 00:52:33 2001 @@ -222,8 +222,25 @@ * when we register our driver. This change * automtically adds hotplug support to the driver. * Kristian Hogsberg <hogsberg@users.sf.net> + * + * 11/17/01 - Various bugfixes/cleanups: + * * Remember to logout of device in sbp2_disconnect. + * * If we fail to reconnect to a device after bus reset + * remember to release unit directory, so the ieee1394 + * knows we no longer manage it. + * * Unregister scsi hosts in sbp2_remove_host when a + * hpsb_host goes away. + * * Remove stupid hack in sbp2_remove_host. + * * Switched to "manual" module initialization + * (i.e. not scsi_module.c) and moved sbp2_cleanup + * moved sbp2scsi_release to sbp2_module_ext. The + * release function is called once pr. registered + * scsi host, but sbp2_cleanup should only be called + * upon module unload. Moved much initialization + * from sbp2scsi_detect to sbp2_module_init. + * Kristian Hogsberg <hogsberg@users.sf.net> */ - + /* @@ -244,6 +261,7 @@ #include <linux/proc_fs.h> #include <linux/blk.h> #include <linux/smp_lock.h> +#include <linux/init.h> #include <asm/current.h> #include <asm/uaccess.h> #include <asm/io.h> @@ -395,7 +413,7 @@ * Globals */ -Scsi_Host_Template *global_scsi_tpnt = NULL; +static Scsi_Host_Template scsi_driver_template; static u8 sbp2_speedto_maxrec[] = { 0x7, 0x8, 0x9 }; @@ -671,13 +689,13 @@ static void sbp2util_remove_command_orb_pool(struct scsi_id_instance_data *scsi_id, struct sbp2scsi_host_info *hi) { - struct list_head *lh; + struct list_head *lh, *next; struct sbp2_command_info *command; unsigned long flags; sbp2_spin_lock(&scsi_id->sbp2_command_orb_lock, flags); if (!list_empty(&scsi_id->sbp2_command_orb_completed)) { - list_for_each(lh, &scsi_id->sbp2_command_orb_completed) { + list_for_each_safe(lh, next, &scsi_id->sbp2_command_orb_completed) { command = list_entry(lh, struct sbp2_command_info, list); /* Release our generic DMA's */ @@ -868,7 +886,6 @@ hpsb_unregister_highlevel(sbp2_hl_handle); sbp2_hl_handle = NULL; } - return; } static int sbp2_probe(struct unit_directory *ud) @@ -889,8 +906,10 @@ SBP2_DEBUG("sbp2_disconnect"); hi = sbp2_find_host_info(ud->ne->host); - if (hi != NULL) - sbp2_remove_device(hi, scsi_id); + if (hi != NULL) { + sbp2_logout_device(hi, scsi_id); + sbp2_remove_device(hi, scsi_id); + } } static void sbp2_update(struct unit_directory *ud) @@ -909,12 +928,10 @@ */ if (sbp2_login_device(hi, scsi_id)) { - /* Login failed too... so, just mark him as - * unvalidated, so that he gets cleaned up - * later. - */ + /* Login failed too, just remove the device. */ SBP2_ERR("sbp2_reconnect_device failed!"); sbp2_remove_device(hi, scsi_id); + hpsb_release_unit_directory(ud); return; } } @@ -978,7 +995,10 @@ sbp2_spin_unlock(&sbp2_host_info_lock, flags); /* Register our host with the SCSI stack. */ - sbp2scsi_register_scsi_host(hi); + hi->scsi_host = scsi_register (&scsi_driver_template, sizeof(void *)); + if (hi->scsi_host) + hi->scsi_host->hostdata[0] = (unsigned long)hi; + scsi_driver_template.present++; return; } @@ -1003,13 +1023,12 @@ } /* - * This function is called when the host is removed + * This function is called when a host is removed. */ static void sbp2_remove_host(struct hpsb_host *host) { struct sbp2scsi_host_info *hi; unsigned long flags; - int i; SBP2_DEBUG("sbp2_remove_host"); @@ -1017,22 +1036,11 @@ hi = sbp2_find_host_info(host); if (hi != NULL) { - /* Here's an annoying hack: we get a disconnect - * callback for each device, so this loop shouldn't be - * necessary. However, the sbp2 driver receives the - * remove_host callback before the nodemgr, so when we - * get the disconnect callback, we've already freed - * the host. Thus, we free the devices here... - */ - for (i = 0; i < SBP2SCSI_MAX_SCSI_IDS; i++) { - if (hi->scsi_id[i] != NULL) { - sbp2_logout_device(hi, hi->scsi_id[i]); - sbp2_remove_device(hi, hi->scsi_id[i]); - } - } sbp2util_remove_request_packet_pool(hi); sbp2_host_count--; list_del(&hi->list); + scsi_unregister(hi->scsi_host); + scsi_driver_template.present--; kfree(hi); } else @@ -1203,10 +1211,7 @@ */ if (sbp2_login_device(hi, scsi_id)) { - /* - * Login failed... so, just mark him as unvalidated, so - * that he gets cleaned up later. - */ + /* Login failed, just remove the device. */ SBP2_ERR("sbp2_login_device failed"); sbp2_remove_device(hi, scsi_id); return -EBUSY; @@ -1231,11 +1236,13 @@ } /* - * This function removes (cleans-up after) any unvalidated sbp2 devices + * This function removes an sbp2 device from the sbp2scsi_host_info struct. */ static void sbp2_remove_device(struct sbp2scsi_host_info *hi, struct scsi_id_instance_data *scsi_id) { + SBP2_DEBUG("sbp2_remove_device"); + /* Complete any pending commands with selection timeout */ sbp2scsi_complete_all_commands(hi, scsi_id, DID_NO_CONNECT); @@ -1276,8 +1283,7 @@ SBP2_DMA_FREE("single logout orb"); } - SBP2_DEBUG("Unvalidated SBP-2 device removed, SCSI ID = %d", - scsi_id->id); + SBP2_DEBUG("SBP-2 device removed, SCSI ID = %d", scsi_id->id); hi->scsi_id[scsi_id->id] = NULL; kfree(scsi_id); } @@ -1381,7 +1387,7 @@ /* * Check status - */ + */ if (STATUS_GET_RESP(scsi_id->status_block.ORB_offset_hi_misc) || STATUS_GET_DEAD_BIT(scsi_id->status_block.ORB_offset_hi_misc) || STATUS_GET_SBP_STATUS(scsi_id->status_block.ORB_offset_hi_misc)) { @@ -1687,9 +1693,9 @@ scsi_id->max_payload_size = min(sbp2_speedto_maxrec[scsi_id->speed_code], (u8)(((be32_to_cpu(hi->host->csr.rom[2]) >> 12) & 0xf) - 1)); - SBP2_ERR("Node " NODE_BUS_FMT ": Max speed [%s] - Max payload [0x%02x/%u]", + SBP2_ERR("Node " NODE_BUS_FMT ": Max speed [%s] - Max payload [%u]", NODE_BUS_ARGS(scsi_id->ne->nodeid), hpsb_speedto_str[scsi_id->speed_code], - scsi_id->max_payload_size, 1 << ((u32)scsi_id->max_payload_size + 2)); + 1 << ((u32)scsi_id->max_payload_size + 2)); return(0); } @@ -2860,127 +2866,111 @@ return(0); } -/* - * This routine is called at setup (init) and does nothing. Not used here. =) - */ -void sbp2scsi_setup( char *str, int *ints) -{ - SBP2_DEBUG("sbp2scsi_setup"); - return; -} - -/* - * This is our detection routine, and is where we init everything. - */ static int sbp2scsi_detect (Scsi_Host_Template *tpnt) { SBP2_DEBUG("sbp2scsi_detect"); - global_scsi_tpnt = tpnt; + /* + * Call sbp2_init to register with the ieee1394 stack. This + * results in a callback to sbp2_add_host for each ieee1394 + * host controller currently registered, and for each of those + * we register a scsi host with the scsi stack. + */ + sbp2_init(); + + /* We return the number of hosts registered. */ + return sbp2_host_count; +} + +MODULE_AUTHOR("James Goodwin <jamesg@filanet.com>"); +MODULE_DESCRIPTION("IEEE-1394 SBP-2 protocol driver"); +MODULE_SUPPORTED_DEVICE(SBP2_DEVICE_NAME); +MODULE_LICENSE("GPL"); + +/* SCSI host template */ +static Scsi_Host_Template scsi_driver_template = { + name: "IEEE-1394 SBP-2 protocol driver", + detect: sbp2scsi_detect, + queuecommand: sbp2scsi_queuecommand, + abort: sbp2scsi_abort, + reset: sbp2scsi_reset, + bios_param: sbp2scsi_biosparam, + can_queue: SBP2SCSI_MAX_OUTSTANDING_CMDS, + this_id: -1, + sg_tablesize: SBP2_MAX_SG_ELEMENTS, + cmd_per_lun: SBP2SCSI_MAX_CMDS_PER_LUN, + use_clustering: SBP2_CLUSTERING, + emulated: 1, + + module: THIS_MODULE, + #if LINUX_VERSION_CODE > KERNEL_VERSION(2,3,26) - global_scsi_tpnt->proc_name = SBP2_DEVICE_NAME; + proc_name: SBP2_DEVICE_NAME #endif +}; + +static int sbp2_module_init(void) +{ + SBP2_DEBUG("sbp2_module_init"); + /* * Module load option for force one command at a time */ if (serialize_io) { SBP2_ERR("Driver forced to serialize I/O (serialize_io = 1)"); - global_scsi_tpnt->can_queue = 1; - global_scsi_tpnt->cmd_per_lun = 1; + scsi_driver_template.can_queue = 1; + scsi_driver_template.cmd_per_lun = 1; } /* - * Module load option to limit max size of requests from the scsi drivers + * Module load option to limit max size of requests from the + * scsi drivers */ if (no_large_packets) { - SBP2_ERR("Driver forced to limit max transfer size (no_large_packets = 1)"); - global_scsi_tpnt->sg_tablesize = 0x1f; - global_scsi_tpnt->use_clustering = DISABLE_CLUSTERING; + SBP2_ERR("Driver forced to limit max transfer size " + "(no_large_packets = 1)"); + scsi_driver_template.sg_tablesize = 0x1f; + scsi_driver_template.use_clustering = DISABLE_CLUSTERING; } if (mode_sense_hack) { SBP2_ERR("Mode sense emulation enabled (mode_sense_hack = 1)"); } - sbp2_init(); - - if (!sbp2_host_count) { - SBP2_ERR("Please load the lower level IEEE-1394 driver (e.g. ohci1394) before sbp2..."); + /* + * Ideally we would register our scsi_driver_template with the + * scsi stack and after that register with the ieee1394 stack + * and process the add_host callbacks. However, the detect + * function in the scsi host template requires that we find at + * least one host, so we "nest" the registrations by calling + * sbp2_init from the detect function. + */ + if (scsi_register_module(MODULE_SCSI_HA, &scsi_driver_template) || + !scsi_driver_template.present) { + SBP2_ERR("Please load the lower level IEEE-1394 driver " + "(e.g. ohci1394) before sbp2..."); sbp2_cleanup(); + return -ENODEV; } - /* - * Since we are returning this count, it means that sbp2 must be - * loaded "after" the host adapter module... - */ - return(sbp2_host_count); + return 0; } -/* - * This function is called from sbp2_add_host, and is where we register - * our scsi host - */ -static void sbp2scsi_register_scsi_host(struct sbp2scsi_host_info *hi) +static void __exit sbp2_module_exit(void) { - struct Scsi_Host *shpnt = NULL; - - SBP2_DEBUG("sbp2scsi_register_scsi_host"); - SBP2_DEBUG("sbp2scsi_host_info = %p", hi); + SBP2_DEBUG("sbp2_module_exit"); /* - * Let's register with the scsi stack + * On module unload we unregister with the ieee1394 stack + * which results in remove_host callbacks for all ieee1394 + * host controllers. In the callbacks we unregister the + * corresponding scsi hosts. */ - if (global_scsi_tpnt) { - - shpnt = scsi_register (global_scsi_tpnt, sizeof(void *)); - - /* - * If successful, save off a context (to be used when SCSI - * commands are received) - */ - if (shpnt) { - shpnt->hostdata[0] = (unsigned long)hi; - } - } - - return; -} - -/* Called when our module is released */ -static int sbp2scsi_release(struct Scsi_Host *host) -{ - SBP2_DEBUG("sbp2scsi_release"); sbp2_cleanup(); - return(0); -} -/* Called for contents of procfs */ -static const char *sbp2scsi_info (struct Scsi_Host *host) -{ - return "IEEE-1394 SBP-2 protocol driver"; + if (scsi_unregister_module(MODULE_SCSI_HA, &scsi_driver_template)) + SBP2_ERR("sbp2_module_exit: couldn't unregister scsi driver"); } -MODULE_AUTHOR("James Goodwin <jamesg@filanet.com>"); -MODULE_DESCRIPTION("IEEE-1394 SBP-2 protocol driver"); -MODULE_SUPPORTED_DEVICE(SBP2_DEVICE_NAME); -MODULE_LICENSE("GPL"); - -/* SCSI host template */ -static Scsi_Host_Template driver_template = { - name: "IEEE1394 SBP-2", - detect: sbp2scsi_detect, - release: sbp2scsi_release, - info: sbp2scsi_info, - queuecommand: sbp2scsi_queuecommand, - abort: sbp2scsi_abort, - reset: sbp2scsi_reset, - bios_param: sbp2scsi_biosparam, - can_queue: SBP2SCSI_MAX_OUTSTANDING_CMDS, - this_id: -1, - sg_tablesize: SBP2_MAX_SG_ELEMENTS, - cmd_per_lun: SBP2SCSI_MAX_CMDS_PER_LUN, - use_clustering: SBP2_CLUSTERING, - emulated: 1 -}; - -#include "../scsi/scsi_module.c" +module_init(sbp2_module_init); +module_exit(sbp2_module_exit); diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/ieee1394/sbp2.h linux-2.5/drivers/ieee1394/sbp2.h --- linux-2.5.1/drivers/ieee1394/sbp2.h Wed Oct 17 21:19:20 2001 +++ linux-2.5/drivers/ieee1394/sbp2.h Sat Dec 29 00:52:33 2001 @@ -403,6 +403,13 @@ spinlock_t sbp2_request_packet_lock; /* + * This is the scsi host we register with the scsi mid level. + * We keep a reference to it here, so we can unregister it + * when the hpsb_host is removed. + */ + struct Scsi_Host *scsi_host; + + /* * Lists keeping track of inuse/free sbp2_request_packets. These structures are * used for sending out sbp2 command and agent reset packets. We initially create * a pool of request packets so that we don't have to do any kmallocs while in critical @@ -498,7 +505,6 @@ /* * Scsi interface related prototypes */ -static const char *sbp2scsi_info (struct Scsi_Host *host); static int sbp2scsi_detect (Scsi_Host_Template *tpnt); void sbp2scsi_setup(char *str, int *ints); static int sbp2scsi_biosparam (Scsi_Disk *disk, kdev_t dev, int geom[]); @@ -509,6 +515,5 @@ u32 status); static void sbp2scsi_complete_command(struct sbp2scsi_host_info *hi, struct scsi_id_instance_data *scsi_id, u32 scsi_status, Scsi_Cmnd *SCpnt, void (*done)(Scsi_Cmnd *)); -static void sbp2scsi_register_scsi_host(struct sbp2scsi_host_info *hi); #endif /* SBP2_H */ diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/ieee1394/video1394.c linux-2.5/drivers/ieee1394/video1394.c --- linux-2.5.1/drivers/ieee1394/video1394.c Tue Oct 2 04:24:25 2001 +++ linux-2.5/drivers/ieee1394/video1394.c Sun Dec 30 21:17:30 2001 @@ -43,10 +43,11 @@ #include <asm/pgtable.h> #include <asm/page.h> #include <linux/sched.h> -#include <asm/segment.h> #include <linux/types.h> #include <linux/wrapper.h> #include <linux/vmalloc.h> +#include <linux/timex.h> +#include <linux/mm.h> #include "ieee1394.h" #include "ieee1394_types.h" @@ -95,6 +96,7 @@ struct dma_cmd **ir_prg; struct it_dma_prg **it_prg; unsigned int *buffer_status; + struct timeval *buffer_time; /* time when the buffer was received */ unsigned int *last_used_cmd; /* For ISO Transmit with variable sized packets only ! */ int ctrlClear; @@ -102,8 +104,8 @@ int cmdPtr; int ctxMatch; wait_queue_head_t waitq; - spinlock_t lock; - unsigned int syt_offset; + spinlock_t lock; + unsigned int syt_offset; int flags; }; @@ -304,6 +306,8 @@ if ((*d)->buffer_status) kfree((*d)->buffer_status); + if ((*d)->buffer_time) + kfree((*d)->buffer_time); if ((*d)->last_used_cmd) kfree((*d)->last_used_cmd); if ((*d)->next_buffer) @@ -437,6 +441,8 @@ d->buffer_status = kmalloc(d->num_desc * sizeof(unsigned int), GFP_KERNEL); + d->buffer_time = kmalloc(d->num_desc * sizeof(struct timeval), + GFP_KERNEL); d->last_used_cmd = kmalloc(d->num_desc * sizeof(unsigned int), GFP_KERNEL); d->next_buffer = kmalloc(d->num_desc * sizeof(int), @@ -447,6 +453,11 @@ free_dma_iso_ctx(&d); return NULL; } + if (d->buffer_time == NULL) { + PRINT(KERN_ERR, ohci->id, "Failed to allocate buffer_time"); + free_dma_iso_ctx(&d); + return NULL; + } if (d->last_used_cmd == NULL) { PRINT(KERN_ERR, ohci->id, "Failed to allocate last_used_cmd"); free_dma_iso_ctx(&d); @@ -458,6 +469,7 @@ return NULL; } memset(d->buffer_status, 0, d->num_desc * sizeof(unsigned int)); + memset(d->buffer_time, 0, d->num_desc * sizeof(struct timeval)); memset(d->last_used_cmd, 0, d->num_desc * sizeof(unsigned int)); memset(d->next_buffer, -1, d->num_desc * sizeof(int)); @@ -604,6 +616,7 @@ if (d->ir_prg[i][d->nb_cmd-1].status & 0xFFFF0000) { reset_ir_status(d, i); d->buffer_status[i] = VIDEO1394_BUFFER_READY; + get_fast_time(&d->buffer_time[i]); } } spin_unlock(&d->lock); @@ -876,9 +889,23 @@ if(copy_from_user(&v, (void *)arg, sizeof(v))) return -EFAULT; + + /* if channel < 0, find lowest available one */ + if (v.channel < 0) { + mask = (u64)0x1; + for (i=0; i<ISO_CHANNELS; i++) { + if (!(ohci->ISO_channel_usage & mask)) { + v.channel = i; + PRINT(KERN_INFO, ohci->id, "Found free channel %d\n", i); + break; + } + mask = mask << 1; + } + } + if (v.channel<0 || v.channel>(ISO_CHANNELS-1)) { PRINT(KERN_ERR, ohci->id, - "Iso channel %d out of bound", v.channel); + "Iso channel %d out of bounds", v.channel); return -EFAULT; } mask = (u64)0x1<<v.channel; @@ -1092,6 +1119,7 @@ } case VIDEO1394_LISTEN_WAIT_BUFFER: + case VIDEO1394_LISTEN_POLL_BUFFER: { struct video1394_wait v; struct dma_iso_ctx *d; @@ -1120,6 +1148,12 @@ d->buffer_status[v.buffer]=VIDEO1394_BUFFER_FREE; break; case VIDEO1394_BUFFER_QUEUED: + if (cmd == VIDEO1394_LISTEN_POLL_BUFFER) { + /* for polling, return error code EINTR */ + spin_unlock_irqrestore(&d->lock, flags); + return -EINTR; + } + #if 1 while(d->buffer_status[v.buffer]!= VIDEO1394_BUFFER_READY) { @@ -1147,6 +1181,10 @@ return -EFAULT; } + /* set time of buffer */ + v.filltime = d->buffer_time[v.buffer]; +// printk("Buffer %d time %d\n", v.buffer, (d->buffer_time[v.buffer]).tv_usec); + /* * Look ahead to see how many more buffers have been received */ @@ -1596,7 +1634,8 @@ { struct ti_ohci *ohci; unsigned long flags; - struct list_head *lh; + struct list_head *lh, *next; + struct video_card *p; /* We only work with the OHCI-1394 driver */ if (strcmp(host->template->name, OHCI1394_DRIVER_NAME)) @@ -1605,14 +1644,11 @@ ohci = (struct ti_ohci *)host->hostdata; spin_lock_irqsave(&video1394_cards_lock, flags); - if (!list_empty(&video1394_cards)) { - struct video_card *p; - list_for_each(lh, &video1394_cards) { - p = list_entry(lh, struct video_card, list); - if (p ->ohci == ohci) { - remove_card(p); - break; - } + list_for_each_safe(lh, next, &video1394_cards) { + p = list_entry(lh, struct video_card, list); + if (p->ohci == ohci) { + remove_card(p); + break; } } spin_unlock_irqrestore(&video1394_cards_lock, flags); @@ -1652,7 +1688,7 @@ devfs_unregister(devfs_handle); devfs_unregister_chrdev(VIDEO1394_MAJOR, VIDEO1394_DRIVER_NAME); - PRINT_G(KERN_INFO, "Removed " VIDEO1394_DRIVER_NAME " module\n"); + PRINT_G(KERN_INFO, "Removed " VIDEO1394_DRIVER_NAME " module"); } static int __init video1394_init_module (void) @@ -1678,6 +1714,7 @@ return -ENOMEM; } + PRINT_G(KERN_INFO, "Installed " VIDEO1394_DRIVER_NAME " module"); return 0; } diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/ieee1394/video1394.h linux-2.5/drivers/ieee1394/video1394.h --- linux-2.5.1/drivers/ieee1394/video1394.h Sun Aug 12 19:39:02 2001 +++ linux-2.5/drivers/ieee1394/video1394.h Thu Dec 13 16:32:35 2001 @@ -35,11 +35,12 @@ VIDEO1394_LISTEN_CHANNEL = 0, VIDEO1394_UNLISTEN_CHANNEL, VIDEO1394_LISTEN_QUEUE_BUFFER, - VIDEO1394_LISTEN_WAIT_BUFFER, + VIDEO1394_LISTEN_WAIT_BUFFER, // wait until buffer is ready VIDEO1394_TALK_CHANNEL, VIDEO1394_UNTALK_CHANNEL, VIDEO1394_TALK_QUEUE_BUFFER, - VIDEO1394_TALK_WAIT_BUFFER + VIDEO1394_TALK_WAIT_BUFFER, + VIDEO1394_LISTEN_POLL_BUFFER // return immediately with -EINTR if not ready }; #define VIDEO1394_SYNC_FRAMES 0x00000001 @@ -47,7 +48,7 @@ #define VIDEO1394_VARIABLE_PACKET_SIZE 0x00000004 struct video1394_mmap { - unsigned int channel; + int channel; /* -1 to find an open channel in LISTEN/TALK */ unsigned int sync_tag; unsigned int nb_buffers; unsigned int buf_size; @@ -69,6 +70,7 @@ struct video1394_wait { unsigned int channel; unsigned int buffer; + struct timeval filltime; /* time of buffer full */ }; diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/input/joydev.c linux-2.5/drivers/input/joydev.c --- linux-2.5.1/drivers/input/joydev.c Fri Nov 30 16:26:04 2001 +++ linux-2.5/drivers/input/joydev.c Sun Dec 30 21:17:30 2001 @@ -31,7 +31,6 @@ #include <asm/io.h> #include <asm/system.h> -#include <asm/segment.h> #include <linux/delay.h> #include <linux/errno.h> #include <linux/joystick.h> diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/isdn/Config.in linux-2.5/drivers/isdn/Config.in --- linux-2.5.1/drivers/isdn/Config.in Fri Nov 30 17:48:32 2001 +++ linux-2.5/drivers/isdn/Config.in Tue Dec 18 14:55:13 2001 @@ -42,6 +42,7 @@ fi bool ' HiSax Support for german 1TR6' CONFIG_HISAX_1TR6 bool ' HiSax Support for US NI1' CONFIG_HISAX_NI1 + int ' Maximum number of cards supported by HiSax' CONFIG_HISAX_MAX_CARDS 8 comment ' HiSax supported cards' bool ' Teles 16.0/8.0' CONFIG_HISAX_16_0 bool ' Teles 16.3 or PNP or PCMCIA' CONFIG_HISAX_16_3 diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/isdn/act2000/act2000.h linux-2.5/drivers/isdn/act2000/act2000.h --- linux-2.5.1/drivers/isdn/act2000/act2000.h Sun Sep 30 19:26:05 2001 +++ linux-2.5/drivers/isdn/act2000/act2000.h Sun Dec 30 21:17:30 2001 @@ -1,4 +1,4 @@ -/* $Id: act2000.h,v 1.8.6.3 2001/09/23 22:24:32 kai Exp $ +/* $Id: act2000.h,v 1.1.4.1 2001/11/20 14:19:34 kai Exp $ * * ISDN lowlevel-module for the IBM ISDN-S0 Active 2000. * @@ -68,7 +68,6 @@ #include <linux/errno.h> #include <linux/fs.h> #include <linux/major.h> -#include <asm/segment.h> #include <asm/io.h> #include <linux/kernel.h> #include <linux/signal.h> diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/isdn/act2000/act2000_isa.c linux-2.5/drivers/isdn/act2000/act2000_isa.c --- linux-2.5.1/drivers/isdn/act2000/act2000_isa.c Sun Sep 30 19:26:05 2001 +++ linux-2.5/drivers/isdn/act2000/act2000_isa.c Thu Dec 13 16:32:35 2001 @@ -1,4 +1,4 @@ -/* $Id: act2000_isa.c,v 1.11.6.3 2001/09/23 22:24:32 kai Exp $ +/* $Id: act2000_isa.c,v 1.1.4.1 2001/11/20 14:19:34 kai Exp $ * * ISDN lowlevel-module for the IBM ISDN-S0 Active 2000 (ISA-Version). * diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/isdn/act2000/act2000_isa.h linux-2.5/drivers/isdn/act2000/act2000_isa.h --- linux-2.5.1/drivers/isdn/act2000/act2000_isa.h Sun Sep 30 19:26:05 2001 +++ linux-2.5/drivers/isdn/act2000/act2000_isa.h Thu Dec 13 16:32:35 2001 @@ -1,4 +1,4 @@ -/* $Id: act2000_isa.h,v 1.4.6.1 2001/09/23 22:24:32 kai Exp $ +/* $Id: act2000_isa.h,v 1.1.4.1 2001/11/20 14:19:34 kai Exp $ * * ISDN lowlevel-module for the IBM ISDN-S0 Active 2000 (ISA-Version). * diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/isdn/act2000/capi.c linux-2.5/drivers/isdn/act2000/capi.c --- linux-2.5.1/drivers/isdn/act2000/capi.c Sun Sep 30 19:26:05 2001 +++ linux-2.5/drivers/isdn/act2000/capi.c Thu Dec 13 16:32:35 2001 @@ -1,4 +1,4 @@ -/* $Id: capi.c,v 1.9.6.2 2001/09/23 22:24:32 kai Exp $ +/* $Id: capi.c,v 1.1.4.1 2001/11/20 14:19:34 kai Exp $ * * ISDN lowlevel-module for the IBM ISDN-S0 Active 2000. * CAPI encoder/decoder diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/isdn/act2000/capi.h linux-2.5/drivers/isdn/act2000/capi.h --- linux-2.5.1/drivers/isdn/act2000/capi.h Sun Sep 30 19:26:05 2001 +++ linux-2.5/drivers/isdn/act2000/capi.h Thu Dec 13 16:32:35 2001 @@ -1,4 +1,4 @@ -/* $Id: capi.h,v 1.6.6.2 2001/09/23 22:24:32 kai Exp $ +/* $Id: capi.h,v 1.1.4.1 2001/11/20 14:19:34 kai Exp $ * * ISDN lowlevel-module for the IBM ISDN-S0 Active 2000. * diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/isdn/act2000/module.c linux-2.5/drivers/isdn/act2000/module.c --- linux-2.5.1/drivers/isdn/act2000/module.c Sun Sep 30 19:26:05 2001 +++ linux-2.5/drivers/isdn/act2000/module.c Thu Dec 13 16:32:35 2001 @@ -1,4 +1,4 @@ -/* $Id: module.c,v 1.14.6.4 2001/09/23 22:24:32 kai Exp $ +/* $Id: module.c,v 1.1.4.1 2001/11/20 14:19:34 kai Exp $ * * ISDN lowlevel-module for the IBM ISDN-S0 Active 2000. * diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/isdn/avmb1/avm_cs.c linux-2.5/drivers/isdn/avmb1/avm_cs.c --- linux-2.5.1/drivers/isdn/avmb1/avm_cs.c Sun Sep 30 19:26:05 2001 +++ linux-2.5/drivers/isdn/avmb1/avm_cs.c Thu Dec 13 16:32:35 2001 @@ -1,4 +1,4 @@ -/* $Id: avm_cs.c,v 1.4.6.3 2001/09/23 22:24:33 kai Exp $ +/* $Id: avm_cs.c,v 1.1.4.1 2001/11/20 14:19:34 kai Exp $ * * A PCMCIA client driver for AVM B1/M1/M2 * diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/isdn/avmb1/avmcard.h linux-2.5/drivers/isdn/avmb1/avmcard.h --- linux-2.5.1/drivers/isdn/avmb1/avmcard.h Sun Sep 30 19:26:05 2001 +++ linux-2.5/drivers/isdn/avmb1/avmcard.h Thu Dec 13 16:32:35 2001 @@ -1,4 +1,4 @@ -/* $Id: avmcard.h,v 1.8.6.4 2001/09/23 22:24:33 kai Exp $ +/* $Id: avmcard.h,v 1.1.4.1 2001/11/20 14:19:34 kai Exp $ * * Copyright 1999 by Carsten Paeth <calle@calle.de> * diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/isdn/avmb1/b1.c linux-2.5/drivers/isdn/avmb1/b1.c --- linux-2.5.1/drivers/isdn/avmb1/b1.c Sun Sep 30 19:26:05 2001 +++ linux-2.5/drivers/isdn/avmb1/b1.c Thu Dec 13 16:32:35 2001 @@ -1,4 +1,4 @@ -/* $Id: b1.c,v 1.20.6.7 2001/09/23 22:24:33 kai Exp $ +/* $Id: b1.c,v 1.1.4.1 2001/11/20 14:19:34 kai Exp $ * * Common module for AVM B1 cards. * @@ -27,7 +27,7 @@ #include "capicmd.h" #include "capiutil.h" -static char *revision = "$Revision: 1.20.6.7 $"; +static char *revision = "$Revision: 1.1.4.1 $"; /* ------------------------------------------------------------- */ diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/isdn/avmb1/b1dma.c linux-2.5/drivers/isdn/avmb1/b1dma.c --- linux-2.5.1/drivers/isdn/avmb1/b1dma.c Sun Sep 30 19:26:05 2001 +++ linux-2.5/drivers/isdn/avmb1/b1dma.c Thu Dec 13 16:32:35 2001 @@ -1,4 +1,4 @@ -/* $Id: b1dma.c,v 1.11.6.8 2001/09/23 22:24:33 kai Exp $ +/* $Id: b1dma.c,v 1.1.4.1 2001/11/20 14:19:34 kai Exp $ * * Common module for AVM B1 cards that support dma with AMCC * @@ -32,7 +32,7 @@ #error FIXME: driver requires 32-bit platform #endif -static char *revision = "$Revision: 1.11.6.8 $"; +static char *revision = "$Revision: 1.1.4.1 $"; /* ------------------------------------------------------------- */ diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/isdn/avmb1/b1isa.c linux-2.5/drivers/isdn/avmb1/b1isa.c --- linux-2.5.1/drivers/isdn/avmb1/b1isa.c Sun Sep 30 19:26:05 2001 +++ linux-2.5/drivers/isdn/avmb1/b1isa.c Thu Dec 13 16:32:35 2001 @@ -1,4 +1,4 @@ -/* $Id: b1isa.c,v 1.10.6.6 2001/09/23 22:24:33 kai Exp $ +/* $Id: b1isa.c,v 1.1.4.1 2001/11/20 14:19:34 kai Exp $ * * Module for AVM B1 ISA-card. * @@ -24,7 +24,7 @@ #include "capilli.h" #include "avmcard.h" -static char *revision = "$Revision: 1.10.6.6 $"; +static char *revision = "$Revision: 1.1.4.1 $"; /* ------------------------------------------------------------- */ diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/isdn/avmb1/b1pci.c linux-2.5/drivers/isdn/avmb1/b1pci.c --- linux-2.5.1/drivers/isdn/avmb1/b1pci.c Sun Sep 30 19:26:05 2001 +++ linux-2.5/drivers/isdn/avmb1/b1pci.c Thu Dec 13 16:32:35 2001 @@ -1,4 +1,4 @@ -/* $Id: b1pci.c,v 1.29.6.5 2001/09/23 22:24:33 kai Exp $ +/* $Id: b1pci.c,v 1.1.4.1 2001/11/20 14:19:34 kai Exp $ * * Module for AVM B1 PCI-card. * @@ -26,7 +26,7 @@ #include "capilli.h" #include "avmcard.h" -static char *revision = "$Revision: 1.29.6.5 $"; +static char *revision = "$Revision: 1.1.4.1 $"; /* ------------------------------------------------------------- */ diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/isdn/avmb1/b1pcmcia.c linux-2.5/drivers/isdn/avmb1/b1pcmcia.c --- linux-2.5.1/drivers/isdn/avmb1/b1pcmcia.c Sun Sep 30 19:26:05 2001 +++ linux-2.5/drivers/isdn/avmb1/b1pcmcia.c Thu Dec 13 16:32:35 2001 @@ -1,4 +1,4 @@ -/* $Id: b1pcmcia.c,v 1.12.6.5 2001/09/23 22:24:33 kai Exp $ +/* $Id: b1pcmcia.c,v 1.1.4.1 2001/11/20 14:19:34 kai Exp $ * * Module for AVM B1/M1/M2 PCMCIA-card. * @@ -25,7 +25,7 @@ #include "capilli.h" #include "avmcard.h" -static char *revision = "$Revision: 1.12.6.5 $"; +static char *revision = "$Revision: 1.1.4.1 $"; /* ------------------------------------------------------------- */ diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/isdn/avmb1/c4.c linux-2.5/drivers/isdn/avmb1/c4.c --- linux-2.5.1/drivers/isdn/avmb1/c4.c Sun Sep 30 19:26:05 2001 +++ linux-2.5/drivers/isdn/avmb1/c4.c Thu Dec 13 16:32:35 2001 @@ -1,4 +1,4 @@ -/* $Id: c4.c,v 1.20.6.11 2001/09/23 22:24:33 kai Exp $ +/* $Id: c4.c,v 1.1.4.1 2001/11/20 14:19:34 kai Exp $ * * Module for AVM C4 & C2 card. * @@ -29,7 +29,7 @@ #include "capilli.h" #include "avmcard.h" -static char *revision = "$Revision: 1.20.6.11 $"; +static char *revision = "$Revision: 1.1.4.1 $"; #undef CONFIG_C4_DEBUG #undef CONFIG_C4_POLLDEBUG diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/isdn/avmb1/capi.c linux-2.5/drivers/isdn/avmb1/capi.c --- linux-2.5.1/drivers/isdn/avmb1/capi.c Thu Dec 6 22:01:17 2001 +++ linux-2.5/drivers/isdn/avmb1/capi.c Thu Dec 13 16:32:35 2001 @@ -1,4 +1,4 @@ -/* $Id: capi.c,v 1.44.6.15 2001/09/28 08:05:29 kai Exp $ +/* $Id: capi.c,v 1.1.4.2 2001/12/09 18:45:13 kai Exp $ * * CAPI 2.0 Interface for Linux * @@ -45,7 +45,7 @@ #include "capifs.h" #endif -static char *revision = "$Revision: 1.44.6.15 $"; +static char *revision = "$Revision: 1.1.4.2 $"; MODULE_DESCRIPTION("CAPI4Linux: Userspace /dev/capi20 interface"); MODULE_AUTHOR("Carsten Paeth"); diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/isdn/avmb1/capicmd.h linux-2.5/drivers/isdn/avmb1/capicmd.h --- linux-2.5.1/drivers/isdn/avmb1/capicmd.h Sun Sep 30 19:26:05 2001 +++ linux-2.5/drivers/isdn/avmb1/capicmd.h Thu Dec 13 16:32:35 2001 @@ -1,4 +1,4 @@ -/* $Id: capicmd.h,v 1.2.6.2 2001/09/23 22:24:33 kai Exp $ +/* $Id: capicmd.h,v 1.1.4.1 2001/11/20 14:19:34 kai Exp $ * * CAPI 2.0 Interface for Linux * diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/isdn/avmb1/capidev.h linux-2.5/drivers/isdn/avmb1/capidev.h --- linux-2.5.1/drivers/isdn/avmb1/capidev.h Sun Sep 30 19:26:05 2001 +++ linux-2.5/drivers/isdn/avmb1/capidev.h Thu Dec 13 16:32:35 2001 @@ -1,4 +1,4 @@ -/* $Id: capidev.h,v 1.6.6.2 2001/09/23 22:24:33 kai Exp $ +/* $Id: capidev.h,v 1.1.4.1 2001/11/20 14:19:34 kai Exp $ * * CAPI 2.0 Interface for Linux * diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/isdn/avmb1/capidrv.c linux-2.5/drivers/isdn/avmb1/capidrv.c --- linux-2.5.1/drivers/isdn/avmb1/capidrv.c Sun Sep 30 19:26:05 2001 +++ linux-2.5/drivers/isdn/avmb1/capidrv.c Sun Dec 30 21:17:30 2001 @@ -1,4 +1,4 @@ -/* $Id: capidrv.c,v 1.39.6.7 2001/09/23 22:24:33 kai Exp $ +/* $Id: capidrv.c,v 1.1.4.1 2001/11/20 14:19:34 kai Exp $ * * ISDN4Linux Driver, using capi20 interface (kernelcapi) * @@ -29,13 +29,12 @@ #include <linux/kernelcapi.h> #include <linux/ctype.h> #include <linux/init.h> -#include <asm/segment.h> #include "capiutil.h" #include "capicmd.h" #include "capidrv.h" -static char *revision = "$Revision: 1.39.6.7 $"; +static char *revision = "$Revision: 1.1.4.1 $"; static int debugmode = 0; MODULE_DESCRIPTION("CAPI4Linux: Interface to ISDN4Linux"); diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/isdn/avmb1/capidrv.h linux-2.5/drivers/isdn/avmb1/capidrv.h --- linux-2.5.1/drivers/isdn/avmb1/capidrv.h Sun Sep 30 19:26:05 2001 +++ linux-2.5/drivers/isdn/avmb1/capidrv.h Thu Dec 13 16:32:35 2001 @@ -1,4 +1,4 @@ -/* $Id: capidrv.h,v 1.2.8.2 2001/09/23 22:24:33 kai Exp $ +/* $Id: capidrv.h,v 1.1.4.1 2001/11/20 14:19:34 kai Exp $ * * ISDN4Linux Driver, using capi20 interface (kernelcapi) * diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/isdn/avmb1/capifs.c linux-2.5/drivers/isdn/avmb1/capifs.c --- linux-2.5.1/drivers/isdn/avmb1/capifs.c Sun Sep 30 19:26:05 2001 +++ linux-2.5/drivers/isdn/avmb1/capifs.c Thu Dec 13 16:32:35 2001 @@ -1,4 +1,4 @@ -/* $Id: capifs.c,v 1.14.6.8 2001/09/23 22:24:33 kai Exp $ +/* $Id: capifs.c,v 1.1.4.1 2001/11/20 14:19:34 kai Exp $ * * Copyright 2000 by Carsten Paeth <calle@calle.de> * @@ -32,7 +32,7 @@ MODULE_AUTHOR("Carsten Paeth"); MODULE_LICENSE("GPL"); -static char *revision = "$Revision: 1.14.6.8 $"; +static char *revision = "$Revision: 1.1.4.1 $"; struct capifs_ncci { struct inode *inode; diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/isdn/avmb1/capifs.h linux-2.5/drivers/isdn/avmb1/capifs.h --- linux-2.5.1/drivers/isdn/avmb1/capifs.h Sun Sep 30 19:26:05 2001 +++ linux-2.5/drivers/isdn/avmb1/capifs.h Thu Dec 13 16:32:35 2001 @@ -1,4 +1,4 @@ -/* $Id: capifs.h,v 1.2.6.2 2001/09/23 22:24:33 kai Exp $ +/* $Id: capifs.h,v 1.1.4.1 2001/11/20 14:19:34 kai Exp $ * * Copyright 2000 by Carsten Paeth <calle@calle.de> * diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/isdn/avmb1/capilli.h linux-2.5/drivers/isdn/avmb1/capilli.h --- linux-2.5.1/drivers/isdn/avmb1/capilli.h Sun Sep 30 19:26:05 2001 +++ linux-2.5/drivers/isdn/avmb1/capilli.h Thu Dec 13 16:32:35 2001 @@ -1,4 +1,4 @@ -/* $Id: capilli.h,v 1.4.8.1 2001/09/23 22:24:33 kai Exp $ +/* $Id: capilli.h,v 1.1.4.1 2001/11/20 14:19:34 kai Exp $ * * Kernel CAPI 2.0 Driver Interface for Linux * diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/isdn/avmb1/capiutil.c linux-2.5/drivers/isdn/avmb1/capiutil.c --- linux-2.5.1/drivers/isdn/avmb1/capiutil.c Sun Sep 30 19:26:05 2001 +++ linux-2.5/drivers/isdn/avmb1/capiutil.c Sun Dec 30 21:17:30 2001 @@ -1,4 +1,4 @@ -/* $Id: capiutil.c,v 1.13.6.4 2001/09/23 22:24:33 kai Exp $ +/* $Id: capiutil.c,v 1.1.4.1 2001/11/20 14:19:34 kai Exp $ * * CAPI 2.0 convert capi message to capi message struct * @@ -17,7 +17,6 @@ #include <linux/kernel.h> #include <linux/mm.h> #include <linux/init.h> -#include <asm/segment.h> #include <linux/config.h> #include "capiutil.h" diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/isdn/avmb1/capiutil.h linux-2.5/drivers/isdn/avmb1/capiutil.h --- linux-2.5.1/drivers/isdn/avmb1/capiutil.h Sun Sep 30 19:26:05 2001 +++ linux-2.5/drivers/isdn/avmb1/capiutil.h Thu Dec 13 16:32:35 2001 @@ -1,4 +1,4 @@ -/* $Id: capiutil.h,v 1.5.6.2 2001/09/23 22:24:33 kai Exp $ +/* $Id: capiutil.h,v 1.1.4.1 2001/11/20 14:19:34 kai Exp $ * * CAPI 2.0 defines & types * diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/isdn/avmb1/kcapi.c linux-2.5/drivers/isdn/avmb1/kcapi.c --- linux-2.5.1/drivers/isdn/avmb1/kcapi.c Sun Sep 30 19:26:05 2001 +++ linux-2.5/drivers/isdn/avmb1/kcapi.c Sun Dec 30 21:17:30 2001 @@ -1,4 +1,4 @@ -/* $Id: kcapi.c,v 1.21.6.8 2001/09/23 22:24:33 kai Exp $ +/* $Id: kcapi.c,v 1.1.4.1 2001/11/20 14:19:34 kai Exp $ * * Kernel CAPI 2.0 Module * @@ -17,7 +17,6 @@ #include <linux/mm.h> #include <linux/interrupt.h> #include <linux/ioport.h> -#include <asm/segment.h> #include <linux/proc_fs.h> #include <linux/skbuff.h> #include <linux/tqueue.h> @@ -33,7 +32,7 @@ #include <linux/b1lli.h> #endif -static char *revision = "$Revision: 1.21.6.8 $"; +static char *revision = "$Revision: 1.1.4.1 $"; /* ------------------------------------------------------------- */ diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/isdn/avmb1/t1isa.c linux-2.5/drivers/isdn/avmb1/t1isa.c --- linux-2.5.1/drivers/isdn/avmb1/t1isa.c Sun Sep 30 19:26:05 2001 +++ linux-2.5/drivers/isdn/avmb1/t1isa.c Thu Dec 13 16:32:35 2001 @@ -1,4 +1,4 @@ -/* $Id: t1isa.c,v 1.16.6.7 2001/09/23 22:24:34 kai Exp $ +/* $Id: t1isa.c,v 1.1.4.1 2001/11/20 14:19:34 kai Exp $ * * Module for AVM T1 HEMA-card. * @@ -25,7 +25,7 @@ #include "capilli.h" #include "avmcard.h" -static char *revision = "$Revision: 1.16.6.7 $"; +static char *revision = "$Revision: 1.1.4.1 $"; /* ------------------------------------------------------------- */ diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/isdn/avmb1/t1pci.c linux-2.5/drivers/isdn/avmb1/t1pci.c --- linux-2.5.1/drivers/isdn/avmb1/t1pci.c Sun Sep 30 19:26:05 2001 +++ linux-2.5/drivers/isdn/avmb1/t1pci.c Thu Dec 13 16:32:35 2001 @@ -1,4 +1,4 @@ -/* $Id: t1pci.c,v 1.13.6.6 2001/09/23 22:24:34 kai Exp $ +/* $Id: t1pci.c,v 1.1.4.1 2001/11/20 14:19:34 kai Exp $ * * Module for AVM T1 PCI-card. * @@ -26,7 +26,7 @@ #include "capilli.h" #include "avmcard.h" -static char *revision = "$Revision: 1.13.6.6 $"; +static char *revision = "$Revision: 1.1.4.1 $"; #undef CONFIG_T1PCI_DEBUG #undef CONFIG_T1PCI_POLLDEBUG diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/isdn/divert/divert_procfs.c linux-2.5/drivers/isdn/divert/divert_procfs.c --- linux-2.5.1/drivers/isdn/divert/divert_procfs.c Thu Dec 6 22:01:17 2001 +++ linux-2.5/drivers/isdn/divert/divert_procfs.c Thu Dec 13 16:32:35 2001 @@ -1,4 +1,4 @@ -/* $Id: divert_procfs.c,v 1.11.6.2 2001/09/23 22:24:36 kai Exp $ +/* $Id: divert_procfs.c,v 1.1.4.1 2001/11/20 14:19:35 kai Exp $ * * Filesystem handling for the diversion supplementary services. * diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/isdn/divert/isdn_divert.c linux-2.5/drivers/isdn/divert/isdn_divert.c --- linux-2.5.1/drivers/isdn/divert/isdn_divert.c Sun Sep 30 19:26:05 2001 +++ linux-2.5/drivers/isdn/divert/isdn_divert.c Thu Dec 13 16:32:35 2001 @@ -1,4 +1,4 @@ -/* $Id: isdn_divert.c,v 1.6.6.3 2001/09/23 22:24:36 kai Exp $ +/* $Id: isdn_divert.c,v 1.1.4.1 2001/11/20 14:19:35 kai Exp $ * * DSS1 main diversion supplementary handling for i4l. * diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/isdn/divert/isdn_divert.h linux-2.5/drivers/isdn/divert/isdn_divert.h --- linux-2.5.1/drivers/isdn/divert/isdn_divert.h Sun Sep 30 19:26:05 2001 +++ linux-2.5/drivers/isdn/divert/isdn_divert.h Thu Dec 13 16:32:35 2001 @@ -1,4 +1,4 @@ -/* $Id: isdn_divert.h,v 1.5.6.1 2001/09/23 22:24:36 kai Exp $ +/* $Id: isdn_divert.h,v 1.1.4.1 2001/11/20 14:19:35 kai Exp $ * * Header for the diversion supplementary ioctl interface. * diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/isdn/eicon/eicon.h linux-2.5/drivers/isdn/eicon/eicon.h --- linux-2.5.1/drivers/isdn/eicon/eicon.h Sun Sep 30 19:26:05 2001 +++ linux-2.5/drivers/isdn/eicon/eicon.h Sun Dec 30 21:17:30 2001 @@ -1,4 +1,4 @@ -/* $Id: eicon.h,v 1.23.6.5 2001/09/23 22:24:37 kai Exp $ +/* $Id: eicon.h,v 1.1.4.1 2001/11/20 14:19:35 kai Exp $ * * ISDN low-level module for Eicon active ISDN-Cards. * @@ -123,7 +123,6 @@ #include <linux/errno.h> #include <linux/fs.h> #include <linux/major.h> -#include <asm/segment.h> #include <asm/io.h> #include <linux/kernel.h> #include <linux/signal.h> diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/isdn/eicon/eicon_dsp.h linux-2.5/drivers/isdn/eicon/eicon_dsp.h --- linux-2.5.1/drivers/isdn/eicon/eicon_dsp.h Sun Sep 30 19:26:05 2001 +++ linux-2.5/drivers/isdn/eicon/eicon_dsp.h Thu Dec 13 16:32:35 2001 @@ -1,4 +1,4 @@ -/* $Id: eicon_dsp.h,v 1.7.6.1 2001/09/23 22:24:37 kai Exp $ +/* $Id: eicon_dsp.h,v 1.1.4.1 2001/11/20 14:19:35 kai Exp $ * * ISDN lowlevel-module for Eicon active cards. * DSP definitions diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/isdn/eicon/eicon_idi.c linux-2.5/drivers/isdn/eicon/eicon_idi.c --- linux-2.5.1/drivers/isdn/eicon/eicon_idi.c Fri Nov 9 21:41:41 2001 +++ linux-2.5/drivers/isdn/eicon/eicon_idi.c Thu Dec 13 16:32:35 2001 @@ -1,4 +1,4 @@ -/* $Id: eicon_idi.c,v 1.41.6.4 2001/11/06 20:58:29 kai Exp $ +/* $Id: eicon_idi.c,v 1.1.4.1 2001/11/20 14:19:35 kai Exp $ * * ISDN lowlevel-module for Eicon active cards. * IDI interface @@ -25,7 +25,7 @@ #undef EICON_FULL_SERVICE_OKTETT -char *eicon_idi_revision = "$Revision: 1.41.6.4 $"; +char *eicon_idi_revision = "$Revision: 1.1.4.1 $"; eicon_manifbuf *manbuf; diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/isdn/eicon/eicon_idi.h linux-2.5/drivers/isdn/eicon/eicon_idi.h --- linux-2.5.1/drivers/isdn/eicon/eicon_idi.h Sun Sep 30 19:26:05 2001 +++ linux-2.5/drivers/isdn/eicon/eicon_idi.h Thu Dec 13 16:32:35 2001 @@ -1,4 +1,4 @@ -/* $Id: eicon_idi.h,v 1.11.6.1 2001/09/23 22:24:37 kai Exp $ +/* $Id: eicon_idi.h,v 1.1.4.1 2001/11/20 14:19:35 kai Exp $ * * ISDN lowlevel-module for the Eicon active cards. * IDI-Interface diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/isdn/eicon/eicon_io.c linux-2.5/drivers/isdn/eicon/eicon_io.c --- linux-2.5.1/drivers/isdn/eicon/eicon_io.c Sun Sep 30 19:26:05 2001 +++ linux-2.5/drivers/isdn/eicon/eicon_io.c Thu Dec 13 16:32:35 2001 @@ -1,4 +1,4 @@ -/* $Id: eicon_io.c,v 1.13.6.2 2001/09/23 22:24:37 kai Exp $ +/* $Id: eicon_io.c,v 1.1.4.1 2001/11/20 14:19:35 kai Exp $ * * ISDN low-level module for Eicon active ISDN-Cards. * Code for communicating with hardware. diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/isdn/eicon/eicon_isa.c linux-2.5/drivers/isdn/eicon/eicon_isa.c --- linux-2.5.1/drivers/isdn/eicon/eicon_isa.c Fri Nov 9 21:41:41 2001 +++ linux-2.5/drivers/isdn/eicon/eicon_isa.c Thu Dec 13 16:32:35 2001 @@ -1,4 +1,4 @@ -/* $Id: eicon_isa.c,v 1.16.6.2 2001/11/06 20:58:29 kai Exp $ +/* $Id: eicon_isa.c,v 1.1.4.1 2001/11/20 14:19:35 kai Exp $ * * ISDN low-level module for Eicon active ISDN-Cards. * Hardware-specific code for old ISA cards. @@ -20,7 +20,7 @@ #define release_shmem release_region #define request_shmem request_region -char *eicon_isa_revision = "$Revision: 1.16.6.2 $"; +char *eicon_isa_revision = "$Revision: 1.1.4.1 $"; #undef EICON_MCA_DEBUG diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/isdn/eicon/eicon_isa.h linux-2.5/drivers/isdn/eicon/eicon_isa.h --- linux-2.5.1/drivers/isdn/eicon/eicon_isa.h Sun Sep 30 19:26:05 2001 +++ linux-2.5/drivers/isdn/eicon/eicon_isa.h Thu Dec 13 16:32:35 2001 @@ -1,4 +1,4 @@ -/* $Id: eicon_isa.h,v 1.10.6.1 2001/09/23 22:24:37 kai Exp $ +/* $Id: eicon_isa.h,v 1.1.4.1 2001/11/20 14:19:35 kai Exp $ * * ISDN low-level module for Eicon active ISDN-Cards. * diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/isdn/eicon/eicon_pci.c linux-2.5/drivers/isdn/eicon/eicon_pci.c --- linux-2.5.1/drivers/isdn/eicon/eicon_pci.c Sun Sep 30 19:26:05 2001 +++ linux-2.5/drivers/isdn/eicon/eicon_pci.c Thu Dec 13 16:32:35 2001 @@ -1,4 +1,4 @@ -/* $Id: eicon_pci.c,v 1.15.6.3 2001/09/23 22:24:37 kai Exp $ +/* $Id: eicon_pci.c,v 1.1.4.1 2001/11/20 14:19:35 kai Exp $ * * ISDN low-level module for Eicon active ISDN-Cards. * Hardware-specific code for PCI cards. @@ -24,7 +24,7 @@ #include "adapter.h" #include "uxio.h" -char *eicon_pci_revision = "$Revision: 1.15.6.3 $"; +char *eicon_pci_revision = "$Revision: 1.1.4.1 $"; #if CONFIG_PCI /* intire stuff is only for PCI */ #ifdef CONFIG_ISDN_DRV_EICON_PCI diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/isdn/eicon/eicon_pci.h linux-2.5/drivers/isdn/eicon/eicon_pci.h --- linux-2.5.1/drivers/isdn/eicon/eicon_pci.h Sun Sep 30 19:26:05 2001 +++ linux-2.5/drivers/isdn/eicon/eicon_pci.h Thu Dec 13 16:32:35 2001 @@ -1,4 +1,4 @@ -/* $Id: eicon_pci.h,v 1.6.6.1 2001/09/23 22:24:37 kai Exp $ +/* $Id: eicon_pci.h,v 1.1.4.1 2001/11/20 14:19:35 kai Exp $ * * ISDN low-level module for Eicon active ISDN-Cards (PCI part). * diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/isdn/eicon/lincfg.c linux-2.5/drivers/isdn/eicon/lincfg.c --- linux-2.5.1/drivers/isdn/eicon/lincfg.c Sun Sep 30 19:26:05 2001 +++ linux-2.5/drivers/isdn/eicon/lincfg.c Sun Dec 30 21:17:30 2001 @@ -11,7 +11,6 @@ #include <linux/fs.h> #undef N_DATA /* Because we have our own definition */ -#include <asm/segment.h> #include <asm/io.h> #include "sys.h" diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/isdn/hisax/Makefile linux-2.5/drivers/isdn/hisax/Makefile --- linux-2.5.1/drivers/isdn/hisax/Makefile Fri Nov 30 17:48:32 2001 +++ linux-2.5/drivers/isdn/hisax/Makefile Tue Dec 18 14:56:45 2001 @@ -4,6 +4,10 @@ O_TARGET := vmlinux-obj.o +# Define maximum number of cards + +EXTRA_CFLAGS += -DHISAX_MAX_CARDS=$(CONFIG_HISAX_MAX_CARDS) + # Objects that export symbols. export-objs := config.o fsm.o hisax_isac.o diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/isdn/hisax/amd7930.c linux-2.5/drivers/isdn/hisax/amd7930.c --- linux-2.5.1/drivers/isdn/hisax/amd7930.c Sun Sep 30 19:26:05 2001 +++ linux-2.5/drivers/isdn/hisax/amd7930.c Thu Dec 13 16:32:35 2001 @@ -1,4 +1,4 @@ -/* $Id: amd7930.c,v 1.5.6.4 2001/09/23 22:24:46 kai Exp $ +/* $Id: amd7930.c,v 1.1.4.1 2001/11/20 14:19:35 kai Exp $ * * HiSax ISDN driver - chip specific routines for AMD 7930 * @@ -98,7 +98,7 @@ #include "rawhdlc.h" #include <linux/interrupt.h> -static const char *amd7930_revision = "$Revision: 1.5.6.4 $"; +static const char *amd7930_revision = "$Revision: 1.1.4.1 $"; #define RCV_BUFSIZE 1024 /* Size of raw receive buffer in bytes */ #define RCV_BUFBLKS 4 /* Number of blocks to divide buffer into diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/isdn/hisax/arcofi.c linux-2.5/drivers/isdn/hisax/arcofi.c --- linux-2.5.1/drivers/isdn/hisax/arcofi.c Sun Sep 30 19:26:05 2001 +++ linux-2.5/drivers/isdn/hisax/arcofi.c Thu Dec 13 16:32:35 2001 @@ -1,4 +1,4 @@ -/* $Id: arcofi.c,v 1.12.6.2 2001/09/23 22:24:46 kai Exp $ +/* $Id: arcofi.c,v 1.1.4.1 2001/11/20 14:19:35 kai Exp $ * * Ansteuerung ARCOFI 2165 * diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/isdn/hisax/arcofi.h linux-2.5/drivers/isdn/hisax/arcofi.h --- linux-2.5.1/drivers/isdn/hisax/arcofi.h Sun Sep 30 19:26:05 2001 +++ linux-2.5/drivers/isdn/hisax/arcofi.h Thu Dec 13 16:32:35 2001 @@ -1,4 +1,4 @@ -/* $Id: arcofi.h,v 1.6.6.2 2001/09/23 22:24:46 kai Exp $ +/* $Id: arcofi.h,v 1.1.4.1 2001/11/20 14:19:35 kai Exp $ * * Ansteuerung ARCOFI 2165 * diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/isdn/hisax/asuscom.c linux-2.5/drivers/isdn/hisax/asuscom.c --- linux-2.5.1/drivers/isdn/hisax/asuscom.c Sun Sep 30 19:26:05 2001 +++ linux-2.5/drivers/isdn/hisax/asuscom.c Thu Dec 13 16:32:35 2001 @@ -1,4 +1,4 @@ -/* $Id: asuscom.c,v 1.11.6.3 2001/09/23 22:24:46 kai Exp $ +/* $Id: asuscom.c,v 1.1.4.1 2001/11/20 14:19:35 kai Exp $ * * low level stuff for ASUSCOM NETWORK INC. ISDNLink cards * @@ -22,7 +22,7 @@ extern const char *CardType[]; -const char *Asuscom_revision = "$Revision: 1.11.6.3 $"; +const char *Asuscom_revision = "$Revision: 1.1.4.1 $"; #define byteout(addr,val) outb(val,addr) #define bytein(addr) inb(addr) diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/isdn/hisax/avm_a1.c linux-2.5/drivers/isdn/hisax/avm_a1.c --- linux-2.5.1/drivers/isdn/hisax/avm_a1.c Sun Sep 30 19:26:05 2001 +++ linux-2.5/drivers/isdn/hisax/avm_a1.c Thu Dec 13 16:32:35 2001 @@ -1,4 +1,4 @@ -/* $Id: avm_a1.c,v 2.13.6.2 2001/09/23 22:24:46 kai Exp $ +/* $Id: avm_a1.c,v 1.1.4.1 2001/11/20 14:19:35 kai Exp $ * * low level stuff for AVM A1 (Fritz) isdn cards * @@ -18,7 +18,7 @@ #include "isdnl1.h" extern const char *CardType[]; -static const char *avm_revision = "$Revision: 2.13.6.2 $"; +static const char *avm_revision = "$Revision: 1.1.4.1 $"; #define AVM_A1_STAT_ISAC 0x01 #define AVM_A1_STAT_HSCX 0x02 diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/isdn/hisax/avm_a1p.c linux-2.5/drivers/isdn/hisax/avm_a1p.c --- linux-2.5.1/drivers/isdn/hisax/avm_a1p.c Sun Sep 30 19:26:05 2001 +++ linux-2.5/drivers/isdn/hisax/avm_a1p.c Thu Dec 13 16:32:35 2001 @@ -1,4 +1,4 @@ -/* $Id: avm_a1p.c,v 2.7.6.2 2001/09/23 22:24:46 kai Exp $ +/* $Id: avm_a1p.c,v 1.1.4.1 2001/11/20 14:19:35 kai Exp $ * * low level stuff for the following AVM cards: * A1 PCMCIA @@ -57,7 +57,7 @@ #define byteout(addr,val) outb(val,addr) #define bytein(addr) inb(addr) -static const char *avm_revision = "$Revision: 2.7.6.2 $"; +static const char *avm_revision = "$Revision: 1.1.4.1 $"; static inline u_char ReadISAC(struct IsdnCardState *cs, u_char offset) diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/isdn/hisax/avm_pci.c linux-2.5/drivers/isdn/hisax/avm_pci.c --- linux-2.5.1/drivers/isdn/hisax/avm_pci.c Sun Sep 30 19:26:05 2001 +++ linux-2.5/drivers/isdn/hisax/avm_pci.c Thu Dec 13 16:32:35 2001 @@ -1,4 +1,4 @@ -/* $Id: avm_pci.c,v 1.22.6.6 2001/09/23 22:24:46 kai Exp $ +/* $Id: avm_pci.c,v 1.1.4.1 2001/11/20 14:19:35 kai Exp $ * * low level stuff for AVM Fritz!PCI and ISA PnP isdn cards * @@ -22,7 +22,7 @@ #include <linux/interrupt.h> extern const char *CardType[]; -static const char *avm_pci_rev = "$Revision: 1.22.6.6 $"; +static const char *avm_pci_rev = "$Revision: 1.1.4.1 $"; #define AVM_FRITZ_PCI 1 #define AVM_FRITZ_PNP 2 diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/isdn/hisax/bkm_a4t.c linux-2.5/drivers/isdn/hisax/bkm_a4t.c --- linux-2.5.1/drivers/isdn/hisax/bkm_a4t.c Sun Sep 30 19:26:05 2001 +++ linux-2.5/drivers/isdn/hisax/bkm_a4t.c Thu Dec 13 16:32:35 2001 @@ -1,4 +1,4 @@ -/* $Id: bkm_a4t.c,v 1.13.6.6 2001/09/23 22:24:46 kai Exp $ +/* $Id: bkm_a4t.c,v 1.1.4.1 2001/11/20 14:19:35 kai Exp $ * * low level stuff for T-Berkom A4T * @@ -24,7 +24,7 @@ extern const char *CardType[]; -const char *bkm_a4t_revision = "$Revision: 1.13.6.6 $"; +const char *bkm_a4t_revision = "$Revision: 1.1.4.1 $"; static inline u_char diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/isdn/hisax/bkm_a8.c linux-2.5/drivers/isdn/hisax/bkm_a8.c --- linux-2.5.1/drivers/isdn/hisax/bkm_a8.c Sun Sep 30 19:26:05 2001 +++ linux-2.5/drivers/isdn/hisax/bkm_a8.c Thu Dec 13 16:32:35 2001 @@ -1,4 +1,4 @@ -/* $Id: bkm_a8.c,v 1.14.6.7 2001/09/23 22:24:46 kai Exp $ +/* $Id: bkm_a8.c,v 1.1.4.1 2001/11/20 14:19:35 kai Exp $ * * low level stuff for Scitel Quadro (4*S0, passive) * @@ -28,7 +28,7 @@ extern const char *CardType[]; -const char sct_quadro_revision[] = "$Revision: 1.14.6.7 $"; +const char sct_quadro_revision[] = "$Revision: 1.1.4.1 $"; static const char *sct_quadro_subtypes[] = { diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/isdn/hisax/bkm_ax.h linux-2.5/drivers/isdn/hisax/bkm_ax.h --- linux-2.5.1/drivers/isdn/hisax/bkm_ax.h Sun Sep 30 19:26:05 2001 +++ linux-2.5/drivers/isdn/hisax/bkm_ax.h Thu Dec 13 16:32:35 2001 @@ -1,4 +1,4 @@ -/* $Id: bkm_ax.h,v 1.5.6.3 2001/09/23 22:24:46 kai Exp $ +/* $Id: bkm_ax.h,v 1.1.4.1 2001/11/20 14:19:35 kai Exp $ * * low level decls for T-Berkom cards A4T and Scitel Quadro (4*S0, passive) * diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/isdn/hisax/callc.c linux-2.5/drivers/isdn/hisax/callc.c --- linux-2.5.1/drivers/isdn/hisax/callc.c Sun Sep 30 19:26:05 2001 +++ linux-2.5/drivers/isdn/hisax/callc.c Thu Dec 13 16:32:35 2001 @@ -1,4 +1,4 @@ -/* $Id: callc.c,v 2.51.6.6 2001/09/23 22:24:46 kai Exp $ +/* $Id: callc.c,v 1.1.4.1 2001/11/20 14:19:35 kai Exp $ * * Author Karsten Keil * Copyright by Karsten Keil <keil@isdn4linux.de> @@ -26,7 +26,7 @@ #define MOD_USE_COUNT ( GET_USE_COUNT (&__this_module)) #endif /* MODULE */ -const char *lli_revision = "$Revision: 2.51.6.6 $"; +const char *lli_revision = "$Revision: 1.1.4.1 $"; extern struct IsdnCard cards[]; extern int nrcards; diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/isdn/hisax/cert.c linux-2.5/drivers/isdn/hisax/cert.c --- linux-2.5.1/drivers/isdn/hisax/cert.c Sun Sep 30 19:26:05 2001 +++ linux-2.5/drivers/isdn/hisax/cert.c Thu Dec 13 16:32:35 2001 @@ -1,4 +1,4 @@ -/* $Id: cert.c,v 2.3.6.3 2001/09/23 22:24:47 kai Exp $ +/* $Id: cert.c,v 1.1.4.1 2001/11/20 14:19:35 kai Exp $ * * Author Karsten Keil * Copyright by Karsten Keil <keil@isdn4linux.de> diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/isdn/hisax/config.c linux-2.5/drivers/isdn/hisax/config.c --- linux-2.5.1/drivers/isdn/hisax/config.c Fri Nov 30 17:48:32 2001 +++ linux-2.5/drivers/isdn/hisax/config.c Thu Dec 13 16:32:35 2001 @@ -1,4 +1,4 @@ -/* $Id: config.c,v 2.57.6.20 2001/09/23 22:24:47 kai Exp $ +/* $Id: config.c,v 1.1.4.5 2001/12/09 19:19:26 kai Exp $ * * Author Karsten Keil * Copyright by Karsten Keil <keil@isdn4linux.de> @@ -336,27 +336,19 @@ NULL, \ } -#define EMPTY_CARD {0, DEFAULT_PROTO, {0, 0, 0, 0}, NULL} - -struct IsdnCard cards[] = { +struct IsdnCard cards[HISAX_MAX_CARDS] = { FIRST_CARD, - EMPTY_CARD, - EMPTY_CARD, - EMPTY_CARD, - EMPTY_CARD, - EMPTY_CARD, - EMPTY_CARD, - EMPTY_CARD, }; -static char HiSaxID[64] __devinitdata = { 0, }; +#define HISAX_IDSIZE (HISAX_MAX_CARDS*8) +static char HiSaxID[HISAX_IDSIZE] __devinitdata = { 0, }; char *HiSax_id __devinitdata = HiSaxID; #ifdef MODULE /* Variables for insmod */ -static int type[8] __devinitdata = { 0, }; -static int protocol[8] __devinitdata = { 0, }; -static int io[8] __devinitdata = { 0, }; +static int type[HISAX_MAX_CARDS] __devinitdata = { 0, }; +static int protocol[HISAX_MAX_CARDS] __devinitdata = { 0, }; +static int io[HISAX_MAX_CARDS] __devinitdata = { 0, }; #undef IO0_IO1 #ifdef CONFIG_HISAX_16_3 #define IO0_IO1 @@ -366,25 +358,27 @@ #define IO0_IO1 #endif #ifdef IO0_IO1 -static int io0[8] __devinitdata = { 0, }; -static int io1[8] __devinitdata = { 0, }; +static int io0[HISAX_MAX_CARDS] __devinitdata = { 0, }; +static int io1[HISAX_MAX_CARDS] __devinitdata = { 0, }; #endif -static int irq[8] __devinitdata = { 0, }; -static int mem[8] __devinitdata = { 0, }; +static int irq[HISAX_MAX_CARDS] __devinitdata = { 0, }; +static int mem[HISAX_MAX_CARDS] __devinitdata = { 0, }; static char *id __devinitdata = HiSaxID; +#define PARM_PARA "1-" __MODULE_STRING(HISAX_MAX_CARDS) "i" + MODULE_DESCRIPTION("ISDN4Linux: Driver for passive ISDN cards"); MODULE_AUTHOR("Karsten Keil"); MODULE_LICENSE("GPL"); -MODULE_PARM(type, "1-8i"); -MODULE_PARM(protocol, "1-8i"); -MODULE_PARM(io, "1-8i"); -MODULE_PARM(irq, "1-8i"); -MODULE_PARM(mem, "1-8i"); +MODULE_PARM(type, PARM_PARA); +MODULE_PARM(protocol, PARM_PARA); +MODULE_PARM(io, PARM_PARA); +MODULE_PARM(irq, PARM_PARA); +MODULE_PARM(mem, PARM_PARA); MODULE_PARM(id, "s"); #ifdef IO0_IO1 -MODULE_PARM(io0, "1-8i"); -MODULE_PARM(io1, "1-8i"); +MODULE_PARM(io0, PARM_PARA); +MODULE_PARM(io1, PARM_PARA); #endif #endif /* MODULE */ @@ -448,6 +442,7 @@ i = 0; j = 1; while (argc && (i < HISAX_MAX_CARDS)) { + cards[i].protocol = DEFAULT_PROTO; if (argc) { cards[i].typ = ints[j]; j++; @@ -475,13 +470,15 @@ } i++; } - if (str && *str) { - strcpy(HiSaxID, str); - HiSax_id = HiSaxID; - } else { + if (str && *str) { + if (strlen(str) < HISAX_IDSIZE) + strcpy(HiSaxID, str); + else + printk(KERN_WARNING "HiSax: ID too long!"); + } else strcpy(HiSaxID, "HiSax"); - HiSax_id = HiSaxID; - } + + HiSax_id = HiSaxID; return 1; } @@ -1396,6 +1393,8 @@ if (protocol[i]) { cards[j].protocol = protocol[i]; nzproto++; + } else { + cards[j].protocol = DEFAULT_PROTO; } switch (type[i]) { case ISDN_CTYPE_16_0: @@ -1473,15 +1472,22 @@ } else { /* QUADRO is a 4 BRI card */ cards[j++].para[0] = 1; - cards[j].typ = ISDN_CTYPE_SCT_QUADRO; - cards[j].protocol = protocol[i]; - cards[j++].para[0] = 2; - cards[j].typ = ISDN_CTYPE_SCT_QUADRO; - cards[j].protocol = protocol[i]; - cards[j++].para[0] = 3; - cards[j].typ = ISDN_CTYPE_SCT_QUADRO; - cards[j].protocol = protocol[i]; - cards[j].para[0] = 4; + /* we need to check if further cards can be added */ + if (j < HISAX_MAX_CARDS) { + cards[j].typ = ISDN_CTYPE_SCT_QUADRO; + cards[j].protocol = protocol[i]; + cards[j++].para[0] = 2; + } + if (j < HISAX_MAX_CARDS) { + cards[j].typ = ISDN_CTYPE_SCT_QUADRO; + cards[j].protocol = protocol[i]; + cards[j++].para[0] = 3; + } + if (j < HISAX_MAX_CARDS) { + cards[j].typ = ISDN_CTYPE_SCT_QUADRO; + cards[j].protocol = protocol[i]; + cards[j].para[0] = 4; + } } break; } @@ -1554,6 +1560,8 @@ cards[i].typ = type[i]; if (protocol[i]) { cards[i].protocol = protocol[i]; + } else { + cards[i].protocol = DEFAULT_PROTO; } } cards[0].para[0] = pcm_irq; @@ -1594,6 +1602,8 @@ cards[i].typ = type[i]; if (protocol[i]) { cards[i].protocol = protocol[i]; + } else { + cards[i].protocol = DEFAULT_PROTO; } } cards[0].para[0] = pcm_irq; @@ -1634,6 +1644,8 @@ cards[i].typ = type[i]; if (protocol[i]) { cards[i].protocol = protocol[i]; + } else { + cards[i].protocol = DEFAULT_PROTO; } } cards[0].para[0] = pcm_irq; @@ -1674,6 +1686,8 @@ cards[i].typ = type[i]; if (protocol[i]) { cards[i].protocol = protocol[i]; + } else { + cards[i].protocol = DEFAULT_PROTO; } } cards[0].para[0] = pcm_irq; diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/isdn/hisax/diva.c linux-2.5/drivers/isdn/hisax/diva.c --- linux-2.5.1/drivers/isdn/hisax/diva.c Sun Sep 30 19:26:05 2001 +++ linux-2.5/drivers/isdn/hisax/diva.c Thu Dec 13 16:32:35 2001 @@ -1,4 +1,4 @@ -/* $Id: diva.c,v 1.25.6.5 2001/09/23 22:24:47 kai Exp $ +/* $Id: diva.c,v 1.1.4.1 2001/11/20 14:19:35 kai Exp $ * * low level stuff for Eicon.Diehl Diva Family ISDN cards * @@ -27,7 +27,7 @@ extern const char *CardType[]; -const char *Diva_revision = "$Revision: 1.25.6.5 $"; +const char *Diva_revision = "$Revision: 1.1.4.1 $"; #define byteout(addr,val) outb(val,addr) #define bytein(addr) inb(addr) diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/isdn/hisax/elsa.c linux-2.5/drivers/isdn/hisax/elsa.c --- linux-2.5.1/drivers/isdn/hisax/elsa.c Sun Sep 30 19:26:05 2001 +++ linux-2.5/drivers/isdn/hisax/elsa.c Thu Dec 13 16:32:35 2001 @@ -1,4 +1,4 @@ -/* $Id: elsa.c,v 2.26.6.6 2001/09/23 22:24:47 kai Exp $ +/* $Id: elsa.c,v 1.1.4.1 2001/11/20 14:19:35 kai Exp $ * * low level stuff for Elsa isdn cards * @@ -33,7 +33,7 @@ extern const char *CardType[]; -const char *Elsa_revision = "$Revision: 2.26.6.6 $"; +const char *Elsa_revision = "$Revision: 1.1.4.1 $"; const char *Elsa_Types[] = {"None", "PC", "PCC-8", "PCC-16", "PCF", "PCF-Pro", "PCMCIA", "QS 1000", "QS 3000", "Microlink PCI", "QS 3000 PCI", diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/isdn/hisax/elsa_cs.c linux-2.5/drivers/isdn/hisax/elsa_cs.c --- linux-2.5.1/drivers/isdn/hisax/elsa_cs.c Sun Sep 30 19:26:05 2001 +++ linux-2.5/drivers/isdn/hisax/elsa_cs.c Thu Dec 13 16:32:35 2001 @@ -72,7 +72,7 @@ MODULE_PARM(pc_debug, "i"); #define DEBUG(n, args...) if (pc_debug>(n)) printk(KERN_DEBUG args); static char *version = -"elsa_cs.c $Revision: 1.1.2.2 $ $Date: 2001/09/23 22:24:47 $ (K.Lichtenwalder)"; +"elsa_cs.c $Revision: 1.1.4.1 $ $Date: 2001/11/20 14:19:35 $ (K.Lichtenwalder)"; #else #define DEBUG(n, args...) #endif diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/isdn/hisax/elsa_ser.c linux-2.5/drivers/isdn/hisax/elsa_ser.c --- linux-2.5.1/drivers/isdn/hisax/elsa_ser.c Sun Sep 30 19:26:05 2001 +++ linux-2.5/drivers/isdn/hisax/elsa_ser.c Thu Dec 13 16:32:35 2001 @@ -1,4 +1,4 @@ -/* $Id: elsa_ser.c,v 2.10.6.4 2001/09/23 22:24:47 kai Exp $ +/* $Id: elsa_ser.c,v 1.1.4.1 2001/11/20 14:19:35 kai Exp $ * * stuff for the serial modem on ELSA cards * diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/isdn/hisax/fsm.c linux-2.5/drivers/isdn/hisax/fsm.c --- linux-2.5.1/drivers/isdn/hisax/fsm.c Sun Sep 30 19:26:05 2001 +++ linux-2.5/drivers/isdn/hisax/fsm.c Thu Dec 13 16:32:35 2001 @@ -1,4 +1,4 @@ -/* $Id: fsm.c,v 1.14.6.4 2001/09/23 22:24:47 kai Exp $ +/* $Id: fsm.c,v 1.1.4.1 2001/11/20 14:19:35 kai Exp $ * * Finite state machine * diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/isdn/hisax/fsm.h linux-2.5/drivers/isdn/hisax/fsm.h --- linux-2.5.1/drivers/isdn/hisax/fsm.h Sun Sep 30 19:26:05 2001 +++ linux-2.5/drivers/isdn/hisax/fsm.h Thu Dec 13 16:32:35 2001 @@ -1,4 +1,4 @@ -/* $Id: fsm.h,v 1.3.2.2 2001/09/23 22:24:47 kai Exp $ +/* $Id: fsm.h,v 1.1.2.1 2001/11/20 14:19:35 kai Exp $ * * Finite state machine * diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/isdn/hisax/gazel.c linux-2.5/drivers/isdn/hisax/gazel.c --- linux-2.5.1/drivers/isdn/hisax/gazel.c Sun Sep 30 19:26:05 2001 +++ linux-2.5/drivers/isdn/hisax/gazel.c Thu Dec 13 16:32:35 2001 @@ -1,4 +1,4 @@ -/* $Id: gazel.c,v 2.11.6.7 2001/09/23 22:24:47 kai Exp $ +/* $Id: gazel.c,v 1.1.4.1 2001/11/20 14:19:35 kai Exp $ * * low level stuff for Gazel isdn cards * @@ -22,7 +22,7 @@ #include <linux/pci.h> extern const char *CardType[]; -const char *gazel_revision = "$Revision: 2.11.6.7 $"; +const char *gazel_revision = "$Revision: 1.1.4.1 $"; #define R647 1 #define R685 2 diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/isdn/hisax/hfc_2bds0.c linux-2.5/drivers/isdn/hisax/hfc_2bds0.c --- linux-2.5.1/drivers/isdn/hisax/hfc_2bds0.c Sun Sep 30 19:26:05 2001 +++ linux-2.5/drivers/isdn/hisax/hfc_2bds0.c Thu Dec 13 16:32:35 2001 @@ -1,4 +1,4 @@ -/* $Id: hfc_2bds0.c,v 1.15.6.3 2001/09/23 22:24:47 kai Exp $ +/* $Id: hfc_2bds0.c,v 1.1.4.1 2001/11/20 14:19:35 kai Exp $ * * specific routines for CCD's HFC 2BDS0 * diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/isdn/hisax/hfc_2bds0.h linux-2.5/drivers/isdn/hisax/hfc_2bds0.h --- linux-2.5.1/drivers/isdn/hisax/hfc_2bds0.h Sun Sep 30 19:26:05 2001 +++ linux-2.5/drivers/isdn/hisax/hfc_2bds0.h Thu Dec 13 16:32:35 2001 @@ -1,4 +1,4 @@ -/* $Id: hfc_2bds0.h,v 1.4.6.2 2001/09/23 22:24:47 kai Exp $ +/* $Id: hfc_2bds0.h,v 1.1.4.1 2001/11/20 14:19:35 kai Exp $ * * specific defines for CCD's HFC 2BDS0 * diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/isdn/hisax/hfc_2bs0.c linux-2.5/drivers/isdn/hisax/hfc_2bs0.c --- linux-2.5.1/drivers/isdn/hisax/hfc_2bs0.c Sun Sep 30 19:26:05 2001 +++ linux-2.5/drivers/isdn/hisax/hfc_2bs0.c Thu Dec 13 16:32:35 2001 @@ -1,4 +1,4 @@ -/* $Id: hfc_2bs0.c,v 1.17.6.3 2001/09/23 22:24:47 kai Exp $ +/* $Id: hfc_2bs0.c,v 1.1.4.1 2001/11/20 14:19:35 kai Exp $ * * specific routines for CCD's HFC 2BS0 * diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/isdn/hisax/hfc_2bs0.h linux-2.5/drivers/isdn/hisax/hfc_2bs0.h --- linux-2.5.1/drivers/isdn/hisax/hfc_2bs0.h Sun Sep 30 19:26:05 2001 +++ linux-2.5/drivers/isdn/hisax/hfc_2bs0.h Thu Dec 13 16:32:35 2001 @@ -1,4 +1,4 @@ -/* $Id: hfc_2bs0.h,v 1.3.6.2 2001/09/23 22:24:47 kai Exp $ +/* $Id: hfc_2bs0.h,v 1.1.4.1 2001/11/20 14:19:35 kai Exp $ * * specific defines for CCD's HFC 2BS0 * diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/isdn/hisax/hfc_pci.c linux-2.5/drivers/isdn/hisax/hfc_pci.c --- linux-2.5.1/drivers/isdn/hisax/hfc_pci.c Sun Sep 30 19:26:05 2001 +++ linux-2.5/drivers/isdn/hisax/hfc_pci.c Thu Dec 13 16:32:35 2001 @@ -1,4 +1,4 @@ -/* $Id: hfc_pci.c,v 1.34.6.8 2001/09/23 22:24:47 kai Exp $ +/* $Id: hfc_pci.c,v 1.1.4.1 2001/11/20 14:19:35 kai Exp $ * * low level driver for CCD´s hfc-pci based cards * @@ -26,7 +26,7 @@ extern const char *CardType[]; -static const char *hfcpci_revision = "$Revision: 1.34.6.8 $"; +static const char *hfcpci_revision = "$Revision: 1.1.4.1 $"; /* table entry in the PCI devices list */ typedef struct { diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/isdn/hisax/hfc_pci.h linux-2.5/drivers/isdn/hisax/hfc_pci.h --- linux-2.5.1/drivers/isdn/hisax/hfc_pci.h Sun Sep 30 19:26:05 2001 +++ linux-2.5/drivers/isdn/hisax/hfc_pci.h Thu Dec 13 16:32:35 2001 @@ -1,4 +1,4 @@ -/* $Id: hfc_pci.h,v 1.8.6.2 2001/09/23 22:24:48 kai Exp $ +/* $Id: hfc_pci.h,v 1.1.4.1 2001/11/20 14:19:35 kai Exp $ * * specific defines for CCD's HFC 2BDS0 PCI chips * diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/isdn/hisax/hfc_sx.c linux-2.5/drivers/isdn/hisax/hfc_sx.c --- linux-2.5.1/drivers/isdn/hisax/hfc_sx.c Sun Sep 30 19:26:05 2001 +++ linux-2.5/drivers/isdn/hisax/hfc_sx.c Thu Dec 13 16:32:35 2001 @@ -1,4 +1,4 @@ -/* $Id: hfc_sx.c,v 1.9.6.3 2001/09/23 22:24:48 kai Exp $ +/* $Id: hfc_sx.c,v 1.1.4.1 2001/11/20 14:19:35 kai Exp $ * * level driver for CCD´s hfc-s+/sp based cards * @@ -20,7 +20,7 @@ extern const char *CardType[]; -static const char *hfcsx_revision = "$Revision: 1.9.6.3 $"; +static const char *hfcsx_revision = "$Revision: 1.1.4.1 $"; /***************************************/ /* IRQ-table for CCDs demo board */ diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/isdn/hisax/hfc_sx.h linux-2.5/drivers/isdn/hisax/hfc_sx.h --- linux-2.5.1/drivers/isdn/hisax/hfc_sx.h Sun Sep 30 19:26:05 2001 +++ linux-2.5/drivers/isdn/hisax/hfc_sx.h Thu Dec 13 16:32:35 2001 @@ -1,4 +1,4 @@ -/* $Id: hfc_sx.h,v 1.2.6.1 2001/09/23 22:24:48 kai Exp $ +/* $Id: hfc_sx.h,v 1.1.4.1 2001/11/20 14:19:35 kai Exp $ * * specific defines for CCD's HFC 2BDS0 S+,SP chips * diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/isdn/hisax/hfcscard.c linux-2.5/drivers/isdn/hisax/hfcscard.c --- linux-2.5.1/drivers/isdn/hisax/hfcscard.c Sun Sep 30 19:26:05 2001 +++ linux-2.5/drivers/isdn/hisax/hfcscard.c Thu Dec 13 16:32:35 2001 @@ -1,4 +1,4 @@ -/* $Id: hfcscard.c,v 1.8.6.2 2001/09/23 22:24:48 kai Exp $ +/* $Id: hfcscard.c,v 1.1.4.1 2001/11/20 14:19:35 kai Exp $ * * low level stuff for hfcs based cards (Teles3c, ACER P10) * @@ -18,7 +18,7 @@ extern const char *CardType[]; -static const char *hfcs_revision = "$Revision: 1.8.6.2 $"; +static const char *hfcs_revision = "$Revision: 1.1.4.1 $"; static void hfcs_interrupt(int intno, void *dev_id, struct pt_regs *regs) diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/isdn/hisax/hisax.h linux-2.5/drivers/isdn/hisax/hisax.h --- linux-2.5.1/drivers/isdn/hisax/hisax.h Sun Sep 30 19:26:05 2001 +++ linux-2.5/drivers/isdn/hisax/hisax.h Sun Dec 30 21:17:30 2001 @@ -1,4 +1,4 @@ -/* $Id: hisax.h,v 2.52.6.9 2001/09/23 22:24:48 kai Exp $ +/* $Id: hisax.h,v 1.1.4.2 2001/12/09 19:15:28 kai Exp $ * * Basic declarations, defines and prototypes * @@ -10,7 +10,6 @@ #include <linux/errno.h> #include <linux/fs.h> #include <linux/major.h> -#include <asm/segment.h> #include <asm/io.h> #include <linux/delay.h> #include <linux/kernel.h> @@ -949,8 +948,6 @@ #define MON1_RX 2 #define MON0_TX 4 #define MON1_TX 8 - -#define HISAX_MAX_CARDS 8 #define ISDN_CTYPE_16_0 1 #define ISDN_CTYPE_8_0 2 diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/isdn/hisax/hscx.c linux-2.5/drivers/isdn/hisax/hscx.c --- linux-2.5.1/drivers/isdn/hisax/hscx.c Sun Sep 30 19:26:05 2001 +++ linux-2.5/drivers/isdn/hisax/hscx.c Thu Dec 13 16:32:35 2001 @@ -1,4 +1,4 @@ -/* $Id: hscx.c,v 1.21.6.3 2001/09/23 22:24:48 kai Exp $ +/* $Id: hscx.c,v 1.1.4.1 2001/11/20 14:19:36 kai Exp $ * * HSCX specific routines * diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/isdn/hisax/hscx.h linux-2.5/drivers/isdn/hisax/hscx.h --- linux-2.5.1/drivers/isdn/hisax/hscx.h Sun Sep 30 19:26:05 2001 +++ linux-2.5/drivers/isdn/hisax/hscx.h Thu Dec 13 16:32:35 2001 @@ -1,4 +1,4 @@ -/* $Id: hscx.h,v 1.6.6.2 2001/09/23 22:24:48 kai Exp $ +/* $Id: hscx.h,v 1.1.4.1 2001/11/20 14:19:36 kai Exp $ * * HSCX specific defines * diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/isdn/hisax/hscx_irq.c linux-2.5/drivers/isdn/hisax/hscx_irq.c --- linux-2.5.1/drivers/isdn/hisax/hscx_irq.c Sun Sep 30 19:26:05 2001 +++ linux-2.5/drivers/isdn/hisax/hscx_irq.c Thu Dec 13 16:32:35 2001 @@ -1,4 +1,4 @@ -/* $Id: hscx_irq.c,v 1.16.6.2 2001/09/23 22:24:48 kai Exp $ +/* $Id: hscx_irq.c,v 1.1.4.1 2001/11/20 14:19:36 kai Exp $ * * low level b-channel stuff for Siemens HSCX * diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/isdn/hisax/icc.c linux-2.5/drivers/isdn/hisax/icc.c --- linux-2.5.1/drivers/isdn/hisax/icc.c Sun Sep 30 19:26:05 2001 +++ linux-2.5/drivers/isdn/hisax/icc.c Thu Dec 13 16:32:35 2001 @@ -1,4 +1,4 @@ -/* $Id: icc.c,v 1.5.6.4 2001/09/23 22:24:48 kai Exp $ +/* $Id: icc.c,v 1.1.4.1 2001/11/20 14:19:36 kai Exp $ * * ICC specific routines * diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/isdn/hisax/icc.h linux-2.5/drivers/isdn/hisax/icc.h --- linux-2.5.1/drivers/isdn/hisax/icc.h Sun Sep 30 19:26:05 2001 +++ linux-2.5/drivers/isdn/hisax/icc.h Thu Dec 13 16:32:35 2001 @@ -1,4 +1,4 @@ -/* $Id: icc.h,v 1.2.6.3 2001/09/23 22:24:48 kai Exp $ +/* $Id: icc.h,v 1.1.4.1 2001/11/20 14:19:36 kai Exp $ * * ICC specific routines * diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/isdn/hisax/ipac.h linux-2.5/drivers/isdn/hisax/ipac.h --- linux-2.5.1/drivers/isdn/hisax/ipac.h Sun Sep 30 19:26:05 2001 +++ linux-2.5/drivers/isdn/hisax/ipac.h Thu Dec 13 16:32:35 2001 @@ -1,4 +1,4 @@ -/* $Id: ipac.h,v 1.5.6.2 2001/09/23 22:24:49 kai Exp $ +/* $Id: ipac.h,v 1.1.4.1 2001/11/20 14:19:36 kai Exp $ * * IPAC specific defines * diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/isdn/hisax/isac.c linux-2.5/drivers/isdn/hisax/isac.c --- linux-2.5.1/drivers/isdn/hisax/isac.c Sun Sep 30 19:26:05 2001 +++ linux-2.5/drivers/isdn/hisax/isac.c Thu Dec 13 16:32:35 2001 @@ -1,4 +1,4 @@ -/* $Id: isac.c,v 1.28.6.3 2001/09/23 22:24:49 kai Exp $ +/* $Id: isac.c,v 1.1.4.1 2001/11/20 14:19:36 kai Exp $ * * ISAC specific routines * diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/isdn/hisax/isac.h linux-2.5/drivers/isdn/hisax/isac.h --- linux-2.5.1/drivers/isdn/hisax/isac.h Sun Sep 30 19:26:05 2001 +++ linux-2.5/drivers/isdn/hisax/isac.h Thu Dec 13 16:32:35 2001 @@ -1,4 +1,4 @@ -/* $Id: isac.h,v 1.7.6.2 2001/09/23 22:24:49 kai Exp $ +/* $Id: isac.h,v 1.1.4.1 2001/11/20 14:19:36 kai Exp $ * * ISAC specific defines * diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/isdn/hisax/isar.c linux-2.5/drivers/isdn/hisax/isar.c --- linux-2.5.1/drivers/isdn/hisax/isar.c Sun Sep 30 19:26:06 2001 +++ linux-2.5/drivers/isdn/hisax/isar.c Thu Dec 13 16:32:35 2001 @@ -1,4 +1,4 @@ -/* $Id: isar.c,v 1.17.6.5 2001/09/23 11:51:33 keil Exp $ +/* $Id: isar.c,v 1.1.4.1 2001/11/20 14:19:36 kai Exp $ * * isar.c ISAR (Siemens PSB 7110) specific routines * diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/isdn/hisax/isar.h linux-2.5/drivers/isdn/hisax/isar.h --- linux-2.5.1/drivers/isdn/hisax/isar.h Sun Sep 30 19:26:05 2001 +++ linux-2.5/drivers/isdn/hisax/isar.h Thu Dec 13 16:32:35 2001 @@ -1,4 +1,4 @@ -/* $Id: isar.h,v 1.9.6.2 2001/09/23 22:24:49 kai Exp $ +/* $Id: isar.h,v 1.1.4.1 2001/11/20 14:19:36 kai Exp $ * * ISAR (Siemens PSB 7110) specific defines * diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/isdn/hisax/isdnl1.c linux-2.5/drivers/isdn/hisax/isdnl1.c --- linux-2.5.1/drivers/isdn/hisax/isdnl1.c Sun Sep 30 19:26:05 2001 +++ linux-2.5/drivers/isdn/hisax/isdnl1.c Thu Dec 13 16:32:35 2001 @@ -1,4 +1,4 @@ -/* $Id: isdnl1.c,v 2.41.6.5 2001/09/23 22:24:49 kai Exp $ +/* $Id: isdnl1.c,v 1.1.4.1 2001/11/20 14:19:36 kai Exp $ * * common low level stuff for Siemens Chipsetbased isdn cards * @@ -18,7 +18,7 @@ * */ -const char *l1_revision = "$Revision: 2.41.6.5 $"; +const char *l1_revision = "$Revision: 1.1.4.1 $"; #define __NO_VERSION__ #include <linux/init.h> diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/isdn/hisax/isdnl1.h linux-2.5/drivers/isdn/hisax/isdnl1.h --- linux-2.5.1/drivers/isdn/hisax/isdnl1.h Sun Sep 30 19:26:05 2001 +++ linux-2.5/drivers/isdn/hisax/isdnl1.h Thu Dec 13 16:32:35 2001 @@ -1,4 +1,4 @@ -/* $Id: isdnl1.h,v 2.9.6.3 2001/09/23 22:24:49 kai Exp $ +/* $Id: isdnl1.h,v 1.1.4.1 2001/11/20 14:19:36 kai Exp $ * * Layer 1 defines * diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/isdn/hisax/isdnl2.c linux-2.5/drivers/isdn/hisax/isdnl2.c --- linux-2.5.1/drivers/isdn/hisax/isdnl2.c Sun Sep 30 19:26:05 2001 +++ linux-2.5/drivers/isdn/hisax/isdnl2.c Thu Dec 13 16:32:35 2001 @@ -1,4 +1,4 @@ -/* $Id: isdnl2.c,v 2.25.6.4 2001/09/23 22:24:49 kai Exp $ +/* $Id: isdnl2.c,v 1.1.4.1 2001/11/20 14:19:36 kai Exp $ * * Author Karsten Keil * based on the teles driver from Jan den Ouden @@ -20,7 +20,7 @@ #include "hisax.h" #include "isdnl2.h" -const char *l2_revision = "$Revision: 2.25.6.4 $"; +const char *l2_revision = "$Revision: 1.1.4.1 $"; static void l2m_debug(struct FsmInst *fi, char *fmt, ...); diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/isdn/hisax/isdnl2.h linux-2.5/drivers/isdn/hisax/isdnl2.h --- linux-2.5.1/drivers/isdn/hisax/isdnl2.h Sun Sep 30 19:26:05 2001 +++ linux-2.5/drivers/isdn/hisax/isdnl2.h Thu Dec 13 16:32:35 2001 @@ -1,4 +1,4 @@ -/* $Id: isdnl2.h,v 1.3.6.2 2001/09/23 22:24:49 kai Exp $ +/* $Id: isdnl2.h,v 1.1.4.1 2001/11/20 14:19:36 kai Exp $ * * Layer 2 defines * diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/isdn/hisax/isdnl3.c linux-2.5/drivers/isdn/hisax/isdnl3.c --- linux-2.5.1/drivers/isdn/hisax/isdnl3.c Sun Sep 30 19:26:05 2001 +++ linux-2.5/drivers/isdn/hisax/isdnl3.c Thu Dec 13 16:32:35 2001 @@ -1,4 +1,4 @@ -/* $Id: isdnl3.c,v 2.17.6.5 2001/09/23 22:24:49 kai Exp $ +/* $Id: isdnl3.c,v 1.1.4.1 2001/11/20 14:19:36 kai Exp $ * * Author Karsten Keil * based on the teles driver from Jan den Ouden @@ -21,7 +21,7 @@ #include "isdnl3.h" #include <linux/config.h> -const char *l3_revision = "$Revision: 2.17.6.5 $"; +const char *l3_revision = "$Revision: 1.1.4.1 $"; static struct Fsm l3fsm; diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/isdn/hisax/isdnl3.h linux-2.5/drivers/isdn/hisax/isdnl3.h --- linux-2.5.1/drivers/isdn/hisax/isdnl3.h Sun Sep 30 19:26:05 2001 +++ linux-2.5/drivers/isdn/hisax/isdnl3.h Thu Dec 13 16:32:35 2001 @@ -1,4 +1,4 @@ -/* $Id: isdnl3.h,v 2.6.6.2 2001/09/23 22:24:49 kai Exp $ +/* $Id: isdnl3.h,v 1.1.4.1 2001/11/20 14:19:36 kai Exp $ * * This software may be used and distributed according to the terms * of the GNU General Public License, incorporated herein by reference. diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/isdn/hisax/isurf.c linux-2.5/drivers/isdn/hisax/isurf.c --- linux-2.5.1/drivers/isdn/hisax/isurf.c Sun Sep 30 19:26:05 2001 +++ linux-2.5/drivers/isdn/hisax/isurf.c Thu Dec 13 16:32:35 2001 @@ -1,4 +1,4 @@ -/* $Id: isurf.c,v 1.10.6.2 2001/09/23 22:24:49 kai Exp $ +/* $Id: isurf.c,v 1.1.4.1 2001/11/20 14:19:36 kai Exp $ * * low level stuff for Siemens I-Surf/I-Talk cards * @@ -19,7 +19,7 @@ extern const char *CardType[]; -static const char *ISurf_revision = "$Revision: 1.10.6.2 $"; +static const char *ISurf_revision = "$Revision: 1.1.4.1 $"; #define byteout(addr,val) outb(val,addr) #define bytein(addr) inb(addr) diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/isdn/hisax/ix1_micro.c linux-2.5/drivers/isdn/hisax/ix1_micro.c --- linux-2.5.1/drivers/isdn/hisax/ix1_micro.c Sun Sep 30 19:26:05 2001 +++ linux-2.5/drivers/isdn/hisax/ix1_micro.c Thu Dec 13 16:32:35 2001 @@ -1,4 +1,4 @@ -/* $Id: ix1_micro.c,v 2.10.6.2 2001/09/23 22:24:49 kai Exp $ +/* $Id: ix1_micro.c,v 1.1.4.1 2001/11/20 14:19:36 kai Exp $ * * low level stuff for ITK ix1-micro Rev.2 isdn cards * derived from the original file teles3.c from Karsten Keil @@ -25,7 +25,7 @@ #include "isdnl1.h" extern const char *CardType[]; -const char *ix1_revision = "$Revision: 2.10.6.2 $"; +const char *ix1_revision = "$Revision: 1.1.4.1 $"; #define byteout(addr,val) outb(val,addr) #define bytein(addr) inb(addr) diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/isdn/hisax/jade.c linux-2.5/drivers/isdn/hisax/jade.c --- linux-2.5.1/drivers/isdn/hisax/jade.c Sun Sep 30 19:26:05 2001 +++ linux-2.5/drivers/isdn/hisax/jade.c Thu Dec 13 16:32:35 2001 @@ -1,4 +1,4 @@ -/* $Id: jade.c,v 1.6.6.3 2001/09/23 22:24:49 kai Exp $ +/* $Id: jade.c,v 1.1.4.1 2001/11/20 14:19:36 kai Exp $ * * JADE stuff (derived from original hscx.c) * diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/isdn/hisax/jade.h linux-2.5/drivers/isdn/hisax/jade.h --- linux-2.5.1/drivers/isdn/hisax/jade.h Sun Sep 30 19:26:05 2001 +++ linux-2.5/drivers/isdn/hisax/jade.h Thu Dec 13 16:32:35 2001 @@ -1,4 +1,4 @@ -/* $Id: jade.h,v 1.3.6.2 2001/09/23 22:24:49 kai Exp $ +/* $Id: jade.h,v 1.1.4.1 2001/11/20 14:19:36 kai Exp $ * * JADE specific defines * diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/isdn/hisax/jade_irq.c linux-2.5/drivers/isdn/hisax/jade_irq.c --- linux-2.5.1/drivers/isdn/hisax/jade_irq.c Sun Sep 30 19:26:05 2001 +++ linux-2.5/drivers/isdn/hisax/jade_irq.c Thu Dec 13 16:32:35 2001 @@ -1,4 +1,4 @@ -/* $Id: jade_irq.c,v 1.5.6.2 2001/09/23 22:24:49 kai Exp $ +/* $Id: jade_irq.c,v 1.1.4.1 2001/11/20 14:19:36 kai Exp $ * * Low level JADE IRQ stuff (derived from original hscx_irq.c) * diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/isdn/hisax/l3_1tr6.c linux-2.5/drivers/isdn/hisax/l3_1tr6.c --- linux-2.5.1/drivers/isdn/hisax/l3_1tr6.c Sun Sep 30 19:26:05 2001 +++ linux-2.5/drivers/isdn/hisax/l3_1tr6.c Thu Dec 13 16:32:35 2001 @@ -1,4 +1,4 @@ -/* $Id: l3_1tr6.c,v 2.13.6.2 2001/09/23 22:24:49 kai Exp $ +/* $Id: l3_1tr6.c,v 1.1.4.1 2001/11/20 14:19:36 kai Exp $ * * German 1TR6 D-channel protocol * @@ -20,7 +20,7 @@ #include <linux/ctype.h> extern char *HiSax_getrev(const char *revision); -const char *l3_1tr6_revision = "$Revision: 2.13.6.2 $"; +const char *l3_1tr6_revision = "$Revision: 1.1.4.1 $"; #define MsgHead(ptr, cref, mty, dis) \ *ptr++ = dis; \ diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/isdn/hisax/l3_1tr6.h linux-2.5/drivers/isdn/hisax/l3_1tr6.h --- linux-2.5.1/drivers/isdn/hisax/l3_1tr6.h Sun Sep 30 19:26:05 2001 +++ linux-2.5/drivers/isdn/hisax/l3_1tr6.h Thu Dec 13 16:32:35 2001 @@ -1,4 +1,4 @@ -/* $Id: l3_1tr6.h,v 2.2.6.2 2001/09/23 22:24:49 kai Exp $ +/* $Id: l3_1tr6.h,v 1.1.4.1 2001/11/20 14:19:36 kai Exp $ * * German 1TR6 D-channel protocol defines * diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/isdn/hisax/l3dss1.c linux-2.5/drivers/isdn/hisax/l3dss1.c --- linux-2.5.1/drivers/isdn/hisax/l3dss1.c Sun Sep 30 19:26:05 2001 +++ linux-2.5/drivers/isdn/hisax/l3dss1.c Thu Dec 13 16:32:35 2001 @@ -1,4 +1,4 @@ -/* $Id: l3dss1.c,v 2.30.6.2 2001/09/23 22:24:49 kai Exp $ +/* $Id: l3dss1.c,v 1.1.4.1 2001/11/20 14:19:36 kai Exp $ * * EURO/DSS1 D-channel protocol * @@ -27,7 +27,7 @@ #include <linux/config.h> extern char *HiSax_getrev(const char *revision); -const char *dss1_revision = "$Revision: 2.30.6.2 $"; +const char *dss1_revision = "$Revision: 1.1.4.1 $"; #define EXT_BEARER_CAPS 1 diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/isdn/hisax/l3dss1.h linux-2.5/drivers/isdn/hisax/l3dss1.h --- linux-2.5.1/drivers/isdn/hisax/l3dss1.h Sun Sep 30 19:26:05 2001 +++ linux-2.5/drivers/isdn/hisax/l3dss1.h Thu Dec 13 16:32:35 2001 @@ -1,4 +1,4 @@ -/* $Id: l3dss1.h,v 1.10.6.2 2001/09/23 22:24:50 kai Exp $ +/* $Id: l3dss1.h,v 1.1.4.1 2001/11/20 14:19:36 kai Exp $ * * DSS1 (Euro) D-channel protocol defines * diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/isdn/hisax/l3ni1.c linux-2.5/drivers/isdn/hisax/l3ni1.c --- linux-2.5.1/drivers/isdn/hisax/l3ni1.c Sun Sep 30 19:26:05 2001 +++ linux-2.5/drivers/isdn/hisax/l3ni1.c Thu Dec 13 16:32:35 2001 @@ -1,4 +1,4 @@ -/* $Id: l3ni1.c,v 2.5.6.3 2001/09/23 22:24:50 kai Exp $ +/* $Id: l3ni1.c,v 1.1.4.1 2001/11/20 14:19:36 kai Exp $ * * NI1 D-channel protocol * @@ -25,7 +25,7 @@ #include <linux/ctype.h> extern char *HiSax_getrev(const char *revision); -const char *ni1_revision = "$Revision: 2.5.6.3 $"; +const char *ni1_revision = "$Revision: 1.1.4.1 $"; #define EXT_BEARER_CAPS 1 diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/isdn/hisax/l3ni1.h linux-2.5/drivers/isdn/hisax/l3ni1.h --- linux-2.5.1/drivers/isdn/hisax/l3ni1.h Sun Sep 30 19:26:05 2001 +++ linux-2.5/drivers/isdn/hisax/l3ni1.h Thu Dec 13 16:32:35 2001 @@ -1,4 +1,4 @@ -/* $Id: l3ni1.h,v 2.3.6.2 2001/09/23 22:24:50 kai Exp $ +/* $Id: l3ni1.h,v 1.1.4.1 2001/11/20 14:19:36 kai Exp $ * * NI1 D-channel protocol * diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/isdn/hisax/lmgr.c linux-2.5/drivers/isdn/hisax/lmgr.c --- linux-2.5.1/drivers/isdn/hisax/lmgr.c Sun Sep 30 19:26:05 2001 +++ linux-2.5/drivers/isdn/hisax/lmgr.c Thu Dec 13 16:32:35 2001 @@ -1,4 +1,4 @@ -/* $Id: lmgr.c,v 1.7.6.2 2001/09/23 22:24:50 kai Exp $ +/* $Id: lmgr.c,v 1.1.4.1 2001/11/20 14:19:36 kai Exp $ * * Layermanagement module * diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/isdn/hisax/mic.c linux-2.5/drivers/isdn/hisax/mic.c --- linux-2.5.1/drivers/isdn/hisax/mic.c Sun Sep 30 19:26:05 2001 +++ linux-2.5/drivers/isdn/hisax/mic.c Thu Dec 13 16:32:35 2001 @@ -1,4 +1,4 @@ -/* $Id: mic.c,v 1.10.6.2 2001/09/23 22:24:50 kai Exp $ +/* $Id: mic.c,v 1.1.4.1 2001/11/20 14:19:36 kai Exp $ * * low level stuff for mic cards * @@ -19,7 +19,7 @@ extern const char *CardType[]; -const char *mic_revision = "$Revision: 1.10.6.2 $"; +const char *mic_revision = "$Revision: 1.1.4.1 $"; #define byteout(addr,val) outb(val,addr) #define bytein(addr) inb(addr) diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/isdn/hisax/netjet.c linux-2.5/drivers/isdn/hisax/netjet.c --- linux-2.5.1/drivers/isdn/hisax/netjet.c Sun Sep 30 19:26:06 2001 +++ linux-2.5/drivers/isdn/hisax/netjet.c Thu Dec 13 16:32:35 2001 @@ -1,4 +1,4 @@ -/* $Id: netjet.c,v 1.24.6.6 2001/09/23 22:24:50 kai Exp $ +/* $Id: netjet.c,v 1.1.4.1 2001/11/20 14:19:36 kai Exp $ * * low level stuff for Traverse Technologie NETJet ISDN cards * @@ -24,7 +24,7 @@ #include <asm/io.h> #include "netjet.h" -const char *NETjet_revision = "$Revision: 1.24.6.6 $"; +const char *NETjet_revision = "$Revision: 1.1.4.1 $"; /* Interface functions */ diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/isdn/hisax/netjet.h linux-2.5/drivers/isdn/hisax/netjet.h --- linux-2.5.1/drivers/isdn/hisax/netjet.h Sun Sep 30 19:26:06 2001 +++ linux-2.5/drivers/isdn/hisax/netjet.h Thu Dec 13 16:32:35 2001 @@ -1,4 +1,4 @@ -/* $Id: netjet.h,v 2.5.6.3 2001/09/23 22:24:50 kai Exp $ +/* $Id: netjet.h,v 1.1.4.1 2001/11/20 14:19:36 kai Exp $ * * NETjet common header file * diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/isdn/hisax/niccy.c linux-2.5/drivers/isdn/hisax/niccy.c --- linux-2.5.1/drivers/isdn/hisax/niccy.c Wed Oct 24 22:34:51 2001 +++ linux-2.5/drivers/isdn/hisax/niccy.c Thu Dec 13 16:32:35 2001 @@ -1,4 +1,4 @@ -/* $Id: niccy.c,v 1.15.6.6 2001/10/20 22:08:24 kai Exp $ +/* $Id: niccy.c,v 1.1.4.1 2001/11/20 14:19:36 kai Exp $ * * low level stuff for Dr. Neuhaus NICCY PnP and NICCY PCI and * compatible (SAGEM cybermodem) @@ -24,7 +24,7 @@ #include <linux/pci.h> extern const char *CardType[]; -const char *niccy_revision = "$Revision: 1.15.6.6 $"; +const char *niccy_revision = "$Revision: 1.1.4.1 $"; #define byteout(addr,val) outb(val,addr) #define bytein(addr) inb(addr) diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/isdn/hisax/nj_s.c linux-2.5/drivers/isdn/hisax/nj_s.c --- linux-2.5.1/drivers/isdn/hisax/nj_s.c Sun Sep 30 19:26:06 2001 +++ linux-2.5/drivers/isdn/hisax/nj_s.c Thu Dec 13 16:32:35 2001 @@ -1,4 +1,4 @@ -/* $Id: nj_s.c,v 2.7.6.6 2001/09/23 22:24:50 kai Exp $ +/* $Id: nj_s.c,v 1.1.4.1 2001/11/20 14:19:36 kai Exp $ * * This software may be used and distributed according to the terms * of the GNU General Public License, incorporated herein by reference. @@ -16,7 +16,7 @@ #include <linux/ppp_defs.h> #include "netjet.h" -const char *NETjet_S_revision = "$Revision: 2.7.6.6 $"; +const char *NETjet_S_revision = "$Revision: 1.1.4.1 $"; static u_char dummyrr(struct IsdnCardState *cs, int chan, u_char off) { diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/isdn/hisax/nj_u.c linux-2.5/drivers/isdn/hisax/nj_u.c --- linux-2.5.1/drivers/isdn/hisax/nj_u.c Sun Sep 30 19:26:06 2001 +++ linux-2.5/drivers/isdn/hisax/nj_u.c Thu Dec 13 16:32:35 2001 @@ -1,4 +1,4 @@ -/* $Id: nj_u.c,v 2.8.6.6 2001/09/23 22:24:50 kai Exp $ +/* $Id: nj_u.c,v 1.1.4.1 2001/11/20 14:19:36 kai Exp $ * * This software may be used and distributed according to the terms * of the GNU General Public License, incorporated herein by reference. @@ -16,7 +16,7 @@ #include <linux/ppp_defs.h> #include "netjet.h" -const char *NETjet_U_revision = "$Revision: 2.8.6.6 $"; +const char *NETjet_U_revision = "$Revision: 1.1.4.1 $"; static u_char dummyrr(struct IsdnCardState *cs, int chan, u_char off) { diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/isdn/hisax/q931.c linux-2.5/drivers/isdn/hisax/q931.c --- linux-2.5.1/drivers/isdn/hisax/q931.c Sun Sep 30 19:26:06 2001 +++ linux-2.5/drivers/isdn/hisax/q931.c Thu Dec 13 16:32:35 2001 @@ -1,4 +1,4 @@ -/* $Id: q931.c,v 1.10.6.3 2001/09/23 22:24:50 kai Exp $ +/* $Id: q931.c,v 1.1.4.1 2001/11/20 14:19:36 kai Exp $ * * code to decode ITU Q.931 call control messages * diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/isdn/hisax/rawhdlc.c linux-2.5/drivers/isdn/hisax/rawhdlc.c --- linux-2.5.1/drivers/isdn/hisax/rawhdlc.c Sun Sep 30 19:26:06 2001 +++ linux-2.5/drivers/isdn/hisax/rawhdlc.c Thu Dec 13 16:32:35 2001 @@ -1,4 +1,4 @@ -/* $Id: rawhdlc.c,v 1.5.6.2 2001/09/23 22:24:51 kai Exp $ +/* $Id: rawhdlc.c,v 1.1.4.1 2001/11/20 14:19:36 kai Exp $ * * support routines for cards that don't support HDLC * diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/isdn/hisax/rawhdlc.h linux-2.5/drivers/isdn/hisax/rawhdlc.h --- linux-2.5.1/drivers/isdn/hisax/rawhdlc.h Sun Sep 30 19:26:06 2001 +++ linux-2.5/drivers/isdn/hisax/rawhdlc.h Thu Dec 13 16:32:35 2001 @@ -1,4 +1,4 @@ -/* $Id: rawhdlc.h,v 1.3.6.2 2001/09/23 22:24:51 kai Exp $ +/* $Id: rawhdlc.h,v 1.1.4.1 2001/11/20 14:19:36 kai Exp $ * * Author Brent Baccala * Copyright by Brent Baccala <baccala@FreeSoft.org> diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/isdn/hisax/s0box.c linux-2.5/drivers/isdn/hisax/s0box.c --- linux-2.5.1/drivers/isdn/hisax/s0box.c Sun Sep 30 19:26:06 2001 +++ linux-2.5/drivers/isdn/hisax/s0box.c Thu Dec 13 16:32:35 2001 @@ -1,4 +1,4 @@ -/* $Id: s0box.c,v 2.4.6.2 2001/09/23 22:24:51 kai Exp $ +/* $Id: s0box.c,v 1.1.4.1 2001/11/20 14:19:36 kai Exp $ * * low level stuff for Creatix S0BOX * @@ -18,7 +18,7 @@ #include "isdnl1.h" extern const char *CardType[]; -const char *s0box_revision = "$Revision: 2.4.6.2 $"; +const char *s0box_revision = "$Revision: 1.1.4.1 $"; static inline void writereg(unsigned int padr, signed int addr, u_char off, u_char val) { diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/isdn/hisax/saphir.c linux-2.5/drivers/isdn/hisax/saphir.c --- linux-2.5.1/drivers/isdn/hisax/saphir.c Sun Sep 30 19:26:06 2001 +++ linux-2.5/drivers/isdn/hisax/saphir.c Thu Dec 13 16:32:35 2001 @@ -1,4 +1,4 @@ -/* $Id: saphir.c,v 1.8.6.2 2001/09/23 22:24:51 kai Exp $ +/* $Id: saphir.c,v 1.1.4.1 2001/11/20 14:19:36 kai Exp $ * * low level stuff for HST Saphir 1 * @@ -20,7 +20,7 @@ #include "isdnl1.h" extern const char *CardType[]; -static char *saphir_rev = "$Revision: 1.8.6.2 $"; +static char *saphir_rev = "$Revision: 1.1.4.1 $"; #define byteout(addr,val) outb(val,addr) #define bytein(addr) inb(addr) diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/isdn/hisax/sedlbauer.c linux-2.5/drivers/isdn/hisax/sedlbauer.c --- linux-2.5.1/drivers/isdn/hisax/sedlbauer.c Sun Sep 30 19:26:06 2001 +++ linux-2.5/drivers/isdn/hisax/sedlbauer.c Thu Dec 13 16:32:35 2001 @@ -1,4 +1,4 @@ -/* $Id: sedlbauer.c,v 1.25.6.6 2001/09/23 22:24:51 kai Exp $ +/* $Id: sedlbauer.c,v 1.1.4.1 2001/11/20 14:19:36 kai Exp $ * * low level stuff for Sedlbauer cards * includes support for the Sedlbauer speed star (speed star II), @@ -51,7 +51,7 @@ extern const char *CardType[]; -const char *Sedlbauer_revision = "$Revision: 1.25.6.6 $"; +const char *Sedlbauer_revision = "$Revision: 1.1.4.1 $"; const char *Sedlbauer_Types[] = {"None", "speed card/win", "speed star", "speed fax+", diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/isdn/hisax/sportster.c linux-2.5/drivers/isdn/hisax/sportster.c --- linux-2.5.1/drivers/isdn/hisax/sportster.c Sun Sep 30 19:26:06 2001 +++ linux-2.5/drivers/isdn/hisax/sportster.c Thu Dec 13 16:32:35 2001 @@ -1,4 +1,4 @@ -/* $Id: sportster.c,v 1.14.6.2 2001/09/23 22:24:51 kai Exp $ +/* $Id: sportster.c,v 1.1.4.1 2001/11/20 14:19:36 kai Exp $ * * low level stuff for USR Sportster internal TA * @@ -20,7 +20,7 @@ #include "isdnl1.h" extern const char *CardType[]; -const char *sportster_revision = "$Revision: 1.14.6.2 $"; +const char *sportster_revision = "$Revision: 1.1.4.1 $"; #define byteout(addr,val) outb(val,addr) #define bytein(addr) inb(addr) diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/isdn/hisax/st5481_init.c linux-2.5/drivers/isdn/hisax/st5481_init.c --- linux-2.5.1/drivers/isdn/hisax/st5481_init.c Sun Sep 30 19:26:06 2001 +++ linux-2.5/drivers/isdn/hisax/st5481_init.c Thu Dec 13 16:32:35 2001 @@ -178,7 +178,7 @@ static struct usb_driver st5481_usb_driver = { name: "st5481_usb", probe: probe_st5481, - disconnect: disconnect_st5481, + disconnect: __devexit_p(disconnect_st5481), id_table: st5481_ids, }; diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/isdn/hisax/tei.c linux-2.5/drivers/isdn/hisax/tei.c --- linux-2.5.1/drivers/isdn/hisax/tei.c Sun Sep 30 19:26:06 2001 +++ linux-2.5/drivers/isdn/hisax/tei.c Thu Dec 13 16:32:35 2001 @@ -1,4 +1,4 @@ -/* $Id: tei.c,v 2.17.6.3 2001/09/23 22:24:51 kai Exp $ +/* $Id: tei.c,v 1.1.4.1 2001/11/20 14:19:36 kai Exp $ * * Author Karsten Keil * based on the teles driver from Jan den Ouden @@ -21,7 +21,7 @@ #include <linux/init.h> #include <linux/random.h> -const char *tei_revision = "$Revision: 2.17.6.3 $"; +const char *tei_revision = "$Revision: 1.1.4.1 $"; #define ID_REQUEST 1 #define ID_ASSIGNED 2 diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/isdn/hisax/teleint.c linux-2.5/drivers/isdn/hisax/teleint.c --- linux-2.5.1/drivers/isdn/hisax/teleint.c Sun Sep 30 19:26:06 2001 +++ linux-2.5/drivers/isdn/hisax/teleint.c Thu Dec 13 16:32:35 2001 @@ -1,4 +1,4 @@ -/* $Id: teleint.c,v 1.14.6.2 2001/09/23 22:24:52 kai Exp $ +/* $Id: teleint.c,v 1.1.4.1 2001/11/20 14:19:36 kai Exp $ * * low level stuff for TeleInt isdn cards * @@ -19,7 +19,7 @@ extern const char *CardType[]; -const char *TeleInt_revision = "$Revision: 1.14.6.2 $"; +const char *TeleInt_revision = "$Revision: 1.1.4.1 $"; #define byteout(addr,val) outb(val,addr) #define bytein(addr) inb(addr) diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/isdn/hisax/teles0.c linux-2.5/drivers/isdn/hisax/teles0.c --- linux-2.5.1/drivers/isdn/hisax/teles0.c Sun Sep 30 19:26:06 2001 +++ linux-2.5/drivers/isdn/hisax/teles0.c Thu Dec 13 16:32:35 2001 @@ -1,4 +1,4 @@ -/* $Id: teles0.c,v 2.13.6.2 2001/09/23 22:24:52 kai Exp $ +/* $Id: teles0.c,v 1.1.4.1 2001/11/20 14:19:36 kai Exp $ * * low level stuff for Teles Memory IO isdn cards * @@ -24,7 +24,7 @@ extern const char *CardType[]; -const char *teles0_revision = "$Revision: 2.13.6.2 $"; +const char *teles0_revision = "$Revision: 1.1.4.1 $"; #define TELES_IOMEM_SIZE 0x400 #define byteout(addr,val) outb(val,addr) diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/isdn/hisax/teles3.c linux-2.5/drivers/isdn/hisax/teles3.c --- linux-2.5.1/drivers/isdn/hisax/teles3.c Sun Sep 30 19:26:06 2001 +++ linux-2.5/drivers/isdn/hisax/teles3.c Thu Dec 13 16:32:35 2001 @@ -1,4 +1,4 @@ -/* $Id: teles3.c,v 2.17.6.2 2001/09/23 22:24:52 kai Exp $ +/* $Id: teles3.c,v 1.1.4.1 2001/11/20 14:19:36 kai Exp $ * * low level stuff for Teles 16.3 & PNP isdn cards * @@ -21,7 +21,7 @@ #include "isdnl1.h" extern const char *CardType[]; -const char *teles3_revision = "$Revision: 2.17.6.2 $"; +const char *teles3_revision = "$Revision: 1.1.4.1 $"; #define byteout(addr,val) outb(val,addr) #define bytein(addr) inb(addr) diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/isdn/hisax/telespci.c linux-2.5/drivers/isdn/hisax/telespci.c --- linux-2.5.1/drivers/isdn/hisax/telespci.c Sun Sep 30 19:26:06 2001 +++ linux-2.5/drivers/isdn/hisax/telespci.c Thu Dec 13 16:32:35 2001 @@ -1,4 +1,4 @@ -/* $Id: telespci.c,v 2.16.6.5 2001/09/23 22:24:52 kai Exp $ +/* $Id: telespci.c,v 1.1.4.1 2001/11/20 14:19:36 kai Exp $ * * low level stuff for Teles PCI isdn cards * @@ -22,7 +22,7 @@ #include <linux/pci.h> extern const char *CardType[]; -const char *telespci_revision = "$Revision: 2.16.6.5 $"; +const char *telespci_revision = "$Revision: 1.1.4.1 $"; #define ZORAN_PO_RQ_PEN 0x02000000 #define ZORAN_PO_WR 0x00800000 diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/isdn/hisax/w6692.c linux-2.5/drivers/isdn/hisax/w6692.c --- linux-2.5.1/drivers/isdn/hisax/w6692.c Sun Sep 30 19:26:06 2001 +++ linux-2.5/drivers/isdn/hisax/w6692.c Thu Dec 13 16:32:35 2001 @@ -1,4 +1,4 @@ -/* $Id: w6692.c,v 1.12.6.6 2001/09/23 22:24:52 kai Exp $ +/* $Id: w6692.c,v 1.1.4.1 2001/11/20 14:19:36 kai Exp $ * * Winbond W6692 specific routines * @@ -36,7 +36,7 @@ extern const char *CardType[]; -const char *w6692_revision = "$Revision: 1.12.6.6 $"; +const char *w6692_revision = "$Revision: 1.1.4.1 $"; #define DBUSY_TIMER_VALUE 80 diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/isdn/hisax/w6692.h linux-2.5/drivers/isdn/hisax/w6692.h --- linux-2.5.1/drivers/isdn/hisax/w6692.h Sun Sep 30 19:26:06 2001 +++ linux-2.5/drivers/isdn/hisax/w6692.h Thu Dec 13 16:32:35 2001 @@ -1,4 +1,4 @@ -/* $Id: w6692.h,v 1.2.6.2 2001/09/23 22:24:52 kai Exp $ +/* $Id: w6692.h,v 1.1.4.1 2001/11/20 14:19:36 kai Exp $ * * Winbond W6692 specific defines * diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/isdn/hysdn/boardergo.c linux-2.5/drivers/isdn/hysdn/boardergo.c --- linux-2.5.1/drivers/isdn/hysdn/boardergo.c Fri Nov 9 21:41:42 2001 +++ linux-2.5/drivers/isdn/hysdn/boardergo.c Thu Dec 13 16:32:35 2001 @@ -1,4 +1,4 @@ -/* $Id: boardergo.c,v 1.5.6.7 2001/11/06 21:58:19 kai Exp $ +/* $Id: boardergo.c,v 1.1.4.1 2001/11/20 14:19:37 kai Exp $ * * Linux driver for HYSDN cards, specific routines for ergo type boards. * diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/isdn/hysdn/boardergo.h linux-2.5/drivers/isdn/hysdn/boardergo.h --- linux-2.5.1/drivers/isdn/hysdn/boardergo.h Sun Sep 30 19:26:06 2001 +++ linux-2.5/drivers/isdn/hysdn/boardergo.h Thu Dec 13 16:32:35 2001 @@ -1,4 +1,4 @@ -/* $Id: boardergo.h,v 1.2.6.1 2001/09/23 22:24:54 kai Exp $ +/* $Id: boardergo.h,v 1.1.4.1 2001/11/20 14:19:37 kai Exp $ * * Linux driver for HYSDN cards, definitions for ergo type boards (buffers..). * diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/isdn/hysdn/hycapi.c linux-2.5/drivers/isdn/hysdn/hycapi.c --- linux-2.5.1/drivers/isdn/hysdn/hycapi.c Sun Sep 30 19:26:06 2001 +++ linux-2.5/drivers/isdn/hysdn/hycapi.c Thu Dec 13 16:32:35 2001 @@ -1,4 +1,4 @@ -/* $Id: hycapi.c,v 1.8.6.4 2001/09/23 22:24:54 kai Exp $ +/* $Id: hycapi.c,v 1.1.4.1 2001/11/20 14:19:37 kai Exp $ * * Linux driver for HYSDN cards, CAPI2.0-Interface. * @@ -29,7 +29,7 @@ #include "hysdn_defs.h" #include <linux/kernelcapi.h> -static char hycapi_revision[]="$Revision: 1.8.6.4 $"; +static char hycapi_revision[]="$Revision: 1.1.4.1 $"; unsigned int hycapi_enable = 0xffffffff; MODULE_PARM(hycapi_enable, "i"); diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/isdn/hysdn/hysdn_boot.c linux-2.5/drivers/isdn/hysdn/hysdn_boot.c --- linux-2.5.1/drivers/isdn/hysdn/hysdn_boot.c Sun Sep 30 19:26:06 2001 +++ linux-2.5/drivers/isdn/hysdn/hysdn_boot.c Thu Dec 13 16:32:35 2001 @@ -1,4 +1,4 @@ -/* $Id: hysdn_boot.c,v 1.4.6.4 2001/09/23 22:24:54 kai Exp $ +/* $Id: hysdn_boot.c,v 1.1.4.1 2001/11/20 14:19:37 kai Exp $ * * Linux driver for HYSDN cards * specific routines for booting and pof handling diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/isdn/hysdn/hysdn_defs.h linux-2.5/drivers/isdn/hysdn/hysdn_defs.h --- linux-2.5.1/drivers/isdn/hysdn/hysdn_defs.h Sun Sep 30 19:26:06 2001 +++ linux-2.5/drivers/isdn/hysdn/hysdn_defs.h Thu Dec 13 16:32:35 2001 @@ -1,4 +1,4 @@ -/* $Id: hysdn_defs.h,v 1.5.6.3 2001/09/23 22:24:54 kai Exp $ +/* $Id: hysdn_defs.h,v 1.1.4.1 2001/11/20 14:19:37 kai Exp $ * * Linux driver for HYSDN cards * global definitions and exported vars and functions. diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/isdn/hysdn/hysdn_init.c linux-2.5/drivers/isdn/hysdn/hysdn_init.c --- linux-2.5.1/drivers/isdn/hysdn/hysdn_init.c Sun Sep 30 19:26:06 2001 +++ linux-2.5/drivers/isdn/hysdn/hysdn_init.c Thu Dec 13 16:32:35 2001 @@ -1,4 +1,4 @@ -/* $Id: hysdn_init.c,v 1.6.6.6 2001/09/23 22:24:54 kai Exp $ +/* $Id: hysdn_init.c,v 1.1.4.1 2001/11/20 14:19:37 kai Exp $ * * Linux driver for HYSDN cards, init functions. * @@ -33,7 +33,7 @@ MODULE_AUTHOR("Werner Cornelius"); MODULE_LICENSE("GPL"); -static char *hysdn_init_revision = "$Revision: 1.6.6.6 $"; +static char *hysdn_init_revision = "$Revision: 1.1.4.1 $"; int cardmax; /* number of found cards */ hysdn_card *card_root = NULL; /* pointer to first card */ diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/isdn/hysdn/hysdn_net.c linux-2.5/drivers/isdn/hysdn/hysdn_net.c --- linux-2.5.1/drivers/isdn/hysdn/hysdn_net.c Sun Sep 30 19:26:06 2001 +++ linux-2.5/drivers/isdn/hysdn/hysdn_net.c Thu Dec 13 16:32:35 2001 @@ -1,4 +1,4 @@ -/* $Id: hysdn_net.c,v 1.8.6.4 2001/09/23 22:24:54 kai Exp $ +/* $Id: hysdn_net.c,v 1.1.4.1 2001/11/20 14:19:37 kai Exp $ * * Linux driver for HYSDN cards, net (ethernet type) handling routines. * @@ -29,7 +29,7 @@ MODULE_PARM(hynet_enable, "i"); /* store the actual version for log reporting */ -char *hysdn_net_revision = "$Revision: 1.8.6.4 $"; +char *hysdn_net_revision = "$Revision: 1.1.4.1 $"; #define MAX_SKB_BUFFERS 20 /* number of buffers for keeping TX-data */ diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/isdn/hysdn/hysdn_pof.h linux-2.5/drivers/isdn/hysdn/hysdn_pof.h --- linux-2.5.1/drivers/isdn/hysdn/hysdn_pof.h Sun Sep 30 19:26:06 2001 +++ linux-2.5/drivers/isdn/hysdn/hysdn_pof.h Thu Dec 13 16:32:35 2001 @@ -1,4 +1,4 @@ -/* $Id: hysdn_pof.h,v 1.2.6.1 2001/09/23 22:24:54 kai Exp $ +/* $Id: hysdn_pof.h,v 1.1.4.1 2001/11/20 14:19:37 kai Exp $ * * Linux driver for HYSDN cards, definitions used for handling pof-files. * diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/isdn/hysdn/hysdn_procconf.c linux-2.5/drivers/isdn/hysdn/hysdn_procconf.c --- linux-2.5.1/drivers/isdn/hysdn/hysdn_procconf.c Sun Sep 30 19:26:06 2001 +++ linux-2.5/drivers/isdn/hysdn/hysdn_procconf.c Thu Dec 13 16:32:35 2001 @@ -1,4 +1,4 @@ -/* $Id: hysdn_procconf.c,v 1.8.6.4 2001/09/23 22:24:54 kai Exp $ +/* $Id: hysdn_procconf.c,v 1.1.4.1 2001/11/20 14:19:37 kai Exp $ * * Linux driver for HYSDN cards, /proc/net filesystem dir and conf functions. * @@ -21,7 +21,7 @@ #include "hysdn_defs.h" -static char *hysdn_procconf_revision = "$Revision: 1.8.6.4 $"; +static char *hysdn_procconf_revision = "$Revision: 1.1.4.1 $"; #define INFO_OUT_LEN 80 /* length of info line including lf */ diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/isdn/hysdn/hysdn_proclog.c linux-2.5/drivers/isdn/hysdn/hysdn_proclog.c --- linux-2.5.1/drivers/isdn/hysdn/hysdn_proclog.c Sun Sep 30 19:26:06 2001 +++ linux-2.5/drivers/isdn/hysdn/hysdn_proclog.c Thu Dec 13 16:32:35 2001 @@ -1,4 +1,4 @@ -/* $Id: hysdn_proclog.c,v 1.9.6.3 2001/09/23 22:24:54 kai Exp $ +/* $Id: hysdn_proclog.c,v 1.1.4.1 2001/11/20 14:19:37 kai Exp $ * * Linux driver for HYSDN cards, /proc/net filesystem log functions. * diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/isdn/hysdn/hysdn_sched.c linux-2.5/drivers/isdn/hysdn/hysdn_sched.c --- linux-2.5.1/drivers/isdn/hysdn/hysdn_sched.c Fri Nov 9 21:41:42 2001 +++ linux-2.5/drivers/isdn/hysdn/hysdn_sched.c Thu Dec 13 16:32:35 2001 @@ -1,4 +1,4 @@ -/* $Id: hysdn_sched.c,v 1.5.6.4 2001/11/06 21:58:19 kai Exp $ +/* $Id: hysdn_sched.c,v 1.1.4.1 2001/11/20 14:19:37 kai Exp $ * * Linux driver for HYSDN cards * scheduler routines for handling exchange card <-> pc. diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/isdn/icn/icn.c linux-2.5/drivers/isdn/icn/icn.c --- linux-2.5.1/drivers/isdn/icn/icn.c Sun Sep 30 19:26:06 2001 +++ linux-2.5/drivers/isdn/icn/icn.c Thu Dec 13 16:32:35 2001 @@ -1,4 +1,4 @@ -/* $Id: icn.c,v 1.65.6.8 2001/09/23 22:24:55 kai Exp $ +/* $Id: icn.c,v 1.1.4.1 2001/11/20 14:19:37 kai Exp $ * * ISDN low-level module for the ICN active ISDN-Card. * @@ -41,7 +41,7 @@ #undef MAP_DEBUG static char -*revision = "$Revision: 1.65.6.8 $"; +*revision = "$Revision: 1.1.4.1 $"; static int icn_addcard(int, char *, char *); diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/isdn/icn/icn.h linux-2.5/drivers/isdn/icn/icn.h --- linux-2.5.1/drivers/isdn/icn/icn.h Sun Sep 30 19:26:06 2001 +++ linux-2.5/drivers/isdn/icn/icn.h Sun Dec 30 21:17:30 2001 @@ -1,4 +1,4 @@ -/* $Id: icn.h,v 1.30.6.5 2001/09/23 22:24:55 kai Exp $ +/* $Id: icn.h,v 1.1.4.1 2001/11/20 14:19:37 kai Exp $ * * ISDN lowlevel-module for the ICN active ISDN-Card. * @@ -39,7 +39,6 @@ #include <linux/errno.h> #include <linux/fs.h> #include <linux/major.h> -#include <asm/segment.h> #include <asm/io.h> #include <linux/kernel.h> #include <linux/signal.h> diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/isdn/isdn_audio.c linux-2.5/drivers/isdn/isdn_audio.c --- linux-2.5.1/drivers/isdn/isdn_audio.c Sun Sep 30 19:26:06 2001 +++ linux-2.5/drivers/isdn/isdn_audio.c Thu Dec 13 16:32:35 2001 @@ -1,4 +1,4 @@ -/* $Id: isdn_audio.c,v 1.21.6.2 2001/09/23 22:24:31 kai Exp $ +/* $Id: isdn_audio.c,v 1.1.4.1 2001/11/20 14:19:33 kai Exp $ * * Linux ISDN subsystem, audio conversion and compression (linklevel). * @@ -15,7 +15,7 @@ #include "isdn_audio.h" #include "isdn_common.h" -char *isdn_audio_revision = "$Revision: 1.21.6.2 $"; +char *isdn_audio_revision = "$Revision: 1.1.4.1 $"; /* * Misc. lookup-tables. diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/isdn/isdn_audio.h linux-2.5/drivers/isdn/isdn_audio.h --- linux-2.5.1/drivers/isdn/isdn_audio.h Sun Sep 30 19:26:06 2001 +++ linux-2.5/drivers/isdn/isdn_audio.h Thu Dec 13 16:32:35 2001 @@ -1,4 +1,4 @@ -/* $Id: isdn_audio.h,v 1.9.6.1 2001/09/23 22:24:31 kai Exp $ +/* $Id: isdn_audio.h,v 1.1.4.1 2001/11/20 14:19:34 kai Exp $ * * Linux ISDN subsystem, audio conversion and compression (linklevel). * diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/isdn/isdn_bsdcomp.c linux-2.5/drivers/isdn/isdn_bsdcomp.c --- linux-2.5.1/drivers/isdn/isdn_bsdcomp.c Sun Sep 30 19:26:06 2001 +++ linux-2.5/drivers/isdn/isdn_bsdcomp.c Sun Dec 30 21:17:30 2001 @@ -71,7 +71,6 @@ #include <asm/system.h> #include <asm/bitops.h> -#include <asm/segment.h> #include <asm/byteorder.h> #include <asm/types.h> diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/isdn/isdn_common.c linux-2.5/drivers/isdn/isdn_common.c --- linux-2.5.1/drivers/isdn/isdn_common.c Fri Nov 9 21:41:41 2001 +++ linux-2.5/drivers/isdn/isdn_common.c Thu Dec 13 16:32:35 2001 @@ -1,4 +1,4 @@ -/* $Id: isdn_common.c,v 1.114.6.16 2001/11/06 20:58:28 kai Exp $ +/* $Id: isdn_common.c,v 1.1.4.1 2001/11/20 14:19:34 kai Exp $ * * Linux ISDN subsystem, common used functions (linklevel). * @@ -44,7 +44,7 @@ isdn_dev *dev; -static char *isdn_revision = "$Revision: 1.114.6.16 $"; +static char *isdn_revision = "$Revision: 1.1.4.1 $"; extern char *isdn_net_revision; extern char *isdn_tty_revision; diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/isdn/isdn_common.h linux-2.5/drivers/isdn/isdn_common.h --- linux-2.5.1/drivers/isdn/isdn_common.h Sun Sep 30 19:26:06 2001 +++ linux-2.5/drivers/isdn/isdn_common.h Thu Dec 13 16:32:35 2001 @@ -1,4 +1,4 @@ -/* $Id: isdn_common.h,v 1.21.6.1 2001/09/23 22:24:31 kai Exp $ +/* $Id: isdn_common.h,v 1.1.4.1 2001/11/20 14:19:34 kai Exp $ * * header for Linux ISDN subsystem * common used functions and debugging-switches (linklevel). diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/isdn/isdn_concap.c linux-2.5/drivers/isdn/isdn_concap.c --- linux-2.5.1/drivers/isdn/isdn_concap.c Sun Sep 30 19:26:06 2001 +++ linux-2.5/drivers/isdn/isdn_concap.c Thu Dec 13 16:32:35 2001 @@ -1,4 +1,4 @@ -/* $Id: isdn_concap.c,v 1.8.6.1 2001/09/23 22:24:31 kai Exp $ +/* $Id: isdn_concap.c,v 1.1.4.1 2001/11/20 14:19:34 kai Exp $ * * Linux ISDN subsystem, protocol encapsulation * diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/isdn/isdn_concap.h linux-2.5/drivers/isdn/isdn_concap.h --- linux-2.5.1/drivers/isdn/isdn_concap.h Sun Sep 30 19:26:06 2001 +++ linux-2.5/drivers/isdn/isdn_concap.h Thu Dec 13 16:32:35 2001 @@ -1,4 +1,4 @@ -/* $Id: isdn_concap.h,v 1.3.6.1 2001/09/23 22:24:31 kai Exp $ +/* $Id: isdn_concap.h,v 1.1.4.1 2001/11/20 14:19:34 kai Exp $ * * Linux ISDN subsystem, protocol encapsulation * diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/isdn/isdn_net.c linux-2.5/drivers/isdn/isdn_net.c --- linux-2.5.1/drivers/isdn/isdn_net.c Fri Nov 9 21:41:41 2001 +++ linux-2.5/drivers/isdn/isdn_net.c Thu Dec 13 16:32:35 2001 @@ -1,4 +1,4 @@ -/* $Id: isdn_net.c,v 1.140.6.11 2001/11/06 20:58:28 kai Exp $ +/* $Id: isdn_net.c,v 1.1.4.1 2001/11/20 14:19:34 kai Exp $ * * Linux ISDN subsystem, network interfaces and related functions (linklevel). * @@ -175,7 +175,7 @@ static void isdn_net_ciscohdlck_connected(isdn_net_local *lp); static void isdn_net_ciscohdlck_disconnected(isdn_net_local *lp); -char *isdn_net_revision = "$Revision: 1.140.6.11 $"; +char *isdn_net_revision = "$Revision: 1.1.4.1 $"; /* * Code for raw-networking over ISDN diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/isdn/isdn_net.h linux-2.5/drivers/isdn/isdn_net.h --- linux-2.5.1/drivers/isdn/isdn_net.h Sun Sep 30 19:26:06 2001 +++ linux-2.5/drivers/isdn/isdn_net.h Thu Dec 13 16:32:35 2001 @@ -1,4 +1,4 @@ -/* $Id: isdn_net.h,v 1.19.6.4 2001/09/28 08:05:29 kai Exp $ +/* $Id: isdn_net.h,v 1.1.4.1 2001/11/20 14:19:34 kai Exp $ * * header for Linux ISDN subsystem, network related functions (linklevel). * diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/isdn/isdn_ppp.c linux-2.5/drivers/isdn/isdn_ppp.c --- linux-2.5.1/drivers/isdn/isdn_ppp.c Fri Nov 9 21:41:41 2001 +++ linux-2.5/drivers/isdn/isdn_ppp.c Thu Dec 13 16:32:35 2001 @@ -1,4 +1,4 @@ -/* $Id: isdn_ppp.c,v 1.85.6.9 2001/11/06 20:58:28 kai Exp $ +/* $Id: isdn_ppp.c,v 1.1.4.1 2001/11/20 14:19:34 kai Exp $ * * Linux ISDN subsystem, functions for synchronous PPP (linklevel). * @@ -69,7 +69,7 @@ static int isdn_ppp_bundle(struct ippp_struct *, int unit); #endif /* CONFIG_ISDN_MPP */ -char *isdn_ppp_revision = "$Revision: 1.85.6.9 $"; +char *isdn_ppp_revision = "$Revision: 1.1.4.1 $"; static struct ippp_struct *ippp_table[ISDN_MAX_CHANNELS]; diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/isdn/isdn_ppp.h linux-2.5/drivers/isdn/isdn_ppp.h --- linux-2.5.1/drivers/isdn/isdn_ppp.h Sun Sep 30 19:26:06 2001 +++ linux-2.5/drivers/isdn/isdn_ppp.h Thu Dec 13 16:32:35 2001 @@ -1,4 +1,4 @@ -/* $Id: isdn_ppp.h,v 1.17.6.1 2001/09/23 22:24:32 kai Exp $ +/* $Id: isdn_ppp.h,v 1.1.4.1 2001/11/20 14:19:34 kai Exp $ * * header for Linux ISDN subsystem, functions for synchronous PPP (linklevel). * diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/isdn/isdn_tty.c linux-2.5/drivers/isdn/isdn_tty.c --- linux-2.5.1/drivers/isdn/isdn_tty.c Fri Nov 9 21:41:41 2001 +++ linux-2.5/drivers/isdn/isdn_tty.c Thu Dec 13 16:32:35 2001 @@ -1,4 +1,4 @@ -/* $Id: isdn_tty.c,v 1.94.6.9 2001/11/06 20:58:29 kai Exp $ +/* $Id: isdn_tty.c,v 1.1.4.1 2001/11/20 14:19:34 kai Exp $ * * Linux ISDN subsystem, tty functions and AT-command emulator (linklevel). * @@ -53,7 +53,7 @@ static int si2bit[8] = {4, 1, 4, 4, 4, 4, 4, 4}; -char *isdn_tty_revision = "$Revision: 1.94.6.9 $"; +char *isdn_tty_revision = "$Revision: 1.1.4.1 $"; /* isdn_tty_try_read() is called from within isdn_tty_rcv_skb() diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/isdn/isdn_tty.h linux-2.5/drivers/isdn/isdn_tty.h --- linux-2.5.1/drivers/isdn/isdn_tty.h Sun Sep 30 19:26:06 2001 +++ linux-2.5/drivers/isdn/isdn_tty.h Thu Dec 13 16:32:35 2001 @@ -1,4 +1,4 @@ -/* $Id: isdn_tty.h,v 1.22.6.2 2001/09/23 22:24:32 kai Exp $ +/* $Id: isdn_tty.h,v 1.1.4.1 2001/11/20 14:19:34 kai Exp $ * * header for Linux ISDN subsystem, tty related functions (linklevel). * diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/isdn/isdn_ttyfax.c linux-2.5/drivers/isdn/isdn_ttyfax.c --- linux-2.5.1/drivers/isdn/isdn_ttyfax.c Sun Sep 30 19:26:06 2001 +++ linux-2.5/drivers/isdn/isdn_ttyfax.c Thu Dec 13 16:32:35 2001 @@ -1,4 +1,4 @@ -/* $Id: isdn_ttyfax.c,v 1.7.6.2 2001/09/23 22:24:32 kai Exp $ +/* $Id: isdn_ttyfax.c,v 1.1.4.1 2001/11/20 14:19:34 kai Exp $ * * Linux ISDN subsystem, tty_fax AT-command emulator (linklevel). * @@ -20,7 +20,7 @@ #include "isdn_ttyfax.h" -static char *isdn_tty_fax_revision = "$Revision: 1.7.6.2 $"; +static char *isdn_tty_fax_revision = "$Revision: 1.1.4.1 $"; #define PARSE_ERROR1 { isdn_tty_fax_modem_result(1, info); return 1; } diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/isdn/isdn_ttyfax.h linux-2.5/drivers/isdn/isdn_ttyfax.h --- linux-2.5.1/drivers/isdn/isdn_ttyfax.h Sun Sep 30 19:26:06 2001 +++ linux-2.5/drivers/isdn/isdn_ttyfax.h Thu Dec 13 16:32:35 2001 @@ -1,4 +1,4 @@ -/* $Id: isdn_ttyfax.h,v 1.2.6.1 2001/09/23 22:24:32 kai Exp $ +/* $Id: isdn_ttyfax.h,v 1.1.4.1 2001/11/20 14:19:34 kai Exp $ * * header for Linux ISDN subsystem, tty_fax related functions (linklevel). * diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/isdn/isdn_v110.c linux-2.5/drivers/isdn/isdn_v110.c --- linux-2.5.1/drivers/isdn/isdn_v110.c Sun Sep 30 19:26:06 2001 +++ linux-2.5/drivers/isdn/isdn_v110.c Thu Dec 13 16:32:35 2001 @@ -1,4 +1,4 @@ -/* $Id: isdn_v110.c,v 1.5.6.4 2001/09/23 22:24:32 kai Exp $ +/* $Id: isdn_v110.c,v 1.1.4.1 2001/11/20 14:19:34 kai Exp $ * * Linux ISDN subsystem, V.110 related functions (linklevel). * @@ -19,7 +19,7 @@ #undef ISDN_V110_DEBUG -char *isdn_v110_revision = "$Revision: 1.5.6.4 $"; +char *isdn_v110_revision = "$Revision: 1.1.4.1 $"; #define V110_38400 255 #define V110_19200 15 diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/isdn/isdn_v110.h linux-2.5/drivers/isdn/isdn_v110.h --- linux-2.5.1/drivers/isdn/isdn_v110.h Sun Sep 30 19:26:06 2001 +++ linux-2.5/drivers/isdn/isdn_v110.h Thu Dec 13 16:32:35 2001 @@ -1,4 +1,4 @@ -/* $Id: isdn_v110.h,v 1.4.6.1 2001/09/23 22:24:32 kai Exp $ +/* $Id: isdn_v110.h,v 1.1.4.1 2001/11/20 14:19:34 kai Exp $ * * Linux ISDN subsystem, V.110 related functions (linklevel). * diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/isdn/isdn_x25iface.c linux-2.5/drivers/isdn/isdn_x25iface.c --- linux-2.5.1/drivers/isdn/isdn_x25iface.c Sun Sep 30 19:26:06 2001 +++ linux-2.5/drivers/isdn/isdn_x25iface.c Thu Dec 13 16:32:35 2001 @@ -1,4 +1,4 @@ -/* $Id: isdn_x25iface.c,v 1.9.6.1 2001/09/23 22:24:32 kai Exp $ +/* $Id: isdn_x25iface.c,v 1.1.4.1 2001/11/20 14:19:34 kai Exp $ * * Linux ISDN subsystem, X.25 related functions * diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/isdn/isdn_x25iface.h linux-2.5/drivers/isdn/isdn_x25iface.h --- linux-2.5.1/drivers/isdn/isdn_x25iface.h Sun Sep 30 19:26:06 2001 +++ linux-2.5/drivers/isdn/isdn_x25iface.h Thu Dec 13 16:32:35 2001 @@ -1,4 +1,4 @@ -/* $Id: isdn_x25iface.h,v 1.3.6.1 2001/09/23 22:24:32 kai Exp $ +/* $Id: isdn_x25iface.h,v 1.1.4.1 2001/11/20 14:19:34 kai Exp $ * * header for Linux ISDN subsystem, x.25 related functions * diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/isdn/isdnloop/isdnloop.c linux-2.5/drivers/isdn/isdnloop/isdnloop.c --- linux-2.5.1/drivers/isdn/isdnloop/isdnloop.c Mon Nov 12 18:02:54 2001 +++ linux-2.5/drivers/isdn/isdnloop/isdnloop.c Thu Dec 13 16:32:36 2001 @@ -1,4 +1,4 @@ -/* $Id: isdnloop.c,v 1.11.6.7 2001/11/11 19:54:31 kai Exp $ +/* $Id: isdnloop.c,v 1.1.4.1 2001/11/20 14:19:37 kai Exp $ * * ISDN low-level module implementing a dummy loop driver. * @@ -14,7 +14,7 @@ #include <linux/init.h> #include "isdnloop.h" -static char *revision = "$Revision: 1.11.6.7 $"; +static char *revision = "$Revision: 1.1.4.1 $"; static char *isdnloop_id; MODULE_DESCRIPTION("ISDN4Linux: Pseudo Driver that simulates an ISDN card"); diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/isdn/isdnloop/isdnloop.h linux-2.5/drivers/isdn/isdnloop/isdnloop.h --- linux-2.5.1/drivers/isdn/isdnloop/isdnloop.h Sun Sep 30 19:26:06 2001 +++ linux-2.5/drivers/isdn/isdnloop/isdnloop.h Sun Dec 30 21:17:30 2001 @@ -1,4 +1,4 @@ -/* $Id: isdnloop.h,v 1.5.6.3 2001/09/23 22:24:56 kai Exp $ +/* $Id: isdnloop.h,v 1.1.4.1 2001/11/20 14:19:37 kai Exp $ * * Loopback lowlevel module for testing of linklevel. * @@ -37,7 +37,6 @@ #include <linux/errno.h> #include <linux/fs.h> #include <linux/major.h> -#include <asm/segment.h> #include <asm/io.h> #include <linux/kernel.h> #include <linux/signal.h> diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/isdn/sc/card.h linux-2.5/drivers/isdn/sc/card.h --- linux-2.5.1/drivers/isdn/sc/card.h Sun Sep 30 19:26:06 2001 +++ linux-2.5/drivers/isdn/sc/card.h Thu Dec 13 16:32:36 2001 @@ -1,4 +1,4 @@ -/* $Id: card.h,v 1.1.10.1 2001/09/23 22:24:59 kai Exp $ +/* $Id: card.h,v 1.1.4.1 2001/11/20 14:19:37 kai Exp $ * * Driver parameters for SpellCaster ISA ISDN adapters * diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/isdn/sc/command.c linux-2.5/drivers/isdn/sc/command.c --- linux-2.5.1/drivers/isdn/sc/command.c Sun Sep 30 19:26:06 2001 +++ linux-2.5/drivers/isdn/sc/command.c Thu Dec 13 16:32:36 2001 @@ -1,4 +1,4 @@ -/* $Id: command.c,v 1.4.10.1 2001/09/23 22:24:59 kai Exp $ +/* $Id: command.c,v 1.1.4.1 2001/11/20 14:19:37 kai Exp $ * * Copyright (C) 1996 SpellCaster Telecommunications Inc. * diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/isdn/sc/debug.c linux-2.5/drivers/isdn/sc/debug.c --- linux-2.5.1/drivers/isdn/sc/debug.c Sun Sep 30 19:26:06 2001 +++ linux-2.5/drivers/isdn/sc/debug.c Thu Dec 13 16:32:36 2001 @@ -1,4 +1,4 @@ -/* $Id: debug.c,v 1.5.6.1 2001/09/23 22:24:59 kai Exp $ +/* $Id: debug.c,v 1.1.4.1 2001/11/20 14:19:37 kai Exp $ * * Copyright (C) 1996 SpellCaster Telecommunications Inc. * diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/isdn/sc/debug.h linux-2.5/drivers/isdn/sc/debug.h --- linux-2.5.1/drivers/isdn/sc/debug.h Sun Sep 30 19:26:06 2001 +++ linux-2.5/drivers/isdn/sc/debug.h Thu Dec 13 16:32:36 2001 @@ -1,4 +1,4 @@ -/* $Id: debug.h,v 1.2.8.1 2001/09/23 22:24:59 kai Exp $ +/* $Id: debug.h,v 1.1.4.1 2001/11/20 14:19:37 kai Exp $ * * Copyright (C) 1996 SpellCaster Telecommunications Inc. * diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/isdn/sc/event.c linux-2.5/drivers/isdn/sc/event.c --- linux-2.5.1/drivers/isdn/sc/event.c Sun Sep 30 19:26:06 2001 +++ linux-2.5/drivers/isdn/sc/event.c Thu Dec 13 16:32:36 2001 @@ -1,4 +1,4 @@ -/* $Id: event.c,v 1.4.8.1 2001/09/23 22:24:59 kai Exp $ +/* $Id: event.c,v 1.1.4.1 2001/11/20 14:19:37 kai Exp $ * * Copyright (C) 1996 SpellCaster Telecommunications Inc. * diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/isdn/sc/includes.h linux-2.5/drivers/isdn/sc/includes.h --- linux-2.5.1/drivers/isdn/sc/includes.h Sun Sep 30 19:26:06 2001 +++ linux-2.5/drivers/isdn/sc/includes.h Sun Dec 30 21:17:30 2001 @@ -6,7 +6,6 @@ #include <linux/version.h> #include <linux/errno.h> -#include <asm/segment.h> #include <asm/io.h> #include <linux/delay.h> #include <linux/kernel.h> diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/isdn/sc/interrupt.c linux-2.5/drivers/isdn/sc/interrupt.c --- linux-2.5.1/drivers/isdn/sc/interrupt.c Sun Sep 30 19:26:06 2001 +++ linux-2.5/drivers/isdn/sc/interrupt.c Thu Dec 13 16:32:36 2001 @@ -1,4 +1,4 @@ -/* $Id: interrupt.c,v 1.4.8.3 2001/09/23 22:24:59 kai Exp $ +/* $Id: interrupt.c,v 1.1.4.1 2001/11/20 14:19:37 kai Exp $ * * Copyright (C) 1996 SpellCaster Telecommunications Inc. * diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/isdn/sc/message.c linux-2.5/drivers/isdn/sc/message.c --- linux-2.5.1/drivers/isdn/sc/message.c Sun Sep 30 19:26:06 2001 +++ linux-2.5/drivers/isdn/sc/message.c Thu Dec 13 16:32:36 2001 @@ -1,4 +1,4 @@ -/* $Id: message.c,v 1.5.8.2 2001/09/23 22:24:59 kai Exp $ +/* $Id: message.c,v 1.1.4.1 2001/11/20 14:19:37 kai Exp $ * * functions for sending and receiving control messages * diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/isdn/sc/message.h linux-2.5/drivers/isdn/sc/message.h --- linux-2.5.1/drivers/isdn/sc/message.h Sun Sep 30 19:26:06 2001 +++ linux-2.5/drivers/isdn/sc/message.h Thu Dec 13 16:32:36 2001 @@ -1,4 +1,4 @@ -/* $Id: message.h,v 1.1.10.1 2001/09/23 22:24:59 kai Exp $ +/* $Id: message.h,v 1.1.4.1 2001/11/20 14:19:37 kai Exp $ * * Copyright (C) 1996 SpellCaster Telecommunications Inc. * diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/isdn/sc/packet.c linux-2.5/drivers/isdn/sc/packet.c --- linux-2.5.1/drivers/isdn/sc/packet.c Sun Sep 30 19:26:06 2001 +++ linux-2.5/drivers/isdn/sc/packet.c Thu Dec 13 16:32:36 2001 @@ -1,4 +1,4 @@ -/* $Id: packet.c,v 1.5.8.1 2001/09/23 22:24:59 kai Exp $ +/* $Id: packet.c,v 1.1.4.1 2001/11/20 14:19:37 kai Exp $ * * Copyright (C) 1996 SpellCaster Telecommunications Inc. * diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/isdn/sc/shmem.c linux-2.5/drivers/isdn/sc/shmem.c --- linux-2.5.1/drivers/isdn/sc/shmem.c Sun Sep 30 19:26:06 2001 +++ linux-2.5/drivers/isdn/sc/shmem.c Thu Dec 13 16:32:36 2001 @@ -1,4 +1,4 @@ -/* $Id: shmem.c,v 1.2.10.1 2001/09/23 22:24:59 kai Exp $ +/* $Id: shmem.c,v 1.1.4.1 2001/11/20 14:19:37 kai Exp $ * * Copyright (C) 1996 SpellCaster Telecommunications Inc. * diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/isdn/sc/timer.c linux-2.5/drivers/isdn/sc/timer.c --- linux-2.5.1/drivers/isdn/sc/timer.c Sun Sep 30 19:26:06 2001 +++ linux-2.5/drivers/isdn/sc/timer.c Thu Dec 13 16:32:36 2001 @@ -1,4 +1,4 @@ -/* $Id: timer.c,v 1.3.6.1 2001/09/23 22:24:59 kai Exp $ +/* $Id: timer.c,v 1.1.4.1 2001/11/20 14:19:37 kai Exp $ * * Copyright (C) 1996 SpellCaster Telecommunications Inc. * diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/isdn/tpam/tpam.h linux-2.5/drivers/isdn/tpam/tpam.h --- linux-2.5.1/drivers/isdn/tpam/tpam.h Fri Nov 9 21:41:41 2001 +++ linux-2.5/drivers/isdn/tpam/tpam.h Thu Dec 13 16:32:36 2001 @@ -1,4 +1,4 @@ -/* $Id: tpam.h,v 1.1.2.3 2001/11/06 20:58:30 kai Exp $ +/* $Id: tpam.h,v 1.1.2.1 2001/11/20 14:19:37 kai Exp $ * * Turbo PAM ISDN driver for Linux. (Kernel Driver) * diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/isdn/tpam/tpam_commands.c linux-2.5/drivers/isdn/tpam/tpam_commands.c --- linux-2.5.1/drivers/isdn/tpam/tpam_commands.c Fri Nov 9 21:41:41 2001 +++ linux-2.5/drivers/isdn/tpam/tpam_commands.c Thu Dec 13 16:32:36 2001 @@ -1,4 +1,4 @@ -/* $Id: tpam_commands.c,v 1.1.2.4 2001/11/06 20:58:30 kai Exp $ +/* $Id: tpam_commands.c,v 1.1.2.1 2001/11/20 14:19:37 kai Exp $ * * Turbo PAM ISDN driver for Linux. (Kernel Driver - ISDN commands) * diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/isdn/tpam/tpam_crcpc.c linux-2.5/drivers/isdn/tpam/tpam_crcpc.c --- linux-2.5.1/drivers/isdn/tpam/tpam_crcpc.c Sun Sep 30 19:26:06 2001 +++ linux-2.5/drivers/isdn/tpam/tpam_crcpc.c Thu Dec 13 16:32:36 2001 @@ -1,4 +1,4 @@ -/* $Id: tpam_crcpc.c,v 1.1.2.2 2001/09/23 22:25:03 kai Exp $ +/* $Id: tpam_crcpc.c,v 1.1.2.1 2001/11/20 14:19:37 kai Exp $ * * Turbo PAM ISDN driver for Linux. (Kernel Driver - CRC encoding) * diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/isdn/tpam/tpam_hdlc.c linux-2.5/drivers/isdn/tpam/tpam_hdlc.c --- linux-2.5.1/drivers/isdn/tpam/tpam_hdlc.c Fri Nov 9 21:41:41 2001 +++ linux-2.5/drivers/isdn/tpam/tpam_hdlc.c Thu Dec 13 16:32:36 2001 @@ -1,4 +1,4 @@ -/* $Id: tpam_hdlc.c,v 1.1.2.3 2001/11/06 20:58:30 kai Exp $ +/* $Id: tpam_hdlc.c,v 1.1.2.1 2001/11/20 14:19:37 kai Exp $ * * Turbo PAM ISDN driver for Linux. (Kernel Driver - HDLC encoding) * diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/isdn/tpam/tpam_main.c linux-2.5/drivers/isdn/tpam/tpam_main.c --- linux-2.5.1/drivers/isdn/tpam/tpam_main.c Sun Sep 30 19:26:06 2001 +++ linux-2.5/drivers/isdn/tpam/tpam_main.c Thu Dec 13 16:32:36 2001 @@ -1,4 +1,4 @@ -/* $Id: tpam_main.c,v 1.1.2.3 2001/09/23 22:25:03 kai Exp $ +/* $Id: tpam_main.c,v 1.1.2.2 2001/12/09 18:45:14 kai Exp $ * * Turbo PAM ISDN driver for Linux. (Kernel Driver - main routines) * @@ -254,7 +254,7 @@ name: "tpam", id_table: tpam_pci_tbl, probe: tpam_probe, - remove: tpam_remove, + remove: __devexit_p(tpam_remove), }; static int __init tpam_init(void) { diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/isdn/tpam/tpam_memory.c linux-2.5/drivers/isdn/tpam/tpam_memory.c --- linux-2.5.1/drivers/isdn/tpam/tpam_memory.c Sun Sep 30 19:26:06 2001 +++ linux-2.5/drivers/isdn/tpam/tpam_memory.c Thu Dec 13 16:32:36 2001 @@ -1,4 +1,4 @@ -/* $Id: tpam_memory.c,v 1.1.2.2 2001/09/23 22:25:03 kai Exp $ +/* $Id: tpam_memory.c,v 1.1.2.1 2001/11/20 14:19:37 kai Exp $ * * Turbo PAM ISDN driver for Linux. (Kernel Driver - Board Memory Access) * diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/isdn/tpam/tpam_nco.c linux-2.5/drivers/isdn/tpam/tpam_nco.c --- linux-2.5.1/drivers/isdn/tpam/tpam_nco.c Sun Sep 30 19:26:06 2001 +++ linux-2.5/drivers/isdn/tpam/tpam_nco.c Thu Dec 13 16:32:36 2001 @@ -1,4 +1,4 @@ -/* $Id: tpam_nco.c,v 1.1.2.2 2001/09/23 22:25:03 kai Exp $ +/* $Id: tpam_nco.c,v 1.1.2.1 2001/11/20 14:19:37 kai Exp $ * * Turbo PAM ISDN driver for Linux. * (Kernel Driver - Low Level NCO Manipulation) diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/isdn/tpam/tpam_queues.c linux-2.5/drivers/isdn/tpam/tpam_queues.c --- linux-2.5.1/drivers/isdn/tpam/tpam_queues.c Sun Sep 30 19:26:06 2001 +++ linux-2.5/drivers/isdn/tpam/tpam_queues.c Thu Dec 13 16:32:36 2001 @@ -1,4 +1,4 @@ -/* $Id: tpam_queues.c,v 1.1.2.2 2001/09/23 22:25:03 kai Exp $ +/* $Id: tpam_queues.c,v 1.1.2.1 2001/11/20 14:19:37 kai Exp $ * * Turbo PAM ISDN driver for Linux. (Kernel Driver) * diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/macintosh/Makefile linux-2.5/drivers/macintosh/Makefile --- linux-2.5.1/drivers/macintosh/Makefile Thu Aug 30 03:49:36 2001 +++ linux-2.5/drivers/macintosh/Makefile Thu Dec 27 16:32:31 2001 @@ -32,9 +32,11 @@ obj-$(CONFIG_MAC_HID) += mac_hid.o obj-$(CONFIG_INPUT_ADBHID) += adbhid.o obj-$(CONFIG_PPC_RTC) += rtc.o +obj-$(CONFIG_ANSLCD) += ans-lcd.o obj-$(CONFIG_ADB_PMU) += via-pmu.o obj-$(CONFIG_ADB_CUDA) += via-cuda.o +obj-$(CONFIG_PMAC_APM_EMU) += apm_emu.o obj-$(CONFIG_ADB) += adb.o obj-$(CONFIG_ADB_KEYBOARD) += mac_keyb.o diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/macintosh/adb.c linux-2.5/drivers/macintosh/adb.c --- linux-2.5.1/drivers/macintosh/adb.c Fri Nov 30 16:26:04 2001 +++ linux-2.5/drivers/macintosh/adb.c Thu Dec 27 16:32:31 2001 @@ -34,6 +34,7 @@ #include <linux/wait.h> #include <linux/init.h> #include <linux/delay.h> +#include <linux/completion.h> #include <asm/uaccess.h> #ifdef CONFIG_PPC #include <asm/prom.h> @@ -78,7 +79,7 @@ static int adb_inited = 0; static pid_t adb_probe_task_pid; static int adb_probe_task_flag; -static wait_queue_head_t adb_probe_task_wq; +static struct completion adb_probe_task_comp; static int sleepy_trackpad; int __adb_probe_sync; @@ -318,7 +319,7 @@ if (machine_is_compatible("AAPL,PowerBook1998") || machine_is_compatible("PowerBook1,1")) sleepy_trackpad = 1; - init_waitqueue_head(&adb_probe_task_wq); + init_completion(&adb_probe_task_comp); adbdev_init(); adb_reset_bus(); } @@ -435,7 +436,7 @@ static void adb_probe_wakeup(struct adb_request *req) { - wake_up(&adb_probe_task_wq); + complete(&adb_probe_task_comp); } static struct adb_request adb_sreq; @@ -484,20 +485,11 @@ if ((flags & ADBREQ_SYNC) && (current->pid && adb_probe_task_pid && adb_probe_task_pid == current->pid)) { - DECLARE_WAITQUEUE(wait, current); req->done = adb_probe_wakeup; - add_wait_queue(&adb_probe_task_wq, &wait); rc = adb_controller->send_request(req, 0); if (rc || req->complete) goto bail; - for (;;) { - set_current_state(TASK_UNINTERRUPTIBLE); - if (req->complete) - break; - schedule(); - } - current->state = TASK_RUNNING; - remove_wait_queue(&adb_probe_task_wq, &wait); + wait_for_completion(&adb_probe_task_comp); rc = 0; goto bail; } @@ -705,17 +697,16 @@ return ret; req = NULL; + spin_lock_irqsave(&state->lock, flags); add_wait_queue(&state->wait_queue, &wait); current->state = TASK_INTERRUPTIBLE; for (;;) { - spin_lock_irqsave(&state->lock, flags); req = state->completed; if (req != NULL) state->completed = req->next; else if (atomic_read(&state->n_pending) == 0) ret = -EIO; - spin_unlock_irqrestore(&state->lock, flags); if (req != NULL || ret != 0) break; @@ -727,12 +718,15 @@ ret = -ERESTARTSYS; break; } + spin_unlock_irqrestore(&state->lock, flags); schedule(); + spin_lock_irqsave(&state->lock, flags); } current->state = TASK_RUNNING; remove_wait_queue(&state->wait_queue, &wait); - + spin_unlock_irqrestore(&state->lock, flags); + if (ret) return ret; @@ -755,6 +749,8 @@ if (count < 2 || count > sizeof(req->data)) return -EINVAL; + if (adb_controller == NULL) + return -ENXIO; ret = verify_area(VERIFY_READ, buf, count); if (ret) return ret; @@ -774,7 +770,10 @@ goto out; atomic_inc(&state->n_pending); - if (adb_controller == NULL) return -ENXIO; + + /* If a probe is in progress, wait for it to complete */ + while (adb_probe_task_pid != 0 || test_bit(0, &adb_probe_task_flag)) + schedule(); /* Special case for ADB_BUSRESET request, all others are sent to the controller */ @@ -782,6 +781,8 @@ &&(req->data[1] == ADB_BUSRESET)) { ret = do_adb_reset_bus(); atomic_dec(&state->n_pending); + if (ret == 0) + ret = count; goto out; } else { req->reply_expected = ((req->data[1] & 0xc) == 0xc); diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/macintosh/adbhid.c linux-2.5/drivers/macintosh/adbhid.c --- linux-2.5.1/drivers/macintosh/adbhid.c Tue Sep 18 21:23:14 2001 +++ linux-2.5/drivers/macintosh/adbhid.c Thu Dec 27 16:32:31 2001 @@ -273,26 +273,39 @@ break; case 0x1f: /* Powerbook button device */ { + int down = (data[1] == (data[1] & 0xf)); #ifdef CONFIG_PMAC_BACKLIGHT int backlight = get_backlight_level(); - +#endif /* * XXX: Where is the contrast control for the passive? * -- Cort */ - switch (data[1]) { + switch (data[1] & 0x0f) { case 0x8: /* mute */ + input_report_key(&adbhid[id]->input, KEY_MUTE, + data[1] == (data[1] & 0xf)); break; - case 0x7: /* contrast decrease */ + case 0x7: /* volume decrease */ + input_report_key(&adbhid[id]->input, KEY_VOLUMEDOWN, + data[1] == (data[1] & 0xf)); break; - case 0x6: /* contrast increase */ + case 0x6: /* volume increase */ + input_report_key(&adbhid[id]->input, KEY_VOLUMEUP, + data[1] == (data[1] & 0xf)); + break; + + case 0xb: /* eject */ + input_report_key(&adbhid[id]->input, KEY_EJECTCD, + data[1] == (data[1] & 0xf)); break; +#ifdef CONFIG_PMAC_BACKLIGHT case 0xa: /* brightness decrease */ - if (backlight < 0) + if (!down || backlight < 0) break; if (backlight > BACKLIGHT_OFF) set_backlight_level(backlight-1); @@ -301,15 +314,15 @@ break; case 0x9: /* brightness increase */ - if (backlight < 0) + if (!down || backlight < 0) break; if (backlight < BACKLIGHT_MAX) set_backlight_level(backlight+1); else set_backlight_level(BACKLIGHT_MAX); break; - } #endif /* CONFIG_PMAC_BACKLIGHT */ + } } break; } @@ -504,6 +517,11 @@ case 0x1f: /* Powerbook button device */ sprintf(adbhid[id]->name, "ADB Powerbook buttons on ID %d:%d.%02x", id, default_id, original_handler_id); + adbhid[id]->input.evbit[0] = BIT(EV_KEY) | BIT(EV_REP); + set_bit(KEY_MUTE, adbhid[id]->input.keybit); + set_bit(KEY_VOLUMEUP, adbhid[id]->input.keybit); + set_bit(KEY_VOLUMEDOWN, adbhid[id]->input.keybit); + set_bit(KEY_EJECTCD, adbhid[id]->input.keybit); break; } if (adbhid[id]->name[0]) @@ -542,16 +560,38 @@ } +static u16 +adbhid_input_reregister(int id, int default_id, int org_handler_id, + int cur_handler_id, int mk) +{ + if (adbhid[id]) { + if (adbhid[id]->input.idproduct != + ((id << 12)|(default_id << 8)|org_handler_id)) { + adbhid_input_unregister(id); + adbhid_input_register(id, default_id, org_handler_id, + cur_handler_id, mk); + } + } else + adbhid_input_register(id, default_id, org_handler_id, + cur_handler_id, mk); + return 1<<id; +} + +static void +adbhid_input_devcleanup(u16 exist) +{ + int i; + for(i=1; i<16; i++) + if (adbhid[i] && !(exist&(1<<i))) + adbhid_input_unregister(i); +} + static void adbhid_probe(void) { struct adb_request req; int i, default_id, org_handler_id, cur_handler_id; - - for (i = 1; i < 16; i++) { - if (adbhid[i]) - adbhid_input_unregister(i); - } + u16 reg = 0; adb_register(ADB_MOUSE, 0, &mouse_ids, adbhid_mouse_input); adb_register(ADB_KEYBOARD, 0, &keyboard_ids, adbhid_keyboard_input); @@ -580,14 +620,14 @@ printk("ADB keyboard at %d, handler 1\n", id); adb_get_infos(id, &default_id, &cur_handler_id); - adbhid_input_register(id, default_id, org_handler_id, cur_handler_id, 0); + reg |= adbhid_input_reregister(id, default_id, org_handler_id, cur_handler_id, 0); } for (i = 0; i < buttons_ids.nids; i++) { int id = buttons_ids.id[i]; adb_get_infos(id, &default_id, &org_handler_id); - adbhid_input_register(id, default_id, org_handler_id, org_handler_id, 0); + reg |= adbhid_input_reregister(id, default_id, org_handler_id, org_handler_id, 0); } /* Try to switch all mice to handler 4, or 2 for three-button @@ -676,9 +716,10 @@ printk("\n"); adb_get_infos(id, &default_id, &cur_handler_id); - adbhid_input_register(id, default_id, org_handler_id, + reg |= adbhid_input_reregister(id, default_id, org_handler_id, cur_handler_id, mouse_kind); } + adbhid_input_devcleanup(reg); } static void diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/macintosh/ans-lcd.c linux-2.5/drivers/macintosh/ans-lcd.c --- linux-2.5.1/drivers/macintosh/ans-lcd.c Thu Jan 1 00:00:00 1970 +++ linux-2.5/drivers/macintosh/ans-lcd.c Thu Dec 27 16:32:31 2001 @@ -0,0 +1,171 @@ +/* + * /dev/lcd driver for Apple Network Servers. + */ + +#include <linux/types.h> +#include <linux/errno.h> +#include <linux/kernel.h> +#include <linux/miscdevice.h> +#include <linux/fcntl.h> +#include <linux/init.h> +#include <linux/delay.h> +#include <asm/uaccess.h> +#include <asm/sections.h> +#include <asm/prom.h> +#include <asm/ans-lcd.h> +#include <asm/io.h> + +#define ANSLCD_ADDR 0xf301c000 +#define ANSLCD_CTRL_IX 0x00 +#define ANSLCD_DATA_IX 0x10 + +static unsigned long anslcd_short_delay = 80; +static unsigned long anslcd_long_delay = 3280; +static volatile unsigned char* anslcd_ptr; + +#undef DEBUG + +static void __pmac +anslcd_write_byte_ctrl ( unsigned char c ) +{ +#ifdef DEBUG + printk(KERN_DEBUG "LCD: CTRL byte: %02x\n",c); +#endif + out_8(anslcd_ptr + ANSLCD_CTRL_IX, c); + switch(c) { + case 1: + case 2: + case 3: + udelay(anslcd_long_delay); break; + default: udelay(anslcd_short_delay); + } +} + +static void __pmac +anslcd_write_byte_data ( unsigned char c ) +{ + out_8(anslcd_ptr + ANSLCD_DATA_IX, c); + udelay(anslcd_short_delay); +} + +static ssize_t __pmac +anslcd_write( struct file * file, const char * buf, + size_t count, loff_t *ppos ) +{ + const char * p = buf; + int i; + +#ifdef DEBUG + printk(KERN_DEBUG "LCD: write\n"); +#endif + + if ( verify_area(VERIFY_READ, buf, count) ) + return -EFAULT; + for ( i = *ppos; count > 0; ++i, ++p, --count ) + { + char c; + __get_user(c, p); + anslcd_write_byte_data( c ); + } + *ppos = i; + return p - buf; +} + +static int __pmac +anslcd_ioctl( struct inode * inode, struct file * file, + unsigned int cmd, unsigned long arg ) +{ + char ch, *temp; + +#ifdef DEBUG + printk(KERN_DEBUG "LCD: ioctl(%d,%d)\n",cmd,arg); +#endif + + switch ( cmd ) + { + case ANSLCD_CLEAR: + anslcd_write_byte_ctrl ( 0x38 ); + anslcd_write_byte_ctrl ( 0x0f ); + anslcd_write_byte_ctrl ( 0x06 ); + anslcd_write_byte_ctrl ( 0x01 ); + anslcd_write_byte_ctrl ( 0x02 ); + return 0; + case ANSLCD_SENDCTRL: + temp = (char *) arg; + __get_user(ch, temp); + for (; ch; temp++) { /* FIXME: This is ugly, but should work, as a \0 byte is not a valid command code */ + anslcd_write_byte_ctrl ( ch ); + __get_user(ch, temp); + } + return 0; + case ANSLCD_SETSHORTDELAY: + if (!capable(CAP_SYS_ADMIN)) + return -EACCES; + anslcd_short_delay=arg; + return 0; + case ANSLCD_SETLONGDELAY: + if (!capable(CAP_SYS_ADMIN)) + return -EACCES; + anslcd_long_delay=arg; + return 0; + default: + return -EINVAL; + } +} + +static int __pmac +anslcd_open( struct inode * inode, struct file * file ) +{ + return 0; +} + +struct file_operations anslcd_fops = { + write: anslcd_write, + ioctl: anslcd_ioctl, + open: anslcd_open, +}; + +static struct miscdevice anslcd_dev = { + ANSLCD_MINOR, + "anslcd", + &anslcd_fops +}; + +const char anslcd_logo[] = "********************" /* Line #1 */ + "* LINUX! *" /* Line #3 */ + "* Welcome to *" /* Line #2 */ + "********************"; /* Line #4 */ + +int __init +anslcd_init(void) +{ + int a; + struct device_node* node; + + node = find_devices("lcd"); + if (!node || !node->parent) + return -ENODEV; + if (strcmp(node->parent->name, "gc")) + return -ENODEV; + + anslcd_ptr = (volatile unsigned char*)ioremap(ANSLCD_ADDR, 0x20); + + misc_register(&anslcd_dev); + +#ifdef DEBUG + printk(KERN_DEBUG "LCD: init\n"); +#endif + + anslcd_write_byte_ctrl ( 0x38 ); + anslcd_write_byte_ctrl ( 0x0c ); + anslcd_write_byte_ctrl ( 0x06 ); + anslcd_write_byte_ctrl ( 0x01 ); + anslcd_write_byte_ctrl ( 0x02 ); + for(a=0;a<80;a++) { + anslcd_write_byte_data(anslcd_logo[a]); + } + return 0; +} + +__initcall(anslcd_init); + diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/macintosh/apm_emu.c linux-2.5/drivers/macintosh/apm_emu.c --- linux-2.5.1/drivers/macintosh/apm_emu.c Thu Jan 1 00:00:00 1970 +++ linux-2.5/drivers/macintosh/apm_emu.c Thu Dec 27 16:32:31 2001 @@ -0,0 +1,545 @@ +/* APM emulation layer for PowerMac + * + * Copyright 2001 Benjamin Herrenschmidt (benh@kernel.crashing.org) + * + * Lots of code inherited from apm.c, see appropriate notice in + * arch/i386/kernel/apm.c + * + * 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, 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. + * + * + */ + +#include <linux/config.h> +#include <linux/module.h> + +#include <linux/poll.h> +#include <linux/types.h> +#include <linux/stddef.h> +#include <linux/timer.h> +#include <linux/fcntl.h> +#include <linux/slab.h> +#include <linux/stat.h> +#include <linux/proc_fs.h> +#include <linux/miscdevice.h> +#include <linux/apm_bios.h> +#include <linux/init.h> +#include <linux/sched.h> +#include <linux/pm.h> +#include <linux/kernel.h> +#include <linux/smp_lock.h> + +#include <linux/adb.h> +#include <linux/pmu.h> + +#include <asm/system.h> +#include <asm/uaccess.h> +#include <asm/machdep.h> + +#undef DEBUG + +#ifdef DEBUG +#define DBG(args...) printk(KERN_DEBUG args) +//#define DBG(args...) xmon_printf(args) +#else +#define DBG(args...) do { } while (0) +#endif + +/* + * The apm_bios device is one of the misc char devices. + * This is its minor number. + */ +#define APM_MINOR_DEV 134 + +/* + * Maximum number of events stored + */ +#define APM_MAX_EVENTS 20 + +#define FAKE_APM_BIOS_VERSION 0x0101 + +#define APM_USER_NOTIFY_TIMEOUT (5*HZ) + +/* + * The per-file APM data + */ +struct apm_user { + int magic; + struct apm_user * next; + int suser: 1; + int suspend_waiting: 1; + int suspends_pending; + int suspends_read; + int event_head; + int event_tail; + apm_event_t events[APM_MAX_EVENTS]; +}; + +/* + * The magic number in apm_user + */ +#define APM_BIOS_MAGIC 0x4101 + +/* + * Local variables + */ +static int suspends_pending; + +static DECLARE_WAIT_QUEUE_HEAD(apm_waitqueue); +static DECLARE_WAIT_QUEUE_HEAD(apm_suspend_waitqueue); +static struct apm_user * user_list; + +static int apm_notify_sleep(struct pmu_sleep_notifier *self, int when); +static struct pmu_sleep_notifier apm_sleep_notifier = { + apm_notify_sleep, + SLEEP_LEVEL_USERLAND, +}; + +static char driver_version[] = "0.5"; /* no spaces */ + +#ifdef DEBUG +static char * apm_event_name[] = { + "system standby", + "system suspend", + "normal resume", + "critical resume", + "low battery", + "power status change", + "update time", + "critical suspend", + "user standby", + "user suspend", + "system standby resume", + "capabilities change" +}; +#define NR_APM_EVENT_NAME \ + (sizeof(apm_event_name) / sizeof(apm_event_name[0])) + +#endif + +static int queue_empty(struct apm_user *as) +{ + return as->event_head == as->event_tail; +} + +static apm_event_t get_queued_event(struct apm_user *as) +{ + as->event_tail = (as->event_tail + 1) % APM_MAX_EVENTS; + return as->events[as->event_tail]; +} + +static void queue_event(apm_event_t event, struct apm_user *sender) +{ + struct apm_user * as; + + DBG("apm_emu: queue_event(%s)\n", apm_event_name[event-1]); + if (user_list == NULL) + return; + for (as = user_list; as != NULL; as = as->next) { + if (as == sender) + continue; + as->event_head = (as->event_head + 1) % APM_MAX_EVENTS; + if (as->event_head == as->event_tail) { + static int notified; + + if (notified++ == 0) + printk(KERN_ERR "apm_emu: an event queue overflowed\n"); + as->event_tail = (as->event_tail + 1) % APM_MAX_EVENTS; + } + as->events[as->event_head] = event; + if (!as->suser) + continue; + switch (event) { + case APM_SYS_SUSPEND: + case APM_USER_SUSPEND: + as->suspends_pending++; + suspends_pending++; + break; + case APM_NORMAL_RESUME: + as->suspend_waiting = 0; + break; + } + } + wake_up_interruptible(&apm_waitqueue); +} + +static int check_apm_user(struct apm_user *as, const char *func) +{ + if ((as == NULL) || (as->magic != APM_BIOS_MAGIC)) { + printk(KERN_ERR "apm_emu: %s passed bad filp\n", func); + return 1; + } + return 0; +} + +static ssize_t do_read(struct file *fp, char *buf, size_t count, loff_t *ppos) +{ + struct apm_user * as; + int i; + apm_event_t event; + DECLARE_WAITQUEUE(wait, current); + + as = fp->private_data; + if (check_apm_user(as, "read")) + return -EIO; + if (count < sizeof(apm_event_t)) + return -EINVAL; + if (queue_empty(as)) { + if (fp->f_flags & O_NONBLOCK) + return -EAGAIN; + add_wait_queue(&apm_waitqueue, &wait); +repeat: + set_current_state(TASK_INTERRUPTIBLE); + if (queue_empty(as) && !signal_pending(current)) { + schedule(); + goto repeat; + } + set_current_state(TASK_RUNNING); + remove_wait_queue(&apm_waitqueue, &wait); + } + i = count; + while ((i >= sizeof(event)) && !queue_empty(as)) { + event = get_queued_event(as); + DBG("apm_emu: do_read, returning: %s\n", apm_event_name[event-1]); + if (copy_to_user(buf, &event, sizeof(event))) { + if (i < count) + break; + return -EFAULT; + } + switch (event) { + case APM_SYS_SUSPEND: + case APM_USER_SUSPEND: + as->suspends_read++; + break; + } + buf += sizeof(event); + i -= sizeof(event); + } + if (i < count) + return count - i; + if (signal_pending(current)) + return -ERESTARTSYS; + return 0; +} + +static unsigned int do_poll(struct file *fp, poll_table * wait) +{ + struct apm_user * as; + + as = fp->private_data; + if (check_apm_user(as, "poll")) + return 0; + poll_wait(fp, &apm_waitqueue, wait); + if (!queue_empty(as)) + return POLLIN | POLLRDNORM; + return 0; +} + +static int do_ioctl(struct inode * inode, struct file *filp, + u_int cmd, u_long arg) +{ + struct apm_user * as; + DECLARE_WAITQUEUE(wait, current); + + as = filp->private_data; + if (check_apm_user(as, "ioctl")) + return -EIO; + if (!as->suser) + return -EPERM; + switch (cmd) { + case APM_IOC_SUSPEND: + /* If a suspend message was sent to userland, we + * consider this as a confirmation message + */ + if (as->suspends_read > 0) { + as->suspends_read--; + as->suspends_pending--; + suspends_pending--; + } else { + // Route to PMU suspend ? + break; + } + as->suspend_waiting = 1; + add_wait_queue(&apm_waitqueue, &wait); + DBG("apm_emu: ioctl waking up sleep waiter !\n"); + wake_up(&apm_suspend_waitqueue); + mb(); + while(as->suspend_waiting && !signal_pending(current)) { + set_current_state(TASK_INTERRUPTIBLE); + schedule(); + } + set_current_state(TASK_RUNNING); + remove_wait_queue(&apm_waitqueue, &wait); + break; + default: + return -EINVAL; + } + return 0; +} + +static int do_release(struct inode * inode, struct file * filp) +{ + struct apm_user * as; + + as = filp->private_data; + if (check_apm_user(as, "release")) + return 0; + filp->private_data = NULL; + lock_kernel(); + if (as->suspends_pending > 0) { + suspends_pending -= as->suspends_pending; + if (suspends_pending <= 0) + wake_up(&apm_suspend_waitqueue); + } + if (user_list == as) + user_list = as->next; + else { + struct apm_user * as1; + + for (as1 = user_list; + (as1 != NULL) && (as1->next != as); + as1 = as1->next) + ; + if (as1 == NULL) + printk(KERN_ERR "apm: filp not in user list\n"); + else + as1->next = as->next; + } + unlock_kernel(); + kfree(as); + return 0; +} + +static int do_open(struct inode * inode, struct file * filp) +{ + struct apm_user * as; + + as = (struct apm_user *)kmalloc(sizeof(*as), GFP_KERNEL); + if (as == NULL) { + printk(KERN_ERR "apm: cannot allocate struct of size %d bytes\n", + sizeof(*as)); + return -ENOMEM; + } + as->magic = APM_BIOS_MAGIC; + as->event_tail = as->event_head = 0; + as->suspends_pending = 0; + as->suspends_read = 0; + /* + * XXX - this is a tiny bit broken, when we consider BSD + * process accounting. If the device is opened by root, we + * instantly flag that we used superuser privs. Who knows, + * we might close the device immediately without doing a + * privileged operation -- cevans + */ + as->suser = capable(CAP_SYS_ADMIN); + as->next = user_list; + user_list = as; + filp->private_data = as; + + DBG("apm_emu: opened by %s, suser: %d\n", current->comm, (int)as->suser); + + return 0; +} + +/* Wait for all clients to ack the suspend request. APM API + * doesn't provide a way to NAK, but this could be added + * here. + */ +static int wait_all_suspend(void) +{ + DECLARE_WAITQUEUE(wait, current); + + add_wait_queue(&apm_suspend_waitqueue, &wait); + DBG("apm_emu: wait_all_suspend(), suspends_pending: %d\n", suspends_pending); + while(suspends_pending > 0) { + set_current_state(TASK_UNINTERRUPTIBLE); + schedule(); + } + set_current_state(TASK_RUNNING); + remove_wait_queue(&apm_suspend_waitqueue, &wait); + + DBG("apm_emu: wait_all_suspend() - complete !\n"); + + return 1; +} + +static int apm_notify_sleep(struct pmu_sleep_notifier *self, int when) +{ + switch(when) { + case PBOOK_SLEEP_REQUEST: + queue_event(APM_SYS_SUSPEND, NULL); + if (!wait_all_suspend()) + return PBOOK_SLEEP_REFUSE; + break; + case PBOOK_SLEEP_REJECT: + case PBOOK_WAKE: + queue_event(APM_NORMAL_RESUME, NULL); + break; + } + return PBOOK_SLEEP_OK; +} + +#define APM_CRITICAL 10 +#define APM_LOW 30 + +static int apm_emu_get_info(char *buf, char **start, off_t fpos, int length) +{ + /* Arguments, with symbols from linux/apm_bios.h. Information is + from the Get Power Status (0x0a) call unless otherwise noted. + + 0) Linux driver version (this will change if format changes) + 1) APM BIOS Version. Usually 1.0, 1.1 or 1.2. + 2) APM flags from APM Installation Check (0x00): + bit 0: APM_16_BIT_SUPPORT + bit 1: APM_32_BIT_SUPPORT + bit 2: APM_IDLE_SLOWS_CLOCK + bit 3: APM_BIOS_DISABLED + bit 4: APM_BIOS_DISENGAGED + 3) AC line status + 0x00: Off-line + 0x01: On-line + 0x02: On backup power (BIOS >= 1.1 only) + 0xff: Unknown + 4) Battery status + 0x00: High + 0x01: Low + 0x02: Critical + 0x03: Charging + 0x04: Selected battery not present (BIOS >= 1.2 only) + 0xff: Unknown + 5) Battery flag + bit 0: High + bit 1: Low + bit 2: Critical + bit 3: Charging + bit 7: No system battery + 0xff: Unknown + 6) Remaining battery life (percentage of charge): + 0-100: valid + -1: Unknown + 7) Remaining battery life (time units): + Number of remaining minutes or seconds + -1: Unknown + 8) min = minutes; sec = seconds */ + + unsigned short ac_line_status = 0xff; + unsigned short battery_status = 0xff; + unsigned short battery_flag = 0xff; + int percentage = -1; + int time_units = -1; + int real_count = 0; + int i; + char * p = buf; + + ac_line_status = ((pmu_power_flags & PMU_PWR_AC_PRESENT) != 0); + for (i=0; i<pmu_battery_count; i++) { + if (percentage < 0) + percentage = 0; + if (time_units < 0) + time_units = 0; + if (pmu_batteries[i].flags & PMU_BATT_PRESENT) { + percentage += (pmu_batteries[i].charge * 100) / + pmu_batteries[i].max_charge; + /* hrm... should we provide the remaining charge + * time when AC is plugged ? If yes, just remove + * that test --BenH + */ + if (!ac_line_status) + time_units += pmu_batteries[i].time_remaining / 60; + real_count++; + if (pmu_batteries[i].flags & PMU_BATT_CHARGING) + battery_flag |= 0x08; + } + } + if (real_count) { + percentage /= real_count; + if (percentage <= APM_CRITICAL) { + battery_status = 0x02; + battery_flag = 0x04; + } else if (percentage <= APM_LOW) { + battery_status = 0x01; + battery_flag = 0x02; + } else { + battery_status = 0x00; + battery_flag = 0x01; + } + if (battery_flag & 0x08) + battery_status = 0x03; + } + p += sprintf(p, "%s %d.%d 0x%02x 0x%02x 0x%02x 0x%02x %d%% %d %s\n", + driver_version, + (FAKE_APM_BIOS_VERSION >> 8) & 0xff, + FAKE_APM_BIOS_VERSION & 0xff, + 0, + ac_line_status, + battery_status, + battery_flag, + percentage, + time_units, + "min"); + + return p - buf; +} + +static struct file_operations apm_bios_fops = { + owner: THIS_MODULE, + read: do_read, + poll: do_poll, + ioctl: do_ioctl, + open: do_open, + release: do_release, +}; + +static struct miscdevice apm_device = { + APM_MINOR_DEV, + "apm_bios", + &apm_bios_fops +}; + +static int __init apm_emu_init(void) +{ + struct proc_dir_entry *apm_proc; + + if (sys_ctrler != SYS_CTRLER_PMU) { + printk(KERN_INFO "apm_emu: Requires a machine with a PMU.\n"); + return -ENODEV; + } + + apm_proc = create_proc_info_entry("apm", 0, NULL, apm_emu_get_info); + if (apm_proc) + SET_MODULE_OWNER(apm_proc); + + misc_register(&apm_device); + + pmu_register_sleep_notifier(&apm_sleep_notifier); + + printk(KERN_INFO "apm_emu: APM Emulation %s initialized.\n", driver_version); + + return 0; +} + +static void __exit apm_emu_exit(void) +{ + pmu_unregister_sleep_notifier(&apm_sleep_notifier); + misc_deregister(&apm_device); + remove_proc_entry("apm", NULL); + + printk(KERN_INFO "apm_emu: APM Emulation removed.\n"); +} + +module_init(apm_emu_init); +module_exit(apm_emu_exit); + +MODULE_AUTHOR("Benjamin Herrenschmidt"); +MODULE_DESCRIPTION("APM emulation layer for PowerMac"); +MODULE_LICENSE("GPL"); +EXPORT_NO_SYMBOLS; + diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/macintosh/mac_hid.c linux-2.5/drivers/macintosh/mac_hid.c --- linux-2.5.1/drivers/macintosh/mac_hid.c Wed Jun 27 20:37:35 2001 +++ linux-2.5/drivers/macintosh/mac_hid.c Thu Dec 27 16:32:31 2001 @@ -200,15 +200,15 @@ 0, 0, 0, KEY_KPCOMMA, 0, KEY_INTL3, 0, 0, /* 0x00-0x07 */ 0, 0, 0, 0, KEY_LANG1, KEY_LANG2, 0, 0, /* 0x08-0x0f */ 0, 0, 0, 0, 0, 0, 0, 0, /* 0x10-0x17 */ - 0, 0, 0, 0, KEY_KPENTER, KEY_RIGHTCTRL, 0, 0, /* 0x18-0x1f */ - 0, 0, 0, 0, 0, 0, 0, 0, /* 0x20-0x27 */ + 0, 0, 0, 0, KEY_KPENTER, KEY_RIGHTCTRL, KEY_VOLUMEUP, 0,/* 0x18-0x1f */ + 0, 0, 0, 0, 0, KEY_VOLUMEDOWN, KEY_MUTE, 0, /* 0x20-0x27 */ 0, 0, 0, 0, 0, 0, 0, 0, /* 0x28-0x2f */ 0, 0, 0, 0, 0, KEY_KPSLASH, 0, KEY_SYSRQ, /* 0x30-0x37 */ - KEY_RIGHTALT, 0, 0, 0, 0, 0, 0, 0, /* 0x38-0x3f */ + KEY_RIGHTALT, 0, 0, KEY_EJECTCD, 0, 0, 0, 0, /* 0x38-0x3f */ 0, 0, 0, 0, 0, 0, 0, KEY_HOME, /* 0x40-0x47 */ KEY_UP, KEY_PAGEUP, 0, KEY_LEFT, 0, KEY_RIGHT, 0, KEY_END, /* 0x48-0x4f */ KEY_DOWN, KEY_PAGEDOWN, KEY_INSERT, KEY_DELETE, 0, 0, 0, 0, /* 0x50-0x57 */ - 0, 0, 0, KEY_LEFTMETA, KEY_RIGHTMETA, KEY_COMPOSE, 0, 0, /* 0x58-0x5f */ + 0, 0, 0, KEY_LEFTMETA, KEY_RIGHTMETA, KEY_COMPOSE, KEY_POWER, 0, /* 0x58-0x5f */ 0, 0, 0, 0, 0, 0, 0, 0, /* 0x60-0x67 */ 0, 0, 0, 0, 0, 0, 0, KEY_MACRO, /* 0x68-0x6f */ 0, 0, 0, 0, 0, 0, 0, 0, /* 0x70-0x77 */ diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/macintosh/mac_keyb.c linux-2.5/drivers/macintosh/mac_keyb.c --- linux-2.5.1/drivers/macintosh/mac_keyb.c Tue Sep 18 21:23:14 2001 +++ linux-2.5/drivers/macintosh/mac_keyb.c Thu Dec 27 15:56:12 2001 @@ -256,7 +256,6 @@ #endif extern struct kbd_struct kbd_table[]; -extern wait_queue_head_t keypress_wait; extern void handle_scancode(unsigned char, int); @@ -423,7 +422,6 @@ struct tty_struct *tty; tty = console_driver.table? console_driver.table[fg_console]: NULL; - wake_up(&keypress_wait); if (tty) { tty_insert_flip_char(tty, ch, 0); con_schedule_flip(tty); diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/macintosh/macserial.c linux-2.5/drivers/macintosh/macserial.c --- linux-2.5.1/drivers/macintosh/macserial.c Mon Oct 15 20:43:24 2001 +++ linux-2.5/drivers/macintosh/macserial.c Sun Dec 30 21:17:30 2001 @@ -38,9 +38,9 @@ #include <asm/irq.h> #include <asm/prom.h> #include <asm/system.h> -#include <asm/segment.h> #include <asm/bitops.h> -#include <asm/feature.h> +#include <asm/machdep.h> +#include <asm/pmac_feature.h> #include <linux/adb.h> #include <linux/pmu.h> #ifdef CONFIG_KGDB @@ -1179,7 +1179,7 @@ } memset(info->curregs, 0, sizeof(info->curregs)); - memset(info->curregs, 0, sizeof(info->pendregs)); + memset(info->pendregs, 0, sizeof(info->pendregs)); info->flags &= ~ZILOG_INITIALIZED; } @@ -1194,69 +1194,34 @@ { int delay = 0; - if (feature_test(info->dev_node, FEATURE_Serial_enable) < 0) - return 0; /* don't have serial power control */ - - /* The timings looks strange but that's the ones MacOS seems - to use for the internal modem. I think we can use a lot faster - ones, at least whe not using the modem, this should be tested. - */ if (state) { PWRDBG("ttyS%02d: powering up hardware\n", info->line); - if (feature_test(info->dev_node, FEATURE_Serial_enable) == 0) { - feature_set(info->dev_node, FEATURE_Serial_enable); - mdelay(10); - feature_set(info->dev_node, FEATURE_Serial_reset); - mdelay(15); - feature_clear(info->dev_node, FEATURE_Serial_reset); - mdelay(10); - } - if (info->zs_chan_a == info->zs_channel) - feature_set(info->dev_node, FEATURE_Serial_IO_A); - else - feature_set(info->dev_node, FEATURE_Serial_IO_B); - delay = 10; - if (info->is_cobalt_modem) { - feature_set_modem_power(info->dev_node, 1); + pmac_call_feature( + PMAC_FTR_SCC_ENABLE, + info->dev_node, info->port_type, 1); + if (info->is_internal_modem) { + pmac_call_feature( + PMAC_FTR_MODEM_ENABLE, + info->dev_node, 0, 1); delay = 2500; /* wait for 2.5s before using */ - } -#ifdef CONFIG_PMAC_PBOOK - if (info->is_irda) - pmu_enable_irled(1); -#endif /* CONFIG_PMAC_PBOOK */ + } else if (info->is_irda) + mdelay(50); /* Do better here once the problems + * with blocking have been ironed out + */ } else { /* TODO: Make that depend on a timer, don't power down * immediately */ PWRDBG("ttyS%02d: shutting down hardware\n", info->line); - if (info->is_cobalt_modem) { + if (info->is_internal_modem) { PWRDBG("ttyS%02d: shutting down modem\n", info->line); - feature_set_modem_power(info->dev_node, 0); - } -#ifdef CONFIG_PMAC_PBOOK - if (info->is_irda) - pmu_enable_irled(0); -#endif /* CONFIG_PMAC_PBOOK */ - - if (info->zs_chan_a == info->zs_channel && !info->is_irda) { - PWRDBG("ttyS%02d: shutting down SCC channel A\n", info->line); - feature_clear(info->dev_node, FEATURE_Serial_IO_A); - } else if (!info->is_irda) { - PWRDBG("ttyS%02d: shutting down SCC channel B\n", info->line); - feature_clear(info->dev_node, FEATURE_Serial_IO_B); - } - /* XXX for now, shut down SCC core only on powerbooks */ - if (is_powerbook - && !(feature_test(info->dev_node, FEATURE_Serial_IO_A) || - feature_test(info->dev_node, FEATURE_Serial_IO_B))) { - PWRDBG("ttyS%02d: shutting down SCC core\n", info->line); - feature_set(info->dev_node, FEATURE_Serial_reset); - mdelay(15); - feature_clear(info->dev_node, FEATURE_Serial_reset); - mdelay(25); - feature_clear(info->dev_node, FEATURE_Serial_enable); - mdelay(5); - } + pmac_call_feature( + PMAC_FTR_MODEM_ENABLE, + info->dev_node, 0, 0); + } + pmac_call_feature( + PMAC_FTR_SCC_ENABLE, + info->dev_node, info->port_type, 0); } return delay; } @@ -2381,7 +2346,7 @@ * Initialize one channel, both the mac_serial and mac_zschannel * structs. We use the dev_node field of the mac_serial struct. */ -static void +static int chan_init(struct mac_serial *zss, struct mac_zschannel *zs_chan, struct mac_zschannel *zs_chan_a) { @@ -2411,12 +2376,15 @@ /* setup misc varariables */ zss->kgdb_channel = 0; - zss->is_cobalt_modem = device_is_compatible(ch, "cobalt"); - /* XXX tested only with wallstreet PowerBook, - should do no harm anyway */ + /* For now, we assume you either have a slot-names property + * with "Modem" in it, or your channel is compatible with + * "cobalt". Might need additional fixups + */ + zss->is_internal_modem = device_is_compatible(ch, "cobalt"); conn = get_property(ch, "AAPL,connector", &len); zss->is_irda = conn && (strcmp(conn, "infrared") == 0); + zss->port_type = PMAC_SCC_ASYNC; /* 1999 Powerbook G3 has slot-names property instead */ slots = (struct slot_names_prop *)get_property(ch, "slot-names", &len); if (slots && slots->count > 0) { @@ -2425,8 +2393,29 @@ else if (strcmp(slots->name, "Modem") == 0) zss->is_internal_modem = 1; } + if (zss->is_irda) + zss->port_type = PMAC_SCC_IRDA; + if (zss->is_internal_modem) { + struct device_node* i2c_modem = find_devices("i2c-modem"); + if (i2c_modem) { + char* mid = get_property(i2c_modem, "modem-id", NULL); + if (mid) switch(*mid) { + case 0x04 : + case 0x05 : + case 0x07 : + case 0x08 : + case 0x0b : + case 0x0c : + zss->port_type = PMAC_SCC_I2S1; + } + printk(KERN_INFO "macserial: i2c-modem detected, id: %d\n", + mid ? (*mid) : 0); + } else { + printk(KERN_INFO "macserial: serial modem detected\n"); + } + } - if (zss->has_dma) { + while (zss->has_dma) { zss->dma_priv = NULL; /* it seems that the last two addresses are the DMA controllers */ @@ -2437,11 +2426,13 @@ zss->tx_dma_irq = ch->intrs[1].line; zss->rx_dma_irq = ch->intrs[2].line; spin_lock_init(&zss->rx_dma_lock); + break; } init_timer(&zss->powerup_timer); zss->powerup_timer.function = powerup_done; zss->powerup_timer.data = (unsigned long) zss; + return 0; } /* Ask the PROM how many Z8530s we have and initialize their zs_channels */ @@ -2496,13 +2487,15 @@ continue; /* set up A side */ - chan_init(&zs_soft[chip + chan_a_index], zs_chan, zs_chan); + if (chan_init(&zs_soft[chip + chan_a_index], zs_chan, zs_chan)) + continue; ++zs_chan; /* set up B side, if it exists */ if (nchan > 1) - chan_init(&zs_soft[chip + 1 - chan_a_index], - zs_chan, zs_chan - 1); + if (chan_init(&zs_soft[chip + 1 - chan_a_index], + zs_chan, zs_chan - 1)) + continue; ++zs_chan; } *pp = 0; @@ -2528,13 +2521,35 @@ if (zs_chain == 0) probe_sccs(); - /* XXX assume it's a powerbook if we have a via-pmu */ + /* XXX assume it's a powerbook if we have a via-pmu + * + * This is OK for core99 machines as well. + */ is_powerbook = find_devices("via-pmu") != 0; - /* Register the interrupt handler for each one */ + /* Register the interrupt handler for each one + * We also request the OF resources here as probe_sccs() + * might be called too early for that + */ save_flags(flags); cli(); for (i = 0; i < zs_channels_found; ++i) { + struct device_node* ch = zs_soft[i].dev_node; + if (!request_OF_resource(ch, 0, NULL)) { + printk(KERN_ERR "macserial: can't request IO resource !\n"); + return -ENODEV; + } if (zs_soft[i].has_dma) { + if (!request_OF_resource(ch, ch->n_addrs - 2, " (tx dma)")) { + printk(KERN_ERR "macserial: can't request TX DMA resource !\n"); + zs_soft[i].has_dma = 0; + goto no_dma; + } + if (!request_OF_resource(ch, ch->n_addrs - 1, " (rx dma)")) { + release_OF_resource(ch, ch->n_addrs - 2); + printk(KERN_ERR "macserial: can't request RX DMA resource !\n"); + zs_soft[i].has_dma = 0; + goto no_dma; + } if (request_irq(zs_soft[i].tx_dma_irq, rs_txdma_irq, 0, "SCC-txdma", &zs_soft[i])) printk(KERN_ERR "macserial: can't get irq %d\n", @@ -2546,6 +2561,7 @@ zs_soft[i].rx_dma_irq); disable_irq(zs_soft[i].rx_dma_irq); } +no_dma: if (request_irq(zs_soft[i].irq, rs_interrupt, 0, "SCC", &zs_soft[i])) printk(KERN_ERR "macserial: can't get irq %d\n", @@ -2580,7 +2596,9 @@ serial_driver.table = serial_table; serial_driver.termios = serial_termios; serial_driver.termios_locked = serial_termios_locked; - +#ifdef CONFIG_SERIAL_CONSOLE + serial_driver.console = &sercons; +#endif serial_driver.open = rs_open; serial_driver.close = rs_close; serial_driver.write = rs_write; @@ -2676,9 +2694,7 @@ connector = get_property(info->dev_node, "AAPL,connector", &lenp); if (connector) printk(", port = %s", connector); - if (info->is_cobalt_modem) - printk(" (cobalt modem)"); - else if (info->is_internal_modem) + if (info->is_internal_modem) printk(" (internal modem)"); if (info->is_irda) printk(" (IrDA)"); @@ -2712,6 +2728,12 @@ free_irq(zs_soft[i].tx_dma_irq, &zs_soft[i]); free_irq(zs_soft[i].rx_dma_irq, &zs_soft[i]); } + release_OF_resource(zs_soft[i].dev_node, 0); + if (zs_soft[i].has_dma) { + struct device_node* ch = zs_soft[i].dev_node; + release_OF_resource(ch, ch->n_addrs - 2); + release_OF_resource(ch, ch->n_addrs - 1); + } } restore_flags(flags); tty_unregister_driver(&callout_driver); @@ -2792,30 +2814,6 @@ /* Don't disable the transmitter. */ } -/* - * Receive character from the serial port - */ -static int serial_console_wait_key(struct console *co) -{ - struct mac_serial *info = zs_soft + co->index; - int val; - - /* Turn of interrupts and enable the transmitter. */ - write_zsreg(info->zs_channel, R1, info->curregs[1] & ~INT_ALL_Rx); - write_zsreg(info->zs_channel, R3, info->curregs[3] | RxENABLE); - - /* Wait for something in the receive buffer. */ - while((read_zsreg(info->zs_channel, 0) & Rx_CH_AV) == 0) - eieio(); - val = read_zsdata(info->zs_channel); - - /* Restore the values in the registers. */ - write_zsreg(info->zs_channel, R1, info->curregs[1]); - write_zsreg(info->zs_channel, R3, info->curregs[3]); - - return val; -} - static kdev_t serial_console_device(struct console *c) { return MKDEV(TTY_MAJOR, 64 + c->index); @@ -3006,7 +3004,6 @@ name: "ttyS", write: serial_console_write, device: serial_console_device, - wait_key: serial_console_wait_key, setup: serial_console_setup, flags: CON_PRINTBUFFER, index: -1, diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/macintosh/macserial.h linux-2.5/drivers/macintosh/macserial.h --- linux-2.5.1/drivers/macintosh/macserial.h Wed Jun 27 20:37:35 2001 +++ linux-2.5/drivers/macintosh/macserial.h Thu Dec 27 16:32:31 2001 @@ -111,8 +111,8 @@ char kgdb_channel; /* Kgdb is running on this channel */ char is_cons; /* Is this our console. */ char is_internal_modem; /* is connected to an internal modem */ - char is_cobalt_modem; /* is a gatwick-based cobalt modem */ char is_irda; /* is connected to an IrDA codec */ + int port_type; /* Port type for pmac_feature */ unsigned char tx_active; /* character is being xmitted */ unsigned char tx_stopped; /* output is suspended */ unsigned char power_wait; /* waiting for power-up delay to expire */ diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/macintosh/mediabay.c linux-2.5/drivers/macintosh/mediabay.c --- linux-2.5.1/drivers/macintosh/mediabay.c Sat Sep 8 19:38:42 2001 +++ linux-2.5/drivers/macintosh/mediabay.c Thu Dec 27 16:32:31 2001 @@ -25,9 +25,13 @@ #include <asm/prom.h> #include <asm/pgtable.h> #include <asm/io.h> -#include <asm/feature.h> +#include <asm/machdep.h> +#include <asm/pmac_feature.h> #include <asm/mediabay.h> #include <asm/sections.h> +#include <asm/ohare.h> +#include <asm/heathrow.h> +#include <asm/keylargo.h> #include <linux/adb.h> #include <linux/pmu.h> @@ -40,7 +44,7 @@ #endif #undef MB_USE_INTERRUPTS -#undef MB_DEBUG +#define MB_DEBUG #define MB_IGNORE_SIGNALS #ifdef MB_DEBUG @@ -49,24 +53,46 @@ #define MBDBG(fmt, arg...) do { } while (0) #endif -struct media_bay_hw { - unsigned char b0; - unsigned char contents; - unsigned char b2; - unsigned char b3; +/* Type of media bay */ +enum { + mb_ohare, + mb_heathrow, + mb_keylargo +}; + +#define MB_FCR32(bay, r) ((bay)->base + ((r) >> 2)) +#define MB_FCR8(bay, r) (((volatile u8*)((bay)->base)) + (r)) + +#define MB_IN32(bay,r) (in_le32(MB_FCR32(bay,r))) +#define MB_OUT32(bay,r,v) (out_le32(MB_FCR32(bay,r), (v))) +#define MB_BIS(bay,r,v) (MB_OUT32((bay), (r), MB_IN32((bay), r) | (v))) +#define MB_BIC(bay,r,v) (MB_OUT32((bay), (r), MB_IN32((bay), r) & ~(v))) +#define MB_IN8(bay,r) (in_8(MB_FCR8(bay,r))) +#define MB_OUT8(bay,r,v) (out_8(MB_FCR8(bay,r), (v))) + +struct media_bay_info; + +struct mb_ops { + char* name; + u8 (*content)(struct media_bay_info* bay); + void (*power)(struct media_bay_info* bay, int on_off); + int (*setup_bus)(struct media_bay_info* bay, u8 device_id); + void (*un_reset)(struct media_bay_info* bay); + void (*un_reset_ide)(struct media_bay_info* bay); }; struct media_bay_info { - volatile struct media_bay_hw* addr; - volatile u8* extint_gpio; + volatile u32* base; int content_id; int state; int last_value; int value_count; int timer; struct device_node* dev_node; - int pismo; /* New PowerBook3,1 */ - int gpio_cache; + int mb_type; + struct mb_ops* ops; + int index; + int cached_gpio; #ifdef CONFIG_BLK_DEV_IDE unsigned long cd_base; int cd_index; @@ -77,33 +103,12 @@ #define MAX_BAYS 2 -static volatile struct media_bay_info media_bays[MAX_BAYS]; +static struct media_bay_info media_bays[MAX_BAYS]; int media_bay_count = 0; -inline int mb_content(volatile struct media_bay_info *bay) -{ - if (bay->pismo) { - unsigned char new_gpio = in_8(bay->extint_gpio + 0xe) & 2; - if (new_gpio) { - bay->gpio_cache = new_gpio; - return MB_NO; - } else if (bay->gpio_cache != new_gpio) { - /* make sure content bits are set */ - feature_set(bay->dev_node, FEATURE_Mediabay_content); - udelay(5); - bay->gpio_cache = new_gpio; - } - return (in_le32((unsigned*)bay->addr) >> 4) & 0xf; - } else { - int cont = (in_8(&bay->addr->contents) >> 4) & 7; - return (cont == 7) ? MB_NO : cont; - } -} - #ifdef CONFIG_BLK_DEV_IDE /* check the busy bit in the media-bay ide interface (assumes the media-bay contains an ide device) */ -//#define MB_IDE_READY(i) ((inb(media_bays[i].cd_base + 0x70) & 0xc0) == 0x40) #define MB_IDE_READY(i) ((inb(media_bays[i].cd_base + 0x70) & 0x80) == 0) #endif @@ -116,7 +121,7 @@ * Consider the media-bay ID value stable if it is the same for * this number of milliseconds */ -#define MB_STABLE_DELAY 40 +#define MB_STABLE_DELAY 100 /* Wait after powering up the media bay this delay in ms * timeout bumped for some powerbooks @@ -166,175 +171,259 @@ mb_powering_down /* Powering down (avoid too fast down/up) */ }; -static void poll_media_bay(int which); -static void set_media_bay(int which, int id); -static void set_mb_power(int which, int onoff); -static void media_bay_step(int i); -static int media_bay_task(void *); +#define MB_POWER_SOUND 0x08 +#define MB_POWER_FLOPPY 0x04 +#define MB_POWER_ATA 0x02 +#define MB_POWER_PCI 0x01 +#define MB_POWER_OFF 0x00 -#ifdef MB_USE_INTERRUPTS -static void media_bay_intr(int irq, void *devid, struct pt_regs *regs); -#endif +/* + * Functions for polling content of media bay + */ + +static u8 __pmac +ohare_mb_content(struct media_bay_info *bay) +{ + return (MB_IN32(bay, OHARE_MBCR) >> 12) & 7; +} + +static u8 __pmac +heathrow_mb_content(struct media_bay_info *bay) +{ + return (MB_IN32(bay, HEATHROW_MBCR) >> 12) & 7; +} + +static u8 __pmac +keylargo_mb_content(struct media_bay_info *bay) +{ + int new_gpio; + + new_gpio = MB_IN8(bay, KL_GPIO_MEDIABAY_IRQ) & KEYLARGO_GPIO_INPUT_DATA; + if (new_gpio) { + bay->cached_gpio = new_gpio; + return MB_NO; + } else if (bay->cached_gpio != new_gpio) { + MB_BIS(bay, KEYLARGO_MBCR, KL_MBCR_MB0_ENABLE); + (void)MB_IN32(bay, KEYLARGO_MBCR); + udelay(5); + MB_BIC(bay, KEYLARGO_MBCR, 0x0000000F); + (void)MB_IN32(bay, KEYLARGO_MBCR); + udelay(5); + bay->cached_gpio = new_gpio; + } + return (MB_IN32(bay, KEYLARGO_MBCR) >> 4) & 7; +} /* - * It seems that the bit for the media-bay interrupt in the IRQ_LEVEL - * register is always set when there is something in the media bay. - * This causes problems for the interrupt code if we attach an interrupt - * handler to the media-bay interrupt, because it tends to go into - * an infinite loop calling the media bay interrupt handler. - * Therefore we do it all by polling the media bay once each tick. + * Functions for powering up/down the bay, puts the bay device + * into reset state as well */ -void __pmac -media_bay_init(void) +static void __pmac +ohare_mb_power(struct media_bay_info* bay, int on_off) { - struct device_node *np; - int n,i; - - for (i=0; i<MAX_BAYS; i++) { - memset((char *)&media_bays[i], 0, sizeof(struct media_bay_info)); - media_bays[i].content_id = -1; -#ifdef CONFIG_BLK_DEV_IDE - media_bays[i].cd_index = -1; -#endif + if (on_off) { + /* Power up device, assert it's reset line */ + MB_BIC(bay, OHARE_FCR, OH_BAY_RESET_N); + MB_BIC(bay, OHARE_FCR, OH_BAY_POWER_N); + } else { + /* Disable all devices */ + MB_BIC(bay, OHARE_FCR, OH_BAY_DEV_MASK); + MB_BIC(bay, OHARE_FCR, OH_FLOPPY_ENABLE); + /* Cut power from bay, release reset line */ + MB_BIS(bay, OHARE_FCR, OH_BAY_POWER_N); + MB_BIS(bay, OHARE_FCR, OH_BAY_RESET_N); + MB_BIS(bay, OHARE_FCR, OH_IDE1_RESET_N); } - - np = find_devices("media-bay"); - n = 0; - while(np && (n<MAX_BAYS)) { - if (np->n_addrs == 0) - continue; - media_bays[n].addr = (volatile struct media_bay_hw *) - ioremap(np->addrs[0].address, sizeof(struct media_bay_hw)); + MB_BIC(bay, OHARE_MBCR, 0x00000F00); +} - media_bays[n].pismo = device_is_compatible(np, "keylargo-media-bay"); - if (media_bays[n].pismo) { - if (!np->parent || strcmp(np->parent->name, "mac-io")) { - printk(KERN_ERR "Pismo media-bay has no mac-io parent !\n"); - continue; - } - media_bays[n].extint_gpio = ioremap(np->parent->addrs[0].address - + 0x58, 0x10); - } +static void __pmac +heathrow_mb_power(struct media_bay_info* bay, int on_off) +{ + if (on_off) { + /* Power up device, assert it's reset line */ + MB_BIC(bay, HEATHROW_FCR, HRW_BAY_RESET_N); + MB_BIC(bay, HEATHROW_FCR, HRW_BAY_POWER_N); + } else { + /* Disable all devices */ + MB_BIC(bay, HEATHROW_FCR, HRW_BAY_DEV_MASK); + MB_BIC(bay, HEATHROW_FCR, HRW_SWIM_ENABLE); + /* Cut power from bay, release reset line */ + MB_BIS(bay, HEATHROW_FCR, HRW_BAY_POWER_N); + MB_BIS(bay, HEATHROW_FCR, HRW_BAY_RESET_N); + MB_BIS(bay, HEATHROW_FCR, HRW_IDE1_RESET_N); + } + MB_BIC(bay, HEATHROW_MBCR, 0x00000F00); +} -#ifdef MB_USE_INTERRUPTS - if (np->n_intrs == 0) { - printk(KERN_ERR "media bay %d has no irq\n",n); - continue; - } +static void __pmac +keylargo_mb_power(struct media_bay_info* bay, int on_off) +{ + if (on_off) { + /* Power up device, assert it's reset line */ + MB_BIC(bay, KEYLARGO_MBCR, KL_MBCR_MB0_DEV_RESET); + MB_BIC(bay, KEYLARGO_MBCR, KL_MBCR_MB0_DEV_POWER); + } else { + /* Disable all devices */ + MB_BIC(bay, KEYLARGO_MBCR, KL_MBCR_MB0_DEV_MASK); + MB_BIC(bay, KEYLARGO_FCR1, KL1_EIDE0_ENABLE); + /* Cut power from bay, release reset line */ + MB_BIS(bay, KEYLARGO_MBCR, KL_MBCR_MB0_DEV_POWER); + MB_BIS(bay, KEYLARGO_MBCR, KL_MBCR_MB0_DEV_RESET); + MB_BIS(bay, KEYLARGO_FCR1, KL1_EIDE0_RESET_N); + } + MB_BIC(bay, KEYLARGO_MBCR, 0x0000000F); +} - if (request_irq(np->intrs[0].line, media_bay_intr, 0, "Media bay", (void *)n)) { - printk(KERN_ERR "Couldn't get IRQ %d for media bay %d\n", - np->intrs[0].line, n); - continue; - } -#endif - media_bay_count++; - - media_bays[n].dev_node = np; +/* + * Functions for configuring the media bay for a given type of device, + * enable the related busses + */ - /* Force an immediate detect */ - set_mb_power(n,0); - mdelay(MB_POWER_DELAY); - if(!media_bays[n].pismo) - out_8(&media_bays[n].addr->contents, 0x70); - mdelay(MB_STABLE_DELAY); - media_bays[n].content_id = MB_NO; - media_bays[n].last_value = mb_content(&media_bays[n]); - media_bays[n].value_count = MS_TO_HZ(MB_STABLE_DELAY); - media_bays[n].state = mb_empty; - do { - mdelay(1000/HZ); - media_bay_step(n); - } while((media_bays[n].state != mb_empty) && - (media_bays[n].state != mb_up)); +static int __pmac +ohare_mb_setup_bus(struct media_bay_info* bay, u8 device_id) +{ + switch(device_id) { + case MB_FD: + case MB_FD1: + MB_BIS(bay, OHARE_FCR, OH_BAY_FLOPPY_ENABLE); + MB_BIS(bay, OHARE_FCR, OH_FLOPPY_ENABLE); + return 0; + case MB_CD: + MB_BIC(bay, OHARE_FCR, OH_IDE1_RESET_N); + MB_BIS(bay, OHARE_FCR, OH_BAY_IDE_ENABLE); + return 0; + case MB_PCI: + MB_BIS(bay, OHARE_FCR, OH_BAY_PCI_ENABLE); + return 0; + } + return -ENODEV; +} - n++; - np=np->next; +static int __pmac +heathrow_mb_setup_bus(struct media_bay_info* bay, u8 device_id) +{ + switch(device_id) { + case MB_FD: + case MB_FD1: + MB_BIS(bay, HEATHROW_FCR, HRW_BAY_FLOPPY_ENABLE); + MB_BIS(bay, HEATHROW_FCR, HRW_SWIM_ENABLE); + return 0; + case MB_CD: + MB_BIC(bay, HEATHROW_FCR, HRW_IDE1_RESET_N); + MB_BIS(bay, HEATHROW_FCR, HRW_BAY_IDE_ENABLE); + return 0; + case MB_PCI: + MB_BIS(bay, HEATHROW_FCR, HRW_BAY_PCI_ENABLE); + return 0; } + return -ENODEV; +} - if (media_bay_count) - { - printk(KERN_INFO "Registered %d media-bay(s)\n", media_bay_count); +static int __pmac +keylargo_mb_setup_bus(struct media_bay_info* bay, u8 device_id) +{ + switch(device_id) { + case MB_CD: + MB_BIS(bay, KEYLARGO_MBCR, KL_MBCR_MB0_IDE_ENABLE); + MB_BIC(bay, KEYLARGO_FCR1, KL1_EIDE0_RESET_N); + MB_BIS(bay, KEYLARGO_FCR1, KL1_EIDE0_ENABLE); + return 0; + case MB_PCI: + MB_BIS(bay, KEYLARGO_MBCR, KL_MBCR_MB0_PCI_ENABLE); + return 0; + case MB_SOUND: + MB_BIS(bay, KEYLARGO_MBCR, KL_MBCR_MB0_SOUND_ENABLE); + return 0; + } + return -ENODEV; +} -#ifdef CONFIG_PMAC_PBOOK - pmu_register_sleep_notifier(&mb_sleep_notifier); -#endif /* CONFIG_PMAC_PBOOK */ +/* + * Functions for tweaking resets + */ - kernel_thread(media_bay_task, NULL, - CLONE_FS | CLONE_FILES | CLONE_SIGHAND); - } +static void __pmac +ohare_mb_un_reset(struct media_bay_info* bay) +{ + MB_BIS(bay, OHARE_FCR, OH_BAY_RESET_N); } -#ifdef MB_USE_INTERRUPTS static void __pmac -media_bay_intr(int irq, void *devid, struct pt_regs *regs) +heathrow_mb_un_reset(struct media_bay_info* bay) { + MB_BIS(bay, HEATHROW_FCR, HRW_BAY_RESET_N); +} + +static void __pmac +keylargo_mb_un_reset(struct media_bay_info* bay) +{ + MB_BIS(bay, KEYLARGO_MBCR, KL_MBCR_MB0_DEV_RESET); +} + +static void __pmac +ohare_mb_un_reset_ide(struct media_bay_info* bay) +{ + MB_BIS(bay, OHARE_FCR, OH_IDE1_RESET_N); +} + +static void __pmac +heathrow_mb_un_reset_ide(struct media_bay_info* bay) +{ + MB_BIS(bay, HEATHROW_FCR, HRW_IDE1_RESET_N); } -#endif static void __pmac -set_mb_power(int which, int onoff) +keylargo_mb_un_reset_ide(struct media_bay_info* bay) { - volatile struct media_bay_info* mb = &media_bays[which]; + MB_BIS(bay, KEYLARGO_FCR1, KL1_EIDE0_RESET_N); +} +static inline void __pmac +set_mb_power(struct media_bay_info* bay, int onoff) +{ + /* Power up up and assert the bay reset line */ if (onoff) { - feature_set(mb->dev_node, FEATURE_Mediabay_power); - udelay(10); - feature_set(mb->dev_node, FEATURE_Mediabay_reset); - udelay(10); - mb->state = mb_powering_up; - MBDBG("mediabay%d: powering up\n", which); - } else { - feature_clear(mb->dev_node, FEATURE_Mediabay_floppy_enable); - if (mb->pismo) - feature_clear(mb->dev_node, FEATURE_IDE0_enable); - else - feature_clear(mb->dev_node, FEATURE_IDE1_enable); - feature_clear(mb->dev_node, FEATURE_Mediabay_IDE_switch); - feature_clear(mb->dev_node, FEATURE_Mediabay_PCI_enable); - feature_clear(mb->dev_node, FEATURE_SWIM3_enable); - feature_clear(mb->dev_node, FEATURE_Mediabay_power); - mb->state = mb_powering_down; - MBDBG("mediabay%d: powering down\n", which); + bay->ops->power(bay, 1); + bay->state = mb_powering_up; + MBDBG("mediabay%d: powering up\n", bay->index); + } else { + /* Make sure everything is powered down & disabled */ + bay->ops->power(bay, 0); + bay->state = mb_powering_down; + MBDBG("mediabay%d: powering down\n", bay->index); } - mb->timer = MS_TO_HZ(MB_POWER_DELAY); + bay->timer = MS_TO_HZ(MB_POWER_DELAY); } static void __pmac -set_media_bay(int which, int id) +poll_media_bay(struct media_bay_info* bay) { - volatile struct media_bay_info* bay; + int id = bay->ops->content(bay); - bay = &media_bays[which]; - - switch (id) { - case MB_CD: - if (bay->pismo) { - feature_set(bay->dev_node, FEATURE_Mediabay_IDE_switch); - udelay(10); - feature_set(bay->dev_node, FEATURE_IDE0_enable); - udelay(10); - feature_set(bay->dev_node, FEATURE_IDE0_reset); - } else { - feature_set(bay->dev_node, FEATURE_IDE1_enable); - udelay(10); - feature_set(bay->dev_node, FEATURE_IDE1_reset); + if (id == bay->last_value) { + if (id != bay->content_id + && ++bay->value_count >= MS_TO_HZ(MB_STABLE_DELAY)) { + /* If the device type changes without going thru "MB_NO", we force + a pass by "MB_NO" to make sure things are properly reset */ + if ((id != MB_NO) && (bay->content_id != MB_NO)) { + id = MB_NO; + MBDBG("mediabay%d: forcing MB_NO\n", bay->index); } - printk(KERN_INFO "media bay %d contains a CD-ROM drive\n", which); - break; - case MB_FD: - case MB_FD1: - feature_set(bay->dev_node, FEATURE_Mediabay_floppy_enable); - feature_set(bay->dev_node, FEATURE_SWIM3_enable); - printk(KERN_INFO "media bay %d contains a floppy disk drive\n", which); - break; - case MB_NO: - break; - default: - printk(KERN_INFO "media bay %d contains an unknown device (%d)\n", - which, id); - break; + MBDBG("mediabay%d: switching to %d\n", bay->index, id); + set_mb_power(bay, id != MB_NO); + bay->content_id = id; + if (id == MB_NO) { +#ifdef CONFIG_BLK_DEV_IDE + bay->cd_retry = 0; +#endif + printk(KERN_INFO "media bay %d is empty\n", bay->index); + } + } + } else { + bay->last_value = id; + bay->value_count = 0; } } @@ -412,11 +501,11 @@ static void __pmac media_bay_step(int i) { - volatile struct media_bay_info* bay = &media_bays[i]; + struct media_bay_info* bay = &media_bays[i]; /* We don't poll when powering down */ if (bay->state != mb_powering_down) - poll_media_bay(i); + poll_media_bay(bay); /* If timer expired or polling IDE busy, run state machine */ if ((bay->state != mb_ide_waiting) && (bay->timer != 0) && ((--bay->timer) != 0)) @@ -424,13 +513,17 @@ switch(bay->state) { case mb_powering_up: - set_media_bay(i, bay->last_value); + if (bay->ops->setup_bus(bay, bay->last_value) < 0) { + MBDBG("mediabay%d: device not supported (kind:%d)\n", i, bay->content_id); + set_mb_power(bay, 0); + break; + } bay->timer = MS_TO_HZ(MB_RESET_DELAY); bay->state = mb_enabling_bay; MBDBG("mediabay%d: enabling (kind:%d)\n", i, bay->content_id); break; case mb_enabling_bay: - feature_clear(bay->dev_node, FEATURE_Mediabay_reset); + bay->ops->un_reset(bay); bay->timer = MS_TO_HZ(MB_SETUP_DELAY); bay->state = mb_resetting; MBDBG("mediabay%d: waiting reset (kind:%d)\n", i, bay->content_id); @@ -444,16 +537,13 @@ } #ifdef CONFIG_BLK_DEV_IDE MBDBG("mediabay%d: waiting IDE reset (kind:%d)\n", i, bay->content_id); - if (bay->pismo) - feature_clear(bay->dev_node, FEATURE_IDE0_reset); - else - feature_clear(bay->dev_node, FEATURE_IDE1_reset); + bay->ops->un_reset_ide(bay); bay->timer = MS_TO_HZ(MB_IDE_WAIT); bay->state = mb_ide_resetting; #else printk(KERN_DEBUG "media-bay %d is ide (not compiled in kernel)\n", i); - set_mb_power(i, 0); -#endif // #ifdef CONFIG_BLK_DEV_IDE + set_mb_power(bay, 0); +#endif /* CONFIG_BLK_DEV_IDE */ break; #ifdef CONFIG_BLK_DEV_IDE @@ -481,7 +571,7 @@ /* We eventually do a retry */ bay->cd_retry++; printk("IDE register error\n"); - set_mb_power(i, 0); + set_mb_power(bay, 0); } else { printk(KERN_DEBUG "media-bay %d is ide %d\n", i, bay->cd_index); MBDBG("mediabay %d IDE ready\n", i); @@ -491,10 +581,10 @@ if (bay->timer == 0) { printk("\nIDE Timeout in bay %d !\n", i); MBDBG("mediabay%d: nIDE Timeout !\n", i); - set_mb_power(i, 0); + set_mb_power(bay, 0); } break; -#endif // #ifdef CONFIG_BLK_DEV_IDE +#endif /* CONFIG_BLK_DEV_IDE */ case mb_powering_down: bay->state = mb_empty; @@ -514,7 +604,7 @@ bay->content_id = MB_NO; } } -#endif +#endif /* CONFIG_BLK_DEV_IDE */ MBDBG("mediabay%d: end of power down\n", i); break; } @@ -526,7 +616,7 @@ * with the IDE driver. It needs to be a thread because * ide_register can't be called from interrupt context. */ -int __pmac +static int __pmac media_bay_task(void *x) { int i; @@ -547,37 +637,12 @@ } } -void __pmac -poll_media_bay(int which) +#ifdef MB_USE_INTERRUPTS +static void __pmac +media_bay_intr(int irq, void *devid, struct pt_regs *regs) { - volatile struct media_bay_info* bay = &media_bays[which]; - int id = mb_content(bay); - - if (id == bay->last_value) { - if (id != bay->content_id - && ++bay->value_count >= MS_TO_HZ(MB_STABLE_DELAY)) { - /* If the device type changes without going thru "MB_NO", we force - a pass by "MB_NO" to make sure things are properly reset */ - if ((id != MB_NO) && (bay->content_id != MB_NO)) { - id = MB_NO; - MBDBG("mediabay%d: forcing MB_NO\n", which); - } - MBDBG("mediabay%d: switching to %d\n", which, id); - set_mb_power(which, id != MB_NO); - bay->content_id = id; - if (id == MB_NO) { -#ifdef CONFIG_BLK_DEV_IDE - bay->cd_retry = 0; -#endif - printk(KERN_INFO "media bay %d is empty\n", which); - } - } - } else { - bay->last_value = id; - bay->value_count = 0; - } } - +#endif #ifdef CONFIG_PMAC_PBOOK /* @@ -586,7 +651,7 @@ int __pmac mb_notify_sleep(struct pmu_sleep_notifier *self, int when) { - volatile struct media_bay_info* bay; + struct media_bay_info* bay; int i; switch (when) { @@ -597,7 +662,7 @@ case PBOOK_SLEEP_NOW: for (i=0; i<media_bay_count; i++) { bay = &media_bays[i]; - set_mb_power(i, 0); + set_mb_power(bay, 0); mdelay(10); } break; @@ -609,14 +674,11 @@ they seem to help the 3400 get it right. */ /* Force MB power to 0 */ - set_mb_power(i, 0); + set_mb_power(bay, 0); mdelay(MB_POWER_DELAY); - if (!bay->pismo) - out_8(&bay->addr->contents, 0x70); - mdelay(MB_STABLE_DELAY); - if (mb_content(bay) != bay->content_id) + if (bay->ops->content(bay) != bay->content_id) continue; - set_mb_power(i, 1); + set_mb_power(bay, 1); bay->last_value = bay->content_id; bay->value_count = MS_TO_HZ(MB_STABLE_DELAY); bay->timer = MS_TO_HZ(MB_POWER_DELAY); @@ -634,4 +696,135 @@ return PBOOK_SLEEP_OK; } #endif /* CONFIG_PMAC_PBOOK */ + + +/* Definitions of "ops" structures. + */ +static struct mb_ops ohare_mb_ops __pmacdata = { + name: "Ohare", + content: ohare_mb_content, + power: ohare_mb_power, + setup_bus: ohare_mb_setup_bus, + un_reset: ohare_mb_un_reset, + un_reset_ide: ohare_mb_un_reset_ide, +}; + +static struct mb_ops heathrow_mb_ops __pmacdata = { + name: "Heathrow", + content: heathrow_mb_content, + power: heathrow_mb_power, + setup_bus: heathrow_mb_setup_bus, + un_reset: heathrow_mb_un_reset, + un_reset_ide: heathrow_mb_un_reset_ide, +}; + +static struct mb_ops keylargo_mb_ops __pmacdata = { + name: "KeyLargo", + content: keylargo_mb_content, + power: keylargo_mb_power, + setup_bus: keylargo_mb_setup_bus, + un_reset: keylargo_mb_un_reset, + un_reset_ide: keylargo_mb_un_reset_ide, +}; + +/* + * It seems that the bit for the media-bay interrupt in the IRQ_LEVEL + * register is always set when there is something in the media bay. + * This causes problems for the interrupt code if we attach an interrupt + * handler to the media-bay interrupt, because it tends to go into + * an infinite loop calling the media bay interrupt handler. + * Therefore we do it all by polling the media bay once each tick. + */ + +void __pmac +media_bay_init(void) +{ + struct device_node *np; + int n,i; + + for (i=0; i<MAX_BAYS; i++) { + memset((char *)&media_bays[i], 0, sizeof(struct media_bay_info)); + media_bays[i].content_id = -1; +#ifdef CONFIG_BLK_DEV_IDE + media_bays[i].cd_index = -1; +#endif + } + + np = find_devices("media-bay"); + n = 0; + while(np && (n<MAX_BAYS)) { + struct media_bay_info* bay = &media_bays[n]; + if (!np->parent || np->n_addrs == 0 || !request_OF_resource(np, 0, NULL)) { + np = np->next; + printk(KERN_ERR "media-bay: Can't request IO resource !\n"); + continue; + } + bay->mb_type = mb_ohare; + + if (device_is_compatible(np, "keylargo-media-bay")) { + bay->mb_type = mb_keylargo; + bay->ops = &keylargo_mb_ops; + } else if (device_is_compatible(np, "heathrow-media-bay")) { + bay->mb_type = mb_heathrow; + bay->ops = &heathrow_mb_ops; + } else if (device_is_compatible(np, "ohare-media-bay")) { + bay->mb_type = mb_ohare; + bay->ops = &ohare_mb_ops; + } else { + printk(KERN_ERR "mediabay: Unknown bay type !\n"); + np = np->next; + continue; + } + bay->base = (volatile u32*)ioremap(np->parent->addrs[0].address, 0x1000); + + /* Enable probe logic on keylargo */ + if (bay->mb_type == mb_keylargo) + MB_BIS(bay, KEYLARGO_MBCR, KL_MBCR_MB0_ENABLE); +#ifdef MB_USE_INTERRUPTS + if (np->n_intrs == 0) { + printk(KERN_ERR "media bay %d has no irq\n",n); + np = np->next; + continue; + } + + if (request_irq(np->intrs[0].line, media_bay_intr, 0, "Media bay", (void *)n)) { + printk(KERN_ERR "Couldn't get IRQ %d for media bay %d\n", + np->intrs[0].line, n); + np = np->next; + continue; + } +#endif + media_bay_count++; + + printk(KERN_INFO "mediabay%d: Registered %s media-bay\n", n, bay->ops->name); + bay->dev_node = np; + bay->index = n; + + /* Force an immediate detect */ + set_mb_power(bay, 0); + mdelay(MB_POWER_DELAY); + bay->content_id = MB_NO; + bay->last_value = bay->ops->content(bay); + bay->value_count = MS_TO_HZ(MB_STABLE_DELAY); + bay->state = mb_empty; + do { + mdelay(1000/HZ); + media_bay_step(n); + } while((bay->state != mb_empty) && + (bay->state != mb_up)); + + n++; + np=np->next; + } + + if (media_bay_count) + { +#ifdef CONFIG_PMAC_PBOOK + pmu_register_sleep_notifier(&mb_sleep_notifier); +#endif /* CONFIG_PMAC_PBOOK */ + + kernel_thread(media_bay_task, NULL, + CLONE_FS | CLONE_FILES | CLONE_SIGHAND); + } +} diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/macintosh/rtc.c linux-2.5/drivers/macintosh/rtc.c --- linux-2.5.1/drivers/macintosh/rtc.c Mon Oct 15 20:43:24 2001 +++ linux-2.5/drivers/macintosh/rtc.c Thu Dec 27 16:32:31 2001 @@ -34,14 +34,13 @@ void get_rtc_time(struct rtc_time *t) { unsigned long nowtime; - + nowtime = (ppc_md.get_rtc_time)(); to_tm(nowtime, t); t->tm_year -= 1900; - t->tm_mon -= 1; - t->tm_wday -= 1; + t->tm_mon -= 1; /* Make sure userland has a 0-based month */ } /* Set the current date and time in the real time clock. */ @@ -49,7 +48,8 @@ { unsigned long nowtime; - nowtime = mktime(t->tm_year+1900, t->tm_mon+1, t->tm_mday, t->tm_hour, t->tm_min, t->tm_sec); + nowtime = mktime(t->tm_year+1900, t->tm_mon+1, t->tm_mday, + t->tm_hour, t->tm_min, t->tm_sec); (ppc_md.set_rtc_time)(nowtime); } diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/macintosh/via-cuda.c linux-2.5/drivers/macintosh/via-cuda.c --- linux-2.5.1/drivers/macintosh/via-cuda.c Tue May 1 23:05:00 2001 +++ linux-2.5/drivers/macintosh/via-cuda.c Thu Dec 27 16:32:31 2001 @@ -191,6 +191,8 @@ if (via == NULL) return -ENODEV; + request_OF_resource(vias, 0, NULL); + if (request_irq(CUDA_IRQ, cuda_interrupt, 0, "ADB", cuda_interrupt)) { printk(KERN_ERR "cuda_init: can't get irq %d\n", CUDA_IRQ); return -EAGAIN; diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/macintosh/via-pmu.c linux-2.5/drivers/macintosh/via-pmu.c --- linux-2.5.1/drivers/macintosh/via-pmu.c Fri Nov 30 16:26:04 2001 +++ linux-2.5/drivers/macintosh/via-pmu.c Thu Dec 27 16:32:31 2001 @@ -9,9 +9,9 @@ * and the RTC (real time clock) chip. * * Copyright (C) 1998 Paul Mackerras and Fabio Riccardi. + * Copyright (C) 2001 Benjamin Herrenschmidt * - * todo: - Check this driver for smp safety (new Core99 motherboards). - * - Cleanup synchro between VIA interrupt and GPIO-based PMU + * todo: - Cleanup synchro between VIA interrupt and GPIO-based PMU * interrupt. * * @@ -45,10 +45,12 @@ #include <asm/sections.h> #include <asm/irq.h> #include <asm/hardirq.h> -#include <asm/feature.h> +#include <asm/pmac_feature.h> #include <asm/uaccess.h> #include <asm/mmu_context.h> +#include <asm/sections.h> #include <asm/cputable.h> +#include <asm/time.h> #ifdef CONFIG_PMAC_BACKLIGHT #include <asm/backlight.h> #endif @@ -56,9 +58,13 @@ /* Some compile options */ #undef SUSPEND_USES_PMU #define DEBUG_SLEEP +#undef HACKED_PCI_SAVE /* Misc minor number allocated for /dev/pmu */ -#define PMU_MINOR 154 +#define PMU_MINOR 154 + +/* How many iterations between battery polls */ +#define BATTERY_POLLING_COUNT 2 static volatile unsigned char *via; @@ -108,7 +114,7 @@ static struct adb_request *current_req; static struct adb_request *last_req; static struct adb_request *req_awaiting_reply; -static unsigned char interrupt_data[32]; +static unsigned char interrupt_data[256]; /* Made bigger: I've been told that might happen */ static unsigned char *reply_ptr; static int data_index; static int data_len; @@ -126,9 +132,26 @@ static int pmu_version; static int drop_interrupts; #ifdef CONFIG_PMAC_PBOOK +static int option_lid_wakeup = 1; static int sleep_in_progress; +static int can_sleep; +#endif /* CONFIG_PMAC_PBOOK */ + +static struct proc_dir_entry *proc_pmu_root; +static struct proc_dir_entry *proc_pmu_info; +static struct proc_dir_entry *proc_pmu_options; + +#ifdef CONFIG_PMAC_PBOOK +int pmu_battery_count; +int pmu_cur_battery; +unsigned int pmu_power_flags; +struct pmu_battery_info pmu_batteries[PMU_MAX_BATTERIES]; +static int query_batt_timer = BATTERY_POLLING_COUNT; +static struct adb_request batt_req; +static struct proc_dir_entry *proc_pmu_batt[PMU_MAX_BATTERIES]; #endif /* CONFIG_PMAC_PBOOK */ +int __fake_sleep; int asleep; struct notifier_block *sleep_notifier_list; @@ -153,15 +176,22 @@ static void pmu_done(struct adb_request *req); static void pmu_handle_data(unsigned char *data, int len, struct pt_regs *regs); -static void set_volume(int level); static void gpio1_interrupt(int irq, void *arg, struct pt_regs *regs); +static int proc_get_info(char *page, char **start, off_t off, + int count, int *eof, void *data); #ifdef CONFIG_PMAC_BACKLIGHT static int pmu_set_backlight_level(int level, void* data); static int pmu_set_backlight_enable(int on, int level, void* data); #endif /* CONFIG_PMAC_BACKLIGHT */ #ifdef CONFIG_PMAC_PBOOK static void pmu_pass_intr(unsigned char *data, int len); -#endif +static int proc_get_batt(char *page, char **start, off_t off, + int count, int *eof, void *data); +#endif /* CONFIG_PMAC_PBOOK */ +static int proc_read_options(char *page, char **start, off_t off, + int count, int *eof, void *data); +static int proc_write_options(struct file *file, const char *buffer, + unsigned long count, void *data); #ifdef CONFIG_ADB struct adb_driver via_pmu_driver = { @@ -309,6 +339,10 @@ } else pmu_kind = PMU_UNKNOWN; +#ifdef CONFIG_PMAC_PBOOK + if (pmac_call_feature(PMAC_FTR_SLEEP_STATE,NULL,0,-1) >= 0) + can_sleep = 1; +#endif /* CONFIG_PMAC_PBOOK */ via = (volatile unsigned char *) ioremap(vias->addrs->address, 0x2000); out_8(&via[IER], IER_CLR | 0x7f); /* disable all intrs */ @@ -362,9 +396,14 @@ if (vias == NULL) return -ENODEV; + request_OF_resource(vias, 0, NULL); + bright_req_1.complete = 1; bright_req_2.complete = 1; bright_req_3.complete = 1; +#ifdef CONFIG_PMAC_PBOOK + batt_req.complete = 1; +#endif if (request_irq(vias->intrs[0].line, via_pmu_interrupt, 0, "VIA-PMU", (void *)0)) { @@ -388,6 +427,46 @@ register_backlight_controller(&pmu_backlight_controller, NULL, "pmu"); #endif /* CONFIG_PMAC_BACKLIGHT */ +#ifdef CONFIG_PMAC_PBOOK + if (machine_is_compatible("AAPL,3400/2400") || + machine_is_compatible("AAPL,3500")) + pmu_battery_count = 1; + else if (machine_is_compatible("AAPL,PowerBook1998") || + machine_is_compatible("PowerBook1,1")) + pmu_battery_count = 2; + else { + struct device_node* prim = find_devices("power-mgt"); + u32 *prim_info = NULL; + if (prim) + prim_info = (u32 *)get_property(prim, "prim-info", NULL); + if (prim_info) { + /* Other stuffs here yet unknown */ + pmu_battery_count = (prim_info[6] >> 16) & 0xff; + } + } +#endif /# CONFIG_PMAC_PBOOK */ + /* Create /proc/pmu */ + proc_pmu_root = proc_mkdir("pmu", 0); + if (proc_pmu_root) { + int i; + proc_pmu_info = create_proc_read_entry("info", 0, proc_pmu_root, + proc_get_info, NULL); +#ifdef CONFIG_PMAC_PBOOK + for (i=0; i<pmu_battery_count; i++) { + char title[16]; + sprintf(title, "battery_%d", i); + proc_pmu_batt[i] = create_proc_read_entry(title, 0, proc_pmu_root, + proc_get_batt, (void *)i); + } +#endif /* CONFIG_PMAC_PBOOK */ + proc_pmu_options = create_proc_entry("options", 0600, proc_pmu_root); + if (proc_pmu_options) { + proc_pmu_options->nlink = 1; + proc_pmu_options->read_proc = proc_read_options; + proc_pmu_options->write_proc = proc_write_options; + } + } + /* Make sure PMU settle down before continuing. This is _very_ important * since the IDE probe may shut interrupts down for quite a bit of time. If * a PMU communication is pending while this happens, the PMU may timeout @@ -448,8 +527,8 @@ pmu_request(&req, NULL, 1, PMU_GET_VERSION); while (!req.complete) pmu_poll(); - if (req.reply_len > 1) - pmu_version = req.reply[1]; + if (req.reply_len > 0) + pmu_version = req.reply[0]; return 1; } @@ -460,6 +539,263 @@ return pmu_kind; } +#ifdef CONFIG_PMAC_PBOOK + +/* + * WARNING ! This code probably needs some debugging... -- BenH. + */ +static void __pmac +done_battery_state_ohare(struct adb_request* req) +{ + unsigned int bat_flags = 0; + int current = 0; + unsigned int capa, max, voltage, time; + int lrange[] = { 0, 275, 850, 1680, 2325, + 2765, 3160, 3500, 3830, 4115, + 4360, 4585, 4795, 4990, 5170, + 5340, 5510, 5710, 5930, 6150, + 6370, 6500 + }; + + if (req->reply[0] & 0x01) + pmu_power_flags |= PMU_PWR_AC_PRESENT; + else + pmu_power_flags &= ~PMU_PWR_AC_PRESENT; + + if (req->reply[0] & 0x04) { + int vb, i, j, charge, pcharge; + bat_flags |= PMU_BATT_PRESENT; + vb = (req->reply[1] << 8) | req->reply[2]; + voltage = ((vb * 2650) + 726650)/100; + current = *((signed char *)&req->reply[5]); + if ((req->reply[0] & 0x01) == 0 && (current > 200)) + vb += (current - 200) * 15; + else if (req->reply[0] & 0x02) + vb = (vb - 10) * 100; + i = (33000 - vb) / 10; + j = i - (i % 100); + if (j <= 0) + charge = 0; + else if (j >= 21) + charge = 650000; + else + charge = (lrange[j + 1] - lrange[j]) * (i - j) + (lrange[j] * 100); + charge = (1000 - charge / 650) / 10; + if (req->reply[0] & 0x40) { + pcharge = (req->reply[6] << 8) + req->reply[7]; + if (pcharge > 6500) + pcharge = 6500; + pcharge *= 100; + pcharge = (1000 - pcharge / 650) / 10; + if (pcharge < charge) + charge = pcharge; + } + capa = charge; + max = 100; + time = (charge * 274) / current; + current = -current; + + } else + capa = max = current = voltage = time = 0; + + if ((req->reply[0] & 0x02) && (current > 0)) + bat_flags |= PMU_BATT_CHARGING; + if (req->reply[0] & 0x04) /* CHECK THIS ONE */ + bat_flags |= PMU_BATT_PRESENT; + + pmu_batteries[pmu_cur_battery].flags = bat_flags; + pmu_batteries[pmu_cur_battery].charge = capa; + pmu_batteries[pmu_cur_battery].max_charge = max; + pmu_batteries[pmu_cur_battery].current = current; + pmu_batteries[pmu_cur_battery].voltage = voltage; + pmu_batteries[pmu_cur_battery].time_remaining = time; +} + +static void __pmac +done_battery_state_smart(struct adb_request* req) +{ + /* format: + * [0] : format of this structure (known: 3,4,5) + * [1] : flags + * + * format 3 & 4: + * + * [2] : charge + * [3] : max charge + * [4] : current + * [5] : voltage + * + * format 5: + * + * [2][3] : charge + * [4][5] : max charge + * [6][7] : current + * [8][9] : voltage + */ + + unsigned int bat_flags = 0; + int current; + unsigned int capa, max, voltage; + + if (req->reply[1] & 0x01) + pmu_power_flags |= PMU_PWR_AC_PRESENT; + else + pmu_power_flags &= ~PMU_PWR_AC_PRESENT; + + + if (req->reply[1] & 0x04) { + bat_flags |= PMU_BATT_PRESENT; + switch(req->reply[0]) { + case 3: + case 4: capa = req->reply[2]; + max = req->reply[3]; + current = *((signed char *)&req->reply[4]); + voltage = req->reply[5]; + break; + case 5: capa = (req->reply[2] << 8) | req->reply[3]; + max = (req->reply[4] << 8) | req->reply[5]; + current = *((signed short *)&req->reply[6]); + voltage = (req->reply[8] << 8) | req->reply[9]; + break; + default: + printk(KERN_WARNING "pmu.c : unrecognized battery info, len: %d, %02x %02x %02x %02x\n", + req->reply_len, req->reply[0], req->reply[1], req->reply[2], req->reply[3]); + break; + } + } else + capa = max = current = voltage = 0; + + if ((req->reply[1] & 0x01) && (current > 0)) + bat_flags |= PMU_BATT_CHARGING; + + pmu_batteries[pmu_cur_battery].flags = bat_flags; + pmu_batteries[pmu_cur_battery].charge = capa; + pmu_batteries[pmu_cur_battery].max_charge = max; + pmu_batteries[pmu_cur_battery].current = current; + pmu_batteries[pmu_cur_battery].voltage = voltage; + if (current) { + if ((req->reply[1] & 0x01) && (current > 0)) + pmu_batteries[pmu_cur_battery].time_remaining + = ((max-capa) * 3600) / current; + else + pmu_batteries[pmu_cur_battery].time_remaining + = (capa * 3600) / (-current); + } else + pmu_batteries[pmu_cur_battery].time_remaining = 0; + + pmu_cur_battery = (pmu_cur_battery + 1) % pmu_battery_count; +} + +static void __pmac +query_battery_state(void) +{ + if (!batt_req.complete) + return; + if (pmu_kind == PMU_OHARE_BASED) + pmu_request(&batt_req, done_battery_state_ohare, + 1, PMU_BATTERY_STATE); + else + pmu_request(&batt_req, done_battery_state_smart, + 2, PMU_SMART_BATTERY_STATE, pmu_cur_battery+1); +} + +#endif /* CONFIG_PMAC_PBOOK */ + +static int +proc_get_info(char *page, char **start, off_t off, + int count, int *eof, void *data) +{ + char* p = page; + + p += sprintf(p, "PMU driver version : %d\n", PMU_DRIVER_VERSION); + p += sprintf(p, "PMU firmware version : %02x\n", pmu_version); +#ifdef CONFIG_PMAC_PBOOK + p += sprintf(p, "AC Power : %d\n", + ((pmu_power_flags & PMU_PWR_AC_PRESENT) != 0)); + p += sprintf(p, "Battery count : %d\n", pmu_battery_count); +#endif /* CONFIG_PMAC_PBOOK */ + + return p - page; +} + +#ifdef CONFIG_PMAC_PBOOK +static int +proc_get_batt(char *page, char **start, off_t off, + int count, int *eof, void *data) +{ + int batnum = (int)data; + char *p = page; + + p += sprintf(p, "\n"); + p += sprintf(p, "flags : %08x\n", + pmu_batteries[batnum].flags); + p += sprintf(p, "charge : %d\n", + pmu_batteries[batnum].charge); + p += sprintf(p, "max_charge : %d\n", + pmu_batteries[batnum].max_charge); + p += sprintf(p, "current : %d\n", + pmu_batteries[batnum].current); + p += sprintf(p, "voltage : %d\n", + pmu_batteries[batnum].voltage); + p += sprintf(p, "time rem. : %d\n", + pmu_batteries[batnum].time_remaining); + + return p - page; +} +#endif /* CONFIG_PMAC_PBOOK */ + +static int +proc_read_options(char *page, char **start, off_t off, + int count, int *eof, void *data) +{ + char *p = page; + +#ifdef CONFIG_PMAC_PBOOK + if (pmu_kind == PMU_KEYLARGO_BASED && can_sleep) + p += sprintf(p, "lid_wakeup=%d\n", option_lid_wakeup); +#endif /* CONFIG_PMAC_PBOOK */ + + return p - page; +} + +static int +proc_write_options(struct file *file, const char *buffer, + unsigned long count, void *data) +{ + char tmp[33]; + char *label, *val; + unsigned long fcount = count; + + if (!count) + return -EINVAL; + if (count > 32) + count = 32; + if (copy_from_user(tmp, buffer, count)) + return -EFAULT; + tmp[count] = 0; + + label = tmp; + while(*label == ' ') + label++; + val = label; + while(*val && (*val != '=')) { + if (*val == ' ') + *val = 0; + val++; + } + if ((*val) == 0) + return -EINVAL; + *(val++) = 0; + while(*val == ' ') + val++; +#ifdef CONFIG_PMAC_PBOOK + if (pmu_kind == PMU_KEYLARGO_BASED && can_sleep) + if (!strcmp(label, "lid_wakeup")) + option_lid_wakeup = ((*val) == '1'); +#endif /* CONFIG_PMAC_PBOOK */ + return fcount; +} + #ifdef CONFIG_ADB /* Send an ADB command */ static int __openfirmware @@ -622,11 +958,7 @@ for (i = 0; i < nbytes; ++i) req->data[i] = va_arg(list, int); va_end(list); - if (pmu_data_len[req->data[0]][1] != 0) { - req->reply[0] = ADB_RET_OK; - req->reply_len = 1; - } else - req->reply_len = 0; + req->reply_len = 0; req->reply_expected = 0; return pmu_queue_request(req); } @@ -835,10 +1167,14 @@ spin_lock_irqsave(&pmu_lock, flags); ++disable_poll; - while ((intr = in_8(&via[IFR])) != 0) { + for (;;) { + intr = in_8(&via[IFR]) & (SR_INT | CB1_INT); + if (intr == 0) + break; if (++nloop > 1000) { printk(KERN_DEBUG "PMU: stuck in intr loop, " - "intr=%x pmu_state=%d\n", intr, pmu_state); + "intr=%x, ier=%x pmu_state=%d\n", + intr, in_8(&via[IER]), pmu_state); break; } out_8(&via[IFR], intr); @@ -847,15 +1183,6 @@ else if (intr & CB1_INT) adb_int_pending = 1; } - /* This is not necessary except if synchronous ADB requests are done - * with interrupts off, which should not happen. Since I'm not sure - * this "wiring" will remain, I'm commenting it out for now. Please do - * not remove. -- BenH. - */ -#if 0 - if (gpio_reg && !pmu_suspended && (in_8(gpio_reg + 0x9) & 0x02) == 0) - adb_int_pending = 1; -#endif if (pmu_state == idle) { if (adb_int_pending) { @@ -866,9 +1193,8 @@ wait_for_ack(); send_byte(PMU_INT_ACK); adb_int_pending = 0; - } else if (current_req) { + } else if (current_req) pmu_start(); - } } --disable_poll; @@ -878,8 +1204,10 @@ static void __openfirmware gpio1_interrupt(int irq, void *arg, struct pt_regs *regs) { - adb_int_pending = 1; - via_pmu_interrupt(0, 0, 0); + if ((in_8(gpio_reg + 0x9) & 0x02) == 0) { + adb_int_pending = 1; + via_pmu_interrupt(0, 0, 0); + } } static void __openfirmware @@ -1040,16 +1368,25 @@ adb_input(data+1, len-1, regs, 1); #endif /* CONFIG_ADB */ } - } else if (data[0] == 0x08 && len == 3) { - /* sound/brightness buttons pressed */ + } else { + /* Sound/brightness button pressed */ + if ((data[0] & PMU_INT_SNDBRT) && len == 3) { #ifdef CONFIG_PMAC_BACKLIGHT - set_backlight_level(data[1] >> 4); + set_backlight_level(data[1] >> 4); #endif - set_volume(data[2]); - } else { + } #ifdef CONFIG_PMAC_PBOOK - pmu_pass_intr(data, len); -#endif + /* Environement or tick interrupt, query batteries */ + if (pmu_battery_count && (data[0] & PMU_INT_TICK)) { + if ((--query_batt_timer) == 0) { + query_battery_state(); + query_batt_timer = BATTERY_POLLING_COUNT; + } + } else if (pmu_battery_count && (data[0] & PMU_INT_ENVIRONMENT)) + query_battery_state(); + if (data[0]) + pmu_pass_intr(data, len); +#endif /* CONFIG_PMAC_PBOOK */ } } @@ -1116,11 +1453,6 @@ pmu_poll(); } -static void __openfirmware -set_volume(int level) -{ -} - void __openfirmware pmu_restart(void) { @@ -1266,10 +1598,14 @@ * PCI devices which may get powered off when we sleep. */ static struct pci_save { +#ifndef HACKED_PCI_SAVE u16 command; u16 cache_lat; u16 intr; u32 rom_address; +#else + u32 config[16]; +#endif } *pbook_pci_saves; static int n_pbook_pci_saves; @@ -1293,14 +1629,24 @@ return; pci_for_each_dev(pd) { +#ifndef HACKED_PCI_SAVE pci_read_config_word(pd, PCI_COMMAND, &ps->command); pci_read_config_word(pd, PCI_CACHE_LINE_SIZE, &ps->cache_lat); pci_read_config_word(pd, PCI_INTERRUPT_LINE, &ps->intr); pci_read_config_dword(pd, PCI_ROM_ADDRESS, &ps->rom_address); +#else + int i; + for (i=1;i<16;i++) + pci_read_config_dword(pd, i<<4, &ps->config[i]); +#endif ++ps; } } +/* For this to work, we must take care of a few things: If gmac was enabled + * during boot, it will be in the pci dev list. If it's disabled at this point + * (and it will probably be), then you can't access it's config space. + */ static void __openfirmware pbook_pci_restore(void) { @@ -1310,7 +1656,13 @@ int j; pci_for_each_dev(pd) { +#ifdef HACKED_PCI_SAVE + int i; ps++; + for (i=2;i<16;i++) + pci_write_config_dword(pd, i<<4, ps->config[i]); + pci_write_config_dword(pd, 4, ps->config[1]); +#else if (ps->command == 0) continue; pci_read_config_word(pd, PCI_COMMAND, &cmd); @@ -1330,8 +1682,8 @@ ps->intr); pci_write_config_word(pd, PCI_COMMAND, ps->command); break; - /* other header types not restored at present */ } +#endif } } @@ -1370,7 +1722,7 @@ } mdelay(50); } -#endif /* DEBUG_SLEEP */ +#endif /* * Put the powerbook to sleep. @@ -1403,6 +1755,15 @@ out_8(&via[IER], IER_SET | SR_INT | CB1_INT); } +static inline void wakeup_decrementer(void) +{ + set_dec(tb_ticks_per_jiffy); + /* No currently-supported powerbook has a 601, + * so use get_tbl, not native + */ + last_jiffy_stamp(0) = tb_last_stamp = get_tbl(); +} + #define GRACKLE_PM (1<<7) #define GRACKLE_DOZE (1<<5) #define GRACKLE_NAP (1<<4) @@ -1436,6 +1797,10 @@ * vmalloc's are done before actual sleep of block drivers */ fsync_dev(0); + /* Give the disks a little time to actually finish writing */ + for (wait = jiffies + (HZ/2); time_before(jiffies, wait); ) + mb(); + /* Sleep can fail now. May not be very robust but useful for debugging */ ret = broadcast_sleep(PBOOK_SLEEP_NOW, PBOOK_WAKE); if (ret != PBOOK_SLEEP_OK) { @@ -1443,13 +1808,9 @@ return -EBUSY; } - /* Give the disks a little time to actually finish writing */ - for (wait = jiffies + (HZ/2); time_before(jiffies, wait); ) - mb(); - /* Wait for completion of async backlight requests */ while (!bright_req_1.complete || !bright_req_2.complete || - !bright_req_3.complete) + !bright_req_3.complete || !batt_req.complete) pmu_poll(); /* Turn off various things. Darwin does some retry tests here... */ @@ -1495,7 +1856,7 @@ /* The VIA is supposed not to be restored correctly*/ save_via_state(); /* We shut down some HW */ - feature_prepare_for_sleep(); + pmac_call_feature(PMAC_FTR_SLEEP_STATE,NULL,0,1); pci_read_config_word(grackle, 0x70, &pmcr1); /* Apparently, MacOS uses NAP mode for Grackle ??? */ @@ -1512,7 +1873,7 @@ pci_write_config_word(grackle, 0x70, pmcr1); /* Make sure the PMU is idle */ - feature_wake_up(); + pmac_call_feature(PMAC_FTR_SLEEP_STATE,NULL,0,0); restore_via_state(); /* Restore L2 cache */ @@ -1522,11 +1883,6 @@ /* Restore userland MMU context */ set_context(current->active_mm->context, current->active_mm->pgd); - /* Re-enable DEC interrupts and kick DEC */ - asm volatile("mtdec %0" : : "r" (0x7fffffff)); - sti(); - asm volatile("mtdec %0" : : "r" (0x10000000)); - /* Power things up */ pmu_request(&req, NULL, 2, PMU_SET_INTR_MASK, 0xfc); while (!req.complete) @@ -1558,6 +1914,10 @@ /* Leave some time for HW to settle down */ mdelay(100); + /* Restart jiffies & scheduling */ + wakeup_decrementer(); + sti(); + /* Notify drivers */ broadcast_wake(); @@ -1571,7 +1931,7 @@ struct adb_request req; int ret, timeout; - if (!feature_can_sleep()) { + if (!can_sleep) { printk(KERN_ERR "Sleep mode not supported on this machine\n"); return -ENOSYS; } @@ -1591,20 +1951,19 @@ * vmalloc's are done before actual sleep of block drivers */ fsync_dev(0); + /* Give the disks a little time to actually finish writing */ + for (wait = jiffies + HZ; time_before(jiffies, wait); ) + mb(); + /* Sleep can fail now. May not be very robust but useful for debugging */ ret = broadcast_sleep(PBOOK_SLEEP_NOW, PBOOK_WAKE); if (ret != PBOOK_SLEEP_OK) { printk("pmu: sleep failed\n"); return -EBUSY; } - - /* Give the disks a little time to actually finish writing */ - for (wait = jiffies + HZ; time_before(jiffies, wait); ) - mb(); - /* Wait for completion of async backlight requests */ while (!bright_req_1.complete || !bright_req_2.complete || - !bright_req_3.complete) + !bright_req_3.complete || !batt_req.complete) pmu_poll(); /* Tell PMU what events will wake us up */ @@ -1614,7 +1973,8 @@ pmu_poll(); pmu_request(&req, NULL, 4, PMU_POWER_EVENTS, PMU_PWR_SET_WAKEUP_EVENTS, - 0, PMU_PWR_WAKEUP_KEY | PMU_PWR_WAKEUP_LID_OPEN); + 0, PMU_PWR_WAKEUP_KEY | + (option_lid_wakeup ? PMU_PWR_WAKEUP_LID_OPEN : 0)); while (!req.complete) pmu_poll(); @@ -1651,10 +2011,12 @@ /* Save the state of PCI config space for some slots */ //pbook_pci_save(); - /* Ask the PMU to put us to sleep */ - pmu_request(&req, NULL, 5, PMU_SLEEP, 'M', 'A', 'T', 'T'); - while (!req.complete && pmu_state != idle) - pmu_poll(); + if (!__fake_sleep) { + /* Ask the PMU to put us to sleep */ + pmu_request(&req, NULL, 5, PMU_SLEEP, 'M', 'A', 'T', 'T'); + while (!req.complete && pmu_state != idle) + pmu_poll(); + } out_8(&via[B], in_8(&via[B]) | TREQ); wait_for_ack(); @@ -1666,13 +2028,16 @@ * talk to the PMU after this, so I moved it to _after_ sending the * sleep command to it. Still need to be checked. */ - feature_prepare_for_sleep(); + pmac_call_feature(PMAC_FTR_SLEEP_STATE,NULL,0,1); /* Call low-level ASM sleep handler */ - low_sleep_handler(); + if (__fake_sleep) + mdelay(5000); + else + low_sleep_handler(); /* Restore Apple core ASICs state */ - feature_wake_up(); + pmac_call_feature(PMAC_FTR_SLEEP_STATE,NULL,0,0); /* Restore VIA */ restore_via_state(); @@ -1694,11 +2059,6 @@ /* Restore userland MMU context */ set_context(current->active_mm->context, current->active_mm->pgd); - /* Re-enable DEC interrupts and kick DEC */ - asm volatile("mtdec %0" : : "r" (0x7fffffff)); - sti(); - asm volatile("mtdec %0" : : "r" (0x10000000)); - /* Tell PMU we are ready */ pmu_request(&req, NULL, 2, PMU_SYSTEM_READY, 2); while (!req.complete) @@ -1725,6 +2085,10 @@ /* Leave some time for HW to settle down */ mdelay(100); + /* Restart jiffies & scheduling */ + wakeup_decrementer(); + sti(); + /* Notify drivers */ broadcast_wake(); @@ -1766,6 +2130,10 @@ * vmalloc's are done before actual sleep of block drivers */ fsync_dev(0); + /* Give the disks a little time to actually finish writing */ + for (wait = jiffies + (HZ/4); time_before(jiffies, wait); ) + mb(); + /* Sleep can fail now. May not be very robust but useful for debugging */ ret = broadcast_sleep(PBOOK_SLEEP_NOW, PBOOK_WAKE); if (ret != PBOOK_SLEEP_OK) { @@ -1773,13 +2141,9 @@ return -EBUSY; } - /* Give the disks a little time to actually finish writing */ - for (wait = jiffies + (HZ/4); time_before(jiffies, wait); ) - mb(); - /* Wait for completion of async backlight requests */ while (!bright_req_1.complete || !bright_req_2.complete || - !bright_req_3.complete) + !bright_req_3.complete || !batt_req.complete) pmu_poll(); /* Disable all interrupts except pmu */ @@ -1811,6 +2175,8 @@ while (!sleep_req.complete) mb(); + pmac_call_feature(PMAC_FTR_SLEEP_STATE,NULL,0,1); + /* displacement-flush the L2 cache - necessary? */ for (p = KERNELBASE; p < KERNELBASE + 0x100000; p += 0x1000) i = *(volatile int *)p; @@ -1825,20 +2191,23 @@ /* OK, we're awake again, start restoring things */ out_be32(mem_ctrl_sleep, 0x3f); + pmac_call_feature(PMAC_FTR_SLEEP_STATE,NULL,0,0); pbook_pci_restore(); /* wait for the PMU interrupt sequence to complete */ while (asleep) mb(); - /* Re-enable DEC interrupts and kick DEC */ - asm volatile("mtdec %0" : : "r" (0x7fffffff)); - sti(); - asm volatile("mtdec %0" : : "r" (0x10000000)); - /* reenable interrupts */ pmac_sleep_restore_intrs(); + /* Leave some time for HW to settle down */ + mdelay(100); + + /* Restart jiffies & scheduling */ + wakeup_decrementer(); + sti(); + /* Notify drivers */ broadcast_wake(); @@ -1877,6 +2246,7 @@ spin_lock_irqsave(&all_pvt_lock, flags); for (list = &all_pmu_pvt; (list = list->next) != &all_pmu_pvt; ) { pp = list_entry(list, struct pmu_private, list); + spin_lock(&pp->lock); i = pp->rb_put + 1; if (i >= RB_SIZE) i = 0; @@ -1887,6 +2257,7 @@ pp->rb_put = i; wake_up_interruptible(&pp->wait); } + spin_unlock(&pp->lock); } spin_unlock_irqrestore(&all_pvt_lock, flags); } @@ -1914,6 +2285,7 @@ { struct pmu_private *pp = file->private_data; DECLARE_WAITQUEUE(wait, current); + unsigned long flags; int ret; if (count < 1 || pp == 0) @@ -1922,38 +2294,41 @@ if (ret) return ret; + spin_lock_irqsave(&pp->lock, flags); add_wait_queue(&pp->wait, &wait); current->state = TASK_INTERRUPTIBLE; for (;;) { ret = -EAGAIN; - spin_lock(&pp->lock); if (pp->rb_get != pp->rb_put) { int i = pp->rb_get; struct rb_entry *rp = &pp->rb_buf[i]; ret = rp->len; + spin_unlock_irqrestore(&pp->lock, flags); if (ret > count) ret = count; if (ret > 0 && copy_to_user(buf, rp->data, ret)) ret = -EFAULT; if (++i >= RB_SIZE) i = 0; + spin_lock_irqsave(&pp->lock, flags); pp->rb_get = i; } - spin_unlock(&pp->lock); if (ret >= 0) break; - if (file->f_flags & O_NONBLOCK) break; ret = -ERESTARTSYS; if (signal_pending(current)) break; + spin_unlock_irqrestore(&pp->lock, flags); schedule(); + spin_lock_irqsave(&pp->lock, flags); } current->state = TASK_RUNNING; remove_wait_queue(&pp->wait, &wait); - + spin_unlock_irqrestore(&pp->lock, flags); + return ret; } @@ -1967,14 +2342,15 @@ { struct pmu_private *pp = filp->private_data; unsigned int mask = 0; - + unsigned long flags; + if (pp == 0) return 0; poll_wait(filp, &pp->wait, wait); - spin_lock(&pp->lock); + spin_lock_irqsave(&pp->lock, flags); if (pp->rb_get != pp->rb_put) mask |= POLLIN; - spin_unlock(&pp->lock); + spin_unlock_irqrestore(&pp->lock, flags); return mask; } @@ -2023,7 +2399,7 @@ sleep_in_progress = 0; return error; case PMU_IOC_CAN_SLEEP: - return put_user(feature_can_sleep(), (__u32 *)arg); + return put_user((u32)can_sleep, (__u32 *)arg); #ifdef CONFIG_PMAC_BACKLIGHT /* Backlight should have its own device or go via @@ -2153,5 +2529,8 @@ EXPORT_SYMBOL(pmu_register_sleep_notifier); EXPORT_SYMBOL(pmu_unregister_sleep_notifier); EXPORT_SYMBOL(pmu_enable_irled); +EXPORT_SYMBOL(pmu_battery_count); +EXPORT_SYMBOL(pmu_batteries); +EXPORT_SYMBOL(pmu_power_flags); #endif /* CONFIG_PMAC_PBOOK */ diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/md/lvm-fs.c linux-2.5/drivers/md/lvm-fs.c --- linux-2.5.1/drivers/md/lvm-fs.c Sun Nov 11 18:09:32 2001 +++ linux-2.5/drivers/md/lvm-fs.c Mon Dec 17 17:16:14 2001 @@ -30,6 +30,7 @@ * 04/10/2001 - corrected devfs_register() call in lvm_init_fs() * 11/04/2001 - don't devfs_register("lvm") as user-space always does it * 10/05/2001 - show more of PV name in /proc/lvm/global + * 16/12/2001 - fix devfs unregister order and prevent duplicate unreg (REG) * */ @@ -138,7 +139,7 @@ int i; devfs_unregister(ch_devfs_handle[vg_ptr->vg_number]); - devfs_unregister(vg_devfs_handle[vg_ptr->vg_number]); + ch_devfs_handle[vg_ptr->vg_number] = NULL; /* remove lv's */ for(i = 0; i < vg_ptr->lv_max; i++) @@ -148,6 +149,10 @@ for(i = 0; i < vg_ptr->pv_max; i++) if(vg_ptr->pv[i]) lvm_fs_remove_pv(vg_ptr, vg_ptr->pv[i]); + /* must not remove directory before leaf nodes */ + devfs_unregister(vg_devfs_handle[vg_ptr->vg_number]); + vg_devfs_handle[vg_ptr->vg_number] = NULL; + if(vg_ptr->vg_dir_pde) { remove_proc_entry(LVM_LV_SUBDIR, vg_ptr->vg_dir_pde); vg_ptr->lv_subdir_pde = NULL; @@ -189,6 +194,7 @@ void lvm_fs_remove_lv(vg_t *vg_ptr, lv_t *lv) { devfs_unregister(lv_devfs_handle[MINOR(lv->lv_dev)]); + lv_devfs_handle[MINOR(lv->lv_dev)] = NULL; if(vg_ptr->lv_subdir_pde) { const char *name = _basename(lv->lv_name); diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/md/lvm-snap.c linux-2.5/drivers/md/lvm-snap.c --- linux-2.5.1/drivers/md/lvm-snap.c Tue Nov 27 17:23:27 2001 +++ linux-2.5/drivers/md/lvm-snap.c Thu Dec 27 22:10:28 2001 @@ -206,20 +206,6 @@ return 1; } -inline int lvm_get_blksize(kdev_t dev) -{ - int correct_size = BLOCK_SIZE, i, major; - - major = MAJOR(dev); - if (blksize_size[major]) - { - i = blksize_size[major][MINOR(dev)]; - if (i) - correct_size = i; - } - return correct_size; -} - #ifdef DEBUG_SNAPSHOT static inline void invalidate_snap_cache(unsigned long start, unsigned long nr, kdev_t dev) @@ -256,7 +242,7 @@ is--; blksize_snap = - lvm_get_blksize(lv_snap->lv_block_exception[is].rdev_new); + block_size(lv_snap->lv_block_exception[is].rdev_new); is -= is % (blksize_snap / sizeof(lv_COW_table_disk_t)); memset(lv_COW_table, 0, blksize_snap); @@ -347,8 +333,8 @@ iobuf = lv_snap->lv_iobuf; - blksize_org = lvm_get_blksize(org_phys_dev); - blksize_snap = lvm_get_blksize(snap_phys_dev); + blksize_org = block_size(org_phys_dev); + blksize_snap = block_size(snap_phys_dev); max_blksize = max(blksize_org, blksize_snap); min_blksize = min(blksize_org, blksize_snap); max_sectors = LVM_MAX_SECTORS * (min_blksize>>9); @@ -592,7 +578,7 @@ snap_phys_dev = lv_snap->lv_block_exception[idx].rdev_new; snap_pe_start = lv_snap->lv_block_exception[idx - (idx % COW_entries_per_pe)].rsector_new - lv_snap->lv_chunk_size; - blksize_snap = lvm_get_blksize(snap_phys_dev); + blksize_snap = block_size(snap_phys_dev); COW_entries_per_block = blksize_snap / sizeof(lv_COW_table_disk_t); idx_COW_table = idx % COW_entries_per_pe % COW_entries_per_block; @@ -640,7 +626,7 @@ idx++; snap_phys_dev = lv_snap->lv_block_exception[idx].rdev_new; snap_pe_start = lv_snap->lv_block_exception[idx - (idx % COW_entries_per_pe)].rsector_new - lv_snap->lv_chunk_size; - blksize_snap = lvm_get_blksize(snap_phys_dev); + blksize_snap = block_size(snap_phys_dev); blocks[0] = snap_pe_start >> (blksize_snap >> 10); } else blocks[0]++; diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/md/lvm.c linux-2.5/drivers/md/lvm.c --- linux-2.5.1/drivers/md/lvm.c Thu Nov 29 15:48:43 2001 +++ linux-2.5/drivers/md/lvm.c Sun Dec 30 21:17:30 2001 @@ -179,6 +179,9 @@ * (Jens Axboe) * - Defer writes to an extent that is being moved [JT + AD] * 28/05/2001 - implemented missing BLKSSZGET ioctl [AD] + * 28/12/2001 - buffer_head -> bio + * removed huge allocation of a lv_t on stack + * (Anders Gustafsson) * */ @@ -209,7 +212,6 @@ #include <linux/devfs_fs_kernel.h> #include <linux/smp_lock.h> #include <asm/ioctl.h> -#include <asm/segment.h> #include <asm/uaccess.h> #ifdef CONFIG_KERNELD @@ -1043,7 +1045,7 @@ memset(&bio,0,sizeof(bio)); bio.bi_dev = inode->i_rdev; - bio.bi_io_vec.bv_len = lvm_get_blksize(bio.bi_dev); + bio.bi_size = lvm_get_blksize(bio.bi_dev); /* NEEDED by bio_sectors */ bio.bi_sector = block * bio_sectors(&bio); bio.bi_rw = READ; if ((err=lvm_map(&bio)) < 0) { @@ -1119,19 +1121,18 @@ return 0; } -static int lvm_map(struct bio *bh) +static int lvm_map(struct bio *bi) { - int minor = MINOR(bh->bi_dev); + int minor = MINOR(bi->bi_dev); ulong index; ulong pe_start; - ulong size = bio_sectors(bh); - ulong rsector_org = bh->bi_sector; + ulong size = bio_sectors(bi); + ulong rsector_org = bi->bi_sector; ulong rsector_map; kdev_t rdev_map; vg_t *vg_this = vg[VG_BLK(minor)]; lv_t *lv = vg_this->lv[LV_BLK(minor)]; - int rw = bio_data_dir(bh); - + int rw = bio_rw(bi); down_read(&lv->lv_lock); if (!(lv->lv_status & LV_ACTIVE)) { @@ -1151,7 +1152,7 @@ P_MAP("%s - lvm_map minor: %d *rdev: %s *rsector: %lu size:%lu\n", lvm_name, minor, - kdevname(bh->bi_dev), + kdevname(bi->bi_dev), rsector_org, size); if (rsector_org + size > lv->lv_size) { @@ -1205,7 +1206,7 @@ * we need to queue this request, because this is in the fast path. */ if (rw == WRITE || rw == WRITEA) { - if(_defer_extent(bh, rw, rdev_map, + if(_defer_extent(bi, rw, rdev_map, rsector_map, vg_this->pe_size)) { up_read(&lv->lv_lock); @@ -1246,13 +1247,13 @@ } out: - bh->bi_dev = rdev_map; - bh->bi_sector = rsector_map; + bi->bi_dev = rdev_map; + bi->bi_sector = rsector_map; up_read(&lv->lv_lock); return 1; bad: - bio_io_error(bh); + bio_io_error(bi); up_read(&lv->lv_lock); return -1; } /* lvm_map() */ @@ -1436,9 +1437,9 @@ { int ret = 0; ulong l, ls = 0, p, size; - lv_t lv; vg_t *vg_ptr; lv_t **snap_lv_ptr; + lv_t *tmplv; if ((vg_ptr = kmalloc(sizeof(vg_t),GFP_KERNEL)) == NULL) { printk(KERN_CRIT @@ -1446,6 +1447,7 @@ lvm_name, __LINE__); return -ENOMEM; } + /* get the volume group structure */ if (copy_from_user(vg_ptr, arg, sizeof(vg_t)) != 0) { P_IOCTL("lvm_do_vg_create ERROR: copy VG ptr %p (%d bytes)\n", @@ -1454,6 +1456,8 @@ return -EFAULT; } + + /* VG_CREATE now uses minor number in VG structure */ if (minor == -1) minor = vg_ptr->vg_number; @@ -1513,19 +1517,30 @@ } memset(snap_lv_ptr, 0, size); + if ((tmplv = kmalloc(sizeof(lv_t),GFP_KERNEL)) == NULL) { + printk(KERN_CRIT + "%s -- VG_CREATE: kmalloc error LV at line %d\n", + lvm_name, __LINE__); + vfree(snap_lv_ptr); + return -ENOMEM; + } + /* get the logical volume structures */ vg_ptr->lv_cur = 0; for (l = 0; l < vg_ptr->lv_max; l++) { lv_t *lvp; + /* user space address */ if ((lvp = vg_ptr->lv[l]) != NULL) { - if (copy_from_user(&lv, lvp, sizeof(lv_t)) != 0) { + if (copy_from_user(tmplv, lvp, sizeof(lv_t)) != 0) { P_IOCTL("ERROR: copying LV ptr %p (%d bytes)\n", lvp, sizeof(lv_t)); lvm_do_vg_remove(minor); + vfree(snap_lv_ptr); + kfree(tmplv); return -EFAULT; } - if ( lv.lv_access & LV_SNAPSHOT) { + if ( tmplv->lv_access & LV_SNAPSHOT) { snap_lv_ptr[ls] = lvp; vg_ptr->lv[l] = NULL; ls++; @@ -1533,8 +1548,10 @@ } vg_ptr->lv[l] = NULL; /* only create original logical volumes for now */ - if (lvm_do_lv_create(minor, lv.lv_name, &lv) != 0) { + if (lvm_do_lv_create(minor, tmplv->lv_name, tmplv) != 0) { lvm_do_vg_remove(minor); + vfree(snap_lv_ptr); + kfree(tmplv); return -EFAULT; } } @@ -1544,18 +1561,22 @@ in place during first path above */ for (l = 0; l < ls; l++) { lv_t *lvp = snap_lv_ptr[l]; - if (copy_from_user(&lv, lvp, sizeof(lv_t)) != 0) { + if (copy_from_user(tmplv, lvp, sizeof(lv_t)) != 0) { lvm_do_vg_remove(minor); + vfree(snap_lv_ptr); + kfree(tmplv); return -EFAULT; } - if (lvm_do_lv_create(minor, lv.lv_name, &lv) != 0) { + if (lvm_do_lv_create(minor, tmplv->lv_name, tmplv) != 0) { lvm_do_vg_remove(minor); + vfree(snap_lv_ptr); + kfree(tmplv); return -EFAULT; } } vfree(snap_lv_ptr); - + kfree(tmplv); vg_count++; diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/md/md.c linux-2.5/drivers/md/md.c --- linux-2.5.1/drivers/md/md.c Tue Dec 11 21:47:35 2001 +++ linux-2.5/drivers/md/md.c Thu Dec 27 22:10:28 2001 @@ -66,7 +66,7 @@ /* * Current RAID-1,4,5 parallel reconstruction 'guaranteed speed limit' - * is 100 KB/sec, so the extra system load does not show up that much. + * is 1000 KB/sec, so the extra system load does not show up that much. * Increase it if you want to have more _guaranteed_ speed. Note that * the RAID driver will use the maximum available bandwith if the IO * subsystem is idle. There is also an 'absolute maximum' reconstruction @@ -76,8 +76,8 @@ * you can change it via /proc/sys/dev/raid/speed_limit_min and _max. */ -static int sysctl_speed_limit_min = 100; -static int sysctl_speed_limit_max = 100000; +static int sysctl_speed_limit_min = 1000; +static int sysctl_speed_limit_max = 200000; static struct ctl_table_header *raid_table_header; @@ -469,40 +469,45 @@ static int read_disk_sb(mdk_rdev_t * rdev) { - int ret = -EINVAL; - struct buffer_head *bh = NULL; - kdev_t dev = rdev->dev; - mdp_super_t *sb; + struct address_space *mapping = rdev->bdev->bd_inode->i_mapping; + struct page *page; + char *p; unsigned long sb_offset; + int n = PAGE_CACHE_SIZE / BLOCK_SIZE; if (!rdev->sb) { MD_BUG(); - goto abort; + return -EINVAL; } /* * Calculate the position of the superblock, - * it's at the end of the disk + * it's at the end of the disk. + * + * It also happens to be a multiple of 4Kb. */ sb_offset = calc_dev_sboffset(rdev->dev, rdev->mddev, 1); rdev->sb_offset = sb_offset; - fsync_dev(dev); - set_blocksize (dev, MD_SB_BYTES); - bh = bread (dev, sb_offset / MD_SB_BLOCKS, MD_SB_BYTES); - - if (bh) { - sb = (mdp_super_t *) bh->b_data; - memcpy (rdev->sb, sb, MD_SB_BYTES); - } else { - printk(NO_SB,partition_name(rdev->dev)); - goto abort; - } + page = read_cache_page(mapping, sb_offset/n, + (filler_t *)mapping->a_ops->readpage, NULL); + if (IS_ERR(page)) + goto out; + wait_on_page(page); + if (!Page_Uptodate(page)) + goto fail; + if (PageError(page)) + goto fail; + p = (char *)page_address(page) + BLOCK_SIZE * (sb_offset % n); + memcpy((char*)rdev->sb, p, MD_SB_BYTES); + page_cache_release(page); printk(KERN_INFO " [events: %08lx]\n", (unsigned long)rdev->sb->events_lo); - ret = 0; -abort: - if (bh) - brelse (bh); - return ret; + return 0; + +fail: + page_cache_release(page); +out: + printk(NO_SB,partition_name(rdev->dev)); + return -EINVAL; } static unsigned int calc_sb_csum(mdp_super_t * sb) @@ -884,15 +889,14 @@ return NULL; } -#define GETBLK_FAILED KERN_ERR \ -"md: getblk failed for device %s\n" - static int write_disk_sb(mdk_rdev_t * rdev) { - struct buffer_head *bh; - kdev_t dev; + struct address_space *mapping = rdev->bdev->bd_inode->i_mapping; + struct page *page; + unsigned offs; + int error; + kdev_t dev = rdev->dev; unsigned long sb_offset, size; - mdp_super_t *sb; if (!rdev->sb) { MD_BUG(); @@ -907,7 +911,6 @@ return 1; } - dev = rdev->dev; sb_offset = calc_dev_sboffset(dev, rdev->mddev, 1); if (rdev->sb_offset != sb_offset) { printk(KERN_INFO "%s's sb offset has changed from %ld to %ld, skipping\n", @@ -928,26 +931,32 @@ printk(KERN_INFO "(write) %s's sb offset: %ld\n", partition_name(dev), sb_offset); fsync_dev(dev); - set_blocksize(dev, MD_SB_BYTES); - bh = getblk(dev, sb_offset / MD_SB_BLOCKS, MD_SB_BYTES); - if (!bh) { - printk(GETBLK_FAILED, partition_name(dev)); - return 1; - } - memset(bh->b_data,0,bh->b_size); - sb = (mdp_super_t *) bh->b_data; - memcpy(sb, rdev->sb, MD_SB_BYTES); - - mark_buffer_uptodate(bh, 1); - mark_buffer_dirty(bh); - ll_rw_block(WRITE, 1, &bh); - wait_on_buffer(bh); - brelse(bh); + page = grab_cache_page(mapping, sb_offset/(PAGE_CACHE_SIZE/BLOCK_SIZE)); + offs = sb_offset % (PAGE_CACHE_SIZE/BLOCK_SIZE); + if (!page) + goto fail; + error = mapping->a_ops->prepare_write(NULL, page, offs, + offs + MD_SB_BYTES); + if (error) + goto unlock; + memcpy((char *)page_address(page) + offs, rdev->sb, MD_SB_BYTES); + error = mapping->a_ops->commit_write(NULL, page, offs, + offs + MD_SB_BYTES); + if (error) + goto unlock; + UnlockPage(page); + wait_on_page(page); + page_cache_release(page); fsync_dev(dev); skip: return 0; +unlock: + UnlockPage(page); + page_cache_release(page); +fail: + printk("md: write_disk_sb failed for device %s\n", partition_name(dev)); + return 1; } -#undef GETBLK_FAILED static void set_this_disk(mddev_t *mddev, mdk_rdev_t *rdev) { @@ -3336,7 +3345,7 @@ int md_do_sync(mddev_t *mddev, mdp_disk_t *spare) { mddev_t *mddev2; - unsigned int max_sectors, currspeed, + unsigned int max_sectors, currspeed = 0, j, window, err, serialize; unsigned long mark[SYNC_MARKS]; unsigned long mark_cnt[SYNC_MARKS]; @@ -3376,8 +3385,7 @@ max_sectors = mddev->sb->size << 1; printk(KERN_INFO "md: syncing RAID array md%d\n", mdidx(mddev)); - printk(KERN_INFO "md: minimum _guaranteed_ reconstruction speed: %d KB/sec/disc.\n", - sysctl_speed_limit_min); + printk(KERN_INFO "md: minimum _guaranteed_ reconstruction speed: %d KB/sec/disc.\n", sysctl_speed_limit_min); printk(KERN_INFO "md: using maximum available idle IO bandwith " "(but not more than %d KB/sec) for reconstruction.\n", sysctl_speed_limit_max); @@ -3409,7 +3417,7 @@ for (j = 0; j < max_sectors;) { int sectors; - sectors = mddev->pers->sync_request(mddev, j); + sectors = mddev->pers->sync_request(mddev, j, currspeed < sysctl_speed_limit_min); if (sectors < 0) { err = sectors; goto out; @@ -4035,3 +4043,4 @@ EXPORT_SYMBOL(md_check_ordering); EXPORT_SYMBOL(get_spare); +MODULE_LICENSE("GPL"); diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/md/raid1.c linux-2.5/drivers/md/raid1.c --- linux-2.5.1/drivers/md/raid1.c Tue Dec 11 21:47:35 2001 +++ linux-2.5/drivers/md/raid1.c Thu Dec 20 19:14:29 2001 @@ -28,7 +28,6 @@ #define MD_DRIVER #define MD_PERSONALITY -#define MAX_WORK_PER_DISK 128 /* * Number of guaranteed r1bios in case of extreme VM load: */ @@ -38,24 +37,6 @@ static spinlock_t retry_list_lock = SPIN_LOCK_UNLOCKED; static LIST_HEAD(retry_list_head); -static inline void check_all_w_bios_empty(r1bio_t *r1_bio) -{ - int i; - - return; - for (i = 0; i < MD_SB_DISKS; i++) - if (r1_bio->write_bios[i]) - BUG(); -} - -static inline void check_all_bios_empty(r1bio_t *r1_bio) -{ - return; - if (r1_bio->read_bio) - BUG(); - check_all_w_bios_empty(r1_bio); -} - static void * r1bio_pool_alloc(int gfp_flags, void *data) { r1bio_t *r1_bio; @@ -69,11 +50,11 @@ static void r1bio_pool_free(void *r1_bio, void *data) { - check_all_bios_empty(r1_bio); kfree(r1_bio); } #define RESYNC_BLOCK_SIZE (64*1024) +#define RESYNC_SECTORS (RESYNC_BLOCK_SIZE >> 9) #define RESYNC_PAGES ((RESYNC_BLOCK_SIZE + PAGE_SIZE-1) / PAGE_SIZE) #define RESYNC_WINDOW (2048*1024) @@ -86,7 +67,6 @@ int i, j; r1_bio = mempool_alloc(conf->r1bio_pool, gfp_flags); - check_all_bios_empty(r1_bio); bio = bio_alloc(gfp_flags, RESYNC_PAGES); if (!bio) @@ -131,7 +111,6 @@ r1bio_t *r1bio = __r1_bio; struct bio *bio = r1bio->master_bio; - check_all_bios_empty(r1bio); if (atomic_read(&bio->bi_cnt) != 1) BUG(); for (i = 0; i < RESYNC_PAGES; i++) { @@ -163,13 +142,25 @@ } *bio = NULL; } - check_all_bios_empty(r1_bio); } static inline void free_r1bio(r1bio_t *r1_bio) { + unsigned long flags; + conf_t *conf = mddev_to_conf(r1_bio->mddev); + /* + * Wake up any possible resync thread that waits for the device + * to go idle. + */ + spin_lock_irqsave(&conf->resync_lock, flags); + if (!--conf->nr_pending) { + wake_up(&conf->wait_idle); + wake_up(&conf->wait_resume); + } + spin_unlock_irqrestore(&conf->resync_lock, flags); + put_all_bios(conf, r1_bio); mempool_free(r1_bio, conf->r1bio_pool); } @@ -178,7 +169,14 @@ { conf_t *conf = mddev_to_conf(r1_bio->mddev); struct bio *bio = r1_bio->master_bio; + unsigned long flags; + spin_lock_irqsave(&conf->resync_lock, flags); + if (!--conf->nr_pending) { + wake_up(&conf->wait_idle); + wake_up(&conf->wait_resume); + } + spin_unlock_irqrestore(&conf->resync_lock, flags); /* * undo any possible partial request fixup magic: */ @@ -222,37 +220,6 @@ md_wakeup_thread(conf->thread); } - -static void inline raid_request_done(unsigned long sector, conf_t *conf, int phase) -{ - unsigned long flags; - spin_lock_irqsave(&conf->segment_lock, flags); - if (sector < conf->start_active) - conf->cnt_done--; - else if (sector >= conf->start_future && conf->phase == phase) - conf->cnt_future--; - else if (!--conf->cnt_pending) - wake_up(&conf->wait_ready); - - spin_unlock_irqrestore(&conf->segment_lock, flags); -} - -static void inline sync_request_done(sector_t sector, conf_t *conf) -{ - unsigned long flags; - - spin_lock_irqsave(&conf->segment_lock, flags); - if (sector >= conf->start_ready) - --conf->cnt_ready; - else if (sector >= conf->start_active) { - if (!--conf->cnt_active) { - conf->start_active = conf->start_ready; - wake_up(&conf->wait_done); - } - } - spin_unlock_irqrestore(&conf->segment_lock, flags); -} - /* * raid_end_bio_io() is called when we have finished servicing a mirrored * operation and are ready to return a success/failure code to the buffer @@ -262,19 +229,29 @@ { struct bio *bio = r1_bio->master_bio; - raid_request_done(bio->bi_sector, mddev_to_conf(r1_bio->mddev), - test_bit(R1BIO_SyncPhase, &r1_bio->state)); - bio_endio(bio, uptodate, nr_sectors); free_r1bio(r1_bio); return 0; } +/* + * Update disk head position estimator based on IRQ completion info. + */ +static void inline update_head_pos(int disk, r1bio_t *r1_bio) +{ + conf_t *conf = mddev_to_conf(r1_bio->mddev); + + conf->mirrors[disk].head_position = + r1_bio->sector + (r1_bio->master_bio->bi_size >> 9); + atomic_dec(&conf->mirrors[disk].nr_pending); +} + static int end_request(struct bio *bio, int nr_sectors) { int uptodate = test_bit(BIO_UPTODATE, &bio->bi_flags); r1bio_t * r1_bio = (r1bio_t *)(bio->bi_private); + int i; /* * this branch is our 'one mirror IO has finished' event handler: @@ -287,20 +264,16 @@ * we will return a good error code for to the higher * levels even if IO on some other mirrored buffer fails. * - * The 'master' represents the complex operation to + * The 'master' represents the composite IO operation to * user-side. So if something waits for IO, then it will * wait for the 'master' bio. */ set_bit(R1BIO_Uptodate, &r1_bio->state); - /* - * We split up the read and write side, imho they are - * conceptually different. - */ - if ((r1_bio->cmd == READ) || (r1_bio->cmd == READA)) { if (!r1_bio->read_bio) BUG(); + update_head_pos(r1_bio->read_disk, r1_bio); /* * we have only one bio on the read side */ @@ -322,6 +295,14 @@ /* * WRITE: * + * First, find the disk this bio belongs to. + */ + for (i = 0; i < MD_SB_DISKS; i++) + if (r1_bio->write_bios[i] == bio) { + update_head_pos(i, r1_bio); + break; + } + /* * Let's see if all mirrored write operations have finished * already. */ @@ -332,44 +313,49 @@ /* * This routine returns the disk from which the requested read should - * be done. It bookkeeps the last read position for every disk - * in array and when new read requests come, the disk which last - * position is nearest to the request, is chosen. + * be done. There is a per-array 'next expected sequential IO' sector + * number - if this matches on the next IO then we use the last disk. + * There is also a per-disk 'last know head position' sector that is + * maintained from IRQ contexts, both the normal and the resync IO + * completion handlers update this position correctly. If there is no + * perfect sequential match then we pick the disk whose head is closest. * - * TODO: now if there are 2 mirrors in the same 2 devices, performance - * degrades dramatically because position is mirror, not device based. - * This should be changed to be device based. Also atomic sequential - * reads should be somehow balanced. + * If there are 2 mirrors in the same 2 devices, performance degrades + * because position is mirror, not device based. */ - static int read_balance(conf_t *conf, struct bio *bio, r1bio_t *r1_bio) { - const int sectors = bio->bi_size >> 9; const unsigned long this_sector = r1_bio->sector; - unsigned long new_distance, current_distance; int new_disk = conf->last_used, disk = new_disk; + const int sectors = bio->bi_size >> 9; + sector_t new_distance, current_distance; /* - * Check if it is sane at all to balance - */ - - if (conf->resync_mirrors) + * Check if it if we can balance. We can balance on the whole + * device if no resync is going on, or below the resync window. + * We take the first readable disk when above the resync window. + */ + if (conf->resync_mirrors && (this_sector + sectors >= conf->next_resync)) { + /* make sure that disk is operational */ + new_disk = 0; + while (!conf->mirrors[new_disk].operational || conf->mirrors[new_disk].write_only) { + new_disk++; + if (new_disk == conf->raid_disks) { + new_disk = 0; + break; + } + } goto rb_out; + } - /* make sure that disk is operational */ - while( !conf->mirrors[new_disk].operational) { - if (new_disk <= 0) new_disk = conf->raid_disks; + /* make sure the disk is operational */ + while (!conf->mirrors[new_disk].operational) { + if (new_disk <= 0) + new_disk = conf->raid_disks; new_disk--; if (new_disk == disk) { - /* - * This means no working disk was found - * Nothing much to do, lets not change anything - * and hope for the best... - */ - new_disk = conf->last_used; - goto rb_out; } } @@ -377,36 +363,16 @@ /* now disk == new_disk == starting point for search */ /* - * Don't touch anything for sequential reads. + * Don't change to another disk for sequential reads: */ - if (this_sector == conf->mirrors[new_disk].head_position) + if (conf->next_seq_sect == this_sector) goto rb_out; - - /* - * If reads have been done only on a single disk - * for a time, lets give another disk a change. - * This is for kicking those idling disks so that - * they would find work near some hotspot. - */ - if (conf->sect_count >= conf->mirrors[new_disk].sect_limit) { - conf->sect_count = 0; - - do { - if (new_disk <= 0) - new_disk = conf->raid_disks; - new_disk--; - if (new_disk == disk) - break; - } while ((conf->mirrors[new_disk].write_only) || - (!conf->mirrors[new_disk].operational)); - + if (this_sector == conf->mirrors[new_disk].head_position) goto rb_out; - } - current_distance = abs(this_sector - - conf->mirrors[disk].head_position); + current_distance = abs(this_sector - conf->mirrors[disk].head_position); - /* Find the disk which is closest */ + /* Find the disk whose head is closest */ do { if (disk <= 0) @@ -417,44 +383,56 @@ (!conf->mirrors[disk].operational)) continue; - new_distance = abs(this_sector - - conf->mirrors[disk].head_position); - + if (!atomic_read(&conf->mirrors[disk].nr_pending)) { + new_disk = disk; + break; + } + new_distance = abs(this_sector - conf->mirrors[disk].head_position); if (new_distance < current_distance) { - conf->sect_count = 0; current_distance = new_distance; new_disk = disk; } } while (disk != conf->last_used); rb_out: - conf->mirrors[new_disk].head_position = this_sector + sectors; + r1_bio->read_disk = new_disk; + conf->next_seq_sect = this_sector + sectors; conf->last_used = new_disk; - conf->sect_count += sectors; return new_disk; } /* - * Wait if the reconstruction state machine puts up a bar for - * new requests in this sector range: + * Throttle resync depth, so that we can both get proper overlapping of + * requests, but are still able to handle normal requests quickly. */ -static inline void new_request(conf_t *conf, r1bio_t *r1_bio) +#define RESYNC_DEPTH 32 + +static void device_barrier(conf_t *conf, sector_t sect) { - spin_lock_irq(&conf->segment_lock); - wait_event_lock_irq(conf->wait_done, - r1_bio->sector < conf->start_active || - r1_bio->sector >= conf->start_future, - conf->segment_lock); - if (r1_bio->sector < conf->start_active) - conf->cnt_done++; - else { - conf->cnt_future++; - if (conf->phase) - set_bit(R1BIO_SyncPhase, &r1_bio->state); + spin_lock_irq(&conf->resync_lock); + wait_event_lock_irq(conf->wait_idle, !waitqueue_active(&conf->wait_resume), conf->resync_lock); + + if (!conf->barrier++) { + wait_event_lock_irq(conf->wait_idle, !conf->nr_pending, conf->resync_lock); + if (conf->nr_pending) + BUG(); } - spin_unlock_irq(&conf->segment_lock); + wait_event_lock_irq(conf->wait_resume, conf->barrier < RESYNC_DEPTH, conf->resync_lock); + conf->next_resync = sect; + spin_unlock_irq(&conf->resync_lock); +} + +static void resume_device(conf_t *conf) +{ + spin_lock_irq(&conf->resync_lock); + if (!conf->barrier) + BUG(); + --conf->barrier; + wake_up(&conf->wait_resume); + wake_up(&conf->wait_idle); + spin_unlock_irq(&conf->resync_lock); } static int make_request(mddev_t *mddev, int rw, struct bio * bio) @@ -466,6 +444,16 @@ int i, sum_bios = 0, disks = MD_SB_DISKS; /* + * Register the new request and wait if the reconstruction + * thread has put up a bar for new requests. + * Continue immediately if no resync is active currently. + */ + spin_lock_irq(&conf->resync_lock); + wait_event_lock_irq(conf->wait_resume, !conf->barrier, conf->resync_lock); + conf->nr_pending++; + spin_unlock_irq(&conf->resync_lock); + + /* * make_request() can abort the operation when READA is being * used and no empty request is available. * @@ -475,7 +463,6 @@ rw = READ; r1_bio = mempool_alloc(conf->r1bio_pool, GFP_NOIO); - check_all_bios_empty(r1_bio); r1_bio->master_bio = bio; @@ -483,8 +470,6 @@ r1_bio->sector = bio->bi_sector; r1_bio->cmd = rw; - new_request(conf, r1_bio); - if (rw == READ) { /* * read balancing logic: @@ -503,15 +488,13 @@ read_bio->bi_private = r1_bio; generic_make_request(read_bio); + atomic_inc(&conf->mirrors[r1_bio->read_disk].nr_pending); return 0; } /* * WRITE: */ - - check_all_w_bios_empty(r1_bio); - for (i = 0; i < disks; i++) { struct bio *mbio; if (!conf->mirrors[i].operational) @@ -542,14 +525,13 @@ /* * We have to be a bit careful about the semaphore above, thats - * why we start the requests separately. Since kmalloc() could - * fail, sleep and make_request() can sleep too, this is the - * safer solution. Imagine, end_request decreasing the semaphore - * before we could have set it up ... We could play tricks with - * the semaphore (presetting it and correcting at the end if - * sum_bios is not 'n' but we have to do end_request by hand if - * all requests finish until we had a chance to set up the - * semaphore correctly ... lots of races). + * why we start the requests separately. Since generic_make_request() + * can sleep, this is the safer solution. Imagine, end_request + * decreasing the semaphore before we could have set it up ... + * We could play tricks with the semaphore (presetting it and + * correcting at the end if sum_bios is not 'n' but we have to + * do end_request by hand if all requests finish until we had a + * chance to set up the semaphore correctly ... lots of races). */ for (i = 0; i < disks; i++) { struct bio *mbio; @@ -558,6 +540,7 @@ continue; generic_make_request(mbio); + atomic_inc(&conf->mirrors[i].nr_pending); } return 0; } @@ -610,8 +593,7 @@ md_wakeup_thread(conf->thread); if (!mirror->write_only) conf->working_disks--; - printk(DISK_FAILED, partition_name(mirror->dev), - conf->working_disks); + printk(DISK_FAILED, partition_name(mirror->dev), conf->working_disks); } static int error(mddev_t *mddev, kdev_t dev) @@ -644,12 +626,6 @@ return 0; } -#undef LAST_DISK -#undef NO_SPARE_DISK -#undef DISK_FAILED -#undef START_SYNCING - - static void print_conf(conf_t *conf) { int i; @@ -674,29 +650,13 @@ static void close_sync(conf_t *conf) { - mddev_t *mddev = conf->mddev; - /* - * If reconstruction was interrupted, we need to close the "active" - * and "pending" holes. - * we know that there are no active rebuild requests, - * os cnt_active == cnt_ready == 0 - */ - spin_lock_irq(&conf->segment_lock); - conf->start_active = conf->start_pending; - conf->start_ready = conf->start_pending; - wait_event_lock_irq(conf->wait_ready, !conf->cnt_pending, conf->segment_lock); - conf->start_active = conf->start_ready = conf->start_pending = conf->start_future; - conf->start_future = mddev->sb->size+1; - conf->cnt_pending = conf->cnt_future; - conf->cnt_future = 0; - conf->phase = conf->phase ^1; - wait_event_lock_irq(conf->wait_ready, !conf->cnt_pending, conf->segment_lock); - conf->start_active = conf->start_ready = conf->start_pending = conf->start_future = 0; - conf->phase = 0; - conf->cnt_future = conf->cnt_done;; - conf->cnt_done = 0; - spin_unlock_irq(&conf->segment_lock); - wake_up(&conf->wait_done); + spin_lock_irq(&conf->resync_lock); + wait_event_lock_irq(conf->wait_resume, !conf->barrier, conf->resync_lock); + spin_unlock_irq(&conf->resync_lock); + + if (conf->barrier) BUG(); + if (waitqueue_active(&conf->wait_idle)) BUG(); + if (waitqueue_active(&conf->wait_resume)) BUG(); } static int diskop(mddev_t *mddev, mdp_disk_t **d, int state) @@ -975,9 +935,9 @@ int uptodate = test_bit(BIO_UPTODATE, &bio->bi_flags); r1bio_t * r1_bio = (r1bio_t *)(bio->bi_private); - check_all_w_bios_empty(r1_bio); if (r1_bio->read_bio != bio) BUG(); + update_head_pos(r1_bio->read_disk, r1_bio); /* * we have read a block, now it needs to be re-written, * or re-read if the read failed. @@ -997,13 +957,21 @@ int uptodate = test_bit(BIO_UPTODATE, &bio->bi_flags); r1bio_t * r1_bio = (r1bio_t *)(bio->bi_private); mddev_t *mddev = r1_bio->mddev; + int i; if (!uptodate) md_error(mddev, bio->bi_dev); + for (i = 0; i < MD_SB_DISKS; i++) + if (r1_bio->write_bios[i] == bio) { + update_head_pos(i, r1_bio); + break; + } + if (atomic_dec_and_test(&r1_bio->remaining)) { - sync_request_done(r1_bio->sector, mddev_to_conf(mddev)); + conf_t *conf = mddev_to_conf(mddev); md_done_sync(mddev, r1_bio->master_bio->bi_size >> 9, uptodate); + resume_device(conf); put_buf(r1_bio); } return 0; @@ -1029,11 +997,11 @@ */ printk(IO_ERROR, partition_name(bio->bi_dev), r1_bio->sector); md_done_sync(mddev, r1_bio->master_bio->bi_size >> 9, 0); + resume_device(conf); + put_buf(r1_bio); return; } - check_all_w_bios_empty(r1_bio); - for (i = 0; i < disks ; i++) { if (!conf->mirrors[i].operational) continue; @@ -1071,8 +1039,8 @@ * must be done */ printk(IO_ERROR, partition_name(bio->bi_dev), r1_bio->sector); - sync_request_done(r1_bio->sector, conf); md_done_sync(mddev, r1_bio->master_bio->bi_size >> 9, 0); + resume_device(conf); put_buf(r1_bio); return; } @@ -1083,6 +1051,7 @@ md_sync_acct(mbio->bi_dev, mbio->bi_size >> 9); generic_make_request(mbio); + atomic_inc(&conf->mirrors[i].nr_pending); } } @@ -1101,6 +1070,7 @@ struct bio *bio; unsigned long flags; mddev_t *mddev; + conf_t *conf; kdev_t dev; @@ -1111,9 +1081,9 @@ r1_bio = list_entry(head->prev, r1bio_t, retry_list); list_del(head->prev); spin_unlock_irqrestore(&retry_list_lock, flags); - check_all_w_bios_empty(r1_bio); mddev = r1_bio->mddev; + conf = mddev_to_conf(mddev); if (mddev->sb_dirty) { printk(KERN_INFO "raid1: dirty sb detected, updating.\n"); mddev->sb_dirty = 0; @@ -1139,13 +1109,12 @@ bio->bi_rw = r1_bio->cmd; generic_make_request(bio); + atomic_inc(&conf->mirrors[r1_bio->read_disk].nr_pending); break; } } spin_unlock_irqrestore(&retry_list_lock, flags); } -#undef IO_ERROR -#undef REDIRECT_SECTOR /* * Private kernel thread to reconstruct mirrors after an unclean @@ -1177,101 +1146,27 @@ { int buffs; - conf->start_active = 0; - conf->start_ready = 0; - conf->start_pending = 0; - conf->start_future = 0; - conf->phase = 0; - buffs = RESYNC_WINDOW / RESYNC_BLOCK_SIZE; if (conf->r1buf_pool) BUG(); conf->r1buf_pool = mempool_create(buffs, r1buf_pool_alloc, r1buf_pool_free, conf); if (!conf->r1buf_pool) return -ENOMEM; - conf->window = 2048; - conf->cnt_future += conf->cnt_done+conf->cnt_pending; - conf->cnt_done = conf->cnt_pending = 0; - if (conf->cnt_ready || conf->cnt_active) - MD_BUG(); + conf->next_resync = 0; return 0; } -static void wait_sync_pending(conf_t *conf, sector_t sector_nr) -{ - spin_lock_irq(&conf->segment_lock); - while (sector_nr >= conf->start_pending) { -// printk("wait .. sect=%lu start_active=%d ready=%d pending=%d future=%d, cnt_done=%d active=%d ready=%d pending=%d future=%d\n", sector_nr, conf->start_active, conf->start_ready, conf->start_pending, conf->start_future, conf->cnt_done, conf->cnt_active, conf->cnt_ready, conf->cnt_pending, conf->cnt_future); - wait_event_lock_irq(conf->wait_done, !conf->cnt_active, - conf->segment_lock); - wait_event_lock_irq(conf->wait_ready, !conf->cnt_pending, - conf->segment_lock); - conf->start_active = conf->start_ready; - conf->start_ready = conf->start_pending; - conf->start_pending = conf->start_future; - conf->start_future = conf->start_future+conf->window; - - // Note: falling off the end is not a problem - conf->phase = conf->phase ^1; - conf->cnt_active = conf->cnt_ready; - conf->cnt_ready = 0; - conf->cnt_pending = conf->cnt_future; - conf->cnt_future = 0; - wake_up(&conf->wait_done); - } - conf->cnt_ready++; - spin_unlock_irq(&conf->segment_lock); -} - /* * perform a "sync" on one "block" * * We need to make sure that no normal I/O request - particularly write * requests - conflict with active sync requests. - * This is achieved by conceptually dividing the block space into a - * number of sections: - * DONE: 0 .. a-1 These blocks are in-sync - * ACTIVE: a.. b-1 These blocks may have active sync requests, but - * no normal IO requests - * READY: b .. c-1 These blocks have no normal IO requests - sync - * request may be happening - * PENDING: c .. d-1 These blocks may have IO requests, but no new - * ones will be added - * FUTURE: d .. end These blocks are not to be considered yet. IO may - * be happening, but not sync - * - * We keep a - * phase which flips (0 or 1) each time d moves and - * a count of: - * z = active io requests in FUTURE since d moved - marked with - * current phase - * y = active io requests in FUTURE before d moved, or PENDING - - * marked with previous phase - * x = active sync requests in READY - * w = active sync requests in ACTIVE - * v = active io requests in DONE * - * Normally, a=b=c=d=0 and z= active io requests - * or a=b=c=d=END and v= active io requests - * Allowed changes to a,b,c,d: - * A: c==d && y==0 -> d+=window, y=z, z=0, phase=!phase - * B: y==0 -> c=d - * C: b=c, w+=x, x=0 - * D: w==0 -> a=b - * E: a==b==c==d==end -> a=b=c=d=0, z=v, v=0 - * - * At start of sync we apply A. - * When y reaches 0, we apply B then A then being sync requests - * When sync point reaches c-1, we wait for y==0, and W==0, and - * then apply apply B then A then D then C. - * Finally, we apply E - * - * The sync request simply issues a "read" against a working drive - * This is marked so that on completion the raid1d thread is woken to - * issue suitable write requests + * This is achieved by tracking pending requests and a 'barrier' concept + * that can be installed to exclude normal IO requests. */ -static int sync_request(mddev_t *mddev, sector_t sector_nr) +static int sync_request(mddev_t *mddev, sector_t sector_nr, int go_faster) { conf_t *conf = mddev_to_conf(mddev); mirror_info_t *mirror; @@ -1283,8 +1178,13 @@ if (!sector_nr) if (init_resync(conf)) return -ENOMEM; - - wait_sync_pending(conf, sector_nr); + /* + * If there is non-resync activity waiting for us then + * put in a delay to throttle resync. + */ + if (!go_faster && waitqueue_active(&conf->wait_resume)) + schedule_timeout(HZ); + device_barrier(conf, sector_nr + RESYNC_SECTORS); /* * If reconstructing, and >1 working disc, @@ -1302,10 +1202,13 @@ } conf->last_used = disk; - mirror = conf->mirrors+conf->last_used; + mirror = conf->mirrors + conf->last_used; r1_bio = mempool_alloc(conf->r1buf_pool, GFP_NOIO); - check_all_bios_empty(r1_bio); + + spin_lock_irq(&conf->resync_lock); + conf->nr_pending++; + spin_unlock_irq(&conf->resync_lock); r1_bio->mddev = mddev; r1_bio->sector = sector_nr; @@ -1344,6 +1247,7 @@ md_sync_acct(read_bio->bi_dev, nr_sectors); generic_make_request(read_bio); + atomic_inc(&conf->mirrors[conf->last_used].nr_pending); return nr_sectors; } @@ -1447,7 +1351,6 @@ disk->number = descriptor->number; disk->raid_disk = disk_idx; disk->dev = rdev->dev; - disk->sect_limit = MAX_WORK_PER_DISK; disk->operational = 0; disk->write_only = 0; disk->spare = 0; @@ -1479,7 +1382,6 @@ disk->number = descriptor->number; disk->raid_disk = disk_idx; disk->dev = rdev->dev; - disk->sect_limit = MAX_WORK_PER_DISK; disk->operational = 1; disk->write_only = 0; disk->spare = 0; @@ -1494,7 +1396,6 @@ disk->number = descriptor->number; disk->raid_disk = disk_idx; disk->dev = rdev->dev; - disk->sect_limit = MAX_WORK_PER_DISK; disk->operational = 0; disk->write_only = 0; disk->spare = 1; @@ -1507,9 +1408,9 @@ conf->mddev = mddev; conf->device_lock = SPIN_LOCK_UNLOCKED; - conf->segment_lock = SPIN_LOCK_UNLOCKED; - init_waitqueue_head(&conf->wait_done); - init_waitqueue_head(&conf->wait_ready); + conf->resync_lock = SPIN_LOCK_UNLOCKED; + init_waitqueue_head(&conf->wait_idle); + init_waitqueue_head(&conf->wait_resume); if (!conf->working_disks) { printk(NONE_OPERATIONAL, mdidx(mddev)); @@ -1610,17 +1511,6 @@ MOD_DEC_USE_COUNT; return -EIO; } - -#undef INVALID_LEVEL -#undef NO_SB -#undef ERRORS -#undef NOT_IN_SYNC -#undef INCONSISTENT -#undef ALREADY_RUNNING -#undef OPERATIONAL -#undef SPARE -#undef NONE_OPERATIONAL -#undef ARRAY_IS_ACTIVE static int stop_resync(mddev_t *mddev) { diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/md/raid5.c linux-2.5/drivers/md/raid5.c --- linux-2.5.1/drivers/md/raid5.c Wed Oct 17 21:21:00 2001 +++ linux-2.5/drivers/md/raid5.c Thu Dec 27 22:10:28 2001 @@ -1226,23 +1226,6 @@ return 0; } -/* - * Determine correct block size for this device. - */ -unsigned int device_bsize (kdev_t dev) -{ - unsigned int i, correct_size; - - correct_size = BLOCK_SIZE; - if (blksize_size[MAJOR(dev)]) { - i = blksize_size[MAJOR(dev)][MINOR(dev)]; - if (i) - correct_size = i; - } - - return correct_size; -} - static int raid5_sync_request (mddev_t *mddev, unsigned long sector_nr) { raid5_conf_t *conf = (raid5_conf_t *) mddev->private; diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/media/radio/radio-gemtek-pci.c linux-2.5/drivers/media/radio/radio-gemtek-pci.c --- linux-2.5.1/drivers/media/radio/radio-gemtek-pci.c Sun Sep 30 19:26:06 2001 +++ linux-2.5/drivers/media/radio/radio-gemtek-pci.c Thu Dec 13 16:32:36 2001 @@ -424,7 +424,7 @@ name: "gemtek_pci", id_table: gemtek_pci_id, probe: gemtek_pci_probe, - remove: gemtek_pci_remove + remove: __devexit_p(gemtek_pci_remove), }; static int __init gemtek_pci_init_module( void ) diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/media/radio/radio-maxiradio.c linux-2.5/drivers/media/radio/radio-maxiradio.c --- linux-2.5.1/drivers/media/radio/radio-maxiradio.c Sun Sep 30 19:26:06 2001 +++ linux-2.5/drivers/media/radio/radio-maxiradio.c Thu Dec 13 16:32:36 2001 @@ -376,7 +376,7 @@ name: "radio-maxiradio", id_table: maxiradio_pci_tbl, probe: maxiradio_init_one, - remove: maxiradio_remove_one, + remove: __devexit_p(maxiradio_remove_one), }; int __init maxiradio_radio_init(void) diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/media/video/Config.in linux-2.5/drivers/media/video/Config.in --- linux-2.5.1/drivers/media/video/Config.in Fri Nov 9 22:01:22 2001 +++ linux-2.5/drivers/media/video/Config.in Thu Dec 13 16:32:36 2001 @@ -22,10 +22,8 @@ fi fi if [ "$CONFIG_PARPORT" != "n" ]; then - if [ "$CONFIG_EXPERIMENTAL" = "y" ]; then - if [ "$CONFIG_PARPORT_1284" != "n" ]; then - dep_tristate ' Winbond W9966CF Webcam Video For Linux (EXPERIMENTAL)' CONFIG_VIDEO_W9966 $CONFIG_VIDEO_DEV $CONFIG_PARPORT - fi + if [ "$CONFIG_PARPORT_1284" != "n" ]; then + dep_tristate ' W9966CF Webcam (FlyCam Supra and others) Video For Linux' CONFIG_VIDEO_W9966 $CONFIG_VIDEO_DEV $CONFIG_PARPORT fi fi dep_tristate ' CPiA Video For Linux' CONFIG_VIDEO_CPIA $CONFIG_VIDEO_DEV diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/media/video/adv7175.c linux-2.5/drivers/media/video/adv7175.c --- linux-2.5.1/drivers/media/video/adv7175.c Sun Sep 30 19:26:06 2001 +++ linux-2.5/drivers/media/video/adv7175.c Sun Dec 30 21:17:30 2001 @@ -38,7 +38,6 @@ #include <asm/pgtable.h> #include <asm/page.h> #include <linux/sched.h> -#include <asm/segment.h> #include <linux/types.h> #include <linux/wrapper.h> diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/media/video/bt856.c linux-2.5/drivers/media/video/bt856.c --- linux-2.5.1/drivers/media/video/bt856.c Sun Sep 30 19:26:06 2001 +++ linux-2.5/drivers/media/video/bt856.c Sun Dec 30 21:17:30 2001 @@ -40,7 +40,6 @@ #include <asm/pgtable.h> #include <asm/page.h> #include <linux/sched.h> -#include <asm/segment.h> #include <linux/types.h> #include <linux/wrapper.h> diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/media/video/bttv-driver.c linux-2.5/drivers/media/video/bttv-driver.c --- linux-2.5.1/drivers/media/video/bttv-driver.c Wed Oct 17 21:19:20 2001 +++ linux-2.5/drivers/media/video/bttv-driver.c Sun Dec 30 21:17:30 2001 @@ -37,7 +37,6 @@ #include <asm/pgtable.h> #include <asm/page.h> #include <linux/sched.h> -#include <asm/segment.h> #include <linux/types.h> #include <linux/wrapper.h> #include <linux/interrupt.h> @@ -2820,7 +2819,7 @@ * Scan for a Bt848 card, request the irq and map the io memory */ -static void __devexit bttv_remove(struct pci_dev *pci_dev) +static void bttv_remove(struct pci_dev *pci_dev) { u8 command; int j; diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/media/video/meye.c linux-2.5/drivers/media/video/meye.c --- linux-2.5.1/drivers/media/video/meye.c Thu Oct 25 20:53:47 2001 +++ linux-2.5/drivers/media/video/meye.c Thu Dec 13 16:32:36 2001 @@ -1460,7 +1460,7 @@ name: "meye", id_table: meye_pci_tbl, probe: meye_probe, - remove: meye_remove, + remove: __devexit_p(meye_remove), }; static int __init meye_init_module(void) { diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/media/video/saa7185.c linux-2.5/drivers/media/video/saa7185.c --- linux-2.5.1/drivers/media/video/saa7185.c Sun Sep 30 19:26:06 2001 +++ linux-2.5/drivers/media/video/saa7185.c Sun Dec 30 21:17:30 2001 @@ -36,7 +36,6 @@ #include <asm/pgtable.h> #include <asm/page.h> #include <linux/sched.h> -#include <asm/segment.h> #include <linux/types.h> #include <linux/wrapper.h> diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/media/video/stradis.c linux-2.5/drivers/media/video/stradis.c --- linux-2.5.1/drivers/media/video/stradis.c Thu Dec 6 22:07:57 2001 +++ linux-2.5/drivers/media/video/stradis.c Sun Dec 30 21:17:30 2001 @@ -37,7 +37,6 @@ #include <asm/pgtable.h> #include <asm/page.h> #include <linux/sched.h> -#include <asm/segment.h> #include <asm/types.h> #include <linux/types.h> #include <linux/wrapper.h> diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/media/video/w9966.c linux-2.5/drivers/media/video/w9966.c --- linux-2.5.1/drivers/media/video/w9966.c Sun Sep 30 19:26:06 2001 +++ linux-2.5/drivers/media/video/w9966.c Thu Dec 13 16:32:36 2001 @@ -1,9 +1,7 @@ /* Winbond w9966cf Webcam parport driver. - Version 0.32 - - Copyright (C) 2001 Jakob Kemi <jakob.kemi@post.utfors.se> + Copyright (C) 2001 Jakob Kemi <jakob.kemi@telia.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 @@ -21,33 +19,16 @@ */ /* Supported devices: - *Lifeview FlyCam Supra (using the Philips saa7111a chip) - - Does any other model using the w9966 interface chip exist ? + * Lifeview FlyCam Supra (using the Philips saa7111a chip) Todo: - - *Add a working EPP mode, since DMA ECP read isn't implemented - in the parport drivers. (That's why it's so sloow) - - *Add support for other ccd-control chips than the saa7111 - please send me feedback on what kind of chips you have. - - *Add proper probing. I don't know what's wrong with the IEEE1284 - parport drivers but (IEEE1284_MODE_NIBBLE|IEEE1284_DEVICE_ID) - and nibble read seems to be broken for some peripherals. - - *Add probing for onboard SRAM, port directions etc. (if possible) - - *Add support for the hardware compressed modes (maybe using v4l2) - - *Fix better support for the capture window (no skewed images, v4l - interface to capt. window) - - *Probably some bugs that I don't know of + * Add a working EPP mode + * Support other ccd-control chips than the saa7111 + (what combinations exists?) + * Add proper probing. IEEE1284 probing of w9966 chips haven't + worked since parport drivers changed in 2.4.x. + * Probe for onboard SRAM, port directions etc. (if possible) - Please support me by sending feedback! - Changes: Alan Cox: Removed RGB mode for kernel merge, added THIS_MODULE @@ -59,6 +40,8 @@ #include <linux/delay.h> #include <linux/videodev.h> #include <linux/parport.h> +#include <linux/types.h> +#include <linux/slab.h> //#define DEBUG // Undef me for production @@ -99,43 +82,44 @@ #define W9966_I2C_W_CLOCK 0x01 struct w9966_dev { - unsigned char dev_state; - unsigned char i2c_state; - unsigned short ppmode; + u8 dev_state; + u8 i2c_state; + int ppmode; struct parport* pport; struct pardevice* pdev; struct video_device vdev; - unsigned short width; - unsigned short height; - unsigned char brightness; - signed char contrast; - signed char color; - signed char hue; + u16 width; + u16 height; + u8 brightness; + s8 contrast; + s8 color; + s8 hue; + u8* buffer; }; /* * Module specific properties */ -MODULE_AUTHOR("Jakob Kemi <jakob.kemi@post.utfors.se>"); -MODULE_DESCRIPTION("Winbond w9966cf WebCam driver (0.32)"); +MODULE_AUTHOR("Jakob Kemi <jakob.kemi@telia.com>"); +MODULE_DESCRIPTION("Winbond w9966cf WebCam driver (FlyCam Supra and others)"); MODULE_LICENSE("GPL"); -#ifdef MODULE -static const char* pardev[] = {[0 ... W9966_MAXCAMS] = ""}; -#else -static const char* pardev[] = {[0 ... W9966_MAXCAMS] = "aggressive"}; -#endif -MODULE_PARM(pardev, "1-" __MODULE_STRING(W9966_MAXCAMS) "s"); -MODULE_PARM_DESC(pardev, "pardev: where to search for\n\ -\teach camera. 'aggressive' means brute-force search.\n\ -\tEg: >pardev=parport3,aggressive,parport2,parport1< would assign -\tcam 1 to parport3 and search every parport for cam 2 etc..."); +static const char* pardev[] = {[0 ... W9966_MAXCAMS] = "auto"}; +MODULE_PARM(pardev, "0-" __MODULE_STRING(W9966_MAXCAMS) "s"); +MODULE_PARM_DESC(pardev,"\n\ +<auto|name|none[,...]> Where to find cameras.\n\ + auto = probe all parports for camera\n\ + name = name of parport (eg parport0)\n\ + none = don't search for this camera\n\ +You can specify all cameras this way, for example: + pardev=parport2,auto,none,parport0 would search for cam1 on parport2, search\n\ + for cam2 on all parports, skip cam3 and search for cam4 on parport0"); static int parmode = 0; MODULE_PARM(parmode, "i"); -MODULE_PARM_DESC(parmode, "parmode: transfer mode (0=auto, 1=ecp, 2=epp"); +MODULE_PARM_DESC(parmode, "\n<0|1|2> transfer mode (0=auto, 1=ecp, 2=epp)"); static int video_nr = -1; MODULE_PARM(video_nr, "i"); @@ -277,17 +261,23 @@ case 0: if (port->modes & PARPORT_MODE_ECP) cam->ppmode = IEEE1284_MODE_ECP; - else if (port->modes & PARPORT_MODE_EPP) - cam->ppmode = IEEE1284_MODE_EPP; +/* else if (port->modes & PARPORT_MODE_EPP) + cam->ppmode = IEEE1284_MODE_EPP;*/ else - cam->ppmode = IEEE1284_MODE_ECP; + cam->ppmode = IEEE1284_MODE_ECPSWE; break; case 1: // hw- or sw-ecp - cam->ppmode = IEEE1284_MODE_ECP; + if (port->modes & PARPORT_MODE_ECP) + cam->ppmode = IEEE1284_MODE_ECP; + else + cam->ppmode = IEEE1284_MODE_ECPSWE; break; case 2: // hw- or sw-epp - cam->ppmode = IEEE1284_MODE_EPP; - break; + if (port->modes & PARPORT_MODE_EPP) + cam->ppmode = IEEE1284_MODE_EPP; + else + cam->ppmode = IEEE1284_MODE_EPPSWE; + break; } // Tell the parport driver that we exists @@ -325,6 +315,8 @@ w9966_setState(cam, W9966_STATE_VDEV, W9966_STATE_VDEV); + cam->buffer = NULL; + // All ok printk( "w9966cf: Found and initialized a webcam on %s.\n", @@ -337,6 +329,12 @@ // Terminate everything gracefully static void w9966_term(struct w9966_dev* cam) { +// Delete allocated buffer if needed + if (cam->buffer != NULL) { + kfree(cam->buffer); + cam->buffer = NULL; + } + // Unregister from v4l if (w9966_getState(cam, W9966_STATE_VDEV, W9966_STATE_VDEV)) { video_unregister_device(&cam->vdev); @@ -431,9 +429,9 @@ { unsigned int i; unsigned int enh_s, enh_e; - unsigned char scale_x, scale_y; - unsigned char regs[0x1c]; - unsigned char saa7111_regs[] = { + u8 scale_x, scale_y; + u8 regs[0x1c]; + u8 saa7111_regs[] = { 0x21, 0x00, 0xd8, 0x23, 0x00, 0x80, 0x80, 0x00, 0x88, 0x10, 0x80, 0x40, 0x40, 0x00, 0x01, 0x00, 0x48, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, @@ -664,6 +662,7 @@ return data; } + // Write a register to the i2c device. // Expects claimed pdev. -1 on error static int w9966_wReg_i2c(struct w9966_dev* cam, int reg, int data) @@ -693,11 +692,23 @@ static int w9966_v4l_open(struct video_device *vdev, int flags) { + struct w9966_dev *cam = (struct w9966_dev*)vdev->priv; + cam->buffer = (u8*)kmalloc(W9966_RBUFFER, GFP_KERNEL); + + if (cam->buffer == NULL) + return -EFAULT; + return 0; } static void w9966_v4l_close(struct video_device *vdev) { + struct w9966_dev *cam = (struct w9966_dev*)vdev->priv; + + if (cam->buffer != NULL) { + kfree(cam->buffer); + cam->buffer = NULL; + } } static int w9966_v4l_ioctl(struct video_device *vdev, unsigned int cmd, void *arg) @@ -920,13 +931,12 @@ while(dleft > 0) { unsigned long tsize = (dleft > W9966_RBUFFER) ? W9966_RBUFFER : dleft; - unsigned char tbuf[W9966_RBUFFER]; - if (parport_read(cam->pport, tbuf, tsize) < tsize) { + if (parport_read(cam->pport, cam->buffer, tsize) < tsize) { w9966_pdev_release(cam); return -EFAULT; } - if (copy_to_user(dest, tbuf, tsize) != 0) { + if (copy_to_user(dest, cam->buffer, tsize) != 0) { w9966_pdev_release(cam); return -EFAULT; } @@ -948,14 +958,14 @@ for (i = 0; i < W9966_MAXCAMS; i++) { + if (strcmp(pardev[i], "none") == 0) // Skip if 'none' + continue; if (w9966_cams[i].dev_state != 0) // Cam is already assigned continue; - if ( - strcmp(pardev[i], "aggressive") == 0 || - strcmp(pardev[i], port->name) == 0 - ) { + if (strcmp(pardev[i], "auto") == 0 || + strcmp(pardev[i], port->name) == 0) { if (w9966_init(&w9966_cams[i], port) != 0) - w9966_term(&w9966_cams[i]); + w9966_term(&w9966_cams[i]); break; // return } } diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/media/video/zr36067.c linux-2.5/drivers/media/video/zr36067.c --- linux-2.5.1/drivers/media/video/zr36067.c Fri Nov 9 22:01:22 2001 +++ linux-2.5/drivers/media/video/zr36067.c Sun Dec 30 21:17:30 2001 @@ -58,7 +58,6 @@ #include <asm/pgtable.h> #include <asm/page.h> #include <linux/sched.h> -#include <asm/segment.h> #include <linux/types.h> #include <linux/wrapper.h> diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/media/video/zr36120.c linux-2.5/drivers/media/video/zr36120.c --- linux-2.5.1/drivers/media/video/zr36120.c Fri Nov 9 22:01:22 2001 +++ linux-2.5/drivers/media/video/zr36120.c Sun Dec 30 21:17:30 2001 @@ -35,7 +35,6 @@ #include <asm/page.h> #include <linux/sched.h> #include <linux/video_decoder.h> -#include <asm/segment.h> #include <linux/version.h> #include <asm/uaccess.h> diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/message/i2o/i2o_config.c linux-2.5/drivers/message/i2o/i2o_config.c --- linux-2.5.1/drivers/message/i2o/i2o_config.c Fri Nov 30 16:26:04 2001 +++ linux-2.5/drivers/message/i2o/i2o_config.c Fri Dec 28 01:41:21 2001 @@ -45,7 +45,7 @@ static spinlock_t i2o_config_lock = SPIN_LOCK_UNLOCKED; struct wait_queue *i2o_wait_queue; -#define MODINC(x,y) (x = x++ % y) +#define MODINC(x,y) ((x) = ((x) + 1) % (y)) struct i2o_cfg_info { diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/mtd/devices/blkmtd.c linux-2.5/drivers/mtd/devices/blkmtd.c --- linux-2.5.1/drivers/mtd/devices/blkmtd.c Fri Oct 5 19:06:51 2001 +++ linux-2.5/drivers/mtd/devices/blkmtd.c Thu Dec 27 22:10:28 2001 @@ -1,10 +1,11 @@ /* - * $Id: blkmtd.c,v 1.3 2001/10/02 15:33:20 dwmw2 Exp $ + * $Id: blkmtd.c,v 1.7 2001/11/10 17:06:30 spse Exp $ + * * blkmtd.c - use a block device as a fake MTD * * Author: Simon Evans <spse@secret.org.uk> * - * Copyright (C) 2001 Simon Evans <spse@secret.org.uk> + * Copyright (C) 2001 Simon Evans * * Licence: GPL * @@ -13,7 +14,7 @@ * cache to cache access. Writes update the page cache with the * new data but make a copy of the new page(s) and then a kernel * thread writes pages out to the device in the background. This - * ensures tht writes are order even if a page is updated twice. + * ensures that writes are order even if a page is updated twice. * Also, since pages in the page cache are never marked as dirty, * we dont have to worry about writepage() being called on some * random page which may not be in the write order. @@ -30,7 +31,7 @@ * small memory systems and too small on large memory systems. * * Page cache usage may still be a bit wrong. Check we are doing - * everything proberly. + * everything properly. * * Somehow allow writes to dirty the page cache so we dont use too * much memory making copies of outgoing pages. Need to handle case @@ -39,15 +40,9 @@ * * Reading should read multiple pages at once rather than using * readpage() for each one. This is easy and will be fixed asap. - * - * Dont run the write_thread if readonly. This is also easy and will - * be fixed asap. - * - * Even though the multiple erase regions are used if the default erase - * block size doesnt match the device properly, erases currently wont - * work on the last page if it is not a full page. */ + #include <linux/config.h> #include <linux/module.h> @@ -59,20 +54,30 @@ #include <linux/mtd/compatmac.h> #include <linux/mtd/mtd.h> +#ifdef CONFIG_MTD_DEBUG +#ifdef CONFIG_PROC_FS +# include <linux/proc_fs.h> +# define BLKMTD_PROC_DEBUG + static struct proc_dir_entry *blkmtd_proc; +#endif +#endif + + /* Default erase size in K, always make it a multiple of PAGE_SIZE */ #define CONFIG_MTD_BLKDEV_ERASESIZE 128 -#define VERSION "1.1" +#define VERSION "1.7" extern int *blk_size[]; -extern int *blksize_size[]; /* Info for the block device */ typedef struct mtd_raw_dev_data_s { struct block_device *binding; - int sector_size, sector_bits, total_sectors; + int sector_size, sector_bits; + int partial_last_page; // 0 if device ends on page boundary, else page no of last page + int last_page_sectors; // Number of sectors in last page if partial_last_page != 0 size_t totalsize; int readonly; struct address_space as; - struct file *file; + struct mtd_info mtd_info; } mtd_raw_dev_data_t; /* Info for each queue item in the write queue */ @@ -85,24 +90,28 @@ } mtdblkdev_write_queue_t; +/* Our erase page - always remains locked. */ +static struct page *erase_page; + /* Static info about the MTD, used in cleanup_module */ -static struct mtd_info *mtd_info; +static mtd_raw_dev_data_t *mtd_rawdevice; /* Write queue fixed size */ #define WRITE_QUEUE_SZ 512 /* Storage for the write queue */ -static mtdblkdev_write_queue_t write_queue[WRITE_QUEUE_SZ]; +static mtdblkdev_write_queue_t *write_queue; +static int write_queue_sz = WRITE_QUEUE_SZ; static int volatile write_queue_head; static int volatile write_queue_tail; static int volatile write_queue_cnt; static spinlock_t mbd_writeq_lock = SPIN_LOCK_UNLOCKED; /* Tell the write thread to finish */ -static volatile int write_task_finish = 0; +static volatile int write_task_finish; /* ipc with the write thread */ -#if LINUX_VERSION_CODE > 0x020300 +#if LINUX_VERSION_CODE > KERNEL_VERSION(2,3,0) static DECLARE_MUTEX_LOCKED(thread_sem); static DECLARE_WAIT_QUEUE_HEAD(thr_wq); static DECLARE_WAIT_QUEUE_HEAD(mtbd_sync_wq); @@ -113,13 +122,14 @@ #endif - /* Module parameters passed by insmod/modprobe */ char *device; /* the block device to use */ int erasesz; /* optional default erase size */ int ro; /* optional read only flag */ int bs; /* optionally force the block size (avoid using) */ int count; /* optionally force the block count (avoid using) */ +int wqs; /* optionally set the write queue size */ + #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,2,0) MODULE_LICENSE("GPL"); @@ -135,10 +145,10 @@ MODULE_PARM_DESC(bs, "force the block size in bytes"); MODULE_PARM(count, "i"); MODULE_PARM_DESC(count, "force the block count"); +MODULE_PARM(wqs, "i"); #endif - /* Page cache stuff */ /* writepage() - should never be called - catch it anyway */ @@ -150,13 +160,13 @@ /* readpage() - reads one page from the block device */ -static int blkmtd_readpage(struct file *file, struct page *page) +static int blkmtd_readpage(mtd_raw_dev_data_t *rawdevice, struct page *page) { int err; int sectornr, sectors, i; struct kiobuf *iobuf; - mtd_raw_dev_data_t *rawdevice = (mtd_raw_dev_data_t *)file->private_data; kdev_t dev; + unsigned long *blocks; if(!rawdevice) { printk("blkmtd: readpage: PANIC file->private_data == NULL\n"); @@ -168,7 +178,7 @@ bdevname(dev), page, page->index); if(Page_Uptodate(page)) { - DEBUG(1, "blkmtd: readpage page %ld is already upto date\n", page->index); + DEBUG(2, "blkmtd: readpage page %ld is already upto date\n", page->index); UnlockPage(page); return 0; } @@ -184,8 +194,9 @@ mtdblkdev_write_queue_t *item = &write_queue[i]; if(page->index >= item->pagenr && page->index < item->pagenr+item->pagecnt) { /* yes it is */ - int index = item->pagenr - page->index; - DEBUG(1, "blkmtd: readpage: found page %ld in outgoing write queue\n", + int index = page->index - item->pagenr; + + DEBUG(2, "blkmtd: readpage: found page %ld in outgoing write queue\n", page->index); if(item->iserase) { memset(page_address(page), 0xff, PAGE_SIZE); @@ -199,7 +210,7 @@ return 0; } i++; - i %= WRITE_QUEUE_SZ; + i %= write_queue_sz; } } spin_unlock(&mbd_writeq_lock); @@ -208,8 +219,24 @@ DEBUG(3, "blkmtd: readpage: getting kiovec\n"); err = alloc_kiovec(1, &iobuf); if (err) { + printk("blkmtd: cant allocate kiobuf\n"); + SetPageError(page); return err; } + + /* Pre 2.4.4 doesnt have space for the block list in the kiobuf */ +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,4) + blocks = kmalloc(KIO_MAX_SECTORS * sizeof(unsigned long)); + if(blocks == NULL) { + printk("blkmtd: cant allocate iobuf blocks\n"); + free_kiovec(1, &iobuf); + SetPageError(page); + return -ENOMEM; + } +#else + blocks = iobuf->blocks; +#endif + iobuf->offset = 0; iobuf->nr_pages = 1; iobuf->length = PAGE_SIZE; @@ -217,16 +244,34 @@ iobuf->maplist[0] = page; sectornr = page->index << (PAGE_SHIFT - rawdevice->sector_bits); sectors = 1 << (PAGE_SHIFT - rawdevice->sector_bits); + if(rawdevice->partial_last_page && page->index == rawdevice->partial_last_page) { + DEBUG(3, "blkmtd: handling partial last page\n"); + sectors = rawdevice->last_page_sectors; + } DEBUG(3, "blkmtd: readpage: sectornr = %d sectors = %d\n", sectornr, sectors); for(i = 0; i < sectors; i++) { - iobuf->blocks[i] = sectornr++; + blocks[i] = sectornr++; + } + /* If only a partial page read in, clear the rest of the page */ + if(rawdevice->partial_last_page && page->index == rawdevice->partial_last_page) { + int offset = rawdevice->last_page_sectors << rawdevice->sector_bits; + int count = PAGE_SIZE-offset; + DEBUG(3, "blkmtd: clear last partial page: offset = %d count = %d\n", offset, count); + memset(page_address(page)+offset, 0, count); + sectors = rawdevice->last_page_sectors; } + DEBUG(3, "bklmtd: readpage: starting brw_kiovec\n"); - err = brw_kiovec(READ, 1, &iobuf, dev, iobuf->blocks, rawdevice->sector_size); + err = brw_kiovec(READ, 1, &iobuf, dev, blocks, rawdevice->sector_size); DEBUG(3, "blkmtd: readpage: finished, err = %d\n", err); iobuf->locked = 0; free_kiovec(1, &iobuf); + +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,4) + kfree(blocks); +#endif + if(err != PAGE_SIZE) { printk("blkmtd: readpage: error reading page %ld\n", page->index); memset(page_address(page), 0, PAGE_SIZE); @@ -246,7 +291,7 @@ static struct address_space_operations blkmtd_aops = { writepage: blkmtd_writepage, - readpage: blkmtd_readpage, + readpage: NULL, }; @@ -256,6 +301,7 @@ int err; struct task_struct *tsk = current; struct kiobuf *iobuf; + unsigned long *blocks; DECLARE_WAITQUEUE(wait, tsk); DEBUG(1, "blkmtd: writetask: starting (pid = %d)\n", tsk->pid); @@ -268,8 +314,23 @@ spin_unlock_irq(&tsk->sigmask_lock); exit_sighand(tsk); - if(alloc_kiovec(1, &iobuf)) + if(alloc_kiovec(1, &iobuf)) { + printk("blkmtd: write_queue_task cant allocate kiobuf\n"); return 0; + } + + /* Pre 2.4.4 doesnt have space for the block list in the kiobuf */ +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,4) + blocks = kmalloc(KIO_MAX_SECTORS * sizeof(unsigned long)); + if(blocks == NULL) { + printk("blkmtd: write_queue_task cant allocate iobuf blocks\n"); + free_kiovec(1, &iobuf); + return 0; + } +#else + blocks = iobuf->blocks; +#endif + DEBUG(2, "blkmtd: writetask: entering main loop\n"); add_wait_queue(&thr_wq, &wait); @@ -280,30 +341,39 @@ /* If nothing in the queue, wake up anyone wanting to know when there is space in the queue then sleep for 2*HZ */ spin_unlock(&mbd_writeq_lock); - DEBUG(3, "blkmtd: writetask: queue empty\n"); + DEBUG(4, "blkmtd: writetask: queue empty\n"); if(waitqueue_active(&mtbd_sync_wq)) wake_up(&mtbd_sync_wq); interruptible_sleep_on_timeout(&thr_wq, 2*HZ); - DEBUG(3, "blkmtd: writetask: woken up\n"); + DEBUG(4, "blkmtd: writetask: woken up\n"); if(write_task_finish) break; } else { /* we have stuff to write */ mtdblkdev_write_queue_t *item = &write_queue[write_queue_tail]; struct page **pages = item->pages; - int pagecnt = item->pagecnt; - int pagenr = item->pagenr; + int i; + int sectornr = item->pagenr << (PAGE_SHIFT - item->rawdevice->sector_bits); + int sectorcnt = item->pagecnt << (PAGE_SHIFT - item->rawdevice->sector_bits); int max_sectors = KIO_MAX_SECTORS >> (item->rawdevice->sector_bits - 9); kdev_t dev = to_kdev_t(item->rawdevice->binding->bd_dev); - + + /* If we are writing to the last page on the device and it doesnt end + * on a page boundary, subtract the number of sectors that dont exist. + */ + if(item->rawdevice->partial_last_page && + (item->pagenr + item->pagecnt -1) == item->rawdevice->partial_last_page) { + sectorcnt -= (1 << (PAGE_SHIFT - item->rawdevice->sector_bits)); + sectorcnt += item->rawdevice->last_page_sectors; + } DEBUG(3, "blkmtd: writetask: got %d queue items\n", write_queue_cnt); set_current_state(TASK_RUNNING); spin_unlock(&mbd_writeq_lock); - DEBUG(2, "blkmtd: write_task: writing pagenr = %d pagecnt = %d", - item->pagenr, item->pagecnt); + DEBUG(2, "blkmtd: writetask: writing pagenr = %d pagecnt = %d sectornr = %d sectorcnt = %d\n", + item->pagenr, item->pagecnt, sectornr, sectorcnt); iobuf->offset = 0; iobuf->locked = 1; @@ -311,31 +381,33 @@ /* Loop through all the pages to be written in the queue item, remembering we can only write KIO_MAX_SECTORS at a time */ - while(pagecnt) { - int sectornr = pagenr << (PAGE_SHIFT - item->rawdevice->sector_bits); - int sectorcnt = pagecnt << (PAGE_SHIFT - item->rawdevice->sector_bits); + while(sectorcnt) { int cursectors = (sectorcnt < max_sectors) ? sectorcnt : max_sectors; int cpagecnt = (cursectors << item->rawdevice->sector_bits) + PAGE_SIZE-1; cpagecnt >>= PAGE_SHIFT; - for(i = 0; i < cpagecnt; i++) + for(i = 0; i < cpagecnt; i++) { + if(item->iserase) { + iobuf->maplist[i] = erase_page; + } else { iobuf->maplist[i] = *(pages++); + } + } for(i = 0; i < cursectors; i++) { - iobuf->blocks[i] = sectornr++; + blocks[i] = sectornr++; } iobuf->nr_pages = cpagecnt; iobuf->length = cursectors << item->rawdevice->sector_bits; DEBUG(3, "blkmtd: write_task: about to kiovec\n"); - err = brw_kiovec(WRITE, 1, &iobuf, dev, iobuf->blocks, item->rawdevice->sector_size); + err = brw_kiovec(WRITE, 1, &iobuf, dev, blocks, item->rawdevice->sector_size); DEBUG(3, "bklmtd: write_task: done, err = %d\n", err); if(err != (cursectors << item->rawdevice->sector_bits)) { /* if an error occured - set this to exit the loop */ - pagecnt = 0; + sectorcnt = 0; } else { - pagenr += cpagecnt; - pagecnt -= cpagecnt; + sectorcnt -= cursectors; } } @@ -345,12 +417,14 @@ spin_lock(&mbd_writeq_lock); write_queue_cnt--; write_queue_tail++; - write_queue_tail %= WRITE_QUEUE_SZ; - for(i = 0 ; i < item->pagecnt; i++) { - UnlockPage(item->pages[i]); - __free_pages(item->pages[i], 0); + write_queue_tail %= write_queue_sz; + if(!item->iserase) { + for(i = 0 ; i < item->pagecnt; i++) { + UnlockPage(item->pages[i]); + __free_pages(item->pages[i], 0); + } + kfree(item->pages); } - kfree(item->pages); item->pages = NULL; spin_unlock(&mbd_writeq_lock); /* Tell others there is some space in the write queue */ @@ -361,6 +435,11 @@ remove_wait_queue(&thr_wq, &wait); DEBUG(1, "blkmtd: writetask: exiting\n"); free_kiovec(1, &iobuf); + +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,4) + kfree(blocks); +#endif + /* Tell people we have exitd */ up(&thread_sem); return 0; @@ -372,43 +451,45 @@ int pagenr, int pagecnt, int iserase) { struct page *outpage; - struct page **new_pages; + struct page **new_pages = NULL; mtdblkdev_write_queue_t *item; int i; DECLARE_WAITQUEUE(wait, current); - DEBUG(2, "mtdblkdev: queue_page_write: adding pagenr = %d pagecnt = %d\n", pagenr, pagecnt); + DEBUG(2, "blkmtd: queue_page_write: adding pagenr = %d pagecnt = %d\n", pagenr, pagecnt); if(!pagecnt) return 0; - if(pages == NULL) + if(pages == NULL && !iserase) return -EINVAL; /* create a array for the list of pages */ - new_pages = kmalloc(pagecnt * sizeof(struct page *), GFP_KERNEL); - if(new_pages == NULL) - return -ENOMEM; + if(!iserase) { + new_pages = kmalloc(pagecnt * sizeof(struct page *), GFP_KERNEL); + if(new_pages == NULL) + return -ENOMEM; - /* make copies of the pages in the page cache */ - for(i = 0; i < pagecnt; i++) { - outpage = alloc_pages(GFP_KERNEL, 0); - if(!outpage) { - while(i--) { - UnlockPage(new_pages[i]); - __free_pages(new_pages[i], 0); + /* make copies of the pages in the page cache */ + for(i = 0; i < pagecnt; i++) { + outpage = alloc_pages(GFP_KERNEL, 0); + if(!outpage) { + while(i--) { + UnlockPage(new_pages[i]); + __free_pages(new_pages[i], 0); + } + kfree(new_pages); + return -ENOMEM; } - kfree(new_pages); - return -ENOMEM; + lock_page(outpage); + memcpy(page_address(outpage), page_address(pages[i]), PAGE_SIZE); + new_pages[i] = outpage; } - lock_page(outpage); - memcpy(page_address(outpage), page_address(pages[i]), PAGE_SIZE); - new_pages[i] = outpage; } /* wait until there is some space in the write queue */ test_lock: spin_lock(&mbd_writeq_lock); - if(write_queue_cnt == WRITE_QUEUE_SZ) { + if(write_queue_cnt == write_queue_sz) { spin_unlock(&mbd_writeq_lock); DEBUG(3, "blkmtd: queue_page: Queue full\n"); current->state = TASK_UNINTERRUPTIBLE; @@ -417,11 +498,11 @@ schedule(); current->state = TASK_RUNNING; remove_wait_queue(&mtbd_sync_wq, &wait); - DEBUG(3, "blkmtd: queue_page: Queue has %d items in it\n", write_queue_cnt); + DEBUG(3, "blkmtd: queue_page_write: Queue has %d items in it\n", write_queue_cnt); goto test_lock; } - DEBUG(3, "blkmtd: queue_write_page: qhead: %d qtail: %d qcnt: %d\n", + DEBUG(3, "blkmtd: queue_page_write: qhead: %d qtail: %d qcnt: %d\n", write_queue_head, write_queue_tail, write_queue_cnt); /* fix up the queue item */ @@ -433,9 +514,9 @@ item->iserase = iserase; write_queue_head++; - write_queue_head %= WRITE_QUEUE_SZ; + write_queue_head %= write_queue_sz; write_queue_cnt++; - DEBUG(3, "blkmtd: queue_write_page: qhead: %d qtail: %d qcnt: %d\n", + DEBUG(3, "blkmtd: queue_page_write: qhead: %d qtail: %d qcnt: %d\n", write_queue_head, write_queue_tail, write_queue_cnt); spin_unlock(&mbd_writeq_lock); DEBUG(2, "blkmtd: queue_page_write: finished\n"); @@ -447,6 +528,8 @@ static int blkmtd_erase(struct mtd_info *mtd, struct erase_info *instr) { mtd_raw_dev_data_t *rawdevice = mtd->priv; + struct mtd_erase_region_info *einfo = mtd->eraseregions; + int numregions = mtd->numeraseregions; size_t from; u_long len; int err = 0; @@ -462,17 +545,23 @@ from = instr->addr; len = instr->len; - /* check page alignment of start and length */ - DEBUG(2, "blkmtd: erase: dev = `%s' from = %d len = %ld\n", + /* check erase region has valid start and length */ + DEBUG(2, "blkmtd: erase: dev = `%s' from = 0x%x len = 0x%lx\n", bdevname(rawdevice->binding->bd_dev), from, len); - if(from % PAGE_SIZE) { - printk("blkmtd: erase: addr not page aligned (addr = %d)\n", from); - instr->state = MTD_ERASE_FAILED; - err = -EIO; + while(numregions) { + DEBUG(3, "blkmtd: checking erase region = 0x%08X size = 0x%X num = 0x%x\n", + einfo->offset, einfo->erasesize, einfo->numblocks); + if(from >= einfo->offset && from < einfo->offset + (einfo->erasesize * einfo->numblocks)) { + if(len == einfo->erasesize && ( (from - einfo->offset) % einfo->erasesize == 0)) + break; + } + numregions--; + einfo++; } - if(len % PAGE_SIZE) { - printk("blkmtd: erase: len not a whole number of pages (len = %ld)\n", len); + if(!numregions) { + /* Not a valid erase block */ + printk("blkmtd: erase: invalid erase request 0x%lX @ 0x%08X\n", len, from); instr->state = MTD_ERASE_FAILED; err = -EIO; } @@ -483,9 +572,14 @@ struct page *page, **pages; int i = 0; + /* Handle the last page of the device not being whole */ + if(len < PAGE_SIZE) + len = PAGE_SIZE; + pagenr = from >> PAGE_SHIFT; pagecnt = len >> PAGE_SHIFT; DEBUG(3, "blkmtd: erase: pagenr = %d pagecnt = %d\n", pagenr, pagecnt); + pages = kmalloc(pagecnt * sizeof(struct page *), GFP_KERNEL); if(pages == NULL) { err = -ENOMEM; @@ -493,9 +587,10 @@ goto erase_out; } + while(pagecnt) { /* get the page via the page cache */ - DEBUG(3, "blkmtd: erase: doing grap_cache_page() for page %d\n", pagenr); + DEBUG(3, "blkmtd: erase: doing grab_cache_page() for page %d\n", pagenr); page = grab_cache_page(&rawdevice->as, pagenr); if(!page) { DEBUG(3, "blkmtd: erase: grab_cache_page() failed for page %d\n", pagenr); @@ -511,7 +606,7 @@ i++; } DEBUG(3, "blkmtd: erase: queuing page write\n"); - err = queue_page_write(rawdevice, pages, from >> PAGE_SHIFT, len >> PAGE_SHIFT, 1); + err = queue_page_write(rawdevice, NULL, from >> PAGE_SHIFT, len >> PAGE_SHIFT, 1); pagecnt = len >> PAGE_SHIFT; if(!err) { while(pagecnt--) { @@ -567,7 +662,7 @@ struct page *page; int cpylen; DEBUG(3, "blkmtd: read: looking for page: %d\n", pagenr); - page = read_cache_page(&rawdevice->as, pagenr, (filler_t *)blkmtd_readpage, rawdevice->file); + page = read_cache_page(&rawdevice->as, pagenr, (filler_t *)blkmtd_readpage, rawdevice); if(IS_ERR(page)) { return PTR_ERR(page); } @@ -683,7 +778,7 @@ struct page *page; DEBUG(3, "blkmtd: write: doing partial start, page = %d len = %d offset = %d\n", pagenr, len1, offset); - page = read_cache_page(&rawdevice->as, pagenr, (filler_t *)blkmtd_readpage, rawdevice->file); + page = read_cache_page(&rawdevice->as, pagenr, (filler_t *)blkmtd_readpage, rawdevice); if(IS_ERR(page)) { kfree(pages); @@ -716,6 +811,7 @@ memcpy(page_address(page), buf, PAGE_SIZE); pages[pagecnt++] = page; UnlockPage(page); + SetPageUptodate(page); pagenr++; pagesc--; buf += PAGE_SIZE; @@ -728,7 +824,7 @@ /* do the third region */ struct page *page; DEBUG(3, "blkmtd: write: doing partial end, page = %d len = %d\n", pagenr, len3); - page = read_cache_page(&rawdevice->as, pagenr, (filler_t *)blkmtd_readpage, rawdevice->file); + page = read_cache_page(&rawdevice->as, pagenr, (filler_t *)blkmtd_readpage, rawdevice); if(IS_ERR(page)) { err = PTR_ERR(page); goto write_err; @@ -766,6 +862,10 @@ static void blkmtd_sync(struct mtd_info *mtd) { DECLARE_WAITQUEUE(wait, current); + mtd_raw_dev_data_t *rawdevice = mtd->priv; + if(rawdevice->readonly) + return; + DEBUG(2, "blkmtd: sync: called\n"); stuff_inq: @@ -784,36 +884,144 @@ } spin_unlock(&mbd_writeq_lock); - DEBUG(2, "blkmtdL sync: finished\n"); + DEBUG(2, "blkmtd: sync: finished\n"); } + +#ifdef BLKMTD_PROC_DEBUG +/* procfs stuff */ +static int blkmtd_proc_read(char *page, char **start, off_t off, int count, int *eof, void *data) +{ + int clean = 0, dirty = 0, locked = 0; + struct list_head *temp; + int i, len, pages = 0, cnt; + MOD_INC_USE_COUNT; + spin_lock(&mbd_writeq_lock); + cnt = write_queue_cnt; + i = write_queue_tail; + while(cnt) { + if(!write_queue[i].iserase) + pages += write_queue[i].pagecnt; + i++; + i %= write_queue_sz; + cnt--; + } + + /* Count the size of the page lists */ + list_for_each(temp, &mtd_rawdevice->as.clean_pages) { + clean++; + } + list_for_each(temp, &mtd_rawdevice->as.dirty_pages) { + dirty++; + } + list_for_each(temp, &mtd_rawdevice->as.locked_pages) { + locked++; + } + + len = sprintf(page, "Write queue head: %d\nWrite queue tail: %d\n" + "Write queue count: %d\nPages in queue: %d (%dK)\n" + "Clean Pages: %d\nDirty Pages: %d\nLocked Pages: %d\n" + "nrpages: %ld\n", + write_queue_head, write_queue_tail, write_queue_cnt, + pages, pages << (PAGE_SHIFT-10), clean, dirty, locked, + mtd_rawdevice->as.nrpages); + if(len <= count) + *eof = 1; + spin_unlock(&mbd_writeq_lock); + MOD_DEC_USE_COUNT; + return len; +} +#endif + + /* Cleanup and exit - sync the device and kill of the kernel thread */ static void __exit cleanup_blkmtd(void) { - if (mtd_info) { - mtd_raw_dev_data_t *rawdevice = mtd_info->priv; - // sync the device - if (rawdevice) { - blkmtd_sync(mtd_info); +#ifdef BLKMTD_PROC_DEBUG + if(blkmtd_proc) { + remove_proc_entry("blkmtd_debug", NULL); + } +#endif + + if (mtd_rawdevice) { + /* sync the device */ + if (!mtd_rawdevice->readonly) { + blkmtd_sync(&mtd_rawdevice->mtd_info); write_task_finish = 1; wake_up_interruptible(&thr_wq); down(&thread_sem); - if(rawdevice->binding != NULL) - blkdev_put(rawdevice->binding, BDEV_RAW); - filp_close(rawdevice->file, NULL); - kfree(mtd_info->priv); } - if(mtd_info->eraseregions) - kfree(mtd_info->eraseregions); - del_mtd_device(mtd_info); - kfree(mtd_info); - mtd_info = NULL; + del_mtd_device(&mtd_rawdevice->mtd_info); + if(mtd_rawdevice->binding != NULL) + blkdev_put(mtd_rawdevice->binding, BDEV_RAW); + + if(mtd_rawdevice->mtd_info.eraseregions) + kfree(mtd_rawdevice->mtd_info.eraseregions); + if(mtd_rawdevice->mtd_info.name) + kfree(mtd_rawdevice->mtd_info.name); + + kfree(mtd_rawdevice); + } + if(write_queue) + kfree(write_queue); + + if(erase_page) { + UnlockPage(erase_page); + __free_pages(erase_page, 0); } printk("blkmtd: unloaded for %s\n", device); } extern struct module __this_module; +#ifndef MODULE + +/* Handle kernel boot params */ + + +static int __init param_blkmtd_device(char *str) +{ + device = str; + return 1; +} + + +static int __init param_blkmtd_erasesz(char *str) +{ + erasesz = simple_strtol(str, NULL, 0); + return 1; +} + + +static int __init param_blkmtd_ro(char *str) +{ + ro = simple_strtol(str, NULL, 0); + return 1; +} + + +static int __init param_blkmtd_bs(char *str) +{ + bs = simple_strtol(str, NULL, 0); + return 1; +} + + +static int __init param_blkmtd_count(char *str) +{ + count = simple_strtol(str, NULL, 0); + return 1; +} + +__setup("blkmtd_device=", param_blkmtd_device); +__setup("blkmtd_erasesz=", param_blkmtd_erasesz); +__setup("blkmtd_ro=", param_blkmtd_ro); +__setup("blkmtd_bs=", param_blkmtd_bs); +__setup("blkmtd_count=", param_blkmtd_count); + +#endif + + /* for a given size and initial erase size, calculate the number and size of each erase region */ static int __init calc_erase_regions(struct mtd_erase_region_info *info, size_t erase_size, size_t total_size) @@ -842,12 +1050,16 @@ } +extern kdev_t name_to_kdev_t(char *line) __init; + /* Startup */ static int __init init_blkmtd(void) { +#ifdef MODULE struct file *file = NULL; struct inode *inode; - mtd_raw_dev_data_t *rawdevice = NULL; +#endif + int maj, min; int i, blocksize, blocksize_bits; loff_t size = 0; @@ -856,15 +1068,12 @@ kdev_t rdev; int err; int mode; - int totalsize = 0, total_sectors = 0; int regions; - mtd_info = NULL; - - // Check args + /* Check args */ if(device == 0) { printk("blkmtd: error, missing `device' name\n"); - return 1; + return -EINVAL; } if(ro) @@ -873,12 +1082,25 @@ if(erasesz) erase_size = erasesz; - DEBUG(1, "blkmtd: got device = `%s' erase size = %dK readonly = %s\n", device, erase_size, readonly ? "yes" : "no"); - // Get a handle on the device + if(wqs) { + if(wqs < 16) + wqs = 16; + if(wqs > 4*WRITE_QUEUE_SZ) + wqs = 4*WRITE_QUEUE_SZ; + write_queue_sz = wqs; + } + + DEBUG(1, "blkmtd: device = `%s' erase size = %dK readonly = %s queue size = %d\n", + device, erase_size, readonly ? "yes" : "no", write_queue_sz); + /* Get a handle on the device */ mode = (readonly) ? O_RDONLY : O_RDWR; + +#ifdef MODULE + file = filp_open(device, mode, 0); if(IS_ERR(file)) { - DEBUG(2, "blkmtd: open_namei returned %ld\n", PTR_ERR(file)); + printk("blkmtd: error, cant open device %s\n", device); + DEBUG(2, "blkmtd: filp_open returned %ld\n", PTR_ERR(file)); return 1; } @@ -891,11 +1113,19 @@ return 1; } rdev = inode->i_rdev; - //filp_close(file, NULL); - DEBUG(1, "blkmtd: found a block device major = %d, minor = %d\n", - MAJOR(rdev), MINOR(rdev)); + filp_close(file, NULL); +#else + rdev = name_to_kdev_t(device); +#endif + maj = MAJOR(rdev); min = MINOR(rdev); + DEBUG(1, "blkmtd: found a block device major = %d, minor = %d\n", maj, min); + + if(!rdev) { + printk("blkmtd: bad block device: `%s'\n", device); + return 1; + } if(maj == MTD_BLOCK_MAJOR) { printk("blkmtd: attempting to use an MTD device as a block device\n"); @@ -905,14 +1135,7 @@ DEBUG(1, "blkmtd: devname = %s\n", bdevname(rdev)); blocksize = BLOCK_SIZE; - if(bs) { - blocksize = bs; - } else { - if (blksize_size[maj] && blksize_size[maj][min]) { - DEBUG(2, "blkmtd: blksize_size = %d\n", blksize_size[maj][min]); - blocksize = blksize_size[maj][min]; - } - } + blocksize = bs ? bs : block_size(rdev); i = blocksize; blocksize_bits = 0; while(i != 1) { @@ -927,116 +1150,159 @@ size = ((loff_t) blk_size[maj][min] << BLOCK_SIZE_BITS) >> blocksize_bits; } } - total_sectors = size; size *= blocksize; - totalsize = size; DEBUG(1, "blkmtd: size = %ld\n", (long int)size); if(size == 0) { printk("blkmtd: cant determine size\n"); return 1; } - rawdevice = (mtd_raw_dev_data_t *)kmalloc(sizeof(mtd_raw_dev_data_t), GFP_KERNEL); - if(rawdevice == NULL) { + + mtd_rawdevice = (mtd_raw_dev_data_t *)kmalloc(sizeof(mtd_raw_dev_data_t), GFP_KERNEL); + if(mtd_rawdevice == NULL) { err = -ENOMEM; goto init_err; } - memset(rawdevice, 0, sizeof(mtd_raw_dev_data_t)); - // get the block device - rawdevice->binding = bdget(kdev_t_to_nr(MKDEV(maj, min))); - err = blkdev_get(rawdevice->binding, mode, 0, BDEV_RAW); + memset(mtd_rawdevice, 0, sizeof(mtd_raw_dev_data_t)); + /* get the block device */ + mtd_rawdevice->binding = bdget(kdev_t_to_nr(MKDEV(maj, min))); + err = blkdev_get(mtd_rawdevice->binding, mode, 0, BDEV_RAW); if (err) { goto init_err; } - rawdevice->totalsize = totalsize; - rawdevice->total_sectors = total_sectors; - rawdevice->sector_size = blocksize; - rawdevice->sector_bits = blocksize_bits; - rawdevice->readonly = readonly; - - DEBUG(2, "sector_size = %d, sector_bits = %d\n", rawdevice->sector_size, rawdevice->sector_bits); - - mtd_info = (struct mtd_info *)kmalloc(sizeof(struct mtd_info), GFP_KERNEL); - if (mtd_info == NULL) { - err = -ENOMEM; + mtd_rawdevice->totalsize = size; + mtd_rawdevice->sector_size = blocksize; + mtd_rawdevice->sector_bits = blocksize_bits; + mtd_rawdevice->readonly = readonly; + + /* See if device ends on page boundary */ + if(size % PAGE_SIZE) { + mtd_rawdevice->partial_last_page = size >> PAGE_SHIFT; + mtd_rawdevice->last_page_sectors = (size & (PAGE_SIZE-1)) >> blocksize_bits; + } + + DEBUG(2, "sector_size = %d, sector_bits = %d, partial_last_page = %d last_page_sectors = %d\n", + mtd_rawdevice->sector_size, mtd_rawdevice->sector_bits, + mtd_rawdevice->partial_last_page, mtd_rawdevice->last_page_sectors); + + /* Setup the MTD structure */ + /* make the name contain the block device in */ + mtd_rawdevice->mtd_info.name = kmalloc(9 + strlen(device), GFP_KERNEL); + if(mtd_rawdevice->mtd_info.name == NULL) goto init_err; - } - memset(mtd_info, 0, sizeof(*mtd_info)); - // Setup the MTD structure - mtd_info->name = "blkmtd block device"; + sprintf(mtd_rawdevice->mtd_info.name, "blkmtd: %s", device); if(readonly) { - mtd_info->type = MTD_ROM; - mtd_info->flags = MTD_CAP_ROM; - mtd_info->erasesize = erase_size << 10; + mtd_rawdevice->mtd_info.type = MTD_ROM; + mtd_rawdevice->mtd_info.flags = MTD_CAP_ROM; + mtd_rawdevice->mtd_info.erasesize = erase_size << 10; } else { - mtd_info->type = MTD_RAM; - mtd_info->flags = MTD_CAP_RAM; - mtd_info->erasesize = erase_size << 10; - } - mtd_info->size = size; - mtd_info->erase = blkmtd_erase; - mtd_info->read = blkmtd_read; - mtd_info->write = blkmtd_write; - mtd_info->sync = blkmtd_sync; - mtd_info->point = 0; - mtd_info->unpoint = 0; + mtd_rawdevice->mtd_info.type = MTD_RAM; + mtd_rawdevice->mtd_info.flags = MTD_CAP_RAM; + mtd_rawdevice->mtd_info.erasesize = erase_size << 10; + } + mtd_rawdevice->mtd_info.size = size; + mtd_rawdevice->mtd_info.erase = blkmtd_erase; + mtd_rawdevice->mtd_info.read = blkmtd_read; + mtd_rawdevice->mtd_info.write = blkmtd_write; + mtd_rawdevice->mtd_info.sync = blkmtd_sync; + mtd_rawdevice->mtd_info.point = 0; + mtd_rawdevice->mtd_info.unpoint = 0; - mtd_info->priv = rawdevice; + mtd_rawdevice->mtd_info.priv = mtd_rawdevice; regions = calc_erase_regions(NULL, erase_size << 10, size); DEBUG(1, "blkmtd: init: found %d erase regions\n", regions); - mtd_info->eraseregions = kmalloc(regions * sizeof(struct mtd_erase_region_info), GFP_KERNEL); - if(mtd_info->eraseregions == NULL) { + mtd_rawdevice->mtd_info.eraseregions = kmalloc(regions * sizeof(struct mtd_erase_region_info), GFP_KERNEL); + if(mtd_rawdevice->mtd_info.eraseregions == NULL) { + err = -ENOMEM; + goto init_err; } - mtd_info->numeraseregions = regions; - calc_erase_regions(mtd_info->eraseregions, erase_size << 10, size); + mtd_rawdevice->mtd_info.numeraseregions = regions; + calc_erase_regions(mtd_rawdevice->mtd_info.eraseregions, erase_size << 10, size); /* setup the page cache info */ - INIT_LIST_HEAD(&rawdevice->as.clean_pages); - INIT_LIST_HEAD(&rawdevice->as.dirty_pages); - INIT_LIST_HEAD(&rawdevice->as.locked_pages); - rawdevice->as.nrpages = 0; - rawdevice->as.a_ops = &blkmtd_aops; - rawdevice->as.host = inode; - rawdevice->as.i_mmap = NULL; - rawdevice->as.i_mmap_shared = NULL; - spin_lock_init(&rawdevice->as.i_shared_lock); - rawdevice->as.gfp_mask = GFP_KERNEL; - rawdevice->file = file; - - file->private_data = rawdevice; + + mtd_rawdevice->as.nrpages = 0; + INIT_LIST_HEAD(&mtd_rawdevice->as.clean_pages); + INIT_LIST_HEAD(&mtd_rawdevice->as.dirty_pages); + INIT_LIST_HEAD(&mtd_rawdevice->as.locked_pages); + mtd_rawdevice->as.host = NULL; + spin_lock_init(&(mtd_rawdevice->as.i_shared_lock)); + + mtd_rawdevice->as.a_ops = &blkmtd_aops; + mtd_rawdevice->as.i_mmap = NULL; + mtd_rawdevice->as.i_mmap_shared = NULL; + mtd_rawdevice->as.gfp_mask = GFP_KERNEL; #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,2,0) - mtd_info->module = THIS_MODULE; + mtd_rawdevice->mtd_info.module = THIS_MODULE; #endif - if (add_mtd_device(mtd_info)) { - err = -EIO; - goto init_err; - } - init_waitqueue_head(&thr_wq); - init_waitqueue_head(&mtbd_sync_wq); - DEBUG(3, "blkmtd: init: kernel task @ %p\n", write_queue_task); - DEBUG(2, "blkmtd: init: starting kernel task\n"); - kernel_thread(write_queue_task, NULL, CLONE_FS | CLONE_FILES | CLONE_SIGHAND); - DEBUG(2, "blkmtd: init: started\n"); - printk("blkmtd loaded: version = %s using %s erase_size = %dK %s\n", VERSION, device, erase_size, (readonly) ? "(read-only)" : ""); - return 0; + if (add_mtd_device(&mtd_rawdevice->mtd_info)) { + err = -EIO; + goto init_err; + } + if(!mtd_rawdevice->readonly) { + /* Allocate the write queue */ + write_queue = kmalloc(write_queue_sz * sizeof(mtdblkdev_write_queue_t), GFP_KERNEL); + if(!write_queue) { + err = -ENOMEM; + goto init_err; + } + /* Set up the erase page */ + erase_page = alloc_pages(GFP_KERNEL, 0); + if(erase_page == NULL) { + err = -ENOMEM; + goto init_err; + } + memset(page_address(erase_page), 0xff, PAGE_SIZE); + lock_page(erase_page); + + init_waitqueue_head(&thr_wq); + init_waitqueue_head(&mtbd_sync_wq); + DEBUG(3, "blkmtd: init: kernel task @ %p\n", write_queue_task); + DEBUG(2, "blkmtd: init: starting kernel task\n"); + kernel_thread(write_queue_task, NULL, CLONE_FS | CLONE_FILES | CLONE_SIGHAND); + DEBUG(2, "blkmtd: init: started\n"); + printk("blkmtd loaded: version = %s using %s erase_size = %dK %s\n", + VERSION, device, erase_size, (readonly) ? "(read-only)" : ""); + } + +#ifdef BLKMTD_PROC_DEBUG + /* create proc entry */ + DEBUG(2, "Creating /proc/blkmtd_debug\n"); + blkmtd_proc = create_proc_read_entry("blkmtd_debug", 0444, + NULL, blkmtd_proc_read, NULL); + if(blkmtd_proc == NULL) { + printk("Cant create /proc/blkmtd_debug\n"); + } else { + blkmtd_proc->owner = THIS_MODULE; + } +#endif + + /* Everything is ok if we got here */ + return 0; + init_err: - if(!rawdevice) { - if(rawdevice->binding) - blkdev_put(rawdevice->binding, BDEV_RAW); - kfree(rawdevice); - rawdevice = NULL; - } - if(mtd_info) { - if(mtd_info->eraseregions) - kfree(mtd_info->eraseregions); - kfree(mtd_info); - mtd_info = NULL; - } - return err; + if(mtd_rawdevice) { + if(mtd_rawdevice->mtd_info.eraseregions) + kfree(mtd_rawdevice->mtd_info.eraseregions); + if(mtd_rawdevice->mtd_info.name) + kfree(mtd_rawdevice->mtd_info.name); + if(mtd_rawdevice->binding) + blkdev_put(mtd_rawdevice->binding, BDEV_RAW); + kfree(mtd_rawdevice); + } + + if(write_queue) { + kfree(write_queue); + write_queue = NULL; + } + + if(erase_page) + __free_pages(erase_page, 0); + return err; } module_init(init_blkmtd); diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/mtd/devices/doc1000.c linux-2.5/drivers/mtd/devices/doc1000.c --- linux-2.5.1/drivers/mtd/devices/doc1000.c Thu Oct 4 22:14:59 2001 +++ linux-2.5/drivers/mtd/devices/doc1000.c Sun Dec 30 21:17:30 2001 @@ -20,7 +20,6 @@ #include <linux/ioctl.h> #include <asm/io.h> #include <asm/system.h> -#include <asm/segment.h> #include <stdarg.h> #include <linux/delay.h> #include <linux/init.h> diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/mtd/devices/pmc551.c linux-2.5/drivers/mtd/devices/pmc551.c --- linux-2.5.1/drivers/mtd/devices/pmc551.c Thu Oct 4 22:14:59 2001 +++ linux-2.5/drivers/mtd/devices/pmc551.c Sun Dec 30 21:17:30 2001 @@ -98,7 +98,6 @@ #include <linux/ioctl.h> #include <asm/io.h> #include <asm/system.h> -#include <asm/segment.h> #include <stdarg.h> #include <linux/pci.h> diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/mtd/devices/slram.c linux-2.5/drivers/mtd/devices/slram.c --- linux-2.5.1/drivers/mtd/devices/slram.c Thu Oct 4 22:14:59 2001 +++ linux-2.5/drivers/mtd/devices/slram.c Sun Dec 30 21:17:30 2001 @@ -20,7 +20,6 @@ #include <linux/init.h> #include <asm/io.h> #include <asm/system.h> -#include <asm/segment.h> #include <stdarg.h> #include <linux/mtd/mtd.h> diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/mtd/nftlmount.c linux-2.5/drivers/mtd/nftlmount.c --- linux-2.5.1/drivers/mtd/nftlmount.c Thu Oct 4 22:13:18 2001 +++ linux-2.5/drivers/mtd/nftlmount.c Thu Dec 20 19:14:29 2001 @@ -4,7 +4,7 @@ * Author: Fabrice Bellard (fabrice.bellard@netgem.com) * Copyright (C) 2000 Netgem S.A. * - * $Id: nftlmount.c,v 1.23 2001/09/19 21:42:32 dwmw2 Exp $ + * $Id: nftlmount.c,v 1.25 2001/11/30 16:46:27 dwmw2 Exp $ * * 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 @@ -39,7 +39,7 @@ #define SECTORSIZE 512 -char nftlmountrev[]="$Revision: 1.23 $"; +char nftlmountrev[]="$Revision: 1.25 $"; /* find_boot_record: Find the NFTL Media Header and its Spare copy which contains the * various device information of the NFTL partition and Bad Unit Table. Update @@ -94,11 +94,11 @@ continue; } -#if 1 /* Some people seem to have devices without ECC or erase marks +#if 0 /* Some people seem to have devices without ECC or erase marks on the Media Header blocks. There are enough other sanity checks in here that we can probably do without it. */ - if (le16_to_cpu ((h1.EraseMark | h1.EraseMark1) != ERASE_MARK)) { + if (le16_to_cpu(h1.EraseMark | h1.EraseMark1) != ERASE_MARK) { printk(KERN_NOTICE "ANAND header found at 0x%x in mtd%d, but erase mark not present (0x%04x,0x%04x instead)\n", block * nftl->EraseSize, nftl->mtd->index, le16_to_cpu(h1.EraseMark), le16_to_cpu(h1.EraseMark1)); diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/net/3c501.c linux-2.5/drivers/net/3c501.c --- linux-2.5.1/drivers/net/3c501.c Sun Sep 30 19:26:06 2001 +++ linux-2.5/drivers/net/3c501.c Thu Dec 27 16:32:31 2001 @@ -87,8 +87,12 @@ * */ +#define DRV_NAME "3c501" +#define DRV_VERSION "2001/11/17" + + static const char version[] = - "3c501.c: 2000/02/08 Alan Cox (alan@redhat.com).\n"; + DRV_NAME ".c: " DRV_VERSION " Alan Cox (alan@redhat.com).\n"; /* * Braindamage remaining: @@ -108,7 +112,9 @@ #include <linux/errno.h> #include <linux/config.h> /* for CONFIG_IP_MULTICAST */ #include <linux/spinlock.h> +#include <linux/ethtool.h> +#include <asm/uaccess.h> #include <asm/bitops.h> #include <asm/io.h> @@ -139,12 +145,14 @@ static int el1_close(struct net_device *dev); static struct net_device_stats *el1_get_stats(struct net_device *dev); static void set_multicast_list(struct net_device *dev); +static int netdev_ioctl (struct net_device *dev, struct ifreq *rq, int cmd); #define EL1_IO_EXTENT 16 #ifndef EL_DEBUG #define EL_DEBUG 0 /* use 0 for production, 1 for devel., >2 for debug */ #endif /* Anything above 5 is wordy death! */ +#define debug el_debug static int el_debug = EL_DEBUG; /* @@ -377,6 +385,7 @@ dev->stop = &el1_close; dev->get_stats = &el1_get_stats; dev->set_multicast_list = &set_multicast_list; + dev->do_ioctl = netdev_ioctl; /* * Setup the generic properties @@ -915,6 +924,86 @@ } } +/** + * netdev_ethtool_ioctl: Handle network interface SIOCETHTOOL ioctls + * @dev: network interface on which out-of-band action is to be performed + * @useraddr: userspace address to which data is to be read and returned + * + * Process the various commands of the SIOCETHTOOL interface. + */ + +static int netdev_ethtool_ioctl (struct net_device *dev, void *useraddr) +{ + u32 ethcmd; + + /* dev_ioctl() in ../../net/core/dev.c has already checked + capable(CAP_NET_ADMIN), so don't bother with that here. */ + + if (get_user(ethcmd, (u32 *)useraddr)) + return -EFAULT; + + switch (ethcmd) { + + case ETHTOOL_GDRVINFO: { + struct ethtool_drvinfo info = { ETHTOOL_GDRVINFO }; + strcpy (info.driver, DRV_NAME); + strcpy (info.version, DRV_VERSION); + sprintf(info.bus_info, "ISA 0x%lx", dev->base_addr); + if (copy_to_user (useraddr, &info, sizeof (info))) + return -EFAULT; + return 0; + } + + /* get message-level */ + case ETHTOOL_GMSGLVL: { + struct ethtool_value edata = {ETHTOOL_GMSGLVL}; + edata.data = debug; + if (copy_to_user(useraddr, &edata, sizeof(edata))) + return -EFAULT; + return 0; + } + /* set message-level */ + case ETHTOOL_SMSGLVL: { + struct ethtool_value edata; + if (copy_from_user(&edata, useraddr, sizeof(edata))) + return -EFAULT; + debug = edata.data; + return 0; + } + + default: + break; + } + + return -EOPNOTSUPP; +} + +/** + * netdev_ioctl: Handle network interface ioctls + * @dev: network interface on which out-of-band action is to be performed + * @rq: user request data + * @cmd: command issued by user + * + * Process the various out-of-band ioctls passed to this driver. + */ + +static int netdev_ioctl (struct net_device *dev, struct ifreq *rq, int cmd) +{ + int rc = 0; + + switch (cmd) { + case SIOCETHTOOL: + rc = netdev_ethtool_ioctl(dev, (void *) rq->ifr_data); + break; + + default: + rc = -EOPNOTSUPP; + break; + } + + return rc; +} + #ifdef MODULE static struct net_device dev_3c501 = { diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/net/3c503.c linux-2.5/drivers/net/3c503.c --- linux-2.5.1/drivers/net/3c503.c Sun Sep 30 19:26:06 2001 +++ linux-2.5/drivers/net/3c503.c Thu Dec 27 16:32:31 2001 @@ -29,11 +29,17 @@ Paul Gortmaker : add support for the 2nd 8kB of RAM on 16 bit cards. Paul Gortmaker : multiple card support for module users. rjohnson@analogic.com : Fix up PIO interface for efficient operation. + Jeff Garzik : ethtool support */ +#define DRV_NAME "3c503" +#define DRV_VERSION "1.10a" +#define DRV_RELDATE "11/17/2001" + + static const char version[] = - "3c503.c:v1.10 9/23/93 Donald Becker (becker@cesdis.gsfc.nasa.gov)\n"; + DRV_NAME ".c:v" DRV_VERSION " " DRV_RELDATE " Donald Becker (becker@scyld.com)\n"; #include <linux/module.h> @@ -45,7 +51,9 @@ #include <linux/netdevice.h> #include <linux/etherdevice.h> #include <linux/init.h> +#include <linux/ethtool.h> +#include <asm/uaccess.h> #include <asm/io.h> #include <asm/system.h> #include <asm/byteorder.h> @@ -74,6 +82,7 @@ int ring_offset); static void el2_get_8390_hdr(struct net_device *dev, struct e8390_pkt_hdr *hdr, int ring_page); +static int netdev_ioctl (struct net_device *dev, struct ifreq *rq, int cmd); /* This routine probes for a memory-mapped 3c503 board by looking for @@ -301,6 +310,7 @@ dev->open = &el2_open; dev->stop = &el2_close; + dev->do_ioctl = &netdev_ioctl; if (dev->mem_start) printk("%s: %s - %dkB RAM, 8kB shared mem window at %#6lx-%#6lx.\n", @@ -607,6 +617,71 @@ outb_p(ei_status.interface_num == 0 ? ECNTRL_THIN : ECNTRL_AUI, E33G_CNTRL); return; } + +/** + * netdev_ethtool_ioctl: Handle network interface SIOCETHTOOL ioctls + * @dev: network interface on which out-of-band action is to be performed + * @useraddr: userspace address to which data is to be read and returned + * + * Process the various commands of the SIOCETHTOOL interface. + */ + +static int netdev_ethtool_ioctl (struct net_device *dev, void *useraddr) +{ + u32 ethcmd; + + /* dev_ioctl() in ../../net/core/dev.c has already checked + capable(CAP_NET_ADMIN), so don't bother with that here. */ + + if (get_user(ethcmd, (u32 *)useraddr)) + return -EFAULT; + + switch (ethcmd) { + + case ETHTOOL_GDRVINFO: { + struct ethtool_drvinfo info = { ETHTOOL_GDRVINFO }; + strcpy (info.driver, DRV_NAME); + strcpy (info.version, DRV_VERSION); + sprintf(info.bus_info, "ISA 0x%lx", dev->base_addr); + if (copy_to_user (useraddr, &info, sizeof (info))) + return -EFAULT; + return 0; + } + + default: + break; + } + + return -EOPNOTSUPP; +} + +/** + * netdev_ioctl: Handle network interface ioctls + * @dev: network interface on which out-of-band action is to be performed + * @rq: user request data + * @cmd: command issued by user + * + * Process the various out-of-band ioctls passed to this driver. + */ + +static int netdev_ioctl (struct net_device *dev, struct ifreq *rq, int cmd) +{ + int rc = 0; + + switch (cmd) { + case SIOCETHTOOL: + rc = netdev_ethtool_ioctl(dev, (void *) rq->ifr_data); + break; + + default: + rc = -EOPNOTSUPP; + break; + } + + return rc; +} + + #ifdef MODULE #define MAX_EL2_CARDS 4 /* Max number of EL2 cards per module */ diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/net/3c505.c linux-2.5/drivers/net/3c505.c --- linux-2.5.1/drivers/net/3c505.c Sun Sep 30 19:26:06 2001 +++ linux-2.5/drivers/net/3c505.c Thu Dec 27 16:32:31 2001 @@ -35,8 +35,13 @@ * Philip Blundell <Philip.Blundell@pobox.com> * Multicard/soft configurable dma channel/rev 2 hardware support * by Christopher Collins <ccollins@pcug.org.au> + * Ethtool support (jgarzik), 11/17/2001 */ +#define DRV_NAME "3c505" +#define DRV_VERSION "1.10a" + + /* Theory of operation: * * The 3c505 is quite an intelligent board. All communication with it is done @@ -103,6 +108,9 @@ #include <linux/slab.h> #include <linux/ioport.h> #include <linux/spinlock.h> +#include <linux/ethtool.h> + +#include <asm/uaccess.h> #include <asm/bitops.h> #include <asm/io.h> #include <asm/dma.h> @@ -148,10 +156,11 @@ *********************************************************/ #ifdef ELP_DEBUG -static const int elp_debug = ELP_DEBUG; +static int elp_debug = ELP_DEBUG; #else -static const int elp_debug; +static int elp_debug; #endif +#define debug elp_debug /* * 0 = no messages (well, some) @@ -1260,6 +1269,87 @@ } } +/** + * netdev_ethtool_ioctl: Handle network interface SIOCETHTOOL ioctls + * @dev: network interface on which out-of-band action is to be performed + * @useraddr: userspace address to which data is to be read and returned + * + * Process the various commands of the SIOCETHTOOL interface. + */ + +static int netdev_ethtool_ioctl (struct net_device *dev, void *useraddr) +{ + u32 ethcmd; + + /* dev_ioctl() in ../../net/core/dev.c has already checked + capable(CAP_NET_ADMIN), so don't bother with that here. */ + + if (get_user(ethcmd, (u32 *)useraddr)) + return -EFAULT; + + switch (ethcmd) { + + case ETHTOOL_GDRVINFO: { + struct ethtool_drvinfo info = { ETHTOOL_GDRVINFO }; + strcpy (info.driver, DRV_NAME); + strcpy (info.version, DRV_VERSION); + sprintf(info.bus_info, "ISA 0x%lx", dev->base_addr); + if (copy_to_user (useraddr, &info, sizeof (info))) + return -EFAULT; + return 0; + } + + /* get message-level */ + case ETHTOOL_GMSGLVL: { + struct ethtool_value edata = {ETHTOOL_GMSGLVL}; + edata.data = debug; + if (copy_to_user(useraddr, &edata, sizeof(edata))) + return -EFAULT; + return 0; + } + /* set message-level */ + case ETHTOOL_SMSGLVL: { + struct ethtool_value edata; + if (copy_from_user(&edata, useraddr, sizeof(edata))) + return -EFAULT; + debug = edata.data; + return 0; + } + + default: + break; + } + + return -EOPNOTSUPP; +} + +/** + * netdev_ioctl: Handle network interface ioctls + * @dev: network interface on which out-of-band action is to be performed + * @rq: user request data + * @cmd: command issued by user + * + * Process the various out-of-band ioctls passed to this driver. + */ + +static int netdev_ioctl (struct net_device *dev, struct ifreq *rq, int cmd) +{ + int rc = 0; + + switch (cmd) { + case SIOCETHTOOL: + rc = netdev_ethtool_ioctl(dev, (void *) rq->ifr_data); + break; + + default: + rc = -EOPNOTSUPP; + break; + } + + return rc; +} + + /****************************************************** * * initialise Etherlink Plus board @@ -1280,6 +1370,7 @@ dev->tx_timeout = elp_timeout; /* local */ dev->watchdog_timeo = 10*HZ; dev->set_multicast_list = elp_set_mc_list; /* local */ + dev->do_ioctl = netdev_ioctl; /* local */ /* Setup the generic properties */ ether_setup(dev); diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/net/3c507.c linux-2.5/drivers/net/3c507.c --- linux-2.5.1/drivers/net/3c507.c Sun Sep 30 19:26:08 2001 +++ linux-2.5/drivers/net/3c507.c Thu Dec 27 16:32:31 2001 @@ -25,8 +25,12 @@ The statistics need to be updated correctly. */ +#define DRV_NAME "3c507" +#define DRV_VERSION "1.10a" +#define DRV_RELDATE "11/17/2001" + static const char version[] = - "3c507.c:v1.10 9/23/94 Donald Becker (becker@cesdis.gsfc.nasa.gov)\n"; + DRV_NAME ".c:v" DRV_VERSION " " DRV_RELDATE " Donald Becker (becker@scyld.com)\n"; #include <linux/module.h> @@ -52,6 +56,9 @@ #include <linux/in.h> #include <linux/string.h> #include <linux/spinlock.h> +#include <linux/ethtool.h> + +#include <asm/uaccess.h> #include <asm/system.h> #include <asm/bitops.h> #include <asm/io.h> @@ -70,6 +77,8 @@ #define NET_DEBUG 1 #endif static unsigned int net_debug = NET_DEBUG; +#define debug net_debug + /* A zero-terminated list of common I/O addresses to be probed. */ static unsigned int netcard_portlist[] __initdata = @@ -296,6 +305,7 @@ static void hardware_send_packet(struct net_device *dev, void *buf, short length); static void init_82586_mem(struct net_device *dev); +static int netdev_ioctl (struct net_device *dev, struct ifreq *rq, int cmd); /* Check for a network adaptor of this type, and return '0' iff one exists. @@ -427,6 +437,7 @@ dev->get_stats = el16_get_stats; dev->tx_timeout = el16_tx_timeout; dev->watchdog_timeo = TX_TIMEOUT; + dev->do_ioctl = netdev_ioctl; ether_setup(dev); /* Generic ethernet behaviour */ @@ -864,6 +875,88 @@ lp->rx_head = rx_head; lp->rx_tail = rx_tail; } + +/** + * netdev_ethtool_ioctl: Handle network interface SIOCETHTOOL ioctls + * @dev: network interface on which out-of-band action is to be performed + * @useraddr: userspace address to which data is to be read and returned + * + * Process the various commands of the SIOCETHTOOL interface. + */ + +static int netdev_ethtool_ioctl (struct net_device *dev, void *useraddr) +{ + u32 ethcmd; + + /* dev_ioctl() in ../../net/core/dev.c has already checked + capable(CAP_NET_ADMIN), so don't bother with that here. */ + + if (get_user(ethcmd, (u32 *)useraddr)) + return -EFAULT; + + switch (ethcmd) { + + case ETHTOOL_GDRVINFO: { + struct ethtool_drvinfo info = { ETHTOOL_GDRVINFO }; + strcpy (info.driver, DRV_NAME); + strcpy (info.version, DRV_VERSION); + sprintf(info.bus_info, "ISA 0x%lx", dev->base_addr); + if (copy_to_user (useraddr, &info, sizeof (info))) + return -EFAULT; + return 0; + } + + /* get message-level */ + case ETHTOOL_GMSGLVL: { + struct ethtool_value edata = {ETHTOOL_GMSGLVL}; + edata.data = debug; + if (copy_to_user(useraddr, &edata, sizeof(edata))) + return -EFAULT; + return 0; + } + /* set message-level */ + case ETHTOOL_SMSGLVL: { + struct ethtool_value edata; + if (copy_from_user(&edata, useraddr, sizeof(edata))) + return -EFAULT; + debug = edata.data; + return 0; + } + + default: + break; + } + + return -EOPNOTSUPP; +} + +/** + * netdev_ioctl: Handle network interface ioctls + * @dev: network interface on which out-of-band action is to be performed + * @rq: user request data + * @cmd: command issued by user + * + * Process the various out-of-band ioctls passed to this driver. + */ + +static int netdev_ioctl (struct net_device *dev, struct ifreq *rq, int cmd) +{ + int rc = 0; + + switch (cmd) { + case SIOCETHTOOL: + rc = netdev_ethtool_ioctl(dev, (void *) rq->ifr_data); + break; + + default: + rc = -EOPNOTSUPP; + break; + } + + return rc; +} + + #ifdef MODULE static struct net_device dev_3c507; static int io = 0x300; diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/net/3c509.c linux-2.5/drivers/net/3c509.c --- linux-2.5.1/drivers/net/3c509.c Sun Nov 25 17:43:42 2001 +++ linux-2.5/drivers/net/3c509.c Thu Dec 27 16:32:31 2001 @@ -43,8 +43,14 @@ v1.18 12Mar2001 Andrew Morton <andrewm@uow.edu.au> - Avoid bogus detect of 3c590's (Andrzej Krzysztofowicz) - Reviewed against 1.18 from scyld.com + v1.18 17Nov2001 Jeff Garzik <jgarzik@mandrakesoft.com> + - ethtool support */ +#define DRV_NAME "3c509" +#define DRV_VERSION "1.18a" +#define DRV_RELDATE "17Nov2001" + /* A few values that may be tweaked. */ /* Time in jiffies before concluding the transmitter is hung. */ @@ -70,12 +76,14 @@ #include <linux/skbuff.h> #include <linux/delay.h> /* for udelay() */ #include <linux/spinlock.h> +#include <linux/ethtool.h> +#include <asm/uaccess.h> #include <asm/bitops.h> #include <asm/io.h> #include <asm/irq.h> -static char versionA[] __initdata = "3c509.c:1.18 12Mar2001 becker@scyld.com\n"; +static char versionA[] __initdata = DRV_NAME ".c:" DRV_VERSION " " DRV_RELDATE "becker@scyld.com\n"; static char versionB[] __initdata = "http://www.scyld.com/network/3c509.html\n"; #ifdef EL3_DEBUG @@ -84,6 +92,7 @@ static int el3_debug = 2; #endif + /* To minimize the size of the driver source I only define operating constants if they are used several times. You'll need the manual anyway if you want to understand driver details. */ @@ -158,6 +167,7 @@ static int el3_close(struct net_device *dev); static void set_multicast_list(struct net_device *dev); static void el3_tx_timeout (struct net_device *dev); +static int netdev_ioctl (struct net_device *dev, struct ifreq *rq, int cmd); #ifdef CONFIG_MCA struct el3_mca_adapters_struct { @@ -513,6 +523,7 @@ dev->set_multicast_list = &set_multicast_list; dev->tx_timeout = el3_tx_timeout; dev->watchdog_timeo = TX_TIMEOUT; + dev->do_ioctl = netdev_ioctl; /* Fill in the generic fields of the device structure. */ ether_setup(dev); @@ -1003,6 +1014,85 @@ return 0; } +/** + * netdev_ethtool_ioctl: Handle network interface SIOCETHTOOL ioctls + * @dev: network interface on which out-of-band action is to be performed + * @useraddr: userspace address to which data is to be read and returned + * + * Process the various commands of the SIOCETHTOOL interface. + */ + +static int netdev_ethtool_ioctl (struct net_device *dev, void *useraddr) +{ + u32 ethcmd; + + /* dev_ioctl() in ../../net/core/dev.c has already checked + capable(CAP_NET_ADMIN), so don't bother with that here. */ + + if (get_user(ethcmd, (u32 *)useraddr)) + return -EFAULT; + + switch (ethcmd) { + + case ETHTOOL_GDRVINFO: { + struct ethtool_drvinfo info = { ETHTOOL_GDRVINFO }; + strcpy (info.driver, DRV_NAME); + strcpy (info.version, DRV_VERSION); + if (copy_to_user (useraddr, &info, sizeof (info))) + return -EFAULT; + return 0; + } + + /* get message-level */ + case ETHTOOL_GMSGLVL: { + struct ethtool_value edata = {ETHTOOL_GMSGLVL}; + edata.data = el3_debug; + if (copy_to_user(useraddr, &edata, sizeof(edata))) + return -EFAULT; + return 0; + } + /* set message-level */ + case ETHTOOL_SMSGLVL: { + struct ethtool_value edata; + if (copy_from_user(&edata, useraddr, sizeof(edata))) + return -EFAULT; + el3_debug = edata.data; + return 0; + } + + default: + break; + } + + return -EOPNOTSUPP; +} + +/** + * netdev_ioctl: Handle network interface ioctls + * @dev: network interface on which out-of-band action is to be performed + * @rq: user request data + * @cmd: command issued by user + * + * Process the various out-of-band ioctls passed to this driver. + */ + +static int netdev_ioctl (struct net_device *dev, struct ifreq *rq, int cmd) +{ + int rc = 0; + + switch (cmd) { + case SIOCETHTOOL: + rc = netdev_ethtool_ioctl(dev, (void *) rq->ifr_data); + break; + + default: + rc = -EOPNOTSUPP; + break; + } + + return rc; +} + #ifdef MODULE /* Parameters that may be passed into the module. */ static int debug = -1; diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/net/3c515.c linux-2.5/drivers/net/3c515.c --- linux-2.5.1/drivers/net/3c515.c Sun Nov 25 17:43:42 2001 +++ linux-2.5/drivers/net/3c515.c Thu Dec 27 16:32:31 2001 @@ -16,9 +16,17 @@ 2/2/00- Added support for kernel-level ISAPnP by Stephen Frost <sfrost@snowman.net> and Alessandro Zummo Cleaned up for 2.3.x/softnet by Jeff Garzik and Alan Cox. + + 11/17/2001 - Added ethtool support (jgarzik) + */ -static char *version = "3c515.c:v0.99-sn 2000/02/12 becker@cesdis.gsfc.nasa.gov and others\n"; +#define DRV_NAME "3c515" +#define DRV_VERSION "0.99t" +#define DRV_RELDATE "17-Nov-2001" + +static char *version = +DRV_NAME ".c:v" DRV_VERSION " " DRV_RELDATE " becker@scyld.com and others\n"; #define CORKSCREW 1 @@ -63,6 +71,9 @@ #include <linux/slab.h> #include <linux/interrupt.h> #include <linux/timer.h> +#include <linux/ethtool.h> + +#include <asm/uaccess.h> #include <asm/bitops.h> #include <asm/io.h> #include <asm/dma.h> @@ -393,6 +404,7 @@ static void update_stats(int addr, struct net_device *dev); static struct net_device_stats *corkscrew_get_stats(struct net_device *dev); static void set_rx_mode(struct net_device *dev); +static int netdev_ioctl (struct net_device *dev, struct ifreq *rq, int cmd); /* @@ -721,6 +733,7 @@ dev->stop = &corkscrew_close; dev->get_stats = &corkscrew_get_stats; dev->set_multicast_list = &set_rx_mode; + dev->do_ioctl = netdev_ioctl; return 0; } @@ -1591,6 +1604,87 @@ outw(new_mode, ioaddr + EL3_CMD); } + +/** + * netdev_ethtool_ioctl: Handle network interface SIOCETHTOOL ioctls + * @dev: network interface on which out-of-band action is to be performed + * @useraddr: userspace address to which data is to be read and returned + * + * Process the various commands of the SIOCETHTOOL interface. + */ + +static int netdev_ethtool_ioctl (struct net_device *dev, void *useraddr) +{ + u32 ethcmd; + + /* dev_ioctl() in ../../net/core/dev.c has already checked + capable(CAP_NET_ADMIN), so don't bother with that here. */ + + if (get_user(ethcmd, (u32 *)useraddr)) + return -EFAULT; + + switch (ethcmd) { + + case ETHTOOL_GDRVINFO: { + struct ethtool_drvinfo info = { ETHTOOL_GDRVINFO }; + strcpy (info.driver, DRV_NAME); + strcpy (info.version, DRV_VERSION); + sprintf(info.bus_info, "ISA 0x%lx", dev->base_addr); + if (copy_to_user (useraddr, &info, sizeof (info))) + return -EFAULT; + return 0; + } + + /* get message-level */ + case ETHTOOL_GMSGLVL: { + struct ethtool_value edata = {ETHTOOL_GMSGLVL}; + edata.data = corkscrew_debug; + if (copy_to_user(useraddr, &edata, sizeof(edata))) + return -EFAULT; + return 0; + } + /* set message-level */ + case ETHTOOL_SMSGLVL: { + struct ethtool_value edata; + if (copy_from_user(&edata, useraddr, sizeof(edata))) + return -EFAULT; + corkscrew_debug = edata.data; + return 0; + } + + default: + break; + } + + return -EOPNOTSUPP; +} + +/** + * netdev_ioctl: Handle network interface ioctls + * @dev: network interface on which out-of-band action is to be performed + * @rq: user request data + * @cmd: command issued by user + * + * Process the various out-of-band ioctls passed to this driver. + */ + +static int netdev_ioctl (struct net_device *dev, struct ifreq *rq, int cmd) +{ + int rc = 0; + + switch (cmd) { + case SIOCETHTOOL: + rc = netdev_ethtool_ioctl(dev, (void *) rq->ifr_data); + break; + + default: + rc = -EOPNOTSUPP; + break; + } + + return rc; +} + #ifdef MODULE void cleanup_module(void) diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/net/3c523.c linux-2.5/drivers/net/3c523.c --- linux-2.5.1/drivers/net/3c523.c Wed Jun 20 18:10:53 2001 +++ linux-2.5/drivers/net/3c523.c Thu Dec 27 16:32:31 2001 @@ -81,10 +81,15 @@ added option to disable multicast as is causes problems Ganesh Sittampalam <ganesh.sittampalam@magdalen.oxford.ac.uk> Stuart Adamson <stuart.adamson@compsoc.net> + Nov 2001 + added support for ethtool (jgarzik) $Header: /fsys2/home/chrisb/linux-1.3.59-MCA/drivers/net/RCS/3c523.c,v 1.1 1996/02/05 01:53:46 chrisb Exp chrisb $ */ +#define DRV_NAME "3c523" +#define DRV_VERSION "17-Nov-2001" + #include <linux/module.h> #include <linux/kernel.h> #include <linux/sched.h> @@ -95,6 +100,9 @@ #include <linux/interrupt.h> #include <linux/delay.h> #include <linux/mca.h> +#include <linux/ethtool.h> + +#include <asm/uaccess.h> #include <asm/processor.h> #include <asm/bitops.h> #include <asm/io.h> @@ -182,6 +190,7 @@ #ifdef ELMC_MULTICAST static void set_multicast_list(struct net_device *dev); #endif +static int netdev_ioctl (struct net_device *dev, struct ifreq *rq, int cmd); /* helper-functions */ static int init586(struct net_device *dev); @@ -563,7 +572,8 @@ #else dev->set_multicast_list = NULL; #endif - + dev->do_ioctl = netdev_ioctl; + ether_setup(dev); /* note that we haven't actually requested the IRQ from the kernel. @@ -1214,6 +1224,69 @@ } #endif +/** + * netdev_ethtool_ioctl: Handle network interface SIOCETHTOOL ioctls + * @dev: network interface on which out-of-band action is to be performed + * @useraddr: userspace address to which data is to be read and returned + * + * Process the various commands of the SIOCETHTOOL interface. + */ + +static int netdev_ethtool_ioctl (struct net_device *dev, void *useraddr) +{ + u32 ethcmd; + + /* dev_ioctl() in ../../net/core/dev.c has already checked + capable(CAP_NET_ADMIN), so don't bother with that here. */ + + if (get_user(ethcmd, (u32 *)useraddr)) + return -EFAULT; + + switch (ethcmd) { + + case ETHTOOL_GDRVINFO: { + struct ethtool_drvinfo info = { ETHTOOL_GDRVINFO }; + strcpy (info.driver, DRV_NAME); + strcpy (info.version, DRV_VERSION); + sprintf(info.bus_info, "MCA 0x%lx", dev->base_addr); + if (copy_to_user (useraddr, &info, sizeof (info))) + return -EFAULT; + return 0; + } + + default: + break; + } + + return -EOPNOTSUPP; +} + +/** + * netdev_ioctl: Handle network interface ioctls + * @dev: network interface on which out-of-band action is to be performed + * @rq: user request data + * @cmd: command issued by user + * + * Process the various out-of-band ioctls passed to this driver. + */ + +static int netdev_ioctl (struct net_device *dev, struct ifreq *rq, int cmd) +{ + int rc = 0; + + switch (cmd) { + case SIOCETHTOOL: + rc = netdev_ethtool_ioctl(dev, (void *) rq->ifr_data); + break; + + default: + rc = -EOPNOTSUPP; + break; + } + + return rc; +} + /*************************************************************************/ #ifdef MODULE diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/net/3c527.c linux-2.5/drivers/net/3c527.c --- linux-2.5.1/drivers/net/3c527.c Thu Apr 12 19:15:25 2001 +++ linux-2.5/drivers/net/3c527.c Thu Dec 27 16:32:31 2001 @@ -16,8 +16,12 @@ * */ +#define DRV_NAME "3c527" +#define DRV_VERSION "0.6a" +#define DRV_RELDATE "2001/11/17" + static const char *version = - "3c527.c:v0.6 2001/03/03 Richard Proctor (rnp@netlink.co.nz)\n"; +DRV_NAME ".c:v" DRV_VERSION " " DRV_RELDATE " Richard Proctor (rnp@netlink.co.nz)\n"; /** * DOC: Traps for the unwary @@ -90,6 +94,9 @@ #include <linux/in.h> #include <linux/slab.h> #include <linux/string.h> +#include <linux/ethtool.h> + +#include <asm/uaccess.h> #include <asm/system.h> #include <asm/bitops.h> #include <asm/io.h> @@ -108,7 +115,7 @@ * The name of the card. Is used for messages and in the requests for * io regions, irqs and dma channels */ -static const char* cardname = "3c527"; +static const char* cardname = DRV_NAME; /* use 0 for production, 1 for verification, >2 for debug */ #ifndef NET_DEBUG @@ -213,6 +220,7 @@ static struct net_device_stats *mc32_get_stats(struct net_device *dev); static void mc32_set_multicast_list(struct net_device *dev); static void mc32_reset_multicast_list(struct net_device *dev); +static int netdev_ioctl (struct net_device *dev, struct ifreq *rq, int cmd); /** * mc32_probe - Search for supported boards @@ -502,7 +510,7 @@ dev->set_multicast_list = mc32_set_multicast_list; dev->tx_timeout = mc32_timeout; dev->watchdog_timeo = HZ*5; /* Board does all the work */ - + dev->do_ioctl = netdev_ioctl; lp->xceiver_state = HALTED; @@ -1644,6 +1652,86 @@ do_mc32_set_multicast_list(dev,1); } +/** + * netdev_ethtool_ioctl: Handle network interface SIOCETHTOOL ioctls + * @dev: network interface on which out-of-band action is to be performed + * @useraddr: userspace address to which data is to be read and returned + * + * Process the various commands of the SIOCETHTOOL interface. + */ + +static int netdev_ethtool_ioctl (struct net_device *dev, void *useraddr) +{ + u32 ethcmd; + + /* dev_ioctl() in ../../net/core/dev.c has already checked + capable(CAP_NET_ADMIN), so don't bother with that here. */ + + if (get_user(ethcmd, (u32 *)useraddr)) + return -EFAULT; + + switch (ethcmd) { + + case ETHTOOL_GDRVINFO: { + struct ethtool_drvinfo info = { ETHTOOL_GDRVINFO }; + strcpy (info.driver, DRV_NAME); + strcpy (info.version, DRV_VERSION); + sprintf(info.bus_info, "MCA 0x%lx", dev->base_addr); + if (copy_to_user (useraddr, &info, sizeof (info))) + return -EFAULT; + return 0; + } + + /* get message-level */ + case ETHTOOL_GMSGLVL: { + struct ethtool_value edata = {ETHTOOL_GMSGLVL}; + edata.data = mc32_debug; + if (copy_to_user(useraddr, &edata, sizeof(edata))) + return -EFAULT; + return 0; + } + /* set message-level */ + case ETHTOOL_SMSGLVL: { + struct ethtool_value edata; + if (copy_from_user(&edata, useraddr, sizeof(edata))) + return -EFAULT; + mc32_debug = edata.data; + return 0; + } + + default: + break; + } + + return -EOPNOTSUPP; +} + +/** + * netdev_ioctl: Handle network interface ioctls + * @dev: network interface on which out-of-band action is to be performed + * @rq: user request data + * @cmd: command issued by user + * + * Process the various out-of-band ioctls passed to this driver. + */ + +static int netdev_ioctl (struct net_device *dev, struct ifreq *rq, int cmd) +{ + int rc = 0; + + switch (cmd) { + case SIOCETHTOOL: + rc = netdev_ethtool_ioctl(dev, (void *) rq->ifr_data); + break; + + default: + rc = -EOPNOTSUPP; + break; + } + + return rc; +} + #ifdef MODULE static struct net_device this_device; diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/net/3c59x.c linux-2.5/drivers/net/3c59x.c --- linux-2.5.1/drivers/net/3c59x.c Fri Nov 9 21:41:42 2001 +++ linux-2.5/drivers/net/3c59x.c Thu Dec 13 16:32:36 2001 @@ -2919,7 +2919,7 @@ static struct pci_driver vortex_driver = { name: "3c59x", probe: vortex_init_one, - remove: vortex_remove_one, + remove: __devexit_p(vortex_remove_one), id_table: vortex_pci_tbl, #ifdef CONFIG_PM suspend: vortex_suspend, diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/net/8139cp.c linux-2.5/drivers/net/8139cp.c --- linux-2.5.1/drivers/net/8139cp.c Mon Nov 19 23:19:42 2001 +++ linux-2.5/drivers/net/8139cp.c Thu Dec 13 16:32:36 2001 @@ -1313,7 +1313,7 @@ name: DRV_NAME, id_table: cp_pci_tbl, probe: cp_init_one, - remove: cp_remove_one, + remove: __devexit_p(cp_remove_one), }; static int __init cp_init (void) diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/net/8139too.c linux-2.5/drivers/net/8139too.c --- linux-2.5.1/drivers/net/8139too.c Sat Nov 24 19:26:37 2001 +++ linux-2.5/drivers/net/8139too.c Thu Dec 13 16:32:36 2001 @@ -1636,23 +1636,24 @@ struct rtl8139_private *tp = dev->priv; void *ioaddr = tp->mmio_addr; unsigned int entry; + unsigned int len = skb->len; /* Calculate the next Tx descriptor entry. */ entry = tp->cur_tx % NUM_TX_DESC; - if (likely(skb->len < TX_BUF_SIZE)) { + if (likely(len < TX_BUF_SIZE)) { skb_copy_and_csum_dev(skb, tp->tx_buf[entry]); dev_kfree_skb(skb); } else { dev_kfree_skb(skb); tp->stats.tx_dropped++; return 0; - } + } /* Note: the chip doesn't have auto-pad! */ spin_lock_irq(&tp->lock); RTL_W32_F (TxStatus0 + (entry * sizeof (u32)), - tp->tx_flag | (skb->len >= ETH_ZLEN ? skb->len : ETH_ZLEN)); + tp->tx_flag | max(len, (unsigned int)ETH_ZLEN)); dev->trans_start = jiffies; @@ -1663,8 +1664,8 @@ netif_stop_queue (dev); spin_unlock_irq(&tp->lock); - DPRINTK ("%s: Queued Tx packet at %p size %u to slot %d.\n", - dev->name, skb->data, skb->len, entry); + DPRINTK ("%s: Queued Tx packet size %u to slot %d.\n", + dev->name, len, entry); return 0; } @@ -2493,7 +2494,7 @@ name: DRV_NAME, id_table: rtl8139_pci_tbl, probe: rtl8139_init_one, - remove: rtl8139_remove_one, + remove: __devexit_p(rtl8139_remove_one), #ifdef CONFIG_PM suspend: rtl8139_suspend, resume: rtl8139_resume, diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/net/Config.in linux-2.5/drivers/net/Config.in --- linux-2.5.1/drivers/net/Config.in Mon Dec 10 19:17:40 2001 +++ linux-2.5/drivers/net/Config.in Thu Dec 27 16:32:31 2001 @@ -10,9 +10,7 @@ tristate 'EQL (serial line load balancing) support' CONFIG_EQUALIZER tristate 'Universal TUN/TAP device driver support' CONFIG_TUN if [ "$CONFIG_EXPERIMENTAL" = "y" ]; then - if [ "$CONFIG_NETLINK" = "y" ]; then - tristate 'Ethertap network tap (OBSOLETE)' CONFIG_ETHERTAP - fi + tristate 'Ethertap network tap (OBSOLETE)' CONFIG_ETHERTAP fi if [ "$CONFIG_ISAPNP" = "y" -o "$CONFIG_ISAPNP" = "m" ]; then @@ -36,11 +34,15 @@ if [ "$CONFIG_PPC" = "y" ]; then dep_tristate ' MACE (Power Mac ethernet) support' CONFIG_MACE $CONFIG_ALL_PPC if [ "$CONFIG_MACE" != "n" ]; then - bool ' Use AAUI port instead of TP by default' CONFIG_MACE_AAUI_PORT + bool ' Use AAUI port instead of TP by default' CONFIG_MACE_AAUI_PORT fi dep_tristate ' BMAC (G3 ethernet) support' CONFIG_BMAC $CONFIG_ALL_PPC dep_tristate ' GMAC (G4/iBook ethernet) support' CONFIG_GMAC $CONFIG_ALL_PPC - tristate ' National DP83902AV (Oak ethernet) support' CONFIG_OAKNET + if [ "$CONFIG_4xx" = "y" ]; then + if [ "$CONFIG_STB03xxx" = "y" -o "$CONFIG_403GCX" = "y" ]; then + tristate ' National DP83902AV (Oak ethernet) support' CONFIG_OAKNET + fi + fi fi if [ "$CONFIG_ZORRO" = "y" ]; then tristate ' Ariadne support' CONFIG_ARIADNE diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/net/acenic.c linux-2.5/drivers/net/acenic.c --- linux-2.5.1/drivers/net/acenic.c Mon Nov 19 23:19:42 2001 +++ linux-2.5/drivers/net/acenic.c Thu Dec 27 16:32:31 2001 @@ -208,6 +208,8 @@ (((u64)(mask) & 0xffffffff00000000) == 0 ? 0 : -EIO) #define pci_dma_supported(dev, mask) \ (((u64)(mask) & 0xffffffff00000000) == 0 ? 1 : 0) +#define DECLARE_PCI_UNMAP_ADDR(ADDR_NAME) +#define DECLARE_PCI_UNMAP_LEN(LEN_NAME) #elif (LINUX_VERSION_CODE < 0x02040d) @@ -231,6 +233,8 @@ } #define pci_unmap_page(cookie, dma_addr, size, dir) \ pci_unmap_single(cookie, dma_addr, size, dir) +#define DECLARE_PCI_UNMAP_ADDR(ADDR_NAME) +#define DECLARE_PCI_UNMAP_LEN(LEN_NAME) #endif @@ -839,9 +843,11 @@ struct sk_buff *skb = ap->skb->rx_std_skbuff[i].skb; if (skb) { + struct ring_info *ringp; dma_addr_t mapping; - mapping = ap->skb->rx_std_skbuff[i].mapping; + ringp = &ap->skb->rx_std_skbuff[i]; + mapping = PCI_UNMAP_ADDR(ringp, mapping); pci_unmap_page(ap->pdev, mapping, ACE_STD_BUFSIZE - (2 + 16), PCI_DMA_FROMDEVICE); @@ -856,9 +862,11 @@ struct sk_buff *skb = ap->skb->rx_mini_skbuff[i].skb; if (skb) { + struct ring_info *ringp; dma_addr_t mapping; - mapping = ap->skb->rx_mini_skbuff[i].mapping; + ringp = &ap->skb->rx_mini_skbuff[i]; + mapping = PCI_UNMAP_ADDR(ringp,mapping); pci_unmap_page(ap->pdev, mapping, ACE_MINI_BUFSIZE - (2 + 16), PCI_DMA_FROMDEVICE); @@ -872,9 +880,11 @@ for (i = 0; i < RX_JUMBO_RING_ENTRIES; i++) { struct sk_buff *skb = ap->skb->rx_jumbo_skbuff[i].skb; if (skb) { + struct ring_info *ringp; dma_addr_t mapping; - mapping = ap->skb->rx_jumbo_skbuff[i].mapping; + ringp = &ap->skb->rx_jumbo_skbuff[i]; + mapping = PCI_UNMAP_ADDR(ringp, mapping); pci_unmap_page(ap->pdev, mapping, ACE_JUMBO_BUFSIZE - (2 + 16), PCI_DMA_FROMDEVICE); @@ -1832,7 +1842,8 @@ ACE_STD_BUFSIZE - (2 + 16), PCI_DMA_FROMDEVICE); ap->skb->rx_std_skbuff[idx].skb = skb; - ap->skb->rx_std_skbuff[idx].mapping = mapping; + PCI_UNMAP_ADDR_SET(&ap->skb->rx_std_skbuff[idx], + mapping, mapping); rd = &ap->rx_std_ring[idx]; set_aceaddr(&rd->addr, mapping); @@ -1897,7 +1908,8 @@ ACE_MINI_BUFSIZE - (2 + 16), PCI_DMA_FROMDEVICE); ap->skb->rx_mini_skbuff[idx].skb = skb; - ap->skb->rx_mini_skbuff[idx].mapping = mapping; + PCI_UNMAP_ADDR_SET(&ap->skb->rx_mini_skbuff[idx], + mapping, mapping); rd = &ap->rx_mini_ring[idx]; set_aceaddr(&rd->addr, mapping); @@ -1957,7 +1969,8 @@ ACE_JUMBO_BUFSIZE - (2 + 16), PCI_DMA_FROMDEVICE); ap->skb->rx_jumbo_skbuff[idx].skb = skb; - ap->skb->rx_jumbo_skbuff[idx].mapping = mapping; + PCI_UNMAP_ADDR_SET(&ap->skb->rx_jumbo_skbuff[idx], + mapping, mapping); rd = &ap->rx_jumbo_ring[idx]; set_aceaddr(&rd->addr, mapping); @@ -2163,7 +2176,9 @@ skb = rip->skb; rip->skb = NULL; - pci_unmap_page(ap->pdev, rip->mapping, mapsize, + pci_unmap_page(ap->pdev, + PCI_UNMAP_ADDR(rip, mapping), + mapsize, PCI_DMA_FROMDEVICE); skb_put(skb, retdesc->size); @@ -2229,12 +2244,13 @@ info = ap->skb->tx_skbuff + idx; skb = info->skb; - mapping = info->mapping; + mapping = PCI_UNMAP_ADDR(info, mapping); if (mapping) { - pci_unmap_page(ap->pdev, mapping, info->maplen, + pci_unmap_page(ap->pdev, mapping, + PCI_UNMAP_LEN(info, maplen), PCI_DMA_TODEVICE); - info->mapping = 0; + PCI_UNMAP_ADDR_SET(info, mapping, 0); } if (skb) { @@ -2518,13 +2534,14 @@ info = ap->skb->tx_skbuff + i; skb = info->skb; - mapping = info->mapping; + mapping = PCI_UNMAP_ADDR(info, mapping); if (mapping) { memset(ap->tx_ring + i, 0, sizeof(struct tx_desc)); - pci_unmap_page(ap->pdev, mapping, info->maplen, + pci_unmap_page(ap->pdev, mapping, + PCI_UNMAP_LEN(info, maplen), PCI_DMA_TODEVICE); - info->mapping = 0; + PCI_UNMAP_ADDR_SET(info, mapping, 0); } if (skb) { dev_kfree_skb(skb); @@ -2545,7 +2562,6 @@ return 0; } - static inline dma_addr_t ace_map_tx_skb(struct ace_private *ap, struct sk_buff *skb, struct sk_buff *tail, u32 idx) @@ -2559,8 +2575,8 @@ info = ap->skb->tx_skbuff + idx; info->skb = tail; - info->mapping = mapping; - info->maplen = skb->len; + PCI_UNMAP_ADDR_SET(info, mapping, mapping); + PCI_UNMAP_LEN_SET(info, maplen, skb->len); return mapping; } @@ -2661,8 +2677,8 @@ } else { info->skb = NULL; } - info->mapping = mapping; - info->maplen = frag->size; + PCI_UNMAP_ADDR_SET(info, mapping, mapping); + PCI_UNMAP_LEN_SET(info, maplen, frag->size); ace_load_tx_bd(desc, mapping, flagsize); } } diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/net/acenic.h linux-2.5/drivers/net/acenic.h --- linux-2.5.1/drivers/net/acenic.h Mon Nov 19 23:19:42 2001 +++ linux-2.5/drivers/net/acenic.h Thu Dec 27 16:32:31 2001 @@ -585,7 +585,7 @@ struct ring_info { struct sk_buff *skb; - dma_addr_t mapping; + DECLARE_PCI_UNMAP_ADDR(mapping) }; @@ -596,8 +596,8 @@ */ struct tx_ring_info { struct sk_buff *skb; - dma_addr_t mapping; - int maplen; + DECLARE_PCI_UNMAP_ADDR(mapping) + DECLARE_PCI_UNMAP_LEN(maplen) }; diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/net/arcnet/com20020-pci.c linux-2.5/drivers/net/arcnet/com20020-pci.c --- linux-2.5.1/drivers/net/arcnet/com20020-pci.c Fri Nov 9 21:41:42 2001 +++ linux-2.5/drivers/net/arcnet/com20020-pci.c Thu Dec 13 16:32:36 2001 @@ -160,7 +160,7 @@ name: "com20020", id_table: com20020pci_id_table, probe: com20020pci_probe, - remove: com20020pci_remove + remove: __devexit_p(com20020pci_remove), }; static int __init com20020pci_init(void) diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/net/bmac.c linux-2.5/drivers/net/bmac.c --- linux-2.5.1/drivers/net/bmac.c Wed Nov 14 23:16:31 2001 +++ linux-2.5/drivers/net/bmac.c Thu Dec 27 16:32:31 2001 @@ -22,7 +22,8 @@ #include <asm/io.h> #include <asm/page.h> #include <asm/pgtable.h> -#include <asm/feature.h> +#include <asm/machdep.h> +#include <asm/pmac_feature.h> #ifdef CONFIG_PMAC_PBOOK #include <linux/adb.h> #include <linux/pmu.h> @@ -155,7 +156,7 @@ static void bmac_start_chip(struct net_device *dev); static void bmac_init_chip(struct net_device *dev); static void bmac_init_registers(struct net_device *dev); -static void bmac_reset_chip(struct net_device *dev); +static void bmac_enable_and_reset_chip(struct net_device *dev); static int bmac_set_address(struct net_device *dev, void *addr); static void bmac_misc_intr(int irq, void *dev_id, struct pt_regs *regs); static void bmac_txdma_intr(int irq, void *dev_id, struct pt_regs *regs); @@ -229,21 +230,18 @@ } static void -bmac_reset_chip(struct net_device *dev) +bmac_enable_and_reset_chip(struct net_device *dev) { struct bmac_data *bp = (struct bmac_data *) dev->priv; volatile struct dbdma_regs *rd = bp->rx_dma; volatile struct dbdma_regs *td = bp->tx_dma; - dbdma_reset(rd); - dbdma_reset(td); + if (rd) + dbdma_reset(rd); + if (td) + dbdma_reset(td); - feature_set(bp->node, FEATURE_BMac_IO_enable); - udelay(10000); - feature_set(bp->node, FEATURE_BMac_reset); - udelay(10000); - feature_clear(bp->node, FEATURE_BMac_reset); - udelay(10000); + pmac_call_feature(PMAC_FTR_BMAC_ENABLE, bp->node, 0, 1); } #define MIFDELAY udelay(10) @@ -522,10 +520,7 @@ } } } - feature_set(bp->node, FEATURE_BMac_reset); - mdelay(10); - feature_clear(bp->node, FEATURE_BMac_IO_enable); - mdelay(10); + pmac_call_feature(PMAC_FTR_BMAC_ENABLE, bp->node, 0, 0); break; case PBOOK_WAKE: /* see if this is enough */ @@ -1267,7 +1262,7 @@ unsigned char *data; save_flags(flags); cli(); - bmac_reset_chip(dev); + bmac_enable_and_reset_chip(dev); bmac_init_tx_ring(bp); bmac_init_rx_ring(bp); bmac_init_chip(dev); @@ -1350,14 +1345,30 @@ bmac->full_name); return; } + bp = (struct bmac_data *) dev->priv; SET_MODULE_OWNER(dev); + bp->node = bmac; + if (!request_OF_resource(bmac, 0, " (bmac)")) { + printk(KERN_ERR "BMAC: can't request IO resource !\n"); + goto err_out; + } + if (!request_OF_resource(bmac, 1, " (bmac tx dma)")) { + printk(KERN_ERR "BMAC: can't request TX DMA resource !\n"); + goto err_out; + } + + if (!request_OF_resource(bmac, 2, " (bmac rx dma)")) { + printk(KERN_ERR "BMAC: can't request RX DMA resource !\n"); + goto err_out; + } dev->base_addr = (unsigned long) ioremap(bmac->addrs[0].address, bmac->addrs[0].size); if (!dev->base_addr) goto err_out; dev->irq = bmac->intrs[0].line; + bmac_enable_and_reset_chip(dev); bmwrite(dev, INTDISABLE, DisableAll); printk(KERN_INFO "%s: BMAC%s at", dev->name, (is_bmac_plus? "+": "")); @@ -1369,6 +1380,10 @@ XXDEBUG((", base_addr=%#0lx", dev->base_addr)); printk("\n"); + /* Enable chip without interrupts for now */ + bmac_enable_and_reset_chip(dev); + bmwrite(dev, INTDISABLE, DisableAll); + dev->open = bmac_open; dev->stop = bmac_close; dev->hard_start_xmit = bmac_output; @@ -1380,7 +1395,6 @@ if (bmac_verify_checksum(dev) != 0) goto err_out_iounmap; - bp = (struct bmac_data *) dev->priv; bp->is_bmac_plus = is_bmac_plus; bp->tx_dma = (volatile struct dbdma_regs *) ioremap(bmac->addrs[1].address, bmac->addrs[1].size); @@ -1399,7 +1413,6 @@ bp->queue = (struct sk_buff_head *)(bp->rx_cmds + N_RX_RING + 1); skb_queue_head_init(bp->queue); - bp->node = bmac; memset((char *) bp->tx_cmds, 0, (N_TX_RING + N_RX_RING + 2) * sizeof(struct dbdma_cmd)); /* init_timer(&bp->tx_timeout); */ @@ -1421,6 +1434,12 @@ goto err_out_irq1; } + /* Mask chip interrupts and disable chip, will be + * re-enabled on open() + */ + disable_irq(dev->irq); + pmac_call_feature(PMAC_FTR_BMAC_ENABLE, bp->node, 0, 0); + bp->next_bmac = bmac_devs; bmac_devs = dev; return; @@ -1436,6 +1455,12 @@ err_out_iounmap: iounmap((void *)dev->base_addr); err_out: + if (bp->node) { + release_OF_resource(bp->node, 0); + release_OF_resource(bp->node, 1); + release_OF_resource(bp->node, 2); + pmac_call_feature(PMAC_FTR_BMAC_ENABLE, bp->node, 0, 0); + } unregister_netdev(dev); kfree(dev); } @@ -1447,6 +1472,7 @@ /* reset the chip */ bp->opened = 1; bmac_reset_and_enable(dev); + enable_irq(dev->irq); dev->flags |= IFF_RUNNING; return 0; } @@ -1459,6 +1485,7 @@ unsigned short config; int i; + bp->sleeping = 1; dev->flags &= ~(IFF_UP | IFF_RUNNING); /* disable rx and tx */ @@ -1492,6 +1519,8 @@ XXDEBUG(("bmac: all bufs freed\n")); bp->opened = 0; + disable_irq(dev->irq); + pmac_call_feature(PMAC_FTR_BMAC_ENABLE, bp->node, 0, 0); return 0; } @@ -1561,7 +1590,7 @@ bmwrite(dev, TXCFG, (config & ~TxMACEnable)); out_le32(&td->control, DBDMA_CLEAR(RUN|PAUSE|FLUSH|WAKE|ACTIVE|DEAD)); printk(KERN_ERR "bmac: transmit timeout - resetting\n"); - bmac_reset_chip(dev); + bmac_enable_and_reset_chip(dev); /* restart rx dma */ cp = bus_to_virt(ld_le32(&rd->cmdptr)); @@ -1683,11 +1712,15 @@ bp = (struct bmac_data *) dev->priv; bmac_devs = bp->next_bmac; + unregister_netdev(dev); + + release_OF_resource(bp->node, 0); + release_OF_resource(bp->node, 1); + release_OF_resource(bp->node, 2); free_irq(dev->irq, dev); free_irq(bp->tx_dma_intr, dev); free_irq(bp->rx_dma_intr, dev); - unregister_netdev(dev); kfree(dev); } while (bmac_devs != NULL); } diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/net/bonding.c linux-2.5/drivers/net/bonding.c --- linux-2.5.1/drivers/net/bonding.c Tue Nov 13 17:19:41 2001 +++ linux-2.5/drivers/net/bonding.c Thu Dec 13 16:32:36 2001 @@ -185,7 +185,6 @@ #include <linux/if_bonding.h> #include <linux/smp.h> -#include <limits.h> #include <linux/if_ether.h> #include <linux/if_arp.h> diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/net/defxx.c linux-2.5/drivers/net/defxx.c --- linux-2.5.1/drivers/net/defxx.c Sun Sep 30 19:26:06 2001 +++ linux-2.5/drivers/net/defxx.c Thu Dec 13 16:32:36 2001 @@ -3360,7 +3360,7 @@ static struct pci_driver dfx_driver = { name: "defxx", probe: dfx_init_one, - remove: dfx_remove_one, + remove: __devexit_p(dfx_remove_one), id_table: dfx_pci_tbl, }; diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/net/dl2k.c linux-2.5/drivers/net/dl2k.c --- linux-2.5.1/drivers/net/dl2k.c Mon Nov 19 23:19:42 2001 +++ linux-2.5/drivers/net/dl2k.c Thu Dec 27 16:32:31 2001 @@ -15,18 +15,22 @@ 0.01 2001/05/03 Created DL2000-based linux driver 0.02 2001/05/21 Added VLAN and hardware checksum support. 1.00 2001/06/26 Added jumbo frame support. - 1.01 2001/08/21 Added two parameters, int_count and int_timeout. + 1.01 2001/08/21 Added two parameters, rx_coalesce and rx_timeout. 1.02 2001/10/08 Supported fiber media. Added flow control parameters. - 1.03 2001/10/12 Changed the default media to 1000mbps_fd for the - fiber devices. - 1.04 2001/11/08 Fixed a bug which Tx stop when a very busy case. + 1.03 2001/10/12 Changed the default media to 1000mbps_fd for + the fiber devices. + 1.04 2001/11/08 Fixed Tx stopped when tx very busy. + 1.05 2001/11/22 Fixed Tx stopped when unidirectional tx busy. + 1.06 2001/12/13 Fixed disconnect bug at 10Mbps mode. + Fixed tx_full flag incorrect. + Added tx_coalesce paramter. */ #include "dl2k.h" static char version[] __devinitdata = - KERN_INFO "D-Link DL2000-based linux driver v1.04 2001/11/08\n"; + KERN_INFO "D-Link DL2000-based linux driver v1.06 2001/12/13\n"; #define MAX_UNITS 8 static int mtu[MAX_UNITS]; @@ -36,11 +40,13 @@ static int tx_flow[MAX_UNITS]; static int rx_flow[MAX_UNITS]; static int copy_thresh; -static int int_count; /* Rx frame count each interrupt */ -static int int_timeout; /* Rx DMA wait time in 64ns increments */ +static int rx_coalesce = 5; /* Rx frame count each interrupt */ +static int rx_timeout = 750; /* Rx DMA wait time in 64ns increments */ +static int tx_coalesce = 8; /* HW xmit count each TxComplete */ MODULE_AUTHOR ("Edward Peng"); MODULE_DESCRIPTION ("D-Link DL2000-based Gigabit Ethernet Adapter"); +MODULE_LICENSE("GPL"); MODULE_PARM (mtu, "1-" __MODULE_STRING (MAX_UNITS) "i"); MODULE_PARM (media, "1-" __MODULE_STRING (MAX_UNITS) "s"); MODULE_PARM (vlan, "1-" __MODULE_STRING (MAX_UNITS) "i"); @@ -48,13 +54,15 @@ MODULE_PARM (tx_flow, "1-" __MODULE_STRING (MAX_UNITS) "i"); MODULE_PARM (rx_flow, "1-" __MODULE_STRING (MAX_UNITS) "i"); MODULE_PARM (copy_thresh, "i"); -MODULE_PARM (int_count, "i"); -MODULE_PARM (int_timeout, "i"); +MODULE_PARM (rx_coalesce, "i"); +MODULE_PARM (rx_timeout, "i"); +MODULE_PARM (tx_coalesce, "i"); /* Enable the default interrupts */ +#define DEFAULT_INTR (RxDMAComplete | HostError | IntRequested | TxComplete| \ + UpdateStats | LinkEvent) #define EnableInt() \ -writew(RxDMAComplete | HostError | IntRequested | TxComplete| \ - UpdateStats | LinkEvent, ioaddr + IntEnable) +writew(DEFAULT_INTR, ioaddr + IntEnable) static int max_intrloop = 50; static int multicast_filter_limit = 0x40; @@ -163,11 +171,11 @@ np->speed = 10; np->full_duplex = 0; } else if (strcmp (media[card_idx], "1000mbps_fd") == 0 || - strcmp (media[card_idx], "5") == 0) { + strcmp (media[card_idx], "6") == 0) { np->speed=1000; np->full_duplex=1; } else if (strcmp (media[card_idx], "1000mbps_hd") == 0 || - strcmp (media[card_idx], "6") == 0) { + strcmp (media[card_idx], "5") == 0) { np->speed = 1000; np->full_duplex = 0; } else { @@ -176,7 +184,7 @@ } if (jumbo[card_idx] != 0) { np->jumbo = 1; - dev->mtu = 9000; + dev->mtu = MAX_JUMBO; } else { np->jumbo = 0; if (mtu[card_idx] > 0 && mtu[card_idx] < PACKET_SIZE) @@ -184,14 +192,15 @@ } np->vlan = (vlan[card_idx] > 0 && vlan[card_idx] < 4096) ? vlan[card_idx] : 0; - if (int_count != 0 && int_timeout != 0) { - np->int_count = int_count; - np->int_timeout = int_timeout; + if (rx_coalesce != 0 && rx_timeout != 0) { + np->rx_coalesce = rx_coalesce; + np->rx_timeout = rx_timeout; np->coalesce = 1; } np->tx_flow = (tx_flow[card_idx]) ? 1 : 0; np->rx_flow = (rx_flow[card_idx]) ? 1 : 0; - + if (tx_coalesce < 1) + tx_coalesce = 1; } dev->open = &rio_open; dev->hard_start_xmit = &start_xmit; @@ -202,8 +211,8 @@ dev->tx_timeout = &tx_timeout; dev->watchdog_timeo = TX_TIMEOUT; dev->change_mtu = &change_mtu; -#ifdef TX_HW_CHECKSUM - dev->features = NETIF_F_SG | NETIF_F_HW_CSUM; +#if 0 + dev->features = NETIF_F_IP_CSUM; #endif pci_set_drvdata (pdev, dev); @@ -389,13 +398,12 @@ i = request_irq (dev->irq, &rio_interrupt, SA_SHIRQ, dev->name, dev); if (i) return i; - /* DebugCtrl bit 4, 5, 9 must set */ writel (readl (ioaddr + DebugCtrl) | 0x0230, ioaddr + DebugCtrl); /* Jumbo frame */ if (np->jumbo != 0) - writew (9014, ioaddr + MaxFrameSize); + writew (MAX_JUMBO+14, ioaddr + MaxFrameSize); alloc_list (dev); @@ -405,7 +413,7 @@ set_multicast (dev); if (np->coalesce) { - writel (np->int_count | np->int_timeout << 16, + writel (np->rx_coalesce | np->rx_timeout << 16, ioaddr + RxDMAIntCtrl); } /* Set RIO to poll every N*320nsec. */ @@ -442,13 +450,31 @@ struct netdev_private *np = dev->priv; long ioaddr = dev->base_addr; - printk (KERN_WARNING "%s: Transmit timed out, TxStatus %4.4x.\n", + printk (KERN_INFO "%s: Tx timed out (%4.4x), is buffer full?\n", dev->name, readl (ioaddr + TxStatus)); + /* Free used tx skbuffs */ + for (; np->cur_tx - np->old_tx > 0; np->old_tx++) { + int entry = np->old_tx % TX_RING_SIZE; + struct sk_buff *skb; + + if (!(np->tx_ring[entry].status & TFDDone)) + break; + skb = np->tx_skbuff[entry]; + pci_unmap_single (np->pdev, + np->tx_ring[entry].fraginfo, + skb->len, PCI_DMA_TODEVICE); + dev_kfree_skb_irq (skb); + np->tx_skbuff[entry] = 0; + } dev->if_port = 0; dev->trans_start = jiffies; np->stats.tx_errors++; - if (!np->tx_full) + /* If the ring is no longer full, clear tx_full and + call netif_wake_queue() */ + if (np->tx_full && np->cur_tx - np->old_tx < TX_QUEUE_LEN - 1) { + np->tx_full = 0; netif_wake_queue (dev); + } } /* allocate and initialize Tx and Rx descriptors */ @@ -466,16 +492,19 @@ /* Initialize Tx descriptors, TFDListPtr leaves in start_xmit(). */ for (i = 0; i < TX_RING_SIZE; i++) { np->tx_skbuff[i] = 0; - np->tx_ring[i].status = 0; + np->tx_ring[i].status = cpu_to_le64 (TFDDone); + np->tx_ring[i].next_desc = cpu_to_le64 (np->tx_ring_dma + + ((i+1)%TX_RING_SIZE) * + sizeof (struct + netdev_desc)); } /* Initialize Rx descriptors */ for (i = 0; i < RX_RING_SIZE; i++) { np->rx_ring[i].next_desc = cpu_to_le64 (np->rx_ring_dma + - ((i + - 1) % RX_RING_SIZE) * - sizeof (struct - netdev_desc)); + ((i + 1) % RX_RING_SIZE) * + sizeof (struct + netdev_desc)); np->rx_ring[i].status = 0; np->rx_ring[i].fraginfo = 0; np->rx_skbuff[i] = 0; @@ -523,13 +552,12 @@ entry = np->cur_tx % TX_RING_SIZE; np->tx_skbuff[entry] = skb; txdesc = &np->tx_ring[entry]; - txdesc->next_desc = 0; /* Set TFDDone to avoid TxDMA gather this descriptor */ txdesc->status = cpu_to_le64 (TFDDone); txdesc->status |= cpu_to_le64 (entry | WordAlignDisable | (1 << FragCountShift)); -#ifdef TX_HW_CHECKSUM +#if 0 if (skb->ip_summed == CHECKSUM_HW) { txdesc->status |= cpu_to_le64 (TCPChecksumEnable | UDPChecksumEnable | @@ -545,21 +573,13 @@ /* Send one packet each time at 10Mbps mode */ /* Tx coalescing loop do not exceed 8 */ - if (entry % 0x08 == 0 || np->speed == 10) + if (entry % tx_coalesce == 0 || np->speed == 10) txdesc->status |= cpu_to_le64 (TxIndicate); txdesc->fraginfo = cpu_to_le64 (pci_map_single (np->pdev, skb->data, skb->len, PCI_DMA_TODEVICE)); txdesc->fraginfo |= cpu_to_le64 (skb->len) << 48; - /* Chain the last descriptor's pointer to this one */ - if (np->last_tx) - np->last_tx->next_desc = cpu_to_le64 (np->tx_ring_dma + - entry * - sizeof (struct - netdev_desc)); - np->last_tx = txdesc; - /* Clear TFDDone, then TxDMA start to send this descriptor */ txdesc->status &= ~cpu_to_le64 (TFDDone); @@ -571,8 +591,10 @@ if (np->cur_tx - np->old_tx < TX_QUEUE_LEN - 1 && np->speed != 10) { /* do nothing */ } else { + spin_lock_irqsave(&np->lock, flags); np->tx_full = 1; netif_stop_queue (dev); + spin_unlock_irqrestore (&np->lock, flags); } /* The first TFDListPtr */ @@ -581,15 +603,15 @@ dev->base_addr + TFDListPtr0); writel (0, dev->base_addr + TFDListPtr1); } - - spin_lock_irqsave (&np->lock, flags); + if (np->old_tx > TX_RING_SIZE) { + spin_lock_irqsave (&np->lock, flags); tx_shift = TX_RING_SIZE; np->old_tx -= tx_shift; np->cur_tx -= tx_shift; + spin_unlock_irqrestore (&np->lock, flags); } - spin_unlock_irqrestore (&np->lock, flags); - + /* NETDEV WATCHDOG timer */ dev->trans_start = jiffies; return 0; @@ -606,33 +628,24 @@ ioaddr = dev->base_addr; np = dev->priv; - spin_lock (&np->lock); + spin_lock(&np->lock); while (1) { - int_status = readw (ioaddr + IntStatus) & - (HostError | TxComplete | IntRequested | - UpdateStats | LinkEvent | RxDMAComplete); - writew (int_status & (HostError | TxComplete | RxComplete | - IntRequested | UpdateStats | LinkEvent | - TxDMAComplete | RxDMAComplete | RFDListEnd - | RxDMAPriority), ioaddr + IntStatus); + int_status = readw (ioaddr + IntStatus); + writew (int_status, ioaddr + IntStatus); + int_status &= DEFAULT_INTR; if (int_status == 0) break; /* Processing received packets */ if (int_status & RxDMAComplete) receive_packet (dev); /* TxComplete interrupt */ - if (int_status & TxComplete || np->tx_full) { - int tx_status = readl (ioaddr + TxStatus); + if ((int_status & TxComplete) || np->tx_full) { + int tx_status; + tx_status = readl (ioaddr + TxStatus); if (tx_status & 0x01) tx_error (dev, tx_status); - /* Send one packet each time at 10Mbps mode */ - if (np->speed == 10) { - np->tx_full = 0; - netif_wake_queue (dev); - } - /* Free used tx skbuffs */ - for (; np->cur_tx - np->old_tx > 0; np->old_tx++) { + for (;np->cur_tx - np->old_tx > 0; np->old_tx++) { int entry = np->old_tx % TX_RING_SIZE; struct sk_buff *skb; @@ -649,9 +662,12 @@ /* If the ring is no longer full, clear tx_full and call netif_wake_queue() */ if (np->tx_full && np->cur_tx - np->old_tx < TX_QUEUE_LEN - 1) { - np->tx_full = 0; - netif_wake_queue (dev); + if (np->speed != 10 || int_status & TxComplete) { + np->tx_full = 0; + netif_wake_queue (dev); + } } + /* Handle uncommon events */ if (int_status & (IntRequested | HostError | LinkEvent | UpdateStats)) @@ -666,7 +682,7 @@ break; } } - spin_unlock (&np->lock); + spin_unlock(&np->lock); } static void @@ -742,7 +758,7 @@ np->stats.collisions++; #endif - /* Restart the Tx. */ + /* Restart the Tx */ writel (readw (dev->base_addr + MACCtrl) | TxEnable, ioaddr + MACCtrl); } @@ -808,7 +824,7 @@ skb_put (skb, pkt_len); } skb->protocol = eth_type_trans (skb, dev); -#ifdef RX_HW_CHECKSUM +#if 0 /* Checksum done by hw, but csum value unavailable. */ if (!(frame_status & (TCPError | UDPError | IPError))) { skb->ip_summed = CHECKSUM_UNNECESSARY; @@ -899,7 +915,7 @@ /* PCI Error, a catastronphic error related to the bus interface occurs, set GlobalReset and HostReset to reset. */ if (int_status & HostError) { - printk (KERN_ERR "%s: PCI Error! IntStatus %4.4x.\n", + printk (KERN_ERR "%s: HostError! IntStatus %4.4x.\n", dev->name, int_status); writew (GlobalReset | HostReset, ioaddr + ASICCtrl + 2); mdelay (500); @@ -914,8 +930,8 @@ u16 temp1; u16 temp2; int i; - /* All statistics registers need to acknowledge, - else overflow could cause some problem */ + /* All statistics registers need to be acknowledged, + else statistic overflow could cause problems */ np->stats.rx_packets += readl (ioaddr + FramesRcvOk); np->stats.tx_packets += readl (ioaddr + FramesXmtOk); np->stats.rx_bytes += readl (ioaddr + OctetRcvOk); @@ -961,7 +977,7 @@ change_mtu (struct net_device *dev, int new_mtu) { struct netdev_private *np = dev->priv; - int max = (np->jumbo) ? 9000 : 1536; + int max = (np->jumbo) ? MAX_JUMBO : 1536; if ((new_mtu < 68) || (new_mtu > max)) { return -EINVAL; @@ -1671,7 +1687,7 @@ name:"dl2k", id_table:rio_pci_tbl, probe:rio_probe1, - remove:rio_remove1, + remove:__devexit_p(rio_remove1), }; static int __init @@ -1693,8 +1709,9 @@ Compile command: -gcc -D__KERNEL__ -DMODULE -I/usr/src/linux/include -Wall -Wstrict-prototypes -O2 -c dl2x.c +gcc -D__KERNEL__ -DMODULE -I/usr/src/linux/include -Wall -Wstrict-prototypes -O2 -c dl2k.c Read Documentation/networking/dl2k.txt for details. */ + diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/net/dl2k.h linux-2.5/drivers/net/dl2k.h --- linux-2.5.1/drivers/net/dl2k.h Mon Nov 19 23:19:42 2001 +++ linux-2.5/drivers/net/dl2k.h Thu Dec 27 16:32:31 2001 @@ -33,7 +33,7 @@ #include <linux/spinlock.h> #include <linux/time.h> #define TX_RING_SIZE 128 -#define TX_QUEUE_LEN 96 /* Limit ring entries actually used. */ +#define TX_QUEUE_LEN 120 /* Limit ring entries actually used. */ #define RX_RING_SIZE 128 #define TX_TOTAL_SIZE TX_RING_SIZE*sizeof(struct netdev_desc) #define RX_TOTAL_SIZE RX_RING_SIZE*sizeof(struct netdev_desc) @@ -649,13 +649,13 @@ struct pci_dev *pdev; spinlock_t lock; struct net_device_stats stats; - unsigned int rx_buf_sz; /* Based on MTU+slack. */ - unsigned int speed; /* Operating speed */ - unsigned int vlan; /* VLAN Id */ - unsigned int chip_id; /* PCI table chip id */ - unsigned int int_count; /* Maximum frames each RxDMAComplete intr */ - unsigned int int_timeout; /* Wait time between RxDMAComplete intr */ - unsigned int tx_full:1; /* The Tx queue is full. */ + unsigned int rx_buf_sz; /* Based on MTU+slack. */ + unsigned int speed; /* Operating speed */ + unsigned int vlan; /* VLAN Id */ + unsigned int chip_id; /* PCI table chip id */ + unsigned int rx_coalesce; /* Maximum frames each RxDMAComplete intr */ + unsigned int rx_timeout; /* Wait time between RxDMAComplete intr */ + unsigned int tx_full:1; /* The Tx queue is full. */ unsigned int full_duplex:1; /* Full-duplex operation requested. */ unsigned int an_enable:2; /* Auto-Negotiated Enable */ unsigned int jumbo:1; /* Jumbo frame enable */ @@ -697,6 +697,7 @@ MODULE_DEVICE_TABLE (pci, rio_pci_tbl); #define TX_TIMEOUT (4*HZ) #define PACKET_SIZE 1536 +#define MAX_JUMBO 8000 #define RIO_IO_SIZE 340 #ifdef RIO_DEBUG #define DEBUG_TFD_DUMP(x) debug_tfd_dump(x) diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/net/eepro100.c linux-2.5/drivers/net/eepro100.c --- linux-2.5.1/drivers/net/eepro100.c Mon Nov 12 17:47:18 2001 +++ linux-2.5/drivers/net/eepro100.c Mon Dec 17 18:05:01 2001 @@ -168,6 +168,9 @@ #ifndef PCI_DEVICE_ID_INTEL_ID1030 #define PCI_DEVICE_ID_INTEL_ID1030 0x1030 #endif +#ifndef PCI_DEVICE_ID_INTEL_ID1038 +#define PCI_DEVICE_ID_INTEL_ID1038 0x1038 +#endif static int speedo_debug = 1; @@ -2271,8 +2274,26 @@ PCI_ANY_ID, PCI_ANY_ID, }, { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ID1030, PCI_ANY_ID, PCI_ANY_ID, }, + { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ID1038, + PCI_ANY_ID, PCI_ANY_ID, }, { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801BA_7, PCI_ANY_ID, PCI_ANY_ID, }, + { PCI_VENDOR_ID_INTEL, 0x1032, + PCI_ANY_ID, PCI_ANY_ID, }, + { PCI_VENDOR_ID_INTEL, 0x1033, + PCI_ANY_ID, PCI_ANY_ID, }, + { PCI_VENDOR_ID_INTEL, 0x1034, + PCI_ANY_ID, PCI_ANY_ID, }, + { PCI_VENDOR_ID_INTEL, 0x1038, + PCI_ANY_ID, PCI_ANY_ID, }, + { PCI_VENDOR_ID_INTEL, 0x1227, + PCI_ANY_ID, PCI_ANY_ID, }, + { PCI_VENDOR_ID_INTEL, 0x1228, + PCI_ANY_ID, PCI_ANY_ID, }, + { PCI_VENDOR_ID_INTEL, 0x5200, + PCI_ANY_ID, PCI_ANY_ID, }, + { PCI_VENDOR_ID_INTEL, 0x5201, + PCI_ANY_ID, PCI_ANY_ID, }, { 0,} }; MODULE_DEVICE_TABLE(pci, eepro100_pci_tbl); @@ -2281,7 +2302,7 @@ name: "eepro100", id_table: eepro100_pci_tbl, probe: eepro100_init_one, - remove: eepro100_remove_one, + remove: __devexit_p(eepro100_remove_one), #ifdef CONFIG_PM suspend: eepro100_suspend, resume: eepro100_resume, diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/net/epic100.c linux-2.5/drivers/net/epic100.c --- linux-2.5.1/drivers/net/epic100.c Sun Sep 30 19:26:06 2001 +++ linux-2.5/drivers/net/epic100.c Thu Dec 13 16:32:36 2001 @@ -1507,7 +1507,7 @@ name: DRV_NAME, id_table: epic_pci_tbl, probe: epic_init_one, - remove: epic_remove_one, + remove: __devexit_p(epic_remove_one), #ifdef CONFIG_PM suspend: epic_suspend, resume: epic_resume, diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/net/fc/iph5526.c linux-2.5/drivers/net/fc/iph5526.c --- linux-2.5.1/drivers/net/fc/iph5526.c Wed Nov 28 18:22:27 2001 +++ linux-2.5/drivers/net/fc/iph5526.c Thu Dec 27 22:10:28 2001 @@ -4534,14 +4534,14 @@ { int i = 0; - driver_template.module = &__this_module; - scsi_register_module(MODULE_SCSI_HA, &driver_template); + driver_template.module = THIS_MODULE; + scsi_register_host(&driver_template); if (driver_template.present) scsi_registered = TRUE; else { printk("iph5526: SCSI registeration failed!!!\n"); scsi_registered = FALSE; - scsi_unregister_module(MODULE_SCSI_HA, &driver_template); + scsi_unregister_host(&driver_template); } while(fc[i] != NULL) { @@ -4590,7 +4590,7 @@ i++; } if (scsi_registered == TRUE) - scsi_unregister_module(MODULE_SCSI_HA, &driver_template); + scsi_unregister_host(&driver_template); } #endif /* MODULE */ diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/net/fealnx.c linux-2.5/drivers/net/fealnx.c --- linux-2.5.1/drivers/net/fealnx.c Mon Nov 19 23:19:42 2001 +++ linux-2.5/drivers/net/fealnx.c Thu Dec 13 16:32:36 2001 @@ -1858,7 +1858,7 @@ name: "fealnx", id_table: fealnx_pci_tbl, probe: fealnx_init_one, - remove: fealnx_remove_one, + remove: __devexit_p(fealnx_remove_one), }; static int __init fealnx_init(void) diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/net/gmac.c linux-2.5/drivers/net/gmac.c --- linux-2.5.1/drivers/net/gmac.c Wed Oct 17 04:56:29 2001 +++ linux-2.5/drivers/net/gmac.c Thu Dec 27 16:32:31 2001 @@ -36,7 +36,8 @@ #include <asm/prom.h> #include <asm/io.h> #include <asm/pgtable.h> -#include <asm/feature.h> +#include <asm/machdep.h> +#include <asm/pmac_feature.h> #include <asm/keylargo.h> #include <asm/pci-bridge.h> #ifdef CONFIG_PMAC_PBOOK @@ -296,6 +297,7 @@ } } +#ifdef CONFIG_PMAC_PBOOK /* Power management: stop PHY chip for suspend mode * * TODO: This will have to be modified is WOL is to be supported. @@ -441,6 +443,7 @@ GM_OUT(GM_RX_CONF, 0); } } +#endif static int mii_do_reset_phy(struct gmac *gm, int phy_addr) @@ -585,8 +588,8 @@ gm->phy_type = PHY_UNKNOWN; /* Hard reset the PHY */ - feature_gmac_phy_reset(gm->of_node); - + pmac_call_feature(PMAC_FTR_GMAC_PHY_RESET, gm->of_node, 0, 0); + /* Find the PHY */ for(i=0; i<=31; i++) { mii_control = mii_read(gm, i, MII_CR); @@ -683,7 +686,7 @@ gmac_set_power(struct gmac *gm, int power_up) { if (power_up) { - feature_set_gmac_power(gm->of_node, 1); + pmac_call_feature(PMAC_FTR_GMAC_ENABLE, gm->of_node, 0, 1); if (gm->pci_devfn != 0xff) { u16 cmd; @@ -708,7 +711,7 @@ PCI_CACHE_LINE_SIZE, 8); } } else { - feature_set_gmac_power(gm->of_node, 0); + pmac_call_feature(PMAC_FTR_GMAC_ENABLE, gm->of_node, 0, 0); } } @@ -1617,6 +1620,11 @@ SET_MODULE_OWNER(dev); gm = dev->priv; + gm->of_node = gmac; + if (!request_OF_resource(gmac, 0, " (gmac)")) { + printk(KERN_ERR "GMAC: can't request IO resource !\n"); + goto out_unreg; + } dev->base_addr = gmac->addrs[0].address; gm->regs = (volatile unsigned int *) ioremap(gmac->addrs[0].address, 0x10000); @@ -1626,7 +1634,6 @@ } dev->irq = gmac->intrs[0].line; gm->dev = dev; - gm->of_node = gmac; spin_lock_init(&gm->lock); @@ -1667,6 +1674,8 @@ out_unreg: unregister_netdev(dev); + if (gm->of_node) + release_OF_resource(gm->of_node, 0); kfree(dev); out_rxdesc: free_page(rx_descpage); @@ -1677,6 +1686,7 @@ MODULE_AUTHOR("Paul Mackerras/Ben Herrenschmidt"); MODULE_DESCRIPTION("PowerMac GMAC driver."); MODULE_LICENSE("GPL"); +EXPORT_NO_SYMBOLS; static void __exit gmac_cleanup_module(void) { @@ -1694,6 +1704,7 @@ iounmap((void *) gm->regs); free_page(gm->tx_desc_page); free_page(gm->rx_desc_page); + release_OF_resource(gm->of_node, 0); gmacs = gm->next_gmac; kfree(dev); } diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/net/hamradio/bpqether.c linux-2.5/drivers/net/hamradio/bpqether.c --- linux-2.5.1/drivers/net/hamradio/bpqether.c Thu Sep 13 23:04:43 2001 +++ linux-2.5/drivers/net/hamradio/bpqether.c Sun Dec 30 21:17:30 2001 @@ -69,7 +69,6 @@ #include <linux/if_arp.h> #include <linux/skbuff.h> #include <net/sock.h> -#include <asm/segment.h> #include <asm/system.h> #include <asm/uaccess.h> #include <linux/mm.h> diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/net/hamradio/dmascc.c linux-2.5/drivers/net/hamradio/dmascc.c --- linux-2.5.1/drivers/net/hamradio/dmascc.c Wed Apr 18 21:40:06 2001 +++ linux-2.5/drivers/net/hamradio/dmascc.c Sun Dec 30 21:17:30 2001 @@ -43,7 +43,6 @@ #include <asm/dma.h> #include <asm/io.h> #include <asm/irq.h> -#include <asm/segment.h> #include <asm/uaccess.h> #include <net/ax25.h> #include "z8530.h" diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/net/hamradio/mkiss.c linux-2.5/drivers/net/hamradio/mkiss.c --- linux-2.5.1/drivers/net/hamradio/mkiss.c Thu Sep 13 23:04:43 2001 +++ linux-2.5/drivers/net/hamradio/mkiss.c Sun Dec 30 21:17:30 2001 @@ -27,7 +27,6 @@ #include <linux/config.h> #include <linux/module.h> #include <asm/system.h> -#include <asm/segment.h> #include <asm/bitops.h> #include <asm/uaccess.h> #include <linux/string.h> diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/net/ioc3-eth.c linux-2.5/drivers/net/ioc3-eth.c --- linux-2.5.1/drivers/net/ioc3-eth.c Wed Oct 17 04:56:29 2001 +++ linux-2.5/drivers/net/ioc3-eth.c Thu Dec 13 16:32:36 2001 @@ -1515,7 +1515,7 @@ name: "ioc3-eth", id_table: ioc3_pci_tbl, probe: ioc3_probe, - remove: ioc3_remove_one, + remove: __devexit_p(ioc3_remove_one), }; static int __init ioc3_init_module(void) diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/net/irda/irtty.c linux-2.5/drivers/net/irda/irtty.c --- linux-2.5.1/drivers/net/irda/irtty.c Sun Sep 30 19:26:06 2001 +++ linux-2.5/drivers/net/irda/irtty.c Sun Dec 30 21:17:30 2001 @@ -32,7 +32,6 @@ #include <linux/if_arp.h> #include <linux/rtnetlink.h> -#include <asm/segment.h> #include <asm/uaccess.h> #include <net/irda/irda.h> diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/net/jazzsonic.c linux-2.5/drivers/net/jazzsonic.c --- linux-2.5.1/drivers/net/jazzsonic.c Sun Sep 9 17:43:01 2001 +++ linux-2.5/drivers/net/jazzsonic.c Sun Dec 30 21:17:30 2001 @@ -29,7 +29,6 @@ #include <asm/system.h> #include <asm/bitops.h> #include <asm/pgtable.h> -#include <asm/segment.h> #include <asm/io.h> #include <asm/dma.h> #include <asm/jazz.h> diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/net/mace.c linux-2.5/drivers/net/mace.c --- linux-2.5.1/drivers/net/mace.c Wed Oct 17 04:56:29 2001 +++ linux-2.5/drivers/net/mace.c Thu Dec 27 16:32:31 2001 @@ -24,9 +24,6 @@ static struct net_device *mace_devs; static int port_aaui = -1; -MODULE_PARM(port_aaui, "i"); -MODULE_PARM_DESC(port_aaui, "MACE uses AAUI port (0-1)"); - #define N_RX_RING 8 #define N_TX_RING 6 #define MAX_TX_ACTIVE 1 @@ -59,6 +56,7 @@ struct timer_list tx_timeout; int timeout_active; int port_aaui; + struct device_node* of_node; struct net_device *next_mace; }; @@ -152,9 +150,25 @@ SET_MODULE_OWNER(dev); mp = dev->priv; + mp->of_node = mace; + + if (!request_OF_resource(mace, 0, " (mace)")) { + printk(KERN_ERR "MACE: can't request IO resource !\n"); + goto err_out; + } + if (!request_OF_resource(mace, 1, " (mace tx dma)")) { + printk(KERN_ERR "MACE: can't request TX DMA resource !\n"); + goto err_out; + } + + if (!request_OF_resource(mace, 2, " (mace tx dma)")) { + printk(KERN_ERR "MACE: can't request RX DMA resource !\n"); + goto err_out; + } + dev->base_addr = mace->addrs[0].address; mp->mace = (volatile struct mace *) - ioremap(mace->addrs[0].address, 0x1000); + ioremap(mace->addrs[0].address, 0x1000); dev->irq = mace->intrs[0].line; printk(KERN_INFO "%s: MACE at", dev->name); @@ -221,6 +235,16 @@ mp->next_mace = mace_devs; mace_devs = dev; + return; + +err_out: + unregister_netdev(dev); + if (mp->of_node) { + release_OF_resource(mp->of_node, 0); + release_OF_resource(mp->of_node, 1); + release_OF_resource(mp->of_node, 2); + } + kfree(dev); } static void dbdma_reset(volatile struct dbdma_regs *dma) @@ -273,14 +297,20 @@ __mace_set_address(dev, dev->dev_addr); /* clear the multicast filter */ - out_8(&mb->iac, ADDRCHG | LOGADDR); - while ((in_8(&mb->iac) & ADDRCHG) != 0) - ; - for (i = 0; i < 8; ++i) { - out_8(&mb->ladrf, 0); + if (in_8(&mb->chipid_hi) == 0x09) { + printk("chip 0x09 mcast workaround...\n"); + out_8(&mb->iac, LOGADDR); + } else { + out_8(&mb->iac, ADDRCHG | LOGADDR); + while ((in_8(&mb->iac) & ADDRCHG) != 0) + ; } + for (i = 0; i < 8; ++i) + out_8(&mb->ladrf, 0); + /* done changing address */ - out_8(&mb->iac, 0); + if (in_8(&mb->chipid_hi) != 0x09) + out_8(&mb->iac, 0); if (mp->port_aaui) out_8(&mb->plscc, PORTSEL_AUI + ENPLSIO); @@ -295,11 +325,17 @@ int i; /* load up the hardware address */ - out_8(&mb->iac, ADDRCHG | PHYADDR); - while ((in_8(&mb->iac) & ADDRCHG) != 0) - ; + if (in_8(&mb->chipid_hi) == 0x09) { + printk("chip 0x09 hwaddr workaround...\n"); + out_8(&mb->iac, PHYADDR); + } else { + while ((in_8(&mb->iac) & ADDRCHG) != 0) + ; + } for (i = 0; i < 6; ++i) out_8(&mb->padr, dev->dev_addr[i] = p[i]); + if (in_8(&mb->chipid_hi) != 0x09) + out_8(&mb->iac, 0); } static int mace_set_address(struct net_device *dev, void *addr) @@ -312,7 +348,6 @@ __mace_set_address(dev, addr); - out_8(&mb->iac, 0); /* note: setting ADDRCHG clears ENRCV */ out_8(&mb->maccc, mp->maccc); @@ -557,12 +592,18 @@ printk("\n"); #endif - out_8(&mb->iac, ADDRCHG | LOGADDR); - while ((in_8(&mb->iac) & ADDRCHG) != 0) - ; - for (i = 0; i < 8; ++i) { - out_8(&mb->ladrf, multicast_filter[i]); + if (in_8(&mb->chipid_hi) == 0x09) { + printk("chip 0x09 mcast workaround...\n"); + out_8(&mb->iac, LOGADDR); + } else { + out_8(&mb->iac, ADDRCHG | LOGADDR); + while ((in_8(&mb->iac) & ADDRCHG) != 0) + ; } + for (i = 0; i < 8; ++i) + out_8(&mb->ladrf, multicast_filter[i]); + if (in_8(&mb->chipid_hi) != 0x09) + out_8(&mb->iac, LOGADDR); } /* reset maccc */ out_8(&mb->maccc, mp->maccc); @@ -913,7 +954,10 @@ MODULE_AUTHOR("Paul Mackerras"); MODULE_DESCRIPTION("PowerMac MACE driver."); +MODULE_PARM(port_aaui, "i"); +MODULE_PARM_DESC(port_aaui, "MACE uses AAUI port (0-1)"); MODULE_LICENSE("GPL"); +EXPORT_NO_SYMBOLS; static void __exit mace_cleanup (void) { @@ -921,19 +965,23 @@ struct mace_data *mp; while ((dev = mace_devs) != 0) { - mp = (struct mace_data *) mace_devs->priv; - mace_devs = mp->next_mace; + mp = (struct mace_data *) mace_devs->priv; + mace_devs = mp->next_mace; - free_irq(dev->irq, dev); - free_irq(mp->tx_dma_intr, dev); - free_irq(mp->rx_dma_intr, dev); + unregister_netdev(dev); + free_irq(dev->irq, dev); + free_irq(mp->tx_dma_intr, dev); + free_irq(mp->rx_dma_intr, dev); + + release_OF_resource(mp->of_node, 0); + release_OF_resource(mp->of_node, 1); + release_OF_resource(mp->of_node, 2); - unregister_netdev(dev); - kfree(dev); + kfree(dev); } if (dummy_buf != NULL) { - kfree(dummy_buf); - dummy_buf = NULL; + kfree(dummy_buf); + dummy_buf = NULL; } } diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/net/macsonic.c linux-2.5/drivers/net/macsonic.c --- linux-2.5.1/drivers/net/macsonic.c Wed Oct 17 04:56:29 2001 +++ linux-2.5/drivers/net/macsonic.c Sun Dec 30 21:17:30 2001 @@ -40,7 +40,6 @@ #include <asm/system.h> #include <asm/bitops.h> #include <asm/pgtable.h> -#include <asm/segment.h> #include <asm/io.h> #include <asm/hwtest.h> #include <asm/dma.h> diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/net/natsemi.c linux-2.5/drivers/net/natsemi.c --- linux-2.5.1/drivers/net/natsemi.c Mon Nov 19 23:19:42 2001 +++ linux-2.5/drivers/net/natsemi.c Thu Dec 27 16:32:31 2001 @@ -100,7 +100,10 @@ * ETHTOOL_* further support (Tim Hockin) version 1.0.13: - * ETHTOOL_[GS]EEPROM support (Tim Hockin) + * ETHTOOL_GEEPROM support (Tim Hockin) + + version 1.0.14: + * Cleanup some messages and autoneg in ethtool (Tim Hockin) TODO: * big endian support with CFG:BEM instead of cpu_to_le32 @@ -108,9 +111,40 @@ * flow control */ +#if !defined(__OPTIMIZE__) +#warning You must compile this file with the correct options! +#warning See the last lines of the source file. +#error You must compile this driver with "-O". +#endif + +#include <linux/config.h> +#include <linux/module.h> +#include <linux/kernel.h> +#include <linux/string.h> +#include <linux/timer.h> +#include <linux/errno.h> +#include <linux/ioport.h> +#include <linux/slab.h> +#include <linux/interrupt.h> +#include <linux/pci.h> +#include <linux/netdevice.h> +#include <linux/etherdevice.h> +#include <linux/skbuff.h> +#include <linux/init.h> +#include <linux/spinlock.h> +#include <linux/ethtool.h> +#include <linux/delay.h> +#include <linux/rtnetlink.h> +#include <linux/mii.h> +#include <asm/processor.h> /* Processor type for cache alignment. */ +#include <asm/bitops.h> +#include <asm/io.h> +#include <asm/irq.h> +#include <asm/uaccess.h> + #define DRV_NAME "natsemi" -#define DRV_VERSION "1.07+LK1.0.13" -#define DRV_RELDATE "Oct 19, 2001" +#define DRV_VERSION "1.07+LK1.0.14" +#define DRV_RELDATE "Nov 27, 2001" /* Updated to recommendations in pci-skeleton v2.03. */ @@ -129,7 +163,12 @@ /* The user-configurable values. These may be modified when a driver module is loaded.*/ -static int debug = 1; /* 1 normal messages, 0 quiet .. 7 verbose. */ +#define NATSEMI_DEF_MSG (NETIF_MSG_DRV | \ + NETIF_MSG_LINK | \ + NETIF_MSG_WOL | \ + NETIF_MSG_RX_ERR | \ + NETIF_MSG_TX_ERR) +static int debug = NATSEMI_DEF_MSG; /* Maximum events (Rx packets, etc.) to handle at each interrupt. */ static int max_interrupt_work = 20; @@ -180,37 +219,6 @@ #define PKT_BUF_SZ 1536 /* Size of each temporary Rx buffer. */ -#if !defined(__OPTIMIZE__) -#warning You must compile this file with the correct options! -#warning See the last lines of the source file. -#error You must compile this driver with "-O". -#endif - -#include <linux/config.h> -#include <linux/module.h> -#include <linux/kernel.h> -#include <linux/string.h> -#include <linux/timer.h> -#include <linux/errno.h> -#include <linux/ioport.h> -#include <linux/slab.h> -#include <linux/interrupt.h> -#include <linux/pci.h> -#include <linux/netdevice.h> -#include <linux/etherdevice.h> -#include <linux/skbuff.h> -#include <linux/init.h> -#include <linux/spinlock.h> -#include <linux/ethtool.h> -#include <linux/delay.h> -#include <linux/rtnetlink.h> -#include <linux/mii.h> -#include <asm/processor.h> /* Processor type for cache alignment. */ -#include <asm/bitops.h> -#include <asm/io.h> -#include <asm/irq.h> -#include <asm/uaccess.h> - /* These identify the driver base version and may not be removed. */ static char version[] __devinitdata = KERN_INFO DRV_NAME ".c:v1.07 1/9/2001 Written by Donald Becker <becker@scyld.com>\n" @@ -229,7 +237,7 @@ MODULE_PARM(full_duplex, "1-" __MODULE_STRING(MAX_UNITS) "i"); MODULE_PARM_DESC(max_interrupt_work, "DP8381x maximum events handled per interrupt"); MODULE_PARM_DESC(mtu, "DP8381x MTU (all boards)"); -MODULE_PARM_DESC(debug, "DP8381x debug level (0-5)"); +MODULE_PARM_DESC(debug, "DP8381x debug bitmask"); MODULE_PARM_DESC(rx_copybreak, "DP8381x copy breakpoint for copy-only-tiny-frames"); MODULE_PARM_DESC(options, "DP8381x: Bits 0-3: media type, bit 17: full duplex"); MODULE_PARM_DESC(full_duplex, "DP8381x full duplex setting(s) (1)"); @@ -414,6 +422,7 @@ enum ChipConfig_bits { CfgPhyDis = 0x200, CfgPhyRst = 0x400, + CfgExtPhy = 0x1000, CfgAnegEnable = 0x2000, CfgAneg100 = 0x4000, CfgAnegFull = 0x8000, @@ -627,6 +636,7 @@ u16 advertising; /* NWay media advertisement */ unsigned int iosize; spinlock_t lock; + u32 msg_enable; }; static int eeprom_read(long ioaddr, int location); @@ -746,6 +756,7 @@ pci_set_drvdata(pdev, dev); np->iosize = iosize; spin_lock_init(&np->lock); + np->msg_enable = debug; /* Reset the chip to erase previous misconfiguration. */ natsemi_reload_eeprom(dev); @@ -760,7 +771,8 @@ if (option & 0x200) np->full_duplex = 1; if (option & 15) - printk(KERN_INFO "%s: ignoring user supplied media type %d", + printk(KERN_INFO + "%s: ignoring user supplied media type %d", dev->name, option & 15); } if (find_cnt < MAX_UNITS && full_duplex[find_cnt] > 0) @@ -789,14 +801,17 @@ } netif_carrier_off(dev); - printk(KERN_INFO "%s: %s at 0x%lx, ", - dev->name, natsemi_pci_info[chip_idx].name, ioaddr); - for (i = 0; i < ETH_ALEN-1; i++) - printk("%2.2x:", dev->dev_addr[i]); - printk("%2.2x, IRQ %d.\n", dev->dev_addr[i], irq); + if (netif_msg_drv(np)) { + printk(KERN_INFO "%s: %s at %#08lx, ", + dev->name, natsemi_pci_info[chip_idx].name, ioaddr); + for (i = 0; i < ETH_ALEN-1; i++) + printk("%02x:", dev->dev_addr[i]); + printk("%02x, IRQ %d.\n", dev->dev_addr[i], irq); + } np->advertising = mdio_read(dev, 1, MII_ADVERTISE); - if ((readl(ioaddr + ChipConfig) & 0xe000) != 0xe000) { + if ((readl(ioaddr + ChipConfig) & 0xe000) != 0xe000 + && netif_msg_probe(np)) { u32 chip_config = readl(ioaddr + ChipConfig); printk(KERN_INFO "%s: Transceiver default autonegotiation %s " "10%s %s duplex.\n", @@ -805,12 +820,18 @@ chip_config & CfgAneg100 ? "0" : "", chip_config & CfgAnegFull ? "full" : "half"); } - printk(KERN_INFO "%s: Transceiver status 0x%4.4x advertising %4.4x.\n", - dev->name, mdio_read(dev, 1, MII_BMSR), - np->advertising); + if (netif_msg_probe(np)) + printk(KERN_INFO + "%s: Transceiver status %#04x advertising %#04x.\n", + dev->name, mdio_read(dev, 1, MII_BMSR), + np->advertising); /* save the silicon revision for later querying */ np->srr = readl(ioaddr + SiliconRev); + if (netif_msg_hw(np)) + printk(KERN_INFO "%s: silicon revision %#04x.\n", + dev->name, np->srr); + return 0; } @@ -907,6 +928,7 @@ u32 rfcr; u16 pmatch[3]; u16 sopass[3]; + struct netdev_private *np = dev->priv; /* * Resetting the chip causes some registers to be lost. @@ -940,10 +962,10 @@ break; udelay(5); } - if (i==NATSEMI_HW_TIMEOUT && debug) { + if (i==NATSEMI_HW_TIMEOUT && netif_msg_hw(np)) { printk(KERN_INFO "%s: reset did not complete in %d usec.\n", dev->name, i*5); - } else if (debug > 2) { + } else if (netif_msg_hw(np)) { printk(KERN_DEBUG "%s: reset completed in %d usec.\n", dev->name, i*5); } @@ -972,6 +994,7 @@ static void natsemi_reload_eeprom(struct net_device *dev) { + struct netdev_private *np = dev->priv; int i; writel(EepromReload, dev->base_addr + PCIBusCfg); @@ -980,10 +1003,10 @@ break; udelay(5); } - if (i==NATSEMI_HW_TIMEOUT && debug) { + if (i==NATSEMI_HW_TIMEOUT && netif_msg_hw(np)) { printk(KERN_INFO "%s: EEPROM did not reload in %d usec.\n", dev->name, i*5); - } else if (debug > 2) { + } else if (netif_msg_hw(np)) { printk(KERN_DEBUG "%s: EEPROM reloaded in %d usec.\n", dev->name, i*5); } @@ -992,6 +1015,7 @@ static void natsemi_stop_rxtx(struct net_device *dev) { long ioaddr = dev->base_addr; + struct netdev_private *np = dev->priv; int i; writel(RxOff | TxOff, ioaddr + ChipCmd); @@ -1000,10 +1024,10 @@ break; udelay(5); } - if (i==NATSEMI_HW_TIMEOUT && debug) { + if (i==NATSEMI_HW_TIMEOUT && netif_msg_hw(np)) { printk(KERN_INFO "%s: Tx/Rx process did not stop in %d usec.\n", dev->name, i*5); - } else if (debug > 2) { + } else if (netif_msg_hw(np)) { printk(KERN_DEBUG "%s: Tx/Rx process stopped in %d usec.\n", dev->name, i*5); } @@ -1021,7 +1045,7 @@ i = request_irq(dev->irq, &intr_handler, SA_SHIRQ, dev->name, dev); if (i) return i; - if (debug > 1) + if (netif_msg_ifup(np)) printk(KERN_DEBUG "%s: netdev_open() irq %d.\n", dev->name, dev->irq); i = alloc_ring(dev); @@ -1036,8 +1060,8 @@ netif_start_queue(dev); - if (debug > 2) - printk(KERN_DEBUG "%s: Done netdev_open(), status: %x.\n", + if (netif_msg_ifup(np)) + printk(KERN_DEBUG "%s: Done netdev_open(), status: %#08x.\n", dev->name, (int)readl(ioaddr + ChipCmd)); /* Set the timer to check for link beat. */ @@ -1057,19 +1081,18 @@ int duplex; int chipcfg = readl(ioaddr + ChipConfig); - if(!(chipcfg & CfgLink)) { + if (!(chipcfg & CfgLink)) { if (netif_carrier_ok(dev)) { - if (debug) - printk(KERN_INFO "%s: no link. Disabling watchdog.\n", + if (netif_msg_link(np)) + printk(KERN_NOTICE "%s: link down.\n", dev->name); netif_carrier_off(dev); } return; } if (!netif_carrier_ok(dev)) { - if (debug) - printk(KERN_INFO "%s: link is back. Enabling watchdog.\n", - dev->name); + if (netif_msg_link(np)) + printk(KERN_NOTICE "%s: link up.\n", dev->name); netif_carrier_on(dev); } @@ -1077,10 +1100,11 @@ /* if duplex is set then bit 28 must be set, too */ if (duplex ^ !!(np->rx_config & RxAcceptTx)) { - if (debug) - printk(KERN_INFO "%s: Setting %s-duplex based on negotiated link" - " capability.\n", dev->name, - duplex ? "full" : "half"); + if (netif_msg_link(np)) + printk(KERN_INFO + "%s: Setting %s-duplex based on negotiated " + "link capability.\n", dev->name, + duplex ? "full" : "half"); if (duplex) { np->rx_config |= RxAcceptTx; np->tx_config |= TxCarrierIgn | TxHeartIgn; @@ -1099,17 +1123,12 @@ long ioaddr = dev->base_addr; int i; - /* save the silicon revision for later */ - if (debug > 4) - printk(KERN_DEBUG "%s: found silicon revision %xh.\n", - dev->name, np->srr); - for (i=0;i<NATSEMI_HW_TIMEOUT;i++) { if (readl(dev->base_addr + ChipConfig) & CfgAnegDone) break; udelay(10); } - if (i==NATSEMI_HW_TIMEOUT && debug) { + if (i==NATSEMI_HW_TIMEOUT && netif_msg_link(np)) { printk(KERN_INFO "%s: autonegotiation did not complete in %d usec.\n", dev->name, i*10); @@ -1174,8 +1193,8 @@ * nothing will be written to memory. */ np->SavedClkRun = readl(ioaddr + ClkRun); writel(np->SavedClkRun & ~PMEEnable, ioaddr + ClkRun); - if (np->SavedClkRun & PMEStatus) { - printk(KERN_NOTICE "%s: Wake-up event %8.8x\n", + if (np->SavedClkRun & PMEStatus && netif_msg_wol(np)) { + printk(KERN_NOTICE "%s: Wake-up event %#08x\n", dev->name, readl(ioaddr + WOLCmd)); } @@ -1205,7 +1224,7 @@ long ioaddr = dev->base_addr; u16 dspcfg; - if (debug > 3) { + if (netif_msg_timer(np)) { /* DO NOT read the IntrStatus register, * a read clears any pending interrupts. */ @@ -1219,9 +1238,9 @@ writew(0, ioaddr+PGSEL); if (dspcfg != DSPCFG_VAL) { if (!netif_queue_stopped(dev)) { - printk(KERN_INFO - "%s: possible phy reset: re-initializing\n", - dev->name); + if (netif_msg_hw(np)) + printk(KERN_NOTICE "%s: possible phy reset: " + "re-initializing\n", dev->name); disable_irq(dev->irq); spin_lock_irq(&np->lock); init_registers(dev); @@ -1244,18 +1263,18 @@ { struct netdev_private *np = dev->priv; - if (debug > 2) { + if (netif_msg_pktdata(np)) { int i; printk(KERN_DEBUG " Tx ring at %p:\n", np->tx_ring); for (i = 0; i < TX_RING_SIZE; i++) { - printk(KERN_DEBUG " #%d desc. %8.8x %8.8x %8.8x.\n", + printk(KERN_DEBUG " #%d desc. %#08x %#08x %#08x.\n", i, np->tx_ring[i].next_desc, np->tx_ring[i].cmd_status, np->tx_ring[i].addr); } printk(KERN_DEBUG " Rx ring %p:\n", np->rx_ring); for (i = 0; i < RX_RING_SIZE; i++) { - printk(KERN_DEBUG " #%d desc. %8.8x %8.8x %8.8x.\n", + printk(KERN_DEBUG " #%d desc. %#08x %#08x %#08x.\n", i, np->rx_ring[i].next_desc, np->rx_ring[i].cmd_status, np->rx_ring[i].addr); @@ -1271,9 +1290,11 @@ disable_irq(dev->irq); spin_lock_irq(&np->lock); if (netif_device_present(dev)) { - printk(KERN_WARNING "%s: Transmit timed out, status %8.8x," - " resetting...\n", - dev->name, readl(ioaddr + IntrStatus)); + if (netif_msg_tx_err(np)) + printk(KERN_WARNING + "%s: Transmit timed out, status %#08x," + " resetting...\n", + dev->name, readl(ioaddr + IntrStatus)); dump_ring(dev); natsemi_reset(dev); @@ -1431,7 +1452,7 @@ dev->trans_start = jiffies; - if (debug > 4) { + if (netif_msg_tx_queued(np)) { printk(KERN_DEBUG "%s: Transmit frame #%d queued in slot %d.\n", dev->name, np->cur_tx, entry); } @@ -1445,13 +1466,14 @@ for (; np->cur_tx - np->dirty_tx > 0; np->dirty_tx++) { int entry = np->dirty_tx % TX_RING_SIZE; if (np->tx_ring[entry].cmd_status & cpu_to_le32(DescOwn)) { - if (debug > 4) + if (netif_msg_tx_err(np)) printk(KERN_DEBUG "%s: tx frame #%d is busy.\n", dev->name, np->dirty_tx); break; } - if (debug > 4) - printk(KERN_DEBUG "%s: tx frame #%d finished with status %8.8xh.\n", + if (netif_msg_tx_done(np)) + printk(KERN_DEBUG + "%s: tx frame #%d finished, status %#08x.\n", dev->name, np->dirty_tx, le32_to_cpu(np->tx_ring[entry].cmd_status)); if (np->tx_ring[entry].cmd_status & cpu_to_le32(DescPktOK)) { @@ -1488,21 +1510,18 @@ static void intr_handler(int irq, void *dev_instance, struct pt_regs *rgs) { struct net_device *dev = dev_instance; - struct netdev_private *np; - long ioaddr; + struct netdev_private *np = dev->priv; + long ioaddr = dev->base_addr; int boguscnt = max_interrupt_work; - ioaddr = dev->base_addr; - np = dev->priv; - if (!netif_device_present(dev)) return; do { /* Reading automatically acknowledges all int sources. */ u32 intr_status = readl(ioaddr + IntrStatus); - if (debug > 4) - printk(KERN_DEBUG "%s: Interrupt, status %4.4x.\n", + if (netif_msg_intr(np)) + printk(KERN_DEBUG "%s: Interrupt, status %#08x.\n", dev->name, intr_status); if (intr_status == 0) @@ -1523,13 +1542,13 @@ if (--boguscnt < 0) { printk(KERN_WARNING "%s: Too much work at interrupt, " - "status=0x%4.4x.\n", + "status=%#08x.\n", dev->name, intr_status); break; } } while (1); - if (debug > 4) + if (netif_msg_intr(np)) printk(KERN_DEBUG "%s: exiting interrupt.\n", dev->name); } @@ -1545,22 +1564,28 @@ /* If the driver owns the next entry it's a new packet. Send it up. */ while (desc_status < 0) { /* e.g. & DescOwn */ - if (debug > 4) - printk(KERN_DEBUG " In netdev_rx() entry %d status was %8.8x.\n", - entry, desc_status); + if (netif_msg_rx_status(np)) + printk(KERN_DEBUG + " netdev_rx() entry %d status was %#08x.\n", + entry, desc_status); if (--boguscnt < 0) break; - if ((desc_status & (DescMore|DescPktOK|DescRxLong)) != DescPktOK) { + if ((desc_status&(DescMore|DescPktOK|DescRxLong)) != DescPktOK){ if (desc_status & DescMore) { - printk(KERN_WARNING "%s: Oversized(?) Ethernet frame spanned " - "multiple buffers, entry %#x status %x.\n", - dev->name, np->cur_rx, desc_status); + if (netif_msg_rx_err(np)) + printk(KERN_WARNING + "%s: Oversized(?) Ethernet " + "frame spanned multiple " + "buffers, entry %#08x " + "status %#08x.\n", dev->name, + np->cur_rx, desc_status); np->stats.rx_length_errors++; } else { /* There was a error. */ - if (debug > 2) - printk(KERN_DEBUG " netdev_rx() Rx error was %8.8x.\n", - desc_status); + if (netif_msg_rx_err(np)) + printk(KERN_DEBUG + " netdev_rx() Rx error was " + "%#08x.\n", desc_status); np->stats.rx_errors++; if (desc_status & (DescRxAbort|DescRxOver)) np->stats.rx_over_errors++; @@ -1575,8 +1600,8 @@ struct sk_buff *skb; /* Omit CRC size. */ int pkt_len = (desc_status & DescSizeMask) - 4; - /* Check if the packet is long enough to accept without copying - to a minimally-sized skbuff. */ + /* Check if the packet is long enough to accept + * without copying to a minimally-sized skbuff. */ if (pkt_len < rx_copybreak && (skb = dev_alloc_skb(pkt_len + 2)) != NULL) { skb->dev = dev; @@ -1639,11 +1664,16 @@ spin_lock(&np->lock); if (intr_status & LinkChange) { - printk(KERN_NOTICE - "%s: Link changed: Autonegotiation advertising" - " %4.4x partner %4.4x.\n", dev->name, - (int)mdio_read(dev, 1, MII_ADVERTISE), - (int)mdio_read(dev, 1, MII_LPA)); + u16 adv = mdio_read(dev, 1, MII_ADVERTISE); + u16 lpa = mdio_read(dev, 1, MII_LPA); + if (mdio_read(dev, 1, MII_BMCR) & BMCR_ANENABLE + && netif_msg_link(np)) { + printk(KERN_INFO + "%s: Autonegotiation advertising" + " %#04x partner %#04x.\n", dev->name, + adv, lpa); + } + /* read MII int status to clear the flag */ readw(ioaddr + MIntrStatus); check_link(dev); @@ -1654,18 +1684,19 @@ if (intr_status & IntrTxUnderrun) { if ((np->tx_config & TxDrthMask) < 62) np->tx_config += 2; - if (debug > 2) - printk(KERN_NOTICE "%s: increasing Tx theshold, new tx cfg %8.8xh.\n", - dev->name, np->tx_config); + if (netif_msg_tx_err(np)) + printk(KERN_NOTICE + "%s: increased Tx theshold, txcfg %#08x.\n", + dev->name, np->tx_config); writel(np->tx_config, ioaddr + TxConfig); } - if (intr_status & WOLPkt) { + if (intr_status & WOLPkt && netif_msg_wol(np)) { int wol_status = readl(ioaddr + WOLCmd); - printk(KERN_NOTICE "%s: Link wake-up event %8.8x\n", + printk(KERN_NOTICE "%s: Link wake-up event %#08x\n", dev->name, wol_status); } if (intr_status & RxStatusFIFOOver) { - if (debug >= 2) { + if (netif_msg_rx_err(np) && netif_msg_intr(np)) { printk(KERN_NOTICE "%s: Rx status FIFO overrun\n", dev->name); } @@ -1673,10 +1704,8 @@ } /* Hmmmmm, it's not clear how to recover from PCI faults. */ if (intr_status & IntrPCIErr) { - if (debug) { - printk(KERN_NOTICE "%s: PCI error %08x\n", dev->name, - intr_status & IntrPCIErr); - } + printk(KERN_NOTICE "%s: PCI error %#08x\n", dev->name, + intr_status & IntrPCIErr); np->stats.tx_fifo_errors++; np->stats.rx_fifo_errors++; } @@ -1775,7 +1804,8 @@ if (dev->flags & IFF_PROMISC) { /* Set promiscuous. */ /* Unconditionally log net taps. */ - printk(KERN_NOTICE "%s: Promiscuous mode enabled.\n", dev->name); + printk(KERN_NOTICE "%s: Promiscuous mode enabled.\n", + dev->name); rx_mode = RxFilterEnable | AcceptBroadcast | AcceptAllMulticast | AcceptAllPhys | AcceptMyPhys; } else if ((dev->mc_count > multicast_filter_limit) @@ -1910,7 +1940,7 @@ /* get message-level */ case ETHTOOL_GMSGLVL: { struct ethtool_value edata = {ETHTOOL_GMSGLVL}; - edata.data = debug; + edata.data = np->msg_enable; if (copy_to_user(useraddr, &edata, sizeof(edata))) return -EFAULT; return 0; @@ -1920,7 +1950,7 @@ struct ethtool_value edata; if (copy_from_user(&edata, useraddr, sizeof(edata))) return -EFAULT; - debug = edata.data; + np->msg_enable = edata.data; return 0; } /* restart autonegotiation */ @@ -2108,18 +2138,22 @@ ecmd->supported = (SUPPORTED_10baseT_Half | SUPPORTED_10baseT_Full | SUPPORTED_100baseT_Half | SUPPORTED_100baseT_Full | - SUPPORTED_Autoneg | SUPPORTED_TP); + SUPPORTED_Autoneg | SUPPORTED_TP | SUPPORTED_MII); - /* only supports twisted-pair */ - ecmd->port = PORT_TP; + /* only supports twisted-pair or MII */ + tmp = readl(dev->base_addr + ChipConfig); + if (tmp & CfgExtPhy) + ecmd->port = PORT_MII; + else + ecmd->port = PORT_TP; /* only supports internal transceiver */ ecmd->transceiver = XCVR_INTERNAL; - /* this isn't fully supported at higher layers */ + /* not sure what this is for */ ecmd->phy_address = readw(dev->base_addr + PhyCtrl) & PhyAddrMask; - ecmd->advertising = ADVERTISED_TP; + ecmd->advertising = ADVERTISED_TP | ADVERTISED_MII; tmp = mdio_read(dev, 1, MII_ADVERTISE); if (tmp & ADVERTISE_10HALF) ecmd->advertising |= ADVERTISED_10baseT_Half; @@ -2130,20 +2164,21 @@ if (tmp & ADVERTISE_100FULL) ecmd->advertising |= ADVERTISED_100baseT_Full; - tmp = readl(dev->base_addr + ChipConfig); - if (tmp & CfgAnegEnable) { + tmp = mdio_read(dev, 1, MII_BMCR); + if (tmp & BMCR_ANENABLE) { ecmd->advertising |= ADVERTISED_Autoneg; ecmd->autoneg = AUTONEG_ENABLE; } else { ecmd->autoneg = AUTONEG_DISABLE; } + tmp = readl(dev->base_addr + ChipConfig); if (tmp & CfgSpeed100) { ecmd->speed = SPEED_100; } else { ecmd->speed = SPEED_10; } - + if (tmp & CfgFullDuplex) { ecmd->duplex = DUPLEX_FULL; } else { @@ -2164,7 +2199,7 @@ return -EINVAL; if (ecmd->duplex != DUPLEX_HALF && ecmd->duplex != DUPLEX_FULL) return -EINVAL; - if (ecmd->port != PORT_TP) + if (ecmd->port != PORT_TP && ecmd->port != PORT_MII) return -EINVAL; if (ecmd->transceiver != XCVR_INTERNAL) return -EINVAL; @@ -2174,39 +2209,22 @@ /* WHEW! now lets bang some bits */ + tmp = mdio_read(dev, 1, MII_BMCR); if (ecmd->autoneg == AUTONEG_ENABLE) { - /* advertise only what has been requested */ - tmp = readl(dev->base_addr + ChipConfig); - tmp &= ~(CfgAneg100 | CfgAnegFull); - tmp |= CfgAnegEnable; - if (ecmd->advertising & ADVERTISED_100baseT_Half - || ecmd->advertising & ADVERTISED_100baseT_Full) { - tmp |= CfgAneg100; - } - if (ecmd->advertising & ADVERTISED_10baseT_Full - || ecmd->advertising & ADVERTISED_100baseT_Full) { - tmp |= CfgAnegFull; - } - writel(tmp, dev->base_addr + ChipConfig); - /* turn on autonegotiation, and force a renegotiate */ - tmp = mdio_read(dev, 1, MII_BMCR); - tmp |= (BMCR_ANENABLE | BMCR_ANRESTART); - mdio_write(dev, 1, MII_BMCR, tmp); + /* turn on autonegotiation */ + tmp |= BMCR_ANENABLE; np->advertising = mdio_read(dev, 1, MII_ADVERTISE); } else { /* turn off auto negotiation, set speed and duplexity */ - tmp = mdio_read(dev, 1, MII_BMCR); tmp &= ~(BMCR_ANENABLE | BMCR_SPEED100 | BMCR_FULLDPLX); - if (ecmd->speed == SPEED_100) { + if (ecmd->speed == SPEED_100) tmp |= BMCR_SPEED100; - } - if (ecmd->duplex == DUPLEX_FULL) { + if (ecmd->duplex == DUPLEX_FULL) tmp |= BMCR_FULLDPLX; - } else { + else np->full_duplex = 0; - } - mdio_write(dev, 1, MII_BMCR, tmp); } + mdio_write(dev, 1, MII_BMCR, tmp); return 0; } @@ -2241,7 +2259,7 @@ /* the interrupt status is clear-on-read - see if we missed any */ if (rbuf[4] & rbuf[5]) { printk(KERN_WARNING - "%s: shoot, we dropped an interrupt (0x%x)\n", + "%s: shoot, we dropped an interrupt (%#08x)\n", dev->name, rbuf[4] & rbuf[5]); } @@ -2308,7 +2326,7 @@ long ioaddr = dev->base_addr; struct netdev_private *np = dev->priv; - if (debug > 1) + if (netif_msg_wol(np)) printk(KERN_INFO "%s: remaining active for wake-on-lan\n", dev->name); @@ -2343,12 +2361,15 @@ netif_stop_queue(dev); netif_carrier_off(dev); - if (debug > 1) { - printk(KERN_DEBUG "%s: Shutting down ethercard, status was %4.4x.\n", - dev->name, (int)readl(ioaddr + ChipCmd)); - printk(KERN_DEBUG "%s: Queue pointers were Tx %d / %d, Rx %d / %d.\n", - dev->name, np->cur_tx, np->dirty_tx, np->cur_rx, np->dirty_rx); - } + if (netif_msg_ifdown(np)) + printk(KERN_DEBUG + "%s: Shutting down ethercard, status was %#04x.\n", + dev->name, (int)readl(ioaddr + ChipCmd)); + if (netif_msg_pktdata(np)) + printk(KERN_DEBUG + "%s: Queue pointers were Tx %d / %d, Rx %d / %d.\n", + dev->name, np->cur_tx, np->dirty_tx, + np->cur_rx, np->dirty_rx); del_timer_sync(&np->timer); @@ -2518,7 +2539,7 @@ name: DRV_NAME, id_table: natsemi_pci_tbl, probe: natsemi_probe1, - remove: natsemi_remove1, + remove: __devexit_p(natsemi_remove1), #ifdef CONFIG_PM suspend: natsemi_suspend, resume: natsemi_resume, diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/net/ne2k-pci.c linux-2.5/drivers/net/ne2k-pci.c --- linux-2.5.1/drivers/net/ne2k-pci.c Sun Sep 30 19:26:07 2001 +++ linux-2.5/drivers/net/ne2k-pci.c Thu Dec 13 16:32:36 2001 @@ -642,7 +642,7 @@ static struct pci_driver ne2k_driver = { name: DRV_NAME, probe: ne2k_pci_init_one, - remove: ne2k_pci_remove_one, + remove: __devexit_p(ne2k_pci_remove_one), id_table: ne2k_pci_tbl, }; diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/net/ns83820.c linux-2.5/drivers/net/ns83820.c --- linux-2.5.1/drivers/net/ns83820.c Fri Nov 9 21:45:35 2001 +++ linux-2.5/drivers/net/ns83820.c Thu Dec 13 22:09:29 2001 @@ -1,7 +1,7 @@ -#define VERSION "0.13" -/* ns83820.c by Benjamin LaHaise <bcrl@redhat.com> +#define _VERSION "0.15" +/* ns83820.c by Benjamin LaHaise <bcrl@redhat.com> with contributions. * - * $Revision: 1.34.2.8 $ + * $Revision: 1.34.2.12 $ * * Copyright 2001 Benjamin LaHaise. * Copyright 2001 Red Hat. @@ -45,6 +45,12 @@ * 0.12 - add statistics counters * - add allmulti/promisc support * 20011009 0.13 - hotplug support, other smaller pci api cleanups + * 20011204 0.13a - optical transceiver support added + * by Michael Clark <michael@metaparadigm.com> + * 20011205 0.13b - call register_netdev earlier in initialization + * suppress duplicate link status messages + * 20011117 0.14 - ethtool GDRVINFO, GLINK support from jgarzik + * 20011204 0.15 get ppc (big endian) working * * Driver Overview * =============== @@ -65,6 +71,7 @@ * D-Link DGE-500T * PureData PDP8023Z-TG * SMC SMC9452TX SMC9462TX + * Netgear GA621 * * Special thanks to SMC for providing hardware to test this driver on. * @@ -86,23 +93,25 @@ #include <linux/in.h> /* for IPPROTO_... */ #include <linux/eeprom.h> #include <linux/compiler.h> +#include <linux/ethtool.h> //#include <linux/skbrefill.h> #include <asm/io.h> +#include <asm/uaccess.h> /* Dprintk is used for more interesting debug events */ #undef Dprintk #define Dprintk dprintk #ifdef CONFIG_HIGHMEM64G -#define USE_64BIT_ADDR +#define USE_64BIT_ADDR "+" #elif defined(__ia64__) -#define USE_64BIT_ADDR +#define USE_64BIT_ADDR "+" #endif /* Tell davem to fix the pci dma api. Grrr. */ /* stolen from acenic.c */ -#ifdef CONFIG_HIGHMEM +#if 0 //def CONFIG_HIGHMEM #if defined(CONFIG_X86) #define DMAADDR_OFFSET 0 #if defined(CONFIG_HIGHMEM64G) @@ -138,6 +147,12 @@ } #endif +#if defined(USE_64BIT_ADDR) +#define VERSION _VERSION USE_64BIT_ADDR +#else +#define VERSION _VERSION +#endif + /* tunables */ #define RX_BUF_SIZE 6144 /* 8192 */ #define NR_RX_DESC 256 @@ -213,6 +228,7 @@ #define CFG_DUPSTS 0x10000000 #define CFG_TBI_EN 0x01000000 #define CFG_MODE_1000 0x00400000 +#define CFG_AUTO_1000 0x00200000 #define CFG_PINT_CTL 0x001c0000 #define CFG_PINT_DUPSTS 0x00100000 #define CFG_PINT_LNKSTS 0x00080000 @@ -316,6 +332,36 @@ #define VDR 0xc4 #define CCSR 0xcc +#define TBICR 0xe0 +#define TBISR 0xe4 +#define TANAR 0xe8 +#define TANLPAR 0xec +#define TANER 0xf0 +#define TESR 0xf4 + +#define TBICR_MR_AN_ENABLE 0x00001000 +#define TBICR_MR_RESTART_AN 0x00000200 + +#define TBISR_MR_LINK_STATUS 0x00000020 +#define TBISR_MR_AN_COMPLETE 0x00000004 + +#define TANAR_PS2 0x00000100 +#define TANAR_PS1 0x00000080 +#define TANAR_HALF_DUP 0x00000040 +#define TANAR_FULL_DUP 0x00000020 + +#define GPIOR_GP5_OE 0x00000200 +#define GPIOR_GP4_OE 0x00000100 +#define GPIOR_GP3_OE 0x00000080 +#define GPIOR_GP2_OE 0x00000040 +#define GPIOR_GP1_OE 0x00000020 +#define GPIOR_GP3_OUT 0x00000004 +#define GPIOR_GP1_OUT 0x00000001 + +#define LINK_AUTONEGOTIATE 0x01 +#define LINK_DOWN 0x02 +#define LINK_UP 0x04 + #define __kick_rx(dev) writel(CR_RXE, dev->base + CR) #define kick_rx(dev) do { \ @@ -390,6 +436,7 @@ u32 IMR_cache; struct eeprom ee; + unsigned linkstate; spinlock_t tx_lock; @@ -441,11 +488,11 @@ static inline void build_rx_desc32(struct ns83820 *dev, u32 *desc, u32 link, u32 buf, u32 cmdsts, u32 extsts) { - desc[0] = link; - desc[1] = buf; - desc[3] = extsts; + desc[0] = cpu_to_le32(link); + desc[1] = cpu_to_le32(buf); + desc[3] = cpu_to_le32(extsts); mb(); - desc[2] = cmdsts; + desc[2] = cpu_to_le32(cmdsts); } #define build_rx_desc build_rx_desc32 @@ -486,7 +533,7 @@ build_rx_desc(dev, sg, 0, buf, cmdsts, 0); /* update link of previous rx */ if (next_empty != dev->rx_info.next_rx) - dev->rx_info.descs[((NR_RX_DESC + next_empty - 1) % NR_RX_DESC) * DESC_SIZE] = dev->rx_info.phy_descs + (next_empty * DESC_SIZE * 4); + dev->rx_info.descs[((NR_RX_DESC + next_empty - 1) % NR_RX_DESC) * DESC_SIZE] = cpu_to_le32(dev->rx_info.phy_descs + (next_empty * DESC_SIZE * 4)); return 0; } @@ -545,39 +592,93 @@ static void phy_intr(struct ns83820 *dev) { - static char *speeds[] = { "10", "100", "1000", "1000(?)" }; + static char *speeds[] = { "10", "100", "1000", "1000(?)", "1000F" }; u32 cfg, new_cfg; + u32 tbisr, tanar, tanlpar; + int speed, fullduplex, newlinkstate; - new_cfg = dev->CFG_cache & ~(CFG_SB | CFG_MODE_1000 | CFG_SPDSTS); cfg = readl(dev->base + CFG) ^ SPDSTS_POLARITY; - if (cfg & CFG_SPDSTS1) - new_cfg |= CFG_MODE_1000 | CFG_SB; - else - new_cfg &= ~CFG_MODE_1000 | CFG_SB; + if (dev->CFG_cache & CFG_TBI_EN) { - if ((cfg & CFG_LNKSTS) && ((new_cfg ^ dev->CFG_cache) & CFG_MODE_1000)) { - writel(new_cfg, dev->base + CFG); - dev->CFG_cache = new_cfg; - } + /* we have an optical transceiver */ + tbisr = readl(dev->base + TBISR); + tanar = readl(dev->base + TANAR); + tanlpar = readl(dev->base + TANLPAR); + dprintk("phy_intr: tbisr=%08x, tanar=%08x, tanlpar=%08x\n", + tbisr, tanar, tanlpar); + + if ( (fullduplex = (tanlpar & TANAR_FULL_DUP) + && (tanar & TANAR_FULL_DUP)) ) { + + /* both of us are full duplex */ + writel(readl(dev->base + TXCFG) + | TXCFG_CSI | TXCFG_HBI | TXCFG_ATP, + dev->base + TXCFG); + writel(readl(dev->base + RXCFG) | RXCFG_RX_FD, + dev->base + RXCFG); + /* Light up full duplex LED */ + writel(readl(dev->base + GPIOR) | GPIOR_GP1_OUT, + dev->base + GPIOR); + + } else if(((tanlpar & TANAR_HALF_DUP) + && (tanar & TANAR_HALF_DUP)) + || ((tanlpar & TANAR_FULL_DUP) + && (tanar & TANAR_HALF_DUP)) + || ((tanlpar & TANAR_HALF_DUP) + && (tanar & TANAR_FULL_DUP))) { + + /* one or both of us are half duplex */ + writel((readl(dev->base + TXCFG) + & ~(TXCFG_CSI | TXCFG_HBI)) | TXCFG_ATP, + dev->base + TXCFG); + writel(readl(dev->base + RXCFG) & ~RXCFG_RX_FD, + dev->base + RXCFG); + /* Turn off full duplex LED */ + writel(readl(dev->base + GPIOR) & ~GPIOR_GP1_OUT, + dev->base + GPIOR); + } - dev->CFG_cache &= ~CFG_SPDSTS; - dev->CFG_cache |= cfg & CFG_SPDSTS; + speed = 4; /* 1000F */ - if (cfg & CFG_LNKSTS) { - netif_start_queue(&dev->net_dev); - netif_wake_queue(&dev->net_dev); } else { - netif_stop_queue(&dev->net_dev); + /* we have a copper transceiver */ + new_cfg = dev->CFG_cache & ~(CFG_SB | CFG_MODE_1000 | CFG_SPDSTS); + + if (cfg & CFG_SPDSTS1) + new_cfg |= CFG_MODE_1000 | CFG_SB; + else + new_cfg &= ~CFG_MODE_1000 | CFG_SB; + + if ((cfg & CFG_LNKSTS) && ((new_cfg ^ dev->CFG_cache) & CFG_MODE_1000)) { + writel(new_cfg, dev->base + CFG); + dev->CFG_cache = new_cfg; + } + + dev->CFG_cache &= ~CFG_SPDSTS; + dev->CFG_cache |= cfg & CFG_SPDSTS; + + speed = ((cfg / CFG_SPDSTS0) & 3); + fullduplex = (cfg & CFG_DUPSTS); } - if (cfg & CFG_LNKSTS) + newlinkstate = (cfg & CFG_LNKSTS) ? LINK_UP : LINK_DOWN; + + if (newlinkstate & LINK_UP + && dev->linkstate != newlinkstate) { + netif_start_queue(&dev->net_dev); + netif_wake_queue(&dev->net_dev); printk(KERN_INFO "%s: link now %s mbps, %s duplex and up.\n", dev->net_dev.name, - speeds[((cfg / CFG_SPDSTS0) & 3)], - (cfg & CFG_DUPSTS) ? "full" : "half"); - else + speeds[speed], + fullduplex ? "full" : "half"); + } else if (newlinkstate & LINK_DOWN + && dev->linkstate != newlinkstate) { + netif_stop_queue(&dev->net_dev); printk(KERN_INFO "%s: link now down.\n", dev->net_dev.name); + } + + dev->linkstate = newlinkstate; } static int ns83820_setup_rx(struct ns83820 *dev) @@ -698,15 +799,15 @@ dprintk("walking descs\n"); next_rx = info->next_rx; desc = info->descs + (DESC_SIZE * next_rx); - while ((CMDSTS_OWN & (cmdsts = desc[CMDSTS])) && + while ((CMDSTS_OWN & (cmdsts = le32_to_cpu(desc[CMDSTS]))) && (cmdsts != CMDSTS_OWN)) { struct sk_buff *skb; - u32 extsts = desc[EXTSTS]; - dmaaddr_high_t bufptr = *(hw_addr_t *)(desc + BUFPTR); + u32 extsts = le32_to_cpu(desc[EXTSTS]); + dmaaddr_high_t bufptr = le32_to_cpu(desc[BUFPTR]); dprintk("cmdsts: %08x\n", cmdsts); - dprintk("link: %08x\n", desc[LINK]); - dprintk("extsts: %08x\n", desc[EXTSTS]); + dprintk("link: %08x\n", cpu_to_le32(desc[LINK])); + dprintk("extsts: %08x\n", extsts); skb = info->skbs[next_rx]; info->skbs[next_rx] = NULL; @@ -718,14 +819,14 @@ pci_unmap_single(dev->pci_dev, bufptr, RX_BUF_SIZE, PCI_DMA_FROMDEVICE); if (CMDSTS_OK & cmdsts) { -#ifndef __i386__ +#if 0 //ndef __i386__ struct sk_buff *tmp; #endif int len = cmdsts & 0xffff; if (!skb) BUG(); skb_put(skb, len); -#ifndef __i386__ /* I hate the network stack sometimes */ +#if 0 //ndef __i386__ /* I hate the network stack sometimes */ tmp = __dev_alloc_skb(RX_BUF_SIZE+16, GFP_ATOMIC); if (!tmp) goto done; @@ -788,9 +889,9 @@ desc = dev->tx_descs + (tx_done_idx * DESC_SIZE); dprintk("tx_done_idx=%d free_idx=%d cmdsts=%08x\n", - tx_done_idx, dev->tx_free_idx, desc[CMDSTS]); + tx_done_idx, dev->tx_free_idx, le32_to_cpu(desc[CMDSTS])); while ((tx_done_idx != dev->tx_free_idx) && - !(CMDSTS_OWN & (cmdsts = desc[CMDSTS])) ) { + !(CMDSTS_OWN & (cmdsts = le32_to_cpu(desc[CMDSTS]))) ) { struct sk_buff *skb; if (cmdsts & CMDSTS_ERR) @@ -801,13 +902,13 @@ dev->stats.tx_bytes += cmdsts & 0xffff; dprintk("tx_done_idx=%d free_idx=%d cmdsts=%08x\n", - tx_done_idx, dev->tx_free_idx, desc[CMDSTS]); + tx_done_idx, dev->tx_free_idx, cmdsts); skb = dev->tx_skbs[tx_done_idx]; dev->tx_skbs[tx_done_idx] = NULL; dprintk("done(%p)\n", skb); if (skb) { pci_unmap_single(dev->pci_dev, - *(hw_addr_t *)(desc + BUFPTR), + le32_to_cpu(desc[BUFPTR]), skb->len, PCI_DMA_TODEVICE); dev_kfree_skb_irq(skb); @@ -815,7 +916,7 @@ tx_done_idx = (tx_done_idx + 1) % NR_TX_DESC; dev->tx_done_idx = tx_done_idx; - desc[CMDSTS] = 0; + desc[CMDSTS] = cpu_to_le32(0); barrier(); desc = dev->tx_descs + (tx_done_idx * DESC_SIZE); } @@ -936,17 +1037,17 @@ } #endif - dprintk("frag[%3u]: %4u @ 0x%x%08Lx\n", free_idx, len, + dprintk("frag[%3u]: %4u @ 0x%08Lx\n", free_idx, len, (unsigned long long)buf); free_idx = (free_idx + 1) % NR_TX_DESC; - desc[LINK] = dev->tx_phy_descs + (free_idx * DESC_SIZE * 4); - *(hw_addr_t *)(desc + BUFPTR) = buf; - desc[EXTSTS] = extsts; + desc[LINK] = cpu_to_le32(dev->tx_phy_descs + (free_idx * DESC_SIZE * 4)); + desc[BUFPTR] = cpu_to_le32(buf); + desc[EXTSTS] = cpu_to_le32(extsts); cmdsts = ((nr_frags|residue) ? CMDSTS_MORE : do_intr ? CMDSTS_INTR : 0); cmdsts |= (desc == first_desc) ? 0 : CMDSTS_OWN; cmdsts |= len; - desc[CMDSTS] = cmdsts; + desc[CMDSTS] = cpu_to_le32(cmdsts); if (residue) { buf += len; @@ -957,7 +1058,8 @@ if (!nr_frags) break; - buf = pci_map_single_high(dev->pci_dev, frag->page, 0, + buf = pci_map_single_high(dev->pci_dev, frag->page, + frag->page_offset, frag->size, PCI_DMA_TODEVICE); dprintk("frag: buf=%08Lx page=%08lx\n", (long long)buf, (long)(frag->page - mem_map)); @@ -967,7 +1069,7 @@ } dprintk("done pkt\n"); dev->tx_skbs[free_idx] = skb; - first_desc[CMDSTS] |= CMDSTS_OWN; + first_desc[CMDSTS] |= cpu_to_le32(CMDSTS_OWN); dev->tx_free_idx = free_idx; kick_tx(dev); @@ -1007,6 +1109,59 @@ return &dev->stats; } +static int ns83820_ethtool_ioctl (struct ns83820 *dev, void *useraddr) +{ + u32 ethcmd; + + if (copy_from_user(ðcmd, useraddr, sizeof (ethcmd))) + return -EFAULT; + + switch (ethcmd) { + case ETHTOOL_GDRVINFO: + { + struct ethtool_drvinfo info = { ETHTOOL_GDRVINFO }; + strcpy(info.driver, "ns83820"); + strcpy(info.version, VERSION); + strcpy(info.bus_info, dev->pci_dev->slot_name); + if (copy_to_user(useraddr, &info, sizeof (info))) + return -EFAULT; + return 0; + } + + /* get link status */ + case ETHTOOL_GLINK: { + struct ethtool_value edata = { ETHTOOL_GLINK }; + u32 cfg = readl(dev->base + CFG) ^ SPDSTS_POLARITY; + + if (cfg & CFG_LNKSTS) + edata.data = 1; + else + edata.data = 0; + if (copy_to_user(useraddr, &edata, sizeof(edata))) + return -EFAULT; + return 0; + } + + default: + break; + } + + return -EOPNOTSUPP; +} + +static int ns83820_ioctl(struct net_device *_dev, struct ifreq *rq, int cmd) +{ + struct ns83820 *dev = _dev->priv; + + switch(cmd) { + case SIOCETHTOOL: + return ns83820_ethtool_ioctl(dev, (void *) rq->ifr_data); + + default: + return -EOPNOTSUPP; + } +} + static void ns83820_irq(int foo, void *data, struct pt_regs *regs) { struct ns83820 *dev = data; @@ -1048,10 +1203,14 @@ Dprintk("BAD\n"); } - if (ISR_RXSOVR & isr) - Dprintk("overrun\n"); - if (ISR_RXORN & isr) - Dprintk("overrun\n"); + if (unlikely(ISR_RXSOVR & isr)) { + Dprintk("overrun: rxsovr\n"); + dev->stats.rx_over_errors ++; + } + if (unlikely(ISR_RXORN & isr)) { + Dprintk("overrun: rxorn\n"); + dev->stats.rx_over_errors ++; + } if ((ISR_RXRCMP & isr) && dev->rx_info.up) writel(CR_RXE, dev->base + CR); @@ -1150,9 +1309,10 @@ memset(dev->tx_descs, 0, 4 * NR_TX_DESC * DESC_SIZE); for (i=0; i<NR_TX_DESC; i++) { - *(hw_addr_t *)(dev->tx_descs + (i * DESC_SIZE) + LINK) - = dev->tx_phy_descs - + ((i+1) % NR_TX_DESC) * DESC_SIZE * 4; + dev->tx_descs[(i * DESC_SIZE) + LINK] + = cpu_to_le32( + dev->tx_phy_descs + + ((i+1) % NR_TX_DESC) * DESC_SIZE * 4); } dev->tx_idx = 0; @@ -1190,6 +1350,9 @@ #if 0 /* I've left this in as an example of how to use eeprom.h */ data = eeprom_readw(&dev->ee, 0xa + 2 - i); #else + /* Read from the perfect match memory: this is loaded by + * the chip from the EEPROM via the EELOAD self test. + */ writel(i*2, dev->base + RFCR); data = readl(dev->base + RFDR); #endif @@ -1287,6 +1450,8 @@ goto out_unmap; } + if(register_netdev(&dev->net_dev)) goto out_unmap; + dev->net_dev.open = ns83820_open; dev->net_dev.stop = ns83820_stop; dev->net_dev.hard_start_xmit = ns83820_hard_start_xmit; @@ -1294,6 +1459,7 @@ dev->net_dev.get_stats = ns83820_get_stats; dev->net_dev.change_mtu = ns83820_change_mtu; dev->net_dev.set_multicast_list = ns83820_set_multicast; + dev->net_dev.do_ioctl = ns83820_ioctl; //FIXME: dev->net_dev.tx_timeout = ns83820_tx_timeout; pci_set_drvdata(pci_dev, dev); @@ -1318,12 +1484,15 @@ dev->CFG_cache = readl(dev->base + CFG); if ((dev->CFG_cache & CFG_PCI64_DET)) { - printk("%s: enabling 64 bit PCI.\n", dev->net_dev.name); + printk("%s: enabling 64 bit PCI addressing.\n", + dev->net_dev.name); dev->CFG_cache |= CFG_T64ADDR | CFG_DATA64_EN; - } else { - printk("%s: disabling 64 bit PCI.\n", dev->net_dev.name); +#if defined(USE_64BIT_ADDR) + dev->net_dev.features |= NETIF_F_HIGHDMA; +#endif + } else dev->CFG_cache &= ~(CFG_T64ADDR | CFG_DATA64_EN); - } + dev->CFG_cache &= (CFG_TBI_EN | CFG_MRM_DIS | CFG_MWI_DIS | CFG_T64ADDR | CFG_DATA64_EN | CFG_EXT_125 | CFG_M64ADDR); @@ -1333,15 +1502,28 @@ dev->CFG_cache |= CFG_POW; #ifdef USE_64BIT_ADDR dev->CFG_cache |= CFG_M64ADDR; - printk("using 64 bit addressing\n"); #endif -#ifdef __LITTLE_ENDIAN + /* Big endian mode does not seem to do what the docs suggest */ dev->CFG_cache &= ~CFG_BEM; -#elif defined(__BIG_ENDIAN) - dev->CFG_cache |= CFG_BEM; -#else -#error This driver only works for big or little endian!!! -#endif + + /* setup optical transceiver if we have one */ + if (dev->CFG_cache & CFG_TBI_EN) { + printk("%s: enabling optical transceiver\n", dev->net_dev.name); + writel(readl(dev->base + GPIOR) | 0x3e8, dev->base + GPIOR); + + /* setup auto negotiation feature advertisement */ + writel(readl(dev->base + TANAR) + | TANAR_HALF_DUP | TANAR_FULL_DUP, + dev->base + TANAR); + + /* start auto negotiation */ + writel(TBICR_MR_AN_ENABLE | TBICR_MR_RESTART_AN, + dev->base + TBICR); + writel(TBICR_MR_AN_ENABLE, dev->base + TBICR); + dev->linkstate = LINK_AUTONEGOTIATE; + + dev->CFG_cache |= CFG_MODE_1000; + } writel(dev->CFG_cache, dev->base + CFG); dprintk("CFG: %08x\n", dev->CFG_cache); @@ -1397,15 +1579,15 @@ dev->net_dev.features |= NETIF_F_HIGHDMA; #endif - register_netdev(&dev->net_dev); - - printk(KERN_INFO "%s: ns83820.c v" VERSION ": DP83820 %02x:%02x:%02x:%02x:%02x:%02x pciaddr=0x%08lx irq=%d rev 0x%x\n", + printk(KERN_INFO "%s: ns83820 v" VERSION ": DP83820 v%u.%u: %02x:%02x:%02x:%02x:%02x:%02x io=0x%08lx irq=%d f=%s\n", dev->net_dev.name, + (unsigned)readl(dev->base + SRR) >> 8, + (unsigned)readl(dev->base + SRR) & 0xff, dev->net_dev.dev_addr[0], dev->net_dev.dev_addr[1], dev->net_dev.dev_addr[2], dev->net_dev.dev_addr[3], dev->net_dev.dev_addr[4], dev->net_dev.dev_addr[5], addr, pci_dev->irq, - (unsigned)readl(dev->base + SRR) + (dev->net_dev.features & NETIF_F_HIGHDMA) ? "sg" : "h,sg" ); return 0; @@ -1455,7 +1637,7 @@ name: "ns83820", id_table: ns83820_pci_tbl, probe: ns83820_init_one, - remove: ns83820_remove_one, + remove: __devexit_p(ns83820_remove_one), #if 0 /* FIXME: implement */ suspend: , resume: , diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/net/pci-skeleton.c linux-2.5/drivers/net/pci-skeleton.c --- linux-2.5.1/drivers/net/pci-skeleton.c Wed Oct 17 04:56:29 2001 +++ linux-2.5/drivers/net/pci-skeleton.c Thu Dec 13 16:32:36 2001 @@ -834,7 +834,7 @@ printk (KERN_INFO "%s: Media type forced to Full Duplex.\n", dev->name); - mdio_write (dev, tp->phys[0], 4, 0x141); + mdio_write (dev, tp->phys[0], MII_ADVERTISE, ADVERTISE_FULL); tp->duplex_lock = 1; } @@ -1235,20 +1235,20 @@ struct netdrv_private *tp = dev->priv; void *ioaddr = tp->mmio_addr; int next_tick = 60 * HZ; - int mii_reg5; + int mii_lpa; - mii_reg5 = mdio_read (dev, tp->phys[0], 5); + mii_lpa = mdio_read (dev, tp->phys[0], MII_LPA); - if (!tp->duplex_lock && mii_reg5 != 0xffff) { - int duplex = (mii_reg5 & 0x0100) - || (mii_reg5 & 0x01C0) == 0x0040; + if (!tp->duplex_lock && mii_lpa != 0xffff) { + int duplex = (mii_lpa & LPA_100FULL) + || (mii_lpa & 0x01C0) == 0x0040; if (tp->full_duplex != duplex) { tp->full_duplex = duplex; printk (KERN_INFO "%s: Setting %s-duplex based on MII #%d link" " partner ability of %4.4x.\n", dev->name, tp->full_duplex ? "full" : "half", - tp->phys[0], mii_reg5); + tp->phys[0], mii_lpa); NETDRV_W8 (Cfg9346, Cfg9346_Unlock); NETDRV_W8 (Config1, tp->full_duplex ? 0x60 : 0x20); NETDRV_W8 (Cfg9346, Cfg9346_Lock); @@ -1980,7 +1980,7 @@ name: MODNAME, id_table: netdrv_pci_tbl, probe: netdrv_init_one, - remove: netdrv_remove_one, + remove: __devexit_p(netdrv_remove_one), #ifdef CONFIG_PM suspend: netdrv_suspend, resume: netdrv_resume, diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/net/pcmcia/3c589_cs.c linux-2.5/drivers/net/pcmcia/3c589_cs.c --- linux-2.5.1/drivers/net/pcmcia/3c589_cs.c Tue Nov 13 17:02:30 2001 +++ linux-2.5/drivers/net/pcmcia/3c589_cs.c Thu Dec 27 16:32:31 2001 @@ -17,6 +17,9 @@ ======================================================================*/ +#define DRV_NAME "3c589_cs" +#define DRV_VERSION "1.162" + #include <linux/module.h> #include <linux/init.h> #include <linux/kernel.h> @@ -28,6 +31,9 @@ #include <linux/interrupt.h> #include <linux/in.h> #include <linux/delay.h> +#include <linux/ethtool.h> + +#include <asm/uaccess.h> #include <asm/io.h> #include <asm/system.h> #include <asm/bitops.h> @@ -134,7 +140,7 @@ INT_MODULE_PARM(pc_debug, PCMCIA_DEBUG); #define DEBUG(n, args...) if (pc_debug>(n)) printk(KERN_DEBUG args) static char *version = -"3c589_cs.c 1.162 2001/10/13 00:08:50 (David Hinds)"; +DRV_NAME ".c " DRV_VERSION " 2001/10/13 00:08:50 (David Hinds)"; #else #define DEBUG(n, args...) #endif @@ -159,6 +165,7 @@ static int el3_close(struct net_device *dev); static void el3_tx_timeout(struct net_device *dev); static void set_multicast_list(struct net_device *dev); +static int netdev_ioctl (struct net_device *dev, struct ifreq *rq, int cmd); static dev_info_t dev_info = "3c589_cs"; @@ -249,7 +256,8 @@ dev->tx_timeout = el3_tx_timeout; dev->watchdog_timeo = TX_TIMEOUT; #endif - + dev->do_ioctl = netdev_ioctl; + /* Register with Card Services */ link->next = dev_list; dev_list = link; @@ -638,6 +646,71 @@ ioaddr + EL3_CMD); outw(SetIntrEnb | IntLatch | TxAvailable | RxComplete | StatsFull | AdapterFailure, ioaddr + EL3_CMD); +} + +static int netdev_ethtool_ioctl (struct net_device *dev, void *useraddr) +{ + u32 ethcmd; + + /* dev_ioctl() in ../../net/core/dev.c has already checked + capable(CAP_NET_ADMIN), so don't bother with that here. */ + + if (get_user(ethcmd, (u32 *)useraddr)) + return -EFAULT; + + switch (ethcmd) { + + case ETHTOOL_GDRVINFO: { + struct ethtool_drvinfo info = { ETHTOOL_GDRVINFO }; + strcpy (info.driver, DRV_NAME); + strcpy (info.version, DRV_VERSION); + sprintf(info.bus_info, "PCMCIA 0x%lx", dev->base_addr); + if (copy_to_user (useraddr, &info, sizeof (info))) + return -EFAULT; + return 0; + } + +#ifdef PCMCIA_DEBUG + /* get message-level */ + case ETHTOOL_GMSGLVL: { + struct ethtool_value edata = {ETHTOOL_GMSGLVL}; + edata.data = pc_debug; + if (copy_to_user(useraddr, &edata, sizeof(edata))) + return -EFAULT; + return 0; + } + /* set message-level */ + case ETHTOOL_SMSGLVL: { + struct ethtool_value edata; + if (copy_from_user(&edata, useraddr, sizeof(edata))) + return -EFAULT; + pc_debug = edata.data; + return 0; + } +#endif + + default: + break; + } + + return -EOPNOTSUPP; +} + +static int netdev_ioctl (struct net_device *dev, struct ifreq *rq, int cmd) +{ + int rc; + + switch (cmd) { + case SIOCETHTOOL: + rc = netdev_ethtool_ioctl(dev, (void *) rq->ifr_data); + break; + + default: + rc = -EOPNOTSUPP; + break; + } + + return rc; } static int el3_config(struct net_device *dev, struct ifmap *map) diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/net/pcmcia/Config.in linux-2.5/drivers/net/pcmcia/Config.in --- linux-2.5.1/drivers/net/pcmcia/Config.in Mon Nov 12 17:35:43 2001 +++ linux-2.5/drivers/net/pcmcia/Config.in Thu Dec 13 16:32:36 2001 @@ -11,10 +11,10 @@ dep_tristate ' 3Com 3c574 PCMCIA support' CONFIG_PCMCIA_3C574 $CONFIG_PCMCIA dep_tristate ' Fujitsu FMV-J18x PCMCIA support' CONFIG_PCMCIA_FMVJ18X $CONFIG_PCMCIA dep_tristate ' NE2000 compatible PCMCIA support' CONFIG_PCMCIA_PCNET $CONFIG_PCMCIA + dep_tristate ' Asix AX88190 PCMCIA support' CONFIG_PCMCIA_AXNET $CONFIG_PCMCIA dep_tristate ' New Media PCMCIA support' CONFIG_PCMCIA_NMCLAN $CONFIG_PCMCIA dep_tristate ' SMC 91Cxx PCMCIA support' CONFIG_PCMCIA_SMC91C92 $CONFIG_PCMCIA dep_tristate ' Xircom 16-bit PCMCIA support' CONFIG_PCMCIA_XIRC2PS $CONFIG_PCMCIA - dep_tristate ' broken NS8390-cards support' CONFIG_PCMCIA_AXNET $CONFIG_PCMCIA dep_tristate ' COM20020 ARCnet PCMCIA support' CONFIG_ARCNET_COM20020_CS $CONFIG_ARCNET_COM20020 $CONFIG_ARCNET $CONFIG_PCMCIA if [ "$CONFIG_IBMTR" != "y" ]; then dep_tristate ' IBM PCMCIA tokenring adapter support' CONFIG_PCMCIA_IBMTR $CONFIG_TR $CONFIG_PCMCIA diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/net/pcmcia/aironet4500_cs.c linux-2.5/drivers/net/pcmcia/aironet4500_cs.c --- linux-2.5.1/drivers/net/pcmcia/aironet4500_cs.c Sun Sep 30 19:26:07 2001 +++ linux-2.5/drivers/net/pcmcia/aironet4500_cs.c Thu Dec 27 16:32:31 2001 @@ -10,8 +10,11 @@ * */ +#define DRV_NAME "aironet4500_cs" +#define DRV_VERSION "0.1" + static const char *awc_version = -"aironet4500_cs.c v0.1 1/1/99 Elmer Joandi, elmer@ylenurme.ee.\n"; +DRV_NAME ".c v" DRV_VERSION " 1/1/99 Elmer Joandi, elmer@ylenurme.ee.\n"; #include <linux/module.h> @@ -24,6 +27,9 @@ #include <linux/timer.h> #include <linux/interrupt.h> #include <linux/in.h> +#include <linux/ethtool.h> + +#include <asm/uaccess.h> #include <asm/io.h> #include <asm/system.h> #include <asm/bitops.h> @@ -159,6 +165,66 @@ return ret; } +static int netdev_ethtool_ioctl (struct net_device *dev, void *useraddr) +{ + u32 ethcmd; + + /* dev_ioctl() in ../../net/core/dev.c has already checked + capable(CAP_NET_ADMIN), so don't bother with that here. */ + + if (get_user(ethcmd, (u32 *)useraddr)) + return -EFAULT; + + switch (ethcmd) { + + case ETHTOOL_GDRVINFO: { + struct ethtool_drvinfo info = { ETHTOOL_GDRVINFO }; + strcpy (info.driver, DRV_NAME); + strcpy (info.version, DRV_VERSION); + sprintf(info.bus_info, "PCMCIA 0x%lx", dev->base_addr); + if (copy_to_user (useraddr, &info, sizeof (info))) + return -EFAULT; + return 0; + } + +#ifdef PCMCIA_DEBUG + /* get message-level */ + case ETHTOOL_GMSGLVL: { + struct ethtool_value edata = {ETHTOOL_GMSGLVL}; + edata.data = pc_debug; + if (copy_to_user(useraddr, &edata, sizeof(edata))) + return -EFAULT; + return 0; + } + /* set message-level */ + case ETHTOOL_SMSGLVL: { + struct ethtool_value edata; + if (copy_from_user(&edata, useraddr, sizeof(edata))) + return -EFAULT; + pc_debug = edata.data; + return 0; + } +#endif + + default: + break; + } + + return -EOPNOTSUPP; +} + +static int awc_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) +{ + switch (cmd) { + case SIOCETHTOOL: + return netdev_ethtool_ioctl(dev, (void *) rq->ifr_data); + + default: + return -EOPNOTSUPP; + } + return 0; +} + /* awc_attach() creates an "instance" of the driver, allocating local data structures for one device. The device is registered @@ -230,7 +296,8 @@ // dev->set_config = &awc_config_misiganes,aga mitte awc_config; dev->get_stats = &awc_get_stats; // dev->set_multicast_list = &awc_set_multicast_list; - + dev->do_ioctl = &awc_ioctl; + strcpy(dev->name, ((struct awc_private *)dev->priv)->node.dev_name); ether_setup(dev); diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/net/pcmcia/ax8390.h linux-2.5/drivers/net/pcmcia/ax8390.h --- linux-2.5.1/drivers/net/pcmcia/ax8390.h Mon Nov 12 17:35:43 2001 +++ linux-2.5/drivers/net/pcmcia/ax8390.h Thu Jan 1 00:00:00 1970 @@ -1,193 +0,0 @@ -/* Generic NS8390 register definitions. */ -/* This file is part of Donald Becker's 8390 drivers, and is distributed - under the same license. Auto-loading of 8390.o only in v2.2 - Paul G. - Some of these names and comments originated from the Crynwr - packet drivers, which are distributed under the GPL. */ - -#ifndef _8390_h -#define _8390_h - -#include <linux/config.h> -#include <linux/if_ether.h> -#include <linux/ioport.h> -#include <linux/skbuff.h> - -#define TX_2X_PAGES 12 -#define TX_1X_PAGES 6 - -/* Should always use two Tx slots to get back-to-back transmits. */ -#define EI_PINGPONG - -#ifdef EI_PINGPONG -#define TX_PAGES TX_2X_PAGES -#else -#define TX_PAGES TX_1X_PAGES -#endif - -#define ETHER_ADDR_LEN 6 - -/* The 8390 specific per-packet-header format. */ -struct e8390_pkt_hdr { - unsigned char status; /* status */ - unsigned char next; /* pointer to next packet. */ - unsigned short count; /* header + packet length in bytes */ -}; - -#ifdef notdef -extern int ei_debug; -#else -#define ei_debug 1 -#endif - -#ifndef HAVE_AUTOIRQ -/* From auto_irq.c */ -extern void autoirq_setup(int waittime); -extern unsigned long autoirq_report(int waittime); -#endif - -static int ethdev_init(struct net_device *dev); -static void NS8390_init(struct net_device *dev, int startp); -static int ei_open(struct net_device *dev); -static int ei_close(struct net_device *dev); -static void ei_interrupt(int irq, void *dev_id, struct pt_regs *regs); - -/* Most of these entries should be in 'struct net_device' (or most of the - things in there should be here!) */ -/* You have one of these per-board */ -struct ei_device { - const char *name; - void (*reset_8390)(struct net_device *); - void (*get_8390_hdr)(struct net_device *, struct e8390_pkt_hdr *, int); - void (*block_output)(struct net_device *, int, const unsigned char *, int); - void (*block_input)(struct net_device *, int, struct sk_buff *, int); - unsigned char mcfilter[8]; - unsigned open:1; - unsigned word16:1; /* We have the 16-bit (vs 8-bit) version of the card. */ - unsigned txing:1; /* Transmit Active */ - unsigned irqlock:1; /* 8390's intrs disabled when '1'. */ - unsigned dmaing:1; /* Remote DMA Active */ - unsigned char tx_start_page, rx_start_page, stop_page; - unsigned char current_page; /* Read pointer in buffer */ - unsigned char interface_num; /* Net port (AUI, 10bT.) to use. */ - unsigned char txqueue; /* Tx Packet buffer queue length. */ - short tx1, tx2; /* Packet lengths for ping-pong tx. */ - short lasttx; /* Alpha version consistency check. */ - unsigned char reg0; /* Register '0' in a WD8013 */ - unsigned char reg5; /* Register '5' in a WD8013 */ - unsigned char saved_irq; /* Original dev->irq value. */ - struct net_device_stats stat; /* The new statistics table. */ - u32 *reg_offset; /* Register mapping table */ - spinlock_t page_lock; /* Page register locks */ - unsigned long priv; /* Private field to store bus IDs etc. */ -}; - -/* The maximum number of 8390 interrupt service routines called per IRQ. */ -#define MAX_SERVICE 12 - -/* The maximum time waited (in jiffies) before assuming a Tx failed. (20ms) */ -#define TX_TIMEOUT (20*HZ/100) - -#define ei_status (*(struct ei_device *)(dev->priv)) - -/* Some generic ethernet register configurations. */ -#define E8390_TX_IRQ_MASK 0xa /* For register EN0_ISR */ -#define E8390_RX_IRQ_MASK 0x5 -#define E8390_RXCONFIG 0x44 /* EN0_RXCR: broadcasts, no multicast,errors */ -#define E8390_RXOFF 0x20 /* EN0_RXCR: Accept no packets */ -#define E8390_TXCONFIG 0x00 /* EN0_TXCR: Normal transmit mode */ -#define E8390_TXOFF 0x02 /* EN0_TXCR: Transmitter off */ - -/* Register accessed at EN_CMD, the 8390 base addr. */ -#define E8390_STOP 0x01 /* Stop and reset the chip */ -#define E8390_START 0x02 /* Start the chip, clear reset */ -#define E8390_TRANS 0x04 /* Transmit a frame */ -#define E8390_RREAD 0x08 /* Remote read */ -#define E8390_RWRITE 0x10 /* Remote write */ -#define E8390_NODMA 0x20 /* Remote DMA */ -#define E8390_PAGE0 0x00 /* Select page chip registers */ -#define E8390_PAGE1 0x40 /* using the two high-order bits */ -#define E8390_PAGE2 0x80 /* Page 3 is invalid. */ - -/* - * Only generate indirect loads given a machine that needs them. - */ - -#if defined(CONFIG_MAC) || defined(CONFIG_AMIGA_PCMCIA) || \ - defined(CONFIG_ARIADNE2) || defined(CONFIG_ARIADNE2_MODULE) || \ - defined(CONFIG_HYDRA) || defined(CONFIG_HYDRA_MODULE) -#define EI_SHIFT(x) (ei_local->reg_offset[x]) -#else -#define EI_SHIFT(x) (x) -#endif - -#define E8390_CMD EI_SHIFT(0x00) /* The command register (for all pages) */ -/* Page 0 register offsets. */ -#define EN0_CLDALO EI_SHIFT(0x01) /* Low byte of current local dma addr RD */ -#define EN0_STARTPG EI_SHIFT(0x01) /* Starting page of ring bfr WR */ -#define EN0_CLDAHI EI_SHIFT(0x02) /* High byte of current local dma addr RD */ -#define EN0_STOPPG EI_SHIFT(0x02) /* Ending page +1 of ring bfr WR */ -#define EN0_BOUNDARY EI_SHIFT(0x03) /* Boundary page of ring bfr RD WR */ -#define EN0_TSR EI_SHIFT(0x04) /* Transmit status reg RD */ -#define EN0_TPSR EI_SHIFT(0x04) /* Transmit starting page WR */ -#define EN0_NCR EI_SHIFT(0x05) /* Number of collision reg RD */ -#define EN0_TCNTLO EI_SHIFT(0x05) /* Low byte of tx byte count WR */ -#define EN0_FIFO EI_SHIFT(0x06) /* FIFO RD */ -#define EN0_TCNTHI EI_SHIFT(0x06) /* High byte of tx byte count WR */ -#define EN0_ISR EI_SHIFT(0x07) /* Interrupt status reg RD WR */ -#define EN0_CRDALO EI_SHIFT(0x08) /* low byte of current remote dma address RD */ -#define EN0_RSARLO EI_SHIFT(0x08) /* Remote start address reg 0 */ -#define EN0_CRDAHI EI_SHIFT(0x09) /* high byte, current remote dma address RD */ -#define EN0_RSARHI EI_SHIFT(0x09) /* Remote start address reg 1 */ -#define EN0_RCNTLO EI_SHIFT(0x0a) /* Remote byte count reg WR */ -#define EN0_RCNTHI EI_SHIFT(0x0b) /* Remote byte count reg WR */ -#define EN0_RSR EI_SHIFT(0x0c) /* rx status reg RD */ -#define EN0_RXCR EI_SHIFT(0x0c) /* RX configuration reg WR */ -#define EN0_TXCR EI_SHIFT(0x0d) /* TX configuration reg WR */ -#define EN0_COUNTER0 EI_SHIFT(0x0d) /* Rcv alignment error counter RD */ -#define EN0_DCFG EI_SHIFT(0x0e) /* Data configuration reg WR */ -#define EN0_COUNTER1 EI_SHIFT(0x0e) /* Rcv CRC error counter RD */ -#define EN0_IMR EI_SHIFT(0x0f) /* Interrupt mask reg WR */ -#define EN0_COUNTER2 EI_SHIFT(0x0f) /* Rcv missed frame error counter RD */ - -/* Bits in EN0_ISR - Interrupt status register */ -#define ENISR_RX 0x01 /* Receiver, no error */ -#define ENISR_TX 0x02 /* Transmitter, no error */ -#define ENISR_RX_ERR 0x04 /* Receiver, with error */ -#define ENISR_TX_ERR 0x08 /* Transmitter, with error */ -#define ENISR_OVER 0x10 /* Receiver overwrote the ring */ -#define ENISR_COUNTERS 0x20 /* Counters need emptying */ -#define ENISR_RDC 0x40 /* remote dma complete */ -#define ENISR_RESET 0x80 /* Reset completed */ -#define ENISR_ALL 0x3f /* Interrupts we will enable */ - -/* Bits in EN0_DCFG - Data config register */ -#define ENDCFG_WTS 0x01 /* word transfer mode selection */ - -/* Page 1 register offsets. */ -#define EN1_PHYS EI_SHIFT(0x01) /* This board's physical enet addr RD WR */ -#define EN1_PHYS_SHIFT(i) EI_SHIFT(i+1) /* Get and set mac address */ -#define EN1_CURPAG EI_SHIFT(0x07) /* Current memory page RD WR */ -#define EN1_MULT EI_SHIFT(0x08) /* Multicast filter mask array (8 bytes) RD WR */ -#define EN1_MULT_SHIFT(i) EI_SHIFT(8+i) /* Get and set multicast filter */ - -/* Bits in received packet status byte and EN0_RSR*/ -#define ENRSR_RXOK 0x01 /* Received a good packet */ -#define ENRSR_CRC 0x02 /* CRC error */ -#define ENRSR_FAE 0x04 /* frame alignment error */ -#define ENRSR_FO 0x08 /* FIFO overrun */ -#define ENRSR_MPA 0x10 /* missed pkt */ -#define ENRSR_PHY 0x20 /* physical/multicast address */ -#define ENRSR_DIS 0x40 /* receiver disable. set in monitor mode */ -#define ENRSR_DEF 0x80 /* deferring */ - -/* Transmitted packet status, EN0_TSR. */ -#define ENTSR_PTX 0x01 /* Packet transmitted without error */ -#define ENTSR_ND 0x02 /* The transmit wasn't deferred. */ -#define ENTSR_COL 0x04 /* The transmit collided at least once. */ -#define ENTSR_ABT 0x08 /* The transmit collided 16 times, and was deferred. */ -#define ENTSR_CRS 0x10 /* The carrier sense was lost. */ -#define ENTSR_FU 0x20 /* A "FIFO underrun" occurred during transmit. */ -#define ENTSR_CDH 0x40 /* The collision detect "heartbeat" signal was lost. */ -#define ENTSR_OWC 0x80 /* There was an out-of-window collision. */ - -#endif /* _8390_h */ diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/net/pcmcia/axnet_cs.c linux-2.5/drivers/net/pcmcia/axnet_cs.c --- linux-2.5.1/drivers/net/pcmcia/axnet_cs.c Mon Nov 12 17:35:43 2001 +++ linux-2.5/drivers/net/pcmcia/axnet_cs.c Thu Dec 13 16:32:36 2001 @@ -11,7 +11,7 @@ Copyright (C) 2001 David A. Hinds -- dahinds@users.sourceforge.net - axnet_cs.c 1.11 2001/06/12 12:42:40 + axnet_cs.c 1.24 2001/11/18 02:46:51 The network driver code is based on Donald Becker's NE2000 code: @@ -20,7 +20,7 @@ Director, National Security Agency. This software may be used and distributed according to the terms of the GNU General Public License, incorporated herein by reference. - Donald Becker may be reached at becker@cesdis1.gsfc.nasa.gov + Donald Becker may be reached at becker@scyld.com ======================================================================*/ @@ -33,12 +33,13 @@ #include <linux/string.h> #include <linux/timer.h> #include <linux/delay.h> +#include <linux/spinlock.h> #include <asm/io.h> #include <asm/system.h> #include <asm/byteorder.h> #include <linux/netdevice.h> -#include "ax8390.h" +#include "../8390.h" #include <pcmcia/version.h> #include <pcmcia/cs_types.h> @@ -51,7 +52,6 @@ #define AXNET_CMD 0x00 #define AXNET_DATAPORT 0x10 /* NatSemi-defined port window offset. */ #define AXNET_RESET 0x1f /* Issue a read to reset, a write to clear. */ -#define AXNET_MISC 0x18 /* For IBM CCAE and Socket EA cards */ #define AXNET_MII_EEP 0x14 /* Offset of MII access port */ #define AXNET_START_PG 0x40 /* First page of TX buffer */ @@ -59,26 +59,13 @@ #define AXNET_RDC_TIMEOUT 0x02 /* Max wait in jiffies for Tx RDC */ -#ifdef PCMCIA_DEBUG -static int pc_debug = PCMCIA_DEBUG; -MODULE_PARM(pc_debug, "i"); -#define DEBUG(n, args...) if (pc_debug>(n)) printk(KERN_DEBUG args) -static char *version = -"axnet_cs.c 1.11 2001/06/12 12:42:40 (David Hinds)"; -#else -#define DEBUG(n, args...) -#endif - -#define DEV_KFREE_SKB(skb) dev_kfree_skb(skb); -#define skb_tx_check(dev, skb) -#define add_rx_bytes(stats, n) (stats)->rx_bytes += n; -#define add_tx_bytes(stats, n) (stats)->tx_bytes += n; -#define netif_mark_up(dev) do { } while (0) -#define netif_mark_down(dev) do { } while (0) - /*====================================================================*/ -/* Parameters that can be set with 'insmod' */ +/* Module parameters */ + +MODULE_AUTHOR("David Hinds <dahinds@users.sourceforge.net>"); +MODULE_DESCRIPTION("Asix AX88190 PCMCIA ethernet driver"); +MODULE_LICENSE("GPL"); #define INT_MODULE_PARM(n, v) static int n = v; MODULE_PARM(n, "i") @@ -87,9 +74,14 @@ static int irq_list[4] = { -1 }; MODULE_PARM(irq_list, "1-4i"); -/* Ugh! Let the user hardwire the hardware address for queer cards */ -static int hw_addr[6] = { 0, /* ... */ }; -MODULE_PARM(hw_addr, "6i"); +#ifdef PCMCIA_DEBUG +INT_MODULE_PARM(pc_debug, PCMCIA_DEBUG); +#define DEBUG(n, args...) if (pc_debug>(n)) printk(KERN_DEBUG args) +static char *version = +"axnet_cs.c 1.24 2001/11/18 02:46:51 (David Hinds)"; +#else +#define DEBUG(n, args...) +#endif /*====================================================================*/ @@ -120,6 +112,11 @@ static dev_info_t dev_info = "axnet_cs"; static dev_link_t *dev_list; +static int axdev_init(struct net_device *dev); +static void AX88190_init(struct net_device *dev, int startp); +static int ax_open(struct net_device *dev); +static void ax_interrupt(int irq, void *dev_id, struct pt_regs *regs); + /*====================================================================*/ typedef struct axnet_dev_t { @@ -210,7 +207,7 @@ link->conf.Attributes = CONF_ENABLE_IRQ; link->conf.IntType = INT_MEMORY_AND_IO; - ethdev_init(dev); + axdev_init(dev); dev->init = &axnet_init; dev->open = &axnet_open; dev->stop = &axnet_close; @@ -302,7 +299,7 @@ {0x00, EN0_RCNTHI}, {0x00, EN0_IMR}, /* Mask completion irq. */ {0xFF, EN0_ISR}, - {E8390_RXOFF, EN0_RXCR}, /* 0x20 Set to monitor */ + {E8390_RXOFF|0x40, EN0_RXCR}, /* 0x60 Set to monitor */ {E8390_TXOFF, EN0_TXCR}, /* 0x02 and loopback mode. */ {0x10, EN0_RCNTLO}, {0x00, EN0_RCNTHI}, @@ -331,30 +328,6 @@ /*====================================================================== - This should be totally unnecessary... but when we can't figure - out the hardware address any other way, we'll let the user hard - wire it when the module is initialized. - -======================================================================*/ - -static int get_hwired(dev_link_t *link) -{ - struct net_device *dev = link->priv; - int i; - - for (i = 0; i < 6; i++) - if (hw_addr[i] != 0) break; - if (i == 6) - return 0; - - for (i = 0; i < 6; i++) - dev->dev_addr[i] = hw_addr[i]; - - return 1; -} /* get_hwired */ - -/*====================================================================== - axnet_config() is scheduled to run after a CARD_INSERTION event is received, to configure the PCMCIA socket, and to make the ethernet device available to the system. @@ -419,7 +392,8 @@ CS_CHECK(GetTupleData, handle, &tuple); CS_CHECK(ParseTuple, handle, &tuple, &parse); link->conf.ConfigBase = parse.config.base; - link->conf.Present = parse.config.rmask[0]; + /* don't trust the CIS on this; Linksys got it wrong */ + link->conf.Present = 0x63; /* Configure card */ link->state |= DEV_CONFIG; @@ -440,7 +414,7 @@ if ((cfg->index == 0) || (cfg->io.nwin == 0)) goto next_entry; - link->conf.ConfigIndex = cfg->index; + link->conf.ConfigIndex = 0x05; /* For multifunction cards, by convention, we configure the network function with window 0, and serial with window 1 */ if (io->nwin > 1) { @@ -480,9 +454,9 @@ goto failed; } - if (!get_prom(link) && !get_hwired(link)) { - printk(KERN_NOTICE "axnet_cs: unable to read hardware net" - " address for io base %#3lx\n", dev->base_addr); + if (!get_prom(link)) { + printk(KERN_NOTICE "axnet_cs: this is not an AX88190 card!\n"); + printk(KERN_NOTICE "axnet_cs: use pcnet_cs instead.\n"); unregister_netdev(dev); goto failed; } @@ -542,7 +516,7 @@ if (link->open) { DEBUG(1, "axnet_cs: release postponed, '%s' still open\n", - info->node.dev_name); + ((axnet_dev_t *)(link->priv))->node.dev_name); link->state |= DEV_STALE_CONFIG; return; } @@ -602,7 +576,7 @@ CardServices(RequestConfiguration, link->handle, &link->conf); if (link->open) { axnet_reset_8390(&info->dev); - NS8390_init(&info->dev, 1); + AX88190_init(&info->dev, 1); netif_device_attach(&info->dev); } } @@ -692,7 +666,7 @@ info->watchdog.expires = jiffies + HZ; add_timer(&info->watchdog); - return ei_open(dev); + return ax_open(dev); } /* axnet_open */ /*====================================================================*/ @@ -708,7 +682,6 @@ link->open--; netif_stop_queue(dev); - netif_mark_down(dev); del_timer(&info->watchdog); if (link->state & DEV_STALE_CONFIG) mod_timer(&link->release, jiffies + HZ/20); @@ -755,7 +728,7 @@ { axnet_dev_t *info = dev_id; info->stale = 0; - ei_interrupt(irq, dev_id, regs); + ax_interrupt(irq, dev_id, regs); } static void ei_watchdog(u_long arg) @@ -807,7 +780,7 @@ else printk(KERN_INFO "%s: link partner did not autonegotiate\n", dev->name); - NS8390_init(dev, 1); + AX88190_init(dev, 1); } info->link_status = link; } @@ -944,10 +917,11 @@ This software may be used and distributed according to the terms of the GNU General Public License, incorporated herein by reference. - The author may be reached as becker@CESDIS.gsfc.nasa.gov, or C/O - Center of Excellence in Space Data and Information Sciences - Code 930.5, Goddard Space Flight Center, Greenbelt MD 20771 - + The author may be reached as becker@scyld.com, or C/O + Scyld Computing Corporation + 410 Severn Ave., Suite 210 + Annapolis MD 21403 + This is the chip-specific code for many 8390-based ethernet adaptors. This is not a complete driver, it must be combined with board-specific code such as ne.c, wd.c, 3c503.c, etc. @@ -957,7 +931,6 @@ a simple innocent change. Please contact me or Donald if you think you have found something that needs changing. -- PG - Changelog: Paul Gortmaker : remove set_bit lock, other cleanups. @@ -981,8 +954,8 @@ */ -static const char *version = - "8390.c:v1.10cvs 9/23/94 Donald Becker (becker@cesdis.gsfc.nasa.gov)\n"; +static const char *version_8390 = + "8390.c:v1.10cvs 9/23/94 Donald Becker (becker@scyld.com)\n"; #include <asm/uaccess.h> #include <asm/bitops.h> @@ -1062,25 +1035,23 @@ * them. */ - - /** - * ei_open - Open/initialize the board. + * ax_open - Open/initialize the board. * @dev: network device to initialize * * This routine goes all-out, setting everything * up anew at each open, even though many of these registers should only * need to be set once at boot. */ -static int ei_open(struct net_device *dev) +static int ax_open(struct net_device *dev) { unsigned long flags; struct ei_device *ei_local = (struct ei_device *) dev->priv; - /* This can't happen unless somebody forgot to call ethdev_init(). */ + /* This can't happen unless somebody forgot to call axdev_init(). */ if (ei_local == NULL) { - printk(KERN_EMERG "%s: ei_open passed a non-existent device!\n", dev->name); + printk(KERN_EMERG "%s: ax_open passed a non-existent device!\n", dev->name); return -ENXIO; } @@ -1099,10 +1070,9 @@ */ spin_lock_irqsave(&ei_local->page_lock, flags); - NS8390_init(dev, 1); + AX88190_init(dev, 1); /* Set the flag before we drop the lock, That way the IRQ arrives after its set and we get no silly warnings */ - netif_mark_up(dev); netif_start_queue(dev); spin_unlock_irqrestore(&ei_local->page_lock, flags); ei_local->irqlock = 0; @@ -1110,27 +1080,6 @@ } /** - * ei_close - shut down network device - * @dev: network device to close - * - * Opposite of ei_open(). Only used when "ifconfig <devname> down" is done. - */ -static int ei_close(struct net_device *dev) -{ - unsigned long flags; - - /* - * Hold the page lock during close - */ - - spin_lock_irqsave(&((struct ei_device *)dev->priv)->page_lock, flags); - NS8390_init(dev, 0); - spin_unlock_irqrestore(&((struct ei_device *)dev->priv)->page_lock, flags); - netif_stop_queue(dev); - return 0; -} - -/** * ei_tx_timeout - handle transmit time out condition * @dev: network device which has apparently fallen asleep * @@ -1169,7 +1118,7 @@ /* Try to restart the card. Perhaps the user has fixed something. */ ei_reset_8390(dev); - NS8390_init(dev, 1); + AX88190_init(dev, 1); spin_unlock(&ei_local->page_lock); enable_irq(dev->irq); @@ -1192,7 +1141,6 @@ unsigned long flags; netif_stop_queue(dev); - skb_tx_check(dev, skb); length = skb->len; @@ -1205,7 +1153,6 @@ outb_p(0x00, e8390_base + EN0_IMR); spin_unlock_irqrestore(&ei_local->page_lock, flags); - /* * Slow phase with lock held. */ @@ -1218,8 +1165,6 @@ send_length = ETH_ZLEN < length ? length : ETH_ZLEN; -#ifdef EI_PINGPONG - /* * We have two Tx slots available for use. Find the first free * slot, and then perform some sanity checks. With two Tx bufs, @@ -1288,22 +1233,6 @@ else netif_start_queue(dev); -#else /* EI_PINGPONG */ - - /* - * Only one Tx buffer in use. You need two Tx bufs to come close to - * back-to-back transmits. Expect a 20 -> 25% performance hit on - * reasonable hardware if you only use one Tx buffer. - */ - - ei_block_output(dev, length, skb->data, ei_local->tx_start_page); - ei_local->txing = 1; - NS8390_trigger_send(dev, send_length, ei_local->tx_start_page); - dev->trans_start = jiffies; - netif_stop_queue(dev); - -#endif /* EI_PINGPONG */ - /* Turn 8390 interrupts back on. */ ei_local->irqlock = 0; outb_p(ENISR_ALL, e8390_base + EN0_IMR); @@ -1311,14 +1240,14 @@ spin_unlock(&ei_local->page_lock); enable_irq(dev->irq); - DEV_KFREE_SKB (skb); - add_tx_bytes(&ei_local->stat, send_length); + dev_kfree_skb (skb); + ei_local->stat.tx_bytes += send_length; return 0; } /** - * ei_interrupt - handle the interrupts from an 8390 + * ax_interrupt - handle the interrupts from an 8390 * @irq: interrupt number * @dev_id: a pointer to the net_device * @regs: unused @@ -1330,7 +1259,7 @@ * needed. */ -static void ei_interrupt(int irq, void *dev_id, struct pt_regs * regs) +static void ax_interrupt(int irq, void *dev_id, struct pt_regs * regs) { struct net_device *dev = dev_id; long e8390_base; @@ -1497,8 +1426,6 @@ struct ei_device *ei_local = (struct ei_device *) dev->priv; int status = inb(e8390_base + EN0_TSR); -#ifdef EI_PINGPONG - /* * There are two Tx buffers, see which one finished, and trigger * the send of another one if it exists. @@ -1541,13 +1468,6 @@ // else printk(KERN_WARNING "%s: unexpected TX-done interrupt, lasttx=%d.\n", // dev->name, ei_local->lasttx); -#else /* EI_PINGPONG */ - /* - * Single Tx buffer: mark it free so another packet can be loaded. - */ - ei_local->txing = 0; -#endif - /* Minimize Tx latency: update the statistics after we restart TXing. */ if (status & ENTSR_COL) ei_local->stat.collisions++; @@ -1655,7 +1575,7 @@ netif_rx(skb); dev->last_rx = jiffies; ei_local->stat.rx_packets++; - add_rx_bytes(&ei_local->stat, pkt_len); + ei_local->stat.rx_bytes += pkt_len; if (pkt_stat & ENRSR_PHY) ei_local->stat.multicast++; } @@ -1801,11 +1721,11 @@ long e8390_base = dev->base_addr; if(dev->flags&IFF_PROMISC) - outb_p(E8390_RXCONFIG | 0x18, e8390_base + EN0_RXCR); + outb_p(E8390_RXCONFIG | 0x58, e8390_base + EN0_RXCR); else if(dev->flags&IFF_ALLMULTI || dev->mc_list) - outb_p(E8390_RXCONFIG | 0x08, e8390_base + EN0_RXCR); + outb_p(E8390_RXCONFIG | 0x48, e8390_base + EN0_RXCR); else - outb_p(E8390_RXCONFIG, e8390_base + EN0_RXCR); + outb_p(E8390_RXCONFIG | 0x40, e8390_base + EN0_RXCR); } /* @@ -1813,28 +1733,30 @@ * be parallel to just about everything else. Its also fairly quick and * not called too often. Must protect against both bh and irq users */ - + +#define dev_lock(dev) (((struct ei_device *)(dev)->priv)->page_lock) + static void set_multicast_list(struct net_device *dev) { unsigned long flags; - spin_lock_irqsave(&((struct ei_device *)dev->priv)->page_lock, flags); + spin_lock_irqsave(&dev_lock(dev), flags); do_set_multicast_list(dev); - spin_unlock_irqrestore(&((struct ei_device *)dev->priv)->page_lock, flags); + spin_unlock_irqrestore(&dev_lock(dev), flags); } /** - * ethdev_init - init rest of 8390 device struct + * axdev_init - init rest of 8390 device struct * @dev: network device structure to init * * Initialize the rest of the 8390 device structure. Do NOT __init * this, as it is used by 8390 based modular drivers too. */ -static int ethdev_init(struct net_device *dev) +static int axdev_init(struct net_device *dev) { if (ei_debug > 1) - printk(version); + printk(version_8390); if (dev->priv == NULL) { @@ -1857,20 +1779,18 @@ return 0; } - - /* This page of functions should be 8390 generic */ /* Follow National Semi's recommendations for initializing the "NIC". */ /** - * NS8390_init - initialize 8390 hardware + * AX88190_init - initialize 8390 hardware * @dev: network device to initialize * @startp: boolean. non-zero value to initiate chip processing * * Must be called with lock held. */ -static void NS8390_init(struct net_device *dev, int startp) +static void AX88190_init(struct net_device *dev, int startp) { axnet_dev_t *info = (axnet_dev_t *)dev; long e8390_base = dev->base_addr; @@ -1887,7 +1807,7 @@ outb_p(0x00, e8390_base + EN0_RCNTLO); outb_p(0x00, e8390_base + EN0_RCNTHI); /* Set to monitor and loopback mode -- this is vital!. */ - outb_p(E8390_RXOFF, e8390_base + EN0_RXCR); /* 0x20 */ + outb_p(E8390_RXOFF|0x40, e8390_base + EN0_RXCR); /* 0x60 */ outb_p(E8390_TXOFF, e8390_base + EN0_TXCR); /* 0x02 */ /* Set the transmit page and receive ring. */ outb_p(ei_local->tx_start_page, e8390_base + EN0_TPSR); @@ -1931,7 +1851,7 @@ outb_p(E8390_TXCONFIG | info->duplex_flag, e8390_base + EN0_TXCR); /* xmit on. */ /* 3c503 TechMan says rxconfig only after the NIC is started. */ - outb_p(E8390_RXCONFIG, e8390_base + EN0_RXCR); /* rx on, */ + outb_p(E8390_RXCONFIG | 0x40, e8390_base + EN0_RXCR); /* rx on, */ do_set_multicast_list(dev); /* (re)load the mcast table */ } } diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/net/pcmcia/fmvj18x_cs.c linux-2.5/drivers/net/pcmcia/fmvj18x_cs.c --- linux-2.5.1/drivers/net/pcmcia/fmvj18x_cs.c Tue Nov 13 17:02:30 2001 +++ linux-2.5/drivers/net/pcmcia/fmvj18x_cs.c Thu Dec 27 16:32:31 2001 @@ -28,6 +28,9 @@ ======================================================================*/ +#define DRV_NAME "fmvj18x_cs" +#define DRV_VERSION "2.6" + #include <linux/module.h> #include <linux/kernel.h> #include <linux/init.h> @@ -39,6 +42,9 @@ #include <linux/interrupt.h> #include <linux/in.h> #include <linux/delay.h> +#include <linux/ethtool.h> + +#include <asm/uaccess.h> #include <asm/io.h> #include <asm/system.h> @@ -73,7 +79,7 @@ #ifdef PCMCIA_DEBUG INT_MODULE_PARM(pc_debug, PCMCIA_DEBUG); #define DEBUG(n, args...) if (pc_debug>(n)) printk(KERN_DEBUG args) -static char *version = "fmvj18x_cs.c 2.6 2001/09/17"; +static char *version = DRV_NAME ".c " DRV_VERSION " 2001/09/17"; #else #define DEBUG(n, args...) #endif @@ -103,6 +109,7 @@ static struct net_device_stats *fjn_get_stats(struct net_device *dev); static void set_rx_mode(struct net_device *dev); static void fjn_tx_timeout(struct net_device *dev); +static int fjn_ioctl(struct net_device *, struct ifreq *, int); static dev_info_t dev_info = "fmvj18x_cs"; static dev_link_t *dev_list; @@ -315,6 +322,7 @@ dev->tx_timeout = fjn_tx_timeout; dev->watchdog_timeo = TX_TIMEOUT; #endif + dev->do_ioctl = fjn_ioctl; /* Register with Card Services */ link->next = dev_list; @@ -1102,6 +1110,65 @@ /*====================================================================*/ +static int netdev_ethtool_ioctl (struct net_device *dev, void *useraddr) +{ + u32 ethcmd; + + /* dev_ioctl() in ../../net/core/dev.c has already checked + capable(CAP_NET_ADMIN), so don't bother with that here. */ + + if (get_user(ethcmd, (u32 *)useraddr)) + return -EFAULT; + + switch (ethcmd) { + + case ETHTOOL_GDRVINFO: { + struct ethtool_drvinfo info = { ETHTOOL_GDRVINFO }; + strcpy (info.driver, DRV_NAME); + strcpy (info.version, DRV_VERSION); + sprintf(info.bus_info, "PCMCIA 0x%lx", dev->base_addr); + if (copy_to_user (useraddr, &info, sizeof (info))) + return -EFAULT; + return 0; + } + +#ifdef PCMCIA_DEBUG + /* get message-level */ + case ETHTOOL_GMSGLVL: { + struct ethtool_value edata = {ETHTOOL_GMSGLVL}; + edata.data = pc_debug; + if (copy_to_user(useraddr, &edata, sizeof(edata))) + return -EFAULT; + return 0; + } + /* set message-level */ + case ETHTOOL_SMSGLVL: { + struct ethtool_value edata; + if (copy_from_user(&edata, useraddr, sizeof(edata))) + return -EFAULT; + pc_debug = edata.data; + return 0; + } +#endif + + default: + break; + } + + return -EOPNOTSUPP; +} + +static int fjn_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) +{ + switch (cmd) { + case SIOCETHTOOL: + return netdev_ethtool_ioctl(dev, (void *) rq->ifr_data); + + default: + return -EOPNOTSUPP; + } +} + static int fjn_config(struct net_device *dev, struct ifmap *map){ return 0; } @@ -1247,3 +1314,4 @@ } restore_flags(flags); } +MODULE_LICENSE("GPL"); diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/net/pcmcia/netwave_cs.c linux-2.5/drivers/net/pcmcia/netwave_cs.c --- linux-2.5.1/drivers/net/pcmcia/netwave_cs.c Fri Oct 12 21:21:18 2001 +++ linux-2.5/drivers/net/pcmcia/netwave_cs.c Thu Dec 27 16:32:31 2001 @@ -37,6 +37,9 @@ /* To have statistics (just packets sent) define this */ #undef NETWAVE_STATS +#define DRV_NAME "netwave_cs" +#define DRV_VERSION "0.3.0" + #include <linux/config.h> #include <linux/module.h> #include <linux/kernel.h> @@ -51,6 +54,9 @@ #include <linux/slab.h> #include <linux/string.h> #include <linux/timer.h> +#include <linux/ethtool.h> + +#include <asm/uaccess.h> #include <asm/system.h> #include <asm/bitops.h> #include <asm/io.h> @@ -163,7 +169,7 @@ MODULE_PARM(pc_debug, "i"); #define DEBUG(n, args...) if (pc_debug>(n)) printk(KERN_DEBUG args) static char *version = -"netwave_cs.c 0.3.0 Thu Jul 17 14:36:02 1997 (John Markus Bjørndalen)\n"; +DRV_NAME ".c " DRV_VERSION " Thu Jul 17 14:36:02 1997 (John Markus Bjørndalen)\n"; #else #define DEBUG(n, args...) #endif @@ -200,6 +206,8 @@ MODULE_PARM(irq_mask, "i"); MODULE_PARM(irq_list, "1-4i"); +MODULE_LICENSE("GPL"); + /*====================================================================*/ /* PCMCIA (Card Services) related functions */ @@ -595,6 +603,53 @@ } } /* netwave_flush_stale_links */ +static int netdev_ethtool_ioctl (struct net_device *dev, void *useraddr) +{ + u32 ethcmd; + + /* dev_ioctl() in ../../net/core/dev.c has already checked + capable(CAP_NET_ADMIN), so don't bother with that here. */ + + if (get_user(ethcmd, (u32 *)useraddr)) + return -EFAULT; + + switch (ethcmd) { + + case ETHTOOL_GDRVINFO: { + struct ethtool_drvinfo info = { ETHTOOL_GDRVINFO }; + strcpy (info.driver, DRV_NAME); + strcpy (info.version, DRV_VERSION); + sprintf(info.bus_info, "PCMCIA 0x%lx", dev->base_addr); + if (copy_to_user (useraddr, &info, sizeof (info))) + return -EFAULT; + return 0; + } + +#ifdef PCMCIA_DEBUG + /* get message-level */ + case ETHTOOL_GMSGLVL: { + struct ethtool_value edata = {ETHTOOL_GMSGLVL}; + edata.data = pc_debug; + if (copy_to_user(useraddr, &edata, sizeof(edata))) + return -EFAULT; + return 0; + } + /* set message-level */ + case ETHTOOL_SMSGLVL: { + struct ethtool_value edata; + if (copy_from_user(&edata, useraddr, sizeof(edata))) + return -EFAULT; + pc_debug = edata.data; + return 0; + } +#endif + + default: + break; + } + + return -EOPNOTSUPP; +} /* * Function netwave_ioctl (dev, rq, cmd) * @@ -617,6 +672,9 @@ DEBUG(0, "%s: ->netwave_ioctl(cmd=0x%X)\n", dev->name, cmd); + if (cmd == SIOCETHTOOL) + return netdev_ethtool_ioctl(dev, (void *) rq->ifr_data); + /* Disable interrupts & save flags */ save_flags(flags); cli(); @@ -1597,4 +1655,3 @@ writeb(rcvMode, ramBase + NETWAVE_EREG_CB + 1); writeb(NETWAVE_CMD_EOC, ramBase + NETWAVE_EREG_CB + 2); } -MODULE_LICENSE("GPL"); diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/net/pcmcia/nmclan_cs.c linux-2.5/drivers/net/pcmcia/nmclan_cs.c --- linux-2.5.1/drivers/net/pcmcia/nmclan_cs.c Tue Nov 13 17:02:30 2001 +++ linux-2.5/drivers/net/pcmcia/nmclan_cs.c Thu Dec 27 16:32:31 2001 @@ -106,6 +106,10 @@ ---------------------------------------------------------------------------- */ +#define DRV_NAME "nmclan_cs" +#define DRV_VERSION "0.16" + + /* ---------------------------------------------------------------------------- Conditional Compilation Options ---------------------------------------------------------------------------- */ @@ -130,6 +134,9 @@ #include <linux/interrupt.h> #include <linux/in.h> #include <linux/delay.h> +#include <linux/ethtool.h> + +#include <asm/uaccess.h> #include <asm/io.h> #include <asm/system.h> #include <asm/bitops.h> @@ -375,7 +382,7 @@ static char rcsid[] = "nmclan_cs.c,v 0.16 1995/07/01 06:42:17 rpao Exp rpao"; static char *version = -"nmclan_cs 0.16 (Roger C. Pao)"; +DRV_NAME " " DRV_VERSION " (Roger C. Pao)"; #endif static dev_info_t dev_info="nmclan_cs"; @@ -1001,6 +1008,66 @@ return 0; } /* mace_close */ + +static int netdev_ethtool_ioctl (struct net_device *dev, void *useraddr) +{ + u32 ethcmd; + + /* dev_ioctl() in ../../net/core/dev.c has already checked + capable(CAP_NET_ADMIN), so don't bother with that here. */ + + if (get_user(ethcmd, (u32 *)useraddr)) + return -EFAULT; + + switch (ethcmd) { + + case ETHTOOL_GDRVINFO: { + struct ethtool_drvinfo info = { ETHTOOL_GDRVINFO }; + strcpy (info.driver, DRV_NAME); + strcpy (info.version, DRV_VERSION); + sprintf(info.bus_info, "PCMCIA 0x%lx", dev->base_addr); + if (copy_to_user (useraddr, &info, sizeof (info))) + return -EFAULT; + return 0; + } + +#ifdef PCMCIA_DEBUG + /* get message-level */ + case ETHTOOL_GMSGLVL: { + struct ethtool_value edata = {ETHTOOL_GMSGLVL}; + edata.data = pc_debug; + if (copy_to_user(useraddr, &edata, sizeof(edata))) + return -EFAULT; + return 0; + } + /* set message-level */ + case ETHTOOL_SMSGLVL: { + struct ethtool_value edata; + if (copy_from_user(&edata, useraddr, sizeof(edata))) + return -EFAULT; + pc_debug = edata.data; + return 0; + } +#endif + + default: + break; + } + + return -EOPNOTSUPP; +} + +static int smc91c92_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) +{ + switch (cmd) { + case SIOCETHTOOL: + return netdev_ethtool_ioctl(dev, (void *) rq->ifr_data); + + default: + return -EOPNOTSUPP; + } + return 0; +} /* ---------------------------------------------------------------------------- mace_start_xmit diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/net/pcmcia/xircom_cb.c linux-2.5/drivers/net/pcmcia/xircom_cb.c --- linux-2.5.1/drivers/net/pcmcia/xircom_cb.c Fri Nov 9 21:41:42 2001 +++ linux-2.5/drivers/net/pcmcia/xircom_cb.c Thu Dec 13 16:32:36 2001 @@ -170,7 +170,7 @@ name: "xircom_cb", id_table: xircom_pci_table, probe: xircom_probe, - remove: xircom_remove, + remove: __devexit_p(xircom_remove), }; diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/net/pcmcia/xircom_tulip_cb.c linux-2.5/drivers/net/pcmcia/xircom_tulip_cb.c --- linux-2.5.1/drivers/net/pcmcia/xircom_tulip_cb.c Fri Nov 9 21:41:42 2001 +++ linux-2.5/drivers/net/pcmcia/xircom_tulip_cb.c Thu Dec 13 16:32:36 2001 @@ -1748,7 +1748,7 @@ name: DRV_NAME, id_table: xircom_pci_table, probe: xircom_init_one, - remove: xircom_remove_one, + remove: __devexit_p(xircom_remove_one), #ifdef CONFIG_PM suspend: xircom_suspend, resume: xircom_resume diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/net/pcnet32.c linux-2.5/drivers/net/pcnet32.c --- linux-2.5.1/drivers/net/pcnet32.c Sun Nov 11 18:09:33 2001 +++ linux-2.5/drivers/net/pcnet32.c Thu Dec 27 16:32:31 2001 @@ -648,6 +648,13 @@ #if defined(__i386__) printk(KERN_WARNING "%s: Probably a Compaq, using the PROM address of", dev->name); memcpy(dev->dev_addr, promaddr, 6); +#elif defined(__powerpc__) + if (!is_valid_ether_addr(dev->dev_addr) + && is_valid_ether_addr(promaddr)) { + printk("\n" KERN_WARNING "%s: using PROM address:", + dev->name); + memcpy(dev->dev_addr, promaddr, 6); + } #endif } } diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/net/sgiseeq.c linux-2.5/drivers/net/sgiseeq.c --- linux-2.5.1/drivers/net/sgiseeq.c Thu Apr 12 19:15:25 2001 +++ linux-2.5/drivers/net/sgiseeq.c Sun Dec 30 21:17:30 2001 @@ -16,7 +16,6 @@ #include <linux/delay.h> #include <asm/io.h> -#include <asm/segment.h> #include <asm/system.h> #include <asm/bitops.h> #include <asm/page.h> diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/net/shaper.c linux-2.5/drivers/net/shaper.c --- linux-2.5.1/drivers/net/shaper.c Sun Sep 30 19:26:07 2001 +++ linux-2.5/drivers/net/shaper.c Thu Dec 13 16:32:36 2001 @@ -737,6 +737,11 @@ static void __exit shaper_exit (void) { + int i; + + for (i = 0; i < shapers; i++) + unregister_netdev(&devs[i]); + kfree(devs); devs = NULL; } diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/net/sis900.c linux-2.5/drivers/net/sis900.c --- linux-2.5.1/drivers/net/sis900.c Tue Oct 9 22:13:03 2001 +++ linux-2.5/drivers/net/sis900.c Thu Dec 27 16:32:31 2001 @@ -1,6 +1,6 @@ /* sis900.c: A SiS 900/7016 PCI Fast Ethernet driver for Linux. Copyright 1999 Silicon Integrated System Corporation - Revision: 1.08.01 Aug. 25 2001 + Revision: 1.08.02 Nov. 30 2001 Modified from the driver which is originally written by Donald Becker. @@ -18,6 +18,7 @@ preliminary Rev. 1.0 Jan. 18, 1998 http://www.sis.com.tw/support/databook.htm + Rev 1.08.02 Nov. 30 2001 Hui-Fen Hsu workaround for EDB & bug fix for dhcp problem Rev 1.08.01 Aug. 25 2001 Hui-Fen Hsu update for 630ET & workaround for ICS1893 PHY Rev 1.08.00 Jun. 11 2001 Hui-Fen Hsu workaround for RTL8201 PHY and some bug fix Rev 1.07.11 Apr. 2 2001 Hui-Fen Hsu updates PCI drivers to use the new pci_set_dma_mask for kernel 2.4.3 @@ -55,18 +56,23 @@ #include <linux/netdevice.h> #include <linux/init.h> #include <linux/mii.h> - #include <linux/etherdevice.h> #include <linux/skbuff.h> +#include <linux/delay.h> +#include <linux/ethtool.h> + #include <asm/processor.h> /* Processor type for cache alignment. */ #include <asm/bitops.h> #include <asm/io.h> -#include <linux/delay.h> +#include <asm/uaccess.h> /* User space memory access functions */ #include "sis900.h" +#define SIS900_MODULE_NAME "sis900" +#define SIS900_DRV_VERSION "v1.08.02 11/30/2001" + static char version[] __devinitdata = -KERN_INFO "sis900.c: v1.08.01 9/25/2001\n"; +KERN_INFO "sis900.c: " SIS900_DRV_VERSION "\n"; static int max_interrupt_work = 40; static int multicast_filter_limit = 128; @@ -870,6 +876,9 @@ netif_start_queue(net_dev); + /* Workaround for EDB */ + sis900_set_mode(ioaddr, HW_SPEED_10_MBPS, FDX_CAPABLE_HALF_SELECTED); + /* Enable all known interrupts by setting the interrupt mask. */ outl((RxSOVR|RxORN|RxERR|RxOK|TxURN|TxERR|TxIDLE), ioaddr + imr); outl(RxENA | inl(ioaddr + cr), ioaddr + cr); @@ -1126,6 +1135,7 @@ sis900_set_mode(net_dev->base_addr, speed, duplex); pci_read_config_byte(sis_priv->pci_dev, PCI_CLASS_REVISION, &revision); sis630_set_eq(net_dev, revision); + netif_start_queue(net_dev); } sis_priv->timer.expires = jiffies + HZ; @@ -1409,6 +1419,12 @@ unsigned int entry; unsigned long flags; + /* Don't transmit data before the complete of auto-negotiation */ + if(!sis_priv->autong_complete){ + netif_stop_queue(net_dev); + return 1; + } + spin_lock_irqsave(&sis_priv->lock, flags); /* Calculate the next Tx descriptor entry. */ @@ -2092,13 +2108,11 @@ pci_set_drvdata(pci_dev, NULL); } -#define SIS900_MODULE_NAME "sis900" - static struct pci_driver sis900_pci_driver = { name: SIS900_MODULE_NAME, id_table: sis900_pci_tbl, probe: sis900_probe, - remove: sis900_remove, + remove: __devexit_p(sis900_remove), }; static int __init sis900_init_module(void) diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/net/slip.c linux-2.5/drivers/net/slip.c --- linux-2.5.1/drivers/net/slip.c Sun Sep 30 19:26:07 2001 +++ linux-2.5/drivers/net/slip.c Thu Dec 27 22:10:28 2001 @@ -1394,7 +1394,7 @@ */ do { if (busy) { - current->counter = 0; + current->time_slice = 0; schedule(); } diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/net/starfire.c linux-2.5/drivers/net/starfire.c --- linux-2.5.1/drivers/net/starfire.c Sun Sep 30 19:26:07 2001 +++ linux-2.5/drivers/net/starfire.c Thu Dec 27 16:32:31 2001 @@ -93,13 +93,16 @@ - Fixed initialization timing problems - Fixed interrupt mask definitions + LK1.3.5 (jgarzik) + - ethtool NWAY_RST, GLINK, [GS]MSGLVL support + TODO: - implement tx_timeout() properly */ #define DRV_NAME "starfire" -#define DRV_VERSION "1.03+LK1.3.4" -#define DRV_RELDATE "August 14, 2001" +#define DRV_VERSION "1.03+LK1.3.5" +#define DRV_RELDATE "November 17, 2001" #include <linux/version.h> #include <linux/module.h> @@ -1789,6 +1792,47 @@ return 0; } + /* restart autonegotiation */ + case ETHTOOL_NWAY_RST: { + int tmp; + int r = -EINVAL; + /* if autoneg is off, it's an error */ + tmp = mdio_read(dev, np->phys[0], MII_BMCR); + if (tmp & BMCR_ANENABLE) { + tmp |= (BMCR_ANRESTART); + mdio_write(dev, np->phys[0], MII_BMCR, tmp); + r = 0; + } + return r; + } + /* get link status */ + case ETHTOOL_GLINK: { + struct ethtool_value edata = {ETHTOOL_GLINK}; + if (mdio_read(dev, np->phys[0], MII_BMSR) & BMSR_LSTATUS) + edata.data = 1; + else + edata.data = 0; + if (copy_to_user(useraddr, &edata, sizeof(edata))) + return -EFAULT; + return 0; + } + + /* get message-level */ + case ETHTOOL_GMSGLVL: { + struct ethtool_value edata = {ETHTOOL_GMSGLVL}; + edata.data = debug; + if (copy_to_user(useraddr, &edata, sizeof(edata))) + return -EFAULT; + return 0; + } + /* set message-level */ + case ETHTOOL_SMSGLVL: { + struct ethtool_value edata; + if (copy_from_user(&edata, useraddr, sizeof(edata))) + return -EFAULT; + debug = edata.data; + return 0; + } default: return -EOPNOTSUPP; } @@ -1963,7 +2007,7 @@ static struct pci_driver starfire_driver = { name: DRV_NAME, probe: starfire_init_one, - remove: starfire_remove_one, + remove: __devexit_p(starfire_remove_one), id_table: starfire_pci_tbl, }; diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/net/strip.c linux-2.5/drivers/net/strip.c --- linux-2.5.1/drivers/net/strip.c Fri Nov 9 22:02:24 2001 +++ linux-2.5/drivers/net/strip.c Sun Dec 30 21:17:30 2001 @@ -87,7 +87,6 @@ #include <linux/init.h> #include <asm/system.h> #include <asm/uaccess.h> -#include <asm/segment.h> #include <asm/bitops.h> /* diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/net/sundance.c linux-2.5/drivers/net/sundance.c --- linux-2.5.1/drivers/net/sundance.c Fri Oct 19 15:32:28 2001 +++ linux-2.5/drivers/net/sundance.c Thu Dec 27 16:32:31 2001 @@ -16,11 +16,16 @@ Support and updates available at http://www.scyld.com/network/sundance.html + + + Version 1.01a (jgarzik): + - Replace some MII-related magic numbers with constants + */ #define DRV_NAME "sundance" -#define DRV_VERSION "1.01" -#define DRV_RELDATE "4/09/00" +#define DRV_VERSION "1.01a" +#define DRV_RELDATE "11-Nov-2001" /* The user-configurable values. @@ -442,7 +447,7 @@ int irq; int i; long ioaddr; - u16 mii_reg0; + u16 mii_ctl; void *ring_space; dma_addr_t ring_dma; @@ -581,15 +586,15 @@ } } /* Reset PHY */ - mdio_write (dev, np->phys[0], 0, 0x8000); + mdio_write (dev, np->phys[0], MII_BMCR, BMCR_RESET); mdelay (300); - mdio_write (dev, np->phys[0], 0, 0x1200); + mdio_write (dev, np->phys[0], MII_BMCR, BMCR_ANENABLE|BMCR_ANRESTART); /* Force media type */ if (!np->an_enable) { - mii_reg0 = 0; - mii_reg0 |= (np->speed == 100) ? 0x2000 : 0; - mii_reg0 |= (np->full_duplex) ? 0x0100 : 0; - mdio_write (dev, np->phys[0], 0, mii_reg0); + mii_ctl = 0; + mii_ctl |= (np->speed == 100) ? BMCR_SPEED100 : 0; + mii_ctl |= (np->full_duplex) ? BMCR_FULLDPLX : 0; + mdio_write (dev, np->phys[0], MII_BMCR, mii_ctl); printk (KERN_INFO "Override speed=%d, %s duplex\n", np->speed, np->full_duplex ? "Full" : "Half"); @@ -797,12 +802,12 @@ { struct netdev_private *np = dev->priv; long ioaddr = dev->base_addr; - int mii_reg5 = mdio_read(dev, np->phys[0], 5); - int negotiated = mii_reg5 & np->advertising; + int mii_lpa = mdio_read(dev, np->phys[0], MII_LPA); + int negotiated = mii_lpa & np->advertising; int duplex; /* Force media */ - if (!np->an_enable || mii_reg5 == 0xffff) { + if (!np->an_enable || mii_lpa == 0xffff) { if (np->full_duplex) writew (readw (ioaddr + MACCtrl0) | EnbFullDuplex, ioaddr + MACCtrl0); @@ -1183,7 +1188,7 @@ { long ioaddr = dev->base_addr; struct netdev_private *np = dev->priv; - u16 mii_reg0, mii_reg4, mii_reg5; + u16 mii_ctl, mii_advertise, mii_lpa; int speed; if (intr_status & IntrDrvRqst) { @@ -1199,27 +1204,27 @@ } if (intr_status & LinkChange) { if (np->an_enable) { - mii_reg4 = mdio_read (dev, np->phys[0], 4); - mii_reg5= mdio_read (dev, np->phys[0], 5); - mii_reg4 &= mii_reg5; + mii_advertise = mdio_read (dev, np->phys[0], MII_ADVERTISE); + mii_lpa= mdio_read (dev, np->phys[0], MII_LPA); + mii_advertise &= mii_lpa; printk (KERN_INFO "%s: Link changed: ", dev->name); - if (mii_reg4 & 0x0100) + if (mii_advertise & ADVERTISE_100FULL) printk ("100Mbps, full duplex\n"); - else if (mii_reg4 & 0x0080) + else if (mii_advertise & ADVERTISE_100HALF) printk ("100Mbps, half duplex\n"); - else if (mii_reg4 & 0x0040) + else if (mii_advertise & ADVERTISE_10FULL) printk ("10Mbps, full duplex\n"); - else if (mii_reg4 & 0x0020) + else if (mii_advertise & ADVERTISE_10HALF) printk ("10Mbps, half duplex\n"); else printk ("\n"); } else { - mii_reg0 = mdio_read (dev, np->phys[0], 0); - speed = (mii_reg0 & 0x2000) ? 100 : 10; + mii_ctl = mdio_read (dev, np->phys[0], MII_BMCR); + speed = (mii_ctl & BMCR_SPEED100) ? 100 : 10; printk (KERN_INFO "%s: Link changed: %dMbps ,", dev->name, speed); - printk ("%s duplex.\n", (mii_reg0 & 0x0100) ? + printk ("%s duplex.\n", (mii_ctl & BMCR_FULLDPLX) ? "full" : "half"); } check_duplex (dev); @@ -1474,7 +1479,7 @@ name: DRV_NAME, id_table: sundance_pci_tbl, probe: sundance_probe1, - remove: sundance_remove1, + remove: __devexit_p(sundance_remove1), }; static int __init sundance_init(void) diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/net/sungem.c linux-2.5/drivers/net/sungem.c --- linux-2.5.1/drivers/net/sungem.c Sun Oct 21 17:36:54 2001 +++ linux-2.5/drivers/net/sungem.c Thu Dec 13 16:32:36 2001 @@ -1,7 +1,15 @@ -/* $Id: sungem.c,v 1.30 2001/10/17 06:55:10 davem Exp $ +/* $Id: sungem.c,v 1.43 2001/12/05 08:40:54 davem Exp $ * sungem.c: Sun GEM ethernet driver. * * Copyright (C) 2000, 2001 David S. Miller (davem@redhat.com) + * + * Support for Apple GMAC and assorted PHYs by + * Benjamin Herrenscmidt (benh@kernel.crashing.org) + * + * TODO: + * - Get rid of all those nasty mdelay's and replace them + * with schedule_timeout. + * - Implement WOL */ #include <linux/module.h> @@ -23,11 +31,15 @@ #include <linux/netdevice.h> #include <linux/etherdevice.h> #include <linux/skbuff.h> +#include <linux/mii.h> +#include <linux/ethtool.h> #include <asm/system.h> #include <asm/bitops.h> #include <asm/io.h> #include <asm/byteorder.h> +#include <asm/uaccess.h> +#include <asm/irq.h> #ifdef __sparc__ #include <asm/idprom.h> @@ -45,15 +57,33 @@ #include "sungem.h" +#define DRV_NAME "sungem" +#define DRV_VERSION "0.96" +#define DRV_RELDATE "11/17/01" +#define DRV_AUTHOR "David S. Miller (davem@redhat.com)" + static char version[] __devinitdata = - "sungem.c:v0.95 16/Oct/01 David S. Miller (davem@redhat.com)\n"; + DRV_NAME ".c:v" DRV_VERSION " " DRV_RELDATE " " DRV_AUTHOR "\n"; -MODULE_AUTHOR("David S. Miller (davem@redhat.com)"); +MODULE_AUTHOR(DRV_AUTHOR); MODULE_DESCRIPTION("Sun GEM Gbit ethernet driver"); MODULE_LICENSE("GPL"); MODULE_PARM(gem_debug, "i"); MODULE_PARM_DESC(gem_debug, "(ignored)"); +MODULE_PARM(link_mode, "i"); + +static int link_mode; + +static u16 link_modes[] __devinitdata = { + BMCR_ANENABLE, /* 0 : autoneg */ + 0, /* 1 : 10bt half duplex */ + BMCR_SPEED100, /* 2 : 100bt half duplex */ + BMCR_SPD2, /* verify this */ /* 3 : 1000bt half duplex */ + BMCR_FULLDPLX, /* 4 : 10bt full duplex */ + BMCR_SPEED100|BMCR_FULLDPLX, /* 5 : 100bt full duplex */ + BMCR_SPD2|BMCR_FULLDPLX /* 6 : 1000bt full duplex */ +}; #define GEM_MODULE_NAME "gem" #define PFX GEM_MODULE_NAME ": " @@ -73,7 +103,7 @@ * they only support 10/100 speeds. -DaveM * * Apple's GMAC does support gigabit on machines with - * the BCM5400 or 5401 PHYs. -BenH + * the BCM54xx PHYs. -BenH */ { PCI_VENDOR_ID_SUN, PCI_DEVICE_ID_SUN_RIO_GEM, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL }, @@ -362,10 +392,6 @@ return 1; } -static void gem_stop(struct gem *, unsigned long); -static void gem_init_rings(struct gem *, int); -static void gem_init_hw(struct gem *); - /* All non-normal interrupt conditions get serviced here. * Returns non-zero if we should just exit the interrupt * handler right now (ie. if we reset the card which invalidates @@ -418,9 +444,9 @@ return 0; do_reset: - gem_stop(gp, gp->regs); - gem_init_rings(gp, 1); - gem_init_hw(gp); + gp->reset_task_pending = 1; + schedule_task(&gp->reset_task); + return 1; } @@ -627,6 +653,10 @@ struct gem *gp = dev->priv; printk(KERN_ERR "%s: transmit timed out, resetting\n", dev->name); + if (!gp->hw_running) { + printk("%s: hrm.. hw not running !\n", dev->name); + return; + } printk(KERN_ERR "%s: TX_STATE[%08x:%08x:%08x]\n", dev->name, readl(gp->regs + TXDMA_CFG), @@ -640,13 +670,19 @@ spin_lock_irq(&gp->lock); - gem_stop(gp, gp->regs); - gem_init_rings(gp, 1); - gem_init_hw(gp); + gp->reset_task_pending = 1; + schedule_task(&gp->reset_task); spin_unlock_irq(&gp->lock); +} - netif_wake_queue(dev); +static __inline__ int gem_intme(int entry) +{ + /* Algorithm: IRQ every 1/2 of descriptors. */ + if (!(entry & ((TX_RING_SIZE>>1)-1))) + return 1; + + return 0; } static int gem_start_xmit(struct sk_buff *skb, struct net_device *dev) @@ -690,15 +726,22 @@ ~PAGE_MASK), len, PCI_DMA_TODEVICE); ctrl |= TXDCTRL_SOF | TXDCTRL_EOF | len; + if (gem_intme(entry)) + ctrl |= TXDCTRL_INTME; txd->buffer = cpu_to_le64(mapping); txd->control_word = cpu_to_le64(ctrl); entry = NEXT_TX(entry); } else { struct gem_txd *txd; u32 first_len; + u64 intme; dma_addr_t first_mapping; int frag, first_entry = entry; + intme = 0; + if (gem_intme(entry)) + intme |= TXDCTRL_INTME; + /* We must give this initial chunk to the device last. * Otherwise we could race with the device. */ @@ -727,11 +770,15 @@ txd->buffer = cpu_to_le64(mapping); txd->control_word = cpu_to_le64(this_ctrl | len); + if (gem_intme(entry)) + intme |= TXDCTRL_INTME; + entry = NEXT_TX(entry); } txd = &gp->init_block->txd[first_entry]; txd->buffer = cpu_to_le64(first_mapping); - txd->control_word = cpu_to_le64(ctrl | TXDCTRL_SOF | first_len); + txd->control_word = + cpu_to_le64(ctrl | TXDCTRL_SOF | intme | first_len); } gp->tx_new = entry; @@ -761,18 +808,19 @@ return -EINVAL; spin_lock_irq(&gp->lock); - gem_stop(gp, gp->regs); dev->mtu = new_mtu; - gem_init_rings(gp, 1); - gem_init_hw(gp); + gp->reset_task_pending = 1; + schedule_task(&gp->reset_task); spin_unlock_irq(&gp->lock); + flush_scheduled_tasks(); + return 0; } #define STOP_TRIES 32 -static void gem_stop(struct gem *gp, unsigned long regs) +static void gem_stop(struct gem *gp) { int limit; u32 val; @@ -781,13 +829,13 @@ writel(0xffffffff, gp->regs + GREG_IMASK); /* Reset the chip */ - writel(GREG_SWRST_TXRST | GREG_SWRST_RXRST, regs + GREG_SWRST); + writel(GREG_SWRST_TXRST | GREG_SWRST_RXRST, gp->regs + GREG_SWRST); limit = STOP_TRIES; do { udelay(20); - val = readl(regs + GREG_SWRST); + val = readl(gp->regs + GREG_SWRST); if (limit-- <= 0) break; } while (val & (GREG_SWRST_TXRST | GREG_SWRST_RXRST)); @@ -810,6 +858,9 @@ val = readl(gp->regs + MAC_RXCFG); writel(val | MAC_RXCFG_ENAB, gp->regs + MAC_RXCFG); + (void) readl(gp->regs + MAC_RXCFG); + udelay(100); + writel(GREG_STAT_TXDONE, gp->regs + GREG_IMASK); writel(RX_RING_SIZE - 4, gp->regs + RXDMA_KICK); @@ -828,6 +879,88 @@ { 1, 0, 1 }, /* 1000BT */ }; +static void gem_begin_auto_negotiation(struct gem *gp, struct ethtool_cmd *ep) +{ + u16 ctl; + + /* Setup link parameters */ + if (!ep) + goto start_aneg; + if (ep->autoneg == AUTONEG_ENABLE) { + /* TODO: parse ep->advertising */ + gp->link_advertise |= (ADVERTISE_10HALF | ADVERTISE_10FULL); + gp->link_advertise |= (ADVERTISE_100HALF | ADVERTISE_100FULL); + /* Can I advertise gigabit here ? I'd need BCM PHY docs... */ + gp->link_cntl = BMCR_ANENABLE; + } else { + gp->link_cntl = 0; + if (ep->speed == SPEED_100) + gp->link_cntl |= BMCR_SPEED100; + else if (ep->speed == SPEED_1000 && gp->gigabit_capable) + /* Hrm... check if this is right... */ + gp->link_cntl |= BMCR_SPD2; + if (ep->duplex == DUPLEX_FULL) + gp->link_cntl |= BMCR_FULLDPLX; + } + +start_aneg: + spin_lock_irq(&gp->lock); + if (!gp->hw_running) { + spin_unlock_irq(&gp->lock); + return; + } + + /* Configure PHY & start aneg */ + ctl = phy_read(gp, MII_BMCR); + ctl &= ~(BMCR_FULLDPLX|BMCR_SPEED100|BMCR_ANENABLE); + ctl |= gp->link_cntl; + if (ctl & BMCR_ANENABLE) { + ctl |= BMCR_ANRESTART; + gp->lstate = link_aneg; + } else { + gp->lstate = link_force_ok; + } + phy_write(gp, MII_BMCR, ctl); + + gp->timer_ticks = 0; + gp->link_timer.expires = jiffies + ((12 * HZ) / 10); + add_timer(&gp->link_timer); + spin_unlock_irq(&gp->lock); +} + +static void gem_read_mii_link_mode(struct gem *gp, int *fd, int *spd, int *pause) +{ + u32 val; + + *fd = 0; + *spd = 10; + *pause = 0; + + if (gp->phy_mod == phymod_bcm5400 || + gp->phy_mod == phymod_bcm5401 || + gp->phy_mod == phymod_bcm5411) { + int link_mode; + + val = phy_read(gp, MII_BCM5400_AUXSTATUS); + link_mode = ((val & MII_BCM5400_AUXSTATUS_LINKMODE_MASK) >> + MII_BCM5400_AUXSTATUS_LINKMODE_SHIFT); + *fd = phy_BCM5400_link_table[link_mode][0]; + *spd = phy_BCM5400_link_table[link_mode][2] ? + 1000 : + (phy_BCM5400_link_table[link_mode][1] ? 100 : 10); + val = phy_read(gp, MII_LPA); + if (val & LPA_PAUSE) + *pause = 1; + } else { + val = phy_read(gp, MII_LPA); + + if (val & (LPA_10FULL | LPA_100FULL)) + *fd = 1; + if (val & (LPA_100FULL | LPA_100HALF)) + *spd = 100; + } +} + /* A link-up condition has occurred, initialize and enable the * rest of the chip. */ @@ -842,32 +975,13 @@ if (gp->phy_type == phy_mii_mdio0 || gp->phy_type == phy_mii_mdio1) { - if (gp->lstate == aneg_wait) { - if (gp->phy_mod == phymod_bcm5400 || - gp->phy_mod == phymod_bcm5401 || - gp->phy_mod == phymod_bcm5411) { - int link_mode; - val = phy_read(gp, PHY_BCM5400_AUXSTATUS); - link_mode = (val & PHY_BCM5400_AUXSTATUS_LINKMODE_MASK) >> - PHY_BCM5400_AUXSTATUS_LINKMODE_SHIFT; - full_duplex = phy_BCM5400_link_table[link_mode][0]; - speed = phy_BCM5400_link_table[link_mode][2] ? 1000 - : (phy_BCM5400_link_table[link_mode][1] ? 100 : 10); - val = phy_read(gp, PHY_LPA); - if (val & PHY_LPA_PAUSE) - pause = 1; - } else { - val = phy_read(gp, PHY_LPA); - if (val & (PHY_LPA_10FULL | PHY_LPA_100FULL)) - full_duplex = 1; - if (val & (PHY_LPA_100FULL | PHY_LPA_100HALF)) - speed = 100; - } - } else { - val = phy_read(gp, PHY_CTRL); - if (val & PHY_CTRL_FDPLX) + val = phy_read(gp, MII_BMCR); + if (val & BMCR_ANENABLE) + gem_read_mii_link_mode(gp, &full_duplex, &speed, &pause); + else { + if (val & BMCR_FULLDPLX) full_duplex = 1; - if (val & PHY_CTRL_SPD100) + if (val & BMCR_SPEED100) speed = 100; } } else { @@ -944,56 +1058,142 @@ static int gem_mdio_link_not_up(struct gem *gp) { - if (gp->lstate == aneg_wait) { - u16 val = phy_read(gp, PHY_CTRL); + if (gp->lstate == link_force_ret) { + printk(KERN_INFO "%s: Autoneg failed again, keeping" + " forced mode\n", gp->dev->name); + phy_write(gp, MII_BMCR, gp->link_fcntl); + gp->timer_ticks = 5; + gp->lstate = link_force_ok; + } else if (gp->lstate == link_aneg) { + u16 val = phy_read(gp, MII_BMCR); /* Try forced modes. */ - val &= ~(PHY_CTRL_ANRES | PHY_CTRL_ANENAB); - val &= ~(PHY_CTRL_FDPLX); - val |= PHY_CTRL_SPD100; - phy_write(gp, PHY_CTRL, val); - gp->timer_ticks = 0; - gp->lstate = force_wait; - return 1; + val &= ~(BMCR_ANRESTART | BMCR_ANENABLE); + val &= ~(BMCR_FULLDPLX); + val |= BMCR_SPEED100; + phy_write(gp, MII_BMCR, val); + gp->timer_ticks = 5; + gp->lstate = link_force_try; } else { /* Downgrade from 100 to 10 Mbps if necessary. * If already at 10Mbps, warn user about the * situation every 10 ticks. */ - u16 val = phy_read(gp, PHY_CTRL); - if (val & PHY_CTRL_SPD100) { - val &= ~PHY_CTRL_SPD100; - phy_write(gp, PHY_CTRL, val); - gp->timer_ticks = 0; - return 1; + u16 val = phy_read(gp, MII_BMCR); + if (val & BMCR_SPEED100) { + val &= ~BMCR_SPEED100; + phy_write(gp, MII_BMCR, val); + gp->timer_ticks = 5; } else { - printk(KERN_ERR "%s: Link down, cable problem?\n", - gp->dev->name); - val |= (PHY_CTRL_ANRES | PHY_CTRL_ANENAB); - phy_write(gp, PHY_CTRL, val); - gp->timer_ticks = 1; - gp->lstate = aneg_wait; return 1; } } + return 0; +} + +static void gem_init_rings(struct gem *, int); +static void gem_init_hw(struct gem *, int); + +static void gem_reset_task(void *data) +{ + struct gem *gp = (struct gem *) data; + + /* The link went down, we reset the ring, but keep + * DMA stopped. Todo: Use this function for reset + * on error as well. + */ + if (gp->hw_running && gp->opened) { + /* Make sure we don't get interrupts or tx packets */ + spin_lock_irq(&gp->lock); + + netif_stop_queue(gp->dev); + + writel(0xffffffff, gp->regs + GREG_IMASK); + + spin_unlock_irq(&gp->lock); + + /* Reset the chip & rings */ + gem_stop(gp); + gem_init_rings(gp, 0); + gem_init_hw(gp, 0); + + netif_wake_queue(gp->dev); + } + gp->reset_task_pending = 0; } static void gem_link_timer(unsigned long data) { struct gem *gp = (struct gem *) data; - int restart_timer = 0; - gp->timer_ticks++; + if (!gp->hw_running) + return; + + /* If the link of task is still pending, we just + * reschedule the link timer + */ + if (gp->reset_task_pending) + goto restart; + + spin_lock_irq(&gp->lock); if (gp->phy_type == phy_mii_mdio0 || gp->phy_type == phy_mii_mdio1) { - u16 val = phy_read(gp, PHY_STAT); + u16 val = phy_read(gp, MII_BMSR); + int up; - if (val & PHY_STAT_LSTAT) { - gem_set_link_modes(gp); - } else if (gp->timer_ticks < 10) { - restart_timer = 1; + /* When using autoneg, we really wait for ANEGCOMPLETE or we may + * get a "transcient" incorrect link state + */ +#if 0 + { + u16 cntl = phy_read(gp, MII_BMCR); + if (cntl & BMCR_ANENABLE) + up = (val & (BMSR_ANEGCOMPLETE | BMSR_LSTATUS)) == (BMSR_ANEGCOMPLETE | BMSR_LSTATUS); + else + up = (val & BMSR_LSTATUS) != 0; + } +#else + up = (val & BMSR_LSTATUS) != 0; +#endif + if (up) { + /* Ok, here we got a link. If we had it due to a forced + * fallback, and we were configured for autoneg, we do + * retry a short autoneg pass. If you know your hub is + * broken, use ethtool ;) + */ + if (gp->lstate == link_force_try && (gp->link_cntl & BMCR_ANENABLE)) { + gp->lstate = link_force_ret; + gp->link_fcntl = phy_read(gp, MII_BMCR); + gp->timer_ticks = 5; + printk(KERN_INFO "%s: Got link after fallback, retrying autoneg" + " once...\n", gp->dev->name); + phy_write(gp, MII_BMCR, + gp->link_fcntl | BMCR_ANENABLE | BMCR_ANRESTART); + } else if (gp->lstate != link_up) { + gp->lstate = link_up; + if (gp->opened) + gem_set_link_modes(gp); + } } else { - restart_timer = gem_mdio_link_not_up(gp); + int restart = 0; + + /* If the link was previously up, we restart the + * whole process + */ + if (gp->lstate == link_up) { + gp->lstate = link_down; + printk(KERN_INFO "%s: Link down\n", gp->dev->name); + gp->reset_task_pending = 1; + schedule_task(&gp->reset_task); + restart = 1; + } else if (++gp->timer_ticks > 10) + restart = gem_mdio_link_not_up(gp); + + if (restart) { + spin_unlock_irq(&gp->lock); + gem_begin_auto_negotiation(gp, NULL); + return; + } } } else { u32 val = readl(gp->regs + PCS_MIISTAT); @@ -1001,17 +1201,17 @@ if (!(val & PCS_MIISTAT_LS)) val = readl(gp->regs + PCS_MIISTAT); - if ((val & PCS_MIISTAT_LS) == 0) { - restart_timer = 1; - } else { - gem_set_link_modes(gp); + if ((val & PCS_MIISTAT_LS) != 0) { + gp->lstate = link_up; + if (gp->opened) + gem_set_link_modes(gp); } } - if (restart_timer) { - gp->link_timer.expires = jiffies + ((12 * HZ) / 10); - add_timer(&gp->link_timer); - } +restart: + gp->link_timer.expires = jiffies + ((12 * HZ) / 10); + add_timer(&gp->link_timer); + spin_unlock_irq(&gp->lock); } static void gem_clean_rings(struct gem *gp) @@ -1108,66 +1308,72 @@ } } -static int -gem_reset_one_mii_phy(struct gem *gp, int phy_addr) +static int gem_reset_one_mii_phy(struct gem *gp, int phy_addr) { u16 val; int limit = 10000; - val = __phy_read(gp, PHY_CTRL, phy_addr); - val &= ~PHY_CTRL_ISO; - val |= PHY_CTRL_RST; - __phy_write(gp, PHY_CTRL, val, phy_addr); + val = __phy_read(gp, MII_BMCR, phy_addr); + val &= ~BMCR_ISOLATE; + val |= BMCR_RESET; + __phy_write(gp, MII_BMCR, val, phy_addr); udelay(100); while (limit--) { - val = __phy_read(gp, PHY_CTRL, phy_addr); - if ((val & PHY_CTRL_RST) == 0) + val = __phy_read(gp, MII_BMCR, phy_addr); + if ((val & BMCR_RESET) == 0) break; udelay(10); } - if ((val & PHY_CTRL_ISO) && limit > 0) - __phy_write(gp, PHY_CTRL, val & ~PHY_CTRL_ISO, phy_addr); + if ((val & BMCR_ISOLATE) && limit > 0) + __phy_write(gp, MII_BMCR, val & ~BMCR_ISOLATE, phy_addr); return (limit <= 0); } -static void -gem_init_bcm5400_phy(struct gem *gp) +static void gem_init_bcm5201_phy(struct gem *gp) +{ + u16 data; + + data = phy_read(gp, MII_BCM5201_MULTIPHY); + data &= ~MII_BCM5201_MULTIPHY_SUPERISOLATE; + phy_write(gp, MII_BCM5201_MULTIPHY, data); +} + +static void gem_init_bcm5400_phy(struct gem *gp) { u16 data; /* Configure for gigabit full duplex */ - data = phy_read(gp, PHY_BCM5400_AUXCONTROL); - data |= PHY_BCM5400_AUXCONTROL_PWR10BASET; - phy_write(gp, PHY_BCM5400_AUXCONTROL, data); - - data = phy_read(gp, PHY_BCM5400_GB_CONTROL); - data |= PHY_BCM5400_GB_CONTROL_FULLDUPLEXCAP; - phy_write(gp, PHY_BCM5400_GB_CONTROL, data); + data = phy_read(gp, MII_BCM5400_AUXCONTROL); + data |= MII_BCM5400_AUXCONTROL_PWR10BASET; + phy_write(gp, MII_BCM5400_AUXCONTROL, data); + + data = phy_read(gp, MII_BCM5400_GB_CONTROL); + data |= MII_BCM5400_GB_CONTROL_FULLDUPLEXCAP; + phy_write(gp, MII_BCM5400_GB_CONTROL, data); mdelay(10); /* Reset and configure cascaded 10/100 PHY */ gem_reset_one_mii_phy(gp, 0x1f); - data = __phy_read(gp, PHY_BCM5201_MULTIPHY, 0x1f); - data |= PHY_BCM5201_MULTIPHY_SERIALMODE; - __phy_write(gp, PHY_BCM5201_MULTIPHY, data, 0x1f); + data = __phy_read(gp, MII_BCM5201_MULTIPHY, 0x1f); + data |= MII_BCM5201_MULTIPHY_SERIALMODE; + __phy_write(gp, MII_BCM5201_MULTIPHY, data, 0x1f); - data = phy_read(gp, PHY_BCM5400_AUXCONTROL); - data &= ~PHY_BCM5400_AUXCONTROL_PWR10BASET; - phy_write(gp, PHY_BCM5400_AUXCONTROL, data); + data = phy_read(gp, MII_BCM5400_AUXCONTROL); + data &= ~MII_BCM5400_AUXCONTROL_PWR10BASET; + phy_write(gp, MII_BCM5400_AUXCONTROL, data); } -static void -gem_init_bcm5401_phy(struct gem *gp) +static void gem_init_bcm5401_phy(struct gem *gp) { u16 data; int rev; - rev = phy_read(gp, PHY_ID1) & 0x000f; + rev = phy_read(gp, MII_PHYSID2) & 0x000f; if (rev == 0 || rev == 3) { /* Some revisions of 5401 appear to need this * initialisation sequence to disable, according @@ -1191,22 +1397,21 @@ } /* Configure for gigabit full duplex */ - data = phy_read(gp, PHY_BCM5400_GB_CONTROL); - data |= PHY_BCM5400_GB_CONTROL_FULLDUPLEXCAP; - phy_write(gp, PHY_BCM5400_GB_CONTROL, data); + data = phy_read(gp, MII_BCM5400_GB_CONTROL); + data |= MII_BCM5400_GB_CONTROL_FULLDUPLEXCAP; + phy_write(gp, MII_BCM5400_GB_CONTROL, data); mdelay(1); /* Reset and configure cascaded 10/100 PHY */ gem_reset_one_mii_phy(gp, 0x1f); - data = __phy_read(gp, PHY_BCM5201_MULTIPHY, 0x1f); - data |= PHY_BCM5201_MULTIPHY_SERIALMODE; - __phy_write(gp, PHY_BCM5201_MULTIPHY, data, 0x1f); + data = __phy_read(gp, MII_BCM5201_MULTIPHY, 0x1f); + data |= MII_BCM5201_MULTIPHY_SERIALMODE; + __phy_write(gp, MII_BCM5201_MULTIPHY, data, 0x1f); } -static void -gem_init_bcm5411_phy(struct gem *gp) +static void gem_init_bcm5411_phy(struct gem *gp) { u16 data; @@ -1220,20 +1425,30 @@ /* Here, Apple seems to want to reset it, do * it as well */ - phy_write(gp, PHY_CTRL, PHY_CTRL_RST); + phy_write(gp, MII_BMCR, BMCR_RESET); /* Start autoneg */ - phy_write(gp, PHY_CTRL, - (PHY_CTRL_ANENAB | PHY_CTRL_FDPLX | - PHY_CTRL_ANRES | PHY_CTRL_SPD2)); - - data = phy_read(gp, PHY_BCM5400_GB_CONTROL); - data |= PHY_BCM5400_GB_CONTROL_FULLDUPLEXCAP; - phy_write(gp, PHY_BCM5400_GB_CONTROL, data); + phy_write(gp, MII_BMCR, + (BMCR_ANENABLE | BMCR_FULLDPLX | + BMCR_ANRESTART | BMCR_SPD2)); + + data = phy_read(gp, MII_BCM5400_GB_CONTROL); + data |= MII_BCM5400_GB_CONTROL_FULLDUPLEXCAP; + phy_write(gp, MII_BCM5400_GB_CONTROL, data); } static void gem_init_phy(struct gem *gp) { + u32 mifcfg; + + if (!gp->wake_on_lan && gp->phy_mod == phymod_bcm5201) + phy_write(gp, MII_BCM5201_INTERRUPT, 0); + + /* Revert MIF CFG setting done on stop_phy */ + mifcfg = readl(gp->regs + MIF_CFG); + mifcfg &= ~MIF_CFG_BBMODE; + writel(mifcfg, gp->regs + MIF_CFG); + #ifdef CONFIG_ALL_PPC if (gp->pdev->vendor == PCI_VENDOR_ID_APPLE) { int i; @@ -1241,7 +1456,7 @@ pmac_call_feature(PMAC_FTR_GMAC_PHY_RESET, gp->of_node, 0, 0); for (i = 0; i < 32; i++) { gp->mii_phy_addr = i; - if (phy_read(gp, PHY_CTRL) != 0xffff) + if (phy_read(gp, MII_BMCR) != 0xffff) break; } if (i == 32) { @@ -1277,54 +1492,68 @@ /* Take PHY out of isloate mode and reset it. */ gem_reset_one_mii_phy(gp, gp->mii_phy_addr); - phy_id = (phy_read(gp, PHY_ID0) << 16 | phy_read(gp, PHY_ID1)) + phy_id = (phy_read(gp, MII_PHYSID1) << 16 | phy_read(gp, MII_PHYSID2)) & 0xfffffff0; printk(KERN_INFO "%s: MII PHY ID: %x ", gp->dev->name, phy_id); switch(phy_id) { - case 0x406210: - gp->phy_mod = phymod_bcm5201; - printk("BCM 5201\n"); - break; - case 0x4061e0: - printk("BCM 5221\n"); - gp->phy_mod = phymod_bcm5221; - break; - case 0x206040: - printk("BCM 5400\n"); - gp->phy_mod = phymod_bcm5400; - gem_init_bcm5400_phy(gp); - break; - case 0x206050: - printk("BCM 5401\n"); - gp->phy_mod = phymod_bcm5401; - gem_init_bcm5401_phy(gp); - break; - case 0x206070: - printk("BCM 5411\n"); - gp->phy_mod = phymod_bcm5411; - gem_init_bcm5411_phy(gp); - break; - default: - printk("Generic\n"); - gp->phy_mod = phymod_generic; + case 0x406210: + gp->phy_mod = phymod_bcm5201; + gem_init_bcm5201_phy(gp); + printk("BCM 5201\n"); + break; + + case 0x4061e0: + printk("BCM 5221\n"); + gp->phy_mod = phymod_bcm5221; + break; + + case 0x206040: + printk("BCM 5400\n"); + gp->phy_mod = phymod_bcm5400; + gem_init_bcm5400_phy(gp); + gp->gigabit_capable = 1; + break; + + case 0x206050: + printk("BCM 5401\n"); + gp->phy_mod = phymod_bcm5401; + gem_init_bcm5401_phy(gp); + gp->gigabit_capable = 1; + break; + + case 0x206070: + printk("BCM 5411\n"); + gp->phy_mod = phymod_bcm5411; + gem_init_bcm5411_phy(gp); + gp->gigabit_capable = 1; + break; + + case 0x18074c0: + printk("Lucent\n"); + gp->phy_mod = phymod_generic; + break; + + case 0x437420: + printk("Enable Semiconductor\n"); + gp->phy_mod = phymod_generic; + break; + + default: + printk("Unknown\n"); + gp->phy_mod = phymod_generic; + break; }; /* Init advertisement and enable autonegotiation. */ - val = phy_read(gp, PHY_CTRL); - val &= ~PHY_CTRL_ANENAB; - phy_write(gp, PHY_CTRL, val); + val = phy_read(gp, MII_BMCR); + val &= ~BMCR_ANENABLE; + phy_write(gp, MII_BMCR, val); udelay(10); - phy_write(gp, PHY_ADV, - phy_read(gp, PHY_ADV) | - (PHY_ADV_10HALF | PHY_ADV_10FULL | - PHY_ADV_100HALF | PHY_ADV_100FULL)); - - val = phy_read(gp, PHY_CTRL); - val |= PHY_CTRL_ANENAB; - phy_write(gp, PHY_CTRL, val); - val |= PHY_CTRL_ANRES; - phy_write(gp, PHY_CTRL, val); + phy_write(gp, MII_ADVERTISE, + phy_read(gp, MII_ADVERTISE) | + (ADVERTISE_10HALF | ADVERTISE_10FULL | + ADVERTISE_100HALF | ADVERTISE_100FULL)); } else { u32 val; int limit; @@ -1379,6 +1608,7 @@ else val |= PCS_SCTRL_LOOP; writel(val, gp->regs + PCS_SCTRL); + gp->gigabit_capable = 1; } } @@ -1392,7 +1622,7 @@ writel(desc_dma >> 32, gp->regs + TXDMA_DBHI); writel(desc_dma & 0xffffffff, gp->regs + TXDMA_DBLOW); - desc_dma += (TX_RING_SIZE * sizeof(struct gem_txd)); + desc_dma += (INIT_BLOCK_TX_RING_SIZE * sizeof(struct gem_txd)); writel(0, gp->regs + TXDMA_KICK); @@ -1410,12 +1640,12 @@ writel(val, gp->regs + RXDMA_PTHRESH); if (readl(gp->regs + GREG_BIFCFG) & GREG_BIFCFG_M66EN) - writel(((6 & RXDMA_BLANK_IPKTS) | - ((4 << 12) & RXDMA_BLANK_ITIME)), + writel(((5 & RXDMA_BLANK_IPKTS) | + ((8 << 12) & RXDMA_BLANK_ITIME)), gp->regs + RXDMA_BLANK); else - writel(((6 & RXDMA_BLANK_IPKTS) | - ((2 << 12) & RXDMA_BLANK_ITIME)), + writel(((5 & RXDMA_BLANK_IPKTS) | + ((4 << 12) & RXDMA_BLANK_ITIME)), gp->regs + RXDMA_BLANK); } @@ -1551,18 +1781,20 @@ writel(0, gp->regs + MAC_MCCFG); writel(0, gp->regs + MAC_XIFCFG); - writel((MAC_TXSTAT_URUN | MAC_TXSTAT_MPE | - MAC_TXSTAT_NCE | MAC_TXSTAT_ECE | - MAC_TXSTAT_LCE | MAC_TXSTAT_FCE | - MAC_TXSTAT_DTE | MAC_TXSTAT_PCE), gp->regs + MAC_TXMASK); - writel((MAC_RXSTAT_OFLW | MAC_RXSTAT_FCE | - MAC_RXSTAT_ACE | MAC_RXSTAT_CCE | - MAC_RXSTAT_LCE | MAC_RXSTAT_VCE), gp->regs + MAC_RXMASK); - writel(0, gp->regs + MAC_MCMASK); + /* Setup MAC interrupts. We want to get all of the interesting + * counter expiration events, but we do not want to hear about + * normal rx/tx as the DMA engine tells us that. + */ + writel(MAC_TXSTAT_XMIT, gp->regs + MAC_TXMASK); + writel(MAC_RXSTAT_RCV, gp->regs + MAC_RXMASK); + + /* Don't enable even the PAUSE interrupts for now, we + * make no use of those events other than to record them. + */ + writel(0xffffffff, gp->regs + MAC_MCMASK); } -static void -gem_init_pause_thresholds(struct gem* gp) +static void gem_init_pause_thresholds(struct gem *gp) { /* Calculate pause thresholds. Setting the OFF threshold to the * full RX fifo size effectively disables PAUSE generation which @@ -1580,11 +1812,7 @@ } { - u32 cfg = readl(gp->regs + GREG_BIFCFG); - - /* XXX Why do I do this? -DaveM XXX */ - cfg |= GREG_BIFCFG_B64DIS; - writel(cfg, gp->regs + GREG_BIFCFG); + u32 cfg; cfg = GREG_CFG_IBURST; cfg |= ((31 << 1) & GREG_CFG_TXDMALIM); @@ -1598,21 +1826,15 @@ struct pci_dev *pdev = gp->pdev; u32 mif_cfg; - /* On Apple's sungem, we can't realy on registers as the chip + /* On Apple's sungem, we can't rely on registers as the chip * was been powered down by the firmware. We do the PHY lookup * when the interface is opened and we configure the driver * with known values. */ if (pdev->vendor == PCI_VENDOR_ID_APPLE) { gp->phy_type = phy_mii_mdio0; - mif_cfg = readl(gp->regs + MIF_CFG); - mif_cfg &= ~MIF_CFG_PSELECT; - writel(mif_cfg, gp->regs + MIF_CFG); - writel(PCS_DMODE_MGM, gp->regs + PCS_DMODE); - writel(MAC_XIFCFG_OE, gp->regs + MAC_XIFCFG); gp->tx_fifo_sz = readl(gp->regs + TXDMA_FSZ) * 64; gp->rx_fifo_sz = readl(gp->regs + RXDMA_FSZ) * 64; - gem_init_pause_thresholds(gp); return 0; } @@ -1651,7 +1873,7 @@ for (i = 0; i < 32; i++) { gp->mii_phy_addr = i; - if (phy_read(gp, PHY_CTRL) != 0xffff) + if (phy_read(gp, MII_BMCR) != 0xffff) break; } if (i == 32) { @@ -1685,12 +1907,10 @@ } } - gem_init_pause_thresholds(gp); - return 0; } -static void gem_init_hw(struct gem *gp) +static void gem_init_hw(struct gem *gp, int restart_link) { /* On Apple's gmac, I initialize the PHY only after * setting up the chip. It appears the gigabit PHYs @@ -1698,18 +1918,28 @@ * the chip is not running, I suspect it might not * be clocked at that point. --BenH */ - if (gp->pdev->vendor == PCI_VENDOR_ID_APPLE) { - gem_check_invariants(gp); - gp->hw_running = 1; - } - gem_init_phy(gp); + if (restart_link) + gem_init_phy(gp); gem_init_dma(gp); gem_init_mac(gp); + gem_init_pause_thresholds(gp); - gp->timer_ticks = 0; - gp->lstate = aneg_wait; - gp->link_timer.expires = jiffies + ((12 * HZ) / 10); - add_timer(&gp->link_timer); + spin_lock_irq(&gp->lock); + if (restart_link) { + /* Default aneg parameters */ + gp->timer_ticks = 0; + gp->lstate = link_down; + + spin_unlock_irq(&gp->lock); + + /* Can I advertise gigabit here ? I'd need BCM PHY docs... */ + gem_begin_auto_negotiation(gp, NULL); + } else { + if (gp->lstate == link_up) + gem_set_link_modes(gp); + + spin_unlock_irq(&gp->lock); + } } #ifdef CONFIG_ALL_PPC @@ -1717,10 +1947,10 @@ * setup properly. There appear to be no need to restore the * base addresses. */ -static void -gem_apple_powerup(struct gem* gp) +static void gem_apple_powerup(struct gem *gp) { u16 cmd; + u32 mif_cfg; pmac_call_feature(PMAC_FTR_GMAC_ENABLE, gp->of_node, 0, 1); @@ -1731,31 +1961,162 @@ pci_write_config_word(gp->pdev, PCI_COMMAND, cmd); pci_write_config_byte(gp->pdev, PCI_LATENCY_TIMER, 6); pci_write_config_byte(gp->pdev, PCI_CACHE_LINE_SIZE, 8); + + mdelay(1); + + mif_cfg = readl(gp->regs + MIF_CFG); + mif_cfg &= ~(MIF_CFG_PSELECT|MIF_CFG_POLL|MIF_CFG_BBMODE|MIF_CFG_MDI1); + mif_cfg |= MIF_CFG_MDI0; + writel(mif_cfg, gp->regs + MIF_CFG); + writel(PCS_DMODE_MGM, gp->regs + PCS_DMODE); + writel(MAC_XIFCFG_OE, gp->regs + MAC_XIFCFG); + + mdelay(1); } /* Turn off the chip's clock */ -static void -gem_apple_powerdown(struct gem* gp) +static void gem_apple_powerdown(struct gem *gp) { pmac_call_feature(PMAC_FTR_GMAC_ENABLE, gp->of_node, 0, 0); } + +#endif /* CONFIG_ALL_PPC */ + +static void gem_stop_phy(struct gem *gp) +{ + u32 mifcfg; + + if (!gp->wake_on_lan && gp->phy_mod == phymod_bcm5201) + phy_write(gp, MII_BCM5201_INTERRUPT, 0); + + /* Make sure we aren't polling PHY status change. We + * don't currently use that feature though + */ + mifcfg = readl(gp->regs + MIF_CFG); + mifcfg &= ~MIF_CFG_POLL; + writel(mifcfg, gp->regs + MIF_CFG); + + /* Here's a strange hack used by both MacOS 9 and X */ + phy_write(gp, MII_LPA, phy_read(gp, MII_LPA)); + + if (gp->wake_on_lan) { + /* Setup wake-on-lan */ + } else + writel(0, gp->regs + MAC_RXCFG); + writel(0, gp->regs + MAC_TXCFG); + writel(0, gp->regs + MAC_XIFCFG); + writel(0, gp->regs + TXDMA_CFG); + writel(0, gp->regs + RXDMA_CFG); + + if (!gp->wake_on_lan) { + gem_stop(gp); + writel(MAC_TXRST_CMD, gp->regs + MAC_TXRST); + writel(MAC_RXRST_CMD, gp->regs + MAC_RXRST); + if (gp->phy_mod == phymod_bcm5400 || gp->phy_mod == phymod_bcm5401 || + gp->phy_mod == phymod_bcm5411) { +#if 0 /* Commented out in Darwin... someone has those dawn docs ? */ + phy_write(gp, MII_BMCR, BMCR_PDOWN); +#endif + } else if (gp->phy_mod == phymod_bcm5201 || gp->phy_mod == phymod_bcm5221) { +#if 0 /* Commented out in Darwin... someone has those dawn docs ? */ + u16 val = phy_read(gp, MII_BCM5201_AUXMODE2) + phy_write(gp, MII_BCM5201_AUXMODE2, + val & ~MII_BCM5201_AUXMODE2_LOWPOWER); +#endif + phy_write(gp, MII_BCM5201_MULTIPHY, MII_BCM5201_MULTIPHY_SUPERISOLATE); + } + + /* According to Apple, we must set the MDIO pins to this begnign + * state or we may 1) eat more current, 2) damage some PHYs + */ + writel(mifcfg | MIF_CFG_BBMODE, gp->regs + MIF_CFG); + writel(0, gp->regs + MIF_BBCLK); + writel(0, gp->regs + MIF_BBDATA); + writel(0, gp->regs + MIF_BBOENAB); + writel(MAC_XIFCFG_GMII | MAC_XIFCFG_LBCK, gp->regs + MAC_XIFCFG); + (void) readl(gp->regs + MAC_XIFCFG); + } +} + +/* Shut down the chip, must be called with pm_sem held. */ +static void gem_shutdown(struct gem *gp) +{ + /* Make us not-running to avoid timers respawning */ + gp->hw_running = 0; + + /* Stop the link timer */ + del_timer_sync(&gp->link_timer); + + /* Stop the reset task */ + while (gp->reset_task_pending) + schedule(); + + /* Actually stop the chip */ + if (gp->pdev->vendor == PCI_VENDOR_ID_APPLE) + gem_stop_phy(gp); + else + gem_stop(gp); + +#ifdef CONFIG_ALL_PPC + /* Power down the chip */ + if (gp->pdev->vendor == PCI_VENDOR_ID_APPLE) + gem_apple_powerdown(gp); #endif /* CONFIG_ALL_PPC */ +} + +static void gem_pm_task(void *data) +{ + struct gem *gp = (struct gem *) data; + + /* We assume if we can't lock the pm_sem, then open() was + * called again (or suspend()), and we can safely ignore + * the PM request + */ + if (down_trylock(&gp->pm_sem)) + return; + + /* Driver was re-opened or already shut down */ + if (gp->opened || !gp->hw_running) { + up(&gp->pm_sem); + return; + } + + gem_shutdown(gp); + + up(&gp->pm_sem); +} + +static void gem_pm_timer(unsigned long data) +{ + struct gem *gp = (struct gem *) data; + + schedule_task(&gp->pm_task); +} static int gem_open(struct net_device *dev) { struct gem *gp = dev->priv; - unsigned long regs = gp->regs; + int hw_was_up = gp->hw_running; - del_timer(&gp->link_timer); + down(&gp->pm_sem); + /* Stop the PM timer/task */ + del_timer(&gp->pm_timer); + flush_scheduled_tasks(); + + if (!gp->hw_running) { #ifdef CONFIG_ALL_PPC - /* First, we need to bring up the chip */ - if (gp->pdev->vendor == PCI_VENDOR_ID_APPLE) - gem_apple_powerup(gp); + /* First, we need to bring up the chip */ + if (gp->pdev->vendor == PCI_VENDOR_ID_APPLE) { + gem_apple_powerup(gp); + gem_check_invariants(gp); + } #endif /* CONFIG_ALL_PPC */ + /* Reset the chip */ + gem_stop(gp); - /* Reset the chip */ - gem_stop(gp, regs); + gp->hw_running = 1; + } /* We can now request the interrupt as we know it's masked * on the controller @@ -1763,9 +2124,14 @@ if (request_irq(gp->pdev->irq, gem_interrupt, SA_SHIRQ, dev->name, (void *)dev)) { #ifdef CONFIG_ALL_PPC - if (gp->pdev->vendor == PCI_VENDOR_ID_APPLE) + if (!hw_was_up && gp->pdev->vendor == PCI_VENDOR_ID_APPLE) gem_apple_powerdown(gp); #endif /* CONFIG_ALL_PPC */ + /* Fire the PM timer that will shut us down in about 10 seconds */ + gp->pm_timer.expires = jiffies + 10*HZ; + add_timer(&gp->pm_timer); + up(&gp->pm_sem); + return -EAGAIN; } @@ -1773,7 +2139,11 @@ gem_init_rings(gp, 0); /* Init & setup chip hardware */ - gem_init_hw(gp); + gem_init_hw(gp, !hw_was_up); + + gp->opened = 1; + + up(&gp->pm_sem); return 0; } @@ -1782,17 +2152,110 @@ { struct gem *gp = dev->priv; - del_timer(&gp->link_timer); - gem_stop(gp, gp->regs); + /* Make sure we don't get distracted by suspend/resume */ + down(&gp->pm_sem); + + /* Stop traffic, mark us closed */ + spin_lock_irq(&gp->lock); + + gp->opened = 0; + writel(0xffffffff, gp->regs + GREG_IMASK); + netif_stop_queue(dev); + + spin_unlock_irq(&gp->lock); + + /* Stop chip */ + gem_stop(gp); + + /* Get rid of rings */ gem_clean_rings(gp); - gp->hw_running = 0; + + /* Bye, the pm timer will finish the job */ + free_irq(gp->pdev->irq, (void *) dev); + + /* Fire the PM timer that will shut us down in about 10 seconds */ + gp->pm_timer.expires = jiffies + 10*HZ; + add_timer(&gp->pm_timer); + + up(&gp->pm_sem); + + return 0; +} + +#ifdef CONFIG_PM +static int gem_suspend(struct pci_dev *pdev, u32 state) +{ + struct net_device *dev = pci_get_drvdata(pdev); + struct gem *gp = dev->priv; + + /* We hold the PM semaphore during entire driver + * sleep time + */ + down(&gp->pm_sem); + + printk(KERN_INFO "%s: suspending, WakeOnLan %s\n", + dev->name, gp->wake_on_lan ? "enabled" : "disabled"); + + /* If the driver is opened, we stop the DMA */ + if (gp->opened) { + /* Stop traffic, mark us closed */ + netif_device_detach(dev); + + spin_lock_irq(&gp->lock); + + writel(0xffffffff, gp->regs + GREG_IMASK); + + spin_unlock_irq(&gp->lock); + + /* Stop chip */ + gem_stop(gp); + + /* Get rid of ring buffers */ + gem_clean_rings(gp); + + if (gp->pdev->vendor == PCI_VENDOR_ID_APPLE) + disable_irq(gp->pdev->irq); + } + + if (gp->hw_running) { + /* Kill PM timer if any */ + del_timer_sync(&gp->pm_timer); + flush_scheduled_tasks(); + + gem_shutdown(gp); + } + + return 0; +} + +static int gem_resume(struct pci_dev *pdev) +{ + struct net_device *dev = pci_get_drvdata(pdev); + struct gem *gp = dev->priv; + + printk(KERN_INFO "%s: resuming\n", dev->name); + + if (gp->opened) { #ifdef CONFIG_ALL_PPC - if (gp->pdev->vendor == PCI_VENDOR_ID_APPLE) - gem_apple_powerdown(gp); + /* First, we need to bring up the chip */ + if (gp->pdev->vendor == PCI_VENDOR_ID_APPLE) { + gem_apple_powerup(gp); + gem_check_invariants(gp); + } #endif /* CONFIG_ALL_PPC */ - free_irq(gp->pdev->irq, (void *)dev); + gem_stop(gp); + gp->hw_running = 1; + gem_init_rings(gp, 0); + gem_init_hw(gp, 1); + netif_device_attach(dev); + if (gp->pdev->vendor == PCI_VENDOR_ID_APPLE) + enable_irq(gp->pdev->irq); + } + up(&gp->pm_sem); + return 0; } +#endif /* CONFIG_PM */ static struct net_device_stats *gem_get_stats(struct net_device *dev) { @@ -1908,12 +2371,219 @@ writel(hash_table[15], gp->regs + MAC_HASH15); } + /* Hrm... we may walk on the reset task here... */ netif_wake_queue(dev); } +/* Eventually add support for changing the advertisement + * on autoneg. + */ +static int gem_ethtool_ioctl(struct net_device *dev, void *ep_user) +{ + struct gem *gp = dev->priv; + u16 bmcr; + int full_duplex, speed, pause; + struct ethtool_cmd ecmd; + + if (copy_from_user(&ecmd, ep_user, sizeof(ecmd))) + return -EFAULT; + + switch(ecmd.cmd) { + case ETHTOOL_GDRVINFO: { + struct ethtool_drvinfo info = { cmd: ETHTOOL_GDRVINFO }; + + strncpy(info.driver, DRV_NAME, ETHTOOL_BUSINFO_LEN); + strncpy(info.version, DRV_VERSION, ETHTOOL_BUSINFO_LEN); + info.fw_version[0] = '\0'; + strncpy(info.bus_info, gp->pdev->slot_name, ETHTOOL_BUSINFO_LEN); + info.regdump_len = 0; /*SUNGEM_NREGS;*/ + + if (copy_to_user(ep_user, &info, sizeof(info))) + return -EFAULT; + + return 0; + } + + case ETHTOOL_GSET: + ecmd.supported = + (SUPPORTED_10baseT_Half | SUPPORTED_10baseT_Full | + SUPPORTED_100baseT_Half | SUPPORTED_100baseT_Full | + SUPPORTED_Autoneg | SUPPORTED_TP | SUPPORTED_MII); + + if (gp->gigabit_capable) + ecmd.supported |= + (SUPPORTED_1000baseT_Half | + SUPPORTED_1000baseT_Full); + + /* XXX hardcoded stuff for now */ + ecmd.port = PORT_MII; + ecmd.transceiver = XCVR_EXTERNAL; + ecmd.phy_address = 0; /* XXX fixed PHYAD */ + + /* Record PHY settings if HW is on. */ + if (gp->hw_running) { + bmcr = phy_read(gp, MII_BMCR); + gem_read_mii_link_mode(gp, &full_duplex, &speed, &pause); + } else + bmcr = 0; + if (bmcr & BMCR_ANENABLE) { + ecmd.autoneg = AUTONEG_ENABLE; + ecmd.speed = speed == 10 ? SPEED_10 : (speed == 1000 ? SPEED_1000 : SPEED_100); + ecmd.duplex = full_duplex ? DUPLEX_FULL : DUPLEX_HALF; + } else { + ecmd.autoneg = AUTONEG_DISABLE; + ecmd.speed = + (bmcr & BMCR_SPEED100) ? + SPEED_100 : SPEED_10; + ecmd.duplex = + (bmcr & BMCR_FULLDPLX) ? + DUPLEX_FULL : DUPLEX_HALF; + } + if (copy_to_user(ep_user, &ecmd, sizeof(ecmd))) + return -EFAULT; + return 0; + + case ETHTOOL_SSET: + if (!capable(CAP_NET_ADMIN)) + return -EPERM; + + /* Verify the settings we care about. */ + if (ecmd.autoneg != AUTONEG_ENABLE && + ecmd.autoneg != AUTONEG_DISABLE) + return -EINVAL; + + if (ecmd.autoneg == AUTONEG_DISABLE && + ((ecmd.speed != SPEED_100 && + ecmd.speed != SPEED_10) || + (ecmd.duplex != DUPLEX_HALF && + ecmd.duplex != DUPLEX_FULL))) + return -EINVAL; + + /* Apply settings and restart link process */ + if (gp->hw_running) + del_timer(&gp->link_timer); + gem_begin_auto_negotiation(gp, &ecmd); + return 0; + + case ETHTOOL_NWAY_RST: + if ((gp->link_cntl & BMCR_ANENABLE) == 0) + return -EINVAL; + if (gp->hw_running) + del_timer(&gp->link_timer); + gem_begin_auto_negotiation(gp, NULL); + return 0; + + case ETHTOOL_GWOL: + case ETHTOOL_SWOL: + break; /* todo */ + + /* get link status */ + case ETHTOOL_GLINK: { + struct ethtool_value edata = { cmd: ETHTOOL_GLINK }; + + edata.data = (gp->lstate == link_up); + if (copy_to_user(ep_user, &edata, sizeof(edata))) + return -EFAULT; + return 0; + } + + /* get message-level */ + case ETHTOOL_GMSGLVL: { + struct ethtool_value edata = { cmd: ETHTOOL_GMSGLVL }; + + edata.data = gem_debug; + if (copy_to_user(ep_user, &edata, sizeof(edata))) + return -EFAULT; + return 0; + } + + /* set message-level */ + case ETHTOOL_SMSGLVL: { + struct ethtool_value edata; + + if (copy_from_user(&edata, ep_user, sizeof(edata))) + return -EFAULT; + gem_debug = edata.data; + return 0; + } + +#if 0 + case ETHTOOL_GREGS: { + struct ethtool_regs regs; + u32 *regbuf; + int r = 0; + + if (copy_from_user(®s, useraddr, sizeof(regs))) + return -EFAULT; + + if (regs.len > SUNGEM_NREGS) { + regs.len = SUNGEM_NREGS; + } + regs.version = 0; + if (copy_to_user(useraddr, ®s, sizeof(regs))) + return -EFAULT; + + if (!gp->hw_running) + return -ENODEV; + useraddr += offsetof(struct ethtool_regs, data); + + /* Use kmalloc to avoid bloating the stack */ + regbuf = kmalloc(4 * SUNGEM_NREGS, GFP_KERNEL); + if (!regbuf) + return -ENOMEM; + spin_lock_irq(&np->lock); + gem_get_regs(gp, regbuf); + spin_unlock_irq(&np->lock); + + if (copy_to_user(useraddr, regbuf, regs.len*sizeof(u32))) + r = -EFAULT; + kfree(regbuf); + return r; + } +#endif + }; + + return -EOPNOTSUPP; +} + static int gem_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) { - return -EINVAL; + struct gem *gp = dev->priv; + struct mii_ioctl_data *data = (struct mii_ioctl_data *)&ifr->ifr_data; + int rc = -EOPNOTSUPP; + + /* Hold the PM semaphore while doing ioctl's or we may collide + * with open/close and power management and oops. + */ + down(&gp->pm_sem); + + switch (cmd) { + case SIOCETHTOOL: + rc = gem_ethtool_ioctl(dev, ifr->ifr_data); + break; + + case SIOCGMIIPHY: /* Get address of MII PHY in use. */ + data->phy_id = gp->mii_phy_addr; + /* Fallthrough... */ + + case SIOCGMIIREG: /* Read MII PHY register. */ + data->val_out = __phy_read(gp, data->reg_num & 0x1f, data->phy_id & 0x1f); + rc = 0; + break; + + case SIOCSMIIREG: /* Write MII PHY register. */ + if (!capable(CAP_NET_ADMIN)) { + rc = -EPERM; + } else { + __phy_write(gp, data->reg_num & 0x1f, data->val_in, data->phy_id & 0x1f); + rc = 0; + } + break; + }; + + up(&gp->pm_sem); + + return rc; } static int __devinit gem_get_device_address(struct gem *gp) @@ -2030,6 +2700,26 @@ gp->dev = dev; spin_lock_init(&gp->lock); + init_MUTEX(&gp->pm_sem); + + init_timer(&gp->link_timer); + gp->link_timer.function = gem_link_timer; + gp->link_timer.data = (unsigned long) gp; + + init_timer(&gp->pm_timer); + gp->pm_timer.function = gem_pm_timer; + gp->pm_timer.data = (unsigned long) gp; + + INIT_TQUEUE(&gp->pm_task, gem_pm_task, gp); + INIT_TQUEUE(&gp->reset_task, gem_reset_task, gp); + + /* Default link parameters */ + if (link_mode >= 0 && link_mode <= 6) + gp->link_cntl = link_modes[link_mode]; + else + gp->link_cntl = BMCR_ANENABLE; + gp->lstate = link_down; + gp->timer_ticks = 0; gp->regs = (unsigned long) ioremap(gemreg_base, gemreg_len); if (gp->regs == 0UL) { @@ -2038,9 +2728,26 @@ goto err_out_free_mmio_res; } - /* On Apple's, we might not access the hardware at that point */ + /* On Apple, we power the chip up now in order for check + * invariants to work, but also because the firmware might + * not have properly shut down the PHY. + */ +#ifdef CONFIG_ALL_PPC + if (pdev->vendor == PCI_VENDOR_ID_APPLE) { + gem_apple_powerup(gp); + if (gem_check_invariants(gp)) + goto err_out_iounmap; + gem_stop(gp); + gp->hw_running = 1; + gem_init_phy(gp); + gem_begin_auto_negotiation(gp, NULL); + } +#endif + /* Non Apple hardware, we just reset the chip and check + * for invariants + */ if (pdev->vendor != PCI_VENDOR_ID_APPLE) { - gem_stop(gp, gp->regs); + gem_stop(gp); if (gem_check_invariants(gp)) goto err_out_iounmap; gp->hw_running = 1; @@ -2074,10 +2781,6 @@ i == 5 ? ' ' : ':'); printk("\n"); - init_timer(&gp->link_timer); - gp->link_timer.function = gem_link_timer; - gp->link_timer.data = (unsigned long) gp; - dev->open = gem_open; dev->stop = gem_close; dev->hard_start_xmit = gem_start_xmit; @@ -2095,9 +2798,20 @@ if (pci_using_dac) dev->features |= NETIF_F_HIGHDMA; + /* Fire the PM timer that will shut us down in about 10 seconds */ + gp->pm_timer.expires = jiffies + 10*HZ; + add_timer(&gp->pm_timer); + return 0; err_out_iounmap: + down(&gp->pm_sem); + /* Stop the PM timer & task */ + del_timer_sync(&gp->pm_timer); + flush_scheduled_tasks(); + if (gp->hw_running) + gem_shutdown(gp); + up(&gp->pm_sem); iounmap((void *) gp->regs); err_out_free_mmio_res: @@ -2120,6 +2834,14 @@ unregister_netdev(dev); + down(&gp->pm_sem); + /* Stop the PM timer & task */ + del_timer_sync(&gp->pm_timer); + flush_scheduled_tasks(); + if (gp->hw_running) + gem_shutdown(gp); + up(&gp->pm_sem); + pci_free_consistent(pdev, sizeof(struct gem_init_block), gp->init_block, @@ -2127,9 +2849,6 @@ iounmap((void *) gp->regs); release_mem_region(pci_resource_start(pdev, 0), pci_resource_len(pdev, 0)); -#ifdef CONFIG_ALL_PPC - pmac_call_feature(PMAC_FTR_GMAC_ENABLE, gp->of_node, 0, 0); -#endif kfree(dev); pci_set_drvdata(pdev, NULL); @@ -2140,7 +2859,11 @@ name: GEM_MODULE_NAME, id_table: gem_pci_tbl, probe: gem_init_one, - remove: gem_remove_one, + remove: __devexit_p(gem_remove_one), +#ifdef CONFIG_PM + suspend: gem_suspend, + resume: gem_resume, +#endif /* CONFIG_PM */ }; static int __init gem_init(void) diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/net/sungem.h linux-2.5/drivers/net/sungem.h --- linux-2.5.1/drivers/net/sungem.h Sun Oct 21 17:36:54 2001 +++ linux-2.5/drivers/net/sungem.h Thu Dec 13 16:32:36 2001 @@ -1,4 +1,4 @@ -/* $Id: sungem.h,v 1.8 2001/10/17 05:55:39 davem Exp $ +/* $Id: sungem.h,v 1.10 2001/11/29 03:57:33 davem Exp $ * sungem.h: Definitions for Sun GEM ethernet driver. * * Copyright (C) 2000 David S. Miller (davem@redhat.com) @@ -753,64 +753,38 @@ #define PROM_SIZE 0x0fffffUL /* Size of ROM */ #define PROM_END 0x200000UL /* End of ROM */ -/* MII phy registers */ -#define PHY_CTRL 0x00 -#define PHY_STAT 0x01 -#define PHY_ID0 0x02 -#define PHY_ID1 0x03 -#define PHY_ADV 0x04 -#define PHY_LPA 0x05 - -#define PHY_CTRL_SPD2 0x0040 /* Gigabit enable? (bcm5411) */ -#define PHY_CTRL_FDPLX 0x0100 /* Full duplex */ -#define PHY_CTRL_ISO 0x0400 /* Isloate MII from PHY */ -#define PHY_CTRL_ANRES 0x0200 /* Auto-negotiation restart */ -#define PHY_CTRL_ANENAB 0x1000 /* Auto-negotiation enable */ -#define PHY_CTRL_SPD100 0x2000 /* Select 100Mbps */ -#define PHY_CTRL_RST 0x8000 /* Reset PHY */ - -#define PHY_STAT_LSTAT 0x0004 /* Link status */ -#define PHY_STAT_ANEGC 0x0020 /* Auto-negotiation complete */ - -#define PHY_ADV_10HALF 0x0020 -#define PHY_ADV_10FULL 0x0040 -#define PHY_ADV_100HALF 0x0080 -#define PHY_ADV_100FULL 0x0100 - -#define PHY_LPA_10HALF 0x0020 -#define PHY_LPA_10FULL 0x0040 -#define PHY_LPA_100HALF 0x0080 -#define PHY_LPA_100FULL 0x0100 -#define PHY_LPA_PAUSE 0x0400 -#define PHY_LPA_FAULT 0x2000 +/* MII definitions missing from mii.h */ + +#define BMCR_SPD2 0x0040 /* Gigabit enable? (bcm5411) */ +#define LPA_PAUSE 0x0400 /* More PHY registers (specific to Broadcom models) */ /* MII BCM5201 MULTIPHY interrupt register */ -#define PHY_BCM5201_INTERRUPT 0x1A -#define PHY_BCM5201_INTERRUPT_INTENABLE 0x4000 +#define MII_BCM5201_INTERRUPT 0x1A +#define MII_BCM5201_INTERRUPT_INTENABLE 0x4000 -#define PHY_BCM5201_AUXMODE2 0x1B -#define PHY_BCM5201_AUXMODE2_LOWPOWER 0x0008 +#define MII_BCM5201_AUXMODE2 0x1B +#define MII_BCM5201_AUXMODE2_LOWPOWER 0x0008 -#define PHY_BCM5201_MULTIPHY 0x1E +#define MII_BCM5201_MULTIPHY 0x1E /* MII BCM5201 MULTIPHY register bits */ -#define PHY_BCM5201_MULTIPHY_SERIALMODE 0x0002 -#define PHY_BCM5201_MULTIPHY_SUPERISOLATE 0x0008 +#define MII_BCM5201_MULTIPHY_SERIALMODE 0x0002 +#define MII_BCM5201_MULTIPHY_SUPERISOLATE 0x0008 /* MII BCM5400 1000-BASET Control register */ -#define PHY_BCM5400_GB_CONTROL 0x09 -#define PHY_BCM5400_GB_CONTROL_FULLDUPLEXCAP 0x0200 +#define MII_BCM5400_GB_CONTROL 0x09 +#define MII_BCM5400_GB_CONTROL_FULLDUPLEXCAP 0x0200 /* MII BCM5400 AUXCONTROL register */ -#define PHY_BCM5400_AUXCONTROL 0x18 -#define PHY_BCM5400_AUXCONTROL_PWR10BASET 0x0004 +#define MII_BCM5400_AUXCONTROL 0x18 +#define MII_BCM5400_AUXCONTROL_PWR10BASET 0x0004 /* MII BCM5400 AUXSTATUS register */ -#define PHY_BCM5400_AUXSTATUS 0x19 -#define PHY_BCM5400_AUXSTATUS_LINKMODE_MASK 0x0700 -#define PHY_BCM5400_AUXSTATUS_LINKMODE_SHIFT 8 +#define MII_BCM5400_AUXSTATUS 0x19 +#define MII_BCM5400_AUXSTATUS_LINKMODE_MASK 0x0700 +#define MII_BCM5400_AUXSTATUS_LINKMODE_SHIFT 8 /* When it can, GEM internally caches 4 aligned TX descriptors * at a time, so that it can use full cacheline DMA reads. @@ -936,9 +910,21 @@ #define RX_COPY_THRESHOLD 256 +#if TX_RING_SIZE < 128 +#define INIT_BLOCK_TX_RING_SIZE 128 +#else +#define INIT_BLOCK_TX_RING_SIZE TX_RING_SIZE +#endif + +#if RX_RING_SIZE < 128 +#define INIT_BLOCK_RX_RING_SIZE 128 +#else +#define INIT_BLOCK_RX_RING_SIZE RX_RING_SIZE +#endif + struct gem_init_block { - struct gem_txd txd[TX_RING_SIZE]; - struct gem_rxd rxd[RX_RING_SIZE]; + struct gem_txd txd[INIT_BLOCK_TX_RING_SIZE]; + struct gem_rxd rxd[INIT_BLOCK_RX_RING_SIZE]; }; enum gem_phy_type { @@ -958,9 +944,12 @@ }; enum link_state { - aneg_wait, - force_wait, - aneg_up, + link_down = 0, /* No link, will retry */ + link_aneg, /* Autoneg in progress */ + link_force_try, /* Try Forced link speed */ + link_force_ret, /* Forced mode worked, retrying autoneg */ + link_force_ok, /* Stay in forced mode */ + link_up /* Link is up */ }; struct gem { @@ -973,6 +962,10 @@ * (ie. not power managed) */ int hw_running; + int opened; + struct semaphore pm_sem; + struct tq_struct pm_task; + struct timer_list pm_timer; struct gem_init_block *init_block; @@ -988,14 +981,22 @@ int rx_pause_off; int rx_pause_on; int mii_phy_addr; + int gigabit_capable; + /* Autoneg & PHY control */ + int link_cntl; + int link_advertise; + int link_fcntl; + enum link_state lstate; + struct timer_list link_timer; + int timer_ticks; + int wake_on_lan; + struct tq_struct reset_task; + volatile int reset_task_pending; + /* Diagnostic counters and state. */ u64 pause_entered; u16 pause_last_time_recvd; - - struct timer_list link_timer; - int timer_ticks; - enum link_state lstate; dma_addr_t gblock_dvma; struct pci_dev *pdev; diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/net/tlan.c linux-2.5/drivers/net/tlan.c --- linux-2.5.1/drivers/net/tlan.c Tue Nov 27 17:23:27 2001 +++ linux-2.5/drivers/net/tlan.c Thu Dec 13 16:32:36 2001 @@ -430,7 +430,7 @@ name: "tlan", id_table: tlan_pci_tbl, probe: tlan_init_one, - remove: tlan_remove_one, + remove: __devexit_p(tlan_remove_one), }; static int __init tlan_probe(void) diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/net/tokenring/lanstreamer.c linux-2.5/drivers/net/tokenring/lanstreamer.c --- linux-2.5.1/drivers/net/tokenring/lanstreamer.c Sat Nov 10 23:38:59 2001 +++ linux-2.5/drivers/net/tokenring/lanstreamer.c Thu Dec 13 16:32:36 2001 @@ -1812,7 +1812,7 @@ name: "lanstreamer", id_table: streamer_pci_tbl, probe: streamer_init_one, - remove: streamer_remove_one, + remove: __devexit_p(streamer_remove_one), }; static int __init streamer_init_module(void) { diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/net/tokenring/olympic.c linux-2.5/drivers/net/tokenring/olympic.c --- linux-2.5.1/drivers/net/tokenring/olympic.c Fri Nov 9 21:46:29 2001 +++ linux-2.5/drivers/net/tokenring/olympic.c Thu Dec 13 16:32:36 2001 @@ -1705,7 +1705,7 @@ name: "olympic", id_table: olympic_pci_tbl, probe: olympic_probe, - remove: olympic_remove_one + remove: __devexit_p(olympic_remove_one), }; static int __init olympic_pci_init(void) diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/net/tokenring/tmspci.c linux-2.5/drivers/net/tokenring/tmspci.c --- linux-2.5.1/drivers/net/tokenring/tmspci.c Thu Sep 13 23:04:43 2001 +++ linux-2.5/drivers/net/tokenring/tmspci.c Sat Dec 22 00:08:54 2001 @@ -253,7 +253,7 @@ return 0; } -static void __exit tms_pci_rmmod (void) +static void __devexit tms_pci_rmmod (void) { pci_unregister_driver (&tms_pci_driver); } diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/net/tulip/tulip_core.c linux-2.5/drivers/net/tulip/tulip_core.c --- linux-2.5.1/drivers/net/tulip/tulip_core.c Tue Dec 11 18:47:49 2001 +++ linux-2.5/drivers/net/tulip/tulip_core.c Thu Dec 13 16:32:36 2001 @@ -1786,7 +1786,7 @@ name: DRV_NAME, id_table: tulip_pci_tbl, probe: tulip_init_one, - remove: tulip_remove_one, + remove: __devexit_p(tulip_remove_one), #ifdef CONFIG_PM suspend: tulip_suspend, resume: tulip_resume, diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/net/via-rhine.c linux-2.5/drivers/net/via-rhine.c --- linux-2.5.1/drivers/net/via-rhine.c Fri Nov 9 21:45:36 2001 +++ linux-2.5/drivers/net/via-rhine.c Wed Dec 19 01:08:32 2001 @@ -161,7 +161,7 @@ KERN_INFO "via-rhine.c:v1.10-LK1.1.12 03/11/2001 Written by Donald Becker\n" KERN_INFO " http://www.scyld.com/network/via-rhine.html\n"; -static char shortname[] __devinitdata = "via-rhine"; +static char shortname[] = "via-rhine"; /* This driver was written to use PCI memory space, however most versions @@ -1667,7 +1667,7 @@ name: "via-rhine", id_table: via_rhine_pci_tbl, probe: via_rhine_init_one, - remove: via_rhine_remove_one, + remove: __devexit_p(via_rhine_remove_one), }; diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/net/wan/comx-hw-mixcom.c linux-2.5/drivers/net/wan/comx-hw-mixcom.c --- linux-2.5.1/drivers/net/wan/comx-hw-mixcom.c Thu Sep 13 23:04:43 2001 +++ linux-2.5/drivers/net/wan/comx-hw-mixcom.c Thu Dec 13 16:32:36 2001 @@ -566,8 +566,6 @@ return 0; -err_restore_flags: - restore_flags(flags); err_release_region: release_region(dev->base_addr, MIXCOM_IO_EXTENT); err_ret: diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/net/wan/farsync.c linux-2.5/drivers/net/wan/farsync.c --- linux-2.5.1/drivers/net/wan/farsync.c Fri Nov 9 21:41:42 2001 +++ linux-2.5/drivers/net/wan/farsync.c Thu Dec 13 16:32:36 2001 @@ -1810,7 +1810,7 @@ name: FST_NAME, id_table: fst_pci_dev_id, probe: fst_add_one, - remove: fst_remove_one, + remove: __devexit_p(fst_remove_one), suspend: NULL, resume: NULL, }; diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/net/wan/lapbether.c linux-2.5/drivers/net/wan/lapbether.c --- linux-2.5.1/drivers/net/wan/lapbether.c Thu Sep 13 23:04:43 2001 +++ linux-2.5/drivers/net/wan/lapbether.c Sun Dec 30 21:17:30 2001 @@ -32,7 +32,6 @@ #include <linux/if_arp.h> #include <linux/skbuff.h> #include <net/sock.h> -#include <asm/segment.h> #include <asm/system.h> #include <asm/uaccess.h> #include <linux/mm.h> diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/net/wan/lmc/lmc_main.c linux-2.5/drivers/net/wan/lmc/lmc_main.c --- linux-2.5.1/drivers/net/wan/lmc/lmc_main.c Thu Sep 13 23:04:43 2001 +++ linux-2.5/drivers/net/wan/lmc/lmc_main.c Sun Dec 30 21:17:30 2001 @@ -50,7 +50,6 @@ #include <linux/interrupt.h> #include <linux/pci.h> #include <linux/delay.h> -#include <asm/segment.h> #include <linux/init.h> #if LINUX_VERSION_CODE < 0x20155 diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/net/wan/lmc/lmc_media.c linux-2.5/drivers/net/wan/lmc/lmc_media.c --- linux-2.5.1/drivers/net/wan/lmc/lmc_media.c Wed Mar 7 03:44:36 2001 +++ linux-2.5/drivers/net/wan/lmc/lmc_media.c Sun Dec 30 21:17:30 2001 @@ -12,7 +12,6 @@ #include <linux/slab.h> #include <linux/interrupt.h> #include <linux/pci.h> -#include <asm/segment.h> //#include <asm/smp.h> #if LINUX_VERSION_CODE < 0x20155 diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/net/wan/lmc/lmc_proto.c linux-2.5/drivers/net/wan/lmc/lmc_proto.c --- linux-2.5.1/drivers/net/wan/lmc/lmc_proto.c Wed Mar 7 03:44:36 2001 +++ linux-2.5/drivers/net/wan/lmc/lmc_proto.c Sun Dec 30 21:17:30 2001 @@ -30,7 +30,6 @@ #include <linux/slab.h> #include <linux/interrupt.h> #include <linux/pci.h> -#include <asm/segment.h> #include <asm/smp.h> #include <linux/in.h> diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/net/wan/sdla_fr.c linux-2.5/drivers/net/wan/sdla_fr.c --- linux-2.5.1/drivers/net/wan/sdla_fr.c Thu Sep 13 23:04:43 2001 +++ linux-2.5/drivers/net/wan/sdla_fr.c Sun Dec 30 21:16:28 2001 @@ -163,10 +163,9 @@ #include <linux/sdla_fr.h> /* frame relay firmware API definitions */ -#if defined(LINUX_2_1) || defined(LINUX_2_4) - #include <asm/uaccess.h> - #include <linux/inetdevice.h> - #include <linux/netdevice.h> +#include <asm/uaccess.h> +#include <linux/inetdevice.h> +#include <linux/netdevice.h> #else #include <asm/segment.h> diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/net/winbond-840.c linux-2.5/drivers/net/winbond-840.c --- linux-2.5.1/drivers/net/winbond-840.c Tue Oct 9 22:13:02 2001 +++ linux-2.5/drivers/net/winbond-840.c Thu Dec 13 16:32:36 2001 @@ -1697,7 +1697,7 @@ name: DRV_NAME, id_table: w840_pci_tbl, probe: w840_probe1, - remove: w840_remove1, + remove: __devexit_p(w840_remove1), #ifdef CONFIG_PM suspend: w840_suspend, resume: w840_resume, diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/net/wireless/airo.c linux-2.5/drivers/net/wireless/airo.c --- linux-2.5.1/drivers/net/wireless/airo.c Fri Nov 9 21:41:42 2001 +++ linux-2.5/drivers/net/wireless/airo.c Sun Dec 30 21:17:30 2001 @@ -19,7 +19,6 @@ #include <linux/config.h> #include <linux/version.h> -#include <asm/segment.h> #include <linux/init.h> #include <linux/kernel.h> @@ -47,7 +46,7 @@ #include <asm/uaccess.h> #ifdef CONFIG_PCI -static struct pci_device_id card_ids[] = __devinitdata { +static struct pci_device_id card_ids[] __devinitdata = { { 0x14b9, 1, PCI_ANY_ID, PCI_ANY_ID, }, { 0x14b9, 0x4500, PCI_ANY_ID, PCI_ANY_ID }, { 0x14b9, 0x4800, PCI_ANY_ID, PCI_ANY_ID, }, @@ -64,7 +63,7 @@ name: "airo", id_table: card_ids, probe: airo_pci_probe, - remove: airo_pci_remove, + remove: __devexit_p(airo_pci_remove), }; #endif /* CONFIG_PCI */ diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/net/wireless/orinoco_plx.c linux-2.5/drivers/net/wireless/orinoco_plx.c --- linux-2.5.1/drivers/net/wireless/orinoco_plx.c Tue Oct 9 22:13:03 2001 +++ linux-2.5/drivers/net/wireless/orinoco_plx.c Thu Dec 13 16:32:36 2001 @@ -279,7 +279,7 @@ name:"orinoco_plx", id_table:orinoco_plx_pci_id_table, probe:orinoco_plx_init_one, - remove:orinoco_plx_remove_one, + remove:__devexit_p(orinoco_plx_remove_one), suspend:0, resume:0 }; diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/net/yellowfin.c linux-2.5/drivers/net/yellowfin.c --- linux-2.5.1/drivers/net/yellowfin.c Fri Oct 19 15:32:28 2001 +++ linux-2.5/drivers/net/yellowfin.c Thu Dec 13 16:32:36 2001 @@ -1506,7 +1506,7 @@ name: DRV_NAME, id_table: yellowfin_pci_tbl, probe: yellowfin_init_one, - remove: yellowfin_remove_one, + remove: __devexit_p(yellowfin_remove_one), }; diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/parport/ChangeLog linux-2.5/drivers/parport/ChangeLog --- linux-2.5.1/drivers/parport/ChangeLog Mon Nov 12 17:45:32 2001 +++ linux-2.5/drivers/parport/ChangeLog Thu Dec 13 16:32:36 2001 @@ -1,3 +1,33 @@ +2001-12-07 Tim Waugh <twaugh@redhat.com> + + * ieee1284_ops.c (parport_ieee1284_epp_write_addr, + parport_ieee1284_epp_read_addr): Actually do something useful. + +2001-12-07 Tim Waugh <twaugh@redhat.com> + + * parport_pc.c (dmaval): Don't use DMA by default. It seems to be + too buggy at the moment. Use 'dma=auto' to restore the previous + behaviour. + +2001-12-03 Rich Liu <Rich.Liu@ite.com.tw> + + * parport_pc.c (sio_ite_8872_probe): ITE8873 is a single-port + serial board, not a serial+parallel. + +2001-11-30 Niels Kristian Bech Jensen <nkbj@image.dk> + + * parport_pc.c: Fix compiler warning. + +2001-12-07 Tim Waugh <twaugh@redhat.com> + + * daisy.c (DEBUG): Undefine. + +2001-12-06 Tim Waugh <twaugh@redhat.com> + + * ieee1284_ops.c (parport_ieee1284_ecp_read_data): Mask off + PARPORT_CONTROL_AUTOFD as well. Bug spotted by Joe + <joeja@mindspring.com>. + 2001-11-12 Tim Waugh <twaugh@redhat.com> * parport_pc.c (init_module): Warn when parameters are ignored. diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/parport/Config.in linux-2.5/drivers/parport/Config.in --- linux-2.5.1/drivers/parport/Config.in Sun Nov 11 18:09:33 2001 +++ linux-2.5/drivers/parport/Config.in Thu Dec 13 16:32:36 2001 @@ -24,9 +24,13 @@ bool ' Use FIFO/DMA if available (EXPERIMENTAL)' CONFIG_PARPORT_PC_FIFO bool ' SuperIO chipset support (EXPERIMENTAL)' CONFIG_PARPORT_PC_SUPERIO fi - fi - if [ "$CONFIG_HOTPLUG" = "y" -a "$CONFIG_PCMCIA" != "n" ]; then - dep_tristate ' Support for PCMCIA management for PC-style ports' CONFIG_PARPORT_PC_PCMCIA $CONFIG_PCMCIA + if [ "$CONFIG_HOTPLUG" = "y" -a "$CONFIG_PCMCIA" != "n" ]; then + if [ "$CONFIG_PARPORT_PC" = "y" ]; then + dep_tristate ' Support for PCMCIA management for PC-style ports' CONFIG_PARPORT_PC_PCMCIA $CONFIG_PCMCIA + else + dep_tristate ' Support for PCMCIA management for PC-style ports' CONFIG_PARPORT_PC_PCMCIA $CONFIG_PARPORT_PC + fi + fi fi if [ "$CONFIG_ARM" = "y" ]; then dep_tristate ' Archimedes hardware' CONFIG_PARPORT_ARC $CONFIG_PARPORT diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/parport/daisy.c linux-2.5/drivers/parport/daisy.c --- linux-2.5.1/drivers/parport/daisy.c Fri Jul 21 21:21:58 2000 +++ linux-2.5/drivers/parport/daisy.c Thu Dec 13 16:32:36 2001 @@ -23,7 +23,7 @@ #include <linux/delay.h> #include <asm/uaccess.h> -#define DEBUG /* undef me for production */ +#undef DEBUG /* undef me for production */ #ifdef DEBUG #define DPRINTK(stuff...) printk (stuff) diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/parport/ieee1284_ops.c linux-2.5/drivers/parport/ieee1284_ops.c --- linux-2.5.1/drivers/parport/ieee1284_ops.c Thu Oct 25 07:07:39 2001 +++ linux-2.5/drivers/parport/ieee1284_ops.c Thu Dec 13 16:32:36 2001 @@ -514,7 +514,8 @@ /* Set HostAck low to start accepting data. */ ctl = parport_read_control (port); - ctl &= ~(PARPORT_CONTROL_STROBE | PARPORT_CONTROL_INIT); + ctl &= ~(PARPORT_CONTROL_STROBE | PARPORT_CONTROL_INIT | + PARPORT_CONTROL_AUTOFD); parport_write_control (port, ctl | PARPORT_CONTROL_AUTOFD); while (count < len) { @@ -823,35 +824,40 @@ const void *buffer, size_t len, int flags) { - /* This is untested */ unsigned char *bp = (unsigned char *) buffer; size_t ret = 0; + /* set EPP idle state (just to make sure) with strobe low */ parport_frob_control (port, PARPORT_CONTROL_STROBE | + PARPORT_CONTROL_AUTOFD | PARPORT_CONTROL_SELECT | - PARPORT_CONTROL_AUTOFD, + PARPORT_CONTROL_INIT, PARPORT_CONTROL_STROBE | - PARPORT_CONTROL_SELECT); + PARPORT_CONTROL_INIT); port->ops->data_forward (port); for (; len > 0; len--, bp++) { - /* Write data and assert nAStrb. */ + /* Event 56: Write data and set nAStrb low. */ parport_write_data (port, *bp); parport_frob_control (port, PARPORT_CONTROL_SELECT, PARPORT_CONTROL_SELECT); - if (parport_poll_peripheral (port, PARPORT_STATUS_BUSY, - PARPORT_STATUS_BUSY, 10)) + /* Event 58: wait for busy (nWait) to go high */ + if (parport_poll_peripheral (port, PARPORT_STATUS_BUSY, 0, 10)) break; + /* Event 59: set nAStrb high */ parport_frob_control (port, PARPORT_CONTROL_SELECT, 0); - if (parport_poll_peripheral (port, PARPORT_STATUS_BUSY, 0, 5)) + /* Event 60: wait for busy (nWait) to go low */ + if (parport_poll_peripheral (port, PARPORT_STATUS_BUSY, + PARPORT_STATUS_BUSY, 5)) break; ret++; } + /* Event 61: set strobe (nWrite) high */ parport_frob_control (port, PARPORT_CONTROL_STROBE, 0); return ret; @@ -862,28 +868,36 @@ void *buffer, size_t len, int flags) { - /* This is untested. */ unsigned char *bp = (unsigned char *) buffer; unsigned ret = 0; + /* Set EPP idle state (just to make sure) with strobe high */ parport_frob_control (port, PARPORT_CONTROL_STROBE | - PARPORT_CONTROL_AUTOFD, 0); + PARPORT_CONTROL_AUTOFD | + PARPORT_CONTROL_SELECT | + PARPORT_CONTROL_INIT, + PARPORT_CONTROL_INIT); port->ops->data_reverse (port); for (; len > 0; len--, bp++) { - parport_frob_control (port, PARPORT_CONTROL_SELECT, 0); + /* Event 64: set nSelectIn (nAStrb) low */ + parport_frob_control (port, PARPORT_CONTROL_SELECT, + PARPORT_CONTROL_SELECT); - /* Event 58 */ - if (parport_poll_peripheral (port, PARPORT_STATUS_BUSY, - PARPORT_STATUS_BUSY, 10)) + /* Event 58: wait for Busy to go high */ + if (parport_wait_peripheral (port, PARPORT_STATUS_BUSY, 0)) { break; + } *bp = parport_read_data (port); + /* Event 59: set nSelectIn (nAStrb) high */ parport_frob_control (port, PARPORT_CONTROL_SELECT, PARPORT_CONTROL_SELECT); - if (parport_poll_peripheral (port, PARPORT_STATUS_BUSY, 0, 5)) + /* Event 60: wait for Busy to go low */ + if (parport_poll_peripheral (port, PARPORT_STATUS_BUSY, + PARPORT_STATUS_BUSY, 5)) break; ret++; diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/parport/parport_cs.c linux-2.5/drivers/parport/parport_cs.c --- linux-2.5.1/drivers/parport/parport_cs.c Sun Sep 30 19:26:08 2001 +++ linux-2.5/drivers/parport/parport_cs.c Tue Dec 18 14:53:28 2001 @@ -5,7 +5,7 @@ (specifically, for the Quatech SPP-100 EPP card: other cards will probably require driver tweaks) - parport_cs.c 1.20 2000/11/02 23:15:05 + parport_cs.c 1.24 2001/10/13 14:04:05 The contents of this file are subject to the Mozilla Public License Version 1.1 (the "License"); you may not use this file @@ -45,6 +45,7 @@ #include <linux/string.h> #include <linux/timer.h> #include <linux/ioport.h> +#include <linux/major.h> #include <linux/parport.h> #include <linux/parport_pc.h> @@ -57,32 +58,31 @@ #include <pcmcia/cisreg.h> #include <pcmcia/ciscode.h> -#ifdef PCMCIA_DEBUG -static int pc_debug = PCMCIA_DEBUG; -MODULE_PARM(pc_debug, "i"); -#define DEBUG(n, args...) if (pc_debug>(n)) printk(KERN_DEBUG args) -static char *version = -"parport_cs.c 1.20 2000/11/02 23:15:05 (David Hinds)"; -#else -#define DEBUG(n, args...) -#endif +/*====================================================================*/ -#ifndef VERSION -#define VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c)) -#endif +/* Module parameters */ -/*====================================================================*/ +MODULE_AUTHOR("David Hinds <dahinds@users.sourceforge.net>"); +MODULE_DESCRIPTION("PCMCIA parallel port card driver"); +MODULE_LICENSE("Dual MPL/GPL"); -/* Parameters that can be set with 'insmod' */ +#define INT_MODULE_PARM(n, v) static int n = v; MODULE_PARM(n, "i") /* Bit map of interrupts to choose from */ -static u_int irq_mask = 0xdeb8; +INT_MODULE_PARM(irq_mask, 0xdeb8); static int irq_list[4] = { -1 }; -static int epp_mode = 1; - -MODULE_PARM(irq_mask, "i"); MODULE_PARM(irq_list, "1-4i"); -MODULE_PARM(epp_mode, "i"); + +INT_MODULE_PARM(epp_mode, 1); + +#ifdef PCMCIA_DEBUG +INT_MODULE_PARM(pc_debug, PCMCIA_DEBUG); +#define DEBUG(n, args...) if (pc_debug>(n)) printk(KERN_DEBUG args) +static char *version = +"parport_cs.c 1.24 2001/10/13 14:04:05 (David Hinds)"; +#else +#define DEBUG(n, args...) +#endif /*====================================================================*/ @@ -105,9 +105,6 @@ static dev_info_t dev_info = "parport_cs"; static dev_link_t *dev_list = NULL; -extern struct parport_operations parport_pc_ops; -static struct parport_operations parport_cs_ops; - /*====================================================================*/ static void cs_error(client_handle_t handle, int func, int ret) @@ -307,19 +304,6 @@ goto failed; } -#if (LINUX_VERSION_CODE < VERSION(2,3,6)) -#if (LINUX_VERSION_CODE >= VERSION(2,2,8)) - p->private_data = kmalloc(sizeof(struct parport_pc_private), - GFP_KERNEL); - ((struct parport_pc_private *)(p->private_data))->ctr = 0x0c; -#endif - parport_proc_register(p); - p->flags |= PARPORT_FLAG_COMA; - parport_pc_write_econtrol(p, 0x00); - parport_pc_write_control(p, 0x0c); - parport_pc_write_data(p, 0x00); -#endif - p->modes |= PARPORT_MODE_PCSPP; if (epp_mode) p->modes |= PARPORT_MODE_TRISTATE | PARPORT_MODE_EPP; @@ -365,14 +349,8 @@ if (info->ndev) { struct parport *p = info->port; -#if (LINUX_VERSION_CODE < VERSION(2,3,6)) - if (!(p->flags & PARPORT_FLAG_COMA)) - parport_quiesce(p); -#endif parport_proc_unregister(p); -#if (LINUX_VERSION_CODE >= VERSION(2,2,8)) kfree(p->private_data); -#endif parport_unregister_port(p); } info->ndev = 0; @@ -430,24 +408,6 @@ /*====================================================================*/ -#if (LINUX_VERSION_CODE < VERSION(2,3,6)) - -static void inc_use_count(void) -{ - MOD_INC_USE_COUNT; - parport_pc_ops.inc_use_count(); -} - -static void dec_use_count(void) -{ - MOD_DEC_USE_COUNT; - parport_pc_ops.dec_use_count(); -} - -#endif - -/*====================================================================*/ - static int __init init_parport_cs(void) { servinfo_t serv; @@ -459,13 +419,6 @@ return -1; } -#if (LINUX_VERSION_CODE < VERSION(2,3,6)) - /* This is to protect against unloading modules out of order */ - parport_cs_ops = parport_pc_ops; - parport_cs_ops.inc_use_count = &inc_use_count; - parport_cs_ops.dec_use_count = &dec_use_count; -#endif - register_pccard_driver(&dev_info, &parport_attach, &parport_detach); return 0; } @@ -480,4 +433,3 @@ module_init(init_parport_cs); module_exit(exit_parport_cs); -MODULE_LICENSE("Dual MPL/GPL"); diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/parport/parport_pc.c linux-2.5/drivers/parport/parport_pc.c --- linux-2.5.1/drivers/parport/parport_pc.c Mon Nov 12 17:44:58 2001 +++ linux-2.5/drivers/parport/parport_pc.c Thu Dec 13 16:32:36 2001 @@ -91,7 +91,9 @@ } superios[NR_SUPERIOS] __devinitdata = { {0,},}; static int user_specified __devinitdata = 0; +#if defined(CONFIG_PARPORT_PC_FIFO) || defined(CONFIG_PARPORT_PC_SUPERIO) static int verbose_probing; +#endif static int registered_parport; /* frob_control, but for ECR */ @@ -1780,6 +1782,7 @@ return ok; } +#ifdef CONFIG_PARPORT_PC_FIFO static int __devinit parport_ECP_supported(struct parport *pb) { int i; @@ -1905,6 +1908,7 @@ return 1; } +#endif static int __devinit parport_ECPPS2_supported(struct parport *pb) { @@ -2004,7 +2008,9 @@ /* Don't bother probing for modes we know we won't use. */ static int __devinit parport_PS2_supported(struct parport *pb) { return 0; } +#ifdef CONFIG_PARPORT_PC_FIFO static int __devinit parport_ECP_supported(struct parport *pb) { return 0; } +#endif static int __devinit parport_EPP_supported(struct parport *pb) { return 0; } static int __devinit parport_ECPEPP_supported(struct parport *pb){return 0;} static int __devinit parport_ECPPS2_supported(struct parport *pb){return 0;} @@ -2453,9 +2459,8 @@ ite8872set = 0x64e00000; break; case 0x6: - printk (KERN_INFO "parport_pc: ITE8873 found (1S1P)\n"); - ite8872set = 0x64a00000; - break; + printk (KERN_INFO "parport_pc: ITE8873 found (1S)\n"); + return 0; case 0x8: DPRINTK (KERN_DEBUG "parport_pc: ITE8874 found (2S)\n"); return 0; @@ -3007,7 +3012,7 @@ static int io[PARPORT_PC_MAX_PORTS+1] = { [0 ... PARPORT_PC_MAX_PORTS] = 0 }; static int io_hi[PARPORT_PC_MAX_PORTS+1] = { [0 ... PARPORT_PC_MAX_PORTS] = PARPORT_IOHI_AUTO }; -static int dmaval[PARPORT_PC_MAX_PORTS] = { [0 ... PARPORT_PC_MAX_PORTS-1] = PARPORT_DMA_AUTO }; +static int dmaval[PARPORT_PC_MAX_PORTS] = { [0 ... PARPORT_PC_MAX_PORTS-1] = PARPORT_DMA_NONE }; static int irqval[PARPORT_PC_MAX_PORTS] = { [0 ... PARPORT_PC_MAX_PORTS-1] = PARPORT_IRQ_PROBEONLY }; static const char *irq[PARPORT_PC_MAX_PORTS] = { NULL, }; static const char *dma[PARPORT_PC_MAX_PORTS] = { NULL, }; @@ -3024,8 +3029,10 @@ MODULE_PARM(irq, "1-" __MODULE_STRING(PARPORT_PC_MAX_PORTS) "s"); MODULE_PARM_DESC(dma, "DMA channel"); MODULE_PARM(dma, "1-" __MODULE_STRING(PARPORT_PC_MAX_PORTS) "s"); -MODULE_PARM(verbose_probing, "i"); +#if defined(CONFIG_PARPORT_PC_FIFO) || defined(CONFIG_PARPORT_PC_SUPERIO) MODULE_PARM_DESC(verbose_probing, "Log chit-chat during initialisation"); +MODULE_PARM(verbose_probing, "i"); +#endif int init_module(void) { diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/parport/parport_serial.c linux-2.5/drivers/parport/parport_serial.c --- linux-2.5.1/drivers/parport/parport_serial.c Fri Nov 9 22:30:55 2001 +++ linux-2.5/drivers/parport/parport_serial.c Thu Dec 13 16:32:36 2001 @@ -331,7 +331,7 @@ name: "parport_serial", id_table: parport_serial_pci_tbl, probe: parport_serial_pci_probe, - remove: parport_serial_pci_remove, + remove: __devexit_p(parport_serial_pci_remove), }; diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/pcmcia/cistpl.c linux-2.5/drivers/pcmcia/cistpl.c --- linux-2.5.1/drivers/pcmcia/cistpl.c Mon Nov 12 17:39:01 2001 +++ linux-2.5/drivers/pcmcia/cistpl.c Thu Dec 13 16:32:36 2001 @@ -264,11 +264,11 @@ (s->cis_mem.sys_start == 0)) { int low = !(s->cap.features & SS_CAP_PAGE_REGS); vs = s; - validate_mem(cis_readable, checksum_match, low); + validate_mem(cis_readable, checksum_match, low, s); s->cis_mem.sys_start = 0; vs = NULL; if (find_mem_region(&s->cis_mem.sys_start, s->cap.map_size, - s->cap.map_size, low, "card services")) { + s->cap.map_size, low, "card services", s)) { printk(KERN_NOTICE "cs: unable to map card memory!\n"); return CS_OUT_OF_RESOURCE; } diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/pcmcia/cs.c linux-2.5/drivers/pcmcia/cs.c --- linux-2.5.1/drivers/pcmcia/cs.c Mon Nov 12 17:48:43 2001 +++ linux-2.5/drivers/pcmcia/cs.c Thu Dec 13 16:32:36 2001 @@ -809,7 +809,7 @@ return 1; for (i = 0; i < MAX_IO_WIN; i++) { if (s->io[i].NumPorts == 0) { - if (find_io_region(base, num, align, name) == 0) { + if (find_io_region(base, num, align, name, s) == 0) { s->io[i].Attributes = attr; s->io[i].BasePort = *base; s->io[i].NumPorts = s->io[i].InUse = num; @@ -821,7 +821,7 @@ /* Try to extend top of window */ try = s->io[i].BasePort + s->io[i].NumPorts; if ((*base == 0) || (*base == try)) - if (find_io_region(&try, num, 0, name) == 0) { + if (find_io_region(&try, num, 0, name, s) == 0) { *base = try; s->io[i].NumPorts += num; s->io[i].InUse += num; @@ -830,7 +830,7 @@ /* Try to extend bottom of window */ try = s->io[i].BasePort - num; if ((*base == 0) || (*base == try)) - if (find_io_region(&try, num, 0, name) == 0) { + if (find_io_region(&try, num, 0, name, s) == 0) { s->io[i].BasePort = *base = try; s->io[i].NumPorts += num; s->io[i].InUse += num; @@ -1974,7 +1974,7 @@ find_mem_region(&win->base, win->size, align, (req->Attributes & WIN_MAP_BELOW_1MB) || !(s->cap.features & SS_CAP_PAGE_REGS), - (*handle)->dev_info)) + (*handle)->dev_info, s)) return CS_IN_USE; (*handle)->state |= CLIENT_WIN_REQ(w); diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/pcmcia/cs_internal.h linux-2.5/drivers/pcmcia/cs_internal.h --- linux-2.5.1/drivers/pcmcia/cs_internal.h Sun Dec 16 23:46:33 2001 +++ linux-2.5/drivers/pcmcia/cs_internal.h Thu Dec 13 16:32:36 2001 @@ -238,11 +238,11 @@ /* In rsrc_mgr */ void validate_mem(int (*is_valid)(u_long), int (*do_cksum)(u_long), - int force_low); + int force_low, socket_info_t *s); int find_io_region(ioaddr_t *base, ioaddr_t num, ioaddr_t align, - char *name); + char *name, socket_info_t *s); int find_mem_region(u_long *base, u_long num, u_long align, - int force_low, char *name); + int force_low, char *name, socket_info_t *s); int try_irq(u_int Attributes, int irq, int specific); void undo_irq(u_int Attributes, int irq); int adjust_resource_info(client_handle_t handle, adjust_t *adj); diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/pcmcia/i82092.c linux-2.5/drivers/pcmcia/i82092.c --- linux-2.5.1/drivers/pcmcia/i82092.c Fri Nov 9 21:45:35 2001 +++ linux-2.5/drivers/pcmcia/i82092.c Thu Dec 13 17:35:27 2001 @@ -42,7 +42,7 @@ name: "i82092aa", id_table: i82092aa_pci_ids, probe: i82092aa_pci_probe, - remove: i82092aa_pci_remove, + remove: __devexit_p(i82092aa_pci_remove), suspend: NULL, resume: NULL }; @@ -160,7 +160,7 @@ return 0; } -static void __exit i82092aa_pci_remove(struct pci_dev *dev) +static void __devexit i82092aa_pci_remove(struct pci_dev *dev) { enter("i82092aa_pci_remove"); diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/pcmcia/i82365.c linux-2.5/drivers/pcmcia/i82365.c --- linux-2.5.1/drivers/pcmcia/i82365.c Sun Nov 25 17:43:42 2001 +++ linux-2.5/drivers/pcmcia/i82365.c Sun Dec 30 21:17:30 2001 @@ -49,7 +49,6 @@ #include <asm/irq.h> #include <asm/io.h> #include <asm/bitops.h> -#include <asm/segment.h> #include <asm/system.h> #include <pcmcia/version.h> diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/pcmcia/pci_socket.c linux-2.5/drivers/pcmcia/pci_socket.c --- linux-2.5.1/drivers/pcmcia/pci_socket.c Fri Nov 9 21:41:42 2001 +++ linux-2.5/drivers/pcmcia/pci_socket.c Thu Dec 13 16:32:36 2001 @@ -249,7 +249,7 @@ name: "cardbus", id_table: cardbus_table, probe: cardbus_probe, - remove: cardbus_remove, + remove: __devexit_p(cardbus_remove), suspend: cardbus_suspend, resume: cardbus_resume, }; diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/pcmcia/rsrc_mgr.c linux-2.5/drivers/pcmcia/rsrc_mgr.c --- linux-2.5.1/drivers/pcmcia/rsrc_mgr.c Mon Nov 12 17:39:01 2001 +++ linux-2.5/drivers/pcmcia/rsrc_mgr.c Thu Dec 13 16:32:36 2001 @@ -44,6 +44,7 @@ #include <linux/ioport.h> #include <linux/timer.h> #include <linux/proc_fs.h> +#include <linux/pci.h> #include <asm/irq.h> #include <asm/io.h> @@ -103,8 +104,82 @@ ======================================================================*/ -#define check_io_resource(b,n) check_resource(&ioport_resource, (b), (n)) -#define check_mem_resource(b,n) check_resource(&iomem_resource, (b), (n)) +static struct resource *resource_parent(unsigned long b, unsigned long n, + int flags, struct pci_dev *dev) +{ +#ifdef CONFIG_PCI + struct resource res, *pr; + + if (dev != NULL) { + res.start = b; + res.end = b + n - 1; + res.flags = flags; + pr = pci_find_parent_resource(dev, &res); + if (pr) + return pr; + } +#endif /* CONFIG_PCI */ + if (flags & IORESOURCE_MEM) + return &iomem_resource; + return &ioport_resource; +} + +static inline int check_io_resource(unsigned long b, unsigned long n, + struct pci_dev *dev) +{ + return check_resource(resource_parent(b, n, IORESOURCE_IO, dev), b, n); +} + +static inline int check_mem_resource(unsigned long b, unsigned long n, + struct pci_dev *dev) +{ + return check_resource(resource_parent(b, n, IORESOURCE_MEM, dev), b, n); +} + +static struct resource *make_resource(unsigned long b, unsigned long n, + int flags, char *name) +{ + struct resource *res = kmalloc(sizeof(*res), GFP_KERNEL); + + if (res) { + memset(res, 0, sizeof(*res)); + res->name = name; + res->start = b; + res->end = b + n - 1; + res->flags = flags | IORESOURCE_BUSY; + } + return res; +} + +static int request_io_resource(unsigned long b, unsigned long n, + char *name, struct pci_dev *dev) +{ + struct resource *res = make_resource(b, n, IORESOURCE_IO, name); + struct resource *pr = resource_parent(b, n, IORESOURCE_IO, dev); + int err = -ENOMEM; + + if (res) { + err = request_resource(pr, res); + if (err) + kfree(res); + } + return err; +} + +static int request_mem_resource(unsigned long b, unsigned long n, + char *name, struct pci_dev *dev) +{ + struct resource *res = make_resource(b, n, IORESOURCE_MEM, name); + struct resource *pr = resource_parent(b, n, IORESOURCE_MEM, dev); + int err = -ENOMEM; + + if (res) { + err = request_resource(pr, res); + if (err) + kfree(res); + } + return err; +} /*====================================================================== @@ -194,7 +269,7 @@ } memset(b, 0, 256); for (i = base, most = 0; i < base+num; i += 8) { - if (check_io_resource(i, 8)) + if (check_io_resource(i, 8, NULL)) continue; hole = inb(i); for (j = 1; j < 8; j++) @@ -207,7 +282,7 @@ bad = any = 0; for (i = base; i < base+num; i += 8) { - if (check_io_resource(i, 8)) + if (check_io_resource(i, 8, NULL)) continue; for (j = 0; j < 8; j++) if (inb(i+j) != most) break; @@ -247,7 +322,8 @@ ======================================================================*/ static int do_mem_probe(u_long base, u_long num, - int (*is_valid)(u_long), int (*do_cksum)(u_long)) + int (*is_valid)(u_long), int (*do_cksum)(u_long), + socket_info_t *s) { u_long i, j, bad, fail, step; @@ -258,13 +334,14 @@ for (i = j = base; i < base+num; i = j + step) { if (!fail) { for (j = i; j < base+num; j += step) - if ((check_mem_resource(j, step) == 0) && is_valid(j)) + if ((check_mem_resource(j, step, s->cap.cb_dev) == 0) && + is_valid(j)) break; fail = ((i == base) && (j == base+num)); } if (fail) { for (j = i; j < base+num; j += 2*step) - if ((check_mem_resource(j, 2*step) == 0) && + if ((check_mem_resource(j, 2*step, s->cap.cb_dev) == 0) && do_cksum(j) && do_cksum(j+step)) break; } @@ -283,12 +360,12 @@ static u_long inv_probe(int (*is_valid)(u_long), int (*do_cksum)(u_long), - resource_map_t *m) + resource_map_t *m, socket_info_t *s) { u_long ok; if (m == &mem_db) return 0; - ok = inv_probe(is_valid, do_cksum, m->next); + ok = inv_probe(is_valid, do_cksum, m->next, s); if (ok) { if (m->base >= 0x100000) sub_interval(&mem_db, m->base, m->num); @@ -296,11 +373,11 @@ } if (m->base < 0x100000) return 0; - return do_mem_probe(m->base, m->num, is_valid, do_cksum); + return do_mem_probe(m->base, m->num, is_valid, do_cksum, s); } void validate_mem(int (*is_valid)(u_long), int (*do_cksum)(u_long), - int force_low) + int force_low, socket_info_t *s) { resource_map_t *m, *n; static u_char order[] = { 0xd0, 0xe0, 0xc0, 0xf0 }; @@ -310,7 +387,7 @@ if (!probe_mem) return; /* We do up to four passes through the list */ if (!force_low) { - if (hi++ || (inv_probe(is_valid, do_cksum, mem_db.next) > 0)) + if (hi++ || (inv_probe(is_valid, do_cksum, mem_db.next, s) > 0)) return; printk(KERN_NOTICE "cs: warning: no high memory space " "available!\n"); @@ -321,7 +398,7 @@ /* Only probe < 1 MB */ if (m->base >= 0x100000) continue; if ((m->base | m->num) & 0xffff) { - ok += do_mem_probe(m->base, m->num, is_valid, do_cksum); + ok += do_mem_probe(m->base, m->num, is_valid, do_cksum, s); continue; } /* Special probe for 64K-aligned block */ @@ -331,7 +408,7 @@ if (ok >= mem_limit) sub_interval(&mem_db, b, 0x10000); else - ok += do_mem_probe(b, 0x10000, is_valid, do_cksum); + ok += do_mem_probe(b, 0x10000, is_valid, do_cksum, s); } } } @@ -340,7 +417,7 @@ #else /* CONFIG_ISA */ void validate_mem(int (*is_valid)(u_long), int (*do_cksum)(u_long), - int force_low) + int force_low, socket_info_t *s) { resource_map_t *m; static int done = 0; @@ -348,7 +425,7 @@ if (!probe_mem || done++) return; for (m = mem_db.next; m != &mem_db; m = m->next) - if (do_mem_probe(m->base, m->num, is_valid, do_cksum)) + if (do_mem_probe(m->base, m->num, is_valid, do_cksum, s)) return; } @@ -368,7 +445,7 @@ ======================================================================*/ int find_io_region(ioaddr_t *base, ioaddr_t num, ioaddr_t align, - char *name) + char *name, socket_info_t *s) { ioaddr_t try; resource_map_t *m; @@ -378,9 +455,8 @@ for (try = (try >= m->base) ? try : try+align; (try >= m->base) && (try+num <= m->base+m->num); try += align) { - if (check_io_resource(try, num) == 0) { + if (request_io_resource(try, num, name, s->cap.cb_dev) == 0) { *base = try; - request_region(try, num, name); return 0; } if (!align) break; @@ -390,7 +466,7 @@ } int find_mem_region(u_long *base, u_long num, u_long align, - int force_low, char *name) + int force_low, char *name, socket_info_t *s) { u_long try; resource_map_t *m; @@ -403,8 +479,7 @@ for (try = (try >= m->base) ? try : try+align; (try >= m->base) && (try+num <= m->base+m->num); try += align) { - if (check_mem_resource(try, num) == 0) { - request_mem_region(try, num, name); + if (request_mem_resource(try, num, name, s->cap.cb_dev) == 0) { *base = try; return 0; } diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/pcmcia/tcic.c linux-2.5/drivers/pcmcia/tcic.c --- linux-2.5.1/drivers/pcmcia/tcic.c Sun Sep 30 19:26:07 2001 +++ linux-2.5/drivers/pcmcia/tcic.c Sun Dec 30 21:17:30 2001 @@ -39,7 +39,6 @@ #include <asm/io.h> #include <asm/bitops.h> -#include <asm/segment.h> #include <asm/system.h> #include <linux/kernel.h> diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/pcmcia/yenta.c linux-2.5/drivers/pcmcia/yenta.c --- linux-2.5.1/drivers/pcmcia/yenta.c Wed Nov 21 07:19:48 2001 +++ linux-2.5/drivers/pcmcia/yenta.c Thu Dec 13 16:32:36 2001 @@ -688,7 +688,7 @@ /* * This does not work currently. The controller - * loses too much informationduring D3 to come up + * loses too much information during D3 to come up * cleanly. We should probably fix yenta_init() * to update all the critical registers, notably * the IO and MEM bridging region data.. That is diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/pnp/Config.in linux-2.5/drivers/pnp/Config.in --- linux-2.5.1/drivers/pnp/Config.in Thu Oct 25 21:01:51 2001 +++ linux-2.5/drivers/pnp/Config.in Sat Dec 29 12:07:19 2001 @@ -8,4 +8,8 @@ dep_tristate ' ISA Plug and Play support' CONFIG_ISAPNP $CONFIG_PNP +if [ "$CONFIG_EXPERIMENTAL" = "y" ]; then + dep_bool ' PNPBIOS support (EXPERIMENTAL)' CONFIG_PNPBIOS $CONFIG_PNP +fi + endmenu diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/pnp/Makefile linux-2.5/drivers/pnp/Makefile --- linux-2.5.1/drivers/pnp/Makefile Mon Mar 26 23:36:30 2001 +++ linux-2.5/drivers/pnp/Makefile Sat Dec 29 12:07:19 2001 @@ -10,15 +10,22 @@ O_TARGET := pnp.o -export-objs := isapnp.o -list-multi := isa-pnp.o +export-objs := isapnp.o pnpbios_core.o +multi-objs := isa-pnp.o pnpbios.o -proc-$(CONFIG_PROC_FS) = isapnp_proc.o -isa-pnp-objs := isapnp.o quirks.o $(proc-y) +isa-pnp-proc-$(CONFIG_PROC_FS) = isapnp_proc.o +pnpbios-proc-$(CONFIG_PROC_FS) = pnpbios_proc.o + +isa-pnp-objs := isapnp.o quirks.o $(isa-pnp-proc-y) +pnpbios-objs := pnpbios_core.o $(pnpbios-proc-y) obj-$(CONFIG_ISAPNP) += isa-pnp.o +obj-$(CONFIG_PNPBIOS) += pnpbios.o include $(TOPDIR)/Rules.make isa-pnp.o: $(isa-pnp-objs) $(LD) $(LD_RFLAG) -r -o $@ $(isa-pnp-objs) + +pnpbios.o: $(pnpbios-objs) + $(LD) $(LD_RFLAG) -r -o $@ $(pnpbios-objs) diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/pnp/pnpbios_core.c linux-2.5/drivers/pnp/pnpbios_core.c --- linux-2.5.1/drivers/pnp/pnpbios_core.c Thu Jan 1 00:00:00 1970 +++ linux-2.5/drivers/pnp/pnpbios_core.c Sat Dec 29 12:07:19 2001 @@ -0,0 +1,1274 @@ +/* + * PnP BIOS services + * + * Originally (C) 1998 Christian Schmidt <schmidt@digadd.de> + * Modifications (c) 1998 Tom Lees <tom@lpsg.demon.co.uk> + * Minor reorganizations by David Hinds <dahinds@users.sourceforge.net> + * Modifications (c) 2001 by Thomas Hood <jdthood@mail.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, 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 + * + * References: + * Compaq Computer Corporation, Phoenix Technologies Ltd., Intel Corporation + * Plug and Play BIOS Specification, Version 1.0A, May 5, 1994 + * Plug and Play BIOS Clarification Paper, October 6, 1994 + * + */ + +#include <linux/types.h> +#include <linux/module.h> +#include <linux/init.h> +#include <linux/linkage.h> +#include <linux/kernel.h> +#include <linux/pnpbios.h> +#include <asm/page.h> +#include <asm/system.h> +#include <linux/mm.h> +#include <linux/smp.h> +#include <asm/desc.h> +#include <linux/ioport.h> +#include <linux/slab.h> +#include <linux/pci.h> +#include <linux/kmod.h> +#include <linux/completion.h> +#include <linux/spinlock.h> +#include <asm/system.h> + + +/* + * + * PnP BIOS INTERFACE + * + */ + +/* PnP BIOS signature: "$PnP" */ +#define PNP_SIGNATURE (('$' << 0) + ('P' << 8) + ('n' << 16) + ('P' << 24)) + +#pragma pack(1) +union pnp_bios_expansion_header { + struct { + u32 signature; /* "$PnP" */ + u8 version; /* in BCD */ + u8 length; /* length in bytes, currently 21h */ + u16 control; /* system capabilities */ + u8 checksum; /* all bytes must add up to 0 */ + + u32 eventflag; /* phys. address of the event flag */ + u16 rmoffset; /* real mode entry point */ + u16 rmcseg; + u16 pm16offset; /* 16 bit protected mode entry */ + u32 pm16cseg; + u32 deviceID; /* EISA encoded system ID or 0 */ + u16 rmdseg; /* real mode data segment */ + u32 pm16dseg; /* 16 bit pm data segment base */ + } fields; + char chars[0x21]; /* To calculate the checksum */ +}; +#pragma pack() + +static struct { + u16 offset; + u16 segment; +} pnp_bios_callpoint; + +static union pnp_bios_expansion_header * pnp_bios_hdr = NULL; + +/* The PnP BIOS entries in the GDT */ +#define PNP_GDT (0x0060) +#define PNP_CS32 (PNP_GDT+0x00) /* segment for calling fn */ +#define PNP_CS16 (PNP_GDT+0x08) /* code segment for BIOS */ +#define PNP_DS (PNP_GDT+0x10) /* data segment for BIOS */ +#define PNP_TS1 (PNP_GDT+0x18) /* transfer data segment */ +#define PNP_TS2 (PNP_GDT+0x20) /* another data segment */ + +/* + * These are some opcodes for a "static asmlinkage" + * As this code is *not* executed inside the linux kernel segment, but in a + * alias at offset 0, we need a far return that can not be compiled by + * default (please, prove me wrong! this is *really* ugly!) + * This is the only way to get the bios to return into the kernel code, + * because the bios code runs in 16 bit protected mode and therefore can only + * return to the caller if the call is within the first 64kB, and the linux + * kernel begins at offset 3GB... + */ + +asmlinkage void pnp_bios_callfunc(void); + +__asm__( + ".text \n" + __ALIGN_STR "\n" + SYMBOL_NAME_STR(pnp_bios_callfunc) ":\n" + " pushl %edx \n" + " pushl %ecx \n" + " pushl %ebx \n" + " pushl %eax \n" + " lcallw " SYMBOL_NAME_STR(pnp_bios_callpoint) "\n" + " addl $16, %esp \n" + " lret \n" + ".previous \n" +); + +#define Q_SET_SEL(selname, address, size) \ +set_base (gdt [(selname) >> 3], __va((u32)(address))); \ +set_limit (gdt [(selname) >> 3], size) + +#define Q2_SET_SEL(selname, address, size) \ +set_base (gdt [(selname) >> 3], (u32)(address)); \ +set_limit (gdt [(selname) >> 3], size) + +/* + * At some point we want to use this stack frame pointer to unwind + * after PnP BIOS oopses. + */ + +u32 pnp_bios_fault_esp; +u32 pnp_bios_fault_eip; +u32 pnp_bios_is_utter_crap = 0; + +static spinlock_t pnp_bios_lock; + +static inline u16 call_pnp_bios(u16 func, u16 arg1, u16 arg2, u16 arg3, + u16 arg4, u16 arg5, u16 arg6, u16 arg7) +{ + unsigned long flags; + u16 status; + + /* + * PnP BIOSes are generally not terribly re-entrant. + * Also, don't rely on them to save everything correctly. + */ + if(pnp_bios_is_utter_crap) + return PNP_FUNCTION_NOT_SUPPORTED; + + /* On some boxes IRQ's during PnP BIOS calls are deadly. */ + spin_lock_irqsave(&pnp_bios_lock, flags); + __cli(); + __asm__ __volatile__( + "pushl %%ebp\n\t" + "pushl %%edi\n\t" + "pushl %%esi\n\t" + "pushl %%ds\n\t" + "pushl %%es\n\t" + "pushl %%fs\n\t" + "pushl %%gs\n\t" + "pushfl\n\t" + "movl %%esp, pnp_bios_fault_esp\n\t" + "movl $1f, pnp_bios_fault_eip\n\t" + "lcall %5,%6\n\t" + "1:popfl\n\t" + "popl %%gs\n\t" + "popl %%fs\n\t" + "popl %%es\n\t" + "popl %%ds\n\t" + "popl %%esi\n\t" + "popl %%edi\n\t" + "popl %%ebp\n\t" + : "=a" (status) + : "0" ((func) | (((u32)arg1) << 16)), + "b" ((arg2) | (((u32)arg3) << 16)), + "c" ((arg4) | (((u32)arg5) << 16)), + "d" ((arg6) | (((u32)arg7) << 16)), + "i" (PNP_CS32), + "i" (0) + : "memory" + ); + spin_unlock_irqrestore(&pnp_bios_lock, flags); + + /* If we get here and this is set then the PnP BIOS faulted on us. */ + if(pnp_bios_is_utter_crap) + { + printk(KERN_ERR "PnPBIOS: Warning! Your PnP BIOS caused a fatal error. Attempting to continue.\n"); + printk(KERN_ERR "PnPBIOS: You may need to reboot with the \"nobiospnp\" option to operate stably.\n"); + printk(KERN_ERR "PnPBIOS: Check with your vendor for an updated BIOS\n"); + } + + return status; +} + + +/* + * + * UTILITY FUNCTIONS + * + */ + +void *pnpbios_kmalloc(size_t size, int f) +{ + void *p = kmalloc( size, f ); + if ( p == NULL ) + printk(KERN_ERR "PnPBIOS: kmalloc() failed.\n"); + return p; +} + +/* + * Call this only after init time + */ +static int pnp_bios_present(void) +{ + return (pnp_bios_hdr != NULL); +} + +/* Forward declaration */ +static void update_devlist( u8 nodenum, struct pnp_bios_node *data ); + + +/* + * + * PnP BIOS ACCESS FUNCTIONS + * + */ + +#define PNP_GET_NUM_SYS_DEV_NODES 0x00 +#define PNP_GET_SYS_DEV_NODE 0x01 +#define PNP_SET_SYS_DEV_NODE 0x02 +#define PNP_GET_EVENT 0x03 +#define PNP_SEND_MESSAGE 0x04 +#define PNP_GET_DOCKING_STATION_INFORMATION 0x05 +#define PNP_SET_STATIC_ALLOCED_RES_INFO 0x09 +#define PNP_GET_STATIC_ALLOCED_RES_INFO 0x0a +#define PNP_GET_APM_ID_TABLE 0x0b +#define PNP_GET_PNP_ISA_CONFIG_STRUC 0x40 +#define PNP_GET_ESCD_INFO 0x41 +#define PNP_READ_ESCD 0x42 +#define PNP_WRITE_ESCD 0x43 + +/* + * Call PnP BIOS with function 0x00, "get number of system device nodes" + */ +static int __pnp_bios_dev_node_info(struct pnp_dev_node_info *data) +{ + u16 status; + if (!pnp_bios_present ()) + return PNP_FUNCTION_NOT_SUPPORTED; + Q2_SET_SEL(PNP_TS1, data, sizeof(struct pnp_dev_node_info)); + status = call_pnp_bios(PNP_GET_NUM_SYS_DEV_NODES, 0, PNP_TS1, 2, PNP_TS1, PNP_DS, 0, 0); + data->no_nodes &= 0xff; + return status; +} + +int pnp_bios_dev_node_info(struct pnp_dev_node_info *data) +{ + int status = __pnp_bios_dev_node_info( data ); + if ( status ) + printk(KERN_WARNING "PnPBIOS: dev_node_info: Unexpected status 0x%x\n", status); + return status; +} + +/* + * Note that some PnP BIOSes (e.g., on Sony Vaio laptops) die a horrible + * death if they are asked to access the "current" configuration. + * Therefore, if it's a matter of indifference, it's better to call + * get_dev_node() and set_dev_node() with boot=1 rather than with boot=0. + */ + +/* + * Call PnP BIOS with function 0x01, "get system device node" + * Input: *nodenum = desired node, + * boot = whether to get nonvolatile boot (!=0) + * or volatile current (0) config + * Output: *nodenum=next node or 0xff if no more nodes + */ +static int __pnp_bios_get_dev_node(u8 *nodenum, char boot, struct pnp_bios_node *data) +{ + u16 status; + if (!pnp_bios_present ()) + return PNP_FUNCTION_NOT_SUPPORTED; + if ( !boot & pnpbios_dont_use_current_config ) + return PNP_FUNCTION_NOT_SUPPORTED; + Q2_SET_SEL(PNP_TS1, nodenum, sizeof(char)); + Q2_SET_SEL(PNP_TS2, data, 64 * 1024); + status = call_pnp_bios(PNP_GET_SYS_DEV_NODE, 0, PNP_TS1, 0, PNP_TS2, boot ? 2 : 1, PNP_DS, 0); + return status; +} + +int pnp_bios_get_dev_node(u8 *nodenum, char boot, struct pnp_bios_node *data) +{ + int status; + status = __pnp_bios_get_dev_node( nodenum, boot, data ); + if ( status ) + printk(KERN_WARNING "PnPBIOS: get_dev_node: Unexpected 0x%x\n", status); + return status; +} + + +/* + * Call PnP BIOS with function 0x02, "set system device node" + * Input: *nodenum = desired node, + * boot = whether to set nonvolatile boot (!=0) + * or volatile current (0) config + */ +static int __pnp_bios_set_dev_node(u8 nodenum, char boot, struct pnp_bios_node *data) +{ + u16 status; + if (!pnp_bios_present ()) + return PNP_FUNCTION_NOT_SUPPORTED; + if ( !boot & pnpbios_dont_use_current_config ) + return PNP_FUNCTION_NOT_SUPPORTED; + Q2_SET_SEL(PNP_TS1, data, /* *((u16 *) data)*/ 65536); + status = call_pnp_bios(PNP_SET_SYS_DEV_NODE, nodenum, 0, PNP_TS1, boot ? 2 : 1, PNP_DS, 0, 0); + return status; +} + +int pnp_bios_set_dev_node(u8 nodenum, char boot, struct pnp_bios_node *data) +{ + int status; + status = __pnp_bios_set_dev_node( nodenum, boot, data ); + if ( status ) { + printk(KERN_WARNING "PnPBIOS: set_dev_node: Unexpected set_dev_node status 0x%x\n", status); + return status; + } + if ( !boot ) { + /* Update devlist */ + u8 thisnodenum = nodenum; + status = __pnp_bios_get_dev_node( &nodenum, boot, data ); + if ( status ) { + printk(KERN_WARNING "PnPBIOS: set_dev_node: Unexpected get_dev_node status 0x%x\n", status); + return status; + } + update_devlist( thisnodenum, data ); + } + return status; +} + +#if needed +/* + * Call PnP BIOS with function 0x03, "get event" + */ +static int pnp_bios_get_event(u16 *event) +{ + u16 status; + if (!pnp_bios_present ()) + return PNP_FUNCTION_NOT_SUPPORTED; + Q2_SET_SEL(PNP_TS1, event, sizeof(u16)); + status = call_pnp_bios(PNP_GET_EVENT, 0, PNP_TS1, PNP_DS, 0, 0 ,0 ,0); + return status; +} +#endif + +#if needed +/* + * Call PnP BIOS with function 0x04, "send message" + */ +static int pnp_bios_send_message(u16 message) +{ + u16 status; + if (!pnp_bios_present ()) + return PNP_FUNCTION_NOT_SUPPORTED; + status = call_pnp_bios(PNP_SEND_MESSAGE, message, PNP_DS, 0, 0, 0, 0, 0); + return status; +} +#endif + +#ifdef CONFIG_HOTPLUG +/* + * Call PnP BIOS with function 0x05, "get docking station information" + */ +static int pnp_bios_dock_station_info(struct pnp_docking_station_info *data) +{ + u16 status; + if (!pnp_bios_present ()) + return PNP_FUNCTION_NOT_SUPPORTED; + Q2_SET_SEL(PNP_TS1, data, sizeof(struct pnp_docking_station_info)); + status = call_pnp_bios(PNP_GET_DOCKING_STATION_INFORMATION, 0, PNP_TS1, PNP_DS, 0, 0, 0, 0); + return status; +} +#endif + +#if needed +/* + * Call PnP BIOS with function 0x09, "set statically allocated resource + * information" + */ +static int pnp_bios_set_stat_res(char *info) +{ + u16 status; + if (!pnp_bios_present ()) + return PNP_FUNCTION_NOT_SUPPORTED; + Q2_SET_SEL(PNP_TS1, info, *((u16 *) info)); + status = call_pnp_bios(PNP_SET_STATIC_ALLOCED_RES_INFO, 0, PNP_TS1, PNP_DS, 0, 0, 0, 0); + return status; +} +#endif + +#if needed +/* + * Call PnP BIOS with function 0x0a, "get statically allocated resource + * information" + */ +static int pnp_bios_get_stat_res(char *info) +{ + u16 status; + if (!pnp_bios_present ()) + return PNP_FUNCTION_NOT_SUPPORTED; + Q2_SET_SEL(PNP_TS1, info, 64 * 1024); + status = call_pnp_bios(PNP_GET_STATIC_ALLOCED_RES_INFO, 0, PNP_TS1, PNP_DS, 0, 0, 0, 0); + return status; +} +#endif + +#if needed +/* + * Call PnP BIOS with function 0x0b, "get APM id table" + */ +static int pnp_bios_apm_id_table(char *table, u16 *size) +{ + u16 status; + if (!pnp_bios_present ()) + return PNP_FUNCTION_NOT_SUPPORTED; + Q2_SET_SEL(PNP_TS1, table, *size); + Q2_SET_SEL(PNP_TS2, size, sizeof(u16)); + status = call_pnp_bios(PNP_GET_APM_ID_TABLE, 0, PNP_TS2, 0, PNP_TS1, PNP_DS, 0, 0); + return status; +} +#endif + +#if needed +/* + * Call PnP BIOS with function 0x40, "get isa pnp configuration structure" + */ +static int pnp_bios_isapnp_config(struct pnp_isa_config_struc *data) +{ + u16 status; + if (!pnp_bios_present ()) + return PNP_FUNCTION_NOT_SUPPORTED; + Q2_SET_SEL(PNP_TS1, data, sizeof(struct pnp_isa_config_struc)); + status = call_pnp_bios(PNP_GET_PNP_ISA_CONFIG_STRUC, 0, PNP_TS1, PNP_DS, 0, 0, 0, 0); + return status; +} +#endif + +#if needed +/* + * Call PnP BIOS with function 0x41, "get ESCD info" + */ +static int pnp_bios_escd_info(struct escd_info_struc *data) +{ + u16 status; + if (!pnp_bios_present ()) + return ESCD_FUNCTION_NOT_SUPPORTED; + Q2_SET_SEL(PNP_TS1, data, sizeof(struct escd_info_struc)); + status = call_pnp_bios(PNP_GET_ESCD_INFO, 0, PNP_TS1, 2, PNP_TS1, 4, PNP_TS1, PNP_DS); + return status; +} +#endif + +#if needed +/* + * Call PnP BIOS function 0x42, "read ESCD" + * nvram_base is determined by calling escd_info + */ +static int pnp_bios_read_escd(char *data, u32 nvram_base) +{ + u16 status; + if (!pnp_bios_present ()) + return ESCD_FUNCTION_NOT_SUPPORTED; + Q2_SET_SEL(PNP_TS1, data, 64 * 1024); + set_base(gdt[PNP_TS2 >> 3], nvram_base); + set_limit(gdt[PNP_TS2 >> 3], 64 * 1024); + status = call_pnp_bios(PNP_READ_ESCD, 0, PNP_TS1, PNP_TS2, PNP_DS, 0, 0, 0); + return status; +} +#endif + +#if needed +/* + * Call PnP BIOS function 0x43, "write ESCD" + */ +static int pnp_bios_write_escd(char *data, u32 nvram_base) +{ + u16 status; + if (!pnp_bios_present ()) + return ESCD_FUNCTION_NOT_SUPPORTED; + Q2_SET_SEL(PNP_TS1, data, 64 * 1024); + set_base(gdt[PNP_TS2 >> 3], nvram_base); + set_limit(gdt[PNP_TS2 >> 3], 64 * 1024); + status = call_pnp_bios(PNP_WRITE_ESCD, 0, PNP_TS1, PNP_TS2, PNP_DS, 0, 0, 0); + return status; +} +#endif + + +/* + * + * DOCKING FUNCTIONS + * + */ + +#ifdef CONFIG_HOTPLUG + +static int unloading = 0; +static struct completion unload_sem; + +/* + * (Much of this belongs in a shared routine somewhere) + */ + +static int pnp_dock_event(int dock, struct pnp_docking_station_info *info) +{ + char *argv [3], **envp, *buf, *scratch; + int i = 0, value; + + if (!hotplug_path [0]) + return -ENOENT; + if (!current->fs->root) { + return -EAGAIN; + } + if (!(envp = (char **) pnpbios_kmalloc (20 * sizeof (char *), GFP_KERNEL))) { + return -ENOMEM; + } + if (!(buf = pnpbios_kmalloc (256, GFP_KERNEL))) { + kfree (envp); + return -ENOMEM; + } + + /* only one standardized param to hotplug command: type */ + argv [0] = hotplug_path; + argv [1] = "dock"; + argv [2] = 0; + + /* minimal command environment */ + envp [i++] = "HOME=/"; + envp [i++] = "PATH=/sbin:/bin:/usr/sbin:/usr/bin"; + +#ifdef DEBUG + /* hint that policy agent should enter no-stdout debug mode */ + envp [i++] = "DEBUG=kernel"; +#endif + /* extensible set of named bus-specific parameters, + * supporting multiple driver selection algorithms. + */ + scratch = buf; + + /* action: add, remove */ + envp [i++] = scratch; + scratch += sprintf (scratch, "ACTION=%s", dock?"add":"remove") + 1; + + /* Report the ident for the dock */ + envp [i++] = scratch; + scratch += sprintf (scratch, "DOCK=%x/%x/%x", + info->location_id, info->serial, info->capabilities); + envp[i] = 0; + + value = call_usermodehelper (argv [0], argv, envp); + kfree (buf); + kfree (envp); + return 0; +} + +/* + * Poll the PnP docking at regular intervals + */ +static int pnp_dock_thread(void * unused) +{ + static struct pnp_docking_station_info now; + int docked = -1, d; + daemonize(); + reparent_to_init(); + strcpy(current->comm, "kpnpbios"); + while(!unloading && !signal_pending(current)) + { + int err; + + /* + * Poll every 2 seconds + */ + set_current_state(TASK_INTERRUPTIBLE); + schedule_timeout(HZ*2); + if(signal_pending(current)) + break; + + err = pnp_bios_dock_station_info(&now); + + switch(err) + { + /* + * No dock to manage + */ + case PNP_FUNCTION_NOT_SUPPORTED: + complete_and_exit(&unload_sem, 0); + case PNP_SYSTEM_NOT_DOCKED: + d = 0; + break; + case PNP_SUCCESS: + d = 1; + break; + default: + printk(KERN_WARNING "PnPBIOS: pnp_dock_thread: Unexpected status 0x%x returned by BIOS.\n", err); + continue; + } + if(d != docked) + { + if(pnp_dock_event(d, &now)==0) + { + docked = d; +#if 0 + printk(KERN_INFO "PnPBIOS: Docking station %stached.\n", docked?"at":"de"); +#endif + } + } + } + complete_and_exit(&unload_sem, 0); +} + +#endif /* CONFIG_HOTPLUG */ + + +/* + * + * NODE DATA PARSING FUNCTIONS + * + */ + +static void add_irqresource(struct pci_dev *dev, int irq) +{ + int i = 0; + while (!(dev->irq_resource[i].flags & IORESOURCE_UNSET) && i < DEVICE_COUNT_IRQ) i++; + if (i < DEVICE_COUNT_IRQ) { + dev->irq_resource[i].start = (unsigned long) irq; + dev->irq_resource[i].flags = IORESOURCE_IRQ; // Also clears _UNSET flag + } +} + +static void add_dmaresource(struct pci_dev *dev, int dma) +{ + int i = 0; + while (!(dev->dma_resource[i].flags & IORESOURCE_UNSET) && i < DEVICE_COUNT_DMA) i++; + if (i < DEVICE_COUNT_DMA) { + dev->dma_resource[i].start = (unsigned long) dma; + dev->dma_resource[i].flags = IORESOURCE_DMA; // Also clears _UNSET flag + } +} + +static void add_ioresource(struct pci_dev *dev, int io, int len) +{ + int i = 0; + while (!(dev->resource[i].flags & IORESOURCE_UNSET) && i < DEVICE_COUNT_RESOURCE) i++; + if (i < DEVICE_COUNT_RESOURCE) { + dev->resource[i].start = (unsigned long) io; + dev->resource[i].end = (unsigned long)(io + len - 1); + dev->resource[i].flags = IORESOURCE_IO; // Also clears _UNSET flag + } +} + +static void add_memresource(struct pci_dev *dev, int mem, int len) +{ + int i = 0; + while (!(dev->resource[i].flags & IORESOURCE_UNSET) && i < DEVICE_COUNT_RESOURCE) i++; + if (i < DEVICE_COUNT_RESOURCE) { + dev->resource[i].start = (unsigned long) mem; + dev->resource[i].end = (unsigned long)(mem + len - 1); + dev->resource[i].flags = IORESOURCE_MEM; // Also clears _UNSET flag + } +} + +static void node_resource_data_to_dev(struct pnp_bios_node *node, struct pci_dev *dev) +{ + unsigned char *p = node->data, *lastp=NULL; + int i; + + /* + * First, set resource info to default values + */ + for (i=0;i<DEVICE_COUNT_RESOURCE;i++) { + dev->resource[i].start = 0; // "disabled" + dev->resource[i].flags = IORESOURCE_UNSET; + } + for (i=0;i<DEVICE_COUNT_IRQ;i++) { + dev->irq_resource[i].start = (unsigned long)-1; // "disabled" + dev->irq_resource[i].flags = IORESOURCE_UNSET; + } + for (i=0;i<DEVICE_COUNT_DMA;i++) { + dev->dma_resource[i].start = (unsigned long)-1; // "disabled" + dev->dma_resource[i].flags = IORESOURCE_UNSET; + } + + /* + * Fill in dev resource info + */ + while ( (char *)p < ((char *)node->data + node->size )) { + if(p==lastp) break; + + if( p[0] & 0x80 ) {// large item + switch (p[0] & 0x7f) { + case 0x01: // memory + { + int io = *(short *) &p[4]; + int len = *(short *) &p[10]; + add_memresource(dev, io, len); + break; + } + case 0x02: // device name + { + int len = *(short *) &p[1]; + memcpy(dev->name, p + 3, len >= 80 ? 79 : len); + break; + } + case 0x05: // 32-bit memory + { + int io = *(int *) &p[4]; + int len = *(int *) &p[16]; + add_memresource(dev, io, len); + break; + } + case 0x06: // fixed location 32-bit memory + { + int io = *(int *) &p[4]; + int len = *(int *) &p[8]; + add_memresource(dev, io, len); + break; + } + } /* switch */ + lastp = p+3; + p = p + p[1] + p[2]*256 + 3; + continue; + } + if ((p[0]>>3) == 0x0f) // end tag + break; + switch (p[0]>>3) { + case 0x04: // irq + { + int i, mask, irq = -1; + mask= p[1] + p[2]*256; + for (i=0;i<16;i++, mask=mask>>1) + if(mask & 0x01) irq=i; + add_irqresource(dev, irq); + break; + } + case 0x05: // dma + { + int i, mask, dma = -1; + mask = p[1]; + for (i=0;i<8;i++, mask = mask>>1) + if(mask & 0x01) dma=i; + add_dmaresource(dev, dma); + break; + } + case 0x08: // io + { + int io= p[2] + p[3] *256; + int len = p[7]; + add_ioresource(dev, io, len); + break; + } + case 0x09: // fixed location io + { + int io = p[1] + p[2] * 256; + int len = p[3]; + add_ioresource(dev, io, len); + break; + } + } /* switch */ + lastp=p+1; + p = p + (p[0] & 0x07) + 1; + + } /* while */ + + return; +} + + +/* + * + * DEVICE LIST MANAGEMENT FUNCTIONS + * + * + * Some of these are exported to give public access + * + * Question: Why maintain a device list when the PnP BIOS can + * list devices for us? Answer: Some PnP BIOSes can't report + * the current configuration, only the boot configuration. + * The boot configuration can be changed, so we need to keep + * a record of what the configuration was when we booted; + * presumably it continues to describe the current config. + * For those BIOSes that can change the current config, we + * keep the information in the devlist up to date. + * + * Note that it is currently assumed that the list does not + * grow or shrink in size after init time, and slot_name + * never changes. The list is protected by a spinlock. + */ + +static LIST_HEAD(pnpbios_devices); + +static spinlock_t pnpbios_devices_lock; + +static int inline insert_device(struct pci_dev *dev) +{ + + /* + * FIXME: Check for re-add of existing node; + * return -1 if node already present + */ + + /* We don't lock because we only do this at init time */ + list_add_tail(&dev->global_list, &pnpbios_devices); + + return 0; +} + +#define HEX(id,a) hex[((id)>>a) & 15] +#define CHAR(id,a) (0x40 + (((id)>>a) & 31)) +// +static void inline pnpid32_to_pnpid(u32 id, char *str) +{ + const char *hex = "0123456789abcdef"; + + id = be32_to_cpu(id); + str[0] = CHAR(id, 26); + str[1] = CHAR(id, 21); + str[2] = CHAR(id,16); + str[3] = HEX(id, 12); + str[4] = HEX(id, 8); + str[5] = HEX(id, 4); + str[6] = HEX(id, 0); + str[7] = '\0'; + + return; +} +// +#undef CHAR +#undef HEX + +/* + * Build a linked list of pci_devs in order of ascending node number + * Called only at init time. + */ +static void __init build_devlist(void) +{ + int i; + int nodenum; + int nodes_got = 0; + int devs = 0; + struct pnp_bios_node *node; + struct pnp_dev_node_info node_info; + struct pci_dev *dev; + + if (!pnp_bios_present ()) + return; + + if (pnp_bios_dev_node_info(&node_info) != 0) + return; + + node = pnpbios_kmalloc(node_info.max_node_size, GFP_KERNEL); + if (!node) + return; + + for(i=0,nodenum=0; i<0xff && nodenum!=0xff; i++) { + int thisnodenum = nodenum; + /* For now we build the list from the "boot" config + * because asking for the "current" config causes + * some BIOSes to crash. */ + if (pnp_bios_get_dev_node((u8 *)&nodenum, (char )1 , node)) { + printk(KERN_WARNING "PnPBIOS: PnP BIOS reported error on attempt to get dev node.\n"); + break; + } + /* The BIOS returns with nodenum = the next node number */ + if (nodenum < thisnodenum) { + printk(KERN_WARNING "PnPBIOS: Node number is out of sequence. Naughty BIOS!\n"); + break; + } + nodes_got++; + dev = pnpbios_kmalloc(sizeof (struct pci_dev), GFP_KERNEL); + if (!dev) + break; + memset(dev,0,sizeof(struct pci_dev)); + dev->devfn=thisnodenum; + memcpy(dev->name,"PNPBIOS",8); + pnpid32_to_pnpid(node->eisa_id,dev->slot_name); + node_resource_data_to_dev(node,dev); + if(insert_device(dev)<0) + kfree(dev); + else + devs++; + } + kfree(node); + + printk(KERN_INFO "PnPBIOS: %i node%s reported by PnP BIOS; %i recorded by driver.\n", + nodes_got, nodes_got != 1 ? "s" : "", devs); +} + +static struct pci_dev *find_device_by_nodenum( u8 nodenum ) +{ + struct pci_dev *dev; + + pnpbios_for_each_dev(dev) { + if(dev->devfn == nodenum) + return dev; + } + + return NULL; +} + +static void update_devlist( u8 nodenum, struct pnp_bios_node *data ) +{ + unsigned long flags; + struct pci_dev *dev; + + spin_lock_irqsave(&pnpbios_devices_lock, flags); + dev = find_device_by_nodenum( nodenum ); + if ( dev ) { + node_resource_data_to_dev(data,dev); + } + spin_unlock_irqrestore(&pnpbios_devices_lock, flags); + + return; +} + + +/* + * + * DRIVER REGISTRATION FUNCTIONS + * + * + * Exported to give public access + * + */ + +static LIST_HEAD(pnpbios_drivers); + +static const struct pnpbios_device_id * +match_device(const struct pnpbios_device_id *ids, const struct pci_dev *dev) +{ + while (*ids->id) + { + if(memcmp(ids->id, dev->slot_name, 7)==0) + return ids; + ids++; + } + return NULL; +} + +static int announce_device(struct pnpbios_driver *drv, struct pci_dev *dev) +{ + const struct pnpbios_device_id *id; + struct pci_dev tmpdev; + int ret; + + if (drv->id_table) { + id = match_device(drv->id_table, dev); + if (!id) + return 0; + } else + id = NULL; + + memcpy( &tmpdev, dev, sizeof(struct pci_dev)); + tmpdev.global_list.prev = NULL; + tmpdev.global_list.next = NULL; + + dev_probe_lock(); + /* Obviously, probe() should not call any pnpbios functions */ + ret = drv->probe(&tmpdev, id); + dev_probe_unlock(); + if (ret < 1) + return 0; + + dev->driver = (void *)drv; + + return 1; +} + +/** + * pnpbios_register_driver - register a new pci driver + * @drv: the driver structure to register + * + * Adds the driver structure to the list of registered drivers + * + * For each device in the pnpbios device list that matches one of + * the ids in drv->id_table, calls the driver's "probe" function with + * arguments (1) a pointer to a *temporary* struct pci_dev containing + * resource info for the device, and (2) a pointer to the id string + * of the device. Expects the probe function to return 1 if the + * driver claims the device (otherwise 0) in which case, marks the + * device as having this driver. + * + * Returns the number of pci devices which were claimed by the driver + * during registration. The driver remains registered even if the + * return value is zero. + */ +int pnpbios_register_driver(struct pnpbios_driver *drv) +{ + struct pci_dev *dev; + unsigned long flags; + int count = 0; + + list_add_tail(&drv->node, &pnpbios_drivers); + spin_lock_irqsave(&pnpbios_devices_lock, flags); + pnpbios_for_each_dev(dev) { + if (!pnpbios_dev_driver(dev)) + count += announce_device(drv, dev); + } + spin_unlock_irqrestore(&pnpbios_devices_lock, flags); + return count; +} + +EXPORT_SYMBOL(pnpbios_register_driver); + +/** + * pnpbios_unregister_driver - unregister a pci driver + * @drv: the driver structure to unregister + * + * Deletes the driver structure from the list of registered PnPBIOS + * drivers, gives it a chance to clean up by calling its "remove" + * function for each device it was responsible for, and marks those + * devices as driverless. + */ +void pnpbios_unregister_driver(struct pnpbios_driver *drv) +{ + unsigned long flags; + struct pci_dev *dev; + + list_del(&drv->node); + spin_lock_irqsave(&pnpbios_devices_lock, flags); + pnpbios_for_each_dev(dev) { + if (dev->driver == (void *)drv) { + if (drv->remove) + drv->remove(dev); + dev->driver = NULL; + } + } + spin_unlock_irqrestore(&pnpbios_devices_lock, flags); +} + +EXPORT_SYMBOL(pnpbios_unregister_driver); + + +/* + * + * RESOURCE RESERVATION FUNCTIONS + * + * + * Used only at init time + * + */ + +static void __init reserve_ioport_range(char *pnpid, int start, int end) +{ + struct resource *res; + char *regionid; + + regionid = pnpbios_kmalloc(16, GFP_KERNEL); + if ( regionid == NULL ) + return; + sprintf(regionid, "PnPBIOS %s", pnpid); + res = request_region(start,end-start+1,regionid); + if ( res == NULL ) + kfree( regionid ); + else + res->flags &= ~IORESOURCE_BUSY; + /* + * Failures at this point are usually harmless. pci quirks for + * example do reserve stuff they know about too, so we may well + * have double reservations. + */ + printk(KERN_INFO + "PnPBIOS: %s: ioport range 0x%x-0x%x %s reserved.\n", + pnpid, start, end, + NULL != res ? "has been" : "could not be" + ); + + return; +} + +static void __init reserve_resources_of_dev( struct pci_dev *dev ) +{ + int i; + + for (i=0;i<DEVICE_COUNT_RESOURCE;i++) { + if ( dev->resource[i].flags & IORESOURCE_UNSET ) + /* end of resources */ + break; + if (dev->resource[i].flags & IORESOURCE_IO) { + /* ioport */ + if ( dev->resource[i].start == 0 ) + /* disabled */ + /* Do nothing */ + continue; + if ( dev->resource[i].start < 0x100 ) + /* + * Below 0x100 is only standard PC hardware + * (pics, kbd, timer, dma, ...) + * We should not get resource conflicts there, + * and the kernel reserves these anyway + * (see arch/i386/kernel/setup.c). + * So, do nothing + */ + continue; + if ( dev->resource[i].end < dev->resource[i].start ) + /* invalid endpoint */ + /* Do nothing */ + continue; + reserve_ioport_range( + dev->slot_name, + dev->resource[i].start, + dev->resource[i].end + ); + } else if (dev->resource[i].flags & IORESOURCE_MEM) { + /* iomem */ + /* For now do nothing */ + continue; + } else { + /* Neither ioport nor iomem */ + /* Do nothing */ + continue; + } + } + + return; +} + +static void __init reserve_resources( void ) +{ + struct pci_dev *dev; + + pnpbios_for_each_dev(dev) { + if ( + 0 != strcmp(dev->slot_name,"PNP0c01") && /* memory controller */ + 0 != strcmp(dev->slot_name,"PNP0c02") /* system peripheral: other */ + ) { + continue; + } + reserve_resources_of_dev(dev); + } + + return; +} + + +/* + * + * INIT AND EXIT + * + */ + +extern int is_sony_vaio_laptop; + +static int pnpbios_disabled; /* = 0 */ +static int dont_reserve_resources; /* = 0 */ +int pnpbios_dont_use_current_config; /* = 0 */ + +#ifndef MODULE +static int __init pnpbios_setup(char *str) +{ + int invert; + + while ((str != NULL) && (*str != '\0')) { + if (strncmp(str, "off", 3) == 0) + pnpbios_disabled=1; + if (strncmp(str, "on", 2) == 0) + pnpbios_disabled=0; + invert = (strncmp(str, "no-", 3) == 0); + if (invert) + str += 3; + if (strncmp(str, "curr", 4) == 0) + pnpbios_dont_use_current_config = invert; + if (strncmp(str, "res", 3) == 0) + dont_reserve_resources = invert; + str = strchr(str, ','); + if (str != NULL) + str += strspn(str, ", \t"); + } + + return 1; +} + +__setup("pnpbios=", pnpbios_setup); +#endif + +void __init pnpbios_init(void) +{ + union pnp_bios_expansion_header *check; + u8 sum; + int i, length; + + spin_lock_init(&pnp_bios_lock); + spin_lock_init(&pnpbios_devices_lock); + + if(pnpbios_disabled) { + printk(KERN_INFO "PnPBIOS: Disabled.\n"); + return; + } + + if ( is_sony_vaio_laptop ) + pnpbios_dont_use_current_config = 1; + + /* + * Search the defined area (0xf0000-0xffff0) for a valid PnP BIOS + * structure and, if one is found, sets up the selectors and + * entry points + */ + for (check = (union pnp_bios_expansion_header *) __va(0xf0000); + check < (union pnp_bios_expansion_header *) __va(0xffff0); + ((void *) (check)) += 16) { + if (check->fields.signature != PNP_SIGNATURE) + continue; + length = check->fields.length; + if (!length) + continue; + for (sum = 0, i = 0; i < length; i++) + sum += check->chars[i]; + if (sum) + continue; + if (check->fields.version < 0x10) { + printk(KERN_WARNING "PnPBIOS: PnP BIOS version %d.%d is not supported.\n", + check->fields.version >> 4, + check->fields.version & 15); + continue; + } + printk(KERN_INFO "PnPBIOS: Found PnP BIOS installation structure at 0x%p.\n", check); + printk(KERN_INFO "PnPBIOS: PnP BIOS version %d.%d, entry 0x%x:0x%x, dseg 0x%x.\n", + check->fields.version >> 4, check->fields.version & 15, + check->fields.pm16cseg, check->fields.pm16offset, + check->fields.pm16dseg); + Q2_SET_SEL(PNP_CS32, &pnp_bios_callfunc, 64 * 1024); + Q_SET_SEL(PNP_CS16, check->fields.pm16cseg, 64 * 1024); + Q_SET_SEL(PNP_DS, check->fields.pm16dseg, 64 * 1024); + pnp_bios_callpoint.offset = check->fields.pm16offset; + pnp_bios_callpoint.segment = PNP_CS16; + pnp_bios_hdr = check; + break; + } + build_devlist(); + if ( ! dont_reserve_resources ) + reserve_resources(); +#ifdef CONFIG_PROC_FS + pnpbios_proc_init(); +#endif +#ifdef CONFIG_HOTPLUG + init_completion(&unload_sem); + if(kernel_thread(pnp_dock_thread, NULL, CLONE_FS | CLONE_FILES | CLONE_SIGNAL)>0) + unloading = 0; +#endif +} + +#ifdef MODULE + +MODULE_LICENSE("GPL"); + +/* We have to run it early and not as a module. */ +module_init(pnpbios_init); + +#ifdef CONFIG_HOTPLUG +static void pnpbios_exit(void) +{ + /* free_resources() ought to go here */ + /* pnpbios_proc_done() */ + unloading = 1; + wait_for_completion(&unload_sem); +} + +module_exit(pnpbios_exit); + +#endif +#endif diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/pnp/pnpbios_proc.c linux-2.5/drivers/pnp/pnpbios_proc.c --- linux-2.5.1/drivers/pnp/pnpbios_proc.c Thu Jan 1 00:00:00 1970 +++ linux-2.5/drivers/pnp/pnpbios_proc.c Sat Dec 29 12:07:19 2001 @@ -0,0 +1,151 @@ +/* + * pnp_proc.c: /proc/bus/pnp interface for Plug and Play devices + * + * Written by David Hinds, dahinds@users.sourceforge.net + */ + +//#include <pcmcia/config.h> +#define __NO_VERSION__ +//#include <pcmcia/k_compat.h> + +#include <linux/module.h> +#include <linux/kernel.h> +#include <linux/slab.h> +#include <linux/types.h> +#include <linux/proc_fs.h> +#include <linux/pnpbios.h> + +static struct proc_dir_entry *proc_pnp = NULL; +static struct proc_dir_entry *proc_pnp_boot = NULL; +static struct pnp_dev_node_info node_info; + +static int proc_read_devices(char *buf, char **start, off_t pos, + int count, int *eof, void *data) +{ + struct pnp_bios_node *node; + int i; + u8 nodenum; + char *p = buf; + + if (pos != 0) { + *eof = 1; + return 0; + } + node = pnpbios_kmalloc(node_info.max_node_size, GFP_KERNEL); + if (!node) return -ENOMEM; + for (i=0,nodenum=0;i<0xff && nodenum!=0xff; i++) { + if ( pnp_bios_get_dev_node(&nodenum, 1, node) ) + break; + p += sprintf(p, "%02x\t%08x\t%02x:%02x:%02x\t%04x\n", + node->handle, node->eisa_id, + node->type_code[0], node->type_code[1], + node->type_code[2], node->flags); + } + kfree(node); + return (p-buf); +} + +static int proc_read_node(char *buf, char **start, off_t pos, + int count, int *eof, void *data) +{ + struct pnp_bios_node *node; + int boot = (long)data >> 8; + u8 nodenum = (long)data; + int len; + + if (pos != 0) { + *eof = 1; + return 0; + } + node = pnpbios_kmalloc(node_info.max_node_size, GFP_KERNEL); + if (!node) return -ENOMEM; + if ( pnp_bios_get_dev_node(&nodenum, boot, node) ) + return -EIO; + len = node->size - sizeof(struct pnp_bios_node); + memcpy(buf, node->data, len); + kfree(node); + return len; +} + +static int proc_write_node(struct file *file, const char *buf, + unsigned long count, void *data) +{ + struct pnp_bios_node *node; + int boot = (long)data >> 8; + u8 nodenum = (long)data; + + node = pnpbios_kmalloc(node_info.max_node_size, GFP_KERNEL); + if (!node) return -ENOMEM; + if ( pnp_bios_get_dev_node(&nodenum, boot, node) ) + return -EIO; + if (count != node->size - sizeof(struct pnp_bios_node)) + return -EINVAL; + memcpy(node->data, buf, count); + if (pnp_bios_set_dev_node(node->handle, boot, node) != 0) + return -EINVAL; + kfree(node); + return count; +} + +/* + * When this is called, pnpbios functions are assumed to + * work and the pnpbios_dont_use_current_config flag + * should already have been set to the appropriate value + */ +void pnpbios_proc_init( void ) +{ + struct pnp_bios_node *node; + struct proc_dir_entry *ent; + char name[3]; + int i; + u8 nodenum; + + if (pnp_bios_dev_node_info(&node_info) != 0) return; + + proc_pnp = proc_mkdir("pnp", proc_bus); + if (!proc_pnp) return; + proc_pnp_boot = proc_mkdir("boot", proc_pnp); + if (!proc_pnp_boot) return; + create_proc_read_entry("devices", 0, proc_pnp, proc_read_devices, NULL); + + node = pnpbios_kmalloc(node_info.max_node_size, GFP_KERNEL); + if (!node) return; + for (i=0,nodenum = 0; i<0xff && nodenum != 0xff; i++) { + if (pnp_bios_get_dev_node(&nodenum, 1, node) != 0) + break; + sprintf(name, "%02x", node->handle); + if ( !pnpbios_dont_use_current_config ) { + ent = create_proc_entry(name, 0, proc_pnp); + if (ent) { + ent->read_proc = proc_read_node; + ent->write_proc = proc_write_node; + ent->data = (void *)(long)(node->handle); + } + } + ent = create_proc_entry(name, 0, proc_pnp_boot); + if (ent) { + ent->read_proc = proc_read_node; + ent->write_proc = proc_write_node; + ent->data = (void *)(long)(node->handle+0x100); + } + } + kfree(node); +} + +void pnpbios_proc_done(void) +{ + int i; + char name[3]; + + if (!proc_pnp) return; + + for (i=0; i<0xff; i++) { + sprintf(name, "%02x", i); + if ( !pnpbios_dont_use_current_config ) + remove_proc_entry(name, proc_pnp); + remove_proc_entry(name, proc_pnp_boot); + } + remove_proc_entry("boot", proc_pnp); + remove_proc_entry("devices", proc_pnp); + remove_proc_entry("pnp", proc_bus); +} diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/s390/Makefile linux-2.5/drivers/s390/Makefile --- linux-2.5.1/drivers/s390/Makefile Wed Jul 25 21:12:02 2001 +++ linux-2.5/drivers/s390/Makefile Thu Dec 27 16:32:31 2001 @@ -7,7 +7,7 @@ subdir-y := block char misc net subdir-m := $(subdir-y) -obj-y := s390io.o s390mach.o s390dyn.o idals.o ccwcache.o +obj-y := s390io.o s390mach.o s390dyn.o idals.o ccwcache.o sysinfo.o export-objs += ccwcache.o idals.o s390dyn.o s390io.o obj-y += $(foreach dir,$(subdir-y),$(dir)/s390-$(dir).o) diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/s390/block/dasd.c linux-2.5/drivers/s390/block/dasd.c --- linux-2.5.1/drivers/s390/block/dasd.c Sun Dec 9 04:02:47 2001 +++ linux-2.5/drivers/s390/block/dasd.c Thu Dec 27 16:32:31 2001 @@ -113,6 +113,7 @@ EXPORT_SYMBOL (dasd_default_erp_postaction); EXPORT_SYMBOL (dasd_sleep_on_req); EXPORT_SYMBOL (dasd_set_normalized_cda); +EXPORT_SYMBOL (dasd_device_from_kdev); /* SECTION: Constant definitions to be used within this file */ @@ -668,12 +669,18 @@ /* init devfs array */ major_info->gendisk.de_arr = (devfs_handle_t *) kmalloc (DASD_PER_MAJOR * sizeof (devfs_handle_t), GFP_KERNEL); + if(major_info->gendisk.de_arr == NULL) + goto out_gd_de_arr; + memset (major_info->gendisk.de_arr, 0, DASD_PER_MAJOR * sizeof (devfs_handle_t)); /* init flags */ major_info->gendisk.flags = (char *) kmalloc (DASD_PER_MAJOR * sizeof (char), GFP_KERNEL); + if(major_info->gendisk.flags == NULL) + goto out_gd_flags; + memset (major_info->gendisk.flags, 0, DASD_PER_MAJOR * sizeof (char)); /* register blockdevice */ @@ -781,10 +788,13 @@ major_info->flags &= ~DASD_MAJOR_INFO_REGISTERED; } - out_reg_blkdev: - kfree (major_info->gendisk.flags); - kfree (major_info->gendisk.de_arr); +out_reg_blkdev: + kfree (major_info->gendisk.flags); + +out_gd_flags: + kfree (major_info->gendisk.de_arr); +out_gd_de_arr: /* Delete the new major info from dasd_major_info if needed */ if (!(major_info->flags & DASD_MAJOR_INFO_IS_STATIC)) { kfree (major_info); @@ -846,7 +856,7 @@ * finds the device structure corresponding to the kdev supplied as argument * in the major_info structures and returns it or NULL when not found */ -static inline dasd_device_t * +dasd_device_t * dasd_device_from_kdev (kdev_t kdev) { major_info_t *major_info = NULL; @@ -1851,15 +1861,15 @@ dasd_era_t era = dasd_era_none; /* default is everything is okay */ devstat_t *stat = (devstat_t *)ds; + if (stat == NULL) { + BUG(); + } DASD_DRIVER_DEBUG_EVENT (6, dasd_int_handler, "Interrupt: IRQ %02x, stat %02x, devno %04x", irq, stat->dstat, stat->devno); asm volatile ("STCK %0":"=m" (now)); - if (stat == NULL) { - BUG(); - } /* first of all check for state change pending interrupt */ if ((stat->dstat & DEV_STAT_ATTENTION ) && @@ -2291,6 +2301,18 @@ rc = put_user(ver, (int *) data); break; } + case BLKGETSIZE:{ /* Return device size */ + long blocks = major_info->gendisk.sizes + [MINOR (inp->i_rdev)] << 1; + rc = put_user(blocks, (long *) data); + break; + } + case BLKGETSIZE64:{ + u64 blocks = major_info->gendisk.sizes + [MINOR (inp->i_rdev)]; + rc = put_user(blocks << 10, (u64 *) data); + break; + } case BLKRRPART:{ if (!capable (CAP_SYS_ADMIN)) { rc = -EACCES; @@ -2484,8 +2506,6 @@ break; } #endif /* 0 */ - case BLKGETSIZE: - case BLKGETSIZE64: case BLKSSZGET: case BLKROSET: case BLKROGET: @@ -2623,7 +2643,6 @@ invalidate_buffers (inp->i_rdev); if ( device->discipline->owner ) __MOD_DEC_USE_COUNT(device->discipline->owner); - MOD_DEC_USE_COUNT; } else if ( count == -1 ) { /* paranoia only */ atomic_set (&device->open_count,0); printk (KERN_WARNING PRINTK_HEADER diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/s390/block/dasd_3990_erp.c linux-2.5/drivers/s390/block/dasd_3990_erp.c --- linux-2.5.1/drivers/s390/block/dasd_3990_erp.c Fri Nov 9 22:05:02 2001 +++ linux-2.5/drivers/s390/block/dasd_3990_erp.c Thu Dec 27 16:32:31 2001 @@ -237,8 +237,9 @@ /* check for 'No Record Found' */ if (sense[1] & SNS1_NO_REC_FOUND) { - DASD_MESSAGE (KERN_ERR, device, "%s", - "EXAMINE 24: No Record Found detected " + DASD_MESSAGE (KERN_ERR, device, + "EXAMINE 24: No Record Found detected %s", + cqr == device->init_cqr ? " " : "- fatal error"); return dasd_era_fatal; @@ -305,8 +306,9 @@ devstat_t *stat) { - char *sense = stat->ii.sense.data; - dasd_era_t era = dasd_era_recover; + char *sense = stat->ii.sense.data; + dasd_era_t era = dasd_era_recover; + dasd_device_t *device = cqr->device; /* check for successful execution first */ if (stat->cstat == 0x00 && @@ -327,7 +329,8 @@ } /* log the erp chain if fatal error occurred */ - if (era == dasd_era_fatal) { + if ((era == dasd_era_fatal ) && + (cqr != device->init_cqr) ){ log_erp_chain (cqr, 0, diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/s390/block/dasd_eckd.c linux-2.5/drivers/s390/block/dasd_eckd.c --- linux-2.5.1/drivers/s390/block/dasd_eckd.c Fri Nov 9 22:05:02 2001 +++ linux-2.5/drivers/s390/block/dasd_eckd.c Thu Dec 27 16:32:31 2001 @@ -585,7 +585,7 @@ /* Free the cqr and cleanup device->sizes */ if ( status != CQR_STATUS_DONE ) { DASD_MESSAGE (KERN_WARNING,device,"%s", - "volume analysis returned fatal error"); + "volume analysis returned unformatted disk"); return -EMEDIUMTYPE; } /* Check Track 0 for Compatible Disk Layout */ @@ -1097,8 +1097,14 @@ ccw->flags |= CCW_FLAG_CC; ccw->cmd_code = locate4k_set ? rw_cmd : dasd_eckd_cdl_cmd (device, recid, req->cmd); - ccw->count = locate4k_set ? byt_per_blk : - dasd_eckd_cdl_reclen (device, recid); + ccw->count = byt_per_blk; + if (!locate4k_set) { + ccw->count = dasd_eckd_cdl_reclen (device,recid); + if (ccw->count < byt_per_blk) { + memset (bh->b_data + size + ccw->count, + 0xE5, byt_per_blk - ccw->count); + } + } if (dasd_set_normalized_cda (ccw, __pa (bh->b_data+size), rw_cp, device)) { goto clear_rw_cp; } diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/s390/block/dasd_int.h linux-2.5/drivers/s390/block/dasd_int.h --- linux-2.5.1/drivers/s390/block/dasd_int.h Sun Sep 30 19:26:07 2001 +++ linux-2.5/drivers/s390/block/dasd_int.h Thu Dec 27 16:32:31 2001 @@ -259,7 +259,6 @@ typedef int (*dasd_info_fn_t) (struct dasd_device_t *, dasd_information_t *); typedef int (*dasd_use_count_fn_t) (int); - /* * the dasd_discipline_t is * sth like a table of virtual functions, if you think of dasd_eckd @@ -364,6 +363,7 @@ void dasd_schedule_bh (dasd_device_t *); int dasd_sleep_on_req(ccw_req_t*); int dasd_set_normalized_cda ( ccw1_t * cp, unsigned long address, ccw_req_t* request, dasd_device_t* device ); +dasd_device_t * dasd_device_from_kdev (kdev_t kdev); extern debug_info_t *dasd_debug_area; extern int (*genhd_dasd_name) (char *, int, int, struct gendisk *); diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/s390/char/con3215.c linux-2.5/drivers/s390/char/con3215.c --- linux-2.5.1/drivers/s390/char/con3215.c Wed Jul 25 21:12:02 2001 +++ linux-2.5/drivers/s390/char/con3215.c Sun Dec 30 13:55:22 2001 @@ -1145,7 +1145,9 @@ tty3215_driver.table = tty3215_table; tty3215_driver.termios = tty3215_termios; tty3215_driver.termios_locked = tty3215_termios_locked; - +#ifdef CONFIG_TN3215_CONSOLE + tty3215_driver.console = &con3215; +#endif tty3215_driver.open = tty3215_open; tty3215_driver.close = tty3215_close; tty3215_driver.write = tty3215_write; diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/s390/char/tuball.c linux-2.5/drivers/s390/char/tuball.c --- linux-2.5.1/drivers/s390/char/tuball.c Thu Oct 11 16:43:29 2001 +++ linux-2.5/drivers/s390/char/tuball.c Thu Dec 27 15:56:12 2001 @@ -84,7 +84,6 @@ tub3270_con_write, /* write */ NULL, /* read */ tub3270_con_device, /* device */ - NULL, /* wait_key */ tub3270_con_unblank, /* unblank */ NULL, /* setup */ CON_PRINTBUFFER, /* flags */ diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/s390/char/tubtty.c linux-2.5/drivers/s390/char/tubtty.c --- linux-2.5.1/drivers/s390/char/tubtty.c Thu Oct 11 16:43:29 2001 +++ linux-2.5/drivers/s390/char/tubtty.c Sun Dec 30 13:55:22 2001 @@ -53,6 +53,7 @@ struct tty_struct *tty3270_table[TUBMAXMINS]; struct termios *tty3270_termios[TUBMAXMINS]; struct termios *tty3270_termios_locked[TUBMAXMINS]; +extern struct console tub3270_con; #ifdef CONFIG_TN3270_CONSOLE int con3270_major = -1; struct tty_driver con3270_driver; @@ -94,7 +95,9 @@ td->table = tty3270_table; td->termios = tty3270_termios; td->termios_locked = tty3270_termios_locked; - +#ifdef CONFIG_TN3270_CONSOLE + td->console = &tub3270_con; +#endif td->open = tty3270_open; td->close = tty3270_close; td->write = tty3270_write; diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/s390/misc/chandev.c linux-2.5/drivers/s390/misc/chandev.c --- linux-2.5.1/drivers/s390/misc/chandev.c Fri Nov 9 22:05:02 2001 +++ linux-2.5/drivers/s390/misc/chandev.c Thu Dec 27 16:32:31 2001 @@ -1057,6 +1057,9 @@ chandev_add_model(chandev_type_osad,0x3088,0x62,-1,-1,0,default_msck_bits,FALSE,FALSE); /* claw */ chandev_add_model(chandev_type_claw,0x3088,0x61,-1,-1,0,default_msck_bits,FALSE,FALSE); + + /* ficon attached ctc */ + chandev_add_model(chandev_type_escon,0x3088,0x1E,-1,-1,0,default_msck_bits,FALSE,FALSE); } @@ -3092,7 +3095,7 @@ chandevs_detected=TRUE; if(pass) { - chandev_printf(chan_exit,"0x%04x 0x%04x 0x%02x 0x%04x 0x%02x 0x%04x 0x%02x 0x%02x 0x%016Lx %-5s %-5s\n", + chandev_printf(chan_exit,"0x%04x 0x%04x 0x%02x 0x%04x 0x%02x 0x%04x 0x%02x 0x%02x 0x%016Lx %-5s%-5s\n", curr_irq,curr_devinfo.devno, ( curr_force ? curr_force->chan_type : ( curr_model ? curr_model->chan_type : diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/s390/net/ctcmain.c linux-2.5/drivers/s390/net/ctcmain.c --- linux-2.5.1/drivers/s390/net/ctcmain.c Thu Oct 11 16:43:29 2001 +++ linux-2.5/drivers/s390/net/ctcmain.c Thu Dec 27 16:32:31 2001 @@ -1,5 +1,5 @@ /* - * $Id: ctcmain.c,v 1.51 2001/09/24 10:38:02 mschwide Exp $ + * $Id: ctcmain.c,v 1.55 2001/12/03 14:28:45 felfert Exp $ * * CTC / ESCON network driver * @@ -35,7 +35,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * - * RELEASE-TAG: CTC/ESCON network driver $Revision: 1.51 $ + * RELEASE-TAG: CTC/ESCON network driver $Revision: 1.55 $ * */ @@ -96,7 +96,9 @@ #ifdef MODULE MODULE_AUTHOR("(C) 2000 IBM Corp. by Fritz Elfert (felfert@millenux.com)"); MODULE_DESCRIPTION("Linux for S/390 CTC/Escon Driver"); +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,12)) MODULE_LICENSE("GPL"); +#endif #ifndef CTC_CHANDEV MODULE_PARM(ctc, "s"); MODULE_PARM_DESC(ctc, @@ -368,7 +370,7 @@ static __inline__ void ctc_clear_busy(net_device *dev) { clear_bit(0, &(((ctc_priv *)dev->priv)->tbusy)); - netif_start_queue(dev); + netif_wake_queue(dev); } static __inline__ int ctc_test_and_set_busy(net_device *dev) @@ -385,7 +387,7 @@ */ static void print_banner(void) { static int printed = 0; - char vbuf[] = "$Revision: 1.51 $"; + char vbuf[] = "$Revision: 1.55 $"; char *version = vbuf; if (printed) @@ -396,7 +398,16 @@ *p = '\0'; } else version = " ??? "; - printk(KERN_INFO "CTC driver Version%s initialized\n", version); + printk(KERN_INFO + "CTC driver Version%swith" +#ifndef CTC_CHANDEV + "out" +#endif + " CHANDEV support" +#ifdef DEBUG + " (DEBUG-VERSION, " __DATE__ __TIME__ ")" +#endif + " initialized\n", version); printed = 1; } @@ -754,12 +765,13 @@ pskb->protocol = ntohs(header->type); header->length -= LL_HEADER_LENGTH; if ((header->length == 0) || - (header->length > skb_tailroom(pskb))) { + (header->length > skb_tailroom(pskb)) || + (header->length > len)) { printk(KERN_WARNING "%s Illegal packet size %d " - "received (MTU=%d), " + "received (MTU=%d blocklen=%d), " "dropping\n", dev->name, header->length, - dev->mtu); + dev->mtu, len); #ifdef DEBUG ctc_dump_skb(pskb, -6); #endif @@ -929,7 +941,8 @@ if (ch->trans_skb != NULL) dev_kfree_skb(ch->trans_skb); clear_normalized_cda(&ch->ccw[1]); - ch->trans_skb = dev_alloc_skb(ch->max_bufsize); + ch->trans_skb = __dev_alloc_skb(ch->max_bufsize, + GFP_ATOMIC|GFP_DMA); if (ch->trans_skb == NULL) { if (warn) printk(KERN_WARNING @@ -1026,7 +1039,6 @@ ch->prof.maxmulti = ch->collect_len + 2; if (ch->prof.maxcqueue < skb_queue_len(&ch->collect_queue)) ch->prof.maxcqueue = skb_queue_len(&ch->collect_queue); - ch->ccw[1].count = ch->collect_len + 2; *((__u16 *)skb_put(ch->trans_skb, 2)) = ch->collect_len + 2; i = 0; while ((skb = skb_dequeue(&ch->collect_queue))) { @@ -1039,11 +1051,10 @@ i++; } ch->collect_len = 0; + spin_unlock(&ch->collect_lock); + ch->ccw[1].count = ch->trans_skb->len; fsm_addtimer(&ch->timer, CTC_TIMEOUT_5SEC, CH_EVENT_TIMER, ch); ch->prof.send_stamp = xtime; -#ifdef DEBUG - printk(KERN_DEBUG "ccw[1].cda = %08x\n", ch->ccw[1].cda); -#endif rc = do_IO(ch->irq, &ch->ccw[0], (intparm_t)ch, 0xff, 0); ch->prof.doios_multi++; if (rc != 0) { @@ -1052,10 +1063,11 @@ fsm_deltimer(&ch->timer); ccw_check_return_code(ch, rc); } - } else + } else { + spin_unlock(&ch->collect_lock); fsm_newstate(fi, CH_STATE_TXIDLE); + } ctc_clear_busy(dev); - spin_unlock(&ch->collect_lock); } /** @@ -1146,9 +1158,6 @@ if (ctc_checkalloc_buffer(ch, 1)) return; ch->ccw[1].count = ch->max_bufsize; -#ifdef DEBUG - printk(KERN_DEBUG "ccw[1].cda = %08x\n", ch->ccw[1].cda); -#endif rc = do_IO(ch->irq, &ch->ccw[0], (intparm_t)ch, 0xff, 0); if (rc != 0) ccw_check_return_code(ch, rc); @@ -1203,9 +1212,6 @@ *((__u16 *)ch->trans_skb->data) = CTC_INITIAL_BLOCKLEN; ch->ccw[1].count = 2; /* Transfer only length */ -#ifdef DEBUG - printk(KERN_DEBUG "ccw[1].cda = %08x\n", ch->ccw[1].cda); -#endif fsm_newstate(fi, (CHANNEL_DIRECTION(ch->flags) == READ) ? CH_STATE_RXINIT : CH_STATE_TXINIT); rc = do_IO(ch->irq, &ch->ccw[0], (intparm_t)ch, 0xff, 0); @@ -1254,9 +1260,6 @@ return; ch->ccw[1].count = ch->max_bufsize; fsm_newstate(fi, CH_STATE_RXIDLE); -#ifdef DEBUG - printk(KERN_DEBUG "ccw[1].cda = %08x\n", ch->ccw[1].cda); -#endif rc = do_IO(ch->irq, &ch->ccw[0], (intparm_t)ch, 0xff, 0); if (rc != 0) { fsm_newstate(fi, CH_STATE_RXINIT); @@ -1716,9 +1719,6 @@ fsm_addtimer(&ch->timer, 1000, CH_EVENT_TIMER, ch); if (event == CH_EVENT_TIMER) s390irq_spin_lock_irqsave(ch->irq, saveflags); -#ifdef DEBUG - printk(KERN_DEBUG "ccw[4].cda = %08x\n", ch->ccw[4].cda); -#endif rc = do_IO(ch->irq, &ch->ccw[3], (intparm_t)ch, 0xff, 0); if (event == CH_EVENT_TIMER) s390irq_spin_unlock_irqrestore(ch->irq, @@ -2479,6 +2479,8 @@ } else { __u16 block_len; int ccw_idx; + struct sk_buff *nskb; + unsigned long hi; /** * Protect skb against beeing free'd by upper @@ -2493,6 +2495,28 @@ LL_HEADER_LENGTH); block_len = skb->len + 2; *((__u16 *)skb_push(skb, 2)) = block_len; + + /** + * IDAL support in CTC is broken, so we have to + * care about skb's above 2G ourselves. + */ + hi = ((unsigned long)skb->tail + LL_HEADER_LENGTH) >> 31; + if (hi) { + nskb = alloc_skb(skb->len, GFP_ATOMIC | GFP_DMA); + if (!nskb) { + atomic_dec(&skb->users); + skb_pull(skb, LL_HEADER_LENGTH + 2); + return -ENOMEM; + } else { + memcpy(skb_put(nskb, skb->len), + skb->data, skb->len); + atomic_inc(&nskb->users); + atomic_dec(&skb->users); + dev_kfree_skb_irq(skb); + skb = nskb; + } + } + ch->ccw[4].count = block_len; if (set_normalized_cda(&ch->ccw[4], virt_to_phys(skb->data))) { /** @@ -2505,6 +2529,7 @@ * Remove our header. It gets added * again on retransmit. */ + atomic_dec(&skb->users); skb_pull(skb, LL_HEADER_LENGTH + 2); return -EBUSY; } @@ -2522,18 +2547,11 @@ ccw_idx = 3; } ch->retry = 0; -#ifdef DEBUG - ctc_dump_skb(skb, 0); -#endif fsm_newstate(ch->fsm, CH_STATE_TX); fsm_addtimer(&ch->timer, CTC_TIMEOUT_5SEC, CH_EVENT_TIMER, ch); s390irq_spin_lock_irqsave(ch->irq, saveflags); ch->prof.send_stamp = xtime; -#ifdef DEBUG - printk(KERN_DEBUG "ccw[%d].cda = %08x\n", ccw_idx+1, - ch->ccw[ccw_idx+1].cda); -#endif rc = do_IO(ch->irq, &ch->ccw[ccw_idx], (intparm_t)ch, 0xff, 0); s390irq_spin_unlock_irqrestore(ch->irq, saveflags); if (ccw_idx == 3) diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/s390/net/fsm.h linux-2.5/drivers/s390/net/fsm.h --- linux-2.5.1/drivers/s390/net/fsm.h Wed Jul 25 21:12:02 2001 +++ linux-2.5/drivers/s390/net/fsm.h Thu Dec 27 16:32:31 2001 @@ -1,4 +1,4 @@ -/* $Id: fsm.h,v 1.3 2001/06/18 16:49:19 felfert Exp $ +/* $Id: fsm.h,v 1.4 2001/09/24 10:38:02 mschwide Exp $ */ #ifndef _FSM_H_ #define _FSM_H_ diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/s390/net/iucv.c linux-2.5/drivers/s390/net/iucv.c --- linux-2.5.1/drivers/s390/net/iucv.c Thu Oct 11 16:43:29 2001 +++ linux-2.5/drivers/s390/net/iucv.c Thu Dec 27 16:32:31 2001 @@ -1,4 +1,4 @@ -/* +/* * $Id$ * * IUCV network driver @@ -478,7 +478,7 @@ b2f0(__u32 code, void *parm) { iucv_debug("iparml before b2f0 call:"); - iucv_dumpit(parm, sizeof(iucv_param.param)); + iucv_dumpit(parm, sizeof(iucv_param)); asm volatile ( "LRA 1,0(%1)\n\t" @@ -490,7 +490,7 @@ ); iucv_debug("iparml after b2f0 call:"); - iucv_dumpit(parm, sizeof(iucv_param.param)); + iucv_dumpit(parm, sizeof(iucv_param)); return (unsigned long)*((__u8 *)(parm + 3)); } @@ -2126,7 +2126,7 @@ iucv_sever (int_buf->ippathid, no_listener); iucv_debug("add_pathid failed, rc = %d", - (int)add_pathid_result); + rc); } else { interrupt = h->interrupt_table; if (interrupt->ConnectionPending) { @@ -2150,8 +2150,8 @@ h->pgm_data); else iucv_debug("ConnectionComplete not called"); - } - + } else + iucv_sever(int_buf->ippathid, no_listener); break; case 0x03: /* connection severed */ diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/s390/net/netiucv.c linux-2.5/drivers/s390/net/netiucv.c --- linux-2.5.1/drivers/s390/net/netiucv.c Thu Oct 11 16:43:29 2001 +++ linux-2.5/drivers/s390/net/netiucv.c Thu Dec 27 16:32:31 2001 @@ -1,5 +1,5 @@ /* - * $Id: netiucv.c,v 1.12 2001/09/24 10:38:02 mschwide Exp $ + * $Id: netiucv.c,v 1.16 2001/12/03 14:28:45 felfert Exp $ * * IUCV network driver * @@ -28,7 +28,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * - * RELEASE-TAG: IUCV network driver $Revision: 1.12 $ + * RELEASE-TAG: IUCV network driver $Revision: 1.16 $ * */ @@ -189,7 +189,7 @@ static __inline__ void netiucv_clear_busy(net_device *dev) { clear_bit(0, &(((netiucv_priv *)dev->priv)->tbusy)); - netif_start_queue(dev); + netif_wake_queue(dev); } static __inline__ int netiucv_test_and_set_busy(net_device *dev) @@ -548,7 +548,7 @@ header->next -= NETIUCV_HDRLEN; if (skb_tailroom(pskb) < header->next) { printk(KERN_WARNING - "%s: Ilegal next field in iucv header: %d > %d\n", + "%s: Illegal next field in iucv header: %d > %d\n", dev->name, header->next, skb_tailroom(pskb)); return; } @@ -618,7 +618,8 @@ iucv_connection *conn = ev->conn; iucv_MessageComplete *eib = (iucv_MessageComplete *)ev->data; netiucv_priv *privptr = NULL; - struct sk_buff *skb = (struct sk_buff *)eib->ipmsgtag; + /* Shut up, gcc! skb is always below 2G. */ + struct sk_buff *skb = (struct sk_buff *)(unsigned long)eib->ipmsgtag; __u32 txbytes = 0; __u32 txpackets = 0; __u32 stat_maxcq = 0; @@ -638,10 +639,9 @@ (skb->len - NETIUCV_HDRLEN - NETIUCV_HDRLEN); } dev_kfree_skb_any(skb); - } else { - conn->tx_buff->data = conn->tx_buff->tail = conn->tx_buff->head; - conn->tx_buff->len = 0; } + conn->tx_buff->data = conn->tx_buff->tail = conn->tx_buff->head; + conn->tx_buff->len = 0; spin_lock_irqsave(&conn->collect_lock, saveflags); while ((skb = skb_dequeue(&conn->collect_queue))) { header.next = conn->tx_buff->len + skb->len + NETIUCV_HDRLEN; @@ -768,7 +768,8 @@ case CONN_STATE_TX: printk(KERN_INFO "%s: Remote dropped connection\n", netdev->name); - iucv_unregister_program(conn->handle); + if (conn->handle) + iucv_unregister_program(conn->handle); conn->handle = 0; fsm_newstate(fi, CONN_STATE_STOPPED); fsm_event(privptr->fsm, DEV_EVENT_CONDOWN, netdev); @@ -881,7 +882,8 @@ #endif fsm_newstate(fi, CONN_STATE_STOPPED); netiucv_purge_skb_queue(&conn->collect_queue); - iucv_unregister_program(conn->handle); + if (conn->handle) + iucv_unregister_program(conn->handle); conn->handle = 0; fsm_event(privptr->fsm, DEV_EVENT_CONDOWN, netdev); } @@ -1127,7 +1129,10 @@ fsm_addtimer(&conn->timer, NETIUCV_TIMEOUT_5SEC, CONN_EVENT_TIMER, conn); conn->prof.send_stamp = xtime; - rc = iucv_send(conn->pathid, NULL, 0, 0, (__u32)nskb, 0, + + rc = iucv_send(conn->pathid, NULL, 0, 0, + /* Shut up, gcc! nskb is always below 2G. */ + (__u32)(((unsigned long)nskb)&0xffffffff), 0, nskb->data, nskb->len); conn->prof.doios_single++; conn->prof.txlen += skb->len; @@ -1167,6 +1172,7 @@ static int netiucv_open(net_device *dev) { MOD_INC_USE_COUNT; + SET_DEVICE_START(dev, 1); fsm_event(((netiucv_priv *)dev->priv)->fsm, DEV_EVENT_START, dev); return 0; } @@ -1573,9 +1579,7 @@ if (file->f_pos == 0) { p += sprintf(p, "Device FSM state: %s\n", fsm_getstate_str(privptr->fsm)); - p += sprintf(p, "RX channel FSM state: %s\n", - fsm_getstate_str(privptr->conn->fsm)); - p += sprintf(p, "TX channel FSM state: %s\n", + p += sprintf(p, "Connection FSM state: %s\n", fsm_getstate_str(privptr->conn->fsm)); p += sprintf(p, "Max. TX buffer used: %ld\n", privptr->conn->prof.maxmulti); @@ -1970,7 +1974,6 @@ dev->addr_len = 0; dev->type = ARPHRD_SLIP; dev->tx_queue_len = NETIUCV_QUEUELEN_DEFAULT; - SET_DEVICE_START(dev, 1); dev_init_buffers(dev); dev->flags = IFF_POINTOPOINT | IFF_NOARP; return dev; @@ -2002,7 +2005,7 @@ static void netiucv_banner(void) { - char vbuf[] = "$Revision: 1.12 $"; + char vbuf[] = "$Revision: 1.16 $"; char *version = vbuf; if ((version = strchr(version, ':'))) { @@ -2118,5 +2121,7 @@ #ifdef MODULE module_init(netiucv_init); module_exit(netiucv_exit); +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,12)) MODULE_LICENSE("GPL"); +#endif #endif diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/s390/s390io.c linux-2.5/drivers/s390/s390io.c --- linux-2.5.1/drivers/s390/s390io.c Thu Nov 22 18:41:14 2001 +++ linux-2.5/drivers/s390/s390io.c Thu Dec 27 16:32:31 2001 @@ -6,6 +6,7 @@ * Copyright (C) 1999, 2000 IBM Deutschland Entwicklung GmbH, * IBM Corporation * Author(s): Ingo Adlung (adlung@de.ibm.com) + * Cornelia Huck (cohuck@de.ibm.com) * ChangeLog: 01/07/2001 Blacklist cleanup (djbarrow@de.ibm.com,barrow_dj@yahoo.com) * 01/04/2001 Holger Smolinski (smolinsk@de.ibm.com) * Fixed lost interrupts and do_adapter_IO @@ -24,6 +25,9 @@ * xx/xx/xxxx some bugfixes & cleanups * 08/02/2001 Cornelia Huck not already known devices can be blacklisted * by piping to /proc/cio_ignore + * 09/xx/2001 couple more fixes + * 10/29/2001 Cornelia Huck Blacklisting reworked again + * 10/29/2001 Cornelia Huck improved utilization of debug feature */ #include <linux/module.h> @@ -108,7 +112,9 @@ static void s390_process_subchannels( void); static void s390_device_recognition_all( void); static void s390_device_recognition_irq( int irq); +#ifdef CONFIG_PROC_FS static void s390_redo_validation(void); +#endif static int s390_validate_subchannel( int irq, int enable); static int s390_SenseID( int irq, senseid_t *sid, __u8 lpm); static int s390_SetPGID( int irq, __u8 lpm, pgid_t *pgid); @@ -117,7 +123,9 @@ static int enable_subchannel( unsigned int irq); static int disable_subchannel( unsigned int irq); +#ifdef CONFIG_PROC_FS static int chan_proc_init( void ); +#endif static inline void do_adapter_IO( __u32 intparm ); @@ -131,108 +139,68 @@ asmlinkage void do_IRQ( struct pt_regs regs ); +#ifdef CONFIG_PROC_FS #define MAX_CIO_PROCFS_ENTRIES 0x300 /* magic number; we want to have some room to spare */ int cio_procfs_device_create(int devno); int cio_procfs_device_remove(int devno); int cio_procfs_device_purge(void); +#endif int cio_notoper_msg = 1; +#ifdef CONFIG_PROC_FS int cio_proc_devinfo = 0; /* switch off the /proc/deviceinfo/ stuff by default until problems are dealt with */ +#endif unsigned long s390_irq_count[NR_CPUS]; /* trace how many irqs have occured per cpu... */ int cio_count_irqs = 1; /* toggle use here... */ /* * "Blacklisting" of certain devices: - * Device numbers given in the commandline as blacklist=... won't be known to Linux + * Device numbers given in the commandline as cio_ignore=... won't be known to Linux * These can be single devices or ranges of devices * - * Introduced by Cornelia Huck <cohuck@de.ibm.com> - * Most of it shamelessly taken from dasd.c + * 10/23/01 reworked to get rid of lists */ -typedef struct dev_blacklist_range_t { - struct dev_blacklist_range_t *next; /* next range in list */ - unsigned int from; /* beginning of range */ - unsigned int to; /* end of range */ - int kmalloced; +static unsigned long bl_dev[2048] = {0,}; -} dev_blacklist_range_t; - -static dev_blacklist_range_t *dev_blacklist_range_head = NULL; /* Anchor for list of ranges */ -static dev_blacklist_range_t *dev_blacklist_unused_head = NULL; - static spinlock_t blacklist_lock = SPIN_LOCK_UNLOCKED; -static int nr_blacklisted_ranges = 0; - -/* Handling of the blacklist ranges */ - -static inline void blacklist_range_destroy( dev_blacklist_range_t *range,int locked ) -{ - long flags; - - if(!locked) - spin_lock_irqsave( &blacklist_lock, flags ); - if(!remove_from_list((list **)&dev_blacklist_range_head,(list *)range)) - BUG(); - nr_blacklisted_ranges--; - if(range->kmalloced) - kfree(range); - else - add_to_list((list **)&dev_blacklist_unused_head,(list *)range); - if(!locked) - spin_unlock_irqrestore( &blacklist_lock, flags ); -} - - +static int highest_ignored = 0; +static int nr_ignored = 0; /* * Function: blacklist_range_add - * Creates a range from the specified arguments and appends it to the list of - * blacklisted devices + * Blacklist the devices from-to */ -static inline dev_blacklist_range_t *blacklist_range_add( int from, int to,int locked) +static inline void blacklist_range_add( int from, int to,int locked) { - dev_blacklist_range_t *range = NULL; unsigned long flags; + int i; if (to && (from>to)) { printk(KERN_WARNING "Invalid blacklist range %x to %x, skipping\n", from, to); - return NULL; + return; } if(!locked) spin_lock_irqsave( &blacklist_lock, flags ); - if(dev_blacklist_unused_head) - range=(dev_blacklist_range_t *) - remove_listhead((list **)&dev_blacklist_unused_head); - else if (init_IRQ_complete) { - if((range = ( dev_blacklist_range_t *) - kmalloc( sizeof( dev_blacklist_range_t ), GFP_KERNEL))) - range->kmalloced=1; - } else { - if((range = ( dev_blacklist_range_t *) - alloc_bootmem( sizeof( dev_blacklist_range_t ) ))) - range->kmalloced=0; - } - if (range) - { - add_to_list((list **)&dev_blacklist_range_head,(list *)range); - range->from = from; - if (to == 0) { /* only a single device is given */ - range->to = from; - } else { - range->to = to; - } - nr_blacklisted_ranges++; + + if (!to) + to = from; + for (i=from;i<=to;i++) { + set_bit(i,&bl_dev); + nr_ignored++; } + + if (to>=highest_ignored) + highest_ignored = to; + if(!locked) spin_unlock_irqrestore( &blacklist_lock, flags ); - return range; } /* @@ -242,14 +210,19 @@ static inline void blacklist_range_remove( int from, int to ) { - dev_blacklist_range_t *temp; long flags; + int i; spin_lock_irqsave( &blacklist_lock, flags ); - for ( temp = dev_blacklist_range_head; - (temp->from != from) && (temp->to != to); - temp = temp->next ); - blacklist_range_destroy( temp,1 ); + + for (i=from;i<=to;i++) { + clear_bit(i,&bl_dev); + nr_ignored--; + } + + if (to == highest_ignored) + for (highest_ignored=from;(highest_ignored>0) && (!test_bit(highest_ignored,&bl_dev));highest_ignored--); + spin_unlock_irqrestore( &blacklist_lock, flags ); } @@ -257,12 +230,12 @@ /* * Variable to hold the blacklisted devices given by the parameter line - * blacklist=... + * cio_ignore=... */ char *blacklist[256] = {NULL, }; /* - * Get the blacklist=... items from the parameter line + * Get the cio_ignore=... items from the parameter line */ static void blacklist_split_parm_string (char *str) @@ -282,7 +255,7 @@ } blacklist[count] = alloc_bootmem (len * sizeof (char) ); if (blacklist == NULL) { - printk (KERN_WARNING "can't store blacklist= parameter no %d\n", count + 1); + printk (KERN_WARNING "can't store cio_ignore= parameter no %d\n", count + 1); break; } memset (blacklist[count], 0, len * sizeof (char)); @@ -319,7 +292,7 @@ /* * Function: blacklist_parse - * Parse the parameters given to blacklist=... + * Parse the parameters given to cio_ignore=... * Add the blacklisted devices to the blacklist chain */ @@ -338,11 +311,9 @@ temp++; to = blacklist_strtoul( temp, &temp ); } - if (!blacklist_range_add( from, to,0 )) { - printk( KERN_WARNING "Blacklisting range from %X to %X failed!\n", from, to); - } + blacklist_range_add( from, to, 0 ); #ifdef CONFIG_DEBUG_IO - printk( "Blacklisted range from %X to %X\n", from, to ); + printk( KERN_INFO "Blacklisted range from %X to %X\n", from, to ); #endif str++; } @@ -356,7 +327,7 @@ void __init blacklist_init( void ) { #ifdef CONFIG_DEBUG_IO - printk( "Reading blacklist...\n"); + printk( KERN_DEBUG "Reading blacklist...\n"); #endif if (cio_debug_initialized) debug_sprintf_event(cio_debug_msg_id, 6, @@ -383,7 +354,7 @@ { int dummy; #ifdef CONFIG_DEBUG_IO - printk( "Reading blacklist parameters...\n" ); + printk( KERN_DEBUG "Reading blacklist parameters...\n" ); #endif if (cio_debug_initialized) debug_sprintf_event(cio_debug_msg_id, 6, @@ -406,24 +377,14 @@ static inline int is_blacklisted( int devno ) { - dev_blacklist_range_t *temp; long flags; int retval=0; - if (dev_blacklist_range_head == NULL) { - /* no blacklist */ - return 0; - } - spin_lock_irqsave( &blacklist_lock, flags ); - temp = dev_blacklist_range_head; - while (temp) { - if ((temp->from <= devno) && (temp->to >= devno)) { - retval=1; /* Deviceno is blacklisted */ - break; - } - temp = temp->next; - } + + if (test_bit(devno,&bl_dev)) + retval=1; + spin_unlock_irqrestore( &blacklist_lock, flags ); return retval; } @@ -435,17 +396,20 @@ void blacklist_free_all_ranges(void) { - dev_blacklist_range_t *tmp = dev_blacklist_range_head; unsigned long flags; + int i; spin_lock_irqsave( &blacklist_lock, flags ); - while (tmp) { - blacklist_range_destroy(tmp,1); - tmp = dev_blacklist_range_head; - } + + for (i=0;i<=highest_ignored;i++) + clear_bit(i,&bl_dev); + highest_ignored = 0; + nr_ignored = 0; + spin_unlock_irqrestore( &blacklist_lock, flags ); } +#ifdef CONFIG_PROC_FS /* * Function: blacklist_parse_proc_parameters * parse the stuff which is piped to /proc/cio_ignore @@ -459,8 +423,6 @@ char *param; int from = 0; int to = 0; - int changed = 0; - dev_blacklist_range_t *range, *temp; long flags; int err = 0; @@ -492,33 +454,9 @@ } else { to = from; } - spin_lock_irqsave( &blacklist_lock, flags ); - range = dev_blacklist_range_head; - while (range != NULL) { - temp = range->next; - if ((from <= range->from) && (to >= range->to)) { - blacklist_range_destroy(range,1); - changed = 1; - } else if ((from <= range->from) && (to>=range->from) && (to < range->to)) { - blacklist_range_add(to+1, range->to,1); - blacklist_range_destroy(range,1); - changed = 1; - } else if ((from > range->from) && (from<=range->to) && (to >= range->to)) { - blacklist_range_add(range->from, from-1,1); - blacklist_range_destroy(range,1); - changed = 1; - } else if ((from > range->from) && (to < range->to)) { - blacklist_range_add(range->from, from-1,1); - blacklist_range_add(to+1, range->to,1); - blacklist_range_destroy(range,1); - changed = 1; - } - range = temp; - } - spin_unlock_irqrestore( &blacklist_lock, flags ); + blacklist_range_remove( from, to ); kfree(param); } - if (changed) s390_redo_validation(); } } else if (strstr(tmp, "add ")) { @@ -567,12 +505,6 @@ } } - /* - * Note: We allow for overlapping ranges here, - * since the user might specify overlapping ranges - * and we walk through all ranges when freeing anyway. - */ - if (!err) blacklist_range_add(from, to, 1); @@ -581,11 +513,11 @@ } } else { - printk("cio_ignore: Parse error; try using 'free all|<devno-range>,<devno-range>,...'\n"); - printk("or 'add <devno-range>,<devno-range>,...'\n"); + printk( KERN_WARNING "cio_ignore: Parse error; try using 'free all|<devno-range>,<devno-range>,...'\n"); + printk( KERN_WARNING "or 'add <devno-range>,<devno-range>,...'\n"); } } - +#endif /* End of blacklist handling */ @@ -642,7 +574,7 @@ } else { - printk( "cio_setup : invalid cio_msg parameter '%s'", parm); + printk( KERN_ERR "cio_setup : invalid cio_msg parameter '%s'", parm); } /* endif */ @@ -658,7 +590,7 @@ } else if (!strcmp(parm, "no")) { cio_notoper_msg = 0; } else { - printk("cio_notoper_setup: invalid cio_notoper_msg parameter '%s'", parm); + printk( KERN_ERR "cio_notoper_setup: invalid cio_notoper_msg parameter '%s'", parm); } return 1; @@ -666,6 +598,7 @@ __setup("cio_notoper_msg=", cio_notoper_setup); +#ifdef CONFIG_PROC_FS static int __init cio_proc_devinfo_setup(char *parm) { if (!strcmp(parm, "yes")) { @@ -673,13 +606,14 @@ } else if (!strcmp(parm, "no")) { cio_proc_devinfo = 0; } else { - printk("cio_proc_devinfo_setup: invalid parameter '%s'\n",parm); + printk( KERN_ERR "cio_proc_devinfo_setup: invalid parameter '%s'\n",parm); } return 1; } __setup("cio_proc_devinfo=", cio_proc_devinfo_setup); +#endif /* * register for adapter interrupts @@ -695,6 +629,7 @@ int s390_register_adapter_interrupt( adapter_int_handler_t handler ) { int ret = 0; + char dbf_txt[15]; if (cio_debug_initialized) debug_text_event(cio_debug_trace_id, 4, "rgaint"); @@ -710,6 +645,11 @@ spin_unlock( &adapter_lock ); + if (cio_debug_initialized) { + sprintf(dbf_txt,"ret:%d",ret); + debug_text_event(cio_debug_trace_id, 4, dbf_txt); + } + return( ret); } @@ -717,6 +657,7 @@ int s390_unregister_adapter_interrupt( adapter_int_handler_t handler ) { int ret = 0; + char dbf_txt[15]; if (cio_debug_initialized) debug_text_event(cio_debug_trace_id, 4, "urgaint"); @@ -732,6 +673,11 @@ spin_unlock( &adapter_lock ); + if (cio_debug_initialized) { + sprintf(dbf_txt,"ret:%d",ret); + debug_text_event(cio_debug_trace_id, 4, dbf_txt); + } + return( ret); } @@ -777,8 +723,7 @@ if (cio_debug_initialized) { - debug_text_event(cio_debug_trace_id, 4, "reqsp"); - sprintf(dbf_txt, "%x", irq); + sprintf(dbf_txt, "reqsp%x", irq); debug_text_event(cio_debug_trace_id, 4, dbf_txt); } @@ -835,6 +780,9 @@ ioinfo[irq]->nopfunc = not_oper_handler; } + if (cio_debug_initialized) + debug_int_event(cio_debug_trace_id, 4, retval); + return retval; } @@ -868,18 +816,13 @@ unsigned long flags; int ret; - unsigned int count = 0; char dbf_txt[15]; if ( irq >= __MAX_SUBCHANNELS || ioinfo[irq] == INVALID_STORAGE_AREA ) - { return; - } /* endif */ - if (cio_debug_initialized) { - debug_text_event(cio_debug_trace_id, 2, "free"); - sprintf(dbf_txt, "%x", irq); + sprintf(dbf_txt, "free%x", irq); debug_text_event(cio_debug_trace_id, 2, dbf_txt); } @@ -887,10 +830,7 @@ #ifdef CONFIG_KERNEL_DEBUG if ( irq != cons_dev ) - { - printk("Trying to free IRQ%d\n",irq); - - } /* endif */ + printk( KERN_DEBUG "Trying to free IRQ%d\n",irq); #endif if (cio_debug_initialized) debug_sprintf_event(cio_debug_msg_id, 2, "Trying to free IRQ %d\n", irq); @@ -899,10 +839,8 @@ * disable the device and reset all IRQ info if * the IRQ is actually owned by the handler ... */ - if ( ioinfo[irq]->ui.flags.ready ) - { - if ( dev_id == ioinfo[irq]->irq_desc.dev_id ) - { + if ( ioinfo[irq]->ui.flags.ready ) { + if ( dev_id == ioinfo[irq]->irq_desc.dev_id ) { /* start deregister */ ioinfo[irq]->ui.flags.unready = 1; @@ -915,15 +853,9 @@ 0xC8C1D3E3, DOIO_WAIT_FOR_INTERRUPT ); - do - { ret = disable_subchannel( irq); - count++; - - if ( ret == -EBUSY ) - { - int iret; + if ( ret == -EBUSY ) { /* * kill it ! @@ -932,45 +864,31 @@ * an async request, twice halt, then * clear. */ - if ( count < 2 ) - { - iret = halt_IO( irq, + ret = halt_IO( irq, 0xC8C1D3E3, DOIO_WAIT_FOR_INTERRUPT ); - if ( iret == -EBUSY ) - { + if ( ret == -EBUSY ) { halt_IO( irq, 0xC8C1D3E3, 0); s390irq_spin_unlock_irqrestore( irq, flags); udelay( 200000 ); /* 200 ms */ s390irq_spin_lock_irqsave( irq, flags); } /* endif */ - } - else - { - iret = clear_IO( irq, - 0x40C3D3D9, - DOIO_WAIT_FOR_INTERRUPT ); + + ret = disable_subchannel(irq); + + if (ret == -EBUSY) { - if ( iret == -EBUSY ) - { - clear_IO( irq, 0xC8C1D3E3, 0); + clear_IO( irq, 0x40C3D3D9,0 ); s390irq_spin_unlock_irqrestore( irq, flags); udelay( 1000000 ); /* 1000 ms */ s390irq_spin_lock_irqsave( irq, flags); - } /* endif */ - - } /* endif */ - - if ( count == 2 ) - { /* give it a very last try ... */ disable_subchannel( irq); - if ( ioinfo[irq]->ui.flags.busy ) - { + if ( ioinfo[irq]->ui.flags.busy ) { printk( KERN_CRIT"free_irq(%04X) " "- device %04X busy, retry " "count exceeded\n", @@ -983,39 +901,30 @@ } /* endif */ - break; /* sigh, let's give up ... */ - } /* endif */ } /* endif */ - } while ( ret == -EBUSY ); - ioinfo[irq]->ui.flags.ready = 0; ioinfo[irq]->ui.flags.unready = 0; /* deregister ended */ ioinfo[irq]->nopfunc = NULL; s390irq_spin_unlock_irqrestore( irq, flags); - } - else - { + } else { s390irq_spin_unlock_irqrestore( irq, flags); - printk( "free_irq(%04X) : error, " + printk( KERN_ERR "free_irq(%04X) : error, " "dev_id does not match !\n", irq); if (cio_debug_initialized) debug_sprintf_event(cio_debug_msg_id, 0, "free_irq(%04X) : error, dev_id does not match !\n", irq); } /* endif */ - - } - else - { + } else { s390irq_spin_unlock_irqrestore( irq, flags); - printk( "free_irq(%04X) : error, " + printk( KERN_ERR "free_irq(%04X) : error, " "no action block ... !\n", irq); if (cio_debug_initialized) debug_sprintf_event(cio_debug_msg_id, 0, @@ -1040,8 +949,7 @@ return -ENODEV; if (cio_debug_initialized) { - debug_text_event(cio_debug_trace_id, 4, "disirq"); - sprintf(dbf_txt, "%x", irq); + sprintf(dbf_txt, "disirq%x", irq); debug_text_event(cio_debug_trace_id, 4, dbf_txt); } @@ -1051,6 +959,9 @@ synchronize_irq(); + if (cio_debug_initialized) + debug_int_event(cio_debug_trace_id, 4, ret); + return( ret); } @@ -1066,8 +977,7 @@ return -ENODEV; if (cio_debug_initialized) { - debug_text_event(cio_debug_trace_id, 4, "enirq"); - sprintf(dbf_txt, "%x", irq); + sprintf(dbf_txt, "enirq%x", irq); debug_text_event(cio_debug_trace_id, 4, dbf_txt); } @@ -1075,6 +985,9 @@ ret = enable_subchannel(irq); s390irq_spin_unlock_irqrestore(irq, flags); + if (cio_debug_initialized) + debug_int_event(cio_debug_trace_id, 4, ret); + return(ret); } @@ -1091,8 +1004,7 @@ SANITY_CHECK(irq); if (cio_debug_initialized) { - debug_text_event(cio_debug_trace_id, 2, "ensch"); - sprintf(dbf_txt, "%x", irq); + sprintf(dbf_txt, "ensch%x", irq); debug_text_event(cio_debug_trace_id, 2, dbf_txt); } @@ -1168,6 +1080,11 @@ } /* endif */ + if (cio_debug_initialized) { + sprintf(dbf_txt,"ret:%d",ret); + debug_text_event(cio_debug_trace_id, 2, dbf_txt); + } + return( ret ); } @@ -1195,8 +1112,7 @@ else { if (cio_debug_initialized) { - debug_text_event(cio_debug_trace_id, 2, "dissch"); - sprintf(dbf_txt, "%x", irq); + sprintf(dbf_txt, "dissch%x", irq); debug_text_event(cio_debug_trace_id, 2, dbf_txt); } @@ -1274,6 +1190,11 @@ } /* endif */ + if (cio_debug_initialized) { + sprintf(dbf_txt, "ret:%d",ret); + debug_text_event(cio_debug_trace_id, 2, dbf_txt); + } + return( ret); } @@ -1364,8 +1285,7 @@ } /* endif */ if (cio_debug_initialized) { - debug_text_event(cio_debug_trace_id, 4, "stIO"); - sprintf(dbf_txt, "%x", irq); + sprintf(dbf_txt, "stIO%x", irq); debug_text_event(cio_debug_trace_id, 4, dbf_txt); } @@ -1427,6 +1347,11 @@ */ ccode = ssch( irq, &(ioinfo[irq]->orb) ); + if (cio_debug_initialized) { + sprintf(dbf_txt, "ccode:%d", ccode); + debug_text_event(cio_debug_trace_id, 4, dbf_txt); + } + switch ( ccode ) { case 0: @@ -1849,8 +1774,7 @@ } /* endif */ if (cio_debug_initialized) { - debug_text_event(cio_debug_trace_id, 4, "doIO"); - sprintf(dbf_txt, "%x", irq); + sprintf(dbf_txt, "doIO%x", irq); debug_text_event(cio_debug_trace_id, 4, dbf_txt); } @@ -1908,8 +1832,7 @@ SANITY_CHECK(irq); if (cio_debug_initialized) { - debug_text_event(cio_debug_trace_id, 4, "resIO"); - sprintf(dbf_txt, "%x", irq); + sprintf(dbf_txt, "resIO%x", irq); debug_text_event(cio_debug_trace_id, 4, dbf_txt); } @@ -1922,6 +1845,11 @@ ccode = rsch( irq); + if (cio_debug_initialized) { + sprintf(dbf_txt, "ccode:%d",ccode); + debug_text_event(cio_debug_trace_id, 4, dbf_txt); + } + switch (ccode) { case 0 : break; @@ -1988,21 +1916,10 @@ { ret = 0; } -#if 0 - /* - * We don't allow for halt_io with a sync do_IO() requests pending. - */ - else if ( ioinfo[irq]->ui.flags.syncio - && (flag & DOIO_WAIT_FOR_INTERRUPT)) - { - ret = -EBUSY; - } -#endif else { if (cio_debug_initialized) { - debug_text_event(cio_debug_trace_id, 2, "haltIO"); - sprintf(dbf_txt, "%x", irq); + sprintf(dbf_txt, "haltIO%x", irq); debug_text_event(cio_debug_trace_id, 2, dbf_txt); } /* @@ -2028,6 +1945,11 @@ */ ccode = hsch( irq ); + if (cio_debug_initialized) { + sprintf(dbf_txt, "ccode:%d",ccode); + debug_text_event(cio_debug_trace_id, 2, dbf_txt); + } + switch ( ccode ) { case 0: @@ -2253,22 +2175,10 @@ { ret = 0; } -#if 0 - /* - * We don't allow for clear_io with a sync do_IO() requests pending. - * Concurrent I/O is possible in SMP environments only, but the - * sync. I/O request can be gated to one CPU at a time only. - */ - else if ( ioinfo[irq]->ui.flags.syncio ) - { - ret = -EBUSY; - } -#endif else { if (cio_debug_initialized) { - debug_text_event(cio_debug_trace_id, 2, "clearIO"); - sprintf(dbf_txt, "%x", irq); + sprintf(dbf_txt, "clearIO%x", irq); debug_text_event(cio_debug_trace_id, 2, dbf_txt); } /* @@ -2294,6 +2204,11 @@ */ ccode = csch( irq ); + if (cio_debug_initialized) { + sprintf(dbf_txt, "ccode:%d",ccode); + debug_text_event(cio_debug_trace_id, 2, dbf_txt); + } + switch ( ccode ) { case 0: @@ -2548,10 +2463,8 @@ } - if (cio_debug_initialized) { - debug_text_event(cio_debug_trace_id, 3, "procIRQ"); - sprintf(dbf_txt, "%x", irq); + sprintf(dbf_txt, "procIRQ%x", irq); debug_text_event(cio_debug_trace_id, 3, dbf_txt); } @@ -2612,6 +2525,11 @@ */ ccode = tsch( irq, &(dp->ii.irb) ); + if (cio_debug_initialized) { + sprintf(dbf_txt, "ccode:%d", ccode); + debug_text_event(cio_debug_trace_id, 3, dbf_txt); + } + // // We must only accumulate the status if the device is busy already // @@ -2675,7 +2593,7 @@ #ifdef CONFIG_DEBUG_IO if ( irq != cons_dev ) - printk( "s390_process_IRQ( %04X ) : " + printk( KERN_DEBUG "s390_process_IRQ( %04X ) : " "residual count from irb after tsch() %d\n", irq, dp->rescnt ); #endif @@ -2698,7 +2616,7 @@ | SCHN_STAT_INTF_CTRL_CHK ))) { if (irq != cons_dev) - printk( "Channel-Check or Interface-Control-Check " + printk( KERN_WARNING "Channel-Check or Interface-Control-Check " "received\n" " ... device %04X on subchannel %04X, dev_stat " ": %02X sch_stat : %02X\n", @@ -2748,7 +2666,7 @@ #ifdef CONFIG_DEBUG_IO if ( irq != cons_dev ) - printk( "s390_process_IRQ( %04X ) : " + printk( KERN_DEBUG "s390_process_IRQ( %04X ) : " "concurrent sense bytes avail %d\n", irq, dp->scnt ); #endif @@ -2800,10 +2718,9 @@ ioinfo[irq]->stctl |= stctl; - ending_status = ( stctl & SCSW_STCTL_SEC_STATUS ) - || ( stctl == (SCSW_STCTL_ALERT_STATUS | SCSW_STCTL_STATUS_PEND) ) - || ( (fctl == SCSW_FCTL_HALT_FUNC) && (stctl == SCSW_STCTL_STATUS_PEND) ) - || ( (fctl == SCSW_FCTL_CLEAR_FUNC) && (stctl == SCSW_STCTL_STATUS_PEND) ); + ending_status = ( stctl & SCSW_STCTL_SEC_STATUS ) + || ( stctl == (SCSW_STCTL_ALERT_STATUS | SCSW_STCTL_STATUS_PEND) ) + || ( stctl == SCSW_STCTL_STATUS_PEND); /* * Check for unsolicited interrupts - for debug purposes only @@ -2821,7 +2738,7 @@ { #ifdef CONFIG_DEBUG_IO if (irq != cons_dev) - printk( "Unsolicited interrupt received for device %04X on subchannel %04X\n" + printk( KERN_INFO "Unsolicited interrupt received for device %04X on subchannel %04X\n" " ... device status : %02X subchannel status : %02X\n", dp->devno, irq, @@ -2998,7 +2915,7 @@ #ifdef CONFIG_DEBUG_IO if ( irq != cons_dev ) - printk( "s390_process_IRQ( %04X ) : " + printk( KERN_DEBUG "s390_process_IRQ( %04X ) : " "BASIC SENSE bytes avail %d\n", irq, sense_count ); #endif @@ -3274,8 +3191,7 @@ else { if (cio_debug_initialized) { - debug_text_event(cio_debug_trace_id, 4, "scons"); - sprintf(dbf_txt, "%x", irq); + sprintf(dbf_txt, "scons%x", irq); debug_text_event(cio_debug_trace_id, 4, dbf_txt); } @@ -3336,8 +3252,7 @@ else { if (cio_debug_initialized) { - debug_text_event(cio_debug_trace_id, 4, "rcons"); - sprintf(dbf_txt, "%x", irq); + sprintf(dbf_txt, "rcons%x", irq); debug_text_event(cio_debug_trace_id, 4, dbf_txt); } @@ -3393,8 +3308,7 @@ { if (cio_debug_initialized) { - debug_text_event(cio_debug_trace_id, 4, "wcons"); - sprintf(dbf_txt, "%x", irq); + sprintf(dbf_txt, "wcons%x", irq); debug_text_event(cio_debug_trace_id, 4, dbf_txt); } @@ -3456,8 +3370,7 @@ char dbf_txt[15]; if (cio_debug_initialized) { - debug_text_event(cio_debug_trace_id, 4, "enisc"); - sprintf(dbf_txt, "%x", irq); + sprintf(dbf_txt, "enisc%x", irq); debug_text_event(cio_debug_trace_id, 4, dbf_txt); } @@ -3573,8 +3486,7 @@ char dbf_txt[15]; if (cio_debug_initialized) { - debug_text_event(cio_debug_trace_id, 4, "disisc"); - sprintf(dbf_txt, "%x", irq); + sprintf(dbf_txt, "disisc%x", irq); debug_text_event(cio_debug_trace_id, 4, dbf_txt); } @@ -3973,7 +3885,7 @@ if ( error ) { - printk( "DIAG X'210' for " + printk( KERN_ERR "DIAG X'210' for " "device %04X returned " "(cc = %d): vdev class : %02X, " "vdev type : %04X \n ... rdev class : %02X, rdev type : %04X, rdev model: %02X\n", @@ -4054,8 +3966,7 @@ } /* endif */ if (cio_debug_initialized) { - debug_text_event(cio_debug_trace_id, 4, "rddevch"); - sprintf(dbf_txt, "%x", irq); + sprintf(dbf_txt, "rddevch%x", irq); debug_text_event(cio_debug_trace_id, 4, dbf_txt); } @@ -4194,8 +4105,7 @@ } /* endif */ if (cio_debug_initialized) { - debug_text_event(cio_debug_trace_id, 4, "rdconf"); - sprintf(dbf_txt, "%x", irq); + sprintf(dbf_txt, "rdconf%x", irq); debug_text_event(cio_debug_trace_id, 4, dbf_txt); } @@ -4637,8 +4547,7 @@ char dbf_txt[15]; if (cio_debug_initialized) { - debug_text_event(cio_debug_trace_id, 4, "devrec"); - sprintf(dbf_txt, "%x", irq); + sprintf(dbf_txt, "devrec%x", irq); debug_text_event(cio_debug_trace_id, 4, dbf_txt); } @@ -4779,10 +4688,12 @@ } } +#ifdef CONFIG_PROC_FS if (cio_proc_devinfo) if (irq < MAX_CIO_PROCFS_ENTRIES) { cio_procfs_device_create(ioinfo[irq]->devno); } +#endif } } irq++; @@ -4811,7 +4722,7 @@ highest_subchannel = (--irq); - printk( "Highest subchannel number detected (hex) : %04X\n", + printk( KERN_INFO "Highest subchannel number detected (hex) : %04X\n", highest_subchannel); if (cio_debug_initialized) debug_sprintf_event(cio_debug_msg_id, 0, @@ -4837,8 +4748,7 @@ char dbf_txt[15]; if (cio_debug_initialized) { - debug_text_event(cio_debug_trace_id, 4, "valsch"); - sprintf(dbf_txt, "%x", irq); + sprintf(dbf_txt, "valsch%x", irq); debug_text_event(cio_debug_trace_id, 4, dbf_txt); } @@ -4876,7 +4786,7 @@ */ if ( p_schib->pmcw.st ) { - printk( "Subchannel %04X reports " + printk( KERN_INFO "Subchannel %04X reports " "non-I/O subchannel type %04X\n", irq, p_schib->pmcw.st); @@ -4898,7 +4808,7 @@ * there is no device and return ENODEV. */ #ifdef CONFIG_DEBUG_IO - printk( "Blacklisted device detected at devno %04X\n", p_schib->pmcw.dev ); + printk( KERN_DEBUG "Blacklisted device detected at devno %04X\n", p_schib->pmcw.dev ); #endif if (cio_debug_initialized) debug_sprintf_event(cio_debug_msg_id, 0, @@ -5109,7 +5019,7 @@ if ( ccode2 != 0 ) { - printk( " ... msch() (2) failed with CC = %X\n", + printk( KERN_ERR " ... msch() (2) failed with CC = %X\n", ccode2 ); if (cio_debug_initialized) debug_sprintf_event(cio_debug_msg_id, 0, @@ -5128,7 +5038,7 @@ } else { - printk( " ... msch() (1) failed with CC = %X\n", + printk( KERN_ERR " ... msch() (1) failed with CC = %X\n", ccode2); if (cio_debug_initialized) debug_sprintf_event(cio_debug_msg_id, 0, @@ -5148,7 +5058,7 @@ if ( (ccode2 != 0) && (ccode2 != 3) && (!retry) ) { - printk( " ... msch() retry count for " + printk( KERN_ERR " ... msch() retry count for " "subchannel %04X exceeded, CC = %d\n", irq, ccode2); @@ -5226,8 +5136,7 @@ } /* endif */ if (cio_debug_initialized) { - debug_text_event(cio_debug_trace_id, 4, "snsID"); - sprintf(dbf_txt, "%x", irq); + sprintf(dbf_txt, "snsID%x", irq); debug_text_event(cio_debug_trace_id, 4, dbf_txt); } @@ -5344,7 +5253,7 @@ if ( pdevstat->flag & DEVSTAT_STATUS_PENDING ) { #ifdef CONFIG_DEBUG_IO - printk( "SenseID : device %04X on " + printk( KERN_DEBUG "SenseID : device %04X on " "Subchannel %04X " "reports pending status, " "retry : %d\n", @@ -5363,7 +5272,7 @@ retry); } /* endif */ - if ( pdevstat->flag & DEVSTAT_FLAG_SENSE_AVAIL ) + else if ( pdevstat->flag & DEVSTAT_FLAG_SENSE_AVAIL ) { /* * if the device doesn't support the SenseID @@ -5373,7 +5282,7 @@ & (SNS0_CMD_REJECT | SNS0_INTERVENTION_REQ) ) { #ifdef CONFIG_DEBUG_IO - printk( "SenseID : device %04X on " + printk( KERN_ERR "SenseID : device %04X on " "Subchannel %04X " "reports cmd reject or " "intervention required\n", @@ -5394,7 +5303,7 @@ else { #ifdef CONFIG_DEBUG_IO - printk( "SenseID : UC on " + printk( KERN_WARNING "SenseID : UC on " "dev %04X, " "retry %d, " "lpum %02X, " @@ -5449,7 +5358,7 @@ || ( irq_ret == -ENODEV ) ) { #ifdef CONFIG_DEBUG_IO - printk( "SenseID : path %02X for " + printk( KERN_ERR "SenseID : path %02X for " "device %04X on " "subchannel %04X " "is 'not operational'\n", @@ -5479,7 +5388,7 @@ DEVSTAT_STATUS_PENDING ) ) { #ifdef CONFIG_DEBUG_IO - printk( "SenseID : start_IO() for " + printk( KERN_INFO "SenseID : start_IO() for " "device %04X on " "subchannel %04X " "returns %d, retry %d, " @@ -5628,7 +5537,7 @@ * consider the device "not operational". */ #ifdef CONFIG_DEBUG_IO - printk( "SenseID : unknown device %04X on subchannel %04X\n", + printk( KERN_WARNING "SenseID : unknown device %04X on subchannel %04X\n", ioinfo[irq]->schib.pmcw.dev, irq); #endif @@ -5732,8 +5641,7 @@ char dbf_txt[15]; if (cio_debug_initialized) { - debug_text_event(cio_debug_trace_id, 4, "dpver"); - sprintf(dbf_txt, "%x", irq); + sprintf(dbf_txt, "dpver%x", irq); debug_text_event(cio_debug_trace_id, 4, dbf_txt); } @@ -5842,7 +5750,7 @@ ioinfo[irq]->ui.flags.pgid_supp = 0; #ifdef CONFIG_DEBUG_IO - printk( "PathVerification(%04X) " + printk( KERN_WARNING "PathVerification(%04X) " "- Device %04X doesn't " " support path grouping\n", irq, @@ -5861,7 +5769,7 @@ else if ( ret == -EIO ) { #ifdef CONFIG_DEBUG_IO - printk("PathVerification(%04X) - I/O error " + printk( KERN_ERR "PathVerification(%04X) - I/O error " "on device %04X\n", irq, ioinfo[irq]->schib.pmcw.dev); #endif @@ -5876,7 +5784,7 @@ } else { #ifdef CONFIG_DEBUG_IO - printk( "PathVerification(%04X) " + printk( KERN_ERR "PathVerification(%04X) " "- Unexpected error on device %04X\n", irq, ioinfo[irq]->schib.pmcw.dev); @@ -5914,6 +5822,7 @@ devstat_t devstat; /* required by request_irq() */ devstat_t *pdevstat = &devstat; unsigned long flags; + char dbf_txt[15]; int irq_ret = 0; /* return code */ @@ -5929,6 +5838,11 @@ } /* endif */ + if (cio_debug_initialized) { + sprintf(dbf_txt,"SPID%x",irq); + debug_text_event(cio_debug_trace_id, 4, dbf_txt); + } + if ( !ioinfo[irq]->ui.flags.ready ) { /* @@ -5966,7 +5880,7 @@ } /* endif */ - spid_ccw[0].cmd_code = 0x5B; /* suspend multipath reconnect */ + spid_ccw[0].cmd_code = CCW_CMD_SUSPEND_RECONN; spid_ccw[0].cda = 0; spid_ccw[0].count = 0; spid_ccw[0].flags = CCW_FLAG_SLI | CCW_FLAG_CC; @@ -5999,7 +5913,7 @@ if ( pdevstat->flag & DEVSTAT_STATUS_PENDING ) { #ifdef CONFIG_DEBUG_IO - printk( "SPID - Device %04X " + printk( KERN_DEBUG "SPID - Device %04X " "on Subchannel %04X " "reports pending status, " "retry : %d\n", @@ -6037,6 +5951,18 @@ { if ( mpath ) { + /* + * We now try single path mode. + * Note we must not issue the suspend + * multipath reconnect, or we will get + * a command reject by tapes. + */ + + spid_ccw[0].cmd_code = CCW_CMD_SET_PGID; + spid_ccw[0].cda = (__u32)virt_to_phys( pgid ); + spid_ccw[0].count = sizeof( pgid_t); + spid_ccw[0].flags = CCW_FLAG_SLI; + pgid->inf.fc = SPID_FUNC_SINGLE_PATH | SPID_FUNC_ESTABLISH; mpath = 0; @@ -6053,7 +5979,7 @@ else { #ifdef CONFIG_DEBUG_IO - printk( "SPID - device %04X," + printk( KERN_WARNING "SPID - device %04X," " unit check," " retry %d, cnt %02d," " sns :" @@ -6101,7 +6027,7 @@ /* don't issue warnings during startup unless requested*/ if (init_IRQ_complete || cio_notoper_msg) { - printk( "SPID - Device %04X " + printk( KERN_WARNING "SPID - Device %04X " "on Subchannel %04X " "became 'not operational'\n", ioinfo[irq]->schib.pmcw.dev, @@ -6171,6 +6097,7 @@ ccw1_t *snid_ccw; /* ccw area for SNID command */ devstat_t devstat; /* required by request_irq() */ devstat_t *pdevstat = &devstat; + char dbf_txt[15]; int irq_ret = 0; /* return code */ int retry = 5; /* retry count */ @@ -6185,6 +6112,11 @@ } /* endif */ + if (cio_debug_initialized) { + sprintf(dbf_txt,"SNID%x",irq); + debug_text_event(cio_debug_trace_id, 4, dbf_txt); + } + if ( !ioinfo[irq]->ui.flags.ready ) { /* @@ -6261,7 +6193,7 @@ else { #ifdef CONFIG_DEBUG_IO - printk( "SNID - device %04X," + printk( KERN_WARNING "SNID - device %04X," " unit check," " flag %04X, " " retry %d, cnt %02d," @@ -6310,7 +6242,7 @@ { /* don't issue warnings during startup unless requested*/ if (init_IRQ_complete || cio_notoper_msg) { - printk( "SNID - Device %04X " + printk( KERN_WARNING "SNID - Device %04X " "on Subchannel %04X " "became 'not operational'\n", ioinfo[irq]->schib.pmcw.dev, @@ -6341,7 +6273,7 @@ if ( pdevstat->flag & DEVSTAT_STATUS_PENDING ) { #ifdef CONFIG_DEBUG_IO - printk( "SNID - Device %04X " + printk( KERN_INFO "SNID - Device %04X " "on Subchannel %04X " "reports pending status, " "retry : %d\n", @@ -6361,7 +6293,7 @@ } /* endif */ - printk( "SNID - device %04X," + printk( KERN_WARNING "SNID - device %04X," " start_io() reports rc : %d, retrying ...\n", ioinfo[irq]->schib.pmcw.dev, irq_ret); @@ -6425,7 +6357,7 @@ int lock = 0; #ifdef CONFIG_DEBUG_CRW - printk( "do_crw_pending : starting ...\n"); + printk( KERN_DEBUG "do_crw_pending : starting ...\n"); #endif if (cio_debug_initialized) debug_sprintf_event(cio_debug_crw_id, 2, @@ -6440,7 +6372,7 @@ irq = pcrwe->crw.rsid; #ifdef CONFIG_DEBUG_CRW - printk( KERN_INFO"do_crw_pending : source is " + printk( KERN_NOTICE"do_crw_pending : source is " "subchannel %04X\n", irq); #endif if (cio_debug_initialized) @@ -6465,7 +6397,7 @@ } /* endif */ #ifdef CONFIG_DEBUG_CRW - printk( "do_crw_pending : subchannel validation - start ...\n"); + printk( KERN_DEBUG "do_crw_pending : subchannel validation - start ...\n"); #endif if (cio_debug_initialized) debug_sprintf_event(cio_debug_crw_id, 4, @@ -6476,7 +6408,7 @@ highest_subchannel = irq; #ifdef CONFIG_DEBUG_CRW - printk( "do_crw_pending : subchannel validation - done\n"); + printk( KERN_DEBUG "do_crw_pending : subchannel validation - done\n"); #endif if (cio_debug_initialized) debug_sprintf_event(cio_debug_crw_id, 4, @@ -6496,7 +6428,7 @@ if ( ioinfo[irq] != INVALID_STORAGE_AREA ) { #ifdef CONFIG_DEBUG_CRW - printk( "do_crw_pending : ioinfo at " + printk( KERN_DEBUG "do_crw_pending : ioinfo at " #ifdef CONFIG_ARCH_S390X "%08lX\n", (unsigned long)ioinfo[irq]); @@ -6523,10 +6455,11 @@ if ( ioinfo[irq]->ui.flags.oper == 0 ) { not_oper_handler_func_t nopfunc=ioinfo[irq]->nopfunc; - +#ifdef CONFIG_PROC_FS /* remove procfs entry */ if (cio_proc_devinfo) cio_procfs_device_remove(dev_no); +#endif /* * If the device has gone * call not oper handler @@ -6543,7 +6476,7 @@ else { #ifdef CONFIG_DEBUG_CRW - printk( "do_crw_pending : device " + printk( KERN_DEBUG "do_crw_pending : device " "recognition - start ...\n"); #endif if (cio_debug_initialized) @@ -6552,7 +6485,7 @@ s390_device_recognition_irq( irq ); #ifdef CONFIG_DEBUG_CRW - printk( "do_crw_pending : device " + printk( KERN_DEBUG "do_crw_pending : device " "recognition - done\n"); #endif if (cio_debug_initialized) @@ -6573,12 +6506,13 @@ pdevreg->oper_func( irq, pdevreg ); } /* endif */ - +#ifdef CONFIG_PROC_FS /* add new procfs entry */ if (cio_proc_devinfo) if (highest_subchannel < MAX_CIO_PROCFS_ENTRIES) { cio_procfs_device_create(ioinfo[irq]->devno); } +#endif } /* * ... it is and was operational, but @@ -6586,23 +6520,26 @@ */ else if ((ioinfo[irq]->devno != dev_no) && ( ioinfo[irq]->nopfunc != NULL )) { +#ifdef CONFIG_PROC_FS int devno_old = ioinfo[irq]->devno; +#endif ioinfo[irq]->nopfunc( irq, DEVSTAT_REVALIDATE ); - +#ifdef CONFIG_PROC_FS /* remove old entry, add new */ if (cio_proc_devinfo) { cio_procfs_device_remove(devno_old); cio_procfs_device_create(ioinfo[irq]->devno); } +#endif } /* endif */ } /* endif */ - +#ifdef CONFIG_PROC_FS /* get rid of dead procfs entries */ if (cio_proc_devinfo) cio_procfs_device_purge(); - +#endif } /* endif */ break; @@ -6610,7 +6547,7 @@ case CRW_RSC_MONITOR : #ifdef CONFIG_DEBUG_CRW - printk( "do_crw_pending : source is " + printk( KERN_NOTICE "do_crw_pending : source is " "monitoring facility\n"); #endif if (cio_debug_initialized) @@ -6623,7 +6560,7 @@ chpid = pcrwe->crw.rsid; #ifdef CONFIG_DEBUG_CRW - printk( "do_crw_pending : source is " + printk( KERN_NOTICE "do_crw_pending : source is " "channel path %02X\n", chpid); #endif if (cio_debug_initialized) @@ -6634,7 +6571,7 @@ case CRW_RSC_CONFIG : #ifdef CONFIG_DEBUG_CRW - printk( "do_crw_pending : source is " + printk( KERN_NOTICE "do_crw_pending : source is " "configuration-alert facility\n"); #endif if (cio_debug_initialized) @@ -6645,7 +6582,7 @@ case CRW_RSC_CSS : #ifdef CONFIG_DEBUG_CRW - printk( "do_crw_pending : source is " + printk( KERN_NOTICE "do_crw_pending : source is " "channel subsystem\n"); #endif if (cio_debug_initialized) @@ -6656,7 +6593,7 @@ default : #ifdef CONFIG_DEBUG_CRW - printk( "do_crw_pending : unknown source\n"); + printk( KERN_NOTICE "do_crw_pending : unknown source\n"); #endif if (cio_debug_initialized) debug_sprintf_event(cio_debug_crw_id, 2, @@ -6670,7 +6607,7 @@ } /* endwhile */ #ifdef CONFIG_DEBUG_CRW - printk( "do_crw_pending : done\n"); + printk( KERN_DEBUG "do_crw_pending : done\n"); #endif if (cio_debug_initialized) debug_sprintf_event(cio_debug_crw_id, 2, @@ -6715,7 +6652,7 @@ { int ret = 0; - cio_debug_msg_id = debug_register("cio_msg",2,4,16*sizeof(long)); + cio_debug_msg_id = debug_register("cio_msg",4,4,16*sizeof(long)); if (cio_debug_msg_id != NULL) { debug_register_view(cio_debug_msg_id, &debug_sprintf_view); #ifdef CONFIG_DEBUG_IO @@ -6756,6 +6693,7 @@ __initcall(cio_debug_init); +#ifdef CONFIG_PROC_FS /* * Display info on subchannels in /proc/subchannels. * Adapted from procfs stuff in dasd.c by Cornelia Huck, 02/28/01. @@ -7163,19 +7101,19 @@ entry->cio_chpid_entry = create_proc_entry( "chpids", S_IFREG|S_IRUGO, entry->cio_device_entry); entry->cio_chpid_entry->proc_fops = &cio_chpid_entry_file_ops; } else { - printk("Error, could not allocate procfs structure!\n"); + printk( KERN_WARNING "Error, could not allocate procfs structure!\n"); remove_proc_entry(buf, cio_procfs_deviceinfo_root); kfree(entry); rc = -ENOMEM; } } else { - printk("Error, could not allocate procfs structure!\n"); + printk( KERN_WARNING "Error, could not allocate procfs structure!\n"); kfree(entry); rc = -ENOMEM; } } else { - printk("Error, could not allocate procfs structure!\n"); + printk( KERN_WARNING "Error, could not allocate procfs structure!\n"); rc = -ENOMEM; } return rc; @@ -7288,15 +7226,14 @@ */ static struct proc_dir_entry *cio_ignore_proc_entry; - static int cio_ignore_proc_open(struct inode *inode, struct file *file) { int rc = 0; int size = 1; int len = 0; tempinfo_t *info; - dev_blacklist_range_t *tmp; long flags; + int i, j; info = (tempinfo_t *) vmalloc(sizeof(tempinfo_t)); if (info == NULL) { @@ -7304,7 +7241,7 @@ rc = -ENOMEM; } else { file->private_data = (void *) info; - size += nr_blacklisted_ranges * 32; + size += nr_ignored * 6; info->data = (char *) vmalloc(size); if (size && info->data == NULL) { printk( KERN_WARNING "No memory available for data\n"); @@ -7312,13 +7249,15 @@ rc = -ENOMEM; } else { spin_lock_irqsave( &blacklist_lock, flags ); - tmp = dev_blacklist_range_head; - while (tmp) { - len += sprintf(info->data+len, "%04x ", tmp->from); - if (tmp->to != tmp->from) - len += sprintf(info->data+len, "- %04x", tmp->to); + for (i=0;i<=highest_ignored;i++) + if (test_bit(i,&bl_dev)) { + len += sprintf(info->data+len, "%04x ", i); + for (j=i;(j<=highest_ignored) && (test_bit(j,&bl_dev));j++); + j--; + if (i != j) + len += sprintf(info->data+len, "- %04x", j); len += sprintf(info->data+len, "\n"); - tmp = tmp->next; + i=j; } spin_unlock_irqrestore( &blacklist_lock, flags ); info->len = len; @@ -7370,7 +7309,7 @@ } buffer[user_len]='\0'; #ifdef CIO_DEBUG_IO - printk ("/proc/cio_ignore: '%s'\n", buffer); + printk ( KERN_DEBUG "/proc/cio_ignore: '%s'\n", buffer); #endif /* CIO_DEBUG_IO */ if (cio_debug_initialized) debug_sprintf_event(cio_debug_msg_id, 2, "/proc/cio_ignore: '%s'\n",buffer); @@ -7491,6 +7430,7 @@ __initcall(cio_irq_proc_init); /* end of procfs stuff */ +#endif schib_t *s390_get_schib( int irq ) { diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/s390/sysinfo.c linux-2.5/drivers/s390/sysinfo.c --- linux-2.5.1/drivers/s390/sysinfo.c Thu Jan 1 00:00:00 1970 +++ linux-2.5/drivers/s390/sysinfo.c Thu Dec 27 16:32:31 2001 @@ -0,0 +1,354 @@ +/* + * drivers/s390/sysinfo.c + * + * Copyright (C) 2001 IBM Deutschland Entwicklung GmbH, IBM Corporation + * Author(s): Ulrich Weigand (Ulrich.Weigand@de.ibm.com) + */ + +#include <linux/config.h> +#include <linux/kernel.h> +#include <linux/mm.h> +#include <linux/proc_fs.h> +#include <linux/init.h> +#include <asm/ebcdic.h> + +struct sysinfo_1_1_1 +{ + char reserved_0[32]; + char manufacturer[16]; + char type[4]; + char reserved_1[12]; + char model[16]; + char sequence[16]; + char plant[4]; +}; + +struct sysinfo_1_2_1 +{ + char reserved_0[80]; + char sequence[16]; + char plant[4]; + char reserved_1[2]; + unsigned short cpu_address; +}; + +struct sysinfo_1_2_2 +{ + char reserved_0[32]; + unsigned int capability; + unsigned short cpus_total; + unsigned short cpus_configured; + unsigned short cpus_standby; + unsigned short cpus_reserved; + unsigned short adjustment[0]; +}; + +struct sysinfo_2_2_1 +{ + char reserved_0[80]; + char sequence[16]; + char plant[4]; + unsigned short cpu_id; + unsigned short cpu_address; +}; + +struct sysinfo_2_2_2 +{ + char reserved_0[32]; + unsigned short lpar_number; + char reserved_1; + unsigned char characteristics; + #define LPAR_CHAR_DEDICATED (1 << 7) + #define LPAR_CHAR_SHARED (1 << 6) + #define LPAR_CHAR_LIMITED (1 << 5) + unsigned short cpus_total; + unsigned short cpus_configured; + unsigned short cpus_standby; + unsigned short cpus_reserved; + char name[8]; + unsigned int caf; + char reserved_2[16]; + unsigned short cpus_dedicated; + unsigned short cpus_shared; +}; + +struct sysinfo_3_2_2 +{ + char reserved_0[31]; + unsigned char count; + struct + { + char reserved_0[4]; + unsigned short cpus_total; + unsigned short cpus_configured; + unsigned short cpus_standby; + unsigned short cpus_reserved; + char name[8]; + unsigned int caf; + char cpi[16]; + char reserved_1[24]; + + } vm[8]; +}; + +union s390_sysinfo +{ + struct sysinfo_1_1_1 sysinfo_1_1_1; + struct sysinfo_1_2_1 sysinfo_1_2_1; + struct sysinfo_1_2_2 sysinfo_1_2_2; + struct sysinfo_2_2_1 sysinfo_2_2_1; + struct sysinfo_2_2_2 sysinfo_2_2_2; + struct sysinfo_3_2_2 sysinfo_3_2_2; +}; + +static inline int stsi (void *sysinfo, + int fc, int sel1, int sel2) +{ + int cc, retv; + +#ifndef CONFIG_ARCH_S390X + __asm__ __volatile__ ( "lr\t0,%2\n" + "\tlr\t1,%3\n" + "\tstsi\t0(%4)\n" + "0:\tipm\t%0\n" + "\tsrl\t%0,28\n" + "1:lr\t%1,0\n" + ".section .fixup,\"ax\"\n" + "2:\tlhi\t%0,3\n" + "\tbras\t1,3f\n" + "\t.long 1b\n" + "3:\tl\t1,0(1)\n" + "\tbr\t1\n" + ".previous\n" + ".section __ex_table,\"a\"\n" + "\t.align 4\n" + "\t.long 0b,2b\n" + ".previous\n" + : "=d" (cc), "=d" (retv) + : "d" ((fc << 28) | sel1), "d" (sel2), "a" (sysinfo) + : "cc", "memory", "0", "1" ); +#else + __asm__ __volatile__ ( "lr\t0,%2\n" + "lr\t1,%3\n" + "\tstsi\t0(%4)\n" + "0:\tipm\t%0\n" + "\tsrl\t%0,28\n" + "1:lr\t%1,0\n" + ".section .fixup,\"ax\"\n" + "2:\tlhi\t%0,3\n" + "\tjg\t1b\n" + ".previous\n" + ".section __ex_table,\"a\"\n" + "\t.align 8\n" + "\t.quad 0b,2b\n" + ".previous\n" + : "=d" (cc), "=d" (retv) + : "d" ((fc << 28) | sel1), "d" (sel2), "a" (sysinfo) + : "cc", "memory", "0", "1" ); +#endif + + return cc? -1 : retv; +} + +static inline int stsi_0 (void) +{ + int rc = stsi (NULL, 0, 0, 0); + return rc == -1 ? rc : (((unsigned int)rc) >> 28); +} + +static inline int stsi_1_1_1 (struct sysinfo_1_1_1 *info) +{ + int rc = stsi (info, 1, 1, 1); + if (rc != -1) + { + EBCASC (info->manufacturer, sizeof(info->manufacturer)); + EBCASC (info->type, sizeof(info->type)); + EBCASC (info->model, sizeof(info->model)); + EBCASC (info->sequence, sizeof(info->sequence)); + EBCASC (info->plant, sizeof(info->plant)); + } + return rc == -1 ? rc : 0; +} + +static inline int stsi_1_2_1 (struct sysinfo_1_2_1 *info) +{ + int rc = stsi (info, 1, 2, 1); + if (rc != -1) + { + EBCASC (info->sequence, sizeof(info->sequence)); + EBCASC (info->plant, sizeof(info->plant)); + } + return rc == -1 ? rc : 0; +} + +static inline int stsi_1_2_2 (struct sysinfo_1_2_2 *info) +{ + int rc = stsi (info, 1, 2, 2); + return rc == -1 ? rc : 0; +} + +static inline int stsi_2_2_1 (struct sysinfo_2_2_1 *info) +{ + int rc = stsi (info, 2, 2, 1); + if (rc != -1) + { + EBCASC (info->sequence, sizeof(info->sequence)); + EBCASC (info->plant, sizeof(info->plant)); + } + return rc == -1 ? rc : 0; +} + +static inline int stsi_2_2_2 (struct sysinfo_2_2_2 *info) +{ + int rc = stsi (info, 2, 2, 2); + if (rc != -1) + { + EBCASC (info->name, sizeof(info->name)); + } + return rc == -1 ? rc : 0; +} + +static inline int stsi_3_2_2 (struct sysinfo_3_2_2 *info) +{ + int rc = stsi (info, 3, 2, 2); + if (rc != -1) + { + int i; + for (i = 0; i < info->count; i++) + { + EBCASC (info->vm[i].name, sizeof(info->vm[i].name)); + EBCASC (info->vm[i].cpi, sizeof(info->vm[i].cpi)); + } + } + return rc == -1 ? rc : 0; +} + + +static int proc_read_sysinfo(char *page, char **start, + off_t off, int count, + int *eof, void *data) +{ + unsigned long info_page = get_free_page (GFP_KERNEL); + union s390_sysinfo *info = (union s390_sysinfo *) info_page; + int len = 0; + int level; + int i; + + if (!info) + return 0; + + level = stsi_0 (); + + if (level < 1) + goto out; + if (stsi_1_1_1 (&info->sysinfo_1_1_1)) + goto out; + + len += sprintf (page+len, "Manufacturer: %-16.16s\n", + info->sysinfo_1_1_1.manufacturer); + len += sprintf (page+len, "Type: %-4.4s\n", + info->sysinfo_1_1_1.type); + len += sprintf (page+len, "Model: %-16.16s\n", + info->sysinfo_1_1_1.model); + len += sprintf (page+len, "Sequence Code: %-16.16s\n", + info->sysinfo_1_1_1.sequence); + len += sprintf (page+len, "Plant: %-4.4s\n", + info->sysinfo_1_1_1.plant); + + if (stsi_1_2_2 (&info->sysinfo_1_2_2)) + goto out; + + len += sprintf (page+len, "\n"); + len += sprintf (page+len, "CPUs Total: %d\n", + info->sysinfo_1_2_2.cpus_total); + len += sprintf (page+len, "CPUs Configured: %d\n", + info->sysinfo_1_2_2.cpus_configured); + len += sprintf (page+len, "CPUs Standby: %d\n", + info->sysinfo_1_2_2.cpus_standby); + len += sprintf (page+len, "CPUs Reserved: %d\n", + info->sysinfo_1_2_2.cpus_reserved); + + len += sprintf (page+len, "Capability: %d\n", + info->sysinfo_1_2_2.capability); + + for (i = 2; i <= info->sysinfo_1_2_2.cpus_total; i++) + len += sprintf (page+len, "Adjustment %02d-way: %d\n", + i, info->sysinfo_1_2_2.adjustment[i-2]); + + if (level < 2) + goto out; + if (stsi_2_2_2 (&info->sysinfo_2_2_2)) + goto out; + + len += sprintf (page+len, "\n"); + len += sprintf (page+len, "LPAR Number: %d\n", + info->sysinfo_2_2_2.lpar_number); + + len += sprintf (page+len, "LPAR Characteristics: "); + if (info->sysinfo_2_2_2.characteristics & LPAR_CHAR_DEDICATED) + len += sprintf (page+len, "Dedicated "); + if (info->sysinfo_2_2_2.characteristics & LPAR_CHAR_SHARED) + len += sprintf (page+len, "Shared "); + if (info->sysinfo_2_2_2.characteristics & LPAR_CHAR_LIMITED) + len += sprintf (page+len, "Limited "); + len += sprintf (page+len, "\n"); + + len += sprintf (page+len, "LPAR Name: %-8.8s\n", + info->sysinfo_2_2_2.name); + + len += sprintf (page+len, "LPAR Adjustment: %d\n", + info->sysinfo_2_2_2.caf); + + len += sprintf (page+len, "LPAR CPUs Total: %d\n", + info->sysinfo_2_2_2.cpus_total); + len += sprintf (page+len, "LPAR CPUs Configured: %d\n", + info->sysinfo_2_2_2.cpus_configured); + len += sprintf (page+len, "LPAR CPUs Standby: %d\n", + info->sysinfo_2_2_2.cpus_standby); + len += sprintf (page+len, "LPAR CPUs Reserved: %d\n", + info->sysinfo_2_2_2.cpus_reserved); + len += sprintf (page+len, "LPAR CPUs Dedicated: %d\n", + info->sysinfo_2_2_2.cpus_dedicated); + len += sprintf (page+len, "LPAR CPUs Shared: %d\n", + info->sysinfo_2_2_2.cpus_shared); + + if (level < 3) + goto out; + if (stsi_3_2_2 (&info->sysinfo_3_2_2)) + goto out; + + for (i = 0; i < info->sysinfo_3_2_2.count; i++) + { + len += sprintf (page+len, "\n"); + len += sprintf (page+len, "VM%02d Name: %-8.8s\n", + i, info->sysinfo_3_2_2.vm[i].name); + len += sprintf (page+len, "VM%02d Control Program: %-16.16s\n", + i, info->sysinfo_3_2_2.vm[i].cpi); + + len += sprintf (page+len, "VM%02d Adjustment: %d\n", + i, info->sysinfo_3_2_2.vm[i].caf); + + len += sprintf (page+len, "VM%02d CPUs Total: %d\n", + i, info->sysinfo_3_2_2.vm[i].cpus_total); + len += sprintf (page+len, "VM%02d CPUs Configured: %d\n", + i, info->sysinfo_3_2_2.vm[i].cpus_configured); + len += sprintf (page+len, "VM%02d CPUs Standby: %d\n", + i, info->sysinfo_3_2_2.vm[i].cpus_standby); + len += sprintf (page+len, "VM%02d CPUs Reserved: %d\n", + i, info->sysinfo_3_2_2.vm[i].cpus_reserved); + } + +out: + free_page (info_page); + return len; +} + +static __init int create_proc_sysinfo(void) +{ + create_proc_read_entry ("sysinfo", 0444, NULL, + proc_read_sysinfo, NULL); + return 0; +} + +__initcall(create_proc_sysinfo); + diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/sbus/char/aurora.c linux-2.5/drivers/sbus/char/aurora.c --- linux-2.5.1/drivers/sbus/char/aurora.c Tue Oct 30 23:08:11 2001 +++ linux-2.5/drivers/sbus/char/aurora.c Sun Dec 30 21:17:30 2001 @@ -66,7 +66,6 @@ #include <asm/irq.h> #include <asm/oplib.h> #include <asm/system.h> -#include <asm/segment.h> #include <asm/bitops.h> #include <asm/kdebug.h> #include <asm/sbus.h> diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/sbus/char/bpp.c linux-2.5/drivers/sbus/char/bpp.c --- linux-2.5.1/drivers/sbus/char/bpp.c Thu Oct 11 16:43:29 2001 +++ linux-2.5/drivers/sbus/char/bpp.c Sun Dec 30 21:17:30 2001 @@ -28,7 +28,6 @@ #if defined(__i386__) # include <asm/system.h> -# include <asm/segment.h> #endif #if defined(__sparc__) diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/sbus/char/sab82532.c linux-2.5/drivers/sbus/char/sab82532.c --- linux-2.5.1/drivers/sbus/char/sab82532.c Wed Oct 17 21:16:39 2001 +++ linux-2.5/drivers/sbus/char/sab82532.c Sun Dec 30 13:55:22 2001 @@ -361,10 +361,6 @@ writeb(SAB82532_CMDR_RMC, &info->regs->w.cmdr); } -#ifdef CONFIG_SERIAL_CONSOLE - if (info->is_console) - wake_up(&keypress_wait); -#endif if (!tty) return; @@ -2255,7 +2251,9 @@ serial_driver.table = sab82532_table; serial_driver.termios = sab82532_termios; serial_driver.termios_locked = sab82532_termios_locked; - +#ifdef CONFIG_SERIAL_CONSOLE + serial_driver.console = &sab82532_console; +#endif serial_driver.open = sab82532_open; serial_driver.close = sab82532_close; serial_driver.write = sab82532_write; @@ -2541,13 +2539,6 @@ sab82532_tec_wait(info); } -static int -sab82532_console_wait_key(struct console *con) -{ - sleep_on(&keypress_wait); - return 0; -} - static kdev_t sab82532_console_device(struct console *con) { @@ -2622,7 +2613,6 @@ name: "ttyS", write: sab82532_console_write, device: sab82532_console_device, - wait_key: sab82532_console_wait_key, setup: sab82532_console_setup, flags: CON_PRINTBUFFER, index: -1, diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/sbus/char/su.c linux-2.5/drivers/sbus/char/su.c --- linux-2.5.1/drivers/sbus/char/su.c Tue Nov 13 17:16:05 2001 +++ linux-2.5/drivers/sbus/char/su.c Sun Dec 30 13:55:22 2001 @@ -2506,7 +2506,9 @@ serial_driver.table = serial_table; serial_driver.termios = serial_termios; serial_driver.termios_locked = serial_termios_locked; - +#ifdef CONFIG_SERIAL_CONSOLE + serial_driver.console = &sercons; +#endif serial_driver.open = su_open; serial_driver.close = su_close; serial_driver.write = su_write; @@ -2854,40 +2856,6 @@ su_outb(info, UART_IER, ier); } -/* - * Receive character from the serial port - */ -static int -serial_console_wait_key(struct console *co) -{ - struct su_struct *info; - int ier; - int lsr; - int c; - - info = su_table + co->index; - - /* - * First save the IER then disable the interrupts so - * that the real driver for the port does not get the - * character. - */ - ier = su_inb(info, UART_IER); - su_outb(info, UART_IER, 0x00); - - do { - lsr = su_inb(info, UART_LSR); - } while (!(lsr & UART_LSR_DR)); - c = su_inb(info, UART_RX); - - /* - * Restore the interrupts - */ - su_outb(info, UART_IER, ier); - - return c; -} - static kdev_t serial_console_device(struct console *c) { @@ -3013,7 +2981,6 @@ name: "ttyS", write: serial_console_write, device: serial_console_device, - wait_key: serial_console_wait_key, setup: serial_console_setup, flags: CON_PRINTBUFFER, index: -1, diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/sbus/char/sunkbd.c linux-2.5/drivers/sbus/char/sunkbd.c --- linux-2.5.1/drivers/sbus/char/sunkbd.c Mon Sep 17 04:22:50 2001 +++ linux-2.5/drivers/sbus/char/sunkbd.c Thu Dec 27 15:56:12 2001 @@ -82,16 +82,6 @@ struct l1a_kbd_state l1a_state; -#ifndef CONFIG_PCI -DECLARE_WAIT_QUEUE_HEAD(keypress_wait); -#endif - -int keyboard_wait_for_keypress(struct console *co) -{ - sleep_on(&keypress_wait); - return 0; -} - static spinlock_t sunkbd_lock = SPIN_LOCK_UNLOCKED; /* @@ -629,7 +619,6 @@ static void put_queue(int ch) { - wake_up(&keypress_wait); if (tty) { tty_insert_flip_char(tty, ch, 0); con_schedule_flip(tty); @@ -638,7 +627,6 @@ static void puts_queue(char *cp) { - wake_up(&keypress_wait); if (!tty) return; diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/sbus/char/zs.c linux-2.5/drivers/sbus/char/zs.c --- linux-2.5.1/drivers/sbus/char/zs.c Tue Oct 30 23:08:11 2001 +++ linux-2.5/drivers/sbus/char/zs.c Sun Dec 30 13:55:22 2001 @@ -532,8 +532,6 @@ /* Continue execution... */ return; } - /* It is a 'keyboard interrupt' ;-) */ - wake_up(&keypress_wait); } #ifndef __sparc_v9__ /* Look for kgdb 'stop' character, consult the gdb @@ -2427,7 +2425,9 @@ serial_driver.table = serial_table; serial_driver.termios = serial_termios; serial_driver.termios_locked = serial_termios_locked; - +#ifdef CONFIG_SERIAL_CONSOLE + serial_driver.console = &zs_console; +#endif serial_driver.open = zs_open; serial_driver.close = zs_close; serial_driver.write = zs_write; @@ -2761,13 +2761,6 @@ #endif } -static int -zs_console_wait_key(struct console *con) -{ - sleep_on(&keypress_wait); - return 0; -} - static kdev_t zs_console_device(struct console *con) { return MKDEV(TTY_MAJOR, 64 + con->index); @@ -2845,7 +2838,6 @@ name: "ttyS", write: zs_console_write, device: zs_console_device, - wait_key: zs_console_wait_key, setup: zs_console_setup, flags: CON_PRINTBUFFER, index: -1, diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/scsi/BusLogic.c linux-2.5/drivers/scsi/BusLogic.c --- linux-2.5.1/drivers/scsi/BusLogic.c Sun Sep 30 19:26:07 2001 +++ linux-2.5/drivers/scsi/BusLogic.c Thu Dec 27 22:10:28 2001 @@ -4106,7 +4106,7 @@ BusLogic_HostAdapter_T *HostAdapter = (BusLogic_HostAdapter_T *) Disk->device->host->hostdata; BIOS_DiskParameters_T *DiskParameters = (BIOS_DiskParameters_T *) Parameters; - struct buffer_head *BufferHead; + unsigned char *buf; if (HostAdapter->ExtendedTranslationEnabled && Disk->capacity >= 2*1024*1024 /* 1 GB in 512 byte sectors */) { @@ -4128,20 +4128,16 @@ } DiskParameters->Cylinders = Disk->capacity / (DiskParameters->Heads * DiskParameters->Sectors); - /* - Attempt to read the first 1024 bytes from the disk device. - */ - BufferHead = bread(MKDEV(MAJOR(Device), MINOR(Device) & ~0x0F), 0, 1024); - if (BufferHead == NULL) return 0; + buf = scsi_bios_ptable(Device); + if (buf == NULL) return 0; /* If the boot sector partition table flag is valid, search for a partition table entry whose end_head matches one of the standard BusLogic geometry translations (64/32, 128/32, or 255/63). */ - if (*(unsigned short *) (BufferHead->b_data + 0x1FE) == 0xAA55) + if (*(unsigned short *) (buf+64) == 0xAA55) { - PartitionTable_T *FirstPartitionEntry = - (PartitionTable_T *) (BufferHead->b_data + 0x1BE); + PartitionTable_T *FirstPartitionEntry = (PartitionTable_T *) buf; PartitionTable_T *PartitionEntry = FirstPartitionEntry; int SavedCylinders = DiskParameters->Cylinders, PartitionNumber; unsigned char PartitionEntryEndHead, PartitionEntryEndSector; @@ -4195,7 +4191,7 @@ DiskParameters->Heads, DiskParameters->Sectors); } } - brelse(BufferHead); + kfree(buf); return 0; } diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/scsi/Config.in linux-2.5/drivers/scsi/Config.in --- linux-2.5.1/drivers/scsi/Config.in Tue Nov 27 17:23:27 2001 +++ linux-2.5/drivers/scsi/Config.in Thu Dec 13 16:32:36 2001 @@ -46,6 +46,9 @@ dep_tristate 'Adaptec AHA152X/2825 support' CONFIG_SCSI_AHA152X $CONFIG_SCSI dep_tristate 'Adaptec AHA1542 support' CONFIG_SCSI_AHA1542 $CONFIG_SCSI dep_tristate 'Adaptec AHA1740 support' CONFIG_SCSI_AHA1740 $CONFIG_SCSI +if [ "$CONFIG_EXPERIMENTAL" = "y" ]; then + dep_tristate 'Adaptec AACRAID support (EXPERIMENTAL)' CONFIG_SCSI_AACRAID $CONFIG_SCSI $CONFIG_PCI +fi source drivers/scsi/aic7xxx/Config.in if [ "$CONFIG_SCSI_AIC7XXX" != "y" ]; then dep_tristate 'Old Adaptec AIC7xxx support' CONFIG_SCSI_AIC7XXX_OLD $CONFIG_SCSI diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/scsi/Makefile linux-2.5/drivers/scsi/Makefile --- linux-2.5.1/drivers/scsi/Makefile Sun Dec 16 20:20:20 2001 +++ linux-2.5/drivers/scsi/Makefile Mon Dec 17 01:03:06 2001 @@ -25,6 +25,7 @@ mod-subdirs := pcmcia ../acorn/scsi +subdir-$(CONFIG_SCSI_AACRAID) += aacraid subdir-$(CONFIG_SCSI_AIC7XXX) += aic7xxx subdir-$(CONFIG_PCMCIA) += pcmcia @@ -64,6 +65,9 @@ obj-$(CONFIG_SCSI_AHA152X) += aha152x.o obj-$(CONFIG_SCSI_AHA1542) += aha1542.o obj-$(CONFIG_SCSI_AHA1740) += aha1740.o +ifeq ($(CONFIG_SCSI_AACRAID),y) + obj-$(CONFIG_SCSI_AACRAID) += aacraid/aacraid.o +endif ifeq ($(CONFIG_SCSI_AIC7XXX),y) obj-$(CONFIG_SCSI_AIC7XXX) += aic7xxx/aic7xxx_drv.o endif diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/scsi/NCR5380.c linux-2.5/drivers/scsi/NCR5380.c --- linux-2.5.1/drivers/scsi/NCR5380.c Sat Feb 17 00:02:36 2001 +++ linux-2.5/drivers/scsi/NCR5380.c Thu Dec 27 15:14:59 2001 @@ -83,8 +83,6 @@ * basically, transfer size needs to be reduced by one * and the last byte read as is done with PSEUDO_DMA. * - * 3. Test USLEEP code - * * 4. Test SCSI-II tagged queueing (I have no devices which support * tagged queueing) * @@ -110,6 +108,12 @@ #define READ_OVERRUNS #endif +#ifdef BOARD_REQUIRES_NO_DELAY +#define io_recovery_delay(x) +#else +#define io_recovery_delay(x) udelay(x) +#endif + /* * Design * Issues : @@ -192,9 +196,8 @@ * phase goes through the various phases as instructed by the target. * if the target goes into MSG IN and sends a DISCONNECT message, * the command structure is placed into the per instance disconnected - * queue, and NCR5380_main tries to find more work. If USLEEP - * was defined, and the target is idle for too long, the system - * will try to sleep. + * queue, and NCR5380_main tries to find more work. If the target is + * idle for too long, the system will try to sleep. * * If a command has disconnected, eventually an interrupt will trigger, * calling NCR5380_intr() which will in turn call NCR5380_reselect @@ -244,21 +247,14 @@ * rely on phase mismatch and EOP interrupts to determine end * of phase. * - * SCSI2 - if defined, SCSI-2 tagged queuing is used where possible - * * UNSAFE - leave interrupts enabled during pseudo-DMA transfers. You * only really want to use this if you're having a problem with * dropped characters during high speed communications, and even * then, you're going to be better off twiddling with transfersize * in the high level code. * - * USLEEP - if defined, on devices that aren't disconnecting from the - * bus, we will go to sleep so that the CPU can get real work done - * when we run a command that won't complete immediately. - * - * Defaults for these will be provided if USLEEP is defined, although - * the user may want to adjust these to allocate CPU resources to - * the SCSI driver or "real" code. + * Defaults for these will be provided although the user may want to adjust + * these to allocate CPU resources to the SCSI driver or "real" code. * * USLEEP_SLEEP - amount of time, in jiffies, to sleep * @@ -322,18 +318,13 @@ static void do_reset(struct Scsi_Host *host); static struct Scsi_Host *first_instance = NULL; static Scsi_Host_Template *the_template = NULL; - -#ifdef USLEEP -struct timer_list usleep_timer; -#endif +static struct timer_list usleep_timer; /* - * Function : void initialize_SCp(Scsi_Cmnd *cmd) + * initialize_SCp - init the scsi pointer field + * @cmd: command block to set up * - * Purpose : initialize the saved data pointers for cmd to point to the - * start of the buffer. - * - * Inputs : cmd - Scsi_Cmnd structure to have pointers reset. + * Set up the internal fields in the SCSI command. */ static __inline__ void initialize_SCp(Scsi_Cmnd * cmd) @@ -362,88 +353,49 @@ static struct { unsigned char mask; const char *name; -} signals[] = { { - - SR_DBP, "PARITY" -}, { - SR_RST, "RST" -}, { - SR_BSY, "BSY" -}, -{ - SR_REQ, "REQ" -}, { - SR_MSG, "MSG" -}, { - SR_CD, "CD" -}, { - SR_IO, "IO" -}, -{ - SR_SEL, "SEL" -}, { - 0, NULL -} -}, - -basrs[] = { { - BASR_ATN, "ATN" -}, { - BASR_ACK, "ACK" -}, { - 0, NULL -} -}, - -icrs[] = { { - ICR_ASSERT_RST, "ASSERT RST" -}, { - ICR_ASSERT_ACK, "ASSERT ACK" -}, -{ - ICR_ASSERT_BSY, "ASSERT BSY" -}, { - ICR_ASSERT_SEL, "ASSERT SEL" -}, -{ - ICR_ASSERT_ATN, "ASSERT ATN" -}, { - ICR_ASSERT_DATA, "ASSERT DATA" -}, -{ - 0, NULL -} -}, - -mrs[] = { { - MR_BLOCK_DMA_MODE, "MODE BLOCK DMA" -}, { - MR_TARGET, "MODE TARGET" -}, -{ - MR_ENABLE_PAR_CHECK, "MODE PARITY CHECK" -}, { - MR_ENABLE_PAR_INTR, - "MODE PARITY INTR" -}, { - MR_MONITOR_BSY, "MODE MONITOR BSY" -}, -{ - MR_DMA_MODE, "MODE DMA" -}, { - MR_ARBITRATE, "MODE ARBITRATION" -}, -{ - 0, NULL -} +} signals[] = { + {SR_DBP, "PARITY"}, + {SR_RST, "RST"}, + {SR_BSY, "BSY"}, + {SR_REQ, "REQ"}, + {SR_MSG, "MSG"}, + {SR_CD, "CD"}, + {SR_IO, "IO"}, + {SR_SEL, "SEL"}, + {0, NULL} +}, +basrs[] = { + {BASR_ATN, "ATN"}, + {BASR_ACK, "ACK"}, + {0, NULL} +}, +icrs[] = { + {ICR_ASSERT_RST, "ASSERT RST"}, + {ICR_ASSERT_ACK, "ASSERT ACK"}, + {ICR_ASSERT_BSY, "ASSERT BSY"}, + {ICR_ASSERT_SEL, "ASSERT SEL"}, + {ICR_ASSERT_ATN, "ASSERT ATN"}, + {ICR_ASSERT_DATA, "ASSERT DATA"}, + {0, NULL} +}, +mrs[] = { + {MR_BLOCK_DMA_MODE, "MODE BLOCK DMA"}, + {MR_TARGET, "MODE TARGET"}, + {MR_ENABLE_PAR_CHECK, "MODE PARITY CHECK"}, + {MR_ENABLE_PAR_INTR, "MODE PARITY INTR"}, + {MR_MONITOR_BSY, "MODE MONITOR BSY"}, + {MR_DMA_MODE, "MODE DMA"}, + {MR_ARBITRATE, "MODE ARBITRATION"}, + {0, NULL} }; -/* - * Function : void NCR5380_print(struct Scsi_Host *instance) +/** + * NCR5380_print - print scsi bus signals + * @instance: adapter state to dump * - * Purpose : print the SCSI bus signals for debugging purposes + * Print the SCSI bus signals for debugging purposes * - * Input : instance - which NCR5380 + * Locks: none */ static void NCR5380_print(struct Scsi_Host *instance) @@ -452,6 +404,7 @@ unsigned long flags; unsigned char status, data, basr, mr, icr, i; NCR5380_setup(instance); + /* FIXME - this needs proper locking */ save_flags(flags); cli(); data = NCR5380_read(CURRENT_SCSI_DATA_REG); @@ -483,32 +436,22 @@ unsigned char value; const char *name; } phases[] = { - - { - PHASE_DATAOUT, "DATAOUT" - }, { - PHASE_DATAIN, "DATAIN" - }, { - PHASE_CMDOUT, "CMDOUT" - }, - { - PHASE_STATIN, "STATIN" - }, { - PHASE_MSGOUT, "MSGOUT" - }, { - PHASE_MSGIN, "MSGIN" - }, - { - PHASE_UNKNOWN, "UNKNOWN" - } + {PHASE_DATAOUT, "DATAOUT"}, + {PHASE_DATAIN, "DATAIN"}, + {PHASE_CMDOUT, "CMDOUT"}, + {PHASE_STATIN, "STATIN"}, + {PHASE_MSGOUT, "MSGOUT"}, + {PHASE_MSGIN, "MSGIN"}, + {PHASE_UNKNOWN, "UNKNOWN"} }; /* - * Function : void NCR5380_print_phase(struct Scsi_Host *instance) + * NCR5380_print_phase - show SCSI phase + * @instance: adapter to dump * - * Purpose : print the current SCSI phase for debugging purposes + * Print the current SCSI phase for debugging purposes * - * Input : instance - which NCR5380 + * Locks: none */ static void NCR5380_print_phase(struct Scsi_Host *instance) @@ -520,11 +463,9 @@ status = NCR5380_read(STATUS_REG); if (!(status & SR_REQ)) - printk("scsi%d : REQ not asserted, phase unknown.\n", - instance->host_no); + printk("scsi%d : REQ not asserted, phase unknown.\n", instance->host_no); else { - for (i = 0; (phases[i].value != PHASE_UNKNOWN) && - (phases[i].value != (status & PHASE_MASK)); ++i); + for (i = 0; (phases[i].value != PHASE_UNKNOWN) && (phases[i].value != (status & PHASE_MASK)); ++i); printk("scsi%d : phase %s\n", instance->host_no, phases[i].name); } } @@ -549,7 +490,7 @@ * conditions are possible. */ -static volatile int main_running = 0; +static unsigned long main_running = 0; /* * Function : run_main(void) @@ -563,14 +504,10 @@ static __inline__ void run_main(void) { - if (!main_running) { - main_running = 1; + if (!test_and_set_bit(0, &main_running)) NCR5380_main(); - } } -#ifdef USLEEP - /* * These need tweaking, and would probably work best as per-device * flags initialized differently for disk, tape, cd, etc devices. @@ -621,63 +558,67 @@ static int should_disconnect(unsigned char cmd) { switch (cmd) { - case READ_6: - case WRITE_6: - case SEEK_6: - case READ_10: - case WRITE_10: - case SEEK_10: - return DISCONNECT_TIME_TO_DATA; - case FORMAT_UNIT: - case SEARCH_HIGH: - case SEARCH_LOW: - case SEARCH_EQUAL: - return DISCONNECT_LONG; - default: - return DISCONNECT_NONE; + case READ_6: + case WRITE_6: + case SEEK_6: + case READ_10: + case WRITE_10: + case SEEK_10: + return DISCONNECT_TIME_TO_DATA; + case FORMAT_UNIT: + case SEARCH_HIGH: + case SEARCH_LOW: + case SEARCH_EQUAL: + return DISCONNECT_LONG; + default: + return DISCONNECT_NONE; } } /* * Assumes instance->time_expires has been set in higher level code. + * + * Locks: Caller must hold io_request_lock */ static int NCR5380_set_timer(struct Scsi_Host *instance) { - unsigned long flags; struct Scsi_Host *tmp, **prev; - save_flags(flags); - cli(); if (((struct NCR5380_hostdata *) (instance->hostdata))->next_timer) { - restore_flags(flags); return -1; } - for (prev = &expires_first, tmp = expires_first; tmp; - prev = &(((struct NCR5380_hostdata *) tmp->hostdata)->next_timer), - tmp = ((struct NCR5380_hostdata *) tmp->hostdata)->next_timer) - if (((struct NCR5380_hostdata *)instance->hostdata)->time_expires < - ((struct NCR5380_hostdata *)tmp->hostdata)->time_expires) + for (prev = &expires_first, tmp = expires_first; tmp; prev = &(((struct NCR5380_hostdata *) tmp->hostdata)->next_timer), tmp = ((struct NCR5380_hostdata *) tmp->hostdata)->next_timer) + if (((struct NCR5380_hostdata *) instance->hostdata)->time_expires < ((struct NCR5380_hostdata *) tmp->hostdata)->time_expires) break; ((struct NCR5380_hostdata *) instance->hostdata)->next_timer = tmp; *prev = instance; - + mod_timer(&usleep_timer, ((struct NCR5380_hostdata *) expires_first->hostdata)->time_expires); - restore_flags(flags); return 0; } -/* Doing something about unwanted reentrancy here might be useful */ -void NCR5380_timer_fn(unsigned long surplus_to_requirements) +/** + * NCR5380_timer_fn - handle polled timeouts + * @unused: unused + * + * Walk the list of controllers, find which controllers have exceeded + * their expiry timeout and then schedule the processing co-routine to + * do the real work. + * + * Doing something about unwanted reentrancy here might be useful + * + * Locks: disables irqs, takes and frees io_request_lock + */ + +static void NCR5380_timer_fn(unsigned long unused) { - unsigned long flags; struct Scsi_Host *instance; - save_flags(flags); - cli(); - for (; expires_first && - time_before_eq(((struct NCR5380_hostdata *)expires_first->hostdata)->time_expires, jiffies); ) - { + + spin_lock_irq(&io_request_lock); + + for (; expires_first && time_before_eq(((struct NCR5380_hostdata *) expires_first->hostdata)->time_expires, jiffies);) { instance = ((struct NCR5380_hostdata *) expires_first->hostdata)->next_timer; ((struct NCR5380_hostdata *) expires_first->hostdata)->next_timer = NULL; ((struct NCR5380_hostdata *) expires_first->hostdata)->time_expires = 0; @@ -685,90 +626,91 @@ } del_timer(&usleep_timer); - if (expires_first) - { - usleep_timer.expires = ((struct NCR5380_hostdata *)expires_first->hostdata)->time_expires; + if (expires_first) { + usleep_timer.expires = ((struct NCR5380_hostdata *) expires_first->hostdata)->time_expires; add_timer(&usleep_timer); } - restore_flags(flags); - - spin_lock_irqsave(&io_request_lock, flags); run_main(); - spin_unlock_irqrestore(&io_request_lock, flags); + spin_unlock_irq(&io_request_lock); } -#endif /* def USLEEP */ +/** + * NCR5380_all_init - global setup + * + * Set up the global values and timers needed by the NCR5380 driver + */ + static inline void NCR5380_all_init(void) { static int done = 0; if (!done) { -#if (NDEBUG & NDEBUG_INIT) - printk("scsi : NCR5380_all_init()\n"); -#endif + dprintk(NDEBUG_INIT, ("scsi : NCR5380_all_init()\n")); done = 1; -#ifdef USLEEP init_timer(&usleep_timer); usleep_timer.function = NCR5380_timer_fn; -#endif } } -#ifdef AUTOPROBE_IRQ -/* - * Function : int NCR5380_probe_irq (struct Scsi_Host *instance, int possible) - * - * Purpose : autoprobe for the IRQ line used by the NCR5380. - * - * Inputs : instance - pointer to this instance of the NCR5380 driver, - * possible - bitmask of permissible interrupts. - * - * Returns : number of the IRQ selected, IRQ_NONE if no interrupt fired. - * - * XXX no effort is made to deal with spurious interrupts. - */ - static int probe_irq __initdata = 0; +/** + * probe_intr - helper for IRQ autoprobe + * @irq: interrupt number + * @dev_id: unused + * @regs: unused + * + * Set a flag to indicate the IRQ in question was received. This is + * used by the IRQ probe code. + */ + static void __init probe_intr(int irq, void *dev_id, struct pt_regs *regs) { probe_irq = irq; } +/** + * NCR5380_probe_irq - find the IRQ of an NCR5380 + * @instance: NCR5380 controller + * @possible: bitmask of ISA IRQ lines + * + * Autoprobe for the IRQ line used by the NCR5380 by triggering an IRQ + * and then looking to see what interrupt actually turned up. + * + * Locks: none, irqs must be enabled on entry + */ + static int __init NCR5380_probe_irq(struct Scsi_Host *instance, int possible) { NCR5380_local_declare(); - struct NCR5380_hostdata *hostdata = (struct NCR5380_hostdata *) - instance->hostdata; + struct NCR5380_hostdata *hostdata = (struct NCR5380_hostdata *) instance->hostdata; unsigned long timeout; int trying_irqs, i, mask; NCR5380_setup(instance); for (trying_irqs = i = 0, mask = 1; i < 16; ++i, mask <<= 1) - if ((mask & possible) && (request_irq(i, &probe_intr, SA_INTERRUPT, "NCR-probe", NULL) - == 0)) + if ((mask & possible) && (request_irq(i, &probe_intr, SA_INTERRUPT, "NCR-probe", NULL) == 0)) trying_irqs |= mask; timeout = jiffies + (250 * HZ / 1000); probe_irq = IRQ_NONE; -/* - * A interrupt is triggered whenever BSY = false, SEL = true - * and a bit set in the SELECT_ENABLE_REG is asserted on the - * SCSI bus. - * - * Note that the bus is only driven when the phase control signals - * (I/O, C/D, and MSG) match those in the TCR, so we must reset that - * to zero. - */ + /* + * A interrupt is triggered whenever BSY = false, SEL = true + * and a bit set in the SELECT_ENABLE_REG is asserted on the + * SCSI bus. + * + * Note that the bus is only driven when the phase control signals + * (I/O, C/D, and MSG) match those in the TCR, so we must reset that + * to zero. + */ NCR5380_write(TARGET_COMMAND_REG, 0); NCR5380_write(SELECT_ENABLE_REG, hostdata->id_mask); NCR5380_write(OUTPUT_DATA_REG, hostdata->id_mask); - NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE | ICR_ASSERT_DATA | - ICR_ASSERT_SEL); + NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE | ICR_ASSERT_DATA | ICR_ASSERT_SEL); - while (probe_irq == IRQ_NONE && time_before(jiffies,timeout)) + while (probe_irq == IRQ_NONE && time_before(jiffies, timeout)) barrier(); NCR5380_write(SELECT_ENABLE_REG, 0); @@ -780,15 +722,16 @@ return probe_irq; } -#endif /* AUTOPROBE_IRQ */ -/* - * Function : void NCR58380_print_options (struct Scsi_Host *instance) +/** + * NCR58380_print_options - show options + * @instance: unused for now + * + * Called by probe code indicating the NCR5380 driver options that + * were selected. At some point this will switch to runtime options + * read from the adapter in question * - * Purpose : called by probe code indicating the NCR5380 driver - * options that were selected. - * - * Inputs : instance, pointer to this instance. Unused. + * Locks: none */ static void __init NCR5380_print_options(struct Scsi_Host *instance) @@ -815,29 +758,25 @@ #ifdef PSEUDO_DMA " PSEUDO DMA" #endif -#ifdef SCSI2 - " SCSI-2" -#endif #ifdef UNSAFE " UNSAFE " #endif ); -#ifdef USLEEP printk(" USLEEP, USLEEP_POLL=%d USLEEP_SLEEP=%d", USLEEP_POLL, USLEEP_SLEEP); -#endif printk(" generic release=%d", NCR5380_PUBLIC_RELEASE); if (((struct NCR5380_hostdata *) instance->hostdata)->flags & FLAG_NCR53C400) { printk(" ncr53c400 release=%d", NCR53C400_PUBLIC_RELEASE); } } -/* - * Function : void NCR5380_print_status (struct Scsi_Host *instance) +/** + * NCR5380_print_status - dump controller info + * @instance: controller to dump * - * Purpose : print commands in the various queues, called from - * NCR5380_abort and NCR5380_debug to aid debugging. + * Print commands in the various queues, called from NCR5380_abort + * and NCR5380_debug to aid debugging. * - * Inputs : instance, pointer to this instance. + * Locks: called functions disable irqs, missing queue lock in proc call */ static void NCR5380_print_status(struct Scsi_Host *instance) @@ -846,16 +785,12 @@ char *start; int len; - printk("NCR5380 : coroutine is%s running.\n", - main_running ? "" : "n't"); + printk("NCR5380 : coroutine is%s running.\n", main_running ? "" : "n't"); -#ifdef NDEBUG - NCR5380_print(instance); - NCR5380_print_phase(instance); -#endif + NCR5380_dprint(NDEBUG_ANY, instance); + NCR5380_dprint_phase(NDEBUG_ANY, instance); - len = NCR5380_proc_info(pr_bfr, &start, 0, sizeof(pr_bfr), - instance->host_no, 0); + len = NCR5380_proc_info(pr_bfr, &start, 0, sizeof(pr_bfr), instance->host_no, 0); pr_bfr[len] = 0; printk("\n%s\n", pr_bfr); } @@ -886,18 +821,14 @@ #ifndef NCR5380_proc_info static #endif -int NCR5380_proc_info( - char *buffer, char **start, off_t offset, - int length, int hostno, int inout) +int NCR5380_proc_info(char *buffer, char **start, off_t offset, int length, int hostno, int inout) { - unsigned long flags; char *pos = buffer; struct Scsi_Host *instance; struct NCR5380_hostdata *hostdata; Scsi_Cmnd *ptr; - for (instance = first_instance; instance && - instance->host_no != hostno; instance = instance->next); + for (instance = first_instance; instance && instance->host_no != hostno; instance = instance->next); if (!instance) return (-ESRCH); hostdata = (struct NCR5380_hostdata *) instance->hostdata; @@ -935,32 +866,27 @@ SPRINTF("IRQ: %d.\n", instance->irq); #ifdef DTC_PUBLIC_RELEASE - SPRINTF("Highwater I/O busy_spin_counts -- write: %d read: %d\n", - dtc_wmaxi, dtc_maxi); + SPRINTF("Highwater I/O busy_spin_counts -- write: %d read: %d\n", dtc_wmaxi, dtc_maxi); #endif #ifdef PAS16_PUBLIC_RELEASE - SPRINTF("Highwater I/O busy_spin_counts -- write: %d read: %d\n", - pas_wmaxi, pas_maxi); + SPRINTF("Highwater I/O busy_spin_counts -- write: %d read: %d\n", pas_wmaxi, pas_maxi); #endif - save_flags(flags); - cli(); + spin_lock_irq(&io_request_lock); SPRINTF("NCR5380 : coroutine is%s running.\n", main_running ? "" : "n't"); if (!hostdata->connected) SPRINTF("scsi%d: no currently connected command\n", instance->host_no); else - pos = lprint_Scsi_Cmnd((Scsi_Cmnd *) hostdata->connected, - pos, buffer, length); + pos = lprint_Scsi_Cmnd((Scsi_Cmnd *) hostdata->connected, pos, buffer, length); SPRINTF("scsi%d: issue_queue\n", instance->host_no); - for (ptr = (Scsi_Cmnd *) hostdata->issue_queue; ptr; - ptr = (Scsi_Cmnd *) ptr->host_scribble) + for (ptr = (Scsi_Cmnd *) hostdata->issue_queue; ptr; ptr = (Scsi_Cmnd *) ptr->host_scribble) pos = lprint_Scsi_Cmnd(ptr, pos, buffer, length); SPRINTF("scsi%d: disconnected_queue\n", instance->host_no); - for (ptr = (Scsi_Cmnd *) hostdata->disconnected_queue; ptr; - ptr = (Scsi_Cmnd *) ptr->host_scribble) + for (ptr = (Scsi_Cmnd *) hostdata->disconnected_queue; ptr; ptr = (Scsi_Cmnd *) ptr->host_scribble) pos = lprint_Scsi_Cmnd(ptr, pos, buffer, length); - restore_flags(flags); + spin_unlock_irq(&io_request_lock); + *start = buffer; if (pos - buffer < offset) return 0; @@ -972,16 +898,14 @@ static char *lprint_Scsi_Cmnd(Scsi_Cmnd * cmd, char *pos, char *buffer, int length) { - SPRINTF("scsi%d : destination target %d, lun %d\n", - cmd->host->host_no, cmd->target, cmd->lun); + SPRINTF("scsi%d : destination target %d, lun %d\n", cmd->host->host_no, cmd->target, cmd->lun); SPRINTF(" command = "); pos = lprint_command(cmd->cmnd, pos, buffer, length); return (pos); } static -char *lprint_command(unsigned char *command, - char *pos, char *buffer, int length) +char *lprint_command(unsigned char *command, char *pos, char *buffer, int length) { int i, s; pos = lprint_opcode(command[0], pos, buffer, length); @@ -999,17 +923,18 @@ } -/* - * Function : void NCR5380_init (struct Scsi_Host *instance, flags) +/** + * NCR5380_init - initialise an NCR5380 + * @instance: adapter to configure + * @flags: control flags * - * Purpose : initializes *instance and corresponding 5380 chip, + * Initializes *instance and corresponding 5380 chip, * with flags OR'd into the initial flags value. * - * Inputs : instance - instantiation of the 5380 driver. - * - * Notes : I assume that the host, hostno, and id bits have been + * Notes : I assume that the host, hostno, and id bits have been * set correctly. I don't care about the irq and other fields. - * + * + * Locks: interrupts must be enabled when we are called */ static void __init NCR5380_init(struct Scsi_Host *instance, int flags) @@ -1017,9 +942,10 @@ NCR5380_local_declare(); int i, pass; unsigned long timeout; - struct NCR5380_hostdata *hostdata = (struct NCR5380_hostdata *) - instance->hostdata; + struct NCR5380_hostdata *hostdata = (struct NCR5380_hostdata *) instance->hostdata; + if(in_interrupt()) + printk(KERN_ERR "NCR5380_init called with interrupts off!\n"); /* * On NCR53C400 boards, NCR5380 registers are mapped 8 past * the base address. @@ -1031,7 +957,6 @@ #endif NCR5380_setup(instance); - NCR5380_all_init(); hostdata->aborted = 0; @@ -1070,17 +995,13 @@ the_template = instance->hostt; first_instance = instance; } -#ifdef USLEEP hostdata->time_expires = 0; hostdata->next_timer = NULL; -#endif #ifndef AUTOSENSE if ((instance->cmd_per_lun > 1) || instance->can_queue > 1) - ) - printk("scsi%d : WARNING : support for multiple outstanding commands enabled\n" - " without AUTOSENSE option, contingent allegiance conditions may\n" - " be incorrectly cleared.\n", instance->host_no); + printk(KERN_WARNING "scsi%d : WARNING : support for multiple outstanding commands enabled\n" " without AUTOSENSE option, contingent allegiance conditions may\n" + " be incorrectly cleared.\n", instance->host_no); #endif /* def AUTOSENSE */ NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE); @@ -1106,50 +1027,40 @@ * failing, do a hard reset of the SCSI bus */ - for (pass = 1; (NCR5380_read(STATUS_REG) & SR_BSY) && - pass <= 6; ++pass) { + for (pass = 1; (NCR5380_read(STATUS_REG) & SR_BSY) && pass <= 6; ++pass) { switch (pass) { case 1: case 3: case 5: - printk("scsi%d: SCSI bus busy, waiting up to five seconds\n", - instance->host_no); + printk("scsi%d: SCSI bus busy, waiting up to five seconds\n", instance->host_no); timeout = jiffies + 5 * HZ; - while (time_before(jiffies,timeout) && (NCR5380_read(STATUS_REG) & SR_BSY)); + while (time_before(jiffies, timeout) && (NCR5380_read(STATUS_REG) & SR_BSY)); break; case 2: - printk("scsi%d: bus busy, attempting abort\n", - instance->host_no); + printk("scsi%d: bus busy, attempting abort\n", instance->host_no); do_abort(instance); break; case 4: - printk("scsi%d: bus busy, attempting reset\n", - instance->host_no); + printk("scsi%d: bus busy, attempting reset\n", instance->host_no); do_reset(instance); break; case 6: - printk("scsi%d: bus locked solid or invalid override\n", - instance->host_no); + printk("scsi%d: bus locked solid or invalid override\n", instance->host_no); } } } -/* - * Function : int NCR5380_queue_command (Scsi_Cmnd *cmd, - * void (*done)(Scsi_Cmnd *)) - * - * Purpose : enqueues a SCSI command +/** + * NCR5380_queue_command - queue a command + * @cmd: SCSI command + * @done: completion handler * - * Inputs : cmd - SCSI command, done - function called on completion, with - * a pointer to the command descriptor. - * - * Returns : 0 - * - * Side effects : * cmd is added to the per instance issue_queue, with minor * twiddling done to the host specific fields of cmd. If the * main coroutine is not running, it is restarted. * + * Locks: io_request lock held by caller. Called functions drop and + * retake this lock. Called functions take dma lock. */ /* Only make static if a wrapper function is used */ @@ -1158,16 +1069,14 @@ #endif int NCR5380_queue_command(Scsi_Cmnd * cmd, void (*done) (Scsi_Cmnd *)) { struct Scsi_Host *instance = cmd->host; - struct NCR5380_hostdata *hostdata = (struct NCR5380_hostdata *) - instance->hostdata; + struct NCR5380_hostdata *hostdata = (struct NCR5380_hostdata *) instance->hostdata; Scsi_Cmnd *tmp; #if (NDEBUG & NDEBUG_NO_WRITE) switch (cmd->cmnd[0]) { - case WRITE_6: - case WRITE_10: - printk("scsi%d : WRITE attempted with NO_WRITE debugging flag set\n", - instance->host_no); + case WRITE_6: + case WRITE_10: + printk("scsi%d : WRITE attempted with NO_WRITE debugging flag set\n", instance->host_no); cmd->result = (DID_ERROR << 16); done(cmd); return 0; @@ -1175,31 +1084,22 @@ #endif /* (NDEBUG & NDEBUG_NO_WRITE) */ #ifdef NCR5380_STATS -#if 0 - if (!hostdata->connected && !hostdata->issue_queue && - !hostdata->disconnected_queue) { - hostdata->timebase = jiffies; - } -#endif -#ifdef NCR5380_STAT_LIMIT - if (cmd->request_bufflen > NCR5380_STAT_LIMIT) -#endif - switch (cmd->cmnd[0]) { - case WRITE: - case WRITE_6: - case WRITE_10: - hostdata->time_write[cmd->target] -= (jiffies - hostdata->timebase); + switch (cmd->cmnd[0]) { + case WRITE: + case WRITE_6: + case WRITE_10: + hostdata->time_write[cmd->target] -= (jiffies - hostdata->timebase); hostdata->bytes_write[cmd->target] += cmd->request_bufflen; hostdata->pendingw++; break; - case READ: - case READ_6: - case READ_10: - hostdata->time_read[cmd->target] -= (jiffies - hostdata->timebase); + case READ: + case READ_6: + case READ_10: + hostdata->time_read[cmd->target] -= (jiffies - hostdata->timebase); hostdata->bytes_read[cmd->target] += cmd->request_bufflen; hostdata->pendingr++; break; - } + } #endif /* @@ -1209,10 +1109,8 @@ cmd->host_scribble = NULL; cmd->scsi_done = done; - cmd->result = 0; - /* * Insert the cmd into the issue queue. Note that REQUEST SENSE * commands are added to the head of the queue since any command will @@ -1225,31 +1123,28 @@ cmd->host_scribble = (unsigned char *) hostdata->issue_queue; hostdata->issue_queue = cmd; } else { - for (tmp = (Scsi_Cmnd *) hostdata->issue_queue; tmp->host_scribble; - tmp = (Scsi_Cmnd *) tmp->host_scribble); + for (tmp = (Scsi_Cmnd *) hostdata->issue_queue; tmp->host_scribble; tmp = (Scsi_Cmnd *) tmp->host_scribble); LIST(cmd, tmp); tmp->host_scribble = (unsigned char *) cmd; } -#if (NDEBUG & NDEBUG_QUEUES) - printk("scsi%d : command added to %s of queue\n", instance->host_no, - (cmd->cmnd[0] == REQUEST_SENSE) ? "head" : "tail"); -#endif + dprintk(NDEBUG_QUEUES, ("scsi%d : command added to %s of queue\n", instance->host_no, (cmd->cmnd[0] == REQUEST_SENSE) ? "head" : "tail")); -/* Run the coroutine if it isn't already running. */ + /* Run the coroutine if it isn't already running. */ run_main(); return 0; } -/* - * Function : NCR5380_main (void) +/** + * NCR5380_main - NCR state machines * - * Purpose : NCR5380_main is a coroutine that runs as long as more work can + * NCR5380_main is a coroutine that runs as long as more work can * be done on the NCR5380 host adapters in a system. Both * NCR5380_queue_command() and NCR5380_intr() will try to start it * in case it is not running. * - * NOTE : NCR5380_main exits with interrupts *disabled*, the caller should - * reenable them. This prevents reentrancy and kernel stack overflow. + * Locks; The caller must hold the io_request_lock. The lock will still be + * held on return but may be dropped while running. Called functions take + * the DMA lock. */ static void NCR5380_main(void) { @@ -1257,7 +1152,6 @@ struct Scsi_Host *instance; struct NCR5380_hostdata *hostdata; int done; - unsigned long flags; /* * We run (with interrupts disabled) until we're sure that none of @@ -1271,43 +1165,22 @@ * this should prevent any race conditions. */ - spin_unlock_irq(&io_request_lock); - - save_flags(flags); - do { - cli(); /* Freeze request queues */ + /* Lock held here */ done = 1; - for (instance = first_instance; instance && - instance->hostt == the_template; instance = instance->next) { - hostdata = (struct NCR5380_hostdata *) instance->hostdata; - cli(); -#ifdef USLEEP + for (instance = first_instance; instance && instance->hostt == the_template; instance = instance->next) { + hostdata = (struct NCR5380_hostdata *) instance->hostdata; + /* Lock held here */ if (!hostdata->connected && !hostdata->selecting) { -#else - if (!hostdata->connected) { -#endif -#if (NDEBUG & NDEBUG_MAIN) - printk("scsi%d : not connected\n", instance->host_no); -#endif + dprintk(NDEBUG_MAIN, ("scsi%d : not connected\n", instance->host_no)); /* * Search through the issue_queue for a command destined * for a target that's not busy. */ -#if (NDEBUG & NDEBUG_LISTS) - for (tmp = (Scsi_Cmnd *) hostdata->issue_queue, prev = NULL; tmp && (tmp != prev); prev = tmp, tmp = (Scsi_Cmnd *) tmp->host_scribble); - /*printk("%p ", tmp); */ - if ((tmp == prev) && tmp) - printk(" LOOP\n"); /* else printk("\n"); */ -#endif - for (tmp = (Scsi_Cmnd *) hostdata->issue_queue, - prev = NULL; tmp; prev = tmp, tmp = (Scsi_Cmnd *) - tmp->host_scribble) { - -#if (NDEBUG & NDEBUG_LISTS) + for (tmp = (Scsi_Cmnd *) hostdata->issue_queue, prev = NULL; tmp; prev = tmp, tmp = (Scsi_Cmnd *) tmp->host_scribble) + { if (prev != tmp) - printk("MAIN tmp=%p target=%d busy=%d lun=%d\n", tmp, tmp->target, hostdata->busy[tmp->target], tmp->lun); -#endif + dprintk(NDEBUG_LISTS, ("MAIN tmp=%p target=%d busy=%d lun=%d\n", tmp, tmp->target, hostdata->busy[tmp->target], tmp->lun)); /* When we find one, remove it from the issue queue. */ if (!(hostdata->busy[tmp->target] & (1 << tmp->lun))) { if (prev) { @@ -1319,8 +1192,6 @@ } tmp->host_scribble = NULL; - /* reenable interrupts after finding one */ - restore_flags(flags); /* * Attempt to establish an I_T_L nexus here. @@ -1328,10 +1199,7 @@ * On failure, we must add the command back to the * issue queue so we can keep trying. */ -#if (NDEBUG & (NDEBUG_MAIN | NDEBUG_QUEUES)) - printk("scsi%d : main() : command for target %d lun %d removed from issue_queue\n", - instance->host_no, tmp->target, tmp->lun); -#endif + dprintk(NDEBUG_MAIN|NDEBUG_QUEUES, ("scsi%d : main() : command for target %d lun %d removed from issue_queue\n", instance->host_no, tmp->target, tmp->lun)); /* * A successful selection is defined as one that @@ -1343,105 +1211,81 @@ * and see if we can do an information transfer, * with failures we will restart. */ -#ifdef USLEEP - hostdata->selecting = 0; /* RvC: have to preset this - to indicate a new command is being performed */ -#endif + hostdata->selecting = 0; + /* RvC: have to preset this to indicate a new command is being performed */ if (!NCR5380_select(instance, tmp, - /* - * REQUEST SENSE commands are issued without tagged - * queueing, even on SCSI-II devices because the - * contingent allegiance condition exists for the - * entire unit. - */ - (tmp->cmnd[0] == REQUEST_SENSE) ? TAG_NONE : - TAG_NEXT)) { + /* + * REQUEST SENSE commands are issued without tagged + * queueing, even on SCSI-II devices because the + * contingent allegiance condition exists for the + * entire unit. + */ + (tmp->cmnd[0] == REQUEST_SENSE) ? TAG_NONE : TAG_NEXT)) { break; } else { - cli(); LIST(tmp, hostdata->issue_queue); - tmp->host_scribble = (unsigned char *) - hostdata->issue_queue; + tmp->host_scribble = (unsigned char *) hostdata->issue_queue; hostdata->issue_queue = tmp; done = 0; - restore_flags(flags); -#if (NDEBUG & (NDEBUG_MAIN | NDEBUG_QUEUES)) - printk("scsi%d : main(): select() failed, returned to issue_queue\n", - instance->host_no); -#endif + dprintk(NDEBUG_MAIN|NDEBUG_QUEUES, ("scsi%d : main(): select() failed, returned to issue_queue\n", instance->host_no)); } + /* lock held here still */ } /* if target/lun is not busy */ } /* for */ + /* exited locked */ } /* if (!hostdata->connected) */ -#ifdef USLEEP - if (hostdata->selecting) - { - tmp = (Scsi_Cmnd *)hostdata->selecting; - if (!NCR5380_select(instance, tmp, - (tmp->cmnd[0] == REQUEST_SENSE) ? TAG_NONE : TAG_NEXT)) - { + if (hostdata->selecting) { + tmp = (Scsi_Cmnd *) hostdata->selecting; + /* Selection will drop and retake the lock */ + if (!NCR5380_select(instance, tmp, (tmp->cmnd[0] == REQUEST_SENSE) ? TAG_NONE : TAG_NEXT)) { /* Ok ?? */ - } - else - { + } else { /* RvC: device failed, so we wait a long time - this is needed for Mustek scanners, that - do not respond to commands immediately - after a scan */ - printk(KERN_DEBUG "scsi%d: device %d did not respond in time\n", - instance->host_no, tmp->target); - cli(); + this is needed for Mustek scanners, that + do not respond to commands immediately + after a scan */ + printk(KERN_DEBUG "scsi%d: device %d did not respond in time\n", instance->host_no, tmp->target); + //spin_lock_irq(&io_request_lock); LIST(tmp, hostdata->issue_queue); tmp->host_scribble = (unsigned char *) hostdata->issue_queue; hostdata->issue_queue = tmp; - restore_flags(flags); + //spin_unlock_irq(&io_request_lock); hostdata->time_expires = jiffies + USLEEP_WAITLONG; - NCR5380_set_timer (instance); + NCR5380_set_timer(instance); } - } /* if hostdata->selecting */ -#endif + } /* if hostdata->selecting */ if (hostdata->connected #ifdef REAL_DMA && !hostdata->dmalen #endif -#ifdef USLEEP && (!hostdata->time_expires || time_before_eq(hostdata->time_expires, jiffies)) -#endif ) { - restore_flags(flags); -#if (NDEBUG & NDEBUG_MAIN) - printk("scsi%d : main() : performing information transfer\n", - instance->host_no); -#endif + dprintk(NDEBUG_MAIN, ("scsi%d : main() : performing information transfer\n", instance->host_no)); NCR5380_information_transfer(instance); -#if (NDEBUG & NDEBUG_MAIN) - printk("scsi%d : main() : done set false\n", instance->host_no); -#endif + dprintk(NDEBUG_MAIN, ("scsi%d : main() : done set false\n", instance->host_no)); done = 0; } else break; } /* for instance */ } while (!done); - spin_lock_irq(&io_request_lock); - /* cli();*/ - main_running = 0; + /* Exit lock held */ + clear_bit(0, &main_running); } #ifndef DONT_USE_INTR #include <linux/blk.h> #include <linux/spinlock.h> -/* - * Function : void NCR5380_intr (int irq) - * - * Purpose : handle interrupts, reestablishing I_T_L or I_T_L_Q nexuses +/** + * NCR5380_intr - generic NCR5380 irq handler + * + * Handle interrupts, reestablishing I_T_L or I_T_L_Q nexuses * from the disconnected queue, and restarting NCR5380_main() * as required. * - * Inputs : int irq, irq that caused this interrupt. - * + * Locks: caller must hold the io_request lock. */ static void NCR5380_intr(int irq, void *dev_id, struct pt_regs *regs) { @@ -1449,17 +1293,12 @@ struct Scsi_Host *instance; int done; unsigned char basr; - unsigned long flags; - save_flags(flags); - cli(); -#if (NDEBUG & NDEBUG_INTR) - printk("scsi : NCR5380 irq %d triggered\n", irq); -#endif + dprintk(NDEBUG_INTR, ("scsi : NCR5380 irq %d triggered\n", irq)); + do { done = 1; - for (instance = first_instance; instance && (instance->hostt == - the_template); instance = instance->next) + for (instance = first_instance; instance && (instance->hostt == the_template); instance = instance->next) if (instance->irq == irq) { /* Look for pending interrupts */ @@ -1467,34 +1306,19 @@ basr = NCR5380_read(BUS_AND_STATUS_REG); /* XXX dispatch to appropriate routine if found and done=0 */ if (basr & BASR_IRQ) { -#if (NDEBUG & NDEBUG_INTR) - NCR5380_print(instance); -#endif - if ((NCR5380_read(STATUS_REG) & (SR_SEL | SR_IO)) == - (SR_SEL | SR_IO)) { + NCR5380_dprint(NDEBUG_INTR, instance); + if ((NCR5380_read(STATUS_REG) & (SR_SEL | SR_IO)) == (SR_SEL | SR_IO)) { done = 0; - restore_flags(flags); -#if (NDEBUG & NDEBUG_INTR) - printk("scsi%d : SEL interrupt\n", instance->host_no); -#endif + dprintk(NDEBUG_INTR, ("scsi%d : SEL interrupt\n", instance->host_no)); NCR5380_reselect(instance); (void) NCR5380_read(RESET_PARITY_INTERRUPT_REG); } else if (basr & BASR_PARITY_ERROR) { -#if (NDEBUG & NDEBUG_INTR) - printk("scsi%d : PARITY interrupt\n", instance->host_no); -#endif + dprintk(NDEBUG_INTR, ("scsi%d : PARITY interrupt\n", instance->host_no)); (void) NCR5380_read(RESET_PARITY_INTERRUPT_REG); } else if ((NCR5380_read(STATUS_REG) & SR_RST) == SR_RST) { -#if (NDEBUG & NDEBUG_INTR) - printk("scsi%d : RESET interrupt\n", instance->host_no); -#endif + dprintk(NDEBUG_INTR, ("scsi%d : RESET interrupt\n", instance->host_no)); (void) NCR5380_read(RESET_PARITY_INTERRUPT_REG); } else { -/* - * XXX the rest of the interrupt conditions should *only* occur during a - * DMA transfer, which I haven't gotten around to fixing yet. - */ - #if defined(REAL_DMA) /* * We should only get PHASE MISMATCH and EOP interrupts @@ -1502,14 +1326,11 @@ * the current setting of the MODE register. */ - if ((NCR5380_read(MODE_REG) & MR_DMA) && ((basr & - BASR_END_DMA_TRANSFER) || - !(basr & BASR_PHASE_MATCH))) { + if ((NCR5380_read(MODE_REG) & MR_DMA) && ((basr & BASR_END_DMA_TRANSFER) || !(basr & BASR_PHASE_MATCH))) { int transfered; if (!hostdata->connected) - panic("scsi%d : received end of DMA interrupt with no connected cmd\n", - instance->hostno); + panic("scsi%d : received end of DMA interrupt with no connected cmd\n", instance->hostno); transfered = (hostdata->dmalen - NCR5380_dma_residual(instance)); hostdata->connected->SCp.this_residual -= transferred; @@ -1522,15 +1343,13 @@ unsigned long timeout = jiffies + NCR_TIMEOUT; spin_unlock_irq(&io_request_lock); - while (NCR5380_read(BUS_AND_STATUS_REG) & BASR_ACK - && time_before(jiffies, timeout)); + while (NCR5380_read(BUS_AND_STATUS_REG) & BASR_ACK && time_before(jiffies, timeout)); spin_lock_irq(&io_request_lock); - - if (time_after_eq(jiffies, timeout) ) - printk("scsi%d: timeout at NCR5380.c:%d\n", - host->host_no, __LINE__); + + if (time_after_eq(jiffies, timeout)) + printk("scsi%d: timeout at NCR5380.c:%d\n", host->host_no, __LINE__); } -#else /* NCR_TIMEOUT */ +#else /* NCR_TIMEOUT */ while (NCR5380_read(BUS_AND_STATUS_REG) & BASR_ACK); #endif @@ -1538,9 +1357,7 @@ NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE); } #else -#if (NDEBUG & NDEBUG_INTR) - printk("scsi : unknown interrupt, BASR 0x%X, MR 0x%X, SR 0x%x\n", basr, NCR5380_read(MODE_REG), NCR5380_read(STATUS_REG)); -#endif + dprintk(NDEBUG_INTR, ("scsi : unknown interrupt, BASR 0x%X, MR 0x%X, SR 0x%x\n", basr, NCR5380_read(MODE_REG), NCR5380_read(STATUS_REG))); (void) NCR5380_read(RESET_PARITY_INTERRUPT_REG); #endif } @@ -1551,6 +1368,17 @@ } while (!done); } +/** + * do_NCR5380_intr + * @irq: interrupt number + * @dev_id: device info + * @regs: registers (unused) + * + * Takes the io_request_lock and invokes the generic NCR5380 interrupt + * handler code + * + * Locks: takes and releases the io_request lock + */ static void do_NCR5380_intr(int irq, void *dev_id, struct pt_regs *regs) { unsigned long flags; @@ -1559,32 +1387,38 @@ NCR5380_intr(irq, dev_id, regs); spin_unlock_irqrestore(&io_request_lock, flags); } - #endif + +/** + * collect_stats - collect stats on a scsi command + * @hostdata: adapter + * @cmd: command being issued + * + * Update the statistical data by parsing the command in question + */ + +static void collect_stats(struct NCR5380_hostdata *hostdata, Scsi_Cmnd * cmd) +{ #ifdef NCR5380_STATS -static void collect_stats(struct NCR5380_hostdata *hostdata, Scsi_Cmnd * cmd) { -#ifdef NCR5380_STAT_LIMIT - if (cmd->request_bufflen > NCR5380_STAT_LIMIT) -#endif - switch (cmd->cmnd[0]) { - case WRITE: - case WRITE_6: - case WRITE_10: - hostdata->time_write[cmd->target] += (jiffies - hostdata->timebase); - /*hostdata->bytes_write[cmd->target] += cmd->request_bufflen; */ - hostdata->pendingw--; - break; - case READ: - case READ_6: - case READ_10: - hostdata->time_read[cmd->target] += (jiffies - hostdata->timebase); - /*hostdata->bytes_read[cmd->target] += cmd->request_bufflen; */ - hostdata->pendingr--; - break; - } -} + switch (cmd->cmnd[0]) { + case WRITE: + case WRITE_6: + case WRITE_10: + hostdata->time_write[cmd->target] += (jiffies - hostdata->timebase); + hostdata->pendingw--; + break; + case READ: + case READ_6: + case READ_10: + hostdata->time_read[cmd->target] += (jiffies - hostdata->timebase); + hostdata->pendingr--; + break; + } #endif +} + + /* * Function : int NCR5380_select (struct Scsi_Host *instance, Scsi_Cmnd *cmd, * int tag); @@ -1614,55 +1448,44 @@ * * If failed (no target) : cmd->scsi_done() will be called, and the * cmd->result host byte set to DID_BAD_TARGET. + * + * Locks: caller holds io_request_lock */ -static int NCR5380_select(struct Scsi_Host *instance, Scsi_Cmnd * cmd, int tag) { + +static int NCR5380_select(struct Scsi_Host *instance, Scsi_Cmnd * cmd, int tag) +{ NCR5380_local_declare(); struct NCR5380_hostdata *hostdata = (struct NCR5380_hostdata *) instance->hostdata; unsigned char tmp[3], phase; unsigned char *data; int len; unsigned long timeout; - unsigned long flags; -#ifdef USLEEP unsigned char value; -#endif - NCR5380_setup(instance); -#ifdef USLEEP - - if (hostdata->selecting) - { + if (hostdata->selecting) { goto part2; /* RvC: sorry prof. Dijkstra, but it keeps the rest of the code nearly the same */ } -#endif - hostdata->restart_select = 0; -#if defined (NDEBUG) && (NDEBUG & NDEBUG_ARBITRATION) - NCR5380_print(instance); - printk("scsi%d : starting arbitration, id = %d\n", instance->host_no, - instance->this_id); -#endif - save_flags(flags); - cli(); + hostdata->restart_select = 0; + + NCR5380_dprint(NDEBUG_ARBITRATION, instance); + dprintk(NDEBUG_ARBITRATION, ("scsi%d : starting arbitration, id = %d\n", instance->host_no, instance->this_id)); /* * Set the phase bits to 0, otherwise the NCR5380 won't drive the * data bus during SELECTION. */ - NCR5380_write(TARGET_COMMAND_REG, 0); - + NCR5380_write(TARGET_COMMAND_REG, 0); /* * Start arbitration. */ - NCR5380_write(OUTPUT_DATA_REG, hostdata->id_mask); - NCR5380_write(MODE_REG, MR_ARBITRATE); - - restore_flags(flags); + NCR5380_write(OUTPUT_DATA_REG, hostdata->id_mask); + NCR5380_write(MODE_REG, MR_ARBITRATE); /* Wait for arbitration logic to complete */ #if NCR_TIMEOUT @@ -1672,11 +1495,11 @@ spin_unlock_irq(&io_request_lock); while (!(NCR5380_read(INITIATOR_COMMAND_REG) & ICR_ARBITRATION_PROGRESS) - && time_before(jiffies,timeout)); + && time_before(jiffies, timeout)); spin_lock_irq(&io_request_lock); - - if (time_after_eq(jiffies,timeout)) { + + if (time_after_eq(jiffies, timeout)) { printk("scsi: arbitration timeout at %d\n", __LINE__); NCR5380_write(MODE_REG, MR_BASE); NCR5380_write(SELECT_ENABLE_REG, hostdata->id_mask); @@ -1687,11 +1510,7 @@ while (!(NCR5380_read(INITIATOR_COMMAND_REG) & ICR_ARBITRATION_PROGRESS)); #endif -#if (NDEBUG & NDEBUG_ARBITRATION) - printk("scsi%d : arbitration complete\n", instance->host_no); -/* Avoid GCC 2.4.5 asm needs to many reloads error */ - __asm__("nop"); -#endif + dprintk(NDEBUG_ARBITRATION, ("scsi%d : arbitration complete\n", instance->host_no)); /* * The arbitration delay is 2.2us, but this is a minimum and there is @@ -1700,34 +1519,25 @@ * */ - udelay(3); + udelay(3); /* Check for lost arbitration */ - if ((NCR5380_read(INITIATOR_COMMAND_REG) & ICR_ARBITRATION_LOST) || - (NCR5380_read(CURRENT_SCSI_DATA_REG) & hostdata->id_higher_mask) || - (NCR5380_read(INITIATOR_COMMAND_REG) & ICR_ARBITRATION_LOST)) { + if ((NCR5380_read(INITIATOR_COMMAND_REG) & ICR_ARBITRATION_LOST) || (NCR5380_read(CURRENT_SCSI_DATA_REG) & hostdata->id_higher_mask) || (NCR5380_read(INITIATOR_COMMAND_REG) & ICR_ARBITRATION_LOST)) { NCR5380_write(MODE_REG, MR_BASE); -#if (NDEBUG & NDEBUG_ARBITRATION) - printk("scsi%d : lost arbitration, deasserting MR_ARBITRATE\n", - instance->host_no); -#endif + dprintk(NDEBUG_ARBITRATION, ("scsi%d : lost arbitration, deasserting MR_ARBITRATE\n", instance->host_no)); return -1; } NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE | ICR_ASSERT_SEL); if (!(hostdata->flags & FLAG_DTC3181E) && - /* RvC: DTC3181E has some trouble with this - * so we simply removed it. Seems to work with - * only Mustek scanner attached - */ - (NCR5380_read(INITIATOR_COMMAND_REG) & ICR_ARBITRATION_LOST)) - { + /* RvC: DTC3181E has some trouble with this + * so we simply removed it. Seems to work with + * only Mustek scanner attached + */ + (NCR5380_read(INITIATOR_COMMAND_REG) & ICR_ARBITRATION_LOST)) { NCR5380_write(MODE_REG, MR_BASE); NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE); -#if (NDEBUG & NDEBUG_ARBITRATION) - printk("scsi%d : lost arbitration, deasserting ICR_ASSERT_SEL\n", - instance->host_no); -#endif + dprintk(NDEBUG_ARBITRATION, ("scsi%d : lost arbitration, deasserting ICR_ASSERT_SEL\n", instance->host_no)); return -1; } /* @@ -1737,10 +1547,7 @@ udelay(2); -#if (NDEBUG & NDEBUG_ARBITRATION) - printk("scsi%d : won arbitration\n", instance->host_no); -#endif - + dprintk(NDEBUG_ARBITRATION, ("scsi%d : won arbitration\n", instance->host_no)); /* * Now that we have won arbitration, start Selection process, asserting @@ -1755,8 +1562,7 @@ * phase immediately after selection. */ - NCR5380_write(INITIATOR_COMMAND_REG, (ICR_BASE | ICR_ASSERT_BSY | - ICR_ASSERT_DATA | ICR_ASSERT_ATN | ICR_ASSERT_SEL)); + NCR5380_write(INITIATOR_COMMAND_REG, (ICR_BASE | ICR_ASSERT_BSY | ICR_ASSERT_DATA | ICR_ASSERT_ATN | ICR_ASSERT_SEL)); NCR5380_write(MODE_REG, MR_BASE); /* @@ -1772,8 +1578,7 @@ udelay(1); /* wingel -- wait two bus deskew delay >2*45ns */ /* Reset BSY */ - NCR5380_write(INITIATOR_COMMAND_REG, (ICR_BASE | ICR_ASSERT_DATA | - ICR_ASSERT_ATN | ICR_ASSERT_SEL)); + NCR5380_write(INITIATOR_COMMAND_REG, (ICR_BASE | ICR_ASSERT_DATA | ICR_ASSERT_ATN | ICR_ASSERT_SEL)); /* * Something weird happens when we cease to drive BSY - looks @@ -1794,9 +1599,7 @@ udelay(1); -#if (NDEBUG & NDEBUG_SELECTION) - printk("scsi%d : selecting target %d\n", instance->host_no, cmd->target); -#endif + dprintk(NDEBUG_SELECTION, ("scsi%d : selecting target %d\n", instance->host_no, cmd->target)); /* * The SCSI specification calls for a 250 ms timeout for the actual @@ -1811,40 +1614,30 @@ * and it's detecting as true. Sigh. */ -#ifdef USLEEP - hostdata->select_time = 0; /* we count the clock ticks at which we polled */ + hostdata->select_time = 0; /* we count the clock ticks at which we polled */ hostdata->selecting = cmd; part2: - /* RvC: here we enter after a sleeping period, or immediately after - execution of part 1 - we poll only once ech clock tick */ + /* RvC: here we enter after a sleeping period, or immediately after + execution of part 1 + we poll only once ech clock tick */ value = NCR5380_read(STATUS_REG) & (SR_BSY | SR_IO); - if (!value && (hostdata->select_time < 25)) - { + if (!value && (hostdata->select_time < 25)) { /* RvC: we still must wait for a device response */ - hostdata->select_time++; /* after 25 ticks the device has failed */ + hostdata->select_time++; /* after 25 ticks the device has failed */ hostdata->time_expires = jiffies + 1; NCR5380_set_timer(instance); return 0; /* RvC: we return here with hostdata->selecting set, to go to sleep */ } - hostdata->selecting = 0; /* clear this pointer, because we passed the - waiting period */ -#else - spin_unlock_irq(&io_request_lock); - while (time_before(jiffies, timeout) && !(NCR5380_read(STATUS_REG) & - (SR_BSY | SR_IO))); - spin_lock_irq(&io_request_lock); -#endif - if ((NCR5380_read(STATUS_REG) & (SR_SEL | SR_IO)) == - (SR_SEL | SR_IO)) { + hostdata->selecting = 0; /* clear this pointer, because we passed the + waiting period */ + if ((NCR5380_read(STATUS_REG) & (SR_SEL | SR_IO)) == (SR_SEL | SR_IO)) { NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE); NCR5380_reselect(instance); - printk("scsi%d : reselection after won arbitration?\n", - instance->host_no); + printk("scsi%d : reselection after won arbitration?\n", instance->host_no); NCR5380_write(SELECT_ENABLE_REG, hostdata->id_mask); return -1; } @@ -1864,22 +1657,15 @@ printk("scsi%d : weirdness\n", instance->host_no); if (hostdata->restart_select) printk("\trestart select\n"); -#if (NDEBUG & NDEBUG_SELECTION) - NCR5380_print(instance); -#endif + NCR5380_dprint(NDEBUG_SELECTION, instance); NCR5380_write(SELECT_ENABLE_REG, hostdata->id_mask); return -1; } cmd->result = DID_BAD_TARGET << 16; -#ifdef NCR5380_STATS collect_stats(hostdata, cmd); -#endif cmd->scsi_done(cmd); NCR5380_write(SELECT_ENABLE_REG, hostdata->id_mask); -#if (NDEBUG & NDEBUG_SELECTION) - printk("scsi%d : target did not respond within 250ms\n", - instance->host_no); -#endif + dprintk(NDEBUG_SELECTION, ("scsi%d : target did not respond within 250ms\n", instance->host_no)); NCR5380_write(SELECT_ENABLE_REG, hostdata->id_mask); return 0; } @@ -1908,7 +1694,7 @@ spin_unlock_irq(&io_request_lock); while (!(NCR5380_read(STATUS_REG) & SR_REQ) && time_before(jiffies, timeout)); spin_lock_irq(&io_request_lock); - + if (time_after_eq(jiffies, timeout)) { printk("scsi%d: timeout at NCR5380.c:%d\n", instance->host_no, __LINE__); NCR5380_write(SELECT_ENABLE_REG, hostdata->id_mask); @@ -1919,47 +1705,20 @@ while (!(NCR5380_read(STATUS_REG) & SR_REQ)); #endif /* def NCR_TIMEOUT */ -#if (NDEBUG & NDEBUG_SELECTION) - printk("scsi%d : target %d selected, going into MESSAGE OUT phase.\n", - instance->host_no, cmd->target); -#endif + dprintk(NDEBUG_SELECTION, ("scsi%d : target %d selected, going into MESSAGE OUT phase.\n", instance->host_no, cmd->target)); tmp[0] = IDENTIFY(((instance->irq == IRQ_NONE) ? 0 : 1), cmd->lun); -#ifdef SCSI2 - if (cmd->device->tagged_queue && (tag != TAG_NONE)) { - tmp[1] = SIMPLE_QUEUE_TAG; - if (tag == TAG_NEXT) { - /* 0 is TAG_NONE, used to imply no tag for this command */ - if (cmd->device->current_tag == 0) - cmd->device->current_tag = 1; - - cmd->tag = cmd->device->current_tag; - cmd->device->current_tag++; - } else - cmd->tag = (unsigned char) tag; - - tmp[2] = cmd->tag; - hostdata->last_message = SIMPLE_QUEUE_TAG; - len = 3; - } else -#endif /* def SCSI2 */ - { - len = 1; - cmd->tag = 0; - } + + len = 1; + cmd->tag = 0; /* Send message(s) */ data = tmp; phase = PHASE_MSGOUT; NCR5380_transfer_pio(instance, &phase, &len, &data); -#if (NDEBUG & NDEBUG_SELECTION) - printk("scsi%d : nexus established.\n", instance->host_no); -#endif + dprintk(NDEBUG_SELECTION, ("scsi%d : nexus established.\n", instance->host_no)); /* XXX need to handle errors here */ hostdata->connected = cmd; -#ifdef SCSI2 - if (!cmd->device->tagged_queue) -#endif - hostdata->busy[cmd->target] |= (1 << cmd->lun); + hostdata->busy[cmd->target] |= (1 << cmd->lun); initialize_SCp(cmd); @@ -1992,27 +1751,22 @@ * counts, we will always do a pseudo DMA or DMA transfer. */ -static int NCR5380_transfer_pio(struct Scsi_Host *instance, - unsigned char *phase, int *count, unsigned char **data) { +static int NCR5380_transfer_pio(struct Scsi_Host *instance, unsigned char *phase, int *count, unsigned char **data) { NCR5380_local_declare(); - register unsigned char p = *phase, tmp; - register int c = *count; - register unsigned char *d = *data; -#ifdef USLEEP + unsigned char p = *phase, tmp; + int c = *count; + unsigned char *d = *data; /* - * RvC: some administrative data to process polling time + * RvC: some administrative data to process polling time */ int break_allowed = 0; struct NCR5380_hostdata *hostdata = (struct NCR5380_hostdata *) instance->hostdata; -#endif NCR5380_setup(instance); -#if (NDEBUG & NDEBUG_PIO) if (!(p & SR_IO)) - printk("scsi%d : pio write %d bytes\n", instance->host_no, c); + dprintk(NDEBUG_PIO, ("scsi%d : pio write %d bytes\n", instance->host_no, c)); else - printk("scsi%d : pio read %d bytes\n", instance->host_no, c); -#endif + dprintk(NDEBUG_PIO, ("scsi%d : pio read %d bytes\n", instance->host_no, c)); /* * The NCR5380 chip will only drive the SCSI bus when the @@ -2022,56 +1776,42 @@ NCR5380_write(TARGET_COMMAND_REG, PHASE_SR_TO_TCR(p)); -#ifdef USLEEP /* RvC: don't know if this is necessary, but other SCSI I/O is short - * so breaks are not necessary there + * so breaks are not necessary there */ - if ((p == PHASE_DATAIN) || (p == PHASE_DATAOUT)) - { + if ((p == PHASE_DATAIN) || (p == PHASE_DATAOUT)) { break_allowed = 1; } -#endif - - do { /* * Wait for assertion of REQ, after which the phase bits will be * valid */ -#ifdef USLEEP /* RvC: we simply poll once, after that we stop temporarily - * and let the device buffer fill up - * if breaking is not allowed, we keep polling as long as needed + * and let the device buffer fill up + * if breaking is not allowed, we keep polling as long as needed */ - while ( !((tmp = NCR5380_read(STATUS_REG)) & SR_REQ) && - !break_allowed ); - if (!(tmp & SR_REQ)) - { + while (!((tmp = NCR5380_read(STATUS_REG)) & SR_REQ) && !break_allowed); + if (!(tmp & SR_REQ)) { /* timeout condition */ hostdata->time_expires = jiffies + USLEEP_SLEEP; - NCR5380_set_timer (instance); + NCR5380_set_timer(instance); break; } -#else - while ( !((tmp = NCR5380_read(STATUS_REG)) & SR_REQ) ); -#endif -#if (NDEBUG & NDEBUG_HANDSHAKE) - printk("scsi%d : REQ detected\n", instance->host_no); -#endif + dprintk(NDEBUG_HANDSHAKE, ("scsi%d : REQ detected\n", instance->host_no)); /* Check for phase mismatch */ if ((tmp & PHASE_MASK) != p) { -#if (NDEBUG & NDEBUG_PIO) - printk("scsi%d : phase mismatch\n", instance->host_no); - NCR5380_print_phase(instance); -#endif + dprintk(NDEBUG_HANDSHAKE, ("scsi%d : phase mismatch\n", instance->host_no)); + NCR5380_dprint_phase(NDEBUG_HANDSHAKE, instance); break; } - /* Do actual transfer from SCSI bus to / from memory */ if (!(p & SR_IO)) - NCR5380_write(OUTPUT_DATA_REG, *d); + /* Do actual transfer from SCSI bus to / from memory */ + if (!(p & SR_IO)) + NCR5380_write(OUTPUT_DATA_REG, *d); else *d = NCR5380_read(CURRENT_SCSI_DATA_REG); @@ -2086,34 +1826,22 @@ if (!(p & SR_IO)) { if (!((p & SR_MSG) && c > 1)) { - NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE | - ICR_ASSERT_DATA); -#if (NDEBUG & NDEBUG_PIO) - NCR5380_print(instance); -#endif - NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE | - ICR_ASSERT_DATA | ICR_ASSERT_ACK); + NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE | ICR_ASSERT_DATA); + NCR5380_dprint(NDEBUG_PIO, instance); + NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE | ICR_ASSERT_DATA | ICR_ASSERT_ACK); } else { - NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE | - ICR_ASSERT_DATA | ICR_ASSERT_ATN); -#if (NDEBUG & NDEBUG_PIO) - NCR5380_print(instance); -#endif - NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE | - ICR_ASSERT_DATA | ICR_ASSERT_ATN | ICR_ASSERT_ACK); + NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE | ICR_ASSERT_DATA | ICR_ASSERT_ATN); + NCR5380_dprint(NDEBUG_PIO, instance); + NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE | ICR_ASSERT_DATA | ICR_ASSERT_ATN | ICR_ASSERT_ACK); } } else { -#if (NDEBUG & NDEBUG_PIO) - NCR5380_print(instance); -#endif + NCR5380_dprint(NDEBUG_PIO, instance); NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE | ICR_ASSERT_ACK); } while (NCR5380_read(STATUS_REG) & SR_REQ); -#if (NDEBUG & NDEBUG_HANDSHAKE) - printk("scsi%d : req false, handshake complete\n", instance->host_no); -#endif + dprintk(NDEBUG_HANDSHAKE, ("scsi%d : req false, handshake complete\n", instance->host_no)); /* * We have several special cases to consider during REQ/ACK handshaking : @@ -2134,9 +1862,7 @@ } } while (--c); -#if (NDEBUG & NDEBUG_PIO) - printk("scsi%d : residual %d\n", instance->host_no, c); -#endif + dprintk(NDEBUG_PIO, ("scsi%d : residual %d\n", instance->host_no, c)); *count = c; *data = d; @@ -2152,36 +1878,46 @@ return -1; } +/** + * do_reset - issue a reset command + * @host: adapter to reset + * + * Issue a reset sequence to the NCR5380 and try and get the bus + * back into sane shape. + * + * Locks: caller holds io_request lock + */ + static void do_reset(struct Scsi_Host *host) { - unsigned long flags; - NCR5380_local_declare(); - NCR5380_setup(host); + NCR5380_local_declare(); + NCR5380_setup(host); + + NCR5380_write(TARGET_COMMAND_REG, PHASE_SR_TO_TCR(NCR5380_read(STATUS_REG) & PHASE_MASK)); + NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE | ICR_ASSERT_RST); + udelay(25); + NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE); +} + +/* + * Function : do_abort (Scsi_Host *host) + * + * Purpose : abort the currently established nexus. Should only be + * called from a routine which can drop into a + * + * Returns : 0 on success, -1 on failure. + * + * Locks: io_request lock held by caller + */ - save_flags(flags); - cli(); - NCR5380_write(TARGET_COMMAND_REG, - PHASE_SR_TO_TCR(NCR5380_read(STATUS_REG) & PHASE_MASK)); - NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE | ICR_ASSERT_RST); - udelay(25); - NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE); - restore_flags(flags); -} /* - - * Function : do_abort (Scsi_Host *host) - * - * Purpose : abort the currently established nexus. Should only be - * called from a routine which can drop into a - * - * Returns : 0 on success, -1 on failure. - */ static int do_abort(struct Scsi_Host *host) { +static int do_abort(struct Scsi_Host *host) { NCR5380_local_declare(); unsigned char tmp, *msgptr, phase; int len; - NCR5380_setup(host); + NCR5380_setup(host); /* Request message out phase */ - NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE | ICR_ASSERT_ATN); + NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE | ICR_ASSERT_ATN); /* * Wait for the target to indicate a valid phase by asserting @@ -2195,11 +1931,10 @@ while (!(tmp = NCR5380_read(STATUS_REG)) & SR_REQ); - NCR5380_write(TARGET_COMMAND_REG, PHASE_SR_TO_TCR(tmp)); + NCR5380_write(TARGET_COMMAND_REG, PHASE_SR_TO_TCR(tmp)); if ((tmp & PHASE_MASK) != PHASE_MSGOUT) { - NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE | ICR_ASSERT_ATN | - ICR_ASSERT_ACK); + NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE | ICR_ASSERT_ATN | ICR_ASSERT_ACK); while (NCR5380_read(STATUS_REG) & SR_REQ); NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE | ICR_ASSERT_ATN); } @@ -2235,54 +1970,46 @@ * * Also, *phase, *count, *data are modified in place. * + * Locks: io_request lock held by caller */ -static int NCR5380_transfer_dma(struct Scsi_Host *instance, - unsigned char *phase, int *count, unsigned char **data) { +static int NCR5380_transfer_dma(struct Scsi_Host *instance, unsigned char *phase, int *count, unsigned char **data) { NCR5380_local_declare(); register int c = *count; register unsigned char p = *phase; register unsigned char *d = *data; unsigned char tmp; -#if defined(PSEUDO_DMA) && !defined(UNSAFE) - unsigned long flags; -#endif int foo; #if defined(REAL_DMA_POLL) int cnt, toPIO; unsigned char saved_data = 0, overrun = 0, residue; #endif - struct NCR5380_hostdata *hostdata = (struct NCR5380_hostdata *) - instance->hostdata; + struct NCR5380_hostdata *hostdata = (struct NCR5380_hostdata *) instance->hostdata; - NCR5380_setup(instance); + NCR5380_setup(instance); if ((tmp = (NCR5380_read(STATUS_REG) & PHASE_MASK)) != p) { *phase = tmp; return -1; } #if defined(REAL_DMA) || defined(REAL_DMA_POLL) -#ifdef READ_OVERRUNS - if (p & SR_IO) { c -= 2; } -#endif -#if (NDEBUG & NDEBUG_DMA) -printk("scsi%d : initializing DMA channel %d for %s, %d bytes %s %0x\n", - instance->host_no, instance->dma_channel, (p & SR_IO) ? "reading" : - "writing", c, (p & SR_IO) ? "to" : "from", (unsigned) d); +#ifdef READ_OVERRUNS + if (p & SR_IO) { + c -= 2; + } #endif -hostdata->dma_len = (p & SR_IO) ? -NCR5380_dma_read_setup(instance, d, c) : -NCR5380_dma_write_setup(instance, d, c); + dprintk(NDEBUG_DMA, ("scsi%d : initializing DMA channel %d for %s, %d bytes %s %0x\n", instance->host_no, instance->dma_channel, (p & SR_IO) ? "reading" : "writing", c, (p & SR_IO) ? "to" : "from", (unsigned) d)); + hostdata->dma_len = (p & SR_IO) ? NCR5380_dma_read_setup(instance, d, c) : NCR5380_dma_write_setup(instance, d, c); #endif -NCR5380_write(TARGET_COMMAND_REG, PHASE_SR_TO_TCR(p)); + NCR5380_write(TARGET_COMMAND_REG, PHASE_SR_TO_TCR(p)); #ifdef REAL_DMA -NCR5380_write(MODE_REG, MR_BASE | MR_DMA_MODE | MR_ENABLE_EOP_INTR | MR_MONITOR_BSY); + NCR5380_write(MODE_REG, MR_BASE | MR_DMA_MODE | MR_ENABLE_EOP_INTR | MR_MONITOR_BSY); #elif defined(REAL_DMA_POLL) -NCR5380_write(MODE_REG, MR_BASE | MR_DMA_MODE); + NCR5380_write(MODE_REG, MR_BASE | MR_DMA_MODE); #else /* * Note : on my sample board, watch-dog timeouts occurred when interrupts @@ -2290,58 +2017,38 @@ * before the setting of DMA mode to after transfer of the last byte. */ -#if defined(PSEUDO_DMA) && !defined(UNSAFE) -save_flags(flags); -cli(); +#if defined(PSEUDO_DMA) && defined(UNSAFE) + spin_unlock_irq(&io_request_lock); #endif /* KLL May need eop and parity in 53c400 */ -if (hostdata->flags & FLAG_NCR53C400) - NCR5380_write(MODE_REG, MR_BASE | MR_DMA_MODE | MR_ENABLE_PAR_CHECK - | MR_ENABLE_PAR_INTR | MR_ENABLE_EOP_INTR | MR_DMA_MODE - | MR_MONITOR_BSY); -else - NCR5380_write(MODE_REG, MR_BASE | MR_DMA_MODE); + if (hostdata->flags & FLAG_NCR53C400) + NCR5380_write(MODE_REG, MR_BASE | MR_DMA_MODE | MR_ENABLE_PAR_CHECK | MR_ENABLE_PAR_INTR | MR_ENABLE_EOP_INTR | MR_DMA_MODE | MR_MONITOR_BSY); + else + NCR5380_write(MODE_REG, MR_BASE | MR_DMA_MODE); #endif /* def REAL_DMA */ -#if (NDEBUG & NDEBUG_DMA) & 0 -printk("scsi%d : mode reg = 0x%X\n", instance->host_no, NCR5380_read(MODE_REG)); -#endif + dprintk(NDEBUG_DMA, ("scsi%d : mode reg = 0x%X\n", instance->host_no, NCR5380_read(MODE_REG))); -/* - * FOO stuff. For some UNAPPARENT reason, I'm getting - * watchdog timers fired on bootup for NO APPARENT REASON, meaning it's - * probably a timing problem. - * - * Since this is the only place I have back-to-back writes, perhaps this - * is the problem? - */ + /* + * On the PAS16 at least I/O recovery delays are not needed here. + * Everyone else seems to want them. + */ -if (p & SR_IO) -{ -#ifndef FOO -udelay(1); -#endif -NCR5380_write(START_DMA_INITIATOR_RECEIVE_REG, 0); -} else { -#ifndef FOO - udelay(1); -#endif - NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE | ICR_ASSERT_DATA); -#ifndef FOO - udelay(1); -#endif - NCR5380_write(START_DMA_SEND_REG, 0); -#ifndef FOO - udelay(1); -#endif -} + if (p & SR_IO) { + io_recovery_delay(1); + NCR5380_write(START_DMA_INITIATOR_RECEIVE_REG, 0); + } else { + io_recovery_delay(1); + NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE | ICR_ASSERT_DATA); + io_recovery_delay(1); + NCR5380_write(START_DMA_SEND_REG, 0); + io_recovery_delay(1); + } #if defined(REAL_DMA_POLL) -do { - tmp = NCR5380_read(BUS_AND_STATUS_REG); -} while ((tmp & BASR_PHASE_MATCH) && !(tmp & (BASR_BUSY_ERROR | - - BASR_END_DMA_TRANSFER))); + do { + tmp = NCR5380_read(BUS_AND_STATUS_REG); + } while ((tmp & BASR_PHASE_MATCH) && !(tmp & (BASR_BUSY_ERROR | BASR_END_DMA_TRANSFER))); /* At this point, either we've completed DMA, or we have a phase mismatch, @@ -2379,172 +2086,128 @@ request. */ -if (p & SR_IO) { + if (p & SR_IO) { #ifdef READ_OVERRUNS - udelay(10); - if (((NCR5380_read(BUS_AND_STATUS_REG) & (BASR_PHASE_MATCH | BASR_ACK)) == - (BASR_PHASE_MATCH | BASR_ACK))) { - saved_data = NCR5380_read(INPUT_DATA_REGISTER); - overrun = 1; - } + udelay(10); + if (((NCR5380_read(BUS_AND_STATUS_REG) & (BASR_PHASE_MATCH | BASR_ACK)) == (BASR_PHASE_MATCH | BASR_ACK))) { + saved_data = NCR5380_read(INPUT_DATA_REGISTER); + overrun = 1; + } #endif -} else { - int limit = 100; - while (((tmp = NCR5380_read(BUS_AND_STATUS_REG)) & BASR_ACK) || - (NCR5380_read(STATUS_REG) & SR_REQ)) { - if (!(tmp & BASR_PHASE_MATCH)) - break; - if (--limit < 0) - break; + } else { + int limit = 100; + while (((tmp = NCR5380_read(BUS_AND_STATUS_REG)) & BASR_ACK) || (NCR5380_read(STATUS_REG) & SR_REQ)) { + if (!(tmp & BASR_PHASE_MATCH)) + break; + if (--limit < 0) + break; + } } -} + dprintk(NDEBUG_DMA, ("scsi%d : polled DMA transfer complete, basr 0x%X, sr 0x%X\n", instance->host_no, tmp, NCR5380_read(STATUS_REG))); -#if (NDEBUG & NDEBUG_DMA) -printk("scsi%d : polled DMA transfer complete, basr 0x%X, sr 0x%X\n", - instance->host_no, tmp, NCR5380_read(STATUS_REG)); -#endif + NCR5380_write(MODE_REG, MR_BASE); + NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE); -NCR5380_write(MODE_REG, MR_BASE); -NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE); - -residue = NCR5380_dma_residual(instance); -c -= residue; -*count -= c; -*data += c; -*phase = NCR5380_read(STATUS_REG) & PHASE_MASK; + residue = NCR5380_dma_residual(instance); + c -= residue; + *count -= c; + *data += c; + *phase = NCR5380_read(STATUS_REG) & PHASE_MASK; #ifdef READ_OVERRUNS -if (*phase == p && (p & SR_IO) && residue == 0) -{ -if (overrun) { -#if (NDEBUG & NDEBUG_DMA) - printk("Got an input overrun, using saved byte\n"); -#endif - **data = saved_data; - *data += 1; - *count -= 1; - cnt = toPIO = 1; -} else { - printk("No overrun??\n"); - cnt = toPIO = 2; -} -#if (NDEBUG & NDEBUG_DMA) -printk("Doing %d-byte PIO to 0x%X\n", cnt, *data); -#endif -NCR5380_transfer_pio(instance, phase, &cnt, data); -*count -= toPIO - cnt; -} + if (*phase == p && (p & SR_IO) && residue == 0) { + if (overrun) { + dprintk(NDEBUG_DMA, ("Got an input overrun, using saved byte\n")); + **data = saved_data; + *data += 1; + *count -= 1; + cnt = toPIO = 1; + } else { + printk("No overrun??\n"); + cnt = toPIO = 2; + } + dprintk(NDEBUG_DMA, ("Doing %d-byte PIO to 0x%X\n", cnt, *data)); + NCR5380_transfer_pio(instance, phase, &cnt, data); + *count -= toPIO - cnt; + } #endif -#if (NDEBUG & NDEBUG_DMA) -printk("Return with data ptr = 0x%X, count %d, last 0x%X, next 0x%X\n", - *data, *count, *(*data + *count - 1), *(*data + *count)); -#endif -return 0; + dprintk(NDEBUG_DMA, ("Return with data ptr = 0x%X, count %d, last 0x%X, next 0x%X\n", *data, *count, *(*data + *count - 1), *(*data + *count))); + return 0; #elif defined(REAL_DMA) -return 0; + return 0; #else /* defined(REAL_DMA_POLL) */ -if (p & SR_IO) { + if (p & SR_IO) { #ifdef DMA_WORKS_RIGHT - foo = NCR5380_pread(instance, d, c); + foo = NCR5380_pread(instance, d, c); #else - int diff = 1; - if (hostdata->flags & FLAG_NCR53C400) { - diff = 0; - } - if (!(foo = NCR5380_pread(instance, d, c - diff))) { - /* - * We can't disable DMA mode after successfully transferring - * what we plan to be the last byte, since that would open up - * a race condition where if the target asserted REQ before - * we got the DMA mode reset, the NCR5380 would have latched - * an additional byte into the INPUT DATA register and we'd - * have dropped it. - * - * The workaround was to transfer one fewer bytes than we - * intended to with the pseudo-DMA read function, wait for - * the chip to latch the last byte, read it, and then disable - * pseudo-DMA mode. - * - * After REQ is asserted, the NCR5380 asserts DRQ and ACK. - * REQ is deasserted when ACK is asserted, and not reasserted - * until ACK goes false. Since the NCR5380 won't lower ACK - * until DACK is asserted, which won't happen unless we twiddle - * the DMA port or we take the NCR5380 out of DMA mode, we - * can guarantee that we won't handshake another extra - * byte. - */ + int diff = 1; + if (hostdata->flags & FLAG_NCR53C400) { + diff = 0; + } + if (!(foo = NCR5380_pread(instance, d, c - diff))) { + /* + * We can't disable DMA mode after successfully transferring + * what we plan to be the last byte, since that would open up + * a race condition where if the target asserted REQ before + * we got the DMA mode reset, the NCR5380 would have latched + * an additional byte into the INPUT DATA register and we'd + * have dropped it. + * + * The workaround was to transfer one fewer bytes than we + * intended to with the pseudo-DMA read function, wait for + * the chip to latch the last byte, read it, and then disable + * pseudo-DMA mode. + * + * After REQ is asserted, the NCR5380 asserts DRQ and ACK. + * REQ is deasserted when ACK is asserted, and not reasserted + * until ACK goes false. Since the NCR5380 won't lower ACK + * until DACK is asserted, which won't happen unless we twiddle + * the DMA port or we take the NCR5380 out of DMA mode, we + * can guarantee that we won't handshake another extra + * byte. + */ - if (!(hostdata->flags & FLAG_NCR53C400)) { - while (!(NCR5380_read(BUS_AND_STATUS_REG) & BASR_DRQ)); - /* Wait for clean handshake */ - while (NCR5380_read(STATUS_REG) & SR_REQ); - d[c - 1] = NCR5380_read(INPUT_DATA_REG); + if (!(hostdata->flags & FLAG_NCR53C400)) { + while (!(NCR5380_read(BUS_AND_STATUS_REG) & BASR_DRQ)); + /* Wait for clean handshake */ + while (NCR5380_read(STATUS_REG) & SR_REQ); + d[c - 1] = NCR5380_read(INPUT_DATA_REG); + } } - } #endif -} else { + } else { #ifdef DMA_WORKS_RIGHT - foo = NCR5380_pwrite(instance, d, c); + foo = NCR5380_pwrite(instance, d, c); #else - int timeout; -#if (NDEBUG & NDEBUG_C400_PWRITE) - printk("About to pwrite %d bytes\n", c); -#endif - if (!(foo = NCR5380_pwrite(instance, d, c))) { - /* - * Wait for the last byte to be sent. If REQ is being asserted for - * the byte we're interested, we'll ACK it and it will go false. - */ - if (!(hostdata->flags & FLAG_HAS_LAST_BYTE_SENT)) { - timeout = 20000; -#if 1 -#if 1 - while (!(NCR5380_read(BUS_AND_STATUS_REG) & - BASR_DRQ) && (NCR5380_read(BUS_AND_STATUS_REG) & - BASR_PHASE_MATCH)); -#else - if (NCR5380_read(STATUS_REG) & SR_REQ) { - for (; timeout && - !(NCR5380_read(BUS_AND_STATUS_REG) & BASR_ACK); - --timeout); - for (; timeout && (NCR5380_read(STATUS_REG) & SR_REQ); - --timeout); - } -#endif - - -#if (NDEBUG & NDEBUG_LAST_BYTE_SENT) - if (!timeout) - printk("scsi%d : timed out on last byte\n", - instance->host_no); -#endif - - - if (hostdata->flags & FLAG_CHECK_LAST_BYTE_SENT) { - hostdata->flags &= ~FLAG_CHECK_LAST_BYTE_SENT; - if (NCR5380_read(TARGET_COMMAND_REG) & TCR_LAST_BYTE_SENT) { - hostdata->flags |= FLAG_HAS_LAST_BYTE_SENT; -#if (NDEBUG & NDEBUG_LAST_BYTE_SENT) - printk("scsi%d : last bit sent works\n", - instance->host_no); -#endif + int timeout; + dprintk(NDEBUG_C400_PWRITE, ("About to pwrite %d bytes\n", c)); + if (!(foo = NCR5380_pwrite(instance, d, c))) { + /* + * Wait for the last byte to be sent. If REQ is being asserted for + * the byte we're interested, we'll ACK it and it will go false. + */ + if (!(hostdata->flags & FLAG_HAS_LAST_BYTE_SENT)) { + timeout = 20000; + while (!(NCR5380_read(BUS_AND_STATUS_REG) & BASR_DRQ) && (NCR5380_read(BUS_AND_STATUS_REG) & BASR_PHASE_MATCH)); + + if (!timeout) + dprintk(NDEBUG_LAST_BYTE_SENT, ("scsi%d : timed out on last byte\n", instance->host_no)); + + if (hostdata->flags & FLAG_CHECK_LAST_BYTE_SENT) { + hostdata->flags &= ~FLAG_CHECK_LAST_BYTE_SENT; + if (NCR5380_read(TARGET_COMMAND_REG) & TCR_LAST_BYTE_SENT) { + hostdata->flags |= FLAG_HAS_LAST_BYTE_SENT; + dprintk(NDEBUG_LAST_WRITE_SENT, ("scsi%d : last bit sent works\n", instance->host_no)); + } } + } else { + dprintk(NDEBUG_C400_PWRITE, ("Waiting for LASTBYTE\n")); + while (!(NCR5380_read(TARGET_COMMAND_REG) & TCR_LAST_BYTE_SENT)); + dprintk(NDEBUG_C400_PWRITE, ("Got LASTBYTE\n")); } - } else { -#if (NDEBUG & NDEBUG_C400_PWRITE) - printk("Waiting for LASTBYTE\n"); -#endif - while (!(NCR5380_read(TARGET_COMMAND_REG) & TCR_LAST_BYTE_SENT)); -#if (NDEBUG & NDEBUG_C400_PWRITE) - printk("Got LASTBYTE\n"); -#endif - } -#else - udelay(5); -#endif } #endif } @@ -2552,13 +2215,9 @@ NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE); if ((!(p & SR_IO)) && (hostdata->flags & FLAG_NCR53C400)) { -#if (NDEBUG & NDEBUG_C400_PWRITE) - printk("53C400w: Checking for IRQ\n"); -#endif + dprintk(NDEBUG_C400_PWRITE, ("53C400w: Checking for IRQ\n")); if (NCR5380_read(BUS_AND_STATUS_REG) & BASR_IRQ) { -#if (NDEBUG & NDEBUG_C400_PWRITE) - printk("53C400w: got it, reading reset interrupt reg\n"); -#endif + dprintk(NDEBUG_C400_PWRITE, ("53C400w: got it, reading reset interrupt reg\n")); NCR5380_read(RESET_PARITY_INTERRUPT_REG); } else { printk("53C400w: IRQ NOT THERE!\n"); @@ -2567,11 +2226,8 @@ *data = d + c; *count = 0; *phase = NCR5380_read(STATUS_REG) & PHASE_MASK; -#if 0 - NCR5380_print_phase(instance); -#endif -#if defined(PSEUDO_DMA) && !defined(UNSAFE) - restore_flags(flags); +#if defined(PSEUDO_DMA) && defined(UNSAFE) + spin_lock_irq(&io_request_lock); #endif /* defined(REAL_DMA_POLL) */ return foo; #endif /* def REAL_DMA */ @@ -2593,12 +2249,13 @@ * * XXX Note : we need to watch for bus free or a reset condition here * to recover from an unexpected bus free condition. + * + * Locks: io_request_lock held by caller */ static void NCR5380_information_transfer(struct Scsi_Host *instance) { NCR5380_local_declare(); - struct NCR5380_hostdata *hostdata = (struct NCR5380_hostdata *) - instance->hostdata; + struct NCR5380_hostdata *hostdata = (struct NCR5380_hostdata *)instance->hostdata; unsigned char msgout = NOP; int sink = 0; int len; @@ -2608,10 +2265,8 @@ unsigned char *data; unsigned char phase, tmp, extended_msg[10], old_phase = 0xff; Scsi_Cmnd *cmd = (Scsi_Cmnd *) hostdata->connected; -#ifdef USLEEP /* RvC: we need to set the end of the polling time */ unsigned long poll_time = jiffies + USLEEP_POLL; -#endif NCR5380_setup(instance); @@ -2622,27 +2277,22 @@ phase = (tmp & PHASE_MASK); if (phase != old_phase) { old_phase = phase; -#if (NDEBUG & NDEBUG_INFORMATION) - NCR5380_print_phase(instance); -#endif + NCR5380_dprint_phase(NDEBUG_INFORMATION, instance); } if (sink && (phase != PHASE_MSGOUT)) { NCR5380_write(TARGET_COMMAND_REG, PHASE_SR_TO_TCR(tmp)); - NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE | ICR_ASSERT_ATN | - ICR_ASSERT_ACK); + NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE | ICR_ASSERT_ATN | ICR_ASSERT_ACK); while (NCR5380_read(STATUS_REG) & SR_REQ); - NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE | - ICR_ASSERT_ATN); + NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE | ICR_ASSERT_ATN); sink = 0; continue; } switch (phase) { - case PHASE_DATAIN: - case PHASE_DATAOUT: + case PHASE_DATAIN: + case PHASE_DATAOUT: #if (NDEBUG & NDEBUG_NO_DATAOUT) - printk("scsi%d : NDEBUG_NO_DATAOUT set, attempted DATAOUT aborted\n", - instance->host_no); + printk("scsi%d : NDEBUG_NO_DATAOUT set, attempted DATAOUT aborted\n", instance->host_no); sink = 1; do_abort(instance); cmd->result = DID_ERROR << 16; @@ -2659,11 +2309,7 @@ --cmd->SCp.buffers_residual; cmd->SCp.this_residual = cmd->SCp.buffer->length; cmd->SCp.ptr = cmd->SCp.buffer->address; -#if (NDEBUG & NDEBUG_INFORMATION) - printk("scsi%d : %d bytes and %d buffers left\n", - instance->host_no, cmd->SCp.this_residual, - cmd->SCp.buffers_residual); -#endif + dprintk(NDEBUG_INFORMATION, ("scsi%d : %d bytes and %d buffers left\n", instance->host_no, cmd->SCp.this_residual, cmd->SCp.buffers_residual)); } /* * The preferred transfer method is going to be @@ -2684,9 +2330,7 @@ * We supplement these 2 if's with the flag. */ #ifdef NCR5380_dma_xfer_len - if (!cmd->device->borken && - !(hostdata->flags & FLAG_NO_PSEUDO_DMA) && - (transfersize = NCR5380_dma_xfer_len(instance, cmd)) != 0) { + if (!cmd->device->borken && !(hostdata->flags & FLAG_NO_PSEUDO_DMA) && (transfersize = NCR5380_dma_xfer_len(instance, cmd)) != 0) { #else transfersize = cmd->transfersize; @@ -2695,27 +2339,21 @@ transfersize = 512; #endif /* LIMIT_TRANSFERSIZE */ - if (!cmd->device->borken && transfersize && - !(hostdata->flags & FLAG_NO_PSEUDO_DMA) && - cmd->SCp.this_residual && !(cmd->SCp.this_residual % - transfersize)) { + if (!cmd->device->borken && transfersize && !(hostdata->flags & FLAG_NO_PSEUDO_DMA) && cmd->SCp.this_residual && !(cmd->SCp.this_residual % transfersize)) { /* Limit transfers to 32K, for xx400 & xx406 * pseudoDMA that transfers in 128 bytes blocks. */ if (transfersize > 32 * 1024) transfersize = 32 * 1024; #endif len = transfersize; - if (NCR5380_transfer_dma(instance, &phase, - &len, (unsigned char **) &cmd->SCp.ptr)) { + if (NCR5380_transfer_dma(instance, &phase, &len, (unsigned char **) &cmd->SCp.ptr)) { /* * If the watchdog timer fires, all future accesses to this * device will use the polled-IO. */ - printk("scsi%d : switching target %d lun %d to slow handshake\n", - instance->host_no, cmd->target, cmd->lun); + printk("scsi%d : switching target %d lun %d to slow handshake\n", instance->host_no, cmd->target, cmd->lun); cmd->device->borken = 1; - NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE | - ICR_ASSERT_ATN); + NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE | ICR_ASSERT_ATN); sink = 1; do_abort(instance); cmd->result = DID_ERROR << 16; @@ -2725,12 +2363,11 @@ cmd->SCp.this_residual -= transfersize - len; } else #endif /* defined(PSEUDO_DMA) || defined(REAL_DMA_POLL) */ - NCR5380_transfer_pio(instance, &phase, - (int *) &cmd->SCp.this_residual, (unsigned char **) - &cmd->SCp.ptr); + NCR5380_transfer_pio(instance, &phase, (int *) &cmd->SCp.this_residual, (unsigned char **) + &cmd->SCp.ptr); break; - case PHASE_MSGIN: - len = 1; + case PHASE_MSGIN: + len = 1; data = &tmp; NCR5380_transfer_pio(instance, &phase, &len, &data); cmd->SCp.Message = tmp; @@ -2747,24 +2384,18 @@ * next_link, done() is called as with unlinked commands. */ #ifdef LINKED - case LINKED_CMD_COMPLETE: - case LINKED_FLG_CMD_COMPLETE: + case LINKED_CMD_COMPLETE: + case LINKED_FLG_CMD_COMPLETE: /* Accept message by clearing ACK */ - NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE); - -#if (NDEBUG & NDEBUG_LINKED) - printk("scsi%d : target %d lun %d linked command complete.\n", - instance->host_no, cmd->target, cmd->lun); -#endif + NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE); + dprintk(NDEBUG_LINKED, ("scsi%d : target %d lun %d linked command complete.\n", instance->host_no, cmd->target, cmd->lun)); /* * Sanity check : A linked command should only terminate with * one of these messages if there are more linked commands * available. */ - if (!cmd->next_link) { - printk("scsi%d : target %d lun %d linked command complete, no next_link\n" - instance->host_no, cmd->target, cmd->lun); + printk("scsi%d : target %d lun %d linked command complete, no next_link\n" instance->host_no, cmd->target, cmd->lun); sink = 1; do_abort(instance); return; @@ -2773,27 +2404,19 @@ /* The next command is still part of this process */ cmd->next_link->tag = cmd->tag; cmd->result = cmd->SCp.Status | (cmd->SCp.Message << 8); -#if (NDEBUG & NDEBUG_LINKED) - printk("scsi%d : target %d lun %d linked request done, calling scsi_done().\n", - instance->host_no, cmd->target, cmd->lun); -#endif -#ifdef NCR5380_STATS + dprintk(NDEBUG_LINKED, ("scsi%d : target %d lun %d linked request done, calling scsi_done().\n", instance->host_no, cmd->target, cmd->lun)); collect_stats(hostdata, cmd); -#endif cmd->scsi_done(cmd); cmd = hostdata->connected; break; #endif /* def LINKED */ - case ABORT: - case COMMAND_COMPLETE: + case ABORT: + case COMMAND_COMPLETE: /* Accept message by clearing ACK */ - sink = 1; + sink = 1; NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE); hostdata->connected = NULL; -#if (NDEBUG & NDEBUG_QUEUES) - printk("scsi%d : command for target %d, lun %d completed\n", - instance->host_no, cmd->target, cmd->lun); -#endif + dprintk(NDEBUG_QUEUES, ("scsi%d : command for target %d, lun %d completed\n", instance->host_no, cmd->target, cmd->lun)); hostdata->busy[cmd->target] &= ~(1 << cmd->lun); /* @@ -2818,13 +2441,8 @@ cmd->result = (cmd->result & 0x00ffff) | (DID_ERROR << 16); #ifdef AUTOSENSE - if ((cmd->cmnd[0] != REQUEST_SENSE) && - (cmd->SCp.Status == CHECK_CONDITION)) { - unsigned long flags; -#if (NDEBUG & NDEBUG_AUTOSENSE) - printk("scsi%d : performing request sense\n", - instance->host_no); -#endif + if ((cmd->cmnd[0] != REQUEST_SENSE) && (cmd->SCp.Status == CHECK_CONDITION)) { + dprintk(NDEBUG_AUTOSENSE, ("scsi%d : performing request sense\n", instance->host_no)); cmd->cmnd[0] = REQUEST_SENSE; cmd->cmnd[1] &= 0xe0; cmd->cmnd[2] = 0; @@ -2837,21 +2455,14 @@ cmd->SCp.ptr = (char *) cmd->sense_buffer; cmd->SCp.this_residual = sizeof(cmd->sense_buffer); - save_flags(flags); - cli(); LIST(cmd, hostdata->issue_queue); cmd->host_scribble = (unsigned char *) hostdata->issue_queue; hostdata->issue_queue = (Scsi_Cmnd *) cmd; - restore_flags(flags); -#if (NDEBUG & NDEBUG_QUEUES) - printk("scsi%d : REQUEST SENSE added to head of issue queue\n", instance->host_no); -#endif + dprintk(NDEBUG_QUEUES, ("scsi%d : REQUEST SENSE added to head of issue queue\n", instance->host_no)); } else { #endif /* def AUTOSENSE */ -#ifdef NCR5380_STATS collect_stats(hostdata, cmd); -#endif cmd->scsi_done(cmd); } @@ -2865,37 +2476,29 @@ while ((NCR5380_read(STATUS_REG) & SR_BSY) && !hostdata->connected) barrier(); return; - case MESSAGE_REJECT: + case MESSAGE_REJECT: /* Accept message by clearing ACK */ - NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE); + NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE); switch (hostdata->last_message) { - case HEAD_OF_QUEUE_TAG: - case ORDERED_QUEUE_TAG: - case SIMPLE_QUEUE_TAG: - cmd->device->tagged_queue = 0; + case HEAD_OF_QUEUE_TAG: + case ORDERED_QUEUE_TAG: + case SIMPLE_QUEUE_TAG: + cmd->device->tagged_queue = 0; hostdata->busy[cmd->target] |= (1 << cmd->lun); break; - default: - break; + default: + break; } - case DISCONNECT: { - unsigned long flags; + case DISCONNECT:{ /* Accept message by clearing ACK */ NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE); cmd->device->disconnect = 1; - save_flags(flags); - cli(); LIST(cmd, hostdata->disconnected_queue); cmd->host_scribble = (unsigned char *) hostdata->disconnected_queue; hostdata->connected = NULL; hostdata->disconnected_queue = cmd; - restore_flags(flags); -#if (NDEBUG & NDEBUG_QUEUES) - printk("scsi%d : command for target %d lun %d was moved from connected to" - " the disconnected_queue\n", instance->host_no, - cmd->target, cmd->lun); -#endif + dprintk(NDEBUG_QUEUES, ("scsi%d : command for target %d lun %d was moved from connected to" " the disconnected_queue\n", instance->host_no, cmd->target, cmd->lun)); /* * Restore phase bits to 0 so an interrupted selection, * arbitration can resume. @@ -2907,9 +2510,6 @@ /* Wait for bus free to avoid nasty timeouts */ while ((NCR5380_read(STATUS_REG) & SR_BSY) && !hostdata->connected) barrier(); -#if 0 - NCR5380_print_status(instance); -#endif return; } /* @@ -2922,12 +2522,12 @@ * disconnecting, and we have to break spec to remain * compatible. */ - case SAVE_POINTERS: - case RESTORE_POINTERS: + case SAVE_POINTERS: + case RESTORE_POINTERS: /* Accept message by clearing ACK */ - NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE); + NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE); break; - case EXTENDED_MESSAGE: + case EXTENDED_MESSAGE: /* * Extended messages are sent in the following format : * Byte @@ -2940,28 +2540,19 @@ * Start the extended message buffer with the EXTENDED_MESSAGE * byte, since print_msg() wants the whole thing. */ - extended_msg[0] = EXTENDED_MESSAGE; + extended_msg[0] = EXTENDED_MESSAGE; /* Accept first byte by clearing ACK */ NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE); - -#if (NDEBUG & NDEBUG_EXTENDED) - printk("scsi%d : receiving extended message\n", - instance->host_no); -#endif + dprintk(NDEBUG_EXTENDED, ("scsi%d : receiving extended message\n", instance->host_no)); len = 2; data = extended_msg + 1; phase = PHASE_MSGIN; NCR5380_transfer_pio(instance, &phase, &len, &data); -#if (NDEBUG & NDEBUG_EXTENDED) - printk("scsi%d : length=%d, code=0x%02x\n", - instance->host_no, (int) extended_msg[1], - (int) extended_msg[2]); -#endif + dprintk(NDEBUG_EXTENDED, ("scsi%d : length=%d, code=0x%02x\n", instance->host_no, (int) extended_msg[1], (int) extended_msg[2])); - if (!len && extended_msg[1] <= - (sizeof(extended_msg) - 1)) { + if (!len && extended_msg[1] <= (sizeof(extended_msg) - 1)) { /* Accept third byte by clearing ACK */ NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE); len = extended_msg[1] - 1; @@ -2969,26 +2560,20 @@ phase = PHASE_MSGIN; NCR5380_transfer_pio(instance, &phase, &len, &data); - -#if (NDEBUG & NDEBUG_EXTENDED) - printk("scsi%d : message received, residual %d\n", - instance->host_no, len); -#endif + dprintk(NDEBUG_EXTENDED, ("scsi%d : message received, residual %d\n", instance->host_no, len)); switch (extended_msg[2]) { - case EXTENDED_SDTR: - case EXTENDED_WDTR: - case EXTENDED_MODIFY_DATA_POINTER: - case EXTENDED_EXTENDED_IDENTIFY: - tmp = 0; + case EXTENDED_SDTR: + case EXTENDED_WDTR: + case EXTENDED_MODIFY_DATA_POINTER: + case EXTENDED_EXTENDED_IDENTIFY: + tmp = 0; } } else if (len) { - printk("scsi%d: error receiving extended message\n", - instance->host_no); + printk("scsi%d: error receiving extended message\n", instance->host_no); tmp = 0; } else { - printk("scsi%d: extended message code %02x length %d is too long\n", - instance->host_no, extended_msg[2], extended_msg[1]); + printk("scsi%d: extended message code %02x length %d is too long\n", instance->host_no, extended_msg[2], extended_msg[1]); tmp = 0; } /* Fall through to reject message */ @@ -2997,26 +2582,23 @@ * If we get something weird that we aren't expecting, * reject it. */ - default: - if (!tmp) { + default: + if (!tmp) { printk("scsi%d: rejecting message ", instance->host_no); print_msg(extended_msg); printk("\n"); } else if (tmp != EXTENDED_MESSAGE) - printk("scsi%d: rejecting unknown message %02x from target %d, lun %d\n", - instance->host_no, tmp, cmd->target, cmd->lun); + printk("scsi%d: rejecting unknown message %02x from target %d, lun %d\n", instance->host_no, tmp, cmd->target, cmd->lun); else - printk("scsi%d: rejecting unknown extended message code %02x, length %d from target %d, lun %d\n", - instance->host_no, extended_msg[1], extended_msg[0], cmd->target, cmd->lun); + printk("scsi%d: rejecting unknown extended message code %02x, length %d from target %d, lun %d\n", instance->host_no, extended_msg[1], extended_msg[0], cmd->target, cmd->lun); msgout = MESSAGE_REJECT; - NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE | - ICR_ASSERT_ATN); + NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE | ICR_ASSERT_ATN); break; } /* switch (tmp) */ break; - case PHASE_MSGOUT: - len = 1; + case PHASE_MSGOUT: + len = 1; data = &msgout; hostdata->last_message = msgout; NCR5380_transfer_pio(instance, &phase, &len, &data); @@ -3024,69 +2606,50 @@ hostdata->busy[cmd->target] &= ~(1 << cmd->lun); hostdata->connected = NULL; cmd->result = DID_ERROR << 16; -#ifdef NCR5380_STATS collect_stats(hostdata, cmd); -#endif cmd->scsi_done(cmd); NCR5380_write(SELECT_ENABLE_REG, hostdata->id_mask); return; } msgout = NOP; break; - case PHASE_CMDOUT: - len = cmd->cmd_len; + case PHASE_CMDOUT: + len = cmd->cmd_len; data = cmd->cmnd; /* * XXX for performance reasons, on machines with a * PSEUDO-DMA architecture we should probably * use the dma transfer function. */ - NCR5380_transfer_pio(instance, &phase, &len, - &data); -#ifdef USLEEP - if (!cmd->device->disconnect && - should_disconnect(cmd->cmnd[0])) - { + NCR5380_transfer_pio(instance, &phase, &len, &data); + if (!cmd->device->disconnect && should_disconnect(cmd->cmnd[0])) { hostdata->time_expires = jiffies + USLEEP_SLEEP; -#if (NDEBUG & NDEBUG_USLEEP) - printk("scsi%d : issued command, sleeping until %ul\n", instance->host_no, - hostdata->time_expires); -#endif + dprintk(NDEBUG_USLEEP, ("scsi%d : issued command, sleeping until %ul\n", instance->host_no, hostdata->time_expires)); NCR5380_set_timer(instance); return; } -#endif /* def USLEEP */ break; - case PHASE_STATIN: - len = 1; + case PHASE_STATIN: + len = 1; data = &tmp; NCR5380_transfer_pio(instance, &phase, &len, &data); cmd->SCp.Status = tmp; break; - default: - printk("scsi%d : unknown phase\n", instance->host_no); -#ifdef NDEBUG - NCR5380_print(instance); -#endif + default: + printk("scsi%d : unknown phase\n", instance->host_no); + NCR5380_dprint(NDEBUG_ALL, instance); } /* switch(phase) */ } /* if (tmp * SR_REQ) */ -#ifdef USLEEP - else - { + else { /* RvC: go to sleep if polling time expired */ - if (!cmd->device->disconnect && time_after_eq(jiffies, poll_time)) - { + if (!cmd->device->disconnect && time_after_eq(jiffies, poll_time)) { hostdata->time_expires = jiffies + USLEEP_SLEEP; -#if (NDEBUG & NDEBUG_USLEEP) - printk("scsi%d : poll timed out, sleeping until %ul\n", instance->host_no, - hostdata->time_expires); -#endif + dprintk(NDEBUG_USLEEP, ("scsi%d : poll timed out, sleeping until %ul\n", instance->host_no, hostdata->time_expires)); NCR5380_set_timer(instance); return; } } -#endif } /* while (1) */ } @@ -3099,9 +2662,9 @@ * * Inputs : instance - this instance of the NCR5380. * + * Locks: io_request_lock held by caller */ - static void NCR5380_reselect(struct Scsi_Host *instance) { NCR5380_local_declare(); struct NCR5380_hostdata *hostdata = (struct NCR5380_hostdata *) @@ -3109,28 +2672,22 @@ unsigned char target_mask; unsigned char lun, phase; int len; -#ifdef SCSI2 - unsigned char tag; -#endif unsigned char msg[3]; unsigned char *data; Scsi_Cmnd *tmp = NULL, *prev; int abort = 0; - NCR5380_setup(instance); + NCR5380_setup(instance); /* * Disable arbitration, etc. since the host adapter obviously * lost, and tell an interrupted NCR5380_select() to restart. */ - NCR5380_write(MODE_REG, MR_BASE); - hostdata->restart_select = 1; - - target_mask = NCR5380_read(CURRENT_SCSI_DATA_REG) & ~(hostdata->id_mask); + NCR5380_write(MODE_REG, MR_BASE); + hostdata->restart_select = 1; -#if (NDEBUG & NDEBUG_RESELECTION) - printk("scsi%d : reselect\n", instance->host_no); -#endif + target_mask = NCR5380_read(CURRENT_SCSI_DATA_REG) & ~(hostdata->id_mask); + dprintk(NDEBUG_SELECTION, ("scsi%d : reselect\n", instance->host_no)); /* * At this point, we have detected that our SCSI ID is on the bus, @@ -3141,10 +2698,10 @@ * signal. */ - NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE | ICR_ASSERT_BSY); + NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE | ICR_ASSERT_BSY); while (NCR5380_read(STATUS_REG) & SR_SEL); - NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE); + NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE); /* * Wait for target to go into MSGIN. @@ -3152,15 +2709,13 @@ while (!(NCR5380_read(STATUS_REG) & SR_REQ)); - len = 1; - data = msg; - phase = PHASE_MSGIN; - NCR5380_transfer_pio(instance, &phase, &len, &data); - + len = 1; + data = msg; + phase = PHASE_MSGIN; + NCR5380_transfer_pio(instance, &phase, &len, &data); if (!msg[0] & 0x80) { - printk("scsi%d : expecting IDENTIFY message, got ", - instance->host_no); + printk("scsi%d : expecting IDENTIFY message, got ", instance->host_no); print_msg(msg); abort = 1; } else { @@ -3174,22 +2729,14 @@ * nexuses so we can chose to do additional data transfer. */ -#ifdef SCSI2 -#error "SCSI-II tagged queueing is not supported yet" -#endif - /* * Find the command corresponding to the I_T_L or I_T_L_Q nexus we * just reestablished, and remove it from the disconnected queue. */ - for (tmp = (Scsi_Cmnd *) hostdata->disconnected_queue, prev = NULL; - tmp; prev = tmp, tmp = (Scsi_Cmnd *) tmp->host_scribble) + for (tmp = (Scsi_Cmnd *) hostdata->disconnected_queue, prev = NULL; tmp; prev = tmp, tmp = (Scsi_Cmnd *) tmp->host_scribble) if ((target_mask == (1 << tmp->target)) && (lun == tmp->lun) -#ifdef SCSI2 - && (tag == tmp->tag) -#endif ) { if (prev) { REMOVE(prev, prev->host_scribble, tmp, tmp->host_scribble); @@ -3202,13 +2749,7 @@ break; } if (!tmp) { -#ifdef SCSI2 - printk("scsi%d : warning : target bitmask %02x lun %d tag %d not in disconnect_queue.\n", - instance->host_no, target_mask, lun, tag); -#else - printk("scsi%d : warning : target bitmask %02x lun %d not in disconnect_queue.\n", - instance->host_no, target_mask, lun); -#endif + printk("scsi%d : warning : target bitmask %02x lun %d not in disconnect_queue.\n", instance->host_no, target_mask, lun); /* * Since we have an established nexus that we can't do anything with, * we must abort it. @@ -3221,10 +2762,7 @@ do_abort(instance); } else { hostdata->connected = tmp; -#if (NDEBUG & NDEBUG_RESELECTION) - printk("scsi%d : nexus established, target = %d, lun = %d, tag = %d\n", - instance->host_no, tmp->target, tmp->lun, tmp->tag); -#endif + dprintk(NDEBUG_RESELECTION, ("scsi%d : nexus established, target = %d, lun = %d, tag = %d\n", instance->host_no, tmp->target, tmp->lun, tmp->tag)); } } @@ -3243,8 +2781,7 @@ #ifdef REAL_DMA static void NCR5380_dma_complete(NCR5380_instance * instance) { NCR5380_local_declare(); - struct NCR5380_hostdata *hostdata = (struct NCR5380_hostdata * - instance->hostdata); + struct NCR5380_hostdata *hostdata = (struct NCR5380_hostdata * instance->hostdata); int transferred; NCR5380_setup(instance); @@ -3287,10 +2824,12 @@ * * Returns : 0 - success, -1 on failure. * - * XXX - there is no way to abort the command that is currently - * connected, you have to wait for it to complete. If this is - * a problem, we could implement longjmp() / setjmp(), setjmp() - * called where the loop started in NCR5380_main(). + * XXX - there is no way to abort the command that is currently + * connected, you have to wait for it to complete. If this is + * a problem, we could implement longjmp() / setjmp(), setjmp() + * called where the loop started in NCR5380_main(). + * + * Locks: io_request_lock held by caller */ #ifndef NCR5380_abort @@ -3298,10 +2837,8 @@ #endif int NCR5380_abort(Scsi_Cmnd * cmd) { NCR5380_local_declare(); - unsigned long flags; struct Scsi_Host *instance = cmd->host; - struct NCR5380_hostdata *hostdata = (struct NCR5380_hostdata *) - instance->hostdata; + struct NCR5380_hostdata *hostdata = (struct NCR5380_hostdata *) instance->hostdata; Scsi_Cmnd *tmp, **prev; printk("scsi%d : aborting command\n", instance->host_no); @@ -3314,15 +2851,10 @@ NCR5380_print_status(instance); - save_flags(flags); - cli(); NCR5380_setup(instance); -#if (NDEBUG & NDEBUG_ABORT) - printk("scsi%d : abort called\n", instance->host_no); - printk(" basr 0x%X, sr 0x%X\n", - NCR5380_read(BUS_AND_STATUS_REG), NCR5380_read(STATUS_REG)); -#endif + dprintk(NDEBUG_ABORT, ("scsi%d : abort called\n", instance->host_no)); + dprintk(NDEBUG_ABORT, (" basr 0x%X, sr 0x%X\n", NCR5380_read(BUS_AND_STATUS_REG), NCR5380_read(STATUS_REG))); #if 0 /* @@ -3332,9 +2864,7 @@ */ if (hostdata->connected == cmd) { -#if (NDEBUG & NDEBUG_ABORT) - printk("scsi%d : aborting connected command\n", instance->host_no); -#endif + dprintk(NDEBUG_ABORT, ("scsi%d : aborting connected command\n", instance->host_no)); hostdata->aborted = 1; /* * We should perform BSY checking, and make sure we haven't slipped @@ -3361,24 +2891,15 @@ * Case 2 : If the command hasn't been issued yet, we simply remove it * from the issue queue. */ -#if (NDEBUG & NDEBUG_ABORT) /* KLL */ - printk("scsi%d : abort going into loop.\n", instance->host_no); -#endif - for (prev = (Scsi_Cmnd **) & (hostdata->issue_queue), - tmp = (Scsi_Cmnd *) hostdata->issue_queue; - tmp; prev = (Scsi_Cmnd **) & (tmp->host_scribble), tmp = - (Scsi_Cmnd *) tmp->host_scribble) + dprintk(NDEBUG_ABORT, ("scsi%d : abort going into loop.\n", instance->host_no)); + for (prev = (Scsi_Cmnd **) & (hostdata->issue_queue), tmp = (Scsi_Cmnd *) hostdata->issue_queue; tmp; prev = (Scsi_Cmnd **) & (tmp->host_scribble), tmp = (Scsi_Cmnd *) tmp->host_scribble) if (cmd == tmp) { REMOVE(5, *prev, tmp, tmp->host_scribble); (*prev) = (Scsi_Cmnd *) tmp->host_scribble; tmp->host_scribble = NULL; tmp->result = DID_ABORT << 16; - restore_flags(flags); -#if (NDEBUG & NDEBUG_ABORT) - printk("scsi%d : abort removed command from issue queue.\n", - instance->host_no); -#endif + dprintk(NDEBUG_ABORT, ("scsi%d : abort removed command from issue queue.\n", instance->host_no)); tmp->done(tmp); return SCSI_ABORT_SUCCESS; } @@ -3400,10 +2921,7 @@ */ if (hostdata->connected) { - restore_flags(flags); -#if (NDEBUG & NDEBUG_ABORT) - printk("scsi%d : abort failed, command connected.\n", instance->host_no); -#endif + dprintk(NDEBUG_ABORT, ("scsi%d : abort failed, command connected.\n", instance->host_no)); return SCSI_ABORT_NOT_RUNNING; } /* @@ -3431,34 +2949,22 @@ * it from the disconnected queue. */ - for (tmp = (Scsi_Cmnd *) hostdata->disconnected_queue; tmp; - tmp = (Scsi_Cmnd *) tmp->host_scribble) + for (tmp = (Scsi_Cmnd *) hostdata->disconnected_queue; tmp; tmp = (Scsi_Cmnd *) tmp->host_scribble) if (cmd == tmp) { - restore_flags(flags); -#if (NDEBUG & NDEBUG_ABORT) - printk("scsi%d : aborting disconnected command.\n", instance->host_no); -#endif + dprintk(NDEBUG_ABORT, ("scsi%d : aborting disconnected command.\n", instance->host_no)); if (NCR5380_select(instance, cmd, (int) cmd->tag)) return SCSI_ABORT_BUSY; - -#if (NDEBUG & NDEBUG_ABORT) - printk("scsi%d : nexus reestablished.\n", instance->host_no); -#endif + dprintk(NDEBUG_ABORT, ("scsi%d : nexus reestablished.\n", instance->host_no)); do_abort(instance); - cli(); - for (prev = (Scsi_Cmnd **) & (hostdata->disconnected_queue), - tmp = (Scsi_Cmnd *) hostdata->disconnected_queue; - tmp; prev = (Scsi_Cmnd **) & (tmp->host_scribble), tmp = - (Scsi_Cmnd *) tmp->host_scribble) + for (prev = (Scsi_Cmnd **) & (hostdata->disconnected_queue), tmp = (Scsi_Cmnd *) hostdata->disconnected_queue; tmp; prev = (Scsi_Cmnd **) & (tmp->host_scribble), tmp = (Scsi_Cmnd *) tmp->host_scribble) if (cmd == tmp) { REMOVE(5, *prev, tmp, tmp->host_scribble); *prev = (Scsi_Cmnd *) tmp->host_scribble; tmp->host_scribble = NULL; tmp->result = DID_ABORT << 16; - restore_flags(flags); tmp->done(tmp); return SCSI_ABORT_SUCCESS; } @@ -3472,10 +2978,7 @@ * so we won't panic, but we will notify the user in case something really * broke. */ - - restore_flags(flags); - printk("scsi%d : warning : SCSI command probably completed successfully\n" - " before abortion\n", instance->host_no); + printk("scsi%d : warning : SCSI command probably completed successfully\n" " before abortion\n", instance->host_no); return SCSI_ABORT_NOT_RUNNING; } @@ -3487,6 +2990,7 @@ * * Returns : SCSI_RESET_WAKEUP * + * Locks: io_request_lock held by caller */ #ifndef NCR5380_reset diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/scsi/NCR5380.h linux-2.5/drivers/scsi/NCR5380.h --- linux-2.5.1/drivers/scsi/NCR5380.h Tue Feb 13 21:15:04 2001 +++ linux-2.5/drivers/scsi/NCR5380.h Thu Dec 13 16:32:36 2001 @@ -55,6 +55,8 @@ #define NDEBUG_C400_PWRITE 0x200000 #define NDEBUG_LISTS 0x400000 +#define NDEBUG_ANY 0xFFFFFFFFUL + /* * The contents of the OUTPUT DATA register are asserted on the bus when * either arbitration is occurring or the phase-indicating signals ( @@ -62,8 +64,8 @@ * bit in the INITIATOR COMMAND register is set. */ -#define OUTPUT_DATA_REG 0 /* wo DATA lines on SCSI bus */ -#define CURRENT_SCSI_DATA_REG 0 /* ro same */ +#define OUTPUT_DATA_REG 0 /* wo DATA lines on SCSI bus */ +#define CURRENT_SCSI_DATA_REG 0 /* ro same */ #define INITIATOR_COMMAND_REG 1 /* rw */ #define ICR_ASSERT_RST 0x80 /* rw Set to assert RST */ @@ -91,10 +93,10 @@ */ #define MR_BLOCK_DMA_MODE 0x80 /* rw block mode DMA */ #define MR_TARGET 0x40 /* rw target mode */ -#define MR_ENABLE_PAR_CHECK 0x20 /* rw enable parity checking */ +#define MR_ENABLE_PAR_CHECK 0x20 /* rw enable parity checking */ #define MR_ENABLE_PAR_INTR 0x10 /* rw enable bad parity interrupt */ #define MR_ENABLE_EOP_INTR 0x08 /* rw enable eop interrupt */ -#define MR_MONITOR_BSY 0x04 /* rw enable int on unexpected bsy fail */ +#define MR_MONITOR_BSY 0x04 /* rw enable int on unexpected bsy fail */ #define MR_DMA_MODE 0x02 /* rw DMA / pseudo DMA mode */ #define MR_ARBITRATE 0x01 /* rw start arbitration */ @@ -116,7 +118,7 @@ * Note : a set bit indicates an active signal, driven by us or another * device. */ -#define SR_RST 0x80 +#define SR_RST 0x80 #define SR_BSY 0x40 #define SR_REQ 0x20 #define SR_MSG 0x10 @@ -159,17 +161,17 @@ /* Write any value to this register to start an ini mode DMA receive */ #define START_DMA_INITIATOR_RECEIVE_REG 7 /* wo */ -#define C400_CONTROL_STATUS_REG NCR53C400_register_offset-8 /* rw */ +#define C400_CONTROL_STATUS_REG NCR53C400_register_offset-8 /* rw */ -#define CSR_RESET 0x80 /* wo Resets 53c400 */ -#define CSR_53C80_REG 0x80 /* ro 5380 registers busy */ -#define CSR_TRANS_DIR 0x40 /* rw Data transfer direction */ -#define CSR_SCSI_BUFF_INTR 0x20 /* rw Enable int on transfer ready */ -#define CSR_53C80_INTR 0x10 /* rw Enable 53c80 interrupts */ -#define CSR_SHARED_INTR 0x08 /* rw Interrupt sharing */ -#define CSR_HOST_BUF_NOT_RDY 0x04 /* ro Is Host buffer ready */ -#define CSR_SCSI_BUF_RDY 0x02 /* ro SCSI buffer read */ -#define CSR_GATED_53C80_IRQ 0x01 /* ro Last block xferred */ +#define CSR_RESET 0x80 /* wo Resets 53c400 */ +#define CSR_53C80_REG 0x80 /* ro 5380 registers busy */ +#define CSR_TRANS_DIR 0x40 /* rw Data transfer direction */ +#define CSR_SCSI_BUFF_INTR 0x20 /* rw Enable int on transfer ready */ +#define CSR_53C80_INTR 0x10 /* rw Enable 53c80 interrupts */ +#define CSR_SHARED_INTR 0x08 /* rw Interrupt sharing */ +#define CSR_HOST_BUF_NOT_RDY 0x04 /* ro Is Host buffer ready */ +#define CSR_SCSI_BUF_RDY 0x02 /* ro SCSI buffer read */ +#define CSR_GATED_53C80_IRQ 0x01 /* ro Last block xferred */ #if 0 #define CSR_BASE CSR_SCSI_BUFF_INTR | CSR_53C80_INTR @@ -178,13 +180,13 @@ #endif /* Number of 128-byte blocks to be transferred */ -#define C400_BLOCK_COUNTER_REG NCR53C400_register_offset-7 /* rw */ +#define C400_BLOCK_COUNTER_REG NCR53C400_register_offset-7 /* rw */ /* Resume transfer after disconnect */ -#define C400_RESUME_TRANSFER_REG NCR53C400_register_offset-6 /* wo */ +#define C400_RESUME_TRANSFER_REG NCR53C400_register_offset-6 /* wo */ /* Access to host buffer stack */ -#define C400_HOST_BUFFER NCR53C400_register_offset-4 /* rw */ +#define C400_HOST_BUFFER NCR53C400_register_offset-4 /* rw */ /* Note : PHASE_* macros are based on the values of the STATUS register */ @@ -203,8 +205,8 @@ * the target register so we can get phase mismatch interrupts on DMA * transfers. */ - -#define PHASE_SR_TO_TCR(phase) ((phase) >> 2) + +#define PHASE_SR_TO_TCR(phase) ((phase) >> 2) /* * The internal should_disconnect() function returns these based on the @@ -220,7 +222,7 @@ * These are "special" values for the tag parameter passed to NCR5380_select. */ -#define TAG_NEXT -1 /* Use next free tag */ +#define TAG_NEXT -1 /* Use next free tag */ #define TAG_NONE -2 /* * Establish I_T_L nexus instead of I_T_L_Q * even on SCSI-II devices. @@ -235,7 +237,7 @@ #define DMA_NONE 255 #define IRQ_AUTO 254 #define DMA_AUTO 254 -#define PORT_AUTO 0xffff /* autoprobe io port for 53c400a */ +#define PORT_AUTO 0xffff /* autoprobe io port for 53c400a */ #define FLAG_HAS_LAST_BYTE_SENT 1 /* NCR53c81 or better */ #define FLAG_CHECK_LAST_BYTE_SENT 2 /* Only test once */ @@ -245,134 +247,188 @@ #ifndef ASM struct NCR5380_hostdata { - NCR5380_implementation_fields; /* implementation specific */ - unsigned char id_mask, id_higher_mask; /* 1 << id, all bits greater */ - unsigned char targets_present; /* targets we have connected + NCR5380_implementation_fields; /* implementation specific */ + unsigned char id_mask, id_higher_mask; /* 1 << id, all bits greater */ + unsigned char targets_present; /* targets we have connected to, so we can call a select failure a retryable condition */ - volatile unsigned char busy[8]; /* index = target, bit = lun */ + volatile unsigned char busy[8]; /* index = target, bit = lun */ #if defined(REAL_DMA) || defined(REAL_DMA_POLL) - volatile int dma_len; /* requested length of DMA */ + volatile int dma_len; /* requested length of DMA */ #endif - volatile unsigned char last_message; /* last message OUT */ - volatile Scsi_Cmnd *connected; /* currently connected command */ - volatile Scsi_Cmnd *issue_queue; /* waiting to be issued */ - volatile Scsi_Cmnd *disconnected_queue; /* waiting for reconnect */ - volatile int restart_select; /* we have disconnected, + volatile unsigned char last_message; /* last message OUT */ + volatile Scsi_Cmnd *connected; /* currently connected command */ + volatile Scsi_Cmnd *issue_queue; /* waiting to be issued */ + volatile Scsi_Cmnd *disconnected_queue; /* waiting for reconnect */ + volatile int restart_select; /* we have disconnected, used to restart NCR5380_select() */ - volatile unsigned aborted:1; /* flag, says aborted */ - int flags; -#ifdef USLEEP - unsigned long time_expires; /* in jiffies, set prior to sleeping */ - struct Scsi_Host *next_timer; - int select_time; /* timer in select for target response */ - volatile Scsi_Cmnd *selecting; -#endif + volatile unsigned aborted:1; /* flag, says aborted */ + int flags; + unsigned long time_expires; /* in jiffies, set prior to sleeping */ + struct Scsi_Host *next_timer; + int select_time; /* timer in select for target response */ + volatile Scsi_Cmnd *selecting; #ifdef NCR5380_STATS - unsigned timebase; /* Base for time calcs */ - long time_read[8]; /* time to do reads */ - long time_write[8]; /* time to do writes */ - unsigned long bytes_read[8]; /* bytes read */ - unsigned long bytes_write[8]; /* bytes written */ - unsigned pendingr; - unsigned pendingw; + unsigned timebase; /* Base for time calcs */ + long time_read[8]; /* time to do reads */ + long time_write[8]; /* time to do writes */ + unsigned long bytes_read[8]; /* bytes read */ + unsigned long bytes_write[8]; /* bytes written */ + unsigned pendingr; + unsigned pendingw; #endif }; #ifdef __KERNEL__ -static struct Scsi_Host *first_instance; /* linked list of 5380's */ +static struct Scsi_Host *first_instance; /* linked list of 5380's */ + +#define dprintk(a,b) do {} while(0) +#define NCR5380_dprint(a,b) do {} while(0) +#define NCR5380_dprint_phase(a,b) do {} while(0) #if defined(AUTOPROBE_IRQ) -static int NCR5380_probe_irq (struct Scsi_Host *instance, int possible); +static int NCR5380_probe_irq(struct Scsi_Host *instance, int possible); #endif -static void NCR5380_init (struct Scsi_Host *instance, int flags); -static void NCR5380_information_transfer (struct Scsi_Host *instance); +static void NCR5380_init(struct Scsi_Host *instance, int flags); +static void NCR5380_information_transfer(struct Scsi_Host *instance); #ifndef DONT_USE_INTR -static void NCR5380_intr (int irq, void *dev_id, struct pt_regs * regs); -static void do_NCR5380_intr (int irq, void *dev_id, struct pt_regs * regs); +static void NCR5380_intr(int irq, void *dev_id, struct pt_regs *regs); +static void do_NCR5380_intr(int irq, void *dev_id, struct pt_regs *regs); #endif -static void NCR5380_main (void); -static void NCR5380_print_options (struct Scsi_Host *instance); -static void NCR5380_print_phase (struct Scsi_Host *instance); -static void NCR5380_print (struct Scsi_Host *instance); +static void NCR5380_main(void); +static void NCR5380_print_options(struct Scsi_Host *instance); +static void NCR5380_print_phase(struct Scsi_Host *instance); +static void NCR5380_print(struct Scsi_Host *instance); #ifndef NCR5380_abort static #endif -int NCR5380_abort (Scsi_Cmnd *cmd); +int NCR5380_abort(Scsi_Cmnd * cmd); #ifndef NCR5380_reset static #endif -int NCR5380_reset (Scsi_Cmnd *cmd, unsigned int reset_flags); +int NCR5380_reset(Scsi_Cmnd * cmd, unsigned int reset_flags); #ifndef NCR5380_queue_command -static +static #endif -int NCR5380_queue_command (Scsi_Cmnd *cmd, void (*done)(Scsi_Cmnd *)); +int NCR5380_queue_command(Scsi_Cmnd * cmd, void (*done) (Scsi_Cmnd *)); -static void NCR5380_reselect (struct Scsi_Host *instance); -static int NCR5380_select (struct Scsi_Host *instance, Scsi_Cmnd *cmd, int tag); +static void NCR5380_reselect(struct Scsi_Host *instance); +static int NCR5380_select(struct Scsi_Host *instance, Scsi_Cmnd * cmd, int tag); #if defined(PSEUDO_DMA) || defined(REAL_DMA) || defined(REAL_DMA_POLL) -static int NCR5380_transfer_dma (struct Scsi_Host *instance, - unsigned char *phase, int *count, unsigned char **data); +static int NCR5380_transfer_dma(struct Scsi_Host *instance, unsigned char *phase, int *count, unsigned char **data); #endif -static int NCR5380_transfer_pio (struct Scsi_Host *instance, - unsigned char *phase, int *count, unsigned char **data); +static int NCR5380_transfer_pio(struct Scsi_Host *instance, unsigned char *phase, int *count, unsigned char **data); #if (defined(REAL_DMA) || defined(REAL_DMA_POLL)) #if defined(i386) || defined(__alpha__) -static __inline__ int NCR5380_pc_dma_setup (struct Scsi_Host *instance, - unsigned char *ptr, unsigned int count, unsigned char mode) { - unsigned limit; - unsigned long bus_addr = virt_to_bus(ptr); - - if (instance->dma_channel <=3) { - if (count > 65536) - count = 65536; - limit = 65536 - (bus_addr & 0xFFFF); - } else { - if (count > 65536 * 2) - count = 65536 * 2; - limit = 65536* 2 - (bus_addr & 0x1FFFF); - } - - if (count > limit) count = limit; - - if ((count & 1) || (bus_addr & 1)) - panic ("scsi%d : attempted unaligned DMA transfer\n", instance->host_no); - cli(); - disable_dma(instance->dma_channel); - clear_dma_ff(instance->dma_channel); - set_dma_addr(instance->dma_channel, bus_addr); - set_dma_count(instance->dma_channel, count); - set_dma_mode(instance->dma_channel, mode); - enable_dma(instance->dma_channel); - sti(); - return count; +/** + * NCR5380_pc_dma_setup - setup ISA DMA + * @instance: adapter to set up + * @ptr: block to transfer (virtual address) + * @count: number of bytes to transfer + * @mode: DMA controller mode to use + * + * Program the DMA controller ready to perform an ISA DMA transfer + * on this chip. + * + * Locks: takes and releases the ISA DMA lock. + */ + +static __inline__ int NCR5380_pc_dma_setup(struct Scsi_Host *instance, unsigned char *ptr, unsigned int count, unsigned char mode) +{ + unsigned limit; + unsigned long bus_addr = virt_to_bus(ptr); + unsigned long flags; + + if (instance->dma_channel <= 3) { + if (count > 65536) + count = 65536; + limit = 65536 - (bus_addr & 0xFFFF); + } else { + if (count > 65536 * 2) + count = 65536 * 2; + limit = 65536 * 2 - (bus_addr & 0x1FFFF); + } + + if (count > limit) + count = limit; + + if ((count & 1) || (bus_addr & 1)) + panic("scsi%d : attempted unaligned DMA transfer\n", instance->host_no); + + flags=claim_dma_lock(); + disable_dma(instance->dma_channel); + clear_dma_ff(instance->dma_channel); + set_dma_addr(instance->dma_channel, bus_addr); + set_dma_count(instance->dma_channel, count); + set_dma_mode(instance->dma_channel, mode); + enable_dma(instance->dma_channel); + release_dma_lock(flags); + + return count; } -static __inline__ int NCR5380_pc_dma_write_setup (struct Scsi_Host *instance, - unsigned char *src, unsigned int count) { - return NCR5380_pc_dma_setup (instance, src, count, DMA_MODE_WRITE); +/** + * NCR5380_pc_dma_write_setup - setup ISA DMA write + * @instance: adapter to set up + * @ptr: block to transfer (virtual address) + * @count: number of bytes to transfer + * + * Program the DMA controller ready to perform an ISA DMA write to the + * SCSI controller. + * + * Locks: called routines take and release the ISA DMA lock. + */ + +static __inline__ int NCR5380_pc_dma_write_setup(struct Scsi_Host *instance, unsigned char *src, unsigned int count) +{ + return NCR5380_pc_dma_setup(instance, src, count, DMA_MODE_WRITE); } -static __inline__ int NCR5380_pc_dma_read_setup (struct Scsi_Host *instance, - unsigned char *src, unsigned int count) { - return NCR5380_pc_dma_setup (instance, src, count, DMA_MODE_READ); +/** + * NCR5380_pc_dma_read_setup - setup ISA DMA read + * @instance: adapter to set up + * @ptr: block to transfer (virtual address) + * @count: number of bytes to transfer + * + * Program the DMA controller ready to perform an ISA DMA read from the + * SCSI controller. + * + * Locks: called routines take and release the ISA DMA lock. + */ + +static __inline__ int NCR5380_pc_dma_read_setup(struct Scsi_Host *instance, unsigned char *src, unsigned int count) +{ + return NCR5380_pc_dma_setup(instance, src, count, DMA_MODE_READ); } -static __inline__ int NCR5380_pc_dma_residual (struct Scsi_Host *instance) { - register int tmp; - cli(); - clear_dma_ff(instance->dma_channel); - tmp = get_dma_residue(instance->dma_channel); - sti(); - return tmp; +/** + * NCR5380_pc_dma_residual - return bytes left + * @instance: adapter + * + * Reports the number of bytes left over after the DMA was terminated. + * + * Locks: takes and releases the ISA DMA lock. + */ + +static __inline__ int NCR5380_pc_dma_residual(struct Scsi_Host *instance) +{ + unsigned long flags; + int tmp; + + flags = claim_dma_lock(); + clear_dma_ff(instance->dma_channel); + tmp = get_dma_residue(instance->dma_channel); + release_dma_lock(flags); + + return tmp; } -#endif /* defined(i386) || defined(__alpha__) */ -#endif /* defined(REAL_DMA) */ -#endif /* __KERNEL__ */ -#endif /* ndef ASM */ -#endif /* NCR5380_H */ +#endif /* defined(i386) || defined(__alpha__) */ +#endif /* defined(REAL_DMA) */ +#endif /* __KERNEL__ */ +#endif /* ndef ASM */ +#endif /* NCR5380_H */ diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/scsi/aacraid/Makefile linux-2.5/drivers/scsi/aacraid/Makefile --- linux-2.5.1/drivers/scsi/aacraid/Makefile Thu Jan 1 00:00:00 1970 +++ linux-2.5/drivers/scsi/aacraid/Makefile Thu Dec 13 16:32:36 2001 @@ -0,0 +1,16 @@ + +EXTRA_CFLAGS += -I$(TOPDIR)/drivers/scsi + + +O_TARGET := dummy.o + +list-multi := aacraid.o +aacraid-objs := linit.o aachba.o commctrl.o comminit.o commsup.o \ + dpcsup.o rx.o sap1sup.o + +obj-$(CONFIG_SCSI_AACRAID) += aacraid.o + +include $(TOPDIR)/Rules.make + +aacraid.o: $(aacraid-objs) + $(LD) -r -o $@ $(aacraid-objs) diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/scsi/aacraid/README linux-2.5/drivers/scsi/aacraid/README --- linux-2.5.1/drivers/scsi/aacraid/README Thu Jan 1 00:00:00 1970 +++ linux-2.5/drivers/scsi/aacraid/README Thu Dec 13 16:32:36 2001 @@ -0,0 +1,41 @@ +AACRAID Driver for Linux (take two) + +Introduction +------------------------- +The aacraid driver adds support for Adaptec (http://www.adaptec.com) +OEM based RAID controllers. This is a major rewrite from the original +Adaptec supplied driver. It has signficantly cleaned up both the code +and the running binary size (the module is less than half the size of +the original). + +This driver is experimental. + +Supported Cards/Chipsets +------------------------- + Dell Computer Corporation PERC 2 Quad Channel + Dell Computer Corporation PERC 2/Si + Dell Computer Corporation PERC 3/Si + Dell Computer Corporation PERC 3/Di + HP NetRAID-4M + +Probably Supported Devices +------------------------- + Any and All Adaptec branded AAC964/5400 series raid controllers. + +People +------------------------- +Alan Cox <alan@redhat.com> +Christoph Hellwig <hch@caldera.de> (small cleanups/fixes) +Matt Domsch <matt_domsch@dell.com> (revision ioctl, adapter messages) + +Original Driver +------------------------- +Adaptec Unix OEM Product Group + +Mailing List +------------------------- +None currently. Also note this is very different to Brian's original driver +so don't expect him to support it. + +Original by Brian Boerner February 2001 +Rewritten by Alan Cox, November 2001 diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/scsi/aacraid/TODO linux-2.5/drivers/scsi/aacraid/TODO --- linux-2.5.1/drivers/scsi/aacraid/TODO Thu Jan 1 00:00:00 1970 +++ linux-2.5/drivers/scsi/aacraid/TODO Thu Dec 13 16:32:36 2001 @@ -0,0 +1,4 @@ +o Testing +o More testing +o Feature request: display the firmware/bios/etc revisions in the + /proc info diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/scsi/aacraid/aachba.c linux-2.5/drivers/scsi/aacraid/aachba.c --- linux-2.5.1/drivers/scsi/aacraid/aachba.c Thu Jan 1 00:00:00 1970 +++ linux-2.5/drivers/scsi/aacraid/aachba.c Thu Dec 13 16:32:36 2001 @@ -0,0 +1,1153 @@ +/* + * Adaptec AAC series RAID controller driver + * (c) Copyright 2001 Red Hat Inc. <alan@redhat.com> + * + * based on the old aacraid driver that is.. + * Adaptec aacraid device driver for Linux. + * Copyright (c) 2000 Adaptec, Inc. (aacraid@adaptec.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, 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; see the file COPYING. If not, write to + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * + */ + +#include <linux/config.h> +#include <linux/kernel.h> +#include <linux/init.h> +#include <linux/types.h> +#include <linux/sched.h> +#include <linux/pci.h> +#include <linux/spinlock.h> +#include <linux/slab.h> +#include <linux/completion.h> +#include <asm/semaphore.h> +#include <asm/uaccess.h> +#define MAJOR_NR SCSI_DISK0_MAJOR /* For DEVICE_NR() */ +#include <linux/blk.h> +#include "scsi.h" +#include "hosts.h" +#include "sd.h" + +#include "aacraid.h" + +/* SCSI Commands */ +#define SS_TEST 0x00 /* Test unit ready */ +#define SS_REZERO 0x01 /* Rezero unit */ +#define SS_REQSEN 0x03 /* Request Sense */ +#define SS_REASGN 0x07 /* Reassign blocks */ +#define SS_READ 0x08 /* Read 6 */ +#define SS_WRITE 0x0A /* Write 6 */ +#define SS_INQUIR 0x12 /* inquiry */ +#define SS_ST_SP 0x1B /* Start/Stop unit */ +#define SS_LOCK 0x1E /* prevent/allow medium removal */ +#define SS_RESERV 0x16 /* Reserve */ +#define SS_RELES 0x17 /* Release */ +#define SS_MODESEN 0x1A /* Mode Sense 6 */ +#define SS_RDCAP 0x25 /* Read Capacity */ +#define SM_READ 0x28 /* Read 10 */ +#define SM_WRITE 0x2A /* Write 10 */ +#define SS_SEEK 0x2B /* Seek */ + +/* values for inqd_pdt: Peripheral device type in plain English */ +#define INQD_PDT_DA 0x00 /* Direct-access (DISK) device */ +#define INQD_PDT_PROC 0x03 /* Processor device */ +#define INQD_PDT_CHNGR 0x08 /* Changer (jukebox, scsi2) */ +#define INQD_PDT_COMM 0x09 /* Communication device (scsi2) */ +#define INQD_PDT_NOLUN2 0x1f /* Unknown Device (scsi2) */ +#define INQD_PDT_NOLUN 0x7f /* Logical Unit Not Present */ + +#define INQD_PDT_DMASK 0x1F /* Peripheral Device Type Mask */ +#define INQD_PDT_QMASK 0xE0 /* Peripheral Device Qualifer Mask */ + +#define TARGET_LUN_TO_CONTAINER(target, lun) (((lun) << 4) | target) +#define CONTAINER_TO_TARGET(cont) ((cont) & 0xf) +#define CONTAINER_TO_LUN(cont) ((cont) >> 4) + +#define MAX_FIB_DATA (sizeof(struct hw_fib) - sizeof(FIB_HEADER)) + +#define MAX_DRIVER_SG_SEGMENT_COUNT 17 + +/* + * Sense keys + */ +#define SENKEY_NO_SENSE 0x00 +#define SENKEY_UNDEFINED 0x01 +#define SENKEY_NOT_READY 0x02 +#define SENKEY_MEDIUM_ERR 0x03 +#define SENKEY_HW_ERR 0x04 +#define SENKEY_ILLEGAL 0x05 +#define SENKEY_ATTENTION 0x06 +#define SENKEY_PROTECTED 0x07 +#define SENKEY_BLANK 0x08 +#define SENKEY_V_UNIQUE 0x09 +#define SENKEY_CPY_ABORT 0x0A +#define SENKEY_ABORT 0x0B +#define SENKEY_EQUAL 0x0C +#define SENKEY_VOL_OVERFLOW 0x0D +#define SENKEY_MISCOMP 0x0E +#define SENKEY_RESERVED 0x0F + +/* + * Sense codes + */ + +#define SENCODE_NO_SENSE 0x00 +#define SENCODE_END_OF_DATA 0x00 +#define SENCODE_BECOMING_READY 0x04 +#define SENCODE_INIT_CMD_REQUIRED 0x04 +#define SENCODE_PARAM_LIST_LENGTH_ERROR 0x1A +#define SENCODE_INVALID_COMMAND 0x20 +#define SENCODE_LBA_OUT_OF_RANGE 0x21 +#define SENCODE_INVALID_CDB_FIELD 0x24 +#define SENCODE_LUN_NOT_SUPPORTED 0x25 +#define SENCODE_INVALID_PARAM_FIELD 0x26 +#define SENCODE_PARAM_NOT_SUPPORTED 0x26 +#define SENCODE_PARAM_VALUE_INVALID 0x26 +#define SENCODE_RESET_OCCURRED 0x29 +#define SENCODE_LUN_NOT_SELF_CONFIGURED_YET 0x3E +#define SENCODE_INQUIRY_DATA_CHANGED 0x3F +#define SENCODE_SAVING_PARAMS_NOT_SUPPORTED 0x39 +#define SENCODE_DIAGNOSTIC_FAILURE 0x40 +#define SENCODE_INTERNAL_TARGET_FAILURE 0x44 +#define SENCODE_INVALID_MESSAGE_ERROR 0x49 +#define SENCODE_LUN_FAILED_SELF_CONFIG 0x4c +#define SENCODE_OVERLAPPED_COMMAND 0x4E + +/* + * Additional sense codes + */ + +#define ASENCODE_NO_SENSE 0x00 +#define ASENCODE_END_OF_DATA 0x05 +#define ASENCODE_BECOMING_READY 0x01 +#define ASENCODE_INIT_CMD_REQUIRED 0x02 +#define ASENCODE_PARAM_LIST_LENGTH_ERROR 0x00 +#define ASENCODE_INVALID_COMMAND 0x00 +#define ASENCODE_LBA_OUT_OF_RANGE 0x00 +#define ASENCODE_INVALID_CDB_FIELD 0x00 +#define ASENCODE_LUN_NOT_SUPPORTED 0x00 +#define ASENCODE_INVALID_PARAM_FIELD 0x00 +#define ASENCODE_PARAM_NOT_SUPPORTED 0x01 +#define ASENCODE_PARAM_VALUE_INVALID 0x02 +#define ASENCODE_RESET_OCCURRED 0x00 +#define ASENCODE_LUN_NOT_SELF_CONFIGURED_YET 0x00 +#define ASENCODE_INQUIRY_DATA_CHANGED 0x03 +#define ASENCODE_SAVING_PARAMS_NOT_SUPPORTED 0x00 +#define ASENCODE_DIAGNOSTIC_FAILURE 0x80 +#define ASENCODE_INTERNAL_TARGET_FAILURE 0x00 +#define ASENCODE_INVALID_MESSAGE_ERROR 0x00 +#define ASENCODE_LUN_FAILED_SELF_CONFIG 0x00 +#define ASENCODE_OVERLAPPED_COMMAND 0x00 + +#define BYTE0(x) (unsigned char)(x) +#define BYTE1(x) (unsigned char)((x) >> 8) +#define BYTE2(x) (unsigned char)((x) >> 16) +#define BYTE3(x) (unsigned char)((x) >> 24) + +/*------------------------------------------------------------------------------ + * S T R U C T S / T Y P E D E F S + *----------------------------------------------------------------------------*/ +/* SCSI inquiry data */ +struct inquiry_data { + u8 inqd_pdt; /* Peripheral qualifier | Peripheral Device Type */ + u8 inqd_dtq; /* RMB | Device Type Qualifier */ + u8 inqd_ver; /* ISO version | ECMA version | ANSI-approved version */ + u8 inqd_rdf; /* AENC | TrmIOP | Response data format */ + u8 inqd_len; /* Additional length (n-4) */ + u8 inqd_pad1[2];/* Reserved - must be zero */ + u8 inqd_pad2; /* RelAdr | WBus32 | WBus16 | Sync | Linked |Reserved| CmdQue | SftRe */ + u8 inqd_vid[8]; /* Vendor ID */ + u8 inqd_pid[16];/* Product ID */ + u8 inqd_prl[4]; /* Product Revision Level */ +}; + +struct sense_data { + u8 error_code; /* 70h (current errors), 71h(deferred errors) */ + u8 valid:1; /* A valid bit of one indicates that the information */ + /* field contains valid information as defined in the + * SCSI-2 Standard. + */ + u8 segment_number; /* Only used for COPY, COMPARE, or COPY AND VERIFY Commands */ + u8 sense_key:4; /* Sense Key */ + u8 reserved:1; + u8 ILI:1; /* Incorrect Length Indicator */ + u8 EOM:1; /* End Of Medium - reserved for random access devices */ + u8 filemark:1; /* Filemark - reserved for random access devices */ + + u8 information[4]; /* for direct-access devices, contains the unsigned + * logical block address or residue associated with + * the sense key + */ + u8 add_sense_len; /* number of additional sense bytes to follow this field */ + u8 cmnd_info[4]; /* not used */ + u8 ASC; /* Additional Sense Code */ + u8 ASCQ; /* Additional Sense Code Qualifier */ + u8 FRUC; /* Field Replaceable Unit Code - not used */ + u8 bit_ptr:3; /* indicates which byte of the CDB or parameter data + * was in error + */ + u8 BPV:1; /* bit pointer valid (BPV): 1- indicates that + * the bit_ptr field has valid value + */ + u8 reserved2:2; + u8 CD:1; /* command data bit: 1- illegal parameter in CDB. + * 0- illegal parameter in data. + */ + u8 SKSV:1; + u8 field_ptr[2]; /* byte of the CDB or parameter data in error */ +}; + +/* + * M O D U L E G L O B A L S + */ + +static struct fsa_scsi_hba *fsa_dev[MAXIMUM_NUM_ADAPTERS]; /* SCSI Device Instance Pointers */ +static struct sense_data sense_data[MAXIMUM_NUM_CONTAINERS]; +static void get_sd_devname(int disknum, char *buffer); + +/** + * aac_get_containers - list containers + * @common: adapter to probe + * + * Make a list of all containers on this controller + */ +int aac_get_containers(struct aac_dev *dev) +{ + struct fsa_scsi_hba *fsa_dev_ptr; + int index, status = 0; + struct aac_query_mount *dinfo; + struct aac_mount *dresp; + struct fib * fibptr; + unsigned instance; + + fsa_dev_ptr = &(dev->fsa_dev); + instance = dev->scsi_host_ptr->unique_id; + + if (!(fibptr = fib_alloc(dev))) + return -ENOMEM; + + for (index = 0; index < MAXIMUM_NUM_CONTAINERS; index++) { + fib_init(fibptr); + dinfo = (struct aac_query_mount *) fib_data(fibptr); + + dinfo->command = cpu_to_le32(VM_NameServe); + dinfo->count = cpu_to_le32(index); + dinfo->type = cpu_to_le32(FT_FILESYS); + + status = fib_send(ContainerCommand, + fibptr, + sizeof (struct aac_query_mount), + FsaNormal, + 1, 1, + NULL, NULL); + if (status < 0 ) { + printk(KERN_WARNING "ProbeContainers: SendFIB failed.\n"); + break; + } + dresp = (struct aac_mount *)fib_data(fibptr); + + if ((le32_to_cpu(dresp->status) == ST_OK) && + (le32_to_cpu(dresp->mnt[0].vol) != CT_NONE)) { + fsa_dev_ptr->valid[index] = 1; + fsa_dev_ptr->type[index] = le32_to_cpu(dresp->mnt[0].vol); + fsa_dev_ptr->size[index] = le32_to_cpu(dresp->mnt[0].capacity); + if (le32_to_cpu(dresp->mnt[0].state) & FSCS_READONLY) + fsa_dev_ptr->ro[index] = 1; + } + fib_complete(fibptr); + /* + * If there are no more containers, then stop asking. + */ + if ((index + 1) >= le32_to_cpu(dresp->count)) + break; + } + fib_free(fibptr); + fsa_dev[instance] = fsa_dev_ptr; + return status; +} + +/** + * probe_container - query a logical volume + * @dev: device to query + * @cid: container identifier + * + * Queries the controller about the given volume. The volume information + * is updated in the struct fsa_scsi_hba structure rather than returned. + */ + +static int probe_container(struct aac_dev *dev, int cid) +{ + struct fsa_scsi_hba *fsa_dev_ptr; + int status; + struct aac_query_mount *dinfo; + struct aac_mount *dresp; + struct fib * fibptr; + unsigned instance; + + fsa_dev_ptr = &(dev->fsa_dev); + instance = dev->scsi_host_ptr->unique_id; + + if (!(fibptr = fib_alloc(dev))) + return -ENOMEM; + + fib_init(fibptr); + + dinfo = (struct aac_query_mount *)fib_data(fibptr); + + dinfo->command = cpu_to_le32(VM_NameServe); + dinfo->count = cpu_to_le32(cid); + dinfo->type = cpu_to_le32(FT_FILESYS); + + status = fib_send(ContainerCommand, + fibptr, + sizeof(struct aac_query_mount), + FsaNormal, + 1, 1, + NULL, NULL); + if (status < 0) { + printk(KERN_WARNING "aacraid: probe_containers query failed.\n"); + goto error; + } + + dresp = (struct aac_mount *) fib_data(fibptr); + + if ((le32_to_cpu(dresp->status) == ST_OK) && + (le32_to_cpu(dresp->mnt[0].vol) != CT_NONE)) { + fsa_dev_ptr->valid[cid] = 1; + fsa_dev_ptr->type[cid] = le32_to_cpu(dresp->mnt[0].vol); + fsa_dev_ptr->size[cid] = le32_to_cpu(dresp->mnt[0].capacity); + if (le32_to_cpu(dresp->mnt[0].state) & FSCS_READONLY) + fsa_dev_ptr->ro[cid] = 1; + } + +error: + fib_complete(fibptr); + fib_free(fibptr); + + return status; +} + +/* Local Structure to set SCSI inquiry data strings */ +struct scsi_inq { + char vid[8]; /* Vendor ID */ + char pid[16]; /* Product ID */ + char prl[4]; /* Product Revision Level */ +}; + +/** + * InqStrCopy - string merge + * @a: string to copy from + * @b: string to copy to + * + * Copy a String from one location to another + * without copying \0 + */ + +static void inqstrcpy(char *a, char *b) +{ + + while(*a != (char)0) + *b++ = *a++; +} + +static char *container_types[] = { + "None", + "Volume", + "Mirror", + "Stripe", + "RAID5", + "SSRW", + "SSRO", + "Morph", + "Legacy", + "RAID4", + "RAID10", + "RAID00", + "V-MIRRORS", + "PSEUDO R4", + "RAID50", + "Unknown" +}; + + + +/* Function: setinqstr + * + * Arguments: [1] pointer to void [1] int + * + * Purpose: Sets SCSI inquiry data strings for vendor, product + * and revision level. Allows strings to be set in platform dependant + * files instead of in OS dependant driver source. + */ + +static void setinqstr(int devtype, void *data, int tindex) +{ + struct scsi_inq *str; + char *findit; + struct aac_driver_ident *mp; + extern struct aac_driver_ident aac_drivers[]; /* HACK FIXME */ + + mp = &aac_drivers[devtype]; + + str = (struct scsi_inq *)(data); /* cast data to scsi inq block */ + + inqstrcpy (mp->vname, str->vid); + inqstrcpy (mp->model, str->pid); /* last six chars reserved for vol type */ + + findit = str->pid; + + for ( ; *findit != ' '; findit++); /* walk till we find a space then incr by 1 */ + findit++; + + if (tindex < (sizeof(container_types)/sizeof(char *))){ + inqstrcpy (container_types[tindex], findit); + } + inqstrcpy ("0001", str->prl); +} + +void set_sense(char *sense_buf, u8 sense_key, u8 sense_code, + u8 a_sense_code, u8 incorrect_length, + u8 bit_pointer, unsigned field_pointer, + unsigned long residue) +{ + sense_buf[0] = 0xF0; /* Sense data valid, err code 70h (current error) */ + sense_buf[1] = 0; /* Segment number, always zero */ + + if (incorrect_length) { + sense_buf[2] = sense_key | 0x20; /* Set the ILI bit | sense key */ + sense_buf[3] = BYTE3(residue); + sense_buf[4] = BYTE2(residue); + sense_buf[5] = BYTE1(residue); + sense_buf[6] = BYTE0(residue); + } else + sense_buf[2] = sense_key; /* Sense key */ + + if (sense_key == SENKEY_ILLEGAL) + sense_buf[7] = 10; /* Additional sense length */ + else + sense_buf[7] = 6; /* Additional sense length */ + + sense_buf[12] = sense_code; /* Additional sense code */ + sense_buf[13] = a_sense_code; /* Additional sense code qualifier */ + if (sense_key == SENKEY_ILLEGAL) { + sense_buf[15] = 0; + + if (sense_code == SENCODE_INVALID_PARAM_FIELD) + sense_buf[15] = 0x80; /* Std sense key specific field */ + /* Illegal parameter is in the parameter block */ + + if (sense_code == SENCODE_INVALID_CDB_FIELD) + sense_buf[15] = 0xc0; /* Std sense key specific field */ + /* Illegal parameter is in the CDB block */ + sense_buf[15] |= bit_pointer; + sense_buf[16] = field_pointer >> 8; /* MSB */ + sense_buf[17] = field_pointer; /* LSB */ + } +} + +static void aac_io_done(Scsi_Cmnd * scsicmd) +{ + unsigned long cpu_flags; + spin_lock_irqsave(&io_request_lock, cpu_flags); + scsicmd->scsi_done(scsicmd); + spin_unlock_irqrestore(&io_request_lock, cpu_flags); +} + +static void __aac_io_done(Scsi_Cmnd * scsicmd) +{ + scsicmd->scsi_done(scsicmd); +} + +static void read_callback(void *context, struct fib * fibptr) +{ + struct aac_dev *dev; + struct aac_read_reply *readreply; + Scsi_Cmnd *scsicmd; + unsigned long lba; + int cid; + + scsicmd = (Scsi_Cmnd *) context; + + dev = (struct aac_dev *)scsicmd->host->hostdata; + cid =TARGET_LUN_TO_CONTAINER(scsicmd->target, scsicmd->lun); + + lba = ((scsicmd->cmnd[1] & 0x1F) << 16) | (scsicmd->cmnd[2] << 8) | scsicmd->cmnd[3]; + dprintk((KERN_DEBUG "read_callback[cpu %d]: lba = %ld, t = %ld.\n", smp_processor_id(), lba, jiffies)); + + if (fibptr == NULL) + BUG(); + + if(scsicmd->use_sg) + pci_unmap_sg(dev->pdev, + (struct scatterlist *)scsicmd->buffer, + scsicmd->use_sg, + scsi_to_pci_dma_dir(scsicmd->sc_data_direction)); + else if(scsicmd->request_bufflen) + pci_unmap_single(dev->pdev, (u32)scsicmd->SCp.ptr, scsicmd->request_bufflen, + scsi_to_pci_dma_dir(scsicmd->sc_data_direction)); + readreply = (struct aac_read_reply *)fib_data(fibptr); + if (le32_to_cpu(readreply->status) == ST_OK) + scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | GOOD; + else { + printk(KERN_WARNING "read_callback: read failed, status = %d\n", readreply->status); + scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | CHECK_CONDITION; + set_sense((char *) &sense_data[cid], + SENKEY_HW_ERR, + SENCODE_INTERNAL_TARGET_FAILURE, + ASENCODE_INTERNAL_TARGET_FAILURE, 0, 0, + 0, 0); + } + fib_complete(fibptr); + fib_free(fibptr); + + aac_io_done(scsicmd); +} + +static void write_callback(void *context, struct fib * fibptr) +{ + struct aac_dev *dev; + struct aac_write_reply *writereply; + Scsi_Cmnd *scsicmd; + unsigned long lba; + int cid; + + scsicmd = (Scsi_Cmnd *) context; + dev = (struct aac_dev *)scsicmd->host->hostdata; + cid = TARGET_LUN_TO_CONTAINER(scsicmd->target, scsicmd->lun); + + lba = ((scsicmd->cmnd[1] & 0x1F) << 16) | (scsicmd->cmnd[2] << 8) | scsicmd->cmnd[3]; + dprintk((KERN_DEBUG "write_callback[cpu %d]: lba = %ld, t = %ld.\n", smp_processor_id(), lba, jiffies)); + if (fibptr == NULL) + BUG(); + + if(scsicmd->use_sg) + pci_unmap_sg(dev->pdev, + (struct scatterlist *)scsicmd->buffer, + scsicmd->use_sg, + scsi_to_pci_dma_dir(scsicmd->sc_data_direction)); + else if(scsicmd->request_bufflen) + pci_unmap_single(dev->pdev, (u32)scsicmd->SCp.ptr, scsicmd->request_bufflen, + scsi_to_pci_dma_dir(scsicmd->sc_data_direction)); + + writereply = (struct aac_write_reply *) fib_data(fibptr); + if (le32_to_cpu(writereply->status) == ST_OK) + scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | GOOD; + else { + printk(KERN_WARNING "write_callback: write failed, status = %d\n", writereply->status); + scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | CHECK_CONDITION; + set_sense((char *) &sense_data[cid], + SENKEY_HW_ERR, + SENCODE_INTERNAL_TARGET_FAILURE, + ASENCODE_INTERNAL_TARGET_FAILURE, 0, 0, + 0, 0); + } + + fib_complete(fibptr); + fib_free(fibptr); + aac_io_done(scsicmd); +} + +int aac_read(Scsi_Cmnd * scsicmd, int cid) +{ + unsigned long lba; + unsigned long count; + unsigned long byte_count = 0; + int status; + + struct aac_read *readcmd; + u16 fibsize; + struct aac_dev *dev; + struct fib * cmd_fibcontext; + + dev = (struct aac_dev *)scsicmd->host->hostdata; + /* + * Get block address and transfer length + */ + if (scsicmd->cmnd[0] == SS_READ) /* 6 byte command */ + { + dprintk((KERN_DEBUG "aachba: received a read(6) command on target %d.\n", cid)); + + lba = ((scsicmd->cmnd[1] & 0x1F) << 16) | (scsicmd->cmnd[2] << 8) | scsicmd->cmnd[3]; + count = scsicmd->cmnd[4]; + + if (count == 0) + count = 256; + } else { + dprintk((KERN_DEBUG "aachba: received a read(10) command on target %d.\n", cid)); + + lba = (scsicmd->cmnd[2] << 24) | (scsicmd->cmnd[3] << 16) | (scsicmd->cmnd[4] << 8) | scsicmd->cmnd[5]; + count = (scsicmd->cmnd[7] << 8) | scsicmd->cmnd[8]; + } + dprintk((KERN_DEBUG "aac_read[cpu %d]: lba = %lu, t = %ld.\n", smp_processor_id(), lba, jiffies)); + /* + * Alocate and initialize a Fib + */ + if (!(cmd_fibcontext = fib_alloc(dev))) { + scsicmd->result = DID_ERROR << 16; + aac_io_done(scsicmd); + return (-1); + } + + fib_init(cmd_fibcontext); + + readcmd = (struct aac_read *) fib_data(cmd_fibcontext); + readcmd->command = cpu_to_le32(VM_CtBlockRead); + readcmd->cid = cpu_to_le32(cid); + readcmd->block = cpu_to_le32(lba); + readcmd->count = cpu_to_le32(count * 512); + readcmd->sg.count = cpu_to_le32(1); + + if (count * 512 > (64 * 1024)) + BUG(); + /* + * Build Scatter/Gather list + */ + if (scsicmd->use_sg) /* use scatter/gather list */ + { + struct scatterlist *sg; + int i; + int sg_count; + + sg = (struct scatterlist *) scsicmd->request_buffer; + + sg_count = pci_map_sg(dev->pdev, sg, scsicmd->use_sg, + scsi_to_pci_dma_dir(scsicmd->sc_data_direction)); + + byte_count = 0; + + for (i = 0; i < sg_count; i++) { + readcmd->sg.sg[i].addr = cpu_to_le32(sg_dma_address(sg)); + readcmd->sg.sg[i].count = cpu_to_le32(sg_dma_len(sg)); + byte_count += sg->length; + if (sg->length > (64 * 1024)) + BUG(); + sg++; + } + readcmd->sg.count = cpu_to_le32(sg_count); + + if (sg_count > MAX_DRIVER_SG_SEGMENT_COUNT) + BUG(); + } + else if(scsicmd->request_bufflen) + { + u32 addr; + addr = pci_map_single(dev->pdev, scsicmd->request_buffer, + scsicmd->request_bufflen, scsi_to_pci_dma_dir(scsicmd->sc_data_direction)); + scsicmd->SCp.ptr = (void *)addr; + readcmd->sg.sg[0].addr = cpu_to_le32(addr); + readcmd->sg.sg[0].count = cpu_to_le32(scsicmd->request_bufflen); + + byte_count = scsicmd->request_bufflen; + + if (byte_count > (64 * 1024)) + BUG(); + } + if (byte_count != readcmd->count) + BUG(); + /* + * Now send the Fib to the adapter + */ + fibsize = sizeof(struct aac_read) + ((readcmd->sg.count - 1) * sizeof (struct sgentry)); + status = fib_send(ContainerCommand, + cmd_fibcontext, + fibsize, + FsaNormal, + 0, 1, + (fib_callback) read_callback, + (void *) scsicmd); + /* + * Check that the command queued to the controller + */ + if (status == -EINPROGRESS) + return 0; + + printk(KERN_WARNING "aac_read: fib_send failed with status: %d.\n", status); + /* + * For some reason, the Fib didn't queue, return QUEUE_FULL + */ + scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | QUEUE_FULL; + aac_io_done(scsicmd); + fib_complete(cmd_fibcontext); + fib_free(cmd_fibcontext); + return -1; +} + +static int aac_write(Scsi_Cmnd * scsicmd, int cid) +{ + unsigned long lba; + unsigned long count; + unsigned long byte_count = 0; + int status; + struct aac_write *writecmd; + u16 fibsize; + struct aac_dev *dev; + struct fib * cmd_fibcontext; + + dev = (struct aac_dev *)scsicmd->host->hostdata; + /* + * Get block address and transfer length + */ + if (scsicmd->cmnd[0] == SS_WRITE) /* 6 byte command */ + { + lba = ((scsicmd->cmnd[1] & 0x1F) << 16) | (scsicmd->cmnd[2] << 8) | scsicmd->cmnd[3]; + count = scsicmd->cmnd[4]; + if (count == 0) + count = 256; + } else { + dprintk((KERN_DEBUG "aachba: received a write(10) command on target %d.\n", cid)); + lba = (scsicmd->cmnd[2] << 24) | (scsicmd->cmnd[3] << 16) | (scsicmd->cmnd[4] << 8) | scsicmd->cmnd[5]; + count = (scsicmd->cmnd[7] << 8) | scsicmd->cmnd[8]; + } + dprintk((KERN_DEBUG "aac_write[cpu %d]: lba = %lu, t = %ld.\n", smp_processor_id(), lba, jiffies)); + /* + * Allocate and initialize a Fib then setup a BlockWrite command + */ + if (!(cmd_fibcontext = fib_alloc(dev))) { + scsicmd->result = DID_ERROR << 16; + aac_io_done(scsicmd); + return -1; + } + fib_init(cmd_fibcontext); + + writecmd = (struct aac_write *) fib_data(cmd_fibcontext); + writecmd->command = cpu_to_le32(VM_CtBlockWrite); + writecmd->cid = cpu_to_le32(cid); + writecmd->block = cpu_to_le32(lba); + writecmd->count = cpu_to_le32(count * 512); + writecmd->sg.count = cpu_to_le32(1); + /* FIXME: why isnt ->stable setup */ + + if (count * 512 > (64 * 1024)) { + BUG(); + } + /* + * Build Scatter/Gather list + */ + if (scsicmd->use_sg) + { + struct scatterlist *sg; + int i; + int sg_count; + + sg = (struct scatterlist *) scsicmd->request_buffer; + + sg_count = pci_map_sg(dev->pdev, sg, scsicmd->use_sg, + scsi_to_pci_dma_dir(scsicmd->sc_data_direction)); + + byte_count = 0; + + for (i = 0; i < scsicmd->use_sg; i++) { + writecmd->sg.sg[i].addr = cpu_to_le32(sg_dma_address(sg)); + writecmd->sg.sg[i].count = cpu_to_le32(sg_dma_len(sg)); + byte_count += sg->length; + + if (sg->length > (64 * 1024)) + BUG(); + sg++; + } + writecmd->sg.count = cpu_to_le32(sg_count); + + if (sg_count > MAX_DRIVER_SG_SEGMENT_COUNT) + BUG(); + } + else if(scsicmd->request_bufflen) + { + u32 addr; + addr = pci_map_single(dev->pdev, + scsicmd->request_buffer, + scsicmd->request_bufflen, + scsi_to_pci_dma_dir(scsicmd->sc_data_direction)); + writecmd->sg.sg[0].addr = cpu_to_le32(addr); + writecmd->sg.sg[0].count = cpu_to_le32(scsicmd->request_bufflen); + scsicmd->SCp.ptr = (void *)addr; + byte_count = scsicmd->request_bufflen; + + if (byte_count > (64 * 1024)) + BUG(); + } + if (byte_count != writecmd->count) + BUG(); + /* + * Now send the Fib to the adapter + */ + fibsize = sizeof (struct aac_write) + ((writecmd->sg.count - 1) * sizeof (struct sgentry)); + + status = fib_send(ContainerCommand, + cmd_fibcontext, + fibsize, FsaNormal, + 0, 1, + (fib_callback) write_callback, + (void *) scsicmd); + /* + * Check that the command queued to the controller + */ + if (status == -EINPROGRESS) + return 0; + + printk(KERN_WARNING "aac_write: fib_send failed with status: %d\n", status); + /* + * For some reason, the Fib didn't queue, return QUEUE_FULL + */ + scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | QUEUE_FULL; + aac_io_done(scsicmd); + + fib_complete(cmd_fibcontext); + fib_free(cmd_fibcontext); + return -1; +} + + +/** + * aac_scsi_cmd() - Process SCSI command + * @scsicmd: SCSI command block + * @wait: 1 if the user wants to await completion + * + * Emulate a SCSI command and queue the required request for the + * aacraid firmware. + */ + +int aac_scsi_cmd(Scsi_Cmnd * scsicmd) +{ + int cid = 0; + struct fsa_scsi_hba *fsa_dev_ptr; + int cardtype; + int ret; + struct aac_dev *dev = (struct aac_dev *)scsicmd->host->hostdata; + + cardtype = dev->cardtype; + + fsa_dev_ptr = fsa_dev[scsicmd->host->unique_id]; + + /* + * If the bus, target or lun is out of range, return fail + * Test does not apply to ID 16, the pseudo id for the controller + * itself. + */ + if (scsicmd->target != scsicmd->host->this_id) { + if ((scsicmd->channel > 0) ||(scsicmd->target > 15) || (scsicmd->lun > 7)) + { + dprintk((KERN_DEBUG "The bus, target or lun is out of range = %d, %d, %d.\n", + scsicmd->channel, scsicmd->target, scsicmd->lun)); + scsicmd->result = DID_BAD_TARGET << 16; + __aac_io_done(scsicmd); + return -1; + } + cid = TARGET_LUN_TO_CONTAINER(scsicmd->target, scsicmd->lun); + /* + * If the target container doesn't exist, it may have + * been newly created + */ + if (fsa_dev_ptr->valid[cid] == 0) { + switch (scsicmd->cmnd[0]) { + case SS_INQUIR: + case SS_RDCAP: + case SS_TEST: + spin_unlock_irq(&io_request_lock); + probe_container(dev, cid); + spin_lock_irq(&io_request_lock); + default: + break; + } + } + /* + * If the target container still doesn't exist, + * return failure + */ + if (fsa_dev_ptr->valid[cid] == 0) { + scsicmd->result = DID_BAD_TARGET << 16; + __aac_io_done(scsicmd); + return -1; + } + } + else if ((scsicmd->cmnd[0] != SS_INQUIR) && /* only INQUIRY & TUR cmnd supported for controller */ + (scsicmd->cmnd[0] != SS_TEST)) + { + /* + * Command aimed at the controller + */ + dprintk((KERN_WARNING "Only INQUIRY & TUR command supported for controller, rcvd = 0x%x.\n", scsicmd->cmnd[0])); + scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | CHECK_CONDITION; + set_sense((char *) &sense_data[cid], + SENKEY_ILLEGAL, + SENCODE_INVALID_COMMAND, + ASENCODE_INVALID_COMMAND, 0, 0, 0, 0); + __aac_io_done(scsicmd); + return -1; + } + /* Handle commands here that don't really require going out to the adapter */ + switch (scsicmd->cmnd[0]) + { + case SS_INQUIR: + { + struct inquiry_data *inq_data_ptr; + + dprintk((KERN_DEBUG "INQUIRY command, ID: %d.\n", scsicmd->target)); + inq_data_ptr = (struct inquiry_data *)scsicmd->request_buffer; + memset(inq_data_ptr, 0, sizeof (struct inquiry_data)); + + inq_data_ptr->inqd_ver = 2; /* claim compliance to SCSI-2 */ + inq_data_ptr->inqd_dtq = 0x80; /* set RMB bit to one indicating that the medium is removable */ + inq_data_ptr->inqd_rdf = 2; /* A response data format value of two indicates that the data shall be in the format specified in SCSI-2 */ + inq_data_ptr->inqd_len = 31; + + /* + * Set the Vendor, Product, and Revision Level + * see: <vendor>.c i.e. aac.c + */ + setinqstr(cardtype, (void *) (inq_data_ptr->inqd_vid), fsa_dev_ptr->type[cid]); + if (scsicmd->target == scsicmd->host->this_id) + inq_data_ptr->inqd_pdt = INQD_PDT_PROC; /* Processor device */ + else + inq_data_ptr->inqd_pdt = INQD_PDT_DA; /* Direct/random access device */ + scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | GOOD; + __aac_io_done(scsicmd); + return 0; + } + case SS_RDCAP: + { + int capacity; + char *cp; + + dprintk((KERN_DEBUG "READ CAPACITY command.\n")); + capacity = fsa_dev_ptr->size[cid] - 1; + cp = scsicmd->request_buffer; + cp[0] = (capacity >> 24) & 0xff; + cp[1] = (capacity >> 16) & 0xff; + cp[2] = (capacity >> 8) & 0xff; + cp[3] = (capacity >> 0) & 0xff; + cp[4] = 0; + cp[5] = 0; + cp[6] = 2; + cp[7] = 0; + + scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | GOOD; + __aac_io_done(scsicmd); + + return 0; + } + + case SS_MODESEN: + { + char *mode_buf; + + dprintk((KERN_DEBUG "MODE SENSE command.\n")); + mode_buf = scsicmd->request_buffer; + mode_buf[0] = 0; /* Mode data length (MSB) */ + mode_buf[1] = 6; /* Mode data length (LSB) */ + mode_buf[2] = 0; /* Medium type - default */ + mode_buf[3] = 0; /* Device-specific param, bit 8: 0/1 = write enabled/protected */ + mode_buf[4] = 0; /* reserved */ + mode_buf[5] = 0; /* reserved */ + mode_buf[6] = 0; /* Block descriptor length (MSB) */ + mode_buf[7] = 0; /* Block descriptor length (LSB) */ + + scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | GOOD; + __aac_io_done(scsicmd); + + return 0; + } + case SS_REQSEN: + dprintk((KERN_DEBUG "REQUEST SENSE command.\n")); + memcpy(scsicmd->sense_buffer, &sense_data[cid], sizeof (struct sense_data)); + memset(&sense_data[cid], 0, sizeof (struct sense_data)); + scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | GOOD; + __aac_io_done(scsicmd); + return (0); + + case SS_LOCK: + dprintk((KERN_DEBUG "LOCK command.\n")); + if (scsicmd->cmnd[4]) + fsa_dev_ptr->locked[cid] = 1; + else + fsa_dev_ptr->locked[cid] = 0; + + scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | GOOD; + __aac_io_done(scsicmd); + return 0; + /* + * These commands are all No-Ops + */ + case SS_TEST: + case SS_RESERV: + case SS_RELES: + case SS_REZERO: + case SS_REASGN: + case SS_SEEK: + case SS_ST_SP: + scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | GOOD; + __aac_io_done(scsicmd); + return (0); + } + + switch (scsicmd->cmnd[0]) + { + case SS_READ: + case SM_READ: + /* + * Hack to keep track of ordinal number of the device that + * corresponds to a container. Needed to convert + * containers to /dev/sd device names + */ + + spin_unlock_irq(&io_request_lock); + fsa_dev_ptr->devno[cid] = DEVICE_NR(scsicmd->request.rq_dev); + ret = aac_read(scsicmd, cid); + spin_lock_irq(&io_request_lock); + return ret; + + case SS_WRITE: + case SM_WRITE: + spin_unlock_irq(&io_request_lock); + ret = aac_write(scsicmd, cid); + spin_lock_irq(&io_request_lock); + return ret; + default: + /* + * Unhandled commands + */ + printk(KERN_WARNING "Unhandled SCSI Command: 0x%x.\n", scsicmd->cmnd[0]); + scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | CHECK_CONDITION; + set_sense((char *) &sense_data[cid], + SENKEY_ILLEGAL, SENCODE_INVALID_COMMAND, + ASENCODE_INVALID_COMMAND, 0, 0, 0, 0); + __aac_io_done(scsicmd); + return -1; + } +} + +static int query_disk(struct aac_dev *dev, void *arg) +{ + struct aac_query_disk qd; + struct fsa_scsi_hba *fsa_dev_ptr; + + fsa_dev_ptr = &(dev->fsa_dev); + if (copy_from_user(&qd, arg, sizeof (struct aac_query_disk))) + return -EFAULT; + if (qd.cnum == -1) + qd.cnum = TARGET_LUN_TO_CONTAINER(qd.target, qd.lun); + else if ((qd.bus == -1) && (qd.target == -1) && (qd.lun == -1)) + { + if (qd.cnum < 0 || qd.cnum > MAXIMUM_NUM_CONTAINERS) + return -EINVAL; + qd.instance = dev->scsi_host_ptr->host_no; + qd.bus = 0; + qd.target = CONTAINER_TO_TARGET(qd.cnum); + qd.lun = CONTAINER_TO_LUN(qd.cnum); + } + else return -EINVAL; + + qd.valid = fsa_dev_ptr->valid[qd.cnum]; + qd.locked = fsa_dev_ptr->locked[qd.cnum]; + qd.deleted = fsa_dev_ptr->deleted[qd.cnum]; + + if (fsa_dev_ptr->devno[qd.cnum] == -1) + qd.unmapped = 1; + else + qd.unmapped = 0; + + get_sd_devname(fsa_dev_ptr->devno[qd.cnum], qd.name); + + if (copy_to_user(arg, &qd, sizeof (struct aac_query_disk))) + return -EFAULT; + return 0; +} + +static void get_sd_devname(int disknum, char *buffer) +{ + if (disknum < 0) { + sprintf(buffer, "%s", ""); + return; + } + + if (disknum < 26) + sprintf(buffer, "sd%c", 'a' + disknum); + else { + unsigned int min1; + unsigned int min2; + /* + * For larger numbers of disks, we need to go to a new + * naming scheme. + */ + min1 = disknum / 26; + min2 = disknum % 26; + sprintf(buffer, "sd%c%c", 'a' + min1 - 1, 'a' + min2); + } +} + +static int force_delete_disk(struct aac_dev *dev, void *arg) +{ + struct aac_delete_disk dd; + struct fsa_scsi_hba *fsa_dev_ptr; + + fsa_dev_ptr = &(dev->fsa_dev); + + if (copy_from_user(&dd, arg, sizeof (struct aac_delete_disk))) + return -EFAULT; + + if (dd.cnum > MAXIMUM_NUM_CONTAINERS) + return -EINVAL; + /* + * Mark this container as being deleted. + */ + fsa_dev_ptr->deleted[dd.cnum] = 1; + /* + * Mark the container as no longer valid + */ + fsa_dev_ptr->valid[dd.cnum] = 0; + return 0; +} + +static int delete_disk(struct aac_dev *dev, void *arg) +{ + struct aac_delete_disk dd; + struct fsa_scsi_hba *fsa_dev_ptr; + + fsa_dev_ptr = &(dev->fsa_dev); + + if (copy_from_user(&dd, arg, sizeof (struct aac_delete_disk))) + return -EFAULT; + + if (dd.cnum > MAXIMUM_NUM_CONTAINERS) + return -EINVAL; + /* + * If the container is locked, it can not be deleted by the API. + */ + if (fsa_dev_ptr->locked[dd.cnum]) + return -EBUSY; + else { + /* + * Mark the container as no longer being valid. + */ + fsa_dev_ptr->valid[dd.cnum] = 0; + fsa_dev_ptr->devno[dd.cnum] = -1; + return 0; + } +} + +int aac_dev_ioctl(struct aac_dev *dev, int cmd, void *arg) +{ + switch (cmd) { + case FSACTL_QUERY_DISK: + return query_disk(dev, arg); + case FSACTL_DELETE_DISK: + return delete_disk(dev, arg); + case FSACTL_FORCE_DELETE_DISK: + return force_delete_disk(dev, arg); + case 2131: + return aac_get_containers(dev); + default: + return -ENOTTY; + } +} + diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/scsi/aacraid/aacraid.h linux-2.5/drivers/scsi/aacraid/aacraid.h --- linux-2.5.1/drivers/scsi/aacraid/aacraid.h Thu Jan 1 00:00:00 1970 +++ linux-2.5/drivers/scsi/aacraid/aacraid.h Thu Dec 13 22:09:29 2001 @@ -0,0 +1,1198 @@ +#define dprintk(x) + +#define AAC_NUM_FIB 128 +#define AAC_NUM_IO_FIB 116 + +/*------------------------------------------------------------------------------ + * D E F I N E S + *----------------------------------------------------------------------------*/ + +struct diskparm +{ + int heads; + int sectors; + int cylinders; +}; + + +/* + * DON'T CHANGE THE ORDER, this is set by the firmware + */ + +#define CT_NONE 0 +#define CT_VOLUME 1 +#define CT_MIRROR 2 +#define CT_STRIPE 3 +#define CT_RAID5 4 +#define CT_SSRW 5 +#define CT_SSRO 6 +#define CT_MORPH 7 +#define CT_PASSTHRU 8 +#define CT_RAID4 9 +#define CT_RAID10 10 /* stripe of mirror */ +#define CT_RAID00 11 /* stripe of stripe */ +#define CT_VOLUME_OF_MIRRORS 12 /* volume of mirror */ +#define CT_PSEUDO_RAID 13 /* really raid4 */ +#define CT_LAST_VOLUME_TYPE 14 + +/* + * Types of objects addressable in some fashion by the client. + * This is a superset of those objects handled just by the filesystem + * and includes "raw" objects that an administrator would use to + * configure containers and filesystems. + */ + +#define FT_REG 1 /* regular file */ +#define FT_DIR 2 /* directory */ +#define FT_BLK 3 /* "block" device - reserved */ +#define FT_CHR 4 /* "character special" device - reserved */ +#define FT_LNK 5 /* symbolic link */ +#define FT_SOCK 6 /* socket */ +#define FT_FIFO 7 /* fifo */ +#define FT_FILESYS 8 /* ADAPTEC's "FSA"(tm) filesystem */ +#define FT_DRIVE 9 /* physical disk - addressable in scsi by bus/target/lun */ +#define FT_SLICE 10 /* virtual disk - raw volume - slice */ +#define FT_PARTITION 11 /* FSA partition - carved out of a slice - building block for containers */ +#define FT_VOLUME 12 /* Container - Volume Set */ +#define FT_STRIPE 13 /* Container - Stripe Set */ +#define FT_MIRROR 14 /* Container - Mirror Set */ +#define FT_RAID5 15 /* Container - Raid 5 Set */ +#define FT_DATABASE 16 /* Storage object with "foreign" content manager */ + +/* + * Host side memory scatter gather list + * Used by the adapter for read, write, and readdirplus operations + */ + +struct sgentry { + u32 addr; /* 32-bit Base address. */ + u32 count; /* Length. */ +}; + +/* + * SGMAP + * + * This is the SGMAP structure for all commands that use + * 32-bit addressing. + * + * Note that the upper 16 bits of SgCount are used as flags. + * Only the lower 16 bits of SgCount are actually used as the + * SG element count. + */ + +struct sgmap { + u32 count; + struct sgentry sg[1]; +}; + +struct creation_info +{ + u8 buildnum; /* e.g., 588 */ + u8 usec; /* e.g., 588 */ + u8 via; /* e.g., 1 = FSU, + * 2 = API + */ + u8 year; /* e.g., 1997 = 97 */ + u32 date; /* + * unsigned Month :4; // 1 - 12 + * unsigned Day :6; // 1 - 32 + * unsigned Hour :6; // 0 - 23 + * unsigned Minute :6; // 0 - 60 + * unsigned Second :6; // 0 - 60 + */ + u64 serial; /* e.g., 0x1DEADB0BFAFAF001 */ +}; + + +/* + * Define all the constants needed for the communication interface + */ + +/* + * Define how many queue entries each queue will have and the total + * number of entries for the entire communication interface. Also define + * how many queues we support. + * + * This has to match the controller + */ + +#define NUMBER_OF_COMM_QUEUES 8 // 4 command; 4 response +#define HOST_HIGH_CMD_ENTRIES 4 +#define HOST_NORM_CMD_ENTRIES 8 +#define ADAP_HIGH_CMD_ENTRIES 4 +#define ADAP_NORM_CMD_ENTRIES 512 +#define HOST_HIGH_RESP_ENTRIES 4 +#define HOST_NORM_RESP_ENTRIES 512 +#define ADAP_HIGH_RESP_ENTRIES 4 +#define ADAP_NORM_RESP_ENTRIES 8 + +#define TOTAL_QUEUE_ENTRIES \ + (HOST_NORM_CMD_ENTRIES + HOST_HIGH_CMD_ENTRIES + ADAP_NORM_CMD_ENTRIES + ADAP_HIGH_CMD_ENTRIES + \ + HOST_NORM_RESP_ENTRIES + HOST_HIGH_RESP_ENTRIES + ADAP_NORM_RESP_ENTRIES + ADAP_HIGH_RESP_ENTRIES) + + +/* + * Set the queues on a 16 byte alignment + */ + +#define QUEUE_ALIGNMENT 16 + +/* + * The queue headers define the Communication Region queues. These + * are physically contiguous and accessible by both the adapter and the + * host. Even though all queue headers are in the same contiguous block + * they will be represented as individual units in the data structures. + */ + +struct aac_entry { + u32 size; /* Size in bytes of the Fib which this QE points to */ + u32 addr; /* Receiver addressable address of the FIB (low 32 address bits) */ +}; + +/* + * The adapter assumes the ProducerIndex and ConsumerIndex are grouped + * adjacently and in that order. + */ + +struct aac_qhdr { + u64 header_addr; /* Address to hand the adapter to access to this queue head */ + u32 *producer; /* The producer index for this queue (host address) */ + u32 *consumer; /* The consumer index for this queue (host address) */ +}; + +/* + * Define all the events which the adapter would like to notify + * the host of. + */ + +#define HostNormCmdQue 1 /* Change in host normal priority command queue */ +#define HostHighCmdQue 2 /* Change in host high priority command queue */ +#define HostNormRespQue 3 /* Change in host normal priority response queue */ +#define HostHighRespQue 4 /* Change in host high priority response queue */ +#define AdapNormRespNotFull 5 +#define AdapHighRespNotFull 6 +#define AdapNormCmdNotFull 7 +#define AdapHighCmdNotFull 8 +#define SynchCommandComplete 9 +#define AdapInternalError 0xfe /* The adapter detected an internal error shutting down */ + +/* + * Define all the events the host wishes to notify the + * adapter of. The first four values much match the Qid the + * corresponding queue. + */ + +#define AdapNormCmdQue 2 +#define AdapHighCmdQue 3 +#define AdapNormRespQue 6 +#define AdapHighRespQue 7 +#define HostShutdown 8 +#define HostPowerFail 9 +#define FatalCommError 10 +#define HostNormRespNotFull 11 +#define HostHighRespNotFull 12 +#define HostNormCmdNotFull 13 +#define HostHighCmdNotFull 14 +#define FastIo 15 +#define AdapPrintfDone 16 + +/* + * Define all the queues that the adapter and host use to communicate + * Number them to match the physical queue layout. + */ + +enum aac_queue_types { + HostNormCmdQueue = 0, /* Adapter to host normal priority command traffic */ + HostHighCmdQueue, /* Adapter to host high priority command traffic */ + AdapNormCmdQueue, /* Host to adapter normal priority command traffic */ + AdapHighCmdQueue, /* Host to adapter high priority command traffic */ + HostNormRespQueue, /* Adapter to host normal priority response traffic */ + HostHighRespQueue, /* Adapter to host high priority response traffic */ + AdapNormRespQueue, /* Host to adapter normal priority response traffic */ + AdapHighRespQueue /* Host to adapter high priority response traffic */ +}; + +/* + * Assign type values to the FSA communication data structures + */ + +#define FIB_MAGIC 0x0001 + +/* + * Define the priority levels the FSA communication routines support. + */ + +#define FsaNormal 1 +#define FsaHigh 2 + +// +// Define the FIB. The FIB is the where all the requested data and +// command information are put to the application on the FSA adapter. +// + +struct aac_fibhdr { + u32 XferState; // Current transfer state for this CCB + u16 Command; // Routing information for the destination + u8 StructType; // Type FIB + u8 Flags; // Flags for FIB + u16 Size; // Size of this FIB in bytes + u16 SenderSize; // Size of the FIB in the sender (for response sizing) + u32 SenderFibAddress; // Host defined data in the FIB + u32 ReceiverFibAddress; // Logical address of this FIB for the adapter + u32 SenderData; // Place holder for the sender to store data + union { + struct { + u32 _ReceiverTimeStart; // Timestamp for receipt of fib + u32 _ReceiverTimeDone; // Timestamp for completion of fib + } _s; + struct list_head _FibLinks; // Used to link Adapter Initiated Fibs on the host + } _u; +}; + +#define FibLinks _u._FibLinks + +#define FIB_DATA_SIZE_IN_BYTES (512 - sizeof(struct aac_fibhdr)) + + +struct hw_fib { + struct aac_fibhdr header; + u8 data[FIB_DATA_SIZE_IN_BYTES]; // Command specific data +}; + +/* + * FIB commands + */ + +#define TestCommandResponse 1 +#define TestAdapterCommand 2 +/* + * Lowlevel and comm commands + */ +#define LastTestCommand 100 +#define ReinitHostNormCommandQueue 101 +#define ReinitHostHighCommandQueue 102 +#define ReinitHostHighRespQueue 103 +#define ReinitHostNormRespQueue 104 +#define ReinitAdapNormCommandQueue 105 +#define ReinitAdapHighCommandQueue 107 +#define ReinitAdapHighRespQueue 108 +#define ReinitAdapNormRespQueue 109 +#define InterfaceShutdown 110 +#define DmaCommandFib 120 +#define StartProfile 121 +#define TermProfile 122 +#define SpeedTest 123 +#define TakeABreakPt 124 +#define RequestPerfData 125 +#define SetInterruptDefTimer 126 +#define SetInterruptDefCount 127 +#define GetInterruptDefStatus 128 +#define LastCommCommand 129 +/* + * Filesystem commands + */ +#define NuFileSystem 300 +#define UFS 301 +#define HostFileSystem 302 +#define LastFileSystemCommand 303 +/* + * Container Commands + */ +#define ContainerCommand 500 +#define ContainerCommand64 501 +/* + * Cluster Commands + */ +#define ClusterCommand 550 +/* + * Scsi Port commands (scsi passthrough) + */ +#define ScsiPortCommand 600 +/* + * Misc house keeping and generic adapter initiated commands + */ +#define AifRequest 700 +#define CheckRevision 701 +#define FsaHostShutdown 702 +#define RequestAdapterInfo 703 +#define IsAdapterPaused 704 +#define SendHostTime 705 +#define LastMiscCommand 706 + +// +// Commands that will target the failover level on the FSA adapter +// + +enum fib_xfer_state { + HostOwned = (1<<0), + AdapterOwned = (1<<1), + FibInitialized = (1<<2), + FibEmpty = (1<<3), + AllocatedFromPool = (1<<4), + SentFromHost = (1<<5), + SentFromAdapter = (1<<6), + ResponseExpected = (1<<7), + NoResponseExpected = (1<<8), + AdapterProcessed = (1<<9), + HostProcessed = (1<<10), + HighPriority = (1<<11), + NormalPriority = (1<<12), + Async = (1<<13), + AsyncIo = (1<<13), // rpbfix: remove with new regime + PageFileIo = (1<<14), // rpbfix: remove with new regime + ShutdownRequest = (1<<15), + LazyWrite = (1<<16), // rpbfix: remove with new regime + AdapterMicroFib = (1<<17), + BIOSFibPath = (1<<18), + FastResponseCapable = (1<<19), + ApiFib = (1<<20) // Its an API Fib. +}; + +/* + * The following defines needs to be updated any time there is an + * incompatible change made to the aac_init structure. + */ + +#define ADAPTER_INIT_STRUCT_REVISION 3 + +struct aac_init +{ + u32 InitStructRevision; + u32 MiniPortRevision; + u32 fsrev; + u32 CommHeaderAddress; + u32 FastIoCommAreaAddress; + u32 AdapterFibsPhysicalAddress; + u32 AdapterFibsVirtualAddress; + u32 AdapterFibsSize; + u32 AdapterFibAlign; + u32 printfbuf; + u32 printfbufsiz; + u32 HostPhysMemPages; // number of 4k pages of host physical memory + u32 HostElapsedSeconds; // number of seconds since 1970. +}; + +enum aac_log_level { + LOG_INIT = 10, + LOG_INFORMATIONAL = 20, + LOG_WARNING = 30, + LOG_LOW_ERROR = 40, + LOG_MEDIUM_ERROR = 50, + LOG_HIGH_ERROR = 60, + LOG_PANIC = 70, + LOG_DEBUG = 80, + LOG_WINDBG_PRINT = 90 +}; + +#define FSAFS_NTC_GET_ADAPTER_FIB_CONTEXT 0x030b +#define FSAFS_NTC_FIB_CONTEXT 0x030c + +struct aac_dev; + +struct adapter_ops +{ + void (*adapter_interrupt)(struct aac_dev *dev); + void (*adapter_notify)(struct aac_dev *dev, u32 event); + void (*adapter_enable_int)(struct aac_dev *dev, u32 event); + void (*adapter_disable_int)(struct aac_dev *dev, u32 event); +}; + +/* + * Define which interrupt handler needs to be installed + */ + +struct aac_driver_ident +{ + u16 vendor; + u16 device; + u16 subsystem_vendor; + u16 subsystem_device; + int (*init)(struct aac_dev *dev, unsigned long num); + char * name; + char * vname; + char * model; +}; + +/* + * The adapter interface specs all queues to be located in the same + * physically contigous block. The host structure that defines the + * commuication queues will assume they are each a seperate physically + * contigous memory region that will support them all being one big + * contigous block. + * There is a command and response queue for each level and direction of + * commuication. These regions are accessed by both the host and adapter. + */ + +struct aac_queue { + u64 logical; /* This is the address we give the adapter */ + struct aac_entry *base; /* This is the system virtual address */ + struct aac_qhdr headers; /* A pointer to the producer and consumer queue headers for this queue */ + u32 entries; /* Number of queue entries on this queue */ + wait_queue_head_t qfull; /* Event to wait on if the queue is full */ + wait_queue_head_t cmdready; /* Indicates there is a Command ready from the adapter on this queue. */ + /* This is only valid for adapter to host command queues. */ + spinlock_t *lock; /* Spinlock for this queue must take this lock before accessing the lock */ + spinlock_t lockdata; /* Actual lock (used only on one side of the lock) */ + unsigned long SavedIrql; /* Previous IRQL when the spin lock is taken */ + u32 padding; /* Padding - FIXME - can remove I believe */ + struct list_head cmdq; /* A queue of FIBs which need to be prcessed by the FS thread. This is */ + /* only valid for command queues which receive entries from the adapter. */ + struct list_head pendingq; /* A queue of outstanding fib's to the adapter. */ + unsigned long numpending; /* Number of entries on outstanding queue. */ + struct aac_dev * dev; /* Back pointer to adapter structure */ +}; + +/* + * Message queues. The order here is important, see also the + * queue type ordering + */ + +struct aac_queue_block +{ + struct aac_queue queue[8]; +}; + +/* + * SaP1 Message Unit Registers + */ + +struct sa_drawbridge_CSR { + // Offset | Name + u32 reserved[10]; // 00h-27h | Reserved + u8 LUT_Offset; // 28h | Looup Table Offset + u8 reserved1[3]; // 29h-2bh | Reserved + u32 LUT_Data; // 2ch | Looup Table Data + u32 reserved2[26]; // 30h-97h | Reserved + u16 PRICLEARIRQ; // 98h | Primary Clear Irq + u16 SECCLEARIRQ; // 9ah | Secondary Clear Irq + u16 PRISETIRQ; // 9ch | Primary Set Irq + u16 SECSETIRQ; // 9eh | Secondary Set Irq + u16 PRICLEARIRQMASK; // a0h | Primary Clear Irq Mask + u16 SECCLEARIRQMASK; // a2h | Secondary Clear Irq Mask + u16 PRISETIRQMASK; // a4h | Primary Set Irq Mask + u16 SECSETIRQMASK; // a6h | Secondary Set Irq Mask + u32 MAILBOX0; // a8h | Scratchpad 0 + u32 MAILBOX1; // ach | Scratchpad 1 + u32 MAILBOX2; // b0h | Scratchpad 2 + u32 MAILBOX3; // b4h | Scratchpad 3 + u32 MAILBOX4; // b8h | Scratchpad 4 + u32 MAILBOX5; // bch | Scratchpad 5 + u32 MAILBOX6; // c0h | Scratchpad 6 + u32 MAILBOX7; // c4h | Scratchpad 7 + + u32 ROM_Setup_Data; // c8h | Rom Setup and Data + u32 ROM_Control_Addr; // cch | Rom Control and Address + + u32 reserved3[12]; // d0h-ffh | reserved + u32 LUT[64]; // 100h-1ffh| Lookup Table Entries + + // + // TO DO + // need to add DMA, I2O, UART, etc registers form 80h to 364h + // + +}; + +#define Mailbox0 SaDbCSR.MAILBOX0 +#define Mailbox1 SaDbCSR.MAILBOX1 +#define Mailbox2 SaDbCSR.MAILBOX2 +#define Mailbox3 SaDbCSR.MAILBOX3 +#define Mailbox4 SaDbCSR.MAILBOX4 +#define Mailbox5 SaDbCSR.MAILBOX5 +#define Mailbox7 SaDbCSR.MAILBOX7 + +#define DoorbellReg_p SaDbCSR.PRISETIRQ +#define DoorbellReg_s SaDbCSR.SECSETIRQ +#define DoorbellClrReg_p SaDbCSR.PRICLEARIRQ + + +#define DOORBELL_0 cpu_to_le16(0x0001) +#define DOORBELL_1 cpu_to_le16(0x0002) +#define DOORBELL_2 cpu_to_le16(0x0004) +#define DOORBELL_3 cpu_to_le16(0x0008) +#define DOORBELL_4 cpu_to_le16(0x0010) +#define DOORBELL_5 cpu_to_le16(0x0020) +#define DOORBELL_6 cpu_to_le16(0x0040) + + +#define PrintfReady DOORBELL_5 +#define PrintfDone DOORBELL_5 + +struct sa_registers { + struct sa_drawbridge_CSR SaDbCSR; /* 98h - c4h */ +}; + + +#define Sa_MINIPORT_REVISION 1 + +#define sa_readw(AEP, CSR) readl(&((AEP)->regs.sa->CSR)) +#define sa_readl(AEP, CSR) readl(&((AEP)->regs.sa->CSR)) +#define sa_writew(AEP, CSR, value) writew(value, &((AEP)->regs.sa->CSR)) +#define sa_writel(AEP, CSR, value) writel(value, &((AEP)->regs.sa->CSR)) + +/* + * Rx Message Unit Registers + */ + +struct rx_mu_registers { + // Local | PCI* | Name + // | | + u32 ARSR; // 1300h | 00h | APIC Register Select Register + u32 reserved0; // 1304h | 04h | Reserved + u32 AWR; // 1308h | 08h | APIC Window Register + u32 reserved1; // 130Ch | 0Ch | Reserved + u32 IMRx[2]; // 1310h | 10h | Inbound Message Registers + u32 OMRx[2]; // 1318h | 18h | Outbound Message Registers + u32 IDR; // 1320h | 20h | Inbound Doorbell Register + u32 IISR; // 1324h | 24h | Inbound Interrupt Status Register + u32 IIMR; // 1328h | 28h | Inbound Interrupt Mask Register + u32 ODR; // 132Ch | 2Ch | Outbound Doorbell Register + u32 OISR; // 1330h | 30h | Outbound Interrupt Status Register + u32 OIMR; // 1334h | 34h | Outbound Interrupt Mask Register + // * Must access through ATU Inbound Translation Window +}; + +struct rx_inbound { + u32 Mailbox[8]; +}; + +#define InboundMailbox0 IndexRegs.Mailbox[0] +#define InboundMailbox1 IndexRegs.Mailbox[1] +#define InboundMailbox2 IndexRegs.Mailbox[2] +#define InboundMailbox3 IndexRegs.Mailbox[3] +#define InboundMailbox4 IndexRegs.Mailbox[4] + +#define INBOUNDDOORBELL_0 cpu_to_le32(0x00000001) +#define INBOUNDDOORBELL_1 cpu_to_le32(0x00000002) +#define INBOUNDDOORBELL_2 cpu_to_le32(0x00000004) +#define INBOUNDDOORBELL_3 cpu_to_le32(0x00000008) +#define INBOUNDDOORBELL_4 cpu_to_le32(0x00000010) +#define INBOUNDDOORBELL_5 cpu_to_le32(0x00000020) +#define INBOUNDDOORBELL_6 cpu_to_le32(0x00000040) + +#define OUTBOUNDDOORBELL_0 cpu_to_le32(0x00000001) +#define OUTBOUNDDOORBELL_1 cpu_to_le32(0x00000002) +#define OUTBOUNDDOORBELL_2 cpu_to_le32(0x00000004) +#define OUTBOUNDDOORBELL_3 cpu_to_le32(0x00000008) +#define OUTBOUNDDOORBELL_4 cpu_to_le32(0x00000010) + +#define InboundDoorbellReg MUnit.IDR +#define OutboundDoorbellReg MUnit.ODR + +struct rx_registers { + struct rx_mu_registers MUnit; // 1300h - 1334h + u32 reserved1[6]; // 1338h - 134ch + struct rx_inbound IndexRegs; +}; + +#define rx_readb(AEP, CSR) readb(&((AEP)->regs.rx->CSR)) +#define rx_readl(AEP, CSR) readl(&((AEP)->regs.rx->CSR)) +#define rx_writeb(AEP, CSR, value) writeb(value, &((AEP)->regs.rx->CSR)) +#define rx_writel(AEP, CSR, value) writel(value, &((AEP)->regs.rx->CSR)) + +struct fib; + +typedef void (*fib_callback)(void *ctxt, struct fib *fibctx); + +struct aac_fib_context { + s16 type; // used for verification of structure + s16 size; + u32 jiffies; // used for cleanup + struct list_head next; // used to link context's into a linked list + struct semaphore wait_sem; // this is used to wait for the next fib to arrive. + int wait; // Set to true when thread is in WaitForSingleObject + unsigned long count; // total number of FIBs on FibList + struct list_head fibs; +}; + +#define MAXIMUM_NUM_CONTAINERS 64 // 4 Luns * 16 Targets +#define MAXIMUM_NUM_ADAPTERS 8 + +struct fsa_scsi_hba { + unsigned long size[MAXIMUM_NUM_CONTAINERS]; + unsigned long type[MAXIMUM_NUM_CONTAINERS]; + unsigned char valid[MAXIMUM_NUM_CONTAINERS]; + unsigned char ro[MAXIMUM_NUM_CONTAINERS]; + unsigned char locked[MAXIMUM_NUM_CONTAINERS]; + unsigned char deleted[MAXIMUM_NUM_CONTAINERS]; + long devno[MAXIMUM_NUM_CONTAINERS]; +}; + +struct fib { + void *next; /* this is used by the allocator */ + s16 type; + s16 size; + /* + * The Adapter that this I/O is destined for. + */ + struct aac_dev *dev; + u64 logicaladdr; /* 64 bit */ + /* + * This is the event the sendfib routine will wait on if the + * caller did not pass one and this is synch io. + */ + struct semaphore event_wait; + spinlock_t event_lock; + + unsigned long done; /* gets set to 1 when fib is complete */ + fib_callback callback; + void *callback_data; + unsigned long flags; + /* + * The following is used to put this fib context onto the + * Outstanding I/O queue. + */ + struct list_head queue; + + void *data; + struct hw_fib *fib; /* Actual shared object */ +}; + +struct aac_dev +{ + struct aac_dev *next; + const char *name; + int id; + + u16 irq_mask; + /* + * Map for 128 fib objects (64k) + */ + dma_addr_t hw_fib_pa; + struct hw_fib *hw_fib_va; + /* + * Fib Headers + */ + struct fib fibs[AAC_NUM_FIB]; + struct fib *free_fib; + struct fib *timeout_fib; + spinlock_t fib_lock; + + struct aac_queue_block *queues; + /* + * The user API will use an IOCTL to register itself to receive + * FIBs from the adapter. The following list is used to keep + * track of all the threads that have requested these FIBs. The + * mutex is used to synchronize access to all data associated + * with the adapter fibs. + */ + struct list_head fib_list; + + struct adapter_ops a_ops; + unsigned long fsrev; /* Main driver's revision number */ + + struct aac_init *init; /* Holds initialization info to communicate with adapter */ + void * init_pa; /* Holds physical address of the init struct */ + + struct pci_dev *pdev; /* Our PCI interface */ + void * printfbuf; /* pointer to buffer used for printf's from the adapter */ + void * comm_addr; /* Base address of Comm area */ + dma_addr_t comm_phys; /* Physical Address of Comm area */ + size_t comm_size; + + struct Scsi_Host *scsi_host_ptr; + struct fsa_scsi_hba fsa_dev; + int thread_pid; + int cardtype; + + /* + * The following is the device specific extension. + */ + union + { + struct sa_registers *sa; + struct rx_registers *rx; + } regs; + /* + * The following is the number of the individual adapter + */ + long devnum; + int aif_thread; + struct completion aif_completion; +}; + +#define AllocateAndMapFibSpace(dev, MapFibContext) \ + dev->a_ops.AllocateAndMapFibSpace(dev, MapFibContext) + +#define UnmapAndFreeFibSpace(dev, MapFibContext) \ + dev->a_ops.UnmapAndFreeFibSpace(dev, MapFibContext) + +#define aac_adapter_interrupt(dev) \ + dev->a_ops.adapter_interrupt(dev) + +#define aac_adapter_notify(dev, event) \ + dev->a_ops.adapter_notify(dev, event) + +#define aac_adapter_enable_int(dev, event) \ + dev->a_ops.adapter_enable_int(dev, event) + +#define aac_adapter_disable_int(dev, event) \ + dev->a_ops.adapter_disable_int(dev, event) + + + +#define FIB_CONTEXT_FLAG_TIMED_OUT (0x00000001) + +/* + * Define the command values + */ + +#define Null 0 +#define GetAttributes 1 +#define SetAttributes 2 +#define Lookup 3 +#define ReadLink 4 +#define Read 5 +#define Write 6 +#define Create 7 +#define MakeDirectory 8 +#define SymbolicLink 9 +#define MakeNode 10 +#define Removex 11 +#define RemoveDirectoryx 12 +#define Rename 13 +#define Link 14 +#define ReadDirectory 15 +#define ReadDirectoryPlus 16 +#define FileSystemStatus 17 +#define FileSystemInfo 18 +#define PathConfigure 19 +#define Commit 20 +#define Mount 21 +#define UnMount 22 +#define Newfs 23 +#define FsCheck 24 +#define FsSync 25 +#define SimReadWrite 26 +#define SetFileSystemStatus 27 +#define BlockRead 28 +#define BlockWrite 29 +#define NvramIoctl 30 +#define FsSyncWait 31 +#define ClearArchiveBit 32 +#define SetAcl 33 +#define GetAcl 34 +#define AssignAcl 35 +#define FaultInsertion 36 /* Fault Insertion Command */ +#define CrazyCache 37 /* Crazycache */ + +#define MAX_FSACOMMAND_NUM 38 + + +/* + * Define the status returns. These are very unixlike although + * most are not in fact used + */ + +#define ST_OK 0 +#define ST_PERM 1 +#define ST_NOENT 2 +#define ST_IO 5 +#define ST_NXIO 6 +#define ST_E2BIG 7 +#define ST_ACCES 13 +#define ST_EXIST 17 +#define ST_XDEV 18 +#define ST_NODEV 19 +#define ST_NOTDIR 20 +#define ST_ISDIR 21 +#define ST_INVAL 22 +#define ST_FBIG 27 +#define ST_NOSPC 28 +#define ST_ROFS 30 +#define ST_MLINK 31 +#define ST_WOULDBLOCK 35 +#define ST_NAMETOOLONG 63 +#define ST_NOTEMPTY 66 +#define ST_DQUOT 69 +#define ST_STALE 70 +#define ST_REMOTE 71 +#define ST_BADHANDLE 10001 +#define ST_NOT_SYNC 10002 +#define ST_BAD_COOKIE 10003 +#define ST_NOTSUPP 10004 +#define ST_TOOSMALL 10005 +#define ST_SERVERFAULT 10006 +#define ST_BADTYPE 10007 +#define ST_JUKEBOX 10008 +#define ST_NOTMOUNTED 10009 +#define ST_MAINTMODE 10010 +#define ST_STALEACL 10011 + +/* + * On writes how does the client want the data written. + */ + +#define CACHE_CSTABLE 1 +#define CACHE_UNSTABLE 2 + +/* + * Lets the client know at which level the data was commited on + * a write request + */ + +#define CMFILE_SYNCH_NVRAM 1 +#define CMDATA_SYNCH_NVRAM 2 +#define CMFILE_SYNCH 3 +#define CMDATA_SYNCH 4 +#define CMUNSTABLE 5 + +struct aac_read +{ + u32 command; + u32 cid; + u32 block; + u32 count; + struct sgmap sg; // Must be last in struct because it is variable +}; + +struct aac_read_reply +{ + u32 status; + u32 count; +}; + +struct aac_write +{ + u32 command; + u32 cid; + u32 block; + u32 count; + u32 stable; + struct sgmap sg; // Must be last in struct because it is variable +}; + +struct aac_write_reply +{ + u32 status; + u32 count; + u32 committed; +}; + + +/* + * Object-Server / Volume-Manager Dispatch Classes + */ + +#define VM_Null 0 +#define VM_NameServe 1 +#define VM_ContainerConfig 2 +#define VM_Ioctl 3 +#define VM_FilesystemIoctl 4 +#define VM_CloseAll 5 +#define VM_CtBlockRead 6 +#define VM_CtBlockWrite 7 +#define VM_SliceBlockRead 8 /* raw access to configured "storage objects" */ +#define VM_SliceBlockWrite 9 +#define VM_DriveBlockRead 10 /* raw access to physical devices */ +#define VM_DriveBlockWrite 11 +#define VM_EnclosureMgt 12 /* enclosure management */ +#define VM_Unused 13 /* used to be diskset management */ +#define VM_CtBlockVerify 14 +#define VM_CtPerf 15 /* performance test */ +#define VM_CtBlockRead64 16 +#define VM_CtBlockWrite64 17 +#define VM_CtBlockVerify64 18 + +#define MAX_VMCOMMAND_NUM 19 /* used for sizing stats array - leave last */ + +/* + * Descriptive information (eg, vital stats) + * that a content manager might report. The + * FileArray filesystem component is one example + * of a content manager. Raw mode might be + * another. + */ + +struct aac_fsinfo { + u32 fsTotalSize; /* Consumed by fs, incl. metadata */ + u32 fsBlockSize; + u32 fsFragSize; + u32 fsMaxExtendSize; + u32 fsSpaceUnits; + u32 fsMaxNumFiles; + u32 fsNumFreeFiles; + u32 fsInodeDensity; +}; /* valid iff ObjType == FT_FILESYS && !(ContentState & FSCS_NOTCLEAN) */ + +union aac_contentinfo { + struct aac_fsinfo filesys; /* valid iff ObjType == FT_FILESYS && !(ContentState & FSCS_NOTCLEAN) */ +}; + +/* + * Query for "mountable" objects, ie, objects that are typically + * associated with a drive letter on the client (host) side. + */ + +struct aac_mntent { + u32 oid; + char name[16]; // if applicable + struct creation_info create_info; // if applicable + u32 capacity; + u32 vol; // substrate structure + u32 obj; // FT_FILESYS, FT_DATABASE, etc. + u32 state; // unready for mounting, readonly, etc. + union aac_contentinfo fileinfo; // Info specific to content manager (eg, filesystem) + u32 altoid; // != oid <==> snapshot or broken mirror exists +}; + +#define FSCS_READONLY 0x0002 /* possible result of broken mirror */ + +struct aac_query_mount { + u32 command; + u32 type; + u32 count; +}; + +struct aac_mount { + u32 status; + u32 type; /* should be same as that requested */ + u32 count; + struct aac_mntent mnt[1]; +}; + +/* + * The following command is sent to shut down each container. + */ + +struct aac_close { + u32 command; + u32 cid; +}; + +struct aac_query_disk +{ + s32 cnum; + s32 bus; + s32 target; + s32 lun; + u32 valid; + u32 locked; + u32 deleted; + s32 instance; + s8 name[10]; + u32 unmapped; +}; + +struct aac_delete_disk { + u32 disknum; + u32 cnum; +}; + +struct fib_ioctl +{ + char *fibctx; + int wait; + char *fib; +}; + +struct revision +{ + int compat; + unsigned long version; + unsigned long build; +}; + +/* + * Ugly - non Linux like ioctl coding for back compat. + */ + +#define CTL_CODE(function, method) ( \ + (4<< 16) | ((function) << 2) | (method) \ +) + +/* + * Define the method codes for how buffers are passed for I/O and FS + * controls + */ + +#define METHOD_BUFFERED 0 +#define METHOD_NEITHER 3 + +/* + * Filesystem ioctls + */ + +#define FSACTL_SENDFIB CTL_CODE(2050, METHOD_BUFFERED) +#define FSACTL_DELETE_DISK 0x163 +#define FSACTL_QUERY_DISK 0x173 +#define FSACTL_OPEN_GET_ADAPTER_FIB CTL_CODE(2100, METHOD_BUFFERED) +#define FSACTL_GET_NEXT_ADAPTER_FIB CTL_CODE(2101, METHOD_BUFFERED) +#define FSACTL_CLOSE_GET_ADAPTER_FIB CTL_CODE(2102, METHOD_BUFFERED) +#define FSACTL_MINIPORT_REV_CHECK CTL_CODE(2107, METHOD_BUFFERED) +#define FSACTL_FORCE_DELETE_DISK CTL_CODE(2120, METHOD_NEITHER) + +struct aac_common +{ + /* + * If this value is set to 1 then interrupt moderation will occur + * in the base commuication support. + */ + unsigned long irq_mod; + int peak_fibs; + int zero_fibs; + unsigned long fib_timeouts; + /* + * Statistical counters in debug mode + */ +#ifdef DBG + unsigned long FibsSent; + unsigned long FibRecved; + unsigned long NoResponseSent; + unsigned long NoResponseRecved; + unsigned long AsyncSent; + unsigned long AsyncRecved; + unsigned long NormalSent; + unsigned long NormalRecved; +#endif +}; + +extern struct aac_common aac_config; + + +/* + * The following macro is used when sending and receiving FIBs. It is + * only used for debugging. + */ + +#if DBG +#define FIB_COUNTER_INCREMENT(counter) (counter)++ +#else +#define FIB_COUNTER_INCREMENT(counter) +#endif + +/* + * Adapter direct commands + */ + +#define BREAKPOINT_REQUEST 0x00000004 +#define INIT_STRUCT_BASE_ADDRESS 0x00000005 +#define SEND_SYNCHRONOUS_FIB 0x0000000c + +/* + * Adapter Status Register + * + * Phase Staus mailbox is 32bits: + * <31:16> = Phase Status + * <15:0> = Phase + * + * The adapter reports is present state through the phase. Only + * a single phase should be ever be set. Each phase can have multiple + * phase status bits to provide more detailed information about the + * state of the board. Care should be taken to ensure that any phase + * status bits that are set when changing the phase are also valid + * for the new phase or be cleared out. Adapter software (monitor, + * iflash, kernel) is responsible for properly maintining the phase + * status mailbox when it is running. + * + * MONKER_API Phases + * + * Phases are bit oriented. It is NOT valid to have multiple bits set + */ + +#define SELF_TEST_FAILED cpu_to_le32(0x00000004) +#define KERNEL_UP_AND_RUNNING cpu_to_le32(0x00000080) +#define KERNEL_PANIC cpu_to_le32(0x00000100) + +/* + * Doorbell bit defines + */ + +#define DoorBellPrintfDone cpu_to_le32(1<<5) // Host -> Adapter +#define DoorBellAdapterNormCmdReady cpu_to_le32(1<<1) // Adapter -> Host +#define DoorBellAdapterNormRespReady cpu_to_le32(1<<2) // Adapter -> Host +#define DoorBellAdapterNormCmdNotFull cpu_to_le32(1<<3) // Adapter -> Host +#define DoorBellAdapterNormRespNotFull cpu_to_le32(1<<4) // Adapter -> Host +#define DoorBellPrintfReady cpu_to_le32(1<<5) // Adapter -> Host + +/* + * For FIB communication, we need all of the following things + * to send back to the user. + */ + +#define AifCmdEventNotify 1 /* Notify of event */ +#define AifCmdJobProgress 2 /* Progress report */ +#define AifCmdAPIReport 3 /* Report from other user of API */ +#define AifCmdDriverNotify 4 /* Notify host driver of event */ +#define AifReqJobList 100 /* Gets back complete job list */ +#define AifReqJobsForCtr 101 /* Gets back jobs for specific container */ +#define AifReqJobsForScsi 102 /* Gets back jobs for specific SCSI device */ +#define AifReqJobReport 103 /* Gets back a specific job report or list of them */ +#define AifReqTerminateJob 104 /* Terminates job */ +#define AifReqSuspendJob 105 /* Suspends a job */ +#define AifReqResumeJob 106 /* Resumes a job */ +#define AifReqSendAPIReport 107 /* API generic report requests */ +#define AifReqAPIJobStart 108 /* Start a job from the API */ +#define AifReqAPIJobUpdate 109 /* Update a job report from the API */ +#define AifReqAPIJobFinish 110 /* Finish a job from the API */ + +/* + * Adapter Initiated FIB command structures. Start with the adapter + * initiated FIBs that really come from the adapter, and get responded + * to by the host. + */ + +struct aac_aifcmd { + u32 command; /* Tell host what type of notify this is */ + u32 seqnum; /* To allow ordering of reports (if necessary) */ + u8 data[1]; /* Undefined length (from kernel viewpoint) */ +}; + +/* + * Adapter Information Block + * + * This is returned by the RequestAdapterInfo block + */ + +struct aac_adapter_info +{ + u32 platform; + u32 cpu; + u32 subcpu; + u32 clock; + u32 execmem; + u32 buffermem; + u32 totalmem; + u32 kernelrev; + u32 kernelbuild; + u32 monitorrev; + u32 monitorbuild; + u32 hwrev; + u32 hwbuild; + u32 biosrev; + u32 biosbuild; + u32 clustering; + u32 clustermask; + u64 serial; + u32 battery; + u32 options; + u32 OEM; +}; + +const char *aac_driverinfo(struct Scsi_Host *); +struct fib *fib_alloc(struct aac_dev *dev); +int fib_setup(struct aac_dev *dev); +void fib_map_free(struct aac_dev *dev); +void fib_free(struct fib * context); +void fib_init(struct fib * context); +void fib_dealloc(struct fib * context); +void aac_printf(struct aac_dev *dev, u32 val); +int fib_send(u16 command, struct fib * context, unsigned long size, int priority, int wait, int reply, fib_callback callback, void *ctxt); +int aac_consumer_get(struct aac_dev * dev, struct aac_queue * q, struct aac_entry **entry); +int aac_consumer_avail(struct aac_dev * dev, struct aac_queue * q); +void aac_consumer_free(struct aac_dev * dev, struct aac_queue * q, u32 qnum); +int fib_complete(struct fib * context); +#define fib_data(fibctx) ((void *)(fibctx)->fib->data) +int aac_detach(struct aac_dev *dev); +struct aac_dev *aac_init_adapter(struct aac_dev *dev); +int aac_get_containers(struct aac_dev *dev); +int aac_scsi_cmd(Scsi_Cmnd *scsi_cmnd_ptr); +int aac_dev_ioctl(struct aac_dev *dev, int cmd, void *arg); +int aac_do_ioctl(struct aac_dev * dev, int cmd, void *arg); +int aac_rx_init(struct aac_dev *dev, unsigned long devNumber); +int aac_sa_init(struct aac_dev *dev, unsigned long devNumber); +unsigned int aac_response_normal(struct aac_queue * q); +unsigned int aac_command_normal(struct aac_queue * q); +int aac_command_thread(struct aac_dev * dev); +int aac_close_fib_context(struct aac_dev * dev, struct aac_fib_context *fibctx); +int fib_adapter_complete(struct fib * fibptr, unsigned short size); diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/scsi/aacraid/commctrl.c linux-2.5/drivers/scsi/aacraid/commctrl.c --- linux-2.5.1/drivers/scsi/aacraid/commctrl.c Thu Jan 1 00:00:00 1970 +++ linux-2.5/drivers/scsi/aacraid/commctrl.c Thu Dec 13 16:32:36 2001 @@ -0,0 +1,410 @@ +/* + * Adaptec AAC series RAID controller driver + * (c) Copyright 2001 Red Hat Inc. <alan@redhat.com> + * + * based on the old aacraid driver that is.. + * Adaptec aacraid device driver for Linux. + * + * Copyright (c) 2000 Adaptec, Inc. (aacraid@adaptec.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, 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; see the file COPYING. If not, write to + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * + * Module Name: + * commctrl.c + * + * Abstract: Contains all routines for control of the AFA comm layer + * + */ + +#include <linux/config.h> +#include <linux/kernel.h> +#include <linux/init.h> +#include <linux/types.h> +#include <linux/sched.h> +#include <linux/pci.h> +#include <linux/spinlock.h> +#include <linux/slab.h> +#include <linux/completion.h> +#include <linux/blk.h> +#include <asm/semaphore.h> +#include <asm/uaccess.h> +#include "scsi.h" +#include "hosts.h" + +#include "aacraid.h" + +/** + * ioctl_send_fib - send a FIB from userspace + * @dev: adapter is being processed + * @arg: arguments to the ioctl call + * + * This routine sends a fib to the adapter on behalf of a user level + * program. + */ + +static int ioctl_send_fib(struct aac_dev * dev, void *arg) +{ + struct hw_fib * kfib; + struct fib *fibptr; + + fibptr = fib_alloc(dev); + if(fibptr == NULL) + return -ENOMEM; + + kfib = fibptr->fib; + /* + * First copy in the header so that we can check the size field. + */ + if (copy_from_user((void *)kfib, arg, sizeof(struct aac_fibhdr))) { + fib_free(fibptr); + return -EFAULT; + } + /* + * Since we copy based on the fib header size, make sure that we + * will not overrun the buffer when we copy the memory. Return + * an error if we would. + */ + if(le32_to_cpu(kfib->header.Size) > sizeof(struct hw_fib) - sizeof(struct aac_fibhdr)) { + fib_free(fibptr); + return -EINVAL; + } + + if (copy_from_user((void *) kfib, arg, le32_to_cpu(kfib->header.Size) + sizeof(struct aac_fibhdr))) { + fib_free(fibptr); + return -EFAULT; + } + + if (kfib->header.Command == cpu_to_le32(TakeABreakPt)) { + aac_adapter_interrupt(dev); + /* + * Since we didn't really send a fib, zero out the state to allow + * cleanup code not to assert. + */ + kfib->header.XferState = 0; + } else { + if (fib_send(kfib->header.Command, fibptr, le32_to_cpu(kfib->header.Size) , FsaNormal, + 1, 1, NULL, NULL) != 0) + { + fib_free(fibptr); + return -EINVAL; + } + if (fib_complete(fibptr) != 0) { + fib_free(fibptr); + return -EINVAL; + } + } + /* + * Make sure that the size returned by the adapter (which includes + * the header) is less than or equal to the size of a fib, so we + * don't corrupt application data. Then copy that size to the user + * buffer. (Don't try to add the header information again, since it + * was already included by the adapter.) + */ + + if (copy_to_user(arg, (void *)kfib, kfib->header.Size)) { + fib_free(fibptr); + return -EFAULT; + } + fib_free(fibptr); + return 0; +} + +/** + * open_getadapter_fib - Get the next fib + * + * This routine will get the next Fib, if available, from the AdapterFibContext + * passed in from the user. + */ + +static int open_getadapter_fib(struct aac_dev * dev, void *arg) +{ + struct aac_fib_context * fibctx; + int status; + unsigned long flags; + + fibctx = kmalloc(sizeof(struct aac_fib_context), GFP_KERNEL); + if (fibctx == NULL) { + status = -ENOMEM; + } else { + fibctx->type = FSAFS_NTC_GET_ADAPTER_FIB_CONTEXT; + fibctx->size = sizeof(struct aac_fib_context); + /* + * Initialize the mutex used to wait for the next AIF. + */ + init_MUTEX_LOCKED(&fibctx->wait_sem); + fibctx->wait = 0; + /* + * Initialize the fibs and set the count of fibs on + * the list to 0. + */ + fibctx->count = 0; + INIT_LIST_HEAD(&fibctx->fibs); + fibctx->jiffies = jiffies/HZ; + /* + * Now add this context onto the adapter's + * AdapterFibContext list. + */ + spin_lock_irqsave(&dev->fib_lock, flags); + list_add_tail(&fibctx->next, &dev->fib_list); + spin_unlock_irqrestore(&dev->fib_lock, flags); + if (copy_to_user(arg, &fibctx, sizeof(struct aac_fib_context *))) { + status = -EFAULT; + } else { + status = 0; + } + } + return status; +} + +/** + * next_getadapter_fib - get the next fib + * @dev: adapter to use + * @arg: ioctl argument + * + * This routine will get the next Fib, if available, from the AdapterFibContext + * passed in from the user. + */ + +static int next_getadapter_fib(struct aac_dev * dev, void *arg) +{ + struct fib_ioctl f; + struct aac_fib_context *fibctx, *aifcp; + struct hw_fib * fib; + int status; + struct list_head * entry; + int found; + unsigned long flags; + + if(copy_from_user((void *)&f, arg, sizeof(struct fib_ioctl))) + return -EFAULT; + /* + * Extract the AdapterFibContext from the Input parameters. + */ + fibctx = (struct aac_fib_context *) f.fibctx; + + /* + * Verify that the HANDLE passed in was a valid AdapterFibContext + * + * Search the list of AdapterFibContext addresses on the adapter + * to be sure this is a valid address + */ + found = 0; + entry = dev->fib_list.next; + + while(entry != &dev->fib_list) { + aifcp = list_entry(entry, struct aac_fib_context, next); + if(fibctx == aifcp) { /* We found a winner */ + found = 1; + break; + } + entry = entry->next; + } + if (found == 0) + return -EINVAL; + + if((fibctx->type != FSAFS_NTC_GET_ADAPTER_FIB_CONTEXT) || + (fibctx->size != sizeof(struct aac_fib_context))) + return -EINVAL; + status = 0; + spin_lock_irqsave(&dev->fib_lock, flags); + /* + * If there are no fibs to send back, then either wait or return + * -EAGAIN + */ +return_fib: + if (!list_empty(&fibctx->fibs)) { + struct list_head * entry; + /* + * Pull the next fib from the fibs + */ + entry = fibctx->fibs.next; + list_del(entry); + + fib = list_entry(entry, struct hw_fib, header.FibLinks); + fibctx->count--; + spin_unlock_irqrestore(&dev->fib_lock, flags); + if (copy_to_user(f.fib, fib, sizeof(struct hw_fib))) { + kfree(fib); + return -EFAULT; + } + /* + * Free the space occupied by this copy of the fib. + */ + kfree(fib); + status = 0; + fibctx->jiffies = jiffies/HZ; + } else { + spin_unlock_irqrestore(&dev->fib_lock, flags); + if (f.wait) { + if(down_interruptible(&fibctx->wait_sem) < 0) { + status = -EINTR; + } else { + /* Lock again and retry */ + spin_lock_irqsave(&dev->fib_lock, flags); + goto return_fib; + } + } else { + status = -EAGAIN; + } + } + return status; +} + +int aac_close_fib_context(struct aac_dev * dev, struct aac_fib_context * fibctx) +{ + struct hw_fib *fib; + + /* + * First free any FIBs that have not been consumed. + */ + while (!list_empty(&fibctx->fibs)) { + struct list_head * entry; + /* + * Pull the next fib from the fibs + */ + entry = fibctx->fibs.next; + list_del(entry); + fib = list_entry(entry, struct hw_fib, header.FibLinks); + fibctx->count--; + /* + * Free the space occupied by this copy of the fib. + */ + kfree(fib); + } + /* + * Remove the Context from the AdapterFibContext List + */ + list_del(&fibctx->next); + /* + * Invalidate context + */ + fibctx->type = 0; + /* + * Free the space occupied by the Context + */ + kfree(fibctx); + return 0; +} + +/** + * close_getadapter_fib - close down user fib context + * @dev: adapter + * @arg: ioctl arguments + * + * This routine will close down the fibctx passed in from the user. + */ + +static int close_getadapter_fib(struct aac_dev * dev, void *arg) +{ + struct aac_fib_context *fibctx, *aifcp; + int status; + unsigned long flags; + struct list_head * entry; + int found; + + /* + * Extract the fibctx from the input parameters + */ + fibctx = arg; + + /* + * Verify that the HANDLE passed in was a valid AdapterFibContext + * + * Search the list of AdapterFibContext addresses on the adapter + * to be sure this is a valid address + */ + + found = 0; + entry = dev->fib_list.next; + + while(entry != &dev->fib_list) { + aifcp = list_entry(entry, struct aac_fib_context, next); + if(fibctx == aifcp) { /* We found a winner */ + found = 1; + break; + } + entry = entry->next; + } + + if(found == 0) + return 0; /* Already gone */ + + if((fibctx->type != FSAFS_NTC_GET_ADAPTER_FIB_CONTEXT) || + (fibctx->size != sizeof(struct aac_fib_context))) + return -EINVAL; + spin_lock_irqsave(&dev->fib_lock, flags); + status = aac_close_fib_context(dev, fibctx); + spin_unlock_irqrestore(&dev->fib_lock, flags); + return status; +} + +/** + * check_revision - close down user fib context + * @dev: adapter + * @arg: ioctl arguments + * + * This routine returns the firmware version. + * Under Linux, there have been no version incompatibilities, so this is simple! + */ + +static int check_revision(struct aac_dev *dev, void *arg) +{ + struct revision response; + + response.compat = 1; + response.version = 0x03000400; + response.build = 0x5125; + + if (copy_to_user(arg, &response, sizeof(response))) + return -EFAULT; + return 0; +} + + +int aac_do_ioctl(struct aac_dev * dev, int cmd, void *arg) +{ + int status; + + /* + * HBA gets first crack + */ + + status = aac_dev_ioctl(dev, cmd, arg); + if(status != -ENOTTY) + return status; + + switch (cmd) { + case FSACTL_MINIPORT_REV_CHECK: + status = check_revision(dev, arg); + break; + case FSACTL_SENDFIB: + status = ioctl_send_fib(dev, arg); + break; + case FSACTL_OPEN_GET_ADAPTER_FIB: + status = open_getadapter_fib(dev, arg); + break; + case FSACTL_GET_NEXT_ADAPTER_FIB: + status = next_getadapter_fib(dev, arg); + break; + case FSACTL_CLOSE_GET_ADAPTER_FIB: + status = close_getadapter_fib(dev, arg); + break; + default: + status = -ENOTTY; + break; + } + return status; +} + diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/scsi/aacraid/comminit.c linux-2.5/drivers/scsi/aacraid/comminit.c --- linux-2.5.1/drivers/scsi/aacraid/comminit.c Thu Jan 1 00:00:00 1970 +++ linux-2.5/drivers/scsi/aacraid/comminit.c Thu Dec 13 16:32:36 2001 @@ -0,0 +1,332 @@ +/* + * Adaptec AAC series RAID controller driver + * (c) Copyright 2001 Red Hat Inc. <alan@redhat.com> + * + * based on the old aacraid driver that is.. + * Adaptec aacraid device driver for Linux. + * + * Copyright (c) 2000 Adaptec, Inc. (aacraid@adaptec.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, 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; see the file COPYING. If not, write to + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * + * Module Name: + * comminit.c + * + * Abstract: This supports the initialization of the host adapter commuication interface. + * This is a platform dependent module for the pci cyclone board. + * + */ + +#include <linux/config.h> +#include <linux/kernel.h> +#include <linux/init.h> +#include <linux/types.h> +#include <linux/sched.h> +#include <linux/pci.h> +#include <linux/spinlock.h> +#include <linux/slab.h> +#include <linux/blk.h> +#include <asm/semaphore.h> +#include "scsi.h" +#include "hosts.h" + +#include "aacraid.h" + +struct aac_common aac_config; + +static struct aac_dev *devices; + +static int aac_alloc_comm(struct aac_dev *dev, void **commaddr, unsigned long commsize, unsigned long commalign) +{ + unsigned char *base; + unsigned long size, align; + unsigned long fibsize = 4096; + unsigned long printfbufsiz = 256; + struct aac_init *init; + dma_addr_t phys; + + size = fibsize + sizeof(struct aac_init) + commsize + commalign + printfbufsiz; + + base = pci_alloc_consistent(dev->pdev, size, &phys); + if(base == NULL) + { + printk(KERN_ERR "aacraid: unable to create mapping.\n"); + return 0; + } + dev->comm_addr = (void *)base; + dev->comm_phys = phys; + dev->comm_size = size; + + dev->init = (struct aac_init *)(base + fibsize); + dev->init_pa = (struct aac_init *)(phys + fibsize); + + init = dev->init; + + init->InitStructRevision = cpu_to_le32(ADAPTER_INIT_STRUCT_REVISION); + init->MiniPortRevision = cpu_to_le32(Sa_MINIPORT_REVISION); + init->fsrev = cpu_to_le32(dev->fsrev); + + /* + * Adapter Fibs are the first thing allocated so that they + * start page aligned + */ + init->AdapterFibsVirtualAddress = cpu_to_le32(base); + init->AdapterFibsPhysicalAddress = cpu_to_le32(phys); + init->AdapterFibsSize = cpu_to_le32(fibsize); + init->AdapterFibAlign = cpu_to_le32(sizeof(struct hw_fib)); + + /* + * Increment the base address by the amount already used + */ + base = base + fibsize + sizeof(struct aac_init); + phys = phys + fibsize + sizeof(struct aac_init); + /* + * Align the beginning of Headers to commalign + */ + align = (commalign - ((unsigned long)(base) & (commalign - 1))); + base = base + align; + phys = phys + align; + /* + * Fill in addresses of the Comm Area Headers and Queues + */ + *commaddr = (unsigned long *)base; + init->CommHeaderAddress = cpu_to_le32(phys); + /* + * Increment the base address by the size of the CommArea + */ + base = base + commsize; + phys = phys + commsize; + /* + * Place the Printf buffer area after the Fast I/O comm area. + */ + dev->printfbuf = (void *)base; + init->printfbuf = cpu_to_le32(phys); + init->printfbufsiz = cpu_to_le32(printfbufsiz); + memset(base, 0, printfbufsiz); + return 1; +} + +static void aac_queue_init(struct aac_dev * dev, struct aac_queue * q, u32 *mem, int qsize) +{ + q->numpending = 0; + q->dev = dev; + INIT_LIST_HEAD(&q->pendingq); + init_waitqueue_head(&q->cmdready); + INIT_LIST_HEAD(&q->cmdq); + init_waitqueue_head(&q->qfull); + spin_lock_init(&q->lockdata); + q->lock = &q->lockdata; + q->headers.producer = mem; + q->headers.consumer = mem+1; + *q->headers.producer = cpu_to_le32(qsize); + *q->headers.consumer = cpu_to_le32(qsize); + q->entries = qsize; +} + +/** + * aac_send_shutdown - shutdown an adapter + * @dev: Adapter to shutdown + * + * This routine will send a VM_CloseAll (shutdown) request to the adapter. + */ + +static int aac_send_shutdown(struct aac_dev * dev) +{ + struct fib * fibctx; + struct aac_close *cmd; + int status; + + fibctx = fib_alloc(dev); + fib_init(fibctx); + + cmd = (struct aac_close *) fib_data(fibctx); + + cmd->command = cpu_to_le32(VM_CloseAll); + cmd->cid = cpu_to_le32(0xffffffff); + + status = fib_send(ContainerCommand, + fibctx, + sizeof(struct aac_close), + FsaNormal, + 1, 1, + NULL, NULL); + + if (status == 0) + fib_complete(fibctx); + fib_free(fibctx); + return status; +} + +/** + * aac_detach - detach adapter + * @detach: adapter to disconnect + * + * Disconnect and shutdown an AAC based adapter, freeing resources + * as we go. + */ + +int aac_detach(struct aac_dev *detach) +{ + struct aac_dev **dev = &devices; + + while(*dev) + { + if(*dev == detach) + { + *dev = detach->next; + aac_send_shutdown(detach); + fib_map_free(detach); + pci_free_consistent(detach->pdev, detach->comm_size, detach->comm_addr, detach->comm_phys); + kfree(detach->queues); + return 1; + } + dev=&((*dev)->next); + } + BUG(); + return 0; +} + +/** + * aac_comm_init - Initialise FSA data structures + * @dev: Adapter to intialise + * + * Initializes the data structures that are required for the FSA commuication + * interface to operate. + * Returns + * 1 - if we were able to init the commuication interface. + * 0 - If there were errors initing. This is a fatal error. + */ + +int aac_comm_init(struct aac_dev * dev) +{ + unsigned long hdrsize = (sizeof(u32) * NUMBER_OF_COMM_QUEUES) * 2; + unsigned long queuesize = sizeof(struct aac_entry) * TOTAL_QUEUE_ENTRIES; + u32 *headers; + struct aac_entry * queues; + unsigned long size; + struct aac_queue_block * comm = dev->queues; + + /* + * Now allocate and initialize the zone structures used as our + * pool of FIB context records. The size of the zone is based + * on the system memory size. We also initialize the mutex used + * to protect the zone. + */ + spin_lock_init(&dev->fib_lock); + + /* + * Allocate the physically contigous space for the commuication + * queue headers. + */ + + size = hdrsize + queuesize; + + if (!aac_alloc_comm(dev, (void * *)&headers, size, QUEUE_ALIGNMENT)) + return -ENOMEM; + + queues = (struct aac_entry *)((unsigned char *)headers + hdrsize); + + /* Adapter to Host normal priority Command queue */ + comm->queue[HostNormCmdQueue].base = queues; + aac_queue_init(dev, &comm->queue[HostNormCmdQueue], headers, HOST_NORM_CMD_ENTRIES); + queues += HOST_NORM_CMD_ENTRIES; + headers += 2; + + /* Adapter to Host high priority command queue */ + comm->queue[HostHighCmdQueue].base = queues; + aac_queue_init(dev, &comm->queue[HostHighCmdQueue], headers, HOST_HIGH_CMD_ENTRIES); + + queues += HOST_HIGH_CMD_ENTRIES; + headers +=2; + + /* Host to adapter normal priority command queue */ + comm->queue[AdapNormCmdQueue].base = queues; + aac_queue_init(dev, &comm->queue[AdapNormCmdQueue], headers, ADAP_NORM_CMD_ENTRIES); + + queues += ADAP_NORM_CMD_ENTRIES; + headers += 2; + + /* host to adapter high priority command queue */ + comm->queue[AdapHighCmdQueue].base = queues; + aac_queue_init(dev, &comm->queue[AdapHighCmdQueue], headers, ADAP_HIGH_CMD_ENTRIES); + + queues += ADAP_HIGH_CMD_ENTRIES; + headers += 2; + + /* adapter to host normal priority response queue */ + comm->queue[HostNormRespQueue].base = queues; + aac_queue_init(dev, &comm->queue[HostNormRespQueue], headers, HOST_NORM_RESP_ENTRIES); + + queues += HOST_NORM_RESP_ENTRIES; + headers += 2; + + /* adapter to host high priority response queue */ + comm->queue[HostHighRespQueue].base = queues; + aac_queue_init(dev, &comm->queue[HostHighRespQueue], headers, HOST_HIGH_RESP_ENTRIES); + + queues += HOST_HIGH_RESP_ENTRIES; + headers += 2; + + /* host to adapter normal priority response queue */ + comm->queue[AdapNormRespQueue].base = queues; + aac_queue_init(dev, &comm->queue[AdapNormRespQueue], headers, ADAP_NORM_RESP_ENTRIES); + + queues += ADAP_NORM_RESP_ENTRIES; + headers += 2; + + /* host to adapter high priority response queue */ + comm->queue[AdapHighRespQueue].base = queues; + aac_queue_init(dev, &comm->queue[AdapHighRespQueue], headers, ADAP_HIGH_RESP_ENTRIES); + + comm->queue[AdapNormCmdQueue].lock = comm->queue[HostNormRespQueue].lock; + comm->queue[AdapHighCmdQueue].lock = comm->queue[HostHighRespQueue].lock; + comm->queue[AdapNormRespQueue].lock = comm->queue[HostNormCmdQueue].lock; + comm->queue[AdapHighRespQueue].lock = comm->queue[HostHighCmdQueue].lock; + + return 0; +} + +struct aac_dev *aac_init_adapter(struct aac_dev *dev) +{ + /* + * Ok now init the communication subsystem + */ + dev->queues = (struct aac_queue_block *) kmalloc(sizeof(struct aac_queue_block), GFP_KERNEL); + if (dev->queues == NULL) { + printk(KERN_ERR "Error could not allocate comm region.\n"); + return NULL; + } + memset(dev->queues, 0, sizeof(struct aac_queue_block)); + + if (aac_comm_init(dev)<0) + return NULL; + /* + * Initialize the list of fibs + */ + if(fib_setup(dev)<0) + return NULL; + + INIT_LIST_HEAD(&dev->fib_list); + spin_lock_init(&dev->fib_lock); + init_completion(&dev->aif_completion); + /* + * Add this adapter in to our dev List. + */ + dev->next = devices; + devices = dev; + return dev; +} + + diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/scsi/aacraid/commsup.c linux-2.5/drivers/scsi/aacraid/commsup.c --- linux-2.5.1/drivers/scsi/aacraid/commsup.c Thu Jan 1 00:00:00 1970 +++ linux-2.5/drivers/scsi/aacraid/commsup.c Thu Dec 13 16:32:36 2001 @@ -0,0 +1,944 @@ +/* + * Adaptec AAC series RAID controller driver + * (c) Copyright 2001 Red Hat Inc. <alan@redhat.com> + * + * based on the old aacraid driver that is.. + + * Adaptec aacraid device driver for Linux. + * + * Copyright (c) 2000 Adaptec, Inc. (aacraid@adaptec.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, 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; see the file COPYING. If not, write to + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * + * Module Name: + * commsup.c + * + * Abstract: Contain all routines that are required for FSA host/adapter + * commuication. + * + * + */ + +#include <linux/config.h> +#include <linux/kernel.h> +#include <linux/init.h> +#include <linux/types.h> +#include <linux/sched.h> +#include <linux/pci.h> +#include <linux/spinlock.h> +#include <linux/slab.h> +#include <linux/completion.h> +#include <asm/semaphore.h> +#include <linux/blk.h> +#include "scsi.h" +#include "hosts.h" + +#include "aacraid.h" + +/** + * fib_map_alloc - allocate the fib objects + * @dev: Adapter to allocate for + * + * Allocate and map the shared PCI space for the FIB blocks used to + * talk to the Adaptec firmware. + */ + +static int fib_map_alloc(struct aac_dev *dev) +{ + if((dev->hw_fib_va = pci_alloc_consistent(dev->pdev, sizeof(struct hw_fib) * AAC_NUM_FIB, &dev->hw_fib_pa))==NULL) + return -ENOMEM; + return 0; +} + +/** + * fib_map_free - free the fib objects + * @dev: Adapter to free + * + * Free the PCI mappings and the memory allocated for FIB blocks + * on this adapter. + */ + +void fib_map_free(struct aac_dev *dev) +{ + pci_free_consistent(dev->pdev, sizeof(struct hw_fib) * AAC_NUM_FIB, dev->hw_fib_va, dev->hw_fib_pa); +} + +/** + * fib_setup - setup the fibs + * @dev: Adapter to set up + * + * Allocate the PCI space for the fibs, map it and then intialise the + * fib area, the unmapped fib data and also the free list + */ + +int fib_setup(struct aac_dev * dev) +{ + struct fib *fibptr; + struct hw_fib *fib; + dma_addr_t fibpa; + int i; + + if(fib_map_alloc(dev)<0) + return -ENOMEM; + + fib = dev->hw_fib_va; + fibpa = dev->hw_fib_pa; + memset(fib, 0, sizeof(struct hw_fib) * AAC_NUM_FIB); + /* + * Initialise the fibs + */ + for (i = 0, fibptr = &dev->fibs[i]; i < AAC_NUM_FIB; i++, fibptr++) + { + fibptr->dev = dev; + fibptr->fib = fib; + fibptr->data = (void *) fibptr->fib->data; + fibptr->next = fibptr+1; /* Forward chain the fibs */ + init_MUTEX_LOCKED(&fibptr->event_wait); + spin_lock_init(&fibptr->event_lock); + fib->header.XferState = cpu_to_le32(0xffffffff); + fib->header.SenderSize = cpu_to_le16(sizeof(struct hw_fib)); + fibptr->logicaladdr = (unsigned long) fibpa; + fib = (struct hw_fib *)((unsigned char *)fib + sizeof(struct hw_fib)); + fibpa = fibpa + sizeof(struct hw_fib); + } + /* + * Add the fib chain to the free list + */ + dev->fibs[AAC_NUM_FIB-1].next = NULL; + /* + * Enable this to debug out of queue space + */ + dev->free_fib = &dev->fibs[0]; + return 0; +} + +/** + * fib_alloc - allocate a fib + * @dev: Adapter to allocate the fib for + * + * Allocate a fib from the adapter fib pool. If the pool is empty we + * wait for fibs to become free. + */ + +struct fib * fib_alloc(struct aac_dev *dev) +{ + struct fib * fibptr; + unsigned long flags; + + spin_lock_irqsave(&dev->fib_lock, flags); + fibptr = dev->free_fib; + if(!fibptr) + BUG(); + dev->free_fib = fibptr->next; + spin_unlock_irqrestore(&dev->fib_lock, flags); + /* + * Set the proper node type code and node byte size + */ + fibptr->type = FSAFS_NTC_FIB_CONTEXT; + fibptr->size = sizeof(struct fib); + /* + * Null out fields that depend on being zero at the start of + * each I/O + */ + fibptr->fib->header.XferState = cpu_to_le32(0); + fibptr->callback = NULL; + fibptr->callback_data = NULL; + + return fibptr; +} + +/** + * fib_free - free a fib + * @fibptr: fib to free up + * + * Frees up a fib and places it on the appropriate queue + * (either free or timed out) + */ + +void fib_free(struct fib * fibptr) +{ + unsigned long flags; + + spin_lock_irqsave(&fibptr->dev->fib_lock, flags); + + if (fibptr->flags & FIB_CONTEXT_FLAG_TIMED_OUT) { + aac_config.fib_timeouts++; + fibptr->next = fibptr->dev->timeout_fib; + fibptr->dev->timeout_fib = fibptr; + } else { + if (fibptr->fib->header.XferState != 0) { + printk(KERN_WARNING "fib_free, XferState != 0, fibptr = 0x%p, XferState = 0x%x\n", + fibptr, fibptr->fib->header.XferState); + } + fibptr->next = fibptr->dev->free_fib; + fibptr->dev->free_fib = fibptr; + } + spin_unlock_irqrestore(&fibptr->dev->fib_lock, flags); +} + +/** + * fib_init - initialise a fib + * @fibptr: The fib to initialize + * + * Set up the generic fib fields ready for use + */ + +void fib_init(struct fib *fibptr) +{ + struct hw_fib *fib = fibptr->fib; + + fib->header.StructType = FIB_MAGIC; + fib->header.Size = cpu_to_le16(sizeof(struct hw_fib)); + fib->header.XferState = cpu_to_le32(HostOwned | FibInitialized | FibEmpty | FastResponseCapable); + fib->header.SenderFibAddress = cpu_to_le32(0); + fib->header.ReceiverFibAddress = cpu_to_le32(0); + fib->header.SenderSize = cpu_to_le16(sizeof(struct hw_fib)); +} + +/** + * fib_deallocate - deallocate a fib + * @fibptr: fib to deallocate + * + * Will deallocate and return to the free pool the FIB pointed to by the + * caller. + */ + +void fib_dealloc(struct fib * fibptr) +{ + struct hw_fib *fib = fibptr->fib; + if(fib->header.StructType != FIB_MAGIC) + BUG(); + fib->header.XferState = cpu_to_le32(0); +} + +/* + * Commuication primitives define and support the queuing method we use to + * support host to adapter commuication. All queue accesses happen through + * these routines and are the only routines which have a knowledge of the + * how these queues are implemented. + */ + +/** + * aac_get_entry - get a queue entry + * @dev: Adapter + * @qid: Queue Number + * @entry: Entry return + * @index: Index return + * @nonotify: notification control + * + * With a priority the routine returns a queue entry if the queue has free entries. If the queue + * is full(no free entries) than no entry is returned and the function returns 0 otherwise 1 is + * returned. + */ + +static int aac_get_entry (struct aac_dev * dev, u32 qid, struct aac_entry **entry, u32 * index, unsigned long *nonotify) +{ + struct aac_queue * q; + + /* + * All of the queues wrap when they reach the end, so we check + * to see if they have reached the end and if they have we just + * set the index back to zero. This is a wrap. You could or off + * the high bits in all updates but this is a bit faster I think. + */ + + q = &dev->queues->queue[qid]; + + *index = le32_to_cpu(*(q->headers.producer)); + if (*index - 2 == le32_to_cpu(*(q->headers.consumer))) + *nonotify = 1; + + if (qid == AdapHighCmdQueue) { + if (*index >= ADAP_HIGH_CMD_ENTRIES) + *index = 0; + } else if (qid == AdapNormCmdQueue) { + if (*index >= ADAP_NORM_CMD_ENTRIES) + *index = 0; /* Wrap to front of the Producer Queue. */ + } + else if (qid == AdapHighRespQueue) + { + if (*index >= ADAP_HIGH_RESP_ENTRIES) + *index = 0; + } + else if (qid == AdapNormRespQueue) + { + if (*index >= ADAP_NORM_RESP_ENTRIES) + *index = 0; /* Wrap to front of the Producer Queue. */ + } + else BUG(); + + if (*index + 1 == le32_to_cpu(*(q->headers.consumer))) { /* Queue is full */ + printk(KERN_WARNING "Queue %d full, %ld outstanding.\n", + qid, q->numpending); + return 0; + } else { + *entry = q->base + *index; + return 1; + } +} + +/** + * aac_queue_get - get the next free QE + * @dev: Adapter + * @index: Returned index + * @priority: Priority of fib + * @fib: Fib to associate with the queue entry + * @wait: Wait if queue full + * @fibptr: Driver fib object to go with fib + * @nonotify: Don't notify the adapter + * + * Gets the next free QE off the requested priorty adapter command + * queue and associates the Fib with the QE. The QE represented by + * index is ready to insert on the queue when this routine returns + * success. + */ + +static int aac_queue_get(struct aac_dev * dev, u32 * index, u32 qid, struct hw_fib * fib, int wait, struct fib * fibptr, unsigned long *nonotify) +{ + struct aac_entry * entry = NULL; + int map = 0; + struct aac_queue * q = &dev->queues->queue[qid]; + + spin_lock_irqsave(q->lock, q->SavedIrql); + + if (qid == AdapHighCmdQueue || qid == AdapNormCmdQueue) + { + /* if no entries wait for some if caller wants to */ + while (!aac_get_entry(dev, qid, &entry, index, nonotify)) + { + printk(KERN_ERR "GetEntries failed\n"); + } + /* + * Setup queue entry with a command, status and fib mapped + */ + entry->size = cpu_to_le32(le16_to_cpu(fib->header.Size)); + map = 1; + } + else if (qid == AdapHighRespQueue || qid == AdapNormRespQueue) + { + while(!aac_get_entry(dev, qid, &entry, index, nonotify)) + { + /* if no entries wait for some if caller wants to */ + } + /* + * Setup queue entry with command, status and fib mapped + */ + entry->size = cpu_to_le32(le16_to_cpu(fib->header.Size)); + entry->addr = cpu_to_le32(fib->header.SenderFibAddress); /* Restore adapters pointer to the FIB */ + fib->header.ReceiverFibAddress = fib->header.SenderFibAddress; /* Let the adapter now where to find its data */ + map = 0; + } + /* + * If MapFib is true than we need to map the Fib and put pointers + * in the queue entry. + */ + if (map) + entry->addr = cpu_to_le32((unsigned long)(fibptr->logicaladdr)); + return 0; +} + + +/** + * aac_insert_entry - insert a queue entry + * @dev: Adapter + * @index: Index of entry to insert + * @qid: Queue number + * @nonotify: Suppress adapter notification + * + * Gets the next free QE off the requested priorty adapter command + * queue and associates the Fib with the QE. The QE represented by + * index is ready to insert on the queue when this routine returns + * success. + */ + +static int aac_insert_entry(struct aac_dev * dev, u32 index, u32 qid, unsigned long nonotify) +{ + struct aac_queue * q = &dev->queues->queue[qid]; + + if(q == NULL) + BUG(); + *(q->headers.producer) = cpu_to_le32(index + 1); + spin_unlock_irqrestore(q->lock, q->SavedIrql); + + if (qid == AdapHighCmdQueue || + qid == AdapNormCmdQueue || + qid == AdapHighRespQueue || + qid == AdapNormRespQueue) + { + if (!nonotify) + aac_adapter_notify(dev, qid); + } + else + printk("Suprise insert!\n"); + return 0; +} + +/* + * Define the highest level of host to adapter communication routines. + * These routines will support host to adapter FS commuication. These + * routines have no knowledge of the commuication method used. This level + * sends and receives FIBs. This level has no knowledge of how these FIBs + * get passed back and forth. + */ + +/** + * fib_send - send a fib to the adapter + * @command: Command to send + * @fibptr: The fib + * @size: Size of fib data area + * @priority: Priority of Fib + * @wait: Async/sync select + * @reply: True if a reply is wanted + * @callback: Called with reply + * @callback_data: Passed to callback + * + * Sends the requested FIB to the adapter and optionally will wait for a + * response FIB. If the caller does not wish to wait for a response than + * an event to wait on must be supplied. This event will be set when a + * response FIB is received from the adapter. + */ + +int fib_send(u16 command, struct fib * fibptr, unsigned long size, int priority, int wait, int reply, fib_callback callback, void * callback_data) +{ + u32 index; + u32 qid; + struct aac_dev * dev = fibptr->dev; + unsigned long nointr = 0; + struct hw_fib * fib = fibptr->fib; + struct aac_queue * q; + unsigned long flags = 0; + + if (!(le32_to_cpu(fib->header.XferState) & HostOwned)) + return -EBUSY; + /* + * There are 5 cases with the wait and reponse requested flags. + * The only invalid cases are if the caller requests to wait and + * does not request a response and if the caller does not want a + * response and the Fibis not allocated from pool. If a response + * is not requesed the Fib will just be deallocaed by the DPC + * routine when the response comes back from the adapter. No + * further processing will be done besides deleting the Fib. We + * will have a debug mode where the adapter can notify the host + * it had a problem and the host can log that fact. + */ + if (wait && !reply) { + return -EINVAL; + } else if (!wait && reply) { + fib->header.XferState |= cpu_to_le32(Async | ResponseExpected); + FIB_COUNTER_INCREMENT(aac_config.AsyncSent); + } else if (!wait && !reply) { + fib->header.XferState |= cpu_to_le32(NoResponseExpected); + FIB_COUNTER_INCREMENT(aac_config.NoResponseSent); + } else if (wait && reply) { + fib->header.XferState |= cpu_to_le32(ResponseExpected); + FIB_COUNTER_INCREMENT(aac_config.NormalSent); + } + fib->header.SenderData = (unsigned long)fibptr; /* for callback */ + /* + * Set FIB state to indicate where it came from and if we want a + * response from the adapter. Also load the command from the + * caller. + */ + fib->header.SenderFibAddress = cpu_to_le32((u32)fib); + fib->header.Command = cpu_to_le16(command); + fib->header.XferState |= cpu_to_le32(SentFromHost); + fibptr->fib->header.Flags = 0; /* Zero the flags field - its internal only... */ + /* + * Set the size of the Fib we want to send to the adapter + */ + fib->header.Size = cpu_to_le16(sizeof(struct aac_fibhdr) + size); + if (le16_to_cpu(fib->header.Size) > le16_to_cpu(fib->header.SenderSize)) { + return -EMSGSIZE; + } + /* + * Get a queue entry connect the FIB to it and send an notify + * the adapter a command is ready. + */ + if (priority == FsaHigh) { + fib->header.XferState |= cpu_to_le32(HighPriority); + qid = AdapHighCmdQueue; + } else { + fib->header.XferState |= cpu_to_le32(NormalPriority); + qid = AdapNormCmdQueue; + } + q = &dev->queues->queue[qid]; + + if(wait) + spin_lock_irqsave(&fibptr->event_lock, flags); + if(aac_queue_get( dev, &index, qid, fib, 1, fibptr, &nointr)<0) + return -EWOULDBLOCK; + dprintk((KERN_DEBUG "fib_send: inserting a queue entry at index %d.\n",index)); + dprintk((KERN_DEBUG "Fib contents:.\n")); + dprintk((KERN_DEBUG " Command = %d.\n", fib->header.Command)); + dprintk((KERN_DEBUG " XferState = %x.\n", fib->header.XferState)); + /* + * Fill in the Callback and CallbackContext if we are not + * going to wait. + */ + if (!wait) { + fibptr->callback = callback; + fibptr->callback_data = callback_data; + } + FIB_COUNTER_INCREMENT(aac_config.FibsSent); + list_add_tail(&fibptr->queue, &q->pendingq); + q->numpending++; + + fibptr->done = 0; + + if(aac_insert_entry(dev, index, qid, (nointr & aac_config.irq_mod)) < 0) + return -EWOULDBLOCK; + /* + * If the caller wanted us to wait for response wait now. + */ + + if (wait) { + spin_unlock_irqrestore(&fibptr->event_lock, flags); + down(&fibptr->event_wait); + if(fibptr->done == 0) + BUG(); + + if((fibptr->flags & FIB_CONTEXT_FLAG_TIMED_OUT)) + return -ETIMEDOUT; + else + return 0; + } + /* + * If the user does not want a response than return success otherwise + * return pending + */ + if (reply) + return -EINPROGRESS; + else + return 0; +} + +/** + * aac_consumer_get - get the top of the queue + * @dev: Adapter + * @q: Queue + * @entry: Return entry + * + * Will return a pointer to the entry on the top of the queue requested that + * we are a consumer of, and return the address of the queue entry. It does + * not change the state of the queue. + */ + +int aac_consumer_get(struct aac_dev * dev, struct aac_queue * q, struct aac_entry **entry) +{ + u32 index; + int status; + + if (*q->headers.producer == *q->headers.consumer) { + status = 0; + } else { + /* + * The consumer index must be wrapped if we have reached + * the end of the queue, else we just use the entry + * pointed to by the header index + */ + if (le32_to_cpu(*q->headers.consumer) >= q->entries) + index = 0; + else + index = le32_to_cpu(*q->headers.consumer); + *entry = q->base + index; + status = 1; + } + return(status); +} + +int aac_consumer_avail(struct aac_dev *dev, struct aac_queue * q) +{ + return (*q->headers.producer != *q->headers.consumer); +} + + +/** + * aac_consumer_free - free consumer entry + * @dev: Adapter + * @q: Queue + * @qid: Queue ident + * + * Frees up the current top of the queue we are a consumer of. If the + * queue was full notify the producer that the queue is no longer full. + */ + +void aac_consumer_free(struct aac_dev * dev, struct aac_queue *q, u32 qid) +{ + int wasfull = 0; + u32 notify; + + if (*q->headers.producer+1 == *q->headers.consumer) + wasfull = 1; + + if (le32_to_cpu(*q->headers.consumer) >= q->entries) + *q->headers.consumer = cpu_to_le32(1); + else + *q->headers.consumer = cpu_to_le32(le32_to_cpu(*q->headers.consumer)+1); + + if (wasfull) { + switch (qid) { + + case HostNormCmdQueue: + notify = HostNormCmdNotFull; + break; + case HostHighCmdQueue: + notify = HostHighCmdNotFull; + break; + case HostNormRespQueue: + notify = HostNormRespNotFull; + break; + case HostHighRespQueue: + notify = HostHighRespNotFull; + break; + default: + BUG(); + return; + } + aac_adapter_notify(dev, notify); + } +} + +/** + * fib_adapter_complete - complete adapter issued fib + * @fibptr: fib to complete + * @size: size of fib + * + * Will do all necessary work to complete a FIB that was sent from + * the adapter. + */ + +int fib_adapter_complete(struct fib * fibptr, unsigned short size) +{ + struct hw_fib * fib = fibptr->fib; + struct aac_dev * dev = fibptr->dev; + unsigned long nointr = 0; + + if (le32_to_cpu(fib->header.XferState) == 0) + return 0; + /* + * If we plan to do anything check the structure type first. + */ + if ( fib->header.StructType != FIB_MAGIC ) { + return -EINVAL; + } + /* + * This block handles the case where the adapter had sent us a + * command and we have finished processing the command. We + * call completeFib when we are done processing the command + * and want to send a response back to the adapter. This will + * send the completed cdb to the adapter. + */ + if (fib->header.XferState & cpu_to_le32(SentFromAdapter)) { + fib->header.XferState |= cpu_to_le32(HostProcessed); + if (fib->header.XferState & cpu_to_le32(HighPriority)) { + u32 index; + if (size) + { + size += sizeof(struct aac_fibhdr); + if (size > le16_to_cpu(fib->header.SenderSize)) + return -EMSGSIZE; + fib->header.Size = cpu_to_le16(size); + } + if(aac_queue_get(dev, &index, AdapHighRespQueue, fib, 1, NULL, &nointr) < 0) { + return -EWOULDBLOCK; + } + if (aac_insert_entry(dev, index, AdapHighRespQueue, (nointr & (int)aac_config.irq_mod)) != 0) { + } + } + else if (fib->header.XferState & NormalPriority) + { + u32 index; + + if (size) { + size += sizeof(struct aac_fibhdr); + if (size > le16_to_cpu(fib->header.SenderSize)) + return -EMSGSIZE; + fib->header.Size = cpu_to_le16(size); + } + if (aac_queue_get(dev, &index, AdapNormRespQueue, fib, 1, NULL, &nointr) < 0) + return -EWOULDBLOCK; + if (aac_insert_entry(dev, index, AdapNormRespQueue, + (nointr & (int)aac_config.irq_mod)) != 0) + { + } + } + } + else + { + printk(KERN_WARNING "fib_complete: Unknown xferstate detected.\n"); + BUG(); + } + return 0; +} + +/** + * fib_complete - fib completion handler + * @fib: FIB to complete + * + * Will do all necessary work to complete a FIB. + */ + +int fib_complete(struct fib * fibptr) +{ + struct hw_fib * fib = fibptr->fib; + + /* + * Check for a fib which has already been completed + */ + + if (fib->header.XferState == cpu_to_le32(0)) + return 0; + /* + * If we plan to do anything check the structure type first. + */ + + if (fib->header.StructType != FIB_MAGIC) + return -EINVAL; + /* + * This block completes a cdb which orginated on the host and we + * just need to deallocate the cdb or reinit it. At this point the + * command is complete that we had sent to the adapter and this + * cdb could be reused. + */ + if((fib->header.XferState & cpu_to_le32(SentFromHost)) && + (fib->header.XferState & cpu_to_le32(AdapterProcessed))) + { + fib_dealloc(fibptr); + } + else if(fib->header.XferState & cpu_to_le32(SentFromHost)) + { + /* + * This handles the case when the host has aborted the I/O + * to the adapter because the adapter is not responding + */ + fib_dealloc(fibptr); + } else if(fib->header.XferState & cpu_to_le32(HostOwned)) { + fib_dealloc(fibptr); + } else { + BUG(); + } + return 0; +} + +/** + * aac_printf - handle printf from firmware + * @dev: Adapter + * @val: Message info + * + * Print a message passed to us by the controller firmware on the + * Adaptec board + */ + +void aac_printf(struct aac_dev *dev, u32 val) +{ + int length = val & 0xffff; + int level = (val >> 16) & 0xffff; + char *cp = dev->printfbuf; + + /* + * The size of the printfbuf is set in port.c + * There is no variable or define for it + */ + if (length > 255) + length = 255; + if (cp[length] != 0) + cp[length] = 0; + if (level == LOG_HIGH_ERROR) + printk(KERN_WARNING "aacraid:%s.\n", cp); + else + printk(KERN_INFO "aacraid:%s.\n", cp); + memset(cp, 0, 256); +} + + +/** + * aac_handle_aif - Handle a message from the firmware + * @dev: Which adapter this fib is from + * @fibptr: Pointer to fibptr from adapter + * + * This routine handles a driver notify fib from the adapter and + * dispatches it to the appropriate routine for handling. + */ + +static void aac_handle_aif(struct aac_dev * dev, struct fib * fibptr) +{ + struct hw_fib * fib = fibptr->fib; + /* + * Set the status of this FIB to be Invalid parameter. + * + * *(u32 *)fib->data = ST_INVAL; + */ + *(u32 *)fib->data = cpu_to_le32(ST_OK); + fib_adapter_complete(fibptr, sizeof(u32)); +} + +/** + * aac_command_thread - command processing thread + * @dev: Adapter to monitor + * + * Waits on the commandready event in it's queue. When the event gets set + * it will pull FIBs off it's queue. It will continue to pull FIBs off + * until the queue is empty. When the queue is empty it will wait for + * more FIBs. + */ + +int aac_command_thread(struct aac_dev * dev) +{ + struct hw_fib *fib, *newfib; + struct fib fibptr; /* for error logging */ + struct aac_queue_block *queues = dev->queues; + struct aac_fib_context *fibctx; + unsigned long flags; + DECLARE_WAITQUEUE(wait, current); + + /* + * We can only have one thread per adapter for AIF's. + */ + if (dev->aif_thread) + return -EINVAL; + /* + * Set up the name that will appear in 'ps' + * stored in task_struct.comm[16]. + */ + sprintf(current->comm, "aacraid"); + daemonize(); + /* + * Let the DPC know it has a place to send the AIF's to. + */ + dev->aif_thread = 1; + memset(&fibptr, 0, sizeof(struct fib)); + add_wait_queue(&queues->queue[HostNormCmdQueue].cmdready, &wait); + set_current_state(TASK_INTERRUPTIBLE); + while(1) + { + spin_lock_irqsave(queues->queue[HostNormCmdQueue].lock, flags); + while(!list_empty(&(queues->queue[HostNormCmdQueue].cmdq))) { + struct list_head *entry; + struct aac_aifcmd * aifcmd; + + set_current_state(TASK_RUNNING); + + entry = queues->queue[HostNormCmdQueue].cmdq.next; + list_del(entry); + + spin_unlock_irqrestore(queues->queue[HostNormCmdQueue].lock, flags); + fib = list_entry(entry, struct hw_fib, header.FibLinks); + /* + * We will process the FIB here or pass it to a + * worker thread that is TBD. We Really can't + * do anything at this point since we don't have + * anything defined for this thread to do. + */ + memset(&fibptr, 0, sizeof(struct fib)); + fibptr.type = FSAFS_NTC_FIB_CONTEXT; + fibptr.size = sizeof( struct fib ); + fibptr.fib = fib; + fibptr.data = fib->data; + fibptr.dev = dev; + /* + * We only handle AifRequest fibs from the adapter. + */ + aifcmd = (struct aac_aifcmd *) fib->data; + if (aifcmd->command == le16_to_cpu(AifCmdDriverNotify)) { + aac_handle_aif(dev, &fibptr); + } else { + /* The u32 here is important and intended. We are using + 32bit wrapping time to fit the adapter field */ + + u32 time_now, time_last; + unsigned long flagv; + + time_now = jiffies/HZ; + + spin_lock_irqsave(&dev->fib_lock, flagv); + entry = dev->fib_list.next; + /* + * For each Context that is on the + * fibctxList, make a copy of the + * fib, and then set the event to wake up the + * thread that is waiting for it. + */ + while (entry != &dev->fib_list) { + /* + * Extract the fibctx + */ + fibctx = list_entry(entry, struct aac_fib_context, next); + /* + * Check if the queue is getting + * backlogged + */ + if (fibctx->count > 20) + { + time_last = fibctx->jiffies; + /* + * Has it been > 2 minutes + * since the last read off + * the queue? + */ + if ((time_now - time_last) > 120) { + entry = entry->next; + aac_close_fib_context(dev, fibctx); + continue; + } + } + /* + * Warning: no sleep allowed while + * holding spinlock + */ + newfib = kmalloc(sizeof(struct hw_fib), GFP_ATOMIC); + if (newfib) { + /* + * Make the copy of the FIB + */ + memcpy(newfib, fib, sizeof(struct hw_fib)); + /* + * Put the FIB onto the + * fibctx's fibs + */ + list_add_tail(&newfib->header.FibLinks, &fibctx->fibs); + fibctx->count++; + /* + * Set the event to wake up the + * thread that will waiting. + */ + up(&fibctx->wait_sem); + } else { + printk(KERN_WARNING "aifd: didn't allocate NewFib.\n"); + } + entry = entry->next; + } + /* + * Set the status of this FIB + */ + *(u32 *)fib->data = cpu_to_le32(ST_OK); + fib_adapter_complete(&fibptr, sizeof(u32)); + spin_unlock_irqrestore(&dev->fib_lock, flagv); + } + spin_lock_irqsave(queues->queue[HostNormCmdQueue].lock, flags); + } + /* + * There are no more AIF's + */ + spin_unlock_irqrestore(queues->queue[HostNormCmdQueue].lock, flags); + schedule(); + + if(signal_pending(current)) + break; + set_current_state(TASK_INTERRUPTIBLE); + } + remove_wait_queue(&queues->queue[HostNormCmdQueue].cmdready, &wait); + dev->aif_thread = 0; + complete_and_exit(&dev->aif_completion, 0); +} diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/scsi/aacraid/dpcsup.c linux-2.5/drivers/scsi/aacraid/dpcsup.c --- linux-2.5.1/drivers/scsi/aacraid/dpcsup.c Thu Jan 1 00:00:00 1970 +++ linux-2.5/drivers/scsi/aacraid/dpcsup.c Thu Dec 13 16:32:36 2001 @@ -0,0 +1,201 @@ +/* + * Adaptec AAC series RAID controller driver + * (c) Copyright 2001 Red Hat Inc. <alan@redhat.com> + * + * based on the old aacraid driver that is.. + * Adaptec aacraid device driver for Linux. + * + * Copyright (c) 2000 Adaptec, Inc. (aacraid@adaptec.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, 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; see the file COPYING. If not, write to + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * + * Module Name: + * dpcsup.c + * + * Abstract: All DPC processing routines for the cyclone board occur here. + * + * + */ + +#include <linux/config.h> +#include <linux/kernel.h> +#include <linux/init.h> +#include <linux/types.h> +#include <linux/sched.h> +#include <linux/pci.h> +#include <linux/spinlock.h> +#include <linux/slab.h> +#include <linux/completion.h> +#include <linux/blk.h> +#include <asm/semaphore.h> +#include "scsi.h" +#include "hosts.h" + +#include "aacraid.h" + +/** + * aac_response_normal - Handle command replies + * @q: Queue to read from + * + * This DPC routine will be run when the adapter interrupts us to let us + * know there is a response on our normal priority queue. We will pull off + * all QE there are and wake up all the waiters before exiting. We will + * take a spinlock out on the queue before operating on it. + */ + +unsigned int aac_response_normal(struct aac_queue * q) +{ + struct aac_dev * dev = q->dev; + struct aac_entry *entry; + struct hw_fib * fib; + struct fib * fibctx; + int consumed = 0; + unsigned long flags; + + spin_lock_irqsave(q->lock, flags); + + /* + * Keep pulling response QEs off the response queue and waking + * up the waiters until there are no more QEs. We then return + * back to the system. If no response was requesed we just + * deallocate the Fib here and continue. + */ + while(aac_consumer_get(dev, q, &entry)) + { + int fast; + + fast = (int) (entry->addr & 0x01); + fib = (struct hw_fib *) (entry->addr & ~0x01); + aac_consumer_free(dev, q, HostNormRespQueue); + fibctx = (struct fib *)fib->header.SenderData; + /* + * Remove this fibctx from the Outstanding I/O queue. + * But only if it has not already been timed out. + * + * If the fib has been timed out already, then just + * continue. The caller has already been notified that + * the fib timed out. + */ + if (!(fibctx->flags & FIB_CONTEXT_FLAG_TIMED_OUT)) { + list_del(&fibctx->queue); + dev->queues->queue[AdapNormCmdQueue].numpending--; + } else { + printk(KERN_WARNING "aacraid: FIB timeout.\n"); + continue; + } + spin_unlock_irqrestore(q->lock, flags); + + if (fast) { + /* + * Doctor the fib + */ + *(u32 *)fib->data = cpu_to_le32(ST_OK); + fib->header.XferState |= cpu_to_le32(AdapterProcessed); + } + + FIB_COUNTER_INCREMENT(aac_config.FibRecved); + + if (fib->header.Command == cpu_to_le16(NuFileSystem)) + { + u32 *pstatus = (u32 *)fib->data; + if (*pstatus & cpu_to_le32(0xffff0000)) + *pstatus = cpu_to_le32(ST_OK); + } + if (fib->header.XferState & cpu_to_le32(NoResponseExpected | Async)) + { + if (fib->header.XferState & cpu_to_le32(NoResponseExpected)) + FIB_COUNTER_INCREMENT(aac_config.NoResponseRecved); + else + FIB_COUNTER_INCREMENT(aac_config.AsyncRecved); + /* + * NOTE: we cannot touch the fibctx after this + * call, because it may have been deallocated. + */ + fibctx->callback(fibctx->callback_data, fibctx); + } else { + unsigned long flagv; + spin_lock_irqsave(&fibctx->event_lock, flagv); + fibctx->done = 1; + up(&fibctx->event_wait); + spin_unlock_irqrestore(&fibctx->event_lock, flagv); + FIB_COUNTER_INCREMENT(aac_config.NormalRecved); + } + consumed++; + spin_lock_irqsave(q->lock, flags); + } + + if (consumed > aac_config.peak_fibs) + aac_config.peak_fibs = consumed; + if (consumed == 0) + aac_config.zero_fibs++; + + spin_unlock_irqrestore(q->lock, flags); + return 0; +} + + +/** + * aac_command_normal - handle commands + * @q: queue to process + * + * This DPC routine will be queued when the adapter interrupts us to + * let us know there is a command on our normal priority queue. We will + * pull off all QE there are and wake up all the waiters before exiting. + * We will take a spinlock out on the queue before operating on it. + */ + +unsigned int aac_command_normal(struct aac_queue *q) +{ + struct aac_dev * dev = q->dev; + struct aac_entry *entry; + unsigned long flags; + + spin_lock_irqsave(q->lock, flags); + + /* + * Keep pulling response QEs off the response queue and waking + * up the waiters until there are no more QEs. We then return + * back to the system. + */ + while(aac_consumer_get(dev, q, &entry)) + { + struct hw_fib * fib; + fib = (struct hw_fib *)entry->addr; + + if (dev->aif_thread) { + list_add_tail(&fib->header.FibLinks, &q->cmdq); + aac_consumer_free(dev, q, HostNormCmdQueue); + wake_up_interruptible(&q->cmdready); + } else { + struct fib fibctx; + aac_consumer_free(dev, q, HostNormCmdQueue); + spin_unlock_irqrestore(q->lock, flags); + memset(&fibctx, 0, sizeof(struct fib)); + fibctx.type = FSAFS_NTC_FIB_CONTEXT; + fibctx.size = sizeof(struct fib); + fibctx.fib = fib; + fibctx.data = fib->data; + fibctx.dev = dev; + /* + * Set the status of this FIB + */ + *(u32 *)fib->data = cpu_to_le32(ST_OK); + fib_adapter_complete(&fibctx, sizeof(u32)); + spin_lock_irqsave(q->lock, flags); + } + } + spin_unlock_irqrestore(q->lock, flags); + return 0; +} diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/scsi/aacraid/linit.c linux-2.5/drivers/scsi/aacraid/linit.c --- linux-2.5.1/drivers/scsi/aacraid/linit.c Thu Jan 1 00:00:00 1970 +++ linux-2.5/drivers/scsi/aacraid/linit.c Thu Dec 13 16:32:36 2001 @@ -0,0 +1,691 @@ +/* + * Adaptec AAC series RAID controller driver + * (c) Copyright 2001 Red Hat Inc. <alan@redhat.com> + * + * based on the old aacraid driver that is.. + * Adaptec aacraid device driver for Linux. + * + * Copyright (c) 2000 Adaptec, Inc. (aacraid@adaptec.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, 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; see the file COPYING. If not, write to + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * + * Module Name: + * linit.c + * + * Abstract: Linux Driver entry module for Adaptec RAID Array Controller + * + * Provides the following driver entry points: + * aac_detect() + * aac_release() + * aac_queuecommand() + * aac_resetcommand() + * aac_biosparm() + * + */ + +#define AAC_DRIVER_VERSION "0.9.9ac2-rel" +#define AAC_DRIVER_BUILD_DATE __DATE__ + +#include <linux/module.h> +#include <linux/config.h> +#include <linux/kernel.h> +#include <linux/init.h> +#include <linux/types.h> +#include <linux/sched.h> +#include <linux/pci.h> +#include <linux/spinlock.h> +#include <linux/slab.h> +#include <linux/completion.h> +#include <asm/semaphore.h> +#include <linux/blk.h> +#include "scsi.h" +#include "hosts.h" + +#include "aacraid.h" +#include "sd.h" + +#define AAC_DRIVERNAME "aacraid" + +MODULE_AUTHOR("Red Hat Inc and Adaptec OEM RAID Solutions"); +MODULE_DESCRIPTION("Supports Dell PERC2, 2/Si, 3/Si, 3/Di, and HP NetRAID-4M devices. http://domsch.com/linux/"); +MODULE_LICENSE("GPL"); + +struct aac_dev *aac_devices[MAXIMUM_NUM_ADAPTERS]; + +static unsigned aac_count = 0; +static int aac_cfg_major = -1; +static int single_command_done = 0; + +/* + * Because of the way Linux names scsi devices, the order in this table has + * become important. Check for on-board Raid first, add-in cards second. + */ + +/* FIXME static */struct aac_driver_ident aac_drivers[] = { + { 0x1028, 0x0001, 0x1028, 0x0001, aac_rx_init, "percraid", "DELL ", "PERCRAID " }, /* PERC 2/Si */ + { 0x1028, 0x0002, 0x1028, 0x0002, aac_rx_init, "percraid", "DELL ", "PERCRAID " }, /* PERC 3/Di */ + { 0x1028, 0x0003, 0x1028, 0x0003, aac_rx_init, "percraid", "DELL ", "PERCRAID " }, /* PERC 3/Si */ + { 0x1028, 0x0004, 0x1028, 0x00d0, aac_rx_init, "percraid", "DELL ", "PERCRAID " }, /* PERC 3/Si */ + { 0x1028, 0x0002, 0x1028, 0x00d1, aac_rx_init, "percraid", "DELL ", "PERCRAID " }, /* PERC 3/Di */ + { 0x1028, 0x0002, 0x1028, 0x00d9, aac_rx_init, "percraid", "DELL ", "PERCRAID " }, /* PERC 3/Di */ + { 0x1028, 0x000a, 0x1028, 0x0106, aac_rx_init, "percraid", "DELL ", "PERCRAID " }, /* PERC 3/Di */ + { 0x1028, 0x000a, 0x1028, 0x011b, aac_rx_init, "percraid", "DELL ", "PERCRAID " }, /* PERC 3/Di */ + { 0x1028, 0x000a, 0x1028, 0x0121, aac_rx_init, "percraid", "DELL ", "PERCRAID " }, /* PERC 3/Di */ + { 0x1011, 0x0046, 0x9005, 0x1364, aac_sa_init, "percraid", "DELL ", "PERCRAID " }, /* Dell PERC2 "Quad Channel" */ + { 0x1011, 0x0046, 0x9005, 0x0365, aac_sa_init, "aacraid", "ADAPTEC ", "Adaptec 5400S " }, /* Adaptec 5400S */ + { 0x1011, 0x0046, 0x103c, 0x10c2, aac_sa_init, "hpnraid", "HP ", "NetRAID-4M " } /* HP NetRAID-4M */ +}; + +#define NUM_AACTYPES (sizeof(aac_drivers) / sizeof(struct aac_driver_ident)) +static int num_aacdrivers = NUM_AACTYPES; + +static int aac_cfg_ioctl(struct inode * inode, struct file * file, unsigned int cmd, unsigned long arg); +static int aac_cfg_open(struct inode * inode, struct file * file); +static int aac_cfg_release(struct inode * inode,struct file * file); + +static struct file_operations aac_cfg_fops = { + owner: THIS_MODULE, + ioctl: aac_cfg_ioctl, + open: aac_cfg_open, + release: aac_cfg_release +}; + +static int aac_detect(Scsi_Host_Template *); +static int aac_release(struct Scsi_Host *); +static int aac_queuecommand(Scsi_Cmnd *, void (*CompletionRoutine)(Scsi_Cmnd *)); +static int aac_command(Scsi_Cmnd *); +static int aac_abortcommand(Scsi_Cmnd *scsi_cmnd_ptr); +static int aac_resetcommand(Scsi_Cmnd *, unsigned int); +static int aac_biosparm(Scsi_Disk *, kdev_t, int *); +static int aac_procinfo(char *, char **, off_t, int, int, int); +static int aac_ioctl(Scsi_Device *, int, void *); + +static void aac_queuedepth(struct Scsi_Host *, Scsi_Device *); + +/** + * aac_detect - Probe for aacraid cards + * @template: SCSI driver template + * + * Probe for AAC Host Adapters initialize, register, and report the + * configuration of each AAC Host Adapter found. + * Returns the number of adapters successfully initialized and + * registered. + * Initializes all data necessary for this particular SCSI driver. + * Notes: + * The detect routine must not call any of the mid level functions + * to queue commands because things are not guaranteed to be set + * up yet. The detect routine can send commands to the host adapter + * as long as the program control will not be passed to scsi.c in + * the processing of the command. Note especially that + * scsi_malloc/scsi_free must not be called. + * + */ + +static int aac_detect(Scsi_Host_Template *template) +{ + int index; + int container; + u16 vendor_id, device_id; + struct Scsi_Host *host_ptr; + struct pci_dev *dev = NULL; + struct aac_dev *aac; + struct fsa_scsi_hba *fsa_dev_ptr; + char *name = NULL; + + printk(KERN_INFO "Red Hat/Adaptec aacraid driver, %s\n", AAC_DRIVER_BUILD_DATE); + + /* setting up the proc directory structure */ + template->proc_name = "aacraid"; + + for( index = 0; index != num_aacdrivers; index++ ) + { + device_id = aac_drivers[index].device; + vendor_id = aac_drivers[index].vendor; + name = aac_drivers[index].name; + dprintk((KERN_DEBUG "Checking %s %x/%x/%x/%x.\n", + name, vendor_id, device_id, + aac_drivers[index].subsystem_vendor, + aac_drivers[index].subsystem_device)); + + dev = NULL; + while((dev = pci_find_device(vendor_id, device_id, dev))) + { + if (pci_enable_device(dev)) + continue; + pci_set_master(dev); + pci_set_dma_mask(dev, 0xFFFFFFFFULL); + + if((dev->subsystem_vendor != aac_drivers[index].subsystem_vendor) || + (dev->subsystem_device != aac_drivers[index].subsystem_device)) + continue; + + dprintk((KERN_DEBUG "%s device detected.\n", name)); + dprintk((KERN_DEBUG "%x/%x/%x/%x.\n", vendor_id, device_id, + aac_drivers[index].subsystem_vendor, aac_drivers[index].subsystem_device)); + /* Increment the host adapter count */ + aac_count++; + /* + * scsi_register() allocates memory for a Scsi_Hosts structure and + * links it into the linked list of host adapters. This linked list + * contains the data for all possible <supported> scsi hosts. + * This is similar to the Scsi_Host_Template, except that we have + * one entry for each actual physical host adapter on the system, + * stored as a linked list. If there are two AAC boards, then we + * will need to make two Scsi_Host entries, but there will be only + * one Scsi_Host_Template entry. The second argument to scsi_register() + * specifies the size of the extra memory we want to hold any device + * specific information. + */ + host_ptr = scsi_register( template, sizeof(struct aac_dev) ); + /* + * These three parameters can be used to allow for wide SCSI + * and for host adapters that support multiple buses. + */ + host_ptr->max_id = 17; + host_ptr->max_lun = 8; + host_ptr->max_channel = 1; + host_ptr->irq = dev->irq; /* Adapter IRQ number */ + /* host_ptr->base = ( char * )(dev->resource[0].start & ~0xff); */ + host_ptr->base = dev->resource[0].start; + scsi_set_pci_device(host_ptr, dev); + dprintk((KERN_DEBUG "Device base address = 0x%lx [0x%lx].\n", host_ptr->base, dev->resource[0].start)); + dprintk((KERN_DEBUG "Device irq = 0x%x.\n", dev->irq)); + /* + * The unique_id field is a unique identifier that must + * be assigned so that we have some way of identifying + * each host adapter properly and uniquely. For hosts + * that do not support more than one card in the + * system, this does not need to be set. It is + * initialized to zero in scsi_register(). This is the + * value returned as aac->id. + */ + host_ptr->unique_id = aac_count - 1; + /* + * This function is called after the device list has + * been built to find the tagged queueing depth + * supported for each device. + */ + host_ptr->select_queue_depths = aac_queuedepth; + aac = (struct aac_dev *)host_ptr->hostdata; + /* attach a pointer back to Scsi_Host */ + aac->scsi_host_ptr = host_ptr; + aac->pdev = dev; + aac->cardtype = index; + aac->name = aac->scsi_host_ptr->hostt->name; + aac->id = aac->scsi_host_ptr->unique_id; + /* Initialize the ordinal number of the device to -1 */ + fsa_dev_ptr = &(aac->fsa_dev); + for( container = 0; container < MAXIMUM_NUM_CONTAINERS; container++ ) + fsa_dev_ptr->devno[container] = -1; + + dprintk((KERN_DEBUG "Initializing Hardware...\n")); + if((*aac_drivers[index].init)(aac , host_ptr->unique_id) != 0) + { + /* device initialization failed */ + printk(KERN_WARNING "aacraid: device initialization failed.\n"); + scsi_unregister(host_ptr); + aac_count--; + } + else + { + dprintk((KERN_DEBUG "%s:%d device initialization successful.\n", name, host_ptr->unique_id)); + aac_get_containers(aac); + aac_devices[aac_count-1] = aac; + } + } + } + + if( aac_count ){ + if((aac_cfg_major = register_chrdev( 0, "aac", &aac_cfg_fops))<0) + printk(KERN_WARNING "aacraid: unable to register \"aac\" device.\n"); + } + + template->present = aac_count; /* # of cards of this type found */ + return aac_count; +} + +/** + * aac_release - release SCSI host resources + * @host_ptr: SCSI host to clean up + * + * Release all resources previously acquired to support a specific Host + * Adapter and unregister the AAC Host Adapter. + * + * BUGS: Does not wait for the thread it kills to die. + */ + +static int aac_release(struct Scsi_Host *host_ptr) +{ + struct aac_dev *dev; + dprintk((KERN_DEBUG "aac_release.\n")); + dev = (struct aac_dev *)host_ptr->hostdata; + /* + * kill any threads we started + */ + kill_proc(dev->thread_pid, SIGKILL, 0); + wait_for_completion(&dev->aif_completion); + /* + * Call the comm layer to detach from this adapter + */ + aac_detach(dev); + /* Check free orderings... */ + /* remove interrupt binding */ + free_irq(host_ptr->irq, dev); + iounmap((void * )dev->regs.sa); + /* unregister adapter */ + scsi_unregister(host_ptr); + /* + * FIXME: This assumes no hot plugging is going on... + */ + if( aac_cfg_major >= 0 ) + { + unregister_chrdev(aac_cfg_major, "aac"); + aac_cfg_major = -1; + } + return 0; +} + +/** + * aac_queuecommand - queue a SCSI command + * @scsi_cmnd_ptr: SCSI command to queue + * @CompletionRoutine: Function to call on command completion + * + * Queues a command for execution by the associated Host Adapter. + */ + +static int aac_queuecommand(Scsi_Cmnd *scsi_cmnd_ptr, void (*CompletionRoutine)(Scsi_Cmnd *)) +{ + int ret; + + scsi_cmnd_ptr->scsi_done = CompletionRoutine; + /* + * aac_scsi_cmd() handles command processing, setting the + * result code and calling completion routine. + */ + if((ret = aac_scsi_cmd(scsi_cmnd_ptr)) != 0) + dprintk((KERN_DEBUG "aac_scsi_cmd failed.\n")); + return ret; +} + + +/** + * aac_done - Callback function for a non-queued command. + * @scsi_cmnd_ptr: SCSI command block to wait for + * + * Sets single_command done to 1. This lets aac_command complete. + * This function is obsolete. + * + * Bugs: Doesn't actually work properly with multiple controllers + */ + +static void aac_done(Scsi_Cmnd * scsi_cmnd_ptr) +{ + single_command_done = 1; +} + +/** + * aac_command - synchronous SCSI command execution + * @scsi_cmnd_ptr: SCSI command to issue + * + * Accepts a single command for execution by the associated Host Adapter. + * Waits until it completes an then returns an int where: + * Byte 0 = SCSI status code + * Byte 1 = SCSI 1 byte message + * Byte 2 = host error return + * Byte 3 = mid level error return + */ + +static int aac_command(Scsi_Cmnd *scsi_cmnd_ptr ) +{ + scsi_cmnd_ptr->scsi_done = aac_done; + dprintk((KERN_DEBUG "aac_command.\n")); + + /* + * aac_scsi_cmd() handles command processing, setting the + * result code and calling completion routine. + */ + single_command_done = 0; + aac_scsi_cmd(scsi_cmnd_ptr); + while(!single_command_done) + rmb(); + return scsi_cmnd_ptr->result; +} + +/** + * aac_abortcommand - Abort command if possible. + * @scsi_cmnd_ptr: SCSI command block to abort + * + * Called when the midlayer wishes to abort a command. We don't support + * this facility, and our firmware looks after life for us. We just + * report the command as busy. + */ + +static int aac_abortcommand(Scsi_Cmnd *scsi_cmnd_ptr ) +{ + return SCSI_ABORT_BUSY; +} + +/** + * aac_resetcommand - Reset command handling + * @scsi_cmnd_ptr: SCSI command block causing the reset + * @reset_flags: Reset hints from the midlayer code + * + * Issue a reset of a SCSI command. We are ourselves not truely a SCSI + * controller and our firmware will do the work for us anyway. Thus this + * is a no-op. We just return SCSI_RESET_PUNT + */ + +static int aac_resetcommand(struct scsi_cmnd *scsi_cmnd_ptr, unsigned int reset_flags ) +{ + return SCSI_RESET_PUNT; +} + +/** + * aac_driverinfo - Returns the host adapter name + * @host_ptr: Scsi host to report on + * + * Returns a static string describing the device in question + */ + +const char *aac_driverinfo(struct Scsi_Host *host_ptr) +{ + struct aac_dev *dev = (struct aac_dev *)host_ptr->hostdata; + return aac_drivers[dev->cardtype].name; +} + +/** + * aac_biosparm - return BIOS parameters for disk + * @disk: SCSI disk object to process + * @device: kdev_t of the disk in question + * @geom: geometry block to fill in + * + * Return the Heads/Sectors/Cylinders BIOS Disk Parameters for Disk. + * The default disk geometry is 64 heads, 32 sectors, and the appropriate + * number of cylinders so as not to exceed drive capacity. In order for + * disks equal to or larger than 1 GB to be addressable by the BIOS + * without exceeding the BIOS limitation of 1024 cylinders, Extended + * Translation should be enabled. With Extended Translation enabled, + * drives between 1 GB inclusive and 2 GB exclusive are given a disk + * geometry of 128 heads and 32 sectors, and drives above 2 GB inclusive + * are given a disk geometry of 255 heads and 63 sectors. However, if + * the BIOS detects that the Extended Translation setting does not match + * the geometry in the partition table, then the translation inferred + * from the partition table will be used by the BIOS, and a warning may + * be displayed. + */ + +static int aac_biosparm(Scsi_Disk *disk, kdev_t dev, int *geom) +{ + struct diskparm *param = (struct diskparm *)geom; + struct buffer_head * buf; + + dprintk((KERN_DEBUG "aac_biosparm.\n")); + + /* + * Assuming extended translation is enabled - #REVISIT# + */ + if( disk->capacity >= 2 * 1024 * 1024 ) /* 1 GB in 512 byte sectors */ + { + if( disk->capacity >= 4 * 1024 * 1024 ) /* 2 GB in 512 byte sectors */ + { + param->heads = 255; + param->sectors = 63; + } + else + { + param->heads = 128; + param->sectors = 32; + } + } + else + { + param->heads = 64; + param->sectors = 32; + } + + param->cylinders = disk->capacity/(param->heads * param->sectors); + + /* + * Read the first 1024 bytes from the disk device + */ + + buf = bread(MKDEV(MAJOR(dev), MINOR(dev)&~0xf), 0, block_size(dev)); + if(buf == NULL) + return 0; + /* + * If the boot sector partition table is valid, search for a partition + * table entry whose end_head matches one of the standard geometry + * translations ( 64/32, 128/32, 255/63 ). + */ + + if(*(unsigned short *)(buf->b_data + 0x1fe) == cpu_to_le16(0xaa55)) + { + struct partition *first = (struct partition * )(buf->b_data + 0x1be); + struct partition *entry = first; + int saved_cylinders = param->cylinders; + int num; + unsigned char end_head, end_sec; + + for(num = 0; num < 4; num++) + { + end_head = entry->end_head; + end_sec = entry->end_sector & 0x3f; + + if(end_head == 63) + { + param->heads = 64; + param->sectors = 32; + break; + } + else if(end_head == 127) + { + param->heads = 128; + param->sectors = 32; + break; + } + else if(end_head == 254) + { + param->heads = 255; + param->sectors = 63; + break; + } + entry++; + } + + if(num == 4) + { + end_head = first->end_head; + end_sec = first->end_sector & 0x3f; + } + + param->cylinders = disk->capacity / (param->heads * param->sectors); + + if(num < 4 && end_sec == param->sectors) + { + if(param->cylinders != saved_cylinders) + dprintk((KERN_DEBUG "Adopting geometry: heads=%d, sectors=%d from partition table %d.\n", + param->heads, param->sectors, num)); + } + else if(end_head > 0 || end_sec > 0) + { + dprintk((KERN_DEBUG "Strange geometry: heads=%d, sectors=%d in partition table %d.\n", + end_head + 1, end_sec, num)); + dprintk((KERN_DEBUG "Using geometry: heads=%d, sectors=%d.\n", + param->heads, param->sectors)); + } + } + brelse(buf); + return 0; +} + +/** + * aac_queuedepth - compute queue depths + * @host: SCSI host in question + * @dev: SCSI device we are considering + * + * Selects queue depths for each target device based on the host adapter's + * total capacity and the queue depth supported by the target device. + * A queue depth of one automatically disables tagged queueing. + */ + +static void aac_queuedepth(struct Scsi_Host * host, Scsi_Device * dev ) +{ + Scsi_Device * dptr; + + dprintk((KERN_DEBUG "aac_queuedepth.\n")); + dprintk((KERN_DEBUG "Device # Q Depth Online\n")); + dprintk((KERN_DEBUG "---------------------------\n")); + for(dptr = dev; dptr != NULL; dptr = dptr->next) + { + if(dptr->host == host) + { + dptr->queue_depth = 10; + dprintk((KERN_DEBUG " %2d %d %d\n", + dptr->id, dptr->queue_depth, dptr->online)); + } + } +} + +/*------------------------------------------------------------------------------ + aac_ioctl() + + Handle SCSI ioctls + *----------------------------------------------------------------------------*/ +static int aac_ioctl(Scsi_Device * scsi_dev_ptr, int cmd, void * arg) +/*----------------------------------------------------------------------------*/ +{ + struct aac_dev *dev; + dprintk((KERN_DEBUG "aac_ioctl.\n")); + dev = (struct aac_dev *)scsi_dev_ptr->host->hostdata; + return aac_do_ioctl(dev, cmd, arg); +} + +/** + * aac_cfg_open - open a configuration file + * @inode: inode being opened + * @file: file handle attached + * + * Called when the configuration device is opened. Does the needed + * set up on the handle and then returns + * + * Bugs: This needs extending to check a given adapter is present + * so we can support hot plugging, and to ref count adapters. + */ + +static int aac_cfg_open(struct inode * inode, struct file * file ) +{ + unsigned minor_number = MINOR(inode->i_rdev); + if(minor_number >= aac_count) + return -ENODEV; + return 0; +} + +/** + * aac_cfg_release - close down an AAC config device + * @inode: inode of configuration file + * @file: file handle of configuration file + * + * Called when the last close of the configuration file handle + * is performed. + */ + +static int aac_cfg_release(struct inode * inode, struct file * file ) +{ + return 0; +} + +/** + * aac_cfg_ioctl - AAC configuration request + * @inode: inode of device + * @file: file handle + * @cmd: ioctl command code + * @arg: argument + * + * Handles a configuration ioctl. Currently this involves wrapping it + * up and feeding it into the nasty windowsalike glue layer. + * + * Bugs: Needs locking against parallel ioctls lower down + * Bugs: Needs to handle hot plugging + */ + +static int aac_cfg_ioctl(struct inode * inode, struct file * file, unsigned int cmd, unsigned long arg ) +{ + struct aac_dev *dev = aac_devices[MINOR(inode->i_rdev)]; + return aac_do_ioctl(dev, cmd, (void *)arg); +} + +/* + * To use the low level SCSI driver support using the linux kernel loadable + * module interface we should initialize the global variable driver_interface + * (datatype Scsi_Host_Template) and then include the file scsi_module.c. + */ + +static Scsi_Host_Template driver_template = { + module: THIS_MODULE, + name: "AAC", + proc_info: aac_procinfo, + detect: aac_detect, + release: aac_release, + info: aac_driverinfo, + ioctl: aac_ioctl, + command: aac_command, + queuecommand: aac_queuecommand, + abort: aac_abortcommand, + reset: aac_resetcommand, + bios_param: aac_biosparm, + can_queue: AAC_NUM_IO_FIB, + this_id: 16, + sg_tablesize: 16, + max_sectors: 128, + cmd_per_lun: 1, + eh_abort_handler: aac_abortcommand, + use_clustering: ENABLE_CLUSTERING, +}; + +#include "scsi_module.c" + +/** + * aac_procinfo - Implement /proc/scsi/<drivername>/<n> + * @proc_buffer: memory buffer for I/O + * @start_ptr: pointer to first valid data + * @offset: offset into file + * @bytes_available: space left + * @host_no: scsi host ident + * @write: direction of I/O + * + * Used to export driver statistics and other infos to the world outside + * the kernel using the proc file system. Also provides an interface to + * feed the driver with information. + * + * For reads + * - if offset > 0 return 0 + * - if offset == 0 write data to proc_buffer and set the start_ptr to + * beginning of proc_buffer, return the number of characters written. + * For writes + * - writes currently not supported, return 0 + * + * Bugs: Only offset zero is handled + */ + +static int aac_procinfo(char *proc_buffer, char **start_ptr,off_t offset, + int bytes_available, int host_no, int write) +{ + if(write || offset > 0) + return 0; + *start_ptr = proc_buffer; + return sprintf(proc_buffer, "%s %d\n", "Raid Controller, scsi hba number", host_no); +} + +EXPORT_NO_SYMBOLS; diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/scsi/aacraid/rx.c linux-2.5/drivers/scsi/aacraid/rx.c --- linux-2.5.1/drivers/scsi/aacraid/rx.c Thu Jan 1 00:00:00 1970 +++ linux-2.5/drivers/scsi/aacraid/rx.c Thu Dec 13 16:32:36 2001 @@ -0,0 +1,413 @@ +/* + * Adaptec AAC series RAID controller driver + * (c) Copyright 2001 Red Hat Inc. <alan@redhat.com> + * + * based on the old aacraid driver that is.. + * Adaptec aacraid device driver for Linux. + * + * Copyright (c) 2000 Adaptec, Inc. (aacraid@adaptec.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, 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; see the file COPYING. If not, write to + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * + * Module Name: + * rx.c + * + * Abstract: Hardware miniport for Drawbridge specific hardware functions. + * + */ + +#include <linux/config.h> +#include <linux/kernel.h> +#include <linux/init.h> +#include <linux/types.h> +#include <linux/sched.h> +#include <linux/pci.h> +#include <linux/spinlock.h> +#include <linux/slab.h> +#include <linux/blk.h> +#include <linux/delay.h> +#include <linux/completion.h> +#include <asm/semaphore.h> +#include "scsi.h" +#include "hosts.h" + +#include "aacraid.h" + +static void aac_rx_intr(int irq, void *dev_id, struct pt_regs *regs) +{ + struct aac_dev *dev = dev_id; + unsigned long bellbits; + u8 intstat, mask; + + intstat = rx_readb(dev, MUnit.OISR); + /* + * Read mask and invert because drawbridge is reversed. + * This allows us to only service interrupts that have + * been enabled. + */ + mask = ~(rx_readb(dev, MUnit.OIMR)); + /* Check to see if this is our interrupt. If it isn't just return */ + if (intstat & mask) + { + bellbits = rx_readl(dev, OutboundDoorbellReg); + if (bellbits & DoorBellPrintfReady) + { + aac_printf(dev, le32_to_cpu(rx_readl (dev, IndexRegs.Mailbox[5]))); + rx_writel(dev, MUnit.ODR,DoorBellPrintfReady); + rx_writel(dev, InboundDoorbellReg,DoorBellPrintfDone); + } + else if (bellbits & DoorBellAdapterNormCmdReady) + { + aac_command_normal(&dev->queues->queue[HostNormCmdQueue]); + rx_writel(dev, MUnit.ODR, DoorBellAdapterNormCmdReady); + } + else if (bellbits & DoorBellAdapterNormRespReady) + { + aac_response_normal(&dev->queues->queue[HostNormRespQueue]); + rx_writel(dev, MUnit.ODR,DoorBellAdapterNormRespReady); + } + else if (bellbits & DoorBellAdapterNormCmdNotFull) + { + rx_writel(dev, MUnit.ODR, DoorBellAdapterNormCmdNotFull); + } + else if (bellbits & DoorBellAdapterNormRespNotFull) + { + rx_writel(dev, MUnit.ODR, DoorBellAdapterNormRespNotFull); + } + } +} + +/** + * aac_rx_enable_interrupt - Enable event reporting + * @dev: Adapter + * @event: Event to enable + * + * Enable event reporting from the i960 for a given event. + */ + +static void aac_rx_enable_interrupt(struct aac_dev * dev, u32 event) +{ + switch (event) { + + case HostNormCmdQue: + dev->irq_mask &= ~(OUTBOUNDDOORBELL_1); + break; + + case HostNormRespQue: + dev->irq_mask &= ~(OUTBOUNDDOORBELL_2); + break; + + case AdapNormCmdNotFull: + dev->irq_mask &= ~(OUTBOUNDDOORBELL_3); + break; + + case AdapNormRespNotFull: + dev->irq_mask &= ~(OUTBOUNDDOORBELL_4); + break; + } +} + +/** + * aac_rx_disable_interrupt - Disable event reporting + * @dev: Adapter + * @event: Event to enable + * + * Disable event reporting from the i960 for a given event. + */ + +static void aac_rx_disable_interrupt(struct aac_dev *dev, u32 event) +{ + switch (event) { + + case HostNormCmdQue: + dev->irq_mask |= (OUTBOUNDDOORBELL_1); + break; + + case HostNormRespQue: + dev->irq_mask |= (OUTBOUNDDOORBELL_2); + break; + + case AdapNormCmdNotFull: + dev->irq_mask |= (OUTBOUNDDOORBELL_3); + break; + + case AdapNormRespNotFull: + dev->irq_mask |= (OUTBOUNDDOORBELL_4); + break; + } +} + +/** + * rx_sync_cmd - send a command and wait + * @dev: Adapter + * @command: Command to execute + * @p1: first parameter + * @ret: adapter status + * + * This routine will send a synchronous comamnd to the adapter and wait + * for its completion. + */ + +static int rx_sync_cmd(struct aac_dev *dev, unsigned long command, unsigned long p1, unsigned long *status) +{ + unsigned long start; + int ok; + /* + * Write the command into Mailbox 0 + */ + rx_writel(dev, InboundMailbox0, cpu_to_le32(command)); + /* + * Write the parameters into Mailboxes 1 - 4 + */ + rx_writel(dev, InboundMailbox1, cpu_to_le32(p1)); + rx_writel(dev, InboundMailbox2, 0); + rx_writel(dev, InboundMailbox3, 0); + rx_writel(dev, InboundMailbox4, 0); + /* + * Clear the synch command doorbell to start on a clean slate. + */ + rx_writel(dev, OutboundDoorbellReg, OUTBOUNDDOORBELL_0); + /* + * Disable doorbell interrupts + */ + rx_writeb(dev, MUnit.OIMR, rx_readb(dev, MUnit.OIMR) | 0x04); + /* + * Force the completion of the mask register write before issuing + * the interrupt. + */ + rx_readb (dev, MUnit.OIMR); + /* + * Signal that there is a new synch command + */ + rx_writel(dev, InboundDoorbellReg, INBOUNDDOORBELL_0); + + ok = 0; + start = jiffies; + + /* + * Wait up to 30 seconds + */ + while (time_before(start+30*HZ, jiffies)) + { + udelay(5); /* Delay 5 microseconds to let Mon960 get info. */ + /* + * Mon960 will set doorbell0 bit when it has completed the command. + */ + if (rx_readl(dev, OutboundDoorbellReg) & OUTBOUNDDOORBELL_0) { + /* + * Clear the doorbell. + */ + rx_writel(dev, OutboundDoorbellReg, OUTBOUNDDOORBELL_0); + ok = 1; + break; + } + /* + * Yield the processor in case we are slow + */ + set_current_state(TASK_UNINTERRUPTIBLE); + schedule_timeout(1); + } + if (ok != 1) { + /* + * Restore interrupt mask even though we timed out + */ + rx_writeb(dev, MUnit.OIMR, rx_readl(dev, MUnit.OIMR) & 0xfb); + return -ETIMEDOUT; + } + /* + * Pull the synch status from Mailbox 0. + */ + *status = le32_to_cpu(rx_readl(dev, IndexRegs.Mailbox[0])); + /* + * Clear the synch command doorbell. + */ + rx_writel(dev, OutboundDoorbellReg, OUTBOUNDDOORBELL_0); + /* + * Restore interrupt mask + */ + rx_writeb(dev, MUnit.OIMR, rx_readl(dev, MUnit.OIMR) & 0xfb); + return 0; + +} + +/** + * aac_rx_interrupt_adapter - interrupt adapter + * @dev: Adapter + * + * Send an interrupt to the i960 and breakpoint it. + */ + +static void aac_rx_interrupt_adapter(struct aac_dev *dev) +{ + unsigned long ret; + rx_sync_cmd(dev, BREAKPOINT_REQUEST, 0, &ret); +} + +/** + * aac_rx_notify_adapter - send an event to the adapter + * @dev: Adapter + * @event: Event to send + * + * Notify the i960 that something it probably cares about has + * happened. + */ + +static void aac_rx_notify_adapter(struct aac_dev *dev, u32 event) +{ + switch (event) { + + case AdapNormCmdQue: + rx_writel(dev, MUnit.IDR,INBOUNDDOORBELL_1); + break; + case HostNormRespNotFull: + rx_writel(dev, MUnit.IDR,INBOUNDDOORBELL_4); + break; + case AdapNormRespQue: + rx_writel(dev, MUnit.IDR,INBOUNDDOORBELL_2); + break; + case HostNormCmdNotFull: + rx_writel(dev, MUnit.IDR,INBOUNDDOORBELL_3); + break; + case HostShutdown: +// rx_sync_cmd(dev, HOST_CRASHING, 0, 0, 0, 0, &ret); + break; + case FastIo: + rx_writel(dev, MUnit.IDR,INBOUNDDOORBELL_6); + break; + case AdapPrintfDone: + rx_writel(dev, MUnit.IDR,INBOUNDDOORBELL_5); + break; + default: + BUG(); + break; + } +} + +/** + * aac_rx_start_adapter - activate adapter + * @dev: Adapter + * + * Start up processing on an i960 based AAC adapter + */ + +static void aac_rx_start_adapter(struct aac_dev *dev) +{ + unsigned long status; + struct aac_init *init; + + init = dev->init; + init->HostElapsedSeconds = cpu_to_le32(jiffies/HZ); + /* + * Tell the adapter we are back and up and running so it will scan + * its command queues and enable our interrupts + */ + dev->irq_mask = (DoorBellPrintfReady | OUTBOUNDDOORBELL_1 | OUTBOUNDDOORBELL_2 | OUTBOUNDDOORBELL_3 | OUTBOUNDDOORBELL_4); + /* + * First clear out all interrupts. Then enable the one's that we + * can handle. + */ + rx_writeb(dev, MUnit.OIMR, 0xff); + rx_writel(dev, MUnit.ODR, 0xffffffff); +// rx_writeb(dev, MUnit.OIMR, ~(u8)OUTBOUND_DOORBELL_INTERRUPT_MASK); + rx_writeb(dev, MUnit.OIMR, 0xfb); + + rx_sync_cmd(dev, INIT_STRUCT_BASE_ADDRESS, (unsigned long) dev->init_pa, &status); +} + +/** + * aac_rx_init - initialize an i960 based AAC card + * @dev: device to configure + * @devnum: adapter number + * + * Allocate and set up resources for the i960 based AAC variants. The + * device_interface in the commregion will be allocated and linked + * to the comm region. + */ + +int aac_rx_init(struct aac_dev *dev, unsigned long num) +{ + unsigned long start; + unsigned long status; + int instance; + const char * name; + + dev->devnum = num; + + instance = dev->id; + name = dev->name; + + /* + * Map in the registers from the adapter. + */ + if((dev->regs.rx = (struct rx_registers *)ioremap((unsigned long)dev->scsi_host_ptr->base, 8192))==NULL) + { + printk(KERN_WARNING "aacraid: unable to map i960.\n" ); + return -1; + } + /* + * Check to see if the board failed any self tests. + */ + if (rx_readl(dev, IndexRegs.Mailbox[7]) & SELF_TEST_FAILED) { + printk(KERN_ERR "%s%d: adapter self-test failed.\n", dev->name, instance); + return -1; + } + /* + * Check to see if the board panic'd while booting. + */ + if (rx_readl(dev, IndexRegs.Mailbox[7]) & KERNEL_PANIC) { + printk(KERN_ERR "%s%d: adapter kernel panic'd.\n", dev->name, instance); + return -1; + } + start = jiffies; + /* + * Wait for the adapter to be up and running. Wait up to 30 seconds. + */ + while (!(rx_readl(dev, IndexRegs.Mailbox[7]) & KERNEL_UP_AND_RUNNING)) + { + if(time_after(jiffies, start+30*HZ)) + { + status = rx_readl(dev, IndexRegs.Mailbox[7]) >> 16; + printk(KERN_ERR "%s%d: adapter kernel failed to start, init status = %ld.\n", dev->name, instance, status); + return -1; + } + set_current_state(TASK_UNINTERRUPTIBLE); + schedule_timeout(1); + } + if (request_irq(dev->scsi_host_ptr->irq, aac_rx_intr, SA_SHIRQ|SA_INTERRUPT, "aacraid", (void *)dev)<0) + { + printk(KERN_ERR "%s%d: Interrupt unavailable.\n", name, instance); + return -1; + } + /* + * Fill in the function dispatch table. + */ + dev->a_ops.adapter_interrupt = aac_rx_interrupt_adapter; + dev->a_ops.adapter_enable_int = aac_rx_enable_interrupt; + dev->a_ops.adapter_disable_int = aac_rx_disable_interrupt; + dev->a_ops.adapter_notify = aac_rx_notify_adapter; + + if (aac_init_adapter(dev) == NULL) + return -1; + /* + * Start any kernel threads needed + */ + dev->thread_pid = kernel_thread((int (*)(void *))aac_command_thread, dev, 0); + /* + * Tell the adapter that all is configured, and it can start + * accepting requests + */ + aac_rx_start_adapter(dev); + return 0; +} diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/scsi/aacraid/sap1sup.c linux-2.5/drivers/scsi/aacraid/sap1sup.c --- linux-2.5.1/drivers/scsi/aacraid/sap1sup.c Thu Jan 1 00:00:00 1970 +++ linux-2.5/drivers/scsi/aacraid/sap1sup.c Thu Dec 13 16:32:36 2001 @@ -0,0 +1,394 @@ +/* + * Adaptec AAC series RAID controller driver + * (c) Copyright 2001 Red Hat Inc. <alan@redhat.com> + * + * based on the old aacraid driver that is.. + * Adaptec aacraid device driver for Linux. + * + * Copyright (c) 2000 Adaptec, Inc. (aacraid@adaptec.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, 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; see the file COPYING. If not, write to + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * + * Module Name: + * sap1sup.c + * + * Abstract: Drawbridge specific support functions + * + */ + +#include <linux/config.h> +#include <linux/kernel.h> +#include <linux/init.h> +#include <linux/types.h> +#include <linux/sched.h> +#include <linux/pci.h> +#include <linux/spinlock.h> +#include <linux/slab.h> +#include <linux/blk.h> +#include <linux/delay.h> +#include <linux/completion.h> +#include <asm/semaphore.h> +#include "scsi.h" +#include "hosts.h" + +#include "aacraid.h" + +static void aac_sa_intr(int irq, void *dev_id, struct pt_regs *regs) +{ + struct aac_dev *dev = dev_id; + unsigned short intstat, mask; + + intstat = sa_readw(dev, DoorbellReg_p); + /* + * Read mask and invert because drawbridge is reversed. + * This allows us to only service interrupts that have been enabled. + */ + mask = ~(sa_readw(dev, SaDbCSR.PRISETIRQMASK)); + + /* Check to see if this is our interrupt. If it isn't just return */ + + if (intstat & mask) { + if (intstat & PrintfReady) { + aac_printf(dev, le32_to_cpu(sa_readl(dev, Mailbox5))); + sa_writew(dev, DoorbellClrReg_p, PrintfReady); /* clear PrintfReady */ + sa_writew(dev, DoorbellReg_s, PrintfDone); + } else if (intstat & DOORBELL_1) { // dev -> Host Normal Command Ready + aac_command_normal(&dev->queues->queue[HostNormCmdQueue]); + sa_writew(dev, DoorbellClrReg_p, DOORBELL_1); + } else if (intstat & DOORBELL_2) { // dev -> Host Normal Response Ready + aac_response_normal(&dev->queues->queue[HostNormRespQueue]); + sa_writew(dev, DoorbellClrReg_p, DOORBELL_2); + } else if (intstat & DOORBELL_3) { // dev -> Host Normal Command Not Full + sa_writew(dev, DoorbellClrReg_p, DOORBELL_3); + } else if (intstat & DOORBELL_4) { // dev -> Host Normal Response Not Full + sa_writew(dev, DoorbellClrReg_p, DOORBELL_4); + } + } +} + +/** + * aac_sa_enable_interrupt - enable an interrupt event + * @dev: Which adapter to enable. + * @event: Which adapter event. + * + * This routine will enable the corresponding adapter event to cause an interrupt on + * the host. + */ + +void aac_sa_enable_interrupt(struct aac_dev *dev, u32 event) +{ + switch (event) { + + case HostNormCmdQue: + sa_writew(dev, SaDbCSR.PRICLEARIRQMASK, DOORBELL_1); + break; + + case HostNormRespQue: + sa_writew(dev, SaDbCSR.PRICLEARIRQMASK, DOORBELL_2); + break; + + case AdapNormCmdNotFull: + sa_writew(dev, SaDbCSR.PRICLEARIRQMASK, DOORBELL_3); + break; + + case AdapNormRespNotFull: + sa_writew(dev, SaDbCSR.PRICLEARIRQMASK, DOORBELL_4); + break; + } +} + +/** + * aac_sa_disable_interrupt - disable an interrupt event + * @dev: Which adapter to enable. + * @event: Which adapter event. + * + * This routine will enable the corresponding adapter event to cause an interrupt on + * the host. + */ + +void aac_sa_disable_interrupt (struct aac_dev *dev, u32 event) +{ + switch (event) { + + case HostNormCmdQue: + sa_writew(dev, SaDbCSR.PRISETIRQMASK, DOORBELL_1); + break; + + case HostNormRespQue: + sa_writew(dev, SaDbCSR.PRISETIRQMASK, DOORBELL_2); + break; + + case AdapNormCmdNotFull: + sa_writew(dev, SaDbCSR.PRISETIRQMASK, DOORBELL_3); + break; + + case AdapNormRespNotFull: + sa_writew(dev, SaDbCSR.PRISETIRQMASK, DOORBELL_4); + break; + } +} + +/** + * aac_sa_notify_adapter - handle adapter notification + * @dev: Adapter that notification is for + * @event: Event to notidy + * + * Notify the adapter of an event + */ + +void aac_sa_notify_adapter(struct aac_dev *dev, u32 event) +{ + switch (event) { + + case AdapNormCmdQue: + sa_writew(dev, DoorbellReg_s,DOORBELL_1); + break; + case HostNormRespNotFull: + sa_writew(dev, DoorbellReg_s,DOORBELL_4); + break; + case AdapNormRespQue: + sa_writew(dev, DoorbellReg_s,DOORBELL_2); + break; + case HostNormCmdNotFull: + sa_writew(dev, DoorbellReg_s,DOORBELL_3); + break; + case HostShutdown: + //sa_sync_cmd(dev, HOST_CRASHING, 0, &ret); + break; + case FastIo: + sa_writew(dev, DoorbellReg_s,DOORBELL_6); + break; + case AdapPrintfDone: + sa_writew(dev, DoorbellReg_s,DOORBELL_5); + break; + default: + BUG(); + break; + } +} + + +/** + * sa_sync_cmd - send a command and wait + * @dev: Adapter + * @command: Command to execute + * @p1: first parameter + * @ret: adapter status + * + * This routine will send a synchronous comamnd to the adapter and wait + * for its completion. + */ + +static int sa_sync_cmd(struct aac_dev *dev, unsigned long command, unsigned long p1, unsigned long *ret) +{ + unsigned long start; + int ok; + /* + * Write the Command into Mailbox 0 + */ + sa_writel(dev, Mailbox0, cpu_to_le32(command)); + /* + * Write the parameters into Mailboxes 1 - 4 + */ + sa_writel(dev, Mailbox1, cpu_to_le32(p1)); + sa_writel(dev, Mailbox2, 0); + sa_writel(dev, Mailbox3, 0); + sa_writel(dev, Mailbox4, 0); + /* + * Clear the synch command doorbell to start on a clean slate. + */ + sa_writew(dev, DoorbellClrReg_p, DOORBELL_0); + /* + * Signal that there is a new synch command + */ + sa_writew(dev, DoorbellReg_s, DOORBELL_0); + + ok = 0; + start = jiffies; + + while(time_before(jiffies, start+30*HZ)) + { + /* + * Delay 5uS so that the monitor gets access + */ + udelay(5); + /* + * Mon110 will set doorbell0 bit when it has + * completed the command. + */ + if(sa_readw(dev, DoorbellReg_p) & DOORBELL_0) { + ok = 1; + break; + } + set_current_state(TASK_UNINTERRUPTIBLE); + schedule_timeout(1); + } + + if (ok != 1) + return -ETIMEDOUT; + /* + * Clear the synch command doorbell. + */ + sa_writew(dev, DoorbellClrReg_p, DOORBELL_0); + /* + * Pull the synch status from Mailbox 0. + */ + *ret = le32_to_cpu(sa_readl(dev, Mailbox0)); + return 0; +} + +/** + * aac_sa_interrupt_adapter - interrupt an adapter + * @dev: Which adapter to enable. + * + * Breakpoint an adapter. + */ + +static void aac_sa_interrupt_adapter (struct aac_dev *dev) +{ + unsigned long ret; + sa_sync_cmd(dev, BREAKPOINT_REQUEST, 0, &ret); +} + +/** + * aac_sa_start_adapter - activate adapter + * @dev: Adapter + * + * Start up processing on an ARM based AAC adapter + */ + +static void aac_sa_start_adapter(struct aac_dev *dev) +{ + unsigned long ret; + struct aac_init *init; + /* + * Fill in the remaining pieces of the init. + */ + init = dev->init; + init->HostElapsedSeconds = cpu_to_le32(jiffies/HZ); + + dprintk(("INIT\n")); + /* + * Tell the adapter we are back and up and running so it will scan its command + * queues and enable our interrupts + */ + dev->irq_mask = (PrintfReady | DOORBELL_1 | DOORBELL_2 | DOORBELL_3 | DOORBELL_4); + /* + * First clear out all interrupts. Then enable the one's that + * we can handle. + */ + dprintk(("MASK\n")); + sa_writew(dev, SaDbCSR.PRISETIRQMASK, cpu_to_le16(0xffff)); + sa_writew(dev, SaDbCSR.PRICLEARIRQMASK, (PrintfReady | DOORBELL_1 | DOORBELL_2 | DOORBELL_3 | DOORBELL_4)); + dprintk(("SYNCCMD\n")); + sa_sync_cmd(dev, INIT_STRUCT_BASE_ADDRESS, (unsigned long) dev->init_pa, &ret); +} + +/** + * aac_sa_init - initialize an ARM based AAC card + * @dev: device to configure + * @devnum: adapter number + * + * Allocate and set up resources for the ARM based AAC variants. The + * device_interface in the commregion will be allocated and linked + * to the comm region. + */ + +int aac_sa_init(struct aac_dev *dev, unsigned long devnum) +{ + unsigned long start; + unsigned long status; + int instance; + const char *name; + + dev->devnum = devnum; + + dprintk(("PREINST\n")); + instance = dev->id; + name = dev->name; + + /* + * Map in the registers from the adapter. + */ + dprintk(("PREMAP\n")); + + if((dev->regs.sa = (struct sa_registers *)ioremap((unsigned long)dev->scsi_host_ptr->base, 8192))==NULL) + { + printk(KERN_WARNING "aacraid: unable to map ARM.\n" ); + return -1; + } + /* + * Check to see if the board failed any self tests. + */ + if (sa_readl(dev, Mailbox7) & SELF_TEST_FAILED) { + printk(KERN_WARNING "%s%d: adapter self-test failed.\n", name, instance); + return -1; + } + /* + * Check to see if the board panic'd while booting. + */ + if (sa_readl(dev, Mailbox7) & KERNEL_PANIC) { + printk(KERN_WARNING "%s%d: adapter kernel panic'd.\n", name, instance); + return -1; + } + start = jiffies; + /* + * Wait for the adapter to be up and running. Wait up to 3 minutes. + */ + while (!(sa_readl(dev, Mailbox7) & KERNEL_UP_AND_RUNNING)) { + if (time_after(start+180*HZ, jiffies)) { + status = sa_readl(dev, Mailbox7) >> 16; + printk(KERN_WARNING "%s%d: adapter kernel failed to start, init status = %d.\n", name, instance, le32_to_cpu(status)); + return -1; + } + set_current_state(TASK_UNINTERRUPTIBLE); + schedule_timeout(1); + } + + dprintk(("ATIRQ\n")); + if (request_irq(dev->scsi_host_ptr->irq, aac_sa_intr, SA_SHIRQ|SA_INTERRUPT, "aacraid", (void *)dev ) < 0) { + printk(KERN_WARNING "%s%d: Interrupt unavailable.\n", name, instance); + return -1; + } + + /* + * Fill in the function dispatch table. + */ + + dev->a_ops.adapter_interrupt = aac_sa_interrupt_adapter; + dev->a_ops.adapter_enable_int = aac_sa_enable_interrupt; + dev->a_ops.adapter_disable_int = aac_sa_disable_interrupt; + dev->a_ops.adapter_notify = aac_sa_notify_adapter; + + dprintk(("FUNCDONE\n")); + + if(aac_init_adapter(dev) == NULL) + return -1; + + dprintk(("NEWADAPTDONE\n")); + /* + * Start any kernel threads needed + */ + dev->thread_pid = kernel_thread((int (*)(void *))aac_command_thread, dev, 0); + /* + * Tell the adapter that all is configure, and it can start + * accepting requests + */ + dprintk(("STARTING\n")); + aac_sa_start_adapter(dev); + dprintk(("STARTED\n")); + return 0; +} + diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/scsi/aha1542.c linux-2.5/drivers/scsi/aha1542.c --- linux-2.5.1/drivers/scsi/aha1542.c Fri Oct 12 22:35:53 2001 +++ linux-2.5/drivers/scsi/aha1542.c Sun Dec 30 20:01:41 2001 @@ -67,10 +67,10 @@ int nseg, int badseg) { - printk(KERN_CRIT "sgpnt[%d:%d] addr %p/0x%lx length %d\n", + printk(KERN_CRIT "sgpnt[%d:%d] page %p/0x%lx length %d\n", badseg, nseg, - sgpnt[badseg].address, - SCSI_PA(sgpnt[badseg].address), + page_address(sgpnt[badseg].page) + sgpnt[badseg].offset, + (unsigned long)page_to_bus(sgpnt[badseg].page) + sgpnt[badseg].offset, sgpnt[badseg].length); /* @@ -176,7 +176,7 @@ static void setup_mailboxes(int base_io, struct Scsi_Host *shpnt); static int aha1542_restart(struct Scsi_Host *shost); -static void aha1542_intr_handle(int irq, void *dev_id, struct pt_regs *regs); +static void aha1542_intr_handle(struct Scsi_Host *shost, void *dev_id, struct pt_regs *regs); static void do_aha1542_intr_handle(int irq, void *dev_id, struct pt_regs *regs); #define aha1542_intr_reset(base) outb(IRST, CONTROL(base)) @@ -419,30 +419,30 @@ static void do_aha1542_intr_handle(int irq, void *dev_id, struct pt_regs *regs) { unsigned long flags; + struct Scsi_Host *shost; + + shost = aha_host[irq - 9]; + if (!shost) + panic("Splunge!"); - spin_lock_irqsave(&io_request_lock, flags); - aha1542_intr_handle(irq, dev_id, regs); - spin_unlock_irqrestore(&io_request_lock, flags); + spin_lock_irqsave(&shost->host_lock, flags); + aha1542_intr_handle(shost, dev_id, regs); + spin_unlock_irqrestore(&shost->host_lock, flags); } /* A "high" level interrupt handler */ -static void aha1542_intr_handle(int irq, void *dev_id, struct pt_regs *regs) +static void aha1542_intr_handle(struct Scsi_Host *shost, void *dev_id, struct pt_regs *regs) { void (*my_done) (Scsi_Cmnd *) = NULL; int errstatus, mbi, mbo, mbistatus; int number_serviced; unsigned long flags; - struct Scsi_Host *shost; Scsi_Cmnd *SCtmp; int flag; int needs_restart; struct mailbox *mb; struct ccb *ccb; - shost = aha_host[irq - 9]; - if (!shost) - panic("Splunge!"); - mb = HOSTDATA(shost)->mb; ccb = HOSTDATA(shost)->ccb; @@ -542,7 +542,7 @@ } my_done = SCtmp->scsi_done; if (SCtmp->host_scribble) { - scsi_free(SCtmp->host_scribble, 512); + kfree(SCtmp->host_scribble); SCtmp->host_scribble = 0; } /* Fetch the sense data, and tuck it away, in the required slot. The @@ -703,18 +703,19 @@ #endif int i; ccb[mbo].op = 2; /* SCSI Initiator Command w/scatter-gather */ - SCpnt->host_scribble = (unsigned char *) scsi_malloc(512); + SCpnt->host_scribble = (unsigned char *) kmalloc(512, GFP_DMA); sgpnt = (struct scatterlist *) SCpnt->request_buffer; cptr = (struct chain *) SCpnt->host_scribble; if (cptr == NULL) panic("aha1542.c: unable to allocate DMA memory\n"); for (i = 0; i < SCpnt->use_sg; i++) { if (sgpnt[i].length == 0 || SCpnt->use_sg > 16 || - (((int) sgpnt[i].address) & 1) || (sgpnt[i].length & 1)) { + (((int) sgpnt[i].offset) & 1) || (sgpnt[i].length & 1)) { unsigned char *ptr; printk(KERN_CRIT "Bad segment list supplied to aha1542.c (%d, %d)\n", SCpnt->use_sg, i); for (i = 0; i < SCpnt->use_sg; i++) { - printk(KERN_CRIT "%d: %p %d\n", i, sgpnt[i].address, + printk(KERN_CRIT "%d: %p %d\n", i, + page_address(sgpnt[i].page) + sgpnt[i].offset, sgpnt[i].length); }; printk(KERN_CRIT "cptr %x: ", (unsigned int) cptr); @@ -723,8 +724,8 @@ printk("%02x ", ptr[i]); panic("Foooooooood fight!"); }; - any2scsi(cptr[i].dataptr, SCSI_PA(sgpnt[i].address)); - if (SCSI_PA(sgpnt[i].address + sgpnt[i].length - 1) > ISA_DMA_THRESHOLD) + any2scsi(cptr[i].dataptr, page_to_bus(sgpnt[i].page) + sgpnt[i].offset); + if (page_to_bus(sgpnt[i].page) + sgpnt[i].offset + sgpnt[i].length - 1 > ISA_DMA_THRESHOLD) BAD_SG_DMA(SCpnt, sgpnt, SCpnt->use_sg, i); any2scsi(cptr[i].datalen, sgpnt[i].length); }; @@ -1442,7 +1443,7 @@ Scsi_Cmnd *SCtmp; SCtmp = HOSTDATA(SCpnt->host)->SCint[i]; if (SCtmp->host_scribble) { - scsi_free(SCtmp->host_scribble, 512); + kfree(SCtmp->host_scribble); SCtmp->host_scribble = NULL; } HOSTDATA(SCpnt->host)->SCint[i] = NULL; @@ -1474,9 +1475,9 @@ * check for timeout, and if we are doing something like this * we are pretty desperate anyways. */ - spin_unlock_irq(&io_request_lock); + spin_unlock_irq(&SCpnt->host->host_lock); scsi_sleep(4 * HZ); - spin_lock_irq(&io_request_lock); + spin_lock_irq(&SCpnt->host->host_lock); WAIT(STATUS(SCpnt->host->io_port), STATMASK, INIT | IDLE, STST | DIAGF | INVDCMD | DF | CDF); @@ -1505,7 +1506,7 @@ continue; } if (SCtmp->host_scribble) { - scsi_free(SCtmp->host_scribble, 512); + kfree(SCtmp->host_scribble); SCtmp->host_scribble = NULL; } HOSTDATA(SCpnt->host)->SCint[i] = NULL; @@ -1538,9 +1539,9 @@ * check for timeout, and if we are doing something like this * we are pretty desperate anyways. */ - spin_unlock_irq(&io_request_lock); + spin_unlock_irq(&SCpnt->host->host_lock); scsi_sleep(4 * HZ); - spin_lock_irq(&io_request_lock); + spin_lock_irq(&SCpnt->host->host_lock); WAIT(STATUS(SCpnt->host->io_port), STATMASK, INIT | IDLE, STST | DIAGF | INVDCMD | DF | CDF); @@ -1574,7 +1575,7 @@ continue; } if (SCtmp->host_scribble) { - scsi_free(SCtmp->host_scribble, 512); + kfree(SCtmp->host_scribble); SCtmp->host_scribble = NULL; } HOSTDATA(SCpnt->host)->SCint[i] = NULL; @@ -1623,7 +1624,7 @@ if (mb[mbi].status) { printk(KERN_ERR "Lost interrupt discovered on irq %d - attempting to recover\n", SCpnt->host->irq); - aha1542_intr_handle(SCpnt->host->irq, NULL); + aha1542_intr_handle(SCpnt->host, NULL); return 0; } /* OK, no lost interrupt. Try looking to see how many pending commands @@ -1712,7 +1713,7 @@ SCtmp = HOSTDATA(SCpnt->host)->SCint[i]; SCtmp->result = DID_RESET << 16; if (SCtmp->host_scribble) { - scsi_free(SCtmp->host_scribble, 512); + kfree(SCtmp->host_scribble); SCtmp->host_scribble = NULL; } printk(KERN_WARNING "Sending DID_RESET for target %d\n", SCpnt->target); @@ -1758,7 +1759,7 @@ SCtmp = HOSTDATA(SCpnt->host)->SCint[i]; SCtmp->result = DID_RESET << 16; if (SCtmp->host_scribble) { - scsi_free(SCtmp->host_scribble, 512); + kfree(SCtmp->host_scribble); SCtmp->host_scribble = NULL; } printk(KERN_WARNING "Sending DID_RESET for target %d\n", SCpnt->target); diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/scsi/aic7xxx/aic7xxx_linux.c linux-2.5/drivers/scsi/aic7xxx/aic7xxx_linux.c --- linux-2.5.1/drivers/scsi/aic7xxx/aic7xxx_linux.c Tue Nov 27 17:23:27 2001 +++ linux-2.5/drivers/scsi/aic7xxx/aic7xxx_linux.c Thu Dec 27 22:10:28 2001 @@ -2727,15 +2727,15 @@ int ret; int extended; struct ahc_softc *ahc; - struct buffer_head *bh; + unsigned char *buf; ahc = *((struct ahc_softc **)disk->device->host->hostdata); - bh = bread(MKDEV(MAJOR(dev), MINOR(dev) & ~0xf), 0, block_size(dev)); + buf = scsi_bios_ptable(dev); - if (bh) { - ret = scsi_partsize(bh, disk->capacity, + if (buf) { + ret = scsi_partsize(buf, disk->capacity, &geom[2], &geom[0], &geom[1]); - brelse(bh); + kfree(buf); if (ret != -1) return (ret); } diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/scsi/aic7xxx_old.c linux-2.5/drivers/scsi/aic7xxx_old.c --- linux-2.5.1/drivers/scsi/aic7xxx_old.c Sun Dec 16 20:20:20 2001 +++ linux-2.5/drivers/scsi/aic7xxx_old.c Thu Dec 27 22:10:28 2001 @@ -11737,15 +11737,15 @@ { int heads, sectors, cylinders, ret; struct aic7xxx_host *p; - struct buffer_head *bh; + unsigned char *buf; p = (struct aic7xxx_host *) disk->device->host->hostdata; - bh = bread(MKDEV(MAJOR(dev), MINOR(dev)&~0xf), 0, block_size(dev)); + buf = scsi_bios_ptable(dev); - if ( bh ) + if ( buf ) { - ret = scsi_partsize(bh, disk->capacity, &geom[2], &geom[0], &geom[1]); - brelse(bh); + ret = scsi_partsize(buf, disk->capacity, &geom[2], &geom[0], &geom[1]); + kfree(buf); if ( ret != -1 ) return(ret); } diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/scsi/cpqfcTSworker.c linux-2.5/drivers/scsi/cpqfcTSworker.c --- linux-2.5.1/drivers/scsi/cpqfcTSworker.c Mon Dec 10 22:15:19 2001 +++ linux-2.5/drivers/scsi/cpqfcTSworker.c Sun Dec 30 20:01:41 2001 @@ -159,7 +159,6 @@ #ifdef PCI_KERNEL_TRACE PTACHYON fcChip = &cpqfcHBAdata->fcChip; #endif - struct fs_struct *fs; DECLARE_MUTEX_LOCKED(fcQueReady); DECLARE_MUTEX_LOCKED(fcTYOBcomplete); DECLARE_MUTEX_LOCKED(TachFrozen); @@ -168,33 +167,7 @@ ENTER("WorkerThread"); lock_kernel(); - /* - * If we were started as result of loading a module, close all of the - * user space pages. We don't need them, and if we didn't close them - * they would be locked into memory. - */ - exit_mm(current); - - current->session = 1; - current->pgrp = 1; - - /* Become as one with the init task */ - - exit_fs(current); /* current->fs->count--; */ - fs = init_task.fs; - // Some kernels compiled for SMP, while actually running - // on a uniproc machine, will return NULL for this call - if( !fs) - { - printk(" cpqfcTS FATAL: fs is NULL! Is this an SMP kernel on uniproc machine?\n "); - } - - else - { - current->fs = fs; - atomic_inc(&fs->count); - } - + daemonize(); siginitsetinv(¤t->blocked, SHUTDOWN_SIGS); diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/scsi/dtc.c linux-2.5/drivers/scsi/dtc.c --- linux-2.5.1/drivers/scsi/dtc.c Sun Sep 30 19:26:07 2001 +++ linux-2.5/drivers/scsi/dtc.c Thu Dec 13 16:32:36 2001 @@ -1,13 +1,11 @@ - #define AUTOSENSE #define PSEUDO_DMA #define DONT_USE_INTR -#define UNSAFE /* Leave interrupts enabled during pseudo-dma I/O */ +#define UNSAFE /* Leave interrupts enabled during pseudo-dma I/O */ #define xNDEBUG (NDEBUG_INTR+NDEBUG_RESELECTION+\ NDEBUG_SELECTION+NDEBUG_ARBITRATION) #define DMA_WORKS_RIGHT - /* * DTC 3180/3280 driver, by * Ray Van Tassle rayvt@comm.mot.com @@ -65,6 +63,7 @@ 6 = yellow 7 = white */ + #if 0 #define rtrc(i) {inb(0x3da); outb(0x31, 0x3c0); outb((i), 0x3c0);} #else @@ -102,336 +101,318 @@ */ /* - */ + */ /* Offset from DTC_5380_OFFSET */ #define DTC_CONTROL_REG 0x100 /* rw */ #define D_CR_ACCESS 0x80 /* ro set=can access 3280 registers */ #define CSR_DIR_READ 0x40 /* rw direction, 1 = read 0 = write */ -#define CSR_RESET 0x80 /* wo Resets 53c400 */ -#define CSR_5380_REG 0x80 /* ro 5380 registers can be accessed */ -#define CSR_TRANS_DIR 0x40 /* rw Data transfer direction */ -#define CSR_SCSI_BUFF_INTR 0x20 /* rw Enable int on transfer ready */ -#define CSR_5380_INTR 0x10 /* rw Enable 5380 interrupts */ -#define CSR_SHARED_INTR 0x08 /* rw Interrupt sharing */ -#define CSR_HOST_BUF_NOT_RDY 0x04 /* ro Host buffer not ready */ -#define CSR_SCSI_BUF_RDY 0x02 /* ro SCSI buffer ready */ -#define CSR_GATED_5380_IRQ 0x01 /* ro Last block xferred */ +#define CSR_RESET 0x80 /* wo Resets 53c400 */ +#define CSR_5380_REG 0x80 /* ro 5380 registers can be accessed */ +#define CSR_TRANS_DIR 0x40 /* rw Data transfer direction */ +#define CSR_SCSI_BUFF_INTR 0x20 /* rw Enable int on transfer ready */ +#define CSR_5380_INTR 0x10 /* rw Enable 5380 interrupts */ +#define CSR_SHARED_INTR 0x08 /* rw Interrupt sharing */ +#define CSR_HOST_BUF_NOT_RDY 0x04 /* ro Host buffer not ready */ +#define CSR_SCSI_BUF_RDY 0x02 /* ro SCSI buffer ready */ +#define CSR_GATED_5380_IRQ 0x01 /* ro Last block xferred */ #define CSR_INT_BASE (CSR_SCSI_BUFF_INTR | CSR_5380_INTR) -#define DTC_BLK_CNT 0x101 /* rw +#define DTC_BLK_CNT 0x101 /* rw * # of 128-byte blocks to transfer */ -#define D_CR_ACCESS 0x80 /* ro set=can access 3280 registers */ +#define D_CR_ACCESS 0x80 /* ro set=can access 3280 registers */ #define DTC_SWITCH_REG 0x3982 /* ro - DIP switches */ #define DTC_RESUME_XFER 0x3982 /* wo - resume data xfer - * after disconnect/reconnect*/ + * after disconnect/reconnect */ #define DTC_5380_OFFSET 0x3880 /* 8 registers here, see NCR5380.h */ /*!!!! for dtc, it's a 128 byte buffer at 3900 !!! */ -#define DTC_DATA_BUF 0x3900 /* rw 128 bytes long */ +#define DTC_DATA_BUF 0x3900 /* rw 128 bytes long */ static struct override { - unsigned int address; - int irq; + unsigned int address; + int irq; } overrides #ifdef OVERRIDE [] __initdata = OVERRIDE; #else -[4] __initdata = {{0, IRQ_AUTO}, {0, IRQ_AUTO}, {0, IRQ_AUTO}, {0, IRQ_AUTO}}; +[4] __initdata = { + {0, IRQ_AUTO}, + {0, IRQ_AUTO}, + {0, IRQ_AUTO}, + {0, IRQ_AUTO} +}; #endif #define NO_OVERRIDES (sizeof(overrides) / sizeof(struct override)) static struct base { - unsigned long address; - int noauto; -} bases[] __initdata = {{0xcc000, 0}, {0xc8000, 0}, {0xdc000, 0}, {0xd8000, 0}}; + unsigned long address; + int noauto; +} bases[] __initdata = { + {0xcc000, 0}, + {0xc8000, 0}, + {0xdc000, 0}, + {0xd8000, 0} +}; #define NO_BASES (sizeof (bases) / sizeof (struct base)) static const struct signature { - const char *string; - int offset; -} signatures[] = { {"DATA TECHNOLOGY CORPORATION BIOS", 0x25}, }; + const char *string; + int offset; +} signatures[] = { + {"DATA TECHNOLOGY CORPORATION BIOS", 0x25}, +}; #define NO_SIGNATURES (sizeof (signatures) / sizeof (struct signature)) -/* - * Function : dtc_setup(char *str, int *ints) - * - * Purpose : LILO command line initialization of the overrides array, - * - * Inputs : str - unused, ints - array of integer parameters with ints[0] - * equal to the number of ints. +/** + * dtc_setup - option setup for dtc3x80 * -*/ + * LILO command line initialization of the overrides array, + */ -void __init dtc_setup(char *str, int *ints){ - static int commandline_current = 0; - int i; - if (ints[0] != 2) - printk("dtc_setup: usage dtc=address,irq\n"); - else - if (commandline_current < NO_OVERRIDES) { - overrides[commandline_current].address = ints[1]; - overrides[commandline_current].irq = ints[2]; - for (i = 0; i < NO_BASES; ++i) - if (bases[i].address == ints[1]) { - bases[i].noauto = 1; - break; - } - ++commandline_current; - } +static int __init dtc_setup(char *str) +{ + static int commandline_current = 0; + int i; + int ints[10]; + + get_options(str, sizeof(ints) / sizeof(int), ints); + + if (ints[0] != 2) + printk(KERN_ERR "dtc_setup: usage dtc=address,irq\n"); + else if (commandline_current < NO_OVERRIDES) { + overrides[commandline_current].address = ints[1]; + overrides[commandline_current].irq = ints[2]; + for (i = 0; i < NO_BASES; ++i) + if (bases[i].address == ints[1]) { + bases[i].noauto = 1; + break; + } + ++commandline_current; + } + return 1; } -/* - * Function : int dtc_detect(Scsi_Host_Template * tpnt) +__setup("dtc=", dtc_setup); + +/** + * dtc_detect - detect DTC 3x80 controllers + * @tpnt: controller template * - * Purpose : detects and initializes DTC 3180/3280 controllers + * Detects and initializes DTC 3180/3280 controllers * that were autoprobed, overridden on the LILO command line, * or specified at compile time. - * - * Inputs : tpnt - template for this SCSI adapter. - * - * Returns : 1 if a host adapter was found, 0 if not. - * -*/ - -int __init dtc_detect(Scsi_Host_Template * tpnt){ - static int current_override = 0, current_base = 0; - struct Scsi_Host *instance; - unsigned int base; - int sig, count; - - tpnt->proc_name = "dtc3x80"; - tpnt->proc_info = &dtc_proc_info; - - for (count = 0; current_override < NO_OVERRIDES; ++current_override) { - base = 0; - - if (overrides[current_override].address) - base = overrides[current_override].address; - else - for (; !base && (current_base < NO_BASES); ++current_base) { -#if (DTCDEBUG & DTCDEBUG_INIT) - printk("scsi-dtc : probing address %08x\n", bases[current_base].address); -#endif - for (sig = 0; sig < NO_SIGNATURES; ++sig) - if (!bases[current_base].noauto && - isa_check_signature(bases[current_base].address + - signatures[sig].offset, - signatures[sig].string, strlen(signatures[sig].string))) { - base = bases[current_base].address; -#if (DTCDEBUG & DTCDEBUG_INIT) - printk("scsi-dtc : detected board.\n"); -#endif - break; - } - } - -#if defined(DTCDEBUG) && (DTCDEBUG & DTCDEBUG_INIT) - printk("scsi-dtc : base = %08x\n", base); -#endif - - if (!base) - break; + */ - instance = scsi_register (tpnt, sizeof(struct NCR5380_hostdata)); - if(instance == NULL) - break; - - instance->base = base; - - NCR5380_init(instance, 0); - - NCR5380_write(DTC_CONTROL_REG, CSR_5380_INTR); /* Enable int's */ - if (overrides[current_override].irq != IRQ_AUTO) - instance->irq = overrides[current_override].irq; - else - instance->irq = NCR5380_probe_irq(instance, DTC_IRQS); +int __init dtc_detect(Scsi_Host_Template * tpnt) +{ + static int current_override = 0, current_base = 0; + struct Scsi_Host *instance; + unsigned int base; + int sig, count; + + tpnt->proc_name = "dtc3x80"; + tpnt->proc_info = &dtc_proc_info; + + for (count = 0; current_override < NO_OVERRIDES; ++current_override) + { + base = 0; + + if (overrides[current_override].address) + base = overrides[current_override].address; + else + { + for (; !base && (current_base < NO_BASES); ++current_base) { + for (sig = 0; sig < NO_SIGNATURES; ++sig) + { + if (!bases[current_base].noauto && isa_check_signature(bases[current_base].address + signatures[sig].offset, signatures[sig].string, strlen(signatures[sig].string))) { + base = bases[current_base].address; + break; + } + } + } + } + + if (!base) + break; + + instance = scsi_register(tpnt, sizeof(struct NCR5380_hostdata)); + if (instance == NULL) + break; + + instance->base = base; + + NCR5380_init(instance, 0); + + NCR5380_write(DTC_CONTROL_REG, CSR_5380_INTR); /* Enable int's */ + if (overrides[current_override].irq != IRQ_AUTO) + instance->irq = overrides[current_override].irq; + else + instance->irq = NCR5380_probe_irq(instance, DTC_IRQS); #ifndef DONT_USE_INTR -/* With interrupts enabled, it will sometimes hang when doing heavy - * reads. So better not enable them until I finger it out. */ - if (instance->irq != IRQ_NONE) - if (request_irq(instance->irq, do_dtc_intr, SA_INTERRUPT, "dtc")) { - printk("scsi%d : IRQ%d not free, interrupts disabled\n", - instance->host_no, instance->irq); - instance->irq = IRQ_NONE; - } - - if (instance->irq == IRQ_NONE) { - printk("scsi%d : interrupts not enabled. for better interactive performance,\n", instance->host_no); - printk("scsi%d : please jumper the board for a free IRQ.\n", instance->host_no); - } + /* With interrupts enabled, it will sometimes hang when doing heavy + * reads. So better not enable them until I figure it out. */ + if (instance->irq != IRQ_NONE) + if (request_irq(instance->irq, do_dtc_intr, SA_INTERRUPT, "dtc")) + { + printk(KERN_WARNING "scsi%d : IRQ%d not free, interrupts disabled\n", instance->host_no, instance->irq); + instance->irq = IRQ_NONE; + } + + if (instance->irq == IRQ_NONE) { + printk(KERN_INFO "scsi%d : interrupts not enabled. for better interactive performance,\n", instance->host_no); + printk(KERN_INFO "scsi%d : please jumper the board for a free IRQ.\n", instance->host_no); + } #else - if (instance->irq != IRQ_NONE) - printk("scsi%d : interrupts not used. Might as well not jumper it.\n", - instance->host_no); - instance->irq = IRQ_NONE; + if (instance->irq != IRQ_NONE) + printk(KERN_INFO "scsi%d : interrupts not used. Might as well not jumper it.\n", instance->host_no); + instance->irq = IRQ_NONE; #endif -#if defined(DTCDEBUG) && (DTCDEBUG & DTCDEBUG_INIT) - printk("scsi%d : irq = %d\n", instance->host_no, instance->irq); -#endif - - printk("scsi%d : at 0x%05X", instance->host_no, (int)instance->base); - if (instance->irq == IRQ_NONE) - printk (" interrupts disabled"); - else - printk (" irq %d", instance->irq); - printk(" options CAN_QUEUE=%d CMD_PER_LUN=%d release=%d", - CAN_QUEUE, CMD_PER_LUN, DTC_PUBLIC_RELEASE); - NCR5380_print_options(instance); - printk("\n"); - - ++current_override; - ++count; - } - return count; + printk(KERN_INFO "scsi%d : at 0x%05X", instance->host_no, (int) instance->base); + if (instance->irq == IRQ_NONE) + printk(" interrupts disabled"); + else + printk(" irq %d", instance->irq); + printk(" options CAN_QUEUE=%d CMD_PER_LUN=%d release=%d", CAN_QUEUE, CMD_PER_LUN, DTC_PUBLIC_RELEASE); + NCR5380_print_options(instance); + printk("\n"); + + ++current_override; + ++count; + } + return count; } -/* - * Function : int dtc_biosparam(Disk * disk, kdev_t dev, int *ip) +/** + * dtc_biosparam - compute disk geometry + * @disk: disk to generate for + * @dev: major/minor of device + * @ip: returned geometry * - * Purpose : Generates a BIOS / DOS compatible H-C-S mapping for + * Generates a BIOS / DOS compatible H-C-S mapping for * the specified device / size. - * - * Inputs : size = size of device in sectors (512 bytes), dev = block device - * major / minor, ip[] = {heads, sectors, cylinders} - * - * Returns : always 0 (success), initializes ip - * -*/ - -/* - * XXX Most SCSI boards use this mapping, I could be incorrect. Some one - * using hard disks on a trantor should verify that this mapping corresponds - * to that used by the BIOS / ASPI driver by running the linux fdisk program - * and matching the H_C_S coordinates to what DOS uses. -*/ + */ -int dtc_biosparam(Disk * disk, kdev_t dev, int * ip) +int dtc_biosparam(Disk * disk, kdev_t dev, int *ip) { - int size = disk->capacity; + int size = disk->capacity; - ip[0] = 64; - ip[1] = 32; - ip[2] = size >> 11; - return 0; + ip[0] = 64; + ip[1] = 32; + ip[2] = size >> 11; + return 0; } -/**************************************************************** - * Function : int NCR5380_pread (struct Scsi_Host *instance, - * unsigned char *dst, int len) - * - * Purpose : Fast 5380 pseudo-dma read function, reads len bytes to - * dst - * - * Inputs : dst = destination, len = length in bytes - * - * Returns : 0 on success, non zero on a failure such as a watchdog - * timeout. -*/ - static int dtc_maxi = 0; static int dtc_wmaxi = 0; -static inline int NCR5380_pread (struct Scsi_Host *instance, - unsigned char *dst, int len) - { - unsigned char *d = dst; - int i; /* For counting time spent in the poll-loop */ - NCR5380_local_declare(); - NCR5380_setup(instance); - - i = 0; - NCR5380_read(RESET_PARITY_INTERRUPT_REG); - NCR5380_write(MODE_REG, MR_ENABLE_EOP_INTR | MR_DMA_MODE); - if (instance->irq == IRQ_NONE) - NCR5380_write(DTC_CONTROL_REG, CSR_DIR_READ); - else - NCR5380_write(DTC_CONTROL_REG, CSR_DIR_READ | CSR_INT_BASE); - NCR5380_write(DTC_BLK_CNT, len >> 7); /* Block count */ - rtrc(1); - while (len > 0) { - rtrc(2); - while (NCR5380_read(DTC_CONTROL_REG) & CSR_HOST_BUF_NOT_RDY) - ++i; - rtrc(3); - isa_memcpy_fromio(d, base + DTC_DATA_BUF, 128); - d += 128; - len -= 128; - rtrc(7); /*** with int's on, it sometimes hangs after here. +/** + * NCR5380_pread - fast pseudo DMA read + * @instance: controller + * @dst: destination buffer + * @len: expected/max size + * + * Fast 5380 pseudo-dma read function, reads len bytes from the controller + * mmio area into dst. + */ + +static inline int NCR5380_pread(struct Scsi_Host *instance, unsigned char *dst, int len) +{ + unsigned char *d = dst; + int i; /* For counting time spent in the poll-loop */ + NCR5380_local_declare(); + NCR5380_setup(instance); + + i = 0; + NCR5380_read(RESET_PARITY_INTERRUPT_REG); + NCR5380_write(MODE_REG, MR_ENABLE_EOP_INTR | MR_DMA_MODE); + if (instance->irq == IRQ_NONE) + NCR5380_write(DTC_CONTROL_REG, CSR_DIR_READ); + else + NCR5380_write(DTC_CONTROL_REG, CSR_DIR_READ | CSR_INT_BASE); + NCR5380_write(DTC_BLK_CNT, len >> 7); /* Block count */ + rtrc(1); + while (len > 0) { + rtrc(2); + while (NCR5380_read(DTC_CONTROL_REG) & CSR_HOST_BUF_NOT_RDY) + ++i; + rtrc(3); + isa_memcpy_fromio(d, base + DTC_DATA_BUF, 128); + d += 128; + len -= 128; + rtrc(7); + /*** with int's on, it sometimes hangs after here. * Looks like something makes HBNR go away. */ - } - rtrc(4); - while ( !(NCR5380_read(DTC_CONTROL_REG) & D_CR_ACCESS)) - ++i; - NCR5380_write(MODE_REG, 0); /* Clear the operating mode */ - rtrc(0); - NCR5380_read(RESET_PARITY_INTERRUPT_REG); - if (i > dtc_maxi) - dtc_maxi = i; - return(0); + } + rtrc(4); + while (!(NCR5380_read(DTC_CONTROL_REG) & D_CR_ACCESS)) + ++i; + NCR5380_write(MODE_REG, 0); /* Clear the operating mode */ + rtrc(0); + NCR5380_read(RESET_PARITY_INTERRUPT_REG); + if (i > dtc_maxi) + dtc_maxi = i; + return (0); } -/**************************************************************** - * Function : int NCR5380_pwrite (struct Scsi_Host *instance, - * unsigned char *src, int len) +/** + * NCR5380_pwrite - fast pseudo DMA write + * @instance: controller + * @dst: destination buffer + * @len: expected/max size * - * Purpose : Fast 5380 pseudo-dma write function, transfers len bytes from - * src - * - * Inputs : src = source, len = length in bytes - * - * Returns : 0 on success, non zero on a failure such as a watchdog - * timeout. -*/ + * Fast 5380 pseudo-dma write function, writes len bytes to the + * controller mmio area from src. + */ -static inline int NCR5380_pwrite (struct Scsi_Host *instance, - unsigned char *src, int len) { - int i; - NCR5380_local_declare(); - NCR5380_setup(instance); - - NCR5380_read(RESET_PARITY_INTERRUPT_REG); - NCR5380_write(MODE_REG, MR_ENABLE_EOP_INTR | MR_DMA_MODE); - /* set direction (write) */ - if (instance->irq == IRQ_NONE) - NCR5380_write(DTC_CONTROL_REG, 0); - else - NCR5380_write(DTC_CONTROL_REG, CSR_5380_INTR); - NCR5380_write(DTC_BLK_CNT, len >> 7); /* Block count */ - for (i = 0; len > 0; ++i) { - rtrc(5); - /* Poll until the host buffer can accept data. */ - while (NCR5380_read(DTC_CONTROL_REG) & CSR_HOST_BUF_NOT_RDY) - ++i; - rtrc(3); - isa_memcpy_toio(base + DTC_DATA_BUF, src, 128); - src += 128; - len -= 128; - } - rtrc(4); - while ( !(NCR5380_read(DTC_CONTROL_REG) & D_CR_ACCESS)) - ++i; - rtrc(6); - /* Wait until the last byte has been sent to the disk */ - while (!(NCR5380_read(TARGET_COMMAND_REG) & TCR_LAST_BYTE_SENT)) - ++i; - rtrc(7); - /* Check for parity error here. fixme. */ - NCR5380_write(MODE_REG, 0); /* Clear the operating mode */ - rtrc(0); - if (i > dtc_wmaxi) - dtc_wmaxi = i; - return (0); +static inline int NCR5380_pwrite(struct Scsi_Host *instance, unsigned char *src, int len) +{ + int i; + NCR5380_local_declare(); + NCR5380_setup(instance); + + NCR5380_read(RESET_PARITY_INTERRUPT_REG); + NCR5380_write(MODE_REG, MR_ENABLE_EOP_INTR | MR_DMA_MODE); + /* set direction (write) */ + if (instance->irq == IRQ_NONE) + NCR5380_write(DTC_CONTROL_REG, 0); + else + NCR5380_write(DTC_CONTROL_REG, CSR_5380_INTR); + NCR5380_write(DTC_BLK_CNT, len >> 7); /* Block count */ + for (i = 0; len > 0; ++i) { + rtrc(5); + /* Poll until the host buffer can accept data. */ + while (NCR5380_read(DTC_CONTROL_REG) & CSR_HOST_BUF_NOT_RDY) + ++i; + rtrc(3); + isa_memcpy_toio(base + DTC_DATA_BUF, src, 128); + src += 128; + len -= 128; + } + rtrc(4); + while (!(NCR5380_read(DTC_CONTROL_REG) & D_CR_ACCESS)) + ++i; + rtrc(6); + /* Wait until the last byte has been sent to the disk */ + while (!(NCR5380_read(TARGET_COMMAND_REG) & TCR_LAST_BYTE_SENT)) + ++i; + rtrc(7); + /* Check for parity error here. fixme. */ + NCR5380_write(MODE_REG, 0); /* Clear the operating mode */ + rtrc(0); + if (i > dtc_wmaxi) + dtc_wmaxi = i; + return (0); } MODULE_LICENSE("GPL"); diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/scsi/fdomain.c linux-2.5/drivers/scsi/fdomain.c --- linux-2.5.1/drivers/scsi/fdomain.c Sun Sep 30 19:26:07 2001 +++ linux-2.5/drivers/scsi/fdomain.c Thu Dec 13 16:32:36 2001 @@ -983,7 +983,7 @@ /* Register the IRQ with the kernel */ retcode = request_irq( interrupt_level, - do_fdomain_16x0_intr, pdev?SA_SHIRQ:0, "fdomain", NULL); + do_fdomain_16x0_intr, pdev?SA_SHIRQ:0, "fdomain", shpnt); if (retcode < 0) { if (retcode == -EINVAL) { @@ -2033,6 +2033,15 @@ } return 0; +} + +int fdomain_16x0_release(struct Scsi_Host *shpnt) +{ + if (shpnt->irq) + free_irq(shpnt->irq, shpnt); + if (shpnt->io_port && shpnt->n_io_port) + release_region(shpnt->io_port, shpnt->n_io_port); + } MODULE_LICENSE("GPL"); diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/scsi/fdomain.h linux-2.5/drivers/scsi/fdomain.h --- linux-2.5.1/drivers/scsi/fdomain.h Fri Nov 12 00:57:30 1999 +++ linux-2.5/drivers/scsi/fdomain.h Thu Dec 13 16:32:36 2001 @@ -34,6 +34,7 @@ int fdomain_16x0_biosparam( Disk *, kdev_t, int * ); int fdomain_16x0_proc_info( char *buffer, char **start, off_t offset, int length, int hostno, int inout ); +int fdomain_16x0_release( struct Scsi_Host *shpnt ); #define FDOMAIN_16X0 { proc_info: fdomain_16x0_proc_info, \ detect: fdomain_16x0_detect, \ @@ -43,6 +44,7 @@ abort: fdomain_16x0_abort, \ reset: fdomain_16x0_reset, \ bios_param: fdomain_16x0_biosparam, \ + release: fdomain_16x0_release, \ can_queue: 1, \ this_id: 6, \ sg_tablesize: 64, \ diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/scsi/g_NCR5380.c linux-2.5/drivers/scsi/g_NCR5380.c --- linux-2.5.1/drivers/scsi/g_NCR5380.c Sun Sep 30 19:26:07 2001 +++ linux-2.5/drivers/scsi/g_NCR5380.c Tue Dec 18 15:31:05 2001 @@ -77,7 +77,7 @@ * IRQ line if overridden on the command line. * */ - + /* * $Log: generic_NCR5380.c,v $ */ @@ -124,787 +124,772 @@ #include <linux/isapnp.h> #define NCR_NOT_SET 0 -static int ncr_irq=NCR_NOT_SET; -static int ncr_dma=NCR_NOT_SET; -static int ncr_addr=NCR_NOT_SET; -static int ncr_5380=NCR_NOT_SET; -static int ncr_53c400=NCR_NOT_SET; -static int ncr_53c400a=NCR_NOT_SET; -static int dtc_3181e=NCR_NOT_SET; +static int ncr_irq = NCR_NOT_SET; +static int ncr_dma = NCR_NOT_SET; +static int ncr_addr = NCR_NOT_SET; +static int ncr_5380 = NCR_NOT_SET; +static int ncr_53c400 = NCR_NOT_SET; +static int ncr_53c400a = NCR_NOT_SET; +static int dtc_3181e = NCR_NOT_SET; static struct override { NCR5380_implementation_fields; - int irq; - int dma; - int board; /* Use NCR53c400, Ricoh, etc. extensions ? */ -} overrides -#ifdef GENERIC_NCR5380_OVERRIDE - [] __initdata = GENERIC_NCR5380_OVERRIDE; + int irq; + int dma; + int board; /* Use NCR53c400, Ricoh, etc. extensions ? */ +} overrides +#ifdef GENERIC_NCR5380_OVERRIDE +[] __initdata = GENERIC_NCR5380_OVERRIDE; #else - [1] __initdata = {{0,},}; +[1] __initdata = { { 0,},}; #endif #define NO_OVERRIDES (sizeof(overrides) / sizeof(struct override)) -/* - * Function : static internal_setup(int board, char *str, int *ints) +/** + * internal_setup - handle lilo command string override + * @board: BOARD_* identifier for the board + * @str: unused + * @ints: numeric parameters * - * Purpose : LILO command line initialization of the overrides array, - * - * Inputs : board - either BOARD_NCR5380 for a normal NCR5380 board, - * or BOARD_NCR53C400 for a NCR53C400 board. str - unused, ints - - * array of integer parameters with ints[0] equal to the number of ints. + * Do LILO command line initialization of the overrides array. Display + * errors when needed * + * Locks: none */ -static void __init internal_setup(int board, char *str, int *ints){ - static int commandline_current = 0; - switch (board) { - case BOARD_NCR5380: - if (ints[0] != 2 && ints[0] != 3) { - printk("generic_NCR5380_setup : usage ncr5380=" STRVAL(NCR5380_map_name) ",irq,dma\n"); - return; - } - break; - case BOARD_NCR53C400: - if (ints[0] != 2) { - printk("generic_NCR53C400_setup : usage ncr53c400=" STRVAL(NCR5380_map_name) ",irq\n"); - return; - } - break; - case BOARD_NCR53C400A: - if (ints[0] != 2) { - printk("generic_NCR53C400A_setup : usage ncr53c400a=" STRVAL(NCR5380_map_name) ",irq\n"); - return; - } - break; - case BOARD_DTC3181E: - if (ints[0] != 2) { - printk("generic_DTC3181E_setup : usage dtc3181e=" STRVAL(NCR5380_map_name) ",irq\n"); - return; - } - break; - } - - if (commandline_current < NO_OVERRIDES) { - overrides[commandline_current].NCR5380_map_name = (NCR5380_map_type)ints[1]; - overrides[commandline_current].irq = ints[2]; - if (ints[0] == 3) - overrides[commandline_current].dma = ints[3]; - else - overrides[commandline_current].dma = DMA_NONE; - overrides[commandline_current].board = board; - ++commandline_current; - } +static void __init internal_setup(int board, char *str, int *ints) +{ + static int commandline_current = 0; + switch (board) { + case BOARD_NCR5380: + if (ints[0] != 2 && ints[0] != 3) { + printk(KERN_ERR "generic_NCR5380_setup : usage ncr5380=" STRVAL(NCR5380_map_name) ",irq,dma\n"); + return; + } + break; + case BOARD_NCR53C400: + if (ints[0] != 2) { + printk(KERN_ERR "generic_NCR53C400_setup : usage ncr53c400=" STRVAL(NCR5380_map_name) ",irq\n"); + return; + } + break; + case BOARD_NCR53C400A: + if (ints[0] != 2) { + printk(KERN_ERR "generic_NCR53C400A_setup : usage ncr53c400a=" STRVAL(NCR5380_map_name) ",irq\n"); + return; + } + break; + case BOARD_DTC3181E: + if (ints[0] != 2) { + printk("generic_DTC3181E_setup : usage dtc3181e=" STRVAL(NCR5380_map_name) ",irq\n"); + return; + } + break; + } + + if (commandline_current < NO_OVERRIDES) { + overrides[commandline_current].NCR5380_map_name = (NCR5380_map_type) ints[1]; + overrides[commandline_current].irq = ints[2]; + if (ints[0] == 3) + overrides[commandline_current].dma = ints[3]; + else + overrides[commandline_current].dma = DMA_NONE; + overrides[commandline_current].board = board; + ++commandline_current; + } } -/* - * Function : generic_NCR5380_setup (char *str, int *ints) +/** + * do_NCR53C80_setup - set up entry point + * @str: unused * - * Purpose : LILO command line initialization of the overrides array, - * - * Inputs : str - unused, ints - array of integer parameters with ints[0] - * equal to the number of ints. + * Setup function invoked at boot to parse the ncr5380= command + * line. */ -void __init generic_NCR5380_setup (char *str, int *ints){ - internal_setup (BOARD_NCR5380, str, ints); +static int __init do_NCR5380_setup(char *str) +{ + int ints[10]; + + get_options(str, sizeof(ints) / sizeof(int), ints); + internal_setup(BOARD_NCR5380, str, ints); + return 1; } -/* - * Function : generic_NCR53C400_setup (char *str, int *ints) +/** + * do_NCR53C400_setup - set up entry point + * @str: unused + * @ints: integer parameters from kernel setup code * - * Purpose : LILO command line initialization of the overrides array, - * - * Inputs : str - unused, ints - array of integer parameters with ints[0] - * equal to the number of ints. + * Setup function invoked at boot to parse the ncr53c400= command + * line. */ -void __init generic_NCR53C400_setup (char *str, int *ints){ - internal_setup (BOARD_NCR53C400, str, ints); +static int __init do_NCR53C400_setup(char *str) +{ + int ints[10]; + + get_options(str, sizeof(ints) / sizeof(int), ints); + internal_setup(BOARD_NCR53C400, str, ints); + return 1; } -/* - * Function : generic_NCR53C400A_setup (char *str, int *ints) +/** + * do_NCR53C400A_setup - set up entry point + * @str: unused + * @ints: integer parameters from kernel setup code * - * Purpose : LILO command line initialization of the overrides array, - * - * Inputs : str - unused, ints - array of integer parameters with ints[0] - * equal to the number of ints. + * Setup function invoked at boot to parse the ncr53c400a= command + * line. */ -void generic_NCR53C400A_setup (char *str, int *ints) { - internal_setup (BOARD_NCR53C400A, str, ints); +static int __init do_NCR53C400A_setup(char *str) +{ + int ints[10]; + + get_options(str, sizeof(ints) / sizeof(int), ints); + internal_setup(BOARD_NCR53C400A, str, ints); + return 1; } -/* - * Function : generic_DTC3181E_setup (char *str, int *ints) +/** + * do_DTC3181E_setup - set up entry point + * @str: unused + * @ints: integer parameters from kernel setup code * - * Purpose : LILO command line initialization of the overrides array, - * - * Inputs : str - unused, ints - array of integer parameters with ints[0] - * equal to the number of ints. + * Setup function invoked at boot to parse the dtc3181e= command + * line. */ -void generic_DTC3181E_setup (char *str, int *ints) { - internal_setup (BOARD_DTC3181E, str, ints); +static int __init do_DTC3181E_setup(char *str) +{ + int ints[10]; + + get_options(str, sizeof(ints) / sizeof(int), ints); + internal_setup(BOARD_DTC3181E, str, ints); + return 1; } -/* - * Function : int generic_NCR5380_detect(Scsi_Host_Template * tpnt) +/** + * generic_NCR5380_detect - look for NCR5380 controllers + * @tpnt: the scsi template * - * Purpose : initializes generic NCR5380 driver based on the - * command line / compile time port and irq definitions. + * Scan for the present of NCR5380, NCR53C400, NCR53C400A, DTC3181E + * and DTC436(ISAPnP) controllers. If overrides have been set we use + * them. * - * Inputs : tpnt - template for this SCSI adapter. - * - * Returns : 1 if a host adapter was found, 0 if not. + * The caller supplied NCR5380_init function is invoked from here, before + * the interrupt line is taken. * + * Locks: none */ -int __init generic_NCR5380_detect(Scsi_Host_Template * tpnt){ - static int current_override = 0; - int count, i; - u_int *ports; - u_int ncr_53c400a_ports[] = {0x280, 0x290, 0x300, 0x310, 0x330, - 0x340, 0x348, 0x350, 0}; - u_int dtc_3181e_ports[] = {0x220, 0x240, 0x280, 0x2a0, 0x2c0, - 0x300, 0x320, 0x340, 0}; - int flags = 0; - struct Scsi_Host *instance; - - if (ncr_irq != NCR_NOT_SET) - overrides[0].irq=ncr_irq; - if (ncr_dma != NCR_NOT_SET) - overrides[0].dma=ncr_dma; - if (ncr_addr != NCR_NOT_SET) - overrides[0].NCR5380_map_name=(NCR5380_map_type)ncr_addr; - if (ncr_5380 != NCR_NOT_SET) - overrides[0].board=BOARD_NCR5380; - else if (ncr_53c400 != NCR_NOT_SET) - overrides[0].board=BOARD_NCR53C400; - else if (ncr_53c400a != NCR_NOT_SET) - overrides[0].board=BOARD_NCR53C400A; - else if (dtc_3181e != NCR_NOT_SET) - overrides[0].board=BOARD_DTC3181E; - - if (!current_override && isapnp_present()) { - struct pci_dev *dev = NULL; - count = 0; - while ((dev = isapnp_find_dev(NULL, ISAPNP_VENDOR('D','T','C'), ISAPNP_FUNCTION(0x436e), dev))) { - if (count >= NO_OVERRIDES) - break; - if (!dev->active && dev->prepare(dev) < 0) { - printk(KERN_ERR "dtc436e probe: prepare failed\n"); - continue; - } - if (!(dev->resource[0].flags & IORESOURCE_IO)) - continue; - if (!dev->active && dev->activate(dev) < 0) { - printk(KERN_ERR "dtc436e probe: activate failed\n"); - continue; - } - if (dev->irq_resource[0].flags & IORESOURCE_IRQ) - overrides[count].irq=dev->irq_resource[0].start; - else - overrides[count].irq=IRQ_NONE; - if (dev->dma_resource[0].flags & IORESOURCE_DMA) - overrides[count].dma=dev->dma_resource[0].start; - else - overrides[count].dma=DMA_NONE; - overrides[count].NCR5380_map_name=(NCR5380_map_type)dev->resource[0].start; - overrides[count].board=BOARD_DTC3181E; - count++; - } - } - - tpnt->proc_name = "g_NCR5380"; - - for (count = 0; current_override < NO_OVERRIDES; ++current_override) { - if (!(overrides[current_override].NCR5380_map_name)) - continue; - - ports = 0; - switch (overrides[current_override].board) { - case BOARD_NCR5380: - flags = FLAG_NO_PSEUDO_DMA; - break; - case BOARD_NCR53C400: - flags = FLAG_NCR53C400; - break; - case BOARD_NCR53C400A: - flags = FLAG_NO_PSEUDO_DMA; - ports = ncr_53c400a_ports; - break; - case BOARD_DTC3181E: - flags = FLAG_NO_PSEUDO_DMA | FLAG_DTC3181E; - ports = dtc_3181e_ports; - break; +int __init generic_NCR5380_detect(Scsi_Host_Template * tpnt) +{ + static int current_override = 0; + int count, i; + unsigned int *ports; + static unsigned int __initdata ncr_53c400a_ports[] = { + 0x280, 0x290, 0x300, 0x310, 0x330, 0x340, 0x348, 0x350, 0 + }; + static unsigned int __initdata dtc_3181e_ports[] = { + 0x220, 0x240, 0x280, 0x2a0, 0x2c0, 0x300, 0x320, 0x340, 0 + }; + int flags = 0; + struct Scsi_Host *instance; + + if (ncr_irq != NCR_NOT_SET) + overrides[0].irq = ncr_irq; + if (ncr_dma != NCR_NOT_SET) + overrides[0].dma = ncr_dma; + if (ncr_addr != NCR_NOT_SET) + overrides[0].NCR5380_map_name = (NCR5380_map_type) ncr_addr; + if (ncr_5380 != NCR_NOT_SET) + overrides[0].board = BOARD_NCR5380; + else if (ncr_53c400 != NCR_NOT_SET) + overrides[0].board = BOARD_NCR53C400; + else if (ncr_53c400a != NCR_NOT_SET) + overrides[0].board = BOARD_NCR53C400A; + else if (dtc_3181e != NCR_NOT_SET) + overrides[0].board = BOARD_DTC3181E; + + if (!current_override && isapnp_present()) { + struct pci_dev *dev = NULL; + count = 0; + while ((dev = isapnp_find_dev(NULL, ISAPNP_VENDOR('D', 'T', 'C'), ISAPNP_FUNCTION(0x436e), dev))) { + if (count >= NO_OVERRIDES) + break; + if (!dev->active && dev->prepare(dev) < 0) { + printk(KERN_ERR "dtc436e probe: prepare failed\n"); + continue; + } + if (!(dev->resource[0].flags & IORESOURCE_IO)) + continue; + if (!dev->active && dev->activate(dev) < 0) { + printk(KERN_ERR "dtc436e probe: activate failed\n"); + continue; + } + if (dev->irq_resource[0].flags & IORESOURCE_IRQ) + overrides[count].irq = dev->irq_resource[0].start; + else + overrides[count].irq = IRQ_NONE; + if (dev->dma_resource[0].flags & IORESOURCE_DMA) + overrides[count].dma = dev->dma_resource[0].start; + else + overrides[count].dma = DMA_NONE; + overrides[count].NCR5380_map_name = (NCR5380_map_type) dev->resource[0].start; + overrides[count].board = BOARD_DTC3181E; + count++; + } } + tpnt->proc_name = "g_NCR5380"; + + for (count = 0; current_override < NO_OVERRIDES; ++current_override) { + if (!(overrides[current_override].NCR5380_map_name)) + continue; + + ports = 0; + switch (overrides[current_override].board) { + case BOARD_NCR5380: + flags = FLAG_NO_PSEUDO_DMA; + break; + case BOARD_NCR53C400: + flags = FLAG_NCR53C400; + break; + case BOARD_NCR53C400A: + flags = FLAG_NO_PSEUDO_DMA; + ports = ncr_53c400a_ports; + break; + case BOARD_DTC3181E: + flags = FLAG_NO_PSEUDO_DMA | FLAG_DTC3181E; + ports = dtc_3181e_ports; + break; + } + #ifdef CONFIG_SCSI_G_NCR5380_PORT - if (ports) { - /* wakeup sequence for the NCR53C400A and DTC3181E*/ + if (ports) { + /* wakeup sequence for the NCR53C400A and DTC3181E */ - /* Disable the adapter and look for a free io port */ - outb(0x59, 0x779); - outb(0xb9, 0x379); - outb(0xc5, 0x379); - outb(0xae, 0x379); - outb(0xa6, 0x379); - outb(0x00, 0x379); - - if (overrides[current_override].NCR5380_map_name != PORT_AUTO) - for(i=0; ports[i]; i++) { - if (overrides[current_override].NCR5380_map_name == ports[i]) - break; - } - else - for(i=0; ports[i]; i++) { - if ((!check_region(ports[i], 16)) && (inb(ports[i]) == 0xff)) - break; - } - if (ports[i]) { - outb(0x59, 0x779); - outb(0xb9, 0x379); - outb(0xc5, 0x379); - outb(0xae, 0x379); - outb(0xa6, 0x379); - outb(0x80 | i, 0x379); /* set io port to be used */ - outb(0xc0, ports[i] + 9); - if (inb(ports[i] + 9) != 0x80) - continue; - else - overrides[current_override].NCR5380_map_name=ports[i]; - } else - continue; - } + /* Disable the adapter and look for a free io port */ + outb(0x59, 0x779); + outb(0xb9, 0x379); + outb(0xc5, 0x379); + outb(0xae, 0x379); + outb(0xa6, 0x379); + outb(0x00, 0x379); + + if (overrides[current_override].NCR5380_map_name != PORT_AUTO) + for (i = 0; ports[i]; i++) { + if (overrides[current_override].NCR5380_map_name == ports[i]) + break; + } else + for (i = 0; ports[i]; i++) { + if ((!check_region(ports[i], 16)) && (inb(ports[i]) == 0xff)) + break; + } + if (ports[i]) { + outb(0x59, 0x779); + outb(0xb9, 0x379); + outb(0xc5, 0x379); + outb(0xae, 0x379); + outb(0xa6, 0x379); + outb(0x80 | i, 0x379); /* set io port to be used */ + outb(0xc0, ports[i] + 9); + if (inb(ports[i] + 9) != 0x80) + continue; + else + overrides[current_override].NCR5380_map_name = ports[i]; + } else + continue; + } - request_region(overrides[current_override].NCR5380_map_name, - NCR5380_region_size, "ncr5380"); + request_region(overrides[current_override].NCR5380_map_name, NCR5380_region_size, "ncr5380"); #else - if(check_mem_region(overrides[current_override].NCR5380_map_name, - NCR5380_region_size)) - continue; - request_mem_region(overrides[current_override].NCR5380_map_name, - NCR5380_region_size, "ncr5380"); + if (check_mem_region(overrides[current_override].NCR5380_map_name, NCR5380_region_size)) + continue; + request_mem_region(overrides[current_override].NCR5380_map_name, NCR5380_region_size, "ncr5380"); #endif - instance = scsi_register (tpnt, sizeof(struct NCR5380_hostdata)); - if(instance == NULL) - { + instance = scsi_register(tpnt, sizeof(struct NCR5380_hostdata)); + if (instance == NULL) { #ifdef CONFIG_SCSI_G_NCR5380_PORT - release_region(overrides[current_override].NCR5380_map_name, - NCR5380_region_size); + release_region(overrides[current_override].NCR5380_map_name, NCR5380_region_size); #else - release_mem_region(overrides[current_override].NCR5380_map_name, - NCR5380_region_size); + release_mem_region(overrides[current_override].NCR5380_map_name, NCR5380_region_size); #endif - continue; - } - - instance->NCR5380_instance_name = overrides[current_override].NCR5380_map_name; - - NCR5380_init(instance, flags); - - if (overrides[current_override].irq != IRQ_AUTO) - instance->irq = overrides[current_override].irq; - else - instance->irq = NCR5380_probe_irq(instance, 0xffff); + continue; + } - if (instance->irq != IRQ_NONE) - if (request_irq(instance->irq, do_generic_NCR5380_intr, SA_INTERRUPT, "NCR5380", NULL)) { - printk("scsi%d : IRQ%d not free, interrupts disabled\n", - instance->host_no, instance->irq); - instance->irq = IRQ_NONE; - } + instance->NCR5380_instance_name = overrides[current_override].NCR5380_map_name; - if (instance->irq == IRQ_NONE) { - printk("scsi%d : interrupts not enabled. for better interactive performance,\n", instance->host_no); - printk("scsi%d : please jumper the board for a free IRQ.\n", instance->host_no); - } + NCR5380_init(instance, flags); - printk("scsi%d : at " STRVAL(NCR5380_map_name) " 0x%x", instance->host_no, (unsigned int)instance->NCR5380_instance_name); - if (instance->irq == IRQ_NONE) - printk (" interrupts disabled"); - else - printk (" irq %d", instance->irq); - printk(" options CAN_QUEUE=%d CMD_PER_LUN=%d release=%d", - CAN_QUEUE, CMD_PER_LUN, GENERIC_NCR5380_PUBLIC_RELEASE); - NCR5380_print_options(instance); - printk("\n"); - - ++current_override; - ++count; - } - return count; -} + if (overrides[current_override].irq != IRQ_AUTO) + instance->irq = overrides[current_override].irq; + else + instance->irq = NCR5380_probe_irq(instance, 0xffff); + + if (instance->irq != IRQ_NONE) + if (request_irq(instance->irq, do_generic_NCR5380_intr, SA_INTERRUPT, "NCR5380", NULL)) { + printk(KERN_WARNING "scsi%d : IRQ%d not free, interrupts disabled\n", instance->host_no, instance->irq); + instance->irq = IRQ_NONE; + } + + if (instance->irq == IRQ_NONE) { + printk(KERN_INFO "scsi%d : interrupts not enabled. for better interactive performance,\n", instance->host_no); + printk(KERN_INFO "scsi%d : please jumper the board for a free IRQ.\n", instance->host_no); + } -const char * generic_NCR5380_info (struct Scsi_Host* host) { - static const char string[]="Generic NCR5380/53C400 Driver"; - return string; + printk(KERN_INFO "scsi%d : at " STRVAL(NCR5380_map_name) " 0x%x", instance->host_no, (unsigned int) instance->NCR5380_instance_name); + if (instance->irq == IRQ_NONE) + printk(" interrupts disabled"); + else + printk(" irq %d", instance->irq); + printk(" options CAN_QUEUE=%d CMD_PER_LUN=%d release=%d", CAN_QUEUE, CMD_PER_LUN, GENERIC_NCR5380_PUBLIC_RELEASE); + NCR5380_print_options(instance); + printk("\n"); + + ++current_override; + ++count; + } + return count; +} + +/** + * generic_NCR5380_info - reporting string + * @host: NCR5380 to report on + * + * Report driver information for the NCR5380 + */ + +const char *generic_NCR5380_info(struct Scsi_Host *host) +{ + static const char string[] = "Generic NCR5380/53C400 Driver"; + return string; } -int generic_NCR5380_release_resources(struct Scsi_Host * instance) +/** + * generic_NCR5380_release_resources - free resources + * @instance: host adapter to clean up + * + * Free the generic interface resources from this adapter. + * + * Locks: none + */ + +int generic_NCR5380_release_resources(struct Scsi_Host *instance) { - NCR5380_local_declare(); - - NCR5380_setup(instance); + NCR5380_local_declare(); + NCR5380_setup(instance); #ifdef CONFIG_SCSI_G_NCR5380_PORT - release_region(instance->NCR5380_instance_name, NCR5380_region_size); + release_region(instance->NCR5380_instance_name, NCR5380_region_size); #else - release_mem_region(instance->NCR5380_instance_name, NCR5380_region_size); -#endif + release_mem_region(instance->NCR5380_instance_name, NCR5380_region_size); +#endif - if (instance->irq != IRQ_NONE) - free_irq(instance->irq, NULL); + if (instance->irq != IRQ_NONE) + free_irq(instance->irq, NULL); return 0; } #ifdef BIOSPARAM -/* - * Function : int generic_NCR5380_biosparam(Disk * disk, kdev_t dev, int *ip) +/** + * generic_NCR5380_biosparam + * @disk: disk to compute geometry for + * @dev: device identifier for this disk + * @ip: sizes to fill in * - * Purpose : Generates a BIOS / DOS compatible H-C-S mapping for - * the specified device / size. + * Generates a BIOS / DOS compatible H-C-S mapping for the specified + * device / size. * - * Inputs : size = size of device in sectors (512 bytes), dev = block device - * major / minor, ip[] = {heads, sectors, cylinders} + * XXX Most SCSI boards use this mapping, I could be incorrect. Someone + * using hard disks on a trantor should verify that this mapping + * corresponds to that used by the BIOS / ASPI driver by running the linux + * fdisk program and matching the H_C_S coordinates to what DOS uses. * - * Returns : always 0 (success), initializes ip - * - */ - -/* - * XXX Most SCSI boards use this mapping, I could be incorrect. Some one - * using hard disks on a trantor should verify that this mapping corresponds - * to that used by the BIOS / ASPI driver by running the linux fdisk program - * and matching the H_C_S coordinates to what DOS uses. + * Locks: none */ int generic_NCR5380_biosparam(Disk * disk, kdev_t dev, int *ip) { - int size = disk->capacity; - ip[0] = 64; - ip[1] = 32; - ip[2] = size >> 11; - return 0; + int size = disk->capacity; + ip[0] = 64; + ip[1] = 32; + ip[2] = size >> 11; + return 0; } #endif #if NCR53C400_PSEUDO_DMA -static inline int NCR5380_pread (struct Scsi_Host *instance, unsigned char *dst, int len) -{ - int blocks = len / 128; - int start = 0; - int bl; -#ifdef CONFIG_SCSI_G_NCR5380_PORT - int i; -#endif - NCR5380_local_declare(); - - NCR5380_setup(instance); - -#if (NDEBUG & NDEBUG_C400_PREAD) - printk("53C400r: About to read %d blocks for %d bytes\n", blocks, len); -#endif - - NCR5380_write(C400_CONTROL_STATUS_REG, CSR_BASE | CSR_TRANS_DIR); - NCR5380_write(C400_BLOCK_COUNTER_REG, blocks); - while (1) { - -#if (NDEBUG & NDEBUG_C400_PREAD) - printk("53C400r: %d blocks left\n", blocks); -#endif - - if ((bl=NCR5380_read(C400_BLOCK_COUNTER_REG)) == 0) { -#if (NDEBUG & NDEBUG_C400_PREAD) - if (blocks) - printk("53C400r: blocks still == %d\n", blocks); - else - printk("53C400r: Exiting loop\n"); -#endif - break; - } - -#if 1 - if (NCR5380_read(C400_CONTROL_STATUS_REG) & CSR_GATED_53C80_IRQ) { - printk("53C400r: Got 53C80_IRQ start=%d, blocks=%d\n", start, blocks); - return -1; - } -#endif - -#if (NDEBUG & NDEBUG_C400_PREAD) - printk("53C400r: Waiting for buffer, bl=%d\n", bl); -#endif - - while (NCR5380_read(C400_CONTROL_STATUS_REG) & CSR_HOST_BUF_NOT_RDY) - ; -#if (NDEBUG & NDEBUG_C400_PREAD) - printk("53C400r: Transferring 128 bytes\n"); -#endif +/** + * NCR5380_pread - pseudo DMA read + * @instance: adapter to read from + * @dst: buffer to read into + * @len: buffer length + * + * Perform a psuedo DMA mode read from an NCR53C400 or equivalent + * controller + */ + +static inline int NCR5380_pread(struct Scsi_Host *instance, unsigned char *dst, int len) +{ + int blocks = len / 128; + int start = 0; + int bl; + + NCR5380_local_declare(); + NCR5380_setup(instance); + + NCR5380_write(C400_CONTROL_STATUS_REG, CSR_BASE | CSR_TRANS_DIR); + NCR5380_write(C400_BLOCK_COUNTER_REG, blocks); + while (1) { + if ((bl = NCR5380_read(C400_BLOCK_COUNTER_REG)) == 0) { + break; + } + if (NCR5380_read(C400_CONTROL_STATUS_REG) & CSR_GATED_53C80_IRQ) { + printk(KERN_ERR "53C400r: Got 53C80_IRQ start=%d, blocks=%d\n", start, blocks); + return -1; + } + while (NCR5380_read(C400_CONTROL_STATUS_REG) & CSR_HOST_BUF_NOT_RDY); #ifdef CONFIG_SCSI_G_NCR5380_PORT - for (i=0; i<128; i++) - dst[start+i] = NCR5380_read(C400_HOST_BUFFER); + { + int i; + for (i = 0; i < 128; i++) + dst[start + i] = NCR5380_read(C400_HOST_BUFFER); + } #else - /* implies CONFIG_SCSI_G_NCR5380_MEM */ - isa_memcpy_fromio(dst+start,NCR53C400_host_buffer+NCR5380_map_name,128); + /* implies CONFIG_SCSI_G_NCR5380_MEM */ + isa_memcpy_fromio(dst + start, NCR53C400_host_buffer + NCR5380_map_name, 128); #endif - start+=128; - blocks--; - } - - if (blocks) { -#if (NDEBUG & NDEBUG_C400_PREAD) - printk("53C400r: EXTRA: Waiting for buffer\n"); -#endif - while (NCR5380_read(C400_CONTROL_STATUS_REG) & CSR_HOST_BUF_NOT_RDY) - ; + start += 128; + blocks--; + } + + if (blocks) { + while (NCR5380_read(C400_CONTROL_STATUS_REG) & CSR_HOST_BUF_NOT_RDY) + { + // FIXME - no timeout + } -#if (NDEBUG & NDEBUG_C400_PREAD) - printk("53C400r: Transferring EXTRA 128 bytes\n"); -#endif #ifdef CONFIG_SCSI_G_NCR5380_PORT - for (i=0; i<128; i++) - dst[start+i] = NCR5380_read(C400_HOST_BUFFER); + { + int i; + for (i = 0; i < 128; i++) + dst[start + i] = NCR5380_read(C400_HOST_BUFFER); + } #else - /* implies CONFIG_SCSI_G_NCR5380_MEM */ - isa_memcpy_fromio(dst+start,NCR53C400_host_buffer+NCR5380_map_name,128); -#endif - start+=128; - blocks--; - } -#if (NDEBUG & NDEBUG_C400_PREAD) - else - printk("53C400r: No EXTRA required\n"); -#endif - -#if (NDEBUG & NDEBUG_C400_PREAD) - printk("53C400r: Final values: blocks=%d start=%d\n", blocks, start); -#endif - - if (!(NCR5380_read(C400_CONTROL_STATUS_REG) & CSR_GATED_53C80_IRQ)) - printk("53C400r: no 53C80 gated irq after transfer"); -#if (NDEBUG & NDEBUG_C400_PREAD) - else - printk("53C400r: Got 53C80 interrupt and tried to clear it\n"); + /* implies CONFIG_SCSI_G_NCR5380_MEM */ + isa_memcpy_fromio(dst + start, NCR53C400_host_buffer + NCR5380_map_name, 128); #endif + start += 128; + blocks--; + } -/* DON'T DO THIS - THEY NEVER ARRIVE! - printk("53C400r: Waiting for 53C80 registers\n"); - while (NCR5380_read(C400_CONTROL_STATUS_REG) & CSR_53C80_REG) - ; -*/ + if (!(NCR5380_read(C400_CONTROL_STATUS_REG) & CSR_GATED_53C80_IRQ)) + printk("53C400r: no 53C80 gated irq after transfer"); - if (!(NCR5380_read(BUS_AND_STATUS_REG) & BASR_END_DMA_TRANSFER)) - printk("53C400r: no end dma signal\n"); -#if (NDEBUG & NDEBUG_C400_PREAD) - else - printk("53C400r: end dma as expected\n"); +#if 0 + /* + * DON'T DO THIS - THEY NEVER ARRIVE! + */ + printk("53C400r: Waiting for 53C80 registers\n"); + while (NCR5380_read(C400_CONTROL_STATUS_REG) & CSR_53C80_REG) + ; #endif - - NCR5380_write(MODE_REG, MR_BASE); - NCR5380_read(RESET_PARITY_INTERRUPT_REG); - return 0; -} + if (!(NCR5380_read(BUS_AND_STATUS_REG) & BASR_END_DMA_TRANSFER)) + printk(KERN_ERR "53C400r: no end dma signal\n"); -static inline int NCR5380_pwrite (struct Scsi_Host *instance, unsigned char *src, int len) -{ - int blocks = len / 128; - int start = 0; - int i; - int bl; - NCR5380_local_declare(); - - NCR5380_setup(instance); - -#if (NDEBUG & NDEBUG_C400_PWRITE) - printk("53C400w: About to write %d blocks for %d bytes\n", blocks, len); -#endif - - NCR5380_write(C400_CONTROL_STATUS_REG, CSR_BASE); - NCR5380_write(C400_BLOCK_COUNTER_REG, blocks); - while (1) { - if (NCR5380_read(C400_CONTROL_STATUS_REG) & CSR_GATED_53C80_IRQ) { - printk("53C400w: Got 53C80_IRQ start=%d, blocks=%d\n", start, blocks); - return -1; - } - - if ((bl=NCR5380_read(C400_BLOCK_COUNTER_REG)) == 0) { -#if (NDEBUG & NDEBUG_C400_PWRITE) - if (blocks) - printk("53C400w: exiting loop, blocks still == %d\n", blocks); - else - printk("53C400w: exiting loop\n"); -#endif - break; - } + NCR5380_write(MODE_REG, MR_BASE); + NCR5380_read(RESET_PARITY_INTERRUPT_REG); + return 0; +} -#if (NDEBUG & NDEBUG_C400_PWRITE) - printk("53C400w: %d blocks left\n", blocks); +/** + * NCR5380_write - pseudo DMA write + * @instance: adapter to read from + * @dst: buffer to read into + * @len: buffer length + * + * Perform a psuedo DMA mode read from an NCR53C400 or equivalent + * controller + */ - printk("53C400w: waiting for buffer, bl=%d\n", bl); -#endif - while (NCR5380_read(C400_CONTROL_STATUS_REG) & CSR_HOST_BUF_NOT_RDY) - ; +static inline int NCR5380_pwrite(struct Scsi_Host *instance, unsigned char *src, int len) +{ + int blocks = len / 128; + int start = 0; + int bl; + int i; + + NCR5380_local_declare(); + NCR5380_setup(instance); + + NCR5380_write(C400_CONTROL_STATUS_REG, CSR_BASE); + NCR5380_write(C400_BLOCK_COUNTER_REG, blocks); + while (1) { + if (NCR5380_read(C400_CONTROL_STATUS_REG) & CSR_GATED_53C80_IRQ) { + printk(KERN_ERR "53C400w: Got 53C80_IRQ start=%d, blocks=%d\n", start, blocks); + return -1; + } -#if (NDEBUG & NDEBUG_C400_PWRITE) - printk("53C400w: transferring 128 bytes\n"); -#endif + if ((bl = NCR5380_read(C400_BLOCK_COUNTER_REG)) == 0) { + break; + } + while (NCR5380_read(C400_CONTROL_STATUS_REG) & CSR_HOST_BUF_NOT_RDY) + ; // FIXME - timeout #ifdef CONFIG_SCSI_G_NCR5380_PORT - for (i=0; i<128; i++) - NCR5380_write(C400_HOST_BUFFER, src[start+i]); + { + for (i = 0; i < 128; i++) + NCR5380_write(C400_HOST_BUFFER, src[start + i]); + } #else - /* implies CONFIG_SCSI_G_NCR5380_MEM */ - isa_memcpy_toio(NCR53C400_host_buffer+NCR5380_map_name,src+start,128); + /* implies CONFIG_SCSI_G_NCR5380_MEM */ + isa_memcpy_toio(NCR53C400_host_buffer + NCR5380_map_name, src + start, 128); #endif - start+=128; - blocks--; - } - if (blocks) { -#if (NDEBUG & NDEBUG_C400_PWRITE) - printk("53C400w: EXTRA waiting for buffer\n"); -#endif - while (NCR5380_read(C400_CONTROL_STATUS_REG) & CSR_HOST_BUF_NOT_RDY) - ; + start += 128; + blocks--; + } + if (blocks) { + while (NCR5380_read(C400_CONTROL_STATUS_REG) & CSR_HOST_BUF_NOT_RDY) + ; // FIXME - no timeout -#if (NDEBUG & NDEBUG_C400_PWRITE) - printk("53C400w: transferring EXTRA 128 bytes\n"); -#endif #ifdef CONFIG_SCSI_G_NCR5380_PORT - for (i=0; i<128; i++) - NCR5380_write(C400_HOST_BUFFER, src[start+i]); + { + for (i = 0; i < 128; i++) + NCR5380_write(C400_HOST_BUFFER, src[start + i]); + } #else - /* implies CONFIG_SCSI_G_NCR5380_MEM */ - isa_memcpy_toio(NCR53C400_host_buffer+NCR5380_map_name,src+start,128); -#endif - start+=128; - blocks--; - } -#if (NDEBUG & NDEBUG_C400_PWRITE) - else - printk("53C400w: No EXTRA required\n"); -#endif - -#if (NDEBUG & NDEBUG_C400_PWRITE) - printk("53C400w: Final values: blocks=%d start=%d\n", blocks, start); + /* implies CONFIG_SCSI_G_NCR5380_MEM */ + isa_memcpy_toio(NCR53C400_host_buffer + NCR5380_map_name, src + start, 128); #endif + start += 128; + blocks--; + } #if 0 - printk("53C400w: waiting for registers to be available\n"); - THEY NEVER DO! - while (NCR5380_read(C400_CONTROL_STATUS_REG) & CSR_53C80_REG) - ; - printk("53C400w: Got em\n"); -#endif - - /* Let's wait for this instead - could be ugly */ - /* All documentation says to check for this. Maybe my hardware is too - * fast. Waiting for it seems to work fine! KLL - */ - while (!(i = NCR5380_read(C400_CONTROL_STATUS_REG) & CSR_GATED_53C80_IRQ)) - ; - - /* - * I know. i is certainly != 0 here but the loop is new. See previous - * comment. - */ - if (i) { -#if (NDEBUG & NDEBUG_C400_PWRITE) - printk("53C400w: got 53C80 gated irq (last block)\n"); -#endif - if (!((i=NCR5380_read(BUS_AND_STATUS_REG)) & BASR_END_DMA_TRANSFER)) - printk("53C400w: No END OF DMA bit - WHOOPS! BASR=%0x\n",i); -#if (NDEBUG & NDEBUG_C400_PWRITE) - else - printk("53C400w: Got END OF DMA\n"); -#endif - } - else - printk("53C400w: no 53C80 gated irq after transfer (last block)\n"); + printk("53C400w: waiting for registers to be available\n"); + THEY NEVER DO ! while (NCR5380_read(C400_CONTROL_STATUS_REG) & CSR_53C80_REG); + printk("53C400w: Got em\n"); +#endif + + /* Let's wait for this instead - could be ugly */ + /* All documentation says to check for this. Maybe my hardware is too + * fast. Waiting for it seems to work fine! KLL + */ + while (!(i = NCR5380_read(C400_CONTROL_STATUS_REG) & CSR_GATED_53C80_IRQ)) + ; // FIXME - no timeout + + /* + * I know. i is certainly != 0 here but the loop is new. See previous + * comment. + */ + if (i) { + if (!((i = NCR5380_read(BUS_AND_STATUS_REG)) & BASR_END_DMA_TRANSFER)) + printk(KERN_ERR "53C400w: No END OF DMA bit - WHOOPS! BASR=%0x\n", i); + } else + printk(KERN_ERR "53C400w: no 53C80 gated irq after transfer (last block)\n"); #if 0 - if (!(NCR5380_read(BUS_AND_STATUS_REG) & BASR_END_DMA_TRANSFER)) { - printk("53C400w: no end dma signal\n"); - } -#endif - -#if (NDEBUG & NDEBUG_C400_PWRITE) - printk("53C400w: waiting for last byte...\n"); -#endif - while (!(NCR5380_read(TARGET_COMMAND_REG) & TCR_LAST_BYTE_SENT)) - ; - -#if (NDEBUG & NDEBUG_C400_PWRITE) - printk("53C400w: got last byte.\n"); - printk("53C400w: pwrite exiting with status 0, whoopee!\n"); + if (!(NCR5380_read(BUS_AND_STATUS_REG) & BASR_END_DMA_TRANSFER)) { + printk(KERN_ERR "53C400w: no end dma signal\n"); + } #endif - return 0; + while (!(NCR5380_read(TARGET_COMMAND_REG) & TCR_LAST_BYTE_SENT)) + ; // TIMEOUT + return 0; } -#endif /* PSEUDO_DMA */ +#endif /* PSEUDO_DMA */ +/* + * Include the NCR5380 core code that we build our driver around + */ + #include "NCR5380.c" #define PRINTP(x) len += sprintf(buffer+len, x) #define ANDP , -static int sprint_opcode(char* buffer, int len, int opcode) { - int start = len; - PRINTP("0x%02x " ANDP opcode); - return len-start; -} - -static int sprint_command (char* buffer, int len, unsigned char *command) { - int i,s,start=len; - len += sprint_opcode(buffer, len, command[0]); - for ( i = 1, s = COMMAND_SIZE(command[0]); i < s; ++i) - PRINTP("%02x " ANDP command[i]); - PRINTP("\n"); - return len-start; -} - -static int sprint_Scsi_Cmnd (char* buffer, int len, Scsi_Cmnd *cmd) { - int start = len; - PRINTP("host number %d destination target %d, lun %d\n" ANDP - cmd->host->host_no ANDP - cmd->target ANDP - cmd->lun); - PRINTP(" command = "); - len += sprint_command (buffer, len, cmd->cmnd); - return len-start; -} - -int generic_NCR5380_proc_info(char* buffer, char** start, off_t offset, int length, int hostno, int inout) -{ - int len = 0; - NCR5380_local_declare(); - unsigned long flags; - unsigned char status; - int i; - struct Scsi_Host *scsi_ptr; - Scsi_Cmnd *ptr; - struct NCR5380_hostdata *hostdata; +static int sprint_opcode(char *buffer, int len, int opcode) +{ + int start = len; + PRINTP("0x%02x " ANDP opcode); + return len - start; +} + +static int sprint_command(char *buffer, int len, unsigned char *command) +{ + int i, s, start = len; + len += sprint_opcode(buffer, len, command[0]); + for (i = 1, s = COMMAND_SIZE(command[0]); i < s; ++i) + PRINTP("%02x " ANDP command[i]); + PRINTP("\n"); + return len - start; +} + +/** + * sprintf_Scsi_Cmnd - print a scsi command + * @buffer: buffr to print into + * @len: buffer length + * @cmd: SCSI command block + * + * Print out the target and command data in hex + */ + +static int sprint_Scsi_Cmnd(char *buffer, int len, Scsi_Cmnd * cmd) +{ + int start = len; + PRINTP("host number %d destination target %d, lun %d\n" ANDP cmd->host->host_no ANDP cmd->target ANDP cmd->lun); + PRINTP(" command = "); + len += sprint_command(buffer, len, cmd->cmnd); + return len - start; +} + +/** + * generic_NCR5380_proc_info - /proc for NCR5380 driver + * @buffer: buffer to print into + * @start: start position + * @offset: offset into buffer + * @len: length + * @hostno: instance to affect + * @inout: read/write + * + * Provide the procfs information for the 5380 controller. We fill + * this with useful debugging information including the commands + * being executed, disconnected command queue and the statistical + * data + * + * Locks: global cli/lock for queue walk + */ + +int generic_NCR5380_proc_info(char *buffer, char **start, off_t offset, int length, int hostno, int inout) +{ + int len = 0; + NCR5380_local_declare(); + unsigned long flags; + unsigned char status; + int i; + struct Scsi_Host *scsi_ptr; + Scsi_Cmnd *ptr; + struct NCR5380_hostdata *hostdata; #ifdef NCR5380_STATS - Scsi_Device *dev; - extern const char *const scsi_device_types[MAX_SCSI_DEVICE_CODE]; + Scsi_Device *dev; + extern const char *const scsi_device_types[MAX_SCSI_DEVICE_CODE]; #endif - save_flags(flags); - cli(); + save_flags(flags); + cli(); - for (scsi_ptr = first_instance; scsi_ptr; scsi_ptr=scsi_ptr->next) - if (scsi_ptr->host_no == hostno) - break; - NCR5380_setup(scsi_ptr); - hostdata = (struct NCR5380_hostdata *)scsi_ptr->hostdata; - - PRINTP("SCSI host number %d : %s\n" ANDP scsi_ptr->host_no ANDP scsi_ptr->hostt->name); - PRINTP("Generic NCR5380 driver version %d\n" ANDP GENERIC_NCR5380_PUBLIC_RELEASE); - PRINTP("NCR5380 core version %d\n" ANDP NCR5380_PUBLIC_RELEASE); + for (scsi_ptr = first_instance; scsi_ptr; scsi_ptr = scsi_ptr->next) + if (scsi_ptr->host_no == hostno) + break; + NCR5380_setup(scsi_ptr); + hostdata = (struct NCR5380_hostdata *) scsi_ptr->hostdata; + + PRINTP("SCSI host number %d : %s\n" ANDP scsi_ptr->host_no ANDP scsi_ptr->hostt->name); + PRINTP("Generic NCR5380 driver version %d\n" ANDP GENERIC_NCR5380_PUBLIC_RELEASE); + PRINTP("NCR5380 core version %d\n" ANDP NCR5380_PUBLIC_RELEASE); #ifdef NCR53C400 - PRINTP("NCR53C400 extension version %d\n" ANDP NCR53C400_PUBLIC_RELEASE); - PRINTP("NCR53C400 card%s detected\n" ANDP (((struct NCR5380_hostdata *)scsi_ptr->hostdata)->flags & FLAG_NCR53C400)?"":" not"); + PRINTP("NCR53C400 extension version %d\n" ANDP NCR53C400_PUBLIC_RELEASE); + PRINTP("NCR53C400 card%s detected\n" ANDP(((struct NCR5380_hostdata *) scsi_ptr->hostdata)->flags & FLAG_NCR53C400) ? "" : " not"); # if NCR53C400_PSEUDO_DMA - PRINTP("NCR53C400 pseudo DMA used\n"); + PRINTP("NCR53C400 pseudo DMA used\n"); # endif #else - PRINTP("NO NCR53C400 driver extensions\n"); + PRINTP("NO NCR53C400 driver extensions\n"); #endif - PRINTP("Using %s mapping at %s 0x%lx, " ANDP STRVAL(NCR5380_map_config) ANDP STRVAL(NCR5380_map_name) ANDP scsi_ptr->NCR5380_instance_name); - if (scsi_ptr->irq == IRQ_NONE) - PRINTP("no interrupt\n"); - else - PRINTP("on interrupt %d\n" ANDP scsi_ptr->irq); + PRINTP("Using %s mapping at %s 0x%lx, " ANDP STRVAL(NCR5380_map_config) ANDP STRVAL(NCR5380_map_name) ANDP scsi_ptr->NCR5380_instance_name); + if (scsi_ptr->irq == IRQ_NONE) + PRINTP("no interrupt\n"); + else + PRINTP("on interrupt %d\n" ANDP scsi_ptr->irq); #ifdef NCR5380_STATS - if (hostdata->connected || hostdata->issue_queue || hostdata->disconnected_queue) - PRINTP("There are commands pending, transfer rates may be crud\n"); - if (hostdata->pendingr) - PRINTP(" %d pending reads" ANDP hostdata->pendingr); - if (hostdata->pendingw) - PRINTP(" %d pending writes" ANDP hostdata->pendingw); - if (hostdata->pendingr || hostdata->pendingw) - PRINTP("\n"); - for (dev = scsi_ptr->host_queue; dev; dev=dev->next) { - unsigned long br = hostdata->bytes_read[dev->id]; - unsigned long bw = hostdata->bytes_write[dev->id]; - long tr = hostdata->time_read[dev->id] / HZ; - long tw = hostdata->time_write[dev->id] / HZ; - - PRINTP(" T:%d %s " ANDP dev->id ANDP (dev->type < MAX_SCSI_DEVICE_CODE) ? scsi_device_types[(int)dev->type] : "Unknown"); - for (i=0; i<8; i++) - if (dev->vendor[i] >= 0x20) - *(buffer+(len++)) = dev->vendor[i]; - *(buffer+(len++)) = ' '; - for (i=0; i<16; i++) - if (dev->model[i] >= 0x20) - *(buffer+(len++)) = dev->model[i]; - *(buffer+(len++)) = ' '; - for (i=0; i<4; i++) - if (dev->rev[i] >= 0x20) - *(buffer+(len++)) = dev->rev[i]; - *(buffer+(len++)) = ' '; - - PRINTP("\n%10ld kb read in %5ld secs" ANDP br/1024 ANDP tr); - if (tr) - PRINTP(" @ %5ld bps" ANDP br / tr); - - PRINTP("\n%10ld kb written in %5ld secs" ANDP bw/1024 ANDP tw); - if (tw) - PRINTP(" @ %5ld bps" ANDP bw / tw); - PRINTP("\n"); - } -#endif - - status = NCR5380_read(STATUS_REG); - if (!(status & SR_REQ)) - PRINTP("REQ not asserted, phase unknown.\n"); - else { - for (i = 0; (phases[i].value != PHASE_UNKNOWN) && - (phases[i].value != (status & PHASE_MASK)); ++i) - ; - PRINTP("Phase %s\n" ANDP phases[i].name); - } - - if (!hostdata->connected) { - PRINTP("No currently connected command\n"); - } else { - len += sprint_Scsi_Cmnd (buffer, len, (Scsi_Cmnd *) hostdata->connected); - } - - PRINTP("issue_queue\n"); - - for (ptr = (Scsi_Cmnd *) hostdata->issue_queue; ptr; - ptr = (Scsi_Cmnd *) ptr->host_scribble) - len += sprint_Scsi_Cmnd (buffer, len, ptr); - - PRINTP("disconnected_queue\n"); - - for (ptr = (Scsi_Cmnd *) hostdata->disconnected_queue; ptr; - ptr = (Scsi_Cmnd *) ptr->host_scribble) - len += sprint_Scsi_Cmnd (buffer, len, ptr); - - *start = buffer + offset; - len -= offset; - if (len > length) - len = length; - restore_flags(flags); - return len; + if (hostdata->connected || hostdata->issue_queue || hostdata->disconnected_queue) + PRINTP("There are commands pending, transfer rates may be crud\n"); + if (hostdata->pendingr) + PRINTP(" %d pending reads" ANDP hostdata->pendingr); + if (hostdata->pendingw) + PRINTP(" %d pending writes" ANDP hostdata->pendingw); + if (hostdata->pendingr || hostdata->pendingw) + PRINTP("\n"); + for (dev = scsi_ptr->host_queue; dev; dev = dev->next) { + unsigned long br = hostdata->bytes_read[dev->id]; + unsigned long bw = hostdata->bytes_write[dev->id]; + long tr = hostdata->time_read[dev->id] / HZ; + long tw = hostdata->time_write[dev->id] / HZ; + + PRINTP(" T:%d %s " ANDP dev->id ANDP(dev->type < MAX_SCSI_DEVICE_CODE) ? scsi_device_types[(int) dev->type] : "Unknown"); + for (i = 0; i < 8; i++) + if (dev->vendor[i] >= 0x20) + *(buffer + (len++)) = dev->vendor[i]; + *(buffer + (len++)) = ' '; + for (i = 0; i < 16; i++) + if (dev->model[i] >= 0x20) + *(buffer + (len++)) = dev->model[i]; + *(buffer + (len++)) = ' '; + for (i = 0; i < 4; i++) + if (dev->rev[i] >= 0x20) + *(buffer + (len++)) = dev->rev[i]; + *(buffer + (len++)) = ' '; + + PRINTP("\n%10ld kb read in %5ld secs" ANDP br / 1024 ANDP tr); + if (tr) + PRINTP(" @ %5ld bps" ANDP br / tr); + + PRINTP("\n%10ld kb written in %5ld secs" ANDP bw / 1024 ANDP tw); + if (tw) + PRINTP(" @ %5ld bps" ANDP bw / tw); + PRINTP("\n"); + } +#endif + + status = NCR5380_read(STATUS_REG); + if (!(status & SR_REQ)) + PRINTP("REQ not asserted, phase unknown.\n"); + else { + for (i = 0; (phases[i].value != PHASE_UNKNOWN) && (phases[i].value != (status & PHASE_MASK)); ++i); + PRINTP("Phase %s\n" ANDP phases[i].name); + } + + if (!hostdata->connected) { + PRINTP("No currently connected command\n"); + } else { + len += sprint_Scsi_Cmnd(buffer, len, (Scsi_Cmnd *) hostdata->connected); + } + + PRINTP("issue_queue\n"); + + for (ptr = (Scsi_Cmnd *) hostdata->issue_queue; ptr; ptr = (Scsi_Cmnd *) ptr->host_scribble) + len += sprint_Scsi_Cmnd(buffer, len, ptr); + + PRINTP("disconnected_queue\n"); + + for (ptr = (Scsi_Cmnd *) hostdata->disconnected_queue; ptr; ptr = (Scsi_Cmnd *) ptr->host_scribble) + len += sprint_Scsi_Cmnd(buffer, len, ptr); + + *start = buffer + offset; + len -= offset; + if (len > length) + len = length; + restore_flags(flags); + return len; } #undef PRINTP #undef ANDP -/* Eventually this will go into an include file, but this will be later */ +/* + * Eventually this will go into an include file, but this will be later + */ static Scsi_Host_Template driver_template = GENERIC_NCR5380; #include <linux/module.h> #include "scsi_module.c" -#ifdef MODULE - MODULE_PARM(ncr_irq, "i"); MODULE_PARM(ncr_dma, "i"); MODULE_PARM(ncr_addr, "i"); @@ -913,65 +898,20 @@ MODULE_PARM(ncr_53c400a, "i"); MODULE_PARM(dtc_3181e, "i"); MODULE_LICENSE("GPL"); -#else - -static int __init do_NCR5380_setup(char *str) -{ - int ints[10]; - - get_options(str, sizeof(ints)/sizeof(int), ints); - generic_NCR5380_setup(str,ints); - - return 1; -} - -static int __init do_NCR53C400_setup(char *str) -{ - int ints[10]; - - get_options(str, sizeof(ints)/sizeof(int), ints); - generic_NCR53C400_setup(str,ints); - return 1; -} - -static int __init do_NCR53C400A_setup(char *str) -{ - int ints[10]; - - get_options(str, sizeof(ints)/sizeof(int), ints); - generic_NCR53C400A_setup(str,ints); - - return 1; -} - -static int __init do_DTC3181E_setup(char *str) -{ - int ints[10]; - - get_options(str, sizeof(ints)/sizeof(int), ints); - generic_DTC3181E_setup(str,ints); - - return 1; -} - -__setup("ncr5380=", do_NCR5380_setup); -__setup("ncr53c400=", do_NCR53C400_setup); -__setup("ncr53c400a=", do_NCR53C400A_setup); -__setup("dtc3181e=", do_DTC3181E_setup); static struct isapnp_device_id id_table[] __devinitdata = { { - ISAPNP_ANY_ID, ISAPNP_ANY_ID, - ISAPNP_VENDOR('D','T','C'), ISAPNP_FUNCTION(0x436e), - 0 - }, + ISAPNP_ANY_ID, ISAPNP_ANY_ID, + ISAPNP_VENDOR('D', 'T', 'C'), ISAPNP_FUNCTION(0x436e), + 0}, {0} }; MODULE_DEVICE_TABLE(isapnp, id_table); -MODULE_LICENSE("GPL"); -#endif - +__setup("ncr5380=", do_NCR5380_setup); +__setup("ncr53c400=", do_NCR53C400_setup); +__setup("ncr53c400a=", do_NCR53C400A_setup); +__setup("dtc3181e=", do_DTC3181E_setup); diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/scsi/g_NCR5380.h linux-2.5/drivers/scsi/g_NCR5380.h --- linux-2.5.1/drivers/scsi/g_NCR5380.h Fri Jul 20 04:08:20 2001 +++ linux-2.5/drivers/scsi/g_NCR5380.h Thu Dec 13 16:32:36 2001 @@ -43,24 +43,18 @@ #define NCR5380_BIOSPARAM NULL #endif -#ifndef ASM int generic_NCR5380_abort(Scsi_Cmnd *); int generic_NCR5380_detect(Scsi_Host_Template *); int generic_NCR5380_release_resources(struct Scsi_Host *); -int generic_NCR5380_queue_command(Scsi_Cmnd *, void (*done)(Scsi_Cmnd *)); +int generic_NCR5380_queue_command(Scsi_Cmnd *, void (*done) (Scsi_Cmnd *)); int generic_NCR5380_reset(Scsi_Cmnd *, unsigned int); -int notyet_generic_proc_info (char *buffer ,char **start, off_t offset, - int length, int hostno, int inout); -const char* generic_NCR5380_info(struct Scsi_Host *); +int notyet_generic_proc_info(char *buffer, char **start, off_t offset, int length, int hostno, int inout); +const char *generic_NCR5380_info(struct Scsi_Host *); #ifdef BIOSPARAM int generic_NCR5380_biosparam(Disk *, kdev_t, int *); #endif -int generic_NCR5380_proc_info(char* buffer, char** start, off_t offset, int length, int hostno, int inout); - -#ifndef NULL -#define NULL 0 -#endif +int generic_NCR5380_proc_info(char *buffer, char **start, off_t offset, int length, int hostno, int inout); #ifndef CMD_PER_LUN #define CMD_PER_LUN 2 @@ -92,19 +86,15 @@ #define STRVAL(x) __STRVAL(x) #ifdef CONFIG_SCSI_G_NCR5380_PORT - #define NCR5380_map_config port - #define NCR5380_map_type int - #define NCR5380_map_name port - #define NCR5380_instance_name io_port - #define NCR53C400_register_offset 0 - #define NCR53C400_address_adjust 8 - +/* + * FIXME: size should be runtime decided + */ #ifdef NCR53C400 #define NCR5380_region_size 16 #else @@ -114,28 +104,19 @@ #define NCR5380_read(reg) (inb(NCR5380_map_name + (reg))) #define NCR5380_write(reg, value) (outb((value), (NCR5380_map_name + (reg)))) -#else +#else /* therefore CONFIG_SCSI_G_NCR5380_MEM */ #define NCR5380_map_config memory - #define NCR5380_map_type unsigned long - #define NCR5380_map_name base - #define NCR5380_instance_name base - #define NCR53C400_register_offset 0x108 - #define NCR53C400_address_adjust 0 - #define NCR53C400_mem_base 0x3880 - #define NCR53C400_host_buffer 0x3900 - #define NCR5380_region_size 0x3a00 - #define NCR5380_read(reg) isa_readb(NCR5380_map_name + NCR53C400_mem_base + (reg)) #define NCR5380_write(reg, value) isa_writeb(NCR5380_map_name + NCR53C400_mem_base + (reg), value) @@ -164,7 +145,5 @@ #define BOARD_NCR53C400A 2 #define BOARD_DTC3181E 3 -#endif /* else def HOSTS_C */ -#endif /* ndef ASM */ -#endif /* GENERIC_NCR5380_H */ - +#endif /* else def HOSTS_C */ +#endif /* GENERIC_NCR5380_H */ diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/scsi/hosts.c linux-2.5/drivers/scsi/hosts.c --- linux-2.5.1/drivers/scsi/hosts.c Sun Dec 16 23:49:23 2001 +++ linux-2.5/drivers/scsi/hosts.c Thu Dec 27 22:10:28 2001 @@ -270,15 +270,6 @@ return retval; } -int -scsi_register_device(struct Scsi_Device_Template * sdpnt) -{ - if(sdpnt->next) panic("Device already registered"); - sdpnt->next = scsi_devicelist; - scsi_devicelist = sdpnt; - return 0; -} - /* * Overrides for Emacs so that we follow Linus's tabbing style. * Emacs will notice this stuff at the end of the file and automatically diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/scsi/hosts.h linux-2.5/drivers/scsi/hosts.h --- linux-2.5.1/drivers/scsi/hosts.h Sun Dec 16 23:46:45 2001 +++ linux-2.5/drivers/scsi/hosts.h Mon Dec 31 21:57:20 2001 @@ -521,17 +521,14 @@ void scsi_initialize_queue(Scsi_Device * SDpnt, struct Scsi_Host * SHpnt); -int scsi_register_device(struct Scsi_Device_Template * sdpnt); -/* These are used by loadable modules */ -extern int scsi_register_module(int, void *); -extern int scsi_unregister_module(int, void *); - -/* The different types of modules that we can load and unload */ -#define MODULE_SCSI_HA 1 -#define MODULE_SCSI_CONST 2 -#define MODULE_SCSI_IOCTL 3 -#define MODULE_SCSI_DEV 4 +/* + * Driver registration/unregistration. + */ +extern int scsi_register_device(struct Scsi_Device_Template *); +extern int scsi_unregister_device(struct Scsi_Device_Template *); +extern int scsi_register_host(Scsi_Host_Template *); +extern int scsi_unregister_host(Scsi_Host_Template *); /* diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/scsi/ide-scsi.c linux-2.5/drivers/scsi/ide-scsi.c --- linux-2.5.1/drivers/scsi/ide-scsi.c Tue Dec 11 17:44:13 2001 +++ linux-2.5/drivers/scsi/ide-scsi.c Thu Dec 27 22:32:17 2001 @@ -50,7 +50,6 @@ #include "scsi.h" #include "hosts.h" #include "sd.h" -#include "ide-scsi.h" #include <scsi/sg.h> #define IDESCSI_DEBUG_LOG 0 @@ -840,13 +839,29 @@ return 0; } -static Scsi_Host_Template idescsi_template = IDESCSI; +static Scsi_Host_Template idescsi_template = { + module: THIS_MODULE, + name: "idescsi", + detect: idescsi_detect, + release: idescsi_release, + info: idescsi_info, + ioctl: idescsi_ioctl, + queuecommand: idescsi_queue, + abort: idescsi_abort, + reset: idescsi_reset, + bios_param: idescsi_bios, + can_queue: 10, + this_id: -1, + sg_tablesize: 256, + cmd_per_lun: 5, + use_clustering: DISABLE_CLUSTERING, + emulated: 1, +}; static int __init init_idescsi_module(void) { idescsi_init(); - idescsi_template.module = THIS_MODULE; - scsi_register_module (MODULE_SCSI_HA, &idescsi_template); + scsi_register_host(&idescsi_template); return 0; } @@ -856,7 +871,7 @@ byte media[] = {TYPE_DISK, TYPE_TAPE, TYPE_PROCESSOR, TYPE_WORM, TYPE_ROM, TYPE_SCANNER, TYPE_MOD, 255}; int i, failed; - scsi_unregister_module (MODULE_SCSI_HA, &idescsi_template); + scsi_unregister_host(&idescsi_template); for (i = 0; media[i] != 255; i++) { failed = 0; while ((drive = ide_scan_devices (media[i], idescsi_driver.name, &idescsi_driver, failed)) != NULL) diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/scsi/mac_scsi.c linux-2.5/drivers/scsi/mac_scsi.c --- linux-2.5.1/drivers/scsi/mac_scsi.c Sun Nov 12 03:01:11 2000 +++ linux-2.5/drivers/scsi/mac_scsi.c Sun Dec 30 20:01:41 2001 @@ -353,7 +353,7 @@ NCR5380_write( INITIATOR_COMMAND_REG, ICR_BASE ); NCR5380_read( RESET_PARITY_INTERRUPT_REG ); - for( end = jiffies + AFTER_RESET_DELAY; jiffies < end; ) + for( end = jiffies + AFTER_RESET_DELAY; time_before(jiffies, end); ) barrier(); /* switch on SCSI IRQ again */ diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/scsi/megaraid.c linux-2.5/drivers/scsi/megaraid.c --- linux-2.5.1/drivers/scsi/megaraid.c Tue Nov 27 17:23:27 2001 +++ linux-2.5/drivers/scsi/megaraid.c Thu Dec 27 22:10:28 2001 @@ -4290,26 +4290,18 @@ static int mega_partsize(Disk * disk, kdev_t dev, int *geom) { - struct buffer_head *bh; struct partition *p, *largest = NULL; int i, largest_cyl; int heads, cyls, sectors; int capacity = disk->capacity; + unsigned char *buf; - int ma = MAJOR(dev); - int mi = (MINOR(dev) & ~0xf); - - int block = 1024; - - if(blksize_size[ma]) - block = blksize_size[ma][mi]; - - if(!(bh = bread(MKDEV(ma,mi), 0, block))) + if (!(buf = scsi_bios_ptable(dev))) return -1; - if( *(unsigned short *)(bh->b_data + 510) == 0xAA55 ) { + if( *(unsigned short *)(buf + 64) == 0xAA55 ) { - for( largest_cyl = -1, p = (struct partition *)(0x1BE + bh->b_data), + for( largest_cyl = -1, p = (struct partition *)buf, i = 0; i < 4; ++i, ++p) { if (!p->sys_ind) continue; @@ -4328,7 +4320,7 @@ sectors = largest->end_sector & 0x3f; if (heads == 0 || sectors == 0) { - brelse(bh); + kfree(buf); return -1; } @@ -4338,11 +4330,11 @@ geom[1] = sectors; geom[2] = cyls; - brelse(bh); + kfree(buf); return 0; } - brelse(bh); + kfree(buf); return -1; } diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/scsi/ncr53c8xx.c linux-2.5/drivers/scsi/ncr53c8xx.c --- linux-2.5.1/drivers/scsi/ncr53c8xx.c Sun Dec 16 20:20:20 2001 +++ linux-2.5/drivers/scsi/ncr53c8xx.c Mon Dec 17 01:03:06 2001 @@ -8626,9 +8626,9 @@ if (DEBUG_FLAGS & DEBUG_TINY) printk ("]\n"); if (done_list) { - NCR_LOCK_SCSI_DONE(np, flags); + NCR_LOCK_SCSI_DONE(done_list->host, flags); ncr_flush_done_cmds(done_list); - NCR_UNLOCK_SCSI_DONE(np, flags); + NCR_UNLOCK_SCSI_DONE(done_list->host, flags); } } @@ -8649,9 +8649,9 @@ NCR_UNLOCK_NCB(np, flags); if (done_list) { - NCR_LOCK_SCSI_DONE(np, flags); + NCR_LOCK_SCSI_DONE(done_list->host, flags); ncr_flush_done_cmds(done_list); - NCR_UNLOCK_SCSI_DONE(np, flags); + NCR_UNLOCK_SCSI_DONE(done_list->host, flags); } } diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/scsi/osst.c linux-2.5/drivers/scsi/osst.c --- linux-2.5.1/drivers/scsi/osst.c Tue Nov 13 17:19:41 2001 +++ linux-2.5/drivers/scsi/osst.c Thu Dec 27 22:10:28 2001 @@ -16,15 +16,15 @@ Copyright 1992 - 2000 Kai Makisara email Kai.Makisara@metla.fi - $Header: /home/cvsroot/Driver/osst.c,v 1.61 2001/06/03 21:55:12 riede Exp $ + $Header: /home/cvsroot/Driver/osst.c,v 1.65 2001/11/11 20:38:56 riede Exp $ Microscopic alterations - Rik Ling, 2000/12/21 Last modified: Wed Feb 2 22:04:05 2000 by makisara@kai.makisara.local Some small formal changes - aeb, 950809 */ -static const char * cvsid = "$Id: osst.c,v 1.61 2001/06/03 21:55:12 riede Exp $"; -const char * osst_version = "0.9.8"; +static const char * cvsid = "$Id: osst.c,v 1.65 2001/11/11 20:38:56 riede Exp $"; +const char * osst_version = "0.9.10"; /* The "failure to reconnect" firmware bug */ #define OSST_FW_NEED_POLL_MIN 10601 /*(107A)*/ @@ -159,6 +159,7 @@ struct Scsi_Device_Template osst_template = { + module: THIS_MODULE, name: "OnStream tape", tag: "osst", scsi_type: TYPE_TAPE, @@ -225,20 +226,20 @@ SRpnt->sr_cmnd[0] != MODE_SENSE && SRpnt->sr_cmnd[0] != TEST_UNIT_READY)) { /* Abnormal conditions for tape */ if (driver_byte(result) & DRIVER_SENSE) { - printk(KERN_WARNING "osst%d:W: Error with sense data: ", dev); - print_req_sense("osst", SRpnt); + printk(KERN_WARNING "osst%d:W: Command with sense data: ", dev); + print_req_sense("osst:", SRpnt); } else { static int notyetprinted = 1; printk(KERN_WARNING - "osst%d:W: Error %x (sugg. bt 0x%x, driver bt 0x%x, host bt 0x%x).\n", + "osst%d:W: Warning %x (sugg. bt 0x%x, driver bt 0x%x, host bt 0x%x).\n", dev, result, suggestion(result), driver_byte(result) & DRIVER_MASK, host_byte(result)); if (notyetprinted) { notyetprinted = 0; printk(KERN_INFO - "osst%d:I: This error may be caused by your scsi controller,\n", dev); + "osst%d:I: This warning may be caused by your scsi controller,\n", dev); printk(KERN_INFO "osst%d:I: it has been reported with some Buslogic cards.\n", dev); } @@ -270,11 +271,10 @@ /* Wakeup from interrupt */ static void osst_sleep_done (Scsi_Cmnd * SCpnt) { - unsigned int dev; + unsigned int dev = TAPE_NR(SCpnt->request.rq_dev); OS_Scsi_Tape * STp; - if ((dev = TAPE_NR(SCpnt->request.rq_dev)) < osst_template.nr_dev) { - STp = os_scsi_tapes[dev]; + if (os_scsi_tapes && (STp = os_scsi_tapes[dev])) { if ((STp->buffer)->writing && (SCpnt->sense_buffer[0] & 0x70) == 0x70 && (SCpnt->sense_buffer[2] & 0x40)) { @@ -480,7 +480,8 @@ for (i=0; i < STp->buffer->sg_segs; i++) memset(STp->buffer->sg[i].address, 0, STp->buffer->sg[i].length); strcpy(STp->buffer->b_data, "READ ERROR ON FRAME"); - } + } else + STp->buffer->buffer_bytes = OS_FRAME_SIZE; return 1; } if (STp->buffer->syscall_result) { @@ -619,8 +620,10 @@ if (!SRpnt) return (-EBUSY); while ( STp->buffer->syscall_result && time_before(jiffies, startwait + timeout*HZ) && - SRpnt->sr_sense_buffer[2] == 2 && SRpnt->sr_sense_buffer[12] == 4 && - (SRpnt->sr_sense_buffer[13] == 1 || SRpnt->sr_sense_buffer[13] == 8) ) { + (( SRpnt->sr_sense_buffer[2] == 2 && SRpnt->sr_sense_buffer[12] == 4 && + (SRpnt->sr_sense_buffer[13] == 1 || SRpnt->sr_sense_buffer[13] == 8) ) || + ( SRpnt->sr_sense_buffer[2] == 6 && SRpnt->sr_sense_buffer[12] == 0x28 && + SRpnt->sr_sense_buffer[13] == 0 ) )) { #if DEBUG if (debugging) { printk(OSST_DEB_MSG "osst%d:D: Sleeping in onstream wait ready\n", dev); @@ -628,7 +631,7 @@ debugging = 0; } #endif - current->state = TASK_INTERRUPTIBLE; + set_current_state(TASK_INTERRUPTIBLE); schedule_timeout(HZ / 10); memset(cmd, 0, MAX_COMMAND_SIZE); @@ -656,6 +659,66 @@ return 0; } +/* + * Wait for a tape to be inserted in the unit + */ +static int osst_wait_for_medium(OS_Scsi_Tape * STp, Scsi_Request ** aSRpnt, unsigned timeout) +{ + unsigned char cmd[MAX_COMMAND_SIZE]; + Scsi_Request * SRpnt; + long startwait = jiffies; +#if DEBUG + int dbg = debugging; + int dev = TAPE_NR(STp->devt); + + printk(OSST_DEB_MSG "osst%d:D: Reached onstream wait for medium\n", dev); +#endif + + memset(cmd, 0, MAX_COMMAND_SIZE); + cmd[0] = TEST_UNIT_READY; + + SRpnt = osst_do_scsi(*aSRpnt, STp, cmd, 0, SCSI_DATA_NONE, STp->timeout, MAX_READY_RETRIES, TRUE); + *aSRpnt = SRpnt; + if (!SRpnt) return (-EBUSY); + + while ( STp->buffer->syscall_result && time_before(jiffies, startwait + timeout*HZ) && + SRpnt->sr_sense_buffer[2] == 2 && SRpnt->sr_sense_buffer[12] == 0x3a && + SRpnt->sr_sense_buffer[13] == 0 ) { +#if DEBUG + if (debugging) { + printk(OSST_DEB_MSG "osst%d:D: Sleeping in onstream wait medium\n", dev); + printk(OSST_DEB_MSG "osst%d:D: Turning off debugging for a while\n", dev); + debugging = 0; + } +#endif + set_current_state(TASK_INTERRUPTIBLE); + schedule_timeout(HZ / 10); + + memset(cmd, 0, MAX_COMMAND_SIZE); + cmd[0] = TEST_UNIT_READY; + + SRpnt = osst_do_scsi(SRpnt, STp, cmd, 0, SCSI_DATA_NONE, STp->timeout, MAX_READY_RETRIES, TRUE); + } + *aSRpnt = SRpnt; +#if DEBUG + debugging = dbg; +#endif + if ( STp->buffer->syscall_result && SRpnt->sr_sense_buffer[2] != 2 && + SRpnt->sr_sense_buffer[12] != 4 && SRpnt->sr_sense_buffer[13] == 1) { +#if DEBUG + printk(OSST_DEB_MSG "osst%d:D: Abnormal exit from onstream wait medium\n", dev); + printk(OSST_DEB_MSG "osst%d:D: Result = %d, Sense: 0=%02x, 2=%02x, 12=%02x, 13=%02x\n", dev, + STp->buffer->syscall_result, SRpnt->sr_sense_buffer[0], SRpnt->sr_sense_buffer[2], + SRpnt->sr_sense_buffer[12], SRpnt->sr_sense_buffer[13]); +#endif + return 0; + } +#if DEBUG + printk(OSST_DEB_MSG "osst%d:D: Normal exit from onstream wait medium\n", dev); +#endif + return 1; +} + static int osst_position_tape_and_confirm(OS_Scsi_Tape * STp, Scsi_Request ** aSRpnt, int frame) { int retval; @@ -694,7 +757,7 @@ result = osst_write_error_recovery(STp, aSRpnt, 0); result |= osst_wait_ready(STp, aSRpnt, 5 * 60); - STp->ps[STp->partition].rw = ST_IDLE; + STp->ps[STp->partition].rw = OS_WRITING_COMPLETE; return (result); } @@ -743,7 +806,7 @@ notyetprinted--; } #endif - current->state = TASK_INTERRUPTIBLE; + set_current_state(TASK_INTERRUPTIBLE); schedule_timeout (HZ / OSST_POLL_PER_SEC); } #if DEBUG @@ -901,6 +964,8 @@ #endif if ( osst_initiate_read(STp, aSRpnt) || ( (!STp->frame_in_buffer) && osst_read_frame(STp, aSRpnt, 30) ) ) { + if (STp->raw) + return (-EIO); position = osst_get_frame_position(STp, aSRpnt); if (position >= 0xbae && position < 0xbb8) position = 0xbb8; @@ -966,7 +1031,7 @@ if (cnt > 1) { STp->recover_count++; STp->recover_erreg++; - printk(KERN_WARNING "osst%d:I: Read error at position %d recovered\n", + printk(KERN_WARNING "osst%d:I: Don't worry, Read error at position %d recovered\n", dev, STp->read_error_frame); } STp->read_count++; @@ -1523,7 +1588,10 @@ retval = osst_reposition_and_retry(STp, aSRpnt, frame, skip, pending); else retval = osst_read_back_buffer_and_rewrite(STp, aSRpnt, frame, skip, pending); - printk(KERN_WARNING "osst%d:I: Write error%srecovered\n", dev, retval?" not ":" "); + printk(KERN_WARNING "osst%d:%s: %sWrite error%srecovered\n", dev, + retval?"E" :"I", + retval?"" :"Don't worry, ", + retval?" not ":" "); break; case OS_WRITE_LAST_MARK: printk(KERN_ERR "osst%d:E: Bad frame in update last marker, fatal\n", dev); @@ -1594,7 +1662,7 @@ mt_count, last_mark_ppos); #endif if (last_mark_ppos > 10 && last_mark_ppos < STp->eod_frame_ppos) { - osst_set_frame_position(STp, aSRpnt, last_mark_ppos, 0); + osst_position_tape_and_confirm(STp, aSRpnt, last_mark_ppos); if (osst_get_logical_frame(STp, aSRpnt, -1, 0) < 0) { #if DEBUG printk(OSST_DEB_MSG @@ -1626,7 +1694,7 @@ #if DEBUG printk(OSST_DEB_MSG "osst%d:D: Positioning to last mark at %d\n", dev, last_mark_ppos); #endif - osst_set_frame_position(STp, aSRpnt, last_mark_ppos, 0); + osst_position_tape_and_confirm(STp, aSRpnt, last_mark_ppos); cnt++; if (osst_get_logical_frame(STp, aSRpnt, -1, 0) < 0) { #if DEBUG @@ -1753,7 +1821,7 @@ #endif return osst_space_over_filemarks_forward_slow(STp, aSRpnt, mt_op, mt_count); } else { - osst_set_frame_position(STp, aSRpnt, next_mark_ppos, 0); + osst_position_tape_and_confirm(STp, aSRpnt, next_mark_ppos); if (osst_get_logical_frame(STp, aSRpnt, -1, 0) < 0) { #if DEBUG printk(OSST_DEB_MSG "osst%d:D: Couldn't get logical blk num in space_filemarks\n", @@ -1793,7 +1861,7 @@ #endif return osst_space_over_filemarks_forward_slow(STp, aSRpnt, mt_op, mt_count); } - osst_set_frame_position(STp, aSRpnt, STp->first_mark_ppos, 0); + osst_position_tape_and_confirm(STp, aSRpnt, STp->first_mark_ppos); if (osst_get_logical_frame(STp, aSRpnt, -1, 0) < 0) { #if DEBUG printk(OSST_DEB_MSG @@ -1825,7 +1893,7 @@ #if DEBUG else printk(OSST_DEB_MSG "osst%d:D: Positioning to next mark at %d\n", dev, next_mark_ppos); #endif - osst_set_frame_position(STp, aSRpnt, next_mark_ppos, 0); + osst_position_tape_and_confirm(STp, aSRpnt, next_mark_ppos); cnt++; if (osst_get_logical_frame(STp, aSRpnt, -1, 0) < 0) { #if DEBUG @@ -2462,7 +2530,7 @@ } #if DEBUG - printk(KERN_INFO "osst%d:D: Block Size changed to 32.5K\n", dev); + printk(KERN_INFO "osst%d:D: Drive Block Size changed to 32.5K\n", dev); /* * In debug mode, we want to see as many errors as possible * to test the error recovery mechanism. @@ -3400,6 +3468,7 @@ if (retval) goto out; STps->rw = ST_IDLE; + /* FIXME -- this may leave the tape without EOD and up2date headers */ } if ((count % STp->block_size) != 0) { @@ -3812,6 +3881,10 @@ ioctl_result = osst_flush_write_buffer(STp, &SRpnt); else ioctl_result = 0; +#if DEBUG + if (debugging) + printk(OSST_DEB_MSG "osst%d:D: Writing %ld filemark(s).\n", dev, arg); +#endif for (i=0; i<arg; i++) ioctl_result |= osst_write_filemark(STp, &SRpnt); if (fileno >= 0) fileno += arg; @@ -3831,14 +3904,9 @@ cmd[4] = arg; timeout = STp->timeout; #if DEBUG - if (debugging) { - if (cmd_in == MTWEOF) - printk(OSST_DEB_MSG "osst%d:D: Writing %d filemarks.\n", dev, - cmd[2] * 65536 + cmd[3] * 256 + cmd[4]); - else - printk(OSST_DEB_MSG "osst%d:D: Writing %d setmarks.\n", dev, + if (debugging) + printk(OSST_DEB_MSG "osst%d:D: Writing %d setmark(s).\n", dev, cmd[2] * 65536 + cmd[3] * 256 + cmd[4]); - } #endif if (fileno >= 0) fileno += arg; @@ -3851,8 +3919,12 @@ case MTRETEN: cmd[0] = START_STOP; cmd[1] = 1; /* Don't wait for completion */ - if (cmd_in == MTLOAD) + if (cmd_in == MTLOAD) { + if (STp->ready == ST_NO_TAPE) + cmd[4] = 4; /* open tray */ + else cmd[4] = 1; /* load */ + } if (cmd_in == MTRETEN) cmd[4] = 3; /* retension then mount */ if (cmd_in == MTOFFL) @@ -3991,7 +4063,7 @@ printk(OSST_DEB_MSG "osst%d:D: IOCTL (%d) Result=%d\n", dev, cmd_in, ioctl_result); #endif - if (!ioctl_result) { + if (!ioctl_result) { /* success */ if (cmd_in == MTFSFM) { fileno--; @@ -4068,6 +4140,8 @@ if (cmd_in == MTLOCK) STp->door_locked = ST_LOCK_FAILS; + if (cmd_in == MTLOAD && osst_wait_for_medium(STp, &SRpnt, 60)) + ioctl_result = osst_wait_ready(STp, &SRpnt, 5 * 60); } *aSRpnt = SRpnt; @@ -4108,6 +4182,7 @@ __MOD_INC_USE_COUNT(STp->device->host->hostt->module); if (osst_template.module) __MOD_INC_USE_COUNT(osst_template.module); + STp->device->access_count++; if (mode != STp->current_mode) { #if DEBUG @@ -4124,6 +4199,8 @@ STp->write_prot = ((flags & O_ACCMODE) == O_RDONLY); STp->raw = (MINOR(inode->i_rdev) & 0x40) != 0; + if (STp->raw) + STp->header_ok = 0; /* Allocate a buffer for this user */ need_dma_buffer = STp->restr_dma; @@ -4214,7 +4291,7 @@ STp->nbr_partitions = 1; /* This guess will be updated later if necessary */ for (i=0; i < ST_NBR_PARTITIONS; i++) { STps = &(STp->ps[i]); - STps->rw = ST_IDLE; /* FIXME - seems to be redundant... */ + STps->rw = ST_IDLE; /* FIXME - seems to be redundant... */ STps->eof = ST_NOEOF; STps->at_sm = 0; STps->last_block_valid = FALSE; @@ -4262,8 +4339,8 @@ STp->door_locked = ST_LOCKED_AUTO; } if (!STp->frame_in_buffer) { - STp->block_size = (STp->raw) ? OS_FRAME_SIZE : ( - (STm->default_blksize > 0) ? STm->default_blksize : OS_DATA_SIZE); + STp->block_size = (STm->default_blksize > 0) ? + STm->default_blksize : OS_DATA_SIZE; STp->buffer->buffer_bytes = STp->buffer->read_pointer = 0; } STp->buffer->buffer_blocks = OS_DATA_SIZE / STp->block_size; @@ -4356,8 +4433,6 @@ return 0; } - STp->min_block = STp->max_block = (-1); - osst_configure_onstream(STp, &SRpnt); /* STp->drv_write_prot = ((STp->buffer)->b_data[2] & 0x80) != 0; FIXME */ @@ -4384,11 +4459,9 @@ } else STp->buffer->aux = NULL; /* this had better never happen! */ - STp->block_size = (STp->raw) ? OS_FRAME_SIZE : ( + STp->block_size = STp->raw ? OS_FRAME_SIZE : ( (STm->default_blksize > 0) ? STm->default_blksize : OS_DATA_SIZE); - STp->min_block = 512; - STp->max_block = OS_DATA_SIZE; - STp->buffer->buffer_blocks = OS_DATA_SIZE / STp->block_size; + STp->buffer->buffer_blocks = STp->raw ? 1 : OS_DATA_SIZE / STp->block_size; STp->buffer->buffer_bytes = STp->buffer->read_pointer = STp->frame_in_buffer = 0; @@ -4446,6 +4519,8 @@ STp->buffer = NULL; } STp->in_use = 0; + STp->header_ok = 0; + STp->device->access_count--; if (STp->device->host->hostt->module) __MOD_DEC_USE_COUNT(STp->device->host->hostt->module); @@ -4482,7 +4557,7 @@ if (result != 0 && result != (-ENOSPC)) goto out; } - if ( STps->rw == ST_WRITING && !(STp->device)->was_reset) { + if ( STps->rw >= ST_WRITING && !(STp->device)->was_reset) { #if DEBUG if (debugging) { @@ -4492,16 +4567,17 @@ dev, STp->nbr_waits, STp->nbr_finished); } #endif + if (STp->write_type != OS_WRITE_NEW_MARK) { + /* true unless the user wrote the filemark for us */ + result = osst_flush_drive_buffer(STp, &SRpnt); + if (result < 0) goto out; + result = osst_write_filemark(STp, &SRpnt); + if (result < 0) goto out; - result = osst_flush_drive_buffer(STp, &SRpnt); - if (result < 0) goto out; - result = osst_write_filemark(STp, &SRpnt); - if (result < 0) goto out; - - if (STps->drv_file >= 0) - STps->drv_file++ ; - STps->drv_block = 0; - + if (STps->drv_file >= 0) + STps->drv_file++ ; + STps->drv_block = 0; + } result = osst_write_eod(STp, &SRpnt); osst_write_header(STp, &SRpnt, !(STp->rew_at_close)); @@ -4585,7 +4661,12 @@ if (STp->buffer != NULL) STp->buffer->in_use = 0; + if (STp->raw) + STp->header_ok = 0; + STp->in_use = 0; + STp->device->access_count--; + if (STp->device->host->hostt->module) __MOD_DEC_USE_COUNT(STp->device->host->hostt->module); if(osst_template.module) @@ -4635,7 +4716,10 @@ cmd_type = _IOC_TYPE(cmd_in); cmd_nr = _IOC_NR(cmd_in); - +#if DEBUG + printk(OSST_DEB_MSG "osst%d:D: Ioctl %d,%d in %s mode\n", dev, + cmd_type, cmd_nr, STp->raw?"raw":"normal"); +#endif if (cmd_type == _IOC_TYPE(MTIOCTOP) && cmd_nr == _IOC_NR(MTIOCTOP)) { struct mtop mtc; @@ -4718,8 +4802,8 @@ } } - if (mtc.mt_op != MTNOP && mtc.mt_op != MTSETBLK && - mtc.mt_op != MTSETDENSITY && mtc.mt_op != MTWSM && + if (mtc.mt_op != MTNOP && mtc.mt_op != MTWEOF && mtc.mt_op != MTWSM && + mtc.mt_op != MTSETDENSITY && mtc.mt_op != MTSETBLK && mtc.mt_op != MTSETDRVBUFFER && mtc.mt_op != MTSETPART) STps->rw = ST_IDLE; /* Prevent automatic WEOF and fsf */ @@ -4771,7 +4855,10 @@ } if (mtc.mt_op == MTSEEK) { - i = osst_seek_sector(STp, &SRpnt, mtc.mt_count); + if (STp->raw) + i = osst_set_frame_position(STp, &SRpnt, mtc.mt_count, 0); + else + i = osst_seek_sector(STp, &SRpnt, mtc.mt_count); if (!STp->can_partitions) STp->ps[0].rw = ST_IDLE; retval = i; @@ -4876,7 +4963,10 @@ retval = (-EINVAL); goto out; } - blk = osst_get_sector(STp, &SRpnt); + if (STp->raw) + blk = osst_get_frame_position(STp, &SRpnt); + else + blk = osst_get_sector(STp, &SRpnt); if (blk < 0) { retval = blk; goto out; @@ -4971,7 +5061,7 @@ tb = NULL; break; } - tb->sg[segs].page = NULL; + tb->sg[segs].page = NULL; tb->sg[segs].length = b_size; got += b_size; segs++; @@ -5423,6 +5513,8 @@ tpnt->partition = 0; tpnt->new_partition = 0; tpnt->nbr_partitions = 0; + tpnt->min_block = 512; + tpnt->max_block = OS_DATA_SIZE; tpnt->timeout = OSST_TIMEOUT; tpnt->long_timeout = OSST_LONG_TIMEOUT; @@ -5462,6 +5554,7 @@ tpnt->current_mode = 0; tpnt->modes[0].defined = TRUE; + tpnt->modes[2].defined = TRUE; tpnt->density_changed = tpnt->compression_changed = tpnt->blksize_changed = FALSE; init_MUTEX(&tpnt->lock); @@ -5583,8 +5676,7 @@ static int __init init_osst(void) { validate_options(); - osst_template.module = THIS_MODULE; - return scsi_register_module(MODULE_SCSI_DEV, &osst_template); + return scsi_register_device(&osst_template); } static void __exit exit_osst (void) @@ -5592,7 +5684,7 @@ int i; OS_Scsi_Tape * STp; - scsi_unregister_module(MODULE_SCSI_DEV, &osst_template); + scsi_unregister_device(&osst_template); #ifdef CONFIG_DEVFS_FS devfs_unregister_chrdev(MAJOR_NR, "osst"); #else diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/scsi/osst.h linux-2.5/drivers/scsi/osst.h --- linux-2.5.1/drivers/scsi/osst.h Fri Jul 20 04:18:00 2001 +++ linux-2.5/drivers/scsi/osst.h Thu Dec 13 16:32:36 2001 @@ -1,5 +1,5 @@ /* - * $Header: /home/cvsroot/Driver/osst.h,v 1.11 2001/01/26 01:54:49 riede Exp $ + * $Header: /home/cvsroot/Driver/osst.h,v 1.12 2001/10/11 00:30:15 riede Exp $ */ #include <asm/byteorder.h> @@ -638,3 +638,5 @@ #define OS_WRITE_HEADER 4 #define OS_WRITE_FILLER 5 +/* Additional rw state */ +#define OS_WRITING_COMPLETE 3 diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/scsi/pas16.c linux-2.5/drivers/scsi/pas16.c --- linux-2.5.1/drivers/scsi/pas16.c Sun Sep 30 19:26:07 2001 +++ linux-2.5/drivers/scsi/pas16.c Thu Dec 13 16:32:36 2001 @@ -1,7 +1,7 @@ #define AUTOSENSE #define PSEUDO_DMA -#define FOO -#define UNSAFE /* Not unsafe for PAS16 -- use it */ +#define BOARD_REQUIRES_NO_UDELAY /* PAS16 needs no I/O recovery delays */ +#define UNSAFE /* Not unsafe for PAS16 -- use it */ /* * This driver adapted from Drew Eckhardt's Trantor T128 driver @@ -52,8 +52,6 @@ * * PARITY - enable parity checking. Not supported. * - * SCSI2 - enable support for SCSI-II tagged queueing. Untested. - * * UNSAFE - leave interrupts enabled during pseudo-DMA transfers. This * parameter comes from the NCR5380 code. It is NOT unsafe with * the PAS16 and you should use it. If you don't you will have @@ -62,8 +60,6 @@ * want to use UNSAFE you can try defining LIMIT_TRANSFERSIZE or * twiddle with the transfer size in the high level code. * - * USLEEP - enable support for devices that don't disconnect. Untested. - * * The card is detected and initialized in one of several ways : * 1. Autoprobe (default) - There are many different models of * the Pro Audio Spectrum/Studio 16, and I only have one of @@ -109,7 +105,7 @@ * * (IRQ_AUTO == 254, IRQ_NONE == 255 in NCR5380.h) */ - + #include <linux/module.h> #include <asm/system.h> @@ -133,467 +129,402 @@ static int pas_wmaxi = 0; static unsigned short pas16_addr = 0; static int pas16_irq = 0; - -int scsi_irq_translate[] = - { 0, 0, 1, 2, 3, 4, 5, 6, 0, 0, 7, 8, 9, 0, 10, 11 }; +static int scsi_irq_translate[] = { 0, 0, 1, 2, 3, 4, 5, 6, 0, 0, 7, 8, 9, 0, 10, 11 }; /* The default_irqs array contains values used to set the irq into the * board via software (as must be done on newer model boards without * irq jumpers on the board). The first value in the array will be * assigned to logical board 0, the next to board 1, etc. */ -int default_irqs[] __initdata = - { PAS16_DEFAULT_BOARD_1_IRQ, - PAS16_DEFAULT_BOARD_2_IRQ, - PAS16_DEFAULT_BOARD_3_IRQ, - PAS16_DEFAULT_BOARD_4_IRQ - }; + +static int default_irqs[] __initdata = { + PAS16_DEFAULT_BOARD_1_IRQ, + PAS16_DEFAULT_BOARD_2_IRQ, + PAS16_DEFAULT_BOARD_3_IRQ, + PAS16_DEFAULT_BOARD_4_IRQ +}; static struct override { - unsigned short io_port; - int irq; -} overrides + unsigned short io_port; + int irq; +} overrides #ifdef PAS16_OVERRIDE - [] __initdata = PAS16_OVERRIDE; +[] __initdata = PAS16_OVERRIDE; #else - [4] __initdata = {{0,IRQ_AUTO}, {0,IRQ_AUTO}, {0,IRQ_AUTO}, - {0,IRQ_AUTO}}; +[4] __initdata = { + {0, IRQ_AUTO}, + {0, IRQ_AUTO}, + {0, IRQ_AUTO}, + {0, IRQ_AUTO} +}; #endif #define NO_OVERRIDES (sizeof(overrides) / sizeof(struct override)) static struct base { - unsigned short io_port; - int noauto; -} bases[] __initdata = - { {PAS16_DEFAULT_BASE_1, 0}, - {PAS16_DEFAULT_BASE_2, 0}, - {PAS16_DEFAULT_BASE_3, 0}, - {PAS16_DEFAULT_BASE_4, 0} - }; + unsigned short io_port; + int noauto; +} bases[] __initdata = { + {PAS16_DEFAULT_BASE_1, 0}, + {PAS16_DEFAULT_BASE_2, 0}, + {PAS16_DEFAULT_BASE_3, 0}, + {PAS16_DEFAULT_BASE_4, 0} +}; #define NO_BASES (sizeof (bases) / sizeof (struct base)) -unsigned short pas16_offset[ 8 ] = - { - 0x1c00, /* OUTPUT_DATA_REG */ - 0x1c01, /* INITIATOR_COMMAND_REG */ - 0x1c02, /* MODE_REG */ - 0x1c03, /* TARGET_COMMAND_REG */ - 0x3c00, /* STATUS_REG ro, SELECT_ENABLE_REG wo */ - 0x3c01, /* BUS_AND_STATUS_REG ro, START_DMA_SEND_REG wo */ - 0x3c02, /* INPUT_DATA_REGISTER ro, (N/A on PAS16 ?) - * START_DMA_TARGET_RECEIVE_REG wo - */ - 0x3c03, /* RESET_PARITY_INTERRUPT_REG ro, - * START_DMA_INITIATOR_RECEIVE_REG wo - */ - }; +unsigned short pas16_offset[8] = { + 0x1c00, /* OUTPUT_DATA_REG */ + 0x1c01, /* INITIATOR_COMMAND_REG */ + 0x1c02, /* MODE_REG */ + 0x1c03, /* TARGET_COMMAND_REG */ + 0x3c00, /* STATUS_REG ro, SELECT_ENABLE_REG wo */ + 0x3c01, /* BUS_AND_STATUS_REG ro, START_DMA_SEND_REG wo */ + 0x3c02, /* INPUT_DATA_REGISTER ro, (N/A on PAS16 ?) + * START_DMA_TARGET_RECEIVE_REG wo + */ + 0x3c03, /* RESET_PARITY_INTERRUPT_REG ro, + * START_DMA_INITIATOR_RECEIVE_REG wo + */ +}; /*----------------------------------------------------------------*/ -/* the following will set the monitor border color (useful to find - where something crashed or gets stuck at */ -/* 1 = blue - 2 = green - 3 = cyan - 4 = red - 5 = magenta - 6 = yellow - 7 = white -*/ -#if 1 -#define rtrc(i) {inb(0x3da); outb(0x31, 0x3c0); outb((i), 0x3c0);} -#else -#define rtrc(i) {} -#endif - -/* - * Function : enable_board( int board_num, unsigned short port ) - * - * Purpose : set address in new model board - * - * Inputs : board_num - logical board number 0-3, port - base address +/** + * enable_board - enable a pas16 board + * @board_num: logical board id + * @port: port to assign it * + * Sets the address on new model PAS16 hardware */ -static void __init - enable_board( int board_num, unsigned short port ) +static void __init enable_board(int board_num, unsigned short port) { - outb( 0xbc + board_num, MASTER_ADDRESS_PTR ); - outb( port >> 2, MASTER_ADDRESS_PTR ); + outb(0xbc + board_num, MASTER_ADDRESS_PTR); + outb(port >> 2, MASTER_ADDRESS_PTR); } - - -/* - * Function : init_board( unsigned short port, int irq ) - * - * Purpose : Set the board up to handle the SCSI interface - * - * Inputs : port - base address of the board, - * irq - irq to assign to the SCSI port - * force_irq - set it even if it conflicts with sound driver +/** + * init_board - set up board + * @port: board address + * @irq: interrupt line + * @force_irq: if true allow scsi/audio on the same int * + * Set the board up to handle the SCSI interface */ -static void __init - init_board( unsigned short io_port, int irq, int force_irq ) +static void __init init_board(unsigned short io_port, int irq, int force_irq) { - unsigned int tmp; - unsigned int pas_irq_code; + unsigned int tmp; + unsigned int pas_irq_code; /* Initialize the SCSI part of the board */ - outb( 0x30, io_port + P_TIMEOUT_COUNTER_REG ); /* Timeout counter */ - outb( 0x01, io_port + P_TIMEOUT_STATUS_REG_OFFSET ); /* Reset TC */ - outb( 0x01, io_port + WAIT_STATE ); /* 1 Wait state */ + outb(0x30, io_port + P_TIMEOUT_COUNTER_REG); /* Timeout counter */ + outb(0x01, io_port + P_TIMEOUT_STATUS_REG_OFFSET); /* Reset TC */ + outb(0x01, io_port + WAIT_STATE); /* 1 Wait state */ - NCR5380_read( RESET_PARITY_INTERRUPT_REG ); + NCR5380_read(RESET_PARITY_INTERRUPT_REG); - /* Set the SCSI interrupt pointer without mucking up the sound - * interrupt pointer in the same byte. + /* + * Set the SCSI interrupt pointer without mucking up the sound + * interrupt pointer in the same byte. */ - pas_irq_code = ( irq < 16 ) ? scsi_irq_translate[irq] : 0; - tmp = inb( io_port + IO_CONFIG_3 ); - - if( (( tmp & 0x0f ) == pas_irq_code) && pas_irq_code > 0 - && !force_irq ) - { - printk( "pas16: WARNING: Can't use same irq as sound " - "driver -- interrupts disabled\n" ); - /* Set up the drive parameters, disable 5380 interrupts */ - outb( 0x4d, io_port + SYS_CONFIG_4 ); - } - else - { - tmp = ( tmp & 0x0f ) | ( pas_irq_code << 4 ); - outb( tmp, io_port + IO_CONFIG_3 ); + + pas_irq_code = (irq < 16) ? scsi_irq_translate[irq] : 0; + tmp = inb(io_port + IO_CONFIG_3); + + if (((tmp & 0x0f) == pas_irq_code) && pas_irq_code > 0 && !force_irq) { + printk(KERN_WARNING "pas16: WARNING: Can't use same irq as sound " "driver -- interrupts disabled\n"); + /* Set up the drive parameters, disable 5380 interrupts */ + outb(0x4d, io_port + SYS_CONFIG_4); + } else { + tmp = (tmp & 0x0f) | (pas_irq_code << 4); + outb(tmp, io_port + IO_CONFIG_3); - /* Set up the drive parameters and enable 5380 interrupts */ - outb( 0x6d, io_port + SYS_CONFIG_4 ); + /* Set up the drive parameters and enable 5380 interrupts */ + outb(0x6d, io_port + SYS_CONFIG_4); } } -/* - * Function : pas16_hw_detect( unsigned short board_num ) - * - * Purpose : determine if a pas16 board is present - * - * Inputs : board_num - logical board number ( 0 - 3 ) +/** + * pas16_hw_detect - probe for hardware + * @board_num: logical board ID to probe for * - * Returns : 0 if board not found, 1 if found. + * Determine if a pas16 board is present */ -static int __init - pas16_hw_detect( unsigned short board_num ) +static int __init pas16_hw_detect(unsigned short board_num) { - unsigned char board_rev, tmp; - unsigned short io_port = bases[ board_num ].io_port; + unsigned char board_rev, tmp; + unsigned short io_port = bases[board_num].io_port; - /* See if we can find a PAS16 board at the address associated - * with this logical board number. - */ - - /* First, attempt to take a newer model board out of reset and - * give it a base address. This shouldn't affect older boards. - */ - enable_board( board_num, io_port ); + /* See if we can find a PAS16 board at the address associated + * with this logical board number. + */ - /* Now see if it looks like a PAS16 board */ - board_rev = inb( io_port + PCB_CONFIG ); + /* First, attempt to take a newer model board out of reset and + * give it a base address. This shouldn't affect older boards. + */ + enable_board(board_num, io_port); - if( board_rev == 0xff ) - return 0; + /* Now see if it looks like a PAS16 board */ + board_rev = inb(io_port + PCB_CONFIG); - tmp = board_rev ^ 0xe0; + if (board_rev == 0xff) + return 0; - outb( tmp, io_port + PCB_CONFIG ); - tmp = inb( io_port + PCB_CONFIG ); - outb( board_rev, io_port + PCB_CONFIG ); + tmp = board_rev ^ 0xe0; - if( board_rev != tmp ) /* Not a PAS-16 */ - return 0; + outb(tmp, io_port + PCB_CONFIG); + tmp = inb(io_port + PCB_CONFIG); + outb(board_rev, io_port + PCB_CONFIG); - if( ( inb( io_port + OPERATION_MODE_1 ) & 0x03 ) != 0x03 ) - return 0; /* return if no SCSI interface found */ + if (board_rev != tmp) /* Not a PAS-16 */ + return 0; - /* Mediavision has some new model boards that return ID bits - * that indicate a SCSI interface, but they're not (LMS). We'll - * put in an additional test to try to weed them out. - */ - - outb( 0x01, io_port + WAIT_STATE ); /* 1 Wait state */ - NCR5380_write( MODE_REG, 0x20 ); /* Is it really SCSI? */ - if( NCR5380_read( MODE_REG ) != 0x20 ) /* Write to a reg. */ - return 0; /* and try to read */ - NCR5380_write( MODE_REG, 0x00 ); /* it back. */ - if( NCR5380_read( MODE_REG ) != 0x00 ) - return 0; + if ((inb(io_port + OPERATION_MODE_1) & 0x03) != 0x03) + return 0; /* return if no SCSI interface found */ - return 1; -} + /* Mediavision has some new model boards that return ID bits + * that indicate a SCSI interface, but they're not (LMS). We'll + * put in an additional test to try to weed them out. + */ + outb(0x01, io_port + WAIT_STATE); /* 1 Wait state */ + NCR5380_write(MODE_REG, 0x20); /* Is it really SCSI? */ + if (NCR5380_read(MODE_REG) != 0x20) /* Write to a reg. */ + return 0; /* and try to read */ + NCR5380_write(MODE_REG, 0x00); /* it back. */ + if (NCR5380_read(MODE_REG) != 0x00) + return 0; -/* - * Function : pas16_setup(char *str, int *ints) - * - * Purpose : LILO command line initialization of the overrides array, - * - * Inputs : str - unused, ints - array of integer parameters with ints[0] - * equal to the number of ints. + return 1; +} + +/** + * pas16_setup - parse command line + * @str: command line block * + * LILO command line initialization of the overrides array from + * the passed in pas16= options */ -void __init pas16_setup(char *str, int *ints) +int __init pas16_setup(char *str, int *ints) { - static int commandline_current = 0; - int i; - if (ints[0] != 2) - printk("pas16_setup : usage pas16=io_port,irq\n"); - else - if (commandline_current < NO_OVERRIDES) { - overrides[commandline_current].io_port = (unsigned short) ints[1]; - overrides[commandline_current].irq = ints[2]; - for (i = 0; i < NO_BASES; ++i) - if (bases[i].io_port == (unsigned short) ints[1]) { - bases[i].noauto = 1; - break; - } - ++commandline_current; + static int commandline_current = 0; + int i; + int ints[10]; + + get_options(str, sizeof(ints) / sizeof(int), ints); + if (ints[0] != 2) + printk(KERN_ERR "pas16_setup : usage pas16=io_port,irq\n"); + else if (commandline_current < NO_OVERRIDES) { + overrides[commandline_current].io_port = (unsigned short) ints[1]; + overrides[commandline_current].irq = ints[2]; + for (i = 0; i < NO_BASES; ++i) + if (bases[i].io_port == (unsigned short) ints[1]) { + bases[i].noauto = 1; + break; + } + ++commandline_current; } + return 1; } -/* - * Function : int pas16_detect(Scsi_Host_Template * tpnt) - * - * Purpose : detects and initializes PAS16 controllers - * that were autoprobed, overridden on the LILO command line, - * or specified at compile time. - * - * Inputs : tpnt - template for this SCSI adapter. - * - * Returns : 1 if a host adapter was found, 0 if not. +__setup("pas16=", pas16_setup); + +/** + * pas16_detect - detect and configure a pas16 + * @tpnt: template * + * Detects and initializes PAS16 controllers that were autoprobed, + * overridden on the LILO command line, or specified at compile time. */ int __init pas16_detect(Scsi_Host_Template * tpnt) { - static int current_override = 0; - static unsigned short current_base = 0; - struct Scsi_Host *instance; - unsigned short io_port; - int count; + static int current_override = 0; + static unsigned short current_base = 0; + struct Scsi_Host *instance; + unsigned short io_port; + int count; + + tpnt->proc_name = "pas16"; + tpnt->proc_info = &pas16_proc_info; + + if (pas16_addr != 0) { + overrides[0].io_port = pas16_addr; + /* + * This is how we avoid seeing more than + * one host adapter at the same I/O port. + * Cribbed shamelessly from pas16_setup(). + */ + for (count = 0; count < NO_BASES; ++count) + if (bases[count].io_port == pas16_addr) { + bases[count].noauto = 1; + break; + } + } + if (pas16_irq != 0) + overrides[0].irq = pas16_irq; - tpnt->proc_name = "pas16"; - tpnt->proc_info = &pas16_proc_info; + for (count = 0; current_override < NO_OVERRIDES; ++current_override) { + io_port = 0; - if (pas16_addr != 0) { - overrides[0].io_port = pas16_addr; - /* - * This is how we avoid seeing more than - * one host adapter at the same I/O port. - * Cribbed shamelessly from pas16_setup(). - */ - for (count = 0; count < NO_BASES; ++count) - if (bases[count].io_port == pas16_addr) { - bases[count].noauto = 1; - break; - } - } - if (pas16_irq != 0) - overrides[0].irq = pas16_irq; - - for (count = 0; current_override < NO_OVERRIDES; ++current_override) { - io_port = 0; - - if (overrides[current_override].io_port) - { - io_port = overrides[current_override].io_port; - enable_board( current_override, io_port ); - init_board( io_port, overrides[current_override].irq, 1 ); - } - else - for (; !io_port && (current_base < NO_BASES); ++current_base) { -#if (PDEBUG & PDEBUG_INIT) - printk("scsi-pas16 : probing io_port %04x\n", (unsigned int) bases[current_base].io_port); -#endif - if ( !bases[current_base].noauto && - pas16_hw_detect( current_base ) ){ - io_port = bases[current_base].io_port; - init_board( io_port, default_irqs[ current_base ], 0 ); -#if (PDEBUG & PDEBUG_INIT) - printk("scsi-pas16 : detected board.\n"); -#endif + if (overrides[current_override].io_port) { + io_port = overrides[current_override].io_port; + enable_board(current_override, io_port); + init_board(io_port, overrides[current_override].irq, 1); + } + else + { + for (; !io_port && (current_base < NO_BASES); ++current_base) { + if (!bases[current_base].noauto && pas16_hw_detect(current_base)) { + io_port = bases[current_base].io_port; + init_board(io_port, default_irqs[current_base], 0); + } + } } - } + if (!io_port) + break; -#if defined(PDEBUG) && (PDEBUG & PDEBUG_INIT) - printk("scsi-pas16 : io_port = %04x\n", (unsigned int) io_port); -#endif + instance = scsi_register(tpnt, sizeof(struct NCR5380_hostdata)); + if (instance == NULL) + break; + + instance->io_port = io_port; + + NCR5380_init(instance, 0); + + if (overrides[current_override].irq != IRQ_AUTO) + instance->irq = overrides[current_override].irq; + else + instance->irq = NCR5380_probe_irq(instance, PAS16_IRQS); + + if (instance->irq != IRQ_NONE) + if (request_irq(instance->irq, do_pas16_intr, SA_INTERRUPT, "pas16", NULL)) { + printk(KERN_WARNING "scsi%d : IRQ%d not free, interrupts disabled\n", instance->host_no, instance->irq); + instance->irq = IRQ_NONE; + } + + if (instance->irq == IRQ_NONE) { + printk(KERN_INFO "scsi%d : interrupts not enabled. for better interactive performance,\n", instance->host_no); + printk(KERN_INFO "scsi%d : please jumper the board for a free IRQ.\n", instance->host_no); + /* Disable 5380 interrupts, leave drive params the same */ + outb(0x4d, io_port + SYS_CONFIG_4); + outb((inb(io_port + IO_CONFIG_3) & 0x0f), io_port + IO_CONFIG_3); + } - if (!io_port) - break; + printk(KERN_INFO "scsi%d : at 0x%04x", instance->host_no, (int) + instance->io_port); + if (instance->irq == IRQ_NONE) + printk(" interrupts disabled"); + else + printk(" irq %d", instance->irq); + printk(" options CAN_QUEUE=%d CMD_PER_LUN=%d release=%d", CAN_QUEUE, CMD_PER_LUN, PAS16_PUBLIC_RELEASE); + NCR5380_print_options(instance); + printk("\n"); - instance = scsi_register (tpnt, sizeof(struct NCR5380_hostdata)); - if(instance == NULL) - break; - - instance->io_port = io_port; - - NCR5380_init(instance, 0); - - if (overrides[current_override].irq != IRQ_AUTO) - instance->irq = overrides[current_override].irq; - else - instance->irq = NCR5380_probe_irq(instance, PAS16_IRQS); - - if (instance->irq != IRQ_NONE) - if (request_irq(instance->irq, do_pas16_intr, SA_INTERRUPT, "pas16", NULL)) { - printk("scsi%d : IRQ%d not free, interrupts disabled\n", - instance->host_no, instance->irq); - instance->irq = IRQ_NONE; - } - - if (instance->irq == IRQ_NONE) { - printk("scsi%d : interrupts not enabled. for better interactive performance,\n", instance->host_no); - printk("scsi%d : please jumper the board for a free IRQ.\n", instance->host_no); - /* Disable 5380 interrupts, leave drive params the same */ - outb( 0x4d, io_port + SYS_CONFIG_4 ); - outb( (inb(io_port + IO_CONFIG_3) & 0x0f), io_port + IO_CONFIG_3 ); + ++current_override; + ++count; } - -#if defined(PDEBUG) && (PDEBUG & PDEBUG_INIT) - printk("scsi%d : irq = %d\n", instance->host_no, instance->irq); -#endif - - printk("scsi%d : at 0x%04x", instance->host_no, (int) - instance->io_port); - if (instance->irq == IRQ_NONE) - printk (" interrupts disabled"); - else - printk (" irq %d", instance->irq); - printk(" options CAN_QUEUE=%d CMD_PER_LUN=%d release=%d", - CAN_QUEUE, CMD_PER_LUN, PAS16_PUBLIC_RELEASE); - NCR5380_print_options(instance); - printk("\n"); - - ++current_override; - ++count; - } - return count; + return count; } -/* - * Function : int pas16_biosparam(Disk *disk, kdev_t dev, int *ip) +/** + * pas16_biosparam - generate C/H/S data + * @disk: Disk to set up + * @dev: device ident of disk + * @ip: array to return C/H/S mapping * - * Purpose : Generates a BIOS / DOS compatible H-C-S mapping for + * Generates a BIOS / DOS compatible H-C-S mapping for * the specified device / size. - * - * Inputs : size = size of device in sectors (512 bytes), dev = block device - * major / minor, ip[] = {heads, sectors, cylinders} - * - * Returns : always 0 (success), initializes ip - * */ -/* - * XXX Most SCSI boards use this mapping, I could be incorrect. Some one - * using hard disks on a trantor should verify that this mapping corresponds - * to that used by the BIOS / ASPI driver by running the linux fdisk program - * and matching the H_C_S coordinates to what DOS uses. - */ - -int pas16_biosparam(Disk * disk, kdev_t dev, int * ip) +int pas16_biosparam(Disk * disk, kdev_t dev, int *ip) { - int size = disk->capacity; - ip[0] = 64; - ip[1] = 32; - ip[2] = size >> 11; /* I think I have it as /(32*64) */ - if( ip[2] > 1024 ) { /* yes, >, not >= */ - ip[0]=255; - ip[1]=63; - ip[2]=size/(63*255); - if( ip[2] > 1023 ) /* yes >1023... */ - ip[2] = 1023; - } + int size = disk->capacity; + ip[0] = 64; + ip[1] = 32; + ip[2] = size >> 11; /* I think I have it as /(32*64) */ + if (ip[2] > 1024) { /* yes, >, not >= */ + ip[0] = 255; + ip[1] = 63; + ip[2] = size / (63 * 255); + if (ip[2] > 1023) /* yes >1023... */ + ip[2] = 1023; + } - return 0; + return 0; } -/* - * Function : int NCR5380_pread (struct Scsi_Host *instance, - * unsigned char *dst, int len) - * - * Purpose : Fast 5380 pseudo-dma read function, transfers len bytes to - * dst - * - * Inputs : dst = destination, len = length in bytes - * - * Returns : 0 on success, non zero on a failure such as a watchdog - * timeout. +/** + * NCR5380_pread - pseudo DMA read + * @instance: board to read from + * @dst: destination for data + * @len: expected/max block length + * + * Fast 5380 pseudo-dma read function, transfers len bytes to + * dst. Unlike most boards the PAS has IRQs enabled here, which + * helps no end. */ -static inline int NCR5380_pread (struct Scsi_Host *instance, unsigned char *dst, - int len) { - register unsigned char *d = dst; - register unsigned short reg = (unsigned short) (instance->io_port + - P_DATA_REG_OFFSET); - register int i = len; - int ii = 0; - - while ( !(inb(instance->io_port + P_STATUS_REG_OFFSET) & P_ST_RDY) ) - ++ii; - - insb( reg, d, i ); - - if ( inb(instance->io_port + P_TIMEOUT_STATUS_REG_OFFSET) & P_TS_TIM) { - outb( P_TS_CT, instance->io_port + P_TIMEOUT_STATUS_REG_OFFSET); - printk("scsi%d : watchdog timer fired in NCR5380_pread()\n", - instance->host_no); - return -1; - } - if (ii > pas_maxi) - pas_maxi = ii; - return 0; +static inline int NCR5380_pread(struct Scsi_Host *instance, unsigned char *dst, int len) +{ + unsigned char *d = dst; + unsigned short reg = (unsigned short) (instance->io_port + P_DATA_REG_OFFSET); + int i = len; + int ii = 0; + + while (!(inb(instance->io_port + P_STATUS_REG_OFFSET) & P_ST_RDY)) + ++ii; + + insb(reg, d, i); + + if (inb(instance->io_port + P_TIMEOUT_STATUS_REG_OFFSET) & P_TS_TIM) { + outb(P_TS_CT, instance->io_port + P_TIMEOUT_STATUS_REG_OFFSET); + printk(KERN_ERR "scsi%d : watchdog timer fired in NCR5380_pread()\n", instance->host_no); + return -1; + } + if (ii > pas_maxi) + pas_maxi = ii; + return 0; } -/* - * Function : int NCR5380_pwrite (struct Scsi_Host *instance, - * unsigned char *src, int len) - * - * Purpose : Fast 5380 pseudo-dma write function, transfers len bytes from - * src - * - * Inputs : src = source, len = length in bytes - * - * Returns : 0 on success, non zero on a failure such as a watchdog - * timeout. +/** + * NCR5380_pwrite - pseudo DMA write + * @instance: board to write to + * @src: source for data + * @len: expected/max block length + * + * Fast 5380 pseudo-dma write function, transfers len bytes from + * src. Unlike most boards the PAS has IRQs enabled here, which + * helps no end. */ -static inline int NCR5380_pwrite (struct Scsi_Host *instance, unsigned char *src, - int len) { - register unsigned char *s = src; - register unsigned short reg = (instance->io_port + P_DATA_REG_OFFSET); - register int i = len; - int ii = 0; - - while ( !((inb(instance->io_port + P_STATUS_REG_OFFSET)) & P_ST_RDY) ) - ++ii; - - outsb( reg, s, i ); - - if (inb(instance->io_port + P_TIMEOUT_STATUS_REG_OFFSET) & P_TS_TIM) { - outb( P_TS_CT, instance->io_port + P_TIMEOUT_STATUS_REG_OFFSET); - printk("scsi%d : watchdog timer fired in NCR5380_pwrite()\n", - instance->host_no); - return -1; - } - if (ii > pas_maxi) - pas_wmaxi = ii; - return 0; +static inline int NCR5380_pwrite(struct Scsi_Host *instance, unsigned char *src, int len) +{ + unsigned char *s = src; + unsigned short reg = (instance->io_port + P_DATA_REG_OFFSET); + int i = len; + int ii = 0; + + while (!((inb(instance->io_port + P_STATUS_REG_OFFSET)) & P_ST_RDY)) + ++ii; + + outsb(reg, s, i); + + if (inb(instance->io_port + P_TIMEOUT_STATUS_REG_OFFSET) & P_TS_TIM) { + outb(P_TS_CT, instance->io_port + P_TIMEOUT_STATUS_REG_OFFSET); + printk(KERN_ERR "scsi%d : watchdog timer fired in NCR5380_pwrite()\n", instance->host_no); + return -1; + } + if (ii > pas_maxi) + pas_wmaxi = ii; + return 0; } #include "NCR5380.c" diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/scsi/pcmcia/aha152x_stub.c linux-2.5/drivers/scsi/pcmcia/aha152x_stub.c --- linux-2.5.1/drivers/scsi/pcmcia/aha152x_stub.c Sun Sep 30 19:26:07 2001 +++ linux-2.5/drivers/scsi/pcmcia/aha152x_stub.c Thu Dec 27 22:10:28 2001 @@ -5,7 +5,7 @@ This driver supports the Adaptec AHA-1460, the New Media Bus Toaster, and the New Media Toast & Jam. - aha152x_cs.c 1.54 2000/06/12 21:27:25 + aha152x_cs.c 1.58 2001/10/13 00:08:51 The contents of this file are subject to the Mozilla Public License Version 1.1 (the "License"); you may not use this file @@ -22,8 +22,8 @@ are Copyright (C) 1999 David A. Hinds. All Rights Reserved. Alternatively, the contents of this file may be used under the - terms of the GNU General Public License version 2 (the "GPL"), in which - case the provisions of the GPL are applicable instead of the + terms of the GNU General Public License version 2 (the "GPL"), in + which case the provisions of the GPL are applicable instead of the above. If you wish to allow the use of your version of this file only under the terms of the GPL and not to allow others to use your version of this file under the MPL, indicate your decision @@ -57,42 +57,39 @@ #include <pcmcia/cistpl.h> #include <pcmcia/ds.h> -#ifdef PCMCIA_DEBUG -static int pc_debug = PCMCIA_DEBUG; -MODULE_PARM(pc_debug, "i"); -#define DEBUG(n, args...) if (pc_debug>(n)) printk(KERN_DEBUG args) -static char *version = -"aha152x_cs.c 1.54 2000/06/12 21:27:25 (David Hinds)"; -#else -#define DEBUG(n, args...) -#endif - /*====================================================================*/ -/* Parameters that can be set with 'insmod' */ +/* Module parameters */ + +MODULE_AUTHOR("David Hinds <dahinds@users.sourceforge.net>"); +MODULE_DESCRIPTION("Adaptec AHA152x-compatible PCMCIA SCSI driver"); +MODULE_LICENSE("Dual MPL/GPL"); -/* Bit map of interrupts to choose from */ -static u_int irq_mask = 0xdeb8; static int irq_list[4] = { -1 }; +MODULE_PARM(irq_list, "1-4i"); -/* SCSI bus setup options */ -static int host_id = 7; -static int reconnect = 1; -static int parity = 1; -static int synchronous = 0; -static int reset_delay = 100; -static int ext_trans = 0; +#define INT_MODULE_PARM(n, v) static int n = v; MODULE_PARM(n, "i") -MODULE_PARM(irq_mask, "i"); -MODULE_PARM(irq_list, "1-4i"); -MODULE_PARM(host_id, "i"); -MODULE_PARM(reconnect, "i"); -MODULE_PARM(parity, "i"); -MODULE_PARM(synchronous, "i"); -MODULE_PARM(reset_delay, "i"); -MODULE_PARM(ext_trans, "i"); +INT_MODULE_PARM(irq_mask, 0xdeb8); +INT_MODULE_PARM(host_id, 7); +INT_MODULE_PARM(reconnect, 1); +INT_MODULE_PARM(parity, 1); +INT_MODULE_PARM(synchronous, 0); +INT_MODULE_PARM(reset_delay, 100); +INT_MODULE_PARM(ext_trans, 0); -MODULE_LICENSE("Dual MPL/GPL"); +#ifdef AHA152X_DEBUG +INT_MODULE_PARM(debug, 0); +#endif + +#ifdef PCMCIA_DEBUG +INT_MODULE_PARM(pc_debug, PCMCIA_DEBUG); +#define DEBUG(n, args...) if (pc_debug>(n)) printk(KERN_DEBUG args) +static char *version = +"aha152x_cs.c 1.58 2001/10/13 00:08:51 (David Hinds)"; +#else +#define DEBUG(n, args...) +#endif /*====================================================================*/ @@ -277,7 +274,6 @@ release_region(link->io.BasePort1, link->io.NumPorts1); /* Set configuration options for the aha152x driver */ - ints[0] = 7; ints[1] = link->io.BasePort1; ints[2] = link->irq.AssignedIRQ; ints[3] = host_id; @@ -285,12 +281,16 @@ ints[5] = parity; ints[6] = synchronous; ints[7] = reset_delay; - if (ext_trans) { - ints[8] = ext_trans; ints[0] = 8; - } + ints[8] = ext_trans; +#ifdef AHA152X_DEBUG + ints[9] = debug; + ints[0] = 9; +#else + ints[0] = 8; +#endif aha152x_setup("PCMCIA setup", ints); - scsi_register_module(MODULE_SCSI_HA, &driver_template); + scsi_register_host(&driver_template); tail = &link->dev; info->ndev = 0; @@ -356,7 +356,7 @@ return; } - scsi_unregister_module(MODULE_SCSI_HA, &driver_template); + scsi_unregister_host(&driver_template); link->dev = NULL; CardServices(ReleaseConfiguration, link->handle); diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/scsi/pcmcia/fdomain_stub.c linux-2.5/drivers/scsi/pcmcia/fdomain_stub.c --- linux-2.5.1/drivers/scsi/pcmcia/fdomain_stub.c Sat Mar 3 02:38:39 2001 +++ linux-2.5/drivers/scsi/pcmcia/fdomain_stub.c Thu Dec 27 22:10:28 2001 @@ -2,7 +2,7 @@ A driver for Future Domain-compatible PCMCIA SCSI cards - fdomain_cs.c 1.43 2000/06/12 21:27:25 + fdomain_cs.c 1.47 2001/10/13 00:08:52 The contents of this file are subject to the Mozilla Public License Version 1.1 (the "License"); you may not use this file @@ -19,8 +19,8 @@ are Copyright (C) 1999 David A. Hinds. All Rights Reserved. Alternatively, the contents of this file may be used under the - terms of the GNU General Public License version 2 (the "GPL"), in which - case the provisions of the GPL are applicable instead of the + terms of the GNU General Public License version 2 (the "GPL"), in + which case the provisions of the GPL are applicable instead of the above. If you wish to allow the use of your version of this file only under the terms of the GPL and not to allow others to use your version of this file under the MPL, indicate your decision @@ -54,27 +54,30 @@ #include <pcmcia/cistpl.h> #include <pcmcia/ds.h> -#ifdef PCMCIA_DEBUG -static int pc_debug = PCMCIA_DEBUG; -MODULE_PARM(pc_debug, "i"); -#define DEBUG(n, args...) if (pc_debug>(n)) printk(KERN_DEBUG args) -static char *version = -"fdomain_cs.c 1.43 2000/06/12 21:27:25 (David Hinds)"; -#else -#define DEBUG(n, args...) -#endif - /*====================================================================*/ -/* Parameters that can be set with 'insmod' */ +/* Module parameters */ + +MODULE_AUTHOR("David Hinds <dahinds@users.sourceforge.net>"); +MODULE_DESCRIPTION("Future Domain PCMCIA SCSI driver"); +MODULE_LICENSE("Dual MPL/GPL"); + +#define INT_MODULE_PARM(n, v) static int n = v; MODULE_PARM(n, "i") /* Bit map of interrupts to choose from */ -static u_int irq_mask = 0xdeb8; +INT_MODULE_PARM(irq_mask, 0xdeb8); static int irq_list[4] = { -1 }; - -MODULE_PARM(irq_mask, "i"); MODULE_PARM(irq_list, "1-4i"); +#ifdef PCMCIA_DEBUG +INT_MODULE_PARM(pc_debug, PCMCIA_DEBUG); +#define DEBUG(n, args...) if (pc_debug>(n)) printk(KERN_DEBUG args) +static char *version = +"fdomain_cs.c 1.47 2001/10/13 00:08:52 (David Hinds)"; +#else +#define DEBUG(n, args...) +#endif + /*====================================================================*/ typedef struct scsi_info_t { @@ -212,6 +215,7 @@ u_char tuple_data[64]; Scsi_Device *dev; dev_node_t *node, **tail; + char str[16]; struct Scsi_Host *host; DEBUG(0, "fdomain_config(0x%p)\n", link); @@ -252,9 +256,10 @@ ints[0] = 2; ints[1] = link->io.BasePort1; ints[2] = link->irq.AssignedIRQ; - fdomain_setup("PCMCIA setup", ints); + sprintf(str, "%d,%d", link->io.BasePort1, link->irq.AssignedIRQ); + fdomain_setup(str, ints); - scsi_register_module(MODULE_SCSI_HA, &driver_template); + scsi_register_host(&driver_template); tail = &link->dev; info->ndev = 0; @@ -319,7 +324,7 @@ return; } - scsi_unregister_module(MODULE_SCSI_HA, &driver_template); + scsi_unregister_host(&driver_template); link->dev = NULL; CardServices(ReleaseConfiguration, link->handle); diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/scsi/pcmcia/nsp_cs.c linux-2.5/drivers/scsi/pcmcia/nsp_cs.c --- linux-2.5.1/drivers/scsi/pcmcia/nsp_cs.c Wed Nov 28 18:22:27 2001 +++ linux-2.5/drivers/scsi/pcmcia/nsp_cs.c Thu Dec 27 22:10:28 2001 @@ -1515,7 +1515,7 @@ goto cs_failed; } - scsi_register_module(MODULE_SCSI_HA, &driver_template); + scsi_register_host(&driver_template); DEBUG(0, "GET_SCSI_INFO\n"); tail = &link->dev; @@ -1611,7 +1611,7 @@ } /* Unlink the device chain */ - scsi_unregister_module(MODULE_SCSI_HA, &driver_template); + scsi_unregister_host(&driver_template); link->dev = NULL; if (link->win) { diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/scsi/pcmcia/qlogic_stub.c linux-2.5/drivers/scsi/pcmcia/qlogic_stub.c --- linux-2.5.1/drivers/scsi/pcmcia/qlogic_stub.c Sat Mar 3 02:38:39 2001 +++ linux-2.5/drivers/scsi/pcmcia/qlogic_stub.c Thu Dec 27 22:10:28 2001 @@ -2,7 +2,7 @@ A driver for the Qlogic SCSI card - qlogic_cs.c 1.79 2000/06/12 21:27:26 + qlogic_cs.c 1.83 2001/10/13 00:08:53 The contents of this file are subject to the Mozilla Public License Version 1.1 (the "License"); you may not use this file @@ -19,8 +19,8 @@ are Copyright (C) 1999 David A. Hinds. All Rights Reserved. Alternatively, the contents of this file may be used under the - terms of the GNU General Public License version 2 (the "GPL"), in which - case the provisions of the GPL are applicable instead of the + terms of the GNU General Public License version 2 (the "GPL"), in + which case the provisions of the GPL are applicable instead of the above. If you wish to allow the use of your version of this file only under the terms of the GPL and not to allow others to use your version of this file under the MPL, indicate your decision @@ -40,6 +40,7 @@ #include <linux/timer.h> #include <linux/ioport.h> #include <asm/io.h> +#include <asm/byteorder.h> #include <scsi/scsi.h> #include <linux/major.h> #include <linux/blk.h> @@ -61,27 +62,30 @@ extern void qlogicfas_preset(int port, int irq); -#ifdef PCMCIA_DEBUG -static int pc_debug = PCMCIA_DEBUG; -MODULE_PARM(pc_debug, "i"); -#define DEBUG(n, args...) if (pc_debug>(n)) printk(KERN_DEBUG args) -static char *version = -"qlogic_cs.c 1.79 2000/06/12 21:27:26 (David Hinds)"; -#else -#define DEBUG(n, args...) -#endif - /*====================================================================*/ -/* Parameters that can be set with 'insmod' */ +/* Module parameters */ + +MODULE_AUTHOR("David Hinds <dahinds@users.sourceforge.net>"); +MODULE_DESCRIPTION("Qlogic PCMCIA SCSI driver"); +MODULE_LICENSE("Dual MPL/GPL"); + +#define INT_MODULE_PARM(n, v) static int n = v; MODULE_PARM(n, "i") /* Bit map of interrupts to choose from */ -static u_int irq_mask = 0xdeb8; +INT_MODULE_PARM(irq_mask, 0xdeb8); static int irq_list[4] = { -1 }; - -MODULE_PARM(irq_mask, "i"); MODULE_PARM(irq_list, "1-4i"); +#ifdef PCMCIA_DEBUG +INT_MODULE_PARM(pc_debug, PCMCIA_DEBUG); +#define DEBUG(n, args...) if (pc_debug>(n)) printk(KERN_DEBUG args) +static char *version = +"qlogic_cs.c 1.83 2001/10/13 00:08:53 (David Hinds)"; +#else +#define DEBUG(n, args...) +#endif + /*====================================================================*/ typedef struct scsi_info_t { @@ -277,7 +281,7 @@ else qlogicfas_preset(link->io.BasePort1, link->irq.AssignedIRQ); - scsi_register_module(MODULE_SCSI_HA, &driver_template); + scsi_register_host(&driver_template); tail = &link->dev; info->ndev = 0; @@ -341,7 +345,7 @@ return; } - scsi_unregister_module(MODULE_SCSI_HA, &driver_template); + scsi_unregister_host(&driver_template); link->dev = NULL; CardServices(ReleaseConfiguration, link->handle); diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/scsi/qla1280.c linux-2.5/drivers/scsi/qla1280.c --- linux-2.5.1/drivers/scsi/qla1280.c Sun Sep 30 19:26:07 2001 +++ linux-2.5/drivers/scsi/qla1280.c Sun Dec 30 21:17:30 2001 @@ -192,7 +192,6 @@ #include <stdarg.h> #include <asm/io.h> #include <asm/irq.h> -#include <asm/segment.h> #include <asm/byteorder.h> #include <linux/version.h> #include <linux/types.h> diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/scsi/qlogicfas.c linux-2.5/drivers/scsi/qlogicfas.c --- linux-2.5.1/drivers/scsi/qlogicfas.c Thu Oct 25 20:53:51 2001 +++ linux-2.5/drivers/scsi/qlogicfas.c Mon Dec 17 03:21:24 2001 @@ -467,10 +467,11 @@ static void do_ql_ihandl(int irq, void *dev_id, struct pt_regs * regs) { unsigned long flags; + struct Scsi_Host *host = dev_id; - spin_lock_irqsave(&io_request_lock, flags); + spin_lock_irqsave(&host->host_lock, flags); ql_ihandl(irq, dev_id, regs); - spin_unlock_irqrestore(&io_request_lock, flags); + spin_unlock_irqrestore(&host->host_lock, flags); } #endif diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/scsi/scsi.c linux-2.5/drivers/scsi/scsi.c --- linux-2.5.1/drivers/scsi/scsi.c Sun Dec 16 20:20:20 2001 +++ linux-2.5/drivers/scsi/scsi.c Thu Dec 27 22:10:28 2001 @@ -1405,9 +1405,6 @@ SCpnt->done(SCpnt); } -static int scsi_register_host(Scsi_Host_Template *); -static int scsi_unregister_host(Scsi_Host_Template *); - /* * Function: scsi_release_commandblocks() * @@ -1842,7 +1839,7 @@ * This entry point should be called by a driver if it is trying * to add a low level scsi driver to the system. */ -static int scsi_register_host(Scsi_Host_Template * tpnt) +int scsi_register_host(Scsi_Host_Template * tpnt) { int pcount; struct Scsi_Host *shpnt; @@ -1992,7 +1989,7 @@ * Similarly, this entry point should be called by a loadable module if it * is trying to remove a low level scsi driver from the system. */ -static int scsi_unregister_host(Scsi_Host_Template * tpnt) +int scsi_unregister_host(Scsi_Host_Template * tpnt) { int online_status; int pcount0, pcount; @@ -2203,22 +2200,27 @@ return -1; } -static int scsi_unregister_device(struct Scsi_Device_Template *tpnt); - /* * This entry point should be called by a loadable module if it is trying * add a high level scsi driver to the system. */ -static int scsi_register_device_module(struct Scsi_Device_Template *tpnt) +int scsi_register_device(struct Scsi_Device_Template *tpnt) { Scsi_Device *SDpnt; struct Scsi_Host *shpnt; int out_of_space = 0; +#ifdef CONFIG_KMOD + if (scsi_hosts == NULL) + request_module("scsi_hostadapter"); +#endif + if (tpnt->next) return 1; - scsi_register_device(tpnt); + tpnt->next = scsi_devicelist; + scsi_devicelist = tpnt; + /* * First scan the devices that we know about, and see if we notice them. */ @@ -2274,7 +2276,7 @@ return 0; } -static int scsi_unregister_device(struct Scsi_Device_Template *tpnt) +int scsi_unregister_device(struct Scsi_Device_Template *tpnt) { Scsi_Device *SDpnt; struct Scsi_Host *shpnt; @@ -2332,60 +2334,6 @@ error_out: unlock_kernel(); return -1; -} - - -/* This function should be called by drivers which needs to register - * with the midlevel scsi system. As of 2.4.0-test9pre3 this is our - * main device/hosts register function /mathiasen - */ -int scsi_register_module(int module_type, void *ptr) -{ - switch (module_type) { - case MODULE_SCSI_HA: - return scsi_register_host((Scsi_Host_Template *) ptr); - - /* Load upper level device handler of some kind */ - case MODULE_SCSI_DEV: -#ifdef CONFIG_KMOD - if (scsi_hosts == NULL) - request_module("scsi_hostadapter"); -#endif - return scsi_register_device_module((struct Scsi_Device_Template *) ptr); - /* The rest of these are not yet implemented */ - - /* Load constants.o */ - case MODULE_SCSI_CONST: - - /* Load specialized ioctl handler for some device. Intended for - * cdroms that have non-SCSI2 audio command sets. */ - case MODULE_SCSI_IOCTL: - - default: - return 1; - } -} - -/* Reverse the actions taken above - */ -int scsi_unregister_module(int module_type, void *ptr) -{ - int retval = 0; - - switch (module_type) { - case MODULE_SCSI_HA: - retval = scsi_unregister_host((Scsi_Host_Template *) ptr); - break; - case MODULE_SCSI_DEV: - retval = scsi_unregister_device((struct Scsi_Device_Template *)ptr); - break; - /* The rest of these are not yet implemented. */ - case MODULE_SCSI_CONST: - case MODULE_SCSI_IOCTL: - break; - default:; - } - return retval; } #ifdef CONFIG_PROC_FS diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/scsi/scsi.h linux-2.5/drivers/scsi/scsi.h --- linux-2.5.1/drivers/scsi/scsi.h Sun Dec 16 23:46:45 2001 +++ linux-2.5/drivers/scsi/scsi.h Mon Dec 31 21:57:20 2001 @@ -434,7 +434,7 @@ /* * Prototypes for functions in scsicam.c */ -extern int scsi_partsize(struct buffer_head *bh, unsigned long capacity, +extern int scsi_partsize(unsigned char *buf, unsigned long capacity, unsigned int *cyls, unsigned int *hds, unsigned int *secs); @@ -548,10 +548,8 @@ */ struct scsi_device { -/* private: */ /* - * This information is private to the scsi mid-layer. Wrapping it in a - * struct private is a way of marking it in a sort of C++ type of way. + * This information is private to the scsi mid-layer. */ struct scsi_device *next; /* Used for linked list */ struct scsi_device *prev; /* Used for linked list */ @@ -563,7 +561,6 @@ volatile unsigned short device_busy; /* commands actually active on low-level */ Scsi_Cmnd *device_queue; /* queue of SCSI Command structures */ -/* public: */ unsigned int id, lun, channel; unsigned int manufacturer; /* Manufacturer of device, for using @@ -681,11 +678,7 @@ */ struct scsi_cmnd { int sc_magic; -/* private: */ - /* - * This information is private to the scsi mid-layer. Wrapping it in a - * struct private is a way of marking it in a sort of C++ type of way. - */ + struct Scsi_Host *host; unsigned short state; unsigned short owner; @@ -726,8 +719,6 @@ unsigned volatile char internal_timeout; struct scsi_cmnd *bh_next; /* To enumerate the commands waiting to be processed. */ - -/* public: */ unsigned int target; unsigned int lun; diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/scsi/scsi_debug.c linux-2.5/drivers/scsi/scsi_debug.c --- linux-2.5.1/drivers/scsi/scsi_debug.c Sun Dec 16 20:20:20 2001 +++ linux-2.5/drivers/scsi/scsi_debug.c Thu Dec 27 15:14:59 2001 @@ -3,8 +3,19 @@ * * Copyright (C) 1992 Eric Youngdale * Simulate a host adapter with 2 disks attached. Do a lot of checking - * to make sure that we are not getting blocks mixed up, and panic if + * to make sure that we are not getting blocks mixed up, and PANIC if * anything out of the ordinary is seen. + * + * This version is more generic, simulating a variable number of disk + * (or disk like devices) sharing a common amount of RAM (default 8 MB + * but can be set at driver/module load time). + * + * For documentation see http://www.torque.net/sg/sdebug.html + * + * D. Gilbert (dpg) work for MOD device test [20010421] + * dpg, work for devfs large number of disks [20010809] + * dpg, make more generic [20011123] + * dpg, forked for lk 2.5 series [20011216] */ #include <linux/config.h> @@ -18,7 +29,9 @@ #include <linux/string.h> #include <linux/genhd.h> #include <linux/fs.h> +#include <linux/init.h> #include <linux/proc_fs.h> +#include <linux/smp_lock.h> #include <asm/system.h> #include <asm/io.h> @@ -27,201 +40,198 @@ #include "scsi.h" #include "hosts.h" -#include "sd.h" - #include<linux/stat.h> -/* A few options that we want selected */ +#ifndef LINUX_VERSION_CODE +#include <linux/version.h> +#endif + +static char scsi_debug_version_str[] = "Version: 1.57 (20011216)"; -#define NR_HOSTS_PRESENT 1 -#define NR_FAKE_DISKS 3 -#define N_HEAD 255 -#define N_SECTOR 63 -#define N_CYLINDER 524 +#ifndef SCSI_CMD_READ_16 +#define SCSI_CMD_READ_16 0x88 +#endif +#ifndef SCSI_CMD_WRITE_16 +#define SCSI_CMD_WRITE_16 0x8a +#endif + +/* A few options that we want selected */ +#define DEF_NR_FAKE_DEVS 1 +#define DEF_DEV_SIZE_MB 8 +#define DEF_FAKE_BLK0 0 + +static int scsi_debug_num_devs = DEF_NR_FAKE_DEVS; + +#define NR_HOSTS_PRESENT (((scsi_debug_num_devs - 1) / 7) + 1) +#define N_HEAD 8 +#define N_SECTOR 32 #define DISK_READONLY(TGT) (0) -#define DISK_REMOVEABLE(TGT) (1) -#define DEVICE_TYPE(TGT) (TGT == 2 ? TYPE_TAPE : TYPE_DISK); +#define DISK_REMOVEABLE(TGT) (0) +#define DEVICE_TYPE(TGT) (TYPE_DISK); + +#define SCSI_DEBUG_MAILBOXES (scsi_debug_num_devs + 1) + +static int scsi_debug_dev_size_mb = DEF_DEV_SIZE_MB; +#define STORE_SIZE (scsi_debug_dev_size_mb * 1024 * 1024) +#define STORE_ELEM_ORDER 1 +#define STORE_ELEM_SIZE (PAGE_SIZE * (1 << STORE_ELEM_ORDER)) +#define STORE_ELEMENTS ((STORE_SIZE / STORE_ELEM_SIZE) + 1) + +/* default sector size is 512 bytes, 2**9 bytes */ +#define POW2_SECT_SIZE 9 +#define SECT_SIZE (1 << POW2_SECT_SIZE) + +#define N_CYLINDER (STORE_SIZE / (SECT_SIZE * N_SECTOR * N_HEAD)) + +static int scsi_debug_fake_blk0 = DEF_FAKE_BLK0; /* Do not attempt to use a timer to simulate a real disk with latency */ /* Only use this in the actual kernel, not in the simulator. */ #define IMMEDIATE -/* Skip some consistency checking. Good for benchmarking */ -#define SPEEDY -/* Read return zeros. Undefine for benchmarking */ -#define CLEAR - -/* Number of real scsi disks that will be detected ahead of time */ -static int NR_REAL = -1; - -#define NR_BLK_DEV 12 -#ifndef MAJOR_NR -#define MAJOR_NR 8 -#endif +#define SDEBUG_SG_ADDRESS + #define START_PARTITION 4 /* Time to wait before completing a command */ #define DISK_SPEED (HZ/10) /* 100ms */ #define CAPACITY (N_HEAD * N_SECTOR * N_CYLINDER) -#define SIZE(TGT) (TGT == 2 ? 2248 : 512) +#define SECT_SIZE_PER(TGT) SECT_SIZE +#define SECT_PER_ELEM (STORE_ELEM_SIZE / SECT_SIZE) static int starts[] = {N_SECTOR, N_HEAD * N_SECTOR, /* Single cylinder */ N_HEAD * N_SECTOR * 4, - CAPACITY, 0}; + 0 /* CAPACITY */, 0}; static int npart = 0; -#include "scsi_debug.h" -#ifdef DEBUG -#define DEB(x) x -#else -#define DEB(x) -#endif +typedef struct scsi_debug_store_elem { + unsigned char * p; +} Sd_store_elem; + +static Sd_store_elem * store_arr = 0; + +typedef struct sdebug_dev_info { + Scsi_Device * sdp; + unsigned short host_no; + unsigned short id; + char reset; + char sb_index; +} Sdebug_dev_info; +static Sdebug_dev_info * devInfop; + +static int num_aborts = 0; +static int num_dev_resets = 0; +static int num_bus_resets = 0; +static int num_host_resets = 0; -#ifdef SPEEDY -#define VERIFY1_DEBUG(RW) -#define VERIFY_DEBUG(RW) -#else +static spinlock_t mailbox_lock = SPIN_LOCK_UNLOCKED; +static rwlock_t sdebug_atomic_rw = RW_LOCK_UNLOCKED; -#define VERIFY1_DEBUG(RW) \ - if (bufflen != 1024) {printk("%d", bufflen); panic("(1)Bad bufflen");}; \ - start = 0; \ - if ((MINOR(SCpnt->request.rq_dev) & 0xf) != 0) start = starts[(MINOR(SCpnt->request.rq_dev) & 0xf) - 1]; \ - if (bh){ \ - if (bh->b_size != 1024) panic ("Wrong bh size"); \ - if ((bh->b_blocknr << 1) + start != block) \ - { printk("Wrong bh block# %d %d ",bh->b_blocknr, block); \ - panic ("Wrong bh block#"); \ - }; \ - if (bh->b_dev != SCpnt->request.rq_dev) \ - panic ("Bad bh target"); \ - }; - -#define VERIFY_DEBUG(RW) \ - if (bufflen != 1024 && (!SCpnt->use_sg)) {printk("%x %d\n ",bufflen, SCpnt->use_sg); panic("Bad bufflen");}; \ - start = 0; \ - if ((MINOR(SCpnt->request.rq_dev) & 0xf) > npart) panic ("Bad partition"); \ - if ((MINOR(SCpnt->request.rq_dev) & 0xf) != 0) start = starts[(MINOR(SCpnt->request.rq_dev) & 0xf) - 1]; \ - if (SCpnt->request.cmd != RW) panic ("Wrong operation"); \ - if (SCpnt->request.sector + start != block) panic("Wrong block."); \ - if (SCpnt->request.current_nr_sectors != 2 && (!SCpnt->use_sg)) panic ("Wrong # blocks"); \ - if (SCpnt->request.bh){ \ - if (SCpnt->request.bh->b_size != 1024) panic ("Wrong bh size"); \ - if ((SCpnt->request.bh->b_blocknr << 1) + start != block) \ - { printk("Wrong bh block# %d %d ",SCpnt->request.bh->b_blocknr, block); \ - panic ("Wrong bh block#"); \ - }; \ - if (SCpnt->request.bh->b_dev != SCpnt->request.rq_dev) \ - panic ("Bad bh target");\ - }; -#endif +#include "scsi_debug.h" typedef void (*done_fct_t) (Scsi_Cmnd *); -static volatile done_fct_t do_done[SCSI_DEBUG_MAILBOXES] = -{NULL,}; +static volatile done_fct_t * do_done = 0; struct Scsi_Host * SHpnt = NULL; +static int scsi_debug_read(Scsi_Cmnd * SCpnt, int upper_blk, int block, + int num, int * errstsp, Sdebug_dev_info * devip); +static int scsi_debug_write(Scsi_Cmnd * SCpnt, int upper_blk, int block, + int num, int * errstsp, Sdebug_dev_info * devip); static void scsi_debug_send_self_command(struct Scsi_Host * shpnt); static void scsi_debug_intr_handle(unsigned long); +static Sdebug_dev_info * devInfoReg(Scsi_Device * sdp); +static void mk_sense_buffer(Sdebug_dev_info * devip, int index, int key, + int asc, int asq, int inbandLen); +static int check_reset(Scsi_Cmnd * SCpnt, Sdebug_dev_info * devip); -static struct timer_list timeout[SCSI_DEBUG_MAILBOXES]; - -Scsi_Cmnd *SCint[SCSI_DEBUG_MAILBOXES] = -{NULL,}; -static char SCrst[SCSI_DEBUG_MAILBOXES] = -{0,}; +static struct timer_list * timeout = 0; +static Scsi_Cmnd ** SCint = 0; /* * Semaphore used to simulate bus lockups. */ static int scsi_debug_lockup = 0; -static char sense_buffer[128] = -{0,}; +#define NUM_SENSE_BUFFS 4 +#define SENSE_BUFF_LEN 32 +static char sense_buffers[NUM_SENSE_BUFFS][SENSE_BUFF_LEN]; -static void scsi_dump(Scsi_Cmnd * SCpnt, int flag) +static int made_block0 = 0; + +static void scsi_debug_mkblock0(unsigned char * buff, int bufflen, + Scsi_Cmnd * SCpnt) { int i; -#if 0 - unsigned char *pnt; -#endif - unsigned int *lpnt; - struct scatterlist *sgpnt = NULL; - printk("use_sg: %d", SCpnt->use_sg); - if (SCpnt->use_sg) { - sgpnt = (struct scatterlist *) SCpnt->buffer; - for (i = 0; i < SCpnt->use_sg; i++) { - printk(":%p %d\n", sgpnt[i].address, sgpnt[i].length); - }; - } else { - printk("nosg: %p %p %d\n", SCpnt->request.buffer, SCpnt->buffer, - SCpnt->bufflen); - lpnt = (int *) SCpnt->request.buffer; - if (lpnt) - printk(" (Alt %x) ", lpnt[15]); - }; - lpnt = (unsigned int *) SCpnt; - for (i = 0; i < sizeof(Scsi_Cmnd) / 4 + 1; i++) { - if ((i & 7) == 0) - printk("\n"); - printk("%x ", *lpnt++); - }; - printk("\n"); - if (flag == 0) - return; -#if 0 - printk("\n"); - lpnt = (unsigned int *) sgpnt[0].address; - for (i = 0; i < sizeof(Scsi_Cmnd) / 4 + 1; i++) { - if ((i & 7) == 0) - printk("\n"); - printk("%x ", *lpnt++); - }; - printk("\n"); -#endif + struct partition *p; + + memset(buff, 0, bufflen); + *((unsigned short *) (buff + 510)) = 0xAA55; + p = (struct partition *) (buff + 0x1be); + i = 0; + while (starts[i + 1]) { + int start_cyl, end_cyl; + + start_cyl = starts[i] / N_HEAD / N_SECTOR; + end_cyl = (starts[i + 1] - 1) / N_HEAD / N_SECTOR; + p->boot_ind = 0; + + p->head = (i == 0 ? 1 : 0); + p->sector = 1 | ((start_cyl >> 8) << 6); + p->cyl = (start_cyl & 0xff); + + p->end_head = N_HEAD - 1; + p->end_sector = N_SECTOR | ((end_cyl >> 8) << 6); + p->end_cyl = (end_cyl & 0xff); + + p->start_sect = starts[i]; + p->nr_sects = starts[i + 1] - starts[i]; + p->sys_ind = 0x83; /* Linux ext2 partition */ + p++; + i++; + } + if (!npart) + npart = i; + made_block0 = 1; + i = (bufflen > STORE_ELEM_SIZE) ? STORE_ELEM_SIZE : bufflen; + memcpy(store_arr[0].p, buff, i); } int scsi_debug_queuecommand(Scsi_Cmnd * SCpnt, void (*done) (Scsi_Cmnd *)) { unchar *cmd = (unchar *) SCpnt->cmnd; - struct partition *p; int block; - struct buffer_head *bh = NULL; + int upper_blk; unsigned char *buff; - int nbytes, sgcount; int scsi_debug_errsts; - struct scatterlist *sgpnt; int target = SCpnt->target; int bufflen = SCpnt->request_bufflen; - unsigned long flags; - int i; - sgcount = 0; - sgpnt = NULL; + unsigned long iflags; + int i, num, capac; + Sdebug_dev_info * devip = NULL; + char * sbuff; #ifdef CONFIG_SMP /* * The io_request_lock *must* be held at this point. */ - if( io_request_lock.lock == 0 ) + if(! spin_is_locked(&io_request_lock)) { - printk("Warning - io_request_lock is not held in queuecommand\n"); + printk("Warning - io_request_lock is not held in " + "queuecommand\n"); } #endif /* - * If we are being notified of the mid-level reposessing a command due to timeout, - * just return. + * If we are being notified of the mid-level reposessing a command + * due to timeout, just return. */ if (done == NULL) { return 0; } - DEB(if (target >= NR_FAKE_DISKS) { - SCpnt->result = DID_TIME_OUT << 16; done(SCpnt); return 0; - } - ); buff = (unsigned char *) SCpnt->request_buffer; @@ -229,249 +239,201 @@ * If a command comes for the ID of the host itself, just print * a silly message and return. */ - if( target == 7 ) { + if(target == 7) { printk("How do you do!\n"); SCpnt->result = 0; done(SCpnt); return 0; } - if (target >= NR_FAKE_DISKS || SCpnt->lun != 0) { + if ((target > 7) || (SCpnt->lun != 0)) { SCpnt->result = DID_NO_CONNECT << 16; done(SCpnt); return 0; } - if (SCrst[target] != 0 && !scsi_debug_lockup) { - SCrst[target] = 0; - memset(SCpnt->sense_buffer, 0, sizeof(SCpnt->sense_buffer)); - SCpnt->sense_buffer[0] = 0x70; - SCpnt->sense_buffer[2] = UNIT_ATTENTION; - SCpnt->result = (CHECK_CONDITION << 1); - done(SCpnt); +#if 0 + printk(KERN_INFO "sdebug:qc: host_no=%d, id=%d, sdp=%p, cmd=0x%x\n", + (int)SCpnt->device->host->host_no, (int)SCpnt->device->id, + SCpnt->device, (int)(unsigned char)*cmd); +#endif + if (NULL == SCpnt->device->hostdata) { + devip = devInfoReg(SCpnt->device); + if (NULL == devip) { + SCpnt->result = DID_NO_CONNECT << 16; + done(SCpnt); + return 0; + } + SCpnt->device->hostdata = devip; } + devip = SCpnt->device->hostdata; + switch (*cmd) { - case REQUEST_SENSE: + case REQUEST_SENSE: /* mandatory */ SCSI_LOG_LLQUEUE(3, printk("Request sense...\n")); -#ifndef DEBUG - { - int i; - printk("scsi_debug: Requesting sense buffer (%p %p %p %d):", SCpnt, buff, done, bufflen); - for (i = 0; i < 12; i++) - printk("%d ", sense_buffer[i]); - printk("\n"); - }; -#endif - memset(buff, 0, bufflen); - memcpy(buff, sense_buffer, bufflen); - memset(sense_buffer, 0, sizeof(sense_buffer)); + if (devip) { + sbuff = &sense_buffers[(int)devip->sb_index][0]; + devip->sb_index = 0; + } + else + sbuff = &sense_buffers[0][0]; + memcpy(buff, sbuff, (bufflen < SENSE_BUFF_LEN) ? + bufflen : SENSE_BUFF_LEN); + memset(sbuff, 0, SENSE_BUFF_LEN); + sbuff[0] = 0x70; SCpnt->result = 0; done(SCpnt); return 0; case START_STOP: + if (check_reset(SCpnt, devip)) { + done(SCpnt); + return 0; + } SCSI_LOG_LLQUEUE(3, printk("START_STOP\n")); scsi_debug_errsts = 0; break; case ALLOW_MEDIUM_REMOVAL: + if (check_reset(SCpnt, devip)) { + done(SCpnt); + return 0; + } if (cmd[4]) { - SCSI_LOG_LLQUEUE(2, printk("Medium removal inhibited...")); + SCSI_LOG_LLQUEUE(2, printk( + "Medium removal inhibited...")); } else { - SCSI_LOG_LLQUEUE(2, printk("Medium removal enabled...")); + SCSI_LOG_LLQUEUE(2, + printk("Medium removal enabled...")); } scsi_debug_errsts = 0; break; - case INQUIRY: + case INQUIRY: /* mandatory */ SCSI_LOG_LLQUEUE(3, printk("Inquiry...(%p %d)\n", buff, bufflen)); memset(buff, 0, bufflen); buff[0] = DEVICE_TYPE(target); - buff[1] = DISK_REMOVEABLE(target) ? 0x80 : 0; /* Removable disk */ - buff[2] = 1; - buff[4] = 33 - 5; - memcpy(&buff[8], "Foo Inc", 7); - memcpy(&buff[16], "XYZZY", 5); - memcpy(&buff[32], "1", 1); + buff[1] = DISK_REMOVEABLE(target) ? 0x80 : 0; + /* Removable disk */ + buff[2] = 2; /* claim SCSI 2 */ + buff[4] = 36 - 5; + memcpy(&buff[8], "Linux ", 8); + memcpy(&buff[16], "scsi_debug ", 16); + memcpy(&buff[32], "0002", 4); scsi_debug_errsts = 0; +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,10) + if (SCpnt->host->max_cmd_len != SCSI_DEBUG_MAX_CMD_LEN) + SCpnt->host->max_cmd_len = SCSI_DEBUG_MAX_CMD_LEN; +#endif break; - case TEST_UNIT_READY: + case SEND_DIAGNOSTIC: /* mandatory */ + SCSI_LOG_LLQUEUE(3, printk("Send Diagnostic\n")); + if (buff) + memset(buff, 0, bufflen); + scsi_debug_errsts = 0; + break; + case TEST_UNIT_READY: /* mandatory */ SCSI_LOG_LLQUEUE(3, printk("Test unit ready(%p %d)\n", buff, bufflen)); if (buff) memset(buff, 0, bufflen); scsi_debug_errsts = 0; break; case READ_CAPACITY: + if (check_reset(SCpnt, devip)) { + done(SCpnt); + return 0; + } SCSI_LOG_LLQUEUE(3, printk("Read Capacity\n")); SHpnt = SCpnt->host; - if (NR_REAL < 0) - NR_REAL = (MINOR(SCpnt->request.rq_dev) >> 4) & 0x0f; memset(buff, 0, bufflen); - buff[0] = (CAPACITY >> 24); - buff[1] = (CAPACITY >> 16) & 0xff; - buff[2] = (CAPACITY >> 8) & 0xff; - buff[3] = CAPACITY & 0xff; + capac = CAPACITY - 1; + buff[0] = (capac >> 24); + buff[1] = (capac >> 16) & 0xff; + buff[2] = (capac >> 8) & 0xff; + buff[3] = capac & 0xff; buff[4] = 0; buff[5] = 0; - buff[6] = (SIZE(target) >> 8) & 0xff; /* 512 byte sectors */ - buff[7] = SIZE(target) & 0xff; + buff[6] = (SECT_SIZE_PER(target) >> 8) & 0xff; + buff[7] = SECT_SIZE_PER(target) & 0xff; scsi_debug_errsts = 0; break; + case SCSI_CMD_READ_16: /* SBC-2 */ + case READ_12: case READ_10: case READ_6: -#ifdef DEBUG - printk("Read..."); -#endif - if ((*cmd) == READ_10) - block = cmd[5] + (cmd[4] << 8) + (cmd[3] << 16) + (cmd[2] << 24); - else - block = cmd[3] + (cmd[2] << 8) + ((cmd[1] & 0x1f) << 16); - VERIFY_DEBUG(READ); -#if defined(SCSI_SETUP_LATENCY) || defined(SCSI_DATARATE) - { - int delay = SCSI_SETUP_LATENCY; - - delay += SCpnt->request.nr_sectors * SCSI_DATARATE; - if (delay) - usleep(delay); - }; -#endif - -#ifdef DEBUG - printk("(r%d)", SCpnt->request.nr_sectors); -#endif - nbytes = bufflen; - if (SCpnt->use_sg) { - sgcount = 0; - sgpnt = (struct scatterlist *) buff; - buff = sgpnt[sgcount].address; - bufflen = sgpnt[sgcount].length; - bh = SCpnt->request.bh; - }; - scsi_debug_errsts = 0; - do { - VERIFY1_DEBUG(READ); - /* For the speedy test, we do not even want to fill the buffer with anything */ -#ifdef CLEAR - memset(buff, 0, bufflen); -#endif - /* If this is block 0, then we want to read the partition table for this - * device. Let's make one up */ - if (block == 0) { - int i; - memset(buff, 0, bufflen); - *((unsigned short *) (buff + 510)) = 0xAA55; - p = (struct partition *) (buff + 0x1be); - i = 0; - while (starts[i + 1]) { - int start_cyl, end_cyl; - - start_cyl = starts[i] / N_HEAD / N_SECTOR; - end_cyl = (starts[i + 1] - 1) / N_HEAD / N_SECTOR; - p->boot_ind = 0; - - p->head = (i == 0 ? 1 : 0); - p->sector = 1 | ((start_cyl >> 8) << 6); - p->cyl = (start_cyl & 0xff); - - p->end_head = N_HEAD - 1; - p->end_sector = N_SECTOR | ((end_cyl >> 8) << 6); - p->end_cyl = (end_cyl & 0xff); - - p->start_sect = starts[i]; - p->nr_sects = starts[i + 1] - starts[i]; - p->sys_ind = 0x81; /* Linux partition */ - p++; - i++; - }; - if (!npart) - npart = i; - scsi_debug_errsts = 0; - break; - }; -#ifdef DEBUG - if (SCpnt->use_sg) - printk("Block %x (%d %d)\n", block, SCpnt->request.nr_sectors, - SCpnt->request.current_nr_sectors); -#endif - -#if 0 - /* Simulate a disk change */ - if (block == 0xfff0) { - sense_buffer[0] = 0x70; - sense_buffer[2] = UNIT_ATTENTION; - starts[0] += 10; - starts[1] += 10; - starts[2] += 10; - -#ifdef DEBUG - { - int i; - printk("scsi_debug: Filling sense buffer:"); - for (i = 0; i < 12; i++) - printk("%d ", sense_buffer[i]); - printk("\n"); - }; -#endif - scsi_debug_errsts = (COMMAND_COMPLETE << 8) | (CHECK_CONDITION << 1); - break; - } /* End phony disk change code */ -#endif - -#ifdef CLEAR - memcpy(buff, &target, sizeof(target)); - memcpy(buff + sizeof(target), cmd, 24); - memcpy(buff + 60, &block, sizeof(block)); - memcpy(buff + 64, SCpnt, sizeof(Scsi_Cmnd)); -#endif - nbytes -= bufflen; - if (SCpnt->use_sg) { -#ifdef CLEAR - memcpy(buff + 128, bh, sizeof(struct buffer_head)); -#endif - block += bufflen >> 9; - bh = bh->b_reqnext; - sgcount++; - if (nbytes) { - if (!bh) - panic("Too few blocks for linked request."); - buff = sgpnt[sgcount].address; - bufflen = sgpnt[sgcount].length; - }; - } - } while (nbytes); - + if (check_reset(SCpnt, devip)) { + done(SCpnt); + return 0; + } + upper_blk = 0; + if ((*cmd) == SCSI_CMD_READ_16) { + upper_blk = cmd[5] + (cmd[4] << 8) + + (cmd[3] << 16) + (cmd[2] << 24); + block = cmd[9] + (cmd[8] << 8) + + (cmd[7] << 16) + (cmd[6] << 24); + num = cmd[13] + (cmd[12] << 8) + + (cmd[11] << 16) + (cmd[10] << 24); + } + else if ((*cmd) == READ_12) { + block = cmd[5] + (cmd[4] << 8) + + (cmd[3] << 16) + (cmd[2] << 24); + num = cmd[9] + (cmd[8] << 8) + + (cmd[7] << 16) + (cmd[6] << 24); + } + else if ((*cmd) == READ_10) { + block = cmd[5] + (cmd[4] << 8) + + (cmd[3] << 16) + (cmd[2] << 24); + num = cmd[8] + (cmd[7] << 8); + } + else { + block = cmd[3] + (cmd[2] << 8) + + ((cmd[1] & 0x1f) << 16); + num = cmd[4]; + } + if (scsi_debug_read(SCpnt, upper_blk, block, num, + &scsi_debug_errsts, devip)) + break; SCpnt->result = 0; - (done) (SCpnt); +/* calls bottom half in upper layers before return from scsi_do_...() */ + (done) (SCpnt); return 0; - - if (SCpnt->use_sg && !scsi_debug_errsts) - if (bh) - scsi_dump(SCpnt, 0); - break; + case SCSI_CMD_WRITE_16: /* SBC-2 */ + case WRITE_12: case WRITE_10: case WRITE_6: -#ifdef DEBUG - printk("Write\n"); -#endif - if ((*cmd) == WRITE_10) - block = cmd[5] + (cmd[4] << 8) + (cmd[3] << 16) + (cmd[2] << 24); - else - block = cmd[3] + (cmd[2] << 8) + ((cmd[1] & 0x1f) << 16); - VERIFY_DEBUG(WRITE); - /* printk("(w%d)",SCpnt->request.nr_sectors); */ - if (SCpnt->use_sg) { - if ((bufflen >> 9) != SCpnt->request.nr_sectors) - panic("Trying to write wrong number of blocks\n"); - sgpnt = (struct scatterlist *) buff; - buff = sgpnt[sgcount].address; - }; -#if 0 - if (block != *((unsigned long *) (buff + 60))) { - printk("%x %x :", block, *((unsigned long *) (buff + 60))); - scsi_dump(SCpnt, 1); - panic("Bad block written.\n"); - }; -#endif - scsi_debug_errsts = 0; - break; + if (check_reset(SCpnt, devip)) { + done(SCpnt); + return 0; + } + upper_blk = 0; + if ((*cmd) == SCSI_CMD_WRITE_16) { + upper_blk = cmd[5] + (cmd[4] << 8) + + (cmd[3] << 16) + (cmd[2] << 24); + block = cmd[9] + (cmd[8] << 8) + + (cmd[7] << 16) + (cmd[6] << 24); + num = cmd[13] + (cmd[12] << 8) + + (cmd[11] << 16) + (cmd[10] << 24); + } + else if ((*cmd) == WRITE_12) { + block = cmd[5] + (cmd[4] << 8) + + (cmd[3] << 16) + (cmd[2] << 24); + num = cmd[9] + (cmd[8] << 8) + + (cmd[7] << 16) + (cmd[6] << 24); + } + else if ((*cmd) == WRITE_10) { + block = cmd[5] + (cmd[4] << 8) + + (cmd[3] << 16) + (cmd[2] << 24); + num = cmd[8] + (cmd[7] << 8); + } + else { + block = cmd[3] + (cmd[2] << 8) + + ((cmd[1] & 0x1f) << 16); + num = cmd[4]; + } + if (scsi_debug_write(SCpnt, upper_blk, block, num, + &scsi_debug_errsts, devip)) + break; + SCpnt->result = 0; +/* calls bottom half in upper layers before return from scsi_do_...() */ + (done) (SCpnt); + return 0; case MODE_SENSE: /* * Used to detect write protected status. @@ -480,26 +442,36 @@ memset(buff, 0, 6); break; default: +#if 0 SCSI_LOG_LLQUEUE(3, printk("Unknown command %d\n", *cmd)); SCpnt->result = DID_NO_CONNECT << 16; done(SCpnt); return 0; - }; +#else + if (check_reset(SCpnt, devip)) { + done(SCpnt); + return 0; + } + scsi_debug_errsts = (COMMAND_COMPLETE << 8) | + (CHECK_CONDITION << 1); + mk_sense_buffer(devip, 2, ILLEGAL_REQUEST, 0x20, 0, 14); + break; +#endif + } - save_flags(flags); - cli(); + spin_lock_irqsave(&mailbox_lock, iflags); for (i = 0; i < SCSI_DEBUG_MAILBOXES; i++) { if (timeout[i].function == NULL) break; - }; + } /* - * If all of the slots are full, just return 1. The new error handling scheme - * allows this, and the mid-level should queue things. + * If all of the slots are full, just return 1. The new error + * handling scheme allows this, and the mid-level should queue things. */ if (i >= SCSI_DEBUG_MAILBOXES || timeout[i].function != 0) { SCSI_LOG_LLQUEUE(1, printk("Command rejected - host busy\n")); - restore_flags(flags); + spin_unlock_irqrestore(&mailbox_lock, iflags); return 1; } SCSI_LOG_LLQUEUE(1, printk("Command accepted - slot %d\n", i)); @@ -511,7 +483,7 @@ do_done[i] = done; scsi_debug_intr_handle(i); /* No timer - do this one right away */ } - restore_flags(flags); + spin_unlock_irqrestore(&mailbox_lock, iflags); #else SCpnt->result = scsi_debug_errsts; @@ -521,16 +493,197 @@ SCint[i] = SCpnt; do_done[i] = done; - restore_flags(flags); + spin_unlock_irqrestore(&mailbox_lock, iflags); add_timer(&timeout[i]); if (!done) - panic("scsi_debug_queuecommand: done can't be NULL\n"); + printk("scsi_debug_queuecommand: done can't be NULL\n"); #if 0 - printk("Sending command (%d %x %d %d)...", i, done, timeout[i].expires, jiffies); + printk("Sending command (%d %x %d %d)...", i, done, + timeout[i].expires, jiffies); +#endif +#endif + + return 0; +} + +static int check_reset(Scsi_Cmnd * SCpnt, Sdebug_dev_info * devip) +{ + if (devip->reset) { + devip->reset = 0; + mk_sense_buffer(devip, 3, UNIT_ATTENTION, 0x29, 0, 14); + SCpnt->result = (COMMAND_COMPLETE << 8) | + (CHECK_CONDITION << 1); + return 1; + } + return 0; +} + +static inline +unsigned char * sdebug_scatg2virt(const struct scatterlist * sclp) +{ + if (NULL == sclp) + return NULL; + else if (sclp->page) + return (unsigned char *)page_address(sclp->page) + + sclp->offset; + else { +#ifdef SDEBUG_SG_ADDRESS + return sclp->address; +#else + return NULL; +#endif + } +} + +static int scsi_debug_read(Scsi_Cmnd * SCpnt, int upper_blk, int block, + int num, int * errstsp, Sdebug_dev_info * devip) +{ + unsigned char *buff = (unsigned char *) SCpnt->request_buffer; + int nbytes, sgcount; + struct scatterlist *sgpnt = NULL; + int bufflen = SCpnt->request_bufflen; + unsigned long iflags; + + if (upper_blk || (block + num > CAPACITY)) { + *errstsp = (COMMAND_COMPLETE << 8) | + (CHECK_CONDITION << 1); + mk_sense_buffer(devip, 1, ILLEGAL_REQUEST, 0x21, 0, 14); + return 1; + } +#if defined(SCSI_SETUP_LATENCY) || defined(SCSI_DATARATE) + { + int delay = SCSI_SETUP_LATENCY; + + delay += SCpnt->request.nr_sectors * SCSI_DATARATE; + if (delay) + usleep(delay); + } #endif + + read_lock_irqsave(&sdebug_atomic_rw, iflags); + sgcount = 0; + nbytes = bufflen; + /* printk("scsi_debug_read: block=%d, tot_bufflen=%d\n", + block, bufflen); */ + if (SCpnt->use_sg) { + sgcount = 0; + sgpnt = (struct scatterlist *) buff; + buff = sdebug_scatg2virt(&sgpnt[sgcount]); + bufflen = sgpnt[sgcount].length; + } + *errstsp = 0; + do { + int resid, k, off, len, rem, blk; + unsigned char * bp; + + /* If this is block 0, then we want to read the partition + * table for this device. Let's make one up */ + if (scsi_debug_fake_blk0 && (block == 0) && (! made_block0)) { + scsi_debug_mkblock0(buff, bufflen, SCpnt); + *errstsp = 0; + break; + } + bp = buff; + blk = block; + for (resid = bufflen; resid > 0; resid -= len) { + k = blk / SECT_PER_ELEM; + off = (blk % SECT_PER_ELEM) * SECT_SIZE; + rem = STORE_ELEM_SIZE - off; + len = (resid > rem) ? rem : resid; +/* printk("sdr: blk=%d k=%d off=%d rem=%d resid" + "=%d len=%d sgcount=%d\n", blk, k, + off, rem, resid, len, sgcount); */ + memcpy(bp, store_arr[k].p + off, len); + bp += len; + blk += len / SECT_SIZE; + } +#if 0 + /* Simulate a disk change */ + if (block == 0xfff0) { + sense_buffer[0] = 0x70; + sense_buffer[2] = UNIT_ATTENTION; + starts[0] += 10; + starts[1] += 10; + starts[2] += 10; + + *errstsp = (COMMAND_COMPLETE << 8) | + (CHECK_CONDITION << 1); + read_unlock_irqrestore(&sdebug_atomic_rw, iflags); + return 1; + } /* End phony disk change code */ #endif + nbytes -= bufflen; + if (SCpnt->use_sg) { + block += bufflen >> POW2_SECT_SIZE; + sgcount++; + if (nbytes) { + buff = sdebug_scatg2virt(&sgpnt[sgcount]); + bufflen = sgpnt[sgcount].length; + } + } + else if (nbytes > 0) + printk("sdebug_read: unexpected nbytes=%d\n", nbytes); + } while (nbytes); + read_unlock_irqrestore(&sdebug_atomic_rw, iflags); + return 0; +} + +static int scsi_debug_write(Scsi_Cmnd * SCpnt, int upper_blk, int block, + int num, int * errstsp, Sdebug_dev_info * devip) +{ + unsigned char *buff = (unsigned char *) SCpnt->request_buffer; + int nbytes, sgcount; + struct scatterlist *sgpnt = NULL; + int bufflen = SCpnt->request_bufflen; + unsigned long iflags; + + if (upper_blk || (block + num > CAPACITY)) { + *errstsp = (COMMAND_COMPLETE << 8) | + (CHECK_CONDITION << 1); + mk_sense_buffer(devip, 1, ILLEGAL_REQUEST, 0x21, 0, 14); + return 1; + } + write_lock_irqsave(&sdebug_atomic_rw, iflags); + sgcount = 0; + nbytes = bufflen; + if (SCpnt->use_sg) { + sgcount = 0; + sgpnt = (struct scatterlist *) buff; + buff = sdebug_scatg2virt(&sgpnt[sgcount]); + bufflen = sgpnt[sgcount].length; + } + *errstsp = 0; + do { + int resid, k, off, len, rem, blk; + unsigned char * bp; + + bp = buff; + blk = block; + for (resid = bufflen; resid > 0; resid -= len) { + k = blk / SECT_PER_ELEM; + off = (blk % SECT_PER_ELEM) * SECT_SIZE; + rem = STORE_ELEM_SIZE - off; + len = (resid > rem) ? rem : resid; + memcpy(store_arr[k].p + off, bp, len); + bp += len; + blk += len / SECT_SIZE; + } + + nbytes -= bufflen; + if (SCpnt->use_sg) { + block += bufflen >> POW2_SECT_SIZE; + sgcount++; + if (nbytes) { + buff = sdebug_scatg2virt(&sgpnt[sgcount]); + bufflen = sgpnt[sgcount].length; + } + } + else if (nbytes > 0) + printk("sdebug_write: unexpected nbytes=%d\n", nbytes); + } while (nbytes); + write_unlock_irqrestore(&sdebug_atomic_rw, iflags); return 0; } @@ -581,10 +734,6 @@ { Scsi_Cmnd *SCtmp; void (*my_done) (Scsi_Cmnd *); -#ifdef DEBUG - int to; -#endif - #if 0 del_timer(&timeout[indx]); #endif @@ -599,59 +748,213 @@ printk("scsi_debug_intr_handle: Unexpected interrupt\n"); return; } -#ifdef DEBUG +#if 0 printk("In intr_handle..."); printk("...done %d %x %d %d\n", i, my_done, to, jiffies); printk("In intr_handle: %d %x %x\n", i, SCtmp, my_done); #endif my_done(SCtmp); -#ifdef DEBUG +#if 0 printk("Called done.\n"); #endif } +static int initialized = 0; + +static int do_init(void) +{ + int sz; + + starts[3] = CAPACITY; + sz = sizeof(Sd_store_elem) * STORE_ELEMENTS; + store_arr = kmalloc(sz, GFP_ATOMIC); + if (NULL == store_arr) + return 1; + memset(store_arr, 0, sz); + sz = sizeof(done_fct_t) * SCSI_DEBUG_MAILBOXES; + do_done = kmalloc(sz, GFP_ATOMIC); + if (NULL == do_done) { + kfree(store_arr); + return 1; + } + memset((void *)do_done, 0, sz); + sz = sizeof(struct timer_list) * SCSI_DEBUG_MAILBOXES; + timeout = kmalloc(sz, GFP_ATOMIC); + if (NULL == timeout) { + kfree((void *)do_done); + kfree(store_arr); + return 1; + } + memset(timeout, 0, sz); + sz = sizeof(Scsi_Cmnd *) * SCSI_DEBUG_MAILBOXES; + SCint = kmalloc(sz, GFP_ATOMIC); + if (NULL == SCint) { + kfree(timeout); + kfree((void *)do_done); + kfree(store_arr); + return 1; + } + memset(SCint, 0, sz); + return 0; +} + +static void do_end(void) +{ + kfree(SCint); + kfree(timeout); + kfree((void *)do_done); + kfree(store_arr); +} + int scsi_debug_detect(Scsi_Host_Template * tpnt) { - int i; + int k, num, sz; + + if (0 == initialized) { + ++initialized; + sz = sizeof(Sdebug_dev_info) * scsi_debug_num_devs; + devInfop = kmalloc(sz, GFP_ATOMIC); + if (NULL == devInfop) { + printk("scsi_debug_detect: out of memory, 0.5\n"); + return 0; + } + memset(devInfop, 0, sz); + if (do_init()) { + printk("scsi_debug_detect: out of memory, 0\n"); + return 0; + } + for (k = 0; k < STORE_ELEMENTS; ++k) { + store_arr[k].p = (unsigned char *) + __get_free_pages(GFP_ATOMIC, STORE_ELEM_ORDER); + if (0 == store_arr[k].p) + goto detect_err; + memset(store_arr[k].p, 0, STORE_ELEM_SIZE); + } + for (k = 0; k < NUM_SENSE_BUFFS; ++k) + sense_buffers[k][0] = 0x70; + for (k = 0; k < NR_HOSTS_PRESENT; k++) { + tpnt->proc_name = "scsi_debug"; /* In the loop??? */ + scsi_register(tpnt, 0); + } + return NR_HOSTS_PRESENT; + } + else { + printk("scsi_debug_detect: called again\n"); + return 0; + } + +detect_err: + num = k; + for (k = 0; k < STORE_ELEMENTS; ++k) { + if (0 != store_arr[k].p) { + free_pages((unsigned long)store_arr[k].p, + STORE_ELEM_ORDER); + store_arr[k].p = NULL; + } + } + printk("scsi_debug_detect: out of memory: %d out of %d bytes\n", + (int)(num * STORE_ELEM_SIZE), + (int)(scsi_debug_dev_size_mb * 1024 * 1024)); + return 0; +} + + +static int num_releases = 0; + +int scsi_debug_release(struct Scsi_Host * hpnt) +{ + int k; + + scsi_unregister(hpnt); + if (++num_releases != NR_HOSTS_PRESENT) + return 0; + + for (k = 0; k < STORE_ELEMENTS; ++k) { + if (0 != store_arr[k].p) { + free_pages((unsigned long)store_arr[k].p, + STORE_ELEM_ORDER); + store_arr[k].p = NULL; + } + } + do_end(); + kfree(devInfop); + return 0; +} - for (i = 0; i < NR_HOSTS_PRESENT; i++) { - tpnt->proc_name = "scsi_debug"; /* Huh? In the loop??? */ - scsi_register(tpnt, 0); +static Sdebug_dev_info * devInfoReg(Scsi_Device * sdp) +{ + int k; + unsigned short host_no, id; + Sdebug_dev_info * devip; + + host_no = sdp->host->host_no; + id = (unsigned short)sdp->id; + for (k = 0; k < scsi_debug_num_devs; ++k) { + devip = &devInfop[k]; + if (devip->sdp && (host_no == devip->host_no) && + (id == devip->id)) { + devip->sdp = sdp; /* overwrite previous sdp */ + return devip; + } + if (NULL == devip->sdp) { + devip->sdp = sdp; + devip->host_no = host_no; + devip->id = id; + devip->reset = 1; + devip->sb_index = 0; + return devip; + } } - return NR_HOSTS_PRESENT; + return NULL; +} + +static void mk_sense_buffer(Sdebug_dev_info * devip, int index, int key, + int asc, int asq, int inbandLen) +{ + char * sbuff; + if ((index < 0) || (index >= NUM_SENSE_BUFFS)) + return; + if (devip) + devip->sb_index = index; + sbuff = &sense_buffers[index][0]; + memset(sbuff, 0, SENSE_BUFF_LEN); + sbuff[0] = 0x70; + sbuff[2] = key; + sbuff[7] = (inbandLen > 7) ? (inbandLen - 8) : 0; + sbuff[12] = asc; + sbuff[13] = asq; } int scsi_debug_abort(Scsi_Cmnd * SCpnt) { -#if 0 +#if 1 + ++num_aborts; + return SUCCESS; +#else int j; void (*my_done) (Scsi_Cmnd *); - unsigned long flags; -#endif - - DEB(printk("scsi_debug_abort\n")); -#if 0 + unsigned long iflags; SCpnt->result = SCpnt->abort_reason << 16; for (j = 0; j < SCSI_DEBUG_MAILBOXES; j++) { if (SCpnt == SCint[j]) { my_done = do_done[j]; my_done(SCpnt); - save_flags(flags); - cli(); + spin_lock_irqsave(&mailbox_lock, iflags); timeout[j] = 0; SCint[j] = NULL; do_done[j] = NULL; - restore_flags(flags); - }; - }; -#endif + spin_unlock_irqrestore(&mailbox_lock, iflags); + } + } return SCSI_ABORT_SNOOZE; +#endif } int scsi_debug_biosparam(Disk * disk, kdev_t dev, int *info) { + /* int size = disk->capacity; */ info[0] = N_HEAD; info[1] = N_SECTOR; info[2] = N_CYLINDER; @@ -660,35 +963,130 @@ return 0; } +#if 0 int scsi_debug_reset(Scsi_Cmnd * SCpnt, unsigned int why) { int i; - unsigned long flags; + unsigned long iflags; void (*my_done) (Scsi_Cmnd *); printk("Bus unlocked by reset - %d\n", why); scsi_debug_lockup = 0; - DEB(printk("scsi_debug_reset called\n")); for (i = 0; i < SCSI_DEBUG_MAILBOXES; i++) { if (SCint[i] == NULL) continue; SCint[i]->result = DID_RESET << 16; my_done = do_done[i]; my_done(SCint[i]); - save_flags(flags); - cli(); + spin_lock_irqsave(&mailbox_lock, iflags); SCint[i] = NULL; do_done[i] = NULL; timeout[i].function = NULL; - restore_flags(flags); + spin_unlock_irqrestore(&mailbox_lock, iflags); } return SCSI_RESET_SUCCESS; } +#endif + +int scsi_debug_device_reset(Scsi_Cmnd * SCpnt) +{ + Scsi_Device * sdp; + int k; + + ++num_dev_resets; + if (SCpnt && ((sdp = SCpnt->device))) { + for (k = 0; k < scsi_debug_num_devs; ++k) { + if (sdp->hostdata == (devInfop + k)) + break; + } + if (k < scsi_debug_num_devs) + devInfop[k].reset = 1; + } + return SUCCESS; +} -const char *scsi_debug_info(void) +int scsi_debug_bus_reset(Scsi_Cmnd * SCpnt) { - static char buffer[] = " "; /* looks nicer without anything here */ - return buffer; + Scsi_Device * sdp; + struct Scsi_Host * hp; + int k; + + ++num_bus_resets; + if (SCpnt && ((sdp = SCpnt->device)) && ((hp = sdp->host))) { + for (k = 0; k < scsi_debug_num_devs; ++k) { + if (hp == devInfop[k].sdp->host) + devInfop[k].reset = 1; + } + } + return SUCCESS; +} + +int scsi_debug_host_reset(Scsi_Cmnd * SCpnt) +{ + int k; + + ++num_host_resets; + for (k = 0; k < scsi_debug_num_devs; ++k) + devInfop[k].reset = 1; + + return SUCCESS; +} + +#ifndef MODULE +static int __init scsi_debug_num_devs_setup(char *str) +{ + int tmp; + + if (get_option(&str, &tmp) == 1) { + if (tmp > 0) + scsi_debug_num_devs = tmp; + return 1; + } else { + printk("scsi_debug_num_devs: usage scsi_debug_num_devs=<n> " + "(<n> can be from 1 to around 2000)\n"); + return 0; + } +} + +__setup("scsi_debug_num_devs=", scsi_debug_num_devs_setup); + +static int __init scsi_debug_dev_size_mb_setup(char *str) +{ + int tmp; + + if (get_option(&str, &tmp) == 1) { + if (tmp > 0) + scsi_debug_dev_size_mb = tmp; + return 1; + } else { + printk("scsi_debug_dev_size_mb: usage scsi_debug_dev_size_mb=<n>\n" + " (<n> is number of MB ram shared by all devs\n"); + return 0; + } +} + +__setup("scsi_debug_dev_size_mb=", scsi_debug_dev_size_mb_setup); +#endif + +MODULE_AUTHOR("Eric Youngdale + Douglas Gilbert"); +MODULE_DESCRIPTION("SCSI debug adapter driver"); +MODULE_PARM(scsi_debug_num_devs, "i"); +MODULE_PARM_DESC(scsi_debug_num_devs, "number of SCSI devices to simulate"); +MODULE_PARM(scsi_debug_dev_size_mb, "i"); +MODULE_PARM_DESC(scsi_debug_dev_size_mb, "size in MB of ram shared by devs"); + +#ifdef MODULE_LICENSE +MODULE_LICENSE("GPL"); +#endif + +static char sdebug_info[256]; + +const char * scsi_debug_info(struct Scsi_Host * shp) +{ + sprintf(sdebug_info, "scsi_debug, %s, num_devs=%d, " + "dev_size_mb=%d\n", scsi_debug_version_str, + scsi_debug_num_devs, scsi_debug_dev_size_mb); + return sdebug_info; } /* scsi_debug_proc_info @@ -738,10 +1136,20 @@ } begin = 0; - pos = len = sprintf(buffer, - "This driver is not a real scsi driver, but it plays one on TV.\n" + pos = len = sprintf(buffer, "scsi_debug adapter driver, %s\n" + "num_devs=%d, shared (ram) size=%d MB, sector_size=%d bytes\n" + "cylinders=%d, heads=%d, sectors=%d\n" + "number of aborts=%d, device_reset=%d, bus_resets=%d, " + "host_resets=%d\n", + scsi_debug_version_str, scsi_debug_num_devs, + scsi_debug_dev_size_mb, SECT_SIZE, + N_CYLINDER, N_HEAD, N_SECTOR, + num_aborts, num_dev_resets, num_bus_resets, num_host_resets); +#if 0 + "This driver is not a real scsi driver, but it plays one on TV.\n" "It is very handy for debugging specific problems because you\n" "can simulate a variety of error conditions\n"); +#endif if (pos < offset) { len = 0; begin = pos; @@ -754,44 +1162,8 @@ return (len); } -#ifdef CONFIG_USER_DEBUG -/* - * This is a hack for the user space emulator. It allows us to - * "insert" arbitrary numbers of additional drivers. - */ -void *scsi_debug_get_handle(void) -{ - static Scsi_Host_Template driver_copy = SCSI_DEBUG; - void *rtn; - rtn = kmalloc(sizeof(driver_copy), GFP_ATOMIC); - if(rtn==NULL) - return NULL; - memcpy(rtn, (void *) &driver_copy, sizeof(driver_copy)); - return rtn; -} -#endif - /* Eventually this will go into an include file, but this will be later */ -static Scsi_Host_Template driver_template = SCSI_DEBUG; +static Scsi_Host_Template driver_template = SCSI_DEBUG_TEMPLATE; #include "scsi_module.c" -/* - * Overrides for Emacs so that we almost follow Linus's tabbing style. - * Emacs will notice this stuff at the end of the file and automatically - * adjust the settings for this buffer only. This must remain at the end - * of the file. - * --------------------------------------------------------------------------- - * Local variables: - * c-indent-level: 4 - * c-brace-imaginary-offset: 0 - * c-brace-offset: -4 - * c-argdecl-indent: 4 - * c-label-offset: -4 - * c-continued-statement-offset: 4 - * c-continued-brace-offset: 0 - * indent-tabs-mode: nil - * tab-width: 8 - * End: - */ -MODULE_LICENSE("GPL"); diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/scsi/scsi_debug.h linux-2.5/drivers/scsi/scsi_debug.h --- linux-2.5.1/drivers/scsi/scsi_debug.h Wed Nov 28 18:22:27 2001 +++ linux-2.5/drivers/scsi/scsi_debug.h Thu Dec 27 15:14:59 2001 @@ -8,34 +8,41 @@ int scsi_debug_queuecommand(Scsi_Cmnd *, void (*done) (Scsi_Cmnd *)); int scsi_debug_abort(Scsi_Cmnd *); int scsi_debug_biosparam(Disk *, kdev_t, int[]); -int scsi_debug_reset(Scsi_Cmnd *, unsigned int); +int scsi_debug_bus_reset(Scsi_Cmnd *); +int scsi_debug_dev_reset(Scsi_Cmnd *); +int scsi_debug_host_reset(Scsi_Cmnd *); int scsi_debug_proc_info(char *, char **, off_t, int, int, int); +const char * scsi_debug_info(struct Scsi_Host *); #ifndef NULL #define NULL 0 #endif - -#define SCSI_DEBUG_MAILBOXES 1 - /* - * Allow the driver to reject commands. Thus we accept only one, but - * and the mid-level will queue the remainder. + * This driver is written for the lk 2.5 series */ #define SCSI_DEBUG_CANQUEUE 255 -#define SCSI_DEBUG {proc_info: scsi_debug_proc_info, \ +#define SCSI_DEBUG_MAX_CMD_LEN 16 + +#define SCSI_DEBUG_TEMPLATE \ + {proc_info: scsi_debug_proc_info, \ name: "SCSI DEBUG", \ + info: scsi_debug_info, \ detect: scsi_debug_detect, \ + release: scsi_debug_release, \ queuecommand: scsi_debug_queuecommand, \ - abort: scsi_debug_abort, \ - reset: scsi_debug_reset, \ + eh_abort_handler: scsi_debug_abort, \ + eh_bus_reset_handler: scsi_debug_bus_reset, \ + eh_device_reset_handler: scsi_debug_device_reset, \ + eh_host_reset_handler: scsi_debug_host_reset, \ bios_param: scsi_debug_biosparam, \ can_queue: SCSI_DEBUG_CANQUEUE, \ this_id: 7, \ - sg_tablesize: 16, \ + sg_tablesize: 64, \ cmd_per_lun: 3, \ unchecked_isa_dma: 0, \ use_clustering: ENABLE_CLUSTERING, \ } + #endif diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/scsi/scsi_merge.c linux-2.5/drivers/scsi/scsi_merge.c --- linux-2.5.1/drivers/scsi/scsi_merge.c Sun Dec 16 20:20:21 2001 +++ linux-2.5/drivers/scsi/scsi_merge.c Thu Dec 20 19:14:29 2001 @@ -59,12 +59,10 @@ */ int scsi_init_io(Scsi_Cmnd *SCpnt) { - struct request *req; + struct request *req = &SCpnt->request; struct scatterlist *sgpnt; int count, gfp_mask; - req = &SCpnt->request; - /* * First we need to know how many scatter gather segments are needed. */ @@ -85,14 +83,13 @@ BUG_ON(!sgpnt); SCpnt->request_buffer = (char *) sgpnt; - SCpnt->request_bufflen = 0; + SCpnt->request_bufflen = req->nr_sectors << 9; req->buffer = NULL; /* * Next, walk the list, and fill in the addresses and sizes of * each segment. */ - SCpnt->request_bufflen = req->nr_sectors << 9; count = blk_rq_map_sg(req->q, req, SCpnt->request_buffer); /* @@ -142,8 +139,7 @@ bounce_limit = BLK_BOUNCE_ANY; else bounce_limit = SHpnt->pci_dev->dma_mask; - } - if (SHpnt->unchecked_isa_dma) + } else if (SHpnt->unchecked_isa_dma) bounce_limit = BLK_BOUNCE_ISA; blk_queue_bounce_limit(q, bounce_limit); diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/scsi/scsi_module.c linux-2.5/drivers/scsi/scsi_module.c --- linux-2.5.1/drivers/scsi/scsi_module.c Wed Sep 20 20:11:53 2000 +++ linux-2.5/drivers/scsi/scsi_module.c Thu Dec 27 22:10:28 2001 @@ -35,17 +35,17 @@ static int __init init_this_scsi_driver(void) { driver_template.module = THIS_MODULE; - scsi_register_module(MODULE_SCSI_HA, &driver_template); + scsi_register_host(&driver_template); if (driver_template.present) return 0; - scsi_unregister_module(MODULE_SCSI_HA, &driver_template); + scsi_unregister_host(&driver_template); return -ENODEV; } static void __exit exit_this_scsi_driver(void) { - scsi_unregister_module(MODULE_SCSI_HA, &driver_template); + scsi_unregister_host(&driver_template); } module_init(init_this_scsi_driver); diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/scsi/scsi_scan.c linux-2.5/drivers/scsi/scsi_scan.c --- linux-2.5.1/drivers/scsi/scsi_scan.c Sun Dec 16 20:20:21 2001 +++ linux-2.5/drivers/scsi/scsi_scan.c Mon Dec 17 01:03:06 2001 @@ -155,11 +155,14 @@ {"EMC", "SYMMETRIX", "*", BLIST_SPARSELUN}, {"CMD", "CRA-7280", "*", BLIST_SPARSELUN}, // CMD RAID Controller {"CNSI", "G7324", "*", BLIST_SPARSELUN}, // Chaparral G7324 RAID + {"CNSi", "G8324", "*", BLIST_SPARSELUN}, // Chaparral G8324 RAID {"Zzyzx", "RocketStor 500S", "*", BLIST_SPARSELUN}, {"Zzyzx", "RocketStor 2000", "*", BLIST_SPARSELUN}, {"SONY", "TSL", "*", BLIST_FORCELUN}, // DDS3 & DDS4 autoloaders {"DELL", "PERCRAID", "*", BLIST_FORCELUN}, {"HP", "NetRAID-4M", "*", BLIST_FORCELUN}, + {"ADAPTEC", "AACRAID", "*", BLIST_FORCELUN}, + {"ADAPTEC", "Adaptec 5400S", "*", BLIST_FORCELUN}, /* * Must be at end of list... @@ -498,6 +501,7 @@ Scsi_Request * SRpnt; int bflags, type = -1; extern devfs_handle_t scsi_devfs_handle; + int scsi_level; SDpnt->host = shpnt; SDpnt->id = dev; @@ -670,6 +674,7 @@ (SDpnt->scsi_level == 1 && (scsi_result[3] & 0x0f) == 1)) SDpnt->scsi_level++; + scsi_level = SDpnt->scsi_level; /* * Accommodate drivers that want to sleep when they should be in a polling @@ -747,6 +752,7 @@ SDpnt->queue_depth = 1; SDpnt->host = shpnt; SDpnt->online = TRUE; + SDpnt->scsi_level = scsi_level; /* * Register the queue for the device. All I/O requests will come diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/scsi/scsi_syms.c linux-2.5/drivers/scsi/scsi_syms.c --- linux-2.5.1/drivers/scsi/scsi_syms.c Sun Dec 16 20:20:21 2001 +++ linux-2.5/drivers/scsi/scsi_syms.c Thu Dec 27 22:10:28 2001 @@ -31,12 +31,15 @@ * This source file contains the symbol table used by scsi loadable * modules. */ -EXPORT_SYMBOL(scsi_register_module); -EXPORT_SYMBOL(scsi_unregister_module); +EXPORT_SYMBOL(scsi_register_device); +EXPORT_SYMBOL(scsi_unregister_device); +EXPORT_SYMBOL(scsi_register_host); +EXPORT_SYMBOL(scsi_unregister_host); EXPORT_SYMBOL(scsi_register); EXPORT_SYMBOL(scsi_unregister); EXPORT_SYMBOL(scsicam_bios_param); EXPORT_SYMBOL(scsi_partsize); +EXPORT_SYMBOL(scsi_bios_ptable); EXPORT_SYMBOL(scsi_allocate_device); EXPORT_SYMBOL(scsi_do_cmd); EXPORT_SYMBOL(scsi_command_size); diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/scsi/scsicam.c linux-2.5/drivers/scsi/scsicam.c --- linux-2.5.1/drivers/scsi/scsicam.c Fri Nov 19 03:09:14 1999 +++ linux-2.5/drivers/scsi/scsicam.c Thu Dec 27 22:10:28 2001 @@ -26,6 +26,22 @@ static int setsize(unsigned long capacity, unsigned int *cyls, unsigned int *hds, unsigned int *secs); +unsigned char *scsi_bios_ptable(kdev_t dev) +{ + unsigned char *res = kmalloc(66, GFP_KERNEL); + kdev_t rdev = MKDEV(MAJOR(dev), MINOR(dev) & ~0xf); + + if (res) { + struct buffer_head *bh = bread(rdev, 0, block_size(rdev)); + if (bh) { + memcpy(res, bh->b_data + 0x1be, 66); + } else { + kfree(res); + res = NULL; + } + } + return res; +} /* * Function : int scsicam_bios_param (Disk *disk, int dev, int *ip) @@ -42,26 +58,18 @@ kdev_t dev, /* Device major, minor */ int *ip /* Heads, sectors, cylinders in that order */ ) { - struct buffer_head *bh; int ret_code; int size = disk->capacity; unsigned long temp_cyl; + unsigned char *p = scsi_bios_ptable(dev); - int ma = MAJOR(dev); - int mi = (MINOR(dev) & ~0xf); - - int block = 1024; - - if(blksize_size[ma]) - block = blksize_size[ma][mi]; - - if (!(bh = bread(MKDEV(ma,mi), 0, block))) + if (!p) return -1; /* try to infer mapping from partition table */ - ret_code = scsi_partsize(bh, (unsigned long) size, (unsigned int *) ip + 2, + ret_code = scsi_partsize(p, (unsigned long) size, (unsigned int *) ip + 2, (unsigned int *) ip + 0, (unsigned int *) ip + 1); - brelse(bh); + kfree(p); if (ret_code == -1) { /* pick some standard mapping with at most 1024 cylinders, @@ -86,7 +94,7 @@ } /* - * Function : static int scsi_partsize(struct buffer_head *bh, unsigned long + * Function : static int scsi_partsize(unsigned char *buf, unsigned long * capacity,unsigned int *cyls, unsigned int *hds, unsigned int *secs); * * Purpose : to determine the BIOS mapping used to create the partition @@ -96,18 +104,17 @@ * */ -int scsi_partsize(struct buffer_head *bh, unsigned long capacity, +int scsi_partsize(unsigned char *buf, unsigned long capacity, unsigned int *cyls, unsigned int *hds, unsigned int *secs) { - struct partition *p, *largest = NULL; + struct partition *p = (struct partition *)buf, *largest = NULL; int i, largest_cyl; int cyl, ext_cyl, end_head, end_cyl, end_sector; unsigned int logical_end, physical_end, ext_physical_end; - if (*(unsigned short *) (bh->b_data + 510) == 0xAA55) { - for (largest_cyl = -1, p = (struct partition *) - (0x1BE + bh->b_data), i = 0; i < 4; ++i, ++p) { + if (*(unsigned short *) (buf + 66) == 0xAA55) { + for (largest_cyl = -1, i = 0; i < 4; ++i, ++p) { if (!p->sys_ind) continue; #ifdef DEBUG diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/scsi/sd.c linux-2.5/drivers/scsi/sd.c --- linux-2.5.1/drivers/scsi/sd.c Sun Dec 16 20:20:21 2001 +++ linux-2.5/drivers/scsi/sd.c Sun Dec 30 20:01:41 2001 @@ -99,6 +99,7 @@ static int sd_init_command(Scsi_Cmnd *); static struct Scsi_Device_Template sd_template = { + module:THIS_MODULE, name:"disk", tag:"sd", scsi_type:TYPE_DISK, @@ -968,9 +969,9 @@ */ int hard_sector = sector_size; int sz = rscsi_disks[i].capacity * (hard_sector/256); + request_queue_t *queue = &rscsi_disks[i].device->request_queue; - /* There are 16 minors allocated for each major device */ - blk_queue_hardsect_size(blk_get_queue(SD_MAJOR(i)), hard_sector); + blk_queue_hardsect_size(queue, hard_sector); printk("SCSI device %s: " "%d %d-byte hdwr sectors (%d MB)\n", nbuff, rscsi_disks[i].capacity, @@ -1332,14 +1333,14 @@ static int __init init_sd(void) { sd_template.module = THIS_MODULE; - return scsi_register_module(MODULE_SCSI_DEV, &sd_template); + return scsi_register_device(&sd_template); } static void __exit exit_sd(void) { int i; - scsi_unregister_module(MODULE_SCSI_DEV, &sd_template); + scsi_unregister_device(&sd_template); for (i = 0; i < N_USED_SD_MAJORS; i++) devfs_unregister_blkdev(SD_MAJOR(i), "sd"); diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/scsi/sg.c linux-2.5/drivers/scsi/sg.c --- linux-2.5.1/drivers/scsi/sg.c Sun Dec 16 20:20:21 2001 +++ linux-2.5/drivers/scsi/sg.c Thu Dec 27 22:10:28 2001 @@ -19,9 +19,9 @@ */ #include <linux/config.h> #ifdef CONFIG_PROC_FS - static char sg_version_str[] = "Version: 3.1.20 (20010814)"; + static char sg_version_str[] = "Version: 3.1.22 (20011208)"; #endif - static int sg_version_num = 30120; /* 2 digits for each component */ + static int sg_version_num = 30122; /* 2 digits for each component */ /* * D. P. Gilbert (dgilbert@interlog.com, dougg@triode.net.au), notes: * - scsi logging is available via SCSI_LOG_TIMEOUT macros. First @@ -82,6 +82,8 @@ #include <linux/iobuf.h> #endif +#define SG_NEW_KIOVEC 0 /* use alloc_kiovec(), not alloc_kiovec_sz() */ + int sg_big_buff = SG_DEF_RESERVED_SIZE; /* N.B. This variable is readable and writeable via /proc/scsi/sg/def_reserved_size . Each time sg_open() is called a buffer @@ -121,6 +123,7 @@ static struct Scsi_Device_Template sg_template = { + module:THIS_MODULE, tag:"sg", scsi_type:0xff, major:SCSI_GENERIC_MAJOR, @@ -135,10 +138,10 @@ typedef struct sg_scatter_hold /* holding area for scsi scatter gather info */ { unsigned short k_use_sg; /* Count of kernel scatter-gather pieces */ - unsigned short sglist_len; /* size of malloc'd scatter-gather list */ + unsigned short sglist_len; /* size of malloc'd scatter-gather list ++ */ unsigned bufflen; /* Size of (aggregate) data buffer */ unsigned b_malloc_len; /* actual len malloc'ed in buffer */ - void * buffer; /* Data buffer or scatter list,12 bytes each*/ + void * buffer; /* Data buffer or scatter list + mem_src_arr */ struct kiobuf * kiobp; /* for direct IO information */ char mapped; /* indicates kiobp has locked pages */ char buffer_mem_src; /* heap whereabouts of 'buffer' */ @@ -181,6 +184,7 @@ char cmd_q; /* 1 -> allow command queuing, 0 -> don't */ char next_cmd_len; /* 0 -> automatic (def), >0 -> use on next write() */ char keep_orphan; /* 0 -> drop orphan (def), 1 -> keep for read() */ + char mmap_called; /* 0 -> mmap() never called on this fd */ } Sg_fd; /* 2760 bytes long on i386 */ typedef struct sg_device /* holds the state of each scsi generic device */ @@ -202,7 +206,8 @@ static int sg_start_req(Sg_request * srp); static void sg_finish_rem_req(Sg_request * srp); static int sg_build_indi(Sg_scatter_hold * schp, Sg_fd * sfp, int buff_size); -static int sg_build_sgat(Sg_scatter_hold * schp, const Sg_fd * sfp); +static int sg_build_sgat(Sg_scatter_hold * schp, const Sg_fd * sfp, + int tablesize); static ssize_t sg_new_read(Sg_fd * sfp, char * buf, size_t count, Sg_request * srp); static ssize_t sg_new_write(Sg_fd * sfp, const char * buf, size_t count, @@ -232,13 +237,14 @@ static Sg_request * sg_add_request(Sg_fd * sfp); static int sg_remove_request(Sg_fd * sfp, Sg_request * srp); static int sg_res_in_use(Sg_fd * sfp); -static void sg_clr_srpnt(Scsi_Request * SRpnt); static int sg_ms_to_jif(unsigned int msecs); -static unsigned sg_jif_to_ms(int jifs); +static inline unsigned sg_jif_to_ms(int jifs); static int sg_allow_access(unsigned char opcode, char dev_type); static int sg_build_dir(Sg_request * srp, Sg_fd * sfp, int dxfer_len); static void sg_unmap_and(Sg_scatter_hold * schp, int free_also); static Sg_device * sg_get_dev(int dev); +static inline int sg_alloc_kiovec(int nr, struct kiobuf **bufp, int *szp); +static inline void sg_free_kiovec(int nr, struct kiobuf **bufp, int *szp); #ifdef CONFIG_PROC_FS static int sg_last_dev(void); #endif @@ -614,6 +620,20 @@ sg_remove_request(sfp, srp); return -ENOSYS; } + if (hp->flags & SG_FLAG_MMAP_IO) { + if (hp->dxfer_len > sfp->reserve.bufflen) { + sg_remove_request(sfp, srp); + return -ENOMEM; /* MMAP_IO size must fit in reserve buffer */ + } + if (hp->flags & SG_FLAG_DIRECT_IO) { + sg_remove_request(sfp, srp); + return -EINVAL; /* either MMAP_IO or DIRECT_IO (not both) */ + } + if (sg_res_in_use(sfp)) { + sg_remove_request(sfp, srp); + return -EBUSY; /* reserve buffer already being used */ + } + } timeout = sg_ms_to_jif(srp->header.timeout); if ((! hp->cmdp) || (hp->cmd_len < 6) || (hp->cmd_len > sizeof(cmnd))) { sg_remove_request(sfp, srp); @@ -714,7 +734,9 @@ (void *)SRpnt->sr_buffer, hp->dxfer_len, sg_cmd_done_bh, timeout, SG_DEFAULT_RETRIES); /* dxfer_len overwrites SRpnt->sr_bufflen, hence need for b_malloc_len */ +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,1) generic_unplug_device(q); +#endif return 0; } @@ -848,7 +870,7 @@ result = get_user(val, (int *)arg); if (result) return result; if (val != sfp->reserve.bufflen) { - if (sg_res_in_use(sfp)) + if (sg_res_in_use(sfp) || sfp->mmap_called) return -EBUSY; sg_remove_scat(&sfp->reserve); sg_build_reserve(sfp, val); @@ -1029,6 +1051,139 @@ return (retval < 0) ? retval : 0; } +static void sg_rb_correct4mmap(Sg_scatter_hold * rsv_schp, int startFinish) +{ + void * page_ptr; + struct page * page; + int k, m; + + SCSI_LOG_TIMEOUT(3, printk("sg_rb_correct4mmap: startFinish=%d, " + "scatg=%d\n", startFinish, rsv_schp->k_use_sg)); + /* N.B. correction _not_ applied to base page of aech allocation */ + if (rsv_schp->k_use_sg) { /* reserve buffer is a scatter gather list */ + struct scatterlist * sclp = rsv_schp->buffer; + + for (k = 0; k < rsv_schp->k_use_sg; ++k, ++sclp) { + for (m = PAGE_SIZE; m < sclp->length; m += PAGE_SIZE) { + page_ptr = (unsigned char *)sclp->address + m; + page = virt_to_page(page_ptr); + if (startFinish) + get_page(page); /* increment page count */ + else { + if (page_count(page) > 0) + put_page_testzero(page); /* decrement page count */ + } + } + } + } + else { /* reserve buffer is just a single allocation */ + for (m = PAGE_SIZE; m < rsv_schp->bufflen; m += PAGE_SIZE) { + page_ptr = (unsigned char *)rsv_schp->buffer + m; + page = virt_to_page(page_ptr); + if (startFinish) + get_page(page); /* increment page count */ + else { + if (page_count(page) > 0) + put_page_testzero(page); /* decrement page count */ + } + } + } +} + +static struct page * sg_vma_nopage(struct vm_area_struct *vma, + unsigned long addr, int unused) +{ + Sg_fd * sfp; + struct page * page = NOPAGE_SIGBUS; + void * page_ptr = NULL; + unsigned long offset; + Sg_scatter_hold * rsv_schp; + + if ((NULL == vma) || (! (sfp = (Sg_fd *)vma->vm_private_data))) + return page; + rsv_schp = &sfp->reserve; + offset = addr - vma->vm_start; + if (offset >= rsv_schp->bufflen) + return page; + SCSI_LOG_TIMEOUT(3, printk("sg_vma_nopage: offset=%lu, scatg=%d\n", + offset, rsv_schp->k_use_sg)); + if (rsv_schp->k_use_sg) { /* reserve buffer is a scatter gather list */ + int k; + unsigned long sa = vma->vm_start; + unsigned long len; + struct scatterlist * sclp = rsv_schp->buffer; + + for (k = 0; (k < rsv_schp->k_use_sg) && (sa < vma->vm_end); + ++k, ++sclp) { + len = vma->vm_end - sa; + len = (len < sclp->length) ? len : sclp->length; + if (offset < len) { + page_ptr = (unsigned char *)sclp->address + offset; + page = virt_to_page(page_ptr); + get_page(page); /* increment page count */ + break; + } + sa += len; + offset -= len; + } + } + else { /* reserve buffer is just a single allocation */ + page_ptr = (unsigned char *)rsv_schp->buffer + offset; + page = virt_to_page(page_ptr); + get_page(page); /* increment page count */ + } + return page; +} + +static struct vm_operations_struct sg_mmap_vm_ops = { + nopage : sg_vma_nopage, +}; + +static int sg_mmap(struct file * filp, struct vm_area_struct *vma) +{ + Sg_fd * sfp; + unsigned long req_sz = vma->vm_end - vma->vm_start; + Sg_scatter_hold * rsv_schp; + + if ((! filp) || (! vma) || (! (sfp = (Sg_fd *)filp->private_data))) + return -ENXIO; + SCSI_LOG_TIMEOUT(3, printk("sg_mmap starting, vm_start=%p, len=%d\n", + (void *)vma->vm_start, (int)req_sz)); + if (vma->vm_pgoff) + return -EINVAL; /* want no offset */ + rsv_schp = &sfp->reserve; + if (req_sz > rsv_schp->bufflen) + return -ENOMEM; /* cannot map more than reserved buffer */ + + if (rsv_schp->k_use_sg) { /* reserve buffer is a scatter gather list */ + int k; + unsigned long sa = vma->vm_start; + unsigned long len; + struct scatterlist * sclp = rsv_schp->buffer; + + for (k = 0; (k < rsv_schp->k_use_sg) && (sa < vma->vm_end); + ++k, ++sclp) { + if ((unsigned long)sclp->address & (PAGE_SIZE - 1)) + return -EFAULT; /* non page aligned memory ?? */ + len = vma->vm_end - sa; + len = (len < sclp->length) ? len : sclp->length; + sa += len; + } + } + else { /* reserve buffer is just a single allocation */ + if ((unsigned long)rsv_schp->buffer & (PAGE_SIZE - 1)) + return -EFAULT; /* non page aligned memory ?? */ + } + if (0 == sfp->mmap_called) { + sg_rb_correct4mmap(rsv_schp, 1); /* do only once per fd lifetime */ + sfp->mmap_called = 1; + } + vma->vm_flags |= (VM_RESERVED | VM_IO); + vma->vm_private_data = sfp; + vma->vm_ops = &sg_mmap_vm_ops; + return 0; +} + /* This function is a "bottom half" handler that is called by the * mid level when a command is completed (or has failed). */ static void sg_cmd_done_bh(Scsi_Cmnd * SCpnt) @@ -1075,7 +1230,14 @@ srp->data.sglist_len = SRpnt->sr_sglist_len; srp->data.bufflen = SRpnt->sr_bufflen; srp->data.buffer = SRpnt->sr_buffer; - sg_clr_srpnt(SRpnt); + /* now clear out request structure */ + SRpnt->sr_use_sg = 0; + SRpnt->sr_sglist_len = 0; + SRpnt->sr_bufflen = 0; + SRpnt->sr_buffer = NULL; + SRpnt->sr_underflow = 0; + SRpnt->sr_request.rq_dev = MKDEV(0, 0); /* "sg" _disowns_ request blk */ + srp->my_cmdp = NULL; srp->done = 1; read_unlock(&sg_dev_arr_lock); @@ -1120,14 +1282,15 @@ if (NULL == sfp->headrp) { SCSI_LOG_TIMEOUT(1, printk("sg...bh: already closed, final cleanup\n")); - sg_remove_sfp(sdp, sfp); + if (0 == sg_remove_sfp(sdp, sfp)) { /* device still present */ + sdp->device->access_count--; + if (sdp->device->host->hostt->module) + __MOD_DEC_USE_COUNT(sdp->device->host->hostt->module); + } + if (sg_template.module) + __MOD_DEC_USE_COUNT(sg_template.module); sfp = NULL; } - sdp->device->access_count--; - if (sg_template.module) - __MOD_DEC_USE_COUNT(sg_template.module); - if (sdp->device->host->hostt->module) - __MOD_DEC_USE_COUNT(sdp->device->host->hostt->module); } else if (srp && srp->orphan) { if (sfp->keep_orphan) @@ -1151,6 +1314,7 @@ poll: sg_poll, ioctl: sg_ioctl, open: sg_open, + mmap: sg_mmap, release: sg_release, fasync: sg_fasync, }; @@ -1175,7 +1339,7 @@ if(!sg_registered) { if (devfs_register_chrdev(SCSI_GENERIC_MAJOR,"sg",&sg_fops)) { - printk("Unable to get major %d for generic SCSI device\n", + printk(KERN_ERR "Unable to get major %d for generic SCSI device\n", SCSI_GENERIC_MAJOR); write_unlock_irqrestore(&sg_dev_arr_lock, iflags); return 1; @@ -1188,7 +1352,7 @@ sg_dev_arr = (Sg_device **)kmalloc(sg_template.dev_max * sizeof(Sg_device *), GFP_ATOMIC); if (NULL == sg_dev_arr) { - printk("sg_init: no space for sg_dev_arr\n"); + printk(KERN_ERR "sg_init: no space for sg_dev_arr\n"); write_unlock_irqrestore(&sg_dev_arr_lock, iflags); return 1; } @@ -1211,8 +1375,8 @@ sg_big_buff = tmp; return 1; } else { - printk("sg_def_reserved_size : usage sg_def_reserved_size=n " - "(n could be 65536, 131072 or 262144)\n"); + printk(KERN_WARNING "sg_def_reserved_size : usage " + "sg_def_reserved_size=n (n could be 65536, 131072 or 262144)\n"); return 0; } } @@ -1237,7 +1401,7 @@ if (NULL == tmp_da) { scsidp->attached--; write_unlock_irqrestore(&sg_dev_arr_lock, iflags); - printk("sg_attach: device array cannot be resized\n"); + printk(KERN_ERR "sg_attach: device array cannot be resized\n"); return 1; } memset(tmp_da, 0, tmp_dev_max * sizeof(Sg_device *)); @@ -1252,7 +1416,7 @@ if (k > MINORMASK) { scsidp->attached--; write_unlock_irqrestore(&sg_dev_arr_lock, iflags); - printk("Unable to attach sg device <%d, %d, %d, %d>" + printk(KERN_WARNING "Unable to attach sg device <%d, %d, %d, %d>" " type=%d, minor number exceed %d\n", scsidp->host->host_no, scsidp->channel, scsidp->id, scsidp->lun, scsidp->type, MINORMASK); @@ -1265,7 +1429,7 @@ if (NULL == sdp) { scsidp->attached--; write_unlock_irqrestore(&sg_dev_arr_lock, iflags); - printk("sg_attach: Sg_device cannot be allocated\n"); + printk(KERN_ERR "sg_attach: Sg_device cannot be allocated\n"); return 1; } @@ -1292,8 +1456,8 @@ case TYPE_WORM: case TYPE_TAPE: break; default: - printk("Attached scsi generic sg%d at scsi%d, channel %d, id %d," - " lun %d, type %d\n", k, scsidp->host->host_no, + printk(KERN_NOTICE "Attached scsi generic sg%d at scsi%d, channel" + " %d, id %d, lun %d, type %d\n", k, scsidp->host->host_no, scsidp->channel, scsidp->id, scsidp->lun, scsidp->type); } return 0; @@ -1370,7 +1534,10 @@ MODULE_AUTHOR("Douglas Gilbert"); MODULE_DESCRIPTION("SCSI generic (sg) driver"); + +#ifdef MODULE_LICENSE MODULE_LICENSE("GPL"); +#endif MODULE_PARM(def_reserved_size, "i"); MODULE_PARM_DESC(def_reserved_size, "size of buffer reserved for each fd"); @@ -1378,8 +1545,7 @@ static int __init init_sg(void) { if (def_reserved_size >= 0) sg_big_buff = def_reserved_size; - sg_template.module = THIS_MODULE; - return scsi_register_module(MODULE_SCSI_DEV, &sg_template); + return scsi_register_device(&sg_template); } static void __exit exit_sg( void) @@ -1387,7 +1553,7 @@ #ifdef CONFIG_PROC_FS sg_proc_cleanup(); #endif /* CONFIG_PROC_FS */ - scsi_unregister_module(MODULE_SCSI_DEV, &sg_template); + scsi_unregister_device(&sg_template); devfs_unregister_chrdev(SCSI_GENERIC_MAJOR, "sg"); if(sg_dev_arr != NULL) { kfree((char *)sg_dev_arr); @@ -1417,9 +1583,8 @@ if (res <= 0) /* -ve -> error, 0 -> done, 1 -> try indirect */ return res; } - if ((! sg_res_in_use(sfp)) && (dxfer_len <= rsv_schp->bufflen)) { + if ((! sg_res_in_use(sfp)) && (dxfer_len <= rsv_schp->bufflen)) sg_link_reserve(sfp, srp, dxfer_len); - } else { res = sg_build_indi(req_schp, sfp, dxfer_len); if (res) { @@ -1445,23 +1610,24 @@ sg_remove_request(sfp, srp); } -static int sg_build_sgat(Sg_scatter_hold * schp, const Sg_fd * sfp) +static int sg_build_sgat(Sg_scatter_hold * schp, const Sg_fd * sfp, + int tablesize) { int mem_src, ret_sz; - int sg_bufflen = PAGE_SIZE; int elem_sz = sizeof(struct scatterlist) + sizeof(char); - int mx_sc_elems = (sg_bufflen / elem_sz) - 1; + /* scatter gather array, followed by mem_src_arr (array of chars) */ + int sg_bufflen = tablesize * elem_sz; + int mx_sc_elems = tablesize; mem_src = SG_HEAP_KMAL; - schp->buffer = (struct scatterlist *)sg_malloc(sfp, sg_bufflen, - &ret_sz, &mem_src); - schp->buffer_mem_src = (char)mem_src; + schp->buffer = sg_malloc(sfp, sg_bufflen, &ret_sz, &mem_src); if (! schp->buffer) return -ENOMEM; else if (ret_sz != sg_bufflen) { sg_bufflen = ret_sz; - mx_sc_elems = (sg_bufflen / elem_sz) - 1; + mx_sc_elems = sg_bufflen / elem_sz; } + schp->buffer_mem_src = (char)mem_src; schp->sglist_len = sg_bufflen; memset(schp->buffer, 0, sg_bufflen); return mx_sc_elems; /* number of scat_gath elements allocated */ @@ -1470,13 +1636,15 @@ static void sg_unmap_and(Sg_scatter_hold * schp, int free_also) { #ifdef SG_ALLOW_DIO_CODE + int nbhs = 0; + if (schp && schp->kiobp) { if (schp->mapped) { unmap_kiobuf(schp->kiobp); schp->mapped = 0; } if (free_also) { - free_kiovec(1, &schp->kiobp); + sg_free_kiovec(1, &schp->kiobp, &nbhs); schp->kiobp = NULL; } } @@ -1494,10 +1662,12 @@ sg_io_hdr_t * hp = &srp->header; Sg_scatter_hold * schp = &srp->data; int sg_tablesize = sfp->parentdp->sg_tablesize; + int nbhs = 0; - res = alloc_kiovec(1, &schp->kiobp); + res = sg_alloc_kiovec(1, &schp->kiobp, &nbhs); if (0 != res) { - SCSI_LOG_TIMEOUT(5, printk("sg_build_dir: alloc_kiovec res=%d\n", res)); + SCSI_LOG_TIMEOUT(5, printk("sg_build_dir: sg_alloc_kiovec res=%d\n", + res)); return 1; } res = map_user_kiobuf((SG_DXFER_TO_DEV == hp->dxfer_direction) ? 1 : 0, @@ -1527,7 +1697,7 @@ hp->info |= SG_INFO_DIRECT_IO; return 0; } - mx_sc_elems = sg_build_sgat(schp, sfp); + mx_sc_elems = sg_build_sgat(schp, sfp, sg_tablesize); if (mx_sc_elems <= 1) { sg_unmap_and(schp, 1); sg_remove_scat(schp); @@ -1535,13 +1705,15 @@ } mem_src_arr = schp->buffer + (mx_sc_elems * sizeof(struct scatterlist)); for (k = 0, sclp = schp->buffer, rem_sz = dxfer_len; - (k < sg_tablesize) && (rem_sz > 0) && (k < mx_sc_elems); + (rem_sz > 0) && (k < mx_sc_elems); ++k, ++sclp) { offset = (0 == k) ? kp->offset : 0; num = (rem_sz > (PAGE_SIZE - offset)) ? (PAGE_SIZE - offset) : rem_sz; sclp->address = page_address(kp->maplist[k]) + offset; +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,13) sclp->page = NULL; +#endif sclp->length = num; mem_src_arr[k] = SG_USER_MEM; rem_sz -= num; @@ -1609,14 +1781,14 @@ char * mem_src_arr; /* N.B. ret_sz and mem_src carried into this block ... */ - mx_sc_elems = sg_build_sgat(schp, sfp); + mx_sc_elems = sg_build_sgat(schp, sfp, sg_tablesize); if (mx_sc_elems < 0) return mx_sc_elems; /* most likely -ENOMEM */ mem_src_arr = schp->buffer + (mx_sc_elems * sizeof(struct scatterlist)); for (k = 0, sclp = schp->buffer, rem_sz = blk_size; - (k < sg_tablesize) && (rem_sz > 0) && (k < mx_sc_elems); + (rem_sz > 0) && (k < mx_sc_elems); ++k, rem_sz -= ret_sz, ++sclp) { if (first) first = 0; @@ -1628,7 +1800,9 @@ break; } sclp->address = p; +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,13) sclp->page = NULL; +#endif sclp->length = ret_sz; mem_src_arr[k] = mem_src; @@ -1664,7 +1838,8 @@ if (schp->bufflen < num_xfer) num_xfer = schp->bufflen; } - if ((num_xfer <= 0) || (new_interface && (SG_FLAG_NO_DXFER & hp->flags))) + if ((num_xfer <= 0) || + (new_interface && ((SG_FLAG_NO_DXFER | SG_FLAG_MMAP_IO) & hp->flags))) return 0; SCSI_LOG_TIMEOUT(4, @@ -1766,7 +1941,7 @@ static char * sg_get_sgat_msa(Sg_scatter_hold * schp) { int elem_sz = sizeof(struct scatterlist) + sizeof(char); - int mx_sc_elems = (schp->sglist_len / elem_sz) - 1; + int mx_sc_elems = schp->sglist_len / elem_sz; return schp->buffer + (sizeof(struct scatterlist) * mx_sc_elems); } @@ -1786,7 +1961,9 @@ k, sclp->address, sclp->length, mem_src)); sg_free(sclp->address, sclp->length, mem_src); sclp->address = NULL; +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,13) sclp->page = NULL; +#endif sclp->length = 0; } sg_free(schp->buffer, schp->sglist_len, schp->buffer_mem_src); @@ -1814,7 +1991,8 @@ if (schp->bufflen < num_xfer) num_xfer = schp->bufflen; } - if ((num_xfer <= 0) || (new_interface && (SG_FLAG_NO_DXFER & hp->flags))) + if ((num_xfer <= 0) || + (new_interface && ((SG_FLAG_NO_DXFER | SG_FLAG_MMAP_IO) & hp->flags))) return 0; SCSI_LOG_TIMEOUT(4, @@ -2189,6 +2367,8 @@ if (sfp->reserve.bufflen > 0) { SCSI_LOG_TIMEOUT(6, printk("__sg_remove_sfp: bufflen=%d, k_use_sg=%d\n", (int)sfp->reserve.bufflen, (int)sfp->reserve.k_use_sg)); + if (sfp->mmap_called) + sg_rb_correct4mmap(&sfp->reserve, 0); /* undo correction */ sg_remove_scat(&sfp->reserve); } sfp->parentdp = NULL; @@ -2237,7 +2417,7 @@ /* MOD_INC's to inhibit unloading sg and associated adapter driver */ if (sg_template.module) __MOD_INC_USE_COUNT(sg_template.module); - if (sdp->device->host->hostt->module) + if (sdp->device->host->hostt->module) __MOD_INC_USE_COUNT(sdp->device->host->hostt->module); SCSI_LOG_TIMEOUT(1, printk( "sg_remove_sfp: worrisome, %d writes pending\n", dirty)); @@ -2311,7 +2491,8 @@ if (retSzp) *retSzp = resSz; } else - printk("sg_low_malloc: bad mem_src=%d, rqSz=%df\n", mem_src, rqSz); + printk(KERN_ERR "sg_low_malloc: bad mem_src=%d, rqSz=%df\n", + mem_src, rqSz); return resp; } @@ -2346,7 +2527,7 @@ if (resp && retSzp) *retSzp = size; break; case SG_HEAP_KMAL: - l_ms = SG_HEAP_PAGE; + l_ms = SG_HEAP_KMAL; /* was SG_HEAP_PAGE */ resp = sg_low_malloc(size, low_dma, l_ms, 0); if (resp) break; @@ -2365,6 +2546,15 @@ return resp; } +static inline int sg_alloc_kiovec(int nr, struct kiobuf **bufp, int *szp) +{ +#if SG_NEW_KIOVEC + return alloc_kiovec_sz(nr, bufp, szp); +#else + return alloc_kiovec(nr, bufp); +#endif +} + static void sg_low_free(char * buff, int size, int mem_src) { if (! buff) return; @@ -2392,7 +2582,7 @@ case SG_USER_MEM: break; /* nothing to do */ default: - printk("sg_low_free: bad mem_src=%d, buff=0x%p, rqSz=%d\n", + printk(KERN_ERR "sg_low_free: bad mem_src=%d, buff=0x%p, rqSz=%d\n", mem_src, buff, size); break; } @@ -2408,14 +2598,13 @@ sg_low_free(buff, size, mem_src); } -static void sg_clr_srpnt(Scsi_Request * SRpnt) +static inline void sg_free_kiovec(int nr, struct kiobuf **bufp, int *szp) { - SRpnt->sr_use_sg = 0; - SRpnt->sr_sglist_len = 0; - SRpnt->sr_bufflen = 0; - SRpnt->sr_buffer = NULL; - SRpnt->sr_underflow = 0; - SRpnt->sr_request.rq_dev = MKDEV(0, 0); /* "sg" _disowns_ command blk */ +#if SG_NEW_KIOVEC + free_kiovec_sz(nr, bufp, szp); +#else + free_kiovec(nr, bufp); +#endif } static int sg_ms_to_jif(unsigned int msecs) @@ -2427,7 +2616,7 @@ : (((int)msecs / 1000) * HZ); } -static unsigned sg_jif_to_ms(int jifs) +static inline unsigned sg_jif_to_ms(int jifs) { if (jifs <= 0) return 0U; @@ -2477,8 +2666,8 @@ if (sg_dev_arr && (dev >= 0)) { read_lock_irqsave(&sg_dev_arr_lock, iflags); - if (dev < sg_template.dev_max) - sdp = sg_dev_arr[dev]; + if (dev < sg_template.dev_max) + sdp = sg_dev_arr[dev]; read_unlock_irqrestore(&sg_dev_arr_lock, iflags); } return sdp; @@ -2671,7 +2860,7 @@ { Sg_device * sdp; const sg_io_hdr_t * hp; - int j, max_dev; + int j, max_dev, new_interface; if (NULL == sg_dev_arr) { PRINT_PROC("sg_dev_arr NULL, driver not initialized\n"); @@ -2717,8 +2906,10 @@ (int)fp->keep_orphan, (int)fp->closed); for (m = 0; (srp = sg_get_nth_request(fp, m)); ++m) { hp = &srp->header; + new_interface = (hp->interface_id == '\0') ? 0 : 1; /* stop indenting so far ... */ - PRINT_PROC(srp->res_used ? " rb>> " : + PRINT_PROC(srp->res_used ? ((new_interface && + (SG_FLAG_MMAP_IO & hp->flags)) ? " mmap>> " : " rb>> ") : ((SG_INFO_DIRECT_IO_MASK & hp->info) ? " dio>> " : " ")); blen = srp->my_cmdp ? srp->my_cmdp->sr_bufflen : srp->data.bufflen; usg = srp->my_cmdp ? srp->my_cmdp->sr_use_sg : srp->data.k_use_sg; @@ -2728,8 +2919,8 @@ if (srp->done) PRINT_PROC(" dur=%d", hp->duration); else - PRINT_PROC(" t_o/elap=%d/%d", ((hp->interface_id == '\0') ? - sg_jif_to_ms(fp->timeout) : hp->timeout), + PRINT_PROC(" t_o/elap=%d/%d", new_interface ? hp->timeout : + sg_jif_to_ms(fp->timeout), sg_jif_to_ms(hp->duration ? (jiffies - hp->duration) : 0)); PRINT_PROC("ms sgat=%d op=0x%02x\n", usg, (int)srp->data.cmd_opcode); /* reset indenting */ diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/scsi/sr.c linux-2.5/drivers/scsi/sr.c --- linux-2.5.1/drivers/scsi/sr.c Sun Dec 16 20:20:21 2001 +++ linux-2.5/drivers/scsi/sr.c Sun Dec 30 20:01:41 2001 @@ -71,6 +71,7 @@ static struct Scsi_Device_Template sr_template = { + module:THIS_MODULE, name:"cdrom", tag:"sr", scsi_type:TYPE_ROM, @@ -287,9 +288,6 @@ return 0; } - if (rq_data_dir(&SCpnt->request) == WRITE && !scsi_CDs[dev].device->writeable) - return 0; - /* * we do lazy blocksize switching (when reading XA sectors, * see CDROMREADMODE2 ioctl) @@ -477,6 +475,7 @@ int the_result, retries; int sector_size; Scsi_Request *SRpnt; + request_queue_t *queue; buffer = (unsigned char *) kmalloc(512, GFP_DMA); SRpnt = scsi_allocate_request(scsi_CDs[i].device); @@ -566,8 +565,9 @@ */ scsi_CDs[i].needs_sector_size = 0; sr_sizes[i] = scsi_CDs[i].capacity >> (BLOCK_SIZE_BITS - 9); - }; - blk_queue_hardsect_size(blk_get_queue(MAJOR_NR), sector_size); + } + queue = &scsi_CDs[i].device->request_queue; + blk_queue_hardsect_size(queue, sector_size); kfree(buffer); } @@ -829,13 +829,12 @@ static int __init init_sr(void) { - sr_template.module = THIS_MODULE; - return scsi_register_module(MODULE_SCSI_DEV, &sr_template); + return scsi_register_device(&sr_template); } static void __exit exit_sr(void) { - scsi_unregister_module(MODULE_SCSI_DEV, &sr_template); + scsi_unregister_device(&sr_template); devfs_unregister_blkdev(MAJOR_NR, "sr"); sr_registered--; if (scsi_CDs != NULL) { diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/scsi/st.c linux-2.5/drivers/scsi/st.c --- linux-2.5.1/drivers/scsi/st.c Fri Nov 9 21:52:21 2001 +++ linux-2.5/drivers/scsi/st.c Thu Dec 27 22:10:28 2001 @@ -3867,14 +3867,14 @@ validate_options(); st_template.module = THIS_MODULE; - return scsi_register_module(MODULE_SCSI_DEV, &st_template); + return scsi_register_device(&st_template); } static void __exit exit_st(void) { int i; - scsi_unregister_module(MODULE_SCSI_DEV, &st_template); + scsi_unregister_device(&st_template); devfs_unregister_chrdev(SCSI_TAPE_MAJOR, "st"); st_registered--; if (scsi_tapes != NULL) { diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/scsi/sym53c8xx_2/sym_hipd.c linux-2.5/drivers/scsi/sym53c8xx_2/sym_hipd.c --- linux-2.5.1/drivers/scsi/sym53c8xx_2/sym_hipd.c Sun Dec 16 20:20:21 2001 +++ linux-2.5/drivers/scsi/sym53c8xx_2/sym_hipd.c Mon Dec 17 01:03:07 2001 @@ -50,7 +50,7 @@ * SUCH DAMAGE. */ -#define SYM_DRIVER_NAME "sym-2.1.16a" +#define SYM_DRIVER_NAME "sym-2.1.17a" #ifdef __FreeBSD__ #include <dev/sym/sym_glue.h> @@ -5797,6 +5797,13 @@ goto attach_failed; /* + * Allocate the array of lists of CCBs hashed by DSA. + */ + np->ccbh = sym_calloc(sizeof(ccb_p *)*CCB_HASH_SIZE, "CCBH"); + if (!np->ccbh) + goto attach_failed; + + /* * Initialyze the CCB free and busy queues. */ sym_que_init(&np->free_ccbq); @@ -5925,6 +5932,8 @@ np->target[i].head.lun0_sa = cpu_to_scr(vtobus(&np->badlun_sa)); } + if (np->ccbh) + sym_mfree(np->ccbh, sizeof(ccb_p *)*CCB_HASH_SIZE, "CCBH"); /* * Now check the cache handling of the pci chipset. diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/scsi/sym53c8xx_comm.h linux-2.5/drivers/scsi/sym53c8xx_comm.h --- linux-2.5.1/drivers/scsi/sym53c8xx_comm.h Sun Dec 16 20:20:21 2001 +++ linux-2.5/drivers/scsi/sym53c8xx_comm.h Thu Dec 13 16:32:36 2001 @@ -438,10 +438,10 @@ #define NCR_LOCK_NCB(np, flags) spin_lock_irqsave(&np->smp_lock, flags) #define NCR_UNLOCK_NCB(np, flags) spin_unlock_irqrestore(&np->smp_lock, flags) -#define NCR_LOCK_SCSI_DONE(np, flags) \ - spin_lock_irqsave(&io_request_lock, flags) -#define NCR_UNLOCK_SCSI_DONE(np, flags) \ - spin_unlock_irqrestore(&io_request_lock, flags) +#define NCR_LOCK_SCSI_DONE(host, flags) \ + spin_lock_irqsave(&(host)->host_lock, flags) +#define NCR_UNLOCK_SCSI_DONE(host, flags) \ + spin_unlock_irqrestore(&((host)->host_lock), flags) #else @@ -452,8 +452,8 @@ #define NCR_LOCK_NCB(np, flags) do { save_flags(flags); cli(); } while (0) #define NCR_UNLOCK_NCB(np, flags) do { restore_flags(flags); } while (0) -#define NCR_LOCK_SCSI_DONE(np, flags) do {;} while (0) -#define NCR_UNLOCK_SCSI_DONE(np, flags) do {;} while (0) +#define NCR_LOCK_SCSI_DONE(host, flags) do {;} while (0) +#define NCR_UNLOCK_SCSI_DONE(host, flags) do {;} while (0) #endif diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/scsi/t128.c linux-2.5/drivers/scsi/t128.c --- linux-2.5.1/drivers/scsi/t128.c Sun Sep 30 19:26:08 2001 +++ linux-2.5/drivers/scsi/t128.c Thu Dec 13 16:32:36 2001 @@ -47,17 +47,12 @@ * increase compared to polled I/O. * * PARITY - enable parity checking. Not supported. - * - * SCSI2 - enable support for SCSI-II tagged queueing. Untested. - * * * UNSAFE - leave interrupts enabled during pseudo-DMA transfers. You * only really want to use this if you're having a problem with * dropped characters during high speed communications, and even * then, you're going to be better off twiddling with transfersize. * - * USLEEP - enable support for devices that don't disconnect. Untested. - * * The card is detected and initialized in one of several ways : * 1. Autoprobe (default) - since the board is memory mapped, * a BIOS signature is scanned for to locate the registers. @@ -101,10 +96,6 @@ * 14 10-12 * 15 9-11 */ - -/* - * $Log: t128.c,v $ - */ #include <asm/system.h> #include <linux/signal.h> @@ -123,276 +114,252 @@ #include <linux/module.h> static struct override { - unsigned long address; - int irq; -} overrides + unsigned long address; + int irq; +} overrides #ifdef T128_OVERRIDE - [] __initdata = T128_OVERRIDE; +[] __initdata = T128_OVERRIDE; #else - [4] __initdata = {{0, IRQ_AUTO}, {0, IRQ_AUTO}, - {0 ,IRQ_AUTO}, {0, IRQ_AUTO}}; +[4] __initdata = { + { 0, IRQ_AUTO}, + { 0, IRQ_AUTO}, + { 0, IRQ_AUTO}, + { 0, IRQ_AUTO} +}; #endif #define NO_OVERRIDES (sizeof(overrides) / sizeof(struct override)) static struct base { - unsigned int address; - int noauto; + unsigned int address; + int noauto; } bases[] __initdata = { - { 0xcc000, 0}, { 0xc8000, 0}, { 0xdc000, 0}, { 0xd8000, 0} + {0xcc000, 0}, + {0xc8000, 0}, + {0xdc000, 0}, + {0xd8000, 0} }; #define NO_BASES (sizeof (bases) / sizeof (struct base)) static const struct signature { - const char *string; - int offset; + const char *string; + int offset; } signatures[] __initdata = { -{"TSROM: SCSI BIOS, Version 1.12", 0x36}, + {"TSROM: SCSI BIOS, Version 1.12", 0x36}, }; #define NO_SIGNATURES (sizeof (signatures) / sizeof (struct signature)) -/* - * Function : t128_setup(char *str, int *ints) - * - * Purpose : LILO command line initialization of the overrides array, - * - * Inputs : str - unused, ints - array of integer parameters with ints[0] - * equal to the number of ints. +/** + * t128_setup + * @str: command line * + * LILO command line initialization of the overrides array, */ -void __init t128_setup(char *str, int *ints){ - static int commandline_current = 0; - int i; - if (ints[0] != 2) - printk("t128_setup : usage t128=address,irq\n"); - else - if (commandline_current < NO_OVERRIDES) { - overrides[commandline_current].address = ints[1]; - overrides[commandline_current].irq = ints[2]; - for (i = 0; i < NO_BASES; ++i) - if (bases[i].address == ints[1]) { - bases[i].noauto = 1; - break; - } - ++commandline_current; +int __init t128_setup(char *str) +{ + static int commandline_current = 0; + int ints[10]; + int i; + + get_options(str, sizeof(ints) / sizeof(int), ints); + + if (ints[0] != 2) + printk(KERN_ERR "t128_setup : usage t128=address,irq\n"); + else if (commandline_current < NO_OVERRIDES) { + overrides[commandline_current].address = ints[1]; + overrides[commandline_current].irq = ints[2]; + for (i = 0; i < NO_BASES; ++i) + if (bases[i].address == ints[1]) { + bases[i].noauto = 1; + break; + } + ++commandline_current; } + return 1; } -/* - * Function : int t128_detect(Scsi_Host_Template * tpnt) +__setup("t128=", t128_setup); + +/** + * t128_detect - detect controllers + * @tpnt: SCSI template * - * Purpose : detects and initializes T128,T128F, or T228 controllers + * Detects and initializes T128,T128F, or T228 controllers * that were autoprobed, overridden on the LILO command line, * or specified at compile time. - * - * Inputs : tpnt - template for this SCSI adapter. - * - * Returns : 1 if a host adapter was found, 0 if not. - * */ -int __init t128_detect(Scsi_Host_Template * tpnt){ - static int current_override = 0, current_base = 0; - struct Scsi_Host *instance; - unsigned long base; - int sig, count; - - tpnt->proc_name = "t128"; - tpnt->proc_info = &t128_proc_info; - - for (count = 0; current_override < NO_OVERRIDES; ++current_override) { - base = 0; - - if (overrides[current_override].address) - base = overrides[current_override].address; - else - for (; !base && (current_base < NO_BASES); ++current_base) { -#if (TDEBUG & TDEBUG_INIT) - printk("scsi-t128 : probing address %08x\n", bases[current_base].address); -#endif - for (sig = 0; sig < NO_SIGNATURES; ++sig) - if (!bases[current_base].noauto && - isa_check_signature(bases[current_base].address + - signatures[sig].offset, - signatures[sig].string, - strlen(signatures[sig].string))) { - base = bases[current_base].address; -#if (TDEBUG & TDEBUG_INIT) - printk("scsi-t128 : detected board.\n"); -#endif +int __init t128_detect(Scsi_Host_Template * tpnt) +{ + static int current_override = 0, current_base = 0; + struct Scsi_Host *instance; + unsigned long base; + int sig, count; + + tpnt->proc_name = "t128"; + tpnt->proc_info = &t128_proc_info; + + for (count = 0; current_override < NO_OVERRIDES; ++current_override) + { + base = 0; + + if (overrides[current_override].address) + base = overrides[current_override].address; + else + for (; !base && (current_base < NO_BASES); ++current_base) { + for (sig = 0; sig < NO_SIGNATURES; ++sig) + if (!bases[current_base].noauto && + isa_check_signature(bases[current_base].address + signatures[sig].offset, + signatures[sig].string, + strlen(signatures[sig].string))) + { + base = bases[current_base].address; + break; + } + } + + if (!base) break; - } - } -#if defined(TDEBUG) && (TDEBUG & TDEBUG_INIT) - printk("scsi-t128 : base = %08x\n", (unsigned int) base); -#endif + instance = scsi_register(tpnt, sizeof(struct NCR5380_hostdata)); + if (instance == NULL) + break; - if (!base) - break; + instance->base = base; - instance = scsi_register (tpnt, sizeof(struct NCR5380_hostdata)); - if(instance == NULL) - break; - - instance->base = base; - - NCR5380_init(instance, 0); - - if (overrides[current_override].irq != IRQ_AUTO) - instance->irq = overrides[current_override].irq; - else - instance->irq = NCR5380_probe_irq(instance, T128_IRQS); - - if (instance->irq != IRQ_NONE) - if (request_irq(instance->irq, do_t128_intr, SA_INTERRUPT, "t128", NULL)) { - printk("scsi%d : IRQ%d not free, interrupts disabled\n", - instance->host_no, instance->irq); - instance->irq = IRQ_NONE; - } - - if (instance->irq == IRQ_NONE) { - printk("scsi%d : interrupts not enabled. for better interactive performance,\n", instance->host_no); - printk("scsi%d : please jumper the board for a free IRQ.\n", instance->host_no); - } + NCR5380_init(instance, 0); -#if defined(TDEBUG) && (TDEBUG & TDEBUG_INIT) - printk("scsi%d : irq = %d\n", instance->host_no, instance->irq); -#endif + if (overrides[current_override].irq != IRQ_AUTO) + instance->irq = overrides[current_override].irq; + else + instance->irq = NCR5380_probe_irq(instance, T128_IRQS); + + if (instance->irq != IRQ_NONE) + if (request_irq(instance->irq, do_t128_intr, SA_INTERRUPT, "t128", NULL)) + { + printk(KERN_WARNING "scsi%d : IRQ%d not free, interrupts disabled\n", instance->host_no, instance->irq); + instance->irq = IRQ_NONE; + } + + if (instance->irq == IRQ_NONE) { + printk(KERN_INFO "scsi%d : interrupts not enabled. for better interactive performance,\n", instance->host_no); + printk(KERN_INFO "scsi%d : please jumper the board for a free IRQ.\n", instance->host_no); + } + + printk(KERN_INFO "scsi%d : at 0x%08lx", instance->host_no,instance->base); + if (instance->irq == IRQ_NONE) + printk(" interrupts disabled"); + else + printk(" irq %d", instance->irq); + printk(" options CAN_QUEUE=%d CMD_PER_LUN=%d release=%d", CAN_QUEUE, CMD_PER_LUN, T128_PUBLIC_RELEASE); + NCR5380_print_options(instance); + printk("\n"); - printk("scsi%d : at 0x%08lx", instance->host_no, instance->base); - if (instance->irq == IRQ_NONE) - printk (" interrupts disabled"); - else - printk (" irq %d", instance->irq); - printk(" options CAN_QUEUE=%d CMD_PER_LUN=%d release=%d", - CAN_QUEUE, CMD_PER_LUN, T128_PUBLIC_RELEASE); - NCR5380_print_options(instance); - printk("\n"); - - ++current_override; - ++count; - } - return count; + ++current_override; + ++count; + } + return count; } -/* - * Function : int t128_biosparam(Disk * disk, kdev_t dev, int *ip) +/** + * t128_biosparam - disk geometry + * @disk: device + * @dev: device major/minor + * @ip: array to return results * - * Purpose : Generates a BIOS / DOS compatible H-C-S mapping for + * Generates a BIOS / DOS compatible H-C-S mapping for * the specified device / size. * - * Inputs : size = size of device in sectors (512 bytes), dev = block device - * major / minor, ip[] = {heads, sectors, cylinders} - * - * Returns : always 0 (success), initializes ip - * + * Most SCSI boards use this mapping, I could be incorrect. Some one + * using hard disks on a trantor should verify that this mapping + * corresponds to that used by the BIOS / ASPI driver by running the + * linux fdisk program and matching the H_C_S coordinates to those + * that DOS uses. */ -/* - * XXX Most SCSI boards use this mapping, I could be incorrect. Some one - * using hard disks on a trantor should verify that this mapping corresponds - * to that used by the BIOS / ASPI driver by running the linux fdisk program - * and matching the H_C_S coordinates to what DOS uses. - */ - -int t128_biosparam(Disk * disk, kdev_t dev, int * ip) +int t128_biosparam(Disk * disk, kdev_t dev, int *ip) { - int size = disk->capacity; - ip[0] = 64; - ip[1] = 32; - ip[2] = size >> 11; - return 0; + int size = disk->capacity; + ip[0] = 64; + ip[1] = 32; + ip[2] = size >> 11; + return 0; } -/* - * Function : int NCR5380_pread (struct Scsi_Host *instance, - * unsigned char *dst, int len) +/** + * NCR5380_pread - pseudo DMA read + * @instance: controller + * @dst: buffer to write to + * @len: expect/max length * - * Purpose : Fast 5380 pseudo-dma read function, transfers len bytes to - * dst - * - * Inputs : dst = destination, len = length in bytes - * - * Returns : 0 on success, non zero on a failure such as a watchdog - * timeout. + * Fast 5380 pseudo-dma read function, transfers len bytes to + * dst from the controller. */ -static inline int NCR5380_pread (struct Scsi_Host *instance, unsigned char *dst, - int len) { - unsigned long reg = instance->base + T_DATA_REG_OFFSET; - unsigned char *d = dst; - register int i = len; - - -#if 0 - for (; i; --i) { - while (!(isa_readb(instance->base+T_STATUS_REG_OFFSET) & T_ST_RDY)) barrier(); -#else - while (!(isa_readb(instance->base+T_STATUS_REG_OFFSET) & T_ST_RDY)) barrier(); - for (; i; --i) { -#endif - *d++ = isa_readb(reg); - } +static inline int NCR5380_pread(struct Scsi_Host *instance, + unsigned char *dst, int len) +{ + unsigned long reg = instance->base + T_DATA_REG_OFFSET; + unsigned char *d = dst; + int i = len; + + while (!(isa_readb(instance->base + T_STATUS_REG_OFFSET) & T_ST_RDY)) + barrier(); + for (; i; --i) { + *d++ = isa_readb(reg); + } - if (isa_readb(instance->base + T_STATUS_REG_OFFSET) & T_ST_TIM) { - unsigned char tmp; - unsigned long foo; - foo = instance->base + T_CONTROL_REG_OFFSET; - tmp = isa_readb(foo); - isa_writeb(tmp | T_CR_CT, foo); - isa_writeb(tmp, foo); - printk("scsi%d : watchdog timer fired in NCR5380_pread()\n", - instance->host_no); - return -1; - } else - return 0; + if (isa_readb(instance->base + T_STATUS_REG_OFFSET) & T_ST_TIM) { + unsigned char tmp; + unsigned long foo; + foo = instance->base + T_CONTROL_REG_OFFSET; + tmp = isa_readb(foo); + isa_writeb(tmp | T_CR_CT, foo); + isa_writeb(tmp, foo); + printk(KERN_ERR "scsi%d : watchdog timer fired in t128 NCR5380_pread.\n", instance->host_no); + return -1; + } else + return 0; } -/* - * Function : int NCR5380_pwrite (struct Scsi_Host *instance, - * unsigned char *src, int len) +/** + * NCR5380_pwrite - pseudo DMA write + * @instance: controller + * @dst: buffer to write to + * @len: expect/max length * - * Purpose : Fast 5380 pseudo-dma write function, transfers len bytes from - * src - * - * Inputs : src = source, len = length in bytes - * - * Returns : 0 on success, non zero on a failure such as a watchdog - * timeout. + * Fast 5380 pseudo-dma write function, transfers len bytes from + * dst to the controller. */ -static inline int NCR5380_pwrite (struct Scsi_Host *instance, unsigned char *src, - int len) { - unsigned long reg = instance->base + T_DATA_REG_OFFSET; - unsigned char *s = src; - register int i = len; - -#if 0 - for (; i; --i) { - while (!(isa_readb(instance->base+T_STATUS_REG_OFFSET) & T_ST_RDY)) barrier(); -#else - while (!(isa_readb(instance->base+T_STATUS_REG_OFFSET) & T_ST_RDY)) barrier(); - for (; i; --i) { -#endif - isa_writeb(*s++, reg); - } - if (isa_readb(instance->base + T_STATUS_REG_OFFSET) & T_ST_TIM) { - unsigned char tmp; - unsigned long foo; - foo = instance->base + T_CONTROL_REG_OFFSET; - tmp = isa_readb(foo); - isa_writeb(tmp | T_CR_CT, foo); - isa_writeb(tmp, foo); - printk("scsi%d : watchdog timer fired in NCR5380_pwrite()\n", - instance->host_no); - return -1; - } else - return 0; +static inline int NCR5380_pwrite(struct Scsi_Host *instance, + unsigned char *src, int len) +{ + unsigned long reg = instance->base + T_DATA_REG_OFFSET; + unsigned char *s = src; + int i = len; + + while (!(isa_readb(instance->base + T_STATUS_REG_OFFSET) & T_ST_RDY)) + barrier(); + for (; i; --i) { + isa_writeb(*s++, reg); + } + + if (isa_readb(instance->base + T_STATUS_REG_OFFSET) & T_ST_TIM) { + unsigned char tmp; + unsigned long foo; + foo = instance->base + T_CONTROL_REG_OFFSET; + tmp = isa_readb(foo); + isa_writeb(tmp | T_CR_CT, foo); + isa_writeb(tmp, foo); + printk(KERN_ERR "scsi%d : watchdog timer fired in t128 NCR5380_pwrite()\n", instance->host_no); + return -1; + } else + return 0; } MODULE_LICENSE("GPL"); diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/scsi/tmscsim.c linux-2.5/drivers/scsi/tmscsim.c --- linux-2.5.1/drivers/scsi/tmscsim.c Sun Sep 30 19:26:08 2001 +++ linux-2.5/drivers/scsi/tmscsim.c Thu Dec 27 22:10:28 2001 @@ -1371,7 +1371,7 @@ #include <asm/unaligned.h> /* - * Function : static int partsize(struct buffer_head *bh, unsigned long + * Function : static int partsize(unsigned char *buf, unsigned long * capacity,unsigned int *cyls, unsigned int *hds, unsigned int *secs); * * Purpose : to determine the BIOS mapping used to create the partition @@ -1381,7 +1381,7 @@ * */ -static int partsize(struct buffer_head *bh, unsigned long capacity, +static int partsize(unsigned char *buf, unsigned long capacity, unsigned int *cyls, unsigned int *hds, unsigned int *secs) { struct partition *p, *largest = NULL; int i, largest_cyl; @@ -1389,9 +1389,9 @@ unsigned int logical_end, physical_end, ext_physical_end; - if (*(unsigned short *) (bh->b_data+510) == 0xAA55) { - for (largest_cyl = -1, p = (struct partition *) - (0x1BE + bh->b_data), i = 0; i < 4; ++i, ++p) { + if (*(unsigned short *) (buf+64) == 0xAA55) { + for (largest_cyl = -1, p = (struct partition *) buf, + i = 0; i < 4; ++i, ++p) { if (!p->sys_ind) continue; cyl = p->cyl + ((p->sector & 0xc0) << 2); @@ -1446,16 +1446,16 @@ { int heads, sectors, cylinders; PACB pACB = (PACB) disk->device->host->hostdata; - struct buffer_head *bh; int ret_code = -1; int size = disk->capacity; + unsigned char *buf; - if ((bh = bread(MKDEV(MAJOR(devno), MINOR(devno)&~0xf), 0, 1024))) + if ((buf = scsi_bios_ptable(devno))) { /* try to infer mapping from partition table */ - ret_code = partsize (bh, (unsigned long) size, (unsigned int *) geom + 2, + ret_code = partsize (buf, (unsigned long) size, (unsigned int *) geom + 2, (unsigned int *) geom + 0, (unsigned int *) geom + 1); - brelse (bh); + kfree (buf); } if (ret_code == -1) { diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/sgi/char/sgiserial.c linux-2.5/drivers/sgi/char/sgiserial.c --- linux-2.5.1/drivers/sgi/char/sgiserial.c Mon Aug 27 15:56:31 2001 +++ linux-2.5/drivers/sgi/char/sgiserial.c Sun Dec 30 13:55:22 2001 @@ -49,8 +49,6 @@ #define NUM_SERIAL 1 /* One chip on board. */ #define NUM_CHANNELS (NUM_SERIAL * 2) -extern wait_queue_head_t keypress_wait; - struct sgi_zslayout *zs_chips[NUM_SERIAL] = { 0, }; struct sgi_zschannel *zs_channels[NUM_CHANNELS] = { 0, 0, }; struct sgi_zschannel *zs_conschan; @@ -100,6 +98,7 @@ DECLARE_TASK_QUEUE(tq_serial); struct tty_driver serial_driver, callout_driver; +struct console sgi_console_driver; struct console *sgisercon; static int serial_refcount; @@ -428,8 +427,6 @@ show_buffers(); return; } - /* It is a 'keyboard interrupt' ;-) */ - wake_up(&keypress_wait); } /* Look for kgdb 'stop' character, consult the gdb documentation * for remote target debugging and arch/sparc/kernel/sparc-stub.c @@ -1890,7 +1887,9 @@ serial_driver.table = serial_table; serial_driver.termios = serial_termios; serial_driver.termios_locked = serial_termios_locked; - +#ifdef CONFIG_SERIAL_CONSOLE + serial_driver.console = &sgi_console_driver; +#endif serial_driver.open = rs_open; serial_driver.close = rs_close; serial_driver.write = rs_write; @@ -2117,12 +2116,6 @@ rs_fair_output(); } -static int zs_console_wait_key(struct console *con) -{ - sleep_on(&keypress_wait); - return 0; -} - static kdev_t zs_console_device(struct console *con) { return MKDEV(TTY_MAJOR, 64 + con->index); @@ -2274,7 +2267,6 @@ name: "ttyS", write: zs_console_write, device: zs_console_device, - wait_key: zs_console_wait_key, setup: zs_console_setup, flags: CON_PRINTBUFFER, index: -1, diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/sound/Config.in linux-2.5/drivers/sound/Config.in --- linux-2.5.1/drivers/sound/Config.in Fri Nov 9 22:06:42 2001 +++ linux-2.5/drivers/sound/Config.in Thu Dec 13 16:32:36 2001 @@ -40,6 +40,9 @@ dep_tristate ' ESS Maestro, Maestro2, Maestro2E driver' CONFIG_SOUND_MAESTRO $CONFIG_SOUND dep_tristate ' ESS Maestro3/Allegro driver (EXPERIMENTAL)' CONFIG_SOUND_MAESTRO3 $CONFIG_SOUND $CONFIG_PCI $CONFIG_EXPERIMENTAL dep_tristate ' Intel ICH (i8xx) audio support' CONFIG_SOUND_ICH $CONFIG_PCI +if [ "$CONFIG_MIPS_ITE8172" = "y" -o "$CONFIG_MIPS_IVR" = "y" ]; then + dep_tristate ' IT8172G Sound' CONFIG_SOUND_IT8172 $CONFIG_SOUND +fi dep_tristate ' RME Hammerfall (RME96XX) support' CONFIG_SOUND_RME96XX $CONFIG_SOUND $CONFIG_PCI $CONFIG_EXPERIMENTAL dep_tristate ' S3 SonicVibes' CONFIG_SOUND_SONICVIBES $CONFIG_SOUND if [ "$CONFIG_VISWS" = "y" ]; then diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/sound/Makefile linux-2.5/drivers/sound/Makefile --- linux-2.5.1/drivers/sound/Makefile Fri Sep 14 21:04:07 2001 +++ linux-2.5/drivers/sound/Makefile Thu Dec 13 16:32:36 2001 @@ -73,6 +73,7 @@ obj-$(CONFIG_SOUND_RME96XX) += rme96xx.o obj-$(CONFIG_SOUND_BT878) += btaudio.o obj-$(CONFIG_SOUND_EMU10K1) += ac97_codec.o +obj-$(CONFIG_SOUND_IT8172) += ite8172.o ac97_codec.o ifeq ($(CONFIG_MIDI_EMU10K1),y) obj-$(CONFIG_SOUND_EMU10K1) += sound.o diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/sound/ad1848.c linux-2.5/drivers/sound/ad1848.c --- linux-2.5.1/drivers/sound/ad1848.c Wed Nov 28 00:44:37 2001 +++ linux-2.5/drivers/sound/ad1848.c Fri Dec 28 01:01:25 2001 @@ -134,7 +134,7 @@ static int loaded; -static int ad_format_mask[10 /*devc->model */ ] = +static int ad_format_mask[13 /*devc->model */ ] = { 0, AFMT_U8 | AFMT_S16_LE | AFMT_MU_LAW | AFMT_A_LAW, @@ -145,7 +145,10 @@ AFMT_U8 | AFMT_S16_LE | AFMT_MU_LAW | AFMT_A_LAW | AFMT_S16_BE | AFMT_IMA_ADPCM, AFMT_U8 | AFMT_S16_LE | AFMT_MU_LAW | AFMT_A_LAW | AFMT_S16_BE | AFMT_IMA_ADPCM, AFMT_U8 | AFMT_S16_LE /* CS4235 */, - AFMT_U8 | AFMT_S16_LE | AFMT_MU_LAW | AFMT_A_LAW /* Ensoniq Soundscape*/ + AFMT_U8 | AFMT_S16_LE | AFMT_MU_LAW | AFMT_A_LAW /* Ensoniq Soundscape*/, + AFMT_U8 | AFMT_S16_LE | AFMT_MU_LAW | AFMT_A_LAW | AFMT_S16_BE | AFMT_IMA_ADPCM, + AFMT_U8 | AFMT_S16_LE | AFMT_MU_LAW | AFMT_A_LAW | AFMT_S16_BE | AFMT_IMA_ADPCM, + AFMT_U8 | AFMT_S16_LE | AFMT_MU_LAW | AFMT_A_LAW | AFMT_S16_BE | AFMT_IMA_ADPCM }; static ad1848_info adev_info[MAX_AUDIO_DEV]; @@ -2965,6 +2968,10 @@ ISAPNP_ANY_ID, ISAPNP_ANY_ID, ISAPNP_VENDOR('Y','M','H'), ISAPNP_FUNCTION(0x0021), 1, 0, 0, 1, 1}, + {"Advanced Gravis InterWave Audio", + ISAPNP_VENDOR('G','R','V'), ISAPNP_DEVICE(0x0001), + ISAPNP_VENDOR('G','R','V'), ISAPNP_FUNCTION(0x0000), + 0, 0, 0, 1, 0}, {0} }; @@ -2977,6 +2984,8 @@ ISAPNP_VENDOR('C','S','C'), ISAPNP_FUNCTION(0x0100), 0 }, { ISAPNP_ANY_ID, ISAPNP_ANY_ID, ISAPNP_VENDOR('Y','M','H'), ISAPNP_FUNCTION(0x0021), 0 }, + { ISAPNP_VENDOR('G','R','V'), ISAPNP_DEVICE(0x0001), + ISAPNP_VENDOR('G','R','V'), ISAPNP_FUNCTION(0x0000), 0 }, {0} }; diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/sound/btaudio.c linux-2.5/drivers/sound/btaudio.c --- linux-2.5.1/drivers/sound/btaudio.c Wed Oct 17 21:19:20 2001 +++ linux-2.5/drivers/sound/btaudio.c Sun Dec 30 19:12:33 2001 @@ -1030,7 +1030,7 @@ name: "btaudio", id_table: btaudio_pci_tbl, probe: btaudio_probe, - remove: btaudio_remove, + remove: __devexit_p(btaudio_remove), }; int btaudio_init_module(void) diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/sound/cs46xx.c linux-2.5/drivers/sound/cs46xx.c --- linux-2.5.1/drivers/sound/cs46xx.c Sun Sep 30 19:26:08 2001 +++ linux-2.5/drivers/sound/cs46xx.c Sun Dec 30 19:12:33 2001 @@ -3003,7 +3003,7 @@ return -ENODEV; case SNDCTL_DSP_SETDUPLEX: - return -EINVAL; + return 0; case SNDCTL_DSP_GETODELAY: if (!(file->f_mode & FMODE_WRITE)) diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/sound/dmasound/Config.in linux-2.5/drivers/sound/dmasound/Config.in --- linux-2.5.1/drivers/sound/dmasound/Config.in Tue Apr 11 05:58:59 2000 +++ linux-2.5/drivers/sound/dmasound/Config.in Thu Dec 27 16:32:31 2001 @@ -4,7 +4,7 @@ dep_tristate ' Atari DMA sound support' CONFIG_DMASOUND_ATARI $CONFIG_SOUND fi if [ "$CONFIG_ALL_PPC" = "y" ]; then - dep_tristate ' PowerMac DMA sound support' CONFIG_DMASOUND_AWACS $CONFIG_SOUND + dep_tristate ' PowerMac DMA sound support' CONFIG_DMASOUND_PMAC $CONFIG_SOUND fi if [ "$CONFIG_AMIGA" = "y" -o "$CONFIG_APUS" = "y" ]; then dep_tristate ' Amiga DMA sound support' CONFIG_DMASOUND_PAULA $CONFIG_SOUND @@ -13,15 +13,27 @@ dep_tristate ' Q40 sound support' CONFIG_DMASOUND_Q40 $CONFIG_SOUND fi if [ "$CONFIG_DMASOUND_ATARI" = "y" -o \ - "$CONFIG_DMASOUND_AWACS" = "y" -o \ + "$CONFIG_DMASOUND_PMAC" = "y" -o \ "$CONFIG_DMASOUND_PAULA" = "y" -o \ "$CONFIG_DMASOUND_Q40" = "y" ]; then define_tristate CONFIG_DMASOUND y else if [ "$CONFIG_DMASOUND_ATARI" = "m" -o \ - "$CONFIG_DMASOUND_AWACS" = "m" -o \ + "$CONFIG_DMASOUND_PMAC" = "m" -o \ "$CONFIG_DMASOUND_PAULA" = "m" -o \ "$CONFIG_DMASOUND_Q40" = "m" ]; then define_tristate CONFIG_DMASOUND m fi fi + +# the new dmasound_pmac driver needs access to the i2c bus +if [ "$CONFIG_DMASOUND_PMAC" = "y" ] ; then + define_tristate CONFIG_I2C y + define_tristate CONFIG_I2C_KEYWEST y +else + if [ "$CONFIG_DMASOUND_PMAC" = "m" ] ; then + define_tristate CONFIG_I2C m + define_tristate CONFIG_I2C_KEYWEST m + fi +fi + diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/sound/dmasound/Makefile linux-2.5/drivers/sound/dmasound/Makefile --- linux-2.5.1/drivers/sound/dmasound/Makefile Fri Dec 29 22:07:23 2000 +++ linux-2.5/drivers/sound/dmasound/Makefile Thu Dec 27 16:32:31 2001 @@ -7,15 +7,21 @@ # # Note 2! The CFLAGS definitions are now in the main makefile... +O_TARGET = dmasound.o + export-objs := dmasound_core.o -obj-$(CONFIG_DMASOUND_ATARI) += dmasound_core.o dmasound_atari.o -obj-$(CONFIG_DMASOUND_AWACS) += dmasound_core.o dmasound_awacs.o -obj-$(CONFIG_DMASOUND_PAULA) += dmasound_core.o dmasound_paula.o -obj-$(CONFIG_DMASOUND_Q40) += dmasound_core.o dmasound_q40.o - -ifeq ($(CONFIG_DMASOUND),y) - O_TARGET = dmasound.o -endif +list-multi := dmasound_pmac.o + +dmasound_pmac-objs := dmasound_awacs.o trans_16.o tas3001c.o dac3550a.o + +obj-$(CONFIG_DMASOUND) += dmasound_core.o +obj-$(CONFIG_DMASOUND_ATARI) += dmasound_atari.o +obj-$(CONFIG_DMASOUND_PMAC) += dmasound_pmac.o +obj-$(CONFIG_DMASOUND_PAULA) += dmasound_paula.o +obj-$(CONFIG_DMASOUND_Q40) += dmasound_q40.o include $(TOPDIR)/Rules.make + +dmasound_pmac.o: $(dmasound_pmac-objs) + $(LD) $(EXTRA_LDFLAGS) -r -o $@ $(dmasound_pmac-objs) diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/sound/dmasound/awacs_defs.h linux-2.5/drivers/sound/dmasound/awacs_defs.h --- linux-2.5.1/drivers/sound/dmasound/awacs_defs.h Sun Sep 17 16:48:05 2000 +++ linux-2.5/drivers/sound/dmasound/awacs_defs.h Thu Dec 27 16:32:31 2001 @@ -71,17 +71,20 @@ /* ------- - --- ----- - ------ */ #define MASK_GAINRIGHT (0xf) /* Gain Right Mask */ #define MASK_GAINLEFT (0xf << 4) /* Gain Left Mask */ -#define MASK_GAINLINE (0x1 << 8) /* Change Gain for Line??? */ -#define MASK_GAINMIC (0x0 << 8) /* Change Gain for Mic??? */ +#define MASK_GAINLINE (0x1 << 8) /* Disable Mic preamp */ +#define MASK_GAINMIC (0x0 << 8) /* Enable Mic preamp */ #define MASK_MUX_CD (0x1 << 9) /* Select CD in MUX */ -#define MASK_MUX_AUDIN (0x1 << 10) /* Select Audio In in MUX */ -#define MASK_MUX_MIC (0x1 << 11) /* Select Mic in MUX */ +#define MASK_MUX_MIC (0x1 << 10) /* Select Mic in MUX */ +#define MASK_MUX_AUDIN (0x1 << 11) /* Select Audio In in MUX */ #define MASK_MUX_LINE MASK_MUX_AUDIN #define GAINRIGHT(x) ((x) & MASK_GAINRIGHT) #define GAINLEFT(x) (((x) << 4) & MASK_GAINLEFT) +#define DEF_CD_GAIN 0x00bb +#define DEF_MIC_GAIN 0x00cc + /* Address 1 Bit Masks */ /* ------- - --- ----- */ #define MASK_ADDR1RES1 (0x3) /* Reserved */ @@ -93,7 +96,10 @@ #define MASK_ADDR1RES2 (0x1 << 8) /* Reserved */ #define MASK_AMUTE (0x1 << 9) /* Output A (Headphone) Mute when 1 */ #define MASK_HDMUTE MASK_AMUTE -#define MASK_PAROUT (0x3 << 10) /* Parallel Out (???) */ +#define MASK_PAROUT0 (0x1 << 10) /* Parallel Output 0 */ +#define MASK_PAROUT1 (0x2 << 10) /* Parallel Output 1 */ + +#define MASK_MIC_BOOST (0x4) /* screamer mic boost */ #define SAMPLERATE_48000 (0x0 << 3) /* 48 or 44.1 kHz */ #define SAMPLERATE_32000 (0x1 << 3) /* 32 or 29.4 kHz */ diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/sound/dmasound/dac3550a.c linux-2.5/drivers/sound/dmasound/dac3550a.c --- linux-2.5.1/drivers/sound/dmasound/dac3550a.c Thu Jan 1 00:00:00 1970 +++ linux-2.5/drivers/sound/dmasound/dac3550a.c Thu Dec 27 16:32:31 2001 @@ -0,0 +1,269 @@ +/* + * Driver for the i2c/i2s based DAC3550a sound chip used + * on some Apple iBooks. Also known as "DACA". + * + * 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. + */ + +#include <linux/version.h> +#include <linux/module.h> +#include <linux/slab.h> +#include <linux/proc_fs.h> +#include <linux/ioport.h> +#include <linux/sysctl.h> +#include <linux/types.h> +#include <linux/i2c.h> +#include <linux/init.h> +#include <asm/uaccess.h> +#include <asm/errno.h> +#include <asm/io.h> + +#include "dmasound.h" + +/* FYI: This code was derived from the tas3001c.c Texas/Tumbler mixer + * control code, as well as info derived from the AppleDACAAudio driver + * from Darwin CVS (main thing I derived being register numbers and + * values, as well as when to make the calls). */ + +#define I2C_DRIVERID_DACA (0xFDCB) + +#define DACA_VERSION "0.1" +#define DACA_DATE "20010930" + +static int cur_left_vol; +static int cur_right_vol; +static struct i2c_client * daca_client = NULL; + +static int daca_attach_adapter(struct i2c_adapter *adapter); + +static int daca_attach_adapter(struct i2c_adapter *adapter); +static int daca_detect_client(struct i2c_adapter *adapter, int address); +static int daca_detach_client(struct i2c_client *client); + +/* Unique ID allocation */ +static int daca_id; +static int daca_initialized; + +struct daca_data +{ + int arf; /* place holder for furture use */ +}; + +struct i2c_driver daca_driver = { + name: "DAC3550A driver V " DACA_VERSION, + id: I2C_DRIVERID_DACA, + flags: I2C_DF_NOTIFY, + attach_adapter: &daca_attach_adapter, + detach_client: &daca_detach_client, + command: NULL, + inc_use: NULL, /* &daca_inc_use, */ + dec_use: NULL /* &daca_dev_use */ + }; + + +#define VOL_MAX ((1<<20) - 1) + +void +daca_get_volume(uint * left_vol, uint *right_vol) +{ + *left_vol = cur_left_vol >> 5; + *right_vol = cur_right_vol >> 5; +} + +int +daca_set_volume(uint left_vol, uint right_vol) +{ + unsigned short voldata; + + if (!daca_client) + return -1; + + /* Derived from experience, not from any specific values */ + left_vol <<= 5; + right_vol <<= 5; + + if (left_vol > VOL_MAX) + left_vol = VOL_MAX; + if (right_vol > VOL_MAX) + right_vol = VOL_MAX; + + voldata = ((left_vol >> 14) & 0x3f) << 8; + voldata |= (right_vol >> 14) & 0x3f; + + if (i2c_smbus_write_word_data(daca_client, 2, voldata) < 0) { + printk("daca: failed to set volume \n"); + return -1; + } + + cur_left_vol = left_vol; + cur_right_vol = right_vol; + + return 0; +} + +int +daca_leave_sleep(void) +{ + if (!daca_client) + return -1; + + /* Do a short sleep, just to make sure I2C bus is awake and paying + * attention to us + */ + wait_ms(20); + /* Write the sample rate reg the value it needs */ + i2c_smbus_write_byte_data(daca_client, 1, 8); + daca_set_volume(cur_left_vol >> 5, cur_right_vol >> 5); + /* Another short delay, just to make sure the other I2C bus writes + * have taken... + */ + wait_ms(20); + /* Write the global config reg - invert right power amp, + * DAC on, use 5-volt mode */ + i2c_smbus_write_byte_data(daca_client, 3, 0x45); + + return 0; +} + +int +daca_enter_sleep(void) +{ + if (!daca_client) + return -1; + + i2c_smbus_write_byte_data(daca_client, 1, 8); + daca_set_volume(cur_left_vol >> 5, cur_right_vol >> 5); + + /* Write the global config reg - invert right power amp, + * DAC on, enter low-power mode, use 5-volt mode + */ + i2c_smbus_write_byte_data(daca_client, 3, 0x65); + + return 0; +} + +static int +daca_attach_adapter(struct i2c_adapter *adapter) +{ + if (!strncmp(adapter->name, "mac-io", 6)) + daca_detect_client(adapter, 0x4d); + return 0; +} + +static int +daca_init_client(struct i2c_client * new_client) +{ + /* + * Probe is not working with the current i2c-keywest + * driver. We try to use addr 0x4d on each adapters + * instead, by setting the format register. + * + * FIXME: I'm sure that can be obtained from the + * device-tree. --BenH. + */ + + /* Write the global config reg - invert right power amp, + * DAC on, use 5-volt mode + */ + if (i2c_smbus_write_byte_data(new_client, 3, 0x45)) + return -1; + + i2c_smbus_write_byte_data(new_client, 1, 8); + daca_client = new_client; + daca_set_volume(15000, 15000); + + return 0; +} + +static int +daca_detect_client(struct i2c_adapter *adapter, int address) +{ + int rc = 0; + struct i2c_client *new_client; + + struct daca_data *data; + const char *client_name = "DAC 3550A Digital Equalizer"; + + new_client = kmalloc( + sizeof(struct i2c_client) + sizeof(struct daca_data), + GFP_KERNEL); + if (!new_client) { + rc = -ENOMEM; + goto bail; + } + + /* This is tricky, but it will set the data to the right value. */ + new_client->data = new_client + 1; + data = (struct daca_data *) (new_client->data); + + new_client->addr = address; + new_client->data = data; + new_client->adapter = adapter; + new_client->driver = &daca_driver; + new_client->flags = 0; + + strcpy(new_client->name,client_name); + + new_client->id = daca_id++; /* Automatically unique */ + + if (daca_init_client(new_client)) { + rc = -ENODEV; + goto bail; + } + + /* Tell the i2c layer a new client has arrived */ + if (i2c_attach_client(new_client)) { + rc = -ENODEV; + goto bail; + } +bail: + if (rc && new_client) + kfree(new_client); + return rc; +} + + +static int +daca_detach_client(struct i2c_client *client) +{ + if (client == daca_client) + daca_client = NULL; + + i2c_detach_client(client); + kfree(client); + + return 0; +} + +int +daca_cleanup(void) +{ + if (!daca_initialized) + return -ENODEV; + i2c_del_driver(&daca_driver); + daca_initialized = 0; + + return 0; +} + +int +daca_init(void) +{ + int rc; + + if (daca_initialized) + return 0; + + printk("dac3550a driver version %s (%s)\n",DACA_VERSION,DACA_DATE); + + if ((rc = i2c_add_driver(&daca_driver))) { + printk("dac3550a: Driver registration failed, module not inserted.\n"); + daca_cleanup(); + return rc; + } + daca_initialized = 1; + + return 0; +} diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/sound/dmasound/dmasound.h linux-2.5/drivers/sound/dmasound/dmasound.h --- linux-2.5.1/drivers/sound/dmasound/dmasound.h Wed Aug 15 08:22:16 2001 +++ linux-2.5/drivers/sound/dmasound/dmasound.h Thu Dec 27 16:32:31 2001 @@ -1,4 +1,4 @@ - +#ifndef _dmasound_h_ /* * linux/drivers/sound/dmasound/dmasound.h * @@ -10,11 +10,11 @@ * device for true DSP processors but it will be called something else. * In v3.0 it's /dev/sndproc but this could be a temporary solution. */ +#define _dmasound_h_ - +#include <linux/types.h> #include <linux/config.h> - #define SND_NDEVS 256 /* Number of supported devices */ #define SND_DEV_CTL 0 /* Control port /dev/mixer */ #define SND_DEV_SEQ 1 /* Sequencer output /dev/sequencer (FM @@ -29,23 +29,16 @@ #define SND_DEV_SNDPROC 9 /* /dev/sndproc for programmable devices */ #define SND_DEV_PSS SND_DEV_SNDPROC -#define DSP_DEFAULT_SPEED 8000 - -#define ON 1 -#define OFF 0 +/* switch on various prinks */ +#define DEBUG_DMASOUND 1 #define MAX_AUDIO_DEV 5 -#define MAX_MIXER_DEV 2 +#define MAX_MIXER_DEV 4 #define MAX_SYNTH_DEV 3 #define MAX_MIDI_DEV 6 #define MAX_TIMER_DEV 3 - #define MAX_CATCH_RADIUS 10 -#define MIN_BUFFERS 4 -#define MIN_BUFSIZE 4 /* in KB */ -#define MAX_BUFSIZE 128 /* Limit for Amiga in KB */ - #define le2be16(x) (((x)<<8 & 0xff00) | ((x)>>8 & 0x00ff)) #define le2be16dbl(x) (((x)<<8 & 0xff00ff00) | ((x)>>8 & 0x00ff00ff)) @@ -67,21 +60,34 @@ */ #undef HAS_8BIT_TABLES -#undef HAS_14BIT_TABLES -#undef HAS_16BIT_TABLES #undef HAS_RECORD #if defined(CONFIG_DMASOUND_ATARI) || defined(CONFIG_DMASOUND_ATARI_MODULE) ||\ defined(CONFIG_DMASOUND_PAULA) || defined(CONFIG_DMASOUND_PAULA_MODULE) ||\ defined(CONFIG_DMASOUND_Q40) || defined(CONFIG_DMASOUND_Q40_MODULE) #define HAS_8BIT_TABLES +#define MIN_BUFFERS 4 +#define MIN_BUFSIZE (1<<12) /* in bytes (- where does this come from ?) */ +#define MIN_FRAG_SIZE 8 /* not 100% sure about this */ +#define MAX_BUFSIZE (1<<17) /* Limit for Amiga is 128 kb */ +#define MAX_FRAG_SIZE 15 /* allow *4 for mono-8 => stereo-16 (for multi) */ + +#else /* is pmac and multi is off */ + +#define MIN_BUFFERS 2 +#define MIN_BUFSIZE (1<<8) /* in bytes */ +#define MIN_FRAG_SIZE 8 +#define MAX_BUFSIZE (1<<18) /* this is somewhat arbitrary for pmac */ +#define MAX_FRAG_SIZE 16 /* need to allow *4 for mono-8 => stereo-16 */ #endif -#if defined(CONFIG_DMASOUND_AWACS) || defined(CONFIG_DMASOUND_AWACS_MODULE) -#define HAS_16BIT_TABLES + +#define DEFAULT_N_BUFFERS 4 +#define DEFAULT_BUFF_SIZE (1<<15) + +#if defined(CONFIG_DMASOUND_PMAC) || defined(CONFIG_DMASOUND_PMAC_MODULE) #define HAS_RECORD #endif - /* * Initialization */ @@ -93,6 +99,14 @@ #define dmasound_deinit() do { } while (0) #endif +/* description of the set-up applies to either hard or soft settings */ + +typedef struct { + int format; /* AFMT_* */ + int stereo; /* 0 = mono, 1 = stereo */ + int size; /* 8/16 bit*/ + int speed; /* speed */ +} SETTINGS; /* * Machine definitions @@ -117,30 +131,29 @@ int (*setTreble)(int); int (*setGain)(int); void (*play)(void); - void (*record)(void); /* optional */ - void (*mixer_init)(void); /* optional */ - int (*mixer_ioctl)(u_int, u_long); /* optional */ - void (*write_sq_setup)(void); /* optional */ - void (*read_sq_setup)(void); /* optional */ - void (*sq_open)(void); /* optional */ - int (*state_info)(char *); /* optional */ - void (*abort_read)(void); /* optional */ + void (*record)(void); /* optional */ + void (*mixer_init)(void); /* optional */ + int (*mixer_ioctl)(u_int, u_long); /* optional */ + int (*write_sq_setup)(void); /* optional */ + int (*read_sq_setup)(void); /* optional */ + int (*sq_open)(mode_t); /* optional */ + int (*state_info)(char *, size_t); /* optional */ + void (*abort_read)(void); /* optional */ int min_dsp_speed; + int max_dsp_speed; + int version ; + int hardware_afmts ; /* OSS says we only return h'ware info */ + /* when queried via SNDCTL_DSP_GETFMTS */ + int capabilities ; /* low-level reply to SNDCTL_DSP_GETCAPS */ + SETTINGS default_hard ; /* open() or init() should set something valid */ + SETTINGS default_soft ; /* you can make it look like old OSS, if you want to */ } MACHINE; - /* * Low level stuff */ typedef struct { - int format; /* AFMT_* */ - int stereo; /* 0 = mono, 1 = stereo */ - int size; /* 8/16 bit*/ - int speed; /* speed */ -} SETTINGS; - -typedef struct { ssize_t (*ct_ulaw)(const u_char *, size_t, u_char *, ssize_t *, ssize_t); ssize_t (*ct_alaw)(const u_char *, size_t, u_char *, ssize_t *, ssize_t); ssize_t (*ct_s8)(const u_char *, size_t, u_char *, ssize_t *, ssize_t); @@ -170,11 +183,10 @@ extern struct sound_settings dmasound; +#ifdef HAS_8BIT_TABLES extern char dmasound_ulaw2dma8[]; extern char dmasound_alaw2dma8[]; -extern short dmasound_ulaw2dma16[]; -extern short dmasound_alaw2dma16[]; - +#endif /* * Mid level stuff @@ -207,14 +219,17 @@ struct sound_queue { /* buffers allocated for this queue */ - int numBufs; - int bufSize; /* in bytes */ + int numBufs; /* real limits on what the user can have */ + int bufSize; /* in bytes */ char **buffers; /* current parameters */ - int max_count; - int block_size; /* in bytes */ - int max_active; + int locked ; /* params cannot be modified when != 0 */ + int user_frags ; /* user requests this many */ + int user_frag_size ; /* of this size */ + int max_count; /* actual # fragments <= numBufs */ + int block_size; /* internal block size in bytes */ + int max_active; /* in-use fragments <= max_count */ /* it shouldn't be necessary to declare any of these volatile */ int front, rear, count; @@ -230,19 +245,35 @@ int active; wait_queue_head_t action_queue, open_queue, sync_queue; int open_mode; - int busy, syncing; + int busy, syncing, xruns, died; }; #define SLEEP(queue) interruptible_sleep_on_timeout(&queue, HZ) #define WAKE_UP(queue) (wake_up_interruptible(&queue)) extern struct sound_queue dmasound_write_sq; +#ifdef HAS_RECORD extern struct sound_queue dmasound_read_sq; +#endif #define write_sq dmasound_write_sq +#ifdef HAS_RECORD #define read_sq dmasound_read_sq +#endif extern int dmasound_catchRadius; #define catchRadius dmasound_catchRadius +/* define the value to be put in the byte-swap reg in mac-io + when we want it to swap for us. +*/ +#define BS_VAL 1 + +static inline void wait_ms(unsigned int ms) +{ + current->state = TASK_UNINTERRUPTIBLE; + schedule_timeout(1 + ms * HZ / 1000); +} + +#endif /* _dmasound_h_ */ diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/sound/dmasound/dmasound_atari.c linux-2.5/drivers/sound/dmasound/dmasound_atari.c --- linux-2.5.1/drivers/sound/dmasound/dmasound_atari.c Thu Oct 25 20:53:52 2001 +++ linux-2.5/drivers/sound/dmasound/dmasound_atari.c Thu Dec 27 16:32:31 2001 @@ -1,10 +1,16 @@ - /* * linux/drivers/sound/dmasound/dmasound_atari.c * * Atari TT and Falcon DMA Sound Driver * * See linux/drivers/sound/dmasound/dmasound_core.c for copyright and credits + * prior to 28/01/2001 + * + * 28/01/2001 [0.1] Iain Sandoe + * - added versioning + * - put in and populated the hardware_afmts field. + * [0.2] - put in SNDCTL_DSP_GETCAPS value. + * 01/02/2001 [0.3] - put in default hard/soft settings. */ @@ -21,10 +27,11 @@ #include "dmasound.h" +#define DMASOUND_ATARI_REVISION 0 +#define DMASOUND_ATARI_EDITION 3 extern void atari_microwire_cmd(int cmd); - static int is_falcon; static int write_sq_ignore_int = 0; /* ++TeSche: used for Falcon */ @@ -137,9 +144,9 @@ static int TTMixerIoctl(u_int cmd, u_long arg); static int FalconMixerIoctl(u_int cmd, u_long arg); static void AtaWriteSqSetup(void); -static void AtaSqOpen(void); -static int TTStateInfo(char *buffer); -static int FalconStateInfo(char *buffer); +static int AtaSqOpen(mode_t mode); +static int TTStateInfo(char *buffer, size_t space); +static int FalconStateInfo(char *buffer, size_t space); /*** Translations ************************************************************/ @@ -1438,43 +1445,73 @@ return AtaMixerIoctl(cmd, arg); } -static void AtaWriteSqSetup(void) +static int AtaWriteSqSetup(void) { write_sq_ignore_int = 0; + return 0 ; } -static void AtaSqOpen(void) +static int AtaSqOpen(mode_t mode) { write_sq_ignore_int = 1; + return 0 ; } -static int TTStateInfo(char *buffer) +static int TTStateInfo(char *buffer, size_t space) { int len = 0; - len += sprintf(buffer+len, "\tsound.volume_left = %ddB [-40...0]\n", + len += sprintf(buffer+len, "\tvol left %ddB [-40... 0]\n", dmasound.volume_left); - len += sprintf(buffer+len, "\tsound.volume_right = %ddB [-40...0]\n", + len += sprintf(buffer+len, "\tvol right %ddB [-40... 0]\n", dmasound.volume_right); - len += sprintf(buffer+len, "\tsound.bass = %ddB [-12...+12]\n", + len += sprintf(buffer+len, "\tbass %ddB [-12...+12]\n", dmasound.bass); - len += sprintf(buffer+len, "\tsound.treble = %ddB [-12...+12]\n", + len += sprintf(buffer+len, "\ttreble %ddB [-12...+12]\n", dmasound.treble); + if (len >= space) { + printk(KERN_ERR "dmasound_atari: overflowed state buffer alloc.\n") ; + len = space ; + } return len; } -static int FalconStateInfo(char *buffer) +static int FalconStateInfo(char *buffer, size_t space) { int len = 0; - len += sprintf(buffer+len, "\tsound.volume_left = %ddB [-22.5...0]\n", + len += sprintf(buffer+len, "\tvol left %ddB [-22.5 ... 0]\n", dmasound.volume_left); - len += sprintf(buffer+len, "\tsound.volume_right = %ddB [-22.5...0]\n", + len += sprintf(buffer+len, "\tvol right %ddB [-22.5 ... 0]\n", dmasound.volume_right); + if (len >= space) { + printk(KERN_ERR "dmasound_atari: overflowed state buffer alloc.\n") ; + len = space ; + } return len; } /*** Machine definitions *****************************************************/ +static SETTINGS def_hard_falcon = { + format: AFMT_S8, + stereo: 0, + size: 8, + speed: 8195 +} ; + +static SETTINGS def_hard_tt = { + format: AFMT_S8, + stereo: 0, + size: 8, + speed: 12517 +} ; + +static SETTINGS def_soft = { + format: AFMT_U8, + stereo: 0, + size: 8, + speed: 8000 +} ; static MACHINE machTT = { name: "Atari", @@ -1501,6 +1538,9 @@ sq_open: AtaSqOpen, state_info: TTStateInfo, min_dsp_speed: 6258, + version: ((DMASOUND_ATARI_REVISION<<8) | DMASOUND_ATARI_EDITION), + hardware_afmts: AFMT_S8, /* h'ware-supported formats *only* here */ + capabilities: DSP_CAP_BATCH /* As per SNDCTL_DSP_GETCAPS */ }; static MACHINE machFalcon = { @@ -1525,6 +1565,9 @@ sq_open: AtaSqOpen, state_info: FalconStateInfo, min_dsp_speed: 8195, + version: ((DMASOUND_ATARI_REVISION<<8) | DMASOUND_ATARI_EDITION), + hardware_afmts: (AFMT_S8 | AFMT_S16_BE), /* h'ware-supported formats *only* here */ + capabilities: DSP_CAP_BATCH /* As per SNDCTL_DSP_GETCAPS */ }; @@ -1536,9 +1579,13 @@ if (MACH_IS_ATARI && ATARIHW_PRESENT(PCM_8BIT)) { if (ATARIHW_PRESENT(CODEC)) { dmasound.mach = machFalcon; + dmasound.mach.default_soft = def_soft ; + dmasound.mach.default_hard = def_hard_falcon ; is_falcon = 1; } else if (ATARIHW_PRESENT(MICROWIRE)) { dmasound.mach = machTT; + dmasound.mach.default_soft = def_soft ; + dmasound.mach.default_hard = def_hard_tt ; is_falcon = 0; } else return -ENODEV; diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/sound/dmasound/dmasound_awacs.c linux-2.5/drivers/sound/dmasound/dmasound_awacs.c --- linux-2.5.1/drivers/sound/dmasound/dmasound_awacs.c Thu Oct 25 20:53:52 2001 +++ linux-2.5/drivers/sound/dmasound/dmasound_awacs.c Thu Dec 27 16:32:31 2001 @@ -1,13 +1,54 @@ - /* * linux/drivers/sound/dmasound/dmasound_awacs.c * * PowerMac `AWACS' and `Burgundy' DMA Sound Driver + * with some limited support for DACA & Tumbler * - * See linux/drivers/sound/dmasound/dmasound_core.c for copyright and credits - */ - + * See linux/drivers/sound/dmasound/dmasound_core.c for copyright and + * history prior to 2001/01/26. + * + * 26/01/2001 ed 0.1 Iain Sandoe + * - added version info. + * - moved dbdma command buffer allocation to PMacXXXSqSetup() + * - fixed up beep dbdma cmd buffers + * + * 08/02/2001 [0.2] + * - make SNDCTL_DSP_GETFMTS return the correct info for the h/w + * - move soft format translations to a separate file + * - [0.3] make SNDCTL_DSP_GETCAPS return correct info. + * - [0.4] more informative machine name strings. + * - [0.5] + * - record changes. + * - made the default_hard/soft entries. + * 04/04/2001 [0.6] + * - minor correction to bit assignments in awacs_defs.h + * - incorporate mixer changes from 2.2.x back-port. + * - take out passthru as a rec input (it isn't). + * - make Input Gain slider work the 'right way up'. + * - try to make the mixer sliders more logical - so now the + * input selectors are just two-state (>50% == ON) and the + * Input Gain slider handles the rest of the gain issues. + * - try to pick slider representations that most closely match + * the actual use - e.g. IGain for input gain... + * - first stab at over/under-run detection. + * - minor cosmetic changes to IRQ identification. + * - fix bug where rates > max would be reported as supported. + * - first stab at over/under-run detection. + * - make use of i2c for mixer settings conditional on perch + * rather than cuda (some machines without perch have cuda). + * - fix bug where TX stops when dbdma status comes up "DEAD" + * so far only reported on PowerComputing clones ... but. + * - put in AWACS/Screamer register write timeouts. + * - part way to partitioning the init() stuff + * - first pass at 'tumbler' stuff (not support - just an attempt + * to allow the driver to load on new G4s). +*/ + +/* GENERAL FIXME/TODO: check that the assumptions about what is written to + mac-io is valid for DACA & Tumbler. +*/ +#include <linux/types.h> #include <linux/module.h> #include <linux/config.h> #include <linux/slab.h> @@ -18,6 +59,9 @@ #include <linux/nvram.h> #include <linux/tty.h> #include <linux/vt_kern.h> +#include <linux/irq.h> +#include <linux/kmod.h> +#include <asm/semaphore.h> #ifdef CONFIG_ADB_CUDA #include <linux/cuda.h> #endif @@ -25,20 +69,30 @@ #include <linux/pmu.h> #endif +#include <linux/i2c-dev.h> + #include <asm/uaccess.h> #include <asm/prom.h> #include <asm/machdep.h> #include <asm/io.h> #include <asm/dbdma.h> -#include <asm/feature.h> +#include <asm/pmac_feature.h> #include <asm/irq.h> +#include <asm/nvram.h> #include "awacs_defs.h" #include "dmasound.h" +#define DMASOUND_AWACS_REVISION 0 +#define DMASOUND_AWACS_EDITION 6 +#define AWACS_BURGUNDY 100 /* fake revision # for burgundy */ +#define AWACS_TUMBLER 90 /* fake revision # for tumbler */ +#define AWACS_DACA 80 /* fake revision # for daca (ibook) */ +#define AWACS_AWACS 2 /* holding revision for AWACS */ +#define AWACS_SCREAMER 3 /* holding revision for Screamer */ /* - * Interrupt numbers and addresses, obtained from the device tree. + * Interrupt numbers and addresses, & info obtained from the device tree. */ static int awacs_irq, awacs_tx_irq, awacs_rx_irq; static volatile struct awacs_regs *awacs; @@ -50,28 +104,58 @@ static char awacs_name[64]; static int awacs_revision; -int awacs_is_screamer = 0; -int awacs_device_id = 0; -int awacs_has_iic = 0; -#define AWACS_BURGUNDY 100 /* fake revision # for burgundy */ +static int awacs_sleeping; +static DECLARE_MUTEX(dmasound_sem); + +static int sound_device_id; /* exists after iMac revA */ +static int hw_can_byteswap = 1 ; /* most pmac sound h/w can */ + +/* model info */ +/* To be replaced with better interaction with pmac_feature.c */ +static int is_pbook_3X00; +static int is_pbook_g3; + +/* expansion info */ +static int has_perch; +static int has_ziva; + +/* for earlier powerbooks which need fiddling with mac-io to enable + * cd etc. +*/ +static unsigned char *latch_base; +static unsigned char *macio_base; /* * Space for the DBDMA command blocks. */ static void *awacs_tx_cmd_space; static volatile struct dbdma_cmd *awacs_tx_cmds; +static int number_of_tx_cmd_buffers = 0; static void *awacs_rx_cmd_space; static volatile struct dbdma_cmd *awacs_rx_cmds; +static int number_of_rx_cmd_buffers = 0; /* * Cached values of AWACS registers (we can't read them). - * Except on the burgundy. XXX + * Except on the burgundy (and screamer). XXX */ + int awacs_reg[8]; +int awacs_reg1_save; + +/* tracking values for the mixer contents +*/ -#define HAS_16BIT_TABLES -#undef HAS_8BIT_TABLES +static int spk_vol = 0 ; +static int line_vol = 0 ; +static int passthru_vol = 0 ; + +static int ip_gain = 0 ; /* mic preamp settings */ +static int rec_lev = 0x4545 ; /* default CD gain 69 % */ +static int mic_lev = 0 ; +static int cd_lev = 0x6363 ; /* 99 % */ +static int line_lev = 0 ; /* * Stuff for outputting a beep. The values range from -327 to +327 @@ -113,20 +197,18 @@ -269, -245, -218, -187, -153, -117, -79, -40, }; +/* beep support */ #define BEEP_SRATE 22050 /* 22050 Hz sample rate */ #define BEEP_BUFLEN 512 #define BEEP_VOLUME 15 /* 0 - 100 */ -static int beep_volume = BEEP_VOLUME; +static int beep_vol = BEEP_VOLUME; static int beep_playing = 0; static int awacs_beep_state = 0; static short *beep_buf; +static void *beep_dbdma_cmd_space; static volatile struct dbdma_cmd *beep_dbdma_cmd; static void (*orig_mksound)(unsigned int, unsigned int); -static int is_pbook_3400; -static unsigned char *latch_base; -static int is_pbook_G3; -static unsigned char *macio_base; /* Burgundy functions */ static void awacs_burgundy_wcw(unsigned addr,unsigned newval); @@ -136,6 +218,18 @@ static void awacs_burgundy_write_mvolume(unsigned address, int volume); static int awacs_burgundy_read_mvolume(unsigned address); +/* we will allocate a single 'emergency' dbdma cmd block to use if the + tx status comes up "DEAD". This happens on some PowerComputing Pmac + clones, either owing to a bug in dbdma or some interaction between + IDE and sound. However, this measure would deal with DEAD status if + if appeared elsewhere. + + for the sake of memory efficiency we'll allocate this cmd as part of + the beep cmd stuff. +*/ + +static volatile struct dbdma_cmd *emergency_dbdma_cmd; + #ifdef CONFIG_PMAC_PBOOK /* * Stuff for restoring after a sleep. @@ -146,78 +240,11 @@ }; #endif /* CONFIG_PMAC_PBOOK */ -static int expand_bal; /* Balance factor for expanding (not volume!) */ -static int expand_data; /* Data for expanding */ - - -/*** Translations ************************************************************/ - - -/* ++TeSche: radically changed for new expanding purposes... - * - * These two routines now deal with copying/expanding/translating the samples - * from user space into our buffer at the right frequency. They take care about - * how much data there's actually to read, how much buffer space there is and - * to convert samples into the right frequency/encoding. They will only work on - * complete samples so it may happen they leave some bytes in the input stream - * if the user didn't write a multiple of the current sample size. They both - * return the number of bytes they've used from both streams so you may detect - * such a situation. Luckily all programs should be able to cope with that. - * - * I think I've optimized anything as far as one can do in plain C, all - * variables should fit in registers and the loops are really short. There's - * one loop for every possible situation. Writing a more generalized and thus - * parameterized loop would only produce slower code. Feel free to optimize - * this in assembler if you like. :) - * - * I think these routines belong here because they're not yet really hardware - * independent, especially the fact that the Falcon can play 16bit samples - * only in stereo is hardcoded in both of them! - * - * ++geert: split in even more functions (one per format) - */ - -static ssize_t pmac_ct_law(const u_char *userPtr, size_t userCount, - u_char frame[], ssize_t *frameUsed, - ssize_t frameLeft); -static ssize_t pmac_ct_s8(const u_char *userPtr, size_t userCount, - u_char frame[], ssize_t *frameUsed, - ssize_t frameLeft); -static ssize_t pmac_ct_u8(const u_char *userPtr, size_t userCount, - u_char frame[], ssize_t *frameUsed, - ssize_t frameLeft); -static ssize_t pmac_ct_s16(const u_char *userPtr, size_t userCount, - u_char frame[], ssize_t *frameUsed, - ssize_t frameLeft); -static ssize_t pmac_ct_u16(const u_char *userPtr, size_t userCount, - u_char frame[], ssize_t *frameUsed, - ssize_t frameLeft); -static ssize_t pmac_ctx_law(const u_char *userPtr, size_t userCount, - u_char frame[], ssize_t *frameUsed, - ssize_t frameLeft); -static ssize_t pmac_ctx_s8(const u_char *userPtr, size_t userCount, - u_char frame[], ssize_t *frameUsed, - ssize_t frameLeft); -static ssize_t pmac_ctx_u8(const u_char *userPtr, size_t userCount, - u_char frame[], ssize_t *frameUsed, - ssize_t frameLeft); -static ssize_t pmac_ctx_s16(const u_char *userPtr, size_t userCount, - u_char frame[], ssize_t *frameUsed, - ssize_t frameLeft); -static ssize_t pmac_ctx_u16(const u_char *userPtr, size_t userCount, - u_char frame[], ssize_t *frameUsed, - ssize_t frameLeft); -static ssize_t pmac_ct_s16_read(const u_char *userPtr, size_t userCount, - u_char frame[], ssize_t *frameUsed, - ssize_t frameLeft); -static ssize_t pmac_ct_u16_read(const u_char *userPtr, size_t userCount, - u_char frame[], ssize_t *frameUsed, - ssize_t frameLeft); - +/* for (soft) sample rate translations */ +int expand_bal; /* Balance factor for expanding (not volume!) */ /*** Low level stuff *********************************************************/ - static void PMacOpen(void); static void PMacRelease(void); static void *PMacAlloc(unsigned int size, int flags); @@ -244,565 +271,212 @@ /*** Mid level stuff **********************************************************/ - static int PMacMixerIoctl(u_int cmd, u_long arg); -static void PMacWriteSqSetup(void); -static void PMacReadSqSetup(void); +static int PMacWriteSqSetup(void); +static int PMacReadSqSetup(void); static void PMacAbortRead(void); +extern TRANS transAwacsNormal ; +extern TRANS transAwacsExpand ; +extern TRANS transAwacsNormalRead ; + +extern int daca_init(void); +extern int daca_cleanup(void); +extern int daca_set_volume(uint left_vol, uint right_vol); +extern void daca_get_volume(uint * left_vol, uint *right_vol); +extern int daca_enter_sleep(void); +extern int daca_leave_sleep(void); + +extern int tas_init(void); +extern int tas_cleanup(void); +extern int tumbler_set_volume(uint left_vol, uint right_vol); +extern void tumbler_get_volume(uint * left_vol, uint *right_vol); +extern void tumbler_set_treble(int treble); +extern void tumbler_get_treble(int *treble); +extern void tumbler_set_bass(int bass); +extern void tumbler_get_bass(int *bass); +extern void tumbler_set_pcm_lvl(int pcm_lvl); +extern void tumbler_get_pcm_lvl(int *pcm_lvl); + +#define TRY_LOCK() \ + if ((rc = down_interruptible(&dmasound_sem)) != 0) \ + return rc; +#define LOCK() down(&dmasound_sem); + +#define UNLOCK() up(&dmasound_sem); + +/* We use different versions that the ones provided in dmasound.h + * + * FIXME: Use different names ;) + */ +#undef IOCTL_IN +#undef IOCTL_OUT -/*** Translations ************************************************************/ - - -static ssize_t pmac_ct_law(const u_char *userPtr, size_t userCount, - u_char frame[], ssize_t *frameUsed, - ssize_t frameLeft) -{ - short *table = dmasound.soft.format == AFMT_MU_LAW - ? dmasound_ulaw2dma16 : dmasound_alaw2dma16; - ssize_t count, used; - short *p = (short *) &frame[*frameUsed]; - int val, stereo = dmasound.soft.stereo; - - frameLeft >>= 2; - if (stereo) - userCount >>= 1; - used = count = min_t(unsigned long, userCount, frameLeft); - while (count > 0) { - u_char data; - if (get_user(data, userPtr++)) - return -EFAULT; - val = table[data]; - *p++ = val; - if (stereo) { - if (get_user(data, userPtr++)) - return -EFAULT; - val = table[data]; - } - *p++ = val; - count--; - } - *frameUsed += used * 4; - return stereo? used * 2: used; -} - - -static ssize_t pmac_ct_s8(const u_char *userPtr, size_t userCount, - u_char frame[], ssize_t *frameUsed, - ssize_t frameLeft) -{ - ssize_t count, used; - short *p = (short *) &frame[*frameUsed]; - int val, stereo = dmasound.soft.stereo; - - frameLeft >>= 2; - if (stereo) - userCount >>= 1; - used = count = min_t(unsigned long, userCount, frameLeft); - while (count > 0) { - u_char data; - if (get_user(data, userPtr++)) - return -EFAULT; - val = data << 8; - *p++ = val; - if (stereo) { - if (get_user(data, userPtr++)) - return -EFAULT; - val = data << 8; - } - *p++ = val; - count--; - } - *frameUsed += used * 4; - return stereo? used * 2: used; -} - - -static ssize_t pmac_ct_u8(const u_char *userPtr, size_t userCount, - u_char frame[], ssize_t *frameUsed, - ssize_t frameLeft) -{ - ssize_t count, used; - short *p = (short *) &frame[*frameUsed]; - int val, stereo = dmasound.soft.stereo; - - frameLeft >>= 2; - if (stereo) - userCount >>= 1; - used = count = min_t(unsigned long, userCount, frameLeft); - while (count > 0) { - u_char data; - if (get_user(data, userPtr++)) - return -EFAULT; - val = (data ^ 0x80) << 8; - *p++ = val; - if (stereo) { - if (get_user(data, userPtr++)) - return -EFAULT; - val = (data ^ 0x80) << 8; - } - *p++ = val; - count--; - } - *frameUsed += used * 4; - return stereo? used * 2: used; -} - - -static ssize_t pmac_ct_s16(const u_char *userPtr, size_t userCount, - u_char frame[], ssize_t *frameUsed, - ssize_t frameLeft) -{ - ssize_t count, used; - int stereo = dmasound.soft.stereo; - short *fp = (short *) &frame[*frameUsed]; - - frameLeft >>= 2; - userCount >>= (stereo? 2: 1); - used = count = min_t(unsigned long, userCount, frameLeft); - if (!stereo) { - short *up = (short *) userPtr; - while (count > 0) { - short data; - if (get_user(data, up++)) - return -EFAULT; - *fp++ = data; - *fp++ = data; - count--; - } - } else { - if (copy_from_user(fp, userPtr, count * 4)) - return -EFAULT; - } - *frameUsed += used * 4; - return stereo? used * 4: used * 2; -} +#define IOCTL_IN(arg, ret) \ + rc = get_user(ret, (int *)(arg)); \ + if (rc) break; +#define IOCTL_OUT(arg, ret) \ + ioctl_return2((int *)(arg), ret) -static ssize_t pmac_ct_u16(const u_char *userPtr, size_t userCount, - u_char frame[], ssize_t *frameUsed, - ssize_t frameLeft) -{ - ssize_t count, used; - int mask = (dmasound.soft.format == AFMT_U16_LE? 0x0080: 0x8000); - int stereo = dmasound.soft.stereo; - short *fp = (short *) &frame[*frameUsed]; - short *up = (short *) userPtr; - - frameLeft >>= 2; - userCount >>= (stereo? 2: 1); - used = count = min_t(unsigned long, userCount, frameLeft); - while (count > 0) { - int data; - if (get_user(data, up++)) - return -EFAULT; - data ^= mask; - *fp++ = data; - if (stereo) { - if (get_user(data, up++)) - return -EFAULT; - data ^= mask; - } - *fp++ = data; - count--; - } - *frameUsed += used * 4; - return stereo? used * 4: used * 2; +static inline int ioctl_return2(int *addr, int value) +{ + return value < 0 ? value : put_user(value, addr); } -static ssize_t pmac_ctx_law(const u_char *userPtr, size_t userCount, - u_char frame[], ssize_t *frameUsed, - ssize_t frameLeft) -{ - unsigned short *table = (unsigned short *) - (dmasound.soft.format == AFMT_MU_LAW - ? dmasound_ulaw2dma16 : dmasound_alaw2dma16); - unsigned int data = expand_data; - unsigned int *p = (unsigned int *) &frame[*frameUsed]; - int bal = expand_bal; - int hSpeed = dmasound.hard.speed, sSpeed = dmasound.soft.speed; - int utotal, ftotal; - int stereo = dmasound.soft.stereo; - - frameLeft >>= 2; - if (stereo) - userCount >>= 1; - ftotal = frameLeft; - utotal = userCount; - while (frameLeft) { - u_char c; - if (bal < 0) { - if (userCount == 0) - break; - if (get_user(c, userPtr++)) - return -EFAULT; - data = table[c]; - if (stereo) { - if (get_user(c, userPtr++)) - return -EFAULT; - data = (data << 16) + table[c]; - } else - data = (data << 16) + data; - userCount--; - bal += hSpeed; - } - *p++ = data; - frameLeft--; - bal -= sSpeed; - } - expand_bal = bal; - expand_data = data; - *frameUsed += (ftotal - frameLeft) * 4; - utotal -= userCount; - return stereo? utotal * 2: utotal; -} +/*** AE - TUMBLER START *********************************************************/ -static ssize_t pmac_ctx_s8(const u_char *userPtr, size_t userCount, - u_char frame[], ssize_t *frameUsed, - ssize_t frameLeft) -{ - unsigned int *p = (unsigned int *) &frame[*frameUsed]; - unsigned int data = expand_data; - int bal = expand_bal; - int hSpeed = dmasound.hard.speed, sSpeed = dmasound.soft.speed; - int stereo = dmasound.soft.stereo; - int utotal, ftotal; - - frameLeft >>= 2; - if (stereo) - userCount >>= 1; - ftotal = frameLeft; - utotal = userCount; - while (frameLeft) { - u_char c; - if (bal < 0) { - if (userCount == 0) - break; - if (get_user(c, userPtr++)) - return -EFAULT; - data = c << 8; - if (stereo) { - if (get_user(c, userPtr++)) - return -EFAULT; - data = (data << 16) + (c << 8); - } else - data = (data << 16) + data; - userCount--; - bal += hSpeed; - } - *p++ = data; - frameLeft--; - bal -= sSpeed; - } - expand_bal = bal; - expand_data = data; - *frameUsed += (ftotal - frameLeft) * 4; - utotal -= userCount; - return stereo? utotal * 2: utotal; -} +int gpio_audio_reset, gpio_audio_reset_pol; +int gpio_amp_mute, gpio_amp_mute_pol; +int gpio_headphone_mute, gpio_headphone_mute_pol; +int gpio_headphone_detect, gpio_headphone_detect_pol; +int gpio_headphone_irq; +int +setup_audio_gpio(const char *name, const char* compatible, int *gpio_addr, int* gpio_pol) +{ + struct device_node *np; + u32* pp; + + np = find_devices("gpio"); + if (!np) + return -ENODEV; -static ssize_t pmac_ctx_u8(const u_char *userPtr, size_t userCount, - u_char frame[], ssize_t *frameUsed, - ssize_t frameLeft) -{ - unsigned int *p = (unsigned int *) &frame[*frameUsed]; - unsigned int data = expand_data; - int bal = expand_bal; - int hSpeed = dmasound.hard.speed, sSpeed = dmasound.soft.speed; - int stereo = dmasound.soft.stereo; - int utotal, ftotal; - - frameLeft >>= 2; - if (stereo) - userCount >>= 1; - ftotal = frameLeft; - utotal = userCount; - while (frameLeft) { - u_char c; - if (bal < 0) { - if (userCount == 0) + np = np->child; + while(np != 0) { + if (name) { + char *property = get_property(np,"audio-gpio",NULL); + if (property != 0 && strcmp(property,name) == 0) break; - if (get_user(c, userPtr++)) - return -EFAULT; - data = (c ^ 0x80) << 8; - if (stereo) { - if (get_user(c, userPtr++)) - return -EFAULT; - data = (data << 16) + ((c ^ 0x80) << 8); - } else - data = (data << 16) + data; - userCount--; - bal += hSpeed; - } - *p++ = data; - frameLeft--; - bal -= sSpeed; - } - expand_bal = bal; - expand_data = data; - *frameUsed += (ftotal - frameLeft) * 4; - utotal -= userCount; - return stereo? utotal * 2: utotal; + } else if (compatible && device_is_compatible(np, compatible)) + break; + np = np->sibling; + } + if (!np) + return -ENODEV; + pp = (u32 *)get_property(np, "AAPL,address", NULL); + if (!pp) + return -ENODEV; + *gpio_addr = (*pp) & 0x0000ffff; + pp = (u32 *)get_property(np, "audio-gpio-active-state", NULL); + if (pp) + *gpio_pol = *pp; + else + *gpio_pol = 1; + if (np->n_intrs > 0) + return np->intrs[0].line; + + return 0; } - -static ssize_t pmac_ctx_s16(const u_char *userPtr, size_t userCount, - u_char frame[], ssize_t *frameUsed, - ssize_t frameLeft) -{ - unsigned int *p = (unsigned int *) &frame[*frameUsed]; - unsigned int data = expand_data; - unsigned short *up = (unsigned short *) userPtr; - int bal = expand_bal; - int hSpeed = dmasound.hard.speed, sSpeed = dmasound.soft.speed; - int stereo = dmasound.soft.stereo; - int utotal, ftotal; - - frameLeft >>= 2; - userCount >>= (stereo? 2: 1); - ftotal = frameLeft; - utotal = userCount; - while (frameLeft) { - unsigned short c; - if (bal < 0) { - if (userCount == 0) - break; - if (get_user(data, up++)) - return -EFAULT; - if (stereo) { - if (get_user(c, up++)) - return -EFAULT; - data = (data << 16) + c; - } else - data = (data << 16) + data; - userCount--; - bal += hSpeed; - } - *p++ = data; - frameLeft--; - bal -= sSpeed; - } - expand_bal = bal; - expand_data = data; - *frameUsed += (ftotal - frameLeft) * 4; - utotal -= userCount; - return stereo? utotal * 4: utotal * 2; +static inline void +write_audio_gpio(int gpio_addr, int data) +{ + if (!gpio_addr) + return; + pmac_call_feature(PMAC_FTR_WRITE_GPIO, NULL, gpio_addr, data ? 0x05 : 0x04); } +static inline int +read_audio_gpio(int gpio_addr) +{ + if (!gpio_addr) + return 0; + return ((pmac_call_feature(PMAC_FTR_READ_GPIO, NULL, gpio_addr, 0) & 0x02) !=0); +} -static ssize_t pmac_ctx_u16(const u_char *userPtr, size_t userCount, - u_char frame[], ssize_t *frameUsed, - ssize_t frameLeft) -{ - int mask = (dmasound.soft.format == AFMT_U16_LE? 0x0080: 0x8000); - unsigned int *p = (unsigned int *) &frame[*frameUsed]; - unsigned int data = expand_data; - unsigned short *up = (unsigned short *) userPtr; - int bal = expand_bal; - int hSpeed = dmasound.hard.speed, sSpeed = dmasound.soft.speed; - int stereo = dmasound.soft.stereo; - int utotal, ftotal; - - frameLeft >>= 2; - userCount >>= (stereo? 2: 1); - ftotal = frameLeft; - utotal = userCount; - while (frameLeft) { - unsigned short c; - if (bal < 0) { - if (userCount == 0) - break; - if (get_user(data, up++)) - return -EFAULT; - data ^= mask; - if (stereo) { - if (get_user(c, up++)) - return -EFAULT; - data = (data << 16) + (c ^ mask); - } else - data = (data << 16) + data; - userCount--; - bal += hSpeed; - } - *p++ = data; - frameLeft--; - bal -= sSpeed; - } - expand_bal = bal; - expand_data = data; - *frameUsed += (ftotal - frameLeft) * 4; - utotal -= userCount; - return stereo? utotal * 4: utotal * 2; -} - -static ssize_t pmac_ct_s8_read(const u_char *userPtr, size_t userCount, - u_char frame[], ssize_t *frameUsed, - ssize_t frameLeft) -{ - ssize_t count, used; - short *p = (short *) &frame[*frameUsed]; - int val, stereo = dmasound.soft.stereo; - - frameLeft >>= 2; - if (stereo) - userCount >>= 1; - used = count = min_t(unsigned long, userCount, frameLeft); - while (count > 0) { - u_char data; - - val = *p++; - data = val >> 8; - if (put_user(data, (u_char *)userPtr++)) - return -EFAULT; - if (stereo) { - val = *p; - data = val >> 8; - if (put_user(data, (u_char *)userPtr++)) - return -EFAULT; - } - p++; - count--; - } - *frameUsed += used * 4; - return stereo? used * 2: used; -} - - -static ssize_t pmac_ct_u8_read(const u_char *userPtr, size_t userCount, - u_char frame[], ssize_t *frameUsed, - ssize_t frameLeft) -{ - ssize_t count, used; - short *p = (short *) &frame[*frameUsed]; - int val, stereo = dmasound.soft.stereo; - - frameLeft >>= 2; - if (stereo) - userCount >>= 1; - used = count = min_t(unsigned long, userCount, frameLeft); - while (count > 0) { - u_char data; - - val = *p++; - data = (val >> 8) ^ 0x80; - if (put_user(data, (u_char *)userPtr++)) - return -EFAULT; - if (stereo) { - val = *p; - data = (val >> 8) ^ 0x80; - if (put_user(data, (u_char *)userPtr++)) - return -EFAULT; - } - p++; - count--; - } - *frameUsed += used * 4; - return stereo? used * 2: used; -} - - -static ssize_t pmac_ct_s16_read(const u_char *userPtr, size_t userCount, - u_char frame[], ssize_t *frameUsed, - ssize_t frameLeft) -{ - ssize_t count, used; - int stereo = dmasound.soft.stereo; - short *fp = (short *) &frame[*frameUsed]; - - frameLeft >>= 2; - userCount >>= (stereo? 2: 1); - used = count = min_t(unsigned long, userCount, frameLeft); - if (!stereo) { - short *up = (short *) userPtr; - while (count > 0) { - short data; - data = *fp; - if (put_user(data, up++)) - return -EFAULT; - fp+=2; - count--; - } +static void +headphone_intr(int irq, void *devid, struct pt_regs *regs) +{ + if (read_audio_gpio(gpio_headphone_detect) == gpio_headphone_detect_pol) { + printk(KERN_INFO "Audio jack plugged, muting speakers.\n"); + write_audio_gpio(gpio_amp_mute, gpio_amp_mute_pol); + write_audio_gpio(gpio_headphone_mute, !gpio_headphone_mute_pol); } else { - if (copy_to_user((u_char *)userPtr, fp, count * 4)) - return -EFAULT; + printk(KERN_INFO "Audio jack unplugged, enabling speakers.\n"); + write_audio_gpio(gpio_amp_mute, !gpio_amp_mute_pol); + write_audio_gpio(gpio_headphone_mute, gpio_headphone_mute_pol); } - *frameUsed += used * 4; - return stereo? used * 4: used * 2; } -static ssize_t pmac_ct_u16_read(const u_char *userPtr, size_t userCount, - u_char frame[], ssize_t *frameUsed, - ssize_t frameLeft) -{ - ssize_t count, used; - int mask = (dmasound.soft.format == AFMT_U16_LE? 0x0080: 0x8000); - int stereo = dmasound.soft.stereo; - short *fp = (short *) &frame[*frameUsed]; - short *up = (short *) userPtr; - - frameLeft >>= 2; - userCount >>= (stereo? 2: 1); - used = count = min_t(unsigned long, userCount, frameLeft); - while (count > 0) { - int data; - - data = *fp++; - data ^= mask; - if (put_user(data, up++)) - return -EFAULT; - if (stereo) { - data = *fp; - data ^= mask; - if (put_user(data, up++)) - return -EFAULT; - } - fp++; - count--; - } - *frameUsed += used * 4; - return stereo? used * 4: used * 2; + +/* Initialize tumbler */ + +static int +awacs_tumbler_init(void) +{ + setup_audio_gpio( + "audio-hw-reset", + NULL, + &gpio_audio_reset, + &gpio_audio_reset_pol); + setup_audio_gpio( + "amp-mute", + NULL, + &gpio_amp_mute, + &gpio_amp_mute_pol); + setup_audio_gpio("headphone-mute", + NULL, + &gpio_headphone_mute, + &gpio_headphone_mute_pol); + gpio_headphone_irq = setup_audio_gpio( + "headphone-detect", + NULL, + &gpio_headphone_detect, + &gpio_headphone_detect_pol); + /* Fix some broken OF entries in desktop machines */ + if (!gpio_headphone_irq) + gpio_headphone_irq = setup_audio_gpio( + NULL, + "keywest-gpio15", + &gpio_headphone_detect, + &gpio_headphone_detect_pol); + + write_audio_gpio(gpio_audio_reset, gpio_audio_reset_pol); + wait_ms(100); + write_audio_gpio(gpio_audio_reset, !gpio_audio_reset_pol); + wait_ms(100); + if (gpio_headphone_irq) { + if (request_irq(gpio_headphone_irq,headphone_intr,0,"Headphone detect",0) < 0) { + printk(KERN_ERR "tumbler: Can't request headphone interrupt\n"); + gpio_headphone_irq = 0; + } else { + u8 val; + /* Activate headphone status interrupts */ + val = pmac_call_feature(PMAC_FTR_READ_GPIO, NULL, gpio_headphone_detect, 0); + pmac_call_feature(PMAC_FTR_WRITE_GPIO, NULL, gpio_headphone_detect, val | 0x80); + /* Trigger it */ + headphone_intr(0,0,0); + } + } + if (!gpio_headphone_irq) { + /* Some machine enter this case ? */ + printk(KERN_WARNING "tumbler: Headphone detect IRQ not found, enabling all outputs !\n"); + write_audio_gpio(gpio_amp_mute, !gpio_amp_mute_pol); + write_audio_gpio(gpio_headphone_mute, !gpio_headphone_mute_pol); + } + return 0; } -static TRANS transAwacsNormal = { - ct_ulaw: pmac_ct_law, - ct_alaw: pmac_ct_law, - ct_s8: pmac_ct_s8, - ct_u8: pmac_ct_u8, - ct_s16be: pmac_ct_s16, - ct_u16be: pmac_ct_u16, - ct_s16le: pmac_ct_s16, - ct_u16le: pmac_ct_u16, -}; +static int +awacs_tumbler_cleanup(void) +{ + if (gpio_headphone_irq) + free_irq(gpio_headphone_irq, 0); + return 0; +} -static TRANS transAwacsExpand = { - ct_ulaw: pmac_ctx_law, - ct_alaw: pmac_ctx_law, - ct_s8: pmac_ctx_s8, - ct_u8: pmac_ctx_u8, - ct_s16be: pmac_ctx_s16, - ct_u16be: pmac_ctx_u16, - ct_s16le: pmac_ctx_s16, - ct_u16le: pmac_ctx_u16, -}; -static TRANS transAwacsNormalRead = { - ct_s8: pmac_ct_s8_read, - ct_u8: pmac_ct_u8_read, - ct_s16be: pmac_ct_s16_read, - ct_u16be: pmac_ct_u16_read, - ct_s16le: pmac_ct_s16_read, - ct_u16le: pmac_ct_u16_read, -}; +/*** AE - TUMBLER END *********************************************************/ -/*** Low level stuff *********************************************************/ +/*** Low level stuff *********************************************************/ /* - * PCI PowerMac, with AWACS and DBDMA. + * PCI PowerMac, with AWACS, Screamer, Burgundy, DACA or Tumbler and DBDMA. */ static void PMacOpen(void) @@ -827,9 +501,9 @@ static int __init PMacIrqInit(void) { - if (request_irq(awacs_irq, pmac_awacs_intr, 0, "AWACS", 0) - || request_irq(awacs_tx_irq, pmac_awacs_tx_intr, 0, "AWACS out", 0) - || request_irq(awacs_rx_irq, pmac_awacs_rx_intr, 0, "AWACS in", 0)) + if (request_irq(awacs_irq, pmac_awacs_intr, 0, "Built-in Sound misc", 0) + || request_irq(awacs_tx_irq, pmac_awacs_tx_intr, 0, "Built-in Sound out", 0) + || request_irq(awacs_rx_irq, pmac_awacs_rx_intr, 0, "Built-in Sound in", 0)) return 0; return 1; } @@ -837,25 +511,44 @@ #ifdef MODULE static void PMacIrqCleanup(void) { - /* turn off output dma */ - out_le32(&awacs_txdma->control, RUN<<16); + /* turn off input & output dma */ + DBDMA_DO_STOP(awacs_txdma); + DBDMA_DO_STOP(awacs_rxdma); + /* disable interrupts from awacs interface */ out_le32(&awacs->control, in_le32(&awacs->control) & 0xfff); -#ifdef CONFIG_PMAC_PBOOK - if (is_pbook_G3) { - feature_clear(awacs_node, FEATURE_Sound_power); - feature_clear(awacs_node, FEATURE_Sound_CLK_enable); + + /* Switch off the sound clock */ + pmac_call_feature(PMAC_FTR_SOUND_CHIP_ENABLE, awacs_node, 0, 0); + /* Make sure proper bits are set on pismo & tipb */ + if (machine_is_compatible("PowerBook3,1") || + machine_is_compatible("PowerBook3,2")) { + awacs_reg[1] |= MASK_PAROUT0 | MASK_PAROUT1; + awacs_write(MASK_ADDR1 | awacs_reg[1]); + wait_ms(200); } -#endif free_irq(awacs_irq, 0); free_irq(awacs_tx_irq, 0); free_irq(awacs_rx_irq, 0); - kfree(awacs_tx_cmd_space); + /* all OF versions I've seen use this value */ + iounmap((void *)awacs); + iounmap((void *)awacs_txdma); + iounmap((void *)awacs_rxdma); + + release_OF_resource(awacs_node, 0); + release_OF_resource(awacs_node, 1); + release_OF_resource(awacs_node, 2); + + if (awacs_tx_cmd_space) + kfree(awacs_tx_cmd_space); if (awacs_rx_cmd_space) kfree(awacs_rx_cmd_space); - if (beep_buf) + if (beep_dbdma_cmd_space) + kfree(beep_dbdma_cmd_space); + if (beep_buf) { kfree(beep_buf); - kd_mksound = orig_mksound; + kd_mksound = orig_mksound; + } #ifdef CONFIG_PMAC_PBOOK pmu_unregister_sleep_notifier(&awacs_sleep_notifier); #endif @@ -865,7 +558,32 @@ static void PMacSilence(void) { /* turn off output dma */ - out_le32(&awacs_txdma->control, RUN<<16); + DBDMA_DO_STOP(awacs_txdma); +} + +static int tumbler_freqs[2] = { 48000, 44100 } ; +static int tumbler_freqs_ok[2] = { 1, 1 } ; + +/* don't know what to do really - just have to leave it where + * OF left things +*/ + +static int tumbler_set_frame_rate(void) +{ + dmasound.hard.speed = 44100 ; + awacs_rate_index = 0 ; + return 44100 ; +} + +/* don't know what to do really - just have to leave it where + * OF left things +*/ + +static int daca_set_frame_rate(void) +{ + dmasound.hard.speed = 44100 ; + awacs_rate_index = 0 ; + return 44100 ; } static int awacs_freqs[8] = { @@ -873,59 +591,115 @@ }; static int awacs_freqs_ok[8] = { 1, 1, 1, 1, 1, 1, 1, 1 }; -static void PMacInit(void) +static int awacs_set_frame_rate(int desired, int catch_r) { - int i, tolerance; - - switch (dmasound.soft.format) { - case AFMT_S16_LE: - case AFMT_U16_LE: - dmasound.hard.format = AFMT_S16_LE; - break; - default: - dmasound.hard.format = AFMT_S16_BE; - break; - } - dmasound.hard.stereo = 1; - dmasound.hard.size = 16; - + int tolerance, i = 8 ; /* * If we have a sample rate which is within catchRadius percent * of the requested value, we don't have to expand the samples. * Otherwise choose the next higher rate. - * N.B.: burgundy awacs (iMac and later) only works at 44100 Hz. + * N.B.: burgundy awacs only works at 44100 Hz. */ - i = 8; do { - tolerance = catchRadius * awacs_freqs[--i] / 100; + tolerance = catch_r * awacs_freqs[--i] / 100; if (awacs_freqs_ok[i] && dmasound.soft.speed <= awacs_freqs[i] + tolerance) break; } while (i > 0); - if (dmasound.soft.speed >= awacs_freqs[i] - tolerance) - dmasound.trans_write = &transAwacsNormal; - else - dmasound.trans_write = &transAwacsExpand; - dmasound.trans_read = &transAwacsNormalRead; dmasound.hard.speed = awacs_freqs[i]; awacs_rate_index = i; - /* XXX disable error interrupt on burgundy for now */ - out_le32(&awacs->control, MASK_IEPC | (i << 8) | 0x11 - | (awacs_revision < AWACS_BURGUNDY? MASK_IEE: 0)); + out_le32(&awacs->control, MASK_IEPC | (i << 8) | 0x11 ); awacs_reg[1] = (awacs_reg[1] & ~MASK_SAMPLERATE) | (i << 3); awacs_write(awacs_reg[1] | MASK_ADDR1); - out_le32(&awacs->byteswap, dmasound.hard.format != AFMT_S16_BE); + return dmasound.hard.speed; +} + +static int burgundy_frame_rates = 1 ; +static int burgundy_set_frame_rate(void) +{ +#ifdef DEBUG_DMASOUND +if (burgundy_frame_rates > 1) + printk("dmasound_pmac: warning Burgundy had more than one frame rate\n"); +#endif + awacs_rate_index = 0 ; + awacs_reg[1] = (awacs_reg[1] & ~MASK_SAMPLERATE) ; + /* XXX disable error interrupt on burgundy for now */ + out_le32(&awacs->control, MASK_IEPC | 0 | 0x11 | MASK_IEE); + return 44100 ; +} + +static int set_frame_rate(int desired, int catch_r) +{ + switch (awacs_revision) { + case AWACS_BURGUNDY: + dmasound.hard.speed = + burgundy_set_frame_rate(); + break ; + case AWACS_TUMBLER: + dmasound.hard.speed = + tumbler_set_frame_rate(); + break ; + case AWACS_DACA: + dmasound.hard.speed = + daca_set_frame_rate(); + break ; + default: + dmasound.hard.speed = + awacs_set_frame_rate(desired, catch_r); + break ; + } + return dmasound.hard.speed ; +} - /* We really want to execute a DMA stop command, after the AWACS - * is initialized. - * For reasons I don't understand, it stops the hissing noise - * common to many PowerBook G3 systems (like mine :-). +static void +awacs_recalibrate(void) +{ + /* Sorry for the horrible delays... I hope to get that improved + * by making the whole PM process asynchronous in a future version */ - out_le32(&awacs_txdma->control, (RUN|WAKE|FLUSH|PAUSE) << 16); - st_le16(&beep_dbdma_cmd->command, DBDMA_STOP); - out_le32(&awacs_txdma->cmdptr, virt_to_bus(beep_dbdma_cmd)); - out_le32(&awacs_txdma->control, RUN | (RUN << 16)); + wait_ms(750); + awacs_reg[1] |= MASK_CMUTE | MASK_AMUTE; + awacs_write(awacs_reg[1] | MASK_RECALIBRATE | MASK_ADDR1); + wait_ms(1000); + awacs_write(awacs_reg[1] | MASK_ADDR1); +} + +static void PMacInit(void) +{ + int tolerance; + + switch (dmasound.soft.format) { + case AFMT_S16_LE: + case AFMT_U16_LE: + if (hw_can_byteswap) + dmasound.hard.format = AFMT_S16_LE; + else + dmasound.hard.format = AFMT_S16_BE; + break; + default: + dmasound.hard.format = AFMT_S16_BE; + break; + } + dmasound.hard.stereo = 1; + dmasound.hard.size = 16; + + /* set dmasound.hard.speed - on the basis of what we want (soft) + * and the tolerance we'll allow. + */ + set_frame_rate(dmasound.soft.speed, catchRadius) ; + + tolerance = (catchRadius * dmasound.hard.speed) / 100; + if (dmasound.soft.speed >= dmasound.hard.speed - tolerance) + dmasound.trans_write = &transAwacsNormal; + else + dmasound.trans_write = &transAwacsExpand; + dmasound.trans_read = &transAwacsNormalRead; + + if (hw_can_byteswap && (dmasound.hard.format == AFMT_S16_LE)) + out_le32(&awacs->byteswap, BS_VAL); + else + out_le32(&awacs->byteswap, 0); expand_bal = -dmasound.soft.speed; } @@ -933,7 +707,8 @@ static int PMacSetFormat(int format) { int size; - + int req_format = format; + switch (format) { case AFMT_QUERY: return dmasound.soft.format; @@ -943,10 +718,16 @@ case AFMT_S8: size = 8; break; - case AFMT_S16_BE: - case AFMT_U16_BE: case AFMT_S16_LE: + if(!hw_can_byteswap) + format = AFMT_S16_BE; + case AFMT_S16_BE: + size = 16; + break; case AFMT_U16_LE: + if(!hw_can_byteswap) + format = AFMT_U16_BE; + case AFMT_U16_BE: size = 16; break; default: /* :-) */ @@ -955,16 +736,16 @@ size = 8; format = AFMT_U8; } - - dmasound.soft.format = format; - dmasound.soft.size = size; - if (dmasound.minDev == SND_DEV_DSP) { - dmasound.dsp.format = format; - dmasound.dsp.size = size; + + if (req_format == format) { + dmasound.soft.format = format; + dmasound.soft.size = size; + if (dmasound.minDev == SND_DEV_DSP) { + dmasound.dsp.format = format; + dmasound.dsp.size = size; + } } - PMacInit(); - return format; } @@ -1007,48 +788,91 @@ return awacs_volume_setter(volume, 2, MASK_AMUTE, 6); } -static void PMacPlay(void) +static void __PMacPlay(void) { volatile struct dbdma_cmd *cp; - int i, count; + int next_frg, count; unsigned long flags; + /* CHECK: how much of this *really* needs IRQs masked? */ + save_flags(flags); cli(); + count = 300 ; /* > two cycles at the lowest sample rate */ + + /* what we want to send next */ + next_frg = (write_sq.front + write_sq.active) % write_sq.max_count; + if (awacs_beep_state) { /* sound takes precedence over beeps */ + /* stop the dma channel */ out_le32(&awacs_txdma->control, (RUN|PAUSE|FLUSH|WAKE) << 16); + while ( (in_le32(&awacs_txdma->status) & RUN) && count--) + udelay(1); + /* FIXME: check that this is OK for other chip sets */ out_le32(&awacs->control, (in_le32(&awacs->control) & ~0x1f00) | (awacs_rate_index << 8)); - out_le32(&awacs->byteswap, dmasound.hard.format != AFMT_S16_BE); - out_le32(&awacs_txdma->cmdptr, virt_to_bus(&(awacs_tx_cmds[(write_sq.front+write_sq.active) % write_sq.max_count]))); + + if (hw_can_byteswap && (dmasound.hard.format == AFMT_S16_LE)) + out_le32(&awacs->byteswap, BS_VAL); + else + out_le32(&awacs->byteswap, 0); + out_le32(&awacs_txdma->cmdptr, + virt_to_bus(&(awacs_tx_cmds[next_frg]))); beep_playing = 0; awacs_beep_state = 0; } - i = write_sq.front + write_sq.active; - if (i >= write_sq.max_count) - i -= write_sq.max_count; + /* this won't allow more than two frags to be in the output queue at + once. (or one, if the max frags is 2 - because count can't exceed + 2 in that case) + */ while (write_sq.active < 2 && write_sq.active < write_sq.count) { - count = (write_sq.count == write_sq.active + 1)?write_sq.rear_size:write_sq.block_size; - if (count < write_sq.block_size && !write_sq.syncing) - /* last block not yet filled, and we're not syncing. */ - break; - cp = &awacs_tx_cmds[i]; + count = (write_sq.count == write_sq.active + 1) ? + write_sq.rear_size:write_sq.block_size ; + if (count < write_sq.block_size) { + if (!write_sq.syncing) /* last block not yet filled,*/ + break; /* and we're not syncing or POST-ed */ + else { + /* pretend the block is full to force a new + block to be started on the next write */ + write_sq.rear_size = write_sq.block_size ; + write_sq.syncing &= ~2 ; /* clear POST */ + } + } + cp = &awacs_tx_cmds[next_frg]; st_le16(&cp->req_count, count); st_le16(&cp->xfer_status, 0); - if (++i >= write_sq.max_count) - i = 0; - out_le16(&awacs_tx_cmds[i].command, DBDMA_STOP); - out_le16(&cp->command, OUTPUT_MORE + INTR_ALWAYS); + st_le16(&cp->command, OUTPUT_MORE + INTR_ALWAYS); + /* put a STOP at the end of the queue - but only if we have + space for it. This means that, if we under-run and we only + have two fragments, we might re-play sound from an existing + queued frag. I guess the solution to that is not to set two + frags if you are likely to under-run... + */ + if (write_sq.count < write_sq.max_count) { + if (++next_frg >= write_sq.max_count) + next_frg = 0 ; /* wrap */ + /* if we get here then we've underrun so we will stop*/ + st_le16(&awacs_tx_cmds[next_frg].command, DBDMA_STOP); + } + /* set the dbdma controller going, if it is not already */ if (write_sq.active == 0) out_le32(&awacs_txdma->cmdptr, virt_to_bus(cp)); + (void)in_le32(&awacs_txdma->status); out_le32(&awacs_txdma->control, ((RUN|WAKE) << 16) + (RUN|WAKE)); ++write_sq.active; } restore_flags(flags); } +static void PMacPlay(void) +{ + LOCK(); + if (!awacs_sleeping) + __PMacPlay(); + UNLOCK(); +} static void PMacRecord(void) { @@ -1067,6 +891,26 @@ restore_flags(flags); } +/* if the TX status comes up "DEAD" - reported on some Power Computing machines + we need to re-start the dbdma - but from a different physical start address + and with a different transfer length. It would get very messy to do this + with the normal dbdma_cmd blocks - we would have to re-write the buffer start + addresses each time. So, we will keep a single dbdma_cmd block which can be + fiddled with. + When DEAD status is first reported the content of the faulted dbdma block is + copied into the emergency buffer and we note that the buffer is in use. + we then bump the start physical address by the amount that was successfully + output before it died. + On any subsequent DEAD result we just do the bump-ups (we know that we are + already using the emergency dbdma_cmd). + CHECK: this just tries to "do it". It is possible that we should abandon + xfers when the number of residual bytes gets below a certain value - I can + see that this might cause a loop-forever if too small a transfer causes + DEAD status. However this is a TODO for now - we'll see what gets reported. + When we get a successful transfer result with the emergency buffer we just + pretend that it completed using the original dmdma_cmd and carry on. The + 'next_cmd' field will already point back to the original loop of blocks. +*/ static void pmac_awacs_tx_intr(int irq, void *devid, struct pt_regs *regs) @@ -1074,35 +918,92 @@ int i = write_sq.front; int stat; volatile struct dbdma_cmd *cp; + /* != 0 when we are dealing with a DEAD xfer */ + static int emergency_in_use = 0 ; - while (write_sq.active > 0) { - cp = &awacs_tx_cmds[i]; + while (write_sq.active > 0) { /* we expect to have done something*/ + if (emergency_in_use) /* we are dealing with DEAD xfer */ + cp = emergency_dbdma_cmd ; + else + cp = &awacs_tx_cmds[i]; stat = ld_le16(&cp->xfer_status); + if (stat & DEAD) { + unsigned short req, res ; + unsigned int phy ; +#ifdef DEBUG_DMASOUND +printk("dmasound_pmac: tx-irq: xfer died - patching it up...\n") ; +#endif + /* to clear DEAD status we must first clear RUN + set it to quiescent to be on the safe side */ + (void)in_le32(&awacs_txdma->status); + out_le32(&awacs_txdma->control, + (RUN|PAUSE|FLUSH|WAKE) << 16); + write_sq.died++ ; + if (!emergency_in_use) { /* new problem */ + memcpy((void *)emergency_dbdma_cmd, (void *)cp, + sizeof(struct dbdma_cmd)); + emergency_in_use = 1; + cp = emergency_dbdma_cmd; + } + /* now bump the values to reflect the amount + we haven't yet shifted */ + req = ld_le16(&cp->req_count); + res = ld_le16(&cp->res_count); + phy = ld_le32(&cp->phy_addr); + phy += (req - res); + st_le16(&cp->req_count, res); + st_le16(&cp->res_count, 0); + st_le16(&cp->xfer_status, 0); + st_le32(&cp->phy_addr, phy); + st_le16(&cp->command, OUTPUT_MORE + INTR_ALWAYS); + /* point at our patched up command block */ + out_le32(&awacs_txdma->cmdptr, virt_to_bus(cp)); + /* we must re-start the controller */ + (void)in_le32(&awacs_txdma->status); + /* should complete clearing the DEAD status */ + out_le32(&awacs_txdma->control, + ((RUN|WAKE) << 16) + (RUN|WAKE)); + break; /* this block is still going */ + } if ((stat & ACTIVE) == 0) break; /* this frame is still going */ + if (emergency_in_use) + emergency_in_use = 0 ; /* done that */ --write_sq.count; --write_sq.active; if (++i >= write_sq.max_count) i = 0; } + + /* if we stopped and we were not sync-ing - then we under-ran */ + if( write_sq.syncing == 0 ){ + stat = in_le32(&awacs_txdma->status) ; + /* we hit the dbdma_stop */ + if( (stat & ACTIVE) == 0 ) write_sq.xruns++ ; + } + + /* if we used some data up then wake the writer to supply some more*/ if (i != write_sq.front) WAKE_UP(write_sq.action_queue); write_sq.front = i; - PMacPlay(); - - if (!write_sq.active) - WAKE_UP(write_sq.sync_queue); + /* but make sure we funnel what we've already got */\ + if (!awacs_sleeping) + __PMacPlay(); + + /* make the wake-on-empty conditional on syncing */ + if (!write_sq.active && (write_sq.syncing & 1)) + WAKE_UP(write_sq.sync_queue); /* any time we're empty */ } static void pmac_awacs_rx_intr(int irq, void *devid, struct pt_regs *regs) { - + int stat ; /* For some reason on my PowerBook G3, I get one interrupt * when the interrupt vector is installed (like something is - * pending). This happens before the dbdma is initialize by + * pending). This happens before the dbdma is initialized by * us, so I just check the command pointer and if it is zero, * just blow it off. */ @@ -1118,8 +1019,35 @@ * interrupt processing for a long time. Geeze, I really hope * this doesn't happen. */ - while (awacs_rx_cmds[read_sq.rear].xfer_status) { + while ((stat=awacs_rx_cmds[read_sq.rear].xfer_status)) { + /* if we got a "DEAD" status then just log it for now. + and try to restart dma. + TODO: figure out how best to fix it up + */ + if (stat & DEAD){ +#ifdef DEBUG_DMASOUND +printk("dmasound_pmac: rx-irq: DIED - attempting resurection\n"); +#endif + /* to clear DEAD status we must first clear RUN + set it to quiescent to be on the safe side */ + (void)in_le32(&awacs_txdma->status); + out_le32(&awacs_txdma->control, + (RUN|PAUSE|FLUSH|WAKE) << 16); + awacs_rx_cmds[read_sq.rear].xfer_status = 0; + awacs_rx_cmds[read_sq.rear].res_count = 0; + read_sq.died++ ; + (void)in_le32(&awacs_txdma->status); + /* re-start the same block */ + out_le32(&awacs_rxdma->cmdptr, + virt_to_bus(&awacs_rx_cmds[read_sq.rear])); + /* we must re-start the controller */ + (void)in_le32(&awacs_rxdma->status); + /* should complete clearing the DEAD status */ + out_le32(&awacs_rxdma->control, + ((RUN|WAKE) << 16) + (RUN|WAKE)); + return; /* try this block again */ + } /* Clear status and move on to next buffer. */ awacs_rx_cmds[read_sq.rear].xfer_status = 0; @@ -1138,6 +1066,7 @@ */ if (read_sq.rear == read_sq.front) { read_sq.front++; + read_sq.xruns++ ; /* we overan */ if (read_sq.front >= read_sq.max_active) read_sq.front = 0; } @@ -1157,8 +1086,9 @@ } if (ctrl & MASK_CNTLERR) { int err = (in_le32(&awacs->codec_stat) & MASK_ERRCODE) >> 16; - if (err != 0 && awacs_revision < AWACS_BURGUNDY) - printk(KERN_ERR "AWACS: error %x\n", err); + /* CHECK: we just swallow burgundy errors at the moment..*/ + if (err != 0 && awacs_revision != AWACS_BURGUNDY) + printk(KERN_ERR "dmasound_pmac: error %x\n", err); } /* Writing 1s to the CNTLERR and PORTCHG bits clears them... */ out_le32(&awacs->control, ctrl); @@ -1167,25 +1097,38 @@ static void awacs_write(int val) { - if (awacs_revision >= AWACS_BURGUNDY) - return; - while (in_le32(&awacs->codec_ctrl) & MASK_NEWECMD) - ; /* XXX should have timeout */ + int count = 300 ; + if (awacs_revision >= AWACS_DACA) + return ; + + while ((in_le32(&awacs->codec_ctrl) & MASK_NEWECMD) && count--) + udelay(1) ; /* timeout is > 2 samples at lowest rate */ out_le32(&awacs->codec_ctrl, val | (awacs_subframe << 22)); + (void)in_le32(&awacs->byteswap); } +/* this is called when the beep timer expires... it will be called even + if the beep has been overidden by other sound output. +*/ static void awacs_nosound(unsigned long xx) { unsigned long flags; + int count = 600 ; /* > four samples at lowest rate */ save_flags(flags); cli(); if (beep_playing) { st_le16(&beep_dbdma_cmd->command, DBDMA_STOP); out_le32(&awacs_txdma->control, (RUN|PAUSE|FLUSH|WAKE) << 16); + while ((in_le32(&awacs_txdma->status) & RUN) && count--) + udelay(1); + /* FIXME: check this is OK for DACA, Tumbler */ out_le32(&awacs->control, (in_le32(&awacs->control) & ~0x1f00) | (awacs_rate_index << 8)); - out_le32(&awacs->byteswap, dmasound.hard.format != AFMT_S16_BE); + if (hw_can_byteswap && (dmasound.hard.format == AFMT_S16_LE)) + out_le32(&awacs->byteswap, BS_VAL); + else + out_le32(&awacs->byteswap, 0); beep_playing = 0; } restore_flags(flags); @@ -1195,6 +1138,11 @@ function: awacs_nosound }; +/* we generate the beep with a single dbdma command that loops a buffer + forever - without generating interrupts. + So, to stop it you have to stop dma output as per awacs_nosound. +*/ + static void awacs_mksound(unsigned int hz, unsigned int ticks) { unsigned long flags; @@ -1207,11 +1155,19 @@ static int beep_nsamples_cache; static int beep_volume_cache; - for (i = 0; i < 8 && awacs_freqs[i] >= BEEP_SRATE; ++i) - if (awacs_freqs_ok[i]) - beep_speed = i; - srate = awacs_freqs[beep_speed]; + if (beep_buf == NULL) + return; + + /* quick-hack fix for DACA, Burgundy & Tumbler */ + if (awacs_revision >= AWACS_DACA){ + srate = 44100 ; + } else { + for (i = 0; i < 8 && awacs_freqs[i] >= BEEP_SRATE; ++i) + if (awacs_freqs_ok[i]) + beep_speed = i; + srate = awacs_freqs[beep_speed]; + } if (hz <= srate / BEEP_BUFLEN || hz > srate / 2) { #if 1 /* this is a hack for broken X server code */ @@ -1237,7 +1193,7 @@ st_le16(&beep_dbdma_cmd->command, OUTPUT_MORE + BR_ALWAYS); restore_flags(flags); - if (hz == beep_hz_cache && beep_volume == beep_volume_cache) { + if (hz == beep_hz_cache && beep_vol == beep_volume_cache) { nsamples = beep_nsamples_cache; } else { period = srate * 256 / hz; /* fixed point */ @@ -1247,11 +1203,11 @@ j = 0; p = beep_buf; for (i = 0; i < nsamples; ++i, p += 2) { - p[0] = p[1] = beep_wform[j >> 8] * beep_volume; + p[0] = p[1] = beep_wform[j >> 8] * beep_vol; j = (j + f) & 0xffff; } beep_hz_cache = hz; - beep_volume_cache = beep_volume; + beep_volume_cache = beep_vol; beep_nsamples_cache = nsamples; } @@ -1263,78 +1219,157 @@ save_flags(flags); cli(); if (beep_playing) { /* i.e. haven't been terminated already */ + int count = 300 ; out_le32(&awacs_txdma->control, (RUN|WAKE|FLUSH|PAUSE) << 16); + while ((in_le32(&awacs_txdma->status) & RUN) && count--) + udelay(1); /* timeout > 2 samples at lowest rate*/ + /* FIXME: check this is OK on DACA, Tumbler */ out_le32(&awacs->control, (in_le32(&awacs->control) & ~0x1f00) | (beep_speed << 8)); - out_le32(&awacs->byteswap, 0); + out_le32(&awacs->byteswap, 0); /* force BE */ out_le32(&awacs_txdma->cmdptr, virt_to_bus(beep_dbdma_cmd)); + (void)in_le32(&awacs_txdma->status); out_le32(&awacs_txdma->control, RUN | (RUN << 16)); } restore_flags(flags); } +/* used in init and for wake-up */ + +static void +load_awacs(void) +{ + awacs_write(awacs_reg[0] + MASK_ADDR0); + awacs_write(awacs_reg[1] + MASK_ADDR1); + awacs_write(awacs_reg[2] + MASK_ADDR2); + awacs_write(awacs_reg[4] + MASK_ADDR4); + + if (awacs_revision == AWACS_SCREAMER) { + awacs_write(awacs_reg[5] + MASK_ADDR5); + wait_ms(100); + awacs_write(awacs_reg[6] + MASK_ADDR6); + wait_ms(2); + awacs_write(awacs_reg[1] + MASK_ADDR1); + awacs_write(awacs_reg[7] + MASK_ADDR7); + } + if (hw_can_byteswap && (dmasound.hard.format == AFMT_S16_LE)) + out_le32(&awacs->byteswap, BS_VAL); + else + out_le32(&awacs->byteswap, 0); +} + #ifdef CONFIG_PMAC_PBOOK /* * Save state when going to sleep, restore it afterwards. */ +/* FIXME: sort out disabling/re-enabling of read stuff as well */ static int awacs_sleep_notify(struct pmu_sleep_notifier *self, int when) { switch (when) { - case PBOOK_SLEEP_NOW: - /* XXX we should stop any dma in progress when going to sleep - and restart it when we wake. */ + case PBOOK_SLEEP_NOW: + LOCK(); + awacs_sleeping = 1; + /* Tell the rest of the driver we are now going to sleep */ + mb(); + if (awacs_revision == AWACS_SCREAMER || + awacs_revision == AWACS_AWACS) { + awacs_reg1_save = awacs_reg[1]; + awacs_reg[1] |= MASK_AMUTE | MASK_CMUTE; + awacs_write(MASK_ADDR1 | awacs_reg[1]); + } + PMacSilence(); + /* stop rx - if going - a bit of a daft user... but */ + out_le32(&awacs_rxdma->control, (RUN|WAKE|FLUSH << 16)); + /* deny interrupts */ + switch (awacs_revision) { + case AWACS_TUMBLER: + break ; /* dont know how yet */ + case AWACS_DACA: + daca_enter_sleep(); + break ; + case AWACS_BURGUNDY: + break ; + case AWACS_SCREAMER: + case AWACS_AWACS: + default: + out_le32(&awacs->control, 0x11) ; + break ; + } disable_irq(awacs_irq); disable_irq(awacs_tx_irq); - if (is_pbook_G3) { - feature_clear(awacs_node, FEATURE_Sound_CLK_enable); - feature_clear(awacs_node, FEATURE_Sound_power); + disable_irq(awacs_rx_irq); + /* Disable sound clock */ + pmac_call_feature(PMAC_FTR_SOUND_CHIP_ENABLE, awacs_node, 0, 0); + /* According to Darwin, we do that after turning off the sound + * chip clock. All this will have to be cleaned up once we properly + * parse the OF sound-objects + */ + if (machine_is_compatible("PowerBook3,1") || + machine_is_compatible("PowerBook3,2")) { + awacs_reg[1] |= MASK_PAROUT0 | MASK_PAROUT1; + awacs_write(MASK_ADDR1 | awacs_reg[1]); + wait_ms(200); } break; case PBOOK_WAKE: - /* There is still a problem on wake. Sound seems to work fine - if I launch mpg123 and resumes fine if mpg123 was playing, - but the console beep is dead until I do something with the - mixer. Probably yet another timing issue */ - if (!feature_test(awacs_node, FEATURE_Sound_CLK_enable) - || !feature_test(awacs_node, FEATURE_Sound_power)) { - /* these aren't present on the 3400 AFAIK -- paulus */ - feature_set(awacs_node, FEATURE_Sound_CLK_enable); - feature_set(awacs_node, FEATURE_Sound_power); - mdelay(1000); - } - out_le32(&awacs->control, MASK_IEPC - | (awacs_rate_index << 8) | 0x11 - | (awacs_revision < AWACS_BURGUNDY? MASK_IEE: 0)); - awacs_write(awacs_reg[0] | MASK_ADDR0); - awacs_write(awacs_reg[1] | MASK_ADDR1); - awacs_write(awacs_reg[2] | MASK_ADDR2); - awacs_write(awacs_reg[4] | MASK_ADDR4); - if (awacs_is_screamer) { - awacs_write(awacs_reg[5] + MASK_ADDR5); - awacs_write(awacs_reg[6] + MASK_ADDR6); - awacs_write(awacs_reg[7] + MASK_ADDR7); - } - out_le32(&awacs->byteswap, dmasound.hard.format != AFMT_S16_BE); + /* Enable sound clock */ + pmac_call_feature(PMAC_FTR_SOUND_CHIP_ENABLE, awacs_node, 0, 1); + if (machine_is_compatible("PowerBook3,1") || + machine_is_compatible("PowerBook3,2")) { + wait_ms(100); + awacs_reg[1] &= ~(MASK_PAROUT0 | MASK_PAROUT1); + awacs_write(MASK_ADDR1 | awacs_reg[1]); + wait_ms(300); + } else + wait_ms(1000); + /* restore settings */ + switch (awacs_revision) { + case AWACS_TUMBLER: + headphone_intr(0,0,0); + break; + case AWACS_DACA: + wait_ms(10); /* Check this !!! */ + daca_leave_sleep(); + break ; /* dont know how yet */ + case AWACS_BURGUNDY: + break ; + case AWACS_SCREAMER: + case AWACS_AWACS: + default: + load_awacs() ; + break ; + } + /* Recalibrate chip */ + if (awacs_revision == AWACS_SCREAMER) + awacs_recalibrate(); + /* Make sure dma is stopped */ + PMacSilence(); enable_irq(awacs_irq); enable_irq(awacs_tx_irq); - if (awacs_revision == 3) { - mdelay(100); - awacs_write(0x6000); - mdelay(2); - awacs_write(awacs_reg[1] | MASK_ADDR1); - } - /* enable CD sound input */ - if (macio_base && is_pbook_G3) { + enable_irq(awacs_rx_irq); + /* OK, allow ints back again */ + out_le32(&awacs->control, MASK_IEPC + | (awacs_rate_index << 8) | 0x11 + | (awacs_revision < AWACS_DACA ? MASK_IEE: 0)); + if (macio_base && is_pbook_g3) { + /* FIXME: should restore the setup we had...*/ out_8(macio_base + 0x37, 3); - } else if (is_pbook_3400) { - feature_set(awacs_node, FEATURE_IOBUS_enable); - udelay(10); + } else if (is_pbook_3X00) { in_8(latch_base + 0x190); } + /* Remove mute */ + if (awacs_revision == AWACS_SCREAMER || + awacs_revision == AWACS_AWACS) { + awacs_reg[1] = awacs_reg1_save; + awacs_write(MASK_ADDR1 | awacs_reg[1]); + } + awacs_sleeping = 0; /* Resume pending sounds. */ - PMacPlay(); + /* we don't try to restart input... */ + __PMacPlay(); + UNLOCK(); } return PBOOK_SLEEP_OK; } @@ -1347,17 +1382,20 @@ inline static void awacs_burgundy_busy_wait(void) { - while (in_le32(&awacs->codec_ctrl) & MASK_NEWECMD) - ; + int count = 50; /* > 2 samples at 44k1 */ + while ((in_le32(&awacs->codec_ctrl) & MASK_NEWECMD) && count--) + udelay(1) ; } inline static void awacs_burgundy_extend_wait(void) { - while (!(in_le32(&awacs->codec_stat) & MASK_EXTEND)) - ; - while (in_le32(&awacs->codec_stat) & MASK_EXTEND) - ; + int count = 50 ; /* > 2 samples at 44k1 */ + while ((!(in_le32(&awacs->codec_stat) & MASK_EXTEND)) && count--) + udelay(1) ; + count = 50; + while ((in_le32(&awacs->codec_stat) & MASK_EXTEND) && count--) + udelay(1); } static void @@ -1447,7 +1485,7 @@ awacs_burgundy_init(void) { if (awacs_burgundy_check()) { - printk(KERN_WARNING "AWACS: disabled by MacOS :-(\n"); + printk(KERN_WARNING "dmasound_pmac: burgundy not working :-(\n"); return 1; } @@ -1515,9 +1553,6 @@ return softvolume > 0 ? softvolume : 0; } - - - static int awacs_burgundy_read_mvolume(unsigned address) { @@ -1533,7 +1568,6 @@ return lvolume + (rvolume << 8); } - static void awacs_burgundy_write_mvolume(unsigned address, int volume) { @@ -1550,21 +1584,23 @@ /* End burgundy functions */ +/* Set up output volumes on machines with the 'perch/whisper' extension card. + * this has an SGS i2c chip (7433) which is accessed using the cuda. + * + * TODO: split this out and make use of the other parts of the SGS chip to + * do Bass, Treble etc. + */ - - - -/* Turn on sound output, needed on G3 desktop powermacs */ static void awacs_enable_amp(int spkr_vol) { +#ifdef CONFIG_ADB_CUDA struct adb_request req; awacs_spkr_vol = spkr_vol; if (sys_ctrler != SYS_CTRLER_CUDA) return; -#ifdef CONFIG_ADB_CUDA /* turn on headphones */ cuda_request(&req, NULL, 5, CUDA_PACKET, CUDA_GET_SET_IIC, 0x8a, 4, 0); @@ -1595,146 +1631,229 @@ * /dev/mixer abstraction */ -static int awacs_mixer_ioctl(u_int cmd, u_long arg) +static void do_line_lev(int data) { - int data; - - switch (cmd) { - case SOUND_MIXER_READ_DEVMASK: - data = SOUND_MASK_VOLUME | SOUND_MASK_SPEAKER - | SOUND_MASK_LINE | SOUND_MASK_MIC - | SOUND_MASK_CD | SOUND_MASK_RECLEV - | SOUND_MASK_ALTPCM - | SOUND_MASK_MONITOR; - return IOCTL_OUT(arg, data); - case SOUND_MIXER_READ_RECMASK: - data = SOUND_MASK_LINE | SOUND_MASK_MIC - | SOUND_MASK_CD; - return IOCTL_OUT(arg, data); - case SOUND_MIXER_READ_RECSRC: - data = 0; - if (awacs_reg[0] & MASK_MUX_AUDIN) - data |= SOUND_MASK_LINE; - if (awacs_reg[0] & MASK_MUX_MIC) - data |= SOUND_MASK_MIC; - if (awacs_reg[0] & MASK_MUX_CD) - data |= SOUND_MASK_CD; - if (awacs_reg[1] & MASK_LOOPTHRU) - data |= SOUND_MASK_MONITOR; - return IOCTL_OUT(arg, data); - case SOUND_MIXER_WRITE_RECSRC: - IOCTL_IN(arg, data); - data &= (SOUND_MASK_LINE - | SOUND_MASK_MIC | SOUND_MASK_CD - | SOUND_MASK_MONITOR); - awacs_reg[0] &= ~(MASK_MUX_CD | MASK_MUX_MIC - | MASK_MUX_AUDIN); - awacs_reg[1] &= ~MASK_LOOPTHRU; - if (data & SOUND_MASK_LINE) + line_lev = data ; + awacs_reg[0] &= ~MASK_MUX_AUDIN; + if ((data & 0xff) >= 50) awacs_reg[0] |= MASK_MUX_AUDIN; - if (data & SOUND_MASK_MIC) - awacs_reg[0] |= MASK_MUX_MIC; - if (data & SOUND_MASK_CD) - awacs_reg[0] |= MASK_MUX_CD; - if (data & SOUND_MASK_MONITOR) + awacs_write(MASK_ADDR0 | awacs_reg[0]); +} + +static void do_ip_gain(int data) +{ + ip_gain = data ; + data &= 0xff; + awacs_reg[0] &= ~MASK_GAINLINE; + if (awacs_revision == AWACS_SCREAMER) { + awacs_reg[6] &= ~MASK_MIC_BOOST ; + if (data >= 33) { + awacs_reg[0] |= MASK_GAINLINE; + if( data >= 66) + awacs_reg[6] |= MASK_MIC_BOOST ; + } + awacs_write(MASK_ADDR6 | awacs_reg[6]) ; + } else { + if (data >= 50) + awacs_reg[0] |= MASK_GAINLINE; + } + awacs_write(MASK_ADDR0 | awacs_reg[0]); +} + +static void do_mic_lev(int data) +{ + mic_lev = data ; + data &= 0xff; + awacs_reg[0] &= ~MASK_MUX_MIC; + if (data >= 50) + awacs_reg[0] |= MASK_MUX_MIC; + awacs_write(MASK_ADDR0 | awacs_reg[0]); +} + +static void do_cd_lev(int data) +{ + cd_lev = data ; + awacs_reg[0] &= ~MASK_MUX_CD; + if ((data & 0xff) >= 50) + awacs_reg[0] |= MASK_MUX_CD; + awacs_write(MASK_ADDR0 | awacs_reg[0]); +} + +static void do_rec_lev(int data) +{ + int left, right ; + rec_lev = data ; + /* need to fudge this to use the volume setter routine */ + left = 100 - (data & 0xff) ; if( left < 0 ) left = 0 ; + right = 100 - ((data >> 8) & 0xff) ; if( right < 0 ) right = 0 ; + left |= (right << 8 ); + left = awacs_volume_setter(left, 0, 0, 4); +} + +static void do_passthru_vol(int data) +{ + passthru_vol = data ; + awacs_reg[1] &= ~MASK_LOOPTHRU; + if (awacs_revision == AWACS_SCREAMER) { + if( data ) { /* switch it on for non-zero */ awacs_reg[1] |= MASK_LOOPTHRU; + awacs_write(MASK_ADDR1 | awacs_reg[1]); + } + data = awacs_volume_setter(data, 5, 0, 6) ; + } else { + if ((data & 0xff) >= 50) + awacs_reg[1] |= MASK_LOOPTHRU; + awacs_write(MASK_ADDR1 | awacs_reg[1]); + data = (awacs_reg[1] & MASK_LOOPTHRU)? 100: 0; + } +} + +static int awacs_mixer_ioctl(u_int cmd, u_long arg) +{ + int data; + int rc; + + switch (cmd) { + case SOUND_MIXER_READ_CAPS: + /* say we will allow multiple inputs? prob. wrong + so I'm switching it to single */ + return IOCTL_OUT(arg, 1); + case SOUND_MIXER_READ_DEVMASK: + data = SOUND_MASK_VOLUME | SOUND_MASK_SPEAKER + | SOUND_MASK_LINE | SOUND_MASK_MIC | SOUND_MASK_CD + | SOUND_MASK_IGAIN | SOUND_MASK_RECLEV + | SOUND_MASK_ALTPCM + | SOUND_MASK_MONITOR; + rc = IOCTL_OUT(arg, data); + break; + case SOUND_MIXER_READ_RECMASK: + data = SOUND_MASK_LINE | SOUND_MASK_MIC | SOUND_MASK_CD; + rc = IOCTL_OUT(arg, data); + break; + case SOUND_MIXER_READ_RECSRC: + data = 0; + if (awacs_reg[0] & MASK_MUX_AUDIN) + data |= SOUND_MASK_LINE; + if (awacs_reg[0] & MASK_MUX_MIC) + data |= SOUND_MASK_MIC; + if (awacs_reg[0] & MASK_MUX_CD) + data |= SOUND_MASK_CD; + rc = IOCTL_OUT(arg, data); + break; + case SOUND_MIXER_WRITE_RECSRC: + IOCTL_IN(arg, data); + data &= (SOUND_MASK_LINE | SOUND_MASK_MIC | SOUND_MASK_CD); + awacs_reg[0] &= ~(MASK_MUX_CD | MASK_MUX_MIC + | MASK_MUX_AUDIN); + if (data & SOUND_MASK_LINE) + awacs_reg[0] |= MASK_MUX_AUDIN; + if (data & SOUND_MASK_MIC) + awacs_reg[0] |= MASK_MUX_MIC; + if (data & SOUND_MASK_CD) + awacs_reg[0] |= MASK_MUX_CD; awacs_write(awacs_reg[0] | MASK_ADDR0); - awacs_write(awacs_reg[1] | MASK_ADDR1); - return IOCTL_OUT(arg, data); + rc = IOCTL_OUT(arg, data); + break; case SOUND_MIXER_READ_STEREODEVS: - data = SOUND_MASK_VOLUME | SOUND_MASK_SPEAKER - | SOUND_MASK_RECLEV; - return IOCTL_OUT(arg, data); - case SOUND_MIXER_READ_CAPS: - return IOCTL_OUT(arg, 0); - case SOUND_MIXER_READ_VOLUME: - data = (awacs_reg[1] & MASK_AMUTE)? 0: - awacs_get_volume(awacs_reg[2], 6); - return IOCTL_OUT(arg, data); + data = SOUND_MASK_VOLUME | SOUND_MASK_SPEAKER| SOUND_MASK_RECLEV ; + if (awacs_revision == AWACS_SCREAMER) + data |= SOUND_MASK_MONITOR ; + rc = IOCTL_OUT(arg, data); + break; case SOUND_MIXER_WRITE_VOLUME: IOCTL_IN(arg, data); - return IOCTL_OUT(arg, PMacSetVolume(data)); - case SOUND_MIXER_READ_SPEAKER: - if (awacs_revision == 3 - && sys_ctrler == SYS_CTRLER_CUDA) - data = awacs_spkr_vol; - else - data = (awacs_reg[1] & MASK_CMUTE)? 0: - awacs_get_volume(awacs_reg[4], 6); - return IOCTL_OUT(arg, data); + line_vol = data ; + awacs_volume_setter(data, 2, 0, 6); + /* fall through */ + case SOUND_MIXER_READ_VOLUME: + rc = IOCTL_OUT(arg, line_vol); + break; case SOUND_MIXER_WRITE_SPEAKER: IOCTL_IN(arg, data); - if (awacs_revision == 3 - && sys_ctrler == SYS_CTRLER_CUDA) + spk_vol = data ; + if (has_perch) awacs_enable_amp(data); else - data = awacs_volume_setter(data, 4, MASK_CMUTE, 6); - return IOCTL_OUT(arg, data); + (void)awacs_volume_setter(data, 4, MASK_CMUTE, 6); + /* fall though */ + case SOUND_MIXER_READ_SPEAKER: + rc = IOCTL_OUT(arg, spk_vol); + break; case SOUND_MIXER_WRITE_ALTPCM: /* really bell volume */ IOCTL_IN(arg, data); - beep_volume = data & 0xff; - /* fall through */ + beep_vol = data & 0xff; + /* fall through */ case SOUND_MIXER_READ_ALTPCM: - return IOCTL_OUT(arg, beep_volume); + rc = IOCTL_OUT(arg, beep_vol); + break; case SOUND_MIXER_WRITE_LINE: IOCTL_IN(arg, data); - awacs_reg[0] &= ~MASK_MUX_AUDIN; - if ((data & 0xff) >= 50) - awacs_reg[0] |= MASK_MUX_AUDIN; - awacs_write(MASK_ADDR0 | awacs_reg[0]); - /* fall through */ + do_line_lev(data) ; + /* fall through */ case SOUND_MIXER_READ_LINE: - data = (awacs_reg[0] & MASK_MUX_AUDIN)? 100: 0; - return IOCTL_OUT(arg, data); + rc = IOCTL_OUT(arg, line_lev); + break; + case SOUND_MIXER_WRITE_IGAIN: + IOCTL_IN(arg, data); + do_ip_gain(data) ; + /* fall through */ + case SOUND_MIXER_READ_IGAIN: + rc = IOCTL_OUT(arg, ip_gain); + break; case SOUND_MIXER_WRITE_MIC: IOCTL_IN(arg, data); - data &= 0xff; - awacs_reg[0] &= ~(MASK_MUX_MIC | MASK_GAINLINE); - if (data >= 25) { - awacs_reg[0] |= MASK_MUX_MIC; - if (data >= 75) - awacs_reg[0] |= MASK_GAINLINE; - } - awacs_write(MASK_ADDR0 | awacs_reg[0]); - /* fall through */ + do_mic_lev(data); + /* fall through */ case SOUND_MIXER_READ_MIC: - data = (awacs_reg[0] & MASK_MUX_MIC)? - (awacs_reg[0] & MASK_GAINLINE? 100: 50): 0; - return IOCTL_OUT(arg, data); + rc = IOCTL_OUT(arg, mic_lev); + break; case SOUND_MIXER_WRITE_CD: IOCTL_IN(arg, data); - awacs_reg[0] &= ~MASK_MUX_CD; - if ((data & 0xff) >= 50) - awacs_reg[0] |= MASK_MUX_CD; - awacs_write(MASK_ADDR0 | awacs_reg[0]); - /* fall through */ + do_cd_lev(data); + /* fall through */ case SOUND_MIXER_READ_CD: - data = (awacs_reg[0] & MASK_MUX_CD)? 100: 0; - return IOCTL_OUT(arg, data); + rc = IOCTL_OUT(arg, cd_lev); + break; case SOUND_MIXER_WRITE_RECLEV: IOCTL_IN(arg, data); - data = awacs_volume_setter(data, 0, 0, 4); - return IOCTL_OUT(arg, data); + do_rec_lev(data) ; + /* fall through */ case SOUND_MIXER_READ_RECLEV: - data = awacs_get_volume(awacs_reg[0], 4); - return IOCTL_OUT(arg, data); + rc = IOCTL_OUT(arg, rec_lev); + break; case MIXER_WRITE(SOUND_MIXER_MONITOR): IOCTL_IN(arg, data); - awacs_reg[1] &= ~MASK_LOOPTHRU; - if ((data & 0xff) >= 50) - awacs_reg[1] |= MASK_LOOPTHRU; - awacs_write(MASK_ADDR1 | awacs_reg[1]); + do_passthru_vol(data) ; /* fall through */ case MIXER_READ(SOUND_MIXER_MONITOR): - data = (awacs_reg[1] & MASK_LOOPTHRU)? 100: 0; - return IOCTL_OUT(arg, data); + rc = IOCTL_OUT(arg, passthru_vol); + break; + default: + rc = -EINVAL; } - return -EINVAL; + + return rc; +} + +static void awacs_mixer_init(void) +{ + awacs_volume_setter(line_vol, 2, 0, 6); + if (has_perch) + awacs_enable_amp(spk_vol); + else + (void)awacs_volume_setter(spk_vol, 4, MASK_CMUTE, 6); + do_line_lev(line_lev) ; + do_ip_gain(ip_gain) ; + do_mic_lev(mic_lev) ; + do_cd_lev(cd_lev) ; + do_rec_lev(rec_lev) ; + do_passthru_vol(passthru_vol) ; } static int burgundy_mixer_ioctl(u_int cmd, u_long arg) { int data; + int rc; /* We are, we are, we are... Burgundy or better */ switch(cmd) { @@ -1742,11 +1861,13 @@ data = SOUND_MASK_VOLUME | SOUND_MASK_CD | SOUND_MASK_LINE | SOUND_MASK_MIC | SOUND_MASK_SPEAKER | SOUND_MASK_ALTPCM; - return IOCTL_OUT(arg, data); + rc = IOCTL_OUT(arg, data); + break; case SOUND_MIXER_READ_RECMASK: data = SOUND_MASK_LINE | SOUND_MASK_MIC | SOUND_MASK_CD; - return IOCTL_OUT(arg, data); + rc = IOCTL_OUT(arg, data); + break; case SOUND_MIXER_READ_RECSRC: data = 0; if (awacs_reg[0] & MASK_MUX_AUDIN) @@ -1755,7 +1876,8 @@ data |= SOUND_MASK_MIC; if (awacs_reg[0] & MASK_MUX_CD) data |= SOUND_MASK_CD; - return IOCTL_OUT(arg, data); + rc = IOCTL_OUT(arg, data); + break; case SOUND_MIXER_WRITE_RECSRC: IOCTL_IN(arg, data); data &= (SOUND_MASK_LINE @@ -1769,23 +1891,26 @@ if (data & SOUND_MASK_CD) awacs_reg[0] |= MASK_MUX_CD; awacs_write(awacs_reg[0] | MASK_ADDR0); - return IOCTL_OUT(arg, data); + rc = IOCTL_OUT(arg, data); + break; case SOUND_MIXER_READ_STEREODEVS: data = SOUND_MASK_VOLUME | SOUND_MASK_SPEAKER | SOUND_MASK_RECLEV | SOUND_MASK_CD | SOUND_MASK_LINE; - return IOCTL_OUT(arg, data); + rc = IOCTL_OUT(arg, data); + break; case SOUND_MIXER_READ_CAPS: - return IOCTL_OUT(arg, 0); + rc = IOCTL_OUT(arg, 0); + break; case SOUND_MIXER_WRITE_VOLUME: IOCTL_IN(arg, data); awacs_burgundy_write_mvolume(MASK_ADDR_BURGUNDY_MASTER_VOLUME, data); /* Fall through */ case SOUND_MIXER_READ_VOLUME: - return IOCTL_OUT(arg, awacs_burgundy_read_mvolume(MASK_ADDR_BURGUNDY_MASTER_VOLUME)); + rc = IOCTL_OUT(arg, awacs_burgundy_read_mvolume(MASK_ADDR_BURGUNDY_MASTER_VOLUME)); + break; case SOUND_MIXER_WRITE_SPEAKER: IOCTL_IN(arg, data); - if (!(data & 0xff)) { /* Mute the left speaker */ awacs_burgundy_wcb(MASK_ADDR_BURGUNDY_MORE_OUTPUTENABLES, @@ -1806,7 +1931,7 @@ } data = (((data&0xff)*16)/100 > 0xf ? 0xf : - (((data&0xff)*16)/100)) + + (((data&0xff)*16)/100)) + ((((data>>8)*16)/100 > 0xf ? 0xf : ((((data>>8)*16)/100)))<<4); @@ -1815,21 +1940,24 @@ case SOUND_MIXER_READ_SPEAKER: data = awacs_burgundy_rcb(MASK_ADDR_BURGUNDY_ATTENSPEAKER); data = (((data & 0xf)*100)/16) + ((((data>>4)*100)/16)<<8); - return IOCTL_OUT(arg, ~data); + rc = IOCTL_OUT(arg, ~data); + break; case SOUND_MIXER_WRITE_ALTPCM: /* really bell volume */ IOCTL_IN(arg, data); - beep_volume = data & 0xff; + beep_vol = data & 0xff; /* fall through */ case SOUND_MIXER_READ_ALTPCM: - return IOCTL_OUT(arg, beep_volume); + rc = IOCTL_OUT(arg, beep_vol); + break; case SOUND_MIXER_WRITE_LINE: IOCTL_IN(arg, data); awacs_burgundy_write_volume(MASK_ADDR_BURGUNDY_VOLLINE, data); /* fall through */ case SOUND_MIXER_READ_LINE: - data = awacs_burgundy_read_volume(MASK_ADDR_BURGUNDY_VOLLINE); - return IOCTL_OUT(arg, data); + data = awacs_burgundy_read_volume(MASK_ADDR_BURGUNDY_VOLLINE); + rc = IOCTL_OUT(arg, data); + break; case SOUND_MIXER_WRITE_MIC: IOCTL_IN(arg, data); /* Mic is mono device */ @@ -1837,66 +1965,330 @@ awacs_burgundy_write_volume(MASK_ADDR_BURGUNDY_VOLMIC, data); /* fall through */ case SOUND_MIXER_READ_MIC: - data = awacs_burgundy_read_volume(MASK_ADDR_BURGUNDY_VOLMIC); + data = awacs_burgundy_read_volume(MASK_ADDR_BURGUNDY_VOLMIC); data <<= 24; - return IOCTL_OUT(arg, data); + rc = IOCTL_OUT(arg, data); + break; case SOUND_MIXER_WRITE_CD: IOCTL_IN(arg, data); awacs_burgundy_write_volume(MASK_ADDR_BURGUNDY_VOLCD, data); /* fall through */ case SOUND_MIXER_READ_CD: data = awacs_burgundy_read_volume(MASK_ADDR_BURGUNDY_VOLCD); - return IOCTL_OUT(arg, data); + rc = IOCTL_OUT(arg, data); + break; case SOUND_MIXER_WRITE_RECLEV: IOCTL_IN(arg, data); data = awacs_volume_setter(data, 0, 0, 4); - return IOCTL_OUT(arg, data); + rc = IOCTL_OUT(arg, data); + break; case SOUND_MIXER_READ_RECLEV: data = awacs_get_volume(awacs_reg[0], 4); - return IOCTL_OUT(arg, data); + rc = IOCTL_OUT(arg, data); + break; case SOUND_MIXER_OUTMASK: + case SOUND_MIXER_OUTSRC: + default: + rc = -EINVAL; + } + + return rc; +} + +static int tumbler_mixer_ioctl(u_int cmd, u_long arg) +{ + int data; + int rc; + + /* We are, we are, we are... Tumbler (and very dumb) */ + /* Ok, we're not THAT dumb anymore, but still pretty dumb :-) */ + + switch(cmd) { + case SOUND_MIXER_READ_DEVMASK: + data = SOUND_MASK_VOLUME | SOUND_MASK_ALTPCM | + SOUND_MASK_BASS | SOUND_MASK_TREBLE | + SOUND_MASK_PCM; + rc = IOCTL_OUT(arg, data); + break; + case SOUND_MIXER_READ_RECMASK: + data = 0; + rc = IOCTL_OUT(arg, data); + break; + case SOUND_MIXER_READ_RECSRC: + data = 0; + rc = IOCTL_OUT(arg, data); + break; + case SOUND_MIXER_WRITE_RECSRC: + IOCTL_IN(arg, data); + data =0; + rc = IOCTL_OUT(arg, data); + break; + case SOUND_MIXER_READ_STEREODEVS: + data = SOUND_MASK_VOLUME; + rc = IOCTL_OUT(arg, data); + break; + case SOUND_MIXER_READ_CAPS: + rc = IOCTL_OUT(arg, 0); + break; + case SOUND_MIXER_WRITE_BASS: + IOCTL_IN(arg, data); + tumbler_set_bass(data); + case SOUND_MIXER_READ_BASS: + tumbler_get_bass(&data); + rc = IOCTL_OUT(arg, data); + break; + case SOUND_MIXER_WRITE_TREBLE: + IOCTL_IN(arg, data); + tumbler_set_treble(data); + /* Fall through */ + case SOUND_MIXER_READ_TREBLE: + tumbler_get_treble(&data); + rc = IOCTL_OUT(arg, data); + break; + case SOUND_MIXER_WRITE_PCM: + IOCTL_IN(arg, data); + tumbler_set_pcm_lvl(data); + /* Fall through */ + case SOUND_MIXER_READ_PCM: + tumbler_get_pcm_lvl(&data); + IOCTL_OUT(arg, data); + break; + case SOUND_MIXER_WRITE_VOLUME: + IOCTL_IN(arg, data); + tumbler_set_volume(data, data); + /* Fall through */ + case SOUND_MIXER_READ_VOLUME: + tumbler_get_volume(& data, &data); + rc = IOCTL_OUT(arg, data); break; + case SOUND_MIXER_WRITE_ALTPCM: /* really bell volume */ + IOCTL_IN(arg, data); + beep_vol = data & 0xff; + /* fall through */ + case SOUND_MIXER_READ_ALTPCM: + rc = IOCTL_OUT(arg, beep_vol); + break; + case SOUND_MIXER_OUTMASK: case SOUND_MIXER_OUTSRC: + default: + rc = -EINVAL; + } + + return rc; +} + +static int daca_mixer_ioctl(u_int cmd, u_long arg) +{ + int data; + int rc; + + /* And the DACA's no genius either! */ + + switch(cmd) { + case SOUND_MIXER_READ_DEVMASK: + data = SOUND_MASK_VOLUME; + rc = IOCTL_OUT(arg, data); + break; + case SOUND_MIXER_READ_RECMASK: + data = 0; + rc = IOCTL_OUT(arg, data); + break; + case SOUND_MIXER_READ_RECSRC: + data = 0; + rc = IOCTL_OUT(arg, data); + break; + case SOUND_MIXER_WRITE_RECSRC: + IOCTL_IN(arg, data); + data =0; + rc = IOCTL_OUT(arg, data); break; + case SOUND_MIXER_READ_STEREODEVS: + data = SOUND_MASK_VOLUME; + rc = IOCTL_OUT(arg, data); + break; + case SOUND_MIXER_READ_CAPS: + rc = IOCTL_OUT(arg, 0); + break; + case SOUND_MIXER_WRITE_VOLUME: + IOCTL_IN(arg, data); + daca_set_volume(data, data); + /* Fall through */ + case SOUND_MIXER_READ_VOLUME: + daca_get_volume(& data, &data); + rc = IOCTL_OUT(arg, data); + break; + case SOUND_MIXER_OUTMASK: + case SOUND_MIXER_OUTSRC: + default: + rc = -EINVAL; } - return -EINVAL; + return rc; } static int PMacMixerIoctl(u_int cmd, u_long arg) { - /* Different IOCTLS for burgundy*/ - if (awacs_revision >= AWACS_BURGUNDY) - return burgundy_mixer_ioctl(cmd, arg); - return awacs_mixer_ioctl(cmd, arg); + int rc; + + /* Different IOCTLS for burgundy and, eventually, DACA & Tumbler */ + + TRY_LOCK(); + + switch (awacs_revision){ + case AWACS_BURGUNDY: + rc = burgundy_mixer_ioctl(cmd, arg); + break ; + case AWACS_DACA: + rc = daca_mixer_ioctl(cmd, arg); + break; + case AWACS_TUMBLER: + rc = tumbler_mixer_ioctl(cmd, arg); + break ; + default: /* ;-)) */ + rc = awacs_mixer_ioctl(cmd, arg); + } + + UNLOCK(); + + return rc; +} + +static void PMacMixerInit(void) +{ + switch (awacs_revision) { + case AWACS_TUMBLER: + printk("AE-Init tumbler mixer\n"); + break ; + + case AWACS_DACA: + case AWACS_BURGUNDY: + break ; /* don't know yet */ + case AWACS_AWACS: + case AWACS_SCREAMER: + default: + awacs_mixer_init() ; + break ; + } } +/* Write/Read sq setup functions: + Check to see if we have enough (or any) dbdma cmd buffers for the + user's fragment settings. If not, allocate some. If this fails we will + point at the beep buffer - as an emergency provision - to stop dma tromping + on some random bit of memory (if someone lets it go anyway). + The command buffers are then set up to point to the fragment buffers + (allocated elsewhere). We need n+1 commands the last of which holds + a NOP + loop to start. +*/ -static void PMacWriteSqSetup(void) +static int PMacWriteSqSetup(void) { - int i; + int i, count = 600 ; volatile struct dbdma_cmd *cp; + LOCK(); + + /* stop the controller from doing any output - if it isn't already. + it _should_ be before this is called anyway */ + + out_le32(&awacs_txdma->control, (RUN|PAUSE|FLUSH|WAKE) << 16); + while ((in_le32(&awacs_txdma->status) & RUN) && count--) + udelay(1); +#ifdef DEBUG_DMASOUND +if (count <= 0) + printk("dmasound_pmac: write sq setup: timeout waiting for dma to stop\n"); +#endif + + if ((write_sq.max_count + 1) > number_of_tx_cmd_buffers) { + if (awacs_tx_cmd_space) + kfree(awacs_tx_cmd_space); + number_of_tx_cmd_buffers = 0; + + /* we need nbufs + 1 (for the loop) and we should request + 1 + again because the DBDMA_ALIGN might pull the start up by up + to sizeof(struct dbdma_cmd) - 4. + */ + + awacs_tx_cmd_space = kmalloc + ((write_sq.max_count + 1 + 1) * sizeof(struct dbdma_cmd), + GFP_KERNEL); + if (awacs_tx_cmd_space == NULL) { + /* don't leave it dangling - nasty but better than a + random address */ + out_le32(&awacs_txdma->cmdptr, virt_to_bus(beep_dbdma_cmd)); + printk(KERN_ERR + "dmasound_pmac: can't allocate dbdma cmd buffers" + ", driver disabled\n"); + UNLOCK(); + return -ENOMEM; + } + awacs_tx_cmds = (volatile struct dbdma_cmd *) + DBDMA_ALIGN(awacs_tx_cmd_space); + number_of_tx_cmd_buffers = write_sq.max_count + 1; + } + cp = awacs_tx_cmds; - memset((void *)cp, 0, (write_sq.numBufs+1) * sizeof(struct dbdma_cmd)); - for (i = 0; i < write_sq.numBufs; ++i, ++cp) { + memset((void *)cp, 0, (write_sq.max_count+1) * sizeof(struct dbdma_cmd)); + for (i = 0; i < write_sq.max_count; ++i, ++cp) { st_le32(&cp->phy_addr, virt_to_bus(write_sq.buffers[i])); } st_le16(&cp->command, DBDMA_NOP + BR_ALWAYS); st_le32(&cp->cmd_dep, virt_to_bus(awacs_tx_cmds)); - out_le32(&awacs_txdma->control, (RUN|PAUSE|FLUSH|WAKE) << 16); + /* point the controller at the command stack - ready to go */ out_le32(&awacs_txdma->cmdptr, virt_to_bus(awacs_tx_cmds)); + UNLOCK(); + return 0; } -static void PMacReadSqSetup(void) +static int PMacReadSqSetup(void) { - int i; + int i, count = 600; volatile struct dbdma_cmd *cp; + LOCK(); + + /* stop the controller from doing any input - if it isn't already. + it _should_ be before this is called anyway */ + + out_le32(&awacs_rxdma->control, (RUN|PAUSE|FLUSH|WAKE) << 16); + while ((in_le32(&awacs_rxdma->status) & RUN) && count--) + udelay(1); +#ifdef DEBUG_DMASOUND +if (count <= 0) + printk("dmasound_pmac: read sq setup: timeout waiting for dma to stop\n"); +#endif + + if ((read_sq.max_count+1) > number_of_rx_cmd_buffers ) { + if (awacs_rx_cmd_space) + kfree(awacs_rx_cmd_space); + number_of_rx_cmd_buffers = 0; + + /* we need nbufs + 1 (for the loop) and we should request + 1 again + because the DBDMA_ALIGN might pull the start up by up to + sizeof(struct dbdma_cmd) - 4 (assuming kmalloc aligns 32 bits). + */ + + awacs_rx_cmd_space = kmalloc + ((read_sq.max_count + 1 + 1) * sizeof(struct dbdma_cmd), + GFP_KERNEL); + if (awacs_rx_cmd_space == NULL) { + /* don't leave it dangling - nasty but better than a + random address */ + out_le32(&awacs_rxdma->cmdptr, virt_to_bus(beep_dbdma_cmd)); + printk(KERN_ERR + "dmasound_pmac: can't allocate dbdma cmd buffers" + ", driver disabled\n"); + UNLOCK(); + return -ENOMEM; + } + awacs_rx_cmds = (volatile struct dbdma_cmd *) + DBDMA_ALIGN(awacs_rx_cmd_space); + number_of_rx_cmd_buffers = read_sq.max_count + 1 ; + } cp = awacs_rx_cmds; - memset((void *)cp, 0, (read_sq.numBufs+1) * sizeof(struct dbdma_cmd)); + memset((void *)cp, 0, (read_sq.max_count+1) * sizeof(struct dbdma_cmd)); /* Set dma buffers up in a loop */ - for (i = 0; i < read_sq.numBufs; i++,cp++) { + for (i = 0; i < read_sq.max_count; i++,cp++) { st_le32(&cp->phy_addr, virt_to_bus(read_sq.buffers[i])); st_le16(&cp->command, INPUT_MORE + INTR_ALWAYS); st_le16(&cp->req_count, read_sq.block_size); @@ -1907,37 +2299,105 @@ */ st_le16(&cp->command, DBDMA_NOP + BR_ALWAYS); st_le32(&cp->cmd_dep, virt_to_bus(awacs_rx_cmds)); - - /* Don't start until the first read is done. - * This will also abort any operations in progress if the DMA - * happens to be running (and it shouldn't). - */ - out_le32(&awacs_rxdma->control, (RUN|PAUSE|FLUSH|WAKE) << 16); + /* point the controller at the command stack - ready to go */ out_le32(&awacs_rxdma->cmdptr, virt_to_bus(awacs_rx_cmds)); + UNLOCK(); + return 0; } +/* TODO: this needs work to guarantee that when it returns DMA has stopped + but in a more elegant way than is done here.... +*/ + static void PMacAbortRead(void) { int i; volatile struct dbdma_cmd *cp; + LOCK(); + /* give it a chance to update the output and provide the IRQ + that is expected. + */ + + out_le32(&awacs_rxdma->control, ((FLUSH) << 16) + FLUSH ); + cp = awacs_rx_cmds; - for (i = 0; i < read_sq.numBufs; i++,cp++) + for (i = 0; i < read_sq.max_count; i++,cp++) st_le16(&cp->command, DBDMA_STOP); /* * We should probably wait for the thing to stop before we - * release the memory + * release the memory. */ + + wait_ms(100) ; /* give it a (small) chance to act */ + + /* apply the sledgehammer approach - just stop it now */ + + out_le32(&awacs_rxdma->control, (RUN|PAUSE|FLUSH|WAKE) << 16); + UNLOCK(); } +extern char *get_afmt_string(int); +static int PMacStateInfo(char *b, size_t sp) +{ + int i, len = 0; + len = sprintf(b,"HW rates: "); + switch (awacs_revision){ + case AWACS_DACA: + case AWACS_BURGUNDY: + len += sprintf(b,"44100 ") ; + break ; + case AWACS_TUMBLER: + for (i=0; i<2; i++){ + if (tumbler_freqs_ok[i]) + len += sprintf(b+len,"%d ", tumbler_freqs[i]) ; + } + break ; + + case AWACS_AWACS: + case AWACS_SCREAMER: + default: + for (i=0; i<8; i++){ + if (awacs_freqs_ok[i]) + len += sprintf(b+len,"%d ", awacs_freqs[i]) ; + } + break ; + } + len += sprintf(b+len,"s/sec\n") ; + if (len < sp) { + len += sprintf(b+len,"HW AFMTS: "); + i = AFMT_U16_BE ; + while (i) { + if (i & dmasound.mach.hardware_afmts) + len += sprintf(b+len,"%s ", + get_afmt_string(i & dmasound.mach.hardware_afmts)); + i >>= 1 ; + } + len += sprintf(b+len,"\n") ; + } + return len ; +} /*** Machine definitions *****************************************************/ +static SETTINGS def_hard = { + format: AFMT_S16_BE, + stereo: 1, + size: 16, + speed: 44100 +} ; + +static SETTINGS def_soft = { + format: AFMT_S16_BE, + stereo: 1, + size: 16, + speed: 44100 +} ; static MACHINE machPMac = { name: awacs_name, - name2: "AWACS", + name2: "PowerMac Built-in Sound", open: PMacOpen, release: PMacRelease, dma_alloc: PMacAlloc, @@ -1951,233 +2411,669 @@ setFormat: PMacSetFormat, setVolume: PMacSetVolume, play: PMacPlay, - record: PMacRecord, + record: NULL, /* default to no record */ + mixer_init: PMacMixerInit, mixer_ioctl: PMacMixerIoctl, write_sq_setup: PMacWriteSqSetup, read_sq_setup: PMacReadSqSetup, + state_info: PMacStateInfo, abort_read: PMacAbortRead, - min_dsp_speed: 8000 + min_dsp_speed: 7350, + max_dsp_speed: 44100, + version: ((DMASOUND_AWACS_REVISION<<8) + DMASOUND_AWACS_EDITION) }; /*** Config & Setup **********************************************************/ +/* Check for pmac models that we care about in terms of special actions. +*/ -int __init dmasound_awacs_init(void) +void __init +set_model(void) { - struct device_node *np; + /* portables/lap-tops */ - if (_machine != _MACH_Pmac) - return -ENODEV; + if (machine_is_compatible("AAPL,3400/2400") || + machine_is_compatible("AAPL,3500")) { + is_pbook_3X00 = 1 ; + } + if (machine_is_compatible("PowerBook1,1") || /* lombard */ + machine_is_compatible("AAPL,PowerBook1998")){ /* wallstreet */ + is_pbook_g3 = 1 ; + return ; + } +} - awacs_subframe = 0; - awacs_revision = 0; - np = find_devices("awacs"); - if (np == 0) { - /* - * powermac G3 models have a node called "davbus" - * with a child called "sound". - */ - struct device_node *sound; - np = find_devices("davbus"); - sound = find_devices("sound"); - if (sound != 0 && sound->parent == np) { - unsigned int *prop, l, i; - prop = (unsigned int *) - get_property(sound, "sub-frame", 0); - if (prop != 0 && *prop >= 0 && *prop < 16) - awacs_subframe = *prop; - if (device_is_compatible(sound, "burgundy")) - awacs_revision = AWACS_BURGUNDY; - /* This should be verified on older screamers */ - if (device_is_compatible(sound, "screamer")) - awacs_is_screamer = 1; - prop = (unsigned int *)get_property(sound, "device-id", 0); - if (prop != 0) - awacs_device_id = *prop; - awacs_has_iic = (find_devices("perch") != NULL); - - /* look for a property saying what sample rates - are available */ - for (i = 0; i < 8; ++i) - awacs_freqs_ok[i] = 0; - prop = (unsigned int *) get_property - (sound, "sample-rates", &l); - if (prop == 0) - prop = (unsigned int *) get_property - (sound, "output-frame-rates", &l); - if (prop != 0) { - for (l /= sizeof(int); l > 0; --l) { - /* sometimes the rate is in the - high-order 16 bits (?) */ - unsigned int r = *prop++; - if (r >= 0x10000) - r >>= 16; - for (i = 0; i < 8; ++i) { - if (r == awacs_freqs[i]) { - awacs_freqs_ok[i] = 1; - break; - } - } +/* Get the OF node that tells us about the registers, interrupts etc. to use + for sound IO. + + On most machines the sound IO OF node is the 'davbus' node. On newer pmacs + with DACA (& Tumbler) the node to use is i2s-a. On much older machines i.e. + before 9500 there is no davbus node and we have to use the 'awacs' property. + + In the latter case we signal this by setting the codec value - so that the + code that looks for chip properties knows how to go about it. +*/ + +static struct device_node +__init *get_snd_io_node(void) +{ + struct device_node *np = NULL; + + /* set up awacs_node for early OF which doesn't have a full set of + * properties on davbus + */ + + awacs_node = find_devices("awacs"); + if (awacs_node) + awacs_revision = AWACS_AWACS; + + /* powermac models after 9500 (other than those which use DACA or + * Tumbler) have a node called "davbus". + */ + np = find_devices("davbus"); + /* + * if we didn't find a davbus device, try 'i2s-a' since + * this seems to be what iBooks (& Tumbler) have. + */ + if (np == NULL) + np = find_devices("i2s-a"); + + /* if we didn't find this - perhaps we are on an early model + * which _only_ has an 'awacs' node + */ + if (np == NULL && awacs_node) + np = awacs_node ; + + /* if we failed all these return null - this will cause the + * driver to give up... + */ + return np ; +} + +/* Get the OF node that contains the info about the sound chip, inputs s-rates + etc. + This node does not exist (or contains much reduced info) on earlier machines + we have to deduce the info other ways for these. +*/ + +static struct device_node +__init *get_snd_info_node(struct device_node *io) +{ + struct device_node *info; + + info = find_devices("sound"); + while (info != 0 && info->parent != io) + info = info->next; + + return info ; +} + +/* Find out what type of codec we have. +*/ + +static int +__init get_codec_type(struct device_node *info) +{ + /* already set if pre-davbus model and info will be NULL */ + int codec = awacs_revision ; + + if (info) { + /* must do awacs first to allow screamer to overide it */ + if (device_is_compatible(info, "awacs")) + codec = AWACS_AWACS ; + if (device_is_compatible(info, "screamer")) + codec = AWACS_SCREAMER; + if (device_is_compatible(info, "burgundy")) + codec = AWACS_BURGUNDY ; + if (device_is_compatible(info, "daca")) + codec = AWACS_DACA; + if (device_is_compatible(info, "tumbler")) + codec = AWACS_TUMBLER; + } + return codec ; +} + +/* find out what type, if any, of expansion card we have +*/ +static void +__init get_expansion_type(void) +{ + if (find_devices("perch") != NULL) + has_perch = 1; + + if (find_devices("pb-ziva-pc") != NULL) + has_ziva = 1; + /* need to work out how we deal with iMac SRS module */ +} + +/* set up frame rates. + * I suspect that these routines don't quite go about it the right way: + * - where there is more than one rate - I think that the first property + * value is the number of rates. + * TODO: check some more device trees and modify accordingly + * Set dmasound.mach.max_dsp_rate on the basis of these routines. +*/ + +static void +__init init_awacs_frame_rates(unsigned int *prop, unsigned int l) +{ + int i ; + if (prop) { + for (i=0; i<8; i++) + awacs_freqs_ok[i] = 0 ; + for (l /= sizeof(int); l > 0; --l) { + unsigned int r = *prop++; + /* Apple 'Fixed' format */ + if (r >= 0x10000) + r >>= 16; + for (i = 0; i < 8; ++i) { + if (r == awacs_freqs[i]) { + awacs_freqs_ok[i] = 1; + break; } - } else { - /* assume just 44.1k is OK */ - awacs_freqs_ok[0] = 1; } } } - if (np != NULL && np->n_addrs >= 3 && np->n_intrs >= 3) { - int vol; - dmasound.mach = machPMac; - - awacs = (volatile struct awacs_regs *) - ioremap(np->addrs[0].address, 0x80); - awacs_txdma = (volatile struct dbdma_regs *) - ioremap(np->addrs[1].address, 0x100); - awacs_rxdma = (volatile struct dbdma_regs *) - ioremap(np->addrs[2].address, 0x100); - - awacs_irq = np->intrs[0].line; - awacs_tx_irq = np->intrs[1].line; - awacs_rx_irq = np->intrs[2].line; + /* else we assume that all the rates are available */ +} - awacs_tx_cmd_space = kmalloc((write_sq.numBufs + 4) * sizeof(struct dbdma_cmd), - GFP_KERNEL); - if (awacs_tx_cmd_space == NULL) { - printk(KERN_ERR "DMA sound driver: Not enough buffer memory, driver disabled!\n"); - return -ENOMEM; +static void +__init init_tumbler_frame_rates(unsigned int *prop, unsigned int l) +{ + int i ; + if (prop) { + for (i=0; i<2; i++) + tumbler_freqs_ok[i] = 0; + for (l /= sizeof(int); l > 0; --l) { + unsigned int r = *prop++; + /* Apple 'Fixed' format */ + if (r >= 0x10000) + r >>= 16; + for (i = 0; i < 2; ++i) { + if (r == tumbler_freqs[i]) { + tumbler_freqs_ok[i] = 1; + break; + } + } } - awacs_node = np; -#ifdef CONFIG_PMAC_PBOOK - if (machine_is_compatible("PowerBook1,1") - || machine_is_compatible("AAPL,PowerBook1998")) { - pmu_suspend(); - feature_set(np, FEATURE_Sound_CLK_enable); - feature_set(np, FEATURE_Sound_power); - /* Shorter delay will not work */ - mdelay(1000); - pmu_resume(); + } + /* else we assume that all the rates are available */ +} + +static void +__init init_burgundy_frame_rates(unsigned int *prop, unsigned int l) +{ + int temp[9] ; + int i = 0 ; + if (prop) { + for (l /= sizeof(int); l > 0; --l) { + unsigned int r = *prop++; + /* Apple 'Fixed' format */ + if (r >= 0x10000) + r >>= 16; + temp[i] = r ; + i++ ; if(i>=9) i=8; + } + } +#ifdef DEBUG_DMASOUND +if (i > 1){ + int j; + printk("dmasound_pmac: burgundy with multiple frame rates\n"); + for(j=0; j<i; j++) + printk("%d ", temp[j]) ; + printk("\n") ; +} +#endif +} + +static void +__init init_daca_frame_rates(unsigned int *prop, unsigned int l) +{ + int temp[9] ; + int i = 0 ; + if (prop) { + for (l /= sizeof(int); l > 0; --l) { + unsigned int r = *prop++; + /* Apple 'Fixed' format */ + if (r >= 0x10000) + r >>= 16; + temp[i] = r ; + i++ ; if(i>=9) i=8; + + } + } +#ifdef DEBUG_DMASOUND +if (i > 1){ + int j; + printk("dmasound_pmac: DACA with multiple frame rates\n"); + for(j=0; j<i; j++) + printk("%d ", temp[j]) ; + printk("\n") ; +} +#endif +} + +static void +__init init_frame_rates(unsigned int *prop, unsigned int l) +{ + switch (awacs_revision){ + case AWACS_TUMBLER: + init_tumbler_frame_rates(prop, l); + break ; + case AWACS_DACA: + init_daca_frame_rates(prop, l); + break ; + case AWACS_BURGUNDY: + init_burgundy_frame_rates(prop, l); + break ; + default: /* ;-))) */ + init_awacs_frame_rates(prop, l); + break ; + } +} + +/* find things/machines that can't do mac-io byteswap +*/ + +static void +__init set_hw_byteswap(struct device_node *io) +{ + struct device_node *mio ; + unsigned int *p, rev = 0 ; + + /* if seems that Keylargo (at least rev2) can't byte-swap */ + + for (mio = io->parent; mio ; mio = mio->parent) { + if (strcmp(mio->name, "mac-io") == 0) { + if (device_is_compatible(mio, "Keylargo")){ + p = (unsigned int *) + get_property(mio, "revision-id", 0); + if (p) + rev = *p ; + } + break; } + } + if (rev >= 2) { + hw_can_byteswap = 0; +#ifdef DEBUG_DMASOUND +printk("dmasound_pmac: found Keylargo rev 2 or later - H/W byte-swap disabled\n") ; #endif - awacs_tx_cmds = (volatile struct dbdma_cmd *) - DBDMA_ALIGN(awacs_tx_cmd_space); + } +} +/* Allocate the resources necessary for beep generation. This cannot be (quite) + done statically (yet) because we cannot do virt_to_bus() on static vars when + the code is loaded as a module. + + for the sake of saving the possibility that two allocations will incur the + overhead of two pull-ups in DBDMA_ALIGN() we allocate the 'emergency' dmdma + command here as well... even tho' it is not part of the beep process. +*/ + +int32_t +__init setup_beep(void) +{ + /* Initialize beep stuff */ + /* want one cmd buffer for beeps, and a second one for emergencies + - i.e. dbdma error conditions. + ask for three to allow for pull up in DBDMA_ALIGN(). + */ + beep_dbdma_cmd_space = + kmalloc((2 + 1) * sizeof(struct dbdma_cmd), GFP_KERNEL); + if(beep_dbdma_cmd_space == NULL) { + printk(KERN_ERR "dmasound_pmac: no beep dbdma cmd space\n") ; + return -ENOMEM ; + } + beep_dbdma_cmd = (volatile struct dbdma_cmd *) + DBDMA_ALIGN(beep_dbdma_cmd_space); + /* set up emergency dbdma cmd */ + emergency_dbdma_cmd = beep_dbdma_cmd+1 ; + beep_buf = (short *) kmalloc(BEEP_BUFLEN * 4, GFP_KERNEL); + if (beep_buf == NULL) { + printk(KERN_ERR "dmasound_pmac: no memory for beep buffer\n"); + if( beep_dbdma_cmd_space ) kfree(beep_dbdma_cmd_space) ; + return -ENOMEM ; + } + /* OK, we should be safe to claim the mksound vector now */ + orig_mksound = kd_mksound; + kd_mksound = awacs_mksound; + return 0 ; +} - awacs_rx_cmd_space = kmalloc((read_sq.numBufs + 4) * sizeof(struct dbdma_cmd), - GFP_KERNEL); - if (awacs_rx_cmd_space == NULL) { - printk("DMA sound driver: No memory for input"); +int __init dmasound_awacs_init(void) +{ + struct device_node *io = NULL, *info = NULL; + int vol, res; + + if (_machine != _MACH_Pmac) + return -ENODEV; + + awacs_subframe = 0; + awacs_revision = 0; + hw_can_byteswap = 1 ; /* most can */ + + /* look for models we need to handle specially */ + set_model() ; + + /* find the OF node that tells us about the dbdma stuff + */ + io = get_snd_io_node(); + if (io == NULL) { +#ifdef DEBUG_DMASOUND +printk("dmasound_pmac: couldn't find sound io OF node\n"); +#endif + return -ENODEV ; + } + + /* find the OF node that tells us about the sound sub-system + * this doesn't exist on pre-davbus machines (earlier than 9500) + */ + if (awacs_revision != AWACS_AWACS) { /* set for pre-davbus */ + info = get_snd_info_node(io) ; + if (info == NULL){ +#ifdef DEBUG_DMASOUND +printk("dmasound_pmac: couldn't find 'sound' OF node\n"); +#endif + return -ENODEV ; } - awacs_rx_cmds = (volatile struct dbdma_cmd *) - DBDMA_ALIGN(awacs_rx_cmd_space); + } + awacs_revision = get_codec_type(info) ; + if (awacs_revision == 0) { +#ifdef DEBUG_DMASOUND +printk("dmasound_pmac: couldn't find a Codec we can handle\n"); +#endif + return -ENODEV ; /* we don't know this type of h/w */ + } + /* set up perch, ziva, SRS or whatever else we have as sound + * expansion. + */ + get_expansion_type(); - awacs_reg[0] = MASK_MUX_CD; - /* FIXME: Only machines with external SRS module need MASK_PAROUT */ - awacs_reg[1] = MASK_LOOPTHRU; - if (awacs_has_iic || awacs_device_id == 0x5 || /*awacs_device_id == 0x8 - || */awacs_device_id == 0xb) - awacs_reg[1] |= MASK_PAROUT; - /* get default volume from nvram */ - vol = (~nvram_read_byte(0x1308) & 7) << 1; - awacs_reg[2] = vol + (vol << 6); - awacs_reg[4] = vol + (vol << 6); - awacs_reg[5] = 0; - awacs_reg[6] = 0; - awacs_reg[7] = 0; - out_le32(&awacs->control, 0x11); - awacs_write(awacs_reg[0] + MASK_ADDR0); - awacs_write(awacs_reg[1] + MASK_ADDR1); - awacs_write(awacs_reg[2] + MASK_ADDR2); - awacs_write(awacs_reg[4] + MASK_ADDR4); - if (awacs_is_screamer) { - awacs_write(awacs_reg[5] + MASK_ADDR5); - awacs_write(awacs_reg[6] + MASK_ADDR6); - awacs_write(awacs_reg[7] + MASK_ADDR7); - } - - /* Initialize recent versions of the awacs */ - if (awacs_revision == 0) { - awacs_revision = - (in_le32(&awacs->codec_stat) >> 12) & 0xf; - if (awacs_revision == 3) { - mdelay(100); - awacs_write(0x6000); - mdelay(2); - awacs_write(awacs_reg[1] + MASK_ADDR1); - awacs_enable_amp(100 * 0x101); + /* we've now got enough information to make up the audio topology. + * we will map the sound part of mac-io now so that we can probe for + * other info if necessary (early AWACS we want to read chip ids) + */ + + if (io->n_addrs < 3 || io->n_intrs < 3) { + /* OK - maybe we need to use the 'awacs' node (on earlier + * machines). + */ + if (awacs_node) { + io = awacs_node ; + if (io->n_addrs < 3 || io->n_intrs < 3) { + printk("dmasound_pmac: can't use %s" + " (%d addrs, %d intrs)\n", + io->full_name, io->n_addrs, io->n_intrs); + return -ENODEV; } + } else { + printk("dmasound_pmac: can't use %s (%d addrs, %d intrs)\n", + io->full_name, io->n_addrs, io->n_intrs); } - if (awacs_revision >= AWACS_BURGUNDY) + } + + if (!request_OF_resource(io, 0, NULL)) { + printk(KERN_ERR "dmasound: can't request IO resource !\n"); + return -ENODEV; + } + if (!request_OF_resource(io, 1, " (tx dma)")) { + release_OF_resource(io, 0); + printk(KERN_ERR "dmasound: can't request TX DMA resource !\n"); + return -ENODEV; + } + + if (!request_OF_resource(io, 2, " (rx dma)")) { + release_OF_resource(io, 0); + release_OF_resource(io, 1); + printk(KERN_ERR "dmasound: can't request RX DMA resource !\n"); + return -ENODEV; + } + + /* all OF versions I've seen use this value */ + awacs = (volatile struct awacs_regs *) + ioremap(io->addrs[0].address, 0x1000); + awacs_txdma = (volatile struct dbdma_regs *) + ioremap(io->addrs[1].address, 0x100); + awacs_rxdma = (volatile struct dbdma_regs *) + ioremap(io->addrs[2].address, 0x100); + +#ifdef CONFIG_PMAC_PBOOK + /* first of all make sure that the chip is powered up....*/ + pmac_call_feature(PMAC_FTR_SOUND_CHIP_ENABLE, io, 0, 1); + if (awacs_revision == AWACS_SCREAMER) + awacs_recalibrate(); +#endif + awacs_irq = io->intrs[0].line; + awacs_tx_irq = io->intrs[1].line; + awacs_rx_irq = io->intrs[2].line; + + awacs_node = io; + + /* if we have an awacs or screamer - probe the chip to make + * sure we have the right revision. + */ + + if (awacs_revision <= AWACS_SCREAMER){ + uint32_t temp, rev, mfg ; + /* find out the awacs revision from the chip */ + temp = in_le32(&awacs->codec_stat); + rev = (temp >> 12) & 0xf; + mfg = (temp >> 8) & 0xf; +#ifdef DEBUG_DMASOUND +printk("dmasound_pmac: Awacs/Screamer Codec Mfct: %d Rev %d\n", mfg, rev); +#endif + if (rev >= AWACS_SCREAMER) + awacs_revision = AWACS_SCREAMER ; + else + awacs_revision = rev ; + } + + dmasound.mach = machPMac; + + /* find out other bits & pieces from OF, these may be present + only on some models ... so be careful. + */ + + /* in the absence of a frame rates property we will use the defaults + */ + + if (info) { + unsigned int *prop, l; + + sound_device_id = 0; + /* device ID appears post g3 b&w */ + prop = (unsigned int *)get_property(info, "device-id", 0); + if (prop != 0) + sound_device_id = *prop; + + /* look for a property saying what sample rates + are available */ + + prop = (unsigned int *)get_property(info, "sample-rates", &l); + if (prop == 0) + prop = (unsigned int *) get_property + (info, "output-frame-rates", &l); + + /* if it's there use it to set up frame rates */ + init_frame_rates(prop, l) ; + } + + out_le32(&awacs->control, 0x11); /* set everything quiesent */ + + set_hw_byteswap(io) ; /* figure out if the h/w can do it */ + + /* get default volume from nvram + * vol = (~nvram_read_byte(0x1308) & 7) << 1; + */ + vol = ((pmac_xpram_read( 8 ) & 7 ) << 1 ); + /* set up tracking values */ + spk_vol = vol * 100 ; + spk_vol /= 7 ; /* get set value to a percentage */ + spk_vol |= (spk_vol << 8) ; /* equal left & right */ + line_vol = passthru_vol = spk_vol ; + + /* fill regs that are shared between AWACS & Burgundy */ + + awacs_reg[2] = vol + (vol << 6); + awacs_reg[4] = vol + (vol << 6); + awacs_reg[5] = vol + (vol << 6); /* screamer has loopthru vol control */ + awacs_reg[6] = 0; /* maybe should be vol << 3 for PCMCIA speaker */ + awacs_reg[7] = 0; + + awacs_reg[0] = MASK_MUX_CD; + awacs_reg[1] = MASK_LOOPTHRU; + + /* FIXME: Only machines with external SRS module need MASK_PAROUT */ + if (has_perch || sound_device_id == 0x5 + || /*sound_device_id == 0x8 ||*/ sound_device_id == 0xb) + awacs_reg[1] |= MASK_PAROUT0 | MASK_PAROUT1; + + switch (awacs_revision) { + case AWACS_TUMBLER: +#ifdef CONFIG_KMOD + request_module("i2c-keywest"); +#endif /* CONFIG_KMOD */ + awacs_tumbler_init(); + tas_init(); + break ; + case AWACS_DACA: +#ifdef CONFIG_KMOD + request_module("i2c-keywest"); +#endif /* CONFIG_KMOD */ + daca_init(); + break ; /* dont know how yet */ + case AWACS_BURGUNDY: awacs_burgundy_init(); + break ; + case AWACS_SCREAMER: + case AWACS_AWACS: + default: + load_awacs() ; + break ; + } + + /* enable/set-up external modules - when we know how */ + + if (has_perch) + awacs_enable_amp(100 * 0x101); + + /* Reset dbdma channels */ + out_le32(&awacs_txdma->control, (RUN|PAUSE|FLUSH|WAKE|DEAD) << 16); + while (in_le32(&awacs_txdma->status) & RUN) + udelay(1); + out_le32(&awacs_rxdma->control, (RUN|PAUSE|FLUSH|WAKE|DEAD) << 16); + while (in_le32(&awacs_rxdma->status) & RUN) + udelay(1); + + /* Initialize beep stuff */ + if ((res=setup_beep())) + return res ; - /* Initialize beep stuff */ - beep_dbdma_cmd = awacs_tx_cmds + (write_sq.numBufs + 1); - orig_mksound = kd_mksound; - kd_mksound = awacs_mksound; - beep_buf = (short *) kmalloc(BEEP_BUFLEN * 4, GFP_KERNEL); - if (beep_buf == NULL) - printk(KERN_WARNING "dmasound: no memory for " - "beep buffer\n"); #ifdef CONFIG_PMAC_PBOOK - pmu_register_sleep_notifier(&awacs_sleep_notifier); + pmu_register_sleep_notifier(&awacs_sleep_notifier); #endif /* CONFIG_PMAC_PBOOK */ - /* Powerbooks have odd ways of enabling inputs such as - an expansion-bay CD or sound from an internal modem - or a PC-card modem. */ - if (machine_is_compatible("AAPL,3400/2400") - || machine_is_compatible("AAPL,3500")) { - is_pbook_3400 = 1; - /* - * Enable CD and PC-card sound inputs. - * This is done by reading from address - * f301a000, + 0x10 to enable the expansion-bay - * CD sound input, + 0x80 to enable the PC-card - * sound input. The 0x100 enables the SCSI bus - * terminator power. - */ - latch_base = (unsigned char *) ioremap - (0xf301a000, 0x1000); - in_8(latch_base + 0x190); - } else if (machine_is_compatible("PowerBook1,1") - || machine_is_compatible("AAPL,PowerBook1998")) { - struct device_node* mio; - macio_base = 0; - is_pbook_G3 = 1; - for (mio = np->parent; mio; mio = mio->parent) { - if (strcmp(mio->name, "mac-io") == 0 - && mio->n_addrs > 0) { - macio_base = (unsigned char *) ioremap - (mio->addrs[0].address, 0x40); - break; - } + /* Powerbooks have odd ways of enabling inputs such as + an expansion-bay CD or sound from an internal modem + or a PC-card modem. */ + if (is_pbook_3X00) { + /* + * Enable CD and PC-card sound inputs. + * This is done by reading from address + * f301a000, + 0x10 to enable the expansion-bay + * CD sound input, + 0x80 to enable the PC-card + * sound input. The 0x100 enables the SCSI bus + * terminator power. + */ + latch_base = (unsigned char *) ioremap (0xf301a000, 0x1000); + in_8(latch_base + 0x190); + + } else if (is_pbook_g3) { + struct device_node* mio; + macio_base = 0; + for (mio = io->parent; mio; mio = mio->parent) { + if (strcmp(mio->name, "mac-io") == 0 + && mio->n_addrs > 0) { + macio_base = (unsigned char *) ioremap + (mio->addrs[0].address, 0x40); + break; } - /* - * Enable CD sound input. - * The relevant bits for writing to this byte are 0x8f. - * I haven't found out what the 0x80 bit does. - * For the 0xf bits, writing 3 or 7 enables the CD - * input, any other value disables it. Values - * 1, 3, 5, 7 enable the microphone. Values 0, 2, - * 4, 6, 8 - f enable the input from the modem. - */ - if (macio_base) - out_8(macio_base + 0x37, 3); - } - sprintf(awacs_name, "PowerMac (AWACS rev %d) ", - awacs_revision); - return dmasound_init(); + } + /* + * Enable CD sound input. + * The relevant bits for writing to this byte are 0x8f. + * I haven't found out what the 0x80 bit does. + * For the 0xf bits, writing 3 or 7 enables the CD + * input, any other value disables it. Values + * 1, 3, 5, 7 enable the microphone. Values 0, 2, + * 4, 6, 8 - f enable the input from the modem. + * -- paulus. + */ + if (macio_base) + out_8(macio_base + 0x37, 3); + } + + if (hw_can_byteswap) + dmasound.mach.hardware_afmts = (AFMT_S16_BE | AFMT_S16_LE) ; + else + dmasound.mach.hardware_afmts = AFMT_S16_BE ; + + /* shut out chips that do output only. + may need to extend this to machines which have no inputs - even tho' + they use screamer - IIRC one of the powerbooks is like this. + */ + + if (awacs_revision != AWACS_TUMBLER && awacs_revision != AWACS_DACA) { + dmasound.mach.capabilities = DSP_CAP_DUPLEX ; + dmasound.mach.record = PMacRecord ; + } + + dmasound.mach.default_hard = def_hard ; + dmasound.mach.default_soft = def_soft ; + + switch (awacs_revision) { + case AWACS_BURGUNDY: + sprintf(awacs_name, "PowerMac Burgundy ") ; + break ; + case AWACS_DACA: + sprintf(awacs_name, "PowerMac DACA ") ; + break ; + case AWACS_TUMBLER: + sprintf(awacs_name, "PowerMac Tumbler ") ; + break ; + case AWACS_SCREAMER: + sprintf(awacs_name, "PowerMac Screamer ") ; + break ; + case AWACS_AWACS: + default: + sprintf(awacs_name, "PowerMac AWACS rev %d ", awacs_revision) ; + break ; } - return -ENODEV; + + return dmasound_init(); } static void __exit dmasound_awacs_cleanup(void) { + switch (awacs_revision) { + case AWACS_TUMBLER: + awacs_tumbler_cleanup(); + tas_cleanup(); + break ; + case AWACS_DACA: + daca_cleanup(); + break; + } dmasound_deinit(); } +MODULE_DESCRIPTION("PowerMac built-in audio driver."); +MODULE_LICENSE("GPL"); + module_init(dmasound_awacs_init); module_exit(dmasound_awacs_cleanup); -MODULE_LICENSE("GPL"); diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/sound/dmasound/dmasound_core.c linux-2.5/drivers/sound/dmasound/dmasound_core.c --- linux-2.5.1/drivers/sound/dmasound/dmasound_core.c Thu Oct 25 20:53:52 2001 +++ linux-2.5/drivers/sound/dmasound/dmasound_core.c Thu Dec 27 16:32:31 2001 @@ -1,4 +1,3 @@ - /* * linux/drivers/sound/dmasound/dmasound_core.c * @@ -103,38 +102,113 @@ * 2000/3/25 Geert Uytterhoeven: * - Integration of dmasound_q40 * - Small clean ups + * + * 2001/01/26 [1.0] Iain Sandoe + * - make /dev/sndstat show revision & edition info. + * - since dmasound.mach.sq_setup() can fail on pmac + * its type has been changed to int and the returns + * are checked. + * [1.1] - stop missing translations from being called. + * 2001/02/08 [1.2] - remove unused translation tables & move machine- + * specific tables to low-level. + * - return correct info. for SNDCTL_DSP_GETFMTS. + * [1.3] - implement SNDCTL_DSP_GETCAPS fully. + * [1.4] - make /dev/sndstat text length usage deterministic. + * - make /dev/sndstat call to low-level + * dmasound.mach.state_info() pass max space to ll driver. + * - tidy startup banners and output info. + * [1.5] - tidy up a little (removed some unused #defines in + * dmasound.h) + * - fix up HAS_RECORD conditionalisation. + * - add record code in places it is missing... + * - change buf-sizes to bytes to allow < 1kb for pmac + * if user param entry is < 256 the value is taken to + * be in kb > 256 is taken to be in bytes. + * - make default buff/frag params conditional on + * machine to allow smaller values for pmac. + * - made the ioctls, read & write comply with the OSS + * rules on setting params. + * - added parsing of _setup() params for record. + * 2001/04/04 [1.6] - fix bug where sample rates higher than maximum were + * being reported as OK. + * - fix open() to return -EBUSY as per OSS doc. when + * audio is in use - this is independent of O_NOBLOCK. + * - fix bug where SNDCTL_DSP_POST was blocking. */ + /* Record capability notes 30/01/2001: + * At present these observations apply only to pmac LL driver (the only one + * that can do record, at present). However, if other LL drivers for machines + * with record are added they may apply. + * + * The fragment parameters for the record and play channels are separate. + * However, if the driver is opened O_RDWR there is no way (in the current OSS + * API) to specify their values independently for the record and playback + * channels. Since the only common factor between the input & output is the + * sample rate (on pmac) it should be possible to open /dev/dspX O_WRONLY and + * /dev/dspY O_RDONLY. The input & output channels could then have different + * characteristics (other than the first that sets sample rate claiming the + * right to set it for ever). As it stands, the format, channels, number of + * bits & sample rate are assumed to be common. In the future perhaps these + * should be the responsibility of the LL driver - and then if a card really + * does not share items between record & playback they can be specified + * separately. +*/ + +/* Thread-safeness of shared_resources notes: 31/01/2001 + * If the user opens O_RDWR and then splits record & play between two threads + * both of which inherit the fd - and then starts changing things from both + * - we will have difficulty telling. + * + * It's bad application coding - but ... + * TODO: think about how to sort this out... without bogging everything down in + * semaphores. + * + * Similarly, the OSS spec says "all changes to parameters must be between + * open() and the first read() or write(). - and a bit later on (by + * implication) "between SNDCTL_DSP_RESET and the first read() or write() after + * it". If the app is multi-threaded and this rule is broken between threads + * we will have trouble spotting it - and the fault will be rather obscure :-( + * + * We will try and put out at least a kmsg if we see it happen... but I think + * it will be quite hard to trap it with an -EXXX return... because we can't + * see the fault until after the damage is done. +*/ #include <linux/module.h> #include <linux/slab.h> #include <linux/sound.h> #include <linux/init.h> #include <linux/soundcard.h> +#include <linux/poll.h> #include <linux/smp_lock.h> #include <asm/uaccess.h> #include "dmasound.h" +#define DMASOUND_CORE_REVISION 1 +#define DMASOUND_CORE_EDITION 6 /* * Declarations */ int dmasound_catchRadius = 0; -static unsigned int numWriteBufs = 4; -static unsigned int writeBufSize = 32; /* in KB! */ +static unsigned int numWriteBufs = DEFAULT_N_BUFFERS; +static unsigned int writeBufSize = DEFAULT_BUFF_SIZE ; /* in bytes */ #ifdef HAS_RECORD -static unsigned int numReadBufs = 4; -static unsigned int readBufSize = 32; /* in KB! */ +static unsigned int numReadBufs = DEFAULT_N_BUFFERS; +static unsigned int readBufSize = DEFAULT_BUFF_SIZE; /* in bytes */ #endif MODULE_PARM(dmasound_catchRadius, "i"); MODULE_PARM(numWriteBufs, "i"); MODULE_PARM(writeBufSize, "i"); +#ifdef HAS_RECORD MODULE_PARM(numReadBufs, "i"); MODULE_PARM(readBufSize, "i"); +#endif MODULE_LICENSE("GPL"); #ifdef MODULE @@ -144,246 +218,18 @@ static int irq_installed = 0; #endif /* MODULE */ +/* control over who can modify resources shared between play/record */ +static mode_t shared_resource_owner = 0 ; +static int shared_resources_initialised = 0 ; /* - * Conversion tables + * Common stuff */ -#ifdef HAS_8BIT_TABLES -/* 8 bit mu-law */ - -char dmasound_ulaw2dma8[] = { - -126, -122, -118, -114, -110, -106, -102, -98, - -94, -90, -86, -82, -78, -74, -70, -66, - -63, -61, -59, -57, -55, -53, -51, -49, - -47, -45, -43, -41, -39, -37, -35, -33, - -31, -30, -29, -28, -27, -26, -25, -24, - -23, -22, -21, -20, -19, -18, -17, -16, - -16, -15, -15, -14, -14, -13, -13, -12, - -12, -11, -11, -10, -10, -9, -9, -8, - -8, -8, -7, -7, -7, -7, -6, -6, - -6, -6, -5, -5, -5, -5, -4, -4, - -4, -4, -4, -4, -3, -3, -3, -3, - -3, -3, -3, -3, -2, -2, -2, -2, - -2, -2, -2, -2, -2, -2, -2, -2, - -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, 0, - 125, 121, 117, 113, 109, 105, 101, 97, - 93, 89, 85, 81, 77, 73, 69, 65, - 62, 60, 58, 56, 54, 52, 50, 48, - 46, 44, 42, 40, 38, 36, 34, 32, - 30, 29, 28, 27, 26, 25, 24, 23, - 22, 21, 20, 19, 18, 17, 16, 15, - 15, 14, 14, 13, 13, 12, 12, 11, - 11, 10, 10, 9, 9, 8, 8, 7, - 7, 7, 6, 6, 6, 6, 5, 5, - 5, 5, 4, 4, 4, 4, 3, 3, - 3, 3, 3, 3, 2, 2, 2, 2, - 2, 2, 2, 2, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0 -}; - -/* 8 bit A-law */ - -char dmasound_alaw2dma8[] = { - -22, -21, -24, -23, -18, -17, -20, -19, - -30, -29, -32, -31, -26, -25, -28, -27, - -11, -11, -12, -12, -9, -9, -10, -10, - -15, -15, -16, -16, -13, -13, -14, -14, - -86, -82, -94, -90, -70, -66, -78, -74, - -118, -114, -126, -122, -102, -98, -110, -106, - -43, -41, -47, -45, -35, -33, -39, -37, - -59, -57, -63, -61, -51, -49, -55, -53, - -2, -2, -2, -2, -2, -2, -2, -2, - -2, -2, -2, -2, -2, -2, -2, -2, - -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, - -6, -6, -6, -6, -5, -5, -5, -5, - -8, -8, -8, -8, -7, -7, -7, -7, - -3, -3, -3, -3, -3, -3, -3, -3, - -4, -4, -4, -4, -4, -4, -4, -4, - 21, 20, 23, 22, 17, 16, 19, 18, - 29, 28, 31, 30, 25, 24, 27, 26, - 10, 10, 11, 11, 8, 8, 9, 9, - 14, 14, 15, 15, 12, 12, 13, 13, - 86, 82, 94, 90, 70, 66, 78, 74, - 118, 114, 126, 122, 102, 98, 110, 106, - 43, 41, 47, 45, 35, 33, 39, 37, - 59, 57, 63, 61, 51, 49, 55, 53, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 5, 5, 5, 5, 4, 4, 4, 4, - 7, 7, 7, 7, 6, 6, 6, 6, - 2, 2, 2, 2, 2, 2, 2, 2, - 3, 3, 3, 3, 3, 3, 3, 3 -}; -#endif /* HAS_8BIT_TABLES */ - -#ifdef HAS_16BIT_TABLES - -/* 16 bit mu-law */ - -short dmasound_ulaw2dma16[] = { - -32124, -31100, -30076, -29052, -28028, -27004, -25980, -24956, - -23932, -22908, -21884, -20860, -19836, -18812, -17788, -16764, - -15996, -15484, -14972, -14460, -13948, -13436, -12924, -12412, - -11900, -11388, -10876, -10364, -9852, -9340, -8828, -8316, - -7932, -7676, -7420, -7164, -6908, -6652, -6396, -6140, - -5884, -5628, -5372, -5116, -4860, -4604, -4348, -4092, - -3900, -3772, -3644, -3516, -3388, -3260, -3132, -3004, - -2876, -2748, -2620, -2492, -2364, -2236, -2108, -1980, - -1884, -1820, -1756, -1692, -1628, -1564, -1500, -1436, - -1372, -1308, -1244, -1180, -1116, -1052, -988, -924, - -876, -844, -812, -780, -748, -716, -684, -652, - -620, -588, -556, -524, -492, -460, -428, -396, - -372, -356, -340, -324, -308, -292, -276, -260, - -244, -228, -212, -196, -180, -164, -148, -132, - -120, -112, -104, -96, -88, -80, -72, -64, - -56, -48, -40, -32, -24, -16, -8, 0, - 32124, 31100, 30076, 29052, 28028, 27004, 25980, 24956, - 23932, 22908, 21884, 20860, 19836, 18812, 17788, 16764, - 15996, 15484, 14972, 14460, 13948, 13436, 12924, 12412, - 11900, 11388, 10876, 10364, 9852, 9340, 8828, 8316, - 7932, 7676, 7420, 7164, 6908, 6652, 6396, 6140, - 5884, 5628, 5372, 5116, 4860, 4604, 4348, 4092, - 3900, 3772, 3644, 3516, 3388, 3260, 3132, 3004, - 2876, 2748, 2620, 2492, 2364, 2236, 2108, 1980, - 1884, 1820, 1756, 1692, 1628, 1564, 1500, 1436, - 1372, 1308, 1244, 1180, 1116, 1052, 988, 924, - 876, 844, 812, 780, 748, 716, 684, 652, - 620, 588, 556, 524, 492, 460, 428, 396, - 372, 356, 340, 324, 308, 292, 276, 260, - 244, 228, 212, 196, 180, 164, 148, 132, - 120, 112, 104, 96, 88, 80, 72, 64, - 56, 48, 40, 32, 24, 16, 8, 0, -}; - -/* 16 bit A-law */ - -short dmasound_alaw2dma16[] = { - -5504, -5248, -6016, -5760, -4480, -4224, -4992, -4736, - -7552, -7296, -8064, -7808, -6528, -6272, -7040, -6784, - -2752, -2624, -3008, -2880, -2240, -2112, -2496, -2368, - -3776, -3648, -4032, -3904, -3264, -3136, -3520, -3392, - -22016, -20992, -24064, -23040, -17920, -16896, -19968, -18944, - -30208, -29184, -32256, -31232, -26112, -25088, -28160, -27136, - -11008, -10496, -12032, -11520, -8960, -8448, -9984, -9472, - -15104, -14592, -16128, -15616, -13056, -12544, -14080, -13568, - -344, -328, -376, -360, -280, -264, -312, -296, - -472, -456, -504, -488, -408, -392, -440, -424, - -88, -72, -120, -104, -24, -8, -56, -40, - -216, -200, -248, -232, -152, -136, -184, -168, - -1376, -1312, -1504, -1440, -1120, -1056, -1248, -1184, - -1888, -1824, -2016, -1952, -1632, -1568, -1760, -1696, - -688, -656, -752, -720, -560, -528, -624, -592, - -944, -912, -1008, -976, -816, -784, -880, -848, - 5504, 5248, 6016, 5760, 4480, 4224, 4992, 4736, - 7552, 7296, 8064, 7808, 6528, 6272, 7040, 6784, - 2752, 2624, 3008, 2880, 2240, 2112, 2496, 2368, - 3776, 3648, 4032, 3904, 3264, 3136, 3520, 3392, - 22016, 20992, 24064, 23040, 17920, 16896, 19968, 18944, - 30208, 29184, 32256, 31232, 26112, 25088, 28160, 27136, - 11008, 10496, 12032, 11520, 8960, 8448, 9984, 9472, - 15104, 14592, 16128, 15616, 13056, 12544, 14080, 13568, - 344, 328, 376, 360, 280, 264, 312, 296, - 472, 456, 504, 488, 408, 392, 440, 424, - 88, 72, 120, 104, 24, 8, 56, 40, - 216, 200, 248, 232, 152, 136, 184, 168, - 1376, 1312, 1504, 1440, 1120, 1056, 1248, 1184, - 1888, 1824, 2016, 1952, 1632, 1568, 1760, 1696, - 688, 656, 752, 720, 560, 528, 624, 592, - 944, 912, 1008, 976, 816, 784, 880, 848, -}; -#endif /* HAS_16BIT_TABLES */ - - -#ifdef HAS_14BIT_TABLES - - /* - * Unused for now. Where are the MSB parts anyway?? - */ - -/* 14 bit mu-law (LSB) */ - -char dmasound_ulaw2dma14l[] = { - 33, 33, 33, 33, 33, 33, 33, 33, - 33, 33, 33, 33, 33, 33, 33, 33, - 33, 33, 33, 33, 33, 33, 33, 33, - 33, 33, 33, 33, 33, 33, 33, 33, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 49, 17, 49, 17, 49, 17, 49, 17, - 49, 17, 49, 17, 49, 17, 49, 17, - 41, 57, 9, 25, 41, 57, 9, 25, - 41, 57, 9, 25, 41, 57, 9, 25, - 37, 45, 53, 61, 5, 13, 21, 29, - 37, 45, 53, 61, 5, 13, 21, 29, - 35, 39, 43, 47, 51, 55, 59, 63, - 3, 7, 11, 15, 19, 23, 27, 31, - 34, 36, 38, 40, 42, 44, 46, 48, - 50, 52, 54, 56, 58, 60, 62, 0, - 31, 31, 31, 31, 31, 31, 31, 31, - 31, 31, 31, 31, 31, 31, 31, 31, - 31, 31, 31, 31, 31, 31, 31, 31, - 31, 31, 31, 31, 31, 31, 31, 31, - 63, 63, 63, 63, 63, 63, 63, 63, - 63, 63, 63, 63, 63, 63, 63, 63, - 15, 47, 15, 47, 15, 47, 15, 47, - 15, 47, 15, 47, 15, 47, 15, 47, - 23, 7, 55, 39, 23, 7, 55, 39, - 23, 7, 55, 39, 23, 7, 55, 39, - 27, 19, 11, 3, 59, 51, 43, 35, - 27, 19, 11, 3, 59, 51, 43, 35, - 29, 25, 21, 17, 13, 9, 5, 1, - 61, 57, 53, 49, 45, 41, 37, 33, - 30, 28, 26, 24, 22, 20, 18, 16, - 14, 12, 10, 8, 6, 4, 2, 0 -}; - -/* 14 bit A-law (LSB) */ - -char dmasound_alaw2dma14l[] = { - 32, 32, 32, 32, 32, 32, 32, 32, - 32, 32, 32, 32, 32, 32, 32, 32, - 16, 48, 16, 48, 16, 48, 16, 48, - 16, 48, 16, 48, 16, 48, 16, 48, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 42, 46, 34, 38, 58, 62, 50, 54, - 10, 14, 2, 6, 26, 30, 18, 22, - 42, 46, 34, 38, 58, 62, 50, 54, - 10, 14, 2, 6, 26, 30, 18, 22, - 40, 56, 8, 24, 40, 56, 8, 24, - 40, 56, 8, 24, 40, 56, 8, 24, - 20, 28, 4, 12, 52, 60, 36, 44, - 20, 28, 4, 12, 52, 60, 36, 44, - 32, 32, 32, 32, 32, 32, 32, 32, - 32, 32, 32, 32, 32, 32, 32, 32, - 48, 16, 48, 16, 48, 16, 48, 16, - 48, 16, 48, 16, 48, 16, 48, 16, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 22, 18, 30, 26, 6, 2, 14, 10, - 54, 50, 62, 58, 38, 34, 46, 42, - 22, 18, 30, 26, 6, 2, 14, 10, - 54, 50, 62, 58, 38, 34, 46, 42, - 24, 8, 56, 40, 24, 8, 56, 40, - 24, 8, 56, 40, 24, 8, 56, 40, - 44, 36, 60, 52, 12, 4, 28, 20, - 44, 36, 60, 52, 12, 4, 28, 20 -}; -#endif /* HAS_14BIT_TABLES */ - +static long long sound_lseek(struct file *file, long long offset, int orig) +{ + return -ESPIPE; +} /* * Mid level stuff @@ -393,15 +239,7 @@ static inline void sound_silence(void) { - /* update hardware settings one more */ - dmasound.mach.init(); - - dmasound.mach.silence(); -} - -static inline void sound_init(void) -{ - dmasound.mach.init(); + dmasound.mach.silence(); /* _MUST_ stop DMA */ } static inline int sound_set_format(int format) @@ -414,8 +252,17 @@ if (speed < 0) return dmasound.soft.speed; + /* trap out-of-range speed settings. + at present we allow (arbitrarily) low rates - using soft + up-conversion - but we can't allow > max because there is + no soft down-conversion. + */ + if (dmasound.mach.max_dsp_speed && + (speed > dmasound.mach.max_dsp_speed)) + speed = dmasound.mach.max_dsp_speed ; + dmasound.soft.speed = speed; - dmasound.mach.init(); + if (dmasound.minDev == SND_DEV_DSP) dmasound.dsp.speed = dmasound.soft.speed; @@ -432,7 +279,6 @@ dmasound.soft.stereo = stereo; if (dmasound.minDev == SND_DEV_DSP) dmasound.dsp.stereo = stereo; - dmasound.mach.init(); return stereo; } @@ -471,10 +317,14 @@ default: return 0; } - return ct_func(userPtr, userCount, frame, frameUsed, frameLeft); + /* if the user has requested a non-existent translation don't try + to call it but just return 0 bytes moved + */ + if (ct_func) + return ct_func(userPtr, userCount, frame, frameUsed, frameLeft); + return 0; } - /* * /dev/mixer abstraction */ @@ -559,6 +409,11 @@ struct sound_queue dmasound_read_sq; #endif +static void sq_reset_output(void) ; +#ifdef HAS_RECORD +static void sq_reset_input(void) ; +#endif + static int sq_allocate_buffers(struct sound_queue *sq, int num, int size) { int i; @@ -588,8 +443,6 @@ int i; if (sq->buffers) { - if (sq != &write_sq && dmasound.mach.abort_read) - dmasound.mach.abort_read(); for (i = 0; i < sq->numBufs; i++) dmasound.mach.dma_free(sq->buffers[i], sq->bufSize); kfree(sq->buffers); @@ -597,15 +450,84 @@ } } -static void sq_setup(struct sound_queue *sq, int max_count, int max_active, - int block_size) + +static int sq_setup(struct sound_queue *sq) { - void (*setup_func)(void); + int (*setup_func)(void); + int hard_frame ; + + if (sq->locked) { /* are we already set? - and not changeable */ +#ifdef DEBUG_DMASOUND +printk("dmasound_core: tried to sq_setup a locked queue\n") ; +#endif + return -EINVAL ; + } + sq->locked = 1 ; /* don't think we have a race prob. here _check_ */ - sq->max_count = max_count; - sq->max_active = max_active; - sq->block_size = block_size; + /* make sure that the parameters are set up + This should have been done already... + */ + + dmasound.mach.init(); + /* OK. If the user has set fragment parameters explicitly, then we + should leave them alone... as long as they are valid. + Invalid user fragment params can occur if we allow the whole buffer + to be used when the user requests the fragments sizes (with no soft + x-lation) and then the user subsequently sets a soft x-lation that + requires increased internal buffering. + + Othwerwise (if the user did not set them) OSS says that we should + select frag params on the basis of 0.5 s output & 0.1 s input + latency. (TODO. For now we will copy in the defaults.) + */ + + if (sq->user_frags <= 0) { + sq->max_count = sq->numBufs ; + sq->max_active = sq->numBufs ; + sq->block_size = sq->bufSize; + /* set up the user info */ + sq->user_frags = sq->numBufs ; + sq->user_frag_size = sq->bufSize ; + sq->user_frag_size *= + (dmasound.soft.size * (dmasound.soft.stereo+1) ) ; + sq->user_frag_size /= + (dmasound.hard.size * (dmasound.hard.stereo+1) ) ; + } else { + /* work out requested block size */ + sq->block_size = sq->user_frag_size ; + sq->block_size *= + (dmasound.hard.size * (dmasound.hard.stereo+1) ) ; + sq->block_size /= + (dmasound.soft.size * (dmasound.soft.stereo+1) ) ; + /* the user wants to write frag-size chunks */ + sq->block_size *= dmasound.hard.speed ; + sq->block_size /= dmasound.soft.speed ; + /* this only works for size values which are powers of 2 */ + hard_frame = + (dmasound.hard.size * (dmasound.hard.stereo+1))/8 ; + sq->block_size += (hard_frame - 1) ; + sq->block_size &= ~(hard_frame - 1) ; /* make sure we are aligned */ + /* let's just check for obvious mistakes */ + if ( sq->block_size <= 0 || sq->block_size > sq->bufSize) { +#ifdef DEBUG_DMASOUND +printk("dmasound_core: invalid frag size (user set %d)\n", sq->user_frag_size) ; +#endif + sq->block_size = sq->bufSize ; + } + if ( sq->user_frags <= sq->numBufs ) { + sq->max_count = sq->user_frags ; + /* if user has set max_active - then use it */ + sq->max_active = (sq->max_active <= sq->max_count) ? + sq->max_active : sq->max_count ; + } else { +#ifdef DEBUG_DMASOUND +printk("dmasound_core: invalid frag count (user set %d)\n", sq->user_frags) ; +#endif + sq->max_count = + sq->max_active = sq->numBufs ; + } + } sq->front = sq->count = sq->rear_size = 0; sq->syncing = 0; sq->active = 0; @@ -613,12 +535,16 @@ if (sq == &write_sq) { sq->rear = -1; setup_func = dmasound.mach.write_sq_setup; - } else { + } +#ifdef HAS_RECORD + else { sq->rear = 0; setup_func = dmasound.mach.read_sq_setup; } +#endif if (setup_func) - setup_func(); + return setup_func(); + return 0 ; } static inline void sq_play(void) @@ -632,6 +558,7 @@ ssize_t uWritten = 0; u_char *dest; ssize_t uUsed, bUsed, bLeft; + unsigned long flags ; /* ++TeSche: Is something like this necessary? * Hey, that's an honest question! Or does any other part of the @@ -640,11 +567,52 @@ if (uLeft == 0) return 0; + /* implement any changes we have made to the soft/hard params. + this is not satisfactory really, all we have done up to now is to + say what we would like - there hasn't been any real checking of capability + */ + + if (shared_resources_initialised == 0) { + dmasound.mach.init() ; + shared_resources_initialised = 1 ; + } + + /* set up the sq if it is not already done. This may seem a dumb place + to do it - but it is what OSS requires. It means that write() can + return memory allocation errors. To avoid this possibility use the + GETBLKSIZE or GETOSPACE ioctls (after you've fiddled with all the + params you want to change) - these ioctls also force the setup. + */ + + if (write_sq.locked == 0) { + if ((uWritten = sq_setup(&write_sq)) < 0) return uWritten ; + uWritten = 0 ; + } + +/* FIXME: I think that this may be the wrong behaviour when we get strapped + for time and the cpu is close to being (or actually) behind in sending data. + - because we've lost the time that the N samples, already in the buffer, + would have given us to get here with the next lot from the user. +*/ /* The interrupt doesn't start to play the last, incomplete frame. * Thus we can append to it without disabling the interrupts! (Note * also that write_sq.rear isn't affected by the interrupt.) */ + /* as of 1.6 this behaviour changes if SNDCTL_DSP_POST has been issued: + this will mimic the behaviour of syncing and allow the sq_play() to + queue a partial fragment. Since sq_play() may/will be called from + the IRQ handler - at least on Pmac we have to deal with it. + The strategy - possibly not optimum - is to kill _POST status if we + get here. This seems, at least, reasonable - in the sense that POST + is supposed to indicate that we might not write before the queue + is drained - and if we get here in time then it does not apply. + */ + + save_flags(flags) ; cli() ; + write_sq.syncing &= ~2 ; /* take out POST status */ + restore_flags(flags) ; + if (write_sq.count > 0 && (bLeft = write_sq.block_size-write_sq.rear_size) > 0) { dest = write_sq.buffers[write_sq.rear]; @@ -655,12 +623,12 @@ return uUsed; src += uUsed; uWritten += uUsed; - uLeft -= uUsed; + uLeft = (uUsed <= uLeft) ? (uLeft - uUsed) : 0 ; /* paranoia */ write_sq.rear_size = bUsed; } - do { - while (write_sq.count == write_sq.max_active) { + while (uLeft) { + while (write_sq.count >= write_sq.max_active) { sq_play(); if (write_sq.open_mode & O_NONBLOCK) return uWritten > 0 ? uWritten : -EAGAIN; @@ -685,19 +653,45 @@ break; src += uUsed; uWritten += uUsed; - uLeft -= uUsed; + uLeft = (uUsed <= uLeft) ? (uLeft - uUsed) : 0 ; /* paranoia */ if (bUsed) { write_sq.rear = (write_sq.rear+1) % write_sq.max_count; write_sq.rear_size = bUsed; write_sq.count++; } - } while (bUsed); /* uUsed may have been 0 */ + } /* uUsed may have been 0 */ sq_play(); return uUsed < 0? uUsed: uWritten; } +static unsigned int sq_poll(struct file *file, struct poll_table_struct *wait) +{ + unsigned int mask = 0; + int retVal; + + if (write_sq.locked == 0) { + if ((retVal = sq_setup(&write_sq)) < 0) + return retVal; + return 0; + } + if (file->f_mode & FMODE_WRITE ) + poll_wait(file, &write_sq.action_queue, wait); +#ifdef HAS_RECORD + if (file->f_mode & FMODE_READ) + poll_wait(file, &read_sq.action_queue, wait); + if (file->f_mode & FMODE_READ) + if (read_sq.block_size - read_sq.rear_size > 0) + mask |= POLLIN | POLLRDNORM; +#endif + if (file->f_mode & FMODE_WRITE) + if (write_sq.count < write_sq.max_active || write_sq.block_size - write_sq.rear_size > 0) + mask |= POLLOUT | POLLWRNORM; + return mask; + +} + #ifdef HAS_RECORD /* * Here is how the values are used for reading. @@ -707,9 +701,12 @@ * The value 'rear' indicates the buffer the DMA is currently filling. * When 'front' == 'rear' the buffer "ring" is empty (we always have an * empty available). The 'rear_size' is used to track partial offsets - * into the current buffer. Right now, I just keep the DMA running. If - * the reader can't keep up, the interrupt tosses the oldest buffer. We - * could also shut down the DMA in this case. + * into the buffer we are currently returning to the user. + + * This level (> [1.5]) doesn't care what strategy the LL driver uses with + * DMA on over-run. It can leave it running (and keep active == 1) or it + * can kill it and set active == 0 in which case this routine will spot + * it and restart the DMA. */ static ssize_t sq_read(struct file *file, char *dst, size_t uLeft, @@ -721,8 +718,25 @@ if (uLeft == 0) return 0; - if (!read_sq.active && dmasound.mach.record) - dmasound.mach.record(); /* Kick off the record process. */ + /* cater for the compatibility mode - record compiled in but no LL */ + if (dmasound.mach.record == NULL) + return -EINVAL ; + + /* see comment in sq_write() + */ + + if( shared_resources_initialised == 0) { + dmasound.mach.init() ; + shared_resources_initialised = 1 ; + } + + /* set up the sq if it is not already done. see comments in sq_write(). + */ + + if (read_sq.locked == 0) { + if ((uRead = sq_setup(&read_sq)) < 0) + return uRead ; + } uRead = 0; @@ -730,6 +744,13 @@ */ while (uLeft > 0) { + /* we happened to get behind and the LL driver killed DMA + then we should set it going again. This also sets it + going the first time through. + */ + if ( !read_sq.active ) + dmasound.mach.record(); + /* When front == rear, the DMA is not done yet. */ while (read_sq.front == read_sq.rear) { @@ -774,14 +795,16 @@ sq->busy = 0; } +#if 0 /* blocking open() */ static inline void sq_wake_up(struct sound_queue *sq, struct file *file, mode_t mode) { if (file->f_mode & mode) { - sq->busy = 0; + sq->busy = 0; /* CHECK: IS THIS OK??? */ WAKE_UP(sq->open_queue); } } +#endif static int sq_open2(struct sound_queue *sq, struct file *file, mode_t mode, int numbufs, int bufsize) @@ -790,6 +813,7 @@ if (file->f_mode & mode) { if (sq->busy) { +#if 0 /* blocking open() */ rc = -EBUSY; if (file->f_flags & O_NONBLOCK) return rc; @@ -800,84 +824,188 @@ return rc; } rc = 0; +#else + /* OSS manual says we will return EBUSY regardless + of O_NOBLOCK. + */ + return -EBUSY ; +#endif } sq->busy = 1; /* Let's play spot-the-race-condition */ - if (sq_allocate_buffers(sq, numbufs, bufsize)) { + /* allocate the default number & size of buffers. + (i.e. specified in _setup() or as module params) + can't be changed at the moment - but _could_ be perhaps + in the setfragments ioctl. + */ + if (( rc = sq_allocate_buffers(sq, numbufs, bufsize))) { +#if 0 /* blocking open() */ sq_wake_up(sq, file, mode); +#else + sq->busy = 0 ; +#endif return rc; } - sq_setup(sq, numbufs, numbufs, bufsize); sq->open_mode = file->f_mode; } return rc; } #define write_sq_init_waitqueue() sq_init_waitqueue(&write_sq) +#if 0 /* blocking open() */ #define write_sq_wake_up(file) sq_wake_up(&write_sq, file, FMODE_WRITE) +#endif #define write_sq_release_buffers() sq_release_buffers(&write_sq) #define write_sq_open(file) \ - sq_open2(&write_sq, file, FMODE_WRITE, numWriteBufs, writeBufSize << 10) + sq_open2(&write_sq, file, FMODE_WRITE, numWriteBufs, writeBufSize ) #ifdef HAS_RECORD #define read_sq_init_waitqueue() sq_init_waitqueue(&read_sq) +#if 0 /* blocking open() */ #define read_sq_wake_up(file) sq_wake_up(&read_sq, file, FMODE_READ) +#endif #define read_sq_release_buffers() sq_release_buffers(&read_sq) #define read_sq_open(file) \ - sq_open2(&read_sq, file, FMODE_READ, numReadBufs, readBufSize << 10) -#else /* !HAS_RECORD */ -#define read_sq_init_waitqueue() do {} while (0) -#define read_sq_wake_up(file) do {} while (0) -#define read_sq_release_buffers() do {} while (0) -#define read_sq_open(file) (0) -#endif /* !HAS_RECORD */ + sq_open2(&read_sq, file, FMODE_READ, numReadBufs, readBufSize ) +#endif static int sq_open(struct inode *inode, struct file *file) { int rc; dmasound.mach.open(); - if ((rc = write_sq_open(file)) || (rc = read_sq_open(file))) { + + if ((rc = write_sq_open(file))) { /* checks the f_mode */ dmasound.mach.release(); return rc; } +#ifdef HAS_RECORD + if (dmasound.mach.record) { + if ((rc = read_sq_open(file))) { /* checks the f_mode */ + dmasound.mach.release(); + return rc; + } + } else { /* no record function installed; in compat mode */ + if (file->f_mode & FMODE_READ) { + /* TODO: if O_RDWR, release any resources grabbed by write part */ + dmasound.mach.release() ; + /* I think this is what is required by open(2) */ + return -ENXIO ; + } + } +#else /* !HAS_RECORD */ + if (file->f_mode & FMODE_READ) { + /* TODO: if O_RDWR, release any resources grabbed by write part */ + dmasound.mach.release() ; + return -ENXIO ; /* I think this is what is required by open(2) */ + } +#endif /* HAS_RECORD */ if (dmasound.mach.sq_open) - dmasound.mach.sq_open(); + dmasound.mach.sq_open(file->f_mode); + + /* CHECK whether this is sensible - in the case that dsp0 could be opened + O_RDONLY and dsp1 could be opened O_WRONLY + */ + dmasound.minDev = MINOR(inode->i_rdev) & 0x0f; - dmasound.soft = dmasound.dsp; - dmasound.hard = dmasound.dsp; - sound_init(); - if ((MINOR(inode->i_rdev) & 0x0f) == SND_DEV_AUDIO) { + + /* OK. - we should make some attempt at consistency. At least the H'ware + options should be set with a valid mode. We will make it that the LL + driver must supply defaults for hard & soft params. + */ + + if (shared_resource_owner == 0) { + /* you can make this AFMT_U8/mono/8K if you want to mimic old + OSS behaviour - while we still have soft translations ;-) */ + dmasound.soft = dmasound.mach.default_soft ; + dmasound.dsp = dmasound.mach.default_soft ; + dmasound.hard = dmasound.mach.default_hard ; + } + +#ifndef DMASOUND_STRICT_OSS_COMPLIANCE + /* none of the current LL drivers can actually do this "native" at the moment + OSS does not really require us to supply /dev/audio if we can't do it. + */ + if (dmasound.minDev == SND_DEV_AUDIO) { sound_set_speed(8000); sound_set_stereo(0); sound_set_format(AFMT_MU_LAW); } - -#if 0 - if (file->f_mode == FMODE_READ && dmasound.mach.record) { - /* Start dma'ing straight away */ - dmasound.mach.record(); - } #endif return 0; } -static void sq_reset(void) +static void sq_reset_output(void) { - sound_silence(); + sound_silence(); /* this _must_ stop DMA, we might be about to lose the buffers */ write_sq.active = 0; write_sq.count = 0; - write_sq.front = (write_sq.rear+1) % write_sq.max_count; + write_sq.rear_size = 0; + /* write_sq.front = (write_sq.rear+1) % write_sq.max_count;*/ + write_sq.front = 0 ; + write_sq.rear = -1 ; /* same as for set-up */ + + /* OK - we can unlock the parameters and fragment settings */ + write_sq.locked = 0 ; + write_sq.user_frags = 0 ; + write_sq.user_frag_size = 0 ; +} + +#ifdef HAS_RECORD + +static void sq_reset_input(void) +{ + if (dmasound.mach.record && read_sq.active) { + if (dmasound.mach.abort_read) { /* this routine must really be present */ + read_sq.syncing = 1 ; + /* this can use the read_sq.sync_queue to sleep if + necessary - it should not return until DMA + is really stopped - because we might deallocate + the buffers as the next action... + */ + dmasound.mach.abort_read() ; + } else { + printk(KERN_ERR + "dmasound_core: %s has no abort_read()!! all bets are off\n", + dmasound.mach.name) ; + } + } + read_sq.syncing = + read_sq.active = + read_sq.front = + read_sq.count = + read_sq.rear = 0 ; + + /* OK - we can unlock the parameters and fragment settings */ + read_sq.locked = 0 ; + read_sq.user_frags = 0 ; + read_sq.user_frag_size = 0 ; +} + +#endif + +static void sq_reset(void) +{ + sq_reset_output() ; +#ifdef HAS_RECORD + sq_reset_input() ; +#endif + /* we could consider resetting the shared_resources_owner here... but I + think it is probably still rather non-obvious to application writer + */ + + /* we release everything else though */ + shared_resources_initialised = 0 ; } static int sq_fsync(struct file *filp, struct dentry *dentry) { int rc = 0; - write_sq.syncing = 1; + write_sq.syncing |= 1; sq_play(); /* there may be an incomplete frame waiting */ while (write_sq.active) { @@ -886,13 +1014,14 @@ /* While waiting for audio output to drain, an * interrupt occurred. Stop audio output immediately * and clear the queue. */ - sq_reset(); + sq_reset_output(); rc = -EINTR; break; } } - write_sq.syncing = 0; + /* flag no sync regardless of whether we had a DSP_POST or not */ + write_sq.syncing = 0 ; return rc; } @@ -901,33 +1030,132 @@ int rc = 0; lock_kernel(); - if (write_sq.busy) - rc = sq_fsync(file, file->f_dentry); - dmasound.soft = dmasound.dsp; - dmasound.hard = dmasound.dsp; - sound_silence(); - write_sq_release_buffers(); - read_sq_release_buffers(); - dmasound.mach.release(); +#ifdef HAS_RECORD + /* probably best to do the read side first - so that time taken to do it + overlaps with playing any remaining output samples. + */ + if (file->f_mode & FMODE_READ) { + sq_reset_input() ; /* make sure dma is stopped and all is quiet */ + read_sq_release_buffers(); + read_sq.busy = 0; + } +#endif - /* There is probably a DOS atack here. They change the mode flag. */ - /* XXX add check here */ - read_sq_wake_up(file); - write_sq_wake_up(file); + if (file->f_mode & FMODE_WRITE) { + if (write_sq.busy) + rc = sq_fsync(file, file->f_dentry); + + sq_reset_output() ; /* make sure dma is stopped and all is quiet */ + write_sq_release_buffers(); + write_sq.busy = 0; + } + + if (file->f_mode & shared_resource_owner) { /* it's us that has them */ + shared_resource_owner = 0 ; + shared_resources_initialised = 0 ; + dmasound.hard = dmasound.mach.default_hard ; + } + + dmasound.mach.release(); +#if 0 /* blocking open() */ /* Wake up a process waiting for the queue being released. * Note: There may be several processes waiting for a call * to open() returning. */ + + /* Iain: hmm I don't understand this next comment ... */ + /* There is probably a DOS atack here. They change the mode flag. */ + /* XXX add check here,*/ +#ifdef HAS_RECORD + read_sq_wake_up(file); /* checks f_mode */ +#endif + write_sq_wake_up(file); /* checks f_mode */ +#endif /* blocking open() */ + unlock_kernel(); return rc; } +/* here we see if we have a right to modify format, channels, size and so on + if no-one else has claimed it already then we do... + + TODO: We might change this to mask O_RDWR such that only one or the other channel + is the owner - if we have problems. +*/ + +static int shared_resources_are_mine(mode_t md) +{ + if (shared_resource_owner) + return (shared_resource_owner & md ) ; + else { + shared_resource_owner = md ; + return 1 ; + } +} + +/* if either queue is locked we must deny the right to change shared params +*/ + +static int queues_are_quiescent(void) +{ +#ifdef HAS_RECORD + if (dmasound.mach.record) + if (read_sq.locked) + return 0 ; +#endif + if (write_sq.locked) + return 0 ; + return 1 ; +} + +/* check and set a queue's fragments per user's wishes... + we will check against the pre-defined literals and the actual sizes. + This is a bit fraught - because soft translations can mess with our + buffer requirements *after* this call - OSS says "call setfrags first" +*/ + +/* It is possible to replace all the -EINVAL returns with an override that + just puts the allowable value in. This may be what many OSS apps require +*/ + +static int set_queue_frags(struct sound_queue *sq, int bufs, int size) +{ + if (sq->locked) { +#ifdef DEBUG_DMASOUND +printk("dmasound_core: tried to set_queue_frags on a locked queue\n") ; +#endif + return -EINVAL ; + } + + if ((size < MIN_FRAG_SIZE) || (size > MAX_FRAG_SIZE)) + return -EINVAL ; + size = (1<<size) ; /* now in bytes */ + if (size > sq->bufSize) + return -EINVAL ; /* this might still not work */ + + if (bufs <= 0) + return -EINVAL ; + if (bufs > sq->numBufs) /* the user is allowed say "don't care" with 0x7fff */ + bufs = sq->numBufs ; + + /* there is, currently, no way to specify max_active separately + from max_count. This could be a LL driver issue - I guess + if there is a requirement for these values to be different then + we will have to pass that info. up to this level. + */ + sq->user_frags = + sq->max_active = bufs ; + sq->user_frag_size = size ; + + return 0 ; +} + static int sq_ioctl(struct inode *inode, struct file *file, u_int cmd, u_long arg) { - int val; + int val, result; u_long fmt; int data; int size, nbufs; @@ -937,85 +1165,167 @@ case SNDCTL_DSP_RESET: sq_reset(); return 0; + break ; + case SNDCTL_DSP_GETFMTS: + fmt = dmasound.mach.hardware_afmts ; /* this is what OSS says.. */ + return IOCTL_OUT(arg, fmt); + break ; + case SNDCTL_DSP_GETBLKSIZE: + /* this should tell the caller about bytes that the app can + read/write - the app doesn't care about our internal buffers. + We force sq_setup() here as per OSS 1.1 (which should + compute the values necessary). + Since there is no mechanism to specify read/write separately, for + fds opened O_RDWR, the write_sq values will, arbitrarily, overwrite + the read_sq ones. + */ + size = 0 ; +#ifdef HAS_RECORD + if (dmasound.mach.record && (file->f_mode & FMODE_READ)) { + if ( !read_sq.locked ) + sq_setup(&read_sq) ; /* set params */ + size = read_sq.user_frag_size ; + } +#endif + if (file->f_mode & FMODE_WRITE) { + if ( !write_sq.locked ) + sq_setup(&write_sq) ; + size = write_sq.user_frag_size ; + } + return IOCTL_OUT(arg, size); + break ; case SNDCTL_DSP_POST: + /* all we are going to do is to tell the LL that any + partial frags can be queued for output. + The LL will have to clear this flag when last output + is queued. + */ + write_sq.syncing |= 0x2 ; + sq_play() ; + return 0 ; case SNDCTL_DSP_SYNC: - return sq_fsync(file, file->f_dentry); - - /* ++TeSche: before changing any of these it's - * probably wise to wait until sound playing has - * settled down. */ + /* This call, effectively, has the same behaviour as SNDCTL_DSP_RESET + except that it waits for output to finish before resetting + everything - read, however, is killed imediately. + */ + result = 0 ; +#ifdef HAS_RECORD + if ((file->f_mode & FMODE_READ) && dmasound.mach.record) + sq_reset_input() ; +#endif + if (file->f_mode & FMODE_WRITE) { + result = sq_fsync(file, file->f_dentry); + sq_reset_output() ; + } + /* if we are the shared resource owner then release them */ + if (file->f_mode & shared_resource_owner) + shared_resources_initialised = 0 ; + return result ; + break ; case SNDCTL_DSP_SPEED: - sq_fsync(file, file->f_dentry); - IOCTL_IN(arg, data); - return IOCTL_OUT(arg, sound_set_speed(data)); + /* changing this on the fly will have wierd effects on the sound. + Where there are rate conversions implemented in soft form - it + will cause the _ctx_xxx() functions to be substituted. + However, there doesn't appear to be any reason to dis-allow it from + a driver pov. + */ + if (shared_resources_are_mine(file->f_mode)) { + IOCTL_IN(arg, data); + data = sound_set_speed(data) ; + shared_resources_initialised = 0 ; + return IOCTL_OUT(arg, data); + } else + return -EINVAL ; + break ; + /* OSS says these next 4 actions are undefined when the device is + busy/active - we will just return -EINVAL. + To be allowed to change one - (a) you have to own the right + (b) the queue(s) must be quiescent + */ case SNDCTL_DSP_STEREO: - sq_fsync(file, file->f_dentry); - IOCTL_IN(arg, data); - return IOCTL_OUT(arg, sound_set_stereo(data)); + if (shared_resources_are_mine(file->f_mode) && + queues_are_quiescent()) { + IOCTL_IN(arg, data); + shared_resources_initialised = 0 ; + return IOCTL_OUT(arg, sound_set_stereo(data)); + } else + return -EINVAL ; + break ; case SOUND_PCM_WRITE_CHANNELS: - sq_fsync(file, file->f_dentry); - IOCTL_IN(arg, data); - return IOCTL_OUT(arg, sound_set_stereo(data-1)+1); + if (shared_resources_are_mine(file->f_mode) && + queues_are_quiescent()) { + IOCTL_IN(arg, data); + /* the user might ask for 20 channels, we will return 1 or 2 */ + shared_resources_initialised = 0 ; + return IOCTL_OUT(arg, sound_set_stereo(data-1)+1); + } else + return -EINVAL ; + break ; case SNDCTL_DSP_SETFMT: - sq_fsync(file, file->f_dentry); - IOCTL_IN(arg, data); - return IOCTL_OUT(arg, sound_set_format(data)); - case SNDCTL_DSP_GETFMTS: - fmt = 0; - if (dmasound.trans_write) { - if (dmasound.trans_write->ct_ulaw) - fmt |= AFMT_MU_LAW; - if (dmasound.trans_write->ct_alaw) - fmt |= AFMT_A_LAW; - if (dmasound.trans_write->ct_s8) - fmt |= AFMT_S8; - if (dmasound.trans_write->ct_u8) - fmt |= AFMT_U8; - if (dmasound.trans_write->ct_s16be) - fmt |= AFMT_S16_BE; - if (dmasound.trans_write->ct_u16be) - fmt |= AFMT_U16_BE; - if (dmasound.trans_write->ct_s16le) - fmt |= AFMT_S16_LE; - if (dmasound.trans_write->ct_u16le) - fmt |= AFMT_U16_LE; - } - return IOCTL_OUT(arg, fmt); - case SNDCTL_DSP_GETBLKSIZE: - size = write_sq.block_size - * dmasound.soft.size * (dmasound.soft.stereo + 1) - / (dmasound.hard.size * (dmasound.hard.stereo + 1)); - return IOCTL_OUT(arg, size); + if (shared_resources_are_mine(file->f_mode) && + queues_are_quiescent()) { + int format; + IOCTL_IN(arg, data); + shared_resources_initialised = 0 ; + format = sound_set_format(data); + result = IOCTL_OUT(arg, format); + if (result < 0) + return result; + if (format != data) + return -EINVAL; + return 0; + } else + return -EINVAL ; + break ; case SNDCTL_DSP_SUBDIVIDE: + return -EINVAL ; break; case SNDCTL_DSP_SETFRAGMENT: - if (write_sq.count || write_sq.active || write_sq.syncing) - return -EINVAL; - IOCTL_IN(arg, size); - nbufs = size >> 16; - if (nbufs < 2 || nbufs > write_sq.numBufs) - nbufs = write_sq.numBufs; - size &= 0xffff; - if (size >= 8 && size <= 29) { - size = 1 << size; - size *= dmasound.hard.size * (dmasound.hard.stereo + 1); - size /= dmasound.soft.size * (dmasound.soft.stereo + 1); - if (size > write_sq.bufSize) - size = write_sq.bufSize; - } else - size = write_sq.bufSize; - sq_setup(&write_sq, write_sq.numBufs, nbufs, size); - return IOCTL_OUT(arg,write_sq.bufSize | write_sq.numBufs << 16); + /* we can do this independently for the two queues - with the + proviso that for fds opened O_RDWR we cannot separate the + actions and both queues will be set per the last call. + NOTE: this does *NOT* actually set the queue up - merely + registers our intentions. + */ + IOCTL_IN(arg, data); + result = 0 ; + nbufs = (data >> 16) & 0x7fff ; /* 0x7fff is 'use maximum' */ + size = data & 0xffff; +#ifdef HAS_RECORD + if ((file->f_mode & FMODE_READ) && dmasound.mach.record) { + result = set_queue_frags(&read_sq, nbufs, size) ; + if (result) + return result ; + } +#endif + if (file->f_mode & FMODE_WRITE) { + result = set_queue_frags(&write_sq, nbufs, size) ; + if (result) + return result ; + } + /* NOTE: this return value is irrelevant - OSS specifically says that + the value is 'random' and that the user _must_ check the actual + frags values using SNDCTL_DSP_GETBLKSIZE or similar */ + return IOCTL_OUT(arg, data); + break ; case SNDCTL_DSP_GETOSPACE: - info.fragments = write_sq.max_active - write_sq.count; - info.fragstotal = write_sq.max_active; - info.fragsize = write_sq.block_size; - info.bytes = info.fragments * info.fragsize; - if (copy_to_user((void *)arg, &info, sizeof(info))) - return -EFAULT; - return 0; + /* + */ + if (file->f_mode & FMODE_WRITE) { + if ( !write_sq.locked ) + sq_setup(&write_sq) ; + info.fragments = write_sq.max_active - write_sq.count; + info.fragstotal = write_sq.max_active; + info.fragsize = write_sq.user_frag_size; + info.bytes = info.fragments * info.fragsize; + if (copy_to_user((void *)arg, &info, sizeof(info))) + return -EFAULT; + return 0; + } else + return -EINVAL ; + break ; case SNDCTL_DSP_GETCAPS: - val = 1; /* Revision level of this ioctl() */ + val = dmasound.mach.capabilities & 0xffffff00; return IOCTL_OUT(arg,val); default: @@ -1029,42 +1339,48 @@ owner: THIS_MODULE, llseek: no_llseek, write: sq_write, + poll: sq_poll, ioctl: sq_ioctl, open: sq_open, release: sq_release, #ifdef HAS_RECORD - read: sq_read, + read: NULL /* default to no read for compat mode */ #endif }; -static void __init sq_init(void) +static int __init sq_init(void) { #ifndef MODULE int sq_unit; #endif + +#ifdef HAS_RECORD + if (dmasound.mach.record) + sq_fops.read = sq_read ; +#endif sq_unit = register_sound_dsp(&sq_fops, -1); - if (sq_unit < 0) - return; + if (sq_unit < 0) { + printk(KERN_ERR "dmasound_core: couldn't register fops\n") ; + return sq_unit ; + } write_sq_init_waitqueue(); +#ifdef HAS_RECORD read_sq_init_waitqueue(); +#endif - /* whatever you like as startup mode for /dev/dsp, - * (/dev/audio hasn't got a startup mode). note that - * once changed a new open() will *not* restore these! + /* These parameters will be restored for every clean open() + * in the case of multiple open()s (e.g. dsp0 & dsp1) they + * will be set so long as the shared resources have no owner. */ - dmasound.dsp.format = AFMT_U8; - dmasound.dsp.stereo = 0; - dmasound.dsp.size = 8; - - /* set minimum rate possible without expanding */ - dmasound.dsp.speed = dmasound.mach.min_dsp_speed; - - /* before the first open to /dev/dsp this wouldn't be set */ - dmasound.soft = dmasound.dsp; - dmasound.hard = dmasound.dsp; - sound_silence(); + if (shared_resource_owner == 0) { + dmasound.soft = dmasound.mach.default_soft ; + dmasound.hard = dmasound.mach.default_hard ; + dmasound.dsp = dmasound.mach.default_soft ; + shared_resources_initialised = 0 ; + } + return 0 ; } @@ -1072,12 +1388,68 @@ * /dev/sndstat */ +/* we allow more space for record-enabled because there are extra output lines. + the number here must include the amount we are prepared to give to the low-level + driver. +*/ + +#ifdef HAS_RECORD +#define STAT_BUFF_LEN 1024 +#else +#define STAT_BUFF_LEN 768 +#endif + +/* this is how much space we will allow the low-level driver to use + in the stat buffer. Currently, 2 * (80 character line + <NL>). + We do not police this (it is up to the ll driver to be honest). +*/ + +#define LOW_LEVEL_STAT_ALLOC 162 + static struct { int busy; - char buf[512]; /* state.buf should not overflow! */ + char buf[STAT_BUFF_LEN]; /* state.buf should not overflow! */ int len, ptr; } state; +/* publish this function for use by low-level code, if required */ + +char *get_afmt_string(int afmt) +{ + switch(afmt) { + case AFMT_MU_LAW: + return "mu-law"; + break; + case AFMT_A_LAW: + return "A-law"; + break; + case AFMT_U8: + return "unsigned 8 bit"; + break; + case AFMT_S8: + return "signed 8 bit"; + break; + case AFMT_S16_BE: + return "signed 16 bit BE"; + break; + case AFMT_U16_BE: + return "unsigned 16 bit BE"; + break; + case AFMT_S16_LE: + return "signed 16 bit LE"; + break; + case AFMT_U16_LE: + return "unsigned 16 bit LE"; + break; + case 0: + return "format not set" ; + break ; + default: + break ; + } + return "ERROR: Unsupported AFMT_XXXX code" ; +} + static int state_open(struct inode *inode, struct file *file) { char *buffer = state.buf; @@ -1090,52 +1462,76 @@ state.ptr = 0; state.busy = 1; - len += sprintf(buffer+len, "%sDMA sound driver:\n", dmasound.mach.name); + len += sprintf(buffer+len, "%sDMA sound driver rev %03d :\n", + dmasound.mach.name, (DMASOUND_CORE_REVISION<<4) + + ((dmasound.mach.version>>8) & 0x0f)); + len += sprintf(buffer+len, + "Core driver edition %02d.%02d : %s driver edition %02d.%02d\n", + DMASOUND_CORE_REVISION, DMASOUND_CORE_EDITION, dmasound.mach.name2, + (dmasound.mach.version >> 8), (dmasound.mach.version & 0xff)) ; + + /* call the low-level module to fill in any stat info. that it has + if present. Maximum buffer usage is specified. + */ - len += sprintf(buffer+len, "\tsound.format = 0x%x", - dmasound.soft.format); - switch (dmasound.soft.format) { - case AFMT_MU_LAW: - len += sprintf(buffer+len, " (mu-law)"); - break; - case AFMT_A_LAW: - len += sprintf(buffer+len, " (A-law)"); - break; - case AFMT_U8: - len += sprintf(buffer+len, " (unsigned 8 bit)"); - break; - case AFMT_S8: - len += sprintf(buffer+len, " (signed 8 bit)"); - break; - case AFMT_S16_BE: - len += sprintf(buffer+len, " (signed 16 bit big)"); - break; - case AFMT_U16_BE: - len += sprintf(buffer+len, " (unsigned 16 bit big)"); - break; - case AFMT_S16_LE: - len += sprintf(buffer+len, " (signed 16 bit little)"); - break; - case AFMT_U16_LE: - len += sprintf(buffer+len, " (unsigned 16 bit little)"); - break; - } - len += sprintf(buffer+len, "\n"); - len += sprintf(buffer+len, "\tsound.speed = %dHz (phys. %dHz)\n", - dmasound.soft.speed, dmasound.hard.speed); - len += sprintf(buffer+len, "\tsound.stereo = 0x%x (%s)\n", - dmasound.soft.stereo, - dmasound.soft.stereo ? "stereo" : "mono"); if (dmasound.mach.state_info) - len += dmasound.mach.state_info(buffer); - len += sprintf(buffer+len, "\tsq.block_size = %d sq.max_count = %d" - " sq.max_active = %d\n", - write_sq.block_size, write_sq.max_count, - write_sq.max_active); - len += sprintf(buffer+len, "\tsq.count = %d sq.rear_size = %d\n", - write_sq.count, write_sq.rear_size); - len += sprintf(buffer+len, "\tsq.active = %d sq.syncing = %d\n", - write_sq.active, write_sq.syncing); + len += dmasound.mach.state_info(buffer+len, + (size_t) LOW_LEVEL_STAT_ALLOC) ; + + /* make usage of the state buffer as deterministic as poss. + exceptional conditions could cause overrun - and this is flagged as + a kernel error. + */ + + /* formats and settings */ + + len += sprintf(buffer+len,"\t\t === Formats & settings ===\n") ; + len += sprintf(buffer+len,"Parameter %20s%20s\n","soft","hard") ; + len += sprintf(buffer+len,"Format :%20s%20s\n", + get_afmt_string(dmasound.soft.format), + get_afmt_string(dmasound.hard.format)); + + len += sprintf(buffer+len,"Samp Rate:%14d s/sec%14d s/sec\n", + dmasound.soft.speed, dmasound.hard.speed); + + len += sprintf(buffer+len,"Channels :%20s%20s\n", + dmasound.soft.stereo ? "stereo" : "mono", + dmasound.hard.stereo ? "stereo" : "mono" ); + + /* sound queue status */ + + len += sprintf(buffer+len,"\t\t === Sound Queue status ===\n"); + len += sprintf(buffer+len,"Allocated:%8s%6s\n","Buffers","Size") ; + len += sprintf(buffer+len,"%9s:%8d%6d\n", + "write", write_sq.numBufs, write_sq.bufSize) ; +#ifdef HAS_RECORD + if (dmasound.mach.record) + len += sprintf(buffer+len,"%9s:%8d%6d\n", + "read", read_sq.numBufs, read_sq.bufSize) ; +#endif + len += sprintf(buffer+len, + "Current : MaxFrg FragSiz MaxAct Frnt Rear " + "Cnt RrSize A B S L xruns\n") ; + len += sprintf(buffer+len,"%9s:%7d%8d%7d%5d%5d%4d%7d%2d%2d%2d%2d%7d\n", + "write", write_sq.max_count, write_sq.block_size, + write_sq.max_active, write_sq.front, write_sq.rear, + write_sq.count, write_sq.rear_size, write_sq.active, + write_sq.busy, write_sq.syncing, write_sq.locked, write_sq.xruns) ; +#ifdef HAS_RECORD + if (dmasound.mach.record) + len += sprintf(buffer+len,"%9s:%7d%8d%7d%5d%5d%4d%7d%2d%2d%2d%2d%7d\n", + "read", read_sq.max_count, read_sq.block_size, + read_sq.max_active, read_sq.front, read_sq.rear, + read_sq.count, read_sq.rear_size, read_sq.active, + read_sq.busy, read_sq.syncing, read_sq.locked, read_sq.xruns) ; +#endif +#ifdef DEBUG_DMASOUND +printk("dmasound: stat buffer used %d bytes\n", len) ; +#endif + + if (len >= STAT_BUFF_LEN) + printk(KERN_ERR "dmasound_core: stat buffer overflowed!\n"); + state.len = len; return 0; } @@ -1171,15 +1567,16 @@ release: state_release, }; -static void __init state_init(void) +static int __init state_init(void) { #ifndef MODULE int state_unit; #endif state_unit = register_sound_special(&state_fops, SND_DEV_STATUS); if (state_unit < 0) - return; + return state_unit ; state.busy = 0; + return 0 ; } @@ -1191,6 +1588,7 @@ int __init dmasound_init(void) { + int res ; #ifdef MODULE if (irq_installed) return -EBUSY; @@ -1199,10 +1597,12 @@ /* Set up sound queue, /dev/audio and /dev/dsp. */ /* Set default settings. */ - sq_init(); + if ((res = sq_init()) < 0) + return res ; /* Set up /dev/sndstat. */ - state_init(); + if ((res = state_init()) < 0) + return res ; /* Set up /dev/mixer. */ mixer_init(); @@ -1215,8 +1615,21 @@ irq_installed = 1; #endif - printk(KERN_INFO "DMA sound driver installed, using %d buffers of %dk.\n", - numWriteBufs, writeBufSize); + printk(KERN_INFO "%s DMA sound driver rev %03d installed\n", + dmasound.mach.name, (DMASOUND_CORE_REVISION<<4) + + ((dmasound.mach.version>>8) & 0x0f)); + printk(KERN_INFO + "Core driver edition %02d.%02d : %s driver edition %02d.%02d\n", + DMASOUND_CORE_REVISION, DMASOUND_CORE_EDITION, dmasound.mach.name2, + (dmasound.mach.version >> 8), (dmasound.mach.version & 0xff)) ; + printk(KERN_INFO "Write will use %4d fragments of %7d bytes as default\n", + numWriteBufs, writeBufSize) ; +#ifdef HAS_RECORD + if (dmasound.mach.record) + printk(KERN_INFO + "Read will use %4d fragments of %7d bytes as default\n", + numReadBufs, readBufSize) ; +#endif return 0; } @@ -1228,6 +1641,7 @@ if (irq_installed) { sound_silence(); dmasound.mach.irqcleanup(); + irq_installed = 0; } write_sq_release_buffers(); @@ -1245,29 +1659,60 @@ static int __init dmasound_setup(char *str) { - int ints[6]; + int ints[6], size; str = get_options(str, ARRAY_SIZE(ints), ints); /* check the bootstrap parameter for "dmasound=" */ + /* FIXME: other than in the most naive of cases there is no sense in these + * buffers being other than powers of two. This is not checked yet. + */ + switch (ints[0]) { +#ifdef HAS_RECORD + case 5: + if ((ints[5] < 0) || (ints[5] > MAX_CATCH_RADIUS)) + printk("dmasound_setup: illegal catch radius, using default = %d\n", catchRadius); + else + catchRadius = ints[5]; + /* fall through */ + case 4: + if (ints[4] < MIN_BUFFERS) + printk("dmasound_setup: illegal number of read buffers, using default = %d\n", + numReadBufs); + else + numReadBufs = ints[4]; + /* fall through */ + case 3: + if ((size = ints[3]) < 256) /* check for small buffer specs */ + size <<= 10 ; + if (size < MIN_BUFSIZE || size > MAX_BUFSIZE) + printk("dmasound_setup: illegal read buffer size, using default = %d\n", readBufSize); + else + readBufSize = size; + /* fall through */ +#else case 3: if ((ints[3] < 0) || (ints[3] > MAX_CATCH_RADIUS)) printk("dmasound_setup: illegal catch radius, using default = %d\n", catchRadius); else catchRadius = ints[3]; /* fall through */ +#endif case 2: if (ints[1] < MIN_BUFFERS) printk("dmasound_setup: illegal number of buffers, using default = %d\n", numWriteBufs); else numWriteBufs = ints[1]; - if (ints[2] < MIN_BUFSIZE || ints[2] > MAX_BUFSIZE) - printk("dmasound_setup: illegal buffer size, using default = %dK\n", writeBufSize); - else - writeBufSize = ints[2]; - break; + /* fall through */ + case 1: + if ((size = ints[2]) < 256) /* check for small buffer specs */ + size <<= 10 ; + if (size < MIN_BUFSIZE || size > MAX_BUFSIZE) + printk("dmasound_setup: illegal write buffer size, using default = %d\n", writeBufSize); + else + writeBufSize = size; case 0: break; default: @@ -1281,6 +1726,85 @@ #endif /* !MODULE */ + /* + * Conversion tables + */ + +#ifdef HAS_8BIT_TABLES +/* 8 bit mu-law */ + +char dmasound_ulaw2dma8[] = { + -126, -122, -118, -114, -110, -106, -102, -98, + -94, -90, -86, -82, -78, -74, -70, -66, + -63, -61, -59, -57, -55, -53, -51, -49, + -47, -45, -43, -41, -39, -37, -35, -33, + -31, -30, -29, -28, -27, -26, -25, -24, + -23, -22, -21, -20, -19, -18, -17, -16, + -16, -15, -15, -14, -14, -13, -13, -12, + -12, -11, -11, -10, -10, -9, -9, -8, + -8, -8, -7, -7, -7, -7, -6, -6, + -6, -6, -5, -5, -5, -5, -4, -4, + -4, -4, -4, -4, -3, -3, -3, -3, + -3, -3, -3, -3, -2, -2, -2, -2, + -2, -2, -2, -2, -2, -2, -2, -2, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, 0, + 125, 121, 117, 113, 109, 105, 101, 97, + 93, 89, 85, 81, 77, 73, 69, 65, + 62, 60, 58, 56, 54, 52, 50, 48, + 46, 44, 42, 40, 38, 36, 34, 32, + 30, 29, 28, 27, 26, 25, 24, 23, + 22, 21, 20, 19, 18, 17, 16, 15, + 15, 14, 14, 13, 13, 12, 12, 11, + 11, 10, 10, 9, 9, 8, 8, 7, + 7, 7, 6, 6, 6, 6, 5, 5, + 5, 5, 4, 4, 4, 4, 3, 3, + 3, 3, 3, 3, 2, 2, 2, 2, + 2, 2, 2, 2, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0 +}; + +/* 8 bit A-law */ + +char dmasound_alaw2dma8[] = { + -22, -21, -24, -23, -18, -17, -20, -19, + -30, -29, -32, -31, -26, -25, -28, -27, + -11, -11, -12, -12, -9, -9, -10, -10, + -15, -15, -16, -16, -13, -13, -14, -14, + -86, -82, -94, -90, -70, -66, -78, -74, + -118, -114, -126, -122, -102, -98, -110, -106, + -43, -41, -47, -45, -35, -33, -39, -37, + -59, -57, -63, -61, -51, -49, -55, -53, + -2, -2, -2, -2, -2, -2, -2, -2, + -2, -2, -2, -2, -2, -2, -2, -2, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -6, -6, -6, -6, -5, -5, -5, -5, + -8, -8, -8, -8, -7, -7, -7, -7, + -3, -3, -3, -3, -3, -3, -3, -3, + -4, -4, -4, -4, -4, -4, -4, -4, + 21, 20, 23, 22, 17, 16, 19, 18, + 29, 28, 31, 30, 25, 24, 27, 26, + 10, 10, 11, 11, 8, 8, 9, 9, + 14, 14, 15, 15, 12, 12, 13, 13, + 86, 82, 94, 90, 70, 66, 78, 74, + 118, 114, 126, 122, 102, 98, 110, 106, + 43, 41, 47, 45, 35, 33, 39, 37, + 59, 57, 63, 61, 51, 49, 55, 53, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 5, 5, 5, 5, 4, 4, 4, 4, + 7, 7, 7, 7, 6, 6, 6, 6, + 2, 2, 2, 2, 2, 2, 2, 2, + 3, 3, 3, 3, 3, 3, 3, 3 +}; +#endif /* HAS_8BIT_TABLES */ /* * Visible symbols for modules @@ -1300,14 +1824,4 @@ EXPORT_SYMBOL(dmasound_ulaw2dma8); EXPORT_SYMBOL(dmasound_alaw2dma8); #endif -#ifdef HAS_16BIT_TABLES -EXPORT_SYMBOL(dmasound_ulaw2dma16); -EXPORT_SYMBOL(dmasound_alaw2dma16); -#endif -#ifdef HAS_14BIT_TABLES -EXPORT_SYMBOL(dmasound_ulaw2dma14l); -EXPORT_SYMBOL(dmasound_ulaw2dma14h); -EXPORT_SYMBOL(dmasound_alaw2dma14l); -EXPORT_SYMBOL(dmasound_alaw2dma14h); -#endif - +EXPORT_SYMBOL(get_afmt_string) ; diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/sound/dmasound/dmasound_paula.c linux-2.5/drivers/sound/dmasound/dmasound_paula.c --- linux-2.5.1/drivers/sound/dmasound/dmasound_paula.c Thu Oct 25 20:53:52 2001 +++ linux-2.5/drivers/sound/dmasound/dmasound_paula.c Thu Dec 27 16:32:31 2001 @@ -1,11 +1,18 @@ - /* * linux/drivers/sound/dmasound/dmasound_paula.c * * Amiga `Paula' DMA Sound Driver * * See linux/drivers/sound/dmasound/dmasound_core.c for copyright and credits - */ + * prior to 28/01/2001 + * + * 28/01/2001 [0.1] Iain Sandoe + * - added versioning + * - put in and populated the hardware_afmts field. + * [0.2] - put in SNDCTL_DSP_GETCAPS value. + * [0.3] - put in constraint on state buffer usage. + * [0.4] - put in default hard/soft settings +*/ #include <linux/module.h> @@ -23,6 +30,8 @@ #include "dmasound.h" +#define DMASOUND_PAULA_REVISION 0 +#define DMASOUND_PAULA_EDITION 4 /* * The minimum period for audio depends on htotal (for OCS/ECS/AGA) @@ -114,7 +123,7 @@ static void AmiMixerInit(void); static int AmiMixerIoctl(u_int cmd, u_long arg); static void AmiWriteSqSetup(void); -static int AmiStateInfo(char *buffer); +static int AmiStateInfo(char *buffer, size_t space); /*** Translations ************************************************************/ @@ -653,19 +662,36 @@ } -static int AmiStateInfo(char *buffer) +static int AmiStateInfo(char *buffer, size_t space) { int len = 0; len += sprintf(buffer+len, "\tsound.volume_left = %d [0...64]\n", dmasound.volume_left); len += sprintf(buffer+len, "\tsound.volume_right = %d [0...64]\n", dmasound.volume_right); + if (len >= space) { + printk(KERN_ERR "dmasound_paula: overlowed state buffer alloc.\n") ; + len = space ; + } return len; } /*** Machine definitions *****************************************************/ +static SETTINGS def_hard = { + format: AFMT_S8, + stereo: 0, + size: 8, + speed: 8000 +} ; + +static SETTINGS def_soft = { + format: AFMT_U8, + stereo: 0, + size: 8, + speed: 8000 +} ; static MACHINE machAmiga = { name: "Amiga", @@ -688,7 +714,10 @@ mixer_ioctl: AmiMixerIoctl, write_sq_setup: AmiWriteSqSetup, state_info: AmiStateInfo, - min_dsp_speed: 8000 + min_dsp_speed: 8000, + version: ((DMASOUND_PAULA_REVISION<<8) | DMASOUND_PAULA_EDITION), + hardware_afmts: (AFMT_S8 | AFMT_S16_BE), /* h'ware-supported formats *only* here */ + capabilities: DSP_CAP_BATCH /* As per SNDCTL_DSP_GETCAPS */ }; @@ -704,6 +733,8 @@ "dmasound [Paula]")) return -EBUSY; dmasound.mach = machAmiga; + dmasound.mach.default_hard = def_hard ; + dmasound.mach.default_soft = def_soft ; err = dmasound_init(); if (err) release_mem_region(CUSTOM_PHYSADDR+0xa0, 0x40); diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/sound/dmasound/dmasound_q40.c linux-2.5/drivers/sound/dmasound/dmasound_q40.c --- linux-2.5.1/drivers/sound/dmasound/dmasound_q40.c Thu Oct 25 20:53:52 2001 +++ linux-2.5/drivers/sound/dmasound/dmasound_q40.c Thu Dec 27 16:32:31 2001 @@ -1,10 +1,16 @@ - /* * linux/drivers/sound/dmasound/dmasound_q40.c * * Q40 DMA Sound Driver * * See linux/drivers/sound/dmasound/dmasound_core.c for copyright and credits + * prior to 28/01/2001 + * + * 28/01/2001 [0.1] Iain Sandoe + * - added versioning + * - put in and populated the hardware_afmts field. + * [0.2] - put in SNDCTL_DSP_GETCAPS value. + * [0.3] - put in default hard/soft settings. */ @@ -18,6 +24,8 @@ #include "dmasound.h" +#define DMASOUND_Q40_REVISION 0 +#define DMASOUND_Q40_EDITION 3 static int expand_bal; /* Balance factor for expanding (not volume!) */ static int expand_data; /* Data for expanding */ @@ -216,7 +224,7 @@ int bal = expand_bal; int hSpeed = dmasound.hard.speed, sSpeed = dmasound.soft.speed; int utotal, ftotal; - + ftotal = frameLeft; utotal = userCount; while (frameLeft) { @@ -390,7 +398,7 @@ q40_pp=start; q40_sc=size; - + write_sq.front = (write_sq.front+1) % write_sq.max_count; write_sq.active++; @@ -446,7 +454,7 @@ *DAC_LEFT=*q40_pp; *DAC_RIGHT=*q40_pp++; q40_sc --; - master_outb(1,SAMPLE_CLEAR_REG); + master_outb(1,SAMPLE_CLEAR_REG); }else Q40Interrupt(); } static void Q40Interrupt(void) @@ -546,6 +554,19 @@ /*** Machine definitions *****************************************************/ +static SETTINGS def_hard = { + format: AFMT_U8, + stereo: 0, + size: 8, + speed: 10000 +} ; + +static SETTINGS def_soft = { + format: AFMT_U8, + stereo: 0, + size: 8, + speed: 8000 +} ; static MACHINE machQ40 = { name: "Q40", @@ -559,10 +580,13 @@ irqcleanup: Q40IrqCleanUp, #endif /* MODULE */ init: Q40Init, - silence: Q40Silence, - setFormat: Q40SetFormat, + silence: Q40Silence, + setFormat: Q40SetFormat, setVolume: Q40SetVolume, - play: Q40Play + play: Q40Play, + version: ((DMASOUND_Q40_REVISION<<8) | DMASOUND_Q40_EDITION), + hardware_afmts: AFMT_U8, /* h'ware-supported formats *only* here */ + capabilities: DSP_CAP_BATCH /* As per SNDCTL_DSP_GETCAPS */ }; @@ -573,6 +597,8 @@ { if (MACH_IS_Q40) { dmasound.mach = machQ40; + dmasound.mach.default_hard = def_hard ; + dmasound.mach.default_soft = def_soft ; return dmasound_init(); } else return -ENODEV; diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/sound/dmasound/tas3001c.c linux-2.5/drivers/sound/dmasound/tas3001c.c --- linux-2.5.1/drivers/sound/dmasound/tas3001c.c Thu Jan 1 00:00:00 1970 +++ linux-2.5/drivers/sound/dmasound/tas3001c.c Thu Dec 27 16:32:31 2001 @@ -0,0 +1,370 @@ +/* + * Driver for the i2c/i2s based TA3001C sound chip used + * on some Apple hardware. Also known as "tumbler". + * + * 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. + * + * Modified by Christopher C. Chimelis <chris@debian.org>: + * + * TODO: + * ----- + * * Enable DRC since the TiBook speakers are less than good + * * Enable control over input line 2 (is this connected?) + * * Play with the dual six-stage cascading biquad filtering to see how + * we can use it to our advantage (currently not implemented) + * + * Version 0.3: + * ------------ + * * Fixed volume control + * * Added bass and treble control + * * Added PCM line level control (mixer 1 in the TAS manual) + * + */ + +#include <linux/version.h> +#include <linux/module.h> +#include <linux/slab.h> +#include <linux/proc_fs.h> +#include <linux/ioport.h> +#include <linux/sysctl.h> +#include <linux/types.h> +#include <linux/i2c.h> +#include <linux/init.h> +#include <asm/uaccess.h> +#include <asm/errno.h> +#include <asm/io.h> +#include <asm/prom.h> + +#include "dmasound.h" +#include "tas3001c.h" + +#define I2C_DRIVERID_TAS (0xFEBA) + +#define TAS_VERSION "0.3" +#define TAS_DATE "20011214" + +#define TAS_SETTING_MAX 100 + +#define VOL_DEFAULT (((TAS_SETTING_MAX*4)/5)<<0) +#define INPUT_DEFAULT (((TAS_SETTING_MAX*4)/5)<<0) +#define BASS_DEFAULT ((TAS_SETTING_MAX/2)<<0) +#define TREBLE_DEFAULT ((TAS_SETTING_MAX/2)<<0) + +static uint cur_left_vol; +static uint cur_right_vol; +static uint cur_pcm_lvl; +static uint cur_treble; +static uint cur_bass; + +static struct i2c_client * tumbler_client = NULL; + +static int tas_attach_adapter(struct i2c_adapter *adapter); + +static int tas_attach_adapter(struct i2c_adapter *adapter); +static int tas_detect_client(struct i2c_adapter *adapter, int address); +static int tas_detach_client(struct i2c_client *client); + +/* Unique ID allocation */ +static int tas_id; +static int tas_initialized; + +static struct device_node* tas_node; +static u8 tas_i2c_address = 0x34; + + +struct tas_data { + int arf; /* place holder for future use */ +}; + +struct i2c_driver tas_driver = { + name: "TAS3001C driver V 0.3", + id: I2C_DRIVERID_TAS, + flags: I2C_DF_NOTIFY, + attach_adapter: &tas_attach_adapter, + detach_client: &tas_detach_client, + command: NULL, + inc_use: NULL, /* &tas_inc_use, */ + dec_use: NULL /* &tas_dev_use */ +}; + +void +tumbler_get_volume(uint * left_vol, uint *right_vol) +{ + *left_vol = cur_left_vol; + *right_vol = cur_right_vol; +} + +int +tumbler_set_register(uint reg, uint size, char *block) +{ + if (i2c_smbus_write_block_data(tumbler_client, reg, size, block) < 0) { + printk("tas3001c: I2C write failed \n"); + return -1; + } + return 0; +} + +void +tumbler_get_pcm_lvl(uint *pcm_lvl) +{ + *pcm_lvl = cur_pcm_lvl; +} + +void +tumbler_get_treble(uint *treble) +{ + *treble = cur_treble; +} + +void +tumbler_get_bass(uint *bass) +{ + *bass = cur_bass; +} + +int +tumbler_set_bass(uint bass) +{ + uint cur_bass_pers = bass; + char block; + + if (!tumbler_client) + return -1; + + bass &= 0xff; + if (bass > TAS_SETTING_MAX) + bass = TAS_SETTING_MAX; + bass = ((bass * 72) / TAS_SETTING_MAX) << 0; + bass = tas_bass_table[bass]; + block = (bass >> 0) & 0xff; + + if (tumbler_set_register(TAS_SET_BASS, &block) < 0) { + printk("tas3001c: failed to set bass \n"); + return -1; + } + cur_bass = cur_bass_pers; + return 0; +} + +int +tumbler_set_treble(uint treble) +{ + uint cur_treble_pers = treble; + char block; + + if (!tumbler_client) + return -1; + + treble &= 0xff; + if (treble > TAS_SETTING_MAX) + treble = TAS_SETTING_MAX; + treble = ((treble * 72) / TAS_SETTING_MAX) << 0; + treble = tas_treble_table[treble]; + block = (treble >> 0) & 0xff; + + if (tumbler_set_register(TAS_SET_TREBLE, &block) < 0) { + printk("tas3001c: failed to set treble \n"); + return -1; + } + cur_treble = cur_treble_pers; + return 0; +} + +int +tumbler_set_pcm_lvl(uint pcm_lvl) +{ + uint pcm_lvl_pers = pcm_lvl; + unsigned char block[3]; + + if (!tumbler_client) + return -1; + + pcm_lvl &= 0xff; + if (pcm_lvl > TAS_SETTING_MAX) + pcm_lvl = TAS_SETTING_MAX; + pcm_lvl = ((pcm_lvl * 176) / TAS_SETTING_MAX) << 0; + + pcm_lvl = tas_input_table[pcm_lvl]; + + block[0] = (pcm_lvl >> 16) & 0xff; + block[1] = (pcm_lvl >> 8) & 0xff; + block[2] = (pcm_lvl >> 0) & 0xff; + + if (tumbler_set_register(TAS_SET_MIXER1, block) < 0) { + printk("tas3001c: failed to set input level \n"); + return -1; + } + cur_pcm_lvl = pcm_lvl_pers; + + return 0; +} + +int +tumbler_set_volume(uint left_vol, uint right_vol) +{ + uint left_vol_pers = left_vol; + uint right_vol_pers = right_vol; + unsigned char block[6]; + + if (!tumbler_client) + return -1; + + left_vol &= 0xff; + if (left_vol > TAS_SETTING_MAX) + left_vol = TAS_SETTING_MAX; + right_vol &= 0xff; + if (right_vol > TAS_SETTING_MAX) + right_vol = TAS_SETTING_MAX; + left_vol = ((left_vol * 176) / TAS_SETTING_MAX) << 0; + right_vol = ((right_vol * 176) / TAS_SETTING_MAX) << 0; + + left_vol = tas_volume_table[left_vol]; + right_vol = tas_volume_table[right_vol]; + + block[0] = (left_vol >> 16) & 0xff; + block[1] = (left_vol >> 8) & 0xff; + block[2] = (left_vol >> 0) & 0xff; + + block[3] = (right_vol >> 16) & 0xff; + block[4] = (right_vol >> 8) & 0xff; + block[5] = (right_vol >> 0) & 0xff; + + if (tumbler_set_register(TAS_SET_VOLUME, block) < 0) { + printk("tas3001c: failed to set volume \n"); + return -1; + } + cur_left_vol = left_vol_pers; + cur_right_vol = right_vol_pers; + + return 0; +} + +static int +tas_attach_adapter(struct i2c_adapter *adapter) +{ + if (!strncmp(adapter->name, "mac-io", 6)) + tas_detect_client(adapter, tas_i2c_address); + + return 0; +} + +static int +tas_init_client(struct i2c_client * new_client) +{ + /* Make sure something answers on the i2c bus + */ + + if (i2c_smbus_write_byte_data(new_client, 1, (1<<6)+(2<<4)+(2<<2)+0) < 0) + return -1; + + tumbler_client = new_client; + + tumbler_set_volume(VOL_DEFAULT, VOL_DEFAULT); + tumbler_set_pcm_lvl(INPUT_DEFAULT); + tumbler_set_bass(BASS_DEFAULT); + tumbler_set_treble(TREBLE_DEFAULT); + + return 0; +} + +static int +tas_detect_client(struct i2c_adapter *adapter, int address) +{ + int rc = 0; + struct i2c_client *new_client; + struct tas_data *data; + const char *client_name = "tas 3001c Digital Equalizer"; + + new_client = kmalloc( + sizeof(struct i2c_client) + sizeof(struct tas_data), + GFP_KERNEL); + if (!new_client) { + rc = -ENOMEM; + goto bail; + } + + /* This is tricky, but it will set the data to the right value. */ + new_client->data = new_client + 1; + data = (struct tas_data *) (new_client->data); + + new_client->addr = address; + new_client->data = data; + new_client->adapter = adapter; + new_client->driver = &tas_driver; + new_client->flags = 0; + + strcpy(new_client->name,client_name); + + new_client->id = tas_id++; /* Automatically unique */ + + if (tas_init_client(new_client)) { + rc = -ENODEV; + goto bail; + } + + /* Tell the i2c layer a new client has arrived */ + if (i2c_attach_client(new_client)) { + rc = -ENODEV; + goto bail; + } +bail: + if (rc && new_client) + kfree(new_client); + return rc; +} + +static int +tas_detach_client(struct i2c_client *client) +{ + if (client == tumbler_client) + tumbler_client = NULL; + + i2c_detach_client(client); + kfree(client); + + return 0; +} + +int +tas_cleanup(void) +{ + if (!tas_initialized) + return -ENODEV; + i2c_del_driver(&tas_driver); + tas_initialized = 0; + + return 0; +} + +int +tas_init(void) +{ + int rc; + u32* paddr; + + if (tas_initialized) + return 0; + + tas_node = find_devices("deq"); + if (tas_node == NULL) + return -ENODEV; + + printk(KERN_INFO "tas3001c driver version %s (%s)\n",TAS_VERSION,TAS_DATE); + paddr = (u32 *)get_property(tas_node, "i2c-address", NULL); + if (paddr) { + tas_i2c_address = (*paddr) >> 1; + printk(KERN_INFO "using i2c address: 0x%x from device-tree\n", + tas_i2c_address); + } else + printk(KERN_INFO "using i2c address: 0x%x (default)\n", tas_i2c_address); + + if ((rc = i2c_add_driver(&tas_driver))) { + printk("tas3001c: Driver registration failed, module not inserted.\n"); + tas_cleanup(); + return rc; + } + tas_initialized = 1; + return 0; +} diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/sound/dmasound/tas3001c.h linux-2.5/drivers/sound/dmasound/tas3001c.h --- linux-2.5.1/drivers/sound/dmasound/tas3001c.h Thu Jan 1 00:00:00 1970 +++ linux-2.5/drivers/sound/dmasound/tas3001c.h Thu Dec 27 16:32:31 2001 @@ -0,0 +1,248 @@ +/* + * Header file for the i2c/i2s based TA3001C sound chip used + * on some Apple hardware. Also known as "tumbler". + * + * 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. + * + * Written by Christopher C. Chimelis <chris@debian.org> + */ + +#ifndef _tas3001c_h_ +#define _tas3001c_h_ + +/* + * Macros that correspond to the registers that we write to + * when setting the various values. + */ +#define TAS_DRC 0x02 /* DRC */ +#define TAS_VOLUME 0x04 /* Volume */ +#define TAS_TREBLE 0x05 /* Treble */ +#define TAS_BASS 0x06 /* Bass */ +#define TAS_MIXER1 0x07 /* PCM line */ +#define TAS_MIXER2 0x08 /* Input (Unk) */ + +/* + * Macros that define various arguments to tas_set_register() + */ +#define TAS_SET_DRC TAS_DRC, 2 +#define TAS_SET_VOLUME TAS_VOLUME, 6 +#define TAS_SET_TREBLE TAS_TREBLE, 1 +#define TAS_SET_BASS TAS_BASS, 1 +#define TAS_SET_MIXER1 TAS_MIXER1, 3 +#define TAS_SET_MIXER2 TAS_MIXER2, 3 + + +/* + * tas_volume_table contains lookup values for the volume settings + * for tumbler. This is straight from the programming manual + * for the chip, however, it's zero-sourced for your shopping pleasure + * (meaning, you'll have to compute the difference between the desired + * dB and the index value of the proper setting. + * + * This table should've been replaced by the formula: + * dB = 20 log(x) + * but, since there's no log() or supporting functions like exp(), + * my implementation of the above won't work. Yeah, I could do it + * the hard way, but this table is just easier :-) + * + * For reference, -70 dB = tas_volume_table[0] + */ + +static unsigned int tas_volume_table[] = { + 0x00000015, 0x00000016, 0x00000017, /* -70.0, -69.5, -69.0 */ + 0x00000019, 0x0000001a, 0x0000001c, /* -68.5, -68.0, -67.5 */ + 0x0000001d, 0x0000001f, 0x00000021, /* -67.0, -66.5, -66.0 */ + 0x00000023, 0x00000025, 0x00000027, /* -65.5, -65.0, -64.5 */ + 0x00000029, 0x0000002c, 0x0000002e, /* -64.0, -63.5, -63.0 */ + 0x00000031, 0x00000034, 0x00000037, /* -62.5, -62.0, -61.5 */ + 0x0000003a, 0x0000003e, 0x00000042, /* -61.0, -60.5, -60.0 */ + 0x00000045, 0x0000004a, 0x0000004e, /* -59.5, -59.0, -58.5 */ + 0x00000053, 0x00000057, 0x0000005d, /* -58.0, -57.5, -57.0 */ + 0x00000062, 0x00000068, 0x0000006e, /* -56.5, -56.0, -55.5 */ + 0x00000075, 0x0000007b, 0x00000083, /* -55.0, -54.5, -54.0 */ + 0x0000008b, 0x00000093, 0x0000009b, /* -53.5, -53.0, -52.5 */ + 0x000000a5, 0x000000ae, 0x000000b9, /* -52.0, -51.5, -51.0 */ + 0x000000c4, 0x000000cf, 0x000000dc, /* -50.5, -50.0, -49.5 */ + 0x000000e9, 0x000000f6, 0x00000105, /* -49.0, -48.5, -48.0 */ + 0x00000114, 0x00000125, 0x00000136, /* -47.5, -47.0, -46.5 */ + 0x00000148, 0x0000015c, 0x00000171, /* -46.0, -45.5, -45.0 */ + 0x00000186, 0x0000019e, 0x000001b6, /* -44.5, -44.0, -43.5 */ + 0x000001d0, 0x000001eb, 0x00000209, /* -43.0, -42.5, -42.0 */ + 0x00000227, 0x00000248, 0x0000026b, /* -41.5, -41.0, -40.5 */ + 0x0000028f, 0x000002b6, 0x000002df, /* -40.0, -39.5, -39.0 */ + 0x0000030b, 0x00000339, 0x0000036a, /* -38.5, -38.0, -37.5 */ + 0x0000039e, 0x000003d5, 0x0000040f, /* -37.0, -36.5, -36.0 */ + 0x0000044c, 0x0000048d, 0x000004d2, /* -35.5, -35.0, -34.5 */ + 0x0000051c, 0x00000569, 0x000005bb, /* -34.0, -33.5, -33.0 */ + 0x00000612, 0x0000066e, 0x000006d0, /* -32.5, -32.0, -31.5 */ + 0x00000737, 0x000007a5, 0x00000818, /* -31.0, -30.5, -30.0 */ + 0x00000893, 0x00000915, 0x0000099f, /* -29.5, -29.0, -28.5 */ + 0x00000a31, 0x00000acc, 0x00000b6f, /* -28.0, -27.5, -27.0 */ + 0x00000c1d, 0x00000cd5, 0x00000d97, /* -26.5, -26.0, -25.5 */ + 0x00000e65, 0x00000f40, 0x00001027, /* -25.0, -24.5, -24.0 */ + 0x0000111c, 0x00001220, 0x00001333, /* -23.5, -23.0, -22.5 */ + 0x00001456, 0x0000158a, 0x000016d1, /* -22.0, -21.5, -21.0 */ + 0x0000182b, 0x0000199a, 0x00001b1e, /* -20.5, -20.0, -19.5 */ + 0x00001cb9, 0x00001e6d, 0x0000203a, /* -19.0, -18.5, -18.0 */ + 0x00002223, 0x00002429, 0x0000264e, /* -17.5, -17.0, -16.5 */ + 0x00002893, 0x00002afa, 0x00002d86, /* -16.0, -15.5, -15.0 */ + 0x00003039, 0x00003314, 0x0000361b, /* -14.5, -14.0, -13.5 */ + 0x00003950, 0x00003cb5, 0x0000404e, /* -13.0, -12.5, -12.0 */ + 0x0000441d, 0x00004827, 0x00004c6d, /* -11.5, -11.0, -10.5 */ + 0x000050f4, 0x000055c0, 0x00005ad5, /* -10.0, -09.5, -09.0 */ + 0x00006037, 0x000065ea, 0x00006bf4, /* -08.5, -08.0, -07.5 */ + 0x0000725a, 0x00007920, 0x0000804e, /* -07.0, -06.5, -06.0 */ + 0x000087e8, 0x00008ff6, 0x0000987d, /* -05.5, -05.0, -04.5 */ + 0x0000a186, 0x0000ab19, 0x0000b53c, /* -04.0, -03.5, -03.0 */ + 0x0000bff9, 0x0000cb59, 0x0000d766, /* -02.5, -02.0, -01.5 */ + 0x0000e429, 0x0000f1ae, 0x00010000, /* -01.0, -00.5, 00.0 */ + 0x00010f2b, 0x00011f3d, 0x00013042, /* +00.5, +01.0, +01.5 */ + 0x00014249, 0x00015562, 0x0001699c, /* +02.0, +02.5, +03.0 */ + 0x00017f09, 0x000195bc, 0x0001adc6, /* +03.5, +04.0, +04.5 */ + 0x0001c73d, 0x0001e237, 0x0001feca, /* +05.0, +05.5, +06.0 */ + 0x00021d0e, 0x00023d1d, 0x00025f12, /* +06.5, +07.0, +07.5 */ + 0x0002830b, 0x0002a925, 0x0002d182, /* +08.0, +08.5, +09.0 */ + 0x0002fc42, 0x0003298b, 0x00035983, /* +09.5, +10.0, +10.5 */ + 0x00038c53, 0x0003c225, 0x0003fb28, /* +11.0, +11.5, +12.0 */ + 0x0004378b, 0x00047783, 0x0004bb44, /* +12.5, +13.0, +13.5 */ + 0x0005030a, 0x00054f10, 0x00059f98, /* +14.0, +14.5, +15.0 */ + 0x0005f4e5, 0x00064f40, 0x0006aef6, /* +15.5, +16.0, +16.5 */ + 0x00071457, 0x00077fbb, 0x0007f17b /* +17.0, +17.5, +18.0 */ +}; + +/* tas_treble_table[] is a lookup table that holds the values to drop into + * the treble setting register on the TAS. Again, there is a formula for + * this one, but we use this instead due to lack of real math functions + * in the kernel. + */ +static char tas_treble_table[] = { + 0x96, 0x95, 0x94, /* -18.0, -17.5, -17.0 */ + 0x93, 0x92, 0x91, /* -16.5, -16.0, -15.5 */ + 0x90, 0x8f, 0x8e, /* -15.0, -14.5, -14.0 */ + 0x8d, 0x8c, 0x8b, /* -13.5, -13.0, -12.5 */ + 0x8a, 0x89, 0x88, /* -12.0, -11.5, -11.0 */ + 0x87, 0x86, 0x85, /* -10.5, -10.0, -09.5 */ + 0x84, 0x83, 0x82, /* -09.0, -08.5, -08.0 */ + 0x81, 0x80, 0x7f, /* -07.5, -07.0, -06.5 */ + 0x7e, 0x7d, 0x7c, /* -06.0, -05.5, -05.0 */ + 0x7b, 0x7a, 0x79, /* -04.5, -04.0, -03.5 */ + 0x78, 0x77, 0x76, /* -03.0, -02.5, -02.0 */ + 0x75, 0x74, 0x73, /* -01.5, -01.0, -00.5 */ + 0x72, 0x71, 0x70, /* 00.0, +00.5, +01.0 */ + 0x6e, 0x6d, 0x6c, /* +01.5, +02.0, +02.5 */ + 0x6b, 0x69, 0x68, /* +03.0, +03.5, +04.0 */ + 0x66, 0x65, 0x63, /* +04.5, +05.0, +05.5 */ + 0x62, 0x60, 0x5e, /* +06.0, +06.5, +07.0 */ + 0x5c, 0x5a, 0x57, /* +07.5, +08.0, +08.5 */ + 0x55, 0x52, 0x4f, /* +09.0, +09.5, +10.0 */ + 0x4c, 0x49, 0x45, /* +10.5, +11.0, +11.5 */ + 0x42, 0x3e, 0x3a, /* +12.0, +12.5, +13.0 */ + 0x36, 0x32, 0x2d, /* +13.5, +14.0, +14.5 */ + 0x28, 0x22, 0x1c, /* +15.0, +15.5, +16.0 */ + 0x16, 0x10, 0x09, /* +16.5, +17.0, +17.5 */ + 0x01 /* +18.0 */ +}; + +/* tas_bass_table[] is a lookup table that holds the values to drop into + * the bass setting register on the TAS. Again, there is a formula for + * this one, but we use this instead due to lack of real math functions + * in the kernel. + */ +static char tas_bass_table[] = { + 0x86, 0x82, 0x7f, /* -18.0, -17.5, -17.0 */ + 0x7d, 0x7a, 0x78, /* -16.5, -16.0, -15.5 */ + 0x76, 0x74, 0x72, /* -15.0, -14.5, -14.0 */ + 0x70, 0x6e, 0x6d, /* -13.5, -13.0, -12.5 */ + 0x6b, 0x69, 0x66, /* -12.0, -11.5, -11.0 */ + 0x64, 0x61, 0x5f, /* -10.5, -10.0, -09.5 */ + 0x5d, 0x5c, 0x5a, /* -09.0, -08.5, -08.0 */ + 0x59, 0x58, 0x56, /* -07.5, -07.0, -06.5 */ + 0x55, 0x54, 0x53, /* -06.0, -05.5, -05.0 */ + 0x51, 0x4f, 0x4d, /* -04.5, -04.0, -03.5 */ + 0x4b, 0x49, 0x46, /* -03.0, -02.5, -02.0 */ + 0x44, 0x42, 0x40, /* -01.5, -01.0, -00.5 */ + 0x3e, 0x3c, 0x3b, /* 00.0, +00.5, +01.0 */ + 0x39, 0x38, 0x36, /* +01.5, +02.0, +02.5 */ + 0x35, 0x33, 0x31, /* +03.0, +03.5, +04.0 */ + 0x30, 0x2e, 0x2c, /* +04.5, +05.0, +05.5 */ + 0x2b, 0x29, 0x28, /* +06.0, +06.5, +07.0 */ + 0x26, 0x25, 0x23, /* +07.5, +08.0, +08.5 */ + 0x21, 0x1f, 0x1c, /* +09.0, +09.5, +10.0 */ + 0x19, 0x18, 0x17, /* +10.5, +11.0, +11.5 */ + 0x16, 0x14, 0x13, /* +12.0, +12.5, +13.0 */ + 0x12, 0x10, 0x0f, /* +13.5, +14.0, +14.5 */ + 0x0d, 0x0b, 0x0a, /* +15.0, +15.5, +16.0 */ + 0x08, 0x06, 0x03, /* +16.5, +17.0, +17.5 */ + 0x01 /* +18.0 */ +}; + +/* tas_input_table[] is a lookup table that holds the values to drop into + * the setting registers on the TAS for "mixers 1 & 2" (which are the input + * lines). Again, there is a formula for these, but we use this instead + * due to lack of real math functions in the kernel. + */ +static unsigned int tas_input_table[] = { + 0x00014b, 0x00015f, 0x000174, /* -70.0, -69.5, -69.0 */ + 0x00018a, 0x0001a1, 0x0001ba, /* -68.5, -68.0, -67.5 */ + 0x0001d4, 0x0001f0, 0x00020d, /* -67.0, -66.5, -66.0 */ + 0x00022c, 0x00024d, 0x000270, /* -65.5, -65.0, -64.5 */ + 0x000295, 0x0002bc, 0x0002e6, /* -64.0, -63.5, -63.0 */ + 0x000312, 0x000340, 0x000372, /* -62.5, -62.0, -61.5 */ + 0x0003a6, 0x0003dd, 0x000418, /* -61.0, -60.5, -60.0 */ + 0x000456, 0x000498, 0x0004de, /* -59.5, -59.0, -58.5 */ + 0x000528, 0x000576, 0x0005c9, /* -58.0, -57.5, -57.0 */ + 0x000620, 0x00067d, 0x0006e0, /* -56.5, -56.0, -55.5 */ + 0x000748, 0x0007b7, 0x00082c, /* -55.0, -54.5, -54.0 */ + 0x0008a8, 0x00092b, 0x0009b6, /* -53.5, -53.0, -52.5 */ + 0x000a49, 0x000ae5, 0x000b8b, /* -52.0, -51.5, -51.0 */ + 0x000c3a, 0x000cf3, 0x000db8, /* -50.5, -50.0, -49.5 */ + 0x000e88, 0x000f64, 0x00104e, /* -49.0, -48.5, -48.0 */ + 0x001145, 0x00124b, 0x001361, /* -47.5, -47.0, -46.5 */ + 0x001487, 0x0015be, 0x001708, /* -46.0, -45.5, -45.0 */ + 0x001865, 0x0019d8, 0x001b60, /* -44.5, -44.0, -43.5 */ + 0x001cff, 0x001eb7, 0x002089, /* -43.0, -42.5, -42.0 */ + 0x002276, 0x002481, 0x0026ab, /* -41.5, -41.0, -40.5 */ + 0x0028f5, 0x002b63, 0x002df5, /* -40.0, -39.5, -39.0 */ + 0x0030ae, 0x003390, 0x00369e, /* -38.5, -38.0, -37.5 */ + 0x0039db, 0x003d49, 0x0040ea, /* -37.0, -36.5, -36.0 */ + 0x0044c3, 0x0048d6, 0x004d27, /* -35.5, -35.0, -34.5 */ + 0x0051b9, 0x005691, 0x005bb2, /* -34.0, -33.5, -33.0 */ + 0x006121, 0x0066e3, 0x006cfb, /* -32.5, -32.0, -31.5 */ + 0x007370, 0x007a48, 0x008186, /* -31.0, -30.5, -30.0 */ + 0x008933, 0x009154, 0x0099f1, /* -29.5, -29.0, -28.5 */ + 0x00a310, 0x00acba, 0x00b6f6, /* -28.0, -27.5, -27.0 */ + 0x00c1cd, 0x00cd49, 0x00d973, /* -26.5, -26.0, -25.5 */ + 0x00e655, 0x00f3fb, 0x010270, /* -25.0, -24.5, -24.0 */ + 0x0111c0, 0x0121f9, 0x013328, /* -23.5, -23.0, -22.5 */ + 0x01455b, 0x0158a2, 0x016d0e, /* -22.0, -21.5, -21.0 */ + 0x0182af, 0x019999, 0x01b1de, /* -20.5, -20.0, -19.5 */ + 0x01cb94, 0x01e6cf, 0x0203a7, /* -19.0, -18.5, -18.0 */ + 0x022235, 0x024293, 0x0264db, /* -17.5, -17.0, -16.5 */ + 0x02892c, 0x02afa3, 0x02d862, /* -16.0, -15.5, -15.0 */ + 0x03038a, 0x033142, 0x0361af, /* -14.5, -14.0, -13.5 */ + 0x0394fa, 0x03cb50, 0x0404de, /* -13.0, -12.5, -12.0 */ + 0x0441d5, 0x048268, 0x04c6d0, /* -11.5, -11.0, -10.5 */ + 0x050f44, 0x055c04, 0x05ad50, /* -10.0, -09.5, -09.0 */ + 0x06036e, 0x065ea5, 0x06bf44, /* -08.5, -08.0, -07.5 */ + 0x07259d, 0x079207, 0x0804dc, /* -07.0, -06.5, -06.0 */ + 0x087e80, 0x08ff59, 0x0987d5, /* -05.5, -05.0, -04.5 */ + 0x0a1866, 0x0ab189, 0x0b53be, /* -04.0, -03.5, -03.0 */ + 0x0bff91, 0x0cb591, 0x0d765a, /* -02.5, -02.0, -01.5 */ + 0x0e4290, 0x0f1adf, 0x100000, /* -01.0, -00.5, 00.0 */ + 0x10f2b4, 0x11f3c9, 0x13041a, /* +00.5, +01.0, +01.5 */ + 0x14248e, 0x15561a, 0x1699c0, /* +02.0, +02.5, +03.0 */ + 0x17f094, 0x195bb8, 0x1adc61, /* +03.5, +04.0, +04.5 */ + 0x1c73d5, 0x1e236d, 0x1fec98, /* +05.0, +05.5, +06.0 */ + 0x21d0d9, 0x23d1cd, 0x25f125, /* +06.5, +07.0, +07.5 */ + 0x2830af, 0x2a9254, 0x2d1818, /* +08.0, +08.5, +09.0 */ + 0x2fc420, 0x3298b0, 0x35982f, /* +09.5, +10.0, +10.5 */ + 0x38c528, 0x3c224c, 0x3fb278, /* +11.0, +11.5, +12.0 */ + 0x437880, 0x477828, 0x4bb446, /* +12.5, +13.0, +13.5 */ + 0x5030a1, 0x54f106, 0x59f980, /* +14.0, +14.5, +15.0 */ + 0x5f4e52, 0x64f403, 0x6aef5d, /* +15.5, +16.0, +16.5 */ + 0x714575, 0x77fbaa, 0x7f17af /* +17.0, +17.5, +18.0 */ +}; + +#endif /* _tas3001c_h_ */ diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/sound/dmasound/trans_16.c linux-2.5/drivers/sound/dmasound/trans_16.c --- linux-2.5.1/drivers/sound/dmasound/trans_16.c Thu Jan 1 00:00:00 1970 +++ linux-2.5/drivers/sound/dmasound/trans_16.c Thu Dec 27 16:32:31 2001 @@ -0,0 +1,679 @@ +/* + * linux/drivers/sound/dmasound/trans_16.c + * + * 16 bit translation routines. Only used by Power mac at present. + * + * See linux/drivers/sound/dmasound/dmasound_core.c for copyright and + * history prior to 08/02/2001. + * + * 08/02/2001 Iain Sandoe + * split from dmasound_awacs.c + */ + +#include <linux/soundcard.h> +#include <asm/uaccess.h> +#include "dmasound.h" + +static short dmasound_alaw2dma16[] ; +static short dmasound_ulaw2dma16[] ; + +static ssize_t pmac_ct_law(const u_char *userPtr, size_t userCount, + u_char frame[], ssize_t *frameUsed, + ssize_t frameLeft); +static ssize_t pmac_ct_s8(const u_char *userPtr, size_t userCount, + u_char frame[], ssize_t *frameUsed, + ssize_t frameLeft); +static ssize_t pmac_ct_u8(const u_char *userPtr, size_t userCount, + u_char frame[], ssize_t *frameUsed, + ssize_t frameLeft); +static ssize_t pmac_ct_s16(const u_char *userPtr, size_t userCount, + u_char frame[], ssize_t *frameUsed, + ssize_t frameLeft); +static ssize_t pmac_ct_u16(const u_char *userPtr, size_t userCount, + u_char frame[], ssize_t *frameUsed, + ssize_t frameLeft); + +static ssize_t pmac_ctx_law(const u_char *userPtr, size_t userCount, + u_char frame[], ssize_t *frameUsed, + ssize_t frameLeft); +static ssize_t pmac_ctx_s8(const u_char *userPtr, size_t userCount, + u_char frame[], ssize_t *frameUsed, + ssize_t frameLeft); +static ssize_t pmac_ctx_u8(const u_char *userPtr, size_t userCount, + u_char frame[], ssize_t *frameUsed, + ssize_t frameLeft); +static ssize_t pmac_ctx_s16(const u_char *userPtr, size_t userCount, + u_char frame[], ssize_t *frameUsed, + ssize_t frameLeft); +static ssize_t pmac_ctx_u16(const u_char *userPtr, size_t userCount, + u_char frame[], ssize_t *frameUsed, + ssize_t frameLeft); + +static ssize_t pmac_ct_s16_read(const u_char *userPtr, size_t userCount, + u_char frame[], ssize_t *frameUsed, + ssize_t frameLeft); +static ssize_t pmac_ct_u16_read(const u_char *userPtr, size_t userCount, + u_char frame[], ssize_t *frameUsed, + ssize_t frameLeft); + +/*** Translations ************************************************************/ + +extern int expand_bal; /* Balance factor for expanding (not volume!) */ +static int expand_data; /* Data for expanding */ + +static ssize_t pmac_ct_law(const u_char *userPtr, size_t userCount, + u_char frame[], ssize_t *frameUsed, + ssize_t frameLeft) +{ + short *table = dmasound.soft.format == AFMT_MU_LAW + ? dmasound_ulaw2dma16 : dmasound_alaw2dma16; + ssize_t count, used; + short *p = (short *) &frame[*frameUsed]; + int val, stereo = dmasound.soft.stereo; + + frameLeft >>= 2; + if (stereo) + userCount >>= 1; + used = count = min_t(unsigned long, userCount, frameLeft); + while (count > 0) { + u_char data; + if (get_user(data, userPtr++)) + return -EFAULT; + val = table[data]; + *p++ = val; + if (stereo) { + if (get_user(data, userPtr++)) + return -EFAULT; + val = table[data]; + } + *p++ = val; + count--; + } + *frameUsed += used * 4; + return stereo? used * 2: used; +} + + +static ssize_t pmac_ct_s8(const u_char *userPtr, size_t userCount, + u_char frame[], ssize_t *frameUsed, + ssize_t frameLeft) +{ + ssize_t count, used; + short *p = (short *) &frame[*frameUsed]; + int val, stereo = dmasound.soft.stereo; + + frameLeft >>= 2; + if (stereo) + userCount >>= 1; + used = count = min_t(unsigned long, userCount, frameLeft); + while (count > 0) { + u_char data; + if (get_user(data, userPtr++)) + return -EFAULT; + val = data << 8; + *p++ = val; + if (stereo) { + if (get_user(data, userPtr++)) + return -EFAULT; + val = data << 8; + } + *p++ = val; + count--; + } + *frameUsed += used * 4; + return stereo? used * 2: used; +} + + +static ssize_t pmac_ct_u8(const u_char *userPtr, size_t userCount, + u_char frame[], ssize_t *frameUsed, + ssize_t frameLeft) +{ + ssize_t count, used; + short *p = (short *) &frame[*frameUsed]; + int val, stereo = dmasound.soft.stereo; + + frameLeft >>= 2; + if (stereo) + userCount >>= 1; + used = count = min_t(unsigned long, userCount, frameLeft); + while (count > 0) { + u_char data; + if (get_user(data, userPtr++)) + return -EFAULT; + val = (data ^ 0x80) << 8; + *p++ = val; + if (stereo) { + if (get_user(data, userPtr++)) + return -EFAULT; + val = (data ^ 0x80) << 8; + } + *p++ = val; + count--; + } + *frameUsed += used * 4; + return stereo? used * 2: used; +} + + +static ssize_t pmac_ct_s16(const u_char *userPtr, size_t userCount, + u_char frame[], ssize_t *frameUsed, + ssize_t frameLeft) +{ + ssize_t count, used; + int stereo = dmasound.soft.stereo; + short *fp = (short *) &frame[*frameUsed]; + + frameLeft >>= 2; + userCount >>= (stereo? 2: 1); + used = count = min_t(unsigned long, userCount, frameLeft); + if (!stereo) { + short *up = (short *) userPtr; + while (count > 0) { + short data; + if (get_user(data, up++)) + return -EFAULT; + *fp++ = data; + *fp++ = data; + count--; + } + } else { + if (copy_from_user(fp, userPtr, count * 4)) + return -EFAULT; + } + *frameUsed += used * 4; + return stereo? used * 4: used * 2; +} + +static ssize_t pmac_ct_u16(const u_char *userPtr, size_t userCount, + u_char frame[], ssize_t *frameUsed, + ssize_t frameLeft) +{ + ssize_t count, used; + int mask = (dmasound.soft.format == AFMT_U16_LE? 0x0080: 0x8000); + int stereo = dmasound.soft.stereo; + short *fp = (short *) &frame[*frameUsed]; + short *up = (short *) userPtr; + + frameLeft >>= 2; + userCount >>= (stereo? 2: 1); + used = count = min_t(unsigned long, userCount, frameLeft); + while (count > 0) { + short data; + if (get_user(data, up++)) + return -EFAULT; + data ^= mask; + *fp++ = data; + if (stereo) { + if (get_user(data, up++)) + return -EFAULT; + data ^= mask; + } + *fp++ = data; + count--; + } + *frameUsed += used * 4; + return stereo? used * 4: used * 2; +} + + +static ssize_t pmac_ctx_law(const u_char *userPtr, size_t userCount, + u_char frame[], ssize_t *frameUsed, + ssize_t frameLeft) +{ + unsigned short *table = (unsigned short *) + (dmasound.soft.format == AFMT_MU_LAW + ? dmasound_ulaw2dma16 : dmasound_alaw2dma16); + unsigned int data = expand_data; + unsigned int *p = (unsigned int *) &frame[*frameUsed]; + int bal = expand_bal; + int hSpeed = dmasound.hard.speed, sSpeed = dmasound.soft.speed; + int utotal, ftotal; + int stereo = dmasound.soft.stereo; + + frameLeft >>= 2; + if (stereo) + userCount >>= 1; + ftotal = frameLeft; + utotal = userCount; + while (frameLeft) { + u_char c; + if (bal < 0) { + if (userCount == 0) + break; + if (get_user(c, userPtr++)) + return -EFAULT; + data = table[c]; + if (stereo) { + if (get_user(c, userPtr++)) + return -EFAULT; + data = (data << 16) + table[c]; + } else + data = (data << 16) + data; + userCount--; + bal += hSpeed; + } + *p++ = data; + frameLeft--; + bal -= sSpeed; + } + expand_bal = bal; + expand_data = data; + *frameUsed += (ftotal - frameLeft) * 4; + utotal -= userCount; + return stereo? utotal * 2: utotal; +} + +static ssize_t pmac_ctx_s8(const u_char *userPtr, size_t userCount, + u_char frame[], ssize_t *frameUsed, + ssize_t frameLeft) +{ + unsigned int *p = (unsigned int *) &frame[*frameUsed]; + unsigned int data = expand_data; + int bal = expand_bal; + int hSpeed = dmasound.hard.speed, sSpeed = dmasound.soft.speed; + int stereo = dmasound.soft.stereo; + int utotal, ftotal; + + frameLeft >>= 2; + if (stereo) + userCount >>= 1; + ftotal = frameLeft; + utotal = userCount; + while (frameLeft) { + u_char c; + if (bal < 0) { + if (userCount == 0) + break; + if (get_user(c, userPtr++)) + return -EFAULT; + data = c << 8; + if (stereo) { + if (get_user(c, userPtr++)) + return -EFAULT; + data = (data << 16) + (c << 8); + } else + data = (data << 16) + data; + userCount--; + bal += hSpeed; + } + *p++ = data; + frameLeft--; + bal -= sSpeed; + } + expand_bal = bal; + expand_data = data; + *frameUsed += (ftotal - frameLeft) * 4; + utotal -= userCount; + return stereo? utotal * 2: utotal; +} + + +static ssize_t pmac_ctx_u8(const u_char *userPtr, size_t userCount, + u_char frame[], ssize_t *frameUsed, + ssize_t frameLeft) +{ + unsigned int *p = (unsigned int *) &frame[*frameUsed]; + unsigned int data = expand_data; + int bal = expand_bal; + int hSpeed = dmasound.hard.speed, sSpeed = dmasound.soft.speed; + int stereo = dmasound.soft.stereo; + int utotal, ftotal; + + frameLeft >>= 2; + if (stereo) + userCount >>= 1; + ftotal = frameLeft; + utotal = userCount; + while (frameLeft) { + u_char c; + if (bal < 0) { + if (userCount == 0) + break; + if (get_user(c, userPtr++)) + return -EFAULT; + data = (c ^ 0x80) << 8; + if (stereo) { + if (get_user(c, userPtr++)) + return -EFAULT; + data = (data << 16) + ((c ^ 0x80) << 8); + } else + data = (data << 16) + data; + userCount--; + bal += hSpeed; + } + *p++ = data; + frameLeft--; + bal -= sSpeed; + } + expand_bal = bal; + expand_data = data; + *frameUsed += (ftotal - frameLeft) * 4; + utotal -= userCount; + return stereo? utotal * 2: utotal; +} + + +static ssize_t pmac_ctx_s16(const u_char *userPtr, size_t userCount, + u_char frame[], ssize_t *frameUsed, + ssize_t frameLeft) +{ + unsigned int *p = (unsigned int *) &frame[*frameUsed]; + unsigned int data = expand_data; + unsigned short *up = (unsigned short *) userPtr; + int bal = expand_bal; + int hSpeed = dmasound.hard.speed, sSpeed = dmasound.soft.speed; + int stereo = dmasound.soft.stereo; + int utotal, ftotal; + + frameLeft >>= 2; + userCount >>= (stereo? 2: 1); + ftotal = frameLeft; + utotal = userCount; + while (frameLeft) { + unsigned short c; + if (bal < 0) { + if (userCount == 0) + break; + if (get_user(data, up++)) + return -EFAULT; + if (stereo) { + if (get_user(c, up++)) + return -EFAULT; + data = (data << 16) + c; + } else + data = (data << 16) + data; + userCount--; + bal += hSpeed; + } + *p++ = data; + frameLeft--; + bal -= sSpeed; + } + expand_bal = bal; + expand_data = data; + *frameUsed += (ftotal - frameLeft) * 4; + utotal -= userCount; + return stereo? utotal * 4: utotal * 2; +} + + +static ssize_t pmac_ctx_u16(const u_char *userPtr, size_t userCount, + u_char frame[], ssize_t *frameUsed, + ssize_t frameLeft) +{ + int mask = (dmasound.soft.format == AFMT_U16_LE? 0x0080: 0x8000); + unsigned int *p = (unsigned int *) &frame[*frameUsed]; + unsigned int data = expand_data; + unsigned short *up = (unsigned short *) userPtr; + int bal = expand_bal; + int hSpeed = dmasound.hard.speed, sSpeed = dmasound.soft.speed; + int stereo = dmasound.soft.stereo; + int utotal, ftotal; + + frameLeft >>= 2; + userCount >>= (stereo? 2: 1); + ftotal = frameLeft; + utotal = userCount; + while (frameLeft) { + unsigned short c; + if (bal < 0) { + if (userCount == 0) + break; + if (get_user(data, up++)) + return -EFAULT; + data ^= mask; + if (stereo) { + if (get_user(c, up++)) + return -EFAULT; + data = (data << 16) + (c ^ mask); + } else + data = (data << 16) + data; + userCount--; + bal += hSpeed; + } + *p++ = data; + frameLeft--; + bal -= sSpeed; + } + expand_bal = bal; + expand_data = data; + *frameUsed += (ftotal - frameLeft) * 4; + utotal -= userCount; + return stereo? utotal * 4: utotal * 2; +} + +/* data in routines... */ + +static ssize_t pmac_ct_s8_read(const u_char *userPtr, size_t userCount, + u_char frame[], ssize_t *frameUsed, + ssize_t frameLeft) +{ + ssize_t count, used; + short *p = (short *) &frame[*frameUsed]; + int val, stereo = dmasound.soft.stereo; + + frameLeft >>= 2; + if (stereo) + userCount >>= 1; + used = count = min_t(unsigned long, userCount, frameLeft); + while (count > 0) { + u_char data; + + val = *p++; + data = val >> 8; + if (put_user(data, (u_char *)userPtr++)) + return -EFAULT; + if (stereo) { + val = *p; + data = val >> 8; + if (put_user(data, (u_char *)userPtr++)) + return -EFAULT; + } + p++; + count--; + } + *frameUsed += used * 4; + return stereo? used * 2: used; +} + + +static ssize_t pmac_ct_u8_read(const u_char *userPtr, size_t userCount, + u_char frame[], ssize_t *frameUsed, + ssize_t frameLeft) +{ + ssize_t count, used; + short *p = (short *) &frame[*frameUsed]; + int val, stereo = dmasound.soft.stereo; + + frameLeft >>= 2; + if (stereo) + userCount >>= 1; + used = count = min_t(unsigned long, userCount, frameLeft); + while (count > 0) { + u_char data; + + val = *p++; + data = (val >> 8) ^ 0x80; + if (put_user(data, (u_char *)userPtr++)) + return -EFAULT; + if (stereo) { + val = *p; + data = (val >> 8) ^ 0x80; + if (put_user(data, (u_char *)userPtr++)) + return -EFAULT; + } + p++; + count--; + } + *frameUsed += used * 4; + return stereo? used * 2: used; +} + +static ssize_t pmac_ct_s16_read(const u_char *userPtr, size_t userCount, + u_char frame[], ssize_t *frameUsed, + ssize_t frameLeft) +{ + ssize_t count, used; + int stereo = dmasound.soft.stereo; + short *fp = (short *) &frame[*frameUsed]; + + frameLeft >>= 2; + userCount >>= (stereo? 2: 1); + used = count = min_t(unsigned long, userCount, frameLeft); + if (!stereo) { + short *up = (short *) userPtr; + while (count > 0) { + short data; + data = *fp; + if (put_user(data, up++)) + return -EFAULT; + fp+=2; + count--; + } + } else { + if (copy_to_user((u_char *)userPtr, fp, count * 4)) + return -EFAULT; + } + *frameUsed += used * 4; + return stereo? used * 4: used * 2; +} + +static ssize_t pmac_ct_u16_read(const u_char *userPtr, size_t userCount, + u_char frame[], ssize_t *frameUsed, + ssize_t frameLeft) +{ + ssize_t count, used; + int mask = (dmasound.soft.format == AFMT_U16_LE? 0x0080: 0x8000); + int stereo = dmasound.soft.stereo; + short *fp = (short *) &frame[*frameUsed]; + short *up = (short *) userPtr; + + frameLeft >>= 2; + userCount >>= (stereo? 2: 1); + used = count = min_t(unsigned long, userCount, frameLeft); + while (count > 0) { + int data; + + data = *fp++; + data ^= mask; + if (put_user(data, up++)) + return -EFAULT; + if (stereo) { + data = *fp; + data ^= mask; + if (put_user(data, up++)) + return -EFAULT; + } + fp++; + count--; + } + *frameUsed += used * 4; + return stereo? used * 4: used * 2; +} + +TRANS transAwacsNormal = { + ct_ulaw: pmac_ct_law, + ct_alaw: pmac_ct_law, + ct_s8: pmac_ct_s8, + ct_u8: pmac_ct_u8, + ct_s16be: pmac_ct_s16, + ct_u16be: pmac_ct_u16, + ct_s16le: pmac_ct_s16, + ct_u16le: pmac_ct_u16, +}; + +TRANS transAwacsExpand = { + ct_ulaw: pmac_ctx_law, + ct_alaw: pmac_ctx_law, + ct_s8: pmac_ctx_s8, + ct_u8: pmac_ctx_u8, + ct_s16be: pmac_ctx_s16, + ct_u16be: pmac_ctx_u16, + ct_s16le: pmac_ctx_s16, + ct_u16le: pmac_ctx_u16, +}; + +TRANS transAwacsNormalRead = { + ct_s8: pmac_ct_s8_read, + ct_u8: pmac_ct_u8_read, + ct_s16be: pmac_ct_s16_read, + ct_u16be: pmac_ct_u16_read, + ct_s16le: pmac_ct_s16_read, + ct_u16le: pmac_ct_u16_read, +}; + +/* translation tables */ +/* 16 bit mu-law */ + +static short dmasound_ulaw2dma16[] = { + -32124, -31100, -30076, -29052, -28028, -27004, -25980, -24956, + -23932, -22908, -21884, -20860, -19836, -18812, -17788, -16764, + -15996, -15484, -14972, -14460, -13948, -13436, -12924, -12412, + -11900, -11388, -10876, -10364, -9852, -9340, -8828, -8316, + -7932, -7676, -7420, -7164, -6908, -6652, -6396, -6140, + -5884, -5628, -5372, -5116, -4860, -4604, -4348, -4092, + -3900, -3772, -3644, -3516, -3388, -3260, -3132, -3004, + -2876, -2748, -2620, -2492, -2364, -2236, -2108, -1980, + -1884, -1820, -1756, -1692, -1628, -1564, -1500, -1436, + -1372, -1308, -1244, -1180, -1116, -1052, -988, -924, + -876, -844, -812, -780, -748, -716, -684, -652, + -620, -588, -556, -524, -492, -460, -428, -396, + -372, -356, -340, -324, -308, -292, -276, -260, + -244, -228, -212, -196, -180, -164, -148, -132, + -120, -112, -104, -96, -88, -80, -72, -64, + -56, -48, -40, -32, -24, -16, -8, 0, + 32124, 31100, 30076, 29052, 28028, 27004, 25980, 24956, + 23932, 22908, 21884, 20860, 19836, 18812, 17788, 16764, + 15996, 15484, 14972, 14460, 13948, 13436, 12924, 12412, + 11900, 11388, 10876, 10364, 9852, 9340, 8828, 8316, + 7932, 7676, 7420, 7164, 6908, 6652, 6396, 6140, + 5884, 5628, 5372, 5116, 4860, 4604, 4348, 4092, + 3900, 3772, 3644, 3516, 3388, 3260, 3132, 3004, + 2876, 2748, 2620, 2492, 2364, 2236, 2108, 1980, + 1884, 1820, 1756, 1692, 1628, 1564, 1500, 1436, + 1372, 1308, 1244, 1180, 1116, 1052, 988, 924, + 876, 844, 812, 780, 748, 716, 684, 652, + 620, 588, 556, 524, 492, 460, 428, 396, + 372, 356, 340, 324, 308, 292, 276, 260, + 244, 228, 212, 196, 180, 164, 148, 132, + 120, 112, 104, 96, 88, 80, 72, 64, + 56, 48, 40, 32, 24, 16, 8, 0, +}; + +/* 16 bit A-law */ + +static short dmasound_alaw2dma16[] = { + -5504, -5248, -6016, -5760, -4480, -4224, -4992, -4736, + -7552, -7296, -8064, -7808, -6528, -6272, -7040, -6784, + -2752, -2624, -3008, -2880, -2240, -2112, -2496, -2368, + -3776, -3648, -4032, -3904, -3264, -3136, -3520, -3392, + -22016, -20992, -24064, -23040, -17920, -16896, -19968, -18944, + -30208, -29184, -32256, -31232, -26112, -25088, -28160, -27136, + -11008, -10496, -12032, -11520, -8960, -8448, -9984, -9472, + -15104, -14592, -16128, -15616, -13056, -12544, -14080, -13568, + -344, -328, -376, -360, -280, -264, -312, -296, + -472, -456, -504, -488, -408, -392, -440, -424, + -88, -72, -120, -104, -24, -8, -56, -40, + -216, -200, -248, -232, -152, -136, -184, -168, + -1376, -1312, -1504, -1440, -1120, -1056, -1248, -1184, + -1888, -1824, -2016, -1952, -1632, -1568, -1760, -1696, + -688, -656, -752, -720, -560, -528, -624, -592, + -944, -912, -1008, -976, -816, -784, -880, -848, + 5504, 5248, 6016, 5760, 4480, 4224, 4992, 4736, + 7552, 7296, 8064, 7808, 6528, 6272, 7040, 6784, + 2752, 2624, 3008, 2880, 2240, 2112, 2496, 2368, + 3776, 3648, 4032, 3904, 3264, 3136, 3520, 3392, + 22016, 20992, 24064, 23040, 17920, 16896, 19968, 18944, + 30208, 29184, 32256, 31232, 26112, 25088, 28160, 27136, + 11008, 10496, 12032, 11520, 8960, 8448, 9984, 9472, + 15104, 14592, 16128, 15616, 13056, 12544, 14080, 13568, + 344, 328, 376, 360, 280, 264, 312, 296, + 472, 456, 504, 488, 408, 392, 440, 424, + 88, 72, 120, 104, 24, 8, 56, 40, + 216, 200, 248, 232, 152, 136, 184, 168, + 1376, 1312, 1504, 1440, 1120, 1056, 1248, 1184, + 1888, 1824, 2016, 1952, 1632, 1568, 1760, 1696, + 688, 656, 752, 720, 560, 528, 624, 592, + 944, 912, 1008, 976, 816, 784, 880, 848, +}; diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/sound/emu10k1/main.c linux-2.5/drivers/sound/emu10k1/main.c --- linux-2.5.1/drivers/sound/emu10k1/main.c Tue Oct 9 17:53:18 2001 +++ linux-2.5/drivers/sound/emu10k1/main.c Thu Dec 13 16:32:36 2001 @@ -1127,7 +1127,7 @@ name: "emu10k1", id_table: emu10k1_pci_tbl, probe: emu10k1_probe, - remove: emu10k1_remove, + remove: __devexit_p(emu10k1_remove), }; static int __init emu10k1_init_module(void) diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/sound/i810_audio.c linux-2.5/drivers/sound/i810_audio.c --- linux-2.5.1/drivers/sound/i810_audio.c Fri Nov 9 22:07:41 2001 +++ linux-2.5/drivers/sound/i810_audio.c Thu Dec 13 16:32:36 2001 @@ -1405,10 +1405,9 @@ if (dmabuf->count < 0) { dmabuf->count = 0; } - cnt = dmabuf->dmasize - dmabuf->fragsize - dmabuf->count; - // this is to make the copy_from_user simpler below - if(cnt > (dmabuf->dmasize - swptr)) - cnt = dmabuf->dmasize - swptr; + cnt = dmabuf->dmasize - swptr; + if(cnt > (dmabuf->dmasize - dmabuf->count)) + cnt = dmabuf->dmasize - dmabuf->count; spin_unlock_irqrestore(&state->card->lock, flags); #ifdef DEBUG2 @@ -1419,16 +1418,13 @@ if (cnt <= 0) { unsigned long tmo; // There is data waiting to be played + i810_update_lvi(state,0); if(!dmabuf->enable && dmabuf->count) { /* force the starting incase SETTRIGGER has been used */ /* to stop it, otherwise this is a deadlock situation */ dmabuf->trigger |= PCM_ENABLE_OUTPUT; start_dac(state); } - // Update the LVI pointer in case we have already - // written data in this syscall and are just waiting - // on the tail bit of data - i810_update_lvi(state,0); if (file->f_flags & O_NONBLOCK) { if (!ret) ret = -EAGAIN; goto ret; @@ -1860,7 +1856,7 @@ if(dmabuf->mapped) abinfo.bytes = dmabuf->count; else - abinfo.bytes = dmabuf->dmasize - dmabuf->count; + abinfo.bytes = dmabuf->dmasize - dmabuf->fragsize - dmabuf->count; abinfo.fragments = abinfo.bytes / dmabuf->userfragsize; spin_unlock_irqrestore(&state->card->lock, flags); #ifdef DEBUG diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/sound/opl3sa2.c linux-2.5/drivers/sound/opl3sa2.c --- linux-2.5.1/drivers/sound/opl3sa2.c Sun Nov 25 17:43:42 2001 +++ linux-2.5/drivers/sound/opl3sa2.c Fri Dec 28 11:21:15 2001 @@ -55,6 +55,7 @@ * sb_card.c and awe_wave.c. (Dec 12, 2000) * Scott Murray Some small cleanups to the init code output. * (Jan 7, 2001) + * Zwane Mwaikambo Added PM support. (Dec 4 2001) * */ @@ -62,13 +63,16 @@ #include <linux/init.h> #include <linux/module.h> #include <linux/isapnp.h> - +#include <linux/pm.h> #include "sound_config.h" #include "ad1848.h" #include "mpu401.h" +#define OPL3SA2_MODULE_NAME "opl3sa2" + /* Useful control port indexes: */ +#define OPL3SA2_PM 0x01 #define OPL3SA2_SYS_CTRL 0x02 #define OPL3SA2_IRQ_CONFIG 0x03 #define OPL3SA2_DMA_CONFIG 0x06 @@ -86,6 +90,11 @@ #define DEFAULT_MIC 50 #define DEFAULT_TIMBRE 0 +/* Power saving modes */ +#define OPL3SA2_PM_MODE1 0x05 +#define OPL3SA2_PM_MODE2 0x04 +#define OPL3SA2_PM_MODE3 0x03 + /* For checking against what the card returns: */ #define VERSION_UNKNOWN 0 #define VERSION_YMF711 1 @@ -121,6 +130,10 @@ typedef struct opl3sa2_mixerdata_tag { unsigned short cfg_port; unsigned short padding; + unsigned char pm_reg; + unsigned int in_suspend; + struct pm_dev *pmdev; + unsigned int card; unsigned int volume_l; unsigned int volume_r; unsigned int mic; @@ -328,6 +341,20 @@ } +static void opl3sa2_mixer_restore(opl3sa2_mixerdata* devc, int card) +{ + if (devc) { + opl3sa2_set_volume(devc, devc->volume_l, devc->volume_r); + opl3sa2_set_mic(devc, devc->mic); + + if (chipset[card] == CHIPSET_OPL3SA3) { + opl3sa3_set_bass(devc, devc->bass_l, devc->bass_r); + opl3sa3_set_treble(devc, devc->treble_l, devc->treble_r); + } + } +} + + static inline void arg_to_vol_mono(unsigned int vol, int* value) { int left; @@ -608,9 +635,9 @@ char tag; /* - * Verify that the I/O port range is free. + * Try and allocate our I/O port range. */ - if(check_region(hw_config->io_base, 2)) { + if(!request_region(hw_config->io_base, 2, OPL3SA2_MODULE_NAME)) { printk(KERN_ERR "opl3sa2: Control I/O port %#x not free\n", hw_config->io_base); return 0; @@ -699,7 +726,6 @@ static void __init attach_opl3sa2(struct address_info* hw_config, int card) { - request_region(hw_config->io_base, 2, chipset_name[card]); /* Initialize IRQ configuration to IRQ-B: -, IRQ-A: WSS+MPU+OPL3 */ opl3sa2_write(hw_config->io_base, OPL3SA2_IRQ_CONFIG, 0x0d); @@ -892,6 +918,81 @@ /* End of component functions */ +/* Power Management support functions */ +static int opl3sa2_suspend(struct pm_dev *pdev, unsigned char pm_mode) +{ + unsigned long flags; + opl3sa2_mixerdata *p; + + if (!pdev) + return -EINVAL; + + save_flags(flags); + cli(); + + p = (opl3sa2_mixerdata *) pdev->data; + + switch (pm_mode) { + case 1: + pm_mode = OPL3SA2_PM_MODE1; + break; + case 2: + pm_mode = OPL3SA2_PM_MODE2; + break; + case 3: + pm_mode = OPL3SA2_PM_MODE3; + break; + default: + /* we don't know howto handle this... */ + restore_flags(flags); + return -EBUSY; + } + + p->in_suspend = 1; + /* its supposed to automute before suspending, so we wont bother */ + opl3sa2_read(p->cfg_port, OPL3SA2_PM, &p->pm_reg); + opl3sa2_write(p->cfg_port, OPL3SA2_PM, p->pm_reg | pm_mode); + /* wait a while for the clock oscillator to stabilise */ + mdelay(10); + + restore_flags(flags); + return 0; +} + +static int opl3sa2_resume(struct pm_dev *pdev) +{ + unsigned long flags; + opl3sa2_mixerdata *p; + + if (!pdev) + return -EINVAL; + + p = (opl3sa2_mixerdata *) pdev->data; + save_flags(flags); + cli(); + + /* I don't think this is necessary */ + opl3sa2_write(p->cfg_port, OPL3SA2_PM, p->pm_reg); + opl3sa2_mixer_restore(p, p->card); + p->in_suspend = 0; + + restore_flags(flags); + return 0; +} + +static int opl3sa2_pm_callback(struct pm_dev *pdev, pm_request_t rqst, void *data) +{ + unsigned char mode = (unsigned char)data; + + switch (rqst) { + case PM_SUSPEND: + return opl3sa2_suspend(pdev, mode); + + case PM_RESUME: + return opl3sa2_resume(pdev); + } + return 0; +} /* * Install OPL3-SA2 based card(s). @@ -989,6 +1090,12 @@ attach_opl3sa2_mss(&cfg_mss[card]); attach_opl3sa2_mixer(&cfg[card], card); + opl3sa2_data[card].card = card; + /* register our power management capabilities */ + opl3sa2_data[card].pmdev = pm_register(PM_ISA_DEV, card, opl3sa2_pm_callback); + if (opl3sa2_data[card].pmdev) + opl3sa2_data[card].pmdev->data = &opl3sa2_data[card]; + /* * Set the Yamaha 3D enhancement mode (aka Ymersion) if asked to and * it's supported. @@ -1033,6 +1140,9 @@ int card; for(card = 0; card < opl3sa2_cards_num; card++) { + if (opl3sa2_data[card].pmdev) + pm_unregister(opl3sa2_data[card].pmdev); + if(cfg_mpu[card].slots[1] != -1) { unload_opl3sa2_mpu(&cfg_mpu[card]); } diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/sound/sb_card.c linux-2.5/drivers/sound/sb_card.c --- linux-2.5.1/drivers/sound/sb_card.c Sun Nov 25 17:43:42 2001 +++ linux-2.5/drivers/sound/sb_card.c Thu Dec 13 16:32:36 2001 @@ -378,6 +378,11 @@ 0,0,0,0, 0,1,1,-1}, {"Sound Blaster AWE 32", + ISAPNP_VENDOR('C','T','L'), ISAPNP_DEVICE(0x0047), + ISAPNP_VENDOR('C','T','L'), ISAPNP_FUNCTION(0x0031), + 0,0,0,0, + 0,1,1,-1}, + {"Sound Blaster AWE 32", ISAPNP_VENDOR('C','T','L'), ISAPNP_DEVICE(0x0048), ISAPNP_VENDOR('C','T','L'), ISAPNP_FUNCTION(0x0031), 0,0,0,0, diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/sound/soundcard.c linux-2.5/drivers/sound/soundcard.c --- linux-2.5.1/drivers/sound/soundcard.c Sun Sep 30 19:26:08 2001 +++ linux-2.5/drivers/sound/soundcard.c Sun Dec 30 21:17:30 2001 @@ -35,7 +35,6 @@ #include <linux/kmod.h> #include <asm/dma.h> #include <asm/io.h> -#include <asm/segment.h> #include <linux/wait.h> #include <linux/slab.h> #include <linux/ioport.h> diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/sound/sscape.c linux-2.5/drivers/sound/sscape.c --- linux-2.5.1/drivers/sound/sscape.c Sun Sep 30 19:26:08 2001 +++ linux-2.5/drivers/sound/sscape.c Sun Dec 30 21:17:30 2001 @@ -34,7 +34,6 @@ #include <linux/kmod.h> #include <asm/dma.h> #include <asm/io.h> -#include <asm/segment.h> #include <linux/wait.h> #include <linux/slab.h> #include <linux/ioport.h> diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/sound/via82cxxx_audio.c linux-2.5/drivers/sound/via82cxxx_audio.c --- linux-2.5.1/drivers/sound/via82cxxx_audio.c Mon Dec 10 18:39:20 2001 +++ linux-2.5/drivers/sound/via82cxxx_audio.c Sun Dec 16 07:00:17 2001 @@ -365,7 +365,7 @@ name: VIA_MODULE_NAME, id_table: via_pci_tbl, probe: via_init_one, - remove: via_remove_one, + remove: __devexit_p(via_remove_one), }; @@ -3271,7 +3271,7 @@ } -static void __exit via_remove_one (struct pci_dev *pdev) +static void __devexit via_remove_one (struct pci_dev *pdev) { struct via_info *card; diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/sound/ymfpci.c linux-2.5/drivers/sound/ymfpci.c --- linux-2.5.1/drivers/sound/ymfpci.c Sun Nov 25 18:17:47 2001 +++ linux-2.5/drivers/sound/ymfpci.c Tue Dec 18 14:43:03 2001 @@ -39,6 +39,7 @@ * native synthesizer through a playback slot. * - Use new 2.3.x cache coherent PCI DMA routines instead of virt_to_bus. * - Make the thing big endian compatible. ALSA has it done. + * - 2001/11/29 ac97_save_state */ #include <linux/config.h> @@ -155,7 +156,7 @@ schedule_timeout(1); } } while (end_time - (signed long)jiffies >= 0); - printk("ymfpci_codec_ready: codec %i is not ready [0x%x]\n", + printk(KERN_ERR "ymfpci_codec_ready: codec %i is not ready [0x%x]\n", secondary, ymfpci_readw(codec, reg)); return -EBUSY; } @@ -173,19 +174,19 @@ static u16 ymfpci_codec_read(struct ac97_codec *dev, u8 reg) { - ymfpci_t *codec = dev->private_data; + ymfpci_t *unit = dev->private_data; + int i; - if (ymfpci_codec_ready(codec, 0, 0)) + if (ymfpci_codec_ready(unit, 0, 0)) return ~0; - ymfpci_writew(codec, YDSXGR_AC97CMDADR, YDSXG_AC97READCMD | reg); - if (ymfpci_codec_ready(codec, 0, 0)) + ymfpci_writew(unit, YDSXGR_AC97CMDADR, YDSXG_AC97READCMD | reg); + if (ymfpci_codec_ready(unit, 0, 0)) return ~0; - if (codec->pci->device == PCI_DEVICE_ID_YAMAHA_744 && codec->rev < 2) { - int i; + if (unit->pci->device == PCI_DEVICE_ID_YAMAHA_744 && unit->rev < 2) { for (i = 0; i < 600; i++) - ymfpci_readw(codec, YDSXGR_PRISTATUSDATA); + ymfpci_readw(unit, YDSXGR_PRISTATUSDATA); } - return ymfpci_readw(codec, YDSXGR_PRISTATUSDATA); + return ymfpci_readw(unit, YDSXGR_PRISTATUSDATA); } /* @@ -404,7 +405,7 @@ dmabuf->ready = 1; #if 0 - printk("prog_dmabuf: rate %d format 0x%x," + printk(KERN_DEBUG "prog_dmabuf: rate %d format 0x%x," " numfrag %d fragsize %d dmasize %d\n", state->format.rate, state->format.format, dmabuf->numfrag, dmabuf->fragsize, dmabuf->dmasize); @@ -615,7 +616,7 @@ dmabuf->hwptr = pos; if (dmabuf->count == 0) { - printk("ymfpci%d: %d: strain: hwptr %d\n", + printk(KERN_ERR "ymfpci%d: %d: strain: hwptr %d\n", codec->dev_audio, voice->number, dmabuf->hwptr); ymf_playback_trigger(codec, ypcm, 0); } @@ -633,7 +634,7 @@ /* * Lost interrupt or other screwage. */ - printk("ymfpci%d: %d: lost: delta %d" + printk(KERN_ERR "ymfpci%d: %d: lost: delta %d" " hwptr %d swptr %d distance %d count %d\n", codec->dev_audio, voice->number, delta, dmabuf->hwptr, swptr, distance, dmabuf->count); @@ -641,10 +642,10 @@ /* * Normal end of DMA. */ -// printk("ymfpci%d: %d: done: delta %d" -// " hwptr %d swptr %d distance %d count %d\n", -// codec->dev_audio, voice->number, delta, -// dmabuf->hwptr, swptr, distance, dmabuf->count); + YMFDBGI("ymfpci%d: %d: done: delta %d" + " hwptr %d swptr %d distance %d count %d\n", + codec->dev_audio, voice->number, delta, + dmabuf->hwptr, swptr, distance, dmabuf->count); } played = dmabuf->count; if (ypcm->running) { @@ -1442,13 +1443,14 @@ { struct ymf_state *state = (struct ymf_state *)file->private_data; struct ymf_dmabuf *dmabuf; + int redzone; unsigned long flags; unsigned int mask = 0; if (file->f_mode & FMODE_WRITE) poll_wait(file, &state->wpcm.dmabuf.wait, wait); - // if (file->f_mode & FMODE_READ) - // poll_wait(file, &dmabuf->wait, wait); + if (file->f_mode & FMODE_READ) + poll_wait(file, &state->rpcm.dmabuf.wait, wait); spin_lock_irqsave(&state->unit->reg_lock, flags); if (file->f_mode & FMODE_READ) { @@ -1457,12 +1459,21 @@ mask |= POLLIN | POLLRDNORM; } if (file->f_mode & FMODE_WRITE) { + redzone = ymf_calc_lend(state->format.rate); + redzone <<= state->format.shift; + redzone *= 3; + dmabuf = &state->wpcm.dmabuf; if (dmabuf->mapped) { if (dmabuf->count >= (signed)dmabuf->fragsize) mask |= POLLOUT | POLLWRNORM; } else { - if ((signed)dmabuf->dmasize >= dmabuf->count + (signed)dmabuf->fragsize) + /* + * Don't select unless a full fragment is available. + * Otherwise artsd does GETOSPACE, sees 0, and loops. + */ + if (dmabuf->count + redzone + dmabuf->fragsize + <= dmabuf->dmasize) mask |= POLLOUT | POLLWRNORM; } } @@ -1497,6 +1508,7 @@ return -EAGAIN; dmabuf->mapped = 1; +/* P3 */ printk(KERN_INFO "ymfpci: using memory mapped sound, untested!\n"); return 0; } @@ -1508,13 +1520,16 @@ unsigned long flags; audio_buf_info abinfo; count_info cinfo; + int redzone; int val; switch (cmd) { case OSS_GETVERSION: + YMFDBGX("ymf_ioctl: cmd 0x%x(GETVER) arg 0x%lx\n", cmd, arg); return put_user(SOUND_VERSION, (int *)arg); case SNDCTL_DSP_RESET: + YMFDBGX("ymf_ioctl: cmd 0x%x(RESET)\n", cmd); if (file->f_mode & FMODE_WRITE) { ymf_wait_dac(state); dmabuf = &state->wpcm.dmabuf; @@ -1536,6 +1551,7 @@ return 0; case SNDCTL_DSP_SYNC: + YMFDBGX("ymf_ioctl: cmd 0x%x(SYNC)\n", cmd); if (file->f_mode & FMODE_WRITE) { dmabuf = &state->wpcm.dmabuf; if (file->f_flags & O_NONBLOCK) { @@ -1554,6 +1570,7 @@ case SNDCTL_DSP_SPEED: /* set smaple rate */ if (get_user(val, (int *)arg)) return -EFAULT; + YMFDBGX("ymf_ioctl: cmd 0x%x(SPEED) sp %d\n", cmd, val); if (val >= 8000 && val <= 48000) { if (file->f_mode & FMODE_WRITE) { ymf_wait_dac(state); @@ -1585,6 +1602,7 @@ case SNDCTL_DSP_STEREO: /* set stereo or mono channel */ if (get_user(val, (int *)arg)) return -EFAULT; + YMFDBGX("ymf_ioctl: cmd 0x%x(STEREO) st %d\n", cmd, val); if (file->f_mode & FMODE_WRITE) { ymf_wait_dac(state); dmabuf = &state->wpcm.dmabuf; @@ -1606,24 +1624,31 @@ return 0; case SNDCTL_DSP_GETBLKSIZE: + YMFDBGX("ymf_ioctl: cmd 0x%x(GETBLK)\n", cmd); if (file->f_mode & FMODE_WRITE) { if ((val = prog_dmabuf(state, 0))) return val; - return put_user(state->wpcm.dmabuf.fragsize, (int *)arg); + val = state->wpcm.dmabuf.fragsize; + YMFDBGX("ymf_ioctl: GETBLK w %d\n", val); + return put_user(val, (int *)arg); } if (file->f_mode & FMODE_READ) { if ((val = prog_dmabuf(state, 1))) return val; - return put_user(state->rpcm.dmabuf.fragsize, (int *)arg); + val = state->rpcm.dmabuf.fragsize; + YMFDBGX("ymf_ioctl: GETBLK r %d\n", val); + return put_user(val, (int *)arg); } return -EINVAL; case SNDCTL_DSP_GETFMTS: /* Returns a mask of supported sample format*/ + YMFDBGX("ymf_ioctl: cmd 0x%x(GETFMTS)\n", cmd); return put_user(AFMT_S16_LE|AFMT_U8, (int *)arg); case SNDCTL_DSP_SETFMT: /* Select sample format */ if (get_user(val, (int *)arg)) return -EFAULT; + YMFDBGX("ymf_ioctl: cmd 0x%x(SETFMT) fmt %d\n", cmd, val); if (val == AFMT_S16_LE || val == AFMT_U8) { if (file->f_mode & FMODE_WRITE) { ymf_wait_dac(state); @@ -1649,6 +1674,7 @@ case SNDCTL_DSP_CHANNELS: if (get_user(val, (int *)arg)) return -EFAULT; + YMFDBGX("ymf_ioctl: cmd 0x%x(CHAN) ch %d\n", cmd, val); if (val != 0) { if (file->f_mode & FMODE_WRITE) { ymf_wait_dac(state); @@ -1676,6 +1702,7 @@ return put_user(state->format.voices, (int *)arg); case SNDCTL_DSP_POST: + YMFDBGX("ymf_ioctl: cmd 0x%x(POST)\n", cmd); /* * Quoting OSS PG: * The ioctl SNDCTL_DSP_POST is a lightweight version of @@ -1697,6 +1724,10 @@ case SNDCTL_DSP_SETFRAGMENT: if (get_user(val, (int *)arg)) return -EFAULT; + YMFDBGX("ymf_ioctl: cmd 0x%x(SETFRAG) fr 0x%04x:%04x(%d:%d)\n", + cmd, + (val >> 16) & 0xFFFF, val & 0xFFFF, + (val >> 16) & 0xFFFF, val & 0xFFFF); dmabuf = &state->wpcm.dmabuf; dmabuf->ossfragshift = val & 0xffff; dmabuf->ossmaxfrags = (val >> 16) & 0xffff; @@ -1707,20 +1738,25 @@ return 0; case SNDCTL_DSP_GETOSPACE: + YMFDBGX("ymf_ioctl: cmd 0x%x(GETOSPACE)\n", cmd); if (!(file->f_mode & FMODE_WRITE)) return -EINVAL; dmabuf = &state->wpcm.dmabuf; if (!dmabuf->ready && (val = prog_dmabuf(state, 0)) != 0) return val; + redzone = ymf_calc_lend(state->format.rate); + redzone <<= state->format.shift; + redzone *= 3; spin_lock_irqsave(&state->unit->reg_lock, flags); abinfo.fragsize = dmabuf->fragsize; - abinfo.bytes = dmabuf->dmasize - dmabuf->count; + abinfo.bytes = dmabuf->dmasize - dmabuf->count - redzone; abinfo.fragstotal = dmabuf->numfrag; abinfo.fragments = abinfo.bytes >> dmabuf->fragshift; spin_unlock_irqrestore(&state->unit->reg_lock, flags); return copy_to_user((void *)arg, &abinfo, sizeof(abinfo)) ? -EFAULT : 0; case SNDCTL_DSP_GETISPACE: + YMFDBGX("ymf_ioctl: cmd 0x%x(GETISPACE)\n", cmd); if (!(file->f_mode & FMODE_READ)) return -EINVAL; dmabuf = &state->rpcm.dmabuf; @@ -1735,15 +1771,18 @@ return copy_to_user((void *)arg, &abinfo, sizeof(abinfo)) ? -EFAULT : 0; case SNDCTL_DSP_NONBLOCK: + YMFDBGX("ymf_ioctl: cmd 0x%x(NONBLOCK)\n", cmd); file->f_flags |= O_NONBLOCK; return 0; case SNDCTL_DSP_GETCAPS: + YMFDBGX("ymf_ioctl: cmd 0x%x(GETCAPS)\n", cmd); /* return put_user(DSP_CAP_REALTIME|DSP_CAP_TRIGGER|DSP_CAP_MMAP, (int *)arg); */ return put_user(0, (int *)arg); case SNDCTL_DSP_GETIPTR: + YMFDBGX("ymf_ioctl: cmd 0x%x(GETIPTR)\n", cmd); if (!(file->f_mode & FMODE_READ)) return -EINVAL; dmabuf = &state->rpcm.dmabuf; @@ -1751,13 +1790,13 @@ cinfo.bytes = dmabuf->total_bytes; cinfo.blocks = dmabuf->count >> dmabuf->fragshift; cinfo.ptr = dmabuf->hwptr; - /* XXX fishy - breaks invariant count=hwptr-swptr */ - if (dmabuf->mapped) - dmabuf->count &= dmabuf->fragsize-1; spin_unlock_irqrestore(&state->unit->reg_lock, flags); + YMFDBGX("ymf_ioctl: GETIPTR ptr %d bytes %d\n", + cinfo.ptr, cinfo.bytes); return copy_to_user((void *)arg, &cinfo, sizeof(cinfo)) ? -EFAULT : 0; case SNDCTL_DSP_GETOPTR: + YMFDBGX("ymf_ioctl: cmd 0x%x(GETOPTR)\n", cmd); if (!(file->f_mode & FMODE_WRITE)) return -EINVAL; dmabuf = &state->wpcm.dmabuf; @@ -1765,22 +1804,25 @@ cinfo.bytes = dmabuf->total_bytes; cinfo.blocks = dmabuf->count >> dmabuf->fragshift; cinfo.ptr = dmabuf->hwptr; - /* XXX fishy - breaks invariant count=swptr-hwptr */ - if (dmabuf->mapped) - dmabuf->count &= dmabuf->fragsize-1; spin_unlock_irqrestore(&state->unit->reg_lock, flags); + YMFDBGX("ymf_ioctl: GETOPTR ptr %d bytes %d\n", + cinfo.ptr, cinfo.bytes); return copy_to_user((void *)arg, &cinfo, sizeof(cinfo)) ? -EFAULT : 0; case SNDCTL_DSP_SETDUPLEX: /* XXX TODO */ + YMFDBGX("ymf_ioctl: cmd 0x%x(SETDUPLEX)\n", cmd); return -EINVAL; case SOUND_PCM_READ_RATE: + YMFDBGX("ymf_ioctl: cmd 0x%x(READ_RATE)\n", cmd); return put_user(state->format.rate, (int *)arg); case SOUND_PCM_READ_CHANNELS: + YMFDBGX("ymf_ioctl: cmd 0x%x(READ_CH)\n", cmd); return put_user(state->format.voices, (int *)arg); case SOUND_PCM_READ_BITS: + YMFDBGX("ymf_ioctl: cmd 0x%x(READ_BITS)\n", cmd); return put_user(AFMT_S16_LE, (int *)arg); case SNDCTL_DSP_MAPINBUF: @@ -1866,8 +1908,8 @@ } #if 0 /* test if interrupts work */ - ymfpci_writew(codec, YDSXGR_TIMERCOUNT, 0xfffe); /* ~ 680ms */ - ymfpci_writeb(codec, YDSXGR_TIMERCTRL, + ymfpci_writew(unit, YDSXGR_TIMERCOUNT, 0xfffe); /* ~ 680ms */ + ymfpci_writeb(unit, YDSXGR_TIMERCTRL, (YDSXGR_TIMERCTRL_TEN|YDSXGR_TIMERCTRL_TIEN)); #endif up(&unit->open_sem); @@ -1895,13 +1937,13 @@ static int ymf_release(struct inode *inode, struct file *file) { struct ymf_state *state = (struct ymf_state *)file->private_data; - ymfpci_t *codec = state->unit; + ymfpci_t *unit = state->unit; #if 0 /* test if interrupts work */ - ymfpci_writeb(codec, YDSXGR_TIMERCTRL, 0); + ymfpci_writeb(unit, YDSXGR_TIMERCTRL, 0); #endif - down(&codec->open_sem); + down(&unit->open_sem); /* * XXX Solve the case of O_NONBLOCK close - don't deallocate here. @@ -1918,7 +1960,7 @@ file->private_data = NULL; /* Can you tell I programmed Solaris */ kfree(state); - up(&codec->open_sem); + up(&unit->open_sem); return 0; } @@ -1928,10 +1970,10 @@ */ static int ymf_open_mixdev(struct inode *inode, struct file *file) { - int i; int minor = MINOR(inode->i_rdev); struct list_head *list; ymfpci_t *unit; + int i; list_for_each(list, &ymf_devs) { unit = list_entry(list, ymfpci_t, ymf_devs); @@ -1988,23 +2030,26 @@ static int ymf_suspend(struct pci_dev *pcidev, u32 unused) { - int i; struct ymf_unit *unit = pci_get_drvdata(pcidev); unsigned long flags; struct ymf_dmabuf *dmabuf; struct list_head *p; struct ymf_state *state; struct ac97_codec *codec; + int i; spin_lock_irqsave(&unit->reg_lock, flags); unit->suspended = 1; + /* + * XXX Talk to Kai to remove ac97_save_state before it's too late! + * Other drivers call ac97_reset, which does not have + * a save counterpart. Current ac97_save_state is empty. + */ for (i = 0; i < NR_AC97; i++) { - codec = unit->ac97_codec[i]; - if (!codec) - continue; - ac97_save_state(codec); + if ((codec = unit->ac97_codec[i]) != NULL) + ac97_save_state(codec); } list_for_each(p, &unit->states) { @@ -2031,12 +2076,12 @@ static int ymf_resume(struct pci_dev *pcidev) { - int i; struct ymf_unit *unit = pci_get_drvdata(pcidev); unsigned long flags; struct list_head *p; struct ymf_state *state; struct ac97_codec *codec; + int i; ymfpci_aclink_reset(unit->pci); ymfpci_codec_ready(unit, 0, 1); /* prints diag if not ready. */ @@ -2063,6 +2108,11 @@ ac97_restore_state(codec); } + for (i = 0; i < NR_AC97; i++) { + if ((codec = unit->ac97_codec[i]) != NULL) + ac97_restore_state(codec); + } + unit->suspended = 0; list_for_each(p, &unit->states) { state = list_entry(p, struct ymf_state, chain); @@ -2160,12 +2210,15 @@ { u8 cmd; + /* + * In the 744, 754 only 0x01 exists, 0x02 is undefined. + * It does not seem to hurt to trip both regardless of revision. + */ pci_read_config_byte(pci, PCIR_DSXGCTRL, &cmd); - if (cmd & 0x03) { - pci_write_config_byte(pci, PCIR_DSXGCTRL, cmd & 0xfc); - pci_write_config_byte(pci, PCIR_DSXGCTRL, cmd | 0x03); - pci_write_config_byte(pci, PCIR_DSXGCTRL, cmd & 0xfc); - } + pci_write_config_byte(pci, PCIR_DSXGCTRL, cmd & 0xfc); + pci_write_config_byte(pci, PCIR_DSXGCTRL, cmd | 0x03); + pci_write_config_byte(pci, PCIR_DSXGCTRL, cmd & 0xfc); + pci_write_config_word(pci, PCIR_DSXPWRCTRL1, 0); pci_write_config_word(pci, PCIR_DSXPWRCTRL2, 0); } @@ -2357,7 +2410,7 @@ codec->codec_write = ymfpci_codec_write; if (ac97_probe_codec(codec) == 0) { - printk("ymfpci: ac97_probe_codec failed\n"); + printk(KERN_ERR "ymfpci: ac97_probe_codec failed\n"); goto out_kfree; } @@ -2398,6 +2451,7 @@ static int __devinit ymf_probe_one(struct pci_dev *pcidev, const struct pci_device_id *ent) { u16 ctrl; + unsigned long base; ymfpci_t *codec; int err; @@ -2406,6 +2460,7 @@ printk(KERN_ERR "ymfpci: pci_enable_device failed\n"); return err; } + base = pci_resource_start(pcidev, 0); if ((codec = kmalloc(sizeof(ymfpci_t), GFP_KERNEL)) == NULL) { printk(KERN_ERR "ymfpci: no core\n"); @@ -2420,16 +2475,21 @@ codec->pci = pcidev; pci_read_config_byte(pcidev, PCI_REVISION_ID, &codec->rev); - codec->reg_area_virt = ioremap(pci_resource_start(pcidev, 0), 0x8000); - if (codec->reg_area_virt == NULL) { - printk(KERN_ERR "ymfpci: unable to map registers\n"); + + if (request_mem_region(base, 0x8000, "ymfpci") == NULL) { + printk(KERN_ERR "ymfpci: unable to request mem region\n"); goto out_free; } + if ((codec->reg_area_virt = ioremap(base, 0x8000)) == NULL) { + printk(KERN_ERR "ymfpci: unable to map registers\n"); + goto out_release_region; + } + pci_set_master(pcidev); printk(KERN_INFO "ymfpci: %s at 0x%lx IRQ %d\n", - (char *)ent->driver_data, pci_resource_start(pcidev, 0), pcidev->irq); + (char *)ent->driver_data, base, pcidev->irq); ymfpci_aclink_reset(pcidev); if (ymfpci_codec_ready(codec, 0, 1) < 0) @@ -2459,8 +2519,7 @@ /* register /dev/dsp */ if ((codec->dev_audio = register_sound_dsp(&ymf_fops, -1)) < 0) { - printk(KERN_ERR "ymfpci%d: unable to register dsp\n", - codec->dev_audio); + printk(KERN_ERR "ymfpci: unable to register dsp\n"); goto out_free_irq; } @@ -2506,6 +2565,8 @@ ymfpci_writel(codec, YDSXGR_STATUS, ~0); out_unmap: iounmap(codec->reg_area_virt); + out_release_region: + release_mem_region(pci_resource_start(pcidev, 0), 0x8000); out_free: kfree(codec); return -ENODEV; @@ -2529,6 +2590,7 @@ ctrl = ymfpci_readw(codec, YDSXGR_GLOBALCTRL); ymfpci_writew(codec, YDSXGR_GLOBALCTRL, ctrl & ~0x0007); iounmap(codec->reg_area_virt); + release_mem_region(pci_resource_start(pcidev, 0), 0x8000); #ifdef CONFIG_SOUND_YMFPCI_LEGACY if (codec->iomidi) { unload_uart401(&codec->mpu_data); @@ -2545,7 +2607,7 @@ name: "ymfpci", id_table: ymf_id_tbl, probe: ymf_probe_one, - remove: ymf_remove_one, + remove: __devexit_p(ymf_remove_one), suspend: ymf_suspend, resume: ymf_resume }; diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/tc/zs.c linux-2.5/drivers/tc/zs.c --- linux-2.5.1/drivers/tc/zs.c Mon Aug 27 15:56:31 2001 +++ linux-2.5/drivers/tc/zs.c Sun Dec 30 21:17:30 2001 @@ -64,7 +64,6 @@ #include <asm/pgtable.h> #include <asm/irq.h> #include <asm/system.h> -#include <asm/segment.h> #include <asm/bitops.h> #include <asm/uaccess.h> #include <asm/wbflush.h> @@ -1893,7 +1892,9 @@ serial_driver.table = serial_table; serial_driver.termios = serial_termios; serial_driver.termios_locked = serial_termios_locked; - +#ifdef CONFIG_SERIAL_CONSOLE + serial_driver.console = &sercons; +#endif serial_driver.open = rs_open; serial_driver.close = rs_close; serial_driver.write = rs_write; @@ -2125,18 +2126,6 @@ } } -/* - * Receive character from the serial port - */ -static int serial_console_wait_key(struct console *co) -{ - struct dec_serial *info; - - info = zs_soft + co->index; - - return zs_poll_rx_char(info); -} - static kdev_t serial_console_device(struct console *c) { return MKDEV(TTY_MAJOR, 64 + c->index); @@ -2271,7 +2260,6 @@ name: "ttyS", write: serial_console_write, device: serial_console_device, - wait_key: serial_console_wait_key, setup: serial_console_setup, flags: CON_PRINTBUFFER, index: -1, diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/telephony/ixj.c linux-2.5/drivers/telephony/ixj.c --- linux-2.5.1/drivers/telephony/ixj.c Thu Oct 25 20:53:52 2001 +++ linux-2.5/drivers/telephony/ixj.c Sun Dec 30 21:17:30 2001 @@ -268,7 +268,6 @@ #include <linux/pci.h> #include <asm/io.h> -#include <asm/segment.h> #include <asm/uaccess.h> #include <linux/isapnp.h> diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/usb/hpusbscsi.c linux-2.5/drivers/usb/hpusbscsi.c --- linux-2.5.1/drivers/usb/hpusbscsi.c Tue Oct 9 22:15:02 2001 +++ linux-2.5/drivers/usb/hpusbscsi.c Mon Dec 31 01:39:36 2001 @@ -117,7 +117,7 @@ (struct hpusbscsi *) new->ctempl.proc_dir = new; new->ctempl.module = THIS_MODULE; - if (scsi_register_module (MODULE_SCSI_HA, &(new->ctempl))) + if (scsi_register_host(&new->ctempl)) goto err_out; /* adding to list for module unload */ @@ -185,7 +185,7 @@ tmp = tmp->next; o = (struct hpusbscsi *)old; usb_unlink_urb(&o->controlurb); - scsi_unregister_module(MODULE_SCSI_HA,&o->ctempl); + scsi_unregister_host(&o->ctempl); kfree(old); } diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/usb/microtek.c linux-2.5/drivers/usb/microtek.c --- linux-2.5.1/drivers/usb/microtek.c Wed Nov 28 18:22:27 2001 +++ linux-2.5/drivers/usb/microtek.c Mon Dec 31 01:39:36 2001 @@ -367,7 +367,7 @@ } MTS_DEBUG_GOT_HERE(); - scsi_unregister_module(MODULE_SCSI_HA, &(to_remove->ctempl)); + scsi_unregister_host(&to_remove->ctempl); unlock_kernel(); kfree( to_remove ); @@ -982,11 +982,11 @@ MTS_DEBUG("registering SCSI module\n"); new_desc->ctempl.module = THIS_MODULE; - result = scsi_register_module(MODULE_SCSI_HA, &(new_desc->ctempl)); + result = scsi_register_host(&new_desc->ctempl); /* Will get hit back in microtek_detect by this func */ if ( result ) { - MTS_ERROR( "error %d from scsi_register_module! Help!\n", + MTS_ERROR( "error %d from scsi_register_host! Help!\n", (int)result ); /* FIXME: need more cleanup? */ diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/usb/storage/usb.c linux-2.5/drivers/usb/storage/usb.c --- linux-2.5.1/drivers/usb/storage/usb.c Sun Nov 11 18:01:32 2001 +++ linux-2.5/drivers/usb/storage/usb.c Mon Dec 31 01:39:36 2001 @@ -1002,7 +1002,7 @@ /* now register - our detect function will be called */ ss->htmplt.module = THIS_MODULE; - scsi_register_module(MODULE_SCSI_HA, &(ss->htmplt)); + scsi_register_host(&ss->htmplt); /* lock access to the data structures */ down(&us_list_semaphore); @@ -1107,8 +1107,8 @@ * interface */ for (next = us_list; next; next = next->next) { - US_DEBUGP("-- calling scsi_unregister_module()\n"); - scsi_unregister_module(MODULE_SCSI_HA, &(next->htmplt)); + US_DEBUGP("-- calling scsi_unregister_host()\n"); + scsi_unregister_host(&next->htmplt); } /* While there are still structures, free them. Note that we are diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/usb/uhci.c linux-2.5/drivers/usb/uhci.c --- linux-2.5.1/drivers/usb/uhci.c Fri Nov 9 21:41:42 2001 +++ linux-2.5/drivers/usb/uhci.c Mon Dec 31 23:00:28 2001 @@ -2990,7 +2990,7 @@ id_table: uhci_pci_ids, probe: uhci_pci_probe, - remove: uhci_pci_remove, + remove: __devexit_p(uhci_pci_remove), #ifdef CONFIG_PM suspend: uhci_pci_suspend, diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/usb/usb-ohci.c linux-2.5/drivers/usb/usb-ohci.c --- linux-2.5.1/drivers/usb/usb-ohci.c Sun Dec 9 04:28:45 2001 +++ linux-2.5/drivers/usb/usb-ohci.c Mon Dec 31 23:00:28 2001 @@ -2860,7 +2860,7 @@ id_table: &ohci_pci_ids [0], probe: ohci_pci_probe, - remove: ohci_pci_remove, + remove: __devexit_p(ohci_pci_remove), #ifdef CONFIG_PM suspend: ohci_pci_suspend, diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/usb/usb-uhci.c linux-2.5/drivers/usb/usb-uhci.c --- linux-2.5.1/drivers/usb/usb-uhci.c Fri Nov 9 21:41:42 2001 +++ linux-2.5/drivers/usb/usb-uhci.c Mon Dec 31 23:00:28 2001 @@ -2845,7 +2845,7 @@ s->running = 1; } -_static void __devexit +_static void uhci_pci_remove (struct pci_dev *dev) { uhci_t *s = pci_get_drvdata(dev); diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/usb/usbnet.c linux-2.5/drivers/usb/usbnet.c --- linux-2.5.1/drivers/usb/usbnet.c Sun Dec 9 04:25:02 2001 +++ linux-2.5/drivers/usb/usbnet.c Mon Dec 31 01:39:36 2001 @@ -1577,7 +1577,7 @@ struct nc_trailer *trailer = 0; #endif /* CONFIG_USB_NET1080 */ - flags = in_interrupt () ? GFP_ATOMIC : GFP_KERNEL; + flags = in_interrupt () ? GFP_ATOMIC : GFP_NOIO; /* might be used for nfs */ // some devices want funky USB-level framing, for // win32 driver (usually) and/or hardware quirks diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/video/aty/atyfb_base.c linux-2.5/drivers/video/aty/atyfb_base.c --- linux-2.5.1/drivers/video/aty/atyfb_base.c Tue Oct 30 23:08:11 2001 +++ linux-2.5/drivers/video/aty/atyfb_base.c Thu Dec 27 15:14:59 2001 @@ -88,6 +88,9 @@ #include <linux/adb.h> #include <linux/pmu.h> #endif +#ifdef CONFIG_BOOTX_TEXT +#include <asm/btext.h> +#endif #ifdef CONFIG_NVRAM #include <linux/nvram.h> #endif @@ -251,11 +254,11 @@ static int default_mclk __initdata = 0; #ifndef MODULE -static const char *mode_option __initdata = NULL; +static char *mode_option __initdata = NULL; #endif #ifdef CONFIG_PPC -#ifdef CONFIG_NVRAM_NOT_DEFINED +#ifndef CONFIG_NVRAM static int default_vmode __initdata = VMODE_NVRAM; static int default_cmode __initdata = CMODE_NVRAM; #else @@ -271,31 +274,35 @@ static unsigned long phys_guiregbase[FB_MAX] __initdata = { 0, }; #endif -static const char m64n_gx[] __initdata = "mach64GX (ATI888GX00)"; -static const char m64n_cx[] __initdata = "mach64CX (ATI888CX00)"; -static const char m64n_ct[] __initdata = "mach64CT (ATI264CT)"; -static const char m64n_et[] __initdata = "mach64ET (ATI264ET)"; -static const char m64n_vta3[] __initdata = "mach64VTA3 (ATI264VT)"; -static const char m64n_vta4[] __initdata = "mach64VTA4 (ATI264VT)"; -static const char m64n_vtb[] __initdata = "mach64VTB (ATI264VTB)"; -static const char m64n_vt4[] __initdata = "mach64VT4 (ATI264VT4)"; -static const char m64n_gt[] __initdata = "3D RAGE (GT)"; -static const char m64n_gtb[] __initdata = "3D RAGE II+ (GTB)"; -static const char m64n_iic_p[] __initdata = "3D RAGE IIC (PCI)"; -static const char m64n_iic_a[] __initdata = "3D RAGE IIC (AGP)"; -static const char m64n_lt[] __initdata = "3D RAGE LT"; -static const char m64n_ltg[] __initdata = "3D RAGE LT-G"; -static const char m64n_gtc_ba[] __initdata = "3D RAGE PRO (BGA, AGP)"; -static const char m64n_gtc_ba1[] __initdata = "3D RAGE PRO (BGA, AGP, 1x only)"; -static const char m64n_gtc_bp[] __initdata = "3D RAGE PRO (BGA, PCI)"; -static const char m64n_gtc_pp[] __initdata = "3D RAGE PRO (PQFP, PCI)"; -static const char m64n_gtc_ppl[] __initdata = "3D RAGE PRO (PQFP, PCI, limited 3D)"; -static const char m64n_xl[] __initdata = "3D RAGE (XL)"; -static const char m64n_ltp_a[] __initdata = "3D RAGE LT PRO (AGP)"; -static const char m64n_ltp_p[] __initdata = "3D RAGE LT PRO (PCI)"; -static const char m64n_mob_p[] __initdata = "3D RAGE Mobility (PCI)"; -static const char m64n_mob_a[] __initdata = "3D RAGE Mobility (AGP)"; +#ifdef CONFIG_FB_ATY_GX +static char m64n_gx[] __initdata = "mach64GX (ATI888GX00)"; +static char m64n_cx[] __initdata = "mach64CX (ATI888CX00)"; +#endif /* CONFIG_FB_ATY_GX */ +#ifdef CONFIG_FB_ATY_CT +static char m64n_ct[] __initdata = "mach64CT (ATI264CT)"; +static char m64n_et[] __initdata = "mach64ET (ATI264ET)"; +static char m64n_vta3[] __initdata = "mach64VTA3 (ATI264VT)"; +static char m64n_vta4[] __initdata = "mach64VTA4 (ATI264VT)"; +static char m64n_vtb[] __initdata = "mach64VTB (ATI264VTB)"; +static char m64n_vt4[] __initdata = "mach64VT4 (ATI264VT4)"; +static char m64n_gt[] __initdata = "3D RAGE (GT)"; +static char m64n_gtb[] __initdata = "3D RAGE II+ (GTB)"; +static char m64n_iic_p[] __initdata = "3D RAGE IIC (PCI)"; +static char m64n_iic_a[] __initdata = "3D RAGE IIC (AGP)"; +static char m64n_lt[] __initdata = "3D RAGE LT"; +static char m64n_ltg[] __initdata = "3D RAGE LT-G"; +static char m64n_gtc_ba[] __initdata = "3D RAGE PRO (BGA, AGP)"; +static char m64n_gtc_ba1[] __initdata = "3D RAGE PRO (BGA, AGP, 1x only)"; +static char m64n_gtc_bp[] __initdata = "3D RAGE PRO (BGA, PCI)"; +static char m64n_gtc_pp[] __initdata = "3D RAGE PRO (PQFP, PCI)"; +static char m64n_gtc_ppl[] __initdata = "3D RAGE PRO (PQFP, PCI, limited 3D)"; +static char m64n_xl[] __initdata = "3D RAGE (XL)"; +static char m64n_ltp_a[] __initdata = "3D RAGE LT PRO (AGP)"; +static char m64n_ltp_p[] __initdata = "3D RAGE LT PRO (PCI)"; +static char m64n_mob_p[] __initdata = "3D RAGE Mobility (PCI)"; +static char m64n_mob_a[] __initdata = "3D RAGE Mobility (AGP)"; +#endif /* CONFIG_FB_ATY_CT */ static const struct { u16 pci_id, chip_type; @@ -357,24 +364,32 @@ #endif /* CONFIG_FB_ATY_CT */ }; -static const char ram_dram[] __initdata = "DRAM"; -static const char ram_vram[] __initdata = "VRAM"; -static const char ram_edo[] __initdata = "EDO"; -static const char ram_sdram[] __initdata = "SDRAM"; -static const char ram_sgram[] __initdata = "SGRAM"; -static const char ram_wram[] __initdata = "WRAM"; -static const char ram_off[] __initdata = "OFF"; -static const char ram_resv[] __initdata = "RESV"; +#if defined(CONFIG_FB_ATY_GX) || defined(CONFIG_FB_ATY_CT) +static char ram_dram[] __initdata = "DRAM"; +static char ram_resv[] __initdata = "RESV"; +#endif /* CONFIG_FB_ATY_GX || CONFIG_FB_ATY_CT */ #ifdef CONFIG_FB_ATY_GX -static const char *aty_gx_ram[8] __initdata = { +static char ram_vram[] __initdata = "VRAM"; +#endif /* CONFIG_FB_ATY_GX */ + +#ifdef CONFIG_FB_ATY_CT +static char ram_edo[] __initdata = "EDO"; +static char ram_sdram[] __initdata = "SDRAM"; +static char ram_sgram[] __initdata = "SGRAM"; +static char ram_wram[] __initdata = "WRAM"; +static char ram_off[] __initdata = "OFF"; +#endif /* CONFIG_FB_ATY_CT */ + +#ifdef CONFIG_FB_ATY_GX +static char *aty_gx_ram[8] __initdata = { ram_dram, ram_vram, ram_vram, ram_dram, ram_dram, ram_vram, ram_vram, ram_resv }; #endif /* CONFIG_FB_ATY_GX */ #ifdef CONFIG_FB_ATY_CT -static const char *aty_ct_ram[8] __initdata = { +static char *aty_ct_ram[8] __initdata = { ram_off, ram_dram, ram_edo, ram_edo, ram_sdram, ram_sgram, ram_wram, ram_resv }; @@ -819,6 +834,13 @@ display_info.disp_reg_address = info->ati_regbase_phys; } #endif /* CONFIG_FB_COMPAT_XPMAC */ +#ifdef CONFIG_BOOTX_TEXT + btext_update_display(info->frame_buffer_phys, + (((par->crtc.h_tot_disp>>16) & 0xff)+1)*8, + ((par->crtc.v_tot_disp>>16) & 0x7ff)+1, + par->crtc.bpp, + par->crtc.vxres*par->crtc.bpp/8); +#endif /* CONFIG_BOOTX_TEXT */ } static int atyfb_decode_var(const struct fb_var_screeninfo *var, @@ -1638,6 +1660,8 @@ } break; case PBOOK_SLEEP_NOW: + if (currcon >= 0) + fb_display[currcon].dispsw = &fbcon_dummy; if (info->blitter_may_be_busy) wait_for_idle(info); /* Stop accel engine (stop bus mastering) */ @@ -1667,7 +1691,11 @@ info->save_framebuffer = 0; } /* Restore display */ - atyfb_set_par(&info->current_par, info); + if (currcon >= 0) { + atyfb_set_dispsw(&fb_display[currcon], + info, info->current_par.crtc.bpp, + info->current_par.accel_flags & FB_ACCELF_TEXT); + } atyfbcon_blank(0, (struct fb_info *)info); break; } @@ -2020,13 +2048,6 @@ if (!mac_find_mode(&var, &info->fb_info, mode_option, 8)) var = default_var; } else { -#ifdef CONFIG_NVRAM - if (default_vmode == VMODE_NVRAM) { - default_vmode = nvram_read_byte(NV_VMODE); - if (default_vmode <= 0 || default_vmode > VMODE_MAX) - default_vmode = VMODE_CHOOSE; - } -#endif if (default_vmode == VMODE_CHOOSE) { if (M64_HAS(G3_PB_1024x768)) /* G3 PowerBook with 1024x768 LCD */ @@ -2139,11 +2160,16 @@ return -ENXIO; #else u16 tmp; + int aux_app; + unsigned long raddr; #endif while ((pdev = pci_find_device(PCI_VENDOR_ID_ATI, PCI_ANY_ID, pdev))) { if ((pdev->class >> 16) == PCI_BASE_CLASS_DISPLAY) { struct resource *rp; +#ifndef __sparc__ + struct resource *rrp; +#endif for (i = sizeof(aty_chips)/sizeof(*aty_chips)-1; i >= 0; i--) if (pdev->device == aty_chips[i].pci_id) @@ -2375,9 +2401,19 @@ } #else /* __sparc__ */ - info->ati_regbase_phys = 0x7ff000 + addr; - info->ati_regbase = (unsigned long) - ioremap(info->ati_regbase_phys, 0x1000); + aux_app = 0; + raddr = addr + 0x7ff000UL; + rrp = &pdev->resource[2]; + if ((rrp->flags & IORESOURCE_MEM) + && request_mem_region(rrp->start, rrp->end - rrp->start + 1, + "atyfb")) { + aux_app = 1; + raddr = rrp->start; + printk(KERN_INFO "atyfb: using auxiliary register aperture\n"); + } + + info->ati_regbase_phys = raddr; + info->ati_regbase = (unsigned long) ioremap(raddr, 0x1000); if(!info->ati_regbase) { kfree(info); @@ -2385,8 +2421,8 @@ return -ENOMEM; } - info->ati_regbase_phys += 0xc00; - info->ati_regbase += 0xc00; + info->ati_regbase_phys += aux_app? 0x400: 0xc00; + info->ati_regbase += aux_app? 0x400: 0xc00; /* * Enable memory-space accesses using config-space @@ -2891,3 +2927,4 @@ } #endif +MODULE_LICENSE("GPL"); diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/video/controlfb.c linux-2.5/drivers/video/controlfb.c --- linux-2.5.1/drivers/video/controlfb.c Wed Nov 14 22:52:20 2001 +++ linux-2.5/drivers/video/controlfb.c Thu Dec 27 16:32:31 2001 @@ -621,14 +621,10 @@ full = p->total_vram == 0x400000; +#ifdef CONFIG_NVRAM /* Try to pick a video mode out of NVRAM if we have one. */ - if (default_cmode == CMODE_NVRAM){ + if (default_cmode == CMODE_NVRAM) cmode = nvram_read_byte(NV_CMODE); - if(cmode < CMODE_8 || cmode > CMODE_32) - cmode = CMODE_8; - } else - cmode=default_cmode; - if (default_vmode == VMODE_NVRAM) { vmode = nvram_read_byte(NV_VMODE); if (vmode < 1 || vmode > VMODE_MAX || @@ -639,15 +635,16 @@ if (control_mac_modes[vmode - 1].m[full] < cmode) vmode = VMODE_640_480_60; } - } else { - vmode=default_vmode; - if (control_mac_modes[vmode - 1].m[full] < cmode) { - if (cmode > CMODE_8) - cmode--; - else - vmode = VMODE_640_480_60; - } } +#endif + + /* If we didn't get something from NVRAM, pick a + * sane default. + */ + if (vmode <= 0 || vmode > VMODE_MAX) + vmode = VMODE_640_480_67; + if (cmode < CMODE_8 || cmode > CMODE_32) + cmode = CMODE_8; if (mac_vmode_to_var(vmode, cmode, &var) < 0) { /* This shouldn't happen! */ diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/video/cyber2000fb.c linux-2.5/drivers/video/cyber2000fb.c --- linux-2.5.1/drivers/video/cyber2000fb.c Thu Oct 25 20:53:52 2001 +++ linux-2.5/drivers/video/cyber2000fb.c Thu Dec 13 16:32:36 2001 @@ -1683,7 +1683,7 @@ static struct pci_driver cyberpro_driver = { name: "CyberPro", probe: cyberpro_probe, - remove: cyberpro_remove, + remove: __devexit_p(cyberpro_remove), suspend: cyberpro_suspend, resume: cyberpro_resume, id_table: cyberpro_pci_table diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/video/dn_cfb4.c linux-2.5/drivers/video/dn_cfb4.c --- linux-2.5.1/drivers/video/dn_cfb4.c Thu Sep 13 23:04:43 2001 +++ linux-2.5/drivers/video/dn_cfb4.c Sun Dec 30 21:17:30 2001 @@ -7,7 +7,6 @@ #include <linux/delay.h> #include <linux/interrupt.h> #include <asm/setup.h> -#include <asm/segment.h> #include <asm/system.h> #include <asm/irq.h> #include <asm/amigahw.h> diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/video/dn_cfb8.c linux-2.5/drivers/video/dn_cfb8.c --- linux-2.5.1/drivers/video/dn_cfb8.c Mon Oct 15 20:47:13 2001 +++ linux-2.5/drivers/video/dn_cfb8.c Sun Dec 30 21:17:30 2001 @@ -7,7 +7,6 @@ #include <linux/delay.h> #include <linux/interrupt.h> #include <asm/setup.h> -#include <asm/segment.h> #include <asm/system.h> #include <asm/irq.h> #include <asm/amigahw.h> diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/video/dnfb.c linux-2.5/drivers/video/dnfb.c --- linux-2.5.1/drivers/video/dnfb.c Thu Sep 13 23:04:43 2001 +++ linux-2.5/drivers/video/dnfb.c Sun Dec 30 21:17:30 2001 @@ -7,7 +7,6 @@ #include <linux/delay.h> #include <linux/interrupt.h> #include <asm/setup.h> -#include <asm/segment.h> #include <asm/system.h> #include <asm/irq.h> #include <asm/amigahw.h> diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/video/fbcon.c linux-2.5/drivers/video/fbcon.c --- linux-2.5.1/drivers/video/fbcon.c Mon Oct 15 20:47:13 2001 +++ linux-2.5/drivers/video/fbcon.c Thu Dec 27 16:32:31 2001 @@ -75,6 +75,7 @@ #include <linux/selection.h> #include <linux/smp.h> #include <linux/init.h> +#include <linux/pm.h> #include <asm/irq.h> #include <asm/system.h> @@ -137,6 +138,12 @@ static void fbcon_free_font(struct display *); static int fbcon_set_origin(struct vc_data *); +#ifdef CONFIG_PM +static int pm_fbcon_request(struct pm_dev *dev, pm_request_t rqst, void *data); +static struct pm_dev *pm_fbcon; +static int fbcon_sleeping; +#endif + /* * Emmanuel: fbcon will now use a hardware cursor if the * low-level driver provides a non-NULL dispsw->cursor pointer, @@ -233,6 +240,7 @@ static struct timer_list cursor_timer = { function: cursor_timer_handler }; +static int use_timer_cursor; static void cursor_timer_handler(unsigned long dev_addr) { @@ -457,11 +465,16 @@ #endif if (irqres) { + use_timer_cursor = 1; cursor_blink_rate = DEFAULT_CURSOR_BLINK_RATE; cursor_timer.expires = jiffies+HZ/50; add_timer(&cursor_timer); } +#ifdef CONFIG_PM + pm_fbcon = pm_register(PM_SYS_DEV, PM_SYS_VGA, pm_fbcon_request); +#endif + return display_desc; } @@ -1558,6 +1571,10 @@ if (blank < 0) /* Entering graphics mode */ return 0; +#ifdef CONFIG_PM + if (fbcon_sleeping) + return 0; +#endif /* CONFIG_PM */ fbcon_cursor(p->conp, blank ? CM_ERASE : CM_DRAW); @@ -2446,6 +2463,39 @@ return done ? (LOGO_H + fontheight(p) - 1) / fontheight(p) : 0 ; } + +#ifdef CONFIG_PM +/* console.c doesn't do enough here */ +static int +pm_fbcon_request(struct pm_dev *dev, pm_request_t rqst, void *data) +{ + unsigned long flags; + + switch (rqst) + { + case PM_RESUME: + acquire_console_sem(); + fbcon_sleeping = 0; + if (use_timer_cursor) { + cursor_timer.expires = jiffies+HZ/50; + add_timer(&cursor_timer); + } + release_console_sem(); + break; + case PM_SUSPEND: + acquire_console_sem(); + save_flags(flags); + cli(); + if (use_timer_cursor) + del_timer(&cursor_timer); + fbcon_sleeping = 1; + restore_flags(flags); + release_console_sem(); + break; + } + return 0; +} +#endif /* CONFIG_PM */ /* * The console `switch' structure for the frame buffer based console diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/video/fbmem.c linux-2.5/drivers/video/fbmem.c --- linux-2.5.1/drivers/video/fbmem.c Wed Nov 14 23:41:37 2001 +++ linux-2.5/drivers/video/fbmem.c Sun Dec 30 20:52:50 2001 @@ -21,6 +21,7 @@ #include <linux/kernel.h> #include <linux/major.h> #include <linux/slab.h> +#include <linux/mm.h> #include <linux/mman.h> #include <linux/tty.h> #include <linux/console.h> @@ -576,12 +577,13 @@ return -EINVAL; off += start; vma->vm_pgoff = off >> PAGE_SHIFT; + /* This is an IO map - tell maydump to skip this VMA */ + vma->vm_flags |= VM_IO; #if defined(__sparc_v9__) vma->vm_flags |= (VM_SHM | VM_LOCKED); if (io_remap_page_range(vma->vm_start, off, vma->vm_end - vma->vm_start, vma->vm_page_prot, 0)) return -EAGAIN; - vma->vm_flags |= VM_IO; #else #if defined(__mc68000__) #if defined(CONFIG_SUN3) @@ -607,8 +609,6 @@ pgprot_val(vma->vm_page_prot) |= _CACHE_UNCACHED; #elif defined(__arm__) vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot); - /* This is an IO map - tell maydump to skip this VMA */ - vma->vm_flags |= VM_IO; #elif defined(__sh__) pgprot_val(vma->vm_page_prot) &= ~_PAGE_CACHABLE; #else @@ -931,3 +931,5 @@ #if 1 /* to go away in 2.5.0 */ EXPORT_SYMBOL(GET_FB_IDX); #endif + +MODULE_LICENSE("GPL"); diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/video/imsttfb.c linux-2.5/drivers/video/imsttfb.c --- linux-2.5.1/drivers/video/imsttfb.c Wed Nov 14 22:52:20 2001 +++ linux-2.5/drivers/video/imsttfb.c Thu Dec 27 16:32:31 2001 @@ -371,7 +371,6 @@ TVP = 1 }; -#define USE_NV_MODES 1 #define INIT_BPP 8 #define INIT_XRES 640 #define INIT_YRES 480 @@ -384,7 +383,8 @@ static char curblink __initdata = 1; static char noaccel __initdata = 0; #if defined(CONFIG_PPC) -static signed char init_vmode __initdata = -1, init_cmode __initdata = -1; +static signed char init_vmode __initdata = VMODE_NVRAM; +static signed char init_cmode __initdata = CMODE_NVRAM; #endif static struct imstt_regvals tvp_reg_init_2 = { @@ -1643,7 +1643,7 @@ name: "imsttfb", id_table: imsttfb_pci_tbl, probe: imsttfb_probe, - remove: imsttfb_remove, + remove: __devexit_p(imsttfb_remove), }; static struct fb_ops imsttfb_ops = { @@ -1804,20 +1804,25 @@ } } -#if USE_NV_MODES && defined(CONFIG_PPC) +#ifdef CONFIG_ALL_PPC { int vmode = init_vmode, cmode = init_cmode; - if (vmode == -1) { +#ifdef CONFIG_NVRAM + /* Attempt to read vmode/cmode from NVRAM */ + if (vmode == VMODE_NVRAM) vmode = nvram_read_byte(NV_VMODE); - if (vmode <= 0 || vmode > VMODE_MAX) - vmode = VMODE_640_480_67; - } - if (cmode == -1) { + if (cmode == CMODE_NVRAM) cmode = nvram_read_byte(NV_CMODE); - if (cmode < CMODE_8 || cmode > CMODE_32) - cmode = CMODE_8; - } +#endif + /* If we didn't get something from NVRAM, pick a + * sane default. + */ + if (vmode <= 0 || vmode > VMODE_MAX) + vmode = VMODE_640_480_67; + if (cmode < CMODE_8 || cmode > CMODE_32) + cmode = CMODE_8; + if (mac_vmode_to_var(vmode, cmode, &p->disp.var)) { p->disp.var.xres = p->disp.var.xres_virtual = INIT_XRES; p->disp.var.yres = p->disp.var.yres_virtual = INIT_YRES; diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/video/matrox/matroxfb_base.c linux-2.5/drivers/video/matrox/matroxfb_base.c --- linux-2.5.1/drivers/video/matrox/matroxfb_base.c Wed Nov 14 22:52:20 2001 +++ linux-2.5/drivers/video/matrox/matroxfb_base.c Thu Dec 13 16:32:36 2001 @@ -108,6 +108,7 @@ #endif static void matroxfb_unregister_device(struct matrox_fb_info* minfo); +int matroxfb_switch(int con, struct fb_info *info); /* --------------------------------------------------------------------- */ diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/video/matrox/matroxfb_g450.c linux-2.5/drivers/video/matrox/matroxfb_g450.c --- linux-2.5.1/drivers/video/matrox/matroxfb_g450.c Fri Nov 9 22:07:41 2001 +++ linux-2.5/drivers/video/matrox/matroxfb_g450.c Thu Dec 13 18:28:08 2001 @@ -103,7 +103,7 @@ m->regs[0x80] = a; m->regs[0x81] = b; m->regs[0x82] = c; - printk(KERN_DEBUG "PLL: %02X %02X %02X\n", a, b, c); + //printk(KERN_DEBUG "PLL: %02X %02X %02X\n", a, b, c); return 0; } diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/video/modedb.c linux-2.5/drivers/video/modedb.c --- linux-2.5.1/drivers/video/modedb.c Wed Nov 28 01:06:50 2001 +++ linux-2.5/drivers/video/modedb.c Thu Dec 13 16:32:36 2001 @@ -41,7 +41,7 @@ #define DEFAULT_MODEDB_INDEX 0 -static const struct fb_videomode modedb[] __initdata = { +static struct fb_videomode modedb[] __initdata = { { /* 640x400 @ 70 Hz, 31.5 kHz hsync */ NULL, 70, 640, 400, 39721, 40, 24, 39, 9, 96, 2, diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/video/offb.c linux-2.5/drivers/video/offb.c --- linux-2.5.1/drivers/video/offb.c Tue Oct 2 16:10:31 2001 +++ linux-2.5/drivers/video/offb.c Thu Dec 27 16:32:31 2001 @@ -52,7 +52,8 @@ cmap_r128, /* ATI Rage128 */ cmap_M3A, /* ATI Rage Mobility M3 Head A */ cmap_M3B, /* ATI Rage Mobility M3 Head B */ - cmap_radeon /* ATI Radeon */ + cmap_radeon, /* ATI Radeon */ + cmap_gxt2000 /* IBM GXT2000 */ }; struct fb_info_offb { @@ -64,6 +65,7 @@ volatile unsigned char *cmap_adr; volatile unsigned char *cmap_data; int cmap_type; + int blanked; union { #ifdef FBCON_HAS_CFB16 u16 cfb16[16]; @@ -210,9 +212,11 @@ static int offb_get_cmap(struct fb_cmap *cmap, int kspc, int con, struct fb_info *info) { - if (con == currcon) /* current console? */ + struct fb_info_offb *info2 = (struct fb_info_offb *)info; + + if (con == currcon && !info2->blanked) /* current console? */ return fb_get_cmap(cmap, kspc, offb_getcolreg, info); - else if (fb_display[con].cmap.len) /* non default colormap? */ + if (fb_display[con].cmap.len) /* non default colormap? */ fb_copy_cmap(&fb_display[con].cmap, cmap, kspc ? 0 : 2); else { @@ -240,7 +244,7 @@ if ((err = fb_alloc_cmap(&fb_display[con].cmap, size, 0))) return err; } - if (con == currcon) /* current console? */ + if (con == currcon && !info2->blanked) /* current console? */ return fb_set_cmap(cmap, kspc, offb_setcolreg, info); else fb_copy_cmap(cmap, &fb_display[con].cmap, kspc ? 0 : 1); @@ -426,7 +430,7 @@ info->cmap_type = cmap_unknown; if (depth == 8) { - /* XXX kludge for ati */ + /* XXX kludge for ati's */ if (dp && !strncmp(name, "ATY,Rage128", 11)) { unsigned long regbase = dp->addrs[2].address; info->cmap_adr = ioremap(regbase, 0x1FFF); @@ -445,10 +449,19 @@ info->cmap_adr = ioremap(regbase, 0x1FFF); info->cmap_type = cmap_radeon; } else if (!strncmp(name, "ATY,", 4)) { + /* Hrm... this is bad... any recent ATI not covered + * by the previous cases will get there, while this + * cose is only good for mach64's. Gotta figure out + * a proper fix... --BenH. + */ unsigned long base = address & 0xff000000UL; info->cmap_adr = ioremap(base + 0x7ff000, 0x1000) + 0xcc0; info->cmap_data = info->cmap_adr + 1; info->cmap_type = cmap_m64; + } else if (dp && device_is_compatible(dp, "pci1014,b7")) { + unsigned long regbase = dp->addrs[0].address; + info->cmap_adr = ioremap(regbase + 0x6000, 0x1000); + info->cmap_type = cmap_gxt2000; } fix->visual = info->cmap_adr ? FB_VISUAL_PSEUDOCOLOR : FB_VISUAL_STATIC_PSEUDOCOLOR; @@ -620,8 +633,10 @@ static int offbcon_switch(int con, struct fb_info *info) { + struct fb_info_offb *info2 = (struct fb_info_offb *)info; + /* Do we have to save the colormap? */ - if (fb_display[currcon].cmap.len) + if (fb_display[currcon].cmap.len && !info2->blanked) fb_get_cmap(&fb_display[currcon].cmap, 1, offb_getcolreg, info); currcon = con; @@ -652,6 +667,15 @@ if (!info2->cmap_adr) return; + if (!info2->blanked) { + if (!blank) + return; + if (fb_display[currcon].cmap.len) + fb_get_cmap(&fb_display[currcon].cmap, 1, offb_getcolreg, info); + } + + info2->blanked = blank; + if (blank) for (i = 0; i < 256; i++) { switch(info2->cmap_type) { @@ -664,26 +688,29 @@ } break; case cmap_M3A: - /* Clear PALETTE_ACCESS_CNTL in DAC_CNTL */ - out_le32((unsigned *)(info2->cmap_adr + 0x58), - in_le32((unsigned *)(info2->cmap_adr + 0x58)) & ~0x20); + /* Clear PALETTE_ACCESS_CNTL in DAC_CNTL */ + out_le32((unsigned *)(info2->cmap_adr + 0x58), + in_le32((unsigned *)(info2->cmap_adr + 0x58)) & ~0x20); case cmap_r128: - /* Set palette index & data */ - out_8(info2->cmap_adr + 0xb0, i); - out_le32((unsigned *)(info2->cmap_adr + 0xb4), 0); - break; + /* Set palette index & data */ + out_8(info2->cmap_adr + 0xb0, i); + out_le32((unsigned *)(info2->cmap_adr + 0xb4), 0); + break; case cmap_M3B: - /* Set PALETTE_ACCESS_CNTL in DAC_CNTL */ - out_le32((unsigned *)(info2->cmap_adr + 0x58), - in_le32((unsigned *)(info2->cmap_adr + 0x58)) | 0x20); - /* Set palette index & data */ - out_8(info2->cmap_adr + 0xb0, i); - out_le32((unsigned *)(info2->cmap_adr + 0xb4), 0); - break; + /* Set PALETTE_ACCESS_CNTL in DAC_CNTL */ + out_le32((unsigned *)(info2->cmap_adr + 0x58), + in_le32((unsigned *)(info2->cmap_adr + 0x58)) | 0x20); + /* Set palette index & data */ + out_8(info2->cmap_adr + 0xb0, i); + out_le32((unsigned *)(info2->cmap_adr + 0xb4), 0); + break; case cmap_radeon: - out_8(info2->cmap_adr + 0xb0, i); - out_le32((unsigned *)(info2->cmap_adr + 0xb4), 0); - break; + out_8(info2->cmap_adr + 0xb0, i); + out_le32((unsigned *)(info2->cmap_adr + 0xb4), 0); + break; + case cmap_gxt2000: + out_le32((unsigned *)info2->cmap_adr + i, 0); + break; } } else @@ -768,6 +795,10 @@ out_8(info2->cmap_adr + 0xb0, regno); out_le32((unsigned *)(info2->cmap_adr + 0xb4), (red << 16 | green << 8 | blue)); + break; + case cmap_gxt2000: + out_le32((unsigned *)info2->cmap_adr + regno, + (red << 16 | green << 8 | blue)); break; } diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/video/platinumfb.c linux-2.5/drivers/video/platinumfb.c --- linux-2.5.1/drivers/video/platinumfb.c Wed Nov 14 22:52:20 2001 +++ linux-2.5/drivers/video/platinumfb.c Thu Dec 27 16:32:31 2001 @@ -126,7 +126,9 @@ */ static void platinum_of_init(struct device_node *dp); -static inline int platinum_vram_reqd(int video_mode, int color_mode); +static inline int platinum_vram_reqd(const struct fb_info_platinum* info, + int video_mode, + int color_mode); static int read_platinum_sense(struct fb_info_platinum *info); static void set_platinum_clock(struct fb_info_platinum *info); static void platinum_set_par(const struct fb_par_platinum *par, struct fb_info_platinum *info); @@ -443,10 +445,12 @@ } } -static inline int platinum_vram_reqd(int video_mode, int color_mode) +static inline int platinum_vram_reqd(const struct fb_info_platinum *info, int video_mode, int color_mode) { - return vmode_attrs[video_mode-1].vres * - (vmode_attrs[video_mode-1].hres * (1<<color_mode) + 0x20) +0x1000; + unsigned int pitch = + (vmode_attrs[video_mode-1].hres * (1<<color_mode) + 0x20); + fixup_pitch(pitch, info, color_mode); + return vmode_attrs[video_mode-1].vres * pitch; } #define STORE_D2(a, d) { \ @@ -487,7 +491,7 @@ volatile struct cmap_regs *cmap_regs = info->cmap_regs; struct platinum_regvals *init; int i; - int vmode, cmode; + int vmode, cmode, pitch; info->current_par = *par; @@ -506,7 +510,9 @@ init->offset[cmode] + 4 - cmode : init->offset[cmode])); out_be32(&platinum_regs->reg[16].r, (unsigned) info->frame_buffer_phys+init->fb_offset+0x10); - out_be32(&platinum_regs->reg[18].r, init->pitch[cmode]); + pitch = init->pitch[cmode]; + fixup_pitch(pitch, info, cmode); + out_be32(&platinum_regs->reg[18].r, pitch); out_be32(&platinum_regs->reg[19].r, (info->total_vram == 0x100000 ? init->mode[cmode+1] : init->mode[cmode])); @@ -535,6 +541,7 @@ display_info.depth = ( (cmode == CMODE_32) ? 32 : ((cmode == CMODE_16) ? 16 : 8)); display_info.pitch = vmode_attrs[vmode-1].hres * (1<<cmode) + 0x20; + fixup_pitch(display_info.pitch, info, cmode); display_info.mode = vmode; strncpy(display_info.name, "platinum", sizeof(display_info.name)); @@ -558,25 +565,27 @@ sense = read_platinum_sense(info); printk(KERN_INFO "Monitor sense value = 0x%x, ", sense); +#ifdef CONFIG_NVRAM if (default_vmode == VMODE_NVRAM) { default_vmode = nvram_read_byte(NV_VMODE); if (default_vmode <= 0 || default_vmode > VMODE_MAX || !platinum_reg_init[default_vmode-1]) default_vmode = VMODE_CHOOSE; } - if (default_vmode == VMODE_CHOOSE) { + if (default_cmode == CMODE_NVRAM) + default_cmode = nvram_read_byte(NV_CMODE); +#endif + if (default_vmode == VMODE_CHOOSE) default_vmode = mac_map_monitor_sense(sense); - } if (default_vmode <= 0 || default_vmode > VMODE_MAX) default_vmode = VMODE_640_480_60; - if (default_cmode == CMODE_NVRAM) - default_cmode = nvram_read_byte(NV_CMODE); if (default_cmode < CMODE_8 || default_cmode > CMODE_32) default_cmode = CMODE_8; /* * Reduce the pixel size if we don't have enough VRAM. */ - while(default_cmode > CMODE_8 && platinum_vram_reqd(default_vmode, default_cmode) > info->total_vram) + while(default_cmode > CMODE_8 && platinum_vram_reqd(info, default_vmode, default_cmode) + > info->total_vram) default_cmode--; printk("using video mode %d and color mode %d.\n", default_vmode, default_cmode); @@ -782,7 +791,7 @@ return -EINVAL; } - if (platinum_vram_reqd(par->vmode, par->cmode) > info->total_vram) { + if (platinum_vram_reqd(info, par->vmode, par->cmode) > info->total_vram) { printk(KERN_ERR "platinum_var_to_par, not enough ram for vmode %d, cmode %d.\n", par->vmode, par->cmode); return -EINVAL; } @@ -826,7 +835,8 @@ fix->visual = (par->cmode == CMODE_8) ? FB_VISUAL_PSEUDOCOLOR : FB_VISUAL_DIRECTCOLOR; fix->line_length = vmode_attrs[par->vmode-1].hres * (1<<par->cmode) + 0x20; - + fixup_pitch(fix->line_length, info, par->cmode); + return 0; } diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/video/platinumfb.h linux-2.5/drivers/video/platinumfb.h --- linux-2.5.1/drivers/video/platinumfb.h Tue Jan 25 22:13:46 2000 +++ linux-2.5/drivers/video/platinumfb.h Thu Dec 27 16:32:31 2001 @@ -158,7 +158,7 @@ /* 832x624, 75Hz (13) */ static struct platinum_regvals platinum_reg_init_13 = { 0x70, - { 864, 1680, 3360 }, /* MacOS does 1680 instead of 1696 to fit 16bpp in 1MB */ + { 864, 1696, 3360 }, { 0xff0, 4, 0, 0, 0, 0, 0x299, 0, 0, 0x21e, 0x120, 0x10, 0x23f, 0x1f, 0x25, 0x37, 0x8a, 0x22a, 0x23e, 0x536, 0x534, 4, 9, 0x52, @@ -310,6 +310,13 @@ { 2, 0, 0xff }, { 0x11, 0x15, 0x19 }, {{ 94, 5 + DIV16 }, { 48, 7 + DIV8 }} }; + +/* MacOS does 1680 instead of 1696 to fit 832x624@75-16bpp in 1MB */ +#define fixup_pitch(ll, info, cmode) \ + do { \ + if ((cmode) == CMODE_16 && (ll) == 1696 && info->total_vram == 0x100000) \ + (ll) = 1680; \ + } while(0) static struct platinum_regvals *platinum_reg_init[VMODE_MAX] = { &platinum_reg_init_1, diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/video/q40fb.c linux-2.5/drivers/video/q40fb.c --- linux-2.5.1/drivers/video/q40fb.c Thu Sep 13 23:04:43 2001 +++ linux-2.5/drivers/video/q40fb.c Sun Dec 30 21:17:30 2001 @@ -9,7 +9,6 @@ #include <asm/uaccess.h> #include <asm/setup.h> -#include <asm/segment.h> #include <asm/system.h> /*#include <asm/irq.h>*/ #include <asm/q40_master.h> diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/video/radeonfb.c linux-2.5/drivers/video/radeonfb.c --- linux-2.5.1/drivers/video/radeonfb.c Wed Nov 14 22:52:20 2001 +++ linux-2.5/drivers/video/radeonfb.c Thu Dec 27 16:32:31 2001 @@ -15,13 +15,16 @@ * blanking, pan_display, and cmap fixes, 0.1.0 * 2001-10-10 Radeon 7500 and 8500 support, and experimental * flat panel support, 0.1.1 + * 2001-11-17 Radeon M6 (ppc) support, Daniel Berlin, 0.1.2 + * 2001-11-18 DFP fixes, Kevin Hendricks, 0.1.3 + * 2001-11-29 more cmap, backlight fixes, Benjamin Herrenschmidt * * Special thanks to ATI DevRel team for their hardware donations. * */ -#define RADEON_VERSION "0.1.1" +#define RADEON_VERSION "0.1.3" #include <linux/config.h> @@ -39,12 +42,33 @@ #include <linux/ioport.h> #include <linux/init.h> #include <linux/pci.h> +#include <linux/vmalloc.h> #include <asm/io.h> #if defined(__powerpc__) #include <asm/prom.h> +#include <asm/pci-bridge.h> +#include <video/macmodes.h> + +#ifdef CONFIG_NVRAM +#include <linux/nvram.h> +#endif + +#ifdef CONFIG_PMAC_BACKLIGHT +#include <asm/backlight.h> +#endif + +#ifdef CONFIG_BOOTX_TEXT +#include <asm/btext.h> +#endif + +#ifdef CONFIG_ADB_PMU +#include <linux/adb.h> +#include <linux/pmu.h> #endif +#endif /* __powerpc__ */ + #include <video/fbcon.h> #include <video/fbcon-cfb8.h> #include <video/fbcon-cfb16.h> @@ -65,17 +89,17 @@ enum radeon_chips { - RADEON_QD, - RADEON_QE, - RADEON_QF, - RADEON_QG, - RADEON_QY, - RADEON_QZ, - RADEON_QL, - RADEON_QW, - RADEON_LW, - RADEON_LY, - RADEON_LZ + RADEON_QD, /* Radeon R100 */ + RADEON_QE, /* Radeon R100 */ + RADEON_QF, /* Radeon R100 */ + RADEON_QG, /* Radeon R100 */ + RADEON_QY, /* Radeon RV100 (VE) */ + RADEON_QZ, /* Radeon RV100 (VE) */ + RADEON_QL, /* Radeon R200 (8500) */ + RADEON_QW, /* Radeon RV200 (7500) */ + RADEON_LW, /* Radeon Mobility M7 */ + RADEON_LY, /* Radeon Mobility M6 */ + RADEON_LZ /* Radeon Mobility M6 */ }; @@ -192,7 +216,6 @@ u32 flags; u32 pix_clock; int xres, yres; - int bpp; /* DDA regs */ u32 dda_config; @@ -214,6 +237,7 @@ u32 lvds_gen_cntl; u32 lvds_pll_cntl; u32 tmds_crc; + u32 tmds_transmitter_cntl; #if defined(__BIG_ENDIAN) u32 surface_cntl; @@ -238,6 +262,8 @@ struct pci_dev *pdev; + unsigned char *EDID; + struct display disp; int currcon; struct display *currcon_display; @@ -250,13 +276,18 @@ int pitch, bpp, depth; int xres, yres, pixclock; + int use_default_var; + int hasCRTC2; int crtDisp_type; int dviDisp_type; int panel_xres, panel_yres; + int clock; int hOver_plus, hSync_width, hblank; int vOver_plus, vSync_width, vblank; + int hAct_high, vAct_high, interlaced; + int synct, misc; u32 dp_gui_master_cntl; @@ -281,6 +312,13 @@ #endif } con_cmap; #endif + +#ifdef CONFIG_PMAC_PBOOK + unsigned char *save_framebuffer; + int pm_reg; +#endif + + struct radeonfb_info *next; }; @@ -433,6 +471,14 @@ } +static inline int var_to_depth(const struct fb_var_screeninfo *var) +{ + if (var->bits_per_pixel != 16) + return var->bits_per_pixel; + return (var->green.length == 6) ? 16 : 15; +} + + static void _radeon_engine_reset(struct radeonfb_info *rinfo) { u32 clock_cntl_index, mclk_cntl, rbbm_soft_reset; @@ -546,7 +592,9 @@ static char fontname[40] __initdata; static char *mode_option __initdata; static char noaccel __initdata = 0; -static char panel_yres __initdata = 0; +static int panel_yres __initdata = 0; +static char force_dfp __initdata = 0; +static struct radeonfb_info *board_list = NULL; #ifdef FBCON_HAS_CFB8 static struct display_switch fbcon_radeon8; @@ -598,11 +646,30 @@ static void radeon_get_pllinfo(struct radeonfb_info *rinfo, char *bios_seg); static void radeon_get_moninfo (struct radeonfb_info *rinfo); static int radeon_get_dfpinfo (struct radeonfb_info *rinfo); -static int radeon_read_OF (struct radeonfb_info *rinfo); +static void radeon_get_EDID(struct radeonfb_info *rinfo); +static int radeon_dfp_parse_EDID(struct radeonfb_info *rinfo); +static void radeon_update_default_var(struct radeonfb_info *rinfo); -#if defined(__powerpc__) + +#ifdef CONFIG_ALL_PPC +static int radeon_read_OF (struct radeonfb_info *rinfo); +static int radeon_get_EDID_OF(struct radeonfb_info *rinfo); extern struct device_node *pci_device_to_OF_node(struct pci_dev *dev); -#endif + +#ifdef CONFIG_PMAC_PBOOK +int radeon_sleep_notify(struct pmu_sleep_notifier *self, int when); +static struct pmu_sleep_notifier radeon_sleep_notifier = { + radeon_sleep_notify, SLEEP_LEVEL_VIDEO, +}; +static int radeon_set_backlight_enable(int on, int level, void *data); +static int radeon_set_backlight_level(int level, void *data); +static struct backlight_controller radeon_backlight_controller = { + radeon_set_backlight_enable, + radeon_set_backlight_level +}; +#endif /* CONFIG_PMAC_PBOOK */ + +#endif /* CONFIG_ALL_PPC */ static struct fb_ops radeon_fb_ops = { fb_get_fix: radeonfb_get_fix, @@ -656,6 +723,8 @@ memcpy(fontname, this_opt + 5, i); } else if (!strncmp(this_opt, "noaccel", 7)) { noaccel = 1; + } else if (!strncmp(this_opt, "dfp", 3)) { + force_dfp = 1; } else if (!strncmp(this_opt, "panel_yres:", 11)) { panel_yres = simple_strtoul((this_opt+11), NULL, 0); } else @@ -845,7 +914,23 @@ RTRACE("radeonfb: probed %s %dk videoram\n", (rinfo->ram_type), (rinfo->video_ram/1024)); +#if !defined(__powerpc__) radeon_get_moninfo(rinfo); +#else + switch (pdev->device) { + case PCI_DEVICE_ID_RADEON_LW: + case PCI_DEVICE_ID_RADEON_LY: + case PCI_DEVICE_ID_RADEON_LZ: + rinfo->dviDisp_type = MT_LCD; + break; + default: + radeon_get_moninfo(rinfo); + break; + } +#endif + + radeon_get_EDID(rinfo); + if ((rinfo->dviDisp_type == MT_DFP) || (rinfo->dviDisp_type == MT_LCD) || (rinfo->crtDisp_type == MT_DFP)) { if (!radeon_get_dfpinfo(rinfo)) { @@ -875,6 +960,9 @@ /* XXX turn off accel for now, blts aren't working right */ noaccel = 1; + /* currcon not yet configured, will be set by first switch */ + rinfo->currcon = -1; + /* set all the vital stuff */ radeon_set_fbinfo (rinfo); @@ -892,6 +980,8 @@ } pci_set_drvdata(pdev, rinfo); + rinfo->next = board_list; + board_list = rinfo; if (register_framebuffer ((struct fb_info *) rinfo) < 0) { printk ("radeonfb: could not register framebuffer\n"); @@ -910,6 +1000,19 @@ radeon_engine_init (rinfo); } +#ifdef CONFIG_PMAC_BACKLIGHT + if (rinfo->dviDisp_type == MT_LCD) + register_backlight_controller(&radeon_backlight_controller, + rinfo, "ati"); +#endif + +#ifdef CONFIG_PMAC_PBOOK + if (rinfo->dviDisp_type == MT_LCD) { + rinfo->pm_reg = pci_find_capability(pdev, PCI_CAP_ID_PM); + pmu_register_sleep_notifier(&radeon_sleep_notifier); + } +#endif + printk ("radeonfb: ATI %s %s %d MB\n", rinfo->name, rinfo->ram_type, (rinfo->video_ram/(1024*1024))); @@ -1054,7 +1157,7 @@ printk("radeonfb: ref_clk=%d, ref_div=%d, xclk=%d from BIOS\n", rinfo->pll.ref_clk, rinfo->pll.ref_div, rinfo->pll.xclk); } else { -#if defined(__powerpc__) +#ifdef CONFIG_ALL_PPC if (radeon_read_OF(rinfo)) { unsigned int tmp, Nx, M, ref_div, xclk; @@ -1116,6 +1219,11 @@ { unsigned int tmp; + if (force_dfp) { + rinfo->dviDisp_type = MT_DFP; + return; + } + tmp = INREG(RADEON_BIOS_4_SCRATCH); if (rinfo->hasCRTC2) { @@ -1155,11 +1263,116 @@ } + +static void radeon_get_EDID(struct radeonfb_info *rinfo) +{ +#ifdef CONFIG_ALL_PPC + if (!radeon_get_EDID_OF(rinfo)) + RTRACE("radeonfb: could not retrieve EDID from OF\n"); +#else + /* XXX use other methods later */ +#endif +} + + +#ifdef CONFIG_ALL_PPC +static int radeon_get_EDID_OF(struct radeonfb_info *rinfo) +{ + struct device_node *dp; + unsigned char *pedid = NULL; + + dp = pci_device_to_OF_node(rinfo->pdev); + pedid = (unsigned char *) get_property(dp, "DFP,EDID", 0); + if (!pedid) + pedid = (unsigned char *) get_property(dp, "LCD,EDID", 0); + if (!pedid) + pedid = (unsigned char *) get_property(dp, "EDID", 0); + + if (pedid) { + rinfo->EDID = pedid; + return 1; + } else + return 0; +} +#endif /* CONFIG_ALL_PPC */ + + +static int radeon_dfp_parse_EDID(struct radeonfb_info *rinfo) +{ + unsigned char *block = rinfo->EDID; + + if (!block) + return 0; + + /* jump to the detailed timing block section */ + block += 54; + + rinfo->clock = (block[0] + (block[1] << 8)); + rinfo->panel_xres = (block[2] + ((block[4] & 0xf0) << 4)); + rinfo->hblank = (block[3] + ((block[4] & 0x0f) << 8)); + rinfo->panel_yres = (block[5] + ((block[7] & 0xf0) << 4)); + rinfo->vblank = (block[6] + ((block[7] & 0x0f) << 8)); + rinfo->hOver_plus = (block[8] + ((block[11] & 0xc0) << 2)); + rinfo->hSync_width = (block[9] + ((block[11] & 0x30) << 4)); + rinfo->vOver_plus = ((block[10] >> 4) + ((block[11] & 0x0c) << 2)); + rinfo->vSync_width = ((block[10] & 0x0f) + ((block[11] & 0x03) << 4)); + rinfo->interlaced = ((block[17] & 0x80) >> 7); + rinfo->synct = ((block[17] & 0x18) >> 3); + rinfo->misc = ((block[17] & 0x06) >> 1); + rinfo->hAct_high = rinfo->vAct_high = 0; + if (rinfo->synct == 3) { + if (rinfo->misc & 2) + rinfo->hAct_high = 1; + if (rinfo->misc & 1) + rinfo->vAct_high = 1; + } + + return 1; +} + + +static void radeon_update_default_var(struct radeonfb_info *rinfo) +{ + struct fb_var_screeninfo *var = &radeonfb_default_var; + + var->xres = rinfo->panel_xres; + var->yres = rinfo->panel_yres; + var->xres_virtual = rinfo->panel_xres; + var->yres_virtual = rinfo->panel_yres; + var->xoffset = var->yoffset = 0; + var->bits_per_pixel = 8; + var->pixclock = 100000000 / rinfo->clock; + var->left_margin = (rinfo->hblank - rinfo->hOver_plus - rinfo->hSync_width); + var->right_margin = rinfo->hOver_plus; + var->upper_margin = (rinfo->vblank - rinfo->vOver_plus - rinfo->vSync_width); + var->lower_margin = rinfo->vOver_plus; + var->hsync_len = rinfo->hSync_width; + var->vsync_len = rinfo->vSync_width; + var->sync = 0; + if (rinfo->synct == 3) { + if (rinfo->hAct_high) + var->sync |= FB_SYNC_HOR_HIGH_ACT; + if (rinfo->vAct_high) + var->sync |= FB_SYNC_VERT_HIGH_ACT; + } + + var->vmode = 0; + if (rinfo->interlaced) + var->vmode |= FB_VMODE_INTERLACED; + + rinfo->use_default_var = 1; +} + + + static int radeon_get_dfpinfo (struct radeonfb_info *rinfo) { unsigned int tmp; unsigned short a, b; + if (radeon_dfp_parse_EDID(rinfo)) + radeon_update_default_var(rinfo); + if (panel_yres) { rinfo->panel_yres = panel_yres; } else { @@ -1175,7 +1388,12 @@ case 600: rinfo->panel_xres = 800; break; - case 786: + case 768: +#if defined(__powerpc__) + if (rinfo->dviDisp_type == MT_LCD) + rinfo->panel_xres = 1152; + else +#endif rinfo->panel_xres = 1024; break; case 1024: @@ -1222,7 +1440,7 @@ } -#if defined(__powerpc__) +#ifdef CONFIG_ALL_PPC static int radeon_read_OF (struct radeonfb_info *rinfo) { struct device_node *dp; @@ -1255,7 +1473,7 @@ OUTREG(DSTCACHE_MODE, 0); /* XXX */ - rinfo->pitch = ((rinfo->xres * (rinfo->depth / 8) + 0x3f)) >> 6; + rinfo->pitch = ((rinfo->xres * (rinfo->bpp / 8) + 0x3f)) >> 6; radeon_fifo_wait (1); temp = INREG(DEFAULT_PITCH_OFFSET); @@ -1333,6 +1551,16 @@ disp = &rinfo->disp; disp->var = radeonfb_default_var; +#if defined(__powerpc__) + if (rinfo->dviDisp_type == MT_LCD) { + if (mac_vmode_to_var(VMODE_1152_768_60, CMODE_8, &disp->var)) + disp->var = radeonfb_default_var; + } +#endif + + rinfo->depth = var_to_depth(&disp->var); + rinfo->bpp = disp->var.bits_per_pixel; + info->disp = disp; radeon_set_dispsw (rinfo, disp); @@ -1360,6 +1588,18 @@ NULL, 0, NULL, 8); else #endif +#if defined(__powerpc__) + if (rinfo->dviDisp_type == MT_LCD) { + if (mac_vmode_to_var(VMODE_1152_768_60, CMODE_8, &rinfo->disp.var)) + rinfo->disp.var = radeonfb_default_var; + } + else +#endif + if (rinfo->use_default_var) + /* We will use the modified default far */ + rinfo->disp.var = radeonfb_default_var; + else + fb_find_mode (&rinfo->disp.var, &rinfo->info, "640x480-8@60", NULL, 0, NULL, 0); @@ -1390,7 +1630,6 @@ disp->can_soft_blank = 1; disp->inverse = 0; - rinfo->depth = disp->var.bits_per_pixel; switch (disp->var.bits_per_pixel) { #ifdef FBCON_HAS_CFB8 case 8: @@ -1443,7 +1682,7 @@ if (fb_display[con].cmap.len) fb_set_cmap(&fb_display[con].cmap, 1, radeon_setcolreg, info); else { - int size = fb_display[con].var.bits_per_pixel == 8 ? 256 : 32; + int size = radeon_get_cmap_len(&fb_display[con].var); fb_set_cmap(fb_default_cmap(size), 1, radeon_setcolreg, info); } } @@ -1535,7 +1774,7 @@ fix->type_aux = disp->type_aux; fix->visual = disp->visual; - fix->xpanstep = 1; + fix->xpanstep = 8; fix->ypanstep = 1; fix->ywrapstep = 0; @@ -1592,6 +1831,23 @@ memcpy (&v, var, sizeof (v)); switch (v.bits_per_pixel) { + case 0 ... 8: + v.bits_per_pixel = 8; + break; + case 9 ... 16: + v.bits_per_pixel = 16; + break; + case 17 ... 24: + v.bits_per_pixel = 24; + break; + case 25 ... 32: + v.bits_per_pixel = 32; + break; + default: + return -EINVAL; + } + + switch (var_to_depth(&v)) { #ifdef FBCON_HAS_CFB8 case 8: nom = den = 1; @@ -1604,6 +1860,17 @@ #endif #ifdef FBCON_HAS_CFB16 + case 15: + nom = 2; + den = 1; + disp->line_length = v.xres_virtual * 2; + disp->visual = FB_VISUAL_DIRECTCOLOR; + v.red.offset = 10; + v.green.offset = 5; + v.red.offset = 0; + v.red.length = v.green.length = v.blue.length = 5; + v.transp.offset = v.transp.length = 0; + break; case 16: nom = 2; den = 1; @@ -1785,7 +2052,7 @@ struct radeonfb_info *rinfo = (struct radeonfb_info *) info; struct display *disp; struct fb_cmap *cmap; - int switchcon = 0; + int switchmode = 0; disp = (con < 0) ? rinfo->info.disp : &fb_display[con]; @@ -1795,17 +2062,13 @@ fb_get_cmap (cmap, 1, radeon_getcolreg, info); } - if ((disp->var.xres != rinfo->xres) || - (disp->var.yres != rinfo->yres) || - (disp->var.pixclock != rinfo->pixclock) || - (disp->var.bits_per_pixel != rinfo->depth)) - switchcon = 1; - - if (switchcon) { - rinfo->currcon = con; - rinfo->currcon_display = disp; - disp->var.activate = FB_ACTIVATE_NOW; + switchmode = (con != rinfo->currcon); + + rinfo->currcon = con; + rinfo->currcon_display = disp; + disp->var.activate = FB_ACTIVATE_NOW; + if (switchmode) { radeonfb_set_var (&disp->var, con, info); radeon_set_dispsw (rinfo, disp); do_install_cmap(con, info); @@ -1837,11 +2100,20 @@ { struct radeonfb_info *rinfo = (struct radeonfb_info *) info; u32 val = INREG(CRTC_EXT_CNTL); + u32 val2 = INREG(LVDS_GEN_CNTL); + +#ifdef CONFIG_PMAC_BACKLIGHT + if (rinfo->dviDisp_type == MT_LCD && _machine == _MACH_Pmac) { + set_backlight_enable(!blank); + return; + } +#endif /* reset it */ val &= ~(CRTC_DISPLAY_DIS | CRTC_HSYNC_DIS | CRTC_VSYNC_DIS); - + val2 &= ~(LVDS_DISPLAY_DIS); + switch (blank) { case VESA_NO_BLANKING: break; @@ -1854,25 +2126,33 @@ case VESA_POWERDOWN: val |= (CRTC_DISPLAY_DIS | CRTC_VSYNC_DIS | CRTC_HSYNC_DIS); + val2 |= (LVDS_DISPLAY_DIS); break; } - - OUTREG(CRTC_EXT_CNTL, val); -} + switch (rinfo->dviDisp_type) { + case MT_LCD: + OUTREG(LVDS_GEN_CNTL, val2); + break; + case MT_CRT: + default: + OUTREG(CRTC_EXT_CNTL, val); + break; + } +} static int radeon_get_cmap_len (const struct fb_var_screeninfo *var) { - int rc = 16; /* reasonable default */ + int rc = 256; /* reasonable default */ - switch (var->bits_per_pixel) { - case 8: - rc = 256; - break; - default: + switch (var_to_depth(var)) { + case 15: rc = 32; break; + case 16: + rc = 64; + break; } return rc; @@ -1915,40 +2195,38 @@ rinfo->palette[regno].green = green; rinfo->palette[regno].blue = blue; - /* init gamma for hicolor */ - if ((rinfo->depth > 8) && (regno == 0)) { - int i; - - for (i=0; i<255; i++) { - OUTREG(PALETTE_INDEX, i); - OUTREG(PALETTE_DATA, (i << 16) | (i << 8) | i); - } - } - /* default */ pindex = regno; - /* XXX actually bpp, fixme */ - if (rinfo->depth == 16) - pindex = regno * 8; - - if (rinfo->depth == 16) { - OUTREG(PALETTE_INDEX, pindex/2); - OUTREG(PALETTE_DATA, (rinfo->palette[regno/2].red << 16) | - (green << 8) | (rinfo->palette[regno/2].blue)); - green = rinfo->palette[regno/2].green; - } - - if ((rinfo->depth == 8) || (regno < 32)) { - OUTREG(PALETTE_INDEX, pindex); - OUTREG(PALETTE_DATA, (red << 16) | (green << 8) | blue); - } + if (rinfo->bpp == 16) { + pindex = regno * 8; + if (rinfo->depth == 16 && regno > 63) + return 1; + if (rinfo->depth == 15 && regno > 31) + return 1; -#if defined(FBCON_HAS_CFB16) || defined(FBCON_HAS_CFB32) - if (regno < 32) { + /* For 565, the green component is mixed one order below */ + if (rinfo->depth == 16) { + OUTREG(PALETTE_INDEX, pindex>>1); + OUTREG(PALETTE_DATA, (rinfo->palette[regno>>1].red << 16) | + (green << 8) | (rinfo->palette[regno>>1].blue)); + green = rinfo->palette[regno<<1].green; + } + } + + if (rinfo->depth != 16 || regno < 32) { + OUTREG(PALETTE_INDEX, pindex); + OUTREG(PALETTE_DATA, (red << 16) | (green << 8) | blue); + } + + if (regno < 16) { switch (rinfo->depth) { #ifdef FBCON_HAS_CFB16 + case 15: + rinfo->con_cmap.cfb16[regno] = (regno << 10) | (regno << 5) | + regno; + break; case 16: rinfo->con_cmap.cfb16[regno] = (regno << 11) | (regno << 5) | regno; @@ -1970,7 +2248,6 @@ #endif } } -#endif return 0; } @@ -2003,6 +2280,7 @@ save->lvds_gen_cntl = INREG(LVDS_GEN_CNTL); save->lvds_pll_cntl = INREG(LVDS_PLL_CNTL); save->tmds_crc = INREG(TMDS_CRC); + save->tmds_transmitter_cntl = INREG(TMDS_TRANSMITTER_CNTL); } @@ -2023,6 +2301,7 @@ int min_bits, format = 0; int hsync_start, hsync_fudge, bytpp, hsync_wid, vsync_wid; int primary_mon = PRIMARY_MONITOR(rinfo); + int depth = var_to_depth(mode); rinfo->xres = mode->xres; rinfo->yres = mode->yres; @@ -2042,13 +2321,13 @@ if (rinfo->panel_yres < mode->yres) rinfo->yres = mode->yres = rinfo->panel_yres; - hTotal = mode->xres + rinfo->hblank + mode->left_margin; - hSyncStart = mode->xres + rinfo->hOver_plus + mode->right_margin; - hSyncEnd = hSyncStart + rinfo->hOver_plus + mode->hsync_len; - - vTotal = mode->yres + rinfo->vblank + mode->upper_margin; - vSyncStart = mode->yres + rinfo->vOver_plus + mode->lower_margin; - vSyncEnd = vSyncStart + rinfo->vSync_width + mode->vsync_len; + hTotal = mode->xres + rinfo->hblank; + hSyncStart = mode->xres + rinfo->hOver_plus; + hSyncEnd = hSyncStart + rinfo->hSync_width; + + vTotal = mode->yres + rinfo->vblank; + vSyncStart = mode->yres + rinfo->vOver_plus; + vSyncEnd = vSyncStart + rinfo->vSync_width; } sync = mode->sync; @@ -2066,7 +2345,7 @@ hsync_wid = 1; else if (hsync_wid > 0x3f) /* max */ hsync_wid = 0x3f; - vsync_wid = mode->vsync_len; + if (vsync_wid == 0) vsync_wid = 1; else if (vsync_wid > 0x1f) /* max */ @@ -2077,24 +2356,8 @@ cSync = mode->sync & FB_SYNC_COMP_HIGH_ACT ? (1 << 4) : 0; - switch (mode->bits_per_pixel) { - case 8: - format = DST_8BPP; - bytpp = 1; - break; - case 16: - format = DST_16BPP; - bytpp = 2; - break; - case 24: - format = DST_24BPP; - bytpp = 3; - break; - case 32: - format = DST_32BPP; - bytpp = 4; - break; - } + format = radeon_get_dstbpp(depth); + bytpp = mode->bits_per_pixel >> 3; if ((primary_mon == MT_DFP) || (primary_mon == MT_LCD)) hsync_fudge = hsync_fudge_fp[format-1]; @@ -2118,7 +2381,7 @@ newmode.dac_cntl = /* INREG(DAC_CNTL) | */ DAC_MASK_ALL | DAC_VGA_ADR_EN | DAC_8BIT_EN; - newmode.crtc_h_total_disp = ((((hTotal / 8) - 1) & 0xffff) | + newmode.crtc_h_total_disp = ((((hTotal / 8) - 1) & 0x3ff) | (((mode->xres / 8) - 1) << 16)); newmode.crtc_h_sync_strt_wid = ((hsync_start & 0x1fff) | @@ -2158,6 +2421,7 @@ newmode.yres = mode->yres; rinfo->bpp = mode->bits_per_pixel; + rinfo->depth = depth; rinfo->hack_crtc_ext_cntl = newmode.crtc_ext_cntl; rinfo->hack_crtc_v_sync_strt_wid = newmode.crtc_v_sync_strt_wid; @@ -2234,50 +2498,38 @@ newmode.dda_on_off = (ron << 16) | roff; if ((primary_mon == MT_DFP) || (primary_mon == MT_LCD)) { - int hRatio, vRatio; - - if ((rinfo->panel_xres == 0) || (rinfo->panel_yres == 0)) { - hRatio = vRatio = 1; - } else { - if (mode->xres > rinfo->panel_xres) - mode->xres = rinfo->panel_xres; - if (mode->yres > rinfo->panel_yres) - mode->yres = rinfo->panel_yres; - - hRatio = mode->xres / rinfo->panel_xres; - vRatio = mode->yres / rinfo->panel_yres; - } + unsigned int hRatio, vRatio; - if (hRatio == 1) { - newmode.fp_horz_stretch = - rinfo->init_state.fp_horz_stretch; - newmode.fp_horz_stretch &= ~(HORZ_STRETCH_BLEND | - HORZ_STRETCH_ENABLE); - } else { - newmode.fp_horz_stretch = - ((((unsigned long)(hRatio * HORZ_STRETCH_RATIO_MAX + - (int)0.5)) & HORZ_STRETCH_RATIO_MASK)) | - (rinfo->init_state.fp_horz_stretch & - (HORZ_PANEL_SIZE | HORZ_FP_LOOP_STRETCH | - HORZ_AUTO_RATIO_INC)); + if (mode->xres > rinfo->panel_xres) + mode->xres = rinfo->panel_xres; + if (mode->yres > rinfo->panel_yres) + mode->yres = rinfo->panel_yres; + + newmode.fp_horz_stretch = (((rinfo->panel_xres / 8) - 1) + << HORZ_PANEL_SHIFT); + newmode.fp_vert_stretch = ((rinfo->panel_yres - 1) + << VERT_PANEL_SHIFT); + + if (mode->xres != rinfo->panel_xres) { + hRatio = round_div(mode->xres * HORZ_STRETCH_RATIO_MAX, + rinfo->panel_xres); + newmode.fp_horz_stretch = (((((unsigned long)hRatio) & HORZ_STRETCH_RATIO_MASK)) | + (newmode.fp_horz_stretch & + (HORZ_PANEL_SIZE | HORZ_FP_LOOP_STRETCH | + HORZ_AUTO_RATIO_INC))); newmode.fp_horz_stretch |= (HORZ_STRETCH_BLEND | HORZ_STRETCH_ENABLE); } newmode.fp_horz_stretch &= ~HORZ_AUTO_RATIO; - if (vRatio == 1) { - newmode.fp_vert_stretch = - rinfo->init_state.fp_vert_stretch; - newmode.fp_vert_stretch &= ~(VERT_STRETCH_BLEND | - VERT_STRETCH_ENABLE); - } else { - newmode.fp_vert_stretch = - ((((unsigned long)(vRatio * VERT_STRETCH_RATIO_MAX + - (int)0.5)) & VERT_STRETCH_RATIO_MASK)) | - (rinfo->init_state.fp_vert_stretch & - (VERT_PANEL_SIZE | VERT_STRETCH_RESERVED)); - newmode.fp_vert_stretch |= (VERT_STRETCH_BLEND | - VERT_STRETCH_ENABLE); + if (mode->yres != rinfo->panel_yres) { + vRatio = round_div(mode->yres * VERT_STRETCH_RATIO_MAX, + rinfo->panel_yres); + newmode.fp_vert_stretch = (((((unsigned long)vRatio) & VERT_STRETCH_RATIO_MASK)) | + (newmode.fp_vert_stretch & + (VERT_PANEL_SIZE | VERT_STRETCH_RESERVED))); + newmode.fp_vert_stretch |= (VERT_STRETCH_BLEND | + VERT_STRETCH_ENABLE); } newmode.fp_vert_stretch &= ~VERT_AUTO_RATIO_EN; @@ -2290,14 +2542,14 @@ FP_USE_SHADOW_EN | FP_CRTC_USE_SHADOW_VEND | FP_CRT_SYNC_ALT)); + newmode.fp_gen_cntl |= (FP_CRTC_DONT_SHADOW_VPAR | FP_CRTC_DONT_SHADOW_HEND); newmode.lvds_gen_cntl = rinfo->init_state.lvds_gen_cntl; newmode.lvds_pll_cntl = rinfo->init_state.lvds_pll_cntl; newmode.tmds_crc = rinfo->init_state.tmds_crc; - - newmode.crtc_ext_cntl &= ~CRTC_CRT_ON; + newmode.tmds_transmitter_cntl = rinfo->init_state.tmds_transmitter_cntl; if (primary_mon == MT_LCD) { newmode.lvds_gen_cntl |= (LVDS_ON | LVDS_BLON); @@ -2305,21 +2557,25 @@ } else { /* DFP */ newmode.fp_gen_cntl |= (FP_FPON | FP_TMDS_EN); + newmode.tmds_transmitter_cntl = (TMDS_RAN_PAT_RST | + ICHCSEL) & ~(TMDS_PLLRST); + newmode.crtc_ext_cntl &= ~CRTC_CRT_ON; } - newmode.fp_crtc_h_total_disp = - rinfo->init_state.fp_crtc_h_total_disp; - newmode.fp_crtc_v_total_disp = - rinfo->init_state.fp_crtc_v_total_disp; - newmode.fp_h_sync_strt_wid = - rinfo->init_state.fp_h_sync_strt_wid; - newmode.fp_v_sync_strt_wid = - rinfo->init_state.fp_v_sync_strt_wid; + newmode.fp_crtc_h_total_disp = newmode.crtc_h_total_disp; + newmode.fp_crtc_v_total_disp = newmode.crtc_v_total_disp; + newmode.fp_h_sync_strt_wid = newmode.crtc_h_sync_strt_wid; + newmode.fp_v_sync_strt_wid = newmode.crtc_v_sync_strt_wid; } /* do it! */ radeon_write_mode (rinfo, &newmode); +#if defined(CONFIG_BOOTX_TEXT) + btext_update_display(rinfo->fb_base_phys, mode->xres, mode->yres, + rinfo->depth, rinfo->pitch*64); +#endif + return; } @@ -2331,7 +2587,8 @@ int primary_mon = PRIMARY_MONITOR(rinfo); /* blank screen */ - OUTREG8(CRTC_EXT_CNTL + 1, 4); + OUTREGP(CRTC_EXT_CNTL, CRTC_DISPLAY_DIS | CRTC_VSYNC_DIS | CRTC_HSYNC_DIS, + ~(CRTC_DISPLAY_DIS | CRTC_VSYNC_DIS | CRTC_HSYNC_DIS)); for (i=0; i<9; i++) OUTREG(common_regs[i].reg, common_regs[i].val); @@ -2347,16 +2604,6 @@ OUTREG(CRTC_OFFSET, 0); OUTREG(CRTC_OFFSET_CNTL, 0); OUTREG(CRTC_PITCH, mode->crtc_pitch); -#if 1 - printk("CRTC_H_TOTAL_DISP = 0x%x, H_SYNC = 0x%x\n", - mode->crtc_h_total_disp, mode->crtc_h_sync_strt_wid); - printk("CRTC_V_TOTAL_DISP = 0x%x, V_SYNC = 0x%x\n", - mode->crtc_v_total_disp, mode->crtc_v_sync_strt_wid); - printk("PPLL_DIV_3 = 0x%x, PPLL_REF_DIV = 0x%x\n", - mode->ppll_div_3, mode->ppll_ref_div); - printk("DDA_CONFIG = 0x%x, DDA_ON_OFF = 0x%x\n", - mode->dda_config, mode->dda_on_off); -#endif #if defined(__BIG_ENDIAN) OUTREG(SURFACE_CNTL, mode->surface_cntl); @@ -2396,27 +2643,31 @@ OUTREG(FP_CRTC_V_TOTAL_DISP, mode->fp_crtc_v_total_disp); OUTREG(FP_H_SYNC_STRT_WID, mode->fp_h_sync_strt_wid); OUTREG(FP_V_SYNC_STRT_WID, mode->fp_v_sync_strt_wid); - OUTREG(TMDS_CRC, mode->tmds_crc); OUTREG(FP_HORZ_STRETCH, mode->fp_horz_stretch); OUTREG(FP_VERT_STRETCH, mode->fp_vert_stretch); OUTREG(FP_GEN_CNTL, mode->fp_gen_cntl); + OUTREG(TMDS_CRC, mode->tmds_crc); + OUTREG(TMDS_TRANSMITTER_CNTL, mode->tmds_transmitter_cntl); if (primary_mon == MT_LCD) { unsigned int tmp = INREG(LVDS_GEN_CNTL); + mode->lvds_gen_cntl &= ~LVDS_STATE_MASK; + mode->lvds_gen_cntl |= (rinfo->init_state.lvds_gen_cntl & LVDS_STATE_MASK); + if ((tmp & (LVDS_ON | LVDS_BLON)) == - (mode->lvds_gen_cntl & (LVDS_ON | LVDS_BLON))) - OUTREG(LVDS_GEN_CNTL, mode->lvds_gen_cntl); - } else { - /* DVI */ - if (mode->lvds_gen_cntl & (LVDS_ON | LVDS_BLON)) { - udelay(1000); + (mode->lvds_gen_cntl & (LVDS_ON | LVDS_BLON))) { OUTREG(LVDS_GEN_CNTL, mode->lvds_gen_cntl); } else { - OUTREG(LVDS_GEN_CNTL, mode->lvds_gen_cntl | - LVDS_BLON); - udelay(1000); - OUTREG(LVDS_GEN_CNTL, mode->lvds_gen_cntl); + if (mode->lvds_gen_cntl & (LVDS_ON | LVDS_BLON)) { + udelay(1000); + OUTREG(LVDS_GEN_CNTL, mode->lvds_gen_cntl); + } else { + OUTREG(LVDS_GEN_CNTL, mode->lvds_gen_cntl | + LVDS_BLON); + udelay(1000); + OUTREG(LVDS_GEN_CNTL, mode->lvds_gen_cntl); + } } } } @@ -2428,6 +2679,204 @@ } +#ifdef CONFIG_PMAC_BACKLIGHT + +static int backlight_conv[] = { + 0xff, 0xc0, 0xb5, 0xaa, 0x9f, 0x94, 0x89, 0x7e, + 0x73, 0x68, 0x5d, 0x52, 0x47, 0x3c, 0x31, 0x24 +}; + +#define BACKLIGHT_LVDS_OFF +#undef BACKLIGHT_DAC_OFF + +/* We turn off the LCD completely instead of just dimming the backlight. + * This provides some greater power saving and the display is useless + * without backlight anyway. + */ + +static int radeon_set_backlight_enable(int on, int level, void *data) +{ + struct radeonfb_info *rinfo = (struct radeonfb_info *)data; + unsigned int lvds_gen_cntl = INREG(LVDS_GEN_CNTL); + + lvds_gen_cntl |= (LVDS_BL_MOD_EN | LVDS_BLON); + if (on && (level > BACKLIGHT_OFF)) { + lvds_gen_cntl |= LVDS_DIGON; + if (!lvds_gen_cntl & LVDS_ON) { + lvds_gen_cntl &= ~LVDS_BLON; + OUTREG(LVDS_GEN_CNTL, lvds_gen_cntl); + (void)INREG(LVDS_GEN_CNTL); + mdelay(10); + lvds_gen_cntl |= LVDS_BLON; + OUTREG(LVDS_GEN_CNTL, lvds_gen_cntl); + } + lvds_gen_cntl &= ~LVDS_BL_MOD_LEVEL_MASK; + lvds_gen_cntl |= (backlight_conv[level] << + LVDS_BL_MOD_LEVEL_SHIFT); + lvds_gen_cntl |= (LVDS_ON | LVDS_EN); + lvds_gen_cntl &= ~LVDS_DISPLAY_DIS; + } else { + lvds_gen_cntl &= ~LVDS_BL_MOD_LEVEL_MASK; + lvds_gen_cntl |= (backlight_conv[0] << + LVDS_BL_MOD_LEVEL_SHIFT); + lvds_gen_cntl |= LVDS_DISPLAY_DIS; + OUTREG(LVDS_GEN_CNTL, lvds_gen_cntl); + udelay(10); + lvds_gen_cntl &= ~(LVDS_ON | LVDS_EN | LVDS_BLON | LVDS_DIGON); + } + + OUTREG(LVDS_GEN_CNTL, lvds_gen_cntl); + rinfo->init_state.lvds_gen_cntl &= ~LVDS_STATE_MASK; + rinfo->init_state.lvds_gen_cntl |= (lvds_gen_cntl & LVDS_STATE_MASK); + + return 0; +} + +static int radeon_set_backlight_level(int level, void *data) +{ + return radeon_set_backlight_enable(1, level, data); +} +#endif /* CONFIG_PMAC_BACKLIGHT */ + + +#ifdef CONFIG_PMAC_PBOOK +static void radeon_set_suspend(struct radeonfb_info *rinfo, int suspend) +{ + u16 pwr_cmd; + + if (!rinfo->pm_reg) + return; + + /* Set the chip into appropriate suspend mode (we use D2, + * D3 would require a compete re-initialization of the chip, + * including PCI config registers, clocks, AGP conf, ...) + */ + if (suspend) { + /* Make sure CRTC2 is reset. Remove that the day + * we decide to actually use CRTC2 and replace it with + * real code for disabling the CRTC2 output during sleep. + */ + + pci_read_config_word(rinfo->pdev, rinfo->pm_reg+PCI_PM_CTRL, + &pwr_cmd); + + /* Switch PCI power managment to D2 */ + pci_write_config_word(rinfo->pdev, rinfo->pm_reg+PCI_PM_CTRL, + (pwr_cmd & ~PCI_PM_CTRL_STATE_MASK) + | 2); + pci_read_config_word(rinfo->pdev, rinfo->pm_reg+PCI_PM_CTRL, + &pwr_cmd); + } else { + /* Switch back PCI powermanagment to D0 */ + mdelay(100); + pci_write_config_word(rinfo->pdev, rinfo->pm_reg+PCI_PM_CTRL, 0); + mdelay(100); + pci_read_config_word(rinfo->pdev, rinfo->pm_reg+PCI_PM_CTRL, + &pwr_cmd); + mdelay(100); + } +} + +/* + * Save the contents of the framebuffer when we go to sleep, + * and restore it when we wake up again. + */ + +int radeon_sleep_notify(struct pmu_sleep_notifier *self, int when) +{ + struct radeonfb_info *rinfo; + + for (rinfo = board_list; rinfo != NULL; rinfo = rinfo->next) { + struct fb_fix_screeninfo fix; + int nb; + + switch (rinfo->chipset) { + case PCI_DEVICE_ID_RADEON_LW: + case PCI_DEVICE_ID_RADEON_LY: + case PCI_DEVICE_ID_RADEON_LZ: + break; + default: + return PBOOK_SLEEP_REFUSE; + } + + radeonfb_get_fix(&fix, fg_console, (struct fb_info *)rinfo); + nb = fb_display[fg_console].var.yres * fix.line_length; + + switch (when) { + case PBOOK_SLEEP_REQUEST: +#if 0 + rinfo->save_framebuffer = vmalloc(nb); + if (rinfo->save_framebuffer == NULL) + return PBOOK_SLEEP_REFUSE; +#endif + break; + case PBOOK_SLEEP_REJECT: +#if 0 + if (rinfo->save_framebuffer) { + vfree(rinfo->save_framebuffer); + rinfo->save_framebuffer = 0; + } +#endif + break; + case PBOOK_SLEEP_NOW: + radeon_engine_idle(); + radeon_engine_reset(); + radeon_engine_idle(); + +#if 0 + /* Backup framebuffer content */ + if (rinfo->save_framebuffer) + memcpy_fromio(rinfo->save_framebuffer, + (void *)rinfo->fb_base, + nb); +#endif + + /* Blank display and LCD */ + radeonfb_blank(VESA_POWERDOWN+1, + (struct fb_info *)rinfo); + + /* Sleep */ + radeon_set_suspend(rinfo, 1); + + break; + case PBOOK_WAKE: + /* Wakeup */ + radeon_set_suspend(rinfo, 0); + + radeon_engine_reset(); + if (!noaccel) { + radeon_engine_init(rinfo); + radeon_engine_reset(); + } + +#if 0 + /* Restore framebuffer content */ + if (rinfo->save_framebuffer) { + memcpy_toio((void *)rinfo->fb_base, + rinfo->save_framebuffer, + nb); + vfree(rinfo->save_framebuffer); + rinfo->save_framebuffer = 0; + } +#endif + + if (rinfo->currcon_display) { + radeonfb_set_var(&rinfo->currcon_display->var, rinfo->currcon, + (struct fb_info *) rinfo); + radeon_set_dispsw(rinfo, rinfo->currcon_display); + do_install_cmap(rinfo->currcon, + (struct fb_info *)rinfo); + } + + radeonfb_blank(0, (struct fb_info *)rinfo); + break; + } + } + + return PBOOK_SLEEP_OK; +} + +#endif /* CONFIG_PMAC_PBOOK */ /* * text console acceleration diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/video/riva/fbdev.c linux-2.5/drivers/video/riva/fbdev.c --- linux-2.5.1/drivers/video/riva/fbdev.c Wed Nov 14 22:52:20 2001 +++ linux-2.5/drivers/video/riva/fbdev.c Thu Dec 13 16:32:36 2001 @@ -2082,7 +2082,7 @@ name: "rivafb", id_table: rivafb_pci_tbl, probe: rivafb_init_one, - remove: rivafb_remove_one, + remove: __devexit_p(rivafb_remove_one), }; diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/video/tdfxfb.c linux-2.5/drivers/video/tdfxfb.c --- linux-2.5.1/drivers/video/tdfxfb.c Wed Nov 14 22:52:20 2001 +++ linux-2.5/drivers/video/tdfxfb.c Sat Dec 29 11:04:53 2001 @@ -401,7 +401,7 @@ /* * Internal routines */ -static void tdfxfb_set_par(const struct tdfxfb_par* par, +static void tdfxfb_set_par(struct tdfxfb_par* par, struct fb_info_tdfx* info); static int tdfxfb_decode_var(const struct fb_var_screeninfo *var, @@ -495,7 +495,7 @@ name: "tdfxfb", id_table: tdfxfb_id_table, probe: tdfxfb_probe, - remove: tdfxfb_remove, + remove: __devexit_p(tdfxfb_remove), }; MODULE_DEVICE_TABLE(pci, tdfxfb_id_table); @@ -1275,7 +1275,7 @@ /* ------------------------------------------------------------------------- */ -static void tdfxfb_set_par(const struct tdfxfb_par* par, +static void tdfxfb_set_par(struct tdfxfb_par* par, struct fb_info_tdfx* info) { struct fb_info_tdfx* i = (struct fb_info_tdfx*)info; struct banshee_reg reg; @@ -1290,6 +1290,28 @@ cpp = (par->bpp + 7)/8; + reg.vidcfg = + VIDCFG_VIDPROC_ENABLE | + VIDCFG_DESK_ENABLE | + VIDCFG_CURS_X11 | + ((cpp - 1) << VIDCFG_PIXFMT_SHIFT) | + (cpp != 1 ? VIDCFG_CLUT_BYPASS : 0); + + /* PLL settings */ + freq = par->pixclock; + + reg.dacmode = 0; + reg.vidcfg &= ~VIDCFG_2X; + + if(freq > i->max_pixclock/2) { + freq = freq > i->max_pixclock ? i->max_pixclock : freq; + reg.dacmode |= DACMODE_2X; + reg.vidcfg |= VIDCFG_2X; + par->hdispend >>= 1; + par->hsyncsta >>= 1; + par->hsyncend >>= 1; + par->htotal >>= 1; + } wd = (par->hdispend >> 3) - 1; hd = (par->hdispend >> 3) - 1; @@ -1356,9 +1378,7 @@ reg.crt[0x02] = hbs; reg.crt[0x03] = 0x80 | (hbe & 0x1f); reg.crt[0x04] = hs; - reg.crt[0x05] = - ((hbe & 0x20) << 2) | - (he & 0x1f); + reg.crt[0x05] = ((hbe & 0x20) << 2) | (he & 0x1f); reg.crt[0x06] = vt; reg.crt[0x07] = ((vs & 0x200) >> 2) | @@ -1380,9 +1400,7 @@ reg.crt[0x0e] = 0x00; reg.crt[0x0f] = 0x00; reg.crt[0x10] = vs; - reg.crt[0x11] = - (ve & 0x0f) | - 0x20; + reg.crt[0x11] = (ve & 0x0f) | 0x20; reg.crt[0x12] = vd; reg.crt[0x13] = wd; reg.crt[0x14] = 0x00; @@ -1411,13 +1429,6 @@ VGAINIT0_EXTSHIFTOUT; reg.vgainit1 = tdfx_inl(VGAINIT1) & 0x1fffff; - reg.vidcfg = - VIDCFG_VIDPROC_ENABLE | - VIDCFG_DESK_ENABLE | - VIDCFG_CURS_X11 | - ((cpp - 1) << VIDCFG_PIXFMT_SHIFT) | - (cpp != 1 ? VIDCFG_CLUT_BYPASS : 0); - fb_info.cursor.enable=reg.vidcfg | VIDCFG_HWCURSOR_ENABLE; fb_info.cursor.disable=reg.vidcfg; @@ -1433,16 +1444,6 @@ reg.srcbase = reg.startaddr; reg.dstbase = reg.startaddr; - /* PLL settings */ - freq = par->pixclock; - - reg.dacmode &= ~DACMODE_2X; - reg.vidcfg &= ~VIDCFG_2X; - if(freq > i->max_pixclock/2) { - freq = freq > i->max_pixclock ? i->max_pixclock : freq; - reg.dacmode |= DACMODE_2X; - reg.vidcfg |= VIDCFG_2X; - } reg.vidpll = do_calc_pll(freq, &fout); #if 0 reg.mempll = do_calc_pll(..., &fout); @@ -1473,9 +1474,13 @@ #endif do_write_regs(®); - + if (reg.vidcfg & VIDCFG_2X) { + par->hdispend <<= 1; + par->hsyncsta <<= 1; + par->hsyncend <<= 1; + par->htotal <<= 1; + } i->current_par = *par; - } static int tdfxfb_decode_var(const struct fb_var_screeninfo* var, diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/video/valkyriefb.c linux-2.5/drivers/video/valkyriefb.c --- linux-2.5.1/drivers/video/valkyriefb.c Wed Nov 14 22:52:20 2001 +++ linux-2.5/drivers/video/valkyriefb.c Thu Dec 27 16:32:31 2001 @@ -7,6 +7,8 @@ * Vmode-switching changes and vmode 15/17 modifications created 29 August * 1998 by Barry K. Nathan <barryn@pobox.com>. * + * Ported to m68k Macintosh by David Huggins-Daines <dhd@debian.org> + * * Derived directly from: * * controlfb.c -- frame buffer device for the PowerMac 'control' display @@ -59,7 +61,12 @@ #include <linux/adb.h> #include <linux/cuda.h> #include <asm/io.h> +#ifdef CONFIG_MAC +#include <asm/bootinfo.h> +#include <asm/macintosh.h> +#else #include <asm/prom.h> +#endif #include <asm/pgtable.h> #include <video/fbcon.h> @@ -71,8 +78,15 @@ static int can_soft_blank = 1; +#ifdef CONFIG_MAC +/* We don't yet have functions to read the PRAM... perhaps we can + adapt them from the PPC code? */ +static int default_vmode = VMODE_640_480_67; +static int default_cmode = CMODE_8; +#else static int default_vmode = VMODE_NVRAM; static int default_cmode = CMODE_NVRAM; +#endif static char fontname[40] __initdata = { 0 }; static int currcon = 0; @@ -117,7 +131,6 @@ int valkyriefb_init(void); int valkyriefb_setup(char*); -static void valkyrie_of_init(struct device_node *dp); static int valkyrie_get_fix(struct fb_fix_screeninfo *fix, int con, struct fb_info *info); static int valkyrie_get_var(struct fb_var_screeninfo *var, int con, @@ -444,6 +457,7 @@ p->sense = read_valkyrie_sense(p); printk(KERN_INFO "Monitor sense value = 0x%x, ", p->sense); +#ifdef CONFIG_NVRAM /* Try to pick a video mode out of NVRAM if we have one. */ if (default_vmode == VMODE_NVRAM) { default_vmode = nvram_read_byte(NV_VMODE); @@ -452,12 +466,13 @@ || !valkyrie_reg_init[default_vmode - 1]) default_vmode = VMODE_CHOOSE; } + if (default_cmode == CMODE_NVRAM) + default_cmode = nvram_read_byte(NV_CMODE); +#endif if (default_vmode == VMODE_CHOOSE) default_vmode = mac_map_monitor_sense(p->sense); if (!valkyrie_reg_init[default_vmode - 1]) default_vmode = VMODE_640_480_67; - if (default_cmode == CMODE_NVRAM) - default_cmode = nvram_read_byte(NV_CMODE); /* * Reduce the pixel size if we don't have enough VRAM or bandwitdh. @@ -550,48 +565,57 @@ int __init valkyriefb_init(void) { + struct fb_info_valkyrie *p; + unsigned long frame_buffer_phys, cmap_regs_phys, flags; + +#ifdef CONFIG_MAC + if (!MACH_IS_MAC) + return 0; + if (!(mac_bi_data.id == MAC_MODEL_Q630 + /* I'm not sure about this one */ + || mac_bi_data.id == MAC_MODEL_P588)) + return 0; + + /* Hardcoded addresses... welcome to 68k Macintosh country :-) */ + frame_buffer_phys = 0xf9000000; + cmap_regs_phys = 0x50f24000; + flags = IOMAP_NOCACHE_SER; /* IOMAP_WRITETHROUGH?? */ +#else /* ppc (!CONFIG_MAC) */ struct device_node *dp; dp = find_devices("valkyrie"); - if (dp != 0) - valkyrie_of_init(dp); - return 0; -} + if (dp == 0) + return 0; -static void __init valkyrie_of_init(struct device_node *dp) -{ - struct fb_info_valkyrie *p; - unsigned long addr; - if(dp->n_addrs != 1) { printk(KERN_ERR "expecting 1 address for valkyrie (got %d)", dp->n_addrs); - return; + return 0; } + frame_buffer_phys = dp->addrs[0].address; + cmap_regs_phys = dp->addrs[0].address+0x304000; + flags = _PAGE_WRITETHRU; +#endif /* ppc (!CONFIG_MAC) */ + p = kmalloc(sizeof(*p), GFP_ATOMIC); if (p == 0) - return; + return 0; memset(p, 0, sizeof(*p)); /* Map in frame buffer and registers */ - addr = dp->addrs[0].address; - if (!request_mem_region(addr, dp->addrs[0].size, "valkyriefb")) { + if (!request_mem_region(frame_buffer_phys, 0x100000, "valkyriefb")) { kfree(p); - return; + return 0; } - p->frame_buffer_phys = addr; - p->frame_buffer = __ioremap(addr, 0x100000, _PAGE_WRITETHRU); - p->cmap_regs_phys = addr + 0x304000; - p->cmap_regs = ioremap(p->cmap_regs_phys,4096); - p->valkyrie_regs_phys = addr + 0x30a000; - p->valkyrie_regs = ioremap(p->valkyrie_regs_phys, 4096); - - /* - * kps: As far as I know, all Valkyries have fixed usable VRAM. - */ p->total_vram = 0x100000; - + p->frame_buffer_phys = frame_buffer_phys; + p->frame_buffer = __ioremap(frame_buffer_phys, p->total_vram, flags); + p->cmap_regs_phys = cmap_regs_phys; + p->cmap_regs = ioremap(p->cmap_regs_phys, 0x1000); + p->valkyrie_regs_phys = cmap_regs_phys+0x6000; + p->valkyrie_regs = ioremap(p->valkyrie_regs_phys, 0x1000); init_valkyrie(p); + return 0; } /* diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/drivers/video/valkyriefb.h linux-2.5/drivers/video/valkyriefb.h --- linux-2.5.1/drivers/video/valkyriefb.h Sat Aug 5 01:06:34 2000 +++ linux-2.5/drivers/video/valkyriefb.h Thu Dec 27 16:32:31 2001 @@ -9,6 +9,8 @@ * * vmode 10 changed by Steven Borley <sjb@salix.demon.co.uk>, 14 mai 2000 * + * Ported to 68k Macintosh by David Huggins-Daines <dhd@debian.org> + * * 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 @@ -37,12 +39,19 @@ * Copyright (C) 1998 Jon Howell */ +#ifdef CONFIG_MAC +/* Valkyrie registers are word-aligned on m68k */ +#define VALKYRIE_REG_PADSIZE 3 +#else +#define VALKYRIE_REG_PADSIZE 7 +#endif + /* * Structure of the registers for the Valkyrie colormap registers. */ struct cmap_regs { unsigned char addr; - char pad1[7]; + char pad1[VALKYRIE_REG_PADSIZE]; unsigned char lut; }; @@ -52,7 +61,7 @@ struct vpreg { /* padded register */ unsigned char r; - char pad[7]; + char pad[VALKYRIE_REG_PADSIZE]; }; @@ -81,6 +90,7 @@ int vres; }; +#ifndef CONFIG_MAC /* Register values for 1024x768, 75Hz mode (17) */ /* I'm not sure which mode this is (16 or 17), so I'm defining it as 17, * since the equivalent mode in controlfb (which I adapted this from) is @@ -125,14 +135,6 @@ 1024, 768 }; -/* Register values for 832x624, 75Hz mode (13) */ -static struct valkyrie_regvals valkyrie_reg_init_13 = { - 9, - { 23, 42, 3 }, /* pixel clock = 57.07MHz for V=74.27Hz */ - { 832, 0 }, - 832, 624 -}; - /* Register values for 800x600, 72Hz mode (11) */ static struct valkyrie_regvals valkyrie_reg_init_11 = { 13, @@ -140,6 +142,15 @@ { 800, 0 }, 800, 600 }; +#endif /* CONFIG_MAC */ + +/* Register values for 832x624, 75Hz mode (13) */ +static struct valkyrie_regvals valkyrie_reg_init_13 = { + 9, + { 23, 42, 3 }, /* pixel clock = 57.07MHz for V=74.27Hz */ + { 832, 0 }, + 832, 624 +}; /* Register values for 800x600, 60Hz mode (10) */ static struct valkyrie_regvals valkyrie_reg_init_10 = { @@ -177,6 +188,15 @@ NULL, NULL, &valkyrie_reg_init_10, +#ifdef CONFIG_MAC + NULL, + NULL, + &valkyrie_reg_init_13, + NULL, + NULL, + NULL, + NULL, +#else &valkyrie_reg_init_11, NULL, &valkyrie_reg_init_13, @@ -184,6 +204,7 @@ &valkyrie_reg_init_15, NULL, &valkyrie_reg_init_17, +#endif NULL, NULL, NULL diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/fs/Config.in linux-2.5/fs/Config.in --- linux-2.5.1/fs/Config.in Fri Nov 30 01:39:02 2001 +++ linux-2.5/fs/Config.in Thu Dec 27 15:56:12 2001 @@ -45,7 +45,7 @@ fi tristate 'Compressed ROM file system support' CONFIG_CRAMFS bool 'Virtual memory file system support (former shm fs)' CONFIG_TMPFS -tristate 'Simple RAM-based file system support' CONFIG_RAMFS +define_bool CONFIG_RAMFS y tristate 'ISO 9660 CDROM file system support' CONFIG_ISO9660_FS dep_mbool ' Microsoft Joliet CDROM extensions' CONFIG_JOLIET $CONFIG_ISO9660_FS diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/fs/adfs/inode.c linux-2.5/fs/adfs/inode.c --- linux-2.5.1/fs/adfs/inode.c Sun Dec 16 20:22:46 2001 +++ linux-2.5/fs/adfs/inode.c Sun Dec 30 20:01:41 2001 @@ -37,11 +37,8 @@ goto abort_toobig; block = __adfs_block_map(inode->i_sb, inode->i_ino, block); - if (block) { - bh->b_dev = inode->i_dev; - bh->b_blocknr = block; - bh->b_state |= (1UL << BH_Mapped); - } + if (block) + map_bh(bh, inode->i_sb, block); return 0; } /* don't support allocation of blocks yet */ @@ -251,7 +248,6 @@ if (!inode) goto out; - inode->i_version = ++event; inode->i_uid = sb->u.adfs_sb.s_uid; inode->i_gid = sb->u.adfs_sb.s_gid; inode->i_ino = obj->file_id; diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/fs/adfs/super.c linux-2.5/fs/adfs/super.c --- linux-2.5.1/fs/adfs/super.c Sun Dec 16 20:22:46 2001 +++ linux-2.5/fs/adfs/super.c Thu Dec 27 15:56:12 2001 @@ -319,8 +319,7 @@ if (parse_options(sb, data)) goto error; - sb->s_blocksize = BLOCK_SIZE; - set_blocksize(dev, BLOCK_SIZE); + sb_set_blocksize(sb, BLOCK_SIZE); if (!(bh = sb_bread(sb, ADFS_DISCRECORD / BLOCK_SIZE))) { adfs_error(sb, "unable to read superblock"); goto error; @@ -347,14 +346,8 @@ goto error_free_bh; } - sb->s_blocksize_bits = dr->log2secsize; - sb->s_blocksize = 1 << sb->s_blocksize_bits; - if (sb->s_blocksize != BLOCK_SIZE && - (sb->s_blocksize == 512 || sb->s_blocksize == 1024 || - sb->s_blocksize == 2048 || sb->s_blocksize == 4096)) { - - brelse(bh); - set_blocksize(dev, sb->s_blocksize); + brelse(bh); + if (sb_set_blocksize(sb, 1 << dr->log2secsize)) { bh = sb_bread(sb, ADFS_DISCRECORD / sb->s_blocksize); if (!bh) { adfs_error(sb, "couldn't read superblock on " @@ -367,12 +360,11 @@ goto error_free_bh; } dr = (struct adfs_discrecord *)(b_data + ADFS_DR_OFFSET); - } - if (sb->s_blocksize != bh->b_size) { + } else { if (!silent) printk(KERN_ERR "VFS: Unsupported blocksize on dev " "%s.\n", bdevname(dev)); - goto error_free_bh; + goto error; } /* diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/fs/affs/file.c linux-2.5/fs/affs/file.c --- linux-2.5.1/fs/affs/file.c Sun Dec 16 20:22:46 2001 +++ linux-2.5/fs/affs/file.c Thu Dec 27 22:10:28 2001 @@ -355,9 +355,7 @@ ext_bh = affs_get_extblock(inode, ext); if (IS_ERR(ext_bh)) goto err_ext; - bh_result->b_blocknr = be32_to_cpu(AFFS_BLOCK(sb, ext_bh, block)); - bh_result->b_dev = inode->i_dev; - bh_result->b_state |= (1UL << BH_Mapped); + map_bh(bh_result, sb, be32_to_cpu(AFFS_BLOCK(sb, ext_bh, block))); if (create) { u32 blocknr = affs_alloc_block(inode, ext_bh->b_blocknr); diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/fs/affs/super.c linux-2.5/fs/affs/super.c --- linux-2.5.1/fs/affs/super.c Sun Dec 16 20:22:46 2001 +++ linux-2.5/fs/affs/super.c Thu Dec 27 15:56:12 2001 @@ -327,10 +327,6 @@ got_root: root_block = AFFS_SB->s_root_block; - sb->s_blocksize_bits = blocksize == 512 ? 9 : - blocksize == 1024 ? 10 : - blocksize == 2048 ? 11 : 12; - /* Find out which kind of FS we have */ boot_bh = sb_bread(sb, 0); if (!boot_bh) { diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/fs/autofs/inode.c linux-2.5/fs/autofs/inode.c --- linux-2.5.1/fs/autofs/inode.c Thu Oct 25 07:02:26 2001 +++ linux-2.5/fs/autofs/inode.c Sun Dec 30 20:01:41 2001 @@ -11,6 +11,7 @@ * ------------------------------------------------------------------------- */ #include <linux/kernel.h> +#include <linux/mm.h> #include <linux/slab.h> #include <linux/file.h> #include <linux/locks.h> diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/fs/bfs/dir.c linux-2.5/fs/bfs/dir.c --- linux-2.5.1/fs/bfs/dir.c Sun Dec 16 20:22:46 2001 +++ linux-2.5/fs/bfs/dir.c Sun Dec 30 20:01:41 2001 @@ -28,13 +28,12 @@ struct inode * dir = f->f_dentry->d_inode; struct buffer_head * bh; struct bfs_dirent * de; - kdev_t dev = dir->i_dev; unsigned int offset; int block; if (f->f_pos & (BFS_DIRENT_SIZE-1)) { printf("Bad f_pos=%08lx for %s:%08lx\n", (unsigned long)f->f_pos, - bdevname(dev), dir->i_ino); + bdevname(dir->i_dev), dir->i_ino); return -EBADF; } @@ -174,7 +173,6 @@ inode->i_nlink = 1; } de->ino = 0; - dir->i_version = ++event; mark_buffer_dirty(bh); dir->i_ctime = dir->i_mtime = CURRENT_TIME; mark_inode_dirty(dir); @@ -227,7 +225,6 @@ } old_de->ino = 0; old_dir->i_ctime = old_dir->i_mtime = CURRENT_TIME; - old_dir->i_version = ++event; mark_inode_dirty(old_dir); if (new_inode) { new_inode->i_nlink--; @@ -256,7 +253,6 @@ struct buffer_head * bh; struct bfs_dirent * de; int block, sblock, eblock, off; - kdev_t dev; int i; dprintf("name=%s, namelen=%d\n", name, namelen); @@ -266,7 +262,6 @@ if (namelen > BFS_NAMELEN) return -ENAMETOOLONG; - dev = dir->i_dev; sblock = dir->iu_sblock; eblock = dir->iu_eblock; for (block=sblock; block<=eblock; block++) { @@ -282,7 +277,6 @@ } dir->i_mtime = CURRENT_TIME; mark_inode_dirty(dir); - dir->i_version = ++event; de->ino = ino; for (i=0; i<BFS_NAMELEN; i++) de->name[i] = (i < namelen) ? name[i] : 0; diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/fs/bfs/file.c linux-2.5/fs/bfs/file.c --- linux-2.5.1/fs/bfs/file.c Sun Dec 16 20:22:53 2001 +++ linux-2.5/fs/bfs/file.c Thu Dec 27 22:10:28 2001 @@ -25,14 +25,14 @@ mmap: generic_file_mmap, }; -static int bfs_move_block(unsigned long from, unsigned long to, kdev_t dev) +static int bfs_move_block(unsigned long from, unsigned long to, struct super_block *sb) { struct buffer_head *bh, *new; - bh = bread(dev, from, BFS_BSIZE); + bh = sb_bread(sb, from); if (!bh) return -EIO; - new = getblk(dev, to, BFS_BSIZE); + new = sb_getblk(sb, to); memcpy(new->b_data, bh->b_data, bh->b_size); mark_buffer_dirty(new); bforget(bh); @@ -40,14 +40,14 @@ return 0; } -static int bfs_move_blocks(kdev_t dev, unsigned long start, unsigned long end, +static int bfs_move_blocks(struct super_block *sb, unsigned long start, unsigned long end, unsigned long where) { unsigned long i; dprintf("%08lx-%08lx->%08lx\n", start, end, where); for (i = start; i <= end; i++) - if(bfs_move_block(i, where + i, dev)) { + if(bfs_move_block(i, where + i, sb)) { dprintf("failed to move block %08lx -> %08lx\n", i, where + i); return -EIO; } @@ -69,9 +69,7 @@ if (!create) { if (phys <= inode->iu_eblock) { dprintf("c=%d, b=%08lx, phys=%08lx (granted)\n", create, block, phys); - bh_result->b_dev = inode->i_dev; - bh_result->b_blocknr = phys; - bh_result->b_state |= (1UL << BH_Mapped); + map_bh(bh_result, sb, phys); } return 0; } @@ -81,9 +79,7 @@ if (inode->i_size && phys <= inode->iu_eblock) { dprintf("c=%d, b=%08lx, phys=%08lx (interim block granted)\n", create, block, phys); - bh_result->b_dev = inode->i_dev; - bh_result->b_blocknr = phys; - bh_result->b_state |= (1UL << BH_Mapped); + map_bh(bh_result, sb, phys); return 0; } @@ -95,9 +91,7 @@ if (inode->iu_eblock == sb->su_lf_eblk) { dprintf("c=%d, b=%08lx, phys=%08lx (simple extension)\n", create, block, phys); - bh_result->b_dev = inode->i_dev; - bh_result->b_blocknr = phys; - bh_result->b_state |= (1UL << BH_Mapped); + map_bh(bh_result, sb, phys); sb->su_freeb -= phys - inode->iu_eblock; sb->su_lf_eblk = inode->iu_eblock = phys; mark_inode_dirty(inode); @@ -109,7 +103,7 @@ /* Ok, we have to move this entire file to the next free block */ phys = sb->su_lf_eblk + 1; if (inode->iu_sblock) { /* if data starts on block 0 then there is no data */ - err = bfs_move_blocks(inode->i_dev, inode->iu_sblock, + err = bfs_move_blocks(inode->i_sb, inode->iu_sblock, inode->iu_eblock, phys); if (err) { dprintf("failed to move ino=%08lx -> fs corruption\n", inode->i_ino); @@ -128,9 +122,7 @@ sb->su_freeb -= inode->iu_eblock - inode->iu_sblock + 1 - inode->i_blocks; mark_inode_dirty(inode); mark_buffer_dirty(sbh); - bh_result->b_dev = inode->i_dev; - bh_result->b_blocknr = phys; - bh_result->b_state |= (1UL << BH_Mapped); + map_bh(bh_result, sb, phys); out: unlock_kernel(); return err; diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/fs/bfs/inode.c linux-2.5/fs/bfs/inode.c --- linux-2.5.1/fs/bfs/inode.c Sun Dec 16 20:22:53 2001 +++ linux-2.5/fs/bfs/inode.c Thu Dec 27 22:10:28 2001 @@ -35,13 +35,12 @@ static void bfs_read_inode(struct inode * inode) { unsigned long ino = inode->i_ino; - kdev_t dev = inode->i_dev; struct bfs_inode * di; struct buffer_head * bh; int block, off; if (ino < BFS_ROOT_INO || ino > inode->i_sb->su_lasti) { - printf("Bad inode number %s:%08lx\n", bdevname(dev), ino); + printf("Bad inode number %s:%08lx\n", bdevname(inode->i_dev), ino); make_bad_inode(inode); return; } @@ -49,7 +48,7 @@ block = (ino - BFS_ROOT_INO)/BFS_INODES_PER_BLOCK + 1; bh = sb_bread(inode->i_sb, block); if (!bh) { - printf("Unable to read inode %s:%08lx\n", bdevname(dev), ino); + printf("Unable to read inode %s:%08lx\n", bdevname(inode->i_dev), ino); make_bad_inode(inode); return; } @@ -88,13 +87,12 @@ static void bfs_write_inode(struct inode * inode, int unused) { unsigned long ino = inode->i_ino; - kdev_t dev = inode->i_dev; struct bfs_inode * di; struct buffer_head * bh; int block, off; if (ino < BFS_ROOT_INO || ino > inode->i_sb->su_lasti) { - printf("Bad inode number %s:%08lx\n", bdevname(dev), ino); + printf("Bad inode number %s:%08lx\n", bdevname(inode->i_dev), ino); return; } @@ -102,7 +100,7 @@ block = (ino - BFS_ROOT_INO)/BFS_INODES_PER_BLOCK + 1; bh = sb_bread(inode->i_sb, block); if (!bh) { - printf("Unable to read inode %s:%08lx\n", bdevname(dev), ino); + printf("Unable to read inode %s:%08lx\n", bdevname(inode->i_dev), ino); unlock_kernel(); return; } @@ -135,7 +133,6 @@ static void bfs_delete_inode(struct inode * inode) { unsigned long ino = inode->i_ino; - kdev_t dev = inode->i_dev; struct bfs_inode * di; struct buffer_head * bh; int block, off; @@ -155,7 +152,7 @@ block = (ino - BFS_ROOT_INO)/BFS_INODES_PER_BLOCK + 1; bh = sb_bread(s, block); if (!bh) { - printf("Unable to read inode %s:%08lx\n", bdevname(dev), ino); + printf("Unable to read inode %s:%08lx\n", bdevname(inode->i_dev), ino); unlock_kernel(); return; } @@ -241,16 +238,12 @@ static struct super_block * bfs_read_super(struct super_block * s, void * data, int silent) { - kdev_t dev; struct buffer_head * bh; struct bfs_super_block * bfs_sb; struct inode * inode; int i, imap_len; - dev = s->s_dev; - set_blocksize(dev, BFS_BSIZE); - s->s_blocksize = BFS_BSIZE; - s->s_blocksize_bits = BFS_BSIZE_BITS; + sb_set_blocksize(s, BFS_BSIZE); bh = sb_bread(s, 0); if(!bh) @@ -259,11 +252,11 @@ if (bfs_sb->s_magic != BFS_MAGIC) { if (!silent) printf("No BFS filesystem on %s (magic=%08x)\n", - bdevname(dev), bfs_sb->s_magic); + bdevname(s->s_dev), bfs_sb->s_magic); goto out; } if (BFS_UNCLEAN(bfs_sb, s) && !silent) - printf("%s is unclean, continuing\n", bdevname(dev)); + printf("%s is unclean, continuing\n", bdevname(s->s_dev)); s->s_magic = BFS_MAGIC; s->su_bfs_sb = bfs_sb; diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/fs/binfmt_elf.c linux-2.5/fs/binfmt_elf.c --- linux-2.5.1/fs/binfmt_elf.c Sun Oct 21 02:16:59 2001 +++ linux-2.5/fs/binfmt_elf.c Sun Dec 30 20:01:41 2001 @@ -32,7 +32,7 @@ #include <linux/highuid.h> #include <linux/smp_lock.h> #include <linux/compiler.h> -#include <linux/limits.h> +#include <linux/highmem.h> #include <asm/uaccess.h> #include <asm/param.h> @@ -505,30 +505,10 @@ #if 0 printk("Using ELF interpreter %s\n", elf_interpreter); #endif -#ifdef __sparc__ - if (ibcs2_interpreter) { - unsigned long old_pers = current->personality; - struct exec_domain *old_domain = current->exec_domain; - struct exec_domain *new_domain; - struct fs_struct *old_fs = current->fs, *new_fs; - get_exec_domain(old_domain); - atomic_inc(&old_fs->count); - - set_personality(PER_SVR4); - interpreter = open_exec(elf_interpreter); - - new_domain = current->exec_domain; - new_fs = current->fs; - current->personality = old_pers; - current->exec_domain = old_domain; - current->fs = old_fs; - put_exec_domain(new_domain); - put_fs_struct(new_fs); - } else -#endif - { - interpreter = open_exec(elf_interpreter); - } + + SET_PERSONALITY(elf_ex, ibcs2_interpreter); + + interpreter = open_exec(elf_interpreter); retval = PTR_ERR(interpreter); if (IS_ERR(interpreter)) goto out_free_interp; @@ -602,10 +582,6 @@ current->flags &= ~PF_FORKNOEXEC; elf_entry = (unsigned long) elf_ex.e_entry; - /* Do this immediately, since STACK_TOP as used in setup_arg_pages - may depend on the personality. */ - SET_PERSONALITY(elf_ex, ibcs2_interpreter); - /* Do this so that we can load the interpreter, if need be. We will change some of these later */ current->mm->rss = 0; @@ -1032,6 +1008,25 @@ elf_fpregset_t fpu; /* NT_PRFPREG */ struct elf_prpsinfo psinfo; /* NT_PRPSINFO */ + /* first copy the parameters from user space */ + memset(&psinfo, 0, sizeof(psinfo)); + { + int i, len; + + len = current->mm->arg_end - current->mm->arg_start; + if (len >= ELF_PRARGSZ) + len = ELF_PRARGSZ-1; + copy_from_user(&psinfo.pr_psargs, + (const char *)current->mm->arg_start, len); + for(i = 0; i < len; i++) + if (psinfo.pr_psargs[i] == 0) + psinfo.pr_psargs[i] = ' '; + psinfo.pr_psargs[len] = 0; + + } + + /* now stop all vm operations */ + down_write(¤t->mm->mmap_sem); segs = current->mm->map_count; #ifdef DEBUG @@ -1073,7 +1068,6 @@ * Set up the notes in similar form to SVR4 core dumps made * with info from their /proc. */ - memset(&psinfo, 0, sizeof(psinfo)); memset(&prstatus, 0, sizeof(prstatus)); notes[0].name = "CORE"; @@ -1129,23 +1123,6 @@ psinfo.pr_flag = current->flags; psinfo.pr_uid = NEW_TO_OLD_UID(current->uid); psinfo.pr_gid = NEW_TO_OLD_GID(current->gid); - { - int i, len; - - set_fs(fs); - - len = current->mm->arg_end - current->mm->arg_start; - if (len >= ELF_PRARGSZ) - len = ELF_PRARGSZ-1; - copy_from_user(&psinfo.pr_psargs, - (const char *)current->mm->arg_start, len); - for(i = 0; i < len; i++) - if (psinfo.pr_psargs[i] == 0) - psinfo.pr_psargs[i] = ' '; - psinfo.pr_psargs[len] = 0; - - set_fs(KERNEL_DS); - } strncpy(psinfo.pr_fname, current->comm, sizeof(psinfo.pr_fname)); notes[2].name = "CORE"; @@ -1217,8 +1194,6 @@ if (!writenote(¬es[i], file)) goto end_coredump; - set_fs(fs); - DUMP_SEEK(dataoff); for(vma = current->mm->mmap; vma != NULL; vma = vma->vm_next) { @@ -1232,22 +1207,24 @@ for (addr = vma->vm_start; addr < vma->vm_end; addr += PAGE_SIZE) { - pgd_t *pgd; - pmd_t *pmd; - pte_t *pte; - - pgd = pgd_offset(vma->vm_mm, addr); - if (pgd_none(*pgd)) - goto nextpage_coredump; - pmd = pmd_offset(pgd, addr); - if (pmd_none(*pmd)) - goto nextpage_coredump; - pte = pte_offset(pmd, addr); - if (pte_none(*pte)) { -nextpage_coredump: + struct page* page; + struct vm_area_struct *vma; + + if (get_user_pages(current, current->mm, addr, 1, 0, 1, + &page, &vma) <= 0) { DUMP_SEEK (file->f_pos + PAGE_SIZE); } else { - DUMP_WRITE((void*)addr, PAGE_SIZE); + if (page == ZERO_PAGE(addr)) { + DUMP_SEEK (file->f_pos + PAGE_SIZE); + } else { + void *kaddr; + flush_cache_page(vma, addr); + kaddr = kmap(page); + DUMP_WRITE(kaddr, PAGE_SIZE); + flush_page_to_ram(page); + kunmap(page); + } + put_page(page); } } } @@ -1260,6 +1237,7 @@ end_coredump: set_fs(fs); + up_write(¤t->mm->mmap_sem); return has_dumped; } #endif /* USE_ELF_CORE_DUMP */ diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/fs/bio.c linux-2.5/fs/bio.c --- linux-2.5.1/fs/bio.c Sun Dec 16 20:20:21 2001 +++ linux-2.5/fs/bio.c Thu Dec 27 22:10:28 2001 @@ -142,6 +142,7 @@ bio->bi_io_vec = bvl; return bio; } + mempool_free(bio, bio_pool); return NULL; } @@ -311,28 +312,6 @@ return NULL; } -#ifdef BIO_PAGEIO -static int bio_end_io_page(struct bio *bio) -{ - struct page *page = bio_page(bio); - - if (!test_bit(BIO_UPTODATE, &bio->bi_flags)) - SetPageError(page); - if (!PageError(page)) - SetPageUptodate(page); - - /* - * Run the hooks that have to be done when a page I/O has completed. - */ - if (PageTestandClearDecrAfter(page)) - atomic_dec(&nr_async_pages); - - UnlockPage(page); - bio_put(bio); - return 1; -} -#endif - static int bio_end_io_kio(struct bio *bio, int nr_sectors) { struct kiobuf *kio = (struct kiobuf *) bio->bi_private; @@ -465,7 +444,10 @@ else clear_bit(BIO_UPTODATE, &bio->bi_flags); - return bio->bi_end_io(bio, nr_sectors); + if (bio->bi_end_io) + return bio->bi_end_io(bio, nr_sectors); + + return 0; } static void __init biovec_init_pool(void) diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/fs/block_dev.c linux-2.5/fs/block_dev.c --- linux-2.5.1/fs/block_dev.c Wed Dec 12 00:47:44 2001 +++ linux-2.5/fs/block_dev.c Thu Dec 27 15:56:12 2001 @@ -102,6 +102,26 @@ return 0; } +int sb_set_blocksize(struct super_block *sb, int size) +{ + int bits; + if (set_blocksize(sb->s_dev, size) < 0) + return 0; + sb->s_blocksize = size; + for (bits = 9, size >>= 9; size >>= 1; bits++) + ; + sb->s_blocksize_bits = bits; + return sb->s_blocksize; +} + +int sb_min_blocksize(struct super_block *sb, int size) +{ + int minsize = get_hardsect_size(sb->s_dev); + if (size < minsize) + size = minsize; + return sb_set_blocksize(sb, size); +} + static int blkdev_get_block(struct inode * inode, sector_t iblock, struct buffer_head * bh, int create) { if (iblock >= max_block(inode->i_rdev)) @@ -330,6 +350,7 @@ inode->i_bdev = new_bdev; inode->i_data.a_ops = &def_blk_aops; inode->i_data.gfp_mask = GFP_USER; + inode->i_mode = S_IFBLK; spin_lock(&bdev_lock); bdev = bdfind(dev, head); if (!bdev) { @@ -499,7 +520,10 @@ de = devfs_find_handle (NULL, NULL, i, MINOR (dev), DEVFS_SPECIAL_BLK, 0); - if (de) bdops = devfs_get_ops (de); + if (de) { + bdops = devfs_get_ops (de); + devfs_put_ops (de); /* We're running in owner module */ + } } if (bdops == NULL) return 0; diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/fs/buffer.c linux-2.5/fs/buffer.c --- linux-2.5.1/fs/buffer.c Tue Dec 11 18:51:43 2001 +++ linux-2.5/fs/buffer.c Thu Dec 27 22:10:28 2001 @@ -324,7 +324,7 @@ lock_kernel(); sync_inodes_sb(sb); - DQUOT_SYNC(dev); + DQUOT_SYNC(sb); lock_super(sb); if (sb->s_dirt && sb->s_op && sb->s_op->write_super) sb->s_op->write_super(sb); @@ -346,7 +346,14 @@ lock_kernel(); sync_inodes(dev); - DQUOT_SYNC(dev); + if (dev) { + struct super_block *sb = get_super(dev); + if (sb) { + DQUOT_SYNC(sb); + drop_super(sb); + } + } else + DQUOT_SYNC(NULL); sync_supers(dev); unlock_kernel(); @@ -1046,7 +1053,7 @@ /* First, check for the "real" dirty limit. */ if (dirty > soft_dirty_limit) { - if (dirty > hard_dirty_limit) + if (dirty > hard_dirty_limit && !(current->flags & PF_NOIO)) return 1; return 0; } @@ -1444,7 +1451,7 @@ return 1; } -void create_empty_buffers(struct page *page, kdev_t dev, unsigned long blocksize) +void create_empty_buffers(struct page *page, unsigned long blocksize) { struct buffer_head *bh, *head, *tail; @@ -1455,8 +1462,6 @@ bh = head; do { - bh->b_dev = dev; - bh->b_blocknr = 0; bh->b_end_io = NULL; tail = bh; bh = bh->b_this_page; @@ -1518,7 +1523,7 @@ BUG(); if (!page->buffers) - create_empty_buffers(page, inode->i_dev, 1 << inode->i_blkbits); + create_empty_buffers(page, 1 << inode->i_blkbits); head = page->buffers; block = page->index << (PAGE_CACHE_SHIFT - inode->i_blkbits); @@ -1585,7 +1590,7 @@ blocksize = 1 << inode->i_blkbits; if (!page->buffers) - create_empty_buffers(page, inode->i_dev, blocksize); + create_empty_buffers(page, blocksize); head = page->buffers; bbits = inode->i_blkbits; @@ -1702,7 +1707,7 @@ PAGE_BUG(page); blocksize = 1 << inode->i_blkbits; if (!page->buffers) - create_empty_buffers(page, inode->i_dev, blocksize); + create_empty_buffers(page, blocksize); head = page->buffers; blocks = PAGE_CACHE_SIZE >> inode->i_blkbits; @@ -1907,7 +1912,7 @@ goto out; if (!page->buffers) - create_empty_buffers(page, inode->i_dev, blocksize); + create_empty_buffers(page, blocksize); /* Find the buffer that contains "offset" */ bh = page->buffers; @@ -2123,13 +2128,14 @@ panic("brw_page: page not locked for I/O"); if (!page->buffers) - create_empty_buffers(page, dev, size); + create_empty_buffers(page, size); head = bh = page->buffers; /* Stage 1: lock all the buffers */ do { lock_buffer(bh); bh->b_blocknr = *(b++); + bh->b_dev = dev; set_bit(BH_Mapped, &bh->b_state); set_buffer_async_io(bh); bh = bh->b_this_page; @@ -2308,7 +2314,7 @@ return 1; } -static int sync_page_buffers(struct buffer_head *head, unsigned int gfp_mask) +static int sync_page_buffers(struct buffer_head *head) { struct buffer_head * bh = head; int tryagain = 0; @@ -2412,9 +2418,10 @@ /* Uhhuh, start writeback so that we don't end up with all dirty pages */ write_unlock(&hash_table_lock); spin_unlock(&lru_list_lock); + gfp_mask = pf_gfp_mask(gfp_mask); if (gfp_mask & __GFP_IO) { if ((gfp_mask & __GFP_HIGHIO) || !PageHighMem(page)) { - if (sync_page_buffers(bh, gfp_mask)) { + if (sync_page_buffers(bh)) { /* no IO or waiting next time */ gfp_mask = 0; goto cleaned_buffers_try_again; diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/fs/char_dev.c linux-2.5/fs/char_dev.c --- linux-2.5.1/fs/char_dev.c Fri Nov 2 19:48:21 2001 +++ linux-2.5/fs/char_dev.c Sun Dec 30 20:01:41 2001 @@ -6,6 +6,7 @@ #include <linux/config.h> #include <linux/init.h> +#include <linux/fs.h> #include <linux/slab.h> #define HASH_BITS 6 diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/fs/coda/cache.c linux-2.5/fs/coda/cache.c --- linux-2.5.1/fs/coda/cache.c Wed Dec 5 21:02:14 2001 +++ linux-2.5/fs/coda/cache.c Sun Dec 30 21:17:30 2001 @@ -14,7 +14,6 @@ #include <linux/stat.h> #include <linux/errno.h> #include <linux/locks.h> -#include <asm/segment.h> #include <asm/uaccess.h> #include <linux/string.h> #include <linux/list.h> diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/fs/coda/coda_linux.c linux-2.5/fs/coda/coda_linux.c --- linux-2.5.1/fs/coda/coda_linux.c Wed Apr 25 23:18:54 2001 +++ linux-2.5/fs/coda/coda_linux.c Sun Dec 30 21:17:30 2001 @@ -15,7 +15,6 @@ #include <linux/stat.h> #include <linux/errno.h> #include <linux/locks.h> -#include <asm/segment.h> #include <asm/uaccess.h> #include <linux/string.h> diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/fs/coda/file.c linux-2.5/fs/coda/file.c --- linux-2.5.1/fs/coda/file.c Wed Dec 5 21:02:14 2001 +++ linux-2.5/fs/coda/file.c Sun Dec 30 21:17:30 2001 @@ -16,7 +16,6 @@ #include <linux/errno.h> #include <linux/locks.h> #include <linux/smp_lock.h> -#include <asm/segment.h> #include <linux/string.h> #include <asm/uaccess.h> diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/fs/coda/inode.c linux-2.5/fs/coda/inode.c --- linux-2.5.1/fs/coda/inode.c Wed Dec 5 21:02:14 2001 +++ linux-2.5/fs/coda/inode.c Sun Dec 30 21:17:30 2001 @@ -25,7 +25,6 @@ #include <linux/fs.h> #include <linux/vmalloc.h> -#include <asm/segment.h> #include <linux/coda.h> #include <linux/coda_linux.h> diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/fs/coda/pioctl.c linux-2.5/fs/coda/pioctl.c --- linux-2.5.1/fs/coda/pioctl.c Wed Dec 5 21:02:14 2001 +++ linux-2.5/fs/coda/pioctl.c Sun Dec 30 21:17:30 2001 @@ -14,7 +14,6 @@ #include <linux/stat.h> #include <linux/errno.h> #include <linux/locks.h> -#include <asm/segment.h> #include <linux/string.h> #define __NO_VERSION__ #include <linux/module.h> diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/fs/coda/psdev.c linux-2.5/fs/coda/psdev.c --- linux-2.5.1/fs/coda/psdev.c Wed Dec 5 21:02:14 2001 +++ linux-2.5/fs/coda/psdev.c Sun Dec 30 21:17:30 2001 @@ -38,7 +38,6 @@ #include <linux/list.h> #include <linux/smp_lock.h> #include <asm/io.h> -#include <asm/segment.h> #include <asm/system.h> #include <asm/poll.h> #include <asm/uaccess.h> diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/fs/coda/sysctl.c linux-2.5/fs/coda/sysctl.c --- linux-2.5.1/fs/coda/sysctl.c Wed Dec 5 21:02:14 2001 +++ linux-2.5/fs/coda/sysctl.c Sun Dec 30 21:17:30 2001 @@ -21,7 +21,6 @@ #include <linux/stat.h> #include <linux/ctype.h> #include <asm/bitops.h> -#include <asm/segment.h> #include <asm/uaccess.h> #include <linux/utsname.h> #define __NO_VERSION__ diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/fs/coda/upcall.c linux-2.5/fs/coda/upcall.c --- linux-2.5.1/fs/coda/upcall.c Wed Dec 5 21:02:14 2001 +++ linux-2.5/fs/coda/upcall.c Sun Dec 30 21:17:30 2001 @@ -15,7 +15,6 @@ */ #include <asm/system.h> -#include <asm/segment.h> #include <asm/signal.h> #include <linux/signal.h> diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/fs/cramfs/inode.c linux-2.5/fs/cramfs/inode.c --- linux-2.5.1/fs/cramfs/inode.c Sun Dec 16 20:22:53 2001 +++ linux-2.5/fs/cramfs/inode.c Thu Dec 27 15:56:12 2001 @@ -195,9 +195,7 @@ unsigned long root_offset; struct super_block * retval = NULL; - set_blocksize(sb->s_dev, PAGE_CACHE_SIZE); - sb->s_blocksize = PAGE_CACHE_SIZE; - sb->s_blocksize_bits = PAGE_CACHE_SHIFT; + sb_set_blocksize(sb, PAGE_CACHE_SIZE); /* Invalidate the read buffers on mount: think disk change.. */ for (i = 0; i < READ_BUFFERS; i++) diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/fs/devfs/base.c linux-2.5/fs/devfs/base.c --- linux-2.5.1/fs/devfs/base.c Fri Nov 30 16:41:52 2001 +++ linux-2.5/fs/devfs/base.c Sun Dec 30 21:16:28 2001 @@ -427,7 +427,7 @@ Work sponsored by SGI. v0.92 20000306 Richard Gooch <rgooch@atnf.csiro.au> - Added DEVFS_FL_NO_PERSISTENCE flag. + Added DEVFS_ FL_NO_PERSISTENCE flag. Removed unnecessary call to <update_devfs_inode_from_entry> in <devfs_readdir>. Work sponsored by SGI. @@ -562,6 +562,45 @@ 20011122 Richard Gooch <rgooch@atnf.csiro.au> Use slab cache rather than fixed buffer for devfsd events. v1.1 + 20011125 Richard Gooch <rgooch@atnf.csiro.au> + Send DEVFSD_NOTIFY_REGISTERED events in <devfs_mk_dir>. + 20011127 Richard Gooch <rgooch@atnf.csiro.au> + Fixed locking bug in <devfs_d_revalidate_wait> due to typo. + Do not send CREATE, CHANGE, ASYNC_OPEN or DELETE events from + devfsd or children. + v1.2 + 20011202 Richard Gooch <rgooch@atnf.csiro.au> + Fixed bug in <devfsd_read>: was dereferencing freed pointer. + v1.3 + 20011203 Richard Gooch <rgooch@atnf.csiro.au> + Fixed bug in <devfsd_close>: was dereferencing freed pointer. + Added process group check for devfsd privileges. + v1.4 + 20011204 Richard Gooch <rgooch@atnf.csiro.au> + Use SLAB_ATOMIC in <devfsd_notify_de> from <devfs_d_delete>. + v1.5 + 20011211 Richard Gooch <rgooch@atnf.csiro.au> + Return old entry in <devfs_mk_dir> for 2.4.x kernels. + 20011212 Richard Gooch <rgooch@atnf.csiro.au> + Increment refcount on module in <check_disc_changed>. + 20011215 Richard Gooch <rgooch@atnf.csiro.au> + Created <devfs_get_handle> and exported <devfs_put>. + Increment refcount on module in <devfs_get_ops>. + Created <devfs_put_ops>. + v1.6 + 20011216 Richard Gooch <rgooch@atnf.csiro.au> + Added poisoning to <devfs_put>. + Improved debugging messages. + v1.7 + 20011221 Richard Gooch <rgooch@atnf.csiro.au> + Corrected (made useful) debugging message in <unregister>. + Moved <kmem_cache_create> in <mount_devfs_fs> to <init_devfs_fs> + 20011224 Richard Gooch <rgooch@atnf.csiro.au> + Added magic number to guard against scribbling drivers. + 20011226 Richard Gooch <rgooch@atnf.csiro.au> + Only return old entry in <devfs_mk_dir> if a directory. + Defined macros for error and debug messages. + v1.8 */ #include <linux/types.h> #include <linux/errno.h> @@ -594,13 +633,16 @@ #include <asm/bitops.h> #include <asm/atomic.h> -#define DEVFS_VERSION "1.1 (20011122)" +#define DEVFS_VERSION "1.8 (20011226)" #define DEVFS_NAME "devfs" #define FIRST_INODE 1 #define STRING_LENGTH 256 +#define FAKE_BLOCK_SIZE 1024 +#define POISON_PTR ( *(void **) poison_array ) +#define MAGIC_VALUE 0x327db823 #ifndef TRUE # define TRUE 1 @@ -637,9 +679,28 @@ #define OPTION_MOUNT 0x01 #define OPTION_ONLY 0x02 -#define OOPS(format, args...) {printk (format, ## args); \ - printk ("Forcing Oops\n"); \ - BUG();} +#define PRINTK(format, args...) \ + {printk (KERN_ERR "%s" format, __FUNCTION__ , ## args);} + +#define OOPS(format, args...) \ + {printk (KERN_CRIT "%s" format, __FUNCTION__ , ## args); \ + printk ("Forcing Oops\n"); \ + BUG();} + +#ifdef CONFIG_DEVFS_DEBUG +# define VERIFY_ENTRY(de) \ + {if ((de) && (de)->magic_number != MAGIC_VALUE) \ + OOPS ("(%p): bad magic value: %x\n", (de), (de)->magic_number);} +# define WRITE_ENTRY_MAGIC(de,magic) (de)->magic_number = (magic) +# define DPRINTK(flag, format, args...) \ + {if (devfs_debug & flag) \ + printk (KERN_INFO "%s" format, __FUNCTION__ , ## args);} +#else +# define VERIFY_ENTRY(de) +# define WRITE_ENTRY_MAGIC(de,magic) +# define DPRINTK(flag, format, args...) +#endif + struct directory_type { @@ -696,6 +757,9 @@ struct devfs_entry { +#ifdef CONFIG_DEVFS_DEBUG + unsigned int magic_number; +#endif void *info; atomic_t refcount; /* When this drops to zero, it's unused */ union @@ -740,6 +804,7 @@ struct devfsd_buf_entry *devfsd_last_event; volatile int devfsd_sleeping; volatile struct task_struct *devfsd_task; + volatile pid_t devfsd_pgrp; volatile struct file *devfsd_file; struct devfsd_notify_struct *devfsd_info; volatile unsigned long devfsd_event_mask; @@ -757,6 +822,8 @@ static unsigned int stat_num_entries; static unsigned int stat_num_bytes; #endif +static unsigned char poison_array[8] = + {0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a}; #ifdef CONFIG_DEVFS_MOUNT static unsigned int boot_options = OPTION_MOUNT; @@ -802,27 +869,26 @@ static struct devfs_entry *devfs_get (struct devfs_entry *de) { + VERIFY_ENTRY (de); if (de) atomic_inc (&de->refcount); return de; } /* End Function devfs_get */ /** * devfs_put - Put (release) a reference to a devfs entry. - * @de: The devfs entry. + * @de: The handle to the devfs entry. */ -static void devfs_put (struct devfs_entry *de) +void devfs_put (devfs_handle_t de) { if (!de) return; + VERIFY_ENTRY (de); + if (de->info == POISON_PTR) OOPS ("(%p): poisoned pointer\n", de); if ( !atomic_dec_and_test (&de->refcount) ) return; - if (de == root_entry) - OOPS ("%s: devfs_put(): root entry being freed\n", DEVFS_NAME); -#ifdef CONFIG_DEVFS_DEBUG - if (devfs_debug & DEBUG_FREE) - printk ("%s: devfs_put(%s): de: %p, parent: %p \"%s\"\n", - DEVFS_NAME, de->name, de, de->parent, - de->parent ? de->parent->name : "no parent"); -#endif + if (de == root_entry) OOPS ("(%p): root entry being freed\n", de); + DPRINTK (DEBUG_FREE, "(%s): de: %p, parent: %p \"%s\"\n", + de->name, de, de->parent, + de->parent ? de->parent->name : "no parent"); if ( S_ISLNK (de->mode) ) kfree (de->u.symlink.linkname); if ( ( S_ISCHR (de->mode) || S_ISBLK (de->mode) ) && de->u.fcb.autogen ) { @@ -831,6 +897,7 @@ MKDEV (de->u.fcb.u.device.major, de->u.fcb.u.device.minor) ); } + WRITE_ENTRY_MAGIC (de, 0); #ifdef CONFIG_DEVFS_DEBUG spin_lock (&stat_lock); --stat_num_entries; @@ -838,6 +905,7 @@ if ( S_ISLNK (de->mode) ) stat_num_bytes -= de->u.symlink.length + 1; spin_unlock (&stat_lock); #endif + de->info = POISON_PTR; kfree (de); } /* End Function devfs_put */ @@ -860,7 +928,7 @@ if ( !S_ISDIR (dir->mode) ) { - printk ("%s: search_dir(%s): not a directory\n", DEVFS_NAME,dir->name); + PRINTK ("(%s): not a directory\n", dir->name); return NULL; } for (curr = dir->u.dir.first; curr != NULL; curr = curr->next) @@ -893,7 +961,7 @@ if ( name && (namelen < 1) ) namelen = strlen (name); if ( ( new = kmalloc (sizeof *new + namelen, GFP_KERNEL) ) == NULL ) return NULL; - memset (new, 0, sizeof *new + namelen); + memset (new, 0, sizeof *new + namelen); /* Will set '\0' on name */ new->mode = mode; if ( S_ISDIR (mode) ) rwlock_init (&new->u.dir.lock); atomic_set (&new->refcount, 1); @@ -902,6 +970,7 @@ spin_unlock (&counter_lock); if (name) memcpy (new->name, name, namelen); new->namelen = namelen; + WRITE_ENTRY_MAGIC (new, MAGIC_VALUE); #ifdef CONFIG_DEVFS_DEBUG spin_lock (&stat_lock); ++stat_num_entries; @@ -918,7 +987,7 @@ * @de: The devfs entry to append. * @removable: If TRUE, increment the count of removable devices for %dir. * @old_de: If an existing entry exists, it will be written here. This may - * be %NULL. + * be %NULL. An implicit devfs_get() is performed on this entry. * * Append a devfs entry to a directory's list of children, checking first to * see if an entry of the same name exists. The directory will be locked. @@ -934,8 +1003,7 @@ if (old_de) *old_de = NULL; if ( !S_ISDIR (dir->mode) ) { - printk ("%s: append_entry(%s): dir: \"%s\" is not a directory\n", - DEVFS_NAME, de->name, dir->name); + PRINTK ("(%s): dir: \"%s\" is not a directory\n", de->name, dir->name); devfs_put (de); return -ENOTDIR; } @@ -1105,15 +1173,13 @@ if ( ( *dir = _devfs_make_parent_for_leaf (*dir, name, namelen, &leaf_pos) ) == NULL ) { - printk ("%s: prepare_leaf(%s): could not create parent path\n", - DEVFS_NAME, name); + PRINTK ("(%s): could not create parent path\n", name); return NULL; } if ( ( de = _devfs_alloc_entry (name + leaf_pos, namelen - leaf_pos,mode) ) == NULL ) { - printk ("%s: prepare_leaf(%s): could not allocate entry\n", - DEVFS_NAME, name); + PRINTK ("(%s): could not allocate entry\n", name); devfs_put (*dir); return NULL; } @@ -1160,19 +1226,20 @@ /** - * find_by_dev - Find a devfs entry in a directory. + * _devfs_find_by_dev - Find a devfs entry in a directory. * @dir: The directory where to search * @major: The major number to search for. * @minor: The minor number to search for. * @type: The type of special file to search for. This may be either * %DEVFS_SPECIAL_CHR or %DEVFS_SPECIAL_BLK. * - * Returns the devfs_entry pointer on success, else %NULL. + * Returns the devfs_entry pointer on success, else %NULL. An implicit + * devfs_get() is performed. */ -static struct devfs_entry *find_by_dev (struct devfs_entry *dir, - unsigned int major, unsigned int minor, - char type) +static struct devfs_entry *_devfs_find_by_dev (struct devfs_entry *dir, + unsigned int major, + unsigned int minor, char type) { struct devfs_entry *entry, *de; @@ -1180,7 +1247,7 @@ if (dir == NULL) return NULL; if ( !S_ISDIR (dir->mode) ) { - printk ("%s: find_by_dev(): not a directory\n", DEVFS_NAME); + PRINTK ("(%p): not a directory\n", dir); devfs_put (dir); return NULL; } @@ -1205,7 +1272,7 @@ for (entry = dir->u.dir.first; entry != NULL; entry = entry->next) { if ( !S_ISDIR (entry->mode) ) continue; - de = find_by_dev (entry, major, minor, type); + de = _devfs_find_by_dev (entry, major, minor, type); if (de) { read_unlock (&dir->u.dir.lock); @@ -1216,51 +1283,51 @@ read_unlock (&dir->u.dir.lock); devfs_put (dir); return NULL; -} /* End Function find_by_dev */ +} /* End Function _devfs_find_by_dev */ /** - * find_entry - Find a devfs entry. + * _devfs_find_entry - Find a devfs entry. * @dir: The handle to the parent devfs directory entry. If this is %NULL the * name is relative to the root of the devfs. - * @name: The name of the entry. This is ignored if @handle is not %NULL. - * @namelen: The number of characters in @name, not including a %NULL - * terminator. If this is 0, then @name must be %NULL-terminated and the - * length is computed internally. - * @major: The major number. This is used if @handle and @name are %NULL. - * @minor: The minor number. This is used if @handle and @name are %NULL. + * @name: The name of the entry. This may be %NULL. + * @major: The major number. This is used if lookup by @name fails. + * @minor: The minor number. This is used if lookup by @name fails. * NOTE: If @major and @minor are both 0, searching by major and minor * numbers is disabled. * @type: The type of special file to search for. This may be either * %DEVFS_SPECIAL_CHR or %DEVFS_SPECIAL_BLK. * @traverse_symlink: If %TRUE then symbolic links are traversed. * - * Returns the devfs_entry pointer on success, else %NULL. + * Returns the devfs_entry pointer on success, else %NULL. An implicit + * devfs_get() is performed. */ -static struct devfs_entry *find_entry (devfs_handle_t dir, - const char *name, unsigned int namelen, - unsigned int major, unsigned int minor, - char type, int traverse_symlink) +static struct devfs_entry *_devfs_find_entry (devfs_handle_t dir, + const char *name, + unsigned int major, + unsigned int minor, + char type, int traverse_symlink) { struct devfs_entry *entry; if (name != NULL) { - if (namelen < 1) namelen = strlen (name); + unsigned int namelen = strlen (name); + if (name[0] == '/') { /* Skip leading pathname component */ if (namelen < 2) { - printk ("%s: find_entry(%s): too short\n", DEVFS_NAME, name); + PRINTK ("(%s): too short\n", name); return NULL; } for (++name, --namelen; (*name != '/') && (namelen > 0); ++name, --namelen); if (namelen < 2) { - printk ("%s: find_entry(%s): too short\n", DEVFS_NAME, name); + PRINTK ("(%s): too short\n", name); return NULL; } ++name; @@ -1271,12 +1338,13 @@ } /* Have to search by major and minor: slow */ if ( (major == 0) && (minor == 0) ) return NULL; - return find_by_dev (root_entry, major, minor, type); -} /* End Function find_entry */ + return _devfs_find_by_dev (root_entry, major, minor, type); +} /* End Function _devfs_find_entry */ static struct devfs_entry *get_devfs_entry_from_vfs_inode (struct inode *inode) { if (inode == NULL) return NULL; + VERIFY_ENTRY ( (struct devfs_entry *) inode->u.generic_ip ); return inode->u.generic_ip; } /* End Function get_devfs_entry_from_vfs_inode */ @@ -1315,10 +1383,14 @@ { struct task_struct *p; - for (p = current; p != &init_task; p = p->p_opptr) + if (current == fs_info->devfsd_task) return (TRUE); + if (current->pgrp == fs_info->devfsd_pgrp) return (TRUE); +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,1) + for (p = current->p_opptr; p != &init_task; p = p->p_opptr) { if (p == fs_info->devfsd_task) return (TRUE); } +#endif return (FALSE); } /* End Function is_devfsd_or_child */ @@ -1375,13 +1447,16 @@ static int devfsd_notify_de (struct devfs_entry *de, unsigned short type, umode_t mode, - uid_t uid, gid_t gid, struct fs_info *fs_info) + uid_t uid, gid_t gid, struct fs_info *fs_info, + int atomic) { struct devfsd_buf_entry *entry; struct devfs_entry *curr; if ( !( fs_info->devfsd_event_mask & (1 << type) ) ) return (FALSE); - if ( ( entry = kmem_cache_alloc (devfsd_buf_cache, 0) ) == NULL ) + if ( ( entry = kmem_cache_alloc (devfsd_buf_cache, + atomic ? SLAB_ATOMIC : SLAB_KERNEL) ) + == NULL ) { atomic_inc (&fs_info->devfsd_overrun_count); return (FALSE); @@ -1414,7 +1489,7 @@ static void devfsd_notify (struct devfs_entry *de,unsigned short type,int wait) { if (devfsd_notify_de (de, type, de->mode, current->euid, - current->egid, &fs_info) && wait) + current->egid, &fs_info, 0) && wait) wait_for_devfsd_finished (&fs_info); } /* End Function devfsd_notify */ @@ -1451,7 +1526,7 @@ if (name == NULL) { - printk ("%s: devfs_register(): NULL name pointer\n", DEVFS_NAME); + PRINTK ("(): NULL name pointer\n"); return NULL; } if (ops == NULL) @@ -1459,23 +1534,19 @@ if ( S_ISBLK (mode) ) ops = (void *) get_blkfops (major); if (ops == NULL) { - printk ("%s: devfs_register(%s): NULL ops pointer\n", - DEVFS_NAME, name); + PRINTK ("(%s): NULL ops pointer\n", name); return NULL; } - printk ("%s: devfs_register(%s): NULL ops, got %p from major table\n", - DEVFS_NAME, name, ops); + PRINTK ("(%s): NULL ops, got %p from major table\n", name, ops); } if ( S_ISDIR (mode) ) { - printk("%s: devfs_register(%s): creating directories is not allowed\n", - DEVFS_NAME, name); + PRINTK ("(%s): creating directories is not allowed\n", name); return NULL; } if ( S_ISLNK (mode) ) { - printk ("%s: devfs_register(%s): creating symlinks is not allowed\n", - DEVFS_NAME, name); + PRINTK ("(%s): creating symlinks is not allowed\n", name); return NULL; } if ( ( S_ISCHR (mode) || S_ISBLK (mode) ) && @@ -1483,8 +1554,8 @@ { if ( ( devnum = devfs_alloc_devnum (devtype) ) == NODEV ) { - printk ("%s: devfs_register(%s): exhausted %s device numbers\n", - DEVFS_NAME, name, S_ISCHR (mode) ? "char" : "block"); + PRINTK ("(%s): exhausted %s device numbers\n", + name, S_ISCHR (mode) ? "char" : "block"); return NULL; } major = MAJOR (devnum); @@ -1492,8 +1563,7 @@ } if ( ( de = _devfs_prepare_leaf (&dir, name, mode) ) == NULL ) { - printk ("%s: devfs_register(%s): could not prepare leaf\n", - DEVFS_NAME, name); + PRINTK ("(%s): could not prepare leaf\n", name); if (devnum != NODEV) devfs_dealloc_devnum (devtype, devnum); return NULL; } @@ -1505,8 +1575,7 @@ } else if ( !S_ISREG (mode) ) { - printk ("%s: devfs_register(%s): illegal mode: %x\n", - DEVFS_NAME, name, mode); + PRINTK ("(%s): illegal mode: %x\n", name, mode); devfs_put (de); devfs_put (dir); return (NULL); @@ -1530,17 +1599,13 @@ if ( ( err = _devfs_append_entry (dir, de, de->u.fcb.removable, NULL) ) != 0 ) { - printk("%s: devfs_register(%s): could not append to parent, err: %d\n", - DEVFS_NAME, name, err); + PRINTK ("(%s): could not append to parent, err: %d\n", name, err); devfs_put (dir); if (devnum != NODEV) devfs_dealloc_devnum (devtype, devnum); return NULL; } -#ifdef CONFIG_DEVFS_DEBUG - if (devfs_debug & DEBUG_REGISTER) - printk ("%s: devfs_register(%s): de: %p dir: %p \"%s\" pp: %p\n", - DEVFS_NAME, name, de, dir, dir->name, dir->parent); -#endif + DPRINTK (DEBUG_REGISTER, "(%s): de: %p dir: %p \"%s\" pp: %p\n", + name, de, dir, dir->name, dir->parent); devfsd_notify (de, DEVFSD_NOTIFY_REGISTERED, flags & DEVFS_FL_WAIT); devfs_put (dir); return de; @@ -1576,7 +1641,7 @@ /** - * unregister - Unregister a device entry from it's parent. + * _devfs_unregister - Unregister a device entry from it's parent. * @dir: The parent directory. * @de: The entry to unregister. * @@ -1584,7 +1649,7 @@ * unlocked by this function. */ -static void unregister (struct devfs_entry *dir, struct devfs_entry *de) +static void _devfs_unregister (struct devfs_entry *dir, struct devfs_entry *de) { int unhooked = _devfs_unhook (de); @@ -1603,34 +1668,30 @@ write_lock (&de->u.dir.lock); de->u.dir.no_more_additions = TRUE; child = de->u.dir.first; - unregister (de, child); + VERIFY_ENTRY (child); + _devfs_unregister (de, child); if (!child) break; -#ifdef CONFIG_DEVFS_DEBUG - if (devfs_debug & DEBUG_UNREGISTER) - printk ("%s: unregister(): child->name: \"%s\" child: %p\n", - DEVFS_NAME, child->name, child); -#endif + DPRINTK (DEBUG_UNREGISTER, "(%s): child: %p refcount: %d\n", + child->name, child, atomic_read (&child->refcount) ); devfs_put (child); } -} /* End Function unregister */ +} /* End Function _devfs_unregister */ /** * devfs_unregister - Unregister a device entry. * @de: A handle previously created by devfs_register() or returned from - * devfs_find_handle(). If this is %NULL the routine does nothing. + * devfs_get_handle(). If this is %NULL the routine does nothing. */ void devfs_unregister (devfs_handle_t de) { + VERIFY_ENTRY (de); if ( (de == NULL) || (de->parent == NULL) ) return; -#ifdef CONFIG_DEVFS_DEBUG - if (devfs_debug & DEBUG_UNREGISTER) - printk ("%s: devfs_unregister(): de->name: \"%s\" de: %p\n", - DEVFS_NAME, de->name, de); -#endif + DPRINTK (DEBUG_UNREGISTER, "(%s): de: %p refcount: %d\n", + de->name, de, atomic_read (&de->refcount) ); write_lock (&de->parent->u.dir.lock); - unregister (de->parent, de); + _devfs_unregister (de->parent, de); devfs_put (de); } /* End Function devfs_unregister */ @@ -1646,16 +1707,12 @@ if (handle != NULL) *handle = NULL; if (name == NULL) { - printk ("%s: devfs_do_symlink(): NULL name pointer\n", DEVFS_NAME); + PRINTK ("(): NULL name pointer\n"); return -EINVAL; } -#ifdef CONFIG_DEVFS_DEBUG - if (devfs_debug & DEBUG_REGISTER) - printk ("%s: devfs_do_symlink(%s)\n", DEVFS_NAME, name); -#endif if (link == NULL) { - printk ("%s: devfs_do_symlink(): NULL link pointer\n", DEVFS_NAME); + PRINTK ("(%s): NULL link pointer\n", name); return -EINVAL; } linklength = strlen (link); @@ -1666,8 +1723,7 @@ if ( ( de = _devfs_prepare_leaf (&dir, name, S_IFLNK | S_IRUGO | S_IXUGO) ) == NULL ) { - printk ("%s: devfs_do_symlink(%s): could not prepare leaf\n", - DEVFS_NAME, name); + PRINTK ("(%s): could not prepare leaf\n", name); kfree (newlink); return -ENOTDIR; } @@ -1677,8 +1733,7 @@ de->u.symlink.length = linklength; if ( ( err = _devfs_append_entry (dir, de, FALSE, NULL) ) != 0 ) { - printk ("%s: devfs_do_symlink(%s): could not append to parent, err: %d\n", - DEVFS_NAME, name, err); + PRINTK ("(%s): could not append to parent, err: %d\n", name, err); devfs_put (dir); return err; } @@ -1713,6 +1768,7 @@ devfs_handle_t de; if (handle != NULL) *handle = NULL; + DPRINTK (DEBUG_REGISTER, "(%s)\n", name); err = devfs_do_symlink (dir, name, flags, link, &de, info); if (err) return err; if (handle != NULL) *handle = de; @@ -1738,39 +1794,47 @@ devfs_handle_t devfs_mk_dir (devfs_handle_t dir, const char *name, void *info) { int err; - struct devfs_entry *de; + struct devfs_entry *de, *old; if (name == NULL) { - printk ("%s: devfs_mk_dir(): NULL name pointer\n", DEVFS_NAME); + PRINTK ("(): NULL name pointer\n"); return NULL; } if ( ( de = _devfs_prepare_leaf (&dir, name, MODE_DIR) ) == NULL ) { - printk ("%s: devfs_mk_dir(%s): could not prepare leaf\n", - DEVFS_NAME, name); + PRINTK ("(%s): could not prepare leaf\n", name); return NULL; } de->info = info; - if ( ( err = _devfs_append_entry (dir, de, FALSE, NULL) ) != 0 ) + if ( ( err = _devfs_append_entry (dir, de, FALSE, &old) ) != 0 ) { - printk ("%s: devfs_mk_dir(%s): could not append to dir: %p \"%s\", err: %d\n", - DEVFS_NAME, name, dir, dir->name, err); +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,1) + if ( old && S_ISDIR (old->mode) ) + { + PRINTK ("(%s): using old entry in dir: %p \"%s\"\n", + name, dir, dir->name); + old->vfs_created = FALSE; + devfs_put (dir); + return old; + } +#endif + PRINTK ("(%s): could not append to dir: %p \"%s\", err: %d\n", + name, dir, dir->name, err); + devfs_put (old); devfs_put (dir); return NULL; } -#ifdef CONFIG_DEVFS_DEBUG - if (devfs_debug & DEBUG_REGISTER) - printk ("%s: devfs_mk_dir(%s): de: %p dir: %p \"%s\"\n", - DEVFS_NAME, name, de, dir, dir->name); -#endif + DPRINTK (DEBUG_REGISTER, "(%s): de: %p dir: %p \"%s\"\n", + name, de, dir, dir->name); + devfsd_notify (de, DEVFSD_NOTIFY_REGISTERED, 0); devfs_put (dir); return de; } /* End Function devfs_mk_dir */ /** - * devfs_find_handle - Find the handle of a devfs entry. + * devfs_get_handle - Find the handle of a devfs entry. * @dir: The handle to the parent devfs directory entry. If this is %NULL the * name is relative to the root of the devfs. * @name: The name of the entry. @@ -1782,20 +1846,31 @@ * traversed. Symlinks pointing out of the devfs namespace will cause a * failure. Symlink traversal consumes stack space. * - * Returns a handle which may later be used in a call to devfs_unregister(), - * devfs_get_flags(), or devfs_set_flags(). On failure %NULL is returned. + * Returns a handle which may later be used in a call to + * devfs_unregister(), devfs_get_flags(), or devfs_set_flags(). A + * subsequent devfs_put() is required to decrement the refcount. + * On failure %NULL is returned. */ +devfs_handle_t devfs_get_handle (devfs_handle_t dir, const char *name, + unsigned int major, unsigned int minor, + char type, int traverse_symlinks) +{ + if ( (name != NULL) && (name[0] == '\0') ) name = NULL; + return _devfs_find_entry (dir, name, major, minor, type,traverse_symlinks); +} /* End Function devfs_get_handle */ + + +/* Compatibility function. Will be removed in sometime in 2.5 */ + devfs_handle_t devfs_find_handle (devfs_handle_t dir, const char *name, unsigned int major, unsigned int minor, char type, int traverse_symlinks) { devfs_handle_t de; - if ( (name != NULL) && (name[0] == '\0') ) name = NULL; - de = find_entry (dir, name, 0, major, minor, type, traverse_symlinks); - devfs_put (de); /* FIXME: in 2.5 consider dropping this and require a - call to devfs_put() */ + de = devfs_get_handle (dir, name, major, minor, type, traverse_symlinks); + devfs_put (de); return de; } /* End Function devfs_find_handle */ @@ -1813,6 +1888,7 @@ unsigned int fl = 0; if (de == NULL) return -EINVAL; + VERIFY_ENTRY (de); if (de->hide) fl |= DEVFS_FL_HIDE; if ( S_ISCHR (de->mode) || S_ISBLK (de->mode) || S_ISREG (de->mode) ) { @@ -1836,11 +1912,8 @@ int devfs_set_flags (devfs_handle_t de, unsigned int flags) { if (de == NULL) return -EINVAL; -#ifdef CONFIG_DEVFS_DEBUG - if (devfs_debug & DEBUG_SET_FLAGS) - printk ("%s: devfs_set_flags(): de->name: \"%s\"\n", - DEVFS_NAME, de->name); -#endif + VERIFY_ENTRY (de); + DPRINTK (DEBUG_SET_FLAGS, "(%s): flags: %x\n", de->name, flags); de->hide = (flags & DEVFS_FL_HIDE) ? TRUE : FALSE; if ( S_ISCHR (de->mode) || S_ISBLK (de->mode) || S_ISREG (de->mode) ) { @@ -1864,6 +1937,7 @@ unsigned int *minor) { if (de == NULL) return -EINVAL; + VERIFY_ENTRY (de); if ( S_ISDIR (de->mode) ) return -EISDIR; if ( !S_ISCHR (de->mode) && !S_ISBLK (de->mode) ) return -EINVAL; if (major != NULL) *major = de->u.fcb.u.device.major; @@ -1904,6 +1978,7 @@ #define NAMEOF(de) ( (de)->mode ? (de)->name : (de)->u.name ) if (de == NULL) return -EINVAL; + VERIFY_ENTRY (de); if (de->namelen >= buflen) return -ENAMETOOLONG; /* Must be first */ path[buflen - 1] = '\0'; if (de->parent == NULL) return buflen - 1; /* Don't prepend root */ @@ -1925,18 +2000,57 @@ * @de: The handle to the device entry. * * Returns a pointer to the device operations on success, else NULL. + * The use count for the module owning the operations will be incremented. */ void *devfs_get_ops (devfs_handle_t de) { + struct module *owner; + if (de == NULL) return NULL; - if ( S_ISCHR (de->mode) || S_ISBLK (de->mode) || S_ISREG (de->mode) ) - return de->u.fcb.ops; - return NULL; + VERIFY_ENTRY (de); + if ( !S_ISCHR (de->mode) && !S_ISBLK (de->mode) && !S_ISREG (de->mode) ) + return NULL; + if (de->u.fcb.ops == NULL) return NULL; + read_lock (&de->parent->u.dir.lock); /* Prevent module from unloading */ + if (de->next == de) owner = NULL; /* Ops pointer is already stale */ + else if ( S_ISCHR (de->mode) || S_ISREG (de->mode) ) + owner = ( (struct file_operations *) de->u.fcb.ops )->owner; + else owner = ( (struct block_device_operations *) de->u.fcb.ops )->owner; + if ( (de->next == de) || !try_inc_mod_count (owner) ) + { /* Entry is already unhooked or module is unloading */ + read_unlock (&de->parent->u.dir.lock); + return NULL; + } + read_unlock (&de->parent->u.dir.lock); /* Module can continue unloading*/ + return de->u.fcb.ops; } /* End Function devfs_get_ops */ /** + * devfs_put_ops - Put the device operations for a devfs entry. + * @de: The handle to the device entry. + * + * The use count for the module owning the operations will be decremented. + */ + +void devfs_put_ops (devfs_handle_t de) +{ + struct module *owner; + + if (de == NULL) return; + VERIFY_ENTRY (de); + if ( !S_ISCHR (de->mode) && !S_ISBLK (de->mode) && !S_ISREG (de->mode) ) + return; + if (de->u.fcb.ops == NULL) return; + if ( S_ISCHR (de->mode) || S_ISREG (de->mode) ) + owner = ( (struct file_operations *) de->u.fcb.ops )->owner; + else owner = ( (struct block_device_operations *) de->u.fcb.ops )->owner; + if (owner) __MOD_DEC_USE_COUNT (owner); +} /* End Function devfs_put_ops */ + + +/** * devfs_set_file_size - Set the file size for a devfs regular file. * @de: The handle to the device entry. * @size: The new file size. @@ -1947,6 +2061,7 @@ int devfs_set_file_size (devfs_handle_t de, unsigned long size) { if (de == NULL) return -EINVAL; + VERIFY_ENTRY (de); if ( !S_ISREG (de->mode) ) return -EINVAL; if (de->u.fcb.u.file.size == size) return 0; de->u.fcb.u.file.size = size; @@ -1966,6 +2081,7 @@ void *devfs_get_info (devfs_handle_t de) { if (de == NULL) return NULL; + VERIFY_ENTRY (de); return de->info; } /* End Function devfs_get_info */ @@ -1980,6 +2096,7 @@ int devfs_set_info (devfs_handle_t de, void *info) { if (de == NULL) return -EINVAL; + VERIFY_ENTRY (de); de->info = info; return 0; } /* End Function devfs_set_info */ @@ -1994,6 +2111,7 @@ devfs_handle_t devfs_get_parent (devfs_handle_t de) { if (de == NULL) return NULL; + VERIFY_ENTRY (de); return de->parent; } /* End Function devfs_get_parent */ @@ -2008,6 +2126,7 @@ devfs_handle_t devfs_get_first_child (devfs_handle_t de) { if (de == NULL) return NULL; + VERIFY_ENTRY (de); if ( !S_ISDIR (de->mode) ) return NULL; return de->u.dir.first; } /* End Function devfs_get_first_child */ @@ -2023,6 +2142,7 @@ devfs_handle_t devfs_get_next_sibling (devfs_handle_t de) { if (de == NULL) return NULL; + VERIFY_ENTRY (de); return de->next; } /* End Function devfs_get_next_sibling */ @@ -2038,14 +2158,15 @@ void devfs_auto_unregister (devfs_handle_t master, devfs_handle_t slave) { if (master == NULL) return; + VERIFY_ENTRY (master); + VERIFY_ENTRY (slave); if (master->slave != NULL) { /* Because of the dumbness of the layers above, ignore duplicates */ if (master->slave == slave) return; - printk ("%s: devfs_auto_unregister(): only one slave allowed\n", - DEVFS_NAME); - OOPS (" master: \"%s\" old slave: \"%s\" new slave: \"%s\"\n", - master->name, master->slave->name, slave->name); + PRINTK ("(%s): only one slave allowed\n", master->name); + OOPS ("(): old slave: \"%s\" new slave: \"%s\"\n", + master->slave->name, slave->name); } master->slave = slave; } /* End Function devfs_auto_unregister */ @@ -2061,6 +2182,7 @@ devfs_handle_t devfs_get_unregister_slave (devfs_handle_t master) { if (master == NULL) return NULL; + VERIFY_ENTRY (master); return master->slave; } /* End Function devfs_get_unregister_slave */ @@ -2076,6 +2198,7 @@ const char *devfs_get_name (devfs_handle_t de, unsigned int *namelen) { if (de == NULL) return NULL; + VERIFY_ENTRY (de); if (namelen != NULL) *namelen = de->namelen; return de->name; } /* End Function devfs_get_name */ @@ -2218,10 +2341,12 @@ __setup("devfs=", devfs_setup); +EXPORT_SYMBOL(devfs_put); EXPORT_SYMBOL(devfs_register); EXPORT_SYMBOL(devfs_unregister); EXPORT_SYMBOL(devfs_mk_symlink); EXPORT_SYMBOL(devfs_mk_dir); +EXPORT_SYMBOL(devfs_get_handle); EXPORT_SYMBOL(devfs_find_handle); EXPORT_SYMBOL(devfs_get_flags); EXPORT_SYMBOL(devfs_set_flags); @@ -2268,8 +2393,9 @@ buf->parent = parent; buf->namelen = namelen; buf->u.name = name; + WRITE_ENTRY_MAGIC (buf, MAGIC_VALUE); if ( !devfsd_notify_de (buf, DEVFSD_NOTIFY_LOOKUP, 0, - current->euid, current->egid, fs_info) ) + current->euid, current->egid, fs_info, 0) ) return -ENOENT; /* Possible success */ return 0; @@ -2286,14 +2412,17 @@ static int check_disc_changed (struct devfs_entry *de) { int tmp; + int retval = 0; kdev_t dev = MKDEV (de->u.fcb.u.device.major, de->u.fcb.u.device.minor); - struct block_device_operations *bdops = de->u.fcb.ops; + struct block_device_operations *bdops; extern int warn_no_part; if ( !S_ISBLK (de->mode) ) return 0; - if (bdops == NULL) return 0; - if (bdops->check_media_change == NULL) return 0; - if ( !bdops->check_media_change (dev) ) return 0; + bdops = devfs_get_ops (de); + if (!bdops) return 0; + if (bdops->check_media_change == NULL) goto out; + if ( !bdops->check_media_change (dev) ) goto out; + retval = 1; printk ( KERN_DEBUG "VFS: Disk change detected on device %s\n", kdevname (dev) ); if (invalidate_device(dev, 0)) @@ -2303,7 +2432,9 @@ warn_no_part = 0; if (bdops->revalidate) bdops->revalidate (dev); warn_no_part = tmp; - return 1; +out: + devfs_put_ops (de); + return retval; } /* End Function check_disc_changed */ @@ -2375,16 +2506,10 @@ if (retval != 0) return retval; retval = inode_setattr (inode, iattr); if (retval != 0) return retval; -#ifdef CONFIG_DEVFS_DEBUG - if (devfs_debug & DEBUG_I_CHANGE) - { - printk ("%s: notify_change(%d): VFS inode: %p devfs_entry: %p\n", - DEVFS_NAME, (int) inode->i_ino, inode, de); - printk ("%s: mode: 0%o uid: %d gid: %d\n", - DEVFS_NAME, (int) inode->i_mode, - (int) inode->i_uid, (int) inode->i_gid); - } -#endif + DPRINTK (DEBUG_I_CHANGE, "(%d): VFS inode: %p devfs_entry: %p\n", + (int) inode->i_ino, inode, de); + DPRINTK (DEBUG_I_CHANGE, "(): mode: 0%o uid: %d gid: %d\n", + (int) inode->i_mode, (int) inode->i_uid, (int) inode->i_gid); /* Inode is not on hash chains, thus must save permissions here rather than in a write_inode() method */ if ( ( !S_ISREG (inode->i_mode) && !S_ISCHR (inode->i_mode) && @@ -2397,16 +2522,17 @@ de->inode.atime = inode->i_atime; de->inode.mtime = inode->i_mtime; de->inode.ctime = inode->i_ctime; - if ( iattr->ia_valid & (ATTR_MODE | ATTR_UID | ATTR_GID) ) + if ( ( iattr->ia_valid & (ATTR_MODE | ATTR_UID | ATTR_GID) ) && + !is_devfsd_or_child (fs_info) ) devfsd_notify_de (de, DEVFSD_NOTIFY_CHANGE, inode->i_mode, - inode->i_uid, inode->i_gid, fs_info); + inode->i_uid, inode->i_gid, fs_info, 0); return 0; } /* End Function devfs_notify_change */ static int devfs_statfs (struct super_block *sb, struct statfs *buf) { buf->f_type = DEVFS_SUPER_MAGIC; - buf->f_bsize = PAGE_SIZE / sizeof (long); + buf->f_bsize = FAKE_BLOCK_SIZE; buf->f_bfree = 0; buf->f_bavail = 0; buf->f_ffree = 0; @@ -2428,7 +2554,7 @@ /** - * get_vfs_inode - Get a VFS inode. + * _devfs_get_vfs_inode - Get a VFS inode. * @sb: The super block. * @de: The devfs inode. * @dentry: The dentry to register with the devfs inode. @@ -2437,9 +2563,9 @@ * performed if the inode is created. */ -static struct inode *get_vfs_inode (struct super_block *sb, - struct devfs_entry *de, - struct dentry *dentry) +static struct inode *_devfs_get_vfs_inode (struct super_block *sb, + struct devfs_entry *de, + struct dentry *dentry) { int is_fcb = FALSE; struct inode *inode; @@ -2447,8 +2573,7 @@ if (de->prev == de) return NULL; /* Quick check to see if unhooked */ if ( ( inode = new_inode (sb) ) == NULL ) { - printk ("%s: get_vfs_inode(%s): new_inode() failed, de: %p\n", - DEVFS_NAME, de->name, de); + PRINTK ("(%s): new_inode() failed, de: %p\n", de->name, de); return NULL; } if (de->parent) @@ -2465,13 +2590,10 @@ } inode->u.generic_ip = devfs_get (de); inode->i_ino = de->inode.ino; -#ifdef CONFIG_DEVFS_DEBUG - if (devfs_debug & DEBUG_I_GET) - printk ("%s: get_vfs_inode(%d): VFS inode: %p devfs_entry: %p\n", - DEVFS_NAME, (int) inode->i_ino, inode, de); -#endif + DPRINTK (DEBUG_I_GET, "(%d): VFS inode: %p devfs_entry: %p\n", + (int) inode->i_ino, inode, de); inode->i_blocks = 0; - inode->i_blksize = 1024; + inode->i_blksize = FAKE_BLOCK_SIZE; inode->i_op = &devfs_iops; inode->i_fop = &devfs_fops; inode->i_rdev = NODEV; @@ -2491,8 +2613,7 @@ if (!inode->i_bdev->bd_op && de->u.fcb.ops) inode->i_bdev->bd_op = de->u.fcb.ops; } - else printk ("%s: get_vfs_inode(%d): no block device from bdget()\n", - DEVFS_NAME, (int) inode->i_ino); + else PRINTK ("(%d): no block device from bdget()\n",(int)inode->i_ino); is_fcb = TRUE; } else if ( S_ISFIFO (de->mode) ) inode->i_fop = &def_fifo_fops; @@ -2519,14 +2640,10 @@ inode->i_atime = de->inode.atime; inode->i_mtime = de->inode.mtime; inode->i_ctime = de->inode.ctime; -#ifdef CONFIG_DEVFS_DEBUG - if (devfs_debug & DEBUG_I_GET) - printk ("%s: mode: 0%o uid: %d gid: %d\n", - DEVFS_NAME, (int) inode->i_mode, - (int) inode->i_uid, (int) inode->i_gid); -#endif + DPRINTK (DEBUG_I_GET, "(): mode: 0%o uid: %d gid: %d\n", + (int) inode->i_mode, (int) inode->i_uid, (int) inode->i_gid); return inode; -} /* End Function get_vfs_inode */ +} /* End Function _devfs_get_vfs_inode */ /* File operations for device entries follow */ @@ -2542,11 +2659,8 @@ fs_info = inode->i_sb->u.generic_sbp; parent = get_devfs_entry_from_vfs_inode (file->f_dentry->d_inode); if ( (long) file->f_pos < 0 ) return -EINVAL; -#ifdef CONFIG_DEVFS_DEBUG - if (devfs_debug & DEBUG_F_READDIR) - printk ("%s: readdir(): fs_info: %p pos: %ld\n", DEVFS_NAME, - fs_info, (long) file->f_pos); -#endif + DPRINTK (DEBUG_F_READDIR, "(%s): fs_info: %p pos: %ld\n", + parent->name, fs_info, (long) file->f_pos); switch ( (long) file->f_pos ) { case 0: @@ -2637,9 +2751,9 @@ inode->i_uid = current->euid; inode->i_gid = current->egid; } - if (df->aopen_notify) + if ( df->aopen_notify && !is_devfsd_or_child (fs_info) ) devfsd_notify_de (de, DEVFSD_NOTIFY_ASYNC_OPEN, inode->i_mode, - current->euid, current->egid, fs_info); + current->euid, current->egid, fs_info, 0); return 0; } /* End Function devfs_open */ @@ -2666,13 +2780,7 @@ static void devfs_d_release (struct dentry *dentry) { -#ifdef CONFIG_DEVFS_DEBUG - struct inode *inode = dentry->d_inode; - - if (devfs_debug & DEBUG_D_RELEASE) - printk ("%s: d_release(): dentry: %p inode: %p\n", - DEVFS_NAME, dentry, inode); -#endif + DPRINTK (DEBUG_D_RELEASE, "(%p): inode: %p\n", dentry, dentry->d_inode); } /* End Function devfs_d_release */ /** @@ -2686,14 +2794,11 @@ struct devfs_entry *de; de = get_devfs_entry_from_vfs_inode (inode); -#ifdef CONFIG_DEVFS_DEBUG - if (devfs_debug & DEBUG_D_IPUT) - printk ("%s: d_iput(): dentry: %p inode: %p de: %p de->dentry: %p\n", - DEVFS_NAME, dentry, inode, de, de->inode.dentry); -#endif + DPRINTK (DEBUG_D_IPUT,"(%s): dentry: %p inode: %p de: %p de->dentry: %p\n", + de->name, dentry, inode, de, de->inode.dentry); if ( de->inode.dentry && (de->inode.dentry != dentry) ) - OOPS ("%s: d_iput(%s): de: %p dentry: %p de->dentry: %p\n", - DEVFS_NAME, de->name, de, dentry, de->inode.dentry); + OOPS ("(%s): de: %p dentry: %p de->dentry: %p\n", + de->name, de, dentry, de->inode.dentry); de->inode.dentry = NULL; iput (inode); devfs_put (de); @@ -2733,20 +2838,13 @@ /* Unhash dentry if negative (has no inode) */ if (inode == NULL) { -#ifdef CONFIG_DEVFS_DEBUG - if (devfs_debug & DEBUG_D_DELETE) - printk ("%s: d_delete(): dropping negative dentry: %p\n", - DEVFS_NAME, dentry); -#endif + DPRINTK (DEBUG_D_DELETE, "(%p): dropping negative dentry\n", dentry); return 1; } fs_info = inode->i_sb->u.generic_sbp; de = get_devfs_entry_from_vfs_inode (inode); -#ifdef CONFIG_DEVFS_DEBUG - if (devfs_debug & DEBUG_D_DELETE) - printk ("%s: d_delete(): dentry: %p inode: %p devfs_entry: %p\n", - DEVFS_NAME, dentry, inode, de); -#endif + DPRINTK (DEBUG_D_DELETE, "(%p): inode: %p devfs_entry: %p\n", + dentry, inode, de); if (de == NULL) return 0; if ( !S_ISCHR (de->mode) && !S_ISBLK (de->mode) && !S_ISREG (de->mode) ) return 0; @@ -2754,7 +2852,7 @@ de->u.fcb.open = FALSE; if (de->u.fcb.aopen_notify) devfsd_notify_de (de, DEVFSD_NOTIFY_CLOSE, inode->i_mode, - current->euid, current->egid, fs_info); + current->euid, current->egid, fs_info, 1); if (!de->u.fcb.auto_owner) return 0; /* Change the ownership/protection back */ inode->i_mode = (de->mode & S_IFMT) | S_IRUGO | S_IWUGO; @@ -2774,25 +2872,19 @@ devfs_handle_t parent = get_devfs_entry_from_vfs_inode (dir); struct inode *inode; -#ifdef CONFIG_DEVFS_DEBUG - if (devfs_debug & DEBUG_I_LOOKUP) - printk ("%s: d_revalidate(%s): dentry: %p by: \"%s\"\n", - DEVFS_NAME, dentry->d_name.name, dentry, current->comm); -#endif + DPRINTK (DEBUG_I_LOOKUP, "(%s): dentry: %p by: \"%s\"\n", + dentry->d_name.name, dentry, current->comm); read_lock (&parent->u.dir.lock); de = _devfs_search_dir (parent, dentry->d_name.name, dentry->d_name.len); - read_lock (&parent->u.dir.lock); + read_unlock (&parent->u.dir.lock); if (de == NULL) return 1; /* Create an inode, now that the driver information is available */ - inode = get_vfs_inode (dir->i_sb, de, dentry); + inode = _devfs_get_vfs_inode (dir->i_sb, de, dentry); devfs_put (de); if (!inode) return 1; -#ifdef CONFIG_DEVFS_DEBUG - if (devfs_debug & DEBUG_I_LOOKUP) - printk ("%s: d_revalidate(): new VFS inode(%u): %p devfs_entry: %p\n", - DEVFS_NAME, de->inode.ino, inode, de); -#endif + DPRINTK (DEBUG_I_LOOKUP, "(%s): new VFS inode(%u): %p de: %p\n", + de->name, de->inode.ino, inode, de); d_instantiate (dentry, inode); return 1; } @@ -2805,21 +2897,17 @@ static struct dentry *devfs_lookup (struct inode *dir, struct dentry *dentry) { - struct fs_info *fs_info; + struct fs_info *fs_info = dir->i_sb->u.generic_sbp; struct devfs_entry *parent, *de; struct inode *inode; /* Set up the dentry operations before anything else, to ensure cleaning up on any error */ dentry->d_op = &devfs_dops; - fs_info = dir->i_sb->u.generic_sbp; /* First try to get the devfs entry for this directory */ parent = get_devfs_entry_from_vfs_inode (dir); -#ifdef CONFIG_DEVFS_DEBUG - if (devfs_debug & DEBUG_I_LOOKUP) - printk ("%s: lookup(%s): dentry: %p parent: %p by: \"%s\"\n", - DEVFS_NAME, dentry->d_name.name, dentry, parent,current->comm); -#endif + DPRINTK (DEBUG_I_LOOKUP, "(%s): dentry: %p parent: %p by: \"%s\"\n", + dentry->d_name.name, dentry, parent, current->comm); if (parent == NULL) return ERR_PTR (-ENOENT); read_lock (&parent->u.dir.lock); de = _devfs_search_dir (parent, dentry->d_name.name, dentry->d_name.len); @@ -2872,14 +2960,11 @@ d_add (dentry, NULL); /* Open the floodgates */ } /* Create an inode, now that the driver information is available */ - inode = get_vfs_inode (dir->i_sb, de, dentry); + inode = _devfs_get_vfs_inode (dir->i_sb, de, dentry); devfs_put (de); if (!inode) return ERR_PTR (-ENOMEM); -#ifdef CONFIG_DEVFS_DEBUG - if (devfs_debug & DEBUG_I_LOOKUP) - printk ("%s: lookup(): new VFS inode(%u): %p devfs_entry: %p\n", - DEVFS_NAME, de->inode.ino, inode, de); -#endif + DPRINTK (DEBUG_I_LOOKUP, "(%s): new VFS inode(%u): %p de: %p\n", + de->name, de->inode.ino, inode, de); d_instantiate (dentry, inode); if (dentry->d_op == &devfs_wait_dops) { /* Unlock directory semaphore, which will release any waiters. They @@ -2897,20 +2982,19 @@ int unhooked; struct devfs_entry *de; struct inode *inode = dentry->d_inode; + struct fs_info *fs_info = dir->i_sb->u.generic_sbp; -#ifdef CONFIG_DEVFS_DEBUG - if (devfs_debug & DEBUG_I_UNLINK) - printk ("%s: unlink(%s)\n", DEVFS_NAME, dentry->d_name.name); -#endif de = get_devfs_entry_from_vfs_inode (inode); + DPRINTK (DEBUG_I_UNLINK, "(%s): de: %p\n", dentry->d_name.name, de); if (de == NULL) return -ENOENT; if (!de->vfs_created) return -EPERM; write_lock (&de->parent->u.dir.lock); unhooked = _devfs_unhook (de); write_unlock (&de->parent->u.dir.lock); if (!unhooked) return -ENOENT; - devfsd_notify_de (de, DEVFSD_NOTIFY_DELETE, inode->i_mode, - inode->i_uid, inode->i_gid, dir->i_sb->u.generic_sbp); + if ( !is_devfsd_or_child (fs_info) ) + devfsd_notify_de (de, DEVFSD_NOTIFY_DELETE, inode->i_mode, + inode->i_uid, inode->i_gid, fs_info, 0); free_dentry (de); devfs_put (de); return 0; @@ -2920,21 +3004,17 @@ const char *symname) { int err; - struct fs_info *fs_info; + struct fs_info *fs_info = dir->i_sb->u.generic_sbp; struct devfs_entry *parent, *de; struct inode *inode; - fs_info = dir->i_sb->u.generic_sbp; /* First try to get the devfs entry for this directory */ parent = get_devfs_entry_from_vfs_inode (dir); if (parent == NULL) return -ENOENT; err = devfs_do_symlink (parent, dentry->d_name.name, DEVFS_FL_NONE, symname, &de, NULL); -#ifdef CONFIG_DEVFS_DEBUG - if (devfs_debug & DEBUG_DISABLED) - printk ("%s: symlink(): errcode from <devfs_do_symlink>: %d\n", - DEVFS_NAME, err); -#endif + DPRINTK (DEBUG_DISABLED, "(%s): errcode from <devfs_do_symlink>: %d\n", + dentry->d_name.name, err); if (err < 0) return err; de->vfs_created = TRUE; de->inode.uid = current->euid; @@ -2942,28 +3022,25 @@ de->inode.atime = CURRENT_TIME; de->inode.mtime = CURRENT_TIME; de->inode.ctime = CURRENT_TIME; - if ( ( inode = get_vfs_inode (dir->i_sb, de, dentry) ) == NULL ) + if ( ( inode = _devfs_get_vfs_inode (dir->i_sb, de, dentry) ) == NULL ) return -ENOMEM; -#ifdef CONFIG_DEVFS_DEBUG - if (devfs_debug & DEBUG_DISABLED) - printk ("%s: symlink(): new VFS inode(%u): %p dentry: %p\n", - DEVFS_NAME, de->inode.ino, inode, dentry); -#endif + DPRINTK (DEBUG_DISABLED, "(%s): new VFS inode(%u): %p dentry: %p\n", + dentry->d_name.name, de->inode.ino, inode, dentry); d_instantiate (dentry, inode); - devfsd_notify_de (de, DEVFSD_NOTIFY_CREATE, inode->i_mode, - inode->i_uid, inode->i_gid, fs_info); + if ( !is_devfsd_or_child (fs_info) ) + devfsd_notify_de (de, DEVFSD_NOTIFY_CREATE, inode->i_mode, + inode->i_uid, inode->i_gid, fs_info, 0); return 0; } /* End Function devfs_symlink */ static int devfs_mkdir (struct inode *dir, struct dentry *dentry, int mode) { int err; - struct fs_info *fs_info; + struct fs_info *fs_info = dir->i_sb->u.generic_sbp; struct devfs_entry *parent, *de; struct inode *inode; mode = (mode & ~S_IFMT) | S_IFDIR; /* VFS doesn't pass S_IFMT part */ - fs_info = dir->i_sb->u.generic_sbp; parent = get_devfs_entry_from_vfs_inode (dir); if (parent == NULL) return -ENOENT; de = _devfs_alloc_entry (dentry->d_name.name, dentry->d_name.len, mode); @@ -2976,16 +3053,14 @@ de->inode.atime = CURRENT_TIME; de->inode.mtime = CURRENT_TIME; de->inode.ctime = CURRENT_TIME; - if ( ( inode = get_vfs_inode (dir->i_sb, de, dentry) ) == NULL ) + if ( ( inode = _devfs_get_vfs_inode (dir->i_sb, de, dentry) ) == NULL ) return -ENOMEM; -#ifdef CONFIG_DEVFS_DEBUG - if (devfs_debug & DEBUG_DISABLED) - printk ("%s: mkdir(): new VFS inode(%u): %p dentry: %p\n", - DEVFS_NAME, de->inode.ino, inode, dentry); -#endif + DPRINTK (DEBUG_DISABLED, "(%s): new VFS inode(%u): %p dentry: %p\n", + dentry->d_name.name, de->inode.ino, inode, dentry); d_instantiate (dentry, inode); - devfsd_notify_de (de, DEVFSD_NOTIFY_CREATE, inode->i_mode, - inode->i_uid, inode->i_gid, fs_info); + if ( !is_devfsd_or_child (fs_info) ) + devfsd_notify_de (de, DEVFSD_NOTIFY_CREATE, inode->i_mode, + inode->i_uid, inode->i_gid, fs_info, 0); return 0; } /* End Function devfs_mkdir */ @@ -2993,11 +3068,10 @@ { int err = 0; struct devfs_entry *de; - struct fs_info *fs_info; + struct fs_info *fs_info = dir->i_sb->u.generic_sbp; struct inode *inode = dentry->d_inode; if (dir->i_sb->u.generic_sbp != inode->i_sb->u.generic_sbp) return -EINVAL; - fs_info = dir->i_sb->u.generic_sbp; de = get_devfs_entry_from_vfs_inode (inode); if (de == NULL) return -ENOENT; if ( !S_ISDIR (de->mode) ) return -ENOTDIR; @@ -3013,8 +3087,9 @@ if ( !_devfs_unhook (de) ) err = -ENOENT; write_unlock (&de->parent->u.dir.lock); if (err) return err; - devfsd_notify_de (de, DEVFSD_NOTIFY_DELETE, inode->i_mode, - inode->i_uid, inode->i_gid, fs_info); + if ( !is_devfsd_or_child (fs_info) ) + devfsd_notify_de (de, DEVFSD_NOTIFY_DELETE, inode->i_mode, + inode->i_uid, inode->i_gid, fs_info, 0); free_dentry (de); devfs_put (de); return 0; @@ -3024,16 +3099,12 @@ int rdev) { int err; - struct fs_info *fs_info; + struct fs_info *fs_info = dir->i_sb->u.generic_sbp; struct devfs_entry *parent, *de; struct inode *inode; -#ifdef CONFIG_DEVFS_DEBUG - if (devfs_debug & DEBUG_I_MKNOD) - printk ("%s: mknod(%s): mode: 0%o dev: %d\n", - DEVFS_NAME, dentry->d_name.name, mode, rdev); -#endif - fs_info = dir->i_sb->u.generic_sbp; + DPRINTK (DEBUG_I_MKNOD, "(%s): mode: 0%o dev: %d\n", + dentry->d_name.name, mode, rdev); parent = get_devfs_entry_from_vfs_inode (dir); if (parent == NULL) return -ENOENT; de = _devfs_alloc_entry (dentry->d_name.name, dentry->d_name.len, mode); @@ -3051,16 +3122,14 @@ de->inode.atime = CURRENT_TIME; de->inode.mtime = CURRENT_TIME; de->inode.ctime = CURRENT_TIME; - if ( ( inode = get_vfs_inode (dir->i_sb, de, dentry) ) == NULL ) + if ( ( inode = _devfs_get_vfs_inode (dir->i_sb, de, dentry) ) == NULL ) return -ENOMEM; -#ifdef CONFIG_DEVFS_DEBUG - if (devfs_debug & DEBUG_I_MKNOD) - printk ("%s: new VFS inode(%u): %p dentry: %p\n", - DEVFS_NAME, de->inode.ino, inode, dentry); -#endif + DPRINTK (DEBUG_I_MKNOD, ": new VFS inode(%u): %p dentry: %p\n", + de->inode.ino, inode, dentry); d_instantiate (dentry, inode); - devfsd_notify_de (de, DEVFSD_NOTIFY_CREATE, inode->i_mode, - inode->i_uid, inode->i_gid, fs_info); + if ( !is_devfsd_or_child (fs_info) ) + devfsd_notify_de (de, DEVFSD_NOTIFY_CREATE, inode->i_mode, + inode->i_uid, inode->i_gid, fs_info, 0); return 0; } /* End Function devfs_mknod */ @@ -3124,15 +3193,11 @@ sb->s_blocksize_bits = 10; sb->s_magic = DEVFS_SUPER_MAGIC; sb->s_op = &devfs_sops; - if ( ( root_inode = get_vfs_inode (sb, root_entry, NULL) ) == NULL ) + if ( ( root_inode = _devfs_get_vfs_inode (sb, root_entry, NULL) ) == NULL ) goto out_no_root; sb->s_root = d_alloc_root (root_inode); if (!sb->s_root) goto out_no_root; -#ifdef CONFIG_DEVFS_DEBUG - if (devfs_debug & DEBUG_S_READ) - printk ("%s: read super, made devfs ptr: %p\n", - DEVFS_NAME, sb->u.generic_sbp); -#endif + DPRINTK (DEBUG_S_READ, "(): made devfs ptr: %p\n", sb->u.generic_sbp); return sb; out_no_root: @@ -3233,11 +3298,17 @@ tlen = rpos - *ppos; if (done) { + devfs_handle_t parent; + spin_lock (&fs_info->devfsd_buffer_lock); fs_info->devfsd_first_event = entry->next; if (entry->next == NULL) fs_info->devfsd_last_event = NULL; spin_unlock (&fs_info->devfsd_buffer_lock); - for (; de != NULL; de = de->parent) devfs_put (de); + for (; de != NULL; de = parent) + { + parent = de->parent; + devfs_put (de); + } kmem_cache_free (devfsd_buf_cache, entry); if (ival > 0) atomic_sub (ival, &fs_info->devfsd_overrun_count); *ppos = 0; @@ -3274,6 +3345,8 @@ } fs_info->devfsd_task = current; spin_unlock (&lock); + fs_info->devfsd_pgrp = (current->pgrp == current->pid) ? + current->pgrp : 0; fs_info->devfsd_file = file; fs_info->devfsd_info = kmalloc (sizeof *fs_info->devfsd_info, GFP_KERNEL); @@ -3304,7 +3377,7 @@ static int devfsd_close (struct inode *inode, struct file *file) { - struct devfsd_buf_entry *entry; + struct devfsd_buf_entry *entry, *next; struct fs_info *fs_info = inode->i_sb->u.generic_sbp; if (fs_info->devfsd_file != file) return 0; @@ -3320,10 +3393,14 @@ fs_info->devfsd_info = NULL; } spin_unlock (&fs_info->devfsd_buffer_lock); + fs_info->devfsd_pgrp = 0; fs_info->devfsd_task = NULL; wake_up (&fs_info->revalidate_wait_queue); - for (; entry; entry = entry->next) + for (; entry; entry = next) + { + next = entry->next; kmem_cache_free (devfsd_buf_cache, entry); + } return 0; } /* End Function devfsd_close */ @@ -3353,14 +3430,15 @@ printk ("%s: v%s Richard Gooch (rgooch@atnf.csiro.au)\n", DEVFS_NAME, DEVFS_VERSION); + devfsd_buf_cache = kmem_cache_create ("devfsd_event", + sizeof (struct devfsd_buf_entry), + 0, 0, NULL, NULL); + if (!devfsd_buf_cache) OOPS ("(): unable to allocate event slab\n"); #ifdef CONFIG_DEVFS_DEBUG devfs_debug = devfs_debug_init; printk ("%s: devfs_debug: 0x%0x\n", DEVFS_NAME, devfs_debug); #endif printk ("%s: boot_options: 0x%0x\n", DEVFS_NAME, boot_options); - devfsd_buf_cache = kmem_cache_create ("devfsd_event", - sizeof (struct devfsd_buf_entry), - 0, 0, NULL, NULL); err = register_filesystem (&devfs_fs_type); if (!err) { diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/fs/devfs/util.c linux-2.5/fs/devfs/util.c --- linux-2.5.1/fs/devfs/util.c Thu Oct 11 16:43:30 2001 +++ linux-2.5/fs/devfs/util.c Thu Dec 27 21:40:50 2001 @@ -61,67 +61,6 @@ /* Private functions follow */ /** - * _devfs_convert_name - Convert from an old style location-based name to new style. - * @new: The new name will be written here. - * @old: The old name. - * @disc: If true, disc partitioning information should be processed. - */ - -static void __init _devfs_convert_name (char *new, const char *old, int disc) -{ - int host, bus, target, lun; - char *ptr; - char part[8]; - - /* Decode "c#b#t#u#" */ - if (old[0] != 'c') return; - host = simple_strtol (old + 1, &ptr, 10); - if (ptr[0] != 'b') return; - bus = simple_strtol (ptr + 1, &ptr, 10); - if (ptr[0] != 't') return; - target = simple_strtol (ptr + 1, &ptr, 10); - if (ptr[0] != 'u') return; - lun = simple_strtol (ptr + 1, &ptr, 10); - if (disc) - { - /* Decode "p#" */ - if (ptr[0] == 'p') sprintf (part, "part%s", ptr + 1); - else strcpy (part, "disc"); - } - else part[0] = '\0'; - sprintf (new, "/host%d/bus%d/target%d/lun%d/%s", - host, bus, target, lun, part); -} /* End Function _devfs_convert_name */ - - -/* Public functions follow */ - -/** - * devfs_make_root - Create the root FS device entry if required. - * @name: The name of the root FS device, as passed by "root=". - */ - -void __init devfs_make_root (const char *name) -{ - char dest[64]; - - if ( (strncmp (name, "sd/", 3) == 0) || (strncmp (name, "sr/", 3) == 0) ) - { - strcpy (dest, "../scsi"); - _devfs_convert_name (dest + 7, name + 3, (name[1] == 'd') ? 1 : 0); - } - else if ( (strncmp (name, "ide/hd/", 7) == 0) || - (strncmp (name, "ide/cd/", 7) == 0) ) - { - strcpy (dest, ".."); - _devfs_convert_name (dest + 2, name + 7, (name[4] == 'h') ? 1 : 0); - } - else return; - devfs_mk_symlink (NULL, name, DEVFS_FL_DEFAULT, dest, NULL, NULL); -} /* End Function devfs_make_root */ - - -/** * devfs_register_tape - Register a tape device in the "/dev/tapes" hierarchy. * @de: Any tape device entry in the device directory. */ diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/fs/devpts/root.c linux-2.5/fs/devpts/root.c --- linux-2.5.1/fs/devpts/root.c Fri Aug 11 21:29:02 2000 +++ linux-2.5/fs/devpts/root.c Thu Dec 13 16:32:36 2001 @@ -101,7 +101,6 @@ int i; const char *p; - dentry->d_inode = NULL; /* Assume failure */ dentry->d_op = &devpts_dentry_operations; if ( dentry->d_name.len == 1 && dentry->d_name.name[0] == '0' ) { @@ -127,11 +126,10 @@ if ( entry >= sbi->max_ptys ) return NULL; - dentry->d_inode = sbi->inodes[entry]; - if ( dentry->d_inode ) - atomic_inc(&dentry->d_inode->i_count); + if ( sbi->inodes[entry] ) + atomic_inc(&sbi->inodes[entry]->i_count); - d_add(dentry, dentry->d_inode); + d_add(dentry, sbi->inodes[entry]); return NULL; } diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/fs/dquot.c linux-2.5/fs/dquot.c --- linux-2.5.1/fs/dquot.c Mon Dec 10 22:13:25 2001 +++ linux-2.5/fs/dquot.c Thu Dec 27 22:10:28 2001 @@ -136,14 +136,14 @@ return is_enabled(sb_dqopt(sb), type); } -static inline int const hashfn(kdev_t dev, unsigned int id, short type) +static inline int const hashfn(struct super_block *sb, unsigned int id, short type) { - return((HASHDEV(dev) ^ id) * (MAXQUOTAS - type)) % NR_DQHASH; + return((HASHDEV(sb->s_dev) ^ id) * (MAXQUOTAS - type)) % NR_DQHASH; } static inline void insert_dquot_hash(struct dquot *dquot) { - struct list_head *head = dquot_hash + hashfn(dquot->dq_dev, dquot->dq_id, dquot->dq_type); + struct list_head *head = dquot_hash + hashfn(dquot->dq_sb, dquot->dq_id, dquot->dq_type); list_add(&dquot->dq_hash, head); } @@ -153,14 +153,14 @@ INIT_LIST_HEAD(&dquot->dq_hash); } -static inline struct dquot *find_dquot(unsigned int hashent, kdev_t dev, unsigned int id, short type) +static inline struct dquot *find_dquot(unsigned int hashent, struct super_block *sb, unsigned int id, short type) { struct list_head *head; struct dquot *dquot; for (head = dquot_hash[hashent].next; head != dquot_hash+hashent; head = head->next) { dquot = list_entry(head, struct dquot, dq_hash); - if (dquot->dq_dev == dev && dquot->dq_id == id && dquot->dq_type == type) + if (dquot->dq_sb == sb && dquot->dq_id == id && dquot->dq_type == type) return dquot; } return NODQUOT; @@ -289,7 +289,7 @@ sizeof(struct dqblk), &offset); if (ret != sizeof(struct dqblk)) printk(KERN_WARNING "VFS: dquota write failed on dev %s\n", - kdevname(dquot->dq_dev)); + kdevname(dquot->dq_sb->s_dev)); set_fs(fs); up(sem); @@ -359,7 +359,7 @@ } } -int sync_dquots(kdev_t dev, short type) +int sync_dquots(struct super_block *sb, short type) { struct list_head *head; struct dquot *dquot; @@ -368,7 +368,7 @@ restart: for (head = inuse_list.next; head != &inuse_list; head = head->next) { dquot = list_entry(head, struct dquot, dq_inuse); - if (dev && dquot->dq_dev != dev) + if (sb && dquot->dq_sb != sb) continue; if (type != -1 && dquot->dq_type != type) continue; @@ -440,7 +440,8 @@ if (!dquot->dq_count) { printk("VFS: dqput: trying to free free dquot\n"); printk("VFS: device %s, dquot of %s %d\n", - kdevname(dquot->dq_dev), quotatypes[dquot->dq_type], + kdevname(dquot->dq_sb->s_dev), + quotatypes[dquot->dq_type], dquot->dq_id); return; } @@ -493,7 +494,7 @@ static struct dquot *dqget(struct super_block *sb, unsigned int id, short type) { - unsigned int hashent = hashfn(sb->s_dev, id, type); + unsigned int hashent = hashfn(sb, id, type); struct dquot *dquot, *empty = NODQUOT; struct quota_mount_options *dqopt = sb_dqopt(sb); @@ -504,7 +505,7 @@ return NODQUOT; } - if ((dquot = find_dquot(hashent, sb->s_dev, id, type)) == NODQUOT) { + if ((dquot = find_dquot(hashent, sb, id, type)) == NODQUOT) { if (empty == NODQUOT) { if ((empty = get_empty_dquot()) == NODQUOT) schedule(); /* Try to wait for a moment... */ @@ -513,7 +514,6 @@ dquot = empty; dquot->dq_id = id; dquot->dq_type = type; - dquot->dq_dev = sb->s_dev; dquot->dq_sb = sb; /* hash it first so it can be found */ insert_dquot_hash(dquot); @@ -1471,7 +1471,7 @@ flags |= SET_QLIMIT; break; case Q_SYNC: - ret = sync_dquots(dev, type); + ret = sync_dquots(sb, type); goto out; case Q_GETSTATS: ret = get_stats(addr); diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/fs/efs/file.c linux-2.5/fs/efs/file.c --- linux-2.5.1/fs/efs/file.c Sun Dec 16 20:22:56 2001 +++ linux-2.5/fs/efs/file.c Thu Dec 27 22:10:28 2001 @@ -29,11 +29,8 @@ return 0; } phys = efs_map_block(inode, iblock); - if (phys) { - bh_result->b_dev = inode->i_dev; - bh_result->b_blocknr = phys; - bh_result->b_state |= (1UL << BH_Mapped); - } + if (phys) + map_bh(bh_result, inode->i_sb, phys); return 0; } diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/fs/efs/super.c linux-2.5/fs/efs/super.c --- linux-2.5.1/fs/efs/super.c Sun Dec 16 20:23:00 2001 +++ linux-2.5/fs/efs/super.c Thu Dec 27 15:56:12 2001 @@ -132,16 +132,13 @@ } struct super_block *efs_read_super(struct super_block *s, void *d, int silent) { - kdev_t dev = s->s_dev; struct efs_sb_info *sb; struct buffer_head *bh; sb = SUPER_INFO(s); s->s_magic = EFS_SUPER_MAGIC; - s->s_blocksize = EFS_BLOCKSIZE; - s->s_blocksize_bits = EFS_BLOCKSIZE_BITS; - set_blocksize(dev, EFS_BLOCKSIZE); + sb_set_blocksize(s, EFS_BLOCKSIZE); /* read the vh (volume header) block */ bh = sb_bread(s, 0); diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/fs/exec.c linux-2.5/fs/exec.c --- linux-2.5.1/fs/exec.c Wed Nov 28 17:30:47 2001 +++ linux-2.5/fs/exec.c Fri Dec 28 00:08:54 2001 @@ -973,9 +973,7 @@ if (do_truncate(file->f_dentry, 0) != 0) goto close_fail; - down_read(¤t->mm->mmap_sem); retval = binfmt->core_dump(signr, regs, file); - up_read(¤t->mm->mmap_sem); close_fail: filp_close(file, NULL); diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/fs/ext2/ialloc.c linux-2.5/fs/ext2/ialloc.c --- linux-2.5.1/fs/ext2/ialloc.c Sun Dec 16 20:23:00 2001 +++ linux-2.5/fs/ext2/ialloc.c Fri Dec 28 00:06:33 2001 @@ -393,7 +393,7 @@ if (inode->u.ext2_i.i_flags & EXT2_SYNC_FL) inode->i_flags |= S_SYNC; insert_inode_hash(inode); - inode->i_generation = event++; + inode->i_generation = sb->u.ext2_sb.s_next_generation++; mark_inode_dirty(inode); unlock_super (sb); diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/fs/ext2/inode.c linux-2.5/fs/ext2/inode.c --- linux-2.5.1/fs/ext2/inode.c Sun Dec 16 20:23:00 2001 +++ linux-2.5/fs/ext2/inode.c Thu Dec 27 22:10:28 2001 @@ -524,9 +524,7 @@ /* Simplest case - block found, no allocation needed */ if (!partial) { got_it: - bh_result->b_dev = inode->i_dev; - bh_result->b_blocknr = le32_to_cpu(chain[depth-1].key); - bh_result->b_state |= (1UL << BH_Mapped); + map_bh(bh_result, inode->i_sb, le32_to_cpu(chain[depth-1].key)); /* Clean up and exit */ partial = chain+depth-1; /* the whole chain */ goto cleanup; diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/fs/ext2/super.c linux-2.5/fs/ext2/super.c --- linux-2.5.1/fs/ext2/super.c Sun Dec 16 20:23:00 2001 +++ linux-2.5/fs/ext2/super.c Fri Dec 28 00:06:33 2001 @@ -25,9 +25,12 @@ #include <linux/init.h> #include <linux/locks.h> #include <linux/blkdev.h> +#include <linux/random.h> #include <asm/uaccess.h> +static void ext2_sync_super(struct super_block *sb, + struct ext2_super_block *es); static char error_buf[1024]; @@ -35,13 +38,13 @@ const char * fmt, ...) { va_list args; + struct ext2_super_block *es = EXT2_SB(sb)->s_es; if (!(sb->s_flags & MS_RDONLY)) { sb->u.ext2_sb.s_mount_state |= EXT2_ERROR_FS; - sb->u.ext2_sb.s_es->s_state = - cpu_to_le16(le16_to_cpu(sb->u.ext2_sb.s_es->s_state) | EXT2_ERROR_FS); - mark_buffer_dirty(sb->u.ext2_sb.s_sbh); - sb->s_dirt = 1; + es->s_state = + cpu_to_le16(le16_to_cpu(es->s_state) | EXT2_ERROR_FS); + ext2_sync_super(sb, es); } va_start (args, fmt); vsprintf (error_buf, fmt, args); @@ -124,8 +127,10 @@ int i; if (!(sb->s_flags & MS_RDONLY)) { - sb->u.ext2_sb.s_es->s_state = le16_to_cpu(sb->u.ext2_sb.s_mount_state); - mark_buffer_dirty(sb->u.ext2_sb.s_sbh); + struct ext2_super_block *es = EXT2_SB(sb)->s_es; + + es->s_state = le16_to_cpu(EXT2_SB(sb)->s_mount_state); + ext2_sync_super(sb, es); } db_count = EXT2_SB(sb)->s_gdb_count; for (i = 0; i < db_count; i++) @@ -305,13 +310,10 @@ (le32_to_cpu(es->s_lastcheck) + le32_to_cpu(es->s_checkinterval) <= CURRENT_TIME)) printk ("EXT2-fs warning: checktime reached, " "running e2fsck is recommended\n"); - es->s_state = cpu_to_le16(le16_to_cpu(es->s_state) & ~EXT2_VALID_FS); if (!(__s16) le16_to_cpu(es->s_max_mnt_count)) es->s_max_mnt_count = (__s16) cpu_to_le16(EXT2_DFL_MAX_MNT_COUNT); es->s_mnt_count=cpu_to_le16(le16_to_cpu(es->s_mnt_count) + 1); - es->s_mtime = cpu_to_le32(CURRENT_TIME); - mark_buffer_dirty(sb->u.ext2_sb.s_sbh); - sb->s_dirt = 1; + ext2_write_super(sb); if (test_opt (sb, DEBUG)) printk ("[EXT II FS %s, %s, bs=%lu, fs=%lu, gc=%lu, " "bpg=%lu, ipg=%lu, mo=%04lx]\n", @@ -418,9 +420,6 @@ * This is important for devices that have a hardware * sectorsize that is larger than the default. */ - blocksize = get_hardsect_size(dev); - if(blocksize < BLOCK_SIZE ) - blocksize = BLOCK_SIZE; sb->u.ext2_sb.s_mount_opt = 0; if (!parse_options ((char *) data, &sb_block, &resuid, &resgid, @@ -428,11 +427,11 @@ return NULL; } - if (set_blocksize(dev, blocksize) < 0) { - printk ("EXT2-fs: unable to set blocksize %d\n", blocksize); + blocksize = sb_min_blocksize(sb, BLOCK_SIZE); + if (!blocksize) { + printk ("EXT2-fs: unable to set blocksize\n"); return NULL; } - sb->s_blocksize = blocksize; /* * If the superblock doesn't start on a sector boundary, @@ -485,18 +484,12 @@ bdevname(dev), i); goto failed_mount; } - sb->s_blocksize_bits = - le32_to_cpu(EXT2_SB(sb)->s_es->s_log_block_size) + 10; - sb->s_blocksize = 1 << sb->s_blocksize_bits; - - sb->s_maxbytes = ext2_max_size(sb->s_blocksize_bits); - + blocksize = BLOCK_SIZE << le32_to_cpu(EXT2_SB(sb)->s_es->s_log_block_size); /* If the blocksize doesn't match, re-read the thing.. */ if (sb->s_blocksize != blocksize) { - blocksize = sb->s_blocksize; brelse(bh); - if (set_blocksize(dev, blocksize) < 0) { + if (!sb_set_blocksize(sb, blocksize)) { printk(KERN_ERR "EXT2-fs: blocksize too small for device.\n"); return NULL; } @@ -517,6 +510,8 @@ } } + sb->s_maxbytes = ext2_max_size(sb->s_blocksize_bits); + if (le32_to_cpu(es->s_rev_level) == EXT2_GOOD_OLD_REV) { sb->u.ext2_sb.s_inode_size = EXT2_GOOD_OLD_INODE_SIZE; sb->u.ext2_sb.s_first_ino = EXT2_GOOD_OLD_FIRST_INO; @@ -630,6 +625,7 @@ sb->u.ext2_sb.s_loaded_inode_bitmaps = 0; sb->u.ext2_sb.s_loaded_block_bitmaps = 0; sb->u.ext2_sb.s_gdb_count = db_count; + get_random_bytes(&sb->u.ext2_sb.s_next_generation, sizeof(u32)); /* * set up enough so that it can read an inode */ @@ -664,6 +660,15 @@ sb->s_dirt = 0; } +static void ext2_sync_super(struct super_block *sb, struct ext2_super_block *es) +{ + es->s_wtime = cpu_to_le32(CURRENT_TIME); + mark_buffer_dirty(EXT2_SB(sb)->s_sbh); + ll_rw_block(WRITE, 1, &EXT2_SB(sb)->s_sbh); + wait_on_buffer(EXT2_SB(sb)->s_sbh); + sb->s_dirt = 0; +} + /* * In the second extended file system, it is not necessary to * write the super block since we use a mapping of the @@ -682,13 +687,14 @@ if (!(sb->s_flags & MS_RDONLY)) { es = sb->u.ext2_sb.s_es; - ext2_debug ("setting valid to 0\n"); - if (le16_to_cpu(es->s_state) & EXT2_VALID_FS) { - es->s_state = cpu_to_le16(le16_to_cpu(es->s_state) & ~EXT2_VALID_FS); + ext2_debug ("setting valid to 0\n"); + es->s_state = cpu_to_le16(le16_to_cpu(es->s_state) & + ~EXT2_VALID_FS); es->s_mtime = cpu_to_le32(CURRENT_TIME); - } - ext2_commit_super (sb, es); + ext2_sync_super(sb, es); + } else + ext2_commit_super (sb, es); } sb->s_dirt = 0; } @@ -725,11 +731,7 @@ */ es->s_state = cpu_to_le16(sb->u.ext2_sb.s_mount_state); es->s_mtime = cpu_to_le32(CURRENT_TIME); - mark_buffer_dirty(sb->u.ext2_sb.s_sbh); - sb->s_dirt = 1; - ext2_commit_super (sb, es); - } - else { + } else { int ret; if ((ret = EXT2_HAS_RO_COMPAT_FEATURE(sb, ~EXT2_FEATURE_RO_COMPAT_SUPP))) { @@ -747,6 +749,7 @@ if (!ext2_setup_super (sb, es, 0)) sb->s_flags &= ~MS_RDONLY; } + ext2_sync_super(sb, es); return 0; } diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/fs/ext3/Makefile linux-2.5/fs/ext3/Makefile --- linux-2.5.1/fs/ext3/Makefile Fri Nov 9 22:25:04 2001 +++ linux-2.5/fs/ext3/Makefile Thu Dec 13 16:32:36 2001 @@ -9,7 +9,7 @@ O_TARGET := ext3.o -obj-y := acl.o balloc.o bitmap.o dir.o file.o fsync.o ialloc.o inode.o \ +obj-y := balloc.o bitmap.o dir.o file.o fsync.o ialloc.o inode.o \ ioctl.o namei.o super.o symlink.o obj-m := $(O_TARGET) diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/fs/ext3/acl.c linux-2.5/fs/ext3/acl.c --- linux-2.5.1/fs/ext3/acl.c Fri Nov 9 22:25:04 2001 +++ linux-2.5/fs/ext3/acl.c Thu Jan 1 00:00:00 1970 @@ -1,17 +0,0 @@ -/* - * linux/fs/ext3/acl.c - * - * Copyright (C) 1993, 1994, 1995 - * Remy Card (card@masi.ibp.fr) - * Laboratoire MASI - Institut Blaise Pascal - * Universite Pierre et Marie Curie (Paris VI) - */ - -#include <linux/fs.h> -#include <linux/sched.h> - - -/* - * This file will contain the Access Control Lists management for the - * second extended file system. - */ diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/fs/ext3/inode.c linux-2.5/fs/ext3/inode.c --- linux-2.5.1/fs/ext3/inode.c Sun Dec 16 20:23:00 2001 +++ linux-2.5/fs/ext3/inode.c Thu Dec 27 22:10:28 2001 @@ -32,7 +32,6 @@ #include <linux/quotaops.h> #include <linux/module.h> - /* * SEARCH_FROM_ZERO forces each block allocation to search from the start * of the filesystem. This is to force rapid reallocation of recently-freed @@ -715,6 +714,8 @@ * reachable from inode. * * akpm: `handle' can be NULL if create == 0. + * + * The BKL may not be held on entry here. Be sure to take it early. */ static int ext3_get_block_handle(handle_t *handle, struct inode *inode, @@ -743,9 +744,7 @@ if (!partial) { bh_result->b_state &= ~(1UL << BH_New); got_it: - bh_result->b_dev = inode->i_dev; - bh_result->b_blocknr = le32_to_cpu(chain[depth-1].key); - bh_result->b_state |= (1UL << BH_Mapped); + map_bh(bh_result, inode->i_sb, le32_to_cpu(chain[depth-1].key)); /* Clean up and exit */ partial = chain+depth-1; /* the whole chain */ goto cleanup; @@ -1020,13 +1019,26 @@ ret = PTR_ERR(handle); goto out; } + unlock_kernel(); ret = block_prepare_write(page, from, to, ext3_get_block); + lock_kernel(); if (ret != 0) goto prepare_write_failed; - if (ext3_should_journal_data(inode)) + if (ext3_should_journal_data(inode)) { ret = walk_page_buffers(handle, page->buffers, from, to, NULL, do_journal_get_write_access); + if (ret) { + /* + * We're going to fail this prepare_write(), + * so commit_write() will not be called. + * We need to undo block_prepare_write()'s kmap(). + * AKPM: Do we need to clear PageUptodate? I don't + * think so. + */ + kunmap(page); + } + } prepare_write_failed: if (ret) ext3_journal_stop(handle, inode); @@ -1094,7 +1106,7 @@ kunmap(page); if (pos > inode->i_size) inode->i_size = pos; - set_bit(EXT3_STATE_JDATA, &inode->u.ext3_i.i_state); + EXT3_I(inode)->i_state |= EXT3_STATE_JDATA; } else { if (ext3_should_order_data(inode)) { ret = walk_page_buffers(handle, page->buffers, @@ -1102,8 +1114,17 @@ } /* Be careful here if generic_commit_write becomes a * required invocation after block_prepare_write. */ - if (ret == 0) + if (ret == 0) { ret = generic_commit_write(file, page, from, to); + } else { + /* + * block_prepare_write() was called, but we're not + * going to call generic_commit_write(). So we + * need to perform generic_commit_write()'s kunmap + * by hand. + */ + kunmap(page); + } } if (inode->i_size > inode->u.ext3_i.i_disksize) { inode->u.ext3_i.i_disksize = inode->i_size; @@ -1138,7 +1159,7 @@ journal_t *journal; int err; - if (test_and_clear_bit(EXT3_STATE_JDATA, &inode->u.ext3_i.i_state)) { + if (EXT3_I(inode)->i_state & EXT3_STATE_JDATA) { /* * This is a REALLY heavyweight approach, but the use of * bmap on dirty files is expected to be extremely rare: @@ -1157,6 +1178,7 @@ * everything they get. */ + EXT3_I(inode)->i_state &= ~EXT3_STATE_JDATA; journal = EXT3_JOURNAL(inode); journal_lock_updates(journal); err = journal_flush(journal); @@ -1265,8 +1287,7 @@ /* bget() all the buffers */ if (order_data) { if (!page->buffers) - create_empty_buffers(page, - inode->i_dev, inode->i_sb->s_blocksize); + create_empty_buffers(page, inode->i_sb->s_blocksize); page_buffers = page->buffers; walk_page_buffers(handle, page_buffers, 0, PAGE_CACHE_SIZE, NULL, bget_one); @@ -1369,7 +1390,7 @@ goto out; if (!page->buffers) - create_empty_buffers(page, inode->i_dev, blocksize); + create_empty_buffers(page, blocksize); /* Find the buffer that contains "offset" */ bh = page->buffers; @@ -2198,7 +2219,7 @@ /* If we are not tracking these fields in the in-memory inode, * then preserve them on disk, but still initialise them to zero * for new inodes. */ - if (inode->u.ext3_i.i_state & EXT3_STATE_NEW) { + if (EXT3_I(inode)->i_state & EXT3_STATE_NEW) { raw_inode->i_faddr = 0; raw_inode->i_frag = 0; raw_inode->i_fsize = 0; @@ -2244,7 +2265,7 @@ rc = ext3_journal_dirty_metadata(handle, bh); if (!err) err = rc; - inode->u.ext3_i.i_state &= ~EXT3_STATE_NEW; + EXT3_I(inode)->i_state &= ~EXT3_STATE_NEW; out_brelse: brelse (bh); @@ -2328,12 +2349,20 @@ int ext3_setattr(struct dentry *dentry, struct iattr *attr) { struct inode *inode = dentry->d_inode; - int error, rc; + int error, rc = 0; + const unsigned int ia_valid = attr->ia_valid; error = inode_change_ok(inode, attr); if (error) return error; - + + if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) || + (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid)) { + error = DQUOT_TRANSFER(inode, attr) ? -EDQUOT : 0; + if (error) + return error; + } + if (attr->ia_valid & ATTR_SIZE && attr->ia_size < inode->i_size) { handle_t *handle; @@ -2351,7 +2380,7 @@ ext3_journal_stop(handle, inode); } - inode_setattr(inode, attr); + rc = inode_setattr(inode, attr); /* If inode_setattr's call to ext3_truncate failed to get a * transaction handle at all, we need to clean up the in-core @@ -2361,7 +2390,9 @@ err_out: ext3_std_error(inode->i_sb, error); - return 0; + if (!error) + error = rc; + return error; } @@ -2662,6 +2693,3 @@ * here, in ext3_aops_journal_start() to ensure that the forthcoming "see if we * need to extend" test in ext3_prepare_write() succeeds. */ - - -MODULE_LICENSE("GPL"); diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/fs/ext3/super.c linux-2.5/fs/ext3/super.c --- linux-2.5.1/fs/ext3/super.c Sun Dec 16 20:23:00 2001 +++ linux-2.5/fs/ext3/super.c Thu Dec 27 15:56:12 2001 @@ -912,10 +912,6 @@ * This is important for devices that have a hardware * sectorsize that is larger than the default. */ - blocksize = EXT3_MIN_BLOCK_SIZE; - hblock = get_hardsect_size(dev); - if (blocksize < hblock) - blocksize = hblock; sbi->s_mount_opt = 0; sbi->s_resuid = EXT3_DEF_RESUID; @@ -925,8 +921,7 @@ goto out_fail; } - sb->s_blocksize = blocksize; - set_blocksize (dev, blocksize); + blocksize = sb_min_blocksize(sb, EXT3_MIN_BLOCK_SIZE); /* * The ext3 superblock will not be buffer aligned for other than 1kB @@ -980,11 +975,10 @@ bdevname(dev), i); goto failed_mount; } - sb->s_blocksize_bits = le32_to_cpu(es->s_log_block_size) + 10; - sb->s_blocksize = 1 << sb->s_blocksize_bits; + blocksize = BLOCK_SIZE << le32_to_cpu(es->s_log_block_size); - if (sb->s_blocksize < EXT3_MIN_BLOCK_SIZE || - sb->s_blocksize > EXT3_MAX_BLOCK_SIZE) { + if (blocksize < EXT3_MIN_BLOCK_SIZE || + blocksize > EXT3_MAX_BLOCK_SIZE) { printk(KERN_ERR "EXT3-fs: Unsupported filesystem blocksize %d on %s.\n", blocksize, bdevname(dev)); @@ -993,21 +987,20 @@ sb->s_maxbytes = ext3_max_size(sb->s_blocksize_bits); + hblock = get_hardsect_size(dev); if (sb->s_blocksize != blocksize) { - blocksize = sb->s_blocksize; - /* * Make sure the blocksize for the filesystem is larger * than the hardware sectorsize for the machine. */ - if (sb->s_blocksize < hblock) { + if (blocksize < hblock) { printk(KERN_ERR "EXT3-fs: blocksize %d too small for " "device blocksize %d.\n", blocksize, hblock); goto failed_mount; } brelse (bh); - set_blocksize (dev, sb->s_blocksize); + sb_set_blocksize(sb, blocksize); logic_sb_block = (sb_block * EXT3_MIN_BLOCK_SIZE) / blocksize; offset = (sb_block * EXT3_MIN_BLOCK_SIZE) % blocksize; bh = sb_bread(sb, logic_sb_block); @@ -1257,8 +1250,11 @@ } journal = journal_init_inode(journal_inode); - if (!journal) + if (!journal) { + printk(KERN_ERR "EXT3-fs: Could not load journal inode\n"); iput(journal_inode); + } + return journal; } @@ -1350,7 +1346,7 @@ journal_t *journal; int journal_inum = le32_to_cpu(es->s_journal_inum); int journal_dev = le32_to_cpu(es->s_journal_dev); - int err; + int err = 0; int really_read_only; really_read_only = is_read_only(sb->s_dev); @@ -1400,9 +1396,10 @@ } if (!EXT3_HAS_INCOMPAT_FEATURE(sb, EXT3_FEATURE_INCOMPAT_RECOVER)) - journal_wipe(journal, !really_read_only); + err = journal_wipe(journal, !really_read_only); + if (!err) + err = journal_load(journal); - err = journal_load(journal); if (err) { printk(KERN_ERR "EXT3-fs: error loading journal.\n"); journal_destroy(journal); @@ -1740,6 +1737,8 @@ EXPORT_NO_SYMBOLS; +MODULE_AUTHOR("Remy Card, Stephen Tweedie, Andrew Morton, Andreas Dilger, Theodore Ts'o and others"); +MODULE_DESCRIPTION("Second Extended Filesystem with journaling extensions"); MODULE_LICENSE("GPL"); module_init(init_ext3_fs) module_exit(exit_ext3_fs) diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/fs/fat/cache.c linux-2.5/fs/fat/cache.c --- linux-2.5.1/fs/fat/cache.c Fri Oct 12 20:48:42 2001 +++ linux-2.5/fs/fat/cache.c Thu Dec 27 22:10:28 2001 @@ -144,7 +144,7 @@ } fat_cache = &cache[0]; for (count = 0; count < FAT_CACHE; count++) { - cache[count].device = 0; + cache[count].sb = NULL; cache[count].next = count == FAT_CACHE-1 ? NULL : &cache[count+1]; } @@ -162,7 +162,7 @@ return; spin_lock(&fat_cache_lock); for (walk = fat_cache; walk; walk = walk->next) - if (inode->i_dev == walk->device + if (inode->i_sb == walk->sb && walk->start_cluster == first && walk->file_cluster <= cluster && walk->file_cluster > *f_clu) { @@ -188,8 +188,8 @@ struct fat_cache *walk; for (walk = fat_cache; walk; walk = walk->next) { - if (walk->device) - printk("<%s,%d>(%d,%d) ", kdevname(walk->device), + if (walk->sb) + printk("<%s,%d>(%d,%d) ", bdevname(walk->sb->s_dev), walk->start_cluster, walk->file_cluster, walk->disk_cluster); else printk("-- "); @@ -207,7 +207,7 @@ last = NULL; spin_lock(&fat_cache_lock); for (walk = fat_cache; walk->next; walk = (last = walk)->next) - if (inode->i_dev == walk->device + if (inode->i_sb == walk->sb && walk->start_cluster == first && walk->file_cluster == f_clu) { if (walk->disk_cluster != d_clu) { @@ -231,7 +231,7 @@ spin_unlock(&fat_cache_lock); return; } - walk->device = inode->i_dev; + walk->sb = inode->i_sb; walk->start_cluster = first; walk->file_cluster = f_clu; walk->disk_cluster = d_clu; @@ -255,21 +255,21 @@ spin_lock(&fat_cache_lock); for (walk = fat_cache; walk; walk = walk->next) - if (walk->device == inode->i_dev + if (walk->sb == inode->i_sb && walk->start_cluster == first) - walk->device = 0; + walk->sb = NULL; spin_unlock(&fat_cache_lock); } -void fat_cache_inval_dev(kdev_t device) +void fat_cache_inval_dev(struct super_block *sb) { struct fat_cache *walk; spin_lock(&fat_cache_lock); for (walk = fat_cache; walk; walk = walk->next) - if (walk->device == device) - walk->device = 0; + if (walk->sb == sb) + walk->sb = 0; spin_unlock(&fat_cache_lock); } diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/fs/fat/file.c linux-2.5/fs/fat/file.c --- linux-2.5.1/fs/fat/file.c Fri Nov 30 16:30:48 2001 +++ linux-2.5/fs/fat/file.c Thu Dec 27 22:10:28 2001 @@ -55,9 +55,7 @@ phys = fat_bmap(inode, iblock); if (phys) { - bh_result->b_dev = inode->i_dev; - bh_result->b_blocknr = phys; - bh_result->b_state |= (1UL << BH_Mapped); + map_bh(bh_result, inode->i_sb, phys); return 0; } if (!create) @@ -74,10 +72,8 @@ phys = fat_bmap(inode, iblock); if (!phys) BUG(); - bh_result->b_dev = inode->i_dev; - bh_result->b_blocknr = phys; - bh_result->b_state |= (1UL << BH_Mapped); bh_result->b_state |= (1UL << BH_New); + map_bh(bh_result, inode->i_sb, phys); return 0; } diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/fs/fat/inode.c linux-2.5/fs/fat/inode.c --- linux-2.5.1/fs/fat/inode.c Sun Dec 16 20:23:00 2001 +++ linux-2.5/fs/fat/inode.c Sun Dec 30 20:01:41 2001 @@ -146,6 +146,7 @@ goto out; *res = 0; inode->i_ino = iunique(sb, MSDOS_ROOT_INO); + inode->i_version = 0; fat_fill_inode(inode, de); fat_attach(inode, ino); insert_inode_hash(inode); @@ -185,7 +186,7 @@ if (MSDOS_SB(sb)->fat_bits == 32) { fat_clusters_flush(sb); } - fat_cache_inval_dev(sb->s_dev); + fat_cache_inval_dev(sb); set_blocksize (sb->s_dev,BLOCK_SIZE); if (MSDOS_SB(sb)->nls_disk) { unload_nls(MSDOS_SB(sb)->nls_disk); @@ -383,7 +384,7 @@ MSDOS_I(inode)->i_fat_inode = inode; inode->i_uid = sbi->options.fs_uid; inode->i_gid = sbi->options.fs_gid; - inode->i_version = ++event; + inode->i_version++; inode->i_generation = 0; inode->i_mode = (S_IRWXUGO & ~sbi->options.fs_umask) | S_IFDIR; inode->i_op = sbi->dir_ops; @@ -569,10 +570,6 @@ sb->s_maxbytes = MAX_NON_LFS; sb->s_op = &fat_sops; - hard_blksize = get_hardsect_size(sb->s_dev); - if (!hard_blksize) - hard_blksize = 512; - opts.isvfat = sbi->options.isvfat; if (!parse_options((char *) data, &fat, &debug, &opts, cvf_format, cvf_options)) @@ -582,8 +579,7 @@ fat_cache_init(); - sb->s_blocksize = hard_blksize; - set_blocksize(sb->s_dev, hard_blksize); + sb_min_blocksize(sb, 512); bh = sb_bread(sb, 0); if (bh == NULL) { printk("FAT: unable to read boot sector\n"); @@ -625,13 +621,15 @@ goto out_invalid; } - if (logical_sector_size < hard_blksize) { + if (logical_sector_size < sb->s_blocksize) { printk("FAT: logical sector size too small for device" " (logical sector size = %d)\n", logical_sector_size); brelse(bh); goto out_invalid; } + hard_blksize = sb->s_blocksize; + sbi->cluster_bits = ffs(logical_sector_size * sbi->cluster_size) - 1; sbi->fats = b->fats; sbi->fat_start = CF_LE_W(b->reserved); @@ -716,9 +714,7 @@ if (error) goto out_invalid; - sb->s_blocksize = logical_sector_size; - sb->s_blocksize_bits = ffs(logical_sector_size) - 1; - set_blocksize(sb->s_dev, sb->s_blocksize); + sb_set_blocksize(sb, logical_sector_size); sbi->cvf_format = &default_cvf; if (!strcmp(cvf_format, "none")) i = -1; @@ -781,6 +777,7 @@ if (!root_inode) goto out_unload_nls; root_inode->i_ino = MSDOS_ROOT_INO; + root_inode->i_version = 0; fat_read_root(root_inode); insert_inode_hash(root_inode); sb->s_root = d_alloc_root(root_inode); @@ -802,7 +799,7 @@ out_invalid: if (!silent) { printk("VFS: Can't find a valid FAT filesystem on dev %s.\n", - kdevname(sb->s_dev)); + bdevname(sb->s_dev)); } out_fail: if (opts.iocharset) { @@ -892,7 +889,7 @@ MSDOS_I(inode)->i_fat_inode = inode; inode->i_uid = sbi->options.fs_uid; inode->i_gid = sbi->options.fs_gid; - inode->i_version = ++event; + inode->i_version++; inode->i_generation = CURRENT_TIME; if ((de->attr & ATTR_DIR) && !IS_FREE(de->name)) { diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/fs/freevxfs/vxfs_inode.c linux-2.5/fs/freevxfs/vxfs_inode.c --- linux-2.5.1/fs/freevxfs/vxfs_inode.c Sun Dec 16 20:23:00 2001 +++ linux-2.5/fs/freevxfs/vxfs_inode.c Sun Dec 30 20:01:41 2001 @@ -35,6 +35,7 @@ #include <linux/fs.h> #include <linux/kernel.h> #include <linux/slab.h> +#include <linux/pagemap.h> #include "vxfs.h" #include "vxfs_inode.h" diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/fs/freevxfs/vxfs_subr.c linux-2.5/fs/freevxfs/vxfs_subr.c --- linux-2.5.1/fs/freevxfs/vxfs_subr.c Sun Dec 16 20:23:00 2001 +++ linux-2.5/fs/freevxfs/vxfs_subr.c Thu Dec 27 22:10:28 2001 @@ -142,10 +142,7 @@ pblock = vxfs_bmap1(ip, iblock); if (pblock != 0) { - bp->b_dev = ip->i_dev; - bp->b_blocknr = pblock; - bp->b_state |= (1UL << BH_Mapped); - + map_bh(bp, ip->i_sb, pblock); return 0; } diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/fs/hfs/dir.c linux-2.5/fs/hfs/dir.c --- linux-2.5.1/fs/hfs/dir.c Tue Feb 13 22:13:45 2001 +++ linux-2.5/fs/hfs/dir.c Sun Dec 30 20:01:41 2001 @@ -69,8 +69,8 @@ /* * update_dirs_plus() * - * Update the fields 'i_size', 'i_nlink', 'i_ctime', 'i_mtime' and - * 'i_version' of the inodes associated with a directory that has + * Update the fields 'i_size', 'i_nlink', 'i_ctime' and 'i_mtime' + * of the inodes associated with a directory that has * had a file ('is_dir'==0) or directory ('is_dir'!=0) added to it. */ static inline void update_dirs_plus(struct hfs_cat_entry *dir, int is_dir) @@ -88,7 +88,6 @@ ++(tmp->i_nlink); } tmp->i_size += HFS_I(tmp)->dir_size; - tmp->i_version = ++event; } tmp->i_ctime = tmp->i_mtime = CURRENT_TIME; mark_inode_dirty(tmp); @@ -100,7 +99,7 @@ * update_dirs_minus() * * Update the fields 'i_size', 'i_nlink', 'i_ctime', 'i_mtime' and - * 'i_version' of the inodes associated with a directory that has + * of the inodes associated with a directory that has * had a file ('is_dir'==0) or directory ('is_dir'!=0) removed. */ static inline void update_dirs_minus(struct hfs_cat_entry *dir, int is_dir) @@ -118,7 +117,6 @@ --(tmp->i_nlink); } tmp->i_size -= HFS_I(tmp)->dir_size; - tmp->i_version = ++event; } tmp->i_ctime = tmp->i_mtime = CURRENT_TIME; mark_inode_dirty(tmp); diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/fs/hfs/file.c linux-2.5/fs/hfs/file.c --- linux-2.5.1/fs/hfs/file.c Sun Dec 16 20:23:00 2001 +++ linux-2.5/fs/hfs/file.c Thu Dec 27 22:10:28 2001 @@ -112,11 +112,9 @@ phys = hfs_extent_map(HFS_I(inode)->fork, iblock, create); if (phys) { - bh_result->b_dev = inode->i_dev; - bh_result->b_blocknr = phys; - bh_result->b_state |= (1UL << BH_Mapped); if (create) bh_result->b_state |= (1UL << BH_New); + map_bh(bh_result, inode->i_sb, phys); return 0; } diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/fs/hfs/file_cap.c linux-2.5/fs/hfs/file_cap.c --- linux-2.5.1/fs/hfs/file_cap.c Mon Sep 10 14:31:25 2001 +++ linux-2.5/fs/hfs/file_cap.c Sun Dec 30 20:01:41 2001 @@ -103,7 +103,6 @@ if (offset != file->f_pos) { file->f_pos = offset; file->f_reada = 0; - file->f_version = ++event; } retval = offset; } diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/fs/hfs/file_hdr.c linux-2.5/fs/hfs/file_hdr.c --- linux-2.5.1/fs/hfs/file_hdr.c Sun Aug 12 17:56:56 2001 +++ linux-2.5/fs/hfs/file_hdr.c Sun Dec 30 20:01:41 2001 @@ -359,7 +359,6 @@ if (offset != file->f_pos) { file->f_pos = offset; file->f_reada = 0; - file->f_version = ++event; } retval = offset; } diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/fs/hfs/super.c linux-2.5/fs/hfs/super.c --- linux-2.5.1/fs/hfs/super.c Sun Dec 16 20:23:00 2001 +++ linux-2.5/fs/hfs/super.c Thu Dec 27 15:56:12 2001 @@ -401,9 +401,7 @@ } /* set the device driver to 512-byte blocks */ - set_blocksize(dev, HFS_SECTOR_SIZE); - s->s_blocksize_bits = HFS_SECTOR_SIZE_BITS; - s->s_blocksize = HFS_SECTOR_SIZE; + sb_set_blocksize(s, HFS_SECTOR_SIZE); #ifdef CONFIG_MAC_PARTITION /* check to see if we're in a partition */ diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/fs/hpfs/file.c linux-2.5/fs/hpfs/file.c --- linux-2.5.1/fs/hpfs/file.c Sun Dec 16 20:23:03 2001 +++ linux-2.5/fs/hpfs/file.c Thu Dec 27 22:10:28 2001 @@ -73,9 +73,7 @@ secno s; s = hpfs_bmap(inode, iblock); if (s) { - bh_result->b_dev = inode->i_dev; - bh_result->b_blocknr = s; - bh_result->b_state |= (1UL << BH_Mapped); + map_bh(bh_result, inode->i_sb, s); return 0; } if (!create) return 0; @@ -89,9 +87,8 @@ } inode->i_blocks++; inode->u.hpfs_i.mmu_private += 512; - bh_result->b_dev = inode->i_dev; - bh_result->b_blocknr = s; - bh_result->b_state |= (1UL << BH_Mapped) | (1UL << BH_New); + bh_result->b_state |= 1UL << BH_New; + map_bh(bh_result, inode->i_sb, s); return 0; } diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/fs/hpfs/hpfs_fn.h linux-2.5/fs/hpfs/hpfs_fn.h --- linux-2.5.1/fs/hpfs/hpfs_fn.h Sun Dec 16 20:23:05 2001 +++ linux-2.5/fs/hpfs/hpfs_fn.h Sun Dec 30 21:17:30 2001 @@ -19,7 +19,6 @@ #include <linux/stat.h> #include <linux/string.h> #include <asm/bitops.h> -#include <asm/segment.h> #include <asm/uaccess.h> #include <linux/smp_lock.h> diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/fs/hpfs/super.c linux-2.5/fs/hpfs/super.c --- linux-2.5.1/fs/hpfs/super.c Thu Oct 25 07:02:26 2001 +++ linux-2.5/fs/hpfs/super.c Thu Dec 27 15:55:40 2001 @@ -409,7 +409,7 @@ /*s->s_hpfs_mounting = 1;*/ dev = s->s_dev; - set_blocksize(dev, 512); + sb_set_blocksize(s, 512); s->s_hpfs_fs_size = -1; if (!(bootblock = hpfs_map_sector(s, 0, &bh0, 0))) goto bail1; if (!(superblock = hpfs_map_sector(s, 16, &bh1, 1))) goto bail2; @@ -436,8 +436,6 @@ /* Fill superblock stuff */ s->s_magic = HPFS_SUPER_MAGIC; - s->s_blocksize = 512; - s->s_blocksize_bits = 9; s->s_op = &hpfs_sops; s->s_hpfs_root = superblock->root; diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/fs/inflate_fs/inflate_syms.c linux-2.5/fs/inflate_fs/inflate_syms.c --- linux-2.5.1/fs/inflate_fs/inflate_syms.c Thu Oct 25 20:53:53 2001 +++ linux-2.5/fs/inflate_fs/inflate_syms.c Thu Dec 13 16:32:36 2001 @@ -19,3 +19,4 @@ EXPORT_SYMBOL(zlib_fs_inflateReset); EXPORT_SYMBOL(zlib_fs_adler32); EXPORT_SYMBOL(zlib_fs_inflateSyncPoint); +MODULE_LICENSE("GPL"); diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/fs/inode.c linux-2.5/fs/inode.c --- linux-2.5.1/fs/inode.c Mon Dec 10 22:13:25 2001 +++ linux-2.5/fs/inode.c Thu Dec 13 16:32:37 2001 @@ -1082,7 +1082,7 @@ } inodes_stat.nr_unused++; spin_unlock(&inode_lock); - if (!sb || sb->s_flags & MS_ACTIVE) + if (!sb || (sb->s_flags & MS_ACTIVE)) return; write_inode_now(inode, 1); spin_lock(&inode_lock); @@ -1207,6 +1207,8 @@ void update_atime (struct inode *inode) { + if (inode->i_atime == CURRENT_TIME) + return; if ( IS_NOATIME (inode) ) return; if ( IS_NODIRATIME (inode) && S_ISDIR (inode->i_mode) ) return; if ( IS_RDONLY (inode) ) return; diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/fs/intermezzo/dcache.c linux-2.5/fs/intermezzo/dcache.c --- linux-2.5.1/fs/intermezzo/dcache.c Tue Nov 13 17:20:56 2001 +++ linux-2.5/fs/intermezzo/dcache.c Sun Dec 30 21:17:30 2001 @@ -16,7 +16,6 @@ #include <linux/errno.h> #include <linux/locks.h> #include <linux/slab.h> -#include <asm/segment.h> #include <asm/uaccess.h> #include <linux/string.h> diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/fs/intermezzo/ext_attr.c linux-2.5/fs/intermezzo/ext_attr.c --- linux-2.5.1/fs/intermezzo/ext_attr.c Sun Nov 11 18:20:21 2001 +++ linux-2.5/fs/intermezzo/ext_attr.c Sun Dec 30 21:17:30 2001 @@ -28,7 +28,6 @@ #include <asm/uaccess.h> #include <linux/slab.h> #include <linux/vmalloc.h> -#include <asm/segment.h> #include <linux/smp_lock.h> #include <linux/intermezzo_fs.h> diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/fs/intermezzo/file.c linux-2.5/fs/intermezzo/file.c --- linux-2.5.1/fs/intermezzo/file.c Sun Nov 11 18:20:21 2001 +++ linux-2.5/fs/intermezzo/file.c Thu Dec 13 16:32:37 2001 @@ -344,7 +344,7 @@ << file->f_dentry->d_inode->i_sb->s_blocksize_bits); error = presto_reserve_space(fset->fset_cache, res_size); - CDEBUG(D_INODE, "Reserved %Ld for %d\n", res_size, size); + CDEBUG(D_INODE, "Reserved %Ld for %Zd\n", res_size, size); if ( error ) { EXIT; return -ENOSPC; @@ -397,7 +397,7 @@ fops = filter_c2cffops(cache->cache_filter); res = fops->write(file, buf, size, off); if ( res != size ) { - CDEBUG(D_FILE, "file write returns short write: size %d, res %d\n", size, res); + CDEBUG(D_FILE, "file write returns short write: size %Zd, res %Zd\n", size, res); } if ( (res > 0) && fdata ) diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/fs/intermezzo/inode.c linux-2.5/fs/intermezzo/inode.c --- linux-2.5.1/fs/intermezzo/inode.c Sun Nov 11 18:20:21 2001 +++ linux-2.5/fs/intermezzo/inode.c Sun Dec 30 21:17:30 2001 @@ -29,7 +29,6 @@ #include <asm/uaccess.h> #include <linux/slab.h> #include <linux/vmalloc.h> -#include <asm/segment.h> #include <linux/intermezzo_fs.h> #include <linux/intermezzo_upcall.h> diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/fs/intermezzo/journal.c linux-2.5/fs/intermezzo/journal.c --- linux-2.5.1/fs/intermezzo/journal.c Tue Nov 13 17:20:56 2001 +++ linux-2.5/fs/intermezzo/journal.c Sun Dec 30 21:17:30 2001 @@ -14,7 +14,6 @@ #include <linux/time.h> #include <linux/errno.h> #include <linux/locks.h> -#include <asm/segment.h> #include <asm/uaccess.h> #include <linux/string.h> #include <linux/smp_lock.h> @@ -1077,7 +1076,7 @@ return 0; } - CDEBUG(D_JOURNAL, "reading prefix: off %ld, size %d\n", + CDEBUG(D_JOURNAL, "reading prefix: off %ld, size %Zd\n", (long)lml_offset, sizeof(record)); rc = presto_fread(fset->fset_lml.fd_file, (char *)&record, sizeof(record), &offset); diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/fs/intermezzo/journal_ext2.c linux-2.5/fs/intermezzo/journal_ext2.c --- linux-2.5.1/fs/intermezzo/journal_ext2.c Sun Nov 11 18:20:21 2001 +++ linux-2.5/fs/intermezzo/journal_ext2.c Sun Dec 30 21:17:30 2001 @@ -12,7 +12,6 @@ #include <linux/stat.h> #include <linux/errno.h> #include <linux/locks.h> -#include <asm/segment.h> #include <asm/uaccess.h> #include <linux/string.h> #include <linux/ext2_fs.h> diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/fs/intermezzo/journal_ext3.c linux-2.5/fs/intermezzo/journal_ext3.c --- linux-2.5.1/fs/intermezzo/journal_ext3.c Sun Nov 11 18:20:21 2001 +++ linux-2.5/fs/intermezzo/journal_ext3.c Sun Dec 30 21:17:30 2001 @@ -17,7 +17,6 @@ #include <linux/stat.h> #include <linux/errno.h> #include <linux/locks.h> -#include <asm/segment.h> #include <asm/uaccess.h> #include <linux/string.h> #include <linux/smp_lock.h> diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/fs/intermezzo/journal_obdfs.c linux-2.5/fs/intermezzo/journal_obdfs.c --- linux-2.5.1/fs/intermezzo/journal_obdfs.c Sun Nov 11 18:20:21 2001 +++ linux-2.5/fs/intermezzo/journal_obdfs.c Sun Dec 30 21:17:30 2001 @@ -17,7 +17,6 @@ #include <linux/stat.h> #include <linux/errno.h> #include <linux/locks.h> -#include <asm/segment.h> #include <asm/uaccess.h> #include <linux/string.h> #ifdef CONFIG_OBDFS_FS diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/fs/intermezzo/journal_reiserfs.c linux-2.5/fs/intermezzo/journal_reiserfs.c --- linux-2.5.1/fs/intermezzo/journal_reiserfs.c Sun Nov 11 18:20:21 2001 +++ linux-2.5/fs/intermezzo/journal_reiserfs.c Sun Dec 30 21:17:30 2001 @@ -17,7 +17,6 @@ #include <linux/errno.h> #include <linux/smp_lock.h> #include <linux/locks.h> -#include <asm/segment.h> #include <asm/uaccess.h> #include <linux/string.h> #if 0 diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/fs/intermezzo/journal_xfs.c linux-2.5/fs/intermezzo/journal_xfs.c --- linux-2.5.1/fs/intermezzo/journal_xfs.c Tue Nov 13 17:20:56 2001 +++ linux-2.5/fs/intermezzo/journal_xfs.c Sun Dec 30 21:17:30 2001 @@ -12,7 +12,6 @@ #include <linux/stat.h> #include <linux/errno.h> #include <linux/locks.h> -#include <asm/segment.h> #include <asm/uaccess.h> #include <linux/string.h> #ifdef CONFIG_FS_XFS diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/fs/intermezzo/presto.c linux-2.5/fs/intermezzo/presto.c --- linux-2.5.1/fs/intermezzo/presto.c Tue Nov 13 17:20:56 2001 +++ linux-2.5/fs/intermezzo/presto.c Sun Dec 30 21:17:30 2001 @@ -17,7 +17,6 @@ #include <linux/vmalloc.h> #include <linux/slab.h> #include <linux/locks.h> -#include <asm/segment.h> #include <asm/uaccess.h> #include <linux/string.h> #include <linux/smp_lock.h> diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/fs/intermezzo/psdev.c linux-2.5/fs/intermezzo/psdev.c --- linux-2.5.1/fs/intermezzo/psdev.c Sun Nov 11 18:20:21 2001 +++ linux-2.5/fs/intermezzo/psdev.c Sun Dec 30 21:17:30 2001 @@ -35,6 +35,7 @@ #include <linux/sched.h> #include <linux/lp.h> #include <linux/slab.h> +#include <asm/ioctls.h> #include <linux/ioport.h> #include <linux/fcntl.h> #include <linux/delay.h> @@ -45,8 +46,8 @@ #include <linux/poll.h> #include <linux/init.h> #include <linux/list.h> +#include <linux/termios.h> #include <asm/io.h> -#include <asm/segment.h> #include <asm/system.h> #include <asm/poll.h> #include <asm/uaccess.h> @@ -176,7 +177,7 @@ /* move data into response buffer. */ if (req->rq_bufsize < count) { - printk("psdev_write: too much cnt: %d, cnt: %d, " + printk("psdev_write: too much cnt: %d, cnt: %Zd, " "opc: %d, uniq: %d.\n", req->rq_bufsize, count, hdr.opcode, hdr.unique); count = req->rq_bufsize; /* don't have more space! */ @@ -209,7 +210,7 @@ __FUNCTION__, kdevname(dev)); } - CDEBUG(D_PSDEV, "count %d\n", count); + CDEBUG(D_PSDEV, "count %Zd\n", count); if (list_empty(&(upccom->uc_pending))) { CDEBUG(D_UPCALL, "Empty pending list in read, not good\n"); return -EINVAL; @@ -228,7 +229,7 @@ } if (count < req->rq_bufsize) { - printk ("psdev_read: buffer too small, read %d of %d bytes\n", + printk ("psdev_read: buffer too small, read %Zd of %d bytes\n", count, req->rq_bufsize); } @@ -281,7 +282,7 @@ error = copy_from_user(&readmount, (void *)arg, sizeof(readmount)); if ( error ) { - printk("psdev: can't copy %d bytes from %p to %p\n", + printk("psdev: can't copy %Zd bytes from %p to %p\n", sizeof(readmount), (struct readmount *) arg, &readmount); EXIT; @@ -469,7 +470,7 @@ input.size = size; upccom->uc_pid = saved_pid; - CDEBUG(D_PSDEV, "get_kmlsize: size = %d\n", size); + CDEBUG(D_PSDEV, "get_kmlsize: size = %Zd\n", size); EXIT; return copy_to_user((char *)arg, &input, sizeof(input)); @@ -621,7 +622,7 @@ error = copy_from_user(&kopt, (void *)arg, sizeof(kopt)); if ( error ) { - printk("psdev: can't copyin %d bytes from %p to %p\n", + printk("psdev: can't copyin %Zd bytes from %p to %p\n", sizeof(kopt), (struct kopt *) arg, &kopt); EXIT; return error; @@ -1244,7 +1245,7 @@ default: CDEBUG(D_PSDEV, "bad ioctl 0x%x, \n", cmd); - CDEBUG(D_PSDEV, "valid are 0x%x - 0x%x, 0x%x - 0x%x \n", + CDEBUG(D_PSDEV, "valid are 0x%Zx - 0x%Zx, 0x%Zx - 0x%Zx \n", PRESTO_GETMOUNT, PRESTO_GET_KMLSIZE, PRESTO_VFS_SETATTR, PRESTO_VFS_IOPEN); EXIT; @@ -1571,8 +1572,8 @@ req->rq_opcode, jiffies - req->rq_posttime, req->rq_unique, req->rq_rep_size); CDEBUG(D_UPCALL, - "..process %d woken up by Lento for req at 0x%x, data at %x\n", - current->pid, (int)req, (int)req->rq_data); + "..process %d woken up by Lento for req at 0x%p, data at %p\n", + current->pid, req, req->rq_data); if (upc_commp->uc_pid) { /* i.e. Lento is still alive */ /* Op went through, interrupt or not we go on */ diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/fs/intermezzo/sysctl.c linux-2.5/fs/intermezzo/sysctl.c --- linux-2.5.1/fs/intermezzo/sysctl.c Sun Nov 11 18:20:21 2001 +++ linux-2.5/fs/intermezzo/sysctl.c Sun Dec 30 21:17:30 2001 @@ -16,7 +16,6 @@ #include <linux/ctype.h> #include <linux/init.h> #include <asm/bitops.h> -#include <asm/segment.h> #include <asm/uaccess.h> #include <linux/utsname.h> #include <linux/blk.h> diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/fs/intermezzo/upcall.c linux-2.5/fs/intermezzo/upcall.c --- linux-2.5.1/fs/intermezzo/upcall.c Sun Nov 11 18:20:21 2001 +++ linux-2.5/fs/intermezzo/upcall.c Sun Dec 30 21:17:30 2001 @@ -20,7 +20,6 @@ */ #include <asm/system.h> -#include <asm/segment.h> #include <asm/signal.h> #include <linux/signal.h> @@ -37,7 +36,6 @@ #include <linux/string.h> #include <asm/uaccess.h> #include <linux/vmalloc.h> -#include <asm/segment.h> #include <linux/intermezzo_fs.h> #include <linux/intermezzo_upcall.h> diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/fs/isofs/inode.c linux-2.5/fs/isofs/inode.c --- linux-2.5.1/fs/isofs/inode.c Sun Dec 16 20:23:05 2001 +++ linux-2.5/fs/isofs/inode.c Thu Dec 27 22:10:28 2001 @@ -480,7 +480,6 @@ int iso_blknum, block; int orig_zonesize; int table; - unsigned int blocksize, blocksize_bits; unsigned int vol_desc_start; unsigned long first_data_zone; struct inode * inode; @@ -508,26 +507,10 @@ * larger than the blocksize the user specified, then use * that value. */ - blocksize = get_hardsect_size(dev); - if(blocksize > opt.blocksize) { - /* - * Force the blocksize we are going to use to be the - * hardware blocksize. - */ - opt.blocksize = blocksize; - } - - blocksize_bits = 0; - { - int i = opt.blocksize; - while (i != 1){ - blocksize_bits++; - i >>=1; - } - } - - set_blocksize(dev, opt.blocksize); - s->s_blocksize = opt.blocksize; + /* + * What if bugger tells us to go beyond page size? + */ + opt.blocksize = sb_min_blocksize(s, opt.blocksize); s->u.isofs_sb.s_high_sierra = high_sierra = 0; /* default is iso9660 */ @@ -540,7 +523,7 @@ struct hs_volume_descriptor * hdp; struct iso_volume_descriptor * vdp; - block = iso_blknum << (ISOFS_BLOCK_BITS-blocksize_bits); + block = iso_blknum << (ISOFS_BLOCK_BITS - s->s_blocksize_bits); if (!(bh = sb_bread(s, block))) goto out_no_read; @@ -651,7 +634,7 @@ * blocks that were 512 bytes (which should only very rarely * happen.) */ - if(blocksize != 0 && orig_zonesize < blocksize) + if(orig_zonesize < opt.blocksize) goto out_bad_size; /* RDE: convert log zone size to bit shift */ @@ -734,15 +717,7 @@ * entries. By forcing the blocksize in this way, we ensure * that we will never be required to do this. */ - if ( orig_zonesize != opt.blocksize ) { - set_blocksize(dev, orig_zonesize); -#ifndef BEQUIET - printk(KERN_DEBUG - "ISOFS: Forcing new log zone size:%d\n", orig_zonesize); -#endif - } - s->s_blocksize = orig_zonesize; - s->s_blocksize_bits = s -> u.isofs_sb.s_log_zone_size; + sb_set_blocksize(s, orig_zonesize); s->u.isofs_sb.s_nls_iocharset = NULL; @@ -853,7 +828,7 @@ goto out_freebh; out_bad_size: printk(KERN_WARNING "Logical zone size(%d) < hardware blocksize(%u)\n", - orig_zonesize, blocksize); + orig_zonesize, opt.blocksize); goto out_freebh; #ifndef IGNORE_WRONG_MULTI_VOLUME_SPECS out_no_support: @@ -890,7 +865,7 @@ * (0 == error.) */ int isofs_get_blocks(struct inode *inode, sector_t iblock, - struct buffer_head **bh_result, unsigned long nblocks) + struct buffer_head **bh, unsigned long nblocks) { unsigned long b_off; unsigned offset, sect_size; @@ -952,16 +927,14 @@ } } - if ( *bh_result ) { - (*bh_result)->b_dev = inode->i_dev; - (*bh_result)->b_blocknr = firstext + b_off - offset; - (*bh_result)->b_state |= (1UL << BH_Mapped); + if ( *bh ) { + map_bh(*bh, inode->i_sb, firstext + b_off - offset); } else { - *bh_result = sb_getblk(inode->i_sb, firstext+b_off-offset); - if ( !*bh_result ) + *bh = sb_getblk(inode->i_sb, firstext+b_off-offset); + if ( !*bh ) goto abort; } - bh_result++; /* Next buffer head */ + bh++; /* Next buffer head */ b_off++; /* Next buffer offset */ nblocks--; rv++; diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/fs/isofs/joliet.c linux-2.5/fs/isofs/joliet.c --- linux-2.5.1/fs/isofs/joliet.c Sun Aug 12 17:56:56 2001 +++ linux-2.5/fs/isofs/joliet.c Sun Dec 30 20:01:41 2001 @@ -8,7 +8,7 @@ #include <linux/string.h> #include <linux/nls.h> -#include <linux/slab.h> +#include <linux/mm.h> #include <linux/iso_fs.h> #include <asm/unaligned.h> diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/fs/isofs/namei.c linux-2.5/fs/isofs/namei.c --- linux-2.5.1/fs/isofs/namei.c Sun Dec 16 20:23:05 2001 +++ linux-2.5/fs/isofs/namei.c Sun Dec 30 20:01:41 2001 @@ -12,7 +12,7 @@ #include <linux/string.h> #include <linux/stat.h> #include <linux/fcntl.h> -#include <linux/slab.h> +#include <linux/mm.h> #include <linux/errno.h> #include <linux/config.h> /* Joliet? */ diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/fs/jbd/commit.c linux-2.5/fs/jbd/commit.c --- linux-2.5.1/fs/jbd/commit.c Fri Nov 9 22:25:04 2001 +++ linux-2.5/fs/jbd/commit.c Thu Dec 13 16:32:37 2001 @@ -47,7 +47,8 @@ struct buffer_head *wbuf[64]; int bufs; int flags; - int blocknr; + int err; + unsigned long blocknr; char *tagp = NULL; journal_header_t *header; journal_block_tag_t *tag = NULL; @@ -352,6 +353,11 @@ jbd_debug(4, "JBD: get descriptor\n"); descriptor = journal_get_descriptor_buffer(journal); + if (!descriptor) { + __journal_abort_hard(journal); + continue; + } + bh = jh2bh(descriptor); jbd_debug(4, "JBD: got buffer %ld (%p)\n", bh->b_blocknr, bh->b_data); @@ -375,7 +381,14 @@ /* Where is the buffer to be written? */ - blocknr = journal_next_log_block(journal); + err = journal_next_log_block(journal, &blocknr); + /* If the block mapping failed, just abandon the buffer + and repeat this loop: we'll fall into the + refile-on-abort condition above. */ + if (err) { + __journal_abort_hard(journal); + continue; + } /* Bump b_count to prevent truncate from stumbling over the shadowed buffer! @@@ This can go if we ever get @@ -554,16 +567,20 @@ jbd_debug(3, "JBD: commit phase 6\n"); + if (is_journal_aborted(journal)) + goto skip_commit; + /* Done it all: now write the commit record. We should have * cleaned up our previous buffers by now, so if we are in abort * mode we can now just skip the rest of the journal write * entirely. */ - if (is_journal_aborted(journal)) - goto skip_commit; - descriptor = journal_get_descriptor_buffer(journal); - + if (!descriptor) { + __journal_abort_hard(journal); + goto skip_commit; + } + /* AKPM: buglet - add `i' to tmp! */ for (i = 0; i < jh2bh(descriptor)->b_size; i += 512) { journal_header_t *tmp = diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/fs/jbd/journal.c linux-2.5/fs/jbd/journal.c --- linux-2.5.1/fs/jbd/journal.c Fri Nov 9 22:25:04 2001 +++ linux-2.5/fs/jbd/journal.c Thu Dec 13 16:32:37 2001 @@ -70,7 +70,6 @@ EXPORT_SYMBOL(journal_destroy); EXPORT_SYMBOL(journal_recover); EXPORT_SYMBOL(journal_update_superblock); -EXPORT_SYMBOL(__journal_abort); EXPORT_SYMBOL(journal_abort); EXPORT_SYMBOL(journal_errno); EXPORT_SYMBOL(journal_ack_err); @@ -606,7 +605,7 @@ * Log buffer allocation routines: */ -unsigned long journal_next_log_block(journal_t *journal) +int journal_next_log_block(journal_t *journal, unsigned long *retp) { unsigned long blocknr; @@ -617,7 +616,7 @@ journal->j_free--; if (journal->j_head == journal->j_last) journal->j_head = journal->j_first; - return journal_bmap(journal, blocknr); + return journal_bmap(journal, blocknr, retp); } /* @@ -627,17 +626,28 @@ * this is a no-op. If needed, we can use j_blk_offset - everything is * ready. */ -unsigned long journal_bmap(journal_t *journal, unsigned long blocknr) +int journal_bmap(journal_t *journal, unsigned long blocknr, + unsigned long *retp) { + int err = 0; unsigned long ret; if (journal->j_inode) { ret = bmap(journal->j_inode, blocknr); - J_ASSERT(ret != 0); + if (ret) + *retp = ret; + else { + printk (KERN_ALERT __FUNCTION__ + ": journal block not found " + "at offset %lu on %s\n", + blocknr, bdevname(journal->j_dev)); + err = -EIO; + __journal_abort_soft(journal, err); + } } else { - ret = blocknr; /* +journal->j_blk_offset */ + *retp = blocknr; /* +journal->j_blk_offset */ } - return ret; + return err; } /* @@ -649,7 +659,13 @@ struct journal_head * journal_get_descriptor_buffer(journal_t *journal) { struct buffer_head *bh; - unsigned long blocknr = journal_next_log_block(journal); + unsigned long blocknr; + int err; + + err = journal_next_log_block(journal, &blocknr); + + if (err) + return NULL; bh = getblk(journal->j_dev, blocknr, journal->j_blocksize); bh->b_state |= (1 << BH_Dirty); @@ -747,7 +763,8 @@ { struct buffer_head *bh; journal_t *journal = journal_init_common(); - int blocknr; + int err; + unsigned long blocknr; if (!journal) return NULL; @@ -757,13 +774,22 @@ journal->j_inode = inode; jbd_debug(1, "journal %p: inode %s/%ld, size %Ld, bits %d, blksize %ld\n", - journal, bdevname(inode->i_dev), inode->i_ino, inode->i_size, + journal, bdevname(inode->i_dev), inode->i_ino, + (long long) inode->i_size, inode->i_sb->s_blocksize_bits, inode->i_sb->s_blocksize); journal->j_maxlen = inode->i_size >> inode->i_sb->s_blocksize_bits; journal->j_blocksize = inode->i_sb->s_blocksize; - blocknr = journal_bmap(journal, 0); + err = journal_bmap(journal, 0, &blocknr); + /* If that failed, give up */ + if (err) { + printk(KERN_ERR __FUNCTION__ ": Cannnot locate journal " + "superblock\n"); + kfree(journal); + return NULL; + } + bh = getblk(journal->j_dev, blocknr, journal->j_blocksize); J_ASSERT(bh != NULL); journal->j_sb_buffer = bh; @@ -772,6 +798,18 @@ return journal; } +/* + * If the journal init or create aborts, we need to mark the journal + * superblock as being NULL to prevent the journal destroy from writing + * back a bogus superblock. + */ +static void journal_fail_superblock (journal_t *journal) +{ + struct buffer_head *bh = journal->j_sb_buffer; + brelse(bh); + journal->j_sb_buffer = NULL; +} + /* * Given a journal_t structure, initialise the various fields for * startup of a new journaling session. We use this both when creating @@ -817,14 +855,15 @@ int journal_create (journal_t *journal) { - int blocknr; + unsigned long blocknr; struct buffer_head *bh; journal_superblock_t *sb; - int i; + int i, err; if (journal->j_maxlen < JFS_MIN_JOURNAL_BLOCKS) { printk (KERN_ERR "Journal length (%d blocks) too short.\n", journal->j_maxlen); + journal_fail_superblock(journal); return -EINVAL; } @@ -841,7 +880,9 @@ have any blocks on disk beginning with JFS_MAGIC_NUMBER. */ jbd_debug(1, "JBD: Zeroing out journal blocks...\n"); for (i = 0; i < journal->j_maxlen; i++) { - blocknr = journal_bmap(journal, i); + err = journal_bmap(journal, i, &blocknr); + if (err) + return err; bh = getblk(journal->j_dev, blocknr, journal->j_blocksize); wait_on_buffer(bh); memset (bh->b_data, 0, journal->j_blocksize); @@ -851,6 +892,7 @@ mark_buffer_uptodate(bh, 1); __brelse(bh); } + sync_dev(journal->j_dev); jbd_debug(1, "JBD: journal cleared.\n"); @@ -915,7 +957,8 @@ { struct buffer_head *bh; journal_superblock_t *sb; - + int err = -EIO; + bh = journal->j_sb_buffer; J_ASSERT(bh != NULL); @@ -925,16 +968,18 @@ if (!buffer_uptodate(bh)) { printk (KERN_ERR "JBD: IO error reading journal superblock\n"); - return -EIO; + goto out; } } sb = journal->j_superblock; + err = -EINVAL; + if (sb->s_header.h_magic != htonl(JFS_MAGIC_NUMBER) || sb->s_blocksize != htonl(journal->j_blocksize)) { printk(KERN_WARNING "JBD: no valid journal superblock found\n"); - return -EINVAL; + goto out; } switch(ntohl(sb->s_header.h_blocktype)) { @@ -946,17 +991,21 @@ break; default: printk(KERN_WARNING "JBD: unrecognised superblock format ID\n"); - return -EINVAL; + goto out; } if (ntohl(sb->s_maxlen) < journal->j_maxlen) journal->j_maxlen = ntohl(sb->s_maxlen); else if (ntohl(sb->s_maxlen) > journal->j_maxlen) { printk (KERN_WARNING "JBD: journal file too short\n"); - return -EINVAL; + goto out; } return 0; + +out: + journal_fail_superblock(journal); + return err; } /* @@ -1061,7 +1110,10 @@ /* We can now mark the journal as empty. */ journal->j_tail = 0; journal->j_tail_sequence = ++journal->j_transaction_sequence; - journal_update_superblock(journal, 1); + if (journal->j_sb_buffer) { + journal_update_superblock(journal, 1); + brelse(journal->j_sb_buffer); + } if (journal->j_inode) iput(journal->j_inode); @@ -1069,7 +1121,6 @@ journal_destroy_revoke(journal); unlock_journal(journal); - brelse(journal->j_sb_buffer); kfree(journal); MOD_DEC_USE_COUNT; } @@ -1356,11 +1407,16 @@ * progress). */ -/* Quick version for internal journal use (doesn't lock the journal) */ -void __journal_abort (journal_t *journal) +/* Quick version for internal journal use (doesn't lock the journal). + * Aborts hard --- we mark the abort as occurred, but do _nothing_ else, + * and don't attempt to make any other journal updates. */ +void __journal_abort_hard (journal_t *journal) { transaction_t *transaction; + if (journal->j_flags & JFS_ABORT) + return; + printk (KERN_ERR "Aborting journal on device %s.\n", journal_dev_name(journal)); @@ -1370,23 +1426,27 @@ log_start_commit(journal, transaction); } -/* Full version for external use */ -void journal_abort (journal_t *journal, int errno) +/* Soft abort: record the abort error status in the journal superblock, + * but don't do any other IO. */ +void __journal_abort_soft (journal_t *journal, int errno) { - lock_journal(journal); - if (journal->j_flags & JFS_ABORT) - goto out; + return; if (!journal->j_errno) journal->j_errno = errno; - __journal_abort(journal); + __journal_abort_hard(journal); if (errno) journal_update_superblock(journal, 1); +} - out: +/* Full version for external use */ +void journal_abort (journal_t *journal, int errno) +{ + lock_journal(journal); + __journal_abort_soft(journal, errno); unlock_journal(journal); } diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/fs/jbd/recovery.c linux-2.5/fs/jbd/recovery.c --- linux-2.5.1/fs/jbd/recovery.c Fri Nov 9 22:25:04 2001 +++ linux-2.5/fs/jbd/recovery.c Thu Dec 13 16:32:37 2001 @@ -70,7 +70,8 @@ static int do_readahead(journal_t *journal, unsigned int start) { int err; - unsigned int max, nbufs, next, blocknr; + unsigned int max, nbufs, next; + unsigned long blocknr; struct buffer_head *bh; struct buffer_head * bufs[MAXBUF]; @@ -86,12 +87,11 @@ nbufs = 0; for (next = start; next < max; next++) { - blocknr = journal_bmap(journal, next); + err = journal_bmap(journal, next, &blocknr); - if (!blocknr) { + if (err) { printk (KERN_ERR "JBD: bad block at offset %u\n", next); - err = -EIO; goto failed; } @@ -132,19 +132,20 @@ static int jread(struct buffer_head **bhp, journal_t *journal, unsigned int offset) { - unsigned int blocknr; + int err; + unsigned long blocknr; struct buffer_head *bh; *bhp = NULL; J_ASSERT (offset < journal->j_maxlen); - blocknr = journal_bmap(journal, offset); + err = journal_bmap(journal, offset, &blocknr); - if (!blocknr) { + if (err) { printk (KERN_ERR "JBD: bad block at offset %u\n", offset); - return -EIO; + return err; } bh = getblk(journal->j_dev, blocknr, journal->j_blocksize); diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/fs/jbd/revoke.c linux-2.5/fs/jbd/revoke.c --- linux-2.5.1/fs/jbd/revoke.c Fri Nov 9 22:25:04 2001 +++ linux-2.5/fs/jbd/revoke.c Thu Dec 13 16:32:37 2001 @@ -495,6 +495,8 @@ if (!descriptor) { descriptor = journal_get_descriptor_buffer(journal); + if (!descriptor) + return; header = (journal_header_t *) &jh2bh(descriptor)->b_data[0]; header->h_magic = htonl(JFS_MAGIC_NUMBER); header->h_blocktype = htonl(JFS_REVOKE_BLOCK); diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/fs/jbd/transaction.c linux-2.5/fs/jbd/transaction.c --- linux-2.5.1/fs/jbd/transaction.c Fri Nov 9 22:25:04 2001 +++ linux-2.5/fs/jbd/transaction.c Thu Dec 13 16:32:37 2001 @@ -1058,21 +1058,6 @@ JBUFFER_TRACE(jh, "not on a transaction"); __journal_file_buffer(jh, handle->h_transaction, wanted_jlist); } - /* - * We need to mark the buffer dirty and refile it inside the lock to - * protect it from release by journal_try_to_free_buffer() - * - * We set ->b_flushtime to something small enough to typically keep - * kupdate away from the buffer. - * - * We don't need to do a balance_dirty() - __block_commit_write() - * does that. - */ - if (!async && !atomic_set_buffer_dirty(jh2bh(jh))) { - jh2bh(jh)->b_flushtime = - jiffies + journal->j_commit_interval + 1 * HZ; - refile_buffer(jh2bh(jh)); - } no_journal: spin_unlock(&journal_datalist_lock); if (need_brelse) { @@ -1604,8 +1589,6 @@ assert_spin_locked(&journal_datalist_lock); - if (!buffer_jbd(bh)) - return 1; jh = bh2jh(bh); if (buffer_locked(bh) || buffer_dirty(bh)) { diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/fs/jffs/inode-v23.c linux-2.5/fs/jffs/inode-v23.c --- linux-2.5.1/fs/jffs/inode-v23.c Thu Oct 4 22:14:35 2001 +++ linux-2.5/fs/jffs/inode-v23.c Sun Dec 30 20:01:41 2001 @@ -365,7 +365,6 @@ inode->i_ctime = raw_inode->ctime; inode->i_blksize = PAGE_SIZE; inode->i_blocks = (inode->i_size + 511) >> 9; - inode->i_version = 0; f = jffs_find_file(c, raw_inode->ino); @@ -1023,7 +1022,6 @@ from the in-memory file system structures. */ jffs_insert_node(c, del_f, &raw_inode, 0, del_node); - dir->i_version = ++event; dir->i_ctime = dir->i_mtime = CURRENT_TIME; mark_inode_dirty(dir); inode->i_nlink--; diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/fs/jffs2/dir.c linux-2.5/fs/jffs2/dir.c --- linux-2.5.1/fs/jffs2/dir.c Fri Sep 14 21:04:07 2001 +++ linux-2.5/fs/jffs2/dir.c Mon Dec 31 18:05:44 2001 @@ -31,13 +31,14 @@ * provisions above, a recipient may use your version of this file * under either the RHEPL or the GPL. * - * $Id: dir.c,v 1.42 2001/05/24 22:24:39 dwmw2 Exp $ + * $Id: dir.c,v 1.45 2001/12/27 22:43:20 dwmw2 Exp $ * */ #include <linux/kernel.h> #include <linux/slab.h> #include <linux/fs.h> +#include <linux/mtd/compatmac.h> /* For completion */ #include <linux/jffs2.h> #include <linux/jffs2_fs_i.h> #include <linux/jffs2_fs_sb.h> @@ -541,7 +542,7 @@ f = JFFS2_INODE_INFO(inode); - ri->dsize = ri->csize = strlen(target); + inode->i_size = ri->isize = ri->dsize = ri->csize = strlen(target); ri->totlen = sizeof(*ri) + ri->dsize; ri->hdr_crc = crc32(0, ri, sizeof(struct jffs2_unknown_node)-4); @@ -931,20 +932,16 @@ ret = jffs2_do_unlink(old_dir_i, old_dentry, 1); if (ret) { - /* Try to delete the _new_ link to return a clean failure */ - int ret2 = jffs2_do_unlink(new_dir_i, new_dentry, 1); - if (ret2) { - struct jffs2_inode_info *f = JFFS2_INODE_INFO(old_dentry->d_inode); - down(&f->sem); - old_dentry->d_inode->i_nlink = f->inocache->nlink++; - up(&f->sem); + /* Oh shit. We really ought to make a single node which can do both atomically */ + struct jffs2_inode_info *f = JFFS2_INODE_INFO(old_dentry->d_inode); + down(&f->sem); + old_dentry->d_inode->i_nlink = f->inocache->nlink++; + up(&f->sem); - printk(KERN_NOTICE "jffs2_rename(): Link succeeded, unlink failed (old err %d, new err %d). You now have a hard link\n", ret, ret2); - /* Might as well let the VFS know */ - d_instantiate(new_dentry, old_dentry->d_inode); - atomic_inc(&old_dentry->d_inode->i_count); - } - + printk(KERN_NOTICE "jffs2_rename(): Link succeeded, unlink failed (err %d). You now have a hard link\n", ret); + /* Might as well let the VFS know */ + d_instantiate(new_dentry, old_dentry->d_inode); + atomic_inc(&old_dentry->d_inode->i_count); } return ret; } diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/fs/jffs2/readinode.c linux-2.5/fs/jffs2/readinode.c --- linux-2.5.1/fs/jffs2/readinode.c Fri Sep 14 21:04:07 2001 +++ linux-2.5/fs/jffs2/readinode.c Mon Dec 31 18:05:44 2001 @@ -31,7 +31,7 @@ * provisions above, a recipient may use your version of this file * under either the RHEPL or the GPL. * - * $Id: readinode.c,v 1.56 2001/07/26 20:32:39 dwmw2 Exp $ + * $Id: readinode.c,v 1.57 2001/12/27 22:49:46 dwmw2 Exp $ * */ @@ -408,6 +408,12 @@ case S_IFLNK: inode->i_op = &jffs2_symlink_inode_operations; + /* Hack to work around broken isize in old symlink code. + Remove this when dwmw2 comes to his senses and stops + symlinks from being an entirely gratuitous special + case. */ + if (!inode->i_size) + inode->i_size = latest_node.dsize; break; case S_IFDIR: diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/fs/jffs2/write.c linux-2.5/fs/jffs2/write.c --- linux-2.5.1/fs/jffs2/write.c Thu Oct 4 22:13:18 2001 +++ linux-2.5/fs/jffs2/write.c Sun Dec 30 20:01:41 2001 @@ -31,7 +31,7 @@ * provisions above, a recipient may use your version of this file * under either the RHEPL or the GPL. * - * $Id: write.c,v 1.28 2001/05/01 16:25:25 dwmw2 Exp $ + * $Id: write.c,v 1.30 2001/12/30 16:01:11 dwmw2 Exp $ * */ @@ -207,8 +207,6 @@ } raw->flash_offset = flash_ofs; raw->totlen = PAD(ri->totlen); - raw->next_in_ino = f->inocache->nodes; - f->inocache->nodes = raw; raw->next_phys = NULL; fn->ofs = ri->offset; @@ -222,6 +220,14 @@ sizeof(*ri)+datalen, flash_ofs, ret, retlen); /* Mark the space as dirtied */ if (retlen) { + /* Doesn't belong to any inode */ + raw->next_in_ino = NULL; + + /* Don't change raw->size to match retlen. We may have + written the node header already, and only the data will + seem corrupted, in which case the scan would skip over + any node we write before the original intended end of + this node */ jffs2_add_physical_node_ref(c, raw, sizeof(*ri)+datalen, 1); jffs2_mark_node_obsolete(c, raw); } else { @@ -237,6 +243,11 @@ } /* Mark the space used */ jffs2_add_physical_node_ref(c, raw, retlen, 0); + + /* Link into per-inode list */ + raw->next_in_ino = f->inocache->nodes; + f->inocache->nodes = raw; + D1(printk(KERN_DEBUG "jffs2_write_dnode wrote node at 0x%08x with dsize 0x%x, csize 0x%x, node_crc 0x%08x, data_crc 0x%08x, totlen 0x%08x\n", flash_ofs, ri->dsize, ri->csize, ri->node_crc, ri->data_crc, ri->totlen)); if (writelen) *writelen = retlen; diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/fs/minix/inode.c linux-2.5/fs/minix/inode.c --- linux-2.5.1/fs/minix/inode.c Sun Dec 16 20:23:05 2001 +++ linux-2.5/fs/minix/inode.c Thu Dec 27 16:32:31 2001 @@ -126,9 +126,7 @@ struct buffer_head **map; struct minix_super_block *ms; int i, block; - kdev_t dev = s->s_dev; struct inode *root_inode; - unsigned int hblock; struct minix_sb_info *sbi = &s->u.minix_sb; /* N.B. These should be compile-time tests. @@ -138,13 +136,9 @@ if (64 != sizeof(struct minix2_inode)) panic("bad V2 i-node size"); - hblock = get_hardsect_size(dev); - if (hblock > BLOCK_SIZE) + if (!sb_set_blocksize(s, BLOCK_SIZE)) goto out_bad_hblock; - set_blocksize(dev, BLOCK_SIZE); - s->s_blocksize = BLOCK_SIZE; - s->s_blocksize_bits = BLOCK_SIZE_BITS; if (!(bh = sb_bread(s, 1))) goto out_bad_sb; @@ -214,7 +208,7 @@ /* set up enough so that it can read an inode */ s->s_op = &minix_sops; root_inode = iget(s, MINIX_ROOT_INO); - if (!root_inode) + if (!root_inode || is_bad_inode(root_inode)) goto out_no_root; s->s_root = d_alloc_root(root_inode); @@ -264,7 +258,7 @@ out_no_fs: if (!silent) printk("VFS: Can't find a Minix or Minix V2 filesystem on device " - "%s.\n", kdevname(dev)); + "%s.\n", bdevname(s->s_dev)); out_release: brelse(bh); goto out; @@ -353,8 +347,10 @@ int i; raw_inode = minix_V1_raw_inode(inode->i_sb, inode->i_ino, &bh); - if (!raw_inode) + if (!raw_inode) { + make_bad_inode(inode); return; + } inode->i_mode = raw_inode->i_mode; inode->i_uid = (uid_t)raw_inode->i_uid; inode->i_gid = (gid_t)raw_inode->i_gid; @@ -378,8 +374,10 @@ int i; raw_inode = minix_V2_raw_inode(inode->i_sb, inode->i_ino, &bh); - if (!raw_inode) + if (!raw_inode) { + make_bad_inode(inode); return; + } inode->i_mode = raw_inode->i_mode; inode->i_uid = (uid_t)raw_inode->i_uid; inode->i_gid = (gid_t)raw_inode->i_gid; diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/fs/minix/itree_common.c linux-2.5/fs/minix/itree_common.c --- linux-2.5.1/fs/minix/itree_common.c Sun Dec 16 20:23:05 2001 +++ linux-2.5/fs/minix/itree_common.c Thu Dec 27 22:10:28 2001 @@ -141,7 +141,7 @@ } static inline int get_block(struct inode * inode, sector_t block, - struct buffer_head *bh_result, int create) + struct buffer_head *bh, int create) { int err = -EIO; int offsets[DEPTH]; @@ -160,9 +160,7 @@ /* Simplest case - block found, no allocation needed */ if (!partial) { got_it: - bh_result->b_dev = inode->i_dev; - bh_result->b_blocknr = block_to_cpu(chain[depth-1].key); - bh_result->b_state |= (1UL << BH_Mapped); + map_bh(bh, inode->i_sb, block_to_cpu(chain[depth-1].key)); /* Clean up and exit */ partial = chain+depth-1; /* the whole chain */ goto cleanup; @@ -196,7 +194,7 @@ if (splice_branch(inode, chain, partial, left) < 0) goto changed; - bh_result->b_state |= (1UL << BH_New); + bh->b_state |= (1UL << BH_New); goto got_it; changed: diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/fs/msdos/msdosfs_syms.c linux-2.5/fs/msdos/msdosfs_syms.c --- linux-2.5.1/fs/msdos/msdosfs_syms.c Mon Mar 13 20:35:39 2000 +++ linux-2.5/fs/msdos/msdosfs_syms.c Thu Dec 13 16:32:37 2001 @@ -40,3 +40,4 @@ module_init(init_msdos_fs) module_exit(exit_msdos_fs) +MODULE_LICENSE("GPL"); diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/fs/msdos/namei.c linux-2.5/fs/msdos/namei.c --- linux-2.5.1/fs/msdos/namei.c Fri Oct 12 20:48:42 2001 +++ linux-2.5/fs/msdos/namei.c Sun Dec 30 20:01:41 2001 @@ -476,7 +476,7 @@ if (error) goto out; } - new_dir->i_version = ++event; + new_dir->i_version++; /* There we go */ @@ -491,7 +491,7 @@ else MSDOS_I(old_inode)->i_attrs &= ~ATTR_HIDDEN; mark_inode_dirty(old_inode); - old_dir->i_version = ++event; + old_dir->i_version++; old_dir->i_ctime = old_dir->i_mtime = CURRENT_TIME; mark_inode_dirty(old_dir); if (new_inode) { @@ -528,7 +528,7 @@ else MSDOS_I(old_inode)->i_attrs &= ~ATTR_HIDDEN; mark_inode_dirty(old_inode); - old_dir->i_version = ++event; + old_dir->i_version++; old_dir->i_ctime = old_dir->i_mtime = CURRENT_TIME; mark_inode_dirty(old_dir); return 0; diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/fs/namespace.c linux-2.5/fs/namespace.c --- linux-2.5.1/fs/namespace.c Thu Dec 13 08:11:09 2001 +++ linux-2.5/fs/namespace.c Sun Dec 30 20:01:41 2001 @@ -10,27 +10,26 @@ #include <linux/config.h> #include <linux/slab.h> +#include <linux/sched.h> #include <linux/smp_lock.h> #include <linux/init.h> #include <linux/quotaops.h> #include <linux/acct.h> #include <linux/module.h> #include <linux/seq_file.h> +#include <linux/namespace.h> #include <asm/uaccess.h> -struct vfsmount *do_kern_mount(char *type, int flags, char *name, void *data); +struct vfsmount *do_kern_mount(const char *type, int flags, char *name, void *data); int do_remount_sb(struct super_block *sb, int flags, void * data); void kill_super(struct super_block *sb); +int __init init_rootfs(void); static struct list_head *mount_hashtable; static int hash_mask, hash_bits; static kmem_cache_t *mnt_cache; -static LIST_HEAD(vfsmntlist); -static DECLARE_MUTEX(mount_sem); -static struct vfsmount *root_vfsmnt; - static inline unsigned long hash(struct vfsmount *mnt, struct dentry *dentry) { unsigned long tmp = ((unsigned long) mnt / L1_CACHE_BYTES); @@ -96,7 +95,7 @@ while (mnt->mnt_parent != mnt) mnt = mnt->mnt_parent; spin_unlock(&dcache_lock); - return mnt == root_vfsmnt; + return mnt == current->namespace->root; } static void detach_mnt(struct vfsmount *mnt, struct nameidata *old_nd) @@ -164,26 +163,29 @@ /* iterator */ static void *m_start(struct seq_file *m, loff_t *pos) { + struct namespace *n = m->private; struct list_head *p; - loff_t n = *pos; + loff_t l = *pos; - down(&mount_sem); - list_for_each(p, &vfsmntlist) - if (!n--) + down_read(&n->sem); + list_for_each(p, &n->list) + if (!l--) return list_entry(p, struct vfsmount, mnt_list); return NULL; } static void *m_next(struct seq_file *m, void *v, loff_t *pos) { + struct namespace *n = m->private; struct list_head *p = ((struct vfsmount *)v)->mnt_list.next; (*pos)++; - return p==&vfsmntlist ? NULL : list_entry(p, struct vfsmount, mnt_list); + return p==&n->list ? NULL : list_entry(p, struct vfsmount, mnt_list); } static void m_stop(struct seq_file *m, void *v) { - up(&mount_sem); + struct namespace *n = m->private; + up_read(&n->sem); } static inline void mangle(struct seq_file *m, const char *s) @@ -329,7 +331,7 @@ return retval; } - down(&mount_sem); + down_write(¤t->namespace->sem); spin_lock(&dcache_lock); if (atomic_read(&sb->s_active) == 1) { @@ -337,7 +339,7 @@ spin_unlock(&dcache_lock); lock_kernel(); DQUOT_OFF(sb); - acct_auto_close(sb->s_dev); + acct_auto_close(sb); unlock_kernel(); spin_lock(&dcache_lock); } @@ -348,7 +350,7 @@ retval = 0; } spin_unlock(&dcache_lock); - up(&mount_sem); + up_write(¤t->namespace->sem); return retval; } @@ -478,7 +480,7 @@ struct list_head head; attach_mnt(mnt, nd); list_add_tail(&head, &mnt->mnt_list); - list_splice(&head, vfsmntlist.prev); + list_splice(&head, current->namespace->list.prev); mntget(mnt); err = 0; } @@ -505,7 +507,7 @@ if (err) return err; - down(&mount_sem); + down_write(¤t->namespace->sem); err = -EINVAL; if (check_mnt(nd->mnt) && (!recurse || check_mnt(old_nd.mnt))) { err = -ENOMEM; @@ -525,7 +527,7 @@ mntput(mnt); } - up(&mount_sem); + up_write(¤t->namespace->sem); path_release(&old_nd); return err; } @@ -572,7 +574,7 @@ if (err) return err; - down(&mount_sem); + down_write(¤t->namespace->sem); while(d_mountpoint(nd->dentry) && follow_down(&nd->mnt, &nd->dentry)) ; err = -EINVAL; @@ -612,7 +614,7 @@ out1: up(&nd->dentry->d_inode->i_zombie); out: - up(&mount_sem); + up_write(¤t->namespace->sem); if (!err) path_release(&parent_nd); path_release(&old_nd); @@ -622,13 +624,22 @@ static int do_add_mount(struct nameidata *nd, char *type, int flags, int mnt_flags, char *name, void *data) { - struct vfsmount *mnt = do_kern_mount(type, flags, name, data); - int err = PTR_ERR(mnt); + struct vfsmount *mnt; + int err; + + if (!type || !memchr(type, 0, PAGE_SIZE)) + return -EINVAL; + /* we need capabilities... */ + if (!capable(CAP_SYS_ADMIN)) + return -EPERM; + + mnt = do_kern_mount(type, flags, name, data); + err = PTR_ERR(mnt); if (IS_ERR(mnt)) goto out; - down(&mount_sem); + down_write(¤t->namespace->sem); /* Something was mounted here while we slept */ while(d_mountpoint(nd->dentry) && follow_down(&nd->mnt, &nd->dentry)) ; @@ -644,7 +655,7 @@ mnt->mnt_flags = mnt_flags; err = graft_tree(mnt, nd); unlock: - up(&mount_sem); + up_write(¤t->namespace->sem); mntput(mnt); out: return err; @@ -744,6 +755,86 @@ return retval; } +int copy_namespace(int flags, struct task_struct *tsk) +{ + struct namespace *namespace = tsk->namespace; + struct namespace *new_ns; + struct vfsmount *rootmnt = NULL, *pwdmnt = NULL, *altrootmnt = NULL; + struct fs_struct *fs = tsk->fs; + + if (!namespace) + return 0; + + get_namespace(namespace); + + if (! (flags & CLONE_NEWNS)) + return 0; + + if (!capable(CAP_SYS_ADMIN)) { + put_namespace(namespace); + return -EPERM; + } + + new_ns = kmalloc(sizeof(struct namespace *), GFP_KERNEL); + if (!new_ns) + goto out; + + atomic_set(&new_ns->count, 1); + init_rwsem(&new_ns->sem); + new_ns->root = NULL; + INIT_LIST_HEAD(&new_ns->list); + + down_write(&tsk->namespace->sem); + /* First pass: copy the tree topology */ + new_ns->root = copy_tree(namespace->root, namespace->root->mnt_root); + spin_lock(&dcache_lock); + list_add_tail(&new_ns->list, &new_ns->root->mnt_list); + spin_unlock(&dcache_lock); + + /* Second pass: switch the tsk->fs->* elements */ + if (fs) { + struct vfsmount *p, *q; + write_lock(&fs->lock); + + p = namespace->root; + q = new_ns->root; + while (p) { + if (p == fs->rootmnt) { + rootmnt = p; + fs->rootmnt = mntget(q); + } + if (p == fs->pwdmnt) { + pwdmnt = p; + fs->pwdmnt = mntget(q); + } + if (p == fs->altrootmnt) { + altrootmnt = p; + fs->altrootmnt = mntget(q); + } + p = next_mnt(p, namespace->root); + q = next_mnt(q, new_ns->root); + } + write_unlock(&fs->lock); + } + up_write(&tsk->namespace->sem); + + tsk->namespace = new_ns; + + if (rootmnt) + mntput(rootmnt); + if (pwdmnt) + mntput(pwdmnt); + if (altrootmnt) + mntput(altrootmnt); + + put_namespace(namespace); + return 0; + +out: + put_namespace(namespace); + return -ENOMEM; +} + asmlinkage long sys_mount(char * dev_name, char * dir_name, char * type, unsigned long flags, void * data) { @@ -862,7 +953,7 @@ user_nd.mnt = mntget(current->fs->rootmnt); user_nd.dentry = dget(current->fs->root); read_unlock(¤t->fs->lock); - down(&mount_sem); + down_write(¤t->namespace->sem); down(&old_nd.dentry->d_inode->i_zombie); error = -EINVAL; if (!check_mnt(user_nd.mnt)) @@ -907,7 +998,7 @@ path_release(&parent_nd); out2: up(&old_nd.dentry->d_inode->i_zombie); - up(&mount_sem); + up_write(¤t->namespace->sem); path_release(&user_nd); path_release(&old_nd); out1: @@ -920,95 +1011,34 @@ goto out2; } -/* - * Absolutely minimal fake fs - only empty root directory and nothing else. - * In 2.5 we'll use ramfs or tmpfs, but for now it's all we need - just - * something to go with root vfsmount. - */ -static struct inode_operations rootfs_dir_inode_operations; -static struct file_operations rootfs_dir_operations; -static int rootfs_mkdir(struct inode *dir, struct dentry *dentry, int mode) -{ - struct inode * inode = new_inode(dir->i_sb); - int error = -ENOSPC; - if (inode) { - inode->i_mode = S_IFDIR|mode; - inode->i_uid = current->fsuid; - inode->i_gid = current->fsgid; - inode->i_op = &rootfs_dir_inode_operations; - inode->i_fop = &rootfs_dir_operations; - d_instantiate(dentry, inode); - dget(dentry); - error = 0; - } - return error; -} -static int rootfs_mknod(struct inode *dir, struct dentry *dentry, int mode, int dev) -{ - struct inode * inode = new_inode(dir->i_sb); - int error = -ENOSPC; - if (inode) { - inode->i_uid = current->fsuid; - inode->i_gid = current->fsgid; - init_special_inode(inode, mode, dev); - d_instantiate(dentry, inode); - dget(dentry); - error = 0; - } - return error; -} -static int rootfs_unlink(struct inode * dir, struct dentry *dentry) -{ - dentry->d_inode->i_nlink--; - dput(dentry); - return 0; -} -static struct dentry *rootfs_lookup(struct inode *dir, struct dentry *dentry) -{ - d_add(dentry, NULL); - return NULL; -} -static struct file_operations rootfs_dir_operations = { - read: generic_read_dir, - readdir: dcache_readdir, -}; -static struct inode_operations rootfs_dir_inode_operations = { - lookup: rootfs_lookup, - mkdir: rootfs_mkdir, - mknod: rootfs_mknod, - unlink: rootfs_unlink, -}; -static struct super_block *rootfs_read_super(struct super_block * sb, void * data, int silent) +static void __init init_mount_tree(void) { - struct inode * inode; - struct dentry * root; - static struct super_operations s_ops = {}; - sb->s_op = &s_ops; - inode = new_inode(sb); - if (!inode) - return NULL; - inode->i_mode = S_IFDIR|0555; - inode->i_uid = inode->i_gid = 0; - inode->i_op = &rootfs_dir_inode_operations; - inode->i_fop = &rootfs_dir_operations; - root = d_alloc_root(inode); - if (!root) { - iput(inode); - return NULL; + struct vfsmount *mnt; + struct namespace *namespace; + struct task_struct *p; + + mnt = do_kern_mount("rootfs", 0, "rootfs", NULL); + if (IS_ERR(mnt)) + panic("Can't create rootfs"); + namespace = kmalloc(sizeof(*namespace), GFP_KERNEL); + if (!namespace) + panic("Can't allocate initial namespace"); + atomic_set(&namespace->count, 1); + INIT_LIST_HEAD(&namespace->list); + init_rwsem(&namespace->sem); + list_add(&mnt->mnt_list, &namespace->list); + namespace->root = mnt; + + init_task.namespace = namespace; + read_lock(&tasklist_lock); + for_each_task(p) { + get_namespace(namespace); + p->namespace = namespace; } - sb->s_root = root; - return sb; -} -static DECLARE_FSTYPE(root_fs_type, "rootfs", rootfs_read_super, FS_NOMOUNT); + read_unlock(&tasklist_lock); -static void __init init_mount_tree(void) -{ - register_filesystem(&root_fs_type); - root_vfsmnt = do_kern_mount("rootfs", 0, "rootfs", NULL); - if (IS_ERR(root_vfsmnt)) - panic("can't allocate root vfsmount"); - set_fs_pwd(current->fs, root_vfsmnt, root_vfsmnt->mnt_root); - set_fs_root(current->fs, root_vfsmnt, root_vfsmnt->mnt_root); + set_fs_pwd(current->fs, namespace->root, namespace->root->mnt_root); + set_fs_root(current->fs, namespace->root, namespace->root->mnt_root); } void __init mnt_init(unsigned long mempages) @@ -1066,5 +1096,6 @@ d++; i--; } while (i); + init_rootfs(); init_mount_tree(); } diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/fs/ncpfs/symlink.c linux-2.5/fs/ncpfs/symlink.c --- linux-2.5.1/fs/ncpfs/symlink.c Fri Dec 29 22:07:57 2000 +++ linux-2.5/fs/ncpfs/symlink.c Sun Dec 30 21:17:30 2001 @@ -21,7 +21,6 @@ #ifdef CONFIG_NCPFS_EXTRAS #include <asm/uaccess.h> -#include <asm/segment.h> #include <linux/errno.h> #include <linux/fs.h> diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/fs/nfs/file.c linux-2.5/fs/nfs/file.c --- linux-2.5.1/fs/nfs/file.c Sun Sep 23 16:48:01 2001 +++ linux-2.5/fs/nfs/file.c Fri Dec 28 02:12:11 2001 @@ -161,15 +161,10 @@ static int nfs_commit_write(struct file *file, struct page *page, unsigned offset, unsigned to) { long status; - loff_t pos = ((loff_t)page->index<<PAGE_CACHE_SHIFT) + to; - struct inode *inode = page->mapping->host; lock_kernel(); status = nfs_updatepage(file, page, offset, to-offset); unlock_kernel(); - /* most likely it's already done. CHECKME */ - if (pos > inode->i_size) - inode->i_size = pos; return status; } diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/fs/nfs/inode.c linux-2.5/fs/nfs/inode.c --- linux-2.5.1/fs/nfs/inode.c Sat Nov 24 21:17:18 2001 +++ linux-2.5/fs/nfs/inode.c Sun Dec 30 23:23:27 2001 @@ -107,17 +107,10 @@ inode->i_rdev = 0; /* We can't support UPDATE_ATIME(), since the server will reset it */ inode->i_flags |= S_NOATIME; - NFS_FILEID(inode) = 0; - NFS_FSID(inode) = 0; - NFS_FLAGS(inode) = 0; INIT_LIST_HEAD(&inode->u.nfs_i.read); INIT_LIST_HEAD(&inode->u.nfs_i.dirty); INIT_LIST_HEAD(&inode->u.nfs_i.commit); INIT_LIST_HEAD(&inode->u.nfs_i.writeback); - inode->u.nfs_i.nread = 0; - inode->u.nfs_i.ndirty = 0; - inode->u.nfs_i.ncommit = 0; - inode->u.nfs_i.npages = 0; NFS_CACHEINV(inode); NFS_ATTRTIMEO(inode) = NFS_MINATTRTIMEO(inode); NFS_ATTRTIMEO_UPDATE(inode) = jiffies; @@ -655,19 +648,6 @@ inode->i_op = &nfs_symlink_inode_operations; else init_special_inode(inode, inode->i_mode, fattr->rdev); - /* - * Preset the size and mtime, as there's no need - * to invalidate the caches. - */ - inode->i_size = nfs_size_to_loff_t(fattr->size); - inode->i_mtime = nfs_time_to_secs(fattr->mtime); - inode->i_atime = nfs_time_to_secs(fattr->atime); - inode->i_ctime = nfs_time_to_secs(fattr->ctime); - NFS_CACHE_CTIME(inode) = fattr->ctime; - NFS_CACHE_MTIME(inode) = fattr->mtime; - NFS_CACHE_ISIZE(inode) = fattr->size; - NFS_ATTRTIMEO(inode) = NFS_MINATTRTIMEO(inode); - NFS_ATTRTIMEO_UPDATE(inode) = jiffies; memcpy(&inode->u.nfs_i.fh, fh, sizeof(inode->u.nfs_i.fh)); } nfs_refresh_inode(inode, fattr); @@ -697,6 +677,9 @@ return 0; if (memcmp(&inode->u.nfs_i.fh, fh, sizeof(inode->u.nfs_i.fh)) != 0) return 0; + /* Force an attribute cache update if inode->i_count == 0 */ + if (!atomic_read(&inode->i_count)) + NFS_CACHEINV(inode); return 1; } @@ -797,7 +780,9 @@ if (!S_ISREG(inode->i_mode)) attr->ia_valid &= ~ATTR_SIZE; + filemap_fdatasync(inode->i_mapping); error = nfs_wb_all(inode); + filemap_fdatawait(inode->i_mapping); if (error) goto out; @@ -825,6 +810,8 @@ fattr.pre_ctime = NFS_CACHE_CTIME(inode); fattr.valid |= NFS_ATTR_WCC; } + /* Force an attribute cache update */ + NFS_CACHEINV(inode); error = nfs_refresh_inode(inode, &fattr); out: return error; @@ -966,6 +953,34 @@ } /* + * nfs_fattr_obsolete - Test if attribute data is newer than cached data + * @inode: inode + * @fattr: attributes to test + * + * Avoid stuffing the attribute cache with obsolete information. + * We always accept updates if the attribute cache timed out, or if + * fattr->ctime is newer than our cached value. + * If fattr->ctime matches the cached value, we still accept the update + * if it increases the file size. + */ +static inline +int nfs_fattr_obsolete(struct inode *inode, struct nfs_fattr *fattr) +{ + s64 cdif; + + if (time_after(jiffies, NFS_READTIME(inode)+NFS_ATTRTIMEO(inode))) + goto out_valid; + if ((cdif = (s64)fattr->ctime - (s64)NFS_CACHE_CTIME(inode)) > 0) + goto out_valid; + /* Ugh... */ + if (cdif == 0 && fattr->size > NFS_CACHE_ISIZE(inode)) + goto out_valid; + return -1; + out_valid: + return 0; +} + +/* * Many nfs protocol calls return the new file attributes after * an operation. Here we update the inode to reflect the state * of the server's inode. @@ -982,6 +997,7 @@ { __u64 new_size, new_mtime; loff_t new_isize; + time_t new_atime; int invalid = 0; dfprintk(VFS, "NFS: refresh_inode(%x/%ld ct=%d info=0x%x)\n", @@ -1012,6 +1028,11 @@ */ NFS_READTIME(inode) = jiffies; + new_atime = nfs_time_to_secs(fattr->atime); + /* Avoid races */ + if (nfs_fattr_obsolete(inode, fattr)) + goto out_nochange; + /* * Note: NFS_CACHE_ISIZE(inode) reflects the state of the cache. * NOT inode->i_size!!! @@ -1056,7 +1077,7 @@ NFS_CACHE_CTIME(inode) = fattr->ctime; inode->i_ctime = nfs_time_to_secs(fattr->ctime); - inode->i_atime = nfs_time_to_secs(fattr->atime); + inode->i_atime = new_atime; NFS_CACHE_MTIME(inode) = new_mtime; inode->i_mtime = nfs_time_to_secs(new_mtime); @@ -1093,7 +1114,10 @@ if (invalid) nfs_zap_caches(inode); return 0; - + out_nochange: + if (new_atime - inode->i_atime > 0) + inode->i_atime = new_atime; + return 0; out_changed: /* * Big trouble! The inode has become a different object. diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/fs/nfs/nfs2xdr.c linux-2.5/fs/nfs/nfs2xdr.c --- linux-2.5.1/fs/nfs/nfs2xdr.c Sat Nov 3 01:40:09 2001 +++ linux-2.5/fs/nfs/nfs2xdr.c Mon Dec 17 14:29:55 2001 @@ -270,14 +270,12 @@ count = ntohl(*p++); hdrlen = (u8 *) p - (u8 *) iov->iov_base; - recvd = req->rq_rlen - hdrlen; - if (p != iov[req->rq_rnr-1].iov_base) { - /* Unexpected reply header size. Punt. - * XXX: Move iovec contents to align data on page - * boundary and adjust RPC header size guess */ - printk(KERN_WARNING "NFS: Odd RPC header size in read reply: %d\n", hdrlen); - return -errno_NFSERR_IO; + if (iov->iov_len > hdrlen) { + dprintk("NFS: READ header is short. iovec will be shifted.\n"); + xdr_shift_iovec(iov, req->rq_rnr, iov->iov_len - hdrlen); } + + recvd = req->rq_rlen - hdrlen; if (count > recvd) { printk(KERN_WARNING "NFS: server cheating in read reply: " "count %d > recvd %d\n", count, recvd); @@ -448,27 +446,23 @@ nfs_xdr_readdirres(struct rpc_rqst *req, u32 *p, struct nfs_readdirres *res) { struct iovec *iov = req->rq_rvec; + int hdrlen; int status, nr; u32 *end, *entry, len; if ((status = ntohl(*p++))) return -nfs_stat_to_errno(status); - if ((void *) p != ((u8 *) iov->iov_base+iov->iov_len)) { - /* Unexpected reply header size. Punt. */ - printk(KERN_WARNING "NFS: Odd RPC header size in readdirres reply\n"); - return -errno_NFSERR_IO; + + hdrlen = (u8 *) p - (u8 *) iov->iov_base; + if (iov->iov_len > hdrlen) { + dprintk("NFS: READDIR header is short. iovec will be shifted.\n"); + xdr_shift_iovec(iov, req->rq_rnr, iov->iov_len - hdrlen); } + /* Get start and end address of XDR data */ p = (u32 *) iov[1].iov_base; end = (u32 *) ((u8 *) p + iov[1].iov_len); - - /* Get start and end of dirent buffer */ - if (res->buffer != p) { - printk(KERN_ERR "NFS: Bad result buffer in readdir\n"); - return -errno_NFSERR_IO; - } - for (nr = 0; *p++; nr++) { entry = p - 1; if (p + 2 > end) @@ -598,13 +592,21 @@ static int nfs_xdr_readlinkres(struct rpc_rqst *req, u32 *p, struct nfs_readlinkres *res) { + struct iovec *iov = req->rq_rvec; u32 *strlen; char *string; + int hdrlen; int status; unsigned int len; if ((status = ntohl(*p++))) return -nfs_stat_to_errno(status); + hdrlen = (u8 *) p - (u8 *) iov->iov_base; + if (iov->iov_len > hdrlen) { + dprintk("NFS: READLINK header is short. iovec will be shifted.\n"); + xdr_shift_iovec(iov, req->rq_rnr, iov->iov_len - hdrlen); + } + strlen = (u32*)res->buffer; /* Convert length of symlink */ len = ntohl(*strlen); diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/fs/nfs/nfs3proc.c linux-2.5/fs/nfs/nfs3proc.c --- linux-2.5.1/fs/nfs/nfs3proc.c Mon Oct 1 20:45:37 2001 +++ linux-2.5/fs/nfs/nfs3proc.c Thu Dec 13 16:32:37 2001 @@ -17,6 +17,37 @@ #define NFSDBG_FACILITY NFSDBG_PROC +/* A wrapper to handle the EJUKEBOX error message */ +static int +nfs3_rpc_wrapper(struct rpc_clnt *clnt, struct rpc_message *msg, int flags) +{ + sigset_t oldset; + int res; + rpc_clnt_sigmask(clnt, &oldset); + do { + res = rpc_call_sync(clnt, msg, flags); + if (res != -EJUKEBOX) + break; + set_current_state(TASK_INTERRUPTIBLE); + schedule_timeout(NFS_JUKEBOX_RETRY_TIME); + res = -ERESTARTSYS; + } while (!signalled()); + rpc_clnt_sigunmask(clnt, &oldset); + return res; +} + +static inline int +nfs3_rpc_call_wrapper(struct rpc_clnt *clnt, u32 proc, void *argp, void *resp, int flags) +{ + struct rpc_message msg = { proc, argp, resp, NULL }; + return nfs3_rpc_wrapper(clnt, &msg, flags); +} + +#define rpc_call(clnt, proc, argp, resp, flags) \ + nfs3_rpc_call_wrapper(clnt, proc, argp, resp, flags) +#define rpc_call_sync(clnt, msg, flags) \ + nfs3_rpc_wrapper(clnt, msg, flags) + /* * Bare-bones access to getattr: this is for nfs_read_super. */ diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/fs/nfs/pagelist.c linux-2.5/fs/nfs/pagelist.c --- linux-2.5.1/fs/nfs/pagelist.c Fri Nov 9 22:28:15 2001 +++ linux-2.5/fs/nfs/pagelist.c Thu Dec 13 16:32:37 2001 @@ -187,7 +187,7 @@ BUG(); } #endif - for (pos = head->prev; pos != head; pos = pos->prev) { + list_for_each_prev(pos, head) { struct nfs_page *p = nfs_list_entry(pos); if (page_index(p->wb_page) < pg_idx) break; diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/fs/nfs/read.c linux-2.5/fs/nfs/read.c --- linux-2.5.1/fs/nfs/read.c Fri Nov 9 22:28:15 2001 +++ linux-2.5/fs/nfs/read.c Mon Dec 17 14:29:55 2001 @@ -397,20 +397,29 @@ { struct nfs_read_data *data = (struct nfs_read_data *) task->tk_calldata; struct inode *inode = data->inode; - int count = data->res.count; + unsigned int count = data->res.count; dprintk("NFS: %4d nfs_readpage_result, (status %d)\n", task->tk_pid, task->tk_status); + if (nfs_async_handle_jukebox(task)) + return; + nfs_refresh_inode(inode, &data->fattr); while (!list_empty(&data->pages)) { struct nfs_page *req = nfs_list_entry(data->pages.next); struct page *page = req->wb_page; nfs_list_remove_request(req); - if (task->tk_status >= 0 && count >= 0) { + if (task->tk_status >= 0) { + if (count < PAGE_CACHE_SIZE) { + char *p = kmap(page); + memset(p + count, 0, PAGE_CACHE_SIZE - count); + kunmap(page); + count = 0; + } else + count -= PAGE_CACHE_SIZE; SetPageUptodate(page); - count -= PAGE_CACHE_SIZE; } else SetPageError(page); flush_dcache_page(page); diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/fs/nfs/unlink.c linux-2.5/fs/nfs/unlink.c --- linux-2.5.1/fs/nfs/unlink.c Thu Aug 16 16:39:37 2001 +++ linux-2.5/fs/nfs/unlink.c Thu Dec 13 16:32:37 2001 @@ -123,6 +123,8 @@ struct dentry *dir = data->dir; struct inode *dir_i; + if (nfs_async_handle_jukebox(task)) + return; if (!dir) return; dir_i = dir->d_inode; diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/fs/nfs/write.c linux-2.5/fs/nfs/write.c --- linux-2.5.1/fs/nfs/write.c Tue Nov 20 22:18:50 2001 +++ linux-2.5/fs/nfs/write.c Sun Dec 30 20:01:41 2001 @@ -49,7 +49,7 @@ #include <linux/config.h> #include <linux/types.h> #include <linux/slab.h> -#include <linux/swap.h> +#include <linux/mm.h> #include <linux/pagemap.h> #include <linux/file.h> @@ -213,6 +213,7 @@ unsigned int offset, unsigned int count) { struct nfs_page *req; + loff_t end; int status; req = nfs_update_request(file, inode, page, offset, count); @@ -223,6 +224,10 @@ req->wb_cred = get_rpccred(NFS_I(inode)->mm_cred); nfs_unlock_request(req); nfs_strategy(inode); + end = ((loff_t)page->index<<PAGE_CACHE_SHIFT) + (loff_t)(offset + count); + if (inode->i_size < end) + inode->i_size = end; + out: return status; } @@ -305,18 +310,30 @@ /* * Insert a write request into an inode + * Note: we sort the list in order to be able to optimize nfs_find_request() + * & co. for the 'write append' case. For 2.5 we may want to consider + * some form of hashing so as to perform well on random writes. */ static inline void nfs_inode_add_request(struct inode *inode, struct nfs_page *req) { + struct list_head *pos, *head; + unsigned long pg_idx = page_index(req->wb_page); + if (!list_empty(&req->wb_hash)) return; if (!NFS_WBACK_BUSY(req)) printk(KERN_ERR "NFS: unlocked request attempted hashed!\n"); - if (list_empty(&inode->u.nfs_i.writeback)) + head = &inode->u.nfs_i.writeback; + if (list_empty(head)) igrab(inode); + list_for_each_prev(pos, head) { + struct nfs_page *entry = nfs_inode_wb_entry(pos); + if (page_index(entry->wb_page) < pg_idx) + break; + } inode->u.nfs_i.npages++; - list_add(&req->wb_hash, &inode->u.nfs_i.writeback); + list_add(&req->wb_hash, pos); req->wb_count++; } @@ -354,15 +371,18 @@ static inline struct nfs_page * _nfs_find_request(struct inode *inode, struct page *page) { - struct list_head *head, *next; + struct list_head *head, *pos; + unsigned long pg_idx = page_index(page); head = &inode->u.nfs_i.writeback; - next = head->next; - while (next != head) { - struct nfs_page *req = nfs_inode_wb_entry(next); - next = next->next; - if (page_index(req->wb_page) != page_index(page)) + list_for_each_prev(pos, head) { + struct nfs_page *req = nfs_inode_wb_entry(pos); + unsigned long found_idx = page_index(req->wb_page); + + if (pg_idx < found_idx) continue; + if (pg_idx != found_idx) + break; req->wb_count++; return req; } @@ -444,20 +464,20 @@ else idx_end = idx_start + npages - 1; - spin_lock(&nfs_wreq_lock); head = &inode->u.nfs_i.writeback; - p = head->next; - while (p != head) { + restart: + spin_lock(&nfs_wreq_lock); + list_for_each_prev(p, head) { unsigned long pg_idx; struct nfs_page *req = nfs_inode_wb_entry(p); - p = p->next; - if (file && req->wb_file != file) continue; pg_idx = page_index(req->wb_page); - if (pg_idx < idx_start || pg_idx > idx_end) + if (pg_idx < idx_start) + break; + if (pg_idx > idx_end) continue; if (!NFS_WBACK_BUSY(req)) @@ -468,9 +488,8 @@ nfs_release_request(req); if (error < 0) return error; - spin_lock(&nfs_wreq_lock); - p = head->next; res++; + goto restart; } spin_unlock(&nfs_wreq_lock); return res; @@ -781,6 +800,7 @@ struct dentry *dentry = file->f_dentry; struct inode *inode = dentry->d_inode; struct nfs_page *req; + loff_t end; int status = 0; dprintk("NFS: nfs_updatepage(%s/%s %d@%Ld)\n", @@ -812,6 +832,10 @@ goto done; status = 0; + end = ((loff_t)page->index<<PAGE_CACHE_SHIFT) + (loff_t)(offset + count); + if (inode->i_size < end) + inode->i_size = end; + /* If we wrote past the end of the page. * Call the strategy routine so it can send out a bunch * of requests. @@ -991,6 +1015,9 @@ dprintk("NFS: %4d nfs_writeback_done (status %d)\n", task->tk_pid, task->tk_status); + if (nfs_async_handle_jukebox(task)) + return; + /* We can't handle that yet but we check for it nevertheless */ if (resp->count < argp->count && task->tk_status >= 0) { static unsigned long complain; @@ -1183,6 +1210,9 @@ dprintk("NFS: %4d nfs_commit_done (status %d)\n", task->tk_pid, task->tk_status); + + if (nfs_async_handle_jukebox(task)) + return; nfs_write_attributes(inode, resp->fattr); while (!list_empty(&data->pages)) { diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/fs/nfsd/export.c linux-2.5/fs/nfsd/export.c --- linux-2.5.1/fs/nfsd/export.c Thu Oct 4 05:57:36 2001 +++ linux-2.5/fs/nfsd/export.c Sun Dec 30 20:01:41 2001 @@ -16,6 +16,7 @@ #include <linux/unistd.h> #include <linux/slab.h> +#include <linux/sched.h> #include <linux/stat.h> #include <linux/in.h> diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/fs/nfsd/vfs.c linux-2.5/fs/nfsd/vfs.c --- linux-2.5.1/fs/nfsd/vfs.c Fri Oct 5 19:23:53 2001 +++ linux-2.5/fs/nfsd/vfs.c Thu Dec 13 16:32:37 2001 @@ -560,9 +560,13 @@ return NULL; rap = frap; ra = *frap; - memset(ra, 0, sizeof(*ra)); ra->p_dev = dev; ra->p_ino = ino; + ra->p_reada = 0; + ra->p_ramax = 0; + ra->p_raend = 0; + ra->p_ralen = 0; + ra->p_rawin = 0; found: if (rap != &raparm_cache) { *rap = ra->p_next; diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/fs/nls/nls_base.c linux-2.5/fs/nls/nls_base.c --- linux-2.5.1/fs/nls/nls_base.c Fri Feb 9 19:29:44 2001 +++ linux-2.5/fs/nls/nls_base.c Sun Dec 30 20:01:41 2001 @@ -13,7 +13,7 @@ #include <linux/string.h> #include <linux/config.h> #include <linux/nls.h> -#include <linux/slab.h> +#include <linux/kernel.h> #include <linux/errno.h> #ifdef CONFIG_KMOD #include <linux/kmod.h> diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/fs/nls/nls_big5.c linux-2.5/fs/nls/nls_big5.c --- linux-2.5.1/fs/nls/nls_big5.c Mon Oct 16 19:58:51 2000 +++ linux-2.5/fs/nls/nls_big5.c Thu Dec 13 22:09:29 2001 @@ -42,6 +42,7 @@ module_init(init_nls_big5) module_exit(exit_nls_big5) +MODULE_LICENSE("Dual BSD/GPL"); /* * Overrides for Emacs so that we follow Linus's tabbing style. diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/fs/nls/nls_cp1251.c linux-2.5/fs/nls/nls_cp1251.c --- linux-2.5.1/fs/nls/nls_cp1251.c Sun Sep 30 19:26:08 2001 +++ linux-2.5/fs/nls/nls_cp1251.c Thu Dec 13 16:32:37 2001 @@ -315,4 +315,4 @@ * c-continued-brace-offset: 0 * End: */ -MODULE_LICENSE("BSD without advertising clause"); +MODULE_LICENSE("Dual BSD/GPL"); diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/fs/nls/nls_cp1255.c linux-2.5/fs/nls/nls_cp1255.c --- linux-2.5.1/fs/nls/nls_cp1255.c Sun Sep 30 19:26:08 2001 +++ linux-2.5/fs/nls/nls_cp1255.c Thu Dec 13 16:32:37 2001 @@ -396,4 +396,4 @@ * c-continued-brace-offset: 0 * End: */ -MODULE_LICENSE("BSD without advertising clause"); +MODULE_LICENSE("Dual BSD/GPL"); diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/fs/nls/nls_cp437.c linux-2.5/fs/nls/nls_cp437.c --- linux-2.5.1/fs/nls/nls_cp437.c Sun Sep 30 19:26:08 2001 +++ linux-2.5/fs/nls/nls_cp437.c Thu Dec 13 16:32:37 2001 @@ -401,4 +401,4 @@ * c-continued-brace-offset: 0 * End: */ -MODULE_LICENSE("BSD without advertising clause"); +MODULE_LICENSE("Dual BSD/GPL"); diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/fs/nls/nls_cp737.c linux-2.5/fs/nls/nls_cp737.c --- linux-2.5.1/fs/nls/nls_cp737.c Sun Sep 30 19:26:08 2001 +++ linux-2.5/fs/nls/nls_cp737.c Thu Dec 13 16:32:37 2001 @@ -364,4 +364,4 @@ * c-continued-brace-offset: 0 * End: */ -MODULE_LICENSE("BSD without advertising clause"); +MODULE_LICENSE("Dual BSD/GPL"); diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/fs/nls/nls_cp775.c linux-2.5/fs/nls/nls_cp775.c --- linux-2.5.1/fs/nls/nls_cp775.c Sun Sep 30 19:26:08 2001 +++ linux-2.5/fs/nls/nls_cp775.c Thu Dec 13 16:32:37 2001 @@ -333,4 +333,4 @@ * c-continued-brace-offset: 0 * End: */ -MODULE_LICENSE("BSD without advertising clause"); +MODULE_LICENSE("Dual BSD/GPL"); diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/fs/nls/nls_cp850.c linux-2.5/fs/nls/nls_cp850.c --- linux-2.5.1/fs/nls/nls_cp850.c Sun Sep 30 19:26:08 2001 +++ linux-2.5/fs/nls/nls_cp850.c Thu Dec 13 16:32:37 2001 @@ -329,4 +329,4 @@ * c-continued-brace-offset: 0 * End: */ -MODULE_LICENSE("BSD without advertising clause"); +MODULE_LICENSE("Dual BSD/GPL"); diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/fs/nls/nls_cp852.c linux-2.5/fs/nls/nls_cp852.c --- linux-2.5.1/fs/nls/nls_cp852.c Sun Sep 30 19:26:08 2001 +++ linux-2.5/fs/nls/nls_cp852.c Thu Dec 13 16:32:37 2001 @@ -351,4 +351,4 @@ * c-continued-brace-offset: 0 * End: */ -MODULE_LICENSE("BSD without advertising clause"); +MODULE_LICENSE("Dual BSD/GPL"); diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/fs/nls/nls_cp855.c linux-2.5/fs/nls/nls_cp855.c --- linux-2.5.1/fs/nls/nls_cp855.c Sun Sep 30 19:26:08 2001 +++ linux-2.5/fs/nls/nls_cp855.c Thu Dec 13 16:32:37 2001 @@ -313,4 +313,4 @@ * c-continued-brace-offset: 0 * End: */ -MODULE_LICENSE("BSD without advertising clause"); +MODULE_LICENSE("Dual BSD/GPL"); diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/fs/nls/nls_cp857.c linux-2.5/fs/nls/nls_cp857.c --- linux-2.5.1/fs/nls/nls_cp857.c Sun Sep 30 19:26:08 2001 +++ linux-2.5/fs/nls/nls_cp857.c Thu Dec 13 16:32:37 2001 @@ -315,4 +315,4 @@ * c-continued-brace-offset: 0 * End: */ -MODULE_LICENSE("BSD without advertising clause"); +MODULE_LICENSE("Dual BSD/GPL"); diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/fs/nls/nls_cp860.c linux-2.5/fs/nls/nls_cp860.c --- linux-2.5.1/fs/nls/nls_cp860.c Sun Sep 30 19:26:08 2001 +++ linux-2.5/fs/nls/nls_cp860.c Thu Dec 13 16:32:37 2001 @@ -378,4 +378,4 @@ * c-continued-brace-offset: 0 * End: */ -MODULE_LICENSE("BSD without advertising clause"); +MODULE_LICENSE("Dual BSD/GPL"); diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/fs/nls/nls_cp861.c linux-2.5/fs/nls/nls_cp861.c --- linux-2.5.1/fs/nls/nls_cp861.c Sun Sep 30 19:26:08 2001 +++ linux-2.5/fs/nls/nls_cp861.c Thu Dec 13 16:32:37 2001 @@ -401,4 +401,4 @@ * c-continued-brace-offset: 0 * End: */ -MODULE_LICENSE("BSD without advertising clause"); +MODULE_LICENSE("Dual BSD/GPL"); diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/fs/nls/nls_cp862.c linux-2.5/fs/nls/nls_cp862.c --- linux-2.5.1/fs/nls/nls_cp862.c Sun Sep 30 19:26:08 2001 +++ linux-2.5/fs/nls/nls_cp862.c Thu Dec 13 16:32:37 2001 @@ -435,4 +435,4 @@ * c-continued-brace-offset: 0 * End: */ -MODULE_LICENSE("BSD without advertising clause"); +MODULE_LICENSE("Dual BSD/GPL"); diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/fs/nls/nls_cp863.c linux-2.5/fs/nls/nls_cp863.c --- linux-2.5.1/fs/nls/nls_cp863.c Sun Sep 30 19:26:08 2001 +++ linux-2.5/fs/nls/nls_cp863.c Thu Dec 13 16:32:37 2001 @@ -395,4 +395,4 @@ * c-continued-brace-offset: 0 * End: */ -MODULE_LICENSE("BSD without advertising clause"); +MODULE_LICENSE("Dual BSD/GPL"); diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/fs/nls/nls_cp864.c linux-2.5/fs/nls/nls_cp864.c --- linux-2.5.1/fs/nls/nls_cp864.c Sun Sep 30 19:26:08 2001 +++ linux-2.5/fs/nls/nls_cp864.c Thu Dec 13 16:32:37 2001 @@ -421,4 +421,4 @@ * c-continued-brace-offset: 0 * End: */ -MODULE_LICENSE("BSD without advertising clause"); +MODULE_LICENSE("Dual BSD/GPL"); diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/fs/nls/nls_cp865.c linux-2.5/fs/nls/nls_cp865.c --- linux-2.5.1/fs/nls/nls_cp865.c Sun Sep 30 19:26:08 2001 +++ linux-2.5/fs/nls/nls_cp865.c Thu Dec 13 16:32:37 2001 @@ -401,4 +401,4 @@ * c-continued-brace-offset: 0 * End: */ -MODULE_LICENSE("BSD without advertising clause"); +MODULE_LICENSE("Dual BSD/GPL"); diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/fs/nls/nls_cp866.c linux-2.5/fs/nls/nls_cp866.c --- linux-2.5.1/fs/nls/nls_cp866.c Sun Sep 30 19:26:08 2001 +++ linux-2.5/fs/nls/nls_cp866.c Thu Dec 13 16:32:37 2001 @@ -319,4 +319,4 @@ * c-continued-brace-offset: 0 * End: */ -MODULE_LICENSE("BSD without advertising clause"); +MODULE_LICENSE("Dual BSD/GPL"); diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/fs/nls/nls_cp869.c linux-2.5/fs/nls/nls_cp869.c --- linux-2.5.1/fs/nls/nls_cp869.c Sun Sep 30 19:26:08 2001 +++ linux-2.5/fs/nls/nls_cp869.c Thu Dec 13 16:32:37 2001 @@ -329,4 +329,4 @@ * c-continued-brace-offset: 0 * End: */ -MODULE_LICENSE("BSD without advertising clause"); +MODULE_LICENSE("Dual BSD/GPL"); diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/fs/nls/nls_cp874.c linux-2.5/fs/nls/nls_cp874.c --- linux-2.5.1/fs/nls/nls_cp874.c Sun Sep 30 19:26:08 2001 +++ linux-2.5/fs/nls/nls_cp874.c Thu Dec 13 16:32:37 2001 @@ -287,4 +287,4 @@ * c-continued-brace-offset: 0 * End: */ -MODULE_LICENSE("BSD without advertising clause"); +MODULE_LICENSE("Dual BSD/GPL"); diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/fs/nls/nls_cp932.c linux-2.5/fs/nls/nls_cp932.c --- linux-2.5.1/fs/nls/nls_cp932.c Fri Apr 6 17:51:19 2001 +++ linux-2.5/fs/nls/nls_cp932.c Thu Dec 13 22:09:29 2001 @@ -7904,6 +7904,7 @@ module_init(init_nls_cp932) module_exit(exit_nls_cp932) +MODULE_LICENSE("Dual BSD/GPL"); /* * Overrides for Emacs so that we follow Linus's tabbing style. diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/fs/nls/nls_cp936.c linux-2.5/fs/nls/nls_cp936.c --- linux-2.5.1/fs/nls/nls_cp936.c Fri Jul 21 22:19:51 2000 +++ linux-2.5/fs/nls/nls_cp936.c Thu Dec 13 22:09:29 2001 @@ -11024,6 +11024,7 @@ module_init(init_nls_cp936) module_exit(exit_nls_cp936) +MODULE_LICENSE("Dual BSD/GPL"); /* * Overrides for Emacs so that we follow Linus's tabbing style. diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/fs/nls/nls_cp949.c linux-2.5/fs/nls/nls_cp949.c --- linux-2.5.1/fs/nls/nls_cp949.c Fri Jul 21 22:19:51 2000 +++ linux-2.5/fs/nls/nls_cp949.c Thu Dec 13 22:09:29 2001 @@ -13941,6 +13941,7 @@ module_init(init_nls_cp949) module_exit(exit_nls_cp949) +MODULE_LICENSE("Dual BSD/GPL"); /* * Overrides for Emacs so that we follow Linus's tabbing style. diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/fs/nls/nls_cp950.c linux-2.5/fs/nls/nls_cp950.c --- linux-2.5.1/fs/nls/nls_cp950.c Fri Jul 21 22:19:51 2000 +++ linux-2.5/fs/nls/nls_cp950.c Thu Dec 13 22:09:30 2001 @@ -9480,6 +9480,7 @@ module_init(init_nls_cp950) module_exit(exit_nls_cp950) +MODULE_LICENSE("Dual BSD/GPL"); /* * Overrides for Emacs so that we follow Linus's tabbing style. diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/fs/nls/nls_euc-jp.c linux-2.5/fs/nls/nls_euc-jp.c --- linux-2.5.1/fs/nls/nls_euc-jp.c Fri Apr 6 17:51:19 2001 +++ linux-2.5/fs/nls/nls_euc-jp.c Thu Dec 13 22:09:30 2001 @@ -581,6 +581,7 @@ module_init(init_nls_euc_jp) module_exit(exit_nls_euc_jp) +MODULE_LICENSE("Dual BSD/GPL"); /* * Overrides for Emacs so that we follow Linus's tabbing style. diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/fs/nls/nls_euc-kr.c linux-2.5/fs/nls/nls_euc-kr.c --- linux-2.5.1/fs/nls/nls_euc-kr.c Mon Oct 16 19:58:51 2000 +++ linux-2.5/fs/nls/nls_euc-kr.c Thu Dec 13 22:09:30 2001 @@ -42,6 +42,7 @@ module_init(init_nls_euc_kr) module_exit(exit_nls_euc_kr) +MODULE_LICENSE("Dual BSD/GPL"); /* * Overrides for Emacs so that we follow Linus's tabbing style. diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/fs/nls/nls_gb2312.c linux-2.5/fs/nls/nls_gb2312.c --- linux-2.5.1/fs/nls/nls_gb2312.c Mon Oct 16 19:58:51 2000 +++ linux-2.5/fs/nls/nls_gb2312.c Thu Dec 13 22:09:30 2001 @@ -42,6 +42,7 @@ module_init(init_nls_gb2312) module_exit(exit_nls_gb2312) +MODULE_LICENSE("Dual BSD/GPL"); /* * Overrides for Emacs so that we follow Linus's tabbing style. diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/fs/nls/nls_iso8859-1.c linux-2.5/fs/nls/nls_iso8859-1.c --- linux-2.5.1/fs/nls/nls_iso8859-1.c Wed Jul 19 05:48:33 2000 +++ linux-2.5/fs/nls/nls_iso8859-1.c Thu Dec 13 22:09:30 2001 @@ -254,6 +254,7 @@ module_init(init_nls_iso8859_1) module_exit(exit_nls_iso8859_1) +MODULE_LICENSE("Dual BSD/GPL"); /* * Overrides for Emacs so that we follow Linus's tabbing style. diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/fs/nls/nls_iso8859-13.c linux-2.5/fs/nls/nls_iso8859-13.c --- linux-2.5.1/fs/nls/nls_iso8859-13.c Sun May 20 00:47:55 2001 +++ linux-2.5/fs/nls/nls_iso8859-13.c Thu Dec 13 22:09:30 2001 @@ -282,6 +282,7 @@ module_init(init_nls_iso8859_13) module_exit(exit_nls_iso8859_13) +MODULE_LICENSE("Dual BSD/GPL"); /* * Overrides for Emacs so that we follow Linus's tabbing style. diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/fs/nls/nls_iso8859-14.c linux-2.5/fs/nls/nls_iso8859-14.c --- linux-2.5.1/fs/nls/nls_iso8859-14.c Wed Jul 19 05:48:33 2000 +++ linux-2.5/fs/nls/nls_iso8859-14.c Thu Dec 13 22:09:30 2001 @@ -338,6 +338,7 @@ module_init(init_nls_iso8859_14) module_exit(exit_nls_iso8859_14) +MODULE_LICENSE("Dual BSD/GPL"); /* * Overrides for Emacs so that we follow Linus's tabbing style. diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/fs/nls/nls_iso8859-15.c linux-2.5/fs/nls/nls_iso8859-15.c --- linux-2.5.1/fs/nls/nls_iso8859-15.c Fri Jul 21 22:19:51 2000 +++ linux-2.5/fs/nls/nls_iso8859-15.c Thu Dec 13 22:09:30 2001 @@ -304,6 +304,7 @@ module_init(init_nls_iso8859_15) module_exit(exit_nls_iso8859_15) +MODULE_LICENSE("Dual BSD/GPL"); /* * Overrides for Emacs so that we follow Linus's tabbing style. diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/fs/nls/nls_iso8859-2.c linux-2.5/fs/nls/nls_iso8859-2.c --- linux-2.5.1/fs/nls/nls_iso8859-2.c Fri Jul 21 22:19:51 2000 +++ linux-2.5/fs/nls/nls_iso8859-2.c Thu Dec 13 22:09:30 2001 @@ -305,6 +305,7 @@ module_init(init_nls_iso8859_2) module_exit(exit_nls_iso8859_2) +MODULE_LICENSE("Dual BSD/GPL"); /* * Overrides for Emacs so that we follow Linus's tabbing style. diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/fs/nls/nls_iso8859-3.c linux-2.5/fs/nls/nls_iso8859-3.c --- linux-2.5.1/fs/nls/nls_iso8859-3.c Fri Jul 21 22:19:51 2000 +++ linux-2.5/fs/nls/nls_iso8859-3.c Thu Dec 13 22:09:30 2001 @@ -305,6 +305,7 @@ module_init(init_nls_iso8859_3) module_exit(exit_nls_iso8859_3) +MODULE_LICENSE("Dual BSD/GPL"); /* * Overrides for Emacs so that we follow Linus's tabbing style. diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/fs/nls/nls_iso8859-4.c linux-2.5/fs/nls/nls_iso8859-4.c --- linux-2.5.1/fs/nls/nls_iso8859-4.c Fri Jul 21 22:19:51 2000 +++ linux-2.5/fs/nls/nls_iso8859-4.c Thu Dec 13 22:09:30 2001 @@ -305,6 +305,7 @@ module_init(init_nls_iso8859_4) module_exit(exit_nls_iso8859_4) +MODULE_LICENSE("Dual BSD/GPL"); /* * Overrides for Emacs so that we follow Linus's tabbing style. diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/fs/nls/nls_iso8859-5.c linux-2.5/fs/nls/nls_iso8859-5.c --- linux-2.5.1/fs/nls/nls_iso8859-5.c Fri Jul 21 22:19:51 2000 +++ linux-2.5/fs/nls/nls_iso8859-5.c Thu Dec 13 22:09:30 2001 @@ -269,6 +269,7 @@ module_init(init_nls_iso8859_5) module_exit(exit_nls_iso8859_5) +MODULE_LICENSE("Dual BSD/GPL"); /* * Overrides for Emacs so that we follow Linus's tabbing style. diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/fs/nls/nls_iso8859-6.c linux-2.5/fs/nls/nls_iso8859-6.c --- linux-2.5.1/fs/nls/nls_iso8859-6.c Fri Jul 21 22:19:51 2000 +++ linux-2.5/fs/nls/nls_iso8859-6.c Thu Dec 13 22:09:30 2001 @@ -260,6 +260,7 @@ module_init(init_nls_iso8859_6) module_exit(exit_nls_iso8859_6) +MODULE_LICENSE("Dual BSD/GPL"); /* * Overrides for Emacs so that we follow Linus's tabbing style. diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/fs/nls/nls_iso8859-7.c linux-2.5/fs/nls/nls_iso8859-7.c --- linux-2.5.1/fs/nls/nls_iso8859-7.c Fri Jul 21 22:19:51 2000 +++ linux-2.5/fs/nls/nls_iso8859-7.c Thu Dec 13 22:09:30 2001 @@ -314,6 +314,7 @@ module_init(init_nls_iso8859_7) module_exit(exit_nls_iso8859_7) +MODULE_LICENSE("Dual BSD/GPL"); /* * Overrides for Emacs so that we follow Linus's tabbing style. diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/fs/nls/nls_iso8859-8.c linux-2.5/fs/nls/nls_iso8859-8.c --- linux-2.5.1/fs/nls/nls_iso8859-8.c Fri Apr 6 17:51:19 2001 +++ linux-2.5/fs/nls/nls_iso8859-8.c Thu Dec 13 22:09:30 2001 @@ -42,6 +42,7 @@ module_init(init_nls_iso8859_8) module_exit(exit_nls_iso8859_8) +MODULE_LICENSE("Dual BSD/GPL"); /* * Overrides for Emacs so that we follow Linus's tabbing style. diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/fs/nls/nls_iso8859-9.c linux-2.5/fs/nls/nls_iso8859-9.c --- linux-2.5.1/fs/nls/nls_iso8859-9.c Fri Jul 21 22:19:51 2000 +++ linux-2.5/fs/nls/nls_iso8859-9.c Thu Dec 13 22:09:30 2001 @@ -269,6 +269,7 @@ module_init(init_nls_iso8859_9) module_exit(exit_nls_iso8859_9) +MODULE_LICENSE("Dual BSD/GPL"); /* * Overrides for Emacs so that we follow Linus's tabbing style. diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/fs/nls/nls_koi8-r.c linux-2.5/fs/nls/nls_koi8-r.c --- linux-2.5.1/fs/nls/nls_koi8-r.c Fri Jul 21 22:19:51 2000 +++ linux-2.5/fs/nls/nls_koi8-r.c Thu Dec 13 22:09:30 2001 @@ -320,6 +320,7 @@ module_init(init_nls_koi8_r) module_exit(exit_nls_koi8_r) +MODULE_LICENSE("Dual BSD/GPL"); /* * Overrides for Emacs so that we follow Linus's tabbing style. diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/fs/nls/nls_koi8-ru.c linux-2.5/fs/nls/nls_koi8-ru.c --- linux-2.5.1/fs/nls/nls_koi8-ru.c Sun May 20 00:47:55 2001 +++ linux-2.5/fs/nls/nls_koi8-ru.c Thu Dec 13 22:09:30 2001 @@ -80,6 +80,7 @@ module_init(init_nls_koi8_ru) module_exit(exit_nls_koi8_ru) +MODULE_LICENSE("Dual BSD/GPL"); /* * Overrides for Emacs so that we follow Linus's tabbing style. diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/fs/nls/nls_koi8-u.c linux-2.5/fs/nls/nls_koi8-u.c --- linux-2.5.1/fs/nls/nls_koi8-u.c Sun May 20 00:47:55 2001 +++ linux-2.5/fs/nls/nls_koi8-u.c Thu Dec 13 22:09:30 2001 @@ -327,6 +327,7 @@ module_init(init_nls_koi8_u) module_exit(exit_nls_koi8_u) +MODULE_LICENSE("Dual BSD/GPL"); /* * Overrides for Emacs so that we follow Linus's tabbing style. diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/fs/nls/nls_sjis.c linux-2.5/fs/nls/nls_sjis.c --- linux-2.5.1/fs/nls/nls_sjis.c Mon Oct 16 19:58:51 2000 +++ linux-2.5/fs/nls/nls_sjis.c Thu Dec 13 22:09:30 2001 @@ -42,6 +42,7 @@ module_init(init_nls_sjis) module_exit(exit_nls_sjis) +MODULE_LICENSE("Dual BSD/GPL"); /* * Overrides for Emacs so that we follow Linus's tabbing style. diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/fs/nls/nls_tis-620.c linux-2.5/fs/nls/nls_tis-620.c --- linux-2.5.1/fs/nls/nls_tis-620.c Fri Apr 6 17:51:19 2001 +++ linux-2.5/fs/nls/nls_tis-620.c Thu Dec 13 22:09:30 2001 @@ -42,6 +42,7 @@ module_init(init_nls_tis_620) module_exit(exit_nls_tis_620) +MODULE_LICENSE("Dual BSD/GPL"); /* * Overrides for Emacs so that we follow Linus's tabbing style. diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/fs/nls/nls_utf8.c linux-2.5/fs/nls/nls_utf8.c --- linux-2.5.1/fs/nls/nls_utf8.c Wed Jul 19 05:48:33 2000 +++ linux-2.5/fs/nls/nls_utf8.c Thu Dec 13 22:09:30 2001 @@ -58,3 +58,4 @@ module_init(init_nls_utf8) module_exit(exit_nls_utf8) +MODULE_LICENSE("Dual BSD/GPL"); diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/fs/ntfs/fs.c linux-2.5/fs/ntfs/fs.c --- linux-2.5.1/fs/ntfs/fs.c Sun Dec 16 20:23:05 2001 +++ linux-2.5/fs/ntfs/fs.c Thu Dec 27 15:56:12 2001 @@ -1016,14 +1016,11 @@ init_ntfs_super_block(vol); if (!parse_options(vol, (char*)options)) goto ntfs_read_super_vol; - blocksize = get_hardsect_size(sb->s_dev); - if (blocksize < 512) - blocksize = 512; - if (set_blocksize(sb->s_dev, blocksize) < 0) { - ntfs_error("Unable to set blocksize %d.\n", blocksize); + blocksize = sb_min_blocksize(sb, 512); + if (!blocksize) { + ntfs_error("Unable to set blocksize.\n"); goto ntfs_read_super_vol; } - sb->s_blocksize = blocksize; /* Read the super block (boot block). */ if (!(bh = sb_bread(sb, 0))) { ntfs_error("Reading super block failed\n"); @@ -1052,10 +1049,7 @@ } ntfs_debug(DEBUG_OTHER, "Done to init volume\n"); /* Inform the kernel that a device block is a NTFS cluster. */ - sb->s_blocksize = vol->cluster_size; - sb->s_blocksize_bits = vol->cluster_size_bits; - if (blocksize != vol->cluster_size && - set_blocksize(sb->s_dev, sb->s_blocksize) < 0) { + if (!sb_set_blocksize(sb, vol->cluster_size)) { ntfs_error("Cluster size too small for device.\n"); goto ntfs_read_super_unl; } diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/fs/openpromfs/inode.c linux-2.5/fs/openpromfs/inode.c --- linux-2.5.1/fs/openpromfs/inode.c Sun Nov 11 18:13:25 2001 +++ linux-2.5/fs/openpromfs/inode.c Thu Dec 13 16:32:37 2001 @@ -1,4 +1,4 @@ -/* $Id: inode.c,v 1.14 2001/02/13 01:17:17 davem Exp $ +/* $Id: inode.c,v 1.15 2001/11/12 09:43:39 davem Exp $ * openpromfs.c: /proc/openprom handling routines * * Copyright (C) 1996-1999 Jakub Jelinek (jakub@redhat.com) diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/fs/partitions/check.h linux-2.5/fs/partitions/check.h --- linux-2.5.1/fs/partitions/check.h Sun Dec 16 23:45:06 2001 +++ linux-2.5/fs/partitions/check.h Mon Dec 31 22:00:53 2001 @@ -1,18 +1,10 @@ #include <linux/pagemap.h> +#include <linux/blkdev.h> /* * add_gd_partition adds a partitions details to the devices partition * description. */ void add_gd_partition(struct gendisk *hd, int minor, int start, int size); - -typedef struct {struct page *v;} Sector; - -unsigned char *read_dev_sector(struct block_device *, unsigned long, Sector *); - -static inline void put_dev_sector(Sector p) -{ - page_cache_release(p.v); -} extern int warn_no_part; diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/fs/proc/array.c linux-2.5/fs/proc/array.c --- linux-2.5.1/fs/proc/array.c Thu Oct 11 16:00:01 2001 +++ linux-2.5/fs/proc/array.c Thu Dec 27 22:10:28 2001 @@ -335,8 +335,7 @@ /* scale priority and nice values from timeslices to -20..20 */ /* to make it look like a "normal" Unix priority/nice value */ - priority = task->counter; - priority = 20 - (priority * 10 + DEF_COUNTER / 2) / DEF_COUNTER; + priority = task->dyn_prio; nice = task->nice; read_lock(&tasklist_lock); diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/fs/proc/base.c linux-2.5/fs/proc/base.c --- linux-2.5.1/fs/proc/base.c Thu Oct 11 06:42:47 2001 +++ linux-2.5/fs/proc/base.c Sun Dec 30 20:22:07 2001 @@ -23,6 +23,9 @@ #include <linux/init.h> #include <linux/file.h> #include <linux/string.h> +#include <linux/seq_file.h> +#include <linux/namespace.h> +#include <linux/mm.h> /* * For hysterical raisins we keep the same inumbers as in the old procfs. @@ -246,6 +249,46 @@ read: pid_maps_read, }; +extern struct seq_operations mounts_op; +static int mounts_open(struct inode *inode, struct file *file) +{ + struct task_struct *task = inode->u.proc_i.task; + int ret = seq_open(file, &mounts_op); + + if (!ret) { + struct seq_file *m = file->private_data; + struct namespace *namespace; + task_lock(task); + namespace = task->namespace; + if (namespace) + get_namespace(namespace); + task_unlock(task); + + if (namespace) + m->private = namespace; + else { + seq_release(inode, file); + ret = -EINVAL; + } + } + return ret; +} + +static int mounts_release(struct inode *inode, struct file *file) +{ + struct seq_file *m = file->private_data; + struct namespace *namespace = m->private; + put_namespace(namespace); + return seq_release(inode, file); +} + +static struct file_operations proc_mounts_operations = { + open: mounts_open, + read: seq_read, + llseek: seq_lseek, + release: mounts_release, +}; + #define PROC_BLOCK_SIZE (3*1024) /* 4K page size but our output routines use some slack for overruns */ static ssize_t proc_info_read(struct file * file, char * buf, @@ -497,6 +540,7 @@ PROC_PID_STATM, PROC_PID_MAPS, PROC_PID_CPU, + PROC_PID_MOUNTS, PROC_PID_FD_DIR = 0x8000, /* 0x8000-0xffff */ }; @@ -516,6 +560,7 @@ E(PROC_PID_CWD, "cwd", S_IFLNK|S_IRWXUGO), E(PROC_PID_ROOT, "root", S_IFLNK|S_IRWXUGO), E(PROC_PID_EXE, "exe", S_IFLNK|S_IRWXUGO), + E(PROC_PID_MOUNTS, "mounts", S_IFREG|S_IRUGO), {0,0,NULL,0} }; #undef E @@ -874,6 +919,9 @@ case PROC_PID_MEM: inode->i_op = &proc_mem_inode_operations; inode->i_fop = &proc_mem_operations; + break; + case PROC_PID_MOUNTS: + inode->i_fop = &proc_mounts_operations; break; default: printk("procfs: impossible type (%d)",p->type); diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/fs/proc/proc_misc.c linux-2.5/fs/proc/proc_misc.c --- linux-2.5.1/fs/proc/proc_misc.c Thu Nov 29 15:49:55 2001 +++ linux-2.5/fs/proc/proc_misc.c Thu Dec 27 15:56:12 2001 @@ -500,18 +500,6 @@ write: write_profile, }; -extern struct seq_operations mounts_op; -static int mounts_open(struct inode *inode, struct file *file) -{ - return seq_open(file, &mounts_op); -} -static struct file_operations proc_mounts_operations = { - open: mounts_open, - read: seq_read, - llseek: seq_lseek, - release: seq_release, -}; - struct proc_dir_entry *proc_root_kcore; static void create_seq_entry(char *name, mode_t mode, struct file_operations *f) @@ -555,11 +543,12 @@ for (p = simple_ones; p->name; p++) create_proc_read_entry(p->name, 0, NULL, p->read_proc, NULL); + proc_symlink("mounts", NULL, "self/mounts"); + /* And now for trickier ones */ entry = create_proc_entry("kmsg", S_IRUSR, &proc_root); if (entry) entry->proc_fops = &proc_kmsg_operations; - create_seq_entry("mounts", 0, &proc_mounts_operations); create_seq_entry("cpuinfo", 0, &proc_cpuinfo_operations); create_seq_entry("interrupts", 0, &proc_interrupts_operations); #ifdef CONFIG_MODULES diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/fs/qnx4/dir.c linux-2.5/fs/qnx4/dir.c --- linux-2.5.1/fs/qnx4/dir.c Sun Dec 16 20:23:05 2001 +++ linux-2.5/fs/qnx4/dir.c Sun Dec 30 21:17:30 2001 @@ -18,7 +18,6 @@ #include <linux/qnx4_fs.h> #include <linux/stat.h> -#include <asm/segment.h> static int qnx4_readdir(struct file *filp, void *dirent, filldir_t filldir) { diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/fs/qnx4/fsync.c linux-2.5/fs/qnx4/fsync.c --- linux-2.5.1/fs/qnx4/fsync.c Sun Dec 16 20:23:05 2001 +++ linux-2.5/fs/qnx4/fsync.c Sun Dec 30 21:17:30 2001 @@ -21,7 +21,6 @@ #include <linux/fs.h> #include <linux/qnx4_fs.h> -#include <asm/segment.h> #include <asm/system.h> /* diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/fs/qnx4/inode.c linux-2.5/fs/qnx4/inode.c --- linux-2.5.1/fs/qnx4/inode.c Sun Dec 16 20:23:05 2001 +++ linux-2.5/fs/qnx4/inode.c Sun Dec 30 20:01:41 2001 @@ -18,8 +18,8 @@ #include <linux/string.h> #include <linux/errno.h> #include <linux/slab.h> -#include <linux/qnx4_fs.h> #include <linux/fs.h> +#include <linux/qnx4_fs.h> #include <linux/locks.h> #include <linux/init.h> #include <linux/highuid.h> @@ -213,9 +213,7 @@ phys = qnx4_block_map( inode, iblock ); if ( phys ) { // logical block is before EOF - bh->b_dev = inode->i_dev; - bh->b_blocknr = phys; - bh->b_state |= (1UL << BH_Mapped); + map_bh(bh, inode->i_sb, phys); } else if ( create ) { // to be done. } @@ -339,13 +337,10 @@ void *data, int silent) { struct buffer_head *bh; - kdev_t dev = s->s_dev; struct inode *root; const char *errmsg; - set_blocksize(dev, QNX4_BLOCK_SIZE); - s->s_blocksize = QNX4_BLOCK_SIZE; - s->s_blocksize_bits = QNX4_BLOCK_SIZE_BITS; + sb_set_blocksize(s, QNX4_BLOCK_SIZE); /* Check the boot signature. Since the qnx4 code is dangerous, we should leave as quickly as possible diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/fs/qnx4/namei.c linux-2.5/fs/qnx4/namei.c --- linux-2.5.1/fs/qnx4/namei.c Tue Sep 5 21:07:30 2000 +++ linux-2.5/fs/qnx4/namei.c Sun Dec 30 21:17:30 2001 @@ -21,7 +21,6 @@ #include <linux/fcntl.h> #include <linux/errno.h> -#include <asm/segment.h> /* * check if the filename is correct. For some obscure reason, qnx writes a diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/fs/qnx4/truncate.c linux-2.5/fs/qnx4/truncate.c --- linux-2.5.1/fs/qnx4/truncate.c Fri Feb 9 19:29:44 2001 +++ linux-2.5/fs/qnx4/truncate.c Sun Dec 30 20:01:41 2001 @@ -13,9 +13,8 @@ #include <linux/config.h> #include <linux/types.h> #include <linux/errno.h> -#include <linux/slab.h> -#include <linux/qnx4_fs.h> #include <linux/fs.h> +#include <linux/qnx4_fs.h> #include <linux/locks.h> #include <asm/uaccess.h> diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/fs/ramfs/inode.c linux-2.5/fs/ramfs/inode.c --- linux-2.5.1/fs/ramfs/inode.c Wed Oct 24 22:19:18 2001 +++ linux-2.5/fs/ramfs/inode.c Thu Dec 27 15:56:12 2001 @@ -325,6 +325,7 @@ } static DECLARE_FSTYPE(ramfs_fs_type, "ramfs", ramfs_read_super, FS_LITTER); +static DECLARE_FSTYPE(rootfs_fs_type, "rootfs", ramfs_read_super, FS_NOMOUNT|FS_LITTER); static int __init init_ramfs_fs(void) { @@ -338,5 +339,11 @@ module_init(init_ramfs_fs) module_exit(exit_ramfs_fs) + +int __init init_rootfs(void) +{ + return register_filesystem(&rootfs_fs_type); +} + MODULE_LICENSE("GPL"); diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/fs/reiserfs/bitmap.c linux-2.5/fs/reiserfs/bitmap.c --- linux-2.5.1/fs/reiserfs/bitmap.c Fri Nov 9 22:18:25 2001 +++ linux-2.5/fs/reiserfs/bitmap.c Thu Dec 13 16:32:37 2001 @@ -84,7 +84,7 @@ to free a list of blocks at once. -Hans */ /* I wonder if it would be less modest now that we use journaling. -Hans */ -void reiserfs_free_block (struct reiserfs_transaction_handle *th, unsigned long block) +static void _reiserfs_free_block (struct reiserfs_transaction_handle *th, unsigned long block) { struct super_block * s = th->t_super; struct reiserfs_super_block * rs; @@ -92,9 +92,6 @@ struct buffer_head ** apbh; int nr, offset; - RFALSE(!s, "vs-4060: trying to free block on nonexistent device"); - RFALSE(is_reusable (s, block, 1) == 0, "vs-4070: can not free such block"); - PROC_INFO_INC( s, free_block ); rs = SB_DISK_SUPER_BLOCK (s); @@ -103,8 +100,12 @@ get_bit_address (s, block, &nr, &offset); - /* mark it before we clear it, just in case */ - journal_mark_freed(th, s, block) ; + if (nr >= sb_bmap_nr (rs)) { + reiserfs_warning ("vs-4075: reiserfs_free_block: " + "block %lu is out of range on %s\n", + block, bdevname(s->s_dev)); + return; + } reiserfs_prepare_for_journal(s, apbh[nr], 1 ) ; @@ -124,7 +125,26 @@ s->s_dirt = 1; } +void reiserfs_free_block (struct reiserfs_transaction_handle *th, + unsigned long block) { + struct super_block * s = th->t_super; + + RFALSE(!s, "vs-4061: trying to free block on nonexistent device"); + RFALSE(is_reusable (s, block, 1) == 0, "vs-4071: can not free such block"); + /* mark it before we clear it, just in case */ + journal_mark_freed(th, s, block) ; + _reiserfs_free_block(th, block) ; +} + +/* preallocated blocks don't need to be run through journal_mark_freed */ +void reiserfs_free_prealloc_block (struct reiserfs_transaction_handle *th, + unsigned long block) { + struct super_block * s = th->t_super; + RFALSE(!s, "vs-4060: trying to free block on nonexistent device"); + RFALSE(is_reusable (s, block, 1) == 0, "vs-4070: can not free such block"); + _reiserfs_free_block(th, block) ; +} /* beginning from offset-th bit in bmap_nr-th bitmap block, find_forward finds the closest zero bit. It returns 1 and zero @@ -402,7 +422,6 @@ ** has allocated it. loop around and try again */ if (reiserfs_test_and_set_le_bit (j, SB_AP_BITMAP (s)[i]->b_data)) { - reiserfs_warning("vs-4150: reiserfs_new_blocknrs, block not free"); reiserfs_restore_prepared_buffer(s, SB_AP_BITMAP(s)[i]) ; amount_needed++ ; continue ; @@ -488,12 +507,7 @@ ** to be grouped towards the start of the border */ border = le32_to_cpu(INODE_PKEY(p_s_inode)->k_dir_id) % (SB_BLOCK_COUNT(th->t_super) - bstart - 1) ; - } else { - /* why would we want to delcare a local variable to this if statement - ** name border????? -chris - ** unsigned long border = 0; - */ - if (!reiserfs_hashed_relocation(th->t_super)) { + } else if (!reiserfs_hashed_relocation(th->t_super)) { hash_in = le32_to_cpu((INODE_PKEY(p_s_inode))->k_dir_id); /* I wonder if the CPU cost of the hash will obscure the layout @@ -503,7 +517,6 @@ hash_out = keyed_hash(((char *) (&hash_in)), 4); border = hash_out % (SB_BLOCK_COUNT(th->t_super) - bstart - 1) ; - } } border += bstart ; allocated[0] = 0 ; /* important. Allows a check later on to see if at @@ -659,11 +672,13 @@ static void __discard_prealloc (struct reiserfs_transaction_handle * th, struct inode * inode) { + unsigned long save = inode->u.reiserfs_i.i_prealloc_block ; while (inode->u.reiserfs_i.i_prealloc_count > 0) { - reiserfs_free_block(th,inode->u.reiserfs_i.i_prealloc_block); + reiserfs_free_prealloc_block(th,inode->u.reiserfs_i.i_prealloc_block); inode->u.reiserfs_i.i_prealloc_block++; inode->u.reiserfs_i.i_prealloc_count --; } + inode->u.reiserfs_i.i_prealloc_block = save ; list_del (&(inode->u.reiserfs_i.i_prealloc_list)); } diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/fs/reiserfs/buffer2.c linux-2.5/fs/reiserfs/buffer2.c --- linux-2.5.1/fs/reiserfs/buffer2.c Fri Nov 9 22:18:25 2001 +++ linux-2.5/fs/reiserfs/buffer2.c Thu Dec 27 22:49:31 2001 @@ -2,15 +2,6 @@ * Copyright 2000 by Hans Reiser, licensing governed by reiserfs/README */ - -/* - * Contains code from - * - * linux/include/linux/lock.h and linux/fs/buffer.c /linux/fs/minix/fsync.c - * - * Copyright (C) 1991, 1992 Linus Torvalds - */ - #include <linux/config.h> #include <linux/sched.h> #include <linux/locks.h> @@ -21,12 +12,8 @@ /* * wait_buffer_until_released * reiserfs_bread - * reiserfs_getblk - * get_new_buffer */ - - /* when we allocate a new block (get_new_buffer, get_empty_nodes) and get buffer for it, it is possible that it is held by someone else or even by this process. In this function we wait until all other @@ -47,7 +34,6 @@ } run_task_queue(&tq_disk); current->policy |= SCHED_YIELD; - /*current->counter = 0;*/ schedule(); } if (repeat_counter > 30000000) { @@ -63,289 +49,15 @@ then it creates a new buffer and schedules I/O to read the block. */ /* The function is NOT SCHEDULE-SAFE! */ - -struct buffer_head * reiserfs_bread (struct super_block *super, int n_block, int n_size) +struct buffer_head * reiserfs_bread (struct super_block *super, int n_block) { struct buffer_head *result; PROC_EXP( unsigned int ctx_switches = kstat.context_swtch ); - result = bread (super -> s_dev, n_block, n_size); + result = sb_bread(super, n_block); PROC_INFO_INC( super, breads ); PROC_EXP( if( kstat.context_swtch != ctx_switches ) PROC_INFO_INC( super, bread_miss ) ); return result; } - -/* This function looks for a buffer which contains a given block. If - the block is in cache it returns it, otherwise it returns a new - buffer which is not uptodate. This is called by reiserfs_bread and - other functions. Note that get_new_buffer ought to be called this - and this ought to be called get_new_buffer, since this doesn't - actually get the block off of the disk. */ -/* The function is NOT SCHEDULE-SAFE! */ - -struct buffer_head * reiserfs_getblk (kdev_t n_dev, int n_block, int n_size) -{ - return getblk (n_dev, n_block, n_size); -} - -#ifdef NEW_GET_NEW_BUFFER - -/* returns one buffer with a blocknr near blocknr. */ -static int get_new_buffer_near_blocknr( - struct super_block * p_s_sb, - int blocknr, - struct buffer_head ** pp_s_new_bh, - struct path * p_s_path - ) { - unsigned long n_new_blocknumber = 0; - int n_ret_value, - n_repeat = CARRY_ON; - -#ifdef CONFIG_REISERFS_CHECK - int repeat_counter = 0; - - if (!blocknr) - printk ("blocknr passed to get_new_buffer_near_blocknr was 0"); -#endif - - - if ( (n_ret_value = reiserfs_new_blocknrs (p_s_sb, &n_new_blocknumber, - blocknr, 1)) == NO_DISK_SPACE ) - return NO_DISK_SPACE; - - *pp_s_new_bh = reiserfs_getblk(p_s_sb->s_dev, n_new_blocknumber, p_s_sb->s_blocksize); - if ( buffer_uptodate(*pp_s_new_bh) ) { - - RFALSE( buffer_dirty(*pp_s_new_bh) || (*pp_s_new_bh)->b_dev == NODEV, - "PAP-14080: invalid uptodate buffer %b for the new block", - *pp_s_new_bh); - - /* Free path buffers to prevent deadlock. */ - /* It is possible that this process has the buffer, which this function is getting, already in - its path, and is responsible for double incrementing the value of b_count. If we recalculate - the path after schedule we can avoid risking an endless loop. This problematic situation is - possible in a multiple processing environment. Suppose process 1 has acquired a path P; then - process 2 balanced and remove block A from the tree. Process 1 continues and runs - get_new_buffer, that returns buffer with block A. If node A was on the path P, then it will - have b_count == 2. If we now will simply wait in while ( (*pp_s_new_bh)->b_count > 1 ) we get - into an endless loop, as nobody will release this buffer and the current process holds buffer - twice. That is why we do decrement_counters_in_path(p_s_path) before waiting until b_count - becomes 1. (it there were other processes holding node A, then eventually we will get a - moment, when all of them released a buffer). */ - if ( atomic_read (&((*pp_s_new_bh)->b_count)) > 1 ) { - decrement_counters_in_path(p_s_path); - n_ret_value |= SCHEDULE_OCCURRED; - } - - while ( atomic_read (&((*pp_s_new_bh)->b_count)) > 1 ) { - -#ifdef REISERFS_INFO - printk("get_new_buffer() calls schedule to decrement b_count\n"); -#endif - -#ifdef CONFIG_REISERFS_CHECK - if ( ! (++repeat_counter % 10000) ) - printk("get_new_buffer(%u): counter(%d) too big", current->pid, repeat_counter); -#endif - - current->counter = 0; - schedule(); - } - -#ifdef CONFIG_REISERFS_CHECK - if ( buffer_dirty(*pp_s_new_bh) || (*pp_s_new_bh)->b_dev == NODEV ) { - print_buffer_head(*pp_s_new_bh,"get_new_buffer"); - reiserfs_panic(p_s_sb, "PAP-14090: get_new_buffer: invalid uptodate buffer %b for the new block(case 2)", *pp_s_new_bh); - } -#endif - - } - else { - ; - - RFALSE( atomic_read (&((*pp_s_new_bh)->b_count)) != 1, - "PAP-14100: not uptodate buffer %b for the new block has b_count more than one", - *pp_s_new_bh); - - } - return (n_ret_value | n_repeat); -} - - -/* returns the block number of the last unformatted node, assumes p_s_key_to_search.k_offset is a byte in the tail of - the file, Useful for when you want to append to a file, and convert a direct item into an unformatted node near the - last unformatted node of the file. Putting the unformatted node near the direct item is potentially very bad to do. - If there is no unformatted node in the file, then we return the block number of the direct item. */ -/* The function is NOT SCHEDULE-SAFE! */ -inline int get_last_unformatted_node_blocknr_of_file( struct key * p_s_key_to_search, struct super_block * p_s_sb, - struct buffer_head * p_s_bh - struct path * p_unf_search_path, struct inode * p_s_inode) - -{ - struct key unf_key_to_search; - struct item_head * p_s_ih; - int n_pos_in_item; - struct buffer_head * p_indirect_item_bh; - - copy_key(&unf_key_to_search,p_s_key_to_search); - unf_key_to_search.k_uniqueness = TYPE_INDIRECT; - unf_key_to_search.k_offset = p_s_inode->u.reiserfs_i.i_first_direct_byte - 1; - - /* p_s_key_to_search->k_offset - MAX_ITEM_LEN(p_s_sb->s_blocksize); */ - if (search_for_position_by_key (p_s_sb, &unf_key_to_search, p_unf_search_path, &n_pos_in_item) == POSITION_FOUND) - { - p_s_ih = B_N_PITEM_HEAD(p_indirect_item_bh = PATH_PLAST_BUFFER(p_unf_search_path), PATH_LAST_POSITION(p_unf_search_path)); - return (B_I_POS_UNFM_POINTER(p_indirect_item_bh, p_s_ih, n_pos_in_item)); - } - /* else */ - printk("reiser-1800: search for unformatted node failed, p_s_key_to_search->k_offset = %u, unf_key_to_search.k_offset = %u, MAX_ITEM_LEN(p_s_sb->s_blocksize) = %ld, debug this\n", p_s_key_to_search->k_offset, unf_key_to_search.k_offset, MAX_ITEM_LEN(p_s_sb->s_blocksize) ); - print_buffer_head(PATH_PLAST_BUFFER(p_unf_search_path), "the buffer holding the item before the key we failed to find"); - print_block_head(PATH_PLAST_BUFFER(p_unf_search_path), "the block head"); - return 0; /* keeps the compiler quiet */ -} - - - /* hasn't been out of disk space tested */ -/* The function is NOT SCHEDULE-SAFE! */ -static int get_buffer_near_last_unf ( struct super_block * p_s_sb, struct key * p_s_key_to_search, - struct inode * p_s_inode, struct buffer_head * p_s_bh, - struct buffer_head ** pp_s_un_bh, struct path * p_s_search_path) -{ - int unf_blocknr = 0, /* blocknr from which we start search for a free block for an unformatted node, if 0 - then we didn't find an unformatted node though we might have found a file hole */ - n_repeat = CARRY_ON; - struct key unf_key_to_search; - struct path unf_search_path; - - copy_key(&unf_key_to_search,p_s_key_to_search); - unf_key_to_search.k_uniqueness = TYPE_INDIRECT; - - if ( - (p_s_inode->u.reiserfs_i.i_first_direct_byte > 4095) /* i_first_direct_byte gets used for all sorts of - crap other than what the name indicates, thus - testing to see if it is 0 is not enough */ - && (p_s_inode->u.reiserfs_i.i_first_direct_byte < MAX_KEY_OFFSET) /* if there is no direct item then - i_first_direct_byte = MAX_KEY_OFFSET */ - ) - { - /* actually, we don't want the last unformatted node, we want the last unformatted node - which is before the current file offset */ - unf_key_to_search.k_offset = ((p_s_inode->u.reiserfs_i.i_first_direct_byte -1) < unf_key_to_search.k_offset) ? p_s_inode->u.reiserfs_i.i_first_direct_byte -1 : unf_key_to_search.k_offset; - - while (unf_key_to_search.k_offset > -1) - { - /* This is our poorly documented way of initializing paths. -Hans */ - init_path (&unf_search_path); - /* get the blocknr from which we start the search for a free block. */ - unf_blocknr = get_last_unformatted_node_blocknr_of_file( p_s_key_to_search, /* assumes this points to the file tail */ - p_s_sb, /* lets us figure out the block size */ - p_s_bh, /* if there is no unformatted node in the file, - then it returns p_s_bh->b_blocknr */ - &unf_search_path, - p_s_inode - ); -/* printk("in while loop: unf_blocknr = %d, *pp_s_un_bh = %p\n", unf_blocknr, *pp_s_un_bh); */ - if (unf_blocknr) - break; - else /* release the path and search again, this could be really slow for huge - holes.....better to spend the coding time adding compression though.... -Hans */ - { - /* Vladimir, is it a problem that I don't brelse these buffers ?-Hans */ - decrement_counters_in_path(&unf_search_path); - unf_key_to_search.k_offset -= 4096; - } - } - if (unf_blocknr) { - n_repeat |= get_new_buffer_near_blocknr(p_s_sb, unf_blocknr, pp_s_un_bh, p_s_search_path); - } - else { /* all unformatted nodes are holes */ - n_repeat |= get_new_buffer_near_blocknr(p_s_sb, p_s_bh->b_blocknr, pp_s_un_bh, p_s_search_path); - } - } - else { /* file has no unformatted nodes */ - n_repeat |= get_new_buffer_near_blocknr(p_s_sb, p_s_bh->b_blocknr, pp_s_un_bh, p_s_search_path); -/* printk("in else: unf_blocknr = %d, *pp_s_un_bh = %p\n", unf_blocknr, *pp_s_un_bh); */ -/* print_path (0, p_s_search_path); */ - } - - return n_repeat; -} - -#endif /* NEW_GET_NEW_BUFFER */ - - -#ifdef OLD_GET_NEW_BUFFER - -/* The function is NOT SCHEDULE-SAFE! */ -int get_new_buffer( - struct reiserfs_transaction_handle *th, - struct buffer_head * p_s_bh, - struct buffer_head ** pp_s_new_bh, - struct path * p_s_path - ) { - unsigned long n_new_blocknumber = 0; - int n_repeat; - struct super_block * p_s_sb = th->t_super; - - if ( (n_repeat = reiserfs_new_unf_blocknrs (th, &n_new_blocknumber, p_s_bh->b_blocknr)) == NO_DISK_SPACE ) - return NO_DISK_SPACE; - - *pp_s_new_bh = reiserfs_getblk(p_s_sb->s_dev, n_new_blocknumber, p_s_sb->s_blocksize); - if (atomic_read (&(*pp_s_new_bh)->b_count) > 1) { - /* Free path buffers to prevent deadlock which can occur in the - situation like : this process holds p_s_path; Block - (*pp_s_new_bh)->b_blocknr is on the path p_s_path, but it is - not necessary, that *pp_s_new_bh is in the tree; process 2 - could remove it from the tree and freed block - (*pp_s_new_bh)->b_blocknr. Reiserfs_new_blocknrs in above - returns block (*pp_s_new_bh)->b_blocknr. Reiserfs_getblk gets - buffer for it, and it has b_count > 1. If we now will simply - wait in while ( (*pp_s_new_bh)->b_count > 1 ) we get into an - endless loop, as nobody will release this buffer and the - current process holds buffer twice. That is why we do - decrement_counters_in_path(p_s_path) before waiting until - b_count becomes 1. (it there were other processes holding node - pp_s_new_bh, then eventually we will get a moment, when all of - them released a buffer). */ - decrement_counters_in_path(p_s_path); - wait_buffer_until_released (*pp_s_new_bh); - n_repeat |= SCHEDULE_OCCURRED; - } - - RFALSE( atomic_read (&((*pp_s_new_bh)->b_count)) != 1 || - buffer_dirty (*pp_s_new_bh), - "PAP-14100: not free or dirty buffer %b for the new block", - *pp_s_new_bh); - - return n_repeat; -} - -#endif /* OLD_GET_NEW_BUFFER */ - - -#ifdef GET_MANY_BLOCKNRS - /* code not yet functional */ -get_next_blocknr ( - unsigned long * p_blocknr_array, /* we get a whole bunch of blocknrs all at once for - the write. This is better than getting them one at - a time. */ - unsigned long ** p_blocknr_index, /* pointer to current offset into the array. */ - unsigned long blocknr_array_length -) -{ - unsigned long return_value; - - if (*p_blocknr_index < p_blocknr_array + blocknr_array_length) { - return_value = **p_blocknr_index; - **p_blocknr_index = 0; - *p_blocknr_index++; - return (return_value); - } - else - { - kfree (p_blocknr_array); - } -} -#endif /* GET_MANY_BLOCKNRS */ diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/fs/reiserfs/dir.c linux-2.5/fs/reiserfs/dir.c --- linux-2.5.1/fs/reiserfs/dir.c Tue Oct 30 23:11:34 2001 +++ linux-2.5/fs/reiserfs/dir.c Thu Dec 13 16:32:37 2001 @@ -22,22 +22,6 @@ fsync: reiserfs_dir_fsync, }; -/* - * directories can handle most operations... - */ -struct inode_operations reiserfs_dir_inode_operations = { - //&reiserfs_dir_operations, /* default_file_ops */ - create: reiserfs_create, - lookup: reiserfs_lookup, - link: reiserfs_link, - unlink: reiserfs_unlink, - symlink: reiserfs_symlink, - mkdir: reiserfs_mkdir, - rmdir: reiserfs_rmdir, - mknod: reiserfs_mknod, - rename: reiserfs_rename, -}; - int reiserfs_dir_fsync(struct file *filp, struct dentry *dentry, int datasync) { lock_kernel(); reiserfs_commit_for_inode(dentry->d_inode) ; @@ -186,7 +170,7 @@ } /* directory continues in the right neighboring block */ - set_cpu_key_k_offset (&pos_key, le_key_k_offset (ITEM_VERSION_1, rkey)); + set_cpu_key_k_offset (&pos_key, le_key_k_offset (KEY_FORMAT_3_5, rkey)); } /* while */ @@ -197,4 +181,72 @@ pathrelse (&path_to_entry); reiserfs_check_path(&path_to_entry) ; return 0; +} + +/* compose directory item containing "." and ".." entries (entries are + not aligned to 4 byte boundary) */ +/* the last four params are LE */ +void make_empty_dir_item_v1 (char * body, __u32 dirid, __u32 objid, + __u32 par_dirid, __u32 par_objid) +{ + struct reiserfs_de_head * deh; + + memset (body, 0, EMPTY_DIR_SIZE_V1); + deh = (struct reiserfs_de_head *)body; + + /* direntry header of "." */ + put_deh_offset( &(deh[0]), DOT_OFFSET ); + /* these two are from make_le_item_head, and are are LE */ + deh[0].deh_dir_id = dirid; + deh[0].deh_objectid = objid; + deh[0].deh_state = 0; /* Endian safe if 0 */ + put_deh_location( &(deh[0]), EMPTY_DIR_SIZE_V1 - strlen( "." )); + mark_de_visible(&(deh[0])); + + /* direntry header of ".." */ + put_deh_offset( &(deh[1]), DOT_DOT_OFFSET); + /* key of ".." for the root directory */ + /* these two are from the inode, and are are LE */ + deh[1].deh_dir_id = par_dirid; + deh[1].deh_objectid = par_objid; + deh[1].deh_state = 0; /* Endian safe if 0 */ + put_deh_location( &(deh[1]), deh_location( &(deh[0]) ) - strlen( ".." ) ); + mark_de_visible(&(deh[1])); + + /* copy ".." and "." */ + memcpy (body + deh_location( &(deh[0]) ), ".", 1); + memcpy (body + deh_location( &(deh[1]) ), "..", 2); +} + +/* compose directory item containing "." and ".." entries */ +void make_empty_dir_item (char * body, __u32 dirid, __u32 objid, + __u32 par_dirid, __u32 par_objid) +{ + struct reiserfs_de_head * deh; + + memset (body, 0, EMPTY_DIR_SIZE); + deh = (struct reiserfs_de_head *)body; + + /* direntry header of "." */ + put_deh_offset( &(deh[0]), DOT_OFFSET ); + /* these two are from make_le_item_head, and are are LE */ + deh[0].deh_dir_id = dirid; + deh[0].deh_objectid = objid; + deh[0].deh_state = 0; /* Endian safe if 0 */ + put_deh_location( &(deh[0]), EMPTY_DIR_SIZE - ROUND_UP( strlen( "." ) ) ); + mark_de_visible(&(deh[0])); + + /* direntry header of ".." */ + put_deh_offset( &(deh[1]), DOT_DOT_OFFSET ); + /* key of ".." for the root directory */ + /* these two are from the inode, and are are LE */ + deh[1].deh_dir_id = par_dirid; + deh[1].deh_objectid = par_objid; + deh[1].deh_state = 0; /* Endian safe if 0 */ + put_deh_location( &(deh[1]), deh_location( &(deh[0])) - ROUND_UP( strlen( ".." ) ) ); + mark_de_visible(&(deh[1])); + + /* copy ".." and "." */ + memcpy (body + deh_location( &(deh[0]) ), ".", 1); + memcpy (body + deh_location( &(deh[1]) ), "..", 2); } diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/fs/reiserfs/do_balan.c linux-2.5/fs/reiserfs/do_balan.c --- linux-2.5.1/fs/reiserfs/do_balan.c Fri Nov 9 22:18:25 2001 +++ linux-2.5/fs/reiserfs/do_balan.c Thu Dec 13 16:32:37 2001 @@ -274,13 +274,6 @@ int pos_in_item; int zeros_num; -#if 0 - if (tb->insert_size [0] % 4) { - reiserfs_panic (tb->tb_sb, "balance_leaf: wrong insert_size %d", - tb->insert_size [0]); - } -#endif - PROC_INFO_INC( tb -> tb_sb, balance_at[ 0 ] ); /* Make balance in case insert_size[0] < 0 */ diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/fs/reiserfs/file.c linux-2.5/fs/reiserfs/file.c --- linux-2.5.1/fs/reiserfs/file.c Fri Oct 12 21:20:42 2001 +++ linux-2.5/fs/reiserfs/file.c Thu Dec 13 16:32:37 2001 @@ -33,7 +33,7 @@ /* fast out for when nothing needs to be done */ if ((atomic_read(&inode->i_count) > 1 || - !inode->u.reiserfs_i.i_pack_on_close || + !(inode->u.reiserfs_i.i_flags & i_pack_on_close_mask) || !tail_has_to_be_packed(inode)) && inode->u.reiserfs_i.i_prealloc_count <= 0) { return 0; @@ -50,7 +50,7 @@ journal_end(&th, inode->i_sb, JOURNAL_PER_BALANCE_CNT * 3) ; if (atomic_read(&inode->i_count) <= 1 && - inode->u.reiserfs_i.i_pack_on_close && + (inode->u.reiserfs_i.i_flags & i_pack_on_close_mask) && tail_has_to_be_packed (inode)) { /* if regular file is released by last holder and it has been appended (we append by unformatted node only) or its direct @@ -97,10 +97,16 @@ /* version 2 items will be caught by the s_maxbytes check ** done for us in vmtruncate */ - if (inode_items_version(inode) == ITEM_VERSION_1 && + if (get_inode_item_key_version(inode) == KEY_FORMAT_3_5 && attr->ia_size > MAX_NON_LFS) return -EFBIG ; } + + if ((((attr->ia_valid & ATTR_UID) && (attr->ia_uid & ~0xffff)) || + ((attr->ia_valid & ATTR_GID) && (attr->ia_gid & ~0xffff))) && + (get_inode_sd_version (inode) == STAT_DATA_V1)) + /* stat data of format v3.5 has 16 bit uid and gid */ + return -EINVAL; error = inode_change_ok(inode, attr) ; if (!error) diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/fs/reiserfs/fix_node.c linux-2.5/fs/reiserfs/fix_node.c --- linux-2.5.1/fs/reiserfs/fix_node.c Sun Dec 16 20:23:05 2001 +++ linux-2.5/fs/reiserfs/fix_node.c Thu Dec 27 23:14:44 2001 @@ -806,7 +806,7 @@ RFALSE( ! *p_n_blocknr, "PAP-8135: reiserfs_new_blocknrs failed when got new blocks"); - p_s_new_bh = reiserfs_getblk(p_s_sb->s_dev, *p_n_blocknr, p_s_sb->s_blocksize); + p_s_new_bh = getblk(p_s_sb->s_dev, *p_n_blocknr, p_s_sb->s_blocksize); if (atomic_read (&(p_s_new_bh->b_count)) > 1) { /*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&*/ /* @@ -1926,7 +1926,7 @@ n_child_position = ( p_s_bh == p_s_tb->FL[n_h] ) ? p_s_tb->lkey[n_h] : B_NR_ITEMS (p_s_tb->FL[n_h]); n_son_number = B_N_CHILD_NUM(p_s_tb->FL[n_h], n_child_position); - p_s_bh = reiserfs_bread(p_s_sb, n_son_number, p_s_sb->s_blocksize); + p_s_bh = reiserfs_bread(p_s_sb, n_son_number); if (!p_s_bh) return IO_ERROR; if ( FILESYSTEM_CHANGED_TB (p_s_tb) ) { @@ -1959,7 +1959,7 @@ n_child_position = ( p_s_bh == p_s_tb->FR[n_h] ) ? p_s_tb->rkey[n_h] + 1 : 0; n_son_number = B_N_CHILD_NUM(p_s_tb->FR[n_h], n_child_position); - p_s_bh = reiserfs_bread(p_s_sb, n_son_number, p_s_sb->s_blocksize); + p_s_bh = reiserfs_bread(p_s_sb, n_son_number); if (!p_s_bh) return IO_ERROR; if ( FILESYSTEM_CHANGED_TB (p_s_tb) ) { @@ -2021,23 +2021,6 @@ // entry would eat 2 byte of virtual node space return sb->s_blocksize; -#if 0 - size = sizeof (struct virtual_node) + sizeof (struct virtual_item); - ih = B_N_PITEM_HEAD (bh, 0); - nr_items = B_NR_ITEMS (bh); - for (i = 0; i < nr_items; i ++, ih ++) { - /* each item occupies some space in virtual node */ - size += sizeof (struct virtual_item); - if (is_direntry_le_ih (ih)) - /* each entry and new one occupeis 2 byte in the virtual node */ - size += (ih_entry_count(ih) + 1) * sizeof( __u16 ); - } - - /* 1 bit for each bitmap block to note whether bitmap block was - dirtied in the operation */ - /* size += (SB_BMAP_NR (sb) * 2 / 8 + 4);*/ - return size; -#endif } @@ -2342,15 +2325,6 @@ reiserfs_panic (p_s_tb->tb_sb, "PAP-8320: fix_nodes: S[0] (%b %z) is not uptodate " "at the beginning of fix_nodes or not in tree (mode %c)", p_s_tbS0, p_s_tbS0, n_op_mode); } - - // FIXME: new items have to be of 8 byte multiples. Including new - // directory items those look like old ones - /* - if (p_s_tb->insert_size[0] % 8) - reiserfs_panic (p_s_tb->tb_sb, "vs-: fix_nodes: incorrect insert_size %d, " - "mode %c", - p_s_tb->insert_size[0], n_op_mode); - */ /* Check parameters. */ switch (n_op_mode) { diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/fs/reiserfs/inode.c linux-2.5/fs/reiserfs/inode.c --- linux-2.5.1/fs/reiserfs/inode.c Sun Dec 16 20:23:05 2001 +++ linux-2.5/fs/reiserfs/inode.c Thu Dec 27 22:10:28 2001 @@ -17,6 +17,8 @@ #define GET_BLOCK_READ_DIRECT 4 /* read the tail if indirect item not found */ #define GET_BLOCK_NO_ISEM 8 /* i_sem is not held, don't preallocate */ +static int reiserfs_get_block (struct inode * inode, sector_t block, + struct buffer_head * bh_result, int create); // // initially this function was derived from minix or ext2's analog and // evolved as the prototype did @@ -40,11 +42,13 @@ reiserfs_delete_object (&th, inode); pop_journal_writer(windex) ; - reiserfs_release_objectid (&th, inode->i_ino); journal_end(&th, inode->i_sb, jbegin_count) ; - up (&inode->i_sem); + up (&inode->i_sem); + + /* all items of file are deleted, so we can remove "save" link */ + remove_save_link (inode, 0/* not truncate */); } else { /* no object items are in the tree */ ; @@ -72,9 +76,9 @@ void make_cpu_key (struct cpu_key * key, const struct inode * inode, loff_t offset, int type, int length ) { - _make_cpu_key (key, inode_items_version (inode), le32_to_cpu (INODE_PKEY (inode)->k_dir_id), - le32_to_cpu (INODE_PKEY (inode)->k_objectid), - offset, type, length); + _make_cpu_key (key, get_inode_item_key_version (inode), le32_to_cpu (INODE_PKEY (inode)->k_dir_id), + le32_to_cpu (INODE_PKEY (inode)->k_objectid), + offset, type, length); } @@ -205,9 +209,7 @@ static inline void set_block_dev_mapped (struct buffer_head * bh, b_blocknr_t block, struct inode * inode) { - bh->b_dev = inode->i_dev; - bh->b_blocknr = block; - bh->b_state |= (1UL << BH_Mapped); + map_bh(bh, inode->i_sb, block); } @@ -215,9 +217,9 @@ // files which were created in the earlier version can not be longer, // than 2 gb // -int file_capable (struct inode * inode, long block) +static int file_capable (struct inode * inode, long block) { - if (inode_items_version (inode) != ITEM_VERSION_1 || // it is new file. + if (get_inode_item_key_version (inode) != KEY_FORMAT_3_5 || // it is new file. block < (1 << (31 - inode->i_sb->s_blocksize_bits))) // old file, but 'block' is inside of 2gb return 1; @@ -269,7 +271,9 @@ pathrelse (&path); if (p) kunmap(bh_result->b_page) ; - if ((args & GET_BLOCK_NO_HOLE)) { + // We do not return -ENOENT if there is a hole but page is uptodate, because it means + // That there is some MMAPED data associated with it that is yet to be written to disk. + if ((args & GET_BLOCK_NO_HOLE) && !Page_Uptodate(bh_result->b_page) ) { return -ENOENT ; } return 0 ; @@ -287,12 +291,14 @@ blocknr = get_block_num(ind_item, path.pos_in_item) ; ret = 0 ; if (blocknr) { - bh_result->b_dev = inode->i_dev; - bh_result->b_blocknr = blocknr; - bh_result->b_state |= (1UL << BH_Mapped); - } else if ((args & GET_BLOCK_NO_HOLE)) { - ret = -ENOENT ; - } + map_bh(bh_result, inode->i_sb, blocknr); + } else + // We do not return -ENOENT if there is a hole but page is uptodate, because it means + // That there is some MMAPED data associated with it that is yet to be written to disk. + if ((args & GET_BLOCK_NO_HOLE) && !Page_Uptodate(bh_result->b_page) ) { + ret = -ENOENT; + } + pathrelse (&path); if (p) kunmap(bh_result->b_page) ; @@ -380,10 +386,9 @@ finished: pathrelse (&path); - bh_result->b_blocknr = 0 ; - bh_result->b_dev = inode->i_dev; + /* I _really_ doubt that you want it. Chris? */ + map_bh(bh_result, inode->i_sb, 0); mark_buffer_uptodate (bh_result, 1); - bh_result->b_state |= (1UL << BH_Mapped); return 0; } @@ -540,7 +545,7 @@ /* bad.... */ lock_kernel() ; th.t_trans_id = 0 ; - version = inode_items_version (inode); + version = get_inode_item_key_version (inode); if (block < 0) { unlock_kernel(); @@ -564,7 +569,7 @@ return ret; } - inode->u.reiserfs_i.i_pack_on_close = 1 ; + inode->u.reiserfs_i.i_flags |= i_pack_on_close_mask; windex = push_journal_writer("reiserfs_get_block") ; @@ -880,7 +885,8 @@ struct stat_data_v1 * sd = (struct stat_data_v1 *)B_I_PITEM (bh, ih); unsigned long blocks; - inode_items_version (inode) = ITEM_VERSION_1; + set_inode_item_key_version (inode, KEY_FORMAT_3_5); + set_inode_sd_version (inode, STAT_DATA_V1); inode->i_mode = sd_v1_mode(sd); inode->i_nlink = sd_v1_nlink(sd); inode->i_uid = sd_v1_uid(sd); @@ -929,13 +935,13 @@ inode->i_generation = sd_v2_generation(sd); if (S_ISDIR (inode->i_mode) || S_ISLNK (inode->i_mode)) - inode_items_version (inode) = ITEM_VERSION_1; + set_inode_item_key_version (inode, KEY_FORMAT_3_5); else - inode_items_version (inode) = ITEM_VERSION_2; + set_inode_item_key_version (inode, KEY_FORMAT_3_6); } /* nopack = 0, by default */ - inode->u.reiserfs_i.nopack = 0; + inode->u.reiserfs_i.i_flags &= ~i_nopack_mask; pathrelse (path); if (S_ISREG (inode->i_mode)) { @@ -1115,7 +1121,7 @@ /* set version 1, version 2 could be used too, because stat data key is the same in both versions */ - key.version = ITEM_VERSION_1; + key.version = KEY_FORMAT_3_5; key.on_disk_key.k_dir_id = dirino; key.on_disk_key.k_objectid = inode->i_ino; key.on_disk_key.u.k_offset_v1.k_offset = SD_OFFSET; @@ -1138,6 +1144,30 @@ } init_inode (inode, &path_to_sd); + + /* It is possible that knfsd is trying to access inode of a file + that is being removed from the disk by some other thread. As we + update sd on unlink all that is required is to check for nlink + here. This bug was first found by Sizif when debugging + SquidNG/Butterfly, forgotten, and found again after Philippe + Gramoulle <philippe.gramoulle@mmania.com> reproduced it. + + More logical fix would require changes in fs/inode.c:iput() to + remove inode from hash-table _after_ fs cleaned disk stuff up and + in iget() to return NULL if I_FREEING inode is found in + hash-table. */ + /* Currently there is one place where it's ok to meet inode with + nlink==0: processing of open-unlinked and half-truncated files + during mount (fs/reiserfs/super.c:finish_unfinished()). */ + if( ( inode -> i_nlink == 0 ) && + ! inode -> i_sb -> u.reiserfs_sb.s_is_unlinked_ok ) { + reiserfs_warning( "vs-13075: reiserfs_read_inode2: " + "dead inode read from disk %K. " + "This is likely to be race with knfsd. Ignore\n", + &key ); + make_bad_inode( inode ); + } + reiserfs_check_path(&path_to_sd) ; /* init inode should be relsing */ } @@ -1162,7 +1192,7 @@ } struct dentry *reiserfs_fh_to_dentry(struct super_block *sb, __u32 *data, - int len, int fhtype, int parent) { + int len, int fhtype, int parent) { struct cpu_key key ; struct inode *inode = NULL ; struct list_head *lp; @@ -1303,26 +1333,6 @@ } } -void reiserfs_dirty_inode (struct inode * inode) { - struct reiserfs_transaction_handle th ; - - if (inode->i_sb->s_flags & MS_RDONLY) { - reiserfs_warning("clm-6006: writing inode %lu on readonly FS\n", - inode->i_ino) ; - return ; - } - lock_kernel() ; - - /* this is really only used for atime updates, so they don't have - ** to be included in O_SYNC or fsync - */ - journal_begin(&th, inode->i_sb, 1) ; - reiserfs_update_sd (&th, inode); - journal_end(&th, inode->i_sb, 1) ; - unlock_kernel() ; -} - - /* FIXME: no need any more. right? */ int reiserfs_sync_inode (struct reiserfs_transaction_handle *th, struct inode * inode) { @@ -1345,20 +1355,20 @@ struct cpu_key key; int retval; - _make_cpu_key (&key, ITEM_VERSION_1, le32_to_cpu (ih->ih_key.k_dir_id), + _make_cpu_key (&key, KEY_FORMAT_3_5, le32_to_cpu (ih->ih_key.k_dir_id), le32_to_cpu (ih->ih_key.k_objectid), DOT_OFFSET, TYPE_DIRENTRY, 3/*key length*/); /* compose item head for new item. Directories consist of items of old type (ITEM_VERSION_1). Do not set key (second arg is 0), it is done by reiserfs_new_inode */ if (old_format_only (sb)) { - make_le_item_head (ih, 0, ITEM_VERSION_1, DOT_OFFSET, TYPE_DIRENTRY, EMPTY_DIR_SIZE_V1, 2); + make_le_item_head (ih, 0, KEY_FORMAT_3_5, DOT_OFFSET, TYPE_DIRENTRY, EMPTY_DIR_SIZE_V1, 2); make_empty_dir_item_v1 (body, ih->ih_key.k_dir_id, ih->ih_key.k_objectid, INODE_PKEY (dir)->k_dir_id, INODE_PKEY (dir)->k_objectid ); } else { - make_le_item_head (ih, 0, ITEM_VERSION_1, DOT_OFFSET, TYPE_DIRENTRY, EMPTY_DIR_SIZE, 2); + make_le_item_head (ih, 0, KEY_FORMAT_3_5, DOT_OFFSET, TYPE_DIRENTRY, EMPTY_DIR_SIZE, 2); make_empty_dir_item (body, ih->ih_key.k_dir_id, ih->ih_key.k_objectid, INODE_PKEY (dir)->k_dir_id, @@ -1394,12 +1404,12 @@ struct cpu_key key; int retval; - _make_cpu_key (&key, ITEM_VERSION_1, + _make_cpu_key (&key, KEY_FORMAT_3_5, le32_to_cpu (ih->ih_key.k_dir_id), le32_to_cpu (ih->ih_key.k_objectid), 1, TYPE_DIRECT, 3/*key length*/); - make_le_item_head (ih, 0, ITEM_VERSION_1, 1, TYPE_DIRECT, item_len, 0/*free_space*/); + make_le_item_head (ih, 0, KEY_FORMAT_3_5, 1, TYPE_DIRECT, item_len, 0/*free_space*/); /* look for place in the tree for new item */ retval = search_item (sb, &key, path); @@ -1470,13 +1480,13 @@ inode->i_generation = ++event; #endif if (old_format_only (sb)) - make_le_item_head (&ih, 0, ITEM_VERSION_1, SD_OFFSET, TYPE_STAT_DATA, SD_V1_SIZE, MAX_US_INT); + make_le_item_head (&ih, 0, KEY_FORMAT_3_5, SD_OFFSET, TYPE_STAT_DATA, SD_V1_SIZE, MAX_US_INT); else - make_le_item_head (&ih, 0, ITEM_VERSION_2, SD_OFFSET, TYPE_STAT_DATA, SD_SIZE, MAX_US_INT); + make_le_item_head (&ih, 0, KEY_FORMAT_3_6, SD_OFFSET, TYPE_STAT_DATA, SD_SIZE, MAX_US_INT); /* key to search for correct place for new stat data */ - _make_cpu_key (&key, ITEM_VERSION_2, le32_to_cpu (ih.ih_key.k_dir_id), + _make_cpu_key (&key, KEY_FORMAT_3_6, le32_to_cpu (ih.ih_key.k_dir_id), le32_to_cpu (ih.ih_key.k_objectid), SD_OFFSET, TYPE_STAT_DATA, 3/*key length*/); /* find proper place for inserting of stat data */ @@ -1512,9 +1522,16 @@ INIT_LIST_HEAD(&inode->u.reiserfs_i.i_prealloc_list) ; - if (old_format_only (sb)) + if (old_format_only (sb)) { + if (inode->i_uid & ~0xffff || inode->i_gid & ~0xffff) { + pathrelse (&path_to_key); + /* i_uid or i_gid is too big to be stored in stat data v3.5 */ + iput (inode); + *err = -EINVAL; + return NULL; + } inode2sd_v1 (&sd, inode); - else + } else inode2sd (&sd, inode); // these do not go to on-disk stat data @@ -1527,10 +1544,14 @@ // format, other new objects will consist of new items) memcpy (INODE_PKEY (inode), &(ih.ih_key), KEY_SIZE); if (old_format_only (sb) || S_ISDIR(mode) || S_ISLNK(mode)) - inode_items_version (inode) = ITEM_VERSION_1; + set_inode_item_key_version (inode, KEY_FORMAT_3_5); else - inode_items_version (inode) = ITEM_VERSION_2; - + set_inode_item_key_version (inode, KEY_FORMAT_3_6); + if (old_format_only (sb)) + set_inode_sd_version (inode, STAT_DATA_V1); + else + set_inode_sd_version (inode, STAT_DATA_V2); + /* insert the stat data into the tree */ retval = reiserfs_insert_item (th, &path_to_key, &key, &ih, (char *)(&sd)); if (retval) { @@ -1690,12 +1711,23 @@ ** because the truncate might pack the item anyway ** (it will unmap bh if it packs). */ - journal_begin(&th, p_s_inode->i_sb, JOURNAL_PER_BALANCE_CNT * 2 ) ; + /* it is enough to reserve space in transaction for 2 balancings: + one for "save" link adding and another for the first + cut_from_item. 1 is for update_sd */ + journal_begin(&th, p_s_inode->i_sb, JOURNAL_PER_BALANCE_CNT * 2 + 1 ) ; reiserfs_update_inode_transaction(p_s_inode) ; windex = push_journal_writer("reiserfs_vfs_truncate_file") ; + if (update_timestamps) + /* we are doing real truncate: if the system crashes before the last + transaction of truncating gets committed - on reboot the file + either appears truncated properly or not truncated at all */ + add_save_link (&th, p_s_inode, 1); reiserfs_do_truncate (&th, p_s_inode, page, update_timestamps) ; pop_journal_writer(windex) ; - journal_end(&th, p_s_inode->i_sb, JOURNAL_PER_BALANCE_CNT * 2 ) ; + journal_end(&th, p_s_inode->i_sb, JOURNAL_PER_BALANCE_CNT * 2 + 1 ) ; + + if (update_timestamps) + remove_save_link (p_s_inode, 1/* truncate */); if (page) { length = offset & (blocksize - 1) ; @@ -1735,6 +1767,7 @@ int bytes_copied = 0 ; int copy_size ; + kmap(bh_result->b_page) ; start_over: lock_kernel() ; journal_begin(&th, inode->i_sb, jbegin_count) ; @@ -1807,10 +1840,8 @@ /* this is where we fill in holes in the file. */ if (use_get_block) { - kmap(bh_result->b_page) ; retval = reiserfs_get_block(inode, block, bh_result, GET_BLOCK_CREATE | GET_BLOCK_NO_ISEM) ; - kunmap(bh_result->b_page) ; if (!retval) { if (!buffer_mapped(bh_result) || bh_result->b_blocknr == 0) { /* get_block failed to find a mapped unformatted node. */ @@ -1819,6 +1850,7 @@ } } } + kunmap(bh_result->b_page) ; return retval ; } diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/fs/reiserfs/ioctl.c linux-2.5/fs/reiserfs/ioctl.c --- linux-2.5.1/fs/reiserfs/ioctl.c Sat Sep 8 19:05:32 2001 +++ linux-2.5/fs/reiserfs/ioctl.c Thu Dec 13 16:32:37 2001 @@ -46,7 +46,7 @@ return -EINVAL ; } /* ioctl already done */ - if (inode->u.reiserfs_i.nopack) { + if (inode->u.reiserfs_i.i_flags & i_nopack_mask) { return 0 ; } lock_kernel(); @@ -59,7 +59,7 @@ write_from = inode->i_size & (blocksize - 1) ; /* if we are on a block boundary, we are already unpacked. */ if ( write_from == 0) { - inode->u.reiserfs_i.nopack = 1; + inode->u.reiserfs_i.i_flags |= i_nopack_mask; goto out ; } @@ -79,7 +79,7 @@ /* conversion can change page contents, must flush */ flush_dcache_page(page) ; - inode->u.reiserfs_i.nopack = 1; + inode->u.reiserfs_i.i_flags |= i_nopack_mask; kunmap(page) ; /* mapped by prepare_write */ out_unlock: diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/fs/reiserfs/journal.c linux-2.5/fs/reiserfs/journal.c --- linux-2.5.1/fs/reiserfs/journal.c Sun Dec 16 20:23:05 2001 +++ linux-2.5/fs/reiserfs/journal.c Mon Dec 17 01:03:07 2001 @@ -92,6 +92,8 @@ static int flush_journal_list(struct super_block *s, struct reiserfs_journal_list *jl, int flushall) ; static int flush_commit_list(struct super_block *s, struct reiserfs_journal_list *jl, int flushall) ; static int can_dirty(struct reiserfs_journal_cnode *cn) ; +static int remove_from_journal_list(struct super_block *s, struct reiserfs_journal_list *jl, struct buffer_head *bh, int remove_freed); +static int journal_join(struct reiserfs_transaction_handle *th, struct super_block *p_s_sb, unsigned long nblocks); static void init_journal_hash(struct super_block *p_s_sb) { memset(SB_JOURNAL(p_s_sb)->j_hash_table, 0, JOURNAL_HASH_SIZE * sizeof(struct reiserfs_journal_cnode *)) ; @@ -1694,7 +1696,7 @@ /* step three, starting at the oldest transaction, replay */ if (last_flush_start > 0) { oldest_start = last_flush_start ; - oldest_trans_id = last_flush_trans_id ; + oldest_trans_id = last_flush_trans_id + 1 ; } cur_dblock = oldest_start ; if (oldest_trans_id) { @@ -1714,6 +1716,8 @@ } cur_dblock = reiserfs_get_journal_block(p_s_sb) + SB_JOURNAL(p_s_sb)->j_start ; replay_count++ ; + if (cur_dblock == oldest_start) + break; } if (oldest_trans_id == 0) { @@ -2080,7 +2084,7 @@ } -int journal_join(struct reiserfs_transaction_handle *th, struct super_block *p_s_sb, unsigned long nblocks) { +static int journal_join(struct reiserfs_transaction_handle *th, struct super_block *p_s_sb, unsigned long nblocks) { return do_journal_begin_r(th, p_s_sb, nblocks, 1) ; } @@ -2235,7 +2239,7 @@ ** ** returns 1 if it cleaned and relsed the buffer. 0 otherwise */ -int remove_from_transaction(struct super_block *p_s_sb, unsigned long blocknr, int already_cleaned) { +static int remove_from_transaction(struct super_block *p_s_sb, unsigned long blocknr, int already_cleaned) { struct buffer_head *bh ; struct reiserfs_journal_cnode *cn ; int ret = 0; @@ -2276,7 +2280,7 @@ } /* removes from a specific journal list hash */ -int remove_from_journal_list(struct super_block *s, struct reiserfs_journal_list *jl, struct buffer_head *bh, int remove_freed) { +static int remove_from_journal_list(struct super_block *s, struct reiserfs_journal_list *jl, struct buffer_head *bh, int remove_freed) { remove_journal_hash(SB_JOURNAL(s)->j_list_hash_table, jl, bh, remove_freed) ; return 0 ; } @@ -2338,20 +2342,6 @@ int show_reiserfs_locks(void) { dump_journal_writers() ; -#if 0 /* debugging code for when we are compiled static don't delete */ - p_s_sb = sb_entry(super_blocks.next); - while (p_s_sb != sb_entry(&super_blocks)) { - if (reiserfs_is_super(p_s_sb)) { -printk("journal lock is %d, join lock is %d, writers %d must wait is %d\n", - atomic_read(&(SB_JOURNAL(p_s_sb)->j_wlock)), - atomic_read(&(SB_JOURNAL(p_s_sb)->j_jlock)), - atomic_read(&(SB_JOURNAL(p_s_sb)->j_wcount)), - SB_JOURNAL(p_s_sb)->j_must_wait) ; - printk("used cnodes %d, free cnodes %d\n", SB_JOURNAL(p_s_sb)->j_cnode_used, SB_JOURNAL(p_s_sb)->j_cnode_free) ; - } - p_s_sb = sb_entry(p_s_sb->s_list.next); - } -#endif return 0 ; } diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/fs/reiserfs/lbalance.c linux-2.5/fs/reiserfs/lbalance.c --- linux-2.5.1/fs/reiserfs/lbalance.c Tue Oct 30 23:11:34 2001 +++ linux-2.5/fs/reiserfs/lbalance.c Thu Dec 13 16:32:37 2001 @@ -63,7 +63,7 @@ /* form item header */ memcpy (&new_ih.ih_key, &ih->ih_key, KEY_SIZE); - put_ih_version( &new_ih, ITEM_VERSION_1 ); + put_ih_version( &new_ih, KEY_FORMAT_3_5 ); /* calculate item len */ put_ih_item_len( &new_ih, DEH_SIZE * copy_count + copy_records_len ); put_ih_entry_count( &new_ih, 0 ); @@ -78,7 +78,7 @@ set_le_ih_k_offset (&new_ih, U32_MAX); /* this item is not yet valid, but we want I_IS_DIRECTORY_ITEM to return 1 for it, so we -1 */ } - set_le_key_k_type (ITEM_VERSION_1, &(new_ih.ih_key), TYPE_DIRENTRY); + set_le_key_k_type (KEY_FORMAT_3_5, &(new_ih.ih_key), TYPE_DIRENTRY); } /* insert item into dest buffer */ diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/fs/reiserfs/namei.c linux-2.5/fs/reiserfs/namei.c --- linux-2.5.1/fs/reiserfs/namei.c Fri Nov 9 22:18:25 2001 +++ linux-2.5/fs/reiserfs/namei.c Thu Dec 13 16:32:37 2001 @@ -17,17 +17,6 @@ #include <linux/reiserfs_fs.h> #include <linux/smp_lock.h> - /* there should be an overview right - here, as there should be in every - conceptual grouping of code. This - should be combined with dir.c and - called dir.c (naming will become - too large to be called one file in - a few years), stop senselessly - imitating the incoherent - structuring of code used by other - filesystems. */ - #define INC_DIR_INODE_NLINK(i) if (i->i_nlink != 1) { i->i_nlink++; if (i->i_nlink >= REISERFS_LINK_MAX) i->i_nlink=1; } #define DEC_DIR_INODE_NLINK(i) if (i->i_nlink != 1) i->i_nlink--; @@ -105,7 +94,7 @@ BUG (); /* store key of the found entry */ - de->de_entry_key.version = ITEM_VERSION_1; + de->de_entry_key.version = KEY_FORMAT_3_5; de->de_entry_key.on_disk_key.k_dir_id = le32_to_cpu (de->de_ih->ih_key.k_dir_id); de->de_entry_key.on_disk_key.k_objectid = le32_to_cpu (de->de_ih->ih_key.k_objectid); set_cpu_key_k_offset (&(de->de_entry_key), deh_offset (deh)); @@ -347,7 +336,7 @@ // at the ext2 code and comparing. It's subfunctions contain no code // used as a template unless they are so labeled. // -struct dentry * reiserfs_lookup (struct inode * dir, struct dentry * dentry) +static struct dentry * reiserfs_lookup (struct inode * dir, struct dentry * dentry) { int retval; struct inode * inode = 0; @@ -373,7 +362,6 @@ return NULL; } - // // a portion of this function, particularly the VFS interface portion, // was derived from minix or ext2's analog and evolved as the @@ -518,7 +506,7 @@ // at the ext2 code and comparing. It's subfunctions contain no code // used as a template unless they are so labeled. // -int reiserfs_create (struct inode * dir, struct dentry *dentry, int mode) +static int reiserfs_create (struct inode * dir, struct dentry *dentry, int mode) { int retval; struct inode * inode; @@ -574,7 +562,7 @@ // at the ext2 code and comparing. It's subfunctions contain no code // used as a template unless they are so labeled. // -int reiserfs_mknod (struct inode * dir, struct dentry *dentry, int mode, int rdev) +static int reiserfs_mknod (struct inode * dir, struct dentry *dentry, int mode, int rdev) { int retval; struct inode * inode; @@ -629,7 +617,7 @@ // at the ext2 code and comparing. It's subfunctions contain no code // used as a template unless they are so labeled. // -int reiserfs_mkdir (struct inode * dir, struct dentry *dentry, int mode) +static int reiserfs_mkdir (struct inode * dir, struct dentry *dentry, int mode) { int retval; struct inode * inode; @@ -708,17 +696,20 @@ // at the ext2 code and comparing. It's subfunctions contain no code // used as a template unless they are so labeled. // -int reiserfs_rmdir (struct inode * dir, struct dentry *dentry) +static int reiserfs_rmdir (struct inode * dir, struct dentry *dentry) { int retval; struct inode * inode; int windex ; struct reiserfs_transaction_handle th ; - int jbegin_count = JOURNAL_PER_BALANCE_CNT * 3; + int jbegin_count; INITIALIZE_PATH (path); struct reiserfs_dir_entry de; + /* we will be doing 2 balancings and update 2 stat data */ + jbegin_count = JOURNAL_PER_BALANCE_CNT * 2 + 2; + journal_begin(&th, dir->i_sb, jbegin_count) ; windex = push_journal_writer("reiserfs_rmdir") ; @@ -762,6 +753,9 @@ dir->i_blocks = ((dir->i_size + 511) >> 9); reiserfs_update_sd (&th, dir); + /* prevent empty directory from getting lost */ + add_save_link (&th, inode, 0/* not truncate */); + pop_journal_writer(windex) ; journal_end(&th, dir->i_sb, jbegin_count) ; reiserfs_check_path(&path) ; @@ -785,7 +779,7 @@ // at the ext2 code and comparing. It's subfunctions contain no code // used as a template unless they are so labeled. // -int reiserfs_unlink (struct inode * dir, struct dentry *dentry) +static int reiserfs_unlink (struct inode * dir, struct dentry *dentry) { int retval; struct inode * inode; @@ -793,7 +787,13 @@ INITIALIZE_PATH (path); int windex ; struct reiserfs_transaction_handle th ; - int jbegin_count = JOURNAL_PER_BALANCE_CNT * 3; + int jbegin_count; + + inode = dentry->d_inode; + + /* in this transaction we can be doing at max two balancings and update + two stat datas */ + jbegin_count = JOURNAL_PER_BALANCE_CNT * 2 + 2; journal_begin(&th, dir->i_sb, jbegin_count) ; windex = push_journal_writer("reiserfs_unlink") ; @@ -803,7 +803,6 @@ retval = -ENOENT; goto end_unlink; } - inode = dentry->d_inode; reiserfs_update_inode_transaction(inode) ; reiserfs_update_inode_transaction(dir) ; @@ -834,6 +833,10 @@ dir->i_ctime = dir->i_mtime = CURRENT_TIME; reiserfs_update_sd (&th, dir); + if (!inode->i_nlink) + /* prevent file from getting lost */ + add_save_link (&th, inode, 0/* not truncate */); + pop_journal_writer(windex) ; journal_end(&th, dir->i_sb, jbegin_count) ; reiserfs_check_path(&path) ; @@ -855,7 +858,7 @@ // at the ext2 code and comparing. It's subfunctions contain no code // used as a template unless they are so labeled. // -int reiserfs_symlink (struct inode * dir, struct dentry * dentry, const char * symname) +static int reiserfs_symlink (struct inode * dir, struct dentry * dentry, const char * symname) { int retval; struct inode * inode; @@ -932,7 +935,7 @@ // at the ext2 code and comparing. It's subfunctions contain no code // used as a template unless they are so labeled. // -int reiserfs_link (struct dentry * old_dentry, struct inode * dir, struct dentry * dentry) +static int reiserfs_link (struct dentry * old_dentry, struct inode * dir, struct dentry * dentry) { int retval; struct inode *inode = old_dentry->d_inode; @@ -1032,8 +1035,8 @@ * one path. If it holds 2 or more, it can get into endless waiting in * get_empty_nodes or its clones */ -int reiserfs_rename (struct inode * old_dir, struct dentry *old_dentry, - struct inode * new_dir, struct dentry *new_dentry) +static int reiserfs_rename (struct inode * old_dir, struct dentry *old_dentry, + struct inode * new_dir, struct dentry *new_dentry) { int retval; INITIALIZE_PATH (old_entry_path); @@ -1044,8 +1047,13 @@ struct inode * old_inode, * new_inode; int windex ; struct reiserfs_transaction_handle th ; - int jbegin_count = JOURNAL_PER_BALANCE_CNT * 3; + int jbegin_count ; + + /* two balancings: old name removal, new name insertion or "save" link, + stat data updates: old directory and new directory and maybe block + containing ".." of renamed directory */ + jbegin_count = JOURNAL_PER_BALANCE_CNT * 3 + 3; old_inode = old_dentry->d_inode; new_inode = new_dentry->d_inode; @@ -1096,8 +1104,8 @@ // FIXME: is it possible, that new_inode == 0 here? If yes, it // is not clear how does ext2 handle that if (!new_inode) { - printk ("reiserfs_rename: new entry is found, new inode == 0\n"); - BUG (); + reiserfs_panic (old_dir->i_sb, + "vs-7050: new entry is found, new inode == 0\n"); } } else if (retval) { pop_journal_writer(windex) ; @@ -1164,13 +1172,6 @@ reiserfs_restore_prepared_buffer (old_inode->i_sb, new_de.de_bh); if (S_ISDIR(old_inode->i_mode)) reiserfs_restore_prepared_buffer (old_inode->i_sb, dot_dot_de.de_bh); -#if 0 - // FIXME: do we need this? shouldn't we simply continue? - run_task_queue(&tq_disk); - current->policy |= SCHED_YIELD; - /*current->counter = 0;*/ - schedule(); -#endif continue; } @@ -1195,29 +1196,25 @@ if (new_inode) { // adjust link number of the victim if (S_ISDIR(new_inode->i_mode)) { - DEC_DIR_INODE_NLINK(new_inode) + new_inode->i_nlink = 0; } else { - new_inode->i_nlink--; + new_inode->i_nlink--; } new_inode->i_ctime = CURRENT_TIME; } if (S_ISDIR(old_inode->i_mode)) { - //if (dot_dot_de.de_bh) { - // adjust ".." of renamed directory + // adjust ".." of renamed directory set_ino_in_dir_entry (&dot_dot_de, INODE_PKEY (new_dir)); journal_mark_dirty (&th, new_dir->i_sb, dot_dot_de.de_bh); - - DEC_DIR_INODE_NLINK(old_dir) - if (new_inode) { - if (S_ISDIR(new_inode->i_mode)) { - DEC_DIR_INODE_NLINK(new_inode) - } else { - new_inode->i_nlink--; - } - } else { - INC_DIR_INODE_NLINK(new_dir) - } + + if (!new_inode) + /* there (in new_dir) was no directory, so it got new link + (".." of renamed directory) */ + INC_DIR_INODE_NLINK(new_dir); + + /* old directory lost one link - ".. " of renamed directory */ + DEC_DIR_INODE_NLINK(old_dir); } // looks like in 2.3.99pre3 brelse is atomic. so we can use pathrelse @@ -1228,18 +1225,40 @@ // anybody, but it will panic if will not be able to find the // entry. This needs one more clean up if (reiserfs_cut_from_item (&th, &old_entry_path, &(old_de.de_entry_key), old_dir, NULL, 0) < 0) - reiserfs_warning ("vs-: reiserfs_rename: coudl not cut old name. Fsck later?\n"); + reiserfs_warning ("vs-7060: reiserfs_rename: couldn't not cut old name. Fsck later?\n"); old_dir->i_size -= DEH_SIZE + old_de.de_entrylen; old_dir->i_blocks = ((old_dir->i_size + 511) >> 9); reiserfs_update_sd (&th, old_dir); reiserfs_update_sd (&th, new_dir); - if (new_inode) + + if (new_inode) { + if (new_inode->i_nlink == 0) + add_save_link (&th, new_inode, 0/* not truncate */); reiserfs_update_sd (&th, new_inode); + } pop_journal_writer(windex) ; journal_end(&th, old_dir->i_sb, jbegin_count) ; return 0; } + + + +/* + * directories can handle most operations... + */ +struct inode_operations reiserfs_dir_inode_operations = { + //&reiserfs_dir_operations, /* default_file_ops */ + create: reiserfs_create, + lookup: reiserfs_lookup, + link: reiserfs_link, + unlink: reiserfs_unlink, + symlink: reiserfs_symlink, + mkdir: reiserfs_mkdir, + rmdir: reiserfs_rmdir, + mknod: reiserfs_mknod, + rename: reiserfs_rename, +}; diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/fs/reiserfs/objectid.c linux-2.5/fs/reiserfs/objectid.c --- linux-2.5.1/fs/reiserfs/objectid.c Fri Nov 9 22:18:25 2001 +++ linux-2.5/fs/reiserfs/objectid.c Thu Dec 13 16:32:37 2001 @@ -162,7 +162,7 @@ i += 2; } - reiserfs_warning ("vs-15010: reiserfs_release_objectid: tried to free free object id (%lu)", + reiserfs_warning ("vs-15011: reiserfs_release_objectid: tried to free free object id (%lu)\n", ( long unsigned ) objectid_to_release); } diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/fs/reiserfs/prints.c linux-2.5/fs/reiserfs/prints.c --- linux-2.5.1/fs/reiserfs/prints.c Fri Nov 9 22:18:25 2001 +++ linux-2.5/fs/reiserfs/prints.c Thu Dec 13 16:32:37 2001 @@ -109,7 +109,7 @@ static void sprintf_item_head (char * buf, struct item_head * ih) { if (ih) { - sprintf (buf, "%s", (ih_version (ih) == ITEM_VERSION_2) ? "*NEW* " : "*OLD*"); + sprintf (buf, "%s", (ih_version (ih) == KEY_FORMAT_3_6) ? "*3.6* " : "*3.5*"); sprintf_le_key (buf + strlen (buf), &(ih->ih_key)); sprintf (buf + strlen (buf), ", item_len %d, item_location %d, " "free_space(entry_count) %d", diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/fs/reiserfs/procfs.c linux-2.5/fs/reiserfs/procfs.c --- linux-2.5.1/fs/reiserfs/procfs.c Fri Nov 9 22:18:25 2001 +++ linux-2.5/fs/reiserfs/procfs.c Wed Dec 19 01:08:32 2001 @@ -15,6 +15,7 @@ #include <linux/sched.h> #include <asm/uaccess.h> #include <linux/reiserfs_fs.h> +#include <linux/reiserfs_fs_sb.h> #include <linux/smp_lock.h> #include <linux/locks.h> #include <linux/init.h> @@ -76,12 +77,20 @@ { int len = 0; struct super_block *sb; + char *format; sb = procinfo_prologue( ( kdev_t ) ( int ) data ); if( sb == NULL ) return -ENOENT; + if ( sb->u.reiserfs_sb.s_properties & (1 << REISERFS_3_6) ) { + format = "3.6"; + } else if ( sb->u.reiserfs_sb.s_properties & (1 << REISERFS_3_5) ) { + format = "3.5"; + } else { + format = "unknown"; + } len += sprintf( &buffer[ len ], "%s format\twith checks %s\n", - old_format_only( sb ) ? "old" : "new", + format, #if defined( CONFIG_REISERFS_CHECK ) "on" #else @@ -179,7 +188,7 @@ dont_have_tails( sb ) ? "NO_TAILS " : "TAILS ", replay_only( sb ) ? "REPLAY_ONLY " : "", reiserfs_dont_log( sb ) ? "DONT_LOG " : "LOG ", - old_format_only( sb ) ? "CONV " : "", + convert_reiserfs( sb ) ? "CONV " : "", atomic_read( &r -> s_generation_counter ), SF( s_kmallocs ), diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/fs/reiserfs/resize.c linux-2.5/fs/reiserfs/resize.c --- linux-2.5.1/fs/reiserfs/resize.c Sun Dec 16 20:23:05 2001 +++ linux-2.5/fs/reiserfs/resize.c Thu Dec 27 23:16:26 2001 @@ -111,7 +111,7 @@ for (i = 0; i < bmap_nr; i++) bitmap[i] = SB_AP_BITMAP(s)[i]; for (i = bmap_nr; i < bmap_nr_new; i++) { - bitmap[i] = reiserfs_getblk(s->s_dev, i * s->s_blocksize * 8, s->s_blocksize); + bitmap[i] = getblk(s->s_dev, i * s->s_blocksize * 8, s->s_blocksize); memset(bitmap[i]->b_data, 0, sb->s_blocksize); reiserfs_test_and_set_le_bit(0, bitmap[i]->b_data); diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/fs/reiserfs/stree.c linux-2.5/fs/reiserfs/stree.c --- linux-2.5.1/fs/reiserfs/stree.c Sun Dec 16 20:23:05 2001 +++ linux-2.5/fs/reiserfs/stree.c Thu Dec 27 22:08:18 2001 @@ -225,7 +225,7 @@ // find out version of the key to->version = le_key_version (from); - if (to->version == ITEM_VERSION_1) { + if (to->version == KEY_FORMAT_3_5) { to->on_disk_key.u.k_offset_v1.k_offset = le32_to_cpu (from->u.k_offset_v1.k_offset); to->on_disk_key.u.k_offset_v1.k_uniqueness = le32_to_cpu (from->u.k_offset_v1.k_uniqueness); } else { @@ -604,7 +604,7 @@ if (blocknr == 0) return; - bh = reiserfs_getblk (s->s_dev, blocknr, s->s_blocksize); + bh = reiserfs_getblk (s, blocknr); if (!buffer_uptodate (bh)) { ll_rw_block (READA, 1, &bh); @@ -649,8 +649,7 @@ DISK_LEAF_NODE_LEVEL */ ) { int n_block_number = SB_ROOT_BLOCK (p_s_sb), - expected_level = SB_TREE_HEIGHT (p_s_sb), - n_block_size = p_s_sb->s_blocksize; + expected_level = SB_TREE_HEIGHT (p_s_sb); struct buffer_head * p_s_bh; struct path_element * p_s_last_element; int n_node_level, n_retval; @@ -697,7 +696,7 @@ /* Read the next tree node, and set the last element in the path to have a pointer to it. */ if ( ! (p_s_bh = p_s_last_element->pe_buffer = - reiserfs_bread(p_s_sb, n_block_number, n_block_size)) ) { + reiserfs_bread(p_s_sb, n_block_number)) ) { p_s_search_path->path_length --; pathrelse(p_s_search_path); return IO_ERROR; @@ -727,7 +726,11 @@ continue; } - RFALSE( ! key_in_buffer(p_s_search_path, p_s_key, p_s_sb), + /* only check that the key is in the buffer if p_s_key is not + equal to the MAX_KEY. Latter case is only possible in + "finish_unfinished()" processing during mount. */ + RFALSE( COMP_KEYS( &MAX_KEY, p_s_key ) && + ! key_in_buffer(p_s_search_path, p_s_key, p_s_sb), "PAP-5130: key is not in the buffer"); #ifdef CONFIG_REISERFS_CHECK if ( cur_tb ) { @@ -917,7 +920,7 @@ } // new file gets truncated - if (inode_items_version (inode) == ITEM_VERSION_2) { + if (get_inode_item_key_version (inode) == KEY_FORMAT_3_6) { // round_len = ROUND_UP (new_file_length); /* this was n_new_file_length < le_ih ... */ @@ -992,10 +995,6 @@ struct item_head * p_le_ih = PATH_PITEM_HEAD(p_s_path); struct buffer_head * p_s_bh = PATH_PLAST_BUFFER(p_s_path); -#ifdef CONFIG_REISERFS_CHECK - int n_repeat_counter = 0; -#endif - /* Stat_data item. */ if ( is_statdata_le_ih (p_le_ih) ) { @@ -1020,13 +1019,11 @@ { int n_unfm_number, /* Number of the item unformatted nodes. */ n_counter, - n_retry, /* Set to one if there is unformatted node buffer in use. */ n_blk_size; __u32 * p_n_unfm_pointer; /* Pointer to the unformatted node number. */ __u32 tmp; struct item_head s_ih; /* Item header. */ char c_mode; /* Returned mode of the balance. */ - struct buffer_head * p_s_un_bh; int need_research; @@ -1099,8 +1096,8 @@ // note: path could be changed, first line in for loop takes care // of it - for ( n_retry = 0, n_counter = *p_n_removed; - n_counter < n_unfm_number; n_counter++, p_n_unfm_pointer-- ) { + for (n_counter = *p_n_removed; + n_counter < n_unfm_number; n_counter++, p_n_unfm_pointer-- ) { if (item_moved (&s_ih, p_s_path)) { need_research = 1 ; @@ -1110,69 +1107,23 @@ p_n_unfm_pointer > (__u32 *)B_I_PITEM(p_s_bh, &s_ih) + I_UNFM_NUM(&s_ih) - 1, "vs-5265: pointer out of range"); - if ( ! get_block_num(p_n_unfm_pointer,0) ) { /* Hole, nothing to remove. */ - if ( ! n_retry ) + /* Hole, nothing to remove. */ + if ( ! get_block_num(p_n_unfm_pointer,0) ) { (*p_n_removed)++; - continue; - } - /* Search for the buffer in cache. */ - p_s_un_bh = sb_get_hash_table(p_s_sb, get_block_num(p_n_unfm_pointer,0)); - - if (p_s_un_bh) { - mark_buffer_clean(p_s_un_bh) ; - if (buffer_locked(p_s_un_bh)) { - __wait_on_buffer(p_s_un_bh) ; - } - /* even if the item moves, the block number of the - ** unformatted node we want to cut won't. So, it was - ** safe to clean the buffer here, this block _will_ - ** get freed during this call to prepare_for_delete_or_cut - */ - if ( item_moved (&s_ih, p_s_path) ) { - need_research = 1; - brelse(p_s_un_bh) ; - break ; - } + continue; } - if ( p_s_un_bh && block_in_use (p_s_un_bh)) { - /* Block is locked or held more than by one holder and by - journal. */ -#ifdef CONFIG_REISERFS_CHECK - if (n_repeat_counter && (n_repeat_counter % 100000) == 0) { - printk("prepare_for_delete, waiting on buffer %lu, b_count %d, %s%cJDIRTY %cJDIRTY_WAIT\n", - p_s_un_bh->b_blocknr, atomic_read (&p_s_un_bh->b_count), - buffer_locked (p_s_un_bh) ? "locked, " : "", - buffer_journaled(p_s_un_bh) ? ' ' : '!', - buffer_journal_dirty(p_s_un_bh) ? ' ' : '!') ; - - } -#endif - n_retry = 1; - brelse (p_s_un_bh); - continue; - } - - if ( ! n_retry ) - (*p_n_removed)++; - - RFALSE( p_s_un_bh && - get_block_num(p_n_unfm_pointer, 0) != p_s_un_bh->b_blocknr, - // note: minix_truncate allows that. As truncate is - // protected by down (inode->i_sem), two truncates can not - // co-exist - "PAP-5280: blocks numbers are different"); + (*p_n_removed)++; tmp = get_block_num(p_n_unfm_pointer,0); put_block_num(p_n_unfm_pointer, 0, 0); journal_mark_dirty (th, p_s_sb, p_s_bh); - bforget (p_s_un_bh); inode->i_blocks -= p_s_sb->s_blocksize / 512; reiserfs_free_block(th, tmp); if ( item_moved (&s_ih, p_s_path) ) { - need_research = 1; - break ; - } + need_research = 1; + break ; + } } /* a trick. If the buffer has been logged, this @@ -1182,28 +1133,6 @@ */ reiserfs_restore_prepared_buffer(p_s_sb, p_s_bh); - if ( n_retry ) { - /* There is block in use. Wait, they should release it soon */ - - RFALSE( *p_n_removed >= n_unfm_number, "PAP-5290: illegal case"); -#ifdef CONFIG_REISERFS_CHECK - if ( !(++n_repeat_counter % 500000) ) { - reiserfs_warning("PAP-5300: prepare_for_delete_or_cut: (pid %u): " - "could not delete item %k in (%d) iterations. New file length %Lu. (inode %Ld), Still trying\n", - current->pid, p_s_item_key, n_repeat_counter, n_new_file_length, inode->i_size); - if (n_repeat_counter == 5000000) { - print_block (PATH_PLAST_BUFFER(p_s_path), 3, - PATH_LAST_POSITION (p_s_path) - 2, PATH_LAST_POSITION (p_s_path) + 2); - reiserfs_panic(p_s_sb, "PAP-5305: prepare_for_delete_or_cut: key %k, new_file_length %Ld", - p_s_item_key, n_new_file_length); - } - } -#endif - - run_task_queue(&tq_disk); - current->policy |= SCHED_YIELD; - schedule(); - } /* This loop can be optimized. */ } while ( (*p_n_removed < n_unfm_number || need_research) && search_for_position_by_key(p_s_sb, p_s_item_key, p_s_path) == POSITION_FOUND ); @@ -1388,8 +1317,8 @@ /* this deletes item which never gets split */ -static void reiserfs_delete_solid_item (struct reiserfs_transaction_handle *th, - struct key * key) +void reiserfs_delete_solid_item (struct reiserfs_transaction_handle *th, + struct key * key) { struct tree_balance tb; INITIALIZE_PATH (path); @@ -1403,13 +1332,13 @@ while (1) { retval = search_item (th->t_super, &cpu_key, &path); if (retval == IO_ERROR) { - reiserfs_warning ("vs-: reiserfs_delete_solid_item: " + reiserfs_warning ("vs-5350: reiserfs_delete_solid_item: " "i/o failure occurred trying to delete %K\n", &cpu_key); break; } if (retval != ITEM_FOUND) { pathrelse (&path); - reiserfs_warning ("vs-: reiserfs_delete_solid_item: %k not found", + reiserfs_warning ("vs-5355: reiserfs_delete_solid_item: %k not found", key); break; } @@ -1429,7 +1358,7 @@ } // IO_ERROR, NO_DISK_SPACE, etc - reiserfs_warning ("vs-: reiserfs_delete_solid_item: " + reiserfs_warning ("vs-5360: reiserfs_delete_solid_item: " "could not delete %K due to fix_nodes failure\n", &cpu_key); unfix_nodes (&tb); break; @@ -1446,15 +1375,6 @@ /* for directory this deletes item containing "." and ".." */ reiserfs_do_truncate (th, inode, NULL, 0/*no timestamp updates*/); - /* delete stat data */ - /* this debug code needs to go away. Trying to find a truncate race - ** -- clm -- 4/1/2000 - */ -#if 0 - if (inode->i_nlink != 0) { - reiserfs_warning("clm-4001: deleting inode with link count==%d\n", inode->i_nlink) ; - } -#endif #if defined( USE_INODE_GENERATION_COUNTER ) if( !old_format_only ( th -> t_super ) ) { @@ -1491,7 +1411,7 @@ */ if (atomic_read(&p_s_inode->i_count) > 1 || !tail_has_to_be_packed (p_s_inode) || - !page || p_s_inode->u.reiserfs_i.nopack) { + !page || (p_s_inode->u.reiserfs_i.i_flags & i_nopack_mask)) { // leave tail in an unformatted node *p_c_mode = M_SKIP_BALANCING; cut_bytes = n_block_size - (n_new_file_size & (n_block_size - 1)); @@ -1693,7 +1613,7 @@ ** be flushed before the transaction commits, so we don't need to ** deal with it here. */ - p_s_inode->u.reiserfs_i.i_pack_on_close = 0 ; + p_s_inode->u.reiserfs_i.i_flags &= ~i_pack_on_close_mask; } return n_ret_value; } @@ -1702,14 +1622,14 @@ static void truncate_directory (struct reiserfs_transaction_handle *th, struct inode * inode) { if (inode->i_nlink) - reiserfs_warning ("vs-5655: truncate_directory: link count != 0"); + reiserfs_warning ("vs-5655: truncate_directory: link count != 0\n"); - set_le_key_k_offset (ITEM_VERSION_1, INODE_PKEY (inode), DOT_OFFSET); - set_le_key_k_type (ITEM_VERSION_1, INODE_PKEY (inode), TYPE_DIRENTRY); + set_le_key_k_offset (KEY_FORMAT_3_5, INODE_PKEY (inode), DOT_OFFSET); + set_le_key_k_type (KEY_FORMAT_3_5, INODE_PKEY (inode), TYPE_DIRENTRY); reiserfs_delete_solid_item (th, INODE_PKEY (inode)); - set_le_key_k_offset (ITEM_VERSION_1, INODE_PKEY (inode), SD_OFFSET); - set_le_key_k_type (ITEM_VERSION_1, INODE_PKEY (inode), TYPE_STAT_DATA); + set_le_key_k_offset (KEY_FORMAT_3_5, INODE_PKEY (inode), SD_OFFSET); + set_le_key_k_type (KEY_FORMAT_3_5, INODE_PKEY (inode), TYPE_STAT_DATA); } @@ -1782,6 +1702,7 @@ pathrelse(&s_search_path); return; } + /* Update key to search for the last file item. */ set_cpu_key_k_offset (&s_item_key, n_file_size); @@ -1818,7 +1739,6 @@ if (update_timestamps) { p_s_inode->i_mtime = p_s_inode->i_ctime = CURRENT_TIME; - // FIXME: sd gets wrong size here } reiserfs_update_sd(th, p_s_inode) ; diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/fs/reiserfs/super.c linux-2.5/fs/reiserfs/super.c --- linux-2.5.1/fs/reiserfs/super.c Fri Nov 9 22:18:25 2001 +++ linux-2.5/fs/reiserfs/super.c Sat Dec 29 02:07:36 2001 @@ -19,6 +19,7 @@ #include <linux/smp_lock.h> #include <linux/locks.h> #include <linux/init.h> +#include <linux/blkdev.h> #define REISERFS_OLD_BLOCKSIZE 4096 #define REISERFS_SUPER_MAGIC_STRING_OFFSET_NJ 20 @@ -26,6 +27,9 @@ char reiserfs_super_magic_string[] = REISERFS_SUPER_MAGIC_STRING; char reiser2fs_super_magic_string[] = REISER2FS_SUPER_MAGIC_STRING; +static int reiserfs_remount (struct super_block * s, int * flags, char * data); +static int reiserfs_statfs (struct super_block * s, struct statfs * buf); + // // a portion of this function, particularly the VFS interface portion, // was derived from minix or ext2's analog and evolved as the @@ -33,7 +37,7 @@ // at the ext2 code and comparing. It's subfunctions contain no code // used as a template unless they are so labeled. // -void reiserfs_write_super (struct super_block * s) +static void reiserfs_write_super (struct super_block * s) { int dirty = 0 ; @@ -52,7 +56,7 @@ // at the ext2 code and comparing. It's subfunctions contain no code // used as a template unless they are so labeled. // -void reiserfs_write_super_lockfs (struct super_block * s) +static void reiserfs_write_super_lockfs (struct super_block * s) { int dirty = 0 ; @@ -73,6 +77,247 @@ reiserfs_allow_writes(s) ; } +extern const struct key MAX_KEY; + + +/* this is used to delete "save link" when there are no items of a + file it points to. It can either happen if unlink is completed but + "save unlink" removal, or if file has both unlink and truncate + pending and as unlink completes first (because key of "save link" + protecting unlink is bigger that a key lf "save link" which + protects truncate), so there left no items to make truncate + completion on */ +static void remove_save_link_only (struct super_block * s, struct key * key) +{ + struct reiserfs_transaction_handle th; + + /* we are going to do one balancing */ + journal_begin (&th, s, JOURNAL_PER_BALANCE_CNT); + + reiserfs_delete_solid_item (&th, key); + if (is_direct_le_key (KEY_FORMAT_3_5, key)) + /* removals are protected by direct items */ + reiserfs_release_objectid (&th, le32_to_cpu (key->k_objectid)); + + journal_end (&th, s, JOURNAL_PER_BALANCE_CNT); +} + + +/* look for uncompleted unlinks and truncates and complete them */ +static void finish_unfinished (struct super_block * s) +{ + INITIALIZE_PATH (path); + struct cpu_key max_cpu_key, obj_key; + struct key save_link_key; + int retval; + struct item_head * ih; + struct buffer_head * bh; + int item_pos; + char * item; + int done; + struct inode * inode; + int truncate; + + + /* compose key to look for "save" links */ + max_cpu_key.version = KEY_FORMAT_3_5; + max_cpu_key.on_disk_key = MAX_KEY; + max_cpu_key.key_length = 3; + + done = 0; + s -> u.reiserfs_sb.s_is_unlinked_ok = 1; + while (1) { + retval = search_item (s, &max_cpu_key, &path); + if (retval != ITEM_NOT_FOUND) { + reiserfs_warning ("vs-2140: finish_unfinished: search_by_key returned %d\n", + retval); + break; + } + + bh = get_last_bh (&path); + item_pos = get_item_pos (&path); + if (item_pos != B_NR_ITEMS (bh)) { + reiserfs_warning ("vs-2060: finish_unfinished: wrong position found\n"); + break; + } + item_pos --; + ih = B_N_PITEM_HEAD (bh, item_pos); + + if (le32_to_cpu (ih->ih_key.k_dir_id) != MAX_KEY_OBJECTID) + /* there are no "save" links anymore */ + break; + + save_link_key = ih->ih_key; + if (is_indirect_le_ih (ih)) + truncate = 1; + else + truncate = 0; + + /* reiserfs_iget needs k_dirid and k_objectid only */ + item = B_I_PITEM (bh, ih); + obj_key.on_disk_key.k_dir_id = le32_to_cpu (*(__u32 *)item); + obj_key.on_disk_key.k_objectid = le32_to_cpu (ih->ih_key.k_objectid); + obj_key.on_disk_key.u.k_offset_v1.k_offset = 0; + obj_key.on_disk_key.u.k_offset_v1.k_uniqueness = 0; + + pathrelse (&path); + + inode = reiserfs_iget (s, &obj_key); + if (!inode) { + /* the unlink almost completed, it just did not manage to remove + "save" link and release objectid */ + reiserfs_warning ("vs-2180: finish_unfinished: iget failed for %K\n", + &obj_key); + remove_save_link_only (s, &save_link_key); + continue; + } + + if (!truncate && inode->i_nlink) { + /* file is not unlinked */ + reiserfs_warning ("vs-2185: finish_unfinished: file %K is not unlinked\n", + &obj_key); + remove_save_link_only (s, &save_link_key); + continue; + } + + if (truncate) { + inode -> u.reiserfs_i.i_flags |= i_link_saved_truncate_mask; + /* not completed truncate found. New size was committed together + with "save" link */ + reiserfs_warning ("Truncating %k to %Ld ..", + INODE_PKEY (inode), inode->i_size); + reiserfs_truncate_file (inode, 0/*don't update modification time*/); + remove_save_link (inode, truncate); + } else { + inode -> u.reiserfs_i.i_flags |= i_link_saved_unlink_mask; + /* not completed unlink (rmdir) found */ + reiserfs_warning ("Removing %k..", INODE_PKEY (inode)); + /* removal gets completed in iput */ + } + + iput (inode); + reiserfs_warning ("done\n"); + done ++; + } + s -> u.reiserfs_sb.s_is_unlinked_ok = 0; + + pathrelse (&path); + if (done) + reiserfs_warning ("There were %d uncompleted unlinks/truncates. " + "Completed\n", done); +} + +/* to protect file being unlinked from getting lost we "safe" link files + being unlinked. This link will be deleted in the same transaction with last + item of file. mounting the filesytem we scan all these links and remove + files which almost got lost */ +void add_save_link (struct reiserfs_transaction_handle * th, + struct inode * inode, int truncate) +{ + INITIALIZE_PATH (path); + int retval; + struct cpu_key key; + struct item_head ih; + __u32 link; + + /* file can only get one "save link" of each kind */ + RFALSE( truncate && + ( inode -> u.reiserfs_i.i_flags & i_link_saved_truncate_mask ), + "saved link already exists for truncated inode %lx", + ( long ) inode -> i_ino ); + RFALSE( !truncate && + ( inode -> u.reiserfs_i.i_flags & i_link_saved_unlink_mask ), + "saved link already exists for unlinked inode %lx", + ( long ) inode -> i_ino ); + + /* setup key of "save" link */ + key.version = KEY_FORMAT_3_5; + key.on_disk_key.k_dir_id = MAX_KEY_OBJECTID; + key.on_disk_key.k_objectid = inode->i_ino; + if (!truncate) { + /* unlink, rmdir, rename */ + set_cpu_key_k_offset (&key, 1 + inode->i_sb->s_blocksize); + set_cpu_key_k_type (&key, TYPE_DIRECT); + + /* item head of "safe" link */ + make_le_item_head (&ih, &key, key.version, 1 + inode->i_sb->s_blocksize, TYPE_DIRECT, + 4/*length*/, 0xffff/*free space*/); + } else { + /* truncate */ + set_cpu_key_k_offset (&key, 1); + set_cpu_key_k_type (&key, TYPE_INDIRECT); + + /* item head of "safe" link */ + make_le_item_head (&ih, &key, key.version, 1, TYPE_INDIRECT, + 4/*length*/, 0/*free space*/); + } + key.key_length = 3; + + /* look for its place in the tree */ + retval = search_item (inode->i_sb, &key, &path); + if (retval != ITEM_NOT_FOUND) { + reiserfs_warning ("vs-2100: add_save_link:" + "search_by_key (%K) returned %d\n", &key, retval); + pathrelse (&path); + return; + } + + /* body of "save" link */ + link = cpu_to_le32 (INODE_PKEY (inode)->k_dir_id); + + /* put "save" link inot tree */ + retval = reiserfs_insert_item (th, &path, &key, &ih, (char *)&link); + if (retval) + reiserfs_warning ("vs-2120: add_save_link: insert_item returned %d\n", + retval); + else { + if( truncate ) + inode -> u.reiserfs_i.i_flags |= i_link_saved_truncate_mask; + else + inode -> u.reiserfs_i.i_flags |= i_link_saved_unlink_mask; + } +} + + +/* this opens transaction unlike add_save_link */ +void remove_save_link (struct inode * inode, int truncate) +{ + struct reiserfs_transaction_handle th; + struct key key; + + + /* we are going to do one balancing only */ + journal_begin (&th, inode->i_sb, JOURNAL_PER_BALANCE_CNT); + + /* setup key of "save" link */ + key.k_dir_id = cpu_to_le32 (MAX_KEY_OBJECTID); + key.k_objectid = INODE_PKEY (inode)->k_objectid; + if (!truncate) { + /* unlink, rmdir, rename */ + set_le_key_k_offset (KEY_FORMAT_3_5, &key, + 1 + inode->i_sb->s_blocksize); + set_le_key_k_type (KEY_FORMAT_3_5, &key, TYPE_DIRECT); + } else { + /* truncate */ + set_le_key_k_offset (KEY_FORMAT_3_5, &key, 1); + set_le_key_k_type (KEY_FORMAT_3_5, &key, TYPE_INDIRECT); + } + + if( ( truncate && + ( inode -> u.reiserfs_i.i_flags & i_link_saved_truncate_mask ) ) || + ( !truncate && + ( inode -> u.reiserfs_i.i_flags & i_link_saved_unlink_mask ) ) ) + reiserfs_delete_solid_item (&th, &key); + if (!truncate) { + reiserfs_release_objectid (&th, inode->i_ino); + inode -> u.reiserfs_i.i_flags &= ~i_link_saved_unlink_mask; + } else + inode -> u.reiserfs_i.i_flags &= ~i_link_saved_truncate_mask; + + journal_end (&th, inode->i_sb, JOURNAL_PER_BALANCE_CNT); +} + + // // a portion of this function, particularly the VFS interface portion, // was derived from minix or ext2's analog and evolved as the @@ -80,7 +325,7 @@ // at the ext2 code and comparing. It's subfunctions contain no code // used as a template unless they are so labeled. // -void reiserfs_put_super (struct super_block * s) +static void reiserfs_put_super (struct super_block * s) { int i; struct reiserfs_transaction_handle th ; @@ -123,6 +368,26 @@ return; } +/* we don't mark inodes dirty, we just log them */ +static void reiserfs_dirty_inode (struct inode * inode) { + struct reiserfs_transaction_handle th ; + + if (inode->i_sb->s_flags & MS_RDONLY) { + reiserfs_warning("clm-6006: writing inode %lu on readonly FS\n", + inode->i_ino) ; + return ; + } + lock_kernel() ; + + /* this is really only used for atime updates, so they don't have + ** to be included in O_SYNC or fsync + */ + journal_begin(&th, inode->i_sb, 1) ; + reiserfs_update_sd (&th, inode); + journal_end(&th, inode->i_sb, 1) ; + unlock_kernel() ; +} + struct super_operations reiserfs_sops = { read_inode: reiserfs_read_inode, @@ -231,7 +496,7 @@ // at the ext2 code and comparing. It's subfunctions contain no code // used as a template unless they are so labeled. // -int reiserfs_remount (struct super_block * s, int * flags, char * data) +static int reiserfs_remount (struct super_block * s, int * flags, char * data) { struct reiserfs_super_block * rs; struct reiserfs_transaction_handle th ; @@ -284,6 +549,10 @@ /* this will force a full flush of all journal lists */ SB_JOURNAL(s)->j_must_wait = 1 ; journal_end(&th, s, 10) ; + + if (!( *flags & MS_RDONLY ) ) + finish_unfinished( s ); + return 0; } @@ -302,11 +571,11 @@ labeling scheme currently used will have enough space. Then we need one block for the super. -Hans */ bmp = (REISERFS_DISK_OFFSET_IN_BYTES / s->s_blocksize) + 1; /* first of bitmap blocks */ - SB_AP_BITMAP (s)[0] = reiserfs_bread (s, bmp, s->s_blocksize); + SB_AP_BITMAP (s)[0] = reiserfs_bread (s, bmp); if(!SB_AP_BITMAP(s)[0]) return 1; for (i = 1, bmp = dl = s->s_blocksize * 8; i < sb_bmap_nr(rs); i ++) { - SB_AP_BITMAP (s)[i] = reiserfs_bread (s, bmp, s->s_blocksize); + SB_AP_BITMAP (s)[i] = reiserfs_bread (s, bmp); if (!SB_AP_BITMAP (s)[i]) return 1; bmp += dl; @@ -329,7 +598,7 @@ memset (SB_AP_BITMAP (s), 0, sizeof (struct buffer_head *) * sb_bmap_nr(rs)); for (i = 0; i < sb_bmap_nr(rs); i ++) { - SB_AP_BITMAP (s)[i] = reiserfs_bread (s, bmp1 + i, s->s_blocksize); + SB_AP_BITMAP (s)[i] = reiserfs_bread (s, bmp1 + i); if (!SB_AP_BITMAP (s)[i]) return 1; } @@ -355,17 +624,17 @@ free, SB_FREE_BLOCKS (s)); } -static int read_super_block (struct super_block * s, int size, int offset) +static int read_super_block (struct super_block * s, int offset) { struct buffer_head * bh; struct reiserfs_super_block * rs; - bh = bread (s->s_dev, offset / size, size); + bh = sb_bread (s, offset / s->s_blocksize); if (!bh) { printk ("read_super_block: " "bread failed (dev %s, block %d, size %d)\n", - kdevname (s->s_dev), offset / size, size); + kdevname (s->s_dev), offset / s->s_blocksize, s->s_blocksize); return 1; } @@ -373,7 +642,7 @@ if (!is_reiserfs_magic_string (rs)) { printk ("read_super_block: " "can't find a reiserfs filesystem on (dev %s, block %lu, size %d)\n", - kdevname(s->s_dev), bh->b_blocknr, size); + kdevname(s->s_dev), bh->b_blocknr, s->s_blocksize); brelse (bh); return 1; } @@ -381,30 +650,23 @@ // // ok, reiserfs signature (old or new) found in at the given offset // - s->s_blocksize = sb_blocksize(rs); - s->s_blocksize_bits = 0; - while ((1 << s->s_blocksize_bits) != s->s_blocksize) - s->s_blocksize_bits ++; - brelse (bh); - if (s->s_blocksize != size) - set_blocksize (s->s_dev, s->s_blocksize); + sb_set_blocksize (s, sb_blocksize(rs)); - bh = reiserfs_bread (s, offset / s->s_blocksize, s->s_blocksize); + bh = reiserfs_bread (s, offset / s->s_blocksize); if (!bh) { printk("read_super_block: " "bread failed (dev %s, block %d, size %d)\n", - kdevname (s->s_dev), offset / size, size); + kdevname (s->s_dev), offset / s->s_blocksize, s->s_blocksize); return 1; } rs = (struct reiserfs_super_block *)bh->b_data; - if (!is_reiserfs_magic_string (rs) || - sb_blocksize(rs) != s->s_blocksize) { + if (!is_reiserfs_magic_string (rs) || sb_blocksize(rs) != s->s_blocksize) { printk ("read_super_block: " "can't find a reiserfs filesystem on (dev %s, block %lu, size %d)\n", - kdevname(s->s_dev), bh->b_blocknr, size); + kdevname(s->s_dev), bh->b_blocknr, s->s_blocksize); brelse (bh); printk ("read_super_block: can't find a reiserfs filesystem on dev %s.\n", kdevname(s->s_dev)); return 1; @@ -608,18 +870,18 @@ // at the ext2 code and comparing. It's subfunctions contain no code // used as a template unless they are so labeled. // -struct super_block * reiserfs_read_super (struct super_block * s, void * data, int silent) +static struct super_block * reiserfs_read_super (struct super_block * s, void * data, int silent) { int size; struct inode *root_inode; - kdev_t dev = s->s_dev; int j; - extern int *blksize_size[]; struct reiserfs_transaction_handle th ; int old_format = 0; unsigned long blocks; int jinit_done = 0 ; struct reiserfs_iget4_args args ; + int old_magic; + struct reiserfs_super_block * rs; memset (&s->u.reiserfs_sb, 0, sizeof (struct reiserfs_sb_info)); @@ -633,18 +895,14 @@ return NULL; } - if (blksize_size[MAJOR(dev)] && blksize_size[MAJOR(dev)][MINOR(dev)] != 0) { - /* as blocksize is set for partition we use it */ - size = blksize_size[MAJOR(dev)][MINOR(dev)]; - } else { - size = BLOCK_SIZE; - set_blocksize (s->s_dev, BLOCK_SIZE); - } + size = block_size(s->s_dev); + sb_set_blocksize(s, size); /* read block (64-th 1k block), which can contain reiserfs super block */ - if (read_super_block (s, size, REISERFS_DISK_OFFSET_IN_BYTES)) { + if (read_super_block (s, REISERFS_DISK_OFFSET_IN_BYTES)) { // try old format (undistributed bitmap, super block in 8-th 1k block of a device) - if (read_super_block (s, size, REISERFS_OLD_DISK_OFFSET_IN_BYTES)) + sb_set_blocksize(s, size); + if (read_super_block (s, REISERFS_OLD_DISK_OFFSET_IN_BYTES)) goto error; else old_format = 1; @@ -704,18 +962,15 @@ goto error ; } - if (!(s->s_flags & MS_RDONLY)) { - struct reiserfs_super_block * rs = SB_DISK_SUPER_BLOCK (s); - int old_magic; - - old_magic = strncmp (rs->s_magic, REISER2FS_SUPER_MAGIC_STRING, + rs = SB_DISK_SUPER_BLOCK (s); + old_magic = strncmp (rs->s_magic, REISER2FS_SUPER_MAGIC_STRING, strlen ( REISER2FS_SUPER_MAGIC_STRING)); - if( old_magic && le16_to_cpu(rs->s_version) != 0 ) { - dput(s->s_root) ; - s->s_root = NULL ; - reiserfs_warning("reiserfs: wrong version/magic combination in the super-block\n") ; - goto error ; - } + if (!old_magic) + set_bit(REISERFS_3_6, &(s->u.reiserfs_sb.s_properties)); + else + set_bit(REISERFS_3_5, &(s->u.reiserfs_sb.s_properties)); + + if (!(s->s_flags & MS_RDONLY)) { journal_begin(&th, s, 1) ; reiserfs_prepare_for_journal(s, SB_BUFFER_WITH_SB(s), 1) ; @@ -724,34 +979,34 @@ if ( old_magic ) { // filesystem created under 3.5.x found - if (!old_format_only (s)) { + if (convert_reiserfs (s)) { reiserfs_warning("reiserfs: converting 3.5.x filesystem to the new format\n") ; // after this 3.5.x will not be able to mount this partition memcpy (rs->s_magic, REISER2FS_SUPER_MAGIC_STRING, sizeof (REISER2FS_SUPER_MAGIC_STRING)); reiserfs_convert_objectid_map_v1(s) ; + set_bit(REISERFS_3_6, &(s->u.reiserfs_sb.s_properties)); + clear_bit(REISERFS_3_5, &(s->u.reiserfs_sb.s_properties)); } else { reiserfs_warning("reiserfs: using 3.5.x disk format\n") ; } - } else { - // new format found - set_bit (REISERFS_CONVERT, &(s->u.reiserfs_sb.s_mount_opt)); } - // mark hash in super block: it could be unset. overwrite should be ok - set_sb_hash_function_code( rs, function2code(s->u.reiserfs_sb.s_hash_function ) ); - journal_mark_dirty(&th, s, SB_BUFFER_WITH_SB (s)); journal_end(&th, s, 1) ; + + /* look for files which were to be removed in previous session */ + finish_unfinished (s); + s->s_dirt = 0; } else { - struct reiserfs_super_block * rs = SB_DISK_SUPER_BLOCK (s); - if (strncmp (rs->s_magic, REISER2FS_SUPER_MAGIC_STRING, - strlen ( REISER2FS_SUPER_MAGIC_STRING))) { + if ( old_magic ) { reiserfs_warning("reiserfs: using 3.5.x disk format\n") ; } } + // mark hash in super block: it could be unset. overwrite should be ok + set_sb_hash_function_code( rs, function2code(s->u.reiserfs_sb.s_hash_function ) ); reiserfs_proc_info_init( s ); reiserfs_proc_register( s, "version", reiserfs_version_in_proc ); @@ -792,7 +1047,7 @@ // at the ext2 code and comparing. It's subfunctions contain no code // used as a template unless they are so labeled. // -int reiserfs_statfs (struct super_block * s, struct statfs * buf) +static int reiserfs_statfs (struct super_block * s, struct statfs * buf) { struct reiserfs_super_block * rs = SB_DISK_SUPER_BLOCK (s); @@ -835,6 +1090,7 @@ reiserfs_proc_info_global_done(); unregister_filesystem(&reiserfs_fs_type); } + module_init(init_reiserfs_fs) ; module_exit(exit_reiserfs_fs) ; diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/fs/reiserfs/tail_conversion.c linux-2.5/fs/reiserfs/tail_conversion.c --- linux-2.5.1/fs/reiserfs/tail_conversion.c Tue Oct 30 23:11:34 2001 +++ linux-2.5/fs/reiserfs/tail_conversion.c Thu Dec 13 16:32:37 2001 @@ -240,7 +240,7 @@ /* Set direct item header to insert. */ - make_le_item_head (&s_ih, 0, inode_items_version (p_s_inode), pos1 + 1, + make_le_item_head (&s_ih, 0, get_inode_item_key_version (p_s_inode), pos1 + 1, TYPE_DIRECT, round_tail_len, 0xffff/*ih_free_space*/); /* we want a pointer to the first byte of the tail in the page. diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/fs/romfs/inode.c linux-2.5/fs/romfs/inode.c --- linux-2.5.1/fs/romfs/inode.c Sun Dec 16 20:23:05 2001 +++ linux-2.5/fs/romfs/inode.c Thu Dec 27 15:56:12 2001 @@ -102,9 +102,7 @@ /* I would parse the options here, but there are none.. :) */ - set_blocksize(dev, ROMBSIZE); - s->s_blocksize = ROMBSIZE; - s->s_blocksize_bits = ROMBSBITS; + sb_set_blocksize(s, ROMBSIZE); s->u.generic_sbp = (void *) 0; s->s_maxbytes = 0xFFFFFFFF; diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/fs/super.c linux-2.5/fs/super.c --- linux-2.5.1/fs/super.c Sat Dec 8 00:24:52 2001 +++ linux-2.5/fs/super.c Thu Dec 27 22:10:28 2001 @@ -34,8 +34,6 @@ #define __NO_VERSION__ #include <linux/module.h> -int do_remount_sb(struct super_block *sb, int flags, void * data); - LIST_HEAD(super_blocks); spinlock_t sb_lock = SPIN_LOCK_UNLOCKED; @@ -377,7 +375,7 @@ get_filesystem(type); } -void put_unnamed_dev(kdev_t dev); /* should become static */ +static void put_anon_dev(kdev_t dev); /** * remove_super - makes superblock unreachable @@ -407,7 +405,7 @@ if (bdev) blkdev_put(bdev, BDEV_FS); else - put_unnamed_dev(dev); + put_anon_dev(dev); } struct vfsmount *alloc_vfsmnt(void); @@ -530,40 +528,127 @@ return err; } +/** + * do_remount_sb - asks filesystem to change mount options. + * @sb: superblock in question + * @flags: numeric part of options + * @data: the rest of options + * + * Alters the mount options of a mounted file system. + */ +int do_remount_sb(struct super_block *sb, int flags, void *data) +{ + int retval; + + if (!(flags & MS_RDONLY) && sb->s_dev && is_read_only(sb->s_dev)) + return -EACCES; + /*flags |= MS_RDONLY;*/ + if (flags & MS_RDONLY) + acct_auto_close(sb); + shrink_dcache_sb(sb); + fsync_super(sb); + /* If we are remounting RDONLY, make sure there are no rw files open */ + if ((flags & MS_RDONLY) && !(sb->s_flags & MS_RDONLY)) + if (!fs_may_remount_ro(sb)) + return -EBUSY; + if (sb->s_op && sb->s_op->remount_fs) { + lock_super(sb); + retval = sb->s_op->remount_fs(sb, &flags, data); + unlock_super(sb); + if (retval) + return retval; + } + sb->s_flags = (sb->s_flags & ~MS_RMT_MASK) | (flags & MS_RMT_MASK); + return 0; +} + /* * Unnamed block devices are dummy devices used by virtual * filesystems which don't use real block-devices. -- jrs */ -static unsigned long unnamed_dev_in_use[256/(8*sizeof(unsigned long))]; +enum {Max_anon = 256}; +static unsigned long unnamed_dev_in_use[Max_anon/(8*sizeof(unsigned long))]; +static spinlock_t unnamed_dev_lock = SPIN_LOCK_UNLOCKED;/* protects the above */ -kdev_t get_unnamed_dev(void) +/** + * put_anon_dev - release anonymous device number. + * @dev: device in question + */ +static void put_anon_dev(kdev_t dev) { - int i; - - for (i = 1; i < 256; i++) { - if (!test_and_set_bit(i,unnamed_dev_in_use)) - return MKDEV(UNNAMED_MAJOR, i); - } - return 0; + spin_lock(&unnamed_dev_lock); + clear_bit(MINOR(dev), unnamed_dev_in_use); + spin_unlock(&unnamed_dev_lock); } -void put_unnamed_dev(kdev_t dev) +/** + * get_anon_super - allocate a superblock for non-device fs + * @type: filesystem type + * @compare: check if existing superblock is what we want + * @data: argument for @compare. + * + * get_anon_super is a helper for non-blockdevice filesystems. + * It either finds and returns one of the superblocks of given type + * (if it can find one that would satisfy caller) or creates a new + * one. In the either case we return an active reference to superblock + * with ->s_umount locked. If superblock is new it gets a new + * anonymous device allocated for it and is inserted into lists - + * other initialization is left to caller. + * + * Rather than duplicating all that logics every time when + * we want something that doesn't fit "nodev" and "single" we pull + * the relevant code into common helper and let get_sb_...() call + * it. + * + * NB: get_sb_...() is going to become an fs type method, with + * current ->read_super() becoming a callback used by common instances. + */ +struct super_block *get_anon_super(struct file_system_type *type, + int (*compare)(struct super_block *,void *), void *data) { - if (!dev || MAJOR(dev) != UNNAMED_MAJOR) - return; - if (test_and_clear_bit(MINOR(dev), unnamed_dev_in_use)) - return; - printk("VFS: put_unnamed_dev: freeing unused device %s\n", - kdevname(dev)); + struct super_block *s = alloc_super(); + kdev_t dev; + struct list_head *p; + + if (!s) + return ERR_PTR(-ENOMEM); + + spin_lock(&unnamed_dev_lock); + dev = find_first_zero_bit(unnamed_dev_in_use, Max_anon); + if (dev == Max_anon) { + spin_unlock(&unnamed_dev_lock); + destroy_super(s); + return ERR_PTR(-EMFILE); + } + set_bit(dev, unnamed_dev_in_use); + spin_unlock(&unnamed_dev_lock); + +retry: + spin_lock(&sb_lock); + if (compare) list_for_each(p, &type->fs_supers) { + struct super_block *old; + old = list_entry(p, struct super_block, s_instances); + if (!compare(old, data)) + continue; + if (!grab_super(old)) + goto retry; + destroy_super(s); + return old; + } + + s->s_dev = dev; + insert_super(s, type); + return s; } static struct super_block *get_sb_bdev(struct file_system_type *fs_type, - char *dev_name, int flags, void * data) + int flags, char *dev_name, void * data) { struct inode *inode; struct block_device *bdev; struct block_device_operations *bdops; + devfs_handle_t de; struct super_block * s; struct nameidata nd; struct list_head *p; @@ -587,28 +672,26 @@ goto out; bd_acquire(inode); bdev = inode->i_bdev; - bdops = devfs_get_ops ( devfs_get_handle_from_inode (inode) ); + de = devfs_get_handle_from_inode (inode); + bdops = devfs_get_ops (de); /* Increments module use count */ if (bdops) bdev->bd_op = bdops; /* Done with lookups, semaphore down */ dev = to_kdev_t(bdev->bd_dev); if (!(flags & MS_RDONLY)) mode |= FMODE_WRITE; error = blkdev_get(bdev, mode, 0, BDEV_FS); + devfs_put_ops (de); /* Decrement module use count now we're safe */ if (error) goto out; check_disk_change(dev); error = -EACCES; - if (!(flags & MS_RDONLY) && is_read_only(dev)) { - blkdev_put(bdev, BDEV_FS); - goto out; - } + if (!(flags & MS_RDONLY) && is_read_only(dev)) + goto out1; error = -ENOMEM; s = alloc_super(); - if (!s) { - blkdev_put(bdev, BDEV_FS); - goto out; - } + if (!s) + goto out1; error = -EBUSY; restart: @@ -622,8 +705,7 @@ ((flags ^ old->s_flags) & MS_RDONLY)) { spin_unlock(&sb_lock); destroy_super(s); - blkdev_put(bdev, BDEV_FS); - goto out; + goto out1; } if (!grab_super(old)) goto restart; @@ -636,97 +718,103 @@ s->s_bdev = bdev; s->s_flags = flags; insert_super(s, fs_type); - - error = -EINVAL; - lock_super(s); if (!fs_type->read_super(s, data, flags & MS_VERBOSE ? 1 : 0)) - goto out_fail; + goto Einval; s->s_flags |= MS_ACTIVE; - unlock_super(s); path_release(&nd); return s; -out_fail: - unlock_super(s); +Einval: deactivate_super(s); remove_super(s); + error = -EINVAL; + goto out; +out1: + blkdev_put(bdev, BDEV_FS); out: path_release(&nd); return ERR_PTR(error); } static struct super_block *get_sb_nodev(struct file_system_type *fs_type, - int flags, void * data) + int flags, char *dev_name, void *data) { - struct super_block *s = alloc_super(); + struct super_block *s = get_anon_super(fs_type, NULL, NULL); + + if (IS_ERR(s)) + return s; - if (!s) - return ERR_PTR(-ENOMEM); - s->s_dev = get_unnamed_dev(); - if (!s->s_dev) { - destroy_super(s); - return ERR_PTR(-EMFILE); - } s->s_flags = flags; - spin_lock(&sb_lock); - insert_super(s, fs_type); - lock_super(s); - if (!fs_type->read_super(s, data, flags & MS_VERBOSE ? 1 : 0)) - goto out_fail; + if (!fs_type->read_super(s, data, flags & MS_VERBOSE ? 1 : 0)) { + deactivate_super(s); + remove_super(s); + return ERR_PTR(-EINVAL); + } s->s_flags |= MS_ACTIVE; - unlock_super(s); return s; +} -out_fail: - unlock_super(s); - deactivate_super(s); - remove_super(s); - return ERR_PTR(-EINVAL); +static int compare_single(struct super_block *s, void *p) +{ + return 1; } static struct super_block *get_sb_single(struct file_system_type *fs_type, - int flags, void *data) + int flags, char *dev_name, void *data) { - struct super_block * s = alloc_super(); - if (!s) - return ERR_PTR(-ENOMEM); - /* - * Get the superblock of kernel-wide instance, but - * keep the reference to fs_type. - */ -retry: - spin_lock(&sb_lock); - if (!list_empty(&fs_type->fs_supers)) { - struct super_block *old; - old = list_entry(fs_type->fs_supers.next, struct super_block, - s_instances); - if (!grab_super(old)) - goto retry; - destroy_super(s); - do_remount_sb(old, flags, data); - return old; - } else { - s->s_dev = get_unnamed_dev(); - if (!s->s_dev) { - spin_unlock(&sb_lock); - destroy_super(s); - return ERR_PTR(-EMFILE); - } + struct super_block *s = get_anon_super(fs_type, compare_single, NULL); + + if (IS_ERR(s)) + return s; + if (!s->s_root) { s->s_flags = flags; - insert_super(s, fs_type); - lock_super(s); - if (!fs_type->read_super(s, data, flags & MS_VERBOSE ? 1 : 0)) - goto out_fail; + if (!fs_type->read_super(s, data, flags & MS_VERBOSE ? 1 : 0)) { + deactivate_super(s); + remove_super(s); + return ERR_PTR(-EINVAL); + } s->s_flags |= MS_ACTIVE; - unlock_super(s); - return s; - - out_fail: - unlock_super(s); - deactivate_super(s); - remove_super(s); - return ERR_PTR(-EINVAL); } + do_remount_sb(s, flags, data); + return s; +} + +struct vfsmount * +do_kern_mount(const char *fstype, int flags, char *name, void *data) +{ + struct file_system_type *type = get_fs_type(fstype); + struct super_block *sb = ERR_PTR(-ENOMEM); + struct vfsmount *mnt; + + if (!type) + return ERR_PTR(-ENODEV); + + mnt = alloc_vfsmnt(); + if (!mnt) + goto out; + set_devname(mnt, name); + if (type->fs_flags & FS_REQUIRES_DEV) + sb = get_sb_bdev(type, flags, name, data); + else if (type->fs_flags & FS_SINGLE) + sb = get_sb_single(type, flags, name, data); + else + sb = get_sb_nodev(type, flags, name, data); + if (IS_ERR(sb)) + goto out_mnt; + if (type->fs_flags & FS_NOMOUNT) + sb->s_flags |= MS_NOUSER; + mnt->mnt_sb = sb; + mnt->mnt_root = dget(sb->s_root); + mnt->mnt_mountpoint = sb->s_root; + mnt->mnt_parent = mnt; + up_write(&sb->s_umount); + put_filesystem(type); + return mnt; +out_mnt: + free_vfsmnt(mnt); +out: + put_filesystem(type); + return (struct vfsmount *)sb; } void kill_super(struct super_block *sb) @@ -739,7 +827,6 @@ return; down_write(&sb->s_umount); - lock_kernel(); sb->s_root = NULL; /* Need to clean after the sucker */ if (fs->fs_flags & FS_LITTER) @@ -748,6 +835,7 @@ dput(root); fsync_super(sb); lock_super(sb); + lock_kernel(); sb->s_flags &= ~MS_ACTIVE; invalidate_inodes(sb); /* bad name - it should be evict_inodes() */ if (sop) { @@ -768,96 +856,7 @@ remove_super(sb); } -/* - * Alters the mount flags of a mounted file system. Only the mount point - * is used as a reference - file system type and the device are ignored. - */ - -int do_remount_sb(struct super_block *sb, int flags, void *data) -{ - int retval; - - if (!(flags & MS_RDONLY) && sb->s_dev && is_read_only(sb->s_dev)) - return -EACCES; - /*flags |= MS_RDONLY;*/ - if (flags & MS_RDONLY) - acct_auto_close(sb->s_dev); - shrink_dcache_sb(sb); - fsync_super(sb); - /* If we are remounting RDONLY, make sure there are no rw files open */ - if ((flags & MS_RDONLY) && !(sb->s_flags & MS_RDONLY)) - if (!fs_may_remount_ro(sb)) - return -EBUSY; - if (sb->s_op && sb->s_op->remount_fs) { - lock_super(sb); - retval = sb->s_op->remount_fs(sb, &flags, data); - unlock_super(sb); - if (retval) - return retval; - } - sb->s_flags = (sb->s_flags & ~MS_RMT_MASK) | (flags & MS_RMT_MASK); - - /* - * We can't invalidate inodes as we can loose data when remounting - * (someone might manage to alter data while we are waiting in lock_super() - * or in foo_remount_fs())) - */ - - return 0; -} - -struct vfsmount *do_kern_mount(char *type, int flags, char *name, void *data) -{ - struct file_system_type * fstype; - struct vfsmount *mnt = NULL; - struct super_block *sb; - - if (!type || !memchr(type, 0, PAGE_SIZE)) - return ERR_PTR(-EINVAL); - - /* we need capabilities... */ - if (!capable(CAP_SYS_ADMIN)) - return ERR_PTR(-EPERM); - - /* ... filesystem driver... */ - fstype = get_fs_type(type); - if (!fstype) - return ERR_PTR(-ENODEV); - - /* ... allocated vfsmount... */ - mnt = alloc_vfsmnt(); - if (!mnt) { - mnt = ERR_PTR(-ENOMEM); - goto fs_out; - } - set_devname(mnt, name); - /* get locked superblock */ - if (fstype->fs_flags & FS_REQUIRES_DEV) - sb = get_sb_bdev(fstype, name, flags, data); - else if (fstype->fs_flags & FS_SINGLE) - sb = get_sb_single(fstype, flags, data); - else - sb = get_sb_nodev(fstype, flags, data); - - if (IS_ERR(sb)) { - free_vfsmnt(mnt); - mnt = (struct vfsmount *)sb; - goto fs_out; - } - if (fstype->fs_flags & FS_NOMOUNT) - sb->s_flags |= MS_NOUSER; - - mnt->mnt_sb = sb; - mnt->mnt_root = dget(sb->s_root); - mnt->mnt_mountpoint = mnt->mnt_root; - mnt->mnt_parent = mnt; - up_write(&sb->s_umount); -fs_out: - put_filesystem(fstype); - return mnt; -} - struct vfsmount *kern_mount(struct file_system_type *type) { - return do_kern_mount((char *)type->name, 0, (char *)type->name, NULL); + return do_kern_mount(type->name, 0, (char *)type->name, NULL); } diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/fs/sysv/ChangeLog linux-2.5/fs/sysv/ChangeLog --- linux-2.5.1/fs/sysv/ChangeLog Fri Nov 9 21:45:35 2001 +++ linux-2.5/fs/sysv/ChangeLog Sun Dec 16 01:22:49 2001 @@ -1,3 +1,12 @@ +Sat Dec 15 2001 Christoph Hellwig <hch@caldera.de> + + * inode.c (sysv_read_inode): Mark inode as bad in case of failure. + * super.c (complete_read_super): Check for bad root inode. + +Wed Nov 21 2001 Andrew Morton <andrewm@uow.edu.au> + + * file.c (sysv_sync_file): Call fsync_inode_data_buffers. + Fri Oct 26 2001 Christoph Hellwig <hch@caldera.de> * dir.c, ialloc.c, namei.c, include/linux/sysv_fs_i.h: diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/fs/sysv/dir.c linux-2.5/fs/sysv/dir.c --- linux-2.5.1/fs/sysv/dir.c Fri Nov 9 21:45:35 2001 +++ linux-2.5/fs/sysv/dir.c Sun Dec 30 20:01:41 2001 @@ -41,7 +41,6 @@ struct inode *dir = (struct inode *)page->mapping->host; int err = 0; - dir->i_version = ++event; page->mapping->a_ops->commit_write(NULL, page, from, to); if (IS_SYNC(dir)) err = waitfor_one_page(page); @@ -111,7 +110,6 @@ done: filp->f_pos = (n << PAGE_CACHE_SHIFT) | offset; - filp->f_version = inode->i_version; UPDATE_ATIME(inode); return 0; } diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/fs/sysv/inode.c linux-2.5/fs/sysv/inode.c --- linux-2.5.1/fs/sysv/inode.c Fri Nov 9 21:45:35 2001 +++ linux-2.5/fs/sysv/inode.c Sun Dec 16 01:22:49 2001 @@ -152,13 +152,13 @@ printk("Bad inode number on dev %s" ": %d is out of range\n", kdevname(inode->i_dev), ino); - return; + goto bad_inode; } raw_inode = sysv_raw_inode(sb, ino, &bh); if (!raw_inode) { printk("Major problem: unable to read inode from dev %s\n", bdevname(inode->i_dev)); - return; + goto bad_inode; } /* SystemV FS: kludge permissions if ino==SYSV_ROOT_INO ?? */ inode->i_mode = fs16_to_cpu(sb, raw_inode->i_mode); @@ -178,6 +178,11 @@ rdev = (u16)fs32_to_cpu(sb, inode->u.sysv_i.i_data[0]); inode->u.sysv_i.i_dir_start_lookup = 0; sysv_set_inode(inode, rdev); + return; + +bad_inode: + make_bad_inode(inode); + return; } static struct buffer_head * sysv_update_inode(struct inode * inode) diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/fs/sysv/itree.c linux-2.5/fs/sysv/itree.c --- linux-2.5.1/fs/sysv/itree.c Sun Dec 16 20:23:05 2001 +++ linux-2.5/fs/sysv/itree.c Thu Dec 27 22:10:28 2001 @@ -211,9 +211,7 @@ /* Simplest case - block found, no allocation needed */ if (!partial) { got_it: - bh_result->b_dev = sb->s_dev; - bh_result->b_blocknr = block_to_cpu(sb, chain[depth-1].key); - bh_result->b_state |= (1UL << BH_Mapped); + map_bh(bh_result, sb, block_to_cpu(sb, chain[depth-1].key)); /* Clean up and exit */ partial = chain+depth-1; /* the whole chain */ goto cleanup; diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/fs/sysv/super.c linux-2.5/fs/sysv/super.c --- linux-2.5.1/fs/sysv/super.c Sun Dec 16 20:23:05 2001 +++ linux-2.5/fs/sysv/super.c Thu Dec 27 15:56:12 2001 @@ -315,8 +315,6 @@ sb->sv_ninodes = (sb->sv_firstdatazone - sb->sv_firstinodezone) << sb->sv_inodes_per_block_bits; - sb->s_blocksize = bsize; - sb->s_blocksize_bits = n_bits; if (!silent) printk("VFS: Found a %s FS (block size = %ld) on device %s\n", found, sb->s_blocksize, bdevname(sb->s_dev)); @@ -325,7 +323,7 @@ /* set up enough so that it can read an inode */ sb->s_op = &sysv_sops; root_inode = iget(sb,SYSV_ROOT_INO); - if (!root_inode) { + if (!root_inode || is_bad_inode(root_inode)) { printk("SysV FS: get root inode failed\n"); return 0; } @@ -361,8 +359,7 @@ panic("Coherent FS: bad super-block size"); if (64 != sizeof (struct sysv_inode)) panic("sysv fs: bad i-node size"); - set_blocksize(dev,BLOCK_SIZE); - sb->s_blocksize = BLOCK_SIZE; + sb_set_blocksize(sb, BLOCK_SIZE); sb->sv_block_base = 0; for (i = 0; i < sizeof(flavours)/sizeof(flavours[0]) && !size; i++) { @@ -380,8 +377,7 @@ case 1: blocknr = bh->b_blocknr << 1; brelse(bh); - set_blocksize(dev, 512); - sb->s_blocksize = 512; + sb_set_blocksize(sb, 512); bh1 = sb_bread(sb, blocknr); bh = sb_bread(sb, blocknr + 1); break; @@ -391,8 +387,7 @@ case 3: blocknr = bh->b_blocknr >> 1; brelse(bh); - set_blocksize(dev, 2048); - sb->s_blocksize = 2048; + sb_set_blocksize(sb, 2048); bh1 = bh = sb_bread(sb, blocknr); break; default: @@ -408,7 +403,7 @@ brelse(bh1); brelse(bh); - set_blocksize(sb->s_dev,BLOCK_SIZE); + sb_set_blocksize(sb, BLOCK_SIZE); printk("oldfs: cannot read superblock\n"); failed: return NULL; @@ -443,8 +438,7 @@ sb->sv_type = FSTYPE_V7; sb->sv_bytesex = BYTESEX_PDP; - set_blocksize(dev, 512); - sb->s_blocksize = 512; + sb_set_blocksize(sb, 512); if ((bh = sb_bread(sb, 1)) == NULL) { if (!silent) diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/fs/udf/inode.c linux-2.5/fs/udf/inode.c --- linux-2.5.1/fs/udf/inode.c Sun Dec 16 20:23:05 2001 +++ linux-2.5/fs/udf/inode.c Sun Dec 30 20:01:41 2001 @@ -215,7 +215,6 @@ page_cache_release(page); mark_inode_dirty(inode); - inode->i_version ++; } struct buffer_head * udf_expand_dir_adinicb(struct inode *inode, int *block, int *err) @@ -310,7 +309,6 @@ mark_buffer_dirty(sbh); udf_release_data(sbh); mark_inode_dirty(inode); - inode->i_version ++; return dbh; } @@ -324,11 +322,7 @@ { phys = udf_block_map(inode, block); if (phys) - { - bh_result->b_dev = inode->i_dev; - bh_result->b_blocknr = phys; - bh_result->b_state |= (1UL << BH_Mapped); - } + map_bh(bh_result, inode->i_sb, phys); return 0; } @@ -357,11 +351,9 @@ if (!phys) BUG(); - bh_result->b_dev = inode->i_dev; - bh_result->b_blocknr = phys; - bh_result->b_state |= (1UL << BH_Mapped); if (new) bh_result->b_state |= (1UL << BH_New); + map_bh(bh_result, inode->i_sb, phys); abort: unlock_kernel(); return err; @@ -1039,7 +1031,6 @@ long convtime_usec; int offset, alen; - inode->i_version = ++event; UDF_I_NEW_INODE(inode) = 0; fe = (struct FileEntry *)bh->b_data; diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/fs/udf/namei.c linux-2.5/fs/udf/namei.c --- linux-2.5.1/fs/udf/namei.c Sun Dec 16 20:23:05 2001 +++ linux-2.5/fs/udf/namei.c Sun Dec 30 20:01:41 2001 @@ -595,7 +595,6 @@ dir->i_size += nfidlen; if (UDF_I_ALLOCTYPE(dir) == ICB_FLAG_AD_IN_ICB) UDF_I_LENALLOC(dir) += nfidlen; - dir->i_version = ++event; mark_inode_dirty(dir); return fi; } @@ -654,7 +653,6 @@ if (UDF_I_ALLOCTYPE(dir) == ICB_FLAG_AD_IN_ICB) { mark_inode_dirty(dir); - dir->i_version = ++event; } if (fibh.sbh != fibh.ebh) udf_release_data(fibh.ebh); @@ -692,7 +690,6 @@ if (UDF_I_ALLOCTYPE(dir) == ICB_FLAG_AD_IN_ICB) { mark_inode_dirty(dir); - dir->i_version = ++event; } mark_inode_dirty(inode); @@ -756,7 +753,6 @@ cpu_to_le32(UDF_I_UNIQUE(inode) & 0x00000000FFFFFFFFUL); cfi.fileCharacteristics |= FILE_DIRECTORY; udf_write_fi(dir, &cfi, fi, &fibh, NULL, NULL); - dir->i_version = ++event; dir->i_nlink++; mark_inode_dirty(dir); d_instantiate(dentry, inode); @@ -851,14 +847,12 @@ if (!empty_dir(inode)) goto end_rmdir; retval = udf_delete_entry(dir, fi, &fibh, &cfi); - dir->i_version = ++event; if (retval) goto end_rmdir; if (inode->i_nlink != 2) udf_warning(inode->i_sb, "udf_rmdir", "empty directory has nlink != 2 (%d)", inode->i_nlink); - inode->i_version = ++event; inode->i_nlink = 0; inode->i_size = 0; mark_inode_dirty(inode); @@ -1070,7 +1064,6 @@ if (UDF_I_ALLOCTYPE(dir) == ICB_FLAG_AD_IN_ICB) { mark_inode_dirty(dir); - dir->i_version = ++event; } if (fibh.sbh != fibh.ebh) udf_release_data(fibh.ebh); @@ -1123,7 +1116,6 @@ if (UDF_I_ALLOCTYPE(dir) == ICB_FLAG_AD_IN_ICB) { mark_inode_dirty(dir); - dir->i_version = ++event; } if (fibh.sbh != fibh.ebh) udf_release_data(fibh.ebh); @@ -1205,7 +1197,6 @@ if (!nfi) goto end_rename; } - new_dir->i_version = ++event; /* * Like most other Unix systems, set the ctime for inodes on a @@ -1227,7 +1218,6 @@ ofi = udf_find_entry(old_dir, old_dentry, &ofibh, &ocfi); udf_delete_entry(old_dir, ofi, &ofibh, &ocfi); - old_dir->i_version = ++event; if (new_inode) { new_inode->i_nlink--; @@ -1247,7 +1237,6 @@ if (UDF_I_ALLOCTYPE(old_inode) == ICB_FLAG_AD_IN_ICB) { mark_inode_dirty(old_inode); - old_inode->i_version = ++event; } else mark_buffer_dirty_inode(dir_bh, old_inode); diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/fs/udf/super.c linux-2.5/fs/udf/super.c --- linux-2.5.1/fs/udf/super.c Sun Dec 16 20:23:05 2001 +++ linux-2.5/fs/udf/super.c Thu Dec 27 15:56:12 2001 @@ -357,30 +357,11 @@ static int udf_set_blocksize(struct super_block *sb, int bsize) { - /* Use specified block size if specified */ - if (bsize) - sb->s_blocksize = bsize; - if (get_hardsect_size(sb->s_dev) > sb->s_blocksize) - sb->s_blocksize = get_hardsect_size(sb->s_dev); - - /* Block size must be an even multiple of 512 */ - switch (sb->s_blocksize) - { - case 512: sb->s_blocksize_bits = 9; break; - case 1024: sb->s_blocksize_bits = 10; break; - case 2048: sb->s_blocksize_bits = 11; break; - case 4096: sb->s_blocksize_bits = 12; break; - case 8192: sb->s_blocksize_bits = 13; break; - default: - { - udf_debug("Bad block size (%ld)\n", sb->s_blocksize); - printk(KERN_ERR "udf: bad block size (%ld)\n", sb->s_blocksize); - return 0; - } + if (!sb_min_blocksize(sb, bsize)) { + udf_debug("Bad block size (%d)\n", bsize); + printk(KERN_ERR "udf: bad block size (%d)\n", bsize); + return 0; } - - /* Set the block size */ - set_blocksize(sb->s_dev, sb->s_blocksize); return sb->s_blocksize; } diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/fs/ufs/inode.c linux-2.5/fs/ufs/inode.c --- linux-2.5.1/fs/ufs/inode.c Sun Dec 16 20:23:05 2001 +++ linux-2.5/fs/ufs/inode.c Thu Dec 27 22:10:28 2001 @@ -310,22 +310,16 @@ static int ufs_getfrag_block (struct inode *inode, sector_t fragment, struct buffer_head *bh_result, int create) { - struct super_block * sb; - struct ufs_sb_private_info * uspi; + struct super_block * sb = inode->i_sb; + struct ufs_sb_private_info * uspi = sb->u.ufs_sb.s_uspi; struct buffer_head * bh; int ret, err, new; unsigned long ptr, phys; - sb = inode->i_sb; - uspi = sb->u.ufs_sb.s_uspi; - if (!create) { phys = ufs_frag_map(inode, fragment); - if (phys) { - bh_result->b_dev = inode->i_dev; - bh_result->b_blocknr = phys; - bh_result->b_state |= (1UL << BH_Mapped); - } + if (phys) + map_bh(bh_result, sb, phys); return 0; } @@ -392,11 +386,9 @@ out: if (err) goto abort; - bh_result->b_dev = inode->i_dev; - bh_result->b_blocknr = phys; - bh_result->b_state |= (1UL << BH_Mapped); if (new) bh_result->b_state |= (1UL << BH_New); + map_bh(bh_result, sb, phys); abort: unlock_kernel(); return err; @@ -494,13 +486,13 @@ if (inode->i_ino < UFS_ROOTINO || inode->i_ino > (uspi->s_ncg * uspi->s_ipg)) { ufs_warning (sb, "ufs_read_inode", "bad inode number (%lu)\n", inode->i_ino); - return; + goto bad_inode; } bh = sb_bread(sb, uspi->s_sbbase + ufs_inotofsba(inode->i_ino)); if (!bh) { ufs_warning (sb, "ufs_read_inode", "unable to read inode %lu\n", inode->i_ino); - return; + goto bad_inode; } ufs_inode = (struct ufs_inode *) (bh->b_data + sizeof(struct ufs_inode) * ufs_inotofsbo(inode->i_ino)); @@ -565,6 +557,11 @@ brelse (bh); UFSD(("EXIT\n")) + return; + +bad_inode: + make_bad_inode(inode); + return; } static int ufs_update_inode(struct inode * inode, int do_sync) diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/fs/ufs/super.c linux-2.5/fs/ufs/super.c --- linux-2.5.1/fs/ufs/super.c Sun Dec 16 20:23:05 2001 +++ linux-2.5/fs/ufs/super.c Thu Dec 27 16:32:31 2001 @@ -442,6 +442,7 @@ struct ufs_super_block_second * usb2; struct ufs_super_block_third * usb3; struct ufs_buffer_head * ubh; + struct inode *inode; unsigned block_size, super_block_size; unsigned flags; @@ -596,8 +597,7 @@ } again: - set_blocksize (sb->s_dev, block_size); - sb->s_blocksize = block_size; + sb_set_blocksize(sb, block_size); /* * read ufs super block from device @@ -716,8 +716,6 @@ /* * Read ufs_super_block into internal data structures */ - sb->s_blocksize = fs32_to_cpu(sb, usb1->fs_fsize); - sb->s_blocksize_bits = fs32_to_cpu(sb, usb1->fs_fshift); sb->s_op = &ufs_super_ops; sb->dq_op = NULL; /***/ sb->s_magic = fs32_to_cpu(sb, usb3->fs_magic); @@ -790,7 +788,13 @@ fs32_to_cpu(sb, usb3->fs_u2.fs_44.fs_maxsymlinklen); sb->u.ufs_sb.s_flags = flags; - sb->s_root = d_alloc_root(iget(sb, UFS_ROOTINO)); + + inode = iget(sb, UFS_ROOTINO); + if (!inode || is_bad_inode(inode)) + goto failed; + sb->s_root = d_alloc_root(inode); + if (!sb->s_root) + goto dalloc_failed; /* @@ -803,6 +807,8 @@ UFSD(("EXIT\n")) return(sb); +dalloc_failed: + iput(inode); failed: if (ubh) ubh_brelse_uspi (uspi); if (uspi) kfree (uspi); diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/fs/vfat/namei.c linux-2.5/fs/vfat/namei.c --- linux-2.5.1/fs/vfat/namei.c Thu Oct 25 07:02:26 2001 +++ linux-2.5/fs/vfat/namei.c Sun Dec 30 20:01:41 2001 @@ -1040,8 +1040,8 @@ return res; inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME; mark_inode_dirty(inode); - inode->i_version = ++event; - dir->i_version = event; + inode->i_version++; + dir->i_version++; dentry->d_time = dentry->d_parent->d_inode->i_version; d_instantiate(dentry,inode); return 0; @@ -1057,7 +1057,7 @@ /* remove the shortname */ dir->i_mtime = CURRENT_TIME; dir->i_atime = CURRENT_TIME; - dir->i_version = ++event; + dir->i_version++; mark_inode_dirty(dir); de->name[0] = DELETED_FLAG; fat_mark_buffer_dirty(sb, bh); @@ -1138,8 +1138,8 @@ goto out; inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME; mark_inode_dirty(inode); - inode->i_version = ++event; - dir->i_version = event; + inode->i_version++; + dir->i_version++; dir->i_nlink++; inode->i_nlink = 2; /* no need to mark them dirty */ res = fat_new_dir(inode, dir, 1); @@ -1209,7 +1209,7 @@ if (res < 0) goto rename_done; } - new_dir->i_version = ++event; + new_dir->i_version++; /* releases old_bh */ vfat_remove_entry(old_dir,&old_sinfo,old_bh,old_de); @@ -1218,7 +1218,7 @@ fat_attach(old_inode, sinfo.ino); mark_inode_dirty(old_inode); - old_dir->i_version = ++event; + old_dir->i_version++; old_dir->i_ctime = old_dir->i_mtime = CURRENT_TIME; mark_inode_dirty(old_dir); if (new_inode) { diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/fs/vfat/vfatfs_syms.c linux-2.5/fs/vfat/vfatfs_syms.c --- linux-2.5.1/fs/vfat/vfatfs_syms.c Fri Oct 12 20:48:42 2001 +++ linux-2.5/fs/vfat/vfatfs_syms.c Thu Dec 13 16:32:37 2001 @@ -33,3 +33,4 @@ module_init(init_vfat_fs) module_exit(exit_vfat_fs) +MODULE_LICENSE("GPL"); diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/include/asm-alpha/pci.h linux-2.5/include/asm-alpha/pci.h --- linux-2.5.1/include/asm-alpha/pci.h Fri Oct 12 22:35:54 2001 +++ linux-2.5/include/asm-alpha/pci.h Thu Dec 27 16:32:31 2001 @@ -101,6 +101,20 @@ extern void pci_unmap_single(struct pci_dev *, dma_addr_t, size_t, int); extern void pci_unmap_page(struct pci_dev *, dma_addr_t, size_t, int); +/* pci_unmap_{single,page} is not a nop, thus... */ +#define DECLARE_PCI_UNMAP_ADDR(ADDR_NAME) \ + dma_addr_t ADDR_NAME; +#define DECLARE_PCI_UNMAP_LEN(LEN_NAME) \ + __u32 LEN_NAME; +#define PCI_UNMAP_ADDR(PTR, ADDR_NAME) \ + ((PTR)->ADDR_NAME) +#define PCI_UNMAP_ADDR_SET(PTR, ADDR_NAME, VAL) \ + (((PTR)->ADDR_NAME) = (VAL)) +#define PCI_UNMAP_LEN(PTR, LEN_NAME) \ + ((PTR)->LEN_NAME) +#define PCI_UNMAP_LEN_SET(PTR, LEN_NAME, VAL) \ + (((PTR)->LEN_NAME) = (VAL)) + /* Map a set of buffers described by scatterlist in streaming mode for PCI DMA. This is the scather-gather version of the above pci_map_single interface. Here the scatter gather list elements diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/include/asm-alpha/processor.h linux-2.5/include/asm-alpha/processor.h --- linux-2.5.1/include/asm-alpha/processor.h Fri Oct 5 19:11:05 2001 +++ linux-2.5/include/asm-alpha/processor.h Thu Dec 27 15:14:59 2001 @@ -30,7 +30,6 @@ * Bus types */ #define EISA_bus 1 -#define EISA_bus__is_a_macro /* for versions in ksyms.c */ #define MCA_bus 0 #define MCA_bus__is_a_macro /* for versions in ksyms.c */ diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/include/asm-arm/bitops.h linux-2.5/include/asm-arm/bitops.h --- linux-2.5.1/include/asm-arm/bitops.h Sun Aug 12 18:14:00 2001 +++ linux-2.5/include/asm-arm/bitops.h Thu Dec 27 22:10:28 2001 @@ -2,6 +2,8 @@ * Copyright 1995, Russell King. * Various bits and pieces copyrights include: * Linus Torvalds (test_bit). + * Big endian support: Copyright 2001, Nicolas Pitre + * reworked by rmk. * * bit 0 is the LSB of addr; bit 32 is the LSB of (addr+1). * @@ -17,81 +19,271 @@ #ifdef __KERNEL__ +#include <asm/system.h> + #define smp_mb__before_clear_bit() do { } while (0) #define smp_mb__after_clear_bit() do { } while (0) /* - * Function prototypes to keep gcc -Wall happy. + * These functions are the basis of our bit ops. + * First, the atomic bitops. + * + * The endian issue for these functions is handled by the macros below. */ -extern void set_bit(int nr, volatile void * addr); +static inline void +____atomic_set_bit_mask(unsigned int mask, volatile unsigned char *p) +{ + unsigned long flags; + + local_irq_save(flags); + *p |= mask; + local_irq_restore(flags); +} -static inline void __set_bit(int nr, volatile void *addr) +static inline void +____atomic_clear_bit_mask(unsigned int mask, volatile unsigned char *p) { - ((unsigned char *) addr)[nr >> 3] |= (1U << (nr & 7)); + unsigned long flags; + + local_irq_save(flags); + *p &= ~mask; + local_irq_restore(flags); } -extern void clear_bit(int nr, volatile void * addr); +static inline void +____atomic_change_bit_mask(unsigned int mask, volatile unsigned char *p) +{ + unsigned long flags; + + local_irq_save(flags); + *p ^= mask; + local_irq_restore(flags); +} -static inline void __clear_bit(int nr, volatile void *addr) +static inline int +____atomic_test_and_set_bit_mask(unsigned int mask, volatile unsigned char *p) { - ((unsigned char *) addr)[nr >> 3] &= ~(1U << (nr & 7)); + unsigned long flags; + unsigned int res; + + local_irq_save(flags); + res = *p; + *p = res | mask; + local_irq_restore(flags); + + return res & mask; } -extern void change_bit(int nr, volatile void * addr); +static inline int +____atomic_test_and_clear_bit_mask(unsigned int mask, volatile unsigned char *p) +{ + unsigned long flags; + unsigned int res; -static inline void __change_bit(int nr, volatile void *addr) + local_irq_save(flags); + res = *p; + *p = res & ~mask; + local_irq_restore(flags); + + return res & mask; +} + +static inline int +____atomic_test_and_change_bit_mask(unsigned int mask, volatile unsigned char *p) { - ((unsigned char *) addr)[nr >> 3] ^= (1U << (nr & 7)); + unsigned long flags; + unsigned int res; + + local_irq_save(flags); + res = *p; + *p = res ^ mask; + local_irq_restore(flags); + + return res & mask; } -extern int test_and_set_bit(int nr, volatile void * addr); +/* + * Now the non-atomic variants. We let the compiler handle all optimisations + * for these. + */ +static inline void ____nonatomic_set_bit(int nr, volatile void *p) +{ + ((unsigned char *) p)[nr >> 3] |= (1U << (nr & 7)); +} + +static inline void ____nonatomic_clear_bit(int nr, volatile void *p) +{ + ((unsigned char *) p)[nr >> 3] &= ~(1U << (nr & 7)); +} + +static inline void ____nonatomic_change_bit(int nr, volatile void *p) +{ + ((unsigned char *) p)[nr >> 3] ^= (1U << (nr & 7)); +} -static inline int __test_and_set_bit(int nr, volatile void *addr) +static inline int ____nonatomic_test_and_set_bit(int nr, volatile void *p) { unsigned int mask = 1 << (nr & 7); unsigned int oldval; - oldval = ((unsigned char *) addr)[nr >> 3]; - ((unsigned char *) addr)[nr >> 3] = oldval | mask; + oldval = ((unsigned char *) p)[nr >> 3]; + ((unsigned char *) p)[nr >> 3] = oldval | mask; return oldval & mask; } -extern int test_and_clear_bit(int nr, volatile void * addr); - -static inline int __test_and_clear_bit(int nr, volatile void *addr) +static inline int ____nonatomic_test_and_clear_bit(int nr, volatile void *p) { unsigned int mask = 1 << (nr & 7); unsigned int oldval; - oldval = ((unsigned char *) addr)[nr >> 3]; - ((unsigned char *) addr)[nr >> 3] = oldval & ~mask; + oldval = ((unsigned char *) p)[nr >> 3]; + ((unsigned char *) p)[nr >> 3] = oldval & ~mask; return oldval & mask; } -extern int test_and_change_bit(int nr, volatile void * addr); - -static inline int __test_and_change_bit(int nr, volatile void *addr) +static inline int ____nonatomic_test_and_change_bit(int nr, volatile void *p) { unsigned int mask = 1 << (nr & 7); unsigned int oldval; - oldval = ((unsigned char *) addr)[nr >> 3]; - ((unsigned char *) addr)[nr >> 3] = oldval ^ mask; + oldval = ((unsigned char *) p)[nr >> 3]; + ((unsigned char *) p)[nr >> 3] = oldval ^ mask; return oldval & mask; } -extern int find_first_zero_bit(void * addr, unsigned size); -extern int find_next_zero_bit(void * addr, int size, int offset); - /* * This routine doesn't need to be atomic. */ -static inline int test_bit(int nr, const void * addr) +static inline int ____test_bit(int nr, const void * p) { - return ((unsigned char *) addr)[nr >> 3] & (1U << (nr & 7)); + return ((volatile unsigned char *) p)[nr >> 3] & (1U << (nr & 7)); } /* + * A note about Endian-ness. + * ------------------------- + * + * When the ARM is put into big endian mode via CR15, the processor + * merely swaps the order of bytes within words, thus: + * + * ------------ physical data bus bits ----------- + * D31 ... D24 D23 ... D16 D15 ... D8 D7 ... D0 + * little byte 3 byte 2 byte 1 byte 0 + * big byte 0 byte 1 byte 2 byte 3 + * + * This means that reading a 32-bit word at address 0 returns the same + * value irrespective of the endian mode bit. + * + * Peripheral devices should be connected with the data bus reversed in + * "Big Endian" mode. ARM Application Note 61 is applicable, and is + * available from http://www.arm.com/. + * + * The following assumes that the data bus connectivity for big endian + * mode has been followed. + * + * Note that bit 0 is defined to be 32-bit word bit 0, not byte 0 bit 0. + */ + +/* + * Little endian assembly bitops. nr = 0 -> byte 0 bit 0. + */ +extern void _set_bit_le(int nr, volatile void * p); +extern void _clear_bit_le(int nr, volatile void * p); +extern void _change_bit_le(int nr, volatile void * p); +extern int _test_and_set_bit_le(int nr, volatile void * p); +extern int _test_and_clear_bit_le(int nr, volatile void * p); +extern int _test_and_change_bit_le(int nr, volatile void * p); +extern int _find_first_zero_bit_le(void * p, unsigned size); +extern int _find_next_zero_bit_le(void * p, int size, int offset); + +/* + * Big endian assembly bitops. nr = 0 -> byte 3 bit 0. + */ +extern void _set_bit_be(int nr, volatile void * p); +extern void _clear_bit_be(int nr, volatile void * p); +extern void _change_bit_be(int nr, volatile void * p); +extern int _test_and_set_bit_be(int nr, volatile void * p); +extern int _test_and_clear_bit_be(int nr, volatile void * p); +extern int _test_and_change_bit_be(int nr, volatile void * p); +extern int _find_first_zero_bit_be(void * p, unsigned size); +extern int _find_next_zero_bit_be(void * p, int size, int offset); + + +/* + * The __* form of bitops are non-atomic and may be reordered. + */ +#define ATOMIC_BITOP_LE(name,nr,p) \ + (__builtin_constant_p(nr) ? \ + ____atomic_##name##_mask(1 << ((nr) & 7), \ + ((unsigned char *)(p)) + ((nr) >> 3)) : \ + _##name##_le(nr,p)) + +#define ATOMIC_BITOP_BE(name,nr,p) \ + (__builtin_constant_p(nr) ? \ + ____atomic_##name##_mask(1 << ((nr) & 7), \ + ((unsigned char *)(p)) + (((nr) >> 3) ^ 3)) : \ + _##name##_be(nr,p)) + +#define NONATOMIC_BITOP_LE(name,nr,p) \ + (____nonatomic_##name(nr, p)) + +#define NONATOMIC_BITOP_BE(name,nr,p) \ + (____nonatomic_##name(nr ^ 0x18, p)) + +#ifndef __ARMEB__ +/* + * These are the little endian, atomic definitions. + */ +#define set_bit(nr,p) ATOMIC_BITOP_LE(set_bit,nr,p) +#define clear_bit(nr,p) ATOMIC_BITOP_LE(clear_bit,nr,p) +#define change_bit(nr,p) ATOMIC_BITOP_LE(change_bit,nr,p) +#define test_and_set_bit(nr,p) ATOMIC_BITOP_LE(test_and_set_bit,nr,p) +#define test_and_clear_bit(nr,p) ATOMIC_BITOP_LE(test_and_clear_bit,nr,p) +#define test_and_change_bit(nr,p) ATOMIC_BITOP_LE(test_and_change_bit,nr,p) +#define test_bit(nr,p) ____test_bit(nr,p) +#define find_first_zero_bit(p,sz) _find_first_zero_bit_le(p,sz) +#define find_next_zero_bit(p,sz,off) _find_next_zero_bit_le(p,sz,off) + +/* + * These are the little endian, non-atomic definitions. + */ +#define __set_bit(nr,p) NONATOMIC_BITOP_LE(set_bit,nr,p) +#define __clear_bit(nr,p) NONATOMIC_BITOP_LE(clear_bit,nr,p) +#define __change_bit(nr,p) NONATOMIC_BITOP_LE(change_bit,nr,p) +#define __test_and_set_bit(nr,p) NONATOMIC_BITOP_LE(test_and_set_bit,nr,p) +#define __test_and_clear_bit(nr,p) NONATOMIC_BITOP_LE(test_and_clear_bit,nr,p) +#define __test_and_change_bit(nr,p) NONATOMIC_BITOP_LE(test_and_change_bit,nr,p) +#define __test_bit(nr,p) ____test_bit(nr,p) + +#else + +/* + * These are the little endian, atomic definitions. + */ +#define set_bit(nr,p) ATOMIC_BITOP_BE(set_bit,nr,p) +#define clear_bit(nr,p) ATOMIC_BITOP_BE(clear_bit,nr,p) +#define change_bit(nr,p) ATOMIC_BITOP_BE(change_bit,nr,p) +#define test_and_set_bit(nr,p) ATOMIC_BITOP_BE(test_and_set_bit,nr,p) +#define test_and_clear_bit(nr,p) ATOMIC_BITOP_BE(test_and_clear_bit,nr,p) +#define test_and_change_bit(nr,p) ATOMIC_BITOP_BE(test_and_change_bit,nr,p) +#define test_bit(nr,p) ____test_bit((nr) ^ 0x18, p) +#define find_first_zero_bit(p,sz) _find_first_zero_bit_be(p,sz) +#define find_next_zero_bit(p,sz,off) _find_next_zero_bit_be(p,sz,off) + +/* + * These are the little endian, non-atomic definitions. + */ +#define __set_bit(nr,p) NONATOMIC_BITOP_BE(set_bit,nr,p) +#define __clear_bit(nr,p) NONATOMIC_BITOP_BE(clear_bit,nr,p) +#define __change_bit(nr,p) NONATOMIC_BITOP_BE(change_bit,nr,p) +#define __test_and_set_bit(nr,p) NONATOMIC_BITOP_BE(test_and_set_bit,nr,p) +#define __test_and_clear_bit(nr,p) NONATOMIC_BITOP_BE(test_and_clear_bit,nr,p) +#define __test_and_change_bit(nr,p) NONATOMIC_BITOP_BE(test_and_change_bit,nr,p) +#define __test_bit(nr,p) ____test_bit((nr) ^ 0x18, p) + +#endif + +/* * ffz = Find First Zero in word. Undefined if no zero exists, * so code should check against ~0UL first.. */ @@ -126,18 +318,25 @@ #define hweight16(x) generic_hweight16(x) #define hweight8(x) generic_hweight8(x) -#define ext2_set_bit test_and_set_bit -#define ext2_clear_bit test_and_clear_bit -#define ext2_test_bit test_bit -#define ext2_find_first_zero_bit find_first_zero_bit -#define ext2_find_next_zero_bit find_next_zero_bit - -/* Bitmap functions for the minix filesystem. */ -#define minix_test_and_set_bit(nr,addr) test_and_set_bit(nr,addr) -#define minix_set_bit(nr,addr) set_bit(nr,addr) -#define minix_test_and_clear_bit(nr,addr) test_and_clear_bit(nr,addr) -#define minix_test_bit(nr,addr) test_bit(nr,addr) -#define minix_find_first_zero_bit(addr,size) find_first_zero_bit(addr,size) +/* + * Ext2 is defined to use little-endian byte ordering. + * These do not need to be atomic. + */ +#define ext2_set_bit(nr,p) NONATOMIC_BITOP_LE(test_and_set_bit,nr,p) +#define ext2_clear_bit(nr,p) NONATOMIC_BITOP_LE(test_and_clear_bit,nr,p) +#define ext2_test_bit(nr,p) __test_bit(nr,p) +#define ext2_find_first_zero_bit(p,sz) _find_first_zero_bit_le(p,sz) +#define ext2_find_next_zero_bit(p,sz,off) _find_next_zero_bit_le(p,sz,off) + +/* + * Minix is defined to use little-endian byte ordering. + * These do not need to be atomic. + */ +#define minix_set_bit(nr,p) NONATOMIC_BITOP_LE(set_bit,nr,p) +#define minix_test_bit(nr,p) __test_bit(nr,p) +#define minix_test_and_set_bit(nr,p) NONATOMIC_BITOP_LE(test_and_set_bit,nr,p) +#define minix_test_and_clear_bit(nr,p) NONATOMIC_BITOP_LE(test_and_clear_bit,nr,p) +#define minix_find_first_zero_bit(p,sz) _find_first_zero_bit_le(p,sz) #endif /* __KERNEL__ */ diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/include/asm-arm/pci.h linux-2.5/include/asm-arm/pci.h --- linux-2.5.1/include/asm-arm/pci.h Fri Nov 9 22:11:15 2001 +++ linux-2.5/include/asm-arm/pci.h Thu Dec 27 16:32:31 2001 @@ -87,6 +87,31 @@ /* nothing to do */ } +/* Whether pci_unmap_{single,page} is a nop depends upon the + * configuration. + */ +#ifdef CONFIG_SA1111 +#define DECLARE_PCI_UNMAP_ADDR(ADDR_NAME) \ + dma_addr_t ADDR_NAME; +#define DECLARE_PCI_UNMAP_LEN(LEN_NAME) \ + __u32 LEN_NAME; +#define PCI_UNMAP_ADDR(PTR, ADDR_NAME) \ + ((PTR)->ADDR_NAME) +#define PCI_UNMAP_ADDR_SET(PTR, ADDR_NAME, VAL) \ + (((PTR)->ADDR_NAME) = (VAL)) +#define PCI_UNMAP_LEN(PTR, LEN_NAME) \ + ((PTR)->LEN_NAME) +#define PCI_UNMAP_LEN_SET(PTR, LEN_NAME, VAL) \ + (((PTR)->LEN_NAME) = (VAL)) +#else /* !(CONFIG_SA1111) */ +#define DECLARE_PCI_UNMAP_ADDR(ADDR_NAME) +#define DECLARE_PCI_UNMAP_LEN(LEN_NAME) +#define PCI_UNMAP_ADDR(PTR, ADDR_NAME) (0) +#define PCI_UNMAP_ADDR_SET(PTR, ADDR_NAME, VAL) do { } while (0) +#define PCI_UNMAP_LEN(PTR, LEN_NAME) (0) +#define PCI_UNMAP_LEN_SET(PTR, LEN_NAME, VAL) do { } while (0) +#endif /* CONFIG_SA1111 */ + /* Map a set of buffers described by scatterlist in streaming * mode for DMA. This is the scather-gather version of the * above pci_map_single interface. Here the scatter gather list diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/include/asm-i386/cpufeature.h linux-2.5/include/asm-i386/cpufeature.h --- linux-2.5.1/include/asm-i386/cpufeature.h Mon Nov 13 05:55:50 2000 +++ linux-2.5/include/asm-i386/cpufeature.h Thu Dec 13 16:32:37 2001 @@ -40,6 +40,7 @@ #define X86_FEATURE_XMM (0*32+25) /* Streaming SIMD Extensions */ #define X86_FEATURE_XMM2 (0*32+26) /* Streaming SIMD Extensions-2 */ #define X86_FEATURE_SELFSNOOP (0*32+27) /* CPU self snoop */ +#define X86_FEATURE_HT (0*32+28) /* Hyper-Threading */ #define X86_FEATURE_ACC (0*32+29) /* Automatic clock control */ #define X86_FEATURE_IA64 (0*32+30) /* IA-64 processor */ diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/include/asm-i386/desc.h linux-2.5/include/asm-i386/desc.h --- linux-2.5.1/include/asm-i386/desc.h Thu Jul 26 20:40:32 2001 +++ linux-2.5/include/asm-i386/desc.h Sat Dec 29 12:07:19 2001 @@ -18,23 +18,31 @@ * 9 - APM BIOS support * 10 - APM BIOS support * 11 - APM BIOS support + * 12 - PNPBIOS support + * 13 - PNPBIOS support + * 14 - PNPBIOS support + * 15 - PNPBIOS support + * 16 - PNPBIOS support + * 17 - not used + * 18 - not used + * 19 - not used * * The TSS+LDT descriptors are spread out a bit so that every CPU * has an exclusive cacheline for the per-CPU TSS and LDT: * - * 12 - CPU#0 TSS <-- new cacheline - * 13 - CPU#0 LDT - * 14 - not used - * 15 - not used - * 16 - CPU#1 TSS <-- new cacheline - * 17 - CPU#1 LDT - * 18 - not used - * 19 - not used + * 20 - CPU#0 TSS <-- new cacheline + * 21 - CPU#0 LDT + * 22 - not used + * 23 - not used + * 24 - CPU#1 TSS <-- new cacheline + * 25 - CPU#1 LDT + * 26 - not used + * 27 - not used * ... NR_CPUS per-CPU TSS+LDT's if on SMP * * Entry into gdt where to find first TSS. */ -#define __FIRST_TSS_ENTRY 12 +#define __FIRST_TSS_ENTRY 20 #define __FIRST_LDT_ENTRY (__FIRST_TSS_ENTRY+1) #define __TSS(n) (((n)<<2) + __FIRST_TSS_ENTRY) @@ -79,13 +87,13 @@ /* * load one particular LDT into the current CPU */ -static inline void load_LDT (struct mm_struct *mm) +static inline void load_LDT (mm_context_t *pc) { int cpu = smp_processor_id(); - void *segments = mm->context.segments; - int count = LDT_ENTRIES; + void *segments = pc->ldt; + int count = pc->size; - if (!segments) { + if (!count) { segments = &default_ldt[0]; count = 5; } diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/include/asm-i386/mmu.h linux-2.5/include/asm-i386/mmu.h --- linux-2.5.1/include/asm-i386/mmu.h Thu Jul 26 01:03:04 2001 +++ linux-2.5/include/asm-i386/mmu.h Fri Dec 28 00:00:30 2001 @@ -4,10 +4,13 @@ /* * The i386 doesn't have a mmu context, but * we put the segment information here. + * + * cpu_vm_mask is used to optimize ldt flushing. */ typedef struct { - void *segments; - unsigned long cpuvalid; + int size; + struct semaphore sem; + void * ldt; } mm_context_t; #endif diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/include/asm-i386/mmu_context.h linux-2.5/include/asm-i386/mmu_context.h --- linux-2.5.1/include/asm-i386/mmu_context.h Sun Dec 16 23:43:25 2001 +++ linux-2.5/include/asm-i386/mmu_context.h Mon Dec 31 21:53:24 2001 @@ -10,7 +10,7 @@ * possibly do the LDT unload here? */ #define destroy_context(mm) do { } while(0) -#define init_new_context(tsk,mm) 0 +int init_new_context(struct task_struct *tsk, struct mm_struct *mm); #ifdef CONFIG_SMP @@ -30,19 +30,19 @@ if (prev != next) { /* stop flush ipis for the previous mm */ clear_bit(cpu, &prev->cpu_vm_mask); - /* - * Re-load LDT if necessary - */ - if (prev->context.segments != next->context.segments) - load_LDT(next); #ifdef CONFIG_SMP cpu_tlbstate[cpu].state = TLBSTATE_OK; cpu_tlbstate[cpu].active_mm = next; #endif set_bit(cpu, &next->cpu_vm_mask); - set_bit(cpu, &next->context.cpuvalid); + /* Re-load page tables */ asm volatile("movl %0,%%cr3": :"r" (__pa(next->pgd))); + /* load_LDT, if either the previous or next thread + * has a non-default LDT. + */ + if (next->context.size+prev->context.size) + load_LDT(&next->context); } #ifdef CONFIG_SMP else { @@ -54,9 +54,8 @@ * tlb flush IPI delivery. We must flush our tlb. */ local_flush_tlb(); + load_LDT(&next->context); } - if (!test_and_set_bit(cpu, &next->context.cpuvalid)) - load_LDT(next); } #endif } diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/include/asm-i386/msr.h linux-2.5/include/asm-i386/msr.h --- linux-2.5.1/include/asm-i386/msr.h Sat Sep 1 18:01:28 2001 +++ linux-2.5/include/asm-i386/msr.h Thu Dec 13 16:32:37 2001 @@ -81,6 +81,7 @@ #define MSR_K7_EVNTSEL0 0xC0010000 #define MSR_K7_PERFCTR0 0xC0010004 +#define MSR_K7_HWCR 0xC0010015 /* Centaur-Hauls/IDT defined MSRs. */ #define MSR_IDT_FCR1 0x107 diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/include/asm-i386/page.h linux-2.5/include/asm-i386/page.h --- linux-2.5.1/include/asm-i386/page.h Sun Dec 16 23:43:25 2001 +++ linux-2.5/include/asm-i386/page.h Mon Dec 31 21:53:19 2001 @@ -80,6 +80,12 @@ #define __PAGE_OFFSET (0xC0000000) +/* + * This much address space is reserved for vmalloc() and iomap() + * as well as fixmap mappings. + */ +#define __VMALLOC_RESERVE (128 << 20) + #ifndef __ASSEMBLY__ /* @@ -118,6 +124,9 @@ #endif /* __ASSEMBLY__ */ #define PAGE_OFFSET ((unsigned long)__PAGE_OFFSET) +#define VMALLOC_RESERVE ((unsigned long)__VMALLOC_RESERVE) +#define __MAXMEM (-__PAGE_OFFSET-__VMALLOC_RESERVE) +#define MAXMEM ((unsigned long)(-PAGE_OFFSET-VMALLOC_RESERVE)) #define __pa(x) ((unsigned long)(x)-PAGE_OFFSET) #define __va(x) ((void *)((unsigned long)(x)+PAGE_OFFSET)) #define virt_to_page(kaddr) (mem_map + (__pa(kaddr) >> PAGE_SHIFT)) diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/include/asm-i386/pci.h linux-2.5/include/asm-i386/pci.h --- linux-2.5.1/include/asm-i386/pci.h Sun Dec 16 23:43:50 2001 +++ linux-2.5/include/asm-i386/pci.h Mon Dec 31 21:53:20 2001 @@ -114,6 +114,14 @@ /* Nothing to do */ } +/* pci_unmap_{page,single} is a nop so... */ +#define DECLARE_PCI_UNMAP_ADDR(ADDR_NAME) +#define DECLARE_PCI_UNMAP_LEN(LEN_NAME) +#define PCI_UNMAP_ADDR(PTR, ADDR_NAME) (0) +#define PCI_UNMAP_ADDR_SET(PTR, ADDR_NAME, VAL) do { } while (0) +#define PCI_UNMAP_LEN(PTR, LEN_NAME) (0) +#define PCI_UNMAP_LEN_SET(PTR, LEN_NAME, VAL) do { } while (0) + /* Map a set of buffers described by scatterlist in streaming * mode for DMA. This is the scather-gather version of the * above pci_map_single interface. Here the scatter gather list diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/include/asm-i386/processor.h linux-2.5/include/asm-i386/processor.h --- linux-2.5.1/include/asm-i386/processor.h Sun Dec 16 23:43:25 2001 +++ linux-2.5/include/asm-i386/processor.h Mon Dec 31 21:53:19 2001 @@ -248,11 +248,7 @@ /* * Bus types (default is ISA, but people can check others with these..) */ -#ifdef CONFIG_EISA extern int EISA_bus; -#else -#define EISA_bus (0) -#endif extern int MCA_bus; /* from system description table in BIOS. Mostly for MCA use, but @@ -431,8 +427,7 @@ */ extern int kernel_thread(int (*fn)(void *), void * arg, unsigned long flags); -/* Copy and release all segment info associated with a VM */ -extern void copy_segments(struct task_struct *p, struct mm_struct * mm); +/* Release all segment info associated with a VM */ extern void release_segments(struct mm_struct * mm); /* @@ -504,6 +499,36 @@ } #define spin_lock_prefetch(x) prefetchw(x) +#endif + +#ifdef ARCH_HAS_PREFETCH +static inline void preload_cache(const void *from, unsigned long n) +{ + if (n>=128) { + int __pf, linestofetch; + + if (n >= boot_cpu_data.x86_cache_size*1024) { + /* Size is bigger than cache, just fill cache. */ + linestofetch = (boot_cpu_data.x86_cache_size*1024) + / L1_CACHE_BYTES; + } else { + /* Size is smaller than cache, read whole chunk. */ + linestofetch = n/L1_CACHE_BYTES; + } + + /* Prime the TLB */ + __asm__ __volatile__ ( + "movb %0, %%eax\n\t" + "movb %1, %%eax\n\t" + : : "m" (from), "m" (from+n-4) + : "eax"); + + for (__pf=0 ; __pf<(linestofetch/2) ; __pf+=L1_CACHE_BYTES*2) { + prefetch (from+__pf); + prefetch (from+__pf+L1_CACHE_BYTES*2); + } + } +} #endif #endif /* __ASM_I386_PROCESSOR_H */ diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/include/asm-i386/rwlock.h linux-2.5/include/asm-i386/rwlock.h --- linux-2.5.1/include/asm-i386/rwlock.h Fri Sep 22 21:07:43 2000 +++ linux-2.5/include/asm-i386/rwlock.h Sat Dec 29 11:10:40 2001 @@ -17,6 +17,8 @@ #ifndef _ASM_I386_RWLOCK_H #define _ASM_I386_RWLOCK_H +#include <linux/stringify.h> + #define RW_LOCK_BIAS 0x01000000 #define RW_LOCK_BIAS_STR "0x01000000" @@ -24,23 +26,29 @@ asm volatile(LOCK "subl $1,(%0)\n\t" \ "js 2f\n" \ "1:\n" \ - ".section .text.lock,\"ax\"\n" \ + ".subsection 1\n" \ + ".ifndef _text_lock_" __stringify(KBUILD_BASENAME) "\n" \ + "_text_lock_" __stringify(KBUILD_BASENAME) ":\n" \ + ".endif\n" \ "2:\tcall " helper "\n\t" \ "jmp 1b\n" \ - ".previous" \ + ".subsection 0\n" \ ::"a" (rw) : "memory") #define __build_read_lock_const(rw, helper) \ asm volatile(LOCK "subl $1,%0\n\t" \ "js 2f\n" \ "1:\n" \ - ".section .text.lock,\"ax\"\n" \ + ".subsection 1\n" \ + ".ifndef _text_lock_" __stringify(KBUILD_BASENAME) "\n" \ + "_text_lock_" __stringify(KBUILD_BASENAME) ":\n" \ + ".endif\n" \ "2:\tpushl %%eax\n\t" \ "leal %0,%%eax\n\t" \ "call " helper "\n\t" \ "popl %%eax\n\t" \ "jmp 1b\n" \ - ".previous" \ + ".subsection 0\n" \ :"=m" (*(volatile int *)rw) : : "memory") #define __build_read_lock(rw, helper) do { \ @@ -54,23 +62,29 @@ asm volatile(LOCK "subl $" RW_LOCK_BIAS_STR ",(%0)\n\t" \ "jnz 2f\n" \ "1:\n" \ - ".section .text.lock,\"ax\"\n" \ + ".subsection 1\n" \ + ".ifndef _text_lock_" __stringify(KBUILD_BASENAME) "\n" \ + "_text_lock_" __stringify(KBUILD_BASENAME) ":\n" \ + ".endif\n" \ "2:\tcall " helper "\n\t" \ "jmp 1b\n" \ - ".previous" \ + ".subsection 0\n" \ ::"a" (rw) : "memory") #define __build_write_lock_const(rw, helper) \ asm volatile(LOCK "subl $" RW_LOCK_BIAS_STR ",(%0)\n\t" \ "jnz 2f\n" \ "1:\n" \ - ".section .text.lock,\"ax\"\n" \ + ".subsection 1\n" \ + ".ifndef _text_lock_" __stringify(KBUILD_BASENAME) "\n" \ + "_text_lock_" __stringify(KBUILD_BASENAME) ":\n" \ + ".endif\n" \ "2:\tpushl %%eax\n\t" \ "leal %0,%%eax\n\t" \ "call " helper "\n\t" \ "popl %%eax\n\t" \ "jmp 1b\n" \ - ".previous" \ + ".subsection 0\n" \ :"=m" (*(volatile int *)rw) : : "memory") #define __build_write_lock(rw, helper) do { \ diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/include/asm-i386/rwsem.h linux-2.5/include/asm-i386/rwsem.h --- linux-2.5.1/include/asm-i386/rwsem.h Sun Dec 16 23:43:25 2001 +++ linux-2.5/include/asm-i386/rwsem.h Mon Dec 31 21:53:19 2001 @@ -40,6 +40,7 @@ #include <linux/list.h> #include <linux/spinlock.h> +#include <linux/stringify.h> struct rwsem_waiter; @@ -101,7 +102,10 @@ LOCK_PREFIX " incl (%%eax)\n\t" /* adds 0x00000001, returns the old value */ " js 2f\n\t" /* jump if we weren't granted the lock */ "1:\n\t" - ".section .text.lock,\"ax\"\n" + ".subsection 1\n" + ".ifndef _text_lock_" __stringify(KBUILD_BASENAME) "\n" + "_text_lock_" __stringify(KBUILD_BASENAME) ":\n" + ".endif\n" "2:\n\t" " pushl %%ecx\n\t" " pushl %%edx\n\t" @@ -109,7 +113,7 @@ " popl %%edx\n\t" " popl %%ecx\n\t" " jmp 1b\n" - ".previous" + ".subsection 0\n" "# ending down_read\n\t" : "+m"(sem->count) : "a"(sem) @@ -130,13 +134,16 @@ " testl %0,%0\n\t" /* was the count 0 before? */ " jnz 2f\n\t" /* jump if we weren't granted the lock */ "1:\n\t" - ".section .text.lock,\"ax\"\n" + ".subsection 1\n" + ".ifndef _text_lock_" __stringify(KBUILD_BASENAME) "\n" + "_text_lock_" __stringify(KBUILD_BASENAME) ":\n" + ".endif\n" "2:\n\t" " pushl %%ecx\n\t" " call rwsem_down_write_failed\n\t" " popl %%ecx\n\t" " jmp 1b\n" - ".previous\n" + ".subsection 0\n" "# ending down_write" : "+d"(tmp), "+m"(sem->count) : "a"(sem) @@ -154,7 +161,10 @@ LOCK_PREFIX " xadd %%edx,(%%eax)\n\t" /* subtracts 1, returns the old value */ " js 2f\n\t" /* jump if the lock is being waited upon */ "1:\n\t" - ".section .text.lock,\"ax\"\n" + ".subsection 1\n" + ".ifndef _text_lock_" __stringify(KBUILD_BASENAME) "\n" + "_text_lock_" __stringify(KBUILD_BASENAME) ":\n" + ".endif\n" "2:\n\t" " decw %%dx\n\t" /* do nothing if still outstanding active readers */ " jnz 1b\n\t" @@ -162,7 +172,7 @@ " call rwsem_wake\n\t" " popl %%ecx\n\t" " jmp 1b\n" - ".previous\n" + ".subsection 0\n" "# ending __up_read\n" : "+m"(sem->count), "+d"(tmp) : "a"(sem) @@ -180,7 +190,10 @@ LOCK_PREFIX " xaddl %%edx,(%%eax)\n\t" /* tries to transition 0xffff0001 -> 0x00000000 */ " jnz 2f\n\t" /* jump if the lock is being waited upon */ "1:\n\t" - ".section .text.lock,\"ax\"\n" + ".subsection 1\n" + ".ifndef _text_lock_" __stringify(KBUILD_BASENAME) "\n" + "_text_lock_" __stringify(KBUILD_BASENAME) ":\n" + ".endif\n" "2:\n\t" " decw %%dx\n\t" /* did the active count reduce to 0? */ " jnz 1b\n\t" /* jump back if not */ @@ -188,7 +201,7 @@ " call rwsem_wake\n\t" " popl %%ecx\n\t" " jmp 1b\n" - ".previous\n" + ".subsection 0\n" "# ending __up_write\n" : "+m"(sem->count) : "a"(sem), "i"(-RWSEM_ACTIVE_WRITE_BIAS) diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/include/asm-i386/semaphore.h linux-2.5/include/asm-i386/semaphore.h --- linux-2.5.1/include/asm-i386/semaphore.h Sun Dec 16 23:43:25 2001 +++ linux-2.5/include/asm-i386/semaphore.h Mon Dec 31 21:53:19 2001 @@ -40,6 +40,7 @@ #include <asm/atomic.h> #include <linux/wait.h> #include <linux/rwsem.h> +#include <linux/stringify.h> struct semaphore { atomic_t count; @@ -122,10 +123,13 @@ LOCK "decl %0\n\t" /* --sem->count */ "js 2f\n" "1:\n" - ".section .text.lock,\"ax\"\n" + ".subsection 1\n" + ".ifndef _text_lock_" __stringify(KBUILD_BASENAME) "\n" + "_text_lock_" __stringify(KBUILD_BASENAME) ":\n" + ".endif\n" "2:\tcall __down_failed\n\t" "jmp 1b\n" - ".previous" + ".subsection 0\n" :"=m" (sem->count) :"c" (sem) :"memory"); @@ -149,10 +153,13 @@ "js 2f\n\t" "xorl %0,%0\n" "1:\n" - ".section .text.lock,\"ax\"\n" + ".subsection 1\n" + ".ifndef _text_lock_" __stringify(KBUILD_BASENAME) "\n" + "_text_lock_" __stringify(KBUILD_BASENAME) ":\n" + ".endif\n" "2:\tcall __down_failed_interruptible\n\t" "jmp 1b\n" - ".previous" + ".subsection 0\n" :"=a" (result), "=m" (sem->count) :"c" (sem) :"memory"); @@ -177,10 +184,13 @@ "js 2f\n\t" "xorl %0,%0\n" "1:\n" - ".section .text.lock,\"ax\"\n" + ".subsection 1\n" + ".ifndef _text_lock_" __stringify(KBUILD_BASENAME) "\n" + "_text_lock_" __stringify(KBUILD_BASENAME) ":\n" + ".endif\n" "2:\tcall __down_failed_trylock\n\t" "jmp 1b\n" - ".previous" + ".subsection 0\n" :"=a" (result), "=m" (sem->count) :"c" (sem) :"memory"); @@ -203,10 +213,13 @@ LOCK "incl %0\n\t" /* ++sem->count */ "jle 2f\n" "1:\n" - ".section .text.lock,\"ax\"\n" + ".subsection 1\n" + ".ifndef _text_lock_" __stringify(KBUILD_BASENAME) "\n" + "_text_lock_" __stringify(KBUILD_BASENAME) ":\n" + ".endif\n" "2:\tcall __up_wakeup\n\t" "jmp 1b\n" - ".previous" + ".subsection 0\n" :"=m" (sem->count) :"c" (sem) :"memory"); diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/include/asm-i386/smp.h linux-2.5/include/asm-i386/smp.h --- linux-2.5.1/include/asm-i386/smp.h Sun Dec 16 23:43:25 2001 +++ linux-2.5/include/asm-i386/smp.h Mon Dec 31 21:53:19 2001 @@ -57,6 +57,9 @@ extern unsigned long cpu_online_map; extern volatile unsigned long smp_invalidate_needed; extern int pic_mode; +extern int smp_num_siblings; +extern int cpu_sibling_map[]; + extern void smp_flush_tlb(void); extern void smp_message_irq(int cpl, void *dev_id, struct pt_regs *regs); extern void smp_send_reschedule(int cpu); diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/include/asm-i386/softirq.h linux-2.5/include/asm-i386/softirq.h --- linux-2.5.1/include/asm-i386/softirq.h Sun Dec 16 23:43:25 2001 +++ linux-2.5/include/asm-i386/softirq.h Mon Dec 31 21:53:19 2001 @@ -3,6 +3,7 @@ #include <asm/atomic.h> #include <asm/hardirq.h> +#include <linux/stringify.h> #define __cpu_bh_enable(cpu) \ do { barrier(); local_bh_count(cpu)--; } while (0) @@ -33,12 +34,15 @@ "jnz 2f;" \ "1:;" \ \ - ".section .text.lock,\"ax\";" \ + ".subsection 1;" \ + ".ifndef _text_lock_" __stringify(KBUILD_BASENAME) "\n" \ + "_text_lock_" __stringify(KBUILD_BASENAME) ":\n" \ + ".endif\n" \ "2: pushl %%eax; pushl %%ecx; pushl %%edx;" \ "call %c1;" \ "popl %%edx; popl %%ecx; popl %%eax;" \ "jmp 1b;" \ - ".previous;" \ + ".subsection 0;" \ \ : /* no output */ \ : "r" (ptr), "i" (do_softirq) \ diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/include/asm-i386/spinlock.h linux-2.5/include/asm-i386/spinlock.h --- linux-2.5.1/include/asm-i386/spinlock.h Sun Dec 16 23:43:25 2001 +++ linux-2.5/include/asm-i386/spinlock.h Mon Dec 31 21:53:19 2001 @@ -5,6 +5,7 @@ #include <asm/rwlock.h> #include <asm/page.h> #include <linux/config.h> +#include <linux/stringify.h> extern int printk(const char * fmt, ...) __attribute__ ((format (printf, 1, 2))); @@ -56,13 +57,16 @@ "\n1:\t" \ "lock ; decb %0\n\t" \ "js 2f\n" \ - ".section .text.lock,\"ax\"\n" \ + ".subsection 1\n" \ + ".ifndef _text_lock_" __stringify(KBUILD_BASENAME) "\n" \ + "_text_lock_" __stringify(KBUILD_BASENAME) ":\n" \ + ".endif\n" \ "2:\t" \ "cmpb $0,%0\n\t" \ "rep;nop\n\t" \ "jle 2b\n\t" \ "jmp 1b\n" \ - ".previous" + ".subsection 0\n" /* * This works. Despite all the confusion. diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/include/asm-i386/string.h linux-2.5/include/asm-i386/string.h --- linux-2.5.1/include/asm-i386/string.h Sun Dec 16 23:43:25 2001 +++ linux-2.5/include/asm-i386/string.h Mon Dec 31 21:53:19 2001 @@ -12,7 +12,7 @@ * Also, the byte strings actually work correctly. Forget * the i486 routines for now as they may be broken.. */ -#if FIXED_486_STRING && defined(CONFIG_X86_USE_STRING_486) +#if defined (CONFIG_DEBUG_486_STRING) && defined(CONFIG_X86_USE_STRING_486) #include <asm/string-486.h> #else diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/include/asm-ia64/pal.h linux-2.5/include/asm-ia64/pal.h --- linux-2.5.1/include/asm-ia64/pal.h Fri Nov 9 22:26:17 2001 +++ linux-2.5/include/asm-ia64/pal.h Thu Dec 13 16:32:37 2001 @@ -88,10 +88,10 @@ typedef s64 pal_status_t; #define PAL_STATUS_SUCCESS 0 /* No error */ -#define PAL_STATUS_UNIMPLEMENTED -1 /* Unimplemented procedure */ -#define PAL_STATUS_EINVAL -2 /* Invalid argument */ -#define PAL_STATUS_ERROR -3 /* Error */ -#define PAL_STATUS_CACHE_INIT_FAIL -4 /* Could not initialize the +#define PAL_STATUS_UNIMPLEMENTED (-1) /* Unimplemented procedure */ +#define PAL_STATUS_EINVAL (-2) /* Invalid argument */ +#define PAL_STATUS_ERROR (-3) /* Error */ +#define PAL_STATUS_CACHE_INIT_FAIL (-4) /* Could not initialize the * specified level and type of * cache without sideeffects * and "restrict" was 1 diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/include/asm-ia64/pci.h linux-2.5/include/asm-ia64/pci.h --- linux-2.5.1/include/asm-ia64/pci.h Fri Nov 9 22:26:17 2001 +++ linux-2.5/include/asm-ia64/pci.h Thu Dec 27 16:32:31 2001 @@ -46,6 +46,20 @@ #define pci_dma_sync_sg platform_pci_dma_sync_sg #define sg_dma_address platform_pci_dma_address +/* pci_unmap_{single,page} is not a nop, thus... */ +#define DECLARE_PCI_UNMAP_ADDR(ADDR_NAME) \ + dma_addr_t ADDR_NAME; +#define DECLARE_PCI_UNMAP_LEN(LEN_NAME) \ + __u32 LEN_NAME; +#define PCI_UNMAP_ADDR(PTR, ADDR_NAME) \ + ((PTR)->ADDR_NAME) +#define PCI_UNMAP_ADDR_SET(PTR, ADDR_NAME, VAL) \ + (((PTR)->ADDR_NAME) = (VAL)) +#define PCI_UNMAP_LEN(PTR, LEN_NAME) \ + ((PTR)->LEN_NAME) +#define PCI_UNMAP_LEN_SET(PTR, LEN_NAME, VAL) \ + (((PTR)->LEN_NAME) = (VAL)) + /* * Return whether the given PCI device DMA address mask can be supported properly. For * example, if your device can only drive the low 24-bits during PCI bus mastering, then diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/include/asm-ia64/processor.h linux-2.5/include/asm-ia64/processor.h --- linux-2.5.1/include/asm-ia64/processor.h Fri Nov 9 22:26:17 2001 +++ linux-2.5/include/asm-ia64/processor.h Thu Dec 27 15:14:59 2001 @@ -50,7 +50,6 @@ * Bus types */ #define EISA_bus 0 -#define EISA_bus__is_a_macro /* for versions in ksyms.c */ #define MCA_bus 0 #define MCA_bus__is_a_macro /* for versions in ksyms.c */ diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/include/asm-ia64/siginfo.h linux-2.5/include/asm-ia64/siginfo.h --- linux-2.5.1/include/asm-ia64/siginfo.h Thu Apr 5 19:51:47 2001 +++ linux-2.5/include/asm-ia64/siginfo.h Thu Dec 13 16:32:37 2001 @@ -119,11 +119,11 @@ #define SI_USER 0 /* sent by kill, sigsend, raise */ #define SI_KERNEL 0x80 /* sent by the kernel from somewhere */ -#define SI_QUEUE -1 /* sent by sigqueue */ +#define SI_QUEUE (-1) /* sent by sigqueue */ #define SI_TIMER __SI_CODE(__SI_TIMER,-2) /* sent by timer expiration */ -#define SI_MESGQ -3 /* sent by real time mesq state change */ -#define SI_ASYNCIO -4 /* sent by AIO completion */ -#define SI_SIGIO -5 /* sent by queued SIGIO */ +#define SI_MESGQ (-3) /* sent by real time mesq state change */ +#define SI_ASYNCIO (-4) /* sent by AIO completion */ +#define SI_SIGIO (-5) /* sent by queued SIGIO */ #define SI_FROMUSER(siptr) ((siptr)->si_code <= 0) #define SI_FROMKERNEL(siptr) ((siptr)->si_code > 0) diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/include/asm-ia64/system.h linux-2.5/include/asm-ia64/system.h --- linux-2.5.1/include/asm-ia64/system.h Fri Nov 9 22:26:17 2001 +++ linux-2.5/include/asm-ia64/system.h Thu Dec 13 16:32:37 2001 @@ -405,6 +405,10 @@ ia64_psr(ia64_task_regs(prev))->dfh = 1; \ __switch_to(prev,next,last); \ } while (0) + +/* Return true if this CPU can call the console drivers in printk() */ +#define arch_consoles_callable() (cpu_online_map & (1UL << smp_processor_id())) + #else # define switch_to(prev,next,last) do { \ ia64_psr(ia64_task_regs(next))->dfh = (ia64_get_fpu_owner() != (next)); \ diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/include/asm-m68k/semaphore.h linux-2.5/include/asm-m68k/semaphore.h --- linux-2.5.1/include/asm-m68k/semaphore.h Thu Oct 25 20:53:55 2001 +++ linux-2.5/include/asm-m68k/semaphore.h Sat Dec 29 11:10:40 2001 @@ -9,6 +9,7 @@ #include <linux/wait.h> #include <linux/spinlock.h> #include <linux/rwsem.h> +#include <linux/stringify.h> #include <asm/system.h> #include <asm/atomic.h> @@ -94,11 +95,14 @@ "subql #1,%0@\n\t" "jmi 2f\n\t" "1:\n" - ".section .text.lock,\"ax\"\n" + ".subsection 1\n" ".even\n" + ".ifndef _text_lock_" __stringify(KBUILD_BASENAME) "\n" + "_text_lock_" __stringify(KBUILD_BASENAME) ":\n" + ".endif\n" "2:\tpea 1b\n\t" "jbra __down_failed\n" - ".previous" + ".subsection 0\n" : /* no outputs */ : "a" (sem1) : "memory"); @@ -119,11 +123,14 @@ "jmi 2f\n\t" "clrl %0\n" "1:\n" - ".section .text.lock,\"ax\"\n" + ".subsection 1\n" ".even\n" + ".ifndef _text_lock_" __stringify(KBUILD_BASENAME) "\n" + "_text_lock_" __stringify(KBUILD_BASENAME) ":\n" + ".endif\n" "2:\tpea 1b\n\t" "jbra __down_failed_interruptible\n" - ".previous" + ".subsection 0\n" : "=d" (result) : "a" (sem1) : "memory"); @@ -145,11 +152,14 @@ "jmi 2f\n\t" "clrl %0\n" "1:\n" - ".section .text.lock,\"ax\"\n" + ".subsection 1\n" ".even\n" + ".ifndef _text_lock_" __stringify(KBUILD_BASENAME) "\n" + "_text_lock_" __stringify(KBUILD_BASENAME) ":\n" + ".endif\n" "2:\tpea 1b\n\t" "jbra __down_failed_trylock\n" - ".previous" + ".subsection 0\n" : "=d" (result) : "a" (sem1) : "memory"); @@ -175,12 +185,15 @@ "addql #1,%0@\n\t" "jle 2f\n" "1:\n" - ".section .text.lock,\"ax\"\n" + ".subsection 1\n" ".even\n" + ".ifndef _text_lock_" __stringify(KBUILD_BASENAME) "\n" + "_text_lock_" __stringify(KBUILD_BASENAME) ":\n" + ".endif\n" "2:\t" "pea 1b\n\t" "jbra __up_wakeup\n" - ".previous" + ".subsection 0\n" : /* no outputs */ : "a" (sem1) : "memory"); diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/include/asm-mips/pci.h linux-2.5/include/asm-mips/pci.h --- linux-2.5.1/include/asm-mips/pci.h Fri Oct 12 22:35:54 2001 +++ linux-2.5/include/asm-mips/pci.h Thu Dec 27 16:32:31 2001 @@ -114,6 +114,14 @@ /* Nothing to do */ } +/* pci_unmap_{page,single} is a nop so... */ +#define DECLARE_PCI_UNMAP_ADDR(ADDR_NAME) +#define DECLARE_PCI_UNMAP_LEN(LEN_NAME) +#define PCI_UNMAP_ADDR(PTR, ADDR_NAME) (0) +#define PCI_UNMAP_ADDR_SET(PTR, ADDR_NAME, VAL) do { } while (0) +#define PCI_UNMAP_LEN(PTR, LEN_NAME) (0) +#define PCI_UNMAP_LEN_SET(PTR, LEN_NAME, VAL) do { } while (0) + /* * Map a set of buffers described by scatterlist in streaming * mode for DMA. This is the scather-gather version of the diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/include/asm-mips64/pci.h linux-2.5/include/asm-mips64/pci.h --- linux-2.5.1/include/asm-mips64/pci.h Fri Oct 12 22:35:54 2001 +++ linux-2.5/include/asm-mips64/pci.h Thu Dec 27 16:32:31 2001 @@ -86,6 +86,20 @@ extern void pci_dma_sync_sg(struct pci_dev *hwdev, struct scatterlist *sg, int nelems, int direction); +/* pci_unmap_{single,page} is not a nop, thus... */ +#define DECLARE_PCI_UNMAP_ADDR(ADDR_NAME) \ + dma_addr_t ADDR_NAME; +#define DECLARE_PCI_UNMAP_LEN(LEN_NAME) \ + __u32 LEN_NAME; +#define PCI_UNMAP_ADDR(PTR, ADDR_NAME) \ + ((PTR)->ADDR_NAME) +#define PCI_UNMAP_ADDR_SET(PTR, ADDR_NAME, VAL) \ + (((PTR)->ADDR_NAME) = (VAL)) +#define PCI_UNMAP_LEN(PTR, LEN_NAME) \ + ((PTR)->LEN_NAME) +#define PCI_UNMAP_LEN_SET(PTR, LEN_NAME, VAL) \ + (((PTR)->LEN_NAME) = (VAL)) + #else /* CONFIG_MAPPED_PCI_IO */ /* @@ -123,6 +137,14 @@ /* Nothing to do */ } + +/* pci_unmap_{page,single} is a nop so... */ +#define DECLARE_PCI_UNMAP_ADDR(ADDR_NAME) +#define DECLARE_PCI_UNMAP_LEN(LEN_NAME) +#define PCI_UNMAP_ADDR(PTR, ADDR_NAME) (0) +#define PCI_UNMAP_ADDR_SET(PTR, ADDR_NAME, VAL) do { } while (0) +#define PCI_UNMAP_LEN(PTR, LEN_NAME) (0) +#define PCI_UNMAP_LEN_SET(PTR, LEN_NAME, VAL) do { } while (0) /* * Map a set of buffers described by scatterlist in streaming diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/include/asm-parisc/pci.h linux-2.5/include/asm-parisc/pci.h --- linux-2.5.1/include/asm-parisc/pci.h Fri Oct 12 22:35:54 2001 +++ linux-2.5/include/asm-parisc/pci.h Thu Dec 27 16:32:31 2001 @@ -172,6 +172,20 @@ #define pci_map_sg(p, sg, n, d) hppa_dma_ops->map_sg(p, sg, n, d) #define pci_unmap_sg(p, sg, n, d) hppa_dma_ops->unmap_sg(p, sg, n, d) +/* pci_unmap_{single,page} is not a nop, thus... */ +#define DECLARE_PCI_UNMAP_ADDR(ADDR_NAME) \ + dma_addr_t ADDR_NAME; +#define DECLARE_PCI_UNMAP_LEN(LEN_NAME) \ + __u32 LEN_NAME; +#define PCI_UNMAP_ADDR(PTR, ADDR_NAME) \ + ((PTR)->ADDR_NAME) +#define PCI_UNMAP_ADDR_SET(PTR, ADDR_NAME, VAL) \ + (((PTR)->ADDR_NAME) = (VAL)) +#define PCI_UNMAP_LEN(PTR, LEN_NAME) \ + ((PTR)->LEN_NAME) +#define PCI_UNMAP_LEN_SET(PTR, LEN_NAME, VAL) \ + (((PTR)->LEN_NAME) = (VAL)) + /* For U2/Astro/Ike based platforms (which are fully I/O coherent) ** dma_sync is a NOP. Let's keep the performance path short here. */ diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/include/asm-parisc/processor.h linux-2.5/include/asm-parisc/processor.h --- linux-2.5.1/include/asm-parisc/processor.h Fri Oct 5 19:11:05 2001 +++ linux-2.5/include/asm-parisc/processor.h Thu Dec 27 15:15:00 2001 @@ -90,7 +90,6 @@ extern void identify_cpu(struct cpuinfo_parisc *); #define EISA_bus 0 /* we don't have ISA support yet */ -#define EISA_bus__is_a_macro /* for versions in ksyms.c */ #define MCA_bus 0 #define MCA_bus__is_a_macro /* for versions in ksyms.c */ diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/include/asm-parisc/semaphore.h linux-2.5/include/asm-parisc/semaphore.h --- linux-2.5.1/include/asm-parisc/semaphore.h Wed Apr 18 00:19:31 2001 +++ linux-2.5/include/asm-parisc/semaphore.h Sat Dec 29 11:10:40 2001 @@ -12,10 +12,6 @@ * */ -/* if you're going to use out-of-line slowpaths, use .section .lock.text, - * not .text.lock or the -ffunction-sections monster will eat you alive - */ - #include <linux/spinlock.h> #include <linux/rwsem.h> diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/include/asm-parisc/spinlock.h linux-2.5/include/asm-parisc/spinlock.h --- linux-2.5.1/include/asm-parisc/spinlock.h Tue Dec 5 20:29:39 2000 +++ linux-2.5/include/asm-parisc/spinlock.h Sat Dec 29 11:10:40 2001 @@ -3,10 +3,6 @@ #include <asm/system.h> -/* if you're going to use out-of-line slowpaths, use .section .lock.text, - * not .text.lock or the -ffunction-sections monster will eat you alive - */ - /* we seem to be the only architecture that uses 0 to mean locked - but we * have to. prumpf */ diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/include/asm-ppc/ans-lcd.h linux-2.5/include/asm-ppc/ans-lcd.h --- linux-2.5.1/include/asm-ppc/ans-lcd.h Thu Jan 1 00:00:00 1970 +++ linux-2.5/include/asm-ppc/ans-lcd.h Thu Dec 27 16:32:31 2001 @@ -0,0 +1,11 @@ +#ifndef _PPC_ANS_LCD_H +#define _PPC_ANS_LCD_H + +#define ANSLCD_MINOR 156 + +#define ANSLCD_CLEAR 0x01 +#define ANSLCD_SENDCTRL 0x02 +#define ANSLCD_SETSHORTDELAY 0x03 +#define ANSLCD_SETLONGDELAY 0x04 + +#endif diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/include/asm-ppc/dbdma.h linux-2.5/include/asm-ppc/dbdma.h --- linux-2.5.1/include/asm-ppc/dbdma.h Mon May 21 22:02:06 2001 +++ linux-2.5/include/asm-ppc/dbdma.h Thu Dec 27 16:32:31 2001 @@ -1,5 +1,5 @@ /* - * BK Id: SCCS/s.dbdma.h 1.5 05/17/01 18:14:24 cort + * BK Id: SCCS/s.dbdma.h 1.8 12/01/01 20:09:11 benh */ /* * Definitions for using the Apple Descriptor-Based DMA controller @@ -93,5 +93,13 @@ /* Align an address for a DBDMA command structure */ #define DBDMA_ALIGN(x) (((unsigned)(x) + sizeof(struct dbdma_cmd) - 1) \ & -sizeof(struct dbdma_cmd)) + +/* Useful macros */ +#define DBDMA_DO_STOP(regs) do { \ + out_le32(&((regs)->control), (RUN|FLUSH)<<16); \ + while(in_le32(&((regs)->status)) & (ACTIVE|FLUSH)) \ + ; \ +} while(0) + #endif /* _ASM_DBDMA_H_ */ #endif /* __KERNEL__ */ diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/include/asm-ppc/heathrow.h linux-2.5/include/asm-ppc/heathrow.h --- linux-2.5.1/include/asm-ppc/heathrow.h Mon May 21 22:02:06 2001 +++ linux-2.5/include/asm-ppc/heathrow.h Thu Dec 27 16:32:31 2001 @@ -1,5 +1,5 @@ /* - * BK Id: SCCS/s.heathrow.h 1.7 05/17/01 18:14:24 cort + * BK Id: SCCS/s.heathrow.h 1.10 12/01/01 20:09:11 benh */ /* * heathrow.h: definitions for using the "Heathrow" I/O controller chip. @@ -17,7 +17,9 @@ #define HEATHROW_CONTRAST_CNTL 0x33 /* offset from ohare base for feature control register */ -#define HEATHROW_FEATURE_REG 0x38 +#define HEATHROW_MBCR 0x34 /* Media bay control */ +#define HEATHROW_FCR 0x38 /* Feature control */ +#define HEATHROW_AUX_CNTL_REG 0x3c /* Aux control */ /* * Bits in feature control register. @@ -30,6 +32,7 @@ #define HRW_BAY_FLOPPY_ENABLE 0x00000010 #define HRW_IDE0_ENABLE 0x00000020 #define HRW_IDE0_RESET_N 0x00000040 +#define HRW_BAY_DEV_MASK 0x0000001c #define HRW_BAY_RESET_N 0x00000080 #define HRW_IOBUS_ENABLE 0x00000100 /* Internal IDE ? */ #define HRW_SCC_ENABLE 0x00000200 @@ -45,7 +48,7 @@ #define HRW_SWIM_CLONE_FLOPPY 0x00080000 /* ??? (0) */ #define HRW_AUD_RUN22 0x00100000 /* ??? (1) */ #define HRW_SCSI_LINK_MODE 0x00200000 /* Read ??? (1) */ -#define HRW_ARB_BYPASS 0x00400000 /* ??? (0 on main, 1 on gatwick) */ +#define HRW_ARB_BYPASS 0x00400000 /* Disable internal PCI arbitrer */ #define HRW_IDE1_RESET_N 0x00800000 /* Media bay */ #define HRW_SLOW_SCC_PCLK 0x01000000 /* ??? (0) */ #define HRW_MODEM_POWER_N 0x02000000 /* Used by internal modem on wallstreet */ @@ -60,3 +63,7 @@ /* Those seem to be different on paddington */ #define PADD_MODEM_POWER_N 0x00000001 /* modem power on paddington */ #define PADD_RESET_SCC 0x02000000 /* check this please */ + +/* Looks like Heathrow has some sort of GPIOs as well... */ +#define HRW_GPIO_MODEM_RESET 0x6d + diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/include/asm-ppc/keylargo.h linux-2.5/include/asm-ppc/keylargo.h --- linux-2.5.1/include/asm-ppc/keylargo.h Tue Aug 28 13:58:33 2001 +++ linux-2.5/include/asm-ppc/keylargo.h Thu Dec 27 16:32:31 2001 @@ -1,5 +1,5 @@ /* - * BK Id: SCCS/s.keylargo.h 1.13 08/19/01 22:23:04 paulus + * BK Id: SCCS/s.keylargo.h 1.15 12/01/01 20:09:11 benh */ /* * keylargo.h: definitions for using the "KeyLargo" I/O controller chip. @@ -29,12 +29,15 @@ #define KEYLARGO_GPIO_CNT 17 #define KEYLARGO_GPIO_OUTPUT_ENABLE 0x04 #define KEYLARGO_GPIO_OUTOUT_DATA 0x01 +#define KEYLARGO_GPIO_INPUT_DATA 0x02 /* Specific GPIO regs */ -#define KL_GPIO_MODEM_RESET (KEYLARGO_GPIO_0+0x03) /* Pangea */ +#define KL_GPIO_MODEM_RESET (KEYLARGO_GPIO_0+0x03) #define KL_GPIO_MODEM_POWER (KEYLARGO_GPIO_0+0x02) /* Pangea */ +#define KL_GPIO_SOUND_POWER (KEYLARGO_GPIO_0+0x05) + /* Hrm... this one is only to be used on Pismo. It seeem to also * control the timebase enable on other machines. Still to be * experimented... --BenH. @@ -54,7 +57,9 @@ #define KL_GPIO_RESET_CPU3 (KEYLARGO_GPIO_EXTINT_0+0x10) #define KL_GPIO_PMU_MESSAGE_IRQ (KEYLARGO_GPIO_EXTINT_0+0x09) -#define KL_GPIO_PMU_MESSAGE_BIT 0x02 +#define KL_GPIO_PMU_MESSAGE_BIT KEYLARGO_GPIO_INPUT_DATA + +#define KL_GPIO_MEDIABAY_IRQ (KEYLARGO_GPIO_EXTINT_0+0x0e) #define KL_GPIO_AIRPORT_0 (KEYLARGO_GPIO_EXTINT_0+0x0a) #define KL_GPIO_AIRPORT_1 (KEYLARGO_GPIO_EXTINT_0+0x0d) @@ -65,11 +70,19 @@ /* * Bits in feature control register */ -#define KL_MBCR_MB0_DEV_ENABLE 0x00001000 +#define KL_MBCR_MB0_PCI_ENABLE 0x00000800 /* exist ? */ +#define KL_MBCR_MB0_IDE_ENABLE 0x00001000 +#define KL_MBCR_MB0_FLOPPY_ENABLE 0x00002000 /* exist ? */ +#define KL_MBCR_MB0_SOUND_ENABLE 0x00004000 /* hrm... */ +#define KL_MBCR_MB0_DEV_MASK 0x00007800 #define KL_MBCR_MB0_DEV_POWER 0x00000400 #define KL_MBCR_MB0_DEV_RESET 0x00000200 #define KL_MBCR_MB0_ENABLE 0x00000100 -#define KL_MBCR_MB1_DEV_ENABLE 0x10000000 +#define KL_MBCR_MB1_PCI_ENABLE 0x08000000 /* exist ? */ +#define KL_MBCR_MB1_IDE_ENABLE 0x10000000 +#define KL_MBCR_MB1_FLOPPY_ENABLE 0x20000000 /* exist ? */ +#define KL_MBCR_MB1_SOUND_ENABLE 0x40000000 /* hrm... */ +#define KL_MBCR_MB1_DEV_MASK 0x78000000 #define KL_MBCR_MB1_DEV_POWER 0x04000000 #define KL_MBCR_MB1_DEV_RESET 0x02000000 #define KL_MBCR_MB1_ENABLE 0x01000000 @@ -81,27 +94,23 @@ #define KL0_SCCA_ENABLE 0x00000010 #define KL0_SCCB_ENABLE 0x00000020 #define KL0_SCC_CELL_ENABLE 0x00000040 +#define KL0_IRDA_HIGH_BAND 0x00000100 +#define KL0_IRDA_SOURCE2_SEL 0x00000200 +#define KL0_IRDA_SOURCE1_SEL 0x00000400 +#define KL0_IRDA_RESET 0x00000800 +#define KL0_IRDA_DEFAULT1 0x00001000 +#define KL0_IRDA_DEFAULT0 0x00002000 +#define KL0_IRDA_FAST_CONNECT 0x00004000 +#define KL0_IRDA_ENABLE 0x00008000 +#define KL0_IRDA_CLK32_ENABLE 0x00010000 +#define KL0_IRDA_CLK19_ENABLE 0x00020000 #define KL0_USB0_PAD_SUSPEND0 0x00040000 #define KL0_USB0_PAD_SUSPEND1 0x00080000 #define KL0_USB0_CELL_ENABLE 0x00100000 #define KL0_USB1_PAD_SUSPEND0 0x00400000 #define KL0_USB1_PAD_SUSPEND1 0x00800000 #define KL0_USB1_CELL_ENABLE 0x01000000 -/* KL id 0x22 only */ #define KL0_USB_REF_SUSPEND 0x10000000 -#define KL0_IRDA_ENABLE 0x00008000 -#define KL0_IRDA_CLK32_ENABLE 0x00010000 -#define KL0_IRDA_CLK19_ENABLE 0x00020000 -/* KL id 0x25 (pangea) only */ -#define KL0_USB1_PAD_SUSPEND_SEL 0x00020000 -#define KL0_USB1_REF_SUSPEND 0x00010000 -#define KL0_USB1_REF_SUSPEND_SEL 0x00008000 -#define KL0_USB1_PMI 0x00004000 -#define KL0_USB0_PAD_SUSPEND_SEL 0x00002000 -#define KL0_USB0_REF_SUSPEND 0x00001000 -#define KL0_USB0_REF_SUSPEND_SEL 0x00000800 -#define KL0_USB0_PMI 0x00000400 - #define KL0_SERIAL_ENABLE (KL0_SCC_B_INTF_ENABLE | \ KL0_SCC_SLOWPCLK | \ diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/include/asm-ppc/machdep.h linux-2.5/include/asm-ppc/machdep.h --- linux-2.5.1/include/asm-ppc/machdep.h Fri Nov 16 18:10:08 2001 +++ linux-2.5/include/asm-ppc/machdep.h Thu Dec 27 16:32:31 2001 @@ -1,5 +1,5 @@ /* - * BK Id: SCCS/s.machdep.h 1.25 11/13/01 21:26:07 paulus + * BK Id: SCCS/s.machdep.h 1.27 12/01/01 20:09:11 benh */ #ifdef __KERNEL__ #ifndef _PPC_MACHDEP_H @@ -16,6 +16,11 @@ struct pci_dev; struct seq_file; +/* We export this macro for external modules like Alsa to know if + * ppc_md.feature_call is implemented or not + */ +#define CONFIG_PPC_HAS_FEATURE_CALLS + struct machdep_calls { void (*setup_arch)(void); /* Optional, may be NULL. */ @@ -94,6 +99,12 @@ /* this is for modules, since _machine can be a define -- Cort */ int ppc_machine; + + /* Motherboard/chipset features. This is a kind of general purpose + * hook used to control some machine specific features (like reset + * lines, chip power control, etc...). + */ + int (*feature_call)(unsigned int feature, ...); #ifdef CONFIG_SMP /* functions for dealing with other cpus */ diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/include/asm-ppc/mediabay.h linux-2.5/include/asm-ppc/mediabay.h --- linux-2.5.1/include/asm-ppc/mediabay.h Mon May 21 22:02:06 2001 +++ linux-2.5/include/asm-ppc/mediabay.h Thu Dec 27 16:32:31 2001 @@ -1,5 +1,5 @@ /* - * BK Id: SCCS/s.mediabay.h 1.5 05/17/01 18:14:25 cort + * BK Id: SCCS/s.mediabay.h 1.8 12/01/01 20:09:11 benh */ /* * mediabay.h: definitions for using the media bay @@ -12,10 +12,13 @@ #ifdef __KERNEL__ -#define MB_FD 0 /* media bay contains floppy drive */ -#define MB_FD1 1 /* media bay contains floppy drive */ -#define MB_CD 3 /* media bay contains ATA drive such as CD */ -#define MB_NO 7 /* media bay contains nothing */ +#define MB_FD 0 /* media bay contains floppy drive (automatic eject ?) */ +#define MB_FD1 1 /* media bay contains floppy drive (manual eject ?) */ +#define MB_SOUND 2 /* sound device ? */ +#define MB_CD 3 /* media bay contains ATA drive such as CD or ZIP */ +#define MB_PCI 5 /* media bay contains a PCI device */ +#define MB_POWER 6 /* media bay contains a Power device (???) */ +#define MB_NO 7 /* media bay contains nothing */ void media_bay_init(void); int check_media_bay(struct device_node *which_bay, int what); diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/include/asm-ppc/ohare.h linux-2.5/include/asm-ppc/ohare.h --- linux-2.5.1/include/asm-ppc/ohare.h Mon May 21 22:02:06 2001 +++ linux-2.5/include/asm-ppc/ohare.h Thu Dec 27 16:32:31 2001 @@ -1,5 +1,5 @@ /* - * BK Id: SCCS/s.ohare.h 1.5 05/17/01 18:14:25 cort + * BK Id: SCCS/s.ohare.h 1.8 12/01/01 20:09:11 benh */ /* * ohare.h: definitions for using the "O'Hare" I/O controller chip. @@ -11,7 +11,8 @@ */ /* offset from ohare base for feature control register */ -#define OHARE_FEATURE_REG 0x38 +#define OHARE_MBCR 0x34 +#define OHARE_FCR 0x38 /* * Bits in feature control register. @@ -25,6 +26,7 @@ #define OH_BAY_FLOPPY_ENABLE 0x10 #define OH_IDE0_ENABLE 0x20 #define OH_IDE0_RESET_N 0x40 /* a guess */ +#define OH_BAY_DEV_MASK 0x1c #define OH_BAY_RESET_N 0x80 #define OH_IOBUS_ENABLE 0x100 /* IOBUS seems to be IDE */ #define OH_SCC_ENABLE 0x200 diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/include/asm-ppc/pci.h linux-2.5/include/asm-ppc/pci.h --- linux-2.5.1/include/asm-ppc/pci.h Sun Oct 21 17:13:07 2001 +++ linux-2.5/include/asm-ppc/pci.h Thu Dec 27 16:32:31 2001 @@ -102,6 +102,13 @@ /* nothing to do */ } +/* pci_unmap_{page,single} is a nop so... */ +#define DECLARE_PCI_UNMAP_ADDR(ADDR_NAME) +#define DECLARE_PCI_UNMAP_LEN(LEN_NAME) +#define PCI_UNMAP_ADDR(PTR, ADDR_NAME) (0) +#define PCI_UNMAP_ADDR_SET(PTR, ADDR_NAME, VAL) do { } while (0) +#define PCI_UNMAP_LEN(PTR, LEN_NAME) (0) +#define PCI_UNMAP_LEN_SET(PTR, LEN_NAME, VAL) do { } while (0) /* * pci_{map,unmap}_single_page maps a kernel page to a dma_addr_t. identical diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/include/asm-ppc/pmac_feature.h linux-2.5/include/asm-ppc/pmac_feature.h --- linux-2.5.1/include/asm-ppc/pmac_feature.h Thu Jan 1 00:00:00 1970 +++ linux-2.5/include/asm-ppc/pmac_feature.h Thu Dec 27 16:32:31 2001 @@ -0,0 +1,251 @@ +/* + * Definition of platform feature hooks for PowerMacs + * + * 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) 1998 Paul Mackerras & + * Ben. Herrenschmidt. + * + * + * Note: I removed media-bay details from the feature stuff, I beleive it's + * not worth it, the media-bay driver can directly use the mac-io + * ASIC registers. + * + * Implementation note: Currently, none of these functions will block. + * However, they may internally protect themselves with a spinlock + * for way too long. Be prepared for at least some of these to block + * in the future. + * + * Unless specifically defined, the result code is assumed to be an + * error when negative, 0 is the default success result. Some functions + * may return additional positive result values. + * + * To keep implementation simple, all feature calls are assumed to have + * the prototype parameters (struct device_node* node, int value). + * When either is not used, pass 0. + */ + +#ifdef __KERNEL__ +#ifndef __PPC_ASM_PMAC_FEATURE_H +#define __PPC_ASM_PMAC_FEATURE_H + +/* + * Known Mac motherboard models + * + * Please, report any error here to benh@kernel.crashing.org, thanks ! + */ + +/* PowerSurge are the first generation of PCI Pmacs. This include + * all of the Grand-Central based machines + */ +#define PMAC_TYPE_PSURGE 0x10 /* PowerSurge */ + +/* Here is the infamous serie of OHare based machines + */ +#define PMAC_TYPE_COMET 0x20 /* Beleived to be PowerBook 2400 */ +#define PMAC_TYPE_HOOPER 0x21 /* Beleived to be PowerBook 3400 */ +#define PMAC_TYPE_KANGA 0x22 /* PowerBook 3500 (first G3) */ +#define PMAC_TYPE_ALCHEMY 0x23 /* Alchemy motherboard base */ +#define PMAC_TYPE_GAZELLE 0x24 /* Spartacus, some 5xxx/6xxx */ +#define PMAC_TYPE_UNKNOWN_OHARE 0x2f /* Unknown, but OHare based */ + +/* Here are the Heathrow based machines + * FIXME: Differenciate wallstreet,mainstreet,wallstreetII + */ +#define PMAC_TYPE_GOSSAMER 0x30 /* Gossamer motherboard */ +#define PMAC_TYPE_SILK 0x31 /* Desktop PowerMac G3 */ +#define PMAC_TYPE_WALLSTREET 0x32 /* Wallstreet/Mainstreet PowerBook*/ +#define PMAC_TYPE_UNKNOWN_HEATHROW 0x3f /* Unknown but heathrow based */ + +/* Here are newworld machines based on Paddington (heathrow derivative) + */ +#define PMAC_TYPE_101_PBOOK 0x40 /* 101 PowerBook (aka Lombard) */ +#define PMAC_TYPE_ORIG_IMAC 0x41 /* First generation iMac */ +#define PMAC_TYPE_YOSEMITE 0x42 /* B&W G3 */ +#define PMAC_TYPE_YIKES 0x43 /* Yikes G4 (PCI graphics) */ +#define PMAC_TYPE_UNKNOWN_PADDINGTON 0x4f /* Unknown but paddington based */ + +/* Core99 machines based on UniNorth 1.0 and 1.5 + * + * Note: A single entry here may cover several actual models according + * to the device-tree. (Sawtooth is most tower G4s, FW_IMAC is most + * FireWire based iMacs, etc...). Those machines are too similar to be + * distinguished here, when they need to be differencied, use the + * device-tree "model" or "compatible" property. + */ +#define PMAC_TYPE_ORIG_IBOOK 0x40 /* First iBook model (no firewire) */ +#define PMAC_TYPE_SAWTOOTH 0x41 /* Desktop G4s */ +#define PMAC_TYPE_FW_IMAC 0x42 /* FireWire iMacs (except Pangea based) */ +#define PMAC_TYPE_FW_IBOOK 0x43 /* FireWire iBooks (except iBook2) */ +#define PMAC_TYPE_CUBE 0x44 /* Cube PowerMac */ +#define PMAC_TYPE_QUICKSILVER 0x45 /* QuickSilver G4s */ +#define PMAC_TYPE_PISMO 0x46 /* Pismo PowerBook */ +#define PMAC_TYPE_TITANIUM 0x47 /* Titanium PowerBook */ +#define PMAC_TYPE_TITANIUM2 0x48 /* Titanium II PowerBook */ +#define PMAC_TYPE_UNKNOWN_CORE99 0x5f + +/* MacRISC2 machines based on the Pangea chipset + */ +#define PMAC_TYPE_PANGEA_IMAC 0x100 /* Flower Power iMac */ +#define PMAC_TYPE_IBOOK2 0x101 /* iBook2 (polycarbonate) */ +#define PMAC_TYPE_UNKNOWN_PANGEA 0x10f + +/* + * Motherboard flags + */ + +#define PMAC_MB_CAN_SLEEP 0x00000001 + +/* + * Feature calls supported on pmac + * + */ + +/* + * Use this inline wrapper + */ +struct device_node; + +static inline int pmac_call_feature(int selector, struct device_node* node, + int param, int value) +{ + if (!ppc_md.feature_call) + return -ENODEV; + return ppc_md.feature_call(selector, node, param, value); +} + +/* PMAC_FTR_SERIAL_ENABLE (struct device_node* node, int param, int value) + * enable/disable an SCC side. Pass the node corresponding to the + * channel side as a parameter. + * param is the type of port + * if param is ored with PMAC_SCC_FLAG_XMON, then the SCC is locked enabled + * for use by xmon. + */ +#define PMAC_FTR_SCC_ENABLE PMAC_FTR_DEF(0) + #define PMAC_SCC_ASYNC 0 + #define PMAC_SCC_IRDA 1 + #define PMAC_SCC_I2S1 2 + #define PMAC_SCC_FLAG_XMON 0x00001000 + +/* PMAC_FTR_MODEM_ENABLE (struct device_node* node, 0, int value) + * enable/disable the internal modem. + */ +#define PMAC_FTR_MODEM_ENABLE PMAC_FTR_DEF(1) + +/* PMAC_FTR_SWIM3_ENABLE (struct device_node* node, 0,int value) + * enable/disable the swim3 (floppy) cell of a mac-io ASIC + */ +#define PMAC_FTR_SWIM3_ENABLE PMAC_FTR_DEF(2) + +/* PMAC_FTR_MESH_ENABLE (struct device_node* node, 0, int value) + * enable/disable the mesh (scsi) cell of a mac-io ASIC + */ +#define PMAC_FTR_MESH_ENABLE PMAC_FTR_DEF(3) + +/* PMAC_FTR_IDE_ENABLE (struct device_node* node, int busID, int value) + * enable/disable an IDE port of a mac-io ASIC + * pass the busID parameter + */ +#define PMAC_FTR_IDE_ENABLE PMAC_FTR_DEF(4) + +/* PMAC_FTR_IDE_RESET (struct device_node* node, int busID, int value) + * assert(1)/release(0) an IDE reset line (mac-io IDE only) + */ +#define PMAC_FTR_IDE_RESET PMAC_FTR_DEF(5) + +/* PMAC_FTR_BMAC_ENABLE (struct device_node* node, 0, int value) + * enable/disable the bmac (ethernet) cell of a mac-io ASIC, also drive + * it's reset line + */ +#define PMAC_FTR_BMAC_ENABLE PMAC_FTR_DEF(6) + +/* PMAC_FTR_GMAC_ENABLE (struct device_node* node, 0, int value) + * enable/disable the gmac (ethernet) cell of an uninorth ASIC. This + * control the cell's clock. + */ +#define PMAC_FTR_GMAC_ENABLE PMAC_FTR_DEF(7) + +/* PMAC_FTR_GMAC_PHY_RESET (struct device_node* node, 0, 0) + * Perform a HW reset of the PHY connected to a gmac controller. + * Pass the gmac device node, not the PHY node. + */ +#define PMAC_FTR_GMAC_PHY_RESET PMAC_FTR_DEF(8) + +/* PMAC_FTR_SOUND_CHIP_ENABLE (struct device_node* node, 0, int value) + * enable/disable the sound chip, whatever it is and provided it can + * acually be controlled + */ +#define PMAC_FTR_SOUND_CHIP_ENABLE PMAC_FTR_DEF(9) + +/* -- add various tweaks related to sound routing -- */ + +/* PMAC_FTR_AIRPORT_ENABLE (struct device_node* node, 0, int value) + * enable/disable the airport card + */ +#define PMAC_FTR_AIRPORT_ENABLE PMAC_FTR_DEF(10) + +/* PMAC_FTR_RESET_CPU (NULL, int cpu_nr, 0) + * toggle the reset line of a CPU on an uninorth-based SMP machine + */ +#define PMAC_FTR_RESET_CPU PMAC_FTR_DEF(11) + +/* PMAC_FTR_USB_ENABLE (struct device_node* node, 0, int value) + * enable/disable an USB cell, along with the power of the USB "pad" + * on keylargo based machines + */ +#define PMAC_FTR_USB_ENABLE PMAC_FTR_DEF(12) + +/* PMAC_FTR_1394_ENABLE (struct device_node* node, 0, int value) + * enable/disable the firewire cell of an uninorth ASIC. + */ +#define PMAC_FTR_1394_ENABLE PMAC_FTR_DEF(13) + +/* PMAC_FTR_1394_CABLE_POWER (struct device_node* node, 0, int value) + * enable/disable the firewire cable power supply of the uninorth + * firewire cell + */ +#define PMAC_FTR_1394_CABLE_POWER PMAC_FTR_DEF(14) + +/* PMAC_FTR_SLEEP_STATE (struct device_node* node, 0, int value) + * set the sleep state of the motherboard. + * Pass -1 as value to query for sleep capability + */ +#define PMAC_FTR_SLEEP_STATE PMAC_FTR_DEF(15) + +/* PMAC_FTR_GET_MB_INFO (NULL, selector, 0) + * + * returns some motherboard infos. + * selector: 0 - model id + * 1 - model flags (capabilities) + * 2 - model name (cast to const char *) + */ +#define PMAC_FTR_GET_MB_INFO PMAC_FTR_DEF(16) +#define PMAC_MB_INFO_MODEL 0 +#define PMAC_MB_INFO_FLAGS 1 +#define PMAC_MB_INFO_NAME 2 + +/* PMAC_FTR_READ_GPIO (NULL, int index, 0) + * + * read a GPIO from a mac-io controller of type KeyLargo or Pangea. + * the value returned is a byte (positive), or a negative error code + */ +#define PMAC_FTR_READ_GPIO PMAC_FTR_DEF(17) + +/* PMAC_FTR_WRITE_GPIO (NULL, int index, int value) + * + * write a GPIO of a mac-io controller of type KeyLargo or Pangea. + */ +#define PMAC_FTR_WRITE_GPIO PMAC_FTR_DEF(18) + + +/* Don't use those directly, they are for the sake of pmac_setup.c */ +extern int pmac_do_feature_call(unsigned int selector, ...); +extern void pmac_feature_init(void); +extern void pmac_feature_late_init(void); + +#define PMAC_FTR_DEF(x) ((_MACH_Pmac << 16) | (x)) + +#endif /* __PPC_ASM_PMAC_FEATURE_H */ +#endif /* __KERNEL__ */ diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/include/asm-ppc/processor.h linux-2.5/include/asm-ppc/processor.h --- linux-2.5.1/include/asm-ppc/processor.h Fri Oct 5 19:11:05 2001 +++ linux-2.5/include/asm-ppc/processor.h Thu Dec 27 16:32:31 2001 @@ -1,5 +1,5 @@ /* - * BK Id: SCCS/s.processor.h 1.31 10/05/01 16:26:22 paulus + * BK Id: SCCS/s.processor.h 1.33 12/01/01 20:09:11 benh */ #ifdef __KERNEL__ #ifndef __ASM_PPC_PROCESSOR_H @@ -209,8 +209,11 @@ #define HID0_DFCA (1<<6) /* Data Cache Flush Assist */ #define HID0_BTIC (1<<5) /* Branch Target Instruction Cache Enable */ #define HID0_ABE (1<<3) /* Address Broadcast Enable */ +#define HID0_FOLD (1<<3) /* Branch Folding enable - 7450 */ #define HID0_BHTE (1<<2) /* Branch History Table Enable */ #define HID0_BTCD (1<<1) /* Branch target cache disable */ +#define HID0_NOPDST (1<<1) /* No-op dst, dstt, etc. instr. */ +#define HID0_NOPTI (1<<0) /* No-op dcbt and dcbst instr. */ #define SPRN_HID1 0x3F1 /* Hardware Implementation Register 1 */ #define SPRN_IABR 0x3F2 /* Instruction Address Breakpoint Register */ #define SPRN_IAC1 0x3F4 /* Instruction Address Compare 1 */ @@ -261,6 +264,14 @@ #define L2CR_L2DF 0x00004000 /* L2 differential clock */ #define L2CR_L2BYP 0x00002000 /* L2 DLL bypass */ #define L2CR_L2IP 0x00000001 /* L2 GI in progress */ +#define SPRN_L2CR2 0x3f8 +#define SPRN_L3CR 0x3FA /* Level 3 Cache Control Regsiter (7450) */ +#define L3CR_L3E 0x80000000 /* L3 enable */ +#define SPRN_MSSCR0 0x3f6 /* Memory Subsystem Control Register 0 */ +#define SPRN_MSSSR0 0x3f7 /* Memory Subsystem Status Register 1 */ +#define SPRN_ICTRL 0x3f3 /* Instruction Cache & Interrupt control reg */ +#define SPRN_LDSTCR 0x3f8 /* Load/Store control register */ +#define SPRN_LDSTDB 0x3f4 /* */ #define SPRN_LR 0x008 /* Link Register */ #define SPRN_MMCR0 0x3B8 /* Monitor Mode Control Register 0 */ #define SPRN_MMCR1 0x3BC /* Monitor Mode Control Register 1 */ @@ -566,7 +577,6 @@ * Bus types */ #define EISA_bus 0 -#define EISA_bus__is_a_macro /* for versions in ksyms.c */ #define MCA_bus 0 #define MCA_bus__is_a_macro /* for versions in ksyms.c */ diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/include/asm-ppc/prom.h linux-2.5/include/asm-ppc/prom.h --- linux-2.5.1/include/asm-ppc/prom.h Tue Aug 28 13:58:33 2001 +++ linux-2.5/include/asm-ppc/prom.h Thu Dec 27 16:32:31 2001 @@ -1,5 +1,5 @@ /* - * BK Id: SCCS/s.prom.h 1.19 08/17/01 15:23:17 paulus + * BK Id: SCCS/s.prom.h 1.21 12/01/01 20:09:11 benh */ /* * Definitions for talking to the Open Firmware PROM on @@ -85,6 +85,10 @@ extern void prom_get_irq_senses(unsigned char *, int, int); extern int prom_n_addr_cells(struct device_node* np); extern int prom_n_size_cells(struct device_node* np); + +extern struct resource* +request_OF_resource(struct device_node* node, int index, const char* name_postfix); +extern int release_OF_resource(struct device_node* node, int index); extern void print_properties(struct device_node *node); extern int call_rtas(const char *service, int nargs, int nret, diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/include/asm-s390/idals.h linux-2.5/include/asm-s390/idals.h --- linux-2.5.1/include/asm-s390/idals.h Wed Jul 25 21:12:02 2001 +++ linux-2.5/include/asm-s390/idals.h Thu Dec 27 16:32:31 2001 @@ -10,7 +10,7 @@ #include <linux/config.h> #include <asm/irq.h> -#define IDA_SIZE_LOG 12 /* 11 for 2k , 12 for 4k */ +#define IDA_SIZE_LOG 11 /* 11 for 2k , 12 for 4k */ #define IDA_BLOCK_SIZE (1L<<IDA_SIZE_LOG) static inline addr_t * diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/include/asm-s390/lowcore.h linux-2.5/include/asm-s390/lowcore.h --- linux-2.5.1/include/asm-s390/lowcore.h Thu Oct 11 16:43:38 2001 +++ linux-2.5/include/asm-s390/lowcore.h Thu Dec 27 16:32:31 2001 @@ -45,6 +45,9 @@ #define __LC_CPUID 0xC60 #define __LC_CPUADDR 0xC68 #define __LC_IPLDEV 0xC7C + +#define __LC_JIFFY_TIMER 0xC80 + #define __LC_PANIC_MAGIC 0xE00 #define __LC_PFAULT_INTPARM 0x080 @@ -161,7 +164,7 @@ /* entry.S sensitive area end */ /* SMP info area: defined by DJB */ - __u64 jiffy_timer_cc; /* 0xc80 */ + __u64 jiffy_timer; /* 0xc80 */ atomic_t ext_call_fast; /* 0xc88 */ __u8 pad11[0xe00-0xc8c]; /* 0xc8c */ diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/include/asm-s390/processor.h linux-2.5/include/asm-s390/processor.h --- linux-2.5.1/include/asm-s390/processor.h Fri Oct 5 19:11:05 2001 +++ linux-2.5/include/asm-s390/processor.h Thu Dec 27 16:32:31 2001 @@ -74,8 +74,6 @@ struct thread_struct { - - struct pt_regs *regs; /* the user registers can be found on*/ s390_fp_regs fp_regs; __u32 ar2; /* kernel access register 2 */ __u32 ar4; /* kernel access register 4 */ @@ -95,8 +93,7 @@ typedef struct thread_struct thread_struct; -#define INIT_THREAD { (struct pt_regs *) 0, \ - { 0,{{0},{0},{0},{0},{0},{0},{0},{0},{0},{0}, \ +#define INIT_THREAD {{0,{{0},{0},{0},{0},{0},{0},{0},{0},{0},{0}, \ {0},{0},{0},{0},{0},{0}}}, \ 0, 0, \ sizeof(init_stack) + (__u32) &init_stack, \ @@ -126,16 +123,25 @@ #define release_segments(mm) do { } while (0) /* - * Return saved PC of a blocked thread. used in kernel/sched + * Return saved PC of a blocked thread. used in kernel/sched. + * resume in entry.S does not create a new stack frame, it + * just stores the registers %r6-%r15 to the frame given by + * schedule. We want to return the address of the caller of + * schedule, so we have to walk the backchain one time to + * find the frame schedule() store its return address. */ extern inline unsigned long thread_saved_pc(struct thread_struct *t) { - return (t->regs) ? ((unsigned long)t->regs->psw.addr) : 0; + unsigned long bc; + bc = *((unsigned long *) t->ksp); + return *((unsigned long *) (bc+56)); } unsigned long get_wchan(struct task_struct *p); -#define KSTK_EIP(tsk) ((tsk)->thread.regs->psw.addr) -#define KSTK_ESP(tsk) ((tsk)->thread.ksp) +#define __KSTK_PTREGS(tsk) \ + ((struct pt_regs *)((unsigned long) tsk+THREAD_SIZE) - 1) +#define KSTK_EIP(tsk) (__KSTK_PTREGS(tsk)->psw.addr) +#define KSTK_ESP(tsk) (__KSTK_PTREGS(tsk)->gprs[15]) /* Allocation and freeing of basic task resources. */ /* diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/include/asm-s390/ptrace.h linux-2.5/include/asm-s390/ptrace.h --- linux-2.5.1/include/asm-s390/ptrace.h Thu Oct 11 16:43:38 2001 +++ linux-2.5/include/asm-s390/ptrace.h Thu Dec 27 16:32:31 2001 @@ -118,7 +118,7 @@ { __u32 mask; __u32 addr; -} psw_t __attribute__ ((aligned(8))); +} __attribute__ ((aligned(8))) psw_t; #ifdef __KERNEL__ #define FIX_PSW(addr) ((unsigned long)(addr)|0x80000000UL) @@ -150,8 +150,8 @@ #define FPC_VALID_MASK 0xF8F8FF03 /* - * The first entries in pt_regs, gdb_pt_regs and user_regs_struct - * are common for all three structures. The s390_regs structure + * The first entries in pt_regs and user_regs_struct + * are common for the two structures. The s390_regs structure * covers the common parts. It simplifies copying the common part * between the three structures. */ @@ -178,30 +178,12 @@ }; /* - * The gdb_pt_regs struct is used instead of the pt_regs structure - * if kernel remote debugging is used. - */ -#if CONFIG_REMOTE_DEBUG -struct gdb_pt_regs -{ - psw_t psw; - __u32 gprs[NUM_GPRS]; - __u32 acrs[NUM_ACRS]; - __u32 orig_gpr2; - __u32 trap; - __u32 crs[16]; - s390_fp_regs fp_regs; - __u32 old_ilc; -}; -#endif - -/* * Now for the program event recording (trace) definitions. */ typedef struct { __u32 cr[3]; -} per_cr_words __attribute__((packed)); +} per_cr_words; #define PER_EM_MASK 0xE8000000 @@ -223,14 +205,14 @@ unsigned : 21; addr_t starting_addr; addr_t ending_addr; -} per_cr_bits __attribute__((packed)); +} per_cr_bits; typedef struct { __u16 perc_atmid; /* 0x096 */ __u32 address; /* 0x098 */ __u8 access_id; /* 0x0a1 */ -} per_lowcore_words __attribute__((packed)); +} per_lowcore_words; typedef struct { @@ -249,14 +231,14 @@ addr_t address; /* 0x098 */ unsigned : 4; /* 0x0a1 */ unsigned access_id : 4; -} per_lowcore_bits __attribute__((packed)); +} per_lowcore_bits; typedef struct { union { per_cr_words words; per_cr_bits bits; - } control_regs __attribute__((packed)); + } control_regs; /* * Use these flags instead of setting em_instruction_fetch * directly they are used so that single stepping can be @@ -275,7 +257,7 @@ per_lowcore_words words; per_lowcore_bits bits; } lowcore; -} per_struct __attribute__((packed)); +} per_struct; typedef struct { diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/include/asm-s390/scatterlist.h linux-2.5/include/asm-s390/scatterlist.h --- linux-2.5.1/include/asm-s390/scatterlist.h Fri Oct 12 22:35:54 2001 +++ linux-2.5/include/asm-s390/scatterlist.h Thu Dec 27 16:32:31 2001 @@ -1,8 +1,16 @@ -#ifndef _ASMS390X_SCATTERLIST_H -#define _ASMS390X_SCATTERLIST_H +#ifndef _ASMS390_SCATTERLIST_H +#define _ASMS390_SCATTERLIST_H struct scatterlist { - char * address; /* Location data is to be transferred to */ + /* This will disappear in 2.5.x */ + char *address; + + /* These two are only valid if ADDRESS member of this + * struct is NULL. + */ + struct page *page; + unsigned int offset; + unsigned int length; }; diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/include/asm-s390/setup.h linux-2.5/include/asm-s390/setup.h --- linux-2.5.1/include/asm-s390/setup.h Wed Jul 25 21:12:02 2001 +++ linux-2.5/include/asm-s390/setup.h Thu Dec 27 16:32:31 2001 @@ -13,7 +13,7 @@ #define RAMDISK_ORIGIN 0x800000 #define RAMDISK_SIZE 0x800000 -#ifndef __ASSEMBLER__ +#ifndef __ASSEMBLY__ #define IPL_DEVICE (*(unsigned long *) (0x10404)) #define INITRD_START (*(unsigned long *) (0x1040C)) diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/include/asm-s390/siginfo.h linux-2.5/include/asm-s390/siginfo.h --- linux-2.5.1/include/asm-s390/siginfo.h Tue Feb 13 22:13:44 2001 +++ linux-2.5/include/asm-s390/siginfo.h Thu Dec 27 16:32:31 2001 @@ -111,7 +111,7 @@ #define SI_USER 0 /* sent by kill, sigsend, raise */ #define SI_KERNEL 0x80 /* sent by the kernel from somewhere */ #define SI_QUEUE -1 /* sent by sigqueue */ -#define SI_TIMER -2 /* sent by timer expiration */ +#define SI_TIMER __SI_CODE(__SI_TIMER,-2) /* sent by timer expiration */ #define SI_MESGQ -3 /* sent by real time mesq state change */ #define SI_ASYNCIO -4 /* sent by AIO completion */ #define SI_SIGIO -5 /* sent by queued SIGIO */ @@ -122,71 +122,71 @@ /* * SIGILL si_codes */ -#define ILL_ILLOPC 1 /* illegal opcode */ -#define ILL_ILLOPN 2 /* illegal operand */ -#define ILL_ILLADR 3 /* illegal addressing mode */ -#define ILL_ILLTRP 4 /* illegal trap */ -#define ILL_PRVOPC 5 /* privileged opcode */ -#define ILL_PRVREG 6 /* privileged register */ -#define ILL_COPROC 7 /* coprocessor error */ -#define ILL_BADSTK 8 /* internal stack error */ +#define ILL_ILLOPC (__SI_FAULT|1) /* illegal opcode */ +#define ILL_ILLOPN (__SI_FAULT|2) /* illegal operand */ +#define ILL_ILLADR (__SI_FAULT|3) /* illegal addressing mode */ +#define ILL_ILLTRP (__SI_FAULT|4) /* illegal trap */ +#define ILL_PRVOPC (__SI_FAULT|5) /* privileged opcode */ +#define ILL_PRVREG (__SI_FAULT|6) /* privileged register */ +#define ILL_COPROC (__SI_FAULT|7) /* coprocessor error */ +#define ILL_BADSTK (__SI_FAULT|8) /* internal stack error */ #define NSIGILL 8 /* * SIGFPE si_codes */ -#define FPE_INTDIV 1 /* integer divide by zero */ -#define FPE_INTOVF 2 /* integer overflow */ -#define FPE_FLTDIV 3 /* floating point divide by zero */ -#define FPE_FLTOVF 4 /* floating point overflow */ -#define FPE_FLTUND 5 /* floating point underflow */ -#define FPE_FLTRES 6 /* floating point inexact result */ -#define FPE_FLTINV 7 /* floating point invalid operation */ -#define FPE_FLTSUB 8 /* subscript out of range */ +#define FPE_INTDIV (__SI_FAULT|1) /* integer divide by zero */ +#define FPE_INTOVF (__SI_FAULT|2) /* integer overflow */ +#define FPE_FLTDIV (__SI_FAULT|3) /* floating point divide by zero */ +#define FPE_FLTOVF (__SI_FAULT|4) /* floating point overflow */ +#define FPE_FLTUND (__SI_FAULT|5) /* floating point underflow */ +#define FPE_FLTRES (__SI_FAULT|6) /* floating point inexact result */ +#define FPE_FLTINV (__SI_FAULT|7) /* floating point invalid operation */ +#define FPE_FLTSUB (__SI_FAULT|8) /* subscript out of range */ #define NSIGFPE 8 /* * SIGSEGV si_codes */ -#define SEGV_MAPERR 1 /* address not mapped to object */ -#define SEGV_ACCERR 2 /* invalid permissions for mapped object */ +#define SEGV_MAPERR (__SI_FAULT|1) /* address not mapped to object */ +#define SEGV_ACCERR (__SI_FAULT|2) /* invalid permissions for mapped object */ #define NSIGSEGV 2 /* * SIGBUS si_codes */ -#define BUS_ADRALN 1 /* invalid address alignment */ -#define BUS_ADRERR 2 /* non-existant physical address */ -#define BUS_OBJERR 3 /* object specific hardware error */ +#define BUS_ADRALN (__SI_FAULT|1) /* invalid address alignment */ +#define BUS_ADRERR (__SI_FAULT|2) /* non-existant physical address */ +#define BUS_OBJERR (__SI_FAULT|3) /* object specific hardware error */ #define NSIGBUS 3 /* * SIGTRAP si_codes */ -#define TRAP_BRKPT 1 /* process breakpoint */ -#define TRAP_TRACE 2 /* process trace trap */ +#define TRAP_BRKPT (__SI_FAULT|1) /* process breakpoint */ +#define TRAP_TRACE (__SI_FAULT|2) /* process trace trap */ #define NSIGTRAP 2 /* * SIGCHLD si_codes */ -#define CLD_EXITED 1 /* child has exited */ -#define CLD_KILLED 2 /* child was killed */ -#define CLD_DUMPED 3 /* child terminated abnormally */ -#define CLD_TRAPPED 4 /* traced child has trapped */ -#define CLD_STOPPED 5 /* child has stopped */ -#define CLD_CONTINUED 6 /* stopped child has continued */ +#define CLD_EXITED (__SI_CHLD|1) /* child has exited */ +#define CLD_KILLED (__SI_CHLD|2) /* child was killed */ +#define CLD_DUMPED (__SI_CHLD|3) /* child terminated abnormally */ +#define CLD_TRAPPED (__SI_CHLD|4) /* traced child has trapped */ +#define CLD_STOPPED (__SI_CHLD|5) /* child has stopped */ +#define CLD_CONTINUED (__SI_CHLD|6) /* stopped child has continued */ #define NSIGCHLD /* * SIGPOLL si_codes */ -#define POLL_IN 1 /* data input available */ -#define POLL_OUT 2 /* output buffers available */ -#define POLL_MSG 3 /* input message available */ -#define POLL_ERR 4 /* i/o error */ -#define POLL_PRI 5 /* high priority input available */ -#define POLL_HUP 6 /* device disconnected */ +#define POLL_IN (__SI_POLL|1) /* data input available */ +#define POLL_OUT (__SI_POLL|2) /* output buffers available */ +#define POLL_MSG (__SI_POLL|3) /* input message available */ +#define POLL_ERR (__SI_POLL|4) /* i/o error */ +#define POLL_PRI (__SI_POLL|5) /* high priority input available */ +#define POLL_HUP (__SI_POLL|6) /* device disconnected */ #define NSIGPOLL 6 /* @@ -224,7 +224,7 @@ #ifdef __KERNEL__ #include <linux/string.h> -extern inline void copy_siginfo(siginfo_t *to, siginfo_t *from) +static inline void copy_siginfo(siginfo_t *to, siginfo_t *from) { if (from->si_code < 0) memcpy(to, from, sizeof(siginfo_t)); diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/include/asm-s390/timex.h linux-2.5/include/asm-s390/timex.h --- linux-2.5.1/include/asm-s390/timex.h Fri May 12 18:41:44 2000 +++ linux-2.5/include/asm-s390/timex.h Thu Dec 27 16:32:31 2001 @@ -17,13 +17,16 @@ (1000000/CLOCK_TICK_FACTOR) / (CLOCK_TICK_RATE/CLOCK_TICK_FACTOR)) \ << (SHIFT_SCALE-SHIFT_HZ)) / HZ) -typedef unsigned long cycles_t; +typedef unsigned long long cycles_t; extern cycles_t cacheflush_time; static inline cycles_t get_cycles(void) { - return 0; + cycles_t cycles; + + __asm__("stck %0" : "=m" (cycles) : : "cc"); + return cycles >> 2; } #endif diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/include/asm-s390/uaccess.h linux-2.5/include/asm-s390/uaccess.h --- linux-2.5.1/include/asm-s390/uaccess.h Thu Oct 11 16:43:38 2001 +++ linux-2.5/include/asm-s390/uaccess.h Thu Dec 27 16:32:31 2001 @@ -379,34 +379,11 @@ * access register are set up, that 4 points to secondary (user) , 2 to primary (kernel) */ -asmlinkage void __copy_from_user_fixup(void /* special calling convention */); -asmlinkage void __copy_to_user_fixup(void /* special calling convention */); - -extern inline unsigned long -__copy_to_user_asm(void* to, const void* from, long n) -{ - - __asm__ __volatile__ ( " lr 2,%2\n" - " lr 4,%1\n" - " lr 3,%0\n" - " lr 5,3\n" - " sacf 512\n" - "0: mvcle 4,2,0\n" - " jo 0b\n" - " sacf 0\n" - " lr %0,3\n" - ".section __ex_table,\"a\"\n" - " .align 4\n" - " .long 0b,__copy_to_user_fixup\n" - ".previous" - : "+&d" (n) : "d" (to), "d" (from) - : "cc", "2", "3", "4", "5" ); - return n; -} +extern long __copy_to_user_asm(const void *from, long n, const void *to); #define __copy_to_user(to, from, n) \ ({ \ - __copy_to_user_asm(to,from,n); \ + __copy_to_user_asm(from, n, to); \ }) #define copy_to_user(to, from, n) \ @@ -414,38 +391,18 @@ long err = 0; \ __typeof__(n) __n = (n); \ if (__access_ok(to,__n)) { \ - err = __copy_to_user_asm(to,from,__n); \ + err = __copy_to_user_asm(from, __n, to); \ } \ else \ err = __n; \ err; \ }) -extern inline unsigned long -__copy_from_user_asm(void* to, const void* from, long n) -{ - __asm__ __volatile__ ( " lr 2,%1\n" - " lr 4,%2\n" - " lr 3,%0\n" - " lr 5,3\n" - " sacf 512\n" - "0: mvcle 2,4,0\n" - " jo 0b\n" - " sacf 0\n" - " lr %0,5\n" - ".section __ex_table,\"a\"\n" - " .align 4\n" - " .long 0b,__copy_from_user_fixup\n" - ".previous" - : "+&d" (n) : "d" (to), "d" (from) - : "cc", "2", "3", "4", "5" ); - return n; -} - +extern long __copy_from_user_asm(void *to, long n, const void *from); #define __copy_from_user(to, from, n) \ ({ \ - __copy_from_user_asm(to,from,n); \ + __copy_from_user_asm(to, n, from); \ }) #define copy_from_user(to, from, n) \ @@ -453,7 +410,7 @@ long err = 0; \ __typeof__(n) __n = (n); \ if (__access_ok(from,__n)) { \ - err = __copy_from_user_asm(to,from,__n); \ + err = __copy_from_user_asm(to, __n, from); \ } \ else \ err = __n; \ @@ -550,38 +507,12 @@ * Zero Userspace */ -static inline unsigned long -__clear_user(void *to, unsigned long n) -{ - __asm__ __volatile__ ( " sacf 512\n" - " lr 4,%1\n" - " lr 5,%0\n" - " sr 2,2\n" - " sr 3,3\n" - "0: mvcle 4,2,0\n" - " jo 0b\n" - " sacf 0\n" - "1: lr %0,3\n" - ".section .fixup,\"ax\"\n" - "2: lhi 5,-4096\n" - " n 5,0x90\n" - " sr 5,4\n" - " mvcle 4,2,0\n" - " sacf 0\n" - " basr 4,0\n" - " l 4,3f-.(4)\n" - " br 4\n" - "3: .long 1b\n" - ".previous\n" - ".section __ex_table,\"a\"\n" - " .align 4\n" - " .long 0b,2b\n" - ".previous" - : "+&a" (n) - : "a" (to) - : "cc", "2", "3", "4", "5" ); - return n; -} +extern long __clear_user_asm(void *to, long n); + +#define __clear_user(to, n) \ +({ \ + __clear_user_asm(to, n); \ +}) static inline unsigned long clear_user(void *to, unsigned long n) diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/include/asm-s390x/lowcore.h linux-2.5/include/asm-s390x/lowcore.h --- linux-2.5.1/include/asm-s390x/lowcore.h Thu Oct 11 16:43:38 2001 +++ linux-2.5/include/asm-s390x/lowcore.h Thu Dec 27 16:32:31 2001 @@ -45,6 +45,8 @@ #define __LC_CPUADDR 0xD98 #define __LC_IPLDEV 0xDB8 +#define __LC_JIFFY_TIMER 0xDC0 + #define __LC_PANIC_MAGIC 0xE00 #define __LC_AREGS_SAVE_AREA 0x1340 @@ -158,7 +160,7 @@ /* entry.S sensitive area end */ /* SMP info area: defined by DJB */ - __u64 jiffy_timer_cc; /* 0xdc0 */ + __u64 jiffy_timer; /* 0xdc0 */ __u64 ext_call_fast; /* 0xdc8 */ __u8 pad12[0xe00-0xdd0]; /* 0xdd0 */ diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/include/asm-s390x/processor.h linux-2.5/include/asm-s390x/processor.h --- linux-2.5.1/include/asm-s390x/processor.h Fri Oct 5 19:11:05 2001 +++ linux-2.5/include/asm-s390x/processor.h Thu Dec 27 16:32:31 2001 @@ -80,7 +80,6 @@ struct thread_struct { - struct pt_regs *regs; /* the user registers can be found on*/ s390_fp_regs fp_regs; __u32 ar2; /* kernel access register 2 */ __u32 ar4; /* kernel access register 4 */ @@ -99,8 +98,7 @@ typedef struct thread_struct thread_struct; -#define INIT_THREAD { (struct pt_regs *) 0, \ - { 0,{{0},{0},{0},{0},{0},{0},{0},{0},{0},{0}, \ +#define INIT_THREAD {{0,{{0},{0},{0},{0},{0},{0},{0},{0},{0},{0}, \ {0},{0},{0},{0},{0},{0}}}, \ 0, 0, \ sizeof(init_stack) + (addr_t) &init_stack, \ @@ -137,15 +135,24 @@ /* * Return saved PC of a blocked thread. used in kernel/sched + * resume in entry.S does not create a new stack frame, it + * just stores the registers %r6-%r15 to the frame given by + * schedule. We want to return the address of the caller of + * schedule, so we have to walk the backchain one time to + * find the frame schedule() store its return address. */ extern inline unsigned long thread_saved_pc(struct thread_struct *t) { - return (t->regs) ? ((unsigned long)t->regs->psw.addr) : 0; + unsigned long bc; + bc = *((unsigned long *) t->ksp); + return *((unsigned long *) (bc+112)); } unsigned long get_wchan(struct task_struct *p); -#define KSTK_EIP(tsk) ((tsk)->thread.regs->psw.addr) -#define KSTK_ESP(tsk) ((tsk)->thread.ksp) +#define __KSTK_PTREGS(tsk) \ + ((struct pt_regs *)((unsigned long) tsk+THREAD_SIZE) - 1) +#define KSTK_EIP(tsk) (__KSTK_PTREGS(tsk)->psw.addr) +#define KSTK_ESP(tsk) (__KSTK_PTREGS(tsk)->gprs[15]) /* Allocation and freeing of basic task resources. */ /* diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/include/asm-s390x/ptrace.h linux-2.5/include/asm-s390x/ptrace.h --- linux-2.5.1/include/asm-s390x/ptrace.h Thu Apr 12 02:02:29 2001 +++ linux-2.5/include/asm-s390x/ptrace.h Thu Dec 27 16:32:31 2001 @@ -98,7 +98,7 @@ { __u64 mask; __u64 addr; -} psw_t __attribute__ ((aligned(8))); +} __attribute__ ((aligned(8))) psw_t; #ifdef __KERNEL__ #define FIX_PSW(addr) ((unsigned long)(addr)) @@ -130,8 +130,8 @@ #define FPC_VALID_MASK 0xF8F8FF03 /* - * The first entries in pt_regs, gdb_pt_regs and user_regs_struct - * are common for all three structures. The s390_regs structure + * The first entries in pt_regs and user_regs_struct + * are common for the two structures. The s390_regs structure * covers the common parts. It simplifies copying the common part * between the three structures. */ @@ -158,29 +158,12 @@ } __attribute__ ((packed)); /* - * The gdb_pt_regs struct is used instead of the pt_regs structure - * if kernel remote debugging is used. - */ -#if CONFIG_REMOTE_DEBUG -struct gdb_pt_regs -{ - psw_t psw; - __u64 gprs[NUM_GPRS]; - __u32 acrs[NUM_ACRS]; - __u64 orig_gpr2; - __u32 trap; - __u32 crs[16]; - s390_fp_regs fp_regs; -}; -#endif - -/* * Now for the program event recording (trace) definitions. */ typedef struct { __u64 cr[3]; -} per_cr_words __attribute__((packed)); +} per_cr_words; #define PER_EM_MASK 0x00000000E8000000UL @@ -203,14 +186,14 @@ unsigned : 21; addr_t starting_addr; addr_t ending_addr; -} per_cr_bits __attribute__((packed)); +} per_cr_bits; typedef struct { __u16 perc_atmid; addr_t address; __u8 access_id; -} per_lowcore_words __attribute__((packed)); +} per_lowcore_words; typedef struct { @@ -230,14 +213,14 @@ addr_t address; /* 0x098 */ unsigned : 4; /* 0x0a1 */ unsigned access_id : 4; -} per_lowcore_bits __attribute__((packed)); +} per_lowcore_bits; typedef struct { union { per_cr_words words; per_cr_bits bits; - } control_regs __attribute__((packed)); + } control_regs; /* * Use these flags instead of setting em_instruction_fetch * directly they are used so that single stepping can be @@ -256,7 +239,7 @@ per_lowcore_words words; per_lowcore_bits bits; } lowcore; -} per_struct __attribute__((packed)); +} per_struct; typedef struct { diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/include/asm-s390x/scatterlist.h linux-2.5/include/asm-s390x/scatterlist.h --- linux-2.5.1/include/asm-s390x/scatterlist.h Fri Oct 12 22:35:54 2001 +++ linux-2.5/include/asm-s390x/scatterlist.h Thu Dec 27 16:32:31 2001 @@ -2,7 +2,15 @@ #define _ASMS390X_SCATTERLIST_H struct scatterlist { - char * address; /* Location data is to be transferred to */ + /* This will disappear in 2.5.x */ + char *address; + + /* These two are only valid if ADDRESS member of this + * struct is NULL. + */ + struct page *page; + unsigned int offset; + unsigned int length; }; diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/include/asm-s390x/setup.h linux-2.5/include/asm-s390x/setup.h --- linux-2.5.1/include/asm-s390x/setup.h Wed Jul 25 21:12:02 2001 +++ linux-2.5/include/asm-s390x/setup.h Thu Dec 27 16:32:31 2001 @@ -13,7 +13,7 @@ #define RAMDISK_ORIGIN 0x800000 #define RAMDISK_SIZE 0x800000 -#ifndef __ASSEMBLER__ +#ifndef __ASSEMBLY__ #define IPL_DEVICE (*(unsigned long *) (0x10400)) #define INITRD_START (*(unsigned long *) (0x10408)) diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/include/asm-s390x/siginfo.h linux-2.5/include/asm-s390x/siginfo.h --- linux-2.5.1/include/asm-s390x/siginfo.h Tue Feb 13 22:13:44 2001 +++ linux-2.5/include/asm-s390x/siginfo.h Thu Dec 27 16:32:31 2001 @@ -111,7 +111,7 @@ #define SI_USER 0 /* sent by kill, sigsend, raise */ #define SI_KERNEL 0x80 /* sent by the kernel from somewhere */ #define SI_QUEUE -1 /* sent by sigqueue */ -#define SI_TIMER -2 /* sent by timer expiration */ +#define SI_TIMER __SI_CODE(__SI_TIMER,-2) /* sent by timer expiration */ #define SI_MESGQ -3 /* sent by real time mesq state change */ #define SI_ASYNCIO -4 /* sent by AIO completion */ #define SI_SIGIO -5 /* sent by queued SIGIO */ @@ -122,71 +122,71 @@ /* * SIGILL si_codes */ -#define ILL_ILLOPC 1 /* illegal opcode */ -#define ILL_ILLOPN 2 /* illegal operand */ -#define ILL_ILLADR 3 /* illegal addressing mode */ -#define ILL_ILLTRP 4 /* illegal trap */ -#define ILL_PRVOPC 5 /* privileged opcode */ -#define ILL_PRVREG 6 /* privileged register */ -#define ILL_COPROC 7 /* coprocessor error */ -#define ILL_BADSTK 8 /* internal stack error */ +#define ILL_ILLOPC (__SI_FAULT|1) /* illegal opcode */ +#define ILL_ILLOPN (__SI_FAULT|2) /* illegal operand */ +#define ILL_ILLADR (__SI_FAULT|3) /* illegal addressing mode */ +#define ILL_ILLTRP (__SI_FAULT|4) /* illegal trap */ +#define ILL_PRVOPC (__SI_FAULT|5) /* privileged opcode */ +#define ILL_PRVREG (__SI_FAULT|6) /* privileged register */ +#define ILL_COPROC (__SI_FAULT|7) /* coprocessor error */ +#define ILL_BADSTK (__SI_FAULT|8) /* internal stack error */ #define NSIGILL 8 /* * SIGFPE si_codes */ -#define FPE_INTDIV 1 /* integer divide by zero */ -#define FPE_INTOVF 2 /* integer overflow */ -#define FPE_FLTDIV 3 /* floating point divide by zero */ -#define FPE_FLTOVF 4 /* floating point overflow */ -#define FPE_FLTUND 5 /* floating point underflow */ -#define FPE_FLTRES 6 /* floating point inexact result */ -#define FPE_FLTINV 7 /* floating point invalid operation */ -#define FPE_FLTSUB 8 /* subscript out of range */ +#define FPE_INTDIV (__SI_FAULT|1) /* integer divide by zero */ +#define FPE_INTOVF (__SI_FAULT|2) /* integer overflow */ +#define FPE_FLTDIV (__SI_FAULT|3) /* floating point divide by zero */ +#define FPE_FLTOVF (__SI_FAULT|4) /* floating point overflow */ +#define FPE_FLTUND (__SI_FAULT|5) /* floating point underflow */ +#define FPE_FLTRES (__SI_FAULT|6) /* floating point inexact result */ +#define FPE_FLTINV (__SI_FAULT|7) /* floating point invalid operation */ +#define FPE_FLTSUB (__SI_FAULT|8) /* subscript out of range */ #define NSIGFPE 8 /* * SIGSEGV si_codes */ -#define SEGV_MAPERR 1 /* address not mapped to object */ -#define SEGV_ACCERR 2 /* invalid permissions for mapped object */ +#define SEGV_MAPERR (__SI_FAULT|1) /* address not mapped to object */ +#define SEGV_ACCERR (__SI_FAULT|2) /* invalid permissions for mapped object */ #define NSIGSEGV 2 /* * SIGBUS si_codes */ -#define BUS_ADRALN 1 /* invalid address alignment */ -#define BUS_ADRERR 2 /* non-existant physical address */ -#define BUS_OBJERR 3 /* object specific hardware error */ +#define BUS_ADRALN (__SI_FAULT|1) /* invalid address alignment */ +#define BUS_ADRERR (__SI_FAULT|2) /* non-existant physical address */ +#define BUS_OBJERR (__SI_FAULT|3) /* object specific hardware error */ #define NSIGBUS 3 /* * SIGTRAP si_codes */ -#define TRAP_BRKPT 1 /* process breakpoint */ -#define TRAP_TRACE 2 /* process trace trap */ +#define TRAP_BRKPT (__SI_FAULT|1) /* process breakpoint */ +#define TRAP_TRACE (__SI_FAULT|2) /* process trace trap */ #define NSIGTRAP 2 /* * SIGCHLD si_codes */ -#define CLD_EXITED 1 /* child has exited */ -#define CLD_KILLED 2 /* child was killed */ -#define CLD_DUMPED 3 /* child terminated abnormally */ -#define CLD_TRAPPED 4 /* traced child has trapped */ -#define CLD_STOPPED 5 /* child has stopped */ -#define CLD_CONTINUED 6 /* stopped child has continued */ +#define CLD_EXITED (__SI_CHLD|1) /* child has exited */ +#define CLD_KILLED (__SI_CHLD|2) /* child was killed */ +#define CLD_DUMPED (__SI_CHLD|3) /* child terminated abnormally */ +#define CLD_TRAPPED (__SI_CHLD|4) /* traced child has trapped */ +#define CLD_STOPPED (__SI_CHLD|5) /* child has stopped */ +#define CLD_CONTINUED (__SI_CHLD|6) /* stopped child has continued */ #define NSIGCHLD /* * SIGPOLL si_codes */ -#define POLL_IN 1 /* data input available */ -#define POLL_OUT 2 /* output buffers available */ -#define POLL_MSG 3 /* input message available */ -#define POLL_ERR 4 /* i/o error */ -#define POLL_PRI 5 /* high priority input available */ -#define POLL_HUP 6 /* device disconnected */ +#define POLL_IN (__SI_POLL|1) /* data input available */ +#define POLL_OUT (__SI_POLL|2) /* output buffers available */ +#define POLL_MSG (__SI_POLL|3) /* input message available */ +#define POLL_ERR (__SI_POLL|4) /* i/o error */ +#define POLL_PRI (__SI_POLL|5) /* high priority input available */ +#define POLL_HUP (__SI_POLL|6) /* device disconnected */ #define NSIGPOLL 6 /* @@ -224,7 +224,7 @@ #ifdef __KERNEL__ #include <linux/string.h> -extern inline void copy_siginfo(siginfo_t *to, siginfo_t *from) +static inline void copy_siginfo(siginfo_t *to, siginfo_t *from) { if (from->si_code < 0) memcpy(to, from, sizeof(siginfo_t)); diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/include/asm-s390x/timex.h linux-2.5/include/asm-s390x/timex.h --- linux-2.5.1/include/asm-s390x/timex.h Tue Feb 13 22:13:44 2001 +++ linux-2.5/include/asm-s390x/timex.h Thu Dec 27 16:32:31 2001 @@ -17,13 +17,16 @@ (1000000/CLOCK_TICK_FACTOR) / (CLOCK_TICK_RATE/CLOCK_TICK_FACTOR)) \ << (SHIFT_SCALE-SHIFT_HZ)) / HZ) -typedef unsigned long cycles_t; +typedef unsigned long long cycles_t; extern cycles_t cacheflush_time; static inline cycles_t get_cycles(void) { - return 0; + cycles_t cycles; + + __asm__("stck %0" : "=m" (cycles) : : "cc"); + return cycles >> 2; } #endif diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/include/asm-s390x/uaccess.h linux-2.5/include/asm-s390x/uaccess.h --- linux-2.5.1/include/asm-s390x/uaccess.h Wed Jul 25 21:12:03 2001 +++ linux-2.5/include/asm-s390x/uaccess.h Thu Dec 27 16:32:31 2001 @@ -336,34 +336,11 @@ * access register are set up, that 4 points to secondary (user) , 2 to primary (kernel) */ -asmlinkage void __copy_from_user_fixup(void /* special calling convention */); -asmlinkage void __copy_to_user_fixup(void /* special calling convention */); - -extern inline unsigned long -__copy_to_user_asm(void* to, const void* from, long n) -{ - - __asm__ __volatile__ ( " lgr 2,%2\n" - " lgr 4,%1\n" - " lgr 3,%0\n" - " lgr 5,3\n" - " sacf 512\n" - "0: mvcle 4,2,0\n" - " jo 0b\n" - " sacf 0\n" - " lgr %0,3\n" - ".section __ex_table,\"a\"\n" - " .align 8\n" - " .quad 0b,__copy_to_user_fixup\n" - ".previous" - : "+&d" (n) : "d" (to), "d" (from) - : "cc", "1", "2", "3", "4", "5" ); - return n; -} +extern long __copy_to_user_asm(const void *from, long n, void *to); #define __copy_to_user(to, from, n) \ ({ \ - __copy_to_user_asm(to,from,n); \ + __copy_to_user_asm(from, n, to); \ }) #define copy_to_user(to, from, n) \ @@ -371,38 +348,18 @@ long err = 0; \ __typeof__(n) __n = (n); \ if (__access_ok(to,__n)) { \ - err = __copy_to_user_asm(to,from,__n); \ + err = __copy_to_user_asm(from, __n, to); \ } \ else \ err = __n; \ err; \ }) -extern inline unsigned long -__copy_from_user_asm(void* to, const void* from, long n) -{ - __asm__ __volatile__ ( " lgr 2,%1\n" - " lgr 4,%2\n" - " lgr 3,%0\n" - " lgr 5,3\n" - " sacf 512\n" - "0: mvcle 2,4,0\n" - " jo 0b\n" - " sacf 0\n" - " lgr %0,5\n" - ".section __ex_table,\"a\"\n" - " .align 8\n" - " .quad 0b,__copy_from_user_fixup\n" - ".previous" - : "+&d" (n) : "d" (to), "d" (from) - : "cc", "1", "2", "3", "4", "5" ); - return n; -} - +extern long __copy_from_user_asm(void *to, long n, const void *from); #define __copy_from_user(to, from, n) \ ({ \ - __copy_from_user_asm(to,from,n); \ + __copy_from_user_asm(to, n, from); \ }) #define copy_from_user(to, from, n) \ @@ -410,7 +367,7 @@ long err = 0; \ __typeof__(n) __n = (n); \ if (__access_ok(from,__n)) { \ - err = __copy_from_user_asm(to,from,__n); \ + err = __copy_from_user_asm(to, __n, from); \ } \ else \ err = __n; \ @@ -520,27 +477,12 @@ * Zero Userspace */ -static inline unsigned long -__clear_user(void *to, unsigned long n) -{ - __asm__ __volatile__ ( " sacf 512\n" - " lgr 4,%1\n" - " lgr 5,%0\n" - " sgr 2,2\n" - " sgr 3,3\n" - "0: mvcle 4,2,0\n" - " jo 0b\n" - "1: sacf 0\n" - " lgr %0,5\n" - ".section __ex_table,\"a\"\n" - " .align 8\n" - " .quad 0b,__copy_to_user_fixup\n" - ".previous" - : "+&a" (n) - : "a" (to) - : "cc", "1", "2", "3", "4", "5" ); - return n; -} +extern long __clear_user_asm(void *to, long n); + +#define __clear_user(to, n) \ +({ \ + __clear_user_asm(to, n); \ +}) static inline unsigned long clear_user(void *to, unsigned long n) diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/include/asm-sh/pci.h linux-2.5/include/asm-sh/pci.h --- linux-2.5.1/include/asm-sh/pci.h Tue Dec 11 18:10:18 2001 +++ linux-2.5/include/asm-sh/pci.h Thu Dec 27 16:32:31 2001 @@ -89,6 +89,31 @@ return virt_to_bus(ptr); } +/* pci_unmap_{single,page} being a nop depends upon the + * configuration. + */ +#ifdef CONFIG_SH_PCIDMA_NONCOHERENT +#define DECLARE_PCI_UNMAP_ADDR(ADDR_NAME) \ + dma_addr_t ADDR_NAME; +#define DECLARE_PCI_UNMAP_LEN(LEN_NAME) \ + __u32 LEN_NAME; +#define PCI_UNMAP_ADDR(PTR, ADDR_NAME) \ + ((PTR)->ADDR_NAME) +#define PCI_UNMAP_ADDR_SET(PTR, ADDR_NAME, VAL) \ + (((PTR)->ADDR_NAME) = (VAL)) +#define PCI_UNMAP_LEN(PTR, LEN_NAME) \ + ((PTR)->LEN_NAME) +#define PCI_UNMAP_LEN_SET(PTR, LEN_NAME, VAL) \ + (((PTR)->LEN_NAME) = (VAL)) +#else +#define DECLARE_PCI_UNMAP_ADDR(ADDR_NAME) +#define DECLARE_PCI_UNMAP_LEN(LEN_NAME) +#define PCI_UNMAP_ADDR(PTR, ADDR_NAME) (0) +#define PCI_UNMAP_ADDR_SET(PTR, ADDR_NAME, VAL) do { } while (0) +#define PCI_UNMAP_LEN(PTR, LEN_NAME) (0) +#define PCI_UNMAP_LEN_SET(PTR, LEN_NAME, VAL) do { } while (0) +#endif + /* Unmap a single streaming mode DMA translation. The dma_addr and size * must match what was provided for in a previous pci_map_single call. All * other usages are undefined. @@ -195,6 +220,11 @@ { return 1; } + +/* Not supporting more than 32-bit PCI bus addresses now, but + * must satisfy references to this function. Change if needed. + */ +#define pci_dac_dma_supported(pci_dev, mask) (0) /* Not supporting more than 32-bit PCI bus addresses now, but * must satisfy references to this function. Change if needed. diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/include/asm-sh/processor.h linux-2.5/include/asm-sh/processor.h --- linux-2.5.1/include/asm-sh/processor.h Fri Oct 5 19:11:05 2001 +++ linux-2.5/include/asm-sh/processor.h Thu Dec 27 15:15:00 2001 @@ -143,7 +143,6 @@ * Bus types */ #define EISA_bus 0 -#define EISA_bus__is_a_macro /* for versions in ksyms.c */ #define MCA_bus 0 #define MCA_bus__is_a_macro /* for versions in ksyms.c */ diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/include/asm-sparc/bitops.h linux-2.5/include/asm-sparc/bitops.h --- linux-2.5.1/include/asm-sparc/bitops.h Tue Oct 30 23:08:11 2001 +++ linux-2.5/include/asm-sparc/bitops.h Thu Dec 13 16:32:37 2001 @@ -1,4 +1,4 @@ -/* $Id: bitops.h,v 1.65 2001/10/30 04:08:26 davem Exp $ +/* $Id: bitops.h,v 1.67 2001/11/19 18:36:34 davem Exp $ * bitops.h: Bit string operations on the Sparc. * * Copyright 1995 David S. Miller (davem@caip.rutgers.edu) diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/include/asm-sparc/keyboard.h linux-2.5/include/asm-sparc/keyboard.h --- linux-2.5.1/include/asm-sparc/keyboard.h Tue Aug 28 14:09:44 2001 +++ linux-2.5/include/asm-sparc/keyboard.h Thu Dec 27 15:56:12 2001 @@ -40,7 +40,6 @@ #define kbd_init pcikbd_init #define compute_shiftstate pci_compute_shiftstate -#define keyboard_wait_for_keypress pci_wait_for_keypress #define getkeycode pci_getkeycode #define setkeycode pci_setkeycode #define getledstate pci_getledstate diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/include/asm-sparc/pci.h linux-2.5/include/asm-sparc/pci.h --- linux-2.5.1/include/asm-sparc/pci.h Tue Nov 13 17:16:05 2001 +++ linux-2.5/include/asm-sparc/pci.h Thu Dec 27 16:32:31 2001 @@ -63,6 +63,20 @@ */ extern void pci_unmap_single(struct pci_dev *hwdev, dma_addr_t dma_addr, size_t size, int direction); +/* pci_unmap_{single,page} is not a nop, thus... */ +#define DECLARE_PCI_UNMAP_ADDR(ADDR_NAME) \ + dma_addr_t ADDR_NAME; +#define DECLARE_PCI_UNMAP_LEN(LEN_NAME) \ + __u32 LEN_NAME; +#define PCI_UNMAP_ADDR(PTR, ADDR_NAME) \ + ((PTR)->ADDR_NAME) +#define PCI_UNMAP_ADDR_SET(PTR, ADDR_NAME, VAL) \ + (((PTR)->ADDR_NAME) = (VAL)) +#define PCI_UNMAP_LEN(PTR, LEN_NAME) \ + ((PTR)->LEN_NAME) +#define PCI_UNMAP_LEN_SET(PTR, LEN_NAME, VAL) \ + (((PTR)->LEN_NAME) = (VAL)) + /* Map a set of buffers described by scatterlist in streaming * mode for DMA. This is the scather-gather version of the * above pci_map_single interface. Here the scatter gather list diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/include/asm-sparc/processor.h linux-2.5/include/asm-sparc/processor.h --- linux-2.5.1/include/asm-sparc/processor.h Thu Oct 11 06:42:47 2001 +++ linux-2.5/include/asm-sparc/processor.h Thu Dec 27 15:15:00 2001 @@ -28,7 +28,6 @@ * Bus types */ #define EISA_bus 0 -#define EISA_bus__is_a_macro /* for versions in ksyms.c */ #define MCA_bus 0 #define MCA_bus__is_a_macro /* for versions in ksyms.c */ diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/include/asm-sparc64/bitops.h linux-2.5/include/asm-sparc64/bitops.h --- linux-2.5.1/include/asm-sparc64/bitops.h Thu Jun 21 04:00:55 2001 +++ linux-2.5/include/asm-sparc64/bitops.h Thu Dec 13 16:32:37 2001 @@ -1,4 +1,4 @@ -/* $Id: bitops.h,v 1.36 2001/06/14 12:34:49 davem Exp $ +/* $Id: bitops.h,v 1.38 2001/11/19 18:36:34 davem Exp $ * bitops.h: Bit string operations on the V9. * * Copyright 1996, 1997 David S. Miller (davem@caip.rutgers.edu) @@ -13,9 +13,9 @@ extern long ___test_and_clear_bit(unsigned long nr, volatile void *addr); extern long ___test_and_change_bit(unsigned long nr, volatile void *addr); -#define test_and_set_bit(nr,addr) (___test_and_set_bit(nr,addr)!=0) -#define test_and_clear_bit(nr,addr) (___test_and_clear_bit(nr,addr)!=0) -#define test_and_change_bit(nr,addr) (___test_and_change_bit(nr,addr)!=0) +#define test_and_set_bit(nr,addr) ({___test_and_set_bit(nr,addr)!=0;}) +#define test_and_clear_bit(nr,addr) ({___test_and_clear_bit(nr,addr)!=0;}) +#define test_and_change_bit(nr,addr) ({___test_and_change_bit(nr,addr)!=0;}) #define set_bit(nr,addr) ((void)___test_and_set_bit(nr,addr)) #define clear_bit(nr,addr) ((void)___test_and_clear_bit(nr,addr)) #define change_bit(nr,addr) ((void)___test_and_change_bit(nr,addr)) @@ -214,8 +214,8 @@ extern long ___test_and_set_le_bit(int nr, volatile void *addr); extern long ___test_and_clear_le_bit(int nr, volatile void *addr); -#define test_and_set_le_bit(nr,addr) (___test_and_set_le_bit(nr,addr)!=0) -#define test_and_clear_le_bit(nr,addr) (___test_and_clear_le_bit(nr,addr)!=0) +#define test_and_set_le_bit(nr,addr) ({___test_and_set_le_bit(nr,addr)!=0;}) +#define test_and_clear_le_bit(nr,addr) ({___test_and_clear_le_bit(nr,addr)!=0;}) #define set_le_bit(nr,addr) ((void)___test_and_set_le_bit(nr,addr)) #define clear_le_bit(nr,addr) ((void)___test_and_clear_le_bit(nr,addr)) diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/include/asm-sparc64/keyboard.h linux-2.5/include/asm-sparc64/keyboard.h --- linux-2.5.1/include/asm-sparc64/keyboard.h Tue Aug 28 14:09:44 2001 +++ linux-2.5/include/asm-sparc64/keyboard.h Thu Dec 27 15:56:12 2001 @@ -38,7 +38,6 @@ #define kbd_init pcikbd_init #define compute_shiftstate pci_compute_shiftstate -#define keyboard_wait_for_keypress pci_wait_for_keypress #define getkeycode pci_getkeycode #define setkeycode pci_setkeycode #define getledstate pci_getledstate diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/include/asm-sparc64/page.h linux-2.5/include/asm-sparc64/page.h --- linux-2.5.1/include/asm-sparc64/page.h Thu Aug 10 19:43:12 2000 +++ linux-2.5/include/asm-sparc64/page.h Thu Dec 13 16:32:37 2001 @@ -1,4 +1,4 @@ -/* $Id: page.h,v 1.36 2000/08/10 01:04:53 davem Exp $ */ +/* $Id: page.h,v 1.38 2001/11/30 01:04:10 davem Exp $ */ #ifndef _SPARC64_PAGE_H #define _SPARC64_PAGE_H @@ -18,13 +18,20 @@ #ifndef __ASSEMBLY__ +#ifdef CONFIG_DEBUG_BUGVERBOSE +extern void do_BUG(const char *file, int line); +#define BUG() do { \ + do_BUG(__FILE__, __LINE__); \ + __builtin_trap(); \ +} while (0) +#else #define BUG() __builtin_trap() +#endif + #define PAGE_BUG(page) BUG() extern void _clear_page(void *page); -extern void _copy_page(void *to, void *from); #define clear_page(X) _clear_page((void *)(X)) -#define copy_page(X,Y) _copy_page((void *)(X), (void *)(Y)) extern void clear_user_page(void *page, unsigned long vaddr); extern void copy_user_page(void *to, void *from, unsigned long vaddr); diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/include/asm-sparc64/pci.h linux-2.5/include/asm-sparc64/pci.h --- linux-2.5.1/include/asm-sparc64/pci.h Tue Nov 13 17:16:05 2001 +++ linux-2.5/include/asm-sparc64/pci.h Thu Dec 27 16:32:31 2001 @@ -77,6 +77,20 @@ pci_map_single(dev, (page_address(page) + (off)), size, dir) #define pci_unmap_page(dev,addr,sz,dir) pci_unmap_single(dev,addr,sz,dir) +/* pci_unmap_{single,page} is not a nop, thus... */ +#define DECLARE_PCI_UNMAP_ADDR(ADDR_NAME) \ + dma_addr_t ADDR_NAME; +#define DECLARE_PCI_UNMAP_LEN(LEN_NAME) \ + __u32 LEN_NAME; +#define PCI_UNMAP_ADDR(PTR, ADDR_NAME) \ + ((PTR)->ADDR_NAME) +#define PCI_UNMAP_ADDR_SET(PTR, ADDR_NAME, VAL) \ + (((PTR)->ADDR_NAME) = (VAL)) +#define PCI_UNMAP_LEN(PTR, LEN_NAME) \ + ((PTR)->LEN_NAME) +#define PCI_UNMAP_LEN_SET(PTR, LEN_NAME, VAL) \ + (((PTR)->LEN_NAME) = (VAL)) + /* Map a set of buffers described by scatterlist in streaming * mode for DMA. This is the scather-gather version of the * above pci_map_single interface. Here the scatter gather list diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/include/asm-sparc64/pgtable.h linux-2.5/include/asm-sparc64/pgtable.h --- linux-2.5.1/include/asm-sparc64/pgtable.h Tue Nov 13 17:16:05 2001 +++ linux-2.5/include/asm-sparc64/pgtable.h Thu Dec 13 16:32:37 2001 @@ -1,4 +1,4 @@ -/* $Id: pgtable.h,v 1.152 2001/11/12 09:43:39 davem Exp $ +/* $Id: pgtable.h,v 1.154 2001/12/05 06:05:36 davem Exp $ * pgtable.h: SpitFire page table operations. * * Copyright 1996,1997 David S. Miller (davem@caip.rutgers.edu) @@ -19,6 +19,23 @@ #include <asm/page.h> #include <asm/processor.h> +/* The kernel image occupies 0x4000000 to 0x1000000 (4MB --> 16MB). + * The page copy blockops use 0x1000000 to 0x18000000 (16MB --> 24MB). + * The PROM resides in an area spanning 0xf0000000 to 0x100000000. + * The vmalloc area spans 0x140000000 to 0x200000000. + * There is a single static kernel PMD which maps from 0x0 to address + * 0x400000000. + */ +#define TLBTEMP_BASE 0x0000000001000000 +#define MODULES_VADDR 0x0000000002000000 +#define MODULES_LEN 0x000000007e000000 +#define MODULES_END 0x0000000080000000 +#define VMALLOC_START 0x0000000140000000 +#define VMALLOC_VMADDR(x) ((unsigned long)(x)) +#define VMALLOC_END 0x0000000200000000 +#define LOW_OBP_ADDRESS 0x00000000f0000000 +#define HI_OBP_ADDRESS 0x0000000100000000 + /* XXX All of this needs to be rethought so we can take advantage * XXX cheetah's full 64-bit virtual address space, ie. no more hole * XXX in the middle like on spitfire. -DaveM @@ -77,13 +94,6 @@ (1) : (PTRS_PER_PGD))) #define FIRST_USER_PGD_NR 0 -/* NOTE: TLB miss handlers depend heavily upon where this is. */ -#define VMALLOC_START 0x0000000140000000UL -#define VMALLOC_VMADDR(x) ((unsigned long)(x)) -#define VMALLOC_END 0x0000000200000000UL -#define LOW_OBP_ADDRESS 0xf0000000UL -#define HI_OBP_ADDRESS 0x100000000UL - #define pte_ERROR(e) __builtin_trap() #define pmd_ERROR(e) __builtin_trap() #define pgd_ERROR(e) __builtin_trap() @@ -290,8 +300,6 @@ #define swp_entry_to_pte(x) ((pte_t) { (x).val }) extern unsigned long prom_virt_to_phys(unsigned long, int *); -#define LOW_OBP_ADDRESS 0xf0000000UL -#define HI_OBP_ADDRESS 0x100000000UL extern __inline__ unsigned long sun4u_get_pte (unsigned long addr) diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/include/asm-sparc64/processor.h linux-2.5/include/asm-sparc64/processor.h --- linux-2.5.1/include/asm-sparc64/processor.h Thu Oct 11 06:42:47 2001 +++ linux-2.5/include/asm-sparc64/processor.h Thu Dec 27 15:15:00 2001 @@ -1,4 +1,4 @@ -/* $Id: processor.h,v 1.76 2001/10/08 09:32:13 davem Exp $ +/* $Id: processor.h,v 1.80 2001/11/17 00:10:48 davem Exp $ * include/asm-sparc64/processor.h * * Copyright (C) 1996 David S. Miller (davem@caip.rutgers.edu) @@ -24,7 +24,6 @@ /* Bus types */ #define EISA_bus 0 -#define EISA_bus__is_a_macro /* for versions in ksyms.c */ #define MCA_bus 0 #define MCA_bus__is_a_macro /* for versions in ksyms.c */ @@ -66,6 +65,15 @@ unsigned long gsr[7]; unsigned long xfsr[7]; +#ifdef CONFIG_DEBUG_SPINLOCK + /* How many spinlocks held by this thread. + * Used with spin lock debugging to catch tasks + * sleeping illegally with locks held. + */ + int smp_lock_count; + unsigned int smp_lock_pc; +#endif + struct reg_window reg_window[NSWINS]; unsigned long rwbuf_stkptrs[NSWINS]; @@ -88,6 +96,7 @@ #define FAULT_CODE_ITLB 0x04 /* Miss happened in I-TLB */ #define FAULT_CODE_WINFIXUP 0x08 /* Miss happened during spill/fill */ +#ifndef CONFIG_DEBUG_SPINLOCK #define INIT_THREAD { \ /* ksp, wstate, cwp, flags, current_ds, */ \ 0, 0, 0, 0, KERNEL_DS, \ @@ -104,6 +113,24 @@ /* user_cntd0, user_cndd1, kernel_cntd0, kernel_cntd0, pcr_reg */ \ 0, 0, 0, 0, 0, \ } +#else /* CONFIG_DEBUG_SPINLOCK */ +#define INIT_THREAD { \ +/* ksp, wstate, cwp, flags, current_ds, */ \ + 0, 0, 0, 0, KERNEL_DS, \ +/* w_saved, fpdepth, fault_code, use_blkcommit, */ \ + 0, 0, 0, 0, \ +/* fault_address, fpsaved, __pad2, kregs, */ \ + 0, { 0 }, 0, 0, \ +/* utraps, gsr, xfsr, smp_lock_count, smp_lock_pc, */\ + 0, { 0 }, { 0 }, 0, 0, \ +/* reg_window */ \ + { { { 0, }, { 0, } }, }, \ +/* rwbuf_stkptrs */ \ + { 0, 0, 0, 0, 0, 0, 0, }, \ +/* user_cntd0, user_cndd1, kernel_cntd0, kernel_cntd0, pcr_reg */ \ + 0, 0, 0, 0, 0, \ +} +#endif /* !(CONFIG_DEBUG_SPINLOCK) */ #ifdef __KERNEL__ #if PAGE_SHIFT == 13 diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/include/asm-sparc64/rwsem.h linux-2.5/include/asm-sparc64/rwsem.h --- linux-2.5.1/include/asm-sparc64/rwsem.h Fri Apr 27 05:17:26 2001 +++ linux-2.5/include/asm-sparc64/rwsem.h Thu Dec 13 16:32:37 2001 @@ -1,4 +1,4 @@ -/* $Id: rwsem.h,v 1.4 2001/04/26 02:36:36 davem Exp $ +/* $Id: rwsem.h,v 1.5 2001/11/18 00:12:56 davem Exp $ * rwsem.h: R/W semaphores implemented using CAS * * Written by David S. Miller (davem@redhat.com), 2001. @@ -59,7 +59,7 @@ " add %%g7, 1, %%g7\n\t" "cmp %%g7, 0\n\t" "bl,pn %%icc, 3f\n\t" - " membar #StoreStore\n" + " membar #StoreLoad | #StoreStore\n" "2:\n\t" ".subsection 2\n" "3:\tmov %0, %%g5\n\t" @@ -92,7 +92,7 @@ "bne,pn %%icc, 1b\n\t" " cmp %%g7, 0\n\t" "bne,pn %%icc, 3f\n\t" - " membar #StoreStore\n" + " membar #StoreLoad | #StoreStore\n" "2:\n\t" ".subsection 2\n" "3:\tmov %0, %%g5\n\t" @@ -122,7 +122,7 @@ "bne,pn %%icc, 1b\n\t" " cmp %%g7, 0\n\t" "bl,pn %%icc, 3f\n\t" - " membar #StoreStore\n" + " membar #StoreLoad | #StoreStore\n" "2:\n\t" ".subsection 2\n" "3:\tsethi %%hi(%2), %%g1\n\t" @@ -160,7 +160,7 @@ " sub %%g7, %%g1, %%g7\n\t" "cmp %%g7, 0\n\t" "bl,pn %%icc, 3f\n\t" - " membar #StoreStore\n" + " membar #StoreLoad | #StoreStore\n" "2:\n\t" ".subsection 2\n" "3:\tmov %0, %%g5\n\t" @@ -189,7 +189,7 @@ "cas [%2], %%g5, %%g7\n\t" "cmp %%g5, %%g7\n\t" "bne,pn %%icc, 1b\n\t" - " nop\n\t" + " membar #StoreLoad | #StoreStore\n\t" "mov %%g7, %0\n\t" : "=&r" (tmp) : "0" (tmp), "r" (sem) @@ -208,7 +208,7 @@ again: __asm__ __volatile__("cas [%2], %3, %0\n\t" - "membar #StoreStore | #StoreLoad" + "membar #StoreLoad | #StoreStore" : "=&r" (prev) : "0" (new), "r" (sem), "r" (old) : "memory"); diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/include/asm-sparc64/semaphore.h linux-2.5/include/asm-sparc64/semaphore.h --- linux-2.5.1/include/asm-sparc64/semaphore.h Sun May 20 18:32:08 2001 +++ linux-2.5/include/asm-sparc64/semaphore.h Thu Dec 13 16:32:37 2001 @@ -75,7 +75,7 @@ " bne,pn %%icc, 1b\n" " cmp %%g7, 1\n" " bl,pn %%icc, 3f\n" -" membar #StoreStore\n" +" membar #StoreLoad | #StoreStore\n" "2:\n" " .subsection 2\n" "3: mov %0, %%g5\n" @@ -120,7 +120,7 @@ " bne,pn %%icc, 1b\n" " cmp %%g7, 1\n" " bl,pn %%icc, 3f\n" -" membar #StoreStore\n" +" membar #StoreLoad | #StoreStore\n" "2:\n" " .subsection 2\n" "3: mov %2, %%g5\n" @@ -173,7 +173,7 @@ " cmp %%g5, %%g7\n" " bne,pn %%icc, 1b\n" " mov 0, %0\n" -" membar #StoreStore\n" +" membar #StoreLoad | #StoreStore\n" "2:\n" : "=&r" (ret) : "r" (sem) @@ -207,7 +207,7 @@ " bne,pn %%icc, 1b\n" " addcc %%g7, 1, %%g0\n" " ble,pn %%icc, 3f\n" -" nop\n" +" membar #StoreLoad | #StoreStore\n" "2:\n" " .subsection 2\n" "3: mov %0, %%g5\n" diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/include/asm-sparc64/smp.h linux-2.5/include/asm-sparc64/smp.h --- linux-2.5.1/include/asm-sparc64/smp.h Fri Apr 27 05:17:26 2001 +++ linux-2.5/include/asm-sparc64/smp.h Thu Dec 13 16:32:37 2001 @@ -8,6 +8,7 @@ #include <linux/config.h> #include <linux/threads.h> +#include <linux/cache.h> #include <asm/asi.h> #include <asm/starfire.h> #include <asm/spitfire.h> @@ -34,7 +35,7 @@ /* Per processor Sparc parameters we need. */ /* Keep this a multiple of 64-bytes for cache reasons. */ -struct cpuinfo_sparc { +typedef struct { /* Dcache line 1 */ unsigned int __pad0; /* bh_count moved to irq_stat for consistency. KAO */ unsigned int multiplier; @@ -51,9 +52,9 @@ /* Dcache lines 3 and 4 */ unsigned int irq_worklists[16]; -}; +} ____cacheline_aligned cpuinfo_sparc; -extern struct cpuinfo_sparc cpu_data[NR_CPUS]; +extern cpuinfo_sparc cpu_data[NR_CPUS]; /* * Private routines/data diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/include/asm-sparc64/smplock.h linux-2.5/include/asm-sparc64/smplock.h --- linux-2.5.1/include/asm-sparc64/smplock.h Thu Mar 23 20:50:09 2000 +++ linux-2.5/include/asm-sparc64/smplock.h Thu Dec 13 16:32:37 2001 @@ -9,7 +9,9 @@ extern spinlock_t kernel_flag; -#define kernel_locked() spin_is_locked(&kernel_flag) +#define kernel_locked() \ + (spin_is_locked(&kernel_flag) &&\ + (current->lock_depth >= 0)) /* * Release global kernel lock and global interrupt lock diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/include/asm-sparc64/spinlock.h linux-2.5/include/asm-sparc64/spinlock.h --- linux-2.5.1/include/asm-sparc64/spinlock.h Fri Apr 27 05:17:26 2001 +++ linux-2.5/include/asm-sparc64/spinlock.h Thu Dec 13 16:32:37 2001 @@ -6,11 +6,13 @@ #ifndef __SPARC64_SPINLOCK_H #define __SPARC64_SPINLOCK_H +#include <linux/config.h> + #ifndef __ASSEMBLY__ /* To get debugging spinlocks which detect and catch - * deadlock situations, set DEBUG_SPINLOCKS in the sparc64 - * specific makefile and rebuild your kernel. + * deadlock situations, set CONFIG_DEBUG_SPINLOCK + * and rebuild your kernel. */ /* All of these locking primitives are expected to work properly @@ -26,7 +28,7 @@ * must be pre-V9 branches. */ -#ifndef SPIN_LOCK_DEBUG +#ifndef CONFIG_DEBUG_SPINLOCK typedef unsigned char spinlock_t; #define SPIN_LOCK_UNLOCKED 0 @@ -75,7 +77,7 @@ : "memory"); } -#else /* !(SPIN_LOCK_DEBUG) */ +#else /* !(CONFIG_DEBUG_SPINLOCK) */ typedef struct { unsigned char lock; @@ -101,11 +103,11 @@ #define spin_lock(lock) _do_spin_lock(lock, "spin_lock") #define spin_unlock(lock) _do_spin_unlock(lock) -#endif /* SPIN_LOCK_DEBUG */ +#endif /* CONFIG_DEBUG_SPINLOCK */ /* Multi-reader locks, these are much saner than the 32-bit Sparc ones... */ -#ifndef SPIN_LOCK_DEBUG +#ifndef CONFIG_DEBUG_SPINLOCK typedef unsigned int rwlock_t; #define RW_LOCK_UNLOCKED 0 @@ -121,7 +123,7 @@ #define write_lock(p) __write_lock(p) #define write_unlock(p) __write_unlock(p) -#else /* !(SPIN_LOCK_DEBUG) */ +#else /* !(CONFIG_DEBUG_SPINLOCK) */ typedef struct { unsigned long lock; @@ -164,7 +166,7 @@ __restore_flags(flags); \ } while(0) -#endif /* SPIN_LOCK_DEBUG */ +#endif /* CONFIG_DEBUG_SPINLOCK */ #endif /* !(__ASSEMBLY__) */ diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/include/asm-sparc64/spitfire.h linux-2.5/include/asm-sparc64/spitfire.h --- linux-2.5.1/include/asm-sparc64/spitfire.h Mon Oct 1 16:19:56 2001 +++ linux-2.5/include/asm-sparc64/spitfire.h Thu Dec 13 16:32:37 2001 @@ -1,4 +1,4 @@ -/* $Id: spitfire.h,v 1.16 2001/09/24 21:17:57 kanoj Exp $ +/* $Id: spitfire.h,v 1.18 2001/11/29 16:42:10 kanoj Exp $ * spitfire.h: SpitFire/BlackBird/Cheetah inline MMU operations. * * Copyright (C) 1996 David S. Miller (davem@caip.rutgers.edu) @@ -32,6 +32,8 @@ #define VIRT_WATCHPOINT 0x0000000000000038 #define PHYS_WATCHPOINT 0x0000000000000040 +#define SPITFIRE_HIGHEST_LOCKED_TLBENT (64 - 1) + #ifndef __ASSEMBLY__ enum ultra_tlb_layout { @@ -43,7 +45,6 @@ #define SPARC64_USE_STICK (tlb_type == cheetah) -#define SPITFIRE_HIGHEST_LOCKED_TLBENT (64 - 1) #define CHEETAH_HIGHEST_LOCKED_TLBENT (16 - 1) #define L1DCACHE_SIZE 0x4000 @@ -357,12 +358,17 @@ * 2 way assosciative, and holds 512 entries. The fourth TLB is for * instruction accesses to 8K non-locked translations, is 2 way * assosciative, and holds 128 entries. + * + * Cheetah has some bug where bogus data can be returned from + * ASI_{D,I}TLB_DATA_ACCESS loads, doing the load twice fixes + * the problem for me. -DaveM */ extern __inline__ unsigned long cheetah_get_ldtlb_data(int entry) { unsigned long data; - __asm__ __volatile__("ldxa [%1] %2, %0" + __asm__ __volatile__("ldxa [%1] %2, %%g0\n\t" + "ldxa [%1] %2, %0" : "=r" (data) : "r" ((0 << 16) | (entry << 3)), "i" (ASI_DTLB_DATA_ACCESS)); @@ -374,7 +380,8 @@ { unsigned long data; - __asm__ __volatile__("ldxa [%1] %2, %0" + __asm__ __volatile__("ldxa [%1] %2, %%g0\n\t" + "ldxa [%1] %2, %0" : "=r" (data) : "r" ((0 << 16) | (entry << 3)), "i" (ASI_ITLB_DATA_ACCESS)); @@ -430,7 +437,8 @@ { unsigned long data; - __asm__ __volatile__("ldxa [%1] %2, %0" + __asm__ __volatile__("ldxa [%1] %2, %%g0\n\t" + "ldxa [%1] %2, %0" : "=r" (data) : "r" ((2 << 16) | (entry << 3)), "i" (ASI_DTLB_DATA_ACCESS)); @@ -461,7 +469,8 @@ { unsigned long data; - __asm__ __volatile__("ldxa [%1] %2, %0" + __asm__ __volatile__("ldxa [%1] %2, %%g0\n\t" + "ldxa [%1] %2, %0" : "=r" (data) : "r" ((2 << 16) | (entry << 3)), "i" (ASI_ITLB_DATA_ACCESS)); diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/include/asm-sparc64/system.h linux-2.5/include/asm-sparc64/system.h --- linux-2.5.1/include/asm-sparc64/system.h Fri Sep 7 18:01:20 2001 +++ linux-2.5/include/asm-sparc64/system.h Thu Dec 13 16:32:37 2001 @@ -1,4 +1,4 @@ -/* $Id: system.h,v 1.64 2001/08/30 03:22:00 kanoj Exp $ */ +/* $Id: system.h,v 1.68 2001/11/18 00:12:56 davem Exp $ */ #ifndef __SPARC64_SYSTEM_H #define __SPARC64_SYSTEM_H @@ -145,6 +145,24 @@ #define flush_register_windows flushw_all #define prepare_to_switch flushw_all +#ifndef CONFIG_DEBUG_SPINLOCk +#define CHECK_LOCKS(PREV) do { } while(0) +#else /* CONFIG_DEBUG_SPINLOCk */ +#define CHECK_LOCKS(PREV) \ +if ((PREV)->thread.smp_lock_count) { \ + unsigned long rpc; \ + __asm__ __volatile__("mov %%i7, %0" : "=r" (rpc)); \ + printk(KERN_CRIT "(%s)[%d]: Sleeping with %d locks held!\n", \ + (PREV)->comm, (PREV)->pid, \ + (PREV)->thread.smp_lock_count); \ + printk(KERN_CRIT "(%s)[%d]: Last lock at %08x\n", \ + (PREV)->comm, (PREV)->pid, \ + (PREV)->thread.smp_lock_pc); \ + printk(KERN_CRIT "(%s)[%d]: Sched caller %016lx\n", \ + (PREV)->comm, (PREV)->pid, rpc); \ +} +#endif /* !(CONFIG_DEBUG_SPINLOCk) */ + /* See what happens when you design the chip correctly? * * We tell gcc we clobber all non-fixed-usage registers except @@ -155,7 +173,8 @@ * and 2 stores in this critical code path. -DaveM */ #define switch_to(prev, next, last) \ -do { if (current->thread.flags & SPARC_FLAG_PERFCTR) { \ +do { CHECK_LOCKS(prev); \ + if (current->thread.flags & SPARC_FLAG_PERFCTR) { \ unsigned long __tmp; \ read_pcr(__tmp); \ current->thread.pcr_reg = __tmp; \ @@ -276,7 +295,7 @@ __cmpxchg_u32(volatile int *m, int old, int new) { __asm__ __volatile__("cas [%2], %3, %0\n\t" - "membar #StoreStore | #StoreLoad" + "membar #StoreLoad | #StoreStore" : "=&r" (new) : "0" (new), "r" (m), "r" (old) : "memory"); @@ -288,7 +307,7 @@ __cmpxchg_u64(volatile long *m, unsigned long old, unsigned long new) { __asm__ __volatile__("casx [%2], %3, %0\n\t" - "membar #StoreStore | #StoreLoad" + "membar #StoreLoad | #StoreStore" : "=&r" (new) : "0" (new), "r" (m), "r" (old) : "memory"); diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/include/asm-sparc64/ttable.h linux-2.5/include/asm-sparc64/ttable.h --- linux-2.5.1/include/asm-sparc64/ttable.h Thu Apr 12 19:10:25 2001 +++ linux-2.5/include/asm-sparc64/ttable.h Thu Dec 13 16:32:37 2001 @@ -1,4 +1,4 @@ -/* $Id: ttable.h,v 1.16 2001/03/28 10:56:34 davem Exp $ */ +/* $Id: ttable.h,v 1.17 2001/11/28 23:32:16 davem Exp $ */ #ifndef _SPARC64_TTABLE_H #define _SPARC64_TTABLE_H @@ -29,6 +29,15 @@ clr %l6; \ nop; +#define TRAP_7INSNS(routine) \ + sethi %hi(109f), %g7; \ + ba,pt %xcc, etrap; \ +109: or %g7, %lo(109b), %g7; \ + call routine; \ + add %sp, STACK_BIAS + REGWIN_SZ, %o0; \ + ba,pt %xcc, rtrap; \ + clr %l6; + #define TRAP_SAVEFPU(routine) \ sethi %hi(109f), %g7; \ ba,pt %xcc, do_fptrap; \ @@ -43,6 +52,11 @@ ba,pt %xcc, routine; \ nop; \ nop; nop; nop; nop; nop; nop; + +#define TRAP_NOSAVE_7INSNS(routine) \ + ba,pt %xcc, routine; \ + nop; \ + nop; nop; nop; nop; nop; #define TRAPTL1(routine) \ sethi %hi(109f), %g7; \ diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/include/linux/acct.h linux-2.5/include/linux/acct.h --- linux-2.5.1/include/linux/acct.h Sun Dec 16 23:43:25 2001 +++ linux-2.5/include/linux/acct.h Mon Dec 31 21:53:32 2001 @@ -76,7 +76,7 @@ #include <linux/config.h> #ifdef CONFIG_BSD_PROCESS_ACCT -extern void acct_auto_close(kdev_t dev); +extern void acct_auto_close(struct super_block *sb); extern int acct_process(long exitcode); #else #define acct_auto_close(x) do { } while (0) diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/include/linux/amigaffs.h linux-2.5/include/linux/amigaffs.h --- linux-2.5.1/include/linux/amigaffs.h Sun Dec 16 20:23:05 2001 +++ linux-2.5/include/linux/amigaffs.h Thu Dec 27 15:56:12 2001 @@ -23,8 +23,7 @@ static inline void affs_set_blocksize(struct super_block *sb, int size) { - set_blocksize(sb->s_dev, size); - sb->s_blocksize = size; + sb_set_blocksize(sb, size); } static inline struct buffer_head * affs_bread(struct super_block *sb, int block) diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/include/linux/bio.h linux-2.5/include/linux/bio.h --- linux-2.5.1/include/linux/bio.h Sun Dec 16 23:43:49 2001 +++ linux-2.5/include/linux/bio.h Mon Dec 31 21:53:19 2001 @@ -35,6 +35,7 @@ #endif #define BIO_MAX_SECTORS 128 +#define BIO_MAX_SIZE (BIO_MAX_SECTORS << 9) /* * was unsigned short, but we might as well be ready for > 64kB I/O pages diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/include/linux/blk.h linux-2.5/include/linux/blk.h --- linux-2.5.1/include/linux/blk.h Sun Dec 16 23:45:06 2001 +++ linux-2.5/include/linux/blk.h Mon Dec 31 21:53:19 2001 @@ -20,7 +20,6 @@ #define INITRD_MINOR 250 /* shouldn't collide with /dev/ram* too soon ... */ extern unsigned long initrd_start,initrd_end; -extern int mount_initrd; /* zero if initrd should not be mounted */ extern int initrd_below_start_ok; /* 1 if it is not an error if initrd_start < memory_start */ extern int rd_doload; /* 1 = load ramdisk, 0 = don't load */ extern int rd_prompt; /* 1 = prompt for ramdisk, 0 = don't prompt */ @@ -54,6 +53,9 @@ while ((rq = __elv_next_request(q))) { rq->flags |= REQ_STARTED; + + if (&rq->queuelist == q->last_merge) + q->last_merge = NULL; if ((rq->flags & REQ_DONTPREP) || !q->prep_rq_fn) break; diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/include/linux/blkdev.h linux-2.5/include/linux/blkdev.h --- linux-2.5.1/include/linux/blkdev.h Sun Dec 16 23:43:29 2001 +++ linux-2.5/include/linux/blkdev.h Mon Dec 31 21:53:19 2001 @@ -6,7 +6,7 @@ #include <linux/genhd.h> #include <linux/tqueue.h> #include <linux/list.h> -#include <linux/mm.h> +#include <linux/pagemap.h> #include <asm/scatterlist.h> @@ -130,16 +130,17 @@ struct request_queue { /* - * the queue request freelist, one for reads and one for writes - */ - struct request_list rq[2]; - - /* * Together with queue_head for cacheline sharing */ struct list_head queue_head; + struct list_head *last_merge; elevator_t elevator; + /* + * the queue request freelist, one for reads and one for writes + */ + struct request_list rq[2]; + request_fn_proc *request_fn; merge_request_fn *back_merge_fn; merge_request_fn *front_merge_fn; @@ -195,8 +196,7 @@ #define RQ_SCSI_DISCONNECTING 0xffe0 #define QUEUE_FLAG_PLUGGED 0 /* queue is plugged */ -#define QUEUE_FLAG_NOSPLIT 1 /* can process bio over several goes */ -#define QUEUE_FLAG_CLUSTER 2 /* cluster several segments into 1 */ +#define QUEUE_FLAG_CLUSTER 1 /* cluster several segments into 1 */ #define blk_queue_plugged(q) test_bit(QUEUE_FLAG_PLUGGED, &(q)->queue_flags) #define blk_mark_plugged(q) set_bit(QUEUE_FLAG_PLUGGED, &(q)->queue_flags) @@ -206,6 +206,14 @@ #define rq_data_dir(rq) ((rq)->flags & 1) /* + * mergeable request must not have _NOMERGE or _BARRIER bit set, nor may + * it already be started by driver. + */ +#define rq_mergeable(rq) \ + (!((rq)->flags & (REQ_NOMERGE | REQ_STARTED | REQ_BARRIER)) \ + && ((rq)->flags & REQ_CMD)) + +/* * noop, requests are automagically marked as active/inactive by I/O * scheduler -- see elv_next_request */ @@ -213,27 +221,25 @@ extern unsigned long blk_max_low_pfn, blk_max_pfn; -#define BLK_BOUNCE_HIGH (blk_max_low_pfn << PAGE_SHIFT) -#define BLK_BOUNCE_ANY (blk_max_pfn << PAGE_SHIFT) -#define BLK_BOUNCE_ISA (ISA_DMA_THRESHOLD) - -#ifdef CONFIG_HIGHMEM +/* + * standard bounce addresses: + * + * BLK_BOUNCE_HIGH : bounce all highmem pages + * BLK_BOUNCE_ANY : don't bounce anything + * BLK_BOUNCE_ISA : bounce pages above ISA DMA boundary + */ +#define BLK_BOUNCE_HIGH (blk_max_low_pfn << PAGE_SHIFT) +#define BLK_BOUNCE_ANY (blk_max_pfn << PAGE_SHIFT) +#define BLK_BOUNCE_ISA (ISA_DMA_THRESHOLD) +extern int init_emergency_isa_pool(void); extern void create_bounce(unsigned long pfn, int gfp, struct bio **bio_orig); -extern void init_emergency_isa_pool(void); extern inline void blk_queue_bounce(request_queue_t *q, struct bio **bio) { create_bounce(q->bounce_pfn, q->bounce_gfp, bio); } -#else /* CONFIG_HIGHMEM */ - -#define blk_queue_bounce(q, bio) do { } while (0) -#define init_emergency_isa_pool() do { } while (0) - -#endif /* CONFIG_HIGHMEM */ - #define rq_for_each_bio(bio, rq) \ if ((rq->bio)) \ for (bio = (rq)->bio; bio; bio = bio->bi_next) @@ -275,9 +281,13 @@ extern void blk_recount_segments(request_queue_t *, struct bio *); extern inline int blk_phys_contig_segment(request_queue_t *q, struct bio *, struct bio *); extern inline int blk_hw_contig_segment(request_queue_t *q, struct bio *, struct bio *); -extern void blk_queue_assign_lock(request_queue_t *q, spinlock_t *); - extern int block_ioctl(kdev_t, unsigned int, unsigned long); +extern int ll_10byte_cmd_build(request_queue_t *, struct request *); + +/* + * get ready for proper ref counting + */ +#define blk_put_queue(q) do { } while (0) /* * Access functions for manipulating queue properties @@ -292,6 +302,9 @@ extern void blk_queue_max_segment_size(request_queue_t *q, unsigned int); extern void blk_queue_hardsect_size(request_queue_t *q, unsigned short); extern void blk_queue_segment_boundary(request_queue_t *q, unsigned long); +extern void blk_queue_assign_lock(request_queue_t *q, spinlock_t *); +extern void blk_queue_prep_rq(request_queue_t *q, prep_rq_fn *pfn); + extern int blk_rq_map_sg(request_queue_t *, struct request *, struct scatterlist *); extern void blk_dump_rq_flags(struct request *, char *); extern void generic_unplug_device(void *); @@ -366,6 +379,15 @@ retval = blksize_size[major][minor]; } return retval; +} + +typedef struct {struct page *v;} Sector; + +unsigned char *read_dev_sector(struct block_device *, unsigned long, Sector *); + +static inline void put_dev_sector(Sector p) +{ + page_cache_release(p.v); } #endif diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/include/linux/console.h linux-2.5/include/linux/console.h --- linux-2.5.1/include/linux/console.h Sun Dec 16 23:43:25 2001 +++ linux-2.5/include/linux/console.h Mon Dec 31 21:53:29 2001 @@ -97,7 +97,6 @@ void (*write)(struct console *, const char *, unsigned); int (*read)(struct console *, const char *, unsigned); kdev_t (*device)(struct console *); - int (*wait_key)(struct console *); void (*unblank)(void); int (*setup)(struct console *, char *); short flags; diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/include/linux/cyclades.h linux-2.5/include/linux/cyclades.h --- linux-2.5.1/include/linux/cyclades.h Fri May 12 18:22:31 2000 +++ linux-2.5/include/linux/cyclades.h Fri Dec 28 01:51:53 2001 @@ -503,6 +503,7 @@ #endif /* Per card data structure */ +struct resource; struct cyclades_card { unsigned long base_phys; unsigned long ctl_phys; @@ -514,6 +515,8 @@ int nports; /* Number of ports in the card */ int bus_index; /* address shift - 0 for ISA, 1 for PCI */ int intr_enabled; /* FW Interrupt flag - 0 disabled, 1 enabled */ + struct resource *resource; + unsigned long res_start, res_len; #ifdef __KERNEL__ spinlock_t card_lock; #else diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/include/linux/devfs_fs.h linux-2.5/include/linux/devfs_fs.h --- linux-2.5.1/include/linux/devfs_fs.h Fri Sep 21 17:55:23 2001 +++ linux-2.5/include/linux/devfs_fs.h Thu Dec 27 21:41:29 2001 @@ -26,7 +26,7 @@ binary interface will change */ struct devfsd_notify_struct -{ +{ /* Use native C types to ensure same types in kernel and user space */ unsigned int type; /* DEVFSD_NOTIFY_* value */ unsigned int mode; /* Mode of the inode or device entry */ unsigned int major; /* Major number of device entry */ diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/include/linux/devfs_fs_kernel.h linux-2.5/include/linux/devfs_fs_kernel.h --- linux-2.5.1/include/linux/devfs_fs_kernel.h Sun Dec 16 23:43:25 2001 +++ linux-2.5/include/linux/devfs_fs_kernel.h Mon Dec 31 21:53:19 2001 @@ -37,8 +37,7 @@ */ #define DEVFS_FL_REMOVABLE 0x010 /* This is a removable media device */ #define DEVFS_FL_WAIT 0x020 /* Wait for devfsd to finish */ -#define DEVFS_FL_NO_PERSISTENCE 0x040 /* Forget changes after unregister */ -#define DEVFS_FL_CURRENT_OWNER 0x080 /* Set initial ownership to current */ +#define DEVFS_FL_CURRENT_OWNER 0x040 /* Set initial ownership to current */ #define DEVFS_FL_DEFAULT DEVFS_FL_NONE @@ -61,6 +60,7 @@ #define UNIQUE_NUMBERSPACE_INITIALISER {SPIN_LOCK_UNLOCKED, 0, 0, 0, NULL} +extern void devfs_put (devfs_handle_t de); extern devfs_handle_t devfs_register (devfs_handle_t dir, const char *name, unsigned int flags, unsigned int major, unsigned int minor, @@ -71,6 +71,9 @@ devfs_handle_t *handle, void *info); extern devfs_handle_t devfs_mk_dir (devfs_handle_t dir, const char *name, void *info); +extern devfs_handle_t devfs_get_handle (devfs_handle_t dir, const char *name, + unsigned int major,unsigned int minor, + char type, int traverse_symlinks); extern devfs_handle_t devfs_find_handle (devfs_handle_t dir, const char *name, unsigned int major,unsigned int minor, char type, int traverse_symlinks); @@ -81,6 +84,7 @@ extern devfs_handle_t devfs_get_handle_from_inode (struct inode *inode); extern int devfs_generate_path (devfs_handle_t de, char *path, int buflen); extern void *devfs_get_ops (devfs_handle_t de); +extern void devfs_put_ops (devfs_handle_t de); extern int devfs_set_file_size (devfs_handle_t de, unsigned long size); extern void *devfs_get_info (devfs_handle_t de); extern int devfs_set_info (devfs_handle_t de, void *info); @@ -112,7 +116,6 @@ int number); extern void mount_devfs_fs (void); -extern void devfs_make_root (const char *name); #else /* CONFIG_DEVFS_FS */ @@ -123,6 +126,10 @@ #define UNIQUE_NUMBERSPACE_INITIALISER {0} +static inline void devfs_put (devfs_handle_t de) +{ + return; +} static inline devfs_handle_t devfs_register (devfs_handle_t dir, const char *name, unsigned int flags, @@ -148,6 +155,15 @@ { return NULL; } +static inline devfs_handle_t devfs_get_handle (devfs_handle_t dir, + const char *name, + unsigned int major, + unsigned int minor, + char type, + int traverse_symlinks) +{ + return NULL; +} static inline devfs_handle_t devfs_find_handle (devfs_handle_t dir, const char *name, unsigned int major, @@ -183,6 +199,10 @@ { return NULL; } +static inline void devfs_put_ops (devfs_handle_t de) +{ + return; +} static inline int devfs_set_file_size (devfs_handle_t de, unsigned long size) { return -ENOSYS; @@ -288,10 +308,6 @@ } static inline void mount_devfs_fs (void) -{ - return; -} -static inline void devfs_make_root (const char *name) { return; } diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/include/linux/eeprom.h linux-2.5/include/linux/eeprom.h --- linux-2.5.1/include/linux/eeprom.h Thu Sep 20 21:20:14 2001 +++ linux-2.5/include/linux/eeprom.h Thu Dec 13 16:32:37 2001 @@ -1,6 +1,7 @@ /* credit winbond-840.c */ #include <asm/io.h> + struct eeprom_ops { void (*set_cs)(void *ee); void (*clear_cs)(void *ee); diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/include/linux/elevator.h linux-2.5/include/linux/elevator.h --- linux-2.5.1/include/linux/elevator.h Wed Nov 28 16:49:23 2001 +++ linux-2.5/include/linux/elevator.h Thu Dec 20 19:14:29 2001 @@ -1,12 +1,8 @@ #ifndef _LINUX_ELEVATOR_H #define _LINUX_ELEVATOR_H -typedef void (elevator_fn) (struct request *, elevator_t *, - struct list_head *, - struct list_head *, int); - typedef int (elevator_merge_fn) (request_queue_t *, struct request **, - struct list_head *, struct bio *); + struct bio *); typedef void (elevator_merge_cleanup_fn) (request_queue_t *, struct request *, int); @@ -21,8 +17,7 @@ struct elevator_s { - int read_latency; - int write_latency; + int latency[2]; elevator_merge_fn *elevator_merge_fn; elevator_merge_cleanup_fn *elevator_merge_cleanup_fn; @@ -35,11 +30,11 @@ elevator_exit_fn *elevator_exit_fn; }; -int elevator_noop_merge(request_queue_t *, struct request **, struct list_head *, struct bio *); +int elevator_noop_merge(request_queue_t *, struct request **, struct bio *); void elevator_noop_merge_cleanup(request_queue_t *, struct request *, int); void elevator_noop_merge_req(struct request *, struct request *); -int elevator_linus_merge(request_queue_t *, struct request **, struct list_head *, struct bio *); +int elevator_linus_merge(request_queue_t *, struct request **, struct bio *); void elevator_linus_merge_cleanup(request_queue_t *, struct request *, int); void elevator_linus_merge_req(struct request *, struct request *); int elv_linus_init(request_queue_t *, elevator_t *); @@ -69,32 +64,7 @@ #define ELEVATOR_FRONT_MERGE 1 #define ELEVATOR_BACK_MERGE 2 -/* - * This is used in the elevator algorithm. We don't prioritise reads - * over writes any more --- although reads are more time-critical than - * writes, by treating them equally we increase filesystem throughput. - * This turns out to give better overall performance. -- sct - */ -#define IN_ORDER(s1,s2) \ - ((((s1)->rq_dev == (s2)->rq_dev && \ - (s1)->sector < (s2)->sector)) || \ - (s1)->rq_dev < (s2)->rq_dev) - -#define BHRQ_IN_ORDER(bh, rq) \ - ((((bh)->b_rdev == (rq)->rq_dev && \ - (bh)->b_rsector < (rq)->sector)) || \ - (bh)->b_rdev < (rq)->rq_dev) - -static inline int elevator_request_latency(elevator_t * elevator, int rw) -{ - int latency; - - latency = elevator->read_latency; - if (rw != READ) - latency = elevator->write_latency; - - return latency; -} +#define elevator_request_latency(e, rw) ((e)->latency[(rw) & 1]) /* * will change once we move to a more complex data structure than a simple @@ -116,9 +86,7 @@ #define ELEVATOR_NOOP \ ((elevator_t) { \ - 0, /* read_latency */ \ - 0, /* write_latency */ \ - \ + { 0, 0}, \ elevator_noop_merge, /* elevator_merge_fn */ \ elevator_noop_merge_cleanup, /* elevator_merge_cleanup_fn */ \ elevator_noop_merge_req, /* elevator_merge_req_fn */ \ @@ -130,9 +98,7 @@ #define ELEVATOR_LINUS \ ((elevator_t) { \ - 8192, /* read passovers */ \ - 16384, /* write passovers */ \ - \ + { 8192, 16384 }, \ elevator_linus_merge, /* elevator_merge_fn */ \ elevator_linus_merge_cleanup, /* elevator_merge_cleanup_fn */ \ elevator_linus_merge_req, /* elevator_merge_req_fn */ \ diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/include/linux/ext2_fs_sb.h linux-2.5/include/linux/ext2_fs_sb.h --- linux-2.5.1/include/linux/ext2_fs_sb.h Fri Dec 29 22:36:44 2000 +++ linux-2.5/include/linux/ext2_fs_sb.h Fri Dec 28 00:06:33 2001 @@ -56,6 +56,7 @@ int s_desc_per_block_bits; int s_inode_size; int s_first_ino; + u32 s_next_generation; }; #endif /* _LINUX_EXT2_FS_SB */ diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/include/linux/ext3_fs.h linux-2.5/include/linux/ext3_fs.h --- linux-2.5.1/include/linux/ext3_fs.h Fri Nov 9 22:25:04 2001 +++ linux-2.5/include/linux/ext3_fs.h Thu Dec 13 16:32:37 2001 @@ -36,8 +36,8 @@ /* * The second extended file system version */ -#define EXT3FS_DATE "06 Nov 2001" -#define EXT3FS_VERSION "2.4-0.9.15" +#define EXT3FS_DATE "02 Dec 2001" +#define EXT3FS_VERSION "2.4-0.9.16" /* * Debug code @@ -577,10 +577,6 @@ ~EXT3_DIR_ROUND) #ifdef __KERNEL__ - -/* Filesize hard limits for 64-bit file offsets */ -extern long long ext3_max_sizes[]; - /* * Describe an inode's exact location on disk and in memory */ @@ -603,9 +599,6 @@ # define ATTRIB_NORET __attribute__((noreturn)) # define NORET_AND noreturn, -/* acl.c */ -extern int ext3_permission (struct inode *, int); - /* balloc.c */ extern int ext3_bg_has_super(struct super_block *sb, int group); extern unsigned long ext3_bg_num_gdb(struct super_block *sb, int group); @@ -619,16 +612,10 @@ unsigned int block_group, struct buffer_head ** bh); -/* bitmap.c */ -extern unsigned long ext3_count_free (struct buffer_head *, unsigned); - /* dir.c */ extern int ext3_check_dir_entry(const char *, struct inode *, struct ext3_dir_entry_2 *, struct buffer_head *, unsigned long); - -/* file.c */ - /* fsync.c */ extern int ext3_sync_file (struct file *, struct dentry *, int); @@ -638,9 +625,9 @@ extern struct inode * ext3_orphan_get (struct super_block *, ino_t); extern unsigned long ext3_count_free_inodes (struct super_block *); extern void ext3_check_inodes_bitmap (struct super_block *); +extern unsigned long ext3_count_free (struct buffer_head *, unsigned); /* inode.c */ - extern struct buffer_head * ext3_getblk (handle_t *, struct inode *, long, int, int *); extern struct buffer_head * ext3_bread (handle_t *, struct inode *, int, int, int *); @@ -654,13 +641,13 @@ extern void ext3_discard_prealloc (struct inode *); extern void ext3_dirty_inode(struct inode *); extern int ext3_change_inode_journal_flag(struct inode *, int); +extern void ext3_truncate (struct inode *); /* ioctl.c */ extern int ext3_ioctl (struct inode *, struct file *, unsigned int, unsigned long); /* namei.c */ -extern struct inode_operations ext3_dir_inode_operations; extern int ext3_orphan_add(handle_t *, struct inode *); extern int ext3_orphan_del(handle_t *, struct inode *); @@ -684,9 +671,6 @@ extern struct super_block * ext3_read_super (struct super_block *,void *,int); extern int ext3_statfs (struct super_block *, struct statfs *); -/* truncate.c */ -extern void ext3_truncate (struct inode *); - #define ext3_std_error(sb, errno) \ do { \ if ((errno)) \ @@ -705,10 +689,15 @@ extern struct inode_operations ext3_file_inode_operations; extern struct file_operations ext3_file_operations; +/* inode.c */ +extern struct address_space_operations ext3_aops; + +/* namei.c */ +extern struct inode_operations ext3_dir_inode_operations; + /* symlink.c */ extern struct inode_operations ext3_fast_symlink_inode_operations; -extern struct address_space_operations ext3_aops; #endif /* __KERNEL__ */ diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/include/linux/ext3_jbd.h linux-2.5/include/linux/ext3_jbd.h --- linux-2.5.1/include/linux/ext3_jbd.h Fri Nov 9 22:25:04 2001 +++ linux-2.5/include/linux/ext3_jbd.h Thu Dec 13 16:32:37 2001 @@ -196,9 +196,22 @@ */ static inline handle_t *ext3_journal_start(struct inode *inode, int nblocks) { + journal_t *journal; + if (inode->i_sb->s_flags & MS_RDONLY) return ERR_PTR(-EROFS); - return journal_start(EXT3_JOURNAL(inode), nblocks); + + /* Special case here: if the journal has aborted behind our + * backs (eg. EIO in the commit thread), then we still need to + * take the FS itself readonly cleanly. */ + journal = EXT3_JOURNAL(inode); + if (is_journal_aborted(journal)) { + ext3_abort(inode->i_sb, __FUNCTION__, + "Detected aborted journal"); + return ERR_PTR(-EROFS); + } + + return journal_start(journal, nblocks); } static inline handle_t * diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/include/linux/fb.h linux-2.5/include/linux/fb.h --- linux-2.5.1/include/linux/fb.h Mon Dec 11 21:16:53 2000 +++ linux-2.5/include/linux/fb.h Mon Dec 31 21:58:47 2001 @@ -241,6 +241,39 @@ __u32 reserved[4]; /* reserved for future compatibility */ }; +/* Internal HW accel */ +#define ROP_COPY 0 +#define ROP_XOR 1 + +struct fb_copyarea { + __u32 sx; /* screen-relative */ + __u32 sy; + __u32 width; + __u32 height; + __u32 dx; + __u32 dy; +}; + +struct fb_fillrect { + __u32 dx; /* screen-relative */ + __u32 dy; + __u32 width; + __u32 height; + __u32 color; + __u32 rop; +}; + +struct fb_image { + __u32 width; /* Size of image */ + __u32 height; + __u16 dx; /* Where to place image */ + __u16 dy; + __u32 fg_color; /* Only used when a mono bitmap */ + __u32 bg_color; + __u8 depth; /* Dpeth of the image */ + char *data; /* Pointer to image data */ +}; + #ifdef __KERNEL__ #if 1 /* to go away in 2.5.0 */ @@ -250,10 +283,10 @@ #endif #include <linux/fs.h> +#include <linux/poll.h> #include <linux/init.h> #include <linux/devfs_fs_kernel.h> - struct fb_info; struct fb_info_gen; struct vm_area_struct; @@ -283,9 +316,25 @@ /* set colormap */ int (*fb_set_cmap)(struct fb_cmap *cmap, int kspc, int con, struct fb_info *info); - /* pan display (optional) */ - int (*fb_pan_display)(struct fb_var_screeninfo *var, int con, - struct fb_info *info); + /* checks var and creates a par based on it */ + int (*fb_check_var)(struct fb_var_screeninfo *var, struct fb_info *info); + /* set the video mode according to par */ + int (*fb_set_par)(struct fb_info *info); + /* set color register */ + int (*fb_setcolreg)(unsigned regno, unsigned red, unsigned green, + unsigned blue, unsigned transp, struct fb_info *info); + /* blank display */ + int (*fb_blank)(int blank, struct fb_info *info); + /* pan display */ + int (*fb_pan_display)(struct fb_var_screeninfo *var, int con, struct fb_info *info); + /* draws a rectangle */ + void (*fb_fillrect)(struct fb_info *p, struct fb_fillrect *rect); + /* Copy data from area to another */ + void (*fb_copyarea)(struct fb_info *p, struct fb_copyarea *region); + /* Draws a image to the display */ + void (*fb_imageblit)(struct fb_info *p, struct fb_image *image); + /* perform polling on fb device */ + int (*fb_poll)(struct fb_info *info, poll_table *wait); /* perform fb specific ioctl (optional) */ int (*fb_ioctl)(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg, int con, struct fb_info *info); @@ -309,6 +358,7 @@ char *screen_base; /* Virtual address */ struct display *disp; /* initial display variable */ struct vc_data *display_fg; /* Console visible on this display */ + int currcon; /* Current VC. */ char fontname[40]; /* default font name */ devfs_handle_t devfs_handle; /* Devfs handle for new name */ devfs_handle_t devfs_lhandle; /* Devfs handle for compat. symlink */ @@ -387,6 +437,9 @@ struct fb_info *info); extern int fbgen_pan_display(struct fb_var_screeninfo *var, int con, struct fb_info *info); +extern void cfb_fillrect(struct fb_info *p, struct fb_fillrect *rect); +extern void cfb_copyarea(struct fb_info *p, struct fb_copyarea *region); +extern void cfb_imageblit(struct fb_info *p, struct fb_image *image); /* * Helper functions @@ -400,6 +453,7 @@ extern int fbgen_switch(int con, struct fb_info *info); extern void fbgen_blank(int blank, struct fb_info *info); +extern void fbgen2_set_disp(int con, struct fb_info *info); /* drivers/video/fbmem.c */ extern int register_framebuffer(struct fb_info *fb_info); diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/include/linux/file.h linux-2.5/include/linux/file.h --- linux-2.5.1/include/linux/file.h Wed Aug 23 18:22:26 2000 +++ linux-2.5/include/linux/file.h Mon Dec 31 21:53:39 2001 @@ -5,6 +5,8 @@ #ifndef __LINUX_FILE_H #define __LINUX_FILE_H +#include <linux/sched.h> + extern void FASTCALL(fput(struct file *)); extern struct file * FASTCALL(fget(unsigned int fd)); diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/include/linux/fs.h linux-2.5/include/linux/fs.h --- linux-2.5.1/include/linux/fs.h Sun Dec 16 23:43:25 2001 +++ linux-2.5/include/linux/fs.h Mon Dec 31 21:53:19 2001 @@ -982,6 +982,7 @@ extern struct vfsmount *kern_mount(struct file_system_type *); extern int may_umount(struct vfsmount *); extern long do_mount(char *, char *, char *, unsigned long, void *); +extern void umount_tree(struct vfsmount *); #define kern_umount mntput @@ -1102,7 +1103,7 @@ extern int try_to_free_buffers(struct page *, unsigned int); extern void refile_buffer(struct buffer_head * buf); -extern void create_empty_buffers(struct page *, kdev_t, unsigned long); +extern void create_empty_buffers(struct page *, unsigned long); extern void end_buffer_io_sync(struct buffer_head *bh, int uptodate); /* reiserfs_writepage needs this */ @@ -1378,6 +1379,8 @@ __bforget(buf); } extern int set_blocksize(kdev_t, int); +extern int sb_set_blocksize(struct super_block *, int); +extern int sb_min_blocksize(struct super_block *, int); extern struct buffer_head * bread(kdev_t, int, int); static inline struct buffer_head * sb_bread(struct super_block *sb, int block) { @@ -1390,6 +1393,12 @@ static inline struct buffer_head * sb_get_hash_table(struct super_block *sb, int block) { return get_hash_table(sb->s_dev, block, sb->s_blocksize); +} +static inline void map_bh(struct buffer_head *bh, struct super_block *sb, int block) +{ + bh->b_state |= 1 << BH_Mapped; + bh->b_dev = sb->s_dev; + bh->b_blocknr = block; } extern void wakeup_bdflush(void); extern void put_unused_buffer_head(struct buffer_head * bh); diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/include/linux/generic_serial.h linux-2.5/include/linux/generic_serial.h --- linux-2.5.1/include/linux/generic_serial.h Fri Sep 7 16:28:38 2001 +++ linux-2.5/include/linux/generic_serial.h Fri Dec 28 01:15:11 2001 @@ -12,9 +12,6 @@ #ifndef GENERIC_SERIAL_H #define GENERIC_SERIAL_H - - - struct real_driver { void (*disable_tx_interrupts) (void *); void (*enable_tx_interrupts) (void *); @@ -98,7 +95,7 @@ struct termios * old_termios); int gs_init_port(struct gs_port *port); int gs_setserial(struct gs_port *port, struct serial_struct *sp); -void gs_getserial(struct gs_port *port, struct serial_struct *sp); +int gs_getserial(struct gs_port *port, struct serial_struct *sp); void gs_got_break(struct gs_port *port); extern int gs_debug; diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/include/linux/gfp.h linux-2.5/include/linux/gfp.h --- linux-2.5.1/include/linux/gfp.h Thu Jan 1 00:00:00 1970 +++ linux-2.5/include/linux/gfp.h Mon Dec 31 21:53:19 2001 @@ -0,0 +1,81 @@ +#ifndef __LINUX_GFP_H +#define __LINUX_GFP_H + +#include <linux/mmzone.h> +#include <linux/stddef.h> +#include <linux/linkage.h> +/* + * GFP bitmasks.. + */ +/* Zone modifiers in GFP_ZONEMASK (see linux/mmzone.h - low four bits) */ +#define __GFP_DMA 0x01 +#define __GFP_HIGHMEM 0x02 + +/* Action modifiers - doesn't change the zoning */ +#define __GFP_WAIT 0x10 /* Can wait and reschedule? */ +#define __GFP_HIGH 0x20 /* Should access emergency pools? */ +#define __GFP_IO 0x40 /* Can start low memory physical IO? */ +#define __GFP_HIGHIO 0x80 /* Can start high mem physical IO? */ +#define __GFP_FS 0x100 /* Can call down to low-level FS? */ + +#define GFP_NOHIGHIO (__GFP_HIGH | __GFP_WAIT | __GFP_IO) +#define GFP_NOIO (__GFP_HIGH | __GFP_WAIT) +#define GFP_NOFS (__GFP_HIGH | __GFP_WAIT | __GFP_IO | __GFP_HIGHIO) +#define GFP_ATOMIC (__GFP_HIGH) +#define GFP_USER ( __GFP_WAIT | __GFP_IO | __GFP_HIGHIO | __GFP_FS) +#define GFP_HIGHUSER ( __GFP_WAIT | __GFP_IO | __GFP_HIGHIO | __GFP_FS | __GFP_HIGHMEM) +#define GFP_KERNEL (__GFP_HIGH | __GFP_WAIT | __GFP_IO | __GFP_HIGHIO | __GFP_FS) +#define GFP_NFS (__GFP_HIGH | __GFP_WAIT | __GFP_IO | __GFP_HIGHIO | __GFP_FS) +#define GFP_KSWAPD ( __GFP_WAIT | __GFP_IO | __GFP_HIGHIO | __GFP_FS) + +/* Flag - indicates that the buffer will be suitable for DMA. Ignored on some + platforms, used as appropriate on others */ + +#define GFP_DMA __GFP_DMA + +/* + * There is only one page-allocator function, and two main namespaces to + * it. The alloc_page*() variants return 'struct page *' and as such + * can allocate highmem pages, the *get*page*() variants return + * virtual kernel addresses to the allocated page(s). + */ +extern struct page * FASTCALL(_alloc_pages(unsigned int gfp_mask, unsigned int order)); +extern struct page * FASTCALL(__alloc_pages(unsigned int gfp_mask, unsigned int order, zonelist_t *zonelist)); +extern struct page * alloc_pages_node(int nid, unsigned int gfp_mask, unsigned int order); + +static inline struct page * alloc_pages(unsigned int gfp_mask, unsigned int order) +{ + /* + * Gets optimized away by the compiler. + */ + if (order >= MAX_ORDER) + return NULL; + return _alloc_pages(gfp_mask, order); +} + +#define alloc_page(gfp_mask) alloc_pages(gfp_mask, 0) + +extern unsigned long FASTCALL(__get_free_pages(unsigned int gfp_mask, unsigned int order)); +extern unsigned long FASTCALL(get_zeroed_page(unsigned int gfp_mask)); + +#define __get_free_page(gfp_mask) \ + __get_free_pages((gfp_mask),0) + +#define __get_dma_pages(gfp_mask, order) \ + __get_free_pages((gfp_mask) | GFP_DMA,(order)) + +/* + * The old interface name will be removed in 2.5: + */ +#define get_free_page get_zeroed_page + +/* + * There is only one 'core' page-freeing function. + */ +extern void FASTCALL(__free_pages(struct page *page, unsigned int order)); +extern void FASTCALL(free_pages(unsigned long addr, unsigned int order)); + +#define __free_page(page) __free_pages((page), 0) +#define free_page(addr) free_pages((addr),0) + +#endif /* __LINUX_GFP_H */ diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/include/linux/highmem.h linux-2.5/include/linux/highmem.h --- linux-2.5.1/include/linux/highmem.h Sun Dec 16 23:44:04 2001 +++ linux-2.5/include/linux/highmem.h Mon Dec 31 21:53:19 2001 @@ -132,15 +132,4 @@ kunmap_atomic(vto, KM_USER1); } -static inline void copy_highpage(struct page *to, struct page *from) -{ - char *vfrom, *vto; - - vfrom = kmap(from); - vto = kmap(to); - copy_page(vto, vfrom); - kunmap(from); - kunmap(to); -} - #endif /* _LINUX_HIGHMEM_H */ diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/include/linux/i8k.h linux-2.5/include/linux/i8k.h --- linux-2.5.1/include/linux/i8k.h Sat Nov 3 01:46:47 2001 +++ linux-2.5/include/linux/i8k.h Thu Dec 13 16:32:37 2001 @@ -1,5 +1,5 @@ /* - * i8k.h -- Linux driver for accessing the SMM BIOS on Dell I8000 laptops + * i8k.h -- Linux driver for accessing the SMM BIOS on Dell laptops * * Copyright (C) 2001 Massimo Dal Zotto <dz@debian.org> * @@ -36,9 +36,9 @@ #define I8K_FAN_HIGH 2 #define I8K_FAN_MAX I8K_FAN_HIGH -#define I8K_VOL_UP 0x01 -#define I8K_VOL_DOWN 0x02 -#define I8K_VOL_MUTE 0x03 +#define I8K_VOL_UP 1 +#define I8K_VOL_DOWN 2 +#define I8K_VOL_MUTE 4 #define I8K_AC 1 #define I8K_BATTERY 0 diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/include/linux/init.h linux-2.5/include/linux/init.h --- linux-2.5.1/include/linux/init.h Sun Dec 16 23:43:25 2001 +++ linux-2.5/include/linux/init.h Mon Dec 31 21:53:19 2001 @@ -111,7 +111,7 @@ */ #define module_exit(x) __exitcall(x); -#else +#else /* MODULE */ #define __init #define __exit @@ -141,7 +141,7 @@ #define __setup(str,func) /* nothing */ -#endif +#endif /* !MODULE */ #ifdef CONFIG_HOTPLUG #define __devinit @@ -153,6 +153,18 @@ #define __devinitdata __initdata #define __devexit __exit #define __devexitdata __exitdata +#endif + +/* Functions marked as __devexit may be discarded at kernel link time, depending + on config options. Newer versions of binutils detect references from + retained sections to discarded sections and flag an error. Pointers to + __devexit functions must use __devexit_p(function_name), the wrapper will + insert either the function_name or NULL, depending on the config options. + */ +#if defined(MODULE) || defined(CONFIG_HOTPLUG) +#define __devexit_p(x) x +#else +#define __devexit_p(x) NULL #endif #endif /* _LINUX_INIT_H */ diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/include/linux/interrupt.h linux-2.5/include/linux/interrupt.h --- linux-2.5.1/include/linux/interrupt.h Sun Dec 16 23:43:25 2001 +++ linux-2.5/include/linux/interrupt.h Mon Dec 31 21:53:19 2001 @@ -3,12 +3,14 @@ #define _LINUX_INTERRUPT_H #include <linux/config.h> +#include <linux/sched.h> #include <linux/kernel.h> #include <linux/smp.h> #include <linux/cache.h> #include <asm/bitops.h> #include <asm/atomic.h> +#include <asm/system.h> #include <asm/ptrace.h> struct irqaction { diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/include/linux/isdn/tpam.h linux-2.5/include/linux/isdn/tpam.h --- linux-2.5.1/include/linux/isdn/tpam.h Mon Jul 2 21:07:55 2001 +++ linux-2.5/include/linux/isdn/tpam.h Thu Dec 13 16:32:37 2001 @@ -1,4 +1,4 @@ -/* $Id: tpam.h,v 1.1.2.1 2001/06/08 08:23:46 kai Exp $ +/* $Id: tpam.h,v 1.1.2.1 2001/11/20 14:19:38 kai Exp $ * * Turbo PAM ISDN driver for Linux. (Kernel Driver) * diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/include/linux/isdn.h linux-2.5/include/linux/isdn.h --- linux-2.5.1/include/linux/isdn.h Sun Sep 30 19:26:42 2001 +++ linux-2.5/include/linux/isdn.h Sun Dec 30 21:17:30 2001 @@ -1,4 +1,4 @@ -/* $Id: isdn.h,v 1.111.6.9 2001/09/23 22:25:05 kai Exp $ +/* $Id: isdn.h,v 1.1.4.1 2001/11/20 14:19:38 kai Exp $ * * Main header for the Linux ISDN subsystem (linklevel). * @@ -150,7 +150,6 @@ #include <linux/errno.h> #include <linux/fs.h> #include <linux/major.h> -#include <asm/segment.h> #include <asm/io.h> #include <linux/kernel.h> #include <linux/signal.h> diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/include/linux/isdn_divertif.h linux-2.5/include/linux/isdn_divertif.h --- linux-2.5.1/include/linux/isdn_divertif.h Sun Sep 30 19:26:42 2001 +++ linux-2.5/include/linux/isdn_divertif.h Thu Dec 13 16:32:37 2001 @@ -1,4 +1,4 @@ -/* $Id: isdn_divertif.h,v 1.4.6.1 2001/09/23 22:25:05 kai Exp $ +/* $Id: isdn_divertif.h,v 1.1.4.1 2001/11/20 14:19:38 kai Exp $ * * Header for the diversion supplementary interface for i4l. * diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/include/linux/isdn_lzscomp.h linux-2.5/include/linux/isdn_lzscomp.h --- linux-2.5.1/include/linux/isdn_lzscomp.h Sun Sep 30 19:26:42 2001 +++ linux-2.5/include/linux/isdn_lzscomp.h Thu Dec 13 16:32:37 2001 @@ -1,4 +1,4 @@ -/* $Id: isdn_lzscomp.h,v 1.1.10.1 2001/09/23 22:25:05 kai Exp $ +/* $Id: isdn_lzscomp.h,v 1.1.4.1 2001/11/20 14:19:38 kai Exp $ * * Header for isdn_lzscomp.c * Concentrated here to not mess up half a dozen kernel headers with code diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/include/linux/isdnif.h linux-2.5/include/linux/isdnif.h --- linux-2.5.1/include/linux/isdnif.h Sun Sep 30 19:26:42 2001 +++ linux-2.5/include/linux/isdnif.h Thu Dec 13 16:32:37 2001 @@ -1,4 +1,4 @@ -/* $Id: isdnif.h,v 1.37.6.6 2001/09/23 22:25:05 kai Exp $ +/* $Id: isdnif.h,v 1.1.4.1 2001/11/20 14:19:38 kai Exp $ * * Linux ISDN subsystem * Definition of the interface between the subsystem and its low-level drivers. diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/include/linux/jbd.h linux-2.5/include/linux/jbd.h --- linux-2.5.1/include/linux/jbd.h Fri Nov 9 22:25:04 2001 +++ linux-2.5/include/linux/jbd.h Thu Dec 13 16:32:37 2001 @@ -221,7 +221,7 @@ #endif #else -#define J_ASSERT(assert) +#define J_ASSERT(assert) do { } while (0) #endif /* JBD_ASSERTIONS */ enum jbd_state_bits { @@ -564,7 +564,7 @@ /* Log buffer allocation */ extern struct journal_head * journal_get_descriptor_buffer(journal_t *); -extern unsigned long journal_next_log_block(journal_t *); +int journal_next_log_block(journal_t *, unsigned long *); /* Commit management */ extern void journal_commit_transaction(journal_t *); @@ -664,15 +664,16 @@ extern void journal_destroy (journal_t *); extern int journal_recover (journal_t *journal); extern int journal_wipe (journal_t *, int); -extern int journal_skip_recovery (journal_t *); -extern void journal_update_superblock (journal_t *, int); -extern void __journal_abort (journal_t *); +extern int journal_skip_recovery (journal_t *); +extern void journal_update_superblock (journal_t *, int); +extern void __journal_abort_hard (journal_t *); +extern void __journal_abort_soft (journal_t *, int); extern void journal_abort (journal_t *, int); extern int journal_errno (journal_t *); extern void journal_ack_err (journal_t *); extern int journal_clear_err (journal_t *); -extern unsigned long journal_bmap(journal_t *journal, unsigned long blocknr); -extern int journal_force_commit(journal_t *journal); +extern int journal_bmap(journal_t *, unsigned long, unsigned long *); +extern int journal_force_commit(journal_t *); /* * journal_head management diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/include/linux/kbd_kern.h linux-2.5/include/linux/kbd_kern.h --- linux-2.5.1/include/linux/kbd_kern.h Sun Dec 16 23:44:43 2001 +++ linux-2.5/include/linux/kbd_kern.h Mon Dec 31 21:55:33 2001 @@ -140,7 +140,6 @@ int getkeycode(unsigned int scancode); int setkeycode(unsigned int scancode, unsigned int keycode); void compute_shiftstate(void); -int keyboard_wait_for_keypress(struct console *); /* defkeymap.c */ diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/include/linux/kernel.h linux-2.5/include/linux/kernel.h --- linux-2.5.1/include/linux/kernel.h Sun Dec 16 23:43:25 2001 +++ linux-2.5/include/linux/kernel.h Mon Dec 31 21:53:19 2001 @@ -37,15 +37,12 @@ #define KERN_INFO "<6>" /* informational */ #define KERN_DEBUG "<7>" /* debug-level messages */ -# define NORET_TYPE /**/ -# define ATTRIB_NORET __attribute__((noreturn)) -# define NORET_AND noreturn, - -#ifdef __i386__ -#define FASTCALL(x) x __attribute__((regparm(3))) -#else -#define FASTCALL(x) x -#endif +extern int console_printk[]; + +#define console_loglevel (console_printk[0]) +#define default_message_loglevel (console_printk[1]) +#define minimum_console_loglevel (console_printk[2]) +#define default_console_loglevel (console_printk[3]) struct completion; @@ -82,8 +79,6 @@ asmlinkage int printk(const char * fmt, ...) __attribute__ ((format (printf, 1, 2))); - -extern int console_loglevel; static inline void console_silent(void) { diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/include/linux/keyboard.h linux-2.5/include/linux/keyboard.h --- linux-2.5.1/include/linux/keyboard.h Sun Dec 16 23:44:28 2001 +++ linux-2.5/include/linux/keyboard.h Mon Dec 31 21:55:33 2001 @@ -26,7 +26,6 @@ extern const int max_vals[]; extern unsigned short *key_maps[MAX_NR_KEYMAPS]; extern unsigned short plain_map[NR_KEYS]; -extern wait_queue_head_t keypress_wait; extern unsigned char keyboard_type; #endif diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/include/linux/linkage.h linux-2.5/include/linux/linkage.h --- linux-2.5.1/include/linux/linkage.h Mon Dec 11 20:49:54 2000 +++ linux-2.5/include/linux/linkage.h Sun Dec 30 20:01:41 2001 @@ -60,4 +60,14 @@ #endif +# define NORET_TYPE /**/ +# define ATTRIB_NORET __attribute__((noreturn)) +# define NORET_AND noreturn, + +#ifdef __i386__ +#define FASTCALL(x) x __attribute__((regparm(3))) +#else +#define FASTCALL(x) x +#endif + #endif diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/include/linux/list.h linux-2.5/include/linux/list.h --- linux-2.5.1/include/linux/list.h Sun Dec 16 23:43:25 2001 +++ linux-2.5/include/linux/list.h Mon Dec 31 21:53:19 2001 @@ -162,6 +162,16 @@ for (pos = (head)->next, n = pos->next; pos != (head); \ pos = n, n = pos->next) +/** + * list_for_each_prev - iterate over a list in reverse order + * @pos: the &struct list_head to use as a loop counter. + * @head: the head for your list. + */ +#define list_for_each_prev(pos, head) \ + for (pos = (head)->prev, prefetch(pos->prev); pos != (head); \ + pos = pos->prev, prefetch(pos->prev)) + + #endif /* __KERNEL__ || _LVM_H_INCLUDE */ #endif diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/include/linux/mm.h linux-2.5/include/linux/mm.h --- linux-2.5.1/include/linux/mm.h Sun Dec 16 23:43:26 2001 +++ linux-2.5/include/linux/mm.h Mon Dec 31 21:53:19 2001 @@ -7,6 +7,7 @@ #ifdef __KERNEL__ #include <linux/config.h> +#include <linux/gfp.h> #include <linux/string.h> #include <linux/list.h> #include <linux/mmzone.h> @@ -344,51 +345,6 @@ /* The array of struct pages */ extern mem_map_t * mem_map; -/* - * There is only one page-allocator function, and two main namespaces to - * it. The alloc_page*() variants return 'struct page *' and as such - * can allocate highmem pages, the *get*page*() variants return - * virtual kernel addresses to the allocated page(s). - */ -extern struct page * FASTCALL(_alloc_pages(unsigned int gfp_mask, unsigned int order)); -extern struct page * FASTCALL(__alloc_pages(unsigned int gfp_mask, unsigned int order, zonelist_t *zonelist)); -extern struct page * alloc_pages_node(int nid, unsigned int gfp_mask, unsigned int order); - -static inline struct page * alloc_pages(unsigned int gfp_mask, unsigned int order) -{ - /* - * Gets optimized away by the compiler. - */ - if (order >= MAX_ORDER) - return NULL; - return _alloc_pages(gfp_mask, order); -} - -#define alloc_page(gfp_mask) alloc_pages(gfp_mask, 0) - -extern unsigned long FASTCALL(__get_free_pages(unsigned int gfp_mask, unsigned int order)); -extern unsigned long FASTCALL(get_zeroed_page(unsigned int gfp_mask)); - -#define __get_free_page(gfp_mask) \ - __get_free_pages((gfp_mask),0) - -#define __get_dma_pages(gfp_mask, order) \ - __get_free_pages((gfp_mask) | GFP_DMA,(order)) - -/* - * The old interface name will be removed in 2.5: - */ -#define get_free_page get_zeroed_page - -/* - * There is only one 'core' page-freeing function. - */ -extern void FASTCALL(__free_pages(struct page *page, unsigned int order)); -extern void FASTCALL(free_pages(unsigned long addr, unsigned int order)); - -#define __free_page(page) __free_pages((page), 0) -#define free_page(addr) free_pages((addr),0) - extern void show_free_areas(void); extern void show_free_areas_node(pg_data_t *pgdat); @@ -418,6 +374,12 @@ extern void ptrace_disable(struct task_struct *); extern int ptrace_check_attach(struct task_struct *task, int kill); +int get_user_pages(struct task_struct *tsk, struct mm_struct *mm, unsigned long start, + int len, int write, int force, struct page **pages, struct vm_area_struct **vmas); + +int get_user_pages(struct task_struct *tsk, struct mm_struct *mm, unsigned long start, + int len, int write, int force, struct page **pages, struct vm_area_struct **vmas); + /* * On a two-level page table, this ends up being trivial. Thus the * inlining and the symmetry break with pte_alloc() that does all @@ -512,35 +474,15 @@ extern int filemap_sync(struct vm_area_struct *, unsigned long, size_t, unsigned int); extern struct page *filemap_nopage(struct vm_area_struct *, unsigned long, int); -/* - * GFP bitmasks.. - */ -/* Zone modifiers in GFP_ZONEMASK (see linux/mmzone.h - low four bits) */ -#define __GFP_DMA 0x01 -#define __GFP_HIGHMEM 0x02 - -/* Action modifiers - doesn't change the zoning */ -#define __GFP_WAIT 0x10 /* Can wait and reschedule? */ -#define __GFP_HIGH 0x20 /* Should access emergency pools? */ -#define __GFP_IO 0x40 /* Can start low memory physical IO? */ -#define __GFP_HIGHIO 0x80 /* Can start high mem physical IO? */ -#define __GFP_FS 0x100 /* Can call down to low-level FS? */ - -#define GFP_NOHIGHIO (__GFP_HIGH | __GFP_WAIT | __GFP_IO) -#define GFP_NOIO (__GFP_HIGH | __GFP_WAIT) -#define GFP_NOFS (__GFP_HIGH | __GFP_WAIT | __GFP_IO | __GFP_HIGHIO) -#define GFP_ATOMIC (__GFP_HIGH) -#define GFP_USER ( __GFP_WAIT | __GFP_IO | __GFP_HIGHIO | __GFP_FS) -#define GFP_HIGHUSER ( __GFP_WAIT | __GFP_IO | __GFP_HIGHIO | __GFP_FS | __GFP_HIGHMEM) -#define GFP_KERNEL (__GFP_HIGH | __GFP_WAIT | __GFP_IO | __GFP_HIGHIO | __GFP_FS) -#define GFP_NFS (__GFP_HIGH | __GFP_WAIT | __GFP_IO | __GFP_HIGHIO | __GFP_FS) -#define GFP_KSWAPD ( __GFP_WAIT | __GFP_IO | __GFP_HIGHIO | __GFP_FS) - -/* Flag - indicates that the buffer will be suitable for DMA. Ignored on some - platforms, used as appropriate on others */ - -#define GFP_DMA __GFP_DMA +static inline unsigned int pf_gfp_mask(unsigned int gfp_mask) +{ + /* avoid all memory balancing I/O methods if this task cannot block on I/O */ + if (current->flags & PF_NOIO) + gfp_mask &= ~(__GFP_IO | __GFP_HIGHIO | __GFP_FS); + return gfp_mask; +} + /* vma is the first one with address < vma->vm_end, * and even address < vma->vm_start. Have to extend vma. */ static inline int expand_stack(struct vm_area_struct * vma, unsigned long address) @@ -553,11 +495,13 @@ * before relocating the vma range ourself. */ address &= PAGE_MASK; + spin_lock(&vma->vm_mm->page_table_lock); grow = (vma->vm_start - address) >> PAGE_SHIFT; if (vma->vm_end - address > current->rlim[RLIMIT_STACK].rlim_cur || - ((vma->vm_mm->total_vm + grow) << PAGE_SHIFT) > current->rlim[RLIMIT_AS].rlim_cur) + ((vma->vm_mm->total_vm + grow) << PAGE_SHIFT) > current->rlim[RLIMIT_AS].rlim_cur) { + spin_unlock(&vma->vm_mm->page_table_lock); return -ENOMEM; - spin_lock(&vma->vm_mm->page_table_lock); + } vma->vm_start = address; vma->vm_pgoff -= grow; vma->vm_mm->total_vm += grow; diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/include/linux/msdos_fs.h linux-2.5/include/linux/msdos_fs.h --- linux-2.5.1/include/linux/msdos_fs.h Fri Nov 30 16:30:17 2001 +++ linux-2.5/include/linux/msdos_fs.h Mon Dec 31 22:00:01 2001 @@ -200,7 +200,7 @@ #include <linux/nls.h> struct fat_cache { - kdev_t device; /* device number. 0 means unused. */ + struct super_block *sb; /* fs in question. NULL means unused */ int start_cluster; /* first cluster of the chain. */ int file_cluster; /* cluster number in the file. */ int disk_cluster; /* cluster number on disk. */ @@ -252,7 +252,7 @@ int *d_clu); extern void fat_cache_add(struct inode *inode, int f_clu, int d_clu); extern void fat_cache_inval_inode(struct inode *inode); -extern void fat_cache_inval_dev(kdev_t device); +extern void fat_cache_inval_dev(struct super_block *sb); extern int fat_get_cluster(struct inode *inode, int cluster); extern int fat_free(struct inode *inode, int skip); diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/include/linux/namespace.h linux-2.5/include/linux/namespace.h --- linux-2.5.1/include/linux/namespace.h Thu Jan 1 00:00:00 1970 +++ linux-2.5/include/linux/namespace.h Thu Dec 27 15:56:12 2001 @@ -0,0 +1,42 @@ +#ifndef _NAMESPACE_H_ +#define _NAMESPACE_H_ +#ifdef __KERNEL__ + +struct namespace { + atomic_t count; + struct vfsmount * root; + struct list_head list; + struct rw_semaphore sem; +}; + +static inline void put_namespace(struct namespace *namespace) +{ + if (atomic_dec_and_test(&namespace->count)) { + down_write(&namespace->sem); + spin_lock(&dcache_lock); + umount_tree(namespace->root); + spin_unlock(&dcache_lock); + up_write(&namespace->sem); + kfree(namespace); + } +} + +static inline void exit_namespace(struct task_struct *p) +{ + struct namespace *namespace = p->namespace; + if (namespace) { + task_lock(p); + p->namespace = NULL; + task_unlock(p); + put_namespace(namespace); + } +} +extern int copy_namespace(int, struct task_struct *); + +static inline void get_namespace(struct namespace *namespace) +{ + atomic_inc(&namespace->count); +} + +#endif +#endif diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/include/linux/netdevice.h linux-2.5/include/linux/netdevice.h --- linux-2.5.1/include/linux/netdevice.h Sun Dec 16 23:44:14 2001 +++ linux-2.5/include/linux/netdevice.h Mon Dec 31 21:56:30 2001 @@ -663,6 +663,8 @@ NETIF_MSG_TX_DONE = 0x0400, NETIF_MSG_RX_STATUS = 0x0800, NETIF_MSG_PKTDATA = 0x1000, + NETIF_MSG_HW = 0x2000, + NETIF_MSG_WOL = 0x4000, }; #define netif_msg_drv(p) ((p)->msg_enable & NETIF_MSG_DRV) @@ -678,6 +680,8 @@ #define netif_msg_tx_done(p) ((p)->msg_enable & NETIF_MSG_TX_DONE) #define netif_msg_rx_status(p) ((p)->msg_enable & NETIF_MSG_RX_STATUS) #define netif_msg_pktdata(p) ((p)->msg_enable & NETIF_MSG_PKTDATA) +#define netif_msg_hw(p) ((p)->msg_enable & NETIF_MSG_HW) +#define netif_msg_wol(p) ((p)->msg_enable & NETIF_MSG_WOL) /* These functions live elsewhere (drivers/net/net_init.c, but related) */ diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/include/linux/netlink.h linux-2.5/include/linux/netlink.h --- linux-2.5.1/include/linux/netlink.h Thu Jul 26 21:00:17 2001 +++ linux-2.5/include/linux/netlink.h Thu Dec 13 16:32:37 2001 @@ -5,6 +5,7 @@ #define NETLINK_SKIP 1 /* Reserved for ENskip */ #define NETLINK_USERSOCK 2 /* Reserved for user mode socket protocols */ #define NETLINK_FIREWALL 3 /* Firewalling hook */ +#define NETLINK_TCPDIAG 4 /* TCP socket monitoring */ #define NETLINK_ARPD 8 #define NETLINK_ROUTE6 11 /* af_inet6 route comm channel */ #define NETLINK_IP6_FW 13 diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/include/linux/nfs_fs.h linux-2.5/include/linux/nfs_fs.h --- linux-2.5.1/include/linux/nfs_fs.h Sun Dec 16 23:44:09 2001 +++ linux-2.5/include/linux/nfs_fs.h Mon Dec 31 21:53:21 2001 @@ -16,6 +16,7 @@ #include <linux/sunrpc/debug.h> #include <linux/sunrpc/auth.h> +#include <linux/sunrpc/clnt.h> #include <linux/nfs.h> #include <linux/nfs2.h> @@ -331,6 +332,29 @@ wait_event(wq, condition); \ __retval; \ }) + +#ifdef CONFIG_NFS_V3 + +#define NFS_JUKEBOX_RETRY_TIME (5 * HZ) +static inline int +nfs_async_handle_jukebox(struct rpc_task *task) +{ + if (task->tk_status != -EJUKEBOX) + return 0; + task->tk_status = 0; + rpc_restart_call(task); + rpc_delay(task, NFS_JUKEBOX_RETRY_TIME); + return 1; +} + +#else + +static inline int +nfs_async_handle_jukebox(struct rpc_task *task) +{ + return 0; +} +#endif /* CONFIG_NFS_V3 */ #endif /* __KERNEL__ */ diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/include/linux/parport.h linux-2.5/include/linux/parport.h --- linux-2.5.1/include/linux/parport.h Wed Nov 14 22:52:47 2001 +++ linux-2.5/include/linux/parport.h Mon Dec 31 21:56:49 2001 @@ -8,6 +8,7 @@ #ifndef _PARPORT_H_ #define _PARPORT_H_ +#include <linux/sched.h> /* Start off with user-visible constants */ diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/include/linux/pci_ids.h linux-2.5/include/linux/pci_ids.h --- linux-2.5.1/include/linux/pci_ids.h Sat Dec 8 00:26:13 2001 +++ linux-2.5/include/linux/pci_ids.h Thu Dec 27 22:10:28 2001 @@ -355,6 +355,7 @@ #define PCI_VENDOR_ID_WD 0x101c #define PCI_DEVICE_ID_WD_7197 0x3296 +#define PCI_DEVICE_ID_WD_90C 0xc24a #define PCI_VENDOR_ID_AMI 0x101e #define PCI_DEVICE_ID_AMI_MEGARAID3 0x1960 @@ -646,6 +647,12 @@ #define PCI_DEVICE_ID_APPLE_KL_USB 0x0019 #define PCI_DEVICE_ID_APPLE_UNI_N_AGP 0x0020 #define PCI_DEVICE_ID_APPLE_UNI_N_GMAC 0x0021 +#define PCI_DEVICE_ID_APPLE_KEYLARGO 0x0022 +#define PCI_DEVICE_ID_APPLE_UNI_N_GMACP 0x0024 +#define PCI_DEVICE_ID_APPLE_KEYLARGO_P 0x0025 +#define PCI_DEVICE_ID_APPLE_KL_USB_P 0x0026 +#define PCI_DEVICE_ID_APPLE_UNI_N_AGP_P 0x0027 +#define PCI_DEVICE_ID_APPLE_UNI_N_AGP15 0x002d #define PCI_DEVICE_ID_APPLE_UNI_N_FW2 0x0030 #define PCI_VENDOR_ID_YAMAHA 0x1073 @@ -946,11 +953,12 @@ #define PCI_DEVICE_ID_VIA_8233_7 0x3065 #define PCI_DEVICE_ID_VIA_82C686_6 0x3068 #define PCI_DEVICE_ID_VIA_8233_0 0x3074 -#define PCI_DEVICE_ID_VIA_8622 0x3102 -#define PCI_DEVICE_ID_VIA_8233C_0 0x3109 -#define PCI_DEVICE_ID_VIA_8361 0x3112 #define PCI_DEVICE_ID_VIA_8633_0 0x3091 #define PCI_DEVICE_ID_VIA_8367_0 0x3099 +#define PCI_DEVICE_ID_VIA_8622 0x3102 +#define PCI_DEVICE_ID_VIA_8233C_0 0x3109 +#define PCI_DEVICE_ID_VIA_8361 0x3112 +#define PCI_DEVICE_ID_VIA_8233A 0x3147 #define PCI_DEVICE_ID_VIA_86C100A 0x6100 #define PCI_DEVICE_ID_VIA_8231 0x8231 #define PCI_DEVICE_ID_VIA_8231_4 0x8235 @@ -960,7 +968,7 @@ #define PCI_DEVICE_ID_VIA_82C597_1 0x8597 #define PCI_DEVICE_ID_VIA_82C598_1 0x8598 #define PCI_DEVICE_ID_VIA_8601_1 0x8601 -#define PCI_DEVICE_ID_VIA_8505_1 0X8605 +#define PCI_DEVICE_ID_VIA_8505_1 0x8605 #define PCI_DEVICE_ID_VIA_8633_1 0xB091 #define PCI_DEVICE_ID_VIA_8367_1 0xB099 @@ -1111,6 +1119,8 @@ #define PCI_DEVICE_ID_ARTOP_ATP850UF 0x0005 #define PCI_DEVICE_ID_ARTOP_ATP860 0x0006 #define PCI_DEVICE_ID_ARTOP_ATP860R 0x0007 +#define PCI_DEVICE_ID_ARTOP_ATP865 0x0008 +#define PCI_DEVICE_ID_ARTOP_ATP865R 0x0009 #define PCI_DEVICE_ID_ARTOP_AEC7610 0x8002 #define PCI_DEVICE_ID_ARTOP_AEC7612UW 0x8010 #define PCI_DEVICE_ID_ARTOP_AEC7612U 0x8020 diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/include/linux/pmu.h linux-2.5/include/linux/pmu.h --- linux-2.5.1/include/linux/pmu.h Thu Aug 30 03:49:36 2001 +++ linux-2.5/include/linux/pmu.h Thu Dec 27 16:32:31 2001 @@ -168,19 +168,41 @@ /* priority levels in notifiers */ #define SLEEP_LEVEL_VIDEO 100 /* Video driver (first wake) */ -#define SLEEP_LEVEL_SOUND 90 /* Sound driver */ -#define SLEEP_LEVEL_MEDIABAY 80 /* Media bay driver */ -#define SLEEP_LEVEL_BLOCK 70 /* IDE, SCSI */ -#define SLEEP_LEVEL_NET 60 /* bmac */ -#define SLEEP_LEVEL_ADB 50 /* ADB */ -#define SLEEP_LEVEL_MISC 30 /* Anything */ -#define SLEEP_LEVEL_LAST 0 /* Reserved for apm_emu */ +#define SLEEP_LEVEL_MEDIABAY 90 /* Media bay driver */ +#define SLEEP_LEVEL_BLOCK 80 /* IDE, SCSI */ +#define SLEEP_LEVEL_NET 70 /* bmac, gmac */ +#define SLEEP_LEVEL_MISC 60 /* Anything else */ +#define SLEEP_LEVEL_USERLAND 55 /* Reserved for apm_emu */ +#define SLEEP_LEVEL_ADB 50 /* ADB (async) */ +#define SLEEP_LEVEL_SOUND 40 /* Sound driver (blocking) */ /* special register notifier functions */ int pmu_register_sleep_notifier(struct pmu_sleep_notifier* notifier); int pmu_unregister_sleep_notifier(struct pmu_sleep_notifier* notifier); -#endif /* CONFIG_PMAC_PBOOK */ +#define PMU_MAX_BATTERIES 2 + +/* values for pmu_power_flags */ +#define PMU_PWR_AC_PRESENT 0x00000001 + +/* values for pmu_battery_info.flags */ +#define PMU_BATT_PRESENT 0x00000001 +#define PMU_BATT_CHARGING 0x00000002 +struct pmu_battery_info +{ + unsigned int flags; + unsigned int charge; /* current charge */ + unsigned int max_charge; /* maximum charge */ + signed int current; /* current, positive if charging */ + unsigned int voltage; /* voltage */ + unsigned int time_remaining; /* remaining time */ +}; + +extern int pmu_battery_count; +extern struct pmu_battery_info pmu_batteries[PMU_MAX_BATTERIES]; +extern unsigned int pmu_power_flags; + +#endif /* CONFIG_PMAC_PBOOK */ #endif /* __KERNEL__ */ diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/include/linux/pnpbios.h linux-2.5/include/linux/pnpbios.h --- linux-2.5.1/include/linux/pnpbios.h Thu Jan 1 00:00:00 1970 +++ linux-2.5/include/linux/pnpbios.h Mon Dec 31 21:53:20 2001 @@ -0,0 +1,211 @@ +/* + * Include file for the interface to a PnP BIOS + * + * Original BIOS code (C) 1998 Christian Schmidt (chr.schmidt@tu-bs.de) + * PnP handler parts (c) 1998 Tom Lees <tom@lpsg.demon.co.uk> + * Minor reorganizations by David Hinds <dhinds@zen.stanford.edu> + * + * 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, 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 + */ + +#ifndef _LINUX_PNPBIOS_H +#define _LINUX_PNPBIOS_H + +#ifdef __KERNEL__ + +#include <linux/types.h> +#include <linux/pci.h> + +/* + * Status codes (warnings and errors) + */ +#define PNP_SUCCESS 0x00 +#define PNP_NOT_SET_STATICALLY 0x7f +#define PNP_UNKNOWN_FUNCTION 0x81 +#define PNP_FUNCTION_NOT_SUPPORTED 0x82 +#define PNP_INVALID_HANDLE 0x83 +#define PNP_BAD_PARAMETER 0x84 +#define PNP_SET_FAILED 0x85 +#define PNP_EVENTS_NOT_PENDING 0x86 +#define PNP_SYSTEM_NOT_DOCKED 0x87 +#define PNP_NO_ISA_PNP_CARDS 0x88 +#define PNP_UNABLE_TO_DETERMINE_DOCK_CAPABILITIES 0x89 +#define PNP_CONFIG_CHANGE_FAILED_NO_BATTERY 0x8a +#define PNP_CONFIG_CHANGE_FAILED_RESOURCE_CONFLICT 0x8b +#define PNP_BUFFER_TOO_SMALL 0x8c +#define PNP_USE_ESCD_SUPPORT 0x8d +#define PNP_MESSAGE_NOT_SUPPORTED 0x8e +#define PNP_HARDWARE_ERROR 0x8f + +#define ESCD_SUCCESS 0x00 +#define ESCD_IO_ERROR_READING 0x55 +#define ESCD_INVALID 0x56 +#define ESCD_BUFFER_TOO_SMALL 0x59 +#define ESCD_NVRAM_TOO_SMALL 0x5a +#define ESCD_FUNCTION_NOT_SUPPORTED 0x81 + +/* + * Events that can be received by "get event" + */ +#define PNPEV_ABOUT_TO_CHANGE_CONFIG 0x0001 +#define PNPEV_DOCK_CHANGED 0x0002 +#define PNPEV_SYSTEM_DEVICE_CHANGED 0x0003 +#define PNPEV_CONFIG_CHANGED_FAILED 0x0004 +#define PNPEV_UNKNOWN_SYSTEM_EVENT 0xffff +/* 0x8000 through 0xfffe are OEM defined */ + +/* + * Messages that should be sent through "send message" + */ +#define PNPMSG_OK 0x00 +#define PNPMSG_ABORT 0x01 +#define PNPMSG_UNDOCK_DEFAULT_ACTION 0x40 +#define PNPMSG_POWER_OFF 0x41 +#define PNPMSG_PNP_OS_ACTIVE 0x42 +#define PNPMSG_PNP_OS_INACTIVE 0x43 +/* 0x8000 through 0xffff are OEM defined */ + +#pragma pack(1) +struct pnp_dev_node_info { + __u16 no_nodes; + __u16 max_node_size; +}; +struct pnp_docking_station_info { + __u32 location_id; + __u32 serial; + __u16 capabilities; +}; +struct pnp_isa_config_struc { + __u8 revision; + __u8 no_csns; + __u16 isa_rd_data_port; + __u16 reserved; +}; +struct escd_info_struc { + __u16 min_escd_write_size; + __u16 escd_size; + __u32 nv_storage_base; +}; +struct pnp_bios_node { + __u16 size; + __u8 handle; + __u32 eisa_id; + __u8 type_code[3]; + __u16 flags; + __u8 data[0]; +}; +#pragma pack() + +struct pnpbios_device_id +{ + char id[8]; + unsigned long driver_data; +}; + +struct pnpbios_driver { + struct list_head node; + char *name; + const struct pnpbios_device_id *id_table; /* NULL if wants all devices */ + int (*probe) (struct pci_dev *dev, const struct pnpbios_device_id *id); /* New device inserted */ + void (*remove) (struct pci_dev *dev); /* Device removed, either due to hotplug remove or module remove */ +}; + +#ifdef CONFIG_PNPBIOS + +/* exported */ +extern int pnpbios_register_driver(struct pnpbios_driver *drv); +extern void pnpbios_unregister_driver(struct pnpbios_driver *drv); + +/* non-exported */ +#define pnpbios_for_each_dev(dev) \ + for(dev = pnpbios_dev_g(pnpbios_devices.next); dev != pnpbios_dev_g(&pnpbios_devices); dev = pnpbios_dev_g(dev->global_list.next)) + + +#define pnpbios_dev_g(n) list_entry(n, struct pci_dev, global_list) + +static __inline struct pnpbios_driver *pnpbios_dev_driver(const struct pci_dev *dev) +{ + return (struct pnpbios_driver *)dev->driver; +} + +extern int pnpbios_dont_use_current_config; +extern void *pnpbios_kmalloc(size_t size, int f); +extern void pnpbios_init (void); +extern void pnpbios_proc_init (void); + +extern int pnp_bios_dev_node_info (struct pnp_dev_node_info *data); +extern int pnp_bios_get_dev_node (u8 *nodenum, char config, struct pnp_bios_node *data); +extern int pnp_bios_set_dev_node (u8 nodenum, char config, struct pnp_bios_node *data); +#if needed +extern int pnp_bios_get_event (u16 *message); +extern int pnp_bios_send_message (u16 message); +extern int pnp_bios_set_stat_res (char *info); +extern int pnp_bios_get_stat_res (char *info); +extern int pnp_bios_apm_id_table (char *table, u16 *size); +extern int pnp_bios_isapnp_config (struct pnp_isa_config_struc *data); +extern int pnp_bios_escd_info (struct escd_info_struc *data); +extern int pnp_bios_read_escd (char *data, u32 nvram_base); +extern int pnp_bios_write_escd (char *data, u32 nvram_base); +#endif + +/* + * a helper function which helps ensure correct pnpbios_driver + * setup and cleanup for commonly-encountered hotplug/modular cases + * + * This MUST stay in a header, as it checks for -DMODULE + */ + +static inline int pnpbios_module_init(struct pnpbios_driver *drv) +{ + int rc = pnpbios_register_driver (drv); + + if (rc > 0) + return 0; + + /* iff CONFIG_HOTPLUG and built into kernel, we should + * leave the driver around for future hotplug events. + * For the module case, a hotplug daemon of some sort + * should load a module in response to an insert event. */ +#if defined(CONFIG_HOTPLUG) && !defined(MODULE) + if (rc == 0) + return 0; +#else + if (rc == 0) + rc = -ENODEV; +#endif + + /* if we get here, we need to clean up pci driver instance + * and return some sort of error */ + pnpbios_unregister_driver (drv); + + return rc; +} + +#else /* CONFIG_PNPBIOS */ + +static __inline__ int pnpbios_register_driver(struct pnpbios_driver *drv) +{ + return 0; +} + +static __inline__ void pnpbios_unregister_driver(struct pnpbios_driver *drv) +{ + return; +} + +#endif /* CONFIG_PNPBIOS */ +#endif /* __KERNEL__ */ + +#endif /* _LINUX_PNPBIOS_H */ diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/include/linux/proc_fs.h linux-2.5/include/linux/proc_fs.h --- linux-2.5.1/include/linux/proc_fs.h Sun Dec 16 23:43:28 2001 +++ linux-2.5/include/linux/proc_fs.h Mon Dec 31 21:53:19 2001 @@ -3,6 +3,8 @@ #include <linux/config.h> #include <linux/slab.h> +#include <linux/fs.h> +#include <asm/atomic.h> /* * The proc filesystem constants/structures diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/include/linux/quota.h linux-2.5/include/linux/quota.h --- linux-2.5.1/include/linux/quota.h Thu Nov 22 18:38:31 2001 +++ linux-2.5/include/linux/quota.h Thu Dec 27 22:10:28 2001 @@ -167,7 +167,6 @@ /* fields after this point are cleared when invalidating */ struct super_block *dq_sb; /* superblock this applies to */ unsigned int dq_id; /* ID this applies to (uid, gid) */ - kdev_t dq_dev; /* Device this applies to */ short dq_type; /* Type of quota */ short dq_flags; /* See DQ_* */ unsigned long dq_referenced; /* Number of times this dquot was diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/include/linux/quotaops.h linux-2.5/include/linux/quotaops.h --- linux-2.5.1/include/linux/quotaops.h Sun Dec 16 23:43:50 2001 +++ linux-2.5/include/linux/quotaops.h Mon Dec 31 21:55:59 2001 @@ -23,7 +23,7 @@ extern void dquot_initialize(struct inode *inode, short type); extern void dquot_drop(struct inode *inode); extern int quota_off(struct super_block *sb, short type); -extern int sync_dquots(kdev_t dev, short type); +extern int sync_dquots(struct super_block *sb, short type); extern int dquot_alloc_block(struct inode *inode, unsigned long number, char prealloc); extern int dquot_alloc_inode(const struct inode *inode, unsigned long number); @@ -159,7 +159,7 @@ return 0; } -#define DQUOT_SYNC(dev) sync_dquots(dev, -1) +#define DQUOT_SYNC(sb) sync_dquots(sb, -1) #define DQUOT_OFF(sb) quota_off(sb, -1) #else @@ -171,7 +171,7 @@ #define DQUOT_DROP(inode) do { } while(0) #define DQUOT_ALLOC_INODE(inode) (0) #define DQUOT_FREE_INODE(inode) do { } while(0) -#define DQUOT_SYNC(dev) do { } while(0) +#define DQUOT_SYNC(sb) do { } while(0) #define DQUOT_OFF(sb) do { } while(0) #define DQUOT_TRANSFER(inode, iattr) (0) extern __inline__ int DQUOT_PREALLOC_BLOCK_NODIRTY(struct inode *inode, int nr) diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/include/linux/raid/md_k.h linux-2.5/include/linux/raid/md_k.h --- linux-2.5.1/include/linux/raid/md_k.h Tue Dec 11 21:47:35 2001 +++ linux-2.5/include/linux/raid/md_k.h Thu Dec 20 19:14:29 2001 @@ -240,7 +240,7 @@ int (*stop_resync)(mddev_t *mddev); int (*restart_resync)(mddev_t *mddev); - int (*sync_request)(mddev_t *mddev, sector_t sector_nr); + int (*sync_request)(mddev_t *mddev, sector_t sector_nr, int go_faster); }; diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/include/linux/raid/raid1.h linux-2.5/include/linux/raid/raid1.h --- linux-2.5.1/include/linux/raid/raid1.h Tue Dec 11 21:47:35 2001 +++ linux-2.5/include/linux/raid/raid1.h Thu Dec 20 19:14:29 2001 @@ -9,8 +9,8 @@ int number; int raid_disk; kdev_t dev; - int sect_limit; - int head_position; + sector_t head_position; + atomic_t nr_pending; /* * State bits: @@ -31,23 +31,21 @@ int raid_disks; int working_disks; int last_used; - sector_t next_sect; - int sect_count; + sector_t next_seq_sect; mdk_thread_t *thread, *resync_thread; int resync_mirrors; mirror_info_t *spare; spinlock_t device_lock; /* for use when syncing mirrors: */ - unsigned long start_active, start_ready, - start_pending, start_future; - int cnt_done, cnt_active, cnt_ready, - cnt_pending, cnt_future; - int phase; - int window; - wait_queue_head_t wait_done; - wait_queue_head_t wait_ready; - spinlock_t segment_lock; + + spinlock_t resync_lock; + int nr_pending; + int barrier; + sector_t next_resync; + + wait_queue_head_t wait_idle; + wait_queue_head_t wait_resume; mempool_t *r1bio_pool; mempool_t *r1buf_pool; @@ -62,7 +60,8 @@ #define mddev_to_conf(mddev) ((conf_t *) mddev->private) /* - * this is our 'private' 'collective' RAID1 buffer head. + * this is our 'private' RAID1 bio. + * * it contains information about what kind of IO operations were started * for this RAID1 operation, and about their status: */ @@ -83,6 +82,7 @@ * if the IO is in READ direction, then this bio is used: */ struct bio *read_bio; + int read_disk; /* * if the IO is in WRITE direction, then multiple bios are used: */ @@ -94,5 +94,5 @@ /* bits for r1bio.state */ #define R1BIO_Uptodate 1 -#define R1BIO_SyncPhase 2 + #endif diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/include/linux/reiserfs_fs.h linux-2.5/include/linux/reiserfs_fs.h --- linux-2.5.1/include/linux/reiserfs_fs.h Tue Nov 27 17:23:27 2001 +++ linux-2.5/include/linux/reiserfs_fs.h Mon Dec 31 22:01:06 2001 @@ -15,10 +15,10 @@ #include <linux/types.h> #ifdef __KERNEL__ #include <linux/slab.h> +#include <linux/interrupt.h> #include <linux/tqueue.h> #include <asm/unaligned.h> #include <linux/bitops.h> -#include <asm/hardirq.h> #include <linux/proc_fs.h> #endif @@ -52,48 +52,17 @@ */ - /* Vladimir, what is the story with - new_get_new_buffer nowadays? I - want a complete explanation written - here. */ - -/* NEW_GET_NEW_BUFFER will try to allocate new blocks better */ -/*#define NEW_GET_NEW_BUFFER*/ -#define OLD_GET_NEW_BUFFER - - /* Vladimir, what about this one too? */ -/* if this is undefined, all inode changes get into stat data immediately, if it can be found in RAM */ -#define DIRTY_LATER - -/* enable journalling */ -#define ENABLE_JOURNAL - #define USE_INODE_GENERATION_COUNTER - -#ifdef __KERNEL__ - -/* #define REISERFS_CHECK */ - #define REISERFS_PREALLOCATE -#endif #define PREALLOCATION_SIZE 8 -/* if this is undefined, all inode changes get into stat data - immediately, if it can be found in RAM */ -#define DIRTY_LATER - - -/*#define READ_LOCK_REISERFS*/ - - /* n must be power of 2 */ #define _ROUND_UP(x,n) (((x)+(n)-1u) & ~((n)-1u)) // to be ok for alpha and others we have to align structures to 8 byte // boundary. // FIXME: do not change 4 by anything else: there is code which relies on that - /* what 4? -Hans */ #define ROUND_UP(x) _ROUND_UP(x,8LL) /* debug levels. Right now, CONFIG_REISERFS_CHECK means print all debug @@ -148,22 +117,17 @@ strlen ( reiser2fs_super_magic_string))); } - /* ReiserFS leaves the first 64k unused, - so that partition labels have enough - space. If someone wants to write a - fancy bootloader that needs more than - 64k, let us know, and this will be - increased in size. This number must - be larger than than the largest block - size on any platform, or code will - break. -Hans */ +/* ReiserFS leaves the first 64k unused, so that partition labels have + enough space. If someone wants to write a fancy bootloader that + needs more than 64k, let us know, and this will be increased in size. + This number must be larger than than the largest block size on any + platform, or code will break. -Hans */ #define REISERFS_DISK_OFFSET_IN_BYTES (64 * 1024) #define REISERFS_FIRST_BLOCK unused_define /* the spot for the super in versions 3.5 - 3.5.10 (inclusive) */ #define REISERFS_OLD_DISK_OFFSET_IN_BYTES (8 * 1024) - // reiserfs internal error code (used by search_by_key adn fix_nodes)) #define CARRY_ON 0 #define REPEAT_SEARCH -1 @@ -172,53 +136,54 @@ #define NO_BALANCING_NEEDED (-4) #define NO_MORE_UNUSED_CONTIGUOUS_BLOCKS (-5) -//#define SCHEDULE_OCCURRED 1 -//#define PATH_INCORRECT 2 - -//#define NO_DISK_SPACE (-1) - - - typedef unsigned long b_blocknr_t; typedef __u32 unp_t; - /* who is responsible for this - completely uncommented struct? */ struct unfm_nodeinfo { - /* This is what? */ unp_t unfm_nodenum; - /* now this I know what it is, and - most of the people on our project - know what it is, but I bet nobody - new I hire will have a clue. */ unsigned short unfm_freespace; }; -/* when reiserfs_file_write is called with a byte count >= MIN_PACK_ON_CLOSE, -** it sets the inode to pack on close, and when extending the file, will only -** use unformatted nodes. -** -** This is a big speed up for the journal, which is badly hurt by direct->indirect -** conversions (they must be logged). -*/ -#define MIN_PACK_ON_CLOSE 512 +/* there are two formats of keys: 3.5 and 3.6 + */ +#define KEY_FORMAT_3_5 0 +#define KEY_FORMAT_3_6 1 -// this says about version of all items (but stat data) the object -// consists of -#define inode_items_version(inode) ((inode)->u.reiserfs_i.i_version) - - - /* This is an aggressive tail suppression policy, I am hoping it - improves our benchmarks. The principle behind it is that - percentage space saving is what matters, not absolute space - saving. This is non-intuitive, but it helps to understand it if - you consider that the cost to access 4 blocks is not much more - than the cost to access 1 block, if you have to do a seek and - rotate. A tail risks a non-linear disk access that is - significant as a percentage of total time cost for a 4 block file - and saves an amount of space that is less significant as a - percentage of space, or so goes the hypothesis. -Hans */ +/* there are two stat datas */ +#define STAT_DATA_V1 0 +#define STAT_DATA_V2 1 + +/** this says about version of key of all items (but stat data) the + object consists of */ +#define get_inode_item_key_version( inode ) \ + (((inode)->u.reiserfs_i.i_flags & i_item_key_version_mask) ? KEY_FORMAT_3_6 : KEY_FORMAT_3_5) + +#define set_inode_item_key_version( inode, version ) \ + ({ if((version)==KEY_FORMAT_3_6) \ + (inode)->u.reiserfs_i.i_flags |= i_item_key_version_mask; \ + else \ + (inode)->u.reiserfs_i.i_flags &= ~i_item_key_version_mask; }) + +#define get_inode_sd_version(inode) \ + (((inode)->u.reiserfs_i.i_flags & i_stat_data_version_mask) ? STAT_DATA_V2 : STAT_DATA_V1) + +#define set_inode_sd_version(inode, version) \ + ({ if((version)==STAT_DATA_V2) \ + (inode)->u.reiserfs_i.i_flags |= i_stat_data_version_mask; \ + else \ + (inode)->u.reiserfs_i.i_flags &= ~i_stat_data_version_mask; }) + +/* This is an aggressive tail suppression policy, I am hoping it + improves our benchmarks. The principle behind it is that percentage + space saving is what matters, not absolute space saving. This is + non-intuitive, but it helps to understand it if you consider that the + cost to access 4 blocks is not much more than the cost to access 1 + block, if you have to do a seek and rotate. A tail risks a + non-linear disk access that is significant as a percentage of total + time cost for a 4 block file and saves an amount of space that is + less significant as a percentage of space, or so goes the hypothesis. + -Hans */ #define STORE_TAIL_IN_UNFM(n_file_size,n_tail_size,n_block_size) \ (\ (!(n_tail_size)) || \ @@ -246,21 +211,6 @@ /***************************************************************************/ // -// we do support for old format of reiserfs: the problem is to -// distinuquish keys with 32 bit offset and keys with 60 bit ones. On -// leaf level we use ih_version of struct item_head (was -// ih_reserved). For all old items it is set to 0 -// (ITEM_VERSION_1). For new items it is ITEM_VERSION_2. On internal -// levels we have to know version of item key belongs to. -// -#define ITEM_VERSION_1 0 -#define ITEM_VERSION_2 1 - - -/* loff_t - long long */ - - -// // directories use this key as well as old files // struct offset_v1 { @@ -341,18 +291,11 @@ indirect2direct conversion */ }; - - - - - - - /* Our function for comparing keys can compare keys of different - lengths. It takes as a parameter the length of the keys it is to - compare. These defines are used in determining what is to be - passed to it as that parameter. */ +/* Our function for comparing keys can compare keys of different + lengths. It takes as a parameter the length of the keys it is to + compare. These defines are used in determining what is to be passed + to it as that parameter. */ #define REISERFS_FULL_KEY_LEN 4 - #define REISERFS_SHORT_KEY_LEN 2 /* The result of the key compare */ @@ -362,7 +305,6 @@ #define KEY_FOUND 1 #define KEY_NOT_FOUND 0 - #define KEY_SIZE (sizeof(struct key)) #define SHORT_KEY_SIZE (sizeof (__u32) + sizeof (__u32)) @@ -387,8 +329,6 @@ #define GOTO_PREVIOUS_ITEM 2 #define NAME_FOUND_INVISIBLE 3 - - /* Everything in the filesystem is stored as a set of items. The item head contains the key of the item, its free space (for indirect items) and specifies the location of the item itself @@ -396,37 +336,28 @@ struct item_head { - struct key ih_key; /* Everything in the tree is found by searching for it based on its key.*/ - - /* This is bloat, this should be part - of the item not the item - header. -Hans */ - union { - __u16 ih_free_space_reserved; /* The free space in the last unformatted node of an indirect item if this - is an indirect item. This equals 0xFFFF iff this is a direct item or - stat data item. Note that the key, not this field, is used to determine - the item type, and thus which field this union contains. */ - __u16 ih_entry_count; /* Iff this is a directory item, this field equals the number of directory - entries in the directory item. */ - } __attribute__ ((__packed__)) u; - __u16 ih_item_len; /* total size of the item body */ - __u16 ih_item_location; /* an offset to the item body within the block */ - /* I thought we were going to use this - for having lots of item types? Why - don't you use this for item type - not item version. That is how you - talked me into this field a year - ago, remember? I am still not - convinced it needs to be 16 bits - (for at least many years), but at - least I can sympathize with that - hope. Change the name from version - to type, and tell people not to use - FFFF in case 16 bits is someday too - small and needs to be extended:-). */ - __u16 ih_version; /* 0 for all old items, 2 for new - ones. Highest bit is set by fsck - temporary, cleaned after all done */ + /* Everything in the tree is found by searching for it based on + * its key.*/ + struct key ih_key; + union { + /* The free space in the last unformatted node of an + indirect item if this is an indirect item. This + equals 0xFFFF iff this is a direct item or stat data + item. Note that the key, not this field, is used to + determine the item type, and thus which field this + union contains. */ + __u16 ih_free_space_reserved; + /* Iff this is a directory item, this field equals the + number of directory entries in the directory item. */ + __u16 ih_entry_count; + } __attribute__ ((__packed__)) u; + __u16 ih_item_len; /* total size of the item body */ + __u16 ih_item_location; /* an offset to the item body + * within the block */ + __u16 ih_version; /* 0 for all old items, 2 for new + ones. Highest bit is set by fsck + temporary, cleaned after all + done */ } __attribute__ ((__packed__)); /* size of item header */ #define IH_SIZE (sizeof(struct item_head)) @@ -446,8 +377,8 @@ #define unreachable_item(ih) (ih_version(ih) & (1 << 15)) -#define get_ih_free_space(ih) (ih_version (ih) == ITEM_VERSION_2 ? 0 : ih_free_space (ih)) -#define set_ih_free_space(ih,val) put_ih_free_space((ih), ((ih_version(ih) == ITEM_VERSION_2) ? 0 : (val))) +#define get_ih_free_space(ih) (ih_version (ih) == KEY_FORMAT_3_6 ? 0 : ih_free_space (ih)) +#define set_ih_free_space(ih,val) put_ih_free_space((ih), ((ih_version(ih) == KEY_FORMAT_3_6) ? 0 : (val))) /* these operate on indirect items, where you've got an array of ints ** at a possibly unaligned location. These are a noop on ia32 @@ -476,6 +407,9 @@ #define V1_DIRENTRY_UNIQUENESS 500 #define V1_ANY_UNIQUENESS 555 // FIXME: comment is required +extern void reiserfs_warning (const char * fmt, ...); +/* __attribute__( ( format ( printf, 1, 2 ) ) ); */ + // // here are conversion routines // @@ -487,14 +421,11 @@ case V1_INDIRECT_UNIQUENESS: return TYPE_INDIRECT; case V1_DIRECT_UNIQUENESS: return TYPE_DIRECT; case V1_DIRENTRY_UNIQUENESS: return TYPE_DIRENTRY; + default: + reiserfs_warning( "vs-500: unknown uniqueness %d\n", uniqueness); + case V1_ANY_UNIQUENESS: + return TYPE_ANY; } -/* - if (uniqueness != V1_ANY_UNIQUENESS) { - printk ("uniqueness %d\n", uniqueness); - BUG (); - } -*/ - return TYPE_ANY; } static inline __u32 type2uniqueness (int type) CONSTF; @@ -505,15 +436,13 @@ case TYPE_INDIRECT: return V1_INDIRECT_UNIQUENESS; case TYPE_DIRECT: return V1_DIRECT_UNIQUENESS; case TYPE_DIRENTRY: return V1_DIRENTRY_UNIQUENESS; + default: + reiserfs_warning( "vs-501: unknown type %d\n", type); + case TYPE_ANY: + return V1_ANY_UNIQUENESS; } - /* - if (type != TYPE_ANY) - BUG (); - */ - return V1_ANY_UNIQUENESS; } - // // key is pointer to on disk key which is stored in le, result is cpu, // there is no way to get version of object from key, so, provide @@ -521,7 +450,7 @@ // static inline loff_t le_key_k_offset (int version, const struct key * key) { - return (version == ITEM_VERSION_1) ? + return (version == KEY_FORMAT_3_5) ? le32_to_cpu( key->u.k_offset_v1.k_offset ) : offset_v2_k_offset( &(key->u.k_offset_v2) ); } @@ -533,7 +462,7 @@ static inline loff_t le_key_k_type (int version, const struct key * key) { - return (version == ITEM_VERSION_1) ? + return (version == KEY_FORMAT_3_5) ? uniqueness2type( le32_to_cpu( key->u.k_offset_v1.k_uniqueness)) : offset_v2_k_type( &(key->u.k_offset_v2) ); } @@ -546,20 +475,21 @@ static inline void set_le_key_k_offset (int version, struct key * key, loff_t offset) { - (version == ITEM_VERSION_1) ? + (version == KEY_FORMAT_3_5) ? (key->u.k_offset_v1.k_offset = cpu_to_le32 (offset)) : /* jdm check */ (set_offset_v2_k_offset( &(key->u.k_offset_v2), offset )); } + + static inline void set_le_ih_k_offset (struct item_head * ih, loff_t offset) { set_le_key_k_offset (ih_version (ih), &(ih->ih_key), offset); } - static inline void set_le_key_k_type (int version, struct key * key, int type) { - (version == ITEM_VERSION_1) ? + (version == KEY_FORMAT_3_5) ? (key->u.k_offset_v1.k_uniqueness = cpu_to_le32(type2uniqueness(type))): (set_offset_v2_k_type( &(key->u.k_offset_v2), type )); } @@ -589,21 +519,21 @@ // static inline loff_t cpu_key_k_offset (const struct cpu_key * key) { - return (key->version == ITEM_VERSION_1) ? + return (key->version == KEY_FORMAT_3_5) ? key->on_disk_key.u.k_offset_v1.k_offset : key->on_disk_key.u.k_offset_v2.k_offset; } static inline loff_t cpu_key_k_type (const struct cpu_key * key) { - return (key->version == ITEM_VERSION_1) ? + return (key->version == KEY_FORMAT_3_5) ? uniqueness2type (key->on_disk_key.u.k_offset_v1.k_uniqueness) : key->on_disk_key.u.k_offset_v2.k_type; } static inline void set_cpu_key_k_offset (struct cpu_key * key, loff_t offset) { - (key->version == ITEM_VERSION_1) ? + (key->version == KEY_FORMAT_3_5) ? (key->on_disk_key.u.k_offset_v1.k_offset = offset) : (key->on_disk_key.u.k_offset_v2.k_offset = offset); } @@ -611,14 +541,15 @@ static inline void set_cpu_key_k_type (struct cpu_key * key, int type) { - (key->version == ITEM_VERSION_1) ? + (key->version == KEY_FORMAT_3_5) ? (key->on_disk_key.u.k_offset_v1.k_uniqueness = type2uniqueness (type)): (key->on_disk_key.u.k_offset_v2.k_type = type); } + static inline void cpu_key_k_offset_dec (struct cpu_key * key) { - if (key->version == ITEM_VERSION_1) + if (key->version == KEY_FORMAT_3_5) key->on_disk_key.u.k_offset_v1.k_offset --; else key->on_disk_key.u.k_offset_v2.k_offset --; @@ -761,7 +692,7 @@ } __attribute__ ((__packed__)); #define SD_V1_SIZE (sizeof(struct stat_data_v1)) -#define stat_data_v1(ih) (ih_version (ih) == ITEM_VERSION_1) +#define stat_data_v1(ih) (ih_version (ih) == KEY_FORMAT_3_5) #define sd_v1_mode(sdp) (le16_to_cpu((sdp)->sd_mode)) #define set_sd_v1_mode(sdp,v) ((sdp)->sd_mode = cpu_to_le16(v)) #define sd_v1_nlink(sdp) (le16_to_cpu((sdp)->sd_nlink)) @@ -815,11 +746,11 @@ } __attribute__ ((__packed__)) u; } __attribute__ ((__packed__)); // -// this is 40 bytes long +// this is 44 bytes long // #define SD_SIZE (sizeof(struct stat_data)) #define SD_V2_SIZE SD_SIZE -#define stat_data_v2(ih) (ih_version (ih) == ITEM_VERSION_2) +#define stat_data_v2(ih) (ih_version (ih) == KEY_FORMAT_3_6) #define sd_v2_mode(sdp) (le16_to_cpu((sdp)->sd_mode)) #define set_sd_v2_mode(sdp,v) ((sdp)->sd_mode = cpu_to_le16(v)) /* sd_reserved */ @@ -949,76 +880,10 @@ #define de_visible(deh) test_bit_unaligned (DEH_Visible, &((deh)->deh_state)) #define de_hidden(deh) !test_bit_unaligned (DEH_Visible, &((deh)->deh_state)) -/* compose directory item containing "." and ".." entries (entries are - not aligned to 4 byte boundary) */ -/* the last four params are LE */ -static inline void make_empty_dir_item_v1 (char * body, - __u32 dirid, __u32 objid, - __u32 par_dirid, __u32 par_objid) -{ - struct reiserfs_de_head * deh; - - memset (body, 0, EMPTY_DIR_SIZE_V1); - deh = (struct reiserfs_de_head *)body; - - /* direntry header of "." */ - put_deh_offset( &(deh[0]), DOT_OFFSET ); - /* these two are from make_le_item_head, and are are LE */ - deh[0].deh_dir_id = dirid; - deh[0].deh_objectid = objid; - deh[0].deh_state = 0; /* Endian safe if 0 */ - put_deh_location( &(deh[0]), EMPTY_DIR_SIZE_V1 - strlen( "." )); - mark_de_visible(&(deh[0])); - - /* direntry header of ".." */ - put_deh_offset( &(deh[1]), DOT_DOT_OFFSET); - /* key of ".." for the root directory */ - /* these two are from the inode, and are are LE */ - deh[1].deh_dir_id = par_dirid; - deh[1].deh_objectid = par_objid; - deh[1].deh_state = 0; /* Endian safe if 0 */ - put_deh_location( &(deh[1]), deh_location( &(deh[0]) ) - strlen( ".." ) ); - mark_de_visible(&(deh[1])); - - /* copy ".." and "." */ - memcpy (body + deh_location( &(deh[0]) ), ".", 1); - memcpy (body + deh_location( &(deh[1]) ), "..", 2); -} - -/* compose directory item containing "." and ".." entries */ -static inline void make_empty_dir_item (char * body, - __u32 dirid, __u32 objid, - __u32 par_dirid, __u32 par_objid) -{ - struct reiserfs_de_head * deh; - - memset (body, 0, EMPTY_DIR_SIZE); - deh = (struct reiserfs_de_head *)body; - - /* direntry header of "." */ - put_deh_offset( &(deh[0]), DOT_OFFSET ); - /* these two are from make_le_item_head, and are are LE */ - deh[0].deh_dir_id = dirid; - deh[0].deh_objectid = objid; - deh[0].deh_state = 0; /* Endian safe if 0 */ - put_deh_location( &(deh[0]), EMPTY_DIR_SIZE - ROUND_UP( strlen( "." ) ) ); - mark_de_visible(&(deh[0])); - - /* direntry header of ".." */ - put_deh_offset( &(deh[1]), DOT_DOT_OFFSET ); - /* key of ".." for the root directory */ - /* these two are from the inode, and are are LE */ - deh[1].deh_dir_id = par_dirid; - deh[1].deh_objectid = par_objid; - deh[1].deh_state = 0; /* Endian safe if 0 */ - put_deh_location( &(deh[1]), deh_location( &(deh[0])) - ROUND_UP( strlen( ".." ) ) ); - mark_de_visible(&(deh[1])); - - /* copy ".." and "." */ - memcpy (body + deh_location( &(deh[0]) ), ".", 1); - memcpy (body + deh_location( &(deh[1]) ), "..", 2); -} - +extern void make_empty_dir_item_v1 (char * body, __u32 dirid, __u32 objid, + __u32 par_dirid, __u32 par_objid); +extern void make_empty_dir_item (char * body, __u32 dirid, __u32 objid, + __u32 par_dirid, __u32 par_objid); /* array of the entry headers */ /* get item body */ @@ -1059,13 +924,9 @@ // two entries per block (at least) //#define REISERFS_MAX_NAME_LEN(block_size) //((block_size - BLKH_SIZE - IH_SIZE - DEH_SIZE * 2) / 2) - -// two entries per block (at least) #define REISERFS_MAX_NAME_LEN(block_size) 255 - - /* this structure is used for operations on directory entries. It is not a disk structure. */ /* When reiserfs_find_entry or search_by_entry_key find directory @@ -1258,23 +1119,17 @@ // in in-core inode key is stored on le form #define INODE_PKEY(inode) ((struct key *)((inode)->u.reiserfs_i.i_key)) -//#define mark_tail_converted(inode) (atomic_set(&((inode)->u.reiserfs_i.i_converted),1)) -//#define unmark_tail_converted(inode) (atomic_set(&((inode)->u.reiserfs_i.i_converted), 0)) -//#define is_tail_converted(inode) (atomic_read(&((inode)->u.reiserfs_i.i_converted))) - - #define MAX_UL_INT 0xffffffff #define MAX_INT 0x7ffffff #define MAX_US_INT 0xffff -///#define TOO_LONG_LENGTH (~0ULL) - // reiserfs version 2 has max offset 60 bits. Version 1 - 32 bit offset #define U32_MAX (~(__u32)0) + static inline loff_t max_reiserfs_offset (const struct inode * inode) { - if (inode_items_version (inode) == ITEM_VERSION_1) + if (get_inode_item_key_version(inode) == KEY_FORMAT_3_5) return (loff_t)U32_MAX; return (loff_t)((~(__u64)0) >> 4); @@ -1307,13 +1162,6 @@ /* FIXATE NODES */ /***************************************************************************/ -//#define VI_TYPE_STAT_DATA 1 -//#define VI_TYPE_DIRECT 2 -//#define VI_TYPE_INDIRECT 4 -//#define VI_TYPE_DIRECTORY 8 -//#define VI_TYPE_FIRST_DIRECTORY_ITEM 16 -//#define VI_TYPE_INSERTED_DIRECTORY_ITEM 32 - #define VI_TYPE_LEFT_MERGEABLE 1 #define VI_TYPE_RIGHT_MERGEABLE 2 @@ -1536,11 +1384,7 @@ #define COMP_KEYS comp_keys #define COMP_SHORT_KEYS comp_short_keys -#define keys_of_same_object comp_short_keys - -/*#define COMP_KEYS(p_s_key1, p_s_key2) comp_keys((unsigned long *)(p_s_key1), (unsigned long *)(p_s_key2)) -#define COMP_SHORT_KEYS(p_s_key1, p_s_key2) comp_short_keys((unsigned long *)(p_s_key1), (unsigned long *)(p_s_key2))*/ - +/*#define keys_of_same_object comp_short_keys*/ /* number of blocks pointed to by the indirect item */ #define I_UNFM_NUM(p_s_ih) ( ih_item_len(p_s_ih) / UNFM_P_SIZE ) @@ -1675,18 +1519,12 @@ int journal_mark_freed(struct reiserfs_transaction_handle *, struct super_block *, unsigned long blocknr) ; int push_journal_writer(char *w) ; int pop_journal_writer(int windex) ; -int journal_lock_dobalance(struct super_block *p_s_sb) ; -int journal_unlock_dobalance(struct super_block *p_s_sb) ; int journal_transaction_should_end(struct reiserfs_transaction_handle *, int) ; int reiserfs_in_journal(struct super_block *p_s_sb, kdev_t dev, unsigned long bl, int size, int searchall, unsigned long *next) ; int journal_begin(struct reiserfs_transaction_handle *, struct super_block *p_s_sb, unsigned long) ; -int journal_join(struct reiserfs_transaction_handle *, struct super_block *p_s_sb, unsigned long) ; struct super_block *reiserfs_get_super(kdev_t dev) ; void flush_async_commits(struct super_block *p_s_sb) ; -int remove_from_transaction(struct super_block *p_s_sb, unsigned long blocknr, int already_cleaned) ; -int remove_from_journal_list(struct super_block *s, struct reiserfs_journal_list *jl, struct buffer_head *bh, int remove_freed) ; - int buffer_journaled(const struct buffer_head *bh) ; int mark_buffer_journal_new(struct buffer_head *bh) ; int reiserfs_sync_all_buffers(kdev_t dev, int wait) ; @@ -1725,6 +1563,10 @@ return 0 ; } +void add_save_link (struct reiserfs_transaction_handle * th, + struct inode * inode, int truncate); +void remove_save_link (struct inode * inode, int truncate); + /* objectid.c */ __u32 reiserfs_get_unused_objectid (struct reiserfs_transaction_handle *th); void reiserfs_release_objectid (struct reiserfs_transaction_handle *th, __u32 objectid_to_release); @@ -1762,16 +1604,16 @@ type = offset_v2_k_type( &(key->u.k_offset_v2)); if (type != TYPE_DIRECT && type != TYPE_INDIRECT && type != TYPE_DIRENTRY) - return ITEM_VERSION_1; + return KEY_FORMAT_3_5; - return ITEM_VERSION_2; + return KEY_FORMAT_3_6; } static inline void copy_key (struct key *to, const struct key *from) { - memcpy (to, from, KEY_SIZE); + memcpy (to, from, KEY_SIZE); } @@ -1815,38 +1657,32 @@ struct inode * inode, struct buffer_head * p_s_un_bh); - +void reiserfs_delete_solid_item (struct reiserfs_transaction_handle *th, + struct key * key); void reiserfs_delete_object (struct reiserfs_transaction_handle *th, struct inode * p_s_inode); void reiserfs_do_truncate (struct reiserfs_transaction_handle *th, struct inode * p_s_inode, struct page *, int update_timestamps); -// -//void lock_inode_to_convert (struct inode * p_s_inode); -//void unlock_inode_after_convert (struct inode * p_s_inode); -//void increment_i_read_sync_counter (struct inode * p_s_inode); -//void decrement_i_read_sync_counter (struct inode * p_s_inode); - -#define block_size(inode) ((inode)->i_sb->s_blocksize) +#define i_block_size(inode) ((inode)->i_sb->s_blocksize) #define file_size(inode) ((inode)->i_size) -#define tail_size(inode) (file_size (inode) & (block_size (inode) - 1)) +#define tail_size(inode) (file_size (inode) & (i_block_size (inode) - 1)) #define tail_has_to_be_packed(inode) (!dont_have_tails ((inode)->i_sb) &&\ -!STORE_TAIL_IN_UNFM(file_size (inode), tail_size(inode), block_size (inode))) - -/* -int get_buffer_by_range (struct super_block * p_s_sb, struct key * p_s_range_begin, struct key * p_s_range_end, - struct buffer_head ** pp_s_buf, unsigned long * p_n_objectid); -int get_buffers_from_range (struct super_block * p_s_sb, struct key * p_s_range_start, struct key * p_s_range_end, - struct buffer_head ** p_s_range_buffers, - int n_max_nr_buffers_to_return); -*/ +!STORE_TAIL_IN_UNFM(file_size (inode), tail_size(inode), i_block_size (inode))) void padd_item (char * item, int total_length, int length); - /* inode.c */ +void reiserfs_read_inode (struct inode * inode) ; +void reiserfs_read_inode2(struct inode * inode, void *p) ; +void reiserfs_delete_inode (struct inode * inode); +void reiserfs_write_inode (struct inode * inode, int) ; +struct dentry *reiserfs_fh_to_dentry(struct super_block *sb, __u32 *data, + int len, int fhtype, int parent); +int reiserfs_dentry_to_fh(struct dentry *dentry, __u32 *data, int *lenp, int need_parent); + int reiserfs_prepare_write(struct file *, struct page *, unsigned, unsigned) ; void reiserfs_truncate_file(struct inode *, int update_timestamps) ; void make_cpu_key (struct cpu_key * cpu_key, const struct inode * inode, loff_t offset, @@ -1854,24 +1690,9 @@ void make_le_item_head (struct item_head * ih, const struct cpu_key * key, int version, loff_t offset, int type, int length, int entry_count); -/*void store_key (struct key * key); -void forget_key (struct key * key);*/ -int reiserfs_get_block (struct inode * inode, sector_t block, - struct buffer_head * bh_result, int create); struct inode * reiserfs_iget (struct super_block * s, const struct cpu_key * key); -void reiserfs_read_inode (struct inode * inode) ; -void reiserfs_read_inode2(struct inode * inode, void *p) ; -void reiserfs_delete_inode (struct inode * inode); -extern int reiserfs_notify_change(struct dentry * dentry, struct iattr * attr); -void reiserfs_write_inode (struct inode * inode, int) ; -/* nfsd support functions */ -struct dentry *reiserfs_fh_to_dentry(struct super_block *sb, __u32 *fh, int len, int fhtype, int parent); -int reiserfs_dentry_to_fh(struct dentry *, __u32 *fh, int *lenp, int need_parent); - -/* we don't mark inodes dirty, we just log them */ -void reiserfs_dirty_inode (struct inode * inode) ; struct inode * reiserfs_new_inode (struct reiserfs_transaction_handle *th, const struct inode * dir, int mode, @@ -1879,36 +1700,12 @@ struct dentry *dentry, struct inode *inode, int * err); int reiserfs_sync_inode (struct reiserfs_transaction_handle *th, struct inode * inode); void reiserfs_update_sd (struct reiserfs_transaction_handle *th, struct inode * inode); -int reiserfs_inode_setattr(struct dentry *, struct iattr * attr); /* namei.c */ inline void set_de_name_and_namelen (struct reiserfs_dir_entry * de); int search_by_entry_key (struct super_block * sb, const struct cpu_key * key, struct path * path, struct reiserfs_dir_entry * de); -struct dentry * reiserfs_lookup (struct inode * dir, struct dentry *dentry); -int reiserfs_create (struct inode * dir, struct dentry *dentry, int mode); -int reiserfs_mknod (struct inode * dir_inode, struct dentry *dentry, int mode, int rdev); -int reiserfs_mkdir (struct inode * dir, struct dentry *dentry, int mode); -int reiserfs_rmdir (struct inode * dir, struct dentry *dentry); -int reiserfs_unlink (struct inode * dir, struct dentry *dentry); -int reiserfs_symlink (struct inode * dir, struct dentry *dentry, const char * symname); -int reiserfs_link (struct dentry * old_dentry, struct inode * dir, struct dentry *dentry); -int reiserfs_rename (struct inode * old_dir, struct dentry *old_dentry, struct inode * new_dir, struct dentry *new_dentry); - -/* super.c */ -inline void reiserfs_mark_buffer_dirty (struct buffer_head * bh, int flag); -inline void reiserfs_mark_buffer_clean (struct buffer_head * bh); -void reiserfs_write_super (struct super_block * s); -void reiserfs_put_super (struct super_block * s); -int reiserfs_remount (struct super_block * s, int * flags, char * data); -/*int read_super_block (struct super_block * s, int size); -int read_bitmaps (struct super_block * s); -int read_old_bitmaps (struct super_block * s); -int read_old_super_block (struct super_block * s, int size);*/ -struct super_block * reiserfs_read_super (struct super_block * s, void * data, int silent); -int reiserfs_statfs (struct super_block * s, struct statfs * buf); - /* procfs.c */ #if defined( CONFIG_PROC_FS ) && defined( CONFIG_REISERFS_PROC_INFO ) @@ -1989,10 +1786,9 @@ /* buffer2.c */ -struct buffer_head * reiserfs_getblk (kdev_t n_dev, int n_block, int n_size); +struct buffer_head * reiserfs_getblk (struct super_block *super, int n_block); void wait_buffer_until_released (const struct buffer_head * bh); -struct buffer_head * reiserfs_bread (struct super_block *super, int n_block, - int n_size); +struct buffer_head * reiserfs_bread (struct super_block *super, int n_block); /* fix_nodes.c */ void * reiserfs_kmalloc (size_t size, int flags, struct super_block * s); @@ -2006,8 +1802,6 @@ /* prints.c */ void reiserfs_panic (struct super_block * s, const char * fmt, ...) __attribute__ ( ( noreturn ) );/* __attribute__( ( format ( printf, 2, 3 ) ) ) */ -void reiserfs_warning (const char * fmt, ...); -/* __attribute__( ( format ( printf, 1, 2 ) ) ); */ void reiserfs_debug (struct super_block *s, int level, const char * fmt, ...); /* __attribute__( ( format ( printf, 3, 4 ) ) ); */ void print_virtual_node (struct virtual_node * vn); @@ -2099,83 +1893,6 @@ #define reiserfs_test_and_clear_le_bit ext2_clear_bit #define reiserfs_test_le_bit ext2_test_bit #define reiserfs_find_next_zero_le_bit ext2_find_next_zero_bit - - -// -// this was totally copied from from linux's -// find_first_zero_bit and changed a bit -// - -#ifdef __i386__ - -static __inline__ int -find_first_nonzero_bit(const void * addr, unsigned size) { - int res; - int __d0; - void *__d1; - - - if (!size) { - return (0); - } - __asm__ __volatile__ ( - "cld\n\t" - "xorl %%eax,%%eax\n\t" - "repe; scasl\n\t" - "je 1f\n\t" - "movl -4(%%edi),%%eax\n\t" - "subl $4, %%edi\n\t" - "bsfl %%eax,%%eax\n\t" - "1:\tsubl %%edx,%%edi\n\t" - "shll $3,%%edi\n\t" - "addl %%edi,%%eax" - :"=a" (res), - "=c"(__d0), "=D"(__d1) - :"1" ((size + 31) >> 5), "d" (addr), "2" (addr)); - return (res); -} - -#else /* __i386__ */ - -static __inline__ int find_next_nonzero_bit(const void * addr, unsigned size, - unsigned offset) -{ - unsigned int * p = ((unsigned int *) addr) + (offset >> 5); - unsigned int result = offset & ~31UL; - unsigned int tmp; - - if (offset >= size) - return size; - size -= result; - offset &= 31UL; - if (offset) { - tmp = *p++; - /* set to zero first offset bits */ - tmp &= ~(~0UL >> (32-offset)); - if (size < 32) - goto found_first; - if (tmp != 0U) - goto found_middle; - size -= 32; - result += 32; - } - while (size >= 32) { - if ((tmp = *p++) != 0U) - goto found_middle; - result += 32; - size -= 32; - } - if (!size) - return result; - tmp = *p; -found_first: -found_middle: - return result + ffs(tmp); -} - -#define find_first_nonzero_bit(addr,size) find_next_nonzero_bit((addr), (size), 0) - -#endif /* 0 */ /* sometimes reiserfs_truncate may require to allocate few new blocks to perform indirect2direct conversion. People probably used to diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/include/linux/reiserfs_fs_i.h linux-2.5/include/linux/reiserfs_fs_i.h --- linux-2.5.1/include/linux/reiserfs_fs_i.h Sun Dec 16 23:43:25 2001 +++ linux-2.5/include/linux/reiserfs_fs_i.h Mon Dec 31 21:53:19 2001 @@ -3,50 +3,47 @@ #include <linux/list.h> +/** bitmasks for i_flags field in reiserfs-specific part of inode */ +typedef enum { + /** this says what format of key do all items (but stat data) of + an object have. If this is set, that format is 3.6 otherwise + - 3.5 */ + i_item_key_version_mask = 0x0001, + /** If this is unset, object has 3.5 stat data, otherwise, it has + 3.6 stat data with 64bit size, 32bit nlink etc. */ + i_stat_data_version_mask = 0x0002, + /** file might need tail packing on close */ + i_pack_on_close_mask = 0x0004, + /** don't pack tail of file */ + i_nopack_mask = 0x0008, + /** If those is set, "safe link" was created for this file during + truncate or unlink. Safe link is used to avoid leakage of disk + space on crash with some files open, but unlinked. */ + i_link_saved_unlink_mask = 0x0010, + i_link_saved_truncate_mask = 0x0020 +} reiserfs_inode_flags; + + struct reiserfs_inode_info { - __u32 i_key [4];/* key is still 4 32 bit integers */ + __u32 i_key [4];/* key is still 4 32 bit integers */ - /* this comment will be totally - cryptic to readers not familiar - with 3.5/3.6 format conversion, and - it does not consider that that 3.6 - might not be the last version */ - int i_version; // this says whether file is old or new - - int i_pack_on_close ; // file might need tail packing on close - - __u32 i_first_direct_byte; // offset of first byte stored in direct item. - - /* My guess is this contains the first - unused block of a sequence of - blocks plus the length of the - sequence, which I think is always - at least two at the time of the - preallocation. I really prefer - allocate on flush conceptually..... - - You know, it really annoys me when - code is this badly commented that I - have to guess what it does. - Neither I nor anyone else has time - for guessing what your - datastructures mean. -Hans */ - //For preallocation - int i_prealloc_block; - int i_prealloc_count; - struct list_head i_prealloc_list; /* per-transaction list of inodes which - * have preallocated blocks */ - /* I regret that you think the below - is a comment you should make.... -Hans */ - //nopack-attribute - int nopack; + /** transient inode flags that are never stored on disk. Bitmasks + for this field are defined above. */ + __u32 i_flags; + + __u32 i_first_direct_byte; // offset of first byte stored in direct item. + + int i_prealloc_block; /* first unused block of a sequence of unused blocks */ + int i_prealloc_count; /* length of that sequence */ + struct list_head i_prealloc_list; /* per-transaction list of inodes which + * have preallocated blocks */ - /* we use these for fsync or O_SYNC to decide which transaction needs - ** to be committed in order for this inode to be properly flushed - */ - unsigned long i_trans_id ; - unsigned long i_trans_index ; + /* we use these for fsync or O_SYNC to decide which transaction + ** needs to be committed in order for this inode to be properly + ** flushed */ + unsigned long i_trans_id ; + unsigned long i_trans_index ; }; - #endif + diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/include/linux/reiserfs_fs_sb.h linux-2.5/include/linux/reiserfs_fs_sb.h --- linux-2.5.1/include/linux/reiserfs_fs_sb.h Sun Dec 16 23:43:25 2001 +++ linux-2.5/include/linux/reiserfs_fs_sb.h Mon Dec 31 21:53:19 2001 @@ -407,6 +407,8 @@ /* To be obsoleted soon by per buffer seals.. -Hans */ atomic_t s_generation_counter; // increased by one every time the // tree gets re-balanced + unsigned int s_properties; /* File system properties. Currently holds + on-disk FS format */ /* session statistics */ int s_kmallocs; @@ -420,11 +422,19 @@ int s_bmaps_without_search; int s_direct2indirect; int s_indirect2direct; + /* set up when it's ok for reiserfs_read_inode2() to read from + disk inode with nlink==0. Currently this is only used during + finish_unfinished() processing at mount time */ + int s_is_unlinked_ok; reiserfs_proc_info_data_t s_proc_info_data; struct proc_dir_entry *procdir; }; +/* Definitions of reiserfs on-disk properties: */ +#define REISERFS_3_5 0 +#define REISERFS_3_6 1 +/* Mount options */ #define NOTAIL 0 /* -o notail: no tails will be created in a session */ #define REPLAYONLY 3 /* replay journal and return 0. Use by fsck */ #define REISERFS_NOLOG 4 /* -o nolog: turn journalling off */ @@ -474,7 +484,8 @@ #define dont_have_tails(s) ((s)->u.reiserfs_sb.s_mount_opt & (1 << NOTAIL)) #define replay_only(s) ((s)->u.reiserfs_sb.s_mount_opt & (1 << REPLAYONLY)) #define reiserfs_dont_log(s) ((s)->u.reiserfs_sb.s_mount_opt & (1 << REISERFS_NOLOG)) -#define old_format_only(s) ((SB_VERSION(s) != REISERFS_VERSION_2) && !((s)->u.reiserfs_sb.s_mount_opt & (1 << REISERFS_CONVERT))) +#define old_format_only(s) ((s)->u.reiserfs_sb.s_properties & (1 << REISERFS_3_5)) +#define convert_reiserfs(s) ((s)->u.reiserfs_sb.s_mount_opt & (1 << REISERFS_CONVERT)) void reiserfs_file_buffer (struct buffer_head * bh, int list); diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/include/linux/rtnetlink.h linux-2.5/include/linux/rtnetlink.h --- linux-2.5.1/include/linux/rtnetlink.h Thu Jul 26 21:01:13 2001 +++ linux-2.5/include/linux/rtnetlink.h Thu Dec 13 16:32:37 2001 @@ -546,7 +546,6 @@ extern int rtattr_parse(struct rtattr *tb[], int maxattr, struct rtattr *rta, int len); -#ifdef CONFIG_RTNETLINK extern struct sock *rtnl; struct rtnetlink_link @@ -568,12 +567,6 @@ extern void rtmsg_ifinfo(int type, struct net_device *dev, unsigned change); -#else - -#define rtmsg_ifinfo(a,b,c) do { } while (0) - -#endif - extern struct semaphore rtnl_sem; #define rtnl_exlock() do { } while(0) @@ -583,14 +576,10 @@ #define rtnl_shlock() down(&rtnl_sem) #define rtnl_shlock_nowait() down_trylock(&rtnl_sem) -#ifndef CONFIG_RTNETLINK -#define rtnl_shunlock() up(&rtnl_sem) -#else #define rtnl_shunlock() do { up(&rtnl_sem); \ if (rtnl && rtnl->receive_queue.qlen) \ rtnl->data_ready(rtnl, 0); \ } while(0) -#endif extern void rtnl_lock(void); extern void rtnl_unlock(void); diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/include/linux/sched.h linux-2.5/include/linux/sched.h --- linux-2.5.1/include/linux/sched.h Sun Dec 16 23:43:25 2001 +++ linux-2.5/include/linux/sched.h Mon Dec 31 21:53:19 2001 @@ -41,6 +41,7 @@ #define CLONE_VFORK 0x00004000 /* set if the parent wants the child to wake it up on mm_release */ #define CLONE_PARENT 0x00008000 /* set if we want to have the same parent as the cloner */ #define CLONE_THREAD 0x00010000 /* Same thread group? */ +#define CLONE_NEWNS 0x00020000 /* New namespace group? */ #define CLONE_SIGNAL (CLONE_SIGHAND | CLONE_THREAD) @@ -149,6 +150,7 @@ extern void update_process_times(int user); extern void update_one_process(struct task_struct *p, unsigned long user, unsigned long system, int cpu); +extern void expire_task(struct task_struct *p); #define MAX_SCHEDULE_TIMEOUT LONG_MAX extern signed long FASTCALL(schedule_timeout(signed long timeout)); @@ -165,6 +167,7 @@ */ #define NR_OPEN_DEFAULT BITS_PER_LONG +struct namespace; /* * Open file table structure */ @@ -299,7 +302,7 @@ * all fields in a single cacheline that are needed for * the goodness() loop in schedule(). */ - long counter; + long dyn_prio; long nice; unsigned long policy; struct mm_struct *mm; @@ -318,7 +321,10 @@ * that's just fine.) */ struct list_head run_list; + long time_slice; unsigned long sleep_time; + /* recalculation loop checkpoint */ + unsigned long rcl_last; struct task_struct *next_task, *prev_task; struct mm_struct *active_mm; @@ -388,6 +394,8 @@ struct fs_struct *fs; /* open file information */ struct files_struct *files; +/* namespace */ + struct namespace *namespace; /* signal handlers */ spinlock_t sigmask_lock; /* Protects signal and blocked */ struct signal_struct *sig; @@ -425,6 +433,7 @@ #define PF_MEMALLOC 0x00000800 /* Allocating memory */ #define PF_MEMDIE 0x00001000 /* Killed for out-of-memory */ #define PF_FREE_PAGES 0x00002000 /* per process page freeing */ +#define PF_NOIO 0x00004000 /* avoid generating further I/O */ #define PF_USEDFPU 0x00100000 /* task used FPU this quantum (SMP) */ @@ -444,8 +453,9 @@ */ #define _STK_LIM (8*1024*1024) -#define DEF_COUNTER (10*HZ/100) /* 100 ms time slice */ -#define MAX_COUNTER (20*HZ/100) +#define MAX_DYNPRIO 100 +#define DEF_TSLICE (6 * HZ / 100) +#define MAX_TSLICE (20 * HZ / 100) #define DEF_NICE (0) @@ -466,14 +476,16 @@ addr_limit: KERNEL_DS, \ exec_domain: &default_exec_domain, \ lock_depth: -1, \ - counter: DEF_COUNTER, \ + dyn_prio: 0, \ nice: DEF_NICE, \ policy: SCHED_OTHER, \ mm: NULL, \ active_mm: &init_mm, \ cpus_runnable: -1, \ cpus_allowed: -1, \ - run_list: LIST_HEAD_INIT(tsk.run_list), \ + run_list: { NULL, NULL }, \ + rcl_last: 0, \ + time_slice: DEF_TSLICE, \ next_task: &tsk, \ prev_task: &tsk, \ p_opptr: &tsk, \ diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/include/linux/serialP.h linux-2.5/include/linux/serialP.h --- linux-2.5.1/include/linux/serialP.h Sun Dec 16 23:44:43 2001 +++ linux-2.5/include/linux/serialP.h Mon Dec 31 21:55:53 2001 @@ -70,7 +70,7 @@ int x_char; /* xon/xoff character */ int close_delay; unsigned short closing_wait; - unsigned short closing_wait2; + unsigned short closing_wait2; /* obsolete */ int IER; /* Interrupt Enable Register */ int MCR; /* Modem control register */ int LCR; /* Line control register */ diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/include/linux/shm.h linux-2.5/include/linux/shm.h --- linux-2.5.1/include/linux/shm.h Sun Dec 16 23:43:31 2001 +++ linux-2.5/include/linux/shm.h Mon Dec 31 21:59:19 2001 @@ -80,7 +80,6 @@ asmlinkage long sys_shmat (int shmid, char *shmaddr, int shmflg, unsigned long *addr); asmlinkage long sys_shmdt (char *shmaddr); asmlinkage long sys_shmctl (int shmid, int cmd, struct shmid_ds *buf); -extern void shm_unuse(swp_entry_t entry, struct page *page); #endif /* __KERNEL__ */ diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/include/linux/shmem_fs.h linux-2.5/include/linux/shmem_fs.h --- linux-2.5.1/include/linux/shmem_fs.h Wed Oct 10 14:53:57 2001 +++ linux-2.5/include/linux/shmem_fs.h Thu Dec 13 16:32:37 2001 @@ -11,7 +11,7 @@ * swapper address space. * * We have to move it here, since not every user of fs.h is including - * mm.h, but m.h is including fs.h via sched .h :-/ + * mm.h, but mm.h is including fs.h via sched .h :-/ */ typedef struct { unsigned long val; diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/include/linux/slab.h linux-2.5/include/linux/slab.h --- linux-2.5.1/include/linux/slab.h Sun Dec 16 23:43:26 2001 +++ linux-2.5/include/linux/slab.h Mon Dec 31 21:53:19 2001 @@ -11,8 +11,8 @@ typedef struct kmem_cache_s kmem_cache_t; -#include <linux/mm.h> -#include <linux/cache.h> +#include <linux/gfp.h> +#include <linux/types.h> /* flags for kmem_cache_alloc() */ #define SLAB_NOFS GFP_NOFS @@ -64,6 +64,7 @@ extern int FASTCALL(kmem_cache_reap(int)); extern int slabinfo_read_proc(char *page, char **start, off_t off, int count, int *eof, void *data); +struct file; extern int slabinfo_write_proc(struct file *file, const char *buffer, unsigned long count, void *data); diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/include/linux/socket.h linux-2.5/include/linux/socket.h --- linux-2.5.1/include/linux/socket.h Sun Dec 16 23:43:25 2001 +++ linux-2.5/include/linux/socket.h Mon Dec 31 21:53:19 2001 @@ -156,6 +156,7 @@ #define AF_IRDA 23 /* IRDA sockets */ #define AF_PPPOX 24 /* PPPoX sockets */ #define AF_WANPIPE 25 /* Wanpipe API Sockets */ +#define AF_LLC 26 /* Linux LLC */ #define AF_BLUETOOTH 31 /* Bluetooth sockets */ #define AF_MAX 32 /* For now.. */ @@ -187,6 +188,7 @@ #define PF_IRDA AF_IRDA #define PF_PPPOX AF_PPPOX #define PF_WANPIPE AF_WANPIPE +#define PF_LLC AF_LLC #define PF_BLUETOOTH AF_BLUETOOTH #define PF_MAX AF_MAX @@ -237,6 +239,8 @@ #define SOL_ATM 264 /* ATM layer (cell level) */ #define SOL_AAL 265 /* ATM Adaption Layer (packet level) */ #define SOL_IRDA 266 +#define SOL_NETBEUI 267 +#define SOL_LLC 268 /* IPX options */ #define IPX_TYPE 1 diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/include/linux/stringify.h linux-2.5/include/linux/stringify.h --- linux-2.5.1/include/linux/stringify.h Thu Jan 1 00:00:00 1970 +++ linux-2.5/include/linux/stringify.h Sat Dec 29 11:10:40 2001 @@ -0,0 +1,12 @@ +#ifndef __LINUX_STRINGIFY_H +#define __LINUX_STRINGIFY_H + +/* Indirect stringification. Doing two levels allows the parameter to be a + * macro itself. For example, compile with -DFOO=bar, __stringify(FOO) + * converts to "bar". + */ + +#define __stringify_1(x) #x +#define __stringify(x) __stringify_1(x) + +#endif /* !__LINUX_STRINGIFY_H */ diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/include/linux/sunrpc/clnt.h linux-2.5/include/linux/sunrpc/clnt.h --- linux-2.5.1/include/linux/sunrpc/clnt.h Sun Dec 16 23:44:19 2001 +++ linux-2.5/include/linux/sunrpc/clnt.h Mon Dec 31 21:53:21 2001 @@ -15,6 +15,7 @@ #include <linux/sunrpc/auth.h> #include <linux/sunrpc/stats.h> #include <linux/sunrpc/xdr.h> +#include <asm/signal.h> /* * This defines an RPC port mapping @@ -136,7 +137,6 @@ xprt_set_timeout(&clnt->cl_timeout, retr, incr); } -extern void rpciod_tcp_dispatcher(void); extern void rpciod_wake_up(void); /* diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/include/linux/tcp_diag.h linux-2.5/include/linux/tcp_diag.h --- linux-2.5.1/include/linux/tcp_diag.h Thu Jan 1 00:00:00 1970 +++ linux-2.5/include/linux/tcp_diag.h Thu Dec 13 16:32:37 2001 @@ -0,0 +1,116 @@ +#ifndef _TCP_DIAG_H_ +#define _TCP_DIAG_H_ 1 + +/* Just some random number */ +#define TCPDIAG_GETSOCK 18 + +/* Socket identity */ +struct tcpdiag_sockid +{ + __u16 tcpdiag_sport; + __u16 tcpdiag_dport; + __u32 tcpdiag_src[4]; + __u32 tcpdiag_dst[4]; + __u32 tcpdiag_if; + __u32 tcpdiag_cookie[2]; +#define TCPDIAG_NOCOOKIE (~0U) +}; + +/* Request structure */ + +struct tcpdiagreq +{ + __u8 tcpdiag_family; /* Family of addresses. */ + __u8 tcpdiag_src_len; + __u8 tcpdiag_dst_len; + __u8 tcpdiag_ext; /* Query extended information */ + + struct tcpdiag_sockid id; + + __u32 tcpdiag_states; /* States to dump */ + __u32 tcpdiag_dbs; /* Tables to dump (NI) */ +}; + +enum +{ + TCPDIAG_REQ_NONE, + TCPDIAG_REQ_BYTECODE, +}; + +#define TCPDIAG_REQ_MAX TCPDIAG_REQ_BYTECODE + +/* Bytecode is sequence of 4 byte commands followed by variable arguments. + * All the commands identified by "code" are conditional jumps forward: + * to offset cc+"yes" or to offset cc+"no". "yes" is supposed to be + * length of the command and its arguments. + */ + +struct tcpdiag_bc_op +{ + unsigned char code; + unsigned char yes; + unsigned short no; +}; + +enum +{ + TCPDIAG_BC_NOP, + TCPDIAG_BC_JMP, + TCPDIAG_BC_S_GE, + TCPDIAG_BC_S_LE, + TCPDIAG_BC_D_GE, + TCPDIAG_BC_D_LE, + TCPDIAG_BC_AUTO, + TCPDIAG_BC_S_COND, + TCPDIAG_BC_D_COND, +}; + +struct tcpdiag_hostcond +{ + __u8 family; + __u8 prefix_len; + int port; + __u32 addr[0]; +}; + +/* Base info structure. It contains socket identity (addrs/ports/cookie) + * and, alas, the information shown by netstat. */ +struct tcpdiagmsg +{ + __u8 tcpdiag_family; + __u8 tcpdiag_state; + __u8 tcpdiag_timer; + __u8 tcpdiag_retrans; + + struct tcpdiag_sockid id; + + __u32 tcpdiag_expires; + __u32 tcpdiag_rqueue; + __u32 tcpdiag_wqueue; + __u32 tcpdiag_uid; + __u32 tcpdiag_inode; +}; + +/* Extensions */ + +enum +{ + TCPDIAG_NONE, + TCPDIAG_MEMINFO, + TCPDIAG_INFO, +}; + +#define TCPDIAG_MAX TCPDIAG_INFO + + +/* TCPDIAG_MEM */ + +struct tcpdiag_meminfo +{ + __u32 tcpdiag_rmem; + __u32 tcpdiag_wmem; + __u32 tcpdiag_fmem; + __u32 tcpdiag_tmem; +}; + +#endif /* _TCP_DIAG_H_ */ diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/include/linux/threads.h linux-2.5/include/linux/threads.h --- linux-2.5.1/include/linux/threads.h Sun Dec 16 23:43:25 2001 +++ linux-2.5/include/linux/threads.h Mon Dec 31 21:53:19 2001 @@ -5,7 +5,7 @@ /* * The default limit for the nr of threads is now in - * /proc/sys/kernel/max-threads. + * /proc/sys/kernel/threads-max. */ #ifdef CONFIG_SMP diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/include/linux/tty_driver.h linux-2.5/include/linux/tty_driver.h --- linux-2.5.1/include/linux/tty_driver.h Sun Dec 16 23:43:25 2001 +++ linux-2.5/include/linux/tty_driver.h Mon Dec 31 21:53:20 2001 @@ -130,6 +130,7 @@ struct termios init_termios; /* Initial termios */ int flags; /* tty driver flags */ int *refcount; /* for loadable tty drivers */ + struct console *console;/* console attached to this tty hardware */ struct proc_dir_entry *proc_entry; /* /proc fs entry */ struct tty_driver *other; /* only used for the PTY driver */ diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/include/linux/vt_kern.h linux-2.5/include/linux/vt_kern.h --- linux-2.5.1/include/linux/vt_kern.h Sun Dec 16 23:44:28 2001 +++ linux-2.5/include/linux/vt_kern.h Mon Dec 31 21:55:33 2001 @@ -9,6 +9,7 @@ #include <linux/config.h> #include <linux/vt.h> #include <linux/kd.h> +#include <linux/tty.h> /* * Presently, a lot of graphics programs do not restore the contents of diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/include/linux/wait.h linux-2.5/include/linux/wait.h --- linux-2.5.1/include/linux/wait.h Sun Dec 16 23:43:25 2001 +++ linux-2.5/include/linux/wait.h Mon Dec 31 21:53:19 2001 @@ -19,24 +19,11 @@ #include <asm/page.h> #include <asm/processor.h> -/* - * Debug control. Slow but useful. - */ -#if defined(CONFIG_DEBUG_WAITQ) -#define WAITQUEUE_DEBUG 1 -#else -#define WAITQUEUE_DEBUG 0 -#endif - struct __wait_queue { unsigned int flags; #define WQ_FLAG_EXCLUSIVE 0x01 struct task_struct * task; struct list_head task_list; -#if WAITQUEUE_DEBUG - long __magic; - long __waker; -#endif }; typedef struct __wait_queue wait_queue_t; @@ -77,129 +64,47 @@ struct __wait_queue_head { wq_lock_t lock; struct list_head task_list; -#if WAITQUEUE_DEBUG - long __magic; - long __creator; -#endif }; typedef struct __wait_queue_head wait_queue_head_t; /* - * Debugging macros. We eschew `do { } while (0)' because gcc can generate - * spurious .aligns. - */ -#if WAITQUEUE_DEBUG -#define WQ_BUG() BUG() -#define CHECK_MAGIC(x) \ - do { \ - if ((x) != (long)&(x)) { \ - printk("bad magic %lx (should be %lx), ", \ - (long)x, (long)&(x)); \ - WQ_BUG(); \ - } \ - } while (0) -#define CHECK_MAGIC_WQHEAD(x) \ - do { \ - if ((x)->__magic != (long)&((x)->__magic)) { \ - printk("bad magic %lx (should be %lx, creator %lx), ", \ - (x)->__magic, (long)&((x)->__magic), (x)->__creator); \ - WQ_BUG(); \ - } \ - } while (0) -#define WQ_CHECK_LIST_HEAD(list) \ - do { \ - if (!(list)->next || !(list)->prev) \ - WQ_BUG(); \ - } while(0) -#define WQ_NOTE_WAKER(tsk) \ - do { \ - (tsk)->__waker = (long)__builtin_return_address(0); \ - } while (0) -#else -#define WQ_BUG() -#define CHECK_MAGIC(x) -#define CHECK_MAGIC_WQHEAD(x) -#define WQ_CHECK_LIST_HEAD(list) -#define WQ_NOTE_WAKER(tsk) -#endif - -/* * Macros for declaration and initialisaton of the datatypes */ -#if WAITQUEUE_DEBUG -# define __WAITQUEUE_DEBUG_INIT(name) (long)&(name).__magic, 0 -# define __WAITQUEUE_HEAD_DEBUG_INIT(name) (long)&(name).__magic, (long)&(name).__magic -#else -# define __WAITQUEUE_DEBUG_INIT(name) -# define __WAITQUEUE_HEAD_DEBUG_INIT(name) -#endif - #define __WAITQUEUE_INITIALIZER(name, tsk) { \ task: tsk, \ - task_list: { NULL, NULL }, \ - __WAITQUEUE_DEBUG_INIT(name)} + task_list: { NULL, NULL } } #define DECLARE_WAITQUEUE(name, tsk) \ wait_queue_t name = __WAITQUEUE_INITIALIZER(name, tsk) #define __WAIT_QUEUE_HEAD_INITIALIZER(name) { \ lock: WAITQUEUE_RW_LOCK_UNLOCKED, \ - task_list: { &(name).task_list, &(name).task_list }, \ - __WAITQUEUE_HEAD_DEBUG_INIT(name)} + task_list: { &(name).task_list, &(name).task_list } } #define DECLARE_WAIT_QUEUE_HEAD(name) \ wait_queue_head_t name = __WAIT_QUEUE_HEAD_INITIALIZER(name) static inline void init_waitqueue_head(wait_queue_head_t *q) { -#if WAITQUEUE_DEBUG - if (!q) - WQ_BUG(); -#endif q->lock = WAITQUEUE_RW_LOCK_UNLOCKED; INIT_LIST_HEAD(&q->task_list); -#if WAITQUEUE_DEBUG - q->__magic = (long)&q->__magic; - q->__creator = (long)current_text_addr(); -#endif } static inline void init_waitqueue_entry(wait_queue_t *q, struct task_struct *p) { -#if WAITQUEUE_DEBUG - if (!q || !p) - WQ_BUG(); -#endif q->flags = 0; q->task = p; -#if WAITQUEUE_DEBUG - q->__magic = (long)&q->__magic; -#endif } static inline int waitqueue_active(wait_queue_head_t *q) { -#if WAITQUEUE_DEBUG - if (!q) - WQ_BUG(); - CHECK_MAGIC_WQHEAD(q); -#endif - return !list_empty(&q->task_list); } static inline void __add_wait_queue(wait_queue_head_t *head, wait_queue_t *new) { -#if WAITQUEUE_DEBUG - if (!head || !new) - WQ_BUG(); - CHECK_MAGIC_WQHEAD(head); - CHECK_MAGIC(new->__magic); - if (!head->task_list.next || !head->task_list.prev) - WQ_BUG(); -#endif list_add(&new->task_list, &head->task_list); } @@ -209,25 +114,12 @@ static inline void __add_wait_queue_tail(wait_queue_head_t *head, wait_queue_t *new) { -#if WAITQUEUE_DEBUG - if (!head || !new) - WQ_BUG(); - CHECK_MAGIC_WQHEAD(head); - CHECK_MAGIC(new->__magic); - if (!head->task_list.next || !head->task_list.prev) - WQ_BUG(); -#endif list_add_tail(&new->task_list, &head->task_list); } static inline void __remove_wait_queue(wait_queue_head_t *head, wait_queue_t *old) { -#if WAITQUEUE_DEBUG - if (!old) - WQ_BUG(); - CHECK_MAGIC(old->__magic); -#endif list_del(&old->task_list); } diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/include/net/dn_fib.h linux-2.5/include/net/dn_fib.h --- linux-2.5.1/include/net/dn_fib.h Mon Dec 11 21:33:56 2000 +++ linux-2.5/include/net/dn_fib.h Thu Dec 13 16:32:37 2001 @@ -113,9 +113,7 @@ int (*get_info)(struct dn_fib_table *table, char *buf, int first, int count); #endif /* CONFIG_PROC_FS */ -#ifdef CONFIG_RTNETLINK int (*dump)(struct dn_fib_table *t, struct sk_buff *skb, struct netlink_callback *cb); -#endif /* CONFIG_RTNETLINK */ unsigned char data[0]; }; @@ -163,7 +161,6 @@ /* * rtnetlink interface */ -#ifdef CONFIG_RTNETLINK extern int dn_fib_rtm_delroute(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg); extern int dn_fib_rtm_newroute(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg); extern int dn_fib_dump(struct sk_buff *skb, struct netlink_callback *cb); @@ -171,7 +168,6 @@ extern int dn_fib_rtm_delrule(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg); extern int dn_fib_rtm_newrule(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg); extern int dn_fib_dump_rules(struct sk_buff *skb, struct netlink_callback *cb); -#endif /* CONFIG_RTNETLINK */ #define DN_NUM_TABLES 255 #define DN_MIN_TABLE 1 diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/include/net/sock.h linux-2.5/include/net/sock.h --- linux-2.5.1/include/net/sock.h Sun Dec 16 23:44:19 2001 +++ linux-2.5/include/net/sock.h Mon Dec 31 21:56:31 2001 @@ -643,9 +643,7 @@ #if defined(CONFIG_PPPOE) || defined(CONFIG_PPPOE_MODULE) struct pppox_opt *pppox; #endif -#ifdef CONFIG_NETLINK struct netlink_opt *af_netlink; -#endif #if defined(CONFIG_ECONET) || defined(CONFIG_ECONET_MODULE) struct econet_opt *af_econet; #endif @@ -828,6 +826,11 @@ unsigned long size, int noblock, int *errcode); +extern struct sk_buff *sock_alloc_send_pskb(struct sock *sk, + unsigned long header_len, + unsigned long data_len, + int noblock, + int *errcode); extern void *sock_kmalloc(struct sock *sk, int size, int priority); extern void sock_kfree_s(struct sock *sk, void *mem, int size); diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/include/pcmcia/ciscode.h linux-2.5/include/pcmcia/ciscode.h --- linux-2.5.1/include/pcmcia/ciscode.h Fri Mar 2 19:02:15 2001 +++ linux-2.5/include/pcmcia/ciscode.h Thu Dec 13 16:32:37 2001 @@ -1,5 +1,5 @@ /* - * ciscode.h 1.45 2000/08/12 02:08:23 + * ciscode.h 1.48 2001/08/24 12:16:12 * * The contents of this file are subject to the Mozilla Public License * Version 1.1 (the "License"); you may not use this file except in @@ -16,8 +16,8 @@ * are Copyright (C) 1999 David A. Hinds. All Rights Reserved. * * Alternatively, the contents of this file may be used under the - * terms of the GNU General Public License version 2 (the "GPL"), in which - * case the provisions of the GPL are applicable instead of the + * terms of the GNU General Public License version 2 (the "GPL"), in + * which case the provisions of the GPL are applicable instead of the * above. If you wish to allow the use of your version of this file * only under the terms of the GPL and not to allow others to use * your version of this file under the MPL, indicate your decision by @@ -104,6 +104,8 @@ #define PRODID_QUATECH_DUAL_RS232 0x0012 #define PRODID_QUATECH_DUAL_RS232_D1 0x0007 #define PRODID_QUATECH_QUAD_RS232 0x001b +#define PRODID_QUATECH_DUAL_RS422 0x000e +#define PRODID_QUATECH_QUAD_RS422 0x0045 #define MANFID_SMC 0x0108 #define PRODID_SMC_ETHER 0x0105 diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/include/pcmcia/cs.h linux-2.5/include/pcmcia/cs.h --- linux-2.5.1/include/pcmcia/cs.h Sat Feb 17 00:02:37 2001 +++ linux-2.5/include/pcmcia/cs.h Thu Dec 13 16:32:37 2001 @@ -1,5 +1,5 @@ /* - * cs.h 1.71 2000/08/29 00:54:20 + * cs.h 1.74 2001/10/04 03:15:22 * * The contents of this file are subject to the Mozilla Public License * Version 1.1 (the "License"); you may not use this file except in @@ -16,8 +16,8 @@ * are Copyright (C) 1999 David A. Hinds. All Rights Reserved. * * Alternatively, the contents of this file may be used under the - * terms of the GNU General Public License version 2 (the "GPL"), in which - * case the provisions of the GPL are applicable instead of the + * terms of the GNU General Public License version 2 (the "GPL"), in + * which case the provisions of the GPL are applicable instead of the * above. If you wish to allow the use of your version of this file * only under the terms of the GPL and not to allow others to use * your version of this file under the MPL, indicate your decision by @@ -181,6 +181,7 @@ #define INT_MEMORY 0x01 #define INT_MEMORY_AND_IO 0x02 #define INT_CARDBUS 0x04 +#define INT_ZOOMED_VIDEO 0x08 /* For RequestIO and ReleaseIO */ typedef struct io_req_t { diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/include/scsi/scsicam.h linux-2.5/include/scsi/scsicam.h --- linux-2.5.1/include/scsi/scsicam.h Tue Feb 20 01:14:38 2001 +++ linux-2.5/include/scsi/scsicam.h Thu Dec 27 22:10:28 2001 @@ -14,6 +14,7 @@ #define SCSICAM_H #include <linux/kdev_t.h> extern int scsicam_bios_param (Disk *disk, kdev_t dev, int *ip); -extern int scsi_partsize(struct buffer_head *bh, unsigned long capacity, +extern int scsi_partsize(unsigned char *buf, unsigned long capacity, unsigned int *cyls, unsigned int *hds, unsigned int *secs); +extern unsigned char *scsi_bios_ptable(kdev_t dev); #endif /* def SCSICAM_H */ diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/include/scsi/sg.h linux-2.5/include/scsi/sg.h --- linux-2.5.1/include/scsi/sg.h Fri Sep 7 16:28:37 2001 +++ linux-2.5/include/scsi/sg.h Thu Dec 13 16:32:37 2001 @@ -11,9 +11,21 @@ Version 2 and 3 extensions to driver: * Copyright (C) 1998 - 2001 Douglas Gilbert - Version: 3.1.20 (20010814) + Version: 3.1.22 (20011208) This version is for 2.4 series kernels. + Changes since 3.1.21 (20011029) + - add support for SG_FLAG_MMAP_IO [permit mmap() on sg devices] + - update documentation pointers in this header + - put KERNEL_VERSION macros around code that breaks early 2.4 series + - fix use count for multiple queued requests on closed fd + - switch back to alloc_kiovec() + Changes since 3.1.20 (20010814) + - use alloc_kiovec_sz() to speed dio [set num_buffer_heads==0] + - changes to cope with larger scatter gather element sizes + - clean up some printk()s + - add MODULE_LICENSE("GPL") [in a 3.1.20 subversion] + - fix race around generic_unplug_device() [in a 3.1.20 subversion] Changes since 3.1.19 (20010623) - add SG_GET_ACCESS_COUNT ioctl - make open() increment and close() decrement access_count @@ -33,56 +45,57 @@ Map of SG verions to the Linux kernels in which they appear: ---------- ---------------------------------- original all kernels < 2.2.6 - 2.1.38 2.2.16 - 2.1.39 2.2.17 - 2.2.19 + 2.1.40 2.2.20 3.0.x optional version 3 sg driver for 2.2 series - 3.1.17 2.4.0 ++ + 3.1.17++ 2.4.0++ Major new features in SG 3.x driver (cf SG 2.x drivers) - SG_IO ioctl() combines function if write() and read() - new interface (sg_io_hdr_t) but still supports old interface - - scatter/gather in user space and direct IO supported + - scatter/gather in user space, direct IO, and mmap supported - The term "indirect IO" refers a method by which data is DMAed into kernel - buffers from the hardware and afterwards is transferred into the user - space (or vice versa if you are writing). Transfer speeds of up to 20 to - 30MBytes/sec have been measured using indirect IO. For faster throughputs - "direct IO" which cuts out the double handling of data is required. - Direct IO is supported by the SG 3.x drivers on 2.4 series Linux kernels - and requires the use of the new interface. - - Requests for direct IO with the new interface will automatically fall back - to indirect IO mode if they cannot be fulfilled. An example of such a case - is an ISA SCSI adapter which is only capable of DMAing to the lower 16MB of - memory due to the architecture of ISA. The 'info' field in the new - interface indicates whether a direct or indirect data transfer took place. - - Obtaining memory for the kernel buffers used in indirect IO is done by - first checking if the "reserved buffer" for the current file descriptor - is available and large enough. If these conditions are _not_ met then - kernel memory is obtained on a per SCSI command basis. This corresponds - to a write(), read() sequence or a SG_IO ioctl() call. Further, the - kernel memory that is suitable for DMA may be constrained by the - architecture of the SCSI adapter (e.g. ISA adapters). + The normal action of this driver is to use the adapter (HBA) driver to DMA + data into kernel buffers and then use the CPU to copy the data into the + user space (vice versa for writes). That is called "indirect" IO due to + the double handling of data. There are two methods offered to remove the + redundant copy: 1) direct IO which uses the kernel kiobuf mechanism and + 2) using the mmap() system call to map the reserve buffer (this driver has + one reserve buffer per fd) into the user space. Both have their advantages. + In terms of absolute speed mmap() is faster. If speed is not a concern, + indirect IO should be fine. Read the documentation for more information. ** N.B. To use direct IO 'echo 1 > /proc/scsi/sg/allow_dio' may be needed. That pseudo file's content is defaulted to 0. ** + + Historical note: this SCSI pass-through driver has been known as "sg" for + a decade. In broader kernel discussions "sg" is used to refer to scatter + gather techniques. The context should clarify which "sg" is referred to. Documentation ============= - A web site for SG device drivers can be found at: + A web site for the SG device driver can be found at: http://www.torque.net/sg [alternatively check the MAINTAINERS file] - The main documents are still based on 2.x versions: + The documentation for the sg version 3 driver can be found at: + http://www.torque.net/sg/p/sg_v3_ho.html + This is a rendering from DocBook source [change the extension to "sgml" + or "xml"]. There are renderings in "ps", "pdf", "rtf" and "txt" (soon). + + The older, version 2 documents discuss the original sg interface in detail: http://www.torque.net/sg/p/scsi-generic.txt http://www.torque.net/sg/p/scsi-generic_long.txt - Documentation on the changes and additions in 3.x version of the sg driver - can be found at: http://www.torque.net/sg/p/scsi-generic_v3.txt A version of this document (potentially out of date) may also be found in the kernel source tree, probably at: /usr/src/linux/Documentation/scsi-generic.txt . - Utility and test programs are available at the sg web site. + + Utility and test programs are available at the sg web site. They are + bundled as sg_utils (for the lk 2.2 series) and sg3_utils (for the + lk 2.4 series). + + There is a HOWTO on the Linux SCSI subsystem in the lk 2.4 series at: + http://www.linuxdoc.org/HOWTO/SCSI-2.4-HOWTO */ + /* New interface introduced in the 3.x SG drivers follows */ typedef struct sg_iovec /* same structure as used by readv() Linux system */ @@ -120,19 +133,20 @@ } sg_io_hdr_t; /* 64 bytes long (on i386) */ /* Use negative values to flag difference from original sg_header structure */ -#define SG_DXFER_NONE -1 /* e.g. a SCSI Test Unit Ready command */ -#define SG_DXFER_TO_DEV -2 /* e.g. a SCSI WRITE command */ -#define SG_DXFER_FROM_DEV -3 /* e.g. a SCSI READ command */ -#define SG_DXFER_TO_FROM_DEV -4 /* treated like SG_DXFER_FROM_DEV with the +#define SG_DXFER_NONE (-1) /* e.g. a SCSI Test Unit Ready command */ +#define SG_DXFER_TO_DEV (-2) /* e.g. a SCSI WRITE command */ +#define SG_DXFER_FROM_DEV (-3) /* e.g. a SCSI READ command */ +#define SG_DXFER_TO_FROM_DEV (-4) /* treated like SG_DXFER_FROM_DEV with the additional property than during indirect IO the user buffer is copied into the kernel buffers before the transfer */ -#define SG_DXFER_UNKNOWN -5 /* Unknown data direction */ +#define SG_DXFER_UNKNOWN (-5) /* Unknown data direction */ /* following flag values can be "or"-ed together */ #define SG_FLAG_DIRECT_IO 1 /* default is indirect IO */ -#define SG_FLAG_LUN_INHIBIT 2 /* default is to put device's lun into */ - /* the 2nd byte of SCSI command */ +#define SG_FLAG_LUN_INHIBIT 2 /* default is overwrite lun in SCSI */ + /* command block (when <= SCSI_2) */ +#define SG_FLAG_MMAP_IO 4 /* request memory mapped IO */ #define SG_FLAG_NO_DXFER 0x10000 /* no transfer of kernel buffers to/from */ /* user space (debug indirect IO) */ diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/init/do_mounts.c linux-2.5/init/do_mounts.c --- linux-2.5.1/init/do_mounts.c Sun Dec 16 20:27:48 2001 +++ linux-2.5/init/do_mounts.c Thu Dec 27 15:56:12 2001 @@ -3,13 +3,10 @@ #include <linux/slab.h> #include <linux/devfs_fs_kernel.h> #include <linux/unistd.h> -#include <linux/string.h> #include <linux/ctype.h> -#include <linux/init.h> -#include <linux/smp_lock.h> #include <linux/blk.h> -#include <linux/tty.h> #include <linux/fd.h> +#include <linux/tty.h> #include <linux/nfs_fs.h> #include <linux/nfs_fs_sb.h> @@ -18,12 +15,9 @@ #include <linux/ext2_fs.h> #include <linux/romfs_fs.h> -#include <asm/uaccess.h> - #define BUILD_CRAMDISK extern int get_filesystem_list(char * buf); -extern void wait_for_keypress(void); asmlinkage long sys_mount(char *dev_name, char *dir_name, char *type, unsigned long flags, void *data); @@ -38,12 +32,21 @@ #ifdef CONFIG_BLK_DEV_INITRD unsigned int real_root_dev; /* do_proc_dointvec cannot handle kdev_t */ -#endif -#ifdef CONFIG_BLK_DEV_RAM -extern int rd_doload; +static int __initdata mount_initrd = 1; + +static int __init no_initrd(char *str) +{ + mount_initrd = 0; + return 1; +} + +__setup("noinitrd", no_initrd); #else -static int rd_doload = 0; +static int __initdata mount_initrd = 0; #endif + +int __initdata rd_doload; /* 1 = load RAM disk, 0 = don't load */ + int root_mountflags = MS_RDONLY | MS_VERBOSE; static char root_device_name[64]; @@ -52,6 +55,13 @@ static int do_devfs = 0; +static int __init load_ramdisk(char *str) +{ + rd_doload = simple_strtol(str,NULL,0) & 3; + return 1; +} +__setup("load_ramdisk=", load_ramdisk); + static int __init readonly(char *str) { if (*str) @@ -353,8 +363,9 @@ static void __init change_floppy(char *fmt, ...) { - extern void wait_for_keypress(void); + struct termios termios; char buf[80]; + char c; int fd; va_list args; va_start(args, fmt); @@ -366,11 +377,38 @@ close(fd); } printk(KERN_NOTICE "VFS: Insert %s and press ENTER\n", buf); - wait_for_keypress(); + fd = open("/dev/console", O_RDWR, 0); + if (fd >= 0) { + sys_ioctl(fd, TCGETS, (long)&termios); + termios.c_lflag &= ~ICANON; + sys_ioctl(fd, TCSETSF, (long)&termios); + read(fd, &c, 1); + termios.c_lflag |= ICANON; + sys_ioctl(fd, TCSETSF, (long)&termios); + close(fd); + } } #ifdef CONFIG_BLK_DEV_RAM +int __initdata rd_prompt = 1; /* 1 = prompt for RAM disk, 0 = don't prompt */ + +static int __init prompt_ramdisk(char *str) +{ + rd_prompt = simple_strtol(str,NULL,0) & 1; + return 1; +} +__setup("prompt_ramdisk=", prompt_ramdisk); + +int __initdata rd_image_start; /* starting block # of image */ + +static int __init ramdisk_start_setup(char *str) +{ + rd_image_start = simple_strtol(str,NULL,0); + return 1; +} +__setup("ramdisk_start=", ramdisk_start_setup); + static int __init crd_load(int in_fd, int out_fd); /* @@ -588,7 +626,6 @@ static int __init rd_load_disk(int n) { #ifdef CONFIG_BLK_DEV_RAM - extern int rd_prompt; if (rd_prompt) change_floppy("root floppy disk to be loaded into RAM disk"); create_dev("/dev/ram", MKDEV(RAMDISK_MAJOR, n), NULL); @@ -596,6 +633,63 @@ return rd_load_image("/dev/root"); } +#ifdef CONFIG_DEVFS_FS + +static void __init convert_name(char *prefix, char *name, char *p, int part) +{ + int host, bus, target, lun; + char dest[64]; + char src[64]; + char *base = p - 1; + + /* Decode "c#b#t#u#" */ + if (*p++ != 'c') + return; + host = simple_strtol(p, &p, 10); + if (*p++ != 'b') + return; + bus = simple_strtol(p, &p, 10); + if (*p++ != 't') + return; + target = simple_strtol(p, &p, 10); + if (*p++ != 'u') + return; + lun = simple_strtol(p, &p, 10); + if (!part) + sprintf(dest, "%s/host%d/bus%d/target%d/lun%d", + prefix, host, bus, target, lun); + else if (*p++ == 'p') + sprintf(dest, "%s/host%d/bus%d/target%d/lun%d/part%s", + prefix, host, bus, target, lun, p); + else + sprintf(dest, "%s/host%d/bus%d/target%d/lun%d/disc", + prefix, host, bus, target, lun); + *base = '\0'; + sprintf(src, "/dev/%s", name); + sys_mkdir(src, 0755); + *base = '/'; + sprintf(src, "/dev/%s", name); + sys_symlink(dest, src); +} + +static void __init devfs_make_root(char *name) +{ + + if (!strncmp(name, "sd/", 3)) + convert_name("../scsi", name, name+3, 1); + else if (!strncmp(name, "sr/", 3)) + convert_name("../scsi", name, name+3, 0); + else if (!strncmp(name, "ide/hd/", 7)) + convert_name("..", name, name + 7, 1); + else if (!strncmp(name, "ide/cd/", 7)) + convert_name("..", name, name + 7, 0); +} +#else +static void __init devfs_make_root(char *name) +{ +} +#endif + static void __init mount_root(void) { #ifdef CONFIG_ROOT_NFS @@ -715,24 +809,22 @@ */ void prepare_namespace(void) { - int do_initrd = 0; int is_floppy = MAJOR(ROOT_DEV) == FLOPPY_MAJOR; #ifdef CONFIG_BLK_DEV_INITRD if (!initrd_start) mount_initrd = 0; - if (mount_initrd) - do_initrd = 1; real_root_dev = ROOT_DEV; #endif sys_mkdir("/dev", 0700); sys_mkdir("/root", 0700); + sys_mknod("/dev/console", S_IFCHR|0600, MKDEV(TTYAUX_MAJOR, 1)); #ifdef CONFIG_DEVFS_FS sys_mount("devfs", "/dev", "devfs", 0, NULL); do_devfs = 1; #endif create_dev("/dev/root", ROOT_DEV, NULL); - if (do_initrd) { + if (mount_initrd) { if (initrd_load() && ROOT_DEV != MKDEV(RAMDISK_MAJOR, 0)) { handle_initrd(); goto out; diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/init/main.c linux-2.5/init/main.c --- linux-2.5.1/init/main.c Sat Dec 8 00:24:52 2001 +++ linux-2.5/init/main.c Sat Dec 29 12:07:19 2001 @@ -62,6 +62,10 @@ #include <linux/isapnp.h> #endif +#ifdef CONFIG_PNPBIOS +#include <linux/pnpbios.h> +#endif + #ifdef CONFIG_IRDA extern int irda_proto_init(void); extern int irda_device_init(void); @@ -516,6 +520,9 @@ #endif #ifdef CONFIG_ISAPNP isapnp_init(); +#endif +#ifdef CONFIG_PNPBIOS + pnpbios_init(); #endif #ifdef CONFIG_TC tc_init(); diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/ipc/shm.c linux-2.5/ipc/shm.c --- linux-2.5.1/ipc/shm.c Sun Dec 9 04:31:51 2001 +++ linux-2.5/ipc/shm.c Sun Dec 30 20:01:41 2001 @@ -17,6 +17,7 @@ #include <linux/config.h> #include <linux/slab.h> +#include <linux/mm.h> #include <linux/shm.h> #include <linux/init.h> #include <linux/file.h> diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/kernel/acct.c linux-2.5/kernel/acct.c --- linux-2.5.1/kernel/acct.c Mon Mar 19 20:35:08 2001 +++ linux-2.5/kernel/acct.c Thu Dec 27 22:10:28 2001 @@ -213,10 +213,10 @@ goto out; } -void acct_auto_close(kdev_t dev) +void acct_auto_close(struct super_block *sb) { lock_kernel(); - if (acct_file && acct_file->f_dentry->d_inode->i_dev == dev) + if (acct_file && acct_file->f_dentry->d_inode->i_sb == sb) sys_acct(NULL); unlock_kernel(); } diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/kernel/exit.c linux-2.5/kernel/exit.c --- linux-2.5.1/kernel/exit.c Fri Nov 30 18:02:34 2001 +++ linux-2.5/kernel/exit.c Sun Dec 30 20:01:41 2001 @@ -5,6 +5,7 @@ */ #include <linux/config.h> +#include <linux/mm.h> #include <linux/slab.h> #include <linux/interrupt.h> #include <linux/smp_lock.h> @@ -12,6 +13,7 @@ #include <linux/completion.h> #include <linux/personality.h> #include <linux/tty.h> +#include <linux/namespace.h> #ifdef CONFIG_BSD_PROCESS_ACCT #include <linux/acct.h> #endif @@ -62,9 +64,9 @@ * timeslices, because any timeslice recovered here * was given away by the parent in the first place.) */ - current->counter += p->counter; - if (current->counter >= MAX_COUNTER) - current->counter = MAX_COUNTER; + current->time_slice += p->time_slice; + if (current->time_slice > MAX_TSLICE) + current->time_slice = MAX_TSLICE; p->pid = 0; free_task_struct(p); } else { @@ -452,6 +454,7 @@ sem_exit(); __exit_files(tsk); __exit_fs(tsk); + exit_namespace(tsk); exit_sighand(tsk); exit_thread(); diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/kernel/fork.c linux-2.5/kernel/fork.c --- linux-2.5.1/kernel/fork.c Fri Nov 30 23:53:28 2001 +++ linux-2.5/kernel/fork.c Sun Dec 30 20:01:41 2001 @@ -19,6 +19,7 @@ #include <linux/module.h> #include <linux/vmalloc.h> #include <linux/completion.h> +#include <linux/namespace.h> #include <linux/personality.h> #include <asm/pgtable.h> @@ -340,11 +341,6 @@ if (retval) goto free_pt; - /* - * child gets a private LDT (if there was an LDT in the parent) - */ - copy_segments(tsk, mm); - if (init_new_context(tsk,mm)) goto free_pt; @@ -566,6 +562,9 @@ struct task_struct *p; struct completion vfork; + if ((clone_flags & (CLONE_NEWNS|CLONE_FS)) == (CLONE_NEWNS|CLONE_FS)) + return -EINVAL; + retval = -EPERM; /* @@ -585,8 +584,10 @@ *p = *current; retval = -EAGAIN; - if (atomic_read(&p->user->processes) >= p->rlim[RLIMIT_NPROC].rlim_cur) - goto bad_fork_free; + if (atomic_read(&p->user->processes) >= p->rlim[RLIMIT_NPROC].rlim_cur) { + if (!capable(CAP_SYS_ADMIN) && !capable(CAP_SYS_RESOURCE)) + goto bad_fork_free; + } atomic_inc(&p->user->__count); atomic_inc(&p->user->processes); @@ -661,9 +662,11 @@ goto bad_fork_cleanup_fs; if (copy_mm(clone_flags, p)) goto bad_fork_cleanup_sighand; + if (copy_namespace(clone_flags, p)) + goto bad_fork_cleanup_mm; retval = copy_thread(0, clone_flags, stack_start, stack_size, p, regs); if (retval) - goto bad_fork_cleanup_mm; + goto bad_fork_cleanup_namespace; p->semundo = NULL; /* Our parent execution domain becomes current domain @@ -682,9 +685,9 @@ * more scheduling fairness. This is only important in the first * timeslice, on the long run the scheduling behaviour is unchanged. */ - p->counter = (current->counter + 1) >> 1; - current->counter >>= 1; - if (!current->counter) + p->time_slice = (current->time_slice + 1) >> 1; + current->time_slice >>= 1; + if (!current->time_slice) current->need_resched = 1; /* @@ -730,6 +733,8 @@ fork_out: return retval; +bad_fork_cleanup_namespace: + exit_namespace(p); bad_fork_cleanup_mm: exit_mm(p); bad_fork_cleanup_sighand: diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/kernel/kmod.c linux-2.5/kernel/kmod.c --- linux-2.5.1/kernel/kmod.c Wed Jul 18 01:23:50 2001 +++ linux-2.5/kernel/kmod.c Thu Dec 27 15:56:12 2001 @@ -24,6 +24,8 @@ #include <linux/unistd.h> #include <linux/kmod.h> #include <linux/smp_lock.h> +#include <linux/slab.h> +#include <linux/namespace.h> #include <linux/completion.h> #include <asm/uaccess.h> @@ -36,6 +38,7 @@ struct fs_struct *our_fs, *init_fs; struct dentry *root, *pwd; struct vfsmount *rootmnt, *pwdmnt; + struct namespace *our_ns, *init_ns; /* * Make modprobe's fs context be a copy of init's. @@ -55,6 +58,11 @@ */ init_fs = init_task.fs; + init_ns = init_task.namespace; + get_namespace(init_ns); + our_ns = current->namespace; + current->namespace = init_ns; + put_namespace(our_ns); read_lock(&init_fs->lock); rootmnt = mntget(init_fs->rootmnt); root = dget(init_fs->root); diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/kernel/ksyms.c linux-2.5/kernel/ksyms.c --- linux-2.5.1/kernel/ksyms.c Sun Dec 16 20:20:21 2001 +++ linux-2.5/kernel/ksyms.c Thu Dec 27 22:10:28 2001 @@ -46,6 +46,7 @@ #include <linux/tty.h> #include <linux/in6.h> #include <linux/completion.h> +#include <linux/seq_file.h> #include <asm/checksum.h> #if defined(CONFIG_PROC_FS) @@ -116,11 +117,11 @@ EXPORT_SYMBOL(find_vma); EXPORT_SYMBOL(get_unmapped_area); EXPORT_SYMBOL(init_mm); +EXPORT_SYMBOL(create_bounce); #ifdef CONFIG_HIGHMEM EXPORT_SYMBOL(kmap_high); EXPORT_SYMBOL(kunmap_high); EXPORT_SYMBOL(highmem_start_page); -EXPORT_SYMBOL(create_bounce); EXPORT_SYMBOL(kmap_prot); EXPORT_SYMBOL(kmap_pte); #endif @@ -188,6 +189,8 @@ EXPORT_SYMBOL(write_inode_now); EXPORT_SYMBOL(notify_change); EXPORT_SYMBOL(set_blocksize); +EXPORT_SYMBOL(sb_set_blocksize); +EXPORT_SYMBOL(sb_min_blocksize); EXPORT_SYMBOL(getblk); EXPORT_SYMBOL(cdget); EXPORT_SYMBOL(cdput); @@ -305,6 +308,7 @@ EXPORT_SYMBOL(ioctl_by_bdev); EXPORT_SYMBOL(grok_partitions); EXPORT_SYMBOL(register_disk); +EXPORT_SYMBOL(read_dev_sector); EXPORT_SYMBOL(tq_disk); EXPORT_SYMBOL(init_buffer); EXPORT_SYMBOL(refile_buffer); @@ -354,9 +358,7 @@ EXPORT_SYMBOL(del_timer); EXPORT_SYMBOL(request_irq); EXPORT_SYMBOL(free_irq); -#if !defined(CONFIG_ARCH_S390) -EXPORT_SYMBOL(irq_stat); /* No separate irq_stat for s390, it is part of PSA */ -#endif +EXPORT_SYMBOL(irq_stat); /* waitqueue handling */ EXPORT_SYMBOL(add_wait_queue); @@ -461,6 +463,7 @@ EXPORT_SYMBOL(bdevname); EXPORT_SYMBOL(cdevname); EXPORT_SYMBOL(simple_strtoul); +EXPORT_SYMBOL(simple_strtoull); EXPORT_SYMBOL(system_utsname); /* UTS data */ EXPORT_SYMBOL(uts_sem); /* UTS semaphore */ #ifndef __mips__ @@ -477,6 +480,12 @@ EXPORT_SYMBOL(reparent_to_init); EXPORT_SYMBOL(daemonize); EXPORT_SYMBOL(csum_partial); /* for networking and md */ +EXPORT_SYMBOL(seq_escape); +EXPORT_SYMBOL(seq_printf); +EXPORT_SYMBOL(seq_open); +EXPORT_SYMBOL(seq_release); +EXPORT_SYMBOL(seq_read); +EXPORT_SYMBOL(seq_lseek); /* Program loader interfaces */ EXPORT_SYMBOL(setup_arg_pages); diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/kernel/panic.c linux-2.5/kernel/panic.c --- linux-2.5.1/kernel/panic.c Sun Sep 30 19:26:08 2001 +++ linux-2.5/kernel/panic.c Sun Dec 16 04:54:34 2001 @@ -96,6 +96,10 @@ #endif sti(); for(;;) { +#if defined(__i386__) && defined(CONFIG_VT) + extern void panic_blink(void); + panic_blink(); +#endif CHECK_EMERGENCY_SYNC } } diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/kernel/pm.c linux-2.5/kernel/pm.c --- linux-2.5.1/kernel/pm.c Fri Apr 6 17:51:19 2001 +++ linux-2.5/kernel/pm.c Sun Dec 30 20:01:41 2001 @@ -20,6 +20,7 @@ #include <linux/module.h> #include <linux/spinlock.h> +#include <linux/mm.h> #include <linux/slab.h> #include <linux/pm.h> #include <linux/interrupt.h> diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/kernel/printk.c linux-2.5/kernel/printk.c --- linux-2.5.1/kernel/printk.c Sun Nov 11 18:20:21 2001 +++ linux-2.5/kernel/printk.c Thu Dec 27 16:32:31 2001 @@ -16,6 +16,7 @@ * 01Mar01 Andrew Morton <andrewm@uow.edu.au> */ +#include <linux/kernel.h> #include <linux/mm.h> #include <linux/tty.h> #include <linux/tty_driver.h> @@ -30,6 +31,8 @@ #ifdef CONFIG_MULTIQUAD #define LOG_BUF_LEN (65536) +#elif defined(CONFIG_ARCH_S390) +#define LOG_BUF_LEN (131072) #elif defined(CONFIG_SMP) #define LOG_BUF_LEN (32768) #else @@ -38,6 +41,10 @@ #define LOG_BUF_MASK (LOG_BUF_LEN-1) +#ifndef arch_consoles_callable +#define arch_consoles_callable() (1) +#endif + /* printk's without a loglevel use this.. */ #define DEFAULT_MESSAGE_LOGLEVEL 4 /* KERN_WARNING */ @@ -47,11 +54,12 @@ DECLARE_WAIT_QUEUE_HEAD(log_wait); -/* Keep together for sysctl support */ -int console_loglevel = DEFAULT_CONSOLE_LOGLEVEL; -int default_message_loglevel = DEFAULT_MESSAGE_LOGLEVEL; -int minimum_console_loglevel = MINIMUM_CONSOLE_LOGLEVEL; -int default_console_loglevel = DEFAULT_CONSOLE_LOGLEVEL; +int console_printk[4] = { + DEFAULT_CONSOLE_LOGLEVEL, /* console_loglevel */ + DEFAULT_MESSAGE_LOGLEVEL, /* default_message_loglevel */ + MINIMUM_CONSOLE_LOGLEVEL, /* minimum_console_loglevel */ + DEFAULT_CONSOLE_LOGLEVEL, /* default_console_loglevel */ +}; int oops_in_progress; @@ -438,6 +446,14 @@ log_level_unknown = 1; } + if (!arch_consoles_callable()) { + /* + * On some architectures, the consoles are not usable + * on secondary CPUs early in the boot process. + */ + spin_unlock_irqrestore(&logbuf_lock, flags); + goto out; + } if (!down_trylock(&console_sem)) { /* * We own the drivers. We can drop the spinlock and let @@ -454,6 +470,7 @@ */ spin_unlock_irqrestore(&logbuf_lock, flags); } +out: return printed_len; } EXPORT_SYMBOL(printk); diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/kernel/ptrace.c linux-2.5/kernel/ptrace.c --- linux-2.5.1/kernel/ptrace.c Wed Nov 21 22:43:01 2001 +++ linux-2.5/kernel/ptrace.c Thu Dec 13 16:32:37 2001 @@ -121,119 +121,17 @@ } /* - * Access another process' address space, one page at a time. + * Access another process' address space. + * Source/target buffer must be kernel space, + * Do not walk the page table directly, use get_user_pages */ -static int access_one_page(struct mm_struct * mm, struct vm_area_struct * vma, unsigned long addr, void *buf, int len, int write) -{ - pgd_t * pgdir; - pmd_t * pgmiddle; - pte_t * pgtable; - char *maddr; - struct page *page; - -repeat: - spin_lock(&mm->page_table_lock); - pgdir = pgd_offset(vma->vm_mm, addr); - if (pgd_none(*pgdir)) - goto fault_in_page; - if (pgd_bad(*pgdir)) - goto bad_pgd; - pgmiddle = pmd_offset(pgdir, addr); - if (pmd_none(*pgmiddle)) - goto fault_in_page; - if (pmd_bad(*pgmiddle)) - goto bad_pmd; - pgtable = pte_offset(pgmiddle, addr); - if (!pte_present(*pgtable)) - goto fault_in_page; - if (write && (!pte_write(*pgtable) || !pte_dirty(*pgtable))) - goto fault_in_page; - page = pte_page(*pgtable); - - /* ZERO_PAGE is special: reads from it are ok even though it's marked reserved */ - if (page != ZERO_PAGE(addr) || write) { - if ((!VALID_PAGE(page)) || PageReserved(page)) { - spin_unlock(&mm->page_table_lock); - return 0; - } - } - get_page(page); - spin_unlock(&mm->page_table_lock); - flush_cache_page(vma, addr); - - if (write) { - maddr = kmap(page); - memcpy(maddr + (addr & ~PAGE_MASK), buf, len); - flush_page_to_ram(page); - flush_icache_page(vma, page); - kunmap(page); - } else { - maddr = kmap(page); - memcpy(buf, maddr + (addr & ~PAGE_MASK), len); - flush_page_to_ram(page); - kunmap(page); - } - put_page(page); - return len; - -fault_in_page: - spin_unlock(&mm->page_table_lock); - /* -1: out of memory. 0 - unmapped page */ - if (handle_mm_fault(mm, vma, addr, write) > 0) - goto repeat; - return 0; - -bad_pgd: - spin_unlock(&mm->page_table_lock); - pgd_ERROR(*pgdir); - return 0; - -bad_pmd: - spin_unlock(&mm->page_table_lock); - pmd_ERROR(*pgmiddle); - return 0; -} - -static int access_mm(struct mm_struct *mm, struct vm_area_struct * vma, unsigned long addr, void *buf, int len, int write) -{ - int copied = 0; - - for (;;) { - unsigned long offset = addr & ~PAGE_MASK; - int this_len = PAGE_SIZE - offset; - int retval; - - if (this_len > len) - this_len = len; - retval = access_one_page(mm, vma, addr, buf, this_len, write); - copied += retval; - if (retval != this_len) - break; - - len -= retval; - if (!len) - break; - - addr += retval; - buf += retval; - - if (addr < vma->vm_end) - continue; - if (!vma->vm_next) - break; - if (vma->vm_next->vm_start != vma->vm_end) - break; - - vma = vma->vm_next; - } - return copied; -} int access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, int len, int write) { - int copied; struct mm_struct *mm; - struct vm_area_struct * vma; + struct vm_area_struct *vma; + struct page *page; + void *old_buf = buf; /* Worry about races with exit() */ task_lock(tsk); @@ -245,14 +143,41 @@ return 0; down_read(&mm->mmap_sem); - vma = find_extend_vma(mm, addr); - copied = 0; - if (vma) - copied = access_mm(mm, vma, addr, buf, len, write); + /* ignore errors, just check how much was sucessfully transfered */ + while (len) { + int bytes, ret, offset; + void *maddr; + + ret = get_user_pages(current, mm, addr, 1, + write, 1, &page, &vma); + if (ret <= 0) + break; + + bytes = len; + offset = addr & (PAGE_SIZE-1); + if (bytes > PAGE_SIZE-offset) + bytes = PAGE_SIZE-offset; + flush_cache_page(vma, addr); + + maddr = kmap(page); + if (write) { + memcpy(maddr + offset, buf, bytes); + flush_page_to_ram(page); + flush_icache_page(vma, page); + } else { + memcpy(buf, maddr + offset, bytes); + flush_page_to_ram(page); + } + kunmap(page); + put_page(page); + len -= bytes; + buf += bytes; + } up_read(&mm->mmap_sem); mmput(mm); - return copied; + + return buf - old_buf; } int ptrace_readdata(struct task_struct *tsk, unsigned long src, char *dst, int len) diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/kernel/sched.c linux-2.5/kernel/sched.c --- linux-2.5.1/kernel/sched.c Thu Nov 22 00:25:48 2001 +++ linux-2.5/kernel/sched.c Sun Dec 30 20:01:41 2001 @@ -68,7 +68,7 @@ #define TICK_SCALE(x) ((x) << 2) #endif -#define NICE_TO_TICKS(nice) (TICK_SCALE(20-(nice))+1) +#define TASK_TIMESLICE(p) (TICK_SCALE(20-(p)->nice)+1) /* @@ -94,6 +94,8 @@ static LIST_HEAD(runqueue_head); +static unsigned long rcl_curr; + /* * We align per-CPU scheduling data on cacheline boundaries, * to prevent cacheline ping-pong. @@ -165,10 +167,11 @@ * Don't do any other calculations if the time slice is * over.. */ - weight = p->counter; - if (!weight) - goto out; - + if (!p->time_slice) + return 0; + + weight = p->dyn_prio + 1; + #ifdef CONFIG_SMP /* Give a largish advantage to the same processor... */ /* (this is equivalent to penalizing other processors) */ @@ -262,6 +265,21 @@ * a problem. */ if (tsk == idle_task(cpu)) { +#if defined(__i386__) && defined(CONFIG_SMP) + /* + * Check if two siblings are idle in the same + * physical package. Use them if found. + */ + if (smp_num_siblings == 2) { + if (cpu_curr(cpu_sibling_map[cpu]) == + idle_task(cpu_sibling_map[cpu])) { + oldest_idle = last_schedule(cpu); + target_tsk = tsk; + break; + } + + } +#endif if (last_schedule(cpu) < oldest_idle) { oldest_idle = last_schedule(cpu); target_tsk = tsk; @@ -309,6 +327,10 @@ */ static inline void add_to_runqueue(struct task_struct * p) { + p->dyn_prio += rcl_curr - p->rcl_last; + p->rcl_last = rcl_curr; + if (p->dyn_prio > MAX_DYNPRIO) + p->dyn_prio = MAX_DYNPRIO; list_add(&p->run_list, &runqueue_head); nr_running++; } @@ -361,9 +383,7 @@ static void process_timeout(unsigned long __data) { - struct task_struct * p = (struct task_struct *) __data; - - wake_up_process(p); + wake_up_process((struct task_struct *)__data); } /** @@ -521,6 +541,25 @@ __schedule_tail(prev); } +void expire_task(struct task_struct *p) +{ + if (unlikely(!p->time_slice)) + goto need_resched; + + if (!--p->time_slice) { + if (p->dyn_prio > 0) { + p->time_slice--; + p->dyn_prio--; + } + p->need_resched = 1; + } else + if (p->time_slice < -TASK_TIMESLICE(p)) { + p->time_slice = 0; +need_resched: + p->need_resched = 1; + } +} + /* * 'schedule()' is the scheduler function. It's a very simple and nice * scheduler: it's not perfect, but certainly works for most things. @@ -563,20 +602,20 @@ /* move an exhausted RR process to be last.. */ if (unlikely(prev->policy == SCHED_RR)) - if (!prev->counter) { - prev->counter = NICE_TO_TICKS(prev->nice); + if (!prev->time_slice) { + prev->time_slice = TASK_TIMESLICE(prev); move_last_runqueue(prev); } switch (prev->state) { - case TASK_INTERRUPTIBLE: - if (signal_pending(prev)) { - prev->state = TASK_RUNNING; - break; - } - default: - del_from_runqueue(prev); - case TASK_RUNNING:; + case TASK_INTERRUPTIBLE: + if (signal_pending(prev)) { + prev->state = TASK_RUNNING; + break; + } + default: + del_from_runqueue(prev); + case TASK_RUNNING:; } prev->need_resched = 0; @@ -601,14 +640,12 @@ /* Do we need to re-calculate counters? */ if (unlikely(!c)) { - struct task_struct *p; - - spin_unlock_irq(&runqueue_lock); - read_lock(&tasklist_lock); - for_each_task(p) - p->counter = (p->counter >> 1) + NICE_TO_TICKS(p->nice); - read_unlock(&tasklist_lock); - spin_lock_irq(&runqueue_lock); + rcl_curr++; + list_for_each(tmp, &runqueue_head) { + p = list_entry(tmp, struct task_struct, run_list); + p->time_slice = TASK_TIMESLICE(p); + p->rcl_last = rcl_curr; + } goto repeat_schedule; } @@ -704,21 +741,17 @@ struct list_head *tmp; struct task_struct *p; - CHECK_MAGIC_WQHEAD(q); - WQ_CHECK_LIST_HEAD(&q->task_list); - list_for_each(tmp,&q->task_list) { unsigned int state; - wait_queue_t *curr = list_entry(tmp, wait_queue_t, task_list); + wait_queue_t *curr = list_entry(tmp, wait_queue_t, task_list); - CHECK_MAGIC(curr->__magic); p = curr->task; state = p->state; - if (state & mode) { - WQ_NOTE_WAKER(curr); - if (try_to_wake_up(p, sync) && (curr->flags&WQ_FLAG_EXCLUSIVE) && !--nr_exclusive) - break; - } + if ((state & mode) && + try_to_wake_up(p, sync) && + ((curr->flags & WQ_FLAG_EXCLUSIVE) && + !--nr_exclusive)) + break; } } @@ -876,11 +909,7 @@ static inline struct task_struct *find_process_by_pid(pid_t pid) { - struct task_struct *tsk = current; - - if (pid) - tsk = find_task_by_pid(pid); - return tsk; + return pid ? find_task_by_pid(pid) : current; } static int setscheduler(pid_t pid, int policy, @@ -1049,9 +1078,8 @@ current->policy |= SCHED_YIELD; current->need_resched = 1; - spin_lock_irq(&runqueue_lock); - move_last_runqueue(current); - spin_unlock_irq(&runqueue_lock); + current->time_slice = 0; + current->dyn_prio++; } return 0; } @@ -1100,7 +1128,7 @@ read_lock(&tasklist_lock); p = find_process_by_pid(pid); if (p) - jiffies_to_timespec(p->policy & SCHED_FIFO ? 0 : NICE_TO_TICKS(p->nice), + jiffies_to_timespec(p->policy & SCHED_FIFO ? 0 : TASK_TIMESLICE(p), &t); read_unlock(&tasklist_lock); if (p) @@ -1216,35 +1244,33 @@ */ void reparent_to_init(void) { - struct task_struct *this_task = current; - write_lock_irq(&tasklist_lock); /* Reparent to init */ - REMOVE_LINKS(this_task); - this_task->p_pptr = child_reaper; - this_task->p_opptr = child_reaper; - SET_LINKS(this_task); + REMOVE_LINKS(current); + current->p_pptr = child_reaper; + current->p_opptr = child_reaper; + SET_LINKS(current); /* Set the exit signal to SIGCHLD so we signal init on exit */ - this_task->exit_signal = SIGCHLD; + current->exit_signal = SIGCHLD; /* We also take the runqueue_lock while altering task fields * which affect scheduling decisions */ spin_lock(&runqueue_lock); - this_task->ptrace = 0; - this_task->nice = DEF_NICE; - this_task->policy = SCHED_OTHER; + current->ptrace = 0; + current->nice = DEF_NICE; + current->policy = SCHED_OTHER; /* cpus_allowed? */ /* rt_priority? */ /* signals? */ - this_task->cap_effective = CAP_INIT_EFF_SET; - this_task->cap_inheritable = CAP_INIT_INH_SET; - this_task->cap_permitted = CAP_FULL_SET; - this_task->keep_capabilities = 0; - memcpy(this_task->rlim, init_task.rlim, sizeof(*(this_task->rlim))); - this_task->user = INIT_USER; + current->cap_effective = CAP_INIT_EFF_SET; + current->cap_inheritable = CAP_INIT_INH_SET; + current->cap_permitted = CAP_FULL_SET; + current->keep_capabilities = 0; + memcpy(current->rlim, init_task.rlim, sizeof(*(current->rlim))); + current->user = INIT_USER; spin_unlock(&runqueue_lock); write_unlock_irq(&tasklist_lock); @@ -1291,9 +1317,10 @@ if (current != &init_task && task_on_runqueue(current)) { printk("UGH! (%d:%d) was on the runqueue, removing.\n", - smp_processor_id(), current->pid); + smp_processor_id(), current->pid); del_from_runqueue(current); } + current->dyn_prio = 0; sched_data->curr = current; sched_data->last_schedule = get_cycles(); clear_bit(current->processor, &wait_init_idle); diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/kernel/signal.c linux-2.5/kernel/signal.c --- linux-2.5.1/kernel/signal.c Fri Dec 14 20:25:24 2001 +++ linux-2.5/kernel/signal.c Mon Dec 17 18:16:36 2001 @@ -649,10 +649,8 @@ /* * kill_something_info() interprets pid in interesting ways just like kill(2). * - * POSIX (2001) specifies "If pid is -1, sig shall be sent to all processes - * (excluding an unspecified set of system processes) for which the process - * has permission to send that signal." - * So, probably the process should also signal itself. + * POSIX specifies that kill(-1,sig) is unspecified, but what we have + * is probably wrong. Should make it like BSD or SYSV. */ static int kill_something_info(int sig, struct siginfo *info, int pid) @@ -665,7 +663,7 @@ read_lock(&tasklist_lock); for_each_task(p) { - if (p->pid > 1) { + if (p->pid > 1 && p != current) { int err = send_sig_info(sig, info, p); ++count; if (err != -EPERM) diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/kernel/sysctl.c linux-2.5/kernel/sysctl.c --- linux-2.5.1/kernel/sysctl.c Mon Dec 10 18:39:20 2001 +++ linux-2.5/kernel/sysctl.c Sun Dec 30 20:01:41 2001 @@ -19,6 +19,7 @@ */ #include <linux/config.h> +#include <linux/mm.h> #include <linux/slab.h> #include <linux/sysctl.h> #include <linux/swapctl.h> diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/kernel/time.c linux-2.5/kernel/time.c --- linux-2.5.1/kernel/time.c Mon Oct 16 19:58:51 2000 +++ linux-2.5/kernel/time.c Thu Dec 13 16:32:37 2001 @@ -70,11 +70,11 @@ */ asmlinkage long sys_time(int * tloc) { - int i; + struct timeval now; + int i; - /* SMP: This is fairly trivial. We grab CURRENT_TIME and - stuff it to user space. No side effects */ - i = CURRENT_TIME; + do_gettimeofday(&now); + i = now.tv_sec; if (tloc) { if (put_user(i,tloc)) i = -EFAULT; diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/kernel/timer.c linux-2.5/kernel/timer.c --- linux-2.5.1/kernel/timer.c Mon Oct 8 17:41:41 2001 +++ linux-2.5/kernel/timer.c Thu Dec 27 22:10:28 2001 @@ -583,10 +583,7 @@ update_one_process(p, user_tick, system, cpu); if (p->pid) { - if (--p->counter <= 0) { - p->counter = 0; - p->need_resched = 1; - } + expire_task(p); if (p->nice > 0) kstat.per_cpu_nice[cpu] += user_tick; else diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/mm/Makefile linux-2.5/mm/Makefile --- linux-2.5.1/mm/Makefile Tue Dec 11 17:49:40 2001 +++ linux-2.5/mm/Makefile Thu Dec 20 19:14:29 2001 @@ -14,8 +14,6 @@ obj-y := memory.o mmap.o filemap.o mprotect.o mlock.o mremap.o \ vmalloc.o slab.o bootmem.o swap.o vmscan.o page_io.o \ page_alloc.o swap_state.o swapfile.o numa.o oom_kill.o \ - shmem.o mempool.o - -obj-$(CONFIG_HIGHMEM) += highmem.o + shmem.o highmem.o mempool.o include $(TOPDIR)/Rules.make diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/mm/bootmem.c linux-2.5/mm/bootmem.c --- linux-2.5.1/mm/bootmem.c Tue Nov 27 17:23:27 2001 +++ linux-2.5/mm/bootmem.c Thu Dec 13 16:32:37 2001 @@ -155,6 +155,12 @@ if (align & (align-1)) BUG(); + offset = 0; + if (align && + (bdata->node_boot_start & (align - 1UL)) != 0) + offset = (align - (bdata->node_boot_start & (align - 1UL))); + offset >>= PAGE_SHIFT; + /* * We try to allocate bootmem pages above 'goal' * first, then we try to allocate lower pages. @@ -166,6 +172,7 @@ preferred = 0; preferred = ((preferred + align - 1) & ~(align - 1)) >> PAGE_SHIFT; + preferred += offset; areasize = (size+PAGE_SIZE-1)/PAGE_SIZE; incr = align >> PAGE_SHIFT ? : 1; @@ -185,7 +192,7 @@ fail_block:; } if (preferred) { - preferred = 0; + preferred = offset; goto restart_scan; } return NULL; diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/mm/filemap.c linux-2.5/mm/filemap.c --- linux-2.5.1/mm/filemap.c Sun Dec 16 23:21:24 2001 +++ linux-2.5/mm/filemap.c Mon Dec 31 22:47:16 2001 @@ -24,6 +24,7 @@ #include <linux/mm.h> #include <linux/iobuf.h> #include <linux/compiler.h> +#include <linux/prefetch.h> #include <asm/pgalloc.h> #include <asm/uaccess.h> @@ -1570,6 +1571,9 @@ size = count; kaddr = kmap(page); +#if defined(CONFIG_MPENTIUMIII) || defined (CONFIG_MK7) + preload_cache (kaddr+offset, size); +#endif left = __copy_to_user(desc->buf, kaddr + offset, size); kunmap(page); diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/mm/highmem.c linux-2.5/mm/highmem.c --- linux-2.5.1/mm/highmem.c Sun Dec 16 20:20:21 2001 +++ linux-2.5/mm/highmem.c Thu Dec 27 22:10:28 2001 @@ -19,6 +19,21 @@ #include <linux/mm.h> #include <linux/pagemap.h> #include <linux/mempool.h> +#include <linux/blkdev.h> + +static mempool_t *page_pool, *isa_page_pool; + +static void *page_pool_alloc(int gfp_mask, void *data) +{ + int gfp = gfp_mask | (int) data; + + return alloc_page(gfp); +} + +static void page_pool_free(void *page, void *data) +{ + __free_page(page); +} /* * Virtual_count is not a pure "count". @@ -28,9 +43,10 @@ * since the last TLB flush - so we can't use it. * n means that there are (n-1) current users of it. */ +#ifdef CONFIG_HIGHMEM static int pkmap_count[LAST_PKMAP]; static unsigned int last_pkmap_nr; -static spinlock_t kmap_lock = SPIN_LOCK_UNLOCKED; +static spinlock_t kmap_lock __cacheline_aligned_in_smp = SPIN_LOCK_UNLOCKED; pte_t * pkmap_page_table; @@ -185,19 +201,6 @@ } #define POOL_SIZE 64 -#define ISA_POOL_SIZE 16 - -static mempool_t *page_pool, *isa_page_pool; - -static void *page_pool_alloc(int gfp_mask, void *data) -{ - return alloc_page(gfp_mask); -} - -static void page_pool_free(void *page, void *data) -{ - __free_page(page); -} static __init int init_emergency_pool(void) { @@ -211,11 +214,37 @@ page_pool = mempool_create(POOL_SIZE, page_pool_alloc, page_pool_free, NULL); if (!page_pool) BUG(); - printk("highmem bounce pool size: %d pages and bhs.\n", POOL_SIZE); + printk("highmem bounce pool size: %d pages\n", POOL_SIZE); return 0; } +__initcall(init_emergency_pool); + +/* + * highmem version, map in to vec + */ +static inline void bounce_copy_vec(struct bio_vec *to, unsigned char *vfrom) +{ + unsigned long flags; + unsigned char *vto; + + local_irq_save(flags); + vto = kmap_atomic(to->bv_page, KM_BOUNCE_READ); + memcpy(vto + to->bv_offset, vfrom, to->bv_len); + kunmap_atomic(vto, KM_BOUNCE_READ); + local_irq_restore(flags); +} + +#else /* CONFIG_HIGHMEM */ + +#define bounce_copy_vec(to, vfrom) \ + memcpy(page_address((to)->bv_page) + (to)->bv_offset, vfrom, (to)->bv_len) + +#endif + +#define ISA_POOL_SIZE 16 + /* * gets called "every" time someone init's a queue with BLK_BOUNCE_ISA * as the max address, so check if the pool has already been created. @@ -225,7 +254,7 @@ if (isa_page_pool) return 0; - isa_page_pool = mempool_create(ISA_POOL_SIZE, page_pool_alloc, page_pool_free, NULL); + isa_page_pool = mempool_create(ISA_POOL_SIZE, page_pool_alloc, page_pool_free, (void *) __GFP_DMA); if (!isa_page_pool) BUG(); @@ -233,8 +262,6 @@ return 0; } -__initcall(init_emergency_pool); - /* * Simple bounce buffer support for highmem pages. Depending on the * queue gfp mask set, *to may or may not be a highmem page. kmap it @@ -242,13 +269,12 @@ */ static inline void copy_to_high_bio_irq(struct bio *to, struct bio *from) { - unsigned char *vto, *vfrom; - unsigned long flags; + unsigned char *vfrom; struct bio_vec *tovec, *fromvec; int i; __bio_for_each_segment(tovec, to, i, 0) { - fromvec = &from->bi_io_vec[i]; + fromvec = from->bi_io_vec + i; /* * not bounced @@ -258,11 +284,7 @@ vfrom = page_address(fromvec->bv_page) + fromvec->bv_offset; - local_irq_save(flags); - vto = kmap_atomic(tovec->bv_page, KM_BOUNCE_READ); - memcpy(vto + tovec->bv_offset, vfrom, tovec->bv_len); - kunmap_atomic(vto, KM_BOUNCE_READ); - local_irq_restore(flags); + bounce_copy_vec(tovec, vfrom); } } @@ -281,7 +303,7 @@ * free up bounce indirect pages used */ __bio_for_each_segment(bvec, bio, i, 0) { - org_vec = &bio_orig->bi_io_vec[i]; + org_vec = bio_orig->bi_io_vec + i; if (bvec->bv_page == org_vec->bv_page) continue; @@ -336,10 +358,25 @@ BUG_ON((*bio_orig)->bi_idx); + /* + * for non-isa bounce case, just check if the bounce pfn is equal + * to or bigger than the highest pfn in the system -- in that case, + * don't waste time iterating over bio segments + */ if (!(gfp & GFP_DMA)) { + if (pfn >= blk_max_pfn) + return; + +#ifndef CONFIG_HIGHMEM + /* + * should not hit for non-highmem case + */ + BUG(); +#endif bio_gfp = GFP_NOHIGHIO; pool = page_pool; } else { + BUG_ON(!isa_page_pool); bio_gfp = GFP_NOIO; pool = isa_page_pool; } @@ -359,7 +396,7 @@ if (!bio) bio = bio_alloc(bio_gfp, (*bio_orig)->bi_vcnt); - to = &bio->bi_io_vec[i]; + to = bio->bi_io_vec + i; to->bv_page = mempool_alloc(pool, gfp); to->bv_len = from->bv_len; diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/mm/memory.c linux-2.5/mm/memory.c --- linux-2.5.1/mm/memory.c Wed Dec 12 17:14:21 2001 +++ linux-2.5/mm/memory.c Thu Dec 13 22:09:30 2001 @@ -397,17 +397,16 @@ spin_unlock(&mm->page_table_lock); } - /* * Do a quick page-table lookup for a single page. */ -static struct page * follow_page(unsigned long address, int write) +static struct page * follow_page(struct mm_struct *mm, unsigned long address, int write) { pgd_t *pgd; pmd_t *pmd; pte_t *ptep, pte; - pgd = pgd_offset(current->mm, address); + pgd = pgd_offset(mm, address); if (pgd_none(*pgd) || pgd_bad(*pgd)) goto out; @@ -443,21 +442,74 @@ return page; } +int get_user_pages(struct task_struct *tsk, struct mm_struct *mm, unsigned long start, + int len, int write, int force, struct page **pages, struct vm_area_struct **vmas) +{ + int i = 0; + + do { + struct vm_area_struct * vma; + + vma = find_extend_vma(mm, start); + + if ( !vma || + (!force && + ((write && (!(vma->vm_flags & VM_WRITE))) || + (!write && (!(vma->vm_flags & VM_READ))) ) )) { + if (i) return i; + return -EFAULT; + } + + spin_lock(&mm->page_table_lock); + do { + struct page *map; + while (!(map = follow_page(mm, start, write))) { + spin_unlock(&mm->page_table_lock); + switch (handle_mm_fault(mm, vma, start, write)) { + case 1: + tsk->min_flt++; + break; + case 2: + tsk->maj_flt++; + break; + case 0: + if (i) return i; + return -EFAULT; + default: + if (i) return i; + return -ENOMEM; + } + spin_lock(&mm->page_table_lock); + } + if (pages) { + pages[i] = get_page_map(map); + /* FIXME: call the correct function, + * depending on the type of the found page + */ + if (pages[i]) + page_cache_get(pages[i]); + } + if (vmas) + vmas[i] = vma; + i++; + start += PAGE_SIZE; + len--; + } while(len && start < vma->vm_end); + spin_unlock(&mm->page_table_lock); + } while(len); + return i; +} + /* * Force in an entire range of pages from the current process's user VA, * and pin them in physical memory. */ - #define dprintk(x...) + int map_user_kiobuf(int rw, struct kiobuf *iobuf, unsigned long va, size_t len) { - unsigned long ptr, end; - int err; + int pgcount, err; struct mm_struct * mm; - struct vm_area_struct * vma = 0; - struct page * map; - int i; - int datain = (rw == READ); /* Make sure the iobuf is not already mapped somewhere. */ if (iobuf->nr_pages) @@ -466,79 +518,37 @@ mm = current->mm; dprintk ("map_user_kiobuf: begin\n"); - ptr = va & PAGE_MASK; - end = (va + len + PAGE_SIZE - 1) & PAGE_MASK; - err = expand_kiobuf(iobuf, (end - ptr) >> PAGE_SHIFT); + pgcount = (va + len + PAGE_SIZE - 1)/PAGE_SIZE - va/PAGE_SIZE; + /* mapping 0 bytes is not permitted */ + if (!pgcount) BUG(); + err = expand_kiobuf(iobuf, pgcount); if (err) return err; - down_read(&mm->mmap_sem); - - err = -EFAULT; iobuf->locked = 0; - iobuf->offset = va & ~PAGE_MASK; + iobuf->offset = va & (PAGE_SIZE-1); iobuf->length = len; - i = 0; - - /* - * First of all, try to fault in all of the necessary pages - */ - while (ptr < end) { - if (!vma || ptr >= vma->vm_end) { - vma = find_vma(current->mm, ptr); - if (!vma) - goto out_unlock; - if (vma->vm_start > ptr) { - if (!(vma->vm_flags & VM_GROWSDOWN)) - goto out_unlock; - if (expand_stack(vma, ptr)) - goto out_unlock; - } - if (((datain) && (!(vma->vm_flags & VM_WRITE))) || - (!(vma->vm_flags & VM_READ))) { - err = -EACCES; - goto out_unlock; - } - } - spin_lock(&mm->page_table_lock); - while (!(map = follow_page(ptr, datain))) { - int ret; - - spin_unlock(&mm->page_table_lock); - ret = handle_mm_fault(current->mm, vma, ptr, datain); - if (ret <= 0) { - if (!ret) - goto out_unlock; - else { - err = -ENOMEM; - goto out_unlock; - } - } - spin_lock(&mm->page_table_lock); - } - map = get_page_map(map); - if (map) { - flush_dcache_page(map); - page_cache_get(map); - } else - printk (KERN_INFO "Mapped page missing [%d]\n", i); - spin_unlock(&mm->page_table_lock); - iobuf->maplist[i] = map; - iobuf->nr_pages = ++i; - - ptr += PAGE_SIZE; - } - + /* Try to fault in all of the necessary pages */ + down_read(&mm->mmap_sem); + /* rw==READ means read from disk, write into memory area */ + err = get_user_pages(current, mm, va, pgcount, + (rw==READ), 0, iobuf->maplist, NULL); up_read(&mm->mmap_sem); + if (err < 0) { + unmap_kiobuf(iobuf); + dprintk ("map_user_kiobuf: end %d\n", err); + return err; + } + iobuf->nr_pages = err; + while (pgcount--) { + /* FIXME: flush superflous for rw==READ, + * probably wrong function for rw==WRITE + */ + flush_dcache_page(iobuf->maplist[pgcount]); + } dprintk ("map_user_kiobuf: end OK\n"); return 0; - - out_unlock: - up_read(&mm->mmap_sem); - unmap_kiobuf(iobuf); - dprintk ("map_user_kiobuf: end %d\n", err); - return err; } /* @@ -588,6 +598,9 @@ if (map) { if (iobuf->locked) UnlockPage(map); + /* FIXME: cache flush missing for rw==READ + * FIXME: call the correct reference counting function + */ page_cache_release(map); } } @@ -1022,16 +1035,10 @@ do_expand: limit = current->rlim[RLIMIT_FSIZE].rlim_cur; - if (limit != RLIM_INFINITY) { - if (inode->i_size >= limit) { - send_sig(SIGXFSZ, current, 0); - goto out; - } - if (offset > limit) { - send_sig(SIGXFSZ, current, 0); - offset = limit; - } - } + if (limit != RLIM_INFINITY && offset > limit) + goto out_sig; + if (offset > inode->i_sb->s_maxbytes) + goto out; inode->i_size = offset; out_truncate: @@ -1040,8 +1047,11 @@ inode->i_op->truncate(inode); unlock_kernel(); } -out: return 0; +out_sig: + send_sig(SIGXFSZ, current, 0); +out: + return -EFBIG; } /* @@ -1104,6 +1114,8 @@ ret = 2; } + mark_page_accessed(page); + lock_page(page); /* @@ -1174,6 +1186,7 @@ flush_page_to_ram(page); entry = pte_mkwrite(pte_mkdirty(mk_pte(page, vma->vm_page_prot))); lru_cache_add(page); + mark_page_accessed(page); } set_pte(page_table, entry); @@ -1225,7 +1238,7 @@ page_cache_release(new_page); return -1; } - copy_highpage(page, new_page); + copy_user_highpage(page, new_page, address); page_cache_release(new_page); lru_cache_add(page); new_page = page; @@ -1414,23 +1427,19 @@ return pte_offset(pmd, address); } -/* - * Simplistic page force-in.. - */ int make_pages_present(unsigned long addr, unsigned long end) { - int write; - struct mm_struct *mm = current->mm; + int ret, len, write; struct vm_area_struct * vma; - vma = find_vma(mm, addr); + vma = find_vma(current->mm, addr); write = (vma->vm_flags & VM_WRITE) != 0; if (addr >= end) BUG(); - do { - if (handle_mm_fault(mm, vma, addr, write) < 0) - return -1; - addr += PAGE_SIZE; - } while (addr < end); - return 0; + if (end > vma->vm_end) + BUG(); + len = (end+PAGE_SIZE-1)/PAGE_SIZE-addr/PAGE_SIZE; + ret = get_user_pages(current, current->mm, addr, + len, write, 0, NULL, NULL); + return ret == len ? 0 : -1; } diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/mm/mempool.c linux-2.5/mm/mempool.c --- linux-2.5.1/mm/mempool.c Sun Dec 16 20:25:28 2001 +++ linux-2.5/mm/mempool.c Sun Dec 30 20:01:41 2001 @@ -8,6 +8,7 @@ * started by Ingo Molnar, Copyright (C) 2001 */ +#include <linux/mm.h> #include <linux/slab.h> #include <linux/module.h> #include <linux/mempool.h> diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/mm/mprotect.c linux-2.5/mm/mprotect.c --- linux-2.5.1/mm/mprotect.c Mon Sep 17 22:30:23 2001 +++ linux-2.5/mm/mprotect.c Sun Dec 30 20:01:41 2001 @@ -3,6 +3,7 @@ * * (C) Copyright 1994 Linus Torvalds */ +#include <linux/mm.h> #include <linux/slab.h> #include <linux/smp_lock.h> #include <linux/shm.h> diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/mm/mremap.c linux-2.5/mm/mremap.c --- linux-2.5.1/mm/mremap.c Fri Sep 21 03:31:26 2001 +++ linux-2.5/mm/mremap.c Sun Dec 30 20:01:41 2001 @@ -4,6 +4,7 @@ * (C) Copyright 1996 Linus Torvalds */ +#include <linux/mm.h> #include <linux/slab.h> #include <linux/smp_lock.h> #include <linux/shm.h> diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/mm/oom_kill.c linux-2.5/mm/oom_kill.c --- linux-2.5.1/mm/oom_kill.c Sun Nov 4 01:05:25 2001 +++ linux-2.5/mm/oom_kill.c Thu Dec 27 22:10:28 2001 @@ -149,7 +149,8 @@ * all the memory it needs. That way it should be able to * exit() and clear out its resources quickly... */ - p->counter = 5 * HZ; + p->time_slice = 2 * MAX_TSLICE; + p->dyn_prio = MAX_DYNPRIO + 1; p->flags |= PF_MEMALLOC | PF_MEMDIE; /* This process has hardware access, be more careful. */ diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/mm/shmem.c linux-2.5/mm/shmem.c --- linux-2.5.1/mm/shmem.c Wed Nov 21 17:57:57 2001 +++ linux-2.5/mm/shmem.c Thu Dec 13 16:32:37 2001 @@ -1193,7 +1193,7 @@ follow_link: shmem_follow_link, }; -static int shmem_parse_options(char *options, int *mode, unsigned long * blocks, unsigned long *inodes) +static int shmem_parse_options(char *options, int *mode, uid_t *uid, gid_t *gid, unsigned long * blocks, unsigned long *inodes) { char *this_char, *value, *rest; @@ -1205,7 +1205,7 @@ *value++ = 0; } else { printk(KERN_ERR - "shmem_parse_options: No value for option '%s'\n", + "tmpfs: No value for mount option '%s'\n", this_char); return 1; } @@ -1230,8 +1230,20 @@ *mode = simple_strtoul(value,&rest,8); if (*rest) goto bad_val; + } else if (!strcmp(this_char,"uid")) { + if (!uid) + continue; + *uid = simple_strtoul(value,&rest,0); + if (*rest) + goto bad_val; + } else if (!strcmp(this_char,"gid")) { + if (!gid) + continue; + *gid = simple_strtoul(value,&rest,0); + if (*rest) + goto bad_val; } else { - printk(KERN_ERR "shmem_parse_options: Bad option %s\n", + printk(KERN_ERR "tmpfs: Bad mount option %s\n", this_char); return 1; } @@ -1239,7 +1251,7 @@ return 0; bad_val: - printk(KERN_ERR "shmem_parse_options: Bad value '%s' for option '%s'\n", + printk(KERN_ERR "tmpfs: Bad value '%s' for mount option '%s'\n", value, this_char); return 1; @@ -1251,7 +1263,7 @@ unsigned long max_blocks = sbinfo->max_blocks; unsigned long max_inodes = sbinfo->max_inodes; - if (shmem_parse_options (data, NULL, &max_blocks, &max_inodes)) + if (shmem_parse_options (data, NULL, NULL, NULL, &max_blocks, &max_inodes)) return -EINVAL; return shmem_set_size(sbinfo, max_blocks, max_inodes); } @@ -1268,6 +1280,8 @@ struct dentry * root; unsigned long blocks, inodes; int mode = S_IRWXUGO | S_ISVTX; + uid_t uid = current->fsuid; + gid_t gid = current->fsgid; struct shmem_sb_info *sbinfo = SHMEM_SB(sb); struct sysinfo si; @@ -1279,10 +1293,8 @@ blocks = inodes = si.totalram / 2; #ifdef CONFIG_TMPFS - if (shmem_parse_options (data, &mode, &blocks, &inodes)) { - printk(KERN_ERR "tmpfs invalid option\n"); + if (shmem_parse_options (data, &mode, &uid, &gid, &blocks, &inodes)) return NULL; - } #endif spin_lock_init (&sbinfo->stat_lock); @@ -1299,6 +1311,8 @@ if (!inode) return NULL; + inode->i_uid = uid; + inode->i_gid = gid; root = d_alloc_root(inode); if (!root) { iput(inode); diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/mm/slab.c linux-2.5/mm/slab.c --- linux-2.5.1/mm/slab.c Tue Nov 27 17:31:22 2001 +++ linux-2.5/mm/slab.c Sun Dec 30 20:01:41 2001 @@ -70,6 +70,8 @@ #include <linux/config.h> #include <linux/slab.h> +#include <linux/mm.h> +#include <linux/cache.h> #include <linux/interrupt.h> #include <linux/init.h> #include <linux/compiler.h> @@ -1282,10 +1284,9 @@ }) #ifdef CONFIG_SMP -void* kmem_cache_alloc_batch(kmem_cache_t* cachep, int flags) +void* kmem_cache_alloc_batch(kmem_cache_t* cachep, cpucache_t* cc, int flags) { int batchcount = cachep->batchcount; - cpucache_t* cc = cc_data(cachep); spin_lock(&cachep->spinlock); while (batchcount--) { @@ -1334,7 +1335,7 @@ objp = cc_entry(cc)[--cc->avail]; } else { STATS_INC_ALLOCMISS(cachep); - objp = kmem_cache_alloc_batch(cachep,flags); + objp = kmem_cache_alloc_batch(cachep,cc,flags); if (!objp) goto alloc_new_slab_nolock; } @@ -1922,12 +1923,13 @@ #endif #ifdef CONFIG_SMP { + cpucache_t *cc = cc_data(cachep); unsigned int batchcount = cachep->batchcount; unsigned int limit; - if (cc_data(cachep)) - limit = cc_data(cachep)->limit; - else + if (cc) + limit = cc->limit; + else limit = 0; len += sprintf(page+len, " : %4u %4u", limit, batchcount); diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/mm/swapfile.c linux-2.5/mm/swapfile.c --- linux-2.5.1/mm/swapfile.c Fri Nov 30 21:33:44 2001 +++ linux-2.5/mm/swapfile.c Sun Dec 30 20:01:41 2001 @@ -5,6 +5,7 @@ * Swap reorganised 29.12.95, Stephen Tweedie */ +#include <linux/mm.h> #include <linux/slab.h> #include <linux/smp_lock.h> #include <linux/kernel_stat.h> @@ -913,16 +914,19 @@ if (S_ISBLK(swap_inode->i_mode)) { kdev_t dev = swap_inode->i_rdev; struct block_device_operations *bdops; + devfs_handle_t de; p->swap_device = dev; set_blocksize(dev, PAGE_SIZE); bd_acquire(swap_inode); bdev = swap_inode->i_bdev; - bdops = devfs_get_ops(devfs_get_handle_from_inode(swap_inode)); + de = devfs_get_handle_from_inode(swap_inode); + bdops = devfs_get_ops(de); /* Increments module use count */ if (bdops) bdev->bd_op = bdops; error = blkdev_get(bdev, FMODE_READ|FMODE_WRITE, 0, BDEV_SWAP); + devfs_put_ops(de);/*Decrement module use count now we're safe*/ if (error) goto bad_swap_2; set_blocksize(dev, PAGE_SIZE); diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/mm/vmalloc.c linux-2.5/mm/vmalloc.c --- linux-2.5.1/mm/vmalloc.c Mon Sep 17 20:16:31 2001 +++ linux-2.5/mm/vmalloc.c Thu Dec 13 16:32:37 2001 @@ -6,6 +6,7 @@ * SMP-safe vmalloc/vfree/ioremap, Tigran Aivazian <tigran@veritas.com>, May 2000 */ +#include <linux/config.h> #include <linux/slab.h> #include <linux/vmalloc.h> #include <linux/spinlock.h> @@ -273,6 +274,43 @@ if (count == 0) goto finished; *buf = *addr; + buf++; + addr++; + count--; + } while (--n > 0); + } +finished: + read_unlock(&vmlist_lock); + return buf - buf_start; +} + +long vwrite(char *buf, char *addr, unsigned long count) +{ + struct vm_struct *tmp; + char *vaddr, *buf_start = buf; + unsigned long n; + + /* Don't allow overflow */ + if ((unsigned long) addr + count < count) + count = -(unsigned long) addr; + + read_lock(&vmlist_lock); + for (tmp = vmlist; tmp; tmp = tmp->next) { + vaddr = (char *) tmp->addr; + if (addr >= vaddr + tmp->size - PAGE_SIZE) + continue; + while (addr < vaddr) { + if (count == 0) + goto finished; + buf++; + addr++; + count--; + } + n = vaddr + tmp->size - PAGE_SIZE - addr; + do { + if (count == 0) + goto finished; + *addr = *buf; buf++; addr++; count--; diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/mm/vmscan.c linux-2.5/mm/vmscan.c --- linux-2.5.1/mm/vmscan.c Sun Nov 18 03:18:17 2001 +++ linux-2.5/mm/vmscan.c Sun Dec 30 20:01:41 2001 @@ -11,6 +11,7 @@ * Multiqueue VM started 5.8.00, Rik van Riel. */ +#include <linux/mm.h> #include <linux/slab.h> #include <linux/kernel_stat.h> #include <linux/swap.h> @@ -338,7 +339,7 @@ { struct list_head * entry; int max_scan = nr_inactive_pages / priority; - int max_mapped = nr_pages << (9 - priority); + int max_mapped = min((nr_pages << (10 - priority)), max_scan / 10); spin_lock(&pagemap_lru_lock); while (--max_scan >= 0 && (entry = inactive_list.prev) != &inactive_list) { @@ -588,6 +589,7 @@ int priority = DEF_PRIORITY; int nr_pages = SWAP_CLUSTER_MAX; + gfp_mask = pf_gfp_mask(gfp_mask); do { nr_pages = shrink_caches(classzone, priority, gfp_mask, nr_pages); if (nr_pages <= 0) diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/net/802/fddi.c linux-2.5/net/802/fddi.c --- linux-2.5.1/net/802/fddi.c Wed Nov 29 05:53:45 2000 +++ linux-2.5/net/802/fddi.c Sun Dec 30 21:17:30 2001 @@ -27,7 +27,6 @@ */ #include <linux/config.h> -#include <asm/segment.h> #include <asm/system.h> #include <linux/types.h> #include <linux/kernel.h> diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/net/802/hippi.c linux-2.5/net/802/hippi.c --- linux-2.5.1/net/802/hippi.c Thu Jun 21 04:00:55 2001 +++ linux-2.5/net/802/hippi.c Sun Dec 30 21:17:30 2001 @@ -36,7 +36,6 @@ #include <net/sock.h> #include <asm/uaccess.h> #include <asm/checksum.h> -#include <asm/segment.h> #include <asm/system.h> /* diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/net/8021q/vlan.c linux-2.5/net/8021q/vlan.c --- linux-2.5.1/net/8021q/vlan.c Tue Oct 30 23:08:12 2001 +++ linux-2.5/net/8021q/vlan.c Thu Dec 13 16:32:37 2001 @@ -1,11 +1,10 @@ /* - * INET An implementation of the TCP/IP protocol suite for the LINUX - * operating system. INET is implemented using the BSD Socket - * interface as the means of communication with the user level. - * + * INET 802.1Q VLAN * Ethernet-type device handling. * - * Authors: Ben Greear <greearb@candelatech.com>, <greearb@agcs.com> + * Authors: Ben Greear <greearb@candelatech.com> + * Please send support related email to: vlan@scry.wanfear.com + * VLAN Home Page: http://www.candelatech.com/~greear/vlan.html * * Fixes: * Fix for packet capture - Nick Eggleston <nick@dccinc.com>; @@ -42,7 +41,7 @@ static char vlan_fullname[] = "802.1Q VLAN Support"; static unsigned int vlan_version = 1; -static unsigned int vlan_release = 5; +static unsigned int vlan_release = 6; static char vlan_copyright[] = " Ben Greear <greearb@candelatech.com>"; static int vlan_device_event(struct notifier_block *, unsigned long, void *); @@ -106,6 +105,23 @@ } /* + * Cleanup of groups before exit + */ + +static void vlan_group_cleanup(void) +{ + struct vlan_group *grp = NULL; + struct vlan_group *nextgroup; + + for (grp = p802_1Q_vlan_list; (grp != NULL);) { + nextgroup = grp->next; + kfree(grp); + grp = nextgroup; + } + p802_1Q_vlan_list = NULL; +} + +/* * Module 'remove' entry point. * o delete /proc/net/router directory and static entries. */ @@ -116,7 +132,7 @@ dev_remove_pack(&vlan_packet_type); vlan_proc_cleanup(); - + vlan_group_cleanup(); vlan_ioctl_hook = NULL; } @@ -328,6 +344,7 @@ /* set up method calls */ new_dev->init = vlan_dev_init; new_dev->destructor = vlan_dev_destruct; + new_dev->features |= NETIF_F_DYNALLOC ; /* new_dev->ifindex = 0; it will be set when added to * the global list. diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/net/8021q/vlan_dev.c linux-2.5/net/8021q/vlan_dev.c --- linux-2.5.1/net/8021q/vlan_dev.c Tue Oct 30 23:08:12 2001 +++ linux-2.5/net/8021q/vlan_dev.c Thu Dec 13 16:32:37 2001 @@ -1,11 +1,10 @@ /* - * INET An implementation of the TCP/IP protocol suite for the LINUX - * operating system. INET is implemented using the BSD Socket - * interface as the means of communication with the user level. - * + * INET 802.1Q VLAN * Ethernet-type device handling. * - * Authors: Ben Greear <greearb@candelatech.com>, <greearb@agcs.com> + * Authors: Ben Greear <greearb@candelatech.com> + * Please send support related email to: vlan@scry.wanfear.com + * VLAN Home Page: http://www.candelatech.com/~greear/vlan.html * * Fixes: Mar 22 2001: Martin Bokaemper <mbokaemper@unispherenetworks.com> * - reset skb->pkt_type on incoming packets when MAC was changed @@ -512,10 +511,6 @@ VLAN_FMEM_DBG("dev->priv free, addr: %p\n", dev->priv); dev->priv = NULL; } - - kfree(dev); - VLAN_FMEM_DBG("net_device free, addr: %p\n", dev); - dev = NULL; } } diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/net/8021q/vlanproc.c linux-2.5/net/8021q/vlanproc.c --- linux-2.5.1/net/8021q/vlanproc.c Tue Nov 13 17:19:41 2001 +++ linux-2.5/net/8021q/vlanproc.c Sun Dec 30 21:17:30 2001 @@ -25,7 +25,6 @@ #include <linux/mm.h> /* verify_area(), etc. */ #include <linux/string.h> /* inline mem*, str* functions */ #include <linux/init.h> /* __initfunc et al. */ -#include <asm/segment.h> /* kernel <-> user copy */ #include <asm/byteorder.h> /* htons(), etc. */ #include <asm/uaccess.h> /* copy_to_user */ #include <asm/io.h> @@ -116,7 +115,7 @@ * Clean up /proc/net/vlan entries */ -void __exit vlan_proc_cleanup(void) +void vlan_proc_cleanup(void) { if (proc_vlan_conf) remove_proc_entry(name_conf, proc_vlan_dir); @@ -462,7 +461,7 @@ return 0; } -void __exit vlan_proc_cleanup(void) +void vlan_proc_cleanup(void) { return; } diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/net/Config.in linux-2.5/net/Config.in --- linux-2.5.1/net/Config.in Tue Oct 30 23:08:12 2001 +++ linux-2.5/net/Config.in Mon Dec 31 18:21:26 2001 @@ -7,11 +7,9 @@ if [ "$CONFIG_PACKET" != "n" ]; then bool ' Packet socket: mmapped IO' CONFIG_PACKET_MMAP fi -bool 'Kernel/User netlink socket' CONFIG_NETLINK -if [ "$CONFIG_NETLINK" = "y" ]; then - bool ' Routing messages' CONFIG_RTNETLINK - tristate ' Netlink device emulation' CONFIG_NETLINK_DEV -fi + +tristate 'Netlink device emulation' CONFIG_NETLINK_DEV + bool 'Network packet filtering (replaces ipchains)' CONFIG_NETFILTER if [ "$CONFIG_NETFILTER" = "y" ]; then bool ' Network packet filtering debugging' CONFIG_NETFILTER_DEBUG @@ -61,7 +59,7 @@ if [ "$CONFIG_DECNET" != "n" ]; then source net/decnet/Config.in fi -tristate '802.1d Ethernet Bridging' CONFIG_BRIDGE +dep_tristate '802.1d Ethernet Bridging' CONFIG_BRIDGE $CONFIG_INET if [ "$CONFIG_EXPERIMENTAL" = "y" ]; then tristate 'CCITT X.25 Packet Layer (EXPERIMENTAL)' CONFIG_X25 tristate 'LAPB Data Link Driver (EXPERIMENTAL)' CONFIG_LAPB diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/net/Makefile linux-2.5/net/Makefile --- linux-2.5.1/net/Makefile Tue Oct 30 23:08:12 2001 +++ linux-2.5/net/Makefile Thu Dec 13 16:32:37 2001 @@ -14,7 +14,7 @@ subdir-m := ipv4 # hum? -subdir-$(CONFIG_NET) += 802 sched +subdir-$(CONFIG_NET) += 802 sched netlink subdir-$(CONFIG_INET) += ipv4 subdir-$(CONFIG_NETFILTER) += ipv4/netfilter subdir-$(CONFIG_UNIX) += unix @@ -27,7 +27,6 @@ endif subdir-$(CONFIG_KHTTPD) += khttpd -subdir-$(CONFIG_NETLINK) += netlink subdir-$(CONFIG_PACKET) += packet subdir-$(CONFIG_NET_SCHED) += sched subdir-$(CONFIG_BRIDGE) += bridge diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/net/README linux-2.5/net/README --- linux-2.5.1/net/README Tue Jun 12 02:15:27 2001 +++ linux-2.5/net/README Thu Dec 13 16:32:37 2001 @@ -23,4 +23,4 @@ unix alan@lxorguk.ukuu.org.uk x25 g4klx@g4klx.demon.co.uk bluetooth maxk@qualcomm.com - +8021q greearb@candelatech.com, vlan@scry.wanfear.com diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/net/atm/resources.c linux-2.5/net/atm/resources.c --- linux-2.5.1/net/atm/resources.c Fri Nov 9 22:11:15 2001 +++ linux-2.5/net/atm/resources.c Sun Dec 30 21:17:30 2001 @@ -11,7 +11,6 @@ #include <linux/module.h> #include <linux/bitops.h> #include <net/sock.h> /* for struct sock */ -#include <asm/segment.h> /* for get_fs_long and put_fs_long */ #include "common.h" #include "resources.h" diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/net/bridge/br.c linux-2.5/net/bridge/br.c --- linux-2.5.1/net/bridge/br.c Wed Oct 17 21:16:39 2001 +++ linux-2.5/net/bridge/br.c Mon Dec 31 18:21:26 2001 @@ -43,9 +43,7 @@ printk(KERN_INFO "NET4: Ethernet Bridge 008 for NET4.0\n"); br_handle_frame_hook = br_handle_frame; -#ifdef CONFIG_INET br_ioctl_hook = br_ioctl_deviceless_stub; -#endif #if defined(CONFIG_ATM_LANE) || defined(CONFIG_ATM_LANE_MODULE) br_fdb_get_hook = br_fdb_get; br_fdb_put_hook = br_fdb_put; @@ -62,9 +60,7 @@ static void __br_clear_ioctl_hook(void) { -#ifdef CONFIG_INET br_ioctl_hook = NULL; -#endif } static void __exit br_deinit(void) diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/net/bridge/br_device.c linux-2.5/net/bridge/br_device.c --- linux-2.5.1/net/bridge/br_device.c Wed Aug 15 08:54:30 2001 +++ linux-2.5/net/bridge/br_device.c Mon Dec 31 18:21:26 2001 @@ -71,7 +71,7 @@ return 0; } -static int br_dev_xmit(struct sk_buff *skb, struct net_device *dev) +int br_dev_xmit(struct sk_buff *skb, struct net_device *dev) { struct net_bridge *br; int ret; diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/net/bridge/br_if.c linux-2.5/net/bridge/br_if.c --- linux-2.5.1/net/bridge/br_if.c Thu Nov 9 23:57:53 2000 +++ linux-2.5/net/bridge/br_if.c Mon Dec 31 18:21:26 2001 @@ -5,7 +5,7 @@ * Authors: * Lennert Buytenhek <buytenh@gnu.org> * - * $Id: br_if.c,v 1.5 2000/11/08 05:16:40 davem Exp $ + * $Id: br_if.c,v 1.6 2001/11/24 17:51:03 davem Exp $ * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -226,6 +226,9 @@ if (dev->flags & IFF_LOOPBACK || dev->type != ARPHRD_ETHER) return -EINVAL; + if (dev->hard_start_xmit == br_dev_xmit) + return -ELOOP; + dev_hold(dev); write_lock_bh(&br->lock); if ((p = new_nbp(br, dev)) == NULL) { @@ -261,8 +264,6 @@ { struct net_bridge *br; int i; - - i = 0; br = bridge_list; for (i=0;i<num;i++) { diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/net/bridge/br_input.c linux-2.5/net/bridge/br_input.c --- linux-2.5.1/net/bridge/br_input.c Wed Aug 15 08:54:39 2001 +++ linux-2.5/net/bridge/br_input.c Mon Dec 31 18:21:26 2001 @@ -46,7 +46,7 @@ br_pass_frame_up_finish); } -static void __br_handle_frame(struct sk_buff *skb) +static int br_handle_frame_finish(struct sk_buff *skb) { struct net_bridge *br; unsigned char *dest; @@ -57,103 +57,112 @@ dest = skb->mac.ethernet->h_dest; p = skb->dev->br_port; - br = p->br; - passedup = 0; + if (p == NULL) + goto err_nolock; - if (!(br->dev.flags & IFF_UP) || - p->state == BR_STATE_DISABLED) - goto freeandout; + br = p->br; + read_lock(&br->lock); + if (skb->dev->br_port == NULL) + goto err; + passedup = 0; if (br->dev.flags & IFF_PROMISC) { struct sk_buff *skb2; skb2 = skb_clone(skb, GFP_ATOMIC); - if (skb2) { + if (skb2 != NULL) { passedup = 1; br_pass_frame_up(br, skb2); } } - if (skb->mac.ethernet->h_source[0] & 1) - goto freeandout; - - if (!passedup && - (dest[0] & 1) && - (br->dev.flags & IFF_ALLMULTI || br->dev.mc_list != NULL)) { - struct sk_buff *skb2; - - skb2 = skb_clone(skb, GFP_ATOMIC); - if (skb2) { - passedup = 1; - br_pass_frame_up(br, skb2); - } - } - - if (br->stp_enabled && - !memcmp(dest, bridge_ula, 5) && - !(dest[5] & 0xF0)) - goto handle_special_frame; - - if (p->state == BR_STATE_LEARNING || - p->state == BR_STATE_FORWARDING) - br_fdb_insert(br, p, skb->mac.ethernet->h_source, 0); - - if (p->state != BR_STATE_FORWARDING) - goto freeandout; - if (dest[0] & 1) { - br_flood_forward(br, skb, 1); + br_flood_forward(br, skb, !passedup); if (!passedup) br_pass_frame_up(br, skb); - else - kfree_skb(skb); - return; + goto out; } dst = br_fdb_get(br, dest); - if (dst != NULL && dst->is_local) { if (!passedup) br_pass_frame_up(br, skb); else kfree_skb(skb); br_fdb_put(dst); - return; + goto out; } if (dst != NULL) { br_forward(dst->dst, skb); br_fdb_put(dst); - return; + goto out; } br_flood_forward(br, skb, 0); - return; - handle_special_frame: - if (!dest[5]) { - br_stp_handle_bpdu(skb); - return; - } +out: + read_unlock(&br->lock); + return 0; - freeandout: +err: + read_unlock(&br->lock); +err_nolock: kfree_skb(skb); + return 0; } -static int br_handle_frame_finish(struct sk_buff *skb) +void br_handle_frame(struct sk_buff *skb) { struct net_bridge *br; + unsigned char *dest; + struct net_bridge_port *p; - br = skb->dev->br_port->br; + dest = skb->mac.ethernet->h_dest; + + p = skb->dev->br_port; + if (p == NULL) + goto err_nolock; + + br = p->br; read_lock(&br->lock); - __br_handle_frame(skb); - read_unlock(&br->lock); + if (skb->dev->br_port == NULL) + goto err; - return 0; -} + if (!(br->dev.flags & IFF_UP) || + p->state == BR_STATE_DISABLED) + goto err; -void br_handle_frame(struct sk_buff *skb) -{ - NF_HOOK(PF_BRIDGE, NF_BR_PRE_ROUTING, skb, skb->dev, NULL, + if (skb->mac.ethernet->h_source[0] & 1) + goto err; + + if (p->state == BR_STATE_LEARNING || + p->state == BR_STATE_FORWARDING) + br_fdb_insert(br, p, skb->mac.ethernet->h_source, 0); + + if (br->stp_enabled && + !memcmp(dest, bridge_ula, 5) && + !(dest[5] & 0xF0)) + goto handle_special_frame; + + if (p->state == BR_STATE_FORWARDING) { + NF_HOOK(PF_BRIDGE, NF_BR_PRE_ROUTING, skb, skb->dev, NULL, br_handle_frame_finish); + read_unlock(&br->lock); + return; + } + +err: + read_unlock(&br->lock); +err_nolock: + kfree_skb(skb); + return; + +handle_special_frame: + if (!dest[5]) { + br_stp_handle_bpdu(skb); + return; + } + + kfree_skb(skb); } diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/net/bridge/br_private.h linux-2.5/net/bridge/br_private.h --- linux-2.5.1/net/bridge/br_private.h Tue Jun 12 02:15:27 2001 +++ linux-2.5/net/bridge/br_private.h Mon Dec 31 18:21:26 2001 @@ -120,6 +120,7 @@ extern void br_inc_use_count(void); /* br_device.c */ +extern int br_dev_xmit(struct sk_buff *skb, struct net_device *dev); extern void br_dev_setup(struct net_device *dev); /* br_fdb.c */ diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/net/core/datagram.c linux-2.5/net/core/datagram.c --- linux-2.5.1/net/core/datagram.c Thu Apr 12 19:11:39 2001 +++ linux-2.5/net/core/datagram.c Thu Dec 13 16:32:37 2001 @@ -30,21 +30,18 @@ #include <asm/system.h> #include <linux/mm.h> #include <linux/interrupt.h> -#include <linux/in.h> #include <linux/errno.h> #include <linux/sched.h> #include <linux/inet.h> #include <linux/netdevice.h> +#include <linux/rtnetlink.h> #include <linux/poll.h> #include <linux/highmem.h> -#include <net/ip.h> #include <net/protocol.h> -#include <net/route.h> -#include <net/tcp.h> -#include <net/udp.h> #include <linux/skbuff.h> #include <net/sock.h> +#include <net/checksum.h> /* diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/net/core/neighbour.c linux-2.5/net/core/neighbour.c --- linux-2.5.1/net/core/neighbour.c Mon Oct 1 16:19:56 2001 +++ linux-2.5/net/core/neighbour.c Thu Dec 13 16:32:37 2001 @@ -1172,9 +1172,6 @@ return 0; } -#ifdef CONFIG_RTNETLINK - - int neigh_delete(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg) { struct ndmsg *ndm = NLMSG_DATA(nlh); @@ -1438,12 +1435,7 @@ netlink_broadcast(rtnl, skb, 0, RTMGRP_NEIGH, GFP_ATOMIC); } - - -#endif - - -#endif +#endif /* CONFIG_ARPD */ #ifdef CONFIG_SYSCTL diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/net/core/rtnetlink.c linux-2.5/net/core/rtnetlink.c --- linux-2.5.1/net/core/rtnetlink.c Sun Aug 5 20:12:41 2001 +++ linux-2.5/net/core/rtnetlink.c Thu Dec 13 16:32:37 2001 @@ -77,15 +77,10 @@ return 0; } -#ifdef CONFIG_RTNETLINK struct sock *rtnl; struct rtnetlink_link * rtnetlink_links[NPROTO]; -#define _S 1 /* superuser privileges required */ -#define _X 2 /* exclusive access to tables required */ -#define _G 4 /* GET request */ - static const int rtm_min[(RTM_MAX+1-RTM_BASE)/4] = { NLMSG_LENGTH(sizeof(struct ifinfomsg)), @@ -533,7 +528,3 @@ rtnetlink_links[PF_UNSPEC] = link_rtnetlink_table; rtnetlink_links[PF_PACKET] = link_rtnetlink_table; } - - - -#endif diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/net/core/scm.c linux-2.5/net/core/scm.c --- linux-2.5.1/net/core/scm.c Thu Nov 9 23:57:53 2000 +++ linux-2.5/net/core/scm.c Thu Dec 13 16:32:37 2001 @@ -26,11 +26,7 @@ #include <asm/system.h> #include <asm/uaccess.h> -#include <linux/inet.h> -#include <net/ip.h> #include <net/protocol.h> -#include <net/tcp.h> -#include <net/udp.h> #include <linux/skbuff.h> #include <net/sock.h> #include <net/scm.h> diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/net/core/skbuff.c linux-2.5/net/core/skbuff.c --- linux-2.5.1/net/core/skbuff.c Tue Aug 7 15:30:50 2001 +++ linux-2.5/net/core/skbuff.c Thu Dec 13 16:32:37 2001 @@ -4,7 +4,7 @@ * Authors: Alan Cox <iiitac@pyr.swan.ac.uk> * Florian La Roche <rzsfl@rz.uni-sb.de> * - * Version: $Id: skbuff.c,v 1.89 2001/08/06 13:25:02 davem Exp $ + * Version: $Id: skbuff.c,v 1.90 2001/11/07 05:56:19 davem Exp $ * * Fixes: * Alan Cox : Fixed the worst of the load balancer bugs. @@ -49,15 +49,14 @@ #include <linux/string.h> #include <linux/skbuff.h> #include <linux/cache.h> +#include <linux/rtnetlink.h> #include <linux/init.h> #include <linux/highmem.h> -#include <net/ip.h> #include <net/protocol.h> #include <net/dst.h> -#include <net/tcp.h> -#include <net/udp.h> #include <net/sock.h> +#include <net/checksum.h> #include <asm/uaccess.h> #include <asm/system.h> diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/net/core/sock.c linux-2.5/net/core/sock.c --- linux-2.5.1/net/core/sock.c Sat Jul 28 19:12:38 2001 +++ linux-2.5/net/core/sock.c Thu Dec 13 16:32:37 2001 @@ -7,7 +7,7 @@ * handler for protocols to use and generic option handler. * * - * Version: $Id: sock.c,v 1.112 2001/07/27 09:54:48 davem Exp $ + * Version: $Id: sock.c,v 1.116 2001/11/08 04:20:06 davem Exp $ * * Authors: Ross Biro, <bir7@leland.Stanford.Edu> * Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG> @@ -113,24 +113,20 @@ #include <asm/uaccess.h> #include <asm/system.h> -#include <linux/inet.h> #include <linux/netdevice.h> -#include <net/ip.h> #include <net/protocol.h> -#include <net/arp.h> -#include <net/route.h> -#include <net/tcp.h> -#include <net/udp.h> #include <linux/skbuff.h> #include <net/sock.h> -#include <net/raw.h> -#include <net/icmp.h> #include <linux/ipsec.h> #ifdef CONFIG_FILTER #include <linux/filter.h> #endif +#ifdef CONFIG_INET +#include <net/tcp.h> +#endif + /* Run time adjustable parameters. */ __u32 sysctl_wmem_max = SK_WMEM_MAX; __u32 sysctl_rmem_max = SK_RMEM_MAX; @@ -759,48 +755,62 @@ * Generic send/receive buffer handlers */ -struct sk_buff *sock_alloc_send_skb(struct sock *sk, unsigned long size, - int noblock, int *errcode) +struct sk_buff *sock_alloc_send_pskb(struct sock *sk, unsigned long header_len, + unsigned long data_len, int noblock, int *errcode) { - int err; struct sk_buff *skb; long timeo; + int err; timeo = sock_sndtimeo(sk, noblock); - while (1) { - unsigned long try_size = size; - err = sock_error(sk); if (err != 0) goto failure; - /* - * We should send SIGPIPE in these cases according to - * 1003.1g draft 6.4. If we (the user) did a shutdown() - * call however we should not. - * - * Note: This routine isnt just used for datagrams and - * anyway some datagram protocols have a notion of - * close down. - */ - err = -EPIPE; - if (sk->shutdown&SEND_SHUTDOWN) + if (sk->shutdown & SEND_SHUTDOWN) goto failure; if (atomic_read(&sk->wmem_alloc) < sk->sndbuf) { - skb = alloc_skb(try_size, sk->allocation); - if (skb) + skb = alloc_skb(header_len, sk->allocation); + if (skb) { + int npages; + int i; + + /* No pages, we're done... */ + if (!data_len) + break; + + npages = (data_len + (PAGE_SIZE - 1)) >> PAGE_SHIFT; + skb->truesize += data_len; + skb_shinfo(skb)->nr_frags = npages; + for (i = 0; i < npages; i++) { + struct page *page; + skb_frag_t *frag; + + page = alloc_pages(sk->allocation, 0); + if (!page) { + err = -ENOBUFS; + kfree_skb(skb); + goto failure; + } + + frag = &skb_shinfo(skb)->frags[i]; + frag->page = page; + frag->page_offset = 0; + frag->size = (data_len >= PAGE_SIZE ? + PAGE_SIZE : + data_len); + data_len -= PAGE_SIZE; + } + + /* Full success... */ break; + } err = -ENOBUFS; goto failure; } - - /* - * This means we have too many buffers for this socket already. - */ - set_bit(SOCK_ASYNC_NOSPACE, &sk->socket->flags); set_bit(SOCK_NOSPACE, &sk->socket->flags); err = -EAGAIN; @@ -819,6 +829,12 @@ failure: *errcode = err; return NULL; +} + +struct sk_buff *sock_alloc_send_skb(struct sock *sk, unsigned long size, + int noblock, int *errcode) +{ + return sock_alloc_send_pskb(sk, size, 0, noblock, errcode); } void __lock_sock(struct sock *sk) diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/net/decnet/README linux-2.5/net/decnet/README --- linux-2.5.1/net/decnet/README Wed May 26 16:36:36 1999 +++ linux-2.5/net/decnet/README Thu Dec 13 16:32:37 2001 @@ -3,6 +3,6 @@ The documentation for this kernel subsystem is available in the Documentation/networking subdirctory of this distribution and also -on line at http://www.sucs.swan.ac.uk/~rohan/DECnet/index.html. +on line at http://www.chygwyn.com/DECnet/ Steve Whitehouse <SteveW@ACM.org> diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/net/decnet/af_decnet.c linux-2.5/net/decnet/af_decnet.c --- linux-2.5.1/net/decnet/af_decnet.c Fri Nov 9 22:12:54 2001 +++ linux-2.5/net/decnet/af_decnet.c Sun Dec 30 21:17:30 2001 @@ -36,6 +36,7 @@ * Steve Whitehouse: Removed unused code. Fix to use sk->allocation * when required. * Patrick Caulfield: /proc/net/decnet now has object name/number + * Steve Whitehouse: Fixed local port allocation, hashed sk list */ @@ -112,7 +113,6 @@ #include <linux/route.h> #include <linux/netfilter.h> #include <net/sock.h> -#include <asm/segment.h> #include <asm/system.h> #include <asm/ioctls.h> #include <linux/mm.h> @@ -139,9 +139,13 @@ dn_address decnet_address = 0; unsigned char decnet_ether_address[ETH_ALEN] = { 0xAA, 0x00, 0x04, 0x00, 0x00, 0x00 }; +#define DN_SK_HASH_SHIFT 8 +#define DN_SK_HASH_SIZE (1 << DN_SK_HASH_SHIFT) +#define DN_SK_HASH_MASK (DN_SK_HASH_SIZE - 1) + static struct proto_ops dn_proto_ops; rwlock_t dn_hash_lock = RW_LOCK_UNLOCKED; -static struct sock *dn_sklist; +static struct sock *dn_sk_hash[DN_SK_HASH_SIZE]; static struct sock *dn_wild_sk; static int __dn_setsockopt(struct socket *sock, int level, int optname, char *optval, int optlen, int flags); @@ -154,18 +158,38 @@ if (scp->addr.sdn_flags & SDF_WILD) return dn_wild_sk ? NULL : &dn_wild_sk; - return &dn_sklist; + return &dn_sk_hash[scp->addrloc & DN_SK_HASH_MASK]; +} + +/* + * Valid ports are those greater than zero and not already in use. + */ +static int check_port(unsigned short port) +{ + struct sock *sk = dn_sk_hash[port & DN_SK_HASH_MASK]; + if (port == 0) + return -1; + while(sk) { + struct dn_scp *scp = DN_SK(sk); + if (scp->addrloc == port) + return -1; + sk = sk->next; + } + return 0; } static unsigned short port_alloc(struct sock *sk) { struct dn_scp *scp = DN_SK(sk); static unsigned short port = 0x2000; + unsigned short i_port = port; - if (port == 0) - port++; + while(check_port(++port) != 0) { + if (port == i_port) + return 0; + } - scp->addrloc = port++; + scp->addrloc = port; return 1; } @@ -238,6 +262,48 @@ sk->pprev = NULL; } +struct sock **listen_hash(struct sockaddr_dn *addr) +{ + int i; + unsigned hash = addr->sdn_objnum; + + if (hash == 0) { + hash = addr->sdn_objnamel; + for(i = 0; i < addr->sdn_objnamel; i++) { + hash ^= addr->sdn_objname[i]; + hash ^= (hash << 3); + } + } + + return &dn_sk_hash[hash & DN_SK_HASH_MASK]; +} + +/* + * Called to transform a socket from bound (i.e. with a local address) + * into a listening socket (doesn't need a local port number) and rehashes + * based upon the object name/number. + */ +static void dn_rehash_sock(struct sock *sk) +{ + struct sock **skp = sk->pprev; + struct dn_scp *scp = DN_SK(sk); + + if (scp->addr.sdn_flags & SDF_WILD) + return; + + write_lock_bh(&dn_hash_lock); + while(*skp != sk) + skp = &((*skp)->next); + *skp = sk->next; + + DN_SK(sk)->addrloc = 0; + skp = listen_hash(&DN_SK(sk)->addr); + + sk->next = *skp; + sk->pprev = skp; + *skp = sk; + write_unlock_bh(&dn_hash_lock); +} int dn_sockaddr2username(struct sockaddr_dn *sdn, unsigned char *buf, unsigned char type) { @@ -328,10 +394,11 @@ struct sock *dn_sklist_find_listener(struct sockaddr_dn *addr) { + struct sock **skp = listen_hash(addr); struct sock *sk; read_lock(&dn_hash_lock); - for(sk = dn_sklist; sk != NULL; sk = sk->next) { + for(sk = *skp; sk != NULL; sk = sk->next) { struct dn_scp *scp = DN_SK(sk); if (sk->state != TCP_LISTEN) continue; @@ -365,7 +432,8 @@ struct dn_scp *scp; read_lock(&dn_hash_lock); - for(sk = dn_sklist; sk != NULL; sk = sk->next) { + sk = dn_sk_hash[cb->dst_port & DN_SK_HASH_MASK]; + for (; sk != NULL; sk = sk->next) { scp = DN_SK(sk); if (cb->src != dn_saddr2dn(&scp->peer)) continue; @@ -1045,6 +1113,9 @@ sizeof(struct optdata_dn)); lock_sock(newsk); + /* + * FIXME: This can fail if we've run out of local ports.... + */ dn_hash_sock(newsk); dn_send_conn_ack(newsk); @@ -1200,6 +1271,7 @@ sk->ack_backlog = 0; sk->state = TCP_LISTEN; err = 0; + dn_rehash_sock(sk); out: release_sock(sk); @@ -2063,44 +2135,47 @@ char buf2[DN_ASCBUF_LEN]; char local_object[DN_MAXOBJL+3]; char remote_object[DN_MAXOBJL+3]; + int i; len += sprintf(buffer + len, "Local Remote\n"); read_lock(&dn_hash_lock); - for(sk = dn_sklist; sk != NULL; sk = sk->next) { - scp = DN_SK(sk); - - dn_printable_object(&scp->addr, local_object); - dn_printable_object(&scp->peer, remote_object); - - len += sprintf(buffer + len, - "%6s/%04X %04d:%04d %04d:%04d %01d %-16s %6s/%04X %04d:%04d %04d:%04d %01d %-16s %4s %s\n", - dn_addr2asc(dn_ntohs(dn_saddr2dn(&scp->addr)), buf1), - scp->addrloc, - scp->numdat, - scp->numoth, - scp->ackxmt_dat, - scp->ackxmt_oth, - scp->flowloc_sw, - local_object, - dn_addr2asc(dn_ntohs(dn_saddr2dn(&scp->peer)), buf2), - scp->addrrem, - scp->numdat_rcv, - scp->numoth_rcv, - scp->ackrcv_dat, - scp->ackrcv_oth, - scp->flowrem_sw, - remote_object, - dn_state2asc(scp->state), - ((scp->accept_mode == ACC_IMMED) ? "IMMED" : "DEFER")); - - pos = begin + len; - if (pos < offset) { - len = 0; - begin = pos; + for(i = 0; i < DN_SK_HASH_SIZE; i++) { + for(sk = dn_sk_hash[i]; sk != NULL; sk = sk->next) { + scp = DN_SK(sk); + + dn_printable_object(&scp->addr, local_object); + dn_printable_object(&scp->peer, remote_object); + + len += sprintf(buffer + len, + "%6s/%04X %04d:%04d %04d:%04d %01d %-16s %6s/%04X %04d:%04d %04d:%04d %01d %-16s %4s %s\n", + dn_addr2asc(dn_ntohs(dn_saddr2dn(&scp->addr)), buf1), + scp->addrloc, + scp->numdat, + scp->numoth, + scp->ackxmt_dat, + scp->ackxmt_oth, + scp->flowloc_sw, + local_object, + dn_addr2asc(dn_ntohs(dn_saddr2dn(&scp->peer)), buf2), + scp->addrrem, + scp->numdat_rcv, + scp->numoth_rcv, + scp->ackrcv_dat, + scp->ackrcv_oth, + scp->flowrem_sw, + remote_object, + dn_state2asc(scp->state), + ((scp->accept_mode == ACC_IMMED) ? "IMMED" : "DEFER")); + + pos = begin + len; + if (pos < offset) { + len = 0; + begin = pos; + } + if (pos > (offset + length)) + break; } - if (pos > (offset + length)) - break; } read_unlock(&dn_hash_lock); @@ -2158,7 +2233,7 @@ MODULE_PARM_DESC(addr, "The DECnet address of this machine: area,node"); #endif -static char banner[] __initdata = KERN_INFO "NET4: DECnet for Linux: V.2.4.9s (C) 1995-2001 Linux DECnet Project Team\n"; +static char banner[] __initdata = KERN_INFO "NET4: DECnet for Linux: V.2.4.15-pre5s (C) 1995-2001 Linux DECnet Project Team\n"; static int __init decnet_init(void) { diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/net/decnet/dn_dev.c linux-2.5/net/decnet/dn_dev.c --- linux-2.5.1/net/decnet/dn_dev.c Fri Jul 6 23:46:22 2001 +++ linux-2.5/net/decnet/dn_dev.c Thu Dec 13 16:32:37 2001 @@ -56,9 +56,7 @@ static struct dn_dev *dn_dev_create(struct net_device *dev, int *err); static void dn_dev_delete(struct net_device *dev); -#ifdef CONFIG_RTNETLINK static void rtmsg_ifa(int event, struct dn_ifaddr *ifa); -#endif static int dn_eth_up(struct net_device *); static void dn_send_brd_hello(struct net_device *dev); @@ -369,9 +367,7 @@ *ifap = ifa1->ifa_next; -#ifdef CONFIG_RTNETLINK rtmsg_ifa(RTM_DELADDR, ifa1); -#endif /* CONFIG_RTNETLINK */ if (destroy) { dn_dev_free_ifa(ifa1); @@ -390,9 +386,7 @@ ifa->ifa_next = dn_db->ifa_list; dn_db->ifa_list = ifa; -#ifdef CONFIG_RTNETLINK rtmsg_ifa(RTM_NEWADDR, ifa); -#endif /* CONFIG_RTNETLINK */ return 0; } @@ -501,7 +495,6 @@ return 0; } -#ifdef CONFIG_RTNETLINK static struct dn_dev *dn_dev_by_index(int ifindex) { struct net_device *dev; @@ -658,8 +651,6 @@ return skb->len; } -#endif /* CONFIG_RTNETLINK */ - static void dn_send_endnode_hello(struct net_device *dev) { struct endnode_hello_message *msg; @@ -1172,7 +1163,6 @@ #endif /* CONFIG_PROC_FS */ -#ifdef CONFIG_RTNETLINK static struct rtnetlink_link dnet_rtnetlink_table[RTM_MAX-RTM_BASE+1] = { { NULL, NULL, }, @@ -1213,7 +1203,6 @@ { NULL, NULL, } #endif }; -#endif /* CONFIG_RTNETLINK */ void __init dn_dev_init(void) { @@ -1223,9 +1212,7 @@ register_gifconf(PF_DECnet, dnet_gifconf); #endif /* CONFIG_DECNET_SIOCGIFCONF */ -#ifdef CONFIG_RTNETLINK rtnetlink_links[PF_DECnet] = dnet_rtnetlink_table; -#endif /* CONFIG_RTNETLINK */ #ifdef CONFIG_PROC_FS proc_net_create("decnet_dev", 0, decnet_dev_get_info); @@ -1242,9 +1229,7 @@ void __exit dn_dev_cleanup(void) { -#ifdef CONFIG_RTNETLINK rtnetlink_links[PF_DECnet] = NULL; -#endif /* CONFIG_RTNETLINK */ #ifdef CONFIG_DECNET_SIOCGIFCONF unregister_gifconf(PF_DECnet); diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/net/decnet/dn_fib.c linux-2.5/net/decnet/dn_fib.c --- linux-2.5.1/net/decnet/dn_fib.c Mon Jan 22 21:32:10 2001 +++ linux-2.5/net/decnet/dn_fib.c Thu Dec 13 16:32:37 2001 @@ -50,9 +50,7 @@ #define endfor_nexthops(fi) } -#ifdef CONFIG_RTNETLINK extern int dn_cache_dump(struct sk_buff *skb, struct netlink_callback *cb); -#endif /* CONFIG_RTNETLINK */ static struct dn_fib_info *dn_fib_info_list; @@ -415,8 +413,6 @@ } -#ifdef CONFIG_RTNETLINK - static int dn_fib_check_attr(struct rtmsg *r, struct rtattr **rta) { int i; @@ -497,7 +493,6 @@ return skb->len; } -#endif /* CONFIG_RTNETLINK */ int dn_fib_sync_down(dn_address local, struct net_device *dev, int force) { diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/net/decnet/dn_nsp_in.c linux-2.5/net/decnet/dn_nsp_in.c --- linux-2.5.1/net/decnet/dn_nsp_in.c Fri Nov 9 22:12:54 2001 +++ linux-2.5/net/decnet/dn_nsp_in.c Sun Dec 30 21:17:30 2001 @@ -59,7 +59,6 @@ #include <linux/inet.h> #include <linux/route.h> #include <net/sock.h> -#include <asm/segment.h> #include <asm/system.h> #include <linux/fcntl.h> #include <linux/mm.h> diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/net/decnet/dn_nsp_out.c linux-2.5/net/decnet/dn_nsp_out.c --- linux-2.5.1/net/decnet/dn_nsp_out.c Mon Jan 22 21:32:10 2001 +++ linux-2.5/net/decnet/dn_nsp_out.c Sun Dec 30 21:17:30 2001 @@ -51,7 +51,6 @@ #include <linux/inet.h> #include <linux/route.h> #include <net/sock.h> -#include <asm/segment.h> #include <asm/system.h> #include <linux/fcntl.h> #include <linux/mm.h> diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/net/decnet/dn_route.c linux-2.5/net/decnet/dn_route.c --- linux-2.5.1/net/decnet/dn_route.c Fri Nov 9 22:12:54 2001 +++ linux-2.5/net/decnet/dn_route.c Thu Dec 13 16:32:37 2001 @@ -1020,7 +1020,6 @@ return dn_route_input_slow(skb); } -#ifdef CONFIG_RTNETLINK static int dn_rt_fill_info(struct sk_buff *skb, u32 pid, u32 seq, int event, int nowait) { struct dn_route *rt = (struct dn_route *)skb->dst; @@ -1181,7 +1180,6 @@ cb->args[1] = idx; return skb->len; } -#endif /* CONFIG_RTNETLINK */ #ifdef CONFIG_PROC_FS diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/net/decnet/dn_rules.c linux-2.5/net/decnet/dn_rules.c --- linux-2.5.1/net/decnet/dn_rules.c Mon Jan 22 21:32:10 2001 +++ linux-2.5/net/decnet/dn_rules.c Thu Dec 13 16:32:37 2001 @@ -299,8 +299,6 @@ notifier_call: dn_fib_rules_event, }; -#ifdef CONFIG_RTNETLINK - static int dn_fib_fill_rule(struct sk_buff *skb, struct dn_fib_rule *r, struct netlink_callback *cb) { struct rtmsg *rtm; @@ -359,8 +357,6 @@ return skb->len; } - -#endif /* CONFIG_RTNETLINK */ void __init dn_fib_rules_init(void) { diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/net/decnet/dn_table.c linux-2.5/net/decnet/dn_table.c --- linux-2.5.1/net/decnet/dn_table.c Mon Jan 22 21:32:10 2001 +++ linux-2.5/net/decnet/dn_table.c Thu Dec 13 16:32:37 2001 @@ -267,7 +267,6 @@ return 0; } -#ifdef CONFIG_RTNETLINK static int dn_fib_dump_info(struct sk_buff *skb, u32 pid, u32 seq, int event, u8 tb_id, u8 type, u8 scope, void *dst, int dst_len, struct dn_fib_info *fi) @@ -435,12 +434,6 @@ return skb->len; } -#else /* no CONFIG_RTNETLINK */ - -#define dn_rtmsg_fib(event,f,z,tb_id,nlh,req) - -#endif /* CONFIG_RTNETLINK */ - static int dn_fib_table_insert(struct dn_fib_table *tb, struct rtmsg *r, struct dn_kern_rta *rta, struct nlmsghdr *n, struct netlink_skb_parms *req) { struct dn_hash *table = (struct dn_hash *)tb->data; @@ -860,9 +853,7 @@ #ifdef CONFIG_PROC_FS t->get_info = dn_fib_table_get_info; #endif -#ifdef CONFIG_RTNETLINK t->dump = dn_fib_table_dump; -#endif dn_fib_tables[n] = t; return t; diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/net/ipv4/Config.in linux-2.5/net/ipv4/Config.in --- linux-2.5.1/net/ipv4/Config.in Wed May 2 03:59:24 2001 +++ linux-2.5/net/ipv4/Config.in Thu Dec 13 16:32:37 2001 @@ -4,8 +4,6 @@ bool ' IP: multicasting' CONFIG_IP_MULTICAST bool ' IP: advanced router' CONFIG_IP_ADVANCED_ROUTER if [ "$CONFIG_IP_ADVANCED_ROUTER" = "y" ]; then - define_bool CONFIG_RTNETLINK y - define_bool CONFIG_NETLINK y bool ' IP: policy routing' CONFIG_IP_MULTIPLE_TABLES if [ "$CONFIG_IP_MULTIPLE_TABLES" = "y" ]; then if [ "$CONFIG_NETFILTER" = "y" ]; then @@ -39,9 +37,7 @@ fi fi if [ "$CONFIG_EXPERIMENTAL" = "y" ]; then - if [ "$CONFIG_RTNETLINK" = "y" ]; then - bool ' IP: ARP daemon support (EXPERIMENTAL)' CONFIG_ARPD - fi + bool ' IP: ARP daemon support (EXPERIMENTAL)' CONFIG_ARPD fi bool ' IP: TCP Explicit Congestion Notification support' CONFIG_INET_ECN bool ' IP: TCP syncookie support (disabled per default)' CONFIG_SYN_COOKIES diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/net/ipv4/Makefile linux-2.5/net/ipv4/Makefile --- linux-2.5.1/net/ipv4/Makefile Tue Oct 30 23:08:12 2001 +++ linux-2.5/net/ipv4/Makefile Thu Dec 13 16:32:37 2001 @@ -15,7 +15,7 @@ ip_input.o ip_fragment.o ip_forward.o ip_options.o \ ip_output.o ip_sockglue.o \ tcp.o tcp_input.o tcp_output.o tcp_timer.o tcp_ipv4.o tcp_minisocks.o \ - raw.o udp.o arp.o icmp.o devinet.o af_inet.o igmp.o \ + tcp_diag.o raw.o udp.o arp.o icmp.o devinet.o af_inet.o igmp.o \ sysctl_net_ipv4.o fib_frontend.o fib_semantics.o fib_hash.o obj-$(CONFIG_IP_MULTIPLE_TABLES) += fib_rules.o diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/net/ipv4/af_inet.c linux-2.5/net/ipv4/af_inet.c --- linux-2.5.1/net/ipv4/af_inet.c Mon Nov 5 17:46:12 2001 +++ linux-2.5/net/ipv4/af_inet.c Thu Dec 13 16:32:37 2001 @@ -5,7 +5,7 @@ * * PF_INET protocol family socket handler. * - * Version: $Id: af_inet.c,v 1.135 2001/10/27 03:27:13 davem Exp $ + * Version: $Id: af_inet.c,v 1.136 2001/11/06 22:21:08 davem Exp $ * * Authors: Ross Biro, <bir7@leland.Stanford.Edu> * Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG> diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/net/ipv4/devinet.c linux-2.5/net/ipv4/devinet.c --- linux-2.5.1/net/ipv4/devinet.c Mon Oct 1 16:19:57 2001 +++ linux-2.5/net/ipv4/devinet.c Thu Dec 13 16:32:37 2001 @@ -1,7 +1,7 @@ /* * NET3 IP device support routines. * - * Version: $Id: devinet.c,v 1.43 2001/09/26 22:52:58 davem Exp $ + * Version: $Id: devinet.c,v 1.44 2001/10/31 21:55:54 davem Exp $ * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -63,11 +63,7 @@ struct ipv4_devconf ipv4_devconf = { 1, 1, 1, 1, 0, }; static struct ipv4_devconf ipv4_devconf_dflt = { 1, 1, 1, 1, 1, }; -#ifdef CONFIG_RTNETLINK static void rtmsg_ifa(int event, struct in_ifaddr *); -#else -#define rtmsg_ifa(a,b) do { } while(0) -#endif static struct notifier_block *inetaddr_chain; static void inet_del_ifa(struct in_device *in_dev, struct in_ifaddr **ifap, int destroy); @@ -359,8 +355,6 @@ return NULL; } -#ifdef CONFIG_RTNETLINK - int inet_rtm_deladdr(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg) { @@ -437,8 +431,6 @@ return inet_insert_ifa(ifa); } -#endif - /* * Determine a default network mask, based on the IP address. */ @@ -859,8 +851,6 @@ notifier_call: inetdev_event, }; -#ifdef CONFIG_RTNETLINK - static int inet_fill_ifaddr(struct sk_buff *skb, struct in_ifaddr *ifa, u32 pid, u32 seq, int event) { @@ -994,8 +984,6 @@ #endif }; -#endif /* CONFIG_RTNETLINK */ - #ifdef CONFIG_SYSCTL @@ -1150,9 +1138,7 @@ { register_gifconf(PF_INET, inet_gifconf); register_netdevice_notifier(&ip_netdev_notifier); -#ifdef CONFIG_RTNETLINK rtnetlink_links[PF_INET] = inet_rtnetlink_table; -#endif #ifdef CONFIG_SYSCTL devinet_sysctl.sysctl_header = register_sysctl_table(devinet_sysctl.devinet_root_dir, 0); diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/net/ipv4/fib_frontend.c linux-2.5/net/ipv4/fib_frontend.c --- linux-2.5.1/net/ipv4/fib_frontend.c Tue Jun 12 02:15:27 2001 +++ linux-2.5/net/ipv4/fib_frontend.c Thu Dec 13 16:32:37 2001 @@ -5,7 +5,7 @@ * * IPv4 Forwarding Information Base: FIB frontend. * - * Version: $Id: fib_frontend.c,v 1.25 2001/05/29 22:16:25 davem Exp $ + * Version: $Id: fib_frontend.c,v 1.26 2001/10/31 21:55:54 davem Exp $ * * Authors: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru> * @@ -332,8 +332,6 @@ #endif -#ifdef CONFIG_RTNETLINK - static int inet_check_attr(struct rtmsg *r, struct rtattr **rta) { int i; @@ -408,8 +406,6 @@ return skb->len; } - -#endif /* Prepare and feed intra-kernel routing request. Really, it should be netlink message, but :-( netlink diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/net/ipv4/fib_hash.c linux-2.5/net/ipv4/fib_hash.c --- linux-2.5.1/net/ipv4/fib_hash.c Tue Aug 31 18:23:03 1999 +++ linux-2.5/net/ipv4/fib_hash.c Thu Dec 13 16:32:37 2001 @@ -5,7 +5,7 @@ * * IPv4 FIB: lookup engine and maintenance routines. * - * Version: $Id: fib_hash.c,v 1.12 1999/08/31 07:03:27 davem Exp $ + * Version: $Id: fib_hash.c,v 1.13 2001/10/31 21:55:54 davem Exp $ * * Authors: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru> * @@ -425,14 +425,9 @@ #endif -#ifdef CONFIG_RTNETLINK static void rtmsg_fib(int, struct fib_node*, int, int, struct nlmsghdr *n, struct netlink_skb_parms *); -#else -#define rtmsg_fib(a, b, c, d, e, f) -#endif - static int fn_hash_insert(struct fib_table *tb, struct rtmsg *r, struct kern_rta *rta, @@ -796,9 +791,7 @@ #endif -#ifdef CONFIG_RTNETLINK - -extern __inline__ int +static __inline__ int fn_hash_dump_bucket(struct sk_buff *skb, struct netlink_callback *cb, struct fib_table *tb, struct fn_zone *fz, @@ -823,7 +816,7 @@ return skb->len; } -extern __inline__ int +static __inline__ int fn_hash_dump_zone(struct sk_buff *skb, struct netlink_callback *cb, struct fib_table *tb, struct fn_zone *fz) @@ -894,8 +887,6 @@ netlink_unicast(rtnl, skb, pid, MSG_DONTWAIT); } -#endif /* CONFIG_RTNETLINK */ - #ifdef CONFIG_IP_MULTIPLE_TABLES struct fib_table * fib_hash_init(int id) #else @@ -920,9 +911,7 @@ tb->tb_delete = fn_hash_delete; tb->tb_flush = fn_hash_flush; tb->tb_select_default = fn_hash_select_default; -#ifdef CONFIG_RTNETLINK tb->tb_dump = fn_hash_dump; -#endif #ifdef CONFIG_PROC_FS tb->tb_get_info = fn_hash_get_info; #endif diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/net/ipv4/fib_rules.c linux-2.5/net/ipv4/fib_rules.c --- linux-2.5.1/net/ipv4/fib_rules.c Wed May 2 03:59:24 2001 +++ linux-2.5/net/ipv4/fib_rules.c Thu Dec 13 16:32:37 2001 @@ -5,7 +5,7 @@ * * IPv4 Forwarding Information Base: policy rules. * - * Version: $Id: fib_rules.c,v 1.16 2001/04/30 04:39:14 davem Exp $ + * Version: $Id: fib_rules.c,v 1.17 2001/10/31 21:55:54 davem Exp $ * * Authors: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru> * @@ -395,9 +395,7 @@ notifier_call: fib_rules_event, }; -#ifdef CONFIG_RTNETLINK - -extern __inline__ int inet_fill_rule(struct sk_buff *skb, +static __inline__ int inet_fill_rule(struct sk_buff *skb, struct fib_rule *r, struct netlink_callback *cb) { @@ -462,8 +460,6 @@ return skb->len; } - -#endif /* CONFIG_RTNETLINK */ void __init fib_rules_init(void) { diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/net/ipv4/fib_semantics.c linux-2.5/net/ipv4/fib_semantics.c --- linux-2.5.1/net/ipv4/fib_semantics.c Tue Aug 22 15:59:00 2000 +++ linux-2.5/net/ipv4/fib_semantics.c Thu Dec 13 16:32:37 2001 @@ -5,7 +5,7 @@ * * IPv4 Forwarding Information Base: semantics. * - * Version: $Id: fib_semantics.c,v 1.17 2000/08/19 23:22:56 davem Exp $ + * Version: $Id: fib_semantics.c,v 1.18 2001/10/31 21:55:54 davem Exp $ * * Authors: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru> * @@ -626,8 +626,6 @@ return inet_select_addr(FIB_RES_DEV(*res), FIB_RES_GW(*res), res->scope); } -#ifdef CONFIG_RTNETLINK - int fib_dump_info(struct sk_buff *skb, u32 pid, u32 seq, int event, u8 tb_id, u8 type, u8 scope, void *dst, int dst_len, u8 tos, @@ -697,8 +695,6 @@ skb_trim(skb, b - skb->data); return -1; } - -#endif /* CONFIG_RTNETLINK */ #ifndef CONFIG_IP_NOSIOCRT diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/net/ipv4/ipconfig.c linux-2.5/net/ipv4/ipconfig.c --- linux-2.5.1/net/ipv4/ipconfig.c Thu Nov 29 15:49:10 2001 +++ linux-2.5/net/ipv4/ipconfig.c Thu Dec 13 16:32:37 2001 @@ -1,5 +1,5 @@ /* - * $Id: ipconfig.c,v 1.42 2001/11/10 07:23:12 davem Exp $ + * $Id: ipconfig.c,v 1.43 2001/11/21 20:27:34 davem Exp $ * * Automatic Configuration of IP -- use DHCP, BOOTP, RARP, or * user-supplied information to configure own IP address and routes. diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/net/ipv4/ipmr.c linux-2.5/net/ipv4/ipmr.c --- linux-2.5.1/net/ipv4/ipmr.c Thu Sep 20 21:12:56 2001 +++ linux-2.5/net/ipv4/ipmr.c Thu Dec 13 16:32:37 2001 @@ -9,7 +9,7 @@ * as published by the Free Software Foundation; either version * 2 of the License, or (at your option) any later version. * - * Version: $Id: ipmr.c,v 1.64 2001/09/18 22:29:09 davem Exp $ + * Version: $Id: ipmr.c,v 1.65 2001/10/31 21:55:54 davem Exp $ * * Fixes: * Michael Chastain : Incorrect size of copying. @@ -294,7 +294,6 @@ atomic_dec(&cache_resolve_queue_len); while((skb=skb_dequeue(&c->mfc_un.unres.unresolved))) { -#ifdef CONFIG_RTNETLINK if (skb->nh.iph->version == 0) { struct nlmsghdr *nlh = (struct nlmsghdr *)skb_pull(skb, sizeof(struct iphdr)); nlh->nlmsg_type = NLMSG_ERROR; @@ -303,7 +302,6 @@ ((struct nlmsgerr*)NLMSG_DATA(nlh))->error = -ETIMEDOUT; netlink_unicast(rtnl, skb, NETLINK_CB(skb).dst_pid, MSG_DONTWAIT); } else -#endif kfree_skb(skb); } @@ -501,7 +499,6 @@ */ while((skb=__skb_dequeue(&uc->mfc_un.unres.unresolved))) { -#ifdef CONFIG_RTNETLINK if (skb->nh.iph->version == 0) { int err; struct nlmsghdr *nlh = (struct nlmsghdr *)skb_pull(skb, sizeof(struct iphdr)); @@ -516,7 +513,6 @@ } err = netlink_unicast(rtnl, skb, NETLINK_CB(skb).dst_pid, MSG_DONTWAIT); } else -#endif ip_mr_forward(skb, c, 0); } } @@ -1522,8 +1518,6 @@ } #endif -#ifdef CONFIG_RTNETLINK - static int ipmr_fill_mroute(struct sk_buff *skb, struct mfc_cache *c, struct rtmsg *rtm) { @@ -1598,7 +1592,6 @@ read_unlock(&mrt_lock); return err; } -#endif #ifdef CONFIG_PROC_FS /* diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/net/ipv4/netfilter/Config.in linux-2.5/net/ipv4/netfilter/Config.in --- linux-2.5.1/net/ipv4/netfilter/Config.in Tue Oct 30 23:08:12 2001 +++ linux-2.5/net/ipv4/netfilter/Config.in Thu Dec 13 16:32:37 2001 @@ -10,7 +10,7 @@ dep_tristate ' IRC protocol support' CONFIG_IP_NF_IRC $CONFIG_IP_NF_CONNTRACK fi -if [ "$CONFIG_EXPERIMENTAL" = "y" -a "$CONFIG_NETLINK" = "y" ]; then +if [ "$CONFIG_EXPERIMENTAL" = "y" ]; then tristate 'Userspace queueing via NETLINK (EXPERIMENTAL)' CONFIG_IP_NF_QUEUE fi tristate 'IP tables support (required for filtering/masq/NAT)' CONFIG_IP_NF_IPTABLES diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/net/ipv4/netfilter/ip_conntrack_irc.c linux-2.5/net/ipv4/netfilter/ip_conntrack_irc.c --- linux-2.5.1/net/ipv4/netfilter/ip_conntrack_irc.c Tue Oct 30 23:08:12 2001 +++ linux-2.5/net/ipv4/netfilter/ip_conntrack_irc.c Thu Dec 13 16:32:37 2001 @@ -1,8 +1,8 @@ -/* IRC extension for IP connection tracking, Version 1.19 - * (C) 2000 by Harald Welte <laforge@gnumonks.org> +/* IRC extension for IP connection tracking, Version 1.20 + * (C) 2000-2001 by Harald Welte <laforge@gnumonks.org> * based on RR's ip_conntrack_ftp.c * - * ip_conntrack_irc.c,v 1.19 2001/10/25 14:34:21 laforge Exp + * ip_conntrack_irc.c,v 1.20 2001/12/06 07:42:10 laforge Exp * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -10,7 +10,7 @@ * 2 of the License, or (at your option) any later version. ** * Module load syntax: - * insmod ip_nat_irc.o ports=port1,port2,...port<MAX_PORTS> + * insmod ip_conntrack_irc.o ports=port1,port2,...port<MAX_PORTS> * * please give the ports of all IRC servers You wish to connect to. * If You don't specify ports, the default will be port 6667 diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/net/ipv4/netfilter/ip_fw_compat.c linux-2.5/net/ipv4/netfilter/ip_fw_compat.c --- linux-2.5.1/net/ipv4/netfilter/ip_fw_compat.c Sat Nov 10 23:36:38 2001 +++ linux-2.5/net/ipv4/netfilter/ip_fw_compat.c Thu Dec 13 16:32:37 2001 @@ -84,6 +84,16 @@ if ((*pskb)->ip_summed == CHECKSUM_HW) (*pskb)->ip_summed = CHECKSUM_NONE; + /* Firewall rules can alter TOS: raw socket (tcpdump) may have + clone of incoming skb: don't disturb it --RR */ + if (skb_cloned(*pskb) && !(*pskb)->sk) { + struct sk_buff *nskb = skb_copy(*pskb, GFP_ATOMIC); + if (!nskb) + return NF_DROP; + kfree_skb(*pskb); + *pskb = nskb; + } + switch (hooknum) { case NF_IP_PRE_ROUTING: if (fwops->fw_acct_in) diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/net/ipv4/netfilter/ip_fw_compat_redir.c linux-2.5/net/ipv4/netfilter/ip_fw_compat_redir.c --- linux-2.5.1/net/ipv4/netfilter/ip_fw_compat_redir.c Fri Aug 4 20:07:24 2000 +++ linux-2.5/net/ipv4/netfilter/ip_fw_compat_redir.c Thu Dec 13 16:32:37 2001 @@ -206,6 +206,8 @@ } list_prepend(&redirs, redir); init_timer(&redir->destroyme); + redir->destroyme.expires = jiffies + 75*HZ; + add_timer(&redir->destroyme); } /* In case mangling has changed, rewrite this part. */ redir->core = ((struct redir_core) diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/net/ipv4/netfilter/ip_nat_core.c linux-2.5/net/ipv4/netfilter/ip_nat_core.c --- linux-2.5.1/net/ipv4/netfilter/ip_nat_core.c Sat Nov 10 23:36:38 2001 +++ linux-2.5/net/ipv4/netfilter/ip_nat_core.c Thu Dec 13 16:32:37 2001 @@ -734,6 +734,18 @@ synchronize_bh()) can vanish. */ READ_LOCK(&ip_nat_lock); for (i = 0; i < info->num_manips; i++) { + /* raw socket (tcpdump) may have clone of incoming + skb: don't disturb it --RR */ + if (skb_cloned(*pskb) && !(*pskb)->sk) { + struct sk_buff *nskb = skb_copy(*pskb, GFP_ATOMIC); + if (!nskb) { + READ_UNLOCK(&ip_nat_lock); + return NF_DROP; + } + kfree_skb(*pskb); + *pskb = nskb; + } + if (info->manips[i].direction == dir && info->manips[i].hooknum == hooknum) { DEBUGP("Mangling %p: %s to %u.%u.%u.%u %u\n", diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/net/ipv4/netfilter/ip_nat_helper.c linux-2.5/net/ipv4/netfilter/ip_nat_helper.c --- linux-2.5.1/net/ipv4/netfilter/ip_nat_helper.c Tue Aug 28 14:09:44 2001 +++ linux-2.5/net/ipv4/netfilter/ip_nat_helper.c Thu Dec 13 16:32:37 2001 @@ -143,6 +143,23 @@ } } + /* Alexey says: if a hook changes _data_ ... it can break + original packet sitting in tcp queue and this is fatal */ + if (skb_cloned(*skb)) { + struct sk_buff *nskb = skb_copy(*skb, GFP_ATOMIC); + if (!nskb) { + if (net_ratelimit()) + printk("Out of memory cloning TCP packet\n"); + return 0; + } + /* Rest of kernel will get very unhappy if we pass it + a suddenly-orphaned skbuff */ + if ((*skb)->sk) + skb_set_owner_w(nskb, (*skb)->sk); + kfree_skb(*skb); + *skb = nskb; + } + /* skb may be copied !! */ iph = (*skb)->nh.iph; tcph = (void *)iph + iph->ihl*4; diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/net/ipv4/netfilter/ip_nat_irc.c linux-2.5/net/ipv4/netfilter/ip_nat_irc.c --- linux-2.5.1/net/ipv4/netfilter/ip_nat_irc.c Tue Oct 30 23:08:12 2001 +++ linux-2.5/net/ipv4/netfilter/ip_nat_irc.c Thu Dec 13 16:32:37 2001 @@ -1,8 +1,8 @@ /* IRC extension for TCP NAT alteration. - * (C) 2000 by Harald Welte <laforge@gnumonks.org> + * (C) 2000-2001 by Harald Welte <laforge@gnumonks.org> * based on a copy of RR's ip_nat_ftp.c * - * ip_nat_irc.c,v 1.15 2001/10/22 10:43:53 laforge Exp + * ip_nat_irc.c,v 1.16 2001/12/06 07:42:10 laforge Exp * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -81,7 +81,7 @@ } newdstip = master->tuplehash[IP_CT_DIR_ORIGINAL].tuple.src.ip; - newsrcip = master->tuplehash[IP_CT_DIR_ORIGINAL].tuple.dst.ip; + newsrcip = ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.src.ip; DEBUGP("nat_expected: DCC cmd. %u.%u.%u.%u->%u.%u.%u.%u\n", NIPQUAD(newsrcip), NIPQUAD(newdstip)); diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/net/ipv4/netfilter/ipt_MIRROR.c linux-2.5/net/ipv4/netfilter/ipt_MIRROR.c --- linux-2.5.1/net/ipv4/netfilter/ipt_MIRROR.c Sun Sep 30 19:26:08 2001 +++ linux-2.5/net/ipv4/netfilter/ipt_MIRROR.c Thu Dec 13 16:32:37 2001 @@ -6,6 +6,10 @@ Copyright (C) 2000 Emmanuel Roger <winfield@freegates.be> + Changes: + 25 Aug 2001 Harald Welte <laforge@gnumonks.org> + - decrement and check TTL if not called from FORWARD hook + 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 @@ -24,6 +28,7 @@ #include <linux/skbuff.h> #include <linux/ip.h> #include <net/ip.h> +#include <net/icmp.h> #include <linux/netfilter_ipv4/ip_tables.h> #include <linux/netdevice.h> #include <linux/route.h> @@ -100,15 +105,31 @@ const void *targinfo, void *userinfo) { - if ((*pskb)->dst != NULL) { - if (route_mirror(*pskb)) { - ip_rewrite(*pskb); - /* Don't let conntrack code see this packet: - it will think we are starting a new - connection! --RR */ - ip_direct_send(*pskb); - return NF_STOLEN; + if (((*pskb)->dst != NULL) && + route_mirror(*pskb)) { + + ip_rewrite(*pskb); + + /* If we are not at FORWARD hook (INPUT/PREROUTING), + * the TTL isn't decreased by the IP stack */ + if (hooknum != NF_IP_FORWARD) { + struct iphdr *iph = (*pskb)->nh.iph; + if (iph->ttl <= 1) { + /* this will traverse normal stack, and + * thus call conntrack on the icmp packet */ + icmp_send(*pskb, ICMP_TIME_EXCEEDED, + ICMP_EXC_TTL, 0); + return NF_DROP; + } + ip_decrease_ttl(iph); } + + /* Don't let conntrack code see this packet: + it will think we are starting a new + connection! --RR */ + ip_direct_send(*pskb); + + return NF_STOLEN; } return NF_DROP; } diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/net/ipv4/netfilter/ipt_TCPMSS.c linux-2.5/net/ipv4/netfilter/ipt_TCPMSS.c --- linux-2.5.1/net/ipv4/netfilter/ipt_TCPMSS.c Sat Nov 10 23:36:38 2001 +++ linux-2.5/net/ipv4/netfilter/ipt_TCPMSS.c Thu Dec 13 16:32:37 2001 @@ -44,11 +44,22 @@ { const struct ipt_tcpmss_info *tcpmssinfo = targinfo; struct tcphdr *tcph; - struct iphdr *iph = (*pskb)->nh.iph; + struct iphdr *iph; u_int16_t tcplen, newtotlen, oldval, newmss; unsigned int i; u_int8_t *opt; + /* raw socket (tcpdump) may have clone of incoming skb: don't + disturb it --RR */ + if (skb_cloned(*pskb) && !(*pskb)->sk) { + struct sk_buff *nskb = skb_copy(*pskb, GFP_ATOMIC); + if (!nskb) + return NF_DROP; + kfree_skb(*pskb); + *pskb = nskb; + } + + iph = (*pskb)->nh.iph; tcplen = (*pskb)->len - iph->ihl*4; tcph = (void *)iph + iph->ihl*4; diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/net/ipv4/netfilter/ipt_TOS.c linux-2.5/net/ipv4/netfilter/ipt_TOS.c --- linux-2.5.1/net/ipv4/netfilter/ipt_TOS.c Sat Nov 10 23:36:38 2001 +++ linux-2.5/net/ipv4/netfilter/ipt_TOS.c Wed Dec 19 01:08:32 2001 @@ -21,6 +21,17 @@ if ((iph->tos & IPTOS_TOS_MASK) != tosinfo->tos) { u_int16_t diffs[2]; + /* raw socket (tcpdump) may have clone of incoming + skb: don't disturb it --RR */ + if (skb_cloned(*pskb) && !(*pskb)->sk) { + struct sk_buff *nskb = skb_copy(*pskb, GFP_ATOMIC); + if (!nskb) + return NF_DROP; + kfree_skb(*pskb); + *pskb = nskb; + iph = (*pskb)->nh.iph; + } + diffs[0] = htons(iph->tos) ^ 0xFFFF; iph->tos = (iph->tos & IPTOS_PREC_MASK) | tosinfo->tos; diffs[1] = htons(iph->tos); diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/net/ipv4/netfilter/ipt_unclean.c linux-2.5/net/ipv4/netfilter/ipt_unclean.c --- linux-2.5.1/net/ipv4/netfilter/ipt_unclean.c Sun Sep 30 19:26:08 2001 +++ linux-2.5/net/ipv4/netfilter/ipt_unclean.c Thu Dec 13 16:32:37 2001 @@ -257,6 +257,8 @@ #define TH_PUSH 0x08 #define TH_ACK 0x10 #define TH_URG 0x20 +#define TH_ECE 0x40 +#define TH_CWR 0x80 /* TCP-specific checks. */ static int @@ -328,9 +330,10 @@ } /* CHECK: TCP flags. */ - tcpflags = ((u_int8_t *)tcph)[13]; + tcpflags = (((u_int8_t *)tcph)[13] & ~(TH_ECE|TH_CWR)); if (tcpflags != TH_SYN && tcpflags != (TH_SYN|TH_ACK) + && tcpflags != TH_RST && tcpflags != (TH_RST|TH_ACK) && tcpflags != (TH_RST|TH_ACK|TH_PUSH) && tcpflags != (TH_FIN|TH_ACK) diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/net/ipv4/route.c linux-2.5/net/ipv4/route.c --- linux-2.5.1/net/ipv4/route.c Tue Oct 30 23:08:12 2001 +++ linux-2.5/net/ipv4/route.c Thu Dec 13 16:32:37 2001 @@ -5,7 +5,7 @@ * * ROUTE - implementation of the IP router. * - * Version: $Id: route.c,v 1.101 2001/10/20 00:00:11 davem Exp $ + * Version: $Id: route.c,v 1.102 2001/10/31 21:55:54 davem Exp $ * * Authors: Ross Biro, <bir7@leland.Stanford.Edu> * Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG> @@ -2013,7 +2013,6 @@ return ip_route_output_slow(rp, key); } -#ifdef CONFIG_RTNETLINK static int rt_fill_info(struct sk_buff *skb, u32 pid, u32 seq, int event, int nowait) { @@ -2218,8 +2217,6 @@ cb->args[1] = idx; return skb->len; } - -#endif /* CONFIG_RTNETLINK */ void ip_rt_multicast_event(struct in_device *in_dev) { diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/net/ipv4/tcp.c linux-2.5/net/ipv4/tcp.c --- linux-2.5.1/net/ipv4/tcp.c Tue Oct 30 23:08:12 2001 +++ linux-2.5/net/ipv4/tcp.c Thu Dec 13 16:32:37 2001 @@ -5,7 +5,7 @@ * * Implementation of the Transmission Control Protocol(TCP). * - * Version: $Id: tcp.c,v 1.214 2001/10/20 00:00:11 davem Exp $ + * Version: $Id: tcp.c,v 1.215 2001/10/31 08:17:58 davem Exp $ * * Authors: Ross Biro, <bir7@leland.Stanford.Edu> * Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG> @@ -2442,6 +2442,7 @@ extern void __skb_cb_too_small_for_tcp(int, int); +extern void tcpdiag_init(void); void __init tcp_init(void) { @@ -2553,4 +2554,6 @@ printk("TCP: Hash tables configured (established %d bind %d)\n", tcp_ehash_size<<1, tcp_bhash_size); + + tcpdiag_init(); } diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/net/ipv4/tcp_diag.c linux-2.5/net/ipv4/tcp_diag.c --- linux-2.5.1/net/ipv4/tcp_diag.c Thu Jan 1 00:00:00 1970 +++ linux-2.5/net/ipv4/tcp_diag.c Thu Dec 13 16:45:01 2001 @@ -0,0 +1,609 @@ +/* + * tcp_diag.c Module for monitoring TCP sockets. + * + * Version: $Id: tcp_diag.c,v 1.1 2001/12/13 16:45:01 davej Exp $ + * + * Authors: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru> + * + * 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. + */ + +#include <linux/config.h> +#include <linux/module.h> +#include <linux/types.h> +#include <linux/fcntl.h> +#include <linux/random.h> +#include <linux/cache.h> +#include <linux/init.h> + +#include <net/icmp.h> +#include <net/tcp.h> +#include <net/ipv6.h> +#include <net/inet_common.h> + +#include <linux/inet.h> +#include <linux/stddef.h> + +#include <linux/tcp_diag.h> + +static struct sock *tcpnl; + + +#define TCPDIAG_PUT(skb, attrtype, attrlen) \ +({ int rtalen = RTA_LENGTH(attrlen); \ + struct rtattr *rta; \ + if (skb_tailroom(skb) < RTA_ALIGN(rtalen)) goto nlmsg_failure; \ + rta = (void*)__skb_put(skb, RTA_ALIGN(rtalen)); \ + rta->rta_type = attrtype; \ + rta->rta_len = rtalen; \ + RTA_DATA(rta); }) + +static int tcpdiag_fill(struct sk_buff *skb, struct sock *sk, + int ext, u32 pid, u32 seq) +{ + struct tcp_opt *tp = &sk->tp_pinfo.af_tcp; + struct tcpdiagmsg *r; + struct nlmsghdr *nlh; + struct tcp_info *info = NULL; + struct tcpdiag_meminfo *minfo = NULL; + unsigned char *b = skb->tail; + + nlh = NLMSG_PUT(skb, pid, seq, TCPDIAG_GETSOCK, sizeof(*r)); + r = NLMSG_DATA(nlh); + if (sk->state != TCP_TIME_WAIT) { + if (ext & (1<<(TCPDIAG_MEMINFO-1))) + minfo = TCPDIAG_PUT(skb, TCPDIAG_MEMINFO, sizeof(*minfo)); + if (ext & (1<<(TCPDIAG_INFO-1))) + info = TCPDIAG_PUT(skb, TCPDIAG_INFO, sizeof(*info)); + } + r->tcpdiag_family = sk->family; + r->tcpdiag_state = sk->state; + r->tcpdiag_timer = 0; + r->tcpdiag_retrans = 0; + + r->id.tcpdiag_sport = sk->sport; + r->id.tcpdiag_dport = sk->dport; + r->id.tcpdiag_src[0] = sk->rcv_saddr; + r->id.tcpdiag_dst[0] = sk->daddr; + r->id.tcpdiag_if = sk->bound_dev_if; + *((struct sock **)&r->id.tcpdiag_cookie) = sk; + + if (r->tcpdiag_state == TCP_TIME_WAIT) { + struct tcp_tw_bucket *tw = (struct tcp_tw_bucket*)sk; + long tmo = tw->ttd - jiffies; + if (tmo < 0) + tmo = 0; + + r->tcpdiag_state = tw->substate; + r->tcpdiag_timer = 3; + r->tcpdiag_expires = (tmo*1000+HZ-1)/HZ; + r->tcpdiag_rqueue = 0; + r->tcpdiag_wqueue = 0; + r->tcpdiag_uid = 0; + r->tcpdiag_inode = 0; +#ifdef CONFIG_IPV6 + if (r->tcpdiag_family == AF_INET6) { + memcpy(r->id.tcpdiag_src, &tw->v6_rcv_saddr, 16); + memcpy(r->id.tcpdiag_dst, &tw->v6_daddr, 16); + } +#endif + nlh->nlmsg_len = skb->tail - b; + return skb->len; + } + +#ifdef CONFIG_IPV6 + if (r->tcpdiag_family == AF_INET6) { + memcpy(r->id.tcpdiag_src, &sk->net_pinfo.af_inet6.rcv_saddr, 16); + memcpy(r->id.tcpdiag_dst, &sk->net_pinfo.af_inet6.daddr, 16); + } +#endif + +#define EXPIRES_IN_MS(tmo) ((tmo-jiffies)*1000+HZ-1)/HZ + + if (tp->pending == TCP_TIME_RETRANS) { + r->tcpdiag_timer = 1; + r->tcpdiag_retrans = tp->retransmits; + r->tcpdiag_expires = EXPIRES_IN_MS(tp->timeout); + } else if (tp->pending == TCP_TIME_PROBE0) { + r->tcpdiag_timer = 4; + r->tcpdiag_retrans = tp->probes_out; + r->tcpdiag_expires = EXPIRES_IN_MS(tp->timeout); + } else if (timer_pending(&sk->timer)) { + r->tcpdiag_timer = 2; + r->tcpdiag_retrans = tp->probes_out; + r->tcpdiag_expires = EXPIRES_IN_MS(sk->timer.expires); + } else { + r->tcpdiag_timer = 0; + r->tcpdiag_expires = 0; + } +#undef EXPIRES_IN_MS + + r->tcpdiag_rqueue = tp->rcv_nxt - tp->copied_seq; + r->tcpdiag_wqueue = tp->write_seq - tp->snd_una; + r->tcpdiag_uid = sock_i_uid(sk); + r->tcpdiag_inode = sock_i_ino(sk); + + if (minfo) { + minfo->tcpdiag_rmem = atomic_read(&sk->rmem_alloc); + minfo->tcpdiag_wmem = sk->wmem_queued; + minfo->tcpdiag_fmem = sk->forward_alloc; + minfo->tcpdiag_tmem = atomic_read(&sk->wmem_alloc); + } + + if (info) { + u32 now = tcp_time_stamp; + + info->tcpi_state = sk->state; + info->tcpi_ca_state = tp->ca_state; + info->tcpi_retransmits = tp->retransmits; + info->tcpi_probes = tp->probes_out; + info->tcpi_backoff = tp->backoff; + info->tcpi_options = 0; + if (tp->tstamp_ok) + info->tcpi_options |= TCPI_OPT_TIMESTAMPS; + if (tp->sack_ok) + info->tcpi_options |= TCPI_OPT_SACK; + if (tp->wscale_ok) { + info->tcpi_options |= TCPI_OPT_WSCALE; + info->tcpi_snd_wscale = tp->snd_wscale; + info->tcpi_rcv_wscale = tp->rcv_wscale; + } else { + info->tcpi_snd_wscale = 0; + info->tcpi_rcv_wscale = 0; + } +#ifdef CONFIG_INET_ECN + if (tp->ecn_flags&TCP_ECN_OK) + info->tcpi_options |= TCPI_OPT_ECN; +#endif + + info->tcpi_rto = (1000000*tp->rto)/HZ; + info->tcpi_ato = (1000000*tp->ack.ato)/HZ; + info->tcpi_snd_mss = tp->mss_cache; + info->tcpi_rcv_mss = tp->ack.rcv_mss; + + info->tcpi_unacked = tp->packets_out; + info->tcpi_sacked = tp->sacked_out; + info->tcpi_lost = tp->lost_out; + info->tcpi_retrans = tp->retrans_out; + info->tcpi_fackets = tp->fackets_out; + + info->tcpi_last_data_sent = ((now - tp->lsndtime)*1000)/HZ; + info->tcpi_last_ack_sent = 0; + info->tcpi_last_data_recv = ((now - tp->ack.lrcvtime)*1000)/HZ; + info->tcpi_last_ack_recv = ((now - tp->rcv_tstamp)*1000)/HZ; + + info->tcpi_pmtu = tp->pmtu_cookie; + info->tcpi_rcv_ssthresh = tp->rcv_ssthresh; + info->tcpi_rtt = ((1000000*tp->srtt)/HZ)>>3; + info->tcpi_rttvar = ((1000000*tp->mdev)/HZ)>>2; + info->tcpi_snd_ssthresh = tp->snd_ssthresh; + info->tcpi_snd_cwnd = tp->snd_cwnd; + info->tcpi_advmss = tp->advmss; + info->tcpi_reordering = tp->reordering; + } + + nlh->nlmsg_len = skb->tail - b; + return skb->len; + +nlmsg_failure: + skb_trim(skb, b - skb->data); + return -1; +} + +extern struct sock *tcp_v4_lookup(u32 saddr, u16 sport, u32 daddr, u16 dport, int dif); +#ifdef CONFIG_IPV6 +extern struct sock *tcp_v6_lookup(struct in6_addr *saddr, u16 sport, + struct in6_addr *daddr, u16 dport, + int dif); +#endif + +static int tcpdiag_get_exact(struct sk_buff *in_skb, struct nlmsghdr *nlh) +{ + int err; + struct sock *sk; + struct tcpdiagreq *req = NLMSG_DATA(nlh); + struct sk_buff *rep; + + if (req->tcpdiag_family == AF_INET) { + sk = tcp_v4_lookup(req->id.tcpdiag_dst[0], req->id.tcpdiag_dport, + req->id.tcpdiag_src[0], req->id.tcpdiag_sport, + req->id.tcpdiag_if); + } +#ifdef CONFIG_IPV6 + else if (req->tcpdiag_family == AF_INET6) { + sk = tcp_v6_lookup((struct in6_addr*)req->id.tcpdiag_dst, req->id.tcpdiag_dport, + (struct in6_addr*)req->id.tcpdiag_src, req->id.tcpdiag_sport, + req->id.tcpdiag_if); + } +#endif + else { + return -EINVAL; + } + + if (sk == NULL) + return -ENOENT; + + err = -ESTALE; + if ((req->id.tcpdiag_cookie[0] != TCPDIAG_NOCOOKIE || + req->id.tcpdiag_cookie[1] != TCPDIAG_NOCOOKIE) && + sk != *((struct sock **)&req->id.tcpdiag_cookie[0])) + goto out; + + err = -ENOMEM; + rep = alloc_skb(NLMSG_SPACE(sizeof(struct tcpdiagmsg)+ + sizeof(struct tcpdiag_meminfo)+ + sizeof(struct tcp_info)+64), GFP_KERNEL); + if (!rep) + goto out; + + if (tcpdiag_fill(rep, sk, req->tcpdiag_ext, + NETLINK_CB(in_skb).pid, + nlh->nlmsg_seq) <= 0) + BUG(); + + err = netlink_unicast(tcpnl, rep, NETLINK_CB(in_skb).pid, MSG_DONTWAIT); + if (err > 0) + err = 0; + +out: + if (sk) { + if (sk->state == TCP_TIME_WAIT) + tcp_tw_put((struct tcp_tw_bucket*)sk); + else + sock_put(sk); + } + return err; +} + +int bitstring_match(u32 *a1, u32 *a2, int bits) +{ + int words = bits >> 5; + + bits &= 0x1f; + + if (words) { + if (memcmp(a1, a2, words << 2)) + return 0; + } + if (bits) { + __u32 w1, w2; + __u32 mask; + + w1 = a1[words]; + w2 = a2[words]; + + mask = htonl((0xffffffff) << (32 - bits)); + + if ((w1 ^ w2) & mask) + return 0; + } + + return 1; +} + + +int tcpdiag_bc_run(char *bc, int len, struct sock *sk) +{ + while (len > 0) { + int yes = 1; + struct tcpdiag_bc_op *op = (struct tcpdiag_bc_op*)bc; + + switch (op->code) { + case TCPDIAG_BC_NOP: + break; + case TCPDIAG_BC_JMP: + yes = 0; + break; + case TCPDIAG_BC_S_GE: + yes = (sk->num >= op[1].no); + break; + case TCPDIAG_BC_S_LE: + yes = (sk->num <= op[1].no); + break; + case TCPDIAG_BC_D_GE: + yes = (ntohs(sk->dport) >= op[1].no); + break; + case TCPDIAG_BC_D_LE: + yes = (ntohs(sk->dport) <= op[1].no); + break; + case TCPDIAG_BC_AUTO: + yes = !(sk->userlocks&SOCK_BINDPORT_LOCK); + break; + case TCPDIAG_BC_S_COND: + case TCPDIAG_BC_D_COND: + { + struct tcpdiag_hostcond *cond = (struct tcpdiag_hostcond*)(op+1); + u32 *addr; + + if (cond->port != -1 && + cond->port != (op->code == TCPDIAG_BC_S_COND ? sk->num : ntohs(sk->dport))) { + yes = 0; + break; + } + + if (cond->prefix_len == 0) + break; + +#ifdef CONFIG_IPV6 + if (sk->family == AF_INET6) { + if (op->code == TCPDIAG_BC_S_COND) + addr = (u32*)&sk->net_pinfo.af_inet6.rcv_saddr; + else + addr = (u32*)&sk->net_pinfo.af_inet6.daddr; + } else +#endif + { + if (op->code == TCPDIAG_BC_S_COND) + addr = &sk->rcv_saddr; + else + addr = &sk->daddr; + } + + if (bitstring_match(addr, cond->addr, cond->prefix_len)) + break; + if (sk->family == AF_INET6 && cond->family == AF_INET) { + if (addr[0] == 0 && addr[1] == 0 && + addr[2] == __constant_htonl(0xffff) && + bitstring_match(addr+3, cond->addr, cond->prefix_len)) + break; + } + yes = 0; + break; + } + } + + if (yes) { + len -= op->yes; + bc += op->yes; + } else { + len -= op->no; + bc += op->no; + } + } + return (len == 0); +} + +int valid_cc(char *bc, int len, int cc) +{ + while (len >= 0) { + struct tcpdiag_bc_op *op = (struct tcpdiag_bc_op*)bc; + + if (cc > len) + return 0; + if (cc == len) + return 1; + if (op->yes < 4) + return 0; + len -= op->yes; + bc += op->yes; + } + return 0; +} + +int tcpdiag_bc_audit(char *bytecode, int bytecode_len) +{ + char *bc = bytecode; + int len = bytecode_len; + + while (len > 0) { + struct tcpdiag_bc_op *op = (struct tcpdiag_bc_op*)bc; + +//printk("BC: %d %d %d {%d} / %d\n", op->code, op->yes, op->no, op[1].no, len); + switch (op->code) { + case TCPDIAG_BC_AUTO: + case TCPDIAG_BC_S_COND: + case TCPDIAG_BC_D_COND: + case TCPDIAG_BC_S_GE: + case TCPDIAG_BC_S_LE: + case TCPDIAG_BC_D_GE: + case TCPDIAG_BC_D_LE: + if (op->yes < 4 || op->yes > len+4) + return -EINVAL; + case TCPDIAG_BC_JMP: + if (op->no < 4 || op->no > len+4) + return -EINVAL; + if (op->no < len && + !valid_cc(bytecode, bytecode_len, len-op->no)) + return -EINVAL; + break; + case TCPDIAG_BC_NOP: + if (op->yes < 4 || op->yes > len+4) + return -EINVAL; + break; + default: + return -EINVAL; + } + bc += op->yes; + len -= op->yes; + } + return len == 0 ? 0 : -EINVAL; +} + + +int tcpdiag_dump(struct sk_buff *skb, struct netlink_callback *cb) +{ + int i, num; + int s_i, s_num; + struct tcpdiagreq *r = NLMSG_DATA(cb->nlh); + struct rtattr *bc = NULL; + + if (cb->nlh->nlmsg_len > 4+NLMSG_SPACE(sizeof(struct tcpdiagreq))) + bc = (struct rtattr*)(r+1); + + s_i = cb->args[1]; + s_num = num = cb->args[2]; + + if (cb->args[0] == 0) { + if (!(r->tcpdiag_states&(TCPF_LISTEN|TCPF_SYN_RECV))) + goto skip_listen_ht; + tcp_listen_lock(); + for (i = s_i; i < TCP_LHTABLE_SIZE; i++) { + struct sock *sk = tcp_listening_hash[i]; + + if (i > s_i) + s_num = 0; + + for (sk = tcp_listening_hash[i], num = 0; + sk != NULL; + sk = sk->next, num++) { + if (num < s_num) + continue; + if (!(r->tcpdiag_states&TCPF_LISTEN) || + r->id.tcpdiag_dport) + continue; + if (r->id.tcpdiag_sport != sk->sport && r->id.tcpdiag_sport) + continue; + if (bc && !tcpdiag_bc_run(RTA_DATA(bc), RTA_PAYLOAD(bc), sk)) + continue; + if (tcpdiag_fill(skb, sk, r->tcpdiag_ext, + NETLINK_CB(cb->skb).pid, + cb->nlh->nlmsg_seq) <= 0) { + tcp_listen_unlock(); + goto done; + } + } + } + tcp_listen_unlock(); +skip_listen_ht: + cb->args[0] = 1; + s_i = num = s_num = 0; + } + + if (!(r->tcpdiag_states&~(TCPF_LISTEN|TCPF_SYN_RECV))) + return skb->len; + + for (i = s_i; i < tcp_ehash_size; i++) { + struct tcp_ehash_bucket *head = &tcp_ehash[i]; + struct sock *sk; + + if (i > s_i) + s_num = 0; + + read_lock_bh(&head->lock); + + for (sk = head->chain, num = 0; + sk != NULL; + sk = sk->next, num++) { + if (num < s_num) + continue; + if (!(r->tcpdiag_states&(1<<sk->state))) + continue; + if (r->id.tcpdiag_sport != sk->sport && r->id.tcpdiag_sport) + continue; + if (r->id.tcpdiag_dport != sk->dport && r->id.tcpdiag_dport) + continue; + if (bc && !tcpdiag_bc_run(RTA_DATA(bc), RTA_PAYLOAD(bc), sk)) + continue; + if (tcpdiag_fill(skb, sk, r->tcpdiag_ext, + NETLINK_CB(cb->skb).pid, + cb->nlh->nlmsg_seq) <= 0) { + read_unlock_bh(&head->lock); + goto done; + } + } + + if (r->tcpdiag_states&TCPF_TIME_WAIT) { + for (sk = tcp_ehash[i+tcp_ehash_size].chain; + sk != NULL; + sk = sk->next, num++) { + if (num < s_num) + continue; + if (!(r->tcpdiag_states&(1<<sk->zapped))) + continue; + if (r->id.tcpdiag_sport != sk->sport && r->id.tcpdiag_sport) + continue; + if (r->id.tcpdiag_dport != sk->dport && r->id.tcpdiag_dport) + continue; + if (bc && !tcpdiag_bc_run(RTA_DATA(bc), RTA_PAYLOAD(bc), sk)) + continue; + if (tcpdiag_fill(skb, sk, r->tcpdiag_ext, + NETLINK_CB(cb->skb).pid, + cb->nlh->nlmsg_seq) <= 0) { + read_unlock_bh(&head->lock); + goto done; + } + } + } + read_unlock_bh(&head->lock); + } + +done: + cb->args[1] = i; + cb->args[2] = num; + return skb->len; +} + +static int tcpdiag_dump_done(struct netlink_callback *cb) +{ + return 0; +} + + +static __inline__ int +tcpdiag_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh) +{ + if (!(nlh->nlmsg_flags&NLM_F_REQUEST)) + return 0; + + if (nlh->nlmsg_type != TCPDIAG_GETSOCK) + goto err_inval; + + if (NLMSG_LENGTH(sizeof(struct tcpdiagreq)) > skb->len) + goto err_inval; + + if (nlh->nlmsg_flags&NLM_F_DUMP) { + if (nlh->nlmsg_len > 4 + NLMSG_SPACE(sizeof(struct tcpdiagreq))) { + struct rtattr *rta = (struct rtattr*)(NLMSG_DATA(nlh) + sizeof(struct tcpdiagreq)); + if (rta->rta_type != TCPDIAG_REQ_BYTECODE || + rta->rta_len < 8 || + rta->rta_len > nlh->nlmsg_len - NLMSG_SPACE(sizeof(struct tcpdiagreq))) + goto err_inval; + if (tcpdiag_bc_audit(RTA_DATA(rta), RTA_PAYLOAD(rta))) + goto err_inval; + } + return netlink_dump_start(tcpnl, skb, nlh, + tcpdiag_dump, + tcpdiag_dump_done); + } else { + return tcpdiag_get_exact(skb, nlh); + } + +err_inval: + return -EINVAL; +} + + +extern __inline__ void tcpdiag_rcv_skb(struct sk_buff *skb) +{ + int err; + struct nlmsghdr * nlh; + + if (skb->len >= NLMSG_SPACE(0)) { + nlh = (struct nlmsghdr *)skb->data; + if (nlh->nlmsg_len < sizeof(*nlh) || skb->len < nlh->nlmsg_len) + return; + err = tcpdiag_rcv_msg(skb, nlh); + if (err) + netlink_ack(skb, nlh, err); + } +} + +static void tcpdiag_rcv(struct sock *sk, int len) +{ + struct sk_buff *skb; + + while ((skb = skb_dequeue(&sk->receive_queue)) != NULL) { + tcpdiag_rcv_skb(skb); + kfree_skb(skb); + } +} + +void __init tcpdiag_init(void) +{ + tcpnl = netlink_kernel_create(NETLINK_TCPDIAG, tcpdiag_rcv); + if (tcpnl == NULL) + panic("tcpdiag_init: Cannot create netlink socket."); +} diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/net/ipv4/tcp_input.c linux-2.5/net/ipv4/tcp_input.c --- linux-2.5.1/net/ipv4/tcp_input.c Mon Dec 10 19:19:42 2001 +++ linux-2.5/net/ipv4/tcp_input.c Thu Dec 13 16:32:37 2001 @@ -5,7 +5,7 @@ * * Implementation of the Transmission Control Protocol(TCP). * - * Version: $Id: tcp_input.c,v 1.238 2001/10/20 00:00:11 davem Exp $ + * Version: $Id: tcp_input.c,v 1.241 2001/11/14 02:48:51 davem Exp $ * * Authors: Ross Biro, <bir7@leland.Stanford.Edu> * Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG> diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/net/ipv4/tcp_ipv4.c linux-2.5/net/ipv4/tcp_ipv4.c --- linux-2.5.1/net/ipv4/tcp_ipv4.c Mon Nov 5 17:46:12 2001 +++ linux-2.5/net/ipv4/tcp_ipv4.c Thu Dec 13 16:32:37 2001 @@ -5,7 +5,7 @@ * * Implementation of the Transmission Control Protocol(TCP). * - * Version: $Id: tcp_ipv4.c,v 1.235 2001/10/26 14:51:13 davem Exp $ + * Version: $Id: tcp_ipv4.c,v 1.237 2001/12/05 08:54:10 davem Exp $ * * IPv4 specific functions * @@ -754,21 +754,19 @@ } static struct open_request *tcp_v4_search_req(struct tcp_opt *tp, - struct iphdr *iph, - struct tcphdr *th, - struct open_request ***prevp) + struct open_request ***prevp, + __u16 rport, + __u32 raddr, __u32 laddr) { struct tcp_listen_opt *lopt = tp->listen_opt; struct open_request *req, **prev; - __u16 rport = th->source; - __u32 raddr = iph->saddr; for (prev = &lopt->syn_table[tcp_v4_synq_hash(raddr, rport)]; (req = *prev) != NULL; prev = &req->dl_next) { if (req->rmt_port == rport && req->af.v4_req.rmt_addr == raddr && - req->af.v4_req.loc_addr == iph->daddr && + req->af.v4_req.loc_addr == laddr && TCP_INET_FAMILY(req->class->family)) { BUG_TRAP(req->sk == NULL); *prevp = prev; @@ -939,7 +937,9 @@ if (sk->lock.users != 0) goto out; - req = tcp_v4_search_req(tp, iph, th, &prev); + req = tcp_v4_search_req(tp, &prev, + th->dest, + iph->daddr, iph->saddr); if (!req) goto out; @@ -1473,11 +1473,14 @@ { struct open_request *req, **prev; struct tcphdr *th = skb->h.th; + struct iphdr *iph = skb->nh.iph; struct tcp_opt *tp = &(sk->tp_pinfo.af_tcp); struct sock *nsk; /* Find possible connection requests. */ - req = tcp_v4_search_req(tp, skb->nh.iph, th, &prev); + req = tcp_v4_search_req(tp, &prev, + th->source, + iph->saddr, iph->daddr); if (req) return tcp_check_req(sk, skb, req, prev); diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/net/ipv4/tcp_output.c linux-2.5/net/ipv4/tcp_output.c --- linux-2.5.1/net/ipv4/tcp_output.c Mon Nov 5 17:46:12 2001 +++ linux-2.5/net/ipv4/tcp_output.c Thu Dec 13 16:32:37 2001 @@ -5,7 +5,7 @@ * * Implementation of the Transmission Control Protocol(TCP). * - * Version: $Id: tcp_output.c,v 1.143 2001/10/26 14:51:13 davem Exp $ + * Version: $Id: tcp_output.c,v 1.144 2001/11/06 22:21:08 davem Exp $ * * Authors: Ross Biro, <bir7@leland.Stanford.Edu> * Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG> diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/net/ipv6/Config.in linux-2.5/net/ipv6/Config.in --- linux-2.5.1/net/ipv6/Config.in Wed May 16 17:31:27 2001 +++ linux-2.5/net/ipv6/Config.in Thu Dec 13 16:32:37 2001 @@ -1,11 +1,7 @@ # # IPv6 configuration # -if [ "$CONFIG_NETLINK" = "y" ]; then - if [ "$CONFIG_RTNETLINK" = "n" ]; then - bool ' IPv6: routing messages via old netlink' CONFIG_IPV6_NETLINK - fi -fi + #bool ' IPv6: flow policy support' CONFIG_RT6_POLICY #bool ' IPv6: firewall support' CONFIG_IPV6_FIREWALL diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/net/ipv6/addrconf.c linux-2.5/net/ipv6/addrconf.c --- linux-2.5.1/net/ipv6/addrconf.c Fri Sep 7 18:01:21 2001 +++ linux-2.5/net/ipv6/addrconf.c Thu Dec 13 16:32:37 2001 @@ -6,7 +6,7 @@ * Pedro Roque <roque@di.fc.ul.pt> * Alexey Kuznetsov <kuznet@ms2.inr.ac.ru> * - * $Id: addrconf.c,v 1.68 2001/09/01 00:31:50 davem Exp $ + * $Id: addrconf.c,v 1.69 2001/10/31 21:55:54 davem Exp $ * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -1644,8 +1644,6 @@ mod_timer(&addr_chk_timer, jiffies + ADDR_CHECK_FREQUENCY); } -#ifdef CONFIG_RTNETLINK - static int inet6_rtm_deladdr(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg) { @@ -1806,13 +1804,11 @@ { inet6_rtm_getroute, inet6_dump_fib, }, { NULL, NULL, }, }; -#endif static void ipv6_ifa_notify(int event, struct inet6_ifaddr *ifp) { -#ifdef CONFIG_RTNETLINK inet6_ifa_notify(event ? : RTM_NEWADDR, ifp); -#endif + switch (event) { case RTM_NEWADDR: ip6_rt_addr_add(&ifp->addr, ifp->idev->dev); @@ -2021,9 +2017,7 @@ addr_chk_timer.expires = jiffies + ADDR_CHECK_FREQUENCY; add_timer(&addr_chk_timer); -#ifdef CONFIG_RTNETLINK rtnetlink_links[PF_INET6] = inet6_rtnetlink_table; -#endif #ifdef CONFIG_SYSCTL addrconf_sysctl.sysctl_header = register_sysctl_table(addrconf_sysctl.addrconf_root_dir, 0); @@ -2039,9 +2033,7 @@ struct inet6_ifaddr *ifa; int i; -#ifdef CONFIG_RTNETLINK rtnetlink_links[PF_INET6] = NULL; -#endif #ifdef CONFIG_SYSCTL addrconf_sysctl_unregister(&ipv6_devconf_dflt); addrconf_sysctl_unregister(&ipv6_devconf); diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/net/ipv6/ip6_fib.c linux-2.5/net/ipv6/ip6_fib.c --- linux-2.5.1/net/ipv6/ip6_fib.c Thu Jun 14 21:16:58 2001 +++ linux-2.5/net/ipv6/ip6_fib.c Thu Dec 13 16:32:37 2001 @@ -5,7 +5,7 @@ * Authors: * Pedro Roque <roque@di.fc.ul.pt> * - * $Id: ip6_fib.c,v 1.24 2001/06/05 11:36:55 davem Exp $ + * $Id: ip6_fib.c,v 1.25 2001/10/31 21:55:55 davem Exp $ * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -466,9 +466,7 @@ *ins = rt; rt->rt6i_node = fn; atomic_inc(&rt->rt6i_ref); -#ifdef CONFIG_RTNETLINK inet6_rt_notify(RTM_NEWROUTE, rt); -#endif rt6_stats.fib_rt_entries++; if ((fn->fn_flags & RTN_RTINFO) == 0) { @@ -925,9 +923,7 @@ if (atomic_read(&rt->rt6i_ref) != 1) BUG(); } -#ifdef CONFIG_RTNETLINK inet6_rt_notify(RTM_DELROUTE, rt); -#endif rt6_release(rt); } diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/net/ipv6/ip6_fw.c linux-2.5/net/ipv6/ip6_fw.c --- linux-2.5.1/net/ipv6/ip6_fw.c Tue Aug 31 18:23:03 1999 +++ linux-2.5/net/ipv6/ip6_fw.c Thu Dec 13 16:32:37 2001 @@ -5,7 +5,7 @@ * Authors: * Pedro Roque <roque@di.fc.ul.pt> * - * $Id: ip6_fw.c,v 1.15 1999/08/31 07:04:03 davem Exp $ + * $Id: ip6_fw.c,v 1.16 2001/10/31 08:17:58 davem Exp $ * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -379,16 +379,12 @@ void __init ip6_fw_init(void) { -#ifdef CONFIG_NETLINK netlink_attach(NETLINK_IP6_FW, ip6_fw_msgrcv); -#endif } #ifdef MODULE void cleanup_module(void) { -#ifdef CONFIG_NETLINK netlink_detach(NETLINK_IP6_FW); -#endif } #endif diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/net/ipv6/ndisc.c linux-2.5/net/ipv6/ndisc.c --- linux-2.5.1/net/ipv6/ndisc.c Mon Sep 10 14:57:00 2001 +++ linux-2.5/net/ipv6/ndisc.c Thu Dec 13 16:32:37 2001 @@ -1207,81 +1207,6 @@ return 0; } -#ifdef CONFIG_PROC_FS -#ifndef CONFIG_RTNETLINK -static int ndisc_get_info(char *buffer, char **start, off_t offset, int length) -{ - int len=0; - off_t pos=0; - int size; - unsigned long now = jiffies; - int i; - - for (i = 0; i <= NEIGH_HASHMASK; i++) { - struct neighbour *neigh; - - read_lock_bh(&nd_tbl.lock); - for (neigh = nd_tbl.hash_buckets[i]; neigh; neigh = neigh->next) { - int j; - - size = 0; - for (j=0; j<16; j++) { - sprintf(buffer+len+size, "%02x", neigh->primary_key[j]); - size += 2; - } - - read_lock(&neigh->lock); - size += sprintf(buffer+len+size, - " %02x %02x %02x %02x %08lx %08lx %08x %04x %04x %04x %8s ", i, - 128, - neigh->type, - neigh->nud_state, - now - neigh->used, - now - neigh->confirmed, - neigh->parms->reachable_time, - neigh->parms->gc_staletime, - atomic_read(&neigh->refcnt) - 1, - neigh->flags | (!neigh->hh ? 0 : (neigh->hh->hh_output==dev_queue_xmit ? 4 : 2)), - neigh->dev->name); - - if ((neigh->nud_state&NUD_VALID) && neigh->dev->addr_len) { - for (j=0; j < neigh->dev->addr_len; j++) { - sprintf(buffer+len+size, "%02x", neigh->ha[j]); - size += 2; - } - } else { - size += sprintf(buffer+len+size, "000000000000"); - } - read_unlock(&neigh->lock); - size += sprintf(buffer+len+size, "\n"); - len += size; - pos += size; - - if (pos <= offset) - len=0; - if (pos >= offset+length) { - read_unlock_bh(&nd_tbl.lock); - goto done; - } - } - read_unlock_bh(&nd_tbl.lock); - } - -done: - - *start = buffer+len-(pos-offset); /* Start of wanted data */ - len = pos-offset; /* Start slop */ - if (len>length) - len = length; /* Ending slop */ - if (len<0) - len = 0; - return len; -} - -#endif -#endif /* CONFIG_PROC_FS */ - - int __init ndisc_init(struct net_proto_family *ops) { struct sock *sk; @@ -1319,11 +1244,6 @@ neigh_table_init(&nd_tbl); -#ifdef CONFIG_PROC_FS -#ifndef CONFIG_RTNETLINK - proc_net_create("ndisc", 0, ndisc_get_info); -#endif -#endif #ifdef CONFIG_SYSCTL neigh_sysctl_register(NULL, &nd_tbl.parms, NET_IPV6, NET_IPV6_NEIGH, "ipv6"); #endif @@ -1333,11 +1253,6 @@ void ndisc_cleanup(void) { -#ifdef CONFIG_PROC_FS -#ifndef CONFIG_RTNETLINK - proc_net_remove("ndisc"); -#endif -#endif neigh_table_clear(&nd_tbl); sock_release(ndisc_socket); ndisc_socket = NULL; /* For safety. */ diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/net/ipv6/netfilter/Config.in linux-2.5/net/ipv6/netfilter/Config.in --- linux-2.5.1/net/ipv6/netfilter/Config.in Tue Oct 30 23:08:12 2001 +++ linux-2.5/net/ipv6/netfilter/Config.in Thu Dec 13 16:32:37 2001 @@ -9,7 +9,7 @@ # dep_tristate ' FTP protocol support' CONFIG_IP6_NF_FTP $CONFIG_IP6_NF_CONNTRACK #fi -#if [ "$CONFIG_EXPERIMENTAL" = "y" -a "$CONFIG_NETLINK" = "y" ]; then +#if [ "$CONFIG_EXPERIMENTAL" = "y" ]; then # tristate 'Userspace queueing via NETLINK (EXPERIMENTAL)' CONFIG_IP6_NF_QUEUE #fi tristate 'IP6 tables support (required for filtering/masq/NAT)' CONFIG_IP6_NF_IPTABLES diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/net/ipv6/netfilter/ip6t_MARK.c linux-2.5/net/ipv6/netfilter/ip6t_MARK.c --- linux-2.5.1/net/ipv6/netfilter/ip6t_MARK.c Sun Sep 30 19:26:08 2001 +++ linux-2.5/net/ipv6/netfilter/ip6t_MARK.c Fri Dec 28 20:41:36 2001 @@ -51,7 +51,7 @@ static int __init init(void) { - printk(KERN_DEBUG "registreing ipv6 mark target\n"); + printk(KERN_DEBUG "registering ipv6 mark target\n"); if (ip6t_register_target(&ip6t_mark_reg)) return -EINVAL; diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/net/ipv6/route.c linux-2.5/net/ipv6/route.c --- linux-2.5.1/net/ipv6/route.c Thu Sep 20 21:12:56 2001 +++ linux-2.5/net/ipv6/route.c Thu Dec 13 16:32:37 2001 @@ -5,7 +5,7 @@ * Authors: * Pedro Roque <roque@di.fc.ul.pt> * - * $Id: route.c,v 1.55 2001/09/18 22:29:10 davem Exp $ + * $Id: route.c,v 1.56 2001/10/31 21:55:55 davem Exp $ * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -1407,8 +1407,6 @@ read_unlock_bh(&rt6_lock); } -#ifdef CONFIG_RTNETLINK - static int inet6_rtm_to_rtmsg(struct rtmsg *r, struct rtattr **rta, struct in6_rtmsg *rtmsg) { @@ -1740,8 +1738,6 @@ NETLINK_CB(skb).dst_groups = RTMGRP_IPV6_ROUTE; netlink_broadcast(rtnl, skb, 0, RTMGRP_IPV6_ROUTE, gfp_any()); } - -#endif /* * /proc diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/net/ipv6/tcp_ipv6.c linux-2.5/net/ipv6/tcp_ipv6.c --- linux-2.5.1/net/ipv6/tcp_ipv6.c Mon Nov 5 17:46:12 2001 +++ linux-2.5/net/ipv6/tcp_ipv6.c Thu Dec 27 15:15:00 2001 @@ -5,7 +5,7 @@ * Authors: * Pedro Roque <roque@di.fc.ul.pt> * - * $Id: tcp_ipv6.c,v 1.140 2001/10/15 12:34:50 davem Exp $ + * $Id: tcp_ipv6.c,v 1.142 2001/11/06 22:21:08 davem Exp $ * * Based on: * linux/net/ipv4/tcp.c @@ -1172,6 +1172,7 @@ tcp_parse_options(skb, &tp, 0); + tp.tstamp_ok = tp.saw_tstamp; tcp_openreq_init(req, &tp, skb); req->class = &or_ipv6; diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/net/irda/ircomm/ircomm_tty.c linux-2.5/net/irda/ircomm/ircomm_tty.c --- linux-2.5.1/net/irda/ircomm/ircomm_tty.c Sun Sep 30 19:26:09 2001 +++ linux-2.5/net/irda/ircomm/ircomm_tty.c Sun Dec 30 21:17:30 2001 @@ -38,7 +38,6 @@ #include <linux/tty.h> #include <linux/interrupt.h> -#include <asm/segment.h> #include <asm/uaccess.h> #include <net/irda/irda.h> diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/net/irda/ircomm/ircomm_tty_ioctl.c linux-2.5/net/irda/ircomm/ircomm_tty_ioctl.c --- linux-2.5.1/net/irda/ircomm/ircomm_tty_ioctl.c Wed Jul 4 18:50:38 2001 +++ linux-2.5/net/irda/ircomm/ircomm_tty_ioctl.c Sun Dec 30 21:17:30 2001 @@ -35,7 +35,6 @@ #include <linux/tty.h> #include <linux/serial.h> -#include <asm/segment.h> #include <asm/uaccess.h> #include <net/irda/irda.h> diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/net/irda/irda_device.c linux-2.5/net/irda/irda_device.c --- linux-2.5.1/net/irda/irda_device.c Mon Nov 12 19:29:57 2001 +++ linux-2.5/net/irda/irda_device.c Sun Dec 30 21:17:30 2001 @@ -44,7 +44,6 @@ #include <linux/spinlock.h> #include <asm/ioctls.h> -#include <asm/segment.h> #include <asm/uaccess.h> #include <asm/dma.h> #include <asm/io.h> diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/net/irda/irsyms.c linux-2.5/net/irda/irsyms.c --- linux-2.5.1/net/irda/irsyms.c Fri Nov 9 22:22:17 2001 +++ linux-2.5/net/irda/irsyms.c Sun Dec 30 21:17:30 2001 @@ -31,7 +31,6 @@ #include <linux/proc_fs.h> #include <linux/smp_lock.h> -#include <asm/segment.h> #include <net/irda/irda.h> #include <net/irda/irmod.h> diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/net/irda/irsysctl.c linux-2.5/net/irda/irsysctl.c --- linux-2.5.1/net/irda/irsysctl.c Fri Nov 30 21:25:10 2001 +++ linux-2.5/net/irda/irsysctl.c Sun Dec 30 21:17:30 2001 @@ -27,7 +27,6 @@ #include <linux/mm.h> #include <linux/ctype.h> #include <linux/sysctl.h> -#include <asm/segment.h> #include <net/irda/irda.h> #include <net/irda/irias_object.h> diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/net/netlink/netlink_dev.c linux-2.5/net/netlink/netlink_dev.c --- linux-2.5.1/net/netlink/netlink_dev.c Fri Nov 9 22:12:55 2001 +++ linux-2.5/net/netlink/netlink_dev.c Thu Dec 13 16:32:37 2001 @@ -195,11 +195,13 @@ /* Someone tell me the official names for the uppercase ones */ make_devfs_entries ("route", 0); make_devfs_entries ("skip", 1); - make_devfs_entries ("USERSOCK", 2); + make_devfs_entries ("usersock", 2); make_devfs_entries ("fwmonitor", 3); - make_devfs_entries ("ARPD", 8); - make_devfs_entries ("ROUTE6", 11); - make_devfs_entries ("IP6_FW", 13); + make_devfs_entries ("tcpdiag", 4); + make_devfs_entries ("arpd", 8); + make_devfs_entries ("route6", 11); + make_devfs_entries ("ip6_fw", 13); + make_devfs_entries ("dnrtmsg", 13); devfs_register_series (devfs_handle, "tap%u", 16, DEVFS_FL_DEFAULT, NETLINK_MAJOR, 16, S_IFCHR | S_IRUSR | S_IWUSR, diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/net/netsyms.c linux-2.5/net/netsyms.c --- linux-2.5.1/net/netsyms.c Mon Nov 5 17:46:12 2001 +++ linux-2.5/net/netsyms.c Thu Dec 13 16:32:37 2001 @@ -116,6 +116,7 @@ EXPORT_SYMBOL(sk_free); EXPORT_SYMBOL(sock_wake_async); EXPORT_SYMBOL(sock_alloc_send_skb); +EXPORT_SYMBOL(sock_alloc_send_pskb); EXPORT_SYMBOL(sock_init_data); EXPORT_SYMBOL(sock_no_release); EXPORT_SYMBOL(sock_no_bind); @@ -406,7 +407,6 @@ #endif -#ifdef CONFIG_NETLINK EXPORT_SYMBOL(netlink_set_err); EXPORT_SYMBOL(netlink_broadcast); EXPORT_SYMBOL(netlink_unicast); @@ -418,9 +418,7 @@ EXPORT_SYMBOL(netlink_detach); EXPORT_SYMBOL(netlink_post); #endif -#endif -#ifdef CONFIG_RTNETLINK EXPORT_SYMBOL(rtattr_parse); EXPORT_SYMBOL(rtnetlink_links); EXPORT_SYMBOL(__rta_fill); @@ -430,7 +428,6 @@ EXPORT_SYMBOL(neigh_delete); EXPORT_SYMBOL(neigh_add); EXPORT_SYMBOL(neigh_dump_info); -#endif EXPORT_SYMBOL(dev_set_allmulti); EXPORT_SYMBOL(dev_set_promiscuity); @@ -553,9 +550,7 @@ EXPORT_SYMBOL(tcf_police); EXPORT_SYMBOL(tcf_police_locate); EXPORT_SYMBOL(tcf_police_destroy); -#ifdef CONFIG_RTNETLINK EXPORT_SYMBOL(tcf_police_dump); -#endif #endif #endif #ifdef CONFIG_NET_CLS diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/net/packet/af_packet.c linux-2.5/net/packet/af_packet.c --- linux-2.5.1/net/packet/af_packet.c Tue Oct 30 23:08:12 2001 +++ linux-2.5/net/packet/af_packet.c Thu Dec 13 16:32:37 2001 @@ -5,7 +5,7 @@ * * PACKET - implements raw packet sockets. * - * Version: $Id: af_packet.c,v 1.57 2001/10/30 03:38:37 davem Exp $ + * Version: $Id: af_packet.c,v 1.58 2001/11/28 21:02:10 davem Exp $ * * Authors: Ross Biro, <bir7@leland.Stanford.Edu> * Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG> @@ -1902,3 +1902,4 @@ module_init(packet_init); module_exit(packet_exit); +MODULE_LICENSE("GPL"); diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/net/rose/af_rose.c linux-2.5/net/rose/af_rose.c --- linux-2.5.1/net/rose/af_rose.c Mon Sep 10 14:58:35 2001 +++ linux-2.5/net/rose/af_rose.c Sun Dec 30 21:17:30 2001 @@ -44,7 +44,6 @@ #include <linux/if_arp.h> #include <linux/skbuff.h> #include <net/sock.h> -#include <asm/segment.h> #include <asm/system.h> #include <asm/uaccess.h> #include <linux/fcntl.h> diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/net/rose/rose_dev.c linux-2.5/net/rose/rose_dev.c --- linux-2.5.1/net/rose/rose_dev.c Thu Jun 28 00:10:55 2001 +++ linux-2.5/net/rose/rose_dev.c Sun Dec 30 21:17:30 2001 @@ -32,7 +32,6 @@ #include <linux/if_ether.h> /* For the statistics structure. */ #include <asm/system.h> -#include <asm/segment.h> #include <asm/io.h> #include <linux/inet.h> diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/net/rose/rose_in.c linux-2.5/net/rose/rose_in.c --- linux-2.5.1/net/rose/rose_in.c Fri Dec 29 22:44:46 2000 +++ linux-2.5/net/rose/rose_in.c Sun Dec 30 21:17:30 2001 @@ -38,7 +38,6 @@ #include <linux/skbuff.h> #include <net/sock.h> #include <net/ip.h> /* For ip_rcv */ -#include <asm/segment.h> #include <asm/system.h> #include <linux/fcntl.h> #include <linux/mm.h> diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/net/rose/rose_link.c linux-2.5/net/rose/rose_link.c --- linux-2.5.1/net/rose/rose_link.c Fri Dec 29 22:44:46 2000 +++ linux-2.5/net/rose/rose_link.c Sun Dec 30 21:17:30 2001 @@ -29,7 +29,6 @@ #include <linux/netdevice.h> #include <linux/skbuff.h> #include <net/sock.h> -#include <asm/segment.h> #include <asm/system.h> #include <linux/fcntl.h> #include <linux/mm.h> diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/net/rose/rose_out.c linux-2.5/net/rose/rose_out.c --- linux-2.5.1/net/rose/rose_out.c Fri Dec 29 22:44:46 2000 +++ linux-2.5/net/rose/rose_out.c Sun Dec 30 21:17:30 2001 @@ -30,7 +30,6 @@ #include <linux/netdevice.h> #include <linux/skbuff.h> #include <net/sock.h> -#include <asm/segment.h> #include <asm/system.h> #include <linux/fcntl.h> #include <linux/mm.h> diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/net/rose/rose_route.c linux-2.5/net/rose/rose_route.c --- linux-2.5.1/net/rose/rose_route.c Sat Jun 30 02:38:26 2001 +++ linux-2.5/net/rose/rose_route.c Sun Dec 30 21:17:30 2001 @@ -36,7 +36,6 @@ #include <linux/if_arp.h> #include <linux/skbuff.h> #include <net/sock.h> -#include <asm/segment.h> #include <asm/system.h> #include <asm/uaccess.h> #include <linux/fcntl.h> diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/net/rose/rose_subr.c linux-2.5/net/rose/rose_subr.c --- linux-2.5.1/net/rose/rose_subr.c Sat Jun 30 02:38:26 2001 +++ linux-2.5/net/rose/rose_subr.c Sun Dec 30 21:17:30 2001 @@ -30,7 +30,6 @@ #include <linux/netdevice.h> #include <linux/skbuff.h> #include <net/sock.h> -#include <asm/segment.h> #include <asm/system.h> #include <linux/fcntl.h> #include <linux/mm.h> diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/net/rose/rose_timer.c linux-2.5/net/rose/rose_timer.c --- linux-2.5.1/net/rose/rose_timer.c Fri Dec 29 22:44:46 2000 +++ linux-2.5/net/rose/rose_timer.c Sun Dec 30 21:17:30 2001 @@ -30,7 +30,6 @@ #include <linux/netdevice.h> #include <linux/skbuff.h> #include <net/sock.h> -#include <asm/segment.h> #include <asm/system.h> #include <linux/fcntl.h> #include <linux/mm.h> diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/net/sched/Config.in linux-2.5/net/sched/Config.in --- linux-2.5.1/net/sched/Config.in Sat Jan 15 03:18:53 2000 +++ linux-2.5/net/sched/Config.in Thu Dec 13 16:32:37 2001 @@ -1,8 +1,6 @@ # # Traffic control configuration. # -define_bool CONFIG_NETLINK y -define_bool CONFIG_RTNETLINK y tristate ' CBQ packet scheduler' CONFIG_NET_SCH_CBQ tristate ' CSZ packet scheduler' CONFIG_NET_SCH_CSZ #tristate ' H-PFQ packet scheduler' CONFIG_NET_SCH_HPFQ diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/net/sched/cls_api.c linux-2.5/net/sched/cls_api.c --- linux-2.5.1/net/sched/cls_api.c Sat Jan 8 00:57:13 2000 +++ linux-2.5/net/sched/cls_api.c Thu Dec 13 16:32:37 2001 @@ -97,8 +97,6 @@ return 0; } -#ifdef CONFIG_RTNETLINK - static int tfilter_notify(struct sk_buff *oskb, struct nlmsghdr *n, struct tcf_proto *tp, unsigned long fh, int event); @@ -430,12 +428,9 @@ return skb->len; } -#endif - int __init tc_filter_init(void) { -#ifdef CONFIG_RTNETLINK struct rtnetlink_link *link_p = rtnetlink_links[PF_UNSPEC]; /* Setup rtnetlink links. It is made here to avoid @@ -448,7 +443,6 @@ link_p[RTM_GETTFILTER-RTM_BASE].doit = tc_ctl_tfilter; link_p[RTM_GETTFILTER-RTM_BASE].dumpit = tc_dump_tfilter; } -#endif #define INIT_TC_FILTER(name) { \ extern struct tcf_proto_ops cls_##name##_ops; \ register_tcf_proto_ops(&cls_##name##_ops); \ diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/net/sched/cls_fw.c linux-2.5/net/sched/cls_fw.c --- linux-2.5.1/net/sched/cls_fw.c Sun Sep 30 19:26:09 2001 +++ linux-2.5/net/sched/cls_fw.c Thu Dec 13 16:32:37 2001 @@ -299,7 +299,6 @@ } } -#ifdef CONFIG_RTNETLINK static int fw_dump(struct tcf_proto *tp, unsigned long fh, struct sk_buff *skb, struct tcmsg *t) { @@ -350,8 +349,6 @@ skb_trim(skb, b - skb->data); return -1; } -#endif - struct tcf_proto_ops cls_fw_ops = { NULL, @@ -365,11 +362,7 @@ fw_change, fw_delete, fw_walk, -#ifdef CONFIG_RTNETLINK fw_dump -#else - NULL -#endif }; #ifdef MODULE diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/net/sched/cls_route.c linux-2.5/net/sched/cls_route.c --- linux-2.5.1/net/sched/cls_route.c Sun Sep 30 19:26:09 2001 +++ linux-2.5/net/sched/cls_route.c Thu Dec 13 16:32:37 2001 @@ -550,7 +550,6 @@ } } -#ifdef CONFIG_RTNETLINK static int route4_dump(struct tcf_proto *tp, unsigned long fh, struct sk_buff *skb, struct tcmsg *t) { @@ -606,7 +605,6 @@ skb_trim(skb, b - skb->data); return -1; } -#endif struct tcf_proto_ops cls_route4_ops = { NULL, @@ -620,11 +618,7 @@ route4_change, route4_delete, route4_walk, -#ifdef CONFIG_RTNETLINK route4_dump -#else - NULL -#endif }; #ifdef MODULE diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/net/sched/cls_rsvp.h linux-2.5/net/sched/cls_rsvp.h --- linux-2.5.1/net/sched/cls_rsvp.h Mon Dec 11 21:30:43 2000 +++ linux-2.5/net/sched/cls_rsvp.h Thu Dec 13 16:32:37 2001 @@ -615,7 +615,6 @@ } } -#ifdef CONFIG_RTNETLINK static int rsvp_dump(struct tcf_proto *tp, unsigned long fh, struct sk_buff *skb, struct tcmsg *t) { @@ -672,7 +671,6 @@ skb_trim(skb, b - skb->data); return -1; } -#endif struct tcf_proto_ops RSVP_OPS = { NULL, @@ -686,11 +684,7 @@ rsvp_change, rsvp_delete, rsvp_walk, -#ifdef CONFIG_RTNETLINK rsvp_dump -#else - NULL -#endif }; #ifdef MODULE diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/net/sched/cls_tcindex.c linux-2.5/net/sched/cls_tcindex.c --- linux-2.5.1/net/sched/cls_tcindex.c Sun Sep 30 19:26:09 2001 +++ linux-2.5/net/sched/cls_tcindex.c Thu Dec 13 16:32:37 2001 @@ -421,8 +421,6 @@ } -#ifdef CONFIG_RTNETLINK - static int tcindex_dump(struct tcf_proto *tp, unsigned long fh, struct sk_buff *skb, struct tcmsg *t) { @@ -481,9 +479,6 @@ return -1; } -#endif - - struct tcf_proto_ops cls_tcindex_ops = { NULL, "tcindex", @@ -496,11 +491,7 @@ tcindex_change, tcindex_delete, tcindex_walk, -#ifdef CONFIG_RTNETLINK tcindex_dump -#else - NULL -#endif }; diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/net/sched/cls_u32.c linux-2.5/net/sched/cls_u32.c --- linux-2.5.1/net/sched/cls_u32.c Sun Sep 30 19:26:09 2001 +++ linux-2.5/net/sched/cls_u32.c Thu Dec 13 16:32:37 2001 @@ -635,7 +635,6 @@ } } -#ifdef CONFIG_RTNETLINK static int u32_dump(struct tcf_proto *tp, unsigned long fh, struct sk_buff *skb, struct tcmsg *t) { @@ -694,7 +693,6 @@ skb_trim(skb, b - skb->data); return -1; } -#endif struct tcf_proto_ops cls_u32_ops = { NULL, @@ -708,11 +706,7 @@ u32_change, u32_delete, u32_walk, -#ifdef CONFIG_RTNETLINK u32_dump -#else - NULL -#endif }; #ifdef MODULE diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/net/sched/police.c linux-2.5/net/sched/police.c --- linux-2.5.1/net/sched/police.c Mon Aug 23 17:01:02 1999 +++ linux-2.5/net/sched/police.c Thu Dec 13 16:32:37 2001 @@ -219,7 +219,6 @@ return p->action; } -#ifdef CONFIG_RTNETLINK int tcf_police_dump(struct sk_buff *skb, struct tcf_police *p) { unsigned char *b = skb->tail; @@ -250,5 +249,3 @@ skb_trim(skb, b - skb->data); return -1; } -#endif - diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/net/sched/sch_api.c linux-2.5/net/sched/sch_api.c --- linux-2.5.1/net/sched/sch_api.c Fri Nov 9 22:12:54 2001 +++ linux-2.5/net/sched/sch_api.c Thu Dec 13 16:32:37 2001 @@ -41,12 +41,10 @@ #include <asm/system.h> #include <asm/bitops.h> -#ifdef CONFIG_RTNETLINK static int qdisc_notify(struct sk_buff *oskb, struct nlmsghdr *n, u32 clid, struct Qdisc *old, struct Qdisc *new); static int tclass_notify(struct sk_buff *oskb, struct nlmsghdr *n, struct Qdisc *q, unsigned long cl, int event); -#endif /* @@ -379,8 +377,6 @@ return err; } -#ifdef CONFIG_RTNETLINK - /* Allocate and initialize new qdisc. @@ -1055,7 +1051,6 @@ dev_put(dev); return skb->len; } -#endif int psched_us_per_tick = 1; int psched_tick_per_us = 1; @@ -1169,9 +1164,7 @@ int __init pktsched_init(void) { -#ifdef CONFIG_RTNETLINK struct rtnetlink_link *link_p; -#endif #if PSCHED_CLOCK_SOURCE == PSCHED_CPU if (psched_calibrate_clock() < 0) @@ -1184,7 +1177,6 @@ #endif #endif -#ifdef CONFIG_RTNETLINK link_p = rtnetlink_links[PF_UNSPEC]; /* Setup rtnetlink links. It is made here to avoid @@ -1201,7 +1193,6 @@ link_p[RTM_GETTCLASS-RTM_BASE].doit = tc_ctl_tclass; link_p[RTM_GETTCLASS-RTM_BASE].dumpit = tc_dump_tclass; } -#endif #define INIT_QDISC(name) { \ extern struct Qdisc_ops name##_qdisc_ops; \ diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/net/sched/sch_atm.c linux-2.5/net/sched/sch_atm.c --- linux-2.5.1/net/sched/sch_atm.c Fri Feb 9 19:34:13 2001 +++ linux-2.5/net/sched/sch_atm.c Thu Dec 13 16:32:37 2001 @@ -619,8 +619,6 @@ } -#ifdef CONFIG_RTNETLINK - static int atm_tc_dump_class(struct Qdisc *sch, unsigned long cl, struct sk_buff *skb, struct tcmsg *tcm) { @@ -668,9 +666,6 @@ return 0; } -#endif - - static struct Qdisc_class_ops atm_class_ops = { atm_tc_graft, /* graft */ @@ -685,9 +680,7 @@ atm_tc_bind_filter, /* bind_tcf */ atm_tc_put, /* unbind_tcf */ -#ifdef CONFIG_RTNETLINK atm_tc_dump_class, /* dump */ -#endif }; struct Qdisc_ops atm_qdisc_ops = @@ -707,9 +700,7 @@ atm_tc_destroy, /* destroy */ NULL, /* change */ -#ifdef CONFIG_RTNETLINK atm_tc_dump /* dump */ -#endif }; diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/net/sched/sch_cbq.c linux-2.5/net/sched/sch_cbq.c --- linux-2.5.1/net/sched/sch_cbq.c Sun Sep 30 19:26:09 2001 +++ linux-2.5/net/sched/sch_cbq.c Thu Dec 13 16:32:37 2001 @@ -1457,8 +1457,6 @@ return 0; } -#ifdef CONFIG_RTNETLINK - static __inline__ int cbq_dump_rate(struct sk_buff *skb, struct cbq_class *cl) { unsigned char *b = skb->tail; @@ -1658,8 +1656,6 @@ return -1; } -#endif - static int cbq_graft(struct Qdisc *sch, unsigned long arg, struct Qdisc *new, struct Qdisc **old) { @@ -2082,9 +2078,7 @@ cbq_bind_filter, cbq_unbind_filter, -#ifdef CONFIG_RTNETLINK cbq_dump_class, -#endif }; struct Qdisc_ops cbq_qdisc_ops = @@ -2104,9 +2098,7 @@ cbq_destroy, NULL /* cbq_change */, -#ifdef CONFIG_RTNETLINK cbq_dump, -#endif }; #ifdef MODULE diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/net/sched/sch_csz.c linux-2.5/net/sched/sch_csz.c --- linux-2.5.1/net/sched/sch_csz.c Sun Sep 30 19:26:09 2001 +++ linux-2.5/net/sched/sch_csz.c Thu Dec 13 16:32:37 2001 @@ -795,7 +795,6 @@ return 0; } -#ifdef CONFIG_RTNETLINK static int csz_dump(struct Qdisc *sch, struct sk_buff *skb) { struct csz_sched_data *q = (struct csz_sched_data *)sch->data; @@ -817,8 +816,6 @@ skb_trim(skb, b - skb->data); return -1; } -#endif - static int csz_graft(struct Qdisc *sch, unsigned long cl, struct Qdisc *new, struct Qdisc **old) @@ -932,7 +929,6 @@ return 0; } -#ifdef CONFIG_RTNETLINK static int csz_dump_class(struct Qdisc *sch, unsigned long cl, struct sk_buff *skb, struct tcmsg *tcm) { struct csz_sched_data *q = (struct csz_sched_data *)sch->data; @@ -978,7 +974,6 @@ skb_trim(skb, b - skb->data); return -1; } -#endif static void csz_walk(struct Qdisc *sch, struct qdisc_walker *arg) { @@ -1030,9 +1025,7 @@ csz_bind, csz_put, -#ifdef CONFIG_RTNETLINK csz_dump_class, -#endif }; struct Qdisc_ops csz_qdisc_ops = @@ -1052,9 +1045,7 @@ csz_destroy, NULL /* csz_change */, -#ifdef CONFIG_RTNETLINK csz_dump, -#endif }; diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/net/sched/sch_dsmark.c linux-2.5/net/sched/sch_dsmark.c --- linux-2.5.1/net/sched/sch_dsmark.c Sun Sep 30 19:26:09 2001 +++ linux-2.5/net/sched/sch_dsmark.c Thu Dec 13 16:32:37 2001 @@ -385,8 +385,6 @@ } -#ifdef CONFIG_RTNETLINK - static int dsmark_dump_class(struct Qdisc *sch, unsigned long cl, struct sk_buff *skb, struct tcmsg *tcm) { @@ -434,9 +432,6 @@ return -1; } -#endif - - static struct Qdisc_class_ops dsmark_class_ops = { dsmark_graft, /* graft */ @@ -451,9 +446,7 @@ dsmark_bind_filter, /* bind_tcf */ dsmark_put, /* unbind_tcf */ -#ifdef CONFIG_RTNETLINK dsmark_dump_class, /* dump */ -#endif }; struct Qdisc_ops dsmark_qdisc_ops = @@ -473,9 +466,7 @@ dsmark_destroy, /* destroy */ NULL, /* change */ -#ifdef CONFIG_RTNETLINK dsmark_dump /* dump */ -#endif }; #ifdef MODULE diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/net/sched/sch_fifo.c linux-2.5/net/sched/sch_fifo.c --- linux-2.5.1/net/sched/sch_fifo.c Mon Aug 23 17:01:02 1999 +++ linux-2.5/net/sched/sch_fifo.c Thu Dec 13 16:32:37 2001 @@ -152,7 +152,6 @@ return 0; } -#ifdef CONFIG_RTNETLINK static int fifo_dump(struct Qdisc *sch, struct sk_buff *skb) { struct fifo_sched_data *q = (void*)sch->data; @@ -168,7 +167,6 @@ skb_trim(skb, b - skb->data); return -1; } -#endif struct Qdisc_ops pfifo_qdisc_ops = { @@ -187,9 +185,7 @@ NULL, fifo_init, -#ifdef CONFIG_RTNETLINK fifo_dump, -#endif }; struct Qdisc_ops bfifo_qdisc_ops = @@ -208,7 +204,5 @@ fifo_reset, NULL, fifo_init, -#ifdef CONFIG_RTNETLINK fifo_dump, -#endif }; diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/net/sched/sch_gred.c linux-2.5/net/sched/sch_gred.c --- linux-2.5.1/net/sched/sch_gred.c Sun Sep 30 19:26:09 2001 +++ linux-2.5/net/sched/sch_gred.c Thu Dec 13 16:32:37 2001 @@ -494,7 +494,6 @@ return -EINVAL; } -#ifdef CONFIG_RTNETLINK static int gred_dump(struct Qdisc *sch, struct sk_buff *skb) { unsigned long qave; @@ -587,7 +586,6 @@ skb_trim(skb, b - skb->data); return -1; } -#endif static void gred_destroy(struct Qdisc *sch) { @@ -615,9 +613,7 @@ gred_reset, gred_destroy, gred_change, /* change */ -#ifdef CONFIG_RTNETLINK gred_dump, -#endif }; diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/net/sched/sch_ingress.c linux-2.5/net/sched/sch_ingress.c --- linux-2.5.1/net/sched/sch_ingress.c Sun Sep 30 19:26:09 2001 +++ linux-2.5/net/sched/sch_ingress.c Thu Dec 13 16:32:37 2001 @@ -304,9 +304,6 @@ } -#ifdef CONFIG_RTNETLINK - - static int ingress_dump(struct Qdisc *sch, struct sk_buff *skb) { unsigned char *b = skb->tail; @@ -322,9 +319,6 @@ return -1; } -#endif - - static struct Qdisc_class_ops ingress_class_ops = { ingress_graft, /* graft */ @@ -339,9 +333,7 @@ ingress_bind_filter, /* bind_tcf */ ingress_put, /* unbind_tcf */ -#ifdef CONFIG_RTNETLINK NULL, /* dump */ -#endif }; struct Qdisc_ops ingress_qdisc_ops = @@ -361,9 +353,7 @@ ingress_destroy, /* destroy */ NULL, /* change */ -#ifdef CONFIG_RTNETLINK ingress_dump, /* dump */ -#endif }; #ifdef MODULE diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/net/sched/sch_prio.c linux-2.5/net/sched/sch_prio.c --- linux-2.5.1/net/sched/sch_prio.c Sun Sep 30 19:26:09 2001 +++ linux-2.5/net/sched/sch_prio.c Thu Dec 13 16:32:37 2001 @@ -231,7 +231,6 @@ return 0; } -#ifdef CONFIG_RTNETLINK static int prio_dump(struct Qdisc *sch, struct sk_buff *skb) { struct prio_sched_data *q = (struct prio_sched_data *)sch->data; @@ -247,7 +246,6 @@ skb_trim(skb, b - skb->data); return -1; } -#endif static int prio_graft(struct Qdisc *sch, unsigned long arg, struct Qdisc *new, struct Qdisc **old) @@ -322,7 +320,6 @@ } -#ifdef CONFIG_RTNETLINK static int prio_dump_class(struct Qdisc *sch, unsigned long cl, struct sk_buff *skb, struct tcmsg *tcm) { @@ -334,7 +331,6 @@ tcm->tcm_info = q->queues[cl-1]->handle; return 0; } -#endif static void prio_walk(struct Qdisc *sch, struct qdisc_walker *arg) { @@ -381,9 +377,7 @@ prio_bind, prio_put, -#ifdef CONFIG_RTNETLINK prio_dump_class, -#endif }; struct Qdisc_ops prio_qdisc_ops = @@ -403,9 +397,7 @@ prio_destroy, prio_tune, -#ifdef CONFIG_RTNETLINK prio_dump, -#endif }; #ifdef MODULE diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/net/sched/sch_red.c linux-2.5/net/sched/sch_red.c --- linux-2.5.1/net/sched/sch_red.c Sun Sep 30 19:26:09 2001 +++ linux-2.5/net/sched/sch_red.c Thu Dec 13 16:32:37 2001 @@ -418,7 +418,6 @@ } -#ifdef CONFIG_RTNETLINK int red_copy_xstats(struct sk_buff *skb, struct tc_red_xstats *st) { RTA_PUT(skb, TCA_XSTATS, sizeof(*st), st); @@ -456,7 +455,6 @@ skb_trim(skb, b - skb->data); return -1; } -#endif static void red_destroy(struct Qdisc *sch) { @@ -480,9 +478,7 @@ red_destroy, red_change, -#ifdef CONFIG_RTNETLINK red_dump, -#endif }; diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/net/sched/sch_sfq.c linux-2.5/net/sched/sch_sfq.c --- linux-2.5.1/net/sched/sch_sfq.c Sun Sep 30 19:26:09 2001 +++ linux-2.5/net/sched/sch_sfq.c Thu Dec 13 16:32:37 2001 @@ -439,7 +439,6 @@ MOD_DEC_USE_COUNT; } -#ifdef CONFIG_RTNETLINK static int sfq_dump(struct Qdisc *sch, struct sk_buff *skb) { struct sfq_sched_data *q = (struct sfq_sched_data *)sch->data; @@ -461,7 +460,6 @@ skb_trim(skb, b - skb->data); return -1; } -#endif struct Qdisc_ops sfq_qdisc_ops = { @@ -480,9 +478,7 @@ sfq_destroy, NULL, /* sfq_change */ -#ifdef CONFIG_RTNETLINK sfq_dump, -#endif }; #ifdef MODULE diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/net/sched/sch_tbf.c linux-2.5/net/sched/sch_tbf.c --- linux-2.5.1/net/sched/sch_tbf.c Sun Sep 30 19:26:09 2001 +++ linux-2.5/net/sched/sch_tbf.c Thu Dec 13 16:32:37 2001 @@ -363,7 +363,6 @@ MOD_DEC_USE_COUNT; } -#ifdef CONFIG_RTNETLINK static int tbf_dump(struct Qdisc *sch, struct sk_buff *skb) { struct tbf_sched_data *q = (struct tbf_sched_data *)sch->data; @@ -391,7 +390,6 @@ skb_trim(skb, b - skb->data); return -1; } -#endif struct Qdisc_ops tbf_qdisc_ops = { @@ -410,9 +408,7 @@ tbf_destroy, tbf_change, -#ifdef CONFIG_RTNETLINK tbf_dump, -#endif }; diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/net/socket.c linux-2.5/net/socket.c --- linux-2.5.1/net/socket.c Wed Oct 17 21:38:28 2001 +++ linux-2.5/net/socket.c Thu Dec 13 16:32:37 2001 @@ -67,6 +67,8 @@ #include <linux/netdevice.h> #include <linux/proc_fs.h> #include <linux/wanrouter.h> +#include <linux/netlink.h> +#include <linux/rtnetlink.h> #include <linux/init.h> #include <linux/poll.h> #include <linux/cache.h> @@ -79,11 +81,7 @@ #include <asm/uaccess.h> -#include <linux/inet.h> -#include <net/ip.h> #include <net/sock.h> -#include <net/tcp.h> -#include <net/udp.h> #include <net/scm.h> #include <linux/netfilter.h> @@ -1724,7 +1722,7 @@ * The netlink device handler may be needed early. */ -#ifdef CONFIG_RTNETLINK +#ifdef CONFIG_NET rtnetlink_init(); #endif #ifdef CONFIG_NETLINK_DEV diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/net/sunrpc/auth_null.c linux-2.5/net/sunrpc/auth_null.c --- linux-2.5.1/net/sunrpc/auth_null.c Thu Aug 16 16:39:37 2001 +++ linux-2.5/net/sunrpc/auth_null.c Sun Dec 30 20:01:41 2001 @@ -7,11 +7,11 @@ */ #include <linux/types.h> -#include <linux/slab.h> #include <linux/socket.h> #include <linux/in.h> #include <linux/utsname.h> #include <linux/sunrpc/clnt.h> +#include <linux/sched.h> #ifdef RPC_DEBUG # define RPCDBG_FACILITY RPCDBG_AUTH diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/net/sunrpc/auth_unix.c linux-2.5/net/sunrpc/auth_unix.c --- linux-2.5.1/net/sunrpc/auth_unix.c Thu Aug 16 16:39:37 2001 +++ linux-2.5/net/sunrpc/auth_unix.c Sun Dec 30 20:01:41 2001 @@ -7,7 +7,7 @@ */ #include <linux/types.h> -#include <linux/slab.h> +#include <linux/sched.h> #include <linux/socket.h> #include <linux/in.h> #include <linux/sunrpc/clnt.h> diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/net/sunrpc/xprt.c linux-2.5/net/sunrpc/xprt.c --- linux-2.5.1/net/sunrpc/xprt.c Mon Oct 8 19:36:07 2001 +++ linux-2.5/net/sunrpc/xprt.c Thu Dec 13 16:32:37 2001 @@ -630,10 +630,14 @@ int to_move = cur_len; if (to_move > copied) to_move = copied; - if (need_csum) - csum = skb_copy_and_csum_bits(skb, offset, cur_ptr, - to_move, csum); - else + if (need_csum) { + unsigned int csum2; + + csum2 = skb_copy_and_csum_bits(skb, offset, + cur_ptr, + to_move, 0); + csum = csum_block_add(csum, csum2, offset); + } else skb_copy_bits(skb, offset, cur_ptr, to_move); offset += to_move; copied -= to_move; @@ -647,8 +651,12 @@ } } if (need_csum) { - if (slack > 0) - csum = skb_checksum(skb, offset, slack, csum); + if (slack > 0) { + unsigned int csum2; + + csum2 = skb_checksum(skb, offset, slack, 0); + csum = csum_block_add(csum, csum2, offset); + } if ((unsigned short)csum_fold(csum)) return -1; } diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/net/unix/af_unix.c linux-2.5/net/unix/af_unix.c --- linux-2.5.1/net/unix/af_unix.c Mon Nov 5 16:32:32 2001 +++ linux-2.5/net/unix/af_unix.c Thu Dec 13 16:32:37 2001 @@ -8,7 +8,7 @@ * as published by the Free Software Foundation; either version * 2 of the License, or (at your option) any later version. * - * Version: $Id: af_unix.c,v 1.123 2001/09/19 04:50:32 davem Exp $ + * Version: $Id: af_unix.c,v 1.126 2001/11/13 05:06:28 davem Exp $ * * Fixes: * Linus Torvalds : Assorted bug cures. diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/net/wanrouter/wanmain.c linux-2.5/net/wanrouter/wanmain.c --- linux-2.5.1/net/wanrouter/wanmain.c Wed Aug 15 08:22:18 2001 +++ linux-2.5/net/wanrouter/wanmain.c Sun Dec 30 21:16:28 2001 @@ -73,6 +73,7 @@ #include <asm/uaccess.h> /* copy_to/from_user */ #include <linux/init.h> /* __initfunc et al. */ #include <../drivers/net/syncppp.h> +#endif #else #include <asm/segment.h> /* kernel <-> user copy */ diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/net/x25/af_x25.c linux-2.5/net/x25/af_x25.c --- linux-2.5.1/net/x25/af_x25.c Mon Sep 10 14:58:35 2001 +++ linux-2.5/net/x25/af_x25.c Sun Dec 30 21:17:30 2001 @@ -46,7 +46,6 @@ #include <linux/if_arp.h> #include <linux/skbuff.h> #include <net/sock.h> -#include <asm/segment.h> #include <asm/system.h> #include <asm/uaccess.h> #include <linux/fcntl.h> diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/net/x25/x25_dev.c linux-2.5/net/x25/x25_dev.c --- linux-2.5.1/net/x25/x25_dev.c Mon Jan 22 21:32:10 2001 +++ linux-2.5/net/x25/x25_dev.c Sun Dec 30 21:17:30 2001 @@ -33,7 +33,6 @@ #include <linux/netdevice.h> #include <linux/skbuff.h> #include <net/sock.h> -#include <asm/segment.h> #include <asm/system.h> #include <asm/uaccess.h> #include <linux/fcntl.h> diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/net/x25/x25_facilities.c linux-2.5/net/x25/x25_facilities.c --- linux-2.5.1/net/x25/x25_facilities.c Wed Jan 24 23:28:36 2001 +++ linux-2.5/net/x25/x25_facilities.c Sun Dec 30 21:17:30 2001 @@ -32,7 +32,6 @@ #include <linux/netdevice.h> #include <linux/skbuff.h> #include <net/sock.h> -#include <asm/segment.h> #include <asm/system.h> #include <linux/fcntl.h> #include <linux/mm.h> diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/net/x25/x25_in.c linux-2.5/net/x25/x25_in.c --- linux-2.5.1/net/x25/x25_in.c Wed Jan 24 23:28:36 2001 +++ linux-2.5/net/x25/x25_in.c Sun Dec 30 21:17:30 2001 @@ -37,7 +37,6 @@ #include <linux/skbuff.h> #include <net/sock.h> #include <net/ip.h> /* For ip_rcv */ -#include <asm/segment.h> #include <asm/system.h> #include <linux/fcntl.h> #include <linux/mm.h> diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/net/x25/x25_link.c linux-2.5/net/x25/x25_link.c --- linux-2.5.1/net/x25/x25_link.c Sat Jun 30 02:38:26 2001 +++ linux-2.5/net/x25/x25_link.c Sun Dec 30 21:17:30 2001 @@ -34,7 +34,6 @@ #include <linux/netdevice.h> #include <linux/skbuff.h> #include <net/sock.h> -#include <asm/segment.h> #include <asm/system.h> #include <asm/uaccess.h> #include <linux/fcntl.h> diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/net/x25/x25_out.c linux-2.5/net/x25/x25_out.c --- linux-2.5.1/net/x25/x25_out.c Thu Apr 12 19:11:39 2001 +++ linux-2.5/net/x25/x25_out.c Sun Dec 30 21:17:30 2001 @@ -35,7 +35,6 @@ #include <linux/netdevice.h> #include <linux/skbuff.h> #include <net/sock.h> -#include <asm/segment.h> #include <asm/system.h> #include <linux/fcntl.h> #include <linux/mm.h> diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/net/x25/x25_route.c linux-2.5/net/x25/x25_route.c --- linux-2.5.1/net/x25/x25_route.c Mon Jan 22 21:32:10 2001 +++ linux-2.5/net/x25/x25_route.c Sun Dec 30 21:17:30 2001 @@ -33,7 +33,6 @@ #include <linux/if_arp.h> #include <linux/skbuff.h> #include <net/sock.h> -#include <asm/segment.h> #include <asm/system.h> #include <asm/uaccess.h> #include <linux/fcntl.h> diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/net/x25/x25_subr.c linux-2.5/net/x25/x25_subr.c --- linux-2.5.1/net/x25/x25_subr.c Sat Jun 30 02:38:26 2001 +++ linux-2.5/net/x25/x25_subr.c Sun Dec 30 21:17:30 2001 @@ -34,7 +34,6 @@ #include <linux/netdevice.h> #include <linux/skbuff.h> #include <net/sock.h> -#include <asm/segment.h> #include <asm/system.h> #include <linux/fcntl.h> #include <linux/mm.h> diff -urN --exclude-from=/home/davej/.exclude linux-2.5.1/net/x25/x25_timer.c linux-2.5/net/x25/x25_timer.c --- linux-2.5.1/net/x25/x25_timer.c Wed Jan 24 23:28:36 2001 +++ linux-2.5/net/x25/x25_timer.c Sun Dec 30 21:17:30 2001 @@ -32,7 +32,6 @@ #include <linux/netdevice.h> #include <linux/skbuff.h> #include <net/sock.h> -#include <asm/segment.h> #include <asm/system.h> #include <linux/fcntl.h> #include <linux/mm.h>