···32793279S: Spain3280328032813281N: Linus Torvalds32823282-E: torvalds@osdl.org32823282+E: torvalds@linux-foundation.org32833283D: Original kernel hacker32843284S: 12725 SW Millikan Way, Suite 40032853285S: Beaverton, Oregon 97005
+4
Documentation/SubmitChecklist
···72727373 If the new code is substantial, addition of subsystem-specific fault7474 injection might be appropriate.7575+7676+22: Newly-added code has been compiled with `gcc -W'. This will generate7777+ lots of noise, but is good for finding bugs like "warning: comparison7878+ between signed and unsigned".
+3-3
Documentation/SubmittingPatches
···134134135135136136Linus Torvalds is the final arbiter of all changes accepted into the137137-Linux kernel. His e-mail address is <torvalds@osdl.org>. He gets138138-a lot of e-mail, so typically you should do your best to -avoid- sending139139-him e-mail.137137+Linux kernel. His e-mail address is <torvalds@linux-foundation.org>. 138138+He gets a lot of e-mail, so typically you should do your best to -avoid-139139+sending him e-mail. 140140141141Patches which are bug fixes, are "obvious" changes, or similarly142142require little discussion should be sent or CC'd to Linus. Patches
+7
Documentation/feature-removal-schedule.txt
···318318Who: Len Brown <len.brown@intel.com>319319320320---------------------------321321+322322+What: JFFS (version 1)323323+When: 2.6.21324324+Why: Unmaintained for years, superceded by JFFS2 for years.325325+Who: Jeff Garzik <jeff@garzik.org>326326+327327+---------------------------
+38-11
Documentation/kdump/kdump.txt
···1717memory image to a dump file on the local disk, or across the network to1818a remote system.19192020-Kdump and kexec are currently supported on the x86, x86_64, ppc64 and IA642020+Kdump and kexec are currently supported on the x86, x86_64, ppc64 and ia642121architectures.22222323When the system kernel boots, it reserves a small section of memory for···616162622) Download the kexec-tools user-space package from the following URL:63636464-http://www.kernel.org/pub/linux/kernel/people/horms/kexec-tools/kexec-tools-testing-20061214.tar.gz6464+http://www.kernel.org/pub/linux/kernel/people/horms/kexec-tools/kexec-tools-testing.tar.gz6565+6666+This is a symlink to the latest version, which at the time of writing is6767+20061214, the only release of kexec-tools-testing so far. As other versions6868+are made released, the older onese will remain available at6969+http://www.kernel.org/pub/linux/kernel/people/horms/kexec-tools/65706671Note: Latest kexec-tools-testing git tree is available at6772···767177723) Unpack the tarball with the tar command, as follows:78737979- tar xvpzf kexec-tools-testing-20061214.tar.gz7474+ tar xvpzf kexec-tools-testing.tar.gz80758181-4) Change to the kexec-tools-1.101 directory, as follows:7676+4) Change to the kexec-tools directory, as follows:82778383- cd kexec-tools-testing-200612147878+ cd kexec-tools-testing-VERSION847985805) Configure the package, as follows:8681···229224230225Dump-capture kernel config options (Arch Dependent, ia64)231226----------------------------------------------------------232232-(To be filled)227227+228228+- No specific options are required to create a dump-capture kernel229229+ for ia64, other than those specified in the arch idependent section230230+ above. This means that it is possible to use the system kernel231231+ as a dump-capture kernel if desired.232232+233233+ The crashkernel region can be automatically placed by the system234234+ kernel at run time. This is done by specifying the base address as 0,235235+ or omitting it all together.236236+237237+ crashkernel=256M@0238238+ or239239+ crashkernel=256M240240+241241+ If the start address is specified, note that the start address of the242242+ kernel will be aligned to 64Mb, so if the start address is not then243243+ any space below the alignment point will be wasted.233244234245235246Boot into System Kernel···263242 On x86 and x86_64, use "crashkernel=64M@16M".264243265244 On ppc64, use "crashkernel=128M@32M".245245+246246+ On ia64, 256M@256M is a generous value that typically works.247247+ The region may be automatically placed on ia64, see the248248+ dump-capture kernel config option notes above.266249267250Load the Dump-capture Kernel268251============================···286261For ppc64:287262 - Use vmlinux288263For ia64:289289- (To be filled)264264+ - Use vmlinux or vmlinuz.gz265265+290266291267If you are using a uncompressed vmlinux image then use following command292268to load dump-capture kernel.···303277 --initrd=<initrd-for-dump-capture-kernel> \304278 --append="root=<root-dev> <arch-specific-options>"305279280280+Please note, that --args-linux does not need to be specified for ia64.281281+It is planned to make this a no-op on that architecture, but for now282282+it should be omitted283283+306284Following are the arch specific command line options to be used while307285loading dump-capture kernel.308286309309-For i386 and x86_64:287287+For i386, x86_64 and ia64:310288 "init 1 irqpoll maxcpus=1"311289312290For ppc64:313291 "init 1 maxcpus=1 noirqdistrib"314314-315315-For IA64316316- (To be filled)317292318293319294Notes on loading the dump-capture kernel:
+549-153
Documentation/pci.txt
···11- How To Write Linux PCI Drivers2133- by Martin Mares <mj@ucw.cz> on 07-Feb-200022+ How To Write Linux PCI Drivers33+44+ by Martin Mares <mj@ucw.cz> on 07-Feb-200055+ updated by Grant Grundler <grundler@parisc-linux.org> on 23-Dec-20064657~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~66-The world of PCI is vast and it's full of (mostly unpleasant) surprises.77-Different PCI devices have different requirements and different bugs --88-because of this, the PCI support layer in Linux kernel is not as trivial99-as one would wish. This short pamphlet tries to help all potential driver1010-authors find their way through the deep forests of PCI handling.88+The world of PCI is vast and full of (mostly unpleasant) surprises.99+Since each CPU architecture implements different chip-sets and PCI devices1010+have different requirements (erm, "features"), the result is the PCI support1111+in the Linux kernel is not as trivial as one would wish. This short paper1212+tries to introduce all potential driver authors to Linux APIs for1313+PCI device drivers.1414+1515+A more complete resource is the third edition of "Linux Device Drivers"1616+by Jonathan Corbet, Alessandro Rubini, and Greg Kroah-Hartman.1717+LDD3 is available for free (under Creative Commons License) from:1818+1919+ http://lwn.net/Kernel/LDD3/2020+2121+However, keep in mind that all documents are subject to "bit rot".2222+Refer to the source code if things are not working as described here.2323+2424+Please send questions/comments/patches about Linux PCI API to the2525+"Linux PCI" <linux-pci@atrey.karlin.mff.cuni.cz> mailing list.2626+1127122813290. Structure of PCI drivers1430~~~~~~~~~~~~~~~~~~~~~~~~~~~1515-There exist two kinds of PCI drivers: new-style ones (which leave most of1616-probing for devices to the PCI layer and support online insertion and removal1717-of devices [thus supporting PCI, hot-pluggable PCI and CardBus in a single1818-driver]) and old-style ones which just do all the probing themselves. Unless1919-you have a very good reason to do so, please don't use the old way of probing2020-in any new code. After the driver finds the devices it wishes to operate2121-on (either the old or the new way), it needs to perform the following steps:3131+PCI drivers "discover" PCI devices in a system via pci_register_driver().3232+Actually, it's the other way around. When the PCI generic code discovers3333+a new device, the driver with a matching "description" will be notified.3434+Details on this below.3535+3636+pci_register_driver() leaves most of the probing for devices to3737+the PCI layer and supports online insertion/removal of devices [thus3838+supporting hot-pluggable PCI, CardBus, and Express-Card in a single driver].3939+pci_register_driver() call requires passing in a table of function4040+pointers and thus dictates the high level structure of a driver.4141+4242+Once the driver knows about a PCI device and takes ownership, the4343+driver generally needs to perform the following initialization:22442345 Enable the device2424- Access device configuration space2525- Discover resources (addresses and IRQ numbers) provided by the device2626- Allocate these resources2727- Communicate with the device4646+ Request MMIO/IOP resources4747+ Set the DMA mask size (for both coherent and streaming DMA)4848+ Allocate and initialize shared control data (pci_allocate_coherent())4949+ Access device configuration space (if needed)5050+ Register IRQ handler (request_irq())5151+ Initialize non-PCI (i.e. LAN/SCSI/etc parts of the chip)5252+ Enable DMA/processing engines5353+5454+When done using the device, and perhaps the module needs to be unloaded,5555+the driver needs to take the follow steps:5656+ Disable the device from generating IRQs5757+ Release the IRQ (free_irq())5858+ Stop all DMA activity5959+ Release DMA buffers (both streaming and coherent)6060+ Unregister from other subsystems (e.g. scsi or netdev)6161+ Release MMIO/IOP resources2862 Disable the device29633030-Most of these topics are covered by the following sections, for the rest3131-look at <linux/pci.h>, it's hopefully well commented.6464+Most of these topics are covered in the following sections.6565+For the rest look at LDD3 or <linux/pci.h> .32663367If the PCI subsystem is not configured (CONFIG_PCI is not set), most of3434-the functions described below are defined as inline functions either completely3535-empty or just returning an appropriate error codes to avoid lots of ifdefs3636-in the drivers.6868+the PCI functions described below are defined as inline functions either6969+completely empty or just returning an appropriate error codes to avoid7070+lots of ifdefs in the drivers.377138723939-1. New-style drivers4040-~~~~~~~~~~~~~~~~~~~~4141-The new-style drivers just call pci_register_driver during their initialization4242-with a pointer to a structure describing the driver (struct pci_driver) which4343-contains:44734545- name Name of the driver7474+1. pci_register_driver() call7575+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~7676+7777+PCI device drivers call pci_register_driver() during their7878+initialization with a pointer to a structure describing the driver7979+(struct pci_driver):8080+8181+ field name Description8282+ ---------- ------------------------------------------------------4683 id_table Pointer to table of device ID's the driver is4784 interested in. Most drivers should export this4885 table using MODULE_DEVICE_TABLE(pci,...).4949- probe Pointer to a probing function which gets called (during5050- execution of pci_register_driver for already existing5151- devices or later if a new device gets inserted) for all5252- PCI devices which match the ID table and are not handled5353- by the other drivers yet. This function gets passed a5454- pointer to the pci_dev structure representing the device5555- and also which entry in the ID table did the device5656- match. It returns zero when the driver has accepted the5757- device or an error code (negative number) otherwise.5858- This function always gets called from process context,5959- so it can sleep.6060- remove Pointer to a function which gets called whenever a6161- device being handled by this driver is removed (either6262- during deregistration of the driver or when it's6363- manually pulled out of a hot-pluggable slot). This6464- function always gets called from process context, so it6565- can sleep.6666- save_state Save a device's state before it's suspend.8686+8787+ probe This probing function gets called (during execution8888+ of pci_register_driver() for already existing8989+ devices or later if a new device gets inserted) for9090+ all PCI devices which match the ID table and are not9191+ "owned" by the other drivers yet. This function gets9292+ passed a "struct pci_dev *" for each device whose9393+ entry in the ID table matches the device. The probe9494+ function returns zero when the driver chooses to9595+ take "ownership" of the device or an error code9696+ (negative number) otherwise.9797+ The probe function always gets called from process9898+ context, so it can sleep.9999+100100+ remove The remove() function gets called whenever a device101101+ being handled by this driver is removed (either during102102+ deregistration of the driver or when it's manually103103+ pulled out of a hot-pluggable slot).104104+ The remove function always gets called from process105105+ context, so it can sleep.106106+67107 suspend Put device into low power state.108108+ suspend_late Put device into low power state.109109+110110+ resume_early Wake device from low power state.68111 resume Wake device from low power state.112112+113113+ (Please see Documentation/power/pci.txt for descriptions114114+ of PCI Power Management and the related functions.)115115+69116 enable_wake Enable device to generate wake events from a low power70117 state.711187272- (Please see Documentation/power/pci.txt for descriptions7373- of PCI Power Management and the related functions)119119+ shutdown Hook into reboot_notifier_list (kernel/sys.c).120120+ Intended to stop any idling DMA operations.121121+ Useful for enabling wake-on-lan (NIC) or changing122122+ the power state of a device before reboot.123123+ e.g. drivers/net/e100.c.741247575-The ID table is an array of struct pci_device_id ending with a all-zero entry.7676-Each entry consists of:125125+ err_handler See Documentation/pci-error-recovery.txt771267878- vendor, device Vendor and device ID to match (or PCI_ANY_ID)127127+ multithread_probe Enable multi-threaded probe/scan. Driver must128128+ provide its own locking/syncronization for init129129+ operations if this is enabled.130130+131131+132132+The ID table is an array of struct pci_device_id entries ending with an133133+all-zero entry. Each entry consists of:134134+135135+ vendor,device Vendor and device ID to match (or PCI_ANY_ID)136136+79137 subvendor, Subsystem vendor and device ID to match (or PCI_ANY_ID)8080- subdevice8181- class, Device class to match. The class_mask tells which bits8282- class_mask of the class are honored during the comparison.138138+ subdevice,139139+140140+ class Device class, subclass, and "interface" to match.141141+ See Appendix D of the PCI Local Bus Spec or142142+ include/linux/pci_ids.h for a full list of classes.143143+ Most drivers do not need to specify class/class_mask144144+ as vendor/device is normally sufficient.145145+146146+ class_mask limit which sub-fields of the class field are compared.147147+ See drivers/scsi/sym53c8xx_2/ for example of usage.148148+83149 driver_data Data private to the driver.150150+ Most drivers don't need to use driver_data field.151151+ Best practice is to use driver_data as an index152152+ into a static list of equivalent device types,153153+ instead of using it as a pointer.841548585-Most drivers don't need to use the driver_data field. Best practice8686-for use of driver_data is to use it as an index into a static list of8787-equivalent device types, not to use it as a pointer.881558989-Have a table entry {PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID}9090-to have probe() called for every PCI device known to the system.156156+Most drivers only need PCI_DEVICE() or PCI_DEVICE_CLASS() to set up157157+a pci_device_id table.911589292-New PCI IDs may be added to a device driver at runtime by writing9393-to the file /sys/bus/pci/drivers/{driver}/new_id. When added, the9494-driver will probe for all devices it can support.159159+New PCI IDs may be added to a device driver pci_ids table at runtime160160+as shown below:9516196162echo "vendor device subvendor subdevice class class_mask driver_data" > \9797- /sys/bus/pci/drivers/{driver}/new_id9898-where all fields are passed in as hexadecimal values (no leading 0x).9999-Users need pass only as many fields as necessary; vendor, device,100100-subvendor, and subdevice fields default to PCI_ANY_ID (FFFFFFFF),101101-class and classmask fields default to 0, and driver_data defaults to102102-0UL. Device drivers must initialize use_driver_data in the dynids struct103103-in their pci_driver struct prior to calling pci_register_driver in order104104-for the driver_data field to get passed to the driver. Otherwise, only a105105-0 is passed in that field.163163+/sys/bus/pci/drivers/{driver}/new_id164164+165165+All fields are passed in as hexadecimal values (no leading 0x).166166+Users need pass only as many fields as necessary:167167+ o vendor, device, subvendor, and subdevice fields default168168+ to PCI_ANY_ID (FFFFFFFF),169169+ o class and classmask fields default to 0170170+ o driver_data defaults to 0UL.171171+172172+Once added, the driver probe routine will be invoked for any unclaimed173173+PCI devices listed in its (newly updated) pci_ids list.106174107175When the driver exits, it just calls pci_unregister_driver() and the PCI layer108176automatically calls the remove hook for all devices handled by the driver.177177+178178+179179+1.1 "Attributes" for driver functions/data109180110181Please mark the initialization and cleanup functions where appropriate111182(the corresponding macros are defined in <linux/init.h>):···184113 __init Initialization code. Thrown away after the driver185114 initializes.186115 __exit Exit code. Ignored for non-modular drivers.187187- __devinit Device initialization code. Identical to __init if188188- the kernel is not compiled with CONFIG_HOTPLUG, normal189189- function otherwise.116116+117117+118118+ __devinit Device initialization code.119119+ Identical to __init if the kernel is not compiled120120+ with CONFIG_HOTPLUG, normal function otherwise.190121 __devexit The same for __exit.191122192192-Tips:193193- The module_init()/module_exit() functions (and all initialization194194- functions called only from these) should be marked __init/exit.195195- The struct pci_driver shouldn't be marked with any of these tags.196196- The ID table array should be marked __devinitdata.197197- The probe() and remove() functions (and all initialization198198- functions called only from these) should be marked __devinit/exit.199199- If you are sure the driver is not a hotplug driver then use only 200200- __init/exit __initdata/exitdata.123123+Tips on when/where to use the above attributes:124124+ o The module_init()/module_exit() functions (and all125125+ initialization functions called _only_ from these)126126+ should be marked __init/__exit.201127202202- Pointers to functions marked as __devexit must be created using203203- __devexit_p(function_name). That will generate the function204204- name or NULL if the __devexit function will be discarded.128128+ o Do not mark the struct pci_driver.129129+130130+ o The ID table array should be marked __devinitdata.131131+132132+ o The probe() and remove() functions should be marked __devinit133133+ and __devexit respectively. All initialization functions134134+ exclusively called by the probe() routine, can be marked __devinit.135135+ Ditto for remove() and __devexit.136136+137137+ o If mydriver_probe() is marked with __devinit(), then all address138138+ references to mydriver_probe must use __devexit_p(mydriver_probe)139139+ (in the struct pci_driver declaration for example).140140+ __devexit_p() will generate the function name _or_ NULL if the141141+ function will be discarded. For an example, see drivers/net/tg3.c.142142+143143+ o Do NOT mark a function if you are not sure which mark to use.144144+ Better to not mark the function than mark the function wrong.205145206146207207-2. How to find PCI devices manually (the old style)208208-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~209209-PCI drivers not using the pci_register_driver() interface search210210-for PCI devices manually using the following constructs:147147+148148+2. How to find PCI devices manually149149+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~150150+151151+PCI drivers should have a really good reason for not using the152152+pci_register_driver() interface to search for PCI devices.153153+The main reason PCI devices are controlled by multiple drivers154154+is because one PCI device implements several different HW services.155155+E.g. combined serial/parallel port/floppy controller.156156+157157+A manual search may be performed using the following constructs:211158212159Searching by vendor and device ID:213160···239150240151Searching by both vendor/device and subsystem vendor/device ID:241152242242- pci_get_subsys(VENDOR_ID, DEVICE_ID, SUBSYS_VENDOR_ID, SUBSYS_DEVICE_ID, dev).153153+ pci_get_subsys(VENDOR_ID,DEVICE_ID, SUBSYS_VENDOR_ID, SUBSYS_DEVICE_ID, dev).243154244244- You can use the constant PCI_ANY_ID as a wildcard replacement for155155+You can use the constant PCI_ANY_ID as a wildcard replacement for245156VENDOR_ID or DEVICE_ID. This allows searching for any device from a246157specific vendor, for example.247158248248- These functions are hotplug-safe. They increment the reference count on159159+These functions are hotplug-safe. They increment the reference count on249160the pci_dev that they return. You must eventually (possibly at module unload)250161decrement the reference count on these devices by calling pci_dev_put().251162252163253253-3. Enabling and disabling devices254254-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~255255- Before you do anything with the device you've found, you need to enable256256-it by calling pci_enable_device() which enables I/O and memory regions of257257-the device, allocates an IRQ if necessary, assigns missing resources if258258-needed and wakes up the device if it was in suspended state. Please note259259-that this function can fail.260164261261- If you want to use the device in bus mastering mode, call pci_set_master()262262-which enables the bus master bit in PCI_COMMAND register and also fixes263263-the latency timer value if it's set to something bogus by the BIOS.165165+3. Device Initialization Steps166166+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~264167265265- If you want to use the PCI Memory-Write-Invalidate transaction,168168+As noted in the introduction, most PCI drivers need the following steps169169+for device initialization:170170+171171+ Enable the device172172+ Request MMIO/IOP resources173173+ Set the DMA mask size (for both coherent and streaming DMA)174174+ Allocate and initialize shared control data (pci_allocate_coherent())175175+ Access device configuration space (if needed)176176+ Register IRQ handler (request_irq())177177+ Initialize non-PCI (i.e. LAN/SCSI/etc parts of the chip)178178+ Enable DMA/processing engines.179179+180180+The driver can access PCI config space registers at any time.181181+(Well, almost. When running BIST, config space can go away...but182182+that will just result in a PCI Bus Master Abort and config reads183183+will return garbage).184184+185185+186186+3.1 Enable the PCI device187187+~~~~~~~~~~~~~~~~~~~~~~~~~188188+Before touching any device registers, the driver needs to enable189189+the PCI device by calling pci_enable_device(). This will:190190+ o wake up the device if it was in suspended state,191191+ o allocate I/O and memory regions of the device (if BIOS did not),192192+ o allocate an IRQ (if BIOS did not).193193+194194+NOTE: pci_enable_device() can fail! Check the return value.195195+NOTE2: Also see pci_enable_device_bars() below. Drivers can196196+ attempt to enable only a subset of BARs they need.197197+198198+[ OS BUG: we don't check resource allocations before enabling those199199+ resources. The sequence would make more sense if we called200200+ pci_request_resources() before calling pci_enable_device().201201+ Currently, the device drivers can't detect the bug when when two202202+ devices have been allocated the same range. This is not a common203203+ problem and unlikely to get fixed soon.204204+205205+ This has been discussed before but not changed as of 2.6.19:206206+ http://lkml.org/lkml/2006/3/2/194207207+]208208+209209+pci_set_master() will enable DMA by setting the bus master bit210210+in the PCI_COMMAND register. It also fixes the latency timer value if211211+it's set to something bogus by the BIOS.212212+213213+If the PCI device can use the PCI Memory-Write-Invalidate transaction,266214call pci_set_mwi(). This enables the PCI_COMMAND bit for Mem-Wr-Inval267215and also ensures that the cache line size register is set correctly.268268-Make sure to check the return value of pci_set_mwi(), not all architectures269269-may support Memory-Write-Invalidate.216216+Check the return value of pci_set_mwi() as not all architectures217217+or chip-sets may support Memory-Write-Invalidate.270218271271- If your driver decides to stop using the device (e.g., there was an272272-error while setting it up or the driver module is being unloaded), it273273-should call pci_disable_device() to deallocate any IRQ resources, disable274274-PCI bus-mastering, etc. You should not do anything with the device after219219+220220+3.2 Request MMIO/IOP resources221221+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~222222+Memory (MMIO), and I/O port addresses should NOT be read directly223223+from the PCI device config space. Use the values in the pci_dev structure224224+as the PCI "bus address" might have been remapped to a "host physical"225225+address by the arch/chip-set specific kernel support.226226+227227+See Documentation/IO-mapping.txt for how to access device registers228228+or device memory.229229+230230+The device driver needs to call pci_request_region() to verify231231+no other device is already using the same address resource.232232+Conversely, drivers should call pci_release_region() AFTER275233calling pci_disable_device().234234+The idea is to prevent two devices colliding on the same address range.276235277277-4. How to access PCI config space236236+[ See OS BUG comment above. Currently (2.6.19), The driver can only237237+ determine MMIO and IO Port resource availability _after_ calling238238+ pci_enable_device(). ]239239+240240+Generic flavors of pci_request_region() are request_mem_region()241241+(for MMIO ranges) and request_region() (for IO Port ranges).242242+Use these for address resources that are not described by "normal" PCI243243+BARs.244244+245245+Also see pci_request_selected_regions() below.246246+247247+248248+3.3 Set the DMA mask size249249+~~~~~~~~~~~~~~~~~~~~~~~~~250250+[ If anything below doesn't make sense, please refer to251251+ Documentation/DMA-API.txt. This section is just a reminder that252252+ drivers need to indicate DMA capabilities of the device and is not253253+ an authoritative source for DMA interfaces. ]254254+255255+While all drivers should explicitly indicate the DMA capability256256+(e.g. 32 or 64 bit) of the PCI bus master, devices with more than257257+32-bit bus master capability for streaming data need the driver258258+to "register" this capability by calling pci_set_dma_mask() with259259+appropriate parameters. In general this allows more efficient DMA260260+on systems where System RAM exists above 4G _physical_ address.261261+262262+Drivers for all PCI-X and PCIe compliant devices must call263263+pci_set_dma_mask() as they are 64-bit DMA devices.264264+265265+Similarly, drivers must also "register" this capability if the device266266+can directly address "consistent memory" in System RAM above 4G physical267267+address by calling pci_set_consistent_dma_mask().268268+Again, this includes drivers for all PCI-X and PCIe compliant devices.269269+Many 64-bit "PCI" devices (before PCI-X) and some PCI-X devices are270270+64-bit DMA capable for payload ("streaming") data but not control271271+("consistent") data.272272+273273+274274+3.4 Setup shared control data275275+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~276276+Once the DMA masks are set, the driver can allocate "consistent" (a.k.a. shared)277277+memory. See Documentation/DMA-API.txt for a full description of278278+the DMA APIs. This section is just a reminder that it needs to be done279279+before enabling DMA on the device.280280+281281+282282+3.5 Initialize device registers283283+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~284284+Some drivers will need specific "capability" fields programmed285285+or other "vendor specific" register initialized or reset.286286+E.g. clearing pending interrupts.287287+288288+289289+3.6 Register IRQ handler290290+~~~~~~~~~~~~~~~~~~~~~~~~291291+While calling request_irq() is the the last step described here,292292+this is often just another intermediate step to initialize a device.293293+This step can often be deferred until the device is opened for use.294294+295295+All interrupt handlers for IRQ lines should be registered with IRQF_SHARED296296+and use the devid to map IRQs to devices (remember that all PCI IRQ lines297297+can be shared).298298+299299+request_irq() will associate an interrupt handler and device handle300300+with an interrupt number. Historically interrupt numbers represent301301+IRQ lines which run from the PCI device to the Interrupt controller.302302+With MSI and MSI-X (more below) the interrupt number is a CPU "vector".303303+304304+request_irq() also enables the interrupt. Make sure the device is305305+quiesced and does not have any interrupts pending before registering306306+the interrupt handler.307307+308308+MSI and MSI-X are PCI capabilities. Both are "Message Signaled Interrupts"309309+which deliver interrupts to the CPU via a DMA write to a Local APIC.310310+The fundamental difference between MSI and MSI-X is how multiple311311+"vectors" get allocated. MSI requires contiguous blocks of vectors312312+while MSI-X can allocate several individual ones.313313+314314+MSI capability can be enabled by calling pci_enable_msi() or315315+pci_enable_msix() before calling request_irq(). This causes316316+the PCI support to program CPU vector data into the PCI device317317+capability registers.318318+319319+If your PCI device supports both, try to enable MSI-X first.320320+Only one can be enabled at a time. Many architectures, chip-sets,321321+or BIOSes do NOT support MSI or MSI-X and the call to pci_enable_msi/msix322322+will fail. This is important to note since many drivers have323323+two (or more) interrupt handlers: one for MSI/MSI-X and another for IRQs.324324+They choose which handler to register with request_irq() based on the325325+return value from pci_enable_msi/msix().326326+327327+There are (at least) two really good reasons for using MSI:328328+1) MSI is an exclusive interrupt vector by definition.329329+ This means the interrupt handler doesn't have to verify330330+ its device caused the interrupt.331331+332332+2) MSI avoids DMA/IRQ race conditions. DMA to host memory is guaranteed333333+ to be visible to the host CPU(s) when the MSI is delivered. This334334+ is important for both data coherency and avoiding stale control data.335335+ This guarantee allows the driver to omit MMIO reads to flush336336+ the DMA stream.337337+338338+See drivers/infiniband/hw/mthca/ or drivers/net/tg3.c for examples339339+of MSI/MSI-X usage.340340+341341+342342+343343+4. PCI device shutdown344344+~~~~~~~~~~~~~~~~~~~~~~~345345+346346+When a PCI device driver is being unloaded, most of the following347347+steps need to be performed:348348+349349+ Disable the device from generating IRQs350350+ Release the IRQ (free_irq())351351+ Stop all DMA activity352352+ Release DMA buffers (both streaming and consistent)353353+ Unregister from other subsystems (e.g. scsi or netdev)354354+ Disable device from responding to MMIO/IO Port addresses355355+ Release MMIO/IO Port resource(s)356356+357357+358358+4.1 Stop IRQs on the device359359+~~~~~~~~~~~~~~~~~~~~~~~~~~~360360+How to do this is chip/device specific. If it's not done, it opens361361+the possibility of a "screaming interrupt" if (and only if)362362+the IRQ is shared with another device.363363+364364+When the shared IRQ handler is "unhooked", the remaining devices365365+using the same IRQ line will still need the IRQ enabled. Thus if the366366+"unhooked" device asserts IRQ line, the system will respond assuming367367+it was one of the remaining devices asserted the IRQ line. Since none368368+of the other devices will handle the IRQ, the system will "hang" until369369+it decides the IRQ isn't going to get handled and masks the IRQ (100,000370370+iterations later). Once the shared IRQ is masked, the remaining devices371371+will stop functioning properly. Not a nice situation.372372+373373+This is another reason to use MSI or MSI-X if it's available.374374+MSI and MSI-X are defined to be exclusive interrupts and thus375375+are not susceptible to the "screaming interrupt" problem.376376+377377+378378+4.2 Release the IRQ379379+~~~~~~~~~~~~~~~~~~~380380+Once the device is quiesced (no more IRQs), one can call free_irq().381381+This function will return control once any pending IRQs are handled,382382+"unhook" the drivers IRQ handler from that IRQ, and finally release383383+the IRQ if no one else is using it.384384+385385+386386+4.3 Stop all DMA activity387387+~~~~~~~~~~~~~~~~~~~~~~~~~388388+It's extremely important to stop all DMA operations BEFORE attempting389389+to deallocate DMA control data. Failure to do so can result in memory390390+corruption, hangs, and on some chip-sets a hard crash.391391+392392+Stopping DMA after stopping the IRQs can avoid races where the393393+IRQ handler might restart DMA engines.394394+395395+While this step sounds obvious and trivial, several "mature" drivers396396+didn't get this step right in the past.397397+398398+399399+4.4 Release DMA buffers400400+~~~~~~~~~~~~~~~~~~~~~~~401401+Once DMA is stopped, clean up streaming DMA first.402402+I.e. unmap data buffers and return buffers to "upstream"403403+owners if there is one.404404+405405+Then clean up "consistent" buffers which contain the control data.406406+407407+See Documentation/DMA-API.txt for details on unmapping interfaces.408408+409409+410410+4.5 Unregister from other subsystems411411+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~412412+Most low level PCI device drivers support some other subsystem413413+like USB, ALSA, SCSI, NetDev, Infiniband, etc. Make sure your414414+driver isn't losing resources from that other subsystem.415415+If this happens, typically the symptom is an Oops (panic) when416416+the subsystem attempts to call into a driver that has been unloaded.417417+418418+419419+4.6 Disable Device from responding to MMIO/IO Port addresses420420+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~421421+io_unmap() MMIO or IO Port resources and then call pci_disable_device().422422+This is the symmetric opposite of pci_enable_device().423423+Do not access device registers after calling pci_disable_device().424424+425425+426426+4.7 Release MMIO/IO Port Resource(s)427427+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~428428+Call pci_release_region() to mark the MMIO or IO Port range as available.429429+Failure to do so usually results in the inability to reload the driver.430430+431431+432432+433433+5. How to access PCI config space278434~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~279279- You can use pci_(read|write)_config_(byte|word|dword) to access the config435435+436436+You can use pci_(read|write)_config_(byte|word|dword) to access the config280437space of a device represented by struct pci_dev *. All these functions return 0281438when successful or an error code (PCIBIOS_...) which can be translated to a text282439string by pcibios_strerror. Most drivers expect that accesses to valid PCI283440devices don't fail.284441285285- If you don't have a struct pci_dev available, you can call442442+If you don't have a struct pci_dev available, you can call286443pci_bus_(read|write)_config_(byte|word|dword) to access a given device287444and function on that bus.288445289289- If you access fields in the standard portion of the config header, please446446+If you access fields in the standard portion of the config header, please290447use symbolic names of locations and bits declared in <linux/pci.h>.291448292292- If you need to access Extended PCI Capability registers, just call449449+If you need to access Extended PCI Capability registers, just call293450pci_find_capability() for the particular capability and it will find the294451corresponding register block for you.295452296453297297-5. Addresses and interrupts298298-~~~~~~~~~~~~~~~~~~~~~~~~~~~299299- Memory and port addresses and interrupt numbers should NOT be read from the300300-config space. You should use the values in the pci_dev structure as they might301301-have been remapped by the kernel.302302-303303- See Documentation/IO-mapping.txt for how to access device memory.304304-305305- The device driver needs to call pci_request_region() to make sure306306-no other device is already using the same resource. The driver is expected307307-to determine MMIO and IO Port resource availability _before_ calling308308-pci_enable_device(). Conversely, drivers should call pci_release_region()309309-_after_ calling pci_disable_device(). The idea is to prevent two devices310310-colliding on the same address range.311311-312312-Generic flavors of pci_request_region() are request_mem_region()313313-(for MMIO ranges) and request_region() (for IO Port ranges).314314-Use these for address resources that are not described by "normal" PCI315315-interfaces (e.g. BAR).316316-317317- All interrupt handlers should be registered with IRQF_SHARED and use the devid318318-to map IRQs to devices (remember that all PCI interrupts are shared).319319-3204543214556. Other interesting functions322456~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~457457+323458pci_find_slot() Find pci_dev corresponding to given bus and324459 slot numbers.325460pci_set_power_state() Set PCI Power Management state (0=D0 ... 3=D3)···560247pci_clear_mwi() Disable Memory-Write-Invalidate transactions.561248562249250250+5632517. Miscellaneous hints564252~~~~~~~~~~~~~~~~~~~~~~565565-When displaying PCI slot names to the user (for example when a driver wants566566-to tell the user what card has it found), please use pci_name(pci_dev)567567-for this purpose.253253+254254+When displaying PCI device names to the user (for example when a driver wants255255+to tell the user what card has it found), please use pci_name(pci_dev).568256569257Always refer to the PCI devices by a pointer to the pci_dev structure.570258All PCI layer functions use this identification and it's the only···573259special purposes -- on systems with multiple primary buses their semantics574260can be pretty complex.575261576576-If you're going to use PCI bus mastering DMA, take a look at577577-Documentation/DMA-mapping.txt.578578-579262Don't try to turn on Fast Back to Back writes in your driver. All devices580263on the bus need to be capable of doing it, so this is something which needs581264to be handled by platform and generic code, not individual drivers.582265583266267267+5842688. Vendor and device identifications585269~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~586586-For the future, let's avoid adding device ids to include/linux/pci_ids.h.587270588588-PCI_VENDOR_ID_xxx for vendors, and a hex constant for device ids.271271+One is not not required to add new device ids to include/linux/pci_ids.h.272272+Please add PCI_VENDOR_ID_xxx for vendors and a hex constant for device ids.589273590590-Rationale: PCI_VENDOR_ID_xxx constants are re-used, but device ids are not.591591- Further, device ids are arbitrary hex numbers, normally used only in a592592- single location, the pci_device_id table.274274+PCI_VENDOR_ID_xxx constants are re-used. The device ids are arbitrary275275+hex numbers (vendor controlled) and normally used only in a single276276+location, the pci_device_id table.277277+278278+Please DO submit new vendor/device ids to pciids.sourceforge.net project.279279+280280+5932815942829. Obsolete functions595283~~~~~~~~~~~~~~~~~~~~~284284+596285There are several functions which you might come across when trying to597286port an old driver to the new PCI interface. They are no longer present598287in the kernel as they aren't compatible with hotplug or PCI domains or599288having sane locking.600289601601-pci_find_device() Superseded by pci_get_device()602602-pci_find_subsys() Superseded by pci_get_subsys()603603-pci_find_slot() Superseded by pci_get_slot()290290+pci_find_device() Superseded by pci_get_device()291291+pci_find_subsys() Superseded by pci_get_subsys()292292+pci_find_slot() Superseded by pci_get_slot()293293+294294+295295+The alternative is the traditional PCI device driver that walks PCI296296+device lists. This is still possible but discouraged.297297+298298+299299+300300+10. pci_enable_device_bars() and Legacy I/O Port space301301+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~302302+303303+Large servers may not be able to provide I/O port resources to all PCI304304+devices. I/O Port space is only 64KB on Intel Architecture[1] and is305305+likely also fragmented since the I/O base register of PCI-to-PCI306306+bridge will usually be aligned to a 4KB boundary[2]. On such systems,307307+pci_enable_device() and pci_request_region() will fail when308308+attempting to enable I/O Port regions that don't have I/O Port309309+resources assigned.310310+311311+Fortunately, many PCI devices which request I/O Port resources also312312+provide access to the same registers via MMIO BARs. These devices can313313+be handled without using I/O port space and the drivers typically314314+offer a CONFIG_ option to only use MMIO regions315315+(e.g. CONFIG_TULIP_MMIO). PCI devices typically provide I/O port316316+interface for legacy OSes and will work when I/O port resources are not317317+assigned. The "PCI Local Bus Specification Revision 3.0" discusses318318+this on p.44, "IMPLEMENTATION NOTE".319319+320320+If your PCI device driver doesn't need I/O port resources assigned to321321+I/O Port BARs, you should use pci_enable_device_bars() instead of322322+pci_enable_device() in order not to enable I/O port regions for the323323+corresponding devices. In addition, you should use324324+pci_request_selected_regions() and pci_release_selected_regions()325325+instead of pci_request_regions()/pci_release_regions() in order not to326326+request/release I/O port regions for the corresponding devices.327327+328328+[1] Some systems support 64KB I/O port space per PCI segment.329329+[2] Some PCI-to-PCI bridges support optional 1KB aligned I/O base.330330+331331+332332+333333+11. MMIO Space and "Write Posting"334334+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~335335+336336+Converting a driver from using I/O Port space to using MMIO space337337+often requires some additional changes. Specifically, "write posting"338338+needs to be handled. Many drivers (e.g. tg3, acenic, sym53c8xx_2)339339+already do this. I/O Port space guarantees write transactions reach the PCI340340+device before the CPU can continue. Writes to MMIO space allow the CPU341341+to continue before the transaction reaches the PCI device. HW weenies342342+call this "Write Posting" because the write completion is "posted" to343343+the CPU before the transaction has reached its destination.344344+345345+Thus, timing sensitive code should add readl() where the CPU is346346+expected to wait before doing other work. The classic "bit banging"347347+sequence works fine for I/O Port space:348348+349349+ for (i = 8; --i; val >>= 1) {350350+ outb(val & 1, ioport_reg); /* write bit */351351+ udelay(10);352352+ }353353+354354+The same sequence for MMIO space should be:355355+356356+ for (i = 8; --i; val >>= 1) {357357+ writeb(val & 1, mmio_reg); /* write bit */358358+ readb(safe_mmio_reg); /* flush posted write */359359+ udelay(10);360360+ }361361+362362+It is important that "safe_mmio_reg" not have any side effects that363363+interferes with the correct operation of the device.364364+365365+Another case to watch out for is when resetting a PCI device. Use PCI366366+Configuration space reads to flush the writel(). This will gracefully367367+handle the PCI master abort on all platforms if the PCI device is368368+expected to not respond to a readl(). Most x86 platforms will allow369369+MMIO reads to master abort (a.k.a. "Soft Fail") and return garbage370370+(e.g. ~0). But many RISC platforms will crash (a.k.a."Hard Fail").371371+
+1-1
Documentation/usb/CREDITS
···2121 Bill Ryder <bryder@sgi.com>2222 Thomas Sailer <sailer@ife.ee.ethz.ch>2323 Gregory P. Smith <greg@electricrain.com>2424- Linus Torvalds <torvalds@osdl.org>2424+ Linus Torvalds <torvalds@linux-foundation.org>2525 Roman Weissgaerber <weissg@vienna.at>2626 <Kazuki.Yasumatsu@fujixerox.co.jp>2727
···278278 the file MAINTAINERS to see if there is a particular person associated279279 with the part of the kernel that you are having trouble with. If there280280 isn't anyone listed there, then the second best thing is to mail281281- them to me (torvalds@osdl.org), and possibly to any other relevant282282- mailing-list or to the newsgroup.281281+ them to me (torvalds@linux-foundation.org), and possibly to any other282282+ relevant mailing-list or to the newsgroup.283283284284 - In all bug-reports, *please* tell what kernel you are talking about,285285 how to duplicate the problem, and what your setup is (use your common
+9-4
arch/i386/kernel/cpu/common.c
···710710 return 1;711711}712712713713-/* Common CPU init for both boot and secondary CPUs */714714-static void __cpuinit _cpu_init(int cpu, struct task_struct *curr)713713+void __cpuinit cpu_set_gdt(int cpu)715714{716716- struct tss_struct * t = &per_cpu(init_tss, cpu);717717- struct thread_struct *thread = &curr->thread;718715 struct Xgt_desc_struct *cpu_gdt_descr = &per_cpu(cpu_gdt_descr, cpu);719716720717 /* Reinit these anyway, even if they've already been done (on···719722 the real ones). */720723 load_gdt(cpu_gdt_descr);721724 set_kernel_gs();725725+}726726+727727+/* Common CPU init for both boot and secondary CPUs */728728+static void __cpuinit _cpu_init(int cpu, struct task_struct *curr)729729+{730730+ struct tss_struct * t = &per_cpu(init_tss, cpu);731731+ struct thread_struct *thread = &curr->thread;722732723733 if (cpu_test_and_set(cpu, cpu_initialized)) {724734 printk(KERN_WARNING "CPU#%d already initialized!\n", cpu);···811807 local_irq_enable();812808 }813809810810+ cpu_set_gdt(cpu);814811 _cpu_init(cpu, curr);815812}816813
+1-7
arch/i386/kernel/nmi.c
···310310311311 if ((nmi >= NMI_INVALID) || (nmi < NMI_NONE))312312 return 0;313313- /*314314- * If any other x86 CPU has a local APIC, then315315- * please test the NMI stuff there and send me the316316- * missing bits. Right now Intel P6/P4 and AMD K7 only.317317- */318318- if ((nmi == NMI_LOCAL_APIC) && (nmi_known_cpu() == 0))319319- return 0; /* no lapic support */313313+320314 nmi_watchdog = nmi;321315 return 1;322316}
+8-1
arch/i386/kernel/paravirt.c
···566566 .irq_enable_sysexit = native_irq_enable_sysexit,567567 .iret = native_iret,568568};569569-EXPORT_SYMBOL(paravirt_ops);569569+570570+/*571571+ * NOTE: CONFIG_PARAVIRT is experimental and the paravirt_ops572572+ * semantics are subject to change. Hence we only do this573573+ * internal-only export of this, until it gets sorted out and574574+ * all lowlevel CPU ops used by modules are separately exported.575575+ */576576+EXPORT_SYMBOL_GPL(paravirt_ops);
+6-3
arch/i386/kernel/smpboot.c
···596596void __devinit initialize_secondary(void)597597{598598 /*599599+ * switch to the per CPU GDT we already set up600600+ * in do_boot_cpu()601601+ */602602+ cpu_set_gdt(current_thread_info()->cpu);603603+604604+ /*599605 * We don't actually need to load the full TSS,600606 * basically just the stack pointer and the eip.601607 */···977971 printk("Booting processor %d/%d eip %lx\n", cpu, apicid, start_eip);978972 /* Stack for startup_32 can be just as for start_secondary onwards */979973 stack_start.esp = (void *) idle->thread.esp;980980-981981- start_pda = cpu_pda(cpu);982982- cpu_gdt_descr = per_cpu(cpu_gdt_descr, cpu);983974984975 irq_ctx_init(cpu);985976
+6
arch/i386/mach-voyager/voyager_smp.c
···773773#endif774774775775 /*776776+ * switch to the per CPU GDT we already set up777777+ * in do_boot_cpu()778778+ */779779+ cpu_set_gdt(current_thread_info()->cpu);780780+781781+ /*776782 * We don't actually need to load the full TSS,777783 * basically just the stack pointer and the eip.778784 */
+14
arch/mips/Kconfig
···15681568 depends on MIPS_MT15691569 default y1570157015711571+config MIPS_MT_SMTC_INSTANT_REPLAY15721572+ bool "Low-latency Dispatch of Deferred SMTC IPIs"15731573+ depends on MIPS_MT_SMTC15741574+ default y15751575+ help15761576+ SMTC pseudo-interrupts between TCs are deferred and queued15771577+ if the target TC is interrupt-inhibited (IXMT). In the first15781578+ SMTC prototypes, these queued IPIs were serviced on return15791579+ to user mode, or on entry into the kernel idle loop. The15801580+ INSTANT_REPLAY option dispatches them as part of local_irq_restore()15811581+ processing, which adds runtime overhead (hence the option to turn15821582+ it off), but ensures that IPIs are handled promptly even under15831583+ heavy I/O interrupt load.15841584+15711585config MIPS_VPE_LOADER_TOM15721586 bool "Load VPE program into memory hidden from linux"15731587 depends on MIPS_VPE_LOADER
+34-22
arch/mips/kernel/smtc.c
···10171017 * SMTC-specific hacks invoked from elsewhere in the kernel.10181018 */1019101910201020+void smtc_ipi_replay(void)10211021+{10221022+ /*10231023+ * To the extent that we've ever turned interrupts off,10241024+ * we may have accumulated deferred IPIs. This is subtle.10251025+ * If we use the smtc_ipi_qdepth() macro, we'll get an10261026+ * exact number - but we'll also disable interrupts10271027+ * and create a window of failure where a new IPI gets10281028+ * queued after we test the depth but before we re-enable10291029+ * interrupts. So long as IXMT never gets set, however,10301030+ * we should be OK: If we pick up something and dispatch10311031+ * it here, that's great. If we see nothing, but concurrent10321032+ * with this operation, another TC sends us an IPI, IXMT10331033+ * is clear, and we'll handle it as a real pseudo-interrupt10341034+ * and not a pseudo-pseudo interrupt.10351035+ */10361036+ if (IPIQ[smp_processor_id()].depth > 0) {10371037+ struct smtc_ipi *pipi;10381038+ extern void self_ipi(struct smtc_ipi *);10391039+10401040+ while ((pipi = smtc_ipi_dq(&IPIQ[smp_processor_id()]))) {10411041+ self_ipi(pipi);10421042+ smtc_cpu_stats[smp_processor_id()].selfipis++;10431043+ }10441044+ }10451045+}10461046+10201047void smtc_idle_loop_hook(void)10211048{10221049#ifdef SMTC_IDLE_HOOK_DEBUG···11401113 if (pdb_msg != &id_ho_db_msg[0])11411114 printk("CPU%d: %s", smp_processor_id(), id_ho_db_msg);11421115#endif /* SMTC_IDLE_HOOK_DEBUG */11431143- /*11441144- * To the extent that we've ever turned interrupts off,11451145- * we may have accumulated deferred IPIs. This is subtle.11461146- * If we use the smtc_ipi_qdepth() macro, we'll get an11471147- * exact number - but we'll also disable interrupts11481148- * and create a window of failure where a new IPI gets11491149- * queued after we test the depth but before we re-enable11501150- * interrupts. So long as IXMT never gets set, however,11511151- * we should be OK: If we pick up something and dispatch11521152- * it here, that's great. If we see nothing, but concurrent11531153- * with this operation, another TC sends us an IPI, IXMT11541154- * is clear, and we'll handle it as a real pseudo-interrupt11551155- * and not a pseudo-pseudo interrupt.11561156- */11571157- if (IPIQ[smp_processor_id()].depth > 0) {11581158- struct smtc_ipi *pipi;11591159- extern void self_ipi(struct smtc_ipi *);1160111611611161- if ((pipi = smtc_ipi_dq(&IPIQ[smp_processor_id()])) != NULL) {11621162- self_ipi(pipi);11631163- smtc_cpu_stats[smp_processor_id()].selfipis++;11641164- }11651165- }11171117+ /*11181118+ * Replay any accumulated deferred IPIs. If "Instant Replay"11191119+ * is in use, there should never be any.11201120+ */11211121+#ifndef CONFIG_MIPS_MT_SMTC_INSTANT_REPLAY11221122+ smtc_ipi_replay();11231123+#endif /* CONFIG_MIPS_MT_SMTC_INSTANT_REPLAY */11661124}1167112511681126void smtc_soft_dump(void)
+9-3
arch/mips/vr41xx/common/irq.c
···11/*22 * Interrupt handing routines for NEC VR4100 series.33 *44- * Copyright (C) 2005 Yoichi Yuasa <yoichi_yuasa@tripeaks.co.jp>44+ * Copyright (C) 2005-2007 Yoichi Yuasa <yoichi_yuasa@tripeaks.co.jp>55 *66 * This program is free software; you can redistribute it and/or modify77 * it under the terms of the GNU General Public License as published by···7373 if (cascade->get_irq != NULL) {7474 unsigned int source_irq = irq;7575 desc = irq_desc + source_irq;7676- desc->chip->ack(source_irq);7676+ if (desc->chip->mask_ack)7777+ desc->chip->mask_ack(source_irq);7878+ else {7979+ desc->chip->mask(source_irq);8080+ desc->chip->ack(source_irq);8181+ }7782 irq = cascade->get_irq(irq);7883 if (irq < 0)7984 atomic_inc(&irq_err_count);8085 else8186 irq_dispatch(irq);8282- desc->chip->end(source_irq);8787+ if (!(desc->status & IRQ_DISABLED) && desc->chip->unmask)8888+ desc->chip->unmask(source_irq);8389 } else8490 do_IRQ(irq);8591}
···302302 if ((nmi >= NMI_INVALID) || (nmi < NMI_NONE))303303 return 0;304304305305- if ((nmi == NMI_LOCAL_APIC) && (nmi_known_cpu() == 0))306306- return 0; /* no lapic support */307305 nmi_watchdog = nmi;308306 return 1;309307}
+6-5
block/elevator.c
···590590 */591591 rq->cmd_flags |= REQ_SOFTBARRIER;592592593593+ /*594594+ * Most requeues happen because of a busy condition,595595+ * don't force unplug of the queue for that case.596596+ */597597+ unplug_it = 0;598598+593599 if (q->ordseq == 0) {594600 list_add(&rq->queuelist, &q->queue_head);595601 break;···610604 }611605612606 list_add_tail(&rq->queuelist, pos);613613- /*614614- * most requeues happen because of a busy condition, don't615615- * force unplug of the queue for that case.616616- */617617- unplug_it = 0;618607 break;619608620609 default:
···700700 goto done;701701 }702702 if (buf->state == STATE_QUEUED ||703703+ buf->state == STATE_PREPARED ||703704 buf->state == STATE_ACTIVE) {704705 dprintk(1,"qbuf: buffer is already queued or active.\n");705706 goto done;
+13-2
drivers/mtd/Kconfig
···164164 memory chips, and also use ioctl() to obtain information about165165 the device, or to erase parts of it.166166167167+config MTD_BLKDEVS168168+ tristate "Common interface to block layer for MTD 'translation layers'"169169+ depends on MTD && BLOCK170170+ default n171171+167172config MTD_BLOCK168173 tristate "Caching block device access to MTD devices"169174 depends on MTD && BLOCK175175+ select MTD_BLKDEVS170176 ---help---171177 Although most flash chips have an erase size too large to be useful172178 as block devices, it is possible to use MTD devices which are based···195189config MTD_BLOCK_RO196190 tristate "Readonly block device access to MTD devices"197191 depends on MTD_BLOCK!=y && MTD && BLOCK192192+ select MTD_BLKDEVS198193 help199194 This allows you to mount read-only file systems (such as cramfs)200195 from an MTD device, without the overhead (and danger) of the caching···207200config FTL208201 tristate "FTL (Flash Translation Layer) support"209202 depends on MTD && BLOCK203203+ select MTD_BLKDEVS210204 ---help---211205 This provides support for the original Flash Translation Layer which212206 is part of the PCMCIA specification. It uses a kind of pseudo-···224216config NFTL225217 tristate "NFTL (NAND Flash Translation Layer) support"226218 depends on MTD && BLOCK219219+ select MTD_BLKDEVS227220 ---help---228221 This provides support for the NAND Flash Translation Layer which is229222 used on M-Systems' DiskOnChip devices. It uses a kind of pseudo-···248239config INFTL249240 tristate "INFTL (Inverse NAND Flash Translation Layer) support"250241 depends on MTD && BLOCK242242+ select MTD_BLKDEVS251243 ---help---252244 This provides support for the Inverse NAND Flash Translation253245 Layer which is used on M-Systems' newer DiskOnChip devices. It···266256config RFD_FTL267257 tristate "Resident Flash Disk (Flash Translation Layer) support"268258 depends on MTD && BLOCK259259+ select MTD_BLKDEVS269260 ---help---270261 This provides support for the flash translation layer known271262 as the Resident Flash Disk (RFD), as used by the Embedded BIOS···276265277266config SSFDC278267 tristate "NAND SSFDC (SmartMedia) read only translation layer"279279- depends on MTD280280- default n268268+ depends on MTD && BLOCK269269+ select MTD_BLKDEVS281270 help282271 This enables read only access to SmartMedia formatted NAND283272 flash. You can mount it with FAT file system.
···643643 int reg_idx;644644 int offset;645645646646- mtd = (struct mtd_info*)kmalloc(sizeof(*mtd), GFP_KERNEL);646646+ mtd = kzalloc(sizeof(*mtd), GFP_KERNEL);647647 if (!mtd) {648648 printk(KERN_WARNING649649 "%s: kmalloc failed for info structure\n", map->name);650650 return NULL;651651 }652652- memset(mtd, 0, sizeof(*mtd));653652 mtd->priv = map;654653655654 memset(&temp, 0, sizeof(temp));
+3-2
drivers/mtd/chips/cfi_cmdset_0001.c
···337337 struct mtd_info *mtd;338338 int i;339339340340- mtd = kmalloc(sizeof(*mtd), GFP_KERNEL);340340+ mtd = kzalloc(sizeof(*mtd), GFP_KERNEL);341341 if (!mtd) {342342 printk(KERN_ERR "Failed to allocate memory for MTD device\n");343343 return NULL;344344 }345345- memset(mtd, 0, sizeof(*mtd));346345 mtd->priv = map;347346 mtd->type = MTD_NORFLASH;348347···22232224 case FL_CFI_QUERY:22242225 case FL_JEDEC_QUERY:22252226 if (chip->oldstate == FL_READY) {22272227+ /* place the chip in a known state before suspend */22282228+ map_write(map, CMD(0xFF), cfi->chips[i].start);22262229 chip->oldstate = chip->state;22272230 chip->state = FL_PM_SUSPENDED;22282231 /* No need to wake_up() on this state change -
···154154#define SST39SF010A 0x00B5155155#define SST39SF020A 0x00B6156156#define SST49LF004B 0x0060157157+#define SST49LF040B 0x0050157158#define SST49LF008A 0x005a158159#define SST49LF030A 0x001C159160#define SST49LF040A 0x0051···14021401 }14031402 }, {14041403 .mfr_id = MANUFACTURER_SST,14041404+ .dev_id = SST49LF040B,14051405+ .name = "SST 49LF040B",14061406+ .uaddr = {14071407+ [0] = MTD_UADDR_0x5555_0x2AAA /* x8 */14081408+ },14091409+ .DevSize = SIZE_512KiB,14101410+ .CmdSet = P_ID_AMD_STD,14111411+ .NumEraseRegions= 1,14121412+ .regions = {14131413+ ERASEINFO(0x01000,128),14141414+ }14151415+ }, {14161416+14171417+ .mfr_id = MANUFACTURER_SST,14051418 .dev_id = SST49LF004B,14061419 .name = "SST 49LF004B",14071420 .uaddr = {···188918741890187518911876/*18921892- * There is a BIG problem properly ID'ing the JEDEC devic and guaranteeing18771877+ * There is a BIG problem properly ID'ing the JEDEC device and guaranteeing18931878 * the mapped address, unlock addresses, and proper chip ID. This function18941879 * attempts to minimize errors. It is doubtfull that this probe will ever18951880 * be perfect - consequently there should be some module parameters that
···163163 *num_parts = this_part + 1;164164 alloc_size = *num_parts * sizeof(struct mtd_partition) +165165 extra_mem_size;166166- parts = kmalloc(alloc_size, GFP_KERNEL);166166+ parts = kzalloc(alloc_size, GFP_KERNEL);167167 if (!parts)168168 {169169 printk(KERN_ERR ERRP "out of memory\n");170170 return NULL;171171 }172172- memset(parts, 0, alloc_size);173172 extra_mem = (unsigned char *)(parts + *num_parts);174173 }175174 /* enter this partition (offset will be calculated later if it is zero at this point) */···345346 *346347 * This function needs to be visible for bootloaders.347348 */348348-int mtdpart_setup(char *s)349349+static int mtdpart_setup(char *s)349350{350351 cmdline = s;351352 return 1;
+1-2
drivers/mtd/devices/block2mtd.c
···295295 if (!devname)296296 return NULL;297297298298- dev = kmalloc(sizeof(struct block2mtd_dev), GFP_KERNEL);298298+ dev = kzalloc(sizeof(struct block2mtd_dev), GFP_KERNEL);299299 if (!dev)300300 return NULL;301301- memset(dev, 0, sizeof(*dev));302301303302 /* Get a handle on the device */304303 bdev = open_bdev_excl(devname, O_RDWR, NULL);
···126126 struct phram_mtd_list *new;127127 int ret = -ENOMEM;128128129129- new = kmalloc(sizeof(*new), GFP_KERNEL);129129+ new = kzalloc(sizeof(*new), GFP_KERNEL);130130 if (!new)131131 goto out0;132132-133133- memset(new, 0, sizeof(*new));134132135133 ret = -EIO;136134 new->mtd.priv = ioremap(start, len);
···6060 Ignore this option if you use run-time physmap configuration6161 (i.e., run-time calling physmap_configure()).62626363+config MTD_PHYSMAP_OF6464+ tristate "Flash device in physical memory map based on OF descirption"6565+ depends on PPC_OF && (MTD_CFI || MTD_JEDECPROBE || MTD_ROM)6666+ help6767+ This provides a 'mapping' driver which allows the NOR Flash and6868+ ROM driver code to communicate with chips which are mapped6969+ physically into the CPU's memory. The mapping description here is7070+ taken from OF device tree.7171+6372config MTD_SUN_UFLASH6473 tristate "Sun Microsystems userflash support"6574 depends on SPARC && MTD_CFI···189180 depends on X86 && MTD_JEDECPROBE190181 help191182 Support for treating the BIOS flash chip on ICHX motherboards183183+ as an MTD device - with this you can reprogram your BIOS.184184+185185+ BE VERY CAREFUL.186186+187187+config MTD_ESB2ROM188188+ tristate "BIOS flash chip on Intel ESB Controller Hub 2"189189+ depends on X86 && MTD_JEDECPROBE && PCI190190+ help191191+ Support for treating the BIOS flash chip on ESB2 motherboards192192+ as an MTD device - with this you can reprogram your BIOS.193193+194194+ BE VERY CAREFUL.195195+196196+config MTD_CK804XROM197197+ tristate "BIOS flash chip on Nvidia CK804"198198+ depends on X86 && MTD_JEDECPROBE199199+ help200200+ Support for treating the BIOS flash chip on nvidia motherboards192201 as an MTD device - with this you can reprogram your BIOS.193202194203 BE VERY CAREFUL.···381354 This enables access routines for the flash chips on the382355 TQ Components TQM834x boards. If you have one of these boards383356 and would like to use the flash chips on it, say 'Y'.384384-385385-config MTD_CSTM_MIPS_IXX386386- tristate "Flash chip mapping on ITE QED-4N-S01B, Globespan IVR or custom board"387387- depends on MIPS && MTD_CFI && MTD_JEDECPROBE && MTD_PARTITIONS388388- help389389- This provides a mapping driver for the Integrated Technology390390- Express, Inc (ITE) QED-4N-S01B eval board and the Globespan IVR391391- Reference Board. It provides the necessary addressing, length,392392- buswidth, vpp code and addition setup of the flash device for393393- these boards. In addition, this mapping driver can be used for394394- other boards via setting of the CONFIG_MTD_CSTM_MIPS_IXX_START/395395- LEN/BUSWIDTH parameters. This mapping will provide one mtd device396396- using one partition. The start address can be offset from the397397- beginning of flash and the len can be less than the total flash398398- device size to allow a window into the flash. Both CFI and JEDEC399399- probes are called.400400-401401-config MTD_CSTM_MIPS_IXX_START402402- hex "Physical start address of flash mapping"403403- depends on MTD_CSTM_MIPS_IXX404404- default "0x8000000"405405- help406406- This is the physical memory location that the MTD driver will407407- use for the flash chips on your particular target board.408408- Refer to the memory map which should hopefully be in the409409- documentation for your board.410410-411411-config MTD_CSTM_MIPS_IXX_LEN412412- hex "Physical length of flash mapping"413413- depends on MTD_CSTM_MIPS_IXX414414- default "0x4000000"415415- help416416- This is the total length that the MTD driver will use for the417417- flash chips on your particular board. Refer to the memory418418- map which should hopefully be in the documentation for your419419- board.420420-421421-config MTD_CSTM_MIPS_IXX_BUSWIDTH422422- int "Bus width in octets"423423- depends on MTD_CSTM_MIPS_IXX424424- default "2"425425- help426426- This is the total bus width of the mapping of the flash chips427427- on your particular board.428357429358config MTD_OCELOT430359 tristate "Momenco Ocelot boot flash device"
···7788#include <linux/module.h>99#include <linux/types.h>1010+#include <linux/version.h>1011#include <linux/kernel.h>1112#include <linux/init.h>1213#include <asm/io.h>···4443 struct resource rsrc;4544 char map_name[sizeof(MOD_NAME) + 2 + ADDRESS_NAME_LEN];4645};4646+4747+/* The 2 bits controlling the window size are often set to allow reading4848+ * the BIOS, but too small to allow writing, since the lock registers are4949+ * 4MiB lower in the address space than the data.5050+ *5151+ * This is intended to prevent flashing the bios, perhaps accidentally.5252+ *5353+ * This parameter allows the normal driver to over-ride the BIOS settings.5454+ *5555+ * The bits are 6 and 7. If both bits are set, it is a 5MiB window.5656+ * If only the 7 Bit is set, it is a 4MiB window. Otherwise, a5757+ * 64KiB window.5858+ *5959+ */6060+static uint win_size_bits;6161+module_param(win_size_bits, uint, 0);6262+MODULE_PARM_DESC(win_size_bits, "ROM window size bits override for 0x43 byte, normally set by BIOS.");47634864static struct amd76xrom_window amd76xrom_window = {4965 .maps = LIST_HEAD_INIT(amd76xrom_window.maps),···11395 /* Remember the pci dev I find the window in - already have a ref */11496 window->pdev = pdev;115979898+ /* Enable the selected rom window. This is often incorrectly9999+ * set up by the BIOS, and the 4MiB offset for the lock registers100100+ * requires the full 5MiB of window space.101101+ *102102+ * This 'write, then read' approach leaves the bits for103103+ * other uses of the hardware info.104104+ */105105+ pci_read_config_byte(pdev, 0x43, &byte);106106+ pci_write_config_byte(pdev, 0x43, byte | win_size_bits );107107+116108 /* Assume the rom window is properly setup, and find it's size */117109 pci_read_config_byte(pdev, 0x43, &byte);118110 if ((byte & ((1<<7)|(1<<6))) == ((1<<7)|(1<<6))) {···157129 (unsigned long long)window->rsrc.end);158130 }159131160160-#if 0161161-162162- /* Enable the selected rom window */163163- pci_read_config_byte(pdev, 0x43, &byte);164164- pci_write_config_byte(pdev, 0x43, byte | rwindow->segen_bits);165165-#endif166132167133 /* Enable writes through the rom window */168134 pci_read_config_byte(pdev, 0x40, &byte);
···122122 /*123123 * Allocate the map_info structs in one go.124124 */125125- maps = kmalloc(sizeof(struct map_info) * nr, GFP_KERNEL);125125+ maps = kzalloc(sizeof(struct map_info) * nr, GFP_KERNEL);126126 if (!maps)127127 return -ENOMEM;128128- memset(maps, 0, sizeof(struct map_info) * nr);129128 /*130129 * Claim and then map the memory regions.131130 */
+356
drivers/mtd/maps/ck804xrom.c
···11+/*22+ * ck804xrom.c33+ *44+ * Normal mappings of chips in physical memory55+ *66+ * Dave Olsen <dolsen@lnxi.com>77+ * Ryan Jackson <rjackson@lnxi.com>88+ */99+1010+#include <linux/module.h>1111+#include <linux/types.h>1212+#include <linux/version.h>1313+#include <linux/kernel.h>1414+#include <linux/init.h>1515+#include <asm/io.h>1616+#include <linux/mtd/mtd.h>1717+#include <linux/mtd/map.h>1818+#include <linux/mtd/cfi.h>1919+#include <linux/mtd/flashchip.h>2020+#include <linux/pci.h>2121+#include <linux/pci_ids.h>2222+#include <linux/list.h>2323+2424+2525+#define MOD_NAME KBUILD_BASENAME2626+2727+#define ADDRESS_NAME_LEN 182828+2929+#define ROM_PROBE_STEP_SIZE (64*1024)3030+3131+struct ck804xrom_window {3232+ void __iomem *virt;3333+ unsigned long phys;3434+ unsigned long size;3535+ struct list_head maps;3636+ struct resource rsrc;3737+ struct pci_dev *pdev;3838+};3939+4040+struct ck804xrom_map_info {4141+ struct list_head list;4242+ struct map_info map;4343+ struct mtd_info *mtd;4444+ struct resource rsrc;4545+ char map_name[sizeof(MOD_NAME) + 2 + ADDRESS_NAME_LEN];4646+};4747+4848+4949+/* The 2 bits controlling the window size are often set to allow reading5050+ * the BIOS, but too small to allow writing, since the lock registers are5151+ * 4MiB lower in the address space than the data.5252+ *5353+ * This is intended to prevent flashing the bios, perhaps accidentally.5454+ *5555+ * This parameter allows the normal driver to override the BIOS settings.5656+ *5757+ * The bits are 6 and 7. If both bits are set, it is a 5MiB window.5858+ * If only the 7 Bit is set, it is a 4MiB window. Otherwise, a5959+ * 64KiB window.6060+ *6161+ */6262+static uint win_size_bits = 0;6363+module_param(win_size_bits, uint, 0);6464+MODULE_PARM_DESC(win_size_bits, "ROM window size bits override for 0x88 byte, normally set by BIOS.");6565+6666+static struct ck804xrom_window ck804xrom_window = {6767+ .maps = LIST_HEAD_INIT(ck804xrom_window.maps),6868+};6969+7070+static void ck804xrom_cleanup(struct ck804xrom_window *window)7171+{7272+ struct ck804xrom_map_info *map, *scratch;7373+ u8 byte;7474+7575+ if (window->pdev) {7676+ /* Disable writes through the rom window */7777+ pci_read_config_byte(window->pdev, 0x6d, &byte);7878+ pci_write_config_byte(window->pdev, 0x6d, byte & ~1);7979+ }8080+8181+ /* Free all of the mtd devices */8282+ list_for_each_entry_safe(map, scratch, &window->maps, list) {8383+ if (map->rsrc.parent)8484+ release_resource(&map->rsrc);8585+8686+ del_mtd_device(map->mtd);8787+ map_destroy(map->mtd);8888+ list_del(&map->list);8989+ kfree(map);9090+ }9191+ if (window->rsrc.parent)9292+ release_resource(&window->rsrc);9393+9494+ if (window->virt) {9595+ iounmap(window->virt);9696+ window->virt = NULL;9797+ window->phys = 0;9898+ window->size = 0;9999+ }100100+ pci_dev_put(window->pdev);101101+}102102+103103+104104+static int __devinit ck804xrom_init_one (struct pci_dev *pdev,105105+ const struct pci_device_id *ent)106106+{107107+ static char *rom_probe_types[] = { "cfi_probe", "jedec_probe", NULL };108108+ u8 byte;109109+ struct ck804xrom_window *window = &ck804xrom_window;110110+ struct ck804xrom_map_info *map = NULL;111111+ unsigned long map_top;112112+113113+ /* Remember the pci dev I find the window in */114114+ window->pdev = pci_dev_get(pdev);115115+116116+ /* Enable the selected rom window. This is often incorrectly117117+ * set up by the BIOS, and the 4MiB offset for the lock registers118118+ * requires the full 5MiB of window space.119119+ *120120+ * This 'write, then read' approach leaves the bits for121121+ * other uses of the hardware info.122122+ */123123+ pci_read_config_byte(pdev, 0x88, &byte);124124+ pci_write_config_byte(pdev, 0x88, byte | win_size_bits );125125+126126+127127+ /* Assume the rom window is properly setup, and find it's size */128128+ pci_read_config_byte(pdev, 0x88, &byte);129129+130130+ if ((byte & ((1<<7)|(1<<6))) == ((1<<7)|(1<<6)))131131+ window->phys = 0xffb00000; /* 5MiB */132132+ else if ((byte & (1<<7)) == (1<<7))133133+ window->phys = 0xffc00000; /* 4MiB */134134+ else135135+ window->phys = 0xffff0000; /* 64KiB */136136+137137+ window->size = 0xffffffffUL - window->phys + 1UL;138138+139139+ /*140140+ * Try to reserve the window mem region. If this fails then141141+ * it is likely due to a fragment of the window being142142+ * "reserved" by the BIOS. In the case that the143143+ * request_mem_region() fails then once the rom size is144144+ * discovered we will try to reserve the unreserved fragment.145145+ */146146+ window->rsrc.name = MOD_NAME;147147+ window->rsrc.start = window->phys;148148+ window->rsrc.end = window->phys + window->size - 1;149149+ window->rsrc.flags = IORESOURCE_MEM | IORESOURCE_BUSY;150150+ if (request_resource(&iomem_resource, &window->rsrc)) {151151+ window->rsrc.parent = NULL;152152+ printk(KERN_ERR MOD_NAME153153+ " %s(): Unable to register resource"154154+ " 0x%.016llx-0x%.016llx - kernel bug?\n",155155+ __func__,156156+ (unsigned long long)window->rsrc.start,157157+ (unsigned long long)window->rsrc.end);158158+ }159159+160160+161161+ /* Enable writes through the rom window */162162+ pci_read_config_byte(pdev, 0x6d, &byte);163163+ pci_write_config_byte(pdev, 0x6d, byte | 1);164164+165165+ /* FIXME handle registers 0x80 - 0x8C the bios region locks */166166+167167+ /* For write accesses caches are useless */168168+ window->virt = ioremap_nocache(window->phys, window->size);169169+ if (!window->virt) {170170+ printk(KERN_ERR MOD_NAME ": ioremap(%08lx, %08lx) failed\n",171171+ window->phys, window->size);172172+ goto out;173173+ }174174+175175+ /* Get the first address to look for a rom chip at */176176+ map_top = window->phys;177177+#if 1178178+ /* The probe sequence run over the firmware hub lock179179+ * registers sets them to 0x7 (no access).180180+ * Probe at most the last 4MiB of the address space.181181+ */182182+ if (map_top < 0xffc00000)183183+ map_top = 0xffc00000;184184+#endif185185+ /* Loop through and look for rom chips. Since we don't know the186186+ * starting address for each chip, probe every ROM_PROBE_STEP_SIZE187187+ * bytes from the starting address of the window.188188+ */189189+ while((map_top - 1) < 0xffffffffUL) {190190+ struct cfi_private *cfi;191191+ unsigned long offset;192192+ int i;193193+194194+ if (!map)195195+ map = kmalloc(sizeof(*map), GFP_KERNEL);196196+197197+ if (!map) {198198+ printk(KERN_ERR MOD_NAME ": kmalloc failed");199199+ goto out;200200+ }201201+ memset(map, 0, sizeof(*map));202202+ INIT_LIST_HEAD(&map->list);203203+ map->map.name = map->map_name;204204+ map->map.phys = map_top;205205+ offset = map_top - window->phys;206206+ map->map.virt = (void __iomem *)207207+ (((unsigned long)(window->virt)) + offset);208208+ map->map.size = 0xffffffffUL - map_top + 1UL;209209+ /* Set the name of the map to the address I am trying */210210+ sprintf(map->map_name, "%s @%08lx",211211+ MOD_NAME, map->map.phys);212212+213213+ /* There is no generic VPP support */214214+ for(map->map.bankwidth = 32; map->map.bankwidth;215215+ map->map.bankwidth >>= 1)216216+ {217217+ char **probe_type;218218+ /* Skip bankwidths that are not supported */219219+ if (!map_bankwidth_supported(map->map.bankwidth))220220+ continue;221221+222222+ /* Setup the map methods */223223+ simple_map_init(&map->map);224224+225225+ /* Try all of the probe methods */226226+ probe_type = rom_probe_types;227227+ for(; *probe_type; probe_type++) {228228+ map->mtd = do_map_probe(*probe_type, &map->map);229229+ if (map->mtd)230230+ goto found;231231+ }232232+ }233233+ map_top += ROM_PROBE_STEP_SIZE;234234+ continue;235235+ found:236236+ /* Trim the size if we are larger than the map */237237+ if (map->mtd->size > map->map.size) {238238+ printk(KERN_WARNING MOD_NAME239239+ " rom(%u) larger than window(%lu). fixing...\n",240240+ map->mtd->size, map->map.size);241241+ map->mtd->size = map->map.size;242242+ }243243+ if (window->rsrc.parent) {244244+ /*245245+ * Registering the MTD device in iomem may not be possible246246+ * if there is a BIOS "reserved" and BUSY range. If this247247+ * fails then continue anyway.248248+ */249249+ map->rsrc.name = map->map_name;250250+ map->rsrc.start = map->map.phys;251251+ map->rsrc.end = map->map.phys + map->mtd->size - 1;252252+ map->rsrc.flags = IORESOURCE_MEM | IORESOURCE_BUSY;253253+ if (request_resource(&window->rsrc, &map->rsrc)) {254254+ printk(KERN_ERR MOD_NAME255255+ ": cannot reserve MTD resource\n");256256+ map->rsrc.parent = NULL;257257+ }258258+ }259259+260260+ /* Make the whole region visible in the map */261261+ map->map.virt = window->virt;262262+ map->map.phys = window->phys;263263+ cfi = map->map.fldrv_priv;264264+ for(i = 0; i < cfi->numchips; i++)265265+ cfi->chips[i].start += offset;266266+267267+ /* Now that the mtd devices is complete claim and export it */268268+ map->mtd->owner = THIS_MODULE;269269+ if (add_mtd_device(map->mtd)) {270270+ map_destroy(map->mtd);271271+ map->mtd = NULL;272272+ goto out;273273+ }274274+275275+276276+ /* Calculate the new value of map_top */277277+ map_top += map->mtd->size;278278+279279+ /* File away the map structure */280280+ list_add(&map->list, &window->maps);281281+ map = NULL;282282+ }283283+284284+ out:285285+ /* Free any left over map structures */286286+ if (map)287287+ kfree(map);288288+289289+ /* See if I have any map structures */290290+ if (list_empty(&window->maps)) {291291+ ck804xrom_cleanup(window);292292+ return -ENODEV;293293+ }294294+ return 0;295295+}296296+297297+298298+static void __devexit ck804xrom_remove_one (struct pci_dev *pdev)299299+{300300+ struct ck804xrom_window *window = &ck804xrom_window;301301+302302+ ck804xrom_cleanup(window);303303+}304304+305305+static struct pci_device_id ck804xrom_pci_tbl[] = {306306+ { PCI_VENDOR_ID_NVIDIA, 0x0051,307307+ PCI_ANY_ID, PCI_ANY_ID, }, /* nvidia ck804 */308308+ { 0, }309309+};310310+311311+MODULE_DEVICE_TABLE(pci, ck804xrom_pci_tbl);312312+313313+#if 0314314+static struct pci_driver ck804xrom_driver = {315315+ .name = MOD_NAME,316316+ .id_table = ck804xrom_pci_tbl,317317+ .probe = ck804xrom_init_one,318318+ .remove = ck804xrom_remove_one,319319+};320320+#endif321321+322322+static int __init init_ck804xrom(void)323323+{324324+ struct pci_dev *pdev;325325+ struct pci_device_id *id;326326+ int retVal;327327+ pdev = NULL;328328+329329+ for(id = ck804xrom_pci_tbl; id->vendor; id++) {330330+ pdev = pci_find_device(id->vendor, id->device, NULL);331331+ if (pdev)332332+ break;333333+ }334334+ if (pdev) {335335+ retVal = ck804xrom_init_one(pdev, &ck804xrom_pci_tbl[0]);336336+ pci_dev_put(pdev);337337+ return retVal;338338+ }339339+ return -ENXIO;340340+#if 0341341+ return pci_module_init(&ck804xrom_driver);342342+#endif343343+}344344+345345+static void __exit cleanup_ck804xrom(void)346346+{347347+ ck804xrom_remove_one(ck804xrom_window.pdev);348348+}349349+350350+module_init(init_ck804xrom);351351+module_exit(cleanup_ck804xrom);352352+353353+MODULE_LICENSE("GPL");354354+MODULE_AUTHOR("Eric Biederman <ebiederman@lnxi.com>, Dave Olsen <dolsen@lnxi.com>");355355+MODULE_DESCRIPTION("MTD map driver for BIOS chips on the Nvidia ck804 southbridge");356356+
-283
drivers/mtd/maps/cstm_mips_ixx.c
···11-/*22- * $Id: cstm_mips_ixx.c,v 1.14 2005/11/07 11:14:26 gleixner Exp $33- *44- * Mapping of a custom board with both AMD CFI and JEDEC flash in partitions.55- * Config with both CFI and JEDEC device support.66- *77- * Basically physmap.c with the addition of partitions and88- * an array of mapping info to accomodate more than one flash type per board.99- *1010- * Copyright 2000 MontaVista Software Inc.1111- *1212- * This program is free software; you can redistribute it and/or modify it1313- * under the terms of the GNU General Public License as published by the1414- * Free Software Foundation; either version 2 of the License, or (at your1515- * option) any later version.1616- *1717- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED1818- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF1919- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN2020- * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,2121- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT2222- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF2323- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON2424- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT2525- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF2626- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.2727- *2828- * You should have received a copy of the GNU General Public License along2929- * with this program; if not, write to the Free Software Foundation, Inc.,3030- * 675 Mass Ave, Cambridge, MA 02139, USA.3131- */3232-3333-#include <linux/module.h>3434-#include <linux/types.h>3535-#include <linux/kernel.h>3636-#include <linux/init.h>3737-#include <asm/io.h>3838-#include <linux/mtd/mtd.h>3939-#include <linux/mtd/map.h>4040-#include <linux/mtd/partitions.h>4141-#include <linux/delay.h>4242-4343-#if defined(CONFIG_MIPS_ITE8172) || defined(CONFIG_MIPS_IVR)4444-#define CC_GCR 0xB40138184545-#define CC_GPBCR 0xB401380A4646-#define CC_GPBDR 0xB40138084747-#define CC_M68K_DEVICE 14848-#define CC_M68K_FUNCTION 64949-#define CC_CONFADDR 0xB80040005050-#define CC_CONFDATA 0xB80040045151-#define CC_FC_FCR 0xB80020045252-#define CC_FC_DCR 0xB80020085353-#define CC_GPACR 0xB40138025454-#define CC_GPAICR 0xB40138045555-#endif /* defined(CONFIG_MIPS_ITE8172) || defined(CONFIG_MIPS_IVR) */5656-5757-#if defined(CONFIG_MIPS_ITE8172) || defined(CONFIG_MIPS_IVR)5858-void cstm_mips_ixx_set_vpp(struct map_info *map,int vpp)5959-{6060- static DEFINE_SPINLOCK(vpp_lock);6161- static int vpp_count = 0;6262- unsigned long flags;6363-6464- spin_lock_irqsave(&vpp_lock, flags);6565-6666- if (vpp) {6767- if (!vpp_count++) {6868- __u16 data;6969- __u8 data1;7070- static u8 first = 1;7171-7272- // Set GPIO port B pin3 to high7373- data = *(__u16 *)(CC_GPBCR);7474- data = (data & 0xff0f) | 0x0040;7575- *(__u16 *)CC_GPBCR = data;7676- *(__u8 *)CC_GPBDR = (*(__u8*)CC_GPBDR) | 0x08;7777- if (first) {7878- first = 0;7979- /* need to have this delay for first8080- enabling vpp after powerup */8181- udelay(40);8282- }8383- }8484- } else {8585- if (!--vpp_count) {8686- __u16 data;8787-8888- // Set GPIO port B pin3 to high8989- data = *(__u16 *)(CC_GPBCR);9090- data = (data & 0xff3f) | 0x0040;9191- *(__u16 *)CC_GPBCR = data;9292- *(__u8 *)CC_GPBDR = (*(__u8*)CC_GPBDR) & 0xf7;9393- }9494- }9595- spin_unlock_irqrestore(&vpp_lock, flags);9696-}9797-#endif9898-9999-/* board and partition description */100100-101101-#define MAX_PHYSMAP_PARTITIONS 8102102-struct cstm_mips_ixx_info {103103- char *name;104104- unsigned long window_addr;105105- unsigned long window_size;106106- int bankwidth;107107- int num_partitions;108108-};109109-110110-#if defined(CONFIG_MIPS_ITE8172) || defined(CONFIG_MIPS_IVR)111111-#define PHYSMAP_NUMBER 1 // number of board desc structs needed, one per contiguous flash type112112-const struct cstm_mips_ixx_info cstm_mips_ixx_board_desc[PHYSMAP_NUMBER] =113113-{114114- { // 28F128J3A in 2x16 configuration115115- "big flash", // name116116- 0x08000000, // window_addr117117- 0x02000000, // window_size118118- 4, // bankwidth119119- 1, // num_partitions120120- }121121-122122-};123123-static struct mtd_partition cstm_mips_ixx_partitions[PHYSMAP_NUMBER][MAX_PHYSMAP_PARTITIONS] = {124124-{ // 28F128J3A in 2x16 configuration125125- {126126- .name = "main partition ",127127- .size = 0x02000000, // 128 x 2 x 128k byte sectors128128- .offset = 0,129129- },130130-},131131-};132132-#else /* defined(CONFIG_MIPS_ITE8172) || defined(CONFIG_MIPS_IVR) */133133-#define PHYSMAP_NUMBER 1 // number of board desc structs needed, one per contiguous flash type134134-const struct cstm_mips_ixx_info cstm_mips_ixx_board_desc[PHYSMAP_NUMBER] =135135-{136136- {137137- "MTD flash", // name138138- CONFIG_MTD_CSTM_MIPS_IXX_START, // window_addr139139- CONFIG_MTD_CSTM_MIPS_IXX_LEN, // window_size140140- CONFIG_MTD_CSTM_MIPS_IXX_BUSWIDTH, // bankwidth141141- 1, // num_partitions142142- },143143-144144-};145145-static struct mtd_partition cstm_mips_ixx_partitions[PHYSMAP_NUMBER][MAX_PHYSMAP_PARTITIONS] = {146146-{147147- {148148- .name = "main partition",149149- .size = CONFIG_MTD_CSTM_MIPS_IXX_LEN,150150- .offset = 0,151151- },152152-},153153-};154154-#endif /* defined(CONFIG_MIPS_ITE8172) || defined(CONFIG_MIPS_IVR) */155155-156156-struct map_info cstm_mips_ixx_map[PHYSMAP_NUMBER];157157-158158-int __init init_cstm_mips_ixx(void)159159-{160160- int i;161161- int jedec;162162- struct mtd_info *mymtd;163163- struct mtd_partition *parts;164164-165165- /* Initialize mapping */166166- for (i=0;i<PHYSMAP_NUMBER;i++) {167167- printk(KERN_NOTICE "cstm_mips_ixx flash device: 0x%lx at 0x%lx\n",168168- cstm_mips_ixx_board_desc[i].window_size, cstm_mips_ixx_board_desc[i].window_addr);169169-170170-171171- cstm_mips_ixx_map[i].phys = cstm_mips_ixx_board_desc[i].window_addr;172172- cstm_mips_ixx_map[i].virt = ioremap(cstm_mips_ixx_board_desc[i].window_addr, cstm_mips_ixx_board_desc[i].window_size);173173- if (!cstm_mips_ixx_map[i].virt) {174174- int j = 0;175175- printk(KERN_WARNING "Failed to ioremap\n");176176- for (j = 0; j < i; j++) {177177- if (cstm_mips_ixx_map[j].virt) {178178- iounmap(cstm_mips_ixx_map[j].virt);179179- cstm_mips_ixx_map[j].virt = NULL;180180- }181181- }182182- return -EIO;183183- }184184- cstm_mips_ixx_map[i].name = cstm_mips_ixx_board_desc[i].name;185185- cstm_mips_ixx_map[i].size = cstm_mips_ixx_board_desc[i].window_size;186186- cstm_mips_ixx_map[i].bankwidth = cstm_mips_ixx_board_desc[i].bankwidth;187187-#if defined(CONFIG_MIPS_ITE8172) || defined(CONFIG_MIPS_IVR)188188- cstm_mips_ixx_map[i].set_vpp = cstm_mips_ixx_set_vpp;189189-#endif190190- simple_map_init(&cstm_mips_ixx_map[i]);191191- //printk(KERN_NOTICE "cstm_mips_ixx: ioremap is %x\n",(unsigned int)(cstm_mips_ixx_map[i].virt));192192- }193193-194194-#if defined(CONFIG_MIPS_ITE8172) || defined(CONFIG_MIPS_IVR)195195- setup_ITE_IVR_flash();196196-#endif /* defined(CONFIG_MIPS_ITE8172) || defined(CONFIG_MIPS_IVR) */197197-198198- for (i=0;i<PHYSMAP_NUMBER;i++) {199199- parts = &cstm_mips_ixx_partitions[i][0];200200- jedec = 0;201201- mymtd = (struct mtd_info *)do_map_probe("cfi_probe", &cstm_mips_ixx_map[i]);202202- //printk(KERN_NOTICE "phymap %d cfi_probe: mymtd is %x\n",i,(unsigned int)mymtd);203203- if (!mymtd) {204204- jedec = 1;205205- mymtd = (struct mtd_info *)do_map_probe("jedec", &cstm_mips_ixx_map[i]);206206- printk(KERN_NOTICE "cstm_mips_ixx %d jedec: mymtd is %x\n",i,(unsigned int)mymtd);207207- }208208- if (mymtd) {209209- mymtd->owner = THIS_MODULE;210210-211211- cstm_mips_ixx_map[i].map_priv_2 = (unsigned long)mymtd;212212- add_mtd_partitions(mymtd, parts, cstm_mips_ixx_board_desc[i].num_partitions);213213- }214214- else {215215- for (i = 0; i < PHYSMAP_NUMBER; i++) {216216- if (cstm_mips_ixx_map[i].virt) {217217- iounmap(cstm_mips_ixx_map[i].virt);218218- cstm_mips_ixx_map[i].virt = NULL;219219- }220220- }221221- return -ENXIO;222222- }223223- }224224- return 0;225225-}226226-227227-static void __exit cleanup_cstm_mips_ixx(void)228228-{229229- int i;230230- struct mtd_info *mymtd;231231-232232- for (i=0;i<PHYSMAP_NUMBER;i++) {233233- mymtd = (struct mtd_info *)cstm_mips_ixx_map[i].map_priv_2;234234- if (mymtd) {235235- del_mtd_partitions(mymtd);236236- map_destroy(mymtd);237237- }238238- if (cstm_mips_ixx_map[i].virt) {239239- iounmap((void *)cstm_mips_ixx_map[i].virt);240240- cstm_mips_ixx_map[i].virt = 0;241241- }242242- }243243-}244244-#if defined(CONFIG_MIPS_ITE8172) || defined(CONFIG_MIPS_IVR)245245-void PCISetULongByOffset(__u32 DevNumber, __u32 FuncNumber, __u32 Offset, __u32 data)246246-{247247- __u32 offset;248248-249249- offset = ( unsigned long )( 0x80000000 | ( DevNumber << 11 ) + ( FuncNumber << 8 ) + Offset) ;250250-251251- *(__u32 *)CC_CONFADDR = offset;252252- *(__u32 *)CC_CONFDATA = data;253253-}254254-void setup_ITE_IVR_flash()255255-{256256- __u32 size, base;257257-258258- size = 0x0e000000; // 32MiB259259- base = (0x08000000) >> 8 >>1; // Bug: we must shift one more bit260260-261261- /* need to set ITE flash to 32 bits instead of default 8 */262262-#ifdef CONFIG_MIPS_IVR263263- *(__u32 *)CC_FC_FCR = 0x55;264264- *(__u32 *)CC_GPACR = 0xfffc;265265-#else266266- *(__u32 *)CC_FC_FCR = 0x77;267267-#endif268268- /* turn bursting off */269269- *(__u32 *)CC_FC_DCR = 0x0;270270-271271- /* setup for one chip 4 byte PCI access */272272- PCISetULongByOffset(CC_M68K_DEVICE, CC_M68K_FUNCTION, 0x60, size | base);273273- PCISetULongByOffset(CC_M68K_DEVICE, CC_M68K_FUNCTION, 0x64, 0x02);274274-}275275-#endif /* defined(CONFIG_MIPS_ITE8172) || defined(CONFIG_MIPS_IVR) */276276-277277-module_init(init_cstm_mips_ixx);278278-module_exit(cleanup_cstm_mips_ixx);279279-280280-281281-MODULE_LICENSE("GPL");282282-MODULE_AUTHOR("Alice Hennessy <ahennessy@mvista.com>");283283-MODULE_DESCRIPTION("MTD map driver for ITE 8172G and Globespan IVR boards");
+450
drivers/mtd/maps/esb2rom.c
···11+/*22+ * esb2rom.c33+ *44+ * Normal mappings of flash chips in physical memory55+ * through the Intel ESB2 Southbridge.66+ *77+ * This was derived from ichxrom.c in May 2006 by88+ * Lew Glendenning <lglendenning@lnxi.com>99+ *1010+ * Eric Biederman, of course, was a major help in this effort.1111+ */1212+1313+#include <linux/module.h>1414+#include <linux/types.h>1515+#include <linux/version.h>1616+#include <linux/kernel.h>1717+#include <linux/init.h>1818+#include <asm/io.h>1919+#include <linux/mtd/mtd.h>2020+#include <linux/mtd/map.h>2121+#include <linux/mtd/cfi.h>2222+#include <linux/mtd/flashchip.h>2323+#include <linux/pci.h>2424+#include <linux/pci_ids.h>2525+#include <linux/list.h>2626+2727+#define MOD_NAME KBUILD_BASENAME2828+2929+#define ADDRESS_NAME_LEN 183030+3131+#define ROM_PROBE_STEP_SIZE (64*1024) /* 64KiB */3232+3333+#define BIOS_CNTL 0xDC3434+#define BIOS_LOCK_ENABLE 0x023535+#define BIOS_WRITE_ENABLE 0x013636+3737+/* This became a 16-bit register, and EN2 has disappeared */3838+#define FWH_DEC_EN1 0xD83939+#define FWH_F8_EN 0x80004040+#define FWH_F0_EN 0x40004141+#define FWH_E8_EN 0x20004242+#define FWH_E0_EN 0x10004343+#define FWH_D8_EN 0x08004444+#define FWH_D0_EN 0x04004545+#define FWH_C8_EN 0x02004646+#define FWH_C0_EN 0x01004747+#define FWH_LEGACY_F_EN 0x00804848+#define FWH_LEGACY_E_EN 0x00404949+/* reserved 0x0020 and 0x0010 */5050+#define FWH_70_EN 0x00085151+#define FWH_60_EN 0x00045252+#define FWH_50_EN 0x00025353+#define FWH_40_EN 0x00015454+5555+/* these are 32-bit values */5656+#define FWH_SEL1 0xD05757+#define FWH_SEL2 0xD45858+5959+#define FWH_8MiB (FWH_F8_EN | FWH_F0_EN | FWH_E8_EN | FWH_E0_EN | \6060+ FWH_D8_EN | FWH_D0_EN | FWH_C8_EN | FWH_C0_EN | \6161+ FWH_70_EN | FWH_60_EN | FWH_50_EN | FWH_40_EN)6262+6363+#define FWH_7MiB (FWH_F8_EN | FWH_F0_EN | FWH_E8_EN | FWH_E0_EN | \6464+ FWH_D8_EN | FWH_D0_EN | FWH_C8_EN | FWH_C0_EN | \6565+ FWH_70_EN | FWH_60_EN | FWH_50_EN)6666+6767+#define FWH_6MiB (FWH_F8_EN | FWH_F0_EN | FWH_E8_EN | FWH_E0_EN | \6868+ FWH_D8_EN | FWH_D0_EN | FWH_C8_EN | FWH_C0_EN | \6969+ FWH_70_EN | FWH_60_EN)7070+7171+#define FWH_5MiB (FWH_F8_EN | FWH_F0_EN | FWH_E8_EN | FWH_E0_EN | \7272+ FWH_D8_EN | FWH_D0_EN | FWH_C8_EN | FWH_C0_EN | \7373+ FWH_70_EN)7474+7575+#define FWH_4MiB (FWH_F8_EN | FWH_F0_EN | FWH_E8_EN | FWH_E0_EN | \7676+ FWH_D8_EN | FWH_D0_EN | FWH_C8_EN | FWH_C0_EN)7777+7878+#define FWH_3_5MiB (FWH_F8_EN | FWH_F0_EN | FWH_E8_EN | FWH_E0_EN | \7979+ FWH_D8_EN | FWH_D0_EN | FWH_C8_EN)8080+8181+#define FWH_3MiB (FWH_F8_EN | FWH_F0_EN | FWH_E8_EN | FWH_E0_EN | \8282+ FWH_D8_EN | FWH_D0_EN)8383+8484+#define FWH_2_5MiB (FWH_F8_EN | FWH_F0_EN | FWH_E8_EN | FWH_E0_EN | \8585+ FWH_D8_EN)8686+8787+#define FWH_2MiB (FWH_F8_EN | FWH_F0_EN | FWH_E8_EN | FWH_E0_EN)8888+8989+#define FWH_1_5MiB (FWH_F8_EN | FWH_F0_EN | FWH_E8_EN)9090+9191+#define FWH_1MiB (FWH_F8_EN | FWH_F0_EN)9292+9393+#define FWH_0_5MiB (FWH_F8_EN)9494+9595+9696+struct esb2rom_window {9797+ void __iomem* virt;9898+ unsigned long phys;9999+ unsigned long size;100100+ struct list_head maps;101101+ struct resource rsrc;102102+ struct pci_dev *pdev;103103+};104104+105105+struct esb2rom_map_info {106106+ struct list_head list;107107+ struct map_info map;108108+ struct mtd_info *mtd;109109+ struct resource rsrc;110110+ char map_name[sizeof(MOD_NAME) + 2 + ADDRESS_NAME_LEN];111111+};112112+113113+static struct esb2rom_window esb2rom_window = {114114+ .maps = LIST_HEAD_INIT(esb2rom_window.maps),115115+};116116+117117+static void esb2rom_cleanup(struct esb2rom_window *window)118118+{119119+ struct esb2rom_map_info *map, *scratch;120120+ u8 byte;121121+122122+ /* Disable writes through the rom window */123123+ pci_read_config_byte(window->pdev, BIOS_CNTL, &byte);124124+ pci_write_config_byte(window->pdev, BIOS_CNTL,125125+ byte & ~BIOS_WRITE_ENABLE);126126+127127+ /* Free all of the mtd devices */128128+ list_for_each_entry_safe(map, scratch, &window->maps, list) {129129+ if (map->rsrc.parent)130130+ release_resource(&map->rsrc);131131+ del_mtd_device(map->mtd);132132+ map_destroy(map->mtd);133133+ list_del(&map->list);134134+ kfree(map);135135+ }136136+ if (window->rsrc.parent)137137+ release_resource(&window->rsrc);138138+ if (window->virt) {139139+ iounmap(window->virt);140140+ window->virt = NULL;141141+ window->phys = 0;142142+ window->size = 0;143143+ }144144+ pci_dev_put(window->pdev);145145+}146146+147147+static int __devinit esb2rom_init_one(struct pci_dev *pdev,148148+ const struct pci_device_id *ent)149149+{150150+ static char *rom_probe_types[] = { "cfi_probe", "jedec_probe", NULL };151151+ struct esb2rom_window *window = &esb2rom_window;152152+ struct esb2rom_map_info *map = NULL;153153+ unsigned long map_top;154154+ u8 byte;155155+ u16 word;156156+157157+ /* For now I just handle the ecb2 and I assume there158158+ * are not a lot of resources up at the top of the address159159+ * space. It is possible to handle other devices in the160160+ * top 16MiB but it is very painful. Also since161161+ * you can only really attach a FWH to an ICHX there162162+ * a number of simplifications you can make.163163+ *164164+ * Also you can page firmware hubs if an 8MiB window isn't enough165165+ * but don't currently handle that case either.166166+ */167167+ window->pdev = pci_dev_get(pdev);168168+169169+ /* RLG: experiment 2. Force the window registers to the widest values */170170+171171+/*172172+ pci_read_config_word(pdev, FWH_DEC_EN1, &word);173173+ printk(KERN_DEBUG "Original FWH_DEC_EN1 : %x\n", word);174174+ pci_write_config_byte(pdev, FWH_DEC_EN1, 0xff);175175+ pci_read_config_byte(pdev, FWH_DEC_EN1, &byte);176176+ printk(KERN_DEBUG "New FWH_DEC_EN1 : %x\n", byte);177177+178178+ pci_read_config_byte(pdev, FWH_DEC_EN2, &byte);179179+ printk(KERN_DEBUG "Original FWH_DEC_EN2 : %x\n", byte);180180+ pci_write_config_byte(pdev, FWH_DEC_EN2, 0x0f);181181+ pci_read_config_byte(pdev, FWH_DEC_EN2, &byte);182182+ printk(KERN_DEBUG "New FWH_DEC_EN2 : %x\n", byte);183183+*/184184+185185+ /* Find a region continuous to the end of the ROM window */186186+ window->phys = 0;187187+ pci_read_config_word(pdev, FWH_DEC_EN1, &word);188188+ printk(KERN_DEBUG "pci_read_config_byte : %x\n", word);189189+190190+ if ((word & FWH_8MiB) == FWH_8MiB)191191+ window->phys = 0xff400000;192192+ else if ((word & FWH_7MiB) == FWH_7MiB)193193+ window->phys = 0xff500000;194194+ else if ((word & FWH_6MiB) == FWH_6MiB)195195+ window->phys = 0xff600000;196196+ else if ((word & FWH_5MiB) == FWH_5MiB)197197+ window->phys = 0xFF700000;198198+ else if ((word & FWH_4MiB) == FWH_4MiB)199199+ window->phys = 0xffc00000;200200+ else if ((word & FWH_3_5MiB) == FWH_3_5MiB)201201+ window->phys = 0xffc80000;202202+ else if ((word & FWH_3MiB) == FWH_3MiB)203203+ window->phys = 0xffd00000;204204+ else if ((word & FWH_2_5MiB) == FWH_2_5MiB)205205+ window->phys = 0xffd80000;206206+ else if ((word & FWH_2MiB) == FWH_2MiB)207207+ window->phys = 0xffe00000;208208+ else if ((word & FWH_1_5MiB) == FWH_1_5MiB)209209+ window->phys = 0xffe80000;210210+ else if ((word & FWH_1MiB) == FWH_1MiB)211211+ window->phys = 0xfff00000;212212+ else if ((word & FWH_0_5MiB) == FWH_0_5MiB)213213+ window->phys = 0xfff80000;214214+215215+ /* reserved 0x0020 and 0x0010 */216216+ window->phys -= 0x400000UL;217217+ window->size = (0xffffffffUL - window->phys) + 1UL;218218+219219+ /* Enable writes through the rom window */220220+ pci_read_config_byte(pdev, BIOS_CNTL, &byte);221221+ if (!(byte & BIOS_WRITE_ENABLE) && (byte & (BIOS_LOCK_ENABLE))) {222222+ /* The BIOS will generate an error if I enable223223+ * this device, so don't even try.224224+ */225225+ printk(KERN_ERR MOD_NAME ": firmware access control, I can't enable writes\n");226226+ goto out;227227+ }228228+ pci_write_config_byte(pdev, BIOS_CNTL, byte | BIOS_WRITE_ENABLE);229229+230230+ /*231231+ * Try to reserve the window mem region. If this fails then232232+ * it is likely due to the window being "reseved" by the BIOS.233233+ */234234+ window->rsrc.name = MOD_NAME;235235+ window->rsrc.start = window->phys;236236+ window->rsrc.end = window->phys + window->size - 1;237237+ window->rsrc.flags = IORESOURCE_MEM | IORESOURCE_BUSY;238238+ if (request_resource(&iomem_resource, &window->rsrc)) {239239+ window->rsrc.parent = NULL;240240+ printk(KERN_DEBUG MOD_NAME241241+ ": %s(): Unable to register resource"242242+ " 0x%.08llx-0x%.08llx - kernel bug?\n",243243+ __func__,244244+ (unsigned long long)window->rsrc.start,245245+ (unsigned long long)window->rsrc.end);246246+ }247247+248248+ /* Map the firmware hub into my address space. */249249+ window->virt = ioremap_nocache(window->phys, window->size);250250+ if (!window->virt) {251251+ printk(KERN_ERR MOD_NAME ": ioremap(%08lx, %08lx) failed\n",252252+ window->phys, window->size);253253+ goto out;254254+ }255255+256256+ /* Get the first address to look for an rom chip at */257257+ map_top = window->phys;258258+ if ((window->phys & 0x3fffff) != 0) {259259+ /* if not aligned on 4MiB, look 4MiB lower in address space */260260+ map_top = window->phys + 0x400000;261261+ }262262+#if 1263263+ /* The probe sequence run over the firmware hub lock264264+ * registers sets them to 0x7 (no access).265265+ * (Insane hardware design, but most copied Intel's.)266266+ * ==> Probe at most the last 4M of the address space.267267+ */268268+ if (map_top < 0xffc00000)269269+ map_top = 0xffc00000;270270+#endif271271+ /* Loop through and look for rom chips */272272+ while ((map_top - 1) < 0xffffffffUL) {273273+ struct cfi_private *cfi;274274+ unsigned long offset;275275+ int i;276276+277277+ if (!map)278278+ map = kmalloc(sizeof(*map), GFP_KERNEL);279279+ if (!map) {280280+ printk(KERN_ERR MOD_NAME ": kmalloc failed");281281+ goto out;282282+ }283283+ memset(map, 0, sizeof(*map));284284+ INIT_LIST_HEAD(&map->list);285285+ map->map.name = map->map_name;286286+ map->map.phys = map_top;287287+ offset = map_top - window->phys;288288+ map->map.virt = (void __iomem *)289289+ (((unsigned long)(window->virt)) + offset);290290+ map->map.size = 0xffffffffUL - map_top + 1UL;291291+ /* Set the name of the map to the address I am trying */292292+ sprintf(map->map_name, "%s @%08lx",293293+ MOD_NAME, map->map.phys);294294+295295+ /* Firmware hubs only use vpp when being programmed296296+ * in a factory setting. So in-place programming297297+ * needs to use a different method.298298+ */299299+ for(map->map.bankwidth = 32; map->map.bankwidth;300300+ map->map.bankwidth >>= 1) {301301+ char **probe_type;302302+ /* Skip bankwidths that are not supported */303303+ if (!map_bankwidth_supported(map->map.bankwidth))304304+ continue;305305+306306+ /* Setup the map methods */307307+ simple_map_init(&map->map);308308+309309+ /* Try all of the probe methods */310310+ probe_type = rom_probe_types;311311+ for(; *probe_type; probe_type++) {312312+ map->mtd = do_map_probe(*probe_type, &map->map);313313+ if (map->mtd)314314+ goto found;315315+ }316316+ }317317+ map_top += ROM_PROBE_STEP_SIZE;318318+ continue;319319+ found:320320+ /* Trim the size if we are larger than the map */321321+ if (map->mtd->size > map->map.size) {322322+ printk(KERN_WARNING MOD_NAME323323+ " rom(%u) larger than window(%lu). fixing...\n",324324+ map->mtd->size, map->map.size);325325+ map->mtd->size = map->map.size;326326+ }327327+ if (window->rsrc.parent) {328328+ /*329329+ * Registering the MTD device in iomem may not be possible330330+ * if there is a BIOS "reserved" and BUSY range. If this331331+ * fails then continue anyway.332332+ */333333+ map->rsrc.name = map->map_name;334334+ map->rsrc.start = map->map.phys;335335+ map->rsrc.end = map->map.phys + map->mtd->size - 1;336336+ map->rsrc.flags = IORESOURCE_MEM | IORESOURCE_BUSY;337337+ if (request_resource(&window->rsrc, &map->rsrc)) {338338+ printk(KERN_ERR MOD_NAME339339+ ": cannot reserve MTD resource\n");340340+ map->rsrc.parent = NULL;341341+ }342342+ }343343+344344+ /* Make the whole region visible in the map */345345+ map->map.virt = window->virt;346346+ map->map.phys = window->phys;347347+ cfi = map->map.fldrv_priv;348348+ for(i = 0; i < cfi->numchips; i++)349349+ cfi->chips[i].start += offset;350350+351351+ /* Now that the mtd devices is complete claim and export it */352352+ map->mtd->owner = THIS_MODULE;353353+ if (add_mtd_device(map->mtd)) {354354+ map_destroy(map->mtd);355355+ map->mtd = NULL;356356+ goto out;357357+ }358358+359359+ /* Calculate the new value of map_top */360360+ map_top += map->mtd->size;361361+362362+ /* File away the map structure */363363+ list_add(&map->list, &window->maps);364364+ map = NULL;365365+ }366366+367367+ out:368368+ /* Free any left over map structures */369369+ kfree(map);370370+371371+ /* See if I have any map structures */372372+ if (list_empty(&window->maps)) {373373+ esb2rom_cleanup(window);374374+ return -ENODEV;375375+ }376376+ return 0;377377+}378378+379379+static void __devexit esb2rom_remove_one (struct pci_dev *pdev)380380+{381381+ struct esb2rom_window *window = &esb2rom_window;382382+ esb2rom_cleanup(window);383383+}384384+385385+static struct pci_device_id esb2rom_pci_tbl[] __devinitdata = {386386+ { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801BA_0,387387+ PCI_ANY_ID, PCI_ANY_ID, },388388+ { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801CA_0,389389+ PCI_ANY_ID, PCI_ANY_ID, },390390+ { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801DB_0,391391+ PCI_ANY_ID, PCI_ANY_ID, },392392+ { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801EB_0,393393+ PCI_ANY_ID, PCI_ANY_ID, },394394+ { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ESB_1,395395+ PCI_ANY_ID, PCI_ANY_ID, },396396+ { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ESB2_0,397397+ PCI_ANY_ID, PCI_ANY_ID, },398398+ { 0, },399399+};400400+401401+#if 0402402+MODULE_DEVICE_TABLE(pci, esb2rom_pci_tbl);403403+404404+static struct pci_driver esb2rom_driver = {405405+ .name = MOD_NAME,406406+ .id_table = esb2rom_pci_tbl,407407+ .probe = esb2rom_init_one,408408+ .remove = esb2rom_remove_one,409409+};410410+#endif411411+412412+static int __init init_esb2rom(void)413413+{414414+ struct pci_dev *pdev;415415+ struct pci_device_id *id;416416+ int retVal;417417+418418+ pdev = NULL;419419+ for (id = esb2rom_pci_tbl; id->vendor; id++) {420420+ printk(KERN_DEBUG "device id = %x\n", id->device);421421+ pdev = pci_get_device(id->vendor, id->device, NULL);422422+ if (pdev) {423423+ printk(KERN_DEBUG "matched device = %x\n", id->device);424424+ break;425425+ }426426+ }427427+ if (pdev) {428428+ printk(KERN_DEBUG "matched device id %x\n", id->device);429429+ retVal = esb2rom_init_one(pdev, &esb2rom_pci_tbl[0]);430430+ pci_dev_put(pdev);431431+ printk(KERN_DEBUG "retVal = %d\n", retVal);432432+ return retVal;433433+ }434434+ return -ENXIO;435435+#if 0436436+ return pci_register_driver(&esb2rom_driver);437437+#endif438438+}439439+440440+static void __exit cleanup_esb2rom(void)441441+{442442+ esb2rom_remove_one(esb2rom_window.pdev);443443+}444444+445445+module_init(init_esb2rom);446446+module_exit(cleanup_esb2rom);447447+448448+MODULE_LICENSE("GPL");449449+MODULE_AUTHOR("Lew Glendenning <lglendenning@lnxi.com>");450450+MODULE_DESCRIPTION("MTD map driver for BIOS chips on the ESB2 southbridge");
+1-3
drivers/mtd/maps/integrator-flash.c
···7575 int err;7676 void __iomem *base;77777878- info = kmalloc(sizeof(struct armflash_info), GFP_KERNEL);7878+ info = kzalloc(sizeof(struct armflash_info), GFP_KERNEL);7979 if (!info) {8080 err = -ENOMEM;8181 goto out;8282 }8383-8484- memset(info, 0, sizeof(struct armflash_info));85838684 info->plat = plat;8785 if (plat && plat->init) {
···7878 struct resource *res = pdev->resource;7979 unsigned long size = res->end - res->start + 1;80808181- info = kmalloc(sizeof(struct omapflash_info), GFP_KERNEL);8181+ info = kzalloc(sizeof(struct omapflash_info), GFP_KERNEL);8282 if (!info)8383 return -ENOMEM;8484-8585- memset(info, 0, sizeof(struct omapflash_info));86848785 if (!request_mem_region(res->start, size, "flash")) {8886 err = -EBUSY;
+1-2
drivers/mtd/maps/pcmciamtd.c
···735735 struct pcmciamtd_dev *dev;736736737737 /* Create new memory card device */738738- dev = kmalloc(sizeof(*dev), GFP_KERNEL);738738+ dev = kzalloc(sizeof(*dev), GFP_KERNEL);739739 if (!dev) return -ENOMEM;740740 DEBUG(1, "dev=0x%p", dev);741741742742- memset(dev, 0, sizeof(*dev));743742 dev->p_dev = link;744743 link->priv = dev;745744
+2-3
drivers/mtd/maps/physmap.c
···8989 return -ENODEV;90909191 printk(KERN_NOTICE "physmap platform flash device: %.8llx at %.8llx\n",9292- (unsigned long long)dev->resource->end - dev->resource->start + 1,9292+ (unsigned long long)(dev->resource->end - dev->resource->start + 1),9393 (unsigned long long)dev->resource->start);94949595- info = kmalloc(sizeof(struct physmap_flash_info), GFP_KERNEL);9595+ info = kzalloc(sizeof(struct physmap_flash_info), GFP_KERNEL);9696 if (info == NULL) {9797 err = -ENOMEM;9898 goto err_out;9999 }100100- memset(info, 0, sizeof(*info));101100102101 platform_set_drvdata(dev, info);103102
+255
drivers/mtd/maps/physmap_of.c
···11+/*22+ * Normal mappings of chips in physical memory for OF devices33+ *44+ * Copyright (C) 2006 MontaVista Software Inc.55+ * Author: Vitaly Wool <vwool@ru.mvista.com>66+ *77+ * This program is free software; you can redistribute it and/or modify it88+ * under the terms of the GNU General Public License as published by the99+ * Free Software Foundation; either version 2 of the License, or (at your1010+ * option) any later version.1111+ */1212+1313+#include <linux/module.h>1414+#include <linux/types.h>1515+#include <linux/kernel.h>1616+#include <linux/init.h>1717+#include <linux/slab.h>1818+#include <linux/device.h>1919+#include <linux/mtd/mtd.h>2020+#include <linux/mtd/map.h>2121+#include <linux/mtd/partitions.h>2222+#include <linux/mtd/physmap.h>2323+#include <asm/io.h>2424+#include <asm/prom.h>2525+#include <asm/of_device.h>2626+#include <asm/of_platform.h>2727+2828+struct physmap_flash_info {2929+ struct mtd_info *mtd;3030+ struct map_info map;3131+ struct resource *res;3232+#ifdef CONFIG_MTD_PARTITIONS3333+ int nr_parts;3434+ struct mtd_partition *parts;3535+#endif3636+};3737+3838+static const char *rom_probe_types[] = { "cfi_probe", "jedec_probe", "map_rom", NULL };3939+#ifdef CONFIG_MTD_PARTITIONS4040+static const char *part_probe_types[] = { "cmdlinepart", "RedBoot", NULL };4141+#endif4242+4343+#ifdef CONFIG_MTD_PARTITIONS4444+static int parse_flash_partitions(struct device_node *node,4545+ struct mtd_partition **parts)4646+{4747+ int i, plen, retval = -ENOMEM;4848+ const u32 *part;4949+ const char *name;5050+5151+ part = get_property(node, "partitions", &plen);5252+ if (part == NULL)5353+ goto err;5454+5555+ retval = plen / (2 * sizeof(u32));5656+ *parts = kzalloc(retval * sizeof(struct mtd_partition), GFP_KERNEL);5757+ if (*parts == NULL) {5858+ printk(KERN_ERR "Can't allocate the flash partition data!\n");5959+ goto err;6060+ }6161+6262+ name = get_property(node, "partition-names", &plen);6363+6464+ for (i = 0; i < retval; i++) {6565+ (*parts)[i].offset = *part++;6666+ (*parts)[i].size = *part & ~1;6767+ if (*part++ & 1) /* bit 0 set signifies read only partition */6868+ (*parts)[i].mask_flags = MTD_WRITEABLE;6969+7070+ if (name != NULL && plen > 0) {7171+ int len = strlen(name) + 1;7272+7373+ (*parts)[i].name = (char *)name;7474+ plen -= len;7575+ name += len;7676+ } else7777+ (*parts)[i].name = "unnamed";7878+ }7979+err:8080+ return retval;8181+}8282+#endif8383+8484+static int of_physmap_remove(struct of_device *dev)8585+{8686+ struct physmap_flash_info *info;8787+8888+ info = dev_get_drvdata(&dev->dev);8989+ if (info == NULL)9090+ return 0;9191+ dev_set_drvdata(&dev->dev, NULL);9292+9393+ if (info->mtd != NULL) {9494+#ifdef CONFIG_MTD_PARTITIONS9595+ if (info->nr_parts) {9696+ del_mtd_partitions(info->mtd);9797+ kfree(info->parts);9898+ } else {9999+ del_mtd_device(info->mtd);100100+ }101101+#else102102+ del_mtd_device(info->mtd);103103+#endif104104+ map_destroy(info->mtd);105105+ }106106+107107+ if (info->map.virt != NULL)108108+ iounmap(info->map.virt);109109+110110+ if (info->res != NULL) {111111+ release_resource(info->res);112112+ kfree(info->res);113113+ }114114+115115+ return 0;116116+}117117+118118+static int __devinit of_physmap_probe(struct of_device *dev, const struct of_device_id *match)119119+{120120+ struct device_node *dp = dev->node;121121+ struct resource res;122122+ struct physmap_flash_info *info;123123+ const char **probe_type;124124+ const char *of_probe;125125+ const u32 *width;126126+ int err;127127+128128+129129+ if (of_address_to_resource(dp, 0, &res)) {130130+ dev_err(&dev->dev, "Can't get the flash mapping!\n");131131+ err = -EINVAL;132132+ goto err_out;133133+ }134134+135135+ dev_dbg(&dev->dev, "physmap flash device: %.8llx at %.8llx\n",136136+ (unsigned long long)res.end - res.start + 1,137137+ (unsigned long long)res.start);138138+139139+ info = kzalloc(sizeof(struct physmap_flash_info), GFP_KERNEL);140140+ if (info == NULL) {141141+ err = -ENOMEM;142142+ goto err_out;143143+ }144144+ memset(info, 0, sizeof(*info));145145+146146+ dev_set_drvdata(&dev->dev, info);147147+148148+ info->res = request_mem_region(res.start, res.end - res.start + 1,149149+ dev->dev.bus_id);150150+ if (info->res == NULL) {151151+ dev_err(&dev->dev, "Could not reserve memory region\n");152152+ err = -ENOMEM;153153+ goto err_out;154154+ }155155+156156+ width = get_property(dp, "bank-width", NULL);157157+ if (width == NULL) {158158+ dev_err(&dev->dev, "Can't get the flash bank width!\n");159159+ err = -EINVAL;160160+ goto err_out;161161+ }162162+163163+ info->map.name = dev->dev.bus_id;164164+ info->map.phys = res.start;165165+ info->map.size = res.end - res.start + 1;166166+ info->map.bankwidth = *width;167167+168168+ info->map.virt = ioremap(info->map.phys, info->map.size);169169+ if (info->map.virt == NULL) {170170+ dev_err(&dev->dev, "Failed to ioremap flash region\n");171171+ err = EIO;172172+ goto err_out;173173+ }174174+175175+ simple_map_init(&info->map);176176+177177+ of_probe = get_property(dp, "probe-type", NULL);178178+ if (of_probe == NULL) {179179+ probe_type = rom_probe_types;180180+ for (; info->mtd == NULL && *probe_type != NULL; probe_type++)181181+ info->mtd = do_map_probe(*probe_type, &info->map);182182+ } else if (!strcmp(of_probe, "CFI"))183183+ info->mtd = do_map_probe("cfi_probe", &info->map);184184+ else if (!strcmp(of_probe, "JEDEC"))185185+ info->mtd = do_map_probe("jedec_probe", &info->map);186186+ else {187187+ if (strcmp(of_probe, "ROM"))188188+ dev_dbg(&dev->dev, "map_probe: don't know probe type "189189+ "'%s', mapping as rom\n");190190+ info->mtd = do_map_probe("mtd_rom", &info->map);191191+ }192192+ if (info->mtd == NULL) {193193+ dev_err(&dev->dev, "map_probe failed\n");194194+ err = -ENXIO;195195+ goto err_out;196196+ }197197+ info->mtd->owner = THIS_MODULE;198198+199199+#ifdef CONFIG_MTD_PARTITIONS200200+ err = parse_mtd_partitions(info->mtd, part_probe_types, &info->parts, 0);201201+ if (err > 0) {202202+ add_mtd_partitions(info->mtd, info->parts, err);203203+ } else if ((err = parse_flash_partitions(dp, &info->parts)) > 0) {204204+ dev_info(&dev->dev, "Using OF partition information\n");205205+ add_mtd_partitions(info->mtd, info->parts, err);206206+ info->nr_parts = err;207207+ } else208208+#endif209209+210210+ add_mtd_device(info->mtd);211211+ return 0;212212+213213+err_out:214214+ of_physmap_remove(dev);215215+ return err;216216+217217+ return 0;218218+219219+220220+}221221+222222+static struct of_device_id of_physmap_match[] = {223223+ {224224+ .type = "rom",225225+ .compatible = "direct-mapped"226226+ },227227+ { },228228+};229229+230230+MODULE_DEVICE_TABLE(of, of_physmap_match);231231+232232+233233+static struct of_platform_driver of_physmap_flash_driver = {234234+ .name = "physmap-flash",235235+ .match_table = of_physmap_match,236236+ .probe = of_physmap_probe,237237+ .remove = of_physmap_remove,238238+};239239+240240+static int __init of_physmap_init(void)241241+{242242+ return of_register_platform_driver(&of_physmap_flash_driver);243243+}244244+245245+static void __exit of_physmap_exit(void)246246+{247247+ of_unregister_platform_driver(&of_physmap_flash_driver);248248+}249249+250250+module_init(of_physmap_init);251251+module_exit(of_physmap_exit);252252+253253+MODULE_LICENSE("GPL");254254+MODULE_AUTHOR("Vitaly Wool <vwool@ru.mvista.com>");255255+MODULE_DESCRIPTION("Configurable MTD map driver for OF");
+1-2
drivers/mtd/maps/plat-ram.c
···147147148148 pdata = pdev->dev.platform_data;149149150150- info = kmalloc(sizeof(*info), GFP_KERNEL);150150+ info = kzalloc(sizeof(*info), GFP_KERNEL);151151 if (info == NULL) {152152 dev_err(&pdev->dev, "no memory for flash info\n");153153 err = -ENOMEM;154154 goto exit_error;155155 }156156157157- memset(info, 0, sizeof(*info));158157 platform_set_drvdata(pdev, info);159158160159 info->dev = &pdev->dev;
+1-3
drivers/mtd/maps/sa1100-flash.c
···273273 /*274274 * Allocate the map_info structs in one go.275275 */276276- info = kmalloc(size, GFP_KERNEL);276276+ info = kzalloc(size, GFP_KERNEL);277277 if (!info) {278278 ret = -ENOMEM;279279 goto out;280280 }281281-282282- memset(info, 0, size);283281284282 if (plat->init) {285283 ret = plat->init();
···7788#include <linux/device.h>99#include <linux/fs.h>1010+#include <linux/err.h>1011#include <linux/init.h>1112#include <linux/kernel.h>1213#include <linux/module.h>···101100102101 mtd = get_mtd_device(NULL, devnum);103102104104- if (!mtd)105105- return -ENODEV;103103+ if (IS_ERR(mtd))104104+ return PTR_ERR(mtd);106105107106 if (MTD_ABSENT == mtd->type) {108107 put_mtd_device(mtd);···432431 if(!(file->f_mode & 2))433432 return -EPERM;434433435435- erase=kmalloc(sizeof(struct erase_info),GFP_KERNEL);434434+ erase=kzalloc(sizeof(struct erase_info),GFP_KERNEL);436435 if (!erase)437436 ret = -ENOMEM;438437 else {···441440442441 init_waitqueue_head(&waitq);443442444444- memset (erase,0,sizeof(struct erase_info));445443 if (copy_from_user(&erase->addr, argp,446444 sizeof(struct erase_info_user))) {447445 kfree(erase);···499499 if (ret)500500 return ret;501501502502- ops.len = buf.length;503502 ops.ooblen = buf.length;504503 ops.ooboffs = buf.start & (mtd->oobsize - 1);505504 ops.datbuf = NULL;506505 ops.mode = MTD_OOB_PLACE;507506508508- if (ops.ooboffs && ops.len > (mtd->oobsize - ops.ooboffs))507507+ if (ops.ooboffs && ops.ooblen > (mtd->oobsize - ops.ooboffs))509508 return -EINVAL;510509511510 ops.oobbuf = kmalloc(buf.length, GFP_KERNEL);···519520 buf.start &= ~(mtd->oobsize - 1);520521 ret = mtd->write_oob(mtd, buf.start, &ops);521522522522- if (copy_to_user(argp + sizeof(uint32_t), &ops.retlen,523523+ if (copy_to_user(argp + sizeof(uint32_t), &ops.oobretlen,523524 sizeof(uint32_t)))524525 ret = -EFAULT;525526···547548 if (ret)548549 return ret;549550550550- ops.len = buf.length;551551 ops.ooblen = buf.length;552552 ops.ooboffs = buf.start & (mtd->oobsize - 1);553553 ops.datbuf = NULL;···562564 buf.start &= ~(mtd->oobsize - 1);563565 ret = mtd->read_oob(mtd, buf.start, &ops);564566565565- if (put_user(ops.retlen, (uint32_t __user *)argp))567567+ if (put_user(ops.oobretlen, (uint32_t __user *)argp))566568 ret = -EFAULT;567567- else if (ops.retlen && copy_to_user(buf.ptr, ops.oobbuf,568568- ops.retlen))569569+ else if (ops.oobretlen && copy_to_user(buf.ptr, ops.oobbuf,570570+ ops.oobretlen))569571 ret = -EFAULT;570572571573 kfree(ops.oobbuf);···614616 memcpy(&oi.eccpos, mtd->ecclayout->eccpos, sizeof(oi.eccpos));615617 memcpy(&oi.oobfree, mtd->ecclayout->oobfree,616618 sizeof(oi.oobfree));619619+ oi.eccbytes = mtd->ecclayout->eccbytes;617620618621 if (copy_to_user(argp, &oi, sizeof(struct nand_oobinfo)))619622 return -EFAULT;···714715 if (!mtd->ecclayout)715716 return -EOPNOTSUPP;716717717717- if (copy_to_user(argp, &mtd->ecclayout,718718+ if (copy_to_user(argp, mtd->ecclayout,718719 sizeof(struct nand_ecclayout)))719720 return -EFAULT;720721 break;
+26-17
drivers/mtd/mtdconcat.c
···247247 struct mtd_oob_ops devops = *ops;248248 int i, err, ret = 0;249249250250- ops->retlen = 0;250250+ ops->retlen = ops->oobretlen = 0;251251252252 for (i = 0; i < concat->num_subdev; i++) {253253 struct mtd_info *subdev = concat->subdev[i];···263263264264 err = subdev->read_oob(subdev, from, &devops);265265 ops->retlen += devops.retlen;266266+ ops->oobretlen += devops.oobretlen;266267267268 /* Save information about bitflips! */268269 if (unlikely(err)) {···279278 return err;280279 }281280282282- devops.len = ops->len - ops->retlen;283283- if (!devops.len)284284- return ret;285285-286286- if (devops.datbuf)281281+ if (devops.datbuf) {282282+ devops.len = ops->len - ops->retlen;283283+ if (!devops.len)284284+ return ret;287285 devops.datbuf += devops.retlen;288288- if (devops.oobbuf)289289- devops.oobbuf += devops.ooblen;286286+ }287287+ if (devops.oobbuf) {288288+ devops.ooblen = ops->ooblen - ops->oobretlen;289289+ if (!devops.ooblen)290290+ return ret;291291+ devops.oobbuf += ops->oobretlen;292292+ }290293291294 from = 0;292295 }···326321 if (err)327322 return err;328323329329- devops.len = ops->len - ops->retlen;330330- if (!devops.len)331331- return 0;332332-333333- if (devops.datbuf)324324+ if (devops.datbuf) {325325+ devops.len = ops->len - ops->retlen;326326+ if (!devops.len)327327+ return 0;334328 devops.datbuf += devops.retlen;335335- if (devops.oobbuf)336336- devops.oobbuf += devops.ooblen;329329+ }330330+ if (devops.oobbuf) {331331+ devops.ooblen = ops->ooblen - ops->oobretlen;332332+ if (!devops.ooblen)333333+ return 0;334334+ devops.oobbuf += devops.oobretlen;335335+ }337336 to = 0;338337 }339338 return -EINVAL;···708699709700 /* allocate the device structure */710701 size = SIZEOF_STRUCT_MTD_CONCAT(num_devs);711711- concat = kmalloc(size, GFP_KERNEL);702702+ concat = kzalloc(size, GFP_KERNEL);712703 if (!concat) {713704 printk714705 ("memory allocation error while creating concatenated device \"%s\"\n",715706 name);716707 return NULL;717708 }718718- memset(concat, 0, size);719709 concat->subdev = (struct mtd_info **) (concat + 1);720710721711 /*···772764 concat->mtd.ecc_stats.badblocks +=773765 subdev[i]->ecc_stats.badblocks;774766 if (concat->mtd.writesize != subdev[i]->writesize ||767767+ concat->mtd.subpage_sft != subdev[i]->subpage_sft ||775768 concat->mtd.oobsize != subdev[i]->oobsize ||776769 concat->mtd.ecctype != subdev[i]->ecctype ||777770 concat->mtd.eccsize != subdev[i]->eccsize ||
+78-15
drivers/mtd/mtdcore.c
···1515#include <linux/timer.h>1616#include <linux/major.h>1717#include <linux/fs.h>1818+#include <linux/err.h>1819#include <linux/ioctl.h>1920#include <linux/init.h>2021#include <linux/mtd/compatmac.h>···193192 * Given a number and NULL address, return the num'th entry in the device194193 * table, if any. Given an address and num == -1, search the device table195194 * for a device with that address and return if it's still present. Given196196- * both, return the num'th driver only if its address matches. Return NULL197197- * if not.195195+ * both, return the num'th driver only if its address matches. Return196196+ * error code if not.198197 */199198200199struct mtd_info *get_mtd_device(struct mtd_info *mtd, int num)201200{202201 struct mtd_info *ret = NULL;203203- int i;202202+ int i, err = -ENODEV;204203205204 mutex_lock(&mtd_table_mutex);206205···214213 ret = NULL;215214 }216215217217- if (ret && !try_module_get(ret->owner))218218- ret = NULL;216216+ if (!ret)217217+ goto out_unlock;219218220220- if (ret)221221- ret->usecount++;219219+ if (!try_module_get(ret->owner))220220+ goto out_unlock;222221222222+ if (ret->get_device) {223223+ err = ret->get_device(ret);224224+ if (err)225225+ goto out_put;226226+ }227227+228228+ ret->usecount++;223229 mutex_unlock(&mtd_table_mutex);224230 return ret;231231+232232+out_put:233233+ module_put(ret->owner);234234+out_unlock:235235+ mutex_unlock(&mtd_table_mutex);236236+ return ERR_PTR(err);237237+}238238+239239+/**240240+ * get_mtd_device_nm - obtain a validated handle for an MTD device by241241+ * device name242242+ * @name: MTD device name to open243243+ *244244+ * This function returns MTD device description structure in case of245245+ * success and an error code in case of failure.246246+ */247247+248248+struct mtd_info *get_mtd_device_nm(const char *name)249249+{250250+ int i, err = -ENODEV;251251+ struct mtd_info *mtd = NULL;252252+253253+ mutex_lock(&mtd_table_mutex);254254+255255+ for (i = 0; i < MAX_MTD_DEVICES; i++) {256256+ if (mtd_table[i] && !strcmp(name, mtd_table[i]->name)) {257257+ mtd = mtd_table[i];258258+ break;259259+ }260260+ }261261+262262+ if (!mtd)263263+ goto out_unlock;264264+265265+ if (!try_module_get(mtd->owner))266266+ goto out_unlock;267267+268268+ if (mtd->get_device) {269269+ err = mtd->get_device(mtd);270270+ if (err)271271+ goto out_put;272272+ }273273+274274+ mtd->usecount++;275275+ mutex_unlock(&mtd_table_mutex);276276+ return mtd;277277+278278+out_put:279279+ module_put(mtd->owner);280280+out_unlock:281281+ mutex_unlock(&mtd_table_mutex);282282+ return ERR_PTR(err);225283}226284227285void put_mtd_device(struct mtd_info *mtd)···289229290230 mutex_lock(&mtd_table_mutex);291231 c = --mtd->usecount;232232+ if (mtd->put_device)233233+ mtd->put_device(mtd);292234 mutex_unlock(&mtd_table_mutex);293235 BUG_ON(c < 0);294236···298236}299237300238/* default_mtd_writev - default mtd writev method for MTD devices that301301- * dont implement their own239239+ * don't implement their own302240 */303241304242int default_mtd_writev(struct mtd_info *mtd, const struct kvec *vecs,···326264 return ret;327265}328266329329-EXPORT_SYMBOL(add_mtd_device);330330-EXPORT_SYMBOL(del_mtd_device);331331-EXPORT_SYMBOL(get_mtd_device);332332-EXPORT_SYMBOL(put_mtd_device);333333-EXPORT_SYMBOL(register_mtd_user);334334-EXPORT_SYMBOL(unregister_mtd_user);335335-EXPORT_SYMBOL(default_mtd_writev);267267+EXPORT_SYMBOL_GPL(add_mtd_device);268268+EXPORT_SYMBOL_GPL(del_mtd_device);269269+EXPORT_SYMBOL_GPL(get_mtd_device);270270+EXPORT_SYMBOL_GPL(get_mtd_device_nm);271271+EXPORT_SYMBOL_GPL(put_mtd_device);272272+EXPORT_SYMBOL_GPL(register_mtd_user);273273+EXPORT_SYMBOL_GPL(unregister_mtd_user);274274+EXPORT_SYMBOL_GPL(default_mtd_writev);336275337276#ifdef CONFIG_PROC_FS338277
+4-4
drivers/mtd/mtdpart.c
···94949595 if (from >= mtd->size)9696 return -EINVAL;9797- if (from + ops->len > mtd->size)9797+ if (ops->datbuf && from + ops->len > mtd->size)9898 return -EINVAL;9999 res = part->master->read_oob(part->master, from + part->offset, ops);100100···161161162162 if (to >= mtd->size)163163 return -EINVAL;164164- if (to + ops->len > mtd->size)164164+ if (ops->datbuf && to + ops->len > mtd->size)165165 return -EINVAL;166166 return part->master->write_oob(part->master, to + part->offset, ops);167167}···323323 for (i = 0; i < nbparts; i++) {324324325325 /* allocate the partition structure */326326- slave = kmalloc (sizeof(*slave), GFP_KERNEL);326326+ slave = kzalloc (sizeof(*slave), GFP_KERNEL);327327 if (!slave) {328328 printk ("memory allocation error while creating partitions for \"%s\"\n",329329 master->name);330330 del_mtd_partitions(master);331331 return -ENOMEM;332332 }333333- memset(slave, 0, sizeof(*slave));334333 list_add(&slave->list, &mtd_partitions);335334336335 /* set up the MTD object for this partition */···340341 slave->mtd.oobsize = master->oobsize;341342 slave->mtd.ecctype = master->ecctype;342343 slave->mtd.eccsize = master->eccsize;344344+ slave->mtd.subpage_sft = master->subpage_sft;343345344346 slave->mtd.name = parts[i].name;345347 slave->mtd.bank_size = master->bank_size;
+16
drivers/mtd/nand/Kconfig
···9090 depends on MTD_NAND && SH_SOLUTION_ENGINE9191 select REED_SOLOMON9292 select REED_SOLOMON_DEC89393+ select BITREVERSE9394 help9495 This enables the driver for the Renesas Technology AG-AND9596 flash interface board (FROM_BOARD4)···133132config MTD_NAND_NDFC134133 tristate "NDFC NanD Flash Controller"135134 depends on MTD_NAND && 44x135135+ select MTD_NAND_ECC_SMC136136 help137137 NDFC Nand Flash Controllers are integrated in EP44x SoCs138138···221219 tristate "Support for NAND Flash on Sharp SL Series (C7xx + others)"222220 depends on MTD_NAND && ARCH_PXA223221222222+config MTD_NAND_CAFE223223+ tristate "NAND support for OLPC CAFÉ chip"224224+ depends on PCI225225+ help226226+ Use NAND flash attached to the CAFÉ chip designed for the $100227227+ laptop.228228+224229config MTD_NAND_CS553X225230 tristate "NAND support for CS5535/CS5536 (AMD Geode companion chip)"226231 depends on MTD_NAND && X86_32 && (X86_PC || X86_GENERICARCH)···240231 the controller be in MMIO mode.241232242233 If you say "m", the module will be called "cs553x_nand.ko".234234+235235+config MTD_NAND_AT91236236+ bool "Support for NAND Flash / SmartMedia on AT91"237237+ depends on MTD_NAND && ARCH_AT91238238+ help239239+ Enables support for NAND Flash / Smart Media Card interface240240+ on Atmel AT91 processors.243241244242config MTD_NAND_NANDSIM245243 tristate "Support for NAND Flash Simulator"
···1111 * published by the Free Software Foundation.1212 *1313 * Overview:1414- * This is a device driver for the NAND flash controller found on 1414+ * This is a device driver for the NAND flash controller found on1515 * the AMD CS5535/CS5536 companion chipsets for the Geode processor.1616 *1717 */···303303 err = cs553x_init_one(i, !!(val & FLSH_MEM_IO), val & 0xFFFFFFFF);304304 }305305306306- /* Register all devices together here. This means we can easily hack it to 306306+ /* Register all devices together here. This means we can easily hack it to307307 do mtdconcat etc. if we want to. */308308 for (i = 0; i < NR_CS553X_CONTROLLERS; i++) {309309 if (cs553x_mtd[i]) {
···4545 unsigned long size = res->end - res->start + 1;4646 int err;47474848- info = kmalloc(sizeof(struct onenand_info), GFP_KERNEL);4848+ info = kzalloc(sizeof(struct onenand_info), GFP_KERNEL);4949 if (!info)5050 return -ENOMEM;5151-5252- memset(info, 0, sizeof(struct onenand_info));53515452 if (!request_mem_region(res->start, size, dev->driver->name)) {5553 err = -EBUSY;···6163 }62646365 info->onenand.mmcontrol = pdata->mmcontrol;6666+ info->onenand.irq = platform_get_irq(pdev, 0);64676568 info->mtd.name = pdev->dev.bus_id;6669 info->mtd.priv = &info->onenand;
+281-89
drivers/mtd/onenand/onenand_base.c
···1313#include <linux/module.h>1414#include <linux/init.h>1515#include <linux/sched.h>1616+#include <linux/interrupt.h>1617#include <linux/jiffies.h>1718#include <linux/mtd/mtd.h>1819#include <linux/mtd/onenand.h>···192191 struct onenand_chip *this = mtd->priv;193192 int value, readcmd = 0, block_cmd = 0;194193 int block, page;195195- /* Now we use page size operation */196196- int sectors = 4, count = 4;197194198195 /* Address translation */199196 switch (cmd) {···243244 }244245245246 if (page != -1) {247247+ /* Now we use page size operation */248248+ int sectors = 4, count = 4;246249 int dataram;247250248251 switch (cmd) {···298297 unsigned long timeout;299298 unsigned int flags = ONENAND_INT_MASTER;300299 unsigned int interrupt = 0;301301- unsigned int ctrl, ecc;300300+ unsigned int ctrl;302301303302 /* The 20 msec is enough */304303 timeout = jiffies + msecs_to_jiffies(20);···310309311310 if (state != FL_READING)312311 cond_resched();313313- touch_softlockup_watchdog();314312 }315313 /* To get correct interrupt status in timeout case */316314 interrupt = this->read_word(this->base + ONENAND_REG_INTERRUPT);···317317 ctrl = this->read_word(this->base + ONENAND_REG_CTRL_STATUS);318318319319 if (ctrl & ONENAND_CTRL_ERROR) {320320- /* It maybe occur at initial bad block */321320 DEBUG(MTD_DEBUG_LEVEL0, "onenand_wait: controller error = 0x%04x\n", ctrl);322322- /* Clear other interrupt bits for preventing ECC error */323323- interrupt &= ONENAND_INT_MASTER;324324- }325325-326326- if (ctrl & ONENAND_CTRL_LOCK) {327327- DEBUG(MTD_DEBUG_LEVEL0, "onenand_wait: it's locked error = 0x%04x\n", ctrl);328328- return -EACCES;321321+ if (ctrl & ONENAND_CTRL_LOCK)322322+ DEBUG(MTD_DEBUG_LEVEL0, "onenand_wait: it's locked error.\n");323323+ return ctrl;329324 }330325331326 if (interrupt & ONENAND_INT_READ) {332332- ecc = this->read_word(this->base + ONENAND_REG_ECC_STATUS);333333- if (ecc & ONENAND_ECC_2BIT_ALL) {327327+ int ecc = this->read_word(this->base + ONENAND_REG_ECC_STATUS);328328+ if (ecc) {334329 DEBUG(MTD_DEBUG_LEVEL0, "onenand_wait: ECC error = 0x%04x\n", ecc);335335- return -EBADMSG;330330+ if (ecc & ONENAND_ECC_2BIT_ALL) {331331+ mtd->ecc_stats.failed++;332332+ return ecc;333333+ } else if (ecc & ONENAND_ECC_1BIT_ALL)334334+ mtd->ecc_stats.corrected++;336335 }337336 }338337339338 return 0;339339+}340340+341341+/*342342+ * onenand_interrupt - [DEFAULT] onenand interrupt handler343343+ * @param irq onenand interrupt number344344+ * @param dev_id interrupt data345345+ *346346+ * complete the work347347+ */348348+static irqreturn_t onenand_interrupt(int irq, void *data)349349+{350350+ struct onenand_chip *this = (struct onenand_chip *) data;351351+352352+ /* To handle shared interrupt */353353+ if (!this->complete.done)354354+ complete(&this->complete);355355+356356+ return IRQ_HANDLED;357357+}358358+359359+/*360360+ * onenand_interrupt_wait - [DEFAULT] wait until the command is done361361+ * @param mtd MTD device structure362362+ * @param state state to select the max. timeout value363363+ *364364+ * Wait for command done.365365+ */366366+static int onenand_interrupt_wait(struct mtd_info *mtd, int state)367367+{368368+ struct onenand_chip *this = mtd->priv;369369+370370+ wait_for_completion(&this->complete);371371+372372+ return onenand_wait(mtd, state);373373+}374374+375375+/*376376+ * onenand_try_interrupt_wait - [DEFAULT] try interrupt wait377377+ * @param mtd MTD device structure378378+ * @param state state to select the max. timeout value379379+ *380380+ * Try interrupt based wait (It is used one-time)381381+ */382382+static int onenand_try_interrupt_wait(struct mtd_info *mtd, int state)383383+{384384+ struct onenand_chip *this = mtd->priv;385385+ unsigned long remain, timeout;386386+387387+ /* We use interrupt wait first */388388+ this->wait = onenand_interrupt_wait;389389+390390+ timeout = msecs_to_jiffies(100);391391+ remain = wait_for_completion_timeout(&this->complete, timeout);392392+ if (!remain) {393393+ printk(KERN_INFO "OneNAND: There's no interrupt. "394394+ "We use the normal wait\n");395395+396396+ /* Release the irq */397397+ free_irq(this->irq, this);398398+399399+ this->wait = onenand_wait;400400+ }401401+402402+ return onenand_wait(mtd, state);403403+}404404+405405+/*406406+ * onenand_setup_wait - [OneNAND Interface] setup onenand wait method407407+ * @param mtd MTD device structure408408+ *409409+ * There's two method to wait onenand work410410+ * 1. polling - read interrupt status register411411+ * 2. interrupt - use the kernel interrupt method412412+ */413413+static void onenand_setup_wait(struct mtd_info *mtd)414414+{415415+ struct onenand_chip *this = mtd->priv;416416+ int syscfg;417417+418418+ init_completion(&this->complete);419419+420420+ if (this->irq <= 0) {421421+ this->wait = onenand_wait;422422+ return;423423+ }424424+425425+ if (request_irq(this->irq, &onenand_interrupt,426426+ IRQF_SHARED, "onenand", this)) {427427+ /* If we can't get irq, use the normal wait */428428+ this->wait = onenand_wait;429429+ return;430430+ }431431+432432+ /* Enable interrupt */433433+ syscfg = this->read_word(this->base + ONENAND_REG_SYS_CFG1);434434+ syscfg |= ONENAND_SYS_CFG1_IOBE;435435+ this->write_word(syscfg, this->base + ONENAND_REG_SYS_CFG1);436436+437437+ this->wait = onenand_try_interrupt_wait;340438}341439342440/**···707609 size_t *retlen, u_char *buf)708610{709611 struct onenand_chip *this = mtd->priv;612612+ struct mtd_ecc_stats stats;710613 int read = 0, column;711614 int thislen;712712- int ret = 0;615615+ int ret = 0, boundary = 0;713616714617 DEBUG(MTD_DEBUG_LEVEL3, "onenand_read: from = 0x%08x, len = %i\n", (unsigned int) from, (int) len);715618···726627727628 /* TODO handling oob */728629729729- while (read < len) {730730- thislen = min_t(int, mtd->writesize, len - read);630630+ stats = mtd->ecc_stats;731631732732- column = from & (mtd->writesize - 1);733733- if (column + thislen > mtd->writesize)734734- thislen = mtd->writesize - column;632632+ /* Read-while-load method */735633736736- if (!onenand_check_bufferram(mtd, from)) {737737- this->command(mtd, ONENAND_CMD_READ, from, mtd->writesize);634634+ /* Do first load to bufferRAM */635635+ if (read < len) {636636+ if (!onenand_check_bufferram(mtd, from)) {637637+ this->command(mtd, ONENAND_CMD_READ, from, mtd->writesize);638638+ ret = this->wait(mtd, FL_READING);639639+ onenand_update_bufferram(mtd, from, !ret);640640+ }641641+ }738642739739- ret = this->wait(mtd, FL_READING);740740- /* First copy data and check return value for ECC handling */741741- onenand_update_bufferram(mtd, from, 1);742742- }643643+ thislen = min_t(int, mtd->writesize, len - read);644644+ column = from & (mtd->writesize - 1);645645+ if (column + thislen > mtd->writesize)646646+ thislen = mtd->writesize - column;743647744744- this->read_bufferram(mtd, ONENAND_DATARAM, buf, column, thislen);648648+ while (!ret) {649649+ /* If there is more to load then start next load */650650+ from += thislen;651651+ if (read + thislen < len) {652652+ this->command(mtd, ONENAND_CMD_READ, from, mtd->writesize);653653+ /*654654+ * Chip boundary handling in DDP655655+ * Now we issued chip 1 read and pointed chip 1656656+ * bufferam so we have to point chip 0 bufferam.657657+ */658658+ if (this->device_id & ONENAND_DEVICE_IS_DDP &&659659+ unlikely(from == (this->chipsize >> 1))) {660660+ this->write_word(0, this->base + ONENAND_REG_START_ADDRESS2);661661+ boundary = 1;662662+ } else663663+ boundary = 0;664664+ ONENAND_SET_PREV_BUFFERRAM(this);665665+ }666666+ /* While load is going, read from last bufferRAM */667667+ this->read_bufferram(mtd, ONENAND_DATARAM, buf, column, thislen);668668+ /* See if we are done */669669+ read += thislen;670670+ if (read == len)671671+ break;672672+ /* Set up for next read from bufferRAM */673673+ if (unlikely(boundary))674674+ this->write_word(0x8000, this->base + ONENAND_REG_START_ADDRESS2);675675+ ONENAND_SET_NEXT_BUFFERRAM(this);676676+ buf += thislen;677677+ thislen = min_t(int, mtd->writesize, len - read);678678+ column = 0;679679+ cond_resched();680680+ /* Now wait for load */681681+ ret = this->wait(mtd, FL_READING);682682+ onenand_update_bufferram(mtd, from, !ret);683683+ }745684746746- read += thislen;747747-748748- if (read == len)749749- break;750750-751751- if (ret) {752752- DEBUG(MTD_DEBUG_LEVEL0, "onenand_read: read failed = %d\n", ret);753753- goto out;754754- }755755-756756- from += thislen;757757- buf += thislen;758758- }759759-760760-out:761685 /* Deselect and wake up anyone waiting on the device */762686 onenand_release_device(mtd);763687···790668 * retlen == desired len and result == -EBADMSG791669 */792670 *retlen = read;793793- return ret;671671+672672+ if (mtd->ecc_stats.failed - stats.failed)673673+ return -EBADMSG;674674+675675+ if (ret)676676+ return ret;677677+678678+ return mtd->ecc_stats.corrected - stats.corrected ? -EUCLEAN : 0;794679}795680796681/**···834705 column = from & (mtd->oobsize - 1);835706836707 while (read < len) {708708+ cond_resched();709709+837710 thislen = mtd->oobsize - column;838711 thislen = min_t(int, thislen, len);839712···848717849718 this->read_bufferram(mtd, ONENAND_SPARERAM, buf, column, thislen);850719720720+ if (ret) {721721+ DEBUG(MTD_DEBUG_LEVEL0, "onenand_read_oob: read failed = 0x%x\n", ret);722722+ goto out;723723+ }724724+851725 read += thislen;852726853727 if (read == len)854728 break;855855-856856- if (ret) {857857- DEBUG(MTD_DEBUG_LEVEL0, "onenand_read_oob: read failed = %d\n", ret);858858- goto out;859859- }860729861730 buf += thislen;862731···887756{888757 BUG_ON(ops->mode != MTD_OOB_PLACE);889758890890- return onenand_do_read_oob(mtd, from + ops->ooboffs, ops->len,891891- &ops->retlen, ops->oobbuf);759759+ return onenand_do_read_oob(mtd, from + ops->ooboffs, ops->ooblen,760760+ &ops->oobretlen, ops->oobbuf);892761}893762894763#ifdef CONFIG_MTD_ONENAND_VERIFY_WRITE···935804 void __iomem *dataram0, *dataram1;936805 int ret = 0;937806807807+ /* In partial page write, just skip it */808808+ if ((addr & (mtd->writesize - 1)) != 0)809809+ return 0;810810+938811 this->command(mtd, ONENAND_CMD_READ, addr, mtd->writesize);939812940813 ret = this->wait(mtd, FL_READING);···961826#define onenand_verify_oob(...) (0)962827#endif963828964964-#define NOTALIGNED(x) ((x & (mtd->writesize - 1)) != 0)829829+#define NOTALIGNED(x) ((x & (this->subpagesize - 1)) != 0)965830966831/**967832 * onenand_write - [MTD Interface] write buffer to FLASH···979844 struct onenand_chip *this = mtd->priv;980845 int written = 0;981846 int ret = 0;847847+ int column, subpage;982848983849 DEBUG(MTD_DEBUG_LEVEL3, "onenand_write: to = 0x%08x, len = %i\n", (unsigned int) to, (int) len);984850···998862 return -EINVAL;999863 }1000864865865+ column = to & (mtd->writesize - 1);866866+ subpage = column || (len & (mtd->writesize - 1));867867+1001868 /* Grab the lock and see if the device is available */1002869 onenand_get_device(mtd, FL_WRITING);10038701004871 /* Loop until all data write */1005872 while (written < len) {10061006- int thislen = min_t(int, mtd->writesize, len - written);873873+ int bytes = mtd->writesize;874874+ int thislen = min_t(int, bytes, len - written);875875+ u_char *wbuf = (u_char *) buf;100787610081008- this->command(mtd, ONENAND_CMD_BUFFERRAM, to, mtd->writesize);877877+ cond_resched();100987810101010- this->write_bufferram(mtd, ONENAND_DATARAM, buf, 0, thislen);879879+ this->command(mtd, ONENAND_CMD_BUFFERRAM, to, bytes);880880+881881+ /* Partial page write */882882+ if (subpage) {883883+ bytes = min_t(int, bytes - column, (int) len);884884+ memset(this->page_buf, 0xff, mtd->writesize);885885+ memcpy(this->page_buf + column, buf, bytes);886886+ wbuf = this->page_buf;887887+ /* Even though partial write, we need page size */888888+ thislen = mtd->writesize;889889+ }890890+891891+ this->write_bufferram(mtd, ONENAND_DATARAM, wbuf, 0, thislen);1011892 this->write_bufferram(mtd, ONENAND_SPARERAM, ffchars, 0, mtd->oobsize);10128931013894 this->command(mtd, ONENAND_CMD_PROG, to, mtd->writesize);101489510151015- onenand_update_bufferram(mtd, to, 1);896896+ /* In partial page write we don't update bufferram */897897+ onenand_update_bufferram(mtd, to, !subpage);10168981017899 ret = this->wait(mtd, FL_WRITING);1018900 if (ret) {1019901 DEBUG(MTD_DEBUG_LEVEL0, "onenand_write: write filaed %d\n", ret);10201020- goto out;902902+ break;903903+ }904904+905905+ /* Only check verify write turn on */906906+ ret = onenand_verify_page(mtd, (u_char *) wbuf, to);907907+ if (ret) {908908+ DEBUG(MTD_DEBUG_LEVEL0, "onenand_write: verify failed %d\n", ret);909909+ break;1021910 }10229111023912 written += thislen;102491310251025- /* Only check verify write turn on */10261026- ret = onenand_verify_page(mtd, (u_char *) buf, to);10271027- if (ret) {10281028- DEBUG(MTD_DEBUG_LEVEL0, "onenand_write: verify failed %d\n", ret);10291029- goto out;10301030- }10311031-1032914 if (written == len)1033915 break;1034916917917+ column = 0;1035918 to += thislen;1036919 buf += thislen;1037920 }103892110391039-out:1040922 /* Deselect and wake up anyone waiting on the device */1041923 onenand_release_device(mtd);1042924···1097943 /* Loop until all data write */1098944 while (written < len) {1099945 int thislen = min_t(int, mtd->oobsize, len - written);946946+947947+ cond_resched();11009481101949 column = to & (mtd->oobsize - 1);1102950···1155999{11561000 BUG_ON(ops->mode != MTD_OOB_PLACE);1157100111581158- return onenand_do_write_oob(mtd, to + ops->ooboffs, ops->len,11591159- &ops->retlen, ops->oobbuf);10021002+ return onenand_do_write_oob(mtd, to + ops->ooboffs, ops->ooblen,10031003+ &ops->oobretlen, ops->oobbuf);11601004}1161100511621006/**···12271071 instr->state = MTD_ERASING;1228107212291073 while (len) {10741074+ cond_resched();1230107512311076 /* Check if we have a bad block, we do not erase bad blocks */12321077 if (onenand_block_checkbad(mtd, addr, 0, 0)) {···12411084 ret = this->wait(mtd, FL_ERASING);12421085 /* Check, if it is write protected */12431086 if (ret) {12441244- if (ret == -EPERM)12451245- DEBUG(MTD_DEBUG_LEVEL0, "onenand_erase: Device is write protected!!!\n");12461246- else12471247- DEBUG(MTD_DEBUG_LEVEL0, "onenand_erase: Failed erase, block %d\n", (unsigned) (addr >> this->erase_shift));10871087+ DEBUG(MTD_DEBUG_LEVEL0, "onenand_erase: Failed erase, block %d\n", (unsigned) (addr >> this->erase_shift));12481088 instr->state = MTD_ERASE_FAILED;12491089 instr->fail_addr = addr;12501090 goto erase_exit;···12821128 /* Release it and go back */12831129 onenand_release_device(mtd);12841130}12851285-1286113112871132/**12881133 * onenand_block_isbad - [MTD Interface] Check whether the block at the given offset is bad···13491196}1350119713511198/**13521352- * onenand_unlock - [MTD Interface] Unlock block(s)11991199+ * onenand_do_lock_cmd - [OneNAND Interface] Lock or unlock block(s)13531200 * @param mtd MTD device structure13541201 * @param ofs offset relative to mtd start13551355- * @param len number of bytes to unlock12021202+ * @param len number of bytes to lock or unlock13561203 *13571357- * Unlock one or more blocks12041204+ * Lock or unlock one or more blocks13581205 */13591359-static int onenand_unlock(struct mtd_info *mtd, loff_t ofs, size_t len)12061206+static int onenand_do_lock_cmd(struct mtd_info *mtd, loff_t ofs, size_t len, int cmd)13601207{13611208 struct onenand_chip *this = mtd->priv;13621209 int start, end, block, value, status;12101210+ int wp_status_mask;1363121113641212 start = ofs >> this->erase_shift;13651213 end = len >> this->erase_shift;12141214+12151215+ if (cmd == ONENAND_CMD_LOCK)12161216+ wp_status_mask = ONENAND_WP_LS;12171217+ else12181218+ wp_status_mask = ONENAND_WP_US;1366121913671220 /* Continuous lock scheme */13681221 if (this->options & ONENAND_HAS_CONT_LOCK) {···13761217 this->write_word(start, this->base + ONENAND_REG_START_BLOCK_ADDRESS);13771218 /* Set end block address */13781219 this->write_word(start + end - 1, this->base + ONENAND_REG_END_BLOCK_ADDRESS);13791379- /* Write unlock command */13801380- this->command(mtd, ONENAND_CMD_UNLOCK, 0, 0);12201220+ /* Write lock command */12211221+ this->command(mtd, cmd, 0, 0);1381122213821223 /* There's no return value */13831383- this->wait(mtd, FL_UNLOCKING);12241224+ this->wait(mtd, FL_LOCKING);1384122513851226 /* Sanity check */13861227 while (this->read_word(this->base + ONENAND_REG_CTRL_STATUS)···1389123013901231 /* Check lock status */13911232 status = this->read_word(this->base + ONENAND_REG_WP_STATUS);13921392- if (!(status & ONENAND_WP_US))12331233+ if (!(status & wp_status_mask))13931234 printk(KERN_ERR "wp status = 0x%x\n", status);1394123513951236 return 0;···14051246 this->write_word(value, this->base + ONENAND_REG_START_ADDRESS2);14061247 /* Set start block address */14071248 this->write_word(block, this->base + ONENAND_REG_START_BLOCK_ADDRESS);14081408- /* Write unlock command */14091409- this->command(mtd, ONENAND_CMD_UNLOCK, 0, 0);12491249+ /* Write lock command */12501250+ this->command(mtd, cmd, 0, 0);1410125114111252 /* There's no return value */14121412- this->wait(mtd, FL_UNLOCKING);12531253+ this->wait(mtd, FL_LOCKING);1413125414141255 /* Sanity check */14151256 while (this->read_word(this->base + ONENAND_REG_CTRL_STATUS)···1418125914191260 /* Check lock status */14201261 status = this->read_word(this->base + ONENAND_REG_WP_STATUS);14211421- if (!(status & ONENAND_WP_US))12621262+ if (!(status & wp_status_mask))14221263 printk(KERN_ERR "block = %d, wp status = 0x%x\n", block, status);14231264 }1424126514251266 return 0;12671267+}12681268+12691269+/**12701270+ * onenand_lock - [MTD Interface] Lock block(s)12711271+ * @param mtd MTD device structure12721272+ * @param ofs offset relative to mtd start12731273+ * @param len number of bytes to unlock12741274+ *12751275+ * Lock one or more blocks12761276+ */12771277+static int onenand_lock(struct mtd_info *mtd, loff_t ofs, size_t len)12781278+{12791279+ return onenand_do_lock_cmd(mtd, ofs, len, ONENAND_CMD_LOCK);12801280+}12811281+12821282+/**12831283+ * onenand_unlock - [MTD Interface] Unlock block(s)12841284+ * @param mtd MTD device structure12851285+ * @param ofs offset relative to mtd start12861286+ * @param len number of bytes to unlock12871287+ *12881288+ * Unlock one or more blocks12891289+ */12901290+static int onenand_unlock(struct mtd_info *mtd, loff_t ofs, size_t len)12911291+{12921292+ return onenand_do_lock_cmd(mtd, ofs, len, ONENAND_CMD_UNLOCK);14261293}1427129414281295/**···14951310 this->command(mtd, ONENAND_CMD_UNLOCK_ALL, 0, 0);1496131114971312 /* There's no return value */14981498- this->wait(mtd, FL_UNLOCKING);13131313+ this->wait(mtd, FL_LOCKING);1499131415001315 /* Sanity check */15011316 while (this->read_word(this->base + ONENAND_REG_CTRL_STATUS)···15191334 return 0;15201335 }1521133615221522- mtd->unlock(mtd, 0x0, this->chipsize);13371337+ onenand_unlock(mtd, 0x0, this->chipsize);1523133815241339 return 0;15251340}···19471762 /* Read manufacturer and device IDs from Register */19481763 maf_id = this->read_word(this->base + ONENAND_REG_MANUFACTURER_ID);19491764 dev_id = this->read_word(this->base + ONENAND_REG_DEVICE_ID);19501950- ver_id= this->read_word(this->base + ONENAND_REG_VERSION_ID);17651765+ ver_id = this->read_word(this->base + ONENAND_REG_VERSION_ID);1951176619521767 /* Check OneNAND device */19531768 if (maf_id != bram_maf_id || dev_id != bram_dev_id)···20311846 if (!this->command)20321847 this->command = onenand_command;20331848 if (!this->wait)20342034- this->wait = onenand_wait;18491849+ onenand_setup_wait(mtd);2035185020361851 if (!this->read_bufferram)20371852 this->read_bufferram = onenand_read_bufferram;···20681883 init_waitqueue_head(&this->wq);20691884 spin_lock_init(&this->chip_lock);2070188518861886+ /*18871887+ * Allow subpage writes up to oobsize.18881888+ */20711889 switch (mtd->oobsize) {20721890 case 64:20731891 this->ecclayout = &onenand_oob_64;18921892+ mtd->subpage_sft = 2;20741893 break;2075189420761895 case 32:20771896 this->ecclayout = &onenand_oob_32;18971897+ mtd->subpage_sft = 1;20781898 break;2079189920801900 default:20811901 printk(KERN_WARNING "No OOB scheme defined for oobsize %d\n",20821902 mtd->oobsize);19031903+ mtd->subpage_sft = 0;20831904 /* To prevent kernel oops */20841905 this->ecclayout = &onenand_oob_32;20851906 break;20861907 }2087190819091909+ this->subpagesize = mtd->writesize >> mtd->subpage_sft;20881910 mtd->ecclayout = this->ecclayout;2089191120901912 /* Fill in remaining MTD driver data */···21141922 mtd->lock_user_prot_reg = onenand_lock_user_prot_reg;21151923#endif21161924 mtd->sync = onenand_sync;21172117- mtd->lock = NULL;19251925+ mtd->lock = onenand_lock;21181926 mtd->unlock = onenand_unlock;21191927 mtd->suspend = onenand_suspend;21201928 mtd->resume = onenand_resume;
+6-8
drivers/mtd/onenand/onenand_bbt.c
···9393 ret = onenand_do_read_oob(mtd, from + j * mtd->writesize + bd->offs,9494 readlen, &retlen, &buf[0]);95959696- if (ret)9696+ /* If it is a initial bad block, just ignore it */9797+ if (ret && !(ret & ONENAND_CTRL_LOAD))9798 return ret;989999100 if (check_short_pattern(&buf[j * scanlen], scanlen, mtd->writesize, bd)) {100101 bbm->bbt[i >> 3] |= 0x03 << (i & 0x6);101102 printk(KERN_WARNING "Bad eraseblock %d at 0x%08x\n",102103 i >> 1, (unsigned int) from);104104+ mtd->ecc_stats.badblocks++;103105 break;104106 }105107 }···179177 int len, ret = 0;180178181179 len = mtd->size >> (this->erase_shift + 2);182182- /* Allocate memory (2bit per block) */183183- bbm->bbt = kmalloc(len, GFP_KERNEL);180180+ /* Allocate memory (2bit per block) and clear the memory bad block table */181181+ bbm->bbt = kzalloc(len, GFP_KERNEL);184182 if (!bbm->bbt) {185183 printk(KERN_ERR "onenand_scan_bbt: Out of memory\n");186184 return -ENOMEM;187185 }188188- /* Clear the memory bad block table */189189- memset(bbm->bbt, 0x00, len);190186191187 /* Set the bad block position */192188 bbm->badblockpos = ONENAND_BADBLOCK_POS;···230230 struct onenand_chip *this = mtd->priv;231231 struct bbm_info *bbm;232232233233- this->bbm = kmalloc(sizeof(struct bbm_info), GFP_KERNEL);233233+ this->bbm = kzalloc(sizeof(struct bbm_info), GFP_KERNEL);234234 if (!this->bbm)235235 return -ENOMEM;236236237237 bbm = this->bbm;238238-239239- memset(bbm, 0, sizeof(struct bbm_info));240238241239 /* 1KB page has same configuration as 2KB page */242240 if (!bbm->badblock_pattern)
+24-6
drivers/mtd/redboot.c
···9696 */9797 if (swab32(buf[i].size) == master->erasesize) {9898 int j;9999- for (j = 0; j < numslots && buf[j].name[0] != 0xff; ++j) {9999+ for (j = 0; j < numslots; ++j) {100100+101101+ /* A single 0xff denotes a deleted entry.102102+ * Two of them in a row is the end of the table.103103+ */104104+ if (buf[j].name[0] == 0xff) {105105+ if (buf[j].name[1] == 0xff) {106106+ break;107107+ } else {108108+ continue;109109+ }110110+ }111111+100112 /* The unsigned long fields were written with the101113 * wrong byte sex, name and pad have no byte sex.102114 */···122110 }123111 }124112 break;113113+ } else {114114+ /* re-calculate of real numslots */115115+ numslots = buf[i].size / sizeof(struct fis_image_desc);125116 }126117 }127118 if (i == numslots) {···138123 for (i = 0; i < numslots; i++) {139124 struct fis_list *new_fl, **prev;140125141141- if (buf[i].name[0] == 0xff)142142- continue;126126+ if (buf[i].name[0] == 0xff) {127127+ if (buf[i].name[1] == 0xff) {128128+ break;129129+ } else {130130+ continue;131131+ }132132+ }143133 if (!redboot_checksum(&buf[i]))144134 break;145135···185165 }186166 }187167#endif188188- parts = kmalloc(sizeof(*parts)*nrparts + nulllen + namelen, GFP_KERNEL);168168+ parts = kzalloc(sizeof(*parts)*nrparts + nulllen + namelen, GFP_KERNEL);189169190170 if (!parts) {191171 ret = -ENOMEM;192172 goto out;193173 }194194-195195- memset(parts, 0, sizeof(*parts)*nrparts + nulllen + namelen);196174197175 nullname = (char *)&parts[nrparts];198176#ifdef CONFIG_MTD_REDBOOT_PARTS_UNALLOCATED
···150150}151151152152/**153153- * pci_match_device - Tell if a PCI device structure has a matching154154- * PCI device id structure153153+ * pci_match_device - Tell if a PCI device structure has a matching PCI device id structure155154 * @drv: the PCI driver to match against156155 * @dev: the PCI device structure to match against157156 *
+5
drivers/pci/quirks.c
···10021002 case 0x186a: /* M6Ne notebook */10031003 asus_hides_smbus = 1;10041004 }10051005+ if (dev->device == PCI_DEVICE_ID_INTEL_82865_HB)10061006+ switch (dev->subsystem_device) {10071007+ case 0x80f2: /* P4P800-X */10081008+ asus_hides_smbus = 1;10091009+ }10051010 if (dev->device == PCI_DEVICE_ID_INTEL_82915GM_HB) {10061011 switch (dev->subsystem_device) {10071012 case 0x1882: /* M6V notebook */
···72727373 If you are unsure about this, say N here.74747575-config USB_MULTITHREAD_PROBE7676- bool "USB Multi-threaded probe (EXPERIMENTAL)"7777- depends on USB && EXPERIMENTAL7878- default n7979- help8080- Say Y here if you want the USB core to spawn a new thread for8181- every USB device that is probed. This can cause a small speedup8282- in boot times on systems with a lot of different USB devices.8383-8484- This option should be safe to enable, but if any odd probing8585- problems are found, please disable it, or dynamically turn it8686- off in the /sys/module/usbcore/parameters/multithread_probe8787- file8888-8989- When in doubt, say N.9090-9175config USB_OTG9276 bool9377 depends on USB && EXPERIMENTAL
+1-8
drivers/usb/core/hub.c
···8888static struct task_struct *khubd_task;89899090/* multithreaded probe logic */9191-static int multithread_probe =9292-#ifdef CONFIG_USB_MULTITHREAD_PROBE9393- 1;9494-#else9595- 0;9696-#endif9797-module_param(multithread_probe, bool, S_IRUGO);9898-MODULE_PARM_DESC(multithread_probe, "Run each USB device probe in a new thread");9191+static int multithread_probe = 0;999210093/* cycle leds on hubs that aren't blinking for attention */10194static int blinkenlights = 0;
···197197 US_SC_DEVICE, US_PR_DEVICE, NULL,198198 US_FL_MAX_SECTORS_64 ),199199200200+/* Reported by Manuel Osdoba <manuel.osdoba@tu-ilmenau.de> */201201+UNUSUAL_DEV( 0x0421, 0x0492, 0x0452, 0x0452,202202+ "Nokia",203203+ "Nokia 6233",204204+ US_SC_DEVICE, US_PR_DEVICE, NULL,205205+ US_FL_MAX_SECTORS_64 ),206206+200207/* Reported by Alex Corcoles <alex@corcoles.net> */201208UNUSUAL_DEV( 0x0421, 0x0495, 0x0370, 0x0370,202209 "Nokia",···260253 "Rio Karma",261254 US_SC_SCSI, US_PR_KARMA, rio_karma_init, 0),262255#endif256256+257257+/*258258+ * This virtual floppy is found in Sun equipment (x4600, x4200m2, etc.)259259+ * Reported by Pete Zaitcev <zaitcev@redhat.com>260260+ * This device chokes on both version of MODE SENSE which we have, so261261+ * use_10_for_ms is not effective, and we use US_FL_NO_WP_DETECT.262262+ */263263+UNUSUAL_DEV( 0x046b, 0xff40, 0x0100, 0x0100,264264+ "AMI",265265+ "Virtual Floppy",266266+ US_SC_DEVICE, US_PR_DEVICE, NULL,267267+ US_FL_NO_WP_DETECT),263268264269/* Patch submitted by Philipp Friedrich <philipp@void.at> */265270UNUSUAL_DEV( 0x0482, 0x0100, 0x0100, 0x0100,
+9-1
fs/block_dev.c
···146146 iocb->ki_nbytes = -EIO;147147148148 if (atomic_dec_and_test(bio_count)) {149149- if (iocb->ki_nbytes < 0)149149+ if ((long)iocb->ki_nbytes < 0)150150 aio_complete(iocb, iocb->ki_nbytes, 0);151151 else152152 aio_complete(iocb, iocb->ki_left, 0);···188188 pvec->idx = 0;189189 }190190 return pvec->page[pvec->idx++];191191+}192192+193193+/* return a page back to pvec array */194194+static void blk_unget_page(struct page *page, struct pvec *pvec)195195+{196196+ pvec->page[--pvec->idx] = page;191197}192198193199static ssize_t···284278 count = min(count, nbytes);285279 goto same_bio;286280 }281281+ } else {282282+ blk_unget_page(page, &pvec);287283 }288284289285 /* bio is ready, submit it */
···838838839839 for (raw = f->inocache->nodes; raw != (void *)f->inocache; raw = raw->next_in_ino) {840840841841+ cond_resched();842842+841843 /* We only care about obsolete ones */842844 if (!(ref_obsolete(raw)))843845 continue;
···128128 }129129130130 if (jffs2_sum_active()) {131131- s = kmalloc(sizeof(struct jffs2_summary), GFP_KERNEL);131131+ s = kzalloc(sizeof(struct jffs2_summary), GFP_KERNEL);132132 if (!s) {133133+ kfree(flashbuf);133134 JFFS2_WARNING("Can't allocate memory for summary\n");134135 return -ENOMEM;135136 }136136- memset(s, 0, sizeof(struct jffs2_summary));137137 }138138139139 for (i=0; i<c->nr_blocks; i++) {140140 struct jffs2_eraseblock *jeb = &c->blocks[i];141141+142142+ cond_resched();141143142144 /* reset summary info for next eraseblock scan */143145 jffs2_sum_reset_collected(s);
+3-3
fs/jffs2/summary.c
···26262727int jffs2_sum_init(struct jffs2_sb_info *c)2828{2929- c->summary = kmalloc(sizeof(struct jffs2_summary), GFP_KERNEL);2929+ c->summary = kzalloc(sizeof(struct jffs2_summary), GFP_KERNEL);30303131 if (!c->summary) {3232 JFFS2_WARNING("Can't allocate memory for summary information!\n");3333 return -ENOMEM;3434 }3535-3636- memset(c->summary, 0, sizeof(struct jffs2_summary));37353836 c->summary->sum_buf = vmalloc(c->sector_size);3937···395397396398 for (i=0; i<je32_to_cpu(summary->sum_num); i++) {397399 dbg_summary("processing summary index %d\n", i);400400+401401+ cond_resched();398402399403 /* Make sure there's a spare ref for dirty space */400404 err = jffs2_prealloc_raw_node_refs(c, jeb, 2);
+4-3
fs/jffs2/super.c
···1717#include <linux/init.h>1818#include <linux/list.h>1919#include <linux/fs.h>2020+#include <linux/err.h>2021#include <linux/mount.h>2122#include <linux/jffs2.h>2223#include <linux/pagemap.h>···185184 struct mtd_info *mtd;186185187186 mtd = get_mtd_device(NULL, mtdnr);188188- if (!mtd) {187187+ if (IS_ERR(mtd)) {189188 D1(printk(KERN_DEBUG "jffs2: MTD device #%u doesn't appear to exist\n", mtdnr));190190- return -EINVAL;189189+ return PTR_ERR(mtd);191190 }192191193192 return jffs2_get_sb_mtd(fs_type, flags, dev_name, data, mtd, mnt);···222221 D1(printk(KERN_DEBUG "jffs2_get_sb(): mtd:%%s, name \"%s\"\n", dev_name+4));223222 for (mtdnr = 0; mtdnr < MAX_MTD_DEVICES; mtdnr++) {224223 mtd = get_mtd_device(NULL, mtdnr);225225- if (mtd) {224224+ if (!IS_ERR(mtd)) {226225 if (!strcmp(mtd->name, dev_name+4))227226 return jffs2_get_sb_mtd(fs_type, flags, dev_name, data, mtd, mnt);228227 put_mtd_device(mtd);
+1-1
fs/jffs2/symlink.c
···5151 */52525353 if (!p) {5454- printk(KERN_ERR "jffs2_follow_link(): can't find symlink taerget\n");5454+ printk(KERN_ERR "jffs2_follow_link(): can't find symlink target\n");5555 p = ERR_PTR(-EIO);5656 }5757 D1(printk(KERN_DEBUG "jffs2_follow_link(): target path is '%s'\n", (char *) f->target));
+9-12
fs/jffs2/wbuf.c
···969969 int oobsize = c->mtd->oobsize;970970 struct mtd_oob_ops ops;971971972972- ops.len = NR_OOB_SCAN_PAGES * oobsize;973973- ops.ooblen = oobsize;972972+ ops.ooblen = NR_OOB_SCAN_PAGES * oobsize;974973 ops.oobbuf = c->oobbuf;975974 ops.ooboffs = 0;976975 ops.datbuf = NULL;···982983 return ret;983984 }984985985985- if (ops.retlen < ops.len) {986986+ if (ops.oobretlen < ops.ooblen) {986987 D1(printk(KERN_WARNING "jffs2_check_oob_empty(): Read OOB "987988 "returned short read (%zd bytes not %d) for block "988988- "at %08x\n", ops.retlen, ops.len, jeb->offset));989989+ "at %08x\n", ops.oobretlen, ops.ooblen, jeb->offset));989990 return -EIO;990991 }991992···10041005 }1005100610061007 /* we know, we are aligned :) */10071007- for (page = oobsize; page < ops.len; page += sizeof(long)) {10081008+ for (page = oobsize; page < ops.ooblen; page += sizeof(long)) {10081009 long dat = *(long *)(&ops.oobbuf[page]);10091010 if(dat != -1)10101011 return 1;···10321033 return 2;10331034 }1034103510351035- ops.len = oobsize;10361036 ops.ooblen = oobsize;10371037 ops.oobbuf = c->oobbuf;10381038 ops.ooboffs = 0;···10461048 return ret;10471049 }1048105010491049- if (ops.retlen < ops.len) {10511051+ if (ops.oobretlen < ops.ooblen) {10501052 D1 (printk (KERN_WARNING "jffs2_check_nand_cleanmarker(): "10511053 "Read OOB return short read (%zd bytes not %d) "10521052- "for block at %08x\n", ops.retlen, ops.len,10541054+ "for block at %08x\n", ops.oobretlen, ops.ooblen,10531055 jeb->offset));10541056 return -EIO;10551057 }···10881090 n.nodetype = cpu_to_je16(JFFS2_NODETYPE_CLEANMARKER);10891091 n.totlen = cpu_to_je32(8);1090109210911091- ops.len = c->fsdata_len;10921092- ops.ooblen = c->fsdata_len;;10931093+ ops.ooblen = c->fsdata_len;10931094 ops.oobbuf = (uint8_t *)&n;10941095 ops.ooboffs = c->fsdata_pos;10951096 ops.datbuf = NULL;···11021105 jeb->offset, ret));11031106 return ret;11041107 }11051105- if (ops.retlen != ops.len) {11081108+ if (ops.oobretlen != ops.ooblen) {11061109 D1(printk(KERN_WARNING "jffs2_write_nand_cleanmarker(): "11071110 "Short write for block at %08x: %zd not %d\n",11081108- jeb->offset, ops.retlen, ops.len));11111111+ jeb->offset, ops.oobretlen, ops.ooblen));11091112 return -EIO;11101113 }11111114 return 0;
+2-3
fs/jffs2/xattr.c
···399399{400400 /* must be called under down_write(xattr_sem) */401401 if (atomic_dec_and_lock(&xd->refcnt, &c->erase_completion_lock)) {402402- uint32_t xid = xd->xid, version = xd->version;403403-404402 unload_xattr_datum(c, xd);405403 xd->flags |= JFFS2_XFLAGS_DEAD;406404 if (xd->node == (void *)xd) {···409411 }410412 spin_unlock(&c->erase_completion_lock);411413412412- dbg_xattr("xdatum(xid=%u, version=%u) was removed.\n", xid, version);414414+ dbg_xattr("xdatum(xid=%u, version=%u) was removed.\n",415415+ xd->xid, xd->version);413416 }414417}415418
···2424 struct mtd_info *mtd;2525 struct mutex lock;2626 int devnum;2727- int blksize;2827 unsigned long size;2928 int readonly;3029 void *blkcore_priv; /* gendisk in 2.5, devfs_handle in 2.4 */···3536 char *name;3637 int major;3738 int part_bits;3939+ int blksize;4040+ int blkshift;38413942 /* Access functions */4043 int (*readsect)(struct mtd_blktrans_dev *dev,
+16-8
include/linux/mtd/mtd.h
···23232424#define MTD_CHAR_MAJOR 902525#define MTD_BLOCK_MAJOR 312626-#define MAX_MTD_DEVICES 162626+#define MAX_MTD_DEVICES 3227272828#define MTD_ERASE_PENDING 0x012929#define MTD_ERASING 0x02···7575 * struct mtd_oob_ops - oob operation operands7676 * @mode: operation mode7777 *7878- * @len: number of bytes to write/read. When a data buffer is given7979- * (datbuf != NULL) this is the number of data bytes. When8080- * no data buffer is available this is the number of oob bytes.7878+ * @len: number of data bytes to write/read8179 *8282- * @retlen: number of bytes written/read. When a data buffer is given8383- * (datbuf != NULL) this is the number of data bytes. When8484- * no data buffer is available this is the number of oob bytes.8080+ * @retlen: number of data bytes written/read8581 *8686- * @ooblen: number of oob bytes per page8282+ * @ooblen: number of oob bytes to write/read8383+ * @oobretlen: number of oob bytes written/read8784 * @ooboffs: offset of oob data in the oob area (only relevant when8885 * mode = MTD_OOB_PLACE)8986 * @datbuf: data buffer - if NULL only oob data are read/written···9194 size_t len;9295 size_t retlen;9396 size_t ooblen;9797+ size_t oobretlen;9498 uint32_t ooboffs;9599 uint8_t *datbuf;96100 uint8_t *oobbuf;···200202201203 /* ECC status information */202204 struct mtd_ecc_stats ecc_stats;205205+ /* Subpage shift (NAND) */206206+ int subpage_sft;203207204208 void *priv;205209206210 struct module *owner;207211 int usecount;212212+213213+ /* If the driver is something smart, like UBI, it may need to maintain214214+ * its own reference counting. The below functions are only for driver.215215+ * The driver may register its callbacks. These callbacks are not216216+ * supposed to be called by MTD users */217217+ int (*get_device) (struct mtd_info *mtd);218218+ void (*put_device) (struct mtd_info *mtd);208219};209220210221···223216extern int del_mtd_device (struct mtd_info *mtd);224217225218extern struct mtd_info *get_mtd_device(struct mtd_info *mtd, int num);219219+extern struct mtd_info *get_mtd_device_nm(const char *name);226220227221extern void put_mtd_device(struct mtd_info *mtd);228222
+10-5
include/linux/mtd/nand.h
···166166 * for all large page devices, as they do not support167167 * autoincrement.*/168168#define NAND_NO_READRDY 0x00000100169169+/* Chip does not allow subpage writes */170170+#define NAND_NO_SUBPAGE_WRITE 0x00000200171171+169172170173/* Options valid for Samsung large page devices */171174#define NAND_SAMSUNG_LP_OPTIONS \···196193/* Nand scan has allocated controller struct */197194#define NAND_CONTROLLER_ALLOC 0x80000000198195196196+/* Cell info constants */197197+#define NAND_CI_CHIPNR_MSK 0x03198198+#define NAND_CI_CELLTYPE_MSK 0x0C199199200200/*201201 * nand_state_t - chip states···292286 * struct nand_buffers - buffer structure for read/write293287 * @ecccalc: buffer for calculated ecc294288 * @ecccode: buffer for ecc read from flash295295- * @oobwbuf: buffer for write oob data296289 * @databuf: buffer for data - dynamically sized297297- * @oobrbuf: buffer to read oob data298290 *299291 * Do not change the order of buffers. databuf and oobrbuf must be in300292 * consecutive order.···300296struct nand_buffers {301297 uint8_t ecccalc[NAND_MAX_OOBSIZE];302298 uint8_t ecccode[NAND_MAX_OOBSIZE];303303- uint8_t oobwbuf[NAND_MAX_OOBSIZE];304304- uint8_t databuf[NAND_MAX_PAGESIZE];305305- uint8_t oobrbuf[NAND_MAX_OOBSIZE];299299+ uint8_t databuf[NAND_MAX_PAGESIZE + NAND_MAX_OOBSIZE];306300};307301308302/**···347345 * @chipsize: [INTERN] the size of one chip for multichip arrays348346 * @pagemask: [INTERN] page number mask = number of (pages / chip) - 1349347 * @pagebuf: [INTERN] holds the pagenumber which is currently in data_buf348348+ * @subpagesize: [INTERN] holds the subpagesize350349 * @ecclayout: [REPLACEABLE] the default ecc placement scheme351350 * @bbt: [INTERN] bad block table pointer352351 * @bbt_td: [REPLACEABLE] bad block table descriptor for flash lookup···395392 unsigned long chipsize;396393 int pagemask;397394 int pagebuf;395395+ int subpagesize;396396+ uint8_t cellinfo;398397 int badblockpos;399398400399 nand_state_t state;
+7-1
include/linux/mtd/onenand.h
···1313#define __LINUX_MTD_ONENAND_H14141515#include <linux/spinlock.h>1616+#include <linux/completion.h>1617#include <linux/mtd/onenand_regs.h>1718#include <linux/mtd/bbm.h>1819···3433 FL_WRITING,3534 FL_ERASING,3635 FL_SYNCING,3737- FL_UNLOCKING,3836 FL_LOCKING,3937 FL_RESETING,4038 FL_OTPING,···8888 * operation is in progress8989 * @state: [INTERN] the current state of the OneNAND device9090 * @page_buf: data buffer9191+ * @subpagesize: [INTERN] holds the subpagesize9192 * @ecclayout: [REPLACEABLE] the default ecc placement scheme9293 * @bbm: [REPLACEABLE] pointer to Bad Block Management9394 * @priv: [OPTIONAL] pointer to private chip date···121120 int (*block_markbad)(struct mtd_info *mtd, loff_t ofs);122121 int (*scan_bbt)(struct mtd_info *mtd);123122123123+ struct completion complete;124124+ int irq;125125+124126 spinlock_t chip_lock;125127 wait_queue_head_t wq;126128 onenand_state_t state;127129 unsigned char *page_buf;128130131131+ int subpagesize;129132 struct nand_ecclayout *ecclayout;130133131134 void *bbm;···143138#define ONENAND_CURRENT_BUFFERRAM(this) (this->bufferram_index)144139#define ONENAND_NEXT_BUFFERRAM(this) (this->bufferram_index ^ 1)145140#define ONENAND_SET_NEXT_BUFFERRAM(this) (this->bufferram_index ^= 1)141141+#define ONENAND_SET_PREV_BUFFERRAM(this) (this->bufferram_index ^= 1)146142147143#define ONENAND_GET_SYS_CFG1(this) \148144 (this->read_word(this->base + ONENAND_REG_SYS_CFG1))
···10101111#include <linux/types.h>1212#include <linux/ioctl.h>1313-#include <linux/qic117.h>14131514/*1615 * Structures and definitions for mag tape io control commands···115116#define MT_ISFTAPE_UNKNOWN 0x800000 /* obsolete */116117#define MT_ISFTAPE_FLAG 0x800000117118118118-struct mt_tape_info {119119- long t_type; /* device type id (mt_type) */120120- char *t_name; /* descriptive name */121121-};122122-123123-#define MT_TAPE_INFO { \124124- {MT_ISUNKNOWN, "Unknown type of tape device"}, \125125- {MT_ISQIC02, "Generic QIC-02 tape streamer"}, \126126- {MT_ISWT5150, "Wangtek 5150, QIC-150"}, \127127- {MT_ISARCHIVE_5945L2, "Archive 5945L-2"}, \128128- {MT_ISCMSJ500, "CMS Jumbo 500"}, \129129- {MT_ISTDC3610, "Tandberg TDC 3610, QIC-24"}, \130130- {MT_ISARCHIVE_VP60I, "Archive VP60i, QIC-02"}, \131131- {MT_ISARCHIVE_2150L, "Archive Viper 2150L"}, \132132- {MT_ISARCHIVE_2060L, "Archive Viper 2060L"}, \133133- {MT_ISARCHIVESC499, "Archive SC-499 QIC-36 controller"}, \134134- {MT_ISQIC02_ALL_FEATURES, "Generic QIC-02 tape, all features"}, \135135- {MT_ISWT5099EEN24, "Wangtek 5099-een24, 60MB"}, \136136- {MT_ISTEAC_MT2ST, "Teac MT-2ST 155mb data cassette drive"}, \137137- {MT_ISEVEREX_FT40A, "Everex FT40A, QIC-40"}, \138138- {MT_ISONSTREAM_SC, "OnStream SC-, DI-, DP-, or USB tape drive"}, \139139- {MT_ISSCSI1, "Generic SCSI-1 tape"}, \140140- {MT_ISSCSI2, "Generic SCSI-2 tape"}, \141141- {0, NULL} \142142-}143143-144119145120/* structure for MTIOCPOS - mag tape get position command */146121···123150};124151125152126126-/* structure for MTIOCVOLINFO, query information about the volume127127- * currently positioned at (zftape)128128- */129129-struct mtvolinfo {130130- unsigned int mt_volno; /* vol-number */131131- unsigned int mt_blksz; /* blocksize used when recording */132132- unsigned int mt_rawsize; /* raw tape space consumed, in kb */133133- unsigned int mt_size; /* volume size after decompression, in kb */134134- unsigned int mt_cmpr:1; /* this volume has been compressed */135135-};136136-137137-/* raw access to a floppy drive, read and write an arbitrary segment.138138- * For ftape/zftape to support formatting etc.139139- */140140-#define MT_FT_RD_SINGLE 0141141-#define MT_FT_RD_AHEAD 1142142-#define MT_FT_WR_ASYNC 0 /* start tape only when all buffers are full */143143-#define MT_FT_WR_MULTI 1 /* start tape, continue until buffers are empty */144144-#define MT_FT_WR_SINGLE 2 /* write a single segment and stop afterwards */145145-#define MT_FT_WR_DELETE 3 /* write deleted data marks, one segment at time */146146-147147-struct mtftseg148148-{ 149149- unsigned mt_segno; /* the segment to read or write */150150- unsigned mt_mode; /* modes for read/write (sync/async etc.) */151151- int mt_result; /* result of r/w request, not of the ioctl */152152- void __user *mt_data; /* User space buffer: must be 29kb */153153-};154154-155155-/* get tape capacity (ftape/zftape)156156- */157157-struct mttapesize {158158- unsigned long mt_capacity; /* entire, uncompressed capacity 159159- * of a cartridge160160- */161161- unsigned long mt_used; /* what has been used so far, raw 162162- * uncompressed amount163163- */164164-};165165-166166-/* possible values of the ftfmt_op field167167- */168168-#define FTFMT_SET_PARMS 1 /* set software parms */169169-#define FTFMT_GET_PARMS 2 /* get software parms */170170-#define FTFMT_FORMAT_TRACK 3 /* start formatting a tape track */171171-#define FTFMT_STATUS 4 /* monitor formatting a tape track */172172-#define FTFMT_VERIFY 5 /* verify the given segment */173173-174174-struct ftfmtparms {175175- unsigned char ft_qicstd; /* QIC-40/QIC-80/QIC-3010/QIC-3020 */176176- unsigned char ft_fmtcode; /* Refer to the QIC specs */177177- unsigned char ft_fhm; /* floppy head max */178178- unsigned char ft_ftm; /* floppy track max */179179- unsigned short ft_spt; /* segments per track */180180- unsigned short ft_tpc; /* tracks per cartridge */181181-};182182-183183-struct ftfmttrack {184184- unsigned int ft_track; /* track to format */185185- unsigned char ft_gap3; /* size of gap3, for FORMAT_TRK */186186-};187187-188188-struct ftfmtstatus {189189- unsigned int ft_segment; /* segment currently being formatted */190190-};191191-192192-struct ftfmtverify {193193- unsigned int ft_segment; /* segment to verify */194194- unsigned long ft_bsm; /* bsm as result of VERIFY cmd */195195-};196196-197197-struct mtftformat {198198- unsigned int fmt_op; /* operation to perform */199199- union fmt_arg {200200- struct ftfmtparms fmt_parms; /* format parameters */201201- struct ftfmttrack fmt_track; /* ctrl while formatting */202202- struct ftfmtstatus fmt_status;203203- struct ftfmtverify fmt_verify; /* for verifying */ 204204- } fmt_arg;205205-};206206-207207-struct mtftcmd {208208- unsigned int ft_wait_before; /* timeout to wait for drive to get ready 209209- * before command is sent. Milliseconds210210- */211211- qic117_cmd_t ft_cmd; /* command to send */212212- unsigned char ft_parm_cnt; /* zero: no parm is sent. */213213- unsigned char ft_parms[3]; /* parameter(s) to send to214214- * the drive. The parms are nibbles215215- * driver sends cmd + 2 step pulses */216216- unsigned int ft_result_bits; /* if non zero, number of bits217217- * returned by the tape drive218218- */219219- unsigned int ft_result; /* the result returned by the tape drive*/220220- unsigned int ft_wait_after; /* timeout to wait for drive to get ready221221- * after command is sent. 0: don't wait */222222- int ft_status; /* status returned by ready wait223223- * undefined if timeout was 0.224224- */225225- int ft_error; /* error code if error status was set by 226226- * command227227- */228228-};229229-230153/* mag tape io control commands */231154#define MTIOCTOP _IOW('m', 1, struct mtop) /* do a mag tape op */232155#define MTIOCGET _IOR('m', 2, struct mtget) /* get tape status */233156#define MTIOCPOS _IOR('m', 3, struct mtpos) /* get tape position */234157235235-/* The next two are used by the QIC-02 driver for runtime reconfiguration.236236- * See tpqic02.h for struct mtconfiginfo.237237- */238238-#define MTIOCGETCONFIG _IOR('m', 4, struct mtconfiginfo) /* get tape config */239239-#define MTIOCSETCONFIG _IOW('m', 5, struct mtconfiginfo) /* set tape config */240240-241241-/* the next six are used by the floppy ftape drivers and its frontends242242- * sorry, but MTIOCTOP commands are write only.243243- */244244-#define MTIOCRDFTSEG _IOWR('m', 6, struct mtftseg) /* read a segment */245245-#define MTIOCWRFTSEG _IOWR('m', 7, struct mtftseg) /* write a segment */246246-#define MTIOCVOLINFO _IOR('m', 8, struct mtvolinfo) /* info about volume */247247-#define MTIOCGETSIZE _IOR('m', 9, struct mttapesize)/* get cartridge size*/248248-#define MTIOCFTFORMAT _IOWR('m', 10, struct mtftformat) /* format ftape */249249-#define MTIOCFTCMD _IOWR('m', 11, struct mtftcmd) /* send QIC-117 cmd */250158251159/* Generic Mag Tape (device independent) status macros for examining252160 * mt_gstat -- HP-UX compatible.
-290
include/linux/qic117.h
···11-#ifndef _QIC117_H22-#define _QIC117_H33-44-/*55- * Copyright (C) 1993-1996 Bas Laarhoven,66- * (C) 1997 Claus-Justus Heine.77-88- This program is free software; you can redistribute it and/or modify99- it under the terms of the GNU General Public License as published by1010- the Free Software Foundation; either version 2, or (at your option)1111- any later version.1212-1313- This program is distributed in the hope that it will be useful,1414- but WITHOUT ANY WARRANTY; without even the implied warranty of1515- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the1616- GNU General Public License for more details.1717-1818- You should have received a copy of the GNU General Public License1919- along with this program; see the file COPYING. If not, write to2020- the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.2121-2222- *2323- * $Source: /homes/cvs/ftape-stacked/include/linux/qic117.h,v $2424- * $Revision: 1.2 $2525- * $Date: 1997/10/05 19:19:32 $2626- *2727- * This file contains QIC-117 spec. related definitions for the2828- * QIC-40/80/3010/3020 floppy-tape driver "ftape" for Linux.2929- *3030- * These data were taken from the Quarter-Inch Cartridge3131- * Drive Standards, Inc. document titled:3232- * `Common Command Set Interface Specification for Flexible3333- * Disk Controller Based Minicartridge Tape Drives'3434- * document QIC-117 Revision J, 28 Aug 96.3535- * For more information, contact:3636- * Quarter-Inch Cartridge Drive Standards, Inc.3737- * 311 East Carrillo Street3838- * Santa Barbara, California 931013939- * Telephone (805) 963-38534040- * Fax (805) 962-15414141- * WWW http://www.qic.org4242- *4343- * Current QIC standard revisions (of interest) are:4444- * QIC-40-MC, Rev. M, 2 Sep 92.4545- * QIC-80-MC, Rev. N, 20 Mar 96.4646- * QIC-80-MC, Rev. K, 15 Dec 94.4747- * QIC-113, Rev. G, 15 Jun 95.4848- * QIC-117, Rev. J, 28 Aug 96.4949- * QIC-122, Rev. B, 6 Mar 91.5050- * QIC-130, Rev. C, 2 Sep 92.5151- * QIC-3010-MC, Rev. F, 14 Jun 95.5252- * QIC-3020-MC, Rev. G, 31 Aug 95.5353- * QIC-CRF3, Rev. B, 15 Jun 95.5454- * */5555-5656-/*5757- * QIC-117 common command set rev. J.5858- * These commands are sent to the tape unit5959- * as number of pulses over the step line.6060- */6161-6262-typedef enum {6363- QIC_NO_COMMAND = 0,6464- QIC_RESET = 1,6565- QIC_REPORT_NEXT_BIT = 2,6666- QIC_PAUSE = 3,6767- QIC_MICRO_STEP_PAUSE = 4,6868- QIC_ALTERNATE_TIMEOUT = 5,6969- QIC_REPORT_DRIVE_STATUS = 6,7070- QIC_REPORT_ERROR_CODE = 7,7171- QIC_REPORT_DRIVE_CONFIGURATION = 8,7272- QIC_REPORT_ROM_VERSION = 9,7373- QIC_LOGICAL_FORWARD = 10,7474- QIC_PHYSICAL_REVERSE = 11,7575- QIC_PHYSICAL_FORWARD = 12,7676- QIC_SEEK_HEAD_TO_TRACK = 13,7777- QIC_SEEK_LOAD_POINT = 14,7878- QIC_ENTER_FORMAT_MODE = 15,7979- QIC_WRITE_REFERENCE_BURST = 16,8080- QIC_ENTER_VERIFY_MODE = 17,8181- QIC_STOP_TAPE = 18,8282-/* commands 19-20: reserved */8383- QIC_MICRO_STEP_HEAD_UP = 21,8484- QIC_MICRO_STEP_HEAD_DOWN = 22,8585- QIC_SOFT_SELECT = 23,8686- QIC_SOFT_DESELECT = 24,8787- QIC_SKIP_REVERSE = 25,8888- QIC_SKIP_FORWARD = 26,8989- QIC_SELECT_RATE = 27,9090-/* command 27, in ccs2: Select Rate or Format */9191- QIC_ENTER_DIAGNOSTIC_1 = 28,9292- QIC_ENTER_DIAGNOSTIC_2 = 29,9393- QIC_ENTER_PRIMARY_MODE = 30,9494-/* command 31: vendor unique */9595- QIC_REPORT_VENDOR_ID = 32,9696- QIC_REPORT_TAPE_STATUS = 33,9797- QIC_SKIP_EXTENDED_REVERSE = 34,9898- QIC_SKIP_EXTENDED_FORWARD = 35,9999- QIC_CALIBRATE_TAPE_LENGTH = 36,100100- QIC_REPORT_FORMAT_SEGMENTS = 37,101101- QIC_SET_FORMAT_SEGMENTS = 38,102102-/* commands 39-45: reserved */103103- QIC_PHANTOM_SELECT = 46,104104- QIC_PHANTOM_DESELECT = 47105105-} qic117_cmd_t;106106-107107-typedef enum {108108- discretional = 0, required, ccs1, ccs2109109-} qic_compatibility;110110-111111-typedef enum {112112- unused, mode, motion, report113113-} command_types;114114-115115-struct qic117_command_table {116116- char *name;117117- __u8 mask;118118- __u8 state;119119- __u8 cmd_type;120120- __u8 non_intr;121121- __u8 level;122122-};123123-124124-#define QIC117_COMMANDS {\125125-/* command mask state cmd_type */\126126-/* | name | | | non_intr */\127127-/* | | | | | | level */\128128-/* 0*/ {NULL, 0x00, 0x00, mode, 0, discretional},\129129-/* 1*/ {"soft reset", 0x00, 0x00, motion, 1, required},\130130-/* 2*/ {"report next bit", 0x00, 0x00, report, 0, required},\131131-/* 3*/ {"pause", 0x36, 0x24, motion, 1, required},\132132-/* 4*/ {"micro step pause", 0x36, 0x24, motion, 1, required},\133133-/* 5*/ {"alternate command timeout", 0x00, 0x00, mode, 0, required},\134134-/* 6*/ {"report drive status", 0x00, 0x00, report, 0, required},\135135-/* 7*/ {"report error code", 0x01, 0x01, report, 0, required},\136136-/* 8*/ {"report drive configuration",0x00, 0x00, report, 0, required},\137137-/* 9*/ {"report rom version", 0x00, 0x00, report, 0, required},\138138-/*10*/ {"logical forward", 0x37, 0x25, motion, 0, required},\139139-/*11*/ {"physical reverse", 0x17, 0x05, motion, 0, required},\140140-/*12*/ {"physical forward", 0x17, 0x05, motion, 0, required},\141141-/*13*/ {"seek head to track", 0x37, 0x25, motion, 0, required},\142142-/*14*/ {"seek load point", 0x17, 0x05, motion, 1, required},\143143-/*15*/ {"enter format mode", 0x1f, 0x05, mode, 0, required},\144144-/*16*/ {"write reference burst", 0x1f, 0x05, motion, 1, required},\145145-/*17*/ {"enter verify mode", 0x37, 0x25, mode, 0, required},\146146-/*18*/ {"stop tape", 0x00, 0x00, motion, 1, required},\147147-/*19*/ {"reserved (19)", 0x00, 0x00, unused, 0, discretional},\148148-/*20*/ {"reserved (20)", 0x00, 0x00, unused, 0, discretional},\149149-/*21*/ {"micro step head up", 0x02, 0x00, motion, 0, required},\150150-/*22*/ {"micro step head down", 0x02, 0x00, motion, 0, required},\151151-/*23*/ {"soft select", 0x00, 0x00, mode, 0, discretional},\152152-/*24*/ {"soft deselect", 0x00, 0x00, mode, 0, discretional},\153153-/*25*/ {"skip segments reverse", 0x36, 0x24, motion, 1, required},\154154-/*26*/ {"skip segments forward", 0x36, 0x24, motion, 1, required},\155155-/*27*/ {"select rate or format", 0x03, 0x01, mode, 0, required /* [ccs2] */},\156156-/*28*/ {"enter diag mode 1", 0x00, 0x00, mode, 0, discretional},\157157-/*29*/ {"enter diag mode 2", 0x00, 0x00, mode, 0, discretional},\158158-/*30*/ {"enter primary mode", 0x00, 0x00, mode, 0, required},\159159-/*31*/ {"vendor unique (31)", 0x00, 0x00, unused, 0, discretional},\160160-/*32*/ {"report vendor id", 0x00, 0x00, report, 0, required},\161161-/*33*/ {"report tape status", 0x04, 0x04, report, 0, ccs1},\162162-/*34*/ {"skip extended reverse", 0x36, 0x24, motion, 1, ccs1},\163163-/*35*/ {"skip extended forward", 0x36, 0x24, motion, 1, ccs1},\164164-/*36*/ {"calibrate tape length", 0x17, 0x05, motion, 1, ccs2},\165165-/*37*/ {"report format segments", 0x17, 0x05, report, 0, ccs2},\166166-/*38*/ {"set format segments", 0x17, 0x05, mode, 0, ccs2},\167167-/*39*/ {"reserved (39)", 0x00, 0x00, unused, 0, discretional},\168168-/*40*/ {"vendor unique (40)", 0x00, 0x00, unused, 0, discretional},\169169-/*41*/ {"vendor unique (41)", 0x00, 0x00, unused, 0, discretional},\170170-/*42*/ {"vendor unique (42)", 0x00, 0x00, unused, 0, discretional},\171171-/*43*/ {"vendor unique (43)", 0x00, 0x00, unused, 0, discretional},\172172-/*44*/ {"vendor unique (44)", 0x00, 0x00, unused, 0, discretional},\173173-/*45*/ {"vendor unique (45)", 0x00, 0x00, unused, 0, discretional},\174174-/*46*/ {"phantom select", 0x00, 0x00, mode, 0, discretional},\175175-/*47*/ {"phantom deselect", 0x00, 0x00, mode, 0, discretional},\176176-}177177-178178-/*179179- * Status bits returned by QIC_REPORT_DRIVE_STATUS180180- */181181-182182-#define QIC_STATUS_READY 0x01 /* Drive is ready or idle. */183183-#define QIC_STATUS_ERROR 0x02 /* Error detected, must read184184- error code to clear this */185185-#define QIC_STATUS_CARTRIDGE_PRESENT 0x04 /* Tape is present */186186-#define QIC_STATUS_WRITE_PROTECT 0x08 /* Tape is write protected */187187-#define QIC_STATUS_NEW_CARTRIDGE 0x10 /* New cartridge inserted, must188188- read error status to clear. */189189-#define QIC_STATUS_REFERENCED 0x20 /* Cartridge appears to have been190190- formatted. */191191-#define QIC_STATUS_AT_BOT 0x40 /* Cartridge is at physical192192- beginning of tape. */193193-#define QIC_STATUS_AT_EOT 0x80 /* Cartridge is at physical end194194- of tape. */195195-/*196196- * Status bits returned by QIC_REPORT_DRIVE_CONFIGURATION197197- */198198-199199-#define QIC_CONFIG_RATE_MASK 0x18200200-#define QIC_CONFIG_RATE_SHIFT 3201201-#define QIC_CONFIG_RATE_250 0202202-#define QIC_CONFIG_RATE_500 2203203-#define QIC_CONFIG_RATE_1000 3204204-#define QIC_CONFIG_RATE_2000 1205205-#define QIC_CONFIG_RATE_4000 0 /* since QIC-117 Rev. J */206206-207207-#define QIC_CONFIG_LONG 0x40 /* Extra Length Tape Detected */208208-#define QIC_CONFIG_80 0x80 /* QIC-80 detected. */209209-210210-/*211211- * Status bits returned by QIC_REPORT_TAPE_STATUS212212- */213213-214214-#define QIC_TAPE_STD_MASK 0x0f215215-#define QIC_TAPE_QIC40 0x01216216-#define QIC_TAPE_QIC80 0x02217217-#define QIC_TAPE_QIC3020 0x03218218-#define QIC_TAPE_QIC3010 0x04219219-220220-#define QIC_TAPE_LEN_MASK 0x70221221-#define QIC_TAPE_205FT 0x10222222-#define QIC_TAPE_307FT 0x20223223-#define QIC_TAPE_VARIABLE 0x30224224-#define QIC_TAPE_1100FT 0x40225225-#define QIC_TAPE_FLEX 0x60226226-227227-#define QIC_TAPE_WIDE 0x80228228-229229-/* Define a value (in feet) slightly higher than 230230- * the possible maximum tape length.231231- */232232-#define QIC_TOP_TAPE_LEN 1500233233-234234-/*235235- * Errors: List of error codes, and their severity.236236- */237237-238238-typedef struct {239239- char *message; /* Text describing the error. */240240- unsigned int fatal:1; /* Non-zero if the error is fatal. */241241-} ftape_error;242242-243243-#define QIC117_ERRORS {\244244- /* 0*/ { "No error", 0, },\245245- /* 1*/ { "Command Received while Drive Not Ready", 0, },\246246- /* 2*/ { "Cartridge Not Present or Removed", 1, },\247247- /* 3*/ { "Motor Speed Error (not within 1%)", 1, },\248248- /* 4*/ { "Motor Speed Fault (jammed, or gross speed error", 1, },\249249- /* 5*/ { "Cartridge Write Protected", 1, },\250250- /* 6*/ { "Undefined or Reserved Command Code", 1, },\251251- /* 7*/ { "Illegal Track Address Specified for Seek", 1, },\252252- /* 8*/ { "Illegal Command in Report Subcontext", 0, },\253253- /* 9*/ { "Illegal Entry into a Diagnostic Mode", 1, },\254254- /*10*/ { "Broken Tape Detected (based on hole sensor)", 1, },\255255- /*11*/ { "Warning--Read Gain Setting Error", 1, },\256256- /*12*/ { "Command Received While Error Status Pending (obs)", 1, },\257257- /*13*/ { "Command Received While New Cartridge Pending", 1, },\258258- /*14*/ { "Command Illegal or Undefined in Primary Mode", 1, },\259259- /*15*/ { "Command Illegal or Undefined in Format Mode", 1, },\260260- /*16*/ { "Command Illegal or Undefined in Verify Mode", 1, },\261261- /*17*/ { "Logical Forward Not at Logical BOT or no Format Segments in Format Mode", 1, },\262262- /*18*/ { "Logical EOT Before All Segments generated", 1, },\263263- /*19*/ { "Command Illegal When Cartridge Not Referenced", 1, },\264264- /*20*/ { "Self-Diagnostic Failed (cannot be cleared)", 1, },\265265- /*21*/ { "Warning EEPROM Not Initialized, Defaults Set", 1, },\266266- /*22*/ { "EEPROM Corrupted or Hardware Failure", 1, },\267267- /*23*/ { "Motion Time-out Error", 1, },\268268- /*24*/ { "Data Segment Too Long -- Logical Forward or Pause", 1, },\269269- /*25*/ { "Transmit Overrun (obs)", 1, },\270270- /*26*/ { "Power On Reset Occurred", 0, },\271271- /*27*/ { "Software Reset Occurred", 0, },\272272- /*28*/ { "Diagnostic Mode 1 Error", 1, },\273273- /*29*/ { "Diagnostic Mode 2 Error", 1, },\274274- /*30*/ { "Command Received During Non-Interruptible Process", 1, },\275275- /*31*/ { "Rate or Format Selection Error", 1, },\276276- /*32*/ { "Illegal Command While in High Speed Mode", 1, },\277277- /*33*/ { "Illegal Seek Segment Value", 1, },\278278- /*34*/ { "Invalid Media", 1, },\279279- /*35*/ { "Head Positioning Failure", 1, },\280280- /*36*/ { "Write Reference Burst Failure", 1, },\281281- /*37*/ { "Prom Code Missing", 1, },\282282- /*38*/ { "Invalid Format", 1, },\283283- /*39*/ { "EOT/BOT System Failure", 1, },\284284- /*40*/ { "Prom A Checksum Error", 1, },\285285- /*41*/ { "Drive Wakeup Reset Occurred", 1, },\286286- /*42*/ { "Prom B Checksum Error", 1, },\287287- /*43*/ { "Illegal Entry into Format Mode", 1, },\288288-}289289-290290-#endif /* _QIC117_H */
···323323int blocking_notifier_call_chain(struct blocking_notifier_head *nh,324324 unsigned long val, void *v)325325{326326- int ret;326326+ int ret = NOTIFY_DONE;327327328328- down_read(&nh->rwsem);329329- ret = notifier_call_chain(&nh->head, val, v);330330- up_read(&nh->rwsem);328328+ /*329329+ * We check the head outside the lock, but if this access is330330+ * racy then it does not matter what the result of the test331331+ * is, we re-check the list after having taken the lock anyway:332332+ */333333+ if (rcu_dereference(nh->head)) {334334+ down_read(&nh->rwsem);335335+ ret = notifier_call_chain(&nh->head, val, v);336336+ up_read(&nh->rwsem);337337+ }331338 return ret;332339}333340
+4
mm/mempolicy.c
···884884 err = get_nodes(&nodes, nmask, maxnode);885885 if (err)886886 return err;887887+#ifdef CONFIG_CPUSETS888888+ /* Restrict the nodes to the allowed nodes in the cpuset */889889+ nodes_and(nodes, nodes, current->mems_allowed);890890+#endif887891 return do_mbind(start, len, mode, &nodes, flags);888892}889893