aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeff Garzik <jeff@garzik.org>2007-06-12 22:34:34 -0400
committerJeff Garzik <jeff@garzik.org>2007-06-12 22:34:34 -0400
commitb232923966f1210e1183353bbd1d52ee53b79fbf (patch)
treee90c72b2cb400af53e1f92aff0af122782d7f65c
parentbca1a5518cab2d58c766863c61ee4ef5f1cc4caa (diff)
parent99f9f3d49cbc7d944476f6fde53a77ec789ab2aa (diff)
Merge branch 'master' into upstream-fixes
-rw-r--r--arch/mips/kernel/scall32-o32.S6
-rw-r--r--arch/mips/kernel/scall64-64.S4
-rw-r--r--arch/mips/kernel/scall64-n32.S4
-rw-r--r--arch/mips/kernel/scall64-o32.S4
-rw-r--r--arch/mips/kernel/smp.c2
-rw-r--r--arch/mips/kernel/smtc-asm.S3
-rw-r--r--arch/mips/kernel/smtc.c4
-rw-r--r--arch/mips/kernel/traps.c15
-rw-r--r--arch/mips/mips-boards/atlas/atlas_int.c5
-rw-r--r--arch/mips/mips-boards/generic/time.c16
-rw-r--r--arch/mips/sgi-ip27/ip27-memory.c2
-rw-r--r--drivers/ata/ahci.c24
-rw-r--r--drivers/ata/libata-core.c62
-rw-r--r--drivers/ata/libata-scsi.c67
-rw-r--r--drivers/ata/libata-sff.c37
-rw-r--r--drivers/ata/pata_isapnp.c1
-rw-r--r--drivers/char/agp/agp.h6
-rw-r--r--drivers/char/agp/intel-agp.c576
-rw-r--r--drivers/ide/ide-disk.c12
-rw-r--r--drivers/ide/ide-probe.c12
-rw-r--r--drivers/ide/ide.c9
-rw-r--r--drivers/ide/pci/amd74xx.c12
-rw-r--r--drivers/ide/pci/generic.c37
-rw-r--r--drivers/ide/pci/hpt366.c8
-rw-r--r--drivers/ide/pci/it821x.c34
-rw-r--r--drivers/ide/pci/serverworks.c51
-rw-r--r--drivers/infiniband/core/cma.c4
-rw-r--r--drivers/infiniband/hw/mlx4/qp.c33
-rw-r--r--drivers/infiniband/hw/mthca/mthca_cmd.c2
-rw-r--r--drivers/media/common/Kconfig1
-rw-r--r--drivers/media/dvb/b2c2/Makefile7
-rw-r--r--drivers/media/dvb/cinergyT2/cinergyT2.c3
-rw-r--r--drivers/media/dvb/frontends/tda10086.c21
-rw-r--r--drivers/media/dvb/frontends/tda826x.c4
-rw-r--r--drivers/media/video/Kconfig2
-rw-r--r--drivers/media/video/ivtv/ivtv-cards.h2
-rw-r--r--drivers/media/video/ivtv/ivtv-driver.c1
-rw-r--r--drivers/media/video/ivtv/ivtv-driver.h16
-rw-r--r--drivers/media/video/ivtv/ivtv-fileops.c16
-rw-r--r--drivers/media/video/ivtv/ivtv-ioctl.c45
-rw-r--r--drivers/media/video/ivtv/ivtv-irq.c204
-rw-r--r--drivers/media/video/ivtv/ivtv-queue.c31
-rw-r--r--drivers/media/video/ivtv/ivtv-queue.h39
-rw-r--r--drivers/media/video/ivtv/ivtv-streams.c2
-rw-r--r--drivers/media/video/ivtv/ivtv-vbi.c2
-rw-r--r--drivers/media/video/ivtv/ivtv-vbi.h2
-rw-r--r--drivers/media/video/saa7111.c49
-rw-r--r--drivers/media/video/usbvision/usbvision-core.c82
-rw-r--r--drivers/media/video/usbvision/usbvision.h1
-rw-r--r--drivers/mmc/core/sd.c26
-rw-r--r--drivers/mmc/host/at91_mci.c5
-rw-r--r--drivers/mmc/host/au1xmmc.c3
-rw-r--r--drivers/net/mlx4/cq.c2
-rw-r--r--drivers/net/mlx4/eq.c4
-rw-r--r--drivers/net/mlx4/fw.c27
-rw-r--r--drivers/net/mlx4/intf.c3
-rw-r--r--drivers/net/mlx4/main.c2
-rw-r--r--drivers/net/mlx4/mr.c8
-rw-r--r--fs/cifs/cifs_debug.c252
-rw-r--r--fs/cifs/cifs_unicode.c12
-rw-r--r--fs/cifs/cifsfs.c2
-rw-r--r--fs/cifs/cifssmb.c4
-rw-r--r--fs/cifs/connect.c16
-rw-r--r--fs/cifs/dir.c184
-rw-r--r--fs/cifs/fcntl.c46
-rw-r--r--fs/cifs/inode.c5
-rw-r--r--fs/cifs/ioctl.c29
-rw-r--r--fs/cifs/rfc1002pdu.h2
-rw-r--r--fs/splice.c70
-rw-r--r--include/asm-mips/bitops.h51
-rw-r--r--include/asm-mips/stackframe.h52
-rw-r--r--include/asm-mips/unistd.h24
-rw-r--r--include/linux/ata.h3
-rw-r--r--include/linux/ide.h1
-rw-r--r--include/linux/libata.h1
-rw-r--r--include/linux/pci_ids.h2
-rw-r--r--include/linux/pipe_fs_i.h30
-rw-r--r--include/linux/videodev2.h7
78 files changed, 1416 insertions, 1039 deletions
diff --git a/arch/mips/kernel/scall32-o32.S b/arch/mips/kernel/scall32-o32.S
index 0c9a9ff8cd25..ae985d1fcca1 100644
--- a/arch/mips/kernel/scall32-o32.S
+++ b/arch/mips/kernel/scall32-o32.S
@@ -657,7 +657,11 @@ einval: li v0, -EINVAL
657 sys sys_getcpu 3 657 sys sys_getcpu 3
658 sys sys_epoll_pwait 6 658 sys sys_epoll_pwait 6
659 sys sys_ioprio_set 3 659 sys sys_ioprio_set 3
660 sys sys_ioprio_get 2 660 sys sys_ioprio_get 2 /* 4315 */
661 sys sys_utimensat 4
662 sys sys_signalfd 3
663 sys sys_timerfd 4
664 sys sys_eventfd 1
661 .endm 665 .endm
662 666
663 /* We pre-compute the number of _instruction_ bytes needed to 667 /* We pre-compute the number of _instruction_ bytes needed to
diff --git a/arch/mips/kernel/scall64-64.S b/arch/mips/kernel/scall64-64.S
index 23f3b118f718..7bcd5a1a85f5 100644
--- a/arch/mips/kernel/scall64-64.S
+++ b/arch/mips/kernel/scall64-64.S
@@ -473,4 +473,8 @@ sys_call_table:
473 PTR sys_epoll_pwait 473 PTR sys_epoll_pwait
474 PTR sys_ioprio_set 474 PTR sys_ioprio_set
475 PTR sys_ioprio_get 475 PTR sys_ioprio_get
476 PTR sys_utimensat /* 5275 */
477 PTR sys_signalfd
478 PTR sys_timerfd
479 PTR sys_eventfd
476 .size sys_call_table,.-sys_call_table 480 .size sys_call_table,.-sys_call_table
diff --git a/arch/mips/kernel/scall64-n32.S b/arch/mips/kernel/scall64-n32.S
index 1631035ffc24..532a2f3b42fc 100644
--- a/arch/mips/kernel/scall64-n32.S
+++ b/arch/mips/kernel/scall64-n32.S
@@ -399,4 +399,8 @@ EXPORT(sysn32_call_table)
399 PTR compat_sys_epoll_pwait 399 PTR compat_sys_epoll_pwait
400 PTR sys_ioprio_set 400 PTR sys_ioprio_set
401 PTR sys_ioprio_get 401 PTR sys_ioprio_get
402 PTR compat_sys_utimensat
403 PTR compat_sys_signalfd /* 5280 */
404 PTR compat_sys_timerfd
405 PTR sys_eventfd
402 .size sysn32_call_table,.-sysn32_call_table 406 .size sysn32_call_table,.-sysn32_call_table
diff --git a/arch/mips/kernel/scall64-o32.S b/arch/mips/kernel/scall64-o32.S
index 2aa99426ac1c..6bbe0f4ed8ba 100644
--- a/arch/mips/kernel/scall64-o32.S
+++ b/arch/mips/kernel/scall64-o32.S
@@ -521,4 +521,8 @@ sys_call_table:
521 PTR compat_sys_epoll_pwait 521 PTR compat_sys_epoll_pwait
522 PTR sys_ioprio_set 522 PTR sys_ioprio_set
523 PTR sys_ioprio_get /* 4315 */ 523 PTR sys_ioprio_get /* 4315 */
524 PTR compat_sys_utimensat
525 PTR compat_sys_signalfd
526 PTR compat_sys_timerfd
527 PTR sys_eventfd
524 .size sys_call_table,.-sys_call_table 528 .size sys_call_table,.-sys_call_table
diff --git a/arch/mips/kernel/smp.c b/arch/mips/kernel/smp.c
index c46e479c992b..67edfa7ed93a 100644
--- a/arch/mips/kernel/smp.c
+++ b/arch/mips/kernel/smp.c
@@ -68,7 +68,7 @@ extern ATTRIB_NORET void cpu_idle(void);
68 * First C code run on the secondary CPUs after being started up by 68 * First C code run on the secondary CPUs after being started up by
69 * the master. 69 * the master.
70 */ 70 */
71asmlinkage void start_secondary(void) 71asmlinkage __cpuinit void start_secondary(void)
72{ 72{
73 unsigned int cpu; 73 unsigned int cpu;
74 74
diff --git a/arch/mips/kernel/smtc-asm.S b/arch/mips/kernel/smtc-asm.S
index 921207c4a83c..20938a4cb52d 100644
--- a/arch/mips/kernel/smtc-asm.S
+++ b/arch/mips/kernel/smtc-asm.S
@@ -121,10 +121,7 @@ LEAF(self_ipi)
121 subu t1,sp,PT_SIZE 121 subu t1,sp,PT_SIZE
122 sw ra,PT_EPC(t1) 122 sw ra,PT_EPC(t1)
123 sw a0,PT_PADSLOT4(t1) 123 sw a0,PT_PADSLOT4(t1)
124 LONG_L s0, TI_REGS($28)
125 LONG_S sp, TI_REGS($28)
126 la t2,ipi_decode 124 la t2,ipi_decode
127 LONG_S s0, TI_REGS($28)
128 sw t2,PT_PADSLOT5(t1) 125 sw t2,PT_PADSLOT5(t1)
129 /* Save pre-disable value of TCStatus */ 126 /* Save pre-disable value of TCStatus */
130 sw t0,PT_TCSTATUS(t1) 127 sw t0,PT_TCSTATUS(t1)
diff --git a/arch/mips/kernel/smtc.c b/arch/mips/kernel/smtc.c
index b361edb83dc6..21eb5993a19f 100644
--- a/arch/mips/kernel/smtc.c
+++ b/arch/mips/kernel/smtc.c
@@ -611,12 +611,12 @@ void smtc_cpus_done(void)
611int setup_irq_smtc(unsigned int irq, struct irqaction * new, 611int setup_irq_smtc(unsigned int irq, struct irqaction * new,
612 unsigned long hwmask) 612 unsigned long hwmask)
613{ 613{
614#ifdef CONFIG_SMTC_IDLE_HOOK_DEBUG
614 unsigned int vpe = current_cpu_data.vpe_id; 615 unsigned int vpe = current_cpu_data.vpe_id;
615 616
616 irq_hwmask[irq] = hwmask;
617#ifdef CONFIG_SMTC_IDLE_HOOK_DEBUG
618 vpemask[vpe][irq - MIPSCPU_INT_BASE] = 1; 617 vpemask[vpe][irq - MIPSCPU_INT_BASE] = 1;
619#endif 618#endif
619 irq_hwmask[irq] = hwmask;
620 620
621 return setup_irq(irq, new); 621 return setup_irq(irq, new);
622} 622}
diff --git a/arch/mips/kernel/traps.c b/arch/mips/kernel/traps.c
index 3f58b6ac1358..a7a17eb9bfcd 100644
--- a/arch/mips/kernel/traps.c
+++ b/arch/mips/kernel/traps.c
@@ -11,6 +11,7 @@
11 * Copyright (C) 2000, 01 MIPS Technologies, Inc. 11 * Copyright (C) 2000, 01 MIPS Technologies, Inc.
12 * Copyright (C) 2002, 2003, 2004, 2005 Maciej W. Rozycki 12 * Copyright (C) 2002, 2003, 2004, 2005 Maciej W. Rozycki
13 */ 13 */
14#include <linux/bug.h>
14#include <linux/init.h> 15#include <linux/init.h>
15#include <linux/mm.h> 16#include <linux/mm.h>
16#include <linux/module.h> 17#include <linux/module.h>
@@ -1190,8 +1191,8 @@ static void *set_vi_srs_handler(int n, vi_handler_t addr, int srs)
1190 1191
1191 memcpy (b, &except_vec_vi, handler_len); 1192 memcpy (b, &except_vec_vi, handler_len);
1192#ifdef CONFIG_MIPS_MT_SMTC 1193#ifdef CONFIG_MIPS_MT_SMTC
1193 if (n > 7) 1194 BUG_ON(n > 7); /* Vector index %d exceeds SMTC maximum. */
1194 printk("Vector index %d exceeds SMTC maximum\n", n); 1195
1195 w = (u32 *)(b + mori_offset); 1196 w = (u32 *)(b + mori_offset);
1196 *w = (*w & 0xffff0000) | (0x100 << n); 1197 *w = (*w & 0xffff0000) | (0x100 << n);
1197#endif /* CONFIG_MIPS_MT_SMTC */ 1198#endif /* CONFIG_MIPS_MT_SMTC */
@@ -1383,6 +1384,13 @@ void __init per_cpu_trap_init(void)
1383 cpu_cache_init(); 1384 cpu_cache_init();
1384 tlb_init(); 1385 tlb_init();
1385#ifdef CONFIG_MIPS_MT_SMTC 1386#ifdef CONFIG_MIPS_MT_SMTC
1387 } else if (!secondaryTC) {
1388 /*
1389 * First TC in non-boot VPE must do subset of tlb_init()
1390 * for MMU countrol registers.
1391 */
1392 write_c0_pagemask(PM_DEFAULT_MASK);
1393 write_c0_wired(0);
1386 } 1394 }
1387#endif /* CONFIG_MIPS_MT_SMTC */ 1395#endif /* CONFIG_MIPS_MT_SMTC */
1388} 1396}
@@ -1531,8 +1539,7 @@ void __init trap_init(void)
1531 if (cpu_has_mipsmt) 1539 if (cpu_has_mipsmt)
1532 set_except_vector(25, handle_mt); 1540 set_except_vector(25, handle_mt);
1533 1541
1534 if (cpu_has_dsp) 1542 set_except_vector(26, handle_dsp);
1535 set_except_vector(26, handle_dsp);
1536 1543
1537 if (cpu_has_vce) 1544 if (cpu_has_vce)
1538 /* Special exception: R4[04]00 uses also the divec space. */ 1545 /* Special exception: R4[04]00 uses also the divec space. */
diff --git a/arch/mips/mips-boards/atlas/atlas_int.c b/arch/mips/mips-boards/atlas/atlas_int.c
index dfa0acbd7fc2..9f49da95aacf 100644
--- a/arch/mips/mips-boards/atlas/atlas_int.c
+++ b/arch/mips/mips-boards/atlas/atlas_int.c
@@ -248,14 +248,13 @@ void __init arch_init_irq(void)
248 case MIPS_REVISION_CORID_CORE_24K: 248 case MIPS_REVISION_CORID_CORE_24K:
249 case MIPS_REVISION_CORID_CORE_EMUL_MSC: 249 case MIPS_REVISION_CORID_CORE_EMUL_MSC:
250 if (cpu_has_veic) 250 if (cpu_has_veic)
251 init_msc_irqs (MSC01E_INT_BASE, 251 init_msc_irqs (MSC01E_INT_BASE, MSC01E_INT_BASE,
252 msc_eicirqmap, msc_nr_eicirqs); 252 msc_eicirqmap, msc_nr_eicirqs);
253 else 253 else
254 init_msc_irqs (MSC01C_INT_BASE, 254 init_msc_irqs (MSC01E_INT_BASE, MSC01C_INT_BASE,
255 msc_irqmap, msc_nr_irqs); 255 msc_irqmap, msc_nr_irqs);
256 } 256 }
257 257
258
259 if (cpu_has_veic) { 258 if (cpu_has_veic) {
260 set_vi_handler (MSC01E_INT_ATLAS, atlas_hw0_irqdispatch); 259 set_vi_handler (MSC01E_INT_ATLAS, atlas_hw0_irqdispatch);
261 setup_irq (MSC01E_INT_BASE + MSC01E_INT_ATLAS, &atlasirq); 260 setup_irq (MSC01E_INT_BASE + MSC01E_INT_ATLAS, &atlasirq);
diff --git a/arch/mips/mips-boards/generic/time.c b/arch/mips/mips-boards/generic/time.c
index 37735bfc3afd..b41db9e7ab1f 100644
--- a/arch/mips/mips-boards/generic/time.c
+++ b/arch/mips/mips-boards/generic/time.c
@@ -88,8 +88,6 @@ irqreturn_t mips_timer_interrupt(int irq, void *dev_id)
88 * the general MIPS timer_interrupt routine. 88 * the general MIPS timer_interrupt routine.
89 */ 89 */
90 90
91 int vpflags;
92
93 /* 91 /*
94 * We could be here due to timer interrupt, 92 * We could be here due to timer interrupt,
95 * perf counter overflow, or both. 93 * perf counter overflow, or both.
@@ -98,15 +96,6 @@ irqreturn_t mips_timer_interrupt(int irq, void *dev_id)
98 perf_irq(); 96 perf_irq();
99 97
100 if (read_c0_cause() & (1 << 30)) { 98 if (read_c0_cause() & (1 << 30)) {
101 /* If timer interrupt, make it de-assert */
102 write_c0_compare (read_c0_count() - 1);
103 /*
104 * DVPE is necessary so long as cross-VPE interrupts
105 * are done via read-modify-write of Cause register.
106 */
107 vpflags = dvpe();
108 clear_c0_cause(CPUCTR_IMASKBIT);
109 evpe(vpflags);
110 /* 99 /*
111 * There are things we only want to do once per tick 100 * There are things we only want to do once per tick
112 * in an "MP" system. One TC of each VPE will take 101 * in an "MP" system. One TC of each VPE will take
@@ -115,14 +104,13 @@ irqreturn_t mips_timer_interrupt(int irq, void *dev_id)
115 * the tick on VPE 0 to run the full timer_interrupt(). 104 * the tick on VPE 0 to run the full timer_interrupt().
116 */ 105 */
117 if (cpu_data[cpu].vpe_id == 0) { 106 if (cpu_data[cpu].vpe_id == 0) {
118 timer_interrupt(irq, NULL); 107 timer_interrupt(irq, NULL);
119 smtc_timer_broadcast(cpu_data[cpu].vpe_id);
120 } else { 108 } else {
121 write_c0_compare(read_c0_count() + 109 write_c0_compare(read_c0_count() +
122 (mips_hpt_frequency/HZ)); 110 (mips_hpt_frequency/HZ));
123 local_timer_interrupt(irq, dev_id); 111 local_timer_interrupt(irq, dev_id);
124 smtc_timer_broadcast(cpu_data[cpu].vpe_id);
125 } 112 }
113 smtc_timer_broadcast(cpu_data[cpu].vpe_id);
126 } 114 }
127#else /* CONFIG_MIPS_MT_SMTC */ 115#else /* CONFIG_MIPS_MT_SMTC */
128 int r2 = cpu_has_mips_r2; 116 int r2 = cpu_has_mips_r2;
diff --git a/arch/mips/sgi-ip27/ip27-memory.c b/arch/mips/sgi-ip27/ip27-memory.c
index fe8a1066aec1..e5e023f50a07 100644
--- a/arch/mips/sgi-ip27/ip27-memory.c
+++ b/arch/mips/sgi-ip27/ip27-memory.c
@@ -517,7 +517,7 @@ void __init paging_init(void)
517 pfn_t start_pfn = slot_getbasepfn(node, 0); 517 pfn_t start_pfn = slot_getbasepfn(node, 0);
518 pfn_t end_pfn = node_getmaxclick(node) + 1; 518 pfn_t end_pfn = node_getmaxclick(node) + 1;
519 519
520 zones_size[ZONE_DMA] = end_pfn - start_pfn; 520 zones_size[ZONE_NORMAL] = end_pfn - start_pfn;
521 free_area_init_node(node, NODE_DATA(node), 521 free_area_init_node(node, NODE_DATA(node),
522 zones_size, start_pfn, NULL); 522 zones_size, start_pfn, NULL);
523 523
diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c
index 7baeaffefe7a..545f330e59a5 100644
--- a/drivers/ata/ahci.c
+++ b/drivers/ata/ahci.c
@@ -426,6 +426,30 @@ static const struct pci_device_id ahci_pci_tbl[] = {
426 { PCI_VDEVICE(NVIDIA, 0x0559), board_ahci }, /* MCP67 */ 426 { PCI_VDEVICE(NVIDIA, 0x0559), board_ahci }, /* MCP67 */
427 { PCI_VDEVICE(NVIDIA, 0x055a), board_ahci }, /* MCP67 */ 427 { PCI_VDEVICE(NVIDIA, 0x055a), board_ahci }, /* MCP67 */
428 { PCI_VDEVICE(NVIDIA, 0x055b), board_ahci }, /* MCP67 */ 428 { PCI_VDEVICE(NVIDIA, 0x055b), board_ahci }, /* MCP67 */
429 { PCI_VDEVICE(NVIDIA, 0x07f0), board_ahci }, /* MCP73 */
430 { PCI_VDEVICE(NVIDIA, 0x07f1), board_ahci }, /* MCP73 */
431 { PCI_VDEVICE(NVIDIA, 0x07f2), board_ahci }, /* MCP73 */
432 { PCI_VDEVICE(NVIDIA, 0x07f3), board_ahci }, /* MCP73 */
433 { PCI_VDEVICE(NVIDIA, 0x07f4), board_ahci }, /* MCP73 */
434 { PCI_VDEVICE(NVIDIA, 0x07f5), board_ahci }, /* MCP73 */
435 { PCI_VDEVICE(NVIDIA, 0x07f6), board_ahci }, /* MCP73 */
436 { PCI_VDEVICE(NVIDIA, 0x07f7), board_ahci }, /* MCP73 */
437 { PCI_VDEVICE(NVIDIA, 0x07f8), board_ahci }, /* MCP73 */
438 { PCI_VDEVICE(NVIDIA, 0x07f9), board_ahci }, /* MCP73 */
439 { PCI_VDEVICE(NVIDIA, 0x07fa), board_ahci }, /* MCP73 */
440 { PCI_VDEVICE(NVIDIA, 0x07fb), board_ahci }, /* MCP73 */
441 { PCI_VDEVICE(NVIDIA, 0x0ad0), board_ahci }, /* MCP77 */
442 { PCI_VDEVICE(NVIDIA, 0x0ad1), board_ahci }, /* MCP77 */
443 { PCI_VDEVICE(NVIDIA, 0x0ad2), board_ahci }, /* MCP77 */
444 { PCI_VDEVICE(NVIDIA, 0x0ad3), board_ahci }, /* MCP77 */
445 { PCI_VDEVICE(NVIDIA, 0x0ad4), board_ahci }, /* MCP77 */
446 { PCI_VDEVICE(NVIDIA, 0x0ad5), board_ahci }, /* MCP77 */
447 { PCI_VDEVICE(NVIDIA, 0x0ad6), board_ahci }, /* MCP77 */
448 { PCI_VDEVICE(NVIDIA, 0x0ad7), board_ahci }, /* MCP77 */
449 { PCI_VDEVICE(NVIDIA, 0x0ad8), board_ahci }, /* MCP77 */
450 { PCI_VDEVICE(NVIDIA, 0x0ad9), board_ahci }, /* MCP77 */
451 { PCI_VDEVICE(NVIDIA, 0x0ada), board_ahci }, /* MCP77 */
452 { PCI_VDEVICE(NVIDIA, 0x0adb), board_ahci }, /* MCP77 */
429 453
430 /* SiS */ 454 /* SiS */
431 { PCI_VDEVICE(SI, 0x1184), board_ahci }, /* SiS 966 */ 455 { PCI_VDEVICE(SI, 0x1184), board_ahci }, /* SiS 966 */
diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
index 4733f009c7c9..047eabd75363 100644
--- a/drivers/ata/libata-core.c
+++ b/drivers/ata/libata-core.c
@@ -1727,7 +1727,7 @@ int ata_dev_read_id(struct ata_device *dev, unsigned int *p_class,
1727 1727
1728 /* sanity check */ 1728 /* sanity check */
1729 rc = -EINVAL; 1729 rc = -EINVAL;
1730 reason = "device reports illegal type"; 1730 reason = "device reports invalid type";
1731 1731
1732 if (class == ATA_DEV_ATA) { 1732 if (class == ATA_DEV_ATA) {
1733 if (!ata_id_is_ata(id) && !ata_id_is_cfa(id)) 1733 if (!ata_id_is_ata(id) && !ata_id_is_cfa(id))
@@ -1900,6 +1900,13 @@ int ata_dev_configure(struct ata_device *dev)
1900 if (ata_msg_probe(ap)) 1900 if (ata_msg_probe(ap))
1901 ata_dump_id(id); 1901 ata_dump_id(id);
1902 1902
1903 /* SCSI only uses 4-char revisions, dump full 8 chars from ATA */
1904 ata_id_c_string(dev->id, fwrevbuf, ATA_ID_FW_REV,
1905 sizeof(fwrevbuf));
1906
1907 ata_id_c_string(dev->id, modelbuf, ATA_ID_PROD,
1908 sizeof(modelbuf));
1909
1903 /* ATA-specific feature tests */ 1910 /* ATA-specific feature tests */
1904 if (dev->class == ATA_DEV_ATA) { 1911 if (dev->class == ATA_DEV_ATA) {
1905 if (ata_id_is_cfa(id)) { 1912 if (ata_id_is_cfa(id)) {
@@ -1914,13 +1921,6 @@ int ata_dev_configure(struct ata_device *dev)
1914 1921
1915 dev->n_sectors = ata_id_n_sectors(id); 1922 dev->n_sectors = ata_id_n_sectors(id);
1916 1923
1917 /* SCSI only uses 4-char revisions, dump full 8 chars from ATA */
1918 ata_id_c_string(dev->id, fwrevbuf, ATA_ID_FW_REV,
1919 sizeof(fwrevbuf));
1920
1921 ata_id_c_string(dev->id, modelbuf, ATA_ID_PROD,
1922 sizeof(modelbuf));
1923
1924 if (dev->id[59] & 0x100) 1924 if (dev->id[59] & 0x100)
1925 dev->multi_count = dev->id[59] & 0xff; 1925 dev->multi_count = dev->id[59] & 0xff;
1926 1926
@@ -2009,7 +2009,9 @@ int ata_dev_configure(struct ata_device *dev)
2009 2009
2010 /* print device info to dmesg */ 2010 /* print device info to dmesg */
2011 if (ata_msg_drv(ap) && print_info) 2011 if (ata_msg_drv(ap) && print_info)
2012 ata_dev_printk(dev, KERN_INFO, "ATAPI, max %s%s\n", 2012 ata_dev_printk(dev, KERN_INFO,
2013 "ATAPI: %s, %s, max %s%s\n",
2014 modelbuf, fwrevbuf,
2013 ata_mode_string(xfer_mask), 2015 ata_mode_string(xfer_mask),
2014 cdb_intr_string); 2016 cdb_intr_string);
2015 } 2017 }
@@ -3059,22 +3061,28 @@ static int ata_bus_post_reset(struct ata_port *ap, unsigned int devmask,
3059 } 3061 }
3060 } 3062 }
3061 3063
3062 /* if device 1 was found in ata_devchk, wait for 3064 /* if device 1 was found in ata_devchk, wait for register
3063 * register access, then wait for BSY to clear 3065 * access briefly, then wait for BSY to clear.
3064 */ 3066 */
3065 while (dev1) { 3067 if (dev1) {
3066 u8 nsect, lbal; 3068 int i;
3067 3069
3068 ap->ops->dev_select(ap, 1); 3070 ap->ops->dev_select(ap, 1);
3069 nsect = ioread8(ioaddr->nsect_addr); 3071
3070 lbal = ioread8(ioaddr->lbal_addr); 3072 /* Wait for register access. Some ATAPI devices fail
3071 if ((nsect == 1) && (lbal == 1)) 3073 * to set nsect/lbal after reset, so don't waste too
3072 break; 3074 * much time on it. We're gonna wait for !BSY anyway.
3073 if (time_after(jiffies, deadline)) 3075 */
3074 return -EBUSY; 3076 for (i = 0; i < 2; i++) {
3075 msleep(50); /* give drive a breather */ 3077 u8 nsect, lbal;
3076 } 3078
3077 if (dev1) { 3079 nsect = ioread8(ioaddr->nsect_addr);
3080 lbal = ioread8(ioaddr->lbal_addr);
3081 if ((nsect == 1) && (lbal == 1))
3082 break;
3083 msleep(50); /* give drive a breather */
3084 }
3085
3078 rc = ata_wait_ready(ap, deadline); 3086 rc = ata_wait_ready(ap, deadline);
3079 if (rc) { 3087 if (rc) {
3080 if (rc != -ENODEV) 3088 if (rc != -ENODEV)
@@ -3769,6 +3777,7 @@ static const struct ata_blacklist_entry ata_device_blacklist [] = {
3769 { "_NEC DV5800A", NULL, ATA_HORKAGE_NODMA }, 3777 { "_NEC DV5800A", NULL, ATA_HORKAGE_NODMA },
3770 { "SAMSUNG CD-ROM SN-124","N001", ATA_HORKAGE_NODMA }, 3778 { "SAMSUNG CD-ROM SN-124","N001", ATA_HORKAGE_NODMA },
3771 { "Seagate STT20000A", NULL, ATA_HORKAGE_NODMA }, 3779 { "Seagate STT20000A", NULL, ATA_HORKAGE_NODMA },
3780 { "IOMEGA ZIP 250 ATAPI", NULL, ATA_HORKAGE_NODMA }, /* temporary fix */
3772 3781
3773 /* Weird ATAPI devices */ 3782 /* Weird ATAPI devices */
3774 { "TORiSAN DVD-ROM DRD-N216", NULL, ATA_HORKAGE_MAX_SEC_128 | 3783 { "TORiSAN DVD-ROM DRD-N216", NULL, ATA_HORKAGE_MAX_SEC_128 |
@@ -3791,6 +3800,8 @@ static const struct ata_blacklist_entry ata_device_blacklist [] = {
3791 { "HTS541060G9SA00", "MB3OC60D", ATA_HORKAGE_NONCQ, }, 3800 { "HTS541060G9SA00", "MB3OC60D", ATA_HORKAGE_NONCQ, },
3792 { "HTS541080G9SA00", "MB4OC60D", ATA_HORKAGE_NONCQ, }, 3801 { "HTS541080G9SA00", "MB4OC60D", ATA_HORKAGE_NONCQ, },
3793 { "HTS541010G9SA00", "MBZOC60D", ATA_HORKAGE_NONCQ, }, 3802 { "HTS541010G9SA00", "MBZOC60D", ATA_HORKAGE_NONCQ, },
3803 /* Drives which do spurious command completion */
3804 { "HTS541680J9SA00", "SB2IC7EP", ATA_HORKAGE_NONCQ, },
3794 3805
3795 /* Devices with NCQ limits */ 3806 /* Devices with NCQ limits */
3796 3807
@@ -6313,7 +6324,8 @@ int ata_host_register(struct ata_host *host, struct scsi_host_template *sht)
6313 /* init sata_spd_limit to the current value */ 6324 /* init sata_spd_limit to the current value */
6314 if (sata_scr_read(ap, SCR_CONTROL, &scontrol) == 0) { 6325 if (sata_scr_read(ap, SCR_CONTROL, &scontrol) == 0) {
6315 int spd = (scontrol >> 4) & 0xf; 6326 int spd = (scontrol >> 4) & 0xf;
6316 ap->hw_sata_spd_limit &= (1 << spd) - 1; 6327 if (spd)
6328 ap->hw_sata_spd_limit &= (1 << spd) - 1;
6317 } 6329 }
6318 ap->sata_spd_limit = ap->hw_sata_spd_limit; 6330 ap->sata_spd_limit = ap->hw_sata_spd_limit;
6319 6331
@@ -6433,6 +6445,9 @@ int ata_host_activate(struct ata_host *host, int irq,
6433 if (rc) 6445 if (rc)
6434 devm_free_irq(host->dev, irq, host); 6446 devm_free_irq(host->dev, irq, host);
6435 6447
6448 /* Used to print device info at probe */
6449 host->irq = irq;
6450
6436 return rc; 6451 return rc;
6437} 6452}
6438 6453
@@ -6818,6 +6833,7 @@ EXPORT_SYMBOL_GPL(ata_check_status);
6818EXPORT_SYMBOL_GPL(ata_altstatus); 6833EXPORT_SYMBOL_GPL(ata_altstatus);
6819EXPORT_SYMBOL_GPL(ata_exec_command); 6834EXPORT_SYMBOL_GPL(ata_exec_command);
6820EXPORT_SYMBOL_GPL(ata_port_start); 6835EXPORT_SYMBOL_GPL(ata_port_start);
6836EXPORT_SYMBOL_GPL(ata_sff_port_start);
6821EXPORT_SYMBOL_GPL(ata_interrupt); 6837EXPORT_SYMBOL_GPL(ata_interrupt);
6822EXPORT_SYMBOL_GPL(ata_do_set_mode); 6838EXPORT_SYMBOL_GPL(ata_do_set_mode);
6823EXPORT_SYMBOL_GPL(ata_data_xfer); 6839EXPORT_SYMBOL_GPL(ata_data_xfer);
diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
index b3900cfbd880..c228df298bd8 100644
--- a/drivers/ata/libata-scsi.c
+++ b/drivers/ata/libata-scsi.c
@@ -1363,12 +1363,22 @@ static void ata_scsi_qc_complete(struct ata_queued_cmd *qc)
1363 * schedule EH_REVALIDATE operation to update the IDENTIFY DEVICE 1363 * schedule EH_REVALIDATE operation to update the IDENTIFY DEVICE
1364 * cache 1364 * cache
1365 */ 1365 */
1366 if (ap->ops->error_handler && 1366 if (ap->ops->error_handler && !need_sense) {
1367 !need_sense && (qc->tf.command == ATA_CMD_SET_FEATURES) && 1367 switch (qc->tf.command) {
1368 ((qc->tf.feature == SETFEATURES_WC_ON) || 1368 case ATA_CMD_SET_FEATURES:
1369 (qc->tf.feature == SETFEATURES_WC_OFF))) { 1369 if ((qc->tf.feature == SETFEATURES_WC_ON) ||
1370 ap->eh_info.action |= ATA_EH_REVALIDATE; 1370 (qc->tf.feature == SETFEATURES_WC_OFF)) {
1371 ata_port_schedule_eh(ap); 1371 ap->eh_info.action |= ATA_EH_REVALIDATE;
1372 ata_port_schedule_eh(ap);
1373 }
1374 break;
1375
1376 case ATA_CMD_INIT_DEV_PARAMS: /* CHS translation changed */
1377 case ATA_CMD_SET_MULTI: /* multi_count changed */
1378 ap->eh_info.action |= ATA_EH_REVALIDATE;
1379 ata_port_schedule_eh(ap);
1380 break;
1381 }
1372 } 1382 }
1373 1383
1374 /* For ATA pass thru (SAT) commands, generate a sense block if 1384 /* For ATA pass thru (SAT) commands, generate a sense block if
@@ -2506,22 +2516,21 @@ ata_scsi_map_proto(u8 byte1)
2506 return ATA_PROT_NODATA; 2516 return ATA_PROT_NODATA;
2507 2517
2508 case 6: /* DMA */ 2518 case 6: /* DMA */
2519 case 10: /* UDMA Data-in */
2520 case 11: /* UDMA Data-Out */
2509 return ATA_PROT_DMA; 2521 return ATA_PROT_DMA;
2510 2522
2511 case 4: /* PIO Data-in */ 2523 case 4: /* PIO Data-in */
2512 case 5: /* PIO Data-out */ 2524 case 5: /* PIO Data-out */
2513 return ATA_PROT_PIO; 2525 return ATA_PROT_PIO;
2514 2526
2515 case 10: /* Device Reset */
2516 case 0: /* Hard Reset */ 2527 case 0: /* Hard Reset */
2517 case 1: /* SRST */ 2528 case 1: /* SRST */
2518 case 2: /* Bus Idle */ 2529 case 8: /* Device Diagnostic */
2519 case 7: /* Packet */ 2530 case 9: /* Device Reset */
2520 case 8: /* DMA Queued */ 2531 case 7: /* DMA Queued */
2521 case 9: /* Device Diagnostic */ 2532 case 12: /* FPDMA */
2522 case 11: /* UDMA Data-in */ 2533 case 15: /* Return Response Info */
2523 case 12: /* UDMA Data-Out */
2524 case 13: /* FPDMA */
2525 default: /* Reserved */ 2534 default: /* Reserved */
2526 break; 2535 break;
2527 } 2536 }
@@ -2552,10 +2561,6 @@ static unsigned int ata_scsi_pass_thru(struct ata_queued_cmd *qc)
2552 if (tf->protocol == ATA_PROT_DMA && dev->dma_mode == 0) 2561 if (tf->protocol == ATA_PROT_DMA && dev->dma_mode == 0)
2553 goto invalid_fld; 2562 goto invalid_fld;
2554 2563
2555 if (cdb[1] & 0xe0)
2556 /* PIO multi not supported yet */
2557 goto invalid_fld;
2558
2559 /* 2564 /*
2560 * 12 and 16 byte CDBs use different offsets to 2565 * 12 and 16 byte CDBs use different offsets to
2561 * provide the various register values. 2566 * provide the various register values.
@@ -2600,12 +2605,26 @@ static unsigned int ata_scsi_pass_thru(struct ata_queued_cmd *qc)
2600 tf->device = cdb[8]; 2605 tf->device = cdb[8];
2601 tf->command = cdb[9]; 2606 tf->command = cdb[9];
2602 } 2607 }
2603 /* 2608
2604 * If slave is possible, enforce correct master/slave bit 2609 /* enforce correct master/slave bit */
2605 */ 2610 tf->device = dev->devno ?
2606 if (qc->ap->flags & ATA_FLAG_SLAVE_POSS) 2611 tf->device | ATA_DEV1 : tf->device & ~ATA_DEV1;
2607 tf->device = qc->dev->devno ? 2612
2608 tf->device | ATA_DEV1 : tf->device & ~ATA_DEV1; 2613 /* sanity check for pio multi commands */
2614 if ((cdb[1] & 0xe0) && !is_multi_taskfile(tf))
2615 goto invalid_fld;
2616
2617 if (is_multi_taskfile(tf)) {
2618 unsigned int multi_count = 1 << (cdb[1] >> 5);
2619
2620 /* compare the passed through multi_count
2621 * with the cached multi_count of libata
2622 */
2623 if (multi_count != dev->multi_count)
2624 ata_dev_printk(dev, KERN_WARNING,
2625 "invalid multi_count %u ignored\n",
2626 multi_count);
2627 }
2609 2628
2610 /* READ/WRITE LONG use a non-standard sect_size */ 2629 /* READ/WRITE LONG use a non-standard sect_size */
2611 qc->sect_size = ATA_SECT_SIZE; 2630 qc->sect_size = ATA_SECT_SIZE;
diff --git a/drivers/ata/libata-sff.c b/drivers/ata/libata-sff.c
index e35d13466c69..ce84805ba5f1 100644
--- a/drivers/ata/libata-sff.c
+++ b/drivers/ata/libata-sff.c
@@ -80,25 +80,25 @@ u8 ata_dummy_irq_on (struct ata_port *ap) { return 0; }
80u8 ata_irq_ack(struct ata_port *ap, unsigned int chk_drq) 80u8 ata_irq_ack(struct ata_port *ap, unsigned int chk_drq)
81{ 81{
82 unsigned int bits = chk_drq ? ATA_BUSY | ATA_DRQ : ATA_BUSY; 82 unsigned int bits = chk_drq ? ATA_BUSY | ATA_DRQ : ATA_BUSY;
83 u8 host_stat, post_stat, status; 83 u8 host_stat = 0, post_stat = 0, status;
84 84
85 status = ata_busy_wait(ap, bits, 1000); 85 status = ata_busy_wait(ap, bits, 1000);
86 if (status & bits) 86 if (status & bits)
87 if (ata_msg_err(ap)) 87 if (ata_msg_err(ap))
88 printk(KERN_ERR "abnormal status 0x%X\n", status); 88 printk(KERN_ERR "abnormal status 0x%X\n", status);
89 89
90 /* get controller status; clear intr, err bits */ 90 if (ap->ioaddr.bmdma_addr) {
91 host_stat = ioread8(ap->ioaddr.bmdma_addr + ATA_DMA_STATUS); 91 /* get controller status; clear intr, err bits */
92 iowrite8(host_stat | ATA_DMA_INTR | ATA_DMA_ERR, 92 host_stat = ioread8(ap->ioaddr.bmdma_addr + ATA_DMA_STATUS);
93 ap->ioaddr.bmdma_addr + ATA_DMA_STATUS); 93 iowrite8(host_stat | ATA_DMA_INTR | ATA_DMA_ERR,
94 94 ap->ioaddr.bmdma_addr + ATA_DMA_STATUS);
95 post_stat = ioread8(ap->ioaddr.bmdma_addr + ATA_DMA_STATUS);
96 95
96 post_stat = ioread8(ap->ioaddr.bmdma_addr + ATA_DMA_STATUS);
97 }
97 if (ata_msg_intr(ap)) 98 if (ata_msg_intr(ap))
98 printk(KERN_INFO "%s: irq ack: host_stat 0x%X, new host_stat 0x%X, drv_stat 0x%X\n", 99 printk(KERN_INFO "%s: irq ack: host_stat 0x%X, new host_stat 0x%X, drv_stat 0x%X\n",
99 __FUNCTION__, 100 __FUNCTION__,
100 host_stat, post_stat, status); 101 host_stat, post_stat, status);
101
102 return status; 102 return status;
103} 103}
104 104
@@ -516,6 +516,27 @@ void ata_bmdma_post_internal_cmd(struct ata_queued_cmd *qc)
516 ata_bmdma_stop(qc); 516 ata_bmdma_stop(qc);
517} 517}
518 518
519/**
520 * ata_sff_port_start - Set port up for dma.
521 * @ap: Port to initialize
522 *
523 * Called just after data structures for each port are
524 * initialized. Allocates space for PRD table if the device
525 * is DMA capable SFF.
526 *
527 * May be used as the port_start() entry in ata_port_operations.
528 *
529 * LOCKING:
530 * Inherited from caller.
531 */
532
533int ata_sff_port_start(struct ata_port *ap)
534{
535 if (ap->ioaddr.bmdma_addr)
536 return ata_port_start(ap);
537 return 0;
538}
539
519#ifdef CONFIG_PCI 540#ifdef CONFIG_PCI
520 541
521static int ata_resources_present(struct pci_dev *pdev, int port) 542static int ata_resources_present(struct pci_dev *pdev, int port)
diff --git a/drivers/ata/pata_isapnp.c b/drivers/ata/pata_isapnp.c
index 1f647b648204..5525518204e6 100644
--- a/drivers/ata/pata_isapnp.c
+++ b/drivers/ata/pata_isapnp.c
@@ -77,7 +77,6 @@ static int isapnp_init_one(struct pnp_dev *idev, const struct pnp_device_id *dev
77 struct ata_host *host; 77 struct ata_host *host;
78 struct ata_port *ap; 78 struct ata_port *ap;
79 void __iomem *cmd_addr, *ctl_addr; 79 void __iomem *cmd_addr, *ctl_addr;
80 int rc;
81 80
82 if (pnp_port_valid(idev, 0) == 0) 81 if (pnp_port_valid(idev, 0) == 0)
83 return -ENODEV; 82 return -ENODEV;
diff --git a/drivers/char/agp/agp.h b/drivers/char/agp/agp.h
index fdbca25a3948..35ab1a9f8e8b 100644
--- a/drivers/char/agp/agp.h
+++ b/drivers/char/agp/agp.h
@@ -176,7 +176,7 @@ struct agp_bridge_data {
176#define I830_GMCH_MEM_MASK 0x1 176#define I830_GMCH_MEM_MASK 0x1
177#define I830_GMCH_MEM_64M 0x1 177#define I830_GMCH_MEM_64M 0x1
178#define I830_GMCH_MEM_128M 0 178#define I830_GMCH_MEM_128M 0
179#define I830_GMCH_GMS_MASK 0x70 179#define I830_GMCH_GMS_MASK 0xF0
180#define I830_GMCH_GMS_DISABLED 0x00 180#define I830_GMCH_GMS_DISABLED 0x00
181#define I830_GMCH_GMS_LOCAL 0x10 181#define I830_GMCH_GMS_LOCAL 0x10
182#define I830_GMCH_GMS_STOLEN_512 0x20 182#define I830_GMCH_GMS_STOLEN_512 0x20
@@ -231,6 +231,10 @@ struct agp_bridge_data {
231#define I965_PGETBL_SIZE_512KB (0 << 1) 231#define I965_PGETBL_SIZE_512KB (0 << 1)
232#define I965_PGETBL_SIZE_256KB (1 << 1) 232#define I965_PGETBL_SIZE_256KB (1 << 1)
233#define I965_PGETBL_SIZE_128KB (2 << 1) 233#define I965_PGETBL_SIZE_128KB (2 << 1)
234#define G33_PGETBL_SIZE_MASK (3 << 8)
235#define G33_PGETBL_SIZE_1M (1 << 8)
236#define G33_PGETBL_SIZE_2M (2 << 8)
237
234#define I810_DRAM_CTL 0x3000 238#define I810_DRAM_CTL 0x3000
235#define I810_DRAM_ROW_0 0x00000001 239#define I810_DRAM_ROW_0 0x00000001
236#define I810_DRAM_ROW_0_SDRAM 0x00000001 240#define I810_DRAM_ROW_0_SDRAM 0x00000001
diff --git a/drivers/char/agp/intel-agp.c b/drivers/char/agp/intel-agp.c
index 9c69f2e761f5..d383168b75fa 100644
--- a/drivers/char/agp/intel-agp.c
+++ b/drivers/char/agp/intel-agp.c
@@ -20,6 +20,14 @@
20#define PCI_DEVICE_ID_INTEL_82965G_IG 0x29A2 20#define PCI_DEVICE_ID_INTEL_82965G_IG 0x29A2
21#define PCI_DEVICE_ID_INTEL_82965GM_HB 0x2A00 21#define PCI_DEVICE_ID_INTEL_82965GM_HB 0x2A00
22#define PCI_DEVICE_ID_INTEL_82965GM_IG 0x2A02 22#define PCI_DEVICE_ID_INTEL_82965GM_IG 0x2A02
23#define PCI_DEVICE_ID_INTEL_82965GME_IG 0x2A12
24#define PCI_DEVICE_ID_INTEL_82945GME_IG 0x27AE
25#define PCI_DEVICE_ID_INTEL_G33_HB 0x29C0
26#define PCI_DEVICE_ID_INTEL_G33_IG 0x29C2
27#define PCI_DEVICE_ID_INTEL_Q35_HB 0x29B0
28#define PCI_DEVICE_ID_INTEL_Q35_IG 0x29B2
29#define PCI_DEVICE_ID_INTEL_Q33_HB 0x29D0
30#define PCI_DEVICE_ID_INTEL_Q33_IG 0x29D2
23 31
24#define IS_I965 (agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82946GZ_HB || \ 32#define IS_I965 (agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82946GZ_HB || \
25 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82965G_1_HB || \ 33 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82965G_1_HB || \
@@ -27,6 +35,9 @@
27 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82965G_HB || \ 35 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82965G_HB || \
28 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82965GM_HB) 36 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82965GM_HB)
29 37
38#define IS_G33 (agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_G33_HB || \
39 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_Q35_HB || \
40 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_Q33_HB)
30 41
31extern int agp_memory_reserved; 42extern int agp_memory_reserved;
32 43
@@ -53,6 +64,8 @@ extern int agp_memory_reserved;
53#define I915_PTEADDR 0x1C 64#define I915_PTEADDR 0x1C
54#define I915_GMCH_GMS_STOLEN_48M (0x6 << 4) 65#define I915_GMCH_GMS_STOLEN_48M (0x6 << 4)
55#define I915_GMCH_GMS_STOLEN_64M (0x7 << 4) 66#define I915_GMCH_GMS_STOLEN_64M (0x7 << 4)
67#define G33_GMCH_GMS_STOLEN_128M (0x8 << 4)
68#define G33_GMCH_GMS_STOLEN_256M (0x9 << 4)
56 69
57/* Intel 965G registers */ 70/* Intel 965G registers */
58#define I965_MSAC 0x62 71#define I965_MSAC 0x62
@@ -86,11 +99,18 @@ static struct gatt_mask intel_i810_masks[] =
86 .type = INTEL_AGP_CACHED_MEMORY} 99 .type = INTEL_AGP_CACHED_MEMORY}
87}; 100};
88 101
89static struct _intel_i810_private { 102static struct _intel_private {
90 struct pci_dev *i810_dev; /* device one */ 103 struct pci_dev *pcidev; /* device one */
91 volatile u8 __iomem *registers; 104 u8 __iomem *registers;
105 u32 __iomem *gtt; /* I915G */
92 int num_dcache_entries; 106 int num_dcache_entries;
93} intel_i810_private; 107 /* gtt_entries is the number of gtt entries that are already mapped
108 * to stolen memory. Stolen memory is larger than the memory mapped
109 * through gtt_entries, as it includes some reserved space for the BIOS
110 * popup and for the GTT.
111 */
112 int gtt_entries; /* i830+ */
113} intel_private;
94 114
95static int intel_i810_fetch_size(void) 115static int intel_i810_fetch_size(void)
96{ 116{
@@ -127,32 +147,32 @@ static int intel_i810_configure(void)
127 147
128 current_size = A_SIZE_FIX(agp_bridge->current_size); 148 current_size = A_SIZE_FIX(agp_bridge->current_size);
129 149
130 if (!intel_i810_private.registers) { 150 if (!intel_private.registers) {
131 pci_read_config_dword(intel_i810_private.i810_dev, I810_MMADDR, &temp); 151 pci_read_config_dword(intel_private.pcidev, I810_MMADDR, &temp);
132 temp &= 0xfff80000; 152 temp &= 0xfff80000;
133 153
134 intel_i810_private.registers = ioremap(temp, 128 * 4096); 154 intel_private.registers = ioremap(temp, 128 * 4096);
135 if (!intel_i810_private.registers) { 155 if (!intel_private.registers) {
136 printk(KERN_ERR PFX "Unable to remap memory.\n"); 156 printk(KERN_ERR PFX "Unable to remap memory.\n");
137 return -ENOMEM; 157 return -ENOMEM;
138 } 158 }
139 } 159 }
140 160
141 if ((readl(intel_i810_private.registers+I810_DRAM_CTL) 161 if ((readl(intel_private.registers+I810_DRAM_CTL)
142 & I810_DRAM_ROW_0) == I810_DRAM_ROW_0_SDRAM) { 162 & I810_DRAM_ROW_0) == I810_DRAM_ROW_0_SDRAM) {
143 /* This will need to be dynamically assigned */ 163 /* This will need to be dynamically assigned */
144 printk(KERN_INFO PFX "detected 4MB dedicated video ram.\n"); 164 printk(KERN_INFO PFX "detected 4MB dedicated video ram.\n");
145 intel_i810_private.num_dcache_entries = 1024; 165 intel_private.num_dcache_entries = 1024;
146 } 166 }
147 pci_read_config_dword(intel_i810_private.i810_dev, I810_GMADDR, &temp); 167 pci_read_config_dword(intel_private.pcidev, I810_GMADDR, &temp);
148 agp_bridge->gart_bus_addr = (temp & PCI_BASE_ADDRESS_MEM_MASK); 168 agp_bridge->gart_bus_addr = (temp & PCI_BASE_ADDRESS_MEM_MASK);
149 writel(agp_bridge->gatt_bus_addr | I810_PGETBL_ENABLED, intel_i810_private.registers+I810_PGETBL_CTL); 169 writel(agp_bridge->gatt_bus_addr | I810_PGETBL_ENABLED, intel_private.registers+I810_PGETBL_CTL);
150 readl(intel_i810_private.registers+I810_PGETBL_CTL); /* PCI Posting. */ 170 readl(intel_private.registers+I810_PGETBL_CTL); /* PCI Posting. */
151 171
152 if (agp_bridge->driver->needs_scratch_page) { 172 if (agp_bridge->driver->needs_scratch_page) {
153 for (i = 0; i < current_size->num_entries; i++) { 173 for (i = 0; i < current_size->num_entries; i++) {
154 writel(agp_bridge->scratch_page, intel_i810_private.registers+I810_PTE_BASE+(i*4)); 174 writel(agp_bridge->scratch_page, intel_private.registers+I810_PTE_BASE+(i*4));
155 readl(intel_i810_private.registers+I810_PTE_BASE+(i*4)); /* PCI posting. */ 175 readl(intel_private.registers+I810_PTE_BASE+(i*4)); /* PCI posting. */
156 } 176 }
157 } 177 }
158 global_cache_flush(); 178 global_cache_flush();
@@ -161,9 +181,9 @@ static int intel_i810_configure(void)
161 181
162static void intel_i810_cleanup(void) 182static void intel_i810_cleanup(void)
163{ 183{
164 writel(0, intel_i810_private.registers+I810_PGETBL_CTL); 184 writel(0, intel_private.registers+I810_PGETBL_CTL);
165 readl(intel_i810_private.registers); /* PCI Posting. */ 185 readl(intel_private.registers); /* PCI Posting. */
166 iounmap(intel_i810_private.registers); 186 iounmap(intel_private.registers);
167} 187}
168 188
169static void intel_i810_tlbflush(struct agp_memory *mem) 189static void intel_i810_tlbflush(struct agp_memory *mem)
@@ -261,9 +281,9 @@ static int intel_i810_insert_entries(struct agp_memory *mem, off_t pg_start,
261 global_cache_flush(); 281 global_cache_flush();
262 for (i = pg_start; i < (pg_start + mem->page_count); i++) { 282 for (i = pg_start; i < (pg_start + mem->page_count); i++) {
263 writel((i*4096)|I810_PTE_LOCAL|I810_PTE_VALID, 283 writel((i*4096)|I810_PTE_LOCAL|I810_PTE_VALID,
264 intel_i810_private.registers+I810_PTE_BASE+(i*4)); 284 intel_private.registers+I810_PTE_BASE+(i*4));
265 } 285 }
266 readl(intel_i810_private.registers+I810_PTE_BASE+((i-1)*4)); 286 readl(intel_private.registers+I810_PTE_BASE+((i-1)*4));
267 break; 287 break;
268 case AGP_PHYS_MEMORY: 288 case AGP_PHYS_MEMORY:
269 case AGP_NORMAL_MEMORY: 289 case AGP_NORMAL_MEMORY:
@@ -273,9 +293,9 @@ static int intel_i810_insert_entries(struct agp_memory *mem, off_t pg_start,
273 writel(agp_bridge->driver->mask_memory(agp_bridge, 293 writel(agp_bridge->driver->mask_memory(agp_bridge,
274 mem->memory[i], 294 mem->memory[i],
275 mask_type), 295 mask_type),
276 intel_i810_private.registers+I810_PTE_BASE+(j*4)); 296 intel_private.registers+I810_PTE_BASE+(j*4));
277 } 297 }
278 readl(intel_i810_private.registers+I810_PTE_BASE+((j-1)*4)); 298 readl(intel_private.registers+I810_PTE_BASE+((j-1)*4));
279 break; 299 break;
280 default: 300 default:
281 goto out_err; 301 goto out_err;
@@ -298,9 +318,9 @@ static int intel_i810_remove_entries(struct agp_memory *mem, off_t pg_start,
298 return 0; 318 return 0;
299 319
300 for (i = pg_start; i < (mem->page_count + pg_start); i++) { 320 for (i = pg_start; i < (mem->page_count + pg_start); i++) {
301 writel(agp_bridge->scratch_page, intel_i810_private.registers+I810_PTE_BASE+(i*4)); 321 writel(agp_bridge->scratch_page, intel_private.registers+I810_PTE_BASE+(i*4));
302 } 322 }
303 readl(intel_i810_private.registers+I810_PTE_BASE+((i-1)*4)); 323 readl(intel_private.registers+I810_PTE_BASE+((i-1)*4));
304 324
305 agp_bridge->driver->tlb_flush(mem); 325 agp_bridge->driver->tlb_flush(mem);
306 return 0; 326 return 0;
@@ -354,7 +374,7 @@ static struct agp_memory *intel_i810_alloc_by_type(size_t pg_count, int type)
354 struct agp_memory *new; 374 struct agp_memory *new;
355 375
356 if (type == AGP_DCACHE_MEMORY) { 376 if (type == AGP_DCACHE_MEMORY) {
357 if (pg_count != intel_i810_private.num_dcache_entries) 377 if (pg_count != intel_private.num_dcache_entries)
358 return NULL; 378 return NULL;
359 379
360 new = agp_create_memory(1); 380 new = agp_create_memory(1);
@@ -404,18 +424,6 @@ static struct aper_size_info_fixed intel_i830_sizes[] =
404 {512, 131072, 7}, 424 {512, 131072, 7},
405}; 425};
406 426
407static struct _intel_i830_private {
408 struct pci_dev *i830_dev; /* device one */
409 volatile u8 __iomem *registers;
410 volatile u32 __iomem *gtt; /* I915G */
411 /* gtt_entries is the number of gtt entries that are already mapped
412 * to stolen memory. Stolen memory is larger than the memory mapped
413 * through gtt_entries, as it includes some reserved space for the BIOS
414 * popup and for the GTT.
415 */
416 int gtt_entries;
417} intel_i830_private;
418
419static void intel_i830_init_gtt_entries(void) 427static void intel_i830_init_gtt_entries(void)
420{ 428{
421 u16 gmch_ctrl; 429 u16 gmch_ctrl;
@@ -429,7 +437,7 @@ static void intel_i830_init_gtt_entries(void)
429 437
430 if (IS_I965) { 438 if (IS_I965) {
431 u32 pgetbl_ctl; 439 u32 pgetbl_ctl;
432 pgetbl_ctl = readl(intel_i830_private.registers+I810_PGETBL_CTL); 440 pgetbl_ctl = readl(intel_private.registers+I810_PGETBL_CTL);
433 441
434 /* The 965 has a field telling us the size of the GTT, 442 /* The 965 has a field telling us the size of the GTT,
435 * which may be larger than what is necessary to map the 443 * which may be larger than what is necessary to map the
@@ -451,6 +459,22 @@ static void intel_i830_init_gtt_entries(void)
451 size = 512; 459 size = 512;
452 } 460 }
453 size += 4; /* add in BIOS popup space */ 461 size += 4; /* add in BIOS popup space */
462 } else if (IS_G33) {
463 /* G33's GTT size defined in gmch_ctrl */
464 switch (gmch_ctrl & G33_PGETBL_SIZE_MASK) {
465 case G33_PGETBL_SIZE_1M:
466 size = 1024;
467 break;
468 case G33_PGETBL_SIZE_2M:
469 size = 2048;
470 break;
471 default:
472 printk(KERN_INFO PFX "Unknown page table size 0x%x, "
473 "assuming 512KB\n",
474 (gmch_ctrl & G33_PGETBL_SIZE_MASK));
475 size = 512;
476 }
477 size += 4;
454 } else { 478 } else {
455 /* On previous hardware, the GTT size was just what was 479 /* On previous hardware, the GTT size was just what was
456 * required to map the aperture. 480 * required to map the aperture.
@@ -471,7 +495,7 @@ static void intel_i830_init_gtt_entries(void)
471 gtt_entries = MB(8) - KB(size); 495 gtt_entries = MB(8) - KB(size);
472 break; 496 break;
473 case I830_GMCH_GMS_LOCAL: 497 case I830_GMCH_GMS_LOCAL:
474 rdct = readb(intel_i830_private.registers+I830_RDRAM_CHANNEL_TYPE); 498 rdct = readb(intel_private.registers+I830_RDRAM_CHANNEL_TYPE);
475 gtt_entries = (I830_RDRAM_ND(rdct) + 1) * 499 gtt_entries = (I830_RDRAM_ND(rdct) + 1) *
476 MB(ddt[I830_RDRAM_DDT(rdct)]); 500 MB(ddt[I830_RDRAM_DDT(rdct)]);
477 local = 1; 501 local = 1;
@@ -502,7 +526,8 @@ static void intel_i830_init_gtt_entries(void)
502 if (agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82915G_HB || 526 if (agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82915G_HB ||
503 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82915GM_HB || 527 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82915GM_HB ||
504 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82945G_HB || 528 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82945G_HB ||
505 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82945GM_HB || IS_I965 ) 529 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82945GM_HB ||
530 IS_I965 || IS_G33)
506 gtt_entries = MB(48) - KB(size); 531 gtt_entries = MB(48) - KB(size);
507 else 532 else
508 gtt_entries = 0; 533 gtt_entries = 0;
@@ -512,10 +537,24 @@ static void intel_i830_init_gtt_entries(void)
512 if (agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82915G_HB || 537 if (agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82915G_HB ||
513 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82915GM_HB || 538 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82915GM_HB ||
514 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82945G_HB || 539 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82945G_HB ||
515 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82945GM_HB || IS_I965) 540 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82945GM_HB ||
541 IS_I965 || IS_G33)
516 gtt_entries = MB(64) - KB(size); 542 gtt_entries = MB(64) - KB(size);
517 else 543 else
518 gtt_entries = 0; 544 gtt_entries = 0;
545 break;
546 case G33_GMCH_GMS_STOLEN_128M:
547 if (IS_G33)
548 gtt_entries = MB(128) - KB(size);
549 else
550 gtt_entries = 0;
551 break;
552 case G33_GMCH_GMS_STOLEN_256M:
553 if (IS_G33)
554 gtt_entries = MB(256) - KB(size);
555 else
556 gtt_entries = 0;
557 break;
519 default: 558 default:
520 gtt_entries = 0; 559 gtt_entries = 0;
521 break; 560 break;
@@ -529,7 +568,7 @@ static void intel_i830_init_gtt_entries(void)
529 "No pre-allocated video memory detected.\n"); 568 "No pre-allocated video memory detected.\n");
530 gtt_entries /= KB(4); 569 gtt_entries /= KB(4);
531 570
532 intel_i830_private.gtt_entries = gtt_entries; 571 intel_private.gtt_entries = gtt_entries;
533} 572}
534 573
535/* The intel i830 automatically initializes the agp aperture during POST. 574/* The intel i830 automatically initializes the agp aperture during POST.
@@ -547,14 +586,14 @@ static int intel_i830_create_gatt_table(struct agp_bridge_data *bridge)
547 num_entries = size->num_entries; 586 num_entries = size->num_entries;
548 agp_bridge->gatt_table_real = NULL; 587 agp_bridge->gatt_table_real = NULL;
549 588
550 pci_read_config_dword(intel_i830_private.i830_dev,I810_MMADDR,&temp); 589 pci_read_config_dword(intel_private.pcidev,I810_MMADDR,&temp);
551 temp &= 0xfff80000; 590 temp &= 0xfff80000;
552 591
553 intel_i830_private.registers = ioremap(temp,128 * 4096); 592 intel_private.registers = ioremap(temp,128 * 4096);
554 if (!intel_i830_private.registers) 593 if (!intel_private.registers)
555 return -ENOMEM; 594 return -ENOMEM;
556 595
557 temp = readl(intel_i830_private.registers+I810_PGETBL_CTL) & 0xfffff000; 596 temp = readl(intel_private.registers+I810_PGETBL_CTL) & 0xfffff000;
558 global_cache_flush(); /* FIXME: ?? */ 597 global_cache_flush(); /* FIXME: ?? */
559 598
560 /* we have to call this as early as possible after the MMIO base address is known */ 599 /* we have to call this as early as possible after the MMIO base address is known */
@@ -614,20 +653,20 @@ static int intel_i830_configure(void)
614 653
615 current_size = A_SIZE_FIX(agp_bridge->current_size); 654 current_size = A_SIZE_FIX(agp_bridge->current_size);
616 655
617 pci_read_config_dword(intel_i830_private.i830_dev,I810_GMADDR,&temp); 656 pci_read_config_dword(intel_private.pcidev,I810_GMADDR,&temp);
618 agp_bridge->gart_bus_addr = (temp & PCI_BASE_ADDRESS_MEM_MASK); 657 agp_bridge->gart_bus_addr = (temp & PCI_BASE_ADDRESS_MEM_MASK);
619 658
620 pci_read_config_word(agp_bridge->dev,I830_GMCH_CTRL,&gmch_ctrl); 659 pci_read_config_word(agp_bridge->dev,I830_GMCH_CTRL,&gmch_ctrl);
621 gmch_ctrl |= I830_GMCH_ENABLED; 660 gmch_ctrl |= I830_GMCH_ENABLED;
622 pci_write_config_word(agp_bridge->dev,I830_GMCH_CTRL,gmch_ctrl); 661 pci_write_config_word(agp_bridge->dev,I830_GMCH_CTRL,gmch_ctrl);
623 662
624 writel(agp_bridge->gatt_bus_addr|I810_PGETBL_ENABLED, intel_i830_private.registers+I810_PGETBL_CTL); 663 writel(agp_bridge->gatt_bus_addr|I810_PGETBL_ENABLED, intel_private.registers+I810_PGETBL_CTL);
625 readl(intel_i830_private.registers+I810_PGETBL_CTL); /* PCI Posting. */ 664 readl(intel_private.registers+I810_PGETBL_CTL); /* PCI Posting. */
626 665
627 if (agp_bridge->driver->needs_scratch_page) { 666 if (agp_bridge->driver->needs_scratch_page) {
628 for (i = intel_i830_private.gtt_entries; i < current_size->num_entries; i++) { 667 for (i = intel_private.gtt_entries; i < current_size->num_entries; i++) {
629 writel(agp_bridge->scratch_page, intel_i830_private.registers+I810_PTE_BASE+(i*4)); 668 writel(agp_bridge->scratch_page, intel_private.registers+I810_PTE_BASE+(i*4));
630 readl(intel_i830_private.registers+I810_PTE_BASE+(i*4)); /* PCI Posting. */ 669 readl(intel_private.registers+I810_PTE_BASE+(i*4)); /* PCI Posting. */
631 } 670 }
632 } 671 }
633 672
@@ -637,7 +676,7 @@ static int intel_i830_configure(void)
637 676
638static void intel_i830_cleanup(void) 677static void intel_i830_cleanup(void)
639{ 678{
640 iounmap(intel_i830_private.registers); 679 iounmap(intel_private.registers);
641} 680}
642 681
643static int intel_i830_insert_entries(struct agp_memory *mem,off_t pg_start, int type) 682static int intel_i830_insert_entries(struct agp_memory *mem,off_t pg_start, int type)
@@ -653,9 +692,9 @@ static int intel_i830_insert_entries(struct agp_memory *mem,off_t pg_start, int
653 temp = agp_bridge->current_size; 692 temp = agp_bridge->current_size;
654 num_entries = A_SIZE_FIX(temp)->num_entries; 693 num_entries = A_SIZE_FIX(temp)->num_entries;
655 694
656 if (pg_start < intel_i830_private.gtt_entries) { 695 if (pg_start < intel_private.gtt_entries) {
657 printk (KERN_DEBUG PFX "pg_start == 0x%.8lx,intel_i830_private.gtt_entries == 0x%.8x\n", 696 printk (KERN_DEBUG PFX "pg_start == 0x%.8lx,intel_private.gtt_entries == 0x%.8x\n",
658 pg_start,intel_i830_private.gtt_entries); 697 pg_start,intel_private.gtt_entries);
659 698
660 printk (KERN_INFO PFX "Trying to insert into local/stolen memory\n"); 699 printk (KERN_INFO PFX "Trying to insert into local/stolen memory\n");
661 goto out_err; 700 goto out_err;
@@ -683,9 +722,9 @@ static int intel_i830_insert_entries(struct agp_memory *mem,off_t pg_start, int
683 for (i = 0, j = pg_start; i < mem->page_count; i++, j++) { 722 for (i = 0, j = pg_start; i < mem->page_count; i++, j++) {
684 writel(agp_bridge->driver->mask_memory(agp_bridge, 723 writel(agp_bridge->driver->mask_memory(agp_bridge,
685 mem->memory[i], mask_type), 724 mem->memory[i], mask_type),
686 intel_i830_private.registers+I810_PTE_BASE+(j*4)); 725 intel_private.registers+I810_PTE_BASE+(j*4));
687 } 726 }
688 readl(intel_i830_private.registers+I810_PTE_BASE+((j-1)*4)); 727 readl(intel_private.registers+I810_PTE_BASE+((j-1)*4));
689 agp_bridge->driver->tlb_flush(mem); 728 agp_bridge->driver->tlb_flush(mem);
690 729
691out: 730out:
@@ -703,15 +742,15 @@ static int intel_i830_remove_entries(struct agp_memory *mem,off_t pg_start,
703 if (mem->page_count == 0) 742 if (mem->page_count == 0)
704 return 0; 743 return 0;
705 744
706 if (pg_start < intel_i830_private.gtt_entries) { 745 if (pg_start < intel_private.gtt_entries) {
707 printk (KERN_INFO PFX "Trying to disable local/stolen memory\n"); 746 printk (KERN_INFO PFX "Trying to disable local/stolen memory\n");
708 return -EINVAL; 747 return -EINVAL;
709 } 748 }
710 749
711 for (i = pg_start; i < (mem->page_count + pg_start); i++) { 750 for (i = pg_start; i < (mem->page_count + pg_start); i++) {
712 writel(agp_bridge->scratch_page, intel_i830_private.registers+I810_PTE_BASE+(i*4)); 751 writel(agp_bridge->scratch_page, intel_private.registers+I810_PTE_BASE+(i*4));
713 } 752 }
714 readl(intel_i830_private.registers+I810_PTE_BASE+((i-1)*4)); 753 readl(intel_private.registers+I810_PTE_BASE+((i-1)*4));
715 754
716 agp_bridge->driver->tlb_flush(mem); 755 agp_bridge->driver->tlb_flush(mem);
717 return 0; 756 return 0;
@@ -734,7 +773,7 @@ static int intel_i915_configure(void)
734 773
735 current_size = A_SIZE_FIX(agp_bridge->current_size); 774 current_size = A_SIZE_FIX(agp_bridge->current_size);
736 775
737 pci_read_config_dword(intel_i830_private.i830_dev, I915_GMADDR, &temp); 776 pci_read_config_dword(intel_private.pcidev, I915_GMADDR, &temp);
738 777
739 agp_bridge->gart_bus_addr = (temp & PCI_BASE_ADDRESS_MEM_MASK); 778 agp_bridge->gart_bus_addr = (temp & PCI_BASE_ADDRESS_MEM_MASK);
740 779
@@ -742,13 +781,13 @@ static int intel_i915_configure(void)
742 gmch_ctrl |= I830_GMCH_ENABLED; 781 gmch_ctrl |= I830_GMCH_ENABLED;
743 pci_write_config_word(agp_bridge->dev,I830_GMCH_CTRL,gmch_ctrl); 782 pci_write_config_word(agp_bridge->dev,I830_GMCH_CTRL,gmch_ctrl);
744 783
745 writel(agp_bridge->gatt_bus_addr|I810_PGETBL_ENABLED, intel_i830_private.registers+I810_PGETBL_CTL); 784 writel(agp_bridge->gatt_bus_addr|I810_PGETBL_ENABLED, intel_private.registers+I810_PGETBL_CTL);
746 readl(intel_i830_private.registers+I810_PGETBL_CTL); /* PCI Posting. */ 785 readl(intel_private.registers+I810_PGETBL_CTL); /* PCI Posting. */
747 786
748 if (agp_bridge->driver->needs_scratch_page) { 787 if (agp_bridge->driver->needs_scratch_page) {
749 for (i = intel_i830_private.gtt_entries; i < current_size->num_entries; i++) { 788 for (i = intel_private.gtt_entries; i < current_size->num_entries; i++) {
750 writel(agp_bridge->scratch_page, intel_i830_private.gtt+i); 789 writel(agp_bridge->scratch_page, intel_private.gtt+i);
751 readl(intel_i830_private.gtt+i); /* PCI Posting. */ 790 readl(intel_private.gtt+i); /* PCI Posting. */
752 } 791 }
753 } 792 }
754 793
@@ -758,8 +797,8 @@ static int intel_i915_configure(void)
758 797
759static void intel_i915_cleanup(void) 798static void intel_i915_cleanup(void)
760{ 799{
761 iounmap(intel_i830_private.gtt); 800 iounmap(intel_private.gtt);
762 iounmap(intel_i830_private.registers); 801 iounmap(intel_private.registers);
763} 802}
764 803
765static int intel_i915_insert_entries(struct agp_memory *mem,off_t pg_start, 804static int intel_i915_insert_entries(struct agp_memory *mem,off_t pg_start,
@@ -776,9 +815,9 @@ static int intel_i915_insert_entries(struct agp_memory *mem,off_t pg_start,
776 temp = agp_bridge->current_size; 815 temp = agp_bridge->current_size;
777 num_entries = A_SIZE_FIX(temp)->num_entries; 816 num_entries = A_SIZE_FIX(temp)->num_entries;
778 817
779 if (pg_start < intel_i830_private.gtt_entries) { 818 if (pg_start < intel_private.gtt_entries) {
780 printk (KERN_DEBUG PFX "pg_start == 0x%.8lx,intel_i830_private.gtt_entries == 0x%.8x\n", 819 printk (KERN_DEBUG PFX "pg_start == 0x%.8lx,intel_private.gtt_entries == 0x%.8x\n",
781 pg_start,intel_i830_private.gtt_entries); 820 pg_start,intel_private.gtt_entries);
782 821
783 printk (KERN_INFO PFX "Trying to insert into local/stolen memory\n"); 822 printk (KERN_INFO PFX "Trying to insert into local/stolen memory\n");
784 goto out_err; 823 goto out_err;
@@ -805,10 +844,10 @@ static int intel_i915_insert_entries(struct agp_memory *mem,off_t pg_start,
805 844
806 for (i = 0, j = pg_start; i < mem->page_count; i++, j++) { 845 for (i = 0, j = pg_start; i < mem->page_count; i++, j++) {
807 writel(agp_bridge->driver->mask_memory(agp_bridge, 846 writel(agp_bridge->driver->mask_memory(agp_bridge,
808 mem->memory[i], mask_type), intel_i830_private.gtt+j); 847 mem->memory[i], mask_type), intel_private.gtt+j);
809 } 848 }
810 849
811 readl(intel_i830_private.gtt+j-1); 850 readl(intel_private.gtt+j-1);
812 agp_bridge->driver->tlb_flush(mem); 851 agp_bridge->driver->tlb_flush(mem);
813 852
814 out: 853 out:
@@ -826,15 +865,15 @@ static int intel_i915_remove_entries(struct agp_memory *mem,off_t pg_start,
826 if (mem->page_count == 0) 865 if (mem->page_count == 0)
827 return 0; 866 return 0;
828 867
829 if (pg_start < intel_i830_private.gtt_entries) { 868 if (pg_start < intel_private.gtt_entries) {
830 printk (KERN_INFO PFX "Trying to disable local/stolen memory\n"); 869 printk (KERN_INFO PFX "Trying to disable local/stolen memory\n");
831 return -EINVAL; 870 return -EINVAL;
832 } 871 }
833 872
834 for (i = pg_start; i < (mem->page_count + pg_start); i++) { 873 for (i = pg_start; i < (mem->page_count + pg_start); i++) {
835 writel(agp_bridge->scratch_page, intel_i830_private.gtt+i); 874 writel(agp_bridge->scratch_page, intel_private.gtt+i);
836 } 875 }
837 readl(intel_i830_private.gtt+i-1); 876 readl(intel_private.gtt+i-1);
838 877
839 agp_bridge->driver->tlb_flush(mem); 878 agp_bridge->driver->tlb_flush(mem);
840 return 0; 879 return 0;
@@ -850,7 +889,7 @@ static int intel_i9xx_fetch_size(void)
850 int aper_size; /* size in megabytes */ 889 int aper_size; /* size in megabytes */
851 int i; 890 int i;
852 891
853 aper_size = pci_resource_len(intel_i830_private.i830_dev, 2) / MB(1); 892 aper_size = pci_resource_len(intel_private.pcidev, 2) / MB(1);
854 893
855 for (i = 0; i < num_sizes; i++) { 894 for (i = 0; i < num_sizes; i++) {
856 if (aper_size == intel_i830_sizes[i].size) { 895 if (aper_size == intel_i830_sizes[i].size) {
@@ -878,20 +917,20 @@ static int intel_i915_create_gatt_table(struct agp_bridge_data *bridge)
878 num_entries = size->num_entries; 917 num_entries = size->num_entries;
879 agp_bridge->gatt_table_real = NULL; 918 agp_bridge->gatt_table_real = NULL;
880 919
881 pci_read_config_dword(intel_i830_private.i830_dev, I915_MMADDR, &temp); 920 pci_read_config_dword(intel_private.pcidev, I915_MMADDR, &temp);
882 pci_read_config_dword(intel_i830_private.i830_dev, I915_PTEADDR,&temp2); 921 pci_read_config_dword(intel_private.pcidev, I915_PTEADDR,&temp2);
883 922
884 intel_i830_private.gtt = ioremap(temp2, 256 * 1024); 923 intel_private.gtt = ioremap(temp2, 256 * 1024);
885 if (!intel_i830_private.gtt) 924 if (!intel_private.gtt)
886 return -ENOMEM; 925 return -ENOMEM;
887 926
888 temp &= 0xfff80000; 927 temp &= 0xfff80000;
889 928
890 intel_i830_private.registers = ioremap(temp,128 * 4096); 929 intel_private.registers = ioremap(temp,128 * 4096);
891 if (!intel_i830_private.registers) 930 if (!intel_private.registers)
892 return -ENOMEM; 931 return -ENOMEM;
893 932
894 temp = readl(intel_i830_private.registers+I810_PGETBL_CTL) & 0xfffff000; 933 temp = readl(intel_private.registers+I810_PGETBL_CTL) & 0xfffff000;
895 global_cache_flush(); /* FIXME: ? */ 934 global_cache_flush(); /* FIXME: ? */
896 935
897 /* we have to call this as early as possible after the MMIO base address is known */ 936 /* we have to call this as early as possible after the MMIO base address is known */
@@ -938,20 +977,20 @@ static int intel_i965_create_gatt_table(struct agp_bridge_data *bridge)
938 num_entries = size->num_entries; 977 num_entries = size->num_entries;
939 agp_bridge->gatt_table_real = NULL; 978 agp_bridge->gatt_table_real = NULL;
940 979
941 pci_read_config_dword(intel_i830_private.i830_dev, I915_MMADDR, &temp); 980 pci_read_config_dword(intel_private.pcidev, I915_MMADDR, &temp);
942 981
943 temp &= 0xfff00000; 982 temp &= 0xfff00000;
944 intel_i830_private.gtt = ioremap((temp + (512 * 1024)) , 512 * 1024); 983 intel_private.gtt = ioremap((temp + (512 * 1024)) , 512 * 1024);
945 984
946 if (!intel_i830_private.gtt) 985 if (!intel_private.gtt)
947 return -ENOMEM; 986 return -ENOMEM;
948 987
949 988
950 intel_i830_private.registers = ioremap(temp,128 * 4096); 989 intel_private.registers = ioremap(temp,128 * 4096);
951 if (!intel_i830_private.registers) 990 if (!intel_private.registers)
952 return -ENOMEM; 991 return -ENOMEM;
953 992
954 temp = readl(intel_i830_private.registers+I810_PGETBL_CTL) & 0xfffff000; 993 temp = readl(intel_private.registers+I810_PGETBL_CTL) & 0xfffff000;
955 global_cache_flush(); /* FIXME: ? */ 994 global_cache_flush(); /* FIXME: ? */
956 995
957 /* we have to call this as early as possible after the MMIO base address is known */ 996 /* we have to call this as early as possible after the MMIO base address is known */
@@ -1722,41 +1761,126 @@ static const struct agp_bridge_driver intel_7505_driver = {
1722 .agp_type_to_mask_type = agp_generic_type_to_mask_type, 1761 .agp_type_to_mask_type = agp_generic_type_to_mask_type,
1723}; 1762};
1724 1763
1725static int find_i810(u16 device) 1764static const struct agp_bridge_driver intel_g33_driver = {
1726{ 1765 .owner = THIS_MODULE,
1727 struct pci_dev *i810_dev; 1766 .aperture_sizes = intel_i830_sizes,
1728 1767 .size_type = FIXED_APER_SIZE,
1729 i810_dev = pci_get_device(PCI_VENDOR_ID_INTEL, device, NULL); 1768 .num_aperture_sizes = 4,
1730 if (!i810_dev) 1769 .needs_scratch_page = TRUE,
1731 return 0; 1770 .configure = intel_i915_configure,
1732 intel_i810_private.i810_dev = i810_dev; 1771 .fetch_size = intel_i9xx_fetch_size,
1733 return 1; 1772 .cleanup = intel_i915_cleanup,
1734} 1773 .tlb_flush = intel_i810_tlbflush,
1774 .mask_memory = intel_i965_mask_memory,
1775 .masks = intel_i810_masks,
1776 .agp_enable = intel_i810_agp_enable,
1777 .cache_flush = global_cache_flush,
1778 .create_gatt_table = intel_i915_create_gatt_table,
1779 .free_gatt_table = intel_i830_free_gatt_table,
1780 .insert_memory = intel_i915_insert_entries,
1781 .remove_memory = intel_i915_remove_entries,
1782 .alloc_by_type = intel_i830_alloc_by_type,
1783 .free_by_type = intel_i810_free_by_type,
1784 .agp_alloc_page = agp_generic_alloc_page,
1785 .agp_destroy_page = agp_generic_destroy_page,
1786 .agp_type_to_mask_type = intel_i830_type_to_mask_type,
1787};
1735 1788
1736static int find_i830(u16 device) 1789static int find_gmch(u16 device)
1737{ 1790{
1738 struct pci_dev *i830_dev; 1791 struct pci_dev *gmch_device;
1739 1792
1740 i830_dev = pci_get_device(PCI_VENDOR_ID_INTEL, device, NULL); 1793 gmch_device = pci_get_device(PCI_VENDOR_ID_INTEL, device, NULL);
1741 if (i830_dev && PCI_FUNC(i830_dev->devfn) != 0) { 1794 if (gmch_device && PCI_FUNC(gmch_device->devfn) != 0) {
1742 i830_dev = pci_get_device(PCI_VENDOR_ID_INTEL, 1795 gmch_device = pci_get_device(PCI_VENDOR_ID_INTEL,
1743 device, i830_dev); 1796 device, gmch_device);
1744 } 1797 }
1745 1798
1746 if (!i830_dev) 1799 if (!gmch_device)
1747 return 0; 1800 return 0;
1748 1801
1749 intel_i830_private.i830_dev = i830_dev; 1802 intel_private.pcidev = gmch_device;
1750 return 1; 1803 return 1;
1751} 1804}
1752 1805
1806/* Table to describe Intel GMCH and AGP/PCIE GART drivers. At least one of
1807 * driver and gmch_driver must be non-null, and find_gmch will determine
1808 * which one should be used if a gmch_chip_id is present.
1809 */
1810static const struct intel_driver_description {
1811 unsigned int chip_id;
1812 unsigned int gmch_chip_id;
1813 char *name;
1814 const struct agp_bridge_driver *driver;
1815 const struct agp_bridge_driver *gmch_driver;
1816} intel_agp_chipsets[] = {
1817 { PCI_DEVICE_ID_INTEL_82443LX_0, 0, "440LX", &intel_generic_driver, NULL },
1818 { PCI_DEVICE_ID_INTEL_82443BX_0, 0, "440BX", &intel_generic_driver, NULL },
1819 { PCI_DEVICE_ID_INTEL_82443GX_0, 0, "440GX", &intel_generic_driver, NULL },
1820 { PCI_DEVICE_ID_INTEL_82810_MC1, PCI_DEVICE_ID_INTEL_82810_IG1, "i810",
1821 NULL, &intel_810_driver },
1822 { PCI_DEVICE_ID_INTEL_82810_MC3, PCI_DEVICE_ID_INTEL_82810_IG3, "i810",
1823 NULL, &intel_810_driver },
1824 { PCI_DEVICE_ID_INTEL_82810E_MC, PCI_DEVICE_ID_INTEL_82810E_IG, "i810",
1825 NULL, &intel_810_driver },
1826 { PCI_DEVICE_ID_INTEL_82815_MC, PCI_DEVICE_ID_INTEL_82815_CGC, "i815",
1827 &intel_810_driver, &intel_815_driver },
1828 { PCI_DEVICE_ID_INTEL_82820_HB, 0, "i820", &intel_820_driver, NULL },
1829 { PCI_DEVICE_ID_INTEL_82820_UP_HB, 0, "i820", &intel_820_driver, NULL },
1830 { PCI_DEVICE_ID_INTEL_82830_HB, PCI_DEVICE_ID_INTEL_82830_CGC, "830M",
1831 &intel_830mp_driver, &intel_830_driver },
1832 { PCI_DEVICE_ID_INTEL_82840_HB, 0, "i840", &intel_840_driver, NULL },
1833 { PCI_DEVICE_ID_INTEL_82845_HB, 0, "845G", &intel_845_driver, NULL },
1834 { PCI_DEVICE_ID_INTEL_82845G_HB, PCI_DEVICE_ID_INTEL_82845G_IG, "830M",
1835 &intel_845_driver, &intel_830_driver },
1836 { PCI_DEVICE_ID_INTEL_82850_HB, 0, "i850", &intel_850_driver, NULL },
1837 { PCI_DEVICE_ID_INTEL_82855PM_HB, 0, "855PM", &intel_845_driver, NULL },
1838 { PCI_DEVICE_ID_INTEL_82855GM_HB, PCI_DEVICE_ID_INTEL_82855GM_IG, "855GM",
1839 &intel_845_driver, &intel_830_driver },
1840 { PCI_DEVICE_ID_INTEL_82860_HB, 0, "i860", &intel_860_driver, NULL },
1841 { PCI_DEVICE_ID_INTEL_82865_HB, PCI_DEVICE_ID_INTEL_82865_IG, "865",
1842 &intel_845_driver, &intel_830_driver },
1843 { PCI_DEVICE_ID_INTEL_82875_HB, 0, "i875", &intel_845_driver, NULL },
1844 { PCI_DEVICE_ID_INTEL_82915G_HB, PCI_DEVICE_ID_INTEL_82915G_IG, "915G",
1845 &intel_845_driver, &intel_915_driver },
1846 { PCI_DEVICE_ID_INTEL_82915GM_HB, PCI_DEVICE_ID_INTEL_82915GM_IG, "915GM",
1847 &intel_845_driver, &intel_915_driver },
1848 { PCI_DEVICE_ID_INTEL_82945G_HB, PCI_DEVICE_ID_INTEL_82945G_IG, "945G",
1849 &intel_845_driver, &intel_915_driver },
1850 { PCI_DEVICE_ID_INTEL_82945GM_HB, PCI_DEVICE_ID_INTEL_82945GM_IG, "945GM",
1851 &intel_845_driver, &intel_915_driver },
1852 { PCI_DEVICE_ID_INTEL_82945GM_HB, PCI_DEVICE_ID_INTEL_82945GME_IG, "945GME",
1853 &intel_845_driver, &intel_915_driver },
1854 { PCI_DEVICE_ID_INTEL_82946GZ_HB, PCI_DEVICE_ID_INTEL_82946GZ_IG, "946GZ",
1855 &intel_845_driver, &intel_i965_driver },
1856 { PCI_DEVICE_ID_INTEL_82965G_1_HB, PCI_DEVICE_ID_INTEL_82965G_1_IG, "965G",
1857 &intel_845_driver, &intel_i965_driver },
1858 { PCI_DEVICE_ID_INTEL_82965Q_HB, PCI_DEVICE_ID_INTEL_82965Q_IG, "965Q",
1859 &intel_845_driver, &intel_i965_driver },
1860 { PCI_DEVICE_ID_INTEL_82965G_HB, PCI_DEVICE_ID_INTEL_82965G_IG, "965G",
1861 &intel_845_driver, &intel_i965_driver },
1862 { PCI_DEVICE_ID_INTEL_82965GM_HB, PCI_DEVICE_ID_INTEL_82965GM_IG, "965GM",
1863 &intel_845_driver, &intel_i965_driver },
1864 { PCI_DEVICE_ID_INTEL_82965GM_HB, PCI_DEVICE_ID_INTEL_82965GME_IG, "965GME/GLE",
1865 &intel_845_driver, &intel_i965_driver },
1866 { PCI_DEVICE_ID_INTEL_7505_0, 0, "E7505", &intel_7505_driver, NULL },
1867 { PCI_DEVICE_ID_INTEL_7205_0, 0, "E7205", &intel_7505_driver, NULL },
1868 { PCI_DEVICE_ID_INTEL_G33_HB, PCI_DEVICE_ID_INTEL_G33_IG, "G33",
1869 &intel_845_driver, &intel_g33_driver },
1870 { PCI_DEVICE_ID_INTEL_Q35_HB, PCI_DEVICE_ID_INTEL_Q35_IG, "Q35",
1871 &intel_845_driver, &intel_g33_driver },
1872 { PCI_DEVICE_ID_INTEL_Q33_HB, PCI_DEVICE_ID_INTEL_Q33_IG, "Q33",
1873 &intel_845_driver, &intel_g33_driver },
1874 { 0, 0, NULL, NULL, NULL }
1875};
1876
1753static int __devinit agp_intel_probe(struct pci_dev *pdev, 1877static int __devinit agp_intel_probe(struct pci_dev *pdev,
1754 const struct pci_device_id *ent) 1878 const struct pci_device_id *ent)
1755{ 1879{
1756 struct agp_bridge_data *bridge; 1880 struct agp_bridge_data *bridge;
1757 char *name = "(unknown)";
1758 u8 cap_ptr = 0; 1881 u8 cap_ptr = 0;
1759 struct resource *r; 1882 struct resource *r;
1883 int i;
1760 1884
1761 cap_ptr = pci_find_capability(pdev, PCI_CAP_ID_AGP); 1885 cap_ptr = pci_find_capability(pdev, PCI_CAP_ID_AGP);
1762 1886
@@ -1764,195 +1888,42 @@ static int __devinit agp_intel_probe(struct pci_dev *pdev,
1764 if (!bridge) 1888 if (!bridge)
1765 return -ENOMEM; 1889 return -ENOMEM;
1766 1890
1767 switch (pdev->device) { 1891 for (i = 0; intel_agp_chipsets[i].name != NULL; i++) {
1768 case PCI_DEVICE_ID_INTEL_82443LX_0: 1892 /* In case that multiple models of gfx chip may
1769 bridge->driver = &intel_generic_driver; 1893 stand on same host bridge type, this can be
1770 name = "440LX"; 1894 sure we detect the right IGD. */
1771 break; 1895 if ((pdev->device == intel_agp_chipsets[i].chip_id) &&
1772 case PCI_DEVICE_ID_INTEL_82443BX_0: 1896 ((intel_agp_chipsets[i].gmch_chip_id == 0) ||
1773 bridge->driver = &intel_generic_driver; 1897 find_gmch(intel_agp_chipsets[i].gmch_chip_id)))
1774 name = "440BX"; 1898 break;
1775 break; 1899 }
1776 case PCI_DEVICE_ID_INTEL_82443GX_0: 1900
1777 bridge->driver = &intel_generic_driver; 1901 if (intel_agp_chipsets[i].name == NULL) {
1778 name = "440GX";
1779 break;
1780 case PCI_DEVICE_ID_INTEL_82810_MC1:
1781 name = "i810";
1782 if (!find_i810(PCI_DEVICE_ID_INTEL_82810_IG1))
1783 goto fail;
1784 bridge->driver = &intel_810_driver;
1785 break;
1786 case PCI_DEVICE_ID_INTEL_82810_MC3:
1787 name = "i810 DC100";
1788 if (!find_i810(PCI_DEVICE_ID_INTEL_82810_IG3))
1789 goto fail;
1790 bridge->driver = &intel_810_driver;
1791 break;
1792 case PCI_DEVICE_ID_INTEL_82810E_MC:
1793 name = "i810 E";
1794 if (!find_i810(PCI_DEVICE_ID_INTEL_82810E_IG))
1795 goto fail;
1796 bridge->driver = &intel_810_driver;
1797 break;
1798 case PCI_DEVICE_ID_INTEL_82815_MC:
1799 /*
1800 * The i815 can operate either as an i810 style
1801 * integrated device, or as an AGP4X motherboard.
1802 */
1803 if (find_i810(PCI_DEVICE_ID_INTEL_82815_CGC))
1804 bridge->driver = &intel_810_driver;
1805 else
1806 bridge->driver = &intel_815_driver;
1807 name = "i815";
1808 break;
1809 case PCI_DEVICE_ID_INTEL_82820_HB:
1810 case PCI_DEVICE_ID_INTEL_82820_UP_HB:
1811 bridge->driver = &intel_820_driver;
1812 name = "i820";
1813 break;
1814 case PCI_DEVICE_ID_INTEL_82830_HB:
1815 if (find_i830(PCI_DEVICE_ID_INTEL_82830_CGC))
1816 bridge->driver = &intel_830_driver;
1817 else
1818 bridge->driver = &intel_830mp_driver;
1819 name = "830M";
1820 break;
1821 case PCI_DEVICE_ID_INTEL_82840_HB:
1822 bridge->driver = &intel_840_driver;
1823 name = "i840";
1824 break;
1825 case PCI_DEVICE_ID_INTEL_82845_HB:
1826 bridge->driver = &intel_845_driver;
1827 name = "i845";
1828 break;
1829 case PCI_DEVICE_ID_INTEL_82845G_HB:
1830 if (find_i830(PCI_DEVICE_ID_INTEL_82845G_IG))
1831 bridge->driver = &intel_830_driver;
1832 else
1833 bridge->driver = &intel_845_driver;
1834 name = "845G";
1835 break;
1836 case PCI_DEVICE_ID_INTEL_82850_HB:
1837 bridge->driver = &intel_850_driver;
1838 name = "i850";
1839 break;
1840 case PCI_DEVICE_ID_INTEL_82855PM_HB:
1841 bridge->driver = &intel_845_driver;
1842 name = "855PM";
1843 break;
1844 case PCI_DEVICE_ID_INTEL_82855GM_HB:
1845 if (find_i830(PCI_DEVICE_ID_INTEL_82855GM_IG)) {
1846 bridge->driver = &intel_830_driver;
1847 name = "855";
1848 } else {
1849 bridge->driver = &intel_845_driver;
1850 name = "855GM";
1851 }
1852 break;
1853 case PCI_DEVICE_ID_INTEL_82860_HB:
1854 bridge->driver = &intel_860_driver;
1855 name = "i860";
1856 break;
1857 case PCI_DEVICE_ID_INTEL_82865_HB:
1858 if (find_i830(PCI_DEVICE_ID_INTEL_82865_IG))
1859 bridge->driver = &intel_830_driver;
1860 else
1861 bridge->driver = &intel_845_driver;
1862 name = "865";
1863 break;
1864 case PCI_DEVICE_ID_INTEL_82875_HB:
1865 bridge->driver = &intel_845_driver;
1866 name = "i875";
1867 break;
1868 case PCI_DEVICE_ID_INTEL_82915G_HB:
1869 if (find_i830(PCI_DEVICE_ID_INTEL_82915G_IG))
1870 bridge->driver = &intel_915_driver;
1871 else
1872 bridge->driver = &intel_845_driver;
1873 name = "915G";
1874 break;
1875 case PCI_DEVICE_ID_INTEL_82915GM_HB:
1876 if (find_i830(PCI_DEVICE_ID_INTEL_82915GM_IG))
1877 bridge->driver = &intel_915_driver;
1878 else
1879 bridge->driver = &intel_845_driver;
1880 name = "915GM";
1881 break;
1882 case PCI_DEVICE_ID_INTEL_82945G_HB:
1883 if (find_i830(PCI_DEVICE_ID_INTEL_82945G_IG))
1884 bridge->driver = &intel_915_driver;
1885 else
1886 bridge->driver = &intel_845_driver;
1887 name = "945G";
1888 break;
1889 case PCI_DEVICE_ID_INTEL_82945GM_HB:
1890 if (find_i830(PCI_DEVICE_ID_INTEL_82945GM_IG))
1891 bridge->driver = &intel_915_driver;
1892 else
1893 bridge->driver = &intel_845_driver;
1894 name = "945GM";
1895 break;
1896 case PCI_DEVICE_ID_INTEL_82946GZ_HB:
1897 if (find_i830(PCI_DEVICE_ID_INTEL_82946GZ_IG))
1898 bridge->driver = &intel_i965_driver;
1899 else
1900 bridge->driver = &intel_845_driver;
1901 name = "946GZ";
1902 break;
1903 case PCI_DEVICE_ID_INTEL_82965G_1_HB:
1904 if (find_i830(PCI_DEVICE_ID_INTEL_82965G_1_IG))
1905 bridge->driver = &intel_i965_driver;
1906 else
1907 bridge->driver = &intel_845_driver;
1908 name = "965G";
1909 break;
1910 case PCI_DEVICE_ID_INTEL_82965Q_HB:
1911 if (find_i830(PCI_DEVICE_ID_INTEL_82965Q_IG))
1912 bridge->driver = &intel_i965_driver;
1913 else
1914 bridge->driver = &intel_845_driver;
1915 name = "965Q";
1916 break;
1917 case PCI_DEVICE_ID_INTEL_82965G_HB:
1918 if (find_i830(PCI_DEVICE_ID_INTEL_82965G_IG))
1919 bridge->driver = &intel_i965_driver;
1920 else
1921 bridge->driver = &intel_845_driver;
1922 name = "965G";
1923 break;
1924 case PCI_DEVICE_ID_INTEL_82965GM_HB:
1925 if (find_i830(PCI_DEVICE_ID_INTEL_82965GM_IG))
1926 bridge->driver = &intel_i965_driver;
1927 else
1928 bridge->driver = &intel_845_driver;
1929 name = "965GM";
1930 break;
1931 case PCI_DEVICE_ID_INTEL_7505_0:
1932 bridge->driver = &intel_7505_driver;
1933 name = "E7505";
1934 break;
1935 case PCI_DEVICE_ID_INTEL_7205_0:
1936 bridge->driver = &intel_7505_driver;
1937 name = "E7205";
1938 break;
1939 default:
1940 if (cap_ptr) 1902 if (cap_ptr)
1941 printk(KERN_WARNING PFX "Unsupported Intel chipset (device id: %04x)\n", 1903 printk(KERN_WARNING PFX "Unsupported Intel chipset"
1942 pdev->device); 1904 "(device id: %04x)\n", pdev->device);
1943 agp_put_bridge(bridge); 1905 agp_put_bridge(bridge);
1944 return -ENODEV; 1906 return -ENODEV;
1945 }; 1907 }
1908
1909 if (intel_agp_chipsets[i].gmch_chip_id != 0)
1910 bridge->driver = intel_agp_chipsets[i].gmch_driver;
1911 else
1912 bridge->driver = intel_agp_chipsets[i].driver;
1913
1914 if (bridge->driver == NULL) {
1915 printk(KERN_WARNING PFX "Failed to find bridge device "
1916 "(chip_id: %04x)\n", intel_agp_chipsets[i].gmch_chip_id);
1917 agp_put_bridge(bridge);
1918 return -ENODEV;
1919 }
1946 1920
1947 bridge->dev = pdev; 1921 bridge->dev = pdev;
1948 bridge->capndx = cap_ptr; 1922 bridge->capndx = cap_ptr;
1923 bridge->dev_private_data = &intel_private;
1949 1924
1950 if (bridge->driver == &intel_810_driver) 1925 printk(KERN_INFO PFX "Detected an Intel %s Chipset.\n",
1951 bridge->dev_private_data = &intel_i810_private; 1926 intel_agp_chipsets[i].name);
1952 else if (bridge->driver == &intel_830_driver)
1953 bridge->dev_private_data = &intel_i830_private;
1954
1955 printk(KERN_INFO PFX "Detected an Intel %s Chipset.\n", name);
1956 1927
1957 /* 1928 /*
1958 * The following fixes the case where the BIOS has "forgotten" to 1929 * The following fixes the case where the BIOS has "forgotten" to
@@ -1988,12 +1959,6 @@ static int __devinit agp_intel_probe(struct pci_dev *pdev,
1988 1959
1989 pci_set_drvdata(pdev, bridge); 1960 pci_set_drvdata(pdev, bridge);
1990 return agp_add_bridge(bridge); 1961 return agp_add_bridge(bridge);
1991
1992fail:
1993 printk(KERN_ERR PFX "Detected an Intel %s chipset, "
1994 "but could not find the secondary device.\n", name);
1995 agp_put_bridge(bridge);
1996 return -ENODEV;
1997} 1962}
1998 1963
1999static void __devexit agp_intel_remove(struct pci_dev *pdev) 1964static void __devexit agp_intel_remove(struct pci_dev *pdev)
@@ -2002,10 +1967,8 @@ static void __devexit agp_intel_remove(struct pci_dev *pdev)
2002 1967
2003 agp_remove_bridge(bridge); 1968 agp_remove_bridge(bridge);
2004 1969
2005 if (intel_i810_private.i810_dev) 1970 if (intel_private.pcidev)
2006 pci_dev_put(intel_i810_private.i810_dev); 1971 pci_dev_put(intel_private.pcidev);
2007 if (intel_i830_private.i830_dev)
2008 pci_dev_put(intel_i830_private.i830_dev);
2009 1972
2010 agp_put_bridge(bridge); 1973 agp_put_bridge(bridge);
2011} 1974}
@@ -2021,10 +1984,8 @@ static int agp_intel_resume(struct pci_dev *pdev)
2021 * as host bridge (00:00) resumes before graphics device (02:00), 1984 * as host bridge (00:00) resumes before graphics device (02:00),
2022 * then our access to its pci space can work right. 1985 * then our access to its pci space can work right.
2023 */ 1986 */
2024 if (intel_i810_private.i810_dev) 1987 if (intel_private.pcidev)
2025 pci_restore_state(intel_i810_private.i810_dev); 1988 pci_restore_state(intel_private.pcidev);
2026 if (intel_i830_private.i830_dev)
2027 pci_restore_state(intel_i830_private.i830_dev);
2028 1989
2029 if (bridge->driver == &intel_generic_driver) 1990 if (bridge->driver == &intel_generic_driver)
2030 intel_configure(); 1991 intel_configure();
@@ -2087,6 +2048,9 @@ static struct pci_device_id agp_intel_pci_table[] = {
2087 ID(PCI_DEVICE_ID_INTEL_82965Q_HB), 2048 ID(PCI_DEVICE_ID_INTEL_82965Q_HB),
2088 ID(PCI_DEVICE_ID_INTEL_82965G_HB), 2049 ID(PCI_DEVICE_ID_INTEL_82965G_HB),
2089 ID(PCI_DEVICE_ID_INTEL_82965GM_HB), 2050 ID(PCI_DEVICE_ID_INTEL_82965GM_HB),
2051 ID(PCI_DEVICE_ID_INTEL_G33_HB),
2052 ID(PCI_DEVICE_ID_INTEL_Q35_HB),
2053 ID(PCI_DEVICE_ID_INTEL_Q33_HB),
2090 { } 2054 { }
2091}; 2055};
2092 2056
diff --git a/drivers/ide/ide-disk.c b/drivers/ide/ide-disk.c
index 7fff773f2df7..dc2175c81f5e 100644
--- a/drivers/ide/ide-disk.c
+++ b/drivers/ide/ide-disk.c
@@ -1037,6 +1037,17 @@ static void ide_disk_release(struct kref *kref)
1037 1037
1038static int ide_disk_probe(ide_drive_t *drive); 1038static int ide_disk_probe(ide_drive_t *drive);
1039 1039
1040/*
1041 * On HPA drives the capacity needs to be
1042 * reinitilized on resume otherwise the disk
1043 * can not be used and a hard reset is required
1044 */
1045static void ide_disk_resume(ide_drive_t *drive)
1046{
1047 if (idedisk_supports_hpa(drive->id))
1048 init_idedisk_capacity(drive);
1049}
1050
1040static void ide_device_shutdown(ide_drive_t *drive) 1051static void ide_device_shutdown(ide_drive_t *drive)
1041{ 1052{
1042#ifdef CONFIG_ALPHA 1053#ifdef CONFIG_ALPHA
@@ -1071,6 +1082,7 @@ static ide_driver_t idedisk_driver = {
1071 }, 1082 },
1072 .probe = ide_disk_probe, 1083 .probe = ide_disk_probe,
1073 .remove = ide_disk_remove, 1084 .remove = ide_disk_remove,
1085 .resume = ide_disk_resume,
1074 .shutdown = ide_device_shutdown, 1086 .shutdown = ide_device_shutdown,
1075 .version = IDEDISK_VERSION, 1087 .version = IDEDISK_VERSION,
1076 .media = ide_disk, 1088 .media = ide_disk,
diff --git a/drivers/ide/ide-probe.c b/drivers/ide/ide-probe.c
index 3cebed77f55d..41bfa4d21ab6 100644
--- a/drivers/ide/ide-probe.c
+++ b/drivers/ide/ide-probe.c
@@ -717,7 +717,7 @@ EXPORT_SYMBOL_GPL(ide_undecoded_slave);
717 * This routine only knows how to look for drive units 0 and 1 717 * This routine only knows how to look for drive units 0 and 1
718 * on an interface, so any setting of MAX_DRIVES > 2 won't work here. 718 * on an interface, so any setting of MAX_DRIVES > 2 won't work here.
719 */ 719 */
720static void probe_hwif(ide_hwif_t *hwif) 720static void probe_hwif(ide_hwif_t *hwif, void (*fixup)(ide_hwif_t *hwif))
721{ 721{
722 unsigned int unit; 722 unsigned int unit;
723 unsigned long flags; 723 unsigned long flags;
@@ -820,6 +820,9 @@ static void probe_hwif(ide_hwif_t *hwif)
820 return; 820 return;
821 } 821 }
822 822
823 if (fixup)
824 fixup(hwif);
825
823 for (unit = 0; unit < MAX_DRIVES; ++unit) { 826 for (unit = 0; unit < MAX_DRIVES; ++unit) {
824 ide_drive_t *drive = &hwif->drives[unit]; 827 ide_drive_t *drive = &hwif->drives[unit];
825 828
@@ -874,10 +877,7 @@ static int hwif_init(ide_hwif_t *hwif);
874 877
875int probe_hwif_init_with_fixup(ide_hwif_t *hwif, void (*fixup)(ide_hwif_t *hwif)) 878int probe_hwif_init_with_fixup(ide_hwif_t *hwif, void (*fixup)(ide_hwif_t *hwif))
876{ 879{
877 probe_hwif(hwif); 880 probe_hwif(hwif, fixup);
878
879 if (fixup)
880 fixup(hwif);
881 881
882 if (!hwif_init(hwif)) { 882 if (!hwif_init(hwif)) {
883 printk(KERN_INFO "%s: failed to initialize IDE interface\n", 883 printk(KERN_INFO "%s: failed to initialize IDE interface\n",
@@ -1404,7 +1404,7 @@ int ideprobe_init (void)
1404 1404
1405 for (index = 0; index < MAX_HWIFS; ++index) 1405 for (index = 0; index < MAX_HWIFS; ++index)
1406 if (probe[index]) 1406 if (probe[index])
1407 probe_hwif(&ide_hwifs[index]); 1407 probe_hwif(&ide_hwifs[index], NULL);
1408 for (index = 0; index < MAX_HWIFS; ++index) 1408 for (index = 0; index < MAX_HWIFS; ++index)
1409 if (probe[index]) 1409 if (probe[index])
1410 hwif_init(&ide_hwifs[index]); 1410 hwif_init(&ide_hwifs[index]);
diff --git a/drivers/ide/ide.c b/drivers/ide/ide.c
index 6002713a20a1..0af0d1614f75 100644
--- a/drivers/ide/ide.c
+++ b/drivers/ide/ide.c
@@ -1010,9 +1010,11 @@ static int generic_ide_resume(struct device *dev)
1010{ 1010{
1011 ide_drive_t *drive = dev->driver_data; 1011 ide_drive_t *drive = dev->driver_data;
1012 ide_hwif_t *hwif = HWIF(drive); 1012 ide_hwif_t *hwif = HWIF(drive);
1013 ide_driver_t *drv = to_ide_driver(dev->driver);
1013 struct request rq; 1014 struct request rq;
1014 struct request_pm_state rqpm; 1015 struct request_pm_state rqpm;
1015 ide_task_t args; 1016 ide_task_t args;
1017 int err;
1016 1018
1017 /* Call ACPI _STM only once */ 1019 /* Call ACPI _STM only once */
1018 if (!(drive->dn % 2)) 1020 if (!(drive->dn % 2))
@@ -1029,7 +1031,12 @@ static int generic_ide_resume(struct device *dev)
1029 rqpm.pm_step = ide_pm_state_start_resume; 1031 rqpm.pm_step = ide_pm_state_start_resume;
1030 rqpm.pm_state = PM_EVENT_ON; 1032 rqpm.pm_state = PM_EVENT_ON;
1031 1033
1032 return ide_do_drive_cmd(drive, &rq, ide_head_wait); 1034 err = ide_do_drive_cmd(drive, &rq, ide_head_wait);
1035
1036 if (err == 0 && drv && drv->resume)
1037 drv->resume(drive);
1038
1039 return err;
1033} 1040}
1034 1041
1035int generic_ide_ioctl(ide_drive_t *drive, struct file *file, struct block_device *bdev, 1042int generic_ide_ioctl(ide_drive_t *drive, struct file *file, struct block_device *bdev,
diff --git a/drivers/ide/pci/amd74xx.c b/drivers/ide/pci/amd74xx.c
index becb1a5648b0..9db1be826e80 100644
--- a/drivers/ide/pci/amd74xx.c
+++ b/drivers/ide/pci/amd74xx.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * Version 2.13 2 * Version 2.15
3 * 3 *
4 * AMD 755/756/766/8111 and nVidia nForce/2/2s/3/3s/CK804/MCP04 4 * AMD 755/756/766/8111 and nVidia nForce/2/2s/3/3s/CK804/MCP04
5 * IDE driver for Linux. 5 * IDE driver for Linux.
@@ -76,6 +76,8 @@ static struct amd_ide_chip {
76 { PCI_DEVICE_ID_NVIDIA_NFORCE_MCP61_IDE, 0x50, AMD_UDMA_133 }, 76 { PCI_DEVICE_ID_NVIDIA_NFORCE_MCP61_IDE, 0x50, AMD_UDMA_133 },
77 { PCI_DEVICE_ID_NVIDIA_NFORCE_MCP65_IDE, 0x50, AMD_UDMA_133 }, 77 { PCI_DEVICE_ID_NVIDIA_NFORCE_MCP65_IDE, 0x50, AMD_UDMA_133 },
78 { PCI_DEVICE_ID_NVIDIA_NFORCE_MCP67_IDE, 0x50, AMD_UDMA_133 }, 78 { PCI_DEVICE_ID_NVIDIA_NFORCE_MCP67_IDE, 0x50, AMD_UDMA_133 },
79 { PCI_DEVICE_ID_NVIDIA_NFORCE_MCP73_IDE, 0x50, AMD_UDMA_133 },
80 { PCI_DEVICE_ID_NVIDIA_NFORCE_MCP77_IDE, 0x50, AMD_UDMA_133 },
79 { PCI_DEVICE_ID_AMD_CS5536_IDE, 0x40, AMD_UDMA_100 }, 81 { PCI_DEVICE_ID_AMD_CS5536_IDE, 0x40, AMD_UDMA_100 },
80 { 0 } 82 { 0 }
81}; 83};
@@ -494,7 +496,9 @@ static ide_pci_device_t amd74xx_chipsets[] __devinitdata = {
494 /* 17 */ DECLARE_NV_DEV("NFORCE-MCP61"), 496 /* 17 */ DECLARE_NV_DEV("NFORCE-MCP61"),
495 /* 18 */ DECLARE_NV_DEV("NFORCE-MCP65"), 497 /* 18 */ DECLARE_NV_DEV("NFORCE-MCP65"),
496 /* 19 */ DECLARE_NV_DEV("NFORCE-MCP67"), 498 /* 19 */ DECLARE_NV_DEV("NFORCE-MCP67"),
497 /* 20 */ DECLARE_AMD_DEV("AMD5536"), 499 /* 20 */ DECLARE_NV_DEV("NFORCE-MCP73"),
500 /* 21 */ DECLARE_NV_DEV("NFORCE-MCP77"),
501 /* 22 */ DECLARE_AMD_DEV("AMD5536"),
498}; 502};
499 503
500static int __devinit amd74xx_probe(struct pci_dev *dev, const struct pci_device_id *id) 504static int __devinit amd74xx_probe(struct pci_dev *dev, const struct pci_device_id *id)
@@ -534,7 +538,9 @@ static struct pci_device_id amd74xx_pci_tbl[] = {
534 { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP61_IDE, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 17 }, 538 { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP61_IDE, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 17 },
535 { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP65_IDE, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 18 }, 539 { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP65_IDE, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 18 },
536 { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP67_IDE, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 19 }, 540 { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP67_IDE, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 19 },
537 { PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_CS5536_IDE, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 20 }, 541 { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP73_IDE, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 20 },
542 { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP77_IDE, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 21 },
543 { PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_CS5536_IDE, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 22 },
538 { 0, }, 544 { 0, },
539}; 545};
540MODULE_DEVICE_TABLE(pci, amd74xx_pci_tbl); 546MODULE_DEVICE_TABLE(pci, amd74xx_pci_tbl);
diff --git a/drivers/ide/pci/generic.c b/drivers/ide/pci/generic.c
index f2c5a141ca10..0d51a11e81da 100644
--- a/drivers/ide/pci/generic.c
+++ b/drivers/ide/pci/generic.c
@@ -198,32 +198,41 @@ static ide_pci_device_t generic_chipsets[] __devinitdata = {
198static int __devinit generic_init_one(struct pci_dev *dev, const struct pci_device_id *id) 198static int __devinit generic_init_one(struct pci_dev *dev, const struct pci_device_id *id)
199{ 199{
200 ide_pci_device_t *d = &generic_chipsets[id->driver_data]; 200 ide_pci_device_t *d = &generic_chipsets[id->driver_data];
201 u16 command;
202 int ret = -ENODEV; 201 int ret = -ENODEV;
203 202
204 /* Don't use the generic entry unless instructed to do so */ 203 /* Don't use the generic entry unless instructed to do so */
205 if (id->driver_data == 0 && ide_generic_all == 0) 204 if (id->driver_data == 0 && ide_generic_all == 0)
206 goto out; 205 goto out;
207 206
208 if (dev->vendor == PCI_VENDOR_ID_UMC && 207 switch (dev->vendor) {
209 dev->device == PCI_DEVICE_ID_UMC_UM8886A && 208 case PCI_VENDOR_ID_UMC:
210 (!(PCI_FUNC(dev->devfn) & 1))) 209 if (dev->device == PCI_DEVICE_ID_UMC_UM8886A &&
211 goto out; /* UM8886A/BF pair */ 210 !(PCI_FUNC(dev->devfn) & 1))
212 211 goto out; /* UM8886A/BF pair */
213 if (dev->vendor == PCI_VENDOR_ID_OPTI && 212 break;
214 dev->device == PCI_DEVICE_ID_OPTI_82C558 && 213 case PCI_VENDOR_ID_OPTI:
215 (!(PCI_FUNC(dev->devfn) & 1))) 214 if (dev->device == PCI_DEVICE_ID_OPTI_82C558 &&
216 goto out; 215 !(PCI_FUNC(dev->devfn) & 1))
217 216 goto out;
218 if (dev->vendor == PCI_VENDOR_ID_JMICRON) { 217 break;
219 if (dev->device != PCI_DEVICE_ID_JMICRON_JMB368 && PCI_FUNC(dev->devfn) != 1) 218 case PCI_VENDOR_ID_JMICRON:
219 if (dev->device != PCI_DEVICE_ID_JMICRON_JMB368 &&
220 PCI_FUNC(dev->devfn) != 1)
221 goto out;
222 break;
223 case PCI_VENDOR_ID_NS:
224 if (dev->device == PCI_DEVICE_ID_NS_87410 &&
225 (dev->class >> 8) != PCI_CLASS_STORAGE_IDE)
220 goto out; 226 goto out;
227 break;
221 } 228 }
222 229
223 if (dev->vendor != PCI_VENDOR_ID_JMICRON) { 230 if (dev->vendor != PCI_VENDOR_ID_JMICRON) {
231 u16 command;
224 pci_read_config_word(dev, PCI_COMMAND, &command); 232 pci_read_config_word(dev, PCI_COMMAND, &command);
225 if (!(command & PCI_COMMAND_IO)) { 233 if (!(command & PCI_COMMAND_IO)) {
226 printk(KERN_INFO "Skipping disabled %s IDE controller.\n", d->name); 234 printk(KERN_INFO "Skipping disabled %s IDE "
235 "controller.\n", d->name);
227 goto out; 236 goto out;
228 } 237 }
229 } 238 }
diff --git a/drivers/ide/pci/hpt366.c b/drivers/ide/pci/hpt366.c
index fcbc5605b38e..ce8a5449a574 100644
--- a/drivers/ide/pci/hpt366.c
+++ b/drivers/ide/pci/hpt366.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * linux/drivers/ide/pci/hpt366.c Version 1.03 May 4, 2007 2 * linux/drivers/ide/pci/hpt366.c Version 1.04 Jun 4, 2007
3 * 3 *
4 * Copyright (C) 1999-2003 Andre Hedrick <andre@linux-ide.org> 4 * Copyright (C) 1999-2003 Andre Hedrick <andre@linux-ide.org>
5 * Portions Copyright (C) 2001 Sun Microsystems, Inc. 5 * Portions Copyright (C) 2001 Sun Microsystems, Inc.
@@ -106,7 +106,8 @@
106 * switch to calculating PCI clock frequency based on the chip's base DPLL 106 * switch to calculating PCI clock frequency based on the chip's base DPLL
107 * frequency 107 * frequency
108 * - switch to using the DPLL clock and enable UltraATA/133 mode by default on 108 * - switch to using the DPLL clock and enable UltraATA/133 mode by default on
109 * anything newer than HPT370/A 109 * anything newer than HPT370/A (except HPT374 that is not capable of this
110 * mode according to the manual)
110 * - fold PCI clock detection and DPLL setup code into init_chipset_hpt366(), 111 * - fold PCI clock detection and DPLL setup code into init_chipset_hpt366(),
111 * also fixing the interchanged 25/40 MHz PCI clock cases for HPT36x chips; 112 * also fixing the interchanged 25/40 MHz PCI clock cases for HPT36x chips;
112 * unify HPT36x/37x timing setup code and the speedproc handlers by joining 113 * unify HPT36x/37x timing setup code and the speedproc handlers by joining
@@ -365,7 +366,6 @@ static u32 sixty_six_base_hpt37x[] = {
365}; 366};
366 367
367#define HPT366_DEBUG_DRIVE_INFO 0 368#define HPT366_DEBUG_DRIVE_INFO 0
368#define HPT374_ALLOW_ATA133_6 1
369#define HPT371_ALLOW_ATA133_6 1 369#define HPT371_ALLOW_ATA133_6 1
370#define HPT302_ALLOW_ATA133_6 1 370#define HPT302_ALLOW_ATA133_6 1
371#define HPT372_ALLOW_ATA133_6 1 371#define HPT372_ALLOW_ATA133_6 1
@@ -450,7 +450,7 @@ static struct hpt_info hpt370a __devinitdata = {
450 450
451static struct hpt_info hpt374 __devinitdata = { 451static struct hpt_info hpt374 __devinitdata = {
452 .chip_type = HPT374, 452 .chip_type = HPT374,
453 .max_mode = HPT374_ALLOW_ATA133_6 ? 4 : 3, 453 .max_mode = 3,
454 .dpll_clk = 48, 454 .dpll_clk = 48,
455 .settings = hpt37x_settings 455 .settings = hpt37x_settings
456}; 456};
diff --git a/drivers/ide/pci/it821x.c b/drivers/ide/pci/it821x.c
index 5faaff87d580..4bd4bf02e917 100644
--- a/drivers/ide/pci/it821x.c
+++ b/drivers/ide/pci/it821x.c
@@ -1,6 +1,6 @@
1 1
2/* 2/*
3 * linux/drivers/ide/pci/it821x.c Version 0.10 Mar 10 2007 3 * linux/drivers/ide/pci/it821x.c Version 0.15 Jun 2 2007
4 * 4 *
5 * Copyright (C) 2004 Red Hat <alan@redhat.com> 5 * Copyright (C) 2004 Red Hat <alan@redhat.com>
6 * Copyright (C) 2007 Bartlomiej Zolnierkiewicz 6 * Copyright (C) 2007 Bartlomiej Zolnierkiewicz
@@ -262,7 +262,7 @@ static int it821x_tunepio(ide_drive_t *drive, u8 set_pio)
262 } 262 }
263 263
264 if (itdev->smart) 264 if (itdev->smart)
265 goto set_drive_speed; 265 return 0;
266 266
267 /* We prefer 66Mhz clock for PIO 0-3, don't care for PIO4 */ 267 /* We prefer 66Mhz clock for PIO 0-3, don't care for PIO4 */
268 itdev->want[unit][1] = pio_want[set_pio]; 268 itdev->want[unit][1] = pio_want[set_pio];
@@ -271,7 +271,6 @@ static int it821x_tunepio(ide_drive_t *drive, u8 set_pio)
271 it821x_clock_strategy(drive); 271 it821x_clock_strategy(drive);
272 it821x_program(drive, itdev->pio[unit]); 272 it821x_program(drive, itdev->pio[unit]);
273 273
274set_drive_speed:
275 return ide_config_drive_speed(drive, XFER_PIO_0 + set_pio); 274 return ide_config_drive_speed(drive, XFER_PIO_0 + set_pio);
276} 275}
277 276
@@ -455,12 +454,12 @@ static int it821x_tune_chipset (ide_drive_t *drive, byte xferspeed)
455 default: 454 default:
456 return 1; 455 return 1;
457 } 456 }
457
458 return ide_config_drive_speed(drive, speed);
458 } 459 }
459 /* 460
460 * In smart mode the clocking is done by the host controller 461 /* don't touch anything in the smart mode */
461 * snooping the mode we picked. The rest of it is not our problem 462 return 0;
462 */
463 return ide_config_drive_speed(drive, speed);
464} 463}
465 464
466/** 465/**
@@ -559,17 +558,10 @@ static void __devinit it821x_fixups(ide_hwif_t *hwif)
559 if(idbits[129] != 1) 558 if(idbits[129] != 1)
560 printk("(%dK stripe)", idbits[146]); 559 printk("(%dK stripe)", idbits[146]);
561 printk(".\n"); 560 printk(".\n");
562 /* Now the core code will have wrongly decided no DMA
563 so we need to fix this */
564 hwif->dma_off_quietly(drive);
565#ifdef CONFIG_IDEDMA_ONLYDISK
566 if (drive->media == ide_disk)
567#endif
568 ide_set_dma(drive);
569 } else { 561 } else {
570 /* Non RAID volume. Fixups to stop the core code 562 /* Non RAID volume. Fixups to stop the core code
571 doing unsupported things */ 563 doing unsupported things */
572 id->field_valid &= 1; 564 id->field_valid &= 3;
573 id->queue_depth = 0; 565 id->queue_depth = 0;
574 id->command_set_1 = 0; 566 id->command_set_1 = 0;
575 id->command_set_2 &= 0xC400; 567 id->command_set_2 &= 0xC400;
@@ -584,6 +576,16 @@ static void __devinit it821x_fixups(ide_hwif_t *hwif)
584 printk(KERN_INFO "%s: Performing identify fixups.\n", 576 printk(KERN_INFO "%s: Performing identify fixups.\n",
585 drive->name); 577 drive->name);
586 } 578 }
579
580 /*
581 * Set MWDMA0 mode as enabled/support - just to tell
582 * IDE core that DMA is supported (it821x hardware
583 * takes care of DMA mode programming).
584 */
585 if (id->capability & 1) {
586 id->dma_mword |= 0x0101;
587 drive->current_speed = XFER_MW_DMA_0;
588 }
587 } 589 }
588 590
589} 591}
diff --git a/drivers/ide/pci/serverworks.c b/drivers/ide/pci/serverworks.c
index 47bcd91c9b5f..d9c4fd1ae996 100644
--- a/drivers/ide/pci/serverworks.c
+++ b/drivers/ide/pci/serverworks.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * linux/drivers/ide/pci/serverworks.c Version 0.9 Mar 4 2007 2 * linux/drivers/ide/pci/serverworks.c Version 0.11 Jun 2 2007
3 * 3 *
4 * Copyright (C) 1998-2000 Michel Aubry 4 * Copyright (C) 1998-2000 Michel Aubry
5 * Copyright (C) 1998-2000 Andrzej Krzysztofowicz 5 * Copyright (C) 1998-2000 Andrzej Krzysztofowicz
@@ -170,42 +170,55 @@ static int svwks_tune_chipset (ide_drive_t *drive, u8 xferspeed)
170 if (!drive->init_speed) { 170 if (!drive->init_speed) {
171 u8 dma_stat = inb(hwif->dma_status); 171 u8 dma_stat = inb(hwif->dma_status);
172 172
173dma_pio:
174 if (((ultra_enable << (7-drive->dn) & 0x80) == 0x80) && 173 if (((ultra_enable << (7-drive->dn) & 0x80) == 0x80) &&
175 ((dma_stat & (1<<(5+unit))) == (1<<(5+unit)))) { 174 ((dma_stat & (1<<(5+unit))) == (1<<(5+unit)))) {
176 drive->current_speed = drive->init_speed = XFER_UDMA_0 + udma_modes[(ultra_timing >> (4*unit)) & ~(0xF0)]; 175 drive->current_speed = drive->init_speed = XFER_UDMA_0 + udma_modes[(ultra_timing >> (4*unit)) & ~(0xF0)];
177 return 0; 176 return 0;
178 } else if ((dma_timing) && 177 } else if ((dma_timing) &&
179 ((dma_stat&(1<<(5+unit)))==(1<<(5+unit)))) { 178 ((dma_stat&(1<<(5+unit)))==(1<<(5+unit)))) {
180 u8 dmaspeed = dma_timing; 179 u8 dmaspeed;
181 180
182 dma_timing &= ~0xFFU; 181 switch (dma_timing & 0x77) {
183 if ((dmaspeed & 0x20) == 0x20) 182 case 0x20:
184 dmaspeed = XFER_MW_DMA_2; 183 dmaspeed = XFER_MW_DMA_2;
185 else if ((dmaspeed & 0x21) == 0x21) 184 break;
185 case 0x21:
186 dmaspeed = XFER_MW_DMA_1; 186 dmaspeed = XFER_MW_DMA_1;
187 else if ((dmaspeed & 0x77) == 0x77) 187 break;
188 case 0x77:
188 dmaspeed = XFER_MW_DMA_0; 189 dmaspeed = XFER_MW_DMA_0;
189 else 190 break;
191 default:
190 goto dma_pio; 192 goto dma_pio;
193 }
194
191 drive->current_speed = drive->init_speed = dmaspeed; 195 drive->current_speed = drive->init_speed = dmaspeed;
192 return 0; 196 return 0;
193 } else if (pio_timing) { 197 }
194 u8 piospeed = pio_timing; 198dma_pio:
199 if (pio_timing) {
200 u8 piospeed;
195 201
196 pio_timing &= ~0xFFU; 202 switch (pio_timing & 0x7f) {
197 if ((piospeed & 0x20) == 0x20) 203 case 0x20:
198 piospeed = XFER_PIO_4; 204 piospeed = XFER_PIO_4;
199 else if ((piospeed & 0x22) == 0x22) 205 break;
206 case 0x22:
200 piospeed = XFER_PIO_3; 207 piospeed = XFER_PIO_3;
201 else if ((piospeed & 0x34) == 0x34) 208 break;
209 case 0x34:
202 piospeed = XFER_PIO_2; 210 piospeed = XFER_PIO_2;
203 else if ((piospeed & 0x47) == 0x47) 211 break;
212 case 0x47:
204 piospeed = XFER_PIO_1; 213 piospeed = XFER_PIO_1;
205 else if ((piospeed & 0x5d) == 0x5d) 214 break;
215 case 0x5d:
206 piospeed = XFER_PIO_0; 216 piospeed = XFER_PIO_0;
207 else 217 break;
218 default:
208 goto oem_setup_failed; 219 goto oem_setup_failed;
220 }
221
209 drive->current_speed = drive->init_speed = piospeed; 222 drive->current_speed = drive->init_speed = piospeed;
210 return 0; 223 return 0;
211 } 224 }
@@ -214,8 +227,8 @@ dma_pio:
214 227
215oem_setup_failed: 228oem_setup_failed:
216 229
217 pio_timing &= ~0xFFU; 230 pio_timing = 0;
218 dma_timing &= ~0xFFU; 231 dma_timing = 0;
219 ultra_timing &= ~(0x0F << (4*unit)); 232 ultra_timing &= ~(0x0F << (4*unit));
220 ultra_enable &= ~(0x01 << drive->dn); 233 ultra_enable &= ~(0x01 << drive->dn);
221 csb5_pio &= ~(0x0F << (4*drive->dn)); 234 csb5_pio &= ~(0x0F << (4*drive->dn));
diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c
index 2eb52b7a71da..32a0e66d2a23 100644
--- a/drivers/infiniband/core/cma.c
+++ b/drivers/infiniband/core/cma.c
@@ -2773,8 +2773,8 @@ static int cma_init(void)
2773 int ret; 2773 int ret;
2774 2774
2775 get_random_bytes(&next_port, sizeof next_port); 2775 get_random_bytes(&next_port, sizeof next_port);
2776 next_port = (next_port % (sysctl_local_port_range[1] - 2776 next_port = ((unsigned int) next_port %
2777 sysctl_local_port_range[0])) + 2777 (sysctl_local_port_range[1] - sysctl_local_port_range[0])) +
2778 sysctl_local_port_range[0]; 2778 sysctl_local_port_range[0];
2779 cma_wq = create_singlethread_workqueue("rdma_cm"); 2779 cma_wq = create_singlethread_workqueue("rdma_cm");
2780 if (!cma_wq) 2780 if (!cma_wq)
diff --git a/drivers/infiniband/hw/mlx4/qp.c b/drivers/infiniband/hw/mlx4/qp.c
index dc137dec2308..5c6d05427a0f 100644
--- a/drivers/infiniband/hw/mlx4/qp.c
+++ b/drivers/infiniband/hw/mlx4/qp.c
@@ -189,18 +189,28 @@ static int send_wqe_overhead(enum ib_qp_type type)
189} 189}
190 190
191static int set_rq_size(struct mlx4_ib_dev *dev, struct ib_qp_cap *cap, 191static int set_rq_size(struct mlx4_ib_dev *dev, struct ib_qp_cap *cap,
192 struct mlx4_ib_qp *qp) 192 int is_user, int has_srq, struct mlx4_ib_qp *qp)
193{ 193{
194 /* Sanity check RQ size before proceeding */ 194 /* Sanity check RQ size before proceeding */
195 if (cap->max_recv_wr > dev->dev->caps.max_wqes || 195 if (cap->max_recv_wr > dev->dev->caps.max_wqes ||
196 cap->max_recv_sge > dev->dev->caps.max_rq_sg) 196 cap->max_recv_sge > dev->dev->caps.max_rq_sg)
197 return -EINVAL; 197 return -EINVAL;
198 198
199 qp->rq.max = cap->max_recv_wr ? roundup_pow_of_two(cap->max_recv_wr) : 0; 199 if (has_srq) {
200 /* QPs attached to an SRQ should have no RQ */
201 if (cap->max_recv_wr)
202 return -EINVAL;
203
204 qp->rq.max = qp->rq.max_gs = 0;
205 } else {
206 /* HW requires >= 1 RQ entry with >= 1 gather entry */
207 if (is_user && (!cap->max_recv_wr || !cap->max_recv_sge))
208 return -EINVAL;
200 209
201 qp->rq.wqe_shift = ilog2(roundup_pow_of_two(cap->max_recv_sge * 210 qp->rq.max = roundup_pow_of_two(max(1, cap->max_recv_wr));
202 sizeof (struct mlx4_wqe_data_seg))); 211 qp->rq.max_gs = roundup_pow_of_two(max(1, cap->max_recv_sge));
203 qp->rq.max_gs = (1 << qp->rq.wqe_shift) / sizeof (struct mlx4_wqe_data_seg); 212 qp->rq.wqe_shift = ilog2(qp->rq.max_gs * sizeof (struct mlx4_wqe_data_seg));
213 }
204 214
205 cap->max_recv_wr = qp->rq.max; 215 cap->max_recv_wr = qp->rq.max;
206 cap->max_recv_sge = qp->rq.max_gs; 216 cap->max_recv_sge = qp->rq.max_gs;
@@ -285,7 +295,7 @@ static int create_qp_common(struct mlx4_ib_dev *dev, struct ib_pd *pd,
285 qp->sq.head = 0; 295 qp->sq.head = 0;
286 qp->sq.tail = 0; 296 qp->sq.tail = 0;
287 297
288 err = set_rq_size(dev, &init_attr->cap, qp); 298 err = set_rq_size(dev, &init_attr->cap, !!pd->uobject, !!init_attr->srq, qp);
289 if (err) 299 if (err)
290 goto err; 300 goto err;
291 301
@@ -762,11 +772,6 @@ static int __mlx4_ib_modify_qp(struct ib_qp *ibqp,
762 optpar |= MLX4_QP_OPTPAR_PKEY_INDEX; 772 optpar |= MLX4_QP_OPTPAR_PKEY_INDEX;
763 } 773 }
764 774
765 if (attr_mask & IB_QP_RNR_RETRY) {
766 context->params1 |= cpu_to_be32(attr->rnr_retry << 13);
767 optpar |= MLX4_QP_OPTPAR_RNR_RETRY;
768 }
769
770 if (attr_mask & IB_QP_AV) { 775 if (attr_mask & IB_QP_AV) {
771 if (mlx4_set_path(dev, &attr->ah_attr, &context->pri_path, 776 if (mlx4_set_path(dev, &attr->ah_attr, &context->pri_path,
772 attr_mask & IB_QP_PORT ? attr->port_num : qp->port)) { 777 attr_mask & IB_QP_PORT ? attr->port_num : qp->port)) {
@@ -802,6 +807,12 @@ static int __mlx4_ib_modify_qp(struct ib_qp *ibqp,
802 807
803 context->pd = cpu_to_be32(to_mpd(ibqp->pd)->pdn); 808 context->pd = cpu_to_be32(to_mpd(ibqp->pd)->pdn);
804 context->params1 = cpu_to_be32(MLX4_IB_ACK_REQ_FREQ << 28); 809 context->params1 = cpu_to_be32(MLX4_IB_ACK_REQ_FREQ << 28);
810
811 if (attr_mask & IB_QP_RNR_RETRY) {
812 context->params1 |= cpu_to_be32(attr->rnr_retry << 13);
813 optpar |= MLX4_QP_OPTPAR_RNR_RETRY;
814 }
815
805 if (attr_mask & IB_QP_RETRY_CNT) { 816 if (attr_mask & IB_QP_RETRY_CNT) {
806 context->params1 |= cpu_to_be32(attr->retry_cnt << 16); 817 context->params1 |= cpu_to_be32(attr->retry_cnt << 16);
807 optpar |= MLX4_QP_OPTPAR_RETRY_COUNT; 818 optpar |= MLX4_QP_OPTPAR_RETRY_COUNT;
diff --git a/drivers/infiniband/hw/mthca/mthca_cmd.c b/drivers/infiniband/hw/mthca/mthca_cmd.c
index 38102520ffb3..f40558d76475 100644
--- a/drivers/infiniband/hw/mthca/mthca_cmd.c
+++ b/drivers/infiniband/hw/mthca/mthca_cmd.c
@@ -772,7 +772,7 @@ int mthca_QUERY_FW(struct mthca_dev *dev, u8 *status)
772 772
773 MTHCA_GET(dev->fw_ver, outbox, QUERY_FW_VER_OFFSET); 773 MTHCA_GET(dev->fw_ver, outbox, QUERY_FW_VER_OFFSET);
774 /* 774 /*
775 * FW subminor version is at more signifant bits than minor 775 * FW subminor version is at more significant bits than minor
776 * version, so swap here. 776 * version, so swap here.
777 */ 777 */
778 dev->fw_ver = (dev->fw_ver & 0xffff00000000ull) | 778 dev->fw_ver = (dev->fw_ver & 0xffff00000000ull) |
diff --git a/drivers/media/common/Kconfig b/drivers/media/common/Kconfig
index c120114c241b..5c63c8e24ee7 100644
--- a/drivers/media/common/Kconfig
+++ b/drivers/media/common/Kconfig
@@ -4,5 +4,6 @@ config VIDEO_SAA7146
4 4
5config VIDEO_SAA7146_VV 5config VIDEO_SAA7146_VV
6 tristate 6 tristate
7 depends on VIDEO_DEV
7 select VIDEO_BUF 8 select VIDEO_BUF
8 select VIDEO_SAA7146 9 select VIDEO_SAA7146
diff --git a/drivers/media/dvb/b2c2/Makefile b/drivers/media/dvb/b2c2/Makefile
index 1a1c3bca55fa..bff00b58bf65 100644
--- a/drivers/media/dvb/b2c2/Makefile
+++ b/drivers/media/dvb/b2c2/Makefile
@@ -1,8 +1,11 @@
1b2c2-flexcop-objs = flexcop.o flexcop-fe-tuner.o flexcop-i2c.o \ 1b2c2-flexcop-objs = flexcop.o flexcop-fe-tuner.o flexcop-i2c.o \
2 flexcop-sram.o flexcop-eeprom.o flexcop-misc.o flexcop-hw-filter.o \ 2 flexcop-sram.o flexcop-eeprom.o flexcop-misc.o flexcop-hw-filter.o
3 flexcop-dma.o
4obj-$(CONFIG_DVB_B2C2_FLEXCOP) += b2c2-flexcop.o 3obj-$(CONFIG_DVB_B2C2_FLEXCOP) += b2c2-flexcop.o
5 4
5ifneq ($(CONFIG_DVB_B2C2_FLEXCOP_PCI),)
6b2c2-flexcop-objs += flexcop-dma.o
7endif
8
6b2c2-flexcop-pci-objs = flexcop-pci.o 9b2c2-flexcop-pci-objs = flexcop-pci.o
7obj-$(CONFIG_DVB_B2C2_FLEXCOP_PCI) += b2c2-flexcop-pci.o 10obj-$(CONFIG_DVB_B2C2_FLEXCOP_PCI) += b2c2-flexcop-pci.o
8 11
diff --git a/drivers/media/dvb/cinergyT2/cinergyT2.c b/drivers/media/dvb/cinergyT2/cinergyT2.c
index 34d7abc900d7..6aba5b39ed14 100644
--- a/drivers/media/dvb/cinergyT2/cinergyT2.c
+++ b/drivers/media/dvb/cinergyT2/cinergyT2.c
@@ -519,8 +519,7 @@ static int cinergyt2_release (struct inode *inode, struct file *file)
519 struct dvb_device *dvbdev = file->private_data; 519 struct dvb_device *dvbdev = file->private_data;
520 struct cinergyt2 *cinergyt2 = dvbdev->priv; 520 struct cinergyt2 *cinergyt2 = dvbdev->priv;
521 521
522 if (mutex_lock_interruptible(&cinergyt2->sem)) 522 mutex_lock(&cinergyt2->sem);
523 return -ERESTARTSYS;
524 523
525 if (!cinergyt2->disconnect_pending && (file->f_flags & O_ACCMODE) != O_RDONLY) { 524 if (!cinergyt2->disconnect_pending && (file->f_flags & O_ACCMODE) != O_RDONLY) {
526 cancel_delayed_work(&cinergyt2->query_work); 525 cancel_delayed_work(&cinergyt2->query_work);
diff --git a/drivers/media/dvb/frontends/tda10086.c b/drivers/media/dvb/frontends/tda10086.c
index ccc429cbbad0..0f2d4b415560 100644
--- a/drivers/media/dvb/frontends/tda10086.c
+++ b/drivers/media/dvb/frontends/tda10086.c
@@ -41,6 +41,7 @@ struct tda10086_state {
41 /* private demod data */ 41 /* private demod data */
42 u32 frequency; 42 u32 frequency;
43 u32 symbol_rate; 43 u32 symbol_rate;
44 bool has_lock;
44}; 45};
45 46
46static int debug = 0; 47static int debug = 0;
@@ -116,7 +117,7 @@ static int tda10086_init(struct dvb_frontend* fe)
116 // misc setup 117 // misc setup
117 tda10086_write_byte(state, 0x01, 0x94); 118 tda10086_write_byte(state, 0x01, 0x94);
118 tda10086_write_byte(state, 0x02, 0x35); // NOTE: TT drivers appear to disable CSWP 119 tda10086_write_byte(state, 0x02, 0x35); // NOTE: TT drivers appear to disable CSWP
119 tda10086_write_byte(state, 0x03, 0x64); 120 tda10086_write_byte(state, 0x03, 0xe4);
120 tda10086_write_byte(state, 0x04, 0x43); 121 tda10086_write_byte(state, 0x04, 0x43);
121 tda10086_write_byte(state, 0x0c, 0x0c); 122 tda10086_write_byte(state, 0x0c, 0x0c);
122 tda10086_write_byte(state, 0x1b, 0xb0); // noise threshold 123 tda10086_write_byte(state, 0x1b, 0xb0); // noise threshold
@@ -146,7 +147,7 @@ static int tda10086_init(struct dvb_frontend* fe)
146 // setup AGC 147 // setup AGC
147 tda10086_write_byte(state, 0x05, 0x0B); 148 tda10086_write_byte(state, 0x05, 0x0B);
148 tda10086_write_byte(state, 0x37, 0x63); 149 tda10086_write_byte(state, 0x37, 0x63);
149 tda10086_write_byte(state, 0x3f, 0x03); // NOTE: flydvb uses 0x0a and varies it 150 tda10086_write_byte(state, 0x3f, 0x0a); // NOTE: flydvb varies it
150 tda10086_write_byte(state, 0x40, 0x64); 151 tda10086_write_byte(state, 0x40, 0x64);
151 tda10086_write_byte(state, 0x41, 0x4f); 152 tda10086_write_byte(state, 0x41, 0x4f);
152 tda10086_write_byte(state, 0x42, 0x43); 153 tda10086_write_byte(state, 0x42, 0x43);
@@ -398,6 +399,10 @@ static int tda10086_set_frontend(struct dvb_frontend* fe,
398 399
399 dprintk ("%s\n", __FUNCTION__); 400 dprintk ("%s\n", __FUNCTION__);
400 401
402 // modify parameters for tuning
403 tda10086_write_byte(state, 0x02, 0x35);
404 state->has_lock = false;
405
401 // set params 406 // set params
402 if (fe->ops.tuner_ops.set_params) { 407 if (fe->ops.tuner_ops.set_params) {
403 fe->ops.tuner_ops.set_params(fe, fe_params); 408 fe->ops.tuner_ops.set_params(fe, fe_params);
@@ -542,8 +547,14 @@ static int tda10086_read_status(struct dvb_frontend* fe, fe_status_t *fe_status)
542 *fe_status |= FE_HAS_VITERBI; 547 *fe_status |= FE_HAS_VITERBI;
543 if (val & 0x08) 548 if (val & 0x08)
544 *fe_status |= FE_HAS_SYNC; 549 *fe_status |= FE_HAS_SYNC;
545 if (val & 0x10) 550 if (val & 0x10) {
546 *fe_status |= FE_HAS_LOCK; 551 *fe_status |= FE_HAS_LOCK;
552 if (!state->has_lock) {
553 state->has_lock = true;
554 // modify parameters for stable reception
555 tda10086_write_byte(state, 0x02, 0x00);
556 }
557 }
547 558
548 return 0; 559 return 0;
549} 560}
@@ -555,7 +566,7 @@ static int tda10086_read_signal_strength(struct dvb_frontend* fe, u16 * signal)
555 566
556 dprintk ("%s\n", __FUNCTION__); 567 dprintk ("%s\n", __FUNCTION__);
557 568
558 _str = tda10086_read_byte(state, 0x43); 569 _str = 0xff - tda10086_read_byte(state, 0x43);
559 *signal = (_str << 8) | _str; 570 *signal = (_str << 8) | _str;
560 571
561 return 0; 572 return 0;
@@ -568,7 +579,7 @@ static int tda10086_read_snr(struct dvb_frontend* fe, u16 * snr)
568 579
569 dprintk ("%s\n", __FUNCTION__); 580 dprintk ("%s\n", __FUNCTION__);
570 581
571 _snr = tda10086_read_byte(state, 0x1c); 582 _snr = 0xff - tda10086_read_byte(state, 0x1c);
572 *snr = (_snr << 8) | _snr; 583 *snr = (_snr << 8) | _snr;
573 584
574 return 0; 585 return 0;
diff --git a/drivers/media/dvb/frontends/tda826x.c b/drivers/media/dvb/frontends/tda826x.c
index 79f971dc52b6..bd3ebc284835 100644
--- a/drivers/media/dvb/frontends/tda826x.c
+++ b/drivers/media/dvb/frontends/tda826x.c
@@ -89,8 +89,8 @@ static int tda826x_set_params(struct dvb_frontend *fe, struct dvb_frontend_param
89 buf[2] = (1<<5) | 0x0b; // 1Mhz + 0.45 VCO 89 buf[2] = (1<<5) | 0x0b; // 1Mhz + 0.45 VCO
90 buf[3] = div >> 7; 90 buf[3] = div >> 7;
91 buf[4] = div << 1; 91 buf[4] = div << 1;
92 buf[5] = 0xff; // basedband filter to max 92 buf[5] = 0x77; // baseband cut-off 19 MHz
93 buf[6] = 0xfe; // gains at max + no RF attenuation 93 buf[6] = 0xfe; // baseband gain 9 db + no RF attenuation
94 buf[7] = 0x83; // charge pumps at high, tests off 94 buf[7] = 0x83; // charge pumps at high, tests off
95 buf[8] = 0x80; // recommended value 4 for AMPVCO + disable ports. 95 buf[8] = 0x80; // recommended value 4 for AMPVCO + disable ports.
96 buf[9] = 0x1a; // normal caltime + recommended values for SELTH + SELVTL 96 buf[9] = 0x1a; // normal caltime + recommended values for SELTH + SELVTL
diff --git a/drivers/media/video/Kconfig b/drivers/media/video/Kconfig
index 5cb3f54b548b..4cca55170e21 100644
--- a/drivers/media/video/Kconfig
+++ b/drivers/media/video/Kconfig
@@ -347,7 +347,7 @@ endmenu # encoder / decoder chips
347 347
348config VIDEO_VIVI 348config VIDEO_VIVI
349 tristate "Virtual Video Driver" 349 tristate "Virtual Video Driver"
350 depends on VIDEO_V4L2 && !SPARC32 && !SPARC64 && PCI 350 depends on VIDEO_V4L2 && !SPARC32 && !SPARC64 && PCI && VIDEO_DEV
351 select VIDEO_BUF 351 select VIDEO_BUF
352 default n 352 default n
353 ---help--- 353 ---help---
diff --git a/drivers/media/video/ivtv/ivtv-cards.h b/drivers/media/video/ivtv/ivtv-cards.h
index 15012f88b802..91e9e90c14a5 100644
--- a/drivers/media/video/ivtv/ivtv-cards.h
+++ b/drivers/media/video/ivtv/ivtv-cards.h
@@ -86,7 +86,7 @@
86 V4L2_CAP_AUDIO | V4L2_CAP_READWRITE | V4L2_CAP_VBI_CAPTURE | \ 86 V4L2_CAP_AUDIO | V4L2_CAP_READWRITE | V4L2_CAP_VBI_CAPTURE | \
87 V4L2_CAP_SLICED_VBI_CAPTURE) 87 V4L2_CAP_SLICED_VBI_CAPTURE)
88#define IVTV_CAP_DECODER (V4L2_CAP_VBI_OUTPUT | V4L2_CAP_VIDEO_OUTPUT | \ 88#define IVTV_CAP_DECODER (V4L2_CAP_VBI_OUTPUT | V4L2_CAP_VIDEO_OUTPUT | \
89 V4L2_CAP_SLICED_VBI_OUTPUT | V4L2_CAP_VIDEO_OUTPUT_OVERLAY | V4L2_CAP_VIDEO_OUTPUT_POS) 89 V4L2_CAP_SLICED_VBI_OUTPUT | V4L2_CAP_VIDEO_OUTPUT_OVERLAY)
90 90
91struct ivtv_card_video_input { 91struct ivtv_card_video_input {
92 u8 video_type; /* video input type */ 92 u8 video_type; /* video input type */
diff --git a/drivers/media/video/ivtv/ivtv-driver.c b/drivers/media/video/ivtv/ivtv-driver.c
index e29f949adf57..efc66355339a 100644
--- a/drivers/media/video/ivtv/ivtv-driver.c
+++ b/drivers/media/video/ivtv/ivtv-driver.c
@@ -652,6 +652,7 @@ static int __devinit ivtv_init_struct1(struct ivtv *itv)
652 itv->dma_timer.data = (unsigned long)itv; 652 itv->dma_timer.data = (unsigned long)itv;
653 653
654 itv->cur_dma_stream = -1; 654 itv->cur_dma_stream = -1;
655 itv->cur_pio_stream = -1;
655 itv->audio_stereo_mode = AUDIO_STEREO; 656 itv->audio_stereo_mode = AUDIO_STEREO;
656 itv->audio_bilingual_mode = AUDIO_MONO_LEFT; 657 itv->audio_bilingual_mode = AUDIO_MONO_LEFT;
657 658
diff --git a/drivers/media/video/ivtv/ivtv-driver.h b/drivers/media/video/ivtv/ivtv-driver.h
index 552f04511ead..e6e56f175f3f 100644
--- a/drivers/media/video/ivtv/ivtv-driver.h
+++ b/drivers/media/video/ivtv/ivtv-driver.h
@@ -237,6 +237,7 @@ extern const u32 yuv_offset[4];
237#define IVTV_IRQ_ENC_VBI_CAP (0x1 << 29) 237#define IVTV_IRQ_ENC_VBI_CAP (0x1 << 29)
238#define IVTV_IRQ_ENC_VIM_RST (0x1 << 28) 238#define IVTV_IRQ_ENC_VIM_RST (0x1 << 28)
239#define IVTV_IRQ_ENC_DMA_COMPLETE (0x1 << 27) 239#define IVTV_IRQ_ENC_DMA_COMPLETE (0x1 << 27)
240#define IVTV_IRQ_ENC_PIO_COMPLETE (0x1 << 25)
240#define IVTV_IRQ_DEC_AUD_MODE_CHG (0x1 << 24) 241#define IVTV_IRQ_DEC_AUD_MODE_CHG (0x1 << 24)
241#define IVTV_IRQ_DEC_DATA_REQ (0x1 << 22) 242#define IVTV_IRQ_DEC_DATA_REQ (0x1 << 22)
242#define IVTV_IRQ_DEC_DMA_COMPLETE (0x1 << 20) 243#define IVTV_IRQ_DEC_DMA_COMPLETE (0x1 << 20)
@@ -247,7 +248,8 @@ extern const u32 yuv_offset[4];
247#define IVTV_IRQ_DEC_VSYNC (0x1 << 10) 248#define IVTV_IRQ_DEC_VSYNC (0x1 << 10)
248 249
249/* IRQ Masks */ 250/* IRQ Masks */
250#define IVTV_IRQ_MASK_INIT (IVTV_IRQ_DMA_ERR|IVTV_IRQ_ENC_DMA_COMPLETE|IVTV_IRQ_DMA_READ) 251#define IVTV_IRQ_MASK_INIT (IVTV_IRQ_DMA_ERR|IVTV_IRQ_ENC_DMA_COMPLETE|\
252 IVTV_IRQ_DMA_READ|IVTV_IRQ_ENC_PIO_COMPLETE)
251 253
252#define IVTV_IRQ_MASK_CAPTURE (IVTV_IRQ_ENC_START_CAP | IVTV_IRQ_ENC_EOS) 254#define IVTV_IRQ_MASK_CAPTURE (IVTV_IRQ_ENC_START_CAP | IVTV_IRQ_ENC_EOS)
253#define IVTV_IRQ_MASK_DECODE (IVTV_IRQ_DEC_DATA_REQ|IVTV_IRQ_DEC_AUD_MODE_CHG) 255#define IVTV_IRQ_MASK_DECODE (IVTV_IRQ_DEC_DATA_REQ|IVTV_IRQ_DEC_AUD_MODE_CHG)
@@ -374,6 +376,9 @@ struct ivtv_mailbox_data {
374#define IVTV_F_S_STREAMOFF 7 /* signal end of stream EOS */ 376#define IVTV_F_S_STREAMOFF 7 /* signal end of stream EOS */
375#define IVTV_F_S_APPL_IO 8 /* this stream is used read/written by an application */ 377#define IVTV_F_S_APPL_IO 8 /* this stream is used read/written by an application */
376 378
379#define IVTV_F_S_PIO_PENDING 9 /* this stream has pending PIO */
380#define IVTV_F_S_PIO_HAS_VBI 1 /* the current PIO request also requests VBI data */
381
377/* per-ivtv, i_flags */ 382/* per-ivtv, i_flags */
378#define IVTV_F_I_DMA 0 /* DMA in progress */ 383#define IVTV_F_I_DMA 0 /* DMA in progress */
379#define IVTV_F_I_UDMA 1 /* UDMA in progress */ 384#define IVTV_F_I_UDMA 1 /* UDMA in progress */
@@ -390,8 +395,11 @@ struct ivtv_mailbox_data {
390#define IVTV_F_I_DECODING_YUV 12 /* this stream is YUV frame decoding */ 395#define IVTV_F_I_DECODING_YUV 12 /* this stream is YUV frame decoding */
391#define IVTV_F_I_ENC_PAUSED 13 /* the encoder is paused */ 396#define IVTV_F_I_ENC_PAUSED 13 /* the encoder is paused */
392#define IVTV_F_I_VALID_DEC_TIMINGS 14 /* last_dec_timing is valid */ 397#define IVTV_F_I_VALID_DEC_TIMINGS 14 /* last_dec_timing is valid */
393#define IVTV_F_I_WORK_HANDLER_VBI 15 /* there is work to be done for VBI */ 398#define IVTV_F_I_HAVE_WORK 15 /* Used in the interrupt handler: there is work to be done */
394#define IVTV_F_I_WORK_HANDLER_YUV 16 /* there is work to be done for YUV */ 399#define IVTV_F_I_WORK_HANDLER_VBI 16 /* there is work to be done for VBI */
400#define IVTV_F_I_WORK_HANDLER_YUV 17 /* there is work to be done for YUV */
401#define IVTV_F_I_WORK_HANDLER_PIO 18 /* there is work to be done for PIO */
402#define IVTV_F_I_PIO 19 /* PIO in progress */
395 403
396/* Event notifications */ 404/* Event notifications */
397#define IVTV_F_I_EV_DEC_STOPPED 28 /* decoder stopped event */ 405#define IVTV_F_I_EV_DEC_STOPPED 28 /* decoder stopped event */
@@ -484,6 +492,7 @@ struct ivtv_stream {
484 492
485 /* Base Dev SG Array for cx23415/6 */ 493 /* Base Dev SG Array for cx23415/6 */
486 struct ivtv_SG_element *SGarray; 494 struct ivtv_SG_element *SGarray;
495 struct ivtv_SG_element *PIOarray;
487 dma_addr_t SG_handle; 496 dma_addr_t SG_handle;
488 int SG_length; 497 int SG_length;
489 498
@@ -706,6 +715,7 @@ struct ivtv {
706 atomic_t decoding; /* count number of active decoding streams */ 715 atomic_t decoding; /* count number of active decoding streams */
707 u32 irq_rr_idx; /* Round-robin stream index */ 716 u32 irq_rr_idx; /* Round-robin stream index */
708 int cur_dma_stream; /* index of stream doing DMA */ 717 int cur_dma_stream; /* index of stream doing DMA */
718 int cur_pio_stream; /* index of stream doing PIO */
709 u32 dma_data_req_offset; 719 u32 dma_data_req_offset;
710 u32 dma_data_req_size; 720 u32 dma_data_req_size;
711 int output_mode; /* NONE, MPG, YUV, UDMA YUV, passthrough */ 721 int output_mode; /* NONE, MPG, YUV, UDMA YUV, passthrough */
diff --git a/drivers/media/video/ivtv/ivtv-fileops.c b/drivers/media/video/ivtv/ivtv-fileops.c
index 8976487a65f3..555d5e6369c3 100644
--- a/drivers/media/video/ivtv/ivtv-fileops.c
+++ b/drivers/media/video/ivtv/ivtv-fileops.c
@@ -32,6 +32,8 @@
32#include "ivtv-yuv.h" 32#include "ivtv-yuv.h"
33#include "ivtv-controls.h" 33#include "ivtv-controls.h"
34#include "ivtv-ioctl.h" 34#include "ivtv-ioctl.h"
35#include "ivtv-cards.h"
36#include <media/saa7115.h>
35 37
36/* This function tries to claim the stream for a specific file descriptor. 38/* This function tries to claim the stream for a specific file descriptor.
37 If no one else is using this stream then the stream is claimed and 39 If no one else is using this stream then the stream is claimed and
@@ -786,6 +788,13 @@ int ivtv_v4l2_close(struct inode *inode, struct file *filp)
786 ivtv_call_i2c_clients(itv, VIDIOC_S_STD, &itv->std); 788 ivtv_call_i2c_clients(itv, VIDIOC_S_STD, &itv->std);
787 /* Select correct audio input (i.e. TV tuner or Line in) */ 789 /* Select correct audio input (i.e. TV tuner or Line in) */
788 ivtv_audio_set_io(itv); 790 ivtv_audio_set_io(itv);
791 if (itv->hw_flags & IVTV_HW_SAA711X)
792 {
793 struct v4l2_crystal_freq crystal_freq;
794 crystal_freq.freq = SAA7115_FREQ_32_11_MHZ;
795 crystal_freq.flags = 0;
796 ivtv_saa7115(itv, VIDIOC_INT_S_CRYSTAL_FREQ, &crystal_freq);
797 }
789 /* Done! Unmute and continue. */ 798 /* Done! Unmute and continue. */
790 ivtv_unmute(itv); 799 ivtv_unmute(itv);
791 ivtv_release_stream(s); 800 ivtv_release_stream(s);
@@ -872,6 +881,13 @@ int ivtv_v4l2_open(struct inode *inode, struct file *filp)
872 set_bit(IVTV_F_I_RADIO_USER, &itv->i_flags); 881 set_bit(IVTV_F_I_RADIO_USER, &itv->i_flags);
873 /* Select the correct audio input (i.e. radio tuner) */ 882 /* Select the correct audio input (i.e. radio tuner) */
874 ivtv_audio_set_io(itv); 883 ivtv_audio_set_io(itv);
884 if (itv->hw_flags & IVTV_HW_SAA711X)
885 {
886 struct v4l2_crystal_freq crystal_freq;
887 crystal_freq.freq = SAA7115_FREQ_32_11_MHZ;
888 crystal_freq.flags = SAA7115_FREQ_FL_APLL;
889 ivtv_saa7115(itv, VIDIOC_INT_S_CRYSTAL_FREQ, &crystal_freq);
890 }
875 /* Done! Unmute and continue. */ 891 /* Done! Unmute and continue. */
876 ivtv_unmute(itv); 892 ivtv_unmute(itv);
877 } 893 }
diff --git a/drivers/media/video/ivtv/ivtv-ioctl.c b/drivers/media/video/ivtv/ivtv-ioctl.c
index 1989ec1cb973..57af1762de1f 100644
--- a/drivers/media/video/ivtv/ivtv-ioctl.c
+++ b/drivers/media/video/ivtv/ivtv-ioctl.c
@@ -532,11 +532,6 @@ static int ivtv_try_or_set_fmt(struct ivtv *itv, int streamtype,
532 itv->yuv_info.yuv_forced_update = 1; 532 itv->yuv_info.yuv_forced_update = 1;
533 return 0; 533 return 0;
534 } 534 }
535 if (!ivtv_vapi(itv, CX2341X_OSD_SET_FRAMEBUFFER_WINDOW, 4,
536 r.width, r.height, r.left, r.top))
537 itv->main_rect = r;
538 else
539 return -EINVAL;
540 } 535 }
541 return 0; 536 return 0;
542 } 537 }
@@ -799,9 +794,39 @@ int ivtv_v4l2_ioctls(struct ivtv *itv, struct file *filp, unsigned int cmd, void
799 return ivtv_get_fmt(itv, id->type, fmt); 794 return ivtv_get_fmt(itv, id->type, fmt);
800 } 795 }
801 796
797 case VIDIOC_CROPCAP: {
798 struct v4l2_cropcap *cropcap = arg;
799
800 if (cropcap->type != V4L2_BUF_TYPE_VIDEO_CAPTURE &&
801 cropcap->type != V4L2_BUF_TYPE_VIDEO_OUTPUT)
802 return -EINVAL;
803 cropcap->bounds.top = cropcap->bounds.left = 0;
804 cropcap->bounds.width = 720;
805 if (cropcap->type == V4L2_BUF_TYPE_VIDEO_CAPTURE) {
806 cropcap->bounds.height = itv->is_50hz ? 576 : 480;
807 cropcap->pixelaspect.numerator = itv->is_50hz ? 59 : 10;
808 cropcap->pixelaspect.denominator = itv->is_50hz ? 54 : 11;
809 } else {
810 cropcap->bounds.height = itv->is_out_50hz ? 576 : 480;
811 cropcap->pixelaspect.numerator = itv->is_out_50hz ? 59 : 10;
812 cropcap->pixelaspect.denominator = itv->is_out_50hz ? 54 : 11;
813 }
814 cropcap->defrect = cropcap->bounds;
815 return 0;
816 }
817
802 case VIDIOC_S_CROP: { 818 case VIDIOC_S_CROP: {
803 struct v4l2_crop *crop = arg; 819 struct v4l2_crop *crop = arg;
804 820
821 if (crop->type == V4L2_BUF_TYPE_VIDEO_OUTPUT &&
822 (itv->v4l2_cap & V4L2_CAP_VIDEO_OUTPUT)) {
823 if (!ivtv_vapi(itv, CX2341X_OSD_SET_FRAMEBUFFER_WINDOW, 4,
824 crop->c.width, crop->c.height, crop->c.left, crop->c.top)) {
825 itv->main_rect = crop->c;
826 return 0;
827 }
828 return -EINVAL;
829 }
805 if (crop->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) 830 if (crop->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
806 return -EINVAL; 831 return -EINVAL;
807 return itv->video_dec_func(itv, VIDIOC_S_CROP, arg); 832 return itv->video_dec_func(itv, VIDIOC_S_CROP, arg);
@@ -810,6 +835,11 @@ int ivtv_v4l2_ioctls(struct ivtv *itv, struct file *filp, unsigned int cmd, void
810 case VIDIOC_G_CROP: { 835 case VIDIOC_G_CROP: {
811 struct v4l2_crop *crop = arg; 836 struct v4l2_crop *crop = arg;
812 837
838 if (crop->type == V4L2_BUF_TYPE_VIDEO_OUTPUT &&
839 (itv->v4l2_cap & V4L2_CAP_VIDEO_OUTPUT)) {
840 crop->c = itv->main_rect;
841 return 0;
842 }
813 if (crop->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) 843 if (crop->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
814 return -EINVAL; 844 return -EINVAL;
815 return itv->video_dec_func(itv, VIDIOC_G_CROP, arg); 845 return itv->video_dec_func(itv, VIDIOC_G_CROP, arg);
@@ -977,7 +1007,7 @@ int ivtv_v4l2_ioctls(struct ivtv *itv, struct file *filp, unsigned int cmd, void
977 if (itv->hw_flags & IVTV_HW_CX25840) { 1007 if (itv->hw_flags & IVTV_HW_CX25840) {
978 itv->vbi.sliced_decoder_line_size = itv->is_60hz ? 272 : 284; 1008 itv->vbi.sliced_decoder_line_size = itv->is_60hz ? 272 : 284;
979 } 1009 }
980 IVTV_DEBUG_INFO("Switching standard to %llx.\n", itv->std); 1010 IVTV_DEBUG_INFO("Switching standard to %llx.\n", (unsigned long long)itv->std);
981 1011
982 /* Tuner */ 1012 /* Tuner */
983 ivtv_call_i2c_clients(itv, VIDIOC_S_STD, &itv->std); 1013 ivtv_call_i2c_clients(itv, VIDIOC_S_STD, &itv->std);
@@ -1207,7 +1237,7 @@ int ivtv_v4l2_ioctls(struct ivtv *itv, struct file *filp, unsigned int cmd, void
1207 (s->buffers - s->q_free.buffers) * 100 / s->buffers, 1237 (s->buffers - s->q_free.buffers) * 100 / s->buffers,
1208 (s->buffers * s->buf_size) / 1024, s->buffers); 1238 (s->buffers * s->buf_size) / 1024, s->buffers);
1209 } 1239 }
1210 IVTV_INFO("Read MPEG/VBI: %lld/%lld bytes\n", itv->mpg_data_received, itv->vbi_data_inserted); 1240 IVTV_INFO("Read MPEG/VBI: %lld/%lld bytes\n", (long long)itv->mpg_data_received, (long long)itv->vbi_data_inserted);
1211 IVTV_INFO("================== END STATUS CARD #%d ==================\n", itv->num); 1241 IVTV_INFO("================== END STATUS CARD #%d ==================\n", itv->num);
1212 break; 1242 break;
1213 } 1243 }
@@ -1455,6 +1485,7 @@ static int ivtv_v4l2_do_ioctl(struct inode *inode, struct file *filp,
1455 case VIDIOC_S_FMT: 1485 case VIDIOC_S_FMT:
1456 case VIDIOC_TRY_FMT: 1486 case VIDIOC_TRY_FMT:
1457 case VIDIOC_ENUM_FMT: 1487 case VIDIOC_ENUM_FMT:
1488 case VIDIOC_CROPCAP:
1458 case VIDIOC_G_CROP: 1489 case VIDIOC_G_CROP:
1459 case VIDIOC_S_CROP: 1490 case VIDIOC_S_CROP:
1460 case VIDIOC_G_FREQUENCY: 1491 case VIDIOC_G_FREQUENCY:
diff --git a/drivers/media/video/ivtv/ivtv-irq.c b/drivers/media/video/ivtv/ivtv-irq.c
index c3a047b381b3..ba98bf054f2e 100644
--- a/drivers/media/video/ivtv/ivtv-irq.c
+++ b/drivers/media/video/ivtv/ivtv-irq.c
@@ -31,8 +31,6 @@
31 31
32#define DMA_MAGIC_COOKIE 0x000001fe 32#define DMA_MAGIC_COOKIE 0x000001fe
33 33
34#define SLICED_VBI_PIO 1
35
36static void ivtv_dma_dec_start(struct ivtv_stream *s); 34static void ivtv_dma_dec_start(struct ivtv_stream *s);
37 35
38static const int ivtv_stream_map[] = { 36static const int ivtv_stream_map[] = {
@@ -42,12 +40,40 @@ static const int ivtv_stream_map[] = {
42 IVTV_ENC_STREAM_TYPE_VBI, 40 IVTV_ENC_STREAM_TYPE_VBI,
43}; 41};
44 42
45static inline int ivtv_use_pio(struct ivtv_stream *s) 43
44static void ivtv_pio_work_handler(struct ivtv *itv)
46{ 45{
47 struct ivtv *itv = s->itv; 46 struct ivtv_stream *s = &itv->streams[itv->cur_pio_stream];
47 struct ivtv_buffer *buf;
48 struct list_head *p;
49 int i = 0;
50
51 IVTV_DEBUG_DMA("ivtv_pio_work_handler\n");
52 if (itv->cur_pio_stream < 0 || itv->cur_pio_stream >= IVTV_MAX_STREAMS ||
53 s->v4l2dev == NULL || !ivtv_use_pio(s)) {
54 itv->cur_pio_stream = -1;
55 /* trigger PIO complete user interrupt */
56 write_reg(IVTV_IRQ_ENC_PIO_COMPLETE, 0x44);
57 return;
58 }
59 IVTV_DEBUG_DMA("Process PIO %s\n", s->name);
60 buf = list_entry(s->q_dma.list.next, struct ivtv_buffer, list);
61 list_for_each(p, &s->q_dma.list) {
62 struct ivtv_buffer *buf = list_entry(p, struct ivtv_buffer, list);
63 u32 size = s->PIOarray[i].size & 0x3ffff;
48 64
49 return s->dma == PCI_DMA_NONE || 65 /* Copy the data from the card to the buffer */
50 (SLICED_VBI_PIO && s->type == IVTV_ENC_STREAM_TYPE_VBI && itv->vbi.sliced_in->service_set); 66 if (s->type == IVTV_DEC_STREAM_TYPE_VBI) {
67 memcpy_fromio(buf->buf, itv->dec_mem + s->PIOarray[i].src - IVTV_DECODER_OFFSET, size);
68 }
69 else {
70 memcpy_fromio(buf->buf, itv->enc_mem + s->PIOarray[i].src, size);
71 }
72 if (s->PIOarray[i].size & 0x80000000)
73 break;
74 i++;
75 }
76 write_reg(IVTV_IRQ_ENC_PIO_COMPLETE, 0x44);
51} 77}
52 78
53void ivtv_irq_work_handler(struct work_struct *work) 79void ivtv_irq_work_handler(struct work_struct *work)
@@ -56,8 +82,11 @@ void ivtv_irq_work_handler(struct work_struct *work)
56 82
57 DEFINE_WAIT(wait); 83 DEFINE_WAIT(wait);
58 84
85 if (test_and_clear_bit(IVTV_F_I_WORK_HANDLER_PIO, &itv->i_flags))
86 ivtv_pio_work_handler(itv);
87
59 if (test_and_clear_bit(IVTV_F_I_WORK_HANDLER_VBI, &itv->i_flags)) 88 if (test_and_clear_bit(IVTV_F_I_WORK_HANDLER_VBI, &itv->i_flags))
60 vbi_work_handler(itv); 89 ivtv_vbi_work_handler(itv);
61 90
62 if (test_and_clear_bit(IVTV_F_I_WORK_HANDLER_YUV, &itv->i_flags)) 91 if (test_and_clear_bit(IVTV_F_I_WORK_HANDLER_YUV, &itv->i_flags))
63 ivtv_yuv_work_handler(itv); 92 ivtv_yuv_work_handler(itv);
@@ -173,8 +202,7 @@ static int stream_enc_dma_append(struct ivtv_stream *s, u32 data[CX2341X_MBOX_MA
173 } 202 }
174 s->buffers_stolen = rc; 203 s->buffers_stolen = rc;
175 204
176 /* got the buffers, now fill in SGarray (DMA) or copy the data from the card 205 /* got the buffers, now fill in SGarray (DMA) */
177 to the buffers (PIO). */
178 buf = list_entry(s->q_predma.list.next, struct ivtv_buffer, list); 206 buf = list_entry(s->q_predma.list.next, struct ivtv_buffer, list);
179 memset(buf->buf, 0, 128); 207 memset(buf->buf, 0, 128);
180 list_for_each(p, &s->q_predma.list) { 208 list_for_each(p, &s->q_predma.list) {
@@ -182,21 +210,11 @@ static int stream_enc_dma_append(struct ivtv_stream *s, u32 data[CX2341X_MBOX_MA
182 210
183 if (skip_bufs-- > 0) 211 if (skip_bufs-- > 0)
184 continue; 212 continue;
185 if (!ivtv_use_pio(s)) { 213 s->SGarray[idx].dst = cpu_to_le32(buf->dma_handle);
186 s->SGarray[idx].dst = cpu_to_le32(buf->dma_handle); 214 s->SGarray[idx].src = cpu_to_le32(offset);
187 s->SGarray[idx].src = cpu_to_le32(offset); 215 s->SGarray[idx].size = cpu_to_le32(s->buf_size);
188 s->SGarray[idx].size = cpu_to_le32(s->buf_size);
189 }
190 buf->bytesused = (size < s->buf_size) ? size : s->buf_size; 216 buf->bytesused = (size < s->buf_size) ? size : s->buf_size;
191 217
192 /* If PIO, then copy the data from the card to the buffer */
193 if (s->type == IVTV_DEC_STREAM_TYPE_VBI) {
194 memcpy_fromio(buf->buf, itv->dec_mem + offset - IVTV_DECODER_OFFSET, buf->bytesused);
195 }
196 else if (ivtv_use_pio(s)) {
197 memcpy_fromio(buf->buf, itv->enc_mem + offset, buf->bytesused);
198 }
199
200 s->q_predma.bytesused += buf->bytesused; 218 s->q_predma.bytesused += buf->bytesused;
201 size -= buf->bytesused; 219 size -= buf->bytesused;
202 offset += s->buf_size; 220 offset += s->buf_size;
@@ -224,11 +242,6 @@ static void dma_post(struct ivtv_stream *s)
224 u32 *u32buf; 242 u32 *u32buf;
225 int x = 0; 243 int x = 0;
226 244
227 if (ivtv_use_pio(s)) {
228 if (s->q_predma.bytesused)
229 ivtv_queue_move(s, &s->q_predma, NULL, &s->q_dma, s->q_predma.bytesused);
230 s->SG_length = 0;
231 }
232 IVTV_DEBUG_DMA("%s %s completed (%x)\n", ivtv_use_pio(s) ? "PIO" : "DMA", 245 IVTV_DEBUG_DMA("%s %s completed (%x)\n", ivtv_use_pio(s) ? "PIO" : "DMA",
233 s->name, s->dma_offset); 246 s->name, s->dma_offset);
234 list_for_each(p, &s->q_dma.list) { 247 list_for_each(p, &s->q_dma.list) {
@@ -278,10 +291,14 @@ static void dma_post(struct ivtv_stream *s)
278 if (buf) 291 if (buf)
279 buf->bytesused += s->dma_last_offset; 292 buf->bytesused += s->dma_last_offset;
280 if (buf && s->type == IVTV_DEC_STREAM_TYPE_VBI) { 293 if (buf && s->type == IVTV_DEC_STREAM_TYPE_VBI) {
281 /* Parse and Groom VBI Data */ 294 list_for_each(p, &s->q_dma.list) {
282 s->q_dma.bytesused -= buf->bytesused; 295 buf = list_entry(p, struct ivtv_buffer, list);
283 ivtv_process_vbi_data(itv, buf, 0, s->type); 296
284 s->q_dma.bytesused += buf->bytesused; 297 /* Parse and Groom VBI Data */
298 s->q_dma.bytesused -= buf->bytesused;
299 ivtv_process_vbi_data(itv, buf, 0, s->type);
300 s->q_dma.bytesused += buf->bytesused;
301 }
285 if (s->id == -1) { 302 if (s->id == -1) {
286 ivtv_queue_move(s, &s->q_dma, NULL, &s->q_free, 0); 303 ivtv_queue_move(s, &s->q_dma, NULL, &s->q_free, 0);
287 return; 304 return;
@@ -351,10 +368,14 @@ static void ivtv_dma_enc_start(struct ivtv_stream *s)
351 struct ivtv_stream *s_vbi = &itv->streams[IVTV_ENC_STREAM_TYPE_VBI]; 368 struct ivtv_stream *s_vbi = &itv->streams[IVTV_ENC_STREAM_TYPE_VBI];
352 int i; 369 int i;
353 370
371 IVTV_DEBUG_DMA("start %s for %s\n", ivtv_use_dma(s) ? "DMA" : "PIO", s->name);
372
354 if (s->q_predma.bytesused) 373 if (s->q_predma.bytesused)
355 ivtv_queue_move(s, &s->q_predma, NULL, &s->q_dma, s->q_predma.bytesused); 374 ivtv_queue_move(s, &s->q_predma, NULL, &s->q_dma, s->q_predma.bytesused);
356 IVTV_DEBUG_DMA("start DMA for %s\n", s->name); 375
357 s->SGarray[s->SG_length - 1].size = cpu_to_le32(le32_to_cpu(s->SGarray[s->SG_length - 1].size) + 256); 376 if (ivtv_use_dma(s))
377 s->SGarray[s->SG_length - 1].size =
378 cpu_to_le32(le32_to_cpu(s->SGarray[s->SG_length - 1].size) + 256);
358 379
359 /* If this is an MPEG stream, and VBI data is also pending, then append the 380 /* If this is an MPEG stream, and VBI data is also pending, then append the
360 VBI DMA to the MPEG DMA and transfer both sets of data at once. 381 VBI DMA to the MPEG DMA and transfer both sets of data at once.
@@ -368,7 +389,8 @@ static void ivtv_dma_enc_start(struct ivtv_stream *s)
368 if (s->type == IVTV_ENC_STREAM_TYPE_MPG && s_vbi->SG_length && 389 if (s->type == IVTV_ENC_STREAM_TYPE_MPG && s_vbi->SG_length &&
369 s->SG_length + s_vbi->SG_length <= s->buffers) { 390 s->SG_length + s_vbi->SG_length <= s->buffers) {
370 ivtv_queue_move(s_vbi, &s_vbi->q_predma, NULL, &s_vbi->q_dma, s_vbi->q_predma.bytesused); 391 ivtv_queue_move(s_vbi, &s_vbi->q_predma, NULL, &s_vbi->q_dma, s_vbi->q_predma.bytesused);
371 s_vbi->SGarray[s_vbi->SG_length - 1].size = cpu_to_le32(le32_to_cpu(s_vbi->SGarray[s->SG_length - 1].size) + 256); 392 if (ivtv_use_dma(s_vbi))
393 s_vbi->SGarray[s_vbi->SG_length - 1].size = cpu_to_le32(le32_to_cpu(s_vbi->SGarray[s->SG_length - 1].size) + 256);
372 for (i = 0; i < s_vbi->SG_length; i++) { 394 for (i = 0; i < s_vbi->SG_length; i++) {
373 s->SGarray[s->SG_length++] = s_vbi->SGarray[i]; 395 s->SGarray[s->SG_length++] = s_vbi->SGarray[i];
374 } 396 }
@@ -381,14 +403,26 @@ static void ivtv_dma_enc_start(struct ivtv_stream *s)
381 /* Mark last buffer size for Interrupt flag */ 403 /* Mark last buffer size for Interrupt flag */
382 s->SGarray[s->SG_length - 1].size |= cpu_to_le32(0x80000000); 404 s->SGarray[s->SG_length - 1].size |= cpu_to_le32(0x80000000);
383 405
384 /* Sync Hardware SG List of buffers */ 406 if (ivtv_use_pio(s)) {
385 ivtv_stream_sync_for_device(s); 407 for (i = 0; i < s->SG_length; i++) {
386 write_reg(s->SG_handle, IVTV_REG_ENCDMAADDR); 408 s->PIOarray[i].src = le32_to_cpu(s->SGarray[i].src);
387 write_reg_sync(read_reg(IVTV_REG_DMAXFER) | 0x02, IVTV_REG_DMAXFER); 409 s->PIOarray[i].size = le32_to_cpu(s->SGarray[i].size);
388 set_bit(IVTV_F_I_DMA, &itv->i_flags); 410 }
389 itv->cur_dma_stream = s->type; 411 set_bit(IVTV_F_I_WORK_HANDLER_PIO, &itv->i_flags);
390 itv->dma_timer.expires = jiffies + HZ / 10; 412 set_bit(IVTV_F_I_HAVE_WORK, &itv->i_flags);
391 add_timer(&itv->dma_timer); 413 set_bit(IVTV_F_I_PIO, &itv->i_flags);
414 itv->cur_pio_stream = s->type;
415 }
416 else {
417 /* Sync Hardware SG List of buffers */
418 ivtv_stream_sync_for_device(s);
419 write_reg(s->SG_handle, IVTV_REG_ENCDMAADDR);
420 write_reg_sync(read_reg(IVTV_REG_DMAXFER) | 0x02, IVTV_REG_DMAXFER);
421 set_bit(IVTV_F_I_DMA, &itv->i_flags);
422 itv->cur_dma_stream = s->type;
423 itv->dma_timer.expires = jiffies + HZ / 10;
424 add_timer(&itv->dma_timer);
425 }
392} 426}
393 427
394static void ivtv_dma_dec_start(struct ivtv_stream *s) 428static void ivtv_dma_dec_start(struct ivtv_stream *s)
@@ -489,6 +523,40 @@ static void ivtv_irq_enc_dma_complete(struct ivtv *itv)
489 wake_up(&itv->dma_waitq); 523 wake_up(&itv->dma_waitq);
490} 524}
491 525
526static void ivtv_irq_enc_pio_complete(struct ivtv *itv)
527{
528 struct ivtv_stream *s;
529
530 if (itv->cur_pio_stream < 0 || itv->cur_pio_stream >= IVTV_MAX_STREAMS) {
531 itv->cur_pio_stream = -1;
532 return;
533 }
534 s = &itv->streams[itv->cur_pio_stream];
535 IVTV_DEBUG_IRQ("ENC PIO COMPLETE %s\n", s->name);
536 s->SG_length = 0;
537 clear_bit(IVTV_F_I_ENC_VBI, &itv->i_flags);
538 clear_bit(IVTV_F_I_PIO, &itv->i_flags);
539 itv->cur_pio_stream = -1;
540 dma_post(s);
541 if (s->type == IVTV_ENC_STREAM_TYPE_MPG)
542 ivtv_vapi(itv, CX2341X_ENC_SCHED_DMA_TO_HOST, 3, 0, 0, 0);
543 else if (s->type == IVTV_ENC_STREAM_TYPE_YUV)
544 ivtv_vapi(itv, CX2341X_ENC_SCHED_DMA_TO_HOST, 3, 0, 0, 1);
545 else if (s->type == IVTV_ENC_STREAM_TYPE_PCM)
546 ivtv_vapi(itv, CX2341X_ENC_SCHED_DMA_TO_HOST, 3, 0, 0, 2);
547 clear_bit(IVTV_F_I_PIO, &itv->i_flags);
548 if (test_and_clear_bit(IVTV_F_S_DMA_HAS_VBI, &s->s_flags)) {
549 u32 tmp;
550
551 s = &itv->streams[IVTV_ENC_STREAM_TYPE_VBI];
552 tmp = s->dma_offset;
553 s->dma_offset = itv->vbi.dma_offset;
554 dma_post(s);
555 s->dma_offset = tmp;
556 }
557 wake_up(&itv->dma_waitq);
558}
559
492static void ivtv_irq_dma_err(struct ivtv *itv) 560static void ivtv_irq_dma_err(struct ivtv *itv)
493{ 561{
494 u32 data[CX2341X_MBOX_MAX_DATA]; 562 u32 data[CX2341X_MBOX_MAX_DATA];
@@ -532,13 +600,7 @@ static void ivtv_irq_enc_start_cap(struct ivtv *itv)
532 clear_bit(IVTV_F_I_ENC_VBI, &itv->i_flags); 600 clear_bit(IVTV_F_I_ENC_VBI, &itv->i_flags);
533 s = &itv->streams[ivtv_stream_map[data[0]]]; 601 s = &itv->streams[ivtv_stream_map[data[0]]];
534 if (!stream_enc_dma_append(s, data)) { 602 if (!stream_enc_dma_append(s, data)) {
535 if (ivtv_use_pio(s)) { 603 set_bit(ivtv_use_pio(s) ? IVTV_F_S_PIO_PENDING : IVTV_F_S_DMA_PENDING, &s->s_flags);
536 dma_post(s);
537 ivtv_vapi(itv, CX2341X_ENC_SCHED_DMA_TO_HOST, 3, 0, 0, data[0]);
538 }
539 else {
540 set_bit(IVTV_F_S_DMA_PENDING, &s->s_flags);
541 }
542 } 604 }
543} 605}
544 606
@@ -551,15 +613,6 @@ static void ivtv_irq_enc_vbi_cap(struct ivtv *itv)
551 IVTV_DEBUG_IRQ("ENC START VBI CAP\n"); 613 IVTV_DEBUG_IRQ("ENC START VBI CAP\n");
552 s = &itv->streams[IVTV_ENC_STREAM_TYPE_VBI]; 614 s = &itv->streams[IVTV_ENC_STREAM_TYPE_VBI];
553 615
554 if (ivtv_use_pio(s)) {
555 if (stream_enc_dma_append(s, data))
556 return;
557 if (s->q_predma.bytesused)
558 ivtv_queue_move(s, &s->q_predma, NULL, &s->q_dma, s->q_predma.bytesused);
559 s->SG_length = 0;
560 dma_post(s);
561 return;
562 }
563 /* If more than two VBI buffers are pending, then 616 /* If more than two VBI buffers are pending, then
564 clear the old ones and start with this new one. 617 clear the old ones and start with this new one.
565 This can happen during transition stages when MPEG capturing is 618 This can happen during transition stages when MPEG capturing is
@@ -582,11 +635,11 @@ static void ivtv_irq_enc_vbi_cap(struct ivtv *itv)
582 if (!stream_enc_dma_append(s, data) && 635 if (!stream_enc_dma_append(s, data) &&
583 !test_bit(IVTV_F_S_STREAMING, &s_mpg->s_flags)) { 636 !test_bit(IVTV_F_S_STREAMING, &s_mpg->s_flags)) {
584 set_bit(IVTV_F_I_ENC_VBI, &itv->i_flags); 637 set_bit(IVTV_F_I_ENC_VBI, &itv->i_flags);
585 set_bit(IVTV_F_S_DMA_PENDING, &s->s_flags); 638 set_bit(ivtv_use_pio(s) ? IVTV_F_S_PIO_PENDING : IVTV_F_S_DMA_PENDING, &s->s_flags);
586 } 639 }
587} 640}
588 641
589static void ivtv_irq_dev_vbi_reinsert(struct ivtv *itv) 642static void ivtv_irq_dec_vbi_reinsert(struct ivtv *itv)
590{ 643{
591 u32 data[CX2341X_MBOX_MAX_DATA]; 644 u32 data[CX2341X_MBOX_MAX_DATA];
592 struct ivtv_stream *s = &itv->streams[IVTV_DEC_STREAM_TYPE_VBI]; 645 struct ivtv_stream *s = &itv->streams[IVTV_DEC_STREAM_TYPE_VBI];
@@ -594,7 +647,7 @@ static void ivtv_irq_dev_vbi_reinsert(struct ivtv *itv)
594 IVTV_DEBUG_IRQ("DEC VBI REINSERT\n"); 647 IVTV_DEBUG_IRQ("DEC VBI REINSERT\n");
595 if (test_bit(IVTV_F_S_CLAIMED, &s->s_flags) && 648 if (test_bit(IVTV_F_S_CLAIMED, &s->s_flags) &&
596 !stream_enc_dma_append(s, data)) { 649 !stream_enc_dma_append(s, data)) {
597 dma_post(s); 650 set_bit(IVTV_F_S_PIO_PENDING, &s->s_flags);
598 } 651 }
599} 652}
600 653
@@ -657,7 +710,6 @@ static void ivtv_irq_vsync(struct ivtv *itv)
657 } 710 }
658 if (frame != (itv->lastVsyncFrame & 1)) { 711 if (frame != (itv->lastVsyncFrame & 1)) {
659 struct ivtv_stream *s = ivtv_get_output_stream(itv); 712 struct ivtv_stream *s = ivtv_get_output_stream(itv);
660 int work = 0;
661 713
662 itv->lastVsyncFrame += 1; 714 itv->lastVsyncFrame += 1;
663 if (frame == 0) { 715 if (frame == 0) {
@@ -678,7 +730,7 @@ static void ivtv_irq_vsync(struct ivtv *itv)
678 /* Send VBI to saa7127 */ 730 /* Send VBI to saa7127 */
679 if (frame) { 731 if (frame) {
680 set_bit(IVTV_F_I_WORK_HANDLER_VBI, &itv->i_flags); 732 set_bit(IVTV_F_I_WORK_HANDLER_VBI, &itv->i_flags);
681 work = 1; 733 set_bit(IVTV_F_I_HAVE_WORK, &itv->i_flags);
682 } 734 }
683 735
684 /* Check if we need to update the yuv registers */ 736 /* Check if we need to update the yuv registers */
@@ -691,11 +743,9 @@ static void ivtv_irq_vsync(struct ivtv *itv)
691 itv->yuv_info.new_frame_info[last_dma_frame].update = 0; 743 itv->yuv_info.new_frame_info[last_dma_frame].update = 0;
692 itv->yuv_info.yuv_forced_update = 0; 744 itv->yuv_info.yuv_forced_update = 0;
693 set_bit(IVTV_F_I_WORK_HANDLER_YUV, &itv->i_flags); 745 set_bit(IVTV_F_I_WORK_HANDLER_YUV, &itv->i_flags);
694 work = 1; 746 set_bit(IVTV_F_I_HAVE_WORK, &itv->i_flags);
695 } 747 }
696 } 748 }
697 if (work)
698 queue_work(itv->irq_work_queues, &itv->irq_work_queue);
699 } 749 }
700} 750}
701 751
@@ -755,6 +805,10 @@ irqreturn_t ivtv_irq_handler(int irq, void *dev_id)
755 ivtv_irq_enc_dma_complete(itv); 805 ivtv_irq_enc_dma_complete(itv);
756 } 806 }
757 807
808 if (combo & IVTV_IRQ_ENC_PIO_COMPLETE) {
809 ivtv_irq_enc_pio_complete(itv);
810 }
811
758 if (combo & IVTV_IRQ_DMA_ERR) { 812 if (combo & IVTV_IRQ_DMA_ERR) {
759 ivtv_irq_dma_err(itv); 813 ivtv_irq_dma_err(itv);
760 } 814 }
@@ -768,7 +822,7 @@ irqreturn_t ivtv_irq_handler(int irq, void *dev_id)
768 } 822 }
769 823
770 if (combo & IVTV_IRQ_DEC_VBI_RE_INSERT) { 824 if (combo & IVTV_IRQ_DEC_VBI_RE_INSERT) {
771 ivtv_irq_dev_vbi_reinsert(itv); 825 ivtv_irq_dec_vbi_reinsert(itv);
772 } 826 }
773 827
774 if (combo & IVTV_IRQ_ENC_EOS) { 828 if (combo & IVTV_IRQ_ENC_EOS) {
@@ -813,6 +867,22 @@ irqreturn_t ivtv_irq_handler(int irq, void *dev_id)
813 } 867 }
814 } 868 }
815 869
870 if ((combo & IVTV_IRQ_DMA) && !test_bit(IVTV_F_I_PIO, &itv->i_flags)) {
871 for (i = 0; i < IVTV_MAX_STREAMS; i++) {
872 int idx = (i + itv->irq_rr_idx++) % IVTV_MAX_STREAMS;
873 struct ivtv_stream *s = &itv->streams[idx];
874
875 if (!test_and_clear_bit(IVTV_F_S_PIO_PENDING, &s->s_flags))
876 continue;
877 if (s->type == IVTV_DEC_STREAM_TYPE_VBI || s->type < IVTV_DEC_STREAM_TYPE_MPG)
878 ivtv_dma_enc_start(s);
879 break;
880 }
881 }
882
883 if (test_and_clear_bit(IVTV_F_I_HAVE_WORK, &itv->i_flags))
884 queue_work(itv->irq_work_queues, &itv->irq_work_queue);
885
816 spin_unlock(&itv->dma_reg_lock); 886 spin_unlock(&itv->dma_reg_lock);
817 887
818 /* If we've just handled a 'forced' vsync, it's safest to say it 888 /* If we've just handled a 'forced' vsync, it's safest to say it
diff --git a/drivers/media/video/ivtv/ivtv-queue.c b/drivers/media/video/ivtv/ivtv-queue.c
index ccfcef1ad91a..a04f9387f63d 100644
--- a/drivers/media/video/ivtv/ivtv-queue.c
+++ b/drivers/media/video/ivtv/ivtv-queue.c
@@ -195,14 +195,26 @@ int ivtv_stream_alloc(struct ivtv_stream *s)
195 s->dma != PCI_DMA_NONE ? "DMA " : "", 195 s->dma != PCI_DMA_NONE ? "DMA " : "",
196 s->name, s->buffers, s->buf_size, s->buffers * s->buf_size / 1024); 196 s->name, s->buffers, s->buf_size, s->buffers * s->buf_size / 1024);
197 197
198 /* Allocate DMA SG Arrays */ 198 if (ivtv_might_use_pio(s)) {
199 if (s->dma != PCI_DMA_NONE) { 199 s->PIOarray = (struct ivtv_SG_element *)kzalloc(SGsize, GFP_KERNEL);
200 s->SGarray = (struct ivtv_SG_element *)kzalloc(SGsize, GFP_KERNEL); 200 if (s->PIOarray == NULL) {
201 if (s->SGarray == NULL) { 201 IVTV_ERR("Could not allocate PIOarray for %s stream\n", s->name);
202 IVTV_ERR("Could not allocate SGarray for %s stream\n", s->name);
203 return -ENOMEM; 202 return -ENOMEM;
204 } 203 }
205 s->SG_length = 0; 204 }
205
206 /* Allocate DMA SG Arrays */
207 s->SGarray = (struct ivtv_SG_element *)kzalloc(SGsize, GFP_KERNEL);
208 if (s->SGarray == NULL) {
209 IVTV_ERR("Could not allocate SGarray for %s stream\n", s->name);
210 if (ivtv_might_use_pio(s)) {
211 kfree(s->PIOarray);
212 s->PIOarray = NULL;
213 }
214 return -ENOMEM;
215 }
216 s->SG_length = 0;
217 if (ivtv_might_use_dma(s)) {
206 s->SG_handle = pci_map_single(itv->dev, s->SGarray, SGsize, s->dma); 218 s->SG_handle = pci_map_single(itv->dev, s->SGarray, SGsize, s->dma);
207 ivtv_stream_sync_for_cpu(s); 219 ivtv_stream_sync_for_cpu(s);
208 } 220 }
@@ -219,7 +231,7 @@ int ivtv_stream_alloc(struct ivtv_stream *s)
219 break; 231 break;
220 } 232 }
221 INIT_LIST_HEAD(&buf->list); 233 INIT_LIST_HEAD(&buf->list);
222 if (s->dma != PCI_DMA_NONE) { 234 if (ivtv_might_use_dma(s)) {
223 buf->dma_handle = pci_map_single(s->itv->dev, 235 buf->dma_handle = pci_map_single(s->itv->dev,
224 buf->buf, s->buf_size + 256, s->dma); 236 buf->buf, s->buf_size + 256, s->dma);
225 ivtv_buf_sync_for_cpu(s, buf); 237 ivtv_buf_sync_for_cpu(s, buf);
@@ -242,7 +254,7 @@ void ivtv_stream_free(struct ivtv_stream *s)
242 254
243 /* empty q_free */ 255 /* empty q_free */
244 while ((buf = ivtv_dequeue(s, &s->q_free))) { 256 while ((buf = ivtv_dequeue(s, &s->q_free))) {
245 if (s->dma != PCI_DMA_NONE) 257 if (ivtv_might_use_dma(s))
246 pci_unmap_single(s->itv->dev, buf->dma_handle, 258 pci_unmap_single(s->itv->dev, buf->dma_handle,
247 s->buf_size + 256, s->dma); 259 s->buf_size + 256, s->dma);
248 kfree(buf->buf); 260 kfree(buf->buf);
@@ -256,6 +268,9 @@ void ivtv_stream_free(struct ivtv_stream *s)
256 sizeof(struct ivtv_SG_element) * s->buffers, PCI_DMA_TODEVICE); 268 sizeof(struct ivtv_SG_element) * s->buffers, PCI_DMA_TODEVICE);
257 s->SG_handle = IVTV_DMA_UNMAPPED; 269 s->SG_handle = IVTV_DMA_UNMAPPED;
258 } 270 }
271 kfree(s->SGarray);
272 kfree(s->PIOarray);
273 s->PIOarray = NULL;
259 s->SGarray = NULL; 274 s->SGarray = NULL;
260 s->SG_length = 0; 275 s->SG_length = 0;
261 } 276 }
diff --git a/drivers/media/video/ivtv/ivtv-queue.h b/drivers/media/video/ivtv/ivtv-queue.h
index 903edd4b4381..2ed8d548255d 100644
--- a/drivers/media/video/ivtv/ivtv-queue.h
+++ b/drivers/media/video/ivtv/ivtv-queue.h
@@ -20,18 +20,43 @@
20 */ 20 */
21 21
22#define IVTV_DMA_UNMAPPED ((u32) -1) 22#define IVTV_DMA_UNMAPPED ((u32) -1)
23#define SLICED_VBI_PIO 1
23 24
24/* ivtv_buffer utility functions */ 25/* ivtv_buffer utility functions */
26
27static inline int ivtv_might_use_pio(struct ivtv_stream *s)
28{
29 return s->dma == PCI_DMA_NONE || (SLICED_VBI_PIO && s->type == IVTV_ENC_STREAM_TYPE_VBI);
30}
31
32static inline int ivtv_use_pio(struct ivtv_stream *s)
33{
34 struct ivtv *itv = s->itv;
35
36 return s->dma == PCI_DMA_NONE ||
37 (SLICED_VBI_PIO && s->type == IVTV_ENC_STREAM_TYPE_VBI && itv->vbi.sliced_in->service_set);
38}
39
40static inline int ivtv_might_use_dma(struct ivtv_stream *s)
41{
42 return s->dma != PCI_DMA_NONE;
43}
44
45static inline int ivtv_use_dma(struct ivtv_stream *s)
46{
47 return !ivtv_use_pio(s);
48}
49
25static inline void ivtv_buf_sync_for_cpu(struct ivtv_stream *s, struct ivtv_buffer *buf) 50static inline void ivtv_buf_sync_for_cpu(struct ivtv_stream *s, struct ivtv_buffer *buf)
26{ 51{
27 if (s->dma != PCI_DMA_NONE) 52 if (ivtv_use_dma(s))
28 pci_dma_sync_single_for_cpu(s->itv->dev, buf->dma_handle, 53 pci_dma_sync_single_for_cpu(s->itv->dev, buf->dma_handle,
29 s->buf_size + 256, s->dma); 54 s->buf_size + 256, s->dma);
30} 55}
31 56
32static inline void ivtv_buf_sync_for_device(struct ivtv_stream *s, struct ivtv_buffer *buf) 57static inline void ivtv_buf_sync_for_device(struct ivtv_stream *s, struct ivtv_buffer *buf)
33{ 58{
34 if (s->dma != PCI_DMA_NONE) 59 if (ivtv_use_dma(s))
35 pci_dma_sync_single_for_device(s->itv->dev, buf->dma_handle, 60 pci_dma_sync_single_for_device(s->itv->dev, buf->dma_handle,
36 s->buf_size + 256, s->dma); 61 s->buf_size + 256, s->dma);
37} 62}
@@ -53,12 +78,14 @@ void ivtv_stream_free(struct ivtv_stream *s);
53 78
54static inline void ivtv_stream_sync_for_cpu(struct ivtv_stream *s) 79static inline void ivtv_stream_sync_for_cpu(struct ivtv_stream *s)
55{ 80{
56 pci_dma_sync_single_for_cpu(s->itv->dev, s->SG_handle, 81 if (ivtv_use_dma(s))
57 sizeof(struct ivtv_SG_element) * s->buffers, PCI_DMA_TODEVICE); 82 pci_dma_sync_single_for_cpu(s->itv->dev, s->SG_handle,
83 sizeof(struct ivtv_SG_element) * s->buffers, PCI_DMA_TODEVICE);
58} 84}
59 85
60static inline void ivtv_stream_sync_for_device(struct ivtv_stream *s) 86static inline void ivtv_stream_sync_for_device(struct ivtv_stream *s)
61{ 87{
62 pci_dma_sync_single_for_device(s->itv->dev, s->SG_handle, 88 if (ivtv_use_dma(s))
63 sizeof(struct ivtv_SG_element) * s->buffers, PCI_DMA_TODEVICE); 89 pci_dma_sync_single_for_device(s->itv->dev, s->SG_handle,
90 sizeof(struct ivtv_SG_element) * s->buffers, PCI_DMA_TODEVICE);
64} 91}
diff --git a/drivers/media/video/ivtv/ivtv-streams.c b/drivers/media/video/ivtv/ivtv-streams.c
index 01a41a844a30..6af88ae9295f 100644
--- a/drivers/media/video/ivtv/ivtv-streams.c
+++ b/drivers/media/video/ivtv/ivtv-streams.c
@@ -868,7 +868,7 @@ int ivtv_stop_v4l2_decode_stream(struct ivtv_stream *s, int flags, u64 pts)
868 if (!test_bit(IVTV_F_S_STREAMING, &s->s_flags)) 868 if (!test_bit(IVTV_F_S_STREAMING, &s->s_flags))
869 return 0; 869 return 0;
870 870
871 IVTV_DEBUG_INFO("Stop Decode at %llu, flags: %x\n", pts, flags); 871 IVTV_DEBUG_INFO("Stop Decode at %llu, flags: %x\n", (unsigned long long)pts, flags);
872 872
873 /* Stop Decoder */ 873 /* Stop Decoder */
874 if (!(flags & VIDEO_CMD_STOP_IMMEDIATELY) || pts) { 874 if (!(flags & VIDEO_CMD_STOP_IMMEDIATELY) || pts) {
diff --git a/drivers/media/video/ivtv/ivtv-vbi.c b/drivers/media/video/ivtv/ivtv-vbi.c
index 5efa5a867818..3ba46e07ea1f 100644
--- a/drivers/media/video/ivtv/ivtv-vbi.c
+++ b/drivers/media/video/ivtv/ivtv-vbi.c
@@ -450,7 +450,7 @@ void ivtv_disable_vbi(struct ivtv *itv)
450} 450}
451 451
452 452
453void vbi_work_handler(struct ivtv *itv) 453void ivtv_vbi_work_handler(struct ivtv *itv)
454{ 454{
455 struct v4l2_sliced_vbi_data data; 455 struct v4l2_sliced_vbi_data data;
456 456
diff --git a/drivers/media/video/ivtv/ivtv-vbi.h b/drivers/media/video/ivtv/ivtv-vbi.h
index cdaea697b3ec..ec211b49702c 100644
--- a/drivers/media/video/ivtv/ivtv-vbi.h
+++ b/drivers/media/video/ivtv/ivtv-vbi.h
@@ -23,4 +23,4 @@ void ivtv_process_vbi_data(struct ivtv *itv, struct ivtv_buffer *buf,
23int ivtv_used_line(struct ivtv *itv, int line, int field); 23int ivtv_used_line(struct ivtv *itv, int line, int field);
24void ivtv_disable_vbi(struct ivtv *itv); 24void ivtv_disable_vbi(struct ivtv *itv);
25void ivtv_set_vbi(unsigned long arg); 25void ivtv_set_vbi(unsigned long arg);
26void vbi_work_handler(struct ivtv *itv); 26void ivtv_vbi_work_handler(struct ivtv *itv);
diff --git a/drivers/media/video/saa7111.c b/drivers/media/video/saa7111.c
index 74839f98b7c4..c1a392e47170 100644
--- a/drivers/media/video/saa7111.c
+++ b/drivers/media/video/saa7111.c
@@ -75,10 +75,6 @@ struct saa7111 {
75 int norm; 75 int norm;
76 int input; 76 int input;
77 int enable; 77 int enable;
78 int bright;
79 int contrast;
80 int hue;
81 int sat;
82}; 78};
83 79
84#define I2C_SAA7111 0x48 80#define I2C_SAA7111 0x48
@@ -96,6 +92,17 @@ saa7111_write (struct i2c_client *client,
96 return i2c_smbus_write_byte_data(client, reg, value); 92 return i2c_smbus_write_byte_data(client, reg, value);
97} 93}
98 94
95static inline void
96saa7111_write_if_changed(struct i2c_client *client, u8 reg, u8 value)
97{
98 struct saa7111 *decoder = i2c_get_clientdata(client);
99
100 if (decoder->reg[reg] != value) {
101 decoder->reg[reg] = value;
102 i2c_smbus_write_byte_data(client, reg, value);
103 }
104}
105
99static int 106static int
100saa7111_write_block (struct i2c_client *client, 107saa7111_write_block (struct i2c_client *client,
101 const u8 *data, 108 const u8 *data,
@@ -439,28 +446,14 @@ saa7111_command (struct i2c_client *client,
439 { 446 {
440 struct video_picture *pic = arg; 447 struct video_picture *pic = arg;
441 448
442 if (decoder->bright != pic->brightness) { 449 /* We want 0 to 255 we get 0-65535 */
443 /* We want 0 to 255 we get 0-65535 */ 450 saa7111_write_if_changed(client, 0x0a, pic->brightness >> 8);
444 decoder->bright = pic->brightness; 451 /* We want 0 to 127 we get 0-65535 */
445 saa7111_write(client, 0x0a, decoder->bright >> 8); 452 saa7111_write(client, 0x0b, pic->contrast >> 9);
446 } 453 /* We want 0 to 127 we get 0-65535 */
447 if (decoder->contrast != pic->contrast) { 454 saa7111_write(client, 0x0c, pic->colour >> 9);
448 /* We want 0 to 127 we get 0-65535 */ 455 /* We want -128 to 127 we get 0-65535 */
449 decoder->contrast = pic->contrast; 456 saa7111_write(client, 0x0d, (pic->hue - 32768) >> 8);
450 saa7111_write(client, 0x0b,
451 decoder->contrast >> 9);
452 }
453 if (decoder->sat != pic->colour) {
454 /* We want 0 to 127 we get 0-65535 */
455 decoder->sat = pic->colour;
456 saa7111_write(client, 0x0c, decoder->sat >> 9);
457 }
458 if (decoder->hue != pic->hue) {
459 /* We want -128 to 127 we get 0-65535 */
460 decoder->hue = pic->hue;
461 saa7111_write(client, 0x0d,
462 (decoder->hue - 32768) >> 8);
463 }
464 } 457 }
465 break; 458 break;
466 459
@@ -524,10 +517,6 @@ saa7111_detect_client (struct i2c_adapter *adapter,
524 decoder->norm = VIDEO_MODE_NTSC; 517 decoder->norm = VIDEO_MODE_NTSC;
525 decoder->input = 0; 518 decoder->input = 0;
526 decoder->enable = 1; 519 decoder->enable = 1;
527 decoder->bright = 32768;
528 decoder->contrast = 32768;
529 decoder->hue = 32768;
530 decoder->sat = 32768;
531 i2c_set_clientdata(client, decoder); 520 i2c_set_clientdata(client, decoder);
532 521
533 i = i2c_attach_client(client); 522 i = i2c_attach_client(client);
diff --git a/drivers/media/video/usbvision/usbvision-core.c b/drivers/media/video/usbvision/usbvision-core.c
index 9118a6227ea6..7df071eb0a3b 100644
--- a/drivers/media/video/usbvision/usbvision-core.c
+++ b/drivers/media/video/usbvision/usbvision-core.c
@@ -1414,6 +1414,11 @@ static void usbvision_isocIrq(struct urb *urb)
1414 if (!USBVISION_IS_OPERATIONAL(usbvision)) 1414 if (!USBVISION_IS_OPERATIONAL(usbvision))
1415 return; 1415 return;
1416 1416
1417 /* any urb with wrong status is ignored without acknowledgement */
1418 if (urb->status == -ENOENT) {
1419 return;
1420 }
1421
1417 f = &usbvision->curFrame; 1422 f = &usbvision->curFrame;
1418 1423
1419 /* Manage streaming interruption */ 1424 /* Manage streaming interruption */
@@ -1436,18 +1441,21 @@ static void usbvision_isocIrq(struct urb *urb)
1436 if (usbvision->streaming == Stream_On) { 1441 if (usbvision->streaming == Stream_On) {
1437 1442
1438 /* If we collected enough data let's parse! */ 1443 /* If we collected enough data let's parse! */
1439 if (scratch_len(usbvision) > USBVISION_HEADER_LENGTH) { /* 12 == header_length */ 1444 if ((scratch_len(usbvision) > USBVISION_HEADER_LENGTH) &&
1440 /*If we don't have a frame we're current working on, complain */ 1445 (!list_empty(&(usbvision->inqueue))) ) {
1441 if(!list_empty(&(usbvision->inqueue))) { 1446 if (!(*f)) {
1442 if (!(*f)) { 1447 (*f) = list_entry(usbvision->inqueue.next,
1443 (*f) = list_entry(usbvision->inqueue.next,struct usbvision_frame, frame); 1448 struct usbvision_frame,
1444 } 1449 frame);
1445 usbvision_parse_data(usbvision);
1446 }
1447 else {
1448 PDEBUG(DBG_IRQ, "received data, but no one needs it");
1449 scratch_reset(usbvision);
1450 } 1450 }
1451 usbvision_parse_data(usbvision);
1452 }
1453 else {
1454 /*If we don't have a frame
1455 we're current working on, complain */
1456 PDEBUG(DBG_IRQ,
1457 "received data, but no one needs it");
1458 scratch_reset(usbvision);
1451 } 1459 }
1452 } 1460 }
1453 else { 1461 else {
@@ -1466,10 +1474,10 @@ static void usbvision_isocIrq(struct urb *urb)
1466 urb->dev = usbvision->dev; 1474 urb->dev = usbvision->dev;
1467 errCode = usb_submit_urb (urb, GFP_ATOMIC); 1475 errCode = usb_submit_urb (urb, GFP_ATOMIC);
1468 1476
1469 /* Disable this warning. By design of the driver. */ 1477 if(errCode) {
1470 // if(errCode) { 1478 err("%s: usb_submit_urb failed: error %d",
1471 // err("%s: usb_submit_urb failed: error %d", __FUNCTION__, errCode); 1479 __FUNCTION__, errCode);
1472 // } 1480 }
1473 1481
1474 return; 1482 return;
1475} 1483}
@@ -2394,7 +2402,7 @@ int usbvision_init_isoc(struct usb_usbvision *usbvision)
2394{ 2402{
2395 struct usb_device *dev = usbvision->dev; 2403 struct usb_device *dev = usbvision->dev;
2396 int bufIdx, errCode, regValue; 2404 int bufIdx, errCode, regValue;
2397 const int sb_size = USBVISION_URB_FRAMES * USBVISION_MAX_ISOC_PACKET_SIZE; 2405 int sb_size;
2398 2406
2399 if (!USBVISION_IS_OPERATIONAL(usbvision)) 2407 if (!USBVISION_IS_OPERATIONAL(usbvision))
2400 return -EFAULT; 2408 return -EFAULT;
@@ -2408,11 +2416,14 @@ int usbvision_init_isoc(struct usb_usbvision *usbvision)
2408 usbvision->last_error = errCode; 2416 usbvision->last_error = errCode;
2409 return -EBUSY; 2417 return -EBUSY;
2410 } 2418 }
2419 sb_size = USBVISION_URB_FRAMES * usbvision->isocPacketSize;
2411 2420
2412 regValue = (16 - usbvision_read_reg(usbvision, USBVISION_ALTER_REG)) & 0x0F; 2421 regValue = (16 - usbvision_read_reg(usbvision,
2422 USBVISION_ALTER_REG)) & 0x0F;
2413 2423
2414 usbvision->usb_bandwidth = regValue >> 1; 2424 usbvision->usb_bandwidth = regValue >> 1;
2415 PDEBUG(DBG_ISOC, "USB Bandwidth Usage: %dMbit/Sec", usbvision->usb_bandwidth); 2425 PDEBUG(DBG_ISOC, "USB Bandwidth Usage: %dMbit/Sec",
2426 usbvision->usb_bandwidth);
2416 2427
2417 2428
2418 2429
@@ -2428,7 +2439,11 @@ int usbvision_init_isoc(struct usb_usbvision *usbvision)
2428 return -ENOMEM; 2439 return -ENOMEM;
2429 } 2440 }
2430 usbvision->sbuf[bufIdx].urb = urb; 2441 usbvision->sbuf[bufIdx].urb = urb;
2431 usbvision->sbuf[bufIdx].data = usb_buffer_alloc(usbvision->dev, sb_size, GFP_KERNEL,&urb->transfer_dma); 2442 usbvision->sbuf[bufIdx].data =
2443 usb_buffer_alloc(usbvision->dev,
2444 sb_size,
2445 GFP_KERNEL,
2446 &urb->transfer_dma);
2432 urb->dev = dev; 2447 urb->dev = dev;
2433 urb->context = usbvision; 2448 urb->context = usbvision;
2434 urb->pipe = usb_rcvisocpipe(dev, usbvision->video_endp); 2449 urb->pipe = usb_rcvisocpipe(dev, usbvision->video_endp);
@@ -2442,21 +2457,26 @@ int usbvision_init_isoc(struct usb_usbvision *usbvision)
2442 for (j = k = 0; j < USBVISION_URB_FRAMES; j++, 2457 for (j = k = 0; j < USBVISION_URB_FRAMES; j++,
2443 k += usbvision->isocPacketSize) { 2458 k += usbvision->isocPacketSize) {
2444 urb->iso_frame_desc[j].offset = k; 2459 urb->iso_frame_desc[j].offset = k;
2445 urb->iso_frame_desc[j].length = usbvision->isocPacketSize; 2460 urb->iso_frame_desc[j].length =
2461 usbvision->isocPacketSize;
2446 } 2462 }
2447 } 2463 }
2448 2464
2449 2465
2450 /* Submit all URBs */ 2466 /* Submit all URBs */
2451 for (bufIdx = 0; bufIdx < USBVISION_NUMSBUF; bufIdx++) { 2467 for (bufIdx = 0; bufIdx < USBVISION_NUMSBUF; bufIdx++) {
2452 errCode = usb_submit_urb(usbvision->sbuf[bufIdx].urb, GFP_KERNEL); 2468 errCode = usb_submit_urb(usbvision->sbuf[bufIdx].urb,
2469 GFP_KERNEL);
2453 if (errCode) { 2470 if (errCode) {
2454 err("%s: usb_submit_urb(%d) failed: error %d", __FUNCTION__, bufIdx, errCode); 2471 err("%s: usb_submit_urb(%d) failed: error %d",
2472 __FUNCTION__, bufIdx, errCode);
2455 } 2473 }
2456 } 2474 }
2457 2475
2458 usbvision->streaming = Stream_Idle; 2476 usbvision->streaming = Stream_Idle;
2459 PDEBUG(DBG_ISOC, "%s: streaming=1 usbvision->video_endp=$%02x", __FUNCTION__, usbvision->video_endp); 2477 PDEBUG(DBG_ISOC, "%s: streaming=1 usbvision->video_endp=$%02x",
2478 __FUNCTION__,
2479 usbvision->video_endp);
2460 return 0; 2480 return 0;
2461} 2481}
2462 2482
@@ -2470,7 +2490,7 @@ int usbvision_init_isoc(struct usb_usbvision *usbvision)
2470void usbvision_stop_isoc(struct usb_usbvision *usbvision) 2490void usbvision_stop_isoc(struct usb_usbvision *usbvision)
2471{ 2491{
2472 int bufIdx, errCode, regValue; 2492 int bufIdx, errCode, regValue;
2473 const int sb_size = USBVISION_URB_FRAMES * USBVISION_MAX_ISOC_PACKET_SIZE; 2493 int sb_size = USBVISION_URB_FRAMES * usbvision->isocPacketSize;
2474 2494
2475 if ((usbvision->streaming == Stream_Off) || (usbvision->dev == NULL)) 2495 if ((usbvision->streaming == Stream_Off) || (usbvision->dev == NULL))
2476 return; 2496 return;
@@ -2499,15 +2519,19 @@ void usbvision_stop_isoc(struct usb_usbvision *usbvision)
2499 errCode = usb_set_interface(usbvision->dev, usbvision->iface, 2519 errCode = usb_set_interface(usbvision->dev, usbvision->iface,
2500 usbvision->ifaceAlt); 2520 usbvision->ifaceAlt);
2501 if (errCode < 0) { 2521 if (errCode < 0) {
2502 err("%s: usb_set_interface() failed: error %d", __FUNCTION__, errCode); 2522 err("%s: usb_set_interface() failed: error %d",
2523 __FUNCTION__, errCode);
2503 usbvision->last_error = errCode; 2524 usbvision->last_error = errCode;
2504 } 2525 }
2505 regValue = (16 - usbvision_read_reg(usbvision, USBVISION_ALTER_REG)) & 0x0F; 2526 regValue = (16-usbvision_read_reg(usbvision, USBVISION_ALTER_REG)) & 0x0F;
2506 usbvision->isocPacketSize = (regValue == 0) ? 0 : (regValue * 64) - 1; 2527 usbvision->isocPacketSize =
2507 PDEBUG(DBG_ISOC, "ISO Packet Length:%d", usbvision->isocPacketSize); 2528 (regValue == 0) ? 0 : (regValue * 64) - 1;
2529 PDEBUG(DBG_ISOC, "ISO Packet Length:%d",
2530 usbvision->isocPacketSize);
2508 2531
2509 usbvision->usb_bandwidth = regValue >> 1; 2532 usbvision->usb_bandwidth = regValue >> 1;
2510 PDEBUG(DBG_ISOC, "USB Bandwidth Usage: %dMbit/Sec", usbvision->usb_bandwidth); 2533 PDEBUG(DBG_ISOC, "USB Bandwidth Usage: %dMbit/Sec",
2534 usbvision->usb_bandwidth);
2511 } 2535 }
2512} 2536}
2513 2537
diff --git a/drivers/media/video/usbvision/usbvision.h b/drivers/media/video/usbvision/usbvision.h
index bd6f6422ed54..c759d00d7014 100644
--- a/drivers/media/video/usbvision/usbvision.h
+++ b/drivers/media/video/usbvision/usbvision.h
@@ -146,7 +146,6 @@
146#define USBVISION_CLIPMASK_SIZE (MAX_FRAME_WIDTH * MAX_FRAME_HEIGHT / 8) //bytesize of clipmask 146#define USBVISION_CLIPMASK_SIZE (MAX_FRAME_WIDTH * MAX_FRAME_HEIGHT / 8) //bytesize of clipmask
147 147
148#define USBVISION_URB_FRAMES 32 148#define USBVISION_URB_FRAMES 32
149#define USBVISION_MAX_ISOC_PACKET_SIZE 959 // NT1003 Specs Document says 1023
150 149
151#define USBVISION_NUM_HEADERMARKER 20 150#define USBVISION_NUM_HEADERMARKER 20
152#define USBVISION_NUMFRAMES 3 /* Maximum number of frames an application can get */ 151#define USBVISION_NUMFRAMES 3 /* Maximum number of frames an application can get */
diff --git a/drivers/mmc/core/sd.c b/drivers/mmc/core/sd.c
index c1dfd03d559a..41bfb5dfe6ff 100644
--- a/drivers/mmc/core/sd.c
+++ b/drivers/mmc/core/sd.c
@@ -15,6 +15,7 @@
15#include <linux/mmc/host.h> 15#include <linux/mmc/host.h>
16#include <linux/mmc/card.h> 16#include <linux/mmc/card.h>
17#include <linux/mmc/mmc.h> 17#include <linux/mmc/mmc.h>
18#include <linux/mmc/sd.h>
18 19
19#include "core.h" 20#include "core.h"
20#include "sysfs.h" 21#include "sysfs.h"
@@ -192,6 +193,16 @@ static int mmc_read_switch(struct mmc_card *card)
192 int err; 193 int err;
193 u8 *status; 194 u8 *status;
194 195
196 if (card->scr.sda_vsn < SCR_SPEC_VER_1)
197 return MMC_ERR_NONE;
198
199 if (!(card->csd.cmdclass & CCC_SWITCH)) {
200 printk(KERN_WARNING "%s: card lacks mandatory switch "
201 "function, performance might suffer.\n",
202 mmc_hostname(card->host));
203 return MMC_ERR_NONE;
204 }
205
195 err = MMC_ERR_FAILED; 206 err = MMC_ERR_FAILED;
196 207
197 status = kmalloc(64, GFP_KERNEL); 208 status = kmalloc(64, GFP_KERNEL);
@@ -204,10 +215,9 @@ static int mmc_read_switch(struct mmc_card *card)
204 215
205 err = mmc_sd_switch(card, 0, 0, 1, status); 216 err = mmc_sd_switch(card, 0, 0, 1, status);
206 if (err != MMC_ERR_NONE) { 217 if (err != MMC_ERR_NONE) {
207 /* 218 printk(KERN_WARNING "%s: problem reading switch "
208 * Card not supporting high-speed will ignore the 219 "capabilities, performance might suffer.\n",
209 * command. 220 mmc_hostname(card->host));
210 */
211 err = MMC_ERR_NONE; 221 err = MMC_ERR_NONE;
212 goto out; 222 goto out;
213 } 223 }
@@ -229,6 +239,12 @@ static int mmc_switch_hs(struct mmc_card *card)
229 int err; 239 int err;
230 u8 *status; 240 u8 *status;
231 241
242 if (card->scr.sda_vsn < SCR_SPEC_VER_1)
243 return MMC_ERR_NONE;
244
245 if (!(card->csd.cmdclass & CCC_SWITCH))
246 return MMC_ERR_NONE;
247
232 if (!(card->host->caps & MMC_CAP_SD_HIGHSPEED)) 248 if (!(card->host->caps & MMC_CAP_SD_HIGHSPEED))
233 return MMC_ERR_NONE; 249 return MMC_ERR_NONE;
234 250
@@ -402,7 +418,7 @@ static int mmc_sd_init_card(struct mmc_host *host, u32 ocr,
402 /* 418 /*
403 * Switch to wider bus (if supported). 419 * Switch to wider bus (if supported).
404 */ 420 */
405 if ((host->caps && MMC_CAP_4_BIT_DATA) && 421 if ((host->caps & MMC_CAP_4_BIT_DATA) &&
406 (card->scr.bus_widths & SD_SCR_BUS_WIDTH_4)) { 422 (card->scr.bus_widths & SD_SCR_BUS_WIDTH_4)) {
407 err = mmc_app_set_bus_width(card, MMC_BUS_WIDTH_4); 423 err = mmc_app_set_bus_width(card, MMC_BUS_WIDTH_4);
408 if (err != MMC_ERR_NONE) 424 if (err != MMC_ERR_NONE)
diff --git a/drivers/mmc/host/at91_mci.c b/drivers/mmc/host/at91_mci.c
index e37943c314cb..5b00c194b628 100644
--- a/drivers/mmc/host/at91_mci.c
+++ b/drivers/mmc/host/at91_mci.c
@@ -417,7 +417,7 @@ static unsigned int at91_mci_send_command(struct at91mci_host *host, struct mmc_
417 blocks = 0; 417 blocks = 0;
418 } 418 }
419 419
420 if (cmd->opcode == MMC_STOP_TRANSMISSION) 420 if (host->flags & FL_SENT_STOP)
421 cmdr |= AT91_MCI_TRCMD_STOP; 421 cmdr |= AT91_MCI_TRCMD_STOP;
422 422
423 if (host->bus_mode == MMC_BUSMODE_OPENDRAIN) 423 if (host->bus_mode == MMC_BUSMODE_OPENDRAIN)
@@ -563,8 +563,7 @@ static void at91mci_completed_command(struct at91mci_host *host)
563 if (status & (AT91_MCI_RINDE | AT91_MCI_RDIRE | AT91_MCI_RCRCE | 563 if (status & (AT91_MCI_RINDE | AT91_MCI_RDIRE | AT91_MCI_RCRCE |
564 AT91_MCI_RENDE | AT91_MCI_RTOE | AT91_MCI_DCRCE | 564 AT91_MCI_RENDE | AT91_MCI_RTOE | AT91_MCI_DCRCE |
565 AT91_MCI_DTOE | AT91_MCI_OVRE | AT91_MCI_UNRE)) { 565 AT91_MCI_DTOE | AT91_MCI_OVRE | AT91_MCI_UNRE)) {
566 if ((status & AT91_MCI_RCRCE) && 566 if ((status & AT91_MCI_RCRCE) && !(mmc_resp_type(cmd) & MMC_RSP_CRC)) {
567 ((cmd->opcode == MMC_SEND_OP_COND) || (cmd->opcode == SD_APP_OP_COND))) {
568 cmd->error = MMC_ERR_NONE; 567 cmd->error = MMC_ERR_NONE;
569 } 568 }
570 else { 569 else {
diff --git a/drivers/mmc/host/au1xmmc.c b/drivers/mmc/host/au1xmmc.c
index f967226d7505..52b63f11ddd6 100644
--- a/drivers/mmc/host/au1xmmc.c
+++ b/drivers/mmc/host/au1xmmc.c
@@ -76,8 +76,7 @@ const struct {
76#endif 76#endif
77}; 77};
78 78
79#define AU1XMMC_CONTROLLER_COUNT \ 79#define AU1XMMC_CONTROLLER_COUNT (ARRAY_SIZE(au1xmmc_card_table))
80 (sizeof(au1xmmc_card_table) / sizeof(au1xmmc_card_table[0]))
81 80
82/* This array stores pointers for the hosts (used by the IRQ handler) */ 81/* This array stores pointers for the hosts (used by the IRQ handler) */
83struct au1xmmc_host *au1xmmc_hosts[AU1XMMC_CONTROLLER_COUNT]; 82struct au1xmmc_host *au1xmmc_hosts[AU1XMMC_CONTROLLER_COUNT];
diff --git a/drivers/net/mlx4/cq.c b/drivers/net/mlx4/cq.c
index 437d78ad0912..39253d0c1590 100644
--- a/drivers/net/mlx4/cq.c
+++ b/drivers/net/mlx4/cq.c
@@ -61,7 +61,7 @@ struct mlx4_cq_context {
61 __be32 solicit_producer_index; 61 __be32 solicit_producer_index;
62 __be32 consumer_index; 62 __be32 consumer_index;
63 __be32 producer_index; 63 __be32 producer_index;
64 u8 reserved6[2]; 64 u32 reserved6[2];
65 __be64 db_rec_addr; 65 __be64 db_rec_addr;
66}; 66};
67 67
diff --git a/drivers/net/mlx4/eq.c b/drivers/net/mlx4/eq.c
index 0f11adb8eb4a..27a82cecd693 100644
--- a/drivers/net/mlx4/eq.c
+++ b/drivers/net/mlx4/eq.c
@@ -490,9 +490,11 @@ static void mlx4_free_irqs(struct mlx4_dev *dev)
490 490
491 if (eq_table->have_irq) 491 if (eq_table->have_irq)
492 free_irq(dev->pdev->irq, dev); 492 free_irq(dev->pdev->irq, dev);
493 for (i = 0; i < MLX4_NUM_EQ; ++i) 493 for (i = 0; i < MLX4_EQ_CATAS; ++i)
494 if (eq_table->eq[i].have_irq) 494 if (eq_table->eq[i].have_irq)
495 free_irq(eq_table->eq[i].irq, eq_table->eq + i); 495 free_irq(eq_table->eq[i].irq, eq_table->eq + i);
496 if (eq_table->eq[MLX4_EQ_CATAS].have_irq)
497 free_irq(eq_table->eq[MLX4_EQ_CATAS].irq, dev);
496} 498}
497 499
498static int __devinit mlx4_map_clr_int(struct mlx4_dev *dev) 500static int __devinit mlx4_map_clr_int(struct mlx4_dev *dev)
diff --git a/drivers/net/mlx4/fw.c b/drivers/net/mlx4/fw.c
index cfa5cc072339..e7ca118c8dfd 100644
--- a/drivers/net/mlx4/fw.c
+++ b/drivers/net/mlx4/fw.c
@@ -37,6 +37,10 @@
37#include "fw.h" 37#include "fw.h"
38#include "icm.h" 38#include "icm.h"
39 39
40enum {
41 MLX4_COMMAND_INTERFACE_REV = 1
42};
43
40extern void __buggy_use_of_MLX4_GET(void); 44extern void __buggy_use_of_MLX4_GET(void);
41extern void __buggy_use_of_MLX4_PUT(void); 45extern void __buggy_use_of_MLX4_PUT(void);
42 46
@@ -452,10 +456,12 @@ int mlx4_QUERY_FW(struct mlx4_dev *dev)
452 u32 *outbox; 456 u32 *outbox;
453 int err = 0; 457 int err = 0;
454 u64 fw_ver; 458 u64 fw_ver;
459 u16 cmd_if_rev;
455 u8 lg; 460 u8 lg;
456 461
457#define QUERY_FW_OUT_SIZE 0x100 462#define QUERY_FW_OUT_SIZE 0x100
458#define QUERY_FW_VER_OFFSET 0x00 463#define QUERY_FW_VER_OFFSET 0x00
464#define QUERY_FW_CMD_IF_REV_OFFSET 0x0a
459#define QUERY_FW_MAX_CMD_OFFSET 0x0f 465#define QUERY_FW_MAX_CMD_OFFSET 0x0f
460#define QUERY_FW_ERR_START_OFFSET 0x30 466#define QUERY_FW_ERR_START_OFFSET 0x30
461#define QUERY_FW_ERR_SIZE_OFFSET 0x38 467#define QUERY_FW_ERR_SIZE_OFFSET 0x38
@@ -477,21 +483,36 @@ int mlx4_QUERY_FW(struct mlx4_dev *dev)
477 483
478 MLX4_GET(fw_ver, outbox, QUERY_FW_VER_OFFSET); 484 MLX4_GET(fw_ver, outbox, QUERY_FW_VER_OFFSET);
479 /* 485 /*
480 * FW subminor version is at more signifant bits than minor 486 * FW subminor version is at more significant bits than minor
481 * version, so swap here. 487 * version, so swap here.
482 */ 488 */
483 dev->caps.fw_ver = (fw_ver & 0xffff00000000ull) | 489 dev->caps.fw_ver = (fw_ver & 0xffff00000000ull) |
484 ((fw_ver & 0xffff0000ull) >> 16) | 490 ((fw_ver & 0xffff0000ull) >> 16) |
485 ((fw_ver & 0x0000ffffull) << 16); 491 ((fw_ver & 0x0000ffffull) << 16);
486 492
493 MLX4_GET(cmd_if_rev, outbox, QUERY_FW_CMD_IF_REV_OFFSET);
494 if (cmd_if_rev != MLX4_COMMAND_INTERFACE_REV) {
495 mlx4_err(dev, "Installed FW has unsupported "
496 "command interface revision %d.\n",
497 cmd_if_rev);
498 mlx4_err(dev, "(Installed FW version is %d.%d.%03d)\n",
499 (int) (dev->caps.fw_ver >> 32),
500 (int) (dev->caps.fw_ver >> 16) & 0xffff,
501 (int) dev->caps.fw_ver & 0xffff);
502 mlx4_err(dev, "This driver version supports only revision %d.\n",
503 MLX4_COMMAND_INTERFACE_REV);
504 err = -ENODEV;
505 goto out;
506 }
507
487 MLX4_GET(lg, outbox, QUERY_FW_MAX_CMD_OFFSET); 508 MLX4_GET(lg, outbox, QUERY_FW_MAX_CMD_OFFSET);
488 cmd->max_cmds = 1 << lg; 509 cmd->max_cmds = 1 << lg;
489 510
490 mlx4_dbg(dev, "FW version %d.%d.%03d, max commands %d\n", 511 mlx4_dbg(dev, "FW version %d.%d.%03d (cmd intf rev %d), max commands %d\n",
491 (int) (dev->caps.fw_ver >> 32), 512 (int) (dev->caps.fw_ver >> 32),
492 (int) (dev->caps.fw_ver >> 16) & 0xffff, 513 (int) (dev->caps.fw_ver >> 16) & 0xffff,
493 (int) dev->caps.fw_ver & 0xffff, 514 (int) dev->caps.fw_ver & 0xffff,
494 cmd->max_cmds); 515 cmd_if_rev, cmd->max_cmds);
495 516
496 MLX4_GET(fw->catas_offset, outbox, QUERY_FW_ERR_START_OFFSET); 517 MLX4_GET(fw->catas_offset, outbox, QUERY_FW_ERR_START_OFFSET);
497 MLX4_GET(fw->catas_size, outbox, QUERY_FW_ERR_SIZE_OFFSET); 518 MLX4_GET(fw->catas_size, outbox, QUERY_FW_ERR_SIZE_OFFSET);
diff --git a/drivers/net/mlx4/intf.c b/drivers/net/mlx4/intf.c
index 65854f9e9c76..9ae951bf6aa6 100644
--- a/drivers/net/mlx4/intf.c
+++ b/drivers/net/mlx4/intf.c
@@ -135,9 +135,6 @@ int mlx4_register_device(struct mlx4_dev *dev)
135 struct mlx4_priv *priv = mlx4_priv(dev); 135 struct mlx4_priv *priv = mlx4_priv(dev);
136 struct mlx4_interface *intf; 136 struct mlx4_interface *intf;
137 137
138 INIT_LIST_HEAD(&priv->ctx_list);
139 spin_lock_init(&priv->ctx_lock);
140
141 mutex_lock(&intf_mutex); 138 mutex_lock(&intf_mutex);
142 139
143 list_add_tail(&priv->dev_list, &dev_list); 140 list_add_tail(&priv->dev_list, &dev_list);
diff --git a/drivers/net/mlx4/main.c b/drivers/net/mlx4/main.c
index 20b8c0d3ced4..d4172937025b 100644
--- a/drivers/net/mlx4/main.c
+++ b/drivers/net/mlx4/main.c
@@ -787,6 +787,8 @@ static int __devinit mlx4_init_one(struct pci_dev *pdev,
787 787
788 dev = &priv->dev; 788 dev = &priv->dev;
789 dev->pdev = pdev; 789 dev->pdev = pdev;
790 INIT_LIST_HEAD(&priv->ctx_list);
791 spin_lock_init(&priv->ctx_lock);
790 792
791 /* 793 /*
792 * Now reset the HCA before we touch the PCI capabilities or 794 * Now reset the HCA before we touch the PCI capabilities or
diff --git a/drivers/net/mlx4/mr.c b/drivers/net/mlx4/mr.c
index b33864dab179..d0808fa3ec82 100644
--- a/drivers/net/mlx4/mr.c
+++ b/drivers/net/mlx4/mr.c
@@ -324,15 +324,17 @@ int mlx4_mr_enable(struct mlx4_dev *dev, struct mlx4_mr *mr)
324 MLX4_MPT_FLAG_MIO | 324 MLX4_MPT_FLAG_MIO |
325 MLX4_MPT_FLAG_REGION | 325 MLX4_MPT_FLAG_REGION |
326 mr->access); 326 mr->access);
327 if (mr->mtt.order < 0)
328 mpt_entry->flags |= cpu_to_be32(MLX4_MPT_FLAG_PHYSICAL);
329 327
330 mpt_entry->key = cpu_to_be32(key_to_hw_index(mr->key)); 328 mpt_entry->key = cpu_to_be32(key_to_hw_index(mr->key));
331 mpt_entry->pd = cpu_to_be32(mr->pd); 329 mpt_entry->pd = cpu_to_be32(mr->pd);
332 mpt_entry->start = cpu_to_be64(mr->iova); 330 mpt_entry->start = cpu_to_be64(mr->iova);
333 mpt_entry->length = cpu_to_be64(mr->size); 331 mpt_entry->length = cpu_to_be64(mr->size);
334 mpt_entry->entity_size = cpu_to_be32(mr->mtt.page_shift); 332 mpt_entry->entity_size = cpu_to_be32(mr->mtt.page_shift);
335 mpt_entry->mtt_seg = cpu_to_be64(mlx4_mtt_addr(dev, &mr->mtt)); 333 if (mr->mtt.order < 0) {
334 mpt_entry->flags |= cpu_to_be32(MLX4_MPT_FLAG_PHYSICAL);
335 mpt_entry->mtt_seg = 0;
336 } else
337 mpt_entry->mtt_seg = cpu_to_be64(mlx4_mtt_addr(dev, &mr->mtt));
336 338
337 err = mlx4_SW2HW_MPT(dev, mailbox, 339 err = mlx4_SW2HW_MPT(dev, mailbox,
338 key_to_hw_index(mr->key) & (dev->caps.num_mpts - 1)); 340 key_to_hw_index(mr->key) & (dev->caps.num_mpts - 1));
diff --git a/fs/cifs/cifs_debug.c b/fs/cifs/cifs_debug.c
index 6017c465440e..07838b2ac1ce 100644
--- a/fs/cifs/cifs_debug.c
+++ b/fs/cifs/cifs_debug.c
@@ -7,16 +7,16 @@
7 * 7 *
8 * This program is free software; you can redistribute it and/or modify 8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by 9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or 10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version. 11 * (at your option) any later version.
12 * 12 *
13 * This program is distributed in the hope that it will be useful, 13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
16 * the GNU General Public License for more details. 16 * the GNU General Public License for more details.
17 * 17 *
18 * You should have received a copy of the GNU General Public License 18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software 19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 */ 21 */
22#include <linux/fs.h> 22#include <linux/fs.h>
@@ -39,7 +39,7 @@ cifs_dump_mem(char *label, void *data, int length)
39 char *charptr = data; 39 char *charptr = data;
40 char buf[10], line[80]; 40 char buf[10], line[80];
41 41
42 printk(KERN_DEBUG "%s: dump of %d bytes of data at 0x%p\n", 42 printk(KERN_DEBUG "%s: dump of %d bytes of data at 0x%p\n",
43 label, length, data); 43 label, length, data);
44 for (i = 0; i < length; i += 16) { 44 for (i = 0; i < length; i += 16) {
45 line[0] = 0; 45 line[0] = 0;
@@ -60,10 +60,10 @@ cifs_dump_mem(char *label, void *data, int length)
60#ifdef CONFIG_CIFS_DEBUG2 60#ifdef CONFIG_CIFS_DEBUG2
61void cifs_dump_detail(struct smb_hdr * smb) 61void cifs_dump_detail(struct smb_hdr * smb)
62{ 62{
63 cERROR(1,("Cmd: %d Err: 0x%x Flags: 0x%x Flgs2: 0x%x Mid: %d Pid: %d", 63 cERROR(1, ("Cmd: %d Err: 0x%x Flags: 0x%x Flgs2: 0x%x Mid: %d Pid: %d",
64 smb->Command, smb->Status.CifsError, 64 smb->Command, smb->Status.CifsError,
65 smb->Flags, smb->Flags2, smb->Mid, smb->Pid)); 65 smb->Flags, smb->Flags2, smb->Mid, smb->Pid));
66 cERROR(1,("smb buf %p len %d", smb, smbCalcSize_LE(smb))); 66 cERROR(1, ("smb buf %p len %d", smb, smbCalcSize_LE(smb)));
67} 67}
68 68
69 69
@@ -72,36 +72,35 @@ void cifs_dump_mids(struct TCP_Server_Info * server)
72 struct list_head *tmp; 72 struct list_head *tmp;
73 struct mid_q_entry * mid_entry; 73 struct mid_q_entry * mid_entry;
74 74
75 if(server == NULL) 75 if (server == NULL)
76 return; 76 return;
77 77
78 cERROR(1,("Dump pending requests:")); 78 cERROR(1, ("Dump pending requests:"));
79 spin_lock(&GlobalMid_Lock); 79 spin_lock(&GlobalMid_Lock);
80 list_for_each(tmp, &server->pending_mid_q) { 80 list_for_each(tmp, &server->pending_mid_q) {
81 mid_entry = list_entry(tmp, struct mid_q_entry, qhead); 81 mid_entry = list_entry(tmp, struct mid_q_entry, qhead);
82 if(mid_entry) { 82 if (mid_entry) {
83 cERROR(1,("State: %d Cmd: %d Pid: %d Tsk: %p Mid %d", 83 cERROR(1, ("State: %d Cmd: %d Pid: %d Tsk: %p Mid %d",
84 mid_entry->midState, 84 mid_entry->midState,
85 (int)mid_entry->command, 85 (int)mid_entry->command,
86 mid_entry->pid, 86 mid_entry->pid,
87 mid_entry->tsk, 87 mid_entry->tsk,
88 mid_entry->mid)); 88 mid_entry->mid));
89#ifdef CONFIG_CIFS_STATS2 89#ifdef CONFIG_CIFS_STATS2
90 cERROR(1,("IsLarge: %d buf: %p time rcv: %ld now: %ld", 90 cERROR(1, ("IsLarge: %d buf: %p time rcv: %ld now: %ld",
91 mid_entry->largeBuf, 91 mid_entry->largeBuf,
92 mid_entry->resp_buf, 92 mid_entry->resp_buf,
93 mid_entry->when_received, 93 mid_entry->when_received,
94 jiffies)); 94 jiffies));
95#endif /* STATS2 */ 95#endif /* STATS2 */
96 cERROR(1,("IsMult: %d IsEnd: %d", mid_entry->multiRsp, 96 cERROR(1, ("IsMult: %d IsEnd: %d", mid_entry->multiRsp,
97 mid_entry->multiEnd)); 97 mid_entry->multiEnd));
98 if(mid_entry->resp_buf) { 98 if (mid_entry->resp_buf) {
99 cifs_dump_detail(mid_entry->resp_buf); 99 cifs_dump_detail(mid_entry->resp_buf);
100 cifs_dump_mem("existing buf: ", 100 cifs_dump_mem("existing buf: ",
101 mid_entry->resp_buf, 101 mid_entry->resp_buf,
102 62 /* fixme */); 102 62 /* fixme */);
103 } 103 }
104
105 } 104 }
106 } 105 }
107 spin_unlock(&GlobalMid_Lock); 106 spin_unlock(&GlobalMid_Lock);
@@ -129,9 +128,10 @@ cifs_debug_data_read(char *buf, char **beginBuffer, off_t offset,
129 "Display Internal CIFS Data Structures for Debugging\n" 128 "Display Internal CIFS Data Structures for Debugging\n"
130 "---------------------------------------------------\n"); 129 "---------------------------------------------------\n");
131 buf += length; 130 buf += length;
132 length = sprintf(buf,"CIFS Version %s\n",CIFS_VERSION); 131 length = sprintf(buf, "CIFS Version %s\n", CIFS_VERSION);
133 buf += length; 132 buf += length;
134 length = sprintf(buf,"Active VFS Requests: %d\n", GlobalTotalActiveXid); 133 length = sprintf(buf,
134 "Active VFS Requests: %d\n", GlobalTotalActiveXid);
135 buf += length; 135 buf += length;
136 length = sprintf(buf, "Servers:"); 136 length = sprintf(buf, "Servers:");
137 buf += length; 137 buf += length;
@@ -141,7 +141,7 @@ cifs_debug_data_read(char *buf, char **beginBuffer, off_t offset,
141 list_for_each(tmp, &GlobalSMBSessionList) { 141 list_for_each(tmp, &GlobalSMBSessionList) {
142 i++; 142 i++;
143 ses = list_entry(tmp, struct cifsSesInfo, cifsSessionList); 143 ses = list_entry(tmp, struct cifsSesInfo, cifsSessionList);
144 if((ses->serverDomain == NULL) || (ses->serverOS == NULL) || 144 if ((ses->serverDomain == NULL) || (ses->serverOS == NULL) ||
145 (ses->serverNOS == NULL)) { 145 (ses->serverNOS == NULL)) {
146 buf += sprintf(buf, "\nentry for %s not fully " 146 buf += sprintf(buf, "\nentry for %s not fully "
147 "displayed\n\t", ses->serverName); 147 "displayed\n\t", ses->serverName);
@@ -149,15 +149,18 @@ cifs_debug_data_read(char *buf, char **beginBuffer, off_t offset,
149 } else { 149 } else {
150 length = 150 length =
151 sprintf(buf, 151 sprintf(buf,
152 "\n%d) Name: %s Domain: %s Mounts: %d OS: %s \n\tNOS: %s\tCapability: 0x%x\n\tSMB session status: %d\t", 152 "\n%d) Name: %s Domain: %s Mounts: %d OS:"
153 " %s \n\tNOS: %s\tCapability: 0x%x\n\tSMB"
154 " session status: %d\t",
153 i, ses->serverName, ses->serverDomain, 155 i, ses->serverName, ses->serverDomain,
154 atomic_read(&ses->inUse), 156 atomic_read(&ses->inUse),
155 ses->serverOS, ses->serverNOS, 157 ses->serverOS, ses->serverNOS,
156 ses->capabilities,ses->status); 158 ses->capabilities, ses->status);
157 buf += length; 159 buf += length;
158 } 160 }
159 if(ses->server) { 161 if (ses->server) {
160 buf += sprintf(buf, "TCP status: %d\n\tLocal Users To Server: %d SecMode: 0x%x Req On Wire: %d", 162 buf += sprintf(buf, "TCP status: %d\n\tLocal Users To "
163 "Server: %d SecMode: 0x%x Req On Wire: %d",
161 ses->server->tcpStatus, 164 ses->server->tcpStatus,
162 atomic_read(&ses->server->socketUseCount), 165 atomic_read(&ses->server->socketUseCount),
163 ses->server->secMode, 166 ses->server->secMode,
@@ -165,7 +168,7 @@ cifs_debug_data_read(char *buf, char **beginBuffer, off_t offset,
165 168
166#ifdef CONFIG_CIFS_STATS2 169#ifdef CONFIG_CIFS_STATS2
167 buf += sprintf(buf, " In Send: %d In MaxReq Wait: %d", 170 buf += sprintf(buf, " In Send: %d In MaxReq Wait: %d",
168 atomic_read(&ses->server->inSend), 171 atomic_read(&ses->server->inSend),
169 atomic_read(&ses->server->num_waiters)); 172 atomic_read(&ses->server->num_waiters));
170#endif 173#endif
171 174
@@ -177,17 +180,19 @@ cifs_debug_data_read(char *buf, char **beginBuffer, off_t offset,
177 mid_entry = list_entry(tmp1, struct 180 mid_entry = list_entry(tmp1, struct
178 mid_q_entry, 181 mid_q_entry,
179 qhead); 182 qhead);
180 if(mid_entry) { 183 if (mid_entry) {
181 length = sprintf(buf,"State: %d com: %d pid: %d tsk: %p mid %d\n", 184 length = sprintf(buf,
182 mid_entry->midState, 185 "State: %d com: %d pid:"
183 (int)mid_entry->command, 186 " %d tsk: %p mid %d\n",
184 mid_entry->pid, 187 mid_entry->midState,
185 mid_entry->tsk, 188 (int)mid_entry->command,
186 mid_entry->mid); 189 mid_entry->pid,
190 mid_entry->tsk,
191 mid_entry->mid);
187 buf += length; 192 buf += length;
188 } 193 }
189 } 194 }
190 spin_unlock(&GlobalMid_Lock); 195 spin_unlock(&GlobalMid_Lock);
191 } 196 }
192 197
193 } 198 }
@@ -207,7 +212,8 @@ cifs_debug_data_read(char *buf, char **beginBuffer, off_t offset,
207 dev_type = le32_to_cpu(tcon->fsDevInfo.DeviceType); 212 dev_type = le32_to_cpu(tcon->fsDevInfo.DeviceType);
208 length = 213 length =
209 sprintf(buf, 214 sprintf(buf,
210 "\n%d) %s Uses: %d Type: %s DevInfo: 0x%x Attributes: 0x%x\nPathComponentMax: %d Status: %d", 215 "\n%d) %s Uses: %d Type: %s DevInfo: 0x%x "
216 "Attributes: 0x%x\nPathComponentMax: %d Status: %d",
211 i, tcon->treeName, 217 i, tcon->treeName,
212 atomic_read(&tcon->useCount), 218 atomic_read(&tcon->useCount),
213 tcon->nativeFileSystem, 219 tcon->nativeFileSystem,
@@ -215,7 +221,7 @@ cifs_debug_data_read(char *buf, char **beginBuffer, off_t offset,
215 le32_to_cpu(tcon->fsAttrInfo.Attributes), 221 le32_to_cpu(tcon->fsAttrInfo.Attributes),
216 le32_to_cpu(tcon->fsAttrInfo.MaxPathNameComponentLength), 222 le32_to_cpu(tcon->fsAttrInfo.MaxPathNameComponentLength),
217 tcon->tidStatus); 223 tcon->tidStatus);
218 buf += length; 224 buf += length;
219 if (dev_type == FILE_DEVICE_DISK) 225 if (dev_type == FILE_DEVICE_DISK)
220 length = sprintf(buf, " type: DISK "); 226 length = sprintf(buf, " type: DISK ");
221 else if (dev_type == FILE_DEVICE_CD_ROM) 227 else if (dev_type == FILE_DEVICE_CD_ROM)
@@ -224,7 +230,7 @@ cifs_debug_data_read(char *buf, char **beginBuffer, off_t offset,
224 length = 230 length =
225 sprintf(buf, " type: %d ", dev_type); 231 sprintf(buf, " type: %d ", dev_type);
226 buf += length; 232 buf += length;
227 if(tcon->tidStatus == CifsNeedReconnect) { 233 if (tcon->tidStatus == CifsNeedReconnect) {
228 buf += sprintf(buf, "\tDISCONNECTED "); 234 buf += sprintf(buf, "\tDISCONNECTED ");
229 length += 14; 235 length += 14;
230 } 236 }
@@ -238,9 +244,9 @@ cifs_debug_data_read(char *buf, char **beginBuffer, off_t offset,
238 /* Now calculate total size of returned data */ 244 /* Now calculate total size of returned data */
239 length = buf - original_buf; 245 length = buf - original_buf;
240 246
241 if(offset + count >= length) 247 if (offset + count >= length)
242 *eof = 1; 248 *eof = 1;
243 if(length < offset) { 249 if (length < offset) {
244 *eof = 1; 250 *eof = 1;
245 return 0; 251 return 0;
246 } else { 252 } else {
@@ -256,18 +262,18 @@ cifs_debug_data_read(char *buf, char **beginBuffer, off_t offset,
256 262
257static int 263static int
258cifs_stats_write(struct file *file, const char __user *buffer, 264cifs_stats_write(struct file *file, const char __user *buffer,
259 unsigned long count, void *data) 265 unsigned long count, void *data)
260{ 266{
261 char c; 267 char c;
262 int rc; 268 int rc;
263 struct list_head *tmp; 269 struct list_head *tmp;
264 struct cifsTconInfo *tcon; 270 struct cifsTconInfo *tcon;
265 271
266 rc = get_user(c, buffer); 272 rc = get_user(c, buffer);
267 if (rc) 273 if (rc)
268 return rc; 274 return rc;
269 275
270 if (c == '1' || c == 'y' || c == 'Y' || c == '0') { 276 if (c == '1' || c == 'y' || c == 'Y' || c == '0') {
271 read_lock(&GlobalSMBSeslock); 277 read_lock(&GlobalSMBSeslock);
272#ifdef CONFIG_CIFS_STATS2 278#ifdef CONFIG_CIFS_STATS2
273 atomic_set(&totBufAllocCount, 0); 279 atomic_set(&totBufAllocCount, 0);
@@ -297,14 +303,14 @@ cifs_stats_write(struct file *file, const char __user *buffer,
297 read_unlock(&GlobalSMBSeslock); 303 read_unlock(&GlobalSMBSeslock);
298 } 304 }
299 305
300 return count; 306 return count;
301} 307}
302 308
303static int 309static int
304cifs_stats_read(char *buf, char **beginBuffer, off_t offset, 310cifs_stats_read(char *buf, char **beginBuffer, off_t offset,
305 int count, int *eof, void *data) 311 int count, int *eof, void *data)
306{ 312{
307 int item_length,i,length; 313 int item_length, i, length;
308 struct list_head *tmp; 314 struct list_head *tmp;
309 struct cifsTconInfo *tcon; 315 struct cifsTconInfo *tcon;
310 316
@@ -314,44 +320,44 @@ cifs_stats_read(char *buf, char **beginBuffer, off_t offset,
314 "Resources in use\nCIFS Session: %d\n", 320 "Resources in use\nCIFS Session: %d\n",
315 sesInfoAllocCount.counter); 321 sesInfoAllocCount.counter);
316 buf += length; 322 buf += length;
317 item_length = 323 item_length =
318 sprintf(buf,"Share (unique mount targets): %d\n", 324 sprintf(buf, "Share (unique mount targets): %d\n",
319 tconInfoAllocCount.counter); 325 tconInfoAllocCount.counter);
320 length += item_length; 326 length += item_length;
321 buf += item_length; 327 buf += item_length;
322 item_length = 328 item_length =
323 sprintf(buf,"SMB Request/Response Buffer: %d Pool size: %d\n", 329 sprintf(buf, "SMB Request/Response Buffer: %d Pool size: %d\n",
324 bufAllocCount.counter, 330 bufAllocCount.counter,
325 cifs_min_rcv + tcpSesAllocCount.counter); 331 cifs_min_rcv + tcpSesAllocCount.counter);
326 length += item_length; 332 length += item_length;
327 buf += item_length; 333 buf += item_length;
328 item_length = 334 item_length =
329 sprintf(buf,"SMB Small Req/Resp Buffer: %d Pool size: %d\n", 335 sprintf(buf, "SMB Small Req/Resp Buffer: %d Pool size: %d\n",
330 smBufAllocCount.counter,cifs_min_small); 336 smBufAllocCount.counter, cifs_min_small);
331 length += item_length; 337 length += item_length;
332 buf += item_length; 338 buf += item_length;
333#ifdef CONFIG_CIFS_STATS2 339#ifdef CONFIG_CIFS_STATS2
334 item_length = sprintf(buf, "Total Large %d Small %d Allocations\n", 340 item_length = sprintf(buf, "Total Large %d Small %d Allocations\n",
335 atomic_read(&totBufAllocCount), 341 atomic_read(&totBufAllocCount),
336 atomic_read(&totSmBufAllocCount)); 342 atomic_read(&totSmBufAllocCount));
337 length += item_length; 343 length += item_length;
338 buf += item_length; 344 buf += item_length;
339#endif /* CONFIG_CIFS_STATS2 */ 345#endif /* CONFIG_CIFS_STATS2 */
340 346
341 item_length = 347 item_length =
342 sprintf(buf,"Operations (MIDs): %d\n", 348 sprintf(buf, "Operations (MIDs): %d\n",
343 midCount.counter); 349 midCount.counter);
344 length += item_length; 350 length += item_length;
345 buf += item_length; 351 buf += item_length;
346 item_length = sprintf(buf, 352 item_length = sprintf(buf,
347 "\n%d session %d share reconnects\n", 353 "\n%d session %d share reconnects\n",
348 tcpSesReconnectCount.counter,tconInfoReconnectCount.counter); 354 tcpSesReconnectCount.counter, tconInfoReconnectCount.counter);
349 length += item_length; 355 length += item_length;
350 buf += item_length; 356 buf += item_length;
351 357
352 item_length = sprintf(buf, 358 item_length = sprintf(buf,
353 "Total vfs operations: %d maximum at one time: %d\n", 359 "Total vfs operations: %d maximum at one time: %d\n",
354 GlobalCurrentXid,GlobalMaxActiveXid); 360 GlobalCurrentXid, GlobalMaxActiveXid);
355 length += item_length; 361 length += item_length;
356 buf += item_length; 362 buf += item_length;
357 363
@@ -360,10 +366,10 @@ cifs_stats_read(char *buf, char **beginBuffer, off_t offset,
360 list_for_each(tmp, &GlobalTreeConnectionList) { 366 list_for_each(tmp, &GlobalTreeConnectionList) {
361 i++; 367 i++;
362 tcon = list_entry(tmp, struct cifsTconInfo, cifsConnectionList); 368 tcon = list_entry(tmp, struct cifsTconInfo, cifsConnectionList);
363 item_length = sprintf(buf,"\n%d) %s",i, tcon->treeName); 369 item_length = sprintf(buf, "\n%d) %s", i, tcon->treeName);
364 buf += item_length; 370 buf += item_length;
365 length += item_length; 371 length += item_length;
366 if(tcon->tidStatus == CifsNeedReconnect) { 372 if (tcon->tidStatus == CifsNeedReconnect) {
367 buf += sprintf(buf, "\tDISCONNECTED "); 373 buf += sprintf(buf, "\tDISCONNECTED ");
368 length += 14; 374 length += 14;
369 } 375 }
@@ -380,15 +386,15 @@ cifs_stats_read(char *buf, char **beginBuffer, off_t offset,
380 item_length = sprintf(buf, "\nWrites: %d Bytes: %lld", 386 item_length = sprintf(buf, "\nWrites: %d Bytes: %lld",
381 atomic_read(&tcon->num_writes), 387 atomic_read(&tcon->num_writes),
382 (long long)(tcon->bytes_written)); 388 (long long)(tcon->bytes_written));
383 buf += item_length; 389 buf += item_length;
384 length += item_length; 390 length += item_length;
385 item_length = sprintf(buf, 391 item_length = sprintf(buf,
386 "\nLocks: %d HardLinks: %d Symlinks: %d", 392 "\nLocks: %d HardLinks: %d Symlinks: %d",
387 atomic_read(&tcon->num_locks), 393 atomic_read(&tcon->num_locks),
388 atomic_read(&tcon->num_hardlinks), 394 atomic_read(&tcon->num_hardlinks),
389 atomic_read(&tcon->num_symlinks)); 395 atomic_read(&tcon->num_symlinks));
390 buf += item_length; 396 buf += item_length;
391 length += item_length; 397 length += item_length;
392 398
393 item_length = sprintf(buf, "\nOpens: %d Closes: %d Deletes: %d", 399 item_length = sprintf(buf, "\nOpens: %d Closes: %d Deletes: %d",
394 atomic_read(&tcon->num_opens), 400 atomic_read(&tcon->num_opens),
@@ -415,12 +421,12 @@ cifs_stats_read(char *buf, char **beginBuffer, off_t offset,
415 } 421 }
416 read_unlock(&GlobalSMBSeslock); 422 read_unlock(&GlobalSMBSeslock);
417 423
418 buf += sprintf(buf,"\n"); 424 buf += sprintf(buf, "\n");
419 length++; 425 length++;
420 426
421 if(offset + count >= length) 427 if (offset + count >= length)
422 *eof = 1; 428 *eof = 1;
423 if(length < offset) { 429 if (length < offset) {
424 *eof = 1; 430 *eof = 1;
425 return 0; 431 return 0;
426 } else { 432 } else {
@@ -428,7 +434,7 @@ cifs_stats_read(char *buf, char **beginBuffer, off_t offset,
428 } 434 }
429 if (length > count) 435 if (length > count)
430 length = count; 436 length = count;
431 437
432 return length; 438 return length;
433} 439}
434#endif 440#endif
@@ -547,11 +553,11 @@ cifs_proc_clean(void)
547 remove_proc_entry("MultiuserMount", proc_fs_cifs); 553 remove_proc_entry("MultiuserMount", proc_fs_cifs);
548 remove_proc_entry("OplockEnabled", proc_fs_cifs); 554 remove_proc_entry("OplockEnabled", proc_fs_cifs);
549/* remove_proc_entry("NTLMV2Enabled",proc_fs_cifs); */ 555/* remove_proc_entry("NTLMV2Enabled",proc_fs_cifs); */
550 remove_proc_entry("SecurityFlags",proc_fs_cifs); 556 remove_proc_entry("SecurityFlags", proc_fs_cifs);
551/* remove_proc_entry("PacketSigningEnabled",proc_fs_cifs); */ 557/* remove_proc_entry("PacketSigningEnabled", proc_fs_cifs); */
552 remove_proc_entry("LinuxExtensionsEnabled",proc_fs_cifs); 558 remove_proc_entry("LinuxExtensionsEnabled", proc_fs_cifs);
553 remove_proc_entry("Experimental",proc_fs_cifs); 559 remove_proc_entry("Experimental", proc_fs_cifs);
554 remove_proc_entry("LookupCacheEnabled",proc_fs_cifs); 560 remove_proc_entry("LookupCacheEnabled", proc_fs_cifs);
555 remove_proc_entry("cifs", proc_root_fs); 561 remove_proc_entry("cifs", proc_root_fs);
556} 562}
557 563
@@ -590,7 +596,7 @@ cifsFYI_write(struct file *file, const char __user *buffer,
590 cifsFYI = 0; 596 cifsFYI = 0;
591 else if (c == '1' || c == 'y' || c == 'Y') 597 else if (c == '1' || c == 'y' || c == 'Y')
592 cifsFYI = 1; 598 cifsFYI = 1;
593 else if((c > '1') && (c <= '9')) 599 else if ((c > '1') && (c <= '9'))
594 cifsFYI = (int) (c - '0'); /* see cifs_debug.h for meanings */ 600 cifsFYI = (int) (c - '0'); /* see cifs_debug.h for meanings */
595 601
596 return count; 602 return count;
@@ -637,28 +643,28 @@ oplockEnabled_write(struct file *file, const char __user *buffer,
637 643
638static int 644static int
639experimEnabled_read(char *page, char **start, off_t off, 645experimEnabled_read(char *page, char **start, off_t off,
640 int count, int *eof, void *data) 646 int count, int *eof, void *data)
641{ 647{
642 int len; 648 int len;
643 649
644 len = sprintf(page, "%d\n", experimEnabled); 650 len = sprintf(page, "%d\n", experimEnabled);
645 651
646 len -= off; 652 len -= off;
647 *start = page + off; 653 *start = page + off;
648 654
649 if (len > count) 655 if (len > count)
650 len = count; 656 len = count;
651 else 657 else
652 *eof = 1; 658 *eof = 1;
653 659
654 if (len < 0) 660 if (len < 0)
655 len = 0; 661 len = 0;
656 662
657 return len; 663 return len;
658} 664}
659static int 665static int
660experimEnabled_write(struct file *file, const char __user *buffer, 666experimEnabled_write(struct file *file, const char __user *buffer,
661 unsigned long count, void *data) 667 unsigned long count, void *data)
662{ 668{
663 char c; 669 char c;
664 int rc; 670 int rc;
@@ -678,46 +684,46 @@ experimEnabled_write(struct file *file, const char __user *buffer,
678 684
679static int 685static int
680linuxExtensionsEnabled_read(char *page, char **start, off_t off, 686linuxExtensionsEnabled_read(char *page, char **start, off_t off,
681 int count, int *eof, void *data) 687 int count, int *eof, void *data)
682{ 688{
683 int len; 689 int len;
684 690
685 len = sprintf(page, "%d\n", linuxExtEnabled); 691 len = sprintf(page, "%d\n", linuxExtEnabled);
686 len -= off; 692 len -= off;
687 *start = page + off; 693 *start = page + off;
688 694
689 if (len > count) 695 if (len > count)
690 len = count; 696 len = count;
691 else 697 else
692 *eof = 1; 698 *eof = 1;
693 699
694 if (len < 0) 700 if (len < 0)
695 len = 0; 701 len = 0;
696 702
697 return len; 703 return len;
698} 704}
699static int 705static int
700linuxExtensionsEnabled_write(struct file *file, const char __user *buffer, 706linuxExtensionsEnabled_write(struct file *file, const char __user *buffer,
701 unsigned long count, void *data) 707 unsigned long count, void *data)
702{ 708{
703 char c; 709 char c;
704 int rc; 710 int rc;
705 711
706 rc = get_user(c, buffer); 712 rc = get_user(c, buffer);
707 if (rc) 713 if (rc)
708 return rc; 714 return rc;
709 if (c == '0' || c == 'n' || c == 'N') 715 if (c == '0' || c == 'n' || c == 'N')
710 linuxExtEnabled = 0; 716 linuxExtEnabled = 0;
711 else if (c == '1' || c == 'y' || c == 'Y') 717 else if (c == '1' || c == 'y' || c == 'Y')
712 linuxExtEnabled = 1; 718 linuxExtEnabled = 1;
713 719
714 return count; 720 return count;
715} 721}
716 722
717 723
718static int 724static int
719lookupFlag_read(char *page, char **start, off_t off, 725lookupFlag_read(char *page, char **start, off_t off,
720 int count, int *eof, void *data) 726 int count, int *eof, void *data)
721{ 727{
722 int len; 728 int len;
723 729
@@ -860,15 +866,15 @@ security_flags_write(struct file *file, const char __user *buffer,
860 char flags_string[12]; 866 char flags_string[12];
861 char c; 867 char c;
862 868
863 if((count < 1) || (count > 11)) 869 if ((count < 1) || (count > 11))
864 return -EINVAL; 870 return -EINVAL;
865 871
866 memset(flags_string, 0, 12); 872 memset(flags_string, 0, 12);
867 873
868 if(copy_from_user(flags_string, buffer, count)) 874 if (copy_from_user(flags_string, buffer, count))
869 return -EFAULT; 875 return -EFAULT;
870 876
871 if(count < 3) { 877 if (count < 3) {
872 /* single char or single char followed by null */ 878 /* single char or single char followed by null */
873 c = flags_string[0]; 879 c = flags_string[0];
874 if (c == '0' || c == 'n' || c == 'N') 880 if (c == '0' || c == 'n' || c == 'N')
@@ -881,15 +887,15 @@ security_flags_write(struct file *file, const char __user *buffer,
881 887
882 flags = simple_strtoul(flags_string, NULL, 0); 888 flags = simple_strtoul(flags_string, NULL, 0);
883 889
884 cFYI(1,("sec flags 0x%x", flags)); 890 cFYI(1, ("sec flags 0x%x", flags));
885 891
886 if(flags <= 0) { 892 if (flags <= 0) {
887 cERROR(1,("invalid security flags %s",flags_string)); 893 cERROR(1, ("invalid security flags %s", flags_string));
888 return -EINVAL; 894 return -EINVAL;
889 } 895 }
890 896
891 if(flags & ~CIFSSEC_MASK) { 897 if (flags & ~CIFSSEC_MASK) {
892 cERROR(1,("attempt to set unsupported security flags 0x%x", 898 cERROR(1, ("attempt to set unsupported security flags 0x%x",
893 flags & ~CIFSSEC_MASK)); 899 flags & ~CIFSSEC_MASK));
894 return -EINVAL; 900 return -EINVAL;
895 } 901 }
diff --git a/fs/cifs/cifs_unicode.c b/fs/cifs/cifs_unicode.c
index 793c4b95c164..701e9a9185f2 100644
--- a/fs/cifs/cifs_unicode.c
+++ b/fs/cifs/cifs_unicode.c
@@ -6,16 +6,16 @@
6 * 6 *
7 * This program is free software; you can redistribute it and/or modify 7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by 8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or 9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version. 10 * (at your option) any later version.
11 * 11 *
12 * This program is distributed in the hope that it will be useful, 12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
15 * the GNU General Public License for more details. 15 * the GNU General Public License for more details.
16 * 16 *
17 * You should have received a copy of the GNU General Public License 17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software 18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 */ 20 */
21#include <linux/fs.h> 21#include <linux/fs.h>
@@ -32,7 +32,7 @@
32 * 32 *
33 */ 33 */
34int 34int
35cifs_strfromUCS_le(char *to, const __le16 * from, 35cifs_strfromUCS_le(char *to, const __le16 * from,
36 int len, const struct nls_table *codepage) 36 int len, const struct nls_table *codepage)
37{ 37{
38 int i; 38 int i;
@@ -66,7 +66,7 @@ cifs_strtoUCS(__le16 * to, const char *from, int len,
66{ 66{
67 int charlen; 67 int charlen;
68 int i; 68 int i;
69 wchar_t * wchar_to = (wchar_t *)to; /* needed to quiet sparse */ 69 wchar_t * wchar_to = (wchar_t *)to; /* needed to quiet sparse */
70 70
71 for (i = 0; len && *from; i++, from += charlen, len -= charlen) { 71 for (i = 0; len && *from; i++, from += charlen, len -= charlen) {
72 72
@@ -79,7 +79,7 @@ cifs_strtoUCS(__le16 * to, const char *from, int len,
79 /* A question mark */ 79 /* A question mark */
80 to[i] = cpu_to_le16(0x003f); 80 to[i] = cpu_to_le16(0x003f);
81 charlen = 1; 81 charlen = 1;
82 } else 82 } else
83 to[i] = cpu_to_le16(wchar_to[i]); 83 to[i] = cpu_to_le16(wchar_to[i]);
84 84
85 } 85 }
diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c
index d38c69b591cf..7c04752b76cb 100644
--- a/fs/cifs/cifsfs.c
+++ b/fs/cifs/cifsfs.c
@@ -825,8 +825,8 @@ cifs_init_mids(void)
825 sizeof (struct oplock_q_entry), 0, 825 sizeof (struct oplock_q_entry), 0,
826 SLAB_HWCACHE_ALIGN, NULL, NULL); 826 SLAB_HWCACHE_ALIGN, NULL, NULL);
827 if (cifs_oplock_cachep == NULL) { 827 if (cifs_oplock_cachep == NULL) {
828 kmem_cache_destroy(cifs_mid_cachep);
829 mempool_destroy(cifs_mid_poolp); 828 mempool_destroy(cifs_mid_poolp);
829 kmem_cache_destroy(cifs_mid_cachep);
830 return -ENOMEM; 830 return -ENOMEM;
831 } 831 }
832 832
diff --git a/fs/cifs/cifssmb.c b/fs/cifs/cifssmb.c
index 14de58fa1437..57419a176688 100644
--- a/fs/cifs/cifssmb.c
+++ b/fs/cifs/cifssmb.c
@@ -433,8 +433,8 @@ CIFSSMBNegotiate(unsigned int xid, struct cifsSesInfo *ses)
433 cFYI(1,("secFlags 0x%x",secFlags)); 433 cFYI(1,("secFlags 0x%x",secFlags));
434 434
435 pSMB->hdr.Mid = GetNextMid(server); 435 pSMB->hdr.Mid = GetNextMid(server);
436 pSMB->hdr.Flags2 |= SMBFLG2_UNICODE; 436 pSMB->hdr.Flags2 |= (SMBFLG2_UNICODE | SMBFLG2_ERR_STATUS);
437 if((secFlags & CIFSSEC_MUST_KRB5) == CIFSSEC_MUST_KRB5) 437 if ((secFlags & CIFSSEC_MUST_KRB5) == CIFSSEC_MUST_KRB5)
438 pSMB->hdr.Flags2 |= SMBFLG2_EXT_SEC; 438 pSMB->hdr.Flags2 |= SMBFLG2_EXT_SEC;
439 439
440 count = 0; 440 count = 0;
diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c
index 216fb625843f..f4e92661b223 100644
--- a/fs/cifs/connect.c
+++ b/fs/cifs/connect.c
@@ -2069,8 +2069,15 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb,
2069 srvTcp->tcpStatus = CifsExiting; 2069 srvTcp->tcpStatus = CifsExiting;
2070 spin_unlock(&GlobalMid_Lock); 2070 spin_unlock(&GlobalMid_Lock);
2071 if (srvTcp->tsk) { 2071 if (srvTcp->tsk) {
2072 struct task_struct *tsk;
2073 /* If we could verify that kthread_stop would
2074 always wake up processes blocked in
2075 tcp in recv_mesg then we could remove the
2076 send_sig call */
2072 send_sig(SIGKILL,srvTcp->tsk,1); 2077 send_sig(SIGKILL,srvTcp->tsk,1);
2073 kthread_stop(srvTcp->tsk); 2078 tsk = srvTcp->tsk;
2079 if(tsk)
2080 kthread_stop(tsk);
2074 } 2081 }
2075 } 2082 }
2076 /* If find_unc succeeded then rc == 0 so we can not end */ 2083 /* If find_unc succeeded then rc == 0 so we can not end */
@@ -2085,8 +2092,11 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb,
2085 /* if the socketUseCount is now zero */ 2092 /* if the socketUseCount is now zero */
2086 if ((temp_rc == -ESHUTDOWN) && 2093 if ((temp_rc == -ESHUTDOWN) &&
2087 (pSesInfo->server) && (pSesInfo->server->tsk)) { 2094 (pSesInfo->server) && (pSesInfo->server->tsk)) {
2095 struct task_struct *tsk;
2088 send_sig(SIGKILL,pSesInfo->server->tsk,1); 2096 send_sig(SIGKILL,pSesInfo->server->tsk,1);
2089 kthread_stop(pSesInfo->server->tsk); 2097 tsk = pSesInfo->server->tsk;
2098 if (tsk)
2099 kthread_stop(tsk);
2090 } 2100 }
2091 } else 2101 } else
2092 cFYI(1, ("No session or bad tcon")); 2102 cFYI(1, ("No session or bad tcon"));
@@ -3334,7 +3344,7 @@ cifs_umount(struct super_block *sb, struct cifs_sb_info *cifs_sb)
3334 return 0; 3344 return 0;
3335 } else if (rc == -ESHUTDOWN) { 3345 } else if (rc == -ESHUTDOWN) {
3336 cFYI(1,("Waking up socket by sending it signal")); 3346 cFYI(1,("Waking up socket by sending it signal"));
3337 if(cifsd_task) { 3347 if (cifsd_task) {
3338 send_sig(SIGKILL,cifsd_task,1); 3348 send_sig(SIGKILL,cifsd_task,1);
3339 kthread_stop(cifsd_task); 3349 kthread_stop(cifsd_task);
3340 } 3350 }
diff --git a/fs/cifs/dir.c b/fs/cifs/dir.c
index e5210519ac4b..8e86aaceb68a 100644
--- a/fs/cifs/dir.c
+++ b/fs/cifs/dir.c
@@ -2,7 +2,7 @@
2 * fs/cifs/dir.c 2 * fs/cifs/dir.c
3 * 3 *
4 * vfs operations that deal with dentries 4 * vfs operations that deal with dentries
5 * 5 *
6 * Copyright (C) International Business Machines Corp., 2002,2005 6 * Copyright (C) International Business Machines Corp., 2002,2005
7 * Author(s): Steve French (sfrench@us.ibm.com) 7 * Author(s): Steve French (sfrench@us.ibm.com)
8 * 8 *
@@ -34,11 +34,12 @@
34static void 34static void
35renew_parental_timestamps(struct dentry *direntry) 35renew_parental_timestamps(struct dentry *direntry)
36{ 36{
37 /* BB check if there is a way to get the kernel to do this or if we really need this */ 37 /* BB check if there is a way to get the kernel to do this or if we
38 really need this */
38 do { 39 do {
39 direntry->d_time = jiffies; 40 direntry->d_time = jiffies;
40 direntry = direntry->d_parent; 41 direntry = direntry->d_parent;
41 } while (!IS_ROOT(direntry)); 42 } while (!IS_ROOT(direntry));
42} 43}
43 44
44/* Note: caller must free return buffer */ 45/* Note: caller must free return buffer */
@@ -51,7 +52,7 @@ build_path_from_dentry(struct dentry *direntry)
51 char *full_path; 52 char *full_path;
52 char dirsep; 53 char dirsep;
53 54
54 if(direntry == NULL) 55 if (direntry == NULL)
55 return NULL; /* not much we can do if dentry is freed and 56 return NULL; /* not much we can do if dentry is freed and
56 we need to reopen the file after it was closed implicitly 57 we need to reopen the file after it was closed implicitly
57 when the server crashed */ 58 when the server crashed */
@@ -59,18 +60,18 @@ build_path_from_dentry(struct dentry *direntry)
59 dirsep = CIFS_DIR_SEP(CIFS_SB(direntry->d_sb)); 60 dirsep = CIFS_DIR_SEP(CIFS_SB(direntry->d_sb));
60 pplen = CIFS_SB(direntry->d_sb)->prepathlen; 61 pplen = CIFS_SB(direntry->d_sb)->prepathlen;
61cifs_bp_rename_retry: 62cifs_bp_rename_retry:
62 namelen = pplen; 63 namelen = pplen;
63 for (temp = direntry; !IS_ROOT(temp);) { 64 for (temp = direntry; !IS_ROOT(temp);) {
64 namelen += (1 + temp->d_name.len); 65 namelen += (1 + temp->d_name.len);
65 temp = temp->d_parent; 66 temp = temp->d_parent;
66 if(temp == NULL) { 67 if (temp == NULL) {
67 cERROR(1,("corrupt dentry")); 68 cERROR(1, ("corrupt dentry"));
68 return NULL; 69 return NULL;
69 } 70 }
70 } 71 }
71 72
72 full_path = kmalloc(namelen+1, GFP_KERNEL); 73 full_path = kmalloc(namelen+1, GFP_KERNEL);
73 if(full_path == NULL) 74 if (full_path == NULL)
74 return full_path; 75 return full_path;
75 full_path[namelen] = 0; /* trailing null */ 76 full_path[namelen] = 0; /* trailing null */
76 for (temp = direntry; !IS_ROOT(temp);) { 77 for (temp = direntry; !IS_ROOT(temp);) {
@@ -84,8 +85,8 @@ cifs_bp_rename_retry:
84 cFYI(0, ("name: %s", full_path + namelen)); 85 cFYI(0, ("name: %s", full_path + namelen));
85 } 86 }
86 temp = temp->d_parent; 87 temp = temp->d_parent;
87 if(temp == NULL) { 88 if (temp == NULL) {
88 cERROR(1,("corrupt dentry")); 89 cERROR(1, ("corrupt dentry"));
89 kfree(full_path); 90 kfree(full_path);
90 return NULL; 91 return NULL;
91 } 92 }
@@ -94,7 +95,7 @@ cifs_bp_rename_retry:
94 cERROR(1, 95 cERROR(1,
95 ("did not end path lookup where expected namelen is %d", 96 ("did not end path lookup where expected namelen is %d",
96 namelen)); 97 namelen));
97 /* presumably this is only possible if racing with a rename 98 /* presumably this is only possible if racing with a rename
98 of one of the parent directories (we can not lock the dentries 99 of one of the parent directories (we can not lock the dentries
99 above us to prevent this, but retrying should be harmless) */ 100 above us to prevent this, but retrying should be harmless) */
100 kfree(full_path); 101 kfree(full_path);
@@ -106,7 +107,7 @@ cifs_bp_rename_retry:
106 since the '\' is a valid posix character so we can not switch 107 since the '\' is a valid posix character so we can not switch
107 those safely to '/' if any are found in the middle of the prepath */ 108 those safely to '/' if any are found in the middle of the prepath */
108 /* BB test paths to Windows with '/' in the midst of prepath */ 109 /* BB test paths to Windows with '/' in the midst of prepath */
109 strncpy(full_path,CIFS_SB(direntry->d_sb)->prepath,pplen); 110 strncpy(full_path, CIFS_SB(direntry->d_sb)->prepath, pplen);
110 return full_path; 111 return full_path;
111} 112}
112 113
@@ -147,12 +148,12 @@ cifs_create(struct inode *inode, struct dentry *direntry, int mode,
147 pTcon = cifs_sb->tcon; 148 pTcon = cifs_sb->tcon;
148 149
149 full_path = build_path_from_dentry(direntry); 150 full_path = build_path_from_dentry(direntry);
150 if(full_path == NULL) { 151 if (full_path == NULL) {
151 FreeXid(xid); 152 FreeXid(xid);
152 return -ENOMEM; 153 return -ENOMEM;
153 } 154 }
154 155
155 if(nd && (nd->flags & LOOKUP_OPEN)) { 156 if (nd && (nd->flags & LOOKUP_OPEN)) {
156 int oflags = nd->intent.open.flags; 157 int oflags = nd->intent.open.flags;
157 158
158 desiredAccess = 0; 159 desiredAccess = 0;
@@ -164,28 +165,29 @@ cifs_create(struct inode *inode, struct dentry *direntry, int mode,
164 write_only = TRUE; 165 write_only = TRUE;
165 } 166 }
166 167
167 if((oflags & (O_CREAT | O_EXCL)) == (O_CREAT | O_EXCL)) 168 if ((oflags & (O_CREAT | O_EXCL)) == (O_CREAT | O_EXCL))
168 disposition = FILE_CREATE; 169 disposition = FILE_CREATE;
169 else if((oflags & (O_CREAT | O_TRUNC)) == (O_CREAT | O_TRUNC)) 170 else if ((oflags & (O_CREAT | O_TRUNC)) == (O_CREAT | O_TRUNC))
170 disposition = FILE_OVERWRITE_IF; 171 disposition = FILE_OVERWRITE_IF;
171 else if((oflags & O_CREAT) == O_CREAT) 172 else if ((oflags & O_CREAT) == O_CREAT)
172 disposition = FILE_OPEN_IF; 173 disposition = FILE_OPEN_IF;
173 else { 174 else {
174 cFYI(1,("Create flag not set in create function")); 175 cFYI(1, ("Create flag not set in create function"));
175 } 176 }
176 } 177 }
177 178
178 /* BB add processing to set equivalent of mode - e.g. via CreateX with ACLs */ 179 /* BB add processing to set equivalent of mode - e.g. via CreateX with
180 ACLs */
179 if (oplockEnabled) 181 if (oplockEnabled)
180 oplock = REQ_OPLOCK; 182 oplock = REQ_OPLOCK;
181 183
182 buf = kmalloc(sizeof(FILE_ALL_INFO),GFP_KERNEL); 184 buf = kmalloc(sizeof(FILE_ALL_INFO), GFP_KERNEL);
183 if(buf == NULL) { 185 if (buf == NULL) {
184 kfree(full_path); 186 kfree(full_path);
185 FreeXid(xid); 187 FreeXid(xid);
186 return -ENOMEM; 188 return -ENOMEM;
187 } 189 }
188 if (cifs_sb->tcon->ses->capabilities & CAP_NT_SMBS) 190 if (cifs_sb->tcon->ses->capabilities & CAP_NT_SMBS)
189 rc = CIFSSMBOpen(xid, pTcon, full_path, disposition, 191 rc = CIFSSMBOpen(xid, pTcon, full_path, disposition,
190 desiredAccess, CREATE_NOT_DIR, 192 desiredAccess, CREATE_NOT_DIR,
191 &fileHandle, &oplock, buf, cifs_sb->local_nls, 193 &fileHandle, &oplock, buf, cifs_sb->local_nls,
@@ -193,27 +195,28 @@ cifs_create(struct inode *inode, struct dentry *direntry, int mode,
193 else 195 else
194 rc = -EIO; /* no NT SMB support fall into legacy open below */ 196 rc = -EIO; /* no NT SMB support fall into legacy open below */
195 197
196 if(rc == -EIO) { 198 if (rc == -EIO) {
197 /* old server, retry the open legacy style */ 199 /* old server, retry the open legacy style */
198 rc = SMBLegacyOpen(xid, pTcon, full_path, disposition, 200 rc = SMBLegacyOpen(xid, pTcon, full_path, disposition,
199 desiredAccess, CREATE_NOT_DIR, 201 desiredAccess, CREATE_NOT_DIR,
200 &fileHandle, &oplock, buf, cifs_sb->local_nls, 202 &fileHandle, &oplock, buf, cifs_sb->local_nls,
201 cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR); 203 cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR);
202 } 204 }
203 if (rc) { 205 if (rc) {
204 cFYI(1, ("cifs_create returned 0x%x", rc)); 206 cFYI(1, ("cifs_create returned 0x%x", rc));
205 } else { 207 } else {
206 /* If Open reported that we actually created a file 208 /* If Open reported that we actually created a file
207 then we now have to set the mode if possible */ 209 then we now have to set the mode if possible */
208 if ((cifs_sb->tcon->ses->capabilities & CAP_UNIX) && 210 if ((cifs_sb->tcon->ses->capabilities & CAP_UNIX) &&
209 (oplock & CIFS_CREATE_ACTION)) 211 (oplock & CIFS_CREATE_ACTION)) {
210 if(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SET_UID) { 212 mode &= ~current->fs->umask;
213 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SET_UID) {
211 CIFSSMBUnixSetPerms(xid, pTcon, full_path, mode, 214 CIFSSMBUnixSetPerms(xid, pTcon, full_path, mode,
212 (__u64)current->fsuid, 215 (__u64)current->fsuid,
213 (__u64)current->fsgid, 216 (__u64)current->fsgid,
214 0 /* dev */, 217 0 /* dev */,
215 cifs_sb->local_nls, 218 cifs_sb->local_nls,
216 cifs_sb->mnt_cifs_flags & 219 cifs_sb->mnt_cifs_flags &
217 CIFS_MOUNT_MAP_SPECIAL_CHR); 220 CIFS_MOUNT_MAP_SPECIAL_CHR);
218 } else { 221 } else {
219 CIFSSMBUnixSetPerms(xid, pTcon, full_path, mode, 222 CIFSSMBUnixSetPerms(xid, pTcon, full_path, mode,
@@ -221,26 +224,28 @@ cifs_create(struct inode *inode, struct dentry *direntry, int mode,
221 (__u64)-1, 224 (__u64)-1,
222 0 /* dev */, 225 0 /* dev */,
223 cifs_sb->local_nls, 226 cifs_sb->local_nls,
224 cifs_sb->mnt_cifs_flags & 227 cifs_sb->mnt_cifs_flags &
225 CIFS_MOUNT_MAP_SPECIAL_CHR); 228 CIFS_MOUNT_MAP_SPECIAL_CHR);
226 } 229 }
227 else { 230 } else {
228 /* BB implement mode setting via Windows security descriptors */ 231 /* BB implement mode setting via Windows security
229 /* eg CIFSSMBWinSetPerms(xid,pTcon,full_path,mode,-1,-1,local_nls);*/ 232 descriptors e.g. */
230 /* could set r/o dos attribute if mode & 0222 == 0 */ 233 /* CIFSSMBWinSetPerms(xid,pTcon,path,mode,-1,-1,nls);*/
234
235 /* Could set r/o dos attribute if mode & 0222 == 0 */
231 } 236 }
232 237
233 /* BB server might mask mode so we have to query for Unix case*/ 238 /* BB server might mask mode so we have to query for Unix case*/
234 if (pTcon->ses->capabilities & CAP_UNIX) 239 if (pTcon->ses->capabilities & CAP_UNIX)
235 rc = cifs_get_inode_info_unix(&newinode, full_path, 240 rc = cifs_get_inode_info_unix(&newinode, full_path,
236 inode->i_sb,xid); 241 inode->i_sb, xid);
237 else { 242 else {
238 rc = cifs_get_inode_info(&newinode, full_path, 243 rc = cifs_get_inode_info(&newinode, full_path,
239 buf, inode->i_sb,xid); 244 buf, inode->i_sb, xid);
240 if(newinode) { 245 if (newinode) {
241 newinode->i_mode = mode; 246 newinode->i_mode = mode;
242 if((oplock & CIFS_CREATE_ACTION) && 247 if ((oplock & CIFS_CREATE_ACTION) &&
243 (cifs_sb->mnt_cifs_flags & 248 (cifs_sb->mnt_cifs_flags &
244 CIFS_MOUNT_SET_UID)) { 249 CIFS_MOUNT_SET_UID)) {
245 newinode->i_uid = current->fsuid; 250 newinode->i_uid = current->fsuid;
246 newinode->i_gid = current->fsgid; 251 newinode->i_gid = current->fsgid;
@@ -259,14 +264,14 @@ cifs_create(struct inode *inode, struct dentry *direntry, int mode,
259 direntry->d_op = &cifs_dentry_ops; 264 direntry->d_op = &cifs_dentry_ops;
260 d_instantiate(direntry, newinode); 265 d_instantiate(direntry, newinode);
261 } 266 }
262 if((nd->flags & LOOKUP_OPEN) == FALSE) { 267 if ((nd->flags & LOOKUP_OPEN) == FALSE) {
263 /* mknod case - do not leave file open */ 268 /* mknod case - do not leave file open */
264 CIFSSMBClose(xid, pTcon, fileHandle); 269 CIFSSMBClose(xid, pTcon, fileHandle);
265 } else if(newinode) { 270 } else if (newinode) {
266 pCifsFile = 271 pCifsFile =
267 kzalloc(sizeof (struct cifsFileInfo), GFP_KERNEL); 272 kzalloc(sizeof (struct cifsFileInfo), GFP_KERNEL);
268 273
269 if(pCifsFile == NULL) 274 if (pCifsFile == NULL)
270 goto cifs_create_out; 275 goto cifs_create_out;
271 pCifsFile->netfid = fileHandle; 276 pCifsFile->netfid = fileHandle;
272 pCifsFile->pid = current->tgid; 277 pCifsFile->pid = current->tgid;
@@ -276,33 +281,33 @@ cifs_create(struct inode *inode, struct dentry *direntry, int mode,
276 init_MUTEX(&pCifsFile->fh_sem); 281 init_MUTEX(&pCifsFile->fh_sem);
277 mutex_init(&pCifsFile->lock_mutex); 282 mutex_init(&pCifsFile->lock_mutex);
278 INIT_LIST_HEAD(&pCifsFile->llist); 283 INIT_LIST_HEAD(&pCifsFile->llist);
279 atomic_set(&pCifsFile->wrtPending,0); 284 atomic_set(&pCifsFile->wrtPending, 0);
280 285
281 /* set the following in open now 286 /* set the following in open now
282 pCifsFile->pfile = file; */ 287 pCifsFile->pfile = file; */
283 write_lock(&GlobalSMBSeslock); 288 write_lock(&GlobalSMBSeslock);
284 list_add(&pCifsFile->tlist,&pTcon->openFileList); 289 list_add(&pCifsFile->tlist, &pTcon->openFileList);
285 pCifsInode = CIFS_I(newinode); 290 pCifsInode = CIFS_I(newinode);
286 if(pCifsInode) { 291 if (pCifsInode) {
287 /* if readable file instance put first in list*/ 292 /* if readable file instance put first in list*/
288 if (write_only == TRUE) { 293 if (write_only == TRUE) {
289 list_add_tail(&pCifsFile->flist, 294 list_add_tail(&pCifsFile->flist,
290 &pCifsInode->openFileList); 295 &pCifsInode->openFileList);
291 } else { 296 } else {
292 list_add(&pCifsFile->flist, 297 list_add(&pCifsFile->flist,
293 &pCifsInode->openFileList); 298 &pCifsInode->openFileList);
294 } 299 }
295 if((oplock & 0xF) == OPLOCK_EXCLUSIVE) { 300 if ((oplock & 0xF) == OPLOCK_EXCLUSIVE) {
296 pCifsInode->clientCanCacheAll = TRUE; 301 pCifsInode->clientCanCacheAll = TRUE;
297 pCifsInode->clientCanCacheRead = TRUE; 302 pCifsInode->clientCanCacheRead = TRUE;
298 cFYI(1,("Exclusive Oplock for inode %p", 303 cFYI(1, ("Exclusive Oplock inode %p",
299 newinode)); 304 newinode));
300 } else if((oplock & 0xF) == OPLOCK_READ) 305 } else if ((oplock & 0xF) == OPLOCK_READ)
301 pCifsInode->clientCanCacheRead = TRUE; 306 pCifsInode->clientCanCacheRead = TRUE;
302 } 307 }
303 write_unlock(&GlobalSMBSeslock); 308 write_unlock(&GlobalSMBSeslock);
304 } 309 }
305 } 310 }
306cifs_create_out: 311cifs_create_out:
307 kfree(buf); 312 kfree(buf);
308 kfree(full_path); 313 kfree(full_path);
@@ -310,8 +315,8 @@ cifs_create_out:
310 return rc; 315 return rc;
311} 316}
312 317
313int cifs_mknod(struct inode *inode, struct dentry *direntry, int mode, 318int cifs_mknod(struct inode *inode, struct dentry *direntry, int mode,
314 dev_t device_number) 319 dev_t device_number)
315{ 320{
316 int rc = -EPERM; 321 int rc = -EPERM;
317 int xid; 322 int xid;
@@ -329,43 +334,45 @@ int cifs_mknod(struct inode *inode, struct dentry *direntry, int mode,
329 pTcon = cifs_sb->tcon; 334 pTcon = cifs_sb->tcon;
330 335
331 full_path = build_path_from_dentry(direntry); 336 full_path = build_path_from_dentry(direntry);
332 if(full_path == NULL) 337 if (full_path == NULL)
333 rc = -ENOMEM; 338 rc = -ENOMEM;
334 else if (pTcon->ses->capabilities & CAP_UNIX) { 339 else if (pTcon->ses->capabilities & CAP_UNIX) {
335 if(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SET_UID) { 340 mode &= ~current->fs->umask;
341 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SET_UID) {
336 rc = CIFSSMBUnixSetPerms(xid, pTcon, full_path, 342 rc = CIFSSMBUnixSetPerms(xid, pTcon, full_path,
337 mode,(__u64)current->fsuid,(__u64)current->fsgid, 343 mode, (__u64)current->fsuid,
344 (__u64)current->fsgid,
338 device_number, cifs_sb->local_nls, 345 device_number, cifs_sb->local_nls,
339 cifs_sb->mnt_cifs_flags & 346 cifs_sb->mnt_cifs_flags &
340 CIFS_MOUNT_MAP_SPECIAL_CHR); 347 CIFS_MOUNT_MAP_SPECIAL_CHR);
341 } else { 348 } else {
342 rc = CIFSSMBUnixSetPerms(xid, pTcon, 349 rc = CIFSSMBUnixSetPerms(xid, pTcon,
343 full_path, mode, (__u64)-1, (__u64)-1, 350 full_path, mode, (__u64)-1, (__u64)-1,
344 device_number, cifs_sb->local_nls, 351 device_number, cifs_sb->local_nls,
345 cifs_sb->mnt_cifs_flags & 352 cifs_sb->mnt_cifs_flags &
346 CIFS_MOUNT_MAP_SPECIAL_CHR); 353 CIFS_MOUNT_MAP_SPECIAL_CHR);
347 } 354 }
348 355
349 if(!rc) { 356 if (!rc) {
350 rc = cifs_get_inode_info_unix(&newinode, full_path, 357 rc = cifs_get_inode_info_unix(&newinode, full_path,
351 inode->i_sb,xid); 358 inode->i_sb, xid);
352 if (pTcon->nocase) 359 if (pTcon->nocase)
353 direntry->d_op = &cifs_ci_dentry_ops; 360 direntry->d_op = &cifs_ci_dentry_ops;
354 else 361 else
355 direntry->d_op = &cifs_dentry_ops; 362 direntry->d_op = &cifs_dentry_ops;
356 if(rc == 0) 363 if (rc == 0)
357 d_instantiate(direntry, newinode); 364 d_instantiate(direntry, newinode);
358 } 365 }
359 } else { 366 } else {
360 if(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_UNX_EMUL) { 367 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_UNX_EMUL) {
361 int oplock = 0; 368 int oplock = 0;
362 u16 fileHandle; 369 u16 fileHandle;
363 FILE_ALL_INFO * buf; 370 FILE_ALL_INFO * buf;
364 371
365 cFYI(1,("sfu compat create special file")); 372 cFYI(1, ("sfu compat create special file"));
366 373
367 buf = kmalloc(sizeof(FILE_ALL_INFO),GFP_KERNEL); 374 buf = kmalloc(sizeof(FILE_ALL_INFO), GFP_KERNEL);
368 if(buf == NULL) { 375 if (buf == NULL) {
369 kfree(full_path); 376 kfree(full_path);
370 FreeXid(xid); 377 FreeXid(xid);
371 return -ENOMEM; 378 return -ENOMEM;
@@ -373,39 +380,38 @@ int cifs_mknod(struct inode *inode, struct dentry *direntry, int mode,
373 380
374 rc = CIFSSMBOpen(xid, pTcon, full_path, 381 rc = CIFSSMBOpen(xid, pTcon, full_path,
375 FILE_CREATE, /* fail if exists */ 382 FILE_CREATE, /* fail if exists */
376 GENERIC_WRITE /* BB would 383 GENERIC_WRITE /* BB would
377 WRITE_OWNER | WRITE_DAC be better? */, 384 WRITE_OWNER | WRITE_DAC be better? */,
378 /* Create a file and set the 385 /* Create a file and set the
379 file attribute to SYSTEM */ 386 file attribute to SYSTEM */
380 CREATE_NOT_DIR | CREATE_OPTION_SPECIAL, 387 CREATE_NOT_DIR | CREATE_OPTION_SPECIAL,
381 &fileHandle, &oplock, buf, 388 &fileHandle, &oplock, buf,
382 cifs_sb->local_nls, 389 cifs_sb->local_nls,
383 cifs_sb->mnt_cifs_flags & 390 cifs_sb->mnt_cifs_flags &
384 CIFS_MOUNT_MAP_SPECIAL_CHR); 391 CIFS_MOUNT_MAP_SPECIAL_CHR);
385 392
386 /* BB FIXME - add handling for backlevel servers 393 /* BB FIXME - add handling for backlevel servers
387 which need legacy open and check for all 394 which need legacy open and check for all
388 calls to SMBOpen for fallback to 395 calls to SMBOpen for fallback to SMBLeagcyOpen */
389 SMBLeagcyOpen */ 396 if (!rc) {
390 if(!rc) {
391 /* BB Do not bother to decode buf since no 397 /* BB Do not bother to decode buf since no
392 local inode yet to put timestamps in, 398 local inode yet to put timestamps in,
393 but we can reuse it safely */ 399 but we can reuse it safely */
394 int bytes_written; 400 int bytes_written;
395 struct win_dev *pdev; 401 struct win_dev *pdev;
396 pdev = (struct win_dev *)buf; 402 pdev = (struct win_dev *)buf;
397 if(S_ISCHR(mode)) { 403 if (S_ISCHR(mode)) {
398 memcpy(pdev->type, "IntxCHR", 8); 404 memcpy(pdev->type, "IntxCHR", 8);
399 pdev->major = 405 pdev->major =
400 cpu_to_le64(MAJOR(device_number)); 406 cpu_to_le64(MAJOR(device_number));
401 pdev->minor = 407 pdev->minor =
402 cpu_to_le64(MINOR(device_number)); 408 cpu_to_le64(MINOR(device_number));
403 rc = CIFSSMBWrite(xid, pTcon, 409 rc = CIFSSMBWrite(xid, pTcon,
404 fileHandle, 410 fileHandle,
405 sizeof(struct win_dev), 411 sizeof(struct win_dev),
406 0, &bytes_written, (char *)pdev, 412 0, &bytes_written, (char *)pdev,
407 NULL, 0); 413 NULL, 0);
408 } else if(S_ISBLK(mode)) { 414 } else if (S_ISBLK(mode)) {
409 memcpy(pdev->type, "IntxBLK", 8); 415 memcpy(pdev->type, "IntxBLK", 8);
410 pdev->major = 416 pdev->major =
411 cpu_to_le64(MAJOR(device_number)); 417 cpu_to_le64(MAJOR(device_number));
@@ -432,7 +438,8 @@ int cifs_mknod(struct inode *inode, struct dentry *direntry, int mode,
432 438
433 439
434struct dentry * 440struct dentry *
435cifs_lookup(struct inode *parent_dir_inode, struct dentry *direntry, struct nameidata *nd) 441cifs_lookup(struct inode *parent_dir_inode, struct dentry *direntry,
442 struct nameidata *nd)
436{ 443{
437 int xid; 444 int xid;
438 int rc = 0; /* to get around spurious gcc warning, set to zero here */ 445 int rc = 0; /* to get around spurious gcc warning, set to zero here */
@@ -447,8 +454,6 @@ cifs_lookup(struct inode *parent_dir_inode, struct dentry *direntry, struct name
447 (" parent inode = 0x%p name is: %s and dentry = 0x%p", 454 (" parent inode = 0x%p name is: %s and dentry = 0x%p",
448 parent_dir_inode, direntry->d_name.name, direntry)); 455 parent_dir_inode, direntry->d_name.name, direntry));
449 456
450 /* BB Add check of incoming data - e.g. frame not longer than maximum SMB - let server check the namelen BB */
451
452 /* check whether path exists */ 457 /* check whether path exists */
453 458
454 cifs_sb = CIFS_SB(parent_dir_inode->i_sb); 459 cifs_sb = CIFS_SB(parent_dir_inode->i_sb);
@@ -472,7 +477,7 @@ cifs_lookup(struct inode *parent_dir_inode, struct dentry *direntry, struct name
472 deadlock in the cases (beginning of sys_rename itself) 477 deadlock in the cases (beginning of sys_rename itself)
473 in which we already have the sb rename sem */ 478 in which we already have the sb rename sem */
474 full_path = build_path_from_dentry(direntry); 479 full_path = build_path_from_dentry(direntry);
475 if(full_path == NULL) { 480 if (full_path == NULL) {
476 FreeXid(xid); 481 FreeXid(xid);
477 return ERR_PTR(-ENOMEM); 482 return ERR_PTR(-ENOMEM);
478 } 483 }
@@ -487,10 +492,10 @@ cifs_lookup(struct inode *parent_dir_inode, struct dentry *direntry, struct name
487 492
488 if (pTcon->ses->capabilities & CAP_UNIX) 493 if (pTcon->ses->capabilities & CAP_UNIX)
489 rc = cifs_get_inode_info_unix(&newInode, full_path, 494 rc = cifs_get_inode_info_unix(&newInode, full_path,
490 parent_dir_inode->i_sb,xid); 495 parent_dir_inode->i_sb, xid);
491 else 496 else
492 rc = cifs_get_inode_info(&newInode, full_path, NULL, 497 rc = cifs_get_inode_info(&newInode, full_path, NULL,
493 parent_dir_inode->i_sb,xid); 498 parent_dir_inode->i_sb, xid);
494 499
495 if ((rc == 0) && (newInode != NULL)) { 500 if ((rc == 0) && (newInode != NULL)) {
496 if (pTcon->nocase) 501 if (pTcon->nocase)
@@ -499,7 +504,7 @@ cifs_lookup(struct inode *parent_dir_inode, struct dentry *direntry, struct name
499 direntry->d_op = &cifs_dentry_ops; 504 direntry->d_op = &cifs_dentry_ops;
500 d_add(direntry, newInode); 505 d_add(direntry, newInode);
501 506
502 /* since paths are not looked up by component - the parent 507 /* since paths are not looked up by component - the parent
503 directories are presumed to be good here */ 508 directories are presumed to be good here */
504 renew_parental_timestamps(direntry); 509 renew_parental_timestamps(direntry);
505 510
@@ -511,13 +516,13 @@ cifs_lookup(struct inode *parent_dir_inode, struct dentry *direntry, struct name
511 else 516 else
512 direntry->d_op = &cifs_dentry_ops; 517 direntry->d_op = &cifs_dentry_ops;
513 d_add(direntry, NULL); 518 d_add(direntry, NULL);
514 /* if it was once a directory (but how can we tell?) we could do 519 /* if it was once a directory (but how can we tell?) we could do
515 shrink_dcache_parent(direntry); */ 520 shrink_dcache_parent(direntry); */
516 } else { 521 } else {
517 cERROR(1,("Error 0x%x on cifs_get_inode_info in lookup of %s", 522 cERROR(1, ("Error 0x%x on cifs_get_inode_info in lookup of %s",
518 rc,full_path)); 523 rc, full_path));
519 /* BB special case check for Access Denied - watch security 524 /* BB special case check for Access Denied - watch security
520 exposure of returning dir info implicitly via different rc 525 exposure of returning dir info implicitly via different rc
521 if file exists or not but no access BB */ 526 if file exists or not but no access BB */
522 } 527 }
523 528
@@ -538,11 +543,11 @@ cifs_d_revalidate(struct dentry *direntry, struct nameidata *nd)
538 } else { 543 } else {
539 cFYI(1, ("neg dentry 0x%p name = %s", 544 cFYI(1, ("neg dentry 0x%p name = %s",
540 direntry, direntry->d_name.name)); 545 direntry, direntry->d_name.name));
541 if(time_after(jiffies, direntry->d_time + HZ) || 546 if (time_after(jiffies, direntry->d_time + HZ) ||
542 !lookupCacheEnabled) { 547 !lookupCacheEnabled) {
543 d_drop(direntry); 548 d_drop(direntry);
544 isValid = 0; 549 isValid = 0;
545 } 550 }
546 } 551 }
547 552
548 return isValid; 553 return isValid;
@@ -559,8 +564,7 @@ cifs_d_revalidate(struct dentry *direntry, struct nameidata *nd)
559 564
560struct dentry_operations cifs_dentry_ops = { 565struct dentry_operations cifs_dentry_ops = {
561 .d_revalidate = cifs_d_revalidate, 566 .d_revalidate = cifs_d_revalidate,
562/* d_delete: cifs_d_delete, *//* not needed except for debugging */ 567/* d_delete: cifs_d_delete, */ /* not needed except for debugging */
563 /* no need for d_hash, d_compare, d_release, d_iput ... yet. BB confirm this BB */
564}; 568};
565 569
566static int cifs_ci_hash(struct dentry *dentry, struct qstr *q) 570static int cifs_ci_hash(struct dentry *dentry, struct qstr *q)
diff --git a/fs/cifs/fcntl.c b/fs/cifs/fcntl.c
index da12b482ebe5..8e375bb4b379 100644
--- a/fs/cifs/fcntl.c
+++ b/fs/cifs/fcntl.c
@@ -2,7 +2,7 @@
2 * fs/cifs/fcntl.c 2 * fs/cifs/fcntl.c
3 * 3 *
4 * vfs operations that deal with the file control API 4 * vfs operations that deal with the file control API
5 * 5 *
6 * Copyright (C) International Business Machines Corp., 2003,2004 6 * Copyright (C) International Business Machines Corp., 2003,2004
7 * Author(s): Steve French (sfrench@us.ibm.com) 7 * Author(s): Steve French (sfrench@us.ibm.com)
8 * 8 *
@@ -35,35 +35,34 @@ static __u32 convert_to_cifs_notify_flags(unsigned long fcntl_notify_flags)
35 35
36 /* No way on Linux VFS to ask to monitor xattr 36 /* No way on Linux VFS to ask to monitor xattr
37 changes (and no stream support either */ 37 changes (and no stream support either */
38 if(fcntl_notify_flags & DN_ACCESS) { 38 if (fcntl_notify_flags & DN_ACCESS) {
39 cifs_ntfy_flags |= FILE_NOTIFY_CHANGE_LAST_ACCESS; 39 cifs_ntfy_flags |= FILE_NOTIFY_CHANGE_LAST_ACCESS;
40 } 40 }
41 if(fcntl_notify_flags & DN_MODIFY) { 41 if (fcntl_notify_flags & DN_MODIFY) {
42 /* What does this mean on directories? */ 42 /* What does this mean on directories? */
43 cifs_ntfy_flags |= FILE_NOTIFY_CHANGE_LAST_WRITE | 43 cifs_ntfy_flags |= FILE_NOTIFY_CHANGE_LAST_WRITE |
44 FILE_NOTIFY_CHANGE_SIZE; 44 FILE_NOTIFY_CHANGE_SIZE;
45 } 45 }
46 if(fcntl_notify_flags & DN_CREATE) { 46 if (fcntl_notify_flags & DN_CREATE) {
47 cifs_ntfy_flags |= FILE_NOTIFY_CHANGE_CREATION | 47 cifs_ntfy_flags |= FILE_NOTIFY_CHANGE_CREATION |
48 FILE_NOTIFY_CHANGE_LAST_WRITE; 48 FILE_NOTIFY_CHANGE_LAST_WRITE;
49 } 49 }
50 if(fcntl_notify_flags & DN_DELETE) { 50 if (fcntl_notify_flags & DN_DELETE) {
51 cifs_ntfy_flags |= FILE_NOTIFY_CHANGE_LAST_WRITE; 51 cifs_ntfy_flags |= FILE_NOTIFY_CHANGE_LAST_WRITE;
52 } 52 }
53 if(fcntl_notify_flags & DN_RENAME) { 53 if (fcntl_notify_flags & DN_RENAME) {
54 /* BB review this - checking various server behaviors */ 54 /* BB review this - checking various server behaviors */
55 cifs_ntfy_flags |= FILE_NOTIFY_CHANGE_DIR_NAME | 55 cifs_ntfy_flags |= FILE_NOTIFY_CHANGE_DIR_NAME |
56 FILE_NOTIFY_CHANGE_FILE_NAME; 56 FILE_NOTIFY_CHANGE_FILE_NAME;
57 } 57 }
58 if(fcntl_notify_flags & DN_ATTRIB) { 58 if (fcntl_notify_flags & DN_ATTRIB) {
59 cifs_ntfy_flags |= FILE_NOTIFY_CHANGE_SECURITY | 59 cifs_ntfy_flags |= FILE_NOTIFY_CHANGE_SECURITY |
60 FILE_NOTIFY_CHANGE_ATTRIBUTES; 60 FILE_NOTIFY_CHANGE_ATTRIBUTES;
61 } 61 }
62/* if(fcntl_notify_flags & DN_MULTISHOT) { 62/* if (fcntl_notify_flags & DN_MULTISHOT) {
63 cifs_ntfy_flags |= ; 63 cifs_ntfy_flags |= ;
64 } */ /* BB fixme - not sure how to handle this with CIFS yet */ 64 } */ /* BB fixme - not sure how to handle this with CIFS yet */
65 65
66
67 return cifs_ntfy_flags; 66 return cifs_ntfy_flags;
68} 67}
69 68
@@ -78,8 +77,7 @@ int cifs_dir_notify(struct file * file, unsigned long arg)
78 __u32 filter = FILE_NOTIFY_CHANGE_NAME | FILE_NOTIFY_CHANGE_ATTRIBUTES; 77 __u32 filter = FILE_NOTIFY_CHANGE_NAME | FILE_NOTIFY_CHANGE_ATTRIBUTES;
79 __u16 netfid; 78 __u16 netfid;
80 79
81 80 if (experimEnabled == 0)
82 if(experimEnabled == 0)
83 return 0; 81 return 0;
84 82
85 xid = GetXid(); 83 xid = GetXid();
@@ -88,21 +86,21 @@ int cifs_dir_notify(struct file * file, unsigned long arg)
88 86
89 full_path = build_path_from_dentry(file->f_path.dentry); 87 full_path = build_path_from_dentry(file->f_path.dentry);
90 88
91 if(full_path == NULL) { 89 if (full_path == NULL) {
92 rc = -ENOMEM; 90 rc = -ENOMEM;
93 } else { 91 } else {
94 cFYI(1,("dir notify on file %s Arg 0x%lx",full_path,arg)); 92 cFYI(1, ("dir notify on file %s Arg 0x%lx", full_path, arg));
95 rc = CIFSSMBOpen(xid, pTcon, full_path, FILE_OPEN, 93 rc = CIFSSMBOpen(xid, pTcon, full_path, FILE_OPEN,
96 GENERIC_READ | SYNCHRONIZE, 0 /* create options */, 94 GENERIC_READ | SYNCHRONIZE, 0 /* create options */,
97 &netfid, &oplock,NULL, cifs_sb->local_nls, 95 &netfid, &oplock, NULL, cifs_sb->local_nls,
98 cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR); 96 cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR);
99 /* BB fixme - add this handle to a notify handle list */ 97 /* BB fixme - add this handle to a notify handle list */
100 if(rc) { 98 if (rc) {
101 cFYI(1,("Could not open directory for notify")); 99 cFYI(1, ("Could not open directory for notify"));
102 } else { 100 } else {
103 filter = convert_to_cifs_notify_flags(arg); 101 filter = convert_to_cifs_notify_flags(arg);
104 if(filter != 0) { 102 if (filter != 0) {
105 rc = CIFSSMBNotify(xid, pTcon, 103 rc = CIFSSMBNotify(xid, pTcon,
106 0 /* no subdirs */, netfid, 104 0 /* no subdirs */, netfid,
107 filter, file, arg & DN_MULTISHOT, 105 filter, file, arg & DN_MULTISHOT,
108 cifs_sb->local_nls); 106 cifs_sb->local_nls);
@@ -113,10 +111,10 @@ int cifs_dir_notify(struct file * file, unsigned long arg)
113 it would close automatically but may be a way 111 it would close automatically but may be a way
114 to do it easily when inode freed or when 112 to do it easily when inode freed or when
115 notify info is cleared/changed */ 113 notify info is cleared/changed */
116 cFYI(1,("notify rc %d",rc)); 114 cFYI(1, ("notify rc %d", rc));
117 } 115 }
118 } 116 }
119 117
120 FreeXid(xid); 118 FreeXid(xid);
121 return rc; 119 return rc;
122} 120}
diff --git a/fs/cifs/inode.c b/fs/cifs/inode.c
index 3e87dad3367c..f0ff12b3f398 100644
--- a/fs/cifs/inode.c
+++ b/fs/cifs/inode.c
@@ -986,7 +986,8 @@ mkdir_get_info:
986 * failed to get it from the server or was set bogus */ 986 * failed to get it from the server or was set bogus */
987 if ((direntry->d_inode) && (direntry->d_inode->i_nlink < 2)) 987 if ((direntry->d_inode) && (direntry->d_inode->i_nlink < 2))
988 direntry->d_inode->i_nlink = 2; 988 direntry->d_inode->i_nlink = 2;
989 if (cifs_sb->tcon->ses->capabilities & CAP_UNIX) 989 if (cifs_sb->tcon->ses->capabilities & CAP_UNIX) {
990 mode &= ~current->fs->umask;
990 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SET_UID) { 991 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SET_UID) {
991 CIFSSMBUnixSetPerms(xid, pTcon, full_path, 992 CIFSSMBUnixSetPerms(xid, pTcon, full_path,
992 mode, 993 mode,
@@ -1004,7 +1005,7 @@ mkdir_get_info:
1004 cifs_sb->mnt_cifs_flags & 1005 cifs_sb->mnt_cifs_flags &
1005 CIFS_MOUNT_MAP_SPECIAL_CHR); 1006 CIFS_MOUNT_MAP_SPECIAL_CHR);
1006 } 1007 }
1007 else { 1008 } else {
1008 /* BB to be implemented via Windows secrty descriptors 1009 /* BB to be implemented via Windows secrty descriptors
1009 eg CIFSSMBWinSetPerms(xid, pTcon, full_path, mode, 1010 eg CIFSSMBWinSetPerms(xid, pTcon, full_path, mode,
1010 -1, -1, local_nls); */ 1011 -1, -1, local_nls); */
diff --git a/fs/cifs/ioctl.c b/fs/cifs/ioctl.c
index e34c7db00f6f..a414f1775ae0 100644
--- a/fs/cifs/ioctl.c
+++ b/fs/cifs/ioctl.c
@@ -30,7 +30,7 @@
30 30
31#define CIFS_IOC_CHECKUMOUNT _IO(0xCF, 2) 31#define CIFS_IOC_CHECKUMOUNT _IO(0xCF, 2)
32 32
33int cifs_ioctl (struct inode * inode, struct file * filep, 33int cifs_ioctl (struct inode * inode, struct file * filep,
34 unsigned int command, unsigned long arg) 34 unsigned int command, unsigned long arg)
35{ 35{
36 int rc = -ENOTTY; /* strange error - but the precedent */ 36 int rc = -ENOTTY; /* strange error - but the precedent */
@@ -47,13 +47,13 @@ int cifs_ioctl (struct inode * inode, struct file * filep,
47 47
48 xid = GetXid(); 48 xid = GetXid();
49 49
50 cFYI(1,("ioctl file %p cmd %u arg %lu",filep,command,arg)); 50 cFYI(1, ("ioctl file %p cmd %u arg %lu", filep, command, arg));
51 51
52 cifs_sb = CIFS_SB(inode->i_sb); 52 cifs_sb = CIFS_SB(inode->i_sb);
53 53
54#ifdef CONFIG_CIFS_POSIX 54#ifdef CONFIG_CIFS_POSIX
55 tcon = cifs_sb->tcon; 55 tcon = cifs_sb->tcon;
56 if(tcon) 56 if (tcon)
57 caps = le64_to_cpu(tcon->fsUnixInfo.Capability); 57 caps = le64_to_cpu(tcon->fsUnixInfo.Capability);
58 else { 58 else {
59 rc = -EIO; 59 rc = -EIO;
@@ -62,24 +62,24 @@ int cifs_ioctl (struct inode * inode, struct file * filep,
62 } 62 }
63#endif /* CONFIG_CIFS_POSIX */ 63#endif /* CONFIG_CIFS_POSIX */
64 64
65 switch(command) { 65 switch (command) {
66 case CIFS_IOC_CHECKUMOUNT: 66 case CIFS_IOC_CHECKUMOUNT:
67 cFYI(1,("User unmount attempted")); 67 cFYI(1, ("User unmount attempted"));
68 if(cifs_sb->mnt_uid == current->uid) 68 if (cifs_sb->mnt_uid == current->uid)
69 rc = 0; 69 rc = 0;
70 else { 70 else {
71 rc = -EACCES; 71 rc = -EACCES;
72 cFYI(1,("uids do not match")); 72 cFYI(1, ("uids do not match"));
73 } 73 }
74 break; 74 break;
75#ifdef CONFIG_CIFS_POSIX 75#ifdef CONFIG_CIFS_POSIX
76 case FS_IOC_GETFLAGS: 76 case FS_IOC_GETFLAGS:
77 if(CIFS_UNIX_EXTATTR_CAP & caps) { 77 if (CIFS_UNIX_EXTATTR_CAP & caps) {
78 if (pSMBFile == NULL) 78 if (pSMBFile == NULL)
79 break; 79 break;
80 rc = CIFSGetExtAttr(xid, tcon, pSMBFile->netfid, 80 rc = CIFSGetExtAttr(xid, tcon, pSMBFile->netfid,
81 &ExtAttrBits, &ExtAttrMask); 81 &ExtAttrBits, &ExtAttrMask);
82 if(rc == 0) 82 if (rc == 0)
83 rc = put_user(ExtAttrBits & 83 rc = put_user(ExtAttrBits &
84 FS_FL_USER_VISIBLE, 84 FS_FL_USER_VISIBLE,
85 (int __user *)arg); 85 (int __user *)arg);
@@ -87,8 +87,8 @@ int cifs_ioctl (struct inode * inode, struct file * filep,
87 break; 87 break;
88 88
89 case FS_IOC_SETFLAGS: 89 case FS_IOC_SETFLAGS:
90 if(CIFS_UNIX_EXTATTR_CAP & caps) { 90 if (CIFS_UNIX_EXTATTR_CAP & caps) {
91 if(get_user(ExtAttrBits,(int __user *)arg)) { 91 if (get_user(ExtAttrBits, (int __user *)arg)) {
92 rc = -EFAULT; 92 rc = -EFAULT;
93 break; 93 break;
94 } 94 }
@@ -96,16 +96,15 @@ int cifs_ioctl (struct inode * inode, struct file * filep,
96 break; 96 break;
97 /* rc= CIFSGetExtAttr(xid,tcon,pSMBFile->netfid, 97 /* rc= CIFSGetExtAttr(xid,tcon,pSMBFile->netfid,
98 extAttrBits, &ExtAttrMask);*/ 98 extAttrBits, &ExtAttrMask);*/
99
100 } 99 }
101 cFYI(1,("set flags not implemented yet")); 100 cFYI(1, ("set flags not implemented yet"));
102 break; 101 break;
103#endif /* CONFIG_CIFS_POSIX */ 102#endif /* CONFIG_CIFS_POSIX */
104 default: 103 default:
105 cFYI(1,("unsupported ioctl")); 104 cFYI(1, ("unsupported ioctl"));
106 break; 105 break;
107 } 106 }
108 107
109 FreeXid(xid); 108 FreeXid(xid);
110 return rc; 109 return rc;
111} 110}
diff --git a/fs/cifs/rfc1002pdu.h b/fs/cifs/rfc1002pdu.h
index aede606132aa..8b69fcceb597 100644
--- a/fs/cifs/rfc1002pdu.h
+++ b/fs/cifs/rfc1002pdu.h
@@ -18,7 +18,7 @@
18 * 18 *
19 * You should have received a copy of the GNU Lesser General Public License 19 * You should have received a copy of the GNU Lesser General Public License
20 * along with this library; if not, write to the Free Software 20 * along with this library; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 */ 22 */
23 23
24/* NB: unlike smb/cifs packets, the RFC1002 structures are big endian */ 24/* NB: unlike smb/cifs packets, the RFC1002 structures are big endian */
diff --git a/fs/splice.c b/fs/splice.c
index 12f28281d2b1..cb211360273a 100644
--- a/fs/splice.c
+++ b/fs/splice.c
@@ -272,7 +272,6 @@ __generic_file_splice_read(struct file *in, loff_t *ppos,
272 struct page *page; 272 struct page *page;
273 pgoff_t index, end_index; 273 pgoff_t index, end_index;
274 loff_t isize; 274 loff_t isize;
275 size_t total_len;
276 int error, page_nr; 275 int error, page_nr;
277 struct splice_pipe_desc spd = { 276 struct splice_pipe_desc spd = {
278 .pages = pages, 277 .pages = pages,
@@ -298,7 +297,6 @@ __generic_file_splice_read(struct file *in, loff_t *ppos,
298 * Now fill in the holes: 297 * Now fill in the holes:
299 */ 298 */
300 error = 0; 299 error = 0;
301 total_len = 0;
302 300
303 /* 301 /*
304 * Lookup the (hopefully) full range of pages we need. 302 * Lookup the (hopefully) full range of pages we need.
@@ -415,43 +413,47 @@ __generic_file_splice_read(struct file *in, loff_t *ppos,
415 413
416 break; 414 break;
417 } 415 }
416 }
417fill_it:
418 /*
419 * i_size must be checked after PageUptodate.
420 */
421 isize = i_size_read(mapping->host);
422 end_index = (isize - 1) >> PAGE_CACHE_SHIFT;
423 if (unlikely(!isize || index > end_index))
424 break;
425
426 /*
427 * if this is the last page, see if we need to shrink
428 * the length and stop
429 */
430 if (end_index == index) {
431 unsigned int plen;
418 432
419 /* 433 /*
420 * i_size must be checked after ->readpage(). 434 * max good bytes in this page
421 */ 435 */
422 isize = i_size_read(mapping->host); 436 plen = ((isize - 1) & ~PAGE_CACHE_MASK) + 1;
423 end_index = (isize - 1) >> PAGE_CACHE_SHIFT; 437 if (plen <= loff)
424 if (unlikely(!isize || index > end_index))
425 break; 438 break;
426 439
427 /* 440 /*
428 * if this is the last page, see if we need to shrink 441 * force quit after adding this page
429 * the length and stop
430 */ 442 */
431 if (end_index == index) { 443 this_len = min(this_len, plen - loff);
432 loff = PAGE_CACHE_SIZE - (isize & ~PAGE_CACHE_MASK); 444 len = this_len;
433 if (total_len + loff > isize)
434 break;
435 /*
436 * force quit after adding this page
437 */
438 len = this_len;
439 this_len = min(this_len, loff);
440 loff = 0;
441 }
442 } 445 }
443fill_it: 446
444 partial[page_nr].offset = loff; 447 partial[page_nr].offset = loff;
445 partial[page_nr].len = this_len; 448 partial[page_nr].len = this_len;
446 len -= this_len; 449 len -= this_len;
447 total_len += this_len;
448 loff = 0; 450 loff = 0;
449 spd.nr_pages++; 451 spd.nr_pages++;
450 index++; 452 index++;
451 } 453 }
452 454
453 /* 455 /*
454 * Release any pages at the end, if we quit early. 'i' is how far 456 * Release any pages at the end, if we quit early. 'page_nr' is how far
455 * we got, 'nr_pages' is how many pages are in the map. 457 * we got, 'nr_pages' is how many pages are in the map.
456 */ 458 */
457 while (page_nr < nr_pages) 459 while (page_nr < nr_pages)
@@ -478,10 +480,18 @@ ssize_t generic_file_splice_read(struct file *in, loff_t *ppos,
478{ 480{
479 ssize_t spliced; 481 ssize_t spliced;
480 int ret; 482 int ret;
483 loff_t isize, left;
484
485 isize = i_size_read(in->f_mapping->host);
486 if (unlikely(*ppos >= isize))
487 return 0;
488
489 left = isize - *ppos;
490 if (unlikely(left < len))
491 len = left;
481 492
482 ret = 0; 493 ret = 0;
483 spliced = 0; 494 spliced = 0;
484
485 while (len) { 495 while (len) {
486 ret = __generic_file_splice_read(in, ppos, pipe, len, flags); 496 ret = __generic_file_splice_read(in, ppos, pipe, len, flags);
487 497
@@ -644,7 +654,6 @@ find_page:
644 * accessed, we are now done! 654 * accessed, we are now done!
645 */ 655 */
646 mark_page_accessed(page); 656 mark_page_accessed(page);
647 balance_dirty_pages_ratelimited(mapping);
648out: 657out:
649 page_cache_release(page); 658 page_cache_release(page);
650 unlock_page(page); 659 unlock_page(page);
@@ -815,6 +824,7 @@ generic_file_splice_write_nolock(struct pipe_inode_info *pipe, struct file *out,
815 if (err) 824 if (err)
816 ret = err; 825 ret = err;
817 } 826 }
827 balance_dirty_pages_ratelimited(mapping);
818 } 828 }
819 829
820 return ret; 830 return ret;
@@ -868,6 +878,7 @@ generic_file_splice_write(struct pipe_inode_info *pipe, struct file *out,
868 if (err) 878 if (err)
869 ret = err; 879 ret = err;
870 } 880 }
881 balance_dirty_pages_ratelimited(mapping);
871 } 882 }
872 883
873 return ret; 884 return ret;
@@ -922,7 +933,6 @@ static long do_splice_to(struct file *in, loff_t *ppos,
922 struct pipe_inode_info *pipe, size_t len, 933 struct pipe_inode_info *pipe, size_t len,
923 unsigned int flags) 934 unsigned int flags)
924{ 935{
925 loff_t isize, left;
926 int ret; 936 int ret;
927 937
928 if (unlikely(!in->f_op || !in->f_op->splice_read)) 938 if (unlikely(!in->f_op || !in->f_op->splice_read))
@@ -935,14 +945,6 @@ static long do_splice_to(struct file *in, loff_t *ppos,
935 if (unlikely(ret < 0)) 945 if (unlikely(ret < 0))
936 return ret; 946 return ret;
937 947
938 isize = i_size_read(in->f_mapping->host);
939 if (unlikely(*ppos >= isize))
940 return 0;
941
942 left = isize - *ppos;
943 if (unlikely(left < len))
944 len = left;
945
946 return in->f_op->splice_read(in, ppos, pipe, len, flags); 948 return in->f_op->splice_read(in, ppos, pipe, len, flags);
947} 949}
948 950
@@ -1058,8 +1060,6 @@ out_release:
1058 return ret; 1060 return ret;
1059} 1061}
1060 1062
1061EXPORT_SYMBOL(do_splice_direct);
1062
1063/* 1063/*
1064 * After the inode slimming patch, i_pipe/i_bdev/i_cdev share the same 1064 * After the inode slimming patch, i_pipe/i_bdev/i_cdev share the same
1065 * location, so checking ->i_pipe is not enough to verify that this is a 1065 * location, so checking ->i_pipe is not enough to verify that this is a
diff --git a/include/asm-mips/bitops.h b/include/asm-mips/bitops.h
index d995413e11fd..ffe245b4258f 100644
--- a/include/asm-mips/bitops.h
+++ b/include/asm-mips/bitops.h
@@ -238,10 +238,11 @@ static inline int test_and_set_bit(unsigned long nr,
238 volatile unsigned long *addr) 238 volatile unsigned long *addr)
239{ 239{
240 unsigned short bit = nr & SZLONG_MASK; 240 unsigned short bit = nr & SZLONG_MASK;
241 unsigned long res;
241 242
242 if (cpu_has_llsc && R10000_LLSC_WAR) { 243 if (cpu_has_llsc && R10000_LLSC_WAR) {
243 unsigned long *m = ((unsigned long *) addr) + (nr >> SZLONG_LOG); 244 unsigned long *m = ((unsigned long *) addr) + (nr >> SZLONG_LOG);
244 unsigned long temp, res; 245 unsigned long temp;
245 246
246 __asm__ __volatile__( 247 __asm__ __volatile__(
247 " .set mips3 \n" 248 " .set mips3 \n"
@@ -254,11 +255,9 @@ static inline int test_and_set_bit(unsigned long nr,
254 : "=&r" (temp), "=m" (*m), "=&r" (res) 255 : "=&r" (temp), "=m" (*m), "=&r" (res)
255 : "r" (1UL << bit), "m" (*m) 256 : "r" (1UL << bit), "m" (*m)
256 : "memory"); 257 : "memory");
257
258 return res != 0;
259 } else if (cpu_has_llsc) { 258 } else if (cpu_has_llsc) {
260 unsigned long *m = ((unsigned long *) addr) + (nr >> SZLONG_LOG); 259 unsigned long *m = ((unsigned long *) addr) + (nr >> SZLONG_LOG);
261 unsigned long temp, res; 260 unsigned long temp;
262 261
263 __asm__ __volatile__( 262 __asm__ __volatile__(
264 " .set push \n" 263 " .set push \n"
@@ -277,25 +276,22 @@ static inline int test_and_set_bit(unsigned long nr,
277 : "=&r" (temp), "=m" (*m), "=&r" (res) 276 : "=&r" (temp), "=m" (*m), "=&r" (res)
278 : "r" (1UL << bit), "m" (*m) 277 : "r" (1UL << bit), "m" (*m)
279 : "memory"); 278 : "memory");
280
281 return res != 0;
282 } else { 279 } else {
283 volatile unsigned long *a = addr; 280 volatile unsigned long *a = addr;
284 unsigned long mask; 281 unsigned long mask;
285 int retval;
286 unsigned long flags; 282 unsigned long flags;
287 283
288 a += nr >> SZLONG_LOG; 284 a += nr >> SZLONG_LOG;
289 mask = 1UL << bit; 285 mask = 1UL << bit;
290 raw_local_irq_save(flags); 286 raw_local_irq_save(flags);
291 retval = (mask & *a) != 0; 287 res = (mask & *a);
292 *a |= mask; 288 *a |= mask;
293 raw_local_irq_restore(flags); 289 raw_local_irq_restore(flags);
294
295 return retval;
296 } 290 }
297 291
298 smp_mb(); 292 smp_mb();
293
294 return res != 0;
299} 295}
300 296
301/* 297/*
@@ -310,6 +306,7 @@ static inline int test_and_clear_bit(unsigned long nr,
310 volatile unsigned long *addr) 306 volatile unsigned long *addr)
311{ 307{
312 unsigned short bit = nr & SZLONG_MASK; 308 unsigned short bit = nr & SZLONG_MASK;
309 unsigned long res;
313 310
314 if (cpu_has_llsc && R10000_LLSC_WAR) { 311 if (cpu_has_llsc && R10000_LLSC_WAR) {
315 unsigned long *m = ((unsigned long *) addr) + (nr >> SZLONG_LOG); 312 unsigned long *m = ((unsigned long *) addr) + (nr >> SZLONG_LOG);
@@ -327,12 +324,10 @@ static inline int test_and_clear_bit(unsigned long nr,
327 : "=&r" (temp), "=m" (*m), "=&r" (res) 324 : "=&r" (temp), "=m" (*m), "=&r" (res)
328 : "r" (1UL << bit), "m" (*m) 325 : "r" (1UL << bit), "m" (*m)
329 : "memory"); 326 : "memory");
330
331 return res != 0;
332#ifdef CONFIG_CPU_MIPSR2 327#ifdef CONFIG_CPU_MIPSR2
333 } else if (__builtin_constant_p(nr)) { 328 } else if (__builtin_constant_p(nr)) {
334 unsigned long *m = ((unsigned long *) addr) + (nr >> SZLONG_LOG); 329 unsigned long *m = ((unsigned long *) addr) + (nr >> SZLONG_LOG);
335 unsigned long temp, res; 330 unsigned long temp;
336 331
337 __asm__ __volatile__( 332 __asm__ __volatile__(
338 "1: " __LL "%0, %1 # test_and_clear_bit \n" 333 "1: " __LL "%0, %1 # test_and_clear_bit \n"
@@ -346,12 +341,10 @@ static inline int test_and_clear_bit(unsigned long nr,
346 : "=&r" (temp), "=m" (*m), "=&r" (res) 341 : "=&r" (temp), "=m" (*m), "=&r" (res)
347 : "ri" (bit), "m" (*m) 342 : "ri" (bit), "m" (*m)
348 : "memory"); 343 : "memory");
349
350 return res;
351#endif 344#endif
352 } else if (cpu_has_llsc) { 345 } else if (cpu_has_llsc) {
353 unsigned long *m = ((unsigned long *) addr) + (nr >> SZLONG_LOG); 346 unsigned long *m = ((unsigned long *) addr) + (nr >> SZLONG_LOG);
354 unsigned long temp, res; 347 unsigned long temp;
355 348
356 __asm__ __volatile__( 349 __asm__ __volatile__(
357 " .set push \n" 350 " .set push \n"
@@ -371,25 +364,22 @@ static inline int test_and_clear_bit(unsigned long nr,
371 : "=&r" (temp), "=m" (*m), "=&r" (res) 364 : "=&r" (temp), "=m" (*m), "=&r" (res)
372 : "r" (1UL << bit), "m" (*m) 365 : "r" (1UL << bit), "m" (*m)
373 : "memory"); 366 : "memory");
374
375 return res != 0;
376 } else { 367 } else {
377 volatile unsigned long *a = addr; 368 volatile unsigned long *a = addr;
378 unsigned long mask; 369 unsigned long mask;
379 int retval;
380 unsigned long flags; 370 unsigned long flags;
381 371
382 a += nr >> SZLONG_LOG; 372 a += nr >> SZLONG_LOG;
383 mask = 1UL << bit; 373 mask = 1UL << bit;
384 raw_local_irq_save(flags); 374 raw_local_irq_save(flags);
385 retval = (mask & *a) != 0; 375 res = (mask & *a);
386 *a &= ~mask; 376 *a &= ~mask;
387 raw_local_irq_restore(flags); 377 raw_local_irq_restore(flags);
388
389 return retval;
390 } 378 }
391 379
392 smp_mb(); 380 smp_mb();
381
382 return res != 0;
393} 383}
394 384
395/* 385/*
@@ -404,10 +394,11 @@ static inline int test_and_change_bit(unsigned long nr,
404 volatile unsigned long *addr) 394 volatile unsigned long *addr)
405{ 395{
406 unsigned short bit = nr & SZLONG_MASK; 396 unsigned short bit = nr & SZLONG_MASK;
397 unsigned long res;
407 398
408 if (cpu_has_llsc && R10000_LLSC_WAR) { 399 if (cpu_has_llsc && R10000_LLSC_WAR) {
409 unsigned long *m = ((unsigned long *) addr) + (nr >> SZLONG_LOG); 400 unsigned long *m = ((unsigned long *) addr) + (nr >> SZLONG_LOG);
410 unsigned long temp, res; 401 unsigned long temp;
411 402
412 __asm__ __volatile__( 403 __asm__ __volatile__(
413 " .set mips3 \n" 404 " .set mips3 \n"
@@ -420,11 +411,9 @@ static inline int test_and_change_bit(unsigned long nr,
420 : "=&r" (temp), "=m" (*m), "=&r" (res) 411 : "=&r" (temp), "=m" (*m), "=&r" (res)
421 : "r" (1UL << bit), "m" (*m) 412 : "r" (1UL << bit), "m" (*m)
422 : "memory"); 413 : "memory");
423
424 return res != 0;
425 } else if (cpu_has_llsc) { 414 } else if (cpu_has_llsc) {
426 unsigned long *m = ((unsigned long *) addr) + (nr >> SZLONG_LOG); 415 unsigned long *m = ((unsigned long *) addr) + (nr >> SZLONG_LOG);
427 unsigned long temp, res; 416 unsigned long temp;
428 417
429 __asm__ __volatile__( 418 __asm__ __volatile__(
430 " .set push \n" 419 " .set push \n"
@@ -443,24 +432,22 @@ static inline int test_and_change_bit(unsigned long nr,
443 : "=&r" (temp), "=m" (*m), "=&r" (res) 432 : "=&r" (temp), "=m" (*m), "=&r" (res)
444 : "r" (1UL << bit), "m" (*m) 433 : "r" (1UL << bit), "m" (*m)
445 : "memory"); 434 : "memory");
446
447 return res != 0;
448 } else { 435 } else {
449 volatile unsigned long *a = addr; 436 volatile unsigned long *a = addr;
450 unsigned long mask, retval; 437 unsigned long mask;
451 unsigned long flags; 438 unsigned long flags;
452 439
453 a += nr >> SZLONG_LOG; 440 a += nr >> SZLONG_LOG;
454 mask = 1UL << bit; 441 mask = 1UL << bit;
455 raw_local_irq_save(flags); 442 raw_local_irq_save(flags);
456 retval = (mask & *a) != 0; 443 res = (mask & *a);
457 *a ^= mask; 444 *a ^= mask;
458 raw_local_irq_restore(flags); 445 raw_local_irq_restore(flags);
459
460 return retval;
461 } 446 }
462 447
463 smp_mb(); 448 smp_mb();
449
450 return res != 0;
464} 451}
465 452
466#include <asm-generic/bitops/non-atomic.h> 453#include <asm-generic/bitops/non-atomic.h>
diff --git a/include/asm-mips/stackframe.h b/include/asm-mips/stackframe.h
index 7afa1fdf70ca..ed33366b85b8 100644
--- a/include/asm-mips/stackframe.h
+++ b/include/asm-mips/stackframe.h
@@ -17,6 +17,18 @@
17#include <asm/mipsregs.h> 17#include <asm/mipsregs.h>
18#include <asm/asm-offsets.h> 18#include <asm/asm-offsets.h>
19 19
20/*
21 * For SMTC kernel, global IE should be left set, and interrupts
22 * controlled exclusively via IXMT.
23 */
24#ifdef CONFIG_MIPS_MT_SMTC
25#define STATMASK 0x1e
26#elif defined(CONFIG_CPU_R3000) || defined(CONFIG_CPU_TX39XX)
27#define STATMASK 0x3f
28#else
29#define STATMASK 0x1f
30#endif
31
20#ifdef CONFIG_MIPS_MT_SMTC 32#ifdef CONFIG_MIPS_MT_SMTC
21#include <asm/mipsmtregs.h> 33#include <asm/mipsmtregs.h>
22#endif /* CONFIG_MIPS_MT_SMTC */ 34#endif /* CONFIG_MIPS_MT_SMTC */
@@ -236,10 +248,10 @@
236 .set reorder 248 .set reorder
237 .set noat 249 .set noat
238 mfc0 a0, CP0_STATUS 250 mfc0 a0, CP0_STATUS
239 ori a0, 0x1f
240 xori a0, 0x1f
241 mtc0 a0, CP0_STATUS
242 li v1, 0xff00 251 li v1, 0xff00
252 ori a0, STATMASK
253 xori a0, STATMASK
254 mtc0 a0, CP0_STATUS
243 and a0, v1 255 and a0, v1
244 LONG_L v0, PT_STATUS(sp) 256 LONG_L v0, PT_STATUS(sp)
245 nor v1, $0, v1 257 nor v1, $0, v1
@@ -249,10 +261,6 @@
249 LONG_L $31, PT_R31(sp) 261 LONG_L $31, PT_R31(sp)
250 LONG_L $28, PT_R28(sp) 262 LONG_L $28, PT_R28(sp)
251 LONG_L $25, PT_R25(sp) 263 LONG_L $25, PT_R25(sp)
252#ifdef CONFIG_64BIT
253 LONG_L $8, PT_R8(sp)
254 LONG_L $9, PT_R9(sp)
255#endif
256 LONG_L $7, PT_R7(sp) 264 LONG_L $7, PT_R7(sp)
257 LONG_L $6, PT_R6(sp) 265 LONG_L $6, PT_R6(sp)
258 LONG_L $5, PT_R5(sp) 266 LONG_L $5, PT_R5(sp)
@@ -273,16 +281,6 @@
273 .endm 281 .endm
274 282
275#else 283#else
276/*
277 * For SMTC kernel, global IE should be left set, and interrupts
278 * controlled exclusively via IXMT.
279 */
280
281#ifdef CONFIG_MIPS_MT_SMTC
282#define STATMASK 0x1e
283#else
284#define STATMASK 0x1f
285#endif
286 .macro RESTORE_SOME 284 .macro RESTORE_SOME
287 .set push 285 .set push
288 .set reorder 286 .set reorder
@@ -385,9 +383,9 @@
385 .macro CLI 383 .macro CLI
386#if !defined(CONFIG_MIPS_MT_SMTC) 384#if !defined(CONFIG_MIPS_MT_SMTC)
387 mfc0 t0, CP0_STATUS 385 mfc0 t0, CP0_STATUS
388 li t1, ST0_CU0 | 0x1f 386 li t1, ST0_CU0 | STATMASK
389 or t0, t1 387 or t0, t1
390 xori t0, 0x1f 388 xori t0, STATMASK
391 mtc0 t0, CP0_STATUS 389 mtc0 t0, CP0_STATUS
392#else /* CONFIG_MIPS_MT_SMTC */ 390#else /* CONFIG_MIPS_MT_SMTC */
393 /* 391 /*
@@ -420,9 +418,9 @@
420 .macro STI 418 .macro STI
421#if !defined(CONFIG_MIPS_MT_SMTC) 419#if !defined(CONFIG_MIPS_MT_SMTC)
422 mfc0 t0, CP0_STATUS 420 mfc0 t0, CP0_STATUS
423 li t1, ST0_CU0 | 0x1f 421 li t1, ST0_CU0 | STATMASK
424 or t0, t1 422 or t0, t1
425 xori t0, 0x1e 423 xori t0, STATMASK & ~1
426 mtc0 t0, CP0_STATUS 424 mtc0 t0, CP0_STATUS
427#else /* CONFIG_MIPS_MT_SMTC */ 425#else /* CONFIG_MIPS_MT_SMTC */
428 /* 426 /*
@@ -451,7 +449,8 @@
451 .endm 449 .endm
452 450
453/* 451/*
454 * Just move to kernel mode and leave interrupts as they are. 452 * Just move to kernel mode and leave interrupts as they are. Note
453 * for the R3000 this means copying the previous enable from IEp.
455 * Set cp0 enable bit as sign that we're running on the kernel stack 454 * Set cp0 enable bit as sign that we're running on the kernel stack
456 */ 455 */
457 .macro KMODE 456 .macro KMODE
@@ -482,9 +481,14 @@
482 move ra, t0 481 move ra, t0
483#endif /* CONFIG_MIPS_MT_SMTC */ 482#endif /* CONFIG_MIPS_MT_SMTC */
484 mfc0 t0, CP0_STATUS 483 mfc0 t0, CP0_STATUS
485 li t1, ST0_CU0 | 0x1e 484 li t1, ST0_CU0 | (STATMASK & ~1)
485#if defined(CONFIG_CPU_R3000) || defined(CONFIG_CPU_TX39XX)
486 andi t2, t0, ST0_IEP
487 srl t2, 2
488 or t0, t2
489#endif
486 or t0, t1 490 or t0, t1
487 xori t0, 0x1e 491 xori t0, STATMASK & ~1
488 mtc0 t0, CP0_STATUS 492 mtc0 t0, CP0_STATUS
489#ifdef CONFIG_MIPS_MT_SMTC 493#ifdef CONFIG_MIPS_MT_SMTC
490 _ehb 494 _ehb
diff --git a/include/asm-mips/unistd.h b/include/asm-mips/unistd.h
index 91c306fcfb72..59d6fec8fbff 100644
--- a/include/asm-mips/unistd.h
+++ b/include/asm-mips/unistd.h
@@ -336,16 +336,20 @@
336#define __NR_epoll_pwait (__NR_Linux + 313) 336#define __NR_epoll_pwait (__NR_Linux + 313)
337#define __NR_ioprio_set (__NR_Linux + 314) 337#define __NR_ioprio_set (__NR_Linux + 314)
338#define __NR_ioprio_get (__NR_Linux + 315) 338#define __NR_ioprio_get (__NR_Linux + 315)
339#define __NR_utimensat (__NR_Linux + 316)
340#define __NR_signalfd (__NR_Linux + 317)
341#define __NR_timerfd (__NR_Linux + 318)
342#define __NR_eventfd (__NR_Linux + 319)
339 343
340/* 344/*
341 * Offset of the last Linux o32 flavoured syscall 345 * Offset of the last Linux o32 flavoured syscall
342 */ 346 */
343#define __NR_Linux_syscalls 315 347#define __NR_Linux_syscalls 319
344 348
345#endif /* _MIPS_SIM == _MIPS_SIM_ABI32 */ 349#endif /* _MIPS_SIM == _MIPS_SIM_ABI32 */
346 350
347#define __NR_O32_Linux 4000 351#define __NR_O32_Linux 4000
348#define __NR_O32_Linux_syscalls 315 352#define __NR_O32_Linux_syscalls 319
349 353
350#if _MIPS_SIM == _MIPS_SIM_ABI64 354#if _MIPS_SIM == _MIPS_SIM_ABI64
351 355
@@ -628,16 +632,20 @@
628#define __NR_epoll_pwait (__NR_Linux + 272) 632#define __NR_epoll_pwait (__NR_Linux + 272)
629#define __NR_ioprio_set (__NR_Linux + 273) 633#define __NR_ioprio_set (__NR_Linux + 273)
630#define __NR_ioprio_get (__NR_Linux + 274) 634#define __NR_ioprio_get (__NR_Linux + 274)
635#define __NR_utimensat (__NR_Linux + 275)
636#define __NR_signalfd (__NR_Linux + 276)
637#define __NR_timerfd (__NR_Linux + 277)
638#define __NR_eventfd (__NR_Linux + 278)
631 639
632/* 640/*
633 * Offset of the last Linux 64-bit flavoured syscall 641 * Offset of the last Linux 64-bit flavoured syscall
634 */ 642 */
635#define __NR_Linux_syscalls 274 643#define __NR_Linux_syscalls 278
636 644
637#endif /* _MIPS_SIM == _MIPS_SIM_ABI64 */ 645#endif /* _MIPS_SIM == _MIPS_SIM_ABI64 */
638 646
639#define __NR_64_Linux 5000 647#define __NR_64_Linux 5000
640#define __NR_64_Linux_syscalls 274 648#define __NR_64_Linux_syscalls 278
641 649
642#if _MIPS_SIM == _MIPS_SIM_NABI32 650#if _MIPS_SIM == _MIPS_SIM_NABI32
643 651
@@ -924,16 +932,20 @@
924#define __NR_epoll_pwait (__NR_Linux + 276) 932#define __NR_epoll_pwait (__NR_Linux + 276)
925#define __NR_ioprio_set (__NR_Linux + 277) 933#define __NR_ioprio_set (__NR_Linux + 277)
926#define __NR_ioprio_get (__NR_Linux + 278) 934#define __NR_ioprio_get (__NR_Linux + 278)
935#define __NR_utimensat (__NR_Linux + 279)
936#define __NR_signalfd (__NR_Linux + 280)
937#define __NR_timerfd (__NR_Linux + 281)
938#define __NR_eventfd (__NR_Linux + 282)
927 939
928/* 940/*
929 * Offset of the last N32 flavoured syscall 941 * Offset of the last N32 flavoured syscall
930 */ 942 */
931#define __NR_Linux_syscalls 278 943#define __NR_Linux_syscalls 282
932 944
933#endif /* _MIPS_SIM == _MIPS_SIM_NABI32 */ 945#endif /* _MIPS_SIM == _MIPS_SIM_NABI32 */
934 946
935#define __NR_N32_Linux 6000 947#define __NR_N32_Linux 6000
936#define __NR_N32_Linux_syscalls 278 948#define __NR_N32_Linux_syscalls 282
937 949
938#ifdef __KERNEL__ 950#ifdef __KERNEL__
939 951
diff --git a/include/linux/ata.h b/include/linux/ata.h
index edb31bfff68f..703febb2df31 100644
--- a/include/linux/ata.h
+++ b/include/linux/ata.h
@@ -151,6 +151,7 @@ enum {
151 ATA_CMD_WRITE_MULTI_EXT = 0x39, 151 ATA_CMD_WRITE_MULTI_EXT = 0x39,
152 ATA_CMD_WRITE_MULTI_FUA_EXT = 0xCE, 152 ATA_CMD_WRITE_MULTI_FUA_EXT = 0xCE,
153 ATA_CMD_SET_FEATURES = 0xEF, 153 ATA_CMD_SET_FEATURES = 0xEF,
154 ATA_CMD_SET_MULTI = 0xC6,
154 ATA_CMD_PACKET = 0xA0, 155 ATA_CMD_PACKET = 0xA0,
155 ATA_CMD_VERIFY = 0x40, 156 ATA_CMD_VERIFY = 0x40,
156 ATA_CMD_VERIFY_EXT = 0x42, 157 ATA_CMD_VERIFY_EXT = 0x42,
@@ -249,7 +250,7 @@ enum ata_tf_protocols {
249 /* ATA taskfile protocols */ 250 /* ATA taskfile protocols */
250 ATA_PROT_UNKNOWN, /* unknown/invalid */ 251 ATA_PROT_UNKNOWN, /* unknown/invalid */
251 ATA_PROT_NODATA, /* no data */ 252 ATA_PROT_NODATA, /* no data */
252 ATA_PROT_PIO, /* PIO single sector */ 253 ATA_PROT_PIO, /* PIO data xfer */
253 ATA_PROT_DMA, /* DMA */ 254 ATA_PROT_DMA, /* DMA */
254 ATA_PROT_NCQ, /* NCQ */ 255 ATA_PROT_NCQ, /* NCQ */
255 ATA_PROT_ATAPI, /* packet command, PIO data xfer*/ 256 ATA_PROT_ATAPI, /* packet command, PIO data xfer*/
diff --git a/include/linux/ide.h b/include/linux/ide.h
index 07aba87d369d..1e365acdd369 100644
--- a/include/linux/ide.h
+++ b/include/linux/ide.h
@@ -1001,6 +1001,7 @@ struct ide_driver_s {
1001 struct device_driver gen_driver; 1001 struct device_driver gen_driver;
1002 int (*probe)(ide_drive_t *); 1002 int (*probe)(ide_drive_t *);
1003 void (*remove)(ide_drive_t *); 1003 void (*remove)(ide_drive_t *);
1004 void (*resume)(ide_drive_t *);
1004 void (*shutdown)(ide_drive_t *); 1005 void (*shutdown)(ide_drive_t *);
1005#ifdef CONFIG_IDE_PROC_FS 1006#ifdef CONFIG_IDE_PROC_FS
1006 ide_proc_entry_t *proc; 1007 ide_proc_entry_t *proc;
diff --git a/include/linux/libata.h b/include/linux/libata.h
index a6a3113120a4..745c4f9b4caa 100644
--- a/include/linux/libata.h
+++ b/include/linux/libata.h
@@ -753,6 +753,7 @@ extern u8 ata_check_status(struct ata_port *ap);
753extern u8 ata_altstatus(struct ata_port *ap); 753extern u8 ata_altstatus(struct ata_port *ap);
754extern void ata_exec_command(struct ata_port *ap, const struct ata_taskfile *tf); 754extern void ata_exec_command(struct ata_port *ap, const struct ata_taskfile *tf);
755extern int ata_port_start (struct ata_port *ap); 755extern int ata_port_start (struct ata_port *ap);
756extern int ata_sff_port_start (struct ata_port *ap);
756extern irqreturn_t ata_interrupt (int irq, void *dev_instance); 757extern irqreturn_t ata_interrupt (int irq, void *dev_instance);
757extern void ata_data_xfer(struct ata_device *adev, unsigned char *buf, 758extern void ata_data_xfer(struct ata_device *adev, unsigned char *buf,
758 unsigned int buflen, int write_data); 759 unsigned int buflen, int write_data);
diff --git a/include/linux/pci_ids.h b/include/linux/pci_ids.h
index 6a115cffea34..9a03b47da603 100644
--- a/include/linux/pci_ids.h
+++ b/include/linux/pci_ids.h
@@ -1233,6 +1233,8 @@
1233#define PCI_DEVICE_ID_NVIDIA_NVENET_26 0x054E 1233#define PCI_DEVICE_ID_NVIDIA_NVENET_26 0x054E
1234#define PCI_DEVICE_ID_NVIDIA_NVENET_27 0x054F 1234#define PCI_DEVICE_ID_NVIDIA_NVENET_27 0x054F
1235#define PCI_DEVICE_ID_NVIDIA_NFORCE_MCP67_IDE 0x0560 1235#define PCI_DEVICE_ID_NVIDIA_NFORCE_MCP67_IDE 0x0560
1236#define PCI_DEVICE_ID_NVIDIA_NFORCE_MCP73_IDE 0x056C
1237#define PCI_DEVICE_ID_NVIDIA_NFORCE_MCP77_IDE 0x0759
1236 1238
1237#define PCI_VENDOR_ID_IMS 0x10e0 1239#define PCI_VENDOR_ID_IMS 0x10e0
1238#define PCI_DEVICE_ID_IMS_TT128 0x9128 1240#define PCI_DEVICE_ID_IMS_TT128 0x9128
diff --git a/include/linux/pipe_fs_i.h b/include/linux/pipe_fs_i.h
index 8bcbc54e1b48..c8884f971228 100644
--- a/include/linux/pipe_fs_i.h
+++ b/include/linux/pipe_fs_i.h
@@ -16,6 +16,21 @@ struct pipe_buffer {
16 unsigned int flags; 16 unsigned int flags;
17}; 17};
18 18
19struct pipe_inode_info {
20 wait_queue_head_t wait;
21 unsigned int nrbufs, curbuf;
22 struct page *tmp_page;
23 unsigned int readers;
24 unsigned int writers;
25 unsigned int waiting_writers;
26 unsigned int r_counter;
27 unsigned int w_counter;
28 struct fasync_struct *fasync_readers;
29 struct fasync_struct *fasync_writers;
30 struct inode *inode;
31 struct pipe_buffer bufs[PIPE_BUFFERS];
32};
33
19/* 34/*
20 * Note on the nesting of these functions: 35 * Note on the nesting of these functions:
21 * 36 *
@@ -38,21 +53,6 @@ struct pipe_buf_operations {
38 void (*get)(struct pipe_inode_info *, struct pipe_buffer *); 53 void (*get)(struct pipe_inode_info *, struct pipe_buffer *);
39}; 54};
40 55
41struct pipe_inode_info {
42 wait_queue_head_t wait;
43 unsigned int nrbufs, curbuf;
44 struct page *tmp_page;
45 unsigned int readers;
46 unsigned int writers;
47 unsigned int waiting_writers;
48 unsigned int r_counter;
49 unsigned int w_counter;
50 struct fasync_struct *fasync_readers;
51 struct fasync_struct *fasync_writers;
52 struct inode *inode;
53 struct pipe_buffer bufs[PIPE_BUFFERS];
54};
55
56/* Differs from PIPE_BUF in that PIPE_SIZE is the length of the actual 56/* Differs from PIPE_BUF in that PIPE_SIZE is the length of the actual
57 memory allocation, whereas PIPE_BUF makes atomicity guarantees. */ 57 memory allocation, whereas PIPE_BUF makes atomicity guarantees. */
58#define PIPE_SIZE PAGE_SIZE 58#define PIPE_SIZE PAGE_SIZE
diff --git a/include/linux/videodev2.h b/include/linux/videodev2.h
index e7560389079c..d16a2b57dc81 100644
--- a/include/linux/videodev2.h
+++ b/include/linux/videodev2.h
@@ -243,8 +243,7 @@ struct v4l2_capability
243#define V4L2_CAP_SLICED_VBI_CAPTURE 0x00000040 /* Is a sliced VBI capture device */ 243#define V4L2_CAP_SLICED_VBI_CAPTURE 0x00000040 /* Is a sliced VBI capture device */
244#define V4L2_CAP_SLICED_VBI_OUTPUT 0x00000080 /* Is a sliced VBI output device */ 244#define V4L2_CAP_SLICED_VBI_OUTPUT 0x00000080 /* Is a sliced VBI output device */
245#define V4L2_CAP_RDS_CAPTURE 0x00000100 /* RDS data capture */ 245#define V4L2_CAP_RDS_CAPTURE 0x00000100 /* RDS data capture */
246#define V4L2_CAP_VIDEO_OUTPUT_POS 0x00000200 /* Video output can have x,y coords */ 246#define V4L2_CAP_VIDEO_OUTPUT_OVERLAY 0x00000200 /* Can do video output overlay */
247#define V4L2_CAP_VIDEO_OUTPUT_OVERLAY 0x00000400 /* Can do video output overlay */
248 247
249#define V4L2_CAP_TUNER 0x00010000 /* has a tuner */ 248#define V4L2_CAP_TUNER 0x00010000 /* has a tuner */
250#define V4L2_CAP_AUDIO 0x00020000 /* has audio support */ 249#define V4L2_CAP_AUDIO 0x00020000 /* has audio support */
@@ -616,12 +615,16 @@ struct v4l2_framebuffer
616#define V4L2_FBUF_CAP_BITMAP_CLIPPING 0x0008 615#define V4L2_FBUF_CAP_BITMAP_CLIPPING 0x0008
617#define V4L2_FBUF_CAP_LOCAL_ALPHA 0x0010 616#define V4L2_FBUF_CAP_LOCAL_ALPHA 0x0010
618#define V4L2_FBUF_CAP_GLOBAL_ALPHA 0x0020 617#define V4L2_FBUF_CAP_GLOBAL_ALPHA 0x0020
618#define V4L2_FBUF_CAP_LOCAL_INV_ALPHA 0x0040
619#define V4L2_FBUF_CAP_GLOBAL_INV_ALPHA 0x0080
619/* Flags for the 'flags' field. */ 620/* Flags for the 'flags' field. */
620#define V4L2_FBUF_FLAG_PRIMARY 0x0001 621#define V4L2_FBUF_FLAG_PRIMARY 0x0001
621#define V4L2_FBUF_FLAG_OVERLAY 0x0002 622#define V4L2_FBUF_FLAG_OVERLAY 0x0002
622#define V4L2_FBUF_FLAG_CHROMAKEY 0x0004 623#define V4L2_FBUF_FLAG_CHROMAKEY 0x0004
623#define V4L2_FBUF_FLAG_LOCAL_ALPHA 0x0008 624#define V4L2_FBUF_FLAG_LOCAL_ALPHA 0x0008
624#define V4L2_FBUF_FLAG_GLOBAL_ALPHA 0x0010 625#define V4L2_FBUF_FLAG_GLOBAL_ALPHA 0x0010
626#define V4L2_FBUF_FLAG_LOCAL_INV_ALPHA 0x0020
627#define V4L2_FBUF_FLAG_GLOBAL_INV_ALPHA 0x0040
625 628
626struct v4l2_clip 629struct v4l2_clip
627{ 630{