From e745bc74270d1562e6debbba7d8b4eebaa5e5993 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Wed, 9 Jan 2013 10:42:08 -0800 Subject: [PATCH] 3.0-stable patches added patches: cris-fix-i-o-macros.patch drivers-rtc-rtc-vt8500.c-correct-handling-of-cr_24h-bitfield.patch drivers-rtc-rtc-vt8500.c-fix-handling-of-data-passed-in-struct-rtc_time.patch mm-limit-mmu_gather-batching-to-fix-soft-lockups-on-config_preempt.patch --- queue-3.0/cris-fix-i-o-macros.patch | 79 +++++++++++ ...-correct-handling-of-cr_24h-bitfield.patch | 43 ++++++ ...ng-of-data-passed-in-struct-rtc_time.patch | 50 +++++++ ...o-fix-soft-lockups-on-config_preempt.patch | 132 ++++++++++++++++++ queue-3.0/series | 4 + 5 files changed, 308 insertions(+) create mode 100644 queue-3.0/cris-fix-i-o-macros.patch create mode 100644 queue-3.0/drivers-rtc-rtc-vt8500.c-correct-handling-of-cr_24h-bitfield.patch create mode 100644 queue-3.0/drivers-rtc-rtc-vt8500.c-fix-handling-of-data-passed-in-struct-rtc_time.patch create mode 100644 queue-3.0/mm-limit-mmu_gather-batching-to-fix-soft-lockups-on-config_preempt.patch diff --git a/queue-3.0/cris-fix-i-o-macros.patch b/queue-3.0/cris-fix-i-o-macros.patch new file mode 100644 index 00000000000..534d9b0ce13 --- /dev/null +++ b/queue-3.0/cris-fix-i-o-macros.patch @@ -0,0 +1,79 @@ +From c24bf9b4cc6a0f330ea355d73bfdf1dae7e63a05 Mon Sep 17 00:00:00 2001 +From: Corey Minyard +Date: Tue, 18 Dec 2012 14:21:19 -0800 +Subject: CRIS: fix I/O macros + +From: Corey Minyard + +commit c24bf9b4cc6a0f330ea355d73bfdf1dae7e63a05 upstream. + +The inb/outb macros for CRIS are broken from a number of points of view, +missing () around parameters and they have an unprotected if statement +in them. This was breaking the compile of IPMI on CRIS and thus I was +being annoyed by build regressions, so I fixed them. + +Plus I don't think they would have worked at all, since the data values +were missing "&" and the outsl had a "3" instead of a "4" for the size. +From what I can tell, this stuff is not used at all, so this can't be +any more broken than it was before, anyway. + +Signed-off-by: Corey Minyard +Cc: Jesper Nilsson +Cc: Mikael Starvik +Acked-by: Geert Uytterhoeven +Signed-off-by: Andrew Morton +Signed-off-by: Linus Torvalds +Signed-off-by: Greg Kroah-Hartman + +--- + arch/cris/include/asm/io.h | 39 +++++++++++++++++++++++++++++++++------ + 1 file changed, 33 insertions(+), 6 deletions(-) + +--- a/arch/cris/include/asm/io.h ++++ b/arch/cris/include/asm/io.h +@@ -133,12 +133,39 @@ static inline void writel(unsigned int b + #define insb(port,addr,count) (cris_iops ? cris_iops->read_io(port,addr,1,count) : 0) + #define insw(port,addr,count) (cris_iops ? cris_iops->read_io(port,addr,2,count) : 0) + #define insl(port,addr,count) (cris_iops ? cris_iops->read_io(port,addr,4,count) : 0) +-#define outb(data,port) if (cris_iops) cris_iops->write_io(port,(void*)(unsigned)data,1,1) +-#define outw(data,port) if (cris_iops) cris_iops->write_io(port,(void*)(unsigned)data,2,1) +-#define outl(data,port) if (cris_iops) cris_iops->write_io(port,(void*)(unsigned)data,4,1) +-#define outsb(port,addr,count) if(cris_iops) cris_iops->write_io(port,(void*)addr,1,count) +-#define outsw(port,addr,count) if(cris_iops) cris_iops->write_io(port,(void*)addr,2,count) +-#define outsl(port,addr,count) if(cris_iops) cris_iops->write_io(port,(void*)addr,3,count) ++static inline void outb(unsigned char data, unsigned int port) ++{ ++ if (cris_iops) ++ cris_iops->write_io(port, (void *) &data, 1, 1); ++} ++static inline void outw(unsigned short data, unsigned int port) ++{ ++ if (cris_iops) ++ cris_iops->write_io(port, (void *) &data, 2, 1); ++} ++static inline void outl(unsigned int data, unsigned int port) ++{ ++ if (cris_iops) ++ cris_iops->write_io(port, (void *) &data, 4, 1); ++} ++static inline void outsb(unsigned int port, const void *addr, ++ unsigned long count) ++{ ++ if (cris_iops) ++ cris_iops->write_io(port, (void *)addr, 1, count); ++} ++static inline void outsw(unsigned int port, const void *addr, ++ unsigned long count) ++{ ++ if (cris_iops) ++ cris_iops->write_io(port, (void *)addr, 2, count); ++} ++static inline void outsl(unsigned int port, const void *addr, ++ unsigned long count) ++{ ++ if (cris_iops) ++ cris_iops->write_io(port, (void *)addr, 4, count); ++} + + /* + * Convert a physical pointer to a virtual kernel pointer for /dev/mem diff --git a/queue-3.0/drivers-rtc-rtc-vt8500.c-correct-handling-of-cr_24h-bitfield.patch b/queue-3.0/drivers-rtc-rtc-vt8500.c-correct-handling-of-cr_24h-bitfield.patch new file mode 100644 index 00000000000..e61b3e7e2cf --- /dev/null +++ b/queue-3.0/drivers-rtc-rtc-vt8500.c-correct-handling-of-cr_24h-bitfield.patch @@ -0,0 +1,43 @@ +From 532db570e5181abc8f4f7bfa6c77c69ec2240198 Mon Sep 17 00:00:00 2001 +From: Tony Prisk +Date: Fri, 4 Jan 2013 15:35:47 -0800 +Subject: drivers/rtc/rtc-vt8500.c: correct handling of CR_24H bitfield + +From: Tony Prisk + +commit 532db570e5181abc8f4f7bfa6c77c69ec2240198 upstream. + +Control register bitfield for 12H/24H mode is handled incorrectly. +Setting CR_24H actually enables 12H mode. This patch renames the define +and changes the initialization code to correctly set 24H mode. + +Signed-off-by: Tony Prisk +Cc: Edgar Toernig +Signed-off-by: Andrew Morton +Signed-off-by: Linus Torvalds +Signed-off-by: Greg Kroah-Hartman + +--- + drivers/rtc/rtc-vt8500.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +--- a/drivers/rtc/rtc-vt8500.c ++++ b/drivers/rtc/rtc-vt8500.c +@@ -69,7 +69,7 @@ + | ALARM_SEC_BIT) + + #define VT8500_RTC_CR_ENABLE (1 << 0) /* Enable RTC */ +-#define VT8500_RTC_CR_24H (1 << 1) /* 24h time format */ ++#define VT8500_RTC_CR_12H (1 << 1) /* 12h time format */ + #define VT8500_RTC_CR_SM_ENABLE (1 << 2) /* Enable periodic irqs */ + #define VT8500_RTC_CR_SM_SEC (1 << 3) /* 0: 1Hz/60, 1: 1Hz */ + #define VT8500_RTC_CR_CALIB (1 << 4) /* Enable calibration */ +@@ -246,7 +246,7 @@ static int __devinit vt8500_rtc_probe(st + } + + /* Enable RTC and set it to 24-hour mode */ +- writel(VT8500_RTC_CR_ENABLE | VT8500_RTC_CR_24H, ++ writel(VT8500_RTC_CR_ENABLE, + vt8500_rtc->regbase + VT8500_RTC_CR); + + vt8500_rtc->rtc = rtc_device_register("vt8500-rtc", &pdev->dev, diff --git a/queue-3.0/drivers-rtc-rtc-vt8500.c-fix-handling-of-data-passed-in-struct-rtc_time.patch b/queue-3.0/drivers-rtc-rtc-vt8500.c-fix-handling-of-data-passed-in-struct-rtc_time.patch new file mode 100644 index 00000000000..7841c8714eb --- /dev/null +++ b/queue-3.0/drivers-rtc-rtc-vt8500.c-fix-handling-of-data-passed-in-struct-rtc_time.patch @@ -0,0 +1,50 @@ +From 2f90b68309683f2c5765a1b04ca23d71e51f1494 Mon Sep 17 00:00:00 2001 +From: Tony Prisk +Date: Fri, 4 Jan 2013 15:35:48 -0800 +Subject: drivers/rtc/rtc-vt8500.c: fix handling of data passed in struct rtc_time + +From: Tony Prisk + +commit 2f90b68309683f2c5765a1b04ca23d71e51f1494 upstream. + +tm_mon is 0..11, whereas vt8500 expects 1..12 for the month field, +causing invalid date errors for January, and causing the day field to +roll over incorrectly. + +The century flag is only handled in vt8500_rtc_read_time, but not set in +vt8500_rtc_set_time. This patch corrects the behaviour of the century +flag. + +Signed-off-by: Edgar Toernig +Signed-off-by: Tony Prisk +Signed-off-by: Andrew Morton +Signed-off-by: Linus Torvalds +Signed-off-by: Greg Kroah-Hartman + +--- + drivers/rtc/rtc-vt8500.c | 7 ++++--- + 1 file changed, 4 insertions(+), 3 deletions(-) + +--- a/drivers/rtc/rtc-vt8500.c ++++ b/drivers/rtc/rtc-vt8500.c +@@ -116,7 +116,7 @@ static int vt8500_rtc_read_time(struct d + tm->tm_min = bcd2bin((time & TIME_MIN_MASK) >> TIME_MIN_S); + tm->tm_hour = bcd2bin((time & TIME_HOUR_MASK) >> TIME_HOUR_S); + tm->tm_mday = bcd2bin(date & DATE_DAY_MASK); +- tm->tm_mon = bcd2bin((date & DATE_MONTH_MASK) >> DATE_MONTH_S); ++ tm->tm_mon = bcd2bin((date & DATE_MONTH_MASK) >> DATE_MONTH_S) - 1; + tm->tm_year = bcd2bin((date & DATE_YEAR_MASK) >> DATE_YEAR_S) + + ((date >> DATE_CENTURY_S) & 1 ? 200 : 100); + tm->tm_wday = (time & TIME_DOW_MASK) >> TIME_DOW_S; +@@ -135,8 +135,9 @@ static int vt8500_rtc_set_time(struct de + } + + writel((bin2bcd(tm->tm_year - 100) << DATE_YEAR_S) +- | (bin2bcd(tm->tm_mon) << DATE_MONTH_S) +- | (bin2bcd(tm->tm_mday)), ++ | (bin2bcd(tm->tm_mon + 1) << DATE_MONTH_S) ++ | (bin2bcd(tm->tm_mday)) ++ | ((tm->tm_year >= 200) << DATE_CENTURY_S), + vt8500_rtc->regbase + VT8500_RTC_DS); + writel((bin2bcd(tm->tm_wday) << TIME_DOW_S) + | (bin2bcd(tm->tm_hour) << TIME_HOUR_S) diff --git a/queue-3.0/mm-limit-mmu_gather-batching-to-fix-soft-lockups-on-config_preempt.patch b/queue-3.0/mm-limit-mmu_gather-batching-to-fix-soft-lockups-on-config_preempt.patch new file mode 100644 index 00000000000..0627a5e4cd4 --- /dev/null +++ b/queue-3.0/mm-limit-mmu_gather-batching-to-fix-soft-lockups-on-config_preempt.patch @@ -0,0 +1,132 @@ +From 53a59fc67f97374758e63a9c785891ec62324c81 Mon Sep 17 00:00:00 2001 +From: Michal Hocko +Date: Fri, 4 Jan 2013 15:35:12 -0800 +Subject: mm: limit mmu_gather batching to fix soft lockups on !CONFIG_PREEMPT + +From: Michal Hocko + +commit 53a59fc67f97374758e63a9c785891ec62324c81 upstream. + +Since commit e303297e6c3a ("mm: extended batches for generic +mmu_gather") we are batching pages to be freed until either +tlb_next_batch cannot allocate a new batch or we are done. + +This works just fine most of the time but we can get in troubles with +non-preemptible kernel (CONFIG_PREEMPT_NONE or CONFIG_PREEMPT_VOLUNTARY) +on large machines where too aggressive batching might lead to soft +lockups during process exit path (exit_mmap) because there are no +scheduling points down the free_pages_and_swap_cache path and so the +freeing can take long enough to trigger the soft lockup. + +The lockup is harmless except when the system is setup to panic on +softlockup which is not that unusual. + +The simplest way to work around this issue is to limit the maximum +number of batches in a single mmu_gather. 10k of collected pages should +be safe to prevent from soft lockups (we would have 2ms for one) even if +they are all freed without an explicit scheduling point. + +This patch doesn't add any new explicit scheduling points because it +relies on zap_pmd_range during page tables zapping which calls +cond_resched per PMD. + +The following lockup has been reported for 3.0 kernel with a huge +process (in order of hundreds gigs but I do know any more details). + + BUG: soft lockup - CPU#56 stuck for 22s! [kernel:31053] + Modules linked in: af_packet nfs lockd fscache auth_rpcgss nfs_acl sunrpc mptctl mptbase autofs4 binfmt_misc dm_round_robin dm_multipath bonding cpufreq_conservative cpufreq_userspace cpufreq_powersave pcc_cpufreq mperf microcode fuse loop osst sg sd_mod crc_t10dif st qla2xxx scsi_transport_fc scsi_tgt netxen_nic i7core_edac iTCO_wdt joydev e1000e serio_raw pcspkr edac_core iTCO_vendor_support acpi_power_meter rtc_cmos hpwdt hpilo button container usbhid hid dm_mirror dm_region_hash dm_log linear uhci_hcd ehci_hcd usbcore usb_common scsi_dh_emc scsi_dh_alua scsi_dh_hp_sw scsi_dh_rdac scsi_dh dm_snapshot pcnet32 mii edd dm_mod raid1 ext3 mbcache jbd fan thermal processor thermal_sys hwmon cciss scsi_mod + Supported: Yes + CPU 56 + Pid: 31053, comm: kernel Not tainted 3.0.31-0.9-default #1 HP ProLiant DL580 G7 + RIP: 0010: _raw_spin_unlock_irqrestore+0x8/0x10 + RSP: 0018:ffff883ec1037af0 EFLAGS: 00000206 + RAX: 0000000000000e00 RBX: ffffea01a0817e28 RCX: ffff88803ffd9e80 + RDX: 0000000000000200 RSI: 0000000000000206 RDI: 0000000000000206 + RBP: 0000000000000002 R08: 0000000000000001 R09: ffff887ec724a400 + R10: 0000000000000000 R11: dead000000200200 R12: ffffffff8144c26e + R13: 0000000000000030 R14: 0000000000000297 R15: 000000000000000e + FS: 00007ed834282700(0000) GS:ffff88c03f200000(0000) knlGS:0000000000000000 + CS: 0010 DS: 0000 ES: 0000 CR0: 000000008005003b + CR2: 000000000068b240 CR3: 0000003ec13c5000 CR4: 00000000000006e0 + DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 + DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 0000000000000400 + Process kernel (pid: 31053, threadinfo ffff883ec1036000, task ffff883ebd5d4100) + Call Trace: + release_pages+0xc5/0x260 + free_pages_and_swap_cache+0x9d/0xc0 + tlb_flush_mmu+0x5c/0x80 + tlb_finish_mmu+0xe/0x50 + exit_mmap+0xbd/0x120 + mmput+0x49/0x120 + exit_mm+0x122/0x160 + do_exit+0x17a/0x430 + do_group_exit+0x3d/0xb0 + get_signal_to_deliver+0x247/0x480 + do_signal+0x71/0x1b0 + do_notify_resume+0x98/0xb0 + int_signal+0x12/0x17 + DWARF2 unwinder stuck at int_signal+0x12/0x17 + +Signed-off-by: Michal Hocko +Cc: Mel Gorman +Cc: Rik van Riel +Cc: Peter Zijlstra +Signed-off-by: Andrew Morton +Signed-off-by: Linus Torvalds +Signed-off-by: Greg Kroah-Hartman + +--- + include/asm-generic/tlb.h | 9 +++++++++ + mm/memory.c | 5 +++++ + 2 files changed, 14 insertions(+) + +--- a/include/asm-generic/tlb.h ++++ b/include/asm-generic/tlb.h +@@ -78,6 +78,14 @@ struct mmu_gather_batch { + #define MAX_GATHER_BATCH \ + ((PAGE_SIZE - sizeof(struct mmu_gather_batch)) / sizeof(void *)) + ++/* ++ * Limit the maximum number of mmu_gather batches to reduce a risk of soft ++ * lockups for non-preemptible kernels on huge machines when a lot of memory ++ * is zapped during unmapping. ++ * 10K pages freed at once should be safe even without a preemption point. ++ */ ++#define MAX_GATHER_BATCH_COUNT (10000UL/MAX_GATHER_BATCH) ++ + /* struct mmu_gather is an opaque type used by the mm code for passing around + * any data needed by arch specific code for tlb_remove_page. + */ +@@ -94,6 +102,7 @@ struct mmu_gather { + struct mmu_gather_batch *active; + struct mmu_gather_batch local; + struct page *__pages[MMU_GATHER_BUNDLE]; ++ unsigned int batch_count; + }; + + #define HAVE_GENERIC_MMU_GATHER +--- a/mm/memory.c ++++ b/mm/memory.c +@@ -205,10 +205,14 @@ static int tlb_next_batch(struct mmu_gat + return 1; + } + ++ if (tlb->batch_count == MAX_GATHER_BATCH_COUNT) ++ return 0; ++ + batch = (void *)__get_free_pages(GFP_NOWAIT | __GFP_NOWARN, 0); + if (!batch) + return 0; + ++ tlb->batch_count++; + batch->next = NULL; + batch->nr = 0; + batch->max = MAX_GATHER_BATCH; +@@ -235,6 +239,7 @@ void tlb_gather_mmu(struct mmu_gather *t + tlb->local.nr = 0; + tlb->local.max = ARRAY_SIZE(tlb->__pages); + tlb->active = &tlb->local; ++ tlb->batch_count = 0; + + #ifdef CONFIG_HAVE_RCU_TABLE_FREE + tlb->batch = NULL; diff --git a/queue-3.0/series b/queue-3.0/series index 589d8f1dec9..be86b791feb 100644 --- a/queue-3.0/series +++ b/queue-3.0/series @@ -40,3 +40,7 @@ solos-pci-fix-double-free-of-tx-skb-in-dma-mode.patch pci-reduce-ricoh-0xe822-sd-card-reader-base-clock-frequency-to-50mhz.patch bluetooth-ath3k-add-support-for-vaio-vpceh.patch bluetooth-cancel-power_on-work-when-unregistering-the-device.patch +cris-fix-i-o-macros.patch +drivers-rtc-rtc-vt8500.c-correct-handling-of-cr_24h-bitfield.patch +drivers-rtc-rtc-vt8500.c-fix-handling-of-data-passed-in-struct-rtc_time.patch +mm-limit-mmu_gather-batching-to-fix-soft-lockups-on-config_preempt.patch -- 2.47.3