···11+What: /sys/bus/pci/drivers/.../bind22+Date: December 200333+Contact: linux-pci@vger.kernel.org44+Description:55+ Writing a device location to this file will cause66+ the driver to attempt to bind to the device found at77+ this location. This is useful for overriding default88+ bindings. The format for the location is: DDDD:BB:DD.F.99+ That is Domain:Bus:Device.Function and is the same as1010+ found in /sys/bus/pci/devices/. For example:1111+ # echo 0000:00:19.0 > /sys/bus/pci/drivers/foo/bind1212+ (Note: kernels before 2.6.28 may require echo -n).1313+1414+What: /sys/bus/pci/drivers/.../unbind1515+Date: December 20031616+Contact: linux-pci@vger.kernel.org1717+Description:1818+ Writing a device location to this file will cause the1919+ driver to attempt to unbind from the device found at2020+ this location. This may be useful when overriding default2121+ bindings. The format for the location is: DDDD:BB:DD.F.2222+ That is Domain:Bus:Device.Function and is the same as2323+ found in /sys/bus/pci/devices/. For example:2424+ # echo 0000:00:19.0 > /sys/bus/pci/drivers/foo/unbind2525+ (Note: kernels before 2.6.28 may require echo -n).2626+2727+What: /sys/bus/pci/drivers/.../new_id2828+Date: December 20032929+Contact: linux-pci@vger.kernel.org3030+Description:3131+ Writing a device ID to this file will attempt to3232+ dynamically add a new device ID to a PCI device driver.3333+ This may allow the driver to support more hardware than3434+ was included in the driver's static device ID support3535+ table at compile time. The format for the device ID is:3636+ VVVV DDDD SVVV SDDD CCCC MMMM PPPP. That is Vendor ID,3737+ Device ID, Subsystem Vendor ID, Subsystem Device ID,3838+ Class, Class Mask, and Private Driver Data. The Vendor ID3939+ and Device ID fields are required, the rest are optional.4040+ Upon successfully adding an ID, the driver will probe4141+ for the device and attempt to bind to it. For example:4242+ # echo "8086 10f5" > /sys/bus/pci/drivers/foo/new_id4343+144What: /sys/bus/pci/devices/.../vpd245Date: February 2008346Contact: Ben Hutchings <bhutchings@solarflare.com>
-205
Documentation/dvb/README.flexcop
···11-This README escorted the skystar2-driver rewriting procedure. It describes the22-state of the new flexcop-driver set and some internals are written down here33-too.44-55-This document hopefully describes things about the flexcop and its66-device-offsprings. Goal was to write an easy-to-write and easy-to-read set of77-drivers based on the skystar2.c and other information.88-99-Remark: flexcop-pci.c was a copy of skystar2.c, but every line has been1010-touched and rewritten.1111-1212-History & News1313-==============1414- 2005-04-01 - correct USB ISOC transfers (thanks to Vadim Catana)1515-1616-1717-1818-1919-General coding processing2020-=========================2121-2222-We should proceed as follows (as long as no one complains):2323-2424-0) Think before start writing code!2525-2626-1) rewriting the skystar2.c with the help of the flexcop register descriptions2727-and splitting up the files to a pci-bus-part and a flexcop-part.2828-The new driver will be called b2c2-flexcop-pci.ko/b2c2-flexcop-usb.ko for the2929-device-specific part and b2c2-flexcop.ko for the common flexcop-functions.3030-3131-2) Search for errors in the leftover of flexcop-pci.c (compare with pluto2.c3232-and other pci drivers)3333-3434-3) make some beautification (see 'Improvements when rewriting (refactoring) is3535-done')3636-3737-4) Testing the new driver and maybe substitute the skystar2.c with it, to reach3838-a wider tester audience.3939-4040-5) creating an usb-bus-part using the already written flexcop code for the pci4141-card.4242-4343-Idea: create a kernel-object for the flexcop and export all important4444-functions. This option saves kernel-memory, but maybe a lot of functions have4545-to be exported to kernel namespace.4646-4747-4848-Current situation4949-=================5050-5151-0) Done :)5252-1) Done (some minor issues left)5353-2) Done5454-3) Not ready yet, more information is necessary5555-4) next to be done (see the table below)5656-5) USB driver is working (yes, there are some minor issues)5757-5858-What seems to be ready?5959------------------------6060-6161-1) Rewriting6262-1a) i2c is cut off from the flexcop-pci.c and seems to work6363-1b) moved tuner and demod stuff from flexcop-pci.c to flexcop-tuner-fe.c6464-1c) moved lnb and diseqc stuff from flexcop-pci.c to flexcop-tuner-fe.c6565-1e) eeprom (reading MAC address)6666-1d) sram (no dynamic sll size detection (commented out) (using default as JJ told me))6767-1f) misc. register accesses for reading parameters (e.g. resetting, revision)6868-1g) pid/mac filter (flexcop-hw-filter.c)6969-1i) dvb-stuff initialization in flexcop.c (done)7070-1h) dma stuff (now just using the size-irq, instead of all-together, to be done)7171-1j) remove flexcop initialization from flexcop-pci.c completely (done)7272-1l) use a well working dma IRQ method (done, see 'Known bugs and problems and TODO')7373-1k) cleanup flexcop-files (remove unused EXPORT_SYMBOLs, make static from7474-non-static where possible, moved code to proper places)7575-7676-2) Search for errors in the leftover of flexcop-pci.c (partially done)7777-5a) add MAC address reading7878-5c) feeding of ISOC data to the software demux (format of the isochronous data7979-and speed optimization, no real error) (thanks to Vadim Catana)8080-8181-What to do in the near future?8282---------------------------------------8383-(no special order here)8484-8585-5) USB driver8686-5b) optimize isoc-transfer (submitting/killing isoc URBs when transfer is starting)8787-8888-Testing changes8989----------------9090-9191-O = item is working9292-P = item is partially working9393-X = item is not working9494-N = item does not apply here9595-<empty field> = item need to be examined9696-9797- | PCI | USB9898-item | mt352 | nxt2002 | stv0299 | mt312 | mt352 | nxt2002 | stv0299 | mt3129999--------+-------+---------+---------+-------+-------+---------+---------+-------100100-1a) | O | | | | N | N | N | N101101-1b) | O | | | | | | O |102102-1c) | N | N | | | N | N | O |103103-1d) | O | O104104-1e) | O | O105105-1f) | P106106-1g) | O107107-1h) | P |108108-1i) | O | N109109-1j) | O | N110110-1l) | O | N111111-2) | O | N112112-5a) | N | O113113-5b)* | N |114114-5c) | N | O115115-116116-* - not done yet117117-118118-Known bugs and problems and TODO119119---------------------------------120120-121121-1g/h/l) when pid filtering is enabled on the pci card122122-123123-DMA usage currently:124124- The DMA is splitted in 2 equal-sized subbuffers. The Flexcop writes to first125125- address and triggers an IRQ when it's full and starts writing to the second126126- address. When the second address is full, the IRQ is triggered again, and127127- the flexcop writes to first address again, and so on.128128- The buffersize of each address is currently 640*188 bytes.129129-130130- Problem is, when using hw-pid-filtering and doing some low-bandwidth131131- operation (like scanning) the buffers won't be filled enough to trigger132132- the IRQ. That's why:133133-134134- When PID filtering is activated, the timer IRQ is used. Every 1.97 ms the IRQ135135- is triggered. Is the current write address of DMA1 different to the one136136- during the last IRQ, then the data is passed to the demuxer.137137-138138- There is an additional DMA-IRQ-method: packet count IRQ. This isn't139139- implemented correctly yet.140140-141141- The solution is to disable HW PID filtering, but I don't know how the DVB142142- API software demux behaves on slow systems with 45MBit/s TS.143143-144144-Solved bugs :)145145---------------146146-1g) pid-filtering (somehow pid index 4 and 5 (EMM_PID and ECM_PID) aren't147147-working)148148-SOLUTION: also index 0 was affected, because net_translation is done for149149-these indexes by default150150-151151-5b) isochronous transfer does only work in the first attempt (for the Sky2PC152152-USB, Air2PC is working) SOLUTION: the flexcop was going asleep and never really153153-woke up again (don't know if this need fixes, see154154-flexcop-fe-tuner.c:flexcop_sleep)155155-156156-NEWS: when the driver is loaded and unloaded and loaded again (w/o doing157157-anything in the while the driver is loaded the first time), no transfers take158158-place anymore.159159-160160-Improvements when rewriting (refactoring) is done161161-=================================================162162-163163-- split sleeping of the flexcop (misc_204.ACPI3_sig = 1;) from lnb_control164164- (enable sleeping for other demods than dvb-s)165165-- add support for CableStar (stv0297 Microtune 203x/ALPS) (almost done, incompatibilities with the Nexus-CA)166166-167167-Debugging168168----------169169-- add verbose debugging to skystar2.c (dump the reg_dw_data) and compare it170170- with this flexcop, this is important, because i2c is now using the171171- flexcop_ibi_value union from flexcop-reg.h (do you have a better idea for172172- that, please tell us so).173173-174174-Everything which is identical in the following table, can be put into a common175175-flexcop-module.176176-177177- PCI USB178178--------------------------------------------------------------------------------179179-Different:180180-Register access: accessing IO memory USB control message181181-I2C bus: I2C bus of the FC USB control message182182-Data transfer: DMA isochronous transfer183183-EEPROM transfer: through i2c bus not clear yet184184-185185-Identical:186186-Streaming: accessing registers187187-PID Filtering: accessing registers188188-Sram destinations: accessing registers189189-Tuner/Demod: I2C bus190190-DVB-stuff: can be written for common use191191-192192-Acknowledgements (just for the rewriting part)193193-================194194-195195-Bjarne Steinsbo thought a lot in the first place of the pci part for this code196196-sharing idea.197197-198198-Andreas Oberritter for providing a recent PCI initialization template199199-(pluto2.c).200200-201201-Boleslaw Ciesielski for pointing out a problem with firmware loader.202202-203203-Vadim Catana for correcting the USB transfer.204204-205205-comments, critics and ideas to linux-dvb@linuxtv.org.
+20-14
Documentation/dvb/technisat.txt
···11-How to set up the Technisat devices22-===================================11+How to set up the Technisat/B2C2 Flexcop devices22+================================================33441) Find out what device you have55================================···16161717If the Technisat is the only TV device in your box get rid of unnecessary modules and check this one:1818"Multimedia devices" => "Customise analog and hybrid tuner modules to build"1919-In this directory uncheck every driver which is activated there.1919+In this directory uncheck every driver which is activated there (except "Simple tuner support" for case 9 only).20202121Then please activate:22222a) Main module part:23232424a.)"Multimedia devices" => "DVB/ATSC adapters" => "Technisat/B2C2 FlexcopII(b) and FlexCopIII adapters"2525-b.)"Multimedia devices" => "DVB/ATSC adapters" => "Technisat/B2C2 FlexcopII(b) and FlexCopIII adapters" => "Technisat/B2C2 Air/Sky/Cable2PC PCI" in case of a PCI card OR2525+b.)"Multimedia devices" => "DVB/ATSC adapters" => "Technisat/B2C2 FlexcopII(b) and FlexCopIII adapters" => "Technisat/B2C2 Air/Sky/Cable2PC PCI" in case of a PCI card2626+OR2627c.)"Multimedia devices" => "DVB/ATSC adapters" => "Technisat/B2C2 FlexcopII(b) and FlexCopIII adapters" => "Technisat/B2C2 Air/Sky/Cable2PC USB" in case of an USB 1.1 adapter2728d.)"Multimedia devices" => "DVB/ATSC adapters" => "Technisat/B2C2 FlexcopII(b) and FlexCopIII adapters" => "Enable debug for the B2C2 FlexCop drivers"2829Notice: d.) is helpful for troubleshooting293030312b) Frontend module part:31323232-1.) Revision 2.3:3333+1.) SkyStar DVB-S Revision 2.3:3334a.)"Multimedia devices" => "Customise DVB frontends" => "Customise the frontend modules to build"3435b.)"Multimedia devices" => "Customise DVB frontends" => "Zarlink VP310/MT312/ZL10313 based"35363636-2.) Revision 2.6:3737+2.) SkyStar DVB-S Revision 2.6:3738a.)"Multimedia devices" => "Customise DVB frontends" => "Customise the frontend modules to build"3839b.)"Multimedia devices" => "Customise DVB frontends" => "ST STV0299 based"39404040-3.) Revision 2.7:4141+3.) SkyStar DVB-S Revision 2.7:4142a.)"Multimedia devices" => "Customise DVB frontends" => "Customise the frontend modules to build"4243b.)"Multimedia devices" => "Customise DVB frontends" => "Samsung S5H1420 based"4344c.)"Multimedia devices" => "Customise DVB frontends" => "Integrant ITD1000 Zero IF tuner for DVB-S/DSS"4445d.)"Multimedia devices" => "Customise DVB frontends" => "ISL6421 SEC controller"45464646-4.) Revision 2.8:4747+4.) SkyStar DVB-S Revision 2.8:4748a.)"Multimedia devices" => "Customise DVB frontends" => "Customise the frontend modules to build"4849b.)"Multimedia devices" => "Customise DVB frontends" => "Conexant CX24113/CX24128 tuner for DVB-S/DSS"4950c.)"Multimedia devices" => "Customise DVB frontends" => "Conexant CX24123 based"5051d.)"Multimedia devices" => "Customise DVB frontends" => "ISL6421 SEC controller"51525252-5.) DVB-T card:5353+5.) AirStar DVB-T card:5354a.)"Multimedia devices" => "Customise DVB frontends" => "Customise the frontend modules to build"5455b.)"Multimedia devices" => "Customise DVB frontends" => "Zarlink MT352 based"55565656-6.) DVB-C card:5757+6.) CableStar DVB-C card:5758a.)"Multimedia devices" => "Customise DVB frontends" => "Customise the frontend modules to build"5859b.)"Multimedia devices" => "Customise DVB frontends" => "ST STV0297 based"59606060-7.) ATSC card 1st generation:6161+7.) AirStar ATSC card 1st generation:6162a.)"Multimedia devices" => "Customise DVB frontends" => "Customise the frontend modules to build"6263b.)"Multimedia devices" => "Customise DVB frontends" => "Broadcom BCM3510"63646464-8.) ATSC card 2nd generation:6565+8.) AirStar ATSC card 2nd generation:6566a.)"Multimedia devices" => "Customise DVB frontends" => "Customise the frontend modules to build"6667b.)"Multimedia devices" => "Customise DVB frontends" => "NxtWave Communications NXT2002/NXT2004 based"6767-c.)"Multimedia devices" => "Customise DVB frontends" => "LG Electronics LGDT3302/LGDT3303 based"6868+c.)"Multimedia devices" => "Customise DVB frontends" => "Generic I2C PLL based tuners"68696969-Author: Uwe Bugla <uwe.bugla@gmx.de> December 20087070+9.) AirStar ATSC card 3rd generation:7171+a.)"Multimedia devices" => "Customise DVB frontends" => "Customise the frontend modules to build"7272+b.)"Multimedia devices" => "Customise DVB frontends" => "LG Electronics LGDT3302/LGDT3303 based"7373+c.)"Multimedia devices" => "Customise analog and hybrid tuner modules to build" => "Simple tuner support"7474+7575+Author: Uwe Bugla <uwe.bugla@gmx.de> February 2009
+4-2
Documentation/kernel-parameters.txt
···868868 icn= [HW,ISDN]869869 Format: <io>[,<membase>[,<icn_id>[,<icn_id2>]]]870870871871- ide= [HW] (E)IDE subsystem872872- Format: ide=nodma or ide=doubler871871+ ide-core.nodma= [HW] (E)IDE subsystem872872+ Format: =0.0 to prevent dma on hda, =0.1 hdb =1.0 hdc873873+ .vlb_clock .pci_clock .noflush .noprobe .nowerr .cdrom874874+ .chs .ignore_cable are additional options873875 See Documentation/ide/ide.txt.874876875877 idebus= [HW] (E)IDE subsystem - VLB/PCI bus speed
+5-6
Documentation/scsi/cxgb3i.txt
···44============5566The Chelsio T3 ASIC based Adapters (S310, S320, S302, S304, Mezz cards, etc.77-series of products) supports iSCSI acceleration and iSCSI Direct Data Placement77+series of products) support iSCSI acceleration and iSCSI Direct Data Placement88(DDP) where the hardware handles the expensive byte touching operations, such99as CRC computation and verification, and direct DMA to the final host memory1010destination:···3131 the TCP segments onto the wire. It handles TCP retransmission if3232 needed.33333434- On receving, S3 h/w recovers the iSCSI PDU by reassembling TCP3434+ On receiving, S3 h/w recovers the iSCSI PDU by reassembling TCP3535 segments, separating the header and data, calculating and verifying3636- the digests, then forwards the header to the host. The payload data,3636+ the digests, then forwarding the header to the host. The payload data,3737 if possible, will be directly placed into the pre-posted host DDP3838 buffer. Otherwise, the payload data will be sent to the host too.3939···6868 sure the ip address is unique in the network.696970703. edit /etc/iscsi/iscsid.conf7171- The default setting for MaxRecvDataSegmentLength (131072) is too big,7272- replace "node.conn[0].iscsi.MaxRecvDataSegmentLength" to be a value no7373- bigger than 15360 (for example 8192):7171+ The default setting for MaxRecvDataSegmentLength (131072) is too big;7272+ replace with a value no bigger than 15360 (for example 8192):74737574 node.conn[0].iscsi.MaxRecvDataSegmentLength = 81927675
+4-1
Documentation/x86/boot.txt
···543543544544 The payload may be compressed. The format of both the compressed and545545 uncompressed data should be determined using the standard magic546546- numbers. Currently only gzip compressed ELF is used.546546+ numbers. The currently supported compression formats are gzip547547+ (magic numbers 1F 8B or 1F 9E), bzip2 (magic number 42 5A) and LZMA548548+ (magic number 5D 00). The uncompressed payload is currently always ELF549549+ (magic number 7F 45 4C 46).547550548551Field name: payload_length549552Type: read
···638638 and include PCI device scope covered by these DMA639639 remapping devices.640640641641+config DMAR_DEFAULT_ON642642+ def_bool y643643+ prompt "Enable DMA Remapping Devices by default"644644+ depends on DMAR645645+ help646646+ Selecting this option will enable a DMAR device at boot time if647647+ one is found. If this option is not selected, DMAR support can648648+ be enabled by passing intel_iommu=on to the kernel. It is649649+ recommended you say N here while the DMAR code remains650650+ experimental.651651+641652endmenu642653643654endif
+1-1
arch/ia64/kernel/iosapic.c
···507507 if (trigger == IOSAPIC_EDGE)508508 return -EINVAL;509509510510- for (i = 0; i <= NR_IRQS; i++) {510510+ for (i = 0; i < NR_IRQS; i++) {511511 info = &iosapic_intr_info[i];512512 if (info->trigger == trigger && info->polarity == pol &&513513 (info->dmode == IOSAPIC_FIXED ||
+1-1
arch/ia64/kernel/unwind.c
···2149214921502150 /* next, remove hash table entries for this table */2151215121522152- for (index = 0; index <= UNW_HASH_SIZE; ++index) {21522152+ for (index = 0; index < UNW_HASH_SIZE; ++index) {21532153 tmp = unw.cache + unw.hash[index];21542154 if (unw.hash[index] >= UNW_CACHE_SIZE21552155 || tmp->ip < table->start || tmp->ip >= table->end)
+7-2
arch/mips/Kconfig
···603603 select SYS_SUPPORTS_64BIT_KERNEL604604 select SYS_SUPPORTS_BIG_ENDIAN605605 select SYS_SUPPORTS_HIGHMEM606606- select CPU_CAVIUM_OCTEON606606+ select SYS_HAS_CPU_CAVIUM_OCTEON607607 help608608 The Octeon simulator is software performance model of the Cavium609609 Octeon Processor. It supports simulating Octeon processors on x86···618618 select SYS_SUPPORTS_BIG_ENDIAN619619 select SYS_SUPPORTS_HIGHMEM620620 select SYS_HAS_EARLY_PRINTK621621- select CPU_CAVIUM_OCTEON621621+ select SYS_HAS_CPU_CAVIUM_OCTEON622622 select SWAP_IO_SPACE623623 help624624 This option supports all of the Octeon reference boards from Cavium···1234123412351235config CPU_CAVIUM_OCTEON12361236 bool "Cavium Octeon processor"12371237+ depends on SYS_HAS_CPU_CAVIUM_OCTEON12371238 select IRQ_CPU12381239 select IRQ_CPU_OCTEON12391240 select CPU_HAS_PREFETCH···13151314config SYS_HAS_CPU_SB113161315 bool1317131613171317+config SYS_HAS_CPU_CAVIUM_OCTEON13181318+ bool13191319+13181320#13191321# CPU may reorder R->R, R->W, W->R, W->W13201322# Reordering beyond LL and SC is handled in WEAK_REORDERING_BEYOND_LLSC···13911387config 64BIT13921388 bool "64-bit kernel"13931389 depends on CPU_SUPPORTS_64BIT_KERNEL && SYS_SUPPORTS_64BIT_KERNEL13901390+ select HAVE_SYSCALL_WRAPPERS13941391 help13951392 Select this option if you want to build a 64-bit kernel.13961393
+3-3
arch/mips/alchemy/common/time.c
···118118 * setup counter 1 (RTC) to tick at full speed119119 */120120 t = 0xffffff;121121- while ((au_readl(SYS_COUNTER_CNTRL) & SYS_CNTRL_T1S) && t--)121121+ while ((au_readl(SYS_COUNTER_CNTRL) & SYS_CNTRL_T1S) && --t)122122 asm volatile ("nop");123123 if (!t)124124 goto cntr_err;···127127 au_sync();128128129129 t = 0xffffff;130130- while ((au_readl(SYS_COUNTER_CNTRL) & SYS_CNTRL_C1S) && t--)130130+ while ((au_readl(SYS_COUNTER_CNTRL) & SYS_CNTRL_C1S) && --t)131131 asm volatile ("nop");132132 if (!t)133133 goto cntr_err;···135135 au_sync();136136137137 t = 0xffffff;138138- while ((au_readl(SYS_COUNTER_CNTRL) & SYS_CNTRL_C1S) && t--)138138+ while ((au_readl(SYS_COUNTER_CNTRL) & SYS_CNTRL_C1S) && --t)139139 asm volatile ("nop");140140 if (!t)141141 goto cntr_err;
···152152 return error;153153}154154155155-asmlinkage unsigned long156156-old_mmap(unsigned long addr, unsigned long len, int prot,157157- int flags, int fd, off_t offset)155155+SYSCALL_DEFINE6(mips_mmap, unsigned long, addr, unsigned long, len,156156+ unsigned long, prot, unsigned long, flags, unsigned long,157157+ fd, off_t, offset)158158{159159 unsigned long result;160160···168168 return result;169169}170170171171-asmlinkage unsigned long172172-sys_mmap2(unsigned long addr, unsigned long len, unsigned long prot,173173- unsigned long flags, unsigned long fd, unsigned long pgoff)171171+SYSCALL_DEFINE6(mips_mmap2, unsigned long, addr, unsigned long, len,172172+ unsigned long, prot, unsigned long, flags, unsigned long, fd,173173+ unsigned long, pgoff)174174{175175 if (pgoff & (~PAGE_MASK >> 12))176176 return -EINVAL;···240240/*241241 * Compacrapability ...242242 */243243-asmlinkage int sys_uname(struct old_utsname __user * name)243243+SYSCALL_DEFINE1(uname, struct old_utsname __user *, name)244244{245245 if (name && !copy_to_user(name, utsname(), sizeof (*name)))246246 return 0;···250250/*251251 * Compacrapability ...252252 */253253-asmlinkage int sys_olduname(struct oldold_utsname __user * name)253253+SYSCALL_DEFINE1(olduname, struct oldold_utsname __user *, name)254254{255255 int error;256256···279279 return error;280280}281281282282-asmlinkage int sys_set_thread_area(unsigned long addr)282282+SYSCALL_DEFINE1(set_thread_area, unsigned long, addr)283283{284284 struct thread_info *ti = task_thread_info(current);285285···290290 return 0;291291}292292293293-asmlinkage int _sys_sysmips(int cmd, long arg1, int arg2, int arg3)293293+asmlinkage int _sys_sysmips(long cmd, long arg1, long arg2, long arg3)294294{295295 switch (cmd) {296296 case MIPS_ATOMIC_SET:···325325 *326326 * This is really horribly ugly.327327 */328328-asmlinkage int sys_ipc(unsigned int call, int first, int second,329329- unsigned long third, void __user *ptr, long fifth)328328+SYSCALL_DEFINE6(ipc, unsigned int, call, int, first, int, second,329329+ unsigned long, third, void __user *, ptr, long, fifth)330330{331331 int version, ret;332332···411411/*412412 * No implemented yet ...413413 */414414-asmlinkage int sys_cachectl(char *addr, int nbytes, int op)414414+SYSCALL_DEFINE3(cachectl, char *, addr, int, nbytes, int, op)415415{416416 return -ENOSYS;417417}
+3-2
arch/mips/mm/cache.c
···1313#include <linux/linkage.h>1414#include <linux/module.h>1515#include <linux/sched.h>1616+#include <linux/syscalls.h>1617#include <linux/mm.h>17181819#include <asm/cacheflush.h>···5958 * We could optimize the case where the cache argument is not BCACHE but6059 * that seems very atypical use ...6160 */6262-asmlinkage int sys_cacheflush(unsigned long addr,6363- unsigned long bytes, unsigned int cache)6161+SYSCALL_DEFINE3(cacheflush, unsigned long, addr, unsigned long, bytes,6262+ unsigned int, cache)6463{6564 if (bytes == 0)6665 return 0;
···367367static int emulate_fp_pair(unsigned char __user *addr, unsigned int reg,368368 unsigned int flags)369369{370370- char *ptr = (char *) ¤t->thread.TS_FPR(reg);371371- int i, ret;370370+ char *ptr0 = (char *) ¤t->thread.TS_FPR(reg);371371+ char *ptr1 = (char *) ¤t->thread.TS_FPR(reg+1);372372+ int i, ret, sw = 0;372373373374 if (!(flags & F))374375 return 0;375376 if (reg & 1)376377 return 0; /* invalid form: FRS/FRT must be even */377377- if (!(flags & SW)) {378378- /* not byte-swapped - easy */379379- if (!(flags & ST))380380- ret = __copy_from_user(ptr, addr, 16);381381- else382382- ret = __copy_to_user(addr, ptr, 16);383383- } else {384384- /* each FPR value is byte-swapped separately */385385- ret = 0;386386- for (i = 0; i < 16; ++i) {387387- if (!(flags & ST))388388- ret |= __get_user(ptr[i^7], addr + i);389389- else390390- ret |= __put_user(ptr[i^7], addr + i);378378+ if (flags & SW)379379+ sw = 7;380380+ ret = 0;381381+ for (i = 0; i < 8; ++i) {382382+ if (!(flags & ST)) {383383+ ret |= __get_user(ptr0[i^sw], addr + i);384384+ ret |= __get_user(ptr1[i^sw], addr + i + 8);385385+ } else {386386+ ret |= __put_user(ptr0[i^sw], addr + i);387387+ ret |= __put_user(ptr1[i^sw], addr + i + 8);391388 }392389 }393390 if (ret)
+31-7
arch/powerpc/lib/copyuser_64.S
···626272: std r8,8(r3)6363 beq+ 3f6464 addi r3,r3,166565-23: ld r9,8(r4)6665.Ldo_tail:6766 bf cr7*4+1,1f6868- rotldi r9,r9,326767+23: lwz r9,8(r4)6868+ addi r4,r4,4696973: stw r9,0(r3)7070 addi r3,r3,471711: bf cr7*4+2,2f7272- rotldi r9,r9,167272+44: lhz r9,8(r4)7373+ addi r4,r4,2737474: sth r9,0(r3)7475 addi r3,r3,275762: bf cr7*4+3,3f7676- rotldi r9,r9,87777+45: lbz r9,8(r4)777875: stb r9,0(r3)78793: li r3,07980 blr···1421416: cmpwi cr1,r5,8143142 addi r3,r3,32144143 sld r9,r9,r10145145- ble cr1,.Ldo_tail144144+ ble cr1,7f14614534: ld r0,8(r4)147146 srd r7,r0,r11148147 or r9,r7,r9149149- b .Ldo_tail148148+7:149149+ bf cr7*4+1,1f150150+ rotldi r9,r9,32151151+94: stw r9,0(r3)152152+ addi r3,r3,4153153+1: bf cr7*4+2,2f154154+ rotldi r9,r9,16155155+95: sth r9,0(r3)156156+ addi r3,r3,2157157+2: bf cr7*4+3,3f158158+ rotldi r9,r9,8159159+96: stb r9,0(r3)160160+3: li r3,0161161+ blr150162151163.Ldst_unaligned:152164 PPC_MTOCRF 0x01,r6 /* put #bytes to 8B bdry into cr7 */···232218121:233219132:234220 addi r3,r3,8235235-123:236221134:237222135:238223138:···239226140:240227141:241228142:229229+123:230230+144:231231+145:242232243233/*244234 * here we have had a fault on a load and r3 points to the first···325309187:326310188:327311189: 312312+194:313313+195:314314+196:3283151:329316 ld r6,-24(r1)330317 ld r5,-8(r1)···348329 .llong 72b,172b349330 .llong 23b,123b350331 .llong 73b,173b332332+ .llong 44b,144b351333 .llong 74b,174b334334+ .llong 45b,145b352335 .llong 75b,175b353336 .llong 24b,124b354337 .llong 25b,125b···368347 .llong 79b,179b369348 .llong 80b,180b370349 .llong 34b,134b350350+ .llong 94b,194b351351+ .llong 95b,195b352352+ .llong 96b,196b371353 .llong 35b,135b372354 .llong 81b,181b373355 .llong 36b,136b
···204204{205205 u32 ma, pcila, pciha;206206207207+ /* Hack warning ! The "old" PCI 2.x cell only let us configure the low208208+ * 32-bit of incoming PLB addresses. The top 4 bits of the 36-bit209209+ * address are actually hard wired to a value that appears to depend210210+ * on the specific SoC. For example, it's 0 on 440EP and 1 on 440EPx.211211+ *212212+ * The trick here is we just crop those top bits and ignore them when213213+ * programming the chip. That means the device-tree has to be right214214+ * for the specific part used (we don't print a warning if it's wrong215215+ * but on the other hand, you'll crash quickly enough), but at least216216+ * this code should work whatever the hard coded value is217217+ */218218+ plb_addr &= 0xffffffffull;219219+220220+ /* Note: Due to the above hack, the test below doesn't actually test221221+ * if you address is above 4G, but it tests that address and222222+ * (address + size) are both contained in the same 4G223223+ */207224 if ((plb_addr + size) > 0xffffffffull || !is_power_of_2(size) ||208225 size < 0x1000 || (plb_addr & (size - 1)) != 0) {209226 printk(KERN_WARNING "%s: Resource out of range\n",
···1818#include <asm/freq.h>1919#include <asm/io.h>20202121-const static int pll1rate[]={1,2,3,4,6,8};2222-const static int pfc_divisors[]={1,2,3,4,6,8,12};2121+static const int pll1rate[]={1,2,3,4,6,8};2222+static const int pfc_divisors[]={1,2,3,4,6,8,12};2323#define ifc_divisors pfc_divisors24242525#if (CONFIG_SH_CLK_MD == 0)
+5
arch/sparc/include/asm/compat.h
···240240 unsigned int __unused2;241241};242242243243+static inline int is_compat_task(void)244244+{245245+ return test_thread_flag(TIF_32BIT);246246+}247247+243248#endif /* _ASM_SPARC64_COMPAT_H */
···116116/*117117 * gzip declarations118118 */119119-120120-#define OF(args) args121119#define STATIC static122120123121#undef memset124122#undef memcpy125123#define memzero(s, n) memset((s), 0, (n))126124127127-typedef unsigned char uch;128128-typedef unsigned short ush;129129-typedef unsigned long ulg;130125131131-/*132132- * Window size must be at least 32k, and a power of two.133133- * We don't actually have a window just a huge output buffer,134134- * so we report a 2G window size, as that should always be135135- * larger than our output buffer:136136- */137137-#define WSIZE 0x80000000138138-139139-/* Input buffer: */140140-static unsigned char *inbuf;141141-142142-/* Sliding window buffer (and final output buffer): */143143-static unsigned char *window;144144-145145-/* Valid bytes in inbuf: */146146-static unsigned insize;147147-148148-/* Index of next byte to be processed in inbuf: */149149-static unsigned inptr;150150-151151-/* Bytes in output buffer: */152152-static unsigned outcnt;153153-154154-/* gzip flag byte */155155-#define ASCII_FLAG 0x01 /* bit 0 set: file probably ASCII text */156156-#define CONTINUATION 0x02 /* bit 1 set: continuation of multi-part gz file */157157-#define EXTRA_FIELD 0x04 /* bit 2 set: extra field present */158158-#define ORIG_NAM 0x08 /* bit 3 set: original file name present */159159-#define COMMENT 0x10 /* bit 4 set: file comment present */160160-#define ENCRYPTED 0x20 /* bit 5 set: file is encrypted */161161-#define RESERVED 0xC0 /* bit 6, 7: reserved */162162-163163-#define get_byte() (inptr < insize ? inbuf[inptr++] : fill_inbuf())164164-165165-/* Diagnostic functions */166166-#ifdef DEBUG167167-# define Assert(cond, msg) do { if (!(cond)) error(msg); } while (0)168168-# define Trace(x) do { fprintf x; } while (0)169169-# define Tracev(x) do { if (verbose) fprintf x ; } while (0)170170-# define Tracevv(x) do { if (verbose > 1) fprintf x ; } while (0)171171-# define Tracec(c, x) do { if (verbose && (c)) fprintf x ; } while (0)172172-# define Tracecv(c, x) do { if (verbose > 1 && (c)) fprintf x ; } while (0)173173-#else174174-# define Assert(cond, msg)175175-# define Trace(x)176176-# define Tracev(x)177177-# define Tracevv(x)178178-# define Tracec(c, x)179179-# define Tracecv(c, x)180180-#endif181181-182182-static int fill_inbuf(void);183183-static void flush_window(void);184126static void error(char *m);185127186128/*···131189static struct boot_params *real_mode; /* Pointer to real-mode data */132190static int quiet;133191134134-extern unsigned char input_data[];135135-extern int input_len;136136-137137-static long bytes_out;138138-139192static void *memset(void *s, int c, unsigned n);140140-static void *memcpy(void *dest, const void *src, unsigned n);193193+void *memcpy(void *dest, const void *src, unsigned n);141194142195static void __putstr(int, const char *);143196#define putstr(__x) __putstr(0, __x)···150213static int vidport;151214static int lines, cols;152215153153-#include "../../../../lib/inflate.c"216216+#ifdef CONFIG_KERNEL_GZIP217217+#include "../../../../lib/decompress_inflate.c"218218+#endif219219+220220+#ifdef CONFIG_KERNEL_BZIP2221221+#include "../../../../lib/decompress_bunzip2.c"222222+#endif223223+224224+#ifdef CONFIG_KERNEL_LZMA225225+#include "../../../../lib/decompress_unlzma.c"226226+#endif154227155228static void scroll(void)156229{···229282 return s;230283}231284232232-static void *memcpy(void *dest, const void *src, unsigned n)285285+void *memcpy(void *dest, const void *src, unsigned n)233286{234287 int i;235288 const char *s = src;···240293 return dest;241294}242295243243-/* ===========================================================================244244- * Fill the input buffer. This is called only when the buffer is empty245245- * and at least one byte is really needed.246246- */247247-static int fill_inbuf(void)248248-{249249- error("ran out of input data");250250- return 0;251251-}252252-253253-/* ===========================================================================254254- * Write the output window window[0..outcnt-1] and update crc and bytes_out.255255- * (Used for the decompressed data only.)256256- */257257-static void flush_window(void)258258-{259259- /* With my window equal to my output buffer260260- * I only need to compute the crc here.261261- */262262- unsigned long c = crc; /* temporary variable */263263- unsigned n;264264- unsigned char *in, ch;265265-266266- in = window;267267- for (n = 0; n < outcnt; n++) {268268- ch = *in++;269269- c = crc_32_tab[((int)c ^ ch) & 0xff] ^ (c >> 8);270270- }271271- crc = c;272272- bytes_out += (unsigned long)outcnt;273273- outcnt = 0;274274-}275296276297static void error(char *x)277298{···322407 lines = real_mode->screen_info.orig_video_lines;323408 cols = real_mode->screen_info.orig_video_cols;324409325325- window = output; /* Output buffer (Normally at 1M) */326410 free_mem_ptr = heap; /* Heap */327411 free_mem_end_ptr = heap + BOOT_HEAP_SIZE;328328- inbuf = input_data; /* Input buffer */329329- insize = input_len;330330- inptr = 0;331412332413#ifdef CONFIG_X86_64333414 if ((unsigned long)output & (__KERNEL_ALIGN - 1))···341430#endif342431#endif343432344344- makecrc();345433 if (!quiet)346434 putstr("\nDecompressing Linux... ");347347- gunzip();435435+ decompress(input_data, input_len, NULL, NULL, output, NULL, error);348436 parse_elf(output);349437 if (!quiet)350438 putstr("done.\nBooting the kernel.\n");
···11+/*22+ * fixmap.h: compile-time virtual memory allocation33+ *44+ * This file is subject to the terms and conditions of the GNU General Public55+ * License. See the file "COPYING" in the main directory of this archive66+ * for more details.77+ *88+ * Copyright (C) 1998 Ingo Molnar99+ *1010+ * Support of BIGMEM added by Gerhard Wichert, Siemens AG, July 19991111+ * x86_32 and x86_64 integration by Gustavo F. Padovan, February 20091212+ */1313+114#ifndef _ASM_X86_FIXMAP_H215#define _ASM_X86_FIXMAP_H3161717+#ifndef __ASSEMBLY__1818+#include <linux/kernel.h>1919+#include <asm/acpi.h>2020+#include <asm/apicdef.h>2121+#include <asm/page.h>422#ifdef CONFIG_X86_3255-# include "fixmap_32.h"2323+#include <linux/threads.h>2424+#include <asm/kmap_types.h>625#else77-# include "fixmap_64.h"2626+#include <asm/vsyscall.h>2727+#ifdef CONFIG_EFI2828+#include <asm/efi.h>829#endif3030+#endif3131+3232+/*3333+ * We can't declare FIXADDR_TOP as variable for x86_64 because vsyscall3434+ * uses fixmaps that relies on FIXADDR_TOP for proper address calculation.3535+ * Because of this, FIXADDR_TOP x86 integration was left as later work.3636+ */3737+#ifdef CONFIG_X86_323838+/* used by vmalloc.c, vsyscall.lds.S.3939+ *4040+ * Leave one empty page between vmalloc'ed areas and4141+ * the start of the fixmap.4242+ */4343+extern unsigned long __FIXADDR_TOP;4444+#define FIXADDR_TOP ((unsigned long)__FIXADDR_TOP)4545+4646+#define FIXADDR_USER_START __fix_to_virt(FIX_VDSO)4747+#define FIXADDR_USER_END __fix_to_virt(FIX_VDSO - 1)4848+#else4949+#define FIXADDR_TOP (VSYSCALL_END-PAGE_SIZE)5050+5151+/* Only covers 32bit vsyscalls currently. Need another set for 64bit. */5252+#define FIXADDR_USER_START ((unsigned long)VSYSCALL32_VSYSCALL)5353+#define FIXADDR_USER_END (FIXADDR_USER_START + PAGE_SIZE)5454+#endif5555+5656+5757+/*5858+ * Here we define all the compile-time 'special' virtual5959+ * addresses. The point is to have a constant address at6060+ * compile time, but to set the physical address only6161+ * in the boot process.6262+ * for x86_32: We allocate these special addresses6363+ * from the end of virtual memory (0xfffff000) backwards.6464+ * Also this lets us do fail-safe vmalloc(), we6565+ * can guarantee that these special addresses and6666+ * vmalloc()-ed addresses never overlap.6767+ *6868+ * These 'compile-time allocated' memory buffers are6969+ * fixed-size 4k pages (or larger if used with an increment7070+ * higher than 1). Use set_fixmap(idx,phys) to associate7171+ * physical memory with fixmap indices.7272+ *7373+ * TLB entries of such buffers will not be flushed across7474+ * task switches.7575+ */7676+enum fixed_addresses {7777+#ifdef CONFIG_X86_327878+ FIX_HOLE,7979+ FIX_VDSO,8080+#else8181+ VSYSCALL_LAST_PAGE,8282+ VSYSCALL_FIRST_PAGE = VSYSCALL_LAST_PAGE8383+ + ((VSYSCALL_END-VSYSCALL_START) >> PAGE_SHIFT) - 1,8484+ VSYSCALL_HPET,8585+#endif8686+ FIX_DBGP_BASE,8787+ FIX_EARLYCON_MEM_BASE,8888+#ifdef CONFIG_X86_LOCAL_APIC8989+ FIX_APIC_BASE, /* local (CPU) APIC) -- required for SMP or not */9090+#endif9191+#ifdef CONFIG_X86_IO_APIC9292+ FIX_IO_APIC_BASE_0,9393+ FIX_IO_APIC_BASE_END = FIX_IO_APIC_BASE_0 + MAX_IO_APICS - 1,9494+#endif9595+#ifdef CONFIG_X86_649696+#ifdef CONFIG_EFI9797+ FIX_EFI_IO_MAP_LAST_PAGE,9898+ FIX_EFI_IO_MAP_FIRST_PAGE = FIX_EFI_IO_MAP_LAST_PAGE9999+ + MAX_EFI_IO_PAGES - 1,100100+#endif101101+#endif102102+#ifdef CONFIG_X86_VISWS_APIC103103+ FIX_CO_CPU, /* Cobalt timer */104104+ FIX_CO_APIC, /* Cobalt APIC Redirection Table */105105+ FIX_LI_PCIA, /* Lithium PCI Bridge A */106106+ FIX_LI_PCIB, /* Lithium PCI Bridge B */107107+#endif108108+#ifdef CONFIG_X86_F00F_BUG109109+ FIX_F00F_IDT, /* Virtual mapping for IDT */110110+#endif111111+#ifdef CONFIG_X86_CYCLONE_TIMER112112+ FIX_CYCLONE_TIMER, /*cyclone timer register*/113113+#endif114114+#ifdef CONFIG_X86_32115115+ FIX_KMAP_BEGIN, /* reserved pte's for temporary kernel mappings */116116+ FIX_KMAP_END = FIX_KMAP_BEGIN+(KM_TYPE_NR*NR_CPUS)-1,117117+#ifdef CONFIG_PCI_MMCONFIG118118+ FIX_PCIE_MCFG,119119+#endif120120+#endif121121+#ifdef CONFIG_PARAVIRT122122+ FIX_PARAVIRT_BOOTMAP,123123+#endif124124+ __end_of_permanent_fixed_addresses,125125+#ifdef CONFIG_PROVIDE_OHCI1394_DMA_INIT126126+ FIX_OHCI1394_BASE,127127+#endif128128+ /*129129+ * 256 temporary boot-time mappings, used by early_ioremap(),130130+ * before ioremap() is functional.131131+ *132132+ * We round it up to the next 256 pages boundary so that we133133+ * can have a single pgd entry and a single pte table:134134+ */135135+#define NR_FIX_BTMAPS 64136136+#define FIX_BTMAPS_SLOTS 4137137+ FIX_BTMAP_END = __end_of_permanent_fixed_addresses + 256 -138138+ (__end_of_permanent_fixed_addresses & 255),139139+ FIX_BTMAP_BEGIN = FIX_BTMAP_END + NR_FIX_BTMAPS*FIX_BTMAPS_SLOTS - 1,140140+#ifdef CONFIG_X86_32141141+ FIX_WP_TEST,142142+#endif143143+ __end_of_fixed_addresses144144+};145145+146146+147147+extern void reserve_top_address(unsigned long reserve);148148+149149+#define FIXADDR_SIZE (__end_of_permanent_fixed_addresses << PAGE_SHIFT)150150+#define FIXADDR_BOOT_SIZE (__end_of_fixed_addresses << PAGE_SHIFT)151151+#define FIXADDR_START (FIXADDR_TOP - FIXADDR_SIZE)152152+#define FIXADDR_BOOT_START (FIXADDR_TOP - FIXADDR_BOOT_SIZE)915310154extern int fixmaps_set;11155···21369 BUG_ON(vaddr >= FIXADDR_TOP || vaddr < FIXADDR_START);21470 return __virt_to_fix(vaddr);21571}7272+#endif /* !__ASSEMBLY__ */21673#endif /* _ASM_X86_FIXMAP_H */
-115
arch/x86/include/asm/fixmap_32.h
···11-/*22- * fixmap.h: compile-time virtual memory allocation33- *44- * This file is subject to the terms and conditions of the GNU General Public55- * License. See the file "COPYING" in the main directory of this archive66- * for more details.77- *88- * Copyright (C) 1998 Ingo Molnar99- *1010- * Support of BIGMEM added by Gerhard Wichert, Siemens AG, July 19991111- */1212-1313-#ifndef _ASM_X86_FIXMAP_32_H1414-#define _ASM_X86_FIXMAP_32_H1515-1616-1717-/* used by vmalloc.c, vsyscall.lds.S.1818- *1919- * Leave one empty page between vmalloc'ed areas and2020- * the start of the fixmap.2121- */2222-extern unsigned long __FIXADDR_TOP;2323-#define FIXADDR_USER_START __fix_to_virt(FIX_VDSO)2424-#define FIXADDR_USER_END __fix_to_virt(FIX_VDSO - 1)2525-2626-#ifndef __ASSEMBLY__2727-#include <linux/kernel.h>2828-#include <asm/acpi.h>2929-#include <asm/apicdef.h>3030-#include <asm/page.h>3131-#include <linux/threads.h>3232-#include <asm/kmap_types.h>3333-3434-/*3535- * Here we define all the compile-time 'special' virtual3636- * addresses. The point is to have a constant address at3737- * compile time, but to set the physical address only3838- * in the boot process. We allocate these special addresses3939- * from the end of virtual memory (0xfffff000) backwards.4040- * Also this lets us do fail-safe vmalloc(), we4141- * can guarantee that these special addresses and4242- * vmalloc()-ed addresses never overlap.4343- *4444- * these 'compile-time allocated' memory buffers are4545- * fixed-size 4k pages. (or larger if used with an increment4646- * highger than 1) use fixmap_set(idx,phys) to associate4747- * physical memory with fixmap indices.4848- *4949- * TLB entries of such buffers will not be flushed across5050- * task switches.5151- */5252-enum fixed_addresses {5353- FIX_HOLE,5454- FIX_VDSO,5555- FIX_DBGP_BASE,5656- FIX_EARLYCON_MEM_BASE,5757-#ifdef CONFIG_X86_LOCAL_APIC5858- FIX_APIC_BASE, /* local (CPU) APIC) -- required for SMP or not */5959-#endif6060-#ifdef CONFIG_X86_IO_APIC6161- FIX_IO_APIC_BASE_0,6262- FIX_IO_APIC_BASE_END = FIX_IO_APIC_BASE_0 + MAX_IO_APICS-1,6363-#endif6464-#ifdef CONFIG_X86_VISWS_APIC6565- FIX_CO_CPU, /* Cobalt timer */6666- FIX_CO_APIC, /* Cobalt APIC Redirection Table */6767- FIX_LI_PCIA, /* Lithium PCI Bridge A */6868- FIX_LI_PCIB, /* Lithium PCI Bridge B */6969-#endif7070-#ifdef CONFIG_X86_F00F_BUG7171- FIX_F00F_IDT, /* Virtual mapping for IDT */7272-#endif7373-#ifdef CONFIG_X86_CYCLONE_TIMER7474- FIX_CYCLONE_TIMER, /*cyclone timer register*/7575-#endif7676- FIX_KMAP_BEGIN, /* reserved pte's for temporary kernel mappings */7777- FIX_KMAP_END = FIX_KMAP_BEGIN+(KM_TYPE_NR*NR_CPUS)-1,7878-#ifdef CONFIG_PCI_MMCONFIG7979- FIX_PCIE_MCFG,8080-#endif8181-#ifdef CONFIG_PARAVIRT8282- FIX_PARAVIRT_BOOTMAP,8383-#endif8484- __end_of_permanent_fixed_addresses,8585- /*8686- * 256 temporary boot-time mappings, used by early_ioremap(),8787- * before ioremap() is functional.8888- *8989- * We round it up to the next 256 pages boundary so that we9090- * can have a single pgd entry and a single pte table:9191- */9292-#define NR_FIX_BTMAPS 649393-#define FIX_BTMAPS_SLOTS 49494- FIX_BTMAP_END = __end_of_permanent_fixed_addresses + 256 -9595- (__end_of_permanent_fixed_addresses & 255),9696- FIX_BTMAP_BEGIN = FIX_BTMAP_END + NR_FIX_BTMAPS*FIX_BTMAPS_SLOTS - 1,9797- FIX_WP_TEST,9898-#ifdef CONFIG_PROVIDE_OHCI1394_DMA_INIT9999- FIX_OHCI1394_BASE,100100-#endif101101- __end_of_fixed_addresses102102-};103103-104104-extern void reserve_top_address(unsigned long reserve);105105-106106-107107-#define FIXADDR_TOP ((unsigned long)__FIXADDR_TOP)108108-109109-#define __FIXADDR_SIZE (__end_of_permanent_fixed_addresses << PAGE_SHIFT)110110-#define __FIXADDR_BOOT_SIZE (__end_of_fixed_addresses << PAGE_SHIFT)111111-#define FIXADDR_START (FIXADDR_TOP - __FIXADDR_SIZE)112112-#define FIXADDR_BOOT_START (FIXADDR_TOP - __FIXADDR_BOOT_SIZE)113113-114114-#endif /* !__ASSEMBLY__ */115115-#endif /* _ASM_X86_FIXMAP_32_H */
-79
arch/x86/include/asm/fixmap_64.h
···11-/*22- * fixmap.h: compile-time virtual memory allocation33- *44- * This file is subject to the terms and conditions of the GNU General Public55- * License. See the file "COPYING" in the main directory of this archive66- * for more details.77- *88- * Copyright (C) 1998 Ingo Molnar99- */1010-1111-#ifndef _ASM_X86_FIXMAP_64_H1212-#define _ASM_X86_FIXMAP_64_H1313-1414-#include <linux/kernel.h>1515-#include <asm/acpi.h>1616-#include <asm/apicdef.h>1717-#include <asm/page.h>1818-#include <asm/vsyscall.h>1919-#include <asm/efi.h>2020-2121-/*2222- * Here we define all the compile-time 'special' virtual2323- * addresses. The point is to have a constant address at2424- * compile time, but to set the physical address only2525- * in the boot process.2626- *2727- * These 'compile-time allocated' memory buffers are2828- * fixed-size 4k pages (or larger if used with an increment2929- * higher than 1). Use set_fixmap(idx,phys) to associate3030- * physical memory with fixmap indices.3131- *3232- * TLB entries of such buffers will not be flushed across3333- * task switches.3434- */3535-3636-enum fixed_addresses {3737- VSYSCALL_LAST_PAGE,3838- VSYSCALL_FIRST_PAGE = VSYSCALL_LAST_PAGE3939- + ((VSYSCALL_END-VSYSCALL_START) >> PAGE_SHIFT) - 1,4040- VSYSCALL_HPET,4141- FIX_DBGP_BASE,4242- FIX_EARLYCON_MEM_BASE,4343- FIX_APIC_BASE, /* local (CPU) APIC) -- required for SMP or not */4444- FIX_IO_APIC_BASE_0,4545- FIX_IO_APIC_BASE_END = FIX_IO_APIC_BASE_0 + MAX_IO_APICS - 1,4646- FIX_EFI_IO_MAP_LAST_PAGE,4747- FIX_EFI_IO_MAP_FIRST_PAGE = FIX_EFI_IO_MAP_LAST_PAGE4848- + MAX_EFI_IO_PAGES - 1,4949-#ifdef CONFIG_PARAVIRT5050- FIX_PARAVIRT_BOOTMAP,5151-#endif5252- __end_of_permanent_fixed_addresses,5353-#ifdef CONFIG_PROVIDE_OHCI1394_DMA_INIT5454- FIX_OHCI1394_BASE,5555-#endif5656- /*5757- * 256 temporary boot-time mappings, used by early_ioremap(),5858- * before ioremap() is functional.5959- *6060- * We round it up to the next 256 pages boundary so that we6161- * can have a single pgd entry and a single pte table:6262- */6363-#define NR_FIX_BTMAPS 646464-#define FIX_BTMAPS_SLOTS 46565- FIX_BTMAP_END = __end_of_permanent_fixed_addresses + 256 -6666- (__end_of_permanent_fixed_addresses & 255),6767- FIX_BTMAP_BEGIN = FIX_BTMAP_END + NR_FIX_BTMAPS*FIX_BTMAPS_SLOTS - 1,6868- __end_of_fixed_addresses6969-};7070-7171-#define FIXADDR_TOP (VSYSCALL_END-PAGE_SIZE)7272-#define FIXADDR_SIZE (__end_of_fixed_addresses << PAGE_SHIFT)7373-#define FIXADDR_START (FIXADDR_TOP - FIXADDR_SIZE)7474-7575-/* Only covers 32bit vsyscalls currently. Need another set for 64bit. */7676-#define FIXADDR_USER_START ((unsigned long)VSYSCALL32_VSYSCALL)7777-#define FIXADDR_USER_END (FIXADDR_USER_START + PAGE_SIZE)7878-7979-#endif /* _ASM_X86_FIXMAP_64_H */
+1-4
arch/x86/include/asm/iomap.h
···2424#include <asm/tlbflush.h>25252626int2727-reserve_io_memtype_wc(u64 base, unsigned long size, pgprot_t *prot);2828-2929-void3030-free_io_memtype(u64 base, unsigned long size);2727+is_io_mapping_possible(resource_size_t base, unsigned long size);31283229void *3330iomap_atomic_prot_pfn(unsigned long pfn, enum km_type type, pgprot_t prot);
···248248#define IO_BITMAP_LONGS (IO_BITMAP_BYTES/sizeof(long))249249#define IO_BITMAP_OFFSET offsetof(struct tss_struct, io_bitmap)250250#define INVALID_IO_BITMAP_OFFSET 0x8000251251-#define INVALID_IO_BITMAP_OFFSET_LAZY 0x9000252251253252struct tss_struct {254253 /*···262263 * be within the limit.263264 */264265 unsigned long io_bitmap[IO_BITMAP_LONGS + 1];265265- /*266266- * Cache the current maximum and the last task that used the bitmap:267267- */268268- unsigned long io_bitmap_max;269269- struct thread_struct *io_bitmap_owner;270266271267 /*272268 * .. and then another 0x100 bytes for the emergency kernel stack:
···2020struct task_struct; /* one of the stranger aspects of C forward declarations */2121struct task_struct *__switch_to(struct task_struct *prev,2222 struct task_struct *next);2323+struct tss_struct;2424+void __switch_to_xtra(struct task_struct *prev_p, struct task_struct *next_p,2525+ struct tss_struct *tss);23262427#ifdef CONFIG_X86_322528
+2-2
arch/x86/include/asm/uaccess_32.h
···157157}158158159159static __always_inline unsigned long __copy_from_user_nocache(void *to,160160- const void __user *from, unsigned long n, unsigned long total)160160+ const void __user *from, unsigned long n)161161{162162 might_fault();163163 if (__builtin_constant_p(n)) {···180180181181static __always_inline unsigned long182182__copy_from_user_inatomic_nocache(void *to, const void __user *from,183183- unsigned long n, unsigned long total)183183+ unsigned long n)184184{185185 return __copy_from_user_ll_nocache_nozero(to, from, n);186186}
+7-18
arch/x86/include/asm/uaccess_64.h
···188188extern long __copy_user_nocache(void *dst, const void __user *src,189189 unsigned size, int zerorest);190190191191-static inline int __copy_from_user_nocache(void *dst, const void __user *src,192192- unsigned size, unsigned long total)191191+static inline int192192+__copy_from_user_nocache(void *dst, const void __user *src, unsigned size)193193{194194 might_sleep();195195- /*196196- * In practice this limit means that large file write()s197197- * which get chunked to 4K copies get handled via198198- * non-temporal stores here. Smaller writes get handled199199- * via regular __copy_from_user():200200- */201201- if (likely(total >= PAGE_SIZE))202202- return __copy_user_nocache(dst, src, size, 1);203203- else204204- return __copy_from_user(dst, src, size);195195+ return __copy_user_nocache(dst, src, size, 1);205196}206197207207-static inline int __copy_from_user_inatomic_nocache(void *dst,208208- const void __user *src, unsigned size, unsigned total)198198+static inline int199199+__copy_from_user_inatomic_nocache(void *dst, const void __user *src,200200+ unsigned size)209201{210210- if (likely(total >= PAGE_SIZE))211211- return __copy_user_nocache(dst, src, size, 0);212212- else213213- return __copy_from_user_inatomic(dst, src, size);202202+ return __copy_user_nocache(dst, src, size, 0);214203}215204216205unsigned long
+2-18
arch/x86/kernel/cpu/proc.c
···77/*88 * Get CPU information for use by the procfs.99 */1010-#ifdef CONFIG_X86_321110static void show_cpuinfo_core(struct seq_file *m, struct cpuinfo_x86 *c,1211 unsigned int cpu)1312{1414-#ifdef CONFIG_X86_HT1313+#ifdef CONFIG_SMP1514 if (c->x86_max_cores * smp_num_siblings > 1) {1615 seq_printf(m, "physical id\t: %d\n", c->phys_proc_id);1716 seq_printf(m, "siblings\t: %d\n",···2324#endif2425}25262727+#ifdef CONFIG_X86_322628static void show_cpuinfo_misc(struct seq_file *m, struct cpuinfo_x86 *c)2729{2830 /*···5050 c->wp_works_ok ? "yes" : "no");5151}5252#else5353-static void show_cpuinfo_core(struct seq_file *m, struct cpuinfo_x86 *c,5454- unsigned int cpu)5555-{5656-#ifdef CONFIG_SMP5757- if (c->x86_max_cores * smp_num_siblings > 1) {5858- seq_printf(m, "physical id\t: %d\n", c->phys_proc_id);5959- seq_printf(m, "siblings\t: %d\n",6060- cpus_weight(per_cpu(cpu_core_map, cpu)));6161- seq_printf(m, "core id\t\t: %d\n", c->cpu_core_id);6262- seq_printf(m, "cpu cores\t: %d\n", c->booted_cores);6363- seq_printf(m, "apicid\t\t: %d\n", c->apicid);6464- seq_printf(m, "initial apicid\t: %d\n", c->initial_apicid);6565- }6666-#endif6767-}6868-6953static void show_cpuinfo_misc(struct seq_file *m, struct cpuinfo_x86 *c)7054{7155 seq_printf(m,
-11
arch/x86/kernel/ioport.c
···85858686 t->io_bitmap_max = bytes;87878888-#ifdef CONFIG_X86_328989- /*9090- * Sets the lazy trigger so that the next I/O operation will9191- * reload the correct bitmap.9292- * Reset the owner so that a process switch will not set9393- * tss->io_bitmap_base to IO_BITMAP_OFFSET.9494- */9595- tss->x86_tss.io_bitmap_base = INVALID_IO_BITMAP_OFFSET_LAZY;9696- tss->io_bitmap_owner = NULL;9797-#else9888 /* Update the TSS: */9989 memcpy(tss->io_bitmap, t->io_bitmap_ptr, bytes_updated);100100-#endif1019010291 put_cpu();10392
+190-1
arch/x86/kernel/process.c
···11#include <linux/errno.h>22#include <linux/kernel.h>33#include <linux/mm.h>44-#include <asm/idle.h>54#include <linux/smp.h>55+#include <linux/prctl.h>66#include <linux/slab.h>77#include <linux/sched.h>88#include <linux/module.h>···1111#include <linux/ftrace.h>1212#include <asm/system.h>1313#include <asm/apic.h>1414+#include <asm/idle.h>1515+#include <asm/uaccess.h>1616+#include <asm/i387.h>14171518unsigned long idle_halt;1619EXPORT_SYMBOL(idle_halt);···5754 __alignof__(union thread_xstate),5855 SLAB_PANIC, NULL);5956}5757+5858+/*5959+ * Free current thread data structures etc..6060+ */6161+void exit_thread(void)6262+{6363+ struct task_struct *me = current;6464+ struct thread_struct *t = &me->thread;6565+6666+ if (me->thread.io_bitmap_ptr) {6767+ struct tss_struct *tss = &per_cpu(init_tss, get_cpu());6868+6969+ kfree(t->io_bitmap_ptr);7070+ t->io_bitmap_ptr = NULL;7171+ clear_thread_flag(TIF_IO_BITMAP);7272+ /*7373+ * Careful, clear this in the TSS too:7474+ */7575+ memset(tss->io_bitmap, 0xff, t->io_bitmap_max);7676+ t->io_bitmap_max = 0;7777+ put_cpu();7878+ }7979+8080+ ds_exit_thread(current);8181+}8282+8383+void flush_thread(void)8484+{8585+ struct task_struct *tsk = current;8686+8787+#ifdef CONFIG_X86_648888+ if (test_tsk_thread_flag(tsk, TIF_ABI_PENDING)) {8989+ clear_tsk_thread_flag(tsk, TIF_ABI_PENDING);9090+ if (test_tsk_thread_flag(tsk, TIF_IA32)) {9191+ clear_tsk_thread_flag(tsk, TIF_IA32);9292+ } else {9393+ set_tsk_thread_flag(tsk, TIF_IA32);9494+ current_thread_info()->status |= TS_COMPAT;9595+ }9696+ }9797+#endif9898+9999+ clear_tsk_thread_flag(tsk, TIF_DEBUG);100100+101101+ tsk->thread.debugreg0 = 0;102102+ tsk->thread.debugreg1 = 0;103103+ tsk->thread.debugreg2 = 0;104104+ tsk->thread.debugreg3 = 0;105105+ tsk->thread.debugreg6 = 0;106106+ tsk->thread.debugreg7 = 0;107107+ memset(tsk->thread.tls_array, 0, sizeof(tsk->thread.tls_array));108108+ /*109109+ * Forget coprocessor state..110110+ */111111+ tsk->fpu_counter = 0;112112+ clear_fpu(tsk);113113+ clear_used_math();114114+}115115+116116+static void hard_disable_TSC(void)117117+{118118+ write_cr4(read_cr4() | X86_CR4_TSD);119119+}120120+121121+void disable_TSC(void)122122+{123123+ preempt_disable();124124+ if (!test_and_set_thread_flag(TIF_NOTSC))125125+ /*126126+ * Must flip the CPU state synchronously with127127+ * TIF_NOTSC in the current running context.128128+ */129129+ hard_disable_TSC();130130+ preempt_enable();131131+}132132+133133+static void hard_enable_TSC(void)134134+{135135+ write_cr4(read_cr4() & ~X86_CR4_TSD);136136+}137137+138138+static void enable_TSC(void)139139+{140140+ preempt_disable();141141+ if (test_and_clear_thread_flag(TIF_NOTSC))142142+ /*143143+ * Must flip the CPU state synchronously with144144+ * TIF_NOTSC in the current running context.145145+ */146146+ hard_enable_TSC();147147+ preempt_enable();148148+}149149+150150+int get_tsc_mode(unsigned long adr)151151+{152152+ unsigned int val;153153+154154+ if (test_thread_flag(TIF_NOTSC))155155+ val = PR_TSC_SIGSEGV;156156+ else157157+ val = PR_TSC_ENABLE;158158+159159+ return put_user(val, (unsigned int __user *)adr);160160+}161161+162162+int set_tsc_mode(unsigned int val)163163+{164164+ if (val == PR_TSC_SIGSEGV)165165+ disable_TSC();166166+ else if (val == PR_TSC_ENABLE)167167+ enable_TSC();168168+ else169169+ return -EINVAL;170170+171171+ return 0;172172+}173173+174174+void __switch_to_xtra(struct task_struct *prev_p, struct task_struct *next_p,175175+ struct tss_struct *tss)176176+{177177+ struct thread_struct *prev, *next;178178+179179+ prev = &prev_p->thread;180180+ next = &next_p->thread;181181+182182+ if (test_tsk_thread_flag(next_p, TIF_DS_AREA_MSR) ||183183+ test_tsk_thread_flag(prev_p, TIF_DS_AREA_MSR))184184+ ds_switch_to(prev_p, next_p);185185+ else if (next->debugctlmsr != prev->debugctlmsr)186186+ update_debugctlmsr(next->debugctlmsr);187187+188188+ if (test_tsk_thread_flag(next_p, TIF_DEBUG)) {189189+ set_debugreg(next->debugreg0, 0);190190+ set_debugreg(next->debugreg1, 1);191191+ set_debugreg(next->debugreg2, 2);192192+ set_debugreg(next->debugreg3, 3);193193+ /* no 4 and 5 */194194+ set_debugreg(next->debugreg6, 6);195195+ set_debugreg(next->debugreg7, 7);196196+ }197197+198198+ if (test_tsk_thread_flag(prev_p, TIF_NOTSC) ^199199+ test_tsk_thread_flag(next_p, TIF_NOTSC)) {200200+ /* prev and next are different */201201+ if (test_tsk_thread_flag(next_p, TIF_NOTSC))202202+ hard_disable_TSC();203203+ else204204+ hard_enable_TSC();205205+ }206206+207207+ if (test_tsk_thread_flag(next_p, TIF_IO_BITMAP)) {208208+ /*209209+ * Copy the relevant range of the IO bitmap.210210+ * Normally this is 128 bytes or less:211211+ */212212+ memcpy(tss->io_bitmap, next->io_bitmap_ptr,213213+ max(prev->io_bitmap_max, next->io_bitmap_max));214214+ } else if (test_tsk_thread_flag(prev_p, TIF_IO_BITMAP)) {215215+ /*216216+ * Clear any possible leftover bits:217217+ */218218+ memset(tss->io_bitmap, 0xff, prev->io_bitmap_max);219219+ }220220+}221221+222222+int sys_fork(struct pt_regs *regs)223223+{224224+ return do_fork(SIGCHLD, regs->sp, regs, 0, NULL, NULL);225225+}226226+227227+/*228228+ * This is trivial, and on the face of it looks like it229229+ * could equally well be done in user mode.230230+ *231231+ * Not so, for quite unobvious reasons - register pressure.232232+ * In user mode vfork() cannot have a stack frame, and if233233+ * done by calling the "clone()" system call directly, you234234+ * do not have enough call-clobbered registers to hold all235235+ * the information you need.236236+ */237237+int sys_vfork(struct pt_regs *regs)238238+{239239+ return do_fork(CLONE_VFORK | CLONE_VM | SIGCHLD, regs->sp, regs, 0,240240+ NULL, NULL);241241+}242242+6024361244/*62245 * Idle related variables and functions
-190
arch/x86/kernel/process_32.c
···230230}231231EXPORT_SYMBOL(kernel_thread);232232233233-/*234234- * Free current thread data structures etc..235235- */236236-void exit_thread(void)237237-{238238- /* The process may have allocated an io port bitmap... nuke it. */239239- if (unlikely(test_thread_flag(TIF_IO_BITMAP))) {240240- struct task_struct *tsk = current;241241- struct thread_struct *t = &tsk->thread;242242- int cpu = get_cpu();243243- struct tss_struct *tss = &per_cpu(init_tss, cpu);244244-245245- kfree(t->io_bitmap_ptr);246246- t->io_bitmap_ptr = NULL;247247- clear_thread_flag(TIF_IO_BITMAP);248248- /*249249- * Careful, clear this in the TSS too:250250- */251251- memset(tss->io_bitmap, 0xff, tss->io_bitmap_max);252252- t->io_bitmap_max = 0;253253- tss->io_bitmap_owner = NULL;254254- tss->io_bitmap_max = 0;255255- tss->x86_tss.io_bitmap_base = INVALID_IO_BITMAP_OFFSET;256256- put_cpu();257257- }258258-259259- ds_exit_thread(current);260260-}261261-262262-void flush_thread(void)263263-{264264- struct task_struct *tsk = current;265265-266266- tsk->thread.debugreg0 = 0;267267- tsk->thread.debugreg1 = 0;268268- tsk->thread.debugreg2 = 0;269269- tsk->thread.debugreg3 = 0;270270- tsk->thread.debugreg6 = 0;271271- tsk->thread.debugreg7 = 0;272272- memset(tsk->thread.tls_array, 0, sizeof(tsk->thread.tls_array));273273- clear_tsk_thread_flag(tsk, TIF_DEBUG);274274- /*275275- * Forget coprocessor state..276276- */277277- tsk->fpu_counter = 0;278278- clear_fpu(tsk);279279- clear_used_math();280280-}281281-282233void release_thread(struct task_struct *dead_task)283234{284235 BUG_ON(dead_task->mm);···317366}318367EXPORT_SYMBOL_GPL(start_thread);319368320320-static void hard_disable_TSC(void)321321-{322322- write_cr4(read_cr4() | X86_CR4_TSD);323323-}324324-325325-void disable_TSC(void)326326-{327327- preempt_disable();328328- if (!test_and_set_thread_flag(TIF_NOTSC))329329- /*330330- * Must flip the CPU state synchronously with331331- * TIF_NOTSC in the current running context.332332- */333333- hard_disable_TSC();334334- preempt_enable();335335-}336336-337337-static void hard_enable_TSC(void)338338-{339339- write_cr4(read_cr4() & ~X86_CR4_TSD);340340-}341341-342342-static void enable_TSC(void)343343-{344344- preempt_disable();345345- if (test_and_clear_thread_flag(TIF_NOTSC))346346- /*347347- * Must flip the CPU state synchronously with348348- * TIF_NOTSC in the current running context.349349- */350350- hard_enable_TSC();351351- preempt_enable();352352-}353353-354354-int get_tsc_mode(unsigned long adr)355355-{356356- unsigned int val;357357-358358- if (test_thread_flag(TIF_NOTSC))359359- val = PR_TSC_SIGSEGV;360360- else361361- val = PR_TSC_ENABLE;362362-363363- return put_user(val, (unsigned int __user *)adr);364364-}365365-366366-int set_tsc_mode(unsigned int val)367367-{368368- if (val == PR_TSC_SIGSEGV)369369- disable_TSC();370370- else if (val == PR_TSC_ENABLE)371371- enable_TSC();372372- else373373- return -EINVAL;374374-375375- return 0;376376-}377377-378378-static noinline void379379-__switch_to_xtra(struct task_struct *prev_p, struct task_struct *next_p,380380- struct tss_struct *tss)381381-{382382- struct thread_struct *prev, *next;383383-384384- prev = &prev_p->thread;385385- next = &next_p->thread;386386-387387- if (test_tsk_thread_flag(next_p, TIF_DS_AREA_MSR) ||388388- test_tsk_thread_flag(prev_p, TIF_DS_AREA_MSR))389389- ds_switch_to(prev_p, next_p);390390- else if (next->debugctlmsr != prev->debugctlmsr)391391- update_debugctlmsr(next->debugctlmsr);392392-393393- if (test_tsk_thread_flag(next_p, TIF_DEBUG)) {394394- set_debugreg(next->debugreg0, 0);395395- set_debugreg(next->debugreg1, 1);396396- set_debugreg(next->debugreg2, 2);397397- set_debugreg(next->debugreg3, 3);398398- /* no 4 and 5 */399399- set_debugreg(next->debugreg6, 6);400400- set_debugreg(next->debugreg7, 7);401401- }402402-403403- if (test_tsk_thread_flag(prev_p, TIF_NOTSC) ^404404- test_tsk_thread_flag(next_p, TIF_NOTSC)) {405405- /* prev and next are different */406406- if (test_tsk_thread_flag(next_p, TIF_NOTSC))407407- hard_disable_TSC();408408- else409409- hard_enable_TSC();410410- }411411-412412- if (!test_tsk_thread_flag(next_p, TIF_IO_BITMAP)) {413413- /*414414- * Disable the bitmap via an invalid offset. We still cache415415- * the previous bitmap owner and the IO bitmap contents:416416- */417417- tss->x86_tss.io_bitmap_base = INVALID_IO_BITMAP_OFFSET;418418- return;419419- }420420-421421- if (likely(next == tss->io_bitmap_owner)) {422422- /*423423- * Previous owner of the bitmap (hence the bitmap content)424424- * matches the next task, we dont have to do anything but425425- * to set a valid offset in the TSS:426426- */427427- tss->x86_tss.io_bitmap_base = IO_BITMAP_OFFSET;428428- return;429429- }430430- /*431431- * Lazy TSS's I/O bitmap copy. We set an invalid offset here432432- * and we let the task to get a GPF in case an I/O instruction433433- * is performed. The handler of the GPF will verify that the434434- * faulting task has a valid I/O bitmap and, it true, does the435435- * real copy and restart the instruction. This will save us436436- * redundant copies when the currently switched task does not437437- * perform any I/O during its timeslice.438438- */439439- tss->x86_tss.io_bitmap_base = INVALID_IO_BITMAP_OFFSET_LAZY;440440-}441369442370/*443371 * switch_to(x,yn) should switch tasks from x to y.···430600 return prev_p;431601}432602433433-int sys_fork(struct pt_regs *regs)434434-{435435- return do_fork(SIGCHLD, regs->sp, regs, 0, NULL, NULL);436436-}437437-438603int sys_clone(struct pt_regs *regs)439604{440605 unsigned long clone_flags;···443618 if (!newsp)444619 newsp = regs->sp;445620 return do_fork(clone_flags, newsp, regs, 0, parent_tidptr, child_tidptr);446446-}447447-448448-/*449449- * This is trivial, and on the face of it looks like it450450- * could equally well be done in user mode.451451- *452452- * Not so, for quite unobvious reasons - register pressure.453453- * In user mode vfork() cannot have a stack frame, and if454454- * done by calling the "clone()" system call directly, you455455- * do not have enough call-clobbered registers to hold all456456- * the information you need.457457- */458458-int sys_vfork(struct pt_regs *regs)459459-{460460- return do_fork(CLONE_VFORK | CLONE_VM | SIGCHLD, regs->sp, regs, 0, NULL, NULL);461621}462622463623/*
-188
arch/x86/kernel/process_64.c
···237237 show_trace(NULL, regs, (void *)(regs + 1), regs->bp);238238}239239240240-/*241241- * Free current thread data structures etc..242242- */243243-void exit_thread(void)244244-{245245- struct task_struct *me = current;246246- struct thread_struct *t = &me->thread;247247-248248- if (me->thread.io_bitmap_ptr) {249249- struct tss_struct *tss = &per_cpu(init_tss, get_cpu());250250-251251- kfree(t->io_bitmap_ptr);252252- t->io_bitmap_ptr = NULL;253253- clear_thread_flag(TIF_IO_BITMAP);254254- /*255255- * Careful, clear this in the TSS too:256256- */257257- memset(tss->io_bitmap, 0xff, t->io_bitmap_max);258258- t->io_bitmap_max = 0;259259- put_cpu();260260- }261261-262262- ds_exit_thread(current);263263-}264264-265265-void flush_thread(void)266266-{267267- struct task_struct *tsk = current;268268-269269- if (test_tsk_thread_flag(tsk, TIF_ABI_PENDING)) {270270- clear_tsk_thread_flag(tsk, TIF_ABI_PENDING);271271- if (test_tsk_thread_flag(tsk, TIF_IA32)) {272272- clear_tsk_thread_flag(tsk, TIF_IA32);273273- } else {274274- set_tsk_thread_flag(tsk, TIF_IA32);275275- current_thread_info()->status |= TS_COMPAT;276276- }277277- }278278- clear_tsk_thread_flag(tsk, TIF_DEBUG);279279-280280- tsk->thread.debugreg0 = 0;281281- tsk->thread.debugreg1 = 0;282282- tsk->thread.debugreg2 = 0;283283- tsk->thread.debugreg3 = 0;284284- tsk->thread.debugreg6 = 0;285285- tsk->thread.debugreg7 = 0;286286- memset(tsk->thread.tls_array, 0, sizeof(tsk->thread.tls_array));287287- /*288288- * Forget coprocessor state..289289- */290290- tsk->fpu_counter = 0;291291- clear_fpu(tsk);292292- clear_used_math();293293-}294294-295240void release_thread(struct task_struct *dead_task)296241{297242 if (dead_task->mm) {···369424 free_thread_xstate(current);370425}371426EXPORT_SYMBOL_GPL(start_thread);372372-373373-static void hard_disable_TSC(void)374374-{375375- write_cr4(read_cr4() | X86_CR4_TSD);376376-}377377-378378-void disable_TSC(void)379379-{380380- preempt_disable();381381- if (!test_and_set_thread_flag(TIF_NOTSC))382382- /*383383- * Must flip the CPU state synchronously with384384- * TIF_NOTSC in the current running context.385385- */386386- hard_disable_TSC();387387- preempt_enable();388388-}389389-390390-static void hard_enable_TSC(void)391391-{392392- write_cr4(read_cr4() & ~X86_CR4_TSD);393393-}394394-395395-static void enable_TSC(void)396396-{397397- preempt_disable();398398- if (test_and_clear_thread_flag(TIF_NOTSC))399399- /*400400- * Must flip the CPU state synchronously with401401- * TIF_NOTSC in the current running context.402402- */403403- hard_enable_TSC();404404- preempt_enable();405405-}406406-407407-int get_tsc_mode(unsigned long adr)408408-{409409- unsigned int val;410410-411411- if (test_thread_flag(TIF_NOTSC))412412- val = PR_TSC_SIGSEGV;413413- else414414- val = PR_TSC_ENABLE;415415-416416- return put_user(val, (unsigned int __user *)adr);417417-}418418-419419-int set_tsc_mode(unsigned int val)420420-{421421- if (val == PR_TSC_SIGSEGV)422422- disable_TSC();423423- else if (val == PR_TSC_ENABLE)424424- enable_TSC();425425- else426426- return -EINVAL;427427-428428- return 0;429429-}430430-431431-/*432432- * This special macro can be used to load a debugging register433433- */434434-#define loaddebug(thread, r) set_debugreg(thread->debugreg ## r, r)435435-436436-static inline void __switch_to_xtra(struct task_struct *prev_p,437437- struct task_struct *next_p,438438- struct tss_struct *tss)439439-{440440- struct thread_struct *prev, *next;441441-442442- prev = &prev_p->thread,443443- next = &next_p->thread;444444-445445- if (test_tsk_thread_flag(next_p, TIF_DS_AREA_MSR) ||446446- test_tsk_thread_flag(prev_p, TIF_DS_AREA_MSR))447447- ds_switch_to(prev_p, next_p);448448- else if (next->debugctlmsr != prev->debugctlmsr)449449- update_debugctlmsr(next->debugctlmsr);450450-451451- if (test_tsk_thread_flag(next_p, TIF_DEBUG)) {452452- loaddebug(next, 0);453453- loaddebug(next, 1);454454- loaddebug(next, 2);455455- loaddebug(next, 3);456456- /* no 4 and 5 */457457- loaddebug(next, 6);458458- loaddebug(next, 7);459459- }460460-461461- if (test_tsk_thread_flag(prev_p, TIF_NOTSC) ^462462- test_tsk_thread_flag(next_p, TIF_NOTSC)) {463463- /* prev and next are different */464464- if (test_tsk_thread_flag(next_p, TIF_NOTSC))465465- hard_disable_TSC();466466- else467467- hard_enable_TSC();468468- }469469-470470- if (test_tsk_thread_flag(next_p, TIF_IO_BITMAP)) {471471- /*472472- * Copy the relevant range of the IO bitmap.473473- * Normally this is 128 bytes or less:474474- */475475- memcpy(tss->io_bitmap, next->io_bitmap_ptr,476476- max(prev->io_bitmap_max, next->io_bitmap_max));477477- } else if (test_tsk_thread_flag(prev_p, TIF_IO_BITMAP)) {478478- /*479479- * Clear any possible leftover bits:480480- */481481- memset(tss->io_bitmap, 0xff, prev->io_bitmap_max);482482- }483483-}484427485428/*486429 * switch_to(x,y) should switch tasks from x to y.···527694 current->personality &= ~READ_IMPLIES_EXEC;528695}529696530530-asmlinkage long sys_fork(struct pt_regs *regs)531531-{532532- return do_fork(SIGCHLD, regs->sp, regs, 0, NULL, NULL);533533-}534534-535697asmlinkage long536698sys_clone(unsigned long clone_flags, unsigned long newsp,537699 void __user *parent_tid, void __user *child_tid, struct pt_regs *regs)···534706 if (!newsp)535707 newsp = regs->sp;536708 return do_fork(clone_flags, newsp, regs, 0, parent_tid, child_tid);537537-}538538-539539-/*540540- * This is trivial, and on the face of it looks like it541541- * could equally well be done in user mode.542542- *543543- * Not so, for quite unobvious reasons - register pressure.544544- * In user mode vfork() cannot have a stack frame, and if545545- * done by calling the "clone()" system call directly, you546546- * do not have enough call-clobbered registers to hold all547547- * the information you need.548548- */549549-asmlinkage long sys_vfork(struct pt_regs *regs)550550-{551551- return do_fork(CLONE_VFORK | CLONE_VM | SIGCHLD, regs->sp, regs, 0,552552- NULL, NULL);553709}554710555711unsigned long get_wchan(struct task_struct *p)
···187187/*188188 * Set up a signal frame.189189 */190190+191191+/*192192+ * Determine which stack to use..193193+ */194194+static unsigned long align_sigframe(unsigned long sp)195195+{196196+#ifdef CONFIG_X86_32197197+ /*198198+ * Align the stack pointer according to the i386 ABI,199199+ * i.e. so that on function entry ((sp + 4) & 15) == 0.200200+ */201201+ sp = ((sp + 4) & -16ul) - 4;202202+#else /* !CONFIG_X86_32 */203203+ sp = round_down(sp, 16) - 8;204204+#endif205205+ return sp;206206+}207207+208208+static inline void __user *209209+get_sigframe(struct k_sigaction *ka, struct pt_regs *regs, size_t frame_size,210210+ void __user **fpstate)211211+{212212+ /* Default to using normal stack */213213+ unsigned long sp = regs->sp;214214+215215+#ifdef CONFIG_X86_64216216+ /* redzone */217217+ sp -= 128;218218+#endif /* CONFIG_X86_64 */219219+220220+ /*221221+ * If we are on the alternate signal stack and would overflow it, don't.222222+ * Return an always-bogus address instead so we will die with SIGSEGV.223223+ */224224+ if (on_sig_stack(sp) && !likely(on_sig_stack(sp - frame_size)))225225+ return (void __user *) -1L;226226+227227+ /* This is the X/Open sanctioned signal stack switching. */228228+ if (ka->sa.sa_flags & SA_ONSTACK) {229229+ if (sas_ss_flags(sp) == 0)230230+ sp = current->sas_ss_sp + current->sas_ss_size;231231+ } else {232232+#ifdef CONFIG_X86_32233233+ /* This is the legacy signal stack switching. */234234+ if ((regs->ss & 0xffff) != __USER_DS &&235235+ !(ka->sa.sa_flags & SA_RESTORER) &&236236+ ka->sa.sa_restorer)237237+ sp = (unsigned long) ka->sa.sa_restorer;238238+#endif /* CONFIG_X86_32 */239239+ }240240+241241+ if (used_math()) {242242+ sp -= sig_xstate_size;243243+#ifdef CONFIG_X86_64244244+ sp = round_down(sp, 64);245245+#endif /* CONFIG_X86_64 */246246+ *fpstate = (void __user *)sp;247247+248248+ if (save_i387_xstate(*fpstate) < 0)249249+ return (void __user *)-1L;250250+ }251251+252252+ return (void __user *)align_sigframe(sp - frame_size);253253+}254254+190255#ifdef CONFIG_X86_32191256static const struct {192257 u16 poplmovl;···274209 0x80cd, /* int $0x80 */275210 0276211};277277-278278-/*279279- * Determine which stack to use..280280- */281281-static inline void __user *282282-get_sigframe(struct k_sigaction *ka, struct pt_regs *regs, size_t frame_size,283283- void **fpstate)284284-{285285- unsigned long sp;286286-287287- /* Default to using normal stack */288288- sp = regs->sp;289289-290290- /*291291- * If we are on the alternate signal stack and would overflow it, don't.292292- * Return an always-bogus address instead so we will die with SIGSEGV.293293- */294294- if (on_sig_stack(sp) && !likely(on_sig_stack(sp - frame_size)))295295- return (void __user *) -1L;296296-297297- /* This is the X/Open sanctioned signal stack switching. */298298- if (ka->sa.sa_flags & SA_ONSTACK) {299299- if (sas_ss_flags(sp) == 0)300300- sp = current->sas_ss_sp + current->sas_ss_size;301301- } else {302302- /* This is the legacy signal stack switching. */303303- if ((regs->ss & 0xffff) != __USER_DS &&304304- !(ka->sa.sa_flags & SA_RESTORER) &&305305- ka->sa.sa_restorer)306306- sp = (unsigned long) ka->sa.sa_restorer;307307- }308308-309309- if (used_math()) {310310- sp = sp - sig_xstate_size;311311- *fpstate = (struct _fpstate *) sp;312312- if (save_i387_xstate(*fpstate) < 0)313313- return (void __user *)-1L;314314- }315315-316316- sp -= frame_size;317317- /*318318- * Align the stack pointer according to the i386 ABI,319319- * i.e. so that on function entry ((sp + 4) & 15) == 0.320320- */321321- sp = ((sp + 4) & -16ul) - 4;322322-323323- return (void __user *) sp;324324-}325212326213static int327214__setup_frame(int sig, struct k_sigaction *ka, sigset_t *set,···405388 return 0;406389}407390#else /* !CONFIG_X86_32 */408408-/*409409- * Determine which stack to use..410410- */411411-static void __user *412412-get_stack(struct k_sigaction *ka, unsigned long sp, unsigned long size)413413-{414414- /* Default to using normal stack - redzone*/415415- sp -= 128;416416-417417- /* This is the X/Open sanctioned signal stack switching. */418418- if (ka->sa.sa_flags & SA_ONSTACK) {419419- if (sas_ss_flags(sp) == 0)420420- sp = current->sas_ss_sp + current->sas_ss_size;421421- }422422-423423- return (void __user *)round_down(sp - size, 64);424424-}425425-426391static int __setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,427392 sigset_t *set, struct pt_regs *regs)428393{···413414 int err = 0;414415 struct task_struct *me = current;415416416416- if (used_math()) {417417- fp = get_stack(ka, regs->sp, sig_xstate_size);418418- frame = (void __user *)round_down(419419- (unsigned long)fp - sizeof(struct rt_sigframe), 16) - 8;420420-421421- if (save_i387_xstate(fp) < 0)422422- return -EFAULT;423423- } else424424- frame = get_stack(ka, regs->sp, sizeof(struct rt_sigframe)) - 8;417417+ frame = get_sigframe(ka, regs, sizeof(struct rt_sigframe), &fp);425418426419 if (!access_ok(VERIFY_WRITE, frame, sizeof(*frame)))427420 return -EFAULT;
-46
arch/x86/kernel/traps.c
···118118 if (!user_mode_vm(regs))119119 die(str, regs, err);120120}121121-122122-/*123123- * Perform the lazy TSS's I/O bitmap copy. If the TSS has an124124- * invalid offset set (the LAZY one) and the faulting thread has125125- * a valid I/O bitmap pointer, we copy the I/O bitmap in the TSS,126126- * we set the offset field correctly and return 1.127127- */128128-static int lazy_iobitmap_copy(void)129129-{130130- struct thread_struct *thread;131131- struct tss_struct *tss;132132- int cpu;133133-134134- cpu = get_cpu();135135- tss = &per_cpu(init_tss, cpu);136136- thread = ¤t->thread;137137-138138- if (tss->x86_tss.io_bitmap_base == INVALID_IO_BITMAP_OFFSET_LAZY &&139139- thread->io_bitmap_ptr) {140140- memcpy(tss->io_bitmap, thread->io_bitmap_ptr,141141- thread->io_bitmap_max);142142- /*143143- * If the previously set map was extending to higher ports144144- * than the current one, pad extra space with 0xff (no access).145145- */146146- if (thread->io_bitmap_max < tss->io_bitmap_max) {147147- memset((char *) tss->io_bitmap +148148- thread->io_bitmap_max, 0xff,149149- tss->io_bitmap_max - thread->io_bitmap_max);150150- }151151- tss->io_bitmap_max = thread->io_bitmap_max;152152- tss->x86_tss.io_bitmap_base = IO_BITMAP_OFFSET;153153- tss->io_bitmap_owner = thread;154154- put_cpu();155155-156156- return 1;157157- }158158- put_cpu();159159-160160- return 0;161161-}162121#endif163122164123static void __kprobes···268309 conditional_sti(regs);269310270311#ifdef CONFIG_X86_32271271- if (lazy_iobitmap_copy()) {272272- /* restart the faulting instruction */273273- return;274274- }275275-276312 if (regs->flags & X86_VM_MASK)277313 goto gp_in_vm86;278314#endif
···11#include <linux/highmem.h>22#include <linux/module.h>33+#include <linux/swap.h> /* for totalram_pages */3445void *kmap(struct page *page)56{···157156EXPORT_SYMBOL(kunmap);158157EXPORT_SYMBOL(kmap_atomic);159158EXPORT_SYMBOL(kunmap_atomic);159159+160160+#ifdef CONFIG_NUMA161161+void __init set_highmem_pages_init(void)162162+{163163+ struct zone *zone;164164+ int nid;165165+166166+ for_each_zone(zone) {167167+ unsigned long zone_start_pfn, zone_end_pfn;168168+169169+ if (!is_highmem(zone))170170+ continue;171171+172172+ zone_start_pfn = zone->zone_start_pfn;173173+ zone_end_pfn = zone_start_pfn + zone->spanned_pages;174174+175175+ nid = zone_to_nid(zone);176176+ printk(KERN_INFO "Initializing %s for node %d (%08lx:%08lx)\n",177177+ zone->name, nid, zone_start_pfn, zone_end_pfn);178178+179179+ add_highpages_with_active_regions(nid, zone_start_pfn,180180+ zone_end_pfn);181181+ }182182+ totalram_pages += totalhigh_pages;183183+}184184+#else185185+void __init set_highmem_pages_init(void)186186+{187187+ add_highpages_with_active_regions(0, highstart_pfn, highend_pfn);188188+189189+ totalram_pages += totalhigh_pages;190190+}191191+#endif /* CONFIG_NUMA */
+49
arch/x86/mm/init.c
···11+#include <linux/swap.h>22+#include <asm/cacheflush.h>33+#include <asm/page.h>44+#include <asm/sections.h>55+#include <asm/system.h>66+77+void free_init_pages(char *what, unsigned long begin, unsigned long end)88+{99+ unsigned long addr = begin;1010+1111+ if (addr >= end)1212+ return;1313+1414+ /*1515+ * If debugging page accesses then do not free this memory but1616+ * mark them not present - any buggy init-section access will1717+ * create a kernel page fault:1818+ */1919+#ifdef CONFIG_DEBUG_PAGEALLOC2020+ printk(KERN_INFO "debug: unmapping init memory %08lx..%08lx\n",2121+ begin, PAGE_ALIGN(end));2222+ set_memory_np(begin, (end - begin) >> PAGE_SHIFT);2323+#else2424+ /*2525+ * We just marked the kernel text read only above, now that2626+ * we are going to free part of that, we need to make that2727+ * writeable first.2828+ */2929+ set_memory_rw(begin, (end - begin) >> PAGE_SHIFT);3030+3131+ printk(KERN_INFO "Freeing %s: %luk freed\n", what, (end - begin) >> 10);3232+3333+ for (; addr < end; addr += PAGE_SIZE) {3434+ ClearPageReserved(virt_to_page(addr));3535+ init_page_count(virt_to_page(addr));3636+ memset((void *)(addr & ~(PAGE_SIZE-1)),3737+ POISON_FREE_INITMEM, PAGE_SIZE);3838+ free_page(addr);3939+ totalram_pages++;4040+ }4141+#endif4242+}4343+4444+void free_initmem(void)4545+{4646+ free_init_pages("unused kernel memory",4747+ (unsigned long)(&__init_begin),4848+ (unsigned long)(&__init_end));4949+}
+4-57
arch/x86/mm/init_32.c
···5050#include <asm/setup.h>5151#include <asm/cacheflush.h>52525353-unsigned int __VMALLOC_RESERVE = 128 << 20;5454-5553unsigned long max_low_pfn_mapped;5654unsigned long max_pfn_mapped;5755···467469 work_with_active_regions(nid, add_highpages_work_fn, &data);468470}469471470470-#ifndef CONFIG_NUMA471471-static void __init set_highmem_pages_init(void)472472-{473473- add_highpages_with_active_regions(0, highstart_pfn, highend_pfn);474474-475475- totalram_pages += totalhigh_pages;476476-}477477-#endif /* !CONFIG_NUMA */478478-479472#else480473static inline void permanent_kmaps_init(pgd_t *pgd_base)481481-{482482-}483483-static inline void set_highmem_pages_init(void)484474{485475}486476#endif /* CONFIG_HIGHMEM */···833847 unsigned long puds, pmds, ptes, tables, start;834848835849 puds = (end + PUD_SIZE - 1) >> PUD_SHIFT;836836- tables = PAGE_ALIGN(puds * sizeof(pud_t));850850+ tables = roundup(puds * sizeof(pud_t), PAGE_SIZE);837851838852 pmds = (end + PMD_SIZE - 1) >> PMD_SHIFT;839839- tables += PAGE_ALIGN(pmds * sizeof(pmd_t));853853+ tables += roundup(pmds * sizeof(pmd_t), PAGE_SIZE);840854841855 if (use_pse) {842856 unsigned long extra;···847861 } else848862 ptes = (end + PAGE_SIZE - 1) >> PAGE_SHIFT;849863850850- tables += PAGE_ALIGN(ptes * sizeof(pte_t));864864+ tables += roundup(ptes * sizeof(pte_t), PAGE_SIZE);851865852866 /* for fixmap */853853- tables += PAGE_ALIGN(__end_of_fixed_addresses * sizeof(pte_t));867867+ tables += roundup(__end_of_fixed_addresses * sizeof(pte_t), PAGE_SIZE);854868855869 /*856870 * RED-PEN putting page tables only on node 0 could···11991213#endif12001214}12011215#endif12021202-12031203-void free_init_pages(char *what, unsigned long begin, unsigned long end)12041204-{12051205-#ifdef CONFIG_DEBUG_PAGEALLOC12061206- /*12071207- * If debugging page accesses then do not free this memory but12081208- * mark them not present - any buggy init-section access will12091209- * create a kernel page fault:12101210- */12111211- printk(KERN_INFO "debug: unmapping init memory %08lx..%08lx\n",12121212- begin, PAGE_ALIGN(end));12131213- set_memory_np(begin, (end - begin) >> PAGE_SHIFT);12141214-#else12151215- unsigned long addr;12161216-12171217- /*12181218- * We just marked the kernel text read only above, now that12191219- * we are going to free part of that, we need to make that12201220- * writeable first.12211221- */12221222- set_memory_rw(begin, (end - begin) >> PAGE_SHIFT);12231223-12241224- for (addr = begin; addr < end; addr += PAGE_SIZE) {12251225- ClearPageReserved(virt_to_page(addr));12261226- init_page_count(virt_to_page(addr));12271227- memset((void *)addr, POISON_FREE_INITMEM, PAGE_SIZE);12281228- free_page(addr);12291229- totalram_pages++;12301230- }12311231- printk(KERN_INFO "Freeing %s: %luk freed\n", what, (end - begin) >> 10);12321232-#endif12331233-}12341234-12351235-void free_initmem(void)12361236-{12371237- free_init_pages("unused kernel memory",12381238- (unsigned long)(&__init_begin),12391239- (unsigned long)(&__init_end));12401240-}1241121612421217#ifdef CONFIG_BLK_DEV_INITRD12431218void free_initrd_mem(unsigned long start, unsigned long end)
+2-37
arch/x86/mm/init_64.c
···714714 pos = start_pfn << PAGE_SHIFT;715715 end_pfn = ((pos + (PMD_SIZE - 1)) >> PMD_SHIFT)716716 << (PMD_SHIFT - PAGE_SHIFT);717717+ if (end_pfn > (end >> PAGE_SHIFT))718718+ end_pfn = end >> PAGE_SHIFT;717719 if (start_pfn < end_pfn) {718720 nr_range = save_mr(mr, nr_range, start_pfn, end_pfn, 0);719721 pos = end_pfn << PAGE_SHIFT;···945943 reservedpages << (PAGE_SHIFT-10),946944 datasize >> 10,947945 initsize >> 10);948948-}949949-950950-void free_init_pages(char *what, unsigned long begin, unsigned long end)951951-{952952- unsigned long addr = begin;953953-954954- if (addr >= end)955955- return;956956-957957- /*958958- * If debugging page accesses then do not free this memory but959959- * mark them not present - any buggy init-section access will960960- * create a kernel page fault:961961- */962962-#ifdef CONFIG_DEBUG_PAGEALLOC963963- printk(KERN_INFO "debug: unmapping init memory %08lx..%08lx\n",964964- begin, PAGE_ALIGN(end));965965- set_memory_np(begin, (end - begin) >> PAGE_SHIFT);966966-#else967967- printk(KERN_INFO "Freeing %s: %luk freed\n", what, (end - begin) >> 10);968968-969969- for (; addr < end; addr += PAGE_SIZE) {970970- ClearPageReserved(virt_to_page(addr));971971- init_page_count(virt_to_page(addr));972972- memset((void *)(addr & ~(PAGE_SIZE-1)),973973- POISON_FREE_INITMEM, PAGE_SIZE);974974- free_page(addr);975975- totalram_pages++;976976- }977977-#endif978978-}979979-980980-void free_initmem(void)981981-{982982- free_init_pages("unused kernel memory",983983- (unsigned long)(&__init_begin),984984- (unsigned long)(&__init_end));985946}986947987948#ifdef CONFIG_DEBUG_RODATA
+4-51
arch/x86/mm/iomap_32.c
···2020#include <asm/pat.h>2121#include <linux/module.h>22222323-#ifdef CONFIG_X86_PAE2424-static int2525-is_io_mapping_possible(resource_size_t base, unsigned long size)2323+int is_io_mapping_possible(resource_size_t base, unsigned long size)2624{2727- return 1;2828-}2929-#else3030-static int3131-is_io_mapping_possible(resource_size_t base, unsigned long size)3232-{2525+#ifndef CONFIG_X86_PAE3326 /* There is no way to map greater than 1 << 32 address without PAE */3427 if (base + size > 0x100000000ULL)3528 return 0;3636-2929+#endif3730 return 1;3831}3939-#endif4040-4141-int4242-reserve_io_memtype_wc(u64 base, unsigned long size, pgprot_t *prot)4343-{4444- unsigned long ret_flag;4545-4646- if (!is_io_mapping_possible(base, size))4747- goto out_err;4848-4949- if (!pat_enabled) {5050- *prot = pgprot_noncached(PAGE_KERNEL);5151- return 0;5252- }5353-5454- if (reserve_memtype(base, base + size, _PAGE_CACHE_WC, &ret_flag))5555- goto out_err;5656-5757- if (ret_flag == _PAGE_CACHE_WB)5858- goto out_free;5959-6060- if (kernel_map_sync_memtype(base, size, ret_flag))6161- goto out_free;6262-6363- *prot = __pgprot(__PAGE_KERNEL | ret_flag);6464- return 0;6565-6666-out_free:6767- free_memtype(base, base + size);6868-out_err:6969- return -EINVAL;7070-}7171-EXPORT_SYMBOL_GPL(reserve_io_memtype_wc);7272-7373-void7474-free_io_memtype(u64 base, unsigned long size)7575-{7676- if (pat_enabled)7777- free_memtype(base, base + size);7878-}7979-EXPORT_SYMBOL_GPL(free_io_memtype);3232+EXPORT_SYMBOL_GPL(is_io_mapping_possible);80338134/* Map 'pfn' using fixed map 'type' and protections 'prot'8235 */
-26
arch/x86/mm/numa_32.c
···423423 setup_bootmem_allocator();424424}425425426426-void __init set_highmem_pages_init(void)427427-{428428-#ifdef CONFIG_HIGHMEM429429- struct zone *zone;430430- int nid;431431-432432- for_each_zone(zone) {433433- unsigned long zone_start_pfn, zone_end_pfn;434434-435435- if (!is_highmem(zone))436436- continue;437437-438438- zone_start_pfn = zone->zone_start_pfn;439439- zone_end_pfn = zone_start_pfn + zone->spanned_pages;440440-441441- nid = zone_to_nid(zone);442442- printk(KERN_INFO "Initializing %s for node %d (%08lx:%08lx)\n",443443- zone->name, nid, zone_start_pfn, zone_end_pfn);444444-445445- add_highpages_with_active_regions(nid, zone_start_pfn,446446- zone_end_pfn);447447- }448448- totalram_pages += totalhigh_pages;449449-#endif450450-}451451-452426#ifdef CONFIG_MEMORY_HOTPLUG453427static int paddr_to_nid(u64 addr)454428{
···313313 return young;314314}315315316316+/**317317+ * reserve_top_address - reserves a hole in the top of kernel address space318318+ * @reserve - size of hole to reserve319319+ *320320+ * Can be used to relocate the fixmap area and poke a hole in the top321321+ * of kernel address space to make room for a hypervisor.322322+ */323323+void __init reserve_top_address(unsigned long reserve)324324+{325325+#ifdef CONFIG_X86_32326326+ BUG_ON(fixmaps_set > 0);327327+ printk(KERN_INFO "Reserving virtual address space above 0x%08x\n",328328+ (int)-reserve);329329+ __FIXADDR_TOP = -reserve - PAGE_SIZE;330330+ __VMALLOC_RESERVE += reserve;331331+#endif332332+}333333+316334int fixmaps_set;317335318336void __native_set_fixmap(enum fixed_addresses idx, pte_t pte)
+2-16
arch/x86/mm/pgtable_32.c
···2020#include <asm/tlb.h>2121#include <asm/tlbflush.h>22222323+unsigned int __VMALLOC_RESERVE = 128 << 20;2424+2325/*2426 * Associate a virtual page frame with a given physical page frame 2527 * and protection flags for that frame.···98969997unsigned long __FIXADDR_TOP = 0xfffff000;10098EXPORT_SYMBOL(__FIXADDR_TOP);101101-102102-/**103103- * reserve_top_address - reserves a hole in the top of kernel address space104104- * @reserve - size of hole to reserve105105- *106106- * Can be used to relocate the fixmap area and poke a hole in the top107107- * of kernel address space to make room for a hypervisor.108108- */109109-void __init reserve_top_address(unsigned long reserve)110110-{111111- BUG_ON(fixmaps_set > 0);112112- printk(KERN_INFO "Reserving virtual address space above 0x%08x\n",113113- (int)-reserve);114114- __FIXADDR_TOP = -reserve - PAGE_SIZE;115115- __VMALLOC_RESERVE += reserve;116116-}11799118100/*119101 * vmalloc=size forces the vmalloc area to be exactly 'size'
+12-2
arch/x86/oprofile/op_model_ppro.c
···7878 if (cpu_has_arch_perfmon) {7979 union cpuid10_eax eax;8080 eax.full = cpuid_eax(0xa);8181- if (counter_width < eax.split.bit_width)8282- counter_width = eax.split.bit_width;8181+8282+ /*8383+ * For Core2 (family 6, model 15), don't reset the8484+ * counter width:8585+ */8686+ if (!(eax.split.version_id == 0 &&8787+ current_cpu_data.x86 == 6 &&8888+ current_cpu_data.x86_model == 15)) {8989+9090+ if (counter_width < eax.split.bit_width)9191+ counter_width = eax.split.bit_width;9292+ }8393 }84948595 /* clear all counters */
+53-41
block/blk-merge.c
···3838 }3939}40404141-void blk_recalc_rq_segments(struct request *rq)4141+static unsigned int __blk_recalc_rq_segments(struct request_queue *q,4242+ struct bio *bio,4343+ unsigned int *seg_size_ptr)4244{4343- int nr_phys_segs;4445 unsigned int phys_size;4546 struct bio_vec *bv, *bvprv = NULL;4646- int seg_size;4747- int cluster;4848- struct req_iterator iter;4949- int high, highprv = 1;5050- struct request_queue *q = rq->q;4747+ int cluster, i, high, highprv = 1;4848+ unsigned int seg_size, nr_phys_segs;4949+ struct bio *fbio;51505252- if (!rq->bio)5353- return;5151+ if (!bio)5252+ return 0;54535454+ fbio = bio;5555 cluster = test_bit(QUEUE_FLAG_CLUSTER, &q->queue_flags);5656 seg_size = 0;5757 phys_size = nr_phys_segs = 0;5858- rq_for_each_segment(bv, rq, iter) {5959- /*6060- * the trick here is making sure that a high page is never6161- * considered part of another segment, since that might6262- * change with the bounce page.6363- */6464- high = page_to_pfn(bv->bv_page) > q->bounce_pfn;6565- if (high || highprv)6666- goto new_segment;6767- if (cluster) {6868- if (seg_size + bv->bv_len > q->max_segment_size)5858+ for_each_bio(bio) {5959+ bio_for_each_segment(bv, bio, i) {6060+ /*6161+ * the trick here is making sure that a high page is6262+ * never considered part of another segment, since that6363+ * might change with the bounce page.6464+ */6565+ high = page_to_pfn(bv->bv_page) > q->bounce_pfn;6666+ if (high || highprv)6967 goto new_segment;7070- if (!BIOVEC_PHYS_MERGEABLE(bvprv, bv))7171- goto new_segment;7272- if (!BIOVEC_SEG_BOUNDARY(q, bvprv, bv))7373- goto new_segment;6868+ if (cluster) {6969+ if (seg_size + bv->bv_len > q->max_segment_size)7070+ goto new_segment;7171+ if (!BIOVEC_PHYS_MERGEABLE(bvprv, bv))7272+ goto new_segment;7373+ if (!BIOVEC_SEG_BOUNDARY(q, bvprv, bv))7474+ goto new_segment;74757575- seg_size += bv->bv_len;7676- bvprv = bv;7777- continue;7878- }7676+ seg_size += bv->bv_len;7777+ bvprv = bv;7878+ continue;7979+ }7980new_segment:8080- if (nr_phys_segs == 1 && seg_size > rq->bio->bi_seg_front_size)8181- rq->bio->bi_seg_front_size = seg_size;8181+ if (nr_phys_segs == 1 && seg_size >8282+ fbio->bi_seg_front_size)8383+ fbio->bi_seg_front_size = seg_size;82848383- nr_phys_segs++;8484- bvprv = bv;8585- seg_size = bv->bv_len;8686- highprv = high;8585+ nr_phys_segs++;8686+ bvprv = bv;8787+ seg_size = bv->bv_len;8888+ highprv = high;8989+ }8790 }88918989- if (nr_phys_segs == 1 && seg_size > rq->bio->bi_seg_front_size)9292+ if (seg_size_ptr)9393+ *seg_size_ptr = seg_size;9494+9595+ return nr_phys_segs;9696+}9797+9898+void blk_recalc_rq_segments(struct request *rq)9999+{100100+ unsigned int seg_size = 0, phys_segs;101101+102102+ phys_segs = __blk_recalc_rq_segments(rq->q, rq->bio, &seg_size);103103+104104+ if (phys_segs == 1 && seg_size > rq->bio->bi_seg_front_size)90105 rq->bio->bi_seg_front_size = seg_size;91106 if (seg_size > rq->biotail->bi_seg_back_size)92107 rq->biotail->bi_seg_back_size = seg_size;931089494- rq->nr_phys_segments = nr_phys_segs;109109+ rq->nr_phys_segments = phys_segs;95110}9611197112void blk_recount_segments(struct request_queue *q, struct bio *bio)98113{9999- struct request rq;100114 struct bio *nxt = bio->bi_next;101101- rq.q = q;102102- rq.bio = rq.biotail = bio;115115+103116 bio->bi_next = NULL;104104- blk_recalc_rq_segments(&rq);117117+ bio->bi_phys_segments = __blk_recalc_rq_segments(q, bio, NULL);105118 bio->bi_next = nxt;106106- bio->bi_phys_segments = rq.nr_phys_segments;107119 bio->bi_flags |= (1 << BIO_SEG_VALID);108120}109121EXPORT_SYMBOL(blk_recount_segments);
+16
block/genhd.c
···256256}257257#endif /* CONFIG_PROC_FS */258258259259+/**260260+ * register_blkdev - register a new block device261261+ *262262+ * @major: the requested major device number [1..255]. If @major=0, try to263263+ * allocate any unused major number.264264+ * @name: the name of the new block device as a zero terminated string265265+ *266266+ * The @name must be unique within the system.267267+ *268268+ * The return value depends on the @major input parameter.269269+ * - if a major device number was requested in range [1..255] then the270270+ * function returns zero on success, or a negative error code271271+ * - if any unused major number was requested with @major=0 parameter272272+ * then the return value is the allocated major number in range273273+ * [1..255] or a negative error code otherwise274274+ */259275int register_blkdev(unsigned int major, const char *name)260276{261277 struct blk_major_name **n, *p;
+59-17
drivers/ata/pata_amd.c
···2424#include <linux/libata.h>25252626#define DRV_NAME "pata_amd"2727-#define DRV_VERSION "0.3.11"2727+#define DRV_VERSION "0.4.1"28282929/**3030 * timing_setup - shared timing computation and load···145145 return ata_sff_prereset(link, deadline);146146}147147148148+/**149149+ * amd_cable_detect - report cable type150150+ * @ap: port151151+ *152152+ * AMD controller/BIOS setups record the cable type in word 0x42153153+ */154154+148155static int amd_cable_detect(struct ata_port *ap)149156{150157 static const u32 bitmask[2] = {0x03, 0x0C};···165158}166159167160/**161161+ * amd_fifo_setup - set the PIO FIFO for ATA/ATAPI162162+ * @ap: ATA interface163163+ * @adev: ATA device164164+ *165165+ * Set the PCI fifo for this device according to the devices present166166+ * on the bus at this point in time. We need to turn the post write buffer167167+ * off for ATAPI devices as we may need to issue a word sized write to the168168+ * device as the final I/O169169+ */170170+171171+static void amd_fifo_setup(struct ata_port *ap)172172+{173173+ struct ata_device *adev;174174+ struct pci_dev *pdev = to_pci_dev(ap->host->dev);175175+ static const u8 fifobit[2] = { 0xC0, 0x30};176176+ u8 fifo = fifobit[ap->port_no];177177+ u8 r;178178+179179+180180+ ata_for_each_dev(adev, &ap->link, ENABLED) {181181+ if (adev->class == ATA_DEV_ATAPI)182182+ fifo = 0;183183+ }184184+ if (pdev->device == PCI_DEVICE_ID_AMD_VIPER_7411) /* FIFO is broken */185185+ fifo = 0;186186+187187+ /* On the later chips the read prefetch bits become no-op bits */188188+ pci_read_config_byte(pdev, 0x41, &r);189189+ r &= ~fifobit[ap->port_no];190190+ r |= fifo;191191+ pci_write_config_byte(pdev, 0x41, r);192192+}193193+194194+/**168195 * amd33_set_piomode - set initial PIO mode data169196 * @ap: ATA interface170197 * @adev: ATA device···208167209168static void amd33_set_piomode(struct ata_port *ap, struct ata_device *adev)210169{170170+ amd_fifo_setup(ap);211171 timing_setup(ap, adev, 0x40, adev->pio_mode, 1);212172}213173214174static void amd66_set_piomode(struct ata_port *ap, struct ata_device *adev)215175{176176+ amd_fifo_setup(ap);216177 timing_setup(ap, adev, 0x40, adev->pio_mode, 2);217178}218179219180static void amd100_set_piomode(struct ata_port *ap, struct ata_device *adev)220181{182182+ amd_fifo_setup(ap);221183 timing_setup(ap, adev, 0x40, adev->pio_mode, 3);222184}223185224186static void amd133_set_piomode(struct ata_port *ap, struct ata_device *adev)225187{188188+ amd_fifo_setup(ap);226189 timing_setup(ap, adev, 0x40, adev->pio_mode, 4);227190}228191···442397 .set_dmamode = nv133_set_dmamode,443398};444399400400+static void amd_clear_fifo(struct pci_dev *pdev)401401+{402402+ u8 fifo;403403+ /* Disable the FIFO, the FIFO logic will re-enable it as404404+ appropriate */405405+ pci_read_config_byte(pdev, 0x41, &fifo);406406+ fifo &= 0x0F;407407+ pci_write_config_byte(pdev, 0x41, fifo);408408+}409409+445410static int amd_init_one(struct pci_dev *pdev, const struct pci_device_id *id)446411{447412 static const struct ata_port_info info[10] = {···558503559504 if (type < 3)560505 ata_pci_bmdma_clear_simplex(pdev);561561-562562- /* Check for AMD7411 */563563- if (type == 3)564564- /* FIFO is broken */565565- pci_write_config_byte(pdev, 0x41, fifo & 0x0F);566566- else567567- pci_write_config_byte(pdev, 0x41, fifo | 0xF0);568568-506506+ if (pdev->vendor == PCI_VENDOR_ID_AMD)507507+ amd_clear_fifo(pdev);569508 /* Cable detection on Nvidia chips doesn't work too well,570509 * cache BIOS programmed UDMA mode.571510 */···585536 return rc;586537587538 if (pdev->vendor == PCI_VENDOR_ID_AMD) {588588- u8 fifo;589589- pci_read_config_byte(pdev, 0x41, &fifo);590590- if (pdev->device == PCI_DEVICE_ID_AMD_VIPER_7411)591591- /* FIFO is broken */592592- pci_write_config_byte(pdev, 0x41, fifo & 0x0F);593593- else594594- pci_write_config_byte(pdev, 0x41, fifo | 0xF0);539539+ amd_clear_fifo(pdev);595540 if (pdev->device == PCI_DEVICE_ID_AMD_VIPER_7409 ||596541 pdev->device == PCI_DEVICE_ID_AMD_COBRA_7401)597542 ata_pci_bmdma_clear_simplex(pdev);598543 }599599-600544 ata_host_resume(host);601545 return 0;602546}
+3
drivers/ata/pata_it821x.c
···557557 id[83] |= 0x4400; /* Word 83 is valid and LBA48 */558558 id[86] |= 0x0400; /* LBA48 on */559559 id[ATA_ID_MAJOR_VER] |= 0x1F;560560+ /* Clear the serial number because it's different each boot561561+ which breaks validation on resume */562562+ memset(&id[ATA_ID_SERNO], 0x20, ATA_ID_SERNO_LEN);560563 }561564 return err_mask;562565}
+4-3
drivers/ata/pata_legacy.c
···283283static unsigned int pdc_data_xfer_vlb(struct ata_device *dev,284284 unsigned char *buf, unsigned int buflen, int rw)285285{286286- if (ata_id_has_dword_io(dev->id)) {286286+ int slop = buflen & 3;287287+ /* 32bit I/O capable *and* we need to write a whole number of dwords */288288+ if (ata_id_has_dword_io(dev->id) && (slop == 0 || slop == 3)) {287289 struct ata_port *ap = dev->link->ap;288288- int slop = buflen & 3;289290 unsigned long flags;290291291292 local_irq_save(flags);···736735 struct ata_port *ap = adev->link->ap;737736 int slop = buflen & 3;738737739739- if (ata_id_has_dword_io(adev->id)) {738738+ if (ata_id_has_dword_io(adev->id) && (slop == 0 || slop == 3)) {740739 if (rw == WRITE)741740 iowrite32_rep(ap->ioaddr.data_addr, buf, buflen >> 2);742741 else
+9-11
drivers/ata/sata_mv.c
···31143114 writelfl(0, hc_mmio + HC_IRQ_CAUSE_OFS);31153115 }3116311631173117- if (!IS_SOC(hpriv)) {31183118- /* Clear any currently outstanding host interrupt conditions */31193119- writelfl(0, mmio + hpriv->irq_cause_ofs);31173117+ /* Clear any currently outstanding host interrupt conditions */31183118+ writelfl(0, mmio + hpriv->irq_cause_ofs);3120311931213121- /* and unmask interrupt generation for host regs */31223122- writelfl(hpriv->unmask_all_irqs, mmio + hpriv->irq_mask_ofs);31203120+ /* and unmask interrupt generation for host regs */31213121+ writelfl(hpriv->unmask_all_irqs, mmio + hpriv->irq_mask_ofs);3123312231243124- /*31253125- * enable only global host interrupts for now.31263126- * The per-port interrupts get done later as ports are set up.31273127- */31283128- mv_set_main_irq_mask(host, 0, PCI_ERR);31293129- }31233123+ /*31243124+ * enable only global host interrupts for now.31253125+ * The per-port interrupts get done later as ports are set up.31263126+ */31273127+ mv_set_main_irq_mask(host, 0, PCI_ERR);31303128done:31313129 return rc;31323130}
+7-3
drivers/block/cciss.c
···36113611 schedule_timeout_uninterruptible(30*HZ);3612361236133613 /* Now try to get the controller to respond to a no-op */36143614- for (i=0; i<12; i++) {36143614+ for (i=0; i<30; i++) {36153615 if (cciss_noop(pdev) == 0)36163616 break;36173617- else36183618- printk("cciss: no-op failed%s\n", (i < 11 ? "; re-trying" : ""));36173617+36183618+ schedule_timeout_uninterruptible(HZ);36193619+ }36203620+ if (i == 30) {36213621+ printk(KERN_ERR "cciss: controller seems dead\n");36223622+ return -EBUSY;36193623 }36203624 }36213625
···452452 kfree(modes);453453 kfree(enabled);454454}455455+456456+/**457457+ * drm_encoder_crtc_ok - can a given crtc drive a given encoder?458458+ * @encoder: encoder to test459459+ * @crtc: crtc to test460460+ *461461+ * Return false if @encoder can't be driven by @crtc, true otherwise.462462+ */463463+static bool drm_encoder_crtc_ok(struct drm_encoder *encoder,464464+ struct drm_crtc *crtc)465465+{466466+ struct drm_device *dev;467467+ struct drm_crtc *tmp;468468+ int crtc_mask = 1;469469+470470+ WARN(!crtc, "checking null crtc?");471471+472472+ dev = crtc->dev;473473+474474+ list_for_each_entry(tmp, &dev->mode_config.crtc_list, head) {475475+ if (tmp == crtc)476476+ break;477477+ crtc_mask <<= 1;478478+ }479479+480480+ if (encoder->possible_crtcs & crtc_mask)481481+ return true;482482+ return false;483483+}484484+485485+/*486486+ * Check the CRTC we're going to map each output to vs. its current487487+ * CRTC. If they don't match, we have to disable the output and the CRTC488488+ * since the driver will have to re-route things.489489+ */490490+static void491491+drm_crtc_prepare_encoders(struct drm_device *dev)492492+{493493+ struct drm_encoder_helper_funcs *encoder_funcs;494494+ struct drm_encoder *encoder;495495+496496+ list_for_each_entry(encoder, &dev->mode_config.encoder_list, head) {497497+ encoder_funcs = encoder->helper_private;498498+ /* Disable unused encoders */499499+ if (encoder->crtc == NULL)500500+ (*encoder_funcs->dpms)(encoder, DRM_MODE_DPMS_OFF);501501+ /* Disable encoders whose CRTC is about to change */502502+ if (encoder_funcs->get_crtc &&503503+ encoder->crtc != (*encoder_funcs->get_crtc)(encoder))504504+ (*encoder_funcs->dpms)(encoder, DRM_MODE_DPMS_OFF);505505+ }506506+}507507+455508/**456509 * drm_crtc_set_mode - set a mode457510 * @crtc: CRTC to program···600547 encoder_funcs->prepare(encoder);601548 }602549550550+ drm_crtc_prepare_encoders(dev);551551+603552 crtc_funcs->prepare(crtc);604553605554 /* Set up the DPLL and any encoders state that needs to adjust or depend···672617 struct drm_device *dev;673618 struct drm_crtc **save_crtcs, *new_crtc;674619 struct drm_encoder **save_encoders, *new_encoder;675675- struct drm_framebuffer *old_fb;620620+ struct drm_framebuffer *old_fb = NULL;676621 bool save_enabled;677622 bool mode_changed = false;678623 bool fb_changed = false;···723668 * and then just flip_or_move it */724669 if (set->crtc->fb != set->fb) {725670 /* If we have no fb then treat it as a full mode set */726726- if (set->crtc->fb == NULL)671671+ if (set->crtc->fb == NULL) {672672+ DRM_DEBUG("crtc has no fb, full mode set\n");727673 mode_changed = true;728728- else if ((set->fb->bits_per_pixel !=674674+ } else if ((set->fb->bits_per_pixel !=729675 set->crtc->fb->bits_per_pixel) ||730676 set->fb->depth != set->crtc->fb->depth)731677 fb_changed = true;···738682 fb_changed = true;739683740684 if (set->mode && !drm_mode_equal(set->mode, &set->crtc->mode)) {741741- DRM_DEBUG("modes are different\n");685685+ DRM_DEBUG("modes are different, full mode set\n");742686 drm_mode_debug_printmodeline(&set->crtc->mode);743687 drm_mode_debug_printmodeline(set->mode);744688 mode_changed = true;···764708 }765709766710 if (new_encoder != connector->encoder) {711711+ DRM_DEBUG("encoder changed, full mode switch\n");767712 mode_changed = true;768713 connector->encoder = new_encoder;769714 }···791734 if (set->connectors[ro] == connector)792735 new_crtc = set->crtc;793736 }737737+738738+ /* Make sure the new CRTC will work with the encoder */739739+ if (new_crtc &&740740+ !drm_encoder_crtc_ok(connector->encoder, new_crtc)) {741741+ ret = -EINVAL;742742+ goto fail_set_mode;743743+ }794744 if (new_crtc != connector->encoder->crtc) {745745+ DRM_DEBUG("crtc changed, full mode switch\n");795746 mode_changed = true;796747 connector->encoder->crtc = new_crtc;797748 }749749+ DRM_DEBUG("setting connector %d crtc to %p\n",750750+ connector->base.id, new_crtc);798751 }799752800753 /* mode_set_base is not a required function */···848781849782fail_set_mode:850783 set->crtc->enabled = save_enabled;784784+ set->crtc->fb = old_fb;851785 count = 0;852786 list_for_each_entry(connector, &dev->mode_config.connector_list, head) {853787 if (!connector->encoder)
+3-3
drivers/gpu/drm/drm_edid.c
···125125 DRM_ERROR("EDID has major version %d, instead of 1\n", edid->version);126126 goto bad;127127 }128128- if (edid->revision <= 0 || edid->revision > 3) {128128+ if (edid->revision > 3) {129129 DRM_ERROR("EDID has minor version %d, which is not between 0-3\n", edid->revision);130130 goto bad;131131 }···320320 mode->htotal = mode->hdisplay + ((pt->hblank_hi << 8) | pt->hblank_lo);321321322322 mode->vdisplay = (pt->vactive_hi << 8) | pt->vactive_lo;323323- mode->vsync_start = mode->vdisplay + ((pt->vsync_offset_hi << 8) |323323+ mode->vsync_start = mode->vdisplay + ((pt->vsync_offset_hi << 4) |324324 pt->vsync_offset_lo);325325 mode->vsync_end = mode->vsync_start +326326- ((pt->vsync_pulse_width_hi << 8) |326326+ ((pt->vsync_pulse_width_hi << 4) |327327 pt->vsync_pulse_width_lo);328328 mode->vtotal = mode->vdisplay + ((pt->vblank_hi << 8) | pt->vblank_lo);329329
+14
drivers/gpu/drm/drm_fops.c
···484484 mutex_lock(&dev->struct_mutex);485485486486 if (file_priv->is_master) {487487+ struct drm_master *master = file_priv->master;487488 struct drm_file *temp;488489 list_for_each_entry(temp, &dev->filelist, lhead) {489490 if ((temp->master == file_priv->master) &&490491 (temp != file_priv))491492 temp->authenticated = 0;493493+ }494494+495495+ /**496496+ * Since the master is disappearing, so is the497497+ * possibility to lock.498498+ */499499+500500+ if (master->lock.hw_lock) {501501+ if (dev->sigdata.lock == master->lock.hw_lock)502502+ dev->sigdata.lock = NULL;503503+ master->lock.hw_lock = NULL;504504+ master->lock.file_priv = NULL;505505+ wake_up_interruptible_all(&master->lock.lock_queue);492506 }493507494508 if (file_priv->minor->master == file_priv->master) {
+10-4
drivers/gpu/drm/drm_irq.c
···435435 */436436void drm_vblank_put(struct drm_device *dev, int crtc)437437{438438+ BUG_ON (atomic_read (&dev->vblank_refcount[crtc]) == 0);439439+438440 /* Last user schedules interrupt disable */439441 if (atomic_dec_and_test(&dev->vblank_refcount[crtc]))440442 mod_timer(&dev->vblank_disable_timer, jiffies + 5*DRM_HZ);···462460 * so that interrupts remain enabled in the interim.463461 */464462 if (!dev->vblank_inmodeset[crtc]) {465465- dev->vblank_inmodeset[crtc] = 1;466466- drm_vblank_get(dev, crtc);463463+ dev->vblank_inmodeset[crtc] = 0x1;464464+ if (drm_vblank_get(dev, crtc) == 0)465465+ dev->vblank_inmodeset[crtc] |= 0x2;467466 }468467}469468EXPORT_SYMBOL(drm_vblank_pre_modeset);···476473 if (dev->vblank_inmodeset[crtc]) {477474 spin_lock_irqsave(&dev->vbl_lock, irqflags);478475 dev->vblank_disable_allowed = 1;479479- dev->vblank_inmodeset[crtc] = 0;480476 spin_unlock_irqrestore(&dev->vbl_lock, irqflags);481481- drm_vblank_put(dev, crtc);477477+478478+ if (dev->vblank_inmodeset[crtc] & 0x2)479479+ drm_vblank_put(dev, crtc);480480+481481+ dev->vblank_inmodeset[crtc] = 0;482482 }483483}484484EXPORT_SYMBOL(drm_vblank_post_modeset);
+2-1
drivers/gpu/drm/drm_lock.c
···8080 __set_current_state(TASK_INTERRUPTIBLE);8181 if (!master->lock.hw_lock) {8282 /* Device has been unregistered */8383+ send_sig(SIGTERM, current, 0);8384 ret = -EINTR;8485 break;8586 }···9493 /* Contention */9594 schedule();9695 if (signal_pending(current)) {9797- ret = -ERESTARTSYS;9696+ ret = -EINTR;9897 break;9998 }10099 }
···383383 drm_i915_irq_emit_t *emit = data;384384 int result;385385386386- RING_LOCK_TEST_WITH_RETURN(dev, file_priv);387387-388386 if (!dev_priv) {389387 DRM_ERROR("called with no initialization\n");390388 return -EINVAL;391389 }390390+391391+ RING_LOCK_TEST_WITH_RETURN(dev, file_priv);392392+392393 mutex_lock(&dev->struct_mutex);393394 result = i915_emit_irq(dev);394395 mutex_unlock(&dev->struct_mutex);
+6
drivers/gpu/drm/i915/intel_bios.c
···111111 panel_fixed_mode->clock = dvo_timing->clock * 10;112112 panel_fixed_mode->type = DRM_MODE_TYPE_PREFERRED;113113114114+ /* Some VBTs have bogus h/vtotal values */115115+ if (panel_fixed_mode->hsync_end > panel_fixed_mode->htotal)116116+ panel_fixed_mode->htotal = panel_fixed_mode->hsync_end + 1;117117+ if (panel_fixed_mode->vsync_end > panel_fixed_mode->vtotal)118118+ panel_fixed_mode->vtotal = panel_fixed_mode->vsync_end + 1;119119+114120 drm_mode_set_name(panel_fixed_mode);115121116122 dev_priv->vbt_mode = panel_fixed_mode;
+1-1
drivers/gpu/drm/i915/intel_display.c
···217217 return false;218218}219219220220-#define INTELPllInvalid(s) do { DRM_DEBUG(s); return false; } while (0)220220+#define INTELPllInvalid(s) do { /* DRM_DEBUG(s); */ return false; } while (0)221221/**222222 * Returns whether the given set of divisors are valid for a given refclk with223223 * the given connectors.
+1-1
drivers/ide/Kconfig
···4646 SMART parameters from disk drives.47474848 To compile this driver as a module, choose M here: the4949- module will be called ide.4949+ module will be called ide-core.ko.50505151 For further information, please read <file:Documentation/ide/ide.txt>.5252
+1-1
drivers/ide/amd74xx.c
···166166 * Check for broken FIFO support.167167 */168168 if (dev->vendor == PCI_VENDOR_ID_AMD &&169169- dev->vendor == PCI_DEVICE_ID_AMD_VIPER_7411)169169+ dev->device == PCI_DEVICE_ID_AMD_VIPER_7411)170170 t &= 0x0f;171171 else172172 t |= 0xf0;
···55555656static DEFINE_MUTEX(idecd_ref_mutex);57575858-static void ide_cd_release(struct kref *);5858+static void ide_cd_release(struct device *);59596060static struct cdrom_info *ide_cd_get(struct gendisk *disk)6161{···6767 if (ide_device_get(cd->drive))6868 cd = NULL;6969 else7070- kref_get(&cd->kref);7070+ get_device(&cd->dev);71717272 }7373 mutex_unlock(&idecd_ref_mutex);···7979 ide_drive_t *drive = cd->drive;80808181 mutex_lock(&idecd_ref_mutex);8282- kref_put(&cd->kref, ide_cd_release);8282+ put_device(&cd->dev);8383 ide_device_put(drive);8484 mutex_unlock(&idecd_ref_mutex);8585}···194194 bio_sectors = max(bio_sectors(failed_command->bio), 4U);195195 sector &= ~(bio_sectors - 1);196196197197+ /*198198+ * The SCSI specification allows for the value199199+ * returned by READ CAPACITY to be up to 75 2K200200+ * sectors past the last readable block.201201+ * Therefore, if we hit a medium error within the202202+ * last 75 2K sectors, we decrease the saved size203203+ * value.204204+ */197205 if (sector < get_capacity(info->disk) &&198206 drive->probed_capacity - sector < 4 * 75)199207 set_capacity(info->disk, sector);···17981790 ide_debug_log(IDE_DBG_FUNC, "Call %s\n", __func__);1799179118001792 ide_proc_unregister_driver(drive, info->driver);18011801-17931793+ device_del(&info->dev);18021794 del_gendisk(info->disk);1803179518041804- ide_cd_put(info);17961796+ mutex_lock(&idecd_ref_mutex);17971797+ put_device(&info->dev);17981798+ mutex_unlock(&idecd_ref_mutex);18051799}1806180018071807-static void ide_cd_release(struct kref *kref)18011801+static void ide_cd_release(struct device *dev)18081802{18091809- struct cdrom_info *info = to_ide_drv(kref, cdrom_info);18031803+ struct cdrom_info *info = to_ide_drv(dev, cdrom_info);18101804 struct cdrom_device_info *devinfo = &info->devinfo;18111805 ide_drive_t *drive = info->drive;18121806 struct gendisk *g = info->disk;···2007199720081998 ide_init_disk(g, drive);2009199920102010- kref_init(&info->kref);20002000+ info->dev.parent = &drive->gendev;20012001+ info->dev.release = ide_cd_release;20022002+ dev_set_name(&info->dev, dev_name(&drive->gendev));20032003+20042004+ if (device_register(&info->dev))20052005+ goto out_free_disk;2011200620122007 info->drive = drive;20132008 info->driver = &ide_cdrom_driver;···20262011 g->driverfs_dev = &drive->gendev;20272012 g->flags = GENHD_FL_CD | GENHD_FL_REMOVABLE;20282013 if (ide_cdrom_setup(drive)) {20292029- ide_cd_release(&info->kref);20142014+ put_device(&info->dev);20302015 goto failed;20312016 }20322017···20362021 add_disk(g);20372022 return 0;2038202320242024+out_free_disk:20252025+ put_disk(g);20392026out_free_cd:20402027 kfree(info);20412028failed:
+1-1
drivers/ide/ide-cd.h
···8080 ide_drive_t *drive;8181 struct ide_driver *driver;8282 struct gendisk *disk;8383- struct kref kref;8383+ struct device dev;84848585 /* Buffer for table of contents. NULL if we haven't allocated8686 a TOC buffer for this device yet. */
···337337 int a, b, i, j = 1;338338 unsigned int *dev_param_mask = (unsigned int *)kp->arg;339339340340+ /* controller . device (0 or 1) [ : 1 (set) | 0 (clear) ] */340341 if (sscanf(s, "%d.%d:%d", &a, &b, &j) != 3 &&341342 sscanf(s, "%d.%d", &a, &b) != 2)342343 return -EINVAL;···350349 if (j)351350 *dev_param_mask |= (1 << i);352351 else353353- *dev_param_mask &= (1 << i);352352+ *dev_param_mask &= ~(1 << i);354353355354 return 0;356355}···393392{394393 int a, b, c = 0, h = 0, s = 0, i, j = 1;395394395395+ /* controller . device (0 or 1) : Cylinders , Heads , Sectors */396396+ /* controller . device (0 or 1) : 1 (use CHS) | 0 (ignore CHS) */396397 if (sscanf(str, "%d.%d:%d,%d,%d", &a, &b, &c, &h, &s) != 5 &&397398 sscanf(str, "%d.%d:%d", &a, &b, &j) != 3)398399 return -EINVAL;···410407 if (j)411408 ide_disks |= (1 << i);412409 else413413- ide_disks &= (1 << i);410410+ ide_disks &= ~(1 << i);414411415412 ide_disks_chs[i].cyl = c;416413 ide_disks_chs[i].head = h;···472469{473470 int i, j = 1;474471472472+ /* controller (ignore) */473473+ /* controller : 1 (ignore) | 0 (use) */475474 if (sscanf(s, "%d:%d", &i, &j) != 2 && sscanf(s, "%d", &i) != 1)476475 return -EINVAL;477476···483478 if (j)484479 ide_ignore_cable |= (1 << i);485480 else486486- ide_ignore_cable &= (1 << i);481481+ ide_ignore_cable &= ~(1 << i);487482488483 return 0;489484}
+2-3
drivers/ide/it821x.c
···55 * May be copied or modified under the terms of the GNU General Public License66 * Based in part on the ITE vendor provided SCSI driver.77 *88- * Documentation available from99- * http://www.ite.com.tw/pc/IT8212F_V04.pdf1010- * Some other documents are NDA.88+ * Documentation:99+ * Datasheet is freely available, some other documents under NDA.1110 *1211 * The ITE8212 isn't exactly a standard IDE controller. It has two1312 * modes. In pass through mode then it is an IDE controller. In its smart
···343343#define spitzkbd_resume NULL344344#endif345345346346-static int __init spitzkbd_probe(struct platform_device *dev)346346+static int __devinit spitzkbd_probe(struct platform_device *dev)347347{348348 struct spitzkbd *spitzkbd;349349 struct input_dev *input_dev;···444444 return err;445445}446446447447-static int spitzkbd_remove(struct platform_device *dev)447447+static int __devexit spitzkbd_remove(struct platform_device *dev)448448{449449 int i;450450 struct spitzkbd *spitzkbd = platform_get_drvdata(dev);···470470471471static struct platform_driver spitzkbd_driver = {472472 .probe = spitzkbd_probe,473473- .remove = spitzkbd_remove,473473+ .remove = __devexit_p(spitzkbd_remove),474474 .suspend = spitzkbd_suspend,475475 .resume = spitzkbd_resume,476476 .driver = {···479479 },480480};481481482482-static int __devinit spitzkbd_init(void)482482+static int __init spitzkbd_init(void)483483{484484 return platform_driver_register(&spitzkbd_driver);485485}
+1-1
drivers/input/mouse/Kconfig
···7070config MOUSE_PS2_LIFEBOOK7171 bool "Fujitsu Lifebook PS/2 mouse protocol extension" if EMBEDDED7272 default y7373- depends on MOUSE_PS27373+ depends on MOUSE_PS2 && X867474 help7575 Say Y here if you have a Fujitsu B-series Lifebook PS/27676 TouchScreen connected to your system.
+24-8
drivers/input/mouse/elantech.c
···542542 ps2_command(ps2dev, NULL, PSMOUSE_CMD_SETSCALE11) ||543543 ps2_command(ps2dev, NULL, PSMOUSE_CMD_SETSCALE11) ||544544 ps2_command(ps2dev, param, PSMOUSE_CMD_GETINFO)) {545545- pr_err("elantech.c: sending Elantech magic knock failed.\n");545545+ pr_debug("elantech.c: sending Elantech magic knock failed.\n");546546 return -1;547547 }548548···551551 * set of magic numbers552552 */553553 if (param[0] != 0x3c || param[1] != 0x03 || param[2] != 0xc8) {554554- pr_info("elantech.c: unexpected magic knock result 0x%02x, 0x%02x, 0x%02x.\n",555555- param[0], param[1], param[2]);554554+ pr_debug("elantech.c: "555555+ "unexpected magic knock result 0x%02x, 0x%02x, 0x%02x.\n",556556+ param[0], param[1], param[2]);557557+ return -1;558558+ }559559+560560+ /*561561+ * Query touchpad's firmware version and see if it reports known562562+ * value to avoid mis-detection. Logitech mice are known to respond563563+ * to Elantech magic knock and there might be more.564564+ */565565+ if (synaptics_send_cmd(psmouse, ETP_FW_VERSION_QUERY, param)) {566566+ pr_debug("elantech.c: failed to query firmware version.\n");567567+ return -1;568568+ }569569+570570+ pr_debug("elantech.c: Elantech version query result 0x%02x, 0x%02x, 0x%02x.\n",571571+ param[0], param[1], param[2]);572572+573573+ if (param[0] == 0 || param[1] != 0) {574574+ pr_debug("elantech.c: Probably not a real Elantech touchpad. Aborting.\n");556575 return -1;557576 }558577···619600 int i, error;620601 unsigned char param[3];621602622622- etd = kzalloc(sizeof(struct elantech_data), GFP_KERNEL);623623- psmouse->private = etd;603603+ psmouse->private = etd = kzalloc(sizeof(struct elantech_data), GFP_KERNEL);624604 if (!etd)625605 return -1;626606···628610 etd->parity[i] = etd->parity[i & (i - 1)] ^ 1;629611630612 /*631631- * Find out what version hardware this is613613+ * Do the version query again so we can store the result632614 */633615 if (synaptics_send_cmd(psmouse, ETP_FW_VERSION_QUERY, param)) {634616 pr_err("elantech.c: failed to query firmware version.\n");635617 goto init_fail;636618 }637637- pr_info("elantech.c: Elantech version query result 0x%02x, 0x%02x, 0x%02x.\n",638638- param[0], param[1], param[2]);639619 etd->fw_version_maj = param[0];640620 etd->fw_version_min = param[2];641621
+1-1
drivers/input/mouse/pxa930_trkball.c
···83838484 __raw_writel(v, trkball->mmio_base + TBCR);85858686- while (i--) {8686+ while (--i) {8787 if (__raw_readl(trkball->mmio_base + TBCR) == v)8888 break;8989 msleep(1);
+4-5
drivers/input/mouse/synaptics.c
···182182183183static int synaptics_query_hardware(struct psmouse *psmouse)184184{185185- int retries = 0;186186-187187- while ((retries++ < 3) && psmouse_reset(psmouse))188188- /* empty */;189189-190185 if (synaptics_identify(psmouse))191186 return -1;192187 if (synaptics_model_id(psmouse))···577582 struct synaptics_data *priv = psmouse->private;578583 struct synaptics_data old_priv = *priv;579584585585+ psmouse_reset(psmouse);586586+580587 if (synaptics_detect(psmouse, 0))581588 return -1;582589···636639 psmouse->private = priv = kzalloc(sizeof(struct synaptics_data), GFP_KERNEL);637640 if (!priv)638641 return -1;642642+643643+ psmouse_reset(psmouse);639644640645 if (synaptics_query_hardware(psmouse)) {641646 printk(KERN_ERR "Unable to query Synaptics hardware.\n");
···6060module_param(swap_xy, bool, 0644);6161MODULE_PARM_DESC(swap_xy, "If set X and Y axes are swapped.");62626363+static int hwcalib_xy;6464+module_param(hwcalib_xy, bool, 0644);6565+MODULE_PARM_DESC(hwcalib_xy, "If set hw-calibrated X/Y are used if available");6666+6367/* device specifc data/functions */6468struct usbtouch_usb;6569struct usbtouch_device_info {···122118123119#define USB_DEVICE_HID_CLASS(vend, prod) \124120 .match_flags = USB_DEVICE_ID_MATCH_INT_CLASS \121121+ | USB_DEVICE_ID_MATCH_INT_PROTOCOL \125122 | USB_DEVICE_ID_MATCH_DEVICE, \126123 .idVendor = (vend), \127124 .idProduct = (prod), \···265260266261static int mtouch_read_data(struct usbtouch_usb *dev, unsigned char *pkt)267262{268268- dev->x = (pkt[8] << 8) | pkt[7];269269- dev->y = (pkt[10] << 8) | pkt[9];263263+ if (hwcalib_xy) {264264+ dev->x = (pkt[4] << 8) | pkt[3];265265+ dev->y = 0xffff - ((pkt[6] << 8) | pkt[5]);266266+ } else {267267+ dev->x = (pkt[8] << 8) | pkt[7];268268+ dev->y = (pkt[10] << 8) | pkt[9];269269+ }270270 dev->touch = (pkt[2] & 0x40) ? 1 : 0;271271272272 return 1;···302292 break;303293 if (ret != -EPIPE)304294 return ret;295295+ }296296+297297+ /* Default min/max xy are the raw values, override if using hw-calib */298298+ if (hwcalib_xy) {299299+ input_set_abs_params(usbtouch->input, ABS_X, 0, 0xffff, 0, 0);300300+ input_set_abs_params(usbtouch->input, ABS_Y, 0, 0xffff, 0, 0);305301 }306302307303 return 0;
+2-1
drivers/md/raid1.c
···12371237 update_head_pos(mirror, r1_bio);1238123812391239 if (atomic_dec_and_test(&r1_bio->remaining)) {12401240- md_done_sync(mddev, r1_bio->sectors, uptodate);12401240+ sector_t s = r1_bio->sectors;12411241 put_buf(r1_bio);12421242+ md_done_sync(mddev, s, uptodate);12421243 }12431244}12441245
+10-9
drivers/md/raid10.c
···12361236 /* for reconstruct, we always reschedule after a read.12371237 * for resync, only after all reads12381238 */12391239+ rdev_dec_pending(conf->mirrors[d].rdev, conf->mddev);12391240 if (test_bit(R10BIO_IsRecover, &r10_bio->state) ||12401241 atomic_dec_and_test(&r10_bio->remaining)) {12411242 /* we have read all the blocks,···12441243 */12451244 reschedule_retry(r10_bio);12461245 }12471247- rdev_dec_pending(conf->mirrors[d].rdev, conf->mddev);12481246}1249124712501248static void end_sync_write(struct bio *bio, int error)···1264126412651265 update_head_pos(i, r10_bio);1266126612671267+ rdev_dec_pending(conf->mirrors[d].rdev, mddev);12671268 while (atomic_dec_and_test(&r10_bio->remaining)) {12681269 if (r10_bio->master_bio == NULL) {12691270 /* the primary of several recovery bios */12701270- md_done_sync(mddev, r10_bio->sectors, 1);12711271+ sector_t s = r10_bio->sectors;12711272 put_buf(r10_bio);12731273+ md_done_sync(mddev, s, 1);12721274 break;12731275 } else {12741276 r10bio_t *r10_bio2 = (r10bio_t *)r10_bio->master_bio;···12781276 r10_bio = r10_bio2;12791277 }12801278 }12811281- rdev_dec_pending(conf->mirrors[d].rdev, mddev);12821279}1283128012841281/*···17501749 if (!go_faster && conf->nr_waiting)17511750 msleep_interruptible(1000);1752175117531753- bitmap_cond_end_sync(mddev->bitmap, sector_nr);17541754-17551752 /* Again, very different code for resync and recovery.17561753 * Both must result in an r10bio with a list of bios that17571754 * have bi_end_io, bi_sector, bi_bdev set,···18851886 /* resync. Schedule a read for every block at this virt offset */18861887 int count = 0;1887188818891889+ bitmap_cond_end_sync(mddev->bitmap, sector_nr);18901890+18881891 if (!bitmap_start_sync(mddev->bitmap, sector_nr,18891892 &sync_blocks, mddev->degraded) &&18901893 !conf->fullsync && !test_bit(MD_RECOVERY_REQUESTED, &mddev->recovery)) {···20112010 /* There is nowhere to write, so all non-sync20122011 * drives must be failed, so try the next chunk...20132012 */20142014- {20152015- sector_t sec = max_sector - sector_nr;20162016- sectors_skipped += sec;20132013+ if (sector_nr + max_sync < max_sector)20142014+ max_sector = sector_nr + max_sync;20152015+20162016+ sectors_skipped += (max_sector - sector_nr);20172017 chunks_skipped ++;20182018 sector_nr = max_sector;20192019 goto skipped;20202020- }20212020}2022202120232022static int run(mddev_t *mddev)
···9191 controllers (default=0)");92929393static int mpt_msi_enable_sas;9494-module_param(mpt_msi_enable_sas, int, 1);9494+module_param(mpt_msi_enable_sas, int, 0);9595MODULE_PARM_DESC(mpt_msi_enable_sas, " Enable MSI Support for SAS \9696- controllers (default=1)");9696+ controllers (default=0)");979798989999static int mpt_channel_mapping;
···12911291 if (host->cmd->data)12921292 DBG("Cannot wait for busy signal when also "12931293 "doing a data transfer");12941294- else12941294+ else if (!(host->quirks & SDHCI_QUIRK_NO_BUSY_IRQ))12951295 return;12961296+12971297+ /* The controller does not support the end-of-busy IRQ,12981298+ * fall through and take the SDHCI_INT_RESPONSE */12961299 }1297130012981301 if (intmask & SDHCI_INT_RESPONSE)
+2
drivers/mmc/host/sdhci.h
···208208#define SDHCI_QUIRK_BROKEN_TIMEOUT_VAL (1<<12)209209/* Controller has an issue with buffer bits for small transfers */210210#define SDHCI_QUIRK_BROKEN_SMALL_PIO (1<<13)211211+/* Controller does not provide transfer-complete interrupt when not busy */212212+#define SDHCI_QUIRK_NO_BUSY_IRQ (1<<14)211213212214 int irq; /* Device IRQ */213215 void __iomem * ioaddr; /* Mapped address */
···1212 DDR memories, intended for battery-operated systems.13131414config MTD_QINFO_PROBE1515+ depends on MTD_LPDDR1516 tristate "Detect flash chips by QINFO probe"1617 help1718 Device Information for LPDDR chips is offered through the Overlay
+1-1
drivers/mtd/maps/Kconfig
···491491492492config MTD_BFIN_ASYNC493493 tristate "Blackfin BF533-STAMP Flash Chip Support"494494- depends on BFIN533_STAMP && MTD_CFI494494+ depends on BFIN533_STAMP && MTD_CFI && MTD_COMPLEX_MAPPINGS495495 select MTD_PARTITIONS496496 default y497497 help
···12841284 spin_lock_irqsave(&priv->txlock, flags);1285128512861286 /* check if there is space to queue this packet */12871287- if (nr_frags > priv->num_txbdfree) {12871287+ if ((nr_frags+1) > priv->num_txbdfree) {12881288 /* no space, stop the queue */12891289 netif_stop_queue(dev);12901290 dev->stats.tx_fifo_errors++;
+1-1
drivers/net/hp-plus.c
···467467 if (this_dev != 0) break; /* only autoprobe 1st one */468468 printk(KERN_NOTICE "hp-plus.c: Presently autoprobing (not recommended) for a single card.\n");469469 }470470- dev = alloc_ei_netdev();470470+ dev = alloc_eip_netdev();471471 if (!dev)472472 break;473473 dev->irq = irq[this_dev];
+12-4
drivers/net/netxen/netxen_nic_main.c
···588588 adapter->pci_mem_read = netxen_nic_pci_mem_read_2M;589589 adapter->pci_mem_write = netxen_nic_pci_mem_write_2M;590590591591- mem_ptr0 = ioremap(mem_base, mem_len);591591+ mem_ptr0 = pci_ioremap_bar(pdev, 0);592592+ if (mem_ptr0 == NULL) {593593+ dev_err(&pdev->dev, "failed to map PCI bar 0\n");594594+ return -EIO;595595+ }596596+592597 pci_len0 = mem_len;593598 first_page_group_start = 0;594599 first_page_group_end = 0;···800795 * See if the firmware gave us a virtual-physical port mapping.801796 */802797 adapter->physical_port = adapter->portnum;803803- i = adapter->pci_read_normalize(adapter, CRB_V2P(adapter->portnum));804804- if (i != 0x55555555)805805- adapter->physical_port = i;798798+ if (adapter->fw_major < 4) {799799+ i = adapter->pci_read_normalize(adapter,800800+ CRB_V2P(adapter->portnum));801801+ if (i != 0x55555555)802802+ adapter->physical_port = i;803803+ }806804807805 adapter->flags &= ~(NETXEN_NIC_MSI_ENABLED | NETXEN_NIC_MSIX_ENABLED);808806
+112-2
drivers/net/r8169.c
···8181#define RTL8169_TX_TIMEOUT (6*HZ)8282#define RTL8169_PHY_TIMEOUT (10*HZ)83838484-#define RTL_EEPROM_SIG cpu_to_le32(0x8129)8585-#define RTL_EEPROM_SIG_MASK cpu_to_le32(0xffff)8484+#define RTL_EEPROM_SIG 0x81298685#define RTL_EEPROM_SIG_ADDR 0x00008686+#define RTL_EEPROM_MAC_ADDR 0x000787878888/* write/read MMIO register */8989#define RTL_W8(reg, val8) writeb ((val8), ioaddr + (reg))···293293 /* Cfg9346Bits */294294 Cfg9346_Lock = 0x00,295295 Cfg9346_Unlock = 0xc0,296296+ Cfg9346_Program = 0x80, /* Programming mode */297297+ Cfg9346_EECS = 0x08, /* Chip select */298298+ Cfg9346_EESK = 0x04, /* Serial data clock */299299+ Cfg9346_EEDI = 0x02, /* Data input */300300+ Cfg9346_EEDO = 0x01, /* Data output */296301297302 /* rx_mode_bits */298303 AcceptErr = 0x20,···310305 /* RxConfigBits */311306 RxCfgFIFOShift = 13,312307 RxCfgDMAShift = 8,308308+ RxCfg9356SEL = 6, /* EEPROM type: 0 = 9346, 1 = 9356 */313309314310 /* TxConfigBits */315311 TxInterFrameGapShift = 24,···1969196319701964};1971196519661966+/* Delay between EEPROM clock transitions. Force out buffered PCI writes. */19671967+#define RTL_EEPROM_DELAY() RTL_R8(Cfg9346)19681968+#define RTL_EEPROM_READ_CMD 619691969+19701970+/* read 16bit word stored in EEPROM. EEPROM is addressed by words. */19711971+static u16 rtl_eeprom_read(void __iomem *ioaddr, int addr)19721972+{19731973+ u16 result = 0;19741974+ int cmd, cmd_len, i;19751975+19761976+ /* check for EEPROM address size (in bits) */19771977+ if (RTL_R32(RxConfig) & (1 << RxCfg9356SEL)) {19781978+ /* EEPROM is 93C56 */19791979+ cmd_len = 3 + 8; /* 3 bits for command id and 8 for address */19801980+ cmd = (RTL_EEPROM_READ_CMD << 8) | (addr & 0xff);19811981+ } else {19821982+ /* EEPROM is 93C46 */19831983+ cmd_len = 3 + 6; /* 3 bits for command id and 6 for address */19841984+ cmd = (RTL_EEPROM_READ_CMD << 6) | (addr & 0x3f);19851985+ }19861986+19871987+ /* enter programming mode */19881988+ RTL_W8(Cfg9346, Cfg9346_Program | Cfg9346_EECS);19891989+ RTL_EEPROM_DELAY();19901990+19911991+ /* write command and requested address */19921992+ while (cmd_len--) {19931993+ u8 x = Cfg9346_Program | Cfg9346_EECS;19941994+19951995+ x |= (cmd & (1 << cmd_len)) ? Cfg9346_EEDI : 0;19961996+19971997+ /* write a bit */19981998+ RTL_W8(Cfg9346, x);19991999+ RTL_EEPROM_DELAY();20002000+20012001+ /* raise clock */20022002+ RTL_W8(Cfg9346, x | Cfg9346_EESK);20032003+ RTL_EEPROM_DELAY();20042004+ }20052005+20062006+ /* lower clock */20072007+ RTL_W8(Cfg9346, Cfg9346_Program | Cfg9346_EECS);20082008+ RTL_EEPROM_DELAY();20092009+20102010+ /* read back 16bit value */20112011+ for (i = 16; i > 0; i--) {20122012+ /* raise clock */20132013+ RTL_W8(Cfg9346, Cfg9346_Program | Cfg9346_EECS | Cfg9346_EESK);20142014+ RTL_EEPROM_DELAY();20152015+20162016+ result <<= 1;20172017+ result |= (RTL_R8(Cfg9346) & Cfg9346_EEDO) ? 1 : 0;20182018+20192019+ /* lower clock */20202020+ RTL_W8(Cfg9346, Cfg9346_Program | Cfg9346_EECS);20212021+ RTL_EEPROM_DELAY();20222022+ }20232023+20242024+ RTL_W8(Cfg9346, Cfg9346_Program);20252025+ /* leave programming mode */20262026+ RTL_W8(Cfg9346, Cfg9346_Lock);20272027+20282028+ return result;20292029+}20302030+20312031+static void rtl_init_mac_address(struct rtl8169_private *tp,20322032+ void __iomem *ioaddr)20332033+{20342034+ struct pci_dev *pdev = tp->pci_dev;20352035+ u16 x;20362036+ u8 mac[8];20372037+20382038+ /* read EEPROM signature */20392039+ x = rtl_eeprom_read(ioaddr, RTL_EEPROM_SIG_ADDR);20402040+20412041+ if (x != RTL_EEPROM_SIG) {20422042+ dev_info(&pdev->dev, "Missing EEPROM signature: %04x\n", x);20432043+ return;20442044+ }20452045+20462046+ /* read MAC address */20472047+ x = rtl_eeprom_read(ioaddr, RTL_EEPROM_MAC_ADDR);20482048+ mac[0] = x & 0xff;20492049+ mac[1] = x >> 8;20502050+ x = rtl_eeprom_read(ioaddr, RTL_EEPROM_MAC_ADDR + 1);20512051+ mac[2] = x & 0xff;20522052+ mac[3] = x >> 8;20532053+ x = rtl_eeprom_read(ioaddr, RTL_EEPROM_MAC_ADDR + 2);20542054+ mac[4] = x & 0xff;20552055+ mac[5] = x >> 8;20562056+20572057+ if (netif_msg_probe(tp)) {20582058+ DECLARE_MAC_BUF(buf);20592059+20602060+ dev_info(&pdev->dev, "MAC address found in EEPROM: %s\n",20612061+ print_mac(buf, mac));20622062+ }20632063+20642064+ if (is_valid_ether_addr(mac))20652065+ rtl_rar_set(tp, mac);20662066+}20672067+19722068static int __devinit19732069rtl8169_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)19742070{···22482140 spin_lock_init(&tp->lock);2249214122502142 tp->mmio_addr = ioaddr;21432143+21442144+ rtl_init_mac_address(tp, ioaddr);2251214522522146 /* Get MAC address */22532147 for (i = 0; i < MAC_ADDR_LEN; i++)
···15841584 */15851585#define AMD_813X_MISC 0x4015861586#define AMD_813X_NOIOAMODE (1<<0)15871587+#define AMD_813X_REV_B2 0x131587158815881589static void quirk_disable_amd_813x_boot_interrupt(struct pci_dev *dev)15891590{15901591 u32 pci_config_dword;1591159215921593 if (noioapicquirk)15941594+ return;15951595+ if (dev->revision == AMD_813X_REV_B2)15931596 return;1594159715951598 pci_read_config_dword(dev, AMD_813X_MISC, &pci_config_dword);···19841981DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_SERVERWORKS, PCI_DEVICE_ID_SERVERWORKS_HT2000_PCIE,19851982 quirk_msi_ht_cap);1986198319871987-19881984/* The nVidia CK804 chipset may have 2 HT MSI mappings.19891985 * MSI are supported if the MSI capability set in any of these mappings.19901986 */···20342032 PCI_DEVICE_ID_SERVERWORKS_HT1000_PXB,20352033 ht_enable_msi_mapping);2036203420352035+DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_8132_BRIDGE,20362036+ ht_enable_msi_mapping);20372037+20372038/* The P5N32-SLI Premium motherboard from Asus has a problem with msi20382039 * for the MCP55 NIC. It is not yet determined whether the msi problem20392040 * also affects other devices. As for now, turn off msi for this device.···20532048 PCI_DEVICE_ID_NVIDIA_NVENET_15,20542049 nvenet_msi_disable);2055205020512051+static void __devinit nv_ht_enable_msi_mapping(struct pci_dev *dev)20522052+{20532053+ struct pci_dev *host_bridge;20542054+ int pos;20552055+ int i, dev_no;20562056+ int found = 0;20572057+20582058+ dev_no = dev->devfn >> 3;20592059+ for (i = dev_no; i >= 0; i--) {20602060+ host_bridge = pci_get_slot(dev->bus, PCI_DEVFN(i, 0));20612061+ if (!host_bridge)20622062+ continue;20632063+20642064+ pos = pci_find_ht_capability(host_bridge, HT_CAPTYPE_SLAVE);20652065+ if (pos != 0) {20662066+ found = 1;20672067+ break;20682068+ }20692069+ pci_dev_put(host_bridge);20702070+ }20712071+20722072+ if (!found)20732073+ return;20742074+20752075+ /* root did that ! */20762076+ if (msi_ht_cap_enabled(host_bridge))20772077+ goto out;20782078+20792079+ ht_enable_msi_mapping(dev);20802080+20812081+out:20822082+ pci_dev_put(host_bridge);20832083+}20842084+20852085+static void __devinit ht_disable_msi_mapping(struct pci_dev *dev)20862086+{20872087+ int pos, ttl = 48;20882088+20892089+ pos = pci_find_ht_capability(dev, HT_CAPTYPE_MSI_MAPPING);20902090+ while (pos && ttl--) {20912091+ u8 flags;20922092+20932093+ if (pci_read_config_byte(dev, pos + HT_MSI_FLAGS,20942094+ &flags) == 0) {20952095+ dev_info(&dev->dev, "Enabling HT MSI Mapping\n");20962096+20972097+ pci_write_config_byte(dev, pos + HT_MSI_FLAGS,20982098+ flags & ~HT_MSI_FLAGS_ENABLE);20992099+ }21002100+ pos = pci_find_next_ht_capability(dev, pos,21012101+ HT_CAPTYPE_MSI_MAPPING);21022102+ }21032103+}21042104+21052105+static int __devinit ht_check_msi_mapping(struct pci_dev *dev)21062106+{21072107+ int pos, ttl = 48;21082108+ int found = 0;21092109+21102110+ /* check if there is HT MSI cap or enabled on this device */21112111+ pos = pci_find_ht_capability(dev, HT_CAPTYPE_MSI_MAPPING);21122112+ while (pos && ttl--) {21132113+ u8 flags;21142114+21152115+ if (found < 1)21162116+ found = 1;21172117+ if (pci_read_config_byte(dev, pos + HT_MSI_FLAGS,21182118+ &flags) == 0) {21192119+ if (flags & HT_MSI_FLAGS_ENABLE) {21202120+ if (found < 2) {21212121+ found = 2;21222122+ break;21232123+ }21242124+ }21252125+ }21262126+ pos = pci_find_next_ht_capability(dev, pos,21272127+ HT_CAPTYPE_MSI_MAPPING);21282128+ }21292129+21302130+ return found;21312131+}21322132+20562133static void __devinit nv_msi_ht_cap_quirk(struct pci_dev *dev)20572134{20582135 struct pci_dev *host_bridge;20592059- int pos, ttl = 48;21362136+ int pos;21372137+ int found;21382138+21392139+ /* check if there is HT MSI cap or enabled on this device */21402140+ found = ht_check_msi_mapping(dev);21412141+21422142+ /* no HT MSI CAP */21432143+ if (found == 0)21442144+ return;2060214520612146 /*20622147 * HT MSI mapping should be disabled on devices that are below···21622067 pos = pci_find_ht_capability(host_bridge, HT_CAPTYPE_SLAVE);21632068 if (pos != 0) {21642069 /* Host bridge is to HT */21652165- ht_enable_msi_mapping(dev);20702070+ if (found == 1) {20712071+ /* it is not enabled, try to enable it */20722072+ nv_ht_enable_msi_mapping(dev);20732073+ }21662074 return;21672075 }2168207621692169- /* Host bridge is not to HT, disable HT MSI mapping on this device */21702170- pos = pci_find_ht_capability(dev, HT_CAPTYPE_MSI_MAPPING);21712171- while (pos && ttl--) {21722172- u8 flags;20772077+ /* HT MSI is not enabled */20782078+ if (found == 1)20792079+ return;2173208021742174- if (pci_read_config_byte(dev, pos + HT_MSI_FLAGS,21752175- &flags) == 0) {21762176- dev_info(&dev->dev, "Disabling HT MSI mapping");21772177- pci_write_config_byte(dev, pos + HT_MSI_FLAGS,21782178- flags & ~HT_MSI_FLAGS_ENABLE);21792179- }21802180- pos = pci_find_next_ht_capability(dev, pos,21812181- HT_CAPTYPE_MSI_MAPPING);21822182- }20812081+ /* Host bridge is not to HT, disable HT MSI mapping on this device */20822082+ ht_disable_msi_mapping(dev);21832083}21842084DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_NVIDIA, PCI_ANY_ID, nv_msi_ht_cap_quirk);21852085DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_AL, PCI_ANY_ID, nv_msi_ht_cap_quirk);
+21
drivers/scsi/cxgb3i/cxgb3i.h
···2020#include <linux/list.h>2121#include <linux/netdevice.h>2222#include <linux/scatterlist.h>2323+#include <linux/skbuff.h>2324#include <scsi/libiscsi_tcp.h>24252526/* from cxgb3 LLD */···112111 struct s3_conn *c3cn;113112 struct cxgb3i_hba *hba;114113 struct cxgb3i_conn *cconn;114114+};115115+116116+/**117117+ * struct cxgb3i_task_data - private iscsi task data118118+ *119119+ * @nr_frags: # of coalesced page frags (from scsi sgl)120120+ * @frags: coalesced page frags (from scsi sgl)121121+ * @skb: tx pdu skb122122+ * @offset: data offset for the next pdu123123+ * @count: max. possible pdu payload124124+ * @sgoffset: offset to the first sg entry for a given offset125125+ */126126+#define MAX_PDU_FRAGS ((ULP2_MAX_PDU_PAYLOAD + 512 - 1) / 512)127127+struct cxgb3i_task_data {128128+ unsigned short nr_frags;129129+ skb_frag_t frags[MAX_PDU_FRAGS];130130+ struct sk_buff *skb;131131+ unsigned int offset;132132+ unsigned int count;133133+ unsigned int sgoffset;115134};116135117136int cxgb3i_iscsi_init(void);
+11-8
drivers/scsi/cxgb3i/cxgb3i_ddp.c
···639639 write_unlock(&cxgb3i_ddp_rwlock);640640641641 ddp_log_info("nppods %u (0x%x ~ 0x%x), bits %u, mask 0x%x,0x%x "642642- "pkt %u,%u.\n",642642+ "pkt %u/%u, %u/%u.\n",643643 ppmax, ddp->llimit, ddp->ulimit, ddp->idx_bits,644644 ddp->idx_mask, ddp->rsvd_tag_mask,645645- ddp->max_txsz, ddp->max_rxsz);645645+ ddp->max_txsz, uinfo.max_txsz,646646+ ddp->max_rxsz, uinfo.max_rxsz);646647 return 0;647648648649free_ddp_map:···655654 * cxgb3i_adapter_ddp_init - initialize the adapter's ddp resource656655 * @tdev: t3cdev adapter657656 * @tformat: tag format658658- * @txsz: max tx pkt size, filled in by this func.659659- * @rxsz: max rx pkt size, filled in by this func.657657+ * @txsz: max tx pdu payload size, filled in by this func.658658+ * @rxsz: max rx pdu payload size, filled in by this func.660659 * initialize the ddp pagepod manager for a given adapter if needed and661660 * setup the tag format for a given iscsi entity662661 */···686685 tformat->sw_bits, tformat->rsvd_bits,687686 tformat->rsvd_shift, tformat->rsvd_mask);688687689689- *txsz = ddp->max_txsz;690690- *rxsz = ddp->max_rxsz;691691- ddp_log_info("ddp max pkt size: %u, %u.\n",692692- ddp->max_txsz, ddp->max_rxsz);688688+ *txsz = min_t(unsigned int, ULP2_MAX_PDU_PAYLOAD,689689+ ddp->max_txsz - ISCSI_PDU_NONPAYLOAD_LEN);690690+ *rxsz = min_t(unsigned int, ULP2_MAX_PDU_PAYLOAD,691691+ ddp->max_rxsz - ISCSI_PDU_NONPAYLOAD_LEN);692692+ ddp_log_info("max payload size: %u/%u, %u/%u.\n",693693+ *txsz, ddp->max_txsz, *rxsz, ddp->max_rxsz);693694 return 0;694695}695696EXPORT_SYMBOL_GPL(cxgb3i_adapter_ddp_init);
+4-1
drivers/scsi/cxgb3i/cxgb3i_ddp.h
···1313#ifndef __CXGB3I_ULP2_DDP_H__1414#define __CXGB3I_ULP2_DDP_H__15151616+#include <linux/vmalloc.h>1717+1618/**1719 * struct cxgb3i_tag_format - cxgb3i ulp tag format for an iscsi entity1820 *···8785 struct sk_buff **gl_skb;8886};89878888+#define ISCSI_PDU_NONPAYLOAD_LEN 312 /* bhs(48) + ahs(256) + digest(8) */9089#define ULP2_MAX_PKT_SIZE 162249191-#define ULP2_MAX_PDU_PAYLOAD (ULP2_MAX_PKT_SIZE - ISCSI_PDU_NONPAYLOAD_MAX)9090+#define ULP2_MAX_PDU_PAYLOAD (ULP2_MAX_PKT_SIZE - ISCSI_PDU_NONPAYLOAD_LEN)9291#define PPOD_PAGES_MAX 49392#define PPOD_PAGES_SHIFT 2 /* 4 pages per pod */9493
···10401040 action = ACTION_FAIL;10411041 break;10421042 case ABORTED_COMMAND:10431043+ action = ACTION_FAIL;10431044 if (sshdr.asc == 0x10) { /* DIF */10441045 description = "Target Data Integrity Failure";10451045- action = ACTION_FAIL;10461046 error = -EILSEQ;10471047- } else10481048- action = ACTION_RETRY;10471047+ }10491048 break;10501049 case NOT_READY:10511050 /* If the device is in the process of becoming
+7
drivers/scsi/sd.c
···107107static void sd_print_sense_hdr(struct scsi_disk *, struct scsi_sense_hdr *);108108static void sd_print_result(struct scsi_disk *, int);109109110110+static DEFINE_SPINLOCK(sd_index_lock);110111static DEFINE_IDA(sd_index_ida);111112112113/* This semaphore is used to mediate the 0->1 reference get in the···19151914 if (!ida_pre_get(&sd_index_ida, GFP_KERNEL))19161915 goto out_put;1917191619171917+ spin_lock(&sd_index_lock);19181918 error = ida_get_new(&sd_index_ida, &index);19191919+ spin_unlock(&sd_index_lock);19191920 } while (error == -EAGAIN);1920192119211922 if (error)···19391936 return 0;1940193719411938 out_free_index:19391939+ spin_lock(&sd_index_lock);19421940 ida_remove(&sd_index_ida, index);19411941+ spin_unlock(&sd_index_lock);19431942 out_put:19441943 put_disk(gd);19451944 out_free:···19911986 struct scsi_disk *sdkp = to_scsi_disk(dev);19921987 struct gendisk *disk = sdkp->disk;1993198819891989+ spin_lock(&sd_index_lock);19941990 ida_remove(&sd_index_ida, sdkp->index);19911991+ spin_unlock(&sd_index_lock);1995199219961993 disk->private_data = NULL;19971994 put_disk(disk);
···21642164 if (scan_timer.function != NULL)21652165 del_timer(&scan_timer);2166216621672167- if (keypad_enabled)21682168- misc_deregister(&keypad_dev);21672167+ if (pprt != NULL) {21682168+ if (keypad_enabled)21692169+ misc_deregister(&keypad_dev);2169217021702170- if (lcd_enabled) {21712171- panel_lcd_print("\x0cLCD driver " PANEL_VERSION21722172- "\nunloaded.\x1b[Lc\x1b[Lb\x1b[L-");21732173- misc_deregister(&lcd_dev);21712171+ if (lcd_enabled) {21722172+ panel_lcd_print("\x0cLCD driver " PANEL_VERSION21732173+ "\nunloaded.\x1b[Lc\x1b[Lb\x1b[L-");21742174+ misc_deregister(&lcd_dev);21752175+ }21762176+21772177+ /* TODO: free all input signals */21782178+ parport_release(pprt);21792179+ parport_unregister_device(pprt);21742180 }21752175-21762176- /* TODO: free all input signals */21772177-21782178- parport_release(pprt);21792179- parport_unregister_device(pprt);21802181 parport_unregister_driver(&panel_driver);21812182}21822183
+1
drivers/staging/rtl8187se/Kconfig
···11config RTL8187SE22 tristate "RealTek RTL8187SE Wireless LAN NIC driver"33 depends on PCI44+ depends on WIRELESS_EXT && COMPAT_NET_DEV_OPS45 default N56 ---help---
···319319 struct usb_device *udev = interface_to_usbdev(intf);320320 struct wbsoft_priv *priv;321321 struct ieee80211_hw *dev;322322- int err;322322+ int nr, err;323323324324 usb_get_dev(udev);325325326326 // 20060630.2 Check the device if it already be opened327327- err = usb_control_msg(udev, usb_rcvctrlpipe( udev, 0 ),328328- 0x01, USB_TYPE_VENDOR|USB_RECIP_DEVICE|USB_DIR_IN,329329- 0x0, 0x400, <mp, 4, HZ*100 );330330- if (err)327327+ nr = usb_control_msg(udev, usb_rcvctrlpipe( udev, 0 ),328328+ 0x01, USB_TYPE_VENDOR|USB_RECIP_DEVICE|USB_DIR_IN,329329+ 0x0, 0x400, <mp, 4, HZ*100 );330330+ if (nr < 0) {331331+ err = nr;331332 goto error;333333+ }332334333335 ltmp = cpu_to_le32(ltmp);334336 if (ltmp) { // Is already initialized?···339337 }340338341339 dev = ieee80211_alloc_hw(sizeof(*priv), &wbsoft_ops);342342- if (!dev)340340+ if (!dev) {341341+ err = -ENOMEM;343342 goto error;343343+ }344344345345 priv = dev->priv;346346···373369 }374370375371 dev->extra_tx_headroom = 12; /* FIXME */376376- dev->flags = 0;372372+ dev->flags = IEEE80211_HW_SIGNAL_UNSPEC;373373+ dev->wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION);377374378375 dev->channel_change_time = 1000;376376+ dev->max_signal = 100;379377 dev->queues = 1;380378381379 dev->wiphy->bands[IEEE80211_BAND_2GHZ] = &wbsoft_band_2GHz;
+9
drivers/usb/class/cdc-acm.c
···13761376 { USB_DEVICE(0x0572, 0x1324), /* Conexant USB MODEM RD02-D400 */13771377 .driver_info = NO_UNION_NORMAL, /* has no union descriptor */13781378 },13791379+ { USB_DEVICE(0x22b8, 0x6425), /* Motorola MOTOMAGX phones */13801380+ },13811381+ { USB_DEVICE(0x0572, 0x1329), /* Hummingbird huc56s (Conexant) */13821382+ .driver_info = NO_UNION_NORMAL, /* union descriptor misplaced on13831383+ data interface instead of13841384+ communications interface.13851385+ Maybe we should define a new13861386+ quirk for this. */13871387+ },1379138813801389 /* control interfaces with various AT-command sets */13811390 { USB_INTERFACE_INFO(USB_CLASS_COMM, USB_CDC_SUBCLASS_ACM,
+8-3
drivers/usb/core/message.c
···653653 if (result <= 0 && result != -ETIMEDOUT)654654 continue;655655 if (result > 1 && ((u8 *)buf)[1] != type) {656656- result = -EPROTO;656656+ result = -ENODATA;657657 continue;658658 }659659 break;···696696 USB_REQ_GET_DESCRIPTOR, USB_DIR_IN,697697 (USB_DT_STRING << 8) + index, langid, buf, size,698698 USB_CTRL_GET_TIMEOUT);699699- if (!(result == 0 || result == -EPIPE))700700- break;699699+ if (result == 0 || result == -EPIPE)700700+ continue;701701+ if (result > 1 && ((u8 *) buf)[1] != USB_DT_STRING) {702702+ result = -ENODATA;703703+ continue;704704+ }705705+ break;701706 }702707 return result;703708}
+1
drivers/usb/gadget/Kconfig
···191191 boolean "OMAP USB Device Controller"192192 depends on ARCH_OMAP193193 select ISP1301_OMAP if MACH_OMAP_H2 || MACH_OMAP_H3 || MACH_OMAP_H4_OTG194194+ select USB_OTG_UTILS if ARCH_OMAP194195 help195196 Many Texas Instruments OMAP processors have flexible full196197 speed USB device controllers, with support for up to 30
+2-2
drivers/usb/gadget/f_obex.c
···366366 f->hs_descriptors = usb_copy_descriptors(hs_function);367367368368 obex->hs.obex_in = usb_find_endpoint(hs_function,369369- f->descriptors, &obex_hs_ep_in_desc);369369+ f->hs_descriptors, &obex_hs_ep_in_desc);370370 obex->hs.obex_out = usb_find_endpoint(hs_function,371371- f->descriptors, &obex_hs_ep_out_desc);371371+ f->hs_descriptors, &obex_hs_ep_out_desc);372372 }373373374374 /* Avoid letting this gadget enumerate until the userspace
+5-1
drivers/usb/gadget/file_storage.c
···38793879 mod_data.protocol_type = USB_SC_SCSI;38803880 mod_data.protocol_name = "Transparent SCSI";3881388138823882- if (gadget_is_sh(fsg->gadget))38823882+ /* Some peripheral controllers are known not to be able to38833883+ * halt bulk endpoints correctly. If one of them is present,38843884+ * disable stalls.38853885+ */38863886+ if (gadget_is_sh(fsg->gadget) || gadget_is_at91(fsg->gadget))38833887 mod_data.can_stall = 0;3884388838853889 if (mod_data.release == 0xffff) { // Parameter wasn't set
···485485 * periodic_size can shrink by USBCMD update if hcc_params allows.486486 */487487 ehci->periodic_size = DEFAULT_I_TDPS;488488+ INIT_LIST_HEAD(&ehci->cached_itd_list);488489 if ((retval = ehci_mem_init(ehci, GFP_KERNEL)) < 0)489490 return retval;490491···498497499498 ehci->reclaim = NULL;500499 ehci->next_uframe = -1;500500+ ehci->clock_frame = -1;501501502502 /*503503 * dedicate a qh for the async ring head, since we couldn't unlink
···1004100410051005 is_in = (stream->bEndpointAddress & USB_DIR_IN) ? 0x10 : 0;10061006 stream->bEndpointAddress &= 0x0f;10071007- stream->ep->hcpriv = NULL;10071007+ if (stream->ep)10081008+ stream->ep->hcpriv = NULL;1008100910091010 if (stream->rescheduled) {10101011 ehci_info (ehci, "ep%d%s-iso rescheduled "···16541653 (stream->bEndpointAddress & USB_DIR_IN) ? "in" : "out");16551654 }16561655 iso_stream_put (ehci, stream);16571657- /* OK to recycle this ITD now that its completion callback ran. */16561656+16581657done:16591658 usb_put_urb(urb);16601659 itd->urb = NULL;16611661- itd->stream = NULL;16621662- list_move(&itd->itd_list, &stream->free_list);16631663- iso_stream_put(ehci, stream);16641664-16601660+ if (ehci->clock_frame != itd->frame || itd->index[7] != -1) {16611661+ /* OK to recycle this ITD now. */16621662+ itd->stream = NULL;16631663+ list_move(&itd->itd_list, &stream->free_list);16641664+ iso_stream_put(ehci, stream);16651665+ } else {16661666+ /* HW might remember this ITD, so we can't recycle it yet.16671667+ * Move it to a safe place until a new frame starts.16681668+ */16691669+ list_move(&itd->itd_list, &ehci->cached_itd_list);16701670+ if (stream->refcount == 2) {16711671+ /* If iso_stream_put() were called here, stream16721672+ * would be freed. Instead, just prevent reuse.16731673+ */16741674+ stream->ep->hcpriv = NULL;16751675+ stream->ep = NULL;16761676+ }16771677+ }16651678 return retval;16661679}16671680···2116210121172102/*-------------------------------------------------------------------------*/2118210321042104+static void free_cached_itd_list(struct ehci_hcd *ehci)21052105+{21062106+ struct ehci_itd *itd, *n;21072107+21082108+ list_for_each_entry_safe(itd, n, &ehci->cached_itd_list, itd_list) {21092109+ struct ehci_iso_stream *stream = itd->stream;21102110+ itd->stream = NULL;21112111+ list_move(&itd->itd_list, &stream->free_list);21122112+ iso_stream_put(ehci, stream);21132113+ }21142114+}21152115+21162116+/*-------------------------------------------------------------------------*/21172117+21192118static void21202119scan_periodic (struct ehci_hcd *ehci)21212120{···21442115 * Touches as few pages as possible: cache-friendly.21452116 */21462117 now_uframe = ehci->next_uframe;21472147- if (HC_IS_RUNNING (ehci_to_hcd(ehci)->state))21182118+ if (HC_IS_RUNNING(ehci_to_hcd(ehci)->state)) {21482119 clock = ehci_readl(ehci, &ehci->regs->frame_index);21492149- else21202120+ clock_frame = (clock >> 3) % ehci->periodic_size;21212121+ } else {21502122 clock = now_uframe + mod - 1;21232123+ clock_frame = -1;21242124+ }21252125+ if (ehci->clock_frame != clock_frame) {21262126+ free_cached_itd_list(ehci);21272127+ ehci->clock_frame = clock_frame;21282128+ }21512129 clock %= mod;21522130 clock_frame = clock >> 3;21532131···23132277 /* rescan the rest of this frame, then ... */23142278 clock = now;23152279 clock_frame = clock >> 3;22802280+ if (ehci->clock_frame != clock_frame) {22812281+ free_cached_itd_list(ehci);22822282+ ehci->clock_frame = clock_frame;22832283+ }23162284 } else {23172285 now_uframe++;23182286 now_uframe %= mod;
+6
drivers/usb/host/ehci.h
···8787 int next_uframe; /* scan periodic, start here */8888 unsigned periodic_sched; /* periodic activity count */89899090+ /* list of itds completed while clock_frame was still active */9191+ struct list_head cached_itd_list;9292+ unsigned clock_frame;9393+9094 /* per root hub port */9195 unsigned long reset_done [EHCI_MAX_ROOT_PORTS];9296···223219 mod_timer(&ehci->watchdog, t + jiffies);224220 }225221}222222+223223+static void free_cached_itd_list(struct ehci_hcd *ehci);226224227225/*-------------------------------------------------------------------------*/228226
+4-11
drivers/usb/musb/davinci.c
···377377 u32 revision;378378379379 musb->mregs += DAVINCI_BASE_OFFSET;380380-#if 0381381- /* REVISIT there's something odd about clocking, this382382- * didn't appear do the job ...383383- */384384- musb->clock = clk_get(pDevice, "usb");385385- if (IS_ERR(musb->clock))386386- return PTR_ERR(musb->clock);387380388388- status = clk_enable(musb->clock);389389- if (status < 0)390390- return -ENODEV;391391-#endif381381+ clk_enable(musb->clock);392382393383 /* returns zero if e.g. not clocked */394384 revision = musb_readl(tibase, DAVINCI_USB_VERSION_REG);···443453 }444454445455 phy_off();456456+457457+ clk_disable(musb->clock);458458+446459 return 0;447460}
+7-6
drivers/usb/musb/musb_core.c
···115115116116117117unsigned musb_debug;118118-module_param(musb_debug, uint, S_IRUGO | S_IWUSR);118118+module_param_named(debug, musb_debug, uint, S_IRUGO | S_IWUSR);119119MODULE_PARM_DESC(debug, "Debug message level. Default = 0");120120121121#define DRIVER_AUTHOR "Mentor Graphics, Texas Instruments, Nokia"···767767#ifdef CONFIG_USB_MUSB_HDRC_HCD768768 case OTG_STATE_A_HOST:769769 case OTG_STATE_A_SUSPEND:770770+ usb_hcd_resume_root_hub(musb_to_hcd(musb));770771 musb_root_disconnect(musb);771772 if (musb->a_wait_bcon != 0)772773 musb_platform_try_idle(musb, jiffies···18161815#ifdef CONFIG_SYSFS18171816 device_remove_file(musb->controller, &dev_attr_mode);18181817 device_remove_file(musb->controller, &dev_attr_vbus);18191819-#ifdef CONFIG_USB_MUSB_OTG18181818+#ifdef CONFIG_USB_GADGET_MUSB_HDRC18201819 device_remove_file(musb->controller, &dev_attr_srp);18211820#endif18221821#endif···20642063#ifdef CONFIG_SYSFS20652064 device_remove_file(musb->controller, &dev_attr_mode);20662065 device_remove_file(musb->controller, &dev_attr_vbus);20672067-#ifdef CONFIG_USB_MUSB_OTG20662066+#ifdef CONFIG_USB_GADGET_MUSB_HDRC20682067 device_remove_file(musb->controller, &dev_attr_srp);20692068#endif20702069#endif···22442243 return platform_driver_probe(&musb_driver, musb_probe);22452244}2246224522472247-/* make us init after usbcore and before usb22482248- * gadget and host-side drivers start to register22462246+/* make us init after usbcore and i2c (transceivers, regulators, etc)22472247+ * and before usb gadget and host-side drivers start to register22492248 */22502250-subsys_initcall(musb_init);22492249+fs_initcall(musb_init);2251225022522251static void __exit musb_cleanup(void)22532252{
···907907 "Genesys Logic",908908 "USB to IDE Optical",909909 US_SC_DEVICE, US_PR_DEVICE, NULL,910910- US_FL_GO_SLOW | US_FL_MAX_SECTORS_64 ),910910+ US_FL_GO_SLOW | US_FL_MAX_SECTORS_64 | US_FL_IGNORE_RESIDUE ),911911912912UNUSUAL_DEV( 0x05e3, 0x0702, 0x0000, 0xffff,913913 "Genesys Logic",914914 "USB to IDE Disk",915915 US_SC_DEVICE, US_PR_DEVICE, NULL,916916- US_FL_GO_SLOW | US_FL_MAX_SECTORS_64 ),916916+ US_FL_GO_SLOW | US_FL_MAX_SECTORS_64 | US_FL_IGNORE_RESIDUE ),917917918918/* Reported by Ben Efros <ben@pc-doctor.com> */919919UNUSUAL_DEV( 0x05e3, 0x0723, 0x9451, 0x9451,
+6
drivers/w1/slaves/Kconfig
···1616 Say Y here if you want to connect 1-wire1717 simple 64bit memory rom(ds2401/ds2411/ds1990*) to your wire.18181919+config W1_SLAVE_DS24312020+ tristate "1kb EEPROM family support (DS2431)"2121+ help2222+ Say Y here if you want to use a 1-wire2323+ 1kb EEPROM family device (DS2431)2424+1925config W1_SLAVE_DS24332026 tristate "4kb EEPROM family support (DS2433)"2127 help
···156156 */157157static int w1_f23_write(struct w1_slave *sl, int addr, int len, const u8 *data)158158{159159+#ifdef CONFIG_W1_SLAVE_DS2433_CRC160160+ struct w1_f23_data *f23 = sl->family_data;161161+#endif159162 u8 wrbuf[4];160163 u8 rdbuf[W1_PAGE_SIZE + 3];161164 u8 es = (addr + len - 1) & 0x1f;···199196200197 /* Reset the bus to wake up the EEPROM (this may not be needed) */201198 w1_reset_bus(sl->master);202202-199199+#ifdef CONFIG_W1_SLAVE_DS2433_CRC200200+ f23->validcrc &= ~(1 << (addr >> W1_PAGE_BITS));201201+#endif203202 return 0;204203}205204
+4-2
fs/Makefile
···6969# Do not add any filesystems before this line7070obj-$(CONFIG_REISERFS_FS) += reiserfs/7171obj-$(CONFIG_EXT3_FS) += ext3/ # Before ext2 so root fs can be ext37272-obj-$(CONFIG_EXT4_FS) += ext4/ # Before ext2 so root fs can be ext47272+obj-$(CONFIG_EXT2_FS) += ext2/7373+# We place ext4 after ext2 so plain ext2 root fs's are mounted using ext27474+# unless explicitly requested by rootfstype7575+obj-$(CONFIG_EXT4_FS) += ext4/7376obj-$(CONFIG_JBD) += jbd/7477obj-$(CONFIG_JBD2) += jbd2/7575-obj-$(CONFIG_EXT2_FS) += ext2/7678obj-$(CONFIG_CRAMFS) += cramfs/7779obj-$(CONFIG_SQUASHFS) += squashfs/7880obj-y += ramfs/
+1-1
fs/bio.c
···302302struct bio *bio_alloc_bioset(gfp_t gfp_mask, int nr_iovecs, struct bio_set *bs)303303{304304 struct bio *bio = NULL;305305- void *p;305305+ void *uninitialized_var(p);306306307307 if (bs) {308308 p = mempool_alloc(bs->bio_pool, gfp_mask);
+8
fs/btrfs/btrfs_inode.h
···6666 */6767 struct list_head delalloc_inodes;68686969+ /* the space_info for where this inode's data allocations are done */7070+ struct btrfs_space_info *space_info;7171+6972 /* full 64 bit generation number, struct vfs_inode doesn't have a big7073 * enough field for this.7174 */···9693 * real block usage of the file9794 */9895 u64 delalloc_bytes;9696+9797+ /* total number of bytes that may be used for this inode for9898+ * delalloc9999+ */100100+ u64 reserved_bytes;99101100102 /*101103 * the size of the file stored in the metadata on disk. data=ordered
+31-9
fs/btrfs/ctree.h
···596596597597struct btrfs_space_info {598598 u64 flags;599599- u64 total_bytes;600600- u64 bytes_used;601601- u64 bytes_pinned;602602- u64 bytes_reserved;603603- u64 bytes_readonly;604604- int full;605605- int force_alloc;599599+600600+ u64 total_bytes; /* total bytes in the space */601601+ u64 bytes_used; /* total bytes used on disk */602602+ u64 bytes_pinned; /* total bytes pinned, will be freed when the603603+ transaction finishes */604604+ u64 bytes_reserved; /* total bytes the allocator has reserved for605605+ current allocations */606606+ u64 bytes_readonly; /* total bytes that are read only */607607+608608+ /* delalloc accounting */609609+ u64 bytes_delalloc; /* number of bytes reserved for allocation,610610+ this space is not necessarily reserved yet611611+ by the allocator */612612+ u64 bytes_may_use; /* number of bytes that may be used for613613+ delalloc */614614+615615+ int full; /* indicates that we cannot allocate any more616616+ chunks for this space */617617+ int force_alloc; /* set if we need to force a chunk alloc for618618+ this space */619619+606620 struct list_head list;607621608622 /* for block groups in our same type */···17961782int btrfs_cleanup_reloc_trees(struct btrfs_root *root);17971783int btrfs_reloc_clone_csums(struct inode *inode, u64 file_pos, u64 len);17981784u64 btrfs_reduce_alloc_profile(struct btrfs_root *root, u64 flags);17851785+void btrfs_set_inode_space_info(struct btrfs_root *root, struct inode *ionde);17861786+int btrfs_check_metadata_free_space(struct btrfs_root *root);17871787+int btrfs_check_data_free_space(struct btrfs_root *root, struct inode *inode,17881788+ u64 bytes);17891789+void btrfs_free_reserved_data_space(struct btrfs_root *root,17901790+ struct inode *inode, u64 bytes);17911791+void btrfs_delalloc_reserve_space(struct btrfs_root *root, struct inode *inode,17921792+ u64 bytes);17931793+void btrfs_delalloc_free_space(struct btrfs_root *root, struct inode *inode,17941794+ u64 bytes);17991795/* ctree.c */18001796int btrfs_previous_item(struct btrfs_root *root,18011797 struct btrfs_path *path, u64 min_objectid,···20512027unsigned long btrfs_force_ra(struct address_space *mapping,20522028 struct file_ra_state *ra, struct file *file,20532029 pgoff_t offset, pgoff_t last_index);20542054-int btrfs_check_free_space(struct btrfs_root *root, u64 num_required,20552055- int for_del);20562030int btrfs_page_mkwrite(struct vm_area_struct *vma, struct page *page);20572031int btrfs_readpage(struct file *file, struct page *page);20582032void btrfs_delete_inode(struct inode *inode);
+237-15
fs/btrfs/extent-tree.c
···6060 u64 bytenr, u64 num_bytes, int alloc,6161 int mark_free);62626363+static int do_chunk_alloc(struct btrfs_trans_handle *trans,6464+ struct btrfs_root *extent_root, u64 alloc_bytes,6565+ u64 flags, int force);6666+6367static int block_group_bits(struct btrfs_block_group_cache *cache, u64 bits)6468{6569 return (cache->flags & bits) == bits;···19131909 found->bytes_pinned = 0;19141910 found->bytes_reserved = 0;19151911 found->bytes_readonly = 0;19121912+ found->bytes_delalloc = 0;19161913 found->full = 0;19171914 found->force_alloc = 0;19181915 *space_info = found;···19751970 (flags & BTRFS_BLOCK_GROUP_DUP)))19761971 flags &= ~BTRFS_BLOCK_GROUP_RAID0;19771972 return flags;19731973+}19741974+19751975+static u64 btrfs_get_alloc_profile(struct btrfs_root *root, u64 data)19761976+{19771977+ struct btrfs_fs_info *info = root->fs_info;19781978+ u64 alloc_profile;19791979+19801980+ if (data) {19811981+ alloc_profile = info->avail_data_alloc_bits &19821982+ info->data_alloc_profile;19831983+ data = BTRFS_BLOCK_GROUP_DATA | alloc_profile;19841984+ } else if (root == root->fs_info->chunk_root) {19851985+ alloc_profile = info->avail_system_alloc_bits &19861986+ info->system_alloc_profile;19871987+ data = BTRFS_BLOCK_GROUP_SYSTEM | alloc_profile;19881988+ } else {19891989+ alloc_profile = info->avail_metadata_alloc_bits &19901990+ info->metadata_alloc_profile;19911991+ data = BTRFS_BLOCK_GROUP_METADATA | alloc_profile;19921992+ }19931993+19941994+ return btrfs_reduce_alloc_profile(root, data);19951995+}19961996+19971997+void btrfs_set_inode_space_info(struct btrfs_root *root, struct inode *inode)19981998+{19991999+ u64 alloc_target;20002000+20012001+ alloc_target = btrfs_get_alloc_profile(root, 1);20022002+ BTRFS_I(inode)->space_info = __find_space_info(root->fs_info,20032003+ alloc_target);20042004+}20052005+20062006+/*20072007+ * for now this just makes sure we have at least 5% of our metadata space free20082008+ * for use.20092009+ */20102010+int btrfs_check_metadata_free_space(struct btrfs_root *root)20112011+{20122012+ struct btrfs_fs_info *info = root->fs_info;20132013+ struct btrfs_space_info *meta_sinfo;20142014+ u64 alloc_target, thresh;20152015+ int committed = 0, ret;20162016+20172017+ /* get the space info for where the metadata will live */20182018+ alloc_target = btrfs_get_alloc_profile(root, 0);20192019+ meta_sinfo = __find_space_info(info, alloc_target);20202020+20212021+again:20222022+ spin_lock(&meta_sinfo->lock);20232023+ if (!meta_sinfo->full)20242024+ thresh = meta_sinfo->total_bytes * 80;20252025+ else20262026+ thresh = meta_sinfo->total_bytes * 95;20272027+20282028+ do_div(thresh, 100);20292029+20302030+ if (meta_sinfo->bytes_used + meta_sinfo->bytes_reserved +20312031+ meta_sinfo->bytes_pinned + meta_sinfo->bytes_readonly > thresh) {20322032+ struct btrfs_trans_handle *trans;20332033+ if (!meta_sinfo->full) {20342034+ meta_sinfo->force_alloc = 1;20352035+ spin_unlock(&meta_sinfo->lock);20362036+20372037+ trans = btrfs_start_transaction(root, 1);20382038+ if (!trans)20392039+ return -ENOMEM;20402040+20412041+ ret = do_chunk_alloc(trans, root->fs_info->extent_root,20422042+ 2 * 1024 * 1024, alloc_target, 0);20432043+ btrfs_end_transaction(trans, root);20442044+ goto again;20452045+ }20462046+ spin_unlock(&meta_sinfo->lock);20472047+20482048+ if (!committed) {20492049+ committed = 1;20502050+ trans = btrfs_join_transaction(root, 1);20512051+ if (!trans)20522052+ return -ENOMEM;20532053+ ret = btrfs_commit_transaction(trans, root);20542054+ if (ret)20552055+ return ret;20562056+ goto again;20572057+ }20582058+ return -ENOSPC;20592059+ }20602060+ spin_unlock(&meta_sinfo->lock);20612061+20622062+ return 0;20632063+}20642064+20652065+/*20662066+ * This will check the space that the inode allocates from to make sure we have20672067+ * enough space for bytes.20682068+ */20692069+int btrfs_check_data_free_space(struct btrfs_root *root, struct inode *inode,20702070+ u64 bytes)20712071+{20722072+ struct btrfs_space_info *data_sinfo;20732073+ int ret = 0, committed = 0;20742074+20752075+ /* make sure bytes are sectorsize aligned */20762076+ bytes = (bytes + root->sectorsize - 1) & ~((u64)root->sectorsize - 1);20772077+20782078+ data_sinfo = BTRFS_I(inode)->space_info;20792079+again:20802080+ /* make sure we have enough space to handle the data first */20812081+ spin_lock(&data_sinfo->lock);20822082+ if (data_sinfo->total_bytes - data_sinfo->bytes_used -20832083+ data_sinfo->bytes_delalloc - data_sinfo->bytes_reserved -20842084+ data_sinfo->bytes_pinned - data_sinfo->bytes_readonly -20852085+ data_sinfo->bytes_may_use < bytes) {20862086+ struct btrfs_trans_handle *trans;20872087+20882088+ /*20892089+ * if we don't have enough free bytes in this space then we need20902090+ * to alloc a new chunk.20912091+ */20922092+ if (!data_sinfo->full) {20932093+ u64 alloc_target;20942094+20952095+ data_sinfo->force_alloc = 1;20962096+ spin_unlock(&data_sinfo->lock);20972097+20982098+ alloc_target = btrfs_get_alloc_profile(root, 1);20992099+ trans = btrfs_start_transaction(root, 1);21002100+ if (!trans)21012101+ return -ENOMEM;21022102+21032103+ ret = do_chunk_alloc(trans, root->fs_info->extent_root,21042104+ bytes + 2 * 1024 * 1024,21052105+ alloc_target, 0);21062106+ btrfs_end_transaction(trans, root);21072107+ if (ret)21082108+ return ret;21092109+ goto again;21102110+ }21112111+ spin_unlock(&data_sinfo->lock);21122112+21132113+ /* commit the current transaction and try again */21142114+ if (!committed) {21152115+ committed = 1;21162116+ trans = btrfs_join_transaction(root, 1);21172117+ if (!trans)21182118+ return -ENOMEM;21192119+ ret = btrfs_commit_transaction(trans, root);21202120+ if (ret)21212121+ return ret;21222122+ goto again;21232123+ }21242124+21252125+ printk(KERN_ERR "no space left, need %llu, %llu delalloc bytes"21262126+ ", %llu bytes_used, %llu bytes_reserved, "21272127+ "%llu bytes_pinned, %llu bytes_readonly, %llu may use"21282128+ "%llu total\n", bytes, data_sinfo->bytes_delalloc,21292129+ data_sinfo->bytes_used, data_sinfo->bytes_reserved,21302130+ data_sinfo->bytes_pinned, data_sinfo->bytes_readonly,21312131+ data_sinfo->bytes_may_use, data_sinfo->total_bytes);21322132+ return -ENOSPC;21332133+ }21342134+ data_sinfo->bytes_may_use += bytes;21352135+ BTRFS_I(inode)->reserved_bytes += bytes;21362136+ spin_unlock(&data_sinfo->lock);21372137+21382138+ return btrfs_check_metadata_free_space(root);21392139+}21402140+21412141+/*21422142+ * if there was an error for whatever reason after calling21432143+ * btrfs_check_data_free_space, call this so we can cleanup the counters.21442144+ */21452145+void btrfs_free_reserved_data_space(struct btrfs_root *root,21462146+ struct inode *inode, u64 bytes)21472147+{21482148+ struct btrfs_space_info *data_sinfo;21492149+21502150+ /* make sure bytes are sectorsize aligned */21512151+ bytes = (bytes + root->sectorsize - 1) & ~((u64)root->sectorsize - 1);21522152+21532153+ data_sinfo = BTRFS_I(inode)->space_info;21542154+ spin_lock(&data_sinfo->lock);21552155+ data_sinfo->bytes_may_use -= bytes;21562156+ BTRFS_I(inode)->reserved_bytes -= bytes;21572157+ spin_unlock(&data_sinfo->lock);21582158+}21592159+21602160+/* called when we are adding a delalloc extent to the inode's io_tree */21612161+void btrfs_delalloc_reserve_space(struct btrfs_root *root, struct inode *inode,21622162+ u64 bytes)21632163+{21642164+ struct btrfs_space_info *data_sinfo;21652165+21662166+ /* get the space info for where this inode will be storing its data */21672167+ data_sinfo = BTRFS_I(inode)->space_info;21682168+21692169+ /* make sure we have enough space to handle the data first */21702170+ spin_lock(&data_sinfo->lock);21712171+ data_sinfo->bytes_delalloc += bytes;21722172+21732173+ /*21742174+ * we are adding a delalloc extent without calling21752175+ * btrfs_check_data_free_space first. This happens on a weird21762176+ * writepage condition, but shouldn't hurt our accounting21772177+ */21782178+ if (unlikely(bytes > BTRFS_I(inode)->reserved_bytes)) {21792179+ data_sinfo->bytes_may_use -= BTRFS_I(inode)->reserved_bytes;21802180+ BTRFS_I(inode)->reserved_bytes = 0;21812181+ } else {21822182+ data_sinfo->bytes_may_use -= bytes;21832183+ BTRFS_I(inode)->reserved_bytes -= bytes;21842184+ }21852185+21862186+ spin_unlock(&data_sinfo->lock);21872187+}21882188+21892189+/* called when we are clearing an delalloc extent from the inode's io_tree */21902190+void btrfs_delalloc_free_space(struct btrfs_root *root, struct inode *inode,21912191+ u64 bytes)21922192+{21932193+ struct btrfs_space_info *info;21942194+21952195+ info = BTRFS_I(inode)->space_info;21962196+21972197+ spin_lock(&info->lock);21982198+ info->bytes_delalloc -= bytes;21992199+ spin_unlock(&info->lock);19782200}1979220119802202static int do_chunk_alloc(struct btrfs_trans_handle *trans,···33373105 (unsigned long long)(info->total_bytes - info->bytes_used -33383106 info->bytes_pinned - info->bytes_reserved),33393107 (info->full) ? "" : "not ");31083108+ printk(KERN_INFO "space_info total=%llu, pinned=%llu, delalloc=%llu,"31093109+ " may_use=%llu, used=%llu\n", info->total_bytes,31103110+ info->bytes_pinned, info->bytes_delalloc, info->bytes_may_use,31113111+ info->bytes_used);3340311233413113 down_read(&info->groups_sem);33423114 list_for_each_entry(cache, &info->block_groups, list) {···33673131{33683132 int ret;33693133 u64 search_start = 0;33703370- u64 alloc_profile;33713134 struct btrfs_fs_info *info = root->fs_info;3372313533733373- if (data) {33743374- alloc_profile = info->avail_data_alloc_bits &33753375- info->data_alloc_profile;33763376- data = BTRFS_BLOCK_GROUP_DATA | alloc_profile;33773377- } else if (root == root->fs_info->chunk_root) {33783378- alloc_profile = info->avail_system_alloc_bits &33793379- info->system_alloc_profile;33803380- data = BTRFS_BLOCK_GROUP_SYSTEM | alloc_profile;33813381- } else {33823382- alloc_profile = info->avail_metadata_alloc_bits &33833383- info->metadata_alloc_profile;33843384- data = BTRFS_BLOCK_GROUP_METADATA | alloc_profile;33853385- }31363136+ data = btrfs_get_alloc_profile(root, data);33863137again:33873387- data = btrfs_reduce_alloc_profile(root, data);33883138 /*33893139 * the only place that sets empty_size is btrfs_realloc_node, which33903140 * is not called recursively on allocations
+13-3
fs/btrfs/file.c
···10911091 WARN_ON(num_pages > nrptrs);10921092 memset(pages, 0, sizeof(struct page *) * nrptrs);1093109310941094- ret = btrfs_check_free_space(root, write_bytes, 0);10941094+ ret = btrfs_check_data_free_space(root, inode, write_bytes);10951095 if (ret)10961096 goto out;1097109710981098 ret = prepare_pages(root, file, pages, num_pages,10991099 pos, first_index, last_index,11001100 write_bytes);11011101- if (ret)11011101+ if (ret) {11021102+ btrfs_free_reserved_data_space(root, inode,11031103+ write_bytes);11021104 goto out;11051105+ }1103110611041107 ret = btrfs_copy_from_user(pos, num_pages,11051108 write_bytes, pages, buf);11061109 if (ret) {11101110+ btrfs_free_reserved_data_space(root, inode,11111111+ write_bytes);11071112 btrfs_drop_pages(pages, num_pages);11081113 goto out;11091114 }···11161111 ret = dirty_and_release_pages(NULL, root, file, pages,11171112 num_pages, pos, write_bytes);11181113 btrfs_drop_pages(pages, num_pages);11191119- if (ret)11141114+ if (ret) {11151115+ btrfs_free_reserved_data_space(root, inode,11161116+ write_bytes);11201117 goto out;11181118+ }1121111911221120 if (will_write) {11231121 btrfs_fdatawrite_range(inode->i_mapping, pos,···11441136 }11451137out:11461138 mutex_unlock(&inode->i_mutex);11391139+ if (ret)11401140+ err = ret;1147114111481142out_nolock:11491143 kfree(pages);
+16-46
fs/btrfs/inode.c
···102102}103103104104/*105105- * a very lame attempt at stopping writes when the FS is 85% full. There106106- * are countless ways this is incorrect, but it is better than nothing.107107- */108108-int btrfs_check_free_space(struct btrfs_root *root, u64 num_required,109109- int for_del)110110-{111111- u64 total;112112- u64 used;113113- u64 thresh;114114- int ret = 0;115115-116116- spin_lock(&root->fs_info->delalloc_lock);117117- total = btrfs_super_total_bytes(&root->fs_info->super_copy);118118- used = btrfs_super_bytes_used(&root->fs_info->super_copy);119119- if (for_del)120120- thresh = total * 90;121121- else122122- thresh = total * 85;123123-124124- do_div(thresh, 100);125125-126126- if (used + root->fs_info->delalloc_bytes + num_required > thresh)127127- ret = -ENOSPC;128128- spin_unlock(&root->fs_info->delalloc_lock);129129- return ret;130130-}131131-132132-/*133105 * this does all the hard work for inserting an inline extent into134106 * the btree. The caller should have done a btrfs_drop_extents so that135107 * no overlapping inline items exist in the btree···11621190 */11631191 if (!(old & EXTENT_DELALLOC) && (bits & EXTENT_DELALLOC)) {11641192 struct btrfs_root *root = BTRFS_I(inode)->root;11931193+ btrfs_delalloc_reserve_space(root, inode, end - start + 1);11651194 spin_lock(&root->fs_info->delalloc_lock);11661195 BTRFS_I(inode)->delalloc_bytes += end - start + 1;11671196 root->fs_info->delalloc_bytes += end - start + 1;···11961223 (unsigned long long)end - start + 1,11971224 (unsigned long long)11981225 root->fs_info->delalloc_bytes);12261226+ btrfs_delalloc_free_space(root, inode, (u64)-1);11991227 root->fs_info->delalloc_bytes = 0;12001228 BTRFS_I(inode)->delalloc_bytes = 0;12011229 } else {12301230+ btrfs_delalloc_free_space(root, inode,12311231+ end - start + 1);12021232 root->fs_info->delalloc_bytes -= end - start + 1;12031233 BTRFS_I(inode)->delalloc_bytes -= end - start + 1;12041234 }···2221224522222246 root = BTRFS_I(dir)->root;2223224722242224- ret = btrfs_check_free_space(root, 1, 1);22252225- if (ret)22262226- goto fail;22272227-22282248 trans = btrfs_start_transaction(root, 1);2229224922302250 btrfs_set_trans_block_group(trans, dir);···22332261 nr = trans->blocks_used;2234226222352263 btrfs_end_transaction_throttle(trans, root);22362236-fail:22372264 btrfs_btree_balance_dirty(root, nr);22382265 return ret;22392266}···22552284 return -ENOTEMPTY;22562285 }2257228622582258- ret = btrfs_check_free_space(root, 1, 1);22592259- if (ret)22602260- goto fail;22612261-22622287 trans = btrfs_start_transaction(root, 1);22632288 btrfs_set_trans_block_group(trans, dir);22642289···22712304fail_trans:22722305 nr = trans->blocks_used;22732306 ret = btrfs_end_transaction_throttle(trans, root);22742274-fail:22752307 btrfs_btree_balance_dirty(root, nr);2276230822772309 if (ret && !err)···27842818 if (size <= hole_start)27852819 return 0;2786282027872787- err = btrfs_check_free_space(root, 1, 0);28212821+ err = btrfs_check_metadata_free_space(root);27882822 if (err)27892823 return err;27902824···29803014 bi->last_trans = 0;29813015 bi->logged_trans = 0;29823016 bi->delalloc_bytes = 0;30173017+ bi->reserved_bytes = 0;29833018 bi->disk_i_size = 0;29843019 bi->flags = 0;29853020 bi->index_cnt = (u64)-1;···30023035 inode->i_ino = args->ino;30033036 init_btrfs_i(inode);30043037 BTRFS_I(inode)->root = args->root;30383038+ btrfs_set_inode_space_info(args->root, inode);30053039 return 0;30063040}30073041···34233455 BTRFS_I(inode)->index_cnt = 2;34243456 BTRFS_I(inode)->root = root;34253457 BTRFS_I(inode)->generation = trans->transid;34583458+ btrfs_set_inode_space_info(root, inode);3426345934273460 if (mode & S_IFDIR)34283461 owner = 0;···35713602 if (!new_valid_dev(rdev))35723603 return -EINVAL;3573360435743574- err = btrfs_check_free_space(root, 1, 0);36053605+ err = btrfs_check_metadata_free_space(root);35753606 if (err)35763607 goto fail;35773608···36343665 u64 objectid;36353666 u64 index = 0;3636366736373637- err = btrfs_check_free_space(root, 1, 0);36683668+ err = btrfs_check_metadata_free_space(root);36383669 if (err)36393670 goto fail;36403671 trans = btrfs_start_transaction(root, 1);···37023733 return -ENOENT;3703373437043735 btrfs_inc_nlink(inode);37053705- err = btrfs_check_free_space(root, 1, 0);37363736+ err = btrfs_check_metadata_free_space(root);37063737 if (err)37073738 goto fail;37083739 err = btrfs_set_inode_index(dir, &index);···37483779 u64 index = 0;37493780 unsigned long nr = 1;3750378137513751- err = btrfs_check_free_space(root, 1, 0);37823782+ err = btrfs_check_metadata_free_space(root);37523783 if (err)37533784 goto out_unlock;37543785···43054336 u64 page_start;43064337 u64 page_end;4307433843084308- ret = btrfs_check_free_space(root, PAGE_CACHE_SIZE, 0);43394339+ ret = btrfs_check_data_free_space(root, inode, PAGE_CACHE_SIZE);43094340 if (ret)43104341 goto out;43114342···4318434943194350 if ((page->mapping != inode->i_mapping) ||43204351 (page_start >= size)) {43524352+ btrfs_free_reserved_data_space(root, inode, PAGE_CACHE_SIZE);43214353 /* page got truncated out from underneath us */43224354 goto out_unlock;43234355 }···46014631 if (old_inode->i_ino == BTRFS_FIRST_FREE_OBJECTID)46024632 return -EXDEV;4603463346044604- ret = btrfs_check_free_space(root, 1, 0);46344634+ ret = btrfs_check_metadata_free_space(root);46054635 if (ret)46064636 goto out_unlock;46074637···47194749 if (name_len > BTRFS_MAX_INLINE_DATA_SIZE(root))47204750 return -ENAMETOOLONG;4721475147224722- err = btrfs_check_free_space(root, 1, 0);47524752+ err = btrfs_check_metadata_free_space(root);47234753 if (err)47244754 goto out_fail;47254755
+3-3
fs/btrfs/ioctl.c
···7070 u64 index = 0;7171 unsigned long nr = 1;72727373- ret = btrfs_check_free_space(root, 1, 0);7373+ ret = btrfs_check_metadata_free_space(root);7474 if (ret)7575 goto fail_commit;7676···203203 if (!root->ref_cows)204204 return -EINVAL;205205206206- ret = btrfs_check_free_space(root, 1, 0);206206+ ret = btrfs_check_metadata_free_space(root);207207 if (ret)208208 goto fail_unlock;209209···374374 unsigned long i;375375 int ret;376376377377- ret = btrfs_check_free_space(root, inode->i_size, 0);377377+ ret = btrfs_check_data_free_space(root, inode, inode->i_size);378378 if (ret)379379 return -ENOSPC;380380
+3
fs/compat_ioctl.c
···19131913/* 0x00 */19141914COMPATIBLE_IOCTL(FIBMAP)19151915COMPATIBLE_IOCTL(FIGETBSZ)19161916+/* 'X' - originally XFS but some now in the VFS */19171917+COMPATIBLE_IOCTL(FIFREEZE)19181918+COMPATIBLE_IOCTL(FITHAW)19161919/* RAID */19171920COMPATIBLE_IOCTL(RAID_VERSION)19181921COMPATIBLE_IOCTL(GET_ARRAY_INFO)
+1-1
fs/dcache.c
···11801180 iput(inode);11811181 return res;11821182}11831183-EXPORT_SYMBOL_GPL(d_obtain_alias);11831183+EXPORT_SYMBOL(d_obtain_alias);1184118411851185/**11861186 * d_splice_alias - splice a disconnected dentry into the tree if one exists
+3-1
fs/ext4/balloc.c
···609609 */610610int ext4_should_retry_alloc(struct super_block *sb, int *retries)611611{612612- if (!ext4_has_free_blocks(EXT4_SB(sb), 1) || (*retries)++ > 3)612612+ if (!ext4_has_free_blocks(EXT4_SB(sb), 1) ||613613+ (*retries)++ > 3 ||614614+ !EXT4_SB(sb)->s_journal)613615 return 0;614616615617 jbd_debug(1, "%s: retrying operation after ENOSPC\n", sb->s_id);
+1-1
fs/ext4/inode.c
···2544254425452545 ext4_journal_stop(handle);2546254625472547- if (mpd.retval == -ENOSPC) {25472547+ if ((mpd.retval == -ENOSPC) && sbi->s_journal) {25482548 /* commit the transaction which would25492549 * free blocks released in the transaction25502550 * and try again
···9595 spin_unlock(&c->erase_completion_lock);969697979898- /* This thread is purely an optimisation. But if it runs when9999- other things could be running, it actually makes things a100100- lot worse. Use yield() and put it at the back of the runqueue101101- every time. Especially during boot, pulling an inode in102102- with read_inode() is much preferable to having the GC thread103103- get there first. */104104- yield();9898+ /* Problem - immediately after bootup, the GCD spends a lot9999+ * of time in places like jffs2_kill_fragtree(); so much so100100+ * that userspace processes (like gdm and X) are starved101101+ * despite plenty of cond_resched()s and renicing. Yield()102102+ * doesn't help, either (presumably because userspace and GCD103103+ * are generally competing for a higher latency resource -104104+ * disk).105105+ * This forces the GCD to slow the hell down. Pulling an106106+ * inode in with read_inode() is much preferable to having107107+ * the GC thread get there first. */108108+ schedule_timeout_interruptible(msecs_to_jiffies(50));105109106110 /* Put_super will send a SIGKILL and then wait on the sem.107111 */
+33-9
fs/jffs2/readinode.c
···220220 struct jffs2_tmp_dnode_info *tn)221221{222222 uint32_t fn_end = tn->fn->ofs + tn->fn->size;223223- struct jffs2_tmp_dnode_info *this;223223+ struct jffs2_tmp_dnode_info *this, *ptn;224224225225 dbg_readinode("insert fragment %#04x-%#04x, ver %u at %08x\n", tn->fn->ofs, fn_end, tn->version, ref_offset(tn->fn->raw));226226···251251 if (this) {252252 /* If the node is coincident with another at a lower address,253253 back up until the other node is found. It may be relevant */254254- while (this->overlapped)255255- this = tn_prev(this);256256-257257- /* First node should never be marked overlapped */258258- BUG_ON(!this);254254+ while (this->overlapped) {255255+ ptn = tn_prev(this);256256+ if (!ptn) {257257+ /*258258+ * We killed a node which set the overlapped259259+ * flags during the scan. Fix it up.260260+ */261261+ this->overlapped = 0;262262+ break;263263+ }264264+ this = ptn;265265+ }259266 dbg_readinode("'this' found %#04x-%#04x (%s)\n", this->fn->ofs, this->fn->ofs + this->fn->size, this->fn ? "data" : "hole");260267 }261268···367360 }368361 if (!this->overlapped)369362 break;370370- this = tn_prev(this);363363+364364+ ptn = tn_prev(this);365365+ if (!ptn) {366366+ /*367367+ * We killed a node which set the overlapped368368+ * flags during the scan. Fix it up.369369+ */370370+ this->overlapped = 0;371371+ break;372372+ }373373+ this = ptn;371374 }372375 }373376···473456 eat_last(&rii->tn_root, &last->rb);474457 ver_insert(&ver_root, last);475458476476- if (unlikely(last->overlapped))477477- continue;459459+ if (unlikely(last->overlapped)) {460460+ if (pen)461461+ continue;462462+ /*463463+ * We killed a node which set the overlapped464464+ * flags during the scan. Fix it up.465465+ */466466+ last->overlapped = 0;467467+ }478468479469 /* Now we have a bunch of nodes in reverse version480470 order, in the tree at ver_root. Most of the time,
+26-1
fs/ocfs2/alloc.c
···47964796 return ret;47974797}4798479847994799+static int ocfs2_replace_extent_rec(struct inode *inode,48004800+ handle_t *handle,48014801+ struct ocfs2_path *path,48024802+ struct ocfs2_extent_list *el,48034803+ int split_index,48044804+ struct ocfs2_extent_rec *split_rec)48054805+{48064806+ int ret;48074807+48084808+ ret = ocfs2_path_bh_journal_access(handle, inode, path,48094809+ path_num_items(path) - 1);48104810+ if (ret) {48114811+ mlog_errno(ret);48124812+ goto out;48134813+ }48144814+48154815+ el->l_recs[split_index] = *split_rec;48164816+48174817+ ocfs2_journal_dirty(handle, path_leaf_bh(path));48184818+out:48194819+ return ret;48204820+}48214821+47994822/*48004823 * Mark part or all of the extent record at split_index in the leaf48014824 * pointed to by path as written. This removes the unwritten···4908488549094886 if (ctxt.c_contig_type == CONTIG_NONE) {49104887 if (ctxt.c_split_covers_rec)49114911- el->l_recs[split_index] = *split_rec;48884888+ ret = ocfs2_replace_extent_rec(inode, handle,48894889+ path, el,48904890+ split_index, split_rec);49124891 else49134892 ret = ocfs2_split_and_insert(inode, handle, path, et,49144893 &last_eb_bh, split_index,
+6-6
fs/ocfs2/dlm/dlmmaster.c
···18491849 if (!mle) {18501850 if (res->owner != DLM_LOCK_RES_OWNER_UNKNOWN &&18511851 res->owner != assert->node_idx) {18521852- mlog(ML_ERROR, "assert_master from "18531853- "%u, but current owner is "18541854- "%u! (%.*s)\n",18551855- assert->node_idx, res->owner,18561856- namelen, name);18571857- goto kill;18521852+ mlog(ML_ERROR, "DIE! Mastery assert from %u, "18531853+ "but current owner is %u! (%.*s)\n",18541854+ assert->node_idx, res->owner, namelen,18551855+ name);18561856+ __dlm_print_one_lock_resource(res);18571857+ BUG();18581858 }18591859 } else if (mle->type != DLM_MLE_MIGRATION) {18601860 if (res->owner != DLM_LOCK_RES_OWNER_UNKNOWN) {
+1-2
fs/ocfs2/dlm/dlmthread.c
···181181182182 spin_lock(&res->spinlock);183183 /* This ensures that clear refmap is sent after the set */184184- __dlm_wait_on_lockres_flags(res, (DLM_LOCK_RES_SETREF_INPROG |185185- DLM_LOCK_RES_MIGRATING));184184+ __dlm_wait_on_lockres_flags(res, DLM_LOCK_RES_SETREF_INPROG);186185 spin_unlock(&res->spinlock);187186188187 /* clear our bit from the master's refmap, ignore errors */
+2-2
fs/ocfs2/dlm/dlmunlock.c
···117117 else118118 BUG_ON(res->owner == dlm->node_num);119119120120- spin_lock(&dlm->spinlock);120120+ spin_lock(&dlm->ast_lock);121121 /* We want to be sure that we're not freeing a lock122122 * that still has AST's pending... */123123 in_use = !list_empty(&lock->ast_list);124124- spin_unlock(&dlm->spinlock);124124+ spin_unlock(&dlm->ast_lock);125125 if (in_use) {126126 mlog(ML_ERROR, "lockres %.*s: Someone is calling dlmunlock "127127 "while waiting for an ast!", res->lockname.len,
+8-3
fs/ocfs2/dlmglue.c
···320320 struct ocfs2_lock_res *lockres);321321static inline void ocfs2_recover_from_dlm_error(struct ocfs2_lock_res *lockres,322322 int convert);323323-#define ocfs2_log_dlm_error(_func, _err, _lockres) do { \324324- mlog(ML_ERROR, "DLM error %d while calling %s on resource %s\n", \325325- _err, _func, _lockres->l_name); \323323+#define ocfs2_log_dlm_error(_func, _err, _lockres) do { \324324+ if ((_lockres)->l_type != OCFS2_LOCK_TYPE_DENTRY) \325325+ mlog(ML_ERROR, "DLM error %d while calling %s on resource %s\n", \326326+ _err, _func, _lockres->l_name); \327327+ else \328328+ mlog(ML_ERROR, "DLM error %d while calling %s on resource %.*s%08x\n", \329329+ _err, _func, OCFS2_DENTRY_LOCK_INO_START - 1, (_lockres)->l_name, \330330+ (unsigned int)ocfs2_get_dentry_lock_ino(_lockres)); \326331} while (0)327332static int ocfs2_downconvert_thread(void *arg);328333static void ocfs2_downconvert_on_unlock(struct ocfs2_super *osb,
+3
fs/ocfs2/ocfs2.h
···341341 struct ocfs2_node_map osb_recovering_orphan_dirs;342342 unsigned int *osb_orphan_wipes;343343 wait_queue_head_t osb_wipe_event;344344+345345+ /* used to protect metaecc calculation check of xattr. */346346+ spinlock_t osb_xattr_lock;344347};345348346349#define OCFS2_SB(sb) ((struct ocfs2_super *)(sb)->s_fs_info)
···708708};709709710710/* This should not be used directly - use rq_for_each_segment */711711+#define for_each_bio(_bio) \712712+ for (; _bio; _bio = _bio->bi_next)711713#define __rq_for_each_bio(_bio, rq) \712714 if ((rq->bio)) \713715 for (_bio = (rq)->bio; _bio; _bio = _bio->bi_next)
···11+#ifndef DECOMPRESS_GENERIC_H22+#define DECOMPRESS_GENERIC_H33+44+/* Minimal chunksize to be read.55+ *Bzip2 prefers at least 409666+ *Lzma prefers 0x10000 */77+#define COMPR_IOBUF_SIZE 409688+99+typedef int (*decompress_fn) (unsigned char *inbuf, int len,1010+ int(*fill)(void*, unsigned int),1111+ int(*writebb)(void*, unsigned int),1212+ unsigned char *output,1313+ int *posp,1414+ void(*error)(char *x));1515+1616+/* inbuf - input buffer1717+ *len - len of pre-read data in inbuf1818+ *fill - function to fill inbuf if empty1919+ *writebb - function to write out outbug2020+ *posp - if non-null, input position (number of bytes read) will be2121+ * returned here2222+ *2323+ *If len != 0, the inbuf is initialized (with as much data), and fill2424+ *should not be called2525+ *If len = 0, the inbuf is allocated, but empty. Its size is IOBUF_SIZE2626+ *fill should be called (repeatedly...) to read data, at most IOBUF_SIZE2727+ */2828+2929+/* Utility routine to detect the decompression method */3030+decompress_fn decompress_method(const unsigned char *inbuf, int len,3131+ const char **name);3232+3333+#endif
+13
include/linux/decompress/inflate.h
···11+#ifndef INFLATE_H22+#define INFLATE_H33+44+/* Other housekeeping constants */55+#define INBUFSIZ 409666+77+int gunzip(unsigned char *inbuf, int len,88+ int(*fill)(void*, unsigned int),99+ int(*flush)(void*, unsigned int),1010+ unsigned char *output,1111+ int *pos,1212+ void(*error_fn)(char *x));1313+#endif
+87
include/linux/decompress/mm.h
···11+/*22+ * linux/compr_mm.h33+ *44+ * Memory management for pre-boot and ramdisk uncompressors55+ *66+ * Authors: Alain Knaff <alain@knaff.lu>77+ *88+ */99+1010+#ifndef DECOMPR_MM_H1111+#define DECOMPR_MM_H1212+1313+#ifdef STATIC1414+1515+/* Code active when included from pre-boot environment: */1616+1717+/* A trivial malloc implementation, adapted from1818+ * malloc by Hannu Savolainen 1993 and Matthias Urlichs 19941919+ */2020+static unsigned long malloc_ptr;2121+static int malloc_count;2222+2323+static void *malloc(int size)2424+{2525+ void *p;2626+2727+ if (size < 0)2828+ error("Malloc error");2929+ if (!malloc_ptr)3030+ malloc_ptr = free_mem_ptr;3131+3232+ malloc_ptr = (malloc_ptr + 3) & ~3; /* Align */3333+3434+ p = (void *)malloc_ptr;3535+ malloc_ptr += size;3636+3737+ if (free_mem_end_ptr && malloc_ptr >= free_mem_end_ptr)3838+ error("Out of memory");3939+4040+ malloc_count++;4141+ return p;4242+}4343+4444+static void free(void *where)4545+{4646+ malloc_count--;4747+ if (!malloc_count)4848+ malloc_ptr = free_mem_ptr;4949+}5050+5151+#define large_malloc(a) malloc(a)5252+#define large_free(a) free(a)5353+5454+#define set_error_fn(x)5555+5656+#define INIT5757+5858+#else /* STATIC */5959+6060+/* Code active when compiled standalone for use when loading ramdisk: */6161+6262+#include <linux/kernel.h>6363+#include <linux/fs.h>6464+#include <linux/string.h>6565+#include <linux/vmalloc.h>6666+6767+/* Use defines rather than static inline in order to avoid spurious6868+ * warnings when not needed (indeed large_malloc / large_free are not6969+ * needed by inflate */7070+7171+#define malloc(a) kmalloc(a, GFP_KERNEL)7272+#define free(a) kfree(a)7373+7474+#define large_malloc(a) vmalloc(a)7575+#define large_free(a) vfree(a)7676+7777+static void(*error)(char *m);7878+#define set_error_fn(x) error = x;7979+8080+#define INIT __init8181+#define STATIC8282+8383+#include <linux/init.h>8484+8585+#endif /* STATIC */8686+8787+#endif /* DECOMPR_MM_H */
···5959 struct nf_conn *ct = (struct nf_conn *)skb->nfct;6060 int ret = NF_ACCEPT;61616262- if (ct) {6262+ if (ct && ct != &nf_conntrack_untracked) {6363 if (!nf_ct_is_confirmed(ct) && !nf_ct_is_dying(ct))6464 ret = __nf_conntrack_confirm(skb);6565 nf_ct_deliver_cached_events(ct);
+60
init/Kconfig
···101101102102 which is done within the script "scripts/setlocalversion".)103103104104+config HAVE_KERNEL_GZIP105105+ bool106106+107107+config HAVE_KERNEL_BZIP2108108+ bool109109+110110+config HAVE_KERNEL_LZMA111111+ bool112112+113113+choice114114+ prompt "Kernel compression mode"115115+ default KERNEL_GZIP116116+ depends on HAVE_KERNEL_GZIP || HAVE_KERNEL_BZIP2 || HAVE_KERNEL_LZMA117117+ help118118+ The linux kernel is a kind of self-extracting executable.119119+ Several compression algorithms are available, which differ120120+ in efficiency, compression and decompression speed.121121+ Compression speed is only relevant when building a kernel.122122+ Decompression speed is relevant at each boot.123123+124124+ If you have any problems with bzip2 or lzma compressed125125+ kernels, mail me (Alain Knaff) <alain@knaff.lu>. (An older126126+ version of this functionality (bzip2 only), for 2.4, was127127+ supplied by Christian Ludwig)128128+129129+ High compression options are mostly useful for users, who130130+ are low on disk space (embedded systems), but for whom ram131131+ size matters less.132132+133133+ If in doubt, select 'gzip'134134+135135+config KERNEL_GZIP136136+ bool "Gzip"137137+ depends on HAVE_KERNEL_GZIP138138+ help139139+ The old and tried gzip compression. Its compression ratio is140140+ the poorest among the 3 choices; however its speed (both141141+ compression and decompression) is the fastest.142142+143143+config KERNEL_BZIP2144144+ bool "Bzip2"145145+ depends on HAVE_KERNEL_BZIP2146146+ help147147+ Its compression ratio and speed is intermediate.148148+ Decompression speed is slowest among the three. The kernel149149+ size is about 10% smaller with bzip2, in comparison to gzip.150150+ Bzip2 uses a large amount of memory. For modern kernels you151151+ will need at least 8MB RAM or more for booting.152152+153153+config KERNEL_LZMA154154+ bool "LZMA"155155+ depends on HAVE_KERNEL_LZMA156156+ help157157+ The most recent compression algorithm.158158+ Its ratio is best, decompression speed is between the other159159+ two. Compression is slowest. The kernel size is about 33%160160+ smaller with LZMA in comparison to gzip.161161+162162+endchoice163163+104164config SWAP105165 bool "Support for paging of anonymous memory (swap)"106166 depends on MMU && BLOCK
+47-131
init/do_mounts_rd.c
···1111#include "do_mounts.h"1212#include "../fs/squashfs/squashfs_fs.h"13131414+#include <linux/decompress/generic.h>1515+1616+1417int __initdata rd_prompt = 1;/* 1 = prompt for RAM disk, 0 = don't prompt */15181619static int __init prompt_ramdisk(char *str)···3229}3330__setup("ramdisk_start=", ramdisk_start_setup);34313535-static int __init crd_load(int in_fd, int out_fd);3232+static int __init crd_load(int in_fd, int out_fd, decompress_fn deco);36333734/*3835 * This routine tries to find a RAM disk image to load, and returns the···4138 * numbers could not be found.4239 *4340 * We currently check for the following magic numbers:4444- * minix4545- * ext24141+ * minix4242+ * ext24643 * romfs4744 * cramfs4845 * squashfs4949- * gzip4646+ * gzip5047 */5151-static int __init 5252-identify_ramdisk_image(int fd, int start_block)4848+static int __init4949+identify_ramdisk_image(int fd, int start_block, decompress_fn *decompressor)5350{5451 const int size = 512;5552 struct minix_super_block *minixsb;···5956 struct squashfs_super_block *squashfsb;6057 int nblocks = -1;6158 unsigned char *buf;5959+ const char *compress_name;62606361 buf = kmalloc(size, GFP_KERNEL);6462 if (!buf)···7369 memset(buf, 0xe5, size);74707571 /*7676- * Read block 0 to test for gzipped kernel7272+ * Read block 0 to test for compressed kernel7773 */7874 sys_lseek(fd, start_block * BLOCK_SIZE, 0);7975 sys_read(fd, buf, size);80768181- /*8282- * If it matches the gzip magic numbers, return 08383- */8484- if (buf[0] == 037 && ((buf[1] == 0213) || (buf[1] == 0236))) {8585- printk(KERN_NOTICE8686- "RAMDISK: Compressed image found at block %d\n",8787- start_block);7777+ *decompressor = decompress_method(buf, size, &compress_name);7878+ if (compress_name) {7979+ printk(KERN_NOTICE "RAMDISK: %s image found at block %d\n",8080+ compress_name, start_block);8181+ if (!*decompressor)8282+ printk(KERN_EMERG8383+ "RAMDISK: %s decompressor not configured!\n",8484+ compress_name);8885 nblocks = 0;8986 goto done;9087 }···147142 printk(KERN_NOTICE148143 "RAMDISK: Couldn't find valid RAM disk image starting at %d.\n",149144 start_block);150150-145145+151146done:152147 sys_lseek(fd, start_block * BLOCK_SIZE, 0);153148 kfree(buf);···162157 int nblocks, i, disk;163158 char *buf = NULL;164159 unsigned short rotate = 0;160160+ decompress_fn decompressor = NULL;165161#if !defined(CONFIG_S390) && !defined(CONFIG_PPC_ISERIES)166162 char rotator[4] = { '|' , '/' , '-' , '\\' };167163#endif···175169 if (in_fd < 0)176170 goto noclose_input;177171178178- nblocks = identify_ramdisk_image(in_fd, rd_image_start);172172+ nblocks = identify_ramdisk_image(in_fd, rd_image_start, &decompressor);179173 if (nblocks < 0)180174 goto done;181175182176 if (nblocks == 0) {183183- if (crd_load(in_fd, out_fd) == 0)177177+ if (crd_load(in_fd, out_fd, decompressor) == 0)184178 goto successful_load;185179 goto done;186180 }···206200 nblocks, rd_blocks);207201 goto done;208202 }209209-203203+210204 /*211205 * OK, time to copy in the data212206 */···279273 return rd_load_image("/dev/root");280274}281275282282-/*283283- * gzip declarations284284- */285285-286286-#define OF(args) args287287-288288-#ifndef memzero289289-#define memzero(s, n) memset ((s), 0, (n))290290-#endif291291-292292-typedef unsigned char uch;293293-typedef unsigned short ush;294294-typedef unsigned long ulg;295295-296296-#define INBUFSIZ 4096297297-#define WSIZE 0x8000 /* window size--must be a power of two, and */298298- /* at least 32K for zip's deflate method */299299-300300-static uch *inbuf;301301-static uch *window;302302-303303-static unsigned insize; /* valid bytes in inbuf */304304-static unsigned inptr; /* index of next byte to be processed in inbuf */305305-static unsigned outcnt; /* bytes in output buffer */306276static int exit_code;307307-static int unzip_error;308308-static long bytes_out;277277+static int decompress_error;309278static int crd_infd, crd_outfd;310279311311-#define get_byte() (inptr < insize ? inbuf[inptr++] : fill_inbuf())312312-313313-/* Diagnostic functions (stubbed out) */314314-#define Assert(cond,msg)315315-#define Trace(x)316316-#define Tracev(x)317317-#define Tracevv(x)318318-#define Tracec(c,x)319319-#define Tracecv(c,x)320320-321321-#define STATIC static322322-#define INIT __init323323-324324-static int __init fill_inbuf(void);325325-static void __init flush_window(void);326326-static void __init error(char *m);327327-328328-#define NO_INFLATE_MALLOC329329-330330-#include "../lib/inflate.c"331331-332332-/* ===========================================================================333333- * Fill the input buffer. This is called only when the buffer is empty334334- * and at least one byte is really needed.335335- * Returning -1 does not guarantee that gunzip() will ever return.336336- */337337-static int __init fill_inbuf(void)280280+static int __init compr_fill(void *buf, unsigned int len)338281{339339- if (exit_code) return -1;340340-341341- insize = sys_read(crd_infd, inbuf, INBUFSIZ);342342- if (insize == 0) {343343- error("RAMDISK: ran out of compressed data");344344- return -1;345345- }346346-347347- inptr = 1;348348-349349- return inbuf[0];282282+ int r = sys_read(crd_infd, buf, len);283283+ if (r < 0)284284+ printk(KERN_ERR "RAMDISK: error while reading compressed data");285285+ else if (r == 0)286286+ printk(KERN_ERR "RAMDISK: EOF while reading compressed data");287287+ return r;350288}351289352352-/* ===========================================================================353353- * Write the output window window[0..outcnt-1] and update crc and bytes_out.354354- * (Used for the decompressed data only.)355355- */356356-static void __init flush_window(void)290290+static int __init compr_flush(void *window, unsigned int outcnt)357291{358358- ulg c = crc; /* temporary variable */359359- unsigned n, written;360360- uch *in, ch;361361-362362- written = sys_write(crd_outfd, window, outcnt);363363- if (written != outcnt && unzip_error == 0) {364364- printk(KERN_ERR "RAMDISK: incomplete write (%d != %d) %ld\n",365365- written, outcnt, bytes_out);366366- unzip_error = 1;367367- }368368- in = window;369369- for (n = 0; n < outcnt; n++) {370370- ch = *in++;371371- c = crc_32_tab[((int)c ^ ch) & 0xff] ^ (c >> 8);372372- }373373- crc = c;374374- bytes_out += (ulg)outcnt;375375- outcnt = 0;292292+ int written = sys_write(crd_outfd, window, outcnt);293293+ if (written != outcnt) {294294+ if (decompress_error == 0)295295+ printk(KERN_ERR296296+ "RAMDISK: incomplete write (%d != %d)\n",297297+ written, outcnt);298298+ decompress_error = 1;299299+ return -1;300300+ }301301+ return outcnt;376302}377303378304static void __init error(char *x)379305{380306 printk(KERN_ERR "%s\n", x);381307 exit_code = 1;382382- unzip_error = 1;308308+ decompress_error = 1;383309}384310385385-static int __init crd_load(int in_fd, int out_fd)311311+static int __init crd_load(int in_fd, int out_fd, decompress_fn deco)386312{387313 int result;388388-389389- insize = 0; /* valid bytes in inbuf */390390- inptr = 0; /* index of next byte to be processed in inbuf */391391- outcnt = 0; /* bytes in output buffer */392392- exit_code = 0;393393- bytes_out = 0;394394- crc = (ulg)0xffffffffL; /* shift register contents */395395-396314 crd_infd = in_fd;397315 crd_outfd = out_fd;398398- inbuf = kmalloc(INBUFSIZ, GFP_KERNEL);399399- if (!inbuf) {400400- printk(KERN_ERR "RAMDISK: Couldn't allocate gzip buffer\n");401401- return -1;402402- }403403- window = kmalloc(WSIZE, GFP_KERNEL);404404- if (!window) {405405- printk(KERN_ERR "RAMDISK: Couldn't allocate gzip window\n");406406- kfree(inbuf);407407- return -1;408408- }409409- makecrc();410410- result = gunzip();411411- if (unzip_error)316316+ result = deco(NULL, 0, compr_fill, compr_flush, NULL, NULL, error);317317+ if (decompress_error)412318 result = 1;413413- kfree(inbuf);414414- kfree(window);415319 return result;416320}
+37-85
init/initramfs.c
···390390 return len - count;391391}392392393393-static void __init flush_buffer(char *buf, unsigned len)393393+static int __init flush_buffer(void *bufv, unsigned len)394394{395395+ char *buf = (char *) bufv;395396 int written;397397+ int origLen = len;396398 if (message)397397- return;399399+ return -1;398400 while ((written = write_buffer(buf, len)) < len && !message) {399401 char c = buf[written];400402 if (c == '0') {···410408 } else411409 error("junk in compressed archive");412410 }411411+ return origLen;413412}414413415415-/*416416- * gzip declarations417417- */414414+static unsigned my_inptr; /* index of next byte to be processed in inbuf */418415419419-#define OF(args) args420420-421421-#ifndef memzero422422-#define memzero(s, n) memset ((s), 0, (n))423423-#endif424424-425425-typedef unsigned char uch;426426-typedef unsigned short ush;427427-typedef unsigned long ulg;428428-429429-#define WSIZE 0x8000 /* window size--must be a power of two, and */430430- /* at least 32K for zip's deflate method */431431-432432-static uch *inbuf;433433-static uch *window;434434-435435-static unsigned insize; /* valid bytes in inbuf */436436-static unsigned inptr; /* index of next byte to be processed in inbuf */437437-static unsigned outcnt; /* bytes in output buffer */438438-static long bytes_out;439439-440440-#define get_byte() (inptr < insize ? inbuf[inptr++] : -1)441441-442442-/* Diagnostic functions (stubbed out) */443443-#define Assert(cond,msg)444444-#define Trace(x)445445-#define Tracev(x)446446-#define Tracevv(x)447447-#define Tracec(c,x)448448-#define Tracecv(c,x)449449-450450-#define STATIC static451451-#define INIT __init452452-453453-static void __init flush_window(void);454454-static void __init error(char *m);455455-456456-#define NO_INFLATE_MALLOC457457-458458-#include "../lib/inflate.c"459459-460460-/* ===========================================================================461461- * Write the output window window[0..outcnt-1] and update crc and bytes_out.462462- * (Used for the decompressed data only.)463463- */464464-static void __init flush_window(void)465465-{466466- ulg c = crc; /* temporary variable */467467- unsigned n;468468- uch *in, ch;469469-470470- flush_buffer(window, outcnt);471471- in = window;472472- for (n = 0; n < outcnt; n++) {473473- ch = *in++;474474- c = crc_32_tab[((int)c ^ ch) & 0xff] ^ (c >> 8);475475- }476476- crc = c;477477- bytes_out += (ulg)outcnt;478478- outcnt = 0;479479-}416416+#include <linux/decompress/generic.h>480417481418static char * __init unpack_to_rootfs(char *buf, unsigned len, int check_only)482419{483420 int written;421421+ decompress_fn decompress;422422+ const char *compress_name;423423+ static __initdata char msg_buf[64];424424+484425 dry_run = check_only;485426 header_buf = kmalloc(110, GFP_KERNEL);486427 symlink_buf = kmalloc(PATH_MAX + N_ALIGN(PATH_MAX) + 1, GFP_KERNEL);487428 name_buf = kmalloc(N_ALIGN(PATH_MAX), GFP_KERNEL);488488- window = kmalloc(WSIZE, GFP_KERNEL);489489- if (!window || !header_buf || !symlink_buf || !name_buf)429429+430430+ if (!header_buf || !symlink_buf || !name_buf)490431 panic("can't allocate buffers");432432+491433 state = Start;492434 this_header = 0;493435 message = NULL;···451505 continue;452506 }453507 this_header = 0;454454- insize = len;455455- inbuf = buf;456456- inptr = 0;457457- outcnt = 0; /* bytes in output buffer */458458- bytes_out = 0;459459- crc = (ulg)0xffffffffL; /* shift register contents */460460- makecrc();461461- gunzip();508508+ decompress = decompress_method(buf, len, &compress_name);509509+ if (decompress)510510+ decompress(buf, len, NULL, flush_buffer, NULL,511511+ &my_inptr, error);512512+ else if (compress_name) {513513+ if (!message) {514514+ snprintf(msg_buf, sizeof msg_buf,515515+ "compression method %s not configured",516516+ compress_name);517517+ message = msg_buf;518518+ }519519+ }462520 if (state != Reset)463463- error("junk in gzipped archive");464464- this_header = saved_offset + inptr;465465- buf += inptr;466466- len -= inptr;521521+ error("junk in compressed archive");522522+ this_header = saved_offset + my_inptr;523523+ buf += my_inptr;524524+ len -= my_inptr;467525 }468526 dir_utime();469469- kfree(window);470527 kfree(name_buf);471528 kfree(symlink_buf);472529 kfree(header_buf);···528579 char *err = unpack_to_rootfs(__initramfs_start,529580 __initramfs_end - __initramfs_start, 0);530581 if (err)531531- panic(err);582582+ panic(err); /* Failed to decompress INTERNAL initramfs */532583 if (initrd_start) {533584#ifdef CONFIG_BLK_DEV_RAM534585 int fd;···554605 printk(KERN_INFO "Unpacking initramfs...");555606 err = unpack_to_rootfs((char *)initrd_start,556607 initrd_end - initrd_start, 0);557557- if (err)558558- panic(err);559559- printk(" done\n");608608+ if (err) {609609+ printk(" failed!\n");610610+ printk(KERN_EMERG "%s\n", err);611611+ } else {612612+ printk(" done\n");613613+ }560614 free_initrd();561615#endif562616 }
+4-3
kernel/seccomp.c
···8899#include <linux/seccomp.h>1010#include <linux/sched.h>1111+#include <linux/compat.h>11121213/* #define SECCOMP_DEBUG 1 */1314#define NR_SECCOMP_MODES 1···2322 0, /* null terminated */2423};25242626-#ifdef TIF_32BIT2525+#ifdef CONFIG_COMPAT2726static int mode1_syscalls_32[] = {2827 __NR_seccomp_read_32, __NR_seccomp_write_32, __NR_seccomp_exit_32, __NR_seccomp_sigreturn_32,2928 0, /* null terminated */···3837 switch (mode) {3938 case 1:4039 syscall = mode1_syscalls;4141-#ifdef TIF_32BIT4242- if (test_thread_flag(TIF_32BIT))4040+#ifdef CONFIG_COMPAT4141+ if (is_compat_task())4342 syscall = mode1_syscalls_32;4443#endif4544 do {
+17-4
kernel/user_namespace.c
···6060 return 0;6161}62626363-void free_user_ns(struct kref *kref)6363+/*6464+ * Deferred destructor for a user namespace. This is required because6565+ * free_user_ns() may be called with uidhash_lock held, but we need to call6666+ * back to free_uid() which will want to take the lock again.6767+ */6868+static void free_user_ns_work(struct work_struct *work)6469{6565- struct user_namespace *ns;6666-6767- ns = container_of(kref, struct user_namespace, kref);7070+ struct user_namespace *ns =7171+ container_of(work, struct user_namespace, destroyer);6872 free_uid(ns->creator);6973 kfree(ns);7474+}7575+7676+void free_user_ns(struct kref *kref)7777+{7878+ struct user_namespace *ns =7979+ container_of(kref, struct user_namespace, kref);8080+8181+ INIT_WORK(&ns->destroyer, free_user_ns_work);8282+ schedule_work(&ns->destroyer);7083}7184EXPORT_SYMBOL(free_user_ns);
+14
lib/Kconfig
···9898 tristate9999100100#101101+# These all provide a common interface (hence the apparent duplication with102102+# ZLIB_INFLATE; DECOMPRESS_GZIP is just a wrapper.)103103+#104104+config DECOMPRESS_GZIP105105+ select ZLIB_INFLATE106106+ tristate107107+108108+config DECOMPRESS_BZIP2109109+ tristate110110+111111+config DECOMPRESS_LZMA112112+ tristate113113+114114+#101115# Generic allocator support is selected if needed102116#103117config GENERIC_ALLOCATOR
···11+/* vi: set sw = 4 ts = 4: */22+/* Small bzip2 deflate implementation, by Rob Landley (rob@landley.net).33+44+ Based on bzip2 decompression code by Julian R Seward (jseward@acm.org),55+ which also acknowledges contributions by Mike Burrows, David Wheeler,66+ Peter Fenwick, Alistair Moffat, Radford Neal, Ian H. Witten,77+ Robert Sedgewick, and Jon L. Bentley.88+99+ This code is licensed under the LGPLv2:1010+ LGPL (http://www.gnu.org/copyleft/lgpl.html1111+*/1212+1313+/*1414+ Size and speed optimizations by Manuel Novoa III (mjn3@codepoet.org).1515+1616+ More efficient reading of Huffman codes, a streamlined read_bunzip()1717+ function, and various other tweaks. In (limited) tests, approximately1818+ 20% faster than bzcat on x86 and about 10% faster on arm.1919+2020+ Note that about 2/3 of the time is spent in read_unzip() reversing2121+ the Burrows-Wheeler transformation. Much of that time is delay2222+ resulting from cache misses.2323+2424+ I would ask that anyone benefiting from this work, especially those2525+ using it in commercial products, consider making a donation to my local2626+ non-profit hospice organization in the name of the woman I loved, who2727+ passed away Feb. 12, 2003.2828+2929+ In memory of Toni W. Hagan3030+3131+ Hospice of Acadiana, Inc.3232+ 2600 Johnston St., Suite 2003333+ Lafayette, LA 70503-32403434+3535+ Phone (337) 232-1234 or 1-800-738-22263636+ Fax (337) 232-12973737+3838+ http://www.hospiceacadiana.com/3939+4040+ Manuel4141+ */4242+4343+/*4444+ Made it fit for running in Linux Kernel by Alain Knaff (alain@knaff.lu)4545+*/4646+4747+4848+#ifndef STATIC4949+#include <linux/decompress/bunzip2.h>5050+#endif /* !STATIC */5151+5252+#include <linux/decompress/mm.h>5353+5454+#ifndef INT_MAX5555+#define INT_MAX 0x7fffffff5656+#endif5757+5858+/* Constants for Huffman coding */5959+#define MAX_GROUPS 66060+#define GROUP_SIZE 50 /* 64 would have been more efficient */6161+#define MAX_HUFCODE_BITS 20 /* Longest Huffman code allowed */6262+#define MAX_SYMBOLS 258 /* 256 literals + RUNA + RUNB */6363+#define SYMBOL_RUNA 06464+#define SYMBOL_RUNB 16565+6666+/* Status return values */6767+#define RETVAL_OK 06868+#define RETVAL_LAST_BLOCK (-1)6969+#define RETVAL_NOT_BZIP_DATA (-2)7070+#define RETVAL_UNEXPECTED_INPUT_EOF (-3)7171+#define RETVAL_UNEXPECTED_OUTPUT_EOF (-4)7272+#define RETVAL_DATA_ERROR (-5)7373+#define RETVAL_OUT_OF_MEMORY (-6)7474+#define RETVAL_OBSOLETE_INPUT (-7)7575+7676+/* Other housekeeping constants */7777+#define BZIP2_IOBUF_SIZE 40967878+7979+/* This is what we know about each Huffman coding group */8080+struct group_data {8181+ /* We have an extra slot at the end of limit[] for a sentinal value. */8282+ int limit[MAX_HUFCODE_BITS+1];8383+ int base[MAX_HUFCODE_BITS];8484+ int permute[MAX_SYMBOLS];8585+ int minLen, maxLen;8686+};8787+8888+/* Structure holding all the housekeeping data, including IO buffers and8989+ memory that persists between calls to bunzip */9090+struct bunzip_data {9191+ /* State for interrupting output loop */9292+ int writeCopies, writePos, writeRunCountdown, writeCount, writeCurrent;9393+ /* I/O tracking data (file handles, buffers, positions, etc.) */9494+ int (*fill)(void*, unsigned int);9595+ int inbufCount, inbufPos /*, outbufPos*/;9696+ unsigned char *inbuf /*,*outbuf*/;9797+ unsigned int inbufBitCount, inbufBits;9898+ /* The CRC values stored in the block header and calculated from the9999+ data */100100+ unsigned int crc32Table[256], headerCRC, totalCRC, writeCRC;101101+ /* Intermediate buffer and its size (in bytes) */102102+ unsigned int *dbuf, dbufSize;103103+ /* These things are a bit too big to go on the stack */104104+ unsigned char selectors[32768]; /* nSelectors = 15 bits */105105+ struct group_data groups[MAX_GROUPS]; /* Huffman coding tables */106106+ int io_error; /* non-zero if we have IO error */107107+};108108+109109+110110+/* Return the next nnn bits of input. All reads from the compressed input111111+ are done through this function. All reads are big endian */112112+static unsigned int INIT get_bits(struct bunzip_data *bd, char bits_wanted)113113+{114114+ unsigned int bits = 0;115115+116116+ /* If we need to get more data from the byte buffer, do so.117117+ (Loop getting one byte at a time to enforce endianness and avoid118118+ unaligned access.) */119119+ while (bd->inbufBitCount < bits_wanted) {120120+ /* If we need to read more data from file into byte buffer, do121121+ so */122122+ if (bd->inbufPos == bd->inbufCount) {123123+ if (bd->io_error)124124+ return 0;125125+ bd->inbufCount = bd->fill(bd->inbuf, BZIP2_IOBUF_SIZE);126126+ if (bd->inbufCount <= 0) {127127+ bd->io_error = RETVAL_UNEXPECTED_INPUT_EOF;128128+ return 0;129129+ }130130+ bd->inbufPos = 0;131131+ }132132+ /* Avoid 32-bit overflow (dump bit buffer to top of output) */133133+ if (bd->inbufBitCount >= 24) {134134+ bits = bd->inbufBits&((1 << bd->inbufBitCount)-1);135135+ bits_wanted -= bd->inbufBitCount;136136+ bits <<= bits_wanted;137137+ bd->inbufBitCount = 0;138138+ }139139+ /* Grab next 8 bits of input from buffer. */140140+ bd->inbufBits = (bd->inbufBits << 8)|bd->inbuf[bd->inbufPos++];141141+ bd->inbufBitCount += 8;142142+ }143143+ /* Calculate result */144144+ bd->inbufBitCount -= bits_wanted;145145+ bits |= (bd->inbufBits >> bd->inbufBitCount)&((1 << bits_wanted)-1);146146+147147+ return bits;148148+}149149+150150+/* Unpacks the next block and sets up for the inverse burrows-wheeler step. */151151+152152+static int INIT get_next_block(struct bunzip_data *bd)153153+{154154+ struct group_data *hufGroup = NULL;155155+ int *base = NULL;156156+ int *limit = NULL;157157+ int dbufCount, nextSym, dbufSize, groupCount, selector,158158+ i, j, k, t, runPos, symCount, symTotal, nSelectors,159159+ byteCount[256];160160+ unsigned char uc, symToByte[256], mtfSymbol[256], *selectors;161161+ unsigned int *dbuf, origPtr;162162+163163+ dbuf = bd->dbuf;164164+ dbufSize = bd->dbufSize;165165+ selectors = bd->selectors;166166+167167+ /* Read in header signature and CRC, then validate signature.168168+ (last block signature means CRC is for whole file, return now) */169169+ i = get_bits(bd, 24);170170+ j = get_bits(bd, 24);171171+ bd->headerCRC = get_bits(bd, 32);172172+ if ((i == 0x177245) && (j == 0x385090))173173+ return RETVAL_LAST_BLOCK;174174+ if ((i != 0x314159) || (j != 0x265359))175175+ return RETVAL_NOT_BZIP_DATA;176176+ /* We can add support for blockRandomised if anybody complains.177177+ There was some code for this in busybox 1.0.0-pre3, but nobody ever178178+ noticed that it didn't actually work. */179179+ if (get_bits(bd, 1))180180+ return RETVAL_OBSOLETE_INPUT;181181+ origPtr = get_bits(bd, 24);182182+ if (origPtr > dbufSize)183183+ return RETVAL_DATA_ERROR;184184+ /* mapping table: if some byte values are never used (encoding things185185+ like ascii text), the compression code removes the gaps to have fewer186186+ symbols to deal with, and writes a sparse bitfield indicating which187187+ values were present. We make a translation table to convert the188188+ symbols back to the corresponding bytes. */189189+ t = get_bits(bd, 16);190190+ symTotal = 0;191191+ for (i = 0; i < 16; i++) {192192+ if (t&(1 << (15-i))) {193193+ k = get_bits(bd, 16);194194+ for (j = 0; j < 16; j++)195195+ if (k&(1 << (15-j)))196196+ symToByte[symTotal++] = (16*i)+j;197197+ }198198+ }199199+ /* How many different Huffman coding groups does this block use? */200200+ groupCount = get_bits(bd, 3);201201+ if (groupCount < 2 || groupCount > MAX_GROUPS)202202+ return RETVAL_DATA_ERROR;203203+ /* nSelectors: Every GROUP_SIZE many symbols we select a new204204+ Huffman coding group. Read in the group selector list,205205+ which is stored as MTF encoded bit runs. (MTF = Move To206206+ Front, as each value is used it's moved to the start of the207207+ list.) */208208+ nSelectors = get_bits(bd, 15);209209+ if (!nSelectors)210210+ return RETVAL_DATA_ERROR;211211+ for (i = 0; i < groupCount; i++)212212+ mtfSymbol[i] = i;213213+ for (i = 0; i < nSelectors; i++) {214214+ /* Get next value */215215+ for (j = 0; get_bits(bd, 1); j++)216216+ if (j >= groupCount)217217+ return RETVAL_DATA_ERROR;218218+ /* Decode MTF to get the next selector */219219+ uc = mtfSymbol[j];220220+ for (; j; j--)221221+ mtfSymbol[j] = mtfSymbol[j-1];222222+ mtfSymbol[0] = selectors[i] = uc;223223+ }224224+ /* Read the Huffman coding tables for each group, which code225225+ for symTotal literal symbols, plus two run symbols (RUNA,226226+ RUNB) */227227+ symCount = symTotal+2;228228+ for (j = 0; j < groupCount; j++) {229229+ unsigned char length[MAX_SYMBOLS], temp[MAX_HUFCODE_BITS+1];230230+ int minLen, maxLen, pp;231231+ /* Read Huffman code lengths for each symbol. They're232232+ stored in a way similar to mtf; record a starting233233+ value for the first symbol, and an offset from the234234+ previous value for everys symbol after that.235235+ (Subtracting 1 before the loop and then adding it236236+ back at the end is an optimization that makes the237237+ test inside the loop simpler: symbol length 0238238+ becomes negative, so an unsigned inequality catches239239+ it.) */240240+ t = get_bits(bd, 5)-1;241241+ for (i = 0; i < symCount; i++) {242242+ for (;;) {243243+ if (((unsigned)t) > (MAX_HUFCODE_BITS-1))244244+ return RETVAL_DATA_ERROR;245245+246246+ /* If first bit is 0, stop. Else247247+ second bit indicates whether to248248+ increment or decrement the value.249249+ Optimization: grab 2 bits and unget250250+ the second if the first was 0. */251251+252252+ k = get_bits(bd, 2);253253+ if (k < 2) {254254+ bd->inbufBitCount++;255255+ break;256256+ }257257+ /* Add one if second bit 1, else258258+ * subtract 1. Avoids if/else */259259+ t += (((k+1)&2)-1);260260+ }261261+ /* Correct for the initial -1, to get the262262+ * final symbol length */263263+ length[i] = t+1;264264+ }265265+ /* Find largest and smallest lengths in this group */266266+ minLen = maxLen = length[0];267267+268268+ for (i = 1; i < symCount; i++) {269269+ if (length[i] > maxLen)270270+ maxLen = length[i];271271+ else if (length[i] < minLen)272272+ minLen = length[i];273273+ }274274+275275+ /* Calculate permute[], base[], and limit[] tables from276276+ * length[].277277+ *278278+ * permute[] is the lookup table for converting279279+ * Huffman coded symbols into decoded symbols. base[]280280+ * is the amount to subtract from the value of a281281+ * Huffman symbol of a given length when using282282+ * permute[].283283+ *284284+ * limit[] indicates the largest numerical value a285285+ * symbol with a given number of bits can have. This286286+ * is how the Huffman codes can vary in length: each287287+ * code with a value > limit[length] needs another288288+ * bit.289289+ */290290+ hufGroup = bd->groups+j;291291+ hufGroup->minLen = minLen;292292+ hufGroup->maxLen = maxLen;293293+ /* Note that minLen can't be smaller than 1, so we294294+ adjust the base and limit array pointers so we're295295+ not always wasting the first entry. We do this296296+ again when using them (during symbol decoding).*/297297+ base = hufGroup->base-1;298298+ limit = hufGroup->limit-1;299299+ /* Calculate permute[]. Concurently, initialize300300+ * temp[] and limit[]. */301301+ pp = 0;302302+ for (i = minLen; i <= maxLen; i++) {303303+ temp[i] = limit[i] = 0;304304+ for (t = 0; t < symCount; t++)305305+ if (length[t] == i)306306+ hufGroup->permute[pp++] = t;307307+ }308308+ /* Count symbols coded for at each bit length */309309+ for (i = 0; i < symCount; i++)310310+ temp[length[i]]++;311311+ /* Calculate limit[] (the largest symbol-coding value312312+ *at each bit length, which is (previous limit <<313313+ *1)+symbols at this level), and base[] (number of314314+ *symbols to ignore at each bit length, which is limit315315+ *minus the cumulative count of symbols coded for316316+ *already). */317317+ pp = t = 0;318318+ for (i = minLen; i < maxLen; i++) {319319+ pp += temp[i];320320+ /* We read the largest possible symbol size321321+ and then unget bits after determining how322322+ many we need, and those extra bits could be323323+ set to anything. (They're noise from324324+ future symbols.) At each level we're325325+ really only interested in the first few326326+ bits, so here we set all the trailing327327+ to-be-ignored bits to 1 so they don't328328+ affect the value > limit[length]329329+ comparison. */330330+ limit[i] = (pp << (maxLen - i)) - 1;331331+ pp <<= 1;332332+ base[i+1] = pp-(t += temp[i]);333333+ }334334+ limit[maxLen+1] = INT_MAX; /* Sentinal value for335335+ * reading next sym. */336336+ limit[maxLen] = pp+temp[maxLen]-1;337337+ base[minLen] = 0;338338+ }339339+ /* We've finished reading and digesting the block header. Now340340+ read this block's Huffman coded symbols from the file and341341+ undo the Huffman coding and run length encoding, saving the342342+ result into dbuf[dbufCount++] = uc */343343+344344+ /* Initialize symbol occurrence counters and symbol Move To345345+ * Front table */346346+ for (i = 0; i < 256; i++) {347347+ byteCount[i] = 0;348348+ mtfSymbol[i] = (unsigned char)i;349349+ }350350+ /* Loop through compressed symbols. */351351+ runPos = dbufCount = symCount = selector = 0;352352+ for (;;) {353353+ /* Determine which Huffman coding group to use. */354354+ if (!(symCount--)) {355355+ symCount = GROUP_SIZE-1;356356+ if (selector >= nSelectors)357357+ return RETVAL_DATA_ERROR;358358+ hufGroup = bd->groups+selectors[selector++];359359+ base = hufGroup->base-1;360360+ limit = hufGroup->limit-1;361361+ }362362+ /* Read next Huffman-coded symbol. */363363+ /* Note: It is far cheaper to read maxLen bits and364364+ back up than it is to read minLen bits and then an365365+ additional bit at a time, testing as we go.366366+ Because there is a trailing last block (with file367367+ CRC), there is no danger of the overread causing an368368+ unexpected EOF for a valid compressed file. As a369369+ further optimization, we do the read inline370370+ (falling back to a call to get_bits if the buffer371371+ runs dry). The following (up to got_huff_bits:) is372372+ equivalent to j = get_bits(bd, hufGroup->maxLen);373373+ */374374+ while (bd->inbufBitCount < hufGroup->maxLen) {375375+ if (bd->inbufPos == bd->inbufCount) {376376+ j = get_bits(bd, hufGroup->maxLen);377377+ goto got_huff_bits;378378+ }379379+ bd->inbufBits =380380+ (bd->inbufBits << 8)|bd->inbuf[bd->inbufPos++];381381+ bd->inbufBitCount += 8;382382+ };383383+ bd->inbufBitCount -= hufGroup->maxLen;384384+ j = (bd->inbufBits >> bd->inbufBitCount)&385385+ ((1 << hufGroup->maxLen)-1);386386+got_huff_bits:387387+ /* Figure how how many bits are in next symbol and388388+ * unget extras */389389+ i = hufGroup->minLen;390390+ while (j > limit[i])391391+ ++i;392392+ bd->inbufBitCount += (hufGroup->maxLen - i);393393+ /* Huffman decode value to get nextSym (with bounds checking) */394394+ if ((i > hufGroup->maxLen)395395+ || (((unsigned)(j = (j>>(hufGroup->maxLen-i))-base[i]))396396+ >= MAX_SYMBOLS))397397+ return RETVAL_DATA_ERROR;398398+ nextSym = hufGroup->permute[j];399399+ /* We have now decoded the symbol, which indicates400400+ either a new literal byte, or a repeated run of the401401+ most recent literal byte. First, check if nextSym402402+ indicates a repeated run, and if so loop collecting403403+ how many times to repeat the last literal. */404404+ if (((unsigned)nextSym) <= SYMBOL_RUNB) { /* RUNA or RUNB */405405+ /* If this is the start of a new run, zero out406406+ * counter */407407+ if (!runPos) {408408+ runPos = 1;409409+ t = 0;410410+ }411411+ /* Neat trick that saves 1 symbol: instead of412412+ or-ing 0 or 1 at each bit position, add 1413413+ or 2 instead. For example, 1011 is 1 << 0414414+ + 1 << 1 + 2 << 2. 1010 is 2 << 0 + 2 << 1415415+ + 1 << 2. You can make any bit pattern416416+ that way using 1 less symbol than the basic417417+ or 0/1 method (except all bits 0, which418418+ would use no symbols, but a run of length 0419419+ doesn't mean anything in this context).420420+ Thus space is saved. */421421+ t += (runPos << nextSym);422422+ /* +runPos if RUNA; +2*runPos if RUNB */423423+424424+ runPos <<= 1;425425+ continue;426426+ }427427+ /* When we hit the first non-run symbol after a run,428428+ we now know how many times to repeat the last429429+ literal, so append that many copies to our buffer430430+ of decoded symbols (dbuf) now. (The last literal431431+ used is the one at the head of the mtfSymbol432432+ array.) */433433+ if (runPos) {434434+ runPos = 0;435435+ if (dbufCount+t >= dbufSize)436436+ return RETVAL_DATA_ERROR;437437+438438+ uc = symToByte[mtfSymbol[0]];439439+ byteCount[uc] += t;440440+ while (t--)441441+ dbuf[dbufCount++] = uc;442442+ }443443+ /* Is this the terminating symbol? */444444+ if (nextSym > symTotal)445445+ break;446446+ /* At this point, nextSym indicates a new literal447447+ character. Subtract one to get the position in the448448+ MTF array at which this literal is currently to be449449+ found. (Note that the result can't be -1 or 0,450450+ because 0 and 1 are RUNA and RUNB. But another451451+ instance of the first symbol in the mtf array,452452+ position 0, would have been handled as part of a453453+ run above. Therefore 1 unused mtf position minus 2454454+ non-literal nextSym values equals -1.) */455455+ if (dbufCount >= dbufSize)456456+ return RETVAL_DATA_ERROR;457457+ i = nextSym - 1;458458+ uc = mtfSymbol[i];459459+ /* Adjust the MTF array. Since we typically expect to460460+ *move only a small number of symbols, and are bound461461+ *by 256 in any case, using memmove here would462462+ *typically be bigger and slower due to function call463463+ *overhead and other assorted setup costs. */464464+ do {465465+ mtfSymbol[i] = mtfSymbol[i-1];466466+ } while (--i);467467+ mtfSymbol[0] = uc;468468+ uc = symToByte[uc];469469+ /* We have our literal byte. Save it into dbuf. */470470+ byteCount[uc]++;471471+ dbuf[dbufCount++] = (unsigned int)uc;472472+ }473473+ /* At this point, we've read all the Huffman-coded symbols474474+ (and repeated runs) for this block from the input stream,475475+ and decoded them into the intermediate buffer. There are476476+ dbufCount many decoded bytes in dbuf[]. Now undo the477477+ Burrows-Wheeler transform on dbuf. See478478+ http://dogma.net/markn/articles/bwt/bwt.htm479479+ */480480+ /* Turn byteCount into cumulative occurrence counts of 0 to n-1. */481481+ j = 0;482482+ for (i = 0; i < 256; i++) {483483+ k = j+byteCount[i];484484+ byteCount[i] = j;485485+ j = k;486486+ }487487+ /* Figure out what order dbuf would be in if we sorted it. */488488+ for (i = 0; i < dbufCount; i++) {489489+ uc = (unsigned char)(dbuf[i] & 0xff);490490+ dbuf[byteCount[uc]] |= (i << 8);491491+ byteCount[uc]++;492492+ }493493+ /* Decode first byte by hand to initialize "previous" byte.494494+ Note that it doesn't get output, and if the first three495495+ characters are identical it doesn't qualify as a run (hence496496+ writeRunCountdown = 5). */497497+ if (dbufCount) {498498+ if (origPtr >= dbufCount)499499+ return RETVAL_DATA_ERROR;500500+ bd->writePos = dbuf[origPtr];501501+ bd->writeCurrent = (unsigned char)(bd->writePos&0xff);502502+ bd->writePos >>= 8;503503+ bd->writeRunCountdown = 5;504504+ }505505+ bd->writeCount = dbufCount;506506+507507+ return RETVAL_OK;508508+}509509+510510+/* Undo burrows-wheeler transform on intermediate buffer to produce output.511511+ If start_bunzip was initialized with out_fd =-1, then up to len bytes of512512+ data are written to outbuf. Return value is number of bytes written or513513+ error (all errors are negative numbers). If out_fd!=-1, outbuf and len514514+ are ignored, data is written to out_fd and return is RETVAL_OK or error.515515+*/516516+517517+static int INIT read_bunzip(struct bunzip_data *bd, char *outbuf, int len)518518+{519519+ const unsigned int *dbuf;520520+ int pos, xcurrent, previous, gotcount;521521+522522+ /* If last read was short due to end of file, return last block now */523523+ if (bd->writeCount < 0)524524+ return bd->writeCount;525525+526526+ gotcount = 0;527527+ dbuf = bd->dbuf;528528+ pos = bd->writePos;529529+ xcurrent = bd->writeCurrent;530530+531531+ /* We will always have pending decoded data to write into the output532532+ buffer unless this is the very first call (in which case we haven't533533+ Huffman-decoded a block into the intermediate buffer yet). */534534+535535+ if (bd->writeCopies) {536536+ /* Inside the loop, writeCopies means extra copies (beyond 1) */537537+ --bd->writeCopies;538538+ /* Loop outputting bytes */539539+ for (;;) {540540+ /* If the output buffer is full, snapshot541541+ * state and return */542542+ if (gotcount >= len) {543543+ bd->writePos = pos;544544+ bd->writeCurrent = xcurrent;545545+ bd->writeCopies++;546546+ return len;547547+ }548548+ /* Write next byte into output buffer, updating CRC */549549+ outbuf[gotcount++] = xcurrent;550550+ bd->writeCRC = (((bd->writeCRC) << 8)551551+ ^bd->crc32Table[((bd->writeCRC) >> 24)552552+ ^xcurrent]);553553+ /* Loop now if we're outputting multiple554554+ * copies of this byte */555555+ if (bd->writeCopies) {556556+ --bd->writeCopies;557557+ continue;558558+ }559559+decode_next_byte:560560+ if (!bd->writeCount--)561561+ break;562562+ /* Follow sequence vector to undo563563+ * Burrows-Wheeler transform */564564+ previous = xcurrent;565565+ pos = dbuf[pos];566566+ xcurrent = pos&0xff;567567+ pos >>= 8;568568+ /* After 3 consecutive copies of the same569569+ byte, the 4th is a repeat count. We count570570+ down from 4 instead *of counting up because571571+ testing for non-zero is faster */572572+ if (--bd->writeRunCountdown) {573573+ if (xcurrent != previous)574574+ bd->writeRunCountdown = 4;575575+ } else {576576+ /* We have a repeated run, this byte577577+ * indicates the count */578578+ bd->writeCopies = xcurrent;579579+ xcurrent = previous;580580+ bd->writeRunCountdown = 5;581581+ /* Sometimes there are just 3 bytes582582+ * (run length 0) */583583+ if (!bd->writeCopies)584584+ goto decode_next_byte;585585+ /* Subtract the 1 copy we'd output586586+ * anyway to get extras */587587+ --bd->writeCopies;588588+ }589589+ }590590+ /* Decompression of this block completed successfully */591591+ bd->writeCRC = ~bd->writeCRC;592592+ bd->totalCRC = ((bd->totalCRC << 1) |593593+ (bd->totalCRC >> 31)) ^ bd->writeCRC;594594+ /* If this block had a CRC error, force file level CRC error. */595595+ if (bd->writeCRC != bd->headerCRC) {596596+ bd->totalCRC = bd->headerCRC+1;597597+ return RETVAL_LAST_BLOCK;598598+ }599599+ }600600+601601+ /* Refill the intermediate buffer by Huffman-decoding next602602+ * block of input */603603+ /* (previous is just a convenient unused temp variable here) */604604+ previous = get_next_block(bd);605605+ if (previous) {606606+ bd->writeCount = previous;607607+ return (previous != RETVAL_LAST_BLOCK) ? previous : gotcount;608608+ }609609+ bd->writeCRC = 0xffffffffUL;610610+ pos = bd->writePos;611611+ xcurrent = bd->writeCurrent;612612+ goto decode_next_byte;613613+}614614+615615+static int INIT nofill(void *buf, unsigned int len)616616+{617617+ return -1;618618+}619619+620620+/* Allocate the structure, read file header. If in_fd ==-1, inbuf must contain621621+ a complete bunzip file (len bytes long). If in_fd!=-1, inbuf and len are622622+ ignored, and data is read from file handle into temporary buffer. */623623+static int INIT start_bunzip(struct bunzip_data **bdp, void *inbuf, int len,624624+ int (*fill)(void*, unsigned int))625625+{626626+ struct bunzip_data *bd;627627+ unsigned int i, j, c;628628+ const unsigned int BZh0 =629629+ (((unsigned int)'B') << 24)+(((unsigned int)'Z') << 16)630630+ +(((unsigned int)'h') << 8)+(unsigned int)'0';631631+632632+ /* Figure out how much data to allocate */633633+ i = sizeof(struct bunzip_data);634634+635635+ /* Allocate bunzip_data. Most fields initialize to zero. */636636+ bd = *bdp = malloc(i);637637+ memset(bd, 0, sizeof(struct bunzip_data));638638+ /* Setup input buffer */639639+ bd->inbuf = inbuf;640640+ bd->inbufCount = len;641641+ if (fill != NULL)642642+ bd->fill = fill;643643+ else644644+ bd->fill = nofill;645645+646646+ /* Init the CRC32 table (big endian) */647647+ for (i = 0; i < 256; i++) {648648+ c = i << 24;649649+ for (j = 8; j; j--)650650+ c = c&0x80000000 ? (c << 1)^0x04c11db7 : (c << 1);651651+ bd->crc32Table[i] = c;652652+ }653653+654654+ /* Ensure that file starts with "BZh['1'-'9']." */655655+ i = get_bits(bd, 32);656656+ if (((unsigned int)(i-BZh0-1)) >= 9)657657+ return RETVAL_NOT_BZIP_DATA;658658+659659+ /* Fourth byte (ascii '1'-'9'), indicates block size in units of 100k of660660+ uncompressed data. Allocate intermediate buffer for block. */661661+ bd->dbufSize = 100000*(i-BZh0);662662+663663+ bd->dbuf = large_malloc(bd->dbufSize * sizeof(int));664664+ return RETVAL_OK;665665+}666666+667667+/* Example usage: decompress src_fd to dst_fd. (Stops at end of bzip2 data,668668+ not end of file.) */669669+STATIC int INIT bunzip2(unsigned char *buf, int len,670670+ int(*fill)(void*, unsigned int),671671+ int(*flush)(void*, unsigned int),672672+ unsigned char *outbuf,673673+ int *pos,674674+ void(*error_fn)(char *x))675675+{676676+ struct bunzip_data *bd;677677+ int i = -1;678678+ unsigned char *inbuf;679679+680680+ set_error_fn(error_fn);681681+ if (flush)682682+ outbuf = malloc(BZIP2_IOBUF_SIZE);683683+ else684684+ len -= 4; /* Uncompressed size hack active in pre-boot685685+ environment */686686+ if (!outbuf) {687687+ error("Could not allocate output bufer");688688+ return -1;689689+ }690690+ if (buf)691691+ inbuf = buf;692692+ else693693+ inbuf = malloc(BZIP2_IOBUF_SIZE);694694+ if (!inbuf) {695695+ error("Could not allocate input bufer");696696+ goto exit_0;697697+ }698698+ i = start_bunzip(&bd, inbuf, len, fill);699699+ if (!i) {700700+ for (;;) {701701+ i = read_bunzip(bd, outbuf, BZIP2_IOBUF_SIZE);702702+ if (i <= 0)703703+ break;704704+ if (!flush)705705+ outbuf += i;706706+ else707707+ if (i != flush(outbuf, i)) {708708+ i = RETVAL_UNEXPECTED_OUTPUT_EOF;709709+ break;710710+ }711711+ }712712+ }713713+ /* Check CRC and release memory */714714+ if (i == RETVAL_LAST_BLOCK) {715715+ if (bd->headerCRC != bd->totalCRC)716716+ error("Data integrity error when decompressing.");717717+ else718718+ i = RETVAL_OK;719719+ } else if (i == RETVAL_UNEXPECTED_OUTPUT_EOF) {720720+ error("Compressed file ends unexpectedly");721721+ }722722+ if (bd->dbuf)723723+ large_free(bd->dbuf);724724+ if (pos)725725+ *pos = bd->inbufPos;726726+ free(bd);727727+ if (!buf)728728+ free(inbuf);729729+exit_0:730730+ if (flush)731731+ free(outbuf);732732+ return i;733733+}734734+735735+#define decompress bunzip2
+167
lib/decompress_inflate.c
···11+#ifdef STATIC22+/* Pre-boot environment: included */33+44+/* prevent inclusion of _LINUX_KERNEL_H in pre-boot environment: lots55+ * errors about console_printk etc... on ARM */66+#define _LINUX_KERNEL_H77+88+#include "zlib_inflate/inftrees.c"99+#include "zlib_inflate/inffast.c"1010+#include "zlib_inflate/inflate.c"1111+1212+#else /* STATIC */1313+/* initramfs et al: linked */1414+1515+#include <linux/zutil.h>1616+1717+#include "zlib_inflate/inftrees.h"1818+#include "zlib_inflate/inffast.h"1919+#include "zlib_inflate/inflate.h"2020+2121+#include "zlib_inflate/infutil.h"2222+2323+#endif /* STATIC */2424+2525+#include <linux/decompress/mm.h>2626+2727+#define INBUF_LEN (16*1024)2828+2929+/* Included from initramfs et al code */3030+STATIC int INIT gunzip(unsigned char *buf, int len,3131+ int(*fill)(void*, unsigned int),3232+ int(*flush)(void*, unsigned int),3333+ unsigned char *out_buf,3434+ int *pos,3535+ void(*error_fn)(char *x)) {3636+ u8 *zbuf;3737+ struct z_stream_s *strm;3838+ int rc;3939+ size_t out_len;4040+4141+ set_error_fn(error_fn);4242+ rc = -1;4343+ if (flush) {4444+ out_len = 0x8000; /* 32 K */4545+ out_buf = malloc(out_len);4646+ } else {4747+ out_len = 0x7fffffff; /* no limit */4848+ }4949+ if (!out_buf) {5050+ error("Out of memory while allocating output buffer");5151+ goto gunzip_nomem1;5252+ }5353+5454+ if (buf)5555+ zbuf = buf;5656+ else {5757+ zbuf = malloc(INBUF_LEN);5858+ len = 0;5959+ }6060+ if (!zbuf) {6161+ error("Out of memory while allocating input buffer");6262+ goto gunzip_nomem2;6363+ }6464+6565+ strm = malloc(sizeof(*strm));6666+ if (strm == NULL) {6767+ error("Out of memory while allocating z_stream");6868+ goto gunzip_nomem3;6969+ }7070+7171+ strm->workspace = malloc(flush ? zlib_inflate_workspacesize() :7272+ sizeof(struct inflate_state));7373+ if (strm->workspace == NULL) {7474+ error("Out of memory while allocating workspace");7575+ goto gunzip_nomem4;7676+ }7777+7878+ if (len == 0)7979+ len = fill(zbuf, INBUF_LEN);8080+8181+ /* verify the gzip header */8282+ if (len < 10 ||8383+ zbuf[0] != 0x1f || zbuf[1] != 0x8b || zbuf[2] != 0x08) {8484+ if (pos)8585+ *pos = 0;8686+ error("Not a gzip file");8787+ goto gunzip_5;8888+ }8989+9090+ /* skip over gzip header (1f,8b,08... 10 bytes total +9191+ * possible asciz filename)9292+ */9393+ strm->next_in = zbuf + 10;9494+ /* skip over asciz filename */9595+ if (zbuf[3] & 0x8) {9696+ while (strm->next_in[0])9797+ strm->next_in++;9898+ strm->next_in++;9999+ }100100+ strm->avail_in = len - (strm->next_in - zbuf);101101+102102+ strm->next_out = out_buf;103103+ strm->avail_out = out_len;104104+105105+ rc = zlib_inflateInit2(strm, -MAX_WBITS);106106+107107+ if (!flush) {108108+ WS(strm)->inflate_state.wsize = 0;109109+ WS(strm)->inflate_state.window = NULL;110110+ }111111+112112+ while (rc == Z_OK) {113113+ if (strm->avail_in == 0) {114114+ /* TODO: handle case where both pos and fill are set */115115+ len = fill(zbuf, INBUF_LEN);116116+ if (len < 0) {117117+ rc = -1;118118+ error("read error");119119+ break;120120+ }121121+ strm->next_in = zbuf;122122+ strm->avail_in = len;123123+ }124124+ rc = zlib_inflate(strm, 0);125125+126126+ /* Write any data generated */127127+ if (flush && strm->next_out > out_buf) {128128+ int l = strm->next_out - out_buf;129129+ if (l != flush(out_buf, l)) {130130+ rc = -1;131131+ error("write error");132132+ break;133133+ }134134+ strm->next_out = out_buf;135135+ strm->avail_out = out_len;136136+ }137137+138138+ /* after Z_FINISH, only Z_STREAM_END is "we unpacked it all" */139139+ if (rc == Z_STREAM_END) {140140+ rc = 0;141141+ break;142142+ } else if (rc != Z_OK) {143143+ error("uncompression error");144144+ rc = -1;145145+ }146146+ }147147+148148+ zlib_inflateEnd(strm);149149+ if (pos)150150+ /* add + 8 to skip over trailer */151151+ *pos = strm->next_in - zbuf+8;152152+153153+gunzip_5:154154+ free(strm->workspace);155155+gunzip_nomem4:156156+ free(strm);157157+gunzip_nomem3:158158+ if (!buf)159159+ free(zbuf);160160+gunzip_nomem2:161161+ if (flush)162162+ free(out_buf);163163+gunzip_nomem1:164164+ return rc; /* returns Z_OK (0) if successful */165165+}166166+167167+#define decompress gunzip
+647
lib/decompress_unlzma.c
···11+/* Lzma decompressor for Linux kernel. Shamelessly snarfed22+ *from busybox 1.1.133+ *44+ *Linux kernel adaptation55+ *Copyright (C) 2006 Alain < alain@knaff.lu >66+ *77+ *Based on small lzma deflate implementation/Small range coder88+ *implementation for lzma.99+ *Copyright (C) 2006 Aurelien Jacobs < aurel@gnuage.org >1010+ *1111+ *Based on LzmaDecode.c from the LZMA SDK 4.22 (http://www.7-zip.org/)1212+ *Copyright (C) 1999-2005 Igor Pavlov1313+ *1414+ *Copyrights of the parts, see headers below.1515+ *1616+ *1717+ *This program is free software; you can redistribute it and/or1818+ *modify it under the terms of the GNU Lesser General Public1919+ *License as published by the Free Software Foundation; either2020+ *version 2.1 of the License, or (at your option) any later version.2121+ *2222+ *This program is distributed in the hope that it will be useful,2323+ *but WITHOUT ANY WARRANTY; without even the implied warranty of2424+ *MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU2525+ *Lesser General Public License for more details.2626+ *2727+ *You should have received a copy of the GNU Lesser General Public2828+ *License along with this library; if not, write to the Free Software2929+ *Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA3030+ */3131+3232+#ifndef STATIC3333+#include <linux/decompress/unlzma.h>3434+#endif /* STATIC */3535+3636+#include <linux/decompress/mm.h>3737+3838+#define MIN(a, b) (((a) < (b)) ? (a) : (b))3939+4040+static long long INIT read_int(unsigned char *ptr, int size)4141+{4242+ int i;4343+ long long ret = 0;4444+4545+ for (i = 0; i < size; i++)4646+ ret = (ret << 8) | ptr[size-i-1];4747+ return ret;4848+}4949+5050+#define ENDIAN_CONVERT(x) \5151+ x = (typeof(x))read_int((unsigned char *)&x, sizeof(x))5252+5353+5454+/* Small range coder implementation for lzma.5555+ *Copyright (C) 2006 Aurelien Jacobs < aurel@gnuage.org >5656+ *5757+ *Based on LzmaDecode.c from the LZMA SDK 4.22 (http://www.7-zip.org/)5858+ *Copyright (c) 1999-2005 Igor Pavlov5959+ */6060+6161+#include <linux/compiler.h>6262+6363+#define LZMA_IOBUF_SIZE 0x100006464+6565+struct rc {6666+ int (*fill)(void*, unsigned int);6767+ uint8_t *ptr;6868+ uint8_t *buffer;6969+ uint8_t *buffer_end;7070+ int buffer_size;7171+ uint32_t code;7272+ uint32_t range;7373+ uint32_t bound;7474+};7575+7676+7777+#define RC_TOP_BITS 247878+#define RC_MOVE_BITS 57979+#define RC_MODEL_TOTAL_BITS 118080+8181+8282+/* Called twice: once at startup and once in rc_normalize() */8383+static void INIT rc_read(struct rc *rc)8484+{8585+ rc->buffer_size = rc->fill((char *)rc->buffer, LZMA_IOBUF_SIZE);8686+ if (rc->buffer_size <= 0)8787+ error("unexpected EOF");8888+ rc->ptr = rc->buffer;8989+ rc->buffer_end = rc->buffer + rc->buffer_size;9090+}9191+9292+/* Called once */9393+static inline void INIT rc_init(struct rc *rc,9494+ int (*fill)(void*, unsigned int),9595+ char *buffer, int buffer_size)9696+{9797+ rc->fill = fill;9898+ rc->buffer = (uint8_t *)buffer;9999+ rc->buffer_size = buffer_size;100100+ rc->buffer_end = rc->buffer + rc->buffer_size;101101+ rc->ptr = rc->buffer;102102+103103+ rc->code = 0;104104+ rc->range = 0xFFFFFFFF;105105+}106106+107107+static inline void INIT rc_init_code(struct rc *rc)108108+{109109+ int i;110110+111111+ for (i = 0; i < 5; i++) {112112+ if (rc->ptr >= rc->buffer_end)113113+ rc_read(rc);114114+ rc->code = (rc->code << 8) | *rc->ptr++;115115+ }116116+}117117+118118+119119+/* Called once. TODO: bb_maybe_free() */120120+static inline void INIT rc_free(struct rc *rc)121121+{122122+ free(rc->buffer);123123+}124124+125125+/* Called twice, but one callsite is in inline'd rc_is_bit_0_helper() */126126+static void INIT rc_do_normalize(struct rc *rc)127127+{128128+ if (rc->ptr >= rc->buffer_end)129129+ rc_read(rc);130130+ rc->range <<= 8;131131+ rc->code = (rc->code << 8) | *rc->ptr++;132132+}133133+static inline void INIT rc_normalize(struct rc *rc)134134+{135135+ if (rc->range < (1 << RC_TOP_BITS))136136+ rc_do_normalize(rc);137137+}138138+139139+/* Called 9 times */140140+/* Why rc_is_bit_0_helper exists?141141+ *Because we want to always expose (rc->code < rc->bound) to optimizer142142+ */143143+static inline uint32_t INIT rc_is_bit_0_helper(struct rc *rc, uint16_t *p)144144+{145145+ rc_normalize(rc);146146+ rc->bound = *p * (rc->range >> RC_MODEL_TOTAL_BITS);147147+ return rc->bound;148148+}149149+static inline int INIT rc_is_bit_0(struct rc *rc, uint16_t *p)150150+{151151+ uint32_t t = rc_is_bit_0_helper(rc, p);152152+ return rc->code < t;153153+}154154+155155+/* Called ~10 times, but very small, thus inlined */156156+static inline void INIT rc_update_bit_0(struct rc *rc, uint16_t *p)157157+{158158+ rc->range = rc->bound;159159+ *p += ((1 << RC_MODEL_TOTAL_BITS) - *p) >> RC_MOVE_BITS;160160+}161161+static inline void rc_update_bit_1(struct rc *rc, uint16_t *p)162162+{163163+ rc->range -= rc->bound;164164+ rc->code -= rc->bound;165165+ *p -= *p >> RC_MOVE_BITS;166166+}167167+168168+/* Called 4 times in unlzma loop */169169+static int INIT rc_get_bit(struct rc *rc, uint16_t *p, int *symbol)170170+{171171+ if (rc_is_bit_0(rc, p)) {172172+ rc_update_bit_0(rc, p);173173+ *symbol *= 2;174174+ return 0;175175+ } else {176176+ rc_update_bit_1(rc, p);177177+ *symbol = *symbol * 2 + 1;178178+ return 1;179179+ }180180+}181181+182182+/* Called once */183183+static inline int INIT rc_direct_bit(struct rc *rc)184184+{185185+ rc_normalize(rc);186186+ rc->range >>= 1;187187+ if (rc->code >= rc->range) {188188+ rc->code -= rc->range;189189+ return 1;190190+ }191191+ return 0;192192+}193193+194194+/* Called twice */195195+static inline void INIT196196+rc_bit_tree_decode(struct rc *rc, uint16_t *p, int num_levels, int *symbol)197197+{198198+ int i = num_levels;199199+200200+ *symbol = 1;201201+ while (i--)202202+ rc_get_bit(rc, p + *symbol, symbol);203203+ *symbol -= 1 << num_levels;204204+}205205+206206+207207+/*208208+ * Small lzma deflate implementation.209209+ * Copyright (C) 2006 Aurelien Jacobs < aurel@gnuage.org >210210+ *211211+ * Based on LzmaDecode.c from the LZMA SDK 4.22 (http://www.7-zip.org/)212212+ * Copyright (C) 1999-2005 Igor Pavlov213213+ */214214+215215+216216+struct lzma_header {217217+ uint8_t pos;218218+ uint32_t dict_size;219219+ uint64_t dst_size;220220+} __attribute__ ((packed)) ;221221+222222+223223+#define LZMA_BASE_SIZE 1846224224+#define LZMA_LIT_SIZE 768225225+226226+#define LZMA_NUM_POS_BITS_MAX 4227227+228228+#define LZMA_LEN_NUM_LOW_BITS 3229229+#define LZMA_LEN_NUM_MID_BITS 3230230+#define LZMA_LEN_NUM_HIGH_BITS 8231231+232232+#define LZMA_LEN_CHOICE 0233233+#define LZMA_LEN_CHOICE_2 (LZMA_LEN_CHOICE + 1)234234+#define LZMA_LEN_LOW (LZMA_LEN_CHOICE_2 + 1)235235+#define LZMA_LEN_MID (LZMA_LEN_LOW \236236+ + (1 << (LZMA_NUM_POS_BITS_MAX + LZMA_LEN_NUM_LOW_BITS)))237237+#define LZMA_LEN_HIGH (LZMA_LEN_MID \238238+ +(1 << (LZMA_NUM_POS_BITS_MAX + LZMA_LEN_NUM_MID_BITS)))239239+#define LZMA_NUM_LEN_PROBS (LZMA_LEN_HIGH + (1 << LZMA_LEN_NUM_HIGH_BITS))240240+241241+#define LZMA_NUM_STATES 12242242+#define LZMA_NUM_LIT_STATES 7243243+244244+#define LZMA_START_POS_MODEL_INDEX 4245245+#define LZMA_END_POS_MODEL_INDEX 14246246+#define LZMA_NUM_FULL_DISTANCES (1 << (LZMA_END_POS_MODEL_INDEX >> 1))247247+248248+#define LZMA_NUM_POS_SLOT_BITS 6249249+#define LZMA_NUM_LEN_TO_POS_STATES 4250250+251251+#define LZMA_NUM_ALIGN_BITS 4252252+253253+#define LZMA_MATCH_MIN_LEN 2254254+255255+#define LZMA_IS_MATCH 0256256+#define LZMA_IS_REP (LZMA_IS_MATCH + (LZMA_NUM_STATES << LZMA_NUM_POS_BITS_MAX))257257+#define LZMA_IS_REP_G0 (LZMA_IS_REP + LZMA_NUM_STATES)258258+#define LZMA_IS_REP_G1 (LZMA_IS_REP_G0 + LZMA_NUM_STATES)259259+#define LZMA_IS_REP_G2 (LZMA_IS_REP_G1 + LZMA_NUM_STATES)260260+#define LZMA_IS_REP_0_LONG (LZMA_IS_REP_G2 + LZMA_NUM_STATES)261261+#define LZMA_POS_SLOT (LZMA_IS_REP_0_LONG \262262+ + (LZMA_NUM_STATES << LZMA_NUM_POS_BITS_MAX))263263+#define LZMA_SPEC_POS (LZMA_POS_SLOT \264264+ +(LZMA_NUM_LEN_TO_POS_STATES << LZMA_NUM_POS_SLOT_BITS))265265+#define LZMA_ALIGN (LZMA_SPEC_POS \266266+ + LZMA_NUM_FULL_DISTANCES - LZMA_END_POS_MODEL_INDEX)267267+#define LZMA_LEN_CODER (LZMA_ALIGN + (1 << LZMA_NUM_ALIGN_BITS))268268+#define LZMA_REP_LEN_CODER (LZMA_LEN_CODER + LZMA_NUM_LEN_PROBS)269269+#define LZMA_LITERAL (LZMA_REP_LEN_CODER + LZMA_NUM_LEN_PROBS)270270+271271+272272+struct writer {273273+ uint8_t *buffer;274274+ uint8_t previous_byte;275275+ size_t buffer_pos;276276+ int bufsize;277277+ size_t global_pos;278278+ int(*flush)(void*, unsigned int);279279+ struct lzma_header *header;280280+};281281+282282+struct cstate {283283+ int state;284284+ uint32_t rep0, rep1, rep2, rep3;285285+};286286+287287+static inline size_t INIT get_pos(struct writer *wr)288288+{289289+ return290290+ wr->global_pos + wr->buffer_pos;291291+}292292+293293+static inline uint8_t INIT peek_old_byte(struct writer *wr,294294+ uint32_t offs)295295+{296296+ if (!wr->flush) {297297+ int32_t pos;298298+ while (offs > wr->header->dict_size)299299+ offs -= wr->header->dict_size;300300+ pos = wr->buffer_pos - offs;301301+ return wr->buffer[pos];302302+ } else {303303+ uint32_t pos = wr->buffer_pos - offs;304304+ while (pos >= wr->header->dict_size)305305+ pos += wr->header->dict_size;306306+ return wr->buffer[pos];307307+ }308308+309309+}310310+311311+static inline void INIT write_byte(struct writer *wr, uint8_t byte)312312+{313313+ wr->buffer[wr->buffer_pos++] = wr->previous_byte = byte;314314+ if (wr->flush && wr->buffer_pos == wr->header->dict_size) {315315+ wr->buffer_pos = 0;316316+ wr->global_pos += wr->header->dict_size;317317+ wr->flush((char *)wr->buffer, wr->header->dict_size);318318+ }319319+}320320+321321+322322+static inline void INIT copy_byte(struct writer *wr, uint32_t offs)323323+{324324+ write_byte(wr, peek_old_byte(wr, offs));325325+}326326+327327+static inline void INIT copy_bytes(struct writer *wr,328328+ uint32_t rep0, int len)329329+{330330+ do {331331+ copy_byte(wr, rep0);332332+ len--;333333+ } while (len != 0 && wr->buffer_pos < wr->header->dst_size);334334+}335335+336336+static inline void INIT process_bit0(struct writer *wr, struct rc *rc,337337+ struct cstate *cst, uint16_t *p,338338+ int pos_state, uint16_t *prob,339339+ int lc, uint32_t literal_pos_mask) {340340+ int mi = 1;341341+ rc_update_bit_0(rc, prob);342342+ prob = (p + LZMA_LITERAL +343343+ (LZMA_LIT_SIZE344344+ * (((get_pos(wr) & literal_pos_mask) << lc)345345+ + (wr->previous_byte >> (8 - lc))))346346+ );347347+348348+ if (cst->state >= LZMA_NUM_LIT_STATES) {349349+ int match_byte = peek_old_byte(wr, cst->rep0);350350+ do {351351+ int bit;352352+ uint16_t *prob_lit;353353+354354+ match_byte <<= 1;355355+ bit = match_byte & 0x100;356356+ prob_lit = prob + 0x100 + bit + mi;357357+ if (rc_get_bit(rc, prob_lit, &mi)) {358358+ if (!bit)359359+ break;360360+ } else {361361+ if (bit)362362+ break;363363+ }364364+ } while (mi < 0x100);365365+ }366366+ while (mi < 0x100) {367367+ uint16_t *prob_lit = prob + mi;368368+ rc_get_bit(rc, prob_lit, &mi);369369+ }370370+ write_byte(wr, mi);371371+ if (cst->state < 4)372372+ cst->state = 0;373373+ else if (cst->state < 10)374374+ cst->state -= 3;375375+ else376376+ cst->state -= 6;377377+}378378+379379+static inline void INIT process_bit1(struct writer *wr, struct rc *rc,380380+ struct cstate *cst, uint16_t *p,381381+ int pos_state, uint16_t *prob) {382382+ int offset;383383+ uint16_t *prob_len;384384+ int num_bits;385385+ int len;386386+387387+ rc_update_bit_1(rc, prob);388388+ prob = p + LZMA_IS_REP + cst->state;389389+ if (rc_is_bit_0(rc, prob)) {390390+ rc_update_bit_0(rc, prob);391391+ cst->rep3 = cst->rep2;392392+ cst->rep2 = cst->rep1;393393+ cst->rep1 = cst->rep0;394394+ cst->state = cst->state < LZMA_NUM_LIT_STATES ? 0 : 3;395395+ prob = p + LZMA_LEN_CODER;396396+ } else {397397+ rc_update_bit_1(rc, prob);398398+ prob = p + LZMA_IS_REP_G0 + cst->state;399399+ if (rc_is_bit_0(rc, prob)) {400400+ rc_update_bit_0(rc, prob);401401+ prob = (p + LZMA_IS_REP_0_LONG402402+ + (cst->state <<403403+ LZMA_NUM_POS_BITS_MAX) +404404+ pos_state);405405+ if (rc_is_bit_0(rc, prob)) {406406+ rc_update_bit_0(rc, prob);407407+408408+ cst->state = cst->state < LZMA_NUM_LIT_STATES ?409409+ 9 : 11;410410+ copy_byte(wr, cst->rep0);411411+ return;412412+ } else {413413+ rc_update_bit_1(rc, prob);414414+ }415415+ } else {416416+ uint32_t distance;417417+418418+ rc_update_bit_1(rc, prob);419419+ prob = p + LZMA_IS_REP_G1 + cst->state;420420+ if (rc_is_bit_0(rc, prob)) {421421+ rc_update_bit_0(rc, prob);422422+ distance = cst->rep1;423423+ } else {424424+ rc_update_bit_1(rc, prob);425425+ prob = p + LZMA_IS_REP_G2 + cst->state;426426+ if (rc_is_bit_0(rc, prob)) {427427+ rc_update_bit_0(rc, prob);428428+ distance = cst->rep2;429429+ } else {430430+ rc_update_bit_1(rc, prob);431431+ distance = cst->rep3;432432+ cst->rep3 = cst->rep2;433433+ }434434+ cst->rep2 = cst->rep1;435435+ }436436+ cst->rep1 = cst->rep0;437437+ cst->rep0 = distance;438438+ }439439+ cst->state = cst->state < LZMA_NUM_LIT_STATES ? 8 : 11;440440+ prob = p + LZMA_REP_LEN_CODER;441441+ }442442+443443+ prob_len = prob + LZMA_LEN_CHOICE;444444+ if (rc_is_bit_0(rc, prob_len)) {445445+ rc_update_bit_0(rc, prob_len);446446+ prob_len = (prob + LZMA_LEN_LOW447447+ + (pos_state <<448448+ LZMA_LEN_NUM_LOW_BITS));449449+ offset = 0;450450+ num_bits = LZMA_LEN_NUM_LOW_BITS;451451+ } else {452452+ rc_update_bit_1(rc, prob_len);453453+ prob_len = prob + LZMA_LEN_CHOICE_2;454454+ if (rc_is_bit_0(rc, prob_len)) {455455+ rc_update_bit_0(rc, prob_len);456456+ prob_len = (prob + LZMA_LEN_MID457457+ + (pos_state <<458458+ LZMA_LEN_NUM_MID_BITS));459459+ offset = 1 << LZMA_LEN_NUM_LOW_BITS;460460+ num_bits = LZMA_LEN_NUM_MID_BITS;461461+ } else {462462+ rc_update_bit_1(rc, prob_len);463463+ prob_len = prob + LZMA_LEN_HIGH;464464+ offset = ((1 << LZMA_LEN_NUM_LOW_BITS)465465+ + (1 << LZMA_LEN_NUM_MID_BITS));466466+ num_bits = LZMA_LEN_NUM_HIGH_BITS;467467+ }468468+ }469469+470470+ rc_bit_tree_decode(rc, prob_len, num_bits, &len);471471+ len += offset;472472+473473+ if (cst->state < 4) {474474+ int pos_slot;475475+476476+ cst->state += LZMA_NUM_LIT_STATES;477477+ prob =478478+ p + LZMA_POS_SLOT +479479+ ((len <480480+ LZMA_NUM_LEN_TO_POS_STATES ? len :481481+ LZMA_NUM_LEN_TO_POS_STATES - 1)482482+ << LZMA_NUM_POS_SLOT_BITS);483483+ rc_bit_tree_decode(rc, prob,484484+ LZMA_NUM_POS_SLOT_BITS,485485+ &pos_slot);486486+ if (pos_slot >= LZMA_START_POS_MODEL_INDEX) {487487+ int i, mi;488488+ num_bits = (pos_slot >> 1) - 1;489489+ cst->rep0 = 2 | (pos_slot & 1);490490+ if (pos_slot < LZMA_END_POS_MODEL_INDEX) {491491+ cst->rep0 <<= num_bits;492492+ prob = p + LZMA_SPEC_POS +493493+ cst->rep0 - pos_slot - 1;494494+ } else {495495+ num_bits -= LZMA_NUM_ALIGN_BITS;496496+ while (num_bits--)497497+ cst->rep0 = (cst->rep0 << 1) |498498+ rc_direct_bit(rc);499499+ prob = p + LZMA_ALIGN;500500+ cst->rep0 <<= LZMA_NUM_ALIGN_BITS;501501+ num_bits = LZMA_NUM_ALIGN_BITS;502502+ }503503+ i = 1;504504+ mi = 1;505505+ while (num_bits--) {506506+ if (rc_get_bit(rc, prob + mi, &mi))507507+ cst->rep0 |= i;508508+ i <<= 1;509509+ }510510+ } else511511+ cst->rep0 = pos_slot;512512+ if (++(cst->rep0) == 0)513513+ return;514514+ }515515+516516+ len += LZMA_MATCH_MIN_LEN;517517+518518+ copy_bytes(wr, cst->rep0, len);519519+}520520+521521+522522+523523+STATIC inline int INIT unlzma(unsigned char *buf, int in_len,524524+ int(*fill)(void*, unsigned int),525525+ int(*flush)(void*, unsigned int),526526+ unsigned char *output,527527+ int *posp,528528+ void(*error_fn)(char *x)529529+ )530530+{531531+ struct lzma_header header;532532+ int lc, pb, lp;533533+ uint32_t pos_state_mask;534534+ uint32_t literal_pos_mask;535535+ uint16_t *p;536536+ int num_probs;537537+ struct rc rc;538538+ int i, mi;539539+ struct writer wr;540540+ struct cstate cst;541541+ unsigned char *inbuf;542542+ int ret = -1;543543+544544+ set_error_fn(error_fn);545545+ if (!flush)546546+ in_len -= 4; /* Uncompressed size hack active in pre-boot547547+ environment */548548+ if (buf)549549+ inbuf = buf;550550+ else551551+ inbuf = malloc(LZMA_IOBUF_SIZE);552552+ if (!inbuf) {553553+ error("Could not allocate input bufer");554554+ goto exit_0;555555+ }556556+557557+ cst.state = 0;558558+ cst.rep0 = cst.rep1 = cst.rep2 = cst.rep3 = 1;559559+560560+ wr.header = &header;561561+ wr.flush = flush;562562+ wr.global_pos = 0;563563+ wr.previous_byte = 0;564564+ wr.buffer_pos = 0;565565+566566+ rc_init(&rc, fill, inbuf, in_len);567567+568568+ for (i = 0; i < sizeof(header); i++) {569569+ if (rc.ptr >= rc.buffer_end)570570+ rc_read(&rc);571571+ ((unsigned char *)&header)[i] = *rc.ptr++;572572+ }573573+574574+ if (header.pos >= (9 * 5 * 5))575575+ error("bad header");576576+577577+ mi = 0;578578+ lc = header.pos;579579+ while (lc >= 9) {580580+ mi++;581581+ lc -= 9;582582+ }583583+ pb = 0;584584+ lp = mi;585585+ while (lp >= 5) {586586+ pb++;587587+ lp -= 5;588588+ }589589+ pos_state_mask = (1 << pb) - 1;590590+ literal_pos_mask = (1 << lp) - 1;591591+592592+ ENDIAN_CONVERT(header.dict_size);593593+ ENDIAN_CONVERT(header.dst_size);594594+595595+ if (header.dict_size == 0)596596+ header.dict_size = 1;597597+598598+ if (output)599599+ wr.buffer = output;600600+ else {601601+ wr.bufsize = MIN(header.dst_size, header.dict_size);602602+ wr.buffer = large_malloc(wr.bufsize);603603+ }604604+ if (wr.buffer == NULL)605605+ goto exit_1;606606+607607+ num_probs = LZMA_BASE_SIZE + (LZMA_LIT_SIZE << (lc + lp));608608+ p = (uint16_t *) large_malloc(num_probs * sizeof(*p));609609+ if (p == 0)610610+ goto exit_2;611611+ num_probs = LZMA_LITERAL + (LZMA_LIT_SIZE << (lc + lp));612612+ for (i = 0; i < num_probs; i++)613613+ p[i] = (1 << RC_MODEL_TOTAL_BITS) >> 1;614614+615615+ rc_init_code(&rc);616616+617617+ while (get_pos(&wr) < header.dst_size) {618618+ int pos_state = get_pos(&wr) & pos_state_mask;619619+ uint16_t *prob = p + LZMA_IS_MATCH +620620+ (cst.state << LZMA_NUM_POS_BITS_MAX) + pos_state;621621+ if (rc_is_bit_0(&rc, prob))622622+ process_bit0(&wr, &rc, &cst, p, pos_state, prob,623623+ lc, literal_pos_mask);624624+ else {625625+ process_bit1(&wr, &rc, &cst, p, pos_state, prob);626626+ if (cst.rep0 == 0)627627+ break;628628+ }629629+ }630630+631631+ if (posp)632632+ *posp = rc.ptr-rc.buffer;633633+ if (wr.flush)634634+ wr.flush(wr.buffer, wr.buffer_pos);635635+ ret = 0;636636+ large_free(p);637637+exit_2:638638+ if (!output)639639+ large_free(wr.buffer);640640+exit_1:641641+ if (!buf)642642+ free(inbuf);643643+exit_0:644644+ return ret;645645+}646646+647647+#define decompress unlzma
+4
lib/zlib_inflate/inflate.h
···11+#ifndef INFLATE_H22+#define INFLATE_H33+14/* inflate.h -- internal inflate state definition25 * Copyright (C) 1995-2004 Mark Adler36 * For conditions of distribution and use, see copyright notice in zlib.h···108105 unsigned short work[288]; /* work area for code table building */109106 code codes[ENOUGH]; /* space for code tables */110107};108108+#endif
+4
lib/zlib_inflate/inftrees.h
···11+#ifndef INFTREES_H22+#define INFTREES_H33+14/* inftrees.h -- header to use inftrees.c25 * Copyright (C) 1995-2005 Mark Adler36 * For conditions of distribution and use, see copyright notice in zlib.h···5653extern int zlib_inflate_table (codetype type, unsigned short *lens,5754 unsigned codes, code **table,5855 unsigned *bits, unsigned short *work);5656+#endif
+4-7
mm/filemap.c
···18161816static size_t __iovec_copy_from_user_inatomic(char *vaddr,18171817 const struct iovec *iov, size_t base, size_t bytes)18181818{18191819- size_t copied = 0, left = 0, total = bytes;18191819+ size_t copied = 0, left = 0;1820182018211821 while (bytes) {18221822 char __user *buf = iov->iov_base + base;18231823 int copy = min(bytes, iov->iov_len - base);1824182418251825 base = 0;18261826- left = __copy_from_user_inatomic_nocache(vaddr, buf, copy, total);18261826+ left = __copy_from_user_inatomic(vaddr, buf, copy);18271827 copied += copy;18281828 bytes -= copy;18291829 vaddr += copy;···18511851 if (likely(i->nr_segs == 1)) {18521852 int left;18531853 char __user *buf = i->iov->iov_base + i->iov_offset;18541854-18551855- left = __copy_from_user_inatomic_nocache(kaddr + offset,18561856- buf, bytes, bytes);18541854+ left = __copy_from_user_inatomic(kaddr + offset, buf, bytes);18571855 copied = bytes - left;18581856 } else {18591857 copied = __iovec_copy_from_user_inatomic(kaddr + offset,···18791881 if (likely(i->nr_segs == 1)) {18801882 int left;18811883 char __user *buf = i->iov->iov_base + i->iov_offset;18821882-18831883- left = __copy_from_user_nocache(kaddr + offset, buf, bytes, bytes);18841884+ left = __copy_from_user(kaddr + offset, buf, bytes);18841885 copied = bytes - left;18851886 } else {18861887 copied = __iovec_copy_from_user_inatomic(kaddr + offset,
···1374137413751375static int tcp_shifted_skb(struct sock *sk, struct sk_buff *skb,13761376 struct tcp_sacktag_state *state,13771377- unsigned int pcount, int shifted, int mss)13771377+ unsigned int pcount, int shifted, int mss,13781378+ int dup_sack)13781379{13791380 struct tcp_sock *tp = tcp_sk(sk);13801381 struct sk_buff *prev = tcp_write_queue_prev(sk, skb);···14111410 }1412141114131412 /* We discard results */14141414- tcp_sacktag_one(skb, sk, state, 0, pcount);14131413+ tcp_sacktag_one(skb, sk, state, dup_sack, pcount);1415141414161415 /* Difference in this won't matter, both ACKed by the same cumul. ACK */14171416 TCP_SKB_CB(prev)->sacked |= (TCP_SKB_CB(skb)->sacked & TCPCB_EVER_RETRANS);···1562156115631562 if (!skb_shift(prev, skb, len))15641563 goto fallback;15651565- if (!tcp_shifted_skb(sk, skb, state, pcount, len, mss))15641564+ if (!tcp_shifted_skb(sk, skb, state, pcount, len, mss, dup_sack))15661565 goto out;1567156615681567 /* Hole filled allows collapsing with the next as well, this is very···15811580 len = skb->len;15821581 if (skb_shift(prev, skb, len)) {15831582 pcount += tcp_skb_pcount(skb);15841584- tcp_shifted_skb(sk, skb, state, tcp_skb_pcount(skb), len, mss);15831583+ tcp_shifted_skb(sk, skb, state, tcp_skb_pcount(skb), len, mss, 0);15851584 }1586158515871586out:
+1-1
net/ipv4/tcp_scalable.c
···11/* Tom Kelly's Scalable TCP22 *33- * See htt://www-lce.eng.cam.ac.uk/~ctk21/scalable/33+ * See http://www.deneholme.net/tom/scalable/44 *55 * John Heffner <jheffner@sc.edu>66 */
···1010my $P = $0;1111$P =~ s@.*/@@g;12121313-my $V = '0.27';1313+my $V = '0.28';14141515use Getopt::Long qw(:config no_auto_abbrev);1616···110110 __iomem|111111 __must_check|112112 __init_refok|113113- __kprobes113113+ __kprobes|114114+ __ref114115 }x;115116our $Attribute = qr{116117 const|···12411240 $realfile =~ s@^([^/]*)/@@;1242124112431242 $p1_prefix = $1;12441244- if ($tree && $p1_prefix ne '' && -e "$root/$p1_prefix") {12431243+ if (!$file && $tree && $p1_prefix ne '' &&12441244+ -e "$root/$p1_prefix") {12451245 WARN("patch prefix '$p1_prefix' exists, appears to be a -p0 patch\n");12461246 }12471247···15851583 }15861584# TEST: allow direct testing of the attribute matcher.15871585 if ($dbg_attr) {15881588- if ($line =~ /^.\s*$Attribute\s*$/) {15861586+ if ($line =~ /^.\s*$Modifier\s*$/) {15891587 ERROR("TEST: is attr\n" . $herecurr);15901590- } elsif ($dbg_attr > 1 && $line =~ /^.+($Attribute)/) {15881588+ } elsif ($dbg_attr > 1 && $line =~ /^.+($Modifier)/) {15911589 ERROR("TEST: is not attr ($1 is)\n". $herecurr);15921590 }15931591 next;···1659165716601658# * goes on variable not on type16611659 # (char*[ const])16621662- if ($line =~ m{\($NonptrType(\s*\*[\s\*]*(?:$Modifier\s*)*)\)}) {16601660+ if ($line =~ m{\($NonptrType(\s*(?:$Modifier\b\s*|\*\s*)+)\)}) {16631661 my ($from, $to) = ($1, $1);1664166216651663 # Should start with a space.···16741672 if ($from ne $to) {16751673 ERROR("\"(foo$from)\" should be \"(foo$to)\"\n" . $herecurr);16761674 }16771677- } elsif ($line =~ m{\b$NonptrType(\s*\*[\s\*]*(?:$Modifier\s*)?)($Ident)}) {16751675+ } elsif ($line =~ m{\b$NonptrType(\s*(?:$Modifier\b\s*|\*\s*)+)($Ident)}) {16781676 my ($from, $to, $ident) = ($1, $1, $2);1679167716801678 # Should start with a space.···16871685 # Modifiers should have spaces.16881686 $to =~ s/(\b$Modifier$)/$1 /;1689168716901690- #print "from<$from> to<$to>\n";16911691- if ($from ne $to) {16881688+ #print "from<$from> to<$to> ident<$ident>\n";16891689+ if ($from ne $to && $ident !~ /^$Modifier$/) {16921690 ERROR("\"foo${from}bar\" should be \"foo${to}bar\"\n" . $herecurr);16931691 }16941692 }···18871885 if ($ctx !~ /[WEBC]x./ && $ca !~ /(?:\)|!|~|\*|-|\&|\||\+\+|\-\-|\{)$/) {18881886 ERROR("space required before that '$op' $at\n" . $hereptr);18891887 }18901890- if ($op eq '*' && $cc =~/\s*const\b/) {18881888+ if ($op eq '*' && $cc =~/\s*$Modifier\b/) {18911889 # A unary '*' may be const1892189018931891 } elsif ($ctx =~ /.xW/) {18941894- ERROR("space prohibited after that '$op' $at\n" . $hereptr);18921892+ ERROR("Aspace prohibited after that '$op' $at\n" . $hereptr);18951893 }1896189418971895 # unary ++ and unary -- are allowed no space on one side.···25622560 if ($line =~ /\bin_atomic\s*\(/) {25632561 if ($realfile =~ m@^drivers/@) {25642562 ERROR("do not use in_atomic in drivers\n" . $herecurr);25652565- } else {25632563+ } elsif ($realfile !~ m@^kernel/@) {25662564 WARN("use of in_atomic() is incorrect outside core kernel code\n" . $herecurr);25672565 }25682566 }
+12-6
scripts/gen_initramfs_list.sh
···55# Released under the terms of the GNU GPL66#77# Generate a cpio packed initramfs. It uses gen_init_cpio to generate88-# the cpio archive, and gzip to pack it.88+# the cpio archive, and then compresses it.99# The script may also be used to generate the inputfile used for gen_init_cpio1010# This script assumes that gen_init_cpio is located in usr/ directory1111···1616cat << EOF1717Usage:1818$0 [-o <file>] [-u <uid>] [-g <gid>] {-d | <cpio_source>} ...1919- -o <file> Create gzipped initramfs file named <file> using2020- gen_init_cpio and gzip1919+ -o <file> Create compressed initramfs file named <file> using2020+ gen_init_cpio and compressor depending on the extension2121 -u <uid> User ID to map to user ID 0 (root).2222 <uid> is only meaningful if <cpio_source> is a2323 directory. "squash" forces all files to uid 0.···225225output="/dev/stdout"226226output_file=""227227is_cpio_compressed=228228+compr="gzip -9 -f"228229229230arg="$1"230231case "$arg" in···234233 echo "deps_initramfs := \\"235234 shift236235 ;;237237- "-o") # generate gzipped cpio image named $1236236+ "-o") # generate compressed cpio image named $1238237 shift239238 output_file="$1"240239 cpio_list="$(mktemp ${TMPDIR:-/tmp}/cpiolist.XXXXXX)"241240 output=${cpio_list}241241+ echo "$output_file" | grep -q "\.gz$" && compr="gzip -9 -f"242242+ echo "$output_file" | grep -q "\.bz2$" && compr="bzip2 -9 -f"243243+ echo "$output_file" | grep -q "\.lzma$" && compr="lzma -9 -f"244244+ echo "$output_file" | grep -q "\.cpio$" && compr="cat"242245 shift243246 ;;244247esac···279274 esac280275done281276282282-# If output_file is set we will generate cpio archive and gzip it277277+# If output_file is set we will generate cpio archive and compress it283278# we are carefull to delete tmp files284279if [ ! -z ${output_file} ]; then285280 if [ -z ${cpio_file} ]; then···292287 if [ "${is_cpio_compressed}" = "compressed" ]; then293288 cat ${cpio_tfile} > ${output_file}294289 else295295- cat ${cpio_tfile} | gzip -f -9 - > ${output_file}290290+ (cat ${cpio_tfile} | ${compr} - > ${output_file}) \291291+ || (rm -f ${output_file} ; false)296292 fi297293 [ -z ${cpio_file} ] && rm ${cpio_tfile}298294fi
+3-2
security/selinux/netlabel.c
···386386 if (!S_ISSOCK(inode->i_mode) ||387387 ((mask & (MAY_WRITE | MAY_APPEND)) == 0))388388 return 0;389389-390389 sock = SOCKET_I(inode);391390 sk = sock->sk;391391+ if (sk == NULL)392392+ return 0;392393 sksec = sk->sk_security;393393- if (sksec->nlbl_state != NLBL_REQUIRE)394394+ if (sksec == NULL || sksec->nlbl_state != NLBL_REQUIRE)394395 return 0;395396396397 local_bh_disable();
+1-1
sound/core/oss/rate.c
···157157 while (dst_frames1 > 0) {158158 S1 = S2;159159 if (src_frames1-- > 0) {160160- S1 = *src;160160+ S2 = *src;161161 src += src_step;162162 }163163 if (pos & ~R_MASK) {
···9797 int capture_chips;9898 int fw_file_set;9999 int firmware_num;100100- int is_hr_stereo:1;101101- int board_has_aes1:1; /* if 1 board has AES1 plug and SRC */102102- int board_has_analog:1; /* if 0 the board is digital only */103103- int board_has_mic:1; /* if 1 the board has microphone input */104104- int board_aes_in_192k:1;/* if 1 the aes input plugs do support 192kHz */105105- int mono_capture:1; /* if 1 the board does mono capture */100100+ unsigned int is_hr_stereo:1;101101+ unsigned int board_has_aes1:1; /* if 1 board has AES1 plug and SRC */102102+ unsigned int board_has_analog:1; /* if 0 the board is digital only */103103+ unsigned int board_has_mic:1; /* if 1 the board has microphone input */104104+ unsigned int board_aes_in_192k:1;/* if 1 the aes input plugs do support 192kHz */105105+ unsigned int mono_capture:1; /* if 1 the board does mono capture */106106107107 struct snd_dma_buffer hostport;108108
+89
usr/Kconfig
···4444 owned by group root in the initial ramdisk image.45454646 If you are not sure, leave it set to "0".4747+4848+config RD_GZIP4949+ bool "Initial ramdisk compressed using gzip"5050+ default y5151+ depends on BLK_DEV_INITRD=y5252+ select DECOMPRESS_GZIP5353+ help5454+ Support loading of a gzip encoded initial ramdisk or cpio buffer.5555+ If unsure, say Y.5656+5757+config RD_BZIP25858+ bool "Initial ramdisk compressed using bzip2"5959+ default n6060+ depends on BLK_DEV_INITRD=y6161+ select DECOMPRESS_BZIP26262+ help6363+ Support loading of a bzip2 encoded initial ramdisk or cpio buffer6464+ If unsure, say N.6565+6666+config RD_LZMA6767+ bool "Initial ramdisk compressed using lzma"6868+ default n6969+ depends on BLK_DEV_INITRD=y7070+ select DECOMPRESS_LZMA7171+ help7272+ Support loading of a lzma encoded initial ramdisk or cpio buffer7373+ If unsure, say N.7474+7575+choice7676+ prompt "Built-in initramfs compression mode"7777+ help7878+ This setting is only meaningful if the INITRAMFS_SOURCE is7979+ set. It decides by which algorithm the INITRAMFS_SOURCE will8080+ be compressed.8181+ Several compression algorithms are available, which differ8282+ in efficiency, compression and decompression speed.8383+ Compression speed is only relevant when building a kernel.8484+ Decompression speed is relevant at each boot.8585+8686+ If you have any problems with bzip2 or lzma compressed8787+ initramfs, mail me (Alain Knaff) <alain@knaff.lu>.8888+8989+ High compression options are mostly useful for users who9090+ are low on disk space (embedded systems), but for whom ram9191+ size matters less.9292+9393+ If in doubt, select 'gzip'9494+9595+config INITRAMFS_COMPRESSION_NONE9696+ bool "None"9797+ help9898+ Do not compress the built-in initramfs at all. This may9999+ sound wasteful in space, but, you should be aware that the100100+ built-in initramfs will be compressed at a later stage101101+ anyways along with the rest of the kernel, on those102102+ architectures that support this.103103+ However, not compressing the initramfs may lead to slightly104104+ higher memory consumption during a short time at boot, while105105+ both the cpio image and the unpacked filesystem image will106106+ be present in memory simultaneously107107+108108+config INITRAMFS_COMPRESSION_GZIP109109+ bool "Gzip"110110+ depends on RD_GZIP111111+ help112112+ The old and tried gzip compression. Its compression ratio is113113+ the poorest among the 3 choices; however its speed (both114114+ compression and decompression) is the fastest.115115+116116+config INITRAMFS_COMPRESSION_BZIP2117117+ bool "Bzip2"118118+ depends on RD_BZIP2119119+ help120120+ Its compression ratio and speed is intermediate.121121+ Decompression speed is slowest among the three. The initramfs122122+ size is about 10% smaller with bzip2, in comparison to gzip.123123+ Bzip2 uses a large amount of memory. For modern kernels you124124+ will need at least 8MB RAM or more for booting.125125+126126+config INITRAMFS_COMPRESSION_LZMA127127+ bool "LZMA"128128+ depends on RD_LZMA129129+ help130130+ The most recent compression algorithm.131131+ Its ratio is best, decompression speed is between the other132132+ two. Compression is slowest. The initramfs size is about 33%133133+ smaller with LZMA in comparison to gzip.134134+135135+endchoice
+25-13
usr/Makefile
···66PHONY += klibcdirs778899-# Generate builtin.o based on initramfs_data.o1010-obj-$(CONFIG_BLK_DEV_INITRD) := initramfs_data.o99+# No compression1010+suffix_$(CONFIG_INITRAMFS_COMPRESSION_NONE) =11111212-# initramfs_data.o contains the initramfs_data.cpio.gz image.1212+# Gzip, but no bzip21313+suffix_$(CONFIG_INITRAMFS_COMPRESSION_GZIP) = .gz1414+1515+# Bzip21616+suffix_$(CONFIG_INITRAMFS_COMPRESSION_BZIP2) = .bz21717+1818+# Lzma1919+suffix_$(CONFIG_INITRAMFS_COMPRESSION_LZMA) = .lzma2020+2121+# Generate builtin.o based on initramfs_data.o2222+obj-$(CONFIG_BLK_DEV_INITRD) := initramfs_data$(suffix_y).o2323+2424+# initramfs_data.o contains the compressed initramfs_data.cpio image.1325# The image is included using .incbin, a dependency which is not1426# tracked automatically.1515-$(obj)/initramfs_data.o: $(obj)/initramfs_data.cpio.gz FORCE2727+$(obj)/initramfs_data$(suffix_y).o: $(obj)/initramfs_data.cpio$(suffix_y) FORCE16281729#####1830# Generate the initramfs cpio archive···3725 $(if $(CONFIG_INITRAMFS_ROOT_UID), -u $(CONFIG_INITRAMFS_ROOT_UID)) \3826 $(if $(CONFIG_INITRAMFS_ROOT_GID), -g $(CONFIG_INITRAMFS_ROOT_GID))39274040-# .initramfs_data.cpio.gz.d is used to identify all files included2828+# .initramfs_data.cpio.d is used to identify all files included4129# in initramfs and to detect if any files are added/removed.4230# Removed files are identified by directory timestamp being updated4331# The dependency list is generated by gen_initramfs.sh -l4444-ifneq ($(wildcard $(obj)/.initramfs_data.cpio.gz.d),)4545- include $(obj)/.initramfs_data.cpio.gz.d3232+ifneq ($(wildcard $(obj)/.initramfs_data.cpio.d),)3333+ include $(obj)/.initramfs_data.cpio.d4634endif47354836quiet_cmd_initfs = GEN $@4937 cmd_initfs = $(initramfs) -o $@ $(ramfs-args) $(ramfs-input)50385151-targets := initramfs_data.cpio.gz3939+targets := initramfs_data.cpio.gz initramfs_data.cpio.bz2 initramfs_data.cpio.lzma initramfs_data.cpio5240# do not try to update files included in initramfs5341$(deps_initramfs): ;54425543$(deps_initramfs): klibcdirs5656-# We rebuild initramfs_data.cpio.gz if:5757-# 1) Any included file is newer then initramfs_data.cpio.gz4444+# We rebuild initramfs_data.cpio if:4545+# 1) Any included file is newer then initramfs_data.cpio5846# 2) There are changes in which files are included (added or deleted)5959-# 3) If gen_init_cpio are newer than initramfs_data.cpio.gz4747+# 3) If gen_init_cpio are newer than initramfs_data.cpio6048# 4) arguments to gen_initramfs.sh changes6161-$(obj)/initramfs_data.cpio.gz: $(obj)/gen_init_cpio $(deps_initramfs) klibcdirs6262- $(Q)$(initramfs) -l $(ramfs-input) > $(obj)/.initramfs_data.cpio.gz.d4949+$(obj)/initramfs_data.cpio$(suffix_y): $(obj)/gen_init_cpio $(deps_initramfs) klibcdirs5050+ $(Q)$(initramfs) -l $(ramfs-input) > $(obj)/.initramfs_data.cpio.d6351 $(call if_changed,initfs)6452
···11+/*22+ initramfs_data includes the compressed binary that is the33+ filesystem used for early user space.44+ Note: Older versions of "as" (prior to binutils 2.11.90.0.2355+ released on 2001-07-14) dit not support .incbin.66+ If you are forced to use older binutils than that then the77+ following trick can be applied to create the resulting binary:88+99+1010+ ld -m elf_i386 --format binary --oformat elf32-i386 -r \1111+ -T initramfs_data.scr initramfs_data.cpio.gz -o initramfs_data.o1212+ ld -m elf_i386 -r -o built-in.o initramfs_data.o1313+1414+ initramfs_data.scr looks like this:1515+SECTIONS1616+{1717+ .init.ramfs : { *(.data) }1818+}1919+2020+ The above example is for i386 - the parameters vary from architectures.2121+ Eventually look up LDFLAGS_BLOB in an older version of the2222+ arch/$(ARCH)/Makefile to see the flags used before .incbin was introduced.2323+2424+ Using .incbin has the advantage over ld that the correct flags are set2525+ in the ELF header, as required by certain architectures.2626+*/2727+2828+.section .init.ramfs,"a"2929+.incbin "usr/initramfs_data.cpio.bz2"
+29
usr/initramfs_data.gz.S
···11+/*22+ initramfs_data includes the compressed binary that is the33+ filesystem used for early user space.44+ Note: Older versions of "as" (prior to binutils 2.11.90.0.2355+ released on 2001-07-14) dit not support .incbin.66+ If you are forced to use older binutils than that then the77+ following trick can be applied to create the resulting binary:88+99+1010+ ld -m elf_i386 --format binary --oformat elf32-i386 -r \1111+ -T initramfs_data.scr initramfs_data.cpio.gz -o initramfs_data.o1212+ ld -m elf_i386 -r -o built-in.o initramfs_data.o1313+1414+ initramfs_data.scr looks like this:1515+SECTIONS1616+{1717+ .init.ramfs : { *(.data) }1818+}1919+2020+ The above example is for i386 - the parameters vary from architectures.2121+ Eventually look up LDFLAGS_BLOB in an older version of the2222+ arch/$(ARCH)/Makefile to see the flags used before .incbin was introduced.2323+2424+ Using .incbin has the advantage over ld that the correct flags are set2525+ in the ELF header, as required by certain architectures.2626+*/2727+2828+.section .init.ramfs,"a"2929+.incbin "usr/initramfs_data.cpio.gz"
+29
usr/initramfs_data.lzma.S
···11+/*22+ initramfs_data includes the compressed binary that is the33+ filesystem used for early user space.44+ Note: Older versions of "as" (prior to binutils 2.11.90.0.2355+ released on 2001-07-14) dit not support .incbin.66+ If you are forced to use older binutils than that then the77+ following trick can be applied to create the resulting binary:88+99+1010+ ld -m elf_i386 --format binary --oformat elf32-i386 -r \1111+ -T initramfs_data.scr initramfs_data.cpio.gz -o initramfs_data.o1212+ ld -m elf_i386 -r -o built-in.o initramfs_data.o1313+1414+ initramfs_data.scr looks like this:1515+SECTIONS1616+{1717+ .init.ramfs : { *(.data) }1818+}1919+2020+ The above example is for i386 - the parameters vary from architectures.2121+ Eventually look up LDFLAGS_BLOB in an older version of the2222+ arch/$(ARCH)/Makefile to see the flags used before .incbin was introduced.2323+2424+ Using .incbin has the advantage over ld that the correct flags are set2525+ in the ELF header, as required by certain architectures.2626+*/2727+2828+.section .init.ramfs,"a"2929+.incbin "usr/initramfs_data.cpio.lzma"