···252252There is an exception to the above. If hotplug funtionality is used253253to remove all the CPUs that are currently assigned to a cpuset,254254then the kernel will automatically update the cpus_allowed of all255255-tasks attached to CPUs in that cpuset with the online CPUs of the256256-nearest parent cpuset that still has some CPUs online. When memory255255+tasks attached to CPUs in that cpuset to allow all CPUs. When memory257256hotplug functionality for removing Memory Nodes is available, a258257similar exception is expected to apply there as well. In general,259258the kernel prefers to violate cpuset placement, over starving a task
+3
Documentation/x86_64/boot-options.txt
···25252626 noapictimer Don't set up the APIC timer27272828+ no_timer_check Don't check the IO-APIC timer. This can work around2929+ problems with incorrect timer initialization on some boards.3030+2831Early Console29323033 syntax: earlyprintk=vga
+6-3
arch/i386/kernel/cpu/amd.c
···195195 c->x86_num_cores = 1;196196 }197197198198-#ifdef CONFIG_X86_SMP198198+#ifdef CONFIG_X86_HT199199 /*200200 * On a AMD dual core setup the lower bits of the APIC id201201 * distingush the cores. Assumes number of cores is a power···203203 */204204 if (c->x86_num_cores > 1) {205205 int cpu = smp_processor_id();206206- /* Fix up the APIC ID following AMD specifications. */207207- cpu_core_id[cpu] >>= hweight32(c->x86_num_cores - 1);206206+ unsigned bits = 0;207207+ while ((1 << bits) < c->x86_num_cores)208208+ bits++;209209+ cpu_core_id[cpu] = phys_proc_id[cpu] & ((1<<bits)-1);210210+ phys_proc_id[cpu] >>= bits;208211 printk(KERN_INFO "CPU %d(%d) -> Core %d\n",209212 cpu, c->x86_num_cores, cpu_core_id[cpu]);210213 }
···888888889889cpumask_t cpu_sibling_map[NR_CPUS] __cacheline_aligned;890890cpumask_t cpu_core_map[NR_CPUS] __cacheline_aligned;891891+EXPORT_SYMBOL(cpu_core_map);891892892893static void __init smp_boot_cpus(unsigned int max_cpus)893894{
+6-4
arch/i386/mm/ioremap.c
···238238 addr < phys_to_virt(ISA_END_ADDRESS))239239 return;240240241241- p = remove_vm_area((void *) (PAGE_MASK & (unsigned long __force) addr));241241+ write_lock(&vmlist_lock);242242+ p = __remove_vm_area((void *) (PAGE_MASK & (unsigned long __force) addr));242243 if (!p) { 243243- printk("__iounmap: bad address %p\n", addr);244244- return;244244+ printk("iounmap: bad address %p\n", addr);245245+ goto out_unlock;245246 }246247247248 if ((p->flags >> 20) && p->phys_addr < virt_to_phys(high_memory) - 1) {248248- /* p->size includes the guard page, but cpa doesn't like that */249249 change_page_attr(virt_to_page(__va(p->phys_addr)),250250 p->size >> PAGE_SHIFT,251251 PAGE_KERNEL);252252 global_flush_tlb();253253 } 254254+out_unlock:255255+ write_unlock(&vmlist_lock);254256 kfree(p); 255257}256258
+9-6
arch/ppc/kernel/head_44x.S
···330330 /* If we are faulting a kernel address, we have to use the331331 * kernel page tables.332332 */333333- andis. r11, r10, 0x8000334334- beq 3f333333+ lis r11, TASK_SIZE@h334334+ cmplw r10, r11335335+ blt+ 3f335336 lis r11, swapper_pg_dir@h336337 ori r11, r11, swapper_pg_dir@l337338···465464 /* If we are faulting a kernel address, we have to use the466465 * kernel page tables.467466 */468468- andis. r11, r10, 0x8000469469- beq 3f467467+ lis r11, TASK_SIZE@h468468+ cmplw r10, r11469469+ blt+ 3f470470 lis r11, swapper_pg_dir@h471471 ori r11, r11, swapper_pg_dir@l472472···535533 /* If we are faulting a kernel address, we have to use the536534 * kernel page tables.537535 */538538- andis. r11, r10, 0x8000539539- beq 3f536536+ lis r11, TASK_SIZE@h537537+ cmplw r10, r11538538+ blt+ 3f540539 lis r11, swapper_pg_dir@h541540 ori r11, r11, swapper_pg_dir@l542541
+1-1
arch/ppc/kernel/setup.c
···499499{500500 struct device_node *prom_stdout;501501 char *name;502502- int offset;502502+ int offset = 0;503503504504 if (of_stdout_device == NULL)505505 return -ENODEV;
+5-2
arch/ppc/lib/string.S
···446446#ifdef CONFIG_8xx447447 /* Don't use prefetch on 8xx */448448 mtctr r0449449+ li r0,044945053: COPY_16_BYTES_WITHEX(0)450451 bdnz 53b451452···565564/* or write fault in cacheline loop */566565105: li r9,156756692: li r3,LG_CACHELINE_BYTES568568- b 99f567567+ mfctr r8568568+ add r0,r0,r8569569+ b 106f569570/* read fault in final word loop */570571108: li r9,0571572 b 93f···588585 * r5 + (ctr << r3), and r9 is 0 for read or 1 for write.589586 */59058799: mfctr r0591591- slw r3,r0,r3588588+106: slw r3,r0,r3592589 add. r3,r3,r5593590 beq 120f /* shouldn't happen */594591 cmpwi 0,r9,0
···2020#include "os.h"21212222#ifdef CONFIG_NOCONFIG_CHAN2323+2424+/* The printk's here are wrong because we are complaining that there is no2525+ * output device, but printk is printing to that output device. The user will2626+ * never see the error. printf would be better, except it can't run on a2727+ * kernel stack because it will overflow it.2828+ * Use printk for now since that will avoid crashing.2929+ */3030+2331static void *not_configged_init(char *str, int device, struct chan_opts *opts)2432{2525- printf(KERN_ERR "Using a channel type which is configured out of "3333+ printk(KERN_ERR "Using a channel type which is configured out of "2634 "UML\n");2735 return(NULL);2836}···3830static int not_configged_open(int input, int output, int primary, void *data,3931 char **dev_out)4032{4141- printf(KERN_ERR "Using a channel type which is configured out of "3333+ printk(KERN_ERR "Using a channel type which is configured out of "4234 "UML\n");4335 return(-ENODEV);4436}45374638static void not_configged_close(int fd, void *data)4739{4848- printf(KERN_ERR "Using a channel type which is configured out of "4040+ printk(KERN_ERR "Using a channel type which is configured out of "4941 "UML\n");5042}51435244static int not_configged_read(int fd, char *c_out, void *data)5345{5454- printf(KERN_ERR "Using a channel type which is configured out of "4646+ printk(KERN_ERR "Using a channel type which is configured out of "5547 "UML\n");5648 return(-EIO);5749}58505951static int not_configged_write(int fd, const char *buf, int len, void *data)6052{6161- printf(KERN_ERR "Using a channel type which is configured out of "5353+ printk(KERN_ERR "Using a channel type which is configured out of "6254 "UML\n");6355 return(-EIO);6456}···6658static int not_configged_console_write(int fd, const char *buf, int len,6759 void *data)6860{6969- printf(KERN_ERR "Using a channel type which is configured out of "6161+ printk(KERN_ERR "Using a channel type which is configured out of "7062 "UML\n");7163 return(-EIO);7264}···7466static int not_configged_window_size(int fd, void *data, unsigned short *rows,7567 unsigned short *cols)7668{7777- printf(KERN_ERR "Using a channel type which is configured out of "6969+ printk(KERN_ERR "Using a channel type which is configured out of "7870 "UML\n");7971 return(-ENODEV);8072}
···3838 }3939 sin->sin_family = AF_INET;4040 sin->sin_addr.s_addr = in_aton(addr);4141- sin->sin_port = port;4141+ sin->sin_port = htons(port);4242 return(sin);4343}4444···5555 struct mcast_data *pri = data;5656 struct sockaddr_in *sin = pri->mcast_addr;5757 struct ip_mreq mreq;5858- int fd, yes = 1;5858+ int fd = -EINVAL, yes = 1, err = -EINVAL;;595960606161- if ((sin->sin_addr.s_addr == 0) || (sin->sin_port == 0)) {6262- fd = -EINVAL;6161+ if ((sin->sin_addr.s_addr == 0) || (sin->sin_port == 0))6362 goto out;6464- }65636664 fd = socket(AF_INET, SOCK_DGRAM, 0);6565+6766 if (fd < 0){6867 printk("mcast_open : data socket failed, errno = %d\n", 6968 errno);7070- fd = -ENOMEM;6969+ fd = -errno;7170 goto out;7271 }73727473 if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(yes)) < 0) {7574 printk("mcast_open: SO_REUSEADDR failed, errno = %d\n",7675 errno);7777- os_close_file(fd);7878- fd = -EINVAL;7979- goto out;7676+ goto out_close;8077 }81788279 /* set ttl according to config */···8184 sizeof(pri->ttl)) < 0) {8285 printk("mcast_open: IP_MULTICAST_TTL failed, error = %d\n",8386 errno);8484- os_close_file(fd);8585- fd = -EINVAL;8686- goto out;8787+ goto out_close;8788 }88898990 /* set LOOP, so data does get fed back to local sockets */9091 if (setsockopt(fd, SOL_IP, IP_MULTICAST_LOOP, &yes, sizeof(yes)) < 0) {9192 printk("mcast_open: IP_MULTICAST_LOOP failed, error = %d\n",9293 errno);9393- os_close_file(fd);9494- fd = -EINVAL;9595- goto out;9494+ goto out_close;9695 }97969897 /* bind socket to mcast address */9998 if (bind(fd, (struct sockaddr *) sin, sizeof(*sin)) < 0) {10099 printk("mcast_open : data bind failed, errno = %d\n", errno);101101- os_close_file(fd);102102- fd = -EINVAL;103103- goto out;100100+ goto out_close;104101 } 105102106103 /* subscribe to the multicast group */···108117 "interface on the host.\n");109118 printk("eth0 should be configured in order to use the "110119 "multicast transport.\n");111111- os_close_file(fd);112112- fd = -EINVAL;120120+ goto out_close;113121 }114122115123 out:116116- return(fd);124124+ return fd;125125+126126+ out_close:127127+ os_close_file(fd);128128+ return err;117129}118130119131static void mcast_close(int fd, void *data)···158164 .delete_address = NULL,159165 .max_packet = MAX_PACKET - ETH_HEADER_OTHER160166};161161-162162-/*163163- * Overrides for Emacs so that we follow Linus's tabbing style.164164- * Emacs will notice this stuff at the end of the file and automatically165165- * adjust the settings for this buffer only. This must remain at the end166166- * of the file.167167- * ---------------------------------------------------------------------------168168- * Local variables:169169- * c-file-style: "linux"170170- * End:171171- */
+3-293
arch/um/drivers/ubd_kern.c
···5555#include "mem_kern.h"5656#include "cow.h"57575858-enum ubd_req { UBD_READ, UBD_WRITE, UBD_MMAP };5858+enum ubd_req { UBD_READ, UBD_WRITE };59596060struct io_thread_req {6161 enum ubd_req op;···6868 unsigned long sector_mask;6969 unsigned long long cow_offset;7070 unsigned long bitmap_words[2];7171- int map_fd;7272- unsigned long long map_offset;7371 int error;7472};7573···120122121123#define MAX_DEV (8)122124123123-/* Changed in early boot */124124-static int ubd_do_mmap = 0;125125-#define UBD_MMAP_BLOCK_SIZE PAGE_SIZE126126-127125static struct block_device_operations ubd_blops = {128126 .owner = THIS_MODULE,129127 .open = ubd_open,···169175 int no_cow;170176 struct cow cow;171177 struct platform_device pdev;172172-173173- int map_writes;174174- int map_reads;175175- int nomap_writes;176176- int nomap_reads;177177- int write_maps;178178};179179180180#define DEFAULT_COW { \···188200 .openflags = OPEN_FLAGS, \189201 .no_cow = 0, \190202 .cow = DEFAULT_COW, \191191- .map_writes = 0, \192192- .map_reads = 0, \193193- .nomap_writes = 0, \194194- .nomap_reads = 0, \195195- .write_maps = 0, \196203}197204198205struct ubd ubd_dev[MAX_DEV] = { [ 0 ... MAX_DEV - 1 ] = DEFAULT_UBD };···297314 int major;298315299316 str++;300300- if(!strcmp(str, "mmap")){301301- CHOOSE_MODE(printk("mmap not supported by the ubd "302302- "driver in tt mode\n"),303303- ubd_do_mmap = 1);304304- return(0);305305- }306306-307317 if(!strcmp(str, "sync")){308318 global_openflags = of_sync(global_openflags);309319 return(0);···500524{501525 struct io_thread_req req;502526 struct request *rq = elv_next_request(ubd_queue);503503- int n, err;527527+ int n;504528505529 do_ubd = NULL;506530 intr_count++;···514538 return;515539 }516540517517- if((req.op != UBD_MMAP) &&518518- ((req.offset != ((__u64) (rq->sector)) << 9) ||519519- (req.length != (rq->current_nr_sectors) << 9)))520520- panic("I/O op mismatch");521521-522522- if(req.map_fd != -1){523523- err = physmem_subst_mapping(req.buffer, req.map_fd,524524- req.map_offset, 1);525525- if(err)526526- printk("ubd_handler - physmem_subst_mapping failed, "527527- "err = %d\n", -err);528528- }529529-530541 ubd_finish(rq, req.error);531542 reactivate_fd(thread_fd, UBD_IRQ); 532543 do_ubd_request(ubd_queue);···546583547584static void ubd_close(struct ubd *dev)548585{549549- if(ubd_do_mmap)550550- physmem_forget_descriptor(dev->fd);551586 os_close_file(dev->fd);552587 if(dev->cow.file == NULL)553588 return;554589555555- if(ubd_do_mmap)556556- physmem_forget_descriptor(dev->cow.fd);557590 os_close_file(dev->cow.fd);558591 vfree(dev->cow.bitmap);559592 dev->cow.bitmap = NULL;···9691010 req->bitmap_words, bitmap_len);9701011}9711012972972-static int mmap_fd(struct request *req, struct ubd *dev, __u64 offset)973973-{974974- __u64 sector;975975- unsigned char *bitmap;976976- int bit, i;977977-978978- /* mmap must have been requested on the command line */979979- if(!ubd_do_mmap)980980- return(-1);981981-982982- /* The buffer must be page aligned */983983- if(((unsigned long) req->buffer % UBD_MMAP_BLOCK_SIZE) != 0)984984- return(-1);985985-986986- /* The request must be a page long */987987- if((req->current_nr_sectors << 9) != PAGE_SIZE)988988- return(-1);989989-990990- if(dev->cow.file == NULL)991991- return(dev->fd);992992-993993- sector = offset >> 9;994994- bitmap = (unsigned char *) dev->cow.bitmap;995995- bit = ubd_test_bit(sector, bitmap);996996-997997- for(i = 1; i < req->current_nr_sectors; i++){998998- if(ubd_test_bit(sector + i, bitmap) != bit)999999- return(-1);10001000- }10011001-10021002- if(bit || (rq_data_dir(req) == WRITE))10031003- offset += dev->cow.data_offset;10041004-10051005- /* The data on disk must be page aligned */10061006- if((offset % UBD_MMAP_BLOCK_SIZE) != 0)10071007- return(-1);10081008-10091009- return(bit ? dev->fd : dev->cow.fd);10101010-}10111011-10121012-static int prepare_mmap_request(struct ubd *dev, int fd, __u64 offset,10131013- struct request *req,10141014- struct io_thread_req *io_req)10151015-{10161016- int err;10171017-10181018- if(rq_data_dir(req) == WRITE){10191019- /* Writes are almost no-ops since the new data is already in the10201020- * host page cache10211021- */10221022- dev->map_writes++;10231023- if(dev->cow.file != NULL)10241024- cowify_bitmap(io_req->offset, io_req->length,10251025- &io_req->sector_mask, &io_req->cow_offset,10261026- dev->cow.bitmap, dev->cow.bitmap_offset,10271027- io_req->bitmap_words,10281028- dev->cow.bitmap_len);10291029- }10301030- else {10311031- int w;10321032-10331033- if((dev->cow.file != NULL) && (fd == dev->cow.fd))10341034- w = 0;10351035- else w = dev->openflags.w;10361036-10371037- if((dev->cow.file != NULL) && (fd == dev->fd))10381038- offset += dev->cow.data_offset;10391039-10401040- err = physmem_subst_mapping(req->buffer, fd, offset, w);10411041- if(err){10421042- printk("physmem_subst_mapping failed, err = %d\n",10431043- -err);10441044- return(1);10451045- }10461046- dev->map_reads++;10471047- }10481048- io_req->op = UBD_MMAP;10491049- io_req->buffer = req->buffer;10501050- return(0);10511051-}10521052-10531013/* Called with ubd_io_lock held */10541014static int prepare_request(struct request *req, struct io_thread_req *io_req)10551015{10561016 struct gendisk *disk = req->rq_disk;10571017 struct ubd *dev = disk->private_data;10581018 __u64 offset;10591059- int len, fd;10191019+ int len;1060102010611021 if(req->rq_status == RQ_INACTIVE) return(1);10621022···99211149931115 io_req->fds[0] = (dev->cow.file != NULL) ? dev->cow.fd : dev->fd;9941116 io_req->fds[1] = dev->fd;995995- io_req->map_fd = -1;9961117 io_req->cow_offset = -1;9971118 io_req->offset = offset;9981119 io_req->length = len;9991120 io_req->error = 0;10001121 io_req->sector_mask = 0;10011001-10021002- fd = mmap_fd(req, dev, io_req->offset);10031003- if(fd > 0){10041004- /* If mmapping is otherwise OK, but the first access to the10051005- * page is a write, then it's not mapped in yet. So we have10061006- * to write the data to disk first, then we can map the disk10071007- * page in and continue normally from there.10081008- */10091009- if((rq_data_dir(req) == WRITE) && !is_remapped(req->buffer)){10101010- io_req->map_fd = dev->fd;10111011- io_req->map_offset = io_req->offset +10121012- dev->cow.data_offset;10131013- dev->write_maps++;10141014- }10151015- else return(prepare_mmap_request(dev, fd, io_req->offset, req,10161016- io_req));10171017- }10181018-10191019- if(rq_data_dir(req) == READ)10201020- dev->nomap_reads++;10211021- else dev->nomap_writes++;1022112210231123 io_req->op = (rq_data_dir(req) == READ) ? UBD_READ : UBD_WRITE;10241124 io_req->offsets[0] = 0;···10841228 }10851229 return(-EINVAL);10861230}10871087-10881088-static int ubd_check_remapped(int fd, unsigned long address, int is_write,10891089- __u64 offset)10901090-{10911091- __u64 bitmap_offset;10921092- unsigned long new_bitmap[2];10931093- int i, err, n;10941094-10951095- /* If it's not a write access, we can't do anything about it */10961096- if(!is_write)10971097- return(0);10981098-10991099- /* We have a write */11001100- for(i = 0; i < sizeof(ubd_dev) / sizeof(ubd_dev[0]); i++){11011101- struct ubd *dev = &ubd_dev[i];11021102-11031103- if((dev->fd != fd) && (dev->cow.fd != fd))11041104- continue;11051105-11061106- /* It's a write to a ubd device */11071107-11081108- /* This should be impossible now */11091109- if(!dev->openflags.w){11101110- /* It's a write access on a read-only device - probably11111111- * shouldn't happen. If the kernel is trying to change11121112- * something with no intention of writing it back out,11131113- * then this message will clue us in that this needs11141114- * fixing11151115- */11161116- printk("Write access to mapped page from readonly ubd "11171117- "device %d\n", i);11181118- return(0);11191119- }11201120-11211121- /* It's a write to a writeable ubd device - it must be COWed11221122- * because, otherwise, the page would have been mapped in11231123- * writeable11241124- */11251125-11261126- if(!dev->cow.file)11271127- panic("Write fault on writeable non-COW ubd device %d",11281128- i);11291129-11301130- /* It should also be an access to the backing file since the11311131- * COW pages should be mapped in read-write11321132- */11331133-11341134- if(fd == dev->fd)11351135- panic("Write fault on a backing page of ubd "11361136- "device %d\n", i);11371137-11381138- /* So, we do the write, copying the backing data to the COW11391139- * file...11401140- */11411141-11421142- err = os_seek_file(dev->fd, offset + dev->cow.data_offset);11431143- if(err < 0)11441144- panic("Couldn't seek to %lld in COW file of ubd "11451145- "device %d, err = %d",11461146- offset + dev->cow.data_offset, i, -err);11471147-11481148- n = os_write_file(dev->fd, (void *) address, PAGE_SIZE);11491149- if(n != PAGE_SIZE)11501150- panic("Couldn't copy data to COW file of ubd "11511151- "device %d, err = %d", i, -n);11521152-11531153- /* ... updating the COW bitmap... */11541154-11551155- cowify_bitmap(offset, PAGE_SIZE, NULL, &bitmap_offset,11561156- dev->cow.bitmap, dev->cow.bitmap_offset,11571157- new_bitmap, dev->cow.bitmap_len);11581158-11591159- err = os_seek_file(dev->fd, bitmap_offset);11601160- if(err < 0)11611161- panic("Couldn't seek to %lld in COW file of ubd "11621162- "device %d, err = %d", bitmap_offset, i, -err);11631163-11641164- n = os_write_file(dev->fd, new_bitmap, sizeof(new_bitmap));11651165- if(n != sizeof(new_bitmap))11661166- panic("Couldn't update bitmap of ubd device %d, "11671167- "err = %d", i, -n);11681168-11691169- /* Maybe we can map the COW page in, and maybe we can't. If11701170- * it is a pre-V3 COW file, we can't, since the alignment will11711171- * be wrong. If it is a V3 or later COW file which has been11721172- * moved to a system with a larger page size, then maybe we11731173- * can't, depending on the exact location of the page.11741174- */11751175-11761176- offset += dev->cow.data_offset;11771177-11781178- /* Remove the remapping, putting the original anonymous page11791179- * back. If the COW file can be mapped in, that is done.11801180- * Otherwise, the COW page is read in.11811181- */11821182-11831183- if(!physmem_remove_mapping((void *) address))11841184- panic("Address 0x%lx not remapped by ubd device %d",11851185- address, i);11861186- if((offset % UBD_MMAP_BLOCK_SIZE) == 0)11871187- physmem_subst_mapping((void *) address, dev->fd,11881188- offset, 1);11891189- else {11901190- err = os_seek_file(dev->fd, offset);11911191- if(err < 0)11921192- panic("Couldn't seek to %lld in COW file of "11931193- "ubd device %d, err = %d", offset, i,11941194- -err);11951195-11961196- n = os_read_file(dev->fd, (void *) address, PAGE_SIZE);11971197- if(n != PAGE_SIZE)11981198- panic("Failed to read page from offset %llx of "11991199- "COW file of ubd device %d, err = %d",12001200- offset, i, -n);12011201- }12021202-12031203- return(1);12041204- }12051205-12061206- /* It's not a write on a ubd device */12071207- return(0);12081208-}12091209-12101210-static struct remapper ubd_remapper = {12111211- .list = LIST_HEAD_INIT(ubd_remapper.list),12121212- .proc = ubd_check_remapped,12131213-};12141214-12151215-static int ubd_remapper_setup(void)12161216-{12171217- if(ubd_do_mmap)12181218- register_remapper(&ubd_remapper);12191219-12201220- return(0);12211221-}12221222-12231223-__initcall(ubd_remapper_setup);1224123112251232static int same_backing_files(char *from_cmdline, char *from_cow, char *cow)12261233{···12861567 int n, nsectors, start, end, bit;12871568 int err;12881569 __u64 off;12891289-12901290- if(req->op == UBD_MMAP){12911291- /* Touch the page to force the host to do any necessary IO to12921292- * get it into memory12931293- */12941294- n = *((volatile int *) req->buffer);12951295- req->error = update_bitmap(req);12961296- return;12971297- }1298157012991571 nsectors = req->length / req->sectorsize;13001572 start = 0;
···99#include "linux/in6.h"1010#include "asm/uaccess.h"11111212-extern unsigned int csum_partial_copy_from(const unsigned char *src, unsigned char *dst, int len,1313- int sum, int *err_ptr);1412extern unsigned csum_partial(const unsigned char *buff, unsigned len,1513 unsigned sum);1614···2931}30323133static __inline__3232-unsigned int csum_partial_copy_from_user(const unsigned char *src, unsigned char *dst,3333- int len, int sum, int *err_ptr)3434+unsigned int csum_partial_copy_from_user(const unsigned char *src,3535+ unsigned char *dst, int len, int sum,3636+ int *err_ptr)3437{3535- return csum_partial_copy_from(src, dst, len, sum, err_ptr);3838+ if(copy_from_user(dst, src, len)){3939+ *err_ptr = -EFAULT;4040+ return(-1);4141+ }4242+ return csum_partial(dst, len, sum);3643}37443845/**···140137 return a;141138}142139143143-#endif140140+extern unsigned short ip_compute_csum(unsigned char * buff, int len);144141145145-/*146146- * Overrides for Emacs so that we follow Linus's tabbing style.147147- * Emacs will notice this stuff at the end of the file and automatically148148- * adjust the settings for this buffer only. This must remain at the end149149- * of the file.150150- * ---------------------------------------------------------------------------151151- * Local variables:152152- * c-file-style: "linux"153153- * End:154154- */142142+#endif
+26-36
arch/um/include/sysdep-x86_64/ptrace.h
···135135 __CHOOSE_MODE(SC_EFLAGS(UPT_SC(r)), REGS_EFLAGS((r)->skas.regs))136136#define UPT_SC(r) ((r)->tt.sc)137137#define UPT_SYSCALL_NR(r) __CHOOSE_MODE((r)->tt.syscall, (r)->skas.syscall)138138+#define UPT_SYSCALL_RET(r) UPT_RAX(r)138139139140extern int user_context(unsigned long sp);140141···197196198197199198#define UPT_SET(regs, reg, val) \200200- ({ unsigned long val; \199199+ ({ unsigned long __upt_val = val; \201200 switch(reg){ \202202- case R8: UPT_R8(regs) = val; break; \203203- case R9: UPT_R9(regs) = val; break; \204204- case R10: UPT_R10(regs) = val; break; \205205- case R11: UPT_R11(regs) = val; break; \206206- case R12: UPT_R12(regs) = val; break; \207207- case R13: UPT_R13(regs) = val; break; \208208- case R14: UPT_R14(regs) = val; break; \209209- case R15: UPT_R15(regs) = val; break; \210210- case RIP: UPT_IP(regs) = val; break; \211211- case RSP: UPT_SP(regs) = val; break; \212212- case RAX: UPT_RAX(regs) = val; break; \213213- case RBX: UPT_RBX(regs) = val; break; \214214- case RCX: UPT_RCX(regs) = val; break; \215215- case RDX: UPT_RDX(regs) = val; break; \216216- case RSI: UPT_RSI(regs) = val; break; \217217- case RDI: UPT_RDI(regs) = val; break; \218218- case RBP: UPT_RBP(regs) = val; break; \219219- case ORIG_RAX: UPT_ORIG_RAX(regs) = val; break; \220220- case CS: UPT_CS(regs) = val; break; \221221- case DS: UPT_DS(regs) = val; break; \222222- case ES: UPT_ES(regs) = val; break; \223223- case FS: UPT_FS(regs) = val; break; \224224- case GS: UPT_GS(regs) = val; break; \225225- case EFLAGS: UPT_EFLAGS(regs) = val; break; \201201+ case R8: UPT_R8(regs) = __upt_val; break; \202202+ case R9: UPT_R9(regs) = __upt_val; break; \203203+ case R10: UPT_R10(regs) = __upt_val; break; \204204+ case R11: UPT_R11(regs) = __upt_val; break; \205205+ case R12: UPT_R12(regs) = __upt_val; break; \206206+ case R13: UPT_R13(regs) = __upt_val; break; \207207+ case R14: UPT_R14(regs) = __upt_val; break; \208208+ case R15: UPT_R15(regs) = __upt_val; break; \209209+ case RIP: UPT_IP(regs) = __upt_val; break; \210210+ case RSP: UPT_SP(regs) = __upt_val; break; \211211+ case RAX: UPT_RAX(regs) = __upt_val; break; \212212+ case RBX: UPT_RBX(regs) = __upt_val; break; \213213+ case RCX: UPT_RCX(regs) = __upt_val; break; \214214+ case RDX: UPT_RDX(regs) = __upt_val; break; \215215+ case RSI: UPT_RSI(regs) = __upt_val; break; \216216+ case RDI: UPT_RDI(regs) = __upt_val; break; \217217+ case RBP: UPT_RBP(regs) = __upt_val; break; \218218+ case ORIG_RAX: UPT_ORIG_RAX(regs) = __upt_val; break; \219219+ case CS: UPT_CS(regs) = __upt_val; break; \220220+ case DS: UPT_DS(regs) = __upt_val; break; \221221+ case ES: UPT_ES(regs) = __upt_val; break; \222222+ case FS: UPT_FS(regs) = __upt_val; break; \223223+ case GS: UPT_GS(regs) = __upt_val; break; \224224+ case EFLAGS: UPT_EFLAGS(regs) = __upt_val; break; \226225 default : \227226 panic("Bad register in UPT_SET : %d\n", reg); \228227 break; \···246245 CHOOSE_MODE((&(r)->tt.faultinfo), (&(r)->skas.faultinfo))247246248247#endif249249-250250-/*251251- * Overrides for Emacs so that we follow Linus's tabbing style.252252- * Emacs will notice this stuff at the end of the file and automatically253253- * adjust the settings for this buffer only. This must remain at the end254254- * of the file.255255- * ---------------------------------------------------------------------------256256- * Local variables:257257- * c-file-style: "linux"258258- * End:259259- */
···11+/*22+ * Copyright (C) 2000, 2001, 2002 Jeff Dike (jdike@karaya.com)33+ * Licensed under the GPL44+ */55+66+#include "linux/init.h"77+#include "linux/bootmem.h"88+#include "linux/initrd.h"99+#include "asm/types.h"1010+#include "user_util.h"1111+#include "kern_util.h"1212+#include "initrd.h"1313+#include "init.h"1414+#include "os.h"1515+1616+/* Changed by uml_initrd_setup, which is a setup */1717+static char *initrd __initdata = NULL;1818+1919+static int __init read_initrd(void)2020+{2121+ void *area;2222+ long long size;2323+ int err;2424+2525+ if(initrd == NULL) return 0;2626+ err = os_file_size(initrd, &size);2727+ if(err) return 0;2828+ area = alloc_bootmem(size);2929+ if(area == NULL) return 0;3030+ if(load_initrd(initrd, area, size) == -1) return 0;3131+ initrd_start = (unsigned long) area;3232+ initrd_end = initrd_start + size;3333+ return 0;3434+}3535+3636+__uml_postsetup(read_initrd);3737+3838+static int __init uml_initrd_setup(char *line, int *add)3939+{4040+ initrd = line;4141+ return 0;4242+}4343+4444+__uml_setup("initrd=", uml_initrd_setup,4545+"initrd=<initrd image>\n"4646+" This is used to boot UML from an initrd image. The argument is the\n"4747+" name of the file containing the image.\n\n"4848+);4949+5050+int load_initrd(char *filename, void *buf, int size)5151+{5252+ int fd, n;5353+5454+ fd = os_open_file(filename, of_read(OPENFLAGS()), 0);5555+ if(fd < 0){5656+ printk("Opening '%s' failed - err = %d\n", filename, -fd);5757+ return(-1);5858+ }5959+ n = os_read_file(fd, buf, size);6060+ if(n != size){6161+ printk("Read of %d bytes from '%s' failed, err = %d\n", size,6262+ filename, -n);6363+ return(-1);6464+ }6565+6666+ os_close_file(fd);6767+ return(0);6868+}6969+/*7070+ * Overrides for Emacs so that we follow Linus's tabbing style.7171+ * Emacs will notice this stuff at the end of the file and automatically7272+ * adjust the settings for this buffer only. This must remain at the end7373+ * of the file.7474+ * ---------------------------------------------------------------------------7575+ * Local variables:7676+ * c-file-style: "linux"7777+ * End:7878+ */
···73737474 .got : { *(.got.plt) *(.got) }7575 .dynamic : { *(.dynamic) }7676+ .tdata : { *(.tdata .tdata.* .gnu.linkonce.td.*) }7777+ .tbss : { *(.tbss .tbss.* .gnu.linkonce.tb.*) *(.tcommon) }7678 /* We want the small data sections together, so single-instruction offsets7779 can access them all, and initialized data all before uninitialized, so7880 we can shorten the on-disk segment size. */
···55 * Licensed under the GPL66 */7788-#include "linux/delay.h"99-#include "asm/processor.h"1010-#include "asm/param.h"88+#include <linux/module.h>99+#include <linux/delay.h>1010+#include <asm/processor.h>1111+#include <asm/param.h>11121213void __delay(unsigned long loops)1314{1415 unsigned long i;15161616- for(i = 0; i < loops; i++) ;1717+ for(i = 0; i < loops; i++)1818+ cpu_relax();1719}18201921void __udelay(unsigned long usecs)2022{2121- int i, n;2323+ unsigned long i, n;22242325 n = (loops_per_jiffy * HZ * usecs) / MILLION;2424- for(i=0;i<n;i++) ;2626+ for(i=0;i<n;i++)2727+ cpu_relax();2528}2929+3030+EXPORT_SYMBOL(__udelay);26312732void __const_udelay(unsigned long usecs)2833{2929- int i, n;3434+ unsigned long i, n;30353136 n = (loops_per_jiffy * HZ * usecs) / MILLION;3232- for(i=0;i<n;i++) ;3737+ for(i=0;i<n;i++)3838+ cpu_relax();3339}34403535-/*3636- * Overrides for Emacs so that we follow Linus's tabbing style.3737- * Emacs will notice this stuff at the end of the file and automatically3838- * adjust the settings for this buffer only. This must remain at the end3939- * of the file.4040- * ---------------------------------------------------------------------------4141- * Local variables:4242- * c-file-style: "linux"4343- * End:4444- */4141+EXPORT_SYMBOL(__const_udelay);
···1515#include "asm/unistd.h"1616#include "asm/prctl.h" /* XXX This should get the constants from libc */1717#include "choose-mode.h"1818+#include "kern.h"18191920asmlinkage long sys_uname64(struct new_utsname __user * name)2021{
+8
arch/um/sys-x86_64/user-offsets.c
···33#include <signal.h>44#define __FRAME_OFFSETS55#include <asm/ptrace.h>66+#include <asm/types.h>77+/* For some reason, x86_64 defines u64 and u32 only in <pci/types.h>, which I88+ * refuse to include here, even though they're used throughout the headers.99+ * These are used in asm/user.h, and that include can't be avoided because of1010+ * the sizeof(struct user_regs_struct) below.1111+ */1212+typedef __u64 u64;1313+typedef __u32 u32;614#include <asm/user.h>715816#define DEFINE(sym, val) \
+10-1
arch/x86_64/kernel/io_apic.c
···42424343int sis_apic_bug; /* not actually supported, dummy for compile */44444545+static int no_timer_check;4646+4547static DEFINE_SPINLOCK(ioapic_lock);46484749/*···16031601 * Ok, does IRQ0 through the IOAPIC work?16041602 */16051603 unmask_IO_APIC_irq(0);16061606- if (timer_irq_works()) {16041604+ if (!no_timer_check && timer_irq_works()) {16071605 nmi_watchdog_default();16081606 if (nmi_watchdog == NMI_IO_APIC) {16091607 disable_8259A_irq(0);···16721670 apic_printk(APIC_VERBOSE," failed :(.\n");16731671 panic("IO-APIC + timer doesn't work! Try using the 'noapic' kernel parameter\n");16741672}16731673+16741674+static int __init notimercheck(char *s)16751675+{16761676+ no_timer_check = 1;16771677+ return 1;16781678+}16791679+__setup("no_timer_check", notimercheck);1675168016761681/*16771682 *
+2-2
arch/x86_64/kernel/ptrace.c
···380380 break;381381382382 switch (addr) { 383383- case 0 ... sizeof(struct user_regs_struct):383383+ case 0 ... sizeof(struct user_regs_struct) - sizeof(long):384384 tmp = getreg(child, addr);385385 break;386386 case offsetof(struct user, u_debugreg[0]):···425425 break;426426427427 switch (addr) { 428428- case 0 ... sizeof(struct user_regs_struct): 428428+ case 0 ... sizeof(struct user_regs_struct) - sizeof(long):429429 ret = putreg(child, addr, data);430430 break;431431 /* Disallows to set a breakpoint into the vsyscall */
+12-13
arch/x86_64/kernel/setup.c
···719719 }720720}721721722722-#ifdef CONFIG_SMP723722/*724723 * On a AMD dual core setup the lower bits of the APIC id distingush the cores.725724 * Assumes number of cores is a power of two.···728729#ifdef CONFIG_SMP729730 int cpu = smp_processor_id();730731 int node = 0;732732+ unsigned bits;731733 if (c->x86_num_cores == 1)732734 return;733733- /* Fix up the APIC ID following the AMD specification. */734734- cpu_core_id[cpu] >>= hweight32(c->x86_num_cores - 1);735735+736736+ bits = 0;737737+ while ((1 << bits) < c->x86_num_cores)738738+ bits++;739739+740740+ /* Low order bits define the core id (index of core in socket) */741741+ cpu_core_id[cpu] = phys_proc_id[cpu] & ((1 << bits)-1);742742+ /* Convert the APIC ID into the socket ID */743743+ phys_proc_id[cpu] >>= bits;735744736745#ifdef CONFIG_NUMA737746 /* When an ACPI SRAT table is available use the mappings from SRAT738747 instead. */739748 if (acpi_numa <= 0) {740740- node = cpu_core_id[cpu];749749+ node = phys_proc_id[cpu];741750 if (!node_online(node))742751 node = first_node(node_online_map);743752 cpu_to_node[cpu] = node;···753746 node = cpu_to_node[cpu];754747 }755748#endif756756- /* For now: - better than BAD_APIC_ID at least*/757757- phys_proc_id[cpu] = cpu_core_id[cpu];758749759750 printk(KERN_INFO "CPU %d(%d) -> Node %d -> Core %d\n",760751 cpu, c->x86_num_cores, node, cpu_core_id[cpu]);761752#endif762753}763763-#else764764-static void __init amd_detect_cmp(struct cpuinfo_x86 *c)765765-{766766-}767767-#endif768754769755static int __init init_amd(struct cpuinfo_x86 *c)770756{···963963 }964964965965#ifdef CONFIG_SMP966966- phys_proc_id[smp_processor_id()] =967967- cpu_core_id[smp_processor_id()] = (cpuid_ebx(1) >> 24) & 0xff;966966+ phys_proc_id[smp_processor_id()] = (cpuid_ebx(1) >> 24) & 0xff;968967#endif969968}970969
···94949595cpumask_t cpu_sibling_map[NR_CPUS] __cacheline_aligned;9696cpumask_t cpu_core_map[NR_CPUS] __cacheline_aligned;9797+EXPORT_SYMBOL(cpu_core_map);97989899/*99100 * Trampoline 80x86 program as an array.
+8-21
arch/x86_64/mm/ioremap.c
···133133 unsigned long flags)134134{135135 int err = 0;136136- if (flags && phys_addr + size - 1 < (end_pfn_map << PAGE_SHIFT)) {136136+ if (phys_addr + size - 1 < (end_pfn_map << PAGE_SHIFT)) {137137 unsigned long npages = (size + PAGE_SIZE - 1) >> PAGE_SHIFT;138138 unsigned long vaddr = (unsigned long) __va(phys_addr);139139···214214 remove_vm_area((void *)(PAGE_MASK & (unsigned long) addr));215215 return NULL;216216 }217217- if (ioremap_change_attr(phys_addr, size, flags) < 0) {217217+ if (flags && ioremap_change_attr(phys_addr, size, flags) < 0) {218218 area->flags &= 0xffffff;219219 vunmap(addr);220220 return NULL;···251251252252void iounmap(volatile void __iomem *addr)253253{254254- struct vm_struct *p, **pprev;254254+ struct vm_struct *p;255255256256 if (addr <= high_memory) 257257 return; ···260260 return;261261262262 write_lock(&vmlist_lock);263263- for (p = vmlist, pprev = &vmlist; p != NULL; pprev = &p->next, p = *pprev)264264- if (p->addr == (void *)(PAGE_MASK & (unsigned long)addr))265265- break;266266- if (!p) { 267267- printk("__iounmap: bad address %p\n", addr);268268- goto out_unlock;269269- }270270- *pprev = p->next;271271- unmap_vm_area(p);272272- if ((p->flags >> 20) &&273273- p->phys_addr + p->size - 1 < virt_to_phys(high_memory)) {274274- /* p->size includes the guard page, but cpa doesn't like that */275275- change_page_attr_addr((unsigned long)__va(p->phys_addr),276276- p->size >> PAGE_SHIFT,277277- PAGE_KERNEL);278278- global_flush_tlb();279279- } 280280-out_unlock:263263+ p = __remove_vm_area((void *)((unsigned long)addr & PAGE_MASK));264264+ if (!p)265265+ printk("iounmap: bad address %p\n", addr);266266+ else if (p->flags >> 20)267267+ ioremap_change_attr(p->phys_addr, p->size, 0);281268 write_unlock(&vmlist_lock);282269 kfree(p); 283270}
+7-1
drivers/block/pktcdvd.c
···20212021 BUG_ON(pd->refcnt < 0);2022202220232023 pd->refcnt++;20242024- if (pd->refcnt == 1) {20242024+ if (pd->refcnt > 1) {20252025+ if ((file->f_mode & FMODE_WRITE) &&20262026+ !test_bit(PACKET_WRITABLE, &pd->flags)) {20272027+ ret = -EBUSY;20282028+ goto out_dec;20292029+ }20302030+ } else {20252031 if (pkt_open_dev(pd, file->f_mode & FMODE_WRITE)) {20262032 ret = -EIO;20272033 goto out_dec;
+18-2
drivers/char/ipmi/ipmi_devintf.c
···4444#include <linux/ipmi.h>4545#include <asm/semaphore.h>4646#include <linux/init.h>4747+#include <linux/device.h>47484849#define IPMI_DEVINTF_VERSION "v33"4950···520519 " interface. Other values will set the major device number"521520 " to that value.");522521522522+static struct class *ipmi_class;523523+523524static void ipmi_new_smi(int if_num)524525{525525- devfs_mk_cdev(MKDEV(ipmi_major, if_num),526526- S_IFCHR | S_IRUSR | S_IWUSR,526526+ dev_t dev = MKDEV(ipmi_major, if_num);527527+528528+ devfs_mk_cdev(dev, S_IFCHR | S_IRUSR | S_IWUSR,527529 "ipmidev/%d", if_num);530530+531531+ class_simple_device_add(ipmi_class, dev, NULL, "ipmi%d", if_num);528532}529533530534static void ipmi_smi_gone(int if_num)531535{536536+ class_simple_device_remove(ipmi_class, MKDEV(ipmi_major, if_num));532537 devfs_remove("ipmidev/%d", if_num);533538}534539···555548 printk(KERN_INFO "ipmi device interface version "556549 IPMI_DEVINTF_VERSION "\n");557550551551+ ipmi_class = class_simple_create(THIS_MODULE, "ipmi");552552+ if (IS_ERR(ipmi_class)) {553553+ printk(KERN_ERR "ipmi: can't register device class\n");554554+ return PTR_ERR(ipmi_class);555555+ }556556+558557 rv = register_chrdev(ipmi_major, DEVICE_NAME, &ipmi_fops);559558 if (rv < 0) {559559+ class_simple_destroy(ipmi_class);560560 printk(KERN_ERR "ipmi: can't get major %d\n", ipmi_major);561561 return rv;562562 }···577563 rv = ipmi_smi_watcher_register(&smi_watcher);578564 if (rv) {579565 unregister_chrdev(ipmi_major, DEVICE_NAME);566566+ class_simple_destroy(ipmi_class);580567 printk(KERN_WARNING "ipmi: can't register smi watcher\n");581568 return rv;582569 }···588573589574static __exit void cleanup_ipmi(void)590575{576576+ class_simple_destroy(ipmi_class);591577 ipmi_smi_watcher_unregister(&smi_watcher);592578 devfs_remove(DEVICE_NAME);593579 unregister_chrdev(ipmi_major, DEVICE_NAME);
+5
drivers/i2c/busses/i2c-keywest.c
···516516 u32 *psteps, *prate;517517 int rc;518518519519+ if (np->n_intrs < 1 || np->n_addrs < 1) {520520+ printk(KERN_ERR "%s: Missing interrupt or address !\n",521521+ np->full_name);522522+ return -ENODEV;523523+ }519524 if (pmac_low_i2c_lock(np))520525 return -ENODEV;521526
+4-1
drivers/mmc/mmc_block.c
···383383 struct mmc_blk_data *md;384384 int err;385385386386- if (card->csd.cmdclass & ~0x1ff)386386+ /*387387+ * Check that the card supports the command class(es) we need.388388+ */389389+ if (!(card->csd.cmdclass & CCC_BLOCK_READ))387390 return -ENODEV;388391389392 if (card->csd.read_blkbits < 9) {
+364-116
drivers/net/tg3.c
···420420{421421 tw32(TG3PCI_MISC_HOST_CTRL,422422 (tp->misc_host_ctrl & ~MISC_HOST_CTRL_MASK_PCI_INT));423423- tw32_mailbox(MAILBOX_INTERRUPT_0 + TG3_64BIT_REG_LOW, 0x00000000);423423+ tw32_mailbox(MAILBOX_INTERRUPT_0 + TG3_64BIT_REG_LOW,424424+ (tp->last_tag << 24));424425 tr32(MAILBOX_INTERRUPT_0 + TG3_64BIT_REG_LOW);425426426427 tg3_cond_int(tp);···456455{457456 tw32(TG3PCI_MISC_HOST_CTRL,458457 (tp->misc_host_ctrl & ~MISC_HOST_CTRL_MASK_PCI_INT));459459- tw32_mailbox(MAILBOX_INTERRUPT_0 + TG3_64BIT_REG_LOW, 0x00000000);458458+ tw32_mailbox(MAILBOX_INTERRUPT_0 + TG3_64BIT_REG_LOW,459459+ tp->last_tag << 24);460460 mmiowb();461461462462- if (tg3_has_work(tp))462462+ /* When doing tagged status, this work check is unnecessary.463463+ * The last_tag we write above tells the chip which piece of464464+ * work we've completed.465465+ */466466+ if (!(tp->tg3_flags & TG3_FLAG_TAGGED_STATUS) &&467467+ tg3_has_work(tp))463468 tw32(HOSTCC_MODE, tp->coalesce_mode |464469 (HOSTCC_MODE_ENABLE | HOSTCC_MODE_NOW));465470}···25072500 if (!(tp->tg3_flags2 & TG3_FLG2_5705_PLUS)) {25082501 if (netif_carrier_ok(tp->dev)) {25092502 tw32(HOSTCC_STAT_COAL_TICKS,25102510- DEFAULT_STAT_COAL_TICKS);25032503+ tp->coal.stats_block_coalesce_usecs);25112504 } else {25122505 tw32(HOSTCC_STAT_COAL_TICKS, 0);25132506 }···28932886 * All RX "locking" is done by ensuring outside28942887 * code synchronizes with dev->poll()28952888 */28962896- done = 1;28972889 if (sblk->idx[0].rx_producer != tp->rx_rcb_ptr) {28982890 int orig_budget = *budget;28992891 int work_done;···2904289829052899 *budget -= work_done;29062900 netdev->quota -= work_done;29072907-29082908- if (work_done >= orig_budget)29092909- done = 0;29102901 }2911290229032903+ if (tp->tg3_flags & TG3_FLAG_TAGGED_STATUS)29042904+ tp->last_tag = sblk->status_tag;29052905+ rmb();29062906+29122907 /* if no more work, tell net stack and NIC we're done */29082908+ done = !tg3_has_work(tp);29132909 if (done) {29142910 spin_lock_irqsave(&tp->lock, flags);29152911 __netif_rx_complete(netdev);···29362928 spin_lock_irqsave(&tp->lock, flags);2937292929382930 /*29392939- * writing any value to intr-mbox-0 clears PCI INTA# and29312931+ * Writing any value to intr-mbox-0 clears PCI INTA# and29402932 * chip-internal interrupt pending events.29412941- * writing non-zero to intr-mbox-0 additional tells the29332933+ * Writing non-zero to intr-mbox-0 additional tells the29422934 * NIC to stop sending us irqs, engaging "in-intr-handler"29432935 * event coalescing.29442936 */29452937 tw32_mailbox(MAILBOX_INTERRUPT_0 + TG3_64BIT_REG_LOW, 0x00000001);29382938+ tp->last_tag = sblk->status_tag;29462939 sblk->status &= ~SD_STATUS_UPDATED;29472947-29482940 if (likely(tg3_has_work(tp)))29492941 netif_rx_schedule(dev); /* schedule NAPI poll */29502942 else {29512951- /* no work, re-enable interrupts29522952- */29432943+ /* No work, re-enable interrupts. */29532944 tw32_mailbox(MAILBOX_INTERRUPT_0 + TG3_64BIT_REG_LOW,29542954- 0x00000000);29452945+ tp->last_tag << 24);29552946 }2956294729572948 spin_unlock_irqrestore(&tp->lock, flags);···29762969 if ((sblk->status & SD_STATUS_UPDATED) ||29772970 !(tr32(TG3PCI_PCISTATE) & PCISTATE_INT_NOT_ACTIVE)) {29782971 /*29722972+ * Writing any value to intr-mbox-0 clears PCI INTA# and29732973+ * chip-internal interrupt pending events.29742974+ * Writing non-zero to intr-mbox-0 additional tells the29752975+ * NIC to stop sending us irqs, engaging "in-intr-handler"29762976+ * event coalescing.29772977+ */29782978+ tw32_mailbox(MAILBOX_INTERRUPT_0 + TG3_64BIT_REG_LOW,29792979+ 0x00000001);29802980+ sblk->status &= ~SD_STATUS_UPDATED;29812981+ if (likely(tg3_has_work(tp)))29822982+ netif_rx_schedule(dev); /* schedule NAPI poll */29832983+ else {29842984+ /* No work, shared interrupt perhaps? re-enable29852985+ * interrupts, and flush that PCI write29862986+ */29872987+ tw32_mailbox(MAILBOX_INTERRUPT_0 + TG3_64BIT_REG_LOW,29882988+ 0x00000000);29892989+ tr32(MAILBOX_INTERRUPT_0 + TG3_64BIT_REG_LOW);29902990+ }29912991+ } else { /* shared interrupt */29922992+ handled = 0;29932993+ }29942994+29952995+ spin_unlock_irqrestore(&tp->lock, flags);29962996+29972997+ return IRQ_RETVAL(handled);29982998+}29992999+30003000+static irqreturn_t tg3_interrupt_tagged(int irq, void *dev_id, struct pt_regs *regs)30013001+{30023002+ struct net_device *dev = dev_id;30033003+ struct tg3 *tp = netdev_priv(dev);30043004+ struct tg3_hw_status *sblk = tp->hw_status;30053005+ unsigned long flags;30063006+ unsigned int handled = 1;30073007+30083008+ spin_lock_irqsave(&tp->lock, flags);30093009+30103010+ /* In INTx mode, it is possible for the interrupt to arrive at30113011+ * the CPU before the status block posted prior to the interrupt.30123012+ * Reading the PCI State register will confirm whether the30133013+ * interrupt is ours and will flush the status block.30143014+ */30153015+ if ((sblk->status & SD_STATUS_UPDATED) ||30163016+ !(tr32(TG3PCI_PCISTATE) & PCISTATE_INT_NOT_ACTIVE)) {30173017+ /*29793018 * writing any value to intr-mbox-0 clears PCI INTA# and29803019 * chip-internal interrupt pending events.29813020 * writing non-zero to intr-mbox-0 additional tells the···30302977 */30312978 tw32_mailbox(MAILBOX_INTERRUPT_0 + TG3_64BIT_REG_LOW,30322979 0x00000001);30333033- /*30343034- * Flush PCI write. This also guarantees that our30353035- * status block has been flushed to host memory.30363036- */30373037- tr32(MAILBOX_INTERRUPT_0 + TG3_64BIT_REG_LOW);29802980+ tp->last_tag = sblk->status_tag;30382981 sblk->status &= ~SD_STATUS_UPDATED;30393039-30402982 if (likely(tg3_has_work(tp)))30412983 netif_rx_schedule(dev); /* schedule NAPI poll */30422984 else {···30392991 * interrupts, and flush that PCI write30402992 */30412993 tw32_mailbox(MAILBOX_INTERRUPT_0 + TG3_64BIT_REG_LOW,30423042- 0x00000000);29942994+ tp->last_tag << 24);30432995 tr32(MAILBOX_INTERRUPT_0 + TG3_64BIT_REG_LOW);30442996 }30452997 } else { /* shared interrupt */···50925044}5093504550945046static void __tg3_set_rx_mode(struct net_device *);50475047+static void tg3_set_coalesce(struct tg3 *tp, struct ethtool_coalesce *ec)50485048+{50495049+ tw32(HOSTCC_RXCOL_TICKS, ec->rx_coalesce_usecs);50505050+ tw32(HOSTCC_TXCOL_TICKS, ec->tx_coalesce_usecs);50515051+ tw32(HOSTCC_RXMAX_FRAMES, ec->rx_max_coalesced_frames);50525052+ tw32(HOSTCC_TXMAX_FRAMES, ec->tx_max_coalesced_frames);50535053+ if (!(tp->tg3_flags2 & TG3_FLG2_5705_PLUS)) {50545054+ tw32(HOSTCC_RXCOAL_TICK_INT, ec->rx_coalesce_usecs_irq);50555055+ tw32(HOSTCC_TXCOAL_TICK_INT, ec->tx_coalesce_usecs_irq);50565056+ }50575057+ tw32(HOSTCC_RXCOAL_MAXF_INT, ec->rx_max_coalesced_frames_irq);50585058+ tw32(HOSTCC_TXCOAL_MAXF_INT, ec->tx_max_coalesced_frames_irq);50595059+ if (!(tp->tg3_flags2 & TG3_FLG2_5705_PLUS)) {50605060+ u32 val = ec->stats_block_coalesce_usecs;50615061+50625062+ if (!netif_carrier_ok(tp->dev))50635063+ val = 0;50645064+50655065+ tw32(HOSTCC_STAT_COAL_TICKS, val);50665066+ }50675067+}5095506850965069/* tp->lock is held. */50975070static int tg3_reset_hw(struct tg3 *tp)···54355366 udelay(10);54365367 }5437536854385438- tw32(HOSTCC_RXCOL_TICKS, 0);54395439- tw32(HOSTCC_TXCOL_TICKS, LOW_TXCOL_TICKS);54405440- tw32(HOSTCC_RXMAX_FRAMES, 1);54415441- tw32(HOSTCC_TXMAX_FRAMES, LOW_RXMAX_FRAMES);54425442- if (!(tp->tg3_flags2 & TG3_FLG2_5705_PLUS)) {54435443- tw32(HOSTCC_RXCOAL_TICK_INT, 0);54445444- tw32(HOSTCC_TXCOAL_TICK_INT, 0);54455445- }54465446- tw32(HOSTCC_RXCOAL_MAXF_INT, 1);54475447- tw32(HOSTCC_TXCOAL_MAXF_INT, 0);53695369+ tg3_set_coalesce(tp, &tp->coal);5448537054495371 /* set status block DMA address */54505372 tw32(HOSTCC_STATUS_BLK_HOST_ADDR + TG3_64BIT_REG_HIGH,···54485388 * the tg3_periodic_fetch_stats call there, and54495389 * tg3_get_stats to see how this works for 5705/5750 chips.54505390 */54515451- tw32(HOSTCC_STAT_COAL_TICKS,54525452- DEFAULT_STAT_COAL_TICKS);54535391 tw32(HOSTCC_STATS_BLK_HOST_ADDR + TG3_64BIT_REG_HIGH,54545392 ((u64) tp->stats_mapping >> 32));54555393 tw32(HOSTCC_STATS_BLK_HOST_ADDR + TG3_64BIT_REG_LOW,···55035445 udelay(100);5504544655055447 tw32_mailbox(MAILBOX_INTERRUPT_0 + TG3_64BIT_REG_LOW, 0);55065506- tr32(MAILBOX_INTERRUPT_0);54485448+ tr32(MAILBOX_INTERRUPT_0 + TG3_64BIT_REG_LOW);54495449+ tp->last_tag = 0;5507545055085451 if (!(tp->tg3_flags2 & TG3_FLG2_5705_PLUS)) {55095452 tw32_f(DMAC_MODE, DMAC_MODE_ENABLE);···57825723 spin_lock_irqsave(&tp->lock, flags);57835724 spin_lock(&tp->tx_lock);5784572557855785- /* All of this garbage is because when using non-tagged57865786- * IRQ status the mailbox/status_block protocol the chip57875787- * uses with the cpu is race prone.57885788- */57895789- if (tp->hw_status->status & SD_STATUS_UPDATED) {57905790- tw32(GRC_LOCAL_CTRL,57915791- tp->grc_local_ctrl | GRC_LCLCTRL_SETINT);57925792- } else {57935793- tw32(HOSTCC_MODE, tp->coalesce_mode |57945794- (HOSTCC_MODE_ENABLE | HOSTCC_MODE_NOW));57955795- }57265726+ if (!(tp->tg3_flags & TG3_FLAG_TAGGED_STATUS)) {57275727+ /* All of this garbage is because when using non-tagged57285728+ * IRQ status the mailbox/status_block protocol the chip57295729+ * uses with the cpu is race prone.57305730+ */57315731+ if (tp->hw_status->status & SD_STATUS_UPDATED) {57325732+ tw32(GRC_LOCAL_CTRL,57335733+ tp->grc_local_ctrl | GRC_LCLCTRL_SETINT);57345734+ } else {57355735+ tw32(HOSTCC_MODE, tp->coalesce_mode |57365736+ (HOSTCC_MODE_ENABLE | HOSTCC_MODE_NOW));57375737+ }5796573857975797- if (!(tr32(WDMAC_MODE) & WDMAC_MODE_ENABLE)) {57985798- tp->tg3_flags2 |= TG3_FLG2_RESTART_TIMER;57995799- spin_unlock(&tp->tx_lock);58005800- spin_unlock_irqrestore(&tp->lock, flags);58015801- schedule_work(&tp->reset_task);58025802- return;57395739+ if (!(tr32(WDMAC_MODE) & WDMAC_MODE_ENABLE)) {57405740+ tp->tg3_flags2 |= TG3_FLG2_RESTART_TIMER;57415741+ spin_unlock(&tp->tx_lock);57425742+ spin_unlock_irqrestore(&tp->lock, flags);57435743+ schedule_work(&tp->reset_task);57445744+ return;57455745+ }58035746 }58045804-58055805- if (tp->tg3_flags2 & TG3_FLG2_5705_PLUS)58065806- tg3_periodic_fetch_stats(tp);5807574758085748 /* This part only runs once per second. */58095749 if (!--tp->timer_counter) {57505750+ if (tp->tg3_flags2 & TG3_FLG2_5705_PLUS)57515751+ tg3_periodic_fetch_stats(tp);57525752+58105753 if (tp->tg3_flags & TG3_FLAG_USE_LINKCHG_REG) {58115754 u32 mac_stat;58125755 int phy_event;···59075846 if (tp->tg3_flags2 & TG3_FLG2_USING_MSI)59085847 err = request_irq(tp->pdev->irq, tg3_msi,59095848 SA_SAMPLE_RANDOM, dev->name, dev);59105910- else59115911- err = request_irq(tp->pdev->irq, tg3_interrupt,58495849+ else {58505850+ irqreturn_t (*fn)(int, void *, struct pt_regs *)=tg3_interrupt;58515851+ if (tp->tg3_flags & TG3_FLAG_TAGGED_STATUS)58525852+ fn = tg3_interrupt_tagged;58535853+ err = request_irq(tp->pdev->irq, fn,59125854 SA_SHIRQ | SA_SAMPLE_RANDOM, dev->name, dev);58555855+ }5913585659145857 if (err)59155858 return err;···5965590059665901 tp->tg3_flags2 &= ~TG3_FLG2_USING_MSI;5967590259685968- err = request_irq(tp->pdev->irq, tg3_interrupt,59695969- SA_SHIRQ | SA_SAMPLE_RANDOM, dev->name, dev);59035903+ {59045904+ irqreturn_t (*fn)(int, void *, struct pt_regs *)=tg3_interrupt;59055905+ if (tp->tg3_flags & TG3_FLAG_TAGGED_STATUS)59065906+ fn = tg3_interrupt_tagged;5970590759085908+ err = request_irq(tp->pdev->irq, fn,59095909+ SA_SHIRQ | SA_SAMPLE_RANDOM, dev->name, dev);59105910+ }59715911 if (err)59725912 return err;59735913···60185948 if ((tp->tg3_flags2 & TG3_FLG2_5750_PLUS) &&60195949 (GET_CHIP_REV(tp->pci_chip_rev_id) != CHIPREV_5750_AX) &&60205950 (GET_CHIP_REV(tp->pci_chip_rev_id) != CHIPREV_5750_BX)) {60216021- if (pci_enable_msi(tp->pdev) == 0) {59515951+ /* All MSI supporting chips should support tagged59525952+ * status. Assert that this is the case.59535953+ */59545954+ if (!(tp->tg3_flags & TG3_FLAG_TAGGED_STATUS)) {59555955+ printk(KERN_WARNING PFX "%s: MSI without TAGGED? "59565956+ "Not using MSI.\n", tp->dev->name);59575957+ } else if (pci_enable_msi(tp->pdev) == 0) {60225958 u32 msi_mode;6023595960245960 msi_mode = tr32(MSGINT_MODE);···60355959 if (tp->tg3_flags2 & TG3_FLG2_USING_MSI)60365960 err = request_irq(tp->pdev->irq, tg3_msi,60375961 SA_SAMPLE_RANDOM, dev->name, dev);60386038- else60396039- err = request_irq(tp->pdev->irq, tg3_interrupt,59625962+ else {59635963+ irqreturn_t (*fn)(int, void *, struct pt_regs *)=tg3_interrupt;59645964+ if (tp->tg3_flags & TG3_FLAG_TAGGED_STATUS)59655965+ fn = tg3_interrupt_tagged;59665966+59675967+ err = request_irq(tp->pdev->irq, fn,60405968 SA_SHIRQ | SA_SAMPLE_RANDOM, dev->name, dev);59695969+ }6041597060425971 if (err) {60435972 if (tp->tg3_flags2 & TG3_FLG2_USING_MSI) {···60615980 tg3_halt(tp, 1);60625981 tg3_free_rings(tp);60635982 } else {60646064- tp->timer_offset = HZ / 10;60656065- tp->timer_counter = tp->timer_multiplier = 10;60666066- tp->asf_counter = tp->asf_multiplier = (10 * 120);59835983+ if (tp->tg3_flags & TG3_FLAG_TAGGED_STATUS)59845984+ tp->timer_offset = HZ;59855985+ else59865986+ tp->timer_offset = HZ / 10;59875987+59885988+ BUG_ON(tp->timer_offset > HZ);59895989+ tp->timer_counter = tp->timer_multiplier =59905990+ (HZ / tp->timer_offset);59915991+ tp->asf_counter = tp->asf_multiplier =59925992+ ((HZ / tp->timer_offset) * 120);6067599360685994 init_timer(&tp->timer);60695995 tp->timer.expires = jiffies + tp->timer_offset;···6093600560946006 if (tp->tg3_flags2 & TG3_FLG2_USING_MSI) {60956007 err = tg3_test_msi(tp);60086008+60966009 if (err) {60976010 spin_lock_irq(&tp->lock);60986011 spin_lock(&tp->tx_lock);···72927203}72937204#endif7294720572067206+static int tg3_get_coalesce(struct net_device *dev, struct ethtool_coalesce *ec)72077207+{72087208+ struct tg3 *tp = netdev_priv(dev);72097209+72107210+ memcpy(ec, &tp->coal, sizeof(*ec));72117211+ return 0;72127212+}72137213+72957214static struct ethtool_ops tg3_ethtool_ops = {72967215 .get_settings = tg3_get_settings,72977216 .set_settings = tg3_set_settings,···73327235 .get_strings = tg3_get_strings,73337236 .get_stats_count = tg3_get_stats_count,73347237 .get_ethtool_stats = tg3_get_ethtool_stats,72387238+ .get_coalesce = tg3_get_coalesce,73357239};7336724073377241static void __devinit tg3_get_eeprom_size(struct tg3 *tp)···85208422 if (tp->tg3_flags2 & TG3_FLG2_5705_PLUS)85218423 tp->tg3_flags2 |= TG3_FLG2_PHY_BER_BUG;8522842485238523- /* Only 5701 and later support tagged irq status mode.85248524- * Also, 5788 chips cannot use tagged irq status.85258525- *85268526- * However, since we are using NAPI avoid tagged irq status85278527- * because the interrupt condition is more difficult to85288528- * fully clear in that mode.85298529- */85308425 tp->coalesce_mode = 0;85318531-85328426 if (GET_CHIP_REV(tp->pci_chip_rev_id) != CHIPREV_5700_AX &&85338427 GET_CHIP_REV(tp->pci_chip_rev_id) != CHIPREV_5700_BX)85348428 tp->coalesce_mode |= HOSTCC_MODE_32BYTE;···85838493 (grc_misc_cfg == GRC_MISC_CFG_BOARD_ID_5788 ||85848494 grc_misc_cfg == GRC_MISC_CFG_BOARD_ID_5788M))85858495 tp->tg3_flags2 |= TG3_FLG2_IS_5788;84968496+84978497+ if (!(tp->tg3_flags2 & TG3_FLG2_IS_5788) &&84988498+ (GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5700))84998499+ tp->tg3_flags |= TG3_FLAG_TAGGED_STATUS;85008500+ if (tp->tg3_flags & TG3_FLAG_TAGGED_STATUS) {85018501+ tp->coalesce_mode |= (HOSTCC_MODE_CLRTICK_RXBD |85028502+ HOSTCC_MODE_CLRTICK_TXBD);85038503+85048504+ tp->misc_host_ctrl |= MISC_HOST_CTRL_TAGGED_STATUS;85058505+ pci_write_config_dword(tp->pdev, TG3PCI_MISC_HOST_CTRL,85068506+ tp->misc_host_ctrl);85078507+ }8586850885878509 /* these are limited to 10/100 only */85888510 if ((GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5703 &&···87738671 return 0;87748672}8775867386748674+#define BOUNDARY_SINGLE_CACHELINE 186758675+#define BOUNDARY_MULTI_CACHELINE 286768676+86778677+static u32 __devinit tg3_calc_dma_bndry(struct tg3 *tp, u32 val)86788678+{86798679+ int cacheline_size;86808680+ u8 byte;86818681+ int goal;86828682+86838683+ pci_read_config_byte(tp->pdev, PCI_CACHE_LINE_SIZE, &byte);86848684+ if (byte == 0)86858685+ cacheline_size = 1024;86868686+ else86878687+ cacheline_size = (int) byte * 4;86888688+86898689+ /* On 5703 and later chips, the boundary bits have no86908690+ * effect.86918691+ */86928692+ if (GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5700 &&86938693+ GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5701 &&86948694+ !(tp->tg3_flags2 & TG3_FLG2_PCI_EXPRESS))86958695+ goto out;86968696+86978697+#if defined(CONFIG_PPC64) || defined(CONFIG_IA64) || defined(CONFIG_PARISC)86988698+ goal = BOUNDARY_MULTI_CACHELINE;86998699+#else87008700+#if defined(CONFIG_SPARC64) || defined(CONFIG_ALPHA)87018701+ goal = BOUNDARY_SINGLE_CACHELINE;87028702+#else87038703+ goal = 0;87048704+#endif87058705+#endif87068706+87078707+ if (!goal)87088708+ goto out;87098709+87108710+ /* PCI controllers on most RISC systems tend to disconnect87118711+ * when a device tries to burst across a cache-line boundary.87128712+ * Therefore, letting tg3 do so just wastes PCI bandwidth.87138713+ *87148714+ * Unfortunately, for PCI-E there are only limited87158715+ * write-side controls for this, and thus for reads87168716+ * we will still get the disconnects. We'll also waste87178717+ * these PCI cycles for both read and write for chips87188718+ * other than 5700 and 5701 which do not implement the87198719+ * boundary bits.87208720+ */87218721+ if ((tp->tg3_flags & TG3_FLAG_PCIX_MODE) &&87228722+ !(tp->tg3_flags2 & TG3_FLG2_PCI_EXPRESS)) {87238723+ switch (cacheline_size) {87248724+ case 16:87258725+ case 32:87268726+ case 64:87278727+ case 128:87288728+ if (goal == BOUNDARY_SINGLE_CACHELINE) {87298729+ val |= (DMA_RWCTRL_READ_BNDRY_128_PCIX |87308730+ DMA_RWCTRL_WRITE_BNDRY_128_PCIX);87318731+ } else {87328732+ val |= (DMA_RWCTRL_READ_BNDRY_384_PCIX |87338733+ DMA_RWCTRL_WRITE_BNDRY_384_PCIX);87348734+ }87358735+ break;87368736+87378737+ case 256:87388738+ val |= (DMA_RWCTRL_READ_BNDRY_256_PCIX |87398739+ DMA_RWCTRL_WRITE_BNDRY_256_PCIX);87408740+ break;87418741+87428742+ default:87438743+ val |= (DMA_RWCTRL_READ_BNDRY_384_PCIX |87448744+ DMA_RWCTRL_WRITE_BNDRY_384_PCIX);87458745+ break;87468746+ };87478747+ } else if (tp->tg3_flags2 & TG3_FLG2_PCI_EXPRESS) {87488748+ switch (cacheline_size) {87498749+ case 16:87508750+ case 32:87518751+ case 64:87528752+ if (goal == BOUNDARY_SINGLE_CACHELINE) {87538753+ val &= ~DMA_RWCTRL_WRITE_BNDRY_DISAB_PCIE;87548754+ val |= DMA_RWCTRL_WRITE_BNDRY_64_PCIE;87558755+ break;87568756+ }87578757+ /* fallthrough */87588758+ case 128:87598759+ default:87608760+ val &= ~DMA_RWCTRL_WRITE_BNDRY_DISAB_PCIE;87618761+ val |= DMA_RWCTRL_WRITE_BNDRY_128_PCIE;87628762+ break;87638763+ };87648764+ } else {87658765+ switch (cacheline_size) {87668766+ case 16:87678767+ if (goal == BOUNDARY_SINGLE_CACHELINE) {87688768+ val |= (DMA_RWCTRL_READ_BNDRY_16 |87698769+ DMA_RWCTRL_WRITE_BNDRY_16);87708770+ break;87718771+ }87728772+ /* fallthrough */87738773+ case 32:87748774+ if (goal == BOUNDARY_SINGLE_CACHELINE) {87758775+ val |= (DMA_RWCTRL_READ_BNDRY_32 |87768776+ DMA_RWCTRL_WRITE_BNDRY_32);87778777+ break;87788778+ }87798779+ /* fallthrough */87808780+ case 64:87818781+ if (goal == BOUNDARY_SINGLE_CACHELINE) {87828782+ val |= (DMA_RWCTRL_READ_BNDRY_64 |87838783+ DMA_RWCTRL_WRITE_BNDRY_64);87848784+ break;87858785+ }87868786+ /* fallthrough */87878787+ case 128:87888788+ if (goal == BOUNDARY_SINGLE_CACHELINE) {87898789+ val |= (DMA_RWCTRL_READ_BNDRY_128 |87908790+ DMA_RWCTRL_WRITE_BNDRY_128);87918791+ break;87928792+ }87938793+ /* fallthrough */87948794+ case 256:87958795+ val |= (DMA_RWCTRL_READ_BNDRY_256 |87968796+ DMA_RWCTRL_WRITE_BNDRY_256);87978797+ break;87988798+ case 512:87998799+ val |= (DMA_RWCTRL_READ_BNDRY_512 |88008800+ DMA_RWCTRL_WRITE_BNDRY_512);88018801+ break;88028802+ case 1024:88038803+ default:88048804+ val |= (DMA_RWCTRL_READ_BNDRY_1024 |88058805+ DMA_RWCTRL_WRITE_BNDRY_1024);88068806+ break;88078807+ };88088808+ }88098809+88108810+out:88118811+ return val;88128812+}88138813+87768814static int __devinit tg3_do_test_dma(struct tg3 *tp, u32 *buf, dma_addr_t buf_dma, int size, int to_device)87778815{87788816 struct tg3_internal_buffer_desc test_desc;···89998757static int __devinit tg3_test_dma(struct tg3 *tp)90008758{90018759 dma_addr_t buf_dma;90029002- u32 *buf;87608760+ u32 *buf, saved_dma_rwctrl;90038761 int ret;9004876290058763 buf = pci_alloc_consistent(tp->pdev, TEST_BUFFER_SIZE, &buf_dma);···90118769 tp->dma_rwctrl = ((0x7 << DMA_RWCTRL_PCI_WRITE_CMD_SHIFT) |90128770 (0x6 << DMA_RWCTRL_PCI_READ_CMD_SHIFT));9013877190149014-#ifndef CONFIG_X8690159015- {90169016- u8 byte;90179017- int cacheline_size;90189018- pci_read_config_byte(tp->pdev, PCI_CACHE_LINE_SIZE, &byte);90199019-90209020- if (byte == 0)90219021- cacheline_size = 1024;90229022- else90239023- cacheline_size = (int) byte * 4;90249024-90259025- switch (cacheline_size) {90269026- case 16:90279027- case 32:90289028- case 64:90299029- case 128:90309030- if ((tp->tg3_flags & TG3_FLAG_PCIX_MODE) &&90319031- !(tp->tg3_flags2 & TG3_FLG2_PCI_EXPRESS)) {90329032- tp->dma_rwctrl |=90339033- DMA_RWCTRL_WRITE_BNDRY_384_PCIX;90349034- break;90359035- } else if (tp->tg3_flags2 & TG3_FLG2_PCI_EXPRESS) {90369036- tp->dma_rwctrl &=90379037- ~(DMA_RWCTRL_PCI_WRITE_CMD);90389038- tp->dma_rwctrl |=90399039- DMA_RWCTRL_WRITE_BNDRY_128_PCIE;90409040- break;90419041- }90429042- /* fallthrough */90439043- case 256:90449044- if (!(tp->tg3_flags & TG3_FLAG_PCIX_MODE) &&90459045- !(tp->tg3_flags2 & TG3_FLG2_PCI_EXPRESS))90469046- tp->dma_rwctrl |=90479047- DMA_RWCTRL_WRITE_BNDRY_256;90489048- else if (!(tp->tg3_flags2 & TG3_FLG2_PCI_EXPRESS))90499049- tp->dma_rwctrl |=90509050- DMA_RWCTRL_WRITE_BNDRY_256_PCIX;90519051- };90529052- }90539053-#endif87728772+ tp->dma_rwctrl = tg3_calc_dma_bndry(tp, tp->dma_rwctrl);9054877390558774 if (tp->tg3_flags2 & TG3_FLG2_PCI_EXPRESS) {90568775 /* DMA read watermark not used on PCIE */···90308827 if (ccval == 0x6 || ccval == 0x7)90318828 tp->dma_rwctrl |= DMA_RWCTRL_ONE_DMA;9032882990339033- /* Set bit 23 to renable PCIX hw bug fix */88308830+ /* Set bit 23 to enable PCIX hw bug fix */90348831 tp->dma_rwctrl |= 0x009f0000;90358832 } else {90368833 tp->dma_rwctrl |= 0x001b000f;···90718868 GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5701)90728869 goto out;9073887088718871+ /* It is best to perform DMA test with maximum write burst size88728872+ * to expose the 5700/5701 write DMA bug.88738873+ */88748874+ saved_dma_rwctrl = tp->dma_rwctrl;88758875+ tp->dma_rwctrl &= ~DMA_RWCTRL_WRITE_BNDRY_MASK;88768876+ tw32(TG3PCI_DMA_RW_CTRL, tp->dma_rwctrl);88778877+90748878 while (1) {90758879 u32 *p = buf, i;90768880···91168906 if (p[i] == i)91178907 continue;9118890891199119- if ((tp->dma_rwctrl & DMA_RWCTRL_WRITE_BNDRY_MASK) ==91209120- DMA_RWCTRL_WRITE_BNDRY_DISAB) {89098909+ if ((tp->dma_rwctrl & DMA_RWCTRL_WRITE_BNDRY_MASK) !=89108910+ DMA_RWCTRL_WRITE_BNDRY_16) {89118911+ tp->dma_rwctrl &= ~DMA_RWCTRL_WRITE_BNDRY_MASK;91218912 tp->dma_rwctrl |= DMA_RWCTRL_WRITE_BNDRY_16;91228913 tw32(TG3PCI_DMA_RW_CTRL, tp->dma_rwctrl);91238914 break;···91348923 ret = 0;91358924 break;91368925 }89268926+ }89278927+ if ((tp->dma_rwctrl & DMA_RWCTRL_WRITE_BNDRY_MASK) !=89288928+ DMA_RWCTRL_WRITE_BNDRY_16) {89298929+ /* DMA test passed without adjusting DMA boundary,89308930+ * just restore the calculated DMA boundary89318931+ */89328932+ tp->dma_rwctrl = saved_dma_rwctrl;89338933+ tw32(TG3PCI_DMA_RW_CTRL, tp->dma_rwctrl);91378934 }9138893591398936out:···92289009 pci_dev_put(peer);9229901092309011 return peer;90129012+}90139013+90149014+static void __devinit tg3_init_coal(struct tg3 *tp)90159015+{90169016+ struct ethtool_coalesce *ec = &tp->coal;90179017+90189018+ memset(ec, 0, sizeof(*ec));90199019+ ec->cmd = ETHTOOL_GCOALESCE;90209020+ ec->rx_coalesce_usecs = LOW_RXCOL_TICKS;90219021+ ec->tx_coalesce_usecs = LOW_TXCOL_TICKS;90229022+ ec->rx_max_coalesced_frames = LOW_RXMAX_FRAMES;90239023+ ec->tx_max_coalesced_frames = LOW_TXMAX_FRAMES;90249024+ ec->rx_coalesce_usecs_irq = DEFAULT_RXCOAL_TICK_INT;90259025+ ec->tx_coalesce_usecs_irq = DEFAULT_TXCOAL_TICK_INT;90269026+ ec->rx_max_coalesced_frames_irq = DEFAULT_RXCOAL_MAXF_INT;90279027+ ec->tx_max_coalesced_frames_irq = DEFAULT_TXCOAL_MAXF_INT;90289028+ ec->stats_block_coalesce_usecs = DEFAULT_STAT_COAL_TICKS;90299029+90309030+ if (tp->coalesce_mode & (HOSTCC_MODE_CLRTICK_RXBD |90319031+ HOSTCC_MODE_CLRTICK_TXBD)) {90329032+ ec->rx_coalesce_usecs = LOW_RXCOL_TICKS_CLRTCKS;90339033+ ec->rx_coalesce_usecs_irq = DEFAULT_RXCOAL_TICK_INT_CLRTCKS;90349034+ ec->tx_coalesce_usecs = LOW_TXCOL_TICKS_CLRTCKS;90359035+ ec->tx_coalesce_usecs_irq = DEFAULT_TXCOAL_TICK_INT_CLRTCKS;90369036+ }92319037}9232903892339039static int __devinit tg3_init_one(struct pci_dev *pdev,···95009256 /* flow control autonegotiation is default behavior */95019257 tp->tg3_flags |= TG3_FLAG_PAUSE_AUTONEG;9502925892599259+ tg3_init_coal(tp);92609260+95039261 err = register_netdev(dev);95049262 if (err) {95059263 printk(KERN_ERR PFX "Cannot register net device, "···95449298 (tp->tg3_flags & TG3_FLAG_SPLIT_MODE) != 0,95459299 (tp->tg3_flags2 & TG3_FLG2_NO_ETH_WIRE_SPEED) == 0,95469300 (tp->tg3_flags2 & TG3_FLG2_TSO_CAPABLE) != 0);93019301+ printk(KERN_INFO "%s: dma_rwctrl[%08x]\n",93029302+ dev->name, tp->dma_rwctrl);9547930395489304 return 0;95499305
···682682 * from EXCR1. Switch back to bank 0, change it in MCR. Then683683 * switch back to bank 2, read it from EXCR1 again and check684684 * it's changed. If so, set baud_base in EXCR2 to 921600. -- dwmw2685685- * On PowerPC we don't want to change baud_base, as we have686686- * a number of different divisors. -- Tom Rini687685 */688686 serial_outp(up, UART_LCR, 0);689687 status1 = serial_in(up, UART_MCR);···697699 serial_outp(up, UART_MCR, status1);698700699701 if ((status2 ^ status1) & UART_MCR_LOOP) {700700-#ifndef CONFIG_PPC702702+ unsigned short quot;703703+701704 serial_outp(up, UART_LCR, 0xE0);705705+706706+ quot = serial_inp(up, UART_DLM) << 8;707707+ quot += serial_inp(up, UART_DLL);708708+ quot <<= 3;709709+702710 status1 = serial_in(up, 0x04); /* EXCR1 */703711 status1 &= ~0xB0; /* Disable LOCK, mask out PRESL[01] */704712 status1 |= 0x10; /* 1.625 divisor for baud_base --> 921600 */705713 serial_outp(up, 0x04, status1);706706- serial_outp(up, UART_LCR, 0);707707- up->port.uartclk = 921600*16;708708-#endif714714+715715+ serial_outp(up, UART_DLL, quot & 0xff);716716+ serial_outp(up, UART_DLM, quot >> 8);709717718718+ serial_outp(up, UART_LCR, 0);719719+720720+ up->port.uartclk = 921600*16;710721 up->port.type = PORT_NS16550A;711722 up->capabilities |= UART_NATSEMI;712723 return;
+71-38
drivers/serial/sunsab.c
···6161 unsigned char pvr_dtr_bit; /* Which PVR bit is DTR */6262 unsigned char pvr_dsr_bit; /* Which PVR bit is DSR */6363 int type; /* SAB82532 version */6464+6565+ /* Setting configuration bits while the transmitter is active6666+ * can cause garbage characters to get emitted by the chip.6767+ * Therefore, we cache such writes here and do the real register6868+ * write the next time the transmitter becomes idle.6969+ */7070+ unsigned int cached_ebrg;7171+ unsigned char cached_mode;7272+ unsigned char cached_pvr;7373+ unsigned char cached_dafo;6474};65756676/*···246236}247237248238static void sunsab_stop_tx(struct uart_port *, unsigned int);239239+static void sunsab_tx_idle(struct uart_sunsab_port *);249240250241static void transmit_chars(struct uart_sunsab_port *up,251242 union sab82532_irq_status *stat)···269258 return;270259271260 set_bit(SAB82532_XPR, &up->irqflags);261261+ sunsab_tx_idle(up);272262273263 if (uart_circ_empty(xmit) || uart_tx_stopped(&up->port)) {274264 up->interrupt_mask1 |= SAB82532_IMR1_XPR;···409397 struct uart_sunsab_port *up = (struct uart_sunsab_port *) port;410398411399 if (mctrl & TIOCM_RTS) {412412- writeb(readb(&up->regs->rw.mode) & ~SAB82532_MODE_FRTS,413413- &up->regs->rw.mode);414414- writeb(readb(&up->regs->rw.mode) | SAB82532_MODE_RTS,415415- &up->regs->rw.mode);400400+ up->cached_mode &= ~SAB82532_MODE_FRTS;401401+ up->cached_mode |= SAB82532_MODE_RTS;416402 } else {417417- writeb(readb(&up->regs->rw.mode) | SAB82532_MODE_FRTS,418418- &up->regs->rw.mode);419419- writeb(readb(&up->regs->rw.mode) | SAB82532_MODE_RTS,420420- &up->regs->rw.mode);403403+ up->cached_mode |= (SAB82532_MODE_FRTS |404404+ SAB82532_MODE_RTS);421405 }422406 if (mctrl & TIOCM_DTR) {423423- writeb(readb(&up->regs->rw.pvr) & ~(up->pvr_dtr_bit), &up->regs->rw.pvr);407407+ up->cached_pvr &= ~(up->pvr_dtr_bit);424408 } else {425425- writeb(readb(&up->regs->rw.pvr) | up->pvr_dtr_bit, &up->regs->rw.pvr);409409+ up->cached_pvr |= up->pvr_dtr_bit;426410 }411411+412412+ set_bit(SAB82532_REGS_PENDING, &up->irqflags);413413+ if (test_bit(SAB82532_XPR, &up->irqflags))414414+ sunsab_tx_idle(up);427415}428416429417/* port->lock is not held. */···459447460448 up->interrupt_mask1 |= SAB82532_IMR1_XPR;461449 writeb(up->interrupt_mask1, &up->regs->w.imr1);450450+}451451+452452+/* port->lock held by caller. */453453+static void sunsab_tx_idle(struct uart_sunsab_port *up)454454+{455455+ if (test_bit(SAB82532_REGS_PENDING, &up->irqflags)) {456456+ u8 tmp;457457+458458+ clear_bit(SAB82532_REGS_PENDING, &up->irqflags);459459+ writeb(up->cached_mode, &up->regs->rw.mode);460460+ writeb(up->cached_pvr, &up->regs->rw.pvr);461461+ writeb(up->cached_dafo, &up->regs->w.dafo);462462+463463+ writeb(up->cached_ebrg & 0xff, &up->regs->w.bgr);464464+ tmp = readb(&up->regs->rw.ccr2);465465+ tmp &= ~0xc0;466466+ tmp |= (up->cached_ebrg >> 2) & 0xc0;467467+ writeb(tmp, &up->regs->rw.ccr2);468468+ }462469}463470464471/* port->lock held by caller. */···548517549518 spin_lock_irqsave(&up->port.lock, flags);550519551551- val = readb(&up->regs->rw.dafo);520520+ val = up->cached_dafo;552521 if (break_state)553522 val |= SAB82532_DAFO_XBRK;554523 else555524 val &= ~SAB82532_DAFO_XBRK;556556- writeb(val, &up->regs->rw.dafo);525525+ up->cached_dafo = val;526526+527527+ set_bit(SAB82532_REGS_PENDING, &up->irqflags);528528+ if (test_bit(SAB82532_XPR, &up->irqflags))529529+ sunsab_tx_idle(up);557530558531 spin_unlock_irqrestore(&up->port.lock, flags);559532}···601566 SAB82532_CCR2_TOE, &up->regs->w.ccr2);602567 writeb(0, &up->regs->w.ccr3);603568 writeb(SAB82532_CCR4_MCK4 | SAB82532_CCR4_EBRG, &up->regs->w.ccr4);604604- writeb(SAB82532_MODE_RTS | SAB82532_MODE_FCTS |605605- SAB82532_MODE_RAC, &up->regs->w.mode);569569+ up->cached_mode = (SAB82532_MODE_RTS | SAB82532_MODE_FCTS |570570+ SAB82532_MODE_RAC);571571+ writeb(up->cached_mode, &up->regs->w.mode);606572 writeb(SAB82532_RFC_DPS|SAB82532_RFC_RFTH_32, &up->regs->w.rfc);607573608574 tmp = readb(&up->regs->rw.ccr0);···634598{635599 struct uart_sunsab_port *up = (struct uart_sunsab_port *) port;636600 unsigned long flags;637637- unsigned char tmp;638601639602 spin_lock_irqsave(&up->port.lock, flags);640603···644609 writeb(up->interrupt_mask1, &up->regs->w.imr1);645610646611 /* Disable break condition */647647- tmp = readb(&up->regs->rw.dafo);648648- tmp &= ~SAB82532_DAFO_XBRK;649649- writeb(tmp, &up->regs->rw.dafo);612612+ up->cached_dafo = readb(&up->regs->rw.dafo);613613+ up->cached_dafo &= ~SAB82532_DAFO_XBRK;614614+ writeb(up->cached_dafo, &up->regs->rw.dafo);650615651616 /* Disable Receiver */ 652652- tmp = readb(&up->regs->rw.mode);653653- tmp &= ~SAB82532_MODE_RAC;654654- writeb(tmp, &up->regs->rw.mode);617617+ up->cached_mode &= ~SAB82532_MODE_RAC;618618+ writeb(up->cached_mode, &up->regs->rw.mode);655619656620 /*657621 * XXX FIXME···719685 unsigned int iflag, unsigned int baud,720686 unsigned int quot)721687{722722- unsigned int ebrg;723688 unsigned char dafo;724689 int bits, n, m;725690···747714 } else {748715 dafo |= SAB82532_DAFO_PAR_EVEN;749716 }717717+ up->cached_dafo = dafo;750718751719 calc_ebrg(baud, &n, &m);752720753753- ebrg = n | (m << 6);721721+ up->cached_ebrg = n | (m << 6);754722755723 up->tec_timeout = (10 * 1000000) / baud;756724 up->cec_timeout = up->tec_timeout >> 2;···804770 uart_update_timeout(&up->port, cflag,805771 (up->port.uartclk / (16 * quot)));806772807807- /* Now bang the new settings into the chip. */808808- sunsab_cec_wait(up);809809- sunsab_tec_wait(up);810810- writeb(dafo, &up->regs->w.dafo);811811- writeb(ebrg & 0xff, &up->regs->w.bgr);812812- writeb((readb(&up->regs->rw.ccr2) & ~0xc0) | ((ebrg >> 2) & 0xc0),813813- &up->regs->rw.ccr2);814814-815815- writeb(readb(&up->regs->rw.mode) | SAB82532_MODE_RAC, &up->regs->rw.mode);816816-773773+ /* Now schedule a register update when the chip's774774+ * transmitter is idle.775775+ */776776+ up->cached_mode |= SAB82532_MODE_RAC;777777+ set_bit(SAB82532_REGS_PENDING, &up->irqflags);778778+ if (test_bit(SAB82532_XPR, &up->irqflags))779779+ sunsab_tx_idle(up);817780}818781819782/* port->lock is not held. */···11151084 up->pvr_dsr_bit = (1 << 3);11161085 up->pvr_dtr_bit = (1 << 2);11171086 }11181118- writeb((1 << 1) | (1 << 2) | (1 << 4), &up->regs->w.pvr);11191119- writeb(readb(&up->regs->rw.mode) | SAB82532_MODE_FRTS,11201120- &up->regs->rw.mode);11211121- writeb(readb(&up->regs->rw.mode) | SAB82532_MODE_RTS,11221122- &up->regs->rw.mode);10871087+ up->cached_pvr = (1 << 1) | (1 << 2) | (1 << 4);10881088+ writeb(up->cached_pvr, &up->regs->w.pvr);10891089+ up->cached_mode = readb(&up->regs->rw.mode);10901090+ up->cached_mode |= SAB82532_MODE_FRTS;10911091+ writeb(up->cached_mode, &up->regs->rw.mode);10921092+ up->cached_mode |= SAB82532_MODE_RTS;10931093+ writeb(up->cached_mode, &up->regs->rw.mode);1123109411241095 up->tec_timeout = SAB82532_MAX_TEC_TIMEOUT;11251096 up->cec_timeout = SAB82532_MAX_CEC_TIMEOUT;
···230230 __constant_cpu_to_le32(0xffffffff)},}231231};232232233233-const struct in_core_key MAX_IN_CORE_KEY = {~0U, ~0U, ~0ULL>>4, 15};234233235234/* Get delimiting key of the buffer by looking for it in the buffers in the path, starting from the bottom236235 of the path, and going upwards. We must check the path's validity at each step. If the key is not in
···8899#include <asm/user.h>10101111+/* x86-64 relocation types, taken from asm-x86_64/elf.h */1212+#define R_X86_64_NONE 0 /* No reloc */1313+#define R_X86_64_64 1 /* Direct 64 bit */1414+#define R_X86_64_PC32 2 /* PC relative 32 bit signed */1515+#define R_X86_64_GOT32 3 /* 32 bit GOT entry */1616+#define R_X86_64_PLT32 4 /* 32 bit PLT address */1717+#define R_X86_64_COPY 5 /* Copy symbol at runtime */1818+#define R_X86_64_GLOB_DAT 6 /* Create GOT entry */1919+#define R_X86_64_JUMP_SLOT 7 /* Create PLT entry */2020+#define R_X86_64_RELATIVE 8 /* Adjust by program base */2121+#define R_X86_64_GOTPCREL 9 /* 32 bit signed pc relative2222+ offset to GOT */2323+#define R_X86_64_32 10 /* Direct 32 bit zero extended */2424+#define R_X86_64_32S 11 /* Direct 32 bit sign extended */2525+#define R_X86_64_16 12 /* Direct 16 bit zero extended */2626+#define R_X86_64_PC16 13 /* 16 bit sign extended pc relative */2727+#define R_X86_64_8 14 /* Direct 8 bit sign extended */2828+#define R_X86_64_PC8 15 /* 8 bit sign extended pc relative */2929+3030+#define R_X86_64_NUM 163131+1132typedef unsigned long elf_greg_t;12331334#define ELF_NGREG (sizeof (struct user_regs_struct) / sizeof(elf_greg_t))···6544} while (0)66456746#ifdef TIF_IA32 /* XXX */6868- clear_thread_flag(TIF_IA32); \4747+#error XXX, indeed4848+ clear_thread_flag(TIF_IA32);6949#endif70507151#define USE_ELF_CORE_DUMP
include/asm-x86_64/ioctl32.h
+3-1
include/linux/err.h
···1313 * This should be a per-architecture thing, to allow different1414 * error and pointer decisions.1515 */1616+#define IS_ERR_VALUE(x) unlikely((x) > (unsigned long)-1000L)1717+1618static inline void *ERR_PTR(long error)1719{1820 return (void *) error;···27252826static inline long IS_ERR(const void *ptr)2927{3030- return unlikely((unsigned long)ptr > (unsigned long)-1000L);2828+ return IS_ERR_VALUE((unsigned long)ptr);3129}32303331#endif /* _LINUX_ERR_H */
···4141extern struct vm_struct *__get_vm_area(unsigned long size, unsigned long flags,4242 unsigned long start, unsigned long end);4343extern struct vm_struct *remove_vm_area(void *addr);4444+extern struct vm_struct *__remove_vm_area(void *addr);4445extern int map_vm_area(struct vm_struct *area, pgprot_t prot,4546 struct page ***pages);4647extern void unmap_vm_area(struct vm_struct *area);
+2-2
include/net/act_generic.h
···22 * include/net/act_generic.h33 *44*/55-#ifndef ACT_GENERIC_H66-#define ACT_GENERIC_H55+#ifndef _NET_ACT_GENERIC_H66+#define _NET_ACT_GENERIC_H77static inline int tcf_defact_release(struct tcf_defact *p, int bind)88{99 int ret = 0;
+6
include/scsi/scsi_transport_spi.h
···27272828struct spi_transport_attrs {2929 int period; /* value in the PPR/SDTR command */3030+ int min_period;3031 int offset;3232+ int max_offset;3133 unsigned int width:1; /* 0 - narrow, 1 - wide */3434+ unsigned int max_width:1;3235 unsigned int iu:1; /* Information Units enabled */3336 unsigned int dt:1; /* DT clocking enabled */3437 unsigned int qas:1; /* Quick Arbitration and Selection enabled */···66636764/* accessor functions */6865#define spi_period(x) (((struct spi_transport_attrs *)&(x)->starget_data)->period)6666+#define spi_min_period(x) (((struct spi_transport_attrs *)&(x)->starget_data)->min_period)6967#define spi_offset(x) (((struct spi_transport_attrs *)&(x)->starget_data)->offset)6868+#define spi_max_offset(x) (((struct spi_transport_attrs *)&(x)->starget_data)->max_offset)7069#define spi_width(x) (((struct spi_transport_attrs *)&(x)->starget_data)->width)7070+#define spi_max_width(x) (((struct spi_transport_attrs *)&(x)->starget_data)->max_width)7171#define spi_iu(x) (((struct spi_transport_attrs *)&(x)->starget_data)->iu)7272#define spi_dt(x) (((struct spi_transport_attrs *)&(x)->starget_data)->dt)7373#define spi_qas(x) (((struct spi_transport_attrs *)&(x)->starget_data)->qas)
+1-1
kernel/sched.c
···4243424342444244 /* No more Mr. Nice Guy. */42454245 if (dest_cpu == NR_CPUS) {42464246- tsk->cpus_allowed = cpuset_cpus_allowed(tsk);42464246+ cpus_setall(tsk->cpus_allowed);42474247 dest_cpu = any_online_cpu(tsk->cpus_allowed);4248424842494249 /*
···10041004 if (pos < size) {10051005 retval = generic_file_direct_IO(READ, iocb,10061006 iov, pos, nr_segs);10071007- if (retval >= 0 && !is_sync_kiocb(iocb))10071007+ if (retval > 0 && !is_sync_kiocb(iocb))10081008 retval = -EIOCBQUEUED;10091009 if (retval > 0)10101010 *ppos = pos + retval;
+31-28
mm/mmap.c
···13021302get_unmapped_area(struct file *file, unsigned long addr, unsigned long len,13031303 unsigned long pgoff, unsigned long flags)13041304{13051305- if (flags & MAP_FIXED) {13061306- unsigned long ret;13051305+ unsigned long ret;1307130613081308- if (addr > TASK_SIZE - len)13091309- return -ENOMEM;13101310- if (addr & ~PAGE_MASK)13111311- return -EINVAL;13121312- if (file && is_file_hugepages(file)) {13131313- /*13141314- * Check if the given range is hugepage aligned, and13151315- * can be made suitable for hugepages.13161316- */13171317- ret = prepare_hugepage_range(addr, len);13181318- } else {13191319- /*13201320- * Ensure that a normal request is not falling in a13211321- * reserved hugepage range. For some archs like IA-64,13221322- * there is a separate region for hugepages.13231323- */13241324- ret = is_hugepage_only_range(current->mm, addr, len);13251325- }13261326- if (ret)13271327- return -EINVAL;13281328- return addr;13071307+ if (!(flags & MAP_FIXED)) {13081308+ unsigned long (*get_area)(struct file *, unsigned long, unsigned long, unsigned long, unsigned long);13091309+13101310+ get_area = current->mm->get_unmapped_area;13111311+ if (file && file->f_op && file->f_op->get_unmapped_area)13121312+ get_area = file->f_op->get_unmapped_area;13131313+ addr = get_area(file, addr, len, pgoff, flags);13141314+ if (IS_ERR_VALUE(addr))13151315+ return addr;13291316 }1330131713311331- if (file && file->f_op && file->f_op->get_unmapped_area)13321332- return file->f_op->get_unmapped_area(file, addr, len,13331333- pgoff, flags);13341334-13351335- return current->mm->get_unmapped_area(file, addr, len, pgoff, flags);13181318+ if (addr > TASK_SIZE - len)13191319+ return -ENOMEM;13201320+ if (addr & ~PAGE_MASK)13211321+ return -EINVAL;13221322+ if (file && is_file_hugepages(file)) {13231323+ /*13241324+ * Check if the given range is hugepage aligned, and13251325+ * can be made suitable for hugepages.13261326+ */13271327+ ret = prepare_hugepage_range(addr, len);13281328+ } else {13291329+ /*13301330+ * Ensure that a normal request is not falling in a13311331+ * reserved hugepage range. For some archs like IA-64,13321332+ * there is a separate region for hugepages.13331333+ */13341334+ ret = is_hugepage_only_range(current->mm, addr, len);13351335+ }13361336+ if (ret)13371337+ return -EINVAL;13381338+ return addr;13361339}1337134013381341EXPORT_SYMBOL(get_unmapped_area);
+26-19
mm/vmalloc.c
···248248 return __get_vm_area(size, flags, VMALLOC_START, VMALLOC_END);249249}250250251251+/* Caller must hold vmlist_lock */252252+struct vm_struct *__remove_vm_area(void *addr)253253+{254254+ struct vm_struct **p, *tmp;255255+256256+ for (p = &vmlist ; (tmp = *p) != NULL ;p = &tmp->next) {257257+ if (tmp->addr == addr)258258+ goto found;259259+ }260260+ return NULL;261261+262262+found:263263+ unmap_vm_area(tmp);264264+ *p = tmp->next;265265+266266+ /*267267+ * Remove the guard page.268268+ */269269+ tmp->size -= PAGE_SIZE;270270+ return tmp;271271+}272272+251273/**252274 * remove_vm_area - find and remove a contingous kernel virtual area253275 *···277255 *278256 * Search for the kernel VM area starting at @addr, and remove it.279257 * This function returns the found VM area, but using it is NOT safe280280- * on SMP machines.258258+ * on SMP machines, except for its size or flags.281259 */282260struct vm_struct *remove_vm_area(void *addr)283261{284284- struct vm_struct **p, *tmp;285285-262262+ struct vm_struct *v;286263 write_lock(&vmlist_lock);287287- for (p = &vmlist ; (tmp = *p) != NULL ;p = &tmp->next) {288288- if (tmp->addr == addr)289289- goto found;290290- }264264+ v = __remove_vm_area(addr);291265 write_unlock(&vmlist_lock);292292- return NULL;293293-294294-found:295295- unmap_vm_area(tmp);296296- *p = tmp->next;297297- write_unlock(&vmlist_lock);298298-299299- /*300300- * Remove the guard page.301301- */302302- tmp->size -= PAGE_SIZE;303303- return tmp;266266+ return v;304267}305268306269void __vunmap(void *addr, int deallocate_pages)
+8
net/ipv4/ip_output.c
···490490 /* Partially cloned skb? */491491 if (skb_shared(frag))492492 goto slow_path;493493+494494+ BUG_ON(frag->sk);495495+ if (skb->sk) {496496+ sock_hold(skb->sk);497497+ frag->sk = skb->sk;498498+ frag->destructor = sock_wfree;499499+ skb->truesize -= frag->truesize;500500+ }493501 }494502495503 /* Everything is OK. Generate! */
···735735736736 sock_hold(sk);737737 if (p->skb2 == NULL) {738738- if (atomic_read(&p->skb->users) != 1) {738738+ if (skb_shared(p->skb)) {739739 p->skb2 = skb_clone(p->skb, p->allocation);740740 } else {741741- p->skb2 = p->skb;742742- atomic_inc(&p->skb->users);741741+ p->skb2 = skb_get(p->skb);742742+ /*743743+ * skb ownership may have been set when744744+ * delivered to a previous socket.745745+ */746746+ skb_orphan(p->skb2);743747 }744748 }745749 if (p->skb2 == NULL) {···789785 sk_for_each_bound(sk, node, &nl_table[ssk->sk_protocol].mc_list)790786 do_one_broadcast(sk, &info);791787788788+ kfree_skb(skb);789789+792790 netlink_unlock_table();793791794792 if (info.skb2)795793 kfree_skb(info.skb2);796796- kfree_skb(skb);797794798795 if (info.delivered) {799796 if (info.congested && (allocation & __GFP_WAIT))
+3-25
net/unix/af_unix.c
···770770 err = path_lookup(sunaddr->sun_path, LOOKUP_PARENT, &nd);771771 if (err)772772 goto out_mknod_parent;773773- /*774774- * Yucky last component or no last component at all?775775- * (foo/., foo/.., /////)776776- */777777- err = -EEXIST;778778- if (nd.last_type != LAST_NORM)779779- goto out_mknod;780780- /*781781- * Lock the directory.782782- */783783- down(&nd.dentry->d_inode->i_sem);784784- /*785785- * Do the final lookup.786786- */787787- dentry = lookup_hash(&nd.last, nd.dentry);773773+774774+ dentry = lookup_create(&nd, 0);788775 err = PTR_ERR(dentry);789776 if (IS_ERR(dentry))790777 goto out_mknod_unlock;791791- err = -ENOENT;792792- /*793793- * Special case - lookup gave negative, but... we had foo/bar/794794- * From the vfs_mknod() POV we just have a negative dentry -795795- * all is fine. Let's be bastards - you had / on the end, you've796796- * been asking for (non-existent) directory. -ENOENT for you.797797- */798798- if (nd.last.name[nd.last.len] && !dentry->d_inode)799799- goto out_mknod_dput;778778+800779 /*801780 * All right, let's create it.802781 */···824845 dput(dentry);825846out_mknod_unlock:826847 up(&nd.dentry->d_inode->i_sem);827827-out_mknod:828848 path_release(&nd);829849out_mknod_parent:830850 if (err==-EEXIST)
+1-1
net/xfrm/xfrm_algo.c
···698698 return -ENOMEM;699699700700 if (skb1->sk)701701- skb_set_owner_w(skb, skb1->sk);701701+ skb_set_owner_w(skb2, skb1->sk);702702703703 /* Looking around. Are we still alive?704704 * OK, link new skb, drop old one */
+12-3
net/xfrm/xfrm_user.c
···3434{3535 struct rtattr *rt = xfrma[type - 1];3636 struct xfrm_algo *algp;3737+ int len;37383839 if (!rt)3940 return 0;40414141- if ((rt->rta_len - sizeof(*rt)) < sizeof(*algp))4242+ len = (rt->rta_len - sizeof(*rt)) - sizeof(*algp);4343+ if (len < 0)4244 return -EINVAL;43454446 algp = RTA_DATA(rt);4747+4848+ len -= (algp->alg_key_len + 7U) / 8; 4949+ if (len < 0)5050+ return -EINVAL;5151+4552 switch (type) {4653 case XFRMA_ALG_AUTH:4754 if (!algp->alg_key_len &&···169162 struct rtattr *rta = u_arg;170163 struct xfrm_algo *p, *ualg;171164 struct xfrm_algo_desc *algo;165165+ int len;172166173167 if (!rta)174168 return 0;···181173 return -ENOSYS;182174 *props = algo->desc.sadb_alg_id;183175184184- p = kmalloc(sizeof(*ualg) + ualg->alg_key_len, GFP_KERNEL);176176+ len = sizeof(*ualg) + (ualg->alg_key_len + 7U) / 8;177177+ p = kmalloc(len, GFP_KERNEL);185178 if (!p)186179 return -ENOMEM;187180188188- memcpy(p, ualg, sizeof(*ualg) + ualg->alg_key_len);181181+ memcpy(p, ualg, len);189182 *algpp = p;190183 return 0;191184}