aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorPaul Mackerras <paulus@samba.org>2008-05-16 09:13:42 -0400
committerPaul Mackerras <paulus@samba.org>2008-05-16 09:13:42 -0400
commitfcff474ea5cb17ff015aa40e92ed86fede41f1e2 (patch)
treea99c0e14daaf31cb078812fb2fbc6abadfcd738f /drivers
parent541b2755c2ef7dd2242ac606c115daa11e43ef69 (diff)
parentf26a3988917913b3d11b2bd741601a2c64ab9204 (diff)
Merge branch 'linux-2.6' into powerpc-next
Diffstat (limited to 'drivers')
-rw-r--r--drivers/base/class.c1
-rw-r--r--drivers/base/memory.c2
-rw-r--r--drivers/base/power/main.c2
-rw-r--r--drivers/char/Kconfig1
-rw-r--r--drivers/char/ipmi/ipmi_si_intf.c10
-rw-r--r--drivers/char/n_tty.c13
-rw-r--r--drivers/char/synclink_gt.c2
-rw-r--r--drivers/char/tty_io.c7
-rw-r--r--drivers/ide/Kconfig54
-rw-r--r--drivers/ide/ide-iops.c2
-rw-r--r--drivers/ide/mips/swarm.c16
-rw-r--r--drivers/ide/pci/alim15x3.c42
-rw-r--r--drivers/ide/pci/cs5520.c2
-rw-r--r--drivers/infiniband/hw/cxgb3/cxio_hal.c4
-rw-r--r--drivers/infiniband/hw/ipath/ipath_driver.c20
-rw-r--r--drivers/infiniband/hw/ipath/ipath_file_ops.c19
-rw-r--r--drivers/infiniband/hw/ipath/ipath_kernel.h10
-rw-r--r--drivers/infiniband/hw/ipath/ipath_qp.c237
-rw-r--r--drivers/infiniband/hw/ipath/ipath_rc.c285
-rw-r--r--drivers/infiniband/hw/ipath/ipath_ruc.c329
-rw-r--r--drivers/infiniband/hw/ipath/ipath_uc.c57
-rw-r--r--drivers/infiniband/hw/ipath/ipath_ud.c66
-rw-r--r--drivers/infiniband/hw/ipath/ipath_user_sdma.h2
-rw-r--r--drivers/infiniband/hw/ipath/ipath_verbs.c176
-rw-r--r--drivers/infiniband/hw/ipath/ipath_verbs.h64
-rw-r--r--drivers/infiniband/hw/nes/nes.c4
-rw-r--r--drivers/infiniband/hw/nes/nes.h1
-rw-r--r--drivers/infiniband/hw/nes/nes_hw.c6
-rw-r--r--drivers/macintosh/adb.c2
-rw-r--r--drivers/md/linear.c1
-rw-r--r--drivers/md/multipath.c1
-rw-r--r--drivers/md/raid0.c1
-rw-r--r--drivers/md/raid1.c4
-rw-r--r--drivers/md/raid10.c4
-rw-r--r--drivers/md/raid5.c26
-rw-r--r--drivers/media/Kconfig3
-rw-r--r--drivers/media/common/tuners/Kconfig50
-rw-r--r--drivers/media/common/tuners/Makefile1
-rw-r--r--drivers/media/common/tuners/mxl5005s.c4110
-rw-r--r--drivers/media/common/tuners/mxl5005s.h131
-rw-r--r--drivers/media/common/tuners/tda18271-common.c24
-rw-r--r--drivers/media/common/tuners/tda18271-fe.c168
-rw-r--r--drivers/media/common/tuners/tda18271-priv.h9
-rw-r--r--drivers/media/common/tuners/tea5767.c6
-rw-r--r--drivers/media/common/tuners/xc5000.c9
-rw-r--r--drivers/media/common/tuners/xc5000.h22
-rw-r--r--drivers/media/common/tuners/xc5000_priv.h2
-rw-r--r--drivers/media/dvb/b2c2/flexcop-fe-tuner.c2
-rw-r--r--drivers/media/dvb/bt8xx/Kconfig1
-rw-r--r--drivers/media/dvb/cinergyT2/Kconfig2
-rw-r--r--drivers/media/dvb/dvb-core/dvb_ca_en50221.c28
-rw-r--r--drivers/media/dvb/dvb-usb/Kconfig1
-rw-r--r--drivers/media/dvb/frontends/Kconfig18
-rw-r--r--drivers/media/dvb/frontends/itd1000.c2
-rw-r--r--drivers/media/dvb/frontends/mt312.c9
-rw-r--r--drivers/media/dvb/frontends/mt312.h4
-rw-r--r--drivers/media/dvb/ttpci/Kconfig2
-rw-r--r--drivers/media/dvb/ttusb-dec/Kconfig1
-rw-r--r--drivers/media/video/Kconfig10
-rw-r--r--drivers/media/video/Makefile2
-rw-r--r--drivers/media/video/au0828/Kconfig3
-rw-r--r--drivers/media/video/au0828/au0828-dvb.c6
-rw-r--r--drivers/media/video/bt8xx/Kconfig3
-rw-r--r--drivers/media/video/cx18/Kconfig5
-rw-r--r--drivers/media/video/cx18/cx18-cards.c25
-rw-r--r--drivers/media/video/cx18/cx18-cards.h5
-rw-r--r--drivers/media/video/cx18/cx18-driver.c29
-rw-r--r--drivers/media/video/cx18/cx18-driver.h3
-rw-r--r--drivers/media/video/cx18/cx18-dvb.c40
-rw-r--r--drivers/media/video/cx18/cx18-fileops.c6
-rw-r--r--drivers/media/video/cx18/cx18-fileops.h9
-rw-r--r--drivers/media/video/cx18/cx18-gpio.c47
-rw-r--r--drivers/media/video/cx18/cx18-i2c.c1
-rw-r--r--drivers/media/video/cx18/cx18-queue.c22
-rw-r--r--drivers/media/video/cx18/cx18-queue.h4
-rw-r--r--drivers/media/video/cx18/cx18-streams.c13
-rw-r--r--drivers/media/video/cx18/cx18-streams.h2
-rw-r--r--drivers/media/video/cx23885/Kconfig6
-rw-r--r--drivers/media/video/cx23885/cx23885-cards.c36
-rw-r--r--drivers/media/video/cx23885/cx23885-dvb.c7
-rw-r--r--drivers/media/video/cx25840/Kconfig1
-rw-r--r--drivers/media/video/cx88/Kconfig6
-rw-r--r--drivers/media/video/cx88/cx88-dvb.c253
-rw-r--r--drivers/media/video/em28xx/Kconfig3
-rw-r--r--drivers/media/video/em28xx/em28xx-cards.c8
-rw-r--r--drivers/media/video/em28xx/em28xx-dvb.c1
-rw-r--r--drivers/media/video/ivtv/Kconfig4
-rw-r--r--drivers/media/video/ivtv/ivtv-controls.c4
-rw-r--r--drivers/media/video/ivtv/ivtv-driver.c8
-rw-r--r--drivers/media/video/ivtv/ivtv-fileops.c2
-rw-r--r--drivers/media/video/ivtv/ivtv-ioctl.c16
-rw-r--r--drivers/media/video/ivtv/ivtv-ioctl.h6
-rw-r--r--drivers/media/video/ivtv/ivtv-queue.c12
-rw-r--r--drivers/media/video/ivtv/ivtv-streams.c13
-rw-r--r--drivers/media/video/ivtv/ivtv-streams.h2
-rw-r--r--drivers/media/video/ivtv/ivtv-vbi.c3
-rw-r--r--drivers/media/video/ivtv/ivtv-yuv.c2
-rw-r--r--drivers/media/video/ivtv/ivtvfb.c6
-rw-r--r--drivers/media/video/mt9m001.c5
-rw-r--r--drivers/media/video/mt9v022.c7
-rw-r--r--drivers/media/video/pvrusb2/Kconfig4
-rw-r--r--drivers/media/video/saa7134/Kconfig3
-rw-r--r--drivers/media/video/saa7134/saa7134-core.c6
-rw-r--r--drivers/media/video/saa7134/saa7134-dvb.c140
-rw-r--r--drivers/media/video/stk-webcam.c7
-rw-r--r--drivers/media/video/tuner-core.c38
-rw-r--r--drivers/media/video/tveeprom.c10
-rw-r--r--drivers/media/video/usbvision/Kconfig2
-rw-r--r--drivers/misc/sgi-xp/xp.h305
-rw-r--r--drivers/misc/sgi-xp/xp_main.c44
-rw-r--r--drivers/misc/sgi-xp/xpc.h83
-rw-r--r--drivers/misc/sgi-xp/xpc_channel.c186
-rw-r--r--drivers/misc/sgi-xp/xpc_main.c60
-rw-r--r--drivers/misc/sgi-xp/xpc_partition.c74
-rw-r--r--drivers/misc/sgi-xp/xpnet.c22
-rw-r--r--drivers/mmc/host/sdhci.h2
-rw-r--r--drivers/net/Kconfig2
-rw-r--r--drivers/net/atlx/atl1.c157
-rw-r--r--drivers/net/atlx/atl1.h2
-rw-r--r--drivers/net/atlx/atlx.c2
-rw-r--r--drivers/net/atlx/atlx.h7
-rw-r--r--drivers/net/cxgb3/adapter.h1
-rw-r--r--drivers/net/cxgb3/common.h1
-rw-r--r--drivers/net/cxgb3/cxgb3_main.c40
-rw-r--r--drivers/net/cxgb3/regs.h8
-rw-r--r--drivers/net/cxgb3/sge.c29
-rw-r--r--drivers/net/cxgb3/t3_hw.c28
-rw-r--r--drivers/net/dm9000.c37
-rw-r--r--drivers/net/ehea/ehea.h27
-rw-r--r--drivers/net/ehea/ehea_main.c25
-rw-r--r--drivers/net/ehea/ehea_qmr.c286
-rw-r--r--drivers/net/gianfar.c2
-rw-r--r--drivers/net/myri10ge/myri10ge.c730
-rw-r--r--drivers/net/myri10ge/myri10ge_mcp.h56
-rw-r--r--drivers/net/myri10ge/myri10ge_mcp_gen_header.h39
-rw-r--r--drivers/net/niu.c53
-rw-r--r--drivers/net/niu.h9
-rw-r--r--drivers/net/ppp_generic.c1
-rw-r--r--drivers/net/pppol2tp.c13
-rw-r--r--drivers/net/ps3_gelic_wireless.c2
-rw-r--r--drivers/net/sfc/Makefile4
-rw-r--r--drivers/net/sfc/boards.h2
-rw-r--r--drivers/net/sfc/efx.c4
-rw-r--r--drivers/net/sfc/enum.h49
-rw-r--r--drivers/net/sfc/ethtool.c259
-rw-r--r--drivers/net/sfc/falcon.c8
-rw-r--r--drivers/net/sfc/falcon_hwdefs.h16
-rw-r--r--drivers/net/sfc/falcon_xmac.c82
-rw-r--r--drivers/net/sfc/mdio_10g.c78
-rw-r--r--drivers/net/sfc/mdio_10g.h24
-rw-r--r--drivers/net/sfc/net_driver.h28
-rw-r--r--drivers/net/sfc/rx.c11
-rw-r--r--drivers/net/sfc/selftest.c717
-rw-r--r--drivers/net/sfc/selftest.h50
-rw-r--r--drivers/net/sfc/sfe4001.c14
-rw-r--r--drivers/net/sfc/tenxpress.c91
-rw-r--r--drivers/net/sfc/tx.c664
-rw-r--r--drivers/net/sfc/xfp_phy.c36
-rw-r--r--drivers/net/sky2.h4
-rw-r--r--drivers/net/wan/Kconfig4
-rw-r--r--drivers/net/wan/cosa.c14
-rw-r--r--drivers/net/wan/hdlc_ppp.c2
-rw-r--r--drivers/net/wan/hostess_sv11.c12
-rw-r--r--drivers/net/wan/lmc/lmc_main.c1
-rw-r--r--drivers/net/wan/sealevel.c1
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-3945.c2
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-4965-rs.c2
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-4965.c2
-rw-r--r--drivers/net/wireless/prism54/islpci_dev.c11
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00dev.c11
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00pci.c5
-rw-r--r--drivers/net/wireless/rt2x00/rt61pci.c31
-rw-r--r--drivers/net/wireless/wavelan.c4
-rw-r--r--drivers/net/wireless/wavelan_cs.c6
-rw-r--r--drivers/net/wireless/zd1211rw/zd_usb.c6
-rw-r--r--drivers/of/base.c3
-rw-r--r--drivers/oprofile/cpu_buffer.c2
-rw-r--r--drivers/oprofile/cpu_buffer.h2
-rw-r--r--drivers/parisc/asp.c2
-rw-r--r--drivers/parisc/ccio-dma.c36
-rw-r--r--drivers/parisc/dino.c14
-rw-r--r--drivers/parisc/gsc.c4
-rw-r--r--drivers/parisc/lasi.c2
-rw-r--r--drivers/parisc/lba_pci.c22
-rw-r--r--drivers/parisc/led.c2
-rw-r--r--drivers/parisc/sba_iommu.c42
-rw-r--r--drivers/parisc/wax.c2
-rw-r--r--drivers/pci/intel-iommu.c6
-rw-r--r--drivers/pci/pci-acpi.c109
-rw-r--r--drivers/pci/quirks.c4
-rw-r--r--drivers/pnp/base.h1
-rw-r--r--drivers/pnp/interface.c2
-rw-r--r--drivers/pnp/quirks.c131
-rw-r--r--drivers/pnp/resource.c2
-rw-r--r--drivers/pnp/support.c8
-rw-r--r--drivers/rtc/rtc-lib.c2
-rw-r--r--drivers/rtc/rtc-m41t80.c3
-rw-r--r--drivers/s390/block/dasd.c5
-rw-r--r--drivers/s390/block/dasd_devmap.c10
-rw-r--r--drivers/s390/block/dasd_int.h2
-rw-r--r--drivers/s390/char/tape_core.c31
-rw-r--r--drivers/s390/char/vmlogrdr.c2
-rw-r--r--drivers/s390/cio/blacklist.c1
-rw-r--r--drivers/s390/cio/device_pgid.c12
-rw-r--r--drivers/scsi/aha152x.c8
-rw-r--r--drivers/scsi/gdth.c51
-rw-r--r--drivers/scsi/libiscsi.c29
-rw-r--r--drivers/scsi/qla1280.c4
-rw-r--r--drivers/serial/Kconfig6
-rw-r--r--drivers/serial/mcfserial.c1
-rw-r--r--drivers/spi/Kconfig1
-rw-r--r--drivers/spi/mpc52xx_psc_spi.c2
-rw-r--r--drivers/spi/pxa2xx_spi.c2
-rw-r--r--drivers/spi/spi_mpc83xx.c411
-rw-r--r--drivers/usb/class/cdc-acm.c3
-rw-r--r--drivers/usb/core/endpoint.c11
-rw-r--r--drivers/usb/core/message.c1
-rw-r--r--drivers/usb/core/sysfs.c137
-rw-r--r--drivers/usb/core/usb.c1
-rw-r--r--drivers/usb/core/usb.h4
-rw-r--r--drivers/usb/gadget/amd5536udc.c10
-rw-r--r--drivers/usb/gadget/atmel_usba_udc.c48
-rw-r--r--drivers/usb/gadget/pxa27x_udc.c17
-rw-r--r--drivers/usb/gadget/pxa27x_udc.h8
-rw-r--r--drivers/usb/gadget/serial.c778
-rw-r--r--drivers/usb/host/isp1760-hcd.c4
-rw-r--r--drivers/usb/host/isp1760-if.c2
-rw-r--r--drivers/usb/host/ohci-sm501.c2
-rw-r--r--drivers/usb/misc/ldusb.c4
-rw-r--r--drivers/usb/misc/usbtest.c5
-rw-r--r--drivers/usb/serial/Kconfig9
-rw-r--r--drivers/usb/serial/Makefile1
-rw-r--r--drivers/usb/serial/moto_modem.c70
-rw-r--r--drivers/usb/serial/option.c9
-rw-r--r--drivers/usb/storage/unusual_devs.h71
-rw-r--r--drivers/video/Kconfig1
-rw-r--r--drivers/video/atmel_lcdfb.c11
-rw-r--r--drivers/video/console/fbcon.c31
-rw-r--r--drivers/video/geode/lxfb_ops.c22
-rw-r--r--drivers/video/logo/Kconfig10
-rw-r--r--drivers/video/logo/Makefile2
-rw-r--r--drivers/video/logo/logo.c10
-rw-r--r--drivers/video/logo/logo_blackfin_clut224.ppm1127
-rw-r--r--drivers/video/logo/logo_blackfin_vga16.ppm1127
-rw-r--r--drivers/video/pnx4008/pnxrgbfb.c11
-rw-r--r--drivers/video/tridentfb.c25
246 files changed, 12880 insertions, 3193 deletions
diff --git a/drivers/base/class.c b/drivers/base/class.c
index 0ef00e8d4153..e085af0ff94f 100644
--- a/drivers/base/class.c
+++ b/drivers/base/class.c
@@ -140,7 +140,6 @@ int class_register(struct class *cls)
140 140
141 pr_debug("device class '%s': registering\n", cls->name); 141 pr_debug("device class '%s': registering\n", cls->name);
142 142
143 INIT_LIST_HEAD(&cls->children);
144 INIT_LIST_HEAD(&cls->devices); 143 INIT_LIST_HEAD(&cls->devices);
145 INIT_LIST_HEAD(&cls->interfaces); 144 INIT_LIST_HEAD(&cls->interfaces);
146 kset_init(&cls->class_dirs); 145 kset_init(&cls->class_dirs);
diff --git a/drivers/base/memory.c b/drivers/base/memory.c
index 8ce6de5a7e28..937e8258981d 100644
--- a/drivers/base/memory.c
+++ b/drivers/base/memory.c
@@ -53,11 +53,13 @@ int register_memory_notifier(struct notifier_block *nb)
53{ 53{
54 return blocking_notifier_chain_register(&memory_chain, nb); 54 return blocking_notifier_chain_register(&memory_chain, nb);
55} 55}
56EXPORT_SYMBOL(register_memory_notifier);
56 57
57void unregister_memory_notifier(struct notifier_block *nb) 58void unregister_memory_notifier(struct notifier_block *nb)
58{ 59{
59 blocking_notifier_chain_unregister(&memory_chain, nb); 60 blocking_notifier_chain_unregister(&memory_chain, nb);
60} 61}
62EXPORT_SYMBOL(unregister_memory_notifier);
61 63
62/* 64/*
63 * register_memory - Setup a sysfs device for a memory block 65 * register_memory - Setup a sysfs device for a memory block
diff --git a/drivers/base/power/main.c b/drivers/base/power/main.c
index 7b76fd3b93a4..45cc3d9eacb8 100644
--- a/drivers/base/power/main.c
+++ b/drivers/base/power/main.c
@@ -418,7 +418,7 @@ void __suspend_report_result(const char *function, void *fn, int ret)
418{ 418{
419 if (ret) { 419 if (ret) {
420 printk(KERN_ERR "%s(): ", function); 420 printk(KERN_ERR "%s(): ", function);
421 print_fn_descriptor_symbol("%s() returns ", (unsigned long)fn); 421 print_fn_descriptor_symbol("%s returns ", fn);
422 printk("%d\n", ret); 422 printk("%d\n", ret);
423 } 423 }
424} 424}
diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig
index 5dce3877eee5..595a925c62a9 100644
--- a/drivers/char/Kconfig
+++ b/drivers/char/Kconfig
@@ -196,6 +196,7 @@ config ESPSERIAL
196config MOXA_INTELLIO 196config MOXA_INTELLIO
197 tristate "Moxa Intellio support" 197 tristate "Moxa Intellio support"
198 depends on SERIAL_NONSTANDARD && (ISA || EISA || PCI) 198 depends on SERIAL_NONSTANDARD && (ISA || EISA || PCI)
199 select FW_LOADER
199 help 200 help
200 Say Y here if you have a Moxa Intellio multiport serial card. 201 Say Y here if you have a Moxa Intellio multiport serial card.
201 202
diff --git a/drivers/char/ipmi/ipmi_si_intf.c b/drivers/char/ipmi/ipmi_si_intf.c
index 5a5455585c1d..192688344ed2 100644
--- a/drivers/char/ipmi/ipmi_si_intf.c
+++ b/drivers/char/ipmi/ipmi_si_intf.c
@@ -2352,10 +2352,16 @@ static int __devinit ipmi_of_probe(struct of_device *dev,
2352 2352
2353 info->si_type = (enum si_type) match->data; 2353 info->si_type = (enum si_type) match->data;
2354 info->addr_source = "device-tree"; 2354 info->addr_source = "device-tree";
2355 info->io_setup = mem_setup;
2356 info->irq_setup = std_irq_setup; 2355 info->irq_setup = std_irq_setup;
2357 2356
2358 info->io.addr_type = IPMI_MEM_ADDR_SPACE; 2357 if (resource.flags & IORESOURCE_IO) {
2358 info->io_setup = port_setup;
2359 info->io.addr_type = IPMI_IO_ADDR_SPACE;
2360 } else {
2361 info->io_setup = mem_setup;
2362 info->io.addr_type = IPMI_MEM_ADDR_SPACE;
2363 }
2364
2359 info->io.addr_data = resource.start; 2365 info->io.addr_data = resource.start;
2360 2366
2361 info->io.regsize = regsize ? *regsize : DEFAULT_REGSIZE; 2367 info->io.regsize = regsize ? *regsize : DEFAULT_REGSIZE;
diff --git a/drivers/char/n_tty.c b/drivers/char/n_tty.c
index 19105ec203f7..8096389b0dc2 100644
--- a/drivers/char/n_tty.c
+++ b/drivers/char/n_tty.c
@@ -282,16 +282,20 @@ static int opost(unsigned char c, struct tty_struct *tty)
282 if (O_ONLRET(tty)) 282 if (O_ONLRET(tty))
283 tty->column = 0; 283 tty->column = 0;
284 if (O_ONLCR(tty)) { 284 if (O_ONLCR(tty)) {
285 if (space < 2) 285 if (space < 2) {
286 unlock_kernel();
286 return -1; 287 return -1;
288 }
287 tty_put_char(tty, '\r'); 289 tty_put_char(tty, '\r');
288 tty->column = 0; 290 tty->column = 0;
289 } 291 }
290 tty->canon_column = tty->column; 292 tty->canon_column = tty->column;
291 break; 293 break;
292 case '\r': 294 case '\r':
293 if (O_ONOCR(tty) && tty->column == 0) 295 if (O_ONOCR(tty) && tty->column == 0) {
296 unlock_kernel();
294 return 0; 297 return 0;
298 }
295 if (O_OCRNL(tty)) { 299 if (O_OCRNL(tty)) {
296 c = '\n'; 300 c = '\n';
297 if (O_ONLRET(tty)) 301 if (O_ONLRET(tty))
@@ -303,10 +307,13 @@ static int opost(unsigned char c, struct tty_struct *tty)
303 case '\t': 307 case '\t':
304 spaces = 8 - (tty->column & 7); 308 spaces = 8 - (tty->column & 7);
305 if (O_TABDLY(tty) == XTABS) { 309 if (O_TABDLY(tty) == XTABS) {
306 if (space < spaces) 310 if (space < spaces) {
311 unlock_kernel();
307 return -1; 312 return -1;
313 }
308 tty->column += spaces; 314 tty->column += spaces;
309 tty->ops->write(tty, " ", spaces); 315 tty->ops->write(tty, " ", spaces);
316 unlock_kernel();
310 return 0; 317 return 0;
311 } 318 }
312 tty->column += spaces; 319 tty->column += spaces;
diff --git a/drivers/char/synclink_gt.c b/drivers/char/synclink_gt.c
index 2001b0e52dc6..55c1653be00c 100644
--- a/drivers/char/synclink_gt.c
+++ b/drivers/char/synclink_gt.c
@@ -916,7 +916,7 @@ static int put_char(struct tty_struct *tty, unsigned char ch)
916{ 916{
917 struct slgt_info *info = tty->driver_data; 917 struct slgt_info *info = tty->driver_data;
918 unsigned long flags; 918 unsigned long flags;
919 int ret; 919 int ret = 0;
920 920
921 if (sanity_check(info, tty->name, "put_char")) 921 if (sanity_check(info, tty->name, "put_char"))
922 return 0; 922 return 0;
diff --git a/drivers/char/tty_io.c b/drivers/char/tty_io.c
index 49c1a2267a55..e94bee032314 100644
--- a/drivers/char/tty_io.c
+++ b/drivers/char/tty_io.c
@@ -1215,10 +1215,11 @@ int tty_check_change(struct tty_struct *tty)
1215 1215
1216 if (!tty->pgrp) { 1216 if (!tty->pgrp) {
1217 printk(KERN_WARNING "tty_check_change: tty->pgrp == NULL!\n"); 1217 printk(KERN_WARNING "tty_check_change: tty->pgrp == NULL!\n");
1218 goto out; 1218 goto out_unlock;
1219 } 1219 }
1220 if (task_pgrp(current) == tty->pgrp) 1220 if (task_pgrp(current) == tty->pgrp)
1221 goto out; 1221 goto out_unlock;
1222 spin_unlock_irqrestore(&tty->ctrl_lock, flags);
1222 if (is_ignored(SIGTTOU)) 1223 if (is_ignored(SIGTTOU))
1223 goto out; 1224 goto out;
1224 if (is_current_pgrp_orphaned()) { 1225 if (is_current_pgrp_orphaned()) {
@@ -1229,6 +1230,8 @@ int tty_check_change(struct tty_struct *tty)
1229 set_thread_flag(TIF_SIGPENDING); 1230 set_thread_flag(TIF_SIGPENDING);
1230 ret = -ERESTARTSYS; 1231 ret = -ERESTARTSYS;
1231out: 1232out:
1233 return ret;
1234out_unlock:
1232 spin_unlock_irqrestore(&tty->ctrl_lock, flags); 1235 spin_unlock_irqrestore(&tty->ctrl_lock, flags);
1233 return ret; 1236 return ret;
1234} 1237}
diff --git a/drivers/ide/Kconfig b/drivers/ide/Kconfig
index f702f9152ce6..b4f3aefa12b6 100644
--- a/drivers/ide/Kconfig
+++ b/drivers/ide/Kconfig
@@ -1,8 +1,6 @@
1# 1#
2# IDE ATA ATAPI Block device driver configuration 2# IDE ATA ATAPI Block device driver configuration
3# 3#
4# Andre Hedrick <andre@linux-ide.org>
5#
6 4
7# Select HAVE_IDE if IDE is supported 5# Select HAVE_IDE if IDE is supported
8config HAVE_IDE 6config HAVE_IDE
@@ -335,7 +333,7 @@ config BLK_DEV_CMD640
335 This driver will work automatically in PCI based systems (most new 333 This driver will work automatically in PCI based systems (most new
336 systems have PCI slots). But if your system uses VESA local bus 334 systems have PCI slots). But if your system uses VESA local bus
337 (VLB) instead of PCI, you must also supply a kernel boot parameter 335 (VLB) instead of PCI, you must also supply a kernel boot parameter
338 to enable the CMD640 bugfix/support: "ide0=cmd640_vlb". (Try "man 336 to enable the CMD640 bugfix/support: "cmd640.probe_vlb". (Try "man
339 bootparam" or see the documentation of your boot loader about how to 337 bootparam" or see the documentation of your boot loader about how to
340 pass options to the kernel.) 338 pass options to the kernel.)
341 339
@@ -457,27 +455,11 @@ config BLK_DEV_ALI15X3
457 onboard chipsets. It also tests for Simplex mode and enables 455 onboard chipsets. It also tests for Simplex mode and enables
458 normal dual channel support. 456 normal dual channel support.
459 457
460 If you say Y here, you also need to say Y to "Use DMA by default 458 Please read the comments at the top of
461 when available", above. Please read the comments at the top of
462 <file:drivers/ide/pci/alim15x3.c>. 459 <file:drivers/ide/pci/alim15x3.c>.
463 460
464 If unsure, say N. 461 If unsure, say N.
465 462
466config WDC_ALI15X3
467 bool "ALI M15x3 WDC support (DANGEROUS)"
468 depends on BLK_DEV_ALI15X3
469 ---help---
470 This allows for UltraDMA support for WDC drives that ignore CRC
471 checking. You are a fool for enabling this option, but there have
472 been requests. DO NOT COMPLAIN IF YOUR DRIVE HAS FS CORRUPTION, IF
473 YOU ENABLE THIS! No one will listen, just laugh for ignoring this
474 SERIOUS WARNING.
475
476 Using this option can allow WDC drives to run at ATA-4/5 transfer
477 rates with only an ATA-2 support structure.
478
479 SAY N!
480
481config BLK_DEV_AMD74XX 463config BLK_DEV_AMD74XX
482 tristate "AMD and nVidia IDE support" 464 tristate "AMD and nVidia IDE support"
483 depends on !ARM 465 depends on !ARM
@@ -520,9 +502,6 @@ config BLK_DEV_CY82C693
520 This driver adds detection and support for the CY82C693 chipset 502 This driver adds detection and support for the CY82C693 chipset
521 used on Digital's PC-Alpha 164SX boards. 503 used on Digital's PC-Alpha 164SX boards.
522 504
523 If you say Y here, you need to say Y to "Use DMA by default
524 when available" as well.
525
526config BLK_DEV_CS5520 505config BLK_DEV_CS5520
527 tristate "Cyrix CS5510/20 MediaGX chipset support (VERY EXPERIMENTAL)" 506 tristate "Cyrix CS5510/20 MediaGX chipset support (VERY EXPERIMENTAL)"
528 depends on EXPERIMENTAL 507 depends on EXPERIMENTAL
@@ -613,13 +592,12 @@ config BLK_DEV_SC1200
613 National SCx200 series of embedded x86 "Geode" systems. 592 National SCx200 series of embedded x86 "Geode" systems.
614 593
615config BLK_DEV_PIIX 594config BLK_DEV_PIIX
616 tristate "Intel PIIXn chipsets support" 595 tristate "Intel PIIX/ICH chipsets support"
617 select BLK_DEV_IDEDMA_PCI 596 select BLK_DEV_IDEDMA_PCI
618 help 597 help
619 This driver adds explicit support for Intel PIIX and ICH chips 598 This driver adds explicit support for Intel PIIX and ICH chips.
620 and also for the Efar Victory66 (slc90e66) chip. This allows 599 This allows the kernel to change PIO, DMA and UDMA speeds and to
621 the kernel to change PIO, DMA and UDMA speeds and to configure 600 configure the chip to optimum performance.
622 the chip to optimum performance.
623 601
624config BLK_DEV_IT8213 602config BLK_DEV_IT8213
625 tristate "IT8213 IDE support" 603 tristate "IT8213 IDE support"
@@ -657,11 +635,7 @@ config BLK_DEV_PDC202XX_OLD
657 happen if the BIOS revisions of all installed cards (three-max) do 635 happen if the BIOS revisions of all installed cards (three-max) do
658 not match, the driver attempts to do dynamic tuning of the chipset 636 not match, the driver attempts to do dynamic tuning of the chipset
659 at boot-time for max-speed. Ultra33 BIOS 1.25 or newer is required 637 at boot-time for max-speed. Ultra33 BIOS 1.25 or newer is required
660 for more than one card. This card may require that you say Y to 638 for more than one card.
661 "Special UDMA Feature".
662
663 If you say Y here, you need to say Y to "Use DMA by default when
664 available" as well.
665 639
666 Please read the comments at the top of 640 Please read the comments at the top of
667 <file:drivers/ide/pci/pdc202xx_old.c>. 641 <file:drivers/ide/pci/pdc202xx_old.c>.
@@ -710,9 +684,6 @@ config BLK_DEV_SIS5513
710 ATA100: SiS635, SiS645, SiS650, SiS730, SiS735, SiS740, 684 ATA100: SiS635, SiS645, SiS650, SiS730, SiS735, SiS740,
711 SiS745, SiS750 685 SiS745, SiS750
712 686
713 If you say Y here, you need to say Y to "Use DMA by default when
714 available" as well.
715
716 Please read the comments at the top of <file:drivers/ide/pci/sis5513.c>. 687 Please read the comments at the top of <file:drivers/ide/pci/sis5513.c>.
717 688
718config BLK_DEV_SL82C105 689config BLK_DEV_SL82C105
@@ -734,9 +705,6 @@ config BLK_DEV_SLC90E66
734 and it will handle timing cycles. Since this is an improved 705 and it will handle timing cycles. Since this is an improved
735 look-a-like to the PIIX4 it should be a nice addition. 706 look-a-like to the PIIX4 it should be a nice addition.
736 707
737 If you say Y here, you need to say Y to "Use DMA by default when
738 available" as well.
739
740 Please read the comments at the top of 708 Please read the comments at the top of
741 <file:drivers/ide/pci/slc90e66.c>. 709 <file:drivers/ide/pci/slc90e66.c>.
742 710
@@ -888,17 +856,17 @@ config BLK_DEV_IDEDOUBLER
888 bool "Amiga IDE Doubler support (EXPERIMENTAL)" 856 bool "Amiga IDE Doubler support (EXPERIMENTAL)"
889 depends on BLK_DEV_GAYLE && EXPERIMENTAL 857 depends on BLK_DEV_GAYLE && EXPERIMENTAL
890 ---help--- 858 ---help---
891 This driver provides support for the so-called `IDE doublers' (made 859 This feature provides support for the so-called `IDE doublers' (made
892 by various manufacturers, e.g. Eyetech) that can be connected to 860 by various manufacturers, e.g. Eyetech) that can be connected to
893 the on-board IDE interface of some Amiga models. Using such an IDE 861 the on-board IDE interface of some Amiga models. Using such an IDE
894 doubler, you can connect up to four instead of two IDE devices to 862 doubler, you can connect up to four instead of two IDE devices to
895 the Amiga's on-board IDE interface. 863 the Amiga's on-board IDE interface.
896 864
897 Note that the normal Amiga Gayle IDE driver may not work correctly 865 Note that the normal Amiga Gayle IDE driver may not work correctly
898 if you have an IDE doubler and don't enable this driver! 866 if you have an IDE doubler and don't enable this feature!
899 867
900 Say Y if you have an IDE doubler. The driver is enabled at kernel 868 Say Y if you have an IDE doubler. The feature is enabled at kernel
901 runtime using the "ide=doubler" kernel boot parameter. 869 runtime using the "gayle.doubler" kernel boot parameter.
902 870
903config BLK_DEV_BUDDHA 871config BLK_DEV_BUDDHA
904 tristate "Buddha/Catweasel/X-Surf IDE interface support (EXPERIMENTAL)" 872 tristate "Buddha/Catweasel/X-Surf IDE interface support (EXPERIMENTAL)"
diff --git a/drivers/ide/ide-iops.c b/drivers/ide/ide-iops.c
index 57d9a9a79a6f..0daf923541ff 100644
--- a/drivers/ide/ide-iops.c
+++ b/drivers/ide/ide-iops.c
@@ -95,7 +95,7 @@ void SELECT_DRIVE (ide_drive_t *drive)
95 hwif->OUTB(drive->select.all, hwif->io_ports.device_addr); 95 hwif->OUTB(drive->select.all, hwif->io_ports.device_addr);
96} 96}
97 97
98void SELECT_MASK (ide_drive_t *drive, int mask) 98static void SELECT_MASK(ide_drive_t *drive, int mask)
99{ 99{
100 const struct ide_port_ops *port_ops = drive->hwif->port_ops; 100 const struct ide_port_ops *port_ops = drive->hwif->port_ops;
101 101
diff --git a/drivers/ide/mips/swarm.c b/drivers/ide/mips/swarm.c
index 712d17bdd470..52fee3d2771a 100644
--- a/drivers/ide/mips/swarm.c
+++ b/drivers/ide/mips/swarm.c
@@ -4,7 +4,7 @@
4 * Author: Manish Lachwani, mlachwani@mvista.com 4 * Author: Manish Lachwani, mlachwani@mvista.com
5 * Copyright (C) 2004 MIPS Technologies, Inc. All rights reserved. 5 * Copyright (C) 2004 MIPS Technologies, Inc. All rights reserved.
6 * Author: Maciej W. Rozycki <macro@mips.com> 6 * Author: Maciej W. Rozycki <macro@mips.com>
7 * Copyright (c) 2006 Maciej W. Rozycki 7 * Copyright (c) 2006, 2008 Maciej W. Rozycki
8 * 8 *
9 * This program is free software; you can redistribute it and/or 9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License 10 * modify it under the terms of the GNU General Public License
@@ -70,8 +70,9 @@ static int __devinit swarm_ide_probe(struct device *dev)
70 ide_hwif_t *hwif; 70 ide_hwif_t *hwif;
71 u8 __iomem *base; 71 u8 __iomem *base;
72 phys_t offset, size; 72 phys_t offset, size;
73 hw_regs_t hw;
73 int i; 74 int i;
74 u8 idx[4] = { 0xff, 0xff, 0xff, 0xff }; 75 u8 idx[] = { 0xff, 0xff, 0xff, 0xff };
75 76
76 if (!SIBYTE_HAVE_IDE) 77 if (!SIBYTE_HAVE_IDE)
77 return -ENODEV; 78 return -ENODEV;
@@ -112,14 +113,15 @@ static int __devinit swarm_ide_probe(struct device *dev)
112 hwif->host_flags = IDE_HFLAG_MMIO; 113 hwif->host_flags = IDE_HFLAG_MMIO;
113 default_hwif_mmiops(hwif); 114 default_hwif_mmiops(hwif);
114 115
115 hwif->chipset = ide_generic;
116
117 for (i = 0; i <= 7; i++) 116 for (i = 0; i <= 7; i++)
118 hwif->io_ports_array[i] = 117 hw.io_ports_array[i] =
119 (unsigned long)(base + ((0x1f0 + i) << 5)); 118 (unsigned long)(base + ((0x1f0 + i) << 5));
120 hwif->io_ports.ctl_addr = 119 hw.io_ports.ctl_addr =
121 (unsigned long)(base + (0x3f6 << 5)); 120 (unsigned long)(base + (0x3f6 << 5));
122 hwif->irq = K_INT_GB_IDE; 121 hw.irq = K_INT_GB_IDE;
122 hw.chipset = ide_generic;
123
124 ide_init_port_hw(hwif, &hw);
123 125
124 idx[0] = hwif->index; 126 idx[0] = hwif->index;
125 127
diff --git a/drivers/ide/pci/alim15x3.c b/drivers/ide/pci/alim15x3.c
index c1922f9cfe80..f2129d5e07f2 100644
--- a/drivers/ide/pci/alim15x3.c
+++ b/drivers/ide/pci/alim15x3.c
@@ -39,6 +39,16 @@
39#include <asm/io.h> 39#include <asm/io.h>
40 40
41/* 41/*
42 * Allow UDMA on M1543C-E chipset for WDC disks that ignore CRC checking
43 * (this is DANGEROUS and could result in data corruption).
44 */
45static int wdc_udma;
46
47module_param(wdc_udma, bool, 0);
48MODULE_PARM_DESC(wdc_udma,
49 "allow UDMA on M1543C-E chipset for WDC disks (DANGEROUS)");
50
51/*
42 * ALi devices are not plug in. Otherwise these static values would 52 * ALi devices are not plug in. Otherwise these static values would
43 * need to go. They ought to go away anyway 53 * need to go. They ought to go away anyway
44 */ 54 */
@@ -76,11 +86,6 @@ static void ali_set_pio_mode(ide_drive_t *drive, const u8 pio)
76 a_clc = 0; 86 a_clc = 0;
77 c_time = ide_pio_timings[pio].cycle_time; 87 c_time = ide_pio_timings[pio].cycle_time;
78 88
79#if 0
80 if ((r_clc = ((c_time - s_time - a_time) * bus_speed + 999) / 1000) >= 16)
81 r_clc = 0;
82#endif
83
84 if (!(r_clc = (c_time * bus_speed + 999) / 1000 - a_clc - s_clc)) { 89 if (!(r_clc = (c_time * bus_speed + 999) / 1000 - a_clc - s_clc)) {
85 r_clc = 1; 90 r_clc = 1;
86 } else { 91 } else {
@@ -110,16 +115,6 @@ static void ali_set_pio_mode(ide_drive_t *drive, const u8 pio)
110 pci_write_config_byte(dev, port, s_clc); 115 pci_write_config_byte(dev, port, s_clc);
111 pci_write_config_byte(dev, port+drive->select.b.unit+2, (a_clc << 4) | r_clc); 116 pci_write_config_byte(dev, port+drive->select.b.unit+2, (a_clc << 4) | r_clc);
112 local_irq_restore(flags); 117 local_irq_restore(flags);
113
114 /*
115 * setup active rec
116 * { 70, 165, 365 }, PIO Mode 0
117 * { 50, 125, 208 }, PIO Mode 1
118 * { 30, 100, 110 }, PIO Mode 2
119 * { 30, 80, 70 }, PIO Mode 3 with IORDY
120 * { 25, 70, 25 }, PIO Mode 4 with IORDY ns
121 * { 20, 50, 30 } PIO Mode 5 with IORDY (nonstandard)
122 */
123} 118}
124 119
125/** 120/**
@@ -131,9 +126,7 @@ static void ali_set_pio_mode(ide_drive_t *drive, const u8 pio)
131 * The actual rules for the ALi are: 126 * The actual rules for the ALi are:
132 * No UDMA on revisions <= 0x20 127 * No UDMA on revisions <= 0x20
133 * Disk only for revisions < 0xC2 128 * Disk only for revisions < 0xC2
134 * Not WDC drives for revisions < 0xC2 129 * Not WDC drives on M1543C-E (?)
135 *
136 * FIXME: WDC ifdef needs to die
137 */ 130 */
138 131
139static u8 ali_udma_filter(ide_drive_t *drive) 132static u8 ali_udma_filter(ide_drive_t *drive)
@@ -141,10 +134,9 @@ static u8 ali_udma_filter(ide_drive_t *drive)
141 if (m5229_revision > 0x20 && m5229_revision < 0xC2) { 134 if (m5229_revision > 0x20 && m5229_revision < 0xC2) {
142 if (drive->media != ide_disk) 135 if (drive->media != ide_disk)
143 return 0; 136 return 0;
144#ifndef CONFIG_WDC_ALI15X3 137 if (chip_is_1543c_e && strstr(drive->id->model, "WDC ") &&
145 if (chip_is_1543c_e && strstr(drive->id->model, "WDC ")) 138 wdc_udma == 0)
146 return 0; 139 return 0;
147#endif
148 } 140 }
149 141
150 return drive->hwif->ultra_mask; 142 return drive->hwif->ultra_mask;
@@ -537,17 +529,9 @@ static const struct ide_port_info ali15x3_chipset __devinitdata = {
537 529
538static int __devinit alim15x3_init_one(struct pci_dev *dev, const struct pci_device_id *id) 530static int __devinit alim15x3_init_one(struct pci_dev *dev, const struct pci_device_id *id)
539{ 531{
540 static struct pci_device_id ati_rs100[] = {
541 { PCI_DEVICE(PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_RS100) },
542 { },
543 };
544
545 struct ide_port_info d = ali15x3_chipset; 532 struct ide_port_info d = ali15x3_chipset;
546 u8 rev = dev->revision, idx = id->driver_data; 533 u8 rev = dev->revision, idx = id->driver_data;
547 534
548 if (pci_dev_present(ati_rs100))
549 printk(KERN_WARNING "alim15x3: ATI Radeon IGP Northbridge is not yet fully tested.\n");
550
551 /* don't use LBA48 DMA on ALi devices before rev 0xC5 */ 535 /* don't use LBA48 DMA on ALi devices before rev 0xC5 */
552 if (rev <= 0xC4) 536 if (rev <= 0xC4)
553 d.host_flags |= IDE_HFLAG_NO_LBA48_DMA; 537 d.host_flags |= IDE_HFLAG_NO_LBA48_DMA;
diff --git a/drivers/ide/pci/cs5520.c b/drivers/ide/pci/cs5520.c
index 17669a434438..992b1cf8db69 100644
--- a/drivers/ide/pci/cs5520.c
+++ b/drivers/ide/pci/cs5520.c
@@ -119,6 +119,7 @@ static const struct ide_dma_ops cs5520_dma_ops = {
119 .dma_timeout = ide_dma_timeout, 119 .dma_timeout = ide_dma_timeout,
120}; 120};
121 121
122/* FIXME: VDMA is disabled because it caused system hangs */
122#define DECLARE_CS_DEV(name_str) \ 123#define DECLARE_CS_DEV(name_str) \
123 { \ 124 { \
124 .name = name_str, \ 125 .name = name_str, \
@@ -126,7 +127,6 @@ static const struct ide_dma_ops cs5520_dma_ops = {
126 .dma_ops = &cs5520_dma_ops, \ 127 .dma_ops = &cs5520_dma_ops, \
127 .host_flags = IDE_HFLAG_ISA_PORTS | \ 128 .host_flags = IDE_HFLAG_ISA_PORTS | \
128 IDE_HFLAG_CS5520 | \ 129 IDE_HFLAG_CS5520 | \
129 IDE_HFLAG_VDMA | \
130 IDE_HFLAG_NO_ATAPI_DMA | \ 130 IDE_HFLAG_NO_ATAPI_DMA | \
131 IDE_HFLAG_ABUSE_SET_DMA_MODE, \ 131 IDE_HFLAG_ABUSE_SET_DMA_MODE, \
132 .pio_mask = ATA_PIO4, \ 132 .pio_mask = ATA_PIO4, \
diff --git a/drivers/infiniband/hw/cxgb3/cxio_hal.c b/drivers/infiniband/hw/cxgb3/cxio_hal.c
index ebf9d3043f80..3f441fc57c17 100644
--- a/drivers/infiniband/hw/cxgb3/cxio_hal.c
+++ b/drivers/infiniband/hw/cxgb3/cxio_hal.c
@@ -405,11 +405,11 @@ int cxio_flush_sq(struct t3_wq *wq, struct t3_cq *cq, int count)
405 struct t3_swsq *sqp = wq->sq + Q_PTR2IDX(wq->sq_rptr, wq->sq_size_log2); 405 struct t3_swsq *sqp = wq->sq + Q_PTR2IDX(wq->sq_rptr, wq->sq_size_log2);
406 406
407 ptr = wq->sq_rptr + count; 407 ptr = wq->sq_rptr + count;
408 sqp += count; 408 sqp = wq->sq + Q_PTR2IDX(ptr, wq->sq_size_log2);
409 while (ptr != wq->sq_wptr) { 409 while (ptr != wq->sq_wptr) {
410 insert_sq_cqe(wq, cq, sqp); 410 insert_sq_cqe(wq, cq, sqp);
411 sqp++;
412 ptr++; 411 ptr++;
412 sqp = wq->sq + Q_PTR2IDX(ptr, wq->sq_size_log2);
413 flushed++; 413 flushed++;
414 } 414 }
415 return flushed; 415 return flushed;
diff --git a/drivers/infiniband/hw/ipath/ipath_driver.c b/drivers/infiniband/hw/ipath/ipath_driver.c
index ce7b7c34360e..daad09a45910 100644
--- a/drivers/infiniband/hw/ipath/ipath_driver.c
+++ b/drivers/infiniband/hw/ipath/ipath_driver.c
@@ -1894,7 +1894,7 @@ void ipath_cancel_sends(struct ipath_devdata *dd, int restore_sendctrl)
1894 */ 1894 */
1895 if (dd->ipath_flags & IPATH_HAS_SEND_DMA) { 1895 if (dd->ipath_flags & IPATH_HAS_SEND_DMA) {
1896 int skip_cancel; 1896 int skip_cancel;
1897 u64 *statp = &dd->ipath_sdma_status; 1897 unsigned long *statp = &dd->ipath_sdma_status;
1898 1898
1899 spin_lock_irqsave(&dd->ipath_sdma_lock, flags); 1899 spin_lock_irqsave(&dd->ipath_sdma_lock, flags);
1900 skip_cancel = 1900 skip_cancel =
@@ -2616,7 +2616,7 @@ int ipath_reset_device(int unit)
2616 ipath_dbg("unit %u port %d is in use " 2616 ipath_dbg("unit %u port %d is in use "
2617 "(PID %u cmd %s), can't reset\n", 2617 "(PID %u cmd %s), can't reset\n",
2618 unit, i, 2618 unit, i,
2619 dd->ipath_pd[i]->port_pid, 2619 pid_nr(dd->ipath_pd[i]->port_pid),
2620 dd->ipath_pd[i]->port_comm); 2620 dd->ipath_pd[i]->port_comm);
2621 ret = -EBUSY; 2621 ret = -EBUSY;
2622 goto bail; 2622 goto bail;
@@ -2654,19 +2654,21 @@ bail:
2654static int ipath_signal_procs(struct ipath_devdata *dd, int sig) 2654static int ipath_signal_procs(struct ipath_devdata *dd, int sig)
2655{ 2655{
2656 int i, sub, any = 0; 2656 int i, sub, any = 0;
2657 pid_t pid; 2657 struct pid *pid;
2658 2658
2659 if (!dd->ipath_pd) 2659 if (!dd->ipath_pd)
2660 return 0; 2660 return 0;
2661 for (i = 1; i < dd->ipath_cfgports; i++) { 2661 for (i = 1; i < dd->ipath_cfgports; i++) {
2662 if (!dd->ipath_pd[i] || !dd->ipath_pd[i]->port_cnt || 2662 if (!dd->ipath_pd[i] || !dd->ipath_pd[i]->port_cnt)
2663 !dd->ipath_pd[i]->port_pid)
2664 continue; 2663 continue;
2665 pid = dd->ipath_pd[i]->port_pid; 2664 pid = dd->ipath_pd[i]->port_pid;
2665 if (!pid)
2666 continue;
2667
2666 dev_info(&dd->pcidev->dev, "context %d in use " 2668 dev_info(&dd->pcidev->dev, "context %d in use "
2667 "(PID %u), sending signal %d\n", 2669 "(PID %u), sending signal %d\n",
2668 i, pid, sig); 2670 i, pid_nr(pid), sig);
2669 kill_proc(pid, sig, 1); 2671 kill_pid(pid, sig, 1);
2670 any++; 2672 any++;
2671 for (sub = 0; sub < INFINIPATH_MAX_SUBPORT; sub++) { 2673 for (sub = 0; sub < INFINIPATH_MAX_SUBPORT; sub++) {
2672 pid = dd->ipath_pd[i]->port_subpid[sub]; 2674 pid = dd->ipath_pd[i]->port_subpid[sub];
@@ -2674,8 +2676,8 @@ static int ipath_signal_procs(struct ipath_devdata *dd, int sig)
2674 continue; 2676 continue;
2675 dev_info(&dd->pcidev->dev, "sub-context " 2677 dev_info(&dd->pcidev->dev, "sub-context "
2676 "%d:%d in use (PID %u), sending " 2678 "%d:%d in use (PID %u), sending "
2677 "signal %d\n", i, sub, pid, sig); 2679 "signal %d\n", i, sub, pid_nr(pid), sig);
2678 kill_proc(pid, sig, 1); 2680 kill_pid(pid, sig, 1);
2679 any++; 2681 any++;
2680 } 2682 }
2681 } 2683 }
diff --git a/drivers/infiniband/hw/ipath/ipath_file_ops.c b/drivers/infiniband/hw/ipath/ipath_file_ops.c
index 3295177c937e..b472b15637f0 100644
--- a/drivers/infiniband/hw/ipath/ipath_file_ops.c
+++ b/drivers/infiniband/hw/ipath/ipath_file_ops.c
@@ -555,7 +555,7 @@ static int ipath_tid_free(struct ipath_portdata *pd, unsigned subport,
555 p = dd->ipath_pageshadow[porttid + tid]; 555 p = dd->ipath_pageshadow[porttid + tid];
556 dd->ipath_pageshadow[porttid + tid] = NULL; 556 dd->ipath_pageshadow[porttid + tid] = NULL;
557 ipath_cdbg(VERBOSE, "PID %u freeing TID %u\n", 557 ipath_cdbg(VERBOSE, "PID %u freeing TID %u\n",
558 pd->port_pid, tid); 558 pid_nr(pd->port_pid), tid);
559 dd->ipath_f_put_tid(dd, &tidbase[tid], 559 dd->ipath_f_put_tid(dd, &tidbase[tid],
560 RCVHQ_RCV_TYPE_EXPECTED, 560 RCVHQ_RCV_TYPE_EXPECTED,
561 dd->ipath_tidinvalid); 561 dd->ipath_tidinvalid);
@@ -1609,7 +1609,7 @@ static int try_alloc_port(struct ipath_devdata *dd, int port,
1609 port); 1609 port);
1610 pd->port_cnt = 1; 1610 pd->port_cnt = 1;
1611 port_fp(fp) = pd; 1611 port_fp(fp) = pd;
1612 pd->port_pid = current->pid; 1612 pd->port_pid = get_pid(task_pid(current));
1613 strncpy(pd->port_comm, current->comm, sizeof(pd->port_comm)); 1613 strncpy(pd->port_comm, current->comm, sizeof(pd->port_comm));
1614 ipath_stats.sps_ports++; 1614 ipath_stats.sps_ports++;
1615 ret = 0; 1615 ret = 0;
@@ -1793,14 +1793,15 @@ static int find_shared_port(struct file *fp,
1793 } 1793 }
1794 port_fp(fp) = pd; 1794 port_fp(fp) = pd;
1795 subport_fp(fp) = pd->port_cnt++; 1795 subport_fp(fp) = pd->port_cnt++;
1796 pd->port_subpid[subport_fp(fp)] = current->pid; 1796 pd->port_subpid[subport_fp(fp)] =
1797 get_pid(task_pid(current));
1797 tidcursor_fp(fp) = 0; 1798 tidcursor_fp(fp) = 0;
1798 pd->active_slaves |= 1 << subport_fp(fp); 1799 pd->active_slaves |= 1 << subport_fp(fp);
1799 ipath_cdbg(PROC, 1800 ipath_cdbg(PROC,
1800 "%s[%u] %u sharing %s[%u] unit:port %u:%u\n", 1801 "%s[%u] %u sharing %s[%u] unit:port %u:%u\n",
1801 current->comm, current->pid, 1802 current->comm, current->pid,
1802 subport_fp(fp), 1803 subport_fp(fp),
1803 pd->port_comm, pd->port_pid, 1804 pd->port_comm, pid_nr(pd->port_pid),
1804 dd->ipath_unit, pd->port_port); 1805 dd->ipath_unit, pd->port_port);
1805 ret = 1; 1806 ret = 1;
1806 goto done; 1807 goto done;
@@ -2066,7 +2067,8 @@ static int ipath_close(struct inode *in, struct file *fp)
2066 * the slave(s) don't wait for receive data forever. 2067 * the slave(s) don't wait for receive data forever.
2067 */ 2068 */
2068 pd->active_slaves &= ~(1 << fd->subport); 2069 pd->active_slaves &= ~(1 << fd->subport);
2069 pd->port_subpid[fd->subport] = 0; 2070 put_pid(pd->port_subpid[fd->subport]);
2071 pd->port_subpid[fd->subport] = NULL;
2070 mutex_unlock(&ipath_mutex); 2072 mutex_unlock(&ipath_mutex);
2071 goto bail; 2073 goto bail;
2072 } 2074 }
@@ -2074,7 +2076,7 @@ static int ipath_close(struct inode *in, struct file *fp)
2074 2076
2075 if (pd->port_hdrqfull) { 2077 if (pd->port_hdrqfull) {
2076 ipath_cdbg(PROC, "%s[%u] had %u rcvhdrqfull errors " 2078 ipath_cdbg(PROC, "%s[%u] had %u rcvhdrqfull errors "
2077 "during run\n", pd->port_comm, pd->port_pid, 2079 "during run\n", pd->port_comm, pid_nr(pd->port_pid),
2078 pd->port_hdrqfull); 2080 pd->port_hdrqfull);
2079 pd->port_hdrqfull = 0; 2081 pd->port_hdrqfull = 0;
2080 } 2082 }
@@ -2134,11 +2136,12 @@ static int ipath_close(struct inode *in, struct file *fp)
2134 unlock_expected_tids(pd); 2136 unlock_expected_tids(pd);
2135 ipath_stats.sps_ports--; 2137 ipath_stats.sps_ports--;
2136 ipath_cdbg(PROC, "%s[%u] closed port %u:%u\n", 2138 ipath_cdbg(PROC, "%s[%u] closed port %u:%u\n",
2137 pd->port_comm, pd->port_pid, 2139 pd->port_comm, pid_nr(pd->port_pid),
2138 dd->ipath_unit, port); 2140 dd->ipath_unit, port);
2139 } 2141 }
2140 2142
2141 pd->port_pid = 0; 2143 put_pid(pd->port_pid);
2144 pd->port_pid = NULL;
2142 dd->ipath_pd[pd->port_port] = NULL; /* before releasing mutex */ 2145 dd->ipath_pd[pd->port_port] = NULL; /* before releasing mutex */
2143 mutex_unlock(&ipath_mutex); 2146 mutex_unlock(&ipath_mutex);
2144 ipath_free_pddata(dd, pd); /* after releasing the mutex */ 2147 ipath_free_pddata(dd, pd); /* after releasing the mutex */
diff --git a/drivers/infiniband/hw/ipath/ipath_kernel.h b/drivers/infiniband/hw/ipath/ipath_kernel.h
index 02b24a340599..59a8b254b97f 100644
--- a/drivers/infiniband/hw/ipath/ipath_kernel.h
+++ b/drivers/infiniband/hw/ipath/ipath_kernel.h
@@ -159,8 +159,8 @@ struct ipath_portdata {
159 /* saved total number of polled urgent packets for poll edge trigger */ 159 /* saved total number of polled urgent packets for poll edge trigger */
160 u32 port_urgent_poll; 160 u32 port_urgent_poll;
161 /* pid of process using this port */ 161 /* pid of process using this port */
162 pid_t port_pid; 162 struct pid *port_pid;
163 pid_t port_subpid[INFINIPATH_MAX_SUBPORT]; 163 struct pid *port_subpid[INFINIPATH_MAX_SUBPORT];
164 /* same size as task_struct .comm[] */ 164 /* same size as task_struct .comm[] */
165 char port_comm[16]; 165 char port_comm[16];
166 /* pkeys set by this use of this port */ 166 /* pkeys set by this use of this port */
@@ -483,7 +483,7 @@ struct ipath_devdata {
483 483
484 /* SendDMA related entries */ 484 /* SendDMA related entries */
485 spinlock_t ipath_sdma_lock; 485 spinlock_t ipath_sdma_lock;
486 u64 ipath_sdma_status; 486 unsigned long ipath_sdma_status;
487 unsigned long ipath_sdma_abort_jiffies; 487 unsigned long ipath_sdma_abort_jiffies;
488 unsigned long ipath_sdma_abort_intr_timeout; 488 unsigned long ipath_sdma_abort_intr_timeout;
489 unsigned long ipath_sdma_buf_jiffies; 489 unsigned long ipath_sdma_buf_jiffies;
@@ -822,8 +822,8 @@ struct ipath_devdata {
822#define IPATH_SDMA_DISARMED 1 822#define IPATH_SDMA_DISARMED 1
823#define IPATH_SDMA_DISABLED 2 823#define IPATH_SDMA_DISABLED 2
824#define IPATH_SDMA_LAYERBUF 3 824#define IPATH_SDMA_LAYERBUF 3
825#define IPATH_SDMA_RUNNING 62 825#define IPATH_SDMA_RUNNING 30
826#define IPATH_SDMA_SHUTDOWN 63 826#define IPATH_SDMA_SHUTDOWN 31
827 827
828/* bit combinations that correspond to abort states */ 828/* bit combinations that correspond to abort states */
829#define IPATH_SDMA_ABORT_NONE 0 829#define IPATH_SDMA_ABORT_NONE 0
diff --git a/drivers/infiniband/hw/ipath/ipath_qp.c b/drivers/infiniband/hw/ipath/ipath_qp.c
index dd5b6e9d57c2..4715911101e4 100644
--- a/drivers/infiniband/hw/ipath/ipath_qp.c
+++ b/drivers/infiniband/hw/ipath/ipath_qp.c
@@ -242,7 +242,6 @@ static void ipath_free_qp(struct ipath_qp_table *qpt, struct ipath_qp *qp)
242{ 242{
243 struct ipath_qp *q, **qpp; 243 struct ipath_qp *q, **qpp;
244 unsigned long flags; 244 unsigned long flags;
245 int fnd = 0;
246 245
247 spin_lock_irqsave(&qpt->lock, flags); 246 spin_lock_irqsave(&qpt->lock, flags);
248 247
@@ -253,51 +252,40 @@ static void ipath_free_qp(struct ipath_qp_table *qpt, struct ipath_qp *qp)
253 *qpp = qp->next; 252 *qpp = qp->next;
254 qp->next = NULL; 253 qp->next = NULL;
255 atomic_dec(&qp->refcount); 254 atomic_dec(&qp->refcount);
256 fnd = 1;
257 break; 255 break;
258 } 256 }
259 } 257 }
260 258
261 spin_unlock_irqrestore(&qpt->lock, flags); 259 spin_unlock_irqrestore(&qpt->lock, flags);
262
263 if (!fnd)
264 return;
265
266 free_qpn(qpt, qp->ibqp.qp_num);
267
268 wait_event(qp->wait, !atomic_read(&qp->refcount));
269} 260}
270 261
271/** 262/**
272 * ipath_free_all_qps - remove all QPs from the table 263 * ipath_free_all_qps - check for QPs still in use
273 * @qpt: the QP table to empty 264 * @qpt: the QP table to empty
265 *
266 * There should not be any QPs still in use.
267 * Free memory for table.
274 */ 268 */
275void ipath_free_all_qps(struct ipath_qp_table *qpt) 269unsigned ipath_free_all_qps(struct ipath_qp_table *qpt)
276{ 270{
277 unsigned long flags; 271 unsigned long flags;
278 struct ipath_qp *qp, *nqp; 272 struct ipath_qp *qp;
279 u32 n; 273 u32 n, qp_inuse = 0;
280 274
275 spin_lock_irqsave(&qpt->lock, flags);
281 for (n = 0; n < qpt->max; n++) { 276 for (n = 0; n < qpt->max; n++) {
282 spin_lock_irqsave(&qpt->lock, flags);
283 qp = qpt->table[n]; 277 qp = qpt->table[n];
284 qpt->table[n] = NULL; 278 qpt->table[n] = NULL;
285 spin_unlock_irqrestore(&qpt->lock, flags); 279
286 280 for (; qp; qp = qp->next)
287 while (qp) { 281 qp_inuse++;
288 nqp = qp->next;
289 free_qpn(qpt, qp->ibqp.qp_num);
290 if (!atomic_dec_and_test(&qp->refcount) ||
291 !ipath_destroy_qp(&qp->ibqp))
292 ipath_dbg("QP memory leak!\n");
293 qp = nqp;
294 }
295 } 282 }
283 spin_unlock_irqrestore(&qpt->lock, flags);
296 284
297 for (n = 0; n < ARRAY_SIZE(qpt->map); n++) { 285 for (n = 0; n < ARRAY_SIZE(qpt->map); n++)
298 if (qpt->map[n].page) 286 if (qpt->map[n].page)
299 free_page((unsigned long)qpt->map[n].page); 287 free_page((unsigned long) qpt->map[n].page);
300 } 288 return qp_inuse;
301} 289}
302 290
303/** 291/**
@@ -336,11 +324,12 @@ static void ipath_reset_qp(struct ipath_qp *qp, enum ib_qp_type type)
336 qp->remote_qpn = 0; 324 qp->remote_qpn = 0;
337 qp->qkey = 0; 325 qp->qkey = 0;
338 qp->qp_access_flags = 0; 326 qp->qp_access_flags = 0;
339 qp->s_busy = 0; 327 atomic_set(&qp->s_dma_busy, 0);
340 qp->s_flags &= IPATH_S_SIGNAL_REQ_WR; 328 qp->s_flags &= IPATH_S_SIGNAL_REQ_WR;
341 qp->s_hdrwords = 0; 329 qp->s_hdrwords = 0;
342 qp->s_wqe = NULL; 330 qp->s_wqe = NULL;
343 qp->s_pkt_delay = 0; 331 qp->s_pkt_delay = 0;
332 qp->s_draining = 0;
344 qp->s_psn = 0; 333 qp->s_psn = 0;
345 qp->r_psn = 0; 334 qp->r_psn = 0;
346 qp->r_msn = 0; 335 qp->r_msn = 0;
@@ -353,7 +342,8 @@ static void ipath_reset_qp(struct ipath_qp *qp, enum ib_qp_type type)
353 } 342 }
354 qp->s_ack_state = IB_OPCODE_RC_ACKNOWLEDGE; 343 qp->s_ack_state = IB_OPCODE_RC_ACKNOWLEDGE;
355 qp->r_nak_state = 0; 344 qp->r_nak_state = 0;
356 qp->r_wrid_valid = 0; 345 qp->r_aflags = 0;
346 qp->r_flags = 0;
357 qp->s_rnr_timeout = 0; 347 qp->s_rnr_timeout = 0;
358 qp->s_head = 0; 348 qp->s_head = 0;
359 qp->s_tail = 0; 349 qp->s_tail = 0;
@@ -361,7 +351,6 @@ static void ipath_reset_qp(struct ipath_qp *qp, enum ib_qp_type type)
361 qp->s_last = 0; 351 qp->s_last = 0;
362 qp->s_ssn = 1; 352 qp->s_ssn = 1;
363 qp->s_lsn = 0; 353 qp->s_lsn = 0;
364 qp->s_wait_credit = 0;
365 memset(qp->s_ack_queue, 0, sizeof(qp->s_ack_queue)); 354 memset(qp->s_ack_queue, 0, sizeof(qp->s_ack_queue));
366 qp->r_head_ack_queue = 0; 355 qp->r_head_ack_queue = 0;
367 qp->s_tail_ack_queue = 0; 356 qp->s_tail_ack_queue = 0;
@@ -370,17 +359,17 @@ static void ipath_reset_qp(struct ipath_qp *qp, enum ib_qp_type type)
370 qp->r_rq.wq->head = 0; 359 qp->r_rq.wq->head = 0;
371 qp->r_rq.wq->tail = 0; 360 qp->r_rq.wq->tail = 0;
372 } 361 }
373 qp->r_reuse_sge = 0;
374} 362}
375 363
376/** 364/**
377 * ipath_error_qp - put a QP into an error state 365 * ipath_error_qp - put a QP into the error state
378 * @qp: the QP to put into an error state 366 * @qp: the QP to put into the error state
379 * @err: the receive completion error to signal if a RWQE is active 367 * @err: the receive completion error to signal if a RWQE is active
380 * 368 *
381 * Flushes both send and receive work queues. 369 * Flushes both send and receive work queues.
382 * Returns true if last WQE event should be generated. 370 * Returns true if last WQE event should be generated.
383 * The QP s_lock should be held and interrupts disabled. 371 * The QP s_lock should be held and interrupts disabled.
372 * If we are already in error state, just return.
384 */ 373 */
385 374
386int ipath_error_qp(struct ipath_qp *qp, enum ib_wc_status err) 375int ipath_error_qp(struct ipath_qp *qp, enum ib_wc_status err)
@@ -389,8 +378,10 @@ int ipath_error_qp(struct ipath_qp *qp, enum ib_wc_status err)
389 struct ib_wc wc; 378 struct ib_wc wc;
390 int ret = 0; 379 int ret = 0;
391 380
392 ipath_dbg("QP%d/%d in error state (%d)\n", 381 if (qp->state == IB_QPS_ERR)
393 qp->ibqp.qp_num, qp->remote_qpn, err); 382 goto bail;
383
384 qp->state = IB_QPS_ERR;
394 385
395 spin_lock(&dev->pending_lock); 386 spin_lock(&dev->pending_lock);
396 if (!list_empty(&qp->timerwait)) 387 if (!list_empty(&qp->timerwait))
@@ -399,39 +390,21 @@ int ipath_error_qp(struct ipath_qp *qp, enum ib_wc_status err)
399 list_del_init(&qp->piowait); 390 list_del_init(&qp->piowait);
400 spin_unlock(&dev->pending_lock); 391 spin_unlock(&dev->pending_lock);
401 392
402 wc.vendor_err = 0; 393 /* Schedule the sending tasklet to drain the send work queue. */
403 wc.byte_len = 0; 394 if (qp->s_last != qp->s_head)
404 wc.imm_data = 0; 395 ipath_schedule_send(qp);
396
397 memset(&wc, 0, sizeof(wc));
405 wc.qp = &qp->ibqp; 398 wc.qp = &qp->ibqp;
406 wc.src_qp = 0; 399 wc.opcode = IB_WC_RECV;
407 wc.wc_flags = 0; 400
408 wc.pkey_index = 0; 401 if (test_and_clear_bit(IPATH_R_WRID_VALID, &qp->r_aflags)) {
409 wc.slid = 0;
410 wc.sl = 0;
411 wc.dlid_path_bits = 0;
412 wc.port_num = 0;
413 if (qp->r_wrid_valid) {
414 qp->r_wrid_valid = 0;
415 wc.wr_id = qp->r_wr_id; 402 wc.wr_id = qp->r_wr_id;
416 wc.opcode = IB_WC_RECV;
417 wc.status = err; 403 wc.status = err;
418 ipath_cq_enter(to_icq(qp->ibqp.recv_cq), &wc, 1); 404 ipath_cq_enter(to_icq(qp->ibqp.recv_cq), &wc, 1);
419 } 405 }
420 wc.status = IB_WC_WR_FLUSH_ERR; 406 wc.status = IB_WC_WR_FLUSH_ERR;
421 407
422 while (qp->s_last != qp->s_head) {
423 struct ipath_swqe *wqe = get_swqe_ptr(qp, qp->s_last);
424
425 wc.wr_id = wqe->wr.wr_id;
426 wc.opcode = ib_ipath_wc_opcode[wqe->wr.opcode];
427 if (++qp->s_last >= qp->s_size)
428 qp->s_last = 0;
429 ipath_cq_enter(to_icq(qp->ibqp.send_cq), &wc, 1);
430 }
431 qp->s_cur = qp->s_tail = qp->s_head;
432 qp->s_hdrwords = 0;
433 qp->s_ack_state = IB_OPCODE_RC_ACKNOWLEDGE;
434
435 if (qp->r_rq.wq) { 408 if (qp->r_rq.wq) {
436 struct ipath_rwq *wq; 409 struct ipath_rwq *wq;
437 u32 head; 410 u32 head;
@@ -447,7 +420,6 @@ int ipath_error_qp(struct ipath_qp *qp, enum ib_wc_status err)
447 tail = wq->tail; 420 tail = wq->tail;
448 if (tail >= qp->r_rq.size) 421 if (tail >= qp->r_rq.size)
449 tail = 0; 422 tail = 0;
450 wc.opcode = IB_WC_RECV;
451 while (tail != head) { 423 while (tail != head) {
452 wc.wr_id = get_rwqe_ptr(&qp->r_rq, tail)->wr_id; 424 wc.wr_id = get_rwqe_ptr(&qp->r_rq, tail)->wr_id;
453 if (++tail >= qp->r_rq.size) 425 if (++tail >= qp->r_rq.size)
@@ -460,6 +432,7 @@ int ipath_error_qp(struct ipath_qp *qp, enum ib_wc_status err)
460 } else if (qp->ibqp.event_handler) 432 } else if (qp->ibqp.event_handler)
461 ret = 1; 433 ret = 1;
462 434
435bail:
463 return ret; 436 return ret;
464} 437}
465 438
@@ -478,11 +451,10 @@ int ipath_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr,
478 struct ipath_ibdev *dev = to_idev(ibqp->device); 451 struct ipath_ibdev *dev = to_idev(ibqp->device);
479 struct ipath_qp *qp = to_iqp(ibqp); 452 struct ipath_qp *qp = to_iqp(ibqp);
480 enum ib_qp_state cur_state, new_state; 453 enum ib_qp_state cur_state, new_state;
481 unsigned long flags;
482 int lastwqe = 0; 454 int lastwqe = 0;
483 int ret; 455 int ret;
484 456
485 spin_lock_irqsave(&qp->s_lock, flags); 457 spin_lock_irq(&qp->s_lock);
486 458
487 cur_state = attr_mask & IB_QP_CUR_STATE ? 459 cur_state = attr_mask & IB_QP_CUR_STATE ?
488 attr->cur_qp_state : qp->state; 460 attr->cur_qp_state : qp->state;
@@ -535,16 +507,42 @@ int ipath_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr,
535 507
536 switch (new_state) { 508 switch (new_state) {
537 case IB_QPS_RESET: 509 case IB_QPS_RESET:
510 if (qp->state != IB_QPS_RESET) {
511 qp->state = IB_QPS_RESET;
512 spin_lock(&dev->pending_lock);
513 if (!list_empty(&qp->timerwait))
514 list_del_init(&qp->timerwait);
515 if (!list_empty(&qp->piowait))
516 list_del_init(&qp->piowait);
517 spin_unlock(&dev->pending_lock);
518 qp->s_flags &= ~IPATH_S_ANY_WAIT;
519 spin_unlock_irq(&qp->s_lock);
520 /* Stop the sending tasklet */
521 tasklet_kill(&qp->s_task);
522 wait_event(qp->wait_dma, !atomic_read(&qp->s_dma_busy));
523 spin_lock_irq(&qp->s_lock);
524 }
538 ipath_reset_qp(qp, ibqp->qp_type); 525 ipath_reset_qp(qp, ibqp->qp_type);
539 break; 526 break;
540 527
528 case IB_QPS_SQD:
529 qp->s_draining = qp->s_last != qp->s_cur;
530 qp->state = new_state;
531 break;
532
533 case IB_QPS_SQE:
534 if (qp->ibqp.qp_type == IB_QPT_RC)
535 goto inval;
536 qp->state = new_state;
537 break;
538
541 case IB_QPS_ERR: 539 case IB_QPS_ERR:
542 lastwqe = ipath_error_qp(qp, IB_WC_WR_FLUSH_ERR); 540 lastwqe = ipath_error_qp(qp, IB_WC_WR_FLUSH_ERR);
543 break; 541 break;
544 542
545 default: 543 default:
544 qp->state = new_state;
546 break; 545 break;
547
548 } 546 }
549 547
550 if (attr_mask & IB_QP_PKEY_INDEX) 548 if (attr_mask & IB_QP_PKEY_INDEX)
@@ -597,8 +595,7 @@ int ipath_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr,
597 if (attr_mask & IB_QP_MAX_QP_RD_ATOMIC) 595 if (attr_mask & IB_QP_MAX_QP_RD_ATOMIC)
598 qp->s_max_rd_atomic = attr->max_rd_atomic; 596 qp->s_max_rd_atomic = attr->max_rd_atomic;
599 597
600 qp->state = new_state; 598 spin_unlock_irq(&qp->s_lock);
601 spin_unlock_irqrestore(&qp->s_lock, flags);
602 599
603 if (lastwqe) { 600 if (lastwqe) {
604 struct ib_event ev; 601 struct ib_event ev;
@@ -612,7 +609,7 @@ int ipath_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr,
612 goto bail; 609 goto bail;
613 610
614inval: 611inval:
615 spin_unlock_irqrestore(&qp->s_lock, flags); 612 spin_unlock_irq(&qp->s_lock);
616 ret = -EINVAL; 613 ret = -EINVAL;
617 614
618bail: 615bail:
@@ -643,7 +640,7 @@ int ipath_query_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr,
643 attr->pkey_index = qp->s_pkey_index; 640 attr->pkey_index = qp->s_pkey_index;
644 attr->alt_pkey_index = 0; 641 attr->alt_pkey_index = 0;
645 attr->en_sqd_async_notify = 0; 642 attr->en_sqd_async_notify = 0;
646 attr->sq_draining = 0; 643 attr->sq_draining = qp->s_draining;
647 attr->max_rd_atomic = qp->s_max_rd_atomic; 644 attr->max_rd_atomic = qp->s_max_rd_atomic;
648 attr->max_dest_rd_atomic = qp->r_max_rd_atomic; 645 attr->max_dest_rd_atomic = qp->r_max_rd_atomic;
649 attr->min_rnr_timer = qp->r_min_rnr_timer; 646 attr->min_rnr_timer = qp->r_min_rnr_timer;
@@ -833,6 +830,7 @@ struct ib_qp *ipath_create_qp(struct ib_pd *ibpd,
833 spin_lock_init(&qp->r_rq.lock); 830 spin_lock_init(&qp->r_rq.lock);
834 atomic_set(&qp->refcount, 0); 831 atomic_set(&qp->refcount, 0);
835 init_waitqueue_head(&qp->wait); 832 init_waitqueue_head(&qp->wait);
833 init_waitqueue_head(&qp->wait_dma);
836 tasklet_init(&qp->s_task, ipath_do_send, (unsigned long)qp); 834 tasklet_init(&qp->s_task, ipath_do_send, (unsigned long)qp);
837 INIT_LIST_HEAD(&qp->piowait); 835 INIT_LIST_HEAD(&qp->piowait);
838 INIT_LIST_HEAD(&qp->timerwait); 836 INIT_LIST_HEAD(&qp->timerwait);
@@ -926,6 +924,7 @@ bail_ip:
926 else 924 else
927 vfree(qp->r_rq.wq); 925 vfree(qp->r_rq.wq);
928 ipath_free_qp(&dev->qp_table, qp); 926 ipath_free_qp(&dev->qp_table, qp);
927 free_qpn(&dev->qp_table, qp->ibqp.qp_num);
929bail_qp: 928bail_qp:
930 kfree(qp); 929 kfree(qp);
931bail_swq: 930bail_swq:
@@ -947,41 +946,44 @@ int ipath_destroy_qp(struct ib_qp *ibqp)
947{ 946{
948 struct ipath_qp *qp = to_iqp(ibqp); 947 struct ipath_qp *qp = to_iqp(ibqp);
949 struct ipath_ibdev *dev = to_idev(ibqp->device); 948 struct ipath_ibdev *dev = to_idev(ibqp->device);
950 unsigned long flags;
951 949
952 spin_lock_irqsave(&qp->s_lock, flags); 950 /* Make sure HW and driver activity is stopped. */
953 qp->state = IB_QPS_ERR; 951 spin_lock_irq(&qp->s_lock);
954 spin_unlock_irqrestore(&qp->s_lock, flags); 952 if (qp->state != IB_QPS_RESET) {
955 spin_lock(&dev->n_qps_lock); 953 qp->state = IB_QPS_RESET;
956 dev->n_qps_allocated--; 954 spin_lock(&dev->pending_lock);
957 spin_unlock(&dev->n_qps_lock); 955 if (!list_empty(&qp->timerwait))
956 list_del_init(&qp->timerwait);
957 if (!list_empty(&qp->piowait))
958 list_del_init(&qp->piowait);
959 spin_unlock(&dev->pending_lock);
960 qp->s_flags &= ~IPATH_S_ANY_WAIT;
961 spin_unlock_irq(&qp->s_lock);
962 /* Stop the sending tasklet */
963 tasklet_kill(&qp->s_task);
964 wait_event(qp->wait_dma, !atomic_read(&qp->s_dma_busy));
965 } else
966 spin_unlock_irq(&qp->s_lock);
958 967
959 /* Stop the sending tasklet. */ 968 ipath_free_qp(&dev->qp_table, qp);
960 tasklet_kill(&qp->s_task);
961 969
962 if (qp->s_tx) { 970 if (qp->s_tx) {
963 atomic_dec(&qp->refcount); 971 atomic_dec(&qp->refcount);
964 if (qp->s_tx->txreq.flags & IPATH_SDMA_TXREQ_F_FREEBUF) 972 if (qp->s_tx->txreq.flags & IPATH_SDMA_TXREQ_F_FREEBUF)
965 kfree(qp->s_tx->txreq.map_addr); 973 kfree(qp->s_tx->txreq.map_addr);
974 spin_lock_irq(&dev->pending_lock);
975 list_add(&qp->s_tx->txreq.list, &dev->txreq_free);
976 spin_unlock_irq(&dev->pending_lock);
977 qp->s_tx = NULL;
966 } 978 }
967 979
968 /* Make sure the QP isn't on the timeout list. */ 980 wait_event(qp->wait, !atomic_read(&qp->refcount));
969 spin_lock_irqsave(&dev->pending_lock, flags);
970 if (!list_empty(&qp->timerwait))
971 list_del_init(&qp->timerwait);
972 if (!list_empty(&qp->piowait))
973 list_del_init(&qp->piowait);
974 if (qp->s_tx)
975 list_add(&qp->s_tx->txreq.list, &dev->txreq_free);
976 spin_unlock_irqrestore(&dev->pending_lock, flags);
977 981
978 /* 982 /* all user's cleaned up, mark it available */
979 * Make sure that the QP is not in the QPN table so receive 983 free_qpn(&dev->qp_table, qp->ibqp.qp_num);
980 * interrupts will discard packets for this QP. XXX Also remove QP 984 spin_lock(&dev->n_qps_lock);
981 * from multicast table. 985 dev->n_qps_allocated--;
982 */ 986 spin_unlock(&dev->n_qps_lock);
983 if (atomic_read(&qp->refcount) != 0)
984 ipath_free_qp(&dev->qp_table, qp);
985 987
986 if (qp->ip) 988 if (qp->ip)
987 kref_put(&qp->ip->ref, ipath_release_mmap_info); 989 kref_put(&qp->ip->ref, ipath_release_mmap_info);
@@ -1026,48 +1028,6 @@ bail:
1026} 1028}
1027 1029
1028/** 1030/**
1029 * ipath_sqerror_qp - put a QP's send queue into an error state
1030 * @qp: QP who's send queue will be put into an error state
1031 * @wc: the WC responsible for putting the QP in this state
1032 *
1033 * Flushes the send work queue.
1034 * The QP s_lock should be held and interrupts disabled.
1035 */
1036
1037void ipath_sqerror_qp(struct ipath_qp *qp, struct ib_wc *wc)
1038{
1039 struct ipath_ibdev *dev = to_idev(qp->ibqp.device);
1040 struct ipath_swqe *wqe = get_swqe_ptr(qp, qp->s_last);
1041
1042 ipath_dbg("Send queue error on QP%d/%d: err: %d\n",
1043 qp->ibqp.qp_num, qp->remote_qpn, wc->status);
1044
1045 spin_lock(&dev->pending_lock);
1046 if (!list_empty(&qp->timerwait))
1047 list_del_init(&qp->timerwait);
1048 if (!list_empty(&qp->piowait))
1049 list_del_init(&qp->piowait);
1050 spin_unlock(&dev->pending_lock);
1051
1052 ipath_cq_enter(to_icq(qp->ibqp.send_cq), wc, 1);
1053 if (++qp->s_last >= qp->s_size)
1054 qp->s_last = 0;
1055
1056 wc->status = IB_WC_WR_FLUSH_ERR;
1057
1058 while (qp->s_last != qp->s_head) {
1059 wqe = get_swqe_ptr(qp, qp->s_last);
1060 wc->wr_id = wqe->wr.wr_id;
1061 wc->opcode = ib_ipath_wc_opcode[wqe->wr.opcode];
1062 ipath_cq_enter(to_icq(qp->ibqp.send_cq), wc, 1);
1063 if (++qp->s_last >= qp->s_size)
1064 qp->s_last = 0;
1065 }
1066 qp->s_cur = qp->s_tail = qp->s_head;
1067 qp->state = IB_QPS_SQE;
1068}
1069
1070/**
1071 * ipath_get_credit - flush the send work queue of a QP 1031 * ipath_get_credit - flush the send work queue of a QP
1072 * @qp: the qp who's send work queue to flush 1032 * @qp: the qp who's send work queue to flush
1073 * @aeth: the Acknowledge Extended Transport Header 1033 * @aeth: the Acknowledge Extended Transport Header
@@ -1093,9 +1053,10 @@ void ipath_get_credit(struct ipath_qp *qp, u32 aeth)
1093 } 1053 }
1094 1054
1095 /* Restart sending if it was blocked due to lack of credits. */ 1055 /* Restart sending if it was blocked due to lack of credits. */
1096 if (qp->s_cur != qp->s_head && 1056 if ((qp->s_flags & IPATH_S_WAIT_SSN_CREDIT) &&
1057 qp->s_cur != qp->s_head &&
1097 (qp->s_lsn == (u32) -1 || 1058 (qp->s_lsn == (u32) -1 ||
1098 ipath_cmp24(get_swqe_ptr(qp, qp->s_cur)->ssn, 1059 ipath_cmp24(get_swqe_ptr(qp, qp->s_cur)->ssn,
1099 qp->s_lsn + 1) <= 0)) 1060 qp->s_lsn + 1) <= 0))
1100 tasklet_hi_schedule(&qp->s_task); 1061 ipath_schedule_send(qp);
1101} 1062}
diff --git a/drivers/infiniband/hw/ipath/ipath_rc.c b/drivers/infiniband/hw/ipath/ipath_rc.c
index 08b11b567614..108df667d2ee 100644
--- a/drivers/infiniband/hw/ipath/ipath_rc.c
+++ b/drivers/infiniband/hw/ipath/ipath_rc.c
@@ -92,6 +92,10 @@ static int ipath_make_rc_ack(struct ipath_ibdev *dev, struct ipath_qp *qp,
92 u32 bth0; 92 u32 bth0;
93 u32 bth2; 93 u32 bth2;
94 94
95 /* Don't send an ACK if we aren't supposed to. */
96 if (!(ib_ipath_state_ops[qp->state] & IPATH_PROCESS_RECV_OK))
97 goto bail;
98
95 /* header size in 32-bit words LRH+BTH = (8+12)/4. */ 99 /* header size in 32-bit words LRH+BTH = (8+12)/4. */
96 hwords = 5; 100 hwords = 5;
97 101
@@ -238,14 +242,25 @@ int ipath_make_rc_req(struct ipath_qp *qp)
238 ipath_make_rc_ack(dev, qp, ohdr, pmtu)) 242 ipath_make_rc_ack(dev, qp, ohdr, pmtu))
239 goto done; 243 goto done;
240 244
241 if (!(ib_ipath_state_ops[qp->state] & IPATH_PROCESS_SEND_OK) || 245 if (!(ib_ipath_state_ops[qp->state] & IPATH_PROCESS_SEND_OK)) {
242 qp->s_rnr_timeout || qp->s_wait_credit) 246 if (!(ib_ipath_state_ops[qp->state] & IPATH_FLUSH_SEND))
243 goto bail; 247 goto bail;
248 /* We are in the error state, flush the work request. */
249 if (qp->s_last == qp->s_head)
250 goto bail;
251 /* If DMAs are in progress, we can't flush immediately. */
252 if (atomic_read(&qp->s_dma_busy)) {
253 qp->s_flags |= IPATH_S_WAIT_DMA;
254 goto bail;
255 }
256 wqe = get_swqe_ptr(qp, qp->s_last);
257 ipath_send_complete(qp, wqe, IB_WC_WR_FLUSH_ERR);
258 goto done;
259 }
244 260
245 /* Limit the number of packets sent without an ACK. */ 261 /* Leave BUSY set until RNR timeout. */
246 if (ipath_cmp24(qp->s_psn, qp->s_last_psn + IPATH_PSN_CREDIT) > 0) { 262 if (qp->s_rnr_timeout) {
247 qp->s_wait_credit = 1; 263 qp->s_flags |= IPATH_S_WAITING;
248 dev->n_rc_stalls++;
249 goto bail; 264 goto bail;
250 } 265 }
251 266
@@ -257,6 +272,9 @@ int ipath_make_rc_req(struct ipath_qp *qp)
257 wqe = get_swqe_ptr(qp, qp->s_cur); 272 wqe = get_swqe_ptr(qp, qp->s_cur);
258 switch (qp->s_state) { 273 switch (qp->s_state) {
259 default: 274 default:
275 if (!(ib_ipath_state_ops[qp->state] &
276 IPATH_PROCESS_NEXT_SEND_OK))
277 goto bail;
260 /* 278 /*
261 * Resend an old request or start a new one. 279 * Resend an old request or start a new one.
262 * 280 *
@@ -294,8 +312,10 @@ int ipath_make_rc_req(struct ipath_qp *qp)
294 case IB_WR_SEND_WITH_IMM: 312 case IB_WR_SEND_WITH_IMM:
295 /* If no credit, return. */ 313 /* If no credit, return. */
296 if (qp->s_lsn != (u32) -1 && 314 if (qp->s_lsn != (u32) -1 &&
297 ipath_cmp24(wqe->ssn, qp->s_lsn + 1) > 0) 315 ipath_cmp24(wqe->ssn, qp->s_lsn + 1) > 0) {
316 qp->s_flags |= IPATH_S_WAIT_SSN_CREDIT;
298 goto bail; 317 goto bail;
318 }
299 wqe->lpsn = wqe->psn; 319 wqe->lpsn = wqe->psn;
300 if (len > pmtu) { 320 if (len > pmtu) {
301 wqe->lpsn += (len - 1) / pmtu; 321 wqe->lpsn += (len - 1) / pmtu;
@@ -325,8 +345,10 @@ int ipath_make_rc_req(struct ipath_qp *qp)
325 case IB_WR_RDMA_WRITE_WITH_IMM: 345 case IB_WR_RDMA_WRITE_WITH_IMM:
326 /* If no credit, return. */ 346 /* If no credit, return. */
327 if (qp->s_lsn != (u32) -1 && 347 if (qp->s_lsn != (u32) -1 &&
328 ipath_cmp24(wqe->ssn, qp->s_lsn + 1) > 0) 348 ipath_cmp24(wqe->ssn, qp->s_lsn + 1) > 0) {
349 qp->s_flags |= IPATH_S_WAIT_SSN_CREDIT;
329 goto bail; 350 goto bail;
351 }
330 ohdr->u.rc.reth.vaddr = 352 ohdr->u.rc.reth.vaddr =
331 cpu_to_be64(wqe->wr.wr.rdma.remote_addr); 353 cpu_to_be64(wqe->wr.wr.rdma.remote_addr);
332 ohdr->u.rc.reth.rkey = 354 ohdr->u.rc.reth.rkey =
@@ -570,7 +592,11 @@ int ipath_make_rc_req(struct ipath_qp *qp)
570 ipath_make_ruc_header(dev, qp, ohdr, bth0 | (qp->s_state << 24), bth2); 592 ipath_make_ruc_header(dev, qp, ohdr, bth0 | (qp->s_state << 24), bth2);
571done: 593done:
572 ret = 1; 594 ret = 1;
595 goto unlock;
596
573bail: 597bail:
598 qp->s_flags &= ~IPATH_S_BUSY;
599unlock:
574 spin_unlock_irqrestore(&qp->s_lock, flags); 600 spin_unlock_irqrestore(&qp->s_lock, flags);
575 return ret; 601 return ret;
576} 602}
@@ -606,7 +632,11 @@ static void send_rc_ack(struct ipath_qp *qp)
606 632
607 spin_unlock_irqrestore(&qp->s_lock, flags); 633 spin_unlock_irqrestore(&qp->s_lock, flags);
608 634
635 /* Don't try to send ACKs if the link isn't ACTIVE */
609 dd = dev->dd; 636 dd = dev->dd;
637 if (!(dd->ipath_flags & IPATH_LINKACTIVE))
638 goto done;
639
610 piobuf = ipath_getpiobuf(dd, 0, NULL); 640 piobuf = ipath_getpiobuf(dd, 0, NULL);
611 if (!piobuf) { 641 if (!piobuf) {
612 /* 642 /*
@@ -668,15 +698,16 @@ static void send_rc_ack(struct ipath_qp *qp)
668 goto done; 698 goto done;
669 699
670queue_ack: 700queue_ack:
671 dev->n_rc_qacks++; 701 if (ib_ipath_state_ops[qp->state] & IPATH_PROCESS_RECV_OK) {
672 qp->s_flags |= IPATH_S_ACK_PENDING; 702 dev->n_rc_qacks++;
673 qp->s_nak_state = qp->r_nak_state; 703 qp->s_flags |= IPATH_S_ACK_PENDING;
674 qp->s_ack_psn = qp->r_ack_psn; 704 qp->s_nak_state = qp->r_nak_state;
705 qp->s_ack_psn = qp->r_ack_psn;
706
707 /* Schedule the send tasklet. */
708 ipath_schedule_send(qp);
709 }
675 spin_unlock_irqrestore(&qp->s_lock, flags); 710 spin_unlock_irqrestore(&qp->s_lock, flags);
676
677 /* Call ipath_do_rc_send() in another thread. */
678 tasklet_hi_schedule(&qp->s_task);
679
680done: 711done:
681 return; 712 return;
682} 713}
@@ -735,7 +766,7 @@ static void reset_psn(struct ipath_qp *qp, u32 psn)
735 /* 766 /*
736 * Set the state to restart in the middle of a request. 767 * Set the state to restart in the middle of a request.
737 * Don't change the s_sge, s_cur_sge, or s_cur_size. 768 * Don't change the s_sge, s_cur_sge, or s_cur_size.
738 * See ipath_do_rc_send(). 769 * See ipath_make_rc_req().
739 */ 770 */
740 switch (opcode) { 771 switch (opcode) {
741 case IB_WR_SEND: 772 case IB_WR_SEND:
@@ -771,27 +802,14 @@ done:
771 * 802 *
772 * The QP s_lock should be held and interrupts disabled. 803 * The QP s_lock should be held and interrupts disabled.
773 */ 804 */
774void ipath_restart_rc(struct ipath_qp *qp, u32 psn, struct ib_wc *wc) 805void ipath_restart_rc(struct ipath_qp *qp, u32 psn)
775{ 806{
776 struct ipath_swqe *wqe = get_swqe_ptr(qp, qp->s_last); 807 struct ipath_swqe *wqe = get_swqe_ptr(qp, qp->s_last);
777 struct ipath_ibdev *dev; 808 struct ipath_ibdev *dev;
778 809
779 if (qp->s_retry == 0) { 810 if (qp->s_retry == 0) {
780 wc->wr_id = wqe->wr.wr_id; 811 ipath_send_complete(qp, wqe, IB_WC_RETRY_EXC_ERR);
781 wc->status = IB_WC_RETRY_EXC_ERR; 812 ipath_error_qp(qp, IB_WC_WR_FLUSH_ERR);
782 wc->opcode = ib_ipath_wc_opcode[wqe->wr.opcode];
783 wc->vendor_err = 0;
784 wc->byte_len = 0;
785 wc->qp = &qp->ibqp;
786 wc->imm_data = 0;
787 wc->src_qp = qp->remote_qpn;
788 wc->wc_flags = 0;
789 wc->pkey_index = 0;
790 wc->slid = qp->remote_ah_attr.dlid;
791 wc->sl = qp->remote_ah_attr.sl;
792 wc->dlid_path_bits = 0;
793 wc->port_num = 0;
794 ipath_sqerror_qp(qp, wc);
795 goto bail; 813 goto bail;
796 } 814 }
797 qp->s_retry--; 815 qp->s_retry--;
@@ -804,6 +822,8 @@ void ipath_restart_rc(struct ipath_qp *qp, u32 psn, struct ib_wc *wc)
804 spin_lock(&dev->pending_lock); 822 spin_lock(&dev->pending_lock);
805 if (!list_empty(&qp->timerwait)) 823 if (!list_empty(&qp->timerwait))
806 list_del_init(&qp->timerwait); 824 list_del_init(&qp->timerwait);
825 if (!list_empty(&qp->piowait))
826 list_del_init(&qp->piowait);
807 spin_unlock(&dev->pending_lock); 827 spin_unlock(&dev->pending_lock);
808 828
809 if (wqe->wr.opcode == IB_WR_RDMA_READ) 829 if (wqe->wr.opcode == IB_WR_RDMA_READ)
@@ -812,7 +832,7 @@ void ipath_restart_rc(struct ipath_qp *qp, u32 psn, struct ib_wc *wc)
812 dev->n_rc_resends += (qp->s_psn - psn) & IPATH_PSN_MASK; 832 dev->n_rc_resends += (qp->s_psn - psn) & IPATH_PSN_MASK;
813 833
814 reset_psn(qp, psn); 834 reset_psn(qp, psn);
815 tasklet_hi_schedule(&qp->s_task); 835 ipath_schedule_send(qp);
816 836
817bail: 837bail:
818 return; 838 return;
@@ -820,13 +840,7 @@ bail:
820 840
821static inline void update_last_psn(struct ipath_qp *qp, u32 psn) 841static inline void update_last_psn(struct ipath_qp *qp, u32 psn)
822{ 842{
823 if (qp->s_last_psn != psn) { 843 qp->s_last_psn = psn;
824 qp->s_last_psn = psn;
825 if (qp->s_wait_credit) {
826 qp->s_wait_credit = 0;
827 tasklet_hi_schedule(&qp->s_task);
828 }
829 }
830} 844}
831 845
832/** 846/**
@@ -845,6 +859,7 @@ static int do_rc_ack(struct ipath_qp *qp, u32 aeth, u32 psn, int opcode,
845{ 859{
846 struct ipath_ibdev *dev = to_idev(qp->ibqp.device); 860 struct ipath_ibdev *dev = to_idev(qp->ibqp.device);
847 struct ib_wc wc; 861 struct ib_wc wc;
862 enum ib_wc_status status;
848 struct ipath_swqe *wqe; 863 struct ipath_swqe *wqe;
849 int ret = 0; 864 int ret = 0;
850 u32 ack_psn; 865 u32 ack_psn;
@@ -909,7 +924,7 @@ static int do_rc_ack(struct ipath_qp *qp, u32 aeth, u32 psn, int opcode,
909 */ 924 */
910 update_last_psn(qp, wqe->psn - 1); 925 update_last_psn(qp, wqe->psn - 1);
911 /* Retry this request. */ 926 /* Retry this request. */
912 ipath_restart_rc(qp, wqe->psn, &wc); 927 ipath_restart_rc(qp, wqe->psn);
913 /* 928 /*
914 * No need to process the ACK/NAK since we are 929 * No need to process the ACK/NAK since we are
915 * restarting an earlier request. 930 * restarting an earlier request.
@@ -925,32 +940,23 @@ static int do_rc_ack(struct ipath_qp *qp, u32 aeth, u32 psn, int opcode,
925 wqe->wr.opcode == IB_WR_ATOMIC_FETCH_AND_ADD)) { 940 wqe->wr.opcode == IB_WR_ATOMIC_FETCH_AND_ADD)) {
926 qp->s_num_rd_atomic--; 941 qp->s_num_rd_atomic--;
927 /* Restart sending task if fence is complete */ 942 /* Restart sending task if fence is complete */
928 if ((qp->s_flags & IPATH_S_FENCE_PENDING) && 943 if (((qp->s_flags & IPATH_S_FENCE_PENDING) &&
929 !qp->s_num_rd_atomic) { 944 !qp->s_num_rd_atomic) ||
930 qp->s_flags &= ~IPATH_S_FENCE_PENDING; 945 qp->s_flags & IPATH_S_RDMAR_PENDING)
931 tasklet_hi_schedule(&qp->s_task); 946 ipath_schedule_send(qp);
932 } else if (qp->s_flags & IPATH_S_RDMAR_PENDING) {
933 qp->s_flags &= ~IPATH_S_RDMAR_PENDING;
934 tasklet_hi_schedule(&qp->s_task);
935 }
936 } 947 }
937 /* Post a send completion queue entry if requested. */ 948 /* Post a send completion queue entry if requested. */
938 if (!(qp->s_flags & IPATH_S_SIGNAL_REQ_WR) || 949 if (!(qp->s_flags & IPATH_S_SIGNAL_REQ_WR) ||
939 (wqe->wr.send_flags & IB_SEND_SIGNALED)) { 950 (wqe->wr.send_flags & IB_SEND_SIGNALED)) {
951 memset(&wc, 0, sizeof wc);
940 wc.wr_id = wqe->wr.wr_id; 952 wc.wr_id = wqe->wr.wr_id;
941 wc.status = IB_WC_SUCCESS; 953 wc.status = IB_WC_SUCCESS;
942 wc.opcode = ib_ipath_wc_opcode[wqe->wr.opcode]; 954 wc.opcode = ib_ipath_wc_opcode[wqe->wr.opcode];
943 wc.vendor_err = 0;
944 wc.byte_len = wqe->length; 955 wc.byte_len = wqe->length;
945 wc.imm_data = 0;
946 wc.qp = &qp->ibqp; 956 wc.qp = &qp->ibqp;
947 wc.src_qp = qp->remote_qpn; 957 wc.src_qp = qp->remote_qpn;
948 wc.wc_flags = 0;
949 wc.pkey_index = 0;
950 wc.slid = qp->remote_ah_attr.dlid; 958 wc.slid = qp->remote_ah_attr.dlid;
951 wc.sl = qp->remote_ah_attr.sl; 959 wc.sl = qp->remote_ah_attr.sl;
952 wc.dlid_path_bits = 0;
953 wc.port_num = 0;
954 ipath_cq_enter(to_icq(qp->ibqp.send_cq), &wc, 0); 960 ipath_cq_enter(to_icq(qp->ibqp.send_cq), &wc, 0);
955 } 961 }
956 qp->s_retry = qp->s_retry_cnt; 962 qp->s_retry = qp->s_retry_cnt;
@@ -971,6 +977,8 @@ static int do_rc_ack(struct ipath_qp *qp, u32 aeth, u32 psn, int opcode,
971 } else { 977 } else {
972 if (++qp->s_last >= qp->s_size) 978 if (++qp->s_last >= qp->s_size)
973 qp->s_last = 0; 979 qp->s_last = 0;
980 if (qp->state == IB_QPS_SQD && qp->s_last == qp->s_cur)
981 qp->s_draining = 0;
974 if (qp->s_last == qp->s_tail) 982 if (qp->s_last == qp->s_tail)
975 break; 983 break;
976 wqe = get_swqe_ptr(qp, qp->s_last); 984 wqe = get_swqe_ptr(qp, qp->s_last);
@@ -994,7 +1002,7 @@ static int do_rc_ack(struct ipath_qp *qp, u32 aeth, u32 psn, int opcode,
994 */ 1002 */
995 if (ipath_cmp24(qp->s_psn, psn) <= 0) { 1003 if (ipath_cmp24(qp->s_psn, psn) <= 0) {
996 reset_psn(qp, psn + 1); 1004 reset_psn(qp, psn + 1);
997 tasklet_hi_schedule(&qp->s_task); 1005 ipath_schedule_send(qp);
998 } 1006 }
999 } else if (ipath_cmp24(qp->s_psn, psn) <= 0) { 1007 } else if (ipath_cmp24(qp->s_psn, psn) <= 0) {
1000 qp->s_state = OP(SEND_LAST); 1008 qp->s_state = OP(SEND_LAST);
@@ -1012,7 +1020,7 @@ static int do_rc_ack(struct ipath_qp *qp, u32 aeth, u32 psn, int opcode,
1012 if (qp->s_last == qp->s_tail) 1020 if (qp->s_last == qp->s_tail)
1013 goto bail; 1021 goto bail;
1014 if (qp->s_rnr_retry == 0) { 1022 if (qp->s_rnr_retry == 0) {
1015 wc.status = IB_WC_RNR_RETRY_EXC_ERR; 1023 status = IB_WC_RNR_RETRY_EXC_ERR;
1016 goto class_b; 1024 goto class_b;
1017 } 1025 }
1018 if (qp->s_rnr_retry_cnt < 7) 1026 if (qp->s_rnr_retry_cnt < 7)
@@ -1033,6 +1041,7 @@ static int do_rc_ack(struct ipath_qp *qp, u32 aeth, u32 psn, int opcode,
1033 ib_ipath_rnr_table[(aeth >> IPATH_AETH_CREDIT_SHIFT) & 1041 ib_ipath_rnr_table[(aeth >> IPATH_AETH_CREDIT_SHIFT) &
1034 IPATH_AETH_CREDIT_MASK]; 1042 IPATH_AETH_CREDIT_MASK];
1035 ipath_insert_rnr_queue(qp); 1043 ipath_insert_rnr_queue(qp);
1044 ipath_schedule_send(qp);
1036 goto bail; 1045 goto bail;
1037 1046
1038 case 3: /* NAK */ 1047 case 3: /* NAK */
@@ -1050,37 +1059,25 @@ static int do_rc_ack(struct ipath_qp *qp, u32 aeth, u32 psn, int opcode,
1050 * RDMA READ response which terminates the RDMA 1059 * RDMA READ response which terminates the RDMA
1051 * READ. 1060 * READ.
1052 */ 1061 */
1053 ipath_restart_rc(qp, psn, &wc); 1062 ipath_restart_rc(qp, psn);
1054 break; 1063 break;
1055 1064
1056 case 1: /* Invalid Request */ 1065 case 1: /* Invalid Request */
1057 wc.status = IB_WC_REM_INV_REQ_ERR; 1066 status = IB_WC_REM_INV_REQ_ERR;
1058 dev->n_other_naks++; 1067 dev->n_other_naks++;
1059 goto class_b; 1068 goto class_b;
1060 1069
1061 case 2: /* Remote Access Error */ 1070 case 2: /* Remote Access Error */
1062 wc.status = IB_WC_REM_ACCESS_ERR; 1071 status = IB_WC_REM_ACCESS_ERR;
1063 dev->n_other_naks++; 1072 dev->n_other_naks++;
1064 goto class_b; 1073 goto class_b;
1065 1074
1066 case 3: /* Remote Operation Error */ 1075 case 3: /* Remote Operation Error */
1067 wc.status = IB_WC_REM_OP_ERR; 1076 status = IB_WC_REM_OP_ERR;
1068 dev->n_other_naks++; 1077 dev->n_other_naks++;
1069 class_b: 1078 class_b:
1070 wc.wr_id = wqe->wr.wr_id; 1079 ipath_send_complete(qp, wqe, status);
1071 wc.opcode = ib_ipath_wc_opcode[wqe->wr.opcode]; 1080 ipath_error_qp(qp, IB_WC_WR_FLUSH_ERR);
1072 wc.vendor_err = 0;
1073 wc.byte_len = 0;
1074 wc.qp = &qp->ibqp;
1075 wc.imm_data = 0;
1076 wc.src_qp = qp->remote_qpn;
1077 wc.wc_flags = 0;
1078 wc.pkey_index = 0;
1079 wc.slid = qp->remote_ah_attr.dlid;
1080 wc.sl = qp->remote_ah_attr.sl;
1081 wc.dlid_path_bits = 0;
1082 wc.port_num = 0;
1083 ipath_sqerror_qp(qp, &wc);
1084 break; 1081 break;
1085 1082
1086 default: 1083 default:
@@ -1126,8 +1123,8 @@ static inline void ipath_rc_rcv_resp(struct ipath_ibdev *dev,
1126 int header_in_data) 1123 int header_in_data)
1127{ 1124{
1128 struct ipath_swqe *wqe; 1125 struct ipath_swqe *wqe;
1126 enum ib_wc_status status;
1129 unsigned long flags; 1127 unsigned long flags;
1130 struct ib_wc wc;
1131 int diff; 1128 int diff;
1132 u32 pad; 1129 u32 pad;
1133 u32 aeth; 1130 u32 aeth;
@@ -1135,6 +1132,10 @@ static inline void ipath_rc_rcv_resp(struct ipath_ibdev *dev,
1135 1132
1136 spin_lock_irqsave(&qp->s_lock, flags); 1133 spin_lock_irqsave(&qp->s_lock, flags);
1137 1134
1135 /* Double check we can process this now that we hold the s_lock. */
1136 if (!(ib_ipath_state_ops[qp->state] & IPATH_PROCESS_RECV_OK))
1137 goto ack_done;
1138
1138 /* Ignore invalid responses. */ 1139 /* Ignore invalid responses. */
1139 if (ipath_cmp24(psn, qp->s_next_psn) >= 0) 1140 if (ipath_cmp24(psn, qp->s_next_psn) >= 0)
1140 goto ack_done; 1141 goto ack_done;
@@ -1159,6 +1160,7 @@ static inline void ipath_rc_rcv_resp(struct ipath_ibdev *dev,
1159 if (unlikely(qp->s_last == qp->s_tail)) 1160 if (unlikely(qp->s_last == qp->s_tail))
1160 goto ack_done; 1161 goto ack_done;
1161 wqe = get_swqe_ptr(qp, qp->s_last); 1162 wqe = get_swqe_ptr(qp, qp->s_last);
1163 status = IB_WC_SUCCESS;
1162 1164
1163 switch (opcode) { 1165 switch (opcode) {
1164 case OP(ACKNOWLEDGE): 1166 case OP(ACKNOWLEDGE):
@@ -1187,6 +1189,7 @@ static inline void ipath_rc_rcv_resp(struct ipath_ibdev *dev,
1187 wqe = get_swqe_ptr(qp, qp->s_last); 1189 wqe = get_swqe_ptr(qp, qp->s_last);
1188 if (unlikely(wqe->wr.opcode != IB_WR_RDMA_READ)) 1190 if (unlikely(wqe->wr.opcode != IB_WR_RDMA_READ))
1189 goto ack_op_err; 1191 goto ack_op_err;
1192 qp->r_flags &= ~IPATH_R_RDMAR_SEQ;
1190 /* 1193 /*
1191 * If this is a response to a resent RDMA read, we 1194 * If this is a response to a resent RDMA read, we
1192 * have to be careful to copy the data to the right 1195 * have to be careful to copy the data to the right
@@ -1200,7 +1203,10 @@ static inline void ipath_rc_rcv_resp(struct ipath_ibdev *dev,
1200 /* no AETH, no ACK */ 1203 /* no AETH, no ACK */
1201 if (unlikely(ipath_cmp24(psn, qp->s_last_psn + 1))) { 1204 if (unlikely(ipath_cmp24(psn, qp->s_last_psn + 1))) {
1202 dev->n_rdma_seq++; 1205 dev->n_rdma_seq++;
1203 ipath_restart_rc(qp, qp->s_last_psn + 1, &wc); 1206 if (qp->r_flags & IPATH_R_RDMAR_SEQ)
1207 goto ack_done;
1208 qp->r_flags |= IPATH_R_RDMAR_SEQ;
1209 ipath_restart_rc(qp, qp->s_last_psn + 1);
1204 goto ack_done; 1210 goto ack_done;
1205 } 1211 }
1206 if (unlikely(wqe->wr.opcode != IB_WR_RDMA_READ)) 1212 if (unlikely(wqe->wr.opcode != IB_WR_RDMA_READ))
@@ -1261,7 +1267,10 @@ static inline void ipath_rc_rcv_resp(struct ipath_ibdev *dev,
1261 /* ACKs READ req. */ 1267 /* ACKs READ req. */
1262 if (unlikely(ipath_cmp24(psn, qp->s_last_psn + 1))) { 1268 if (unlikely(ipath_cmp24(psn, qp->s_last_psn + 1))) {
1263 dev->n_rdma_seq++; 1269 dev->n_rdma_seq++;
1264 ipath_restart_rc(qp, qp->s_last_psn + 1, &wc); 1270 if (qp->r_flags & IPATH_R_RDMAR_SEQ)
1271 goto ack_done;
1272 qp->r_flags |= IPATH_R_RDMAR_SEQ;
1273 ipath_restart_rc(qp, qp->s_last_psn + 1);
1265 goto ack_done; 1274 goto ack_done;
1266 } 1275 }
1267 if (unlikely(wqe->wr.opcode != IB_WR_RDMA_READ)) 1276 if (unlikely(wqe->wr.opcode != IB_WR_RDMA_READ))
@@ -1291,31 +1300,16 @@ static inline void ipath_rc_rcv_resp(struct ipath_ibdev *dev,
1291 goto ack_done; 1300 goto ack_done;
1292 } 1301 }
1293 1302
1294ack_done:
1295 spin_unlock_irqrestore(&qp->s_lock, flags);
1296 goto bail;
1297
1298ack_op_err: 1303ack_op_err:
1299 wc.status = IB_WC_LOC_QP_OP_ERR; 1304 status = IB_WC_LOC_QP_OP_ERR;
1300 goto ack_err; 1305 goto ack_err;
1301 1306
1302ack_len_err: 1307ack_len_err:
1303 wc.status = IB_WC_LOC_LEN_ERR; 1308 status = IB_WC_LOC_LEN_ERR;
1304ack_err: 1309ack_err:
1305 wc.wr_id = wqe->wr.wr_id; 1310 ipath_send_complete(qp, wqe, status);
1306 wc.opcode = ib_ipath_wc_opcode[wqe->wr.opcode]; 1311 ipath_error_qp(qp, IB_WC_WR_FLUSH_ERR);
1307 wc.vendor_err = 0; 1312ack_done:
1308 wc.byte_len = 0;
1309 wc.imm_data = 0;
1310 wc.qp = &qp->ibqp;
1311 wc.src_qp = qp->remote_qpn;
1312 wc.wc_flags = 0;
1313 wc.pkey_index = 0;
1314 wc.slid = qp->remote_ah_attr.dlid;
1315 wc.sl = qp->remote_ah_attr.sl;
1316 wc.dlid_path_bits = 0;
1317 wc.port_num = 0;
1318 ipath_sqerror_qp(qp, &wc);
1319 spin_unlock_irqrestore(&qp->s_lock, flags); 1313 spin_unlock_irqrestore(&qp->s_lock, flags);
1320bail: 1314bail:
1321 return; 1315 return;
@@ -1384,7 +1378,12 @@ static inline int ipath_rc_rcv_error(struct ipath_ibdev *dev,
1384 psn &= IPATH_PSN_MASK; 1378 psn &= IPATH_PSN_MASK;
1385 e = NULL; 1379 e = NULL;
1386 old_req = 1; 1380 old_req = 1;
1381
1387 spin_lock_irqsave(&qp->s_lock, flags); 1382 spin_lock_irqsave(&qp->s_lock, flags);
1383 /* Double check we can process this now that we hold the s_lock. */
1384 if (!(ib_ipath_state_ops[qp->state] & IPATH_PROCESS_RECV_OK))
1385 goto unlock_done;
1386
1388 for (i = qp->r_head_ack_queue; ; i = prev) { 1387 for (i = qp->r_head_ack_queue; ; i = prev) {
1389 if (i == qp->s_tail_ack_queue) 1388 if (i == qp->s_tail_ack_queue)
1390 old_req = 0; 1389 old_req = 0;
@@ -1512,7 +1511,7 @@ static inline int ipath_rc_rcv_error(struct ipath_ibdev *dev,
1512 break; 1511 break;
1513 } 1512 }
1514 qp->r_nak_state = 0; 1513 qp->r_nak_state = 0;
1515 tasklet_hi_schedule(&qp->s_task); 1514 ipath_schedule_send(qp);
1516 1515
1517unlock_done: 1516unlock_done:
1518 spin_unlock_irqrestore(&qp->s_lock, flags); 1517 spin_unlock_irqrestore(&qp->s_lock, flags);
@@ -1523,13 +1522,12 @@ send_ack:
1523 return 0; 1522 return 0;
1524} 1523}
1525 1524
1526static void ipath_rc_error(struct ipath_qp *qp, enum ib_wc_status err) 1525void ipath_rc_error(struct ipath_qp *qp, enum ib_wc_status err)
1527{ 1526{
1528 unsigned long flags; 1527 unsigned long flags;
1529 int lastwqe; 1528 int lastwqe;
1530 1529
1531 spin_lock_irqsave(&qp->s_lock, flags); 1530 spin_lock_irqsave(&qp->s_lock, flags);
1532 qp->state = IB_QPS_ERR;
1533 lastwqe = ipath_error_qp(qp, err); 1531 lastwqe = ipath_error_qp(qp, err);
1534 spin_unlock_irqrestore(&qp->s_lock, flags); 1532 spin_unlock_irqrestore(&qp->s_lock, flags);
1535 1533
@@ -1545,18 +1543,15 @@ static void ipath_rc_error(struct ipath_qp *qp, enum ib_wc_status err)
1545 1543
1546static inline void ipath_update_ack_queue(struct ipath_qp *qp, unsigned n) 1544static inline void ipath_update_ack_queue(struct ipath_qp *qp, unsigned n)
1547{ 1545{
1548 unsigned long flags;
1549 unsigned next; 1546 unsigned next;
1550 1547
1551 next = n + 1; 1548 next = n + 1;
1552 if (next > IPATH_MAX_RDMA_ATOMIC) 1549 if (next > IPATH_MAX_RDMA_ATOMIC)
1553 next = 0; 1550 next = 0;
1554 spin_lock_irqsave(&qp->s_lock, flags);
1555 if (n == qp->s_tail_ack_queue) { 1551 if (n == qp->s_tail_ack_queue) {
1556 qp->s_tail_ack_queue = next; 1552 qp->s_tail_ack_queue = next;
1557 qp->s_ack_state = OP(ACKNOWLEDGE); 1553 qp->s_ack_state = OP(ACKNOWLEDGE);
1558 } 1554 }
1559 spin_unlock_irqrestore(&qp->s_lock, flags);
1560} 1555}
1561 1556
1562/** 1557/**
@@ -1585,6 +1580,7 @@ void ipath_rc_rcv(struct ipath_ibdev *dev, struct ipath_ib_header *hdr,
1585 int diff; 1580 int diff;
1586 struct ib_reth *reth; 1581 struct ib_reth *reth;
1587 int header_in_data; 1582 int header_in_data;
1583 unsigned long flags;
1588 1584
1589 /* Validate the SLID. See Ch. 9.6.1.5 */ 1585 /* Validate the SLID. See Ch. 9.6.1.5 */
1590 if (unlikely(be16_to_cpu(hdr->lrh[3]) != qp->remote_ah_attr.dlid)) 1586 if (unlikely(be16_to_cpu(hdr->lrh[3]) != qp->remote_ah_attr.dlid))
@@ -1643,11 +1639,7 @@ void ipath_rc_rcv(struct ipath_ibdev *dev, struct ipath_ib_header *hdr,
1643 opcode == OP(SEND_LAST) || 1639 opcode == OP(SEND_LAST) ||
1644 opcode == OP(SEND_LAST_WITH_IMMEDIATE)) 1640 opcode == OP(SEND_LAST_WITH_IMMEDIATE))
1645 break; 1641 break;
1646 nack_inv: 1642 goto nack_inv;
1647 ipath_rc_error(qp, IB_WC_REM_INV_REQ_ERR);
1648 qp->r_nak_state = IB_NAK_INVALID_REQUEST;
1649 qp->r_ack_psn = qp->r_psn;
1650 goto send_ack;
1651 1643
1652 case OP(RDMA_WRITE_FIRST): 1644 case OP(RDMA_WRITE_FIRST):
1653 case OP(RDMA_WRITE_MIDDLE): 1645 case OP(RDMA_WRITE_MIDDLE):
@@ -1673,18 +1665,13 @@ void ipath_rc_rcv(struct ipath_ibdev *dev, struct ipath_ib_header *hdr,
1673 break; 1665 break;
1674 } 1666 }
1675 1667
1676 wc.imm_data = 0; 1668 memset(&wc, 0, sizeof wc);
1677 wc.wc_flags = 0;
1678 1669
1679 /* OK, process the packet. */ 1670 /* OK, process the packet. */
1680 switch (opcode) { 1671 switch (opcode) {
1681 case OP(SEND_FIRST): 1672 case OP(SEND_FIRST):
1682 if (!ipath_get_rwqe(qp, 0)) { 1673 if (!ipath_get_rwqe(qp, 0))
1683 rnr_nak: 1674 goto rnr_nak;
1684 qp->r_nak_state = IB_RNR_NAK | qp->r_min_rnr_timer;
1685 qp->r_ack_psn = qp->r_psn;
1686 goto send_ack;
1687 }
1688 qp->r_rcv_len = 0; 1675 qp->r_rcv_len = 0;
1689 /* FALLTHROUGH */ 1676 /* FALLTHROUGH */
1690 case OP(SEND_MIDDLE): 1677 case OP(SEND_MIDDLE):
@@ -1741,9 +1728,8 @@ void ipath_rc_rcv(struct ipath_ibdev *dev, struct ipath_ib_header *hdr,
1741 goto nack_inv; 1728 goto nack_inv;
1742 ipath_copy_sge(&qp->r_sge, data, tlen); 1729 ipath_copy_sge(&qp->r_sge, data, tlen);
1743 qp->r_msn++; 1730 qp->r_msn++;
1744 if (!qp->r_wrid_valid) 1731 if (!test_and_clear_bit(IPATH_R_WRID_VALID, &qp->r_aflags))
1745 break; 1732 break;
1746 qp->r_wrid_valid = 0;
1747 wc.wr_id = qp->r_wr_id; 1733 wc.wr_id = qp->r_wr_id;
1748 wc.status = IB_WC_SUCCESS; 1734 wc.status = IB_WC_SUCCESS;
1749 if (opcode == OP(RDMA_WRITE_LAST_WITH_IMMEDIATE) || 1735 if (opcode == OP(RDMA_WRITE_LAST_WITH_IMMEDIATE) ||
@@ -1751,14 +1737,10 @@ void ipath_rc_rcv(struct ipath_ibdev *dev, struct ipath_ib_header *hdr,
1751 wc.opcode = IB_WC_RECV_RDMA_WITH_IMM; 1737 wc.opcode = IB_WC_RECV_RDMA_WITH_IMM;
1752 else 1738 else
1753 wc.opcode = IB_WC_RECV; 1739 wc.opcode = IB_WC_RECV;
1754 wc.vendor_err = 0;
1755 wc.qp = &qp->ibqp; 1740 wc.qp = &qp->ibqp;
1756 wc.src_qp = qp->remote_qpn; 1741 wc.src_qp = qp->remote_qpn;
1757 wc.pkey_index = 0;
1758 wc.slid = qp->remote_ah_attr.dlid; 1742 wc.slid = qp->remote_ah_attr.dlid;
1759 wc.sl = qp->remote_ah_attr.sl; 1743 wc.sl = qp->remote_ah_attr.sl;
1760 wc.dlid_path_bits = 0;
1761 wc.port_num = 0;
1762 /* Signal completion event if the solicited bit is set. */ 1744 /* Signal completion event if the solicited bit is set. */
1763 ipath_cq_enter(to_icq(qp->ibqp.recv_cq), &wc, 1745 ipath_cq_enter(to_icq(qp->ibqp.recv_cq), &wc,
1764 (ohdr->bth[0] & 1746 (ohdr->bth[0] &
@@ -1819,9 +1801,13 @@ void ipath_rc_rcv(struct ipath_ibdev *dev, struct ipath_ib_header *hdr,
1819 next = qp->r_head_ack_queue + 1; 1801 next = qp->r_head_ack_queue + 1;
1820 if (next > IPATH_MAX_RDMA_ATOMIC) 1802 if (next > IPATH_MAX_RDMA_ATOMIC)
1821 next = 0; 1803 next = 0;
1804 spin_lock_irqsave(&qp->s_lock, flags);
1805 /* Double check we can process this while holding the s_lock. */
1806 if (!(ib_ipath_state_ops[qp->state] & IPATH_PROCESS_RECV_OK))
1807 goto unlock;
1822 if (unlikely(next == qp->s_tail_ack_queue)) { 1808 if (unlikely(next == qp->s_tail_ack_queue)) {
1823 if (!qp->s_ack_queue[next].sent) 1809 if (!qp->s_ack_queue[next].sent)
1824 goto nack_inv; 1810 goto nack_inv_unlck;
1825 ipath_update_ack_queue(qp, next); 1811 ipath_update_ack_queue(qp, next);
1826 } 1812 }
1827 e = &qp->s_ack_queue[qp->r_head_ack_queue]; 1813 e = &qp->s_ack_queue[qp->r_head_ack_queue];
@@ -1842,7 +1828,7 @@ void ipath_rc_rcv(struct ipath_ibdev *dev, struct ipath_ib_header *hdr,
1842 ok = ipath_rkey_ok(qp, &e->rdma_sge, len, vaddr, 1828 ok = ipath_rkey_ok(qp, &e->rdma_sge, len, vaddr,
1843 rkey, IB_ACCESS_REMOTE_READ); 1829 rkey, IB_ACCESS_REMOTE_READ);
1844 if (unlikely(!ok)) 1830 if (unlikely(!ok))
1845 goto nack_acc; 1831 goto nack_acc_unlck;
1846 /* 1832 /*
1847 * Update the next expected PSN. We add 1 later 1833 * Update the next expected PSN. We add 1 later
1848 * below, so only add the remainder here. 1834 * below, so only add the remainder here.
@@ -1869,13 +1855,12 @@ void ipath_rc_rcv(struct ipath_ibdev *dev, struct ipath_ib_header *hdr,
1869 qp->r_psn++; 1855 qp->r_psn++;
1870 qp->r_state = opcode; 1856 qp->r_state = opcode;
1871 qp->r_nak_state = 0; 1857 qp->r_nak_state = 0;
1872 barrier();
1873 qp->r_head_ack_queue = next; 1858 qp->r_head_ack_queue = next;
1874 1859
1875 /* Call ipath_do_rc_send() in another thread. */ 1860 /* Schedule the send tasklet. */
1876 tasklet_hi_schedule(&qp->s_task); 1861 ipath_schedule_send(qp);
1877 1862
1878 goto done; 1863 goto unlock;
1879 } 1864 }
1880 1865
1881 case OP(COMPARE_SWAP): 1866 case OP(COMPARE_SWAP):
@@ -1894,9 +1879,13 @@ void ipath_rc_rcv(struct ipath_ibdev *dev, struct ipath_ib_header *hdr,
1894 next = qp->r_head_ack_queue + 1; 1879 next = qp->r_head_ack_queue + 1;
1895 if (next > IPATH_MAX_RDMA_ATOMIC) 1880 if (next > IPATH_MAX_RDMA_ATOMIC)
1896 next = 0; 1881 next = 0;
1882 spin_lock_irqsave(&qp->s_lock, flags);
1883 /* Double check we can process this while holding the s_lock. */
1884 if (!(ib_ipath_state_ops[qp->state] & IPATH_PROCESS_RECV_OK))
1885 goto unlock;
1897 if (unlikely(next == qp->s_tail_ack_queue)) { 1886 if (unlikely(next == qp->s_tail_ack_queue)) {
1898 if (!qp->s_ack_queue[next].sent) 1887 if (!qp->s_ack_queue[next].sent)
1899 goto nack_inv; 1888 goto nack_inv_unlck;
1900 ipath_update_ack_queue(qp, next); 1889 ipath_update_ack_queue(qp, next);
1901 } 1890 }
1902 if (!header_in_data) 1891 if (!header_in_data)
@@ -1906,13 +1895,13 @@ void ipath_rc_rcv(struct ipath_ibdev *dev, struct ipath_ib_header *hdr,
1906 vaddr = ((u64) be32_to_cpu(ateth->vaddr[0]) << 32) | 1895 vaddr = ((u64) be32_to_cpu(ateth->vaddr[0]) << 32) |
1907 be32_to_cpu(ateth->vaddr[1]); 1896 be32_to_cpu(ateth->vaddr[1]);
1908 if (unlikely(vaddr & (sizeof(u64) - 1))) 1897 if (unlikely(vaddr & (sizeof(u64) - 1)))
1909 goto nack_inv; 1898 goto nack_inv_unlck;
1910 rkey = be32_to_cpu(ateth->rkey); 1899 rkey = be32_to_cpu(ateth->rkey);
1911 /* Check rkey & NAK */ 1900 /* Check rkey & NAK */
1912 if (unlikely(!ipath_rkey_ok(qp, &qp->r_sge, 1901 if (unlikely(!ipath_rkey_ok(qp, &qp->r_sge,
1913 sizeof(u64), vaddr, rkey, 1902 sizeof(u64), vaddr, rkey,
1914 IB_ACCESS_REMOTE_ATOMIC))) 1903 IB_ACCESS_REMOTE_ATOMIC)))
1915 goto nack_acc; 1904 goto nack_acc_unlck;
1916 /* Perform atomic OP and save result. */ 1905 /* Perform atomic OP and save result. */
1917 maddr = (atomic64_t *) qp->r_sge.sge.vaddr; 1906 maddr = (atomic64_t *) qp->r_sge.sge.vaddr;
1918 sdata = be64_to_cpu(ateth->swap_data); 1907 sdata = be64_to_cpu(ateth->swap_data);
@@ -1929,13 +1918,12 @@ void ipath_rc_rcv(struct ipath_ibdev *dev, struct ipath_ib_header *hdr,
1929 qp->r_psn++; 1918 qp->r_psn++;
1930 qp->r_state = opcode; 1919 qp->r_state = opcode;
1931 qp->r_nak_state = 0; 1920 qp->r_nak_state = 0;
1932 barrier();
1933 qp->r_head_ack_queue = next; 1921 qp->r_head_ack_queue = next;
1934 1922
1935 /* Call ipath_do_rc_send() in another thread. */ 1923 /* Schedule the send tasklet. */
1936 tasklet_hi_schedule(&qp->s_task); 1924 ipath_schedule_send(qp);
1937 1925
1938 goto done; 1926 goto unlock;
1939 } 1927 }
1940 1928
1941 default: 1929 default:
@@ -1951,14 +1939,31 @@ void ipath_rc_rcv(struct ipath_ibdev *dev, struct ipath_ib_header *hdr,
1951 goto send_ack; 1939 goto send_ack;
1952 goto done; 1940 goto done;
1953 1941
1942rnr_nak:
1943 qp->r_nak_state = IB_RNR_NAK | qp->r_min_rnr_timer;
1944 qp->r_ack_psn = qp->r_psn;
1945 goto send_ack;
1946
1947nack_inv_unlck:
1948 spin_unlock_irqrestore(&qp->s_lock, flags);
1949nack_inv:
1950 ipath_rc_error(qp, IB_WC_LOC_QP_OP_ERR);
1951 qp->r_nak_state = IB_NAK_INVALID_REQUEST;
1952 qp->r_ack_psn = qp->r_psn;
1953 goto send_ack;
1954
1955nack_acc_unlck:
1956 spin_unlock_irqrestore(&qp->s_lock, flags);
1954nack_acc: 1957nack_acc:
1955 ipath_rc_error(qp, IB_WC_REM_ACCESS_ERR); 1958 ipath_rc_error(qp, IB_WC_LOC_PROT_ERR);
1956 qp->r_nak_state = IB_NAK_REMOTE_ACCESS_ERROR; 1959 qp->r_nak_state = IB_NAK_REMOTE_ACCESS_ERROR;
1957 qp->r_ack_psn = qp->r_psn; 1960 qp->r_ack_psn = qp->r_psn;
1958
1959send_ack: 1961send_ack:
1960 send_rc_ack(qp); 1962 send_rc_ack(qp);
1963 goto done;
1961 1964
1965unlock:
1966 spin_unlock_irqrestore(&qp->s_lock, flags);
1962done: 1967done:
1963 return; 1968 return;
1964} 1969}
diff --git a/drivers/infiniband/hw/ipath/ipath_ruc.c b/drivers/infiniband/hw/ipath/ipath_ruc.c
index 9e3fe61cbd08..a4b5521567fe 100644
--- a/drivers/infiniband/hw/ipath/ipath_ruc.c
+++ b/drivers/infiniband/hw/ipath/ipath_ruc.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (c) 2006, 2007 QLogic Corporation. All rights reserved. 2 * Copyright (c) 2006, 2007, 2008 QLogic Corporation. All rights reserved.
3 * Copyright (c) 2005, 2006 PathScale, Inc. All rights reserved. 3 * Copyright (c) 2005, 2006 PathScale, Inc. All rights reserved.
4 * 4 *
5 * This software is available to you under a choice of one of two 5 * This software is available to you under a choice of one of two
@@ -78,6 +78,7 @@ const u32 ib_ipath_rnr_table[32] = {
78 * ipath_insert_rnr_queue - put QP on the RNR timeout list for the device 78 * ipath_insert_rnr_queue - put QP on the RNR timeout list for the device
79 * @qp: the QP 79 * @qp: the QP
80 * 80 *
81 * Called with the QP s_lock held and interrupts disabled.
81 * XXX Use a simple list for now. We might need a priority 82 * XXX Use a simple list for now. We might need a priority
82 * queue if we have lots of QPs waiting for RNR timeouts 83 * queue if we have lots of QPs waiting for RNR timeouts
83 * but that should be rare. 84 * but that should be rare.
@@ -85,9 +86,9 @@ const u32 ib_ipath_rnr_table[32] = {
85void ipath_insert_rnr_queue(struct ipath_qp *qp) 86void ipath_insert_rnr_queue(struct ipath_qp *qp)
86{ 87{
87 struct ipath_ibdev *dev = to_idev(qp->ibqp.device); 88 struct ipath_ibdev *dev = to_idev(qp->ibqp.device);
88 unsigned long flags;
89 89
90 spin_lock_irqsave(&dev->pending_lock, flags); 90 /* We already did a spin_lock_irqsave(), so just use spin_lock */
91 spin_lock(&dev->pending_lock);
91 if (list_empty(&dev->rnrwait)) 92 if (list_empty(&dev->rnrwait))
92 list_add(&qp->timerwait, &dev->rnrwait); 93 list_add(&qp->timerwait, &dev->rnrwait);
93 else { 94 else {
@@ -109,7 +110,7 @@ void ipath_insert_rnr_queue(struct ipath_qp *qp)
109 nqp->s_rnr_timeout -= qp->s_rnr_timeout; 110 nqp->s_rnr_timeout -= qp->s_rnr_timeout;
110 list_add(&qp->timerwait, l); 111 list_add(&qp->timerwait, l);
111 } 112 }
112 spin_unlock_irqrestore(&dev->pending_lock, flags); 113 spin_unlock(&dev->pending_lock);
113} 114}
114 115
115/** 116/**
@@ -140,20 +141,11 @@ int ipath_init_sge(struct ipath_qp *qp, struct ipath_rwqe *wqe,
140 goto bail; 141 goto bail;
141 142
142bad_lkey: 143bad_lkey:
144 memset(&wc, 0, sizeof(wc));
143 wc.wr_id = wqe->wr_id; 145 wc.wr_id = wqe->wr_id;
144 wc.status = IB_WC_LOC_PROT_ERR; 146 wc.status = IB_WC_LOC_PROT_ERR;
145 wc.opcode = IB_WC_RECV; 147 wc.opcode = IB_WC_RECV;
146 wc.vendor_err = 0;
147 wc.byte_len = 0;
148 wc.imm_data = 0;
149 wc.qp = &qp->ibqp; 148 wc.qp = &qp->ibqp;
150 wc.src_qp = 0;
151 wc.wc_flags = 0;
152 wc.pkey_index = 0;
153 wc.slid = 0;
154 wc.sl = 0;
155 wc.dlid_path_bits = 0;
156 wc.port_num = 0;
157 /* Signal solicited completion event. */ 149 /* Signal solicited completion event. */
158 ipath_cq_enter(to_icq(qp->ibqp.recv_cq), &wc, 1); 150 ipath_cq_enter(to_icq(qp->ibqp.recv_cq), &wc, 1);
159 ret = 0; 151 ret = 0;
@@ -194,6 +186,11 @@ int ipath_get_rwqe(struct ipath_qp *qp, int wr_id_only)
194 } 186 }
195 187
196 spin_lock_irqsave(&rq->lock, flags); 188 spin_lock_irqsave(&rq->lock, flags);
189 if (!(ib_ipath_state_ops[qp->state] & IPATH_PROCESS_RECV_OK)) {
190 ret = 0;
191 goto unlock;
192 }
193
197 wq = rq->wq; 194 wq = rq->wq;
198 tail = wq->tail; 195 tail = wq->tail;
199 /* Validate tail before using it since it is user writable. */ 196 /* Validate tail before using it since it is user writable. */
@@ -201,9 +198,8 @@ int ipath_get_rwqe(struct ipath_qp *qp, int wr_id_only)
201 tail = 0; 198 tail = 0;
202 do { 199 do {
203 if (unlikely(tail == wq->head)) { 200 if (unlikely(tail == wq->head)) {
204 spin_unlock_irqrestore(&rq->lock, flags);
205 ret = 0; 201 ret = 0;
206 goto bail; 202 goto unlock;
207 } 203 }
208 /* Make sure entry is read after head index is read. */ 204 /* Make sure entry is read after head index is read. */
209 smp_rmb(); 205 smp_rmb();
@@ -216,7 +212,7 @@ int ipath_get_rwqe(struct ipath_qp *qp, int wr_id_only)
216 wq->tail = tail; 212 wq->tail = tail;
217 213
218 ret = 1; 214 ret = 1;
219 qp->r_wrid_valid = 1; 215 set_bit(IPATH_R_WRID_VALID, &qp->r_aflags);
220 if (handler) { 216 if (handler) {
221 u32 n; 217 u32 n;
222 218
@@ -243,8 +239,8 @@ int ipath_get_rwqe(struct ipath_qp *qp, int wr_id_only)
243 goto bail; 239 goto bail;
244 } 240 }
245 } 241 }
242unlock:
246 spin_unlock_irqrestore(&rq->lock, flags); 243 spin_unlock_irqrestore(&rq->lock, flags);
247
248bail: 244bail:
249 return ret; 245 return ret;
250} 246}
@@ -270,38 +266,63 @@ static void ipath_ruc_loopback(struct ipath_qp *sqp)
270 struct ib_wc wc; 266 struct ib_wc wc;
271 u64 sdata; 267 u64 sdata;
272 atomic64_t *maddr; 268 atomic64_t *maddr;
269 enum ib_wc_status send_status;
273 270
271 /*
272 * Note that we check the responder QP state after
273 * checking the requester's state.
274 */
274 qp = ipath_lookup_qpn(&dev->qp_table, sqp->remote_qpn); 275 qp = ipath_lookup_qpn(&dev->qp_table, sqp->remote_qpn);
275 if (!qp) {
276 dev->n_pkt_drops++;
277 return;
278 }
279 276
280again:
281 spin_lock_irqsave(&sqp->s_lock, flags); 277 spin_lock_irqsave(&sqp->s_lock, flags);
282 278
283 if (!(ib_ipath_state_ops[sqp->state] & IPATH_PROCESS_SEND_OK) || 279 /* Return if we are already busy processing a work request. */
284 sqp->s_rnr_timeout) { 280 if ((sqp->s_flags & (IPATH_S_BUSY | IPATH_S_ANY_WAIT)) ||
285 spin_unlock_irqrestore(&sqp->s_lock, flags); 281 !(ib_ipath_state_ops[sqp->state] & IPATH_PROCESS_OR_FLUSH_SEND))
286 goto done; 282 goto unlock;
287 }
288 283
289 /* Get the next send request. */ 284 sqp->s_flags |= IPATH_S_BUSY;
290 if (sqp->s_last == sqp->s_head) { 285
291 /* Send work queue is empty. */ 286again:
292 spin_unlock_irqrestore(&sqp->s_lock, flags); 287 if (sqp->s_last == sqp->s_head)
293 goto done; 288 goto clr_busy;
289 wqe = get_swqe_ptr(sqp, sqp->s_last);
290
291 /* Return if it is not OK to start a new work reqeust. */
292 if (!(ib_ipath_state_ops[sqp->state] & IPATH_PROCESS_NEXT_SEND_OK)) {
293 if (!(ib_ipath_state_ops[sqp->state] & IPATH_FLUSH_SEND))
294 goto clr_busy;
295 /* We are in the error state, flush the work request. */
296 send_status = IB_WC_WR_FLUSH_ERR;
297 goto flush_send;
294 } 298 }
295 299
296 /* 300 /*
297 * We can rely on the entry not changing without the s_lock 301 * We can rely on the entry not changing without the s_lock
298 * being held until we update s_last. 302 * being held until we update s_last.
303 * We increment s_cur to indicate s_last is in progress.
299 */ 304 */
300 wqe = get_swqe_ptr(sqp, sqp->s_last); 305 if (sqp->s_last == sqp->s_cur) {
306 if (++sqp->s_cur >= sqp->s_size)
307 sqp->s_cur = 0;
308 }
301 spin_unlock_irqrestore(&sqp->s_lock, flags); 309 spin_unlock_irqrestore(&sqp->s_lock, flags);
302 310
303 wc.wc_flags = 0; 311 if (!qp || !(ib_ipath_state_ops[qp->state] & IPATH_PROCESS_RECV_OK)) {
304 wc.imm_data = 0; 312 dev->n_pkt_drops++;
313 /*
314 * For RC, the requester would timeout and retry so
315 * shortcut the timeouts and just signal too many retries.
316 */
317 if (sqp->ibqp.qp_type == IB_QPT_RC)
318 send_status = IB_WC_RETRY_EXC_ERR;
319 else
320 send_status = IB_WC_SUCCESS;
321 goto serr;
322 }
323
324 memset(&wc, 0, sizeof wc);
325 send_status = IB_WC_SUCCESS;
305 326
306 sqp->s_sge.sge = wqe->sg_list[0]; 327 sqp->s_sge.sge = wqe->sg_list[0];
307 sqp->s_sge.sg_list = wqe->sg_list + 1; 328 sqp->s_sge.sg_list = wqe->sg_list + 1;
@@ -313,75 +334,33 @@ again:
313 wc.imm_data = wqe->wr.ex.imm_data; 334 wc.imm_data = wqe->wr.ex.imm_data;
314 /* FALLTHROUGH */ 335 /* FALLTHROUGH */
315 case IB_WR_SEND: 336 case IB_WR_SEND:
316 if (!ipath_get_rwqe(qp, 0)) { 337 if (!ipath_get_rwqe(qp, 0))
317 rnr_nak: 338 goto rnr_nak;
318 /* Handle RNR NAK */
319 if (qp->ibqp.qp_type == IB_QPT_UC)
320 goto send_comp;
321 if (sqp->s_rnr_retry == 0) {
322 wc.status = IB_WC_RNR_RETRY_EXC_ERR;
323 goto err;
324 }
325 if (sqp->s_rnr_retry_cnt < 7)
326 sqp->s_rnr_retry--;
327 dev->n_rnr_naks++;
328 sqp->s_rnr_timeout =
329 ib_ipath_rnr_table[qp->r_min_rnr_timer];
330 ipath_insert_rnr_queue(sqp);
331 goto done;
332 }
333 break; 339 break;
334 340
335 case IB_WR_RDMA_WRITE_WITH_IMM: 341 case IB_WR_RDMA_WRITE_WITH_IMM:
336 if (unlikely(!(qp->qp_access_flags & 342 if (unlikely(!(qp->qp_access_flags & IB_ACCESS_REMOTE_WRITE)))
337 IB_ACCESS_REMOTE_WRITE))) { 343 goto inv_err;
338 wc.status = IB_WC_REM_INV_REQ_ERR;
339 goto err;
340 }
341 wc.wc_flags = IB_WC_WITH_IMM; 344 wc.wc_flags = IB_WC_WITH_IMM;
342 wc.imm_data = wqe->wr.ex.imm_data; 345 wc.imm_data = wqe->wr.ex.imm_data;
343 if (!ipath_get_rwqe(qp, 1)) 346 if (!ipath_get_rwqe(qp, 1))
344 goto rnr_nak; 347 goto rnr_nak;
345 /* FALLTHROUGH */ 348 /* FALLTHROUGH */
346 case IB_WR_RDMA_WRITE: 349 case IB_WR_RDMA_WRITE:
347 if (unlikely(!(qp->qp_access_flags & 350 if (unlikely(!(qp->qp_access_flags & IB_ACCESS_REMOTE_WRITE)))
348 IB_ACCESS_REMOTE_WRITE))) { 351 goto inv_err;
349 wc.status = IB_WC_REM_INV_REQ_ERR;
350 goto err;
351 }
352 if (wqe->length == 0) 352 if (wqe->length == 0)
353 break; 353 break;
354 if (unlikely(!ipath_rkey_ok(qp, &qp->r_sge, wqe->length, 354 if (unlikely(!ipath_rkey_ok(qp, &qp->r_sge, wqe->length,
355 wqe->wr.wr.rdma.remote_addr, 355 wqe->wr.wr.rdma.remote_addr,
356 wqe->wr.wr.rdma.rkey, 356 wqe->wr.wr.rdma.rkey,
357 IB_ACCESS_REMOTE_WRITE))) { 357 IB_ACCESS_REMOTE_WRITE)))
358 acc_err: 358 goto acc_err;
359 wc.status = IB_WC_REM_ACCESS_ERR;
360 err:
361 wc.wr_id = wqe->wr.wr_id;
362 wc.opcode = ib_ipath_wc_opcode[wqe->wr.opcode];
363 wc.vendor_err = 0;
364 wc.byte_len = 0;
365 wc.qp = &sqp->ibqp;
366 wc.src_qp = sqp->remote_qpn;
367 wc.pkey_index = 0;
368 wc.slid = sqp->remote_ah_attr.dlid;
369 wc.sl = sqp->remote_ah_attr.sl;
370 wc.dlid_path_bits = 0;
371 wc.port_num = 0;
372 spin_lock_irqsave(&sqp->s_lock, flags);
373 ipath_sqerror_qp(sqp, &wc);
374 spin_unlock_irqrestore(&sqp->s_lock, flags);
375 goto done;
376 }
377 break; 359 break;
378 360
379 case IB_WR_RDMA_READ: 361 case IB_WR_RDMA_READ:
380 if (unlikely(!(qp->qp_access_flags & 362 if (unlikely(!(qp->qp_access_flags & IB_ACCESS_REMOTE_READ)))
381 IB_ACCESS_REMOTE_READ))) { 363 goto inv_err;
382 wc.status = IB_WC_REM_INV_REQ_ERR;
383 goto err;
384 }
385 if (unlikely(!ipath_rkey_ok(qp, &sqp->s_sge, wqe->length, 364 if (unlikely(!ipath_rkey_ok(qp, &sqp->s_sge, wqe->length,
386 wqe->wr.wr.rdma.remote_addr, 365 wqe->wr.wr.rdma.remote_addr,
387 wqe->wr.wr.rdma.rkey, 366 wqe->wr.wr.rdma.rkey,
@@ -394,11 +373,8 @@ again:
394 373
395 case IB_WR_ATOMIC_CMP_AND_SWP: 374 case IB_WR_ATOMIC_CMP_AND_SWP:
396 case IB_WR_ATOMIC_FETCH_AND_ADD: 375 case IB_WR_ATOMIC_FETCH_AND_ADD:
397 if (unlikely(!(qp->qp_access_flags & 376 if (unlikely(!(qp->qp_access_flags & IB_ACCESS_REMOTE_ATOMIC)))
398 IB_ACCESS_REMOTE_ATOMIC))) { 377 goto inv_err;
399 wc.status = IB_WC_REM_INV_REQ_ERR;
400 goto err;
401 }
402 if (unlikely(!ipath_rkey_ok(qp, &qp->r_sge, sizeof(u64), 378 if (unlikely(!ipath_rkey_ok(qp, &qp->r_sge, sizeof(u64),
403 wqe->wr.wr.atomic.remote_addr, 379 wqe->wr.wr.atomic.remote_addr,
404 wqe->wr.wr.atomic.rkey, 380 wqe->wr.wr.atomic.rkey,
@@ -415,7 +391,8 @@ again:
415 goto send_comp; 391 goto send_comp;
416 392
417 default: 393 default:
418 goto done; 394 send_status = IB_WC_LOC_QP_OP_ERR;
395 goto serr;
419 } 396 }
420 397
421 sge = &sqp->s_sge.sge; 398 sge = &sqp->s_sge.sge;
@@ -448,8 +425,7 @@ again:
448 sqp->s_len -= len; 425 sqp->s_len -= len;
449 } 426 }
450 427
451 if (wqe->wr.opcode == IB_WR_RDMA_WRITE || 428 if (!test_and_clear_bit(IPATH_R_WRID_VALID, &qp->r_aflags))
452 wqe->wr.opcode == IB_WR_RDMA_READ)
453 goto send_comp; 429 goto send_comp;
454 430
455 if (wqe->wr.opcode == IB_WR_RDMA_WRITE_WITH_IMM) 431 if (wqe->wr.opcode == IB_WR_RDMA_WRITE_WITH_IMM)
@@ -458,33 +434,89 @@ again:
458 wc.opcode = IB_WC_RECV; 434 wc.opcode = IB_WC_RECV;
459 wc.wr_id = qp->r_wr_id; 435 wc.wr_id = qp->r_wr_id;
460 wc.status = IB_WC_SUCCESS; 436 wc.status = IB_WC_SUCCESS;
461 wc.vendor_err = 0;
462 wc.byte_len = wqe->length; 437 wc.byte_len = wqe->length;
463 wc.qp = &qp->ibqp; 438 wc.qp = &qp->ibqp;
464 wc.src_qp = qp->remote_qpn; 439 wc.src_qp = qp->remote_qpn;
465 wc.pkey_index = 0;
466 wc.slid = qp->remote_ah_attr.dlid; 440 wc.slid = qp->remote_ah_attr.dlid;
467 wc.sl = qp->remote_ah_attr.sl; 441 wc.sl = qp->remote_ah_attr.sl;
468 wc.dlid_path_bits = 0;
469 wc.port_num = 1; 442 wc.port_num = 1;
470 /* Signal completion event if the solicited bit is set. */ 443 /* Signal completion event if the solicited bit is set. */
471 ipath_cq_enter(to_icq(qp->ibqp.recv_cq), &wc, 444 ipath_cq_enter(to_icq(qp->ibqp.recv_cq), &wc,
472 wqe->wr.send_flags & IB_SEND_SOLICITED); 445 wqe->wr.send_flags & IB_SEND_SOLICITED);
473 446
474send_comp: 447send_comp:
448 spin_lock_irqsave(&sqp->s_lock, flags);
449flush_send:
475 sqp->s_rnr_retry = sqp->s_rnr_retry_cnt; 450 sqp->s_rnr_retry = sqp->s_rnr_retry_cnt;
476 ipath_send_complete(sqp, wqe, IB_WC_SUCCESS); 451 ipath_send_complete(sqp, wqe, send_status);
477 goto again; 452 goto again;
478 453
454rnr_nak:
455 /* Handle RNR NAK */
456 if (qp->ibqp.qp_type == IB_QPT_UC)
457 goto send_comp;
458 /*
459 * Note: we don't need the s_lock held since the BUSY flag
460 * makes this single threaded.
461 */
462 if (sqp->s_rnr_retry == 0) {
463 send_status = IB_WC_RNR_RETRY_EXC_ERR;
464 goto serr;
465 }
466 if (sqp->s_rnr_retry_cnt < 7)
467 sqp->s_rnr_retry--;
468 spin_lock_irqsave(&sqp->s_lock, flags);
469 if (!(ib_ipath_state_ops[sqp->state] & IPATH_PROCESS_RECV_OK))
470 goto clr_busy;
471 sqp->s_flags |= IPATH_S_WAITING;
472 dev->n_rnr_naks++;
473 sqp->s_rnr_timeout = ib_ipath_rnr_table[qp->r_min_rnr_timer];
474 ipath_insert_rnr_queue(sqp);
475 goto clr_busy;
476
477inv_err:
478 send_status = IB_WC_REM_INV_REQ_ERR;
479 wc.status = IB_WC_LOC_QP_OP_ERR;
480 goto err;
481
482acc_err:
483 send_status = IB_WC_REM_ACCESS_ERR;
484 wc.status = IB_WC_LOC_PROT_ERR;
485err:
486 /* responder goes to error state */
487 ipath_rc_error(qp, wc.status);
488
489serr:
490 spin_lock_irqsave(&sqp->s_lock, flags);
491 ipath_send_complete(sqp, wqe, send_status);
492 if (sqp->ibqp.qp_type == IB_QPT_RC) {
493 int lastwqe = ipath_error_qp(sqp, IB_WC_WR_FLUSH_ERR);
494
495 sqp->s_flags &= ~IPATH_S_BUSY;
496 spin_unlock_irqrestore(&sqp->s_lock, flags);
497 if (lastwqe) {
498 struct ib_event ev;
499
500 ev.device = sqp->ibqp.device;
501 ev.element.qp = &sqp->ibqp;
502 ev.event = IB_EVENT_QP_LAST_WQE_REACHED;
503 sqp->ibqp.event_handler(&ev, sqp->ibqp.qp_context);
504 }
505 goto done;
506 }
507clr_busy:
508 sqp->s_flags &= ~IPATH_S_BUSY;
509unlock:
510 spin_unlock_irqrestore(&sqp->s_lock, flags);
479done: 511done:
480 if (atomic_dec_and_test(&qp->refcount)) 512 if (qp && atomic_dec_and_test(&qp->refcount))
481 wake_up(&qp->wait); 513 wake_up(&qp->wait);
482} 514}
483 515
484static void want_buffer(struct ipath_devdata *dd, struct ipath_qp *qp) 516static void want_buffer(struct ipath_devdata *dd, struct ipath_qp *qp)
485{ 517{
486 if (!(dd->ipath_flags & IPATH_HAS_SEND_DMA) || 518 if (!(dd->ipath_flags & IPATH_HAS_SEND_DMA) ||
487 qp->ibqp.qp_type == IB_QPT_SMI) { 519 qp->ibqp.qp_type == IB_QPT_SMI) {
488 unsigned long flags; 520 unsigned long flags;
489 521
490 spin_lock_irqsave(&dd->ipath_sendctrl_lock, flags); 522 spin_lock_irqsave(&dd->ipath_sendctrl_lock, flags);
@@ -502,26 +534,36 @@ static void want_buffer(struct ipath_devdata *dd, struct ipath_qp *qp)
502 * @dev: the device we ran out of buffers on 534 * @dev: the device we ran out of buffers on
503 * 535 *
504 * Called when we run out of PIO buffers. 536 * Called when we run out of PIO buffers.
537 * If we are now in the error state, return zero to flush the
538 * send work request.
505 */ 539 */
506static void ipath_no_bufs_available(struct ipath_qp *qp, 540static int ipath_no_bufs_available(struct ipath_qp *qp,
507 struct ipath_ibdev *dev) 541 struct ipath_ibdev *dev)
508{ 542{
509 unsigned long flags; 543 unsigned long flags;
544 int ret = 1;
510 545
511 /* 546 /*
512 * Note that as soon as want_buffer() is called and 547 * Note that as soon as want_buffer() is called and
513 * possibly before it returns, ipath_ib_piobufavail() 548 * possibly before it returns, ipath_ib_piobufavail()
514 * could be called. If we are still in the tasklet function, 549 * could be called. Therefore, put QP on the piowait list before
515 * tasklet_hi_schedule() will not call us until the next time 550 * enabling the PIO avail interrupt.
516 * tasklet_hi_schedule() is called.
517 * We leave the busy flag set so that another post send doesn't
518 * try to put the same QP on the piowait list again.
519 */ 551 */
520 spin_lock_irqsave(&dev->pending_lock, flags); 552 spin_lock_irqsave(&qp->s_lock, flags);
521 list_add_tail(&qp->piowait, &dev->piowait); 553 if (ib_ipath_state_ops[qp->state] & IPATH_PROCESS_SEND_OK) {
522 spin_unlock_irqrestore(&dev->pending_lock, flags); 554 dev->n_piowait++;
523 want_buffer(dev->dd, qp); 555 qp->s_flags |= IPATH_S_WAITING;
524 dev->n_piowait++; 556 qp->s_flags &= ~IPATH_S_BUSY;
557 spin_lock(&dev->pending_lock);
558 if (list_empty(&qp->piowait))
559 list_add_tail(&qp->piowait, &dev->piowait);
560 spin_unlock(&dev->pending_lock);
561 } else
562 ret = 0;
563 spin_unlock_irqrestore(&qp->s_lock, flags);
564 if (ret)
565 want_buffer(dev->dd, qp);
566 return ret;
525} 567}
526 568
527/** 569/**
@@ -597,15 +639,13 @@ void ipath_do_send(unsigned long data)
597 struct ipath_qp *qp = (struct ipath_qp *)data; 639 struct ipath_qp *qp = (struct ipath_qp *)data;
598 struct ipath_ibdev *dev = to_idev(qp->ibqp.device); 640 struct ipath_ibdev *dev = to_idev(qp->ibqp.device);
599 int (*make_req)(struct ipath_qp *qp); 641 int (*make_req)(struct ipath_qp *qp);
600 642 unsigned long flags;
601 if (test_and_set_bit(IPATH_S_BUSY, &qp->s_busy))
602 goto bail;
603 643
604 if ((qp->ibqp.qp_type == IB_QPT_RC || 644 if ((qp->ibqp.qp_type == IB_QPT_RC ||
605 qp->ibqp.qp_type == IB_QPT_UC) && 645 qp->ibqp.qp_type == IB_QPT_UC) &&
606 qp->remote_ah_attr.dlid == dev->dd->ipath_lid) { 646 qp->remote_ah_attr.dlid == dev->dd->ipath_lid) {
607 ipath_ruc_loopback(qp); 647 ipath_ruc_loopback(qp);
608 goto clear; 648 goto bail;
609 } 649 }
610 650
611 if (qp->ibqp.qp_type == IB_QPT_RC) 651 if (qp->ibqp.qp_type == IB_QPT_RC)
@@ -615,6 +655,19 @@ void ipath_do_send(unsigned long data)
615 else 655 else
616 make_req = ipath_make_ud_req; 656 make_req = ipath_make_ud_req;
617 657
658 spin_lock_irqsave(&qp->s_lock, flags);
659
660 /* Return if we are already busy processing a work request. */
661 if ((qp->s_flags & (IPATH_S_BUSY | IPATH_S_ANY_WAIT)) ||
662 !(ib_ipath_state_ops[qp->state] & IPATH_PROCESS_OR_FLUSH_SEND)) {
663 spin_unlock_irqrestore(&qp->s_lock, flags);
664 goto bail;
665 }
666
667 qp->s_flags |= IPATH_S_BUSY;
668
669 spin_unlock_irqrestore(&qp->s_lock, flags);
670
618again: 671again:
619 /* Check for a constructed packet to be sent. */ 672 /* Check for a constructed packet to be sent. */
620 if (qp->s_hdrwords != 0) { 673 if (qp->s_hdrwords != 0) {
@@ -624,8 +677,8 @@ again:
624 */ 677 */
625 if (ipath_verbs_send(qp, &qp->s_hdr, qp->s_hdrwords, 678 if (ipath_verbs_send(qp, &qp->s_hdr, qp->s_hdrwords,
626 qp->s_cur_sge, qp->s_cur_size)) { 679 qp->s_cur_sge, qp->s_cur_size)) {
627 ipath_no_bufs_available(qp, dev); 680 if (ipath_no_bufs_available(qp, dev))
628 goto bail; 681 goto bail;
629 } 682 }
630 dev->n_unicast_xmit++; 683 dev->n_unicast_xmit++;
631 /* Record that we sent the packet and s_hdr is empty. */ 684 /* Record that we sent the packet and s_hdr is empty. */
@@ -634,16 +687,20 @@ again:
634 687
635 if (make_req(qp)) 688 if (make_req(qp))
636 goto again; 689 goto again;
637clear: 690
638 clear_bit(IPATH_S_BUSY, &qp->s_busy);
639bail:; 691bail:;
640} 692}
641 693
694/*
695 * This should be called with s_lock held.
696 */
642void ipath_send_complete(struct ipath_qp *qp, struct ipath_swqe *wqe, 697void ipath_send_complete(struct ipath_qp *qp, struct ipath_swqe *wqe,
643 enum ib_wc_status status) 698 enum ib_wc_status status)
644{ 699{
645 unsigned long flags; 700 u32 old_last, last;
646 u32 last; 701
702 if (!(ib_ipath_state_ops[qp->state] & IPATH_PROCESS_OR_FLUSH_SEND))
703 return;
647 704
648 /* See ch. 11.2.4.1 and 10.7.3.1 */ 705 /* See ch. 11.2.4.1 and 10.7.3.1 */
649 if (!(qp->s_flags & IPATH_S_SIGNAL_REQ_WR) || 706 if (!(qp->s_flags & IPATH_S_SIGNAL_REQ_WR) ||
@@ -651,27 +708,25 @@ void ipath_send_complete(struct ipath_qp *qp, struct ipath_swqe *wqe,
651 status != IB_WC_SUCCESS) { 708 status != IB_WC_SUCCESS) {
652 struct ib_wc wc; 709 struct ib_wc wc;
653 710
711 memset(&wc, 0, sizeof wc);
654 wc.wr_id = wqe->wr.wr_id; 712 wc.wr_id = wqe->wr.wr_id;
655 wc.status = status; 713 wc.status = status;
656 wc.opcode = ib_ipath_wc_opcode[wqe->wr.opcode]; 714 wc.opcode = ib_ipath_wc_opcode[wqe->wr.opcode];
657 wc.vendor_err = 0;
658 wc.byte_len = wqe->length;
659 wc.imm_data = 0;
660 wc.qp = &qp->ibqp; 715 wc.qp = &qp->ibqp;
661 wc.src_qp = 0; 716 if (status == IB_WC_SUCCESS)
662 wc.wc_flags = 0; 717 wc.byte_len = wqe->length;
663 wc.pkey_index = 0; 718 ipath_cq_enter(to_icq(qp->ibqp.send_cq), &wc,
664 wc.slid = 0; 719 status != IB_WC_SUCCESS);
665 wc.sl = 0;
666 wc.dlid_path_bits = 0;
667 wc.port_num = 0;
668 ipath_cq_enter(to_icq(qp->ibqp.send_cq), &wc, 0);
669 } 720 }
670 721
671 spin_lock_irqsave(&qp->s_lock, flags); 722 old_last = last = qp->s_last;
672 last = qp->s_last;
673 if (++last >= qp->s_size) 723 if (++last >= qp->s_size)
674 last = 0; 724 last = 0;
675 qp->s_last = last; 725 qp->s_last = last;
676 spin_unlock_irqrestore(&qp->s_lock, flags); 726 if (qp->s_cur == old_last)
727 qp->s_cur = last;
728 if (qp->s_tail == old_last)
729 qp->s_tail = last;
730 if (qp->state == IB_QPS_SQD && last == qp->s_cur)
731 qp->s_draining = 0;
677} 732}
diff --git a/drivers/infiniband/hw/ipath/ipath_uc.c b/drivers/infiniband/hw/ipath/ipath_uc.c
index bfe8926b5514..7fd18e833907 100644
--- a/drivers/infiniband/hw/ipath/ipath_uc.c
+++ b/drivers/infiniband/hw/ipath/ipath_uc.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (c) 2006, 2007 QLogic Corporation. All rights reserved. 2 * Copyright (c) 2006, 2007, 2008 QLogic Corporation. All rights reserved.
3 * Copyright (c) 2005, 2006 PathScale, Inc. All rights reserved. 3 * Copyright (c) 2005, 2006 PathScale, Inc. All rights reserved.
4 * 4 *
5 * This software is available to you under a choice of one of two 5 * This software is available to you under a choice of one of two
@@ -47,14 +47,30 @@ int ipath_make_uc_req(struct ipath_qp *qp)
47{ 47{
48 struct ipath_other_headers *ohdr; 48 struct ipath_other_headers *ohdr;
49 struct ipath_swqe *wqe; 49 struct ipath_swqe *wqe;
50 unsigned long flags;
50 u32 hwords; 51 u32 hwords;
51 u32 bth0; 52 u32 bth0;
52 u32 len; 53 u32 len;
53 u32 pmtu = ib_mtu_enum_to_int(qp->path_mtu); 54 u32 pmtu = ib_mtu_enum_to_int(qp->path_mtu);
54 int ret = 0; 55 int ret = 0;
55 56
56 if (!(ib_ipath_state_ops[qp->state] & IPATH_PROCESS_SEND_OK)) 57 spin_lock_irqsave(&qp->s_lock, flags);
58
59 if (!(ib_ipath_state_ops[qp->state] & IPATH_PROCESS_SEND_OK)) {
60 if (!(ib_ipath_state_ops[qp->state] & IPATH_FLUSH_SEND))
61 goto bail;
62 /* We are in the error state, flush the work request. */
63 if (qp->s_last == qp->s_head)
64 goto bail;
65 /* If DMAs are in progress, we can't flush immediately. */
66 if (atomic_read(&qp->s_dma_busy)) {
67 qp->s_flags |= IPATH_S_WAIT_DMA;
68 goto bail;
69 }
70 wqe = get_swqe_ptr(qp, qp->s_last);
71 ipath_send_complete(qp, wqe, IB_WC_WR_FLUSH_ERR);
57 goto done; 72 goto done;
73 }
58 74
59 ohdr = &qp->s_hdr.u.oth; 75 ohdr = &qp->s_hdr.u.oth;
60 if (qp->remote_ah_attr.ah_flags & IB_AH_GRH) 76 if (qp->remote_ah_attr.ah_flags & IB_AH_GRH)
@@ -69,9 +85,12 @@ int ipath_make_uc_req(struct ipath_qp *qp)
69 qp->s_wqe = NULL; 85 qp->s_wqe = NULL;
70 switch (qp->s_state) { 86 switch (qp->s_state) {
71 default: 87 default:
88 if (!(ib_ipath_state_ops[qp->state] &
89 IPATH_PROCESS_NEXT_SEND_OK))
90 goto bail;
72 /* Check if send work queue is empty. */ 91 /* Check if send work queue is empty. */
73 if (qp->s_cur == qp->s_head) 92 if (qp->s_cur == qp->s_head)
74 goto done; 93 goto bail;
75 /* 94 /*
76 * Start a new request. 95 * Start a new request.
77 */ 96 */
@@ -134,7 +153,7 @@ int ipath_make_uc_req(struct ipath_qp *qp)
134 break; 153 break;
135 154
136 default: 155 default:
137 goto done; 156 goto bail;
138 } 157 }
139 break; 158 break;
140 159
@@ -194,9 +213,14 @@ int ipath_make_uc_req(struct ipath_qp *qp)
194 ipath_make_ruc_header(to_idev(qp->ibqp.device), 213 ipath_make_ruc_header(to_idev(qp->ibqp.device),
195 qp, ohdr, bth0 | (qp->s_state << 24), 214 qp, ohdr, bth0 | (qp->s_state << 24),
196 qp->s_next_psn++ & IPATH_PSN_MASK); 215 qp->s_next_psn++ & IPATH_PSN_MASK);
216done:
197 ret = 1; 217 ret = 1;
218 goto unlock;
198 219
199done: 220bail:
221 qp->s_flags &= ~IPATH_S_BUSY;
222unlock:
223 spin_unlock_irqrestore(&qp->s_lock, flags);
200 return ret; 224 return ret;
201} 225}
202 226
@@ -258,8 +282,7 @@ void ipath_uc_rcv(struct ipath_ibdev *dev, struct ipath_ib_header *hdr,
258 */ 282 */
259 opcode = be32_to_cpu(ohdr->bth[0]) >> 24; 283 opcode = be32_to_cpu(ohdr->bth[0]) >> 24;
260 284
261 wc.imm_data = 0; 285 memset(&wc, 0, sizeof wc);
262 wc.wc_flags = 0;
263 286
264 /* Compare the PSN verses the expected PSN. */ 287 /* Compare the PSN verses the expected PSN. */
265 if (unlikely(ipath_cmp24(psn, qp->r_psn) != 0)) { 288 if (unlikely(ipath_cmp24(psn, qp->r_psn) != 0)) {
@@ -322,8 +345,8 @@ void ipath_uc_rcv(struct ipath_ibdev *dev, struct ipath_ib_header *hdr,
322 case OP(SEND_ONLY): 345 case OP(SEND_ONLY):
323 case OP(SEND_ONLY_WITH_IMMEDIATE): 346 case OP(SEND_ONLY_WITH_IMMEDIATE):
324 send_first: 347 send_first:
325 if (qp->r_reuse_sge) { 348 if (qp->r_flags & IPATH_R_REUSE_SGE) {
326 qp->r_reuse_sge = 0; 349 qp->r_flags &= ~IPATH_R_REUSE_SGE;
327 qp->r_sge = qp->s_rdma_read_sge; 350 qp->r_sge = qp->s_rdma_read_sge;
328 } else if (!ipath_get_rwqe(qp, 0)) { 351 } else if (!ipath_get_rwqe(qp, 0)) {
329 dev->n_pkt_drops++; 352 dev->n_pkt_drops++;
@@ -340,13 +363,13 @@ void ipath_uc_rcv(struct ipath_ibdev *dev, struct ipath_ib_header *hdr,
340 case OP(SEND_MIDDLE): 363 case OP(SEND_MIDDLE):
341 /* Check for invalid length PMTU or posted rwqe len. */ 364 /* Check for invalid length PMTU or posted rwqe len. */
342 if (unlikely(tlen != (hdrsize + pmtu + 4))) { 365 if (unlikely(tlen != (hdrsize + pmtu + 4))) {
343 qp->r_reuse_sge = 1; 366 qp->r_flags |= IPATH_R_REUSE_SGE;
344 dev->n_pkt_drops++; 367 dev->n_pkt_drops++;
345 goto done; 368 goto done;
346 } 369 }
347 qp->r_rcv_len += pmtu; 370 qp->r_rcv_len += pmtu;
348 if (unlikely(qp->r_rcv_len > qp->r_len)) { 371 if (unlikely(qp->r_rcv_len > qp->r_len)) {
349 qp->r_reuse_sge = 1; 372 qp->r_flags |= IPATH_R_REUSE_SGE;
350 dev->n_pkt_drops++; 373 dev->n_pkt_drops++;
351 goto done; 374 goto done;
352 } 375 }
@@ -372,7 +395,7 @@ void ipath_uc_rcv(struct ipath_ibdev *dev, struct ipath_ib_header *hdr,
372 /* Check for invalid length. */ 395 /* Check for invalid length. */
373 /* XXX LAST len should be >= 1 */ 396 /* XXX LAST len should be >= 1 */
374 if (unlikely(tlen < (hdrsize + pad + 4))) { 397 if (unlikely(tlen < (hdrsize + pad + 4))) {
375 qp->r_reuse_sge = 1; 398 qp->r_flags |= IPATH_R_REUSE_SGE;
376 dev->n_pkt_drops++; 399 dev->n_pkt_drops++;
377 goto done; 400 goto done;
378 } 401 }
@@ -380,7 +403,7 @@ void ipath_uc_rcv(struct ipath_ibdev *dev, struct ipath_ib_header *hdr,
380 tlen -= (hdrsize + pad + 4); 403 tlen -= (hdrsize + pad + 4);
381 wc.byte_len = tlen + qp->r_rcv_len; 404 wc.byte_len = tlen + qp->r_rcv_len;
382 if (unlikely(wc.byte_len > qp->r_len)) { 405 if (unlikely(wc.byte_len > qp->r_len)) {
383 qp->r_reuse_sge = 1; 406 qp->r_flags |= IPATH_R_REUSE_SGE;
384 dev->n_pkt_drops++; 407 dev->n_pkt_drops++;
385 goto done; 408 goto done;
386 } 409 }
@@ -390,14 +413,10 @@ void ipath_uc_rcv(struct ipath_ibdev *dev, struct ipath_ib_header *hdr,
390 wc.wr_id = qp->r_wr_id; 413 wc.wr_id = qp->r_wr_id;
391 wc.status = IB_WC_SUCCESS; 414 wc.status = IB_WC_SUCCESS;
392 wc.opcode = IB_WC_RECV; 415 wc.opcode = IB_WC_RECV;
393 wc.vendor_err = 0;
394 wc.qp = &qp->ibqp; 416 wc.qp = &qp->ibqp;
395 wc.src_qp = qp->remote_qpn; 417 wc.src_qp = qp->remote_qpn;
396 wc.pkey_index = 0;
397 wc.slid = qp->remote_ah_attr.dlid; 418 wc.slid = qp->remote_ah_attr.dlid;
398 wc.sl = qp->remote_ah_attr.sl; 419 wc.sl = qp->remote_ah_attr.sl;
399 wc.dlid_path_bits = 0;
400 wc.port_num = 0;
401 /* Signal completion event if the solicited bit is set. */ 420 /* Signal completion event if the solicited bit is set. */
402 ipath_cq_enter(to_icq(qp->ibqp.recv_cq), &wc, 421 ipath_cq_enter(to_icq(qp->ibqp.recv_cq), &wc,
403 (ohdr->bth[0] & 422 (ohdr->bth[0] &
@@ -488,8 +507,8 @@ void ipath_uc_rcv(struct ipath_ibdev *dev, struct ipath_ib_header *hdr,
488 dev->n_pkt_drops++; 507 dev->n_pkt_drops++;
489 goto done; 508 goto done;
490 } 509 }
491 if (qp->r_reuse_sge) 510 if (qp->r_flags & IPATH_R_REUSE_SGE)
492 qp->r_reuse_sge = 0; 511 qp->r_flags &= ~IPATH_R_REUSE_SGE;
493 else if (!ipath_get_rwqe(qp, 1)) { 512 else if (!ipath_get_rwqe(qp, 1)) {
494 dev->n_pkt_drops++; 513 dev->n_pkt_drops++;
495 goto done; 514 goto done;
diff --git a/drivers/infiniband/hw/ipath/ipath_ud.c b/drivers/infiniband/hw/ipath/ipath_ud.c
index 8b6a261c89e3..77ca8ca74e78 100644
--- a/drivers/infiniband/hw/ipath/ipath_ud.c
+++ b/drivers/infiniband/hw/ipath/ipath_ud.c
@@ -65,9 +65,9 @@ static void ipath_ud_loopback(struct ipath_qp *sqp, struct ipath_swqe *swqe)
65 u32 length; 65 u32 length;
66 66
67 qp = ipath_lookup_qpn(&dev->qp_table, swqe->wr.wr.ud.remote_qpn); 67 qp = ipath_lookup_qpn(&dev->qp_table, swqe->wr.wr.ud.remote_qpn);
68 if (!qp) { 68 if (!qp || !(ib_ipath_state_ops[qp->state] & IPATH_PROCESS_RECV_OK)) {
69 dev->n_pkt_drops++; 69 dev->n_pkt_drops++;
70 goto send_comp; 70 goto done;
71 } 71 }
72 72
73 rsge.sg_list = NULL; 73 rsge.sg_list = NULL;
@@ -91,14 +91,12 @@ static void ipath_ud_loopback(struct ipath_qp *sqp, struct ipath_swqe *swqe)
91 * present on the wire. 91 * present on the wire.
92 */ 92 */
93 length = swqe->length; 93 length = swqe->length;
94 memset(&wc, 0, sizeof wc);
94 wc.byte_len = length + sizeof(struct ib_grh); 95 wc.byte_len = length + sizeof(struct ib_grh);
95 96
96 if (swqe->wr.opcode == IB_WR_SEND_WITH_IMM) { 97 if (swqe->wr.opcode == IB_WR_SEND_WITH_IMM) {
97 wc.wc_flags = IB_WC_WITH_IMM; 98 wc.wc_flags = IB_WC_WITH_IMM;
98 wc.imm_data = swqe->wr.ex.imm_data; 99 wc.imm_data = swqe->wr.ex.imm_data;
99 } else {
100 wc.wc_flags = 0;
101 wc.imm_data = 0;
102 } 100 }
103 101
104 /* 102 /*
@@ -229,7 +227,6 @@ static void ipath_ud_loopback(struct ipath_qp *sqp, struct ipath_swqe *swqe)
229 } 227 }
230 wc.status = IB_WC_SUCCESS; 228 wc.status = IB_WC_SUCCESS;
231 wc.opcode = IB_WC_RECV; 229 wc.opcode = IB_WC_RECV;
232 wc.vendor_err = 0;
233 wc.qp = &qp->ibqp; 230 wc.qp = &qp->ibqp;
234 wc.src_qp = sqp->ibqp.qp_num; 231 wc.src_qp = sqp->ibqp.qp_num;
235 /* XXX do we know which pkey matched? Only needed for GSI. */ 232 /* XXX do we know which pkey matched? Only needed for GSI. */
@@ -248,8 +245,7 @@ drop:
248 kfree(rsge.sg_list); 245 kfree(rsge.sg_list);
249 if (atomic_dec_and_test(&qp->refcount)) 246 if (atomic_dec_and_test(&qp->refcount))
250 wake_up(&qp->wait); 247 wake_up(&qp->wait);
251send_comp: 248done:;
252 ipath_send_complete(sqp, swqe, IB_WC_SUCCESS);
253} 249}
254 250
255/** 251/**
@@ -264,6 +260,7 @@ int ipath_make_ud_req(struct ipath_qp *qp)
264 struct ipath_other_headers *ohdr; 260 struct ipath_other_headers *ohdr;
265 struct ib_ah_attr *ah_attr; 261 struct ib_ah_attr *ah_attr;
266 struct ipath_swqe *wqe; 262 struct ipath_swqe *wqe;
263 unsigned long flags;
267 u32 nwords; 264 u32 nwords;
268 u32 extra_bytes; 265 u32 extra_bytes;
269 u32 bth0; 266 u32 bth0;
@@ -271,13 +268,30 @@ int ipath_make_ud_req(struct ipath_qp *qp)
271 u16 lid; 268 u16 lid;
272 int ret = 0; 269 int ret = 0;
273 270
274 if (unlikely(!(ib_ipath_state_ops[qp->state] & IPATH_PROCESS_SEND_OK))) 271 spin_lock_irqsave(&qp->s_lock, flags);
275 goto bail; 272
273 if (!(ib_ipath_state_ops[qp->state] & IPATH_PROCESS_NEXT_SEND_OK)) {
274 if (!(ib_ipath_state_ops[qp->state] & IPATH_FLUSH_SEND))
275 goto bail;
276 /* We are in the error state, flush the work request. */
277 if (qp->s_last == qp->s_head)
278 goto bail;
279 /* If DMAs are in progress, we can't flush immediately. */
280 if (atomic_read(&qp->s_dma_busy)) {
281 qp->s_flags |= IPATH_S_WAIT_DMA;
282 goto bail;
283 }
284 wqe = get_swqe_ptr(qp, qp->s_last);
285 ipath_send_complete(qp, wqe, IB_WC_WR_FLUSH_ERR);
286 goto done;
287 }
276 288
277 if (qp->s_cur == qp->s_head) 289 if (qp->s_cur == qp->s_head)
278 goto bail; 290 goto bail;
279 291
280 wqe = get_swqe_ptr(qp, qp->s_cur); 292 wqe = get_swqe_ptr(qp, qp->s_cur);
293 if (++qp->s_cur >= qp->s_size)
294 qp->s_cur = 0;
281 295
282 /* Construct the header. */ 296 /* Construct the header. */
283 ah_attr = &to_iah(wqe->wr.wr.ud.ah)->attr; 297 ah_attr = &to_iah(wqe->wr.wr.ud.ah)->attr;
@@ -288,10 +302,23 @@ int ipath_make_ud_req(struct ipath_qp *qp)
288 dev->n_unicast_xmit++; 302 dev->n_unicast_xmit++;
289 } else { 303 } else {
290 dev->n_unicast_xmit++; 304 dev->n_unicast_xmit++;
291 lid = ah_attr->dlid & 305 lid = ah_attr->dlid & ~((1 << dev->dd->ipath_lmc) - 1);
292 ~((1 << dev->dd->ipath_lmc) - 1);
293 if (unlikely(lid == dev->dd->ipath_lid)) { 306 if (unlikely(lid == dev->dd->ipath_lid)) {
307 /*
308 * If DMAs are in progress, we can't generate
309 * a completion for the loopback packet since
310 * it would be out of order.
311 * XXX Instead of waiting, we could queue a
312 * zero length descriptor so we get a callback.
313 */
314 if (atomic_read(&qp->s_dma_busy)) {
315 qp->s_flags |= IPATH_S_WAIT_DMA;
316 goto bail;
317 }
318 spin_unlock_irqrestore(&qp->s_lock, flags);
294 ipath_ud_loopback(qp, wqe); 319 ipath_ud_loopback(qp, wqe);
320 spin_lock_irqsave(&qp->s_lock, flags);
321 ipath_send_complete(qp, wqe, IB_WC_SUCCESS);
295 goto done; 322 goto done;
296 } 323 }
297 } 324 }
@@ -368,11 +395,13 @@ int ipath_make_ud_req(struct ipath_qp *qp)
368 ohdr->u.ud.deth[1] = cpu_to_be32(qp->ibqp.qp_num); 395 ohdr->u.ud.deth[1] = cpu_to_be32(qp->ibqp.qp_num);
369 396
370done: 397done:
371 if (++qp->s_cur >= qp->s_size)
372 qp->s_cur = 0;
373 ret = 1; 398 ret = 1;
399 goto unlock;
374 400
375bail: 401bail:
402 qp->s_flags &= ~IPATH_S_BUSY;
403unlock:
404 spin_unlock_irqrestore(&qp->s_lock, flags);
376 return ret; 405 return ret;
377} 406}
378 407
@@ -506,8 +535,8 @@ void ipath_ud_rcv(struct ipath_ibdev *dev, struct ipath_ib_header *hdr,
506 /* 535 /*
507 * Get the next work request entry to find where to put the data. 536 * Get the next work request entry to find where to put the data.
508 */ 537 */
509 if (qp->r_reuse_sge) 538 if (qp->r_flags & IPATH_R_REUSE_SGE)
510 qp->r_reuse_sge = 0; 539 qp->r_flags &= ~IPATH_R_REUSE_SGE;
511 else if (!ipath_get_rwqe(qp, 0)) { 540 else if (!ipath_get_rwqe(qp, 0)) {
512 /* 541 /*
513 * Count VL15 packets dropped due to no receive buffer. 542 * Count VL15 packets dropped due to no receive buffer.
@@ -523,7 +552,7 @@ void ipath_ud_rcv(struct ipath_ibdev *dev, struct ipath_ib_header *hdr,
523 } 552 }
524 /* Silently drop packets which are too big. */ 553 /* Silently drop packets which are too big. */
525 if (wc.byte_len > qp->r_len) { 554 if (wc.byte_len > qp->r_len) {
526 qp->r_reuse_sge = 1; 555 qp->r_flags |= IPATH_R_REUSE_SGE;
527 dev->n_pkt_drops++; 556 dev->n_pkt_drops++;
528 goto bail; 557 goto bail;
529 } 558 }
@@ -535,7 +564,8 @@ void ipath_ud_rcv(struct ipath_ibdev *dev, struct ipath_ib_header *hdr,
535 ipath_skip_sge(&qp->r_sge, sizeof(struct ib_grh)); 564 ipath_skip_sge(&qp->r_sge, sizeof(struct ib_grh));
536 ipath_copy_sge(&qp->r_sge, data, 565 ipath_copy_sge(&qp->r_sge, data,
537 wc.byte_len - sizeof(struct ib_grh)); 566 wc.byte_len - sizeof(struct ib_grh));
538 qp->r_wrid_valid = 0; 567 if (!test_and_clear_bit(IPATH_R_WRID_VALID, &qp->r_aflags))
568 goto bail;
539 wc.wr_id = qp->r_wr_id; 569 wc.wr_id = qp->r_wr_id;
540 wc.status = IB_WC_SUCCESS; 570 wc.status = IB_WC_SUCCESS;
541 wc.opcode = IB_WC_RECV; 571 wc.opcode = IB_WC_RECV;
diff --git a/drivers/infiniband/hw/ipath/ipath_user_sdma.h b/drivers/infiniband/hw/ipath/ipath_user_sdma.h
index e70946c1428c..fc76316c4a58 100644
--- a/drivers/infiniband/hw/ipath/ipath_user_sdma.h
+++ b/drivers/infiniband/hw/ipath/ipath_user_sdma.h
@@ -45,8 +45,6 @@ int ipath_user_sdma_writev(struct ipath_devdata *dd,
45int ipath_user_sdma_make_progress(struct ipath_devdata *dd, 45int ipath_user_sdma_make_progress(struct ipath_devdata *dd,
46 struct ipath_user_sdma_queue *pq); 46 struct ipath_user_sdma_queue *pq);
47 47
48int ipath_user_sdma_pkt_sent(const struct ipath_user_sdma_queue *pq,
49 u32 counter);
50void ipath_user_sdma_queue_drain(struct ipath_devdata *dd, 48void ipath_user_sdma_queue_drain(struct ipath_devdata *dd,
51 struct ipath_user_sdma_queue *pq); 49 struct ipath_user_sdma_queue *pq);
52 50
diff --git a/drivers/infiniband/hw/ipath/ipath_verbs.c b/drivers/infiniband/hw/ipath/ipath_verbs.c
index 5015cd2e57bd..e0ec540042bf 100644
--- a/drivers/infiniband/hw/ipath/ipath_verbs.c
+++ b/drivers/infiniband/hw/ipath/ipath_verbs.c
@@ -111,16 +111,24 @@ static unsigned int ib_ipath_disable_sma;
111module_param_named(disable_sma, ib_ipath_disable_sma, uint, S_IWUSR | S_IRUGO); 111module_param_named(disable_sma, ib_ipath_disable_sma, uint, S_IWUSR | S_IRUGO);
112MODULE_PARM_DESC(disable_sma, "Disable the SMA"); 112MODULE_PARM_DESC(disable_sma, "Disable the SMA");
113 113
114/*
115 * Note that it is OK to post send work requests in the SQE and ERR
116 * states; ipath_do_send() will process them and generate error
117 * completions as per IB 1.2 C10-96.
118 */
114const int ib_ipath_state_ops[IB_QPS_ERR + 1] = { 119const int ib_ipath_state_ops[IB_QPS_ERR + 1] = {
115 [IB_QPS_RESET] = 0, 120 [IB_QPS_RESET] = 0,
116 [IB_QPS_INIT] = IPATH_POST_RECV_OK, 121 [IB_QPS_INIT] = IPATH_POST_RECV_OK,
117 [IB_QPS_RTR] = IPATH_POST_RECV_OK | IPATH_PROCESS_RECV_OK, 122 [IB_QPS_RTR] = IPATH_POST_RECV_OK | IPATH_PROCESS_RECV_OK,
118 [IB_QPS_RTS] = IPATH_POST_RECV_OK | IPATH_PROCESS_RECV_OK | 123 [IB_QPS_RTS] = IPATH_POST_RECV_OK | IPATH_PROCESS_RECV_OK |
119 IPATH_POST_SEND_OK | IPATH_PROCESS_SEND_OK, 124 IPATH_POST_SEND_OK | IPATH_PROCESS_SEND_OK |
125 IPATH_PROCESS_NEXT_SEND_OK,
120 [IB_QPS_SQD] = IPATH_POST_RECV_OK | IPATH_PROCESS_RECV_OK | 126 [IB_QPS_SQD] = IPATH_POST_RECV_OK | IPATH_PROCESS_RECV_OK |
121 IPATH_POST_SEND_OK, 127 IPATH_POST_SEND_OK | IPATH_PROCESS_SEND_OK,
122 [IB_QPS_SQE] = IPATH_POST_RECV_OK | IPATH_PROCESS_RECV_OK, 128 [IB_QPS_SQE] = IPATH_POST_RECV_OK | IPATH_PROCESS_RECV_OK |
123 [IB_QPS_ERR] = 0, 129 IPATH_POST_SEND_OK | IPATH_FLUSH_SEND,
130 [IB_QPS_ERR] = IPATH_POST_RECV_OK | IPATH_FLUSH_RECV |
131 IPATH_POST_SEND_OK | IPATH_FLUSH_SEND,
124}; 132};
125 133
126struct ipath_ucontext { 134struct ipath_ucontext {
@@ -230,18 +238,6 @@ void ipath_skip_sge(struct ipath_sge_state *ss, u32 length)
230 } 238 }
231} 239}
232 240
233static void ipath_flush_wqe(struct ipath_qp *qp, struct ib_send_wr *wr)
234{
235 struct ib_wc wc;
236
237 memset(&wc, 0, sizeof(wc));
238 wc.wr_id = wr->wr_id;
239 wc.status = IB_WC_WR_FLUSH_ERR;
240 wc.opcode = ib_ipath_wc_opcode[wr->opcode];
241 wc.qp = &qp->ibqp;
242 ipath_cq_enter(to_icq(qp->ibqp.send_cq), &wc, 1);
243}
244
245/* 241/*
246 * Count the number of DMA descriptors needed to send length bytes of data. 242 * Count the number of DMA descriptors needed to send length bytes of data.
247 * Don't modify the ipath_sge_state to get the count. 243 * Don't modify the ipath_sge_state to get the count.
@@ -347,14 +343,8 @@ static int ipath_post_one_send(struct ipath_qp *qp, struct ib_send_wr *wr)
347 spin_lock_irqsave(&qp->s_lock, flags); 343 spin_lock_irqsave(&qp->s_lock, flags);
348 344
349 /* Check that state is OK to post send. */ 345 /* Check that state is OK to post send. */
350 if (unlikely(!(ib_ipath_state_ops[qp->state] & IPATH_POST_SEND_OK))) { 346 if (unlikely(!(ib_ipath_state_ops[qp->state] & IPATH_POST_SEND_OK)))
351 if (qp->state != IB_QPS_SQE && qp->state != IB_QPS_ERR) 347 goto bail_inval;
352 goto bail_inval;
353 /* C10-96 says generate a flushed completion entry. */
354 ipath_flush_wqe(qp, wr);
355 ret = 0;
356 goto bail;
357 }
358 348
359 /* IB spec says that num_sge == 0 is OK. */ 349 /* IB spec says that num_sge == 0 is OK. */
360 if (wr->num_sge > qp->s_max_sge) 350 if (wr->num_sge > qp->s_max_sge)
@@ -677,6 +667,7 @@ bail:;
677static void ipath_ib_timer(struct ipath_ibdev *dev) 667static void ipath_ib_timer(struct ipath_ibdev *dev)
678{ 668{
679 struct ipath_qp *resend = NULL; 669 struct ipath_qp *resend = NULL;
670 struct ipath_qp *rnr = NULL;
680 struct list_head *last; 671 struct list_head *last;
681 struct ipath_qp *qp; 672 struct ipath_qp *qp;
682 unsigned long flags; 673 unsigned long flags;
@@ -703,7 +694,9 @@ static void ipath_ib_timer(struct ipath_ibdev *dev)
703 if (--qp->s_rnr_timeout == 0) { 694 if (--qp->s_rnr_timeout == 0) {
704 do { 695 do {
705 list_del_init(&qp->timerwait); 696 list_del_init(&qp->timerwait);
706 tasklet_hi_schedule(&qp->s_task); 697 qp->timer_next = rnr;
698 rnr = qp;
699 atomic_inc(&qp->refcount);
707 if (list_empty(last)) 700 if (list_empty(last))
708 break; 701 break;
709 qp = list_entry(last->next, struct ipath_qp, 702 qp = list_entry(last->next, struct ipath_qp,
@@ -743,13 +736,15 @@ static void ipath_ib_timer(struct ipath_ibdev *dev)
743 spin_unlock_irqrestore(&dev->pending_lock, flags); 736 spin_unlock_irqrestore(&dev->pending_lock, flags);
744 737
745 /* XXX What if timer fires again while this is running? */ 738 /* XXX What if timer fires again while this is running? */
746 for (qp = resend; qp != NULL; qp = qp->timer_next) { 739 while (resend != NULL) {
747 struct ib_wc wc; 740 qp = resend;
741 resend = qp->timer_next;
748 742
749 spin_lock_irqsave(&qp->s_lock, flags); 743 spin_lock_irqsave(&qp->s_lock, flags);
750 if (qp->s_last != qp->s_tail && qp->state == IB_QPS_RTS) { 744 if (qp->s_last != qp->s_tail &&
745 ib_ipath_state_ops[qp->state] & IPATH_PROCESS_SEND_OK) {
751 dev->n_timeouts++; 746 dev->n_timeouts++;
752 ipath_restart_rc(qp, qp->s_last_psn + 1, &wc); 747 ipath_restart_rc(qp, qp->s_last_psn + 1);
753 } 748 }
754 spin_unlock_irqrestore(&qp->s_lock, flags); 749 spin_unlock_irqrestore(&qp->s_lock, flags);
755 750
@@ -757,6 +752,19 @@ static void ipath_ib_timer(struct ipath_ibdev *dev)
757 if (atomic_dec_and_test(&qp->refcount)) 752 if (atomic_dec_and_test(&qp->refcount))
758 wake_up(&qp->wait); 753 wake_up(&qp->wait);
759 } 754 }
755 while (rnr != NULL) {
756 qp = rnr;
757 rnr = qp->timer_next;
758
759 spin_lock_irqsave(&qp->s_lock, flags);
760 if (ib_ipath_state_ops[qp->state] & IPATH_PROCESS_SEND_OK)
761 ipath_schedule_send(qp);
762 spin_unlock_irqrestore(&qp->s_lock, flags);
763
764 /* Notify ipath_destroy_qp() if it is waiting. */
765 if (atomic_dec_and_test(&qp->refcount))
766 wake_up(&qp->wait);
767 }
760} 768}
761 769
762static void update_sge(struct ipath_sge_state *ss, u32 length) 770static void update_sge(struct ipath_sge_state *ss, u32 length)
@@ -1012,13 +1020,24 @@ static void sdma_complete(void *cookie, int status)
1012 struct ipath_verbs_txreq *tx = cookie; 1020 struct ipath_verbs_txreq *tx = cookie;
1013 struct ipath_qp *qp = tx->qp; 1021 struct ipath_qp *qp = tx->qp;
1014 struct ipath_ibdev *dev = to_idev(qp->ibqp.device); 1022 struct ipath_ibdev *dev = to_idev(qp->ibqp.device);
1023 unsigned int flags;
1024 enum ib_wc_status ibs = status == IPATH_SDMA_TXREQ_S_OK ?
1025 IB_WC_SUCCESS : IB_WC_WR_FLUSH_ERR;
1015 1026
1016 /* Generate a completion queue entry if needed */ 1027 if (atomic_dec_and_test(&qp->s_dma_busy)) {
1017 if (qp->ibqp.qp_type != IB_QPT_RC && tx->wqe) { 1028 spin_lock_irqsave(&qp->s_lock, flags);
1018 enum ib_wc_status ibs = status == IPATH_SDMA_TXREQ_S_OK ? 1029 if (tx->wqe)
1019 IB_WC_SUCCESS : IB_WC_WR_FLUSH_ERR; 1030 ipath_send_complete(qp, tx->wqe, ibs);
1020 1031 if ((ib_ipath_state_ops[qp->state] & IPATH_FLUSH_SEND &&
1032 qp->s_last != qp->s_head) ||
1033 (qp->s_flags & IPATH_S_WAIT_DMA))
1034 ipath_schedule_send(qp);
1035 spin_unlock_irqrestore(&qp->s_lock, flags);
1036 wake_up(&qp->wait_dma);
1037 } else if (tx->wqe) {
1038 spin_lock_irqsave(&qp->s_lock, flags);
1021 ipath_send_complete(qp, tx->wqe, ibs); 1039 ipath_send_complete(qp, tx->wqe, ibs);
1040 spin_unlock_irqrestore(&qp->s_lock, flags);
1022 } 1041 }
1023 1042
1024 if (tx->txreq.flags & IPATH_SDMA_TXREQ_F_FREEBUF) 1043 if (tx->txreq.flags & IPATH_SDMA_TXREQ_F_FREEBUF)
@@ -1029,6 +1048,21 @@ static void sdma_complete(void *cookie, int status)
1029 wake_up(&qp->wait); 1048 wake_up(&qp->wait);
1030} 1049}
1031 1050
1051static void decrement_dma_busy(struct ipath_qp *qp)
1052{
1053 unsigned int flags;
1054
1055 if (atomic_dec_and_test(&qp->s_dma_busy)) {
1056 spin_lock_irqsave(&qp->s_lock, flags);
1057 if ((ib_ipath_state_ops[qp->state] & IPATH_FLUSH_SEND &&
1058 qp->s_last != qp->s_head) ||
1059 (qp->s_flags & IPATH_S_WAIT_DMA))
1060 ipath_schedule_send(qp);
1061 spin_unlock_irqrestore(&qp->s_lock, flags);
1062 wake_up(&qp->wait_dma);
1063 }
1064}
1065
1032/* 1066/*
1033 * Compute the number of clock cycles of delay before sending the next packet. 1067 * Compute the number of clock cycles of delay before sending the next packet.
1034 * The multipliers reflect the number of clocks for the fastest rate so 1068 * The multipliers reflect the number of clocks for the fastest rate so
@@ -1067,9 +1101,12 @@ static int ipath_verbs_send_dma(struct ipath_qp *qp,
1067 if (tx) { 1101 if (tx) {
1068 qp->s_tx = NULL; 1102 qp->s_tx = NULL;
1069 /* resend previously constructed packet */ 1103 /* resend previously constructed packet */
1104 atomic_inc(&qp->s_dma_busy);
1070 ret = ipath_sdma_verbs_send(dd, tx->ss, tx->len, tx); 1105 ret = ipath_sdma_verbs_send(dd, tx->ss, tx->len, tx);
1071 if (ret) 1106 if (ret) {
1072 qp->s_tx = tx; 1107 qp->s_tx = tx;
1108 decrement_dma_busy(qp);
1109 }
1073 goto bail; 1110 goto bail;
1074 } 1111 }
1075 1112
@@ -1120,12 +1157,14 @@ static int ipath_verbs_send_dma(struct ipath_qp *qp,
1120 tx->txreq.sg_count = ndesc; 1157 tx->txreq.sg_count = ndesc;
1121 tx->map_len = (hdrwords + 2) << 2; 1158 tx->map_len = (hdrwords + 2) << 2;
1122 tx->txreq.map_addr = &tx->hdr; 1159 tx->txreq.map_addr = &tx->hdr;
1160 atomic_inc(&qp->s_dma_busy);
1123 ret = ipath_sdma_verbs_send(dd, ss, dwords, tx); 1161 ret = ipath_sdma_verbs_send(dd, ss, dwords, tx);
1124 if (ret) { 1162 if (ret) {
1125 /* save ss and length in dwords */ 1163 /* save ss and length in dwords */
1126 tx->ss = ss; 1164 tx->ss = ss;
1127 tx->len = dwords; 1165 tx->len = dwords;
1128 qp->s_tx = tx; 1166 qp->s_tx = tx;
1167 decrement_dma_busy(qp);
1129 } 1168 }
1130 goto bail; 1169 goto bail;
1131 } 1170 }
@@ -1146,6 +1185,7 @@ static int ipath_verbs_send_dma(struct ipath_qp *qp,
1146 memcpy(piobuf, hdr, hdrwords << 2); 1185 memcpy(piobuf, hdr, hdrwords << 2);
1147 ipath_copy_from_sge(piobuf + hdrwords, ss, len); 1186 ipath_copy_from_sge(piobuf + hdrwords, ss, len);
1148 1187
1188 atomic_inc(&qp->s_dma_busy);
1149 ret = ipath_sdma_verbs_send(dd, NULL, 0, tx); 1189 ret = ipath_sdma_verbs_send(dd, NULL, 0, tx);
1150 /* 1190 /*
1151 * If we couldn't queue the DMA request, save the info 1191 * If we couldn't queue the DMA request, save the info
@@ -1156,6 +1196,7 @@ static int ipath_verbs_send_dma(struct ipath_qp *qp,
1156 tx->ss = NULL; 1196 tx->ss = NULL;
1157 tx->len = 0; 1197 tx->len = 0;
1158 qp->s_tx = tx; 1198 qp->s_tx = tx;
1199 decrement_dma_busy(qp);
1159 } 1200 }
1160 dev->n_unaligned++; 1201 dev->n_unaligned++;
1161 goto bail; 1202 goto bail;
@@ -1179,6 +1220,7 @@ static int ipath_verbs_send_pio(struct ipath_qp *qp,
1179 unsigned flush_wc; 1220 unsigned flush_wc;
1180 u32 control; 1221 u32 control;
1181 int ret; 1222 int ret;
1223 unsigned int flags;
1182 1224
1183 piobuf = ipath_getpiobuf(dd, plen, NULL); 1225 piobuf = ipath_getpiobuf(dd, plen, NULL);
1184 if (unlikely(piobuf == NULL)) { 1226 if (unlikely(piobuf == NULL)) {
@@ -1249,8 +1291,11 @@ static int ipath_verbs_send_pio(struct ipath_qp *qp,
1249 } 1291 }
1250 copy_io(piobuf, ss, len, flush_wc); 1292 copy_io(piobuf, ss, len, flush_wc);
1251done: 1293done:
1252 if (qp->s_wqe) 1294 if (qp->s_wqe) {
1295 spin_lock_irqsave(&qp->s_lock, flags);
1253 ipath_send_complete(qp, qp->s_wqe, IB_WC_SUCCESS); 1296 ipath_send_complete(qp, qp->s_wqe, IB_WC_SUCCESS);
1297 spin_unlock_irqrestore(&qp->s_lock, flags);
1298 }
1254 ret = 0; 1299 ret = 0;
1255bail: 1300bail:
1256 return ret; 1301 return ret;
@@ -1283,19 +1328,12 @@ int ipath_verbs_send(struct ipath_qp *qp, struct ipath_ib_header *hdr,
1283 * can defer SDMA restart until link goes ACTIVE without 1328 * can defer SDMA restart until link goes ACTIVE without
1284 * worrying about just how we got there. 1329 * worrying about just how we got there.
1285 */ 1330 */
1286 if (qp->ibqp.qp_type == IB_QPT_SMI) 1331 if (qp->ibqp.qp_type == IB_QPT_SMI ||
1332 !(dd->ipath_flags & IPATH_HAS_SEND_DMA))
1287 ret = ipath_verbs_send_pio(qp, hdr, hdrwords, ss, len, 1333 ret = ipath_verbs_send_pio(qp, hdr, hdrwords, ss, len,
1288 plen, dwords); 1334 plen, dwords);
1289 /* All non-VL15 packets are dropped if link is not ACTIVE */
1290 else if (!(dd->ipath_flags & IPATH_LINKACTIVE)) {
1291 if (qp->s_wqe)
1292 ipath_send_complete(qp, qp->s_wqe, IB_WC_SUCCESS);
1293 ret = 0;
1294 } else if (dd->ipath_flags & IPATH_HAS_SEND_DMA)
1295 ret = ipath_verbs_send_dma(qp, hdr, hdrwords, ss, len,
1296 plen, dwords);
1297 else 1335 else
1298 ret = ipath_verbs_send_pio(qp, hdr, hdrwords, ss, len, 1336 ret = ipath_verbs_send_dma(qp, hdr, hdrwords, ss, len,
1299 plen, dwords); 1337 plen, dwords);
1300 1338
1301 return ret; 1339 return ret;
@@ -1403,27 +1441,46 @@ bail:
1403 * This is called from ipath_intr() at interrupt level when a PIO buffer is 1441 * This is called from ipath_intr() at interrupt level when a PIO buffer is
1404 * available after ipath_verbs_send() returned an error that no buffers were 1442 * available after ipath_verbs_send() returned an error that no buffers were
1405 * available. Return 1 if we consumed all the PIO buffers and we still have 1443 * available. Return 1 if we consumed all the PIO buffers and we still have
1406 * QPs waiting for buffers (for now, just do a tasklet_hi_schedule and 1444 * QPs waiting for buffers (for now, just restart the send tasklet and
1407 * return zero). 1445 * return zero).
1408 */ 1446 */
1409int ipath_ib_piobufavail(struct ipath_ibdev *dev) 1447int ipath_ib_piobufavail(struct ipath_ibdev *dev)
1410{ 1448{
1449 struct list_head *list;
1450 struct ipath_qp *qplist;
1411 struct ipath_qp *qp; 1451 struct ipath_qp *qp;
1412 unsigned long flags; 1452 unsigned long flags;
1413 1453
1414 if (dev == NULL) 1454 if (dev == NULL)
1415 goto bail; 1455 goto bail;
1416 1456
1457 list = &dev->piowait;
1458 qplist = NULL;
1459
1417 spin_lock_irqsave(&dev->pending_lock, flags); 1460 spin_lock_irqsave(&dev->pending_lock, flags);
1418 while (!list_empty(&dev->piowait)) { 1461 while (!list_empty(list)) {
1419 qp = list_entry(dev->piowait.next, struct ipath_qp, 1462 qp = list_entry(list->next, struct ipath_qp, piowait);
1420 piowait);
1421 list_del_init(&qp->piowait); 1463 list_del_init(&qp->piowait);
1422 clear_bit(IPATH_S_BUSY, &qp->s_busy); 1464 qp->pio_next = qplist;
1423 tasklet_hi_schedule(&qp->s_task); 1465 qplist = qp;
1466 atomic_inc(&qp->refcount);
1424 } 1467 }
1425 spin_unlock_irqrestore(&dev->pending_lock, flags); 1468 spin_unlock_irqrestore(&dev->pending_lock, flags);
1426 1469
1470 while (qplist != NULL) {
1471 qp = qplist;
1472 qplist = qp->pio_next;
1473
1474 spin_lock_irqsave(&qp->s_lock, flags);
1475 if (ib_ipath_state_ops[qp->state] & IPATH_PROCESS_SEND_OK)
1476 ipath_schedule_send(qp);
1477 spin_unlock_irqrestore(&qp->s_lock, flags);
1478
1479 /* Notify ipath_destroy_qp() if it is waiting. */
1480 if (atomic_dec_and_test(&qp->refcount))
1481 wake_up(&qp->wait);
1482 }
1483
1427bail: 1484bail:
1428 return 0; 1485 return 0;
1429} 1486}
@@ -2145,11 +2202,12 @@ bail:
2145void ipath_unregister_ib_device(struct ipath_ibdev *dev) 2202void ipath_unregister_ib_device(struct ipath_ibdev *dev)
2146{ 2203{
2147 struct ib_device *ibdev = &dev->ibdev; 2204 struct ib_device *ibdev = &dev->ibdev;
2148 2205 u32 qps_inuse;
2149 disable_timer(dev->dd);
2150 2206
2151 ib_unregister_device(ibdev); 2207 ib_unregister_device(ibdev);
2152 2208
2209 disable_timer(dev->dd);
2210
2153 if (!list_empty(&dev->pending[0]) || 2211 if (!list_empty(&dev->pending[0]) ||
2154 !list_empty(&dev->pending[1]) || 2212 !list_empty(&dev->pending[1]) ||
2155 !list_empty(&dev->pending[2])) 2213 !list_empty(&dev->pending[2]))
@@ -2164,7 +2222,10 @@ void ipath_unregister_ib_device(struct ipath_ibdev *dev)
2164 * Note that ipath_unregister_ib_device() can be called before all 2222 * Note that ipath_unregister_ib_device() can be called before all
2165 * the QPs are destroyed! 2223 * the QPs are destroyed!
2166 */ 2224 */
2167 ipath_free_all_qps(&dev->qp_table); 2225 qps_inuse = ipath_free_all_qps(&dev->qp_table);
2226 if (qps_inuse)
2227 ipath_dev_err(dev->dd, "QP memory leak! %u still in use\n",
2228 qps_inuse);
2168 kfree(dev->qp_table.table); 2229 kfree(dev->qp_table.table);
2169 kfree(dev->lk_table.table); 2230 kfree(dev->lk_table.table);
2170 kfree(dev->txreq_bufs); 2231 kfree(dev->txreq_bufs);
@@ -2215,17 +2276,14 @@ static ssize_t show_stats(struct device *device, struct device_attribute *attr,
2215 "RC OTH NAKs %d\n" 2276 "RC OTH NAKs %d\n"
2216 "RC timeouts %d\n" 2277 "RC timeouts %d\n"
2217 "RC RDMA dup %d\n" 2278 "RC RDMA dup %d\n"
2218 "RC stalls %d\n"
2219 "piobuf wait %d\n" 2279 "piobuf wait %d\n"
2220 "no piobuf %d\n"
2221 "unaligned %d\n" 2280 "unaligned %d\n"
2222 "PKT drops %d\n" 2281 "PKT drops %d\n"
2223 "WQE errs %d\n", 2282 "WQE errs %d\n",
2224 dev->n_rc_resends, dev->n_rc_qacks, dev->n_rc_acks, 2283 dev->n_rc_resends, dev->n_rc_qacks, dev->n_rc_acks,
2225 dev->n_seq_naks, dev->n_rdma_seq, dev->n_rnr_naks, 2284 dev->n_seq_naks, dev->n_rdma_seq, dev->n_rnr_naks,
2226 dev->n_other_naks, dev->n_timeouts, 2285 dev->n_other_naks, dev->n_timeouts,
2227 dev->n_rdma_dup_busy, dev->n_rc_stalls, dev->n_piowait, 2286 dev->n_rdma_dup_busy, dev->n_piowait, dev->n_unaligned,
2228 dev->n_no_piobuf, dev->n_unaligned,
2229 dev->n_pkt_drops, dev->n_wqe_errs); 2287 dev->n_pkt_drops, dev->n_wqe_errs);
2230 for (i = 0; i < ARRAY_SIZE(dev->opstats); i++) { 2288 for (i = 0; i < ARRAY_SIZE(dev->opstats); i++) {
2231 const struct ipath_opcode_stats *si = &dev->opstats[i]; 2289 const struct ipath_opcode_stats *si = &dev->opstats[i];
diff --git a/drivers/infiniband/hw/ipath/ipath_verbs.h b/drivers/infiniband/hw/ipath/ipath_verbs.h
index 6514aa8306cd..9d12ae8a778e 100644
--- a/drivers/infiniband/hw/ipath/ipath_verbs.h
+++ b/drivers/infiniband/hw/ipath/ipath_verbs.h
@@ -74,6 +74,11 @@
74#define IPATH_POST_RECV_OK 0x02 74#define IPATH_POST_RECV_OK 0x02
75#define IPATH_PROCESS_RECV_OK 0x04 75#define IPATH_PROCESS_RECV_OK 0x04
76#define IPATH_PROCESS_SEND_OK 0x08 76#define IPATH_PROCESS_SEND_OK 0x08
77#define IPATH_PROCESS_NEXT_SEND_OK 0x10
78#define IPATH_FLUSH_SEND 0x20
79#define IPATH_FLUSH_RECV 0x40
80#define IPATH_PROCESS_OR_FLUSH_SEND \
81 (IPATH_PROCESS_SEND_OK | IPATH_FLUSH_SEND)
77 82
78/* IB Performance Manager status values */ 83/* IB Performance Manager status values */
79#define IB_PMA_SAMPLE_STATUS_DONE 0x00 84#define IB_PMA_SAMPLE_STATUS_DONE 0x00
@@ -353,12 +358,14 @@ struct ipath_qp {
353 struct ib_qp ibqp; 358 struct ib_qp ibqp;
354 struct ipath_qp *next; /* link list for QPN hash table */ 359 struct ipath_qp *next; /* link list for QPN hash table */
355 struct ipath_qp *timer_next; /* link list for ipath_ib_timer() */ 360 struct ipath_qp *timer_next; /* link list for ipath_ib_timer() */
361 struct ipath_qp *pio_next; /* link for ipath_ib_piobufavail() */
356 struct list_head piowait; /* link for wait PIO buf */ 362 struct list_head piowait; /* link for wait PIO buf */
357 struct list_head timerwait; /* link for waiting for timeouts */ 363 struct list_head timerwait; /* link for waiting for timeouts */
358 struct ib_ah_attr remote_ah_attr; 364 struct ib_ah_attr remote_ah_attr;
359 struct ipath_ib_header s_hdr; /* next packet header to send */ 365 struct ipath_ib_header s_hdr; /* next packet header to send */
360 atomic_t refcount; 366 atomic_t refcount;
361 wait_queue_head_t wait; 367 wait_queue_head_t wait;
368 wait_queue_head_t wait_dma;
362 struct tasklet_struct s_task; 369 struct tasklet_struct s_task;
363 struct ipath_mmap_info *ip; 370 struct ipath_mmap_info *ip;
364 struct ipath_sge_state *s_cur_sge; 371 struct ipath_sge_state *s_cur_sge;
@@ -369,7 +376,7 @@ struct ipath_qp {
369 struct ipath_sge_state s_rdma_read_sge; 376 struct ipath_sge_state s_rdma_read_sge;
370 struct ipath_sge_state r_sge; /* current receive data */ 377 struct ipath_sge_state r_sge; /* current receive data */
371 spinlock_t s_lock; 378 spinlock_t s_lock;
372 unsigned long s_busy; 379 atomic_t s_dma_busy;
373 u16 s_pkt_delay; 380 u16 s_pkt_delay;
374 u16 s_hdrwords; /* size of s_hdr in 32 bit words */ 381 u16 s_hdrwords; /* size of s_hdr in 32 bit words */
375 u32 s_cur_size; /* size of send packet in bytes */ 382 u32 s_cur_size; /* size of send packet in bytes */
@@ -383,6 +390,7 @@ struct ipath_qp {
383 u32 s_rnr_timeout; /* number of milliseconds for RNR timeout */ 390 u32 s_rnr_timeout; /* number of milliseconds for RNR timeout */
384 u32 r_ack_psn; /* PSN for next ACK or atomic ACK */ 391 u32 r_ack_psn; /* PSN for next ACK or atomic ACK */
385 u64 r_wr_id; /* ID for current receive WQE */ 392 u64 r_wr_id; /* ID for current receive WQE */
393 unsigned long r_aflags;
386 u32 r_len; /* total length of r_sge */ 394 u32 r_len; /* total length of r_sge */
387 u32 r_rcv_len; /* receive data len processed */ 395 u32 r_rcv_len; /* receive data len processed */
388 u32 r_psn; /* expected rcv packet sequence number */ 396 u32 r_psn; /* expected rcv packet sequence number */
@@ -394,8 +402,7 @@ struct ipath_qp {
394 u8 r_state; /* opcode of last packet received */ 402 u8 r_state; /* opcode of last packet received */
395 u8 r_nak_state; /* non-zero if NAK is pending */ 403 u8 r_nak_state; /* non-zero if NAK is pending */
396 u8 r_min_rnr_timer; /* retry timeout value for RNR NAKs */ 404 u8 r_min_rnr_timer; /* retry timeout value for RNR NAKs */
397 u8 r_reuse_sge; /* for UC receive errors */ 405 u8 r_flags;
398 u8 r_wrid_valid; /* r_wrid set but CQ entry not yet made */
399 u8 r_max_rd_atomic; /* max number of RDMA read/atomic to receive */ 406 u8 r_max_rd_atomic; /* max number of RDMA read/atomic to receive */
400 u8 r_head_ack_queue; /* index into s_ack_queue[] */ 407 u8 r_head_ack_queue; /* index into s_ack_queue[] */
401 u8 qp_access_flags; 408 u8 qp_access_flags;
@@ -404,13 +411,13 @@ struct ipath_qp {
404 u8 s_rnr_retry_cnt; 411 u8 s_rnr_retry_cnt;
405 u8 s_retry; /* requester retry counter */ 412 u8 s_retry; /* requester retry counter */
406 u8 s_rnr_retry; /* requester RNR retry counter */ 413 u8 s_rnr_retry; /* requester RNR retry counter */
407 u8 s_wait_credit; /* limit number of unacked packets sent */
408 u8 s_pkey_index; /* PKEY index to use */ 414 u8 s_pkey_index; /* PKEY index to use */
409 u8 s_max_rd_atomic; /* max number of RDMA read/atomic to send */ 415 u8 s_max_rd_atomic; /* max number of RDMA read/atomic to send */
410 u8 s_num_rd_atomic; /* number of RDMA read/atomic pending */ 416 u8 s_num_rd_atomic; /* number of RDMA read/atomic pending */
411 u8 s_tail_ack_queue; /* index into s_ack_queue[] */ 417 u8 s_tail_ack_queue; /* index into s_ack_queue[] */
412 u8 s_flags; 418 u8 s_flags;
413 u8 s_dmult; 419 u8 s_dmult;
420 u8 s_draining;
414 u8 timeout; /* Timeout for this QP */ 421 u8 timeout; /* Timeout for this QP */
415 enum ib_mtu path_mtu; 422 enum ib_mtu path_mtu;
416 u32 remote_qpn; 423 u32 remote_qpn;
@@ -428,16 +435,40 @@ struct ipath_qp {
428 struct ipath_sge r_sg_list[0]; /* verified SGEs */ 435 struct ipath_sge r_sg_list[0]; /* verified SGEs */
429}; 436};
430 437
431/* Bit definition for s_busy. */ 438/*
432#define IPATH_S_BUSY 0 439 * Atomic bit definitions for r_aflags.
440 */
441#define IPATH_R_WRID_VALID 0
442
443/*
444 * Bit definitions for r_flags.
445 */
446#define IPATH_R_REUSE_SGE 0x01
447#define IPATH_R_RDMAR_SEQ 0x02
433 448
434/* 449/*
435 * Bit definitions for s_flags. 450 * Bit definitions for s_flags.
451 *
452 * IPATH_S_FENCE_PENDING - waiting for all prior RDMA read or atomic SWQEs
453 * before processing the next SWQE
454 * IPATH_S_RDMAR_PENDING - waiting for any RDMA read or atomic SWQEs
455 * before processing the next SWQE
456 * IPATH_S_WAITING - waiting for RNR timeout or send buffer available.
457 * IPATH_S_WAIT_SSN_CREDIT - waiting for RC credits to process next SWQE
458 * IPATH_S_WAIT_DMA - waiting for send DMA queue to drain before generating
459 * next send completion entry not via send DMA.
436 */ 460 */
437#define IPATH_S_SIGNAL_REQ_WR 0x01 461#define IPATH_S_SIGNAL_REQ_WR 0x01
438#define IPATH_S_FENCE_PENDING 0x02 462#define IPATH_S_FENCE_PENDING 0x02
439#define IPATH_S_RDMAR_PENDING 0x04 463#define IPATH_S_RDMAR_PENDING 0x04
440#define IPATH_S_ACK_PENDING 0x08 464#define IPATH_S_ACK_PENDING 0x08
465#define IPATH_S_BUSY 0x10
466#define IPATH_S_WAITING 0x20
467#define IPATH_S_WAIT_SSN_CREDIT 0x40
468#define IPATH_S_WAIT_DMA 0x80
469
470#define IPATH_S_ANY_WAIT (IPATH_S_FENCE_PENDING | IPATH_S_RDMAR_PENDING | \
471 IPATH_S_WAITING | IPATH_S_WAIT_SSN_CREDIT | IPATH_S_WAIT_DMA)
441 472
442#define IPATH_PSN_CREDIT 512 473#define IPATH_PSN_CREDIT 512
443 474
@@ -573,13 +604,11 @@ struct ipath_ibdev {
573 u32 n_rnr_naks; 604 u32 n_rnr_naks;
574 u32 n_other_naks; 605 u32 n_other_naks;
575 u32 n_timeouts; 606 u32 n_timeouts;
576 u32 n_rc_stalls;
577 u32 n_pkt_drops; 607 u32 n_pkt_drops;
578 u32 n_vl15_dropped; 608 u32 n_vl15_dropped;
579 u32 n_wqe_errs; 609 u32 n_wqe_errs;
580 u32 n_rdma_dup_busy; 610 u32 n_rdma_dup_busy;
581 u32 n_piowait; 611 u32 n_piowait;
582 u32 n_no_piobuf;
583 u32 n_unaligned; 612 u32 n_unaligned;
584 u32 port_cap_flags; 613 u32 port_cap_flags;
585 u32 pma_sample_start; 614 u32 pma_sample_start;
@@ -657,6 +686,17 @@ static inline struct ipath_ibdev *to_idev(struct ib_device *ibdev)
657 return container_of(ibdev, struct ipath_ibdev, ibdev); 686 return container_of(ibdev, struct ipath_ibdev, ibdev);
658} 687}
659 688
689/*
690 * This must be called with s_lock held.
691 */
692static inline void ipath_schedule_send(struct ipath_qp *qp)
693{
694 if (qp->s_flags & IPATH_S_ANY_WAIT)
695 qp->s_flags &= ~IPATH_S_ANY_WAIT;
696 if (!(qp->s_flags & IPATH_S_BUSY))
697 tasklet_hi_schedule(&qp->s_task);
698}
699
660int ipath_process_mad(struct ib_device *ibdev, 700int ipath_process_mad(struct ib_device *ibdev,
661 int mad_flags, 701 int mad_flags,
662 u8 port_num, 702 u8 port_num,
@@ -706,12 +746,10 @@ int ipath_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr,
706int ipath_query_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr, 746int ipath_query_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr,
707 int attr_mask, struct ib_qp_init_attr *init_attr); 747 int attr_mask, struct ib_qp_init_attr *init_attr);
708 748
709void ipath_free_all_qps(struct ipath_qp_table *qpt); 749unsigned ipath_free_all_qps(struct ipath_qp_table *qpt);
710 750
711int ipath_init_qp_table(struct ipath_ibdev *idev, int size); 751int ipath_init_qp_table(struct ipath_ibdev *idev, int size);
712 752
713void ipath_sqerror_qp(struct ipath_qp *qp, struct ib_wc *wc);
714
715void ipath_get_credit(struct ipath_qp *qp, u32 aeth); 753void ipath_get_credit(struct ipath_qp *qp, u32 aeth);
716 754
717unsigned ipath_ib_rate_to_mult(enum ib_rate rate); 755unsigned ipath_ib_rate_to_mult(enum ib_rate rate);
@@ -729,7 +767,9 @@ void ipath_uc_rcv(struct ipath_ibdev *dev, struct ipath_ib_header *hdr,
729void ipath_rc_rcv(struct ipath_ibdev *dev, struct ipath_ib_header *hdr, 767void ipath_rc_rcv(struct ipath_ibdev *dev, struct ipath_ib_header *hdr,
730 int has_grh, void *data, u32 tlen, struct ipath_qp *qp); 768 int has_grh, void *data, u32 tlen, struct ipath_qp *qp);
731 769
732void ipath_restart_rc(struct ipath_qp *qp, u32 psn, struct ib_wc *wc); 770void ipath_restart_rc(struct ipath_qp *qp, u32 psn);
771
772void ipath_rc_error(struct ipath_qp *qp, enum ib_wc_status err);
733 773
734int ipath_post_ud_send(struct ipath_qp *qp, struct ib_send_wr *wr); 774int ipath_post_ud_send(struct ipath_qp *qp, struct ib_send_wr *wr);
735 775
diff --git a/drivers/infiniband/hw/nes/nes.c b/drivers/infiniband/hw/nes/nes.c
index 9f7364a9096d..a4e9269a29bd 100644
--- a/drivers/infiniband/hw/nes/nes.c
+++ b/drivers/infiniband/hw/nes/nes.c
@@ -91,10 +91,6 @@ unsigned int nes_debug_level = 0;
91module_param_named(debug_level, nes_debug_level, uint, 0644); 91module_param_named(debug_level, nes_debug_level, uint, 0644);
92MODULE_PARM_DESC(debug_level, "Enable debug output level"); 92MODULE_PARM_DESC(debug_level, "Enable debug output level");
93 93
94unsigned int nes_lro_max_aggr = NES_LRO_MAX_AGGR;
95module_param(nes_lro_max_aggr, int, NES_LRO_MAX_AGGR);
96MODULE_PARM_DESC(nes_mro_max_aggr, " nic LRO MAX packet aggregation");
97
98LIST_HEAD(nes_adapter_list); 94LIST_HEAD(nes_adapter_list);
99static LIST_HEAD(nes_dev_list); 95static LIST_HEAD(nes_dev_list);
100 96
diff --git a/drivers/infiniband/hw/nes/nes.h b/drivers/infiniband/hw/nes/nes.h
index 1f9f7bf73862..61b46e9c7d2d 100644
--- a/drivers/infiniband/hw/nes/nes.h
+++ b/drivers/infiniband/hw/nes/nes.h
@@ -173,7 +173,6 @@ extern int disable_mpa_crc;
173extern unsigned int send_first; 173extern unsigned int send_first;
174extern unsigned int nes_drv_opt; 174extern unsigned int nes_drv_opt;
175extern unsigned int nes_debug_level; 175extern unsigned int nes_debug_level;
176extern unsigned int nes_lro_max_aggr;
177 176
178extern struct list_head nes_adapter_list; 177extern struct list_head nes_adapter_list;
179 178
diff --git a/drivers/infiniband/hw/nes/nes_hw.c b/drivers/infiniband/hw/nes/nes_hw.c
index 8dc70f9bad2f..d3278f111ca7 100644
--- a/drivers/infiniband/hw/nes/nes_hw.c
+++ b/drivers/infiniband/hw/nes/nes_hw.c
@@ -42,6 +42,10 @@
42 42
43#include "nes.h" 43#include "nes.h"
44 44
45static unsigned int nes_lro_max_aggr = NES_LRO_MAX_AGGR;
46module_param(nes_lro_max_aggr, uint, 0444);
47MODULE_PARM_DESC(nes_lro_max_aggr, "NIC LRO max packet aggregation");
48
45static u32 crit_err_count; 49static u32 crit_err_count;
46u32 int_mod_timer_init; 50u32 int_mod_timer_init;
47u32 int_mod_cq_depth_256; 51u32 int_mod_cq_depth_256;
@@ -1738,7 +1742,7 @@ int nes_init_nic_qp(struct nes_device *nesdev, struct net_device *netdev)
1738 jumbomode = 1; 1742 jumbomode = 1;
1739 nes_nic_init_timer_defaults(nesdev, jumbomode); 1743 nes_nic_init_timer_defaults(nesdev, jumbomode);
1740 } 1744 }
1741 nesvnic->lro_mgr.max_aggr = NES_LRO_MAX_AGGR; 1745 nesvnic->lro_mgr.max_aggr = nes_lro_max_aggr;
1742 nesvnic->lro_mgr.max_desc = NES_MAX_LRO_DESCRIPTORS; 1746 nesvnic->lro_mgr.max_desc = NES_MAX_LRO_DESCRIPTORS;
1743 nesvnic->lro_mgr.lro_arr = nesvnic->lro_desc; 1747 nesvnic->lro_mgr.lro_arr = nesvnic->lro_desc;
1744 nesvnic->lro_mgr.get_skb_header = nes_lro_get_skb_hdr; 1748 nesvnic->lro_mgr.get_skb_header = nes_lro_get_skb_hdr;
diff --git a/drivers/macintosh/adb.c b/drivers/macintosh/adb.c
index b8b9e44f7f4e..dbaad39020a1 100644
--- a/drivers/macintosh/adb.c
+++ b/drivers/macintosh/adb.c
@@ -334,7 +334,7 @@ int __init adb_init(void)
334 return 0; 334 return 0;
335} 335}
336 336
337__initcall(adb_init); 337device_initcall(adb_init);
338 338
339static int 339static int
340do_adb_reset_bus(void) 340do_adb_reset_bus(void)
diff --git a/drivers/md/linear.c b/drivers/md/linear.c
index 0b8511776b3e..10748240cb2f 100644
--- a/drivers/md/linear.c
+++ b/drivers/md/linear.c
@@ -250,6 +250,7 @@ static int linear_run (mddev_t *mddev)
250{ 250{
251 linear_conf_t *conf; 251 linear_conf_t *conf;
252 252
253 mddev->queue->queue_lock = &mddev->queue->__queue_lock;
253 conf = linear_conf(mddev, mddev->raid_disks); 254 conf = linear_conf(mddev, mddev->raid_disks);
254 255
255 if (!conf) 256 if (!conf)
diff --git a/drivers/md/multipath.c b/drivers/md/multipath.c
index 42ee1a2dc144..4f4d1f383842 100644
--- a/drivers/md/multipath.c
+++ b/drivers/md/multipath.c
@@ -417,6 +417,7 @@ static int multipath_run (mddev_t *mddev)
417 * bookkeeping area. [whatever we allocate in multipath_run(), 417 * bookkeeping area. [whatever we allocate in multipath_run(),
418 * should be freed in multipath_stop()] 418 * should be freed in multipath_stop()]
419 */ 419 */
420 mddev->queue->queue_lock = &mddev->queue->__queue_lock;
420 421
421 conf = kzalloc(sizeof(multipath_conf_t), GFP_KERNEL); 422 conf = kzalloc(sizeof(multipath_conf_t), GFP_KERNEL);
422 mddev->private = conf; 423 mddev->private = conf;
diff --git a/drivers/md/raid0.c b/drivers/md/raid0.c
index 818b48284096..914c04ddec7c 100644
--- a/drivers/md/raid0.c
+++ b/drivers/md/raid0.c
@@ -280,6 +280,7 @@ static int raid0_run (mddev_t *mddev)
280 (mddev->chunk_size>>1)-1); 280 (mddev->chunk_size>>1)-1);
281 blk_queue_max_sectors(mddev->queue, mddev->chunk_size >> 9); 281 blk_queue_max_sectors(mddev->queue, mddev->chunk_size >> 9);
282 blk_queue_segment_boundary(mddev->queue, (mddev->chunk_size>>1) - 1); 282 blk_queue_segment_boundary(mddev->queue, (mddev->chunk_size>>1) - 1);
283 mddev->queue->queue_lock = &mddev->queue->__queue_lock;
283 284
284 conf = kmalloc(sizeof (raid0_conf_t), GFP_KERNEL); 285 conf = kmalloc(sizeof (raid0_conf_t), GFP_KERNEL);
285 if (!conf) 286 if (!conf)
diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
index 6778b7cb39bd..ac409b7d83f5 100644
--- a/drivers/md/raid1.c
+++ b/drivers/md/raid1.c
@@ -1935,6 +1935,9 @@ static int run(mddev_t *mddev)
1935 if (!conf->r1bio_pool) 1935 if (!conf->r1bio_pool)
1936 goto out_no_mem; 1936 goto out_no_mem;
1937 1937
1938 spin_lock_init(&conf->device_lock);
1939 mddev->queue->queue_lock = &conf->device_lock;
1940
1938 rdev_for_each(rdev, tmp, mddev) { 1941 rdev_for_each(rdev, tmp, mddev) {
1939 disk_idx = rdev->raid_disk; 1942 disk_idx = rdev->raid_disk;
1940 if (disk_idx >= mddev->raid_disks 1943 if (disk_idx >= mddev->raid_disks
@@ -1958,7 +1961,6 @@ static int run(mddev_t *mddev)
1958 } 1961 }
1959 conf->raid_disks = mddev->raid_disks; 1962 conf->raid_disks = mddev->raid_disks;
1960 conf->mddev = mddev; 1963 conf->mddev = mddev;
1961 spin_lock_init(&conf->device_lock);
1962 INIT_LIST_HEAD(&conf->retry_list); 1964 INIT_LIST_HEAD(&conf->retry_list);
1963 1965
1964 spin_lock_init(&conf->resync_lock); 1966 spin_lock_init(&conf->resync_lock);
diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
index faf3d8912979..8536ede1e712 100644
--- a/drivers/md/raid10.c
+++ b/drivers/md/raid10.c
@@ -2082,6 +2082,9 @@ static int run(mddev_t *mddev)
2082 goto out_free_conf; 2082 goto out_free_conf;
2083 } 2083 }
2084 2084
2085 spin_lock_init(&conf->device_lock);
2086 mddev->queue->queue_lock = &conf->device_lock;
2087
2085 rdev_for_each(rdev, tmp, mddev) { 2088 rdev_for_each(rdev, tmp, mddev) {
2086 disk_idx = rdev->raid_disk; 2089 disk_idx = rdev->raid_disk;
2087 if (disk_idx >= mddev->raid_disks 2090 if (disk_idx >= mddev->raid_disks
@@ -2103,7 +2106,6 @@ static int run(mddev_t *mddev)
2103 2106
2104 disk->head_position = 0; 2107 disk->head_position = 0;
2105 } 2108 }
2106 spin_lock_init(&conf->device_lock);
2107 INIT_LIST_HEAD(&conf->retry_list); 2109 INIT_LIST_HEAD(&conf->retry_list);
2108 2110
2109 spin_lock_init(&conf->resync_lock); 2111 spin_lock_init(&conf->resync_lock);
diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
index 087eee0cb809..93fde48c0f42 100644
--- a/drivers/md/raid5.c
+++ b/drivers/md/raid5.c
@@ -2369,8 +2369,8 @@ static void handle_parity_checks5(raid5_conf_t *conf, struct stripe_head *sh,
2369 2369
2370 /* complete a check operation */ 2370 /* complete a check operation */
2371 if (test_and_clear_bit(STRIPE_OP_CHECK, &sh->ops.complete)) { 2371 if (test_and_clear_bit(STRIPE_OP_CHECK, &sh->ops.complete)) {
2372 clear_bit(STRIPE_OP_CHECK, &sh->ops.ack); 2372 clear_bit(STRIPE_OP_CHECK, &sh->ops.ack);
2373 clear_bit(STRIPE_OP_CHECK, &sh->ops.pending); 2373 clear_bit(STRIPE_OP_CHECK, &sh->ops.pending);
2374 if (s->failed == 0) { 2374 if (s->failed == 0) {
2375 if (sh->ops.zero_sum_result == 0) 2375 if (sh->ops.zero_sum_result == 0)
2376 /* parity is correct (on disc, 2376 /* parity is correct (on disc,
@@ -2400,16 +2400,6 @@ static void handle_parity_checks5(raid5_conf_t *conf, struct stripe_head *sh,
2400 canceled_check = 1; /* STRIPE_INSYNC is not set */ 2400 canceled_check = 1; /* STRIPE_INSYNC is not set */
2401 } 2401 }
2402 2402
2403 /* check if we can clear a parity disk reconstruct */
2404 if (test_bit(STRIPE_OP_COMPUTE_BLK, &sh->ops.complete) &&
2405 test_bit(STRIPE_OP_MOD_REPAIR_PD, &sh->ops.pending)) {
2406
2407 clear_bit(STRIPE_OP_MOD_REPAIR_PD, &sh->ops.pending);
2408 clear_bit(STRIPE_OP_COMPUTE_BLK, &sh->ops.complete);
2409 clear_bit(STRIPE_OP_COMPUTE_BLK, &sh->ops.ack);
2410 clear_bit(STRIPE_OP_COMPUTE_BLK, &sh->ops.pending);
2411 }
2412
2413 /* start a new check operation if there are no failures, the stripe is 2403 /* start a new check operation if there are no failures, the stripe is
2414 * not insync, and a repair is not in flight 2404 * not insync, and a repair is not in flight
2415 */ 2405 */
@@ -2424,6 +2414,17 @@ static void handle_parity_checks5(raid5_conf_t *conf, struct stripe_head *sh,
2424 } 2414 }
2425 } 2415 }
2426 2416
2417 /* check if we can clear a parity disk reconstruct */
2418 if (test_bit(STRIPE_OP_COMPUTE_BLK, &sh->ops.complete) &&
2419 test_bit(STRIPE_OP_MOD_REPAIR_PD, &sh->ops.pending)) {
2420
2421 clear_bit(STRIPE_OP_MOD_REPAIR_PD, &sh->ops.pending);
2422 clear_bit(STRIPE_OP_COMPUTE_BLK, &sh->ops.complete);
2423 clear_bit(STRIPE_OP_COMPUTE_BLK, &sh->ops.ack);
2424 clear_bit(STRIPE_OP_COMPUTE_BLK, &sh->ops.pending);
2425 }
2426
2427
2427 /* Wait for check parity and compute block operations to complete 2428 /* Wait for check parity and compute block operations to complete
2428 * before write-back. If a failure occurred while the check operation 2429 * before write-back. If a failure occurred while the check operation
2429 * was in flight we need to cycle this stripe through handle_stripe 2430 * was in flight we need to cycle this stripe through handle_stripe
@@ -4256,6 +4257,7 @@ static int run(mddev_t *mddev)
4256 goto abort; 4257 goto abort;
4257 } 4258 }
4258 spin_lock_init(&conf->device_lock); 4259 spin_lock_init(&conf->device_lock);
4260 mddev->queue->queue_lock = &conf->device_lock;
4259 init_waitqueue_head(&conf->wait_for_stripe); 4261 init_waitqueue_head(&conf->wait_for_stripe);
4260 init_waitqueue_head(&conf->wait_for_overlap); 4262 init_waitqueue_head(&conf->wait_for_overlap);
4261 INIT_LIST_HEAD(&conf->handle_list); 4263 INIT_LIST_HEAD(&conf->handle_list);
diff --git a/drivers/media/Kconfig b/drivers/media/Kconfig
index ddf57e135c6c..7a7803b5d497 100644
--- a/drivers/media/Kconfig
+++ b/drivers/media/Kconfig
@@ -89,8 +89,7 @@ config DVB_CORE
89 89
90config VIDEO_MEDIA 90config VIDEO_MEDIA
91 tristate 91 tristate
92 default DVB_CORE || VIDEO_DEV 92 default (DVB_CORE && (VIDEO_DEV = n)) || (VIDEO_DEV && (DVB_CORE = n)) || (DVB_CORE && VIDEO_DEV)
93 depends on DVB_CORE || VIDEO_DEV
94 93
95comment "Multimedia drivers" 94comment "Multimedia drivers"
96 95
diff --git a/drivers/media/common/tuners/Kconfig b/drivers/media/common/tuners/Kconfig
index 5be85ff53e12..d6206540476b 100644
--- a/drivers/media/common/tuners/Kconfig
+++ b/drivers/media/common/tuners/Kconfig
@@ -1,6 +1,6 @@
1config MEDIA_ATTACH 1config MEDIA_ATTACH
2 bool "Load and attach frontend and tuner driver modules as needed" 2 bool "Load and attach frontend and tuner driver modules as needed"
3 depends on DVB_CORE 3 depends on VIDEO_MEDIA
4 depends on MODULES 4 depends on MODULES
5 help 5 help
6 Remove the static dependency of DVB card drivers on all 6 Remove the static dependency of DVB card drivers on all
@@ -19,10 +19,10 @@ config MEDIA_ATTACH
19 19
20config MEDIA_TUNER 20config MEDIA_TUNER
21 tristate 21 tristate
22 default DVB_CORE || VIDEO_DEV 22 default VIDEO_MEDIA && I2C
23 depends on DVB_CORE || VIDEO_DEV 23 depends on VIDEO_MEDIA && I2C
24 select MEDIA_TUNER_XC2028 if !MEDIA_TUNER_CUSTOMIZE 24 select MEDIA_TUNER_XC2028 if !MEDIA_TUNER_CUSTOMIZE && HOTPLUG
25 select MEDIA_TUNER_XC5000 if !MEDIA_TUNER_CUSTOMIZE 25 select MEDIA_TUNER_XC5000 if !MEDIA_TUNER_CUSTOMIZE && HOTPLUG
26 select MEDIA_TUNER_MT20XX if !MEDIA_TUNER_CUSTOMIZE 26 select MEDIA_TUNER_MT20XX if !MEDIA_TUNER_CUSTOMIZE
27 select MEDIA_TUNER_TDA8290 if !MEDIA_TUNER_CUSTOMIZE 27 select MEDIA_TUNER_TDA8290 if !MEDIA_TUNER_CUSTOMIZE
28 select MEDIA_TUNER_TEA5761 if !MEDIA_TUNER_CUSTOMIZE 28 select MEDIA_TUNER_TEA5761 if !MEDIA_TUNER_CUSTOMIZE
@@ -46,7 +46,7 @@ if MEDIA_TUNER_CUSTOMIZE
46 46
47config MEDIA_TUNER_SIMPLE 47config MEDIA_TUNER_SIMPLE
48 tristate "Simple tuner support" 48 tristate "Simple tuner support"
49 depends on I2C 49 depends on VIDEO_MEDIA && I2C
50 select MEDIA_TUNER_TDA9887 50 select MEDIA_TUNER_TDA9887
51 default m if MEDIA_TUNER_CUSTOMIZE 51 default m if MEDIA_TUNER_CUSTOMIZE
52 help 52 help
@@ -54,7 +54,7 @@ config MEDIA_TUNER_SIMPLE
54 54
55config MEDIA_TUNER_TDA8290 55config MEDIA_TUNER_TDA8290
56 tristate "TDA 8290/8295 + 8275(a)/18271 tuner combo" 56 tristate "TDA 8290/8295 + 8275(a)/18271 tuner combo"
57 depends on I2C 57 depends on VIDEO_MEDIA && I2C
58 select MEDIA_TUNER_TDA827X 58 select MEDIA_TUNER_TDA827X
59 select MEDIA_TUNER_TDA18271 59 select MEDIA_TUNER_TDA18271
60 default m if MEDIA_TUNER_CUSTOMIZE 60 default m if MEDIA_TUNER_CUSTOMIZE
@@ -63,21 +63,21 @@ config MEDIA_TUNER_TDA8290
63 63
64config MEDIA_TUNER_TDA827X 64config MEDIA_TUNER_TDA827X
65 tristate "Philips TDA827X silicon tuner" 65 tristate "Philips TDA827X silicon tuner"
66 depends on DVB_CORE && I2C 66 depends on VIDEO_MEDIA && I2C
67 default m if DVB_FE_CUSTOMISE 67 default m if DVB_FE_CUSTOMISE
68 help 68 help
69 A DVB-T silicon tuner module. Say Y when you want to support this tuner. 69 A DVB-T silicon tuner module. Say Y when you want to support this tuner.
70 70
71config MEDIA_TUNER_TDA18271 71config MEDIA_TUNER_TDA18271
72 tristate "NXP TDA18271 silicon tuner" 72 tristate "NXP TDA18271 silicon tuner"
73 depends on I2C 73 depends on VIDEO_MEDIA && I2C
74 default m if DVB_FE_CUSTOMISE 74 default m if DVB_FE_CUSTOMISE
75 help 75 help
76 A silicon tuner module. Say Y when you want to support this tuner. 76 A silicon tuner module. Say Y when you want to support this tuner.
77 77
78config MEDIA_TUNER_TDA9887 78config MEDIA_TUNER_TDA9887
79 tristate "TDA 9885/6/7 analog IF demodulator" 79 tristate "TDA 9885/6/7 analog IF demodulator"
80 depends on I2C 80 depends on VIDEO_MEDIA && I2C
81 default m if MEDIA_TUNER_CUSTOMIZE 81 default m if MEDIA_TUNER_CUSTOMIZE
82 help 82 help
83 Say Y here to include support for Philips TDA9885/6/7 83 Say Y here to include support for Philips TDA9885/6/7
@@ -85,67 +85,79 @@ config MEDIA_TUNER_TDA9887
85 85
86config MEDIA_TUNER_TEA5761 86config MEDIA_TUNER_TEA5761
87 tristate "TEA 5761 radio tuner (EXPERIMENTAL)" 87 tristate "TEA 5761 radio tuner (EXPERIMENTAL)"
88 depends on I2C && EXPERIMENTAL 88 depends on VIDEO_MEDIA && I2C
89 depends on EXPERIMENTAL
89 default m if MEDIA_TUNER_CUSTOMIZE 90 default m if MEDIA_TUNER_CUSTOMIZE
90 help 91 help
91 Say Y here to include support for the Philips TEA5761 radio tuner. 92 Say Y here to include support for the Philips TEA5761 radio tuner.
92 93
93config MEDIA_TUNER_TEA5767 94config MEDIA_TUNER_TEA5767
94 tristate "TEA 5767 radio tuner" 95 tristate "TEA 5767 radio tuner"
95 depends on I2C 96 depends on VIDEO_MEDIA && I2C
96 default m if MEDIA_TUNER_CUSTOMIZE 97 default m if MEDIA_TUNER_CUSTOMIZE
97 help 98 help
98 Say Y here to include support for the Philips TEA5767 radio tuner. 99 Say Y here to include support for the Philips TEA5767 radio tuner.
99 100
100config MEDIA_TUNER_MT20XX 101config MEDIA_TUNER_MT20XX
101 tristate "Microtune 2032 / 2050 tuners" 102 tristate "Microtune 2032 / 2050 tuners"
102 depends on I2C 103 depends on VIDEO_MEDIA && I2C
103 default m if MEDIA_TUNER_CUSTOMIZE 104 default m if MEDIA_TUNER_CUSTOMIZE
104 help 105 help
105 Say Y here to include support for the MT2032 / MT2050 tuner. 106 Say Y here to include support for the MT2032 / MT2050 tuner.
106 107
107config MEDIA_TUNER_MT2060 108config MEDIA_TUNER_MT2060
108 tristate "Microtune MT2060 silicon IF tuner" 109 tristate "Microtune MT2060 silicon IF tuner"
109 depends on I2C 110 depends on VIDEO_MEDIA && I2C
110 default m if DVB_FE_CUSTOMISE 111 default m if DVB_FE_CUSTOMISE
111 help 112 help
112 A driver for the silicon IF tuner MT2060 from Microtune. 113 A driver for the silicon IF tuner MT2060 from Microtune.
113 114
114config MEDIA_TUNER_MT2266 115config MEDIA_TUNER_MT2266
115 tristate "Microtune MT2266 silicon tuner" 116 tristate "Microtune MT2266 silicon tuner"
116 depends on I2C 117 depends on VIDEO_MEDIA && I2C
117 default m if DVB_FE_CUSTOMISE 118 default m if DVB_FE_CUSTOMISE
118 help 119 help
119 A driver for the silicon baseband tuner MT2266 from Microtune. 120 A driver for the silicon baseband tuner MT2266 from Microtune.
120 121
121config MEDIA_TUNER_MT2131 122config MEDIA_TUNER_MT2131
122 tristate "Microtune MT2131 silicon tuner" 123 tristate "Microtune MT2131 silicon tuner"
123 depends on I2C 124 depends on VIDEO_MEDIA && I2C
124 default m if DVB_FE_CUSTOMISE 125 default m if DVB_FE_CUSTOMISE
125 help 126 help
126 A driver for the silicon baseband tuner MT2131 from Microtune. 127 A driver for the silicon baseband tuner MT2131 from Microtune.
127 128
128config MEDIA_TUNER_QT1010 129config MEDIA_TUNER_QT1010
129 tristate "Quantek QT1010 silicon tuner" 130 tristate "Quantek QT1010 silicon tuner"
130 depends on DVB_CORE && I2C 131 depends on VIDEO_MEDIA && I2C
131 default m if DVB_FE_CUSTOMISE 132 default m if DVB_FE_CUSTOMISE
132 help 133 help
133 A driver for the silicon tuner QT1010 from Quantek. 134 A driver for the silicon tuner QT1010 from Quantek.
134 135
135config MEDIA_TUNER_XC2028 136config MEDIA_TUNER_XC2028
136 tristate "XCeive xc2028/xc3028 tuners" 137 tristate "XCeive xc2028/xc3028 tuners"
137 depends on I2C && FW_LOADER 138 depends on VIDEO_MEDIA && I2C
139 depends on HOTPLUG
140 select FW_LOADER
138 default m if MEDIA_TUNER_CUSTOMIZE 141 default m if MEDIA_TUNER_CUSTOMIZE
139 help 142 help
140 Say Y here to include support for the xc2028/xc3028 tuners. 143 Say Y here to include support for the xc2028/xc3028 tuners.
141 144
142config MEDIA_TUNER_XC5000 145config MEDIA_TUNER_XC5000
143 tristate "Xceive XC5000 silicon tuner" 146 tristate "Xceive XC5000 silicon tuner"
144 depends on I2C 147 depends on VIDEO_MEDIA && I2C
148 depends on HOTPLUG
149 select FW_LOADER
145 default m if DVB_FE_CUSTOMISE 150 default m if DVB_FE_CUSTOMISE
146 help 151 help
147 A driver for the silicon tuner XC5000 from Xceive. 152 A driver for the silicon tuner XC5000 from Xceive.
148 This device is only used inside a SiP called togther with a 153 This device is only used inside a SiP called togther with a
149 demodulator for now. 154 demodulator for now.
150 155
156config MEDIA_TUNER_MXL5005S
157 tristate "MaxLinear MSL5005S silicon tuner"
158 depends on VIDEO_MEDIA && I2C
159 default m if DVB_FE_CUSTOMISE
160 help
161 A driver for the silicon tuner MXL5005S from MaxLinear.
162
151endif # MEDIA_TUNER_CUSTOMIZE 163endif # MEDIA_TUNER_CUSTOMIZE
diff --git a/drivers/media/common/tuners/Makefile b/drivers/media/common/tuners/Makefile
index 236d9932fd92..55f7e6706297 100644
--- a/drivers/media/common/tuners/Makefile
+++ b/drivers/media/common/tuners/Makefile
@@ -20,6 +20,7 @@ obj-$(CONFIG_MEDIA_TUNER_MT2060) += mt2060.o
20obj-$(CONFIG_MEDIA_TUNER_MT2266) += mt2266.o 20obj-$(CONFIG_MEDIA_TUNER_MT2266) += mt2266.o
21obj-$(CONFIG_MEDIA_TUNER_QT1010) += qt1010.o 21obj-$(CONFIG_MEDIA_TUNER_QT1010) += qt1010.o
22obj-$(CONFIG_MEDIA_TUNER_MT2131) += mt2131.o 22obj-$(CONFIG_MEDIA_TUNER_MT2131) += mt2131.o
23obj-$(CONFIG_MEDIA_TUNER_MXL5005S) += mxl5005s.o
23 24
24EXTRA_CFLAGS += -Idrivers/media/dvb/dvb-core 25EXTRA_CFLAGS += -Idrivers/media/dvb/dvb-core
25EXTRA_CFLAGS += -Idrivers/media/dvb/frontends 26EXTRA_CFLAGS += -Idrivers/media/dvb/frontends
diff --git a/drivers/media/common/tuners/mxl5005s.c b/drivers/media/common/tuners/mxl5005s.c
new file mode 100644
index 000000000000..5d05b5390f66
--- /dev/null
+++ b/drivers/media/common/tuners/mxl5005s.c
@@ -0,0 +1,4110 @@
1/*
2 MaxLinear MXL5005S VSB/QAM/DVBT tuner driver
3
4 Copyright (C) 2008 MaxLinear
5 Copyright (C) 2006 Steven Toth <stoth@hauppauge.com>
6 Functions:
7 mxl5005s_reset()
8 mxl5005s_writereg()
9 mxl5005s_writeregs()
10 mxl5005s_init()
11 mxl5005s_reconfigure()
12 mxl5005s_AssignTunerMode()
13 mxl5005s_set_params()
14 mxl5005s_get_frequency()
15 mxl5005s_get_bandwidth()
16 mxl5005s_release()
17 mxl5005s_attach()
18
19 Copyright (C) 2008 Realtek
20 Copyright (C) 2008 Jan Hoogenraad
21 Functions:
22 mxl5005s_SetRfFreqHz()
23
24 This program is free software; you can redistribute it and/or modify
25 it under the terms of the GNU General Public License as published by
26 the Free Software Foundation; either version 2 of the License, or
27 (at your option) any later version.
28
29 This program is distributed in the hope that it will be useful,
30 but WITHOUT ANY WARRANTY; without even the implied warranty of
31 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
32 GNU General Public License for more details.
33
34 You should have received a copy of the GNU General Public License
35 along with this program; if not, write to the Free Software
36 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
37
38*/
39
40/*
41 History of this driver (Steven Toth):
42 I was given a public release of a linux driver that included
43 support for the MaxLinear MXL5005S silicon tuner. Analysis of
44 the tuner driver showed clearly three things.
45
46 1. The tuner driver didn't support the LinuxTV tuner API
47 so the code Realtek added had to be removed.
48
49 2. A significant amount of the driver is reference driver code
50 from MaxLinear, I felt it was important to identify and
51 preserve this.
52
53 3. New code has to be added to interface correctly with the
54 LinuxTV API, as a regular kernel module.
55
56 Other than the reference driver enum's, I've clearly marked
57 sections of the code and retained the copyright of the
58 respective owners.
59*/
60#include <linux/kernel.h>
61#include <linux/init.h>
62#include <linux/module.h>
63#include <linux/string.h>
64#include <linux/slab.h>
65#include <linux/delay.h>
66#include "dvb_frontend.h"
67#include "mxl5005s.h"
68
69static int debug;
70
71#define dprintk(level, arg...) do { \
72 if (level <= debug) \
73 printk(arg); \
74 } while (0)
75
76#define TUNER_REGS_NUM 104
77#define INITCTRL_NUM 40
78
79#ifdef _MXL_PRODUCTION
80#define CHCTRL_NUM 39
81#else
82#define CHCTRL_NUM 36
83#endif
84
85#define MXLCTRL_NUM 189
86#define MASTER_CONTROL_ADDR 9
87
88/* Enumeration of Master Control Register State */
89enum master_control_state {
90 MC_LOAD_START = 1,
91 MC_POWER_DOWN,
92 MC_SYNTH_RESET,
93 MC_SEQ_OFF
94};
95
96/* Enumeration of MXL5005 Tuner Modulation Type */
97enum {
98 MXL_DEFAULT_MODULATION = 0,
99 MXL_DVBT,
100 MXL_ATSC,
101 MXL_QAM,
102 MXL_ANALOG_CABLE,
103 MXL_ANALOG_OTA
104} tuner_modu_type;
105
106/* MXL5005 Tuner Register Struct */
107struct TunerReg {
108 u16 Reg_Num; /* Tuner Register Address */
109 u16 Reg_Val; /* Current sw programmed value waiting to be writen */
110};
111
112enum {
113 /* Initialization Control Names */
114 DN_IQTN_AMP_CUT = 1, /* 1 */
115 BB_MODE, /* 2 */
116 BB_BUF, /* 3 */
117 BB_BUF_OA, /* 4 */
118 BB_ALPF_BANDSELECT, /* 5 */
119 BB_IQSWAP, /* 6 */
120 BB_DLPF_BANDSEL, /* 7 */
121 RFSYN_CHP_GAIN, /* 8 */
122 RFSYN_EN_CHP_HIGAIN, /* 9 */
123 AGC_IF, /* 10 */
124 AGC_RF, /* 11 */
125 IF_DIVVAL, /* 12 */
126 IF_VCO_BIAS, /* 13 */
127 CHCAL_INT_MOD_IF, /* 14 */
128 CHCAL_FRAC_MOD_IF, /* 15 */
129 DRV_RES_SEL, /* 16 */
130 I_DRIVER, /* 17 */
131 EN_AAF, /* 18 */
132 EN_3P, /* 19 */
133 EN_AUX_3P, /* 20 */
134 SEL_AAF_BAND, /* 21 */
135 SEQ_ENCLK16_CLK_OUT, /* 22 */
136 SEQ_SEL4_16B, /* 23 */
137 XTAL_CAPSELECT, /* 24 */
138 IF_SEL_DBL, /* 25 */
139 RFSYN_R_DIV, /* 26 */
140 SEQ_EXTSYNTHCALIF, /* 27 */
141 SEQ_EXTDCCAL, /* 28 */
142 AGC_EN_RSSI, /* 29 */
143 RFA_ENCLKRFAGC, /* 30 */
144 RFA_RSSI_REFH, /* 31 */
145 RFA_RSSI_REF, /* 32 */
146 RFA_RSSI_REFL, /* 33 */
147 RFA_FLR, /* 34 */
148 RFA_CEIL, /* 35 */
149 SEQ_EXTIQFSMPULSE, /* 36 */
150 OVERRIDE_1, /* 37 */
151 BB_INITSTATE_DLPF_TUNE, /* 38 */
152 TG_R_DIV, /* 39 */
153 EN_CHP_LIN_B, /* 40 */
154
155 /* Channel Change Control Names */
156 DN_POLY = 51, /* 51 */
157 DN_RFGAIN, /* 52 */
158 DN_CAP_RFLPF, /* 53 */
159 DN_EN_VHFUHFBAR, /* 54 */
160 DN_GAIN_ADJUST, /* 55 */
161 DN_IQTNBUF_AMP, /* 56 */
162 DN_IQTNGNBFBIAS_BST, /* 57 */
163 RFSYN_EN_OUTMUX, /* 58 */
164 RFSYN_SEL_VCO_OUT, /* 59 */
165 RFSYN_SEL_VCO_HI, /* 60 */
166 RFSYN_SEL_DIVM, /* 61 */
167 RFSYN_RF_DIV_BIAS, /* 62 */
168 DN_SEL_FREQ, /* 63 */
169 RFSYN_VCO_BIAS, /* 64 */
170 CHCAL_INT_MOD_RF, /* 65 */
171 CHCAL_FRAC_MOD_RF, /* 66 */
172 RFSYN_LPF_R, /* 67 */
173 CHCAL_EN_INT_RF, /* 68 */
174 TG_LO_DIVVAL, /* 69 */
175 TG_LO_SELVAL, /* 70 */
176 TG_DIV_VAL, /* 71 */
177 TG_VCO_BIAS, /* 72 */
178 SEQ_EXTPOWERUP, /* 73 */
179 OVERRIDE_2, /* 74 */
180 OVERRIDE_3, /* 75 */
181 OVERRIDE_4, /* 76 */
182 SEQ_FSM_PULSE, /* 77 */
183 GPIO_4B, /* 78 */
184 GPIO_3B, /* 79 */
185 GPIO_4, /* 80 */
186 GPIO_3, /* 81 */
187 GPIO_1B, /* 82 */
188 DAC_A_ENABLE, /* 83 */
189 DAC_B_ENABLE, /* 84 */
190 DAC_DIN_A, /* 85 */
191 DAC_DIN_B, /* 86 */
192#ifdef _MXL_PRODUCTION
193 RFSYN_EN_DIV, /* 87 */
194 RFSYN_DIVM, /* 88 */
195 DN_BYPASS_AGC_I2C /* 89 */
196#endif
197} MXL5005_ControlName;
198
199/*
200 * The following context is source code provided by MaxLinear.
201 * MaxLinear source code - Common_MXL.h (?)
202 */
203
204/* Constants */
205#define MXL5005S_REG_WRITING_TABLE_LEN_MAX 104
206#define MXL5005S_LATCH_BYTE 0xfe
207
208/* Register address, MSB, and LSB */
209#define MXL5005S_BB_IQSWAP_ADDR 59
210#define MXL5005S_BB_IQSWAP_MSB 0
211#define MXL5005S_BB_IQSWAP_LSB 0
212
213#define MXL5005S_BB_DLPF_BANDSEL_ADDR 53
214#define MXL5005S_BB_DLPF_BANDSEL_MSB 4
215#define MXL5005S_BB_DLPF_BANDSEL_LSB 3
216
217/* Standard modes */
218enum {
219 MXL5005S_STANDARD_DVBT,
220 MXL5005S_STANDARD_ATSC,
221};
222#define MXL5005S_STANDARD_MODE_NUM 2
223
224/* Bandwidth modes */
225enum {
226 MXL5005S_BANDWIDTH_6MHZ = 6000000,
227 MXL5005S_BANDWIDTH_7MHZ = 7000000,
228 MXL5005S_BANDWIDTH_8MHZ = 8000000,
229};
230#define MXL5005S_BANDWIDTH_MODE_NUM 3
231
232/* MXL5005 Tuner Control Struct */
233struct TunerControl {
234 u16 Ctrl_Num; /* Control Number */
235 u16 size; /* Number of bits to represent Value */
236 u16 addr[25]; /* Array of Tuner Register Address for each bit pos */
237 u16 bit[25]; /* Array of bit pos in Reg Addr for each bit pos */
238 u16 val[25]; /* Binary representation of Value */
239};
240
241/* MXL5005 Tuner Struct */
242struct mxl5005s_state {
243 u8 Mode; /* 0: Analog Mode ; 1: Digital Mode */
244 u8 IF_Mode; /* for Analog Mode, 0: zero IF; 1: low IF */
245 u32 Chan_Bandwidth; /* filter channel bandwidth (6, 7, 8) */
246 u32 IF_OUT; /* Desired IF Out Frequency */
247 u16 IF_OUT_LOAD; /* IF Out Load Resistor (200/300 Ohms) */
248 u32 RF_IN; /* RF Input Frequency */
249 u32 Fxtal; /* XTAL Frequency */
250 u8 AGC_Mode; /* AGC Mode 0: Dual AGC; 1: Single AGC */
251 u16 TOP; /* Value: take over point */
252 u8 CLOCK_OUT; /* 0: turn off clk out; 1: turn on clock out */
253 u8 DIV_OUT; /* 4MHz or 16MHz */
254 u8 CAPSELECT; /* 0: disable On-Chip pulling cap; 1: enable */
255 u8 EN_RSSI; /* 0: disable RSSI; 1: enable RSSI */
256
257 /* Modulation Type; */
258 /* 0 - Default; 1 - DVB-T; 2 - ATSC; 3 - QAM; 4 - Analog Cable */
259 u8 Mod_Type;
260
261 /* Tracking Filter Type */
262 /* 0 - Default; 1 - Off; 2 - Type C; 3 - Type C-H */
263 u8 TF_Type;
264
265 /* Calculated Settings */
266 u32 RF_LO; /* Synth RF LO Frequency */
267 u32 IF_LO; /* Synth IF LO Frequency */
268 u32 TG_LO; /* Synth TG_LO Frequency */
269
270 /* Pointers to ControlName Arrays */
271 u16 Init_Ctrl_Num; /* Number of INIT Control Names */
272 struct TunerControl
273 Init_Ctrl[INITCTRL_NUM]; /* INIT Control Names Array Pointer */
274
275 u16 CH_Ctrl_Num; /* Number of CH Control Names */
276 struct TunerControl
277 CH_Ctrl[CHCTRL_NUM]; /* CH Control Name Array Pointer */
278
279 u16 MXL_Ctrl_Num; /* Number of MXL Control Names */
280 struct TunerControl
281 MXL_Ctrl[MXLCTRL_NUM]; /* MXL Control Name Array Pointer */
282
283 /* Pointer to Tuner Register Array */
284 u16 TunerRegs_Num; /* Number of Tuner Registers */
285 struct TunerReg
286 TunerRegs[TUNER_REGS_NUM]; /* Tuner Register Array Pointer */
287
288 /* Linux driver framework specific */
289 struct mxl5005s_config *config;
290 struct dvb_frontend *frontend;
291 struct i2c_adapter *i2c;
292
293 /* Cache values */
294 u32 current_mode;
295
296};
297
298static u16 MXL_GetMasterControl(u8 *MasterReg, int state);
299static u16 MXL_ControlWrite(struct dvb_frontend *fe, u16 ControlNum, u32 value);
300static u16 MXL_ControlRead(struct dvb_frontend *fe, u16 controlNum, u32 *value);
301static void MXL_RegWriteBit(struct dvb_frontend *fe, u8 address, u8 bit,
302 u8 bitVal);
303static u16 MXL_GetCHRegister(struct dvb_frontend *fe, u8 *RegNum,
304 u8 *RegVal, int *count);
305static u32 MXL_Ceiling(u32 value, u32 resolution);
306static u16 MXL_RegRead(struct dvb_frontend *fe, u8 RegNum, u8 *RegVal);
307static u16 MXL_ControlWrite_Group(struct dvb_frontend *fe, u16 controlNum,
308 u32 value, u16 controlGroup);
309static u16 MXL_SetGPIO(struct dvb_frontend *fe, u8 GPIO_Num, u8 GPIO_Val);
310static u16 MXL_GetInitRegister(struct dvb_frontend *fe, u8 *RegNum,
311 u8 *RegVal, int *count);
312static u32 MXL_GetXtalInt(u32 Xtal_Freq);
313static u16 MXL_TuneRF(struct dvb_frontend *fe, u32 RF_Freq);
314static void MXL_SynthIFLO_Calc(struct dvb_frontend *fe);
315static void MXL_SynthRFTGLO_Calc(struct dvb_frontend *fe);
316static u16 MXL_GetCHRegister_ZeroIF(struct dvb_frontend *fe, u8 *RegNum,
317 u8 *RegVal, int *count);
318static int mxl5005s_writeregs(struct dvb_frontend *fe, u8 *addrtable,
319 u8 *datatable, u8 len);
320static u16 MXL_IFSynthInit(struct dvb_frontend *fe);
321static int mxl5005s_AssignTunerMode(struct dvb_frontend *fe, u32 mod_type,
322 u32 bandwidth);
323static int mxl5005s_reconfigure(struct dvb_frontend *fe, u32 mod_type,
324 u32 bandwidth);
325
326/* ----------------------------------------------------------------
327 * Begin: Custom code salvaged from the Realtek driver.
328 * Copyright (C) 2008 Realtek
329 * Copyright (C) 2008 Jan Hoogenraad
330 * This code is placed under the terms of the GNU General Public License
331 *
332 * Released by Realtek under GPLv2.
333 * Thanks to Realtek for a lot of support we received !
334 *
335 * Revision: 080314 - original version
336 */
337
338static int mxl5005s_SetRfFreqHz(struct dvb_frontend *fe, unsigned long RfFreqHz)
339{
340 struct mxl5005s_state *state = fe->tuner_priv;
341 unsigned char AddrTable[MXL5005S_REG_WRITING_TABLE_LEN_MAX];
342 unsigned char ByteTable[MXL5005S_REG_WRITING_TABLE_LEN_MAX];
343 int TableLen;
344
345 u32 IfDivval = 0;
346 unsigned char MasterControlByte;
347
348 dprintk(1, "%s() freq=%ld\n", __func__, RfFreqHz);
349
350 /* Set MxL5005S tuner RF frequency according to example code. */
351
352 /* Tuner RF frequency setting stage 0 */
353 MXL_GetMasterControl(ByteTable, MC_SYNTH_RESET);
354 AddrTable[0] = MASTER_CONTROL_ADDR;
355 ByteTable[0] |= state->config->AgcMasterByte;
356
357 mxl5005s_writeregs(fe, AddrTable, ByteTable, 1);
358
359 /* Tuner RF frequency setting stage 1 */
360 MXL_TuneRF(fe, RfFreqHz);
361
362 MXL_ControlRead(fe, IF_DIVVAL, &IfDivval);
363
364 MXL_ControlWrite(fe, SEQ_FSM_PULSE, 0);
365 MXL_ControlWrite(fe, SEQ_EXTPOWERUP, 1);
366 MXL_ControlWrite(fe, IF_DIVVAL, 8);
367 MXL_GetCHRegister(fe, AddrTable, ByteTable, &TableLen);
368
369 MXL_GetMasterControl(&MasterControlByte, MC_LOAD_START);
370 AddrTable[TableLen] = MASTER_CONTROL_ADDR ;
371 ByteTable[TableLen] = MasterControlByte |
372 state->config->AgcMasterByte;
373 TableLen += 1;
374
375 mxl5005s_writeregs(fe, AddrTable, ByteTable, TableLen);
376
377 /* Wait 30 ms. */
378 msleep(150);
379
380 /* Tuner RF frequency setting stage 2 */
381 MXL_ControlWrite(fe, SEQ_FSM_PULSE, 1);
382 MXL_ControlWrite(fe, IF_DIVVAL, IfDivval);
383 MXL_GetCHRegister_ZeroIF(fe, AddrTable, ByteTable, &TableLen);
384
385 MXL_GetMasterControl(&MasterControlByte, MC_LOAD_START);
386 AddrTable[TableLen] = MASTER_CONTROL_ADDR ;
387 ByteTable[TableLen] = MasterControlByte |
388 state->config->AgcMasterByte ;
389 TableLen += 1;
390
391 mxl5005s_writeregs(fe, AddrTable, ByteTable, TableLen);
392
393 msleep(100);
394
395 return 0;
396}
397/* End: Custom code taken from the Realtek driver */
398
399/* ----------------------------------------------------------------
400 * Begin: Reference driver code found in the Realtek driver.
401 * Copyright (C) 2008 MaxLinear
402 */
403static u16 MXL5005_RegisterInit(struct dvb_frontend *fe)
404{
405 struct mxl5005s_state *state = fe->tuner_priv;
406 state->TunerRegs_Num = TUNER_REGS_NUM ;
407
408 state->TunerRegs[0].Reg_Num = 9 ;
409 state->TunerRegs[0].Reg_Val = 0x40 ;
410
411 state->TunerRegs[1].Reg_Num = 11 ;
412 state->TunerRegs[1].Reg_Val = 0x19 ;
413
414 state->TunerRegs[2].Reg_Num = 12 ;
415 state->TunerRegs[2].Reg_Val = 0x60 ;
416
417 state->TunerRegs[3].Reg_Num = 13 ;
418 state->TunerRegs[3].Reg_Val = 0x00 ;
419
420 state->TunerRegs[4].Reg_Num = 14 ;
421 state->TunerRegs[4].Reg_Val = 0x00 ;
422
423 state->TunerRegs[5].Reg_Num = 15 ;
424 state->TunerRegs[5].Reg_Val = 0xC0 ;
425
426 state->TunerRegs[6].Reg_Num = 16 ;
427 state->TunerRegs[6].Reg_Val = 0x00 ;
428
429 state->TunerRegs[7].Reg_Num = 17 ;
430 state->TunerRegs[7].Reg_Val = 0x00 ;
431
432 state->TunerRegs[8].Reg_Num = 18 ;
433 state->TunerRegs[8].Reg_Val = 0x00 ;
434
435 state->TunerRegs[9].Reg_Num = 19 ;
436 state->TunerRegs[9].Reg_Val = 0x34 ;
437
438 state->TunerRegs[10].Reg_Num = 21 ;
439 state->TunerRegs[10].Reg_Val = 0x00 ;
440
441 state->TunerRegs[11].Reg_Num = 22 ;
442 state->TunerRegs[11].Reg_Val = 0x6B ;
443
444 state->TunerRegs[12].Reg_Num = 23 ;
445 state->TunerRegs[12].Reg_Val = 0x35 ;
446
447 state->TunerRegs[13].Reg_Num = 24 ;
448 state->TunerRegs[13].Reg_Val = 0x70 ;
449
450 state->TunerRegs[14].Reg_Num = 25 ;
451 state->TunerRegs[14].Reg_Val = 0x3E ;
452
453 state->TunerRegs[15].Reg_Num = 26 ;
454 state->TunerRegs[15].Reg_Val = 0x82 ;
455
456 state->TunerRegs[16].Reg_Num = 31 ;
457 state->TunerRegs[16].Reg_Val = 0x00 ;
458
459 state->TunerRegs[17].Reg_Num = 32 ;
460 state->TunerRegs[17].Reg_Val = 0x40 ;
461
462 state->TunerRegs[18].Reg_Num = 33 ;
463 state->TunerRegs[18].Reg_Val = 0x53 ;
464
465 state->TunerRegs[19].Reg_Num = 34 ;
466 state->TunerRegs[19].Reg_Val = 0x81 ;
467
468 state->TunerRegs[20].Reg_Num = 35 ;
469 state->TunerRegs[20].Reg_Val = 0xC9 ;
470
471 state->TunerRegs[21].Reg_Num = 36 ;
472 state->TunerRegs[21].Reg_Val = 0x01 ;
473
474 state->TunerRegs[22].Reg_Num = 37 ;
475 state->TunerRegs[22].Reg_Val = 0x00 ;
476
477 state->TunerRegs[23].Reg_Num = 41 ;
478 state->TunerRegs[23].Reg_Val = 0x00 ;
479
480 state->TunerRegs[24].Reg_Num = 42 ;
481 state->TunerRegs[24].Reg_Val = 0xF8 ;
482
483 state->TunerRegs[25].Reg_Num = 43 ;
484 state->TunerRegs[25].Reg_Val = 0x43 ;
485
486 state->TunerRegs[26].Reg_Num = 44 ;
487 state->TunerRegs[26].Reg_Val = 0x20 ;
488
489 state->TunerRegs[27].Reg_Num = 45 ;
490 state->TunerRegs[27].Reg_Val = 0x80 ;
491
492 state->TunerRegs[28].Reg_Num = 46 ;
493 state->TunerRegs[28].Reg_Val = 0x88 ;
494
495 state->TunerRegs[29].Reg_Num = 47 ;
496 state->TunerRegs[29].Reg_Val = 0x86 ;
497
498 state->TunerRegs[30].Reg_Num = 48 ;
499 state->TunerRegs[30].Reg_Val = 0x00 ;
500
501 state->TunerRegs[31].Reg_Num = 49 ;
502 state->TunerRegs[31].Reg_Val = 0x00 ;
503
504 state->TunerRegs[32].Reg_Num = 53 ;
505 state->TunerRegs[32].Reg_Val = 0x94 ;
506
507 state->TunerRegs[33].Reg_Num = 54 ;
508 state->TunerRegs[33].Reg_Val = 0xFA ;
509
510 state->TunerRegs[34].Reg_Num = 55 ;
511 state->TunerRegs[34].Reg_Val = 0x92 ;
512
513 state->TunerRegs[35].Reg_Num = 56 ;
514 state->TunerRegs[35].Reg_Val = 0x80 ;
515
516 state->TunerRegs[36].Reg_Num = 57 ;
517 state->TunerRegs[36].Reg_Val = 0x41 ;
518
519 state->TunerRegs[37].Reg_Num = 58 ;
520 state->TunerRegs[37].Reg_Val = 0xDB ;
521
522 state->TunerRegs[38].Reg_Num = 59 ;
523 state->TunerRegs[38].Reg_Val = 0x00 ;
524
525 state->TunerRegs[39].Reg_Num = 60 ;
526 state->TunerRegs[39].Reg_Val = 0x00 ;
527
528 state->TunerRegs[40].Reg_Num = 61 ;
529 state->TunerRegs[40].Reg_Val = 0x00 ;
530
531 state->TunerRegs[41].Reg_Num = 62 ;
532 state->TunerRegs[41].Reg_Val = 0x00 ;
533
534 state->TunerRegs[42].Reg_Num = 65 ;
535 state->TunerRegs[42].Reg_Val = 0xF8 ;
536
537 state->TunerRegs[43].Reg_Num = 66 ;
538 state->TunerRegs[43].Reg_Val = 0xE4 ;
539
540 state->TunerRegs[44].Reg_Num = 67 ;
541 state->TunerRegs[44].Reg_Val = 0x90 ;
542
543 state->TunerRegs[45].Reg_Num = 68 ;
544 state->TunerRegs[45].Reg_Val = 0xC0 ;
545
546 state->TunerRegs[46].Reg_Num = 69 ;
547 state->TunerRegs[46].Reg_Val = 0x01 ;
548
549 state->TunerRegs[47].Reg_Num = 70 ;
550 state->TunerRegs[47].Reg_Val = 0x50 ;
551
552 state->TunerRegs[48].Reg_Num = 71 ;
553 state->TunerRegs[48].Reg_Val = 0x06 ;
554
555 state->TunerRegs[49].Reg_Num = 72 ;
556 state->TunerRegs[49].Reg_Val = 0x00 ;
557
558 state->TunerRegs[50].Reg_Num = 73 ;
559 state->TunerRegs[50].Reg_Val = 0x20 ;
560
561 state->TunerRegs[51].Reg_Num = 76 ;
562 state->TunerRegs[51].Reg_Val = 0xBB ;
563
564 state->TunerRegs[52].Reg_Num = 77 ;
565 state->TunerRegs[52].Reg_Val = 0x13 ;
566
567 state->TunerRegs[53].Reg_Num = 81 ;
568 state->TunerRegs[53].Reg_Val = 0x04 ;
569
570 state->TunerRegs[54].Reg_Num = 82 ;
571 state->TunerRegs[54].Reg_Val = 0x75 ;
572
573 state->TunerRegs[55].Reg_Num = 83 ;
574 state->TunerRegs[55].Reg_Val = 0x00 ;
575
576 state->TunerRegs[56].Reg_Num = 84 ;
577 state->TunerRegs[56].Reg_Val = 0x00 ;
578
579 state->TunerRegs[57].Reg_Num = 85 ;
580 state->TunerRegs[57].Reg_Val = 0x00 ;
581
582 state->TunerRegs[58].Reg_Num = 91 ;
583 state->TunerRegs[58].Reg_Val = 0x70 ;
584
585 state->TunerRegs[59].Reg_Num = 92 ;
586 state->TunerRegs[59].Reg_Val = 0x00 ;
587
588 state->TunerRegs[60].Reg_Num = 93 ;
589 state->TunerRegs[60].Reg_Val = 0x00 ;
590
591 state->TunerRegs[61].Reg_Num = 94 ;
592 state->TunerRegs[61].Reg_Val = 0x00 ;
593
594 state->TunerRegs[62].Reg_Num = 95 ;
595 state->TunerRegs[62].Reg_Val = 0x0C ;
596
597 state->TunerRegs[63].Reg_Num = 96 ;
598 state->TunerRegs[63].Reg_Val = 0x00 ;
599
600 state->TunerRegs[64].Reg_Num = 97 ;
601 state->TunerRegs[64].Reg_Val = 0x00 ;
602
603 state->TunerRegs[65].Reg_Num = 98 ;
604 state->TunerRegs[65].Reg_Val = 0xE2 ;
605
606 state->TunerRegs[66].Reg_Num = 99 ;
607 state->TunerRegs[66].Reg_Val = 0x00 ;
608
609 state->TunerRegs[67].Reg_Num = 100 ;
610 state->TunerRegs[67].Reg_Val = 0x00 ;
611
612 state->TunerRegs[68].Reg_Num = 101 ;
613 state->TunerRegs[68].Reg_Val = 0x12 ;
614
615 state->TunerRegs[69].Reg_Num = 102 ;
616 state->TunerRegs[69].Reg_Val = 0x80 ;
617
618 state->TunerRegs[70].Reg_Num = 103 ;
619 state->TunerRegs[70].Reg_Val = 0x32 ;
620
621 state->TunerRegs[71].Reg_Num = 104 ;
622 state->TunerRegs[71].Reg_Val = 0xB4 ;
623
624 state->TunerRegs[72].Reg_Num = 105 ;
625 state->TunerRegs[72].Reg_Val = 0x60 ;
626
627 state->TunerRegs[73].Reg_Num = 106 ;
628 state->TunerRegs[73].Reg_Val = 0x83 ;
629
630 state->TunerRegs[74].Reg_Num = 107 ;
631 state->TunerRegs[74].Reg_Val = 0x84 ;
632
633 state->TunerRegs[75].Reg_Num = 108 ;
634 state->TunerRegs[75].Reg_Val = 0x9C ;
635
636 state->TunerRegs[76].Reg_Num = 109 ;
637 state->TunerRegs[76].Reg_Val = 0x02 ;
638
639 state->TunerRegs[77].Reg_Num = 110 ;
640 state->TunerRegs[77].Reg_Val = 0x81 ;
641
642 state->TunerRegs[78].Reg_Num = 111 ;
643 state->TunerRegs[78].Reg_Val = 0xC0 ;
644
645 state->TunerRegs[79].Reg_Num = 112 ;
646 state->TunerRegs[79].Reg_Val = 0x10 ;
647
648 state->TunerRegs[80].Reg_Num = 131 ;
649 state->TunerRegs[80].Reg_Val = 0x8A ;
650
651 state->TunerRegs[81].Reg_Num = 132 ;
652 state->TunerRegs[81].Reg_Val = 0x10 ;
653
654 state->TunerRegs[82].Reg_Num = 133 ;
655 state->TunerRegs[82].Reg_Val = 0x24 ;
656
657 state->TunerRegs[83].Reg_Num = 134 ;
658 state->TunerRegs[83].Reg_Val = 0x00 ;
659
660 state->TunerRegs[84].Reg_Num = 135 ;
661 state->TunerRegs[84].Reg_Val = 0x00 ;
662
663 state->TunerRegs[85].Reg_Num = 136 ;
664 state->TunerRegs[85].Reg_Val = 0x7E ;
665
666 state->TunerRegs[86].Reg_Num = 137 ;
667 state->TunerRegs[86].Reg_Val = 0x40 ;
668
669 state->TunerRegs[87].Reg_Num = 138 ;
670 state->TunerRegs[87].Reg_Val = 0x38 ;
671
672 state->TunerRegs[88].Reg_Num = 146 ;
673 state->TunerRegs[88].Reg_Val = 0xF6 ;
674
675 state->TunerRegs[89].Reg_Num = 147 ;
676 state->TunerRegs[89].Reg_Val = 0x1A ;
677
678 state->TunerRegs[90].Reg_Num = 148 ;
679 state->TunerRegs[90].Reg_Val = 0x62 ;
680
681 state->TunerRegs[91].Reg_Num = 149 ;
682 state->TunerRegs[91].Reg_Val = 0x33 ;
683
684 state->TunerRegs[92].Reg_Num = 150 ;
685 state->TunerRegs[92].Reg_Val = 0x80 ;
686
687 state->TunerRegs[93].Reg_Num = 156 ;
688 state->TunerRegs[93].Reg_Val = 0x56 ;
689
690 state->TunerRegs[94].Reg_Num = 157 ;
691 state->TunerRegs[94].Reg_Val = 0x17 ;
692
693 state->TunerRegs[95].Reg_Num = 158 ;
694 state->TunerRegs[95].Reg_Val = 0xA9 ;
695
696 state->TunerRegs[96].Reg_Num = 159 ;
697 state->TunerRegs[96].Reg_Val = 0x00 ;
698
699 state->TunerRegs[97].Reg_Num = 160 ;
700 state->TunerRegs[97].Reg_Val = 0x00 ;
701
702 state->TunerRegs[98].Reg_Num = 161 ;
703 state->TunerRegs[98].Reg_Val = 0x00 ;
704
705 state->TunerRegs[99].Reg_Num = 162 ;
706 state->TunerRegs[99].Reg_Val = 0x40 ;
707
708 state->TunerRegs[100].Reg_Num = 166 ;
709 state->TunerRegs[100].Reg_Val = 0xAE ;
710
711 state->TunerRegs[101].Reg_Num = 167 ;
712 state->TunerRegs[101].Reg_Val = 0x1B ;
713
714 state->TunerRegs[102].Reg_Num = 168 ;
715 state->TunerRegs[102].Reg_Val = 0xF2 ;
716
717 state->TunerRegs[103].Reg_Num = 195 ;
718 state->TunerRegs[103].Reg_Val = 0x00 ;
719
720 return 0 ;
721}
722
723static u16 MXL5005_ControlInit(struct dvb_frontend *fe)
724{
725 struct mxl5005s_state *state = fe->tuner_priv;
726 state->Init_Ctrl_Num = INITCTRL_NUM;
727
728 state->Init_Ctrl[0].Ctrl_Num = DN_IQTN_AMP_CUT ;
729 state->Init_Ctrl[0].size = 1 ;
730 state->Init_Ctrl[0].addr[0] = 73;
731 state->Init_Ctrl[0].bit[0] = 7;
732 state->Init_Ctrl[0].val[0] = 0;
733
734 state->Init_Ctrl[1].Ctrl_Num = BB_MODE ;
735 state->Init_Ctrl[1].size = 1 ;
736 state->Init_Ctrl[1].addr[0] = 53;
737 state->Init_Ctrl[1].bit[0] = 2;
738 state->Init_Ctrl[1].val[0] = 1;
739
740 state->Init_Ctrl[2].Ctrl_Num = BB_BUF ;
741 state->Init_Ctrl[2].size = 2 ;
742 state->Init_Ctrl[2].addr[0] = 53;
743 state->Init_Ctrl[2].bit[0] = 1;
744 state->Init_Ctrl[2].val[0] = 0;
745 state->Init_Ctrl[2].addr[1] = 57;
746 state->Init_Ctrl[2].bit[1] = 0;
747 state->Init_Ctrl[2].val[1] = 1;
748
749 state->Init_Ctrl[3].Ctrl_Num = BB_BUF_OA ;
750 state->Init_Ctrl[3].size = 1 ;
751 state->Init_Ctrl[3].addr[0] = 53;
752 state->Init_Ctrl[3].bit[0] = 0;
753 state->Init_Ctrl[3].val[0] = 0;
754
755 state->Init_Ctrl[4].Ctrl_Num = BB_ALPF_BANDSELECT ;
756 state->Init_Ctrl[4].size = 3 ;
757 state->Init_Ctrl[4].addr[0] = 53;
758 state->Init_Ctrl[4].bit[0] = 5;
759 state->Init_Ctrl[4].val[0] = 0;
760 state->Init_Ctrl[4].addr[1] = 53;
761 state->Init_Ctrl[4].bit[1] = 6;
762 state->Init_Ctrl[4].val[1] = 0;
763 state->Init_Ctrl[4].addr[2] = 53;
764 state->Init_Ctrl[4].bit[2] = 7;
765 state->Init_Ctrl[4].val[2] = 1;
766
767 state->Init_Ctrl[5].Ctrl_Num = BB_IQSWAP ;
768 state->Init_Ctrl[5].size = 1 ;
769 state->Init_Ctrl[5].addr[0] = 59;
770 state->Init_Ctrl[5].bit[0] = 0;
771 state->Init_Ctrl[5].val[0] = 0;
772
773 state->Init_Ctrl[6].Ctrl_Num = BB_DLPF_BANDSEL ;
774 state->Init_Ctrl[6].size = 2 ;
775 state->Init_Ctrl[6].addr[0] = 53;
776 state->Init_Ctrl[6].bit[0] = 3;
777 state->Init_Ctrl[6].val[0] = 0;
778 state->Init_Ctrl[6].addr[1] = 53;
779 state->Init_Ctrl[6].bit[1] = 4;
780 state->Init_Ctrl[6].val[1] = 1;
781
782 state->Init_Ctrl[7].Ctrl_Num = RFSYN_CHP_GAIN ;
783 state->Init_Ctrl[7].size = 4 ;
784 state->Init_Ctrl[7].addr[0] = 22;
785 state->Init_Ctrl[7].bit[0] = 4;
786 state->Init_Ctrl[7].val[0] = 0;
787 state->Init_Ctrl[7].addr[1] = 22;
788 state->Init_Ctrl[7].bit[1] = 5;
789 state->Init_Ctrl[7].val[1] = 1;
790 state->Init_Ctrl[7].addr[2] = 22;
791 state->Init_Ctrl[7].bit[2] = 6;
792 state->Init_Ctrl[7].val[2] = 1;
793 state->Init_Ctrl[7].addr[3] = 22;
794 state->Init_Ctrl[7].bit[3] = 7;
795 state->Init_Ctrl[7].val[3] = 0;
796
797 state->Init_Ctrl[8].Ctrl_Num = RFSYN_EN_CHP_HIGAIN ;
798 state->Init_Ctrl[8].size = 1 ;
799 state->Init_Ctrl[8].addr[0] = 22;
800 state->Init_Ctrl[8].bit[0] = 2;
801 state->Init_Ctrl[8].val[0] = 0;
802
803 state->Init_Ctrl[9].Ctrl_Num = AGC_IF ;
804 state->Init_Ctrl[9].size = 4 ;
805 state->Init_Ctrl[9].addr[0] = 76;
806 state->Init_Ctrl[9].bit[0] = 0;
807 state->Init_Ctrl[9].val[0] = 1;
808 state->Init_Ctrl[9].addr[1] = 76;
809 state->Init_Ctrl[9].bit[1] = 1;
810 state->Init_Ctrl[9].val[1] = 1;
811 state->Init_Ctrl[9].addr[2] = 76;
812 state->Init_Ctrl[9].bit[2] = 2;
813 state->Init_Ctrl[9].val[2] = 0;
814 state->Init_Ctrl[9].addr[3] = 76;
815 state->Init_Ctrl[9].bit[3] = 3;
816 state->Init_Ctrl[9].val[3] = 1;
817
818 state->Init_Ctrl[10].Ctrl_Num = AGC_RF ;
819 state->Init_Ctrl[10].size = 4 ;
820 state->Init_Ctrl[10].addr[0] = 76;
821 state->Init_Ctrl[10].bit[0] = 4;
822 state->Init_Ctrl[10].val[0] = 1;
823 state->Init_Ctrl[10].addr[1] = 76;
824 state->Init_Ctrl[10].bit[1] = 5;
825 state->Init_Ctrl[10].val[1] = 1;
826 state->Init_Ctrl[10].addr[2] = 76;
827 state->Init_Ctrl[10].bit[2] = 6;
828 state->Init_Ctrl[10].val[2] = 0;
829 state->Init_Ctrl[10].addr[3] = 76;
830 state->Init_Ctrl[10].bit[3] = 7;
831 state->Init_Ctrl[10].val[3] = 1;
832
833 state->Init_Ctrl[11].Ctrl_Num = IF_DIVVAL ;
834 state->Init_Ctrl[11].size = 5 ;
835 state->Init_Ctrl[11].addr[0] = 43;
836 state->Init_Ctrl[11].bit[0] = 3;
837 state->Init_Ctrl[11].val[0] = 0;
838 state->Init_Ctrl[11].addr[1] = 43;
839 state->Init_Ctrl[11].bit[1] = 4;
840 state->Init_Ctrl[11].val[1] = 0;
841 state->Init_Ctrl[11].addr[2] = 43;
842 state->Init_Ctrl[11].bit[2] = 5;
843 state->Init_Ctrl[11].val[2] = 0;
844 state->Init_Ctrl[11].addr[3] = 43;
845 state->Init_Ctrl[11].bit[3] = 6;
846 state->Init_Ctrl[11].val[3] = 1;
847 state->Init_Ctrl[11].addr[4] = 43;
848 state->Init_Ctrl[11].bit[4] = 7;
849 state->Init_Ctrl[11].val[4] = 0;
850
851 state->Init_Ctrl[12].Ctrl_Num = IF_VCO_BIAS ;
852 state->Init_Ctrl[12].size = 6 ;
853 state->Init_Ctrl[12].addr[0] = 44;
854 state->Init_Ctrl[12].bit[0] = 2;
855 state->Init_Ctrl[12].val[0] = 0;
856 state->Init_Ctrl[12].addr[1] = 44;
857 state->Init_Ctrl[12].bit[1] = 3;
858 state->Init_Ctrl[12].val[1] = 0;
859 state->Init_Ctrl[12].addr[2] = 44;
860 state->Init_Ctrl[12].bit[2] = 4;
861 state->Init_Ctrl[12].val[2] = 0;
862 state->Init_Ctrl[12].addr[3] = 44;
863 state->Init_Ctrl[12].bit[3] = 5;
864 state->Init_Ctrl[12].val[3] = 1;
865 state->Init_Ctrl[12].addr[4] = 44;
866 state->Init_Ctrl[12].bit[4] = 6;
867 state->Init_Ctrl[12].val[4] = 0;
868 state->Init_Ctrl[12].addr[5] = 44;
869 state->Init_Ctrl[12].bit[5] = 7;
870 state->Init_Ctrl[12].val[5] = 0;
871
872 state->Init_Ctrl[13].Ctrl_Num = CHCAL_INT_MOD_IF ;
873 state->Init_Ctrl[13].size = 7 ;
874 state->Init_Ctrl[13].addr[0] = 11;
875 state->Init_Ctrl[13].bit[0] = 0;
876 state->Init_Ctrl[13].val[0] = 1;
877 state->Init_Ctrl[13].addr[1] = 11;
878 state->Init_Ctrl[13].bit[1] = 1;
879 state->Init_Ctrl[13].val[1] = 0;
880 state->Init_Ctrl[13].addr[2] = 11;
881 state->Init_Ctrl[13].bit[2] = 2;
882 state->Init_Ctrl[13].val[2] = 0;
883 state->Init_Ctrl[13].addr[3] = 11;
884 state->Init_Ctrl[13].bit[3] = 3;
885 state->Init_Ctrl[13].val[3] = 1;
886 state->Init_Ctrl[13].addr[4] = 11;
887 state->Init_Ctrl[13].bit[4] = 4;
888 state->Init_Ctrl[13].val[4] = 1;
889 state->Init_Ctrl[13].addr[5] = 11;
890 state->Init_Ctrl[13].bit[5] = 5;
891 state->Init_Ctrl[13].val[5] = 0;
892 state->Init_Ctrl[13].addr[6] = 11;
893 state->Init_Ctrl[13].bit[6] = 6;
894 state->Init_Ctrl[13].val[6] = 0;
895
896 state->Init_Ctrl[14].Ctrl_Num = CHCAL_FRAC_MOD_IF ;
897 state->Init_Ctrl[14].size = 16 ;
898 state->Init_Ctrl[14].addr[0] = 13;
899 state->Init_Ctrl[14].bit[0] = 0;
900 state->Init_Ctrl[14].val[0] = 0;
901 state->Init_Ctrl[14].addr[1] = 13;
902 state->Init_Ctrl[14].bit[1] = 1;
903 state->Init_Ctrl[14].val[1] = 0;
904 state->Init_Ctrl[14].addr[2] = 13;
905 state->Init_Ctrl[14].bit[2] = 2;
906 state->Init_Ctrl[14].val[2] = 0;
907 state->Init_Ctrl[14].addr[3] = 13;
908 state->Init_Ctrl[14].bit[3] = 3;
909 state->Init_Ctrl[14].val[3] = 0;
910 state->Init_Ctrl[14].addr[4] = 13;
911 state->Init_Ctrl[14].bit[4] = 4;
912 state->Init_Ctrl[14].val[4] = 0;
913 state->Init_Ctrl[14].addr[5] = 13;
914 state->Init_Ctrl[14].bit[5] = 5;
915 state->Init_Ctrl[14].val[5] = 0;
916 state->Init_Ctrl[14].addr[6] = 13;
917 state->Init_Ctrl[14].bit[6] = 6;
918 state->Init_Ctrl[14].val[6] = 0;
919 state->Init_Ctrl[14].addr[7] = 13;
920 state->Init_Ctrl[14].bit[7] = 7;
921 state->Init_Ctrl[14].val[7] = 0;
922 state->Init_Ctrl[14].addr[8] = 12;
923 state->Init_Ctrl[14].bit[8] = 0;
924 state->Init_Ctrl[14].val[8] = 0;
925 state->Init_Ctrl[14].addr[9] = 12;
926 state->Init_Ctrl[14].bit[9] = 1;
927 state->Init_Ctrl[14].val[9] = 0;
928 state->Init_Ctrl[14].addr[10] = 12;
929 state->Init_Ctrl[14].bit[10] = 2;
930 state->Init_Ctrl[14].val[10] = 0;
931 state->Init_Ctrl[14].addr[11] = 12;
932 state->Init_Ctrl[14].bit[11] = 3;
933 state->Init_Ctrl[14].val[11] = 0;
934 state->Init_Ctrl[14].addr[12] = 12;
935 state->Init_Ctrl[14].bit[12] = 4;
936 state->Init_Ctrl[14].val[12] = 0;
937 state->Init_Ctrl[14].addr[13] = 12;
938 state->Init_Ctrl[14].bit[13] = 5;
939 state->Init_Ctrl[14].val[13] = 1;
940 state->Init_Ctrl[14].addr[14] = 12;
941 state->Init_Ctrl[14].bit[14] = 6;
942 state->Init_Ctrl[14].val[14] = 1;
943 state->Init_Ctrl[14].addr[15] = 12;
944 state->Init_Ctrl[14].bit[15] = 7;
945 state->Init_Ctrl[14].val[15] = 0;
946
947 state->Init_Ctrl[15].Ctrl_Num = DRV_RES_SEL ;
948 state->Init_Ctrl[15].size = 3 ;
949 state->Init_Ctrl[15].addr[0] = 147;
950 state->Init_Ctrl[15].bit[0] = 2;
951 state->Init_Ctrl[15].val[0] = 0;
952 state->Init_Ctrl[15].addr[1] = 147;
953 state->Init_Ctrl[15].bit[1] = 3;
954 state->Init_Ctrl[15].val[1] = 1;
955 state->Init_Ctrl[15].addr[2] = 147;
956 state->Init_Ctrl[15].bit[2] = 4;
957 state->Init_Ctrl[15].val[2] = 1;
958
959 state->Init_Ctrl[16].Ctrl_Num = I_DRIVER ;
960 state->Init_Ctrl[16].size = 2 ;
961 state->Init_Ctrl[16].addr[0] = 147;
962 state->Init_Ctrl[16].bit[0] = 0;
963 state->Init_Ctrl[16].val[0] = 0;
964 state->Init_Ctrl[16].addr[1] = 147;
965 state->Init_Ctrl[16].bit[1] = 1;
966 state->Init_Ctrl[16].val[1] = 1;
967
968 state->Init_Ctrl[17].Ctrl_Num = EN_AAF ;
969 state->Init_Ctrl[17].size = 1 ;
970 state->Init_Ctrl[17].addr[0] = 147;
971 state->Init_Ctrl[17].bit[0] = 7;
972 state->Init_Ctrl[17].val[0] = 0;
973
974 state->Init_Ctrl[18].Ctrl_Num = EN_3P ;
975 state->Init_Ctrl[18].size = 1 ;
976 state->Init_Ctrl[18].addr[0] = 147;
977 state->Init_Ctrl[18].bit[0] = 6;
978 state->Init_Ctrl[18].val[0] = 0;
979
980 state->Init_Ctrl[19].Ctrl_Num = EN_AUX_3P ;
981 state->Init_Ctrl[19].size = 1 ;
982 state->Init_Ctrl[19].addr[0] = 156;
983 state->Init_Ctrl[19].bit[0] = 0;
984 state->Init_Ctrl[19].val[0] = 0;
985
986 state->Init_Ctrl[20].Ctrl_Num = SEL_AAF_BAND ;
987 state->Init_Ctrl[20].size = 1 ;
988 state->Init_Ctrl[20].addr[0] = 147;
989 state->Init_Ctrl[20].bit[0] = 5;
990 state->Init_Ctrl[20].val[0] = 0;
991
992 state->Init_Ctrl[21].Ctrl_Num = SEQ_ENCLK16_CLK_OUT ;
993 state->Init_Ctrl[21].size = 1 ;
994 state->Init_Ctrl[21].addr[0] = 137;
995 state->Init_Ctrl[21].bit[0] = 4;
996 state->Init_Ctrl[21].val[0] = 0;
997
998 state->Init_Ctrl[22].Ctrl_Num = SEQ_SEL4_16B ;
999 state->Init_Ctrl[22].size = 1 ;
1000 state->Init_Ctrl[22].addr[0] = 137;
1001 state->Init_Ctrl[22].bit[0] = 7;
1002 state->Init_Ctrl[22].val[0] = 0;
1003
1004 state->Init_Ctrl[23].Ctrl_Num = XTAL_CAPSELECT ;
1005 state->Init_Ctrl[23].size = 1 ;
1006 state->Init_Ctrl[23].addr[0] = 91;
1007 state->Init_Ctrl[23].bit[0] = 5;
1008 state->Init_Ctrl[23].val[0] = 1;
1009
1010 state->Init_Ctrl[24].Ctrl_Num = IF_SEL_DBL ;
1011 state->Init_Ctrl[24].size = 1 ;
1012 state->Init_Ctrl[24].addr[0] = 43;
1013 state->Init_Ctrl[24].bit[0] = 0;
1014 state->Init_Ctrl[24].val[0] = 1;
1015
1016 state->Init_Ctrl[25].Ctrl_Num = RFSYN_R_DIV ;
1017 state->Init_Ctrl[25].size = 2 ;
1018 state->Init_Ctrl[25].addr[0] = 22;
1019 state->Init_Ctrl[25].bit[0] = 0;
1020 state->Init_Ctrl[25].val[0] = 1;
1021 state->Init_Ctrl[25].addr[1] = 22;
1022 state->Init_Ctrl[25].bit[1] = 1;
1023 state->Init_Ctrl[25].val[1] = 1;
1024
1025 state->Init_Ctrl[26].Ctrl_Num = SEQ_EXTSYNTHCALIF ;
1026 state->Init_Ctrl[26].size = 1 ;
1027 state->Init_Ctrl[26].addr[0] = 134;
1028 state->Init_Ctrl[26].bit[0] = 2;
1029 state->Init_Ctrl[26].val[0] = 0;
1030
1031 state->Init_Ctrl[27].Ctrl_Num = SEQ_EXTDCCAL ;
1032 state->Init_Ctrl[27].size = 1 ;
1033 state->Init_Ctrl[27].addr[0] = 137;
1034 state->Init_Ctrl[27].bit[0] = 3;
1035 state->Init_Ctrl[27].val[0] = 0;
1036
1037 state->Init_Ctrl[28].Ctrl_Num = AGC_EN_RSSI ;
1038 state->Init_Ctrl[28].size = 1 ;
1039 state->Init_Ctrl[28].addr[0] = 77;
1040 state->Init_Ctrl[28].bit[0] = 7;
1041 state->Init_Ctrl[28].val[0] = 0;
1042
1043 state->Init_Ctrl[29].Ctrl_Num = RFA_ENCLKRFAGC ;
1044 state->Init_Ctrl[29].size = 1 ;
1045 state->Init_Ctrl[29].addr[0] = 166;
1046 state->Init_Ctrl[29].bit[0] = 7;
1047 state->Init_Ctrl[29].val[0] = 1;
1048
1049 state->Init_Ctrl[30].Ctrl_Num = RFA_RSSI_REFH ;
1050 state->Init_Ctrl[30].size = 3 ;
1051 state->Init_Ctrl[30].addr[0] = 166;
1052 state->Init_Ctrl[30].bit[0] = 0;
1053 state->Init_Ctrl[30].val[0] = 0;
1054 state->Init_Ctrl[30].addr[1] = 166;
1055 state->Init_Ctrl[30].bit[1] = 1;
1056 state->Init_Ctrl[30].val[1] = 1;
1057 state->Init_Ctrl[30].addr[2] = 166;
1058 state->Init_Ctrl[30].bit[2] = 2;
1059 state->Init_Ctrl[30].val[2] = 1;
1060
1061 state->Init_Ctrl[31].Ctrl_Num = RFA_RSSI_REF ;
1062 state->Init_Ctrl[31].size = 3 ;
1063 state->Init_Ctrl[31].addr[0] = 166;
1064 state->Init_Ctrl[31].bit[0] = 3;
1065 state->Init_Ctrl[31].val[0] = 1;
1066 state->Init_Ctrl[31].addr[1] = 166;
1067 state->Init_Ctrl[31].bit[1] = 4;
1068 state->Init_Ctrl[31].val[1] = 0;
1069 state->Init_Ctrl[31].addr[2] = 166;
1070 state->Init_Ctrl[31].bit[2] = 5;
1071 state->Init_Ctrl[31].val[2] = 1;
1072
1073 state->Init_Ctrl[32].Ctrl_Num = RFA_RSSI_REFL ;
1074 state->Init_Ctrl[32].size = 3 ;
1075 state->Init_Ctrl[32].addr[0] = 167;
1076 state->Init_Ctrl[32].bit[0] = 0;
1077 state->Init_Ctrl[32].val[0] = 1;
1078 state->Init_Ctrl[32].addr[1] = 167;
1079 state->Init_Ctrl[32].bit[1] = 1;
1080 state->Init_Ctrl[32].val[1] = 1;
1081 state->Init_Ctrl[32].addr[2] = 167;
1082 state->Init_Ctrl[32].bit[2] = 2;
1083 state->Init_Ctrl[32].val[2] = 0;
1084
1085 state->Init_Ctrl[33].Ctrl_Num = RFA_FLR ;
1086 state->Init_Ctrl[33].size = 4 ;
1087 state->Init_Ctrl[33].addr[0] = 168;
1088 state->Init_Ctrl[33].bit[0] = 0;
1089 state->Init_Ctrl[33].val[0] = 0;
1090 state->Init_Ctrl[33].addr[1] = 168;
1091 state->Init_Ctrl[33].bit[1] = 1;
1092 state->Init_Ctrl[33].val[1] = 1;
1093 state->Init_Ctrl[33].addr[2] = 168;
1094 state->Init_Ctrl[33].bit[2] = 2;
1095 state->Init_Ctrl[33].val[2] = 0;
1096 state->Init_Ctrl[33].addr[3] = 168;
1097 state->Init_Ctrl[33].bit[3] = 3;
1098 state->Init_Ctrl[33].val[3] = 0;
1099
1100 state->Init_Ctrl[34].Ctrl_Num = RFA_CEIL ;
1101 state->Init_Ctrl[34].size = 4 ;
1102 state->Init_Ctrl[34].addr[0] = 168;
1103 state->Init_Ctrl[34].bit[0] = 4;
1104 state->Init_Ctrl[34].val[0] = 1;
1105 state->Init_Ctrl[34].addr[1] = 168;
1106 state->Init_Ctrl[34].bit[1] = 5;
1107 state->Init_Ctrl[34].val[1] = 1;
1108 state->Init_Ctrl[34].addr[2] = 168;
1109 state->Init_Ctrl[34].bit[2] = 6;
1110 state->Init_Ctrl[34].val[2] = 1;
1111 state->Init_Ctrl[34].addr[3] = 168;
1112 state->Init_Ctrl[34].bit[3] = 7;
1113 state->Init_Ctrl[34].val[3] = 1;
1114
1115 state->Init_Ctrl[35].Ctrl_Num = SEQ_EXTIQFSMPULSE ;
1116 state->Init_Ctrl[35].size = 1 ;
1117 state->Init_Ctrl[35].addr[0] = 135;
1118 state->Init_Ctrl[35].bit[0] = 0;
1119 state->Init_Ctrl[35].val[0] = 0;
1120
1121 state->Init_Ctrl[36].Ctrl_Num = OVERRIDE_1 ;
1122 state->Init_Ctrl[36].size = 1 ;
1123 state->Init_Ctrl[36].addr[0] = 56;
1124 state->Init_Ctrl[36].bit[0] = 3;
1125 state->Init_Ctrl[36].val[0] = 0;
1126
1127 state->Init_Ctrl[37].Ctrl_Num = BB_INITSTATE_DLPF_TUNE ;
1128 state->Init_Ctrl[37].size = 7 ;
1129 state->Init_Ctrl[37].addr[0] = 59;
1130 state->Init_Ctrl[37].bit[0] = 1;
1131 state->Init_Ctrl[37].val[0] = 0;
1132 state->Init_Ctrl[37].addr[1] = 59;
1133 state->Init_Ctrl[37].bit[1] = 2;
1134 state->Init_Ctrl[37].val[1] = 0;
1135 state->Init_Ctrl[37].addr[2] = 59;
1136 state->Init_Ctrl[37].bit[2] = 3;
1137 state->Init_Ctrl[37].val[2] = 0;
1138 state->Init_Ctrl[37].addr[3] = 59;
1139 state->Init_Ctrl[37].bit[3] = 4;
1140 state->Init_Ctrl[37].val[3] = 0;
1141 state->Init_Ctrl[37].addr[4] = 59;
1142 state->Init_Ctrl[37].bit[4] = 5;
1143 state->Init_Ctrl[37].val[4] = 0;
1144 state->Init_Ctrl[37].addr[5] = 59;
1145 state->Init_Ctrl[37].bit[5] = 6;
1146 state->Init_Ctrl[37].val[5] = 0;
1147 state->Init_Ctrl[37].addr[6] = 59;
1148 state->Init_Ctrl[37].bit[6] = 7;
1149 state->Init_Ctrl[37].val[6] = 0;
1150
1151 state->Init_Ctrl[38].Ctrl_Num = TG_R_DIV ;
1152 state->Init_Ctrl[38].size = 6 ;
1153 state->Init_Ctrl[38].addr[0] = 32;
1154 state->Init_Ctrl[38].bit[0] = 2;
1155 state->Init_Ctrl[38].val[0] = 0;
1156 state->Init_Ctrl[38].addr[1] = 32;
1157 state->Init_Ctrl[38].bit[1] = 3;
1158 state->Init_Ctrl[38].val[1] = 0;
1159 state->Init_Ctrl[38].addr[2] = 32;
1160 state->Init_Ctrl[38].bit[2] = 4;
1161 state->Init_Ctrl[38].val[2] = 0;
1162 state->Init_Ctrl[38].addr[3] = 32;
1163 state->Init_Ctrl[38].bit[3] = 5;
1164 state->Init_Ctrl[38].val[3] = 0;
1165 state->Init_Ctrl[38].addr[4] = 32;
1166 state->Init_Ctrl[38].bit[4] = 6;
1167 state->Init_Ctrl[38].val[4] = 1;
1168 state->Init_Ctrl[38].addr[5] = 32;
1169 state->Init_Ctrl[38].bit[5] = 7;
1170 state->Init_Ctrl[38].val[5] = 0;
1171
1172 state->Init_Ctrl[39].Ctrl_Num = EN_CHP_LIN_B ;
1173 state->Init_Ctrl[39].size = 1 ;
1174 state->Init_Ctrl[39].addr[0] = 25;
1175 state->Init_Ctrl[39].bit[0] = 3;
1176 state->Init_Ctrl[39].val[0] = 1;
1177
1178
1179 state->CH_Ctrl_Num = CHCTRL_NUM ;
1180
1181 state->CH_Ctrl[0].Ctrl_Num = DN_POLY ;
1182 state->CH_Ctrl[0].size = 2 ;
1183 state->CH_Ctrl[0].addr[0] = 68;
1184 state->CH_Ctrl[0].bit[0] = 6;
1185 state->CH_Ctrl[0].val[0] = 1;
1186 state->CH_Ctrl[0].addr[1] = 68;
1187 state->CH_Ctrl[0].bit[1] = 7;
1188 state->CH_Ctrl[0].val[1] = 1;
1189
1190 state->CH_Ctrl[1].Ctrl_Num = DN_RFGAIN ;
1191 state->CH_Ctrl[1].size = 2 ;
1192 state->CH_Ctrl[1].addr[0] = 70;
1193 state->CH_Ctrl[1].bit[0] = 6;
1194 state->CH_Ctrl[1].val[0] = 1;
1195 state->CH_Ctrl[1].addr[1] = 70;
1196 state->CH_Ctrl[1].bit[1] = 7;
1197 state->CH_Ctrl[1].val[1] = 0;
1198
1199 state->CH_Ctrl[2].Ctrl_Num = DN_CAP_RFLPF ;
1200 state->CH_Ctrl[2].size = 9 ;
1201 state->CH_Ctrl[2].addr[0] = 69;
1202 state->CH_Ctrl[2].bit[0] = 5;
1203 state->CH_Ctrl[2].val[0] = 0;
1204 state->CH_Ctrl[2].addr[1] = 69;
1205 state->CH_Ctrl[2].bit[1] = 6;
1206 state->CH_Ctrl[2].val[1] = 0;
1207 state->CH_Ctrl[2].addr[2] = 69;
1208 state->CH_Ctrl[2].bit[2] = 7;
1209 state->CH_Ctrl[2].val[2] = 0;
1210 state->CH_Ctrl[2].addr[3] = 68;
1211 state->CH_Ctrl[2].bit[3] = 0;
1212 state->CH_Ctrl[2].val[3] = 0;
1213 state->CH_Ctrl[2].addr[4] = 68;
1214 state->CH_Ctrl[2].bit[4] = 1;
1215 state->CH_Ctrl[2].val[4] = 0;
1216 state->CH_Ctrl[2].addr[5] = 68;
1217 state->CH_Ctrl[2].bit[5] = 2;
1218 state->CH_Ctrl[2].val[5] = 0;
1219 state->CH_Ctrl[2].addr[6] = 68;
1220 state->CH_Ctrl[2].bit[6] = 3;
1221 state->CH_Ctrl[2].val[6] = 0;
1222 state->CH_Ctrl[2].addr[7] = 68;
1223 state->CH_Ctrl[2].bit[7] = 4;
1224 state->CH_Ctrl[2].val[7] = 0;
1225 state->CH_Ctrl[2].addr[8] = 68;
1226 state->CH_Ctrl[2].bit[8] = 5;
1227 state->CH_Ctrl[2].val[8] = 0;
1228
1229 state->CH_Ctrl[3].Ctrl_Num = DN_EN_VHFUHFBAR ;
1230 state->CH_Ctrl[3].size = 1 ;
1231 state->CH_Ctrl[3].addr[0] = 70;
1232 state->CH_Ctrl[3].bit[0] = 5;
1233 state->CH_Ctrl[3].val[0] = 0;
1234
1235 state->CH_Ctrl[4].Ctrl_Num = DN_GAIN_ADJUST ;
1236 state->CH_Ctrl[4].size = 3 ;
1237 state->CH_Ctrl[4].addr[0] = 73;
1238 state->CH_Ctrl[4].bit[0] = 4;
1239 state->CH_Ctrl[4].val[0] = 0;
1240 state->CH_Ctrl[4].addr[1] = 73;
1241 state->CH_Ctrl[4].bit[1] = 5;
1242 state->CH_Ctrl[4].val[1] = 1;
1243 state->CH_Ctrl[4].addr[2] = 73;
1244 state->CH_Ctrl[4].bit[2] = 6;
1245 state->CH_Ctrl[4].val[2] = 0;
1246
1247 state->CH_Ctrl[5].Ctrl_Num = DN_IQTNBUF_AMP ;
1248 state->CH_Ctrl[5].size = 4 ;
1249 state->CH_Ctrl[5].addr[0] = 70;
1250 state->CH_Ctrl[5].bit[0] = 0;
1251 state->CH_Ctrl[5].val[0] = 0;
1252 state->CH_Ctrl[5].addr[1] = 70;
1253 state->CH_Ctrl[5].bit[1] = 1;
1254 state->CH_Ctrl[5].val[1] = 0;
1255 state->CH_Ctrl[5].addr[2] = 70;
1256 state->CH_Ctrl[5].bit[2] = 2;
1257 state->CH_Ctrl[5].val[2] = 0;
1258 state->CH_Ctrl[5].addr[3] = 70;
1259 state->CH_Ctrl[5].bit[3] = 3;
1260 state->CH_Ctrl[5].val[3] = 0;
1261
1262 state->CH_Ctrl[6].Ctrl_Num = DN_IQTNGNBFBIAS_BST ;
1263 state->CH_Ctrl[6].size = 1 ;
1264 state->CH_Ctrl[6].addr[0] = 70;
1265 state->CH_Ctrl[6].bit[0] = 4;
1266 state->CH_Ctrl[6].val[0] = 1;
1267
1268 state->CH_Ctrl[7].Ctrl_Num = RFSYN_EN_OUTMUX ;
1269 state->CH_Ctrl[7].size = 1 ;
1270 state->CH_Ctrl[7].addr[0] = 111;
1271 state->CH_Ctrl[7].bit[0] = 4;
1272 state->CH_Ctrl[7].val[0] = 0;
1273
1274 state->CH_Ctrl[8].Ctrl_Num = RFSYN_SEL_VCO_OUT ;
1275 state->CH_Ctrl[8].size = 1 ;
1276 state->CH_Ctrl[8].addr[0] = 111;
1277 state->CH_Ctrl[8].bit[0] = 7;
1278 state->CH_Ctrl[8].val[0] = 1;
1279
1280 state->CH_Ctrl[9].Ctrl_Num = RFSYN_SEL_VCO_HI ;
1281 state->CH_Ctrl[9].size = 1 ;
1282 state->CH_Ctrl[9].addr[0] = 111;
1283 state->CH_Ctrl[9].bit[0] = 6;
1284 state->CH_Ctrl[9].val[0] = 1;
1285
1286 state->CH_Ctrl[10].Ctrl_Num = RFSYN_SEL_DIVM ;
1287 state->CH_Ctrl[10].size = 1 ;
1288 state->CH_Ctrl[10].addr[0] = 111;
1289 state->CH_Ctrl[10].bit[0] = 5;
1290 state->CH_Ctrl[10].val[0] = 0;
1291
1292 state->CH_Ctrl[11].Ctrl_Num = RFSYN_RF_DIV_BIAS ;
1293 state->CH_Ctrl[11].size = 2 ;
1294 state->CH_Ctrl[11].addr[0] = 110;
1295 state->CH_Ctrl[11].bit[0] = 0;
1296 state->CH_Ctrl[11].val[0] = 1;
1297 state->CH_Ctrl[11].addr[1] = 110;
1298 state->CH_Ctrl[11].bit[1] = 1;
1299 state->CH_Ctrl[11].val[1] = 0;
1300
1301 state->CH_Ctrl[12].Ctrl_Num = DN_SEL_FREQ ;
1302 state->CH_Ctrl[12].size = 3 ;
1303 state->CH_Ctrl[12].addr[0] = 69;
1304 state->CH_Ctrl[12].bit[0] = 2;
1305 state->CH_Ctrl[12].val[0] = 0;
1306 state->CH_Ctrl[12].addr[1] = 69;
1307 state->CH_Ctrl[12].bit[1] = 3;
1308 state->CH_Ctrl[12].val[1] = 0;
1309 state->CH_Ctrl[12].addr[2] = 69;
1310 state->CH_Ctrl[12].bit[2] = 4;
1311 state->CH_Ctrl[12].val[2] = 0;
1312
1313 state->CH_Ctrl[13].Ctrl_Num = RFSYN_VCO_BIAS ;
1314 state->CH_Ctrl[13].size = 6 ;
1315 state->CH_Ctrl[13].addr[0] = 110;
1316 state->CH_Ctrl[13].bit[0] = 2;
1317 state->CH_Ctrl[13].val[0] = 0;
1318 state->CH_Ctrl[13].addr[1] = 110;
1319 state->CH_Ctrl[13].bit[1] = 3;
1320 state->CH_Ctrl[13].val[1] = 0;
1321 state->CH_Ctrl[13].addr[2] = 110;
1322 state->CH_Ctrl[13].bit[2] = 4;
1323 state->CH_Ctrl[13].val[2] = 0;
1324 state->CH_Ctrl[13].addr[3] = 110;
1325 state->CH_Ctrl[13].bit[3] = 5;
1326 state->CH_Ctrl[13].val[3] = 0;
1327 state->CH_Ctrl[13].addr[4] = 110;
1328 state->CH_Ctrl[13].bit[4] = 6;
1329 state->CH_Ctrl[13].val[4] = 0;
1330 state->CH_Ctrl[13].addr[5] = 110;
1331 state->CH_Ctrl[13].bit[5] = 7;
1332 state->CH_Ctrl[13].val[5] = 1;
1333
1334 state->CH_Ctrl[14].Ctrl_Num = CHCAL_INT_MOD_RF ;
1335 state->CH_Ctrl[14].size = 7 ;
1336 state->CH_Ctrl[14].addr[0] = 14;
1337 state->CH_Ctrl[14].bit[0] = 0;
1338 state->CH_Ctrl[14].val[0] = 0;
1339 state->CH_Ctrl[14].addr[1] = 14;
1340 state->CH_Ctrl[14].bit[1] = 1;
1341 state->CH_Ctrl[14].val[1] = 0;
1342 state->CH_Ctrl[14].addr[2] = 14;
1343 state->CH_Ctrl[14].bit[2] = 2;
1344 state->CH_Ctrl[14].val[2] = 0;
1345 state->CH_Ctrl[14].addr[3] = 14;
1346 state->CH_Ctrl[14].bit[3] = 3;
1347 state->CH_Ctrl[14].val[3] = 0;
1348 state->CH_Ctrl[14].addr[4] = 14;
1349 state->CH_Ctrl[14].bit[4] = 4;
1350 state->CH_Ctrl[14].val[4] = 0;
1351 state->CH_Ctrl[14].addr[5] = 14;
1352 state->CH_Ctrl[14].bit[5] = 5;
1353 state->CH_Ctrl[14].val[5] = 0;
1354 state->CH_Ctrl[14].addr[6] = 14;
1355 state->CH_Ctrl[14].bit[6] = 6;
1356 state->CH_Ctrl[14].val[6] = 0;
1357
1358 state->CH_Ctrl[15].Ctrl_Num = CHCAL_FRAC_MOD_RF ;
1359 state->CH_Ctrl[15].size = 18 ;
1360 state->CH_Ctrl[15].addr[0] = 17;
1361 state->CH_Ctrl[15].bit[0] = 6;
1362 state->CH_Ctrl[15].val[0] = 0;
1363 state->CH_Ctrl[15].addr[1] = 17;
1364 state->CH_Ctrl[15].bit[1] = 7;
1365 state->CH_Ctrl[15].val[1] = 0;
1366 state->CH_Ctrl[15].addr[2] = 16;
1367 state->CH_Ctrl[15].bit[2] = 0;
1368 state->CH_Ctrl[15].val[2] = 0;
1369 state->CH_Ctrl[15].addr[3] = 16;
1370 state->CH_Ctrl[15].bit[3] = 1;
1371 state->CH_Ctrl[15].val[3] = 0;
1372 state->CH_Ctrl[15].addr[4] = 16;
1373 state->CH_Ctrl[15].bit[4] = 2;
1374 state->CH_Ctrl[15].val[4] = 0;
1375 state->CH_Ctrl[15].addr[5] = 16;
1376 state->CH_Ctrl[15].bit[5] = 3;
1377 state->CH_Ctrl[15].val[5] = 0;
1378 state->CH_Ctrl[15].addr[6] = 16;
1379 state->CH_Ctrl[15].bit[6] = 4;
1380 state->CH_Ctrl[15].val[6] = 0;
1381 state->CH_Ctrl[15].addr[7] = 16;
1382 state->CH_Ctrl[15].bit[7] = 5;
1383 state->CH_Ctrl[15].val[7] = 0;
1384 state->CH_Ctrl[15].addr[8] = 16;
1385 state->CH_Ctrl[15].bit[8] = 6;
1386 state->CH_Ctrl[15].val[8] = 0;
1387 state->CH_Ctrl[15].addr[9] = 16;
1388 state->CH_Ctrl[15].bit[9] = 7;
1389 state->CH_Ctrl[15].val[9] = 0;
1390 state->CH_Ctrl[15].addr[10] = 15;
1391 state->CH_Ctrl[15].bit[10] = 0;
1392 state->CH_Ctrl[15].val[10] = 0;
1393 state->CH_Ctrl[15].addr[11] = 15;
1394 state->CH_Ctrl[15].bit[11] = 1;
1395 state->CH_Ctrl[15].val[11] = 0;
1396 state->CH_Ctrl[15].addr[12] = 15;
1397 state->CH_Ctrl[15].bit[12] = 2;
1398 state->CH_Ctrl[15].val[12] = 0;
1399 state->CH_Ctrl[15].addr[13] = 15;
1400 state->CH_Ctrl[15].bit[13] = 3;
1401 state->CH_Ctrl[15].val[13] = 0;
1402 state->CH_Ctrl[15].addr[14] = 15;
1403 state->CH_Ctrl[15].bit[14] = 4;
1404 state->CH_Ctrl[15].val[14] = 0;
1405 state->CH_Ctrl[15].addr[15] = 15;
1406 state->CH_Ctrl[15].bit[15] = 5;
1407 state->CH_Ctrl[15].val[15] = 0;
1408 state->CH_Ctrl[15].addr[16] = 15;
1409 state->CH_Ctrl[15].bit[16] = 6;
1410 state->CH_Ctrl[15].val[16] = 1;
1411 state->CH_Ctrl[15].addr[17] = 15;
1412 state->CH_Ctrl[15].bit[17] = 7;
1413 state->CH_Ctrl[15].val[17] = 1;
1414
1415 state->CH_Ctrl[16].Ctrl_Num = RFSYN_LPF_R ;
1416 state->CH_Ctrl[16].size = 5 ;
1417 state->CH_Ctrl[16].addr[0] = 112;
1418 state->CH_Ctrl[16].bit[0] = 0;
1419 state->CH_Ctrl[16].val[0] = 0;
1420 state->CH_Ctrl[16].addr[1] = 112;
1421 state->CH_Ctrl[16].bit[1] = 1;
1422 state->CH_Ctrl[16].val[1] = 0;
1423 state->CH_Ctrl[16].addr[2] = 112;
1424 state->CH_Ctrl[16].bit[2] = 2;
1425 state->CH_Ctrl[16].val[2] = 0;
1426 state->CH_Ctrl[16].addr[3] = 112;
1427 state->CH_Ctrl[16].bit[3] = 3;
1428 state->CH_Ctrl[16].val[3] = 0;
1429 state->CH_Ctrl[16].addr[4] = 112;
1430 state->CH_Ctrl[16].bit[4] = 4;
1431 state->CH_Ctrl[16].val[4] = 1;
1432
1433 state->CH_Ctrl[17].Ctrl_Num = CHCAL_EN_INT_RF ;
1434 state->CH_Ctrl[17].size = 1 ;
1435 state->CH_Ctrl[17].addr[0] = 14;
1436 state->CH_Ctrl[17].bit[0] = 7;
1437 state->CH_Ctrl[17].val[0] = 0;
1438
1439 state->CH_Ctrl[18].Ctrl_Num = TG_LO_DIVVAL ;
1440 state->CH_Ctrl[18].size = 4 ;
1441 state->CH_Ctrl[18].addr[0] = 107;
1442 state->CH_Ctrl[18].bit[0] = 3;
1443 state->CH_Ctrl[18].val[0] = 0;
1444 state->CH_Ctrl[18].addr[1] = 107;
1445 state->CH_Ctrl[18].bit[1] = 4;
1446 state->CH_Ctrl[18].val[1] = 0;
1447 state->CH_Ctrl[18].addr[2] = 107;
1448 state->CH_Ctrl[18].bit[2] = 5;
1449 state->CH_Ctrl[18].val[2] = 0;
1450 state->CH_Ctrl[18].addr[3] = 107;
1451 state->CH_Ctrl[18].bit[3] = 6;
1452 state->CH_Ctrl[18].val[3] = 0;
1453
1454 state->CH_Ctrl[19].Ctrl_Num = TG_LO_SELVAL ;
1455 state->CH_Ctrl[19].size = 3 ;
1456 state->CH_Ctrl[19].addr[0] = 107;
1457 state->CH_Ctrl[19].bit[0] = 7;
1458 state->CH_Ctrl[19].val[0] = 1;
1459 state->CH_Ctrl[19].addr[1] = 106;
1460 state->CH_Ctrl[19].bit[1] = 0;
1461 state->CH_Ctrl[19].val[1] = 1;
1462 state->CH_Ctrl[19].addr[2] = 106;
1463 state->CH_Ctrl[19].bit[2] = 1;
1464 state->CH_Ctrl[19].val[2] = 1;
1465
1466 state->CH_Ctrl[20].Ctrl_Num = TG_DIV_VAL ;
1467 state->CH_Ctrl[20].size = 11 ;
1468 state->CH_Ctrl[20].addr[0] = 109;
1469 state->CH_Ctrl[20].bit[0] = 2;
1470 state->CH_Ctrl[20].val[0] = 0;
1471 state->CH_Ctrl[20].addr[1] = 109;
1472 state->CH_Ctrl[20].bit[1] = 3;
1473 state->CH_Ctrl[20].val[1] = 0;
1474 state->CH_Ctrl[20].addr[2] = 109;
1475 state->CH_Ctrl[20].bit[2] = 4;
1476 state->CH_Ctrl[20].val[2] = 0;
1477 state->CH_Ctrl[20].addr[3] = 109;
1478 state->CH_Ctrl[20].bit[3] = 5;
1479 state->CH_Ctrl[20].val[3] = 0;
1480 state->CH_Ctrl[20].addr[4] = 109;
1481 state->CH_Ctrl[20].bit[4] = 6;
1482 state->CH_Ctrl[20].val[4] = 0;
1483 state->CH_Ctrl[20].addr[5] = 109;
1484 state->CH_Ctrl[20].bit[5] = 7;
1485 state->CH_Ctrl[20].val[5] = 0;
1486 state->CH_Ctrl[20].addr[6] = 108;
1487 state->CH_Ctrl[20].bit[6] = 0;
1488 state->CH_Ctrl[20].val[6] = 0;
1489 state->CH_Ctrl[20].addr[7] = 108;
1490 state->CH_Ctrl[20].bit[7] = 1;
1491 state->CH_Ctrl[20].val[7] = 0;
1492 state->CH_Ctrl[20].addr[8] = 108;
1493 state->CH_Ctrl[20].bit[8] = 2;
1494 state->CH_Ctrl[20].val[8] = 1;
1495 state->CH_Ctrl[20].addr[9] = 108;
1496 state->CH_Ctrl[20].bit[9] = 3;
1497 state->CH_Ctrl[20].val[9] = 1;
1498 state->CH_Ctrl[20].addr[10] = 108;
1499 state->CH_Ctrl[20].bit[10] = 4;
1500 state->CH_Ctrl[20].val[10] = 1;
1501
1502 state->CH_Ctrl[21].Ctrl_Num = TG_VCO_BIAS ;
1503 state->CH_Ctrl[21].size = 6 ;
1504 state->CH_Ctrl[21].addr[0] = 106;
1505 state->CH_Ctrl[21].bit[0] = 2;
1506 state->CH_Ctrl[21].val[0] = 0;
1507 state->CH_Ctrl[21].addr[1] = 106;
1508 state->CH_Ctrl[21].bit[1] = 3;
1509 state->CH_Ctrl[21].val[1] = 0;
1510 state->CH_Ctrl[21].addr[2] = 106;
1511 state->CH_Ctrl[21].bit[2] = 4;
1512 state->CH_Ctrl[21].val[2] = 0;
1513 state->CH_Ctrl[21].addr[3] = 106;
1514 state->CH_Ctrl[21].bit[3] = 5;
1515 state->CH_Ctrl[21].val[3] = 0;
1516 state->CH_Ctrl[21].addr[4] = 106;
1517 state->CH_Ctrl[21].bit[4] = 6;
1518 state->CH_Ctrl[21].val[4] = 0;
1519 state->CH_Ctrl[21].addr[5] = 106;
1520 state->CH_Ctrl[21].bit[5] = 7;
1521 state->CH_Ctrl[21].val[5] = 1;
1522
1523 state->CH_Ctrl[22].Ctrl_Num = SEQ_EXTPOWERUP ;
1524 state->CH_Ctrl[22].size = 1 ;
1525 state->CH_Ctrl[22].addr[0] = 138;
1526 state->CH_Ctrl[22].bit[0] = 4;
1527 state->CH_Ctrl[22].val[0] = 1;
1528
1529 state->CH_Ctrl[23].Ctrl_Num = OVERRIDE_2 ;
1530 state->CH_Ctrl[23].size = 1 ;
1531 state->CH_Ctrl[23].addr[0] = 17;
1532 state->CH_Ctrl[23].bit[0] = 5;
1533 state->CH_Ctrl[23].val[0] = 0;
1534
1535 state->CH_Ctrl[24].Ctrl_Num = OVERRIDE_3 ;
1536 state->CH_Ctrl[24].size = 1 ;
1537 state->CH_Ctrl[24].addr[0] = 111;
1538 state->CH_Ctrl[24].bit[0] = 3;
1539 state->CH_Ctrl[24].val[0] = 0;
1540
1541 state->CH_Ctrl[25].Ctrl_Num = OVERRIDE_4 ;
1542 state->CH_Ctrl[25].size = 1 ;
1543 state->CH_Ctrl[25].addr[0] = 112;
1544 state->CH_Ctrl[25].bit[0] = 7;
1545 state->CH_Ctrl[25].val[0] = 0;
1546
1547 state->CH_Ctrl[26].Ctrl_Num = SEQ_FSM_PULSE ;
1548 state->CH_Ctrl[26].size = 1 ;
1549 state->CH_Ctrl[26].addr[0] = 136;
1550 state->CH_Ctrl[26].bit[0] = 7;
1551 state->CH_Ctrl[26].val[0] = 0;
1552
1553 state->CH_Ctrl[27].Ctrl_Num = GPIO_4B ;
1554 state->CH_Ctrl[27].size = 1 ;
1555 state->CH_Ctrl[27].addr[0] = 149;
1556 state->CH_Ctrl[27].bit[0] = 7;
1557 state->CH_Ctrl[27].val[0] = 0;
1558
1559 state->CH_Ctrl[28].Ctrl_Num = GPIO_3B ;
1560 state->CH_Ctrl[28].size = 1 ;
1561 state->CH_Ctrl[28].addr[0] = 149;
1562 state->CH_Ctrl[28].bit[0] = 6;
1563 state->CH_Ctrl[28].val[0] = 0;
1564
1565 state->CH_Ctrl[29].Ctrl_Num = GPIO_4 ;
1566 state->CH_Ctrl[29].size = 1 ;
1567 state->CH_Ctrl[29].addr[0] = 149;
1568 state->CH_Ctrl[29].bit[0] = 5;
1569 state->CH_Ctrl[29].val[0] = 1;
1570
1571 state->CH_Ctrl[30].Ctrl_Num = GPIO_3 ;
1572 state->CH_Ctrl[30].size = 1 ;
1573 state->CH_Ctrl[30].addr[0] = 149;
1574 state->CH_Ctrl[30].bit[0] = 4;
1575 state->CH_Ctrl[30].val[0] = 1;
1576
1577 state->CH_Ctrl[31].Ctrl_Num = GPIO_1B ;
1578 state->CH_Ctrl[31].size = 1 ;
1579 state->CH_Ctrl[31].addr[0] = 149;
1580 state->CH_Ctrl[31].bit[0] = 3;
1581 state->CH_Ctrl[31].val[0] = 0;
1582
1583 state->CH_Ctrl[32].Ctrl_Num = DAC_A_ENABLE ;
1584 state->CH_Ctrl[32].size = 1 ;
1585 state->CH_Ctrl[32].addr[0] = 93;
1586 state->CH_Ctrl[32].bit[0] = 1;
1587 state->CH_Ctrl[32].val[0] = 0;
1588
1589 state->CH_Ctrl[33].Ctrl_Num = DAC_B_ENABLE ;
1590 state->CH_Ctrl[33].size = 1 ;
1591 state->CH_Ctrl[33].addr[0] = 93;
1592 state->CH_Ctrl[33].bit[0] = 0;
1593 state->CH_Ctrl[33].val[0] = 0;
1594
1595 state->CH_Ctrl[34].Ctrl_Num = DAC_DIN_A ;
1596 state->CH_Ctrl[34].size = 6 ;
1597 state->CH_Ctrl[34].addr[0] = 92;
1598 state->CH_Ctrl[34].bit[0] = 2;
1599 state->CH_Ctrl[34].val[0] = 0;
1600 state->CH_Ctrl[34].addr[1] = 92;
1601 state->CH_Ctrl[34].bit[1] = 3;
1602 state->CH_Ctrl[34].val[1] = 0;
1603 state->CH_Ctrl[34].addr[2] = 92;
1604 state->CH_Ctrl[34].bit[2] = 4;
1605 state->CH_Ctrl[34].val[2] = 0;
1606 state->CH_Ctrl[34].addr[3] = 92;
1607 state->CH_Ctrl[34].bit[3] = 5;
1608 state->CH_Ctrl[34].val[3] = 0;
1609 state->CH_Ctrl[34].addr[4] = 92;
1610 state->CH_Ctrl[34].bit[4] = 6;
1611 state->CH_Ctrl[34].val[4] = 0;
1612 state->CH_Ctrl[34].addr[5] = 92;
1613 state->CH_Ctrl[34].bit[5] = 7;
1614 state->CH_Ctrl[34].val[5] = 0;
1615
1616 state->CH_Ctrl[35].Ctrl_Num = DAC_DIN_B ;
1617 state->CH_Ctrl[35].size = 6 ;
1618 state->CH_Ctrl[35].addr[0] = 93;
1619 state->CH_Ctrl[35].bit[0] = 2;
1620 state->CH_Ctrl[35].val[0] = 0;
1621 state->CH_Ctrl[35].addr[1] = 93;
1622 state->CH_Ctrl[35].bit[1] = 3;
1623 state->CH_Ctrl[35].val[1] = 0;
1624 state->CH_Ctrl[35].addr[2] = 93;
1625 state->CH_Ctrl[35].bit[2] = 4;
1626 state->CH_Ctrl[35].val[2] = 0;
1627 state->CH_Ctrl[35].addr[3] = 93;
1628 state->CH_Ctrl[35].bit[3] = 5;
1629 state->CH_Ctrl[35].val[3] = 0;
1630 state->CH_Ctrl[35].addr[4] = 93;
1631 state->CH_Ctrl[35].bit[4] = 6;
1632 state->CH_Ctrl[35].val[4] = 0;
1633 state->CH_Ctrl[35].addr[5] = 93;
1634 state->CH_Ctrl[35].bit[5] = 7;
1635 state->CH_Ctrl[35].val[5] = 0;
1636
1637#ifdef _MXL_PRODUCTION
1638 state->CH_Ctrl[36].Ctrl_Num = RFSYN_EN_DIV ;
1639 state->CH_Ctrl[36].size = 1 ;
1640 state->CH_Ctrl[36].addr[0] = 109;
1641 state->CH_Ctrl[36].bit[0] = 1;
1642 state->CH_Ctrl[36].val[0] = 1;
1643
1644 state->CH_Ctrl[37].Ctrl_Num = RFSYN_DIVM ;
1645 state->CH_Ctrl[37].size = 2 ;
1646 state->CH_Ctrl[37].addr[0] = 112;
1647 state->CH_Ctrl[37].bit[0] = 5;
1648 state->CH_Ctrl[37].val[0] = 0;
1649 state->CH_Ctrl[37].addr[1] = 112;
1650 state->CH_Ctrl[37].bit[1] = 6;
1651 state->CH_Ctrl[37].val[1] = 0;
1652
1653 state->CH_Ctrl[38].Ctrl_Num = DN_BYPASS_AGC_I2C ;
1654 state->CH_Ctrl[38].size = 1 ;
1655 state->CH_Ctrl[38].addr[0] = 65;
1656 state->CH_Ctrl[38].bit[0] = 1;
1657 state->CH_Ctrl[38].val[0] = 0;
1658#endif
1659
1660 return 0 ;
1661}
1662
1663static void InitTunerControls(struct dvb_frontend *fe)
1664{
1665 MXL5005_RegisterInit(fe);
1666 MXL5005_ControlInit(fe);
1667#ifdef _MXL_INTERNAL
1668 MXL5005_MXLControlInit(fe);
1669#endif
1670}
1671
1672static u16 MXL5005_TunerConfig(struct dvb_frontend *fe,
1673 u8 Mode, /* 0: Analog Mode ; 1: Digital Mode */
1674 u8 IF_mode, /* for Analog Mode, 0: zero IF; 1: low IF */
1675 u32 Bandwidth, /* filter channel bandwidth (6, 7, 8) */
1676 u32 IF_out, /* Desired IF Out Frequency */
1677 u32 Fxtal, /* XTAL Frequency */
1678 u8 AGC_Mode, /* AGC Mode - Dual AGC: 0, Single AGC: 1 */
1679 u16 TOP, /* 0: Dual AGC; Value: take over point */
1680 u16 IF_OUT_LOAD, /* IF Out Load Resistor (200 / 300 Ohms) */
1681 u8 CLOCK_OUT, /* 0: turn off clk out; 1: turn on clock out */
1682 u8 DIV_OUT, /* 0: Div-1; 1: Div-4 */
1683 u8 CAPSELECT, /* 0: disable On-Chip pulling cap; 1: enable */
1684 u8 EN_RSSI, /* 0: disable RSSI; 1: enable RSSI */
1685
1686 /* Modulation Type; */
1687 /* 0 - Default; 1 - DVB-T; 2 - ATSC; 3 - QAM; 4 - Analog Cable */
1688 u8 Mod_Type,
1689
1690 /* Tracking Filter */
1691 /* 0 - Default; 1 - Off; 2 - Type C; 3 - Type C-H */
1692 u8 TF_Type
1693 )
1694{
1695 struct mxl5005s_state *state = fe->tuner_priv;
1696 u16 status = 0;
1697
1698 state->Mode = Mode;
1699 state->IF_Mode = IF_mode;
1700 state->Chan_Bandwidth = Bandwidth;
1701 state->IF_OUT = IF_out;
1702 state->Fxtal = Fxtal;
1703 state->AGC_Mode = AGC_Mode;
1704 state->TOP = TOP;
1705 state->IF_OUT_LOAD = IF_OUT_LOAD;
1706 state->CLOCK_OUT = CLOCK_OUT;
1707 state->DIV_OUT = DIV_OUT;
1708 state->CAPSELECT = CAPSELECT;
1709 state->EN_RSSI = EN_RSSI;
1710 state->Mod_Type = Mod_Type;
1711 state->TF_Type = TF_Type;
1712
1713 /* Initialize all the controls and registers */
1714 InitTunerControls(fe);
1715
1716 /* Synthesizer LO frequency calculation */
1717 MXL_SynthIFLO_Calc(fe);
1718
1719 return status;
1720}
1721
1722static void MXL_SynthIFLO_Calc(struct dvb_frontend *fe)
1723{
1724 struct mxl5005s_state *state = fe->tuner_priv;
1725 if (state->Mode == 1) /* Digital Mode */
1726 state->IF_LO = state->IF_OUT;
1727 else /* Analog Mode */ {
1728 if (state->IF_Mode == 0) /* Analog Zero IF mode */
1729 state->IF_LO = state->IF_OUT + 400000;
1730 else /* Analog Low IF mode */
1731 state->IF_LO = state->IF_OUT + state->Chan_Bandwidth/2;
1732 }
1733}
1734
1735static void MXL_SynthRFTGLO_Calc(struct dvb_frontend *fe)
1736{
1737 struct mxl5005s_state *state = fe->tuner_priv;
1738
1739 if (state->Mode == 1) /* Digital Mode */ {
1740 /* remove 20.48MHz setting for 2.6.10 */
1741 state->RF_LO = state->RF_IN;
1742 /* change for 2.6.6 */
1743 state->TG_LO = state->RF_IN - 750000;
1744 } else /* Analog Mode */ {
1745 if (state->IF_Mode == 0) /* Analog Zero IF mode */ {
1746 state->RF_LO = state->RF_IN - 400000;
1747 state->TG_LO = state->RF_IN - 1750000;
1748 } else /* Analog Low IF mode */ {
1749 state->RF_LO = state->RF_IN - state->Chan_Bandwidth/2;
1750 state->TG_LO = state->RF_IN -
1751 state->Chan_Bandwidth + 500000;
1752 }
1753 }
1754}
1755
1756static u16 MXL_OverwriteICDefault(struct dvb_frontend *fe)
1757{
1758 u16 status = 0;
1759
1760 status += MXL_ControlWrite(fe, OVERRIDE_1, 1);
1761 status += MXL_ControlWrite(fe, OVERRIDE_2, 1);
1762 status += MXL_ControlWrite(fe, OVERRIDE_3, 1);
1763 status += MXL_ControlWrite(fe, OVERRIDE_4, 1);
1764
1765 return status;
1766}
1767
1768static u16 MXL_BlockInit(struct dvb_frontend *fe)
1769{
1770 struct mxl5005s_state *state = fe->tuner_priv;
1771 u16 status = 0;
1772
1773 status += MXL_OverwriteICDefault(fe);
1774
1775 /* Downconverter Control Dig Ana */
1776 status += MXL_ControlWrite(fe, DN_IQTN_AMP_CUT, state->Mode ? 1 : 0);
1777
1778 /* Filter Control Dig Ana */
1779 status += MXL_ControlWrite(fe, BB_MODE, state->Mode ? 0 : 1);
1780 status += MXL_ControlWrite(fe, BB_BUF, state->Mode ? 3 : 2);
1781 status += MXL_ControlWrite(fe, BB_BUF_OA, state->Mode ? 1 : 0);
1782 status += MXL_ControlWrite(fe, BB_IQSWAP, state->Mode ? 0 : 1);
1783 status += MXL_ControlWrite(fe, BB_INITSTATE_DLPF_TUNE, 0);
1784
1785 /* Initialize Low-Pass Filter */
1786 if (state->Mode) { /* Digital Mode */
1787 switch (state->Chan_Bandwidth) {
1788 case 8000000:
1789 status += MXL_ControlWrite(fe, BB_DLPF_BANDSEL, 0);
1790 break;
1791 case 7000000:
1792 status += MXL_ControlWrite(fe, BB_DLPF_BANDSEL, 2);
1793 break;
1794 case 6000000:
1795 status += MXL_ControlWrite(fe,
1796 BB_DLPF_BANDSEL, 3);
1797 break;
1798 }
1799 } else { /* Analog Mode */
1800 switch (state->Chan_Bandwidth) {
1801 case 8000000: /* Low Zero */
1802 status += MXL_ControlWrite(fe, BB_ALPF_BANDSELECT,
1803 (state->IF_Mode ? 0 : 3));
1804 break;
1805 case 7000000:
1806 status += MXL_ControlWrite(fe, BB_ALPF_BANDSELECT,
1807 (state->IF_Mode ? 1 : 4));
1808 break;
1809 case 6000000:
1810 status += MXL_ControlWrite(fe, BB_ALPF_BANDSELECT,
1811 (state->IF_Mode ? 2 : 5));
1812 break;
1813 }
1814 }
1815
1816 /* Charge Pump Control Dig Ana */
1817 status += MXL_ControlWrite(fe, RFSYN_CHP_GAIN, state->Mode ? 5 : 8);
1818 status += MXL_ControlWrite(fe,
1819 RFSYN_EN_CHP_HIGAIN, state->Mode ? 1 : 1);
1820 status += MXL_ControlWrite(fe, EN_CHP_LIN_B, state->Mode ? 0 : 0);
1821
1822 /* AGC TOP Control */
1823 if (state->AGC_Mode == 0) /* Dual AGC */ {
1824 status += MXL_ControlWrite(fe, AGC_IF, 15);
1825 status += MXL_ControlWrite(fe, AGC_RF, 15);
1826 } else /* Single AGC Mode Dig Ana */
1827 status += MXL_ControlWrite(fe, AGC_RF, state->Mode ? 15 : 12);
1828
1829 if (state->TOP == 55) /* TOP == 5.5 */
1830 status += MXL_ControlWrite(fe, AGC_IF, 0x0);
1831
1832 if (state->TOP == 72) /* TOP == 7.2 */
1833 status += MXL_ControlWrite(fe, AGC_IF, 0x1);
1834
1835 if (state->TOP == 92) /* TOP == 9.2 */
1836 status += MXL_ControlWrite(fe, AGC_IF, 0x2);
1837
1838 if (state->TOP == 110) /* TOP == 11.0 */
1839 status += MXL_ControlWrite(fe, AGC_IF, 0x3);
1840
1841 if (state->TOP == 129) /* TOP == 12.9 */
1842 status += MXL_ControlWrite(fe, AGC_IF, 0x4);
1843
1844 if (state->TOP == 147) /* TOP == 14.7 */
1845 status += MXL_ControlWrite(fe, AGC_IF, 0x5);
1846
1847 if (state->TOP == 168) /* TOP == 16.8 */
1848 status += MXL_ControlWrite(fe, AGC_IF, 0x6);
1849
1850 if (state->TOP == 194) /* TOP == 19.4 */
1851 status += MXL_ControlWrite(fe, AGC_IF, 0x7);
1852
1853 if (state->TOP == 212) /* TOP == 21.2 */
1854 status += MXL_ControlWrite(fe, AGC_IF, 0x9);
1855
1856 if (state->TOP == 232) /* TOP == 23.2 */
1857 status += MXL_ControlWrite(fe, AGC_IF, 0xA);
1858
1859 if (state->TOP == 252) /* TOP == 25.2 */
1860 status += MXL_ControlWrite(fe, AGC_IF, 0xB);
1861
1862 if (state->TOP == 271) /* TOP == 27.1 */
1863 status += MXL_ControlWrite(fe, AGC_IF, 0xC);
1864
1865 if (state->TOP == 292) /* TOP == 29.2 */
1866 status += MXL_ControlWrite(fe, AGC_IF, 0xD);
1867
1868 if (state->TOP == 317) /* TOP == 31.7 */
1869 status += MXL_ControlWrite(fe, AGC_IF, 0xE);
1870
1871 if (state->TOP == 349) /* TOP == 34.9 */
1872 status += MXL_ControlWrite(fe, AGC_IF, 0xF);
1873
1874 /* IF Synthesizer Control */
1875 status += MXL_IFSynthInit(fe);
1876
1877 /* IF UpConverter Control */
1878 if (state->IF_OUT_LOAD == 200) {
1879 status += MXL_ControlWrite(fe, DRV_RES_SEL, 6);
1880 status += MXL_ControlWrite(fe, I_DRIVER, 2);
1881 }
1882 if (state->IF_OUT_LOAD == 300) {
1883 status += MXL_ControlWrite(fe, DRV_RES_SEL, 4);
1884 status += MXL_ControlWrite(fe, I_DRIVER, 1);
1885 }
1886
1887 /* Anti-Alias Filtering Control
1888 * initialise Anti-Aliasing Filter
1889 */
1890 if (state->Mode) { /* Digital Mode */
1891 if (state->IF_OUT >= 4000000UL && state->IF_OUT <= 6280000UL) {
1892 status += MXL_ControlWrite(fe, EN_AAF, 1);
1893 status += MXL_ControlWrite(fe, EN_3P, 1);
1894 status += MXL_ControlWrite(fe, EN_AUX_3P, 1);
1895 status += MXL_ControlWrite(fe, SEL_AAF_BAND, 0);
1896 }
1897 if ((state->IF_OUT == 36125000UL) ||
1898 (state->IF_OUT == 36150000UL)) {
1899 status += MXL_ControlWrite(fe, EN_AAF, 1);
1900 status += MXL_ControlWrite(fe, EN_3P, 1);
1901 status += MXL_ControlWrite(fe, EN_AUX_3P, 1);
1902 status += MXL_ControlWrite(fe, SEL_AAF_BAND, 1);
1903 }
1904 if (state->IF_OUT > 36150000UL) {
1905 status += MXL_ControlWrite(fe, EN_AAF, 0);
1906 status += MXL_ControlWrite(fe, EN_3P, 1);
1907 status += MXL_ControlWrite(fe, EN_AUX_3P, 1);
1908 status += MXL_ControlWrite(fe, SEL_AAF_BAND, 1);
1909 }
1910 } else { /* Analog Mode */
1911 if (state->IF_OUT >= 4000000UL && state->IF_OUT <= 5000000UL) {
1912 status += MXL_ControlWrite(fe, EN_AAF, 1);
1913 status += MXL_ControlWrite(fe, EN_3P, 1);
1914 status += MXL_ControlWrite(fe, EN_AUX_3P, 1);
1915 status += MXL_ControlWrite(fe, SEL_AAF_BAND, 0);
1916 }
1917 if (state->IF_OUT > 5000000UL) {
1918 status += MXL_ControlWrite(fe, EN_AAF, 0);
1919 status += MXL_ControlWrite(fe, EN_3P, 0);
1920 status += MXL_ControlWrite(fe, EN_AUX_3P, 0);
1921 status += MXL_ControlWrite(fe, SEL_AAF_BAND, 0);
1922 }
1923 }
1924
1925 /* Demod Clock Out */
1926 if (state->CLOCK_OUT)
1927 status += MXL_ControlWrite(fe, SEQ_ENCLK16_CLK_OUT, 1);
1928 else
1929 status += MXL_ControlWrite(fe, SEQ_ENCLK16_CLK_OUT, 0);
1930
1931 if (state->DIV_OUT == 1)
1932 status += MXL_ControlWrite(fe, SEQ_SEL4_16B, 1);
1933 if (state->DIV_OUT == 0)
1934 status += MXL_ControlWrite(fe, SEQ_SEL4_16B, 0);
1935
1936 /* Crystal Control */
1937 if (state->CAPSELECT)
1938 status += MXL_ControlWrite(fe, XTAL_CAPSELECT, 1);
1939 else
1940 status += MXL_ControlWrite(fe, XTAL_CAPSELECT, 0);
1941
1942 if (state->Fxtal >= 12000000UL && state->Fxtal <= 16000000UL)
1943 status += MXL_ControlWrite(fe, IF_SEL_DBL, 1);
1944 if (state->Fxtal > 16000000UL && state->Fxtal <= 32000000UL)
1945 status += MXL_ControlWrite(fe, IF_SEL_DBL, 0);
1946
1947 if (state->Fxtal >= 12000000UL && state->Fxtal <= 22000000UL)
1948 status += MXL_ControlWrite(fe, RFSYN_R_DIV, 3);
1949 if (state->Fxtal > 22000000UL && state->Fxtal <= 32000000UL)
1950 status += MXL_ControlWrite(fe, RFSYN_R_DIV, 0);
1951
1952 /* Misc Controls */
1953 if (state->Mode == 0 && state->IF_Mode == 1) /* Analog LowIF mode */
1954 status += MXL_ControlWrite(fe, SEQ_EXTIQFSMPULSE, 0);
1955 else
1956 status += MXL_ControlWrite(fe, SEQ_EXTIQFSMPULSE, 1);
1957
1958 /* status += MXL_ControlRead(fe, IF_DIVVAL, &IF_DIVVAL_Val); */
1959
1960 /* Set TG_R_DIV */
1961 status += MXL_ControlWrite(fe, TG_R_DIV,
1962 MXL_Ceiling(state->Fxtal, 1000000));
1963
1964 /* Apply Default value to BB_INITSTATE_DLPF_TUNE */
1965
1966 /* RSSI Control */
1967 if (state->EN_RSSI) {
1968 status += MXL_ControlWrite(fe, SEQ_EXTSYNTHCALIF, 1);
1969 status += MXL_ControlWrite(fe, SEQ_EXTDCCAL, 1);
1970 status += MXL_ControlWrite(fe, AGC_EN_RSSI, 1);
1971 status += MXL_ControlWrite(fe, RFA_ENCLKRFAGC, 1);
1972
1973 /* RSSI reference point */
1974 status += MXL_ControlWrite(fe, RFA_RSSI_REF, 2);
1975 status += MXL_ControlWrite(fe, RFA_RSSI_REFH, 3);
1976 status += MXL_ControlWrite(fe, RFA_RSSI_REFL, 1);
1977
1978 /* TOP point */
1979 status += MXL_ControlWrite(fe, RFA_FLR, 0);
1980 status += MXL_ControlWrite(fe, RFA_CEIL, 12);
1981 }
1982
1983 /* Modulation type bit settings
1984 * Override the control values preset
1985 */
1986 if (state->Mod_Type == MXL_DVBT) /* DVB-T Mode */ {
1987 state->AGC_Mode = 1; /* Single AGC Mode */
1988
1989 /* Enable RSSI */
1990 status += MXL_ControlWrite(fe, SEQ_EXTSYNTHCALIF, 1);
1991 status += MXL_ControlWrite(fe, SEQ_EXTDCCAL, 1);
1992 status += MXL_ControlWrite(fe, AGC_EN_RSSI, 1);
1993 status += MXL_ControlWrite(fe, RFA_ENCLKRFAGC, 1);
1994
1995 /* RSSI reference point */
1996 status += MXL_ControlWrite(fe, RFA_RSSI_REF, 3);
1997 status += MXL_ControlWrite(fe, RFA_RSSI_REFH, 5);
1998 status += MXL_ControlWrite(fe, RFA_RSSI_REFL, 1);
1999
2000 /* TOP point */
2001 status += MXL_ControlWrite(fe, RFA_FLR, 2);
2002 status += MXL_ControlWrite(fe, RFA_CEIL, 13);
2003 if (state->IF_OUT <= 6280000UL) /* Low IF */
2004 status += MXL_ControlWrite(fe, BB_IQSWAP, 0);
2005 else /* High IF */
2006 status += MXL_ControlWrite(fe, BB_IQSWAP, 1);
2007
2008 }
2009 if (state->Mod_Type == MXL_ATSC) /* ATSC Mode */ {
2010 state->AGC_Mode = 1; /* Single AGC Mode */
2011
2012 /* Enable RSSI */
2013 status += MXL_ControlWrite(fe, SEQ_EXTSYNTHCALIF, 1);
2014 status += MXL_ControlWrite(fe, SEQ_EXTDCCAL, 1);
2015 status += MXL_ControlWrite(fe, AGC_EN_RSSI, 1);
2016 status += MXL_ControlWrite(fe, RFA_ENCLKRFAGC, 1);
2017
2018 /* RSSI reference point */
2019 status += MXL_ControlWrite(fe, RFA_RSSI_REF, 2);
2020 status += MXL_ControlWrite(fe, RFA_RSSI_REFH, 4);
2021 status += MXL_ControlWrite(fe, RFA_RSSI_REFL, 1);
2022
2023 /* TOP point */
2024 status += MXL_ControlWrite(fe, RFA_FLR, 2);
2025 status += MXL_ControlWrite(fe, RFA_CEIL, 13);
2026 status += MXL_ControlWrite(fe, BB_INITSTATE_DLPF_TUNE, 1);
2027 /* Low Zero */
2028 status += MXL_ControlWrite(fe, RFSYN_CHP_GAIN, 5);
2029
2030 if (state->IF_OUT <= 6280000UL) /* Low IF */
2031 status += MXL_ControlWrite(fe, BB_IQSWAP, 0);
2032 else /* High IF */
2033 status += MXL_ControlWrite(fe, BB_IQSWAP, 1);
2034 }
2035 if (state->Mod_Type == MXL_QAM) /* QAM Mode */ {
2036 state->Mode = MXL_DIGITAL_MODE;
2037
2038 /* state->AGC_Mode = 1; */ /* Single AGC Mode */
2039
2040 /* Disable RSSI */ /* change here for v2.6.5 */
2041 status += MXL_ControlWrite(fe, SEQ_EXTSYNTHCALIF, 1);
2042 status += MXL_ControlWrite(fe, SEQ_EXTDCCAL, 1);
2043 status += MXL_ControlWrite(fe, AGC_EN_RSSI, 0);
2044 status += MXL_ControlWrite(fe, RFA_ENCLKRFAGC, 1);
2045
2046 /* RSSI reference point */
2047 status += MXL_ControlWrite(fe, RFA_RSSI_REFH, 5);
2048 status += MXL_ControlWrite(fe, RFA_RSSI_REF, 3);
2049 status += MXL_ControlWrite(fe, RFA_RSSI_REFL, 2);
2050 /* change here for v2.6.5 */
2051 status += MXL_ControlWrite(fe, RFSYN_CHP_GAIN, 3);
2052
2053 if (state->IF_OUT <= 6280000UL) /* Low IF */
2054 status += MXL_ControlWrite(fe, BB_IQSWAP, 0);
2055 else /* High IF */
2056 status += MXL_ControlWrite(fe, BB_IQSWAP, 1);
2057 status += MXL_ControlWrite(fe, RFSYN_CHP_GAIN, 2);
2058
2059 }
2060 if (state->Mod_Type == MXL_ANALOG_CABLE) {
2061 /* Analog Cable Mode */
2062 /* state->Mode = MXL_DIGITAL_MODE; */
2063
2064 state->AGC_Mode = 1; /* Single AGC Mode */
2065
2066 /* Disable RSSI */
2067 status += MXL_ControlWrite(fe, SEQ_EXTSYNTHCALIF, 1);
2068 status += MXL_ControlWrite(fe, SEQ_EXTDCCAL, 1);
2069 status += MXL_ControlWrite(fe, AGC_EN_RSSI, 0);
2070 status += MXL_ControlWrite(fe, RFA_ENCLKRFAGC, 1);
2071 /* change for 2.6.3 */
2072 status += MXL_ControlWrite(fe, AGC_IF, 1);
2073 status += MXL_ControlWrite(fe, AGC_RF, 15);
2074 status += MXL_ControlWrite(fe, BB_IQSWAP, 1);
2075 }
2076
2077 if (state->Mod_Type == MXL_ANALOG_OTA) {
2078 /* Analog OTA Terrestrial mode add for 2.6.7 */
2079 /* state->Mode = MXL_ANALOG_MODE; */
2080
2081 /* Enable RSSI */
2082 status += MXL_ControlWrite(fe, SEQ_EXTSYNTHCALIF, 1);
2083 status += MXL_ControlWrite(fe, SEQ_EXTDCCAL, 1);
2084 status += MXL_ControlWrite(fe, AGC_EN_RSSI, 1);
2085 status += MXL_ControlWrite(fe, RFA_ENCLKRFAGC, 1);
2086
2087 /* RSSI reference point */
2088 status += MXL_ControlWrite(fe, RFA_RSSI_REFH, 5);
2089 status += MXL_ControlWrite(fe, RFA_RSSI_REF, 3);
2090 status += MXL_ControlWrite(fe, RFA_RSSI_REFL, 2);
2091 status += MXL_ControlWrite(fe, RFSYN_CHP_GAIN, 3);
2092 status += MXL_ControlWrite(fe, BB_IQSWAP, 1);
2093 }
2094
2095 /* RSSI disable */
2096 if (state->EN_RSSI == 0) {
2097 status += MXL_ControlWrite(fe, SEQ_EXTSYNTHCALIF, 1);
2098 status += MXL_ControlWrite(fe, SEQ_EXTDCCAL, 1);
2099 status += MXL_ControlWrite(fe, AGC_EN_RSSI, 0);
2100 status += MXL_ControlWrite(fe, RFA_ENCLKRFAGC, 1);
2101 }
2102
2103 return status;
2104}
2105
2106static u16 MXL_IFSynthInit(struct dvb_frontend *fe)
2107{
2108 struct mxl5005s_state *state = fe->tuner_priv;
2109 u16 status = 0 ;
2110 u32 Fref = 0 ;
2111 u32 Kdbl, intModVal ;
2112 u32 fracModVal ;
2113 Kdbl = 2 ;
2114
2115 if (state->Fxtal >= 12000000UL && state->Fxtal <= 16000000UL)
2116 Kdbl = 2 ;
2117 if (state->Fxtal > 16000000UL && state->Fxtal <= 32000000UL)
2118 Kdbl = 1 ;
2119
2120 /* IF Synthesizer Control */
2121 if (state->Mode == 0 && state->IF_Mode == 1) /* Analog Low IF mode */ {
2122 if (state->IF_LO == 41000000UL) {
2123 status += MXL_ControlWrite(fe, IF_DIVVAL, 0x08);
2124 status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x0C);
2125 Fref = 328000000UL ;
2126 }
2127 if (state->IF_LO == 47000000UL) {
2128 status += MXL_ControlWrite(fe, IF_DIVVAL, 0x08);
2129 status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x08);
2130 Fref = 376000000UL ;
2131 }
2132 if (state->IF_LO == 54000000UL) {
2133 status += MXL_ControlWrite(fe, IF_DIVVAL, 0x10);
2134 status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x0C);
2135 Fref = 324000000UL ;
2136 }
2137 if (state->IF_LO == 60000000UL) {
2138 status += MXL_ControlWrite(fe, IF_DIVVAL, 0x10);
2139 status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x08);
2140 Fref = 360000000UL ;
2141 }
2142 if (state->IF_LO == 39250000UL) {
2143 status += MXL_ControlWrite(fe, IF_DIVVAL, 0x08);
2144 status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x0C);
2145 Fref = 314000000UL ;
2146 }
2147 if (state->IF_LO == 39650000UL) {
2148 status += MXL_ControlWrite(fe, IF_DIVVAL, 0x08);
2149 status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x0C);
2150 Fref = 317200000UL ;
2151 }
2152 if (state->IF_LO == 40150000UL) {
2153 status += MXL_ControlWrite(fe, IF_DIVVAL, 0x08);
2154 status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x0C);
2155 Fref = 321200000UL ;
2156 }
2157 if (state->IF_LO == 40650000UL) {
2158 status += MXL_ControlWrite(fe, IF_DIVVAL, 0x08);
2159 status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x0C);
2160 Fref = 325200000UL ;
2161 }
2162 }
2163
2164 if (state->Mode || (state->Mode == 0 && state->IF_Mode == 0)) {
2165 if (state->IF_LO == 57000000UL) {
2166 status += MXL_ControlWrite(fe, IF_DIVVAL, 0x10);
2167 status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x08);
2168 Fref = 342000000UL ;
2169 }
2170 if (state->IF_LO == 44000000UL) {
2171 status += MXL_ControlWrite(fe, IF_DIVVAL, 0x08);
2172 status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x08);
2173 Fref = 352000000UL ;
2174 }
2175 if (state->IF_LO == 43750000UL) {
2176 status += MXL_ControlWrite(fe, IF_DIVVAL, 0x08);
2177 status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x08);
2178 Fref = 350000000UL ;
2179 }
2180 if (state->IF_LO == 36650000UL) {
2181 status += MXL_ControlWrite(fe, IF_DIVVAL, 0x04);
2182 status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x08);
2183 Fref = 366500000UL ;
2184 }
2185 if (state->IF_LO == 36150000UL) {
2186 status += MXL_ControlWrite(fe, IF_DIVVAL, 0x04);
2187 status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x08);
2188 Fref = 361500000UL ;
2189 }
2190 if (state->IF_LO == 36000000UL) {
2191 status += MXL_ControlWrite(fe, IF_DIVVAL, 0x04);
2192 status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x08);
2193 Fref = 360000000UL ;
2194 }
2195 if (state->IF_LO == 35250000UL) {
2196 status += MXL_ControlWrite(fe, IF_DIVVAL, 0x04);
2197 status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x08);
2198 Fref = 352500000UL ;
2199 }
2200 if (state->IF_LO == 34750000UL) {
2201 status += MXL_ControlWrite(fe, IF_DIVVAL, 0x04);
2202 status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x08);
2203 Fref = 347500000UL ;
2204 }
2205 if (state->IF_LO == 6280000UL) {
2206 status += MXL_ControlWrite(fe, IF_DIVVAL, 0x07);
2207 status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x08);
2208 Fref = 376800000UL ;
2209 }
2210 if (state->IF_LO == 5000000UL) {
2211 status += MXL_ControlWrite(fe, IF_DIVVAL, 0x09);
2212 status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x08);
2213 Fref = 360000000UL ;
2214 }
2215 if (state->IF_LO == 4500000UL) {
2216 status += MXL_ControlWrite(fe, IF_DIVVAL, 0x06);
2217 status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x08);
2218 Fref = 360000000UL ;
2219 }
2220 if (state->IF_LO == 4570000UL) {
2221 status += MXL_ControlWrite(fe, IF_DIVVAL, 0x06);
2222 status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x08);
2223 Fref = 365600000UL ;
2224 }
2225 if (state->IF_LO == 4000000UL) {
2226 status += MXL_ControlWrite(fe, IF_DIVVAL, 0x05);
2227 status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x08);
2228 Fref = 360000000UL ;
2229 }
2230 if (state->IF_LO == 57400000UL) {
2231 status += MXL_ControlWrite(fe, IF_DIVVAL, 0x10);
2232 status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x08);
2233 Fref = 344400000UL ;
2234 }
2235 if (state->IF_LO == 44400000UL) {
2236 status += MXL_ControlWrite(fe, IF_DIVVAL, 0x08);
2237 status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x08);
2238 Fref = 355200000UL ;
2239 }
2240 if (state->IF_LO == 44150000UL) {
2241 status += MXL_ControlWrite(fe, IF_DIVVAL, 0x08);
2242 status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x08);
2243 Fref = 353200000UL ;
2244 }
2245 if (state->IF_LO == 37050000UL) {
2246 status += MXL_ControlWrite(fe, IF_DIVVAL, 0x04);
2247 status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x08);
2248 Fref = 370500000UL ;
2249 }
2250 if (state->IF_LO == 36550000UL) {
2251 status += MXL_ControlWrite(fe, IF_DIVVAL, 0x04);
2252 status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x08);
2253 Fref = 365500000UL ;
2254 }
2255 if (state->IF_LO == 36125000UL) {
2256 status += MXL_ControlWrite(fe, IF_DIVVAL, 0x04);
2257 status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x08);
2258 Fref = 361250000UL ;
2259 }
2260 if (state->IF_LO == 6000000UL) {
2261 status += MXL_ControlWrite(fe, IF_DIVVAL, 0x07);
2262 status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x08);
2263 Fref = 360000000UL ;
2264 }
2265 if (state->IF_LO == 5400000UL) {
2266 status += MXL_ControlWrite(fe, IF_DIVVAL, 0x07);
2267 status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x0C);
2268 Fref = 324000000UL ;
2269 }
2270 if (state->IF_LO == 5380000UL) {
2271 status += MXL_ControlWrite(fe, IF_DIVVAL, 0x07);
2272 status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x0C);
2273 Fref = 322800000UL ;
2274 }
2275 if (state->IF_LO == 5200000UL) {
2276 status += MXL_ControlWrite(fe, IF_DIVVAL, 0x09);
2277 status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x08);
2278 Fref = 374400000UL ;
2279 }
2280 if (state->IF_LO == 4900000UL) {
2281 status += MXL_ControlWrite(fe, IF_DIVVAL, 0x09);
2282 status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x08);
2283 Fref = 352800000UL ;
2284 }
2285 if (state->IF_LO == 4400000UL) {
2286 status += MXL_ControlWrite(fe, IF_DIVVAL, 0x06);
2287 status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x08);
2288 Fref = 352000000UL ;
2289 }
2290 if (state->IF_LO == 4063000UL) /* add for 2.6.8 */ {
2291 status += MXL_ControlWrite(fe, IF_DIVVAL, 0x05);
2292 status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x08);
2293 Fref = 365670000UL ;
2294 }
2295 }
2296 /* CHCAL_INT_MOD_IF */
2297 /* CHCAL_FRAC_MOD_IF */
2298 intModVal = Fref / (state->Fxtal * Kdbl/2);
2299 status += MXL_ControlWrite(fe, CHCAL_INT_MOD_IF, intModVal);
2300
2301 fracModVal = (2<<15)*(Fref/1000 - (state->Fxtal/1000 * Kdbl/2) *
2302 intModVal);
2303
2304 fracModVal = fracModVal / ((state->Fxtal * Kdbl/2)/1000);
2305 status += MXL_ControlWrite(fe, CHCAL_FRAC_MOD_IF, fracModVal);
2306
2307 return status ;
2308}
2309
2310static u32 MXL_GetXtalInt(u32 Xtal_Freq)
2311{
2312 if ((Xtal_Freq % 1000000) == 0)
2313 return (Xtal_Freq / 10000);
2314 else
2315 return (((Xtal_Freq / 1000000) + 1)*100);
2316}
2317
2318static u16 MXL_TuneRF(struct dvb_frontend *fe, u32 RF_Freq)
2319{
2320 struct mxl5005s_state *state = fe->tuner_priv;
2321 u16 status = 0;
2322 u32 divider_val, E3, E4, E5, E5A;
2323 u32 Fmax, Fmin, FmaxBin, FminBin;
2324 u32 Kdbl_RF = 2;
2325 u32 tg_divval;
2326 u32 tg_lo;
2327 u32 Xtal_Int;
2328
2329 u32 Fref_TG;
2330 u32 Fvco;
2331
2332 Xtal_Int = MXL_GetXtalInt(state->Fxtal);
2333
2334 state->RF_IN = RF_Freq;
2335
2336 MXL_SynthRFTGLO_Calc(fe);
2337
2338 if (state->Fxtal >= 12000000UL && state->Fxtal <= 22000000UL)
2339 Kdbl_RF = 2;
2340 if (state->Fxtal > 22000000 && state->Fxtal <= 32000000)
2341 Kdbl_RF = 1;
2342
2343 /* Downconverter Controls
2344 * Look-Up Table Implementation for:
2345 * DN_POLY
2346 * DN_RFGAIN
2347 * DN_CAP_RFLPF
2348 * DN_EN_VHFUHFBAR
2349 * DN_GAIN_ADJUST
2350 * Change the boundary reference from RF_IN to RF_LO
2351 */
2352 if (state->RF_LO < 40000000UL)
2353 return -1;
2354
2355 if (state->RF_LO >= 40000000UL && state->RF_LO <= 75000000UL) {
2356 status += MXL_ControlWrite(fe, DN_POLY, 2);
2357 status += MXL_ControlWrite(fe, DN_RFGAIN, 3);
2358 status += MXL_ControlWrite(fe, DN_CAP_RFLPF, 423);
2359 status += MXL_ControlWrite(fe, DN_EN_VHFUHFBAR, 1);
2360 status += MXL_ControlWrite(fe, DN_GAIN_ADJUST, 1);
2361 }
2362 if (state->RF_LO > 75000000UL && state->RF_LO <= 100000000UL) {
2363 status += MXL_ControlWrite(fe, DN_POLY, 3);
2364 status += MXL_ControlWrite(fe, DN_RFGAIN, 3);
2365 status += MXL_ControlWrite(fe, DN_CAP_RFLPF, 222);
2366 status += MXL_ControlWrite(fe, DN_EN_VHFUHFBAR, 1);
2367 status += MXL_ControlWrite(fe, DN_GAIN_ADJUST, 1);
2368 }
2369 if (state->RF_LO > 100000000UL && state->RF_LO <= 150000000UL) {
2370 status += MXL_ControlWrite(fe, DN_POLY, 3);
2371 status += MXL_ControlWrite(fe, DN_RFGAIN, 3);
2372 status += MXL_ControlWrite(fe, DN_CAP_RFLPF, 147);
2373 status += MXL_ControlWrite(fe, DN_EN_VHFUHFBAR, 1);
2374 status += MXL_ControlWrite(fe, DN_GAIN_ADJUST, 2);
2375 }
2376 if (state->RF_LO > 150000000UL && state->RF_LO <= 200000000UL) {
2377 status += MXL_ControlWrite(fe, DN_POLY, 3);
2378 status += MXL_ControlWrite(fe, DN_RFGAIN, 3);
2379 status += MXL_ControlWrite(fe, DN_CAP_RFLPF, 9);
2380 status += MXL_ControlWrite(fe, DN_EN_VHFUHFBAR, 1);
2381 status += MXL_ControlWrite(fe, DN_GAIN_ADJUST, 2);
2382 }
2383 if (state->RF_LO > 200000000UL && state->RF_LO <= 300000000UL) {
2384 status += MXL_ControlWrite(fe, DN_POLY, 3);
2385 status += MXL_ControlWrite(fe, DN_RFGAIN, 3);
2386 status += MXL_ControlWrite(fe, DN_CAP_RFLPF, 0);
2387 status += MXL_ControlWrite(fe, DN_EN_VHFUHFBAR, 1);
2388 status += MXL_ControlWrite(fe, DN_GAIN_ADJUST, 3);
2389 }
2390 if (state->RF_LO > 300000000UL && state->RF_LO <= 650000000UL) {
2391 status += MXL_ControlWrite(fe, DN_POLY, 3);
2392 status += MXL_ControlWrite(fe, DN_RFGAIN, 1);
2393 status += MXL_ControlWrite(fe, DN_CAP_RFLPF, 0);
2394 status += MXL_ControlWrite(fe, DN_EN_VHFUHFBAR, 0);
2395 status += MXL_ControlWrite(fe, DN_GAIN_ADJUST, 3);
2396 }
2397 if (state->RF_LO > 650000000UL && state->RF_LO <= 900000000UL) {
2398 status += MXL_ControlWrite(fe, DN_POLY, 3);
2399 status += MXL_ControlWrite(fe, DN_RFGAIN, 2);
2400 status += MXL_ControlWrite(fe, DN_CAP_RFLPF, 0);
2401 status += MXL_ControlWrite(fe, DN_EN_VHFUHFBAR, 0);
2402 status += MXL_ControlWrite(fe, DN_GAIN_ADJUST, 3);
2403 }
2404 if (state->RF_LO > 900000000UL)
2405 return -1;
2406
2407 /* DN_IQTNBUF_AMP */
2408 /* DN_IQTNGNBFBIAS_BST */
2409 if (state->RF_LO >= 40000000UL && state->RF_LO <= 75000000UL) {
2410 status += MXL_ControlWrite(fe, DN_IQTNBUF_AMP, 1);
2411 status += MXL_ControlWrite(fe, DN_IQTNGNBFBIAS_BST, 0);
2412 }
2413 if (state->RF_LO > 75000000UL && state->RF_LO <= 100000000UL) {
2414 status += MXL_ControlWrite(fe, DN_IQTNBUF_AMP, 1);
2415 status += MXL_ControlWrite(fe, DN_IQTNGNBFBIAS_BST, 0);
2416 }
2417 if (state->RF_LO > 100000000UL && state->RF_LO <= 150000000UL) {
2418 status += MXL_ControlWrite(fe, DN_IQTNBUF_AMP, 1);
2419 status += MXL_ControlWrite(fe, DN_IQTNGNBFBIAS_BST, 0);
2420 }
2421 if (state->RF_LO > 150000000UL && state->RF_LO <= 200000000UL) {
2422 status += MXL_ControlWrite(fe, DN_IQTNBUF_AMP, 1);
2423 status += MXL_ControlWrite(fe, DN_IQTNGNBFBIAS_BST, 0);
2424 }
2425 if (state->RF_LO > 200000000UL && state->RF_LO <= 300000000UL) {
2426 status += MXL_ControlWrite(fe, DN_IQTNBUF_AMP, 1);
2427 status += MXL_ControlWrite(fe, DN_IQTNGNBFBIAS_BST, 0);
2428 }
2429 if (state->RF_LO > 300000000UL && state->RF_LO <= 400000000UL) {
2430 status += MXL_ControlWrite(fe, DN_IQTNBUF_AMP, 1);
2431 status += MXL_ControlWrite(fe, DN_IQTNGNBFBIAS_BST, 0);
2432 }
2433 if (state->RF_LO > 400000000UL && state->RF_LO <= 450000000UL) {
2434 status += MXL_ControlWrite(fe, DN_IQTNBUF_AMP, 1);
2435 status += MXL_ControlWrite(fe, DN_IQTNGNBFBIAS_BST, 0);
2436 }
2437 if (state->RF_LO > 450000000UL && state->RF_LO <= 500000000UL) {
2438 status += MXL_ControlWrite(fe, DN_IQTNBUF_AMP, 1);
2439 status += MXL_ControlWrite(fe, DN_IQTNGNBFBIAS_BST, 0);
2440 }
2441 if (state->RF_LO > 500000000UL && state->RF_LO <= 550000000UL) {
2442 status += MXL_ControlWrite(fe, DN_IQTNBUF_AMP, 1);
2443 status += MXL_ControlWrite(fe, DN_IQTNGNBFBIAS_BST, 0);
2444 }
2445 if (state->RF_LO > 550000000UL && state->RF_LO <= 600000000UL) {
2446 status += MXL_ControlWrite(fe, DN_IQTNBUF_AMP, 1);
2447 status += MXL_ControlWrite(fe, DN_IQTNGNBFBIAS_BST, 0);
2448 }
2449 if (state->RF_LO > 600000000UL && state->RF_LO <= 650000000UL) {
2450 status += MXL_ControlWrite(fe, DN_IQTNBUF_AMP, 1);
2451 status += MXL_ControlWrite(fe, DN_IQTNGNBFBIAS_BST, 0);
2452 }
2453 if (state->RF_LO > 650000000UL && state->RF_LO <= 700000000UL) {
2454 status += MXL_ControlWrite(fe, DN_IQTNBUF_AMP, 1);
2455 status += MXL_ControlWrite(fe, DN_IQTNGNBFBIAS_BST, 0);
2456 }
2457 if (state->RF_LO > 700000000UL && state->RF_LO <= 750000000UL) {
2458 status += MXL_ControlWrite(fe, DN_IQTNBUF_AMP, 1);
2459 status += MXL_ControlWrite(fe, DN_IQTNGNBFBIAS_BST, 0);
2460 }
2461 if (state->RF_LO > 750000000UL && state->RF_LO <= 800000000UL) {
2462 status += MXL_ControlWrite(fe, DN_IQTNBUF_AMP, 1);
2463 status += MXL_ControlWrite(fe, DN_IQTNGNBFBIAS_BST, 0);
2464 }
2465 if (state->RF_LO > 800000000UL && state->RF_LO <= 850000000UL) {
2466 status += MXL_ControlWrite(fe, DN_IQTNBUF_AMP, 10);
2467 status += MXL_ControlWrite(fe, DN_IQTNGNBFBIAS_BST, 1);
2468 }
2469 if (state->RF_LO > 850000000UL && state->RF_LO <= 900000000UL) {
2470 status += MXL_ControlWrite(fe, DN_IQTNBUF_AMP, 10);
2471 status += MXL_ControlWrite(fe, DN_IQTNGNBFBIAS_BST, 1);
2472 }
2473
2474 /*
2475 * Set RF Synth and LO Path Control
2476 *
2477 * Look-Up table implementation for:
2478 * RFSYN_EN_OUTMUX
2479 * RFSYN_SEL_VCO_OUT
2480 * RFSYN_SEL_VCO_HI
2481 * RFSYN_SEL_DIVM
2482 * RFSYN_RF_DIV_BIAS
2483 * DN_SEL_FREQ
2484 *
2485 * Set divider_val, Fmax, Fmix to use in Equations
2486 */
2487 FminBin = 28000000UL ;
2488 FmaxBin = 42500000UL ;
2489 if (state->RF_LO >= 40000000UL && state->RF_LO <= FmaxBin) {
2490 status += MXL_ControlWrite(fe, RFSYN_EN_OUTMUX, 1);
2491 status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_OUT, 0);
2492 status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_HI, 0);
2493 status += MXL_ControlWrite(fe, RFSYN_SEL_DIVM, 0);
2494 status += MXL_ControlWrite(fe, RFSYN_RF_DIV_BIAS, 1);
2495 status += MXL_ControlWrite(fe, DN_SEL_FREQ, 1);
2496 divider_val = 64 ;
2497 Fmax = FmaxBin ;
2498 Fmin = FminBin ;
2499 }
2500 FminBin = 42500000UL ;
2501 FmaxBin = 56000000UL ;
2502 if (state->RF_LO > FminBin && state->RF_LO <= FmaxBin) {
2503 status += MXL_ControlWrite(fe, RFSYN_EN_OUTMUX, 1);
2504 status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_OUT, 0);
2505 status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_HI, 1);
2506 status += MXL_ControlWrite(fe, RFSYN_SEL_DIVM, 0);
2507 status += MXL_ControlWrite(fe, RFSYN_RF_DIV_BIAS, 1);
2508 status += MXL_ControlWrite(fe, DN_SEL_FREQ, 1);
2509 divider_val = 64 ;
2510 Fmax = FmaxBin ;
2511 Fmin = FminBin ;
2512 }
2513 FminBin = 56000000UL ;
2514 FmaxBin = 85000000UL ;
2515 if (state->RF_LO > FminBin && state->RF_LO <= FmaxBin) {
2516 status += MXL_ControlWrite(fe, RFSYN_EN_OUTMUX, 0);
2517 status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_OUT, 1);
2518 status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_HI, 0);
2519 status += MXL_ControlWrite(fe, RFSYN_SEL_DIVM, 0);
2520 status += MXL_ControlWrite(fe, RFSYN_RF_DIV_BIAS, 1);
2521 status += MXL_ControlWrite(fe, DN_SEL_FREQ, 1);
2522 divider_val = 32 ;
2523 Fmax = FmaxBin ;
2524 Fmin = FminBin ;
2525 }
2526 FminBin = 85000000UL ;
2527 FmaxBin = 112000000UL ;
2528 if (state->RF_LO > FminBin && state->RF_LO <= FmaxBin) {
2529 status += MXL_ControlWrite(fe, RFSYN_EN_OUTMUX, 0);
2530 status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_OUT, 1);
2531 status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_HI, 1);
2532 status += MXL_ControlWrite(fe, RFSYN_SEL_DIVM, 0);
2533 status += MXL_ControlWrite(fe, RFSYN_RF_DIV_BIAS, 1);
2534 status += MXL_ControlWrite(fe, DN_SEL_FREQ, 1);
2535 divider_val = 32 ;
2536 Fmax = FmaxBin ;
2537 Fmin = FminBin ;
2538 }
2539 FminBin = 112000000UL ;
2540 FmaxBin = 170000000UL ;
2541 if (state->RF_LO > FminBin && state->RF_LO <= FmaxBin) {
2542 status += MXL_ControlWrite(fe, RFSYN_EN_OUTMUX, 0);
2543 status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_OUT, 1);
2544 status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_HI, 0);
2545 status += MXL_ControlWrite(fe, RFSYN_SEL_DIVM, 0);
2546 status += MXL_ControlWrite(fe, RFSYN_RF_DIV_BIAS, 1);
2547 status += MXL_ControlWrite(fe, DN_SEL_FREQ, 2);
2548 divider_val = 16 ;
2549 Fmax = FmaxBin ;
2550 Fmin = FminBin ;
2551 }
2552 FminBin = 170000000UL ;
2553 FmaxBin = 225000000UL ;
2554 if (state->RF_LO > FminBin && state->RF_LO <= FmaxBin) {
2555 status += MXL_ControlWrite(fe, RFSYN_EN_OUTMUX, 0);
2556 status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_OUT, 1);
2557 status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_HI, 1);
2558 status += MXL_ControlWrite(fe, RFSYN_SEL_DIVM, 0);
2559 status += MXL_ControlWrite(fe, RFSYN_RF_DIV_BIAS, 1);
2560 status += MXL_ControlWrite(fe, DN_SEL_FREQ, 2);
2561 divider_val = 16 ;
2562 Fmax = FmaxBin ;
2563 Fmin = FminBin ;
2564 }
2565 FminBin = 225000000UL ;
2566 FmaxBin = 300000000UL ;
2567 if (state->RF_LO > FminBin && state->RF_LO <= FmaxBin) {
2568 status += MXL_ControlWrite(fe, RFSYN_EN_OUTMUX, 0);
2569 status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_OUT, 1);
2570 status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_HI, 0);
2571 status += MXL_ControlWrite(fe, RFSYN_SEL_DIVM, 0);
2572 status += MXL_ControlWrite(fe, RFSYN_RF_DIV_BIAS, 1);
2573 status += MXL_ControlWrite(fe, DN_SEL_FREQ, 4);
2574 divider_val = 8 ;
2575 Fmax = 340000000UL ;
2576 Fmin = FminBin ;
2577 }
2578 FminBin = 300000000UL ;
2579 FmaxBin = 340000000UL ;
2580 if (state->RF_LO > FminBin && state->RF_LO <= FmaxBin) {
2581 status += MXL_ControlWrite(fe, RFSYN_EN_OUTMUX, 1);
2582 status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_OUT, 0);
2583 status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_HI, 0);
2584 status += MXL_ControlWrite(fe, RFSYN_SEL_DIVM, 0);
2585 status += MXL_ControlWrite(fe, RFSYN_RF_DIV_BIAS, 1);
2586 status += MXL_ControlWrite(fe, DN_SEL_FREQ, 0);
2587 divider_val = 8 ;
2588 Fmax = FmaxBin ;
2589 Fmin = 225000000UL ;
2590 }
2591 FminBin = 340000000UL ;
2592 FmaxBin = 450000000UL ;
2593 if (state->RF_LO > FminBin && state->RF_LO <= FmaxBin) {
2594 status += MXL_ControlWrite(fe, RFSYN_EN_OUTMUX, 1);
2595 status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_OUT, 0);
2596 status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_HI, 1);
2597 status += MXL_ControlWrite(fe, RFSYN_SEL_DIVM, 0);
2598 status += MXL_ControlWrite(fe, RFSYN_RF_DIV_BIAS, 2);
2599 status += MXL_ControlWrite(fe, DN_SEL_FREQ, 0);
2600 divider_val = 8 ;
2601 Fmax = FmaxBin ;
2602 Fmin = FminBin ;
2603 }
2604 FminBin = 450000000UL ;
2605 FmaxBin = 680000000UL ;
2606 if (state->RF_LO > FminBin && state->RF_LO <= FmaxBin) {
2607 status += MXL_ControlWrite(fe, RFSYN_EN_OUTMUX, 0);
2608 status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_OUT, 1);
2609 status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_HI, 0);
2610 status += MXL_ControlWrite(fe, RFSYN_SEL_DIVM, 1);
2611 status += MXL_ControlWrite(fe, RFSYN_RF_DIV_BIAS, 1);
2612 status += MXL_ControlWrite(fe, DN_SEL_FREQ, 0);
2613 divider_val = 4 ;
2614 Fmax = FmaxBin ;
2615 Fmin = FminBin ;
2616 }
2617 FminBin = 680000000UL ;
2618 FmaxBin = 900000000UL ;
2619 if (state->RF_LO > FminBin && state->RF_LO <= FmaxBin) {
2620 status += MXL_ControlWrite(fe, RFSYN_EN_OUTMUX, 0);
2621 status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_OUT, 1);
2622 status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_HI, 1);
2623 status += MXL_ControlWrite(fe, RFSYN_SEL_DIVM, 1);
2624 status += MXL_ControlWrite(fe, RFSYN_RF_DIV_BIAS, 1);
2625 status += MXL_ControlWrite(fe, DN_SEL_FREQ, 0);
2626 divider_val = 4 ;
2627 Fmax = FmaxBin ;
2628 Fmin = FminBin ;
2629 }
2630
2631 /* CHCAL_INT_MOD_RF
2632 * CHCAL_FRAC_MOD_RF
2633 * RFSYN_LPF_R
2634 * CHCAL_EN_INT_RF
2635 */
2636 /* Equation E3 RFSYN_VCO_BIAS */
2637 E3 = (((Fmax-state->RF_LO)/1000)*32)/((Fmax-Fmin)/1000) + 8 ;
2638 status += MXL_ControlWrite(fe, RFSYN_VCO_BIAS, E3);
2639
2640 /* Equation E4 CHCAL_INT_MOD_RF */
2641 E4 = (state->RF_LO*divider_val/1000)/(2*state->Fxtal*Kdbl_RF/1000);
2642 MXL_ControlWrite(fe, CHCAL_INT_MOD_RF, E4);
2643
2644 /* Equation E5 CHCAL_FRAC_MOD_RF CHCAL_EN_INT_RF */
2645 E5 = ((2<<17)*(state->RF_LO/10000*divider_val -
2646 (E4*(2*state->Fxtal*Kdbl_RF)/10000))) /
2647 (2*state->Fxtal*Kdbl_RF/10000);
2648
2649 status += MXL_ControlWrite(fe, CHCAL_FRAC_MOD_RF, E5);
2650
2651 /* Equation E5A RFSYN_LPF_R */
2652 E5A = (((Fmax - state->RF_LO)/1000)*4/((Fmax-Fmin)/1000)) + 1 ;
2653 status += MXL_ControlWrite(fe, RFSYN_LPF_R, E5A);
2654
2655 /* Euqation E5B CHCAL_EN_INIT_RF */
2656 status += MXL_ControlWrite(fe, CHCAL_EN_INT_RF, ((E5 == 0) ? 1 : 0));
2657 /*if (E5 == 0)
2658 * status += MXL_ControlWrite(fe, CHCAL_EN_INT_RF, 1);
2659 *else
2660 * status += MXL_ControlWrite(fe, CHCAL_FRAC_MOD_RF, E5);
2661 */
2662
2663 /*
2664 * Set TG Synth
2665 *
2666 * Look-Up table implementation for:
2667 * TG_LO_DIVVAL
2668 * TG_LO_SELVAL
2669 *
2670 * Set divider_val, Fmax, Fmix to use in Equations
2671 */
2672 if (state->TG_LO < 33000000UL)
2673 return -1;
2674
2675 FminBin = 33000000UL ;
2676 FmaxBin = 50000000UL ;
2677 if (state->TG_LO >= FminBin && state->TG_LO <= FmaxBin) {
2678 status += MXL_ControlWrite(fe, TG_LO_DIVVAL, 0x6);
2679 status += MXL_ControlWrite(fe, TG_LO_SELVAL, 0x0);
2680 divider_val = 36 ;
2681 Fmax = FmaxBin ;
2682 Fmin = FminBin ;
2683 }
2684 FminBin = 50000000UL ;
2685 FmaxBin = 67000000UL ;
2686 if (state->TG_LO > FminBin && state->TG_LO <= FmaxBin) {
2687 status += MXL_ControlWrite(fe, TG_LO_DIVVAL, 0x1);
2688 status += MXL_ControlWrite(fe, TG_LO_SELVAL, 0x0);
2689 divider_val = 24 ;
2690 Fmax = FmaxBin ;
2691 Fmin = FminBin ;
2692 }
2693 FminBin = 67000000UL ;
2694 FmaxBin = 100000000UL ;
2695 if (state->TG_LO > FminBin && state->TG_LO <= FmaxBin) {
2696 status += MXL_ControlWrite(fe, TG_LO_DIVVAL, 0xC);
2697 status += MXL_ControlWrite(fe, TG_LO_SELVAL, 0x2);
2698 divider_val = 18 ;
2699 Fmax = FmaxBin ;
2700 Fmin = FminBin ;
2701 }
2702 FminBin = 100000000UL ;
2703 FmaxBin = 150000000UL ;
2704 if (state->TG_LO > FminBin && state->TG_LO <= FmaxBin) {
2705 status += MXL_ControlWrite(fe, TG_LO_DIVVAL, 0x8);
2706 status += MXL_ControlWrite(fe, TG_LO_SELVAL, 0x2);
2707 divider_val = 12 ;
2708 Fmax = FmaxBin ;
2709 Fmin = FminBin ;
2710 }
2711 FminBin = 150000000UL ;
2712 FmaxBin = 200000000UL ;
2713 if (state->TG_LO > FminBin && state->TG_LO <= FmaxBin) {
2714 status += MXL_ControlWrite(fe, TG_LO_DIVVAL, 0x0);
2715 status += MXL_ControlWrite(fe, TG_LO_SELVAL, 0x2);
2716 divider_val = 8 ;
2717 Fmax = FmaxBin ;
2718 Fmin = FminBin ;
2719 }
2720 FminBin = 200000000UL ;
2721 FmaxBin = 300000000UL ;
2722 if (state->TG_LO > FminBin && state->TG_LO <= FmaxBin) {
2723 status += MXL_ControlWrite(fe, TG_LO_DIVVAL, 0x8);
2724 status += MXL_ControlWrite(fe, TG_LO_SELVAL, 0x3);
2725 divider_val = 6 ;
2726 Fmax = FmaxBin ;
2727 Fmin = FminBin ;
2728 }
2729 FminBin = 300000000UL ;
2730 FmaxBin = 400000000UL ;
2731 if (state->TG_LO > FminBin && state->TG_LO <= FmaxBin) {
2732 status += MXL_ControlWrite(fe, TG_LO_DIVVAL, 0x0);
2733 status += MXL_ControlWrite(fe, TG_LO_SELVAL, 0x3);
2734 divider_val = 4 ;
2735 Fmax = FmaxBin ;
2736 Fmin = FminBin ;
2737 }
2738 FminBin = 400000000UL ;
2739 FmaxBin = 600000000UL ;
2740 if (state->TG_LO > FminBin && state->TG_LO <= FmaxBin) {
2741 status += MXL_ControlWrite(fe, TG_LO_DIVVAL, 0x8);
2742 status += MXL_ControlWrite(fe, TG_LO_SELVAL, 0x7);
2743 divider_val = 3 ;
2744 Fmax = FmaxBin ;
2745 Fmin = FminBin ;
2746 }
2747 FminBin = 600000000UL ;
2748 FmaxBin = 900000000UL ;
2749 if (state->TG_LO > FminBin && state->TG_LO <= FmaxBin) {
2750 status += MXL_ControlWrite(fe, TG_LO_DIVVAL, 0x0);
2751 status += MXL_ControlWrite(fe, TG_LO_SELVAL, 0x7);
2752 divider_val = 2 ;
2753 Fmax = FmaxBin ;
2754 Fmin = FminBin ;
2755 }
2756
2757 /* TG_DIV_VAL */
2758 tg_divval = (state->TG_LO*divider_val/100000) *
2759 (MXL_Ceiling(state->Fxtal, 1000000) * 100) /
2760 (state->Fxtal/1000);
2761
2762 status += MXL_ControlWrite(fe, TG_DIV_VAL, tg_divval);
2763
2764 if (state->TG_LO > 600000000UL)
2765 status += MXL_ControlWrite(fe, TG_DIV_VAL, tg_divval + 1);
2766
2767 Fmax = 1800000000UL ;
2768 Fmin = 1200000000UL ;
2769
2770 /* prevent overflow of 32 bit unsigned integer, use
2771 * following equation. Edit for v2.6.4
2772 */
2773 /* Fref_TF = Fref_TG * 1000 */
2774 Fref_TG = (state->Fxtal/1000) / MXL_Ceiling(state->Fxtal, 1000000);
2775
2776 /* Fvco = Fvco/10 */
2777 Fvco = (state->TG_LO/10000) * divider_val * Fref_TG;
2778
2779 tg_lo = (((Fmax/10 - Fvco)/100)*32) / ((Fmax-Fmin)/1000)+8;
2780
2781 /* below equation is same as above but much harder to debug.
2782 * tg_lo = ( ((Fmax/10000 * Xtal_Int)/100) -
2783 * ((state->TG_LO/10000)*divider_val *
2784 * (state->Fxtal/10000)/100) )*32/((Fmax-Fmin)/10000 *
2785 * Xtal_Int/100) + 8;
2786 */
2787
2788 status += MXL_ControlWrite(fe, TG_VCO_BIAS , tg_lo);
2789
2790 /* add for 2.6.5 Special setting for QAM */
2791 if (state->Mod_Type == MXL_QAM) {
2792 if (state->RF_IN < 680000000)
2793 status += MXL_ControlWrite(fe, RFSYN_CHP_GAIN, 3);
2794 else
2795 status += MXL_ControlWrite(fe, RFSYN_CHP_GAIN, 2);
2796 }
2797
2798 /* Off Chip Tracking Filter Control */
2799 if (state->TF_Type == MXL_TF_OFF) {
2800 /* Tracking Filter Off State; turn off all the banks */
2801 status += MXL_ControlWrite(fe, DAC_A_ENABLE, 0);
2802 status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0);
2803 status += MXL_SetGPIO(fe, 3, 1); /* Bank1 Off */
2804 status += MXL_SetGPIO(fe, 1, 1); /* Bank2 Off */
2805 status += MXL_SetGPIO(fe, 4, 1); /* Bank3 Off */
2806 }
2807
2808 if (state->TF_Type == MXL_TF_C) /* Tracking Filter type C */ {
2809 status += MXL_ControlWrite(fe, DAC_B_ENABLE, 1);
2810 status += MXL_ControlWrite(fe, DAC_DIN_A, 0);
2811
2812 if (state->RF_IN >= 43000000 && state->RF_IN < 150000000) {
2813 status += MXL_ControlWrite(fe, DAC_A_ENABLE, 0);
2814 status += MXL_ControlWrite(fe, DAC_DIN_B, 0);
2815 status += MXL_SetGPIO(fe, 3, 0);
2816 status += MXL_SetGPIO(fe, 1, 1);
2817 status += MXL_SetGPIO(fe, 4, 1);
2818 }
2819 if (state->RF_IN >= 150000000 && state->RF_IN < 280000000) {
2820 status += MXL_ControlWrite(fe, DAC_A_ENABLE, 0);
2821 status += MXL_ControlWrite(fe, DAC_DIN_B, 0);
2822 status += MXL_SetGPIO(fe, 3, 1);
2823 status += MXL_SetGPIO(fe, 1, 0);
2824 status += MXL_SetGPIO(fe, 4, 1);
2825 }
2826 if (state->RF_IN >= 280000000 && state->RF_IN < 360000000) {
2827 status += MXL_ControlWrite(fe, DAC_A_ENABLE, 0);
2828 status += MXL_ControlWrite(fe, DAC_DIN_B, 0);
2829 status += MXL_SetGPIO(fe, 3, 1);
2830 status += MXL_SetGPIO(fe, 1, 0);
2831 status += MXL_SetGPIO(fe, 4, 0);
2832 }
2833 if (state->RF_IN >= 360000000 && state->RF_IN < 560000000) {
2834 status += MXL_ControlWrite(fe, DAC_A_ENABLE, 0);
2835 status += MXL_ControlWrite(fe, DAC_DIN_B, 0);
2836 status += MXL_SetGPIO(fe, 3, 1);
2837 status += MXL_SetGPIO(fe, 1, 1);
2838 status += MXL_SetGPIO(fe, 4, 0);
2839 }
2840 if (state->RF_IN >= 560000000 && state->RF_IN < 580000000) {
2841 status += MXL_ControlWrite(fe, DAC_A_ENABLE, 1);
2842 status += MXL_ControlWrite(fe, DAC_DIN_B, 29);
2843 status += MXL_SetGPIO(fe, 3, 1);
2844 status += MXL_SetGPIO(fe, 1, 1);
2845 status += MXL_SetGPIO(fe, 4, 0);
2846 }
2847 if (state->RF_IN >= 580000000 && state->RF_IN < 630000000) {
2848 status += MXL_ControlWrite(fe, DAC_A_ENABLE, 1);
2849 status += MXL_ControlWrite(fe, DAC_DIN_B, 0);
2850 status += MXL_SetGPIO(fe, 3, 1);
2851 status += MXL_SetGPIO(fe, 1, 1);
2852 status += MXL_SetGPIO(fe, 4, 0);
2853 }
2854 if (state->RF_IN >= 630000000 && state->RF_IN < 700000000) {
2855 status += MXL_ControlWrite(fe, DAC_A_ENABLE, 1);
2856 status += MXL_ControlWrite(fe, DAC_DIN_B, 16);
2857 status += MXL_SetGPIO(fe, 3, 1);
2858 status += MXL_SetGPIO(fe, 1, 1);
2859 status += MXL_SetGPIO(fe, 4, 1);
2860 }
2861 if (state->RF_IN >= 700000000 && state->RF_IN < 760000000) {
2862 status += MXL_ControlWrite(fe, DAC_A_ENABLE, 1);
2863 status += MXL_ControlWrite(fe, DAC_DIN_B, 7);
2864 status += MXL_SetGPIO(fe, 3, 1);
2865 status += MXL_SetGPIO(fe, 1, 1);
2866 status += MXL_SetGPIO(fe, 4, 1);
2867 }
2868 if (state->RF_IN >= 760000000 && state->RF_IN <= 900000000) {
2869 status += MXL_ControlWrite(fe, DAC_A_ENABLE, 1);
2870 status += MXL_ControlWrite(fe, DAC_DIN_B, 0);
2871 status += MXL_SetGPIO(fe, 3, 1);
2872 status += MXL_SetGPIO(fe, 1, 1);
2873 status += MXL_SetGPIO(fe, 4, 1);
2874 }
2875 }
2876
2877 if (state->TF_Type == MXL_TF_C_H) {
2878
2879 /* Tracking Filter type C-H for Hauppauge only */
2880 status += MXL_ControlWrite(fe, DAC_DIN_A, 0);
2881
2882 if (state->RF_IN >= 43000000 && state->RF_IN < 150000000) {
2883 status += MXL_ControlWrite(fe, DAC_A_ENABLE, 0);
2884 status += MXL_SetGPIO(fe, 4, 0);
2885 status += MXL_SetGPIO(fe, 3, 1);
2886 status += MXL_SetGPIO(fe, 1, 1);
2887 }
2888 if (state->RF_IN >= 150000000 && state->RF_IN < 280000000) {
2889 status += MXL_ControlWrite(fe, DAC_A_ENABLE, 0);
2890 status += MXL_SetGPIO(fe, 4, 1);
2891 status += MXL_SetGPIO(fe, 3, 0);
2892 status += MXL_SetGPIO(fe, 1, 1);
2893 }
2894 if (state->RF_IN >= 280000000 && state->RF_IN < 360000000) {
2895 status += MXL_ControlWrite(fe, DAC_A_ENABLE, 0);
2896 status += MXL_SetGPIO(fe, 4, 1);
2897 status += MXL_SetGPIO(fe, 3, 0);
2898 status += MXL_SetGPIO(fe, 1, 0);
2899 }
2900 if (state->RF_IN >= 360000000 && state->RF_IN < 560000000) {
2901 status += MXL_ControlWrite(fe, DAC_A_ENABLE, 0);
2902 status += MXL_SetGPIO(fe, 4, 1);
2903 status += MXL_SetGPIO(fe, 3, 1);
2904 status += MXL_SetGPIO(fe, 1, 0);
2905 }
2906 if (state->RF_IN >= 560000000 && state->RF_IN < 580000000) {
2907 status += MXL_ControlWrite(fe, DAC_A_ENABLE, 1);
2908 status += MXL_SetGPIO(fe, 4, 1);
2909 status += MXL_SetGPIO(fe, 3, 1);
2910 status += MXL_SetGPIO(fe, 1, 0);
2911 }
2912 if (state->RF_IN >= 580000000 && state->RF_IN < 630000000) {
2913 status += MXL_ControlWrite(fe, DAC_A_ENABLE, 1);
2914 status += MXL_SetGPIO(fe, 4, 1);
2915 status += MXL_SetGPIO(fe, 3, 1);
2916 status += MXL_SetGPIO(fe, 1, 0);
2917 }
2918 if (state->RF_IN >= 630000000 && state->RF_IN < 700000000) {
2919 status += MXL_ControlWrite(fe, DAC_A_ENABLE, 1);
2920 status += MXL_SetGPIO(fe, 4, 1);
2921 status += MXL_SetGPIO(fe, 3, 1);
2922 status += MXL_SetGPIO(fe, 1, 1);
2923 }
2924 if (state->RF_IN >= 700000000 && state->RF_IN < 760000000) {
2925 status += MXL_ControlWrite(fe, DAC_A_ENABLE, 1);
2926 status += MXL_SetGPIO(fe, 4, 1);
2927 status += MXL_SetGPIO(fe, 3, 1);
2928 status += MXL_SetGPIO(fe, 1, 1);
2929 }
2930 if (state->RF_IN >= 760000000 && state->RF_IN <= 900000000) {
2931 status += MXL_ControlWrite(fe, DAC_A_ENABLE, 1);
2932 status += MXL_SetGPIO(fe, 4, 1);
2933 status += MXL_SetGPIO(fe, 3, 1);
2934 status += MXL_SetGPIO(fe, 1, 1);
2935 }
2936 }
2937
2938 if (state->TF_Type == MXL_TF_D) { /* Tracking Filter type D */
2939
2940 status += MXL_ControlWrite(fe, DAC_DIN_B, 0);
2941
2942 if (state->RF_IN >= 43000000 && state->RF_IN < 174000000) {
2943 status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0);
2944 status += MXL_SetGPIO(fe, 4, 0);
2945 status += MXL_SetGPIO(fe, 1, 1);
2946 status += MXL_SetGPIO(fe, 3, 1);
2947 }
2948 if (state->RF_IN >= 174000000 && state->RF_IN < 250000000) {
2949 status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0);
2950 status += MXL_SetGPIO(fe, 4, 0);
2951 status += MXL_SetGPIO(fe, 1, 0);
2952 status += MXL_SetGPIO(fe, 3, 1);
2953 }
2954 if (state->RF_IN >= 250000000 && state->RF_IN < 310000000) {
2955 status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0);
2956 status += MXL_SetGPIO(fe, 4, 1);
2957 status += MXL_SetGPIO(fe, 1, 0);
2958 status += MXL_SetGPIO(fe, 3, 1);
2959 }
2960 if (state->RF_IN >= 310000000 && state->RF_IN < 360000000) {
2961 status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0);
2962 status += MXL_SetGPIO(fe, 4, 1);
2963 status += MXL_SetGPIO(fe, 1, 0);
2964 status += MXL_SetGPIO(fe, 3, 0);
2965 }
2966 if (state->RF_IN >= 360000000 && state->RF_IN < 470000000) {
2967 status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0);
2968 status += MXL_SetGPIO(fe, 4, 1);
2969 status += MXL_SetGPIO(fe, 1, 1);
2970 status += MXL_SetGPIO(fe, 3, 0);
2971 }
2972 if (state->RF_IN >= 470000000 && state->RF_IN < 640000000) {
2973 status += MXL_ControlWrite(fe, DAC_B_ENABLE, 1);
2974 status += MXL_SetGPIO(fe, 4, 1);
2975 status += MXL_SetGPIO(fe, 1, 1);
2976 status += MXL_SetGPIO(fe, 3, 0);
2977 }
2978 if (state->RF_IN >= 640000000 && state->RF_IN <= 900000000) {
2979 status += MXL_ControlWrite(fe, DAC_B_ENABLE, 1);
2980 status += MXL_SetGPIO(fe, 4, 1);
2981 status += MXL_SetGPIO(fe, 1, 1);
2982 status += MXL_SetGPIO(fe, 3, 1);
2983 }
2984 }
2985
2986 if (state->TF_Type == MXL_TF_D_L) {
2987
2988 /* Tracking Filter type D-L for Lumanate ONLY change 2.6.3 */
2989 status += MXL_ControlWrite(fe, DAC_DIN_A, 0);
2990
2991 /* if UHF and terrestrial => Turn off Tracking Filter */
2992 if (state->RF_IN >= 471000000 &&
2993 (state->RF_IN - 471000000)%6000000 != 0) {
2994 /* Turn off all the banks */
2995 status += MXL_SetGPIO(fe, 3, 1);
2996 status += MXL_SetGPIO(fe, 1, 1);
2997 status += MXL_SetGPIO(fe, 4, 1);
2998 status += MXL_ControlWrite(fe, DAC_A_ENABLE, 0);
2999 status += MXL_ControlWrite(fe, AGC_IF, 10);
3000 } else {
3001 /* if VHF or cable => Turn on Tracking Filter */
3002 if (state->RF_IN >= 43000000 &&
3003 state->RF_IN < 140000000) {
3004
3005 status += MXL_ControlWrite(fe, DAC_A_ENABLE, 0);
3006 status += MXL_SetGPIO(fe, 4, 1);
3007 status += MXL_SetGPIO(fe, 1, 1);
3008 status += MXL_SetGPIO(fe, 3, 0);
3009 }
3010 if (state->RF_IN >= 140000000 &&
3011 state->RF_IN < 240000000) {
3012 status += MXL_ControlWrite(fe, DAC_A_ENABLE, 0);
3013 status += MXL_SetGPIO(fe, 4, 1);
3014 status += MXL_SetGPIO(fe, 1, 0);
3015 status += MXL_SetGPIO(fe, 3, 0);
3016 }
3017 if (state->RF_IN >= 240000000 &&
3018 state->RF_IN < 340000000) {
3019 status += MXL_ControlWrite(fe, DAC_A_ENABLE, 0);
3020 status += MXL_SetGPIO(fe, 4, 0);
3021 status += MXL_SetGPIO(fe, 1, 1);
3022 status += MXL_SetGPIO(fe, 3, 0);
3023 }
3024 if (state->RF_IN >= 340000000 &&
3025 state->RF_IN < 430000000) {
3026 status += MXL_ControlWrite(fe, DAC_A_ENABLE, 0);
3027 status += MXL_SetGPIO(fe, 4, 0);
3028 status += MXL_SetGPIO(fe, 1, 0);
3029 status += MXL_SetGPIO(fe, 3, 1);
3030 }
3031 if (state->RF_IN >= 430000000 &&
3032 state->RF_IN < 470000000) {
3033 status += MXL_ControlWrite(fe, DAC_A_ENABLE, 1);
3034 status += MXL_SetGPIO(fe, 4, 1);
3035 status += MXL_SetGPIO(fe, 1, 0);
3036 status += MXL_SetGPIO(fe, 3, 1);
3037 }
3038 if (state->RF_IN >= 470000000 &&
3039 state->RF_IN < 570000000) {
3040 status += MXL_ControlWrite(fe, DAC_A_ENABLE, 1);
3041 status += MXL_SetGPIO(fe, 4, 0);
3042 status += MXL_SetGPIO(fe, 1, 0);
3043 status += MXL_SetGPIO(fe, 3, 1);
3044 }
3045 if (state->RF_IN >= 570000000 &&
3046 state->RF_IN < 620000000) {
3047 status += MXL_ControlWrite(fe, DAC_A_ENABLE, 0);
3048 status += MXL_SetGPIO(fe, 4, 0);
3049 status += MXL_SetGPIO(fe, 1, 1);
3050 status += MXL_SetGPIO(fe, 3, 1);
3051 }
3052 if (state->RF_IN >= 620000000 &&
3053 state->RF_IN < 760000000) {
3054 status += MXL_ControlWrite(fe, DAC_A_ENABLE, 1);
3055 status += MXL_SetGPIO(fe, 4, 0);
3056 status += MXL_SetGPIO(fe, 1, 1);
3057 status += MXL_SetGPIO(fe, 3, 1);
3058 }
3059 if (state->RF_IN >= 760000000 &&
3060 state->RF_IN <= 900000000) {
3061 status += MXL_ControlWrite(fe, DAC_A_ENABLE, 1);
3062 status += MXL_SetGPIO(fe, 4, 1);
3063 status += MXL_SetGPIO(fe, 1, 1);
3064 status += MXL_SetGPIO(fe, 3, 1);
3065 }
3066 }
3067 }
3068
3069 if (state->TF_Type == MXL_TF_E) /* Tracking Filter type E */ {
3070
3071 status += MXL_ControlWrite(fe, DAC_DIN_B, 0);
3072
3073 if (state->RF_IN >= 43000000 && state->RF_IN < 174000000) {
3074 status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0);
3075 status += MXL_SetGPIO(fe, 4, 0);
3076 status += MXL_SetGPIO(fe, 1, 1);
3077 status += MXL_SetGPIO(fe, 3, 1);
3078 }
3079 if (state->RF_IN >= 174000000 && state->RF_IN < 250000000) {
3080 status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0);
3081 status += MXL_SetGPIO(fe, 4, 0);
3082 status += MXL_SetGPIO(fe, 1, 0);
3083 status += MXL_SetGPIO(fe, 3, 1);
3084 }
3085 if (state->RF_IN >= 250000000 && state->RF_IN < 310000000) {
3086 status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0);
3087 status += MXL_SetGPIO(fe, 4, 1);
3088 status += MXL_SetGPIO(fe, 1, 0);
3089 status += MXL_SetGPIO(fe, 3, 1);
3090 }
3091 if (state->RF_IN >= 310000000 && state->RF_IN < 360000000) {
3092 status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0);
3093 status += MXL_SetGPIO(fe, 4, 1);
3094 status += MXL_SetGPIO(fe, 1, 0);
3095 status += MXL_SetGPIO(fe, 3, 0);
3096 }
3097 if (state->RF_IN >= 360000000 && state->RF_IN < 470000000) {
3098 status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0);
3099 status += MXL_SetGPIO(fe, 4, 1);
3100 status += MXL_SetGPIO(fe, 1, 1);
3101 status += MXL_SetGPIO(fe, 3, 0);
3102 }
3103 if (state->RF_IN >= 470000000 && state->RF_IN < 640000000) {
3104 status += MXL_ControlWrite(fe, DAC_B_ENABLE, 1);
3105 status += MXL_SetGPIO(fe, 4, 1);
3106 status += MXL_SetGPIO(fe, 1, 1);
3107 status += MXL_SetGPIO(fe, 3, 0);
3108 }
3109 if (state->RF_IN >= 640000000 && state->RF_IN <= 900000000) {
3110 status += MXL_ControlWrite(fe, DAC_B_ENABLE, 1);
3111 status += MXL_SetGPIO(fe, 4, 1);
3112 status += MXL_SetGPIO(fe, 1, 1);
3113 status += MXL_SetGPIO(fe, 3, 1);
3114 }
3115 }
3116
3117 if (state->TF_Type == MXL_TF_F) {
3118
3119 /* Tracking Filter type F */
3120 status += MXL_ControlWrite(fe, DAC_DIN_B, 0);
3121
3122 if (state->RF_IN >= 43000000 && state->RF_IN < 160000000) {
3123 status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0);
3124 status += MXL_SetGPIO(fe, 4, 0);
3125 status += MXL_SetGPIO(fe, 1, 1);
3126 status += MXL_SetGPIO(fe, 3, 1);
3127 }
3128 if (state->RF_IN >= 160000000 && state->RF_IN < 210000000) {
3129 status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0);
3130 status += MXL_SetGPIO(fe, 4, 0);
3131 status += MXL_SetGPIO(fe, 1, 0);
3132 status += MXL_SetGPIO(fe, 3, 1);
3133 }
3134 if (state->RF_IN >= 210000000 && state->RF_IN < 300000000) {
3135 status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0);
3136 status += MXL_SetGPIO(fe, 4, 1);
3137 status += MXL_SetGPIO(fe, 1, 0);
3138 status += MXL_SetGPIO(fe, 3, 1);
3139 }
3140 if (state->RF_IN >= 300000000 && state->RF_IN < 390000000) {
3141 status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0);
3142 status += MXL_SetGPIO(fe, 4, 1);
3143 status += MXL_SetGPIO(fe, 1, 0);
3144 status += MXL_SetGPIO(fe, 3, 0);
3145 }
3146 if (state->RF_IN >= 390000000 && state->RF_IN < 515000000) {
3147 status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0);
3148 status += MXL_SetGPIO(fe, 4, 1);
3149 status += MXL_SetGPIO(fe, 1, 1);
3150 status += MXL_SetGPIO(fe, 3, 0);
3151 }
3152 if (state->RF_IN >= 515000000 && state->RF_IN < 650000000) {
3153 status += MXL_ControlWrite(fe, DAC_B_ENABLE, 1);
3154 status += MXL_SetGPIO(fe, 4, 1);
3155 status += MXL_SetGPIO(fe, 1, 1);
3156 status += MXL_SetGPIO(fe, 3, 0);
3157 }
3158 if (state->RF_IN >= 650000000 && state->RF_IN <= 900000000) {
3159 status += MXL_ControlWrite(fe, DAC_B_ENABLE, 1);
3160 status += MXL_SetGPIO(fe, 4, 1);
3161 status += MXL_SetGPIO(fe, 1, 1);
3162 status += MXL_SetGPIO(fe, 3, 1);
3163 }
3164 }
3165
3166 if (state->TF_Type == MXL_TF_E_2) {
3167
3168 /* Tracking Filter type E_2 */
3169 status += MXL_ControlWrite(fe, DAC_DIN_B, 0);
3170
3171 if (state->RF_IN >= 43000000 && state->RF_IN < 174000000) {
3172 status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0);
3173 status += MXL_SetGPIO(fe, 4, 0);
3174 status += MXL_SetGPIO(fe, 1, 1);
3175 status += MXL_SetGPIO(fe, 3, 1);
3176 }
3177 if (state->RF_IN >= 174000000 && state->RF_IN < 250000000) {
3178 status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0);
3179 status += MXL_SetGPIO(fe, 4, 0);
3180 status += MXL_SetGPIO(fe, 1, 0);
3181 status += MXL_SetGPIO(fe, 3, 1);
3182 }
3183 if (state->RF_IN >= 250000000 && state->RF_IN < 350000000) {
3184 status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0);
3185 status += MXL_SetGPIO(fe, 4, 1);
3186 status += MXL_SetGPIO(fe, 1, 0);
3187 status += MXL_SetGPIO(fe, 3, 1);
3188 }
3189 if (state->RF_IN >= 350000000 && state->RF_IN < 400000000) {
3190 status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0);
3191 status += MXL_SetGPIO(fe, 4, 1);
3192 status += MXL_SetGPIO(fe, 1, 0);
3193 status += MXL_SetGPIO(fe, 3, 0);
3194 }
3195 if (state->RF_IN >= 400000000 && state->RF_IN < 570000000) {
3196 status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0);
3197 status += MXL_SetGPIO(fe, 4, 1);
3198 status += MXL_SetGPIO(fe, 1, 1);
3199 status += MXL_SetGPIO(fe, 3, 0);
3200 }
3201 if (state->RF_IN >= 570000000 && state->RF_IN < 770000000) {
3202 status += MXL_ControlWrite(fe, DAC_B_ENABLE, 1);
3203 status += MXL_SetGPIO(fe, 4, 1);
3204 status += MXL_SetGPIO(fe, 1, 1);
3205 status += MXL_SetGPIO(fe, 3, 0);
3206 }
3207 if (state->RF_IN >= 770000000 && state->RF_IN <= 900000000) {
3208 status += MXL_ControlWrite(fe, DAC_B_ENABLE, 1);
3209 status += MXL_SetGPIO(fe, 4, 1);
3210 status += MXL_SetGPIO(fe, 1, 1);
3211 status += MXL_SetGPIO(fe, 3, 1);
3212 }
3213 }
3214
3215 if (state->TF_Type == MXL_TF_G) {
3216
3217 /* Tracking Filter type G add for v2.6.8 */
3218 status += MXL_ControlWrite(fe, DAC_DIN_B, 0);
3219
3220 if (state->RF_IN >= 50000000 && state->RF_IN < 190000000) {
3221
3222 status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0);
3223 status += MXL_SetGPIO(fe, 4, 0);
3224 status += MXL_SetGPIO(fe, 1, 1);
3225 status += MXL_SetGPIO(fe, 3, 1);
3226 }
3227 if (state->RF_IN >= 190000000 && state->RF_IN < 280000000) {
3228 status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0);
3229 status += MXL_SetGPIO(fe, 4, 0);
3230 status += MXL_SetGPIO(fe, 1, 0);
3231 status += MXL_SetGPIO(fe, 3, 1);
3232 }
3233 if (state->RF_IN >= 280000000 && state->RF_IN < 350000000) {
3234 status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0);
3235 status += MXL_SetGPIO(fe, 4, 1);
3236 status += MXL_SetGPIO(fe, 1, 0);
3237 status += MXL_SetGPIO(fe, 3, 1);
3238 }
3239 if (state->RF_IN >= 350000000 && state->RF_IN < 400000000) {
3240 status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0);
3241 status += MXL_SetGPIO(fe, 4, 1);
3242 status += MXL_SetGPIO(fe, 1, 0);
3243 status += MXL_SetGPIO(fe, 3, 0);
3244 }
3245 if (state->RF_IN >= 400000000 && state->RF_IN < 470000000) {
3246 status += MXL_ControlWrite(fe, DAC_B_ENABLE, 1);
3247 status += MXL_SetGPIO(fe, 4, 1);
3248 status += MXL_SetGPIO(fe, 1, 0);
3249 status += MXL_SetGPIO(fe, 3, 1);
3250 }
3251 if (state->RF_IN >= 470000000 && state->RF_IN < 640000000) {
3252 status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0);
3253 status += MXL_SetGPIO(fe, 4, 1);
3254 status += MXL_SetGPIO(fe, 1, 1);
3255 status += MXL_SetGPIO(fe, 3, 0);
3256 }
3257 if (state->RF_IN >= 640000000 && state->RF_IN < 820000000) {
3258 status += MXL_ControlWrite(fe, DAC_B_ENABLE, 1);
3259 status += MXL_SetGPIO(fe, 4, 1);
3260 status += MXL_SetGPIO(fe, 1, 1);
3261 status += MXL_SetGPIO(fe, 3, 0);
3262 }
3263 if (state->RF_IN >= 820000000 && state->RF_IN <= 900000000) {
3264 status += MXL_ControlWrite(fe, DAC_B_ENABLE, 1);
3265 status += MXL_SetGPIO(fe, 4, 1);
3266 status += MXL_SetGPIO(fe, 1, 1);
3267 status += MXL_SetGPIO(fe, 3, 1);
3268 }
3269 }
3270
3271 if (state->TF_Type == MXL_TF_E_NA) {
3272
3273 /* Tracking Filter type E-NA for Empia ONLY change for 2.6.8 */
3274 status += MXL_ControlWrite(fe, DAC_DIN_B, 0);
3275
3276 /* if UHF and terrestrial=> Turn off Tracking Filter */
3277 if (state->RF_IN >= 471000000 &&
3278 (state->RF_IN - 471000000)%6000000 != 0) {
3279
3280 /* Turn off all the banks */
3281 status += MXL_SetGPIO(fe, 3, 1);
3282 status += MXL_SetGPIO(fe, 1, 1);
3283 status += MXL_SetGPIO(fe, 4, 1);
3284 status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0);
3285
3286 /* 2.6.12 Turn on RSSI */
3287 status += MXL_ControlWrite(fe, SEQ_EXTSYNTHCALIF, 1);
3288 status += MXL_ControlWrite(fe, SEQ_EXTDCCAL, 1);
3289 status += MXL_ControlWrite(fe, AGC_EN_RSSI, 1);
3290 status += MXL_ControlWrite(fe, RFA_ENCLKRFAGC, 1);
3291
3292 /* RSSI reference point */
3293 status += MXL_ControlWrite(fe, RFA_RSSI_REFH, 5);
3294 status += MXL_ControlWrite(fe, RFA_RSSI_REF, 3);
3295 status += MXL_ControlWrite(fe, RFA_RSSI_REFL, 2);
3296
3297 /* following parameter is from analog OTA mode,
3298 * can be change to seek better performance */
3299 status += MXL_ControlWrite(fe, RFSYN_CHP_GAIN, 3);
3300 } else {
3301 /* if VHF or Cable => Turn on Tracking Filter */
3302
3303 /* 2.6.12 Turn off RSSI */
3304 status += MXL_ControlWrite(fe, AGC_EN_RSSI, 0);
3305
3306 /* change back from above condition */
3307 status += MXL_ControlWrite(fe, RFSYN_CHP_GAIN, 5);
3308
3309
3310 if (state->RF_IN >= 43000000 && state->RF_IN < 174000000) {
3311
3312 status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0);
3313 status += MXL_SetGPIO(fe, 4, 0);
3314 status += MXL_SetGPIO(fe, 1, 1);
3315 status += MXL_SetGPIO(fe, 3, 1);
3316 }
3317 if (state->RF_IN >= 174000000 && state->RF_IN < 250000000) {
3318 status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0);
3319 status += MXL_SetGPIO(fe, 4, 0);
3320 status += MXL_SetGPIO(fe, 1, 0);
3321 status += MXL_SetGPIO(fe, 3, 1);
3322 }
3323 if (state->RF_IN >= 250000000 && state->RF_IN < 350000000) {
3324 status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0);
3325 status += MXL_SetGPIO(fe, 4, 1);
3326 status += MXL_SetGPIO(fe, 1, 0);
3327 status += MXL_SetGPIO(fe, 3, 1);
3328 }
3329 if (state->RF_IN >= 350000000 && state->RF_IN < 400000000) {
3330 status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0);
3331 status += MXL_SetGPIO(fe, 4, 1);
3332 status += MXL_SetGPIO(fe, 1, 0);
3333 status += MXL_SetGPIO(fe, 3, 0);
3334 }
3335 if (state->RF_IN >= 400000000 && state->RF_IN < 570000000) {
3336 status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0);
3337 status += MXL_SetGPIO(fe, 4, 1);
3338 status += MXL_SetGPIO(fe, 1, 1);
3339 status += MXL_SetGPIO(fe, 3, 0);
3340 }
3341 if (state->RF_IN >= 570000000 && state->RF_IN < 770000000) {
3342 status += MXL_ControlWrite(fe, DAC_B_ENABLE, 1);
3343 status += MXL_SetGPIO(fe, 4, 1);
3344 status += MXL_SetGPIO(fe, 1, 1);
3345 status += MXL_SetGPIO(fe, 3, 0);
3346 }
3347 if (state->RF_IN >= 770000000 && state->RF_IN <= 900000000) {
3348 status += MXL_ControlWrite(fe, DAC_B_ENABLE, 1);
3349 status += MXL_SetGPIO(fe, 4, 1);
3350 status += MXL_SetGPIO(fe, 1, 1);
3351 status += MXL_SetGPIO(fe, 3, 1);
3352 }
3353 }
3354 }
3355 return status ;
3356}
3357
3358static u16 MXL_SetGPIO(struct dvb_frontend *fe, u8 GPIO_Num, u8 GPIO_Val)
3359{
3360 u16 status = 0;
3361
3362 if (GPIO_Num == 1)
3363 status += MXL_ControlWrite(fe, GPIO_1B, GPIO_Val ? 0 : 1);
3364
3365 /* GPIO2 is not available */
3366
3367 if (GPIO_Num == 3) {
3368 if (GPIO_Val == 1) {
3369 status += MXL_ControlWrite(fe, GPIO_3, 0);
3370 status += MXL_ControlWrite(fe, GPIO_3B, 0);
3371 }
3372 if (GPIO_Val == 0) {
3373 status += MXL_ControlWrite(fe, GPIO_3, 1);
3374 status += MXL_ControlWrite(fe, GPIO_3B, 1);
3375 }
3376 if (GPIO_Val == 3) { /* tri-state */
3377 status += MXL_ControlWrite(fe, GPIO_3, 0);
3378 status += MXL_ControlWrite(fe, GPIO_3B, 1);
3379 }
3380 }
3381 if (GPIO_Num == 4) {
3382 if (GPIO_Val == 1) {
3383 status += MXL_ControlWrite(fe, GPIO_4, 0);
3384 status += MXL_ControlWrite(fe, GPIO_4B, 0);
3385 }
3386 if (GPIO_Val == 0) {
3387 status += MXL_ControlWrite(fe, GPIO_4, 1);
3388 status += MXL_ControlWrite(fe, GPIO_4B, 1);
3389 }
3390 if (GPIO_Val == 3) { /* tri-state */
3391 status += MXL_ControlWrite(fe, GPIO_4, 0);
3392 status += MXL_ControlWrite(fe, GPIO_4B, 1);
3393 }
3394 }
3395
3396 return status;
3397}
3398
3399static u16 MXL_ControlWrite(struct dvb_frontend *fe, u16 ControlNum, u32 value)
3400{
3401 u16 status = 0;
3402
3403 /* Will write ALL Matching Control Name */
3404 /* Write Matching INIT Control */
3405 status += MXL_ControlWrite_Group(fe, ControlNum, value, 1);
3406 /* Write Matching CH Control */
3407 status += MXL_ControlWrite_Group(fe, ControlNum, value, 2);
3408#ifdef _MXL_INTERNAL
3409 /* Write Matching MXL Control */
3410 status += MXL_ControlWrite_Group(fe, ControlNum, value, 3);
3411#endif
3412 return status;
3413}
3414
3415static u16 MXL_ControlWrite_Group(struct dvb_frontend *fe, u16 controlNum,
3416 u32 value, u16 controlGroup)
3417{
3418 struct mxl5005s_state *state = fe->tuner_priv;
3419 u16 i, j, k;
3420 u32 highLimit;
3421 u32 ctrlVal;
3422
3423 if (controlGroup == 1) /* Initial Control */ {
3424
3425 for (i = 0; i < state->Init_Ctrl_Num; i++) {
3426
3427 if (controlNum == state->Init_Ctrl[i].Ctrl_Num) {
3428
3429 highLimit = 1 << state->Init_Ctrl[i].size;
3430 if (value < highLimit) {
3431 for (j = 0; j < state->Init_Ctrl[i].size; j++) {
3432 state->Init_Ctrl[i].val[j] = (u8)((value >> j) & 0x01);
3433 MXL_RegWriteBit(fe, (u8)(state->Init_Ctrl[i].addr[j]),
3434 (u8)(state->Init_Ctrl[i].bit[j]),
3435 (u8)((value>>j) & 0x01));
3436 }
3437 ctrlVal = 0;
3438 for (k = 0; k < state->Init_Ctrl[i].size; k++)
3439 ctrlVal += state->Init_Ctrl[i].val[k] * (1 << k);
3440 } else
3441 return -1;
3442 }
3443 }
3444 }
3445 if (controlGroup == 2) /* Chan change Control */ {
3446
3447 for (i = 0; i < state->CH_Ctrl_Num; i++) {
3448
3449 if (controlNum == state->CH_Ctrl[i].Ctrl_Num) {
3450
3451 highLimit = 1 << state->CH_Ctrl[i].size;
3452 if (value < highLimit) {
3453 for (j = 0; j < state->CH_Ctrl[i].size; j++) {
3454 state->CH_Ctrl[i].val[j] = (u8)((value >> j) & 0x01);
3455 MXL_RegWriteBit(fe, (u8)(state->CH_Ctrl[i].addr[j]),
3456 (u8)(state->CH_Ctrl[i].bit[j]),
3457 (u8)((value>>j) & 0x01));
3458 }
3459 ctrlVal = 0;
3460 for (k = 0; k < state->CH_Ctrl[i].size; k++)
3461 ctrlVal += state->CH_Ctrl[i].val[k] * (1 << k);
3462 } else
3463 return -1;
3464 }
3465 }
3466 }
3467#ifdef _MXL_INTERNAL
3468 if (controlGroup == 3) /* Maxlinear Control */ {
3469
3470 for (i = 0; i < state->MXL_Ctrl_Num; i++) {
3471
3472 if (controlNum == state->MXL_Ctrl[i].Ctrl_Num) {
3473
3474 highLimit = (1 << state->MXL_Ctrl[i].size);
3475 if (value < highLimit) {
3476 for (j = 0; j < state->MXL_Ctrl[i].size; j++) {
3477 state->MXL_Ctrl[i].val[j] = (u8)((value >> j) & 0x01);
3478 MXL_RegWriteBit(fe, (u8)(state->MXL_Ctrl[i].addr[j]),
3479 (u8)(state->MXL_Ctrl[i].bit[j]),
3480 (u8)((value>>j) & 0x01));
3481 }
3482 ctrlVal = 0;
3483 for (k = 0; k < state->MXL_Ctrl[i].size; k++)
3484 ctrlVal += state->MXL_Ctrl[i].val[k] * (1 << k);
3485 } else
3486 return -1;
3487 }
3488 }
3489 }
3490#endif
3491 return 0 ; /* successful return */
3492}
3493
3494static u16 MXL_RegRead(struct dvb_frontend *fe, u8 RegNum, u8 *RegVal)
3495{
3496 struct mxl5005s_state *state = fe->tuner_priv;
3497 int i ;
3498
3499 for (i = 0; i < 104; i++) {
3500 if (RegNum == state->TunerRegs[i].Reg_Num) {
3501 *RegVal = (u8)(state->TunerRegs[i].Reg_Val);
3502 return 0;
3503 }
3504 }
3505
3506 return 1;
3507}
3508
3509static u16 MXL_ControlRead(struct dvb_frontend *fe, u16 controlNum, u32 *value)
3510{
3511 struct mxl5005s_state *state = fe->tuner_priv;
3512 u32 ctrlVal ;
3513 u16 i, k ;
3514
3515 for (i = 0; i < state->Init_Ctrl_Num ; i++) {
3516
3517 if (controlNum == state->Init_Ctrl[i].Ctrl_Num) {
3518
3519 ctrlVal = 0;
3520 for (k = 0; k < state->Init_Ctrl[i].size; k++)
3521 ctrlVal += state->Init_Ctrl[i].val[k] * (1<<k);
3522 *value = ctrlVal;
3523 return 0;
3524 }
3525 }
3526
3527 for (i = 0; i < state->CH_Ctrl_Num ; i++) {
3528
3529 if (controlNum == state->CH_Ctrl[i].Ctrl_Num) {
3530
3531 ctrlVal = 0;
3532 for (k = 0; k < state->CH_Ctrl[i].size; k++)
3533 ctrlVal += state->CH_Ctrl[i].val[k] * (1 << k);
3534 *value = ctrlVal;
3535 return 0;
3536
3537 }
3538 }
3539
3540#ifdef _MXL_INTERNAL
3541 for (i = 0; i < state->MXL_Ctrl_Num ; i++) {
3542
3543 if (controlNum == state->MXL_Ctrl[i].Ctrl_Num) {
3544
3545 ctrlVal = 0;
3546 for (k = 0; k < state->MXL_Ctrl[i].size; k++)
3547 ctrlVal += state->MXL_Ctrl[i].val[k] * (1<<k);
3548 *value = ctrlVal;
3549 return 0;
3550
3551 }
3552 }
3553#endif
3554 return 1;
3555}
3556
3557static void MXL_RegWriteBit(struct dvb_frontend *fe, u8 address, u8 bit,
3558 u8 bitVal)
3559{
3560 struct mxl5005s_state *state = fe->tuner_priv;
3561 int i ;
3562
3563 const u8 AND_MAP[8] = {
3564 0xFE, 0xFD, 0xFB, 0xF7,
3565 0xEF, 0xDF, 0xBF, 0x7F } ;
3566
3567 const u8 OR_MAP[8] = {
3568 0x01, 0x02, 0x04, 0x08,
3569 0x10, 0x20, 0x40, 0x80 } ;
3570
3571 for (i = 0; i < state->TunerRegs_Num; i++) {
3572 if (state->TunerRegs[i].Reg_Num == address) {
3573 if (bitVal)
3574 state->TunerRegs[i].Reg_Val |= OR_MAP[bit];
3575 else
3576 state->TunerRegs[i].Reg_Val &= AND_MAP[bit];
3577 break ;
3578 }
3579 }
3580}
3581
3582static u32 MXL_Ceiling(u32 value, u32 resolution)
3583{
3584 return (value/resolution + (value % resolution > 0 ? 1 : 0));
3585}
3586
3587/* Retrieve the Initialzation Registers */
3588static u16 MXL_GetInitRegister(struct dvb_frontend *fe, u8 *RegNum,
3589 u8 *RegVal, int *count)
3590{
3591 u16 status = 0;
3592 int i ;
3593
3594 u8 RegAddr[] = {
3595 11, 12, 13, 22, 32, 43, 44, 53, 56, 59, 73,
3596 76, 77, 91, 134, 135, 137, 147,
3597 156, 166, 167, 168, 25 };
3598
3599 *count = sizeof(RegAddr) / sizeof(u8);
3600
3601 status += MXL_BlockInit(fe);
3602
3603 for (i = 0 ; i < *count; i++) {
3604 RegNum[i] = RegAddr[i];
3605 status += MXL_RegRead(fe, RegNum[i], &RegVal[i]);
3606 }
3607
3608 return status;
3609}
3610
3611static u16 MXL_GetCHRegister(struct dvb_frontend *fe, u8 *RegNum, u8 *RegVal,
3612 int *count)
3613{
3614 u16 status = 0;
3615 int i ;
3616
3617/* add 77, 166, 167, 168 register for 2.6.12 */
3618#ifdef _MXL_PRODUCTION
3619 u8 RegAddr[] = {14, 15, 16, 17, 22, 43, 65, 68, 69, 70, 73, 92, 93, 106,
3620 107, 108, 109, 110, 111, 112, 136, 138, 149, 77, 166, 167, 168 } ;
3621#else
3622 u8 RegAddr[] = {14, 15, 16, 17, 22, 43, 68, 69, 70, 73, 92, 93, 106,
3623 107, 108, 109, 110, 111, 112, 136, 138, 149, 77, 166, 167, 168 } ;
3624 /*
3625 u8 RegAddr[171];
3626 for (i = 0; i <= 170; i++)
3627 RegAddr[i] = i;
3628 */
3629#endif
3630
3631 *count = sizeof(RegAddr) / sizeof(u8);
3632
3633 for (i = 0 ; i < *count; i++) {
3634 RegNum[i] = RegAddr[i];
3635 status += MXL_RegRead(fe, RegNum[i], &RegVal[i]);
3636 }
3637
3638 return status;
3639}
3640
3641static u16 MXL_GetCHRegister_ZeroIF(struct dvb_frontend *fe, u8 *RegNum,
3642 u8 *RegVal, int *count)
3643{
3644 u16 status = 0;
3645 int i;
3646
3647 u8 RegAddr[] = {43, 136};
3648
3649 *count = sizeof(RegAddr) / sizeof(u8);
3650
3651 for (i = 0; i < *count; i++) {
3652 RegNum[i] = RegAddr[i];
3653 status += MXL_RegRead(fe, RegNum[i], &RegVal[i]);
3654 }
3655
3656 return status;
3657}
3658
3659static u16 MXL_GetMasterControl(u8 *MasterReg, int state)
3660{
3661 if (state == 1) /* Load_Start */
3662 *MasterReg = 0xF3;
3663 if (state == 2) /* Power_Down */
3664 *MasterReg = 0x41;
3665 if (state == 3) /* Synth_Reset */
3666 *MasterReg = 0xB1;
3667 if (state == 4) /* Seq_Off */
3668 *MasterReg = 0xF1;
3669
3670 return 0;
3671}
3672
3673#ifdef _MXL_PRODUCTION
3674static u16 MXL_VCORange_Test(struct dvb_frontend *fe, int VCO_Range)
3675{
3676 struct mxl5005s_state *state = fe->tuner_priv;
3677 u16 status = 0 ;
3678
3679 if (VCO_Range == 1) {
3680 status += MXL_ControlWrite(fe, RFSYN_EN_DIV, 1);
3681 status += MXL_ControlWrite(fe, RFSYN_EN_OUTMUX, 0);
3682 status += MXL_ControlWrite(fe, RFSYN_SEL_DIVM, 0);
3683 status += MXL_ControlWrite(fe, RFSYN_DIVM, 1);
3684 status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_OUT, 1);
3685 status += MXL_ControlWrite(fe, RFSYN_RF_DIV_BIAS, 1);
3686 status += MXL_ControlWrite(fe, DN_SEL_FREQ, 0);
3687 if (state->Mode == 0 && state->IF_Mode == 1) {
3688 /* Analog Low IF Mode */
3689 status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_HI, 1);
3690 status += MXL_ControlWrite(fe, RFSYN_VCO_BIAS, 8);
3691 status += MXL_ControlWrite(fe, CHCAL_INT_MOD_RF, 56);
3692 status += MXL_ControlWrite(fe,
3693 CHCAL_FRAC_MOD_RF, 180224);
3694 }
3695 if (state->Mode == 0 && state->IF_Mode == 0) {
3696 /* Analog Zero IF Mode */
3697 status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_HI, 1);
3698 status += MXL_ControlWrite(fe, RFSYN_VCO_BIAS, 8);
3699 status += MXL_ControlWrite(fe, CHCAL_INT_MOD_RF, 56);
3700 status += MXL_ControlWrite(fe,
3701 CHCAL_FRAC_MOD_RF, 222822);
3702 }
3703 if (state->Mode == 1) /* Digital Mode */ {
3704 status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_HI, 1);
3705 status += MXL_ControlWrite(fe, RFSYN_VCO_BIAS, 8);
3706 status += MXL_ControlWrite(fe, CHCAL_INT_MOD_RF, 56);
3707 status += MXL_ControlWrite(fe,
3708 CHCAL_FRAC_MOD_RF, 229376);
3709 }
3710 }
3711
3712 if (VCO_Range == 2) {
3713 status += MXL_ControlWrite(fe, RFSYN_EN_DIV, 1);
3714 status += MXL_ControlWrite(fe, RFSYN_EN_OUTMUX, 0);
3715 status += MXL_ControlWrite(fe, RFSYN_SEL_DIVM, 0);
3716 status += MXL_ControlWrite(fe, RFSYN_DIVM, 1);
3717 status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_OUT, 1);
3718 status += MXL_ControlWrite(fe, RFSYN_RF_DIV_BIAS, 1);
3719 status += MXL_ControlWrite(fe, DN_SEL_FREQ, 0);
3720 status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_HI, 1);
3721 status += MXL_ControlWrite(fe, RFSYN_VCO_BIAS, 40);
3722 status += MXL_ControlWrite(fe, CHCAL_INT_MOD_RF, 41);
3723 if (state->Mode == 0 && state->IF_Mode == 1) {
3724 /* Analog Low IF Mode */
3725 status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_HI, 1);
3726 status += MXL_ControlWrite(fe, RFSYN_VCO_BIAS, 40);
3727 status += MXL_ControlWrite(fe, CHCAL_INT_MOD_RF, 42);
3728 status += MXL_ControlWrite(fe,
3729 CHCAL_FRAC_MOD_RF, 206438);
3730 }
3731 if (state->Mode == 0 && state->IF_Mode == 0) {
3732 /* Analog Zero IF Mode */
3733 status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_HI, 1);
3734 status += MXL_ControlWrite(fe, RFSYN_VCO_BIAS, 40);
3735 status += MXL_ControlWrite(fe, CHCAL_INT_MOD_RF, 42);
3736 status += MXL_ControlWrite(fe,
3737 CHCAL_FRAC_MOD_RF, 206438);
3738 }
3739 if (state->Mode == 1) /* Digital Mode */ {
3740 status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_HI, 1);
3741 status += MXL_ControlWrite(fe, RFSYN_VCO_BIAS, 40);
3742 status += MXL_ControlWrite(fe, CHCAL_INT_MOD_RF, 41);
3743 status += MXL_ControlWrite(fe,
3744 CHCAL_FRAC_MOD_RF, 16384);
3745 }
3746 }
3747
3748 if (VCO_Range == 3) {
3749 status += MXL_ControlWrite(fe, RFSYN_EN_DIV, 1);
3750 status += MXL_ControlWrite(fe, RFSYN_EN_OUTMUX, 0);
3751 status += MXL_ControlWrite(fe, RFSYN_SEL_DIVM, 0);
3752 status += MXL_ControlWrite(fe, RFSYN_DIVM, 1);
3753 status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_OUT, 1);
3754 status += MXL_ControlWrite(fe, RFSYN_RF_DIV_BIAS, 1);
3755 status += MXL_ControlWrite(fe, DN_SEL_FREQ, 0);
3756 status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_HI, 0);
3757 status += MXL_ControlWrite(fe, RFSYN_VCO_BIAS, 8);
3758 status += MXL_ControlWrite(fe, CHCAL_INT_MOD_RF, 42);
3759 if (state->Mode == 0 && state->IF_Mode == 1) {
3760 /* Analog Low IF Mode */
3761 status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_HI, 0);
3762 status += MXL_ControlWrite(fe, RFSYN_VCO_BIAS, 8);
3763 status += MXL_ControlWrite(fe, CHCAL_INT_MOD_RF, 44);
3764 status += MXL_ControlWrite(fe,
3765 CHCAL_FRAC_MOD_RF, 173670);
3766 }
3767 if (state->Mode == 0 && state->IF_Mode == 0) {
3768 /* Analog Zero IF Mode */
3769 status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_HI, 0);
3770 status += MXL_ControlWrite(fe, RFSYN_VCO_BIAS, 8);
3771 status += MXL_ControlWrite(fe, CHCAL_INT_MOD_RF, 44);
3772 status += MXL_ControlWrite(fe,
3773 CHCAL_FRAC_MOD_RF, 173670);
3774 }
3775 if (state->Mode == 1) /* Digital Mode */ {
3776 status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_HI, 0);
3777 status += MXL_ControlWrite(fe, RFSYN_VCO_BIAS, 8);
3778 status += MXL_ControlWrite(fe, CHCAL_INT_MOD_RF, 42);
3779 status += MXL_ControlWrite(fe,
3780 CHCAL_FRAC_MOD_RF, 245760);
3781 }
3782 }
3783
3784 if (VCO_Range == 4) {
3785 status += MXL_ControlWrite(fe, RFSYN_EN_DIV, 1);
3786 status += MXL_ControlWrite(fe, RFSYN_EN_OUTMUX, 0);
3787 status += MXL_ControlWrite(fe, RFSYN_SEL_DIVM, 0);
3788 status += MXL_ControlWrite(fe, RFSYN_DIVM, 1);
3789 status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_OUT, 1);
3790 status += MXL_ControlWrite(fe, RFSYN_RF_DIV_BIAS, 1);
3791 status += MXL_ControlWrite(fe, DN_SEL_FREQ, 0);
3792 status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_HI, 0);
3793 status += MXL_ControlWrite(fe, RFSYN_VCO_BIAS, 40);
3794 status += MXL_ControlWrite(fe, CHCAL_INT_MOD_RF, 27);
3795 if (state->Mode == 0 && state->IF_Mode == 1) {
3796 /* Analog Low IF Mode */
3797 status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_HI, 0);
3798 status += MXL_ControlWrite(fe, RFSYN_VCO_BIAS, 40);
3799 status += MXL_ControlWrite(fe, CHCAL_INT_MOD_RF, 27);
3800 status += MXL_ControlWrite(fe,
3801 CHCAL_FRAC_MOD_RF, 206438);
3802 }
3803 if (state->Mode == 0 && state->IF_Mode == 0) {
3804 /* Analog Zero IF Mode */
3805 status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_HI, 0);
3806 status += MXL_ControlWrite(fe, RFSYN_VCO_BIAS, 40);
3807 status += MXL_ControlWrite(fe, CHCAL_INT_MOD_RF, 27);
3808 status += MXL_ControlWrite(fe,
3809 CHCAL_FRAC_MOD_RF, 206438);
3810 }
3811 if (state->Mode == 1) /* Digital Mode */ {
3812 status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_HI, 0);
3813 status += MXL_ControlWrite(fe, RFSYN_VCO_BIAS, 40);
3814 status += MXL_ControlWrite(fe, CHCAL_INT_MOD_RF, 27);
3815 status += MXL_ControlWrite(fe,
3816 CHCAL_FRAC_MOD_RF, 212992);
3817 }
3818 }
3819
3820 return status;
3821}
3822
3823static u16 MXL_Hystersis_Test(struct dvb_frontend *fe, int Hystersis)
3824{
3825 struct mxl5005s_state *state = fe->tuner_priv;
3826 u16 status = 0;
3827
3828 if (Hystersis == 1)
3829 status += MXL_ControlWrite(fe, DN_BYPASS_AGC_I2C, 1);
3830
3831 return status;
3832}
3833#endif
3834/* End: Reference driver code found in the Realtek driver that
3835 * is copyright MaxLinear */
3836
3837/* ----------------------------------------------------------------
3838 * Begin: Everything after here is new code to adapt the
3839 * proprietary Realtek driver into a Linux API tuner.
3840 * Copyright (C) 2008 Steven Toth <stoth@hauppauge.com>
3841 */
3842static int mxl5005s_reset(struct dvb_frontend *fe)
3843{
3844 struct mxl5005s_state *state = fe->tuner_priv;
3845 int ret = 0;
3846
3847 u8 buf[2] = { 0xff, 0x00 };
3848 struct i2c_msg msg = { .addr = state->config->i2c_address, .flags = 0,
3849 .buf = buf, .len = 2 };
3850
3851 dprintk(2, "%s()\n", __func__);
3852
3853 if (fe->ops.i2c_gate_ctrl)
3854 fe->ops.i2c_gate_ctrl(fe, 1);
3855
3856 if (i2c_transfer(state->i2c, &msg, 1) != 1) {
3857 printk(KERN_WARNING "mxl5005s I2C reset failed\n");
3858 ret = -EREMOTEIO;
3859 }
3860
3861 if (fe->ops.i2c_gate_ctrl)
3862 fe->ops.i2c_gate_ctrl(fe, 0);
3863
3864 return ret;
3865}
3866
3867/* Write a single byte to a single reg, latch the value if required by
3868 * following the transaction with the latch byte.
3869 */
3870static int mxl5005s_writereg(struct dvb_frontend *fe, u8 reg, u8 val, int latch)
3871{
3872 struct mxl5005s_state *state = fe->tuner_priv;
3873 u8 buf[3] = { reg, val, MXL5005S_LATCH_BYTE };
3874 struct i2c_msg msg = { .addr = state->config->i2c_address, .flags = 0,
3875 .buf = buf, .len = 3 };
3876
3877 if (latch == 0)
3878 msg.len = 2;
3879
3880 dprintk(2, "%s(0x%x, 0x%x, 0x%x)\n", __func__, reg, val, msg.addr);
3881
3882 if (i2c_transfer(state->i2c, &msg, 1) != 1) {
3883 printk(KERN_WARNING "mxl5005s I2C write failed\n");
3884 return -EREMOTEIO;
3885 }
3886 return 0;
3887}
3888
3889static int mxl5005s_writeregs(struct dvb_frontend *fe, u8 *addrtable,
3890 u8 *datatable, u8 len)
3891{
3892 int ret = 0, i;
3893
3894 if (fe->ops.i2c_gate_ctrl)
3895 fe->ops.i2c_gate_ctrl(fe, 1);
3896
3897 for (i = 0 ; i < len-1; i++) {
3898 ret = mxl5005s_writereg(fe, addrtable[i], datatable[i], 0);
3899 if (ret < 0)
3900 break;
3901 }
3902
3903 ret = mxl5005s_writereg(fe, addrtable[i], datatable[i], 1);
3904
3905 if (fe->ops.i2c_gate_ctrl)
3906 fe->ops.i2c_gate_ctrl(fe, 0);
3907
3908 return ret;
3909}
3910
3911static int mxl5005s_init(struct dvb_frontend *fe)
3912{
3913 dprintk(1, "%s()\n", __func__);
3914 return mxl5005s_reconfigure(fe, MXL_QAM, MXL5005S_BANDWIDTH_6MHZ);
3915}
3916
3917static int mxl5005s_reconfigure(struct dvb_frontend *fe, u32 mod_type,
3918 u32 bandwidth)
3919{
3920 struct mxl5005s_state *state = fe->tuner_priv;
3921
3922 u8 AddrTable[MXL5005S_REG_WRITING_TABLE_LEN_MAX];
3923 u8 ByteTable[MXL5005S_REG_WRITING_TABLE_LEN_MAX];
3924 int TableLen;
3925
3926 dprintk(1, "%s(type=%d, bw=%d)\n", __func__, mod_type, bandwidth);
3927
3928 mxl5005s_reset(fe);
3929
3930 /* Tuner initialization stage 0 */
3931 MXL_GetMasterControl(ByteTable, MC_SYNTH_RESET);
3932 AddrTable[0] = MASTER_CONTROL_ADDR;
3933 ByteTable[0] |= state->config->AgcMasterByte;
3934
3935 mxl5005s_writeregs(fe, AddrTable, ByteTable, 1);
3936
3937 mxl5005s_AssignTunerMode(fe, mod_type, bandwidth);
3938
3939 /* Tuner initialization stage 1 */
3940 MXL_GetInitRegister(fe, AddrTable, ByteTable, &TableLen);
3941
3942 mxl5005s_writeregs(fe, AddrTable, ByteTable, TableLen);
3943
3944 return 0;
3945}
3946
3947static int mxl5005s_AssignTunerMode(struct dvb_frontend *fe, u32 mod_type,
3948 u32 bandwidth)
3949{
3950 struct mxl5005s_state *state = fe->tuner_priv;
3951 struct mxl5005s_config *c = state->config;
3952
3953 InitTunerControls(fe);
3954
3955 /* Set MxL5005S parameters. */
3956 MXL5005_TunerConfig(
3957 fe,
3958 c->mod_mode,
3959 c->if_mode,
3960 bandwidth,
3961 c->if_freq,
3962 c->xtal_freq,
3963 c->agc_mode,
3964 c->top,
3965 c->output_load,
3966 c->clock_out,
3967 c->div_out,
3968 c->cap_select,
3969 c->rssi_enable,
3970 mod_type,
3971 c->tracking_filter);
3972
3973 return 0;
3974}
3975
3976static int mxl5005s_set_params(struct dvb_frontend *fe,
3977 struct dvb_frontend_parameters *params)
3978{
3979 struct mxl5005s_state *state = fe->tuner_priv;
3980 u32 req_mode, req_bw = 0;
3981 int ret;
3982
3983 dprintk(1, "%s()\n", __func__);
3984
3985 if (fe->ops.info.type == FE_ATSC) {
3986 switch (params->u.vsb.modulation) {
3987 case VSB_8:
3988 req_mode = MXL_ATSC; break;
3989 default:
3990 case QAM_64:
3991 case QAM_256:
3992 case QAM_AUTO:
3993 req_mode = MXL_QAM; break;
3994 }
3995 } else
3996 req_mode = MXL_DVBT;
3997
3998 /* Change tuner for new modulation type if reqd */
3999 if (req_mode != state->current_mode) {
4000 switch (req_mode) {
4001 case VSB_8:
4002 case QAM_64:
4003 case QAM_256:
4004 case QAM_AUTO:
4005 req_bw = MXL5005S_BANDWIDTH_6MHZ;
4006 break;
4007 default:
4008 /* Assume DVB-T */
4009 switch (params->u.ofdm.bandwidth) {
4010 case BANDWIDTH_6_MHZ:
4011 req_bw = MXL5005S_BANDWIDTH_6MHZ;
4012 break;
4013 case BANDWIDTH_7_MHZ:
4014 req_bw = MXL5005S_BANDWIDTH_7MHZ;
4015 break;
4016 case BANDWIDTH_AUTO:
4017 case BANDWIDTH_8_MHZ:
4018 req_bw = MXL5005S_BANDWIDTH_8MHZ;
4019 break;
4020 }
4021 }
4022
4023 state->current_mode = req_mode;
4024 ret = mxl5005s_reconfigure(fe, req_mode, req_bw);
4025
4026 } else
4027 ret = 0;
4028
4029 if (ret == 0) {
4030 dprintk(1, "%s() freq=%d\n", __func__, params->frequency);
4031 ret = mxl5005s_SetRfFreqHz(fe, params->frequency);
4032 }
4033
4034 return ret;
4035}
4036
4037static int mxl5005s_get_frequency(struct dvb_frontend *fe, u32 *frequency)
4038{
4039 struct mxl5005s_state *state = fe->tuner_priv;
4040 dprintk(1, "%s()\n", __func__);
4041
4042 *frequency = state->RF_IN;
4043
4044 return 0;
4045}
4046
4047static int mxl5005s_get_bandwidth(struct dvb_frontend *fe, u32 *bandwidth)
4048{
4049 struct mxl5005s_state *state = fe->tuner_priv;
4050 dprintk(1, "%s()\n", __func__);
4051
4052 *bandwidth = state->Chan_Bandwidth;
4053
4054 return 0;
4055}
4056
4057static int mxl5005s_release(struct dvb_frontend *fe)
4058{
4059 dprintk(1, "%s()\n", __func__);
4060 kfree(fe->tuner_priv);
4061 fe->tuner_priv = NULL;
4062 return 0;
4063}
4064
4065static const struct dvb_tuner_ops mxl5005s_tuner_ops = {
4066 .info = {
4067 .name = "MaxLinear MXL5005S",
4068 .frequency_min = 48000000,
4069 .frequency_max = 860000000,
4070 .frequency_step = 50000,
4071 },
4072
4073 .release = mxl5005s_release,
4074 .init = mxl5005s_init,
4075
4076 .set_params = mxl5005s_set_params,
4077 .get_frequency = mxl5005s_get_frequency,
4078 .get_bandwidth = mxl5005s_get_bandwidth,
4079};
4080
4081struct dvb_frontend *mxl5005s_attach(struct dvb_frontend *fe,
4082 struct i2c_adapter *i2c,
4083 struct mxl5005s_config *config)
4084{
4085 struct mxl5005s_state *state = NULL;
4086 dprintk(1, "%s()\n", __func__);
4087
4088 state = kzalloc(sizeof(struct mxl5005s_state), GFP_KERNEL);
4089 if (state == NULL)
4090 return NULL;
4091
4092 state->frontend = fe;
4093 state->config = config;
4094 state->i2c = i2c;
4095 state->current_mode = MXL_QAM;
4096
4097 printk(KERN_INFO "MXL5005S: Attached at address 0x%02x\n",
4098 config->i2c_address);
4099
4100 memcpy(&fe->ops.tuner_ops, &mxl5005s_tuner_ops,
4101 sizeof(struct dvb_tuner_ops));
4102
4103 fe->tuner_priv = state;
4104 return fe;
4105}
4106EXPORT_SYMBOL(mxl5005s_attach);
4107
4108MODULE_DESCRIPTION("MaxLinear MXL5005S silicon tuner driver");
4109MODULE_AUTHOR("Steven Toth");
4110MODULE_LICENSE("GPL");
diff --git a/drivers/media/common/tuners/mxl5005s.h b/drivers/media/common/tuners/mxl5005s.h
new file mode 100644
index 000000000000..396db150bf0c
--- /dev/null
+++ b/drivers/media/common/tuners/mxl5005s.h
@@ -0,0 +1,131 @@
1/*
2 MaxLinear MXL5005S VSB/QAM/DVBT tuner driver
3
4 Copyright (C) 2008 MaxLinear
5 Copyright (C) 2008 Steven Toth <stoth@hauppauge.com>
6
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
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
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
19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20
21*/
22
23#ifndef __MXL5005S_H
24#define __MXL5005S_H
25
26#include <linux/i2c.h>
27#include "dvb_frontend.h"
28
29struct mxl5005s_config {
30
31 /* 7 bit i2c address */
32 u8 i2c_address;
33
34#define IF_FREQ_4570000HZ 4570000
35#define IF_FREQ_4571429HZ 4571429
36#define IF_FREQ_5380000HZ 5380000
37#define IF_FREQ_36000000HZ 36000000
38#define IF_FREQ_36125000HZ 36125000
39#define IF_FREQ_36166667HZ 36166667
40#define IF_FREQ_44000000HZ 44000000
41 u32 if_freq;
42
43#define CRYSTAL_FREQ_4000000HZ 4000000
44#define CRYSTAL_FREQ_16000000HZ 16000000
45#define CRYSTAL_FREQ_25000000HZ 25000000
46#define CRYSTAL_FREQ_28800000HZ 28800000
47 u32 xtal_freq;
48
49#define MXL_DUAL_AGC 0
50#define MXL_SINGLE_AGC 1
51 u8 agc_mode;
52
53#define MXL_TF_DEFAULT 0
54#define MXL_TF_OFF 1
55#define MXL_TF_C 2
56#define MXL_TF_C_H 3
57#define MXL_TF_D 4
58#define MXL_TF_D_L 5
59#define MXL_TF_E 6
60#define MXL_TF_F 7
61#define MXL_TF_E_2 8
62#define MXL_TF_E_NA 9
63#define MXL_TF_G 10
64 u8 tracking_filter;
65
66#define MXL_RSSI_DISABLE 0
67#define MXL_RSSI_ENABLE 1
68 u8 rssi_enable;
69
70#define MXL_CAP_SEL_DISABLE 0
71#define MXL_CAP_SEL_ENABLE 1
72 u8 cap_select;
73
74#define MXL_DIV_OUT_1 0
75#define MXL_DIV_OUT_4 1
76 u8 div_out;
77
78#define MXL_CLOCK_OUT_DISABLE 0
79#define MXL_CLOCK_OUT_ENABLE 1
80 u8 clock_out;
81
82#define MXL5005S_IF_OUTPUT_LOAD_200_OHM 200
83#define MXL5005S_IF_OUTPUT_LOAD_300_OHM 300
84 u32 output_load;
85
86#define MXL5005S_TOP_5P5 55
87#define MXL5005S_TOP_7P2 72
88#define MXL5005S_TOP_9P2 92
89#define MXL5005S_TOP_11P0 110
90#define MXL5005S_TOP_12P9 129
91#define MXL5005S_TOP_14P7 147
92#define MXL5005S_TOP_16P8 168
93#define MXL5005S_TOP_19P4 194
94#define MXL5005S_TOP_21P2 212
95#define MXL5005S_TOP_23P2 232
96#define MXL5005S_TOP_25P2 252
97#define MXL5005S_TOP_27P1 271
98#define MXL5005S_TOP_29P2 292
99#define MXL5005S_TOP_31P7 317
100#define MXL5005S_TOP_34P9 349
101 u32 top;
102
103#define MXL_ANALOG_MODE 0
104#define MXL_DIGITAL_MODE 1
105 u8 mod_mode;
106
107#define MXL_ZERO_IF 0
108#define MXL_LOW_IF 1
109 u8 if_mode;
110
111 /* Stuff I don't know what to do with */
112 u8 AgcMasterByte;
113};
114
115#if defined(CONFIG_MEDIA_TUNER_MXL5005S) || \
116 (defined(CONFIG_MEDIA_TUNER_MXL5005S_MODULE) && defined(MODULE))
117extern struct dvb_frontend *mxl5005s_attach(struct dvb_frontend *fe,
118 struct i2c_adapter *i2c,
119 struct mxl5005s_config *config);
120#else
121static inline struct dvb_frontend *mxl5005s_attach(struct dvb_frontend *fe,
122 struct i2c_adapter *i2c,
123 struct mxl5005s_config *config)
124{
125 printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__);
126 return NULL;
127}
128#endif /* CONFIG_DVB_TUNER_MXL5005S */
129
130#endif /* __MXL5005S_H */
131
diff --git a/drivers/media/common/tuners/tda18271-common.c b/drivers/media/common/tuners/tda18271-common.c
index e27a7620a32f..42b5f5d4bfe6 100644
--- a/drivers/media/common/tuners/tda18271-common.c
+++ b/drivers/media/common/tuners/tda18271-common.c
@@ -227,9 +227,8 @@ int tda18271_charge_pump_source(struct dvb_frontend *fe,
227 227
228 regs[r_cp] &= ~0x20; 228 regs[r_cp] &= ~0x20;
229 regs[r_cp] |= ((force & 1) << 5); 229 regs[r_cp] |= ((force & 1) << 5);
230 tda18271_write_regs(fe, r_cp, 1);
231 230
232 return 0; 231 return tda18271_write_regs(fe, r_cp, 1);
233} 232}
234 233
235int tda18271_init_regs(struct dvb_frontend *fe) 234int tda18271_init_regs(struct dvb_frontend *fe)
@@ -487,16 +486,15 @@ int tda18271_set_standby_mode(struct dvb_frontend *fe,
487 struct tda18271_priv *priv = fe->tuner_priv; 486 struct tda18271_priv *priv = fe->tuner_priv;
488 unsigned char *regs = priv->tda18271_regs; 487 unsigned char *regs = priv->tda18271_regs;
489 488
490 tda_dbg("sm = %d, sm_lt = %d, sm_xt = %d\n", sm, sm_lt, sm_xt); 489 if (tda18271_debug & DBG_ADV)
490 tda_dbg("sm = %d, sm_lt = %d, sm_xt = %d\n", sm, sm_lt, sm_xt);
491 491
492 regs[R_EP3] &= ~0xe0; /* clear sm, sm_lt, sm_xt */ 492 regs[R_EP3] &= ~0xe0; /* clear sm, sm_lt, sm_xt */
493 regs[R_EP3] |= sm ? (1 << 7) : 0 | 493 regs[R_EP3] |= sm ? (1 << 7) : 0 |
494 sm_lt ? (1 << 6) : 0 | 494 sm_lt ? (1 << 6) : 0 |
495 sm_xt ? (1 << 5) : 0; 495 sm_xt ? (1 << 5) : 0;
496 496
497 tda18271_write_regs(fe, R_EP3, 1); 497 return tda18271_write_regs(fe, R_EP3, 1);
498
499 return 0;
500} 498}
501 499
502/*---------------------------------------------------------------------*/ 500/*---------------------------------------------------------------------*/
@@ -510,7 +508,7 @@ int tda18271_calc_main_pll(struct dvb_frontend *fe, u32 freq)
510 u32 div; 508 u32 div;
511 509
512 int ret = tda18271_lookup_pll_map(fe, MAIN_PLL, &freq, &pd, &d); 510 int ret = tda18271_lookup_pll_map(fe, MAIN_PLL, &freq, &pd, &d);
513 if (ret < 0) 511 if (tda_fail(ret))
514 goto fail; 512 goto fail;
515 513
516 regs[R_MPD] = (0x77 & pd); 514 regs[R_MPD] = (0x77 & pd);
@@ -542,7 +540,7 @@ int tda18271_calc_cal_pll(struct dvb_frontend *fe, u32 freq)
542 u32 div; 540 u32 div;
543 541
544 int ret = tda18271_lookup_pll_map(fe, CAL_PLL, &freq, &pd, &d); 542 int ret = tda18271_lookup_pll_map(fe, CAL_PLL, &freq, &pd, &d);
545 if (ret < 0) 543 if (tda_fail(ret))
546 goto fail; 544 goto fail;
547 545
548 regs[R_CPD] = pd; 546 regs[R_CPD] = pd;
@@ -566,7 +564,7 @@ int tda18271_calc_bp_filter(struct dvb_frontend *fe, u32 *freq)
566 u8 val; 564 u8 val;
567 565
568 int ret = tda18271_lookup_map(fe, BP_FILTER, freq, &val); 566 int ret = tda18271_lookup_map(fe, BP_FILTER, freq, &val);
569 if (ret < 0) 567 if (tda_fail(ret))
570 goto fail; 568 goto fail;
571 569
572 regs[R_EP1] &= ~0x07; /* clear bp filter bits */ 570 regs[R_EP1] &= ~0x07; /* clear bp filter bits */
@@ -583,7 +581,7 @@ int tda18271_calc_km(struct dvb_frontend *fe, u32 *freq)
583 u8 val; 581 u8 val;
584 582
585 int ret = tda18271_lookup_map(fe, RF_CAL_KMCO, freq, &val); 583 int ret = tda18271_lookup_map(fe, RF_CAL_KMCO, freq, &val);
586 if (ret < 0) 584 if (tda_fail(ret))
587 goto fail; 585 goto fail;
588 586
589 regs[R_EB13] &= ~0x7c; /* clear k & m bits */ 587 regs[R_EB13] &= ~0x7c; /* clear k & m bits */
@@ -600,7 +598,7 @@ int tda18271_calc_rf_band(struct dvb_frontend *fe, u32 *freq)
600 u8 val; 598 u8 val;
601 599
602 int ret = tda18271_lookup_map(fe, RF_BAND, freq, &val); 600 int ret = tda18271_lookup_map(fe, RF_BAND, freq, &val);
603 if (ret < 0) 601 if (tda_fail(ret))
604 goto fail; 602 goto fail;
605 603
606 regs[R_EP2] &= ~0xe0; /* clear rf band bits */ 604 regs[R_EP2] &= ~0xe0; /* clear rf band bits */
@@ -617,7 +615,7 @@ int tda18271_calc_gain_taper(struct dvb_frontend *fe, u32 *freq)
617 u8 val; 615 u8 val;
618 616
619 int ret = tda18271_lookup_map(fe, GAIN_TAPER, freq, &val); 617 int ret = tda18271_lookup_map(fe, GAIN_TAPER, freq, &val);
620 if (ret < 0) 618 if (tda_fail(ret))
621 goto fail; 619 goto fail;
622 620
623 regs[R_EP2] &= ~0x1f; /* clear gain taper bits */ 621 regs[R_EP2] &= ~0x1f; /* clear gain taper bits */
@@ -634,7 +632,7 @@ int tda18271_calc_ir_measure(struct dvb_frontend *fe, u32 *freq)
634 u8 val; 632 u8 val;
635 633
636 int ret = tda18271_lookup_map(fe, IR_MEASURE, freq, &val); 634 int ret = tda18271_lookup_map(fe, IR_MEASURE, freq, &val);
637 if (ret < 0) 635 if (tda_fail(ret))
638 goto fail; 636 goto fail;
639 637
640 regs[R_EP5] &= ~0x07; 638 regs[R_EP5] &= ~0x07;
diff --git a/drivers/media/common/tuners/tda18271-fe.c b/drivers/media/common/tuners/tda18271-fe.c
index b262100ae897..89c01fb1f859 100644
--- a/drivers/media/common/tuners/tda18271-fe.c
+++ b/drivers/media/common/tuners/tda18271-fe.c
@@ -51,6 +51,7 @@ static int tda18271_channel_configuration(struct dvb_frontend *fe,
51{ 51{
52 struct tda18271_priv *priv = fe->tuner_priv; 52 struct tda18271_priv *priv = fe->tuner_priv;
53 unsigned char *regs = priv->tda18271_regs; 53 unsigned char *regs = priv->tda18271_regs;
54 int ret;
54 u32 N; 55 u32 N;
55 56
56 /* update TV broadcast parameters */ 57 /* update TV broadcast parameters */
@@ -85,7 +86,9 @@ static int tda18271_channel_configuration(struct dvb_frontend *fe,
85 /* update rf top / if top */ 86 /* update rf top / if top */
86 regs[R_EB22] = 0x00; 87 regs[R_EB22] = 0x00;
87 regs[R_EB22] |= map->rfagc_top; 88 regs[R_EB22] |= map->rfagc_top;
88 tda18271_write_regs(fe, R_EB22, 1); 89 ret = tda18271_write_regs(fe, R_EB22, 1);
90 if (tda_fail(ret))
91 goto fail;
89 92
90 /* --------------------------------------------------------------- */ 93 /* --------------------------------------------------------------- */
91 94
@@ -121,7 +124,9 @@ static int tda18271_channel_configuration(struct dvb_frontend *fe,
121 /* agc1 has priority on agc2 */ 124 /* agc1 has priority on agc2 */
122 regs[R_EB1] &= ~0x01; 125 regs[R_EB1] &= ~0x01;
123 126
124 tda18271_write_regs(fe, R_EB1, 1); 127 ret = tda18271_write_regs(fe, R_EB1, 1);
128 if (tda_fail(ret))
129 goto fail;
125 130
126 /* --------------------------------------------------------------- */ 131 /* --------------------------------------------------------------- */
127 132
@@ -141,7 +146,9 @@ static int tda18271_channel_configuration(struct dvb_frontend *fe,
141 break; 146 break;
142 } 147 }
143 148
144 tda18271_write_regs(fe, R_TM, 7); 149 ret = tda18271_write_regs(fe, R_TM, 7);
150 if (tda_fail(ret))
151 goto fail;
145 152
146 /* force charge pump source */ 153 /* force charge pump source */
147 charge_pump_source(fe, 1); 154 charge_pump_source(fe, 1);
@@ -158,9 +165,9 @@ static int tda18271_channel_configuration(struct dvb_frontend *fe,
158 regs[R_EP3] &= ~0x04; 165 regs[R_EP3] &= ~0x04;
159 else 166 else
160 regs[R_EP3] |= 0x04; 167 regs[R_EP3] |= 0x04;
161 tda18271_write_regs(fe, R_EP3, 1); 168 ret = tda18271_write_regs(fe, R_EP3, 1);
162 169fail:
163 return 0; 170 return ret;
164} 171}
165 172
166static int tda18271_read_thermometer(struct dvb_frontend *fe) 173static int tda18271_read_thermometer(struct dvb_frontend *fe)
@@ -213,11 +220,13 @@ static int tda18271c2_rf_tracking_filters_correction(struct dvb_frontend *fe,
213 struct tda18271_priv *priv = fe->tuner_priv; 220 struct tda18271_priv *priv = fe->tuner_priv;
214 struct tda18271_rf_tracking_filter_cal *map = priv->rf_cal_state; 221 struct tda18271_rf_tracking_filter_cal *map = priv->rf_cal_state;
215 unsigned char *regs = priv->tda18271_regs; 222 unsigned char *regs = priv->tda18271_regs;
216 int tm_current, rfcal_comp, approx, i; 223 int tm_current, rfcal_comp, approx, i, ret;
217 u8 dc_over_dt, rf_tab; 224 u8 dc_over_dt, rf_tab;
218 225
219 /* power up */ 226 /* power up */
220 tda18271_set_standby_mode(fe, 0, 0, 0); 227 ret = tda18271_set_standby_mode(fe, 0, 0, 0);
228 if (tda_fail(ret))
229 goto fail;
221 230
222 /* read die current temperature */ 231 /* read die current temperature */
223 tm_current = tda18271_read_thermometer(fe); 232 tm_current = tda18271_read_thermometer(fe);
@@ -228,8 +237,8 @@ static int tda18271c2_rf_tracking_filters_correction(struct dvb_frontend *fe,
228 rf_tab = regs[R_EB14]; 237 rf_tab = regs[R_EB14];
229 238
230 i = tda18271_lookup_rf_band(fe, &freq, NULL); 239 i = tda18271_lookup_rf_band(fe, &freq, NULL);
231 if (i < 0) 240 if (tda_fail(i))
232 return -EINVAL; 241 return i;
233 242
234 if ((0 == map[i].rf3) || (freq / 1000 < map[i].rf2)) { 243 if ((0 == map[i].rf3) || (freq / 1000 < map[i].rf2)) {
235 approx = map[i].rf_a1 * 244 approx = map[i].rf_a1 *
@@ -250,35 +259,42 @@ static int tda18271c2_rf_tracking_filters_correction(struct dvb_frontend *fe,
250 rfcal_comp = dc_over_dt * (tm_current - priv->tm_rfcal); 259 rfcal_comp = dc_over_dt * (tm_current - priv->tm_rfcal);
251 260
252 regs[R_EB14] = approx + rfcal_comp; 261 regs[R_EB14] = approx + rfcal_comp;
253 tda18271_write_regs(fe, R_EB14, 1); 262 ret = tda18271_write_regs(fe, R_EB14, 1);
254 263fail:
255 return 0; 264 return ret;
256} 265}
257 266
258static int tda18271_por(struct dvb_frontend *fe) 267static int tda18271_por(struct dvb_frontend *fe)
259{ 268{
260 struct tda18271_priv *priv = fe->tuner_priv; 269 struct tda18271_priv *priv = fe->tuner_priv;
261 unsigned char *regs = priv->tda18271_regs; 270 unsigned char *regs = priv->tda18271_regs;
271 int ret;
262 272
263 /* power up detector 1 */ 273 /* power up detector 1 */
264 regs[R_EB12] &= ~0x20; 274 regs[R_EB12] &= ~0x20;
265 tda18271_write_regs(fe, R_EB12, 1); 275 ret = tda18271_write_regs(fe, R_EB12, 1);
276 if (tda_fail(ret))
277 goto fail;
266 278
267 regs[R_EB18] &= ~0x80; /* turn agc1 loop on */ 279 regs[R_EB18] &= ~0x80; /* turn agc1 loop on */
268 regs[R_EB18] &= ~0x03; /* set agc1_gain to 6 dB */ 280 regs[R_EB18] &= ~0x03; /* set agc1_gain to 6 dB */
269 tda18271_write_regs(fe, R_EB18, 1); 281 ret = tda18271_write_regs(fe, R_EB18, 1);
282 if (tda_fail(ret))
283 goto fail;
270 284
271 regs[R_EB21] |= 0x03; /* set agc2_gain to -6 dB */ 285 regs[R_EB21] |= 0x03; /* set agc2_gain to -6 dB */
272 286
273 /* POR mode */ 287 /* POR mode */
274 tda18271_set_standby_mode(fe, 1, 0, 0); 288 ret = tda18271_set_standby_mode(fe, 1, 0, 0);
289 if (tda_fail(ret))
290 goto fail;
275 291
276 /* disable 1.5 MHz low pass filter */ 292 /* disable 1.5 MHz low pass filter */
277 regs[R_EB23] &= ~0x04; /* forcelp_fc2_en = 0 */ 293 regs[R_EB23] &= ~0x04; /* forcelp_fc2_en = 0 */
278 regs[R_EB23] &= ~0x02; /* XXX: lp_fc[2] = 0 */ 294 regs[R_EB23] &= ~0x02; /* XXX: lp_fc[2] = 0 */
279 tda18271_write_regs(fe, R_EB21, 3); 295 ret = tda18271_write_regs(fe, R_EB21, 3);
280 296fail:
281 return 0; 297 return ret;
282} 298}
283 299
284static int tda18271_calibrate_rf(struct dvb_frontend *fe, u32 freq) 300static int tda18271_calibrate_rf(struct dvb_frontend *fe, u32 freq)
@@ -389,7 +405,7 @@ static int tda18271_powerscan(struct dvb_frontend *fe,
389{ 405{
390 struct tda18271_priv *priv = fe->tuner_priv; 406 struct tda18271_priv *priv = fe->tuner_priv;
391 unsigned char *regs = priv->tda18271_regs; 407 unsigned char *regs = priv->tda18271_regs;
392 int sgn, bcal, count, wait; 408 int sgn, bcal, count, wait, ret;
393 u8 cid_target; 409 u8 cid_target;
394 u16 count_limit; 410 u16 count_limit;
395 u32 freq; 411 u32 freq;
@@ -421,7 +437,9 @@ static int tda18271_powerscan(struct dvb_frontend *fe,
421 tda18271_write_regs(fe, R_EP2, 1); 437 tda18271_write_regs(fe, R_EP2, 1);
422 438
423 /* read power detection info, stored in EB10 */ 439 /* read power detection info, stored in EB10 */
424 tda18271_read_extended(fe); 440 ret = tda18271_read_extended(fe);
441 if (tda_fail(ret))
442 return ret;
425 443
426 /* algorithm initialization */ 444 /* algorithm initialization */
427 sgn = 1; 445 sgn = 1;
@@ -447,7 +465,9 @@ static int tda18271_powerscan(struct dvb_frontend *fe,
447 tda18271_write_regs(fe, R_EP2, 1); 465 tda18271_write_regs(fe, R_EP2, 1);
448 466
449 /* read power detection info, stored in EB10 */ 467 /* read power detection info, stored in EB10 */
450 tda18271_read_extended(fe); 468 ret = tda18271_read_extended(fe);
469 if (tda_fail(ret))
470 return ret;
451 471
452 count += 200; 472 count += 200;
453 473
@@ -478,6 +498,7 @@ static int tda18271_powerscan_init(struct dvb_frontend *fe)
478{ 498{
479 struct tda18271_priv *priv = fe->tuner_priv; 499 struct tda18271_priv *priv = fe->tuner_priv;
480 unsigned char *regs = priv->tda18271_regs; 500 unsigned char *regs = priv->tda18271_regs;
501 int ret;
481 502
482 /* set standard to digital */ 503 /* set standard to digital */
483 regs[R_EP3] &= ~0x1f; /* clear std bits */ 504 regs[R_EP3] &= ~0x1f; /* clear std bits */
@@ -489,10 +510,14 @@ static int tda18271_powerscan_init(struct dvb_frontend *fe)
489 /* update IF output level & IF notch frequency */ 510 /* update IF output level & IF notch frequency */
490 regs[R_EP4] &= ~0x1c; /* clear if level bits */ 511 regs[R_EP4] &= ~0x1c; /* clear if level bits */
491 512
492 tda18271_write_regs(fe, R_EP3, 2); 513 ret = tda18271_write_regs(fe, R_EP3, 2);
514 if (tda_fail(ret))
515 goto fail;
493 516
494 regs[R_EB18] &= ~0x03; /* set agc1_gain to 6 dB */ 517 regs[R_EB18] &= ~0x03; /* set agc1_gain to 6 dB */
495 tda18271_write_regs(fe, R_EB18, 1); 518 ret = tda18271_write_regs(fe, R_EB18, 1);
519 if (tda_fail(ret))
520 goto fail;
496 521
497 regs[R_EB21] &= ~0x03; /* set agc2_gain to -15 dB */ 522 regs[R_EB21] &= ~0x03; /* set agc2_gain to -15 dB */
498 523
@@ -500,9 +525,9 @@ static int tda18271_powerscan_init(struct dvb_frontend *fe)
500 regs[R_EB23] |= 0x04; /* forcelp_fc2_en = 1 */ 525 regs[R_EB23] |= 0x04; /* forcelp_fc2_en = 1 */
501 regs[R_EB23] |= 0x02; /* lp_fc[2] = 1 */ 526 regs[R_EB23] |= 0x02; /* lp_fc[2] = 1 */
502 527
503 tda18271_write_regs(fe, R_EB21, 3); 528 ret = tda18271_write_regs(fe, R_EB21, 3);
504 529fail:
505 return 0; 530 return ret;
506} 531}
507 532
508static int tda18271_rf_tracking_filters_init(struct dvb_frontend *fe, u32 freq) 533static int tda18271_rf_tracking_filters_init(struct dvb_frontend *fe, u32 freq)
@@ -521,7 +546,7 @@ static int tda18271_rf_tracking_filters_init(struct dvb_frontend *fe, u32 freq)
521 546
522 i = tda18271_lookup_rf_band(fe, &freq, NULL); 547 i = tda18271_lookup_rf_band(fe, &freq, NULL);
523 548
524 if (i < 0) 549 if (tda_fail(i))
525 return i; 550 return i;
526 551
527 rf_default[RF1] = 1000 * map[i].rf1_def; 552 rf_default[RF1] = 1000 * map[i].rf1_def;
@@ -535,6 +560,8 @@ static int tda18271_rf_tracking_filters_init(struct dvb_frontend *fe, u32 freq)
535 560
536 /* look for optimized calibration frequency */ 561 /* look for optimized calibration frequency */
537 bcal = tda18271_powerscan(fe, &rf_default[rf], &rf_freq[rf]); 562 bcal = tda18271_powerscan(fe, &rf_default[rf], &rf_freq[rf]);
563 if (tda_fail(bcal))
564 return bcal;
538 565
539 tda18271_calc_rf_cal(fe, &rf_freq[rf]); 566 tda18271_calc_rf_cal(fe, &rf_freq[rf]);
540 prog_tab[rf] = regs[R_EB14]; 567 prog_tab[rf] = regs[R_EB14];
@@ -575,22 +602,29 @@ static int tda18271_calc_rf_filter_curve(struct dvb_frontend *fe)
575{ 602{
576 struct tda18271_priv *priv = fe->tuner_priv; 603 struct tda18271_priv *priv = fe->tuner_priv;
577 unsigned int i; 604 unsigned int i;
605 int ret;
578 606
579 tda_info("tda18271: performing RF tracking filter calibration\n"); 607 tda_info("tda18271: performing RF tracking filter calibration\n");
580 608
581 /* wait for die temperature stabilization */ 609 /* wait for die temperature stabilization */
582 msleep(200); 610 msleep(200);
583 611
584 tda18271_powerscan_init(fe); 612 ret = tda18271_powerscan_init(fe);
613 if (tda_fail(ret))
614 goto fail;
585 615
586 /* rf band calibration */ 616 /* rf band calibration */
587 for (i = 0; priv->rf_cal_state[i].rfmax != 0; i++) 617 for (i = 0; priv->rf_cal_state[i].rfmax != 0; i++) {
618 ret =
588 tda18271_rf_tracking_filters_init(fe, 1000 * 619 tda18271_rf_tracking_filters_init(fe, 1000 *
589 priv->rf_cal_state[i].rfmax); 620 priv->rf_cal_state[i].rfmax);
621 if (tda_fail(ret))
622 goto fail;
623 }
590 624
591 priv->tm_rfcal = tda18271_read_thermometer(fe); 625 priv->tm_rfcal = tda18271_read_thermometer(fe);
592 626fail:
593 return 0; 627 return ret;
594} 628}
595 629
596/* ------------------------------------------------------------------ */ 630/* ------------------------------------------------------------------ */
@@ -599,6 +633,7 @@ static int tda18271c2_rf_cal_init(struct dvb_frontend *fe)
599{ 633{
600 struct tda18271_priv *priv = fe->tuner_priv; 634 struct tda18271_priv *priv = fe->tuner_priv;
601 unsigned char *regs = priv->tda18271_regs; 635 unsigned char *regs = priv->tda18271_regs;
636 int ret;
602 637
603 /* test RF_CAL_OK to see if we need init */ 638 /* test RF_CAL_OK to see if we need init */
604 if ((regs[R_EP1] & 0x10) == 0) 639 if ((regs[R_EP1] & 0x10) == 0)
@@ -607,15 +642,22 @@ static int tda18271c2_rf_cal_init(struct dvb_frontend *fe)
607 if (priv->cal_initialized) 642 if (priv->cal_initialized)
608 return 0; 643 return 0;
609 644
610 tda18271_calc_rf_filter_curve(fe); 645 ret = tda18271_calc_rf_filter_curve(fe);
646 if (tda_fail(ret))
647 goto fail;
611 648
612 tda18271_por(fe); 649 ret = tda18271_por(fe);
650 if (tda_fail(ret))
651 goto fail;
613 652
614 tda_info("tda18271: RF tracking filter calibration complete\n"); 653 tda_info("tda18271: RF tracking filter calibration complete\n");
615 654
616 priv->cal_initialized = true; 655 priv->cal_initialized = true;
617 656 goto end;
618 return 0; 657fail:
658 tda_info("tda18271: RF tracking filter calibration failed!\n");
659end:
660 return ret;
619} 661}
620 662
621static int tda18271c1_rf_tracking_filter_calibration(struct dvb_frontend *fe, 663static int tda18271c1_rf_tracking_filter_calibration(struct dvb_frontend *fe,
@@ -623,6 +665,7 @@ static int tda18271c1_rf_tracking_filter_calibration(struct dvb_frontend *fe,
623{ 665{
624 struct tda18271_priv *priv = fe->tuner_priv; 666 struct tda18271_priv *priv = fe->tuner_priv;
625 unsigned char *regs = priv->tda18271_regs; 667 unsigned char *regs = priv->tda18271_regs;
668 int ret;
626 u32 N = 0; 669 u32 N = 0;
627 670
628 /* calculate bp filter */ 671 /* calculate bp filter */
@@ -671,7 +714,10 @@ static int tda18271c1_rf_tracking_filter_calibration(struct dvb_frontend *fe,
671 714
672 tda18271_calc_main_pll(fe, N); 715 tda18271_calc_main_pll(fe, N);
673 716
674 tda18271_write_regs(fe, R_EP3, 11); 717 ret = tda18271_write_regs(fe, R_EP3, 11);
718 if (tda_fail(ret))
719 return ret;
720
675 msleep(5); /* RF tracking filter calibration initialization */ 721 msleep(5); /* RF tracking filter calibration initialization */
676 722
677 /* search for K,M,CO for RF calibration */ 723 /* search for K,M,CO for RF calibration */
@@ -719,45 +765,56 @@ static int tda18271_ir_cal_init(struct dvb_frontend *fe)
719{ 765{
720 struct tda18271_priv *priv = fe->tuner_priv; 766 struct tda18271_priv *priv = fe->tuner_priv;
721 unsigned char *regs = priv->tda18271_regs; 767 unsigned char *regs = priv->tda18271_regs;
768 int ret;
722 769
723 tda18271_read_regs(fe); 770 ret = tda18271_read_regs(fe);
771 if (tda_fail(ret))
772 goto fail;
724 773
725 /* test IR_CAL_OK to see if we need init */ 774 /* test IR_CAL_OK to see if we need init */
726 if ((regs[R_EP1] & 0x08) == 0) 775 if ((regs[R_EP1] & 0x08) == 0)
727 tda18271_init_regs(fe); 776 ret = tda18271_init_regs(fe);
728 777fail:
729 return 0; 778 return ret;
730} 779}
731 780
732static int tda18271_init(struct dvb_frontend *fe) 781static int tda18271_init(struct dvb_frontend *fe)
733{ 782{
734 struct tda18271_priv *priv = fe->tuner_priv; 783 struct tda18271_priv *priv = fe->tuner_priv;
784 int ret;
735 785
736 mutex_lock(&priv->lock); 786 mutex_lock(&priv->lock);
737 787
738 /* power up */ 788 /* power up */
739 tda18271_set_standby_mode(fe, 0, 0, 0); 789 ret = tda18271_set_standby_mode(fe, 0, 0, 0);
790 if (tda_fail(ret))
791 goto fail;
740 792
741 /* initialization */ 793 /* initialization */
742 tda18271_ir_cal_init(fe); 794 ret = tda18271_ir_cal_init(fe);
795 if (tda_fail(ret))
796 goto fail;
743 797
744 if (priv->id == TDA18271HDC2) 798 if (priv->id == TDA18271HDC2)
745 tda18271c2_rf_cal_init(fe); 799 tda18271c2_rf_cal_init(fe);
746 800fail:
747 mutex_unlock(&priv->lock); 801 mutex_unlock(&priv->lock);
748 802
749 return 0; 803 return ret;
750} 804}
751 805
752static int tda18271_tune(struct dvb_frontend *fe, 806static int tda18271_tune(struct dvb_frontend *fe,
753 struct tda18271_std_map_item *map, u32 freq, u32 bw) 807 struct tda18271_std_map_item *map, u32 freq, u32 bw)
754{ 808{
755 struct tda18271_priv *priv = fe->tuner_priv; 809 struct tda18271_priv *priv = fe->tuner_priv;
810 int ret;
756 811
757 tda_dbg("freq = %d, ifc = %d, bw = %d, agc_mode = %d, std = %d\n", 812 tda_dbg("freq = %d, ifc = %d, bw = %d, agc_mode = %d, std = %d\n",
758 freq, map->if_freq, bw, map->agc_mode, map->std); 813 freq, map->if_freq, bw, map->agc_mode, map->std);
759 814
760 tda18271_init(fe); 815 ret = tda18271_init(fe);
816 if (tda_fail(ret))
817 goto fail;
761 818
762 mutex_lock(&priv->lock); 819 mutex_lock(&priv->lock);
763 820
@@ -769,11 +826,11 @@ static int tda18271_tune(struct dvb_frontend *fe,
769 tda18271c2_rf_tracking_filters_correction(fe, freq); 826 tda18271c2_rf_tracking_filters_correction(fe, freq);
770 break; 827 break;
771 } 828 }
772 tda18271_channel_configuration(fe, map, freq, bw); 829 ret = tda18271_channel_configuration(fe, map, freq, bw);
773 830
774 mutex_unlock(&priv->lock); 831 mutex_unlock(&priv->lock);
775 832fail:
776 return 0; 833 return ret;
777} 834}
778 835
779/* ------------------------------------------------------------------ */ 836/* ------------------------------------------------------------------ */
@@ -837,7 +894,7 @@ static int tda18271_set_params(struct dvb_frontend *fe,
837 894
838 ret = tda18271_tune(fe, map, freq, bw); 895 ret = tda18271_tune(fe, map, freq, bw);
839 896
840 if (ret < 0) 897 if (tda_fail(ret))
841 goto fail; 898 goto fail;
842 899
843 priv->frequency = freq; 900 priv->frequency = freq;
@@ -893,7 +950,7 @@ static int tda18271_set_analog_params(struct dvb_frontend *fe,
893 950
894 ret = tda18271_tune(fe, map, freq, 0); 951 ret = tda18271_tune(fe, map, freq, 0);
895 952
896 if (ret < 0) 953 if (tda_fail(ret))
897 goto fail; 954 goto fail;
898 955
899 priv->frequency = freq; 956 priv->frequency = freq;
@@ -905,16 +962,17 @@ fail:
905static int tda18271_sleep(struct dvb_frontend *fe) 962static int tda18271_sleep(struct dvb_frontend *fe)
906{ 963{
907 struct tda18271_priv *priv = fe->tuner_priv; 964 struct tda18271_priv *priv = fe->tuner_priv;
965 int ret;
908 966
909 mutex_lock(&priv->lock); 967 mutex_lock(&priv->lock);
910 968
911 /* standby mode w/ slave tuner output 969 /* standby mode w/ slave tuner output
912 * & loop thru & xtal oscillator on */ 970 * & loop thru & xtal oscillator on */
913 tda18271_set_standby_mode(fe, 1, 0, 0); 971 ret = tda18271_set_standby_mode(fe, 1, 0, 0);
914 972
915 mutex_unlock(&priv->lock); 973 mutex_unlock(&priv->lock);
916 974
917 return 0; 975 return ret;
918} 976}
919 977
920static int tda18271_release(struct dvb_frontend *fe) 978static int tda18271_release(struct dvb_frontend *fe)
@@ -1095,10 +1153,10 @@ struct dvb_frontend *tda18271_attach(struct dvb_frontend *fe, u8 addr,
1095 if (cfg) 1153 if (cfg)
1096 priv->small_i2c = cfg->small_i2c; 1154 priv->small_i2c = cfg->small_i2c;
1097 1155
1098 if (tda18271_get_id(fe) < 0) 1156 if (tda_fail(tda18271_get_id(fe)))
1099 goto fail; 1157 goto fail;
1100 1158
1101 if (tda18271_assign_map_layout(fe) < 0) 1159 if (tda_fail(tda18271_assign_map_layout(fe)))
1102 goto fail; 1160 goto fail;
1103 1161
1104 mutex_lock(&priv->lock); 1162 mutex_lock(&priv->lock);
diff --git a/drivers/media/common/tuners/tda18271-priv.h b/drivers/media/common/tuners/tda18271-priv.h
index 2bc5eb368ea2..81a739365f8c 100644
--- a/drivers/media/common/tuners/tda18271-priv.h
+++ b/drivers/media/common/tuners/tda18271-priv.h
@@ -153,6 +153,15 @@ extern int tda18271_debug;
153#define tda_reg(fmt, arg...) dprintk(KERN_DEBUG, DBG_REG, fmt, ##arg) 153#define tda_reg(fmt, arg...) dprintk(KERN_DEBUG, DBG_REG, fmt, ##arg)
154#define tda_cal(fmt, arg...) dprintk(KERN_DEBUG, DBG_CAL, fmt, ##arg) 154#define tda_cal(fmt, arg...) dprintk(KERN_DEBUG, DBG_CAL, fmt, ##arg)
155 155
156#define tda_fail(ret) \
157({ \
158 int __ret; \
159 __ret = (ret < 0); \
160 if (__ret) \
161 tda_printk(KERN_ERR, "error %d on line %d\n", ret, __LINE__);\
162 __ret; \
163})
164
156/*---------------------------------------------------------------------*/ 165/*---------------------------------------------------------------------*/
157 166
158enum tda18271_map_type { 167enum tda18271_map_type {
diff --git a/drivers/media/common/tuners/tea5767.c b/drivers/media/common/tuners/tea5767.c
index f6e7d7ad8424..1f5646334a8f 100644
--- a/drivers/media/common/tuners/tea5767.c
+++ b/drivers/media/common/tuners/tea5767.c
@@ -373,14 +373,14 @@ int tea5767_autodetection(struct i2c_adapter* i2c_adap, u8 i2c_addr)
373 373
374 if ((rc = tuner_i2c_xfer_recv(&i2c, buffer, 7))< 5) { 374 if ((rc = tuner_i2c_xfer_recv(&i2c, buffer, 7))< 5) {
375 printk(KERN_WARNING "It is not a TEA5767. Received %i bytes.\n", rc); 375 printk(KERN_WARNING "It is not a TEA5767. Received %i bytes.\n", rc);
376 return EINVAL; 376 return -EINVAL;
377 } 377 }
378 378
379 /* If all bytes are the same then it's a TV tuner and not a tea5767 */ 379 /* If all bytes are the same then it's a TV tuner and not a tea5767 */
380 if (buffer[0] == buffer[1] && buffer[0] == buffer[2] && 380 if (buffer[0] == buffer[1] && buffer[0] == buffer[2] &&
381 buffer[0] == buffer[3] && buffer[0] == buffer[4]) { 381 buffer[0] == buffer[3] && buffer[0] == buffer[4]) {
382 printk(KERN_WARNING "All bytes are equal. It is not a TEA5767\n"); 382 printk(KERN_WARNING "All bytes are equal. It is not a TEA5767\n");
383 return EINVAL; 383 return -EINVAL;
384 } 384 }
385 385
386 /* Status bytes: 386 /* Status bytes:
@@ -390,7 +390,7 @@ int tea5767_autodetection(struct i2c_adapter* i2c_adap, u8 i2c_addr)
390 */ 390 */
391 if (((buffer[3] & 0x0f) != 0x00) || (buffer[4] != 0x00)) { 391 if (((buffer[3] & 0x0f) != 0x00) || (buffer[4] != 0x00)) {
392 printk(KERN_WARNING "Chip ID is not zero. It is not a TEA5767\n"); 392 printk(KERN_WARNING "Chip ID is not zero. It is not a TEA5767\n");
393 return EINVAL; 393 return -EINVAL;
394 } 394 }
395 395
396 396
diff --git a/drivers/media/common/tuners/xc5000.c b/drivers/media/common/tuners/xc5000.c
index 43d35bdb221f..ceae6db901ec 100644
--- a/drivers/media/common/tuners/xc5000.c
+++ b/drivers/media/common/tuners/xc5000.c
@@ -212,7 +212,7 @@ static void xc5000_TunerReset(struct dvb_frontend *fe)
212 dprintk(1, "%s()\n", __func__); 212 dprintk(1, "%s()\n", __func__);
213 213
214 if (priv->cfg->tuner_callback) { 214 if (priv->cfg->tuner_callback) {
215 ret = priv->cfg->tuner_callback(priv->cfg->priv, 215 ret = priv->cfg->tuner_callback(priv->devptr,
216 XC5000_TUNER_RESET, 0); 216 XC5000_TUNER_RESET, 0);
217 if (ret) 217 if (ret)
218 printk(KERN_ERR "xc5000: reset failed\n"); 218 printk(KERN_ERR "xc5000: reset failed\n");
@@ -900,9 +900,9 @@ static const struct dvb_tuner_ops xc5000_tuner_ops = {
900 .get_status = xc5000_get_status 900 .get_status = xc5000_get_status
901}; 901};
902 902
903struct dvb_frontend * xc5000_attach(struct dvb_frontend *fe, 903struct dvb_frontend *xc5000_attach(struct dvb_frontend *fe,
904 struct i2c_adapter *i2c, 904 struct i2c_adapter *i2c,
905 struct xc5000_config *cfg) 905 struct xc5000_config *cfg, void *devptr)
906{ 906{
907 struct xc5000_priv *priv = NULL; 907 struct xc5000_priv *priv = NULL;
908 u16 id = 0; 908 u16 id = 0;
@@ -916,6 +916,7 @@ struct dvb_frontend * xc5000_attach(struct dvb_frontend *fe,
916 priv->cfg = cfg; 916 priv->cfg = cfg;
917 priv->bandwidth = BANDWIDTH_6_MHZ; 917 priv->bandwidth = BANDWIDTH_6_MHZ;
918 priv->i2c = i2c; 918 priv->i2c = i2c;
919 priv->devptr = devptr;
919 920
920 /* Check if firmware has been loaded. It is possible that another 921 /* Check if firmware has been loaded. It is possible that another
921 instance of the driver has loaded the firmware. 922 instance of the driver has loaded the firmware.
diff --git a/drivers/media/common/tuners/xc5000.h b/drivers/media/common/tuners/xc5000.h
index 0ee80f9d19b8..c910715addc9 100644
--- a/drivers/media/common/tuners/xc5000.h
+++ b/drivers/media/common/tuners/xc5000.h
@@ -31,29 +31,31 @@ struct xc5000_config {
31 u8 i2c_address; 31 u8 i2c_address;
32 u32 if_khz; 32 u32 if_khz;
33 33
34 /* For each bridge framework, when it attaches either analog or digital,
35 * it has to store a reference back to its _core equivalent structure,
36 * so that it can service the hardware by steering gpio's etc.
37 * Each bridge implementation is different so cast priv accordingly.
38 * The xc5000 driver cares not for this value, other than ensuring
39 * it's passed back to a bridge during tuner_callback().
40 */
41 void *priv;
42 int (*tuner_callback) (void *priv, int command, int arg); 34 int (*tuner_callback) (void *priv, int command, int arg);
43}; 35};
44 36
45/* xc5000 callback command */ 37/* xc5000 callback command */
46#define XC5000_TUNER_RESET 0 38#define XC5000_TUNER_RESET 0
47 39
40/* For each bridge framework, when it attaches either analog or digital,
41 * it has to store a reference back to its _core equivalent structure,
42 * so that it can service the hardware by steering gpio's etc.
43 * Each bridge implementation is different so cast devptr accordingly.
44 * The xc5000 driver cares not for this value, other than ensuring
45 * it's passed back to a bridge during tuner_callback().
46 */
47
48#if defined(CONFIG_MEDIA_TUNER_XC5000) || \ 48#if defined(CONFIG_MEDIA_TUNER_XC5000) || \
49 (defined(CONFIG_MEDIA_TUNER_XC5000_MODULE) && defined(MODULE)) 49 (defined(CONFIG_MEDIA_TUNER_XC5000_MODULE) && defined(MODULE))
50extern struct dvb_frontend* xc5000_attach(struct dvb_frontend *fe, 50extern struct dvb_frontend* xc5000_attach(struct dvb_frontend *fe,
51 struct i2c_adapter *i2c, 51 struct i2c_adapter *i2c,
52 struct xc5000_config *cfg); 52 struct xc5000_config *cfg,
53 void *devptr);
53#else 54#else
54static inline struct dvb_frontend* xc5000_attach(struct dvb_frontend *fe, 55static inline struct dvb_frontend* xc5000_attach(struct dvb_frontend *fe,
55 struct i2c_adapter *i2c, 56 struct i2c_adapter *i2c,
56 struct xc5000_config *cfg) 57 struct xc5000_config *cfg,
58 void *devptr)
57{ 59{
58 printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__); 60 printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__);
59 return NULL; 61 return NULL;
diff --git a/drivers/media/common/tuners/xc5000_priv.h b/drivers/media/common/tuners/xc5000_priv.h
index 13b2d19341da..ecebfe4745ad 100644
--- a/drivers/media/common/tuners/xc5000_priv.h
+++ b/drivers/media/common/tuners/xc5000_priv.h
@@ -31,6 +31,8 @@ struct xc5000_priv {
31 u8 video_standard; 31 u8 video_standard;
32 u8 rf_mode; 32 u8 rf_mode;
33 u8 fwloaded; 33 u8 fwloaded;
34
35 void *devptr;
34}; 36};
35 37
36#endif 38#endif
diff --git a/drivers/media/dvb/b2c2/flexcop-fe-tuner.c b/drivers/media/dvb/b2c2/flexcop-fe-tuner.c
index 7b0ea3bdfafb..f9d087669d5d 100644
--- a/drivers/media/dvb/b2c2/flexcop-fe-tuner.c
+++ b/drivers/media/dvb/b2c2/flexcop-fe-tuner.c
@@ -634,7 +634,7 @@ int flexcop_frontend_init(struct flexcop_device *fc)
634 } 634 }
635 635
636 /* try the sky v2.3 (vp310/Samsung tbdu18132(tsa5059)) */ 636 /* try the sky v2.3 (vp310/Samsung tbdu18132(tsa5059)) */
637 fc->fe = dvb_attach(vp310_mt312_attach, 637 fc->fe = dvb_attach(mt312_attach,
638 &skystar23_samsung_tbdu18132_config, i2c); 638 &skystar23_samsung_tbdu18132_config, i2c);
639 if (fc->fe != NULL) { 639 if (fc->fe != NULL) {
640 ops = &fc->fe->ops; 640 ops = &fc->fe->ops;
diff --git a/drivers/media/dvb/bt8xx/Kconfig b/drivers/media/dvb/bt8xx/Kconfig
index d1239b8342f8..7588db1319d0 100644
--- a/drivers/media/dvb/bt8xx/Kconfig
+++ b/drivers/media/dvb/bt8xx/Kconfig
@@ -1,6 +1,7 @@
1config DVB_BT8XX 1config DVB_BT8XX
2 tristate "BT8xx based PCI cards" 2 tristate "BT8xx based PCI cards"
3 depends on DVB_CORE && PCI && I2C && VIDEO_BT848 3 depends on DVB_CORE && PCI && I2C && VIDEO_BT848
4 depends on HOTPLUG # due to FW_LOADER
4 select DVB_MT352 if !DVB_FE_CUSTOMISE 5 select DVB_MT352 if !DVB_FE_CUSTOMISE
5 select DVB_SP887X if !DVB_FE_CUSTOMISE 6 select DVB_SP887X if !DVB_FE_CUSTOMISE
6 select DVB_NXT6000 if !DVB_FE_CUSTOMISE 7 select DVB_NXT6000 if !DVB_FE_CUSTOMISE
diff --git a/drivers/media/dvb/cinergyT2/Kconfig b/drivers/media/dvb/cinergyT2/Kconfig
index 3d778c5aba68..c03513b2ccae 100644
--- a/drivers/media/dvb/cinergyT2/Kconfig
+++ b/drivers/media/dvb/cinergyT2/Kconfig
@@ -1,6 +1,6 @@
1config DVB_CINERGYT2 1config DVB_CINERGYT2
2 tristate "Terratec CinergyT2/qanu USB2 DVB-T receiver" 2 tristate "Terratec CinergyT2/qanu USB2 DVB-T receiver"
3 depends on DVB_CORE && USB 3 depends on DVB_CORE && USB && INPUT
4 help 4 help
5 Support for "TerraTec CinergyT2" USB2.0 Highspeed DVB Receivers 5 Support for "TerraTec CinergyT2" USB2.0 Highspeed DVB Receivers
6 6
diff --git a/drivers/media/dvb/dvb-core/dvb_ca_en50221.c b/drivers/media/dvb/dvb-core/dvb_ca_en50221.c
index 8cbdb0ec67e2..588fbe105c27 100644
--- a/drivers/media/dvb/dvb-core/dvb_ca_en50221.c
+++ b/drivers/media/dvb/dvb-core/dvb_ca_en50221.c
@@ -910,15 +910,21 @@ static void dvb_ca_en50221_thread_update_delay(struct dvb_ca_private *ca)
910 int curdelay = 100000000; 910 int curdelay = 100000000;
911 int slot; 911 int slot;
912 912
913 /* Beware of too high polling frequency, because one polling
914 * call might take several hundred milliseconds until timeout!
915 */
913 for (slot = 0; slot < ca->slot_count; slot++) { 916 for (slot = 0; slot < ca->slot_count; slot++) {
914 switch (ca->slot_info[slot].slot_state) { 917 switch (ca->slot_info[slot].slot_state) {
915 default: 918 default:
916 case DVB_CA_SLOTSTATE_NONE: 919 case DVB_CA_SLOTSTATE_NONE:
920 delay = HZ * 60; /* 60s */
921 if (!(ca->flags & DVB_CA_EN50221_FLAG_IRQ_CAMCHANGE))
922 delay = HZ * 5; /* 5s */
923 break;
917 case DVB_CA_SLOTSTATE_INVALID: 924 case DVB_CA_SLOTSTATE_INVALID:
918 delay = HZ * 60; 925 delay = HZ * 60; /* 60s */
919 if (!(ca->flags & DVB_CA_EN50221_FLAG_IRQ_CAMCHANGE)) { 926 if (!(ca->flags & DVB_CA_EN50221_FLAG_IRQ_CAMCHANGE))
920 delay = HZ / 10; 927 delay = HZ / 10; /* 100ms */
921 }
922 break; 928 break;
923 929
924 case DVB_CA_SLOTSTATE_UNINITIALISED: 930 case DVB_CA_SLOTSTATE_UNINITIALISED:
@@ -926,19 +932,17 @@ static void dvb_ca_en50221_thread_update_delay(struct dvb_ca_private *ca)
926 case DVB_CA_SLOTSTATE_VALIDATE: 932 case DVB_CA_SLOTSTATE_VALIDATE:
927 case DVB_CA_SLOTSTATE_WAITFR: 933 case DVB_CA_SLOTSTATE_WAITFR:
928 case DVB_CA_SLOTSTATE_LINKINIT: 934 case DVB_CA_SLOTSTATE_LINKINIT:
929 delay = HZ / 10; 935 delay = HZ / 10; /* 100ms */
930 break; 936 break;
931 937
932 case DVB_CA_SLOTSTATE_RUNNING: 938 case DVB_CA_SLOTSTATE_RUNNING:
933 delay = HZ * 60; 939 delay = HZ * 60; /* 60s */
934 if (!(ca->flags & DVB_CA_EN50221_FLAG_IRQ_CAMCHANGE)) { 940 if (!(ca->flags & DVB_CA_EN50221_FLAG_IRQ_CAMCHANGE))
935 delay = HZ / 10; 941 delay = HZ / 10; /* 100ms */
936 }
937 if (ca->open) { 942 if (ca->open) {
938 if ((!ca->slot_info[slot].da_irq_supported) || 943 if ((!ca->slot_info[slot].da_irq_supported) ||
939 (!(ca->flags & DVB_CA_EN50221_FLAG_IRQ_DA))) { 944 (!(ca->flags & DVB_CA_EN50221_FLAG_IRQ_DA)))
940 delay = HZ / 10; 945 delay = HZ / 10; /* 100ms */
941 }
942 } 946 }
943 break; 947 break;
944 } 948 }
diff --git a/drivers/media/dvb/dvb-usb/Kconfig b/drivers/media/dvb/dvb-usb/Kconfig
index 4c1cff9feb2e..cf4584e48b6d 100644
--- a/drivers/media/dvb/dvb-usb/Kconfig
+++ b/drivers/media/dvb/dvb-usb/Kconfig
@@ -1,6 +1,7 @@
1config DVB_USB 1config DVB_USB
2 tristate "Support for various USB DVB devices" 2 tristate "Support for various USB DVB devices"
3 depends on DVB_CORE && USB && I2C 3 depends on DVB_CORE && USB && I2C
4 depends on HOTPLUG # due to FW_LOADER
4 select FW_LOADER 5 select FW_LOADER
5 help 6 help
6 By enabling this you will be able to choose the various supported 7 By enabling this you will be able to choose the various supported
diff --git a/drivers/media/dvb/frontends/Kconfig b/drivers/media/dvb/frontends/Kconfig
index 6d2384605927..c20553c4da1f 100644
--- a/drivers/media/dvb/frontends/Kconfig
+++ b/drivers/media/dvb/frontends/Kconfig
@@ -30,7 +30,7 @@ config DVB_CX24123
30 A DVB-S tuner module. Say Y when you want to support this frontend. 30 A DVB-S tuner module. Say Y when you want to support this frontend.
31 31
32config DVB_MT312 32config DVB_MT312
33 tristate "Zarlink VP310/MT312 based" 33 tristate "Zarlink VP310/MT312/ZL10313 based"
34 depends on DVB_CORE && I2C 34 depends on DVB_CORE && I2C
35 default m if DVB_FE_CUSTOMISE 35 default m if DVB_FE_CUSTOMISE
36 help 36 help
@@ -97,7 +97,7 @@ comment "DVB-T (terrestrial) frontends"
97 97
98config DVB_SP8870 98config DVB_SP8870
99 tristate "Spase sp8870 based" 99 tristate "Spase sp8870 based"
100 depends on DVB_CORE && I2C 100 depends on DVB_CORE && I2C && HOTPLUG
101 default m if DVB_FE_CUSTOMISE 101 default m if DVB_FE_CUSTOMISE
102 select FW_LOADER 102 select FW_LOADER
103 help 103 help
@@ -110,7 +110,7 @@ config DVB_SP8870
110 110
111config DVB_SP887X 111config DVB_SP887X
112 tristate "Spase sp887x based" 112 tristate "Spase sp887x based"
113 depends on DVB_CORE && I2C 113 depends on DVB_CORE && I2C && HOTPLUG
114 default m if DVB_FE_CUSTOMISE 114 default m if DVB_FE_CUSTOMISE
115 select FW_LOADER 115 select FW_LOADER
116 help 116 help
@@ -144,7 +144,7 @@ config DVB_L64781
144 144
145config DVB_TDA1004X 145config DVB_TDA1004X
146 tristate "Philips TDA10045H/TDA10046H based" 146 tristate "Philips TDA10045H/TDA10046H based"
147 depends on DVB_CORE && I2C 147 depends on DVB_CORE && I2C && HOTPLUG
148 default m if DVB_FE_CUSTOMISE 148 default m if DVB_FE_CUSTOMISE
149 select FW_LOADER 149 select FW_LOADER
150 help 150 help
@@ -211,7 +211,7 @@ config DVB_DIB7000P
211 211
212config DVB_TDA10048 212config DVB_TDA10048
213 tristate "Philips TDA10048HN based" 213 tristate "Philips TDA10048HN based"
214 depends on DVB_CORE && I2C 214 depends on DVB_CORE && I2C && HOTPLUG
215 default m if DVB_FE_CUSTOMISE 215 default m if DVB_FE_CUSTOMISE
216 select FW_LOADER 216 select FW_LOADER
217 help 217 help
@@ -253,7 +253,7 @@ comment "ATSC (North American/Korean Terrestrial/Cable DTV) frontends"
253 253
254config DVB_NXT200X 254config DVB_NXT200X
255 tristate "NxtWave Communications NXT2002/NXT2004 based" 255 tristate "NxtWave Communications NXT2002/NXT2004 based"
256 depends on DVB_CORE && I2C 256 depends on DVB_CORE && I2C && HOTPLUG
257 default m if DVB_FE_CUSTOMISE 257 default m if DVB_FE_CUSTOMISE
258 select FW_LOADER 258 select FW_LOADER
259 help 259 help
@@ -268,7 +268,7 @@ config DVB_NXT200X
268 268
269config DVB_OR51211 269config DVB_OR51211
270 tristate "Oren OR51211 based" 270 tristate "Oren OR51211 based"
271 depends on DVB_CORE && I2C 271 depends on DVB_CORE && I2C && HOTPLUG
272 default m if DVB_FE_CUSTOMISE 272 default m if DVB_FE_CUSTOMISE
273 select FW_LOADER 273 select FW_LOADER
274 help 274 help
@@ -281,7 +281,7 @@ config DVB_OR51211
281 281
282config DVB_OR51132 282config DVB_OR51132
283 tristate "Oren OR51132 based" 283 tristate "Oren OR51132 based"
284 depends on DVB_CORE && I2C 284 depends on DVB_CORE && I2C && HOTPLUG
285 default m if DVB_FE_CUSTOMISE 285 default m if DVB_FE_CUSTOMISE
286 select FW_LOADER 286 select FW_LOADER
287 help 287 help
@@ -297,7 +297,7 @@ config DVB_OR51132
297 297
298config DVB_BCM3510 298config DVB_BCM3510
299 tristate "Broadcom BCM3510" 299 tristate "Broadcom BCM3510"
300 depends on DVB_CORE && I2C 300 depends on DVB_CORE && I2C && HOTPLUG
301 default m if DVB_FE_CUSTOMISE 301 default m if DVB_FE_CUSTOMISE
302 select FW_LOADER 302 select FW_LOADER
303 help 303 help
diff --git a/drivers/media/dvb/frontends/itd1000.c b/drivers/media/dvb/frontends/itd1000.c
index 04c562ccf990..600dad6b41ea 100644
--- a/drivers/media/dvb/frontends/itd1000.c
+++ b/drivers/media/dvb/frontends/itd1000.c
@@ -195,7 +195,7 @@ static void itd1000_set_vco(struct itd1000_state *state, u32 freq_khz)
195 } 195 }
196} 196}
197 197
198struct { 198static const struct {
199 u32 freq; 199 u32 freq;
200 u8 values[10]; /* RFTR, RFST1 - RFST9 */ 200 u8 values[10]; /* RFTR, RFST1 - RFST9 */
201} itd1000_fre_values[] = { 201} itd1000_fre_values[] = {
diff --git a/drivers/media/dvb/frontends/mt312.c b/drivers/media/dvb/frontends/mt312.c
index 081ca3398c76..5ac9b15920f8 100644
--- a/drivers/media/dvb/frontends/mt312.c
+++ b/drivers/media/dvb/frontends/mt312.c
@@ -737,7 +737,7 @@ static void mt312_release(struct dvb_frontend *fe)
737} 737}
738 738
739#define MT312_SYS_CLK 90000000UL /* 90 MHz */ 739#define MT312_SYS_CLK 90000000UL /* 90 MHz */
740static struct dvb_frontend_ops vp310_mt312_ops = { 740static struct dvb_frontend_ops mt312_ops = {
741 741
742 .info = { 742 .info = {
743 .name = "Zarlink ???? DVB-S", 743 .name = "Zarlink ???? DVB-S",
@@ -776,7 +776,7 @@ static struct dvb_frontend_ops vp310_mt312_ops = {
776 .set_voltage = mt312_set_voltage, 776 .set_voltage = mt312_set_voltage,
777}; 777};
778 778
779struct dvb_frontend *vp310_mt312_attach(const struct mt312_config *config, 779struct dvb_frontend *mt312_attach(const struct mt312_config *config,
780 struct i2c_adapter *i2c) 780 struct i2c_adapter *i2c)
781{ 781{
782 struct mt312_state *state = NULL; 782 struct mt312_state *state = NULL;
@@ -795,7 +795,7 @@ struct dvb_frontend *vp310_mt312_attach(const struct mt312_config *config,
795 goto error; 795 goto error;
796 796
797 /* create dvb_frontend */ 797 /* create dvb_frontend */
798 memcpy(&state->frontend.ops, &vp310_mt312_ops, 798 memcpy(&state->frontend.ops, &mt312_ops,
799 sizeof(struct dvb_frontend_ops)); 799 sizeof(struct dvb_frontend_ops));
800 state->frontend.demodulator_priv = state; 800 state->frontend.demodulator_priv = state;
801 801
@@ -827,12 +827,13 @@ error:
827 kfree(state); 827 kfree(state);
828 return NULL; 828 return NULL;
829} 829}
830EXPORT_SYMBOL(vp310_mt312_attach); 830EXPORT_SYMBOL(mt312_attach);
831 831
832module_param(debug, int, 0644); 832module_param(debug, int, 0644);
833MODULE_PARM_DESC(debug, "Turn on/off frontend debugging (default:off)."); 833MODULE_PARM_DESC(debug, "Turn on/off frontend debugging (default:off).");
834 834
835MODULE_DESCRIPTION("Zarlink VP310/MT312/ZL10313 DVB-S Demodulator driver"); 835MODULE_DESCRIPTION("Zarlink VP310/MT312/ZL10313 DVB-S Demodulator driver");
836MODULE_AUTHOR("Andreas Oberritter <obi@linuxtv.org>"); 836MODULE_AUTHOR("Andreas Oberritter <obi@linuxtv.org>");
837MODULE_AUTHOR("Matthias Schwarzott <zzam@gentoo.org>");
837MODULE_LICENSE("GPL"); 838MODULE_LICENSE("GPL");
838 839
diff --git a/drivers/media/dvb/frontends/mt312.h b/drivers/media/dvb/frontends/mt312.h
index de796eab3911..29e3bb5496b8 100644
--- a/drivers/media/dvb/frontends/mt312.h
+++ b/drivers/media/dvb/frontends/mt312.h
@@ -37,10 +37,10 @@ struct mt312_config {
37}; 37};
38 38
39#if defined(CONFIG_DVB_MT312) || (defined(CONFIG_DVB_MT312_MODULE) && defined(MODULE)) 39#if defined(CONFIG_DVB_MT312) || (defined(CONFIG_DVB_MT312_MODULE) && defined(MODULE))
40struct dvb_frontend *vp310_mt312_attach(const struct mt312_config *config, 40struct dvb_frontend *mt312_attach(const struct mt312_config *config,
41 struct i2c_adapter *i2c); 41 struct i2c_adapter *i2c);
42#else 42#else
43static inline struct dvb_frontend *vp310_mt312_attach( 43static inline struct dvb_frontend *mt312_attach(
44 const struct mt312_config *config, struct i2c_adapter *i2c) 44 const struct mt312_config *config, struct i2c_adapter *i2c)
45{ 45{
46 printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__); 46 printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__);
diff --git a/drivers/media/dvb/ttpci/Kconfig b/drivers/media/dvb/ttpci/Kconfig
index ae882432dd3d..d4339b1b3b68 100644
--- a/drivers/media/dvb/ttpci/Kconfig
+++ b/drivers/media/dvb/ttpci/Kconfig
@@ -5,6 +5,7 @@ config TTPCI_EEPROM
5config DVB_AV7110 5config DVB_AV7110
6 tristate "AV7110 cards" 6 tristate "AV7110 cards"
7 depends on DVB_CORE && PCI && I2C 7 depends on DVB_CORE && PCI && I2C
8 depends on HOTPLUG
8 select FW_LOADER if !DVB_AV7110_FIRMWARE 9 select FW_LOADER if !DVB_AV7110_FIRMWARE
9 select TTPCI_EEPROM 10 select TTPCI_EEPROM
10 select VIDEO_SAA7146_VV 11 select VIDEO_SAA7146_VV
@@ -123,6 +124,7 @@ config DVB_BUDGET_AV
123 depends on DVB_BUDGET_CORE && I2C 124 depends on DVB_BUDGET_CORE && I2C
124 select VIDEO_SAA7146_VV 125 select VIDEO_SAA7146_VV
125 depends on VIDEO_DEV # dependencies of VIDEO_SAA7146_VV 126 depends on VIDEO_DEV # dependencies of VIDEO_SAA7146_VV
127 depends on HOTPLUG # dependency of FW_LOADER
126 select DVB_PLL if !DVB_FE_CUSTOMISE 128 select DVB_PLL if !DVB_FE_CUSTOMISE
127 select DVB_STV0299 if !DVB_FE_CUSTOMISE 129 select DVB_STV0299 if !DVB_FE_CUSTOMISE
128 select DVB_TDA1004X if !DVB_FE_CUSTOMISE 130 select DVB_TDA1004X if !DVB_FE_CUSTOMISE
diff --git a/drivers/media/dvb/ttusb-dec/Kconfig b/drivers/media/dvb/ttusb-dec/Kconfig
index 83611012ef34..0712899e39a4 100644
--- a/drivers/media/dvb/ttusb-dec/Kconfig
+++ b/drivers/media/dvb/ttusb-dec/Kconfig
@@ -1,6 +1,7 @@
1config DVB_TTUSB_DEC 1config DVB_TTUSB_DEC
2 tristate "Technotrend/Hauppauge USB DEC devices" 2 tristate "Technotrend/Hauppauge USB DEC devices"
3 depends on DVB_CORE && USB 3 depends on DVB_CORE && USB
4 depends on HOTPLUG # due to FW_LOADER
4 select FW_LOADER 5 select FW_LOADER
5 select CRC32 6 select CRC32
6 help 7 help
diff --git a/drivers/media/video/Kconfig b/drivers/media/video/Kconfig
index fe743aa7f645..89d8d37838a3 100644
--- a/drivers/media/video/Kconfig
+++ b/drivers/media/video/Kconfig
@@ -44,6 +44,10 @@ config VIDEO_TVEEPROM
44 tristate 44 tristate
45 depends on I2C 45 depends on I2C
46 46
47config VIDEO_TUNER
48 tristate
49 depends on MEDIA_TUNER
50
47# 51#
48# Multimedia Video device configuration 52# Multimedia Video device configuration
49# 53#
@@ -690,7 +694,7 @@ config VIDEO_MXB
690 tristate "Siemens-Nixdorf 'Multimedia eXtension Board'" 694 tristate "Siemens-Nixdorf 'Multimedia eXtension Board'"
691 depends on PCI && VIDEO_V4L1 && I2C 695 depends on PCI && VIDEO_V4L1 && I2C
692 select VIDEO_SAA7146_VV 696 select VIDEO_SAA7146_VV
693 select MEDIA_TUNER 697 select VIDEO_TUNER
694 select VIDEO_SAA7111 if VIDEO_HELPER_CHIPS_AUTO 698 select VIDEO_SAA7111 if VIDEO_HELPER_CHIPS_AUTO
695 select VIDEO_TDA9840 if VIDEO_HELPER_CHIPS_AUTO 699 select VIDEO_TDA9840 if VIDEO_HELPER_CHIPS_AUTO
696 select VIDEO_TEA6415C if VIDEO_HELPER_CHIPS_AUTO 700 select VIDEO_TEA6415C if VIDEO_HELPER_CHIPS_AUTO
@@ -906,7 +910,7 @@ config SOC_CAMERA
906 910
907config SOC_CAMERA_MT9M001 911config SOC_CAMERA_MT9M001
908 tristate "mt9m001 support" 912 tristate "mt9m001 support"
909 depends on SOC_CAMERA 913 depends on SOC_CAMERA && I2C
910 select GPIO_PCA953X if MT9M001_PCA9536_SWITCH 914 select GPIO_PCA953X if MT9M001_PCA9536_SWITCH
911 help 915 help
912 This driver supports MT9M001 cameras from Micron, monochrome 916 This driver supports MT9M001 cameras from Micron, monochrome
@@ -921,7 +925,7 @@ config MT9M001_PCA9536_SWITCH
921 925
922config SOC_CAMERA_MT9V022 926config SOC_CAMERA_MT9V022
923 tristate "mt9v022 support" 927 tristate "mt9v022 support"
924 depends on SOC_CAMERA 928 depends on SOC_CAMERA && I2C
925 select GPIO_PCA953X if MT9V022_PCA9536_SWITCH 929 select GPIO_PCA953X if MT9V022_PCA9536_SWITCH
926 help 930 help
927 This driver supports MT9V022 cameras from Micron 931 This driver supports MT9V022 cameras from Micron
diff --git a/drivers/media/video/Makefile b/drivers/media/video/Makefile
index a352c6e31f0c..dff0d6abe917 100644
--- a/drivers/media/video/Makefile
+++ b/drivers/media/video/Makefile
@@ -84,7 +84,7 @@ obj-$(CONFIG_VIDEO_HEXIUM_GEMINI) += hexium_gemini.o
84obj-$(CONFIG_VIDEO_DPC) += dpc7146.o 84obj-$(CONFIG_VIDEO_DPC) += dpc7146.o
85obj-$(CONFIG_TUNER_3036) += tuner-3036.o 85obj-$(CONFIG_TUNER_3036) += tuner-3036.o
86 86
87obj-$(CONFIG_MEDIA_TUNER) += tuner.o 87obj-$(CONFIG_VIDEO_TUNER) += tuner.o
88 88
89obj-$(CONFIG_VIDEOBUF_GEN) += videobuf-core.o 89obj-$(CONFIG_VIDEOBUF_GEN) += videobuf-core.o
90obj-$(CONFIG_VIDEOBUF_DMA_SG) += videobuf-dma-sg.o 90obj-$(CONFIG_VIDEOBUF_DMA_SG) += videobuf-dma-sg.o
diff --git a/drivers/media/video/au0828/Kconfig b/drivers/media/video/au0828/Kconfig
index cab277fafa63..def10d086373 100644
--- a/drivers/media/video/au0828/Kconfig
+++ b/drivers/media/video/au0828/Kconfig
@@ -1,8 +1,9 @@
1 1
2config VIDEO_AU0828 2config VIDEO_AU0828
3 tristate "Auvitek AU0828 support" 3 tristate "Auvitek AU0828 support"
4 depends on VIDEO_DEV && I2C && INPUT && DVB_CORE 4 depends on VIDEO_DEV && I2C && INPUT && DVB_CORE && USB
5 select I2C_ALGOBIT 5 select I2C_ALGOBIT
6 select VIDEO_TVEEPROM
6 select DVB_AU8522 if !DVB_FE_CUSTOMIZE 7 select DVB_AU8522 if !DVB_FE_CUSTOMIZE
7 select MEDIA_TUNER_XC5000 if !DVB_FE_CUSTOMIZE 8 select MEDIA_TUNER_XC5000 if !DVB_FE_CUSTOMIZE
8 ---help--- 9 ---help---
diff --git a/drivers/media/video/au0828/au0828-dvb.c b/drivers/media/video/au0828/au0828-dvb.c
index 1371b4e4b5f1..c86a5f17eca8 100644
--- a/drivers/media/video/au0828/au0828-dvb.c
+++ b/drivers/media/video/au0828/au0828-dvb.c
@@ -337,12 +337,10 @@ int au0828_dvb_register(struct au0828_dev *dev)
337 dvb->frontend = dvb_attach(au8522_attach, 337 dvb->frontend = dvb_attach(au8522_attach,
338 &hauppauge_hvr950q_config, 338 &hauppauge_hvr950q_config,
339 &dev->i2c_adap); 339 &dev->i2c_adap);
340 if (dvb->frontend != NULL) { 340 if (dvb->frontend != NULL)
341 hauppauge_hvr950q_tunerconfig.priv = dev;
342 dvb_attach(xc5000_attach, dvb->frontend, 341 dvb_attach(xc5000_attach, dvb->frontend,
343 &dev->i2c_adap, 342 &dev->i2c_adap,
344 &hauppauge_hvr950q_tunerconfig); 343 &hauppauge_hvr950q_tunerconfig, dev);
345 }
346 break; 344 break;
347 default: 345 default:
348 printk(KERN_WARNING "The frontend of your DVB/ATSC card " 346 printk(KERN_WARNING "The frontend of your DVB/ATSC card "
diff --git a/drivers/media/video/bt8xx/Kconfig b/drivers/media/video/bt8xx/Kconfig
index 7431ef6de9f1..24a34fc1f2b3 100644
--- a/drivers/media/video/bt8xx/Kconfig
+++ b/drivers/media/video/bt8xx/Kconfig
@@ -1,12 +1,13 @@
1config VIDEO_BT848 1config VIDEO_BT848
2 tristate "BT848 Video For Linux" 2 tristate "BT848 Video For Linux"
3 depends on VIDEO_DEV && PCI && I2C && VIDEO_V4L2 && INPUT 3 depends on VIDEO_DEV && PCI && I2C && VIDEO_V4L2 && INPUT
4 depends on HOTPLUG # due to FW_LOADER
4 select I2C_ALGOBIT 5 select I2C_ALGOBIT
5 select FW_LOADER 6 select FW_LOADER
6 select VIDEO_BTCX 7 select VIDEO_BTCX
7 select VIDEOBUF_DMA_SG 8 select VIDEOBUF_DMA_SG
8 select VIDEO_IR 9 select VIDEO_IR
9 select MEDIA_TUNER 10 select VIDEO_TUNER
10 select VIDEO_TVEEPROM 11 select VIDEO_TVEEPROM
11 select VIDEO_MSP3400 if VIDEO_HELPER_CHIPS_AUTO 12 select VIDEO_MSP3400 if VIDEO_HELPER_CHIPS_AUTO
12 select VIDEO_TVAUDIO if VIDEO_HELPER_CHIPS_AUTO 13 select VIDEO_TVAUDIO if VIDEO_HELPER_CHIPS_AUTO
diff --git a/drivers/media/video/cx18/Kconfig b/drivers/media/video/cx18/Kconfig
index acc4b47f1d1d..5f942690570c 100644
--- a/drivers/media/video/cx18/Kconfig
+++ b/drivers/media/video/cx18/Kconfig
@@ -1,14 +1,17 @@
1config VIDEO_CX18 1config VIDEO_CX18
2 tristate "Conexant cx23418 MPEG encoder support" 2 tristate "Conexant cx23418 MPEG encoder support"
3 depends on VIDEO_V4L2 && DVB_CORE && PCI && I2C && EXPERIMENTAL 3 depends on VIDEO_V4L2 && DVB_CORE && PCI && I2C && EXPERIMENTAL
4 depends on INPUT # due to VIDEO_IR
5 depends on HOTPLUG # due to FW_LOADER
4 select I2C_ALGOBIT 6 select I2C_ALGOBIT
5 select FW_LOADER 7 select FW_LOADER
6 select VIDEO_IR 8 select VIDEO_IR
7 select MEDIA_TUNER 9 select VIDEO_TUNER
8 select VIDEO_TVEEPROM 10 select VIDEO_TVEEPROM
9 select VIDEO_CX2341X 11 select VIDEO_CX2341X
10 select VIDEO_CS5345 12 select VIDEO_CS5345
11 select DVB_S5H1409 13 select DVB_S5H1409
14 select MEDIA_TUNER_MXL5005S
12 ---help--- 15 ---help---
13 This is a video4linux driver for Conexant cx23418 based 16 This is a video4linux driver for Conexant cx23418 based
14 PCI combo video recorder devices. 17 PCI combo video recorder devices.
diff --git a/drivers/media/video/cx18/cx18-cards.c b/drivers/media/video/cx18/cx18-cards.c
index f5e3ba1f5354..553adbf2cd44 100644
--- a/drivers/media/video/cx18/cx18-cards.c
+++ b/drivers/media/video/cx18/cx18-cards.c
@@ -47,11 +47,12 @@ static struct cx18_card_tuner_i2c cx18_i2c_std = {
47static const struct cx18_card cx18_card_hvr1600_esmt = { 47static const struct cx18_card cx18_card_hvr1600_esmt = {
48 .type = CX18_CARD_HVR_1600_ESMT, 48 .type = CX18_CARD_HVR_1600_ESMT,
49 .name = "Hauppauge HVR-1600", 49 .name = "Hauppauge HVR-1600",
50 .comment = "DVB & VBI are not yet supported\n", 50 .comment = "VBI is not yet supported\n",
51 .v4l2_capabilities = CX18_CAP_ENCODER, 51 .v4l2_capabilities = CX18_CAP_ENCODER,
52 .hw_audio_ctrl = CX18_HW_CX23418, 52 .hw_audio_ctrl = CX18_HW_CX23418,
53 .hw_muxer = CX18_HW_CS5345, 53 .hw_muxer = CX18_HW_CS5345,
54 .hw_all = CX18_HW_TVEEPROM | CX18_HW_TUNER | CX18_HW_CS5345, 54 .hw_all = CX18_HW_TVEEPROM | CX18_HW_TUNER |
55 CX18_HW_CS5345 | CX18_HW_DVB,
55 .video_inputs = { 56 .video_inputs = {
56 { CX18_CARD_INPUT_VID_TUNER, 0, CX23418_COMPOSITE7 }, 57 { CX18_CARD_INPUT_VID_TUNER, 0, CX23418_COMPOSITE7 },
57 { CX18_CARD_INPUT_SVIDEO1, 1, CX23418_SVIDEO1 }, 58 { CX18_CARD_INPUT_SVIDEO1, 1, CX23418_SVIDEO1 },
@@ -86,11 +87,12 @@ static const struct cx18_card cx18_card_hvr1600_esmt = {
86static const struct cx18_card cx18_card_hvr1600_samsung = { 87static const struct cx18_card cx18_card_hvr1600_samsung = {
87 .type = CX18_CARD_HVR_1600_SAMSUNG, 88 .type = CX18_CARD_HVR_1600_SAMSUNG,
88 .name = "Hauppauge HVR-1600 (Preproduction)", 89 .name = "Hauppauge HVR-1600 (Preproduction)",
89 .comment = "DVB & VBI are not yet supported\n", 90 .comment = "VBI is not yet supported\n",
90 .v4l2_capabilities = CX18_CAP_ENCODER, 91 .v4l2_capabilities = CX18_CAP_ENCODER,
91 .hw_audio_ctrl = CX18_HW_CX23418, 92 .hw_audio_ctrl = CX18_HW_CX23418,
92 .hw_muxer = CX18_HW_CS5345, 93 .hw_muxer = CX18_HW_CS5345,
93 .hw_all = CX18_HW_TVEEPROM | CX18_HW_TUNER | CX18_HW_CS5345, 94 .hw_all = CX18_HW_TVEEPROM | CX18_HW_TUNER |
95 CX18_HW_CS5345 | CX18_HW_DVB,
94 .video_inputs = { 96 .video_inputs = {
95 { CX18_CARD_INPUT_VID_TUNER, 0, CX23418_COMPOSITE7 }, 97 { CX18_CARD_INPUT_VID_TUNER, 0, CX23418_COMPOSITE7 },
96 { CX18_CARD_INPUT_SVIDEO1, 1, CX23418_SVIDEO1 }, 98 { CX18_CARD_INPUT_SVIDEO1, 1, CX23418_SVIDEO1 },
@@ -134,14 +136,15 @@ static const struct cx18_card_pci_info cx18_pci_h900[] = {
134static const struct cx18_card cx18_card_h900 = { 136static const struct cx18_card cx18_card_h900 = {
135 .type = CX18_CARD_COMPRO_H900, 137 .type = CX18_CARD_COMPRO_H900,
136 .name = "Compro VideoMate H900", 138 .name = "Compro VideoMate H900",
137 .comment = "Not yet supported!\n", 139 .comment = "DVB & VBI are not yet supported\n",
138 .v4l2_capabilities = 0, 140 .v4l2_capabilities = CX18_CAP_ENCODER,
139 .hw_audio_ctrl = CX18_HW_CX23418, 141 .hw_audio_ctrl = CX18_HW_CX23418,
140 .hw_all = CX18_HW_TUNER, 142 .hw_all = CX18_HW_TUNER,
141 .video_inputs = { 143 .video_inputs = {
142 { CX18_CARD_INPUT_VID_TUNER, 0, CX23418_COMPOSITE7 }, 144 { CX18_CARD_INPUT_VID_TUNER, 0, CX23418_COMPOSITE2 },
143 { CX18_CARD_INPUT_SVIDEO1, 1, CX23418_SVIDEO1 }, 145 { CX18_CARD_INPUT_SVIDEO1, 1,
144 { CX18_CARD_INPUT_COMPOSITE1, 1, CX23418_COMPOSITE3 }, 146 CX23418_SVIDEO_LUMA3 | CX23418_SVIDEO_CHROMA4 },
147 { CX18_CARD_INPUT_COMPOSITE1, 1, CX23418_COMPOSITE1 },
145 }, 148 },
146 .audio_inputs = { 149 .audio_inputs = {
147 { CX18_CARD_INPUT_AUD_TUNER, 150 { CX18_CARD_INPUT_AUD_TUNER,
@@ -163,6 +166,7 @@ static const struct cx18_card cx18_card_h900 = {
163 .tune_lane = 0, 166 .tune_lane = 0,
164 .initial_emrs = 0, 167 .initial_emrs = 0,
165 }, 168 },
169 .xceive_pin = 15,
166 .pci_list = cx18_pci_h900, 170 .pci_list = cx18_pci_h900,
167 .i2c = &cx18_i2c_std, 171 .i2c = &cx18_i2c_std,
168}; 172};
@@ -200,8 +204,6 @@ static const struct cx18_card cx18_card_mpc718 = {
200 /* XC3028 tuner */ 204 /* XC3028 tuner */
201 { .std = V4L2_STD_ALL, .tuner = TUNER_XC2028 }, 205 { .std = V4L2_STD_ALL, .tuner = TUNER_XC2028 },
202 }, 206 },
203 /* tuner reset */
204 .gpio_init = { .direction = 0x1000, .initial_value = 0x1000 },
205 .ddr = { 207 .ddr = {
206 /* Probably Samsung K4D263238G-VC33 memory */ 208 /* Probably Samsung K4D263238G-VC33 memory */
207 .chip_config = 0x003, 209 .chip_config = 0x003,
@@ -211,6 +213,7 @@ static const struct cx18_card cx18_card_mpc718 = {
211 .tune_lane = 0, 213 .tune_lane = 0,
212 .initial_emrs = 2, 214 .initial_emrs = 2,
213 }, 215 },
216 .xceive_pin = 15,
214 .pci_list = cx18_pci_mpc718, 217 .pci_list = cx18_pci_mpc718,
215 .i2c = &cx18_i2c_std, 218 .i2c = &cx18_i2c_std,
216}; 219};
diff --git a/drivers/media/video/cx18/cx18-cards.h b/drivers/media/video/cx18/cx18-cards.h
index bca249bdd337..bccb67f0db16 100644
--- a/drivers/media/video/cx18/cx18-cards.h
+++ b/drivers/media/video/cx18/cx18-cards.h
@@ -114,8 +114,8 @@ struct cx18_card_pci_info {
114/* The mask is the set of bits used by the operation */ 114/* The mask is the set of bits used by the operation */
115 115
116struct cx18_gpio_init { /* set initial GPIO DIR and OUT values */ 116struct cx18_gpio_init { /* set initial GPIO DIR and OUT values */
117 u16 direction; /* DIR setting. Leave to 0 if no init is needed */ 117 u32 direction; /* DIR setting. Leave to 0 if no init is needed */
118 u16 initial_value; 118 u32 initial_value;
119}; 119};
120 120
121struct cx18_card_tuner { 121struct cx18_card_tuner {
@@ -153,6 +153,7 @@ struct cx18_card {
153 struct cx18_card_audio_input radio_input; 153 struct cx18_card_audio_input radio_input;
154 154
155 /* GPIO card-specific settings */ 155 /* GPIO card-specific settings */
156 u8 xceive_pin; /* XCeive tuner GPIO reset pin */
156 struct cx18_gpio_init gpio_init; 157 struct cx18_gpio_init gpio_init;
157 158
158 struct cx18_card_tuner tuners[CX18_CARD_MAX_TUNERS]; 159 struct cx18_card_tuner tuners[CX18_CARD_MAX_TUNERS];
diff --git a/drivers/media/video/cx18/cx18-driver.c b/drivers/media/video/cx18/cx18-driver.c
index 3f55d47bc4b9..0dd4e0529970 100644
--- a/drivers/media/video/cx18/cx18-driver.c
+++ b/drivers/media/video/cx18/cx18-driver.c
@@ -164,16 +164,6 @@ MODULE_LICENSE("GPL");
164 164
165MODULE_VERSION(CX18_VERSION); 165MODULE_VERSION(CX18_VERSION);
166 166
167int cx18_waitq(wait_queue_head_t *waitq)
168{
169 DEFINE_WAIT(wait);
170
171 prepare_to_wait(waitq, &wait, TASK_INTERRUPTIBLE);
172 schedule();
173 finish_wait(waitq, &wait);
174 return signal_pending(current) ? -EINTR : 0;
175}
176
177/* Generic utility functions */ 167/* Generic utility functions */
178int cx18_msleep_timeout(unsigned int msecs, int intr) 168int cx18_msleep_timeout(unsigned int msecs, int intr)
179{ 169{
@@ -220,13 +210,13 @@ static void cx18_process_eeprom(struct cx18 *cx)
220 210
221 /* Many thanks to Steven Toth from Hauppauge for providing the 211 /* Many thanks to Steven Toth from Hauppauge for providing the
222 model numbers */ 212 model numbers */
213 /* Note: the Samsung memory models cannot be reliably determined
214 from the model number. Use the cardtype module option if you
215 have one of these preproduction models. */
223 switch (tv.model) { 216 switch (tv.model) {
224 case 74000 ... 74099: 217 case 74000 ... 74999:
225 cx->card = cx18_get_card(CX18_CARD_HVR_1600_ESMT); 218 cx->card = cx18_get_card(CX18_CARD_HVR_1600_ESMT);
226 break; 219 break;
227 case 74700 ... 74799:
228 cx->card = cx18_get_card(CX18_CARD_HVR_1600_SAMSUNG);
229 break;
230 case 0: 220 case 0:
231 CX18_ERR("Invalid EEPROM\n"); 221 CX18_ERR("Invalid EEPROM\n");
232 return; 222 return;
@@ -548,6 +538,7 @@ static int cx18_setup_pci(struct cx18 *cx, struct pci_dev *dev,
548 return 0; 538 return 0;
549} 539}
550 540
541#ifdef MODULE
551static u32 cx18_request_module(struct cx18 *cx, u32 hw, 542static u32 cx18_request_module(struct cx18 *cx, u32 hw,
552 const char *name, u32 id) 543 const char *name, u32 id)
553{ 544{
@@ -560,12 +551,14 @@ static u32 cx18_request_module(struct cx18 *cx, u32 hw,
560 CX18_DEBUG_INFO("Loaded module %s\n", name); 551 CX18_DEBUG_INFO("Loaded module %s\n", name);
561 return hw; 552 return hw;
562} 553}
554#endif
563 555
564static void cx18_load_and_init_modules(struct cx18 *cx) 556static void cx18_load_and_init_modules(struct cx18 *cx)
565{ 557{
566 u32 hw = cx->card->hw_all; 558 u32 hw = cx->card->hw_all;
567 int i; 559 int i;
568 560
561#ifdef MODULE
569 /* load modules */ 562 /* load modules */
570#ifndef CONFIG_MEDIA_TUNER 563#ifndef CONFIG_MEDIA_TUNER
571 hw = cx18_request_module(cx, hw, "tuner", CX18_HW_TUNER); 564 hw = cx18_request_module(cx, hw, "tuner", CX18_HW_TUNER);
@@ -573,6 +566,7 @@ static void cx18_load_and_init_modules(struct cx18 *cx)
573#ifndef CONFIG_VIDEO_CS5345 566#ifndef CONFIG_VIDEO_CS5345
574 hw = cx18_request_module(cx, hw, "cs5345", CX18_HW_CS5345); 567 hw = cx18_request_module(cx, hw, "cs5345", CX18_HW_CS5345);
575#endif 568#endif
569#endif
576 570
577 /* check which i2c devices are actually found */ 571 /* check which i2c devices are actually found */
578 for (i = 0; i < 32; i++) { 572 for (i = 0; i < 32; i++) {
@@ -801,7 +795,7 @@ static int __devinit cx18_probe(struct pci_dev *dev,
801 return 0; 795 return 0;
802 796
803free_streams: 797free_streams:
804 cx18_streams_cleanup(cx); 798 cx18_streams_cleanup(cx, 1);
805free_irq: 799free_irq:
806 free_irq(cx->dev->irq, (void *)cx); 800 free_irq(cx->dev->irq, (void *)cx);
807free_i2c: 801free_i2c:
@@ -904,14 +898,13 @@ static void cx18_remove(struct pci_dev *pci_dev)
904 898
905 cx18_halt_firmware(cx); 899 cx18_halt_firmware(cx);
906 900
907 cx18_streams_cleanup(cx); 901 cx18_streams_cleanup(cx, 1);
908 902
909 exit_cx18_i2c(cx); 903 exit_cx18_i2c(cx);
910 904
911 free_irq(cx->dev->irq, (void *)cx); 905 free_irq(cx->dev->irq, (void *)cx);
912 906
913 if (cx->dev) 907 cx18_iounmap(cx);
914 cx18_iounmap(cx);
915 908
916 release_mem_region(cx->base_addr, CX18_MEM_SIZE); 909 release_mem_region(cx->base_addr, CX18_MEM_SIZE);
917 910
diff --git a/drivers/media/video/cx18/cx18-driver.h b/drivers/media/video/cx18/cx18-driver.h
index 2ee939193bb7..a2a6c58d12fe 100644
--- a/drivers/media/video/cx18/cx18-driver.h
+++ b/drivers/media/video/cx18/cx18-driver.h
@@ -444,9 +444,6 @@ extern spinlock_t cx18_cards_lock;
444/* Return non-zero if a signal is pending */ 444/* Return non-zero if a signal is pending */
445int cx18_msleep_timeout(unsigned int msecs, int intr); 445int cx18_msleep_timeout(unsigned int msecs, int intr);
446 446
447/* Wait on queue, returns -EINTR if interrupted */
448int cx18_waitq(wait_queue_head_t *waitq);
449
450/* Read Hauppauge eeprom */ 447/* Read Hauppauge eeprom */
451struct tveeprom; /* forward reference */ 448struct tveeprom; /* forward reference */
452void cx18_read_eeprom(struct cx18 *cx, struct tveeprom *tv); 449void cx18_read_eeprom(struct cx18 *cx, struct tveeprom *tv);
diff --git a/drivers/media/video/cx18/cx18-dvb.c b/drivers/media/video/cx18/cx18-dvb.c
index 65efe69d939a..c9744173f969 100644
--- a/drivers/media/video/cx18/cx18-dvb.c
+++ b/drivers/media/video/cx18/cx18-dvb.c
@@ -24,25 +24,27 @@
24#include "cx18-streams.h" 24#include "cx18-streams.h"
25#include "cx18-cards.h" 25#include "cx18-cards.h"
26#include "s5h1409.h" 26#include "s5h1409.h"
27 27#include "mxl5005s.h"
28/* Wait until the MXL500X driver is merged */
29#ifdef HAVE_MXL500X
30#include "mxl500x.h"
31#endif
32 28
33DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr); 29DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
34 30
35#define CX18_REG_DMUX_NUM_PORT_0_CONTROL 0xd5a000 31#define CX18_REG_DMUX_NUM_PORT_0_CONTROL 0xd5a000
36 32
37#ifdef HAVE_MXL500X 33static struct mxl5005s_config hauppauge_hvr1600_tuner = {
38static struct mxl500x_config hauppauge_hvr1600_tuner = { 34 .i2c_address = 0xC6 >> 1,
39 .delsys = MXL500x_MODE_ATSC, 35 .if_freq = IF_FREQ_5380000HZ,
40 .octf = MXL500x_OCTF_CH, 36 .xtal_freq = CRYSTAL_FREQ_16000000HZ,
41 .xtal_freq = 16000000, 37 .agc_mode = MXL_SINGLE_AGC,
42 .iflo_freq = 5380000, 38 .tracking_filter = MXL_TF_C_H,
43 .ref_freq = 322800000, 39 .rssi_enable = MXL_RSSI_ENABLE,
44 .rssi_ena = MXL_RSSI_ENABLE, 40 .cap_select = MXL_CAP_SEL_ENABLE,
45 .addr = 0xC6 >> 1, 41 .div_out = MXL_DIV_OUT_4,
42 .clock_out = MXL_CLOCK_OUT_DISABLE,
43 .output_load = MXL5005S_IF_OUTPUT_LOAD_200_OHM,
44 .top = MXL5005S_TOP_25P2,
45 .mod_mode = MXL_DIGITAL_MODE,
46 .if_mode = MXL_ZERO_IF,
47 .AgcMasterByte = 0x00,
46}; 48};
47 49
48static struct s5h1409_config hauppauge_hvr1600_config = { 50static struct s5h1409_config hauppauge_hvr1600_config = {
@@ -55,7 +57,6 @@ static struct s5h1409_config hauppauge_hvr1600_config = {
55 .mpeg_timing = S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK 57 .mpeg_timing = S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK
56 58
57}; 59};
58#endif
59 60
60static int dvb_register(struct cx18_stream *stream); 61static int dvb_register(struct cx18_stream *stream);
61 62
@@ -252,21 +253,18 @@ static int dvb_register(struct cx18_stream *stream)
252 int ret = 0; 253 int ret = 0;
253 254
254 switch (cx->card->type) { 255 switch (cx->card->type) {
255/* Wait until the MXL500X driver is merged */
256#ifdef HAVE_MXL500X
257 case CX18_CARD_HVR_1600_ESMT: 256 case CX18_CARD_HVR_1600_ESMT:
258 case CX18_CARD_HVR_1600_SAMSUNG: 257 case CX18_CARD_HVR_1600_SAMSUNG:
259 dvb->fe = dvb_attach(s5h1409_attach, 258 dvb->fe = dvb_attach(s5h1409_attach,
260 &hauppauge_hvr1600_config, 259 &hauppauge_hvr1600_config,
261 &cx->i2c_adap[0]); 260 &cx->i2c_adap[0]);
262 if (dvb->fe != NULL) { 261 if (dvb->fe != NULL) {
263 dvb_attach(mxl500x_attach, dvb->fe, 262 dvb_attach(mxl5005s_attach, dvb->fe,
264 &hauppauge_hvr1600_tuner, 263 &cx->i2c_adap[0],
265 &cx->i2c_adap[0]); 264 &hauppauge_hvr1600_tuner);
266 ret = 0; 265 ret = 0;
267 } 266 }
268 break; 267 break;
269#endif
270 default: 268 default:
271 /* No Digital Tv Support */ 269 /* No Digital Tv Support */
272 break; 270 break;
diff --git a/drivers/media/video/cx18/cx18-fileops.c b/drivers/media/video/cx18/cx18-fileops.c
index 69303065a294..0b3141db174b 100644
--- a/drivers/media/video/cx18/cx18-fileops.c
+++ b/drivers/media/video/cx18/cx18-fileops.c
@@ -39,7 +39,7 @@
39 associated VBI streams are also automatically claimed. 39 associated VBI streams are also automatically claimed.
40 Possible error returns: -EBUSY if someone else has claimed 40 Possible error returns: -EBUSY if someone else has claimed
41 the stream or 0 on success. */ 41 the stream or 0 on success. */
42int cx18_claim_stream(struct cx18_open_id *id, int type) 42static int cx18_claim_stream(struct cx18_open_id *id, int type)
43{ 43{
44 struct cx18 *cx = id->cx; 44 struct cx18 *cx = id->cx;
45 struct cx18_stream *s = &cx->streams[type]; 45 struct cx18_stream *s = &cx->streams[type];
@@ -87,7 +87,7 @@ int cx18_claim_stream(struct cx18_open_id *id, int type)
87 87
88/* This function releases a previously claimed stream. It will take into 88/* This function releases a previously claimed stream. It will take into
89 account associated VBI streams. */ 89 account associated VBI streams. */
90void cx18_release_stream(struct cx18_stream *s) 90static void cx18_release_stream(struct cx18_stream *s)
91{ 91{
92 struct cx18 *cx = s->cx; 92 struct cx18 *cx = s->cx;
93 struct cx18_stream *s_vbi; 93 struct cx18_stream *s_vbi;
@@ -662,6 +662,8 @@ int cx18_v4l2_open(struct inode *inode, struct file *filp)
662 for (x = 0; cx == NULL && x < cx18_cards_active; x++) { 662 for (x = 0; cx == NULL && x < cx18_cards_active; x++) {
663 /* find out which stream this open was on */ 663 /* find out which stream this open was on */
664 for (y = 0; y < CX18_MAX_STREAMS; y++) { 664 for (y = 0; y < CX18_MAX_STREAMS; y++) {
665 if (cx18_cards[x] == NULL)
666 continue;
665 s = &cx18_cards[x]->streams[y]; 667 s = &cx18_cards[x]->streams[y];
666 if (s->v4l2dev && s->v4l2dev->minor == minor) { 668 if (s->v4l2dev && s->v4l2dev->minor == minor) {
667 cx = cx18_cards[x]; 669 cx = cx18_cards[x];
diff --git a/drivers/media/video/cx18/cx18-fileops.h b/drivers/media/video/cx18/cx18-fileops.h
index 16cdafbd24c5..46da0282fc7d 100644
--- a/drivers/media/video/cx18/cx18-fileops.h
+++ b/drivers/media/video/cx18/cx18-fileops.h
@@ -34,12 +34,3 @@ void cx18_stop_capture(struct cx18_open_id *id, int gop_end);
34void cx18_mute(struct cx18 *cx); 34void cx18_mute(struct cx18 *cx);
35void cx18_unmute(struct cx18 *cx); 35void cx18_unmute(struct cx18 *cx);
36 36
37/* Utilities */
38
39/* Try to claim a stream for the filehandle. Return 0 on success,
40 -EBUSY if stream already claimed. Once a stream is claimed, it
41 remains claimed until the associated filehandle is closed. */
42int cx18_claim_stream(struct cx18_open_id *id, int type);
43
44/* Release a previously claimed stream. */
45void cx18_release_stream(struct cx18_stream *s);
diff --git a/drivers/media/video/cx18/cx18-gpio.c b/drivers/media/video/cx18/cx18-gpio.c
index 19253e6b8673..bb8bc86086d0 100644
--- a/drivers/media/video/cx18/cx18-gpio.c
+++ b/drivers/media/video/cx18/cx18-gpio.c
@@ -35,6 +35,9 @@
35#define CX18_REG_GPIO_OUT2 0xc78104 35#define CX18_REG_GPIO_OUT2 0xc78104
36#define CX18_REG_GPIO_DIR2 0xc7810c 36#define CX18_REG_GPIO_DIR2 0xc7810c
37 37
38static u32 gpio_dir;
39static u32 gpio_val;
40
38/* 41/*
39 * HVR-1600 GPIO pins, courtesy of Hauppauge: 42 * HVR-1600 GPIO pins, courtesy of Hauppauge:
40 * 43 *
@@ -44,31 +47,53 @@
44 * gpio13: cs5345 reset pin 47 * gpio13: cs5345 reset pin
45*/ 48*/
46 49
50static void gpio_write(struct cx18 *cx)
51{
52 write_reg((gpio_dir & 0xffff) << 16, CX18_REG_GPIO_DIR1);
53 write_reg(((gpio_dir & 0xffff) << 16) | (gpio_val & 0xffff),
54 CX18_REG_GPIO_OUT1);
55 write_reg(gpio_dir & 0xffff0000, CX18_REG_GPIO_DIR2);
56 write_reg((gpio_dir & 0xffff0000) | ((gpio_val & 0xffff0000) >> 16),
57 CX18_REG_GPIO_OUT2);
58}
59
47void cx18_gpio_init(struct cx18 *cx) 60void cx18_gpio_init(struct cx18 *cx)
48{ 61{
49 if (cx->card->gpio_init.direction == 0) 62 gpio_dir = cx->card->gpio_init.direction;
63 gpio_val = cx->card->gpio_init.initial_value;
64
65 if (gpio_dir == 0)
50 return; 66 return;
51 67
52 CX18_DEBUG_INFO("GPIO initial dir: %08x out: %08x\n", 68 gpio_dir |= 1 << cx->card->xceive_pin;
53 read_reg(CX18_REG_GPIO_DIR1), read_reg(CX18_REG_GPIO_OUT1)); 69 gpio_val |= 1 << cx->card->xceive_pin;
54 70
55 /* init output data then direction */ 71 CX18_DEBUG_INFO("GPIO initial dir: %08x/%08x out: %08x/%08x\n",
56 write_reg(cx->card->gpio_init.direction << 16, CX18_REG_GPIO_DIR1); 72 read_reg(CX18_REG_GPIO_DIR1), read_reg(CX18_REG_GPIO_DIR2),
57 write_reg(0, CX18_REG_GPIO_DIR2); 73 read_reg(CX18_REG_GPIO_OUT1), read_reg(CX18_REG_GPIO_OUT2));
58 write_reg((cx->card->gpio_init.direction << 16) | 74
59 cx->card->gpio_init.initial_value, CX18_REG_GPIO_OUT1); 75 gpio_write(cx);
60 write_reg(0, CX18_REG_GPIO_OUT2);
61} 76}
62 77
63/* Xceive tuner reset function */ 78/* Xceive tuner reset function */
64int cx18_reset_tuner_gpio(void *dev, int cmd, int value) 79int cx18_reset_tuner_gpio(void *dev, int cmd, int value)
65{ 80{
66 struct i2c_algo_bit_data *algo = dev; 81 struct i2c_algo_bit_data *algo = dev;
67 struct cx18 *cx = algo->data; 82 struct cx18_i2c_algo_callback_data *cb_data = algo->data;
68/* int curdir, curout;*/ 83 struct cx18 *cx = cb_data->cx;
69 84
70 if (cmd != XC2028_TUNER_RESET) 85 if (cmd != XC2028_TUNER_RESET)
71 return 0; 86 return 0;
72 CX18_DEBUG_INFO("Resetting tuner\n"); 87 CX18_DEBUG_INFO("Resetting tuner\n");
88
89 gpio_dir |= 1 << cx->card->xceive_pin;
90 gpio_val &= ~(1 << cx->card->xceive_pin);
91
92 gpio_write(cx);
93 schedule_timeout_interruptible(msecs_to_jiffies(1));
94
95 gpio_val |= 1 << cx->card->xceive_pin;
96 gpio_write(cx);
97 schedule_timeout_interruptible(msecs_to_jiffies(1));
73 return 0; 98 return 0;
74} 99}
diff --git a/drivers/media/video/cx18/cx18-i2c.c b/drivers/media/video/cx18/cx18-i2c.c
index 18c88d1e4833..4f08a4058d1a 100644
--- a/drivers/media/video/cx18/cx18-i2c.c
+++ b/drivers/media/video/cx18/cx18-i2c.c
@@ -25,6 +25,7 @@
25#include "cx18-cards.h" 25#include "cx18-cards.h"
26#include "cx18-gpio.h" 26#include "cx18-gpio.h"
27#include "cx18-av-core.h" 27#include "cx18-av-core.h"
28#include "cx18-i2c.h"
28 29
29#include <media/ir-kbd-i2c.h> 30#include <media/ir-kbd-i2c.h>
30 31
diff --git a/drivers/media/video/cx18/cx18-queue.c b/drivers/media/video/cx18/cx18-queue.c
index 65af1bb507ca..6990b77c6200 100644
--- a/drivers/media/video/cx18/cx18-queue.c
+++ b/drivers/media/video/cx18/cx18-queue.c
@@ -26,17 +26,6 @@
26#include "cx18-queue.h" 26#include "cx18-queue.h"
27#include "cx18-scb.h" 27#include "cx18-scb.h"
28 28
29int cx18_buf_copy_from_user(struct cx18_stream *s, struct cx18_buffer *buf,
30 const char __user *src, int copybytes)
31{
32 if (s->buf_size - buf->bytesused < copybytes)
33 copybytes = s->buf_size - buf->bytesused;
34 if (copy_from_user(buf->buf + buf->bytesused, src, copybytes))
35 return -EFAULT;
36 buf->bytesused += copybytes;
37 return copybytes;
38}
39
40void cx18_buf_swap(struct cx18_buffer *buf) 29void cx18_buf_swap(struct cx18_buffer *buf)
41{ 30{
42 int i; 31 int i;
@@ -159,8 +148,9 @@ static void cx18_queue_move_buf(struct cx18_stream *s, struct cx18_queue *from,
159 -ENOMEM is returned if the buffers could not be obtained, 0 if all 148 -ENOMEM is returned if the buffers could not be obtained, 0 if all
160 buffers where obtained from the 'from' list and if non-zero then 149 buffers where obtained from the 'from' list and if non-zero then
161 the number of stolen buffers is returned. */ 150 the number of stolen buffers is returned. */
162int cx18_queue_move(struct cx18_stream *s, struct cx18_queue *from, 151static int cx18_queue_move(struct cx18_stream *s, struct cx18_queue *from,
163 struct cx18_queue *steal, struct cx18_queue *to, int needed_bytes) 152 struct cx18_queue *steal, struct cx18_queue *to,
153 int needed_bytes)
164{ 154{
165 unsigned long flags; 155 unsigned long flags;
166 int rc = 0; 156 int rc = 0;
@@ -239,12 +229,12 @@ int cx18_stream_alloc(struct cx18_stream *s)
239 229
240 /* allocate stream buffers. Initially all buffers are in q_free. */ 230 /* allocate stream buffers. Initially all buffers are in q_free. */
241 for (i = 0; i < s->buffers; i++) { 231 for (i = 0; i < s->buffers; i++) {
242 struct cx18_buffer *buf = 232 struct cx18_buffer *buf = kzalloc(sizeof(struct cx18_buffer),
243 kzalloc(sizeof(struct cx18_buffer), GFP_KERNEL); 233 GFP_KERNEL|__GFP_NOWARN);
244 234
245 if (buf == NULL) 235 if (buf == NULL)
246 break; 236 break;
247 buf->buf = kmalloc(s->buf_size, GFP_KERNEL); 237 buf->buf = kmalloc(s->buf_size, GFP_KERNEL|__GFP_NOWARN);
248 if (buf->buf == NULL) { 238 if (buf->buf == NULL) {
249 kfree(buf); 239 kfree(buf);
250 break; 240 break;
diff --git a/drivers/media/video/cx18/cx18-queue.h b/drivers/media/video/cx18/cx18-queue.h
index f86c8a6fa6e7..91423b9863a4 100644
--- a/drivers/media/video/cx18/cx18-queue.h
+++ b/drivers/media/video/cx18/cx18-queue.h
@@ -39,8 +39,6 @@ static inline void cx18_buf_sync_for_device(struct cx18_stream *s,
39 s->buf_size, s->dma); 39 s->buf_size, s->dma);
40} 40}
41 41
42int cx18_buf_copy_from_user(struct cx18_stream *s, struct cx18_buffer *buf,
43 const char __user *src, int copybytes);
44void cx18_buf_swap(struct cx18_buffer *buf); 42void cx18_buf_swap(struct cx18_buffer *buf);
45 43
46/* cx18_queue utility functions */ 44/* cx18_queue utility functions */
@@ -48,8 +46,6 @@ void cx18_queue_init(struct cx18_queue *q);
48void cx18_enqueue(struct cx18_stream *s, struct cx18_buffer *buf, 46void cx18_enqueue(struct cx18_stream *s, struct cx18_buffer *buf,
49 struct cx18_queue *q); 47 struct cx18_queue *q);
50struct cx18_buffer *cx18_dequeue(struct cx18_stream *s, struct cx18_queue *q); 48struct cx18_buffer *cx18_dequeue(struct cx18_stream *s, struct cx18_queue *q);
51int cx18_queue_move(struct cx18_stream *s, struct cx18_queue *from,
52 struct cx18_queue *steal, struct cx18_queue *to, int needed_bytes);
53struct cx18_buffer *cx18_queue_find_buf(struct cx18_stream *s, u32 id, 49struct cx18_buffer *cx18_queue_find_buf(struct cx18_stream *s, u32 id,
54 u32 bytesused); 50 u32 bytesused);
55void cx18_flush_queues(struct cx18_stream *s); 51void cx18_flush_queues(struct cx18_stream *s);
diff --git a/drivers/media/video/cx18/cx18-streams.c b/drivers/media/video/cx18/cx18-streams.c
index afb141b2027a..4ca9d847f1b1 100644
--- a/drivers/media/video/cx18/cx18-streams.c
+++ b/drivers/media/video/cx18/cx18-streams.c
@@ -218,7 +218,7 @@ int cx18_streams_setup(struct cx18 *cx)
218 return 0; 218 return 0;
219 219
220 /* One or more streams could not be initialized. Clean 'em all up. */ 220 /* One or more streams could not be initialized. Clean 'em all up. */
221 cx18_streams_cleanup(cx); 221 cx18_streams_cleanup(cx, 0);
222 return -ENOMEM; 222 return -ENOMEM;
223} 223}
224 224
@@ -296,12 +296,12 @@ int cx18_streams_register(struct cx18 *cx)
296 return 0; 296 return 0;
297 297
298 /* One or more streams could not be initialized. Clean 'em all up. */ 298 /* One or more streams could not be initialized. Clean 'em all up. */
299 cx18_streams_cleanup(cx); 299 cx18_streams_cleanup(cx, 1);
300 return -ENOMEM; 300 return -ENOMEM;
301} 301}
302 302
303/* Unregister v4l2 devices */ 303/* Unregister v4l2 devices */
304void cx18_streams_cleanup(struct cx18 *cx) 304void cx18_streams_cleanup(struct cx18 *cx, int unregister)
305{ 305{
306 struct video_device *vdev; 306 struct video_device *vdev;
307 int type; 307 int type;
@@ -319,8 +319,11 @@ void cx18_streams_cleanup(struct cx18 *cx)
319 319
320 cx18_stream_free(&cx->streams[type]); 320 cx18_stream_free(&cx->streams[type]);
321 321
322 /* Unregister device */ 322 /* Unregister or release device */
323 video_unregister_device(vdev); 323 if (unregister)
324 video_unregister_device(vdev);
325 else
326 video_device_release(vdev);
324 } 327 }
325} 328}
326 329
diff --git a/drivers/media/video/cx18/cx18-streams.h b/drivers/media/video/cx18/cx18-streams.h
index 8c7ba7d2fa79..f327e947b24f 100644
--- a/drivers/media/video/cx18/cx18-streams.h
+++ b/drivers/media/video/cx18/cx18-streams.h
@@ -24,7 +24,7 @@
24u32 cx18_find_handle(struct cx18 *cx); 24u32 cx18_find_handle(struct cx18 *cx);
25int cx18_streams_setup(struct cx18 *cx); 25int cx18_streams_setup(struct cx18 *cx);
26int cx18_streams_register(struct cx18 *cx); 26int cx18_streams_register(struct cx18 *cx);
27void cx18_streams_cleanup(struct cx18 *cx); 27void cx18_streams_cleanup(struct cx18 *cx, int unregister);
28 28
29/* Capture related */ 29/* Capture related */
30int cx18_start_v4l2_encode_stream(struct cx18_stream *s); 30int cx18_start_v4l2_encode_stream(struct cx18_stream *s);
diff --git a/drivers/media/video/cx23885/Kconfig b/drivers/media/video/cx23885/Kconfig
index cadf936c3673..7bf14c9a15c7 100644
--- a/drivers/media/video/cx23885/Kconfig
+++ b/drivers/media/video/cx23885/Kconfig
@@ -1,18 +1,20 @@
1config VIDEO_CX23885 1config VIDEO_CX23885
2 tristate "Conexant cx23885 (2388x successor) support" 2 tristate "Conexant cx23885 (2388x successor) support"
3 depends on DVB_CORE && VIDEO_DEV && PCI && I2C && INPUT 3 depends on DVB_CORE && VIDEO_DEV && PCI && I2C && INPUT
4 depends on HOTPLUG # due to FW_LOADER
4 select I2C_ALGOBIT 5 select I2C_ALGOBIT
5 select FW_LOADER 6 select FW_LOADER
6 select VIDEO_BTCX 7 select VIDEO_BTCX
7 select MEDIA_TUNER 8 select VIDEO_TUNER
8 select VIDEO_TVEEPROM 9 select VIDEO_TVEEPROM
9 select VIDEO_IR 10 select VIDEO_IR
10 select VIDEOBUF_DVB 11 select VIDEOBUF_DVB
11 select VIDEO_CX25840 12 select VIDEO_CX25840
13 select VIDEO_CX2341X
14 select DVB_DIB7000P if !DVB_FE_CUSTOMISE
12 select MEDIA_TUNER_MT2131 if !DVB_FE_CUSTOMISE 15 select MEDIA_TUNER_MT2131 if !DVB_FE_CUSTOMISE
13 select DVB_S5H1409 if !DVB_FE_CUSTOMISE 16 select DVB_S5H1409 if !DVB_FE_CUSTOMISE
14 select DVB_LGDT330X if !DVB_FE_CUSTOMISE 17 select DVB_LGDT330X if !DVB_FE_CUSTOMISE
15 select DVB_PLL if !DVB_FE_CUSTOMISE
16 select MEDIA_TUNER_XC2028 if !DVB_FE_CUSTOMIZE 18 select MEDIA_TUNER_XC2028 if !DVB_FE_CUSTOMIZE
17 select MEDIA_TUNER_TDA8290 if !DVB_FE_CUSTOMIZE 19 select MEDIA_TUNER_TDA8290 if !DVB_FE_CUSTOMIZE
18 select MEDIA_TUNER_TDA18271 if !DVB_FE_CUSTOMIZE 20 select MEDIA_TUNER_TDA18271 if !DVB_FE_CUSTOMIZE
diff --git a/drivers/media/video/cx23885/cx23885-cards.c b/drivers/media/video/cx23885/cx23885-cards.c
index 6ebf58724a01..20e05f230546 100644
--- a/drivers/media/video/cx23885/cx23885-cards.c
+++ b/drivers/media/video/cx23885/cx23885-cards.c
@@ -200,6 +200,10 @@ struct cx23885_subid cx23885_subids[] = {
200 .card = CX23885_BOARD_HAUPPAUGE_HVR1200, 200 .card = CX23885_BOARD_HAUPPAUGE_HVR1200,
201 }, { 201 }, {
202 .subvendor = 0x0070, 202 .subvendor = 0x0070,
203 .subdevice = 0x71d3,
204 .card = CX23885_BOARD_HAUPPAUGE_HVR1200,
205 }, {
206 .subvendor = 0x0070,
203 .subdevice = 0x8101, 207 .subdevice = 0x8101,
204 .card = CX23885_BOARD_HAUPPAUGE_HVR1700, 208 .card = CX23885_BOARD_HAUPPAUGE_HVR1700,
205 }, { 209 }, {
@@ -245,6 +249,33 @@ static void hauppauge_eeprom(struct cx23885_dev *dev, u8 *eeprom_data)
245 /* Make sure we support the board model */ 249 /* Make sure we support the board model */
246 switch (tv.model) 250 switch (tv.model)
247 { 251 {
252 case 71009:
253 /* WinTV-HVR1200 (PCIe, Retail, full height)
254 * DVB-T and basic analog */
255 case 71359:
256 /* WinTV-HVR1200 (PCIe, OEM, half height)
257 * DVB-T and basic analog */
258 case 71439:
259 /* WinTV-HVR1200 (PCIe, OEM, half height)
260 * DVB-T and basic analog */
261 case 71449:
262 /* WinTV-HVR1200 (PCIe, OEM, full height)
263 * DVB-T and basic analog */
264 case 71939:
265 /* WinTV-HVR1200 (PCIe, OEM, half height)
266 * DVB-T and basic analog */
267 case 71949:
268 /* WinTV-HVR1200 (PCIe, OEM, full height)
269 * DVB-T and basic analog */
270 case 71959:
271 /* WinTV-HVR1200 (PCIe, OEM, full height)
272 * DVB-T and basic analog */
273 case 71979:
274 /* WinTV-HVR1200 (PCIe, OEM, half height)
275 * DVB-T and basic analog */
276 case 71999:
277 /* WinTV-HVR1200 (PCIe, OEM, full height)
278 * DVB-T and basic analog */
248 case 76601: /* WinTV-HVR1800lp (PCIe, Retail, No IR, Dual channel ATSC and MPEG2 HW Encoder */ 279 case 76601: /* WinTV-HVR1800lp (PCIe, Retail, No IR, Dual channel ATSC and MPEG2 HW Encoder */
249 case 77001: /* WinTV-HVR1500 (Express Card, OEM, No IR, ATSC and Basic analog */ 280 case 77001: /* WinTV-HVR1500 (Express Card, OEM, No IR, ATSC and Basic analog */
250 case 77011: /* WinTV-HVR1500 (Express Card, Retail, No IR, ATSC and Basic analog */ 281 case 77011: /* WinTV-HVR1500 (Express Card, Retail, No IR, ATSC and Basic analog */
@@ -263,8 +294,11 @@ static void hauppauge_eeprom(struct cx23885_dev *dev, u8 *eeprom_data)
263 case 80019: 294 case 80019:
264 /* WinTV-HVR1400 (Express Card, Retail, IR, 295 /* WinTV-HVR1400 (Express Card, Retail, IR,
265 * DVB-T and Basic analog */ 296 * DVB-T and Basic analog */
297 case 81509:
298 /* WinTV-HVR1700 (PCIe, OEM, No IR, half height)
299 * DVB-T and MPEG2 HW Encoder */
266 case 81519: 300 case 81519:
267 /* WinTV-HVR1700 (PCIe, Retail, No IR, half height, 301 /* WinTV-HVR1700 (PCIe, OEM, No IR, full height)
268 * DVB-T and MPEG2 HW Encoder */ 302 * DVB-T and MPEG2 HW Encoder */
269 break; 303 break;
270 default: 304 default:
diff --git a/drivers/media/video/cx23885/cx23885-dvb.c b/drivers/media/video/cx23885/cx23885-dvb.c
index f05649727b60..022aa391937a 100644
--- a/drivers/media/video/cx23885/cx23885-dvb.c
+++ b/drivers/media/video/cx23885/cx23885-dvb.c
@@ -37,7 +37,6 @@
37#include "lgdt330x.h" 37#include "lgdt330x.h"
38#include "xc5000.h" 38#include "xc5000.h"
39#include "tda10048.h" 39#include "tda10048.h"
40#include "dvb-pll.h"
41#include "tuner-xc2028.h" 40#include "tuner-xc2028.h"
42#include "tuner-simple.h" 41#include "tuner-simple.h"
43#include "dib7000p.h" 42#include "dib7000p.h"
@@ -385,12 +384,10 @@ static int dvb_register(struct cx23885_tsport *port)
385 port->dvb.frontend = dvb_attach(s5h1409_attach, 384 port->dvb.frontend = dvb_attach(s5h1409_attach,
386 &hauppauge_hvr1500q_config, 385 &hauppauge_hvr1500q_config,
387 &dev->i2c_bus[0].i2c_adap); 386 &dev->i2c_bus[0].i2c_adap);
388 if (port->dvb.frontend != NULL) { 387 if (port->dvb.frontend != NULL)
389 hauppauge_hvr1500q_tunerconfig.priv = i2c_bus;
390 dvb_attach(xc5000_attach, port->dvb.frontend, 388 dvb_attach(xc5000_attach, port->dvb.frontend,
391 &i2c_bus->i2c_adap, 389 &i2c_bus->i2c_adap,
392 &hauppauge_hvr1500q_tunerconfig); 390 &hauppauge_hvr1500q_tunerconfig, i2c_bus);
393 }
394 break; 391 break;
395 case CX23885_BOARD_HAUPPAUGE_HVR1500: 392 case CX23885_BOARD_HAUPPAUGE_HVR1500:
396 i2c_bus = &dev->i2c_bus[1]; 393 i2c_bus = &dev->i2c_bus[1];
diff --git a/drivers/media/video/cx25840/Kconfig b/drivers/media/video/cx25840/Kconfig
index 7cf29a03ed63..448f4cd0ce34 100644
--- a/drivers/media/video/cx25840/Kconfig
+++ b/drivers/media/video/cx25840/Kconfig
@@ -1,6 +1,7 @@
1config VIDEO_CX25840 1config VIDEO_CX25840
2 tristate "Conexant CX2584x audio/video decoders" 2 tristate "Conexant CX2584x audio/video decoders"
3 depends on VIDEO_V4L2 && I2C && EXPERIMENTAL 3 depends on VIDEO_V4L2 && I2C && EXPERIMENTAL
4 depends on HOTPLUG # due to FW_LOADER
4 select FW_LOADER 5 select FW_LOADER
5 ---help--- 6 ---help---
6 Support for the Conexant CX2584x audio/video decoders. 7 Support for the Conexant CX2584x audio/video decoders.
diff --git a/drivers/media/video/cx88/Kconfig b/drivers/media/video/cx88/Kconfig
index b0d7d6a7a4cc..10e20d8196dc 100644
--- a/drivers/media/video/cx88/Kconfig
+++ b/drivers/media/video/cx88/Kconfig
@@ -2,10 +2,9 @@ config VIDEO_CX88
2 tristate "Conexant 2388x (bt878 successor) support" 2 tristate "Conexant 2388x (bt878 successor) support"
3 depends on VIDEO_DEV && PCI && I2C && INPUT 3 depends on VIDEO_DEV && PCI && I2C && INPUT
4 select I2C_ALGOBIT 4 select I2C_ALGOBIT
5 select FW_LOADER
6 select VIDEO_BTCX 5 select VIDEO_BTCX
7 select VIDEOBUF_DMA_SG 6 select VIDEOBUF_DMA_SG
8 select MEDIA_TUNER 7 select VIDEO_TUNER
9 select VIDEO_TVEEPROM 8 select VIDEO_TVEEPROM
10 select VIDEO_IR 9 select VIDEO_IR
11 select VIDEO_WM8775 if VIDEO_HELPER_CHIPS_AUTO 10 select VIDEO_WM8775 if VIDEO_HELPER_CHIPS_AUTO
@@ -34,8 +33,9 @@ config VIDEO_CX88_ALSA
34 33
35config VIDEO_CX88_BLACKBIRD 34config VIDEO_CX88_BLACKBIRD
36 tristate "Blackbird MPEG encoder support (cx2388x + cx23416)" 35 tristate "Blackbird MPEG encoder support (cx2388x + cx23416)"
37 depends on VIDEO_CX88 36 depends on VIDEO_CX88 && HOTPLUG
38 select VIDEO_CX2341X 37 select VIDEO_CX2341X
38 select FW_LOADER
39 ---help--- 39 ---help---
40 This adds support for MPEG encoder cards based on the 40 This adds support for MPEG encoder cards based on the
41 Blackbird reference design, using the Conexant 2388x 41 Blackbird reference design, using the Conexant 2388x
diff --git a/drivers/media/video/cx88/cx88-dvb.c b/drivers/media/video/cx88/cx88-dvb.c
index 1c7fe6862a60..d96173ff1dba 100644
--- a/drivers/media/video/cx88/cx88-dvb.c
+++ b/drivers/media/video/cx88/cx88-dvb.c
@@ -509,9 +509,6 @@ static int attach_xc3028(u8 addr, struct cx8802_dev *dev)
509 if (!fe) { 509 if (!fe) {
510 printk(KERN_ERR "%s/2: xc3028 attach failed\n", 510 printk(KERN_ERR "%s/2: xc3028 attach failed\n",
511 dev->core->name); 511 dev->core->name);
512 dvb_frontend_detach(dev->dvb.frontend);
513 dvb_unregister_frontend(dev->dvb.frontend);
514 dev->dvb.frontend = NULL;
515 return -EINVAL; 512 return -EINVAL;
516 } 513 }
517 514
@@ -523,20 +520,23 @@ static int attach_xc3028(u8 addr, struct cx8802_dev *dev)
523 520
524static int dvb_register(struct cx8802_dev *dev) 521static int dvb_register(struct cx8802_dev *dev)
525{ 522{
523 struct cx88_core *core = dev->core;
524
526 /* init struct videobuf_dvb */ 525 /* init struct videobuf_dvb */
527 dev->dvb.name = dev->core->name; 526 dev->dvb.name = core->name;
528 dev->ts_gen_cntrl = 0x0c; 527 dev->ts_gen_cntrl = 0x0c;
529 528
530 /* init frontend */ 529 /* init frontend */
531 switch (dev->core->boardnr) { 530 switch (core->boardnr) {
532 case CX88_BOARD_HAUPPAUGE_DVB_T1: 531 case CX88_BOARD_HAUPPAUGE_DVB_T1:
533 dev->dvb.frontend = dvb_attach(cx22702_attach, 532 dev->dvb.frontend = dvb_attach(cx22702_attach,
534 &connexant_refboard_config, 533 &connexant_refboard_config,
535 &dev->core->i2c_adap); 534 &core->i2c_adap);
536 if (dev->dvb.frontend != NULL) { 535 if (dev->dvb.frontend != NULL) {
537 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61, 536 if (!dvb_attach(dvb_pll_attach, dev->dvb.frontend,
538 &dev->core->i2c_adap, 537 0x61, &core->i2c_adap,
539 DVB_PLL_THOMSON_DTT759X); 538 DVB_PLL_THOMSON_DTT759X))
539 goto frontend_detach;
540 } 540 }
541 break; 541 break;
542 case CX88_BOARD_TERRATEC_CINERGY_1400_DVB_T1: 542 case CX88_BOARD_TERRATEC_CINERGY_1400_DVB_T1:
@@ -545,11 +545,12 @@ static int dvb_register(struct cx8802_dev *dev)
545 case CX88_BOARD_WINFAST_DTV1000: 545 case CX88_BOARD_WINFAST_DTV1000:
546 dev->dvb.frontend = dvb_attach(cx22702_attach, 546 dev->dvb.frontend = dvb_attach(cx22702_attach,
547 &connexant_refboard_config, 547 &connexant_refboard_config,
548 &dev->core->i2c_adap); 548 &core->i2c_adap);
549 if (dev->dvb.frontend != NULL) { 549 if (dev->dvb.frontend != NULL) {
550 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x60, 550 if (!dvb_attach(dvb_pll_attach, dev->dvb.frontend,
551 &dev->core->i2c_adap, 551 0x60, &core->i2c_adap,
552 DVB_PLL_THOMSON_DTT7579); 552 DVB_PLL_THOMSON_DTT7579))
553 goto frontend_detach;
553 } 554 }
554 break; 555 break;
555 case CX88_BOARD_WINFAST_DTV2000H: 556 case CX88_BOARD_WINFAST_DTV2000H:
@@ -559,29 +560,32 @@ static int dvb_register(struct cx8802_dev *dev)
559 case CX88_BOARD_HAUPPAUGE_HVR3000: 560 case CX88_BOARD_HAUPPAUGE_HVR3000:
560 dev->dvb.frontend = dvb_attach(cx22702_attach, 561 dev->dvb.frontend = dvb_attach(cx22702_attach,
561 &hauppauge_hvr_config, 562 &hauppauge_hvr_config,
562 &dev->core->i2c_adap); 563 &core->i2c_adap);
563 if (dev->dvb.frontend != NULL) { 564 if (dev->dvb.frontend != NULL) {
564 dvb_attach(simple_tuner_attach, dev->dvb.frontend, 565 if (!dvb_attach(simple_tuner_attach, dev->dvb.frontend,
565 &dev->core->i2c_adap, 0x61, 566 &core->i2c_adap, 0x61,
566 TUNER_PHILIPS_FMD1216ME_MK3); 567 TUNER_PHILIPS_FMD1216ME_MK3))
568 goto frontend_detach;
567 } 569 }
568 break; 570 break;
569 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_PLUS: 571 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_PLUS:
570 dev->dvb.frontend = dvb_attach(mt352_attach, 572 dev->dvb.frontend = dvb_attach(mt352_attach,
571 &dvico_fusionhdtv, 573 &dvico_fusionhdtv,
572 &dev->core->i2c_adap); 574 &core->i2c_adap);
573 if (dev->dvb.frontend != NULL) { 575 if (dev->dvb.frontend != NULL) {
574 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x60, 576 if (!dvb_attach(dvb_pll_attach, dev->dvb.frontend,
575 NULL, DVB_PLL_THOMSON_DTT7579); 577 0x60, NULL, DVB_PLL_THOMSON_DTT7579))
578 goto frontend_detach;
576 break; 579 break;
577 } 580 }
578 /* ZL10353 replaces MT352 on later cards */ 581 /* ZL10353 replaces MT352 on later cards */
579 dev->dvb.frontend = dvb_attach(zl10353_attach, 582 dev->dvb.frontend = dvb_attach(zl10353_attach,
580 &dvico_fusionhdtv_plus_v1_1, 583 &dvico_fusionhdtv_plus_v1_1,
581 &dev->core->i2c_adap); 584 &core->i2c_adap);
582 if (dev->dvb.frontend != NULL) { 585 if (dev->dvb.frontend != NULL) {
583 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x60, 586 if (!dvb_attach(dvb_pll_attach, dev->dvb.frontend,
584 NULL, DVB_PLL_THOMSON_DTT7579); 587 0x60, NULL, DVB_PLL_THOMSON_DTT7579))
588 goto frontend_detach;
585 } 589 }
586 break; 590 break;
587 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL: 591 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL:
@@ -589,28 +593,31 @@ static int dvb_register(struct cx8802_dev *dev)
589 * compatible, with a slightly different MT352 AGC gain. */ 593 * compatible, with a slightly different MT352 AGC gain. */
590 dev->dvb.frontend = dvb_attach(mt352_attach, 594 dev->dvb.frontend = dvb_attach(mt352_attach,
591 &dvico_fusionhdtv_dual, 595 &dvico_fusionhdtv_dual,
592 &dev->core->i2c_adap); 596 &core->i2c_adap);
593 if (dev->dvb.frontend != NULL) { 597 if (dev->dvb.frontend != NULL) {
594 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61, 598 if (!dvb_attach(dvb_pll_attach, dev->dvb.frontend,
595 NULL, DVB_PLL_THOMSON_DTT7579); 599 0x61, NULL, DVB_PLL_THOMSON_DTT7579))
600 goto frontend_detach;
596 break; 601 break;
597 } 602 }
598 /* ZL10353 replaces MT352 on later cards */ 603 /* ZL10353 replaces MT352 on later cards */
599 dev->dvb.frontend = dvb_attach(zl10353_attach, 604 dev->dvb.frontend = dvb_attach(zl10353_attach,
600 &dvico_fusionhdtv_plus_v1_1, 605 &dvico_fusionhdtv_plus_v1_1,
601 &dev->core->i2c_adap); 606 &core->i2c_adap);
602 if (dev->dvb.frontend != NULL) { 607 if (dev->dvb.frontend != NULL) {
603 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61, 608 if (!dvb_attach(dvb_pll_attach, dev->dvb.frontend,
604 NULL, DVB_PLL_THOMSON_DTT7579); 609 0x61, NULL, DVB_PLL_THOMSON_DTT7579))
610 goto frontend_detach;
605 } 611 }
606 break; 612 break;
607 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T1: 613 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T1:
608 dev->dvb.frontend = dvb_attach(mt352_attach, 614 dev->dvb.frontend = dvb_attach(mt352_attach,
609 &dvico_fusionhdtv, 615 &dvico_fusionhdtv,
610 &dev->core->i2c_adap); 616 &core->i2c_adap);
611 if (dev->dvb.frontend != NULL) { 617 if (dev->dvb.frontend != NULL) {
612 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61, 618 if (!dvb_attach(dvb_pll_attach, dev->dvb.frontend,
613 NULL, DVB_PLL_LG_Z201); 619 0x61, NULL, DVB_PLL_LG_Z201))
620 goto frontend_detach;
614 } 621 }
615 break; 622 break;
616 case CX88_BOARD_KWORLD_DVB_T: 623 case CX88_BOARD_KWORLD_DVB_T:
@@ -618,10 +625,11 @@ static int dvb_register(struct cx8802_dev *dev)
618 case CX88_BOARD_ADSTECH_DVB_T_PCI: 625 case CX88_BOARD_ADSTECH_DVB_T_PCI:
619 dev->dvb.frontend = dvb_attach(mt352_attach, 626 dev->dvb.frontend = dvb_attach(mt352_attach,
620 &dntv_live_dvbt_config, 627 &dntv_live_dvbt_config,
621 &dev->core->i2c_adap); 628 &core->i2c_adap);
622 if (dev->dvb.frontend != NULL) { 629 if (dev->dvb.frontend != NULL) {
623 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61, 630 if (!dvb_attach(dvb_pll_attach, dev->dvb.frontend,
624 NULL, DVB_PLL_UNKNOWN_1); 631 0x61, NULL, DVB_PLL_UNKNOWN_1))
632 goto frontend_detach;
625 } 633 }
626 break; 634 break;
627 case CX88_BOARD_DNTV_LIVE_DVB_T_PRO: 635 case CX88_BOARD_DNTV_LIVE_DVB_T_PRO:
@@ -630,32 +638,35 @@ static int dvb_register(struct cx8802_dev *dev)
630 dev->dvb.frontend = dvb_attach(mt352_attach, &dntv_live_dvbt_pro_config, 638 dev->dvb.frontend = dvb_attach(mt352_attach, &dntv_live_dvbt_pro_config,
631 &dev->vp3054->adap); 639 &dev->vp3054->adap);
632 if (dev->dvb.frontend != NULL) { 640 if (dev->dvb.frontend != NULL) {
633 dvb_attach(simple_tuner_attach, dev->dvb.frontend, 641 if (!dvb_attach(simple_tuner_attach, dev->dvb.frontend,
634 &dev->core->i2c_adap, 0x61, 642 &core->i2c_adap, 0x61,
635 TUNER_PHILIPS_FMD1216ME_MK3); 643 TUNER_PHILIPS_FMD1216ME_MK3))
644 goto frontend_detach;
636 } 645 }
637#else 646#else
638 printk(KERN_ERR "%s/2: built without vp3054 support\n", dev->core->name); 647 printk(KERN_ERR "%s/2: built without vp3054 support\n",
648 core->name);
639#endif 649#endif
640 break; 650 break;
641 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_HYBRID: 651 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_HYBRID:
642 dev->dvb.frontend = dvb_attach(zl10353_attach, 652 dev->dvb.frontend = dvb_attach(zl10353_attach,
643 &dvico_fusionhdtv_hybrid, 653 &dvico_fusionhdtv_hybrid,
644 &dev->core->i2c_adap); 654 &core->i2c_adap);
645 if (dev->dvb.frontend != NULL) { 655 if (dev->dvb.frontend != NULL) {
646 dvb_attach(simple_tuner_attach, dev->dvb.frontend, 656 if (!dvb_attach(simple_tuner_attach, dev->dvb.frontend,
647 &dev->core->i2c_adap, 0x61, 657 &core->i2c_adap, 0x61,
648 TUNER_THOMSON_FE6600); 658 TUNER_THOMSON_FE6600))
659 goto frontend_detach;
649 } 660 }
650 break; 661 break;
651 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_PRO: 662 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_PRO:
652 dev->dvb.frontend = dvb_attach(zl10353_attach, 663 dev->dvb.frontend = dvb_attach(zl10353_attach,
653 &dvico_fusionhdtv_xc3028, 664 &dvico_fusionhdtv_xc3028,
654 &dev->core->i2c_adap); 665 &core->i2c_adap);
655 if (dev->dvb.frontend == NULL) 666 if (dev->dvb.frontend == NULL)
656 dev->dvb.frontend = dvb_attach(mt352_attach, 667 dev->dvb.frontend = dvb_attach(mt352_attach,
657 &dvico_fusionhdtv_mt352_xc3028, 668 &dvico_fusionhdtv_mt352_xc3028,
658 &dev->core->i2c_adap); 669 &core->i2c_adap);
659 /* 670 /*
660 * On this board, the demod provides the I2C bus pullup. 671 * On this board, the demod provides the I2C bus pullup.
661 * We must not permit gate_ctrl to be performed, or 672 * We must not permit gate_ctrl to be performed, or
@@ -668,19 +679,18 @@ static int dvb_register(struct cx8802_dev *dev)
668 break; 679 break;
669 case CX88_BOARD_PCHDTV_HD3000: 680 case CX88_BOARD_PCHDTV_HD3000:
670 dev->dvb.frontend = dvb_attach(or51132_attach, &pchdtv_hd3000, 681 dev->dvb.frontend = dvb_attach(or51132_attach, &pchdtv_hd3000,
671 &dev->core->i2c_adap); 682 &core->i2c_adap);
672 if (dev->dvb.frontend != NULL) { 683 if (dev->dvb.frontend != NULL) {
673 dvb_attach(simple_tuner_attach, dev->dvb.frontend, 684 if (!dvb_attach(simple_tuner_attach, dev->dvb.frontend,
674 &dev->core->i2c_adap, 0x61, 685 &core->i2c_adap, 0x61,
675 TUNER_THOMSON_DTT761X); 686 TUNER_THOMSON_DTT761X))
687 goto frontend_detach;
676 } 688 }
677 break; 689 break;
678 case CX88_BOARD_DVICO_FUSIONHDTV_3_GOLD_Q: 690 case CX88_BOARD_DVICO_FUSIONHDTV_3_GOLD_Q:
679 dev->ts_gen_cntrl = 0x08; 691 dev->ts_gen_cntrl = 0x08;
680 {
681 /* Do a hardware reset of chip before using it. */
682 struct cx88_core *core = dev->core;
683 692
693 /* Do a hardware reset of chip before using it. */
684 cx_clear(MO_GP0_IO, 1); 694 cx_clear(MO_GP0_IO, 1);
685 mdelay(100); 695 mdelay(100);
686 cx_set(MO_GP0_IO, 1); 696 cx_set(MO_GP0_IO, 1);
@@ -690,139 +700,137 @@ static int dvb_register(struct cx8802_dev *dev)
690 fusionhdtv_3_gold.pll_rf_set = lgdt330x_pll_rf_set; 700 fusionhdtv_3_gold.pll_rf_set = lgdt330x_pll_rf_set;
691 dev->dvb.frontend = dvb_attach(lgdt330x_attach, 701 dev->dvb.frontend = dvb_attach(lgdt330x_attach,
692 &fusionhdtv_3_gold, 702 &fusionhdtv_3_gold,
693 &dev->core->i2c_adap); 703 &core->i2c_adap);
694 if (dev->dvb.frontend != NULL) { 704 if (dev->dvb.frontend != NULL) {
695 dvb_attach(simple_tuner_attach, dev->dvb.frontend, 705 if (!dvb_attach(simple_tuner_attach, dev->dvb.frontend,
696 &dev->core->i2c_adap, 0x61, 706 &core->i2c_adap, 0x61,
697 TUNER_MICROTUNE_4042FI5); 707 TUNER_MICROTUNE_4042FI5))
698 } 708 goto frontend_detach;
699 } 709 }
700 break; 710 break;
701 case CX88_BOARD_DVICO_FUSIONHDTV_3_GOLD_T: 711 case CX88_BOARD_DVICO_FUSIONHDTV_3_GOLD_T:
702 dev->ts_gen_cntrl = 0x08; 712 dev->ts_gen_cntrl = 0x08;
703 {
704 /* Do a hardware reset of chip before using it. */
705 struct cx88_core *core = dev->core;
706 713
714 /* Do a hardware reset of chip before using it. */
707 cx_clear(MO_GP0_IO, 1); 715 cx_clear(MO_GP0_IO, 1);
708 mdelay(100); 716 mdelay(100);
709 cx_set(MO_GP0_IO, 9); 717 cx_set(MO_GP0_IO, 9);
710 mdelay(200); 718 mdelay(200);
711 dev->dvb.frontend = dvb_attach(lgdt330x_attach, 719 dev->dvb.frontend = dvb_attach(lgdt330x_attach,
712 &fusionhdtv_3_gold, 720 &fusionhdtv_3_gold,
713 &dev->core->i2c_adap); 721 &core->i2c_adap);
714 if (dev->dvb.frontend != NULL) { 722 if (dev->dvb.frontend != NULL) {
715 dvb_attach(simple_tuner_attach, dev->dvb.frontend, 723 if (!dvb_attach(simple_tuner_attach, dev->dvb.frontend,
716 &dev->core->i2c_adap, 0x61, 724 &core->i2c_adap, 0x61,
717 TUNER_THOMSON_DTT761X); 725 TUNER_THOMSON_DTT761X))
718 } 726 goto frontend_detach;
719 } 727 }
720 break; 728 break;
721 case CX88_BOARD_DVICO_FUSIONHDTV_5_GOLD: 729 case CX88_BOARD_DVICO_FUSIONHDTV_5_GOLD:
722 dev->ts_gen_cntrl = 0x08; 730 dev->ts_gen_cntrl = 0x08;
723 {
724 /* Do a hardware reset of chip before using it. */
725 struct cx88_core *core = dev->core;
726 731
732 /* Do a hardware reset of chip before using it. */
727 cx_clear(MO_GP0_IO, 1); 733 cx_clear(MO_GP0_IO, 1);
728 mdelay(100); 734 mdelay(100);
729 cx_set(MO_GP0_IO, 1); 735 cx_set(MO_GP0_IO, 1);
730 mdelay(200); 736 mdelay(200);
731 dev->dvb.frontend = dvb_attach(lgdt330x_attach, 737 dev->dvb.frontend = dvb_attach(lgdt330x_attach,
732 &fusionhdtv_5_gold, 738 &fusionhdtv_5_gold,
733 &dev->core->i2c_adap); 739 &core->i2c_adap);
734 if (dev->dvb.frontend != NULL) { 740 if (dev->dvb.frontend != NULL) {
735 dvb_attach(simple_tuner_attach, dev->dvb.frontend, 741 if (!dvb_attach(simple_tuner_attach, dev->dvb.frontend,
736 &dev->core->i2c_adap, 0x61, 742 &core->i2c_adap, 0x61,
737 TUNER_LG_TDVS_H06XF); 743 TUNER_LG_TDVS_H06XF))
738 dvb_attach(tda9887_attach, dev->dvb.frontend, 744 goto frontend_detach;
739 &dev->core->i2c_adap, 0x43); 745 if (!dvb_attach(tda9887_attach, dev->dvb.frontend,
740 } 746 &core->i2c_adap, 0x43))
747 goto frontend_detach;
741 } 748 }
742 break; 749 break;
743 case CX88_BOARD_PCHDTV_HD5500: 750 case CX88_BOARD_PCHDTV_HD5500:
744 dev->ts_gen_cntrl = 0x08; 751 dev->ts_gen_cntrl = 0x08;
745 {
746 /* Do a hardware reset of chip before using it. */
747 struct cx88_core *core = dev->core;
748 752
753 /* Do a hardware reset of chip before using it. */
749 cx_clear(MO_GP0_IO, 1); 754 cx_clear(MO_GP0_IO, 1);
750 mdelay(100); 755 mdelay(100);
751 cx_set(MO_GP0_IO, 1); 756 cx_set(MO_GP0_IO, 1);
752 mdelay(200); 757 mdelay(200);
753 dev->dvb.frontend = dvb_attach(lgdt330x_attach, 758 dev->dvb.frontend = dvb_attach(lgdt330x_attach,
754 &pchdtv_hd5500, 759 &pchdtv_hd5500,
755 &dev->core->i2c_adap); 760 &core->i2c_adap);
756 if (dev->dvb.frontend != NULL) { 761 if (dev->dvb.frontend != NULL) {
757 dvb_attach(simple_tuner_attach, dev->dvb.frontend, 762 if (!dvb_attach(simple_tuner_attach, dev->dvb.frontend,
758 &dev->core->i2c_adap, 0x61, 763 &core->i2c_adap, 0x61,
759 TUNER_LG_TDVS_H06XF); 764 TUNER_LG_TDVS_H06XF))
760 dvb_attach(tda9887_attach, dev->dvb.frontend, 765 goto frontend_detach;
761 &dev->core->i2c_adap, 0x43); 766 if (!dvb_attach(tda9887_attach, dev->dvb.frontend,
762 } 767 &core->i2c_adap, 0x43))
768 goto frontend_detach;
763 } 769 }
764 break; 770 break;
765 case CX88_BOARD_ATI_HDTVWONDER: 771 case CX88_BOARD_ATI_HDTVWONDER:
766 dev->dvb.frontend = dvb_attach(nxt200x_attach, 772 dev->dvb.frontend = dvb_attach(nxt200x_attach,
767 &ati_hdtvwonder, 773 &ati_hdtvwonder,
768 &dev->core->i2c_adap); 774 &core->i2c_adap);
769 if (dev->dvb.frontend != NULL) { 775 if (dev->dvb.frontend != NULL) {
770 dvb_attach(simple_tuner_attach, dev->dvb.frontend, 776 if (!dvb_attach(simple_tuner_attach, dev->dvb.frontend,
771 &dev->core->i2c_adap, 0x61, 777 &core->i2c_adap, 0x61,
772 TUNER_PHILIPS_TUV1236D); 778 TUNER_PHILIPS_TUV1236D))
779 goto frontend_detach;
773 } 780 }
774 break; 781 break;
775 case CX88_BOARD_HAUPPAUGE_NOVASPLUS_S1: 782 case CX88_BOARD_HAUPPAUGE_NOVASPLUS_S1:
776 case CX88_BOARD_HAUPPAUGE_NOVASE2_S1: 783 case CX88_BOARD_HAUPPAUGE_NOVASE2_S1:
777 dev->dvb.frontend = dvb_attach(cx24123_attach, 784 dev->dvb.frontend = dvb_attach(cx24123_attach,
778 &hauppauge_novas_config, 785 &hauppauge_novas_config,
779 &dev->core->i2c_adap); 786 &core->i2c_adap);
780 if (dev->dvb.frontend) { 787 if (dev->dvb.frontend) {
781 dvb_attach(isl6421_attach, dev->dvb.frontend, 788 if (!dvb_attach(isl6421_attach, dev->dvb.frontend,
782 &dev->core->i2c_adap, 0x08, 0x00, 0x00); 789 &core->i2c_adap, 0x08, 0x00, 0x00))
790 goto frontend_detach;
783 } 791 }
784 break; 792 break;
785 case CX88_BOARD_KWORLD_DVBS_100: 793 case CX88_BOARD_KWORLD_DVBS_100:
786 dev->dvb.frontend = dvb_attach(cx24123_attach, 794 dev->dvb.frontend = dvb_attach(cx24123_attach,
787 &kworld_dvbs_100_config, 795 &kworld_dvbs_100_config,
788 &dev->core->i2c_adap); 796 &core->i2c_adap);
789 if (dev->dvb.frontend) { 797 if (dev->dvb.frontend) {
790 dev->core->prev_set_voltage = dev->dvb.frontend->ops.set_voltage; 798 core->prev_set_voltage = dev->dvb.frontend->ops.set_voltage;
791 dev->dvb.frontend->ops.set_voltage = kworld_dvbs_100_set_voltage; 799 dev->dvb.frontend->ops.set_voltage = kworld_dvbs_100_set_voltage;
792 } 800 }
793 break; 801 break;
794 case CX88_BOARD_GENIATECH_DVBS: 802 case CX88_BOARD_GENIATECH_DVBS:
795 dev->dvb.frontend = dvb_attach(cx24123_attach, 803 dev->dvb.frontend = dvb_attach(cx24123_attach,
796 &geniatech_dvbs_config, 804 &geniatech_dvbs_config,
797 &dev->core->i2c_adap); 805 &core->i2c_adap);
798 if (dev->dvb.frontend) { 806 if (dev->dvb.frontend) {
799 dev->core->prev_set_voltage = dev->dvb.frontend->ops.set_voltage; 807 core->prev_set_voltage = dev->dvb.frontend->ops.set_voltage;
800 dev->dvb.frontend->ops.set_voltage = geniatech_dvbs_set_voltage; 808 dev->dvb.frontend->ops.set_voltage = geniatech_dvbs_set_voltage;
801 } 809 }
802 break; 810 break;
803 case CX88_BOARD_PINNACLE_PCTV_HD_800i: 811 case CX88_BOARD_PINNACLE_PCTV_HD_800i:
804 dev->dvb.frontend = dvb_attach(s5h1409_attach, 812 dev->dvb.frontend = dvb_attach(s5h1409_attach,
805 &pinnacle_pctv_hd_800i_config, 813 &pinnacle_pctv_hd_800i_config,
806 &dev->core->i2c_adap); 814 &core->i2c_adap);
807 if (dev->dvb.frontend != NULL) { 815 if (dev->dvb.frontend != NULL) {
808 /* tuner_config.video_dev must point to 816 /* tuner_config.video_dev must point to
809 * i2c_adap.algo_data 817 * i2c_adap.algo_data
810 */ 818 */
811 pinnacle_pctv_hd_800i_tuner_config.priv = 819 if (!dvb_attach(xc5000_attach, dev->dvb.frontend,
812 dev->core->i2c_adap.algo_data; 820 &core->i2c_adap,
813 dvb_attach(xc5000_attach, dev->dvb.frontend, 821 &pinnacle_pctv_hd_800i_tuner_config,
814 &dev->core->i2c_adap, 822 core->i2c_adap.algo_data))
815 &pinnacle_pctv_hd_800i_tuner_config); 823 goto frontend_detach;
816 } 824 }
817 break; 825 break;
818 case CX88_BOARD_DVICO_FUSIONHDTV_5_PCI_NANO: 826 case CX88_BOARD_DVICO_FUSIONHDTV_5_PCI_NANO:
819 dev->dvb.frontend = dvb_attach(s5h1409_attach, 827 dev->dvb.frontend = dvb_attach(s5h1409_attach,
820 &dvico_hdtv5_pci_nano_config, 828 &dvico_hdtv5_pci_nano_config,
821 &dev->core->i2c_adap); 829 &core->i2c_adap);
822 if (dev->dvb.frontend != NULL) { 830 if (dev->dvb.frontend != NULL) {
823 struct dvb_frontend *fe; 831 struct dvb_frontend *fe;
824 struct xc2028_config cfg = { 832 struct xc2028_config cfg = {
825 .i2c_adap = &dev->core->i2c_adap, 833 .i2c_adap = &core->i2c_adap,
826 .i2c_addr = 0x61, 834 .i2c_addr = 0x61,
827 .callback = cx88_pci_nano_callback, 835 .callback = cx88_pci_nano_callback,
828 }; 836 };
@@ -841,50 +849,50 @@ static int dvb_register(struct cx8802_dev *dev)
841 case CX88_BOARD_PINNACLE_HYBRID_PCTV: 849 case CX88_BOARD_PINNACLE_HYBRID_PCTV:
842 dev->dvb.frontend = dvb_attach(zl10353_attach, 850 dev->dvb.frontend = dvb_attach(zl10353_attach,
843 &cx88_geniatech_x8000_mt, 851 &cx88_geniatech_x8000_mt,
844 &dev->core->i2c_adap); 852 &core->i2c_adap);
845 if (attach_xc3028(0x61, dev) < 0) 853 if (attach_xc3028(0x61, dev) < 0)
846 return -EINVAL; 854 goto frontend_detach;
847 break; 855 break;
848 case CX88_BOARD_GENIATECH_X8000_MT: 856 case CX88_BOARD_GENIATECH_X8000_MT:
849 dev->ts_gen_cntrl = 0x00; 857 dev->ts_gen_cntrl = 0x00;
850 858
851 dev->dvb.frontend = dvb_attach(zl10353_attach, 859 dev->dvb.frontend = dvb_attach(zl10353_attach,
852 &cx88_geniatech_x8000_mt, 860 &cx88_geniatech_x8000_mt,
853 &dev->core->i2c_adap); 861 &core->i2c_adap);
854 if (attach_xc3028(0x61, dev) < 0) 862 if (attach_xc3028(0x61, dev) < 0)
855 return -EINVAL; 863 goto frontend_detach;
856 break; 864 break;
857 case CX88_BOARD_KWORLD_ATSC_120: 865 case CX88_BOARD_KWORLD_ATSC_120:
858 dev->dvb.frontend = dvb_attach(s5h1409_attach, 866 dev->dvb.frontend = dvb_attach(s5h1409_attach,
859 &kworld_atsc_120_config, 867 &kworld_atsc_120_config,
860 &dev->core->i2c_adap); 868 &core->i2c_adap);
861 if (attach_xc3028(0x61, dev) < 0) 869 if (attach_xc3028(0x61, dev) < 0)
862 return -EINVAL; 870 goto frontend_detach;
863 break; 871 break;
864 case CX88_BOARD_DVICO_FUSIONHDTV_7_GOLD: 872 case CX88_BOARD_DVICO_FUSIONHDTV_7_GOLD:
865 dev->dvb.frontend = dvb_attach(s5h1411_attach, 873 dev->dvb.frontend = dvb_attach(s5h1411_attach,
866 &dvico_fusionhdtv7_config, 874 &dvico_fusionhdtv7_config,
867 &dev->core->i2c_adap); 875 &core->i2c_adap);
868 if (dev->dvb.frontend != NULL) { 876 if (dev->dvb.frontend != NULL) {
869 /* tuner_config.video_dev must point to 877 /* tuner_config.video_dev must point to
870 * i2c_adap.algo_data 878 * i2c_adap.algo_data
871 */ 879 */
872 dvico_fusionhdtv7_tuner_config.priv = 880 if (!dvb_attach(xc5000_attach, dev->dvb.frontend,
873 dev->core->i2c_adap.algo_data; 881 &core->i2c_adap,
874 dvb_attach(xc5000_attach, dev->dvb.frontend, 882 &dvico_fusionhdtv7_tuner_config,
875 &dev->core->i2c_adap, 883 core->i2c_adap.algo_data))
876 &dvico_fusionhdtv7_tuner_config); 884 goto frontend_detach;
877 } 885 }
878 break; 886 break;
879 default: 887 default:
880 printk(KERN_ERR "%s/2: The frontend of your DVB/ATSC card isn't supported yet\n", 888 printk(KERN_ERR "%s/2: The frontend of your DVB/ATSC card isn't supported yet\n",
881 dev->core->name); 889 core->name);
882 break; 890 break;
883 } 891 }
884 if (NULL == dev->dvb.frontend) { 892 if (NULL == dev->dvb.frontend) {
885 printk(KERN_ERR 893 printk(KERN_ERR
886 "%s/2: frontend initialization failed\n", 894 "%s/2: frontend initialization failed\n",
887 dev->core->name); 895 core->name);
888 return -EINVAL; 896 return -EINVAL;
889 } 897 }
890 898
@@ -892,11 +900,18 @@ static int dvb_register(struct cx8802_dev *dev)
892 dev->dvb.frontend->ops.ts_bus_ctrl = cx88_dvb_bus_ctrl; 900 dev->dvb.frontend->ops.ts_bus_ctrl = cx88_dvb_bus_ctrl;
893 901
894 /* Put the analog decoder in standby to keep it quiet */ 902 /* Put the analog decoder in standby to keep it quiet */
895 cx88_call_i2c_clients (dev->core, TUNER_SET_STANDBY, NULL); 903 cx88_call_i2c_clients(core, TUNER_SET_STANDBY, NULL);
896 904
897 /* register everything */ 905 /* register everything */
898 return videobuf_dvb_register(&dev->dvb, THIS_MODULE, dev, 906 return videobuf_dvb_register(&dev->dvb, THIS_MODULE, dev,
899 &dev->pci->dev, adapter_nr); 907 &dev->pci->dev, adapter_nr);
908
909frontend_detach:
910 if (dev->dvb.frontend) {
911 dvb_frontend_detach(dev->dvb.frontend);
912 dev->dvb.frontend = NULL;
913 }
914 return -EINVAL;
900} 915}
901 916
902/* ----------------------------------------------------------- */ 917/* ----------------------------------------------------------- */
diff --git a/drivers/media/video/em28xx/Kconfig b/drivers/media/video/em28xx/Kconfig
index c7c2896bbd8b..16a5af30e9d1 100644
--- a/drivers/media/video/em28xx/Kconfig
+++ b/drivers/media/video/em28xx/Kconfig
@@ -1,7 +1,7 @@
1config VIDEO_EM28XX 1config VIDEO_EM28XX
2 tristate "Empia EM28xx USB video capture support" 2 tristate "Empia EM28xx USB video capture support"
3 depends on VIDEO_DEV && I2C && INPUT 3 depends on VIDEO_DEV && I2C && INPUT
4 select MEDIA_TUNER 4 select VIDEO_TUNER
5 select VIDEO_TVEEPROM 5 select VIDEO_TVEEPROM
6 select VIDEO_IR 6 select VIDEO_IR
7 select VIDEOBUF_VMALLOC 7 select VIDEOBUF_VMALLOC
@@ -35,7 +35,6 @@ config VIDEO_EM28XX_DVB
35 select DVB_LGDT330X if !DVB_FE_CUSTOMISE 35 select DVB_LGDT330X if !DVB_FE_CUSTOMISE
36 select DVB_ZL10353 if !DVB_FE_CUSTOMISE 36 select DVB_ZL10353 if !DVB_FE_CUSTOMISE
37 select VIDEOBUF_DVB 37 select VIDEOBUF_DVB
38 select FW_LOADER
39 ---help--- 38 ---help---
40 This adds support for DVB cards based on the 39 This adds support for DVB cards based on the
41 Empiatech em28xx chips. 40 Empiatech em28xx chips.
diff --git a/drivers/media/video/em28xx/em28xx-cards.c b/drivers/media/video/em28xx/em28xx-cards.c
index 50ccf3771204..3e4f3c7e92e7 100644
--- a/drivers/media/video/em28xx/em28xx-cards.c
+++ b/drivers/media/video/em28xx/em28xx-cards.c
@@ -420,7 +420,13 @@ struct usb_device_id em28xx_id_table [] = {
420 .driver_info = EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900 }, 420 .driver_info = EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900 },
421 { USB_DEVICE(0x2040, 0x6502), 421 { USB_DEVICE(0x2040, 0x6502),
422 .driver_info = EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900 }, 422 .driver_info = EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900 },
423 { USB_DEVICE(0x2040, 0x6513), 423 { USB_DEVICE(0x2040, 0x6513), /* HCW HVR-980 */
424 .driver_info = EM2880_BOARD_HAUPPAUGE_WINTV_HVR_950 },
425 { USB_DEVICE(0x2040, 0x6517), /* HP HVR-950 */
426 .driver_info = EM2880_BOARD_HAUPPAUGE_WINTV_HVR_950 },
427 { USB_DEVICE(0x2040, 0x651b), /* RP HVR-950 */
428 .driver_info = EM2880_BOARD_HAUPPAUGE_WINTV_HVR_950 },
429 { USB_DEVICE(0x2040, 0x651f), /* HCW HVR-850 */
424 .driver_info = EM2880_BOARD_HAUPPAUGE_WINTV_HVR_950 }, 430 .driver_info = EM2880_BOARD_HAUPPAUGE_WINTV_HVR_950 },
425 { USB_DEVICE(0x0ccd, 0x0042), 431 { USB_DEVICE(0x0ccd, 0x0042),
426 .driver_info = EM2880_BOARD_TERRATEC_HYBRID_XS }, 432 .driver_info = EM2880_BOARD_TERRATEC_HYBRID_XS },
diff --git a/drivers/media/video/em28xx/em28xx-dvb.c b/drivers/media/video/em28xx/em28xx-dvb.c
index 7df81575b7f2..8cf4983f0039 100644
--- a/drivers/media/video/em28xx/em28xx-dvb.c
+++ b/drivers/media/video/em28xx/em28xx-dvb.c
@@ -251,7 +251,6 @@ static int attach_xc3028(u8 addr, struct em28xx *dev)
251 printk(KERN_ERR "%s/2: xc3028 attach failed\n", 251 printk(KERN_ERR "%s/2: xc3028 attach failed\n",
252 dev->name); 252 dev->name);
253 dvb_frontend_detach(dev->dvb->frontend); 253 dvb_frontend_detach(dev->dvb->frontend);
254 dvb_unregister_frontend(dev->dvb->frontend);
255 dev->dvb->frontend = NULL; 254 dev->dvb->frontend = NULL;
256 return -EINVAL; 255 return -EINVAL;
257 } 256 }
diff --git a/drivers/media/video/ivtv/Kconfig b/drivers/media/video/ivtv/Kconfig
index eec115bf9517..5d7ee8fcdd50 100644
--- a/drivers/media/video/ivtv/Kconfig
+++ b/drivers/media/video/ivtv/Kconfig
@@ -1,10 +1,12 @@
1config VIDEO_IVTV 1config VIDEO_IVTV
2 tristate "Conexant cx23416/cx23415 MPEG encoder/decoder support" 2 tristate "Conexant cx23416/cx23415 MPEG encoder/decoder support"
3 depends on VIDEO_V4L1 && VIDEO_V4L2 && PCI && I2C && EXPERIMENTAL 3 depends on VIDEO_V4L1 && VIDEO_V4L2 && PCI && I2C && EXPERIMENTAL
4 depends on INPUT # due to VIDEO_IR
5 depends on HOTPLUG # due to FW_LOADER
4 select I2C_ALGOBIT 6 select I2C_ALGOBIT
5 select FW_LOADER 7 select FW_LOADER
6 select VIDEO_IR 8 select VIDEO_IR
7 select MEDIA_TUNER 9 select VIDEO_TUNER
8 select VIDEO_TVEEPROM 10 select VIDEO_TVEEPROM
9 select VIDEO_CX2341X 11 select VIDEO_CX2341X
10 select VIDEO_CX25840 12 select VIDEO_CX25840
diff --git a/drivers/media/video/ivtv/ivtv-controls.c b/drivers/media/video/ivtv/ivtv-controls.c
index 8c02fa661591..c7e449f6397b 100644
--- a/drivers/media/video/ivtv/ivtv-controls.c
+++ b/drivers/media/video/ivtv/ivtv-controls.c
@@ -181,12 +181,12 @@ static int ivtv_setup_vbi_fmt(struct ivtv *itv, enum v4l2_mpeg_stream_vbi_fmt fm
181 return 0; 181 return 0;
182 } 182 }
183 /* Need sliced data for mpeg insertion */ 183 /* Need sliced data for mpeg insertion */
184 if (get_service_set(itv->vbi.sliced_in) == 0) { 184 if (ivtv_get_service_set(itv->vbi.sliced_in) == 0) {
185 if (itv->is_60hz) 185 if (itv->is_60hz)
186 itv->vbi.sliced_in->service_set = V4L2_SLICED_CAPTION_525; 186 itv->vbi.sliced_in->service_set = V4L2_SLICED_CAPTION_525;
187 else 187 else
188 itv->vbi.sliced_in->service_set = V4L2_SLICED_WSS_625; 188 itv->vbi.sliced_in->service_set = V4L2_SLICED_WSS_625;
189 expand_service_set(itv->vbi.sliced_in, itv->is_50hz); 189 ivtv_expand_service_set(itv->vbi.sliced_in, itv->is_50hz);
190 } 190 }
191 return 0; 191 return 0;
192} 192}
diff --git a/drivers/media/video/ivtv/ivtv-driver.c b/drivers/media/video/ivtv/ivtv-driver.c
index ed020f722b05..797e636771da 100644
--- a/drivers/media/video/ivtv/ivtv-driver.c
+++ b/drivers/media/video/ivtv/ivtv-driver.c
@@ -853,6 +853,7 @@ static int ivtv_setup_pci(struct ivtv *itv, struct pci_dev *dev,
853 return 0; 853 return 0;
854} 854}
855 855
856#ifdef MODULE
856static u32 ivtv_request_module(struct ivtv *itv, u32 hw, 857static u32 ivtv_request_module(struct ivtv *itv, u32 hw,
857 const char *name, u32 id) 858 const char *name, u32 id)
858{ 859{
@@ -865,12 +866,14 @@ static u32 ivtv_request_module(struct ivtv *itv, u32 hw,
865 IVTV_DEBUG_INFO("Loaded module %s\n", name); 866 IVTV_DEBUG_INFO("Loaded module %s\n", name);
866 return hw; 867 return hw;
867} 868}
869#endif
868 870
869static void ivtv_load_and_init_modules(struct ivtv *itv) 871static void ivtv_load_and_init_modules(struct ivtv *itv)
870{ 872{
871 u32 hw = itv->card->hw_all; 873 u32 hw = itv->card->hw_all;
872 unsigned i; 874 unsigned i;
873 875
876#ifdef MODULE
874 /* load modules */ 877 /* load modules */
875#ifndef CONFIG_MEDIA_TUNER 878#ifndef CONFIG_MEDIA_TUNER
876 hw = ivtv_request_module(itv, hw, "tuner", IVTV_HW_TUNER); 879 hw = ivtv_request_module(itv, hw, "tuner", IVTV_HW_TUNER);
@@ -911,6 +914,7 @@ static void ivtv_load_and_init_modules(struct ivtv *itv)
911#ifndef CONFIG_VIDEO_M52790 914#ifndef CONFIG_VIDEO_M52790
912 hw = ivtv_request_module(itv, hw, "m52790", IVTV_HW_M52790); 915 hw = ivtv_request_module(itv, hw, "m52790", IVTV_HW_M52790);
913#endif 916#endif
917#endif
914 918
915 /* check which i2c devices are actually found */ 919 /* check which i2c devices are actually found */
916 for (i = 0; i < 32; i++) { 920 for (i = 0; i < 32; i++) {
@@ -1228,7 +1232,7 @@ static int __devinit ivtv_probe(struct pci_dev *dev,
1228 return 0; 1232 return 0;
1229 1233
1230free_streams: 1234free_streams:
1231 ivtv_streams_cleanup(itv); 1235 ivtv_streams_cleanup(itv, 1);
1232free_irq: 1236free_irq:
1233 free_irq(itv->dev->irq, (void *)itv); 1237 free_irq(itv->dev->irq, (void *)itv);
1234free_i2c: 1238free_i2c:
@@ -1373,7 +1377,7 @@ static void ivtv_remove(struct pci_dev *pci_dev)
1373 flush_workqueue(itv->irq_work_queues); 1377 flush_workqueue(itv->irq_work_queues);
1374 destroy_workqueue(itv->irq_work_queues); 1378 destroy_workqueue(itv->irq_work_queues);
1375 1379
1376 ivtv_streams_cleanup(itv); 1380 ivtv_streams_cleanup(itv, 1);
1377 ivtv_udma_free(itv); 1381 ivtv_udma_free(itv);
1378 1382
1379 exit_ivtv_i2c(itv); 1383 exit_ivtv_i2c(itv);
diff --git a/drivers/media/video/ivtv/ivtv-fileops.c b/drivers/media/video/ivtv/ivtv-fileops.c
index 2b74b0ab1477..f2fa434b677b 100644
--- a/drivers/media/video/ivtv/ivtv-fileops.c
+++ b/drivers/media/video/ivtv/ivtv-fileops.c
@@ -987,6 +987,8 @@ int ivtv_v4l2_open(struct inode *inode, struct file *filp)
987 /* Find which card this open was on */ 987 /* Find which card this open was on */
988 spin_lock(&ivtv_cards_lock); 988 spin_lock(&ivtv_cards_lock);
989 for (x = 0; itv == NULL && x < ivtv_cards_active; x++) { 989 for (x = 0; itv == NULL && x < ivtv_cards_active; x++) {
990 if (ivtv_cards[x] == NULL)
991 continue;
990 /* find out which stream this open was on */ 992 /* find out which stream this open was on */
991 for (y = 0; y < IVTV_MAX_STREAMS; y++) { 993 for (y = 0; y < IVTV_MAX_STREAMS; y++) {
992 s = &ivtv_cards[x]->streams[y]; 994 s = &ivtv_cards[x]->streams[y];
diff --git a/drivers/media/video/ivtv/ivtv-ioctl.c b/drivers/media/video/ivtv/ivtv-ioctl.c
index d508b5d0538c..26cc0f6699fd 100644
--- a/drivers/media/video/ivtv/ivtv-ioctl.c
+++ b/drivers/media/video/ivtv/ivtv-ioctl.c
@@ -38,7 +38,7 @@
38#include <linux/dvb/audio.h> 38#include <linux/dvb/audio.h>
39#include <linux/i2c-id.h> 39#include <linux/i2c-id.h>
40 40
41u16 service2vbi(int type) 41u16 ivtv_service2vbi(int type)
42{ 42{
43 switch (type) { 43 switch (type) {
44 case V4L2_SLICED_TELETEXT_B: 44 case V4L2_SLICED_TELETEXT_B:
@@ -88,7 +88,7 @@ static u16 select_service_from_set(int field, int line, u16 set, int is_pal)
88 return 0; 88 return 0;
89} 89}
90 90
91void expand_service_set(struct v4l2_sliced_vbi_format *fmt, int is_pal) 91void ivtv_expand_service_set(struct v4l2_sliced_vbi_format *fmt, int is_pal)
92{ 92{
93 u16 set = fmt->service_set; 93 u16 set = fmt->service_set;
94 int f, l; 94 int f, l;
@@ -115,7 +115,7 @@ static int check_service_set(struct v4l2_sliced_vbi_format *fmt, int is_pal)
115 return set != 0; 115 return set != 0;
116} 116}
117 117
118u16 get_service_set(struct v4l2_sliced_vbi_format *fmt) 118u16 ivtv_get_service_set(struct v4l2_sliced_vbi_format *fmt)
119{ 119{
120 int f, l; 120 int f, l;
121 u16 set = 0; 121 u16 set = 0;
@@ -466,7 +466,7 @@ static int ivtv_get_fmt(struct ivtv *itv, int streamtype, struct v4l2_format *fm
466 vbifmt->service_lines[0][23] = V4L2_SLICED_WSS_625; 466 vbifmt->service_lines[0][23] = V4L2_SLICED_WSS_625;
467 vbifmt->service_lines[0][16] = V4L2_SLICED_VPS; 467 vbifmt->service_lines[0][16] = V4L2_SLICED_VPS;
468 } 468 }
469 vbifmt->service_set = get_service_set(vbifmt); 469 vbifmt->service_set = ivtv_get_service_set(vbifmt);
470 break; 470 break;
471 } 471 }
472 472
@@ -481,12 +481,12 @@ static int ivtv_get_fmt(struct ivtv *itv, int streamtype, struct v4l2_format *fm
481 if (streamtype == IVTV_DEC_STREAM_TYPE_VBI) { 481 if (streamtype == IVTV_DEC_STREAM_TYPE_VBI) {
482 vbifmt->service_set = itv->is_50hz ? V4L2_SLICED_VBI_625 : 482 vbifmt->service_set = itv->is_50hz ? V4L2_SLICED_VBI_625 :
483 V4L2_SLICED_VBI_525; 483 V4L2_SLICED_VBI_525;
484 expand_service_set(vbifmt, itv->is_50hz); 484 ivtv_expand_service_set(vbifmt, itv->is_50hz);
485 break; 485 break;
486 } 486 }
487 487
488 itv->video_dec_func(itv, VIDIOC_G_FMT, fmt); 488 itv->video_dec_func(itv, VIDIOC_G_FMT, fmt);
489 vbifmt->service_set = get_service_set(vbifmt); 489 vbifmt->service_set = ivtv_get_service_set(vbifmt);
490 break; 490 break;
491 } 491 }
492 case V4L2_BUF_TYPE_VBI_OUTPUT: 492 case V4L2_BUF_TYPE_VBI_OUTPUT:
@@ -640,9 +640,9 @@ static int ivtv_try_or_set_fmt(struct ivtv *itv, int streamtype,
640 memset(vbifmt->reserved, 0, sizeof(vbifmt->reserved)); 640 memset(vbifmt->reserved, 0, sizeof(vbifmt->reserved));
641 641
642 if (vbifmt->service_set) 642 if (vbifmt->service_set)
643 expand_service_set(vbifmt, itv->is_50hz); 643 ivtv_expand_service_set(vbifmt, itv->is_50hz);
644 set = check_service_set(vbifmt, itv->is_50hz); 644 set = check_service_set(vbifmt, itv->is_50hz);
645 vbifmt->service_set = get_service_set(vbifmt); 645 vbifmt->service_set = ivtv_get_service_set(vbifmt);
646 646
647 if (!set_fmt) 647 if (!set_fmt)
648 return 0; 648 return 0;
diff --git a/drivers/media/video/ivtv/ivtv-ioctl.h b/drivers/media/video/ivtv/ivtv-ioctl.h
index a03351b6853d..4e67f0ed1fc0 100644
--- a/drivers/media/video/ivtv/ivtv-ioctl.h
+++ b/drivers/media/video/ivtv/ivtv-ioctl.h
@@ -21,9 +21,9 @@
21#ifndef IVTV_IOCTL_H 21#ifndef IVTV_IOCTL_H
22#define IVTV_IOCTL_H 22#define IVTV_IOCTL_H
23 23
24u16 service2vbi(int type); 24u16 ivtv_service2vbi(int type);
25void expand_service_set(struct v4l2_sliced_vbi_format *fmt, int is_pal); 25void ivtv_expand_service_set(struct v4l2_sliced_vbi_format *fmt, int is_pal);
26u16 get_service_set(struct v4l2_sliced_vbi_format *fmt); 26u16 ivtv_get_service_set(struct v4l2_sliced_vbi_format *fmt);
27int ivtv_v4l2_ioctl(struct inode *inode, struct file *filp, unsigned int cmd, 27int ivtv_v4l2_ioctl(struct inode *inode, struct file *filp, unsigned int cmd,
28 unsigned long arg); 28 unsigned long arg);
29int ivtv_v4l2_ioctls(struct ivtv *itv, struct file *filp, unsigned int cmd, void *arg); 29int ivtv_v4l2_ioctls(struct ivtv *itv, struct file *filp, unsigned int cmd, void *arg);
diff --git a/drivers/media/video/ivtv/ivtv-queue.c b/drivers/media/video/ivtv/ivtv-queue.c
index 3e1deec67a5e..fc8b1eaa333b 100644
--- a/drivers/media/video/ivtv/ivtv-queue.c
+++ b/drivers/media/video/ivtv/ivtv-queue.c
@@ -203,14 +203,14 @@ int ivtv_stream_alloc(struct ivtv_stream *s)
203 s->dma != PCI_DMA_NONE ? "DMA " : "", 203 s->dma != PCI_DMA_NONE ? "DMA " : "",
204 s->name, s->buffers, s->buf_size, s->buffers * s->buf_size / 1024); 204 s->name, s->buffers, s->buf_size, s->buffers * s->buf_size / 1024);
205 205
206 s->sg_pending = kzalloc(SGsize, GFP_KERNEL); 206 s->sg_pending = kzalloc(SGsize, GFP_KERNEL|__GFP_NOWARN);
207 if (s->sg_pending == NULL) { 207 if (s->sg_pending == NULL) {
208 IVTV_ERR("Could not allocate sg_pending for %s stream\n", s->name); 208 IVTV_ERR("Could not allocate sg_pending for %s stream\n", s->name);
209 return -ENOMEM; 209 return -ENOMEM;
210 } 210 }
211 s->sg_pending_size = 0; 211 s->sg_pending_size = 0;
212 212
213 s->sg_processing = kzalloc(SGsize, GFP_KERNEL); 213 s->sg_processing = kzalloc(SGsize, GFP_KERNEL|__GFP_NOWARN);
214 if (s->sg_processing == NULL) { 214 if (s->sg_processing == NULL) {
215 IVTV_ERR("Could not allocate sg_processing for %s stream\n", s->name); 215 IVTV_ERR("Could not allocate sg_processing for %s stream\n", s->name);
216 kfree(s->sg_pending); 216 kfree(s->sg_pending);
@@ -219,7 +219,8 @@ int ivtv_stream_alloc(struct ivtv_stream *s)
219 } 219 }
220 s->sg_processing_size = 0; 220 s->sg_processing_size = 0;
221 221
222 s->sg_dma = kzalloc(sizeof(struct ivtv_sg_element), GFP_KERNEL); 222 s->sg_dma = kzalloc(sizeof(struct ivtv_sg_element),
223 GFP_KERNEL|__GFP_NOWARN);
223 if (s->sg_dma == NULL) { 224 if (s->sg_dma == NULL) {
224 IVTV_ERR("Could not allocate sg_dma for %s stream\n", s->name); 225 IVTV_ERR("Could not allocate sg_dma for %s stream\n", s->name);
225 kfree(s->sg_pending); 226 kfree(s->sg_pending);
@@ -235,11 +236,12 @@ int ivtv_stream_alloc(struct ivtv_stream *s)
235 236
236 /* allocate stream buffers. Initially all buffers are in q_free. */ 237 /* allocate stream buffers. Initially all buffers are in q_free. */
237 for (i = 0; i < s->buffers; i++) { 238 for (i = 0; i < s->buffers; i++) {
238 struct ivtv_buffer *buf = kzalloc(sizeof(struct ivtv_buffer), GFP_KERNEL); 239 struct ivtv_buffer *buf = kzalloc(sizeof(struct ivtv_buffer),
240 GFP_KERNEL|__GFP_NOWARN);
239 241
240 if (buf == NULL) 242 if (buf == NULL)
241 break; 243 break;
242 buf->buf = kmalloc(s->buf_size + 256, GFP_KERNEL); 244 buf->buf = kmalloc(s->buf_size + 256, GFP_KERNEL|__GFP_NOWARN);
243 if (buf->buf == NULL) { 245 if (buf->buf == NULL) {
244 kfree(buf); 246 kfree(buf);
245 break; 247 break;
diff --git a/drivers/media/video/ivtv/ivtv-streams.c b/drivers/media/video/ivtv/ivtv-streams.c
index 4ab8d36831ba..c47c2b945147 100644
--- a/drivers/media/video/ivtv/ivtv-streams.c
+++ b/drivers/media/video/ivtv/ivtv-streams.c
@@ -244,7 +244,7 @@ int ivtv_streams_setup(struct ivtv *itv)
244 return 0; 244 return 0;
245 245
246 /* One or more streams could not be initialized. Clean 'em all up. */ 246 /* One or more streams could not be initialized. Clean 'em all up. */
247 ivtv_streams_cleanup(itv); 247 ivtv_streams_cleanup(itv, 0);
248 return -ENOMEM; 248 return -ENOMEM;
249} 249}
250 250
@@ -304,12 +304,12 @@ int ivtv_streams_register(struct ivtv *itv)
304 return 0; 304 return 0;
305 305
306 /* One or more streams could not be initialized. Clean 'em all up. */ 306 /* One or more streams could not be initialized. Clean 'em all up. */
307 ivtv_streams_cleanup(itv); 307 ivtv_streams_cleanup(itv, 1);
308 return -ENOMEM; 308 return -ENOMEM;
309} 309}
310 310
311/* Unregister v4l2 devices */ 311/* Unregister v4l2 devices */
312void ivtv_streams_cleanup(struct ivtv *itv) 312void ivtv_streams_cleanup(struct ivtv *itv, int unregister)
313{ 313{
314 int type; 314 int type;
315 315
@@ -322,8 +322,11 @@ void ivtv_streams_cleanup(struct ivtv *itv)
322 continue; 322 continue;
323 323
324 ivtv_stream_free(&itv->streams[type]); 324 ivtv_stream_free(&itv->streams[type]);
325 /* Unregister device */ 325 /* Unregister or release device */
326 video_unregister_device(vdev); 326 if (unregister)
327 video_unregister_device(vdev);
328 else
329 video_device_release(vdev);
327 } 330 }
328} 331}
329 332
diff --git a/drivers/media/video/ivtv/ivtv-streams.h b/drivers/media/video/ivtv/ivtv-streams.h
index 3d76a415fbd8..a653a5136417 100644
--- a/drivers/media/video/ivtv/ivtv-streams.h
+++ b/drivers/media/video/ivtv/ivtv-streams.h
@@ -23,7 +23,7 @@
23 23
24int ivtv_streams_setup(struct ivtv *itv); 24int ivtv_streams_setup(struct ivtv *itv);
25int ivtv_streams_register(struct ivtv *itv); 25int ivtv_streams_register(struct ivtv *itv);
26void ivtv_streams_cleanup(struct ivtv *itv); 26void ivtv_streams_cleanup(struct ivtv *itv, int unregister);
27 27
28/* Capture related */ 28/* Capture related */
29int ivtv_start_v4l2_encode_stream(struct ivtv_stream *s); 29int ivtv_start_v4l2_encode_stream(struct ivtv_stream *s);
diff --git a/drivers/media/video/ivtv/ivtv-vbi.c b/drivers/media/video/ivtv/ivtv-vbi.c
index c151bcf5519a..71798f0da27f 100644
--- a/drivers/media/video/ivtv/ivtv-vbi.c
+++ b/drivers/media/video/ivtv/ivtv-vbi.c
@@ -169,7 +169,8 @@ static void copy_vbi_data(struct ivtv *itv, int lines, u32 pts_stamp)
169 linemask[0] |= (1 << l); 169 linemask[0] |= (1 << l);
170 else 170 else
171 linemask[1] |= (1 << (l - 32)); 171 linemask[1] |= (1 << (l - 32));
172 dst[sd + 12 + line * 43] = service2vbi(itv->vbi.sliced_data[i].id); 172 dst[sd + 12 + line * 43] =
173 ivtv_service2vbi(itv->vbi.sliced_data[i].id);
173 memcpy(dst + sd + 12 + line * 43 + 1, itv->vbi.sliced_data[i].data, 42); 174 memcpy(dst + sd + 12 + line * 43 + 1, itv->vbi.sliced_data[i].data, 42);
174 line++; 175 line++;
175 } 176 }
diff --git a/drivers/media/video/ivtv/ivtv-yuv.c b/drivers/media/video/ivtv/ivtv-yuv.c
index 62f70bd5e3cb..a9417f6e4087 100644
--- a/drivers/media/video/ivtv/ivtv-yuv.c
+++ b/drivers/media/video/ivtv/ivtv-yuv.c
@@ -908,7 +908,7 @@ static void ivtv_yuv_init(struct ivtv *itv)
908 } 908 }
909 909
910 /* We need a buffer for blanking when Y plane is offset - non-fatal if we can't get one */ 910 /* We need a buffer for blanking when Y plane is offset - non-fatal if we can't get one */
911 yi->blanking_ptr = kzalloc(720 * 16, GFP_KERNEL); 911 yi->blanking_ptr = kzalloc(720 * 16, GFP_KERNEL|__GFP_NOWARN);
912 if (yi->blanking_ptr) { 912 if (yi->blanking_ptr) {
913 yi->blanking_dmaptr = pci_map_single(itv->dev, yi->blanking_ptr, 720*16, PCI_DMA_TODEVICE); 913 yi->blanking_dmaptr = pci_map_single(itv->dev, yi->blanking_ptr, 720*16, PCI_DMA_TODEVICE);
914 } else { 914 } else {
diff --git a/drivers/media/video/ivtv/ivtvfb.c b/drivers/media/video/ivtv/ivtvfb.c
index df789f683e63..73be154f7f05 100644
--- a/drivers/media/video/ivtv/ivtvfb.c
+++ b/drivers/media/video/ivtv/ivtvfb.c
@@ -948,7 +948,8 @@ static int ivtvfb_init_vidmode(struct ivtv *itv)
948 } 948 }
949 949
950 /* Allocate the pseudo palette */ 950 /* Allocate the pseudo palette */
951 oi->ivtvfb_info.pseudo_palette = kmalloc(sizeof(u32) * 16, GFP_KERNEL); 951 oi->ivtvfb_info.pseudo_palette =
952 kmalloc(sizeof(u32) * 16, GFP_KERNEL|__GFP_NOWARN);
952 953
953 if (!oi->ivtvfb_info.pseudo_palette) { 954 if (!oi->ivtvfb_info.pseudo_palette) {
954 IVTVFB_ERR("abort, unable to alloc pseudo pallete\n"); 955 IVTVFB_ERR("abort, unable to alloc pseudo pallete\n");
@@ -1056,7 +1057,8 @@ static int ivtvfb_init_card(struct ivtv *itv)
1056 return -EBUSY; 1057 return -EBUSY;
1057 } 1058 }
1058 1059
1059 itv->osd_info = kzalloc(sizeof(struct osd_info), GFP_ATOMIC); 1060 itv->osd_info = kzalloc(sizeof(struct osd_info),
1061 GFP_ATOMIC|__GFP_NOWARN);
1060 if (itv->osd_info == NULL) { 1062 if (itv->osd_info == NULL) {
1061 IVTVFB_ERR("Failed to allocate memory for osd_info\n"); 1063 IVTVFB_ERR("Failed to allocate memory for osd_info\n");
1062 return -ENOMEM; 1064 return -ENOMEM;
diff --git a/drivers/media/video/mt9m001.c b/drivers/media/video/mt9m001.c
index 179e47049a45..ee43499544c1 100644
--- a/drivers/media/video/mt9m001.c
+++ b/drivers/media/video/mt9m001.c
@@ -12,15 +12,12 @@
12#include <linux/slab.h> 12#include <linux/slab.h>
13#include <linux/i2c.h> 13#include <linux/i2c.h>
14#include <linux/log2.h> 14#include <linux/log2.h>
15#include <linux/gpio.h>
15 16
16#include <media/v4l2-common.h> 17#include <media/v4l2-common.h>
17#include <media/v4l2-chip-ident.h> 18#include <media/v4l2-chip-ident.h>
18#include <media/soc_camera.h> 19#include <media/soc_camera.h>
19 20
20#ifdef CONFIG_MT9M001_PCA9536_SWITCH
21#include <asm/gpio.h>
22#endif
23
24/* mt9m001 i2c address 0x5d 21/* mt9m001 i2c address 0x5d
25 * The platform has to define i2c_board_info 22 * The platform has to define i2c_board_info
26 * and call i2c_register_board_info() */ 23 * and call i2c_register_board_info() */
diff --git a/drivers/media/video/mt9v022.c b/drivers/media/video/mt9v022.c
index d1391ac55096..1658fe590392 100644
--- a/drivers/media/video/mt9v022.c
+++ b/drivers/media/video/mt9v022.c
@@ -13,15 +13,12 @@
13#include <linux/i2c.h> 13#include <linux/i2c.h>
14#include <linux/delay.h> 14#include <linux/delay.h>
15#include <linux/log2.h> 15#include <linux/log2.h>
16#include <linux/gpio.h>
16 17
17#include <media/v4l2-common.h> 18#include <media/v4l2-common.h>
18#include <media/v4l2-chip-ident.h> 19#include <media/v4l2-chip-ident.h>
19#include <media/soc_camera.h> 20#include <media/soc_camera.h>
20 21
21#ifdef CONFIG_MT9M001_PCA9536_SWITCH
22#include <asm/gpio.h>
23#endif
24
25/* mt9v022 i2c address 0x48, 0x4c, 0x58, 0x5c 22/* mt9v022 i2c address 0x48, 0x4c, 0x58, 0x5c
26 * The platform has to define i2c_board_info 23 * The platform has to define i2c_board_info
27 * and call i2c_register_board_info() */ 24 * and call i2c_register_board_info() */
@@ -91,7 +88,7 @@ static const struct soc_camera_data_format mt9v022_monochrome_formats[] = {
91struct mt9v022 { 88struct mt9v022 {
92 struct i2c_client *client; 89 struct i2c_client *client;
93 struct soc_camera_device icd; 90 struct soc_camera_device icd;
94 int model; /* V4L2_IDENT_MT9M001* codes from v4l2-chip-ident.h */ 91 int model; /* V4L2_IDENT_MT9V022* codes from v4l2-chip-ident.h */
95 int switch_gpio; 92 int switch_gpio;
96 u16 chip_control; 93 u16 chip_control;
97 unsigned char datawidth; 94 unsigned char datawidth;
diff --git a/drivers/media/video/pvrusb2/Kconfig b/drivers/media/video/pvrusb2/Kconfig
index 9620c67fae77..4482b2c72ced 100644
--- a/drivers/media/video/pvrusb2/Kconfig
+++ b/drivers/media/video/pvrusb2/Kconfig
@@ -1,8 +1,10 @@
1config VIDEO_PVRUSB2 1config VIDEO_PVRUSB2
2 tristate "Hauppauge WinTV-PVR USB2 support" 2 tristate "Hauppauge WinTV-PVR USB2 support"
3 depends on VIDEO_V4L2 && I2C 3 depends on VIDEO_V4L2 && I2C
4 depends on VIDEO_MEDIA # Avoids pvrusb = Y / DVB = M
5 depends on HOTPLUG # due to FW_LOADER
4 select FW_LOADER 6 select FW_LOADER
5 select MEDIA_TUNER 7 select VIDEO_TUNER
6 select VIDEO_TVEEPROM 8 select VIDEO_TVEEPROM
7 select VIDEO_CX2341X 9 select VIDEO_CX2341X
8 select VIDEO_SAA711X 10 select VIDEO_SAA711X
diff --git a/drivers/media/video/saa7134/Kconfig b/drivers/media/video/saa7134/Kconfig
index 40e4c3bd2cb9..83f076abce35 100644
--- a/drivers/media/video/saa7134/Kconfig
+++ b/drivers/media/video/saa7134/Kconfig
@@ -3,7 +3,7 @@ config VIDEO_SAA7134
3 depends on VIDEO_DEV && PCI && I2C && INPUT 3 depends on VIDEO_DEV && PCI && I2C && INPUT
4 select VIDEOBUF_DMA_SG 4 select VIDEOBUF_DMA_SG
5 select VIDEO_IR 5 select VIDEO_IR
6 select MEDIA_TUNER 6 select VIDEO_TUNER
7 select VIDEO_TVEEPROM 7 select VIDEO_TVEEPROM
8 select CRC32 8 select CRC32
9 ---help--- 9 ---help---
@@ -27,6 +27,7 @@ config VIDEO_SAA7134_ALSA
27config VIDEO_SAA7134_DVB 27config VIDEO_SAA7134_DVB
28 tristate "DVB/ATSC Support for saa7134 based TV cards" 28 tristate "DVB/ATSC Support for saa7134 based TV cards"
29 depends on VIDEO_SAA7134 && DVB_CORE 29 depends on VIDEO_SAA7134 && DVB_CORE
30 depends on HOTPLUG # due to FW_LOADER
30 select VIDEOBUF_DVB 31 select VIDEOBUF_DVB
31 select FW_LOADER 32 select FW_LOADER
32 select DVB_PLL if !DVB_FE_CUSTOMISE 33 select DVB_PLL if !DVB_FE_CUSTOMISE
diff --git a/drivers/media/video/saa7134/saa7134-core.c b/drivers/media/video/saa7134/saa7134-core.c
index eec127864fe3..2c19cd0113c8 100644
--- a/drivers/media/video/saa7134/saa7134-core.c
+++ b/drivers/media/video/saa7134/saa7134-core.c
@@ -864,7 +864,6 @@ static int __devinit saa7134_initdev(struct pci_dev *pci_dev,
864 struct saa7134_dev *dev; 864 struct saa7134_dev *dev;
865 struct saa7134_mpeg_ops *mops; 865 struct saa7134_mpeg_ops *mops;
866 int err; 866 int err;
867 int mask;
868 867
869 if (saa7134_devcount == SAA7134_MAXBOARDS) 868 if (saa7134_devcount == SAA7134_MAXBOARDS)
870 return -ENOMEM; 869 return -ENOMEM;
@@ -1065,11 +1064,6 @@ static int __devinit saa7134_initdev(struct pci_dev *pci_dev,
1065 if (TUNER_ABSENT != dev->tuner_type) 1064 if (TUNER_ABSENT != dev->tuner_type)
1066 saa7134_i2c_call_clients(dev, TUNER_SET_STANDBY, NULL); 1065 saa7134_i2c_call_clients(dev, TUNER_SET_STANDBY, NULL);
1067 1066
1068 if (card(dev).gpiomask != 0) {
1069 mask = card(dev).gpiomask;
1070 saa_andorl(SAA7134_GPIO_GPMODE0 >> 2, mask, mask);
1071 saa_andorl(SAA7134_GPIO_GPSTATUS0 >> 2, mask, 0);
1072 }
1073 return 0; 1067 return 0;
1074 1068
1075 fail4: 1069 fail4:
diff --git a/drivers/media/video/saa7134/saa7134-dvb.c b/drivers/media/video/saa7134/saa7134-dvb.c
index 2d16be2259db..469f93aac008 100644
--- a/drivers/media/video/saa7134/saa7134-dvb.c
+++ b/drivers/media/video/saa7134/saa7134-dvb.c
@@ -538,19 +538,23 @@ static int philips_tda827x_tuner_sleep(struct dvb_frontend *fe)
538 return 0; 538 return 0;
539} 539}
540 540
541static void configure_tda827x_fe(struct saa7134_dev *dev, struct tda1004x_config *cdec_conf, 541static int configure_tda827x_fe(struct saa7134_dev *dev,
542 struct tda827x_config *tuner_conf) 542 struct tda1004x_config *cdec_conf,
543 struct tda827x_config *tuner_conf)
543{ 544{
544 dev->dvb.frontend = dvb_attach(tda10046_attach, cdec_conf, &dev->i2c_adap); 545 dev->dvb.frontend = dvb_attach(tda10046_attach, cdec_conf, &dev->i2c_adap);
545 if (dev->dvb.frontend) { 546 if (dev->dvb.frontend) {
546 if (cdec_conf->i2c_gate) 547 if (cdec_conf->i2c_gate)
547 dev->dvb.frontend->ops.i2c_gate_ctrl = tda8290_i2c_gate_ctrl; 548 dev->dvb.frontend->ops.i2c_gate_ctrl = tda8290_i2c_gate_ctrl;
548 if (dvb_attach(tda827x_attach, dev->dvb.frontend, cdec_conf->tuner_address, 549 if (dvb_attach(tda827x_attach, dev->dvb.frontend,
549 &dev->i2c_adap, tuner_conf) == NULL) { 550 cdec_conf->tuner_address,
550 wprintk("no tda827x tuner found at addr: %02x\n", 551 &dev->i2c_adap, tuner_conf))
552 return 0;
553
554 wprintk("no tda827x tuner found at addr: %02x\n",
551 cdec_conf->tuner_address); 555 cdec_conf->tuner_address);
552 }
553 } 556 }
557 return -EINVAL;
554} 558}
555 559
556/* ------------------------------------------------------------------ */ 560/* ------------------------------------------------------------------ */
@@ -997,7 +1001,9 @@ static int dvb_init(struct saa7134_dev *dev)
997 break; 1001 break;
998 case SAA7134_BOARD_FLYDVBTDUO: 1002 case SAA7134_BOARD_FLYDVBTDUO:
999 case SAA7134_BOARD_FLYDVBT_DUO_CARDBUS: 1003 case SAA7134_BOARD_FLYDVBT_DUO_CARDBUS:
1000 configure_tda827x_fe(dev, &tda827x_lifeview_config, &tda827x_cfg_0); 1004 if (configure_tda827x_fe(dev, &tda827x_lifeview_config,
1005 &tda827x_cfg_0) < 0)
1006 goto dettach_frontend;
1001 break; 1007 break;
1002 case SAA7134_BOARD_PHILIPS_EUROPA: 1008 case SAA7134_BOARD_PHILIPS_EUROPA:
1003 case SAA7134_BOARD_VIDEOMATE_DVBT_300: 1009 case SAA7134_BOARD_VIDEOMATE_DVBT_300:
@@ -1022,36 +1028,52 @@ static int dvb_init(struct saa7134_dev *dev)
1022 } 1028 }
1023 break; 1029 break;
1024 case SAA7134_BOARD_KWORLD_DVBT_210: 1030 case SAA7134_BOARD_KWORLD_DVBT_210:
1025 configure_tda827x_fe(dev, &kworld_dvb_t_210_config, &tda827x_cfg_2); 1031 if (configure_tda827x_fe(dev, &kworld_dvb_t_210_config,
1032 &tda827x_cfg_2) < 0)
1033 goto dettach_frontend;
1026 break; 1034 break;
1027 case SAA7134_BOARD_PHILIPS_TIGER: 1035 case SAA7134_BOARD_PHILIPS_TIGER:
1028 configure_tda827x_fe(dev, &philips_tiger_config, &tda827x_cfg_0); 1036 if (configure_tda827x_fe(dev, &philips_tiger_config,
1037 &tda827x_cfg_0) < 0)
1038 goto dettach_frontend;
1029 break; 1039 break;
1030 case SAA7134_BOARD_PINNACLE_PCTV_310i: 1040 case SAA7134_BOARD_PINNACLE_PCTV_310i:
1031 configure_tda827x_fe(dev, &pinnacle_pctv_310i_config, &tda827x_cfg_1); 1041 if (configure_tda827x_fe(dev, &pinnacle_pctv_310i_config,
1042 &tda827x_cfg_1) < 0)
1043 goto dettach_frontend;
1032 break; 1044 break;
1033 case SAA7134_BOARD_HAUPPAUGE_HVR1110: 1045 case SAA7134_BOARD_HAUPPAUGE_HVR1110:
1034 configure_tda827x_fe(dev, &hauppauge_hvr_1110_config, &tda827x_cfg_1); 1046 if (configure_tda827x_fe(dev, &hauppauge_hvr_1110_config,
1047 &tda827x_cfg_1) < 0)
1048 goto dettach_frontend;
1035 break; 1049 break;
1036 case SAA7134_BOARD_ASUSTeK_P7131_DUAL: 1050 case SAA7134_BOARD_ASUSTeK_P7131_DUAL:
1037 configure_tda827x_fe(dev, &asus_p7131_dual_config, &tda827x_cfg_0); 1051 if (configure_tda827x_fe(dev, &asus_p7131_dual_config,
1052 &tda827x_cfg_0) < 0)
1053 goto dettach_frontend;
1038 break; 1054 break;
1039 case SAA7134_BOARD_FLYDVBT_LR301: 1055 case SAA7134_BOARD_FLYDVBT_LR301:
1040 configure_tda827x_fe(dev, &tda827x_lifeview_config, &tda827x_cfg_0); 1056 if (configure_tda827x_fe(dev, &tda827x_lifeview_config,
1057 &tda827x_cfg_0) < 0)
1058 goto dettach_frontend;
1041 break; 1059 break;
1042 case SAA7134_BOARD_FLYDVB_TRIO: 1060 case SAA7134_BOARD_FLYDVB_TRIO:
1043 if(! use_frontend) { /* terrestrial */ 1061 if (!use_frontend) { /* terrestrial */
1044 configure_tda827x_fe(dev, &lifeview_trio_config, &tda827x_cfg_0); 1062 if (configure_tda827x_fe(dev, &lifeview_trio_config,
1063 &tda827x_cfg_0) < 0)
1064 goto dettach_frontend;
1045 } else { /* satellite */ 1065 } else { /* satellite */
1046 dev->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs, &dev->i2c_adap); 1066 dev->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs, &dev->i2c_adap);
1047 if (dev->dvb.frontend) { 1067 if (dev->dvb.frontend) {
1048 if (dvb_attach(tda826x_attach, dev->dvb.frontend, 0x63, 1068 if (dvb_attach(tda826x_attach, dev->dvb.frontend, 0x63,
1049 &dev->i2c_adap, 0) == NULL) { 1069 &dev->i2c_adap, 0) == NULL) {
1050 wprintk("%s: Lifeview Trio, No tda826x found!\n", __func__); 1070 wprintk("%s: Lifeview Trio, No tda826x found!\n", __func__);
1071 goto dettach_frontend;
1051 } 1072 }
1052 if (dvb_attach(isl6421_attach, dev->dvb.frontend, &dev->i2c_adap, 1073 if (dvb_attach(isl6421_attach, dev->dvb.frontend, &dev->i2c_adap,
1053 0x08, 0, 0) == NULL) { 1074 0x08, 0, 0) == NULL) {
1054 wprintk("%s: Lifeview Trio, No ISL6421 found!\n", __func__); 1075 wprintk("%s: Lifeview Trio, No ISL6421 found!\n", __func__);
1076 goto dettach_frontend;
1055 } 1077 }
1056 } 1078 }
1057 } 1079 }
@@ -1067,15 +1089,20 @@ static int dvb_init(struct saa7134_dev *dev)
1067 &ads_duo_cfg) == NULL) { 1089 &ads_duo_cfg) == NULL) {
1068 wprintk("no tda827x tuner found at addr: %02x\n", 1090 wprintk("no tda827x tuner found at addr: %02x\n",
1069 ads_tech_duo_config.tuner_address); 1091 ads_tech_duo_config.tuner_address);
1092 goto dettach_frontend;
1070 } 1093 }
1071 } 1094 }
1072 break; 1095 break;
1073 case SAA7134_BOARD_TEVION_DVBT_220RF: 1096 case SAA7134_BOARD_TEVION_DVBT_220RF:
1074 configure_tda827x_fe(dev, &tevion_dvbt220rf_config, &tda827x_cfg_0); 1097 if (configure_tda827x_fe(dev, &tevion_dvbt220rf_config,
1098 &tda827x_cfg_0) < 0)
1099 goto dettach_frontend;
1075 break; 1100 break;
1076 case SAA7134_BOARD_MEDION_MD8800_QUADRO: 1101 case SAA7134_BOARD_MEDION_MD8800_QUADRO:
1077 if (!use_frontend) { /* terrestrial */ 1102 if (!use_frontend) { /* terrestrial */
1078 configure_tda827x_fe(dev, &md8800_dvbt_config, &tda827x_cfg_0); 1103 if (configure_tda827x_fe(dev, &md8800_dvbt_config,
1104 &tda827x_cfg_0) < 0)
1105 goto dettach_frontend;
1079 } else { /* satellite */ 1106 } else { /* satellite */
1080 dev->dvb.frontend = dvb_attach(tda10086_attach, 1107 dev->dvb.frontend = dvb_attach(tda10086_attach,
1081 &flydvbs, &dev->i2c_adap); 1108 &flydvbs, &dev->i2c_adap);
@@ -1086,16 +1113,20 @@ static int dvb_init(struct saa7134_dev *dev)
1086 struct i2c_msg msg = {.addr = 0x08, .flags = 0, .len = 1}; 1113 struct i2c_msg msg = {.addr = 0x08, .flags = 0, .len = 1};
1087 1114
1088 if (dvb_attach(tda826x_attach, dev->dvb.frontend, 1115 if (dvb_attach(tda826x_attach, dev->dvb.frontend,
1089 0x60, &dev->i2c_adap, 0) == NULL) 1116 0x60, &dev->i2c_adap, 0) == NULL) {
1090 wprintk("%s: Medion Quadro, no tda826x " 1117 wprintk("%s: Medion Quadro, no tda826x "
1091 "found !\n", __func__); 1118 "found !\n", __func__);
1119 goto dettach_frontend;
1120 }
1092 if (dev_id != 0x08) { 1121 if (dev_id != 0x08) {
1093 /* we need to open the i2c gate (we know it exists) */ 1122 /* we need to open the i2c gate (we know it exists) */
1094 fe->ops.i2c_gate_ctrl(fe, 1); 1123 fe->ops.i2c_gate_ctrl(fe, 1);
1095 if (dvb_attach(isl6405_attach, fe, 1124 if (dvb_attach(isl6405_attach, fe,
1096 &dev->i2c_adap, 0x08, 0, 0) == NULL) 1125 &dev->i2c_adap, 0x08, 0, 0) == NULL) {
1097 wprintk("%s: Medion Quadro, no ISL6405 " 1126 wprintk("%s: Medion Quadro, no ISL6405 "
1098 "found !\n", __func__); 1127 "found !\n", __func__);
1128 goto dettach_frontend;
1129 }
1099 if (dev_id == 0x07) { 1130 if (dev_id == 0x07) {
1100 /* fire up the 2nd section of the LNB supply since 1131 /* fire up the 2nd section of the LNB supply since
1101 we can't do this from the other section */ 1132 we can't do this from the other section */
@@ -1117,19 +1148,17 @@ static int dvb_init(struct saa7134_dev *dev)
1117 case SAA7134_BOARD_AVERMEDIA_AVERTVHD_A180: 1148 case SAA7134_BOARD_AVERMEDIA_AVERTVHD_A180:
1118 dev->dvb.frontend = dvb_attach(nxt200x_attach, &avertvhda180, 1149 dev->dvb.frontend = dvb_attach(nxt200x_attach, &avertvhda180,
1119 &dev->i2c_adap); 1150 &dev->i2c_adap);
1120 if (dev->dvb.frontend) { 1151 if (dev->dvb.frontend)
1121 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61, 1152 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61,
1122 NULL, DVB_PLL_TDHU2); 1153 NULL, DVB_PLL_TDHU2);
1123 }
1124 break; 1154 break;
1125 case SAA7134_BOARD_KWORLD_ATSC110: 1155 case SAA7134_BOARD_KWORLD_ATSC110:
1126 dev->dvb.frontend = dvb_attach(nxt200x_attach, &kworldatsc110, 1156 dev->dvb.frontend = dvb_attach(nxt200x_attach, &kworldatsc110,
1127 &dev->i2c_adap); 1157 &dev->i2c_adap);
1128 if (dev->dvb.frontend) { 1158 if (dev->dvb.frontend)
1129 dvb_attach(simple_tuner_attach, dev->dvb.frontend, 1159 dvb_attach(simple_tuner_attach, dev->dvb.frontend,
1130 &dev->i2c_adap, 0x61, 1160 &dev->i2c_adap, 0x61,
1131 TUNER_PHILIPS_TUV1236D); 1161 TUNER_PHILIPS_TUV1236D);
1132 }
1133 break; 1162 break;
1134 case SAA7134_BOARD_FLYDVBS_LR300: 1163 case SAA7134_BOARD_FLYDVBS_LR300:
1135 dev->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs, 1164 dev->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs,
@@ -1138,10 +1167,12 @@ static int dvb_init(struct saa7134_dev *dev)
1138 if (dvb_attach(tda826x_attach, dev->dvb.frontend, 0x60, 1167 if (dvb_attach(tda826x_attach, dev->dvb.frontend, 0x60,
1139 &dev->i2c_adap, 0) == NULL) { 1168 &dev->i2c_adap, 0) == NULL) {
1140 wprintk("%s: No tda826x found!\n", __func__); 1169 wprintk("%s: No tda826x found!\n", __func__);
1170 goto dettach_frontend;
1141 } 1171 }
1142 if (dvb_attach(isl6421_attach, dev->dvb.frontend, 1172 if (dvb_attach(isl6421_attach, dev->dvb.frontend,
1143 &dev->i2c_adap, 0x08, 0, 0) == NULL) { 1173 &dev->i2c_adap, 0x08, 0, 0) == NULL) {
1144 wprintk("%s: No ISL6421 found!\n", __func__); 1174 wprintk("%s: No ISL6421 found!\n", __func__);
1175 goto dettach_frontend;
1145 } 1176 }
1146 } 1177 }
1147 break; 1178 break;
@@ -1168,43 +1199,65 @@ static int dvb_init(struct saa7134_dev *dev)
1168 } 1199 }
1169 break; 1200 break;
1170 case SAA7134_BOARD_CINERGY_HT_PCMCIA: 1201 case SAA7134_BOARD_CINERGY_HT_PCMCIA:
1171 configure_tda827x_fe(dev, &cinergy_ht_config, &tda827x_cfg_0); 1202 if (configure_tda827x_fe(dev, &cinergy_ht_config,
1203 &tda827x_cfg_0) < 0)
1204 goto dettach_frontend;
1172 break; 1205 break;
1173 case SAA7134_BOARD_CINERGY_HT_PCI: 1206 case SAA7134_BOARD_CINERGY_HT_PCI:
1174 configure_tda827x_fe(dev, &cinergy_ht_pci_config, &tda827x_cfg_0); 1207 if (configure_tda827x_fe(dev, &cinergy_ht_pci_config,
1208 &tda827x_cfg_0) < 0)
1209 goto dettach_frontend;
1175 break; 1210 break;
1176 case SAA7134_BOARD_PHILIPS_TIGER_S: 1211 case SAA7134_BOARD_PHILIPS_TIGER_S:
1177 configure_tda827x_fe(dev, &philips_tiger_s_config, &tda827x_cfg_2); 1212 if (configure_tda827x_fe(dev, &philips_tiger_s_config,
1213 &tda827x_cfg_2) < 0)
1214 goto dettach_frontend;
1178 break; 1215 break;
1179 case SAA7134_BOARD_ASUS_P7131_4871: 1216 case SAA7134_BOARD_ASUS_P7131_4871:
1180 configure_tda827x_fe(dev, &asus_p7131_4871_config, &tda827x_cfg_2); 1217 if (configure_tda827x_fe(dev, &asus_p7131_4871_config,
1218 &tda827x_cfg_2) < 0)
1219 goto dettach_frontend;
1181 break; 1220 break;
1182 case SAA7134_BOARD_ASUSTeK_P7131_HYBRID_LNA: 1221 case SAA7134_BOARD_ASUSTeK_P7131_HYBRID_LNA:
1183 configure_tda827x_fe(dev, &asus_p7131_hybrid_lna_config, &tda827x_cfg_2); 1222 if (configure_tda827x_fe(dev, &asus_p7131_hybrid_lna_config,
1223 &tda827x_cfg_2) < 0)
1224 goto dettach_frontend;
1184 break; 1225 break;
1185 case SAA7134_BOARD_AVERMEDIA_SUPER_007: 1226 case SAA7134_BOARD_AVERMEDIA_SUPER_007:
1186 configure_tda827x_fe(dev, &avermedia_super_007_config, &tda827x_cfg_0); 1227 if (configure_tda827x_fe(dev, &avermedia_super_007_config,
1228 &tda827x_cfg_0) < 0)
1229 goto dettach_frontend;
1187 break; 1230 break;
1188 case SAA7134_BOARD_TWINHAN_DTV_DVB_3056: 1231 case SAA7134_BOARD_TWINHAN_DTV_DVB_3056:
1189 configure_tda827x_fe(dev, &twinhan_dtv_dvb_3056_config, &tda827x_cfg_2_sw42); 1232 if (configure_tda827x_fe(dev, &twinhan_dtv_dvb_3056_config,
1233 &tda827x_cfg_2_sw42) < 0)
1234 goto dettach_frontend;
1190 break; 1235 break;
1191 case SAA7134_BOARD_PHILIPS_SNAKE: 1236 case SAA7134_BOARD_PHILIPS_SNAKE:
1192 dev->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs, 1237 dev->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs,
1193 &dev->i2c_adap); 1238 &dev->i2c_adap);
1194 if (dev->dvb.frontend) { 1239 if (dev->dvb.frontend) {
1195 if (dvb_attach(tda826x_attach, dev->dvb.frontend, 0x60, 1240 if (dvb_attach(tda826x_attach, dev->dvb.frontend, 0x60,
1196 &dev->i2c_adap, 0) == NULL) 1241 &dev->i2c_adap, 0) == NULL) {
1197 wprintk("%s: No tda826x found!\n", __func__); 1242 wprintk("%s: No tda826x found!\n", __func__);
1243 goto dettach_frontend;
1244 }
1198 if (dvb_attach(lnbp21_attach, dev->dvb.frontend, 1245 if (dvb_attach(lnbp21_attach, dev->dvb.frontend,
1199 &dev->i2c_adap, 0, 0) == NULL) 1246 &dev->i2c_adap, 0, 0) == NULL) {
1200 wprintk("%s: No lnbp21 found!\n", __func__); 1247 wprintk("%s: No lnbp21 found!\n", __func__);
1248 goto dettach_frontend;
1249 }
1201 } 1250 }
1202 break; 1251 break;
1203 case SAA7134_BOARD_CREATIX_CTX953: 1252 case SAA7134_BOARD_CREATIX_CTX953:
1204 configure_tda827x_fe(dev, &md8800_dvbt_config, &tda827x_cfg_0); 1253 if (configure_tda827x_fe(dev, &md8800_dvbt_config,
1254 &tda827x_cfg_0) < 0)
1255 goto dettach_frontend;
1205 break; 1256 break;
1206 case SAA7134_BOARD_MSI_TVANYWHERE_AD11: 1257 case SAA7134_BOARD_MSI_TVANYWHERE_AD11:
1207 configure_tda827x_fe(dev, &philips_tiger_s_config, &tda827x_cfg_2); 1258 if (configure_tda827x_fe(dev, &philips_tiger_s_config,
1259 &tda827x_cfg_2) < 0)
1260 goto dettach_frontend;
1208 break; 1261 break;
1209 case SAA7134_BOARD_AVERMEDIA_CARDBUS_506: 1262 case SAA7134_BOARD_AVERMEDIA_CARDBUS_506:
1210 dev->dvb.frontend = dvb_attach(mt352_attach, 1263 dev->dvb.frontend = dvb_attach(mt352_attach,
@@ -1218,16 +1271,20 @@ static int dvb_init(struct saa7134_dev *dev)
1218 if (dev->dvb.frontend) { 1271 if (dev->dvb.frontend) {
1219 struct dvb_frontend *fe; 1272 struct dvb_frontend *fe;
1220 if (dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x60, 1273 if (dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x60,
1221 &dev->i2c_adap, DVB_PLL_PHILIPS_SD1878_TDA8261) == NULL) 1274 &dev->i2c_adap, DVB_PLL_PHILIPS_SD1878_TDA8261) == NULL) {
1222 wprintk("%s: MD7134 DVB-S, no SD1878 " 1275 wprintk("%s: MD7134 DVB-S, no SD1878 "
1223 "found !\n", __func__); 1276 "found !\n", __func__);
1277 goto dettach_frontend;
1278 }
1224 /* we need to open the i2c gate (we know it exists) */ 1279 /* we need to open the i2c gate (we know it exists) */
1225 fe = dev->dvb.frontend; 1280 fe = dev->dvb.frontend;
1226 fe->ops.i2c_gate_ctrl(fe, 1); 1281 fe->ops.i2c_gate_ctrl(fe, 1);
1227 if (dvb_attach(isl6405_attach, fe, 1282 if (dvb_attach(isl6405_attach, fe,
1228 &dev->i2c_adap, 0x08, 0, 0) == NULL) 1283 &dev->i2c_adap, 0x08, 0, 0) == NULL) {
1229 wprintk("%s: MD7134 DVB-S, no ISL6405 " 1284 wprintk("%s: MD7134 DVB-S, no ISL6405 "
1230 "found !\n", __func__); 1285 "found !\n", __func__);
1286 goto dettach_frontend;
1287 }
1231 fe->ops.i2c_gate_ctrl(fe, 0); 1288 fe->ops.i2c_gate_ctrl(fe, 0);
1232 dev->original_set_voltage = fe->ops.set_voltage; 1289 dev->original_set_voltage = fe->ops.set_voltage;
1233 fe->ops.set_voltage = md8800_set_voltage; 1290 fe->ops.set_voltage = md8800_set_voltage;
@@ -1254,10 +1311,7 @@ static int dvb_init(struct saa7134_dev *dev)
1254 if (!fe) { 1311 if (!fe) {
1255 printk(KERN_ERR "%s/2: xc3028 attach failed\n", 1312 printk(KERN_ERR "%s/2: xc3028 attach failed\n",
1256 dev->name); 1313 dev->name);
1257 dvb_frontend_detach(dev->dvb.frontend); 1314 goto dettach_frontend;
1258 dvb_unregister_frontend(dev->dvb.frontend);
1259 dev->dvb.frontend = NULL;
1260 return -1;
1261 } 1315 }
1262 } 1316 }
1263 1317
@@ -1282,6 +1336,12 @@ static int dvb_init(struct saa7134_dev *dev)
1282 dev->dvb.frontend->ops.tuner_ops.sleep(dev->dvb.frontend); 1336 dev->dvb.frontend->ops.tuner_ops.sleep(dev->dvb.frontend);
1283 } 1337 }
1284 return ret; 1338 return ret;
1339
1340dettach_frontend:
1341 dvb_frontend_detach(dev->dvb.frontend);
1342 dev->dvb.frontend = NULL;
1343
1344 return -1;
1285} 1345}
1286 1346
1287static int dvb_fini(struct saa7134_dev *dev) 1347static int dvb_fini(struct saa7134_dev *dev)
diff --git a/drivers/media/video/stk-webcam.c b/drivers/media/video/stk-webcam.c
index 9276ed997388..b12c60cf5a09 100644
--- a/drivers/media/video/stk-webcam.c
+++ b/drivers/media/video/stk-webcam.c
@@ -30,6 +30,7 @@
30#include <linux/kref.h> 30#include <linux/kref.h>
31 31
32#include <linux/usb.h> 32#include <linux/usb.h>
33#include <linux/mm.h>
33#include <linux/vmalloc.h> 34#include <linux/vmalloc.h>
34#include <linux/videodev2.h> 35#include <linux/videodev2.h>
35#include <media/v4l2-common.h> 36#include <media/v4l2-common.h>
@@ -245,6 +246,8 @@ static int stk_initialise(struct stk_camera *dev)
245 return -1; 246 return -1;
246} 247}
247 248
249#ifdef CONFIG_VIDEO_V4L1_COMPAT
250
248/* sysfs functions */ 251/* sysfs functions */
249/*FIXME cleanup this */ 252/*FIXME cleanup this */
250 253
@@ -350,6 +353,10 @@ static void stk_remove_sysfs_files(struct video_device *vdev)
350 video_device_remove_file(vdev, &dev_attr_vflip); 353 video_device_remove_file(vdev, &dev_attr_vflip);
351} 354}
352 355
356#else
357#define stk_create_sysfs_files(a)
358#define stk_remove_sysfs_files(a)
359#endif
353 360
354/* *********************************************** */ 361/* *********************************************** */
355/* 362/*
diff --git a/drivers/media/video/tuner-core.c b/drivers/media/video/tuner-core.c
index 6bf104ea051d..5a75788b92ae 100644
--- a/drivers/media/video/tuner-core.c
+++ b/drivers/media/video/tuner-core.c
@@ -40,11 +40,11 @@
40 typeof(&FUNCTION) __a = symbol_request(FUNCTION); \ 40 typeof(&FUNCTION) __a = symbol_request(FUNCTION); \
41 if (__a) { \ 41 if (__a) { \
42 __r = (int) __a(ARGS); \ 42 __r = (int) __a(ARGS); \
43 symbol_put(FUNCTION); \
43 } else { \ 44 } else { \
44 printk(KERN_ERR "TUNER: Unable to find " \ 45 printk(KERN_ERR "TUNER: Unable to find " \
45 "symbol "#FUNCTION"()\n"); \ 46 "symbol "#FUNCTION"()\n"); \
46 } \ 47 } \
47 symbol_put(FUNCTION); \
48 __r; \ 48 __r; \
49}) 49})
50 50
@@ -340,16 +340,6 @@ static void tuner_i2c_address_check(struct tuner *t)
340 tuner_warn("====================== WARNING! ======================\n"); 340 tuner_warn("====================== WARNING! ======================\n");
341} 341}
342 342
343static void attach_tda829x(struct tuner *t)
344{
345 struct tda829x_config cfg = {
346 .lna_cfg = t->config,
347 .tuner_callback = t->tuner_callback,
348 };
349 dvb_attach(tda829x_attach,
350 &t->fe, t->i2c->adapter, t->i2c->addr, &cfg);
351}
352
353static struct xc5000_config xc5000_cfg; 343static struct xc5000_config xc5000_cfg;
354 344
355static void set_type(struct i2c_client *c, unsigned int type, 345static void set_type(struct i2c_client *c, unsigned int type,
@@ -385,12 +375,19 @@ static void set_type(struct i2c_client *c, unsigned int type,
385 375
386 switch (t->type) { 376 switch (t->type) {
387 case TUNER_MT2032: 377 case TUNER_MT2032:
388 dvb_attach(microtune_attach, 378 if (!dvb_attach(microtune_attach,
389 &t->fe, t->i2c->adapter, t->i2c->addr); 379 &t->fe, t->i2c->adapter, t->i2c->addr))
380 goto attach_failed;
390 break; 381 break;
391 case TUNER_PHILIPS_TDA8290: 382 case TUNER_PHILIPS_TDA8290:
392 { 383 {
393 attach_tda829x(t); 384 struct tda829x_config cfg = {
385 .lna_cfg = t->config,
386 .tuner_callback = t->tuner_callback,
387 };
388 if (!dvb_attach(tda829x_attach, &t->fe, t->i2c->adapter,
389 t->i2c->addr, &cfg))
390 goto attach_failed;
394 break; 391 break;
395 } 392 }
396 case TUNER_TEA5767: 393 case TUNER_TEA5767:
@@ -441,8 +438,9 @@ static void set_type(struct i2c_client *c, unsigned int type,
441 break; 438 break;
442 } 439 }
443 case TUNER_TDA9887: 440 case TUNER_TDA9887:
444 dvb_attach(tda9887_attach, 441 if (!dvb_attach(tda9887_attach,
445 &t->fe, t->i2c->adapter, t->i2c->addr); 442 &t->fe, t->i2c->adapter, t->i2c->addr))
443 goto attach_failed;
446 break; 444 break;
447 case TUNER_XC5000: 445 case TUNER_XC5000:
448 { 446 {
@@ -450,10 +448,10 @@ static void set_type(struct i2c_client *c, unsigned int type,
450 448
451 xc5000_cfg.i2c_address = t->i2c->addr; 449 xc5000_cfg.i2c_address = t->i2c->addr;
452 xc5000_cfg.if_khz = 5380; 450 xc5000_cfg.if_khz = 5380;
453 xc5000_cfg.priv = c->adapter->algo_data;
454 xc5000_cfg.tuner_callback = t->tuner_callback; 451 xc5000_cfg.tuner_callback = t->tuner_callback;
455 if (!dvb_attach(xc5000_attach, 452 if (!dvb_attach(xc5000_attach,
456 &t->fe, t->i2c->adapter, &xc5000_cfg)) 453 &t->fe, t->i2c->adapter, &xc5000_cfg,
454 c->adapter->algo_data))
457 goto attach_failed; 455 goto attach_failed;
458 456
459 xc_tuner_ops = &t->fe.ops.tuner_ops; 457 xc_tuner_ops = &t->fe.ops.tuner_ops;
@@ -1167,7 +1165,7 @@ static int tuner_probe(struct i2c_client *client,
1167 /* If chip is not tda8290, don't register. 1165 /* If chip is not tda8290, don't register.
1168 since it can be tda9887*/ 1166 since it can be tda9887*/
1169 if (tuner_symbol_probe(tda829x_probe, t->i2c->adapter, 1167 if (tuner_symbol_probe(tda829x_probe, t->i2c->adapter,
1170 t->i2c->addr) == 0) { 1168 t->i2c->addr) >= 0) {
1171 tuner_dbg("tda829x detected\n"); 1169 tuner_dbg("tda829x detected\n");
1172 } else { 1170 } else {
1173 /* Default is being tda9887 */ 1171 /* Default is being tda9887 */
@@ -1181,7 +1179,7 @@ static int tuner_probe(struct i2c_client *client,
1181 case 0x60: 1179 case 0x60:
1182 if (tuner_symbol_probe(tea5767_autodetection, 1180 if (tuner_symbol_probe(tea5767_autodetection,
1183 t->i2c->adapter, t->i2c->addr) 1181 t->i2c->adapter, t->i2c->addr)
1184 != EINVAL) { 1182 >= 0) {
1185 t->type = TUNER_TEA5767; 1183 t->type = TUNER_TEA5767;
1186 t->mode_mask = T_RADIO; 1184 t->mode_mask = T_RADIO;
1187 t->mode = T_STANDBY; 1185 t->mode = T_STANDBY;
diff --git a/drivers/media/video/tveeprom.c b/drivers/media/video/tveeprom.c
index 3cf8a8e801e5..9da0e1807ffb 100644
--- a/drivers/media/video/tveeprom.c
+++ b/drivers/media/video/tveeprom.c
@@ -319,10 +319,12 @@ audioIC[] =
319 {AUDIO_CHIP_INTERNAL, "CX25843"}, 319 {AUDIO_CHIP_INTERNAL, "CX25843"},
320 {AUDIO_CHIP_INTERNAL, "CX23418"}, 320 {AUDIO_CHIP_INTERNAL, "CX23418"},
321 {AUDIO_CHIP_INTERNAL, "CX23885"}, 321 {AUDIO_CHIP_INTERNAL, "CX23885"},
322 /* 40-42 */ 322 /* 40-44 */
323 {AUDIO_CHIP_INTERNAL, "CX23888"}, 323 {AUDIO_CHIP_INTERNAL, "CX23888"},
324 {AUDIO_CHIP_INTERNAL, "SAA7131"}, 324 {AUDIO_CHIP_INTERNAL, "SAA7131"},
325 {AUDIO_CHIP_INTERNAL, "CX23887"}, 325 {AUDIO_CHIP_INTERNAL, "CX23887"},
326 {AUDIO_CHIP_INTERNAL, "SAA7164"},
327 {AUDIO_CHIP_INTERNAL, "AU8522"},
326}; 328};
327 329
328/* This list is supplied by Hauppauge. Thanks! */ 330/* This list is supplied by Hauppauge. Thanks! */
@@ -341,8 +343,10 @@ static const char *decoderIC[] = {
341 "CX882", "TVP5150A", "CX25840", "CX25841", "CX25842", 343 "CX882", "TVP5150A", "CX25840", "CX25841", "CX25842",
342 /* 30-34 */ 344 /* 30-34 */
343 "CX25843", "CX23418", "NEC61153", "CX23885", "CX23888", 345 "CX25843", "CX23418", "NEC61153", "CX23885", "CX23888",
344 /* 35-37 */ 346 /* 35-39 */
345 "SAA7131", "CX25837", "CX23887" 347 "SAA7131", "CX25837", "CX23887", "CX23885A", "CX23887A",
348 /* 40-42 */
349 "SAA7164", "CX23885B", "AU8522"
346}; 350};
347 351
348static int hasRadioTuner(int tunerType) 352static int hasRadioTuner(int tunerType)
diff --git a/drivers/media/video/usbvision/Kconfig b/drivers/media/video/usbvision/Kconfig
index 74e1d3075a20..fc24ef05b3f3 100644
--- a/drivers/media/video/usbvision/Kconfig
+++ b/drivers/media/video/usbvision/Kconfig
@@ -1,7 +1,7 @@
1config VIDEO_USBVISION 1config VIDEO_USBVISION
2 tristate "USB video devices based on Nogatech NT1003/1004/1005" 2 tristate "USB video devices based on Nogatech NT1003/1004/1005"
3 depends on I2C && VIDEO_V4L2 3 depends on I2C && VIDEO_V4L2
4 select MEDIA_TUNER 4 select VIDEO_TUNER
5 select VIDEO_SAA711X if VIDEO_HELPER_CHIPS_AUTO 5 select VIDEO_SAA711X if VIDEO_HELPER_CHIPS_AUTO
6 ---help--- 6 ---help---
7 There are more than 50 different USB video devices based on 7 There are more than 50 different USB video devices based on
diff --git a/drivers/misc/sgi-xp/xp.h b/drivers/misc/sgi-xp/xp.h
index 5515234be86a..03a87a307e32 100644
--- a/drivers/misc/sgi-xp/xp.h
+++ b/drivers/misc/sgi-xp/xp.h
@@ -157,215 +157,136 @@ struct xpc_msg {
157/* 157/*
158 * Define the return values and values passed to user's callout functions. 158 * Define the return values and values passed to user's callout functions.
159 * (It is important to add new value codes at the end just preceding 159 * (It is important to add new value codes at the end just preceding
160 * xpcUnknownReason, which must have the highest numerical value.) 160 * xpUnknownReason, which must have the highest numerical value.)
161 */ 161 */
162enum xpc_retval { 162enum xp_retval {
163 xpcSuccess = 0, 163 xpSuccess = 0,
164 164
165 xpcNotConnected, /* 1: channel is not connected */ 165 xpNotConnected, /* 1: channel is not connected */
166 xpcConnected, /* 2: channel connected (opened) */ 166 xpConnected, /* 2: channel connected (opened) */
167 xpcRETIRED1, /* 3: (formerly xpcDisconnected) */ 167 xpRETIRED1, /* 3: (formerly xpDisconnected) */
168 168
169 xpcMsgReceived, /* 4: message received */ 169 xpMsgReceived, /* 4: message received */
170 xpcMsgDelivered, /* 5: message delivered and acknowledged */ 170 xpMsgDelivered, /* 5: message delivered and acknowledged */
171 171
172 xpcRETIRED2, /* 6: (formerly xpcTransferFailed) */ 172 xpRETIRED2, /* 6: (formerly xpTransferFailed) */
173 173
174 xpcNoWait, /* 7: operation would require wait */ 174 xpNoWait, /* 7: operation would require wait */
175 xpcRetry, /* 8: retry operation */ 175 xpRetry, /* 8: retry operation */
176 xpcTimeout, /* 9: timeout in xpc_allocate_msg_wait() */ 176 xpTimeout, /* 9: timeout in xpc_allocate_msg_wait() */
177 xpcInterrupted, /* 10: interrupted wait */ 177 xpInterrupted, /* 10: interrupted wait */
178 178
179 xpcUnequalMsgSizes, /* 11: message size disparity between sides */ 179 xpUnequalMsgSizes, /* 11: message size disparity between sides */
180 xpcInvalidAddress, /* 12: invalid address */ 180 xpInvalidAddress, /* 12: invalid address */
181 181
182 xpcNoMemory, /* 13: no memory available for XPC structures */ 182 xpNoMemory, /* 13: no memory available for XPC structures */
183 xpcLackOfResources, /* 14: insufficient resources for operation */ 183 xpLackOfResources, /* 14: insufficient resources for operation */
184 xpcUnregistered, /* 15: channel is not registered */ 184 xpUnregistered, /* 15: channel is not registered */
185 xpcAlreadyRegistered, /* 16: channel is already registered */ 185 xpAlreadyRegistered, /* 16: channel is already registered */
186 186
187 xpcPartitionDown, /* 17: remote partition is down */ 187 xpPartitionDown, /* 17: remote partition is down */
188 xpcNotLoaded, /* 18: XPC module is not loaded */ 188 xpNotLoaded, /* 18: XPC module is not loaded */
189 xpcUnloading, /* 19: this side is unloading XPC module */ 189 xpUnloading, /* 19: this side is unloading XPC module */
190 190
191 xpcBadMagic, /* 20: XPC MAGIC string not found */ 191 xpBadMagic, /* 20: XPC MAGIC string not found */
192 192
193 xpcReactivating, /* 21: remote partition was reactivated */ 193 xpReactivating, /* 21: remote partition was reactivated */
194 194
195 xpcUnregistering, /* 22: this side is unregistering channel */ 195 xpUnregistering, /* 22: this side is unregistering channel */
196 xpcOtherUnregistering, /* 23: other side is unregistering channel */ 196 xpOtherUnregistering, /* 23: other side is unregistering channel */
197 197
198 xpcCloneKThread, /* 24: cloning kernel thread */ 198 xpCloneKThread, /* 24: cloning kernel thread */
199 xpcCloneKThreadFailed, /* 25: cloning kernel thread failed */ 199 xpCloneKThreadFailed, /* 25: cloning kernel thread failed */
200 200
201 xpcNoHeartbeat, /* 26: remote partition has no heartbeat */ 201 xpNoHeartbeat, /* 26: remote partition has no heartbeat */
202 202
203 xpcPioReadError, /* 27: PIO read error */ 203 xpPioReadError, /* 27: PIO read error */
204 xpcPhysAddrRegFailed, /* 28: registration of phys addr range failed */ 204 xpPhysAddrRegFailed, /* 28: registration of phys addr range failed */
205 205
206 xpcBteDirectoryError, /* 29: maps to BTEFAIL_DIR */ 206 xpRETIRED3, /* 29: (formerly xpBteDirectoryError) */
207 xpcBtePoisonError, /* 30: maps to BTEFAIL_POISON */ 207 xpRETIRED4, /* 30: (formerly xpBtePoisonError) */
208 xpcBteWriteError, /* 31: maps to BTEFAIL_WERR */ 208 xpRETIRED5, /* 31: (formerly xpBteWriteError) */
209 xpcBteAccessError, /* 32: maps to BTEFAIL_ACCESS */ 209 xpRETIRED6, /* 32: (formerly xpBteAccessError) */
210 xpcBtePWriteError, /* 33: maps to BTEFAIL_PWERR */ 210 xpRETIRED7, /* 33: (formerly xpBtePWriteError) */
211 xpcBtePReadError, /* 34: maps to BTEFAIL_PRERR */ 211 xpRETIRED8, /* 34: (formerly xpBtePReadError) */
212 xpcBteTimeOutError, /* 35: maps to BTEFAIL_TOUT */ 212 xpRETIRED9, /* 35: (formerly xpBteTimeOutError) */
213 xpcBteXtalkError, /* 36: maps to BTEFAIL_XTERR */ 213 xpRETIRED10, /* 36: (formerly xpBteXtalkError) */
214 xpcBteNotAvailable, /* 37: maps to BTEFAIL_NOTAVAIL */ 214 xpRETIRED11, /* 37: (formerly xpBteNotAvailable) */
215 xpcBteUnmappedError, /* 38: unmapped BTEFAIL_ error */ 215 xpRETIRED12, /* 38: (formerly xpBteUnmappedError) */
216 216
217 xpcBadVersion, /* 39: bad version number */ 217 xpBadVersion, /* 39: bad version number */
218 xpcVarsNotSet, /* 40: the XPC variables are not set up */ 218 xpVarsNotSet, /* 40: the XPC variables are not set up */
219 xpcNoRsvdPageAddr, /* 41: unable to get rsvd page's phys addr */ 219 xpNoRsvdPageAddr, /* 41: unable to get rsvd page's phys addr */
220 xpcInvalidPartid, /* 42: invalid partition ID */ 220 xpInvalidPartid, /* 42: invalid partition ID */
221 xpcLocalPartid, /* 43: local partition ID */ 221 xpLocalPartid, /* 43: local partition ID */
222 222
223 xpcOtherGoingDown, /* 44: other side going down, reason unknown */ 223 xpOtherGoingDown, /* 44: other side going down, reason unknown */
224 xpcSystemGoingDown, /* 45: system is going down, reason unknown */ 224 xpSystemGoingDown, /* 45: system is going down, reason unknown */
225 xpcSystemHalt, /* 46: system is being halted */ 225 xpSystemHalt, /* 46: system is being halted */
226 xpcSystemReboot, /* 47: system is being rebooted */ 226 xpSystemReboot, /* 47: system is being rebooted */
227 xpcSystemPoweroff, /* 48: system is being powered off */ 227 xpSystemPoweroff, /* 48: system is being powered off */
228 228
229 xpcDisconnecting, /* 49: channel disconnecting (closing) */ 229 xpDisconnecting, /* 49: channel disconnecting (closing) */
230 230
231 xpcOpenCloseError, /* 50: channel open/close protocol error */ 231 xpOpenCloseError, /* 50: channel open/close protocol error */
232 232
233 xpcDisconnected, /* 51: channel disconnected (closed) */ 233 xpDisconnected, /* 51: channel disconnected (closed) */
234 234
235 xpcBteSh2Start, /* 52: BTE CRB timeout */ 235 xpBteCopyError, /* 52: bte_copy() returned error */
236 236
237 /* 53: 0x1 BTE Error Response Short */ 237 xpUnknownReason /* 53: unknown reason - must be last in enum */
238 xpcBteSh2RspShort = xpcBteSh2Start + BTEFAIL_SH2_RESP_SHORT,
239
240 /* 54: 0x2 BTE Error Response Long */
241 xpcBteSh2RspLong = xpcBteSh2Start + BTEFAIL_SH2_RESP_LONG,
242
243 /* 56: 0x4 BTE Error Response DSB */
244 xpcBteSh2RspDSB = xpcBteSh2Start + BTEFAIL_SH2_RESP_DSP,
245
246 /* 60: 0x8 BTE Error Response Access */
247 xpcBteSh2RspAccess = xpcBteSh2Start + BTEFAIL_SH2_RESP_ACCESS,
248
249 /* 68: 0x10 BTE Error CRB timeout */
250 xpcBteSh2CRBTO = xpcBteSh2Start + BTEFAIL_SH2_CRB_TO,
251
252 /* 84: 0x20 BTE Error NACK limit */
253 xpcBteSh2NACKLimit = xpcBteSh2Start + BTEFAIL_SH2_NACK_LIMIT,
254
255 /* 115: BTE end */
256 xpcBteSh2End = xpcBteSh2Start + BTEFAIL_SH2_ALL,
257
258 xpcUnknownReason /* 116: unknown reason - must be last in enum */
259}; 238};
260 239
261/* 240/*
262 * Define the callout function types used by XPC to update the user on 241 * Define the callout function type used by XPC to update the user on
263 * connection activity and state changes (via the user function registered by 242 * connection activity and state changes via the user function registered
264 * xpc_connect()) and to notify them of messages received and delivered (via 243 * by xpc_connect().
265 * the user function registered by xpc_send_notify()).
266 *
267 * The two function types are xpc_channel_func and xpc_notify_func and
268 * both share the following arguments, with the exception of "data", which
269 * only xpc_channel_func has.
270 * 244 *
271 * Arguments: 245 * Arguments:
272 * 246 *
273 * reason - reason code. (See following table.) 247 * reason - reason code.
274 * partid - partition ID associated with condition. 248 * partid - partition ID associated with condition.
275 * ch_number - channel # associated with condition. 249 * ch_number - channel # associated with condition.
276 * data - pointer to optional data. (See following table.) 250 * data - pointer to optional data.
277 * key - pointer to optional user-defined value provided as the "key" 251 * key - pointer to optional user-defined value provided as the "key"
278 * argument to xpc_connect() or xpc_send_notify(). 252 * argument to xpc_connect().
279 * 253 *
280 * In the following table the "Optional Data" column applies to callouts made 254 * A reason code of xpConnected indicates that a connection has been
281 * to functions registered by xpc_connect(). A "NA" in that column indicates 255 * established to the specified partition on the specified channel. The data
282 * that this reason code can be passed to functions registered by 256 * argument indicates the max number of entries allowed in the message queue.
283 * xpc_send_notify() (i.e. they don't have data arguments).
284 * 257 *
285 * Also, the first three reason codes in the following table indicate 258 * A reason code of xpMsgReceived indicates that a XPC message arrived from
286 * success, whereas the others indicate failure. When a failure reason code 259 * the specified partition on the specified channel. The data argument
287 * is received, one can assume that the channel is not connected. 260 * specifies the address of the message's payload. The user must call
261 * xpc_received() when finished with the payload.
288 * 262 *
289 * 263 * All other reason codes indicate failure. The data argmument is NULL.
290 * Reason Code | Cause | Optional Data 264 * When a failure reason code is received, one can assume that the channel
291 * =====================+================================+===================== 265 * is not connected.
292 * xpcConnected | connection has been established| max #of entries
293 * | to the specified partition on | allowed in message
294 * | the specified channel | queue
295 * ---------------------+--------------------------------+---------------------
296 * xpcMsgReceived | an XPC message arrived from | address of payload
297 * | the specified partition on the |
298 * | specified channel | [the user must call
299 * | | xpc_received() when
300 * | | finished with the
301 * | | payload]
302 * ---------------------+--------------------------------+---------------------
303 * xpcMsgDelivered | notification that the message | NA
304 * | was delivered to the intended |
305 * | recipient and that they have |
306 * | acknowledged its receipt by |
307 * | calling xpc_received() |
308 * =====================+================================+=====================
309 * xpcUnequalMsgSizes | can't connect to the specified | NULL
310 * | partition on the specified |
311 * | channel because of mismatched |
312 * | message sizes |
313 * ---------------------+--------------------------------+---------------------
314 * xpcNoMemory | insufficient memory avaiable | NULL
315 * | to allocate message queue |
316 * ---------------------+--------------------------------+---------------------
317 * xpcLackOfResources | lack of resources to create | NULL
318 * | the necessary kthreads to |
319 * | support the channel |
320 * ---------------------+--------------------------------+---------------------
321 * xpcUnregistering | this side's user has | NULL or NA
322 * | unregistered by calling |
323 * | xpc_disconnect() |
324 * ---------------------+--------------------------------+---------------------
325 * xpcOtherUnregistering| the other side's user has | NULL or NA
326 * | unregistered by calling |
327 * | xpc_disconnect() |
328 * ---------------------+--------------------------------+---------------------
329 * xpcNoHeartbeat | the other side's XPC is no | NULL or NA
330 * | longer heartbeating |
331 * | |
332 * ---------------------+--------------------------------+---------------------
333 * xpcUnloading | this side's XPC module is | NULL or NA
334 * | being unloaded |
335 * | |
336 * ---------------------+--------------------------------+---------------------
337 * xpcOtherUnloading | the other side's XPC module is | NULL or NA
338 * | is being unloaded |
339 * | |
340 * ---------------------+--------------------------------+---------------------
341 * xpcPioReadError | xp_nofault_PIOR() returned an | NULL or NA
342 * | error while sending an IPI |
343 * | |
344 * ---------------------+--------------------------------+---------------------
345 * xpcInvalidAddress | the address either received or | NULL or NA
346 * | sent by the specified partition|
347 * | is invalid |
348 * ---------------------+--------------------------------+---------------------
349 * xpcBteNotAvailable | attempt to pull data from the | NULL or NA
350 * xpcBtePoisonError | specified partition over the |
351 * xpcBteWriteError | specified channel via a |
352 * xpcBteAccessError | bte_copy() failed |
353 * xpcBteTimeOutError | |
354 * xpcBteXtalkError | |
355 * xpcBteDirectoryError | |
356 * xpcBteGenericError | |
357 * xpcBteUnmappedError | |
358 * ---------------------+--------------------------------+---------------------
359 * xpcUnknownReason | the specified channel to the | NULL or NA
360 * | specified partition was |
361 * | unavailable for unknown reasons|
362 * =====================+================================+=====================
363 */ 266 */
364 267typedef void (*xpc_channel_func) (enum xp_retval reason, short partid,
365typedef void (*xpc_channel_func) (enum xpc_retval reason, partid_t partid,
366 int ch_number, void *data, void *key); 268 int ch_number, void *data, void *key);
367 269
368typedef void (*xpc_notify_func) (enum xpc_retval reason, partid_t partid, 270/*
271 * Define the callout function type used by XPC to notify the user of
272 * messages received and delivered via the user function registered by
273 * xpc_send_notify().
274 *
275 * Arguments:
276 *
277 * reason - reason code.
278 * partid - partition ID associated with condition.
279 * ch_number - channel # associated with condition.
280 * key - pointer to optional user-defined value provided as the "key"
281 * argument to xpc_send_notify().
282 *
283 * A reason code of xpMsgDelivered indicates that the message was delivered
284 * to the intended recipient and that they have acknowledged its receipt by
285 * calling xpc_received().
286 *
287 * All other reason codes indicate failure.
288 */
289typedef void (*xpc_notify_func) (enum xp_retval reason, short partid,
369 int ch_number, void *key); 290 int ch_number, void *key);
370 291
371/* 292/*
@@ -401,57 +322,57 @@ struct xpc_registration {
401struct xpc_interface { 322struct xpc_interface {
402 void (*connect) (int); 323 void (*connect) (int);
403 void (*disconnect) (int); 324 void (*disconnect) (int);
404 enum xpc_retval (*allocate) (partid_t, int, u32, void **); 325 enum xp_retval (*allocate) (short, int, u32, void **);
405 enum xpc_retval (*send) (partid_t, int, void *); 326 enum xp_retval (*send) (short, int, void *);
406 enum xpc_retval (*send_notify) (partid_t, int, void *, 327 enum xp_retval (*send_notify) (short, int, void *,
407 xpc_notify_func, void *); 328 xpc_notify_func, void *);
408 void (*received) (partid_t, int, void *); 329 void (*received) (short, int, void *);
409 enum xpc_retval (*partid_to_nasids) (partid_t, void *); 330 enum xp_retval (*partid_to_nasids) (short, void *);
410}; 331};
411 332
412extern struct xpc_interface xpc_interface; 333extern struct xpc_interface xpc_interface;
413 334
414extern void xpc_set_interface(void (*)(int), 335extern void xpc_set_interface(void (*)(int),
415 void (*)(int), 336 void (*)(int),
416 enum xpc_retval (*)(partid_t, int, u32, void **), 337 enum xp_retval (*)(short, int, u32, void **),
417 enum xpc_retval (*)(partid_t, int, void *), 338 enum xp_retval (*)(short, int, void *),
418 enum xpc_retval (*)(partid_t, int, void *, 339 enum xp_retval (*)(short, int, void *,
419 xpc_notify_func, void *), 340 xpc_notify_func, void *),
420 void (*)(partid_t, int, void *), 341 void (*)(short, int, void *),
421 enum xpc_retval (*)(partid_t, void *)); 342 enum xp_retval (*)(short, void *));
422extern void xpc_clear_interface(void); 343extern void xpc_clear_interface(void);
423 344
424extern enum xpc_retval xpc_connect(int, xpc_channel_func, void *, u16, 345extern enum xp_retval xpc_connect(int, xpc_channel_func, void *, u16,
425 u16, u32, u32); 346 u16, u32, u32);
426extern void xpc_disconnect(int); 347extern void xpc_disconnect(int);
427 348
428static inline enum xpc_retval 349static inline enum xp_retval
429xpc_allocate(partid_t partid, int ch_number, u32 flags, void **payload) 350xpc_allocate(short partid, int ch_number, u32 flags, void **payload)
430{ 351{
431 return xpc_interface.allocate(partid, ch_number, flags, payload); 352 return xpc_interface.allocate(partid, ch_number, flags, payload);
432} 353}
433 354
434static inline enum xpc_retval 355static inline enum xp_retval
435xpc_send(partid_t partid, int ch_number, void *payload) 356xpc_send(short partid, int ch_number, void *payload)
436{ 357{
437 return xpc_interface.send(partid, ch_number, payload); 358 return xpc_interface.send(partid, ch_number, payload);
438} 359}
439 360
440static inline enum xpc_retval 361static inline enum xp_retval
441xpc_send_notify(partid_t partid, int ch_number, void *payload, 362xpc_send_notify(short partid, int ch_number, void *payload,
442 xpc_notify_func func, void *key) 363 xpc_notify_func func, void *key)
443{ 364{
444 return xpc_interface.send_notify(partid, ch_number, payload, func, key); 365 return xpc_interface.send_notify(partid, ch_number, payload, func, key);
445} 366}
446 367
447static inline void 368static inline void
448xpc_received(partid_t partid, int ch_number, void *payload) 369xpc_received(short partid, int ch_number, void *payload)
449{ 370{
450 return xpc_interface.received(partid, ch_number, payload); 371 return xpc_interface.received(partid, ch_number, payload);
451} 372}
452 373
453static inline enum xpc_retval 374static inline enum xp_retval
454xpc_partid_to_nasids(partid_t partid, void *nasids) 375xpc_partid_to_nasids(short partid, void *nasids)
455{ 376{
456 return xpc_interface.partid_to_nasids(partid, nasids); 377 return xpc_interface.partid_to_nasids(partid, nasids);
457} 378}
diff --git a/drivers/misc/sgi-xp/xp_main.c b/drivers/misc/sgi-xp/xp_main.c
index 1fbf99bae963..196480b691a1 100644
--- a/drivers/misc/sgi-xp/xp_main.c
+++ b/drivers/misc/sgi-xp/xp_main.c
@@ -42,21 +42,21 @@ EXPORT_SYMBOL_GPL(xpc_registrations);
42/* 42/*
43 * Initialize the XPC interface to indicate that XPC isn't loaded. 43 * Initialize the XPC interface to indicate that XPC isn't loaded.
44 */ 44 */
45static enum xpc_retval 45static enum xp_retval
46xpc_notloaded(void) 46xpc_notloaded(void)
47{ 47{
48 return xpcNotLoaded; 48 return xpNotLoaded;
49} 49}
50 50
51struct xpc_interface xpc_interface = { 51struct xpc_interface xpc_interface = {
52 (void (*)(int))xpc_notloaded, 52 (void (*)(int))xpc_notloaded,
53 (void (*)(int))xpc_notloaded, 53 (void (*)(int))xpc_notloaded,
54 (enum xpc_retval(*)(partid_t, int, u32, void **))xpc_notloaded, 54 (enum xp_retval(*)(short, int, u32, void **))xpc_notloaded,
55 (enum xpc_retval(*)(partid_t, int, void *))xpc_notloaded, 55 (enum xp_retval(*)(short, int, void *))xpc_notloaded,
56 (enum xpc_retval(*)(partid_t, int, void *, xpc_notify_func, void *)) 56 (enum xp_retval(*)(short, int, void *, xpc_notify_func, void *))
57 xpc_notloaded, 57 xpc_notloaded,
58 (void (*)(partid_t, int, void *))xpc_notloaded, 58 (void (*)(short, int, void *))xpc_notloaded,
59 (enum xpc_retval(*)(partid_t, void *))xpc_notloaded 59 (enum xp_retval(*)(short, void *))xpc_notloaded
60}; 60};
61EXPORT_SYMBOL_GPL(xpc_interface); 61EXPORT_SYMBOL_GPL(xpc_interface);
62 62
@@ -66,12 +66,12 @@ EXPORT_SYMBOL_GPL(xpc_interface);
66void 66void
67xpc_set_interface(void (*connect) (int), 67xpc_set_interface(void (*connect) (int),
68 void (*disconnect) (int), 68 void (*disconnect) (int),
69 enum xpc_retval (*allocate) (partid_t, int, u32, void **), 69 enum xp_retval (*allocate) (short, int, u32, void **),
70 enum xpc_retval (*send) (partid_t, int, void *), 70 enum xp_retval (*send) (short, int, void *),
71 enum xpc_retval (*send_notify) (partid_t, int, void *, 71 enum xp_retval (*send_notify) (short, int, void *,
72 xpc_notify_func, void *), 72 xpc_notify_func, void *),
73 void (*received) (partid_t, int, void *), 73 void (*received) (short, int, void *),
74 enum xpc_retval (*partid_to_nasids) (partid_t, void *)) 74 enum xp_retval (*partid_to_nasids) (short, void *))
75{ 75{
76 xpc_interface.connect = connect; 76 xpc_interface.connect = connect;
77 xpc_interface.disconnect = disconnect; 77 xpc_interface.disconnect = disconnect;
@@ -91,16 +91,16 @@ xpc_clear_interface(void)
91{ 91{
92 xpc_interface.connect = (void (*)(int))xpc_notloaded; 92 xpc_interface.connect = (void (*)(int))xpc_notloaded;
93 xpc_interface.disconnect = (void (*)(int))xpc_notloaded; 93 xpc_interface.disconnect = (void (*)(int))xpc_notloaded;
94 xpc_interface.allocate = (enum xpc_retval(*)(partid_t, int, u32, 94 xpc_interface.allocate = (enum xp_retval(*)(short, int, u32,
95 void **))xpc_notloaded; 95 void **))xpc_notloaded;
96 xpc_interface.send = (enum xpc_retval(*)(partid_t, int, void *)) 96 xpc_interface.send = (enum xp_retval(*)(short, int, void *))
97 xpc_notloaded; 97 xpc_notloaded;
98 xpc_interface.send_notify = (enum xpc_retval(*)(partid_t, int, void *, 98 xpc_interface.send_notify = (enum xp_retval(*)(short, int, void *,
99 xpc_notify_func, 99 xpc_notify_func,
100 void *))xpc_notloaded; 100 void *))xpc_notloaded;
101 xpc_interface.received = (void (*)(partid_t, int, void *)) 101 xpc_interface.received = (void (*)(short, int, void *))
102 xpc_notloaded; 102 xpc_notloaded;
103 xpc_interface.partid_to_nasids = (enum xpc_retval(*)(partid_t, void *)) 103 xpc_interface.partid_to_nasids = (enum xp_retval(*)(short, void *))
104 xpc_notloaded; 104 xpc_notloaded;
105} 105}
106EXPORT_SYMBOL_GPL(xpc_clear_interface); 106EXPORT_SYMBOL_GPL(xpc_clear_interface);
@@ -123,13 +123,13 @@ EXPORT_SYMBOL_GPL(xpc_clear_interface);
123 * nentries - max #of XPC message entries a message queue can contain. 123 * nentries - max #of XPC message entries a message queue can contain.
124 * The actual number, which is determined when a connection 124 * The actual number, which is determined when a connection
125 * is established and may be less then requested, will be 125 * is established and may be less then requested, will be
126 * passed to the user via the xpcConnected callout. 126 * passed to the user via the xpConnected callout.
127 * assigned_limit - max number of kthreads allowed to be processing 127 * assigned_limit - max number of kthreads allowed to be processing
128 * messages (per connection) at any given instant. 128 * messages (per connection) at any given instant.
129 * idle_limit - max number of kthreads allowed to be idle at any given 129 * idle_limit - max number of kthreads allowed to be idle at any given
130 * instant. 130 * instant.
131 */ 131 */
132enum xpc_retval 132enum xp_retval
133xpc_connect(int ch_number, xpc_channel_func func, void *key, u16 payload_size, 133xpc_connect(int ch_number, xpc_channel_func func, void *key, u16 payload_size,
134 u16 nentries, u32 assigned_limit, u32 idle_limit) 134 u16 nentries, u32 assigned_limit, u32 idle_limit)
135{ 135{
@@ -143,12 +143,12 @@ xpc_connect(int ch_number, xpc_channel_func func, void *key, u16 payload_size,
143 registration = &xpc_registrations[ch_number]; 143 registration = &xpc_registrations[ch_number];
144 144
145 if (mutex_lock_interruptible(&registration->mutex) != 0) 145 if (mutex_lock_interruptible(&registration->mutex) != 0)
146 return xpcInterrupted; 146 return xpInterrupted;
147 147
148 /* if XPC_CHANNEL_REGISTERED(ch_number) */ 148 /* if XPC_CHANNEL_REGISTERED(ch_number) */
149 if (registration->func != NULL) { 149 if (registration->func != NULL) {
150 mutex_unlock(&registration->mutex); 150 mutex_unlock(&registration->mutex);
151 return xpcAlreadyRegistered; 151 return xpAlreadyRegistered;
152 } 152 }
153 153
154 /* register the channel for connection */ 154 /* register the channel for connection */
@@ -163,7 +163,7 @@ xpc_connect(int ch_number, xpc_channel_func func, void *key, u16 payload_size,
163 163
164 xpc_interface.connect(ch_number); 164 xpc_interface.connect(ch_number);
165 165
166 return xpcSuccess; 166 return xpSuccess;
167} 167}
168EXPORT_SYMBOL_GPL(xpc_connect); 168EXPORT_SYMBOL_GPL(xpc_connect);
169 169
diff --git a/drivers/misc/sgi-xp/xpc.h b/drivers/misc/sgi-xp/xpc.h
index 9eb6d4a3269c..11ac267ed68f 100644
--- a/drivers/misc/sgi-xp/xpc.h
+++ b/drivers/misc/sgi-xp/xpc.h
@@ -172,13 +172,13 @@ struct xpc_vars {
172 (_version >= _XPC_VERSION(3, 1)) 172 (_version >= _XPC_VERSION(3, 1))
173 173
174static inline int 174static inline int
175xpc_hb_allowed(partid_t partid, struct xpc_vars *vars) 175xpc_hb_allowed(short partid, struct xpc_vars *vars)
176{ 176{
177 return ((vars->heartbeating_to_mask & (1UL << partid)) != 0); 177 return ((vars->heartbeating_to_mask & (1UL << partid)) != 0);
178} 178}
179 179
180static inline void 180static inline void
181xpc_allow_hb(partid_t partid, struct xpc_vars *vars) 181xpc_allow_hb(short partid, struct xpc_vars *vars)
182{ 182{
183 u64 old_mask, new_mask; 183 u64 old_mask, new_mask;
184 184
@@ -190,7 +190,7 @@ xpc_allow_hb(partid_t partid, struct xpc_vars *vars)
190} 190}
191 191
192static inline void 192static inline void
193xpc_disallow_hb(partid_t partid, struct xpc_vars *vars) 193xpc_disallow_hb(short partid, struct xpc_vars *vars)
194{ 194{
195 u64 old_mask, new_mask; 195 u64 old_mask, new_mask;
196 196
@@ -408,11 +408,11 @@ struct xpc_notify {
408 * messages. 408 * messages.
409 */ 409 */
410struct xpc_channel { 410struct xpc_channel {
411 partid_t partid; /* ID of remote partition connected */ 411 short partid; /* ID of remote partition connected */
412 spinlock_t lock; /* lock for updating this structure */ 412 spinlock_t lock; /* lock for updating this structure */
413 u32 flags; /* general flags */ 413 u32 flags; /* general flags */
414 414
415 enum xpc_retval reason; /* reason why channel is disconnect'g */ 415 enum xp_retval reason; /* reason why channel is disconnect'g */
416 int reason_line; /* line# disconnect initiated from */ 416 int reason_line; /* line# disconnect initiated from */
417 417
418 u16 number; /* channel # */ 418 u16 number; /* channel # */
@@ -522,7 +522,7 @@ struct xpc_partition {
522 spinlock_t act_lock; /* protect updating of act_state */ 522 spinlock_t act_lock; /* protect updating of act_state */
523 u8 act_state; /* from XPC HB viewpoint */ 523 u8 act_state; /* from XPC HB viewpoint */
524 u8 remote_vars_version; /* version# of partition's vars */ 524 u8 remote_vars_version; /* version# of partition's vars */
525 enum xpc_retval reason; /* reason partition is deactivating */ 525 enum xp_retval reason; /* reason partition is deactivating */
526 int reason_line; /* line# deactivation initiated from */ 526 int reason_line; /* line# deactivation initiated from */
527 int reactivate_nasid; /* nasid in partition to reactivate */ 527 int reactivate_nasid; /* nasid in partition to reactivate */
528 528
@@ -615,7 +615,7 @@ struct xpc_partition {
615/* interval in seconds to print 'waiting disengagement' messages */ 615/* interval in seconds to print 'waiting disengagement' messages */
616#define XPC_DISENGAGE_PRINTMSG_INTERVAL 10 616#define XPC_DISENGAGE_PRINTMSG_INTERVAL 10
617 617
618#define XPC_PARTID(_p) ((partid_t) ((_p) - &xpc_partitions[0])) 618#define XPC_PARTID(_p) ((short)((_p) - &xpc_partitions[0]))
619 619
620/* found in xp_main.c */ 620/* found in xp_main.c */
621extern struct xpc_registration xpc_registrations[]; 621extern struct xpc_registration xpc_registrations[];
@@ -646,31 +646,31 @@ extern void xpc_allow_IPI_ops(void);
646extern void xpc_restrict_IPI_ops(void); 646extern void xpc_restrict_IPI_ops(void);
647extern int xpc_identify_act_IRQ_sender(void); 647extern int xpc_identify_act_IRQ_sender(void);
648extern int xpc_partition_disengaged(struct xpc_partition *); 648extern int xpc_partition_disengaged(struct xpc_partition *);
649extern enum xpc_retval xpc_mark_partition_active(struct xpc_partition *); 649extern enum xp_retval xpc_mark_partition_active(struct xpc_partition *);
650extern void xpc_mark_partition_inactive(struct xpc_partition *); 650extern void xpc_mark_partition_inactive(struct xpc_partition *);
651extern void xpc_discovery(void); 651extern void xpc_discovery(void);
652extern void xpc_check_remote_hb(void); 652extern void xpc_check_remote_hb(void);
653extern void xpc_deactivate_partition(const int, struct xpc_partition *, 653extern void xpc_deactivate_partition(const int, struct xpc_partition *,
654 enum xpc_retval); 654 enum xp_retval);
655extern enum xpc_retval xpc_initiate_partid_to_nasids(partid_t, void *); 655extern enum xp_retval xpc_initiate_partid_to_nasids(short, void *);
656 656
657/* found in xpc_channel.c */ 657/* found in xpc_channel.c */
658extern void xpc_initiate_connect(int); 658extern void xpc_initiate_connect(int);
659extern void xpc_initiate_disconnect(int); 659extern void xpc_initiate_disconnect(int);
660extern enum xpc_retval xpc_initiate_allocate(partid_t, int, u32, void **); 660extern enum xp_retval xpc_initiate_allocate(short, int, u32, void **);
661extern enum xpc_retval xpc_initiate_send(partid_t, int, void *); 661extern enum xp_retval xpc_initiate_send(short, int, void *);
662extern enum xpc_retval xpc_initiate_send_notify(partid_t, int, void *, 662extern enum xp_retval xpc_initiate_send_notify(short, int, void *,
663 xpc_notify_func, void *); 663 xpc_notify_func, void *);
664extern void xpc_initiate_received(partid_t, int, void *); 664extern void xpc_initiate_received(short, int, void *);
665extern enum xpc_retval xpc_setup_infrastructure(struct xpc_partition *); 665extern enum xp_retval xpc_setup_infrastructure(struct xpc_partition *);
666extern enum xpc_retval xpc_pull_remote_vars_part(struct xpc_partition *); 666extern enum xp_retval xpc_pull_remote_vars_part(struct xpc_partition *);
667extern void xpc_process_channel_activity(struct xpc_partition *); 667extern void xpc_process_channel_activity(struct xpc_partition *);
668extern void xpc_connected_callout(struct xpc_channel *); 668extern void xpc_connected_callout(struct xpc_channel *);
669extern void xpc_deliver_msg(struct xpc_channel *); 669extern void xpc_deliver_msg(struct xpc_channel *);
670extern void xpc_disconnect_channel(const int, struct xpc_channel *, 670extern void xpc_disconnect_channel(const int, struct xpc_channel *,
671 enum xpc_retval, unsigned long *); 671 enum xp_retval, unsigned long *);
672extern void xpc_disconnect_callout(struct xpc_channel *, enum xpc_retval); 672extern void xpc_disconnect_callout(struct xpc_channel *, enum xp_retval);
673extern void xpc_partition_going_down(struct xpc_partition *, enum xpc_retval); 673extern void xpc_partition_going_down(struct xpc_partition *, enum xp_retval);
674extern void xpc_teardown_infrastructure(struct xpc_partition *); 674extern void xpc_teardown_infrastructure(struct xpc_partition *);
675 675
676static inline void 676static inline void
@@ -901,7 +901,7 @@ xpc_IPI_receive(AMO_t *amo)
901 return FETCHOP_LOAD_OP(TO_AMO((u64)&amo->variable), FETCHOP_CLEAR); 901 return FETCHOP_LOAD_OP(TO_AMO((u64)&amo->variable), FETCHOP_CLEAR);
902} 902}
903 903
904static inline enum xpc_retval 904static inline enum xp_retval
905xpc_IPI_send(AMO_t *amo, u64 flag, int nasid, int phys_cpuid, int vector) 905xpc_IPI_send(AMO_t *amo, u64 flag, int nasid, int phys_cpuid, int vector)
906{ 906{
907 int ret = 0; 907 int ret = 0;
@@ -923,7 +923,7 @@ xpc_IPI_send(AMO_t *amo, u64 flag, int nasid, int phys_cpuid, int vector)
923 923
924 local_irq_restore(irq_flags); 924 local_irq_restore(irq_flags);
925 925
926 return ((ret == 0) ? xpcSuccess : xpcPioReadError); 926 return ((ret == 0) ? xpSuccess : xpPioReadError);
927} 927}
928 928
929/* 929/*
@@ -992,7 +992,7 @@ xpc_notify_IRQ_send(struct xpc_channel *ch, u8 ipi_flag, char *ipi_flag_string,
992 unsigned long *irq_flags) 992 unsigned long *irq_flags)
993{ 993{
994 struct xpc_partition *part = &xpc_partitions[ch->partid]; 994 struct xpc_partition *part = &xpc_partitions[ch->partid];
995 enum xpc_retval ret; 995 enum xp_retval ret;
996 996
997 if (likely(part->act_state != XPC_P_DEACTIVATING)) { 997 if (likely(part->act_state != XPC_P_DEACTIVATING)) {
998 ret = xpc_IPI_send(part->remote_IPI_amo_va, 998 ret = xpc_IPI_send(part->remote_IPI_amo_va,
@@ -1001,7 +1001,7 @@ xpc_notify_IRQ_send(struct xpc_channel *ch, u8 ipi_flag, char *ipi_flag_string,
1001 part->remote_IPI_phys_cpuid, SGI_XPC_NOTIFY); 1001 part->remote_IPI_phys_cpuid, SGI_XPC_NOTIFY);
1002 dev_dbg(xpc_chan, "%s sent to partid=%d, channel=%d, ret=%d\n", 1002 dev_dbg(xpc_chan, "%s sent to partid=%d, channel=%d, ret=%d\n",
1003 ipi_flag_string, ch->partid, ch->number, ret); 1003 ipi_flag_string, ch->partid, ch->number, ret);
1004 if (unlikely(ret != xpcSuccess)) { 1004 if (unlikely(ret != xpSuccess)) {
1005 if (irq_flags != NULL) 1005 if (irq_flags != NULL)
1006 spin_unlock_irqrestore(&ch->lock, *irq_flags); 1006 spin_unlock_irqrestore(&ch->lock, *irq_flags);
1007 XPC_DEACTIVATE_PARTITION(part, ret); 1007 XPC_DEACTIVATE_PARTITION(part, ret);
@@ -1123,41 +1123,10 @@ xpc_IPI_init(int index)
1123 return amo; 1123 return amo;
1124} 1124}
1125 1125
1126static inline enum xpc_retval 1126static inline enum xp_retval
1127xpc_map_bte_errors(bte_result_t error) 1127xpc_map_bte_errors(bte_result_t error)
1128{ 1128{
1129 if (error == BTE_SUCCESS) 1129 return ((error == BTE_SUCCESS) ? xpSuccess : xpBteCopyError);
1130 return xpcSuccess;
1131
1132 if (is_shub2()) {
1133 if (BTE_VALID_SH2_ERROR(error))
1134 return xpcBteSh2Start + error;
1135 return xpcBteUnmappedError;
1136 }
1137 switch (error) {
1138 case BTE_SUCCESS:
1139 return xpcSuccess;
1140 case BTEFAIL_DIR:
1141 return xpcBteDirectoryError;
1142 case BTEFAIL_POISON:
1143 return xpcBtePoisonError;
1144 case BTEFAIL_WERR:
1145 return xpcBteWriteError;
1146 case BTEFAIL_ACCESS:
1147 return xpcBteAccessError;
1148 case BTEFAIL_PWERR:
1149 return xpcBtePWriteError;
1150 case BTEFAIL_PRERR:
1151 return xpcBtePReadError;
1152 case BTEFAIL_TOUT:
1153 return xpcBteTimeOutError;
1154 case BTEFAIL_XTERR:
1155 return xpcBteXtalkError;
1156 case BTEFAIL_NOTAVAIL:
1157 return xpcBteNotAvailable;
1158 default:
1159 return xpcBteUnmappedError;
1160 }
1161} 1130}
1162 1131
1163/* 1132/*
diff --git a/drivers/misc/sgi-xp/xpc_channel.c b/drivers/misc/sgi-xp/xpc_channel.c
index bfcb9ea968e9..9c90c2d55c08 100644
--- a/drivers/misc/sgi-xp/xpc_channel.c
+++ b/drivers/misc/sgi-xp/xpc_channel.c
@@ -53,7 +53,7 @@ xpc_kzalloc_cacheline_aligned(size_t size, gfp_t flags, void **base)
53 * Set up the initial values for the XPartition Communication channels. 53 * Set up the initial values for the XPartition Communication channels.
54 */ 54 */
55static void 55static void
56xpc_initialize_channels(struct xpc_partition *part, partid_t partid) 56xpc_initialize_channels(struct xpc_partition *part, short partid)
57{ 57{
58 int ch_number; 58 int ch_number;
59 struct xpc_channel *ch; 59 struct xpc_channel *ch;
@@ -90,12 +90,12 @@ xpc_initialize_channels(struct xpc_partition *part, partid_t partid)
90 * Setup the infrastructure necessary to support XPartition Communication 90 * Setup the infrastructure necessary to support XPartition Communication
91 * between the specified remote partition and the local one. 91 * between the specified remote partition and the local one.
92 */ 92 */
93enum xpc_retval 93enum xp_retval
94xpc_setup_infrastructure(struct xpc_partition *part) 94xpc_setup_infrastructure(struct xpc_partition *part)
95{ 95{
96 int ret, cpuid; 96 int ret, cpuid;
97 struct timer_list *timer; 97 struct timer_list *timer;
98 partid_t partid = XPC_PARTID(part); 98 short partid = XPC_PARTID(part);
99 99
100 /* 100 /*
101 * Zero out MOST of the entry for this partition. Only the fields 101 * Zero out MOST of the entry for this partition. Only the fields
@@ -114,7 +114,7 @@ xpc_setup_infrastructure(struct xpc_partition *part)
114 GFP_KERNEL); 114 GFP_KERNEL);
115 if (part->channels == NULL) { 115 if (part->channels == NULL) {
116 dev_err(xpc_chan, "can't get memory for channels\n"); 116 dev_err(xpc_chan, "can't get memory for channels\n");
117 return xpcNoMemory; 117 return xpNoMemory;
118 } 118 }
119 119
120 part->nchannels = XPC_NCHANNELS; 120 part->nchannels = XPC_NCHANNELS;
@@ -129,7 +129,7 @@ xpc_setup_infrastructure(struct xpc_partition *part)
129 part->channels = NULL; 129 part->channels = NULL;
130 dev_err(xpc_chan, "can't get memory for local get/put " 130 dev_err(xpc_chan, "can't get memory for local get/put "
131 "values\n"); 131 "values\n");
132 return xpcNoMemory; 132 return xpNoMemory;
133 } 133 }
134 134
135 part->remote_GPs = xpc_kzalloc_cacheline_aligned(XPC_GP_SIZE, 135 part->remote_GPs = xpc_kzalloc_cacheline_aligned(XPC_GP_SIZE,
@@ -143,7 +143,7 @@ xpc_setup_infrastructure(struct xpc_partition *part)
143 part->local_GPs = NULL; 143 part->local_GPs = NULL;
144 kfree(part->channels); 144 kfree(part->channels);
145 part->channels = NULL; 145 part->channels = NULL;
146 return xpcNoMemory; 146 return xpNoMemory;
147 } 147 }
148 148
149 /* allocate all the required open and close args */ 149 /* allocate all the required open and close args */
@@ -159,7 +159,7 @@ xpc_setup_infrastructure(struct xpc_partition *part)
159 part->local_GPs = NULL; 159 part->local_GPs = NULL;
160 kfree(part->channels); 160 kfree(part->channels);
161 part->channels = NULL; 161 part->channels = NULL;
162 return xpcNoMemory; 162 return xpNoMemory;
163 } 163 }
164 164
165 part->remote_openclose_args = 165 part->remote_openclose_args =
@@ -175,7 +175,7 @@ xpc_setup_infrastructure(struct xpc_partition *part)
175 part->local_GPs = NULL; 175 part->local_GPs = NULL;
176 kfree(part->channels); 176 kfree(part->channels);
177 part->channels = NULL; 177 part->channels = NULL;
178 return xpcNoMemory; 178 return xpNoMemory;
179 } 179 }
180 180
181 xpc_initialize_channels(part, partid); 181 xpc_initialize_channels(part, partid);
@@ -209,7 +209,7 @@ xpc_setup_infrastructure(struct xpc_partition *part)
209 part->local_GPs = NULL; 209 part->local_GPs = NULL;
210 kfree(part->channels); 210 kfree(part->channels);
211 part->channels = NULL; 211 part->channels = NULL;
212 return xpcLackOfResources; 212 return xpLackOfResources;
213 } 213 }
214 214
215 /* Setup a timer to check for dropped IPIs */ 215 /* Setup a timer to check for dropped IPIs */
@@ -243,7 +243,7 @@ xpc_setup_infrastructure(struct xpc_partition *part)
243 xpc_vars_part[partid].nchannels = part->nchannels; 243 xpc_vars_part[partid].nchannels = part->nchannels;
244 xpc_vars_part[partid].magic = XPC_VP_MAGIC1; 244 xpc_vars_part[partid].magic = XPC_VP_MAGIC1;
245 245
246 return xpcSuccess; 246 return xpSuccess;
247} 247}
248 248
249/* 249/*
@@ -254,7 +254,7 @@ xpc_setup_infrastructure(struct xpc_partition *part)
254 * dst must be a cacheline aligned virtual address on this partition. 254 * dst must be a cacheline aligned virtual address on this partition.
255 * cnt must be an cacheline sized 255 * cnt must be an cacheline sized
256 */ 256 */
257static enum xpc_retval 257static enum xp_retval
258xpc_pull_remote_cachelines(struct xpc_partition *part, void *dst, 258xpc_pull_remote_cachelines(struct xpc_partition *part, void *dst,
259 const void *src, size_t cnt) 259 const void *src, size_t cnt)
260{ 260{
@@ -270,7 +270,7 @@ xpc_pull_remote_cachelines(struct xpc_partition *part, void *dst,
270 bte_ret = xp_bte_copy((u64)src, (u64)dst, (u64)cnt, 270 bte_ret = xp_bte_copy((u64)src, (u64)dst, (u64)cnt,
271 (BTE_NORMAL | BTE_WACQUIRE), NULL); 271 (BTE_NORMAL | BTE_WACQUIRE), NULL);
272 if (bte_ret == BTE_SUCCESS) 272 if (bte_ret == BTE_SUCCESS)
273 return xpcSuccess; 273 return xpSuccess;
274 274
275 dev_dbg(xpc_chan, "xp_bte_copy() from partition %d failed, ret=%d\n", 275 dev_dbg(xpc_chan, "xp_bte_copy() from partition %d failed, ret=%d\n",
276 XPC_PARTID(part), bte_ret); 276 XPC_PARTID(part), bte_ret);
@@ -282,7 +282,7 @@ xpc_pull_remote_cachelines(struct xpc_partition *part, void *dst,
282 * Pull the remote per partition specific variables from the specified 282 * Pull the remote per partition specific variables from the specified
283 * partition. 283 * partition.
284 */ 284 */
285enum xpc_retval 285enum xp_retval
286xpc_pull_remote_vars_part(struct xpc_partition *part) 286xpc_pull_remote_vars_part(struct xpc_partition *part)
287{ 287{
288 u8 buffer[L1_CACHE_BYTES * 2]; 288 u8 buffer[L1_CACHE_BYTES * 2];
@@ -290,8 +290,8 @@ xpc_pull_remote_vars_part(struct xpc_partition *part)
290 (struct xpc_vars_part *)L1_CACHE_ALIGN((u64)buffer); 290 (struct xpc_vars_part *)L1_CACHE_ALIGN((u64)buffer);
291 struct xpc_vars_part *pulled_entry; 291 struct xpc_vars_part *pulled_entry;
292 u64 remote_entry_cacheline_pa, remote_entry_pa; 292 u64 remote_entry_cacheline_pa, remote_entry_pa;
293 partid_t partid = XPC_PARTID(part); 293 short partid = XPC_PARTID(part);
294 enum xpc_retval ret; 294 enum xp_retval ret;
295 295
296 /* pull the cacheline that contains the variables we're interested in */ 296 /* pull the cacheline that contains the variables we're interested in */
297 297
@@ -311,7 +311,7 @@ xpc_pull_remote_vars_part(struct xpc_partition *part)
311 ret = xpc_pull_remote_cachelines(part, pulled_entry_cacheline, 311 ret = xpc_pull_remote_cachelines(part, pulled_entry_cacheline,
312 (void *)remote_entry_cacheline_pa, 312 (void *)remote_entry_cacheline_pa,
313 L1_CACHE_BYTES); 313 L1_CACHE_BYTES);
314 if (ret != xpcSuccess) { 314 if (ret != xpSuccess) {
315 dev_dbg(xpc_chan, "failed to pull XPC vars_part from " 315 dev_dbg(xpc_chan, "failed to pull XPC vars_part from "
316 "partition %d, ret=%d\n", partid, ret); 316 "partition %d, ret=%d\n", partid, ret);
317 return ret; 317 return ret;
@@ -326,11 +326,11 @@ xpc_pull_remote_vars_part(struct xpc_partition *part)
326 dev_dbg(xpc_chan, "partition %d's XPC vars_part for " 326 dev_dbg(xpc_chan, "partition %d's XPC vars_part for "
327 "partition %d has bad magic value (=0x%lx)\n", 327 "partition %d has bad magic value (=0x%lx)\n",
328 partid, sn_partition_id, pulled_entry->magic); 328 partid, sn_partition_id, pulled_entry->magic);
329 return xpcBadMagic; 329 return xpBadMagic;
330 } 330 }
331 331
332 /* they've not been initialized yet */ 332 /* they've not been initialized yet */
333 return xpcRetry; 333 return xpRetry;
334 } 334 }
335 335
336 if (xpc_vars_part[partid].magic == XPC_VP_MAGIC1) { 336 if (xpc_vars_part[partid].magic == XPC_VP_MAGIC1) {
@@ -344,7 +344,7 @@ xpc_pull_remote_vars_part(struct xpc_partition *part)
344 dev_err(xpc_chan, "partition %d's XPC vars_part for " 344 dev_err(xpc_chan, "partition %d's XPC vars_part for "
345 "partition %d are not valid\n", partid, 345 "partition %d are not valid\n", partid,
346 sn_partition_id); 346 sn_partition_id);
347 return xpcInvalidAddress; 347 return xpInvalidAddress;
348 } 348 }
349 349
350 /* the variables we imported look to be valid */ 350 /* the variables we imported look to be valid */
@@ -366,9 +366,9 @@ xpc_pull_remote_vars_part(struct xpc_partition *part)
366 } 366 }
367 367
368 if (pulled_entry->magic == XPC_VP_MAGIC1) 368 if (pulled_entry->magic == XPC_VP_MAGIC1)
369 return xpcRetry; 369 return xpRetry;
370 370
371 return xpcSuccess; 371 return xpSuccess;
372} 372}
373 373
374/* 374/*
@@ -379,7 +379,7 @@ xpc_get_IPI_flags(struct xpc_partition *part)
379{ 379{
380 unsigned long irq_flags; 380 unsigned long irq_flags;
381 u64 IPI_amo; 381 u64 IPI_amo;
382 enum xpc_retval ret; 382 enum xp_retval ret;
383 383
384 /* 384 /*
385 * See if there are any IPI flags to be handled. 385 * See if there are any IPI flags to be handled.
@@ -398,7 +398,7 @@ xpc_get_IPI_flags(struct xpc_partition *part)
398 (void *)part-> 398 (void *)part->
399 remote_openclose_args_pa, 399 remote_openclose_args_pa,
400 XPC_OPENCLOSE_ARGS_SIZE); 400 XPC_OPENCLOSE_ARGS_SIZE);
401 if (ret != xpcSuccess) { 401 if (ret != xpSuccess) {
402 XPC_DEACTIVATE_PARTITION(part, ret); 402 XPC_DEACTIVATE_PARTITION(part, ret);
403 403
404 dev_dbg(xpc_chan, "failed to pull openclose args from " 404 dev_dbg(xpc_chan, "failed to pull openclose args from "
@@ -414,7 +414,7 @@ xpc_get_IPI_flags(struct xpc_partition *part)
414 ret = xpc_pull_remote_cachelines(part, part->remote_GPs, 414 ret = xpc_pull_remote_cachelines(part, part->remote_GPs,
415 (void *)part->remote_GPs_pa, 415 (void *)part->remote_GPs_pa,
416 XPC_GP_SIZE); 416 XPC_GP_SIZE);
417 if (ret != xpcSuccess) { 417 if (ret != xpSuccess) {
418 XPC_DEACTIVATE_PARTITION(part, ret); 418 XPC_DEACTIVATE_PARTITION(part, ret);
419 419
420 dev_dbg(xpc_chan, "failed to pull GPs from partition " 420 dev_dbg(xpc_chan, "failed to pull GPs from partition "
@@ -431,7 +431,7 @@ xpc_get_IPI_flags(struct xpc_partition *part)
431/* 431/*
432 * Allocate the local message queue and the notify queue. 432 * Allocate the local message queue and the notify queue.
433 */ 433 */
434static enum xpc_retval 434static enum xp_retval
435xpc_allocate_local_msgqueue(struct xpc_channel *ch) 435xpc_allocate_local_msgqueue(struct xpc_channel *ch)
436{ 436{
437 unsigned long irq_flags; 437 unsigned long irq_flags;
@@ -464,18 +464,18 @@ xpc_allocate_local_msgqueue(struct xpc_channel *ch)
464 ch->local_nentries = nentries; 464 ch->local_nentries = nentries;
465 } 465 }
466 spin_unlock_irqrestore(&ch->lock, irq_flags); 466 spin_unlock_irqrestore(&ch->lock, irq_flags);
467 return xpcSuccess; 467 return xpSuccess;
468 } 468 }
469 469
470 dev_dbg(xpc_chan, "can't get memory for local message queue and notify " 470 dev_dbg(xpc_chan, "can't get memory for local message queue and notify "
471 "queue, partid=%d, channel=%d\n", ch->partid, ch->number); 471 "queue, partid=%d, channel=%d\n", ch->partid, ch->number);
472 return xpcNoMemory; 472 return xpNoMemory;
473} 473}
474 474
475/* 475/*
476 * Allocate the cached remote message queue. 476 * Allocate the cached remote message queue.
477 */ 477 */
478static enum xpc_retval 478static enum xp_retval
479xpc_allocate_remote_msgqueue(struct xpc_channel *ch) 479xpc_allocate_remote_msgqueue(struct xpc_channel *ch)
480{ 480{
481 unsigned long irq_flags; 481 unsigned long irq_flags;
@@ -502,12 +502,12 @@ xpc_allocate_remote_msgqueue(struct xpc_channel *ch)
502 ch->remote_nentries = nentries; 502 ch->remote_nentries = nentries;
503 } 503 }
504 spin_unlock_irqrestore(&ch->lock, irq_flags); 504 spin_unlock_irqrestore(&ch->lock, irq_flags);
505 return xpcSuccess; 505 return xpSuccess;
506 } 506 }
507 507
508 dev_dbg(xpc_chan, "can't get memory for cached remote message queue, " 508 dev_dbg(xpc_chan, "can't get memory for cached remote message queue, "
509 "partid=%d, channel=%d\n", ch->partid, ch->number); 509 "partid=%d, channel=%d\n", ch->partid, ch->number);
510 return xpcNoMemory; 510 return xpNoMemory;
511} 511}
512 512
513/* 513/*
@@ -515,20 +515,20 @@ xpc_allocate_remote_msgqueue(struct xpc_channel *ch)
515 * 515 *
516 * Note: Assumes all of the channel sizes are filled in. 516 * Note: Assumes all of the channel sizes are filled in.
517 */ 517 */
518static enum xpc_retval 518static enum xp_retval
519xpc_allocate_msgqueues(struct xpc_channel *ch) 519xpc_allocate_msgqueues(struct xpc_channel *ch)
520{ 520{
521 unsigned long irq_flags; 521 unsigned long irq_flags;
522 enum xpc_retval ret; 522 enum xp_retval ret;
523 523
524 DBUG_ON(ch->flags & XPC_C_SETUP); 524 DBUG_ON(ch->flags & XPC_C_SETUP);
525 525
526 ret = xpc_allocate_local_msgqueue(ch); 526 ret = xpc_allocate_local_msgqueue(ch);
527 if (ret != xpcSuccess) 527 if (ret != xpSuccess)
528 return ret; 528 return ret;
529 529
530 ret = xpc_allocate_remote_msgqueue(ch); 530 ret = xpc_allocate_remote_msgqueue(ch);
531 if (ret != xpcSuccess) { 531 if (ret != xpSuccess) {
532 kfree(ch->local_msgqueue_base); 532 kfree(ch->local_msgqueue_base);
533 ch->local_msgqueue = NULL; 533 ch->local_msgqueue = NULL;
534 kfree(ch->notify_queue); 534 kfree(ch->notify_queue);
@@ -540,7 +540,7 @@ xpc_allocate_msgqueues(struct xpc_channel *ch)
540 ch->flags |= XPC_C_SETUP; 540 ch->flags |= XPC_C_SETUP;
541 spin_unlock_irqrestore(&ch->lock, irq_flags); 541 spin_unlock_irqrestore(&ch->lock, irq_flags);
542 542
543 return xpcSuccess; 543 return xpSuccess;
544} 544}
545 545
546/* 546/*
@@ -552,7 +552,7 @@ xpc_allocate_msgqueues(struct xpc_channel *ch)
552static void 552static void
553xpc_process_connect(struct xpc_channel *ch, unsigned long *irq_flags) 553xpc_process_connect(struct xpc_channel *ch, unsigned long *irq_flags)
554{ 554{
555 enum xpc_retval ret; 555 enum xp_retval ret;
556 556
557 DBUG_ON(!spin_is_locked(&ch->lock)); 557 DBUG_ON(!spin_is_locked(&ch->lock));
558 558
@@ -568,7 +568,7 @@ xpc_process_connect(struct xpc_channel *ch, unsigned long *irq_flags)
568 ret = xpc_allocate_msgqueues(ch); 568 ret = xpc_allocate_msgqueues(ch);
569 spin_lock_irqsave(&ch->lock, *irq_flags); 569 spin_lock_irqsave(&ch->lock, *irq_flags);
570 570
571 if (ret != xpcSuccess) 571 if (ret != xpSuccess)
572 XPC_DISCONNECT_CHANNEL(ch, ret, irq_flags); 572 XPC_DISCONNECT_CHANNEL(ch, ret, irq_flags);
573 573
574 if (ch->flags & (XPC_C_CONNECTED | XPC_C_DISCONNECTING)) 574 if (ch->flags & (XPC_C_CONNECTED | XPC_C_DISCONNECTING))
@@ -603,7 +603,7 @@ xpc_process_connect(struct xpc_channel *ch, unsigned long *irq_flags)
603 * Notify those who wanted to be notified upon delivery of their message. 603 * Notify those who wanted to be notified upon delivery of their message.
604 */ 604 */
605static void 605static void
606xpc_notify_senders(struct xpc_channel *ch, enum xpc_retval reason, s64 put) 606xpc_notify_senders(struct xpc_channel *ch, enum xp_retval reason, s64 put)
607{ 607{
608 struct xpc_notify *notify; 608 struct xpc_notify *notify;
609 u8 notify_type; 609 u8 notify_type;
@@ -748,7 +748,7 @@ xpc_process_disconnect(struct xpc_channel *ch, unsigned long *irq_flags)
748 748
749 if (ch->flags & XPC_C_DISCONNECTINGCALLOUT_MADE) { 749 if (ch->flags & XPC_C_DISCONNECTINGCALLOUT_MADE) {
750 spin_unlock_irqrestore(&ch->lock, *irq_flags); 750 spin_unlock_irqrestore(&ch->lock, *irq_flags);
751 xpc_disconnect_callout(ch, xpcDisconnected); 751 xpc_disconnect_callout(ch, xpDisconnected);
752 spin_lock_irqsave(&ch->lock, *irq_flags); 752 spin_lock_irqsave(&ch->lock, *irq_flags);
753 } 753 }
754 754
@@ -791,7 +791,7 @@ xpc_process_openclose_IPI(struct xpc_partition *part, int ch_number,
791 struct xpc_openclose_args *args = 791 struct xpc_openclose_args *args =
792 &part->remote_openclose_args[ch_number]; 792 &part->remote_openclose_args[ch_number];
793 struct xpc_channel *ch = &part->channels[ch_number]; 793 struct xpc_channel *ch = &part->channels[ch_number];
794 enum xpc_retval reason; 794 enum xp_retval reason;
795 795
796 spin_lock_irqsave(&ch->lock, irq_flags); 796 spin_lock_irqsave(&ch->lock, irq_flags);
797 797
@@ -871,10 +871,10 @@ again:
871 871
872 if (!(ch->flags & XPC_C_DISCONNECTING)) { 872 if (!(ch->flags & XPC_C_DISCONNECTING)) {
873 reason = args->reason; 873 reason = args->reason;
874 if (reason <= xpcSuccess || reason > xpcUnknownReason) 874 if (reason <= xpSuccess || reason > xpUnknownReason)
875 reason = xpcUnknownReason; 875 reason = xpUnknownReason;
876 else if (reason == xpcUnregistering) 876 else if (reason == xpUnregistering)
877 reason = xpcOtherUnregistering; 877 reason = xpOtherUnregistering;
878 878
879 XPC_DISCONNECT_CHANNEL(ch, reason, &irq_flags); 879 XPC_DISCONNECT_CHANNEL(ch, reason, &irq_flags);
880 880
@@ -961,7 +961,7 @@ again:
961 961
962 if (ch->flags & XPC_C_OPENREQUEST) { 962 if (ch->flags & XPC_C_OPENREQUEST) {
963 if (args->msg_size != ch->msg_size) { 963 if (args->msg_size != ch->msg_size) {
964 XPC_DISCONNECT_CHANNEL(ch, xpcUnequalMsgSizes, 964 XPC_DISCONNECT_CHANNEL(ch, xpUnequalMsgSizes,
965 &irq_flags); 965 &irq_flags);
966 spin_unlock_irqrestore(&ch->lock, irq_flags); 966 spin_unlock_irqrestore(&ch->lock, irq_flags);
967 return; 967 return;
@@ -991,7 +991,7 @@ again:
991 return; 991 return;
992 } 992 }
993 if (!(ch->flags & XPC_C_OPENREQUEST)) { 993 if (!(ch->flags & XPC_C_OPENREQUEST)) {
994 XPC_DISCONNECT_CHANNEL(ch, xpcOpenCloseError, 994 XPC_DISCONNECT_CHANNEL(ch, xpOpenCloseError,
995 &irq_flags); 995 &irq_flags);
996 spin_unlock_irqrestore(&ch->lock, irq_flags); 996 spin_unlock_irqrestore(&ch->lock, irq_flags);
997 return; 997 return;
@@ -1042,18 +1042,18 @@ again:
1042/* 1042/*
1043 * Attempt to establish a channel connection to a remote partition. 1043 * Attempt to establish a channel connection to a remote partition.
1044 */ 1044 */
1045static enum xpc_retval 1045static enum xp_retval
1046xpc_connect_channel(struct xpc_channel *ch) 1046xpc_connect_channel(struct xpc_channel *ch)
1047{ 1047{
1048 unsigned long irq_flags; 1048 unsigned long irq_flags;
1049 struct xpc_registration *registration = &xpc_registrations[ch->number]; 1049 struct xpc_registration *registration = &xpc_registrations[ch->number];
1050 1050
1051 if (mutex_trylock(&registration->mutex) == 0) 1051 if (mutex_trylock(&registration->mutex) == 0)
1052 return xpcRetry; 1052 return xpRetry;
1053 1053
1054 if (!XPC_CHANNEL_REGISTERED(ch->number)) { 1054 if (!XPC_CHANNEL_REGISTERED(ch->number)) {
1055 mutex_unlock(&registration->mutex); 1055 mutex_unlock(&registration->mutex);
1056 return xpcUnregistered; 1056 return xpUnregistered;
1057 } 1057 }
1058 1058
1059 spin_lock_irqsave(&ch->lock, irq_flags); 1059 spin_lock_irqsave(&ch->lock, irq_flags);
@@ -1095,10 +1095,10 @@ xpc_connect_channel(struct xpc_channel *ch)
1095 * the channel lock as needed. 1095 * the channel lock as needed.
1096 */ 1096 */
1097 mutex_unlock(&registration->mutex); 1097 mutex_unlock(&registration->mutex);
1098 XPC_DISCONNECT_CHANNEL(ch, xpcUnequalMsgSizes, 1098 XPC_DISCONNECT_CHANNEL(ch, xpUnequalMsgSizes,
1099 &irq_flags); 1099 &irq_flags);
1100 spin_unlock_irqrestore(&ch->lock, irq_flags); 1100 spin_unlock_irqrestore(&ch->lock, irq_flags);
1101 return xpcUnequalMsgSizes; 1101 return xpUnequalMsgSizes;
1102 } 1102 }
1103 } else { 1103 } else {
1104 ch->msg_size = registration->msg_size; 1104 ch->msg_size = registration->msg_size;
@@ -1120,7 +1120,7 @@ xpc_connect_channel(struct xpc_channel *ch)
1120 1120
1121 spin_unlock_irqrestore(&ch->lock, irq_flags); 1121 spin_unlock_irqrestore(&ch->lock, irq_flags);
1122 1122
1123 return xpcSuccess; 1123 return xpSuccess;
1124} 1124}
1125 1125
1126/* 1126/*
@@ -1203,7 +1203,7 @@ xpc_process_msg_IPI(struct xpc_partition *part, int ch_number)
1203 * Notify senders that messages sent have been 1203 * Notify senders that messages sent have been
1204 * received and delivered by the other side. 1204 * received and delivered by the other side.
1205 */ 1205 */
1206 xpc_notify_senders(ch, xpcMsgDelivered, 1206 xpc_notify_senders(ch, xpMsgDelivered,
1207 ch->remote_GP.get); 1207 ch->remote_GP.get);
1208 } 1208 }
1209 1209
@@ -1335,7 +1335,7 @@ xpc_process_channel_activity(struct xpc_partition *part)
1335 * at the same time. 1335 * at the same time.
1336 */ 1336 */
1337void 1337void
1338xpc_partition_going_down(struct xpc_partition *part, enum xpc_retval reason) 1338xpc_partition_going_down(struct xpc_partition *part, enum xp_retval reason)
1339{ 1339{
1340 unsigned long irq_flags; 1340 unsigned long irq_flags;
1341 int ch_number; 1341 int ch_number;
@@ -1375,7 +1375,7 @@ xpc_partition_going_down(struct xpc_partition *part, enum xpc_retval reason)
1375void 1375void
1376xpc_teardown_infrastructure(struct xpc_partition *part) 1376xpc_teardown_infrastructure(struct xpc_partition *part)
1377{ 1377{
1378 partid_t partid = XPC_PARTID(part); 1378 short partid = XPC_PARTID(part);
1379 1379
1380 /* 1380 /*
1381 * We start off by making this partition inaccessible to local 1381 * We start off by making this partition inaccessible to local
@@ -1428,7 +1428,7 @@ xpc_teardown_infrastructure(struct xpc_partition *part)
1428void 1428void
1429xpc_initiate_connect(int ch_number) 1429xpc_initiate_connect(int ch_number)
1430{ 1430{
1431 partid_t partid; 1431 short partid;
1432 struct xpc_partition *part; 1432 struct xpc_partition *part;
1433 struct xpc_channel *ch; 1433 struct xpc_channel *ch;
1434 1434
@@ -1456,13 +1456,13 @@ xpc_connected_callout(struct xpc_channel *ch)
1456 /* let the registerer know that a connection has been established */ 1456 /* let the registerer know that a connection has been established */
1457 1457
1458 if (ch->func != NULL) { 1458 if (ch->func != NULL) {
1459 dev_dbg(xpc_chan, "ch->func() called, reason=xpcConnected, " 1459 dev_dbg(xpc_chan, "ch->func() called, reason=xpConnected, "
1460 "partid=%d, channel=%d\n", ch->partid, ch->number); 1460 "partid=%d, channel=%d\n", ch->partid, ch->number);
1461 1461
1462 ch->func(xpcConnected, ch->partid, ch->number, 1462 ch->func(xpConnected, ch->partid, ch->number,
1463 (void *)(u64)ch->local_nentries, ch->key); 1463 (void *)(u64)ch->local_nentries, ch->key);
1464 1464
1465 dev_dbg(xpc_chan, "ch->func() returned, reason=xpcConnected, " 1465 dev_dbg(xpc_chan, "ch->func() returned, reason=xpConnected, "
1466 "partid=%d, channel=%d\n", ch->partid, ch->number); 1466 "partid=%d, channel=%d\n", ch->partid, ch->number);
1467 } 1467 }
1468} 1468}
@@ -1484,7 +1484,7 @@ void
1484xpc_initiate_disconnect(int ch_number) 1484xpc_initiate_disconnect(int ch_number)
1485{ 1485{
1486 unsigned long irq_flags; 1486 unsigned long irq_flags;
1487 partid_t partid; 1487 short partid;
1488 struct xpc_partition *part; 1488 struct xpc_partition *part;
1489 struct xpc_channel *ch; 1489 struct xpc_channel *ch;
1490 1490
@@ -1503,7 +1503,7 @@ xpc_initiate_disconnect(int ch_number)
1503 if (!(ch->flags & XPC_C_DISCONNECTED)) { 1503 if (!(ch->flags & XPC_C_DISCONNECTED)) {
1504 ch->flags |= XPC_C_WDISCONNECT; 1504 ch->flags |= XPC_C_WDISCONNECT;
1505 1505
1506 XPC_DISCONNECT_CHANNEL(ch, xpcUnregistering, 1506 XPC_DISCONNECT_CHANNEL(ch, xpUnregistering,
1507 &irq_flags); 1507 &irq_flags);
1508 } 1508 }
1509 1509
@@ -1528,7 +1528,7 @@ xpc_initiate_disconnect(int ch_number)
1528 */ 1528 */
1529void 1529void
1530xpc_disconnect_channel(const int line, struct xpc_channel *ch, 1530xpc_disconnect_channel(const int line, struct xpc_channel *ch,
1531 enum xpc_retval reason, unsigned long *irq_flags) 1531 enum xp_retval reason, unsigned long *irq_flags)
1532{ 1532{
1533 u32 channel_was_connected = (ch->flags & XPC_C_CONNECTED); 1533 u32 channel_was_connected = (ch->flags & XPC_C_CONNECTED);
1534 1534
@@ -1563,7 +1563,7 @@ xpc_disconnect_channel(const int line, struct xpc_channel *ch,
1563 1563
1564 } else if ((ch->flags & XPC_C_CONNECTEDCALLOUT_MADE) && 1564 } else if ((ch->flags & XPC_C_CONNECTEDCALLOUT_MADE) &&
1565 !(ch->flags & XPC_C_DISCONNECTINGCALLOUT)) { 1565 !(ch->flags & XPC_C_DISCONNECTINGCALLOUT)) {
1566 /* start a kthread that will do the xpcDisconnecting callout */ 1566 /* start a kthread that will do the xpDisconnecting callout */
1567 xpc_create_kthreads(ch, 1, 1); 1567 xpc_create_kthreads(ch, 1, 1);
1568 } 1568 }
1569 1569
@@ -1575,7 +1575,7 @@ xpc_disconnect_channel(const int line, struct xpc_channel *ch,
1575} 1575}
1576 1576
1577void 1577void
1578xpc_disconnect_callout(struct xpc_channel *ch, enum xpc_retval reason) 1578xpc_disconnect_callout(struct xpc_channel *ch, enum xp_retval reason)
1579{ 1579{
1580 /* 1580 /*
1581 * Let the channel's registerer know that the channel is being 1581 * Let the channel's registerer know that the channel is being
@@ -1598,13 +1598,13 @@ xpc_disconnect_callout(struct xpc_channel *ch, enum xpc_retval reason)
1598 * Wait for a message entry to become available for the specified channel, 1598 * Wait for a message entry to become available for the specified channel,
1599 * but don't wait any longer than 1 jiffy. 1599 * but don't wait any longer than 1 jiffy.
1600 */ 1600 */
1601static enum xpc_retval 1601static enum xp_retval
1602xpc_allocate_msg_wait(struct xpc_channel *ch) 1602xpc_allocate_msg_wait(struct xpc_channel *ch)
1603{ 1603{
1604 enum xpc_retval ret; 1604 enum xp_retval ret;
1605 1605
1606 if (ch->flags & XPC_C_DISCONNECTING) { 1606 if (ch->flags & XPC_C_DISCONNECTING) {
1607 DBUG_ON(ch->reason == xpcInterrupted); 1607 DBUG_ON(ch->reason == xpInterrupted);
1608 return ch->reason; 1608 return ch->reason;
1609 } 1609 }
1610 1610
@@ -1614,11 +1614,11 @@ xpc_allocate_msg_wait(struct xpc_channel *ch)
1614 1614
1615 if (ch->flags & XPC_C_DISCONNECTING) { 1615 if (ch->flags & XPC_C_DISCONNECTING) {
1616 ret = ch->reason; 1616 ret = ch->reason;
1617 DBUG_ON(ch->reason == xpcInterrupted); 1617 DBUG_ON(ch->reason == xpInterrupted);
1618 } else if (ret == 0) { 1618 } else if (ret == 0) {
1619 ret = xpcTimeout; 1619 ret = xpTimeout;
1620 } else { 1620 } else {
1621 ret = xpcInterrupted; 1621 ret = xpInterrupted;
1622 } 1622 }
1623 1623
1624 return ret; 1624 return ret;
@@ -1628,12 +1628,12 @@ xpc_allocate_msg_wait(struct xpc_channel *ch)
1628 * Allocate an entry for a message from the message queue associated with the 1628 * Allocate an entry for a message from the message queue associated with the
1629 * specified channel. 1629 * specified channel.
1630 */ 1630 */
1631static enum xpc_retval 1631static enum xp_retval
1632xpc_allocate_msg(struct xpc_channel *ch, u32 flags, 1632xpc_allocate_msg(struct xpc_channel *ch, u32 flags,
1633 struct xpc_msg **address_of_msg) 1633 struct xpc_msg **address_of_msg)
1634{ 1634{
1635 struct xpc_msg *msg; 1635 struct xpc_msg *msg;
1636 enum xpc_retval ret; 1636 enum xp_retval ret;
1637 s64 put; 1637 s64 put;
1638 1638
1639 /* this reference will be dropped in xpc_send_msg() */ 1639 /* this reference will be dropped in xpc_send_msg() */
@@ -1645,7 +1645,7 @@ xpc_allocate_msg(struct xpc_channel *ch, u32 flags,
1645 } 1645 }
1646 if (!(ch->flags & XPC_C_CONNECTED)) { 1646 if (!(ch->flags & XPC_C_CONNECTED)) {
1647 xpc_msgqueue_deref(ch); 1647 xpc_msgqueue_deref(ch);
1648 return xpcNotConnected; 1648 return xpNotConnected;
1649 } 1649 }
1650 1650
1651 /* 1651 /*
@@ -1653,7 +1653,7 @@ xpc_allocate_msg(struct xpc_channel *ch, u32 flags,
1653 * If none are available, we'll make sure that we grab the latest 1653 * If none are available, we'll make sure that we grab the latest
1654 * GP values. 1654 * GP values.
1655 */ 1655 */
1656 ret = xpcTimeout; 1656 ret = xpTimeout;
1657 1657
1658 while (1) { 1658 while (1) {
1659 1659
@@ -1683,16 +1683,16 @@ xpc_allocate_msg(struct xpc_channel *ch, u32 flags,
1683 * that will cause the IPI handler to fetch the latest 1683 * that will cause the IPI handler to fetch the latest
1684 * GP values as if an IPI was sent by the other side. 1684 * GP values as if an IPI was sent by the other side.
1685 */ 1685 */
1686 if (ret == xpcTimeout) 1686 if (ret == xpTimeout)
1687 xpc_IPI_send_local_msgrequest(ch); 1687 xpc_IPI_send_local_msgrequest(ch);
1688 1688
1689 if (flags & XPC_NOWAIT) { 1689 if (flags & XPC_NOWAIT) {
1690 xpc_msgqueue_deref(ch); 1690 xpc_msgqueue_deref(ch);
1691 return xpcNoWait; 1691 return xpNoWait;
1692 } 1692 }
1693 1693
1694 ret = xpc_allocate_msg_wait(ch); 1694 ret = xpc_allocate_msg_wait(ch);
1695 if (ret != xpcInterrupted && ret != xpcTimeout) { 1695 if (ret != xpInterrupted && ret != xpTimeout) {
1696 xpc_msgqueue_deref(ch); 1696 xpc_msgqueue_deref(ch);
1697 return ret; 1697 return ret;
1698 } 1698 }
@@ -1711,7 +1711,7 @@ xpc_allocate_msg(struct xpc_channel *ch, u32 flags,
1711 1711
1712 *address_of_msg = msg; 1712 *address_of_msg = msg;
1713 1713
1714 return xpcSuccess; 1714 return xpSuccess;
1715} 1715}
1716 1716
1717/* 1717/*
@@ -1727,11 +1727,11 @@ xpc_allocate_msg(struct xpc_channel *ch, u32 flags,
1727 * payload - address of the allocated payload area pointer (filled in on 1727 * payload - address of the allocated payload area pointer (filled in on
1728 * return) in which the user-defined message is constructed. 1728 * return) in which the user-defined message is constructed.
1729 */ 1729 */
1730enum xpc_retval 1730enum xp_retval
1731xpc_initiate_allocate(partid_t partid, int ch_number, u32 flags, void **payload) 1731xpc_initiate_allocate(short partid, int ch_number, u32 flags, void **payload)
1732{ 1732{
1733 struct xpc_partition *part = &xpc_partitions[partid]; 1733 struct xpc_partition *part = &xpc_partitions[partid];
1734 enum xpc_retval ret = xpcUnknownReason; 1734 enum xp_retval ret = xpUnknownReason;
1735 struct xpc_msg *msg = NULL; 1735 struct xpc_msg *msg = NULL;
1736 1736
1737 DBUG_ON(partid <= 0 || partid >= XP_MAX_PARTITIONS); 1737 DBUG_ON(partid <= 0 || partid >= XP_MAX_PARTITIONS);
@@ -1814,11 +1814,11 @@ xpc_send_msgs(struct xpc_channel *ch, s64 initial_put)
1814 * local message queue's Put value and sends an IPI to the partition the 1814 * local message queue's Put value and sends an IPI to the partition the
1815 * message is being sent to. 1815 * message is being sent to.
1816 */ 1816 */
1817static enum xpc_retval 1817static enum xp_retval
1818xpc_send_msg(struct xpc_channel *ch, struct xpc_msg *msg, u8 notify_type, 1818xpc_send_msg(struct xpc_channel *ch, struct xpc_msg *msg, u8 notify_type,
1819 xpc_notify_func func, void *key) 1819 xpc_notify_func func, void *key)
1820{ 1820{
1821 enum xpc_retval ret = xpcSuccess; 1821 enum xp_retval ret = xpSuccess;
1822 struct xpc_notify *notify = notify; 1822 struct xpc_notify *notify = notify;
1823 s64 put, msg_number = msg->number; 1823 s64 put, msg_number = msg->number;
1824 1824
@@ -1908,12 +1908,12 @@ xpc_send_msg(struct xpc_channel *ch, struct xpc_msg *msg, u8 notify_type,
1908 * payload - pointer to the payload area allocated via 1908 * payload - pointer to the payload area allocated via
1909 * xpc_initiate_allocate(). 1909 * xpc_initiate_allocate().
1910 */ 1910 */
1911enum xpc_retval 1911enum xp_retval
1912xpc_initiate_send(partid_t partid, int ch_number, void *payload) 1912xpc_initiate_send(short partid, int ch_number, void *payload)
1913{ 1913{
1914 struct xpc_partition *part = &xpc_partitions[partid]; 1914 struct xpc_partition *part = &xpc_partitions[partid];
1915 struct xpc_msg *msg = XPC_MSG_ADDRESS(payload); 1915 struct xpc_msg *msg = XPC_MSG_ADDRESS(payload);
1916 enum xpc_retval ret; 1916 enum xp_retval ret;
1917 1917
1918 dev_dbg(xpc_chan, "msg=0x%p, partid=%d, channel=%d\n", (void *)msg, 1918 dev_dbg(xpc_chan, "msg=0x%p, partid=%d, channel=%d\n", (void *)msg,
1919 partid, ch_number); 1919 partid, ch_number);
@@ -1957,13 +1957,13 @@ xpc_initiate_send(partid_t partid, int ch_number, void *payload)
1957 * receipt. THIS FUNCTION MUST BE NON-BLOCKING. 1957 * receipt. THIS FUNCTION MUST BE NON-BLOCKING.
1958 * key - user-defined key to be passed to the function when it's called. 1958 * key - user-defined key to be passed to the function when it's called.
1959 */ 1959 */
1960enum xpc_retval 1960enum xp_retval
1961xpc_initiate_send_notify(partid_t partid, int ch_number, void *payload, 1961xpc_initiate_send_notify(short partid, int ch_number, void *payload,
1962 xpc_notify_func func, void *key) 1962 xpc_notify_func func, void *key)
1963{ 1963{
1964 struct xpc_partition *part = &xpc_partitions[partid]; 1964 struct xpc_partition *part = &xpc_partitions[partid];
1965 struct xpc_msg *msg = XPC_MSG_ADDRESS(payload); 1965 struct xpc_msg *msg = XPC_MSG_ADDRESS(payload);
1966 enum xpc_retval ret; 1966 enum xp_retval ret;
1967 1967
1968 dev_dbg(xpc_chan, "msg=0x%p, partid=%d, channel=%d\n", (void *)msg, 1968 dev_dbg(xpc_chan, "msg=0x%p, partid=%d, channel=%d\n", (void *)msg,
1969 partid, ch_number); 1969 partid, ch_number);
@@ -1985,7 +1985,7 @@ xpc_pull_remote_msg(struct xpc_channel *ch, s64 get)
1985 struct xpc_msg *remote_msg, *msg; 1985 struct xpc_msg *remote_msg, *msg;
1986 u32 msg_index, nmsgs; 1986 u32 msg_index, nmsgs;
1987 u64 msg_offset; 1987 u64 msg_offset;
1988 enum xpc_retval ret; 1988 enum xp_retval ret;
1989 1989
1990 if (mutex_lock_interruptible(&ch->msg_to_pull_mutex) != 0) { 1990 if (mutex_lock_interruptible(&ch->msg_to_pull_mutex) != 0) {
1991 /* we were interrupted by a signal */ 1991 /* we were interrupted by a signal */
@@ -2012,7 +2012,7 @@ xpc_pull_remote_msg(struct xpc_channel *ch, s64 get)
2012 2012
2013 ret = xpc_pull_remote_cachelines(part, msg, remote_msg, 2013 ret = xpc_pull_remote_cachelines(part, msg, remote_msg,
2014 nmsgs * ch->msg_size); 2014 nmsgs * ch->msg_size);
2015 if (ret != xpcSuccess) { 2015 if (ret != xpSuccess) {
2016 2016
2017 dev_dbg(xpc_chan, "failed to pull %d msgs starting with" 2017 dev_dbg(xpc_chan, "failed to pull %d msgs starting with"
2018 " msg %ld from partition %d, channel=%d, " 2018 " msg %ld from partition %d, channel=%d, "
@@ -2112,7 +2112,7 @@ xpc_deliver_msg(struct xpc_channel *ch)
2112 ch->number); 2112 ch->number);
2113 2113
2114 /* deliver the message to its intended recipient */ 2114 /* deliver the message to its intended recipient */
2115 ch->func(xpcMsgReceived, ch->partid, ch->number, 2115 ch->func(xpMsgReceived, ch->partid, ch->number,
2116 &msg->payload, ch->key); 2116 &msg->payload, ch->key);
2117 2117
2118 dev_dbg(xpc_chan, "ch->func() returned, msg=0x%p, " 2118 dev_dbg(xpc_chan, "ch->func() returned, msg=0x%p, "
@@ -2203,7 +2203,7 @@ xpc_acknowledge_msgs(struct xpc_channel *ch, s64 initial_get, u8 msg_flags)
2203 * xpc_initiate_allocate(). 2203 * xpc_initiate_allocate().
2204 */ 2204 */
2205void 2205void
2206xpc_initiate_received(partid_t partid, int ch_number, void *payload) 2206xpc_initiate_received(short partid, int ch_number, void *payload)
2207{ 2207{
2208 struct xpc_partition *part = &xpc_partitions[partid]; 2208 struct xpc_partition *part = &xpc_partitions[partid];
2209 struct xpc_channel *ch; 2209 struct xpc_channel *ch;
diff --git a/drivers/misc/sgi-xp/xpc_main.c b/drivers/misc/sgi-xp/xpc_main.c
index f673ba90eb0e..08256ed0d9a6 100644
--- a/drivers/misc/sgi-xp/xpc_main.c
+++ b/drivers/misc/sgi-xp/xpc_main.c
@@ -315,13 +315,13 @@ xpc_initiate_discovery(void *ignore)
315 * the XPC per partition variables from the remote partition and waiting for 315 * the XPC per partition variables from the remote partition and waiting for
316 * the remote partition to pull ours. 316 * the remote partition to pull ours.
317 */ 317 */
318static enum xpc_retval 318static enum xp_retval
319xpc_make_first_contact(struct xpc_partition *part) 319xpc_make_first_contact(struct xpc_partition *part)
320{ 320{
321 enum xpc_retval ret; 321 enum xp_retval ret;
322 322
323 while ((ret = xpc_pull_remote_vars_part(part)) != xpcSuccess) { 323 while ((ret = xpc_pull_remote_vars_part(part)) != xpSuccess) {
324 if (ret != xpcRetry) { 324 if (ret != xpRetry) {
325 XPC_DEACTIVATE_PARTITION(part, ret); 325 XPC_DEACTIVATE_PARTITION(part, ret);
326 return ret; 326 return ret;
327 } 327 }
@@ -406,7 +406,7 @@ xpc_partition_up(struct xpc_partition *part)
406 406
407 dev_dbg(xpc_chan, "activating partition %d\n", XPC_PARTID(part)); 407 dev_dbg(xpc_chan, "activating partition %d\n", XPC_PARTID(part));
408 408
409 if (xpc_setup_infrastructure(part) != xpcSuccess) 409 if (xpc_setup_infrastructure(part) != xpSuccess)
410 return; 410 return;
411 411
412 /* 412 /*
@@ -418,7 +418,7 @@ xpc_partition_up(struct xpc_partition *part)
418 418
419 (void)xpc_part_ref(part); /* this will always succeed */ 419 (void)xpc_part_ref(part); /* this will always succeed */
420 420
421 if (xpc_make_first_contact(part) == xpcSuccess) 421 if (xpc_make_first_contact(part) == xpSuccess)
422 xpc_channel_mgr(part); 422 xpc_channel_mgr(part);
423 423
424 xpc_part_deref(part); 424 xpc_part_deref(part);
@@ -429,7 +429,7 @@ xpc_partition_up(struct xpc_partition *part)
429static int 429static int
430xpc_activating(void *__partid) 430xpc_activating(void *__partid)
431{ 431{
432 partid_t partid = (u64)__partid; 432 short partid = (u64)__partid;
433 struct xpc_partition *part = &xpc_partitions[partid]; 433 struct xpc_partition *part = &xpc_partitions[partid];
434 unsigned long irq_flags; 434 unsigned long irq_flags;
435 435
@@ -470,7 +470,7 @@ xpc_activating(void *__partid)
470 470
471 spin_lock_irqsave(&part->act_lock, irq_flags); 471 spin_lock_irqsave(&part->act_lock, irq_flags);
472 part->act_state = XPC_P_INACTIVE; 472 part->act_state = XPC_P_INACTIVE;
473 XPC_SET_REASON(part, xpcPhysAddrRegFailed, __LINE__); 473 XPC_SET_REASON(part, xpPhysAddrRegFailed, __LINE__);
474 spin_unlock_irqrestore(&part->act_lock, irq_flags); 474 spin_unlock_irqrestore(&part->act_lock, irq_flags);
475 part->remote_rp_pa = 0; 475 part->remote_rp_pa = 0;
476 return 0; 476 return 0;
@@ -488,7 +488,7 @@ xpc_activating(void *__partid)
488 xpc_disallow_hb(partid, xpc_vars); 488 xpc_disallow_hb(partid, xpc_vars);
489 xpc_mark_partition_inactive(part); 489 xpc_mark_partition_inactive(part);
490 490
491 if (part->reason == xpcReactivating) { 491 if (part->reason == xpReactivating) {
492 /* interrupting ourselves results in activating partition */ 492 /* interrupting ourselves results in activating partition */
493 xpc_IPI_send_reactivate(part); 493 xpc_IPI_send_reactivate(part);
494 } 494 }
@@ -499,7 +499,7 @@ xpc_activating(void *__partid)
499void 499void
500xpc_activate_partition(struct xpc_partition *part) 500xpc_activate_partition(struct xpc_partition *part)
501{ 501{
502 partid_t partid = XPC_PARTID(part); 502 short partid = XPC_PARTID(part);
503 unsigned long irq_flags; 503 unsigned long irq_flags;
504 struct task_struct *kthread; 504 struct task_struct *kthread;
505 505
@@ -508,7 +508,7 @@ xpc_activate_partition(struct xpc_partition *part)
508 DBUG_ON(part->act_state != XPC_P_INACTIVE); 508 DBUG_ON(part->act_state != XPC_P_INACTIVE);
509 509
510 part->act_state = XPC_P_ACTIVATION_REQ; 510 part->act_state = XPC_P_ACTIVATION_REQ;
511 XPC_SET_REASON(part, xpcCloneKThread, __LINE__); 511 XPC_SET_REASON(part, xpCloneKThread, __LINE__);
512 512
513 spin_unlock_irqrestore(&part->act_lock, irq_flags); 513 spin_unlock_irqrestore(&part->act_lock, irq_flags);
514 514
@@ -517,7 +517,7 @@ xpc_activate_partition(struct xpc_partition *part)
517 if (IS_ERR(kthread)) { 517 if (IS_ERR(kthread)) {
518 spin_lock_irqsave(&part->act_lock, irq_flags); 518 spin_lock_irqsave(&part->act_lock, irq_flags);
519 part->act_state = XPC_P_INACTIVE; 519 part->act_state = XPC_P_INACTIVE;
520 XPC_SET_REASON(part, xpcCloneKThreadFailed, __LINE__); 520 XPC_SET_REASON(part, xpCloneKThreadFailed, __LINE__);
521 spin_unlock_irqrestore(&part->act_lock, irq_flags); 521 spin_unlock_irqrestore(&part->act_lock, irq_flags);
522 } 522 }
523} 523}
@@ -541,7 +541,7 @@ xpc_activate_partition(struct xpc_partition *part)
541irqreturn_t 541irqreturn_t
542xpc_notify_IRQ_handler(int irq, void *dev_id) 542xpc_notify_IRQ_handler(int irq, void *dev_id)
543{ 543{
544 partid_t partid = (partid_t) (u64)dev_id; 544 short partid = (short)(u64)dev_id;
545 struct xpc_partition *part = &xpc_partitions[partid]; 545 struct xpc_partition *part = &xpc_partitions[partid];
546 546
547 DBUG_ON(partid <= 0 || partid >= XP_MAX_PARTITIONS); 547 DBUG_ON(partid <= 0 || partid >= XP_MAX_PARTITIONS);
@@ -643,7 +643,7 @@ xpc_kthread_waitmsgs(struct xpc_partition *part, struct xpc_channel *ch)
643static int 643static int
644xpc_kthread_start(void *args) 644xpc_kthread_start(void *args)
645{ 645{
646 partid_t partid = XPC_UNPACK_ARG1(args); 646 short partid = XPC_UNPACK_ARG1(args);
647 u16 ch_number = XPC_UNPACK_ARG2(args); 647 u16 ch_number = XPC_UNPACK_ARG2(args);
648 struct xpc_partition *part = &xpc_partitions[partid]; 648 struct xpc_partition *part = &xpc_partitions[partid];
649 struct xpc_channel *ch; 649 struct xpc_channel *ch;
@@ -696,7 +696,7 @@ xpc_kthread_start(void *args)
696 ch->flags |= XPC_C_DISCONNECTINGCALLOUT; 696 ch->flags |= XPC_C_DISCONNECTINGCALLOUT;
697 spin_unlock_irqrestore(&ch->lock, irq_flags); 697 spin_unlock_irqrestore(&ch->lock, irq_flags);
698 698
699 xpc_disconnect_callout(ch, xpcDisconnecting); 699 xpc_disconnect_callout(ch, xpDisconnecting);
700 700
701 spin_lock_irqsave(&ch->lock, irq_flags); 701 spin_lock_irqsave(&ch->lock, irq_flags);
702 ch->flags |= XPC_C_DISCONNECTINGCALLOUT_MADE; 702 ch->flags |= XPC_C_DISCONNECTINGCALLOUT_MADE;
@@ -776,7 +776,7 @@ xpc_create_kthreads(struct xpc_channel *ch, int needed,
776 * then we'll deadlock if all other kthreads assigned 776 * then we'll deadlock if all other kthreads assigned
777 * to this channel are blocked in the channel's 777 * to this channel are blocked in the channel's
778 * registerer, because the only thing that will unblock 778 * registerer, because the only thing that will unblock
779 * them is the xpcDisconnecting callout that this 779 * them is the xpDisconnecting callout that this
780 * failed kthread_run() would have made. 780 * failed kthread_run() would have made.
781 */ 781 */
782 782
@@ -796,7 +796,7 @@ xpc_create_kthreads(struct xpc_channel *ch, int needed,
796 * to function. 796 * to function.
797 */ 797 */
798 spin_lock_irqsave(&ch->lock, irq_flags); 798 spin_lock_irqsave(&ch->lock, irq_flags);
799 XPC_DISCONNECT_CHANNEL(ch, xpcLackOfResources, 799 XPC_DISCONNECT_CHANNEL(ch, xpLackOfResources,
800 &irq_flags); 800 &irq_flags);
801 spin_unlock_irqrestore(&ch->lock, irq_flags); 801 spin_unlock_irqrestore(&ch->lock, irq_flags);
802 } 802 }
@@ -809,7 +809,7 @@ void
809xpc_disconnect_wait(int ch_number) 809xpc_disconnect_wait(int ch_number)
810{ 810{
811 unsigned long irq_flags; 811 unsigned long irq_flags;
812 partid_t partid; 812 short partid;
813 struct xpc_partition *part; 813 struct xpc_partition *part;
814 struct xpc_channel *ch; 814 struct xpc_channel *ch;
815 int wakeup_channel_mgr; 815 int wakeup_channel_mgr;
@@ -857,9 +857,9 @@ xpc_disconnect_wait(int ch_number)
857} 857}
858 858
859static void 859static void
860xpc_do_exit(enum xpc_retval reason) 860xpc_do_exit(enum xp_retval reason)
861{ 861{
862 partid_t partid; 862 short partid;
863 int active_part_count, printed_waiting_msg = 0; 863 int active_part_count, printed_waiting_msg = 0;
864 struct xpc_partition *part; 864 struct xpc_partition *part;
865 unsigned long printmsg_time, disengage_request_timeout = 0; 865 unsigned long printmsg_time, disengage_request_timeout = 0;
@@ -955,7 +955,7 @@ xpc_do_exit(enum xpc_retval reason)
955 del_timer_sync(&xpc_hb_timer); 955 del_timer_sync(&xpc_hb_timer);
956 DBUG_ON(xpc_vars->heartbeating_to_mask != 0); 956 DBUG_ON(xpc_vars->heartbeating_to_mask != 0);
957 957
958 if (reason == xpcUnloading) { 958 if (reason == xpUnloading) {
959 /* take ourselves off of the reboot_notifier_list */ 959 /* take ourselves off of the reboot_notifier_list */
960 (void)unregister_reboot_notifier(&xpc_reboot_notifier); 960 (void)unregister_reboot_notifier(&xpc_reboot_notifier);
961 961
@@ -981,20 +981,20 @@ xpc_do_exit(enum xpc_retval reason)
981static int 981static int
982xpc_system_reboot(struct notifier_block *nb, unsigned long event, void *unused) 982xpc_system_reboot(struct notifier_block *nb, unsigned long event, void *unused)
983{ 983{
984 enum xpc_retval reason; 984 enum xp_retval reason;
985 985
986 switch (event) { 986 switch (event) {
987 case SYS_RESTART: 987 case SYS_RESTART:
988 reason = xpcSystemReboot; 988 reason = xpSystemReboot;
989 break; 989 break;
990 case SYS_HALT: 990 case SYS_HALT:
991 reason = xpcSystemHalt; 991 reason = xpSystemHalt;
992 break; 992 break;
993 case SYS_POWER_OFF: 993 case SYS_POWER_OFF:
994 reason = xpcSystemPoweroff; 994 reason = xpSystemPoweroff;
995 break; 995 break;
996 default: 996 default:
997 reason = xpcSystemGoingDown; 997 reason = xpSystemGoingDown;
998 } 998 }
999 999
1000 xpc_do_exit(reason); 1000 xpc_do_exit(reason);
@@ -1008,7 +1008,7 @@ static void
1008xpc_die_disengage(void) 1008xpc_die_disengage(void)
1009{ 1009{
1010 struct xpc_partition *part; 1010 struct xpc_partition *part;
1011 partid_t partid; 1011 short partid;
1012 unsigned long engaged; 1012 unsigned long engaged;
1013 long time, printmsg_time, disengage_request_timeout; 1013 long time, printmsg_time, disengage_request_timeout;
1014 1014
@@ -1124,7 +1124,7 @@ int __init
1124xpc_init(void) 1124xpc_init(void)
1125{ 1125{
1126 int ret; 1126 int ret;
1127 partid_t partid; 1127 short partid;
1128 struct xpc_partition *part; 1128 struct xpc_partition *part;
1129 struct task_struct *kthread; 1129 struct task_struct *kthread;
1130 size_t buf_size; 1130 size_t buf_size;
@@ -1279,7 +1279,7 @@ xpc_init(void)
1279 /* mark this new thread as a non-starter */ 1279 /* mark this new thread as a non-starter */
1280 complete(&xpc_discovery_exited); 1280 complete(&xpc_discovery_exited);
1281 1281
1282 xpc_do_exit(xpcUnloading); 1282 xpc_do_exit(xpUnloading);
1283 return -EBUSY; 1283 return -EBUSY;
1284 } 1284 }
1285 1285
@@ -1297,7 +1297,7 @@ module_init(xpc_init);
1297void __exit 1297void __exit
1298xpc_exit(void) 1298xpc_exit(void)
1299{ 1299{
1300 xpc_do_exit(xpcUnloading); 1300 xpc_do_exit(xpUnloading);
1301} 1301}
1302 1302
1303module_exit(xpc_exit); 1303module_exit(xpc_exit);
diff --git a/drivers/misc/sgi-xp/xpc_partition.c b/drivers/misc/sgi-xp/xpc_partition.c
index acd3fd4285d7..7dd4b5812c42 100644
--- a/drivers/misc/sgi-xp/xpc_partition.c
+++ b/drivers/misc/sgi-xp/xpc_partition.c
@@ -403,7 +403,7 @@ xpc_check_remote_hb(void)
403{ 403{
404 struct xpc_vars *remote_vars; 404 struct xpc_vars *remote_vars;
405 struct xpc_partition *part; 405 struct xpc_partition *part;
406 partid_t partid; 406 short partid;
407 bte_result_t bres; 407 bte_result_t bres;
408 408
409 remote_vars = (struct xpc_vars *)xpc_remote_copy_buffer; 409 remote_vars = (struct xpc_vars *)xpc_remote_copy_buffer;
@@ -444,7 +444,7 @@ xpc_check_remote_hb(void)
444 (remote_vars->heartbeat_offline == 0)) || 444 (remote_vars->heartbeat_offline == 0)) ||
445 !xpc_hb_allowed(sn_partition_id, remote_vars)) { 445 !xpc_hb_allowed(sn_partition_id, remote_vars)) {
446 446
447 XPC_DEACTIVATE_PARTITION(part, xpcNoHeartbeat); 447 XPC_DEACTIVATE_PARTITION(part, xpNoHeartbeat);
448 continue; 448 continue;
449 } 449 }
450 450
@@ -459,7 +459,7 @@ xpc_check_remote_hb(void)
459 * is large enough to contain a copy of their reserved page header and 459 * is large enough to contain a copy of their reserved page header and
460 * part_nasids mask. 460 * part_nasids mask.
461 */ 461 */
462static enum xpc_retval 462static enum xp_retval
463xpc_get_remote_rp(int nasid, u64 *discovered_nasids, 463xpc_get_remote_rp(int nasid, u64 *discovered_nasids,
464 struct xpc_rsvd_page *remote_rp, u64 *remote_rp_pa) 464 struct xpc_rsvd_page *remote_rp, u64 *remote_rp_pa)
465{ 465{
@@ -469,7 +469,7 @@ xpc_get_remote_rp(int nasid, u64 *discovered_nasids,
469 469
470 *remote_rp_pa = xpc_get_rsvd_page_pa(nasid); 470 *remote_rp_pa = xpc_get_rsvd_page_pa(nasid);
471 if (*remote_rp_pa == 0) 471 if (*remote_rp_pa == 0)
472 return xpcNoRsvdPageAddr; 472 return xpNoRsvdPageAddr;
473 473
474 /* pull over the reserved page header and part_nasids mask */ 474 /* pull over the reserved page header and part_nasids mask */
475 bres = xp_bte_copy(*remote_rp_pa, (u64)remote_rp, 475 bres = xp_bte_copy(*remote_rp_pa, (u64)remote_rp,
@@ -489,18 +489,18 @@ xpc_get_remote_rp(int nasid, u64 *discovered_nasids,
489 489
490 if (remote_rp->partid < 1 || 490 if (remote_rp->partid < 1 ||
491 remote_rp->partid > (XP_MAX_PARTITIONS - 1)) { 491 remote_rp->partid > (XP_MAX_PARTITIONS - 1)) {
492 return xpcInvalidPartid; 492 return xpInvalidPartid;
493 } 493 }
494 494
495 if (remote_rp->partid == sn_partition_id) 495 if (remote_rp->partid == sn_partition_id)
496 return xpcLocalPartid; 496 return xpLocalPartid;
497 497
498 if (XPC_VERSION_MAJOR(remote_rp->version) != 498 if (XPC_VERSION_MAJOR(remote_rp->version) !=
499 XPC_VERSION_MAJOR(XPC_RP_VERSION)) { 499 XPC_VERSION_MAJOR(XPC_RP_VERSION)) {
500 return xpcBadVersion; 500 return xpBadVersion;
501 } 501 }
502 502
503 return xpcSuccess; 503 return xpSuccess;
504} 504}
505 505
506/* 506/*
@@ -509,13 +509,13 @@ xpc_get_remote_rp(int nasid, u64 *discovered_nasids,
509 * remote_vars points to a buffer that is cacheline aligned for BTE copies and 509 * remote_vars points to a buffer that is cacheline aligned for BTE copies and
510 * assumed to be of size XPC_RP_VARS_SIZE. 510 * assumed to be of size XPC_RP_VARS_SIZE.
511 */ 511 */
512static enum xpc_retval 512static enum xp_retval
513xpc_get_remote_vars(u64 remote_vars_pa, struct xpc_vars *remote_vars) 513xpc_get_remote_vars(u64 remote_vars_pa, struct xpc_vars *remote_vars)
514{ 514{
515 int bres; 515 int bres;
516 516
517 if (remote_vars_pa == 0) 517 if (remote_vars_pa == 0)
518 return xpcVarsNotSet; 518 return xpVarsNotSet;
519 519
520 /* pull over the cross partition variables */ 520 /* pull over the cross partition variables */
521 bres = xp_bte_copy(remote_vars_pa, (u64)remote_vars, XPC_RP_VARS_SIZE, 521 bres = xp_bte_copy(remote_vars_pa, (u64)remote_vars, XPC_RP_VARS_SIZE,
@@ -525,10 +525,10 @@ xpc_get_remote_vars(u64 remote_vars_pa, struct xpc_vars *remote_vars)
525 525
526 if (XPC_VERSION_MAJOR(remote_vars->version) != 526 if (XPC_VERSION_MAJOR(remote_vars->version) !=
527 XPC_VERSION_MAJOR(XPC_V_VERSION)) { 527 XPC_VERSION_MAJOR(XPC_V_VERSION)) {
528 return xpcBadVersion; 528 return xpBadVersion;
529 } 529 }
530 530
531 return xpcSuccess; 531 return xpSuccess;
532} 532}
533 533
534/* 534/*
@@ -604,16 +604,16 @@ xpc_identify_act_IRQ_req(int nasid)
604 int reactivate = 0; 604 int reactivate = 0;
605 int stamp_diff; 605 int stamp_diff;
606 struct timespec remote_rp_stamp = { 0, 0 }; 606 struct timespec remote_rp_stamp = { 0, 0 };
607 partid_t partid; 607 short partid;
608 struct xpc_partition *part; 608 struct xpc_partition *part;
609 enum xpc_retval ret; 609 enum xp_retval ret;
610 610
611 /* pull over the reserved page structure */ 611 /* pull over the reserved page structure */
612 612
613 remote_rp = (struct xpc_rsvd_page *)xpc_remote_copy_buffer; 613 remote_rp = (struct xpc_rsvd_page *)xpc_remote_copy_buffer;
614 614
615 ret = xpc_get_remote_rp(nasid, NULL, remote_rp, &remote_rp_pa); 615 ret = xpc_get_remote_rp(nasid, NULL, remote_rp, &remote_rp_pa);
616 if (ret != xpcSuccess) { 616 if (ret != xpSuccess) {
617 dev_warn(xpc_part, "unable to get reserved page from nasid %d, " 617 dev_warn(xpc_part, "unable to get reserved page from nasid %d, "
618 "which sent interrupt, reason=%d\n", nasid, ret); 618 "which sent interrupt, reason=%d\n", nasid, ret);
619 return; 619 return;
@@ -632,7 +632,7 @@ xpc_identify_act_IRQ_req(int nasid)
632 remote_vars = (struct xpc_vars *)xpc_remote_copy_buffer; 632 remote_vars = (struct xpc_vars *)xpc_remote_copy_buffer;
633 633
634 ret = xpc_get_remote_vars(remote_vars_pa, remote_vars); 634 ret = xpc_get_remote_vars(remote_vars_pa, remote_vars);
635 if (ret != xpcSuccess) { 635 if (ret != xpSuccess) {
636 636
637 dev_warn(xpc_part, "unable to get XPC variables from nasid %d, " 637 dev_warn(xpc_part, "unable to get XPC variables from nasid %d, "
638 "which sent interrupt, reason=%d\n", nasid, ret); 638 "which sent interrupt, reason=%d\n", nasid, ret);
@@ -699,7 +699,7 @@ xpc_identify_act_IRQ_req(int nasid)
699 &remote_rp_stamp, remote_rp_pa, 699 &remote_rp_stamp, remote_rp_pa,
700 remote_vars_pa, remote_vars); 700 remote_vars_pa, remote_vars);
701 part->reactivate_nasid = nasid; 701 part->reactivate_nasid = nasid;
702 XPC_DEACTIVATE_PARTITION(part, xpcReactivating); 702 XPC_DEACTIVATE_PARTITION(part, xpReactivating);
703 return; 703 return;
704 } 704 }
705 705
@@ -754,11 +754,11 @@ xpc_identify_act_IRQ_req(int nasid)
754 754
755 if (reactivate) { 755 if (reactivate) {
756 part->reactivate_nasid = nasid; 756 part->reactivate_nasid = nasid;
757 XPC_DEACTIVATE_PARTITION(part, xpcReactivating); 757 XPC_DEACTIVATE_PARTITION(part, xpReactivating);
758 758
759 } else if (XPC_SUPPORTS_DISENGAGE_REQUEST(part->remote_vars_version) && 759 } else if (XPC_SUPPORTS_DISENGAGE_REQUEST(part->remote_vars_version) &&
760 xpc_partition_disengage_requested(1UL << partid)) { 760 xpc_partition_disengage_requested(1UL << partid)) {
761 XPC_DEACTIVATE_PARTITION(part, xpcOtherGoingDown); 761 XPC_DEACTIVATE_PARTITION(part, xpOtherGoingDown);
762 } 762 }
763} 763}
764 764
@@ -825,7 +825,7 @@ xpc_identify_act_IRQ_sender(void)
825int 825int
826xpc_partition_disengaged(struct xpc_partition *part) 826xpc_partition_disengaged(struct xpc_partition *part)
827{ 827{
828 partid_t partid = XPC_PARTID(part); 828 short partid = XPC_PARTID(part);
829 int disengaged; 829 int disengaged;
830 830
831 disengaged = (xpc_partition_engaged(1UL << partid) == 0); 831 disengaged = (xpc_partition_engaged(1UL << partid) == 0);
@@ -870,20 +870,20 @@ xpc_partition_disengaged(struct xpc_partition *part)
870/* 870/*
871 * Mark specified partition as active. 871 * Mark specified partition as active.
872 */ 872 */
873enum xpc_retval 873enum xp_retval
874xpc_mark_partition_active(struct xpc_partition *part) 874xpc_mark_partition_active(struct xpc_partition *part)
875{ 875{
876 unsigned long irq_flags; 876 unsigned long irq_flags;
877 enum xpc_retval ret; 877 enum xp_retval ret;
878 878
879 dev_dbg(xpc_part, "setting partition %d to ACTIVE\n", XPC_PARTID(part)); 879 dev_dbg(xpc_part, "setting partition %d to ACTIVE\n", XPC_PARTID(part));
880 880
881 spin_lock_irqsave(&part->act_lock, irq_flags); 881 spin_lock_irqsave(&part->act_lock, irq_flags);
882 if (part->act_state == XPC_P_ACTIVATING) { 882 if (part->act_state == XPC_P_ACTIVATING) {
883 part->act_state = XPC_P_ACTIVE; 883 part->act_state = XPC_P_ACTIVE;
884 ret = xpcSuccess; 884 ret = xpSuccess;
885 } else { 885 } else {
886 DBUG_ON(part->reason == xpcSuccess); 886 DBUG_ON(part->reason == xpSuccess);
887 ret = part->reason; 887 ret = part->reason;
888 } 888 }
889 spin_unlock_irqrestore(&part->act_lock, irq_flags); 889 spin_unlock_irqrestore(&part->act_lock, irq_flags);
@@ -896,7 +896,7 @@ xpc_mark_partition_active(struct xpc_partition *part)
896 */ 896 */
897void 897void
898xpc_deactivate_partition(const int line, struct xpc_partition *part, 898xpc_deactivate_partition(const int line, struct xpc_partition *part,
899 enum xpc_retval reason) 899 enum xp_retval reason)
900{ 900{
901 unsigned long irq_flags; 901 unsigned long irq_flags;
902 902
@@ -905,15 +905,15 @@ xpc_deactivate_partition(const int line, struct xpc_partition *part,
905 if (part->act_state == XPC_P_INACTIVE) { 905 if (part->act_state == XPC_P_INACTIVE) {
906 XPC_SET_REASON(part, reason, line); 906 XPC_SET_REASON(part, reason, line);
907 spin_unlock_irqrestore(&part->act_lock, irq_flags); 907 spin_unlock_irqrestore(&part->act_lock, irq_flags);
908 if (reason == xpcReactivating) { 908 if (reason == xpReactivating) {
909 /* we interrupt ourselves to reactivate partition */ 909 /* we interrupt ourselves to reactivate partition */
910 xpc_IPI_send_reactivate(part); 910 xpc_IPI_send_reactivate(part);
911 } 911 }
912 return; 912 return;
913 } 913 }
914 if (part->act_state == XPC_P_DEACTIVATING) { 914 if (part->act_state == XPC_P_DEACTIVATING) {
915 if ((part->reason == xpcUnloading && reason != xpcUnloading) || 915 if ((part->reason == xpUnloading && reason != xpUnloading) ||
916 reason == xpcReactivating) { 916 reason == xpReactivating) {
917 XPC_SET_REASON(part, reason, line); 917 XPC_SET_REASON(part, reason, line);
918 } 918 }
919 spin_unlock_irqrestore(&part->act_lock, irq_flags); 919 spin_unlock_irqrestore(&part->act_lock, irq_flags);
@@ -982,10 +982,10 @@ xpc_discovery(void)
982 int max_regions; 982 int max_regions;
983 int nasid; 983 int nasid;
984 struct xpc_rsvd_page *rp; 984 struct xpc_rsvd_page *rp;
985 partid_t partid; 985 short partid;
986 struct xpc_partition *part; 986 struct xpc_partition *part;
987 u64 *discovered_nasids; 987 u64 *discovered_nasids;
988 enum xpc_retval ret; 988 enum xp_retval ret;
989 989
990 remote_rp = xpc_kmalloc_cacheline_aligned(XPC_RP_HEADER_SIZE + 990 remote_rp = xpc_kmalloc_cacheline_aligned(XPC_RP_HEADER_SIZE +
991 xp_nasid_mask_bytes, 991 xp_nasid_mask_bytes,
@@ -1063,12 +1063,12 @@ xpc_discovery(void)
1063 1063
1064 ret = xpc_get_remote_rp(nasid, discovered_nasids, 1064 ret = xpc_get_remote_rp(nasid, discovered_nasids,
1065 remote_rp, &remote_rp_pa); 1065 remote_rp, &remote_rp_pa);
1066 if (ret != xpcSuccess) { 1066 if (ret != xpSuccess) {
1067 dev_dbg(xpc_part, "unable to get reserved page " 1067 dev_dbg(xpc_part, "unable to get reserved page "
1068 "from nasid %d, reason=%d\n", nasid, 1068 "from nasid %d, reason=%d\n", nasid,
1069 ret); 1069 ret);
1070 1070
1071 if (ret == xpcLocalPartid) 1071 if (ret == xpLocalPartid)
1072 break; 1072 break;
1073 1073
1074 continue; 1074 continue;
@@ -1082,7 +1082,7 @@ xpc_discovery(void)
1082 /* pull over the cross partition variables */ 1082 /* pull over the cross partition variables */
1083 1083
1084 ret = xpc_get_remote_vars(remote_vars_pa, remote_vars); 1084 ret = xpc_get_remote_vars(remote_vars_pa, remote_vars);
1085 if (ret != xpcSuccess) { 1085 if (ret != xpSuccess) {
1086 dev_dbg(xpc_part, "unable to get XPC variables " 1086 dev_dbg(xpc_part, "unable to get XPC variables "
1087 "from nasid %d, reason=%d\n", nasid, 1087 "from nasid %d, reason=%d\n", nasid,
1088 ret); 1088 ret);
@@ -1116,7 +1116,7 @@ xpc_discovery(void)
1116 "register xp_addr region 0x%016lx\n", 1116 "register xp_addr region 0x%016lx\n",
1117 partid, remote_vars->amos_page_pa); 1117 partid, remote_vars->amos_page_pa);
1118 1118
1119 XPC_SET_REASON(part, xpcPhysAddrRegFailed, 1119 XPC_SET_REASON(part, xpPhysAddrRegFailed,
1120 __LINE__); 1120 __LINE__);
1121 break; 1121 break;
1122 } 1122 }
@@ -1151,8 +1151,8 @@ xpc_discovery(void)
1151 * Given a partid, get the nasids owned by that partition from the 1151 * Given a partid, get the nasids owned by that partition from the
1152 * remote partition's reserved page. 1152 * remote partition's reserved page.
1153 */ 1153 */
1154enum xpc_retval 1154enum xp_retval
1155xpc_initiate_partid_to_nasids(partid_t partid, void *nasid_mask) 1155xpc_initiate_partid_to_nasids(short partid, void *nasid_mask)
1156{ 1156{
1157 struct xpc_partition *part; 1157 struct xpc_partition *part;
1158 u64 part_nasid_pa; 1158 u64 part_nasid_pa;
@@ -1160,7 +1160,7 @@ xpc_initiate_partid_to_nasids(partid_t partid, void *nasid_mask)
1160 1160
1161 part = &xpc_partitions[partid]; 1161 part = &xpc_partitions[partid];
1162 if (part->remote_rp_pa == 0) 1162 if (part->remote_rp_pa == 0)
1163 return xpcPartitionDown; 1163 return xpPartitionDown;
1164 1164
1165 memset(nasid_mask, 0, XP_NASID_MASK_BYTES); 1165 memset(nasid_mask, 0, XP_NASID_MASK_BYTES);
1166 1166
diff --git a/drivers/misc/sgi-xp/xpnet.c b/drivers/misc/sgi-xp/xpnet.c
index a9543c65814d..822dc8e8d7f0 100644
--- a/drivers/misc/sgi-xp/xpnet.c
+++ b/drivers/misc/sgi-xp/xpnet.c
@@ -166,7 +166,7 @@ struct device *xpnet = &xpnet_dbg_subname;
166 * Packet was recevied by XPC and forwarded to us. 166 * Packet was recevied by XPC and forwarded to us.
167 */ 167 */
168static void 168static void
169xpnet_receive(partid_t partid, int channel, struct xpnet_message *msg) 169xpnet_receive(short partid, int channel, struct xpnet_message *msg)
170{ 170{
171 struct sk_buff *skb; 171 struct sk_buff *skb;
172 bte_result_t bret; 172 bte_result_t bret;
@@ -282,7 +282,7 @@ xpnet_receive(partid_t partid, int channel, struct xpnet_message *msg)
282 * state or message reception on a connection. 282 * state or message reception on a connection.
283 */ 283 */
284static void 284static void
285xpnet_connection_activity(enum xpc_retval reason, partid_t partid, int channel, 285xpnet_connection_activity(enum xp_retval reason, short partid, int channel,
286 void *data, void *key) 286 void *data, void *key)
287{ 287{
288 long bp; 288 long bp;
@@ -291,13 +291,13 @@ xpnet_connection_activity(enum xpc_retval reason, partid_t partid, int channel,
291 DBUG_ON(channel != XPC_NET_CHANNEL); 291 DBUG_ON(channel != XPC_NET_CHANNEL);
292 292
293 switch (reason) { 293 switch (reason) {
294 case xpcMsgReceived: /* message received */ 294 case xpMsgReceived: /* message received */
295 DBUG_ON(data == NULL); 295 DBUG_ON(data == NULL);
296 296
297 xpnet_receive(partid, channel, (struct xpnet_message *)data); 297 xpnet_receive(partid, channel, (struct xpnet_message *)data);
298 break; 298 break;
299 299
300 case xpcConnected: /* connection completed to a partition */ 300 case xpConnected: /* connection completed to a partition */
301 spin_lock_bh(&xpnet_broadcast_lock); 301 spin_lock_bh(&xpnet_broadcast_lock);
302 xpnet_broadcast_partitions |= 1UL << (partid - 1); 302 xpnet_broadcast_partitions |= 1UL << (partid - 1);
303 bp = xpnet_broadcast_partitions; 303 bp = xpnet_broadcast_partitions;
@@ -330,7 +330,7 @@ xpnet_connection_activity(enum xpc_retval reason, partid_t partid, int channel,
330static int 330static int
331xpnet_dev_open(struct net_device *dev) 331xpnet_dev_open(struct net_device *dev)
332{ 332{
333 enum xpc_retval ret; 333 enum xp_retval ret;
334 334
335 dev_dbg(xpnet, "calling xpc_connect(%d, 0x%p, NULL, %ld, %ld, %ld, " 335 dev_dbg(xpnet, "calling xpc_connect(%d, 0x%p, NULL, %ld, %ld, %ld, "
336 "%ld)\n", XPC_NET_CHANNEL, xpnet_connection_activity, 336 "%ld)\n", XPC_NET_CHANNEL, xpnet_connection_activity,
@@ -340,7 +340,7 @@ xpnet_dev_open(struct net_device *dev)
340 ret = xpc_connect(XPC_NET_CHANNEL, xpnet_connection_activity, NULL, 340 ret = xpc_connect(XPC_NET_CHANNEL, xpnet_connection_activity, NULL,
341 XPNET_MSG_SIZE, XPNET_MSG_NENTRIES, 341 XPNET_MSG_SIZE, XPNET_MSG_NENTRIES,
342 XPNET_MAX_KTHREADS, XPNET_MAX_IDLE_KTHREADS); 342 XPNET_MAX_KTHREADS, XPNET_MAX_IDLE_KTHREADS);
343 if (ret != xpcSuccess) { 343 if (ret != xpSuccess) {
344 dev_err(xpnet, "ifconfig up of %s failed on XPC connect, " 344 dev_err(xpnet, "ifconfig up of %s failed on XPC connect, "
345 "ret=%d\n", dev->name, ret); 345 "ret=%d\n", dev->name, ret);
346 346
@@ -407,7 +407,7 @@ xpnet_dev_get_stats(struct net_device *dev)
407 * release the skb and then release our pending message structure. 407 * release the skb and then release our pending message structure.
408 */ 408 */
409static void 409static void
410xpnet_send_completed(enum xpc_retval reason, partid_t partid, int channel, 410xpnet_send_completed(enum xp_retval reason, short partid, int channel,
411 void *__qm) 411 void *__qm)
412{ 412{
413 struct xpnet_pending_msg *queued_msg = (struct xpnet_pending_msg *)__qm; 413 struct xpnet_pending_msg *queued_msg = (struct xpnet_pending_msg *)__qm;
@@ -439,12 +439,12 @@ static int
439xpnet_dev_hard_start_xmit(struct sk_buff *skb, struct net_device *dev) 439xpnet_dev_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
440{ 440{
441 struct xpnet_pending_msg *queued_msg; 441 struct xpnet_pending_msg *queued_msg;
442 enum xpc_retval ret; 442 enum xp_retval ret;
443 struct xpnet_message *msg; 443 struct xpnet_message *msg;
444 u64 start_addr, end_addr; 444 u64 start_addr, end_addr;
445 long dp; 445 long dp;
446 u8 second_mac_octet; 446 u8 second_mac_octet;
447 partid_t dest_partid; 447 short dest_partid;
448 struct xpnet_dev_private *priv; 448 struct xpnet_dev_private *priv;
449 u16 embedded_bytes; 449 u16 embedded_bytes;
450 450
@@ -528,7 +528,7 @@ xpnet_dev_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
528 528
529 ret = xpc_allocate(dest_partid, XPC_NET_CHANNEL, 529 ret = xpc_allocate(dest_partid, XPC_NET_CHANNEL,
530 XPC_NOWAIT, (void **)&msg); 530 XPC_NOWAIT, (void **)&msg);
531 if (unlikely(ret != xpcSuccess)) 531 if (unlikely(ret != xpSuccess))
532 continue; 532 continue;
533 533
534 msg->embedded_bytes = embedded_bytes; 534 msg->embedded_bytes = embedded_bytes;
@@ -557,7 +557,7 @@ xpnet_dev_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
557 557
558 ret = xpc_send_notify(dest_partid, XPC_NET_CHANNEL, msg, 558 ret = xpc_send_notify(dest_partid, XPC_NET_CHANNEL, msg,
559 xpnet_send_completed, queued_msg); 559 xpnet_send_completed, queued_msg);
560 if (unlikely(ret != xpcSuccess)) { 560 if (unlikely(ret != xpSuccess)) {
561 atomic_dec(&queued_msg->use_count); 561 atomic_dec(&queued_msg->use_count);
562 continue; 562 continue;
563 } 563 }
diff --git a/drivers/mmc/host/sdhci.h b/drivers/mmc/host/sdhci.h
index 7fb02e177a3d..299118de8933 100644
--- a/drivers/mmc/host/sdhci.h
+++ b/drivers/mmc/host/sdhci.h
@@ -187,7 +187,7 @@ struct sdhci_host {
187 struct mmc_request *mrq; /* Current request */ 187 struct mmc_request *mrq; /* Current request */
188 struct mmc_command *cmd; /* Current command */ 188 struct mmc_command *cmd; /* Current command */
189 struct mmc_data *data; /* Current data request */ 189 struct mmc_data *data; /* Current data request */
190 int data_early:1; /* Data finished before cmd */ 190 unsigned int data_early:1; /* Data finished before cmd */
191 191
192 struct scatterlist *cur_sg; /* We're working on this */ 192 struct scatterlist *cur_sg; /* We're working on this */
193 int num_sg; /* Entries left */ 193 int num_sg; /* Entries left */
diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig
index 009e8fdcfe5c..02d5165b147c 100644
--- a/drivers/net/Kconfig
+++ b/drivers/net/Kconfig
@@ -2425,7 +2425,7 @@ config CHELSIO_T3
2425 2425
2426config EHEA 2426config EHEA
2427 tristate "eHEA Ethernet support" 2427 tristate "eHEA Ethernet support"
2428 depends on IBMEBUS && INET && SPARSEMEM 2428 depends on IBMEBUS && INET && SPARSEMEM && MEMORY_HOTPLUG
2429 select INET_LRO 2429 select INET_LRO
2430 ---help--- 2430 ---help---
2431 This driver supports the IBM pSeries eHEA ethernet adapter. 2431 This driver supports the IBM pSeries eHEA ethernet adapter.
diff --git a/drivers/net/atlx/atl1.c b/drivers/net/atlx/atl1.c
index 0afe522b8f7b..9c2394d49428 100644
--- a/drivers/net/atlx/atl1.c
+++ b/drivers/net/atlx/atl1.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * Copyright(c) 2005 - 2006 Attansic Corporation. All rights reserved. 2 * Copyright(c) 2005 - 2006 Attansic Corporation. All rights reserved.
3 * Copyright(c) 2006 - 2007 Chris Snook <csnook@redhat.com> 3 * Copyright(c) 2006 - 2007 Chris Snook <csnook@redhat.com>
4 * Copyright(c) 2006 Jay Cliburn <jcliburn@gmail.com> 4 * Copyright(c) 2006 - 2008 Jay Cliburn <jcliburn@gmail.com>
5 * 5 *
6 * Derived from Intel e1000 driver 6 * Derived from Intel e1000 driver
7 * Copyright(c) 1999 - 2005 Intel Corporation. All rights reserved. 7 * Copyright(c) 1999 - 2005 Intel Corporation. All rights reserved.
@@ -36,7 +36,6 @@
36 * A very incomplete list of things that need to be dealt with: 36 * A very incomplete list of things that need to be dealt with:
37 * 37 *
38 * TODO: 38 * TODO:
39 * Wake on LAN.
40 * Add more ethtool functions. 39 * Add more ethtool functions.
41 * Fix abstruse irq enable/disable condition described here: 40 * Fix abstruse irq enable/disable condition described here:
42 * http://marc.theaimsgroup.com/?l=linux-netdev&m=116398508500553&w=2 41 * http://marc.theaimsgroup.com/?l=linux-netdev&m=116398508500553&w=2
@@ -638,21 +637,18 @@ static s32 atl1_phy_leave_power_saving(struct atl1_hw *hw)
638} 637}
639 638
640/* 639/*
641 *TODO: do something or get rid of this 640 * Force the PHY into power saving mode using vendor magic.
642 */ 641 */
643#ifdef CONFIG_PM 642#ifdef CONFIG_PM
644static s32 atl1_phy_enter_power_saving(struct atl1_hw *hw) 643static void atl1_phy_enter_power_saving(struct atl1_hw *hw)
645{ 644{
646/* s32 ret_val; 645 atl1_write_phy_reg(hw, MII_DBG_ADDR, 0);
647 * u16 phy_data; 646 atl1_write_phy_reg(hw, MII_DBG_DATA, 0x124E);
648 */ 647 atl1_write_phy_reg(hw, MII_DBG_ADDR, 2);
648 atl1_write_phy_reg(hw, MII_DBG_DATA, 0x3000);
649 atl1_write_phy_reg(hw, MII_DBG_ADDR, 3);
650 atl1_write_phy_reg(hw, MII_DBG_DATA, 0);
649 651
650/*
651 ret_val = atl1_write_phy_reg(hw, ...);
652 ret_val = atl1_write_phy_reg(hw, ...);
653 ....
654*/
655 return 0;
656} 652}
657#endif 653#endif
658 654
@@ -2784,64 +2780,93 @@ static int atl1_suspend(struct pci_dev *pdev, pm_message_t state)
2784 struct atl1_hw *hw = &adapter->hw; 2780 struct atl1_hw *hw = &adapter->hw;
2785 u32 ctrl = 0; 2781 u32 ctrl = 0;
2786 u32 wufc = adapter->wol; 2782 u32 wufc = adapter->wol;
2783 u32 val;
2784 int retval;
2785 u16 speed;
2786 u16 duplex;
2787 2787
2788 netif_device_detach(netdev); 2788 netif_device_detach(netdev);
2789 if (netif_running(netdev)) 2789 if (netif_running(netdev))
2790 atl1_down(adapter); 2790 atl1_down(adapter);
2791 2791
2792 retval = pci_save_state(pdev);
2793 if (retval)
2794 return retval;
2795
2792 atl1_read_phy_reg(hw, MII_BMSR, (u16 *) & ctrl); 2796 atl1_read_phy_reg(hw, MII_BMSR, (u16 *) & ctrl);
2793 atl1_read_phy_reg(hw, MII_BMSR, (u16 *) & ctrl); 2797 atl1_read_phy_reg(hw, MII_BMSR, (u16 *) & ctrl);
2794 if (ctrl & BMSR_LSTATUS) 2798 val = ctrl & BMSR_LSTATUS;
2799 if (val)
2795 wufc &= ~ATLX_WUFC_LNKC; 2800 wufc &= ~ATLX_WUFC_LNKC;
2796 2801
2797 /* reduce speed to 10/100M */ 2802 if (val && wufc) {
2798 if (wufc) { 2803 val = atl1_get_speed_and_duplex(hw, &speed, &duplex);
2799 atl1_phy_enter_power_saving(hw); 2804 if (val) {
2800 /* if resume, let driver to re- setup link */ 2805 if (netif_msg_ifdown(adapter))
2801 hw->phy_configured = false; 2806 dev_printk(KERN_DEBUG, &pdev->dev,
2802 atl1_set_mac_addr(hw); 2807 "error getting speed/duplex\n");
2803 atlx_set_multi(netdev); 2808 goto disable_wol;
2809 }
2804 2810
2805 ctrl = 0; 2811 ctrl = 0;
2806 /* turn on magic packet wol */
2807 if (wufc & ATLX_WUFC_MAG)
2808 ctrl = WOL_MAGIC_EN | WOL_MAGIC_PME_EN;
2809 2812
2810 /* turn on Link change WOL */ 2813 /* enable magic packet WOL */
2811 if (wufc & ATLX_WUFC_LNKC) 2814 if (wufc & ATLX_WUFC_MAG)
2812 ctrl |= (WOL_LINK_CHG_EN | WOL_LINK_CHG_PME_EN); 2815 ctrl |= (WOL_MAGIC_EN | WOL_MAGIC_PME_EN);
2813 iowrite32(ctrl, hw->hw_addr + REG_WOL_CTRL); 2816 iowrite32(ctrl, hw->hw_addr + REG_WOL_CTRL);
2814 2817 ioread32(hw->hw_addr + REG_WOL_CTRL);
2815 /* turn on all-multi mode if wake on multicast is enabled */ 2818
2816 ctrl = ioread32(hw->hw_addr + REG_MAC_CTRL); 2819 /* configure the mac */
2817 ctrl &= ~MAC_CTRL_DBG; 2820 ctrl = MAC_CTRL_RX_EN;
2818 ctrl &= ~MAC_CTRL_PROMIS_EN; 2821 ctrl |= ((u32)((speed == SPEED_1000) ? MAC_CTRL_SPEED_1000 :
2819 if (wufc & ATLX_WUFC_MC) 2822 MAC_CTRL_SPEED_10_100) << MAC_CTRL_SPEED_SHIFT);
2820 ctrl |= MAC_CTRL_MC_ALL_EN; 2823 if (duplex == FULL_DUPLEX)
2821 else 2824 ctrl |= MAC_CTRL_DUPLX;
2822 ctrl &= ~MAC_CTRL_MC_ALL_EN; 2825 ctrl |= (((u32)adapter->hw.preamble_len &
2823 2826 MAC_CTRL_PRMLEN_MASK) << MAC_CTRL_PRMLEN_SHIFT);
2824 /* turn on broadcast mode if wake on-BC is enabled */ 2827 if (adapter->vlgrp)
2825 if (wufc & ATLX_WUFC_BC) 2828 ctrl |= MAC_CTRL_RMV_VLAN;
2829 if (wufc & ATLX_WUFC_MAG)
2826 ctrl |= MAC_CTRL_BC_EN; 2830 ctrl |= MAC_CTRL_BC_EN;
2827 else
2828 ctrl &= ~MAC_CTRL_BC_EN;
2829
2830 /* enable RX */
2831 ctrl |= MAC_CTRL_RX_EN;
2832 iowrite32(ctrl, hw->hw_addr + REG_MAC_CTRL); 2831 iowrite32(ctrl, hw->hw_addr + REG_MAC_CTRL);
2833 pci_enable_wake(pdev, PCI_D3hot, 1); 2832 ioread32(hw->hw_addr + REG_MAC_CTRL);
2834 pci_enable_wake(pdev, PCI_D3cold, 1); 2833
2835 } else { 2834 /* poke the PHY */
2836 iowrite32(0, hw->hw_addr + REG_WOL_CTRL); 2835 ctrl = ioread32(hw->hw_addr + REG_PCIE_PHYMISC);
2837 pci_enable_wake(pdev, PCI_D3hot, 0); 2836 ctrl |= PCIE_PHYMISC_FORCE_RCV_DET;
2838 pci_enable_wake(pdev, PCI_D3cold, 0); 2837 iowrite32(ctrl, hw->hw_addr + REG_PCIE_PHYMISC);
2838 ioread32(hw->hw_addr + REG_PCIE_PHYMISC);
2839
2840 pci_enable_wake(pdev, pci_choose_state(pdev, state), 1);
2841 goto exit;
2839 } 2842 }
2840 2843
2841 pci_save_state(pdev); 2844 if (!val && wufc) {
2845 ctrl |= (WOL_LINK_CHG_EN | WOL_LINK_CHG_PME_EN);
2846 iowrite32(ctrl, hw->hw_addr + REG_WOL_CTRL);
2847 ioread32(hw->hw_addr + REG_WOL_CTRL);
2848 iowrite32(0, hw->hw_addr + REG_MAC_CTRL);
2849 ioread32(hw->hw_addr + REG_MAC_CTRL);
2850 hw->phy_configured = false;
2851 pci_enable_wake(pdev, pci_choose_state(pdev, state), 1);
2852 goto exit;
2853 }
2854
2855disable_wol:
2856 iowrite32(0, hw->hw_addr + REG_WOL_CTRL);
2857 ioread32(hw->hw_addr + REG_WOL_CTRL);
2858 ctrl = ioread32(hw->hw_addr + REG_PCIE_PHYMISC);
2859 ctrl |= PCIE_PHYMISC_FORCE_RCV_DET;
2860 iowrite32(ctrl, hw->hw_addr + REG_PCIE_PHYMISC);
2861 ioread32(hw->hw_addr + REG_PCIE_PHYMISC);
2862 atl1_phy_enter_power_saving(hw);
2863 hw->phy_configured = false;
2864 pci_enable_wake(pdev, pci_choose_state(pdev, state), 0);
2865exit:
2866 if (netif_running(netdev))
2867 pci_disable_msi(adapter->pdev);
2842 pci_disable_device(pdev); 2868 pci_disable_device(pdev);
2843 2869 pci_set_power_state(pdev, pci_choose_state(pdev, state));
2844 pci_set_power_state(pdev, PCI_D3hot);
2845 2870
2846 return 0; 2871 return 0;
2847} 2872}
@@ -2855,20 +2880,26 @@ static int atl1_resume(struct pci_dev *pdev)
2855 pci_set_power_state(pdev, PCI_D0); 2880 pci_set_power_state(pdev, PCI_D0);
2856 pci_restore_state(pdev); 2881 pci_restore_state(pdev);
2857 2882
2858 /* FIXME: check and handle */
2859 err = pci_enable_device(pdev); 2883 err = pci_enable_device(pdev);
2884 if (err) {
2885 if (netif_msg_ifup(adapter))
2886 dev_printk(KERN_DEBUG, &pdev->dev,
2887 "error enabling pci device\n");
2888 return err;
2889 }
2890
2891 pci_set_master(pdev);
2892 iowrite32(0, adapter->hw.hw_addr + REG_WOL_CTRL);
2860 pci_enable_wake(pdev, PCI_D3hot, 0); 2893 pci_enable_wake(pdev, PCI_D3hot, 0);
2861 pci_enable_wake(pdev, PCI_D3cold, 0); 2894 pci_enable_wake(pdev, PCI_D3cold, 0);
2862 2895
2863 iowrite32(0, adapter->hw.hw_addr + REG_WOL_CTRL); 2896 atl1_reset_hw(&adapter->hw);
2864 atl1_reset(adapter); 2897 adapter->cmb.cmb->int_stats = 0;
2865 2898
2866 if (netif_running(netdev)) 2899 if (netif_running(netdev))
2867 atl1_up(adapter); 2900 atl1_up(adapter);
2868 netif_device_attach(netdev); 2901 netif_device_attach(netdev);
2869 2902
2870 atl1_via_workaround(adapter);
2871
2872 return 0; 2903 return 0;
2873} 2904}
2874#else 2905#else
@@ -2876,6 +2907,13 @@ static int atl1_resume(struct pci_dev *pdev)
2876#define atl1_resume NULL 2907#define atl1_resume NULL
2877#endif 2908#endif
2878 2909
2910static void atl1_shutdown(struct pci_dev *pdev)
2911{
2912#ifdef CONFIG_PM
2913 atl1_suspend(pdev, PMSG_SUSPEND);
2914#endif
2915}
2916
2879#ifdef CONFIG_NET_POLL_CONTROLLER 2917#ifdef CONFIG_NET_POLL_CONTROLLER
2880static void atl1_poll_controller(struct net_device *netdev) 2918static void atl1_poll_controller(struct net_device *netdev)
2881{ 2919{
@@ -3122,7 +3160,8 @@ static struct pci_driver atl1_driver = {
3122 .probe = atl1_probe, 3160 .probe = atl1_probe,
3123 .remove = __devexit_p(atl1_remove), 3161 .remove = __devexit_p(atl1_remove),
3124 .suspend = atl1_suspend, 3162 .suspend = atl1_suspend,
3125 .resume = atl1_resume 3163 .resume = atl1_resume,
3164 .shutdown = atl1_shutdown
3126}; 3165};
3127 3166
3128/* 3167/*
diff --git a/drivers/net/atlx/atl1.h b/drivers/net/atlx/atl1.h
index 51893d66eae1..a5015b14a429 100644
--- a/drivers/net/atlx/atl1.h
+++ b/drivers/net/atlx/atl1.h
@@ -1,7 +1,7 @@
1/* 1/*
2 * Copyright(c) 2005 - 2006 Attansic Corporation. All rights reserved. 2 * Copyright(c) 2005 - 2006 Attansic Corporation. All rights reserved.
3 * Copyright(c) 2006 - 2007 Chris Snook <csnook@redhat.com> 3 * Copyright(c) 2006 - 2007 Chris Snook <csnook@redhat.com>
4 * Copyright(c) 2006 Jay Cliburn <jcliburn@gmail.com> 4 * Copyright(c) 2006 - 2008 Jay Cliburn <jcliburn@gmail.com>
5 * 5 *
6 * Derived from Intel e1000 driver 6 * Derived from Intel e1000 driver
7 * Copyright(c) 1999 - 2005 Intel Corporation. All rights reserved. 7 * Copyright(c) 1999 - 2005 Intel Corporation. All rights reserved.
diff --git a/drivers/net/atlx/atlx.c b/drivers/net/atlx/atlx.c
index f06b854e2501..b3e7fcf0f6e7 100644
--- a/drivers/net/atlx/atlx.c
+++ b/drivers/net/atlx/atlx.c
@@ -2,7 +2,7 @@
2 * 2 *
3 * Copyright(c) 2005 - 2006 Attansic Corporation. All rights reserved. 3 * Copyright(c) 2005 - 2006 Attansic Corporation. All rights reserved.
4 * Copyright(c) 2006 - 2007 Chris Snook <csnook@redhat.com> 4 * Copyright(c) 2006 - 2007 Chris Snook <csnook@redhat.com>
5 * Copyright(c) 2006 Jay Cliburn <jcliburn@gmail.com> 5 * Copyright(c) 2006 - 2008 Jay Cliburn <jcliburn@gmail.com>
6 * Copyright(c) 2007 Atheros Corporation. All rights reserved. 6 * Copyright(c) 2007 Atheros Corporation. All rights reserved.
7 * 7 *
8 * Derived from Intel e1000 driver 8 * Derived from Intel e1000 driver
diff --git a/drivers/net/atlx/atlx.h b/drivers/net/atlx/atlx.h
index 3be7c09734d4..297a03da6b7f 100644
--- a/drivers/net/atlx/atlx.h
+++ b/drivers/net/atlx/atlx.h
@@ -2,7 +2,7 @@
2 * 2 *
3 * Copyright(c) 2005 - 2006 Attansic Corporation. All rights reserved. 3 * Copyright(c) 2005 - 2006 Attansic Corporation. All rights reserved.
4 * Copyright(c) 2006 - 2007 Chris Snook <csnook@redhat.com> 4 * Copyright(c) 2006 - 2007 Chris Snook <csnook@redhat.com>
5 * Copyright(c) 2006 Jay Cliburn <jcliburn@gmail.com> 5 * Copyright(c) 2006 - 2008 Jay Cliburn <jcliburn@gmail.com>
6 * Copyright(c) 2007 Atheros Corporation. All rights reserved. 6 * Copyright(c) 2007 Atheros Corporation. All rights reserved.
7 * 7 *
8 * Derived from Intel e1000 driver 8 * Derived from Intel e1000 driver
@@ -29,7 +29,7 @@
29#include <linux/module.h> 29#include <linux/module.h>
30#include <linux/types.h> 30#include <linux/types.h>
31 31
32#define ATLX_DRIVER_VERSION "2.1.1" 32#define ATLX_DRIVER_VERSION "2.1.3"
33MODULE_AUTHOR("Xiong Huang <xiong.huang@atheros.com>, \ 33MODULE_AUTHOR("Xiong Huang <xiong.huang@atheros.com>, \
34 Chris Snook <csnook@redhat.com>, Jay Cliburn <jcliburn@gmail.com>"); 34 Chris Snook <csnook@redhat.com>, Jay Cliburn <jcliburn@gmail.com>");
35MODULE_LICENSE("GPL"); 35MODULE_LICENSE("GPL");
@@ -460,6 +460,9 @@ MODULE_VERSION(ATLX_DRIVER_VERSION);
460#define MII_ATLX_PSSR_100MBS 0x4000 /* 01=100Mbs */ 460#define MII_ATLX_PSSR_100MBS 0x4000 /* 01=100Mbs */
461#define MII_ATLX_PSSR_1000MBS 0x8000 /* 10=1000Mbs */ 461#define MII_ATLX_PSSR_1000MBS 0x8000 /* 10=1000Mbs */
462 462
463#define MII_DBG_ADDR 0x1D
464#define MII_DBG_DATA 0x1E
465
463/* PCI Command Register Bit Definitions */ 466/* PCI Command Register Bit Definitions */
464#define PCI_REG_COMMAND 0x04 /* PCI Command Register */ 467#define PCI_REG_COMMAND 0x04 /* PCI Command Register */
465#define CMD_IO_SPACE 0x0001 468#define CMD_IO_SPACE 0x0001
diff --git a/drivers/net/cxgb3/adapter.h b/drivers/net/cxgb3/adapter.h
index 4fdb13f8447b..acebe431d068 100644
--- a/drivers/net/cxgb3/adapter.h
+++ b/drivers/net/cxgb3/adapter.h
@@ -71,6 +71,7 @@ enum { /* adapter flags */
71 USING_MSIX = (1 << 2), 71 USING_MSIX = (1 << 2),
72 QUEUES_BOUND = (1 << 3), 72 QUEUES_BOUND = (1 << 3),
73 TP_PARITY_INIT = (1 << 4), 73 TP_PARITY_INIT = (1 << 4),
74 NAPI_INIT = (1 << 5),
74}; 75};
75 76
76struct fl_pg_chunk { 77struct fl_pg_chunk {
diff --git a/drivers/net/cxgb3/common.h b/drivers/net/cxgb3/common.h
index 91ee7277b813..579bee42a5cb 100644
--- a/drivers/net/cxgb3/common.h
+++ b/drivers/net/cxgb3/common.h
@@ -698,6 +698,7 @@ void mac_prep(struct cmac *mac, struct adapter *adapter, int index);
698void early_hw_init(struct adapter *adapter, const struct adapter_info *ai); 698void early_hw_init(struct adapter *adapter, const struct adapter_info *ai);
699int t3_prep_adapter(struct adapter *adapter, const struct adapter_info *ai, 699int t3_prep_adapter(struct adapter *adapter, const struct adapter_info *ai,
700 int reset); 700 int reset);
701int t3_replay_prep_adapter(struct adapter *adapter);
701void t3_led_ready(struct adapter *adapter); 702void t3_led_ready(struct adapter *adapter);
702void t3_fatal_err(struct adapter *adapter); 703void t3_fatal_err(struct adapter *adapter);
703void t3_set_vlan_accel(struct adapter *adapter, unsigned int ports, int on); 704void t3_set_vlan_accel(struct adapter *adapter, unsigned int ports, int on);
diff --git a/drivers/net/cxgb3/cxgb3_main.c b/drivers/net/cxgb3/cxgb3_main.c
index ce949d5fae39..3a3127216791 100644
--- a/drivers/net/cxgb3/cxgb3_main.c
+++ b/drivers/net/cxgb3/cxgb3_main.c
@@ -421,6 +421,13 @@ static void init_napi(struct adapter *adap)
421 netif_napi_add(qs->netdev, &qs->napi, qs->napi.poll, 421 netif_napi_add(qs->netdev, &qs->napi, qs->napi.poll,
422 64); 422 64);
423 } 423 }
424
425 /*
426 * netif_napi_add() can be called only once per napi_struct because it
427 * adds each new napi_struct to a list. Be careful not to call it a
428 * second time, e.g., during EEH recovery, by making a note of it.
429 */
430 adap->flags |= NAPI_INIT;
424} 431}
425 432
426/* 433/*
@@ -896,7 +903,8 @@ static int cxgb_up(struct adapter *adap)
896 goto out; 903 goto out;
897 904
898 setup_rss(adap); 905 setup_rss(adap);
899 init_napi(adap); 906 if (!(adap->flags & NAPI_INIT))
907 init_napi(adap);
900 adap->flags |= FULL_INIT_DONE; 908 adap->flags |= FULL_INIT_DONE;
901 } 909 }
902 910
@@ -999,7 +1007,7 @@ static int offload_open(struct net_device *dev)
999 return 0; 1007 return 0;
1000 1008
1001 if (!adap_up && (err = cxgb_up(adapter)) < 0) 1009 if (!adap_up && (err = cxgb_up(adapter)) < 0)
1002 return err; 1010 goto out;
1003 1011
1004 t3_tp_set_offload_mode(adapter, 1); 1012 t3_tp_set_offload_mode(adapter, 1);
1005 tdev->lldev = adapter->port[0]; 1013 tdev->lldev = adapter->port[0];
@@ -1061,10 +1069,8 @@ static int cxgb_open(struct net_device *dev)
1061 int other_ports = adapter->open_device_map & PORT_MASK; 1069 int other_ports = adapter->open_device_map & PORT_MASK;
1062 int err; 1070 int err;
1063 1071
1064 if (!adapter->open_device_map && (err = cxgb_up(adapter)) < 0) { 1072 if (!adapter->open_device_map && (err = cxgb_up(adapter)) < 0)
1065 quiesce_rx(adapter);
1066 return err; 1073 return err;
1067 }
1068 1074
1069 set_bit(pi->port_id, &adapter->open_device_map); 1075 set_bit(pi->port_id, &adapter->open_device_map);
1070 if (is_offload(adapter) && !ofld_disable) { 1076 if (is_offload(adapter) && !ofld_disable) {
@@ -2424,14 +2430,11 @@ static pci_ers_result_t t3_io_error_detected(struct pci_dev *pdev,
2424 test_bit(OFFLOAD_DEVMAP_BIT, &adapter->open_device_map)) 2430 test_bit(OFFLOAD_DEVMAP_BIT, &adapter->open_device_map))
2425 offload_close(&adapter->tdev); 2431 offload_close(&adapter->tdev);
2426 2432
2427 /* Free sge resources */
2428 t3_free_sge_resources(adapter);
2429
2430 adapter->flags &= ~FULL_INIT_DONE; 2433 adapter->flags &= ~FULL_INIT_DONE;
2431 2434
2432 pci_disable_device(pdev); 2435 pci_disable_device(pdev);
2433 2436
2434 /* Request a slot slot reset. */ 2437 /* Request a slot reset. */
2435 return PCI_ERS_RESULT_NEED_RESET; 2438 return PCI_ERS_RESULT_NEED_RESET;
2436} 2439}
2437 2440
@@ -2448,13 +2451,20 @@ static pci_ers_result_t t3_io_slot_reset(struct pci_dev *pdev)
2448 if (pci_enable_device(pdev)) { 2451 if (pci_enable_device(pdev)) {
2449 dev_err(&pdev->dev, 2452 dev_err(&pdev->dev,
2450 "Cannot re-enable PCI device after reset.\n"); 2453 "Cannot re-enable PCI device after reset.\n");
2451 return PCI_ERS_RESULT_DISCONNECT; 2454 goto err;
2452 } 2455 }
2453 pci_set_master(pdev); 2456 pci_set_master(pdev);
2457 pci_restore_state(pdev);
2454 2458
2455 t3_prep_adapter(adapter, adapter->params.info, 1); 2459 /* Free sge resources */
2460 t3_free_sge_resources(adapter);
2461
2462 if (t3_replay_prep_adapter(adapter))
2463 goto err;
2456 2464
2457 return PCI_ERS_RESULT_RECOVERED; 2465 return PCI_ERS_RESULT_RECOVERED;
2466err:
2467 return PCI_ERS_RESULT_DISCONNECT;
2458} 2468}
2459 2469
2460/** 2470/**
@@ -2483,13 +2493,6 @@ static void t3_io_resume(struct pci_dev *pdev)
2483 netif_device_attach(netdev); 2493 netif_device_attach(netdev);
2484 } 2494 }
2485 } 2495 }
2486
2487 if (is_offload(adapter)) {
2488 __set_bit(OFFLOAD_DEVMAP_BIT, &adapter->registered_device_map);
2489 if (offload_open(adapter->port[0]))
2490 printk(KERN_WARNING
2491 "Could not bring back offload capabilities\n");
2492 }
2493} 2496}
2494 2497
2495static struct pci_error_handlers t3_err_handler = { 2498static struct pci_error_handlers t3_err_handler = {
@@ -2608,6 +2611,7 @@ static int __devinit init_one(struct pci_dev *pdev,
2608 } 2611 }
2609 2612
2610 pci_set_master(pdev); 2613 pci_set_master(pdev);
2614 pci_save_state(pdev);
2611 2615
2612 mmio_start = pci_resource_start(pdev, 0); 2616 mmio_start = pci_resource_start(pdev, 0);
2613 mmio_len = pci_resource_len(pdev, 0); 2617 mmio_len = pci_resource_len(pdev, 0);
diff --git a/drivers/net/cxgb3/regs.h b/drivers/net/cxgb3/regs.h
index 02dbbb300929..567178879345 100644
--- a/drivers/net/cxgb3/regs.h
+++ b/drivers/net/cxgb3/regs.h
@@ -444,6 +444,14 @@
444 444
445#define A_PCIE_CFG 0x88 445#define A_PCIE_CFG 0x88
446 446
447#define S_ENABLELINKDWNDRST 21
448#define V_ENABLELINKDWNDRST(x) ((x) << S_ENABLELINKDWNDRST)
449#define F_ENABLELINKDWNDRST V_ENABLELINKDWNDRST(1U)
450
451#define S_ENABLELINKDOWNRST 20
452#define V_ENABLELINKDOWNRST(x) ((x) << S_ENABLELINKDOWNRST)
453#define F_ENABLELINKDOWNRST V_ENABLELINKDOWNRST(1U)
454
447#define S_PCIE_CLIDECEN 16 455#define S_PCIE_CLIDECEN 16
448#define V_PCIE_CLIDECEN(x) ((x) << S_PCIE_CLIDECEN) 456#define V_PCIE_CLIDECEN(x) ((x) << S_PCIE_CLIDECEN)
449#define F_PCIE_CLIDECEN V_PCIE_CLIDECEN(1U) 457#define F_PCIE_CLIDECEN V_PCIE_CLIDECEN(1U)
diff --git a/drivers/net/cxgb3/sge.c b/drivers/net/cxgb3/sge.c
index 98a6bbd11d4c..796eb305cdc3 100644
--- a/drivers/net/cxgb3/sge.c
+++ b/drivers/net/cxgb3/sge.c
@@ -539,6 +539,31 @@ static void *alloc_ring(struct pci_dev *pdev, size_t nelem, size_t elem_size,
539} 539}
540 540
541/** 541/**
542 * t3_reset_qset - reset a sge qset
543 * @q: the queue set
544 *
545 * Reset the qset structure.
546 * the NAPI structure is preserved in the event of
547 * the qset's reincarnation, for example during EEH recovery.
548 */
549static void t3_reset_qset(struct sge_qset *q)
550{
551 if (q->adap &&
552 !(q->adap->flags & NAPI_INIT)) {
553 memset(q, 0, sizeof(*q));
554 return;
555 }
556
557 q->adap = NULL;
558 memset(&q->rspq, 0, sizeof(q->rspq));
559 memset(q->fl, 0, sizeof(struct sge_fl) * SGE_RXQ_PER_SET);
560 memset(q->txq, 0, sizeof(struct sge_txq) * SGE_TXQ_PER_SET);
561 q->txq_stopped = 0;
562 memset(&q->tx_reclaim_timer, 0, sizeof(q->tx_reclaim_timer));
563}
564
565
566/**
542 * free_qset - free the resources of an SGE queue set 567 * free_qset - free the resources of an SGE queue set
543 * @adapter: the adapter owning the queue set 568 * @adapter: the adapter owning the queue set
544 * @q: the queue set 569 * @q: the queue set
@@ -594,7 +619,7 @@ static void t3_free_qset(struct adapter *adapter, struct sge_qset *q)
594 q->rspq.desc, q->rspq.phys_addr); 619 q->rspq.desc, q->rspq.phys_addr);
595 } 620 }
596 621
597 memset(q, 0, sizeof(*q)); 622 t3_reset_qset(q);
598} 623}
599 624
600/** 625/**
@@ -1365,7 +1390,7 @@ static void restart_ctrlq(unsigned long data)
1365 */ 1390 */
1366int t3_mgmt_tx(struct adapter *adap, struct sk_buff *skb) 1391int t3_mgmt_tx(struct adapter *adap, struct sk_buff *skb)
1367{ 1392{
1368 int ret; 1393 int ret;
1369 local_bh_disable(); 1394 local_bh_disable();
1370 ret = ctrl_xmit(adap, &adap->sge.qs[0].txq[TXQ_CTRL], skb); 1395 ret = ctrl_xmit(adap, &adap->sge.qs[0].txq[TXQ_CTRL], skb);
1371 local_bh_enable(); 1396 local_bh_enable();
diff --git a/drivers/net/cxgb3/t3_hw.c b/drivers/net/cxgb3/t3_hw.c
index a99496a431c4..d405a932c73a 100644
--- a/drivers/net/cxgb3/t3_hw.c
+++ b/drivers/net/cxgb3/t3_hw.c
@@ -3264,6 +3264,7 @@ static void config_pcie(struct adapter *adap)
3264 3264
3265 t3_write_reg(adap, A_PCIE_PEX_ERR, 0xffffffff); 3265 t3_write_reg(adap, A_PCIE_PEX_ERR, 0xffffffff);
3266 t3_set_reg_field(adap, A_PCIE_CFG, 0, 3266 t3_set_reg_field(adap, A_PCIE_CFG, 0,
3267 F_ENABLELINKDWNDRST | F_ENABLELINKDOWNRST |
3267 F_PCIE_DMASTOPEN | F_PCIE_CLIDECEN); 3268 F_PCIE_DMASTOPEN | F_PCIE_CLIDECEN);
3268} 3269}
3269 3270
@@ -3655,3 +3656,30 @@ void t3_led_ready(struct adapter *adapter)
3655 t3_set_reg_field(adapter, A_T3DBG_GPIO_EN, F_GPIO0_OUT_VAL, 3656 t3_set_reg_field(adapter, A_T3DBG_GPIO_EN, F_GPIO0_OUT_VAL,
3656 F_GPIO0_OUT_VAL); 3657 F_GPIO0_OUT_VAL);
3657} 3658}
3659
3660int t3_replay_prep_adapter(struct adapter *adapter)
3661{
3662 const struct adapter_info *ai = adapter->params.info;
3663 unsigned int i, j = 0;
3664 int ret;
3665
3666 early_hw_init(adapter, ai);
3667 ret = init_parity(adapter);
3668 if (ret)
3669 return ret;
3670
3671 for_each_port(adapter, i) {
3672 struct port_info *p = adap2pinfo(adapter, i);
3673 while (!adapter->params.vpd.port_type[j])
3674 ++j;
3675
3676 p->port_type->phy_prep(&p->phy, adapter, ai->phy_base_addr + j,
3677 ai->mdio_ops);
3678
3679 p->phy.ops->power_down(&p->phy, 1);
3680 ++j;
3681 }
3682
3683return 0;
3684}
3685
diff --git a/drivers/net/dm9000.c b/drivers/net/dm9000.c
index e6fe2614ea6d..d45bcd2660af 100644
--- a/drivers/net/dm9000.c
+++ b/drivers/net/dm9000.c
@@ -117,6 +117,9 @@ typedef struct board_info {
117 117
118 struct mutex addr_lock; /* phy and eeprom access lock */ 118 struct mutex addr_lock; /* phy and eeprom access lock */
119 119
120 struct delayed_work phy_poll;
121 struct net_device *ndev;
122
120 spinlock_t lock; 123 spinlock_t lock;
121 124
122 struct mii_if_info mii; 125 struct mii_if_info mii;
@@ -297,6 +300,10 @@ static void dm9000_set_io(struct board_info *db, int byte_width)
297 } 300 }
298} 301}
299 302
303static void dm9000_schedule_poll(board_info_t *db)
304{
305 schedule_delayed_work(&db->phy_poll, HZ * 2);
306}
300 307
301/* Our watchdog timed out. Called by the networking layer */ 308/* Our watchdog timed out. Called by the networking layer */
302static void dm9000_timeout(struct net_device *dev) 309static void dm9000_timeout(struct net_device *dev)
@@ -465,6 +472,17 @@ static const struct ethtool_ops dm9000_ethtool_ops = {
465 .set_eeprom = dm9000_set_eeprom, 472 .set_eeprom = dm9000_set_eeprom,
466}; 473};
467 474
475static void
476dm9000_poll_work(struct work_struct *w)
477{
478 struct delayed_work *dw = container_of(w, struct delayed_work, work);
479 board_info_t *db = container_of(dw, board_info_t, phy_poll);
480
481 mii_check_media(&db->mii, netif_msg_link(db), 0);
482
483 if (netif_running(db->ndev))
484 dm9000_schedule_poll(db);
485}
468 486
469/* dm9000_release_board 487/* dm9000_release_board
470 * 488 *
@@ -503,7 +521,7 @@ dm9000_release_board(struct platform_device *pdev, struct board_info *db)
503/* 521/*
504 * Search DM9000 board, allocate space and register it 522 * Search DM9000 board, allocate space and register it
505 */ 523 */
506static int 524static int __devinit
507dm9000_probe(struct platform_device *pdev) 525dm9000_probe(struct platform_device *pdev)
508{ 526{
509 struct dm9000_plat_data *pdata = pdev->dev.platform_data; 527 struct dm9000_plat_data *pdata = pdev->dev.platform_data;
@@ -525,17 +543,21 @@ dm9000_probe(struct platform_device *pdev)
525 543
526 SET_NETDEV_DEV(ndev, &pdev->dev); 544 SET_NETDEV_DEV(ndev, &pdev->dev);
527 545
528 dev_dbg(&pdev->dev, "dm9000_probe()"); 546 dev_dbg(&pdev->dev, "dm9000_probe()\n");
529 547
530 /* setup board info structure */ 548 /* setup board info structure */
531 db = (struct board_info *) ndev->priv; 549 db = (struct board_info *) ndev->priv;
532 memset(db, 0, sizeof (*db)); 550 memset(db, 0, sizeof (*db));
533 551
534 db->dev = &pdev->dev; 552 db->dev = &pdev->dev;
553 db->ndev = ndev;
535 554
536 spin_lock_init(&db->lock); 555 spin_lock_init(&db->lock);
537 mutex_init(&db->addr_lock); 556 mutex_init(&db->addr_lock);
538 557
558 INIT_DELAYED_WORK(&db->phy_poll, dm9000_poll_work);
559
560
539 if (pdev->num_resources < 2) { 561 if (pdev->num_resources < 2) {
540 ret = -ENODEV; 562 ret = -ENODEV;
541 goto out; 563 goto out;
@@ -761,6 +783,8 @@ dm9000_open(struct net_device *dev)
761 783
762 mii_check_media(&db->mii, netif_msg_link(db), 1); 784 mii_check_media(&db->mii, netif_msg_link(db), 1);
763 netif_start_queue(dev); 785 netif_start_queue(dev);
786
787 dm9000_schedule_poll(db);
764 788
765 return 0; 789 return 0;
766} 790}
@@ -879,6 +903,8 @@ dm9000_stop(struct net_device *ndev)
879 if (netif_msg_ifdown(db)) 903 if (netif_msg_ifdown(db))
880 dev_dbg(db->dev, "shutting down %s\n", ndev->name); 904 dev_dbg(db->dev, "shutting down %s\n", ndev->name);
881 905
906 cancel_delayed_work(&db->phy_poll);
907
882 netif_stop_queue(ndev); 908 netif_stop_queue(ndev);
883 netif_carrier_off(ndev); 909 netif_carrier_off(ndev);
884 910
@@ -1288,6 +1314,8 @@ dm9000_phy_read(struct net_device *dev, int phy_reg_unused, int reg)
1288 spin_unlock_irqrestore(&db->lock,flags); 1314 spin_unlock_irqrestore(&db->lock,flags);
1289 1315
1290 mutex_unlock(&db->addr_lock); 1316 mutex_unlock(&db->addr_lock);
1317
1318 dm9000_dbg(db, 5, "phy_read[%02x] -> %04x\n", reg, ret);
1291 return ret; 1319 return ret;
1292} 1320}
1293 1321
@@ -1301,6 +1329,7 @@ dm9000_phy_write(struct net_device *dev, int phyaddr_unused, int reg, int value)
1301 unsigned long flags; 1329 unsigned long flags;
1302 unsigned long reg_save; 1330 unsigned long reg_save;
1303 1331
1332 dm9000_dbg(db, 5, "phy_write[%02x] = %04x\n", reg, value);
1304 mutex_lock(&db->addr_lock); 1333 mutex_lock(&db->addr_lock);
1305 1334
1306 spin_lock_irqsave(&db->lock,flags); 1335 spin_lock_irqsave(&db->lock,flags);
@@ -1372,7 +1401,7 @@ dm9000_drv_resume(struct platform_device *dev)
1372 return 0; 1401 return 0;
1373} 1402}
1374 1403
1375static int 1404static int __devexit
1376dm9000_drv_remove(struct platform_device *pdev) 1405dm9000_drv_remove(struct platform_device *pdev)
1377{ 1406{
1378 struct net_device *ndev = platform_get_drvdata(pdev); 1407 struct net_device *ndev = platform_get_drvdata(pdev);
@@ -1393,7 +1422,7 @@ static struct platform_driver dm9000_driver = {
1393 .owner = THIS_MODULE, 1422 .owner = THIS_MODULE,
1394 }, 1423 },
1395 .probe = dm9000_probe, 1424 .probe = dm9000_probe,
1396 .remove = dm9000_drv_remove, 1425 .remove = __devexit_p(dm9000_drv_remove),
1397 .suspend = dm9000_drv_suspend, 1426 .suspend = dm9000_drv_suspend,
1398 .resume = dm9000_drv_resume, 1427 .resume = dm9000_drv_resume,
1399}; 1428};
diff --git a/drivers/net/ehea/ehea.h b/drivers/net/ehea/ehea.h
index f5dacceab95b..fe872fbd671e 100644
--- a/drivers/net/ehea/ehea.h
+++ b/drivers/net/ehea/ehea.h
@@ -40,7 +40,7 @@
40#include <asm/io.h> 40#include <asm/io.h>
41 41
42#define DRV_NAME "ehea" 42#define DRV_NAME "ehea"
43#define DRV_VERSION "EHEA_0090" 43#define DRV_VERSION "EHEA_0091"
44 44
45/* eHEA capability flags */ 45/* eHEA capability flags */
46#define DLPAR_PORT_ADD_REM 1 46#define DLPAR_PORT_ADD_REM 1
@@ -118,6 +118,13 @@
118#define EHEA_MR_ACC_CTRL 0x00800000 118#define EHEA_MR_ACC_CTRL 0x00800000
119 119
120#define EHEA_BUSMAP_START 0x8000000000000000ULL 120#define EHEA_BUSMAP_START 0x8000000000000000ULL
121#define EHEA_INVAL_ADDR 0xFFFFFFFFFFFFFFFFULL
122#define EHEA_DIR_INDEX_SHIFT 13 /* 8k Entries in 64k block */
123#define EHEA_TOP_INDEX_SHIFT (EHEA_DIR_INDEX_SHIFT * 2)
124#define EHEA_MAP_ENTRIES (1 << EHEA_DIR_INDEX_SHIFT)
125#define EHEA_MAP_SIZE (0x10000) /* currently fixed map size */
126#define EHEA_INDEX_MASK (EHEA_MAP_ENTRIES - 1)
127
121 128
122#define EHEA_WATCH_DOG_TIMEOUT 10*HZ 129#define EHEA_WATCH_DOG_TIMEOUT 10*HZ
123 130
@@ -192,10 +199,20 @@ struct h_epas {
192 set to 0 if unused */ 199 set to 0 if unused */
193}; 200};
194 201
195struct ehea_busmap { 202/*
196 unsigned int entries; /* total number of entries */ 203 * Memory map data structures
197 unsigned int valid_sections; /* number of valid sections */ 204 */
198 u64 *vaddr; 205struct ehea_dir_bmap
206{
207 u64 ent[EHEA_MAP_ENTRIES];
208};
209struct ehea_top_bmap
210{
211 struct ehea_dir_bmap *dir[EHEA_MAP_ENTRIES];
212};
213struct ehea_bmap
214{
215 struct ehea_top_bmap *top[EHEA_MAP_ENTRIES];
199}; 216};
200 217
201struct ehea_qp; 218struct ehea_qp;
diff --git a/drivers/net/ehea/ehea_main.c b/drivers/net/ehea/ehea_main.c
index f9bc21c74b59..d1b6d4e7495d 100644
--- a/drivers/net/ehea/ehea_main.c
+++ b/drivers/net/ehea/ehea_main.c
@@ -35,6 +35,7 @@
35#include <linux/if_ether.h> 35#include <linux/if_ether.h>
36#include <linux/notifier.h> 36#include <linux/notifier.h>
37#include <linux/reboot.h> 37#include <linux/reboot.h>
38#include <linux/memory.h>
38#include <asm/kexec.h> 39#include <asm/kexec.h>
39#include <linux/mutex.h> 40#include <linux/mutex.h>
40 41
@@ -3503,6 +3504,24 @@ void ehea_crash_handler(void)
3503 0, H_DEREG_BCMC); 3504 0, H_DEREG_BCMC);
3504} 3505}
3505 3506
3507static int ehea_mem_notifier(struct notifier_block *nb,
3508 unsigned long action, void *data)
3509{
3510 switch (action) {
3511 case MEM_OFFLINE:
3512 ehea_info("memory has been removed");
3513 ehea_rereg_mrs(NULL);
3514 break;
3515 default:
3516 break;
3517 }
3518 return NOTIFY_OK;
3519}
3520
3521static struct notifier_block ehea_mem_nb = {
3522 .notifier_call = ehea_mem_notifier,
3523};
3524
3506static int ehea_reboot_notifier(struct notifier_block *nb, 3525static int ehea_reboot_notifier(struct notifier_block *nb,
3507 unsigned long action, void *unused) 3526 unsigned long action, void *unused)
3508{ 3527{
@@ -3581,6 +3600,10 @@ int __init ehea_module_init(void)
3581 if (ret) 3600 if (ret)
3582 ehea_info("failed registering reboot notifier"); 3601 ehea_info("failed registering reboot notifier");
3583 3602
3603 ret = register_memory_notifier(&ehea_mem_nb);
3604 if (ret)
3605 ehea_info("failed registering memory remove notifier");
3606
3584 ret = crash_shutdown_register(&ehea_crash_handler); 3607 ret = crash_shutdown_register(&ehea_crash_handler);
3585 if (ret) 3608 if (ret)
3586 ehea_info("failed registering crash handler"); 3609 ehea_info("failed registering crash handler");
@@ -3604,6 +3627,7 @@ int __init ehea_module_init(void)
3604out3: 3627out3:
3605 ibmebus_unregister_driver(&ehea_driver); 3628 ibmebus_unregister_driver(&ehea_driver);
3606out2: 3629out2:
3630 unregister_memory_notifier(&ehea_mem_nb);
3607 unregister_reboot_notifier(&ehea_reboot_nb); 3631 unregister_reboot_notifier(&ehea_reboot_nb);
3608 crash_shutdown_unregister(&ehea_crash_handler); 3632 crash_shutdown_unregister(&ehea_crash_handler);
3609out: 3633out:
@@ -3621,6 +3645,7 @@ static void __exit ehea_module_exit(void)
3621 ret = crash_shutdown_unregister(&ehea_crash_handler); 3645 ret = crash_shutdown_unregister(&ehea_crash_handler);
3622 if (ret) 3646 if (ret)
3623 ehea_info("failed unregistering crash handler"); 3647 ehea_info("failed unregistering crash handler");
3648 unregister_memory_notifier(&ehea_mem_nb);
3624 kfree(ehea_fw_handles.arr); 3649 kfree(ehea_fw_handles.arr);
3625 kfree(ehea_bcmc_regs.arr); 3650 kfree(ehea_bcmc_regs.arr);
3626 ehea_destroy_busmap(); 3651 ehea_destroy_busmap();
diff --git a/drivers/net/ehea/ehea_qmr.c b/drivers/net/ehea/ehea_qmr.c
index d522e905f460..140f05baafd8 100644
--- a/drivers/net/ehea/ehea_qmr.c
+++ b/drivers/net/ehea/ehea_qmr.c
@@ -31,8 +31,8 @@
31#include "ehea_phyp.h" 31#include "ehea_phyp.h"
32#include "ehea_qmr.h" 32#include "ehea_qmr.h"
33 33
34struct ehea_bmap *ehea_bmap = NULL;
34 35
35struct ehea_busmap ehea_bmap = { 0, 0, NULL };
36 36
37 37
38static void *hw_qpageit_get_inc(struct hw_queue *queue) 38static void *hw_qpageit_get_inc(struct hw_queue *queue)
@@ -559,125 +559,253 @@ int ehea_destroy_qp(struct ehea_qp *qp)
559 return 0; 559 return 0;
560} 560}
561 561
562int ehea_create_busmap(void) 562static inline int ehea_calc_index(unsigned long i, unsigned long s)
563{ 563{
564 u64 vaddr = EHEA_BUSMAP_START; 564 return (i >> s) & EHEA_INDEX_MASK;
565 unsigned long high_section_index = 0; 565}
566 int i;
567 566
568 /* 567static inline int ehea_init_top_bmap(struct ehea_top_bmap *ehea_top_bmap,
569 * Sections are not in ascending order -> Loop over all sections and 568 int dir)
570 * find the highest PFN to compute the required map size. 569{
571 */ 570 if(!ehea_top_bmap->dir[dir]) {
572 ehea_bmap.valid_sections = 0; 571 ehea_top_bmap->dir[dir] =
572 kzalloc(sizeof(struct ehea_dir_bmap), GFP_KERNEL);
573 if (!ehea_top_bmap->dir[dir])
574 return -ENOMEM;
575 }
576 return 0;
577}
573 578
574 for (i = 0; i < NR_MEM_SECTIONS; i++) 579static inline int ehea_init_bmap(struct ehea_bmap *ehea_bmap, int top, int dir)
575 if (valid_section_nr(i)) 580{
576 high_section_index = i; 581 if(!ehea_bmap->top[top]) {
582 ehea_bmap->top[top] =
583 kzalloc(sizeof(struct ehea_top_bmap), GFP_KERNEL);
584 if (!ehea_bmap->top[top])
585 return -ENOMEM;
586 }
587 return ehea_init_top_bmap(ehea_bmap->top[top], dir);
588}
577 589
578 ehea_bmap.entries = high_section_index + 1; 590static int ehea_create_busmap_callback(unsigned long pfn,
579 ehea_bmap.vaddr = vmalloc(ehea_bmap.entries * sizeof(*ehea_bmap.vaddr)); 591 unsigned long nr_pages, void *arg)
592{
593 unsigned long i, mr_len, start_section, end_section;
594 start_section = (pfn * PAGE_SIZE) / EHEA_SECTSIZE;
595 end_section = start_section + ((nr_pages * PAGE_SIZE) / EHEA_SECTSIZE);
596 mr_len = *(unsigned long *)arg;
580 597
581 if (!ehea_bmap.vaddr) 598 ehea_bmap = kzalloc(sizeof(struct ehea_bmap), GFP_KERNEL);
599 if (!ehea_bmap)
582 return -ENOMEM; 600 return -ENOMEM;
583 601
584 for (i = 0 ; i < ehea_bmap.entries; i++) { 602 for (i = start_section; i < end_section; i++) {
585 unsigned long pfn = section_nr_to_pfn(i); 603 int ret;
604 int top, dir, idx;
605 u64 vaddr;
606
607 top = ehea_calc_index(i, EHEA_TOP_INDEX_SHIFT);
608 dir = ehea_calc_index(i, EHEA_DIR_INDEX_SHIFT);
609
610 ret = ehea_init_bmap(ehea_bmap, top, dir);
611 if(ret)
612 return ret;
586 613
587 if (pfn_valid(pfn)) { 614 idx = i & EHEA_INDEX_MASK;
588 ehea_bmap.vaddr[i] = vaddr; 615 vaddr = EHEA_BUSMAP_START + mr_len + i * EHEA_SECTSIZE;
589 vaddr += EHEA_SECTSIZE; 616
590 ehea_bmap.valid_sections++; 617 ehea_bmap->top[top]->dir[dir]->ent[idx] = vaddr;
591 } else
592 ehea_bmap.vaddr[i] = 0;
593 } 618 }
594 619
620 mr_len += nr_pages * PAGE_SIZE;
621 *(unsigned long *)arg = mr_len;
622
595 return 0; 623 return 0;
596} 624}
597 625
626static unsigned long ehea_mr_len;
627
628static DEFINE_MUTEX(ehea_busmap_mutex);
629
630int ehea_create_busmap(void)
631{
632 int ret;
633 mutex_lock(&ehea_busmap_mutex);
634 ehea_mr_len = 0;
635 ret = walk_memory_resource(0, 1ULL << MAX_PHYSMEM_BITS, &ehea_mr_len,
636 ehea_create_busmap_callback);
637 mutex_unlock(&ehea_busmap_mutex);
638 return ret;
639}
640
598void ehea_destroy_busmap(void) 641void ehea_destroy_busmap(void)
599{ 642{
600 vfree(ehea_bmap.vaddr); 643 int top, dir;
644 mutex_lock(&ehea_busmap_mutex);
645 if (!ehea_bmap)
646 goto out_destroy;
647
648 for (top = 0; top < EHEA_MAP_ENTRIES; top++) {
649 if (!ehea_bmap->top[top])
650 continue;
651
652 for (dir = 0; dir < EHEA_MAP_ENTRIES; dir++) {
653 if (!ehea_bmap->top[top]->dir[dir])
654 continue;
655
656 kfree(ehea_bmap->top[top]->dir[dir]);
657 }
658
659 kfree(ehea_bmap->top[top]);
660 }
661
662 kfree(ehea_bmap);
663 ehea_bmap = NULL;
664out_destroy:
665 mutex_unlock(&ehea_busmap_mutex);
601} 666}
602 667
603u64 ehea_map_vaddr(void *caddr) 668u64 ehea_map_vaddr(void *caddr)
604{ 669{
605 u64 mapped_addr; 670 int top, dir, idx;
606 unsigned long index = __pa(caddr) >> SECTION_SIZE_BITS; 671 unsigned long index, offset;
607 672
608 if (likely(index < ehea_bmap.entries)) { 673 if (!ehea_bmap)
609 mapped_addr = ehea_bmap.vaddr[index]; 674 return EHEA_INVAL_ADDR;
610 if (likely(mapped_addr)) 675
611 mapped_addr |= (((unsigned long)caddr) 676 index = virt_to_abs(caddr) >> SECTION_SIZE_BITS;
612 & (EHEA_SECTSIZE - 1)); 677 top = (index >> EHEA_TOP_INDEX_SHIFT) & EHEA_INDEX_MASK;
613 else 678 if (!ehea_bmap->top[top])
614 mapped_addr = -1; 679 return EHEA_INVAL_ADDR;
615 } else 680
616 mapped_addr = -1; 681 dir = (index >> EHEA_DIR_INDEX_SHIFT) & EHEA_INDEX_MASK;
617 682 if (!ehea_bmap->top[top]->dir[dir])
618 if (unlikely(mapped_addr == -1)) 683 return EHEA_INVAL_ADDR;
619 if (!test_and_set_bit(__EHEA_STOP_XFER, &ehea_driver_flags)) 684
620 schedule_work(&ehea_rereg_mr_task); 685 idx = index & EHEA_INDEX_MASK;
621 686 if (!ehea_bmap->top[top]->dir[dir]->ent[idx])
622 return mapped_addr; 687 return EHEA_INVAL_ADDR;
688
689 offset = (unsigned long)caddr & (EHEA_SECTSIZE - 1);
690 return ehea_bmap->top[top]->dir[dir]->ent[idx] | offset;
691}
692
693static inline void *ehea_calc_sectbase(int top, int dir, int idx)
694{
695 unsigned long ret = idx;
696 ret |= dir << EHEA_DIR_INDEX_SHIFT;
697 ret |= top << EHEA_TOP_INDEX_SHIFT;
698 return abs_to_virt(ret << SECTION_SIZE_BITS);
699}
700
701static u64 ehea_reg_mr_section(int top, int dir, int idx, u64 *pt,
702 struct ehea_adapter *adapter,
703 struct ehea_mr *mr)
704{
705 void *pg;
706 u64 j, m, hret;
707 unsigned long k = 0;
708 u64 pt_abs = virt_to_abs(pt);
709
710 void *sectbase = ehea_calc_sectbase(top, dir, idx);
711
712 for (j = 0; j < (EHEA_PAGES_PER_SECTION / EHEA_MAX_RPAGE); j++) {
713
714 for (m = 0; m < EHEA_MAX_RPAGE; m++) {
715 pg = sectbase + ((k++) * EHEA_PAGESIZE);
716 pt[m] = virt_to_abs(pg);
717 }
718 hret = ehea_h_register_rpage_mr(adapter->handle, mr->handle, 0,
719 0, pt_abs, EHEA_MAX_RPAGE);
720
721 if ((hret != H_SUCCESS)
722 && (hret != H_PAGE_REGISTERED)) {
723 ehea_h_free_resource(adapter->handle, mr->handle,
724 FORCE_FREE);
725 ehea_error("register_rpage_mr failed");
726 return hret;
727 }
728 }
729 return hret;
730}
731
732static u64 ehea_reg_mr_sections(int top, int dir, u64 *pt,
733 struct ehea_adapter *adapter,
734 struct ehea_mr *mr)
735{
736 u64 hret = H_SUCCESS;
737 int idx;
738
739 for (idx = 0; idx < EHEA_MAP_ENTRIES; idx++) {
740 if (!ehea_bmap->top[top]->dir[dir]->ent[idx])
741 continue;
742
743 hret = ehea_reg_mr_section(top, dir, idx, pt, adapter, mr);
744 if ((hret != H_SUCCESS) && (hret != H_PAGE_REGISTERED))
745 return hret;
746 }
747 return hret;
748}
749
750static u64 ehea_reg_mr_dir_sections(int top, u64 *pt,
751 struct ehea_adapter *adapter,
752 struct ehea_mr *mr)
753{
754 u64 hret = H_SUCCESS;
755 int dir;
756
757 for (dir = 0; dir < EHEA_MAP_ENTRIES; dir++) {
758 if (!ehea_bmap->top[top]->dir[dir])
759 continue;
760
761 hret = ehea_reg_mr_sections(top, dir, pt, adapter, mr);
762 if ((hret != H_SUCCESS) && (hret != H_PAGE_REGISTERED))
763 return hret;
764 }
765 return hret;
623} 766}
624 767
625int ehea_reg_kernel_mr(struct ehea_adapter *adapter, struct ehea_mr *mr) 768int ehea_reg_kernel_mr(struct ehea_adapter *adapter, struct ehea_mr *mr)
626{ 769{
627 int ret; 770 int ret;
628 u64 *pt; 771 u64 *pt;
629 void *pg; 772 u64 hret;
630 u64 hret, pt_abs, i, j, m, mr_len;
631 u32 acc_ctrl = EHEA_MR_ACC_CTRL; 773 u32 acc_ctrl = EHEA_MR_ACC_CTRL;
632 774
633 mr_len = ehea_bmap.valid_sections * EHEA_SECTSIZE; 775 unsigned long top;
634 776
635 pt = kzalloc(PAGE_SIZE, GFP_KERNEL); 777 pt = kzalloc(PAGE_SIZE, GFP_KERNEL);
636 if (!pt) { 778 if (!pt) {
637 ehea_error("no mem"); 779 ehea_error("no mem");
638 ret = -ENOMEM; 780 ret = -ENOMEM;
639 goto out; 781 goto out;
640 } 782 }
641 pt_abs = virt_to_abs(pt);
642 783
643 hret = ehea_h_alloc_resource_mr(adapter->handle, 784 hret = ehea_h_alloc_resource_mr(adapter->handle, EHEA_BUSMAP_START,
644 EHEA_BUSMAP_START, mr_len, 785 ehea_mr_len, acc_ctrl, adapter->pd,
645 acc_ctrl, adapter->pd,
646 &mr->handle, &mr->lkey); 786 &mr->handle, &mr->lkey);
787
647 if (hret != H_SUCCESS) { 788 if (hret != H_SUCCESS) {
648 ehea_error("alloc_resource_mr failed"); 789 ehea_error("alloc_resource_mr failed");
649 ret = -EIO; 790 ret = -EIO;
650 goto out; 791 goto out;
651 } 792 }
652 793
653 for (i = 0 ; i < ehea_bmap.entries; i++) 794 if (!ehea_bmap) {
654 if (ehea_bmap.vaddr[i]) { 795 ehea_h_free_resource(adapter->handle, mr->handle, FORCE_FREE);
655 void *sectbase = __va(i << SECTION_SIZE_BITS); 796 ehea_error("no busmap available");
656 unsigned long k = 0; 797 ret = -EIO;
657 798 goto out;
658 for (j = 0; j < (EHEA_PAGES_PER_SECTION / 799 }
659 EHEA_MAX_RPAGE); j++) { 800
660 801 for (top = 0; top < EHEA_MAP_ENTRIES; top++) {
661 for (m = 0; m < EHEA_MAX_RPAGE; m++) { 802 if (!ehea_bmap->top[top])
662 pg = sectbase + ((k++) * EHEA_PAGESIZE); 803 continue;
663 pt[m] = virt_to_abs(pg); 804
664 } 805 hret = ehea_reg_mr_dir_sections(top, pt, adapter, mr);
665 806 if((hret != H_PAGE_REGISTERED) && (hret != H_SUCCESS))
666 hret = ehea_h_register_rpage_mr(adapter->handle, 807 break;
667 mr->handle, 808 }
668 0, 0, pt_abs,
669 EHEA_MAX_RPAGE);
670 if ((hret != H_SUCCESS)
671 && (hret != H_PAGE_REGISTERED)) {
672 ehea_h_free_resource(adapter->handle,
673 mr->handle,
674 FORCE_FREE);
675 ehea_error("register_rpage_mr failed");
676 ret = -EIO;
677 goto out;
678 }
679 }
680 }
681 809
682 if (hret != H_SUCCESS) { 810 if (hret != H_SUCCESS) {
683 ehea_h_free_resource(adapter->handle, mr->handle, FORCE_FREE); 811 ehea_h_free_resource(adapter->handle, mr->handle, FORCE_FREE);
diff --git a/drivers/net/gianfar.c b/drivers/net/gianfar.c
index 6f22f068d6ee..25bdd0832df5 100644
--- a/drivers/net/gianfar.c
+++ b/drivers/net/gianfar.c
@@ -635,6 +635,8 @@ static void free_skb_resources(struct gfar_private *priv)
635 dev_kfree_skb_any(priv->tx_skbuff[i]); 635 dev_kfree_skb_any(priv->tx_skbuff[i]);
636 priv->tx_skbuff[i] = NULL; 636 priv->tx_skbuff[i] = NULL;
637 } 637 }
638
639 txbdp++;
638 } 640 }
639 641
640 kfree(priv->tx_skbuff); 642 kfree(priv->tx_skbuff);
diff --git a/drivers/net/myri10ge/myri10ge.c b/drivers/net/myri10ge/myri10ge.c
index ef63c8d2bd7e..c91b12ea26ad 100644
--- a/drivers/net/myri10ge/myri10ge.c
+++ b/drivers/net/myri10ge/myri10ge.c
@@ -144,11 +144,13 @@ struct myri10ge_tx_buf {
144 char *req_bytes; 144 char *req_bytes;
145 struct myri10ge_tx_buffer_state *info; 145 struct myri10ge_tx_buffer_state *info;
146 int mask; /* number of transmit slots -1 */ 146 int mask; /* number of transmit slots -1 */
147 int boundary; /* boundary transmits cannot cross */
148 int req ____cacheline_aligned; /* transmit slots submitted */ 147 int req ____cacheline_aligned; /* transmit slots submitted */
149 int pkt_start; /* packets started */ 148 int pkt_start; /* packets started */
149 int stop_queue;
150 int linearized;
150 int done ____cacheline_aligned; /* transmit slots completed */ 151 int done ____cacheline_aligned; /* transmit slots completed */
151 int pkt_done; /* packets completed */ 152 int pkt_done; /* packets completed */
153 int wake_queue;
152}; 154};
153 155
154struct myri10ge_rx_done { 156struct myri10ge_rx_done {
@@ -160,29 +162,50 @@ struct myri10ge_rx_done {
160 struct net_lro_desc lro_desc[MYRI10GE_MAX_LRO_DESCRIPTORS]; 162 struct net_lro_desc lro_desc[MYRI10GE_MAX_LRO_DESCRIPTORS];
161}; 163};
162 164
163struct myri10ge_priv { 165struct myri10ge_slice_netstats {
164 int running; /* running? */ 166 unsigned long rx_packets;
165 int csum_flag; /* rx_csums? */ 167 unsigned long tx_packets;
168 unsigned long rx_bytes;
169 unsigned long tx_bytes;
170 unsigned long rx_dropped;
171 unsigned long tx_dropped;
172};
173
174struct myri10ge_slice_state {
166 struct myri10ge_tx_buf tx; /* transmit ring */ 175 struct myri10ge_tx_buf tx; /* transmit ring */
167 struct myri10ge_rx_buf rx_small; 176 struct myri10ge_rx_buf rx_small;
168 struct myri10ge_rx_buf rx_big; 177 struct myri10ge_rx_buf rx_big;
169 struct myri10ge_rx_done rx_done; 178 struct myri10ge_rx_done rx_done;
179 struct net_device *dev;
180 struct napi_struct napi;
181 struct myri10ge_priv *mgp;
182 struct myri10ge_slice_netstats stats;
183 __be32 __iomem *irq_claim;
184 struct mcp_irq_data *fw_stats;
185 dma_addr_t fw_stats_bus;
186 int watchdog_tx_done;
187 int watchdog_tx_req;
188};
189
190struct myri10ge_priv {
191 struct myri10ge_slice_state ss;
192 int tx_boundary; /* boundary transmits cannot cross */
193 int running; /* running? */
194 int csum_flag; /* rx_csums? */
170 int small_bytes; 195 int small_bytes;
171 int big_bytes; 196 int big_bytes;
197 int max_intr_slots;
172 struct net_device *dev; 198 struct net_device *dev;
173 struct napi_struct napi;
174 struct net_device_stats stats; 199 struct net_device_stats stats;
200 spinlock_t stats_lock;
175 u8 __iomem *sram; 201 u8 __iomem *sram;
176 int sram_size; 202 int sram_size;
177 unsigned long board_span; 203 unsigned long board_span;
178 unsigned long iomem_base; 204 unsigned long iomem_base;
179 __be32 __iomem *irq_claim;
180 __be32 __iomem *irq_deassert; 205 __be32 __iomem *irq_deassert;
181 char *mac_addr_string; 206 char *mac_addr_string;
182 struct mcp_cmd_response *cmd; 207 struct mcp_cmd_response *cmd;
183 dma_addr_t cmd_bus; 208 dma_addr_t cmd_bus;
184 struct mcp_irq_data *fw_stats;
185 dma_addr_t fw_stats_bus;
186 struct pci_dev *pdev; 209 struct pci_dev *pdev;
187 int msi_enabled; 210 int msi_enabled;
188 u32 link_state; 211 u32 link_state;
@@ -191,20 +214,16 @@ struct myri10ge_priv {
191 __be32 __iomem *intr_coal_delay_ptr; 214 __be32 __iomem *intr_coal_delay_ptr;
192 int mtrr; 215 int mtrr;
193 int wc_enabled; 216 int wc_enabled;
194 int wake_queue;
195 int stop_queue;
196 int down_cnt; 217 int down_cnt;
197 wait_queue_head_t down_wq; 218 wait_queue_head_t down_wq;
198 struct work_struct watchdog_work; 219 struct work_struct watchdog_work;
199 struct timer_list watchdog_timer; 220 struct timer_list watchdog_timer;
200 int watchdog_tx_done;
201 int watchdog_tx_req;
202 int watchdog_pause;
203 int watchdog_resets; 221 int watchdog_resets;
204 int tx_linearized; 222 int watchdog_pause;
205 int pause; 223 int pause;
206 char *fw_name; 224 char *fw_name;
207 char eeprom_strings[MYRI10GE_EEPROM_STRINGS_SIZE]; 225 char eeprom_strings[MYRI10GE_EEPROM_STRINGS_SIZE];
226 char *product_code_string;
208 char fw_version[128]; 227 char fw_version[128];
209 int fw_ver_major; 228 int fw_ver_major;
210 int fw_ver_minor; 229 int fw_ver_minor;
@@ -228,58 +247,54 @@ static char *myri10ge_fw_aligned = "myri10ge_eth_z8e.dat";
228 247
229static char *myri10ge_fw_name = NULL; 248static char *myri10ge_fw_name = NULL;
230module_param(myri10ge_fw_name, charp, S_IRUGO | S_IWUSR); 249module_param(myri10ge_fw_name, charp, S_IRUGO | S_IWUSR);
231MODULE_PARM_DESC(myri10ge_fw_name, "Firmware image name\n"); 250MODULE_PARM_DESC(myri10ge_fw_name, "Firmware image name");
232 251
233static int myri10ge_ecrc_enable = 1; 252static int myri10ge_ecrc_enable = 1;
234module_param(myri10ge_ecrc_enable, int, S_IRUGO); 253module_param(myri10ge_ecrc_enable, int, S_IRUGO);
235MODULE_PARM_DESC(myri10ge_ecrc_enable, "Enable Extended CRC on PCI-E\n"); 254MODULE_PARM_DESC(myri10ge_ecrc_enable, "Enable Extended CRC on PCI-E");
236
237static int myri10ge_max_intr_slots = 1024;
238module_param(myri10ge_max_intr_slots, int, S_IRUGO);
239MODULE_PARM_DESC(myri10ge_max_intr_slots, "Interrupt queue slots\n");
240 255
241static int myri10ge_small_bytes = -1; /* -1 == auto */ 256static int myri10ge_small_bytes = -1; /* -1 == auto */
242module_param(myri10ge_small_bytes, int, S_IRUGO | S_IWUSR); 257module_param(myri10ge_small_bytes, int, S_IRUGO | S_IWUSR);
243MODULE_PARM_DESC(myri10ge_small_bytes, "Threshold of small packets\n"); 258MODULE_PARM_DESC(myri10ge_small_bytes, "Threshold of small packets");
244 259
245static int myri10ge_msi = 1; /* enable msi by default */ 260static int myri10ge_msi = 1; /* enable msi by default */
246module_param(myri10ge_msi, int, S_IRUGO | S_IWUSR); 261module_param(myri10ge_msi, int, S_IRUGO | S_IWUSR);
247MODULE_PARM_DESC(myri10ge_msi, "Enable Message Signalled Interrupts\n"); 262MODULE_PARM_DESC(myri10ge_msi, "Enable Message Signalled Interrupts");
248 263
249static int myri10ge_intr_coal_delay = 75; 264static int myri10ge_intr_coal_delay = 75;
250module_param(myri10ge_intr_coal_delay, int, S_IRUGO); 265module_param(myri10ge_intr_coal_delay, int, S_IRUGO);
251MODULE_PARM_DESC(myri10ge_intr_coal_delay, "Interrupt coalescing delay\n"); 266MODULE_PARM_DESC(myri10ge_intr_coal_delay, "Interrupt coalescing delay");
252 267
253static int myri10ge_flow_control = 1; 268static int myri10ge_flow_control = 1;
254module_param(myri10ge_flow_control, int, S_IRUGO); 269module_param(myri10ge_flow_control, int, S_IRUGO);
255MODULE_PARM_DESC(myri10ge_flow_control, "Pause parameter\n"); 270MODULE_PARM_DESC(myri10ge_flow_control, "Pause parameter");
256 271
257static int myri10ge_deassert_wait = 1; 272static int myri10ge_deassert_wait = 1;
258module_param(myri10ge_deassert_wait, int, S_IRUGO | S_IWUSR); 273module_param(myri10ge_deassert_wait, int, S_IRUGO | S_IWUSR);
259MODULE_PARM_DESC(myri10ge_deassert_wait, 274MODULE_PARM_DESC(myri10ge_deassert_wait,
260 "Wait when deasserting legacy interrupts\n"); 275 "Wait when deasserting legacy interrupts");
261 276
262static int myri10ge_force_firmware = 0; 277static int myri10ge_force_firmware = 0;
263module_param(myri10ge_force_firmware, int, S_IRUGO); 278module_param(myri10ge_force_firmware, int, S_IRUGO);
264MODULE_PARM_DESC(myri10ge_force_firmware, 279MODULE_PARM_DESC(myri10ge_force_firmware,
265 "Force firmware to assume aligned completions\n"); 280 "Force firmware to assume aligned completions");
266 281
267static int myri10ge_initial_mtu = MYRI10GE_MAX_ETHER_MTU - ETH_HLEN; 282static int myri10ge_initial_mtu = MYRI10GE_MAX_ETHER_MTU - ETH_HLEN;
268module_param(myri10ge_initial_mtu, int, S_IRUGO); 283module_param(myri10ge_initial_mtu, int, S_IRUGO);
269MODULE_PARM_DESC(myri10ge_initial_mtu, "Initial MTU\n"); 284MODULE_PARM_DESC(myri10ge_initial_mtu, "Initial MTU");
270 285
271static int myri10ge_napi_weight = 64; 286static int myri10ge_napi_weight = 64;
272module_param(myri10ge_napi_weight, int, S_IRUGO); 287module_param(myri10ge_napi_weight, int, S_IRUGO);
273MODULE_PARM_DESC(myri10ge_napi_weight, "Set NAPI weight\n"); 288MODULE_PARM_DESC(myri10ge_napi_weight, "Set NAPI weight");
274 289
275static int myri10ge_watchdog_timeout = 1; 290static int myri10ge_watchdog_timeout = 1;
276module_param(myri10ge_watchdog_timeout, int, S_IRUGO); 291module_param(myri10ge_watchdog_timeout, int, S_IRUGO);
277MODULE_PARM_DESC(myri10ge_watchdog_timeout, "Set watchdog timeout\n"); 292MODULE_PARM_DESC(myri10ge_watchdog_timeout, "Set watchdog timeout");
278 293
279static int myri10ge_max_irq_loops = 1048576; 294static int myri10ge_max_irq_loops = 1048576;
280module_param(myri10ge_max_irq_loops, int, S_IRUGO); 295module_param(myri10ge_max_irq_loops, int, S_IRUGO);
281MODULE_PARM_DESC(myri10ge_max_irq_loops, 296MODULE_PARM_DESC(myri10ge_max_irq_loops,
282 "Set stuck legacy IRQ detection threshold\n"); 297 "Set stuck legacy IRQ detection threshold");
283 298
284#define MYRI10GE_MSG_DEFAULT NETIF_MSG_LINK 299#define MYRI10GE_MSG_DEFAULT NETIF_MSG_LINK
285 300
@@ -289,21 +304,22 @@ MODULE_PARM_DESC(myri10ge_debug, "Debug level (0=none,...,16=all)");
289 304
290static int myri10ge_lro = 1; 305static int myri10ge_lro = 1;
291module_param(myri10ge_lro, int, S_IRUGO); 306module_param(myri10ge_lro, int, S_IRUGO);
292MODULE_PARM_DESC(myri10ge_lro, "Enable large receive offload\n"); 307MODULE_PARM_DESC(myri10ge_lro, "Enable large receive offload");
293 308
294static int myri10ge_lro_max_pkts = MYRI10GE_LRO_MAX_PKTS; 309static int myri10ge_lro_max_pkts = MYRI10GE_LRO_MAX_PKTS;
295module_param(myri10ge_lro_max_pkts, int, S_IRUGO); 310module_param(myri10ge_lro_max_pkts, int, S_IRUGO);
296MODULE_PARM_DESC(myri10ge_lro, "Number of LRO packets to be aggregated\n"); 311MODULE_PARM_DESC(myri10ge_lro_max_pkts,
312 "Number of LRO packets to be aggregated");
297 313
298static int myri10ge_fill_thresh = 256; 314static int myri10ge_fill_thresh = 256;
299module_param(myri10ge_fill_thresh, int, S_IRUGO | S_IWUSR); 315module_param(myri10ge_fill_thresh, int, S_IRUGO | S_IWUSR);
300MODULE_PARM_DESC(myri10ge_fill_thresh, "Number of empty rx slots allowed\n"); 316MODULE_PARM_DESC(myri10ge_fill_thresh, "Number of empty rx slots allowed");
301 317
302static int myri10ge_reset_recover = 1; 318static int myri10ge_reset_recover = 1;
303 319
304static int myri10ge_wcfifo = 0; 320static int myri10ge_wcfifo = 0;
305module_param(myri10ge_wcfifo, int, S_IRUGO); 321module_param(myri10ge_wcfifo, int, S_IRUGO);
306MODULE_PARM_DESC(myri10ge_wcfifo, "Enable WC Fifo when WC is enabled\n"); 322MODULE_PARM_DESC(myri10ge_wcfifo, "Enable WC Fifo when WC is enabled");
307 323
308#define MYRI10GE_FW_OFFSET 1024*1024 324#define MYRI10GE_FW_OFFSET 1024*1024
309#define MYRI10GE_HIGHPART_TO_U32(X) \ 325#define MYRI10GE_HIGHPART_TO_U32(X) \
@@ -359,8 +375,10 @@ myri10ge_send_cmd(struct myri10ge_priv *mgp, u32 cmd,
359 for (sleep_total = 0; 375 for (sleep_total = 0;
360 sleep_total < 1000 376 sleep_total < 1000
361 && response->result == htonl(MYRI10GE_NO_RESPONSE_RESULT); 377 && response->result == htonl(MYRI10GE_NO_RESPONSE_RESULT);
362 sleep_total += 10) 378 sleep_total += 10) {
363 udelay(10); 379 udelay(10);
380 mb();
381 }
364 } else { 382 } else {
365 /* use msleep for most command */ 383 /* use msleep for most command */
366 for (sleep_total = 0; 384 for (sleep_total = 0;
@@ -420,6 +438,10 @@ static int myri10ge_read_mac_addr(struct myri10ge_priv *mgp)
420 ptr += 1; 438 ptr += 1;
421 } 439 }
422 } 440 }
441 if (memcmp(ptr, "PC=", 3) == 0) {
442 ptr += 3;
443 mgp->product_code_string = ptr;
444 }
423 if (memcmp((const void *)ptr, "SN=", 3) == 0) { 445 if (memcmp((const void *)ptr, "SN=", 3) == 0) {
424 ptr += 3; 446 ptr += 3;
425 mgp->serial_number = simple_strtoul(ptr, &ptr, 10); 447 mgp->serial_number = simple_strtoul(ptr, &ptr, 10);
@@ -442,7 +464,7 @@ abort:
442static void myri10ge_dummy_rdma(struct myri10ge_priv *mgp, int enable) 464static void myri10ge_dummy_rdma(struct myri10ge_priv *mgp, int enable)
443{ 465{
444 char __iomem *submit; 466 char __iomem *submit;
445 __be32 buf[16]; 467 __be32 buf[16] __attribute__ ((__aligned__(8)));
446 u32 dma_low, dma_high; 468 u32 dma_low, dma_high;
447 int i; 469 int i;
448 470
@@ -609,13 +631,38 @@ static int myri10ge_adopt_running_firmware(struct myri10ge_priv *mgp)
609 return status; 631 return status;
610} 632}
611 633
634int myri10ge_get_firmware_capabilities(struct myri10ge_priv *mgp)
635{
636 struct myri10ge_cmd cmd;
637 int status;
638
639 /* probe for IPv6 TSO support */
640 mgp->features = NETIF_F_SG | NETIF_F_HW_CSUM | NETIF_F_TSO;
641 status = myri10ge_send_cmd(mgp, MXGEFW_CMD_GET_MAX_TSO6_HDR_SIZE,
642 &cmd, 0);
643 if (status == 0) {
644 mgp->max_tso6 = cmd.data0;
645 mgp->features |= NETIF_F_TSO6;
646 }
647
648 status = myri10ge_send_cmd(mgp, MXGEFW_CMD_GET_RX_RING_SIZE, &cmd, 0);
649 if (status != 0) {
650 dev_err(&mgp->pdev->dev,
651 "failed MXGEFW_CMD_GET_RX_RING_SIZE\n");
652 return -ENXIO;
653 }
654
655 mgp->max_intr_slots = 2 * (cmd.data0 / sizeof(struct mcp_dma_addr));
656
657 return 0;
658}
659
612static int myri10ge_load_firmware(struct myri10ge_priv *mgp) 660static int myri10ge_load_firmware(struct myri10ge_priv *mgp)
613{ 661{
614 char __iomem *submit; 662 char __iomem *submit;
615 __be32 buf[16]; 663 __be32 buf[16] __attribute__ ((__aligned__(8)));
616 u32 dma_low, dma_high, size; 664 u32 dma_low, dma_high, size;
617 int status, i; 665 int status, i;
618 struct myri10ge_cmd cmd;
619 666
620 size = 0; 667 size = 0;
621 status = myri10ge_load_hotplug_firmware(mgp, &size); 668 status = myri10ge_load_hotplug_firmware(mgp, &size);
@@ -635,7 +682,7 @@ static int myri10ge_load_firmware(struct myri10ge_priv *mgp)
635 } 682 }
636 dev_info(&mgp->pdev->dev, 683 dev_info(&mgp->pdev->dev,
637 "Successfully adopted running firmware\n"); 684 "Successfully adopted running firmware\n");
638 if (mgp->tx.boundary == 4096) { 685 if (mgp->tx_boundary == 4096) {
639 dev_warn(&mgp->pdev->dev, 686 dev_warn(&mgp->pdev->dev,
640 "Using firmware currently running on NIC" 687 "Using firmware currently running on NIC"
641 ". For optimal\n"); 688 ". For optimal\n");
@@ -646,7 +693,9 @@ static int myri10ge_load_firmware(struct myri10ge_priv *mgp)
646 } 693 }
647 694
648 mgp->fw_name = "adopted"; 695 mgp->fw_name = "adopted";
649 mgp->tx.boundary = 2048; 696 mgp->tx_boundary = 2048;
697 myri10ge_dummy_rdma(mgp, 1);
698 status = myri10ge_get_firmware_capabilities(mgp);
650 return status; 699 return status;
651 } 700 }
652 701
@@ -681,26 +730,18 @@ static int myri10ge_load_firmware(struct myri10ge_priv *mgp)
681 msleep(1); 730 msleep(1);
682 mb(); 731 mb();
683 i = 0; 732 i = 0;
684 while (mgp->cmd->data != MYRI10GE_NO_CONFIRM_DATA && i < 20) { 733 while (mgp->cmd->data != MYRI10GE_NO_CONFIRM_DATA && i < 9) {
685 msleep(1); 734 msleep(1 << i);
686 i++; 735 i++;
687 } 736 }
688 if (mgp->cmd->data != MYRI10GE_NO_CONFIRM_DATA) { 737 if (mgp->cmd->data != MYRI10GE_NO_CONFIRM_DATA) {
689 dev_err(&mgp->pdev->dev, "handoff failed\n"); 738 dev_err(&mgp->pdev->dev, "handoff failed\n");
690 return -ENXIO; 739 return -ENXIO;
691 } 740 }
692 dev_info(&mgp->pdev->dev, "handoff confirmed\n");
693 myri10ge_dummy_rdma(mgp, 1); 741 myri10ge_dummy_rdma(mgp, 1);
742 status = myri10ge_get_firmware_capabilities(mgp);
694 743
695 /* probe for IPv6 TSO support */ 744 return status;
696 mgp->features = NETIF_F_SG | NETIF_F_HW_CSUM | NETIF_F_TSO;
697 status = myri10ge_send_cmd(mgp, MXGEFW_CMD_GET_MAX_TSO6_HDR_SIZE,
698 &cmd, 0);
699 if (status == 0) {
700 mgp->max_tso6 = cmd.data0;
701 mgp->features |= NETIF_F_TSO6;
702 }
703 return 0;
704} 745}
705 746
706static int myri10ge_update_mac_address(struct myri10ge_priv *mgp, u8 * addr) 747static int myri10ge_update_mac_address(struct myri10ge_priv *mgp, u8 * addr)
@@ -772,7 +813,7 @@ static int myri10ge_dma_test(struct myri10ge_priv *mgp, int test_type)
772 * transfers took to complete. 813 * transfers took to complete.
773 */ 814 */
774 815
775 len = mgp->tx.boundary; 816 len = mgp->tx_boundary;
776 817
777 cmd.data0 = MYRI10GE_LOWPART_TO_U32(dmatest_bus); 818 cmd.data0 = MYRI10GE_LOWPART_TO_U32(dmatest_bus);
778 cmd.data1 = MYRI10GE_HIGHPART_TO_U32(dmatest_bus); 819 cmd.data1 = MYRI10GE_HIGHPART_TO_U32(dmatest_bus);
@@ -834,17 +875,17 @@ static int myri10ge_reset(struct myri10ge_priv *mgp)
834 875
835 /* Now exchange information about interrupts */ 876 /* Now exchange information about interrupts */
836 877
837 bytes = myri10ge_max_intr_slots * sizeof(*mgp->rx_done.entry); 878 bytes = mgp->max_intr_slots * sizeof(*mgp->ss.rx_done.entry);
838 memset(mgp->rx_done.entry, 0, bytes); 879 memset(mgp->ss.rx_done.entry, 0, bytes);
839 cmd.data0 = (u32) bytes; 880 cmd.data0 = (u32) bytes;
840 status = myri10ge_send_cmd(mgp, MXGEFW_CMD_SET_INTRQ_SIZE, &cmd, 0); 881 status = myri10ge_send_cmd(mgp, MXGEFW_CMD_SET_INTRQ_SIZE, &cmd, 0);
841 cmd.data0 = MYRI10GE_LOWPART_TO_U32(mgp->rx_done.bus); 882 cmd.data0 = MYRI10GE_LOWPART_TO_U32(mgp->ss.rx_done.bus);
842 cmd.data1 = MYRI10GE_HIGHPART_TO_U32(mgp->rx_done.bus); 883 cmd.data1 = MYRI10GE_HIGHPART_TO_U32(mgp->ss.rx_done.bus);
843 status |= myri10ge_send_cmd(mgp, MXGEFW_CMD_SET_INTRQ_DMA, &cmd, 0); 884 status |= myri10ge_send_cmd(mgp, MXGEFW_CMD_SET_INTRQ_DMA, &cmd, 0);
844 885
845 status |= 886 status |=
846 myri10ge_send_cmd(mgp, MXGEFW_CMD_GET_IRQ_ACK_OFFSET, &cmd, 0); 887 myri10ge_send_cmd(mgp, MXGEFW_CMD_GET_IRQ_ACK_OFFSET, &cmd, 0);
847 mgp->irq_claim = (__iomem __be32 *) (mgp->sram + cmd.data0); 888 mgp->ss.irq_claim = (__iomem __be32 *) (mgp->sram + cmd.data0);
848 status |= myri10ge_send_cmd(mgp, MXGEFW_CMD_GET_IRQ_DEASSERT_OFFSET, 889 status |= myri10ge_send_cmd(mgp, MXGEFW_CMD_GET_IRQ_DEASSERT_OFFSET,
849 &cmd, 0); 890 &cmd, 0);
850 mgp->irq_deassert = (__iomem __be32 *) (mgp->sram + cmd.data0); 891 mgp->irq_deassert = (__iomem __be32 *) (mgp->sram + cmd.data0);
@@ -858,17 +899,17 @@ static int myri10ge_reset(struct myri10ge_priv *mgp)
858 } 899 }
859 put_be32(htonl(mgp->intr_coal_delay), mgp->intr_coal_delay_ptr); 900 put_be32(htonl(mgp->intr_coal_delay), mgp->intr_coal_delay_ptr);
860 901
861 memset(mgp->rx_done.entry, 0, bytes); 902 memset(mgp->ss.rx_done.entry, 0, bytes);
862 903
863 /* reset mcp/driver shared state back to 0 */ 904 /* reset mcp/driver shared state back to 0 */
864 mgp->tx.req = 0; 905 mgp->ss.tx.req = 0;
865 mgp->tx.done = 0; 906 mgp->ss.tx.done = 0;
866 mgp->tx.pkt_start = 0; 907 mgp->ss.tx.pkt_start = 0;
867 mgp->tx.pkt_done = 0; 908 mgp->ss.tx.pkt_done = 0;
868 mgp->rx_big.cnt = 0; 909 mgp->ss.rx_big.cnt = 0;
869 mgp->rx_small.cnt = 0; 910 mgp->ss.rx_small.cnt = 0;
870 mgp->rx_done.idx = 0; 911 mgp->ss.rx_done.idx = 0;
871 mgp->rx_done.cnt = 0; 912 mgp->ss.rx_done.cnt = 0;
872 mgp->link_changes = 0; 913 mgp->link_changes = 0;
873 status = myri10ge_update_mac_address(mgp, mgp->dev->dev_addr); 914 status = myri10ge_update_mac_address(mgp, mgp->dev->dev_addr);
874 myri10ge_change_pause(mgp, mgp->pause); 915 myri10ge_change_pause(mgp, mgp->pause);
@@ -1020,9 +1061,10 @@ myri10ge_unmap_rx_page(struct pci_dev *pdev,
1020 * page into an skb */ 1061 * page into an skb */
1021 1062
1022static inline int 1063static inline int
1023myri10ge_rx_done(struct myri10ge_priv *mgp, struct myri10ge_rx_buf *rx, 1064myri10ge_rx_done(struct myri10ge_slice_state *ss, struct myri10ge_rx_buf *rx,
1024 int bytes, int len, __wsum csum) 1065 int bytes, int len, __wsum csum)
1025{ 1066{
1067 struct myri10ge_priv *mgp = ss->mgp;
1026 struct sk_buff *skb; 1068 struct sk_buff *skb;
1027 struct skb_frag_struct rx_frags[MYRI10GE_MAX_FRAGS_PER_FRAME]; 1069 struct skb_frag_struct rx_frags[MYRI10GE_MAX_FRAGS_PER_FRAME];
1028 int i, idx, hlen, remainder; 1070 int i, idx, hlen, remainder;
@@ -1052,11 +1094,10 @@ myri10ge_rx_done(struct myri10ge_priv *mgp, struct myri10ge_rx_buf *rx,
1052 rx_frags[0].page_offset += MXGEFW_PAD; 1094 rx_frags[0].page_offset += MXGEFW_PAD;
1053 rx_frags[0].size -= MXGEFW_PAD; 1095 rx_frags[0].size -= MXGEFW_PAD;
1054 len -= MXGEFW_PAD; 1096 len -= MXGEFW_PAD;
1055 lro_receive_frags(&mgp->rx_done.lro_mgr, rx_frags, 1097 lro_receive_frags(&ss->rx_done.lro_mgr, rx_frags,
1056 len, len, 1098 len, len,
1057 /* opaque, will come back in get_frag_header */ 1099 /* opaque, will come back in get_frag_header */
1058 (void *)(__force unsigned long)csum, 1100 (void *)(__force unsigned long)csum, csum);
1059 csum);
1060 return 1; 1101 return 1;
1061 } 1102 }
1062 1103
@@ -1096,10 +1137,11 @@ myri10ge_rx_done(struct myri10ge_priv *mgp, struct myri10ge_rx_buf *rx,
1096 return 1; 1137 return 1;
1097} 1138}
1098 1139
1099static inline void myri10ge_tx_done(struct myri10ge_priv *mgp, int mcp_index) 1140static inline void
1141myri10ge_tx_done(struct myri10ge_slice_state *ss, int mcp_index)
1100{ 1142{
1101 struct pci_dev *pdev = mgp->pdev; 1143 struct pci_dev *pdev = ss->mgp->pdev;
1102 struct myri10ge_tx_buf *tx = &mgp->tx; 1144 struct myri10ge_tx_buf *tx = &ss->tx;
1103 struct sk_buff *skb; 1145 struct sk_buff *skb;
1104 int idx, len; 1146 int idx, len;
1105 1147
@@ -1117,8 +1159,8 @@ static inline void myri10ge_tx_done(struct myri10ge_priv *mgp, int mcp_index)
1117 len = pci_unmap_len(&tx->info[idx], len); 1159 len = pci_unmap_len(&tx->info[idx], len);
1118 pci_unmap_len_set(&tx->info[idx], len, 0); 1160 pci_unmap_len_set(&tx->info[idx], len, 0);
1119 if (skb) { 1161 if (skb) {
1120 mgp->stats.tx_bytes += skb->len; 1162 ss->stats.tx_bytes += skb->len;
1121 mgp->stats.tx_packets++; 1163 ss->stats.tx_packets++;
1122 dev_kfree_skb_irq(skb); 1164 dev_kfree_skb_irq(skb);
1123 if (len) 1165 if (len)
1124 pci_unmap_single(pdev, 1166 pci_unmap_single(pdev,
@@ -1134,16 +1176,18 @@ static inline void myri10ge_tx_done(struct myri10ge_priv *mgp, int mcp_index)
1134 } 1176 }
1135 } 1177 }
1136 /* start the queue if we've stopped it */ 1178 /* start the queue if we've stopped it */
1137 if (netif_queue_stopped(mgp->dev) 1179 if (netif_queue_stopped(ss->dev)
1138 && tx->req - tx->done < (tx->mask >> 1)) { 1180 && tx->req - tx->done < (tx->mask >> 1)) {
1139 mgp->wake_queue++; 1181 tx->wake_queue++;
1140 netif_wake_queue(mgp->dev); 1182 netif_wake_queue(ss->dev);
1141 } 1183 }
1142} 1184}
1143 1185
1144static inline int myri10ge_clean_rx_done(struct myri10ge_priv *mgp, int budget) 1186static inline int
1187myri10ge_clean_rx_done(struct myri10ge_slice_state *ss, int budget)
1145{ 1188{
1146 struct myri10ge_rx_done *rx_done = &mgp->rx_done; 1189 struct myri10ge_rx_done *rx_done = &ss->rx_done;
1190 struct myri10ge_priv *mgp = ss->mgp;
1147 unsigned long rx_bytes = 0; 1191 unsigned long rx_bytes = 0;
1148 unsigned long rx_packets = 0; 1192 unsigned long rx_packets = 0;
1149 unsigned long rx_ok; 1193 unsigned long rx_ok;
@@ -1159,40 +1203,40 @@ static inline int myri10ge_clean_rx_done(struct myri10ge_priv *mgp, int budget)
1159 rx_done->entry[idx].length = 0; 1203 rx_done->entry[idx].length = 0;
1160 checksum = csum_unfold(rx_done->entry[idx].checksum); 1204 checksum = csum_unfold(rx_done->entry[idx].checksum);
1161 if (length <= mgp->small_bytes) 1205 if (length <= mgp->small_bytes)
1162 rx_ok = myri10ge_rx_done(mgp, &mgp->rx_small, 1206 rx_ok = myri10ge_rx_done(ss, &ss->rx_small,
1163 mgp->small_bytes, 1207 mgp->small_bytes,
1164 length, checksum); 1208 length, checksum);
1165 else 1209 else
1166 rx_ok = myri10ge_rx_done(mgp, &mgp->rx_big, 1210 rx_ok = myri10ge_rx_done(ss, &ss->rx_big,
1167 mgp->big_bytes, 1211 mgp->big_bytes,
1168 length, checksum); 1212 length, checksum);
1169 rx_packets += rx_ok; 1213 rx_packets += rx_ok;
1170 rx_bytes += rx_ok * (unsigned long)length; 1214 rx_bytes += rx_ok * (unsigned long)length;
1171 cnt++; 1215 cnt++;
1172 idx = cnt & (myri10ge_max_intr_slots - 1); 1216 idx = cnt & (mgp->max_intr_slots - 1);
1173 work_done++; 1217 work_done++;
1174 } 1218 }
1175 rx_done->idx = idx; 1219 rx_done->idx = idx;
1176 rx_done->cnt = cnt; 1220 rx_done->cnt = cnt;
1177 mgp->stats.rx_packets += rx_packets; 1221 ss->stats.rx_packets += rx_packets;
1178 mgp->stats.rx_bytes += rx_bytes; 1222 ss->stats.rx_bytes += rx_bytes;
1179 1223
1180 if (myri10ge_lro) 1224 if (myri10ge_lro)
1181 lro_flush_all(&rx_done->lro_mgr); 1225 lro_flush_all(&rx_done->lro_mgr);
1182 1226
1183 /* restock receive rings if needed */ 1227 /* restock receive rings if needed */
1184 if (mgp->rx_small.fill_cnt - mgp->rx_small.cnt < myri10ge_fill_thresh) 1228 if (ss->rx_small.fill_cnt - ss->rx_small.cnt < myri10ge_fill_thresh)
1185 myri10ge_alloc_rx_pages(mgp, &mgp->rx_small, 1229 myri10ge_alloc_rx_pages(mgp, &ss->rx_small,
1186 mgp->small_bytes + MXGEFW_PAD, 0); 1230 mgp->small_bytes + MXGEFW_PAD, 0);
1187 if (mgp->rx_big.fill_cnt - mgp->rx_big.cnt < myri10ge_fill_thresh) 1231 if (ss->rx_big.fill_cnt - ss->rx_big.cnt < myri10ge_fill_thresh)
1188 myri10ge_alloc_rx_pages(mgp, &mgp->rx_big, mgp->big_bytes, 0); 1232 myri10ge_alloc_rx_pages(mgp, &ss->rx_big, mgp->big_bytes, 0);
1189 1233
1190 return work_done; 1234 return work_done;
1191} 1235}
1192 1236
1193static inline void myri10ge_check_statblock(struct myri10ge_priv *mgp) 1237static inline void myri10ge_check_statblock(struct myri10ge_priv *mgp)
1194{ 1238{
1195 struct mcp_irq_data *stats = mgp->fw_stats; 1239 struct mcp_irq_data *stats = mgp->ss.fw_stats;
1196 1240
1197 if (unlikely(stats->stats_updated)) { 1241 if (unlikely(stats->stats_updated)) {
1198 unsigned link_up = ntohl(stats->link_up); 1242 unsigned link_up = ntohl(stats->link_up);
@@ -1219,9 +1263,9 @@ static inline void myri10ge_check_statblock(struct myri10ge_priv *mgp)
1219 } 1263 }
1220 } 1264 }
1221 if (mgp->rdma_tags_available != 1265 if (mgp->rdma_tags_available !=
1222 ntohl(mgp->fw_stats->rdma_tags_available)) { 1266 ntohl(stats->rdma_tags_available)) {
1223 mgp->rdma_tags_available = 1267 mgp->rdma_tags_available =
1224 ntohl(mgp->fw_stats->rdma_tags_available); 1268 ntohl(stats->rdma_tags_available);
1225 printk(KERN_WARNING "myri10ge: %s: RDMA timed out! " 1269 printk(KERN_WARNING "myri10ge: %s: RDMA timed out! "
1226 "%d tags left\n", mgp->dev->name, 1270 "%d tags left\n", mgp->dev->name,
1227 mgp->rdma_tags_available); 1271 mgp->rdma_tags_available);
@@ -1234,26 +1278,27 @@ static inline void myri10ge_check_statblock(struct myri10ge_priv *mgp)
1234 1278
1235static int myri10ge_poll(struct napi_struct *napi, int budget) 1279static int myri10ge_poll(struct napi_struct *napi, int budget)
1236{ 1280{
1237 struct myri10ge_priv *mgp = 1281 struct myri10ge_slice_state *ss =
1238 container_of(napi, struct myri10ge_priv, napi); 1282 container_of(napi, struct myri10ge_slice_state, napi);
1239 struct net_device *netdev = mgp->dev; 1283 struct net_device *netdev = ss->mgp->dev;
1240 int work_done; 1284 int work_done;
1241 1285
1242 /* process as many rx events as NAPI will allow */ 1286 /* process as many rx events as NAPI will allow */
1243 work_done = myri10ge_clean_rx_done(mgp, budget); 1287 work_done = myri10ge_clean_rx_done(ss, budget);
1244 1288
1245 if (work_done < budget) { 1289 if (work_done < budget) {
1246 netif_rx_complete(netdev, napi); 1290 netif_rx_complete(netdev, napi);
1247 put_be32(htonl(3), mgp->irq_claim); 1291 put_be32(htonl(3), ss->irq_claim);
1248 } 1292 }
1249 return work_done; 1293 return work_done;
1250} 1294}
1251 1295
1252static irqreturn_t myri10ge_intr(int irq, void *arg) 1296static irqreturn_t myri10ge_intr(int irq, void *arg)
1253{ 1297{
1254 struct myri10ge_priv *mgp = arg; 1298 struct myri10ge_slice_state *ss = arg;
1255 struct mcp_irq_data *stats = mgp->fw_stats; 1299 struct myri10ge_priv *mgp = ss->mgp;
1256 struct myri10ge_tx_buf *tx = &mgp->tx; 1300 struct mcp_irq_data *stats = ss->fw_stats;
1301 struct myri10ge_tx_buf *tx = &ss->tx;
1257 u32 send_done_count; 1302 u32 send_done_count;
1258 int i; 1303 int i;
1259 1304
@@ -1264,7 +1309,7 @@ static irqreturn_t myri10ge_intr(int irq, void *arg)
1264 /* low bit indicates receives are present, so schedule 1309 /* low bit indicates receives are present, so schedule
1265 * napi poll handler */ 1310 * napi poll handler */
1266 if (stats->valid & 1) 1311 if (stats->valid & 1)
1267 netif_rx_schedule(mgp->dev, &mgp->napi); 1312 netif_rx_schedule(ss->dev, &ss->napi);
1268 1313
1269 if (!mgp->msi_enabled) { 1314 if (!mgp->msi_enabled) {
1270 put_be32(0, mgp->irq_deassert); 1315 put_be32(0, mgp->irq_deassert);
@@ -1281,7 +1326,7 @@ static irqreturn_t myri10ge_intr(int irq, void *arg)
1281 /* check for transmit completes and receives */ 1326 /* check for transmit completes and receives */
1282 send_done_count = ntohl(stats->send_done_count); 1327 send_done_count = ntohl(stats->send_done_count);
1283 if (send_done_count != tx->pkt_done) 1328 if (send_done_count != tx->pkt_done)
1284 myri10ge_tx_done(mgp, (int)send_done_count); 1329 myri10ge_tx_done(ss, (int)send_done_count);
1285 if (unlikely(i > myri10ge_max_irq_loops)) { 1330 if (unlikely(i > myri10ge_max_irq_loops)) {
1286 printk(KERN_WARNING "myri10ge: %s: irq stuck?\n", 1331 printk(KERN_WARNING "myri10ge: %s: irq stuck?\n",
1287 mgp->dev->name); 1332 mgp->dev->name);
@@ -1296,16 +1341,46 @@ static irqreturn_t myri10ge_intr(int irq, void *arg)
1296 1341
1297 myri10ge_check_statblock(mgp); 1342 myri10ge_check_statblock(mgp);
1298 1343
1299 put_be32(htonl(3), mgp->irq_claim + 1); 1344 put_be32(htonl(3), ss->irq_claim + 1);
1300 return (IRQ_HANDLED); 1345 return (IRQ_HANDLED);
1301} 1346}
1302 1347
1303static int 1348static int
1304myri10ge_get_settings(struct net_device *netdev, struct ethtool_cmd *cmd) 1349myri10ge_get_settings(struct net_device *netdev, struct ethtool_cmd *cmd)
1305{ 1350{
1351 struct myri10ge_priv *mgp = netdev_priv(netdev);
1352 char *ptr;
1353 int i;
1354
1306 cmd->autoneg = AUTONEG_DISABLE; 1355 cmd->autoneg = AUTONEG_DISABLE;
1307 cmd->speed = SPEED_10000; 1356 cmd->speed = SPEED_10000;
1308 cmd->duplex = DUPLEX_FULL; 1357 cmd->duplex = DUPLEX_FULL;
1358
1359 /*
1360 * parse the product code to deterimine the interface type
1361 * (CX4, XFP, Quad Ribbon Fiber) by looking at the character
1362 * after the 3rd dash in the driver's cached copy of the
1363 * EEPROM's product code string.
1364 */
1365 ptr = mgp->product_code_string;
1366 if (ptr == NULL) {
1367 printk(KERN_ERR "myri10ge: %s: Missing product code\n",
1368 netdev->name);
1369 return 0;
1370 }
1371 for (i = 0; i < 3; i++, ptr++) {
1372 ptr = strchr(ptr, '-');
1373 if (ptr == NULL) {
1374 printk(KERN_ERR "myri10ge: %s: Invalid product "
1375 "code %s\n", netdev->name,
1376 mgp->product_code_string);
1377 return 0;
1378 }
1379 }
1380 if (*ptr == 'R' || *ptr == 'Q') {
1381 /* We've found either an XFP or quad ribbon fiber */
1382 cmd->port = PORT_FIBRE;
1383 }
1309 return 0; 1384 return 0;
1310} 1385}
1311 1386
@@ -1324,6 +1399,7 @@ static int
1324myri10ge_get_coalesce(struct net_device *netdev, struct ethtool_coalesce *coal) 1399myri10ge_get_coalesce(struct net_device *netdev, struct ethtool_coalesce *coal)
1325{ 1400{
1326 struct myri10ge_priv *mgp = netdev_priv(netdev); 1401 struct myri10ge_priv *mgp = netdev_priv(netdev);
1402
1327 coal->rx_coalesce_usecs = mgp->intr_coal_delay; 1403 coal->rx_coalesce_usecs = mgp->intr_coal_delay;
1328 return 0; 1404 return 0;
1329} 1405}
@@ -1370,10 +1446,10 @@ myri10ge_get_ringparam(struct net_device *netdev,
1370{ 1446{
1371 struct myri10ge_priv *mgp = netdev_priv(netdev); 1447 struct myri10ge_priv *mgp = netdev_priv(netdev);
1372 1448
1373 ring->rx_mini_max_pending = mgp->rx_small.mask + 1; 1449 ring->rx_mini_max_pending = mgp->ss.rx_small.mask + 1;
1374 ring->rx_max_pending = mgp->rx_big.mask + 1; 1450 ring->rx_max_pending = mgp->ss.rx_big.mask + 1;
1375 ring->rx_jumbo_max_pending = 0; 1451 ring->rx_jumbo_max_pending = 0;
1376 ring->tx_max_pending = mgp->rx_small.mask + 1; 1452 ring->tx_max_pending = mgp->ss.rx_small.mask + 1;
1377 ring->rx_mini_pending = ring->rx_mini_max_pending; 1453 ring->rx_mini_pending = ring->rx_mini_max_pending;
1378 ring->rx_pending = ring->rx_max_pending; 1454 ring->rx_pending = ring->rx_max_pending;
1379 ring->rx_jumbo_pending = ring->rx_jumbo_max_pending; 1455 ring->rx_jumbo_pending = ring->rx_jumbo_max_pending;
@@ -1383,6 +1459,7 @@ myri10ge_get_ringparam(struct net_device *netdev,
1383static u32 myri10ge_get_rx_csum(struct net_device *netdev) 1459static u32 myri10ge_get_rx_csum(struct net_device *netdev)
1384{ 1460{
1385 struct myri10ge_priv *mgp = netdev_priv(netdev); 1461 struct myri10ge_priv *mgp = netdev_priv(netdev);
1462
1386 if (mgp->csum_flag) 1463 if (mgp->csum_flag)
1387 return 1; 1464 return 1;
1388 else 1465 else
@@ -1392,6 +1469,7 @@ static u32 myri10ge_get_rx_csum(struct net_device *netdev)
1392static int myri10ge_set_rx_csum(struct net_device *netdev, u32 csum_enabled) 1469static int myri10ge_set_rx_csum(struct net_device *netdev, u32 csum_enabled)
1393{ 1470{
1394 struct myri10ge_priv *mgp = netdev_priv(netdev); 1471 struct myri10ge_priv *mgp = netdev_priv(netdev);
1472
1395 if (csum_enabled) 1473 if (csum_enabled)
1396 mgp->csum_flag = MXGEFW_FLAGS_CKSUM; 1474 mgp->csum_flag = MXGEFW_FLAGS_CKSUM;
1397 else 1475 else
@@ -1411,7 +1489,7 @@ static int myri10ge_set_tso(struct net_device *netdev, u32 tso_enabled)
1411 return 0; 1489 return 0;
1412} 1490}
1413 1491
1414static const char myri10ge_gstrings_stats[][ETH_GSTRING_LEN] = { 1492static const char myri10ge_gstrings_main_stats[][ETH_GSTRING_LEN] = {
1415 "rx_packets", "tx_packets", "rx_bytes", "tx_bytes", "rx_errors", 1493 "rx_packets", "tx_packets", "rx_bytes", "tx_bytes", "rx_errors",
1416 "tx_errors", "rx_dropped", "tx_dropped", "multicast", "collisions", 1494 "tx_errors", "rx_dropped", "tx_dropped", "multicast", "collisions",
1417 "rx_length_errors", "rx_over_errors", "rx_crc_errors", 1495 "rx_length_errors", "rx_over_errors", "rx_crc_errors",
@@ -1421,28 +1499,39 @@ static const char myri10ge_gstrings_stats[][ETH_GSTRING_LEN] = {
1421 /* device-specific stats */ 1499 /* device-specific stats */
1422 "tx_boundary", "WC", "irq", "MSI", 1500 "tx_boundary", "WC", "irq", "MSI",
1423 "read_dma_bw_MBs", "write_dma_bw_MBs", "read_write_dma_bw_MBs", 1501 "read_dma_bw_MBs", "write_dma_bw_MBs", "read_write_dma_bw_MBs",
1424 "serial_number", "tx_pkt_start", "tx_pkt_done", 1502 "serial_number", "watchdog_resets",
1425 "tx_req", "tx_done", "rx_small_cnt", "rx_big_cnt",
1426 "wake_queue", "stop_queue", "watchdog_resets", "tx_linearized",
1427 "link_changes", "link_up", "dropped_link_overflow", 1503 "link_changes", "link_up", "dropped_link_overflow",
1428 "dropped_link_error_or_filtered", 1504 "dropped_link_error_or_filtered",
1429 "dropped_pause", "dropped_bad_phy", "dropped_bad_crc32", 1505 "dropped_pause", "dropped_bad_phy", "dropped_bad_crc32",
1430 "dropped_unicast_filtered", "dropped_multicast_filtered", 1506 "dropped_unicast_filtered", "dropped_multicast_filtered",
1431 "dropped_runt", "dropped_overrun", "dropped_no_small_buffer", 1507 "dropped_runt", "dropped_overrun", "dropped_no_small_buffer",
1432 "dropped_no_big_buffer", "LRO aggregated", "LRO flushed", 1508 "dropped_no_big_buffer"
1509};
1510
1511static const char myri10ge_gstrings_slice_stats[][ETH_GSTRING_LEN] = {
1512 "----------- slice ---------",
1513 "tx_pkt_start", "tx_pkt_done", "tx_req", "tx_done",
1514 "rx_small_cnt", "rx_big_cnt",
1515 "wake_queue", "stop_queue", "tx_linearized", "LRO aggregated",
1516 "LRO flushed",
1433 "LRO avg aggr", "LRO no_desc" 1517 "LRO avg aggr", "LRO no_desc"
1434}; 1518};
1435 1519
1436#define MYRI10GE_NET_STATS_LEN 21 1520#define MYRI10GE_NET_STATS_LEN 21
1437#define MYRI10GE_STATS_LEN ARRAY_SIZE(myri10ge_gstrings_stats) 1521#define MYRI10GE_MAIN_STATS_LEN ARRAY_SIZE(myri10ge_gstrings_main_stats)
1522#define MYRI10GE_SLICE_STATS_LEN ARRAY_SIZE(myri10ge_gstrings_slice_stats)
1438 1523
1439static void 1524static void
1440myri10ge_get_strings(struct net_device *netdev, u32 stringset, u8 * data) 1525myri10ge_get_strings(struct net_device *netdev, u32 stringset, u8 * data)
1441{ 1526{
1442 switch (stringset) { 1527 switch (stringset) {
1443 case ETH_SS_STATS: 1528 case ETH_SS_STATS:
1444 memcpy(data, *myri10ge_gstrings_stats, 1529 memcpy(data, *myri10ge_gstrings_main_stats,
1445 sizeof(myri10ge_gstrings_stats)); 1530 sizeof(myri10ge_gstrings_main_stats));
1531 data += sizeof(myri10ge_gstrings_main_stats);
1532 memcpy(data, *myri10ge_gstrings_slice_stats,
1533 sizeof(myri10ge_gstrings_slice_stats));
1534 data += sizeof(myri10ge_gstrings_slice_stats);
1446 break; 1535 break;
1447 } 1536 }
1448} 1537}
@@ -1451,7 +1540,7 @@ static int myri10ge_get_sset_count(struct net_device *netdev, int sset)
1451{ 1540{
1452 switch (sset) { 1541 switch (sset) {
1453 case ETH_SS_STATS: 1542 case ETH_SS_STATS:
1454 return MYRI10GE_STATS_LEN; 1543 return MYRI10GE_MAIN_STATS_LEN + MYRI10GE_SLICE_STATS_LEN;
1455 default: 1544 default:
1456 return -EOPNOTSUPP; 1545 return -EOPNOTSUPP;
1457 } 1546 }
@@ -1462,12 +1551,13 @@ myri10ge_get_ethtool_stats(struct net_device *netdev,
1462 struct ethtool_stats *stats, u64 * data) 1551 struct ethtool_stats *stats, u64 * data)
1463{ 1552{
1464 struct myri10ge_priv *mgp = netdev_priv(netdev); 1553 struct myri10ge_priv *mgp = netdev_priv(netdev);
1554 struct myri10ge_slice_state *ss;
1465 int i; 1555 int i;
1466 1556
1467 for (i = 0; i < MYRI10GE_NET_STATS_LEN; i++) 1557 for (i = 0; i < MYRI10GE_NET_STATS_LEN; i++)
1468 data[i] = ((unsigned long *)&mgp->stats)[i]; 1558 data[i] = ((unsigned long *)&mgp->stats)[i];
1469 1559
1470 data[i++] = (unsigned int)mgp->tx.boundary; 1560 data[i++] = (unsigned int)mgp->tx_boundary;
1471 data[i++] = (unsigned int)mgp->wc_enabled; 1561 data[i++] = (unsigned int)mgp->wc_enabled;
1472 data[i++] = (unsigned int)mgp->pdev->irq; 1562 data[i++] = (unsigned int)mgp->pdev->irq;
1473 data[i++] = (unsigned int)mgp->msi_enabled; 1563 data[i++] = (unsigned int)mgp->msi_enabled;
@@ -1475,40 +1565,44 @@ myri10ge_get_ethtool_stats(struct net_device *netdev,
1475 data[i++] = (unsigned int)mgp->write_dma; 1565 data[i++] = (unsigned int)mgp->write_dma;
1476 data[i++] = (unsigned int)mgp->read_write_dma; 1566 data[i++] = (unsigned int)mgp->read_write_dma;
1477 data[i++] = (unsigned int)mgp->serial_number; 1567 data[i++] = (unsigned int)mgp->serial_number;
1478 data[i++] = (unsigned int)mgp->tx.pkt_start;
1479 data[i++] = (unsigned int)mgp->tx.pkt_done;
1480 data[i++] = (unsigned int)mgp->tx.req;
1481 data[i++] = (unsigned int)mgp->tx.done;
1482 data[i++] = (unsigned int)mgp->rx_small.cnt;
1483 data[i++] = (unsigned int)mgp->rx_big.cnt;
1484 data[i++] = (unsigned int)mgp->wake_queue;
1485 data[i++] = (unsigned int)mgp->stop_queue;
1486 data[i++] = (unsigned int)mgp->watchdog_resets; 1568 data[i++] = (unsigned int)mgp->watchdog_resets;
1487 data[i++] = (unsigned int)mgp->tx_linearized;
1488 data[i++] = (unsigned int)mgp->link_changes; 1569 data[i++] = (unsigned int)mgp->link_changes;
1489 data[i++] = (unsigned int)ntohl(mgp->fw_stats->link_up); 1570
1490 data[i++] = (unsigned int)ntohl(mgp->fw_stats->dropped_link_overflow); 1571 /* firmware stats are useful only in the first slice */
1491 data[i++] = 1572 ss = &mgp->ss;
1492 (unsigned int)ntohl(mgp->fw_stats->dropped_link_error_or_filtered); 1573 data[i++] = (unsigned int)ntohl(ss->fw_stats->link_up);
1493 data[i++] = (unsigned int)ntohl(mgp->fw_stats->dropped_pause); 1574 data[i++] = (unsigned int)ntohl(ss->fw_stats->dropped_link_overflow);
1494 data[i++] = (unsigned int)ntohl(mgp->fw_stats->dropped_bad_phy);
1495 data[i++] = (unsigned int)ntohl(mgp->fw_stats->dropped_bad_crc32);
1496 data[i++] = 1575 data[i++] =
1497 (unsigned int)ntohl(mgp->fw_stats->dropped_unicast_filtered); 1576 (unsigned int)ntohl(ss->fw_stats->dropped_link_error_or_filtered);
1577 data[i++] = (unsigned int)ntohl(ss->fw_stats->dropped_pause);
1578 data[i++] = (unsigned int)ntohl(ss->fw_stats->dropped_bad_phy);
1579 data[i++] = (unsigned int)ntohl(ss->fw_stats->dropped_bad_crc32);
1580 data[i++] = (unsigned int)ntohl(ss->fw_stats->dropped_unicast_filtered);
1498 data[i++] = 1581 data[i++] =
1499 (unsigned int)ntohl(mgp->fw_stats->dropped_multicast_filtered); 1582 (unsigned int)ntohl(ss->fw_stats->dropped_multicast_filtered);
1500 data[i++] = (unsigned int)ntohl(mgp->fw_stats->dropped_runt); 1583 data[i++] = (unsigned int)ntohl(ss->fw_stats->dropped_runt);
1501 data[i++] = (unsigned int)ntohl(mgp->fw_stats->dropped_overrun); 1584 data[i++] = (unsigned int)ntohl(ss->fw_stats->dropped_overrun);
1502 data[i++] = (unsigned int)ntohl(mgp->fw_stats->dropped_no_small_buffer); 1585 data[i++] = (unsigned int)ntohl(ss->fw_stats->dropped_no_small_buffer);
1503 data[i++] = (unsigned int)ntohl(mgp->fw_stats->dropped_no_big_buffer); 1586 data[i++] = (unsigned int)ntohl(ss->fw_stats->dropped_no_big_buffer);
1504 data[i++] = mgp->rx_done.lro_mgr.stats.aggregated; 1587
1505 data[i++] = mgp->rx_done.lro_mgr.stats.flushed; 1588 data[i++] = 0;
1506 if (mgp->rx_done.lro_mgr.stats.flushed) 1589 data[i++] = (unsigned int)ss->tx.pkt_start;
1507 data[i++] = mgp->rx_done.lro_mgr.stats.aggregated / 1590 data[i++] = (unsigned int)ss->tx.pkt_done;
1508 mgp->rx_done.lro_mgr.stats.flushed; 1591 data[i++] = (unsigned int)ss->tx.req;
1592 data[i++] = (unsigned int)ss->tx.done;
1593 data[i++] = (unsigned int)ss->rx_small.cnt;
1594 data[i++] = (unsigned int)ss->rx_big.cnt;
1595 data[i++] = (unsigned int)ss->tx.wake_queue;
1596 data[i++] = (unsigned int)ss->tx.stop_queue;
1597 data[i++] = (unsigned int)ss->tx.linearized;
1598 data[i++] = ss->rx_done.lro_mgr.stats.aggregated;
1599 data[i++] = ss->rx_done.lro_mgr.stats.flushed;
1600 if (ss->rx_done.lro_mgr.stats.flushed)
1601 data[i++] = ss->rx_done.lro_mgr.stats.aggregated /
1602 ss->rx_done.lro_mgr.stats.flushed;
1509 else 1603 else
1510 data[i++] = 0; 1604 data[i++] = 0;
1511 data[i++] = mgp->rx_done.lro_mgr.stats.no_desc; 1605 data[i++] = ss->rx_done.lro_mgr.stats.no_desc;
1512} 1606}
1513 1607
1514static void myri10ge_set_msglevel(struct net_device *netdev, u32 value) 1608static void myri10ge_set_msglevel(struct net_device *netdev, u32 value)
@@ -1544,19 +1638,17 @@ static const struct ethtool_ops myri10ge_ethtool_ops = {
1544 .get_msglevel = myri10ge_get_msglevel 1638 .get_msglevel = myri10ge_get_msglevel
1545}; 1639};
1546 1640
1547static int myri10ge_allocate_rings(struct net_device *dev) 1641static int myri10ge_allocate_rings(struct myri10ge_slice_state *ss)
1548{ 1642{
1549 struct myri10ge_priv *mgp; 1643 struct myri10ge_priv *mgp = ss->mgp;
1550 struct myri10ge_cmd cmd; 1644 struct myri10ge_cmd cmd;
1645 struct net_device *dev = mgp->dev;
1551 int tx_ring_size, rx_ring_size; 1646 int tx_ring_size, rx_ring_size;
1552 int tx_ring_entries, rx_ring_entries; 1647 int tx_ring_entries, rx_ring_entries;
1553 int i, status; 1648 int i, status;
1554 size_t bytes; 1649 size_t bytes;
1555 1650
1556 mgp = netdev_priv(dev);
1557
1558 /* get ring sizes */ 1651 /* get ring sizes */
1559
1560 status = myri10ge_send_cmd(mgp, MXGEFW_CMD_GET_SEND_RING_SIZE, &cmd, 0); 1652 status = myri10ge_send_cmd(mgp, MXGEFW_CMD_GET_SEND_RING_SIZE, &cmd, 0);
1561 tx_ring_size = cmd.data0; 1653 tx_ring_size = cmd.data0;
1562 status |= myri10ge_send_cmd(mgp, MXGEFW_CMD_GET_RX_RING_SIZE, &cmd, 0); 1654 status |= myri10ge_send_cmd(mgp, MXGEFW_CMD_GET_RX_RING_SIZE, &cmd, 0);
@@ -1566,144 +1658,142 @@ static int myri10ge_allocate_rings(struct net_device *dev)
1566 1658
1567 tx_ring_entries = tx_ring_size / sizeof(struct mcp_kreq_ether_send); 1659 tx_ring_entries = tx_ring_size / sizeof(struct mcp_kreq_ether_send);
1568 rx_ring_entries = rx_ring_size / sizeof(struct mcp_dma_addr); 1660 rx_ring_entries = rx_ring_size / sizeof(struct mcp_dma_addr);
1569 mgp->tx.mask = tx_ring_entries - 1; 1661 ss->tx.mask = tx_ring_entries - 1;
1570 mgp->rx_small.mask = mgp->rx_big.mask = rx_ring_entries - 1; 1662 ss->rx_small.mask = ss->rx_big.mask = rx_ring_entries - 1;
1571 1663
1572 status = -ENOMEM; 1664 status = -ENOMEM;
1573 1665
1574 /* allocate the host shadow rings */ 1666 /* allocate the host shadow rings */
1575 1667
1576 bytes = 8 + (MYRI10GE_MAX_SEND_DESC_TSO + 4) 1668 bytes = 8 + (MYRI10GE_MAX_SEND_DESC_TSO + 4)
1577 * sizeof(*mgp->tx.req_list); 1669 * sizeof(*ss->tx.req_list);
1578 mgp->tx.req_bytes = kzalloc(bytes, GFP_KERNEL); 1670 ss->tx.req_bytes = kzalloc(bytes, GFP_KERNEL);
1579 if (mgp->tx.req_bytes == NULL) 1671 if (ss->tx.req_bytes == NULL)
1580 goto abort_with_nothing; 1672 goto abort_with_nothing;
1581 1673
1582 /* ensure req_list entries are aligned to 8 bytes */ 1674 /* ensure req_list entries are aligned to 8 bytes */
1583 mgp->tx.req_list = (struct mcp_kreq_ether_send *) 1675 ss->tx.req_list = (struct mcp_kreq_ether_send *)
1584 ALIGN((unsigned long)mgp->tx.req_bytes, 8); 1676 ALIGN((unsigned long)ss->tx.req_bytes, 8);
1585 1677
1586 bytes = rx_ring_entries * sizeof(*mgp->rx_small.shadow); 1678 bytes = rx_ring_entries * sizeof(*ss->rx_small.shadow);
1587 mgp->rx_small.shadow = kzalloc(bytes, GFP_KERNEL); 1679 ss->rx_small.shadow = kzalloc(bytes, GFP_KERNEL);
1588 if (mgp->rx_small.shadow == NULL) 1680 if (ss->rx_small.shadow == NULL)
1589 goto abort_with_tx_req_bytes; 1681 goto abort_with_tx_req_bytes;
1590 1682
1591 bytes = rx_ring_entries * sizeof(*mgp->rx_big.shadow); 1683 bytes = rx_ring_entries * sizeof(*ss->rx_big.shadow);
1592 mgp->rx_big.shadow = kzalloc(bytes, GFP_KERNEL); 1684 ss->rx_big.shadow = kzalloc(bytes, GFP_KERNEL);
1593 if (mgp->rx_big.shadow == NULL) 1685 if (ss->rx_big.shadow == NULL)
1594 goto abort_with_rx_small_shadow; 1686 goto abort_with_rx_small_shadow;
1595 1687
1596 /* allocate the host info rings */ 1688 /* allocate the host info rings */
1597 1689
1598 bytes = tx_ring_entries * sizeof(*mgp->tx.info); 1690 bytes = tx_ring_entries * sizeof(*ss->tx.info);
1599 mgp->tx.info = kzalloc(bytes, GFP_KERNEL); 1691 ss->tx.info = kzalloc(bytes, GFP_KERNEL);
1600 if (mgp->tx.info == NULL) 1692 if (ss->tx.info == NULL)
1601 goto abort_with_rx_big_shadow; 1693 goto abort_with_rx_big_shadow;
1602 1694
1603 bytes = rx_ring_entries * sizeof(*mgp->rx_small.info); 1695 bytes = rx_ring_entries * sizeof(*ss->rx_small.info);
1604 mgp->rx_small.info = kzalloc(bytes, GFP_KERNEL); 1696 ss->rx_small.info = kzalloc(bytes, GFP_KERNEL);
1605 if (mgp->rx_small.info == NULL) 1697 if (ss->rx_small.info == NULL)
1606 goto abort_with_tx_info; 1698 goto abort_with_tx_info;
1607 1699
1608 bytes = rx_ring_entries * sizeof(*mgp->rx_big.info); 1700 bytes = rx_ring_entries * sizeof(*ss->rx_big.info);
1609 mgp->rx_big.info = kzalloc(bytes, GFP_KERNEL); 1701 ss->rx_big.info = kzalloc(bytes, GFP_KERNEL);
1610 if (mgp->rx_big.info == NULL) 1702 if (ss->rx_big.info == NULL)
1611 goto abort_with_rx_small_info; 1703 goto abort_with_rx_small_info;
1612 1704
1613 /* Fill the receive rings */ 1705 /* Fill the receive rings */
1614 mgp->rx_big.cnt = 0; 1706 ss->rx_big.cnt = 0;
1615 mgp->rx_small.cnt = 0; 1707 ss->rx_small.cnt = 0;
1616 mgp->rx_big.fill_cnt = 0; 1708 ss->rx_big.fill_cnt = 0;
1617 mgp->rx_small.fill_cnt = 0; 1709 ss->rx_small.fill_cnt = 0;
1618 mgp->rx_small.page_offset = MYRI10GE_ALLOC_SIZE; 1710 ss->rx_small.page_offset = MYRI10GE_ALLOC_SIZE;
1619 mgp->rx_big.page_offset = MYRI10GE_ALLOC_SIZE; 1711 ss->rx_big.page_offset = MYRI10GE_ALLOC_SIZE;
1620 mgp->rx_small.watchdog_needed = 0; 1712 ss->rx_small.watchdog_needed = 0;
1621 mgp->rx_big.watchdog_needed = 0; 1713 ss->rx_big.watchdog_needed = 0;
1622 myri10ge_alloc_rx_pages(mgp, &mgp->rx_small, 1714 myri10ge_alloc_rx_pages(mgp, &ss->rx_small,
1623 mgp->small_bytes + MXGEFW_PAD, 0); 1715 mgp->small_bytes + MXGEFW_PAD, 0);
1624 1716
1625 if (mgp->rx_small.fill_cnt < mgp->rx_small.mask + 1) { 1717 if (ss->rx_small.fill_cnt < ss->rx_small.mask + 1) {
1626 printk(KERN_ERR "myri10ge: %s: alloced only %d small bufs\n", 1718 printk(KERN_ERR "myri10ge: %s: alloced only %d small bufs\n",
1627 dev->name, mgp->rx_small.fill_cnt); 1719 dev->name, ss->rx_small.fill_cnt);
1628 goto abort_with_rx_small_ring; 1720 goto abort_with_rx_small_ring;
1629 } 1721 }
1630 1722
1631 myri10ge_alloc_rx_pages(mgp, &mgp->rx_big, mgp->big_bytes, 0); 1723 myri10ge_alloc_rx_pages(mgp, &ss->rx_big, mgp->big_bytes, 0);
1632 if (mgp->rx_big.fill_cnt < mgp->rx_big.mask + 1) { 1724 if (ss->rx_big.fill_cnt < ss->rx_big.mask + 1) {
1633 printk(KERN_ERR "myri10ge: %s: alloced only %d big bufs\n", 1725 printk(KERN_ERR "myri10ge: %s: alloced only %d big bufs\n",
1634 dev->name, mgp->rx_big.fill_cnt); 1726 dev->name, ss->rx_big.fill_cnt);
1635 goto abort_with_rx_big_ring; 1727 goto abort_with_rx_big_ring;
1636 } 1728 }
1637 1729
1638 return 0; 1730 return 0;
1639 1731
1640abort_with_rx_big_ring: 1732abort_with_rx_big_ring:
1641 for (i = mgp->rx_big.cnt; i < mgp->rx_big.fill_cnt; i++) { 1733 for (i = ss->rx_big.cnt; i < ss->rx_big.fill_cnt; i++) {
1642 int idx = i & mgp->rx_big.mask; 1734 int idx = i & ss->rx_big.mask;
1643 myri10ge_unmap_rx_page(mgp->pdev, &mgp->rx_big.info[idx], 1735 myri10ge_unmap_rx_page(mgp->pdev, &ss->rx_big.info[idx],
1644 mgp->big_bytes); 1736 mgp->big_bytes);
1645 put_page(mgp->rx_big.info[idx].page); 1737 put_page(ss->rx_big.info[idx].page);
1646 } 1738 }
1647 1739
1648abort_with_rx_small_ring: 1740abort_with_rx_small_ring:
1649 for (i = mgp->rx_small.cnt; i < mgp->rx_small.fill_cnt; i++) { 1741 for (i = ss->rx_small.cnt; i < ss->rx_small.fill_cnt; i++) {
1650 int idx = i & mgp->rx_small.mask; 1742 int idx = i & ss->rx_small.mask;
1651 myri10ge_unmap_rx_page(mgp->pdev, &mgp->rx_small.info[idx], 1743 myri10ge_unmap_rx_page(mgp->pdev, &ss->rx_small.info[idx],
1652 mgp->small_bytes + MXGEFW_PAD); 1744 mgp->small_bytes + MXGEFW_PAD);
1653 put_page(mgp->rx_small.info[idx].page); 1745 put_page(ss->rx_small.info[idx].page);
1654 } 1746 }
1655 1747
1656 kfree(mgp->rx_big.info); 1748 kfree(ss->rx_big.info);
1657 1749
1658abort_with_rx_small_info: 1750abort_with_rx_small_info:
1659 kfree(mgp->rx_small.info); 1751 kfree(ss->rx_small.info);
1660 1752
1661abort_with_tx_info: 1753abort_with_tx_info:
1662 kfree(mgp->tx.info); 1754 kfree(ss->tx.info);
1663 1755
1664abort_with_rx_big_shadow: 1756abort_with_rx_big_shadow:
1665 kfree(mgp->rx_big.shadow); 1757 kfree(ss->rx_big.shadow);
1666 1758
1667abort_with_rx_small_shadow: 1759abort_with_rx_small_shadow:
1668 kfree(mgp->rx_small.shadow); 1760 kfree(ss->rx_small.shadow);
1669 1761
1670abort_with_tx_req_bytes: 1762abort_with_tx_req_bytes:
1671 kfree(mgp->tx.req_bytes); 1763 kfree(ss->tx.req_bytes);
1672 mgp->tx.req_bytes = NULL; 1764 ss->tx.req_bytes = NULL;
1673 mgp->tx.req_list = NULL; 1765 ss->tx.req_list = NULL;
1674 1766
1675abort_with_nothing: 1767abort_with_nothing:
1676 return status; 1768 return status;
1677} 1769}
1678 1770
1679static void myri10ge_free_rings(struct net_device *dev) 1771static void myri10ge_free_rings(struct myri10ge_slice_state *ss)
1680{ 1772{
1681 struct myri10ge_priv *mgp; 1773 struct myri10ge_priv *mgp = ss->mgp;
1682 struct sk_buff *skb; 1774 struct sk_buff *skb;
1683 struct myri10ge_tx_buf *tx; 1775 struct myri10ge_tx_buf *tx;
1684 int i, len, idx; 1776 int i, len, idx;
1685 1777
1686 mgp = netdev_priv(dev); 1778 for (i = ss->rx_big.cnt; i < ss->rx_big.fill_cnt; i++) {
1687 1779 idx = i & ss->rx_big.mask;
1688 for (i = mgp->rx_big.cnt; i < mgp->rx_big.fill_cnt; i++) { 1780 if (i == ss->rx_big.fill_cnt - 1)
1689 idx = i & mgp->rx_big.mask; 1781 ss->rx_big.info[idx].page_offset = MYRI10GE_ALLOC_SIZE;
1690 if (i == mgp->rx_big.fill_cnt - 1) 1782 myri10ge_unmap_rx_page(mgp->pdev, &ss->rx_big.info[idx],
1691 mgp->rx_big.info[idx].page_offset = MYRI10GE_ALLOC_SIZE;
1692 myri10ge_unmap_rx_page(mgp->pdev, &mgp->rx_big.info[idx],
1693 mgp->big_bytes); 1783 mgp->big_bytes);
1694 put_page(mgp->rx_big.info[idx].page); 1784 put_page(ss->rx_big.info[idx].page);
1695 } 1785 }
1696 1786
1697 for (i = mgp->rx_small.cnt; i < mgp->rx_small.fill_cnt; i++) { 1787 for (i = ss->rx_small.cnt; i < ss->rx_small.fill_cnt; i++) {
1698 idx = i & mgp->rx_small.mask; 1788 idx = i & ss->rx_small.mask;
1699 if (i == mgp->rx_small.fill_cnt - 1) 1789 if (i == ss->rx_small.fill_cnt - 1)
1700 mgp->rx_small.info[idx].page_offset = 1790 ss->rx_small.info[idx].page_offset =
1701 MYRI10GE_ALLOC_SIZE; 1791 MYRI10GE_ALLOC_SIZE;
1702 myri10ge_unmap_rx_page(mgp->pdev, &mgp->rx_small.info[idx], 1792 myri10ge_unmap_rx_page(mgp->pdev, &ss->rx_small.info[idx],
1703 mgp->small_bytes + MXGEFW_PAD); 1793 mgp->small_bytes + MXGEFW_PAD);
1704 put_page(mgp->rx_small.info[idx].page); 1794 put_page(ss->rx_small.info[idx].page);
1705 } 1795 }
1706 tx = &mgp->tx; 1796 tx = &ss->tx;
1707 while (tx->done != tx->req) { 1797 while (tx->done != tx->req) {
1708 idx = tx->done & tx->mask; 1798 idx = tx->done & tx->mask;
1709 skb = tx->info[idx].skb; 1799 skb = tx->info[idx].skb;
@@ -1714,7 +1804,7 @@ static void myri10ge_free_rings(struct net_device *dev)
1714 len = pci_unmap_len(&tx->info[idx], len); 1804 len = pci_unmap_len(&tx->info[idx], len);
1715 pci_unmap_len_set(&tx->info[idx], len, 0); 1805 pci_unmap_len_set(&tx->info[idx], len, 0);
1716 if (skb) { 1806 if (skb) {
1717 mgp->stats.tx_dropped++; 1807 ss->stats.tx_dropped++;
1718 dev_kfree_skb_any(skb); 1808 dev_kfree_skb_any(skb);
1719 if (len) 1809 if (len)
1720 pci_unmap_single(mgp->pdev, 1810 pci_unmap_single(mgp->pdev,
@@ -1729,19 +1819,19 @@ static void myri10ge_free_rings(struct net_device *dev)
1729 PCI_DMA_TODEVICE); 1819 PCI_DMA_TODEVICE);
1730 } 1820 }
1731 } 1821 }
1732 kfree(mgp->rx_big.info); 1822 kfree(ss->rx_big.info);
1733 1823
1734 kfree(mgp->rx_small.info); 1824 kfree(ss->rx_small.info);
1735 1825
1736 kfree(mgp->tx.info); 1826 kfree(ss->tx.info);
1737 1827
1738 kfree(mgp->rx_big.shadow); 1828 kfree(ss->rx_big.shadow);
1739 1829
1740 kfree(mgp->rx_small.shadow); 1830 kfree(ss->rx_small.shadow);
1741 1831
1742 kfree(mgp->tx.req_bytes); 1832 kfree(ss->tx.req_bytes);
1743 mgp->tx.req_bytes = NULL; 1833 ss->tx.req_bytes = NULL;
1744 mgp->tx.req_list = NULL; 1834 ss->tx.req_list = NULL;
1745} 1835}
1746 1836
1747static int myri10ge_request_irq(struct myri10ge_priv *mgp) 1837static int myri10ge_request_irq(struct myri10ge_priv *mgp)
@@ -1840,13 +1930,11 @@ myri10ge_get_frag_header(struct skb_frag_struct *frag, void **mac_hdr,
1840 1930
1841static int myri10ge_open(struct net_device *dev) 1931static int myri10ge_open(struct net_device *dev)
1842{ 1932{
1843 struct myri10ge_priv *mgp; 1933 struct myri10ge_priv *mgp = netdev_priv(dev);
1844 struct myri10ge_cmd cmd; 1934 struct myri10ge_cmd cmd;
1845 struct net_lro_mgr *lro_mgr; 1935 struct net_lro_mgr *lro_mgr;
1846 int status, big_pow2; 1936 int status, big_pow2;
1847 1937
1848 mgp = netdev_priv(dev);
1849
1850 if (mgp->running != MYRI10GE_ETH_STOPPED) 1938 if (mgp->running != MYRI10GE_ETH_STOPPED)
1851 return -EBUSY; 1939 return -EBUSY;
1852 1940
@@ -1883,16 +1971,16 @@ static int myri10ge_open(struct net_device *dev)
1883 /* get the lanai pointers to the send and receive rings */ 1971 /* get the lanai pointers to the send and receive rings */
1884 1972
1885 status |= myri10ge_send_cmd(mgp, MXGEFW_CMD_GET_SEND_OFFSET, &cmd, 0); 1973 status |= myri10ge_send_cmd(mgp, MXGEFW_CMD_GET_SEND_OFFSET, &cmd, 0);
1886 mgp->tx.lanai = 1974 mgp->ss.tx.lanai =
1887 (struct mcp_kreq_ether_send __iomem *)(mgp->sram + cmd.data0); 1975 (struct mcp_kreq_ether_send __iomem *)(mgp->sram + cmd.data0);
1888 1976
1889 status |= 1977 status |=
1890 myri10ge_send_cmd(mgp, MXGEFW_CMD_GET_SMALL_RX_OFFSET, &cmd, 0); 1978 myri10ge_send_cmd(mgp, MXGEFW_CMD_GET_SMALL_RX_OFFSET, &cmd, 0);
1891 mgp->rx_small.lanai = 1979 mgp->ss.rx_small.lanai =
1892 (struct mcp_kreq_ether_recv __iomem *)(mgp->sram + cmd.data0); 1980 (struct mcp_kreq_ether_recv __iomem *)(mgp->sram + cmd.data0);
1893 1981
1894 status |= myri10ge_send_cmd(mgp, MXGEFW_CMD_GET_BIG_RX_OFFSET, &cmd, 0); 1982 status |= myri10ge_send_cmd(mgp, MXGEFW_CMD_GET_BIG_RX_OFFSET, &cmd, 0);
1895 mgp->rx_big.lanai = 1983 mgp->ss.rx_big.lanai =
1896 (struct mcp_kreq_ether_recv __iomem *)(mgp->sram + cmd.data0); 1984 (struct mcp_kreq_ether_recv __iomem *)(mgp->sram + cmd.data0);
1897 1985
1898 if (status != 0) { 1986 if (status != 0) {
@@ -1904,15 +1992,15 @@ static int myri10ge_open(struct net_device *dev)
1904 } 1992 }
1905 1993
1906 if (myri10ge_wcfifo && mgp->wc_enabled) { 1994 if (myri10ge_wcfifo && mgp->wc_enabled) {
1907 mgp->tx.wc_fifo = (u8 __iomem *) mgp->sram + MXGEFW_ETH_SEND_4; 1995 mgp->ss.tx.wc_fifo = (u8 __iomem *) mgp->sram + MXGEFW_ETH_SEND_4;
1908 mgp->rx_small.wc_fifo = 1996 mgp->ss.rx_small.wc_fifo =
1909 (u8 __iomem *) mgp->sram + MXGEFW_ETH_RECV_SMALL; 1997 (u8 __iomem *) mgp->sram + MXGEFW_ETH_RECV_SMALL;
1910 mgp->rx_big.wc_fifo = 1998 mgp->ss.rx_big.wc_fifo =
1911 (u8 __iomem *) mgp->sram + MXGEFW_ETH_RECV_BIG; 1999 (u8 __iomem *) mgp->sram + MXGEFW_ETH_RECV_BIG;
1912 } else { 2000 } else {
1913 mgp->tx.wc_fifo = NULL; 2001 mgp->ss.tx.wc_fifo = NULL;
1914 mgp->rx_small.wc_fifo = NULL; 2002 mgp->ss.rx_small.wc_fifo = NULL;
1915 mgp->rx_big.wc_fifo = NULL; 2003 mgp->ss.rx_big.wc_fifo = NULL;
1916 } 2004 }
1917 2005
1918 /* Firmware needs the big buff size as a power of 2. Lie and 2006 /* Firmware needs the big buff size as a power of 2. Lie and
@@ -1929,7 +2017,7 @@ static int myri10ge_open(struct net_device *dev)
1929 mgp->big_bytes = big_pow2; 2017 mgp->big_bytes = big_pow2;
1930 } 2018 }
1931 2019
1932 status = myri10ge_allocate_rings(dev); 2020 status = myri10ge_allocate_rings(&mgp->ss);
1933 if (status != 0) 2021 if (status != 0)
1934 goto abort_with_irq; 2022 goto abort_with_irq;
1935 2023
@@ -1948,12 +2036,12 @@ static int myri10ge_open(struct net_device *dev)
1948 goto abort_with_rings; 2036 goto abort_with_rings;
1949 } 2037 }
1950 2038
1951 cmd.data0 = MYRI10GE_LOWPART_TO_U32(mgp->fw_stats_bus); 2039 cmd.data0 = MYRI10GE_LOWPART_TO_U32(mgp->ss.fw_stats_bus);
1952 cmd.data1 = MYRI10GE_HIGHPART_TO_U32(mgp->fw_stats_bus); 2040 cmd.data1 = MYRI10GE_HIGHPART_TO_U32(mgp->ss.fw_stats_bus);
1953 cmd.data2 = sizeof(struct mcp_irq_data); 2041 cmd.data2 = sizeof(struct mcp_irq_data);
1954 status = myri10ge_send_cmd(mgp, MXGEFW_CMD_SET_STATS_DMA_V2, &cmd, 0); 2042 status = myri10ge_send_cmd(mgp, MXGEFW_CMD_SET_STATS_DMA_V2, &cmd, 0);
1955 if (status == -ENOSYS) { 2043 if (status == -ENOSYS) {
1956 dma_addr_t bus = mgp->fw_stats_bus; 2044 dma_addr_t bus = mgp->ss.fw_stats_bus;
1957 bus += offsetof(struct mcp_irq_data, send_done_count); 2045 bus += offsetof(struct mcp_irq_data, send_done_count);
1958 cmd.data0 = MYRI10GE_LOWPART_TO_U32(bus); 2046 cmd.data0 = MYRI10GE_LOWPART_TO_U32(bus);
1959 cmd.data1 = MYRI10GE_HIGHPART_TO_U32(bus); 2047 cmd.data1 = MYRI10GE_HIGHPART_TO_U32(bus);
@@ -1974,20 +2062,20 @@ static int myri10ge_open(struct net_device *dev)
1974 mgp->link_state = ~0U; 2062 mgp->link_state = ~0U;
1975 mgp->rdma_tags_available = 15; 2063 mgp->rdma_tags_available = 15;
1976 2064
1977 lro_mgr = &mgp->rx_done.lro_mgr; 2065 lro_mgr = &mgp->ss.rx_done.lro_mgr;
1978 lro_mgr->dev = dev; 2066 lro_mgr->dev = dev;
1979 lro_mgr->features = LRO_F_NAPI; 2067 lro_mgr->features = LRO_F_NAPI;
1980 lro_mgr->ip_summed = CHECKSUM_COMPLETE; 2068 lro_mgr->ip_summed = CHECKSUM_COMPLETE;
1981 lro_mgr->ip_summed_aggr = CHECKSUM_UNNECESSARY; 2069 lro_mgr->ip_summed_aggr = CHECKSUM_UNNECESSARY;
1982 lro_mgr->max_desc = MYRI10GE_MAX_LRO_DESCRIPTORS; 2070 lro_mgr->max_desc = MYRI10GE_MAX_LRO_DESCRIPTORS;
1983 lro_mgr->lro_arr = mgp->rx_done.lro_desc; 2071 lro_mgr->lro_arr = mgp->ss.rx_done.lro_desc;
1984 lro_mgr->get_frag_header = myri10ge_get_frag_header; 2072 lro_mgr->get_frag_header = myri10ge_get_frag_header;
1985 lro_mgr->max_aggr = myri10ge_lro_max_pkts; 2073 lro_mgr->max_aggr = myri10ge_lro_max_pkts;
1986 lro_mgr->frag_align_pad = 2; 2074 lro_mgr->frag_align_pad = 2;
1987 if (lro_mgr->max_aggr > MAX_SKB_FRAGS) 2075 if (lro_mgr->max_aggr > MAX_SKB_FRAGS)
1988 lro_mgr->max_aggr = MAX_SKB_FRAGS; 2076 lro_mgr->max_aggr = MAX_SKB_FRAGS;
1989 2077
1990 napi_enable(&mgp->napi); /* must happen prior to any irq */ 2078 napi_enable(&mgp->ss.napi); /* must happen prior to any irq */
1991 2079
1992 status = myri10ge_send_cmd(mgp, MXGEFW_CMD_ETHERNET_UP, &cmd, 0); 2080 status = myri10ge_send_cmd(mgp, MXGEFW_CMD_ETHERNET_UP, &cmd, 0);
1993 if (status) { 2081 if (status) {
@@ -1996,8 +2084,8 @@ static int myri10ge_open(struct net_device *dev)
1996 goto abort_with_rings; 2084 goto abort_with_rings;
1997 } 2085 }
1998 2086
1999 mgp->wake_queue = 0; 2087 mgp->ss.tx.wake_queue = 0;
2000 mgp->stop_queue = 0; 2088 mgp->ss.tx.stop_queue = 0;
2001 mgp->running = MYRI10GE_ETH_RUNNING; 2089 mgp->running = MYRI10GE_ETH_RUNNING;
2002 mgp->watchdog_timer.expires = jiffies + myri10ge_watchdog_timeout * HZ; 2090 mgp->watchdog_timer.expires = jiffies + myri10ge_watchdog_timeout * HZ;
2003 add_timer(&mgp->watchdog_timer); 2091 add_timer(&mgp->watchdog_timer);
@@ -2005,7 +2093,7 @@ static int myri10ge_open(struct net_device *dev)
2005 return 0; 2093 return 0;
2006 2094
2007abort_with_rings: 2095abort_with_rings:
2008 myri10ge_free_rings(dev); 2096 myri10ge_free_rings(&mgp->ss);
2009 2097
2010abort_with_irq: 2098abort_with_irq:
2011 myri10ge_free_irq(mgp); 2099 myri10ge_free_irq(mgp);
@@ -2017,21 +2105,19 @@ abort_with_nothing:
2017 2105
2018static int myri10ge_close(struct net_device *dev) 2106static int myri10ge_close(struct net_device *dev)
2019{ 2107{
2020 struct myri10ge_priv *mgp; 2108 struct myri10ge_priv *mgp = netdev_priv(dev);
2021 struct myri10ge_cmd cmd; 2109 struct myri10ge_cmd cmd;
2022 int status, old_down_cnt; 2110 int status, old_down_cnt;
2023 2111
2024 mgp = netdev_priv(dev);
2025
2026 if (mgp->running != MYRI10GE_ETH_RUNNING) 2112 if (mgp->running != MYRI10GE_ETH_RUNNING)
2027 return 0; 2113 return 0;
2028 2114
2029 if (mgp->tx.req_bytes == NULL) 2115 if (mgp->ss.tx.req_bytes == NULL)
2030 return 0; 2116 return 0;
2031 2117
2032 del_timer_sync(&mgp->watchdog_timer); 2118 del_timer_sync(&mgp->watchdog_timer);
2033 mgp->running = MYRI10GE_ETH_STOPPING; 2119 mgp->running = MYRI10GE_ETH_STOPPING;
2034 napi_disable(&mgp->napi); 2120 napi_disable(&mgp->ss.napi);
2035 netif_carrier_off(dev); 2121 netif_carrier_off(dev);
2036 netif_stop_queue(dev); 2122 netif_stop_queue(dev);
2037 old_down_cnt = mgp->down_cnt; 2123 old_down_cnt = mgp->down_cnt;
@@ -2047,7 +2133,7 @@ static int myri10ge_close(struct net_device *dev)
2047 2133
2048 netif_tx_disable(dev); 2134 netif_tx_disable(dev);
2049 myri10ge_free_irq(mgp); 2135 myri10ge_free_irq(mgp);
2050 myri10ge_free_rings(dev); 2136 myri10ge_free_rings(&mgp->ss);
2051 2137
2052 mgp->running = MYRI10GE_ETH_STOPPED; 2138 mgp->running = MYRI10GE_ETH_STOPPED;
2053 return 0; 2139 return 0;
@@ -2143,7 +2229,7 @@ myri10ge_submit_req_wc(struct myri10ge_tx_buf *tx,
2143 2229
2144/* 2230/*
2145 * Transmit a packet. We need to split the packet so that a single 2231 * Transmit a packet. We need to split the packet so that a single
2146 * segment does not cross myri10ge->tx.boundary, so this makes segment 2232 * segment does not cross myri10ge->tx_boundary, so this makes segment
2147 * counting tricky. So rather than try to count segments up front, we 2233 * counting tricky. So rather than try to count segments up front, we
2148 * just give up if there are too few segments to hold a reasonably 2234 * just give up if there are too few segments to hold a reasonably
2149 * fragmented packet currently available. If we run 2235 * fragmented packet currently available. If we run
@@ -2154,8 +2240,9 @@ myri10ge_submit_req_wc(struct myri10ge_tx_buf *tx,
2154static int myri10ge_xmit(struct sk_buff *skb, struct net_device *dev) 2240static int myri10ge_xmit(struct sk_buff *skb, struct net_device *dev)
2155{ 2241{
2156 struct myri10ge_priv *mgp = netdev_priv(dev); 2242 struct myri10ge_priv *mgp = netdev_priv(dev);
2243 struct myri10ge_slice_state *ss;
2157 struct mcp_kreq_ether_send *req; 2244 struct mcp_kreq_ether_send *req;
2158 struct myri10ge_tx_buf *tx = &mgp->tx; 2245 struct myri10ge_tx_buf *tx;
2159 struct skb_frag_struct *frag; 2246 struct skb_frag_struct *frag;
2160 dma_addr_t bus; 2247 dma_addr_t bus;
2161 u32 low; 2248 u32 low;
@@ -2166,6 +2253,9 @@ static int myri10ge_xmit(struct sk_buff *skb, struct net_device *dev)
2166 int cum_len, seglen, boundary, rdma_count; 2253 int cum_len, seglen, boundary, rdma_count;
2167 u8 flags, odd_flag; 2254 u8 flags, odd_flag;
2168 2255
2256 /* always transmit through slot 0 */
2257 ss = &mgp->ss;
2258 tx = &ss->tx;
2169again: 2259again:
2170 req = tx->req_list; 2260 req = tx->req_list;
2171 avail = tx->mask - 1 - (tx->req - tx->done); 2261 avail = tx->mask - 1 - (tx->req - tx->done);
@@ -2180,7 +2270,7 @@ again:
2180 2270
2181 if ((unlikely(avail < max_segments))) { 2271 if ((unlikely(avail < max_segments))) {
2182 /* we are out of transmit resources */ 2272 /* we are out of transmit resources */
2183 mgp->stop_queue++; 2273 tx->stop_queue++;
2184 netif_stop_queue(dev); 2274 netif_stop_queue(dev);
2185 return 1; 2275 return 1;
2186 } 2276 }
@@ -2242,7 +2332,7 @@ again:
2242 if (skb_padto(skb, ETH_ZLEN)) { 2332 if (skb_padto(skb, ETH_ZLEN)) {
2243 /* The packet is gone, so we must 2333 /* The packet is gone, so we must
2244 * return 0 */ 2334 * return 0 */
2245 mgp->stats.tx_dropped += 1; 2335 ss->stats.tx_dropped += 1;
2246 return 0; 2336 return 0;
2247 } 2337 }
2248 /* adjust the len to account for the zero pad 2338 /* adjust the len to account for the zero pad
@@ -2284,7 +2374,7 @@ again:
2284 2374
2285 while (1) { 2375 while (1) {
2286 /* Break the SKB or Fragment up into pieces which 2376 /* Break the SKB or Fragment up into pieces which
2287 * do not cross mgp->tx.boundary */ 2377 * do not cross mgp->tx_boundary */
2288 low = MYRI10GE_LOWPART_TO_U32(bus); 2378 low = MYRI10GE_LOWPART_TO_U32(bus);
2289 high_swapped = htonl(MYRI10GE_HIGHPART_TO_U32(bus)); 2379 high_swapped = htonl(MYRI10GE_HIGHPART_TO_U32(bus));
2290 while (len) { 2380 while (len) {
@@ -2294,7 +2384,8 @@ again:
2294 if (unlikely(count == max_segments)) 2384 if (unlikely(count == max_segments))
2295 goto abort_linearize; 2385 goto abort_linearize;
2296 2386
2297 boundary = (low + tx->boundary) & ~(tx->boundary - 1); 2387 boundary =
2388 (low + mgp->tx_boundary) & ~(mgp->tx_boundary - 1);
2298 seglen = boundary - low; 2389 seglen = boundary - low;
2299 if (seglen > len) 2390 if (seglen > len)
2300 seglen = len; 2391 seglen = len;
@@ -2378,7 +2469,7 @@ again:
2378 myri10ge_submit_req_wc(tx, tx->req_list, count); 2469 myri10ge_submit_req_wc(tx, tx->req_list, count);
2379 tx->pkt_start++; 2470 tx->pkt_start++;
2380 if ((avail - count) < MXGEFW_MAX_SEND_DESC) { 2471 if ((avail - count) < MXGEFW_MAX_SEND_DESC) {
2381 mgp->stop_queue++; 2472 tx->stop_queue++;
2382 netif_stop_queue(dev); 2473 netif_stop_queue(dev);
2383 } 2474 }
2384 dev->trans_start = jiffies; 2475 dev->trans_start = jiffies;
@@ -2420,12 +2511,12 @@ abort_linearize:
2420 if (skb_linearize(skb)) 2511 if (skb_linearize(skb))
2421 goto drop; 2512 goto drop;
2422 2513
2423 mgp->tx_linearized++; 2514 tx->linearized++;
2424 goto again; 2515 goto again;
2425 2516
2426drop: 2517drop:
2427 dev_kfree_skb_any(skb); 2518 dev_kfree_skb_any(skb);
2428 mgp->stats.tx_dropped += 1; 2519 ss->stats.tx_dropped += 1;
2429 return 0; 2520 return 0;
2430 2521
2431} 2522}
@@ -2433,7 +2524,7 @@ drop:
2433static int myri10ge_sw_tso(struct sk_buff *skb, struct net_device *dev) 2524static int myri10ge_sw_tso(struct sk_buff *skb, struct net_device *dev)
2434{ 2525{
2435 struct sk_buff *segs, *curr; 2526 struct sk_buff *segs, *curr;
2436 struct myri10ge_priv *mgp = dev->priv; 2527 struct myri10ge_priv *mgp = netdev_priv(dev);
2437 int status; 2528 int status;
2438 2529
2439 segs = skb_gso_segment(skb, dev->features & ~NETIF_F_TSO6); 2530 segs = skb_gso_segment(skb, dev->features & ~NETIF_F_TSO6);
@@ -2473,14 +2564,13 @@ static struct net_device_stats *myri10ge_get_stats(struct net_device *dev)
2473 2564
2474static void myri10ge_set_multicast_list(struct net_device *dev) 2565static void myri10ge_set_multicast_list(struct net_device *dev)
2475{ 2566{
2567 struct myri10ge_priv *mgp = netdev_priv(dev);
2476 struct myri10ge_cmd cmd; 2568 struct myri10ge_cmd cmd;
2477 struct myri10ge_priv *mgp;
2478 struct dev_mc_list *mc_list; 2569 struct dev_mc_list *mc_list;
2479 __be32 data[2] = { 0, 0 }; 2570 __be32 data[2] = { 0, 0 };
2480 int err; 2571 int err;
2481 DECLARE_MAC_BUF(mac); 2572 DECLARE_MAC_BUF(mac);
2482 2573
2483 mgp = netdev_priv(dev);
2484 /* can be called from atomic contexts, 2574 /* can be called from atomic contexts,
2485 * pass 1 to force atomicity in myri10ge_send_cmd() */ 2575 * pass 1 to force atomicity in myri10ge_send_cmd() */
2486 myri10ge_change_promisc(mgp, dev->flags & IFF_PROMISC, 1); 2576 myri10ge_change_promisc(mgp, dev->flags & IFF_PROMISC, 1);
@@ -2616,13 +2706,14 @@ static void myri10ge_enable_ecrc(struct myri10ge_priv *mgp)
2616 ext_type = (val & PCI_EXP_FLAGS_TYPE) >> 4; 2706 ext_type = (val & PCI_EXP_FLAGS_TYPE) >> 4;
2617 if (ext_type != PCI_EXP_TYPE_ROOT_PORT) { 2707 if (ext_type != PCI_EXP_TYPE_ROOT_PORT) {
2618 if (myri10ge_ecrc_enable > 1) { 2708 if (myri10ge_ecrc_enable > 1) {
2619 struct pci_dev *old_bridge = bridge; 2709 struct pci_dev *prev_bridge, *old_bridge = bridge;
2620 2710
2621 /* Walk the hierarchy up to the root port 2711 /* Walk the hierarchy up to the root port
2622 * where ECRC has to be enabled */ 2712 * where ECRC has to be enabled */
2623 do { 2713 do {
2714 prev_bridge = bridge;
2624 bridge = bridge->bus->self; 2715 bridge = bridge->bus->self;
2625 if (!bridge) { 2716 if (!bridge || prev_bridge == bridge) {
2626 dev_err(dev, 2717 dev_err(dev,
2627 "Failed to find root port" 2718 "Failed to find root port"
2628 " to force ECRC\n"); 2719 " to force ECRC\n");
@@ -2681,9 +2772,9 @@ static void myri10ge_enable_ecrc(struct myri10ge_priv *mgp)
2681 * already been enabled, then it must use a firmware image which works 2772 * already been enabled, then it must use a firmware image which works
2682 * around unaligned completion packets (myri10ge_ethp_z8e.dat), and it 2773 * around unaligned completion packets (myri10ge_ethp_z8e.dat), and it
2683 * should also ensure that it never gives the device a Read-DMA which is 2774 * should also ensure that it never gives the device a Read-DMA which is
2684 * larger than 2KB by setting the tx.boundary to 2KB. If ECRC is 2775 * larger than 2KB by setting the tx_boundary to 2KB. If ECRC is
2685 * enabled, then the driver should use the aligned (myri10ge_eth_z8e.dat) 2776 * enabled, then the driver should use the aligned (myri10ge_eth_z8e.dat)
2686 * firmware image, and set tx.boundary to 4KB. 2777 * firmware image, and set tx_boundary to 4KB.
2687 */ 2778 */
2688 2779
2689static void myri10ge_firmware_probe(struct myri10ge_priv *mgp) 2780static void myri10ge_firmware_probe(struct myri10ge_priv *mgp)
@@ -2692,7 +2783,7 @@ static void myri10ge_firmware_probe(struct myri10ge_priv *mgp)
2692 struct device *dev = &pdev->dev; 2783 struct device *dev = &pdev->dev;
2693 int status; 2784 int status;
2694 2785
2695 mgp->tx.boundary = 4096; 2786 mgp->tx_boundary = 4096;
2696 /* 2787 /*
2697 * Verify the max read request size was set to 4KB 2788 * Verify the max read request size was set to 4KB
2698 * before trying the test with 4KB. 2789 * before trying the test with 4KB.
@@ -2704,7 +2795,7 @@ static void myri10ge_firmware_probe(struct myri10ge_priv *mgp)
2704 } 2795 }
2705 if (status != 4096) { 2796 if (status != 4096) {
2706 dev_warn(dev, "Max Read Request size != 4096 (%d)\n", status); 2797 dev_warn(dev, "Max Read Request size != 4096 (%d)\n", status);
2707 mgp->tx.boundary = 2048; 2798 mgp->tx_boundary = 2048;
2708 } 2799 }
2709 /* 2800 /*
2710 * load the optimized firmware (which assumes aligned PCIe 2801 * load the optimized firmware (which assumes aligned PCIe
@@ -2737,7 +2828,7 @@ static void myri10ge_firmware_probe(struct myri10ge_priv *mgp)
2737 "Please install up to date fw\n"); 2828 "Please install up to date fw\n");
2738abort: 2829abort:
2739 /* fall back to using the unaligned firmware */ 2830 /* fall back to using the unaligned firmware */
2740 mgp->tx.boundary = 2048; 2831 mgp->tx_boundary = 2048;
2741 mgp->fw_name = myri10ge_fw_unaligned; 2832 mgp->fw_name = myri10ge_fw_unaligned;
2742 2833
2743} 2834}
@@ -2758,7 +2849,7 @@ static void myri10ge_select_firmware(struct myri10ge_priv *mgp)
2758 if (link_width < 8) { 2849 if (link_width < 8) {
2759 dev_info(&mgp->pdev->dev, "PCIE x%d Link\n", 2850 dev_info(&mgp->pdev->dev, "PCIE x%d Link\n",
2760 link_width); 2851 link_width);
2761 mgp->tx.boundary = 4096; 2852 mgp->tx_boundary = 4096;
2762 mgp->fw_name = myri10ge_fw_aligned; 2853 mgp->fw_name = myri10ge_fw_aligned;
2763 } else { 2854 } else {
2764 myri10ge_firmware_probe(mgp); 2855 myri10ge_firmware_probe(mgp);
@@ -2767,12 +2858,12 @@ static void myri10ge_select_firmware(struct myri10ge_priv *mgp)
2767 if (myri10ge_force_firmware == 1) { 2858 if (myri10ge_force_firmware == 1) {
2768 dev_info(&mgp->pdev->dev, 2859 dev_info(&mgp->pdev->dev,
2769 "Assuming aligned completions (forced)\n"); 2860 "Assuming aligned completions (forced)\n");
2770 mgp->tx.boundary = 4096; 2861 mgp->tx_boundary = 4096;
2771 mgp->fw_name = myri10ge_fw_aligned; 2862 mgp->fw_name = myri10ge_fw_aligned;
2772 } else { 2863 } else {
2773 dev_info(&mgp->pdev->dev, 2864 dev_info(&mgp->pdev->dev,
2774 "Assuming unaligned completions (forced)\n"); 2865 "Assuming unaligned completions (forced)\n");
2775 mgp->tx.boundary = 2048; 2866 mgp->tx_boundary = 2048;
2776 mgp->fw_name = myri10ge_fw_unaligned; 2867 mgp->fw_name = myri10ge_fw_unaligned;
2777 } 2868 }
2778 } 2869 }
@@ -2889,6 +2980,7 @@ static void myri10ge_watchdog(struct work_struct *work)
2889{ 2980{
2890 struct myri10ge_priv *mgp = 2981 struct myri10ge_priv *mgp =
2891 container_of(work, struct myri10ge_priv, watchdog_work); 2982 container_of(work, struct myri10ge_priv, watchdog_work);
2983 struct myri10ge_tx_buf *tx;
2892 u32 reboot; 2984 u32 reboot;
2893 int status; 2985 int status;
2894 u16 cmd, vendor; 2986 u16 cmd, vendor;
@@ -2938,15 +3030,16 @@ static void myri10ge_watchdog(struct work_struct *work)
2938 3030
2939 printk(KERN_ERR "myri10ge: %s: device timeout, resetting\n", 3031 printk(KERN_ERR "myri10ge: %s: device timeout, resetting\n",
2940 mgp->dev->name); 3032 mgp->dev->name);
3033 tx = &mgp->ss.tx;
2941 printk(KERN_INFO "myri10ge: %s: %d %d %d %d %d\n", 3034 printk(KERN_INFO "myri10ge: %s: %d %d %d %d %d\n",
2942 mgp->dev->name, mgp->tx.req, mgp->tx.done, 3035 mgp->dev->name, tx->req, tx->done,
2943 mgp->tx.pkt_start, mgp->tx.pkt_done, 3036 tx->pkt_start, tx->pkt_done,
2944 (int)ntohl(mgp->fw_stats->send_done_count)); 3037 (int)ntohl(mgp->ss.fw_stats->send_done_count));
2945 msleep(2000); 3038 msleep(2000);
2946 printk(KERN_INFO "myri10ge: %s: %d %d %d %d %d\n", 3039 printk(KERN_INFO "myri10ge: %s: %d %d %d %d %d\n",
2947 mgp->dev->name, mgp->tx.req, mgp->tx.done, 3040 mgp->dev->name, tx->req, tx->done,
2948 mgp->tx.pkt_start, mgp->tx.pkt_done, 3041 tx->pkt_start, tx->pkt_done,
2949 (int)ntohl(mgp->fw_stats->send_done_count)); 3042 (int)ntohl(mgp->ss.fw_stats->send_done_count));
2950 } 3043 }
2951 rtnl_lock(); 3044 rtnl_lock();
2952 myri10ge_close(mgp->dev); 3045 myri10ge_close(mgp->dev);
@@ -2969,28 +3062,31 @@ static void myri10ge_watchdog(struct work_struct *work)
2969static void myri10ge_watchdog_timer(unsigned long arg) 3062static void myri10ge_watchdog_timer(unsigned long arg)
2970{ 3063{
2971 struct myri10ge_priv *mgp; 3064 struct myri10ge_priv *mgp;
3065 struct myri10ge_slice_state *ss;
2972 u32 rx_pause_cnt; 3066 u32 rx_pause_cnt;
2973 3067
2974 mgp = (struct myri10ge_priv *)arg; 3068 mgp = (struct myri10ge_priv *)arg;
2975 3069
2976 if (mgp->rx_small.watchdog_needed) { 3070 rx_pause_cnt = ntohl(mgp->ss.fw_stats->dropped_pause);
2977 myri10ge_alloc_rx_pages(mgp, &mgp->rx_small, 3071
3072 ss = &mgp->ss;
3073 if (ss->rx_small.watchdog_needed) {
3074 myri10ge_alloc_rx_pages(mgp, &ss->rx_small,
2978 mgp->small_bytes + MXGEFW_PAD, 1); 3075 mgp->small_bytes + MXGEFW_PAD, 1);
2979 if (mgp->rx_small.fill_cnt - mgp->rx_small.cnt >= 3076 if (ss->rx_small.fill_cnt - ss->rx_small.cnt >=
2980 myri10ge_fill_thresh) 3077 myri10ge_fill_thresh)
2981 mgp->rx_small.watchdog_needed = 0; 3078 ss->rx_small.watchdog_needed = 0;
2982 } 3079 }
2983 if (mgp->rx_big.watchdog_needed) { 3080 if (ss->rx_big.watchdog_needed) {
2984 myri10ge_alloc_rx_pages(mgp, &mgp->rx_big, mgp->big_bytes, 1); 3081 myri10ge_alloc_rx_pages(mgp, &ss->rx_big, mgp->big_bytes, 1);
2985 if (mgp->rx_big.fill_cnt - mgp->rx_big.cnt >= 3082 if (ss->rx_big.fill_cnt - ss->rx_big.cnt >=
2986 myri10ge_fill_thresh) 3083 myri10ge_fill_thresh)
2987 mgp->rx_big.watchdog_needed = 0; 3084 ss->rx_big.watchdog_needed = 0;
2988 } 3085 }
2989 rx_pause_cnt = ntohl(mgp->fw_stats->dropped_pause);
2990 3086
2991 if (mgp->tx.req != mgp->tx.done && 3087 if (ss->tx.req != ss->tx.done &&
2992 mgp->tx.done == mgp->watchdog_tx_done && 3088 ss->tx.done == ss->watchdog_tx_done &&
2993 mgp->watchdog_tx_req != mgp->watchdog_tx_done) { 3089 ss->watchdog_tx_req != ss->watchdog_tx_done) {
2994 /* nic seems like it might be stuck.. */ 3090 /* nic seems like it might be stuck.. */
2995 if (rx_pause_cnt != mgp->watchdog_pause) { 3091 if (rx_pause_cnt != mgp->watchdog_pause) {
2996 if (net_ratelimit()) 3092 if (net_ratelimit())
@@ -3005,8 +3101,8 @@ static void myri10ge_watchdog_timer(unsigned long arg)
3005 /* rearm timer */ 3101 /* rearm timer */
3006 mod_timer(&mgp->watchdog_timer, 3102 mod_timer(&mgp->watchdog_timer,
3007 jiffies + myri10ge_watchdog_timeout * HZ); 3103 jiffies + myri10ge_watchdog_timeout * HZ);
3008 mgp->watchdog_tx_done = mgp->tx.done; 3104 ss->watchdog_tx_done = ss->tx.done;
3009 mgp->watchdog_tx_req = mgp->tx.req; 3105 ss->watchdog_tx_req = ss->tx.req;
3010 mgp->watchdog_pause = rx_pause_cnt; 3106 mgp->watchdog_pause = rx_pause_cnt;
3011} 3107}
3012 3108
@@ -3030,7 +3126,7 @@ static int myri10ge_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
3030 3126
3031 mgp = netdev_priv(netdev); 3127 mgp = netdev_priv(netdev);
3032 mgp->dev = netdev; 3128 mgp->dev = netdev;
3033 netif_napi_add(netdev, &mgp->napi, myri10ge_poll, myri10ge_napi_weight); 3129 netif_napi_add(netdev, &mgp->ss.napi, myri10ge_poll, myri10ge_napi_weight);
3034 mgp->pdev = pdev; 3130 mgp->pdev = pdev;
3035 mgp->csum_flag = MXGEFW_FLAGS_CKSUM; 3131 mgp->csum_flag = MXGEFW_FLAGS_CKSUM;
3036 mgp->pause = myri10ge_flow_control; 3132 mgp->pause = myri10ge_flow_control;
@@ -3076,9 +3172,9 @@ static int myri10ge_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
3076 if (mgp->cmd == NULL) 3172 if (mgp->cmd == NULL)
3077 goto abort_with_netdev; 3173 goto abort_with_netdev;
3078 3174
3079 mgp->fw_stats = dma_alloc_coherent(&pdev->dev, sizeof(*mgp->fw_stats), 3175 mgp->ss.fw_stats = dma_alloc_coherent(&pdev->dev, sizeof(*mgp->ss.fw_stats),
3080 &mgp->fw_stats_bus, GFP_KERNEL); 3176 &mgp->ss.fw_stats_bus, GFP_KERNEL);
3081 if (mgp->fw_stats == NULL) 3177 if (mgp->ss.fw_stats == NULL)
3082 goto abort_with_cmd; 3178 goto abort_with_cmd;
3083 3179
3084 mgp->board_span = pci_resource_len(pdev, 0); 3180 mgp->board_span = pci_resource_len(pdev, 0);
@@ -3118,12 +3214,12 @@ static int myri10ge_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
3118 netdev->dev_addr[i] = mgp->mac_addr[i]; 3214 netdev->dev_addr[i] = mgp->mac_addr[i];
3119 3215
3120 /* allocate rx done ring */ 3216 /* allocate rx done ring */
3121 bytes = myri10ge_max_intr_slots * sizeof(*mgp->rx_done.entry); 3217 bytes = mgp->max_intr_slots * sizeof(*mgp->ss.rx_done.entry);
3122 mgp->rx_done.entry = dma_alloc_coherent(&pdev->dev, bytes, 3218 mgp->ss.rx_done.entry = dma_alloc_coherent(&pdev->dev, bytes,
3123 &mgp->rx_done.bus, GFP_KERNEL); 3219 &mgp->ss.rx_done.bus, GFP_KERNEL);
3124 if (mgp->rx_done.entry == NULL) 3220 if (mgp->ss.rx_done.entry == NULL)
3125 goto abort_with_ioremap; 3221 goto abort_with_ioremap;
3126 memset(mgp->rx_done.entry, 0, bytes); 3222 memset(mgp->ss.rx_done.entry, 0, bytes);
3127 3223
3128 myri10ge_select_firmware(mgp); 3224 myri10ge_select_firmware(mgp);
3129 3225
@@ -3183,7 +3279,7 @@ static int myri10ge_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
3183 } 3279 }
3184 dev_info(dev, "%s IRQ %d, tx bndry %d, fw %s, WC %s\n", 3280 dev_info(dev, "%s IRQ %d, tx bndry %d, fw %s, WC %s\n",
3185 (mgp->msi_enabled ? "MSI" : "xPIC"), 3281 (mgp->msi_enabled ? "MSI" : "xPIC"),
3186 netdev->irq, mgp->tx.boundary, mgp->fw_name, 3282 netdev->irq, mgp->tx_boundary, mgp->fw_name,
3187 (mgp->wc_enabled ? "Enabled" : "Disabled")); 3283 (mgp->wc_enabled ? "Enabled" : "Disabled"));
3188 3284
3189 return 0; 3285 return 0;
@@ -3195,9 +3291,9 @@ abort_with_firmware:
3195 myri10ge_dummy_rdma(mgp, 0); 3291 myri10ge_dummy_rdma(mgp, 0);
3196 3292
3197abort_with_rx_done: 3293abort_with_rx_done:
3198 bytes = myri10ge_max_intr_slots * sizeof(*mgp->rx_done.entry); 3294 bytes = mgp->max_intr_slots * sizeof(*mgp->ss.rx_done.entry);
3199 dma_free_coherent(&pdev->dev, bytes, 3295 dma_free_coherent(&pdev->dev, bytes,
3200 mgp->rx_done.entry, mgp->rx_done.bus); 3296 mgp->ss.rx_done.entry, mgp->ss.rx_done.bus);
3201 3297
3202abort_with_ioremap: 3298abort_with_ioremap:
3203 iounmap(mgp->sram); 3299 iounmap(mgp->sram);
@@ -3207,8 +3303,8 @@ abort_with_wc:
3207 if (mgp->mtrr >= 0) 3303 if (mgp->mtrr >= 0)
3208 mtrr_del(mgp->mtrr, mgp->iomem_base, mgp->board_span); 3304 mtrr_del(mgp->mtrr, mgp->iomem_base, mgp->board_span);
3209#endif 3305#endif
3210 dma_free_coherent(&pdev->dev, sizeof(*mgp->fw_stats), 3306 dma_free_coherent(&pdev->dev, sizeof(*mgp->ss.fw_stats),
3211 mgp->fw_stats, mgp->fw_stats_bus); 3307 mgp->ss.fw_stats, mgp->ss.fw_stats_bus);
3212 3308
3213abort_with_cmd: 3309abort_with_cmd:
3214 dma_free_coherent(&pdev->dev, sizeof(*mgp->cmd), 3310 dma_free_coherent(&pdev->dev, sizeof(*mgp->cmd),
@@ -3246,9 +3342,9 @@ static void myri10ge_remove(struct pci_dev *pdev)
3246 /* avoid a memory leak */ 3342 /* avoid a memory leak */
3247 pci_restore_state(pdev); 3343 pci_restore_state(pdev);
3248 3344
3249 bytes = myri10ge_max_intr_slots * sizeof(*mgp->rx_done.entry); 3345 bytes = mgp->max_intr_slots * sizeof(*mgp->ss.rx_done.entry);
3250 dma_free_coherent(&pdev->dev, bytes, 3346 dma_free_coherent(&pdev->dev, bytes,
3251 mgp->rx_done.entry, mgp->rx_done.bus); 3347 mgp->ss.rx_done.entry, mgp->ss.rx_done.bus);
3252 3348
3253 iounmap(mgp->sram); 3349 iounmap(mgp->sram);
3254 3350
@@ -3256,8 +3352,8 @@ static void myri10ge_remove(struct pci_dev *pdev)
3256 if (mgp->mtrr >= 0) 3352 if (mgp->mtrr >= 0)
3257 mtrr_del(mgp->mtrr, mgp->iomem_base, mgp->board_span); 3353 mtrr_del(mgp->mtrr, mgp->iomem_base, mgp->board_span);
3258#endif 3354#endif
3259 dma_free_coherent(&pdev->dev, sizeof(*mgp->fw_stats), 3355 dma_free_coherent(&pdev->dev, sizeof(*mgp->ss.fw_stats),
3260 mgp->fw_stats, mgp->fw_stats_bus); 3356 mgp->ss.fw_stats, mgp->ss.fw_stats_bus);
3261 3357
3262 dma_free_coherent(&pdev->dev, sizeof(*mgp->cmd), 3358 dma_free_coherent(&pdev->dev, sizeof(*mgp->cmd),
3263 mgp->cmd, mgp->cmd_bus); 3359 mgp->cmd, mgp->cmd_bus);
diff --git a/drivers/net/myri10ge/myri10ge_mcp.h b/drivers/net/myri10ge/myri10ge_mcp.h
index 58e57178c563..fdbeeee07372 100644
--- a/drivers/net/myri10ge/myri10ge_mcp.h
+++ b/drivers/net/myri10ge/myri10ge_mcp.h
@@ -10,7 +10,7 @@ struct mcp_dma_addr {
10 __be32 low; 10 __be32 low;
11}; 11};
12 12
13/* 4 Bytes. 8 Bytes for NDIS drivers. */ 13/* 4 Bytes */
14struct mcp_slot { 14struct mcp_slot {
15 __sum16 checksum; 15 __sum16 checksum;
16 __be16 length; 16 __be16 length;
@@ -144,6 +144,7 @@ enum myri10ge_mcp_cmd_type {
144 * a power of 2 number of entries. */ 144 * a power of 2 number of entries. */
145 145
146 MXGEFW_CMD_SET_INTRQ_SIZE, /* in bytes */ 146 MXGEFW_CMD_SET_INTRQ_SIZE, /* in bytes */
147#define MXGEFW_CMD_SET_INTRQ_SIZE_FLAG_NO_STRICT_SIZE_CHECK (1 << 31)
147 148
148 /* command to bring ethernet interface up. Above parameters 149 /* command to bring ethernet interface up. Above parameters
149 * (plus mtu & mac address) must have been exchanged prior 150 * (plus mtu & mac address) must have been exchanged prior
@@ -221,10 +222,14 @@ enum myri10ge_mcp_cmd_type {
221 MXGEFW_CMD_GET_MAX_RSS_QUEUES, 222 MXGEFW_CMD_GET_MAX_RSS_QUEUES,
222 MXGEFW_CMD_ENABLE_RSS_QUEUES, 223 MXGEFW_CMD_ENABLE_RSS_QUEUES,
223 /* data0 = number of slices n (0, 1, ..., n-1) to enable 224 /* data0 = number of slices n (0, 1, ..., n-1) to enable
224 * data1 = interrupt mode. 0=share one INTx/MSI, 1=use one MSI-X per queue. 225 * data1 = interrupt mode.
226 * 0=share one INTx/MSI, 1=use one MSI-X per queue.
225 * If all queues share one interrupt, the driver must have set 227 * If all queues share one interrupt, the driver must have set
226 * RSS_SHARED_INTERRUPT_DMA before enabling queues. 228 * RSS_SHARED_INTERRUPT_DMA before enabling queues.
227 */ 229 */
230#define MXGEFW_SLICE_INTR_MODE_SHARED 0
231#define MXGEFW_SLICE_INTR_MODE_ONE_PER_SLICE 1
232
228 MXGEFW_CMD_GET_RSS_SHARED_INTERRUPT_MASK_OFFSET, 233 MXGEFW_CMD_GET_RSS_SHARED_INTERRUPT_MASK_OFFSET,
229 MXGEFW_CMD_SET_RSS_SHARED_INTERRUPT_DMA, 234 MXGEFW_CMD_SET_RSS_SHARED_INTERRUPT_DMA,
230 /* data0, data1 = bus address lsw, msw */ 235 /* data0, data1 = bus address lsw, msw */
@@ -241,10 +246,14 @@ enum myri10ge_mcp_cmd_type {
241 * 0: disable rss. nic does not distribute receive packets. 246 * 0: disable rss. nic does not distribute receive packets.
242 * 1: enable rss. nic distributes receive packets among queues. 247 * 1: enable rss. nic distributes receive packets among queues.
243 * data1 = hash type 248 * data1 = hash type
244 * 1: IPV4 249 * 1: IPV4 (required by RSS)
245 * 2: TCP_IPV4 250 * 2: TCP_IPV4 (required by RSS)
246 * 3: IPV4 | TCP_IPV4 251 * 3: IPV4 | TCP_IPV4 (required by RSS)
252 * 4: source port
247 */ 253 */
254#define MXGEFW_RSS_HASH_TYPE_IPV4 0x1
255#define MXGEFW_RSS_HASH_TYPE_TCP_IPV4 0x2
256#define MXGEFW_RSS_HASH_TYPE_SRC_PORT 0x4
248 257
249 MXGEFW_CMD_GET_MAX_TSO6_HDR_SIZE, 258 MXGEFW_CMD_GET_MAX_TSO6_HDR_SIZE,
250 /* Return data = the max. size of the entire headers of a IPv6 TSO packet. 259 /* Return data = the max. size of the entire headers of a IPv6 TSO packet.
@@ -260,6 +269,8 @@ enum myri10ge_mcp_cmd_type {
260 * 0: Linux/FreeBSD style (NIC default) 269 * 0: Linux/FreeBSD style (NIC default)
261 * 1: NDIS/NetBSD style 270 * 1: NDIS/NetBSD style
262 */ 271 */
272#define MXGEFW_TSO_MODE_LINUX 0
273#define MXGEFW_TSO_MODE_NDIS 1
263 274
264 MXGEFW_CMD_MDIO_READ, 275 MXGEFW_CMD_MDIO_READ,
265 /* data0 = dev_addr (PMA/PMD or PCS ...), data1 = register/addr */ 276 /* data0 = dev_addr (PMA/PMD or PCS ...), data1 = register/addr */
@@ -286,6 +297,38 @@ enum myri10ge_mcp_cmd_type {
286 /* Return data = NIC memory offset of mcp_vpump_public_global */ 297 /* Return data = NIC memory offset of mcp_vpump_public_global */
287 MXGEFW_CMD_RESET_VPUMP, 298 MXGEFW_CMD_RESET_VPUMP,
288 /* Resets the VPUMP state */ 299 /* Resets the VPUMP state */
300
301 MXGEFW_CMD_SET_RSS_MCP_SLOT_TYPE,
302 /* data0 = mcp_slot type to use.
303 * 0 = the default 4B mcp_slot
304 * 1 = 8B mcp_slot_8
305 */
306#define MXGEFW_RSS_MCP_SLOT_TYPE_MIN 0
307#define MXGEFW_RSS_MCP_SLOT_TYPE_WITH_HASH 1
308
309 MXGEFW_CMD_SET_THROTTLE_FACTOR,
310 /* set the throttle factor for ethp_z8e
311 * data0 = throttle_factor
312 * throttle_factor = 256 * pcie-raw-speed / tx_speed
313 * tx_speed = 256 * pcie-raw-speed / throttle_factor
314 *
315 * For PCI-E x8: pcie-raw-speed == 16Gb/s
316 * For PCI-E x4: pcie-raw-speed == 8Gb/s
317 *
318 * ex1: throttle_factor == 0x1a0 (416), tx_speed == 1.23GB/s == 9.846 Gb/s
319 * ex2: throttle_factor == 0x200 (512), tx_speed == 1.0GB/s == 8 Gb/s
320 *
321 * with tx_boundary == 2048, max-throttle-factor == 8191 => min-speed == 500Mb/s
322 * with tx_boundary == 4096, max-throttle-factor == 4095 => min-speed == 1Gb/s
323 */
324
325 MXGEFW_CMD_VPUMP_UP,
326 /* Allocates VPump Connection, Send Request and Zero copy buffer address tables */
327 MXGEFW_CMD_GET_VPUMP_CLK,
328 /* Get the lanai clock */
329
330 MXGEFW_CMD_GET_DCA_OFFSET,
331 /* offset of dca control for WDMAs */
289}; 332};
290 333
291enum myri10ge_mcp_cmd_status { 334enum myri10ge_mcp_cmd_status {
@@ -302,7 +345,8 @@ enum myri10ge_mcp_cmd_status {
302 MXGEFW_CMD_ERROR_UNALIGNED, 345 MXGEFW_CMD_ERROR_UNALIGNED,
303 MXGEFW_CMD_ERROR_NO_MDIO, 346 MXGEFW_CMD_ERROR_NO_MDIO,
304 MXGEFW_CMD_ERROR_XFP_FAILURE, 347 MXGEFW_CMD_ERROR_XFP_FAILURE,
305 MXGEFW_CMD_ERROR_XFP_ABSENT 348 MXGEFW_CMD_ERROR_XFP_ABSENT,
349 MXGEFW_CMD_ERROR_BAD_PCIE_LINK
306}; 350};
307 351
308#define MXGEFW_OLD_IRQ_DATA_LEN 40 352#define MXGEFW_OLD_IRQ_DATA_LEN 40
diff --git a/drivers/net/myri10ge/myri10ge_mcp_gen_header.h b/drivers/net/myri10ge/myri10ge_mcp_gen_header.h
index 16a810dd6d51..07d65c2cbb24 100644
--- a/drivers/net/myri10ge/myri10ge_mcp_gen_header.h
+++ b/drivers/net/myri10ge/myri10ge_mcp_gen_header.h
@@ -1,30 +1,6 @@
1#ifndef __MYRI10GE_MCP_GEN_HEADER_H__ 1#ifndef __MYRI10GE_MCP_GEN_HEADER_H__
2#define __MYRI10GE_MCP_GEN_HEADER_H__ 2#define __MYRI10GE_MCP_GEN_HEADER_H__
3 3
4/* this file define a standard header used as a first entry point to
5 * exchange information between firmware/driver and driver. The
6 * header structure can be anywhere in the mcp. It will usually be in
7 * the .data section, because some fields needs to be initialized at
8 * compile time.
9 * The 32bit word at offset MX_HEADER_PTR_OFFSET in the mcp must
10 * contains the location of the header.
11 *
12 * Typically a MCP will start with the following:
13 * .text
14 * .space 52 ! to help catch MEMORY_INT errors
15 * bt start ! jump to real code
16 * nop
17 * .long _gen_mcp_header
18 *
19 * The source will have a definition like:
20 *
21 * mcp_gen_header_t gen_mcp_header = {
22 * .header_length = sizeof(mcp_gen_header_t),
23 * .mcp_type = MCP_TYPE_XXX,
24 * .version = "something $Id: mcp_gen_header.h,v 1.2 2006/05/13 10:04:35 bgoglin Exp $",
25 * .mcp_globals = (unsigned)&Globals
26 * };
27 */
28 4
29#define MCP_HEADER_PTR_OFFSET 0x3c 5#define MCP_HEADER_PTR_OFFSET 0x3c
30 6
@@ -32,13 +8,14 @@
32#define MCP_TYPE_PCIE 0x70636965 /* "PCIE" pcie-only MCP */ 8#define MCP_TYPE_PCIE 0x70636965 /* "PCIE" pcie-only MCP */
33#define MCP_TYPE_ETH 0x45544820 /* "ETH " */ 9#define MCP_TYPE_ETH 0x45544820 /* "ETH " */
34#define MCP_TYPE_MCP0 0x4d435030 /* "MCP0" */ 10#define MCP_TYPE_MCP0 0x4d435030 /* "MCP0" */
11#define MCP_TYPE_DFLT 0x20202020 /* " " */
35 12
36struct mcp_gen_header { 13struct mcp_gen_header {
37 /* the first 4 fields are filled at compile time */ 14 /* the first 4 fields are filled at compile time */
38 unsigned header_length; 15 unsigned header_length;
39 __be32 mcp_type; 16 __be32 mcp_type;
40 char version[128]; 17 char version[128];
41 unsigned mcp_globals; /* pointer to mcp-type specific structure */ 18 unsigned mcp_private; /* pointer to mcp-type specific structure */
42 19
43 /* filled by the MCP at run-time */ 20 /* filled by the MCP at run-time */
44 unsigned sram_size; 21 unsigned sram_size;
@@ -53,6 +30,18 @@ struct mcp_gen_header {
53 * 30 *
54 * Never remove any field. Keep everything naturally align. 31 * Never remove any field. Keep everything naturally align.
55 */ 32 */
33
34 /* Specifies if the running mcp is mcp0, 1, or 2. */
35 unsigned char mcp_index;
36 unsigned char disable_rabbit;
37 unsigned char unaligned_tlp;
38 unsigned char pad1;
39 unsigned counters_addr;
40 unsigned copy_block_info; /* for small mcps loaded with "lload -d" */
41 unsigned short handoff_id_major; /* must be equal */
42 unsigned short handoff_id_caps; /* bitfield: new mcp must have superset */
43 unsigned msix_table_addr; /* start address of msix table in firmware */
44 /* 8 */
56}; 45};
57 46
58#endif /* __MYRI10GE_MCP_GEN_HEADER_H__ */ 47#endif /* __MYRI10GE_MCP_GEN_HEADER_H__ */
diff --git a/drivers/net/niu.c b/drivers/net/niu.c
index 57cfd72ffdf7..918f802fe089 100644
--- a/drivers/net/niu.c
+++ b/drivers/net/niu.c
@@ -865,7 +865,6 @@ static int link_status_1g_serdes(struct niu *np, int *link_up_p)
865 return 0; 865 return 0;
866} 866}
867 867
868
869static int link_status_10g_serdes(struct niu *np, int *link_up_p) 868static int link_status_10g_serdes(struct niu *np, int *link_up_p)
870{ 869{
871 unsigned long flags; 870 unsigned long flags;
@@ -900,7 +899,6 @@ static int link_status_10g_serdes(struct niu *np, int *link_up_p)
900 return 0; 899 return 0;
901} 900}
902 901
903
904static int link_status_1g_rgmii(struct niu *np, int *link_up_p) 902static int link_status_1g_rgmii(struct niu *np, int *link_up_p)
905{ 903{
906 struct niu_link_config *lp = &np->link_config; 904 struct niu_link_config *lp = &np->link_config;
@@ -957,7 +955,6 @@ out:
957 return err; 955 return err;
958} 956}
959 957
960
961static int bcm8704_reset(struct niu *np) 958static int bcm8704_reset(struct niu *np)
962{ 959{
963 int err, limit; 960 int err, limit;
@@ -1357,8 +1354,6 @@ static int mii_reset(struct niu *np)
1357 return 0; 1354 return 0;
1358} 1355}
1359 1356
1360
1361
1362static int xcvr_init_1g_rgmii(struct niu *np) 1357static int xcvr_init_1g_rgmii(struct niu *np)
1363{ 1358{
1364 int err; 1359 int err;
@@ -1419,7 +1414,6 @@ static int xcvr_init_1g_rgmii(struct niu *np)
1419 return 0; 1414 return 0;
1420} 1415}
1421 1416
1422
1423static int mii_init_common(struct niu *np) 1417static int mii_init_common(struct niu *np)
1424{ 1418{
1425 struct niu_link_config *lp = &np->link_config; 1419 struct niu_link_config *lp = &np->link_config;
@@ -7008,31 +7002,20 @@ static int __devinit niu_phy_type_prop_decode(struct niu *np,
7008 return 0; 7002 return 0;
7009} 7003}
7010 7004
7011/* niu board models have a trailing dash version incremented
7012 * with HW rev change. Need to ingnore the dash version while
7013 * checking for match
7014 *
7015 * for example, for the 10G card the current vpd.board_model
7016 * is 501-5283-04, of which -04 is the dash version and have
7017 * to be ignored
7018 */
7019static int niu_board_model_match(struct niu *np, const char *model)
7020{
7021 return !strncmp(np->vpd.board_model, model, strlen(model));
7022}
7023
7024static int niu_pci_vpd_get_nports(struct niu *np) 7005static int niu_pci_vpd_get_nports(struct niu *np)
7025{ 7006{
7026 int ports = 0; 7007 int ports = 0;
7027 7008
7028 if ((niu_board_model_match(np, NIU_QGC_LP_BM_STR)) || 7009 if ((!strcmp(np->vpd.model, NIU_QGC_LP_MDL_STR)) ||
7029 (niu_board_model_match(np, NIU_QGC_PEM_BM_STR)) || 7010 (!strcmp(np->vpd.model, NIU_QGC_PEM_MDL_STR)) ||
7030 (niu_board_model_match(np, NIU_ALONSO_BM_STR))) { 7011 (!strcmp(np->vpd.model, NIU_MARAMBA_MDL_STR)) ||
7012 (!strcmp(np->vpd.model, NIU_KIMI_MDL_STR)) ||
7013 (!strcmp(np->vpd.model, NIU_ALONSO_MDL_STR))) {
7031 ports = 4; 7014 ports = 4;
7032 } else if ((niu_board_model_match(np, NIU_2XGF_LP_BM_STR)) || 7015 } else if ((!strcmp(np->vpd.model, NIU_2XGF_LP_MDL_STR)) ||
7033 (niu_board_model_match(np, NIU_2XGF_PEM_BM_STR)) || 7016 (!strcmp(np->vpd.model, NIU_2XGF_PEM_MDL_STR)) ||
7034 (niu_board_model_match(np, NIU_FOXXY_BM_STR)) || 7017 (!strcmp(np->vpd.model, NIU_FOXXY_MDL_STR)) ||
7035 (niu_board_model_match(np, NIU_2XGF_MRVL_BM_STR))) { 7018 (!strcmp(np->vpd.model, NIU_2XGF_MRVL_MDL_STR))) {
7036 ports = 2; 7019 ports = 2;
7037 } 7020 }
7038 7021
@@ -7053,8 +7036,8 @@ static void __devinit niu_pci_vpd_validate(struct niu *np)
7053 return; 7036 return;
7054 } 7037 }
7055 7038
7056 if (!strcmp(np->vpd.model, "SUNW,CP3220") || 7039 if (!strcmp(np->vpd.model, NIU_ALONSO_MDL_STR) ||
7057 !strcmp(np->vpd.model, "SUNW,CP3260")) { 7040 !strcmp(np->vpd.model, NIU_KIMI_MDL_STR)) {
7058 np->flags |= NIU_FLAGS_10G; 7041 np->flags |= NIU_FLAGS_10G;
7059 np->flags &= ~NIU_FLAGS_FIBER; 7042 np->flags &= ~NIU_FLAGS_FIBER;
7060 np->flags |= NIU_FLAGS_XCVR_SERDES; 7043 np->flags |= NIU_FLAGS_XCVR_SERDES;
@@ -7065,7 +7048,7 @@ static void __devinit niu_pci_vpd_validate(struct niu *np)
7065 } 7048 }
7066 if (np->flags & NIU_FLAGS_10G) 7049 if (np->flags & NIU_FLAGS_10G)
7067 np->mac_xcvr = MAC_XCVR_XPCS; 7050 np->mac_xcvr = MAC_XCVR_XPCS;
7068 } else if (niu_board_model_match(np, NIU_FOXXY_BM_STR)) { 7051 } else if (!strcmp(np->vpd.model, NIU_FOXXY_MDL_STR)) {
7069 np->flags |= (NIU_FLAGS_10G | NIU_FLAGS_FIBER | 7052 np->flags |= (NIU_FLAGS_10G | NIU_FLAGS_FIBER |
7070 NIU_FLAGS_HOTPLUG_PHY); 7053 NIU_FLAGS_HOTPLUG_PHY);
7071 } else if (niu_phy_type_prop_decode(np, np->vpd.phy_type)) { 7054 } else if (niu_phy_type_prop_decode(np, np->vpd.phy_type)) {
@@ -7541,8 +7524,8 @@ static int __devinit walk_phys(struct niu *np, struct niu_parent *parent)
7541 u32 val; 7524 u32 val;
7542 int err; 7525 int err;
7543 7526
7544 if (!strcmp(np->vpd.model, "SUNW,CP3220") || 7527 if (!strcmp(np->vpd.model, NIU_ALONSO_MDL_STR) ||
7545 !strcmp(np->vpd.model, "SUNW,CP3260")) { 7528 !strcmp(np->vpd.model, NIU_KIMI_MDL_STR)) {
7546 num_10g = 0; 7529 num_10g = 0;
7547 num_1g = 2; 7530 num_1g = 2;
7548 parent->plat_type = PLAT_TYPE_ATCA_CP3220; 7531 parent->plat_type = PLAT_TYPE_ATCA_CP3220;
@@ -7551,7 +7534,7 @@ static int __devinit walk_phys(struct niu *np, struct niu_parent *parent)
7551 phy_encode(PORT_TYPE_1G, 1) | 7534 phy_encode(PORT_TYPE_1G, 1) |
7552 phy_encode(PORT_TYPE_1G, 2) | 7535 phy_encode(PORT_TYPE_1G, 2) |
7553 phy_encode(PORT_TYPE_1G, 3)); 7536 phy_encode(PORT_TYPE_1G, 3));
7554 } else if (niu_board_model_match(np, NIU_FOXXY_BM_STR)) { 7537 } else if (!strcmp(np->vpd.model, NIU_FOXXY_MDL_STR)) {
7555 num_10g = 2; 7538 num_10g = 2;
7556 num_1g = 0; 7539 num_1g = 0;
7557 parent->num_ports = 2; 7540 parent->num_ports = 2;
@@ -7946,6 +7929,7 @@ static int __devinit niu_get_of_props(struct niu *np)
7946 struct device_node *dp; 7929 struct device_node *dp;
7947 const char *phy_type; 7930 const char *phy_type;
7948 const u8 *mac_addr; 7931 const u8 *mac_addr;
7932 const char *model;
7949 int prop_len; 7933 int prop_len;
7950 7934
7951 if (np->parent->plat_type == PLAT_TYPE_NIU) 7935 if (np->parent->plat_type == PLAT_TYPE_NIU)
@@ -8000,6 +7984,11 @@ static int __devinit niu_get_of_props(struct niu *np)
8000 7984
8001 memcpy(dev->dev_addr, dev->perm_addr, dev->addr_len); 7985 memcpy(dev->dev_addr, dev->perm_addr, dev->addr_len);
8002 7986
7987 model = of_get_property(dp, "model", &prop_len);
7988
7989 if (model)
7990 strcpy(np->vpd.model, model);
7991
8003 return 0; 7992 return 0;
8004#else 7993#else
8005 return -EINVAL; 7994 return -EINVAL;
diff --git a/drivers/net/niu.h b/drivers/net/niu.h
index 97ffbe137bcb..12fd570b9423 100644
--- a/drivers/net/niu.h
+++ b/drivers/net/niu.h
@@ -2946,6 +2946,15 @@ struct rx_ring_info {
2946#define NIU_ALONSO_BM_STR "373-0202" 2946#define NIU_ALONSO_BM_STR "373-0202"
2947#define NIU_FOXXY_BM_STR "501-7961" 2947#define NIU_FOXXY_BM_STR "501-7961"
2948#define NIU_2XGF_MRVL_BM_STR "SK-6E82" 2948#define NIU_2XGF_MRVL_BM_STR "SK-6E82"
2949#define NIU_QGC_LP_MDL_STR "SUNW,pcie-qgc"
2950#define NIU_2XGF_LP_MDL_STR "SUNW,pcie-2xgf"
2951#define NIU_QGC_PEM_MDL_STR "SUNW,pcie-qgc-pem"
2952#define NIU_2XGF_PEM_MDL_STR "SUNW,pcie-2xgf-pem"
2953#define NIU_ALONSO_MDL_STR "SUNW,CP3220"
2954#define NIU_KIMI_MDL_STR "SUNW,CP3260"
2955#define NIU_MARAMBA_MDL_STR "SUNW,pcie-neptune"
2956#define NIU_FOXXY_MDL_STR "SUNW,pcie-rfem"
2957#define NIU_2XGF_MRVL_MDL_STR "SysKonnect,pcie-2xgf"
2949 2958
2950#define NIU_VPD_MIN_MAJOR 3 2959#define NIU_VPD_MIN_MAJOR 3
2951#define NIU_VPD_MIN_MINOR 4 2960#define NIU_VPD_MIN_MINOR 4
diff --git a/drivers/net/ppp_generic.c b/drivers/net/ppp_generic.c
index d3207c0da895..1f4ca2b54a73 100644
--- a/drivers/net/ppp_generic.c
+++ b/drivers/net/ppp_generic.c
@@ -2458,6 +2458,7 @@ ppp_create_interface(int unit, int *retp)
2458 2458
2459out3: 2459out3:
2460 atomic_dec(&ppp_unit_count); 2460 atomic_dec(&ppp_unit_count);
2461 unregister_netdev(dev);
2461out2: 2462out2:
2462 mutex_unlock(&all_ppp_mutex); 2463 mutex_unlock(&all_ppp_mutex);
2463 free_netdev(dev); 2464 free_netdev(dev);
diff --git a/drivers/net/pppol2tp.c b/drivers/net/pppol2tp.c
index 244d7830c92a..79359919335b 100644
--- a/drivers/net/pppol2tp.c
+++ b/drivers/net/pppol2tp.c
@@ -1621,9 +1621,16 @@ out_no_ppp:
1621end: 1621end:
1622 release_sock(sk); 1622 release_sock(sk);
1623 1623
1624 if (error != 0) 1624 if (error != 0) {
1625 PRINTK(session ? session->debug : -1, PPPOL2TP_MSG_CONTROL, KERN_WARNING, 1625 if (session)
1626 "%s: connect failed: %d\n", session->name, error); 1626 PRINTK(session->debug,
1627 PPPOL2TP_MSG_CONTROL, KERN_WARNING,
1628 "%s: connect failed: %d\n",
1629 session->name, error);
1630 else
1631 PRINTK(-1, PPPOL2TP_MSG_CONTROL, KERN_WARNING,
1632 "connect failed: %d\n", error);
1633 }
1627 1634
1628 return error; 1635 return error;
1629} 1636}
diff --git a/drivers/net/ps3_gelic_wireless.c b/drivers/net/ps3_gelic_wireless.c
index 0d32123085e9..1dae1f2ed813 100644
--- a/drivers/net/ps3_gelic_wireless.c
+++ b/drivers/net/ps3_gelic_wireless.c
@@ -2474,6 +2474,8 @@ static void gelic_wl_free(struct gelic_wl_info *wl)
2474 2474
2475 pr_debug("%s: <-\n", __func__); 2475 pr_debug("%s: <-\n", __func__);
2476 2476
2477 free_page((unsigned long)wl->buf);
2478
2477 pr_debug("%s: destroy queues\n", __func__); 2479 pr_debug("%s: destroy queues\n", __func__);
2478 destroy_workqueue(wl->eurus_cmd_queue); 2480 destroy_workqueue(wl->eurus_cmd_queue);
2479 destroy_workqueue(wl->event_queue); 2481 destroy_workqueue(wl->event_queue);
diff --git a/drivers/net/sfc/Makefile b/drivers/net/sfc/Makefile
index 0f023447eafd..1d2daeec7ac1 100644
--- a/drivers/net/sfc/Makefile
+++ b/drivers/net/sfc/Makefile
@@ -1,5 +1,5 @@
1sfc-y += efx.o falcon.o tx.o rx.o falcon_xmac.o \ 1sfc-y += efx.o falcon.o tx.o rx.o falcon_xmac.o \
2 i2c-direct.o ethtool.o xfp_phy.o mdio_10g.o \ 2 i2c-direct.o selftest.o ethtool.o xfp_phy.o \
3 tenxpress.o boards.o sfe4001.o 3 mdio_10g.o tenxpress.o boards.o sfe4001.o
4 4
5obj-$(CONFIG_SFC) += sfc.o 5obj-$(CONFIG_SFC) += sfc.o
diff --git a/drivers/net/sfc/boards.h b/drivers/net/sfc/boards.h
index f56341d428e1..695764dc2e64 100644
--- a/drivers/net/sfc/boards.h
+++ b/drivers/net/sfc/boards.h
@@ -22,5 +22,7 @@ enum efx_board_type {
22extern int efx_set_board_info(struct efx_nic *efx, u16 revision_info); 22extern int efx_set_board_info(struct efx_nic *efx, u16 revision_info);
23extern int sfe4001_poweron(struct efx_nic *efx); 23extern int sfe4001_poweron(struct efx_nic *efx);
24extern void sfe4001_poweroff(struct efx_nic *efx); 24extern void sfe4001_poweroff(struct efx_nic *efx);
25/* Are we putting the PHY into flash config mode */
26extern unsigned int sfe4001_phy_flash_cfg;
25 27
26#endif 28#endif
diff --git a/drivers/net/sfc/efx.c b/drivers/net/sfc/efx.c
index 59edcf793c19..418f2e53a95b 100644
--- a/drivers/net/sfc/efx.c
+++ b/drivers/net/sfc/efx.c
@@ -1873,6 +1873,7 @@ static int efx_init_struct(struct efx_nic *efx, struct efx_nic_type *type,
1873 tx_queue->queue = i; 1873 tx_queue->queue = i;
1874 tx_queue->buffer = NULL; 1874 tx_queue->buffer = NULL;
1875 tx_queue->channel = &efx->channel[0]; /* for safety */ 1875 tx_queue->channel = &efx->channel[0]; /* for safety */
1876 tx_queue->tso_headers_free = NULL;
1876 } 1877 }
1877 for (i = 0; i < EFX_MAX_RX_QUEUES; i++) { 1878 for (i = 0; i < EFX_MAX_RX_QUEUES; i++) {
1878 rx_queue = &efx->rx_queue[i]; 1879 rx_queue = &efx->rx_queue[i];
@@ -2071,7 +2072,8 @@ static int __devinit efx_pci_probe(struct pci_dev *pci_dev,
2071 net_dev = alloc_etherdev(sizeof(*efx)); 2072 net_dev = alloc_etherdev(sizeof(*efx));
2072 if (!net_dev) 2073 if (!net_dev)
2073 return -ENOMEM; 2074 return -ENOMEM;
2074 net_dev->features |= NETIF_F_IP_CSUM | NETIF_F_SG | NETIF_F_HIGHDMA; 2075 net_dev->features |= (NETIF_F_IP_CSUM | NETIF_F_SG |
2076 NETIF_F_HIGHDMA | NETIF_F_TSO);
2075 if (lro) 2077 if (lro)
2076 net_dev->features |= NETIF_F_LRO; 2078 net_dev->features |= NETIF_F_LRO;
2077 efx = net_dev->priv; 2079 efx = net_dev->priv;
diff --git a/drivers/net/sfc/enum.h b/drivers/net/sfc/enum.h
index 43663a4619da..c53290d08e2b 100644
--- a/drivers/net/sfc/enum.h
+++ b/drivers/net/sfc/enum.h
@@ -10,6 +10,55 @@
10#ifndef EFX_ENUM_H 10#ifndef EFX_ENUM_H
11#define EFX_ENUM_H 11#define EFX_ENUM_H
12 12
13/**
14 * enum efx_loopback_mode - loopback modes
15 * @LOOPBACK_NONE: no loopback
16 * @LOOPBACK_XGMII: loopback within MAC at XGMII level
17 * @LOOPBACK_XGXS: loopback within MAC at XGXS level
18 * @LOOPBACK_XAUI: loopback within MAC at XAUI level
19 * @LOOPBACK_PHYXS: loopback within PHY at PHYXS level
20 * @LOOPBACK_PCS: loopback within PHY at PCS level
21 * @LOOPBACK_PMAPMD: loopback within PHY at PMAPMD level
22 * @LOOPBACK_NETWORK: reflecting loopback (even further than furthest!)
23 */
24/* Please keep in order and up-to-date w.r.t the following two #defines */
25enum efx_loopback_mode {
26 LOOPBACK_NONE = 0,
27 LOOPBACK_MAC = 1,
28 LOOPBACK_XGMII = 2,
29 LOOPBACK_XGXS = 3,
30 LOOPBACK_XAUI = 4,
31 LOOPBACK_PHY = 5,
32 LOOPBACK_PHYXS = 6,
33 LOOPBACK_PCS = 7,
34 LOOPBACK_PMAPMD = 8,
35 LOOPBACK_NETWORK = 9,
36 LOOPBACK_MAX
37};
38
39#define LOOPBACK_TEST_MAX LOOPBACK_PMAPMD
40
41extern const char *efx_loopback_mode_names[];
42#define LOOPBACK_MODE_NAME(mode) \
43 STRING_TABLE_LOOKUP(mode, efx_loopback_mode)
44#define LOOPBACK_MODE(efx) \
45 LOOPBACK_MODE_NAME(efx->loopback_mode)
46
47/* These loopbacks occur within the controller */
48#define LOOPBACKS_10G_INTERNAL ((1 << LOOPBACK_XGMII)| \
49 (1 << LOOPBACK_XGXS) | \
50 (1 << LOOPBACK_XAUI))
51
52#define LOOPBACK_MASK(_efx) \
53 (1 << (_efx)->loopback_mode)
54
55#define LOOPBACK_INTERNAL(_efx) \
56 ((LOOPBACKS_10G_INTERNAL & LOOPBACK_MASK(_efx)) ? 1 : 0)
57
58#define LOOPBACK_OUT_OF(_from, _to, _mask) \
59 (((LOOPBACK_MASK(_from) & (_mask)) && \
60 ((LOOPBACK_MASK(_to) & (_mask)) == 0)) ? 1 : 0)
61
13/*****************************************************************************/ 62/*****************************************************************************/
14 63
15/** 64/**
diff --git a/drivers/net/sfc/ethtool.c b/drivers/net/sfc/ethtool.c
index ad541badbd98..e2c75d101610 100644
--- a/drivers/net/sfc/ethtool.c
+++ b/drivers/net/sfc/ethtool.c
@@ -12,12 +12,26 @@
12#include <linux/ethtool.h> 12#include <linux/ethtool.h>
13#include <linux/rtnetlink.h> 13#include <linux/rtnetlink.h>
14#include "net_driver.h" 14#include "net_driver.h"
15#include "selftest.h"
15#include "efx.h" 16#include "efx.h"
16#include "ethtool.h" 17#include "ethtool.h"
17#include "falcon.h" 18#include "falcon.h"
18#include "gmii.h" 19#include "gmii.h"
19#include "mac.h" 20#include "mac.h"
20 21
22const char *efx_loopback_mode_names[] = {
23 [LOOPBACK_NONE] = "NONE",
24 [LOOPBACK_MAC] = "MAC",
25 [LOOPBACK_XGMII] = "XGMII",
26 [LOOPBACK_XGXS] = "XGXS",
27 [LOOPBACK_XAUI] = "XAUI",
28 [LOOPBACK_PHY] = "PHY",
29 [LOOPBACK_PHYXS] = "PHY(XS)",
30 [LOOPBACK_PCS] = "PHY(PCS)",
31 [LOOPBACK_PMAPMD] = "PHY(PMAPMD)",
32 [LOOPBACK_NETWORK] = "NETWORK",
33};
34
21static int efx_ethtool_set_tx_csum(struct net_device *net_dev, u32 enable); 35static int efx_ethtool_set_tx_csum(struct net_device *net_dev, u32 enable);
22 36
23struct ethtool_string { 37struct ethtool_string {
@@ -217,23 +231,179 @@ static void efx_ethtool_get_drvinfo(struct net_device *net_dev,
217 strlcpy(info->bus_info, pci_name(efx->pci_dev), sizeof(info->bus_info)); 231 strlcpy(info->bus_info, pci_name(efx->pci_dev), sizeof(info->bus_info));
218} 232}
219 233
234/**
235 * efx_fill_test - fill in an individual self-test entry
236 * @test_index: Index of the test
237 * @strings: Ethtool strings, or %NULL
238 * @data: Ethtool test results, or %NULL
239 * @test: Pointer to test result (used only if data != %NULL)
240 * @unit_format: Unit name format (e.g. "channel\%d")
241 * @unit_id: Unit id (e.g. 0 for "channel0")
242 * @test_format: Test name format (e.g. "loopback.\%s.tx.sent")
243 * @test_id: Test id (e.g. "PHY" for "loopback.PHY.tx_sent")
244 *
245 * Fill in an individual self-test entry.
246 */
247static void efx_fill_test(unsigned int test_index,
248 struct ethtool_string *strings, u64 *data,
249 int *test, const char *unit_format, int unit_id,
250 const char *test_format, const char *test_id)
251{
252 struct ethtool_string unit_str, test_str;
253
254 /* Fill data value, if applicable */
255 if (data)
256 data[test_index] = *test;
257
258 /* Fill string, if applicable */
259 if (strings) {
260 snprintf(unit_str.name, sizeof(unit_str.name),
261 unit_format, unit_id);
262 snprintf(test_str.name, sizeof(test_str.name),
263 test_format, test_id);
264 snprintf(strings[test_index].name,
265 sizeof(strings[test_index].name),
266 "%-9s%-17s", unit_str.name, test_str.name);
267 }
268}
269
270#define EFX_PORT_NAME "port%d", 0
271#define EFX_CHANNEL_NAME(_channel) "channel%d", _channel->channel
272#define EFX_TX_QUEUE_NAME(_tx_queue) "txq%d", _tx_queue->queue
273#define EFX_RX_QUEUE_NAME(_rx_queue) "rxq%d", _rx_queue->queue
274#define EFX_LOOPBACK_NAME(_mode, _counter) \
275 "loopback.%s." _counter, LOOPBACK_MODE_NAME(mode)
276
277/**
278 * efx_fill_loopback_test - fill in a block of loopback self-test entries
279 * @efx: Efx NIC
280 * @lb_tests: Efx loopback self-test results structure
281 * @mode: Loopback test mode
282 * @test_index: Starting index of the test
283 * @strings: Ethtool strings, or %NULL
284 * @data: Ethtool test results, or %NULL
285 */
286static int efx_fill_loopback_test(struct efx_nic *efx,
287 struct efx_loopback_self_tests *lb_tests,
288 enum efx_loopback_mode mode,
289 unsigned int test_index,
290 struct ethtool_string *strings, u64 *data)
291{
292 struct efx_tx_queue *tx_queue;
293
294 efx_for_each_tx_queue(tx_queue, efx) {
295 efx_fill_test(test_index++, strings, data,
296 &lb_tests->tx_sent[tx_queue->queue],
297 EFX_TX_QUEUE_NAME(tx_queue),
298 EFX_LOOPBACK_NAME(mode, "tx_sent"));
299 efx_fill_test(test_index++, strings, data,
300 &lb_tests->tx_done[tx_queue->queue],
301 EFX_TX_QUEUE_NAME(tx_queue),
302 EFX_LOOPBACK_NAME(mode, "tx_done"));
303 }
304 efx_fill_test(test_index++, strings, data,
305 &lb_tests->rx_good,
306 EFX_PORT_NAME,
307 EFX_LOOPBACK_NAME(mode, "rx_good"));
308 efx_fill_test(test_index++, strings, data,
309 &lb_tests->rx_bad,
310 EFX_PORT_NAME,
311 EFX_LOOPBACK_NAME(mode, "rx_bad"));
312
313 return test_index;
314}
315
316/**
317 * efx_ethtool_fill_self_tests - get self-test details
318 * @efx: Efx NIC
319 * @tests: Efx self-test results structure, or %NULL
320 * @strings: Ethtool strings, or %NULL
321 * @data: Ethtool test results, or %NULL
322 */
323static int efx_ethtool_fill_self_tests(struct efx_nic *efx,
324 struct efx_self_tests *tests,
325 struct ethtool_string *strings,
326 u64 *data)
327{
328 struct efx_channel *channel;
329 unsigned int n = 0;
330 enum efx_loopback_mode mode;
331
332 /* Interrupt */
333 efx_fill_test(n++, strings, data, &tests->interrupt,
334 "core", 0, "interrupt", NULL);
335
336 /* Event queues */
337 efx_for_each_channel(channel, efx) {
338 efx_fill_test(n++, strings, data,
339 &tests->eventq_dma[channel->channel],
340 EFX_CHANNEL_NAME(channel),
341 "eventq.dma", NULL);
342 efx_fill_test(n++, strings, data,
343 &tests->eventq_int[channel->channel],
344 EFX_CHANNEL_NAME(channel),
345 "eventq.int", NULL);
346 efx_fill_test(n++, strings, data,
347 &tests->eventq_poll[channel->channel],
348 EFX_CHANNEL_NAME(channel),
349 "eventq.poll", NULL);
350 }
351
352 /* PHY presence */
353 efx_fill_test(n++, strings, data, &tests->phy_ok,
354 EFX_PORT_NAME, "phy_ok", NULL);
355
356 /* Loopback tests */
357 efx_fill_test(n++, strings, data, &tests->loopback_speed,
358 EFX_PORT_NAME, "loopback.speed", NULL);
359 efx_fill_test(n++, strings, data, &tests->loopback_full_duplex,
360 EFX_PORT_NAME, "loopback.full_duplex", NULL);
361 for (mode = LOOPBACK_NONE; mode < LOOPBACK_TEST_MAX; mode++) {
362 if (!(efx->loopback_modes & (1 << mode)))
363 continue;
364 n = efx_fill_loopback_test(efx,
365 &tests->loopback[mode], mode, n,
366 strings, data);
367 }
368
369 return n;
370}
371
220static int efx_ethtool_get_stats_count(struct net_device *net_dev) 372static int efx_ethtool_get_stats_count(struct net_device *net_dev)
221{ 373{
222 return EFX_ETHTOOL_NUM_STATS; 374 return EFX_ETHTOOL_NUM_STATS;
223} 375}
224 376
377static int efx_ethtool_self_test_count(struct net_device *net_dev)
378{
379 struct efx_nic *efx = net_dev->priv;
380
381 return efx_ethtool_fill_self_tests(efx, NULL, NULL, NULL);
382}
383
225static void efx_ethtool_get_strings(struct net_device *net_dev, 384static void efx_ethtool_get_strings(struct net_device *net_dev,
226 u32 string_set, u8 *strings) 385 u32 string_set, u8 *strings)
227{ 386{
387 struct efx_nic *efx = net_dev->priv;
228 struct ethtool_string *ethtool_strings = 388 struct ethtool_string *ethtool_strings =
229 (struct ethtool_string *)strings; 389 (struct ethtool_string *)strings;
230 int i; 390 int i;
231 391
232 if (string_set == ETH_SS_STATS) 392 switch (string_set) {
393 case ETH_SS_STATS:
233 for (i = 0; i < EFX_ETHTOOL_NUM_STATS; i++) 394 for (i = 0; i < EFX_ETHTOOL_NUM_STATS; i++)
234 strncpy(ethtool_strings[i].name, 395 strncpy(ethtool_strings[i].name,
235 efx_ethtool_stats[i].name, 396 efx_ethtool_stats[i].name,
236 sizeof(ethtool_strings[i].name)); 397 sizeof(ethtool_strings[i].name));
398 break;
399 case ETH_SS_TEST:
400 efx_ethtool_fill_self_tests(efx, NULL,
401 ethtool_strings, NULL);
402 break;
403 default:
404 /* No other string sets */
405 break;
406 }
237} 407}
238 408
239static void efx_ethtool_get_stats(struct net_device *net_dev, 409static void efx_ethtool_get_stats(struct net_device *net_dev,
@@ -272,6 +442,22 @@ static void efx_ethtool_get_stats(struct net_device *net_dev,
272 } 442 }
273} 443}
274 444
445static int efx_ethtool_set_tso(struct net_device *net_dev, u32 enable)
446{
447 int rc;
448
449 /* Our TSO requires TX checksumming, so force TX checksumming
450 * on when TSO is enabled.
451 */
452 if (enable) {
453 rc = efx_ethtool_set_tx_csum(net_dev, 1);
454 if (rc)
455 return rc;
456 }
457
458 return ethtool_op_set_tso(net_dev, enable);
459}
460
275static int efx_ethtool_set_tx_csum(struct net_device *net_dev, u32 enable) 461static int efx_ethtool_set_tx_csum(struct net_device *net_dev, u32 enable)
276{ 462{
277 struct efx_nic *efx = net_dev->priv; 463 struct efx_nic *efx = net_dev->priv;
@@ -283,6 +469,15 @@ static int efx_ethtool_set_tx_csum(struct net_device *net_dev, u32 enable)
283 469
284 efx_flush_queues(efx); 470 efx_flush_queues(efx);
285 471
472 /* Our TSO requires TX checksumming, so disable TSO when
473 * checksumming is disabled
474 */
475 if (!enable) {
476 rc = efx_ethtool_set_tso(net_dev, 0);
477 if (rc)
478 return rc;
479 }
480
286 return 0; 481 return 0;
287} 482}
288 483
@@ -305,6 +500,64 @@ static u32 efx_ethtool_get_rx_csum(struct net_device *net_dev)
305 return efx->rx_checksum_enabled; 500 return efx->rx_checksum_enabled;
306} 501}
307 502
503static void efx_ethtool_self_test(struct net_device *net_dev,
504 struct ethtool_test *test, u64 *data)
505{
506 struct efx_nic *efx = net_dev->priv;
507 struct efx_self_tests efx_tests;
508 int offline, already_up;
509 int rc;
510
511 ASSERT_RTNL();
512 if (efx->state != STATE_RUNNING) {
513 rc = -EIO;
514 goto fail1;
515 }
516
517 /* We need rx buffers and interrupts. */
518 already_up = (efx->net_dev->flags & IFF_UP);
519 if (!already_up) {
520 rc = dev_open(efx->net_dev);
521 if (rc) {
522 EFX_ERR(efx, "failed opening device.\n");
523 goto fail2;
524 }
525 }
526
527 memset(&efx_tests, 0, sizeof(efx_tests));
528 offline = (test->flags & ETH_TEST_FL_OFFLINE);
529
530 /* Perform online self tests first */
531 rc = efx_online_test(efx, &efx_tests);
532 if (rc)
533 goto out;
534
535 /* Perform offline tests only if online tests passed */
536 if (offline) {
537 /* Stop the kernel from sending packets during the test. */
538 efx_stop_queue(efx);
539 rc = efx_flush_queues(efx);
540 if (!rc)
541 rc = efx_offline_test(efx, &efx_tests,
542 efx->loopback_modes);
543 efx_wake_queue(efx);
544 }
545
546 out:
547 if (!already_up)
548 dev_close(efx->net_dev);
549
550 EFX_LOG(efx, "%s all %sline self-tests\n",
551 rc == 0 ? "passed" : "failed", offline ? "off" : "on");
552
553 fail2:
554 fail1:
555 /* Fill ethtool results structures */
556 efx_ethtool_fill_self_tests(efx, &efx_tests, NULL, data);
557 if (rc)
558 test->flags |= ETH_TEST_FL_FAILED;
559}
560
308/* Restart autonegotiation */ 561/* Restart autonegotiation */
309static int efx_ethtool_nway_reset(struct net_device *net_dev) 562static int efx_ethtool_nway_reset(struct net_device *net_dev)
310{ 563{
@@ -451,8 +704,12 @@ struct ethtool_ops efx_ethtool_ops = {
451 .set_tx_csum = efx_ethtool_set_tx_csum, 704 .set_tx_csum = efx_ethtool_set_tx_csum,
452 .get_sg = ethtool_op_get_sg, 705 .get_sg = ethtool_op_get_sg,
453 .set_sg = ethtool_op_set_sg, 706 .set_sg = ethtool_op_set_sg,
707 .get_tso = ethtool_op_get_tso,
708 .set_tso = efx_ethtool_set_tso,
454 .get_flags = ethtool_op_get_flags, 709 .get_flags = ethtool_op_get_flags,
455 .set_flags = ethtool_op_set_flags, 710 .set_flags = ethtool_op_set_flags,
711 .self_test_count = efx_ethtool_self_test_count,
712 .self_test = efx_ethtool_self_test,
456 .get_strings = efx_ethtool_get_strings, 713 .get_strings = efx_ethtool_get_strings,
457 .phys_id = efx_ethtool_phys_id, 714 .phys_id = efx_ethtool_phys_id,
458 .get_stats_count = efx_ethtool_get_stats_count, 715 .get_stats_count = efx_ethtool_get_stats_count,
diff --git a/drivers/net/sfc/falcon.c b/drivers/net/sfc/falcon.c
index 46db549ce580..b57cc68058c0 100644
--- a/drivers/net/sfc/falcon.c
+++ b/drivers/net/sfc/falcon.c
@@ -1129,6 +1129,7 @@ static void falcon_handle_driver_event(struct efx_channel *channel,
1129 case RX_RECOVERY_EV_DECODE: 1129 case RX_RECOVERY_EV_DECODE:
1130 EFX_ERR(efx, "channel %d seen DRIVER RX_RESET event. " 1130 EFX_ERR(efx, "channel %d seen DRIVER RX_RESET event. "
1131 "Resetting.\n", channel->channel); 1131 "Resetting.\n", channel->channel);
1132 atomic_inc(&efx->rx_reset);
1132 efx_schedule_reset(efx, 1133 efx_schedule_reset(efx,
1133 EFX_WORKAROUND_6555(efx) ? 1134 EFX_WORKAROUND_6555(efx) ?
1134 RESET_TYPE_RX_RECOVERY : 1135 RESET_TYPE_RX_RECOVERY :
@@ -1731,7 +1732,8 @@ void falcon_drain_tx_fifo(struct efx_nic *efx)
1731 efx_oword_t temp; 1732 efx_oword_t temp;
1732 int count; 1733 int count;
1733 1734
1734 if (FALCON_REV(efx) < FALCON_REV_B0) 1735 if ((FALCON_REV(efx) < FALCON_REV_B0) ||
1736 (efx->loopback_mode != LOOPBACK_NONE))
1735 return; 1737 return;
1736 1738
1737 falcon_read(efx, &temp, MAC0_CTRL_REG_KER); 1739 falcon_read(efx, &temp, MAC0_CTRL_REG_KER);
@@ -2091,6 +2093,8 @@ static int falcon_probe_phy(struct efx_nic *efx)
2091 efx->phy_type); 2093 efx->phy_type);
2092 return -1; 2094 return -1;
2093 } 2095 }
2096
2097 efx->loopback_modes = LOOPBACKS_10G_INTERNAL | efx->phy_op->loopbacks;
2094 return 0; 2098 return 0;
2095} 2099}
2096 2100
@@ -2468,14 +2472,12 @@ int falcon_probe_nic(struct efx_nic *efx)
2468 fail5: 2472 fail5:
2469 falcon_free_buffer(efx, &efx->irq_status); 2473 falcon_free_buffer(efx, &efx->irq_status);
2470 fail4: 2474 fail4:
2471 /* fall-thru */
2472 fail3: 2475 fail3:
2473 if (nic_data->pci_dev2) { 2476 if (nic_data->pci_dev2) {
2474 pci_dev_put(nic_data->pci_dev2); 2477 pci_dev_put(nic_data->pci_dev2);
2475 nic_data->pci_dev2 = NULL; 2478 nic_data->pci_dev2 = NULL;
2476 } 2479 }
2477 fail2: 2480 fail2:
2478 /* fall-thru */
2479 fail1: 2481 fail1:
2480 kfree(efx->nic_data); 2482 kfree(efx->nic_data);
2481 return rc; 2483 return rc;
diff --git a/drivers/net/sfc/falcon_hwdefs.h b/drivers/net/sfc/falcon_hwdefs.h
index 0485a63eaff6..06e2d68fc3d1 100644
--- a/drivers/net/sfc/falcon_hwdefs.h
+++ b/drivers/net/sfc/falcon_hwdefs.h
@@ -636,6 +636,14 @@
636#define XX_HIDRVA_WIDTH 1 636#define XX_HIDRVA_WIDTH 1
637#define XX_LODRVA_LBN 8 637#define XX_LODRVA_LBN 8
638#define XX_LODRVA_WIDTH 1 638#define XX_LODRVA_WIDTH 1
639#define XX_LPBKD_LBN 3
640#define XX_LPBKD_WIDTH 1
641#define XX_LPBKC_LBN 2
642#define XX_LPBKC_WIDTH 1
643#define XX_LPBKB_LBN 1
644#define XX_LPBKB_WIDTH 1
645#define XX_LPBKA_LBN 0
646#define XX_LPBKA_WIDTH 1
639 647
640#define XX_TXDRV_CTL_REG_MAC 0x12 648#define XX_TXDRV_CTL_REG_MAC 0x12
641#define XX_DEQD_LBN 28 649#define XX_DEQD_LBN 28
@@ -656,8 +664,14 @@
656#define XX_DTXA_WIDTH 4 664#define XX_DTXA_WIDTH 4
657 665
658/* XAUI XGXS core status register */ 666/* XAUI XGXS core status register */
659#define XX_FORCE_SIG_DECODE_FORCED 0xff
660#define XX_CORE_STAT_REG_MAC 0x16 667#define XX_CORE_STAT_REG_MAC 0x16
668#define XX_FORCE_SIG_LBN 24
669#define XX_FORCE_SIG_WIDTH 8
670#define XX_FORCE_SIG_DECODE_FORCED 0xff
671#define XX_XGXS_LB_EN_LBN 23
672#define XX_XGXS_LB_EN_WIDTH 1
673#define XX_XGMII_LB_EN_LBN 22
674#define XX_XGMII_LB_EN_WIDTH 1
661#define XX_ALIGN_DONE_LBN 20 675#define XX_ALIGN_DONE_LBN 20
662#define XX_ALIGN_DONE_WIDTH 1 676#define XX_ALIGN_DONE_WIDTH 1
663#define XX_SYNC_STAT_LBN 16 677#define XX_SYNC_STAT_LBN 16
diff --git a/drivers/net/sfc/falcon_xmac.c b/drivers/net/sfc/falcon_xmac.c
index aa7521b24a5d..a74b7931a3c4 100644
--- a/drivers/net/sfc/falcon_xmac.c
+++ b/drivers/net/sfc/falcon_xmac.c
@@ -32,7 +32,7 @@
32 (FALCON_XMAC_REGBANK + ((mac_reg) * FALCON_XMAC_REG_SIZE)) 32 (FALCON_XMAC_REGBANK + ((mac_reg) * FALCON_XMAC_REG_SIZE))
33 33
34void falcon_xmac_writel(struct efx_nic *efx, 34void falcon_xmac_writel(struct efx_nic *efx,
35 efx_dword_t *value, unsigned int mac_reg) 35 efx_dword_t *value, unsigned int mac_reg)
36{ 36{
37 efx_oword_t temp; 37 efx_oword_t temp;
38 38
@@ -69,6 +69,10 @@ static int falcon_reset_xmac(struct efx_nic *efx)
69 udelay(10); 69 udelay(10);
70 } 70 }
71 71
72 /* This often fails when DSP is disabled, ignore it */
73 if (sfe4001_phy_flash_cfg != 0)
74 return 0;
75
72 EFX_ERR(efx, "timed out waiting for XMAC core reset\n"); 76 EFX_ERR(efx, "timed out waiting for XMAC core reset\n");
73 return -ETIMEDOUT; 77 return -ETIMEDOUT;
74} 78}
@@ -223,7 +227,7 @@ static int falcon_xgmii_status(struct efx_nic *efx)
223 /* The ISR latches, so clear it and re-read */ 227 /* The ISR latches, so clear it and re-read */
224 falcon_xmac_readl(efx, &reg, XM_MGT_INT_REG_MAC_B0); 228 falcon_xmac_readl(efx, &reg, XM_MGT_INT_REG_MAC_B0);
225 falcon_xmac_readl(efx, &reg, XM_MGT_INT_REG_MAC_B0); 229 falcon_xmac_readl(efx, &reg, XM_MGT_INT_REG_MAC_B0);
226 230
227 if (EFX_DWORD_FIELD(reg, XM_LCLFLT) || 231 if (EFX_DWORD_FIELD(reg, XM_LCLFLT) ||
228 EFX_DWORD_FIELD(reg, XM_RMTFLT)) { 232 EFX_DWORD_FIELD(reg, XM_RMTFLT)) {
229 EFX_INFO(efx, "MGT_INT: "EFX_DWORD_FMT"\n", EFX_DWORD_VAL(reg)); 233 EFX_INFO(efx, "MGT_INT: "EFX_DWORD_FMT"\n", EFX_DWORD_VAL(reg));
@@ -237,7 +241,7 @@ static void falcon_mask_status_intr(struct efx_nic *efx, int enable)
237{ 241{
238 efx_dword_t reg; 242 efx_dword_t reg;
239 243
240 if (FALCON_REV(efx) < FALCON_REV_B0) 244 if ((FALCON_REV(efx) < FALCON_REV_B0) || LOOPBACK_INTERNAL(efx))
241 return; 245 return;
242 246
243 /* Flush the ISR */ 247 /* Flush the ISR */
@@ -284,6 +288,9 @@ int falcon_xaui_link_ok(struct efx_nic *efx)
284 efx_dword_t reg; 288 efx_dword_t reg;
285 int align_done, sync_status, link_ok = 0; 289 int align_done, sync_status, link_ok = 0;
286 290
291 if (LOOPBACK_INTERNAL(efx))
292 return 1;
293
287 /* Read link status */ 294 /* Read link status */
288 falcon_xmac_readl(efx, &reg, XX_CORE_STAT_REG_MAC); 295 falcon_xmac_readl(efx, &reg, XX_CORE_STAT_REG_MAC);
289 296
@@ -374,6 +381,61 @@ static void falcon_reconfigure_xmac_core(struct efx_nic *efx)
374 falcon_xmac_writel(efx, &reg, XM_ADR_HI_REG_MAC); 381 falcon_xmac_writel(efx, &reg, XM_ADR_HI_REG_MAC);
375} 382}
376 383
384static void falcon_reconfigure_xgxs_core(struct efx_nic *efx)
385{
386 efx_dword_t reg;
387 int xgxs_loopback = (efx->loopback_mode == LOOPBACK_XGXS) ? 1 : 0;
388 int xaui_loopback = (efx->loopback_mode == LOOPBACK_XAUI) ? 1 : 0;
389 int xgmii_loopback =
390 (efx->loopback_mode == LOOPBACK_XGMII) ? 1 : 0;
391
392 /* XGXS block is flaky and will need to be reset if moving
393 * into our out of XGMII, XGXS or XAUI loopbacks. */
394 if (EFX_WORKAROUND_5147(efx)) {
395 int old_xgmii_loopback, old_xgxs_loopback, old_xaui_loopback;
396 int reset_xgxs;
397
398 falcon_xmac_readl(efx, &reg, XX_CORE_STAT_REG_MAC);
399 old_xgxs_loopback = EFX_DWORD_FIELD(reg, XX_XGXS_LB_EN);
400 old_xgmii_loopback = EFX_DWORD_FIELD(reg, XX_XGMII_LB_EN);
401
402 falcon_xmac_readl(efx, &reg, XX_SD_CTL_REG_MAC);
403 old_xaui_loopback = EFX_DWORD_FIELD(reg, XX_LPBKA);
404
405 /* The PHY driver may have turned XAUI off */
406 reset_xgxs = ((xgxs_loopback != old_xgxs_loopback) ||
407 (xaui_loopback != old_xaui_loopback) ||
408 (xgmii_loopback != old_xgmii_loopback));
409 if (reset_xgxs) {
410 falcon_xmac_readl(efx, &reg, XX_PWR_RST_REG_MAC);
411 EFX_SET_DWORD_FIELD(reg, XX_RSTXGXSTX_EN, 1);
412 EFX_SET_DWORD_FIELD(reg, XX_RSTXGXSRX_EN, 1);
413 falcon_xmac_writel(efx, &reg, XX_PWR_RST_REG_MAC);
414 udelay(1);
415 EFX_SET_DWORD_FIELD(reg, XX_RSTXGXSTX_EN, 0);
416 EFX_SET_DWORD_FIELD(reg, XX_RSTXGXSRX_EN, 0);
417 falcon_xmac_writel(efx, &reg, XX_PWR_RST_REG_MAC);
418 udelay(1);
419 }
420 }
421
422 falcon_xmac_readl(efx, &reg, XX_CORE_STAT_REG_MAC);
423 EFX_SET_DWORD_FIELD(reg, XX_FORCE_SIG,
424 (xgxs_loopback || xaui_loopback) ?
425 XX_FORCE_SIG_DECODE_FORCED : 0);
426 EFX_SET_DWORD_FIELD(reg, XX_XGXS_LB_EN, xgxs_loopback);
427 EFX_SET_DWORD_FIELD(reg, XX_XGMII_LB_EN, xgmii_loopback);
428 falcon_xmac_writel(efx, &reg, XX_CORE_STAT_REG_MAC);
429
430 falcon_xmac_readl(efx, &reg, XX_SD_CTL_REG_MAC);
431 EFX_SET_DWORD_FIELD(reg, XX_LPBKD, xaui_loopback);
432 EFX_SET_DWORD_FIELD(reg, XX_LPBKC, xaui_loopback);
433 EFX_SET_DWORD_FIELD(reg, XX_LPBKB, xaui_loopback);
434 EFX_SET_DWORD_FIELD(reg, XX_LPBKA, xaui_loopback);
435 falcon_xmac_writel(efx, &reg, XX_SD_CTL_REG_MAC);
436}
437
438
377/* Try and bring the Falcon side of the Falcon-Phy XAUI link fails 439/* Try and bring the Falcon side of the Falcon-Phy XAUI link fails
378 * to come back up. Bash it until it comes back up */ 440 * to come back up. Bash it until it comes back up */
379static int falcon_check_xaui_link_up(struct efx_nic *efx) 441static int falcon_check_xaui_link_up(struct efx_nic *efx)
@@ -382,7 +444,8 @@ static int falcon_check_xaui_link_up(struct efx_nic *efx)
382 tries = EFX_WORKAROUND_5147(efx) ? 5 : 1; 444 tries = EFX_WORKAROUND_5147(efx) ? 5 : 1;
383 max_tries = tries; 445 max_tries = tries;
384 446
385 if (efx->phy_type == PHY_TYPE_NONE) 447 if ((efx->loopback_mode == LOOPBACK_NETWORK) ||
448 (efx->phy_type == PHY_TYPE_NONE))
386 return 0; 449 return 0;
387 450
388 while (tries) { 451 while (tries) {
@@ -408,8 +471,13 @@ void falcon_reconfigure_xmac(struct efx_nic *efx)
408 falcon_mask_status_intr(efx, 0); 471 falcon_mask_status_intr(efx, 0);
409 472
410 falcon_deconfigure_mac_wrapper(efx); 473 falcon_deconfigure_mac_wrapper(efx);
474
475 efx->tx_disabled = LOOPBACK_INTERNAL(efx);
411 efx->phy_op->reconfigure(efx); 476 efx->phy_op->reconfigure(efx);
477
478 falcon_reconfigure_xgxs_core(efx);
412 falcon_reconfigure_xmac_core(efx); 479 falcon_reconfigure_xmac_core(efx);
480
413 falcon_reconfigure_mac_wrapper(efx); 481 falcon_reconfigure_mac_wrapper(efx);
414 482
415 /* Ensure XAUI link is up */ 483 /* Ensure XAUI link is up */
@@ -491,13 +559,15 @@ void falcon_update_stats_xmac(struct efx_nic *efx)
491 (mac_stats->rx_bytes - mac_stats->rx_good_bytes); 559 (mac_stats->rx_bytes - mac_stats->rx_good_bytes);
492} 560}
493 561
494#define EFX_XAUI_RETRAIN_MAX 8
495
496int falcon_check_xmac(struct efx_nic *efx) 562int falcon_check_xmac(struct efx_nic *efx)
497{ 563{
498 unsigned xaui_link_ok; 564 unsigned xaui_link_ok;
499 int rc; 565 int rc;
500 566
567 if ((efx->loopback_mode == LOOPBACK_NETWORK) ||
568 (efx->phy_type == PHY_TYPE_NONE))
569 return 0;
570
501 falcon_mask_status_intr(efx, 0); 571 falcon_mask_status_intr(efx, 0);
502 xaui_link_ok = falcon_xaui_link_ok(efx); 572 xaui_link_ok = falcon_xaui_link_ok(efx);
503 573
diff --git a/drivers/net/sfc/mdio_10g.c b/drivers/net/sfc/mdio_10g.c
index dc06bb0aa575..c4f540e93b79 100644
--- a/drivers/net/sfc/mdio_10g.c
+++ b/drivers/net/sfc/mdio_10g.c
@@ -44,6 +44,9 @@ static int mdio_clause45_check_mmd(struct efx_nic *efx, int mmd,
44 int status; 44 int status;
45 int phy_id = efx->mii.phy_id; 45 int phy_id = efx->mii.phy_id;
46 46
47 if (LOOPBACK_INTERNAL(efx))
48 return 0;
49
47 /* Read MMD STATUS2 to check it is responding. */ 50 /* Read MMD STATUS2 to check it is responding. */
48 status = mdio_clause45_read(efx, phy_id, mmd, MDIO_MMDREG_STAT2); 51 status = mdio_clause45_read(efx, phy_id, mmd, MDIO_MMDREG_STAT2);
49 if (((status >> MDIO_MMDREG_STAT2_PRESENT_LBN) & 52 if (((status >> MDIO_MMDREG_STAT2_PRESENT_LBN) &
@@ -164,6 +167,22 @@ int mdio_clause45_links_ok(struct efx_nic *efx, unsigned int mmd_mask)
164 int mmd = 0; 167 int mmd = 0;
165 int good; 168 int good;
166 169
170 /* If the port is in loopback, then we should only consider a subset
171 * of mmd's */
172 if (LOOPBACK_INTERNAL(efx))
173 return 1;
174 else if (efx->loopback_mode == LOOPBACK_NETWORK)
175 return 0;
176 else if (efx->loopback_mode == LOOPBACK_PHYXS)
177 mmd_mask &= ~(MDIO_MMDREG_DEVS0_PHYXS |
178 MDIO_MMDREG_DEVS0_PCS |
179 MDIO_MMDREG_DEVS0_PMAPMD);
180 else if (efx->loopback_mode == LOOPBACK_PCS)
181 mmd_mask &= ~(MDIO_MMDREG_DEVS0_PCS |
182 MDIO_MMDREG_DEVS0_PMAPMD);
183 else if (efx->loopback_mode == LOOPBACK_PMAPMD)
184 mmd_mask &= ~MDIO_MMDREG_DEVS0_PMAPMD;
185
167 while (mmd_mask) { 186 while (mmd_mask) {
168 if (mmd_mask & 1) { 187 if (mmd_mask & 1) {
169 /* Double reads because link state is latched, and a 188 /* Double reads because link state is latched, and a
@@ -182,6 +201,65 @@ int mdio_clause45_links_ok(struct efx_nic *efx, unsigned int mmd_mask)
182 return ok; 201 return ok;
183} 202}
184 203
204void mdio_clause45_transmit_disable(struct efx_nic *efx)
205{
206 int phy_id = efx->mii.phy_id;
207 int ctrl1, ctrl2;
208
209 ctrl1 = ctrl2 = mdio_clause45_read(efx, phy_id, MDIO_MMD_PMAPMD,
210 MDIO_MMDREG_TXDIS);
211 if (efx->tx_disabled)
212 ctrl2 |= (1 << MDIO_MMDREG_TXDIS_GLOBAL_LBN);
213 else
214 ctrl1 &= ~(1 << MDIO_MMDREG_TXDIS_GLOBAL_LBN);
215 if (ctrl1 != ctrl2)
216 mdio_clause45_write(efx, phy_id, MDIO_MMD_PMAPMD,
217 MDIO_MMDREG_TXDIS, ctrl2);
218}
219
220void mdio_clause45_phy_reconfigure(struct efx_nic *efx)
221{
222 int phy_id = efx->mii.phy_id;
223 int ctrl1, ctrl2;
224
225 /* Handle (with debouncing) PMA/PMD loopback */
226 ctrl1 = ctrl2 = mdio_clause45_read(efx, phy_id, MDIO_MMD_PMAPMD,
227 MDIO_MMDREG_CTRL1);
228
229 if (efx->loopback_mode == LOOPBACK_PMAPMD)
230 ctrl2 |= (1 << MDIO_PMAPMD_CTRL1_LBACK_LBN);
231 else
232 ctrl2 &= ~(1 << MDIO_PMAPMD_CTRL1_LBACK_LBN);
233
234 if (ctrl1 != ctrl2)
235 mdio_clause45_write(efx, phy_id, MDIO_MMD_PMAPMD,
236 MDIO_MMDREG_CTRL1, ctrl2);
237
238 /* Handle (with debouncing) PCS loopback */
239 ctrl1 = ctrl2 = mdio_clause45_read(efx, phy_id, MDIO_MMD_PCS,
240 MDIO_MMDREG_CTRL1);
241 if (efx->loopback_mode == LOOPBACK_PCS)
242 ctrl2 |= (1 << MDIO_MMDREG_CTRL1_LBACK_LBN);
243 else
244 ctrl2 &= ~(1 << MDIO_MMDREG_CTRL1_LBACK_LBN);
245
246 if (ctrl1 != ctrl2)
247 mdio_clause45_write(efx, phy_id, MDIO_MMD_PCS,
248 MDIO_MMDREG_CTRL1, ctrl2);
249
250 /* Handle (with debouncing) PHYXS network loopback */
251 ctrl1 = ctrl2 = mdio_clause45_read(efx, phy_id, MDIO_MMD_PHYXS,
252 MDIO_MMDREG_CTRL1);
253 if (efx->loopback_mode == LOOPBACK_NETWORK)
254 ctrl2 |= (1 << MDIO_MMDREG_CTRL1_LBACK_LBN);
255 else
256 ctrl2 &= ~(1 << MDIO_MMDREG_CTRL1_LBACK_LBN);
257
258 if (ctrl1 != ctrl2)
259 mdio_clause45_write(efx, phy_id, MDIO_MMD_PHYXS,
260 MDIO_MMDREG_CTRL1, ctrl2);
261}
262
185/** 263/**
186 * mdio_clause45_get_settings - Read (some of) the PHY settings over MDIO. 264 * mdio_clause45_get_settings - Read (some of) the PHY settings over MDIO.
187 * @efx: Efx NIC 265 * @efx: Efx NIC
diff --git a/drivers/net/sfc/mdio_10g.h b/drivers/net/sfc/mdio_10g.h
index 2214b6d820a7..cb99f3f4491c 100644
--- a/drivers/net/sfc/mdio_10g.h
+++ b/drivers/net/sfc/mdio_10g.h
@@ -44,11 +44,16 @@
44#define MDIO_MMDREG_DEVS1 (6) 44#define MDIO_MMDREG_DEVS1 (6)
45#define MDIO_MMDREG_CTRL2 (7) 45#define MDIO_MMDREG_CTRL2 (7)
46#define MDIO_MMDREG_STAT2 (8) 46#define MDIO_MMDREG_STAT2 (8)
47#define MDIO_MMDREG_TXDIS (9)
47 48
48/* Bits in MMDREG_CTRL1 */ 49/* Bits in MMDREG_CTRL1 */
49/* Reset */ 50/* Reset */
50#define MDIO_MMDREG_CTRL1_RESET_LBN (15) 51#define MDIO_MMDREG_CTRL1_RESET_LBN (15)
51#define MDIO_MMDREG_CTRL1_RESET_WIDTH (1) 52#define MDIO_MMDREG_CTRL1_RESET_WIDTH (1)
53/* Loopback */
54/* Loopback bit for WIS, PCS, PHYSX and DTEXS */
55#define MDIO_MMDREG_CTRL1_LBACK_LBN (14)
56#define MDIO_MMDREG_CTRL1_LBACK_WIDTH (1)
52 57
53/* Bits in MMDREG_STAT1 */ 58/* Bits in MMDREG_STAT1 */
54#define MDIO_MMDREG_STAT1_FAULT_LBN (7) 59#define MDIO_MMDREG_STAT1_FAULT_LBN (7)
@@ -56,6 +61,9 @@
56/* Link state */ 61/* Link state */
57#define MDIO_MMDREG_STAT1_LINK_LBN (2) 62#define MDIO_MMDREG_STAT1_LINK_LBN (2)
58#define MDIO_MMDREG_STAT1_LINK_WIDTH (1) 63#define MDIO_MMDREG_STAT1_LINK_WIDTH (1)
64/* Low power ability */
65#define MDIO_MMDREG_STAT1_LPABLE_LBN (1)
66#define MDIO_MMDREG_STAT1_LPABLE_WIDTH (1)
59 67
60/* Bits in ID reg */ 68/* Bits in ID reg */
61#define MDIO_ID_REV(_id32) (_id32 & 0xf) 69#define MDIO_ID_REV(_id32) (_id32 & 0xf)
@@ -76,6 +84,14 @@
76#define MDIO_MMDREG_STAT2_PRESENT_LBN (14) 84#define MDIO_MMDREG_STAT2_PRESENT_LBN (14)
77#define MDIO_MMDREG_STAT2_PRESENT_WIDTH (2) 85#define MDIO_MMDREG_STAT2_PRESENT_WIDTH (2)
78 86
87/* Bits in MMDREG_TXDIS */
88#define MDIO_MMDREG_TXDIS_GLOBAL_LBN (0)
89#define MDIO_MMDREG_TXDIS_GLOBAL_WIDTH (1)
90
91/* MMD-specific bits, ordered by MMD, then register */
92#define MDIO_PMAPMD_CTRL1_LBACK_LBN (0)
93#define MDIO_PMAPMD_CTRL1_LBACK_WIDTH (1)
94
79/* PMA type (4 bits) */ 95/* PMA type (4 bits) */
80#define MDIO_PMAPMD_CTRL2_10G_CX4 (0x0) 96#define MDIO_PMAPMD_CTRL2_10G_CX4 (0x0)
81#define MDIO_PMAPMD_CTRL2_10G_EW (0x1) 97#define MDIO_PMAPMD_CTRL2_10G_EW (0x1)
@@ -95,7 +111,7 @@
95#define MDIO_PMAPMD_CTRL2_10_BT (0xf) 111#define MDIO_PMAPMD_CTRL2_10_BT (0xf)
96#define MDIO_PMAPMD_CTRL2_TYPE_MASK (0xf) 112#define MDIO_PMAPMD_CTRL2_TYPE_MASK (0xf)
97 113
98/* /\* PHY XGXS lane state *\/ */ 114/* PHY XGXS lane state */
99#define MDIO_PHYXS_LANE_STATE (0x18) 115#define MDIO_PHYXS_LANE_STATE (0x18)
100#define MDIO_PHYXS_LANE_ALIGNED_LBN (12) 116#define MDIO_PHYXS_LANE_ALIGNED_LBN (12)
101 117
@@ -217,6 +233,12 @@ int mdio_clause45_check_mmds(struct efx_nic *efx,
217extern int mdio_clause45_links_ok(struct efx_nic *efx, 233extern int mdio_clause45_links_ok(struct efx_nic *efx,
218 unsigned int mmd_mask); 234 unsigned int mmd_mask);
219 235
236/* Generic transmit disable support though PMAPMD */
237extern void mdio_clause45_transmit_disable(struct efx_nic *efx);
238
239/* Generic part of reconfigure: set/clear loopback bits */
240extern void mdio_clause45_phy_reconfigure(struct efx_nic *efx);
241
220/* Read (some of) the PHY settings over MDIO */ 242/* Read (some of) the PHY settings over MDIO */
221extern void mdio_clause45_get_settings(struct efx_nic *efx, 243extern void mdio_clause45_get_settings(struct efx_nic *efx,
222 struct ethtool_cmd *ecmd); 244 struct ethtool_cmd *ecmd);
diff --git a/drivers/net/sfc/net_driver.h b/drivers/net/sfc/net_driver.h
index c505482c2520..59f261b4171f 100644
--- a/drivers/net/sfc/net_driver.h
+++ b/drivers/net/sfc/net_driver.h
@@ -134,6 +134,8 @@ struct efx_special_buffer {
134 * Set only on the final fragment of a packet; %NULL for all other 134 * Set only on the final fragment of a packet; %NULL for all other
135 * fragments. When this fragment completes, then we can free this 135 * fragments. When this fragment completes, then we can free this
136 * skb. 136 * skb.
137 * @tsoh: The associated TSO header structure, or %NULL if this
138 * buffer is not a TSO header.
137 * @dma_addr: DMA address of the fragment. 139 * @dma_addr: DMA address of the fragment.
138 * @len: Length of this fragment. 140 * @len: Length of this fragment.
139 * This field is zero when the queue slot is empty. 141 * This field is zero when the queue slot is empty.
@@ -144,6 +146,7 @@ struct efx_special_buffer {
144 */ 146 */
145struct efx_tx_buffer { 147struct efx_tx_buffer {
146 const struct sk_buff *skb; 148 const struct sk_buff *skb;
149 struct efx_tso_header *tsoh;
147 dma_addr_t dma_addr; 150 dma_addr_t dma_addr;
148 unsigned short len; 151 unsigned short len;
149 unsigned char continuation; 152 unsigned char continuation;
@@ -187,6 +190,13 @@ struct efx_tx_buffer {
187 * variable indicates that the queue is full. This is to 190 * variable indicates that the queue is full. This is to
188 * avoid cache-line ping-pong between the xmit path and the 191 * avoid cache-line ping-pong between the xmit path and the
189 * completion path. 192 * completion path.
193 * @tso_headers_free: A list of TSO headers allocated for this TX queue
194 * that are not in use, and so available for new TSO sends. The list
195 * is protected by the TX queue lock.
196 * @tso_bursts: Number of times TSO xmit invoked by kernel
197 * @tso_long_headers: Number of packets with headers too long for standard
198 * blocks
199 * @tso_packets: Number of packets via the TSO xmit path
190 */ 200 */
191struct efx_tx_queue { 201struct efx_tx_queue {
192 /* Members which don't change on the fast path */ 202 /* Members which don't change on the fast path */
@@ -206,6 +216,10 @@ struct efx_tx_queue {
206 unsigned int insert_count ____cacheline_aligned_in_smp; 216 unsigned int insert_count ____cacheline_aligned_in_smp;
207 unsigned int write_count; 217 unsigned int write_count;
208 unsigned int old_read_count; 218 unsigned int old_read_count;
219 struct efx_tso_header *tso_headers_free;
220 unsigned int tso_bursts;
221 unsigned int tso_long_headers;
222 unsigned int tso_packets;
209}; 223};
210 224
211/** 225/**
@@ -434,6 +448,9 @@ struct efx_board {
434 struct efx_blinker blinker; 448 struct efx_blinker blinker;
435}; 449};
436 450
451#define STRING_TABLE_LOOKUP(val, member) \
452 member ## _names[val]
453
437enum efx_int_mode { 454enum efx_int_mode {
438 /* Be careful if altering to correct macro below */ 455 /* Be careful if altering to correct macro below */
439 EFX_INT_MODE_MSIX = 0, 456 EFX_INT_MODE_MSIX = 0,
@@ -506,6 +523,7 @@ enum efx_fc_type {
506 * @check_hw: Check hardware 523 * @check_hw: Check hardware
507 * @reset_xaui: Reset XAUI side of PHY for (software sequenced reset) 524 * @reset_xaui: Reset XAUI side of PHY for (software sequenced reset)
508 * @mmds: MMD presence mask 525 * @mmds: MMD presence mask
526 * @loopbacks: Supported loopback modes mask
509 */ 527 */
510struct efx_phy_operations { 528struct efx_phy_operations {
511 int (*init) (struct efx_nic *efx); 529 int (*init) (struct efx_nic *efx);
@@ -515,6 +533,7 @@ struct efx_phy_operations {
515 int (*check_hw) (struct efx_nic *efx); 533 int (*check_hw) (struct efx_nic *efx);
516 void (*reset_xaui) (struct efx_nic *efx); 534 void (*reset_xaui) (struct efx_nic *efx);
517 int mmds; 535 int mmds;
536 unsigned loopbacks;
518}; 537};
519 538
520/* 539/*
@@ -653,7 +672,6 @@ union efx_multicast_hash {
653 * @phy_op: PHY interface 672 * @phy_op: PHY interface
654 * @phy_data: PHY private data (including PHY-specific stats) 673 * @phy_data: PHY private data (including PHY-specific stats)
655 * @mii: PHY interface 674 * @mii: PHY interface
656 * @phy_powered: PHY power state
657 * @tx_disabled: PHY transmitter turned off 675 * @tx_disabled: PHY transmitter turned off
658 * @link_up: Link status 676 * @link_up: Link status
659 * @link_options: Link options (MII/GMII format) 677 * @link_options: Link options (MII/GMII format)
@@ -662,6 +680,9 @@ union efx_multicast_hash {
662 * @multicast_hash: Multicast hash table 680 * @multicast_hash: Multicast hash table
663 * @flow_control: Flow control flags - separate RX/TX so can't use link_options 681 * @flow_control: Flow control flags - separate RX/TX so can't use link_options
664 * @reconfigure_work: work item for dealing with PHY events 682 * @reconfigure_work: work item for dealing with PHY events
683 * @loopback_mode: Loopback status
684 * @loopback_modes: Supported loopback mode bitmask
685 * @loopback_selftest: Offline self-test private state
665 * 686 *
666 * The @priv field of the corresponding &struct net_device points to 687 * The @priv field of the corresponding &struct net_device points to
667 * this. 688 * this.
@@ -721,6 +742,7 @@ struct efx_nic {
721 struct efx_phy_operations *phy_op; 742 struct efx_phy_operations *phy_op;
722 void *phy_data; 743 void *phy_data;
723 struct mii_if_info mii; 744 struct mii_if_info mii;
745 unsigned tx_disabled;
724 746
725 int link_up; 747 int link_up;
726 unsigned int link_options; 748 unsigned int link_options;
@@ -732,6 +754,10 @@ struct efx_nic {
732 struct work_struct reconfigure_work; 754 struct work_struct reconfigure_work;
733 755
734 atomic_t rx_reset; 756 atomic_t rx_reset;
757 enum efx_loopback_mode loopback_mode;
758 unsigned int loopback_modes;
759
760 void *loopback_selftest;
735}; 761};
736 762
737/** 763/**
diff --git a/drivers/net/sfc/rx.c b/drivers/net/sfc/rx.c
index 551299b462ae..670622373ddf 100644
--- a/drivers/net/sfc/rx.c
+++ b/drivers/net/sfc/rx.c
@@ -19,6 +19,7 @@
19#include "rx.h" 19#include "rx.h"
20#include "efx.h" 20#include "efx.h"
21#include "falcon.h" 21#include "falcon.h"
22#include "selftest.h"
22#include "workarounds.h" 23#include "workarounds.h"
23 24
24/* Number of RX descriptors pushed at once. */ 25/* Number of RX descriptors pushed at once. */
@@ -683,6 +684,15 @@ void __efx_rx_packet(struct efx_channel *channel,
683 struct sk_buff *skb; 684 struct sk_buff *skb;
684 int lro = efx->net_dev->features & NETIF_F_LRO; 685 int lro = efx->net_dev->features & NETIF_F_LRO;
685 686
687 /* If we're in loopback test, then pass the packet directly to the
688 * loopback layer, and free the rx_buf here
689 */
690 if (unlikely(efx->loopback_selftest)) {
691 efx_loopback_rx_packet(efx, rx_buf->data, rx_buf->len);
692 efx_free_rx_buffer(efx, rx_buf);
693 goto done;
694 }
695
686 if (rx_buf->skb) { 696 if (rx_buf->skb) {
687 prefetch(skb_shinfo(rx_buf->skb)); 697 prefetch(skb_shinfo(rx_buf->skb));
688 698
@@ -736,7 +746,6 @@ void __efx_rx_packet(struct efx_channel *channel,
736 /* Update allocation strategy method */ 746 /* Update allocation strategy method */
737 channel->rx_alloc_level += RX_ALLOC_FACTOR_SKB; 747 channel->rx_alloc_level += RX_ALLOC_FACTOR_SKB;
738 748
739 /* fall-thru */
740done: 749done:
741 efx->net_dev->last_rx = jiffies; 750 efx->net_dev->last_rx = jiffies;
742} 751}
diff --git a/drivers/net/sfc/selftest.c b/drivers/net/sfc/selftest.c
new file mode 100644
index 000000000000..cbda15946e8f
--- /dev/null
+++ b/drivers/net/sfc/selftest.c
@@ -0,0 +1,717 @@
1/****************************************************************************
2 * Driver for Solarflare Solarstorm network controllers and boards
3 * Copyright 2005-2006 Fen Systems Ltd.
4 * Copyright 2006-2008 Solarflare Communications Inc.
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License version 2 as published
8 * by the Free Software Foundation, incorporated herein by reference.
9 */
10
11#include <linux/netdevice.h>
12#include <linux/module.h>
13#include <linux/delay.h>
14#include <linux/kernel_stat.h>
15#include <linux/pci.h>
16#include <linux/ethtool.h>
17#include <linux/ip.h>
18#include <linux/in.h>
19#include <linux/udp.h>
20#include <linux/rtnetlink.h>
21#include <asm/io.h>
22#include "net_driver.h"
23#include "ethtool.h"
24#include "efx.h"
25#include "falcon.h"
26#include "selftest.h"
27#include "boards.h"
28#include "workarounds.h"
29#include "mac.h"
30
31/*
32 * Loopback test packet structure
33 *
34 * The self-test should stress every RSS vector, and unfortunately
35 * Falcon only performs RSS on TCP/UDP packets.
36 */
37struct efx_loopback_payload {
38 struct ethhdr header;
39 struct iphdr ip;
40 struct udphdr udp;
41 __be16 iteration;
42 const char msg[64];
43} __attribute__ ((packed));
44
45/* Loopback test source MAC address */
46static const unsigned char payload_source[ETH_ALEN] = {
47 0x00, 0x0f, 0x53, 0x1b, 0x1b, 0x1b,
48};
49
50static const char *payload_msg =
51 "Hello world! This is an Efx loopback test in progress!";
52
53/**
54 * efx_selftest_state - persistent state during a selftest
55 * @flush: Drop all packets in efx_loopback_rx_packet
56 * @packet_count: Number of packets being used in this test
57 * @skbs: An array of skbs transmitted
58 * @rx_good: RX good packet count
59 * @rx_bad: RX bad packet count
60 * @payload: Payload used in tests
61 */
62struct efx_selftest_state {
63 int flush;
64 int packet_count;
65 struct sk_buff **skbs;
66 atomic_t rx_good;
67 atomic_t rx_bad;
68 struct efx_loopback_payload payload;
69};
70
71/**************************************************************************
72 *
73 * Configurable values
74 *
75 **************************************************************************/
76
77/* Level of loopback testing
78 *
79 * The maximum packet burst length is 16**(n-1), i.e.
80 *
81 * - Level 0 : no packets
82 * - Level 1 : 1 packet
83 * - Level 2 : 17 packets (1 * 1 packet, 1 * 16 packets)
84 * - Level 3 : 273 packets (1 * 1 packet, 1 * 16 packet, 1 * 256 packets)
85 *
86 */
87static unsigned int loopback_test_level = 3;
88
89/**************************************************************************
90 *
91 * Interrupt and event queue testing
92 *
93 **************************************************************************/
94
95/* Test generation and receipt of interrupts */
96static int efx_test_interrupts(struct efx_nic *efx,
97 struct efx_self_tests *tests)
98{
99 struct efx_channel *channel;
100
101 EFX_LOG(efx, "testing interrupts\n");
102 tests->interrupt = -1;
103
104 /* Reset interrupt flag */
105 efx->last_irq_cpu = -1;
106 smp_wmb();
107
108 /* ACK each interrupting event queue. Receiving an interrupt due to
109 * traffic before a test event is raised is considered a pass */
110 efx_for_each_channel_with_interrupt(channel, efx) {
111 if (channel->work_pending)
112 efx_process_channel_now(channel);
113 if (efx->last_irq_cpu >= 0)
114 goto success;
115 }
116
117 falcon_generate_interrupt(efx);
118
119 /* Wait for arrival of test interrupt. */
120 EFX_LOG(efx, "waiting for test interrupt\n");
121 schedule_timeout_uninterruptible(HZ / 10);
122 if (efx->last_irq_cpu >= 0)
123 goto success;
124
125 EFX_ERR(efx, "timed out waiting for interrupt\n");
126 return -ETIMEDOUT;
127
128 success:
129 EFX_LOG(efx, "test interrupt (mode %d) seen on CPU%d\n",
130 efx->interrupt_mode, efx->last_irq_cpu);
131 tests->interrupt = 1;
132 return 0;
133}
134
135/* Test generation and receipt of non-interrupting events */
136static int efx_test_eventq(struct efx_channel *channel,
137 struct efx_self_tests *tests)
138{
139 unsigned int magic;
140
141 /* Channel specific code, limited to 20 bits */
142 magic = (0x00010150 + channel->channel);
143 EFX_LOG(channel->efx, "channel %d testing event queue with code %x\n",
144 channel->channel, magic);
145
146 tests->eventq_dma[channel->channel] = -1;
147 tests->eventq_int[channel->channel] = 1; /* fake pass */
148 tests->eventq_poll[channel->channel] = 1; /* fake pass */
149
150 /* Reset flag and zero magic word */
151 channel->efx->last_irq_cpu = -1;
152 channel->eventq_magic = 0;
153 smp_wmb();
154
155 falcon_generate_test_event(channel, magic);
156 udelay(1);
157
158 efx_process_channel_now(channel);
159 if (channel->eventq_magic != magic) {
160 EFX_ERR(channel->efx, "channel %d failed to see test event\n",
161 channel->channel);
162 return -ETIMEDOUT;
163 } else {
164 tests->eventq_dma[channel->channel] = 1;
165 }
166
167 return 0;
168}
169
170/* Test generation and receipt of interrupting events */
171static int efx_test_eventq_irq(struct efx_channel *channel,
172 struct efx_self_tests *tests)
173{
174 unsigned int magic, count;
175
176 /* Channel specific code, limited to 20 bits */
177 magic = (0x00010150 + channel->channel);
178 EFX_LOG(channel->efx, "channel %d testing event queue with code %x\n",
179 channel->channel, magic);
180
181 tests->eventq_dma[channel->channel] = -1;
182 tests->eventq_int[channel->channel] = -1;
183 tests->eventq_poll[channel->channel] = -1;
184
185 /* Reset flag and zero magic word */
186 channel->efx->last_irq_cpu = -1;
187 channel->eventq_magic = 0;
188 smp_wmb();
189
190 falcon_generate_test_event(channel, magic);
191
192 /* Wait for arrival of interrupt */
193 count = 0;
194 do {
195 schedule_timeout_uninterruptible(HZ / 100);
196
197 if (channel->work_pending)
198 efx_process_channel_now(channel);
199
200 if (channel->eventq_magic == magic)
201 goto eventq_ok;
202 } while (++count < 2);
203
204 EFX_ERR(channel->efx, "channel %d timed out waiting for event queue\n",
205 channel->channel);
206
207 /* See if interrupt arrived */
208 if (channel->efx->last_irq_cpu >= 0) {
209 EFX_ERR(channel->efx, "channel %d saw interrupt on CPU%d "
210 "during event queue test\n", channel->channel,
211 raw_smp_processor_id());
212 tests->eventq_int[channel->channel] = 1;
213 }
214
215 /* Check to see if event was received even if interrupt wasn't */
216 efx_process_channel_now(channel);
217 if (channel->eventq_magic == magic) {
218 EFX_ERR(channel->efx, "channel %d event was generated, but "
219 "failed to trigger an interrupt\n", channel->channel);
220 tests->eventq_dma[channel->channel] = 1;
221 }
222
223 return -ETIMEDOUT;
224 eventq_ok:
225 EFX_LOG(channel->efx, "channel %d event queue passed\n",
226 channel->channel);
227 tests->eventq_dma[channel->channel] = 1;
228 tests->eventq_int[channel->channel] = 1;
229 tests->eventq_poll[channel->channel] = 1;
230 return 0;
231}
232
233/**************************************************************************
234 *
235 * PHY testing
236 *
237 **************************************************************************/
238
239/* Check PHY presence by reading the PHY ID registers */
240static int efx_test_phy(struct efx_nic *efx,
241 struct efx_self_tests *tests)
242{
243 u16 physid1, physid2;
244 struct mii_if_info *mii = &efx->mii;
245 struct net_device *net_dev = efx->net_dev;
246
247 if (efx->phy_type == PHY_TYPE_NONE)
248 return 0;
249
250 EFX_LOG(efx, "testing PHY presence\n");
251 tests->phy_ok = -1;
252
253 physid1 = mii->mdio_read(net_dev, mii->phy_id, MII_PHYSID1);
254 physid2 = mii->mdio_read(net_dev, mii->phy_id, MII_PHYSID2);
255
256 if ((physid1 != 0x0000) && (physid1 != 0xffff) &&
257 (physid2 != 0x0000) && (physid2 != 0xffff)) {
258 EFX_LOG(efx, "found MII PHY %d ID 0x%x:%x\n",
259 mii->phy_id, physid1, physid2);
260 tests->phy_ok = 1;
261 return 0;
262 }
263
264 EFX_ERR(efx, "no MII PHY present with ID %d\n", mii->phy_id);
265 return -ENODEV;
266}
267
268/**************************************************************************
269 *
270 * Loopback testing
271 * NB Only one loopback test can be executing concurrently.
272 *
273 **************************************************************************/
274
275/* Loopback test RX callback
276 * This is called for each received packet during loopback testing.
277 */
278void efx_loopback_rx_packet(struct efx_nic *efx,
279 const char *buf_ptr, int pkt_len)
280{
281 struct efx_selftest_state *state = efx->loopback_selftest;
282 struct efx_loopback_payload *received;
283 struct efx_loopback_payload *payload;
284
285 BUG_ON(!buf_ptr);
286
287 /* If we are just flushing, then drop the packet */
288 if ((state == NULL) || state->flush)
289 return;
290
291 payload = &state->payload;
292
293 received = (struct efx_loopback_payload *)(char *) buf_ptr;
294 received->ip.saddr = payload->ip.saddr;
295 received->ip.check = payload->ip.check;
296
297 /* Check that header exists */
298 if (pkt_len < sizeof(received->header)) {
299 EFX_ERR(efx, "saw runt RX packet (length %d) in %s loopback "
300 "test\n", pkt_len, LOOPBACK_MODE(efx));
301 goto err;
302 }
303
304 /* Check that the ethernet header exists */
305 if (memcmp(&received->header, &payload->header, ETH_HLEN) != 0) {
306 EFX_ERR(efx, "saw non-loopback RX packet in %s loopback test\n",
307 LOOPBACK_MODE(efx));
308 goto err;
309 }
310
311 /* Check packet length */
312 if (pkt_len != sizeof(*payload)) {
313 EFX_ERR(efx, "saw incorrect RX packet length %d (wanted %d) in "
314 "%s loopback test\n", pkt_len, (int)sizeof(*payload),
315 LOOPBACK_MODE(efx));
316 goto err;
317 }
318
319 /* Check that IP header matches */
320 if (memcmp(&received->ip, &payload->ip, sizeof(payload->ip)) != 0) {
321 EFX_ERR(efx, "saw corrupted IP header in %s loopback test\n",
322 LOOPBACK_MODE(efx));
323 goto err;
324 }
325
326 /* Check that msg and padding matches */
327 if (memcmp(&received->msg, &payload->msg, sizeof(received->msg)) != 0) {
328 EFX_ERR(efx, "saw corrupted RX packet in %s loopback test\n",
329 LOOPBACK_MODE(efx));
330 goto err;
331 }
332
333 /* Check that iteration matches */
334 if (received->iteration != payload->iteration) {
335 EFX_ERR(efx, "saw RX packet from iteration %d (wanted %d) in "
336 "%s loopback test\n", ntohs(received->iteration),
337 ntohs(payload->iteration), LOOPBACK_MODE(efx));
338 goto err;
339 }
340
341 /* Increase correct RX count */
342 EFX_TRACE(efx, "got loopback RX in %s loopback test\n",
343 LOOPBACK_MODE(efx));
344
345 atomic_inc(&state->rx_good);
346 return;
347
348 err:
349#ifdef EFX_ENABLE_DEBUG
350 if (atomic_read(&state->rx_bad) == 0) {
351 EFX_ERR(efx, "received packet:\n");
352 print_hex_dump(KERN_ERR, "", DUMP_PREFIX_OFFSET, 0x10, 1,
353 buf_ptr, pkt_len, 0);
354 EFX_ERR(efx, "expected packet:\n");
355 print_hex_dump(KERN_ERR, "", DUMP_PREFIX_OFFSET, 0x10, 1,
356 &state->payload, sizeof(state->payload), 0);
357 }
358#endif
359 atomic_inc(&state->rx_bad);
360}
361
362/* Initialise an efx_selftest_state for a new iteration */
363static void efx_iterate_state(struct efx_nic *efx)
364{
365 struct efx_selftest_state *state = efx->loopback_selftest;
366 struct net_device *net_dev = efx->net_dev;
367 struct efx_loopback_payload *payload = &state->payload;
368
369 /* Initialise the layerII header */
370 memcpy(&payload->header.h_dest, net_dev->dev_addr, ETH_ALEN);
371 memcpy(&payload->header.h_source, &payload_source, ETH_ALEN);
372 payload->header.h_proto = htons(ETH_P_IP);
373
374 /* saddr set later and used as incrementing count */
375 payload->ip.daddr = htonl(INADDR_LOOPBACK);
376 payload->ip.ihl = 5;
377 payload->ip.check = htons(0xdead);
378 payload->ip.tot_len = htons(sizeof(*payload) - sizeof(struct ethhdr));
379 payload->ip.version = IPVERSION;
380 payload->ip.protocol = IPPROTO_UDP;
381
382 /* Initialise udp header */
383 payload->udp.source = 0;
384 payload->udp.len = htons(sizeof(*payload) - sizeof(struct ethhdr) -
385 sizeof(struct iphdr));
386 payload->udp.check = 0; /* checksum ignored */
387
388 /* Fill out payload */
389 payload->iteration = htons(ntohs(payload->iteration) + 1);
390 memcpy(&payload->msg, payload_msg, sizeof(payload_msg));
391
392 /* Fill out remaining state members */
393 atomic_set(&state->rx_good, 0);
394 atomic_set(&state->rx_bad, 0);
395 smp_wmb();
396}
397
398static int efx_tx_loopback(struct efx_tx_queue *tx_queue)
399{
400 struct efx_nic *efx = tx_queue->efx;
401 struct efx_selftest_state *state = efx->loopback_selftest;
402 struct efx_loopback_payload *payload;
403 struct sk_buff *skb;
404 int i, rc;
405
406 /* Transmit N copies of buffer */
407 for (i = 0; i < state->packet_count; i++) {
408 /* Allocate an skb, holding an extra reference for
409 * transmit completion counting */
410 skb = alloc_skb(sizeof(state->payload), GFP_KERNEL);
411 if (!skb)
412 return -ENOMEM;
413 state->skbs[i] = skb;
414 skb_get(skb);
415
416 /* Copy the payload in, incrementing the source address to
417 * exercise the rss vectors */
418 payload = ((struct efx_loopback_payload *)
419 skb_put(skb, sizeof(state->payload)));
420 memcpy(payload, &state->payload, sizeof(state->payload));
421 payload->ip.saddr = htonl(INADDR_LOOPBACK | (i << 2));
422
423 /* Ensure everything we've written is visible to the
424 * interrupt handler. */
425 smp_wmb();
426
427 if (NET_DEV_REGISTERED(efx))
428 netif_tx_lock_bh(efx->net_dev);
429 rc = efx_xmit(efx, tx_queue, skb);
430 if (NET_DEV_REGISTERED(efx))
431 netif_tx_unlock_bh(efx->net_dev);
432
433 if (rc != NETDEV_TX_OK) {
434 EFX_ERR(efx, "TX queue %d could not transmit packet %d "
435 "of %d in %s loopback test\n", tx_queue->queue,
436 i + 1, state->packet_count, LOOPBACK_MODE(efx));
437
438 /* Defer cleaning up the other skbs for the caller */
439 kfree_skb(skb);
440 return -EPIPE;
441 }
442 }
443
444 return 0;
445}
446
447static int efx_rx_loopback(struct efx_tx_queue *tx_queue,
448 struct efx_loopback_self_tests *lb_tests)
449{
450 struct efx_nic *efx = tx_queue->efx;
451 struct efx_selftest_state *state = efx->loopback_selftest;
452 struct sk_buff *skb;
453 int tx_done = 0, rx_good, rx_bad;
454 int i, rc = 0;
455
456 if (NET_DEV_REGISTERED(efx))
457 netif_tx_lock_bh(efx->net_dev);
458
459 /* Count the number of tx completions, and decrement the refcnt. Any
460 * skbs not already completed will be free'd when the queue is flushed */
461 for (i=0; i < state->packet_count; i++) {
462 skb = state->skbs[i];
463 if (skb && !skb_shared(skb))
464 ++tx_done;
465 dev_kfree_skb_any(skb);
466 }
467
468 if (NET_DEV_REGISTERED(efx))
469 netif_tx_unlock_bh(efx->net_dev);
470
471 /* Check TX completion and received packet counts */
472 rx_good = atomic_read(&state->rx_good);
473 rx_bad = atomic_read(&state->rx_bad);
474 if (tx_done != state->packet_count) {
475 /* Don't free the skbs; they will be picked up on TX
476 * overflow or channel teardown.
477 */
478 EFX_ERR(efx, "TX queue %d saw only %d out of an expected %d "
479 "TX completion events in %s loopback test\n",
480 tx_queue->queue, tx_done, state->packet_count,
481 LOOPBACK_MODE(efx));
482 rc = -ETIMEDOUT;
483 /* Allow to fall through so we see the RX errors as well */
484 }
485
486 /* We may always be up to a flush away from our desired packet total */
487 if (rx_good != state->packet_count) {
488 EFX_LOG(efx, "TX queue %d saw only %d out of an expected %d "
489 "received packets in %s loopback test\n",
490 tx_queue->queue, rx_good, state->packet_count,
491 LOOPBACK_MODE(efx));
492 rc = -ETIMEDOUT;
493 /* Fall through */
494 }
495
496 /* Update loopback test structure */
497 lb_tests->tx_sent[tx_queue->queue] += state->packet_count;
498 lb_tests->tx_done[tx_queue->queue] += tx_done;
499 lb_tests->rx_good += rx_good;
500 lb_tests->rx_bad += rx_bad;
501
502 return rc;
503}
504
505static int
506efx_test_loopback(struct efx_tx_queue *tx_queue,
507 struct efx_loopback_self_tests *lb_tests)
508{
509 struct efx_nic *efx = tx_queue->efx;
510 struct efx_selftest_state *state = efx->loopback_selftest;
511 struct efx_channel *channel;
512 int i, rc = 0;
513
514 for (i = 0; i < loopback_test_level; i++) {
515 /* Determine how many packets to send */
516 state->packet_count = (efx->type->txd_ring_mask + 1) / 3;
517 state->packet_count = min(1 << (i << 2), state->packet_count);
518 state->skbs = kzalloc(sizeof(state->skbs[0]) *
519 state->packet_count, GFP_KERNEL);
520 state->flush = 0;
521
522 EFX_LOG(efx, "TX queue %d testing %s loopback with %d "
523 "packets\n", tx_queue->queue, LOOPBACK_MODE(efx),
524 state->packet_count);
525
526 efx_iterate_state(efx);
527 rc = efx_tx_loopback(tx_queue);
528
529 /* NAPI polling is not enabled, so process channels synchronously */
530 schedule_timeout_uninterruptible(HZ / 50);
531 efx_for_each_channel_with_interrupt(channel, efx) {
532 if (channel->work_pending)
533 efx_process_channel_now(channel);
534 }
535
536 rc |= efx_rx_loopback(tx_queue, lb_tests);
537 kfree(state->skbs);
538
539 if (rc) {
540 /* Wait a while to ensure there are no packets
541 * floating around after a failure. */
542 schedule_timeout_uninterruptible(HZ / 10);
543 return rc;
544 }
545 }
546
547 EFX_LOG(efx, "TX queue %d passed %s loopback test with a burst length "
548 "of %d packets\n", tx_queue->queue, LOOPBACK_MODE(efx),
549 state->packet_count);
550
551 return rc;
552}
553
554static int efx_test_loopbacks(struct efx_nic *efx,
555 struct efx_self_tests *tests,
556 unsigned int loopback_modes)
557{
558 struct efx_selftest_state *state = efx->loopback_selftest;
559 struct ethtool_cmd ecmd, ecmd_loopback;
560 struct efx_tx_queue *tx_queue;
561 enum efx_loopback_mode old_mode, mode;
562 int count, rc = 0, link_up;
563
564 rc = efx_ethtool_get_settings(efx->net_dev, &ecmd);
565 if (rc) {
566 EFX_ERR(efx, "could not get GMII settings\n");
567 return rc;
568 }
569 old_mode = efx->loopback_mode;
570
571 /* Disable autonegotiation for the purposes of loopback */
572 memcpy(&ecmd_loopback, &ecmd, sizeof(ecmd_loopback));
573 if (ecmd_loopback.autoneg == AUTONEG_ENABLE) {
574 ecmd_loopback.autoneg = AUTONEG_DISABLE;
575 ecmd_loopback.duplex = DUPLEX_FULL;
576 ecmd_loopback.speed = SPEED_10000;
577 }
578
579 rc = efx_ethtool_set_settings(efx->net_dev, &ecmd_loopback);
580 if (rc) {
581 EFX_ERR(efx, "could not disable autonegotiation\n");
582 goto out;
583 }
584 tests->loopback_speed = ecmd_loopback.speed;
585 tests->loopback_full_duplex = ecmd_loopback.duplex;
586
587 /* Test all supported loopback modes */
588 for (mode = LOOPBACK_NONE; mode < LOOPBACK_TEST_MAX; mode++) {
589 if (!(loopback_modes & (1 << mode)))
590 continue;
591
592 /* Move the port into the specified loopback mode. */
593 state->flush = 1;
594 efx->loopback_mode = mode;
595 efx_reconfigure_port(efx);
596
597 /* Wait for the PHY to signal the link is up */
598 count = 0;
599 do {
600 struct efx_channel *channel = &efx->channel[0];
601
602 falcon_check_xmac(efx);
603 schedule_timeout_uninterruptible(HZ / 10);
604 if (channel->work_pending)
605 efx_process_channel_now(channel);
606 /* Wait for PHY events to be processed */
607 flush_workqueue(efx->workqueue);
608 rmb();
609
610 /* efx->link_up can be 1 even if the XAUI link is down,
611 * (bug5762). Usually, it's not worth bothering with the
612 * difference, but for selftests, we need that extra
613 * guarantee that the link is really, really, up.
614 */
615 link_up = efx->link_up;
616 if (!falcon_xaui_link_ok(efx))
617 link_up = 0;
618
619 } while ((++count < 20) && !link_up);
620
621 /* The link should now be up. If it isn't, there is no point
622 * in attempting a loopback test */
623 if (!link_up) {
624 EFX_ERR(efx, "loopback %s never came up\n",
625 LOOPBACK_MODE(efx));
626 rc = -EIO;
627 goto out;
628 }
629
630 EFX_LOG(efx, "link came up in %s loopback in %d iterations\n",
631 LOOPBACK_MODE(efx), count);
632
633 /* Test every TX queue */
634 efx_for_each_tx_queue(tx_queue, efx) {
635 rc |= efx_test_loopback(tx_queue,
636 &tests->loopback[mode]);
637 if (rc)
638 goto out;
639 }
640 }
641
642 out:
643 /* Take out of loopback and restore PHY settings */
644 state->flush = 1;
645 efx->loopback_mode = old_mode;
646 efx_ethtool_set_settings(efx->net_dev, &ecmd);
647
648 return rc;
649}
650
651/**************************************************************************
652 *
653 * Entry points
654 *
655 *************************************************************************/
656
657/* Online (i.e. non-disruptive) testing
658 * This checks interrupt generation, event delivery and PHY presence. */
659int efx_online_test(struct efx_nic *efx, struct efx_self_tests *tests)
660{
661 struct efx_channel *channel;
662 int rc = 0;
663
664 EFX_LOG(efx, "performing online self-tests\n");
665
666 rc |= efx_test_interrupts(efx, tests);
667 efx_for_each_channel(channel, efx) {
668 if (channel->has_interrupt)
669 rc |= efx_test_eventq_irq(channel, tests);
670 else
671 rc |= efx_test_eventq(channel, tests);
672 }
673 rc |= efx_test_phy(efx, tests);
674
675 if (rc)
676 EFX_ERR(efx, "failed online self-tests\n");
677
678 return rc;
679}
680
681/* Offline (i.e. disruptive) testing
682 * This checks MAC and PHY loopback on the specified port. */
683int efx_offline_test(struct efx_nic *efx,
684 struct efx_self_tests *tests, unsigned int loopback_modes)
685{
686 struct efx_selftest_state *state;
687 int rc = 0;
688
689 EFX_LOG(efx, "performing offline self-tests\n");
690
691 /* Create a selftest_state structure to hold state for the test */
692 state = kzalloc(sizeof(*state), GFP_KERNEL);
693 if (state == NULL) {
694 rc = -ENOMEM;
695 goto out;
696 }
697
698 /* Set the port loopback_selftest member. From this point on
699 * all received packets will be dropped. Mark the state as
700 * "flushing" so all inflight packets are dropped */
701 BUG_ON(efx->loopback_selftest);
702 state->flush = 1;
703 efx->loopback_selftest = (void *)state;
704
705 rc = efx_test_loopbacks(efx, tests, loopback_modes);
706
707 efx->loopback_selftest = NULL;
708 wmb();
709 kfree(state);
710
711 out:
712 if (rc)
713 EFX_ERR(efx, "failed offline self-tests\n");
714
715 return rc;
716}
717
diff --git a/drivers/net/sfc/selftest.h b/drivers/net/sfc/selftest.h
new file mode 100644
index 000000000000..f6999c2b622d
--- /dev/null
+++ b/drivers/net/sfc/selftest.h
@@ -0,0 +1,50 @@
1/****************************************************************************
2 * Driver for Solarflare Solarstorm network controllers and boards
3 * Copyright 2005-2006 Fen Systems Ltd.
4 * Copyright 2006-2008 Solarflare Communications Inc.
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License version 2 as published
8 * by the Free Software Foundation, incorporated herein by reference.
9 */
10
11#ifndef EFX_SELFTEST_H
12#define EFX_SELFTEST_H
13
14#include "net_driver.h"
15
16/*
17 * Self tests
18 */
19
20struct efx_loopback_self_tests {
21 int tx_sent[EFX_MAX_TX_QUEUES];
22 int tx_done[EFX_MAX_TX_QUEUES];
23 int rx_good;
24 int rx_bad;
25};
26
27/* Efx self test results
28 * For fields which are not counters, 1 indicates success and -1
29 * indicates failure.
30 */
31struct efx_self_tests {
32 int interrupt;
33 int eventq_dma[EFX_MAX_CHANNELS];
34 int eventq_int[EFX_MAX_CHANNELS];
35 int eventq_poll[EFX_MAX_CHANNELS];
36 int phy_ok;
37 int loopback_speed;
38 int loopback_full_duplex;
39 struct efx_loopback_self_tests loopback[LOOPBACK_TEST_MAX];
40};
41
42extern void efx_loopback_rx_packet(struct efx_nic *efx,
43 const char *buf_ptr, int pkt_len);
44extern int efx_online_test(struct efx_nic *efx,
45 struct efx_self_tests *tests);
46extern int efx_offline_test(struct efx_nic *efx,
47 struct efx_self_tests *tests,
48 unsigned int loopback_modes);
49
50#endif /* EFX_SELFTEST_H */
diff --git a/drivers/net/sfc/sfe4001.c b/drivers/net/sfc/sfe4001.c
index 11fa9fb8f48b..725d1a539c49 100644
--- a/drivers/net/sfc/sfe4001.c
+++ b/drivers/net/sfc/sfe4001.c
@@ -130,6 +130,15 @@ void sfe4001_poweroff(struct efx_nic *efx)
130 (void) efx_i2c_read(i2c, MAX6647, RSL, &in, 1); 130 (void) efx_i2c_read(i2c, MAX6647, RSL, &in, 1);
131} 131}
132 132
133/* The P0_EN_3V3X line on SFE4001 boards (from A2 onward) is connected
134 * to the FLASH_CFG_1 input on the DSP. We must keep it high at power-
135 * up to allow writing the flash (done through MDIO from userland).
136 */
137unsigned int sfe4001_phy_flash_cfg;
138module_param_named(phy_flash_cfg, sfe4001_phy_flash_cfg, uint, 0444);
139MODULE_PARM_DESC(phy_flash_cfg,
140 "Force PHY to enter flash configuration mode");
141
133/* This board uses an I2C expander to provider power to the PHY, which needs to 142/* This board uses an I2C expander to provider power to the PHY, which needs to
134 * be turned on before the PHY can be used. 143 * be turned on before the PHY can be used.
135 * Context: Process context, rtnl lock held 144 * Context: Process context, rtnl lock held
@@ -203,6 +212,8 @@ int sfe4001_poweron(struct efx_nic *efx)
203 out = 0xff & ~((1 << P0_EN_1V2_LBN) | (1 << P0_EN_2V5_LBN) | 212 out = 0xff & ~((1 << P0_EN_1V2_LBN) | (1 << P0_EN_2V5_LBN) |
204 (1 << P0_EN_3V3X_LBN) | (1 << P0_EN_5V_LBN) | 213 (1 << P0_EN_3V3X_LBN) | (1 << P0_EN_5V_LBN) |
205 (1 << P0_X_TRST_LBN)); 214 (1 << P0_X_TRST_LBN));
215 if (sfe4001_phy_flash_cfg)
216 out |= 1 << P0_EN_3V3X_LBN;
206 217
207 rc = efx_i2c_write(i2c, PCA9539, P0_OUT, &out, 1); 218 rc = efx_i2c_write(i2c, PCA9539, P0_OUT, &out, 1);
208 if (rc) 219 if (rc)
@@ -226,6 +237,9 @@ int sfe4001_poweron(struct efx_nic *efx)
226 if (in & (1 << P1_AFE_PWD_LBN)) 237 if (in & (1 << P1_AFE_PWD_LBN))
227 goto done; 238 goto done;
228 239
240 /* DSP doesn't look powered in flash config mode */
241 if (sfe4001_phy_flash_cfg)
242 goto done;
229 } while (++count < 20); 243 } while (++count < 20);
230 244
231 EFX_INFO(efx, "timed out waiting for power\n"); 245 EFX_INFO(efx, "timed out waiting for power\n");
diff --git a/drivers/net/sfc/tenxpress.c b/drivers/net/sfc/tenxpress.c
index a2e9f79e47b1..b1cd6deec01f 100644
--- a/drivers/net/sfc/tenxpress.c
+++ b/drivers/net/sfc/tenxpress.c
@@ -24,6 +24,11 @@
24 MDIO_MMDREG_DEVS0_PCS | \ 24 MDIO_MMDREG_DEVS0_PCS | \
25 MDIO_MMDREG_DEVS0_PHYXS) 25 MDIO_MMDREG_DEVS0_PHYXS)
26 26
27#define TENXPRESS_LOOPBACKS ((1 << LOOPBACK_PHYXS) | \
28 (1 << LOOPBACK_PCS) | \
29 (1 << LOOPBACK_PMAPMD) | \
30 (1 << LOOPBACK_NETWORK))
31
27/* We complain if we fail to see the link partner as 10G capable this many 32/* We complain if we fail to see the link partner as 10G capable this many
28 * times in a row (must be > 1 as sampling the autoneg. registers is racy) 33 * times in a row (must be > 1 as sampling the autoneg. registers is racy)
29 */ 34 */
@@ -72,6 +77,10 @@
72#define PMA_PMD_BIST_RXD_LBN (1) 77#define PMA_PMD_BIST_RXD_LBN (1)
73#define PMA_PMD_BIST_AFE_LBN (0) 78#define PMA_PMD_BIST_AFE_LBN (0)
74 79
80/* Special Software reset register */
81#define PMA_PMD_EXT_CTRL_REG 49152
82#define PMA_PMD_EXT_SSR_LBN 15
83
75#define BIST_MAX_DELAY (1000) 84#define BIST_MAX_DELAY (1000)
76#define BIST_POLL_DELAY (10) 85#define BIST_POLL_DELAY (10)
77 86
@@ -86,6 +95,11 @@
86#define PCS_TEST_SELECT_REG 0xd807 /* PRM 10.5.8 */ 95#define PCS_TEST_SELECT_REG 0xd807 /* PRM 10.5.8 */
87#define CLK312_EN_LBN 3 96#define CLK312_EN_LBN 3
88 97
98/* PHYXS registers */
99#define PHYXS_TEST1 (49162)
100#define LOOPBACK_NEAR_LBN (8)
101#define LOOPBACK_NEAR_WIDTH (1)
102
89/* Boot status register */ 103/* Boot status register */
90#define PCS_BOOT_STATUS_REG (0xd000) 104#define PCS_BOOT_STATUS_REG (0xd000)
91#define PCS_BOOT_FATAL_ERR_LBN (0) 105#define PCS_BOOT_FATAL_ERR_LBN (0)
@@ -106,7 +120,9 @@ MODULE_PARM_DESC(crc_error_reset_threshold,
106 120
107struct tenxpress_phy_data { 121struct tenxpress_phy_data {
108 enum tenxpress_state state; 122 enum tenxpress_state state;
123 enum efx_loopback_mode loopback_mode;
109 atomic_t bad_crc_count; 124 atomic_t bad_crc_count;
125 int tx_disabled;
110 int bad_lp_tries; 126 int bad_lp_tries;
111}; 127};
112 128
@@ -199,10 +215,12 @@ static int tenxpress_phy_init(struct efx_nic *efx)
199 215
200 tenxpress_set_state(efx, TENXPRESS_STATUS_NORMAL); 216 tenxpress_set_state(efx, TENXPRESS_STATUS_NORMAL);
201 217
202 rc = mdio_clause45_wait_reset_mmds(efx, 218 if (!sfe4001_phy_flash_cfg) {
203 TENXPRESS_REQUIRED_DEVS); 219 rc = mdio_clause45_wait_reset_mmds(efx,
204 if (rc < 0) 220 TENXPRESS_REQUIRED_DEVS);
205 goto fail; 221 if (rc < 0)
222 goto fail;
223 }
206 224
207 rc = mdio_clause45_check_mmds(efx, TENXPRESS_REQUIRED_DEVS, 0); 225 rc = mdio_clause45_check_mmds(efx, TENXPRESS_REQUIRED_DEVS, 0);
208 if (rc < 0) 226 if (rc < 0)
@@ -225,6 +243,35 @@ static int tenxpress_phy_init(struct efx_nic *efx)
225 return rc; 243 return rc;
226} 244}
227 245
246static int tenxpress_special_reset(struct efx_nic *efx)
247{
248 int rc, reg;
249
250 EFX_TRACE(efx, "%s\n", __func__);
251
252 /* Initiate reset */
253 reg = mdio_clause45_read(efx, efx->mii.phy_id,
254 MDIO_MMD_PMAPMD, PMA_PMD_EXT_CTRL_REG);
255 reg |= (1 << PMA_PMD_EXT_SSR_LBN);
256 mdio_clause45_write(efx, efx->mii.phy_id, MDIO_MMD_PMAPMD,
257 PMA_PMD_EXT_CTRL_REG, reg);
258
259 msleep(200);
260
261 /* Wait for the blocks to come out of reset */
262 rc = mdio_clause45_wait_reset_mmds(efx,
263 TENXPRESS_REQUIRED_DEVS);
264 if (rc < 0)
265 return rc;
266
267 /* Try and reconfigure the device */
268 rc = tenxpress_init(efx);
269 if (rc < 0)
270 return rc;
271
272 return 0;
273}
274
228static void tenxpress_set_bad_lp(struct efx_nic *efx, int bad_lp) 275static void tenxpress_set_bad_lp(struct efx_nic *efx, int bad_lp)
229{ 276{
230 struct tenxpress_phy_data *pd = efx->phy_data; 277 struct tenxpress_phy_data *pd = efx->phy_data;
@@ -299,11 +346,46 @@ static int tenxpress_link_ok(struct efx_nic *efx, int check_lp)
299 return ok; 346 return ok;
300} 347}
301 348
349static void tenxpress_phyxs_loopback(struct efx_nic *efx)
350{
351 int phy_id = efx->mii.phy_id;
352 int ctrl1, ctrl2;
353
354 ctrl1 = ctrl2 = mdio_clause45_read(efx, phy_id, MDIO_MMD_PHYXS,
355 PHYXS_TEST1);
356 if (efx->loopback_mode == LOOPBACK_PHYXS)
357 ctrl2 |= (1 << LOOPBACK_NEAR_LBN);
358 else
359 ctrl2 &= ~(1 << LOOPBACK_NEAR_LBN);
360 if (ctrl1 != ctrl2)
361 mdio_clause45_write(efx, phy_id, MDIO_MMD_PHYXS,
362 PHYXS_TEST1, ctrl2);
363}
364
302static void tenxpress_phy_reconfigure(struct efx_nic *efx) 365static void tenxpress_phy_reconfigure(struct efx_nic *efx)
303{ 366{
367 struct tenxpress_phy_data *phy_data = efx->phy_data;
368 int loop_change = LOOPBACK_OUT_OF(phy_data, efx,
369 TENXPRESS_LOOPBACKS);
370
304 if (!tenxpress_state_is(efx, TENXPRESS_STATUS_NORMAL)) 371 if (!tenxpress_state_is(efx, TENXPRESS_STATUS_NORMAL))
305 return; 372 return;
306 373
374 /* When coming out of transmit disable, coming out of low power
375 * mode, or moving out of any PHY internal loopback mode,
376 * perform a special software reset */
377 if ((phy_data->tx_disabled && !efx->tx_disabled) ||
378 loop_change) {
379 (void) tenxpress_special_reset(efx);
380 falcon_reset_xaui(efx);
381 }
382
383 mdio_clause45_transmit_disable(efx);
384 mdio_clause45_phy_reconfigure(efx);
385 tenxpress_phyxs_loopback(efx);
386
387 phy_data->tx_disabled = efx->tx_disabled;
388 phy_data->loopback_mode = efx->loopback_mode;
307 efx->link_up = tenxpress_link_ok(efx, 0); 389 efx->link_up = tenxpress_link_ok(efx, 0);
308 efx->link_options = GM_LPA_10000FULL; 390 efx->link_options = GM_LPA_10000FULL;
309} 391}
@@ -431,4 +513,5 @@ struct efx_phy_operations falcon_tenxpress_phy_ops = {
431 .clear_interrupt = tenxpress_phy_clear_interrupt, 513 .clear_interrupt = tenxpress_phy_clear_interrupt,
432 .reset_xaui = tenxpress_reset_xaui, 514 .reset_xaui = tenxpress_reset_xaui,
433 .mmds = TENXPRESS_REQUIRED_DEVS, 515 .mmds = TENXPRESS_REQUIRED_DEVS,
516 .loopbacks = TENXPRESS_LOOPBACKS,
434}; 517};
diff --git a/drivers/net/sfc/tx.c b/drivers/net/sfc/tx.c
index fbb866b2185e..9b436f5b4888 100644
--- a/drivers/net/sfc/tx.c
+++ b/drivers/net/sfc/tx.c
@@ -82,6 +82,46 @@ static inline void efx_dequeue_buffer(struct efx_tx_queue *tx_queue,
82 } 82 }
83} 83}
84 84
85/**
86 * struct efx_tso_header - a DMA mapped buffer for packet headers
87 * @next: Linked list of free ones.
88 * The list is protected by the TX queue lock.
89 * @dma_unmap_len: Length to unmap for an oversize buffer, or 0.
90 * @dma_addr: The DMA address of the header below.
91 *
92 * This controls the memory used for a TSO header. Use TSOH_DATA()
93 * to find the packet header data. Use TSOH_SIZE() to calculate the
94 * total size required for a given packet header length. TSO headers
95 * in the free list are exactly %TSOH_STD_SIZE bytes in size.
96 */
97struct efx_tso_header {
98 union {
99 struct efx_tso_header *next;
100 size_t unmap_len;
101 };
102 dma_addr_t dma_addr;
103};
104
105static int efx_enqueue_skb_tso(struct efx_tx_queue *tx_queue,
106 const struct sk_buff *skb);
107static void efx_fini_tso(struct efx_tx_queue *tx_queue);
108static void efx_tsoh_heap_free(struct efx_tx_queue *tx_queue,
109 struct efx_tso_header *tsoh);
110
111static inline void efx_tsoh_free(struct efx_tx_queue *tx_queue,
112 struct efx_tx_buffer *buffer)
113{
114 if (buffer->tsoh) {
115 if (likely(!buffer->tsoh->unmap_len)) {
116 buffer->tsoh->next = tx_queue->tso_headers_free;
117 tx_queue->tso_headers_free = buffer->tsoh;
118 } else {
119 efx_tsoh_heap_free(tx_queue, buffer->tsoh);
120 }
121 buffer->tsoh = NULL;
122 }
123}
124
85 125
86/* 126/*
87 * Add a socket buffer to a TX queue 127 * Add a socket buffer to a TX queue
@@ -114,6 +154,9 @@ static inline int efx_enqueue_skb(struct efx_tx_queue *tx_queue,
114 154
115 EFX_BUG_ON_PARANOID(tx_queue->write_count != tx_queue->insert_count); 155 EFX_BUG_ON_PARANOID(tx_queue->write_count != tx_queue->insert_count);
116 156
157 if (skb_shinfo((struct sk_buff *)skb)->gso_size)
158 return efx_enqueue_skb_tso(tx_queue, skb);
159
117 /* Get size of the initial fragment */ 160 /* Get size of the initial fragment */
118 len = skb_headlen(skb); 161 len = skb_headlen(skb);
119 162
@@ -166,6 +209,8 @@ static inline int efx_enqueue_skb(struct efx_tx_queue *tx_queue,
166 insert_ptr = (tx_queue->insert_count & 209 insert_ptr = (tx_queue->insert_count &
167 efx->type->txd_ring_mask); 210 efx->type->txd_ring_mask);
168 buffer = &tx_queue->buffer[insert_ptr]; 211 buffer = &tx_queue->buffer[insert_ptr];
212 efx_tsoh_free(tx_queue, buffer);
213 EFX_BUG_ON_PARANOID(buffer->tsoh);
169 EFX_BUG_ON_PARANOID(buffer->skb); 214 EFX_BUG_ON_PARANOID(buffer->skb);
170 EFX_BUG_ON_PARANOID(buffer->len); 215 EFX_BUG_ON_PARANOID(buffer->len);
171 EFX_BUG_ON_PARANOID(buffer->continuation != 1); 216 EFX_BUG_ON_PARANOID(buffer->continuation != 1);
@@ -432,6 +477,9 @@ void efx_fini_tx_queue(struct efx_tx_queue *tx_queue)
432 477
433 efx_release_tx_buffers(tx_queue); 478 efx_release_tx_buffers(tx_queue);
434 479
480 /* Free up TSO header cache */
481 efx_fini_tso(tx_queue);
482
435 /* Release queue's stop on port, if any */ 483 /* Release queue's stop on port, if any */
436 if (tx_queue->stopped) { 484 if (tx_queue->stopped) {
437 tx_queue->stopped = 0; 485 tx_queue->stopped = 0;
@@ -450,3 +498,619 @@ void efx_remove_tx_queue(struct efx_tx_queue *tx_queue)
450} 498}
451 499
452 500
501/* Efx TCP segmentation acceleration.
502 *
503 * Why? Because by doing it here in the driver we can go significantly
504 * faster than the GSO.
505 *
506 * Requires TX checksum offload support.
507 */
508
509/* Number of bytes inserted at the start of a TSO header buffer,
510 * similar to NET_IP_ALIGN.
511 */
512#if defined(__i386__) || defined(__x86_64__)
513#define TSOH_OFFSET 0
514#else
515#define TSOH_OFFSET NET_IP_ALIGN
516#endif
517
518#define TSOH_BUFFER(tsoh) ((u8 *)(tsoh + 1) + TSOH_OFFSET)
519
520/* Total size of struct efx_tso_header, buffer and padding */
521#define TSOH_SIZE(hdr_len) \
522 (sizeof(struct efx_tso_header) + TSOH_OFFSET + hdr_len)
523
524/* Size of blocks on free list. Larger blocks must be allocated from
525 * the heap.
526 */
527#define TSOH_STD_SIZE 128
528
529#define PTR_DIFF(p1, p2) ((u8 *)(p1) - (u8 *)(p2))
530#define ETH_HDR_LEN(skb) (skb_network_header(skb) - (skb)->data)
531#define SKB_TCP_OFF(skb) PTR_DIFF(tcp_hdr(skb), (skb)->data)
532#define SKB_IPV4_OFF(skb) PTR_DIFF(ip_hdr(skb), (skb)->data)
533
534/**
535 * struct tso_state - TSO state for an SKB
536 * @remaining_len: Bytes of data we've yet to segment
537 * @seqnum: Current sequence number
538 * @packet_space: Remaining space in current packet
539 * @ifc: Input fragment cursor.
540 * Where we are in the current fragment of the incoming SKB. These
541 * values get updated in place when we split a fragment over
542 * multiple packets.
543 * @p: Parameters.
544 * These values are set once at the start of the TSO send and do
545 * not get changed as the routine progresses.
546 *
547 * The state used during segmentation. It is put into this data structure
548 * just to make it easy to pass into inline functions.
549 */
550struct tso_state {
551 unsigned remaining_len;
552 unsigned seqnum;
553 unsigned packet_space;
554
555 struct {
556 /* DMA address of current position */
557 dma_addr_t dma_addr;
558 /* Remaining length */
559 unsigned int len;
560 /* DMA address and length of the whole fragment */
561 unsigned int unmap_len;
562 dma_addr_t unmap_addr;
563 struct page *page;
564 unsigned page_off;
565 } ifc;
566
567 struct {
568 /* The number of bytes of header */
569 unsigned int header_length;
570
571 /* The number of bytes to put in each outgoing segment. */
572 int full_packet_size;
573
574 /* Current IPv4 ID, host endian. */
575 unsigned ipv4_id;
576 } p;
577};
578
579
580/*
581 * Verify that our various assumptions about sk_buffs and the conditions
582 * under which TSO will be attempted hold true.
583 */
584static inline void efx_tso_check_safe(const struct sk_buff *skb)
585{
586 EFX_BUG_ON_PARANOID(skb->protocol != htons(ETH_P_IP));
587 EFX_BUG_ON_PARANOID(((struct ethhdr *)skb->data)->h_proto !=
588 skb->protocol);
589 EFX_BUG_ON_PARANOID(ip_hdr(skb)->protocol != IPPROTO_TCP);
590 EFX_BUG_ON_PARANOID((PTR_DIFF(tcp_hdr(skb), skb->data)
591 + (tcp_hdr(skb)->doff << 2u)) >
592 skb_headlen(skb));
593}
594
595
596/*
597 * Allocate a page worth of efx_tso_header structures, and string them
598 * into the tx_queue->tso_headers_free linked list. Return 0 or -ENOMEM.
599 */
600static int efx_tsoh_block_alloc(struct efx_tx_queue *tx_queue)
601{
602
603 struct pci_dev *pci_dev = tx_queue->efx->pci_dev;
604 struct efx_tso_header *tsoh;
605 dma_addr_t dma_addr;
606 u8 *base_kva, *kva;
607
608 base_kva = pci_alloc_consistent(pci_dev, PAGE_SIZE, &dma_addr);
609 if (base_kva == NULL) {
610 EFX_ERR(tx_queue->efx, "Unable to allocate page for TSO"
611 " headers\n");
612 return -ENOMEM;
613 }
614
615 /* pci_alloc_consistent() allocates pages. */
616 EFX_BUG_ON_PARANOID(dma_addr & (PAGE_SIZE - 1u));
617
618 for (kva = base_kva; kva < base_kva + PAGE_SIZE; kva += TSOH_STD_SIZE) {
619 tsoh = (struct efx_tso_header *)kva;
620 tsoh->dma_addr = dma_addr + (TSOH_BUFFER(tsoh) - base_kva);
621 tsoh->next = tx_queue->tso_headers_free;
622 tx_queue->tso_headers_free = tsoh;
623 }
624
625 return 0;
626}
627
628
629/* Free up a TSO header, and all others in the same page. */
630static void efx_tsoh_block_free(struct efx_tx_queue *tx_queue,
631 struct efx_tso_header *tsoh,
632 struct pci_dev *pci_dev)
633{
634 struct efx_tso_header **p;
635 unsigned long base_kva;
636 dma_addr_t base_dma;
637
638 base_kva = (unsigned long)tsoh & PAGE_MASK;
639 base_dma = tsoh->dma_addr & PAGE_MASK;
640
641 p = &tx_queue->tso_headers_free;
642 while (*p != NULL)
643 if (((unsigned long)*p & PAGE_MASK) == base_kva)
644 *p = (*p)->next;
645 else
646 p = &(*p)->next;
647
648 pci_free_consistent(pci_dev, PAGE_SIZE, (void *)base_kva, base_dma);
649}
650
651static struct efx_tso_header *
652efx_tsoh_heap_alloc(struct efx_tx_queue *tx_queue, size_t header_len)
653{
654 struct efx_tso_header *tsoh;
655
656 tsoh = kmalloc(TSOH_SIZE(header_len), GFP_ATOMIC | GFP_DMA);
657 if (unlikely(!tsoh))
658 return NULL;
659
660 tsoh->dma_addr = pci_map_single(tx_queue->efx->pci_dev,
661 TSOH_BUFFER(tsoh), header_len,
662 PCI_DMA_TODEVICE);
663 if (unlikely(pci_dma_mapping_error(tsoh->dma_addr))) {
664 kfree(tsoh);
665 return NULL;
666 }
667
668 tsoh->unmap_len = header_len;
669 return tsoh;
670}
671
672static void
673efx_tsoh_heap_free(struct efx_tx_queue *tx_queue, struct efx_tso_header *tsoh)
674{
675 pci_unmap_single(tx_queue->efx->pci_dev,
676 tsoh->dma_addr, tsoh->unmap_len,
677 PCI_DMA_TODEVICE);
678 kfree(tsoh);
679}
680
681/**
682 * efx_tx_queue_insert - push descriptors onto the TX queue
683 * @tx_queue: Efx TX queue
684 * @dma_addr: DMA address of fragment
685 * @len: Length of fragment
686 * @skb: Only non-null for end of last segment
687 * @end_of_packet: True if last fragment in a packet
688 * @unmap_addr: DMA address of fragment for unmapping
689 * @unmap_len: Only set this in last segment of a fragment
690 *
691 * Push descriptors onto the TX queue. Return 0 on success or 1 if
692 * @tx_queue full.
693 */
694static int efx_tx_queue_insert(struct efx_tx_queue *tx_queue,
695 dma_addr_t dma_addr, unsigned len,
696 const struct sk_buff *skb, int end_of_packet,
697 dma_addr_t unmap_addr, unsigned unmap_len)
698{
699 struct efx_tx_buffer *buffer;
700 struct efx_nic *efx = tx_queue->efx;
701 unsigned dma_len, fill_level, insert_ptr, misalign;
702 int q_space;
703
704 EFX_BUG_ON_PARANOID(len <= 0);
705
706 fill_level = tx_queue->insert_count - tx_queue->old_read_count;
707 /* -1 as there is no way to represent all descriptors used */
708 q_space = efx->type->txd_ring_mask - 1 - fill_level;
709
710 while (1) {
711 if (unlikely(q_space-- <= 0)) {
712 /* It might be that completions have happened
713 * since the xmit path last checked. Update
714 * the xmit path's copy of read_count.
715 */
716 ++tx_queue->stopped;
717 /* This memory barrier protects the change of
718 * stopped from the access of read_count. */
719 smp_mb();
720 tx_queue->old_read_count =
721 *(volatile unsigned *)&tx_queue->read_count;
722 fill_level = (tx_queue->insert_count
723 - tx_queue->old_read_count);
724 q_space = efx->type->txd_ring_mask - 1 - fill_level;
725 if (unlikely(q_space-- <= 0))
726 return 1;
727 smp_mb();
728 --tx_queue->stopped;
729 }
730
731 insert_ptr = tx_queue->insert_count & efx->type->txd_ring_mask;
732 buffer = &tx_queue->buffer[insert_ptr];
733 ++tx_queue->insert_count;
734
735 EFX_BUG_ON_PARANOID(tx_queue->insert_count -
736 tx_queue->read_count >
737 efx->type->txd_ring_mask);
738
739 efx_tsoh_free(tx_queue, buffer);
740 EFX_BUG_ON_PARANOID(buffer->len);
741 EFX_BUG_ON_PARANOID(buffer->unmap_len);
742 EFX_BUG_ON_PARANOID(buffer->skb);
743 EFX_BUG_ON_PARANOID(buffer->continuation != 1);
744 EFX_BUG_ON_PARANOID(buffer->tsoh);
745
746 buffer->dma_addr = dma_addr;
747
748 /* Ensure we do not cross a boundary unsupported by H/W */
749 dma_len = (~dma_addr & efx->type->tx_dma_mask) + 1;
750
751 misalign = (unsigned)dma_addr & efx->type->bug5391_mask;
752 if (misalign && dma_len + misalign > 512)
753 dma_len = 512 - misalign;
754
755 /* If there is enough space to send then do so */
756 if (dma_len >= len)
757 break;
758
759 buffer->len = dma_len; /* Don't set the other members */
760 dma_addr += dma_len;
761 len -= dma_len;
762 }
763
764 EFX_BUG_ON_PARANOID(!len);
765 buffer->len = len;
766 buffer->skb = skb;
767 buffer->continuation = !end_of_packet;
768 buffer->unmap_addr = unmap_addr;
769 buffer->unmap_len = unmap_len;
770 return 0;
771}
772
773
774/*
775 * Put a TSO header into the TX queue.
776 *
777 * This is special-cased because we know that it is small enough to fit in
778 * a single fragment, and we know it doesn't cross a page boundary. It
779 * also allows us to not worry about end-of-packet etc.
780 */
781static inline void efx_tso_put_header(struct efx_tx_queue *tx_queue,
782 struct efx_tso_header *tsoh, unsigned len)
783{
784 struct efx_tx_buffer *buffer;
785
786 buffer = &tx_queue->buffer[tx_queue->insert_count &
787 tx_queue->efx->type->txd_ring_mask];
788 efx_tsoh_free(tx_queue, buffer);
789 EFX_BUG_ON_PARANOID(buffer->len);
790 EFX_BUG_ON_PARANOID(buffer->unmap_len);
791 EFX_BUG_ON_PARANOID(buffer->skb);
792 EFX_BUG_ON_PARANOID(buffer->continuation != 1);
793 EFX_BUG_ON_PARANOID(buffer->tsoh);
794 buffer->len = len;
795 buffer->dma_addr = tsoh->dma_addr;
796 buffer->tsoh = tsoh;
797
798 ++tx_queue->insert_count;
799}
800
801
802/* Remove descriptors put into a tx_queue. */
803static void efx_enqueue_unwind(struct efx_tx_queue *tx_queue)
804{
805 struct efx_tx_buffer *buffer;
806
807 /* Work backwards until we hit the original insert pointer value */
808 while (tx_queue->insert_count != tx_queue->write_count) {
809 --tx_queue->insert_count;
810 buffer = &tx_queue->buffer[tx_queue->insert_count &
811 tx_queue->efx->type->txd_ring_mask];
812 efx_tsoh_free(tx_queue, buffer);
813 EFX_BUG_ON_PARANOID(buffer->skb);
814 buffer->len = 0;
815 buffer->continuation = 1;
816 if (buffer->unmap_len) {
817 pci_unmap_page(tx_queue->efx->pci_dev,
818 buffer->unmap_addr,
819 buffer->unmap_len, PCI_DMA_TODEVICE);
820 buffer->unmap_len = 0;
821 }
822 }
823}
824
825
826/* Parse the SKB header and initialise state. */
827static inline void tso_start(struct tso_state *st, const struct sk_buff *skb)
828{
829 /* All ethernet/IP/TCP headers combined size is TCP header size
830 * plus offset of TCP header relative to start of packet.
831 */
832 st->p.header_length = ((tcp_hdr(skb)->doff << 2u)
833 + PTR_DIFF(tcp_hdr(skb), skb->data));
834 st->p.full_packet_size = (st->p.header_length
835 + skb_shinfo(skb)->gso_size);
836
837 st->p.ipv4_id = ntohs(ip_hdr(skb)->id);
838 st->seqnum = ntohl(tcp_hdr(skb)->seq);
839
840 EFX_BUG_ON_PARANOID(tcp_hdr(skb)->urg);
841 EFX_BUG_ON_PARANOID(tcp_hdr(skb)->syn);
842 EFX_BUG_ON_PARANOID(tcp_hdr(skb)->rst);
843
844 st->packet_space = st->p.full_packet_size;
845 st->remaining_len = skb->len - st->p.header_length;
846}
847
848
849/**
850 * tso_get_fragment - record fragment details and map for DMA
851 * @st: TSO state
852 * @efx: Efx NIC
853 * @data: Pointer to fragment data
854 * @len: Length of fragment
855 *
856 * Record fragment details and map for DMA. Return 0 on success, or
857 * -%ENOMEM if DMA mapping fails.
858 */
859static inline int tso_get_fragment(struct tso_state *st, struct efx_nic *efx,
860 int len, struct page *page, int page_off)
861{
862
863 st->ifc.unmap_addr = pci_map_page(efx->pci_dev, page, page_off,
864 len, PCI_DMA_TODEVICE);
865 if (likely(!pci_dma_mapping_error(st->ifc.unmap_addr))) {
866 st->ifc.unmap_len = len;
867 st->ifc.len = len;
868 st->ifc.dma_addr = st->ifc.unmap_addr;
869 st->ifc.page = page;
870 st->ifc.page_off = page_off;
871 return 0;
872 }
873 return -ENOMEM;
874}
875
876
877/**
878 * tso_fill_packet_with_fragment - form descriptors for the current fragment
879 * @tx_queue: Efx TX queue
880 * @skb: Socket buffer
881 * @st: TSO state
882 *
883 * Form descriptors for the current fragment, until we reach the end
884 * of fragment or end-of-packet. Return 0 on success, 1 if not enough
885 * space in @tx_queue.
886 */
887static inline int tso_fill_packet_with_fragment(struct efx_tx_queue *tx_queue,
888 const struct sk_buff *skb,
889 struct tso_state *st)
890{
891
892 int n, end_of_packet, rc;
893
894 if (st->ifc.len == 0)
895 return 0;
896 if (st->packet_space == 0)
897 return 0;
898
899 EFX_BUG_ON_PARANOID(st->ifc.len <= 0);
900 EFX_BUG_ON_PARANOID(st->packet_space <= 0);
901
902 n = min(st->ifc.len, st->packet_space);
903
904 st->packet_space -= n;
905 st->remaining_len -= n;
906 st->ifc.len -= n;
907 st->ifc.page_off += n;
908 end_of_packet = st->remaining_len == 0 || st->packet_space == 0;
909
910 rc = efx_tx_queue_insert(tx_queue, st->ifc.dma_addr, n,
911 st->remaining_len ? NULL : skb,
912 end_of_packet, st->ifc.unmap_addr,
913 st->ifc.len ? 0 : st->ifc.unmap_len);
914
915 st->ifc.dma_addr += n;
916
917 return rc;
918}
919
920
921/**
922 * tso_start_new_packet - generate a new header and prepare for the new packet
923 * @tx_queue: Efx TX queue
924 * @skb: Socket buffer
925 * @st: TSO state
926 *
927 * Generate a new header and prepare for the new packet. Return 0 on
928 * success, or -1 if failed to alloc header.
929 */
930static inline int tso_start_new_packet(struct efx_tx_queue *tx_queue,
931 const struct sk_buff *skb,
932 struct tso_state *st)
933{
934 struct efx_tso_header *tsoh;
935 struct iphdr *tsoh_iph;
936 struct tcphdr *tsoh_th;
937 unsigned ip_length;
938 u8 *header;
939
940 /* Allocate a DMA-mapped header buffer. */
941 if (likely(TSOH_SIZE(st->p.header_length) <= TSOH_STD_SIZE)) {
942 if (tx_queue->tso_headers_free == NULL)
943 if (efx_tsoh_block_alloc(tx_queue))
944 return -1;
945 EFX_BUG_ON_PARANOID(!tx_queue->tso_headers_free);
946 tsoh = tx_queue->tso_headers_free;
947 tx_queue->tso_headers_free = tsoh->next;
948 tsoh->unmap_len = 0;
949 } else {
950 tx_queue->tso_long_headers++;
951 tsoh = efx_tsoh_heap_alloc(tx_queue, st->p.header_length);
952 if (unlikely(!tsoh))
953 return -1;
954 }
955
956 header = TSOH_BUFFER(tsoh);
957 tsoh_th = (struct tcphdr *)(header + SKB_TCP_OFF(skb));
958 tsoh_iph = (struct iphdr *)(header + SKB_IPV4_OFF(skb));
959
960 /* Copy and update the headers. */
961 memcpy(header, skb->data, st->p.header_length);
962
963 tsoh_th->seq = htonl(st->seqnum);
964 st->seqnum += skb_shinfo(skb)->gso_size;
965 if (st->remaining_len > skb_shinfo(skb)->gso_size) {
966 /* This packet will not finish the TSO burst. */
967 ip_length = st->p.full_packet_size - ETH_HDR_LEN(skb);
968 tsoh_th->fin = 0;
969 tsoh_th->psh = 0;
970 } else {
971 /* This packet will be the last in the TSO burst. */
972 ip_length = (st->p.header_length - ETH_HDR_LEN(skb)
973 + st->remaining_len);
974 tsoh_th->fin = tcp_hdr(skb)->fin;
975 tsoh_th->psh = tcp_hdr(skb)->psh;
976 }
977 tsoh_iph->tot_len = htons(ip_length);
978
979 /* Linux leaves suitable gaps in the IP ID space for us to fill. */
980 tsoh_iph->id = htons(st->p.ipv4_id);
981 st->p.ipv4_id++;
982
983 st->packet_space = skb_shinfo(skb)->gso_size;
984 ++tx_queue->tso_packets;
985
986 /* Form a descriptor for this header. */
987 efx_tso_put_header(tx_queue, tsoh, st->p.header_length);
988
989 return 0;
990}
991
992
993/**
994 * efx_enqueue_skb_tso - segment and transmit a TSO socket buffer
995 * @tx_queue: Efx TX queue
996 * @skb: Socket buffer
997 *
998 * Context: You must hold netif_tx_lock() to call this function.
999 *
1000 * Add socket buffer @skb to @tx_queue, doing TSO or return != 0 if
1001 * @skb was not enqueued. In all cases @skb is consumed. Return
1002 * %NETDEV_TX_OK or %NETDEV_TX_BUSY.
1003 */
1004static int efx_enqueue_skb_tso(struct efx_tx_queue *tx_queue,
1005 const struct sk_buff *skb)
1006{
1007 int frag_i, rc, rc2 = NETDEV_TX_OK;
1008 struct tso_state state;
1009 skb_frag_t *f;
1010
1011 /* Verify TSO is safe - these checks should never fail. */
1012 efx_tso_check_safe(skb);
1013
1014 EFX_BUG_ON_PARANOID(tx_queue->write_count != tx_queue->insert_count);
1015
1016 tso_start(&state, skb);
1017
1018 /* Assume that skb header area contains exactly the headers, and
1019 * all payload is in the frag list.
1020 */
1021 if (skb_headlen(skb) == state.p.header_length) {
1022 /* Grab the first payload fragment. */
1023 EFX_BUG_ON_PARANOID(skb_shinfo(skb)->nr_frags < 1);
1024 frag_i = 0;
1025 f = &skb_shinfo(skb)->frags[frag_i];
1026 rc = tso_get_fragment(&state, tx_queue->efx,
1027 f->size, f->page, f->page_offset);
1028 if (rc)
1029 goto mem_err;
1030 } else {
1031 /* It may look like this code fragment assumes that the
1032 * skb->data portion does not cross a page boundary, but
1033 * that is not the case. It is guaranteed to be direct
1034 * mapped memory, and therefore is physically contiguous,
1035 * and so DMA will work fine. kmap_atomic() on this region
1036 * will just return the direct mapping, so that will work
1037 * too.
1038 */
1039 int page_off = (unsigned long)skb->data & (PAGE_SIZE - 1);
1040 int hl = state.p.header_length;
1041 rc = tso_get_fragment(&state, tx_queue->efx,
1042 skb_headlen(skb) - hl,
1043 virt_to_page(skb->data), page_off + hl);
1044 if (rc)
1045 goto mem_err;
1046 frag_i = -1;
1047 }
1048
1049 if (tso_start_new_packet(tx_queue, skb, &state) < 0)
1050 goto mem_err;
1051
1052 while (1) {
1053 rc = tso_fill_packet_with_fragment(tx_queue, skb, &state);
1054 if (unlikely(rc))
1055 goto stop;
1056
1057 /* Move onto the next fragment? */
1058 if (state.ifc.len == 0) {
1059 if (++frag_i >= skb_shinfo(skb)->nr_frags)
1060 /* End of payload reached. */
1061 break;
1062 f = &skb_shinfo(skb)->frags[frag_i];
1063 rc = tso_get_fragment(&state, tx_queue->efx,
1064 f->size, f->page, f->page_offset);
1065 if (rc)
1066 goto mem_err;
1067 }
1068
1069 /* Start at new packet? */
1070 if (state.packet_space == 0 &&
1071 tso_start_new_packet(tx_queue, skb, &state) < 0)
1072 goto mem_err;
1073 }
1074
1075 /* Pass off to hardware */
1076 falcon_push_buffers(tx_queue);
1077
1078 tx_queue->tso_bursts++;
1079 return NETDEV_TX_OK;
1080
1081 mem_err:
1082 EFX_ERR(tx_queue->efx, "Out of memory for TSO headers, or PCI mapping"
1083 " error\n");
1084 dev_kfree_skb_any((struct sk_buff *)skb);
1085 goto unwind;
1086
1087 stop:
1088 rc2 = NETDEV_TX_BUSY;
1089
1090 /* Stop the queue if it wasn't stopped before. */
1091 if (tx_queue->stopped == 1)
1092 efx_stop_queue(tx_queue->efx);
1093
1094 unwind:
1095 efx_enqueue_unwind(tx_queue);
1096 return rc2;
1097}
1098
1099
1100/*
1101 * Free up all TSO datastructures associated with tx_queue. This
1102 * routine should be called only once the tx_queue is both empty and
1103 * will no longer be used.
1104 */
1105static void efx_fini_tso(struct efx_tx_queue *tx_queue)
1106{
1107 unsigned i;
1108
1109 if (tx_queue->buffer)
1110 for (i = 0; i <= tx_queue->efx->type->txd_ring_mask; ++i)
1111 efx_tsoh_free(tx_queue, &tx_queue->buffer[i]);
1112
1113 while (tx_queue->tso_headers_free != NULL)
1114 efx_tsoh_block_free(tx_queue, tx_queue->tso_headers_free,
1115 tx_queue->efx->pci_dev);
1116}
diff --git a/drivers/net/sfc/xfp_phy.c b/drivers/net/sfc/xfp_phy.c
index 66dd5bf1eaa9..3b9f9ddbc372 100644
--- a/drivers/net/sfc/xfp_phy.c
+++ b/drivers/net/sfc/xfp_phy.c
@@ -24,6 +24,10 @@
24 MDIO_MMDREG_DEVS0_PMAPMD | \ 24 MDIO_MMDREG_DEVS0_PMAPMD | \
25 MDIO_MMDREG_DEVS0_PHYXS) 25 MDIO_MMDREG_DEVS0_PHYXS)
26 26
27#define XFP_LOOPBACKS ((1 << LOOPBACK_PCS) | \
28 (1 << LOOPBACK_PMAPMD) | \
29 (1 << LOOPBACK_NETWORK))
30
27/****************************************************************************/ 31/****************************************************************************/
28/* Quake-specific MDIO registers */ 32/* Quake-specific MDIO registers */
29#define MDIO_QUAKE_LED0_REG (0xD006) 33#define MDIO_QUAKE_LED0_REG (0xD006)
@@ -35,6 +39,10 @@ void xfp_set_led(struct efx_nic *p, int led, int mode)
35 mode); 39 mode);
36} 40}
37 41
42struct xfp_phy_data {
43 int tx_disabled;
44};
45
38#define XFP_MAX_RESET_TIME 500 46#define XFP_MAX_RESET_TIME 500
39#define XFP_RESET_WAIT 10 47#define XFP_RESET_WAIT 10
40 48
@@ -72,18 +80,31 @@ static int xfp_reset_phy(struct efx_nic *efx)
72 80
73static int xfp_phy_init(struct efx_nic *efx) 81static int xfp_phy_init(struct efx_nic *efx)
74{ 82{
83 struct xfp_phy_data *phy_data;
75 u32 devid = mdio_clause45_read_id(efx, MDIO_MMD_PHYXS); 84 u32 devid = mdio_clause45_read_id(efx, MDIO_MMD_PHYXS);
76 int rc; 85 int rc;
77 86
87 phy_data = kzalloc(sizeof(struct xfp_phy_data), GFP_KERNEL);
88 efx->phy_data = (void *) phy_data;
89
78 EFX_INFO(efx, "XFP: PHY ID reg %x (OUI %x model %x revision" 90 EFX_INFO(efx, "XFP: PHY ID reg %x (OUI %x model %x revision"
79 " %x)\n", devid, MDIO_ID_OUI(devid), MDIO_ID_MODEL(devid), 91 " %x)\n", devid, MDIO_ID_OUI(devid), MDIO_ID_MODEL(devid),
80 MDIO_ID_REV(devid)); 92 MDIO_ID_REV(devid));
81 93
94 phy_data->tx_disabled = efx->tx_disabled;
95
82 rc = xfp_reset_phy(efx); 96 rc = xfp_reset_phy(efx);
83 97
84 EFX_INFO(efx, "XFP: PHY init %s.\n", 98 EFX_INFO(efx, "XFP: PHY init %s.\n",
85 rc ? "failed" : "successful"); 99 rc ? "failed" : "successful");
100 if (rc < 0)
101 goto fail;
86 102
103 return 0;
104
105 fail:
106 kfree(efx->phy_data);
107 efx->phy_data = NULL;
87 return rc; 108 return rc;
88} 109}
89 110
@@ -110,6 +131,16 @@ static int xfp_phy_check_hw(struct efx_nic *efx)
110 131
111static void xfp_phy_reconfigure(struct efx_nic *efx) 132static void xfp_phy_reconfigure(struct efx_nic *efx)
112{ 133{
134 struct xfp_phy_data *phy_data = efx->phy_data;
135
136 /* Reset the PHY when moving from tx off to tx on */
137 if (phy_data->tx_disabled && !efx->tx_disabled)
138 xfp_reset_phy(efx);
139
140 mdio_clause45_transmit_disable(efx);
141 mdio_clause45_phy_reconfigure(efx);
142
143 phy_data->tx_disabled = efx->tx_disabled;
113 efx->link_up = xfp_link_ok(efx); 144 efx->link_up = xfp_link_ok(efx);
114 efx->link_options = GM_LPA_10000FULL; 145 efx->link_options = GM_LPA_10000FULL;
115} 146}
@@ -119,6 +150,10 @@ static void xfp_phy_fini(struct efx_nic *efx)
119{ 150{
120 /* Clobber the LED if it was blinking */ 151 /* Clobber the LED if it was blinking */
121 efx->board_info.blink(efx, 0); 152 efx->board_info.blink(efx, 0);
153
154 /* Free the context block */
155 kfree(efx->phy_data);
156 efx->phy_data = NULL;
122} 157}
123 158
124struct efx_phy_operations falcon_xfp_phy_ops = { 159struct efx_phy_operations falcon_xfp_phy_ops = {
@@ -129,4 +164,5 @@ struct efx_phy_operations falcon_xfp_phy_ops = {
129 .clear_interrupt = xfp_phy_clear_interrupt, 164 .clear_interrupt = xfp_phy_clear_interrupt,
130 .reset_xaui = efx_port_dummy_op_void, 165 .reset_xaui = efx_port_dummy_op_void,
131 .mmds = XFP_REQUIRED_DEVS, 166 .mmds = XFP_REQUIRED_DEVS,
167 .loopbacks = XFP_LOOPBACKS,
132}; 168};
diff --git a/drivers/net/sky2.h b/drivers/net/sky2.h
index 7bb3ba9bcbd8..c0a5eea20007 100644
--- a/drivers/net/sky2.h
+++ b/drivers/net/sky2.h
@@ -1966,13 +1966,13 @@ struct sky2_status_le {
1966struct tx_ring_info { 1966struct tx_ring_info {
1967 struct sk_buff *skb; 1967 struct sk_buff *skb;
1968 DECLARE_PCI_UNMAP_ADDR(mapaddr); 1968 DECLARE_PCI_UNMAP_ADDR(mapaddr);
1969 DECLARE_PCI_UNMAP_ADDR(maplen); 1969 DECLARE_PCI_UNMAP_LEN(maplen);
1970}; 1970};
1971 1971
1972struct rx_ring_info { 1972struct rx_ring_info {
1973 struct sk_buff *skb; 1973 struct sk_buff *skb;
1974 dma_addr_t data_addr; 1974 dma_addr_t data_addr;
1975 DECLARE_PCI_UNMAP_ADDR(data_size); 1975 DECLARE_PCI_UNMAP_LEN(data_size);
1976 dma_addr_t frag_addr[ETH_JUMBO_MTU >> PAGE_SHIFT]; 1976 dma_addr_t frag_addr[ETH_JUMBO_MTU >> PAGE_SHIFT];
1977}; 1977};
1978 1978
diff --git a/drivers/net/wan/Kconfig b/drivers/net/wan/Kconfig
index 8005dd16fb4e..d5140aed7b79 100644
--- a/drivers/net/wan/Kconfig
+++ b/drivers/net/wan/Kconfig
@@ -150,11 +150,9 @@ config HDLC_FR
150 150
151config HDLC_PPP 151config HDLC_PPP
152 tristate "Synchronous Point-to-Point Protocol (PPP) support" 152 tristate "Synchronous Point-to-Point Protocol (PPP) support"
153 depends on HDLC && BROKEN 153 depends on HDLC
154 help 154 help
155 Generic HDLC driver supporting PPP over WAN connections. 155 Generic HDLC driver supporting PPP over WAN connections.
156 This module is currently broken and will cause a kernel panic
157 when a device configured in PPP mode is activated.
158 156
159 It will be replaced by new PPP implementation in Linux 2.6.26. 157 It will be replaced by new PPP implementation in Linux 2.6.26.
160 158
diff --git a/drivers/net/wan/cosa.c b/drivers/net/wan/cosa.c
index 45ddfc9763cc..b0fce1387eaf 100644
--- a/drivers/net/wan/cosa.c
+++ b/drivers/net/wan/cosa.c
@@ -629,7 +629,7 @@ static void sppp_channel_init(struct channel_data *chan)
629 d->base_addr = chan->cosa->datareg; 629 d->base_addr = chan->cosa->datareg;
630 d->irq = chan->cosa->irq; 630 d->irq = chan->cosa->irq;
631 d->dma = chan->cosa->dma; 631 d->dma = chan->cosa->dma;
632 d->priv = chan; 632 d->ml_priv = chan;
633 sppp_attach(&chan->pppdev); 633 sppp_attach(&chan->pppdev);
634 if (register_netdev(d)) { 634 if (register_netdev(d)) {
635 printk(KERN_WARNING "%s: register_netdev failed.\n", d->name); 635 printk(KERN_WARNING "%s: register_netdev failed.\n", d->name);
@@ -650,7 +650,7 @@ static void sppp_channel_delete(struct channel_data *chan)
650 650
651static int cosa_sppp_open(struct net_device *d) 651static int cosa_sppp_open(struct net_device *d)
652{ 652{
653 struct channel_data *chan = d->priv; 653 struct channel_data *chan = d->ml_priv;
654 int err; 654 int err;
655 unsigned long flags; 655 unsigned long flags;
656 656
@@ -690,7 +690,7 @@ static int cosa_sppp_open(struct net_device *d)
690 690
691static int cosa_sppp_tx(struct sk_buff *skb, struct net_device *dev) 691static int cosa_sppp_tx(struct sk_buff *skb, struct net_device *dev)
692{ 692{
693 struct channel_data *chan = dev->priv; 693 struct channel_data *chan = dev->ml_priv;
694 694
695 netif_stop_queue(dev); 695 netif_stop_queue(dev);
696 696
@@ -701,7 +701,7 @@ static int cosa_sppp_tx(struct sk_buff *skb, struct net_device *dev)
701 701
702static void cosa_sppp_timeout(struct net_device *dev) 702static void cosa_sppp_timeout(struct net_device *dev)
703{ 703{
704 struct channel_data *chan = dev->priv; 704 struct channel_data *chan = dev->ml_priv;
705 705
706 if (test_bit(RXBIT, &chan->cosa->rxtx)) { 706 if (test_bit(RXBIT, &chan->cosa->rxtx)) {
707 chan->stats.rx_errors++; 707 chan->stats.rx_errors++;
@@ -720,7 +720,7 @@ static void cosa_sppp_timeout(struct net_device *dev)
720 720
721static int cosa_sppp_close(struct net_device *d) 721static int cosa_sppp_close(struct net_device *d)
722{ 722{
723 struct channel_data *chan = d->priv; 723 struct channel_data *chan = d->ml_priv;
724 unsigned long flags; 724 unsigned long flags;
725 725
726 netif_stop_queue(d); 726 netif_stop_queue(d);
@@ -800,7 +800,7 @@ static int sppp_tx_done(struct channel_data *chan, int size)
800 800
801static struct net_device_stats *cosa_net_stats(struct net_device *dev) 801static struct net_device_stats *cosa_net_stats(struct net_device *dev)
802{ 802{
803 struct channel_data *chan = dev->priv; 803 struct channel_data *chan = dev->ml_priv;
804 return &chan->stats; 804 return &chan->stats;
805} 805}
806 806
@@ -1217,7 +1217,7 @@ static int cosa_sppp_ioctl(struct net_device *dev, struct ifreq *ifr,
1217 int cmd) 1217 int cmd)
1218{ 1218{
1219 int rv; 1219 int rv;
1220 struct channel_data *chan = dev->priv; 1220 struct channel_data *chan = dev->ml_priv;
1221 rv = cosa_ioctl_common(chan->cosa, chan, cmd, (unsigned long)ifr->ifr_data); 1221 rv = cosa_ioctl_common(chan->cosa, chan, cmd, (unsigned long)ifr->ifr_data);
1222 if (rv == -ENOIOCTLCMD) { 1222 if (rv == -ENOIOCTLCMD) {
1223 return sppp_do_ioctl(dev, ifr, cmd); 1223 return sppp_do_ioctl(dev, ifr, cmd);
diff --git a/drivers/net/wan/hdlc_ppp.c b/drivers/net/wan/hdlc_ppp.c
index 10396d9686f4..00308337928e 100644
--- a/drivers/net/wan/hdlc_ppp.c
+++ b/drivers/net/wan/hdlc_ppp.c
@@ -45,7 +45,7 @@ static int ppp_open(struct net_device *dev)
45 int (*old_ioctl)(struct net_device *, struct ifreq *, int); 45 int (*old_ioctl)(struct net_device *, struct ifreq *, int);
46 int result; 46 int result;
47 47
48 dev->priv = &state(hdlc)->syncppp_ptr; 48 dev->ml_priv = &state(hdlc)->syncppp_ptr;
49 state(hdlc)->syncppp_ptr = &state(hdlc)->pppdev; 49 state(hdlc)->syncppp_ptr = &state(hdlc)->pppdev;
50 state(hdlc)->pppdev.dev = dev; 50 state(hdlc)->pppdev.dev = dev;
51 51
diff --git a/drivers/net/wan/hostess_sv11.c b/drivers/net/wan/hostess_sv11.c
index 83dbc924fcb5..f3065d3473fd 100644
--- a/drivers/net/wan/hostess_sv11.c
+++ b/drivers/net/wan/hostess_sv11.c
@@ -75,7 +75,7 @@ static void hostess_input(struct z8530_channel *c, struct sk_buff *skb)
75 75
76static int hostess_open(struct net_device *d) 76static int hostess_open(struct net_device *d)
77{ 77{
78 struct sv11_device *sv11=d->priv; 78 struct sv11_device *sv11=d->ml_priv;
79 int err = -1; 79 int err = -1;
80 80
81 /* 81 /*
@@ -128,7 +128,7 @@ static int hostess_open(struct net_device *d)
128 128
129static int hostess_close(struct net_device *d) 129static int hostess_close(struct net_device *d)
130{ 130{
131 struct sv11_device *sv11=d->priv; 131 struct sv11_device *sv11=d->ml_priv;
132 /* 132 /*
133 * Discard new frames 133 * Discard new frames
134 */ 134 */
@@ -159,14 +159,14 @@ static int hostess_close(struct net_device *d)
159 159
160static int hostess_ioctl(struct net_device *d, struct ifreq *ifr, int cmd) 160static int hostess_ioctl(struct net_device *d, struct ifreq *ifr, int cmd)
161{ 161{
162 /* struct sv11_device *sv11=d->priv; 162 /* struct sv11_device *sv11=d->ml_priv;
163 z8530_ioctl(d,&sv11->sync.chanA,ifr,cmd) */ 163 z8530_ioctl(d,&sv11->sync.chanA,ifr,cmd) */
164 return sppp_do_ioctl(d, ifr,cmd); 164 return sppp_do_ioctl(d, ifr,cmd);
165} 165}
166 166
167static struct net_device_stats *hostess_get_stats(struct net_device *d) 167static struct net_device_stats *hostess_get_stats(struct net_device *d)
168{ 168{
169 struct sv11_device *sv11=d->priv; 169 struct sv11_device *sv11=d->ml_priv;
170 if(sv11) 170 if(sv11)
171 return z8530_get_stats(&sv11->sync.chanA); 171 return z8530_get_stats(&sv11->sync.chanA);
172 else 172 else
@@ -179,7 +179,7 @@ static struct net_device_stats *hostess_get_stats(struct net_device *d)
179 179
180static int hostess_queue_xmit(struct sk_buff *skb, struct net_device *d) 180static int hostess_queue_xmit(struct sk_buff *skb, struct net_device *d)
181{ 181{
182 struct sv11_device *sv11=d->priv; 182 struct sv11_device *sv11=d->ml_priv;
183 return z8530_queue_xmit(&sv11->sync.chanA, skb); 183 return z8530_queue_xmit(&sv11->sync.chanA, skb);
184} 184}
185 185
@@ -325,6 +325,7 @@ static struct sv11_device *sv11_init(int iobase, int irq)
325 /* 325 /*
326 * Initialise the PPP components 326 * Initialise the PPP components
327 */ 327 */
328 d->ml_priv = sv;
328 sppp_attach(&sv->netdev); 329 sppp_attach(&sv->netdev);
329 330
330 /* 331 /*
@@ -333,7 +334,6 @@ static struct sv11_device *sv11_init(int iobase, int irq)
333 334
334 d->base_addr = iobase; 335 d->base_addr = iobase;
335 d->irq = irq; 336 d->irq = irq;
336 d->priv = sv;
337 337
338 if(register_netdev(d)) 338 if(register_netdev(d))
339 { 339 {
diff --git a/drivers/net/wan/lmc/lmc_main.c b/drivers/net/wan/lmc/lmc_main.c
index 6635ecef36e5..62133cee446a 100644
--- a/drivers/net/wan/lmc/lmc_main.c
+++ b/drivers/net/wan/lmc/lmc_main.c
@@ -891,6 +891,7 @@ static int __devinit lmc_init_one(struct pci_dev *pdev,
891 891
892 /* Initialize the sppp layer */ 892 /* Initialize the sppp layer */
893 /* An ioctl can cause a subsequent detach for raw frame interface */ 893 /* An ioctl can cause a subsequent detach for raw frame interface */
894 dev->ml_priv = sc;
894 sc->if_type = LMC_PPP; 895 sc->if_type = LMC_PPP;
895 sc->check = 0xBEAFCAFE; 896 sc->check = 0xBEAFCAFE;
896 dev->base_addr = pci_resource_start(pdev, 0); 897 dev->base_addr = pci_resource_start(pdev, 0);
diff --git a/drivers/net/wan/sealevel.c b/drivers/net/wan/sealevel.c
index 11276bf3149f..44a89df1b8bf 100644
--- a/drivers/net/wan/sealevel.c
+++ b/drivers/net/wan/sealevel.c
@@ -241,6 +241,7 @@ static inline struct slvl_device *slvl_alloc(int iobase, int irq)
241 return NULL; 241 return NULL;
242 242
243 sv = d->priv; 243 sv = d->priv;
244 d->ml_priv = sv;
244 sv->if_ptr = &sv->pppdev; 245 sv->if_ptr = &sv->pppdev;
245 sv->pppdev.dev = d; 246 sv->pppdev.dev = d;
246 d->base_addr = iobase; 247 d->base_addr = iobase;
diff --git a/drivers/net/wireless/iwlwifi/iwl-3945.c b/drivers/net/wireless/iwlwifi/iwl-3945.c
index d3406830c8e3..62a3d8f8563e 100644
--- a/drivers/net/wireless/iwlwifi/iwl-3945.c
+++ b/drivers/net/wireless/iwlwifi/iwl-3945.c
@@ -666,7 +666,7 @@ static void iwl3945_rx_reply_rx(struct iwl3945_priv *priv,
666 rx_status.flag = 0; 666 rx_status.flag = 0;
667 rx_status.mactime = le64_to_cpu(rx_end->timestamp); 667 rx_status.mactime = le64_to_cpu(rx_end->timestamp);
668 rx_status.freq = 668 rx_status.freq =
669 ieee80211_frequency_to_channel(le16_to_cpu(rx_hdr->channel)); 669 ieee80211_channel_to_frequency(le16_to_cpu(rx_hdr->channel));
670 rx_status.band = (rx_hdr->phy_flags & RX_RES_PHY_FLAGS_BAND_24_MSK) ? 670 rx_status.band = (rx_hdr->phy_flags & RX_RES_PHY_FLAGS_BAND_24_MSK) ?
671 IEEE80211_BAND_2GHZ : IEEE80211_BAND_5GHZ; 671 IEEE80211_BAND_2GHZ : IEEE80211_BAND_5GHZ;
672 672
diff --git a/drivers/net/wireless/iwlwifi/iwl-4965-rs.c b/drivers/net/wireless/iwlwifi/iwl-4965-rs.c
index b608e1ca8b40..c9847b1a67f7 100644
--- a/drivers/net/wireless/iwlwifi/iwl-4965-rs.c
+++ b/drivers/net/wireless/iwlwifi/iwl-4965-rs.c
@@ -163,8 +163,8 @@ struct iwl4965_lq_sta {
163 struct dentry *rs_sta_dbgfs_tx_agg_tid_en_file; 163 struct dentry *rs_sta_dbgfs_tx_agg_tid_en_file;
164#endif 164#endif
165 struct iwl4965_rate dbg_fixed; 165 struct iwl4965_rate dbg_fixed;
166 struct iwl_priv *drv;
167#endif 166#endif
167 struct iwl_priv *drv;
168}; 168};
169 169
170static void rs_rate_scale_perform(struct iwl_priv *priv, 170static void rs_rate_scale_perform(struct iwl_priv *priv,
diff --git a/drivers/net/wireless/iwlwifi/iwl-4965.c b/drivers/net/wireless/iwlwifi/iwl-4965.c
index 17f629fb96ff..bf19eb8aafd0 100644
--- a/drivers/net/wireless/iwlwifi/iwl-4965.c
+++ b/drivers/net/wireless/iwlwifi/iwl-4965.c
@@ -3978,7 +3978,7 @@ static void iwl4965_rx_reply_rx(struct iwl_priv *priv,
3978 3978
3979 rx_status.mactime = le64_to_cpu(rx_start->timestamp); 3979 rx_status.mactime = le64_to_cpu(rx_start->timestamp);
3980 rx_status.freq = 3980 rx_status.freq =
3981 ieee80211_frequency_to_channel(le16_to_cpu(rx_start->channel)); 3981 ieee80211_channel_to_frequency(le16_to_cpu(rx_start->channel));
3982 rx_status.band = (rx_start->phy_flags & RX_RES_PHY_FLAGS_BAND_24_MSK) ? 3982 rx_status.band = (rx_start->phy_flags & RX_RES_PHY_FLAGS_BAND_24_MSK) ?
3983 IEEE80211_BAND_2GHZ : IEEE80211_BAND_5GHZ; 3983 IEEE80211_BAND_2GHZ : IEEE80211_BAND_5GHZ;
3984 rx_status.rate_idx = 3984 rx_status.rate_idx =
diff --git a/drivers/net/wireless/prism54/islpci_dev.c b/drivers/net/wireless/prism54/islpci_dev.c
index 04c2638d75ad..9196825ed1b5 100644
--- a/drivers/net/wireless/prism54/islpci_dev.c
+++ b/drivers/net/wireless/prism54/islpci_dev.c
@@ -388,8 +388,15 @@ islpci_open(struct net_device *ndev)
388 388
389 netif_start_queue(ndev); 389 netif_start_queue(ndev);
390 390
391 /* Turn off carrier unless we know we have associated */ 391 /* Turn off carrier if in STA or Ad-hoc mode. It will be turned on
392 netif_carrier_off(ndev); 392 * once the firmware receives a trap of being associated
393 * (GEN_OID_LINKSTATE). In other modes (AP or WDS or monitor) we
394 * should just leave the carrier on as its expected the firmware
395 * won't send us a trigger. */
396 if (priv->iw_mode == IW_MODE_INFRA || priv->iw_mode == IW_MODE_ADHOC)
397 netif_carrier_off(ndev);
398 else
399 netif_carrier_on(ndev);
393 400
394 return 0; 401 return 0;
395} 402}
diff --git a/drivers/net/wireless/rt2x00/rt2x00dev.c b/drivers/net/wireless/rt2x00/rt2x00dev.c
index 8d8657fb64dd..b22c02737185 100644
--- a/drivers/net/wireless/rt2x00/rt2x00dev.c
+++ b/drivers/net/wireless/rt2x00/rt2x00dev.c
@@ -1032,8 +1032,10 @@ static int rt2x00lib_initialize(struct rt2x00_dev *rt2x00dev)
1032 * Initialize the device. 1032 * Initialize the device.
1033 */ 1033 */
1034 status = rt2x00dev->ops->lib->initialize(rt2x00dev); 1034 status = rt2x00dev->ops->lib->initialize(rt2x00dev);
1035 if (status) 1035 if (status) {
1036 goto exit; 1036 rt2x00queue_uninitialize(rt2x00dev);
1037 return status;
1038 }
1037 1039
1038 __set_bit(DEVICE_INITIALIZED, &rt2x00dev->flags); 1040 __set_bit(DEVICE_INITIALIZED, &rt2x00dev->flags);
1039 1041
@@ -1043,11 +1045,6 @@ static int rt2x00lib_initialize(struct rt2x00_dev *rt2x00dev)
1043 rt2x00rfkill_register(rt2x00dev); 1045 rt2x00rfkill_register(rt2x00dev);
1044 1046
1045 return 0; 1047 return 0;
1046
1047exit:
1048 rt2x00lib_uninitialize(rt2x00dev);
1049
1050 return status;
1051} 1048}
1052 1049
1053int rt2x00lib_start(struct rt2x00_dev *rt2x00dev) 1050int rt2x00lib_start(struct rt2x00_dev *rt2x00dev)
diff --git a/drivers/net/wireless/rt2x00/rt2x00pci.c b/drivers/net/wireless/rt2x00/rt2x00pci.c
index 7867ec64bd2c..971af2546b59 100644
--- a/drivers/net/wireless/rt2x00/rt2x00pci.c
+++ b/drivers/net/wireless/rt2x00/rt2x00pci.c
@@ -314,13 +314,14 @@ int rt2x00pci_initialize(struct rt2x00_dev *rt2x00dev)
314 if (status) { 314 if (status) {
315 ERROR(rt2x00dev, "IRQ %d allocation failed (error %d).\n", 315 ERROR(rt2x00dev, "IRQ %d allocation failed (error %d).\n",
316 pci_dev->irq, status); 316 pci_dev->irq, status);
317 return status; 317 goto exit;
318 } 318 }
319 319
320 return 0; 320 return 0;
321 321
322exit: 322exit:
323 rt2x00pci_uninitialize(rt2x00dev); 323 queue_for_each(rt2x00dev, queue)
324 rt2x00pci_free_queue_dma(rt2x00dev, queue);
324 325
325 return status; 326 return status;
326} 327}
diff --git a/drivers/net/wireless/rt2x00/rt61pci.c b/drivers/net/wireless/rt2x00/rt61pci.c
index ae12dcdd3c24..14bc7b281659 100644
--- a/drivers/net/wireless/rt2x00/rt61pci.c
+++ b/drivers/net/wireless/rt2x00/rt61pci.c
@@ -2366,6 +2366,7 @@ static int rt61pci_beacon_update(struct ieee80211_hw *hw, struct sk_buff *skb,
2366{ 2366{
2367 struct rt2x00_dev *rt2x00dev = hw->priv; 2367 struct rt2x00_dev *rt2x00dev = hw->priv;
2368 struct rt2x00_intf *intf = vif_to_intf(control->vif); 2368 struct rt2x00_intf *intf = vif_to_intf(control->vif);
2369 struct queue_entry_priv_pci_tx *priv_tx;
2369 struct skb_frame_desc *skbdesc; 2370 struct skb_frame_desc *skbdesc;
2370 unsigned int beacon_base; 2371 unsigned int beacon_base;
2371 u32 reg; 2372 u32 reg;
@@ -2373,21 +2374,8 @@ static int rt61pci_beacon_update(struct ieee80211_hw *hw, struct sk_buff *skb,
2373 if (unlikely(!intf->beacon)) 2374 if (unlikely(!intf->beacon))
2374 return -ENOBUFS; 2375 return -ENOBUFS;
2375 2376
2376 /* 2377 priv_tx = intf->beacon->priv_data;
2377 * We need to append the descriptor in front of the 2378 memset(priv_tx->desc, 0, intf->beacon->queue->desc_size);
2378 * beacon frame.
2379 */
2380 if (skb_headroom(skb) < intf->beacon->queue->desc_size) {
2381 if (pskb_expand_head(skb, intf->beacon->queue->desc_size,
2382 0, GFP_ATOMIC))
2383 return -ENOMEM;
2384 }
2385
2386 /*
2387 * Add the descriptor in front of the skb.
2388 */
2389 skb_push(skb, intf->beacon->queue->desc_size);
2390 memset(skb->data, 0, intf->beacon->queue->desc_size);
2391 2379
2392 /* 2380 /*
2393 * Fill in skb descriptor 2381 * Fill in skb descriptor
@@ -2395,9 +2383,9 @@ static int rt61pci_beacon_update(struct ieee80211_hw *hw, struct sk_buff *skb,
2395 skbdesc = get_skb_frame_desc(skb); 2383 skbdesc = get_skb_frame_desc(skb);
2396 memset(skbdesc, 0, sizeof(*skbdesc)); 2384 memset(skbdesc, 0, sizeof(*skbdesc));
2397 skbdesc->flags |= FRAME_DESC_DRIVER_GENERATED; 2385 skbdesc->flags |= FRAME_DESC_DRIVER_GENERATED;
2398 skbdesc->data = skb->data + intf->beacon->queue->desc_size; 2386 skbdesc->data = skb->data;
2399 skbdesc->data_len = skb->len - intf->beacon->queue->desc_size; 2387 skbdesc->data_len = skb->len;
2400 skbdesc->desc = skb->data; 2388 skbdesc->desc = priv_tx->desc;
2401 skbdesc->desc_len = intf->beacon->queue->desc_size; 2389 skbdesc->desc_len = intf->beacon->queue->desc_size;
2402 skbdesc->entry = intf->beacon; 2390 skbdesc->entry = intf->beacon;
2403 2391
@@ -2425,7 +2413,10 @@ static int rt61pci_beacon_update(struct ieee80211_hw *hw, struct sk_buff *skb,
2425 */ 2413 */
2426 beacon_base = HW_BEACON_OFFSET(intf->beacon->entry_idx); 2414 beacon_base = HW_BEACON_OFFSET(intf->beacon->entry_idx);
2427 rt2x00pci_register_multiwrite(rt2x00dev, beacon_base, 2415 rt2x00pci_register_multiwrite(rt2x00dev, beacon_base,
2428 skb->data, skb->len); 2416 skbdesc->desc, skbdesc->desc_len);
2417 rt2x00pci_register_multiwrite(rt2x00dev,
2418 beacon_base + skbdesc->desc_len,
2419 skbdesc->data, skbdesc->data_len);
2429 rt61pci_kick_tx_queue(rt2x00dev, control->queue); 2420 rt61pci_kick_tx_queue(rt2x00dev, control->queue);
2430 2421
2431 return 0; 2422 return 0;
@@ -2490,7 +2481,7 @@ static const struct data_queue_desc rt61pci_queue_tx = {
2490 2481
2491static const struct data_queue_desc rt61pci_queue_bcn = { 2482static const struct data_queue_desc rt61pci_queue_bcn = {
2492 .entry_num = 4 * BEACON_ENTRIES, 2483 .entry_num = 4 * BEACON_ENTRIES,
2493 .data_size = MGMT_FRAME_SIZE, 2484 .data_size = 0, /* No DMA required for beacons */
2494 .desc_size = TXINFO_SIZE, 2485 .desc_size = TXINFO_SIZE,
2495 .priv_size = sizeof(struct queue_entry_priv_pci_tx), 2486 .priv_size = sizeof(struct queue_entry_priv_pci_tx),
2496}; 2487};
diff --git a/drivers/net/wireless/wavelan.c b/drivers/net/wireless/wavelan.c
index 03384a43186b..49ae97003952 100644
--- a/drivers/net/wireless/wavelan.c
+++ b/drivers/net/wireless/wavelan.c
@@ -908,9 +908,9 @@ static void wv_psa_show(psa_t * p)
908 p->psa_call_code[3], p->psa_call_code[4], p->psa_call_code[5], 908 p->psa_call_code[3], p->psa_call_code[4], p->psa_call_code[5],
909 p->psa_call_code[6], p->psa_call_code[7]); 909 p->psa_call_code[6], p->psa_call_code[7]);
910#ifdef DEBUG_SHOW_UNUSED 910#ifdef DEBUG_SHOW_UNUSED
911 printk(KERN_DEBUG "psa_reserved[]: %02X:%02X:%02X:%02X\n", 911 printk(KERN_DEBUG "psa_reserved[]: %02X:%02X\n",
912 p->psa_reserved[0], 912 p->psa_reserved[0],
913 p->psa_reserved[1], p->psa_reserved[2], p->psa_reserved[3]); 913 p->psa_reserved[1]);
914#endif /* DEBUG_SHOW_UNUSED */ 914#endif /* DEBUG_SHOW_UNUSED */
915 printk(KERN_DEBUG "psa_conf_status: %d, ", p->psa_conf_status); 915 printk(KERN_DEBUG "psa_conf_status: %d, ", p->psa_conf_status);
916 printk("psa_crc: 0x%02x%02x, ", p->psa_crc[0], p->psa_crc[1]); 916 printk("psa_crc: 0x%02x%02x, ", p->psa_crc[0], p->psa_crc[1]);
diff --git a/drivers/net/wireless/wavelan_cs.c b/drivers/net/wireless/wavelan_cs.c
index baf74015751c..b584c0ecc62d 100644
--- a/drivers/net/wireless/wavelan_cs.c
+++ b/drivers/net/wireless/wavelan_cs.c
@@ -1074,11 +1074,9 @@ wv_psa_show(psa_t * p)
1074 p->psa_call_code[6], 1074 p->psa_call_code[6],
1075 p->psa_call_code[7]); 1075 p->psa_call_code[7]);
1076#ifdef DEBUG_SHOW_UNUSED 1076#ifdef DEBUG_SHOW_UNUSED
1077 printk(KERN_DEBUG "psa_reserved[]: %02X:%02X:%02X:%02X\n", 1077 printk(KERN_DEBUG "psa_reserved[]: %02X:%02X\n",
1078 p->psa_reserved[0], 1078 p->psa_reserved[0],
1079 p->psa_reserved[1], 1079 p->psa_reserved[1]);
1080 p->psa_reserved[2],
1081 p->psa_reserved[3]);
1082#endif /* DEBUG_SHOW_UNUSED */ 1080#endif /* DEBUG_SHOW_UNUSED */
1083 printk(KERN_DEBUG "psa_conf_status: %d, ", p->psa_conf_status); 1081 printk(KERN_DEBUG "psa_conf_status: %d, ", p->psa_conf_status);
1084 printk("psa_crc: 0x%02x%02x, ", p->psa_crc[0], p->psa_crc[1]); 1082 printk("psa_crc: 0x%02x%02x, ", p->psa_crc[0], p->psa_crc[1]);
diff --git a/drivers/net/wireless/zd1211rw/zd_usb.c b/drivers/net/wireless/zd1211rw/zd_usb.c
index 5316074f39f0..12e24f04dddf 100644
--- a/drivers/net/wireless/zd1211rw/zd_usb.c
+++ b/drivers/net/wireless/zd1211rw/zd_usb.c
@@ -889,9 +889,13 @@ static void tx_urb_complete(struct urb *urb)
889 } 889 }
890free_urb: 890free_urb:
891 skb = (struct sk_buff *)urb->context; 891 skb = (struct sk_buff *)urb->context;
892 zd_mac_tx_to_dev(skb, urb->status); 892 /*
893 * grab 'usb' pointer before handing off the skb (since
894 * it might be freed by zd_mac_tx_to_dev or mac80211)
895 */
893 cb = (struct zd_tx_skb_control_block *)skb->cb; 896 cb = (struct zd_tx_skb_control_block *)skb->cb;
894 usb = &zd_hw_mac(cb->hw)->chip.usb; 897 usb = &zd_hw_mac(cb->hw)->chip.usb;
898 zd_mac_tx_to_dev(skb, urb->status);
895 free_tx_urb(usb, urb); 899 free_tx_urb(usb, urb);
896 tx_dec_submitted_urbs(usb); 900 tx_dec_submitted_urbs(usb);
897 return; 901 return;
diff --git a/drivers/of/base.c b/drivers/of/base.c
index 9bd7c4a31253..23ffb7c0caf2 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -65,6 +65,9 @@ struct property *of_find_property(const struct device_node *np,
65{ 65{
66 struct property *pp; 66 struct property *pp;
67 67
68 if (!np)
69 return NULL;
70
68 read_lock(&devtree_lock); 71 read_lock(&devtree_lock);
69 for (pp = np->properties; pp != 0; pp = pp->next) { 72 for (pp = np->properties; pp != 0; pp = pp->next) {
70 if (of_prop_cmp(pp->name, name) == 0) { 73 if (of_prop_cmp(pp->name, name) == 0) {
diff --git a/drivers/oprofile/cpu_buffer.c b/drivers/oprofile/cpu_buffer.c
index efcbf4b4579f..2450b3a393ff 100644
--- a/drivers/oprofile/cpu_buffer.c
+++ b/drivers/oprofile/cpu_buffer.c
@@ -27,7 +27,7 @@
27#include "buffer_sync.h" 27#include "buffer_sync.h"
28#include "oprof.h" 28#include "oprof.h"
29 29
30DEFINE_PER_CPU_SHARED_ALIGNED(struct oprofile_cpu_buffer, cpu_buffer); 30DEFINE_PER_CPU(struct oprofile_cpu_buffer, cpu_buffer);
31 31
32static void wq_sync_buffer(struct work_struct *work); 32static void wq_sync_buffer(struct work_struct *work);
33 33
diff --git a/drivers/oprofile/cpu_buffer.h b/drivers/oprofile/cpu_buffer.h
index 13588174311d..c3e366b52261 100644
--- a/drivers/oprofile/cpu_buffer.h
+++ b/drivers/oprofile/cpu_buffer.h
@@ -46,7 +46,7 @@ struct oprofile_cpu_buffer {
46 unsigned long sample_invalid_eip; 46 unsigned long sample_invalid_eip;
47 int cpu; 47 int cpu;
48 struct delayed_work work; 48 struct delayed_work work;
49} ____cacheline_aligned; 49};
50 50
51DECLARE_PER_CPU(struct oprofile_cpu_buffer, cpu_buffer); 51DECLARE_PER_CPU(struct oprofile_cpu_buffer, cpu_buffer);
52 52
diff --git a/drivers/parisc/asp.c b/drivers/parisc/asp.c
index 558420bc9f88..821369135369 100644
--- a/drivers/parisc/asp.c
+++ b/drivers/parisc/asp.c
@@ -88,7 +88,7 @@ asp_init_chip(struct parisc_device *dev)
88 ret = -EBUSY; 88 ret = -EBUSY;
89 dev->irq = gsc_claim_irq(&gsc_irq, ASP_GSC_IRQ); 89 dev->irq = gsc_claim_irq(&gsc_irq, ASP_GSC_IRQ);
90 if (dev->irq < 0) { 90 if (dev->irq < 0) {
91 printk(KERN_ERR "%s(): cannot get GSC irq\n", __FUNCTION__); 91 printk(KERN_ERR "%s(): cannot get GSC irq\n", __func__);
92 goto out; 92 goto out;
93 } 93 }
94 94
diff --git a/drivers/parisc/ccio-dma.c b/drivers/parisc/ccio-dma.c
index 07d2a8d4498f..b30e38f3a50d 100644
--- a/drivers/parisc/ccio-dma.c
+++ b/drivers/parisc/ccio-dma.c
@@ -359,7 +359,7 @@ ccio_alloc_range(struct ioc *ioc, struct device *dev, size_t size)
359 BUG_ON((pages_needed * IOVP_SIZE) > DMA_CHUNK_SIZE); 359 BUG_ON((pages_needed * IOVP_SIZE) > DMA_CHUNK_SIZE);
360 360
361 DBG_RES("%s() size: %d pages_needed %d\n", 361 DBG_RES("%s() size: %d pages_needed %d\n",
362 __FUNCTION__, size, pages_needed); 362 __func__, size, pages_needed);
363 363
364 /* 364 /*
365 ** "seek and ye shall find"...praying never hurts either... 365 ** "seek and ye shall find"...praying never hurts either...
@@ -395,16 +395,16 @@ ccio_alloc_range(struct ioc *ioc, struct device *dev, size_t size)
395#endif 395#endif
396 } else { 396 } else {
397 panic("%s: %s() Too many pages to map. pages_needed: %u\n", 397 panic("%s: %s() Too many pages to map. pages_needed: %u\n",
398 __FILE__, __FUNCTION__, pages_needed); 398 __FILE__, __func__, pages_needed);
399 } 399 }
400 400
401 panic("%s: %s() I/O MMU is out of mapping resources.\n", __FILE__, 401 panic("%s: %s() I/O MMU is out of mapping resources.\n", __FILE__,
402 __FUNCTION__); 402 __func__);
403 403
404resource_found: 404resource_found:
405 405
406 DBG_RES("%s() res_idx %d res_hint: %d\n", 406 DBG_RES("%s() res_idx %d res_hint: %d\n",
407 __FUNCTION__, res_idx, ioc->res_hint); 407 __func__, res_idx, ioc->res_hint);
408 408
409#ifdef CCIO_SEARCH_TIME 409#ifdef CCIO_SEARCH_TIME
410 { 410 {
@@ -450,7 +450,7 @@ ccio_free_range(struct ioc *ioc, dma_addr_t iova, unsigned long pages_mapped)
450 BUG_ON(pages_mapped > BITS_PER_LONG); 450 BUG_ON(pages_mapped > BITS_PER_LONG);
451 451
452 DBG_RES("%s(): res_idx: %d pages_mapped %d\n", 452 DBG_RES("%s(): res_idx: %d pages_mapped %d\n",
453 __FUNCTION__, res_idx, pages_mapped); 453 __func__, res_idx, pages_mapped);
454 454
455#ifdef CCIO_MAP_STATS 455#ifdef CCIO_MAP_STATS
456 ioc->used_pages -= pages_mapped; 456 ioc->used_pages -= pages_mapped;
@@ -474,7 +474,7 @@ ccio_free_range(struct ioc *ioc, dma_addr_t iova, unsigned long pages_mapped)
474#endif 474#endif
475 } else { 475 } else {
476 panic("%s:%s() Too many pages to unmap.\n", __FILE__, 476 panic("%s:%s() Too many pages to unmap.\n", __FILE__,
477 __FUNCTION__); 477 __func__);
478 } 478 }
479} 479}
480 480
@@ -775,7 +775,7 @@ ccio_map_single(struct device *dev, void *addr, size_t size,
775 pdir_start = &(ioc->pdir_base[idx]); 775 pdir_start = &(ioc->pdir_base[idx]);
776 776
777 DBG_RUN("%s() 0x%p -> 0x%lx size: %0x%x\n", 777 DBG_RUN("%s() 0x%p -> 0x%lx size: %0x%x\n",
778 __FUNCTION__, addr, (long)iovp | offset, size); 778 __func__, addr, (long)iovp | offset, size);
779 779
780 /* If not cacheline aligned, force SAFE_DMA on the whole mess */ 780 /* If not cacheline aligned, force SAFE_DMA on the whole mess */
781 if((size % L1_CACHE_BYTES) || ((unsigned long)addr % L1_CACHE_BYTES)) 781 if((size % L1_CACHE_BYTES) || ((unsigned long)addr % L1_CACHE_BYTES))
@@ -820,7 +820,7 @@ ccio_unmap_single(struct device *dev, dma_addr_t iova, size_t size,
820 ioc = GET_IOC(dev); 820 ioc = GET_IOC(dev);
821 821
822 DBG_RUN("%s() iovp 0x%lx/%x\n", 822 DBG_RUN("%s() iovp 0x%lx/%x\n",
823 __FUNCTION__, (long)iova, size); 823 __func__, (long)iova, size);
824 824
825 iova ^= offset; /* clear offset bits */ 825 iova ^= offset; /* clear offset bits */
826 size += offset; 826 size += offset;
@@ -922,7 +922,7 @@ ccio_map_sg(struct device *dev, struct scatterlist *sglist, int nents,
922 BUG_ON(!dev); 922 BUG_ON(!dev);
923 ioc = GET_IOC(dev); 923 ioc = GET_IOC(dev);
924 924
925 DBG_RUN_SG("%s() START %d entries\n", __FUNCTION__, nents); 925 DBG_RUN_SG("%s() START %d entries\n", __func__, nents);
926 926
927 /* Fast path single entry scatterlists. */ 927 /* Fast path single entry scatterlists. */
928 if (nents == 1) { 928 if (nents == 1) {
@@ -966,7 +966,7 @@ ccio_map_sg(struct device *dev, struct scatterlist *sglist, int nents,
966 966
967 BUG_ON(coalesced != filled); 967 BUG_ON(coalesced != filled);
968 968
969 DBG_RUN_SG("%s() DONE %d mappings\n", __FUNCTION__, filled); 969 DBG_RUN_SG("%s() DONE %d mappings\n", __func__, filled);
970 970
971 for (i = 0; i < filled; i++) 971 for (i = 0; i < filled; i++)
972 current_len += sg_dma_len(sglist + i); 972 current_len += sg_dma_len(sglist + i);
@@ -995,7 +995,7 @@ ccio_unmap_sg(struct device *dev, struct scatterlist *sglist, int nents,
995 ioc = GET_IOC(dev); 995 ioc = GET_IOC(dev);
996 996
997 DBG_RUN_SG("%s() START %d entries, %08lx,%x\n", 997 DBG_RUN_SG("%s() START %d entries, %08lx,%x\n",
998 __FUNCTION__, nents, sg_virt_addr(sglist), sglist->length); 998 __func__, nents, sg_virt_addr(sglist), sglist->length);
999 999
1000#ifdef CCIO_MAP_STATS 1000#ifdef CCIO_MAP_STATS
1001 ioc->usg_calls++; 1001 ioc->usg_calls++;
@@ -1011,7 +1011,7 @@ ccio_unmap_sg(struct device *dev, struct scatterlist *sglist, int nents,
1011 ++sglist; 1011 ++sglist;
1012 } 1012 }
1013 1013
1014 DBG_RUN_SG("%s() DONE (nents %d)\n", __FUNCTION__, nents); 1014 DBG_RUN_SG("%s() DONE (nents %d)\n", __func__, nents);
1015} 1015}
1016 1016
1017static struct hppa_dma_ops ccio_ops = { 1017static struct hppa_dma_ops ccio_ops = {
@@ -1225,7 +1225,7 @@ static int
1225ccio_get_iotlb_size(struct parisc_device *dev) 1225ccio_get_iotlb_size(struct parisc_device *dev)
1226{ 1226{
1227 if (dev->spa_shift == 0) { 1227 if (dev->spa_shift == 0) {
1228 panic("%s() : Can't determine I/O TLB size.\n", __FUNCTION__); 1228 panic("%s() : Can't determine I/O TLB size.\n", __func__);
1229 } 1229 }
1230 return (1 << dev->spa_shift); 1230 return (1 << dev->spa_shift);
1231} 1231}
@@ -1315,7 +1315,7 @@ ccio_ioc_init(struct ioc *ioc)
1315 BUG_ON((1 << get_order(ioc->pdir_size)) != (ioc->pdir_size >> PAGE_SHIFT)); 1315 BUG_ON((1 << get_order(ioc->pdir_size)) != (ioc->pdir_size >> PAGE_SHIFT));
1316 1316
1317 DBG_INIT("%s() hpa 0x%p mem %luMB IOV %dMB (%d bits)\n", 1317 DBG_INIT("%s() hpa 0x%p mem %luMB IOV %dMB (%d bits)\n",
1318 __FUNCTION__, ioc->ioc_regs, 1318 __func__, ioc->ioc_regs,
1319 (unsigned long) num_physpages >> (20 - PAGE_SHIFT), 1319 (unsigned long) num_physpages >> (20 - PAGE_SHIFT),
1320 iova_space_size>>20, 1320 iova_space_size>>20,
1321 iov_order + PAGE_SHIFT); 1321 iov_order + PAGE_SHIFT);
@@ -1323,7 +1323,7 @@ ccio_ioc_init(struct ioc *ioc)
1323 ioc->pdir_base = (u64 *)__get_free_pages(GFP_KERNEL, 1323 ioc->pdir_base = (u64 *)__get_free_pages(GFP_KERNEL,
1324 get_order(ioc->pdir_size)); 1324 get_order(ioc->pdir_size));
1325 if(NULL == ioc->pdir_base) { 1325 if(NULL == ioc->pdir_base) {
1326 panic("%s() could not allocate I/O Page Table\n", __FUNCTION__); 1326 panic("%s() could not allocate I/O Page Table\n", __func__);
1327 } 1327 }
1328 memset(ioc->pdir_base, 0, ioc->pdir_size); 1328 memset(ioc->pdir_base, 0, ioc->pdir_size);
1329 1329
@@ -1332,12 +1332,12 @@ ccio_ioc_init(struct ioc *ioc)
1332 1332
1333 /* resource map size dictated by pdir_size */ 1333 /* resource map size dictated by pdir_size */
1334 ioc->res_size = (ioc->pdir_size / sizeof(u64)) >> 3; 1334 ioc->res_size = (ioc->pdir_size / sizeof(u64)) >> 3;
1335 DBG_INIT("%s() res_size 0x%x\n", __FUNCTION__, ioc->res_size); 1335 DBG_INIT("%s() res_size 0x%x\n", __func__, ioc->res_size);
1336 1336
1337 ioc->res_map = (u8 *)__get_free_pages(GFP_KERNEL, 1337 ioc->res_map = (u8 *)__get_free_pages(GFP_KERNEL,
1338 get_order(ioc->res_size)); 1338 get_order(ioc->res_size));
1339 if(NULL == ioc->res_map) { 1339 if(NULL == ioc->res_map) {
1340 panic("%s() could not allocate resource map\n", __FUNCTION__); 1340 panic("%s() could not allocate resource map\n", __func__);
1341 } 1341 }
1342 memset(ioc->res_map, 0, ioc->res_size); 1342 memset(ioc->res_map, 0, ioc->res_size);
1343 1343
@@ -1409,7 +1409,7 @@ ccio_init_resource(struct resource *res, char *name, void __iomem *ioaddr)
1409 result = insert_resource(&iomem_resource, res); 1409 result = insert_resource(&iomem_resource, res);
1410 if (result < 0) { 1410 if (result < 0) {
1411 printk(KERN_ERR "%s() failed to claim CCIO bus address space (%08lx,%08lx)\n", 1411 printk(KERN_ERR "%s() failed to claim CCIO bus address space (%08lx,%08lx)\n",
1412 __FUNCTION__, res->start, res->end); 1412 __func__, res->start, res->end);
1413 } 1413 }
1414} 1414}
1415 1415
diff --git a/drivers/parisc/dino.c b/drivers/parisc/dino.c
index d9c6322a721b..fd56128525d1 100644
--- a/drivers/parisc/dino.c
+++ b/drivers/parisc/dino.c
@@ -180,7 +180,7 @@ static int dino_cfg_read(struct pci_bus *bus, unsigned int devfn, int where,
180 void __iomem *base_addr = d->hba.base_addr; 180 void __iomem *base_addr = d->hba.base_addr;
181 unsigned long flags; 181 unsigned long flags;
182 182
183 DBG("%s: %p, %d, %d, %d\n", __FUNCTION__, base_addr, devfn, where, 183 DBG("%s: %p, %d, %d, %d\n", __func__, base_addr, devfn, where,
184 size); 184 size);
185 spin_lock_irqsave(&d->dinosaur_pen, flags); 185 spin_lock_irqsave(&d->dinosaur_pen, flags);
186 186
@@ -215,7 +215,7 @@ static int dino_cfg_write(struct pci_bus *bus, unsigned int devfn, int where,
215 void __iomem *base_addr = d->hba.base_addr; 215 void __iomem *base_addr = d->hba.base_addr;
216 unsigned long flags; 216 unsigned long flags;
217 217
218 DBG("%s: %p, %d, %d, %d\n", __FUNCTION__, base_addr, devfn, where, 218 DBG("%s: %p, %d, %d, %d\n", __func__, base_addr, devfn, where,
219 size); 219 size);
220 spin_lock_irqsave(&d->dinosaur_pen, flags); 220 spin_lock_irqsave(&d->dinosaur_pen, flags);
221 221
@@ -301,7 +301,7 @@ static void dino_disable_irq(unsigned int irq)
301 struct dino_device *dino_dev = irq_desc[irq].chip_data; 301 struct dino_device *dino_dev = irq_desc[irq].chip_data;
302 int local_irq = gsc_find_local_irq(irq, dino_dev->global_irq, DINO_LOCAL_IRQS); 302 int local_irq = gsc_find_local_irq(irq, dino_dev->global_irq, DINO_LOCAL_IRQS);
303 303
304 DBG(KERN_WARNING "%s(0x%p, %d)\n", __FUNCTION__, dino_dev, irq); 304 DBG(KERN_WARNING "%s(0x%p, %d)\n", __func__, dino_dev, irq);
305 305
306 /* Clear the matching bit in the IMR register */ 306 /* Clear the matching bit in the IMR register */
307 dino_dev->imr &= ~(DINO_MASK_IRQ(local_irq)); 307 dino_dev->imr &= ~(DINO_MASK_IRQ(local_irq));
@@ -314,7 +314,7 @@ static void dino_enable_irq(unsigned int irq)
314 int local_irq = gsc_find_local_irq(irq, dino_dev->global_irq, DINO_LOCAL_IRQS); 314 int local_irq = gsc_find_local_irq(irq, dino_dev->global_irq, DINO_LOCAL_IRQS);
315 u32 tmp; 315 u32 tmp;
316 316
317 DBG(KERN_WARNING "%s(0x%p, %d)\n", __FUNCTION__, dino_dev, irq); 317 DBG(KERN_WARNING "%s(0x%p, %d)\n", __func__, dino_dev, irq);
318 318
319 /* 319 /*
320 ** clear pending IRQ bits 320 ** clear pending IRQ bits
@@ -340,7 +340,7 @@ static void dino_enable_irq(unsigned int irq)
340 tmp = __raw_readl(dino_dev->hba.base_addr+DINO_ILR); 340 tmp = __raw_readl(dino_dev->hba.base_addr+DINO_ILR);
341 if (tmp & DINO_MASK_IRQ(local_irq)) { 341 if (tmp & DINO_MASK_IRQ(local_irq)) {
342 DBG(KERN_WARNING "%s(): IRQ asserted! (ILR 0x%x)\n", 342 DBG(KERN_WARNING "%s(): IRQ asserted! (ILR 0x%x)\n",
343 __FUNCTION__, tmp); 343 __func__, tmp);
344 gsc_writel(dino_dev->txn_data, dino_dev->txn_addr); 344 gsc_writel(dino_dev->txn_data, dino_dev->txn_addr);
345 } 345 }
346} 346}
@@ -388,7 +388,7 @@ ilr_again:
388 int local_irq = __ffs(mask); 388 int local_irq = __ffs(mask);
389 int irq = dino_dev->global_irq[local_irq]; 389 int irq = dino_dev->global_irq[local_irq];
390 DBG(KERN_DEBUG "%s(%d, %p) mask 0x%x\n", 390 DBG(KERN_DEBUG "%s(%d, %p) mask 0x%x\n",
391 __FUNCTION__, irq, intr_dev, mask); 391 __func__, irq, intr_dev, mask);
392 __do_IRQ(irq); 392 __do_IRQ(irq);
393 mask &= ~(1 << local_irq); 393 mask &= ~(1 << local_irq);
394 } while (mask); 394 } while (mask);
@@ -566,7 +566,7 @@ dino_fixup_bus(struct pci_bus *bus)
566 int port_base = HBA_PORT_BASE(dino_dev->hba.hba_num); 566 int port_base = HBA_PORT_BASE(dino_dev->hba.hba_num);
567 567
568 DBG(KERN_WARNING "%s(0x%p) bus %d platform_data 0x%p\n", 568 DBG(KERN_WARNING "%s(0x%p) bus %d platform_data 0x%p\n",
569 __FUNCTION__, bus, bus->secondary, 569 __func__, bus, bus->secondary,
570 bus->bridge->platform_data); 570 bus->bridge->platform_data);
571 571
572 /* Firmware doesn't set up card-mode dino, so we have to */ 572 /* Firmware doesn't set up card-mode dino, so we have to */
diff --git a/drivers/parisc/gsc.c b/drivers/parisc/gsc.c
index 1b3e3fd12d95..f7d088b897ee 100644
--- a/drivers/parisc/gsc.c
+++ b/drivers/parisc/gsc.c
@@ -112,7 +112,7 @@ static void gsc_asic_disable_irq(unsigned int irq)
112 int local_irq = gsc_find_local_irq(irq, irq_dev->global_irq, 32); 112 int local_irq = gsc_find_local_irq(irq, irq_dev->global_irq, 32);
113 u32 imr; 113 u32 imr;
114 114
115 DEBPRINTK(KERN_DEBUG "%s(%d) %s: IMR 0x%x\n", __FUNCTION__, irq, 115 DEBPRINTK(KERN_DEBUG "%s(%d) %s: IMR 0x%x\n", __func__, irq,
116 irq_dev->name, imr); 116 irq_dev->name, imr);
117 117
118 /* Disable the IRQ line by clearing the bit in the IMR */ 118 /* Disable the IRQ line by clearing the bit in the IMR */
@@ -127,7 +127,7 @@ static void gsc_asic_enable_irq(unsigned int irq)
127 int local_irq = gsc_find_local_irq(irq, irq_dev->global_irq, 32); 127 int local_irq = gsc_find_local_irq(irq, irq_dev->global_irq, 32);
128 u32 imr; 128 u32 imr;
129 129
130 DEBPRINTK(KERN_DEBUG "%s(%d) %s: IMR 0x%x\n", __FUNCTION__, irq, 130 DEBPRINTK(KERN_DEBUG "%s(%d) %s: IMR 0x%x\n", __func__, irq,
131 irq_dev->name, imr); 131 irq_dev->name, imr);
132 132
133 /* Enable the IRQ line by setting the bit in the IMR */ 133 /* Enable the IRQ line by setting the bit in the IMR */
diff --git a/drivers/parisc/lasi.c b/drivers/parisc/lasi.c
index cb3d28176129..bee510098ce8 100644
--- a/drivers/parisc/lasi.c
+++ b/drivers/parisc/lasi.c
@@ -193,7 +193,7 @@ lasi_init_chip(struct parisc_device *dev)
193 dev->irq = gsc_alloc_irq(&gsc_irq); 193 dev->irq = gsc_alloc_irq(&gsc_irq);
194 if (dev->irq < 0) { 194 if (dev->irq < 0) {
195 printk(KERN_ERR "%s(): cannot get GSC irq\n", 195 printk(KERN_ERR "%s(): cannot get GSC irq\n",
196 __FUNCTION__); 196 __func__);
197 kfree(lasi); 197 kfree(lasi);
198 return -EBUSY; 198 return -EBUSY;
199 } 199 }
diff --git a/drivers/parisc/lba_pci.c b/drivers/parisc/lba_pci.c
index 66ce61048361..a28c8946deaa 100644
--- a/drivers/parisc/lba_pci.c
+++ b/drivers/parisc/lba_pci.c
@@ -377,12 +377,12 @@ static int elroy_cfg_read(struct pci_bus *bus, unsigned int devfn, int pos, int
377 /* original - Generate config cycle on broken elroy 377 /* original - Generate config cycle on broken elroy
378 with risk we will miss PCI bus errors. */ 378 with risk we will miss PCI bus errors. */
379 *data = lba_rd_cfg(d, tok, pos, size); 379 *data = lba_rd_cfg(d, tok, pos, size);
380 DBG_CFG("%s(%x+%2x) -> 0x%x (a)\n", __FUNCTION__, tok, pos, *data); 380 DBG_CFG("%s(%x+%2x) -> 0x%x (a)\n", __func__, tok, pos, *data);
381 return 0; 381 return 0;
382 } 382 }
383 383
384 if (LBA_SKIP_PROBE(d) && !lba_device_present(bus->secondary, devfn, d)) { 384 if (LBA_SKIP_PROBE(d) && !lba_device_present(bus->secondary, devfn, d)) {
385 DBG_CFG("%s(%x+%2x) -> -1 (b)\n", __FUNCTION__, tok, pos); 385 DBG_CFG("%s(%x+%2x) -> -1 (b)\n", __func__, tok, pos);
386 /* either don't want to look or know device isn't present. */ 386 /* either don't want to look or know device isn't present. */
387 *data = ~0U; 387 *data = ~0U;
388 return(0); 388 return(0);
@@ -398,7 +398,7 @@ static int elroy_cfg_read(struct pci_bus *bus, unsigned int devfn, int pos, int
398 case 2: *data = READ_REG16(data_reg + (pos & 2)); break; 398 case 2: *data = READ_REG16(data_reg + (pos & 2)); break;
399 case 4: *data = READ_REG32(data_reg); break; 399 case 4: *data = READ_REG32(data_reg); break;
400 } 400 }
401 DBG_CFG("%s(%x+%2x) -> 0x%x (c)\n", __FUNCTION__, tok, pos, *data); 401 DBG_CFG("%s(%x+%2x) -> 0x%x (c)\n", __func__, tok, pos, *data);
402 return 0; 402 return 0;
403} 403}
404 404
@@ -441,16 +441,16 @@ static int elroy_cfg_write(struct pci_bus *bus, unsigned int devfn, int pos, int
441 if (!LBA_SKIP_PROBE(d)) { 441 if (!LBA_SKIP_PROBE(d)) {
442 /* Original Workaround */ 442 /* Original Workaround */
443 lba_wr_cfg(d, tok, pos, (u32) data, size); 443 lba_wr_cfg(d, tok, pos, (u32) data, size);
444 DBG_CFG("%s(%x+%2x) = 0x%x (a)\n", __FUNCTION__, tok, pos,data); 444 DBG_CFG("%s(%x+%2x) = 0x%x (a)\n", __func__, tok, pos,data);
445 return 0; 445 return 0;
446 } 446 }
447 447
448 if (LBA_SKIP_PROBE(d) && (!lba_device_present(bus->secondary, devfn, d))) { 448 if (LBA_SKIP_PROBE(d) && (!lba_device_present(bus->secondary, devfn, d))) {
449 DBG_CFG("%s(%x+%2x) = 0x%x (b)\n", __FUNCTION__, tok, pos,data); 449 DBG_CFG("%s(%x+%2x) = 0x%x (b)\n", __func__, tok, pos,data);
450 return 1; /* New Workaround */ 450 return 1; /* New Workaround */
451 } 451 }
452 452
453 DBG_CFG("%s(%x+%2x) = 0x%x (c)\n", __FUNCTION__, tok, pos, data); 453 DBG_CFG("%s(%x+%2x) = 0x%x (c)\n", __func__, tok, pos, data);
454 454
455 /* Basic Algorithm */ 455 /* Basic Algorithm */
456 LBA_CFG_ADDR_SETUP(d, tok | pos); 456 LBA_CFG_ADDR_SETUP(d, tok | pos);
@@ -521,7 +521,7 @@ static int mercury_cfg_write(struct pci_bus *bus, unsigned int devfn, int pos, i
521 if ((pos > 255) || (devfn > 255)) 521 if ((pos > 255) || (devfn > 255))
522 return -EINVAL; 522 return -EINVAL;
523 523
524 DBG_CFG("%s(%x+%2x) <- 0x%x (c)\n", __FUNCTION__, tok, pos, data); 524 DBG_CFG("%s(%x+%2x) <- 0x%x (c)\n", __func__, tok, pos, data);
525 525
526 LBA_CFG_TR4_ADDR_SETUP(d, tok | pos); 526 LBA_CFG_TR4_ADDR_SETUP(d, tok | pos);
527 switch(size) { 527 switch(size) {
@@ -890,7 +890,7 @@ LBA_PORT_IN(32, 0)
890#define LBA_PORT_OUT(size, mask) \ 890#define LBA_PORT_OUT(size, mask) \
891static void lba_astro_out##size (struct pci_hba_data *d, u16 addr, u##size val) \ 891static void lba_astro_out##size (struct pci_hba_data *d, u16 addr, u##size val) \
892{ \ 892{ \
893 DBG_PORT("%s(0x%p, 0x%x, 0x%x)\n", __FUNCTION__, d, addr, val); \ 893 DBG_PORT("%s(0x%p, 0x%x, 0x%x)\n", __func__, d, addr, val); \
894 WRITE_REG##size(val, astro_iop_base + addr); \ 894 WRITE_REG##size(val, astro_iop_base + addr); \
895 if (LBA_DEV(d)->hw_rev < 3) \ 895 if (LBA_DEV(d)->hw_rev < 3) \
896 lba_t32 = READ_U32(d->base_addr + LBA_FUNC_ID); \ 896 lba_t32 = READ_U32(d->base_addr + LBA_FUNC_ID); \
@@ -932,7 +932,7 @@ static struct pci_port_ops lba_astro_port_ops = {
932static u##size lba_pat_in##size (struct pci_hba_data *l, u16 addr) \ 932static u##size lba_pat_in##size (struct pci_hba_data *l, u16 addr) \
933{ \ 933{ \
934 u##size t; \ 934 u##size t; \
935 DBG_PORT("%s(0x%p, 0x%x) ->", __FUNCTION__, l, addr); \ 935 DBG_PORT("%s(0x%p, 0x%x) ->", __func__, l, addr); \
936 t = READ_REG##size(PIOP_TO_GMMIO(LBA_DEV(l), addr)); \ 936 t = READ_REG##size(PIOP_TO_GMMIO(LBA_DEV(l), addr)); \
937 DBG_PORT(" 0x%x\n", t); \ 937 DBG_PORT(" 0x%x\n", t); \
938 return (t); \ 938 return (t); \
@@ -948,7 +948,7 @@ LBA_PORT_IN(32, 0)
948static void lba_pat_out##size (struct pci_hba_data *l, u16 addr, u##size val) \ 948static void lba_pat_out##size (struct pci_hba_data *l, u16 addr, u##size val) \
949{ \ 949{ \
950 void __iomem *where = PIOP_TO_GMMIO(LBA_DEV(l), addr); \ 950 void __iomem *where = PIOP_TO_GMMIO(LBA_DEV(l), addr); \
951 DBG_PORT("%s(0x%p, 0x%x, 0x%x)\n", __FUNCTION__, l, addr, val); \ 951 DBG_PORT("%s(0x%p, 0x%x, 0x%x)\n", __func__, l, addr, val); \
952 WRITE_REG##size(val, where); \ 952 WRITE_REG##size(val, where); \
953 /* flush the I/O down to the elroy at least */ \ 953 /* flush the I/O down to the elroy at least */ \
954 lba_t32 = READ_U32(l->base_addr + LBA_FUNC_ID); \ 954 lba_t32 = READ_U32(l->base_addr + LBA_FUNC_ID); \
@@ -1584,7 +1584,7 @@ void lba_set_iregs(struct parisc_device *lba, u32 ibase, u32 imask)
1584 WARN_ON((ibase & 0x001fffff) != 0); 1584 WARN_ON((ibase & 0x001fffff) != 0);
1585 WARN_ON((imask & 0x001fffff) != 0); 1585 WARN_ON((imask & 0x001fffff) != 0);
1586 1586
1587 DBG("%s() ibase 0x%x imask 0x%x\n", __FUNCTION__, ibase, imask); 1587 DBG("%s() ibase 0x%x imask 0x%x\n", __func__, ibase, imask);
1588 WRITE_REG32( imask, base_addr + LBA_IMASK); 1588 WRITE_REG32( imask, base_addr + LBA_IMASK);
1589 WRITE_REG32( ibase, base_addr + LBA_IBASE); 1589 WRITE_REG32( ibase, base_addr + LBA_IBASE);
1590 iounmap(base_addr); 1590 iounmap(base_addr);
diff --git a/drivers/parisc/led.c b/drivers/parisc/led.c
index 703b85edb004..f9b12664f9fb 100644
--- a/drivers/parisc/led.c
+++ b/drivers/parisc/led.c
@@ -569,7 +569,7 @@ int __init register_led_driver(int model, unsigned long cmd_reg, unsigned long d
569 569
570 default: 570 default:
571 printk(KERN_ERR "%s: Wrong LCD/LED model %d !\n", 571 printk(KERN_ERR "%s: Wrong LCD/LED model %d !\n",
572 __FUNCTION__, lcd_info.model); 572 __func__, lcd_info.model);
573 return 1; 573 return 1;
574 } 574 }
575 575
diff --git a/drivers/parisc/sba_iommu.c b/drivers/parisc/sba_iommu.c
index afc849bd3f58..bc73b96346ff 100644
--- a/drivers/parisc/sba_iommu.c
+++ b/drivers/parisc/sba_iommu.c
@@ -384,7 +384,7 @@ sba_search_bitmap(struct ioc *ioc, struct device *dev,
384 } 384 }
385 mask = RESMAP_MASK(bits_wanted) >> bitshiftcnt; 385 mask = RESMAP_MASK(bits_wanted) >> bitshiftcnt;
386 386
387 DBG_RES("%s() o %ld %p", __FUNCTION__, o, res_ptr); 387 DBG_RES("%s() o %ld %p", __func__, o, res_ptr);
388 while(res_ptr < res_end) 388 while(res_ptr < res_end)
389 { 389 {
390 DBG_RES(" %p %lx %lx\n", res_ptr, mask, *res_ptr); 390 DBG_RES(" %p %lx %lx\n", res_ptr, mask, *res_ptr);
@@ -454,7 +454,7 @@ sba_alloc_range(struct ioc *ioc, struct device *dev, size_t size)
454#endif 454#endif
455 455
456 DBG_RES("%s(%x) %d -> %lx hint %x/%x\n", 456 DBG_RES("%s(%x) %d -> %lx hint %x/%x\n",
457 __FUNCTION__, size, pages_needed, pide, 457 __func__, size, pages_needed, pide,
458 (uint) ((unsigned long) ioc->res_hint - (unsigned long) ioc->res_map), 458 (uint) ((unsigned long) ioc->res_hint - (unsigned long) ioc->res_map),
459 ioc->res_bitshift ); 459 ioc->res_bitshift );
460 460
@@ -497,7 +497,7 @@ sba_free_range(struct ioc *ioc, dma_addr_t iova, size_t size)
497 unsigned long m = RESMAP_MASK(bits_not_wanted) >> (pide & (BITS_PER_LONG - 1)); 497 unsigned long m = RESMAP_MASK(bits_not_wanted) >> (pide & (BITS_PER_LONG - 1));
498 498
499 DBG_RES("%s( ,%x,%x) %x/%lx %x %p %lx\n", 499 DBG_RES("%s( ,%x,%x) %x/%lx %x %p %lx\n",
500 __FUNCTION__, (uint) iova, size, 500 __func__, (uint) iova, size,
501 bits_not_wanted, m, pide, res_ptr, *res_ptr); 501 bits_not_wanted, m, pide, res_ptr, *res_ptr);
502 502
503#ifdef SBA_COLLECT_STATS 503#ifdef SBA_COLLECT_STATS
@@ -740,7 +740,7 @@ sba_map_single(struct device *dev, void *addr, size_t size,
740 iovp = (dma_addr_t) pide << IOVP_SHIFT; 740 iovp = (dma_addr_t) pide << IOVP_SHIFT;
741 741
742 DBG_RUN("%s() 0x%p -> 0x%lx\n", 742 DBG_RUN("%s() 0x%p -> 0x%lx\n",
743 __FUNCTION__, addr, (long) iovp | offset); 743 __func__, addr, (long) iovp | offset);
744 744
745 pdir_start = &(ioc->pdir_base[pide]); 745 pdir_start = &(ioc->pdir_base[pide]);
746 746
@@ -798,7 +798,7 @@ sba_unmap_single(struct device *dev, dma_addr_t iova, size_t size,
798 unsigned long flags; 798 unsigned long flags;
799 dma_addr_t offset; 799 dma_addr_t offset;
800 800
801 DBG_RUN("%s() iovp 0x%lx/%x\n", __FUNCTION__, (long) iova, size); 801 DBG_RUN("%s() iovp 0x%lx/%x\n", __func__, (long) iova, size);
802 802
803 ioc = GET_IOC(dev); 803 ioc = GET_IOC(dev);
804 offset = iova & ~IOVP_MASK; 804 offset = iova & ~IOVP_MASK;
@@ -937,7 +937,7 @@ sba_map_sg(struct device *dev, struct scatterlist *sglist, int nents,
937 int coalesced, filled = 0; 937 int coalesced, filled = 0;
938 unsigned long flags; 938 unsigned long flags;
939 939
940 DBG_RUN_SG("%s() START %d entries\n", __FUNCTION__, nents); 940 DBG_RUN_SG("%s() START %d entries\n", __func__, nents);
941 941
942 ioc = GET_IOC(dev); 942 ioc = GET_IOC(dev);
943 943
@@ -998,7 +998,7 @@ sba_map_sg(struct device *dev, struct scatterlist *sglist, int nents,
998 998
999 spin_unlock_irqrestore(&ioc->res_lock, flags); 999 spin_unlock_irqrestore(&ioc->res_lock, flags);
1000 1000
1001 DBG_RUN_SG("%s() DONE %d mappings\n", __FUNCTION__, filled); 1001 DBG_RUN_SG("%s() DONE %d mappings\n", __func__, filled);
1002 1002
1003 return filled; 1003 return filled;
1004} 1004}
@@ -1023,7 +1023,7 @@ sba_unmap_sg(struct device *dev, struct scatterlist *sglist, int nents,
1023#endif 1023#endif
1024 1024
1025 DBG_RUN_SG("%s() START %d entries, %p,%x\n", 1025 DBG_RUN_SG("%s() START %d entries, %p,%x\n",
1026 __FUNCTION__, nents, sg_virt_addr(sglist), sglist->length); 1026 __func__, nents, sg_virt_addr(sglist), sglist->length);
1027 1027
1028 ioc = GET_IOC(dev); 1028 ioc = GET_IOC(dev);
1029 1029
@@ -1047,7 +1047,7 @@ sba_unmap_sg(struct device *dev, struct scatterlist *sglist, int nents,
1047 ++sglist; 1047 ++sglist;
1048 } 1048 }
1049 1049
1050 DBG_RUN_SG("%s() DONE (nents %d)\n", __FUNCTION__, nents); 1050 DBG_RUN_SG("%s() DONE (nents %d)\n", __func__, nents);
1051 1051
1052#ifdef ASSERT_PDIR_SANITY 1052#ifdef ASSERT_PDIR_SANITY
1053 spin_lock_irqsave(&ioc->res_lock, flags); 1053 spin_lock_irqsave(&ioc->res_lock, flags);
@@ -1118,7 +1118,7 @@ sba_alloc_pdir(unsigned int pdir_size)
1118 pdir_base = __get_free_pages(GFP_KERNEL, pdir_order); 1118 pdir_base = __get_free_pages(GFP_KERNEL, pdir_order);
1119 if (NULL == (void *) pdir_base) { 1119 if (NULL == (void *) pdir_base) {
1120 panic("%s() could not allocate I/O Page Table\n", 1120 panic("%s() could not allocate I/O Page Table\n",
1121 __FUNCTION__); 1121 __func__);
1122 } 1122 }
1123 1123
1124 /* If this is not PA8700 (PCX-W2) 1124 /* If this is not PA8700 (PCX-W2)
@@ -1261,7 +1261,7 @@ sba_ioc_init_pluto(struct parisc_device *sba, struct ioc *ioc, int ioc_num)
1261 ioc->pdir_size = (iova_space_size / IOVP_SIZE) * sizeof(u64); 1261 ioc->pdir_size = (iova_space_size / IOVP_SIZE) * sizeof(u64);
1262 1262
1263 DBG_INIT("%s() hpa 0x%p IOV %dMB (%d bits)\n", 1263 DBG_INIT("%s() hpa 0x%p IOV %dMB (%d bits)\n",
1264 __FUNCTION__, ioc->ioc_hpa, iova_space_size >> 20, 1264 __func__, ioc->ioc_hpa, iova_space_size >> 20,
1265 iov_order + PAGE_SHIFT); 1265 iov_order + PAGE_SHIFT);
1266 1266
1267 ioc->pdir_base = (void *) __get_free_pages(GFP_KERNEL, 1267 ioc->pdir_base = (void *) __get_free_pages(GFP_KERNEL,
@@ -1272,7 +1272,7 @@ sba_ioc_init_pluto(struct parisc_device *sba, struct ioc *ioc, int ioc_num)
1272 memset(ioc->pdir_base, 0, ioc->pdir_size); 1272 memset(ioc->pdir_base, 0, ioc->pdir_size);
1273 1273
1274 DBG_INIT("%s() pdir %p size %x\n", 1274 DBG_INIT("%s() pdir %p size %x\n",
1275 __FUNCTION__, ioc->pdir_base, ioc->pdir_size); 1275 __func__, ioc->pdir_base, ioc->pdir_size);
1276 1276
1277#ifdef SBA_HINT_SUPPORT 1277#ifdef SBA_HINT_SUPPORT
1278 ioc->hint_shift_pdir = iov_order + PAGE_SHIFT; 1278 ioc->hint_shift_pdir = iov_order + PAGE_SHIFT;
@@ -1354,7 +1354,7 @@ sba_ioc_init_pluto(struct parisc_device *sba, struct ioc *ioc, int ioc_num)
1354 1354
1355 if (agp_found && sba_reserve_agpgart) { 1355 if (agp_found && sba_reserve_agpgart) {
1356 printk(KERN_INFO "%s: reserving %dMb of IOVA space for agpgart\n", 1356 printk(KERN_INFO "%s: reserving %dMb of IOVA space for agpgart\n",
1357 __FUNCTION__, (iova_space_size/2) >> 20); 1357 __func__, (iova_space_size/2) >> 20);
1358 ioc->pdir_size /= 2; 1358 ioc->pdir_size /= 2;
1359 ioc->pdir_base[PDIR_INDEX(iova_space_size/2)] = SBA_AGPGART_COOKIE; 1359 ioc->pdir_base[PDIR_INDEX(iova_space_size/2)] = SBA_AGPGART_COOKIE;
1360 } 1360 }
@@ -1406,7 +1406,7 @@ sba_ioc_init(struct parisc_device *sba, struct ioc *ioc, int ioc_num)
1406 ioc->pdir_size = pdir_size = (iova_space_size/IOVP_SIZE) * sizeof(u64); 1406 ioc->pdir_size = pdir_size = (iova_space_size/IOVP_SIZE) * sizeof(u64);
1407 1407
1408 DBG_INIT("%s() hpa 0x%lx mem %ldMB IOV %dMB (%d bits)\n", 1408 DBG_INIT("%s() hpa 0x%lx mem %ldMB IOV %dMB (%d bits)\n",
1409 __FUNCTION__, 1409 __func__,
1410 ioc->ioc_hpa, 1410 ioc->ioc_hpa,
1411 (unsigned long) num_physpages >> (20 - PAGE_SHIFT), 1411 (unsigned long) num_physpages >> (20 - PAGE_SHIFT),
1412 iova_space_size>>20, 1412 iova_space_size>>20,
@@ -1415,7 +1415,7 @@ sba_ioc_init(struct parisc_device *sba, struct ioc *ioc, int ioc_num)
1415 ioc->pdir_base = sba_alloc_pdir(pdir_size); 1415 ioc->pdir_base = sba_alloc_pdir(pdir_size);
1416 1416
1417 DBG_INIT("%s() pdir %p size %x\n", 1417 DBG_INIT("%s() pdir %p size %x\n",
1418 __FUNCTION__, ioc->pdir_base, pdir_size); 1418 __func__, ioc->pdir_base, pdir_size);
1419 1419
1420#ifdef SBA_HINT_SUPPORT 1420#ifdef SBA_HINT_SUPPORT
1421 /* FIXME : DMA HINTs not used */ 1421 /* FIXME : DMA HINTs not used */
@@ -1443,7 +1443,7 @@ sba_ioc_init(struct parisc_device *sba, struct ioc *ioc, int ioc_num)
1443#endif 1443#endif
1444 1444
1445 DBG_INIT("%s() IOV base 0x%lx mask 0x%0lx\n", 1445 DBG_INIT("%s() IOV base 0x%lx mask 0x%0lx\n",
1446 __FUNCTION__, ioc->ibase, ioc->imask); 1446 __func__, ioc->ibase, ioc->imask);
1447 1447
1448 /* 1448 /*
1449 ** FIXME: Hint registers are programmed with default hint 1449 ** FIXME: Hint registers are programmed with default hint
@@ -1470,7 +1470,7 @@ sba_ioc_init(struct parisc_device *sba, struct ioc *ioc, int ioc_num)
1470 1470
1471 ioc->ibase = 0; /* used by SBA_IOVA and related macros */ 1471 ioc->ibase = 0; /* used by SBA_IOVA and related macros */
1472 1472
1473 DBG_INIT("%s() DONE\n", __FUNCTION__); 1473 DBG_INIT("%s() DONE\n", __func__);
1474} 1474}
1475 1475
1476 1476
@@ -1544,7 +1544,7 @@ printk("sba_hw_init(): mem_boot 0x%x 0x%x 0x%x 0x%x\n", PAGE0->mem_boot.hpa,
1544 if (!IS_PLUTO(sba_dev->dev)) { 1544 if (!IS_PLUTO(sba_dev->dev)) {
1545 ioc_ctl = READ_REG(sba_dev->sba_hpa+IOC_CTRL); 1545 ioc_ctl = READ_REG(sba_dev->sba_hpa+IOC_CTRL);
1546 DBG_INIT("%s() hpa 0x%lx ioc_ctl 0x%Lx ->", 1546 DBG_INIT("%s() hpa 0x%lx ioc_ctl 0x%Lx ->",
1547 __FUNCTION__, sba_dev->sba_hpa, ioc_ctl); 1547 __func__, sba_dev->sba_hpa, ioc_ctl);
1548 ioc_ctl &= ~(IOC_CTRL_RM | IOC_CTRL_NC | IOC_CTRL_CE); 1548 ioc_ctl &= ~(IOC_CTRL_RM | IOC_CTRL_NC | IOC_CTRL_CE);
1549 ioc_ctl |= IOC_CTRL_DD | IOC_CTRL_D4 | IOC_CTRL_TC; 1549 ioc_ctl |= IOC_CTRL_DD | IOC_CTRL_D4 | IOC_CTRL_TC;
1550 /* j6700 v1.6 firmware sets 0x294f */ 1550 /* j6700 v1.6 firmware sets 0x294f */
@@ -1675,7 +1675,7 @@ sba_common_init(struct sba_device *sba_dev)
1675 1675
1676 res_size >>= 3; /* convert bit count to byte count */ 1676 res_size >>= 3; /* convert bit count to byte count */
1677 DBG_INIT("%s() res_size 0x%x\n", 1677 DBG_INIT("%s() res_size 0x%x\n",
1678 __FUNCTION__, res_size); 1678 __func__, res_size);
1679 1679
1680 sba_dev->ioc[i].res_size = res_size; 1680 sba_dev->ioc[i].res_size = res_size;
1681 sba_dev->ioc[i].res_map = (char *) __get_free_pages(GFP_KERNEL, get_order(res_size)); 1681 sba_dev->ioc[i].res_map = (char *) __get_free_pages(GFP_KERNEL, get_order(res_size));
@@ -1688,7 +1688,7 @@ sba_common_init(struct sba_device *sba_dev)
1688 if (NULL == sba_dev->ioc[i].res_map) 1688 if (NULL == sba_dev->ioc[i].res_map)
1689 { 1689 {
1690 panic("%s:%s() could not allocate resource map\n", 1690 panic("%s:%s() could not allocate resource map\n",
1691 __FILE__, __FUNCTION__ ); 1691 __FILE__, __func__ );
1692 } 1692 }
1693 1693
1694 memset(sba_dev->ioc[i].res_map, 0, res_size); 1694 memset(sba_dev->ioc[i].res_map, 0, res_size);
@@ -1725,7 +1725,7 @@ sba_common_init(struct sba_device *sba_dev)
1725#endif 1725#endif
1726 1726
1727 DBG_INIT("%s() %d res_map %x %p\n", 1727 DBG_INIT("%s() %d res_map %x %p\n",
1728 __FUNCTION__, i, res_size, sba_dev->ioc[i].res_map); 1728 __func__, i, res_size, sba_dev->ioc[i].res_map);
1729 } 1729 }
1730 1730
1731 spin_lock_init(&sba_dev->sba_lock); 1731 spin_lock_init(&sba_dev->sba_lock);
diff --git a/drivers/parisc/wax.c b/drivers/parisc/wax.c
index 813c2c24ab1e..892a83bbe73d 100644
--- a/drivers/parisc/wax.c
+++ b/drivers/parisc/wax.c
@@ -93,7 +93,7 @@ wax_init_chip(struct parisc_device *dev)
93 dev->irq = gsc_claim_irq(&gsc_irq, WAX_GSC_IRQ); 93 dev->irq = gsc_claim_irq(&gsc_irq, WAX_GSC_IRQ);
94 if (dev->irq < 0) { 94 if (dev->irq < 0) {
95 printk(KERN_ERR "%s(): cannot get GSC irq\n", 95 printk(KERN_ERR "%s(): cannot get GSC irq\n",
96 __FUNCTION__); 96 __func__);
97 kfree(wax); 97 kfree(wax);
98 return -EBUSY; 98 return -EBUSY;
99 } 99 }
diff --git a/drivers/pci/intel-iommu.c b/drivers/pci/intel-iommu.c
index 1fd8bb765702..66c0fd21894b 100644
--- a/drivers/pci/intel-iommu.c
+++ b/drivers/pci/intel-iommu.c
@@ -49,7 +49,7 @@
49 49
50#define DEFAULT_DOMAIN_ADDRESS_WIDTH 48 50#define DEFAULT_DOMAIN_ADDRESS_WIDTH 48
51 51
52#define DMAR_OPERATION_TIMEOUT (HZ*60) /* 1m */ 52#define DMAR_OPERATION_TIMEOUT ((cycles_t) tsc_khz*10*1000) /* 10sec */
53 53
54#define DOMAIN_MAX_ADDR(gaw) ((((u64)1) << gaw) - 1) 54#define DOMAIN_MAX_ADDR(gaw) ((((u64)1) << gaw) - 1)
55 55
@@ -490,12 +490,12 @@ static int iommu_alloc_root_entry(struct intel_iommu *iommu)
490 490
491#define IOMMU_WAIT_OP(iommu, offset, op, cond, sts) \ 491#define IOMMU_WAIT_OP(iommu, offset, op, cond, sts) \
492{\ 492{\
493 unsigned long start_time = jiffies;\ 493 cycles_t start_time = get_cycles();\
494 while (1) {\ 494 while (1) {\
495 sts = op (iommu->reg + offset);\ 495 sts = op (iommu->reg + offset);\
496 if (cond)\ 496 if (cond)\
497 break;\ 497 break;\
498 if (time_after(jiffies, start_time + DMAR_OPERATION_TIMEOUT))\ 498 if (DMAR_OPERATION_TIMEOUT < (get_cycles() - start_time))\
499 panic("DMAR hardware is malfunctioning\n");\ 499 panic("DMAR hardware is malfunctioning\n");\
500 cpu_relax();\ 500 cpu_relax();\
501 }\ 501 }\
diff --git a/drivers/pci/pci-acpi.c b/drivers/pci/pci-acpi.c
index 72f7476930c8..9d6fc8e6285d 100644
--- a/drivers/pci/pci-acpi.c
+++ b/drivers/pci/pci-acpi.c
@@ -19,8 +19,31 @@
19#include <linux/pci-acpi.h> 19#include <linux/pci-acpi.h>
20#include "pci.h" 20#include "pci.h"
21 21
22static u32 ctrlset_buf[3] = {0, 0, 0}; 22struct acpi_osc_data {
23static u32 global_ctrlsets = 0; 23 acpi_handle handle;
24 u32 ctrlset_buf[3];
25 u32 global_ctrlsets;
26 struct list_head sibiling;
27};
28static LIST_HEAD(acpi_osc_data_list);
29
30static struct acpi_osc_data *acpi_get_osc_data(acpi_handle handle)
31{
32 struct acpi_osc_data *data;
33
34 list_for_each_entry(data, &acpi_osc_data_list, sibiling) {
35 if (data->handle == handle)
36 return data;
37 }
38 data = kzalloc(sizeof(*data), GFP_KERNEL);
39 if (!data)
40 return NULL;
41 INIT_LIST_HEAD(&data->sibiling);
42 data->handle = handle;
43 list_add_tail(&data->sibiling, &acpi_osc_data_list);
44 return data;
45}
46
24static u8 OSC_UUID[16] = {0x5B, 0x4D, 0xDB, 0x33, 0xF7, 0x1F, 0x1C, 0x40, 0x96, 0x57, 0x74, 0x41, 0xC0, 0x3D, 0xD7, 0x66}; 47static u8 OSC_UUID[16] = {0x5B, 0x4D, 0xDB, 0x33, 0xF7, 0x1F, 0x1C, 0x40, 0x96, 0x57, 0x74, 0x41, 0xC0, 0x3D, 0xD7, 0x66};
25 48
26static acpi_status 49static acpi_status
@@ -37,8 +60,27 @@ acpi_query_osc (
37 union acpi_object *out_obj; 60 union acpi_object *out_obj;
38 u32 osc_dw0; 61 u32 osc_dw0;
39 acpi_status *ret_status = (acpi_status *)retval; 62 acpi_status *ret_status = (acpi_status *)retval;
63 struct acpi_osc_data *osc_data;
64 u32 flags = (unsigned long)context, temp;
65 acpi_handle tmp;
66
67 status = acpi_get_handle(handle, "_OSC", &tmp);
68 if (ACPI_FAILURE(status))
69 return status;
70
71 osc_data = acpi_get_osc_data(handle);
72 if (!osc_data) {
73 printk(KERN_ERR "acpi osc data array is full\n");
74 return AE_ERROR;
75 }
76
77 osc_data->ctrlset_buf[OSC_SUPPORT_TYPE] |= (flags & OSC_SUPPORT_MASKS);
78
79 /* do _OSC query for all possible controls */
80 temp = osc_data->ctrlset_buf[OSC_CONTROL_TYPE];
81 osc_data->ctrlset_buf[OSC_QUERY_TYPE] = OSC_QUERY_ENABLE;
82 osc_data->ctrlset_buf[OSC_CONTROL_TYPE] = OSC_CONTROL_MASKS;
40 83
41
42 /* Setting up input parameters */ 84 /* Setting up input parameters */
43 input.count = 4; 85 input.count = 4;
44 input.pointer = in_params; 86 input.pointer = in_params;
@@ -51,13 +93,11 @@ acpi_query_osc (
51 in_params[2].integer.value = 3; 93 in_params[2].integer.value = 3;
52 in_params[3].type = ACPI_TYPE_BUFFER; 94 in_params[3].type = ACPI_TYPE_BUFFER;
53 in_params[3].buffer.length = 12; 95 in_params[3].buffer.length = 12;
54 in_params[3].buffer.pointer = (u8 *)context; 96 in_params[3].buffer.pointer = (u8 *)osc_data->ctrlset_buf;
55 97
56 status = acpi_evaluate_object(handle, "_OSC", &input, &output); 98 status = acpi_evaluate_object(handle, "_OSC", &input, &output);
57 if (ACPI_FAILURE (status)) { 99 if (ACPI_FAILURE(status))
58 *ret_status = status; 100 goto out_nofree;
59 return status;
60 }
61 out_obj = output.pointer; 101 out_obj = output.pointer;
62 102
63 if (out_obj->type != ACPI_TYPE_BUFFER) { 103 if (out_obj->type != ACPI_TYPE_BUFFER) {
@@ -76,7 +116,8 @@ acpi_query_osc (
76 printk(KERN_DEBUG "_OSC invalid revision\n"); 116 printk(KERN_DEBUG "_OSC invalid revision\n");
77 if (osc_dw0 & OSC_CAPABILITIES_MASK_ERROR) { 117 if (osc_dw0 & OSC_CAPABILITIES_MASK_ERROR) {
78 /* Update Global Control Set */ 118 /* Update Global Control Set */
79 global_ctrlsets = *((u32 *)(out_obj->buffer.pointer+8)); 119 osc_data->global_ctrlsets =
120 *((u32 *)(out_obj->buffer.pointer + 8));
80 status = AE_OK; 121 status = AE_OK;
81 goto query_osc_out; 122 goto query_osc_out;
82 } 123 }
@@ -85,12 +126,21 @@ acpi_query_osc (
85 } 126 }
86 127
87 /* Update Global Control Set */ 128 /* Update Global Control Set */
88 global_ctrlsets = *((u32 *)(out_obj->buffer.pointer + 8)); 129 osc_data->global_ctrlsets = *((u32 *)(out_obj->buffer.pointer + 8));
89 status = AE_OK; 130 status = AE_OK;
90 131
91query_osc_out: 132query_osc_out:
92 kfree(output.pointer); 133 kfree(output.pointer);
134out_nofree:
93 *ret_status = status; 135 *ret_status = status;
136
137 osc_data->ctrlset_buf[OSC_QUERY_TYPE] = !OSC_QUERY_ENABLE;
138 osc_data->ctrlset_buf[OSC_CONTROL_TYPE] = temp;
139 if (ACPI_FAILURE(status)) {
140 /* no osc support at all */
141 osc_data->ctrlset_buf[OSC_SUPPORT_TYPE] = 0;
142 }
143
94 return status; 144 return status;
95} 145}
96 146
@@ -165,28 +215,15 @@ run_osc_out:
165 **/ 215 **/
166acpi_status __pci_osc_support_set(u32 flags, const char *hid) 216acpi_status __pci_osc_support_set(u32 flags, const char *hid)
167{ 217{
168 u32 temp; 218 acpi_status retval = AE_NOT_FOUND;
169 acpi_status retval;
170 219
171 if (!(flags & OSC_SUPPORT_MASKS)) { 220 if (!(flags & OSC_SUPPORT_MASKS)) {
172 return AE_TYPE; 221 return AE_TYPE;
173 } 222 }
174 ctrlset_buf[OSC_SUPPORT_TYPE] |= (flags & OSC_SUPPORT_MASKS);
175
176 /* do _OSC query for all possible controls */
177 temp = ctrlset_buf[OSC_CONTROL_TYPE];
178 ctrlset_buf[OSC_QUERY_TYPE] = OSC_QUERY_ENABLE;
179 ctrlset_buf[OSC_CONTROL_TYPE] = OSC_CONTROL_MASKS;
180 acpi_get_devices(hid, 223 acpi_get_devices(hid,
181 acpi_query_osc, 224 acpi_query_osc,
182 ctrlset_buf, 225 (void *)(unsigned long)flags,
183 (void **) &retval ); 226 (void **) &retval );
184 ctrlset_buf[OSC_QUERY_TYPE] = !OSC_QUERY_ENABLE;
185 ctrlset_buf[OSC_CONTROL_TYPE] = temp;
186 if (ACPI_FAILURE(retval)) {
187 /* no osc support at all */
188 ctrlset_buf[OSC_SUPPORT_TYPE] = 0;
189 }
190 return AE_OK; 227 return AE_OK;
191} 228}
192 229
@@ -201,19 +238,31 @@ acpi_status pci_osc_control_set(acpi_handle handle, u32 flags)
201{ 238{
202 acpi_status status; 239 acpi_status status;
203 u32 ctrlset; 240 u32 ctrlset;
241 acpi_handle tmp;
242 struct acpi_osc_data *osc_data;
243
244 status = acpi_get_handle(handle, "_OSC", &tmp);
245 if (ACPI_FAILURE(status))
246 return status;
247
248 osc_data = acpi_get_osc_data(handle);
249 if (!osc_data) {
250 printk(KERN_ERR "acpi osc data array is full\n");
251 return AE_ERROR;
252 }
204 253
205 ctrlset = (flags & OSC_CONTROL_MASKS); 254 ctrlset = (flags & OSC_CONTROL_MASKS);
206 if (!ctrlset) { 255 if (!ctrlset) {
207 return AE_TYPE; 256 return AE_TYPE;
208 } 257 }
209 if (ctrlset_buf[OSC_SUPPORT_TYPE] && 258 if (osc_data->ctrlset_buf[OSC_SUPPORT_TYPE] &&
210 ((global_ctrlsets & ctrlset) != ctrlset)) { 259 ((osc_data->global_ctrlsets & ctrlset) != ctrlset)) {
211 return AE_SUPPORT; 260 return AE_SUPPORT;
212 } 261 }
213 ctrlset_buf[OSC_CONTROL_TYPE] |= ctrlset; 262 osc_data->ctrlset_buf[OSC_CONTROL_TYPE] |= ctrlset;
214 status = acpi_run_osc(handle, ctrlset_buf); 263 status = acpi_run_osc(handle, osc_data->ctrlset_buf);
215 if (ACPI_FAILURE (status)) { 264 if (ACPI_FAILURE (status)) {
216 ctrlset_buf[OSC_CONTROL_TYPE] &= ~ctrlset; 265 osc_data->ctrlset_buf[OSC_CONTROL_TYPE] &= ~ctrlset;
217 } 266 }
218 267
219 return status; 268 return status;
diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c
index afd914ebe215..dabb563f51d9 100644
--- a/drivers/pci/quirks.c
+++ b/drivers/pci/quirks.c
@@ -1503,8 +1503,7 @@ static void pci_do_fixups(struct pci_dev *dev, struct pci_fixup *f, struct pci_f
1503 (f->device == dev->device || f->device == (u16) PCI_ANY_ID)) { 1503 (f->device == dev->device || f->device == (u16) PCI_ANY_ID)) {
1504#ifdef DEBUG 1504#ifdef DEBUG
1505 dev_dbg(&dev->dev, "calling "); 1505 dev_dbg(&dev->dev, "calling ");
1506 print_fn_descriptor_symbol("%s()\n", 1506 print_fn_descriptor_symbol("%s\n", f->hook);
1507 (unsigned long) f->hook);
1508#endif 1507#endif
1509 f->hook(dev); 1508 f->hook(dev);
1510 } 1509 }
@@ -1826,6 +1825,7 @@ static void __devinit nv_msi_ht_cap_quirk(struct pci_dev *dev)
1826 } 1825 }
1827} 1826}
1828DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_NVIDIA, PCI_ANY_ID, nv_msi_ht_cap_quirk); 1827DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_NVIDIA, PCI_ANY_ID, nv_msi_ht_cap_quirk);
1828DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_AL, PCI_ANY_ID, nv_msi_ht_cap_quirk);
1829 1829
1830static void __devinit quirk_msi_intx_disable_bug(struct pci_dev *dev) 1830static void __devinit quirk_msi_intx_disable_bug(struct pci_dev *dev)
1831{ 1831{
diff --git a/drivers/pnp/base.h b/drivers/pnp/base.h
index 4fe7c58f57e9..886dac823ed6 100644
--- a/drivers/pnp/base.h
+++ b/drivers/pnp/base.h
@@ -19,6 +19,7 @@ void pnp_remove_card(struct pnp_card *card);
19int pnp_add_card_device(struct pnp_card *card, struct pnp_dev *dev); 19int pnp_add_card_device(struct pnp_card *card, struct pnp_dev *dev);
20void pnp_remove_card_device(struct pnp_dev *dev); 20void pnp_remove_card_device(struct pnp_dev *dev);
21 21
22struct pnp_option *pnp_build_option(int priority);
22struct pnp_option *pnp_register_independent_option(struct pnp_dev *dev); 23struct pnp_option *pnp_register_independent_option(struct pnp_dev *dev);
23struct pnp_option *pnp_register_dependent_option(struct pnp_dev *dev, 24struct pnp_option *pnp_register_dependent_option(struct pnp_dev *dev,
24 int priority); 25 int priority);
diff --git a/drivers/pnp/interface.c b/drivers/pnp/interface.c
index 5d9301de1778..5695a79f3a52 100644
--- a/drivers/pnp/interface.c
+++ b/drivers/pnp/interface.c
@@ -424,7 +424,7 @@ pnp_set_current_resources(struct device *dmdev, struct device_attribute *attr,
424 start = simple_strtoul(buf, &buf, 0); 424 start = simple_strtoul(buf, &buf, 0);
425 pnp_res = pnp_add_irq_resource(dev, start, 0); 425 pnp_res = pnp_add_irq_resource(dev, start, 0);
426 if (pnp_res) 426 if (pnp_res)
427 nirq++; 427 pnp_res->index = nirq++;
428 continue; 428 continue;
429 } 429 }
430 if (!strnicmp(buf, "dma", 3)) { 430 if (!strnicmp(buf, "dma", 3)) {
diff --git a/drivers/pnp/quirks.c b/drivers/pnp/quirks.c
index d049a2279fea..e2b7de4cb05e 100644
--- a/drivers/pnp/quirks.c
+++ b/drivers/pnp/quirks.c
@@ -111,6 +111,113 @@ static void quirk_sb16audio_resources(struct pnp_dev *dev)
111 dev_info(&dev->dev, "SB audio device quirk - increased port range\n"); 111 dev_info(&dev->dev, "SB audio device quirk - increased port range\n");
112} 112}
113 113
114static struct pnp_option *quirk_isapnp_mpu_options(struct pnp_dev *dev)
115{
116 struct pnp_option *head = NULL;
117 struct pnp_option *prev = NULL;
118 struct pnp_option *res;
119
120 /*
121 * Build a functional IRQ-less variant of each MPU option.
122 */
123
124 for (res = dev->dependent; res; res = res->next) {
125 struct pnp_option *curr;
126 struct pnp_port *port;
127 struct pnp_port *copy;
128
129 port = res->port;
130 if (!port || !res->irq)
131 continue;
132
133 copy = pnp_alloc(sizeof *copy);
134 if (!copy)
135 break;
136
137 copy->min = port->min;
138 copy->max = port->max;
139 copy->align = port->align;
140 copy->size = port->size;
141 copy->flags = port->flags;
142
143 curr = pnp_build_option(PNP_RES_PRIORITY_FUNCTIONAL);
144 if (!curr) {
145 kfree(copy);
146 break;
147 }
148 curr->port = copy;
149
150 if (prev)
151 prev->next = curr;
152 else
153 head = curr;
154 prev = curr;
155 }
156 if (head)
157 dev_info(&dev->dev, "adding IRQ-less MPU options\n");
158
159 return head;
160}
161
162static void quirk_ad1815_mpu_resources(struct pnp_dev *dev)
163{
164 struct pnp_option *res;
165 struct pnp_irq *irq;
166
167 /*
168 * Distribute the independent IRQ over the dependent options
169 */
170
171 res = dev->independent;
172 if (!res)
173 return;
174
175 irq = res->irq;
176 if (!irq || irq->next)
177 return;
178
179 res = dev->dependent;
180 if (!res)
181 return;
182
183 while (1) {
184 struct pnp_irq *copy;
185
186 copy = pnp_alloc(sizeof *copy);
187 if (!copy)
188 break;
189
190 memcpy(copy->map, irq->map, sizeof copy->map);
191 copy->flags = irq->flags;
192
193 copy->next = res->irq; /* Yes, this is NULL */
194 res->irq = copy;
195
196 if (!res->next)
197 break;
198 res = res->next;
199 }
200 kfree(irq);
201
202 res->next = quirk_isapnp_mpu_options(dev);
203
204 res = dev->independent;
205 res->irq = NULL;
206}
207
208static void quirk_isapnp_mpu_resources(struct pnp_dev *dev)
209{
210 struct pnp_option *res;
211
212 res = dev->dependent;
213 if (!res)
214 return;
215
216 while (res->next)
217 res = res->next;
218
219 res->next = quirk_isapnp_mpu_options(dev);
220}
114 221
115#include <linux/pci.h> 222#include <linux/pci.h>
116 223
@@ -205,6 +312,11 @@ static struct pnp_fixup pnp_fixups[] = {
205 {"CTL0043", quirk_sb16audio_resources}, 312 {"CTL0043", quirk_sb16audio_resources},
206 {"CTL0044", quirk_sb16audio_resources}, 313 {"CTL0044", quirk_sb16audio_resources},
207 {"CTL0045", quirk_sb16audio_resources}, 314 {"CTL0045", quirk_sb16audio_resources},
315 /* Add IRQ-less MPU options */
316 {"ADS7151", quirk_ad1815_mpu_resources},
317 {"ADS7181", quirk_isapnp_mpu_resources},
318 {"AZT0002", quirk_isapnp_mpu_resources},
319 /* PnP resources that might overlap PCI BARs */
208 {"PNP0c01", quirk_system_pci_resources}, 320 {"PNP0c01", quirk_system_pci_resources},
209 {"PNP0c02", quirk_system_pci_resources}, 321 {"PNP0c02", quirk_system_pci_resources},
210 {""} 322 {""}
@@ -212,20 +324,15 @@ static struct pnp_fixup pnp_fixups[] = {
212 324
213void pnp_fixup_device(struct pnp_dev *dev) 325void pnp_fixup_device(struct pnp_dev *dev)
214{ 326{
215 int i = 0; 327 struct pnp_fixup *f;
216 void (*quirk)(struct pnp_dev *);
217
218 while (*pnp_fixups[i].id) {
219 if (compare_pnp_id(dev->id, pnp_fixups[i].id)) {
220 quirk = pnp_fixups[i].quirk_function;
221 328
329 for (f = pnp_fixups; *f->id; f++) {
330 if (!compare_pnp_id(dev->id, f->id))
331 continue;
222#ifdef DEBUG 332#ifdef DEBUG
223 dev_dbg(&dev->dev, "calling "); 333 dev_dbg(&dev->dev, "%s: calling ", f->id);
224 print_fn_descriptor_symbol("%s()\n", 334 print_fn_descriptor_symbol("%s\n", f->quirk_function);
225 (unsigned long) *quirk);
226#endif 335#endif
227 (*quirk)(dev); 336 f->quirk_function(dev);
228 }
229 i++;
230 } 337 }
231} 338}
diff --git a/drivers/pnp/resource.c b/drivers/pnp/resource.c
index 2041620d5682..390b50096e30 100644
--- a/drivers/pnp/resource.c
+++ b/drivers/pnp/resource.c
@@ -28,7 +28,7 @@ static int pnp_reserve_mem[16] = {[0 ... 15] = -1 }; /* reserve (don't use) some
28 * option registration 28 * option registration
29 */ 29 */
30 30
31static struct pnp_option *pnp_build_option(int priority) 31struct pnp_option *pnp_build_option(int priority)
32{ 32{
33 struct pnp_option *option = pnp_alloc(sizeof(struct pnp_option)); 33 struct pnp_option *option = pnp_alloc(sizeof(struct pnp_option));
34 34
diff --git a/drivers/pnp/support.c b/drivers/pnp/support.c
index 3eba85ed729c..95b076c18c07 100644
--- a/drivers/pnp/support.c
+++ b/drivers/pnp/support.c
@@ -45,10 +45,10 @@ void pnp_eisa_id_to_string(u32 id, char *str)
45 str[0] = 'A' + ((id >> 26) & 0x3f) - 1; 45 str[0] = 'A' + ((id >> 26) & 0x3f) - 1;
46 str[1] = 'A' + ((id >> 21) & 0x1f) - 1; 46 str[1] = 'A' + ((id >> 21) & 0x1f) - 1;
47 str[2] = 'A' + ((id >> 16) & 0x1f) - 1; 47 str[2] = 'A' + ((id >> 16) & 0x1f) - 1;
48 str[3] = hex_asc((id >> 12) & 0xf); 48 str[3] = hex_asc_hi(id >> 8);
49 str[4] = hex_asc((id >> 8) & 0xf); 49 str[4] = hex_asc_lo(id >> 8);
50 str[5] = hex_asc((id >> 4) & 0xf); 50 str[5] = hex_asc_hi(id);
51 str[6] = hex_asc((id >> 0) & 0xf); 51 str[6] = hex_asc_lo(id);
52 str[7] = '\0'; 52 str[7] = '\0';
53} 53}
54 54
diff --git a/drivers/rtc/rtc-lib.c b/drivers/rtc/rtc-lib.c
index ba795a4db1e9..9f996ec881ce 100644
--- a/drivers/rtc/rtc-lib.c
+++ b/drivers/rtc/rtc-lib.c
@@ -51,7 +51,7 @@ EXPORT_SYMBOL(rtc_year_days);
51 */ 51 */
52void rtc_time_to_tm(unsigned long time, struct rtc_time *tm) 52void rtc_time_to_tm(unsigned long time, struct rtc_time *tm)
53{ 53{
54 register int days, month, year; 54 unsigned int days, month, year;
55 55
56 days = time / 86400; 56 days = time / 86400;
57 time -= days * 86400; 57 time -= days * 86400;
diff --git a/drivers/rtc/rtc-m41t80.c b/drivers/rtc/rtc-m41t80.c
index 316bfaa80872..a3e0880b38fb 100644
--- a/drivers/rtc/rtc-m41t80.c
+++ b/drivers/rtc/rtc-m41t80.c
@@ -15,6 +15,7 @@
15 15
16#include <linux/module.h> 16#include <linux/module.h>
17#include <linux/init.h> 17#include <linux/init.h>
18#include <linux/kernel.h>
18#include <linux/slab.h> 19#include <linux/slab.h>
19#include <linux/string.h> 20#include <linux/string.h>
20#include <linux/i2c.h> 21#include <linux/i2c.h>
@@ -803,6 +804,7 @@ static int m41t80_probe(struct i2c_client *client,
803 804
804#ifdef CONFIG_RTC_DRV_M41T80_WDT 805#ifdef CONFIG_RTC_DRV_M41T80_WDT
805 if (clientdata->features & M41T80_FEATURE_HT) { 806 if (clientdata->features & M41T80_FEATURE_HT) {
807 save_client = client;
806 rc = misc_register(&wdt_dev); 808 rc = misc_register(&wdt_dev);
807 if (rc) 809 if (rc)
808 goto exit; 810 goto exit;
@@ -811,7 +813,6 @@ static int m41t80_probe(struct i2c_client *client,
811 misc_deregister(&wdt_dev); 813 misc_deregister(&wdt_dev);
812 goto exit; 814 goto exit;
813 } 815 }
814 save_client = client;
815 } 816 }
816#endif 817#endif
817 return 0; 818 return 0;
diff --git a/drivers/s390/block/dasd.c b/drivers/s390/block/dasd.c
index ac6d4d3218b3..8ba3f135da22 100644
--- a/drivers/s390/block/dasd.c
+++ b/drivers/s390/block/dasd.c
@@ -925,6 +925,8 @@ static void dasd_handle_killed_request(struct ccw_device *cdev,
925 struct dasd_ccw_req *cqr; 925 struct dasd_ccw_req *cqr;
926 struct dasd_device *device; 926 struct dasd_device *device;
927 927
928 if (!intparm)
929 return;
928 cqr = (struct dasd_ccw_req *) intparm; 930 cqr = (struct dasd_ccw_req *) intparm;
929 if (cqr->status != DASD_CQR_IN_IO) { 931 if (cqr->status != DASD_CQR_IN_IO) {
930 MESSAGE(KERN_DEBUG, 932 MESSAGE(KERN_DEBUG,
@@ -976,17 +978,16 @@ void dasd_int_handler(struct ccw_device *cdev, unsigned long intparm,
976 if (IS_ERR(irb)) { 978 if (IS_ERR(irb)) {
977 switch (PTR_ERR(irb)) { 979 switch (PTR_ERR(irb)) {
978 case -EIO: 980 case -EIO:
979 dasd_handle_killed_request(cdev, intparm);
980 break; 981 break;
981 case -ETIMEDOUT: 982 case -ETIMEDOUT:
982 printk(KERN_WARNING"%s(%s): request timed out\n", 983 printk(KERN_WARNING"%s(%s): request timed out\n",
983 __func__, cdev->dev.bus_id); 984 __func__, cdev->dev.bus_id);
984 //FIXME - dasd uses own timeout interface...
985 break; 985 break;
986 default: 986 default:
987 printk(KERN_WARNING"%s(%s): unknown error %ld\n", 987 printk(KERN_WARNING"%s(%s): unknown error %ld\n",
988 __func__, cdev->dev.bus_id, PTR_ERR(irb)); 988 __func__, cdev->dev.bus_id, PTR_ERR(irb));
989 } 989 }
990 dasd_handle_killed_request(cdev, intparm);
990 return; 991 return;
991 } 992 }
992 993
diff --git a/drivers/s390/block/dasd_devmap.c b/drivers/s390/block/dasd_devmap.c
index f4fb40257348..d774e79476fe 100644
--- a/drivers/s390/block/dasd_devmap.c
+++ b/drivers/s390/block/dasd_devmap.c
@@ -86,10 +86,10 @@ static DEFINE_SPINLOCK(dasd_devmap_lock);
86static struct list_head dasd_hashlists[256]; 86static struct list_head dasd_hashlists[256];
87int dasd_max_devindex; 87int dasd_max_devindex;
88 88
89static struct dasd_devmap *dasd_add_busid(char *, int); 89static struct dasd_devmap *dasd_add_busid(const char *, int);
90 90
91static inline int 91static inline int
92dasd_hash_busid(char *bus_id) 92dasd_hash_busid(const char *bus_id)
93{ 93{
94 int hash, i; 94 int hash, i;
95 95
@@ -394,7 +394,7 @@ dasd_parse(void)
394 * devices. 394 * devices.
395 */ 395 */
396static struct dasd_devmap * 396static struct dasd_devmap *
397dasd_add_busid(char *bus_id, int features) 397dasd_add_busid(const char *bus_id, int features)
398{ 398{
399 struct dasd_devmap *devmap, *new, *tmp; 399 struct dasd_devmap *devmap, *new, *tmp;
400 int hash; 400 int hash;
@@ -430,7 +430,7 @@ dasd_add_busid(char *bus_id, int features)
430 * Find devmap for device with given bus_id. 430 * Find devmap for device with given bus_id.
431 */ 431 */
432static struct dasd_devmap * 432static struct dasd_devmap *
433dasd_find_busid(char *bus_id) 433dasd_find_busid(const char *bus_id)
434{ 434{
435 struct dasd_devmap *devmap, *tmp; 435 struct dasd_devmap *devmap, *tmp;
436 int hash; 436 int hash;
@@ -452,7 +452,7 @@ dasd_find_busid(char *bus_id)
452 * Check if busid has been added to the list of dasd ranges. 452 * Check if busid has been added to the list of dasd ranges.
453 */ 453 */
454int 454int
455dasd_busid_known(char *bus_id) 455dasd_busid_known(const char *bus_id)
456{ 456{
457 return IS_ERR(dasd_find_busid(bus_id)) ? -ENOENT : 0; 457 return IS_ERR(dasd_find_busid(bus_id)) ? -ENOENT : 0;
458} 458}
diff --git a/drivers/s390/block/dasd_int.h b/drivers/s390/block/dasd_int.h
index 6c624bf44617..fb2f931cf844 100644
--- a/drivers/s390/block/dasd_int.h
+++ b/drivers/s390/block/dasd_int.h
@@ -598,7 +598,7 @@ struct dasd_device *dasd_device_from_cdev_locked(struct ccw_device *);
598struct dasd_device *dasd_device_from_devindex(int); 598struct dasd_device *dasd_device_from_devindex(int);
599 599
600int dasd_parse(void); 600int dasd_parse(void);
601int dasd_busid_known(char *); 601int dasd_busid_known(const char *);
602 602
603/* externals in dasd_gendisk.c */ 603/* externals in dasd_gendisk.c */
604int dasd_gendisk_init(void); 604int dasd_gendisk_init(void);
diff --git a/drivers/s390/char/tape_core.c b/drivers/s390/char/tape_core.c
index 7ad8cf157641..76e44eb7c47f 100644
--- a/drivers/s390/char/tape_core.c
+++ b/drivers/s390/char/tape_core.c
@@ -76,32 +76,9 @@ const char *tape_op_verbose[TO_SIZE] =
76 [TO_KEKL_QUERY] = "KLQ",[TO_RDC] = "RDC", 76 [TO_KEKL_QUERY] = "KLQ",[TO_RDC] = "RDC",
77}; 77};
78 78
79static int 79static int devid_to_int(struct ccw_dev_id *dev_id)
80busid_to_int(char *bus_id)
81{ 80{
82 int dec; 81 return dev_id->devno + (dev_id->ssid << 16);
83 int d;
84 char * s;
85
86 for(s = bus_id, d = 0; *s != '\0' && *s != '.'; s++)
87 d = (d * 10) + (*s - '0');
88 dec = d;
89 for(s++, d = 0; *s != '\0' && *s != '.'; s++)
90 d = (d * 10) + (*s - '0');
91 dec = (dec << 8) + d;
92
93 for(s++; *s != '\0'; s++) {
94 if (*s >= '0' && *s <= '9') {
95 d = *s - '0';
96 } else if (*s >= 'a' && *s <= 'f') {
97 d = *s - 'a' + 10;
98 } else {
99 d = *s - 'A' + 10;
100 }
101 dec = (dec << 4) + d;
102 }
103
104 return dec;
105} 82}
106 83
107/* 84/*
@@ -551,6 +528,7 @@ tape_generic_probe(struct ccw_device *cdev)
551{ 528{
552 struct tape_device *device; 529 struct tape_device *device;
553 int ret; 530 int ret;
531 struct ccw_dev_id dev_id;
554 532
555 device = tape_alloc_device(); 533 device = tape_alloc_device();
556 if (IS_ERR(device)) 534 if (IS_ERR(device))
@@ -565,7 +543,8 @@ tape_generic_probe(struct ccw_device *cdev)
565 cdev->dev.driver_data = device; 543 cdev->dev.driver_data = device;
566 cdev->handler = __tape_do_irq; 544 cdev->handler = __tape_do_irq;
567 device->cdev = cdev; 545 device->cdev = cdev;
568 device->cdev_id = busid_to_int(cdev->dev.bus_id); 546 ccw_device_get_id(cdev, &dev_id);
547 device->cdev_id = devid_to_int(&dev_id);
569 PRINT_INFO("tape device %s found\n", cdev->dev.bus_id); 548 PRINT_INFO("tape device %s found\n", cdev->dev.bus_id);
570 return ret; 549 return ret;
571} 550}
diff --git a/drivers/s390/char/vmlogrdr.c b/drivers/s390/char/vmlogrdr.c
index d364e0bfae12..e8487347e4d4 100644
--- a/drivers/s390/char/vmlogrdr.c
+++ b/drivers/s390/char/vmlogrdr.c
@@ -858,7 +858,7 @@ static int __init vmlogrdr_init(void)
858 for (i=0; i < MAXMINOR; ++i ) { 858 for (i=0; i < MAXMINOR; ++i ) {
859 sys_ser[i].buffer = (char *) get_zeroed_page(GFP_KERNEL); 859 sys_ser[i].buffer = (char *) get_zeroed_page(GFP_KERNEL);
860 if (!sys_ser[i].buffer) { 860 if (!sys_ser[i].buffer) {
861 rc = ENOMEM; 861 rc = -ENOMEM;
862 break; 862 break;
863 } 863 }
864 sys_ser[i].current_position = sys_ser[i].buffer; 864 sys_ser[i].current_position = sys_ser[i].buffer;
diff --git a/drivers/s390/cio/blacklist.c b/drivers/s390/cio/blacklist.c
index 9c21b8f43f9b..a4a5f2efea48 100644
--- a/drivers/s390/cio/blacklist.c
+++ b/drivers/s390/cio/blacklist.c
@@ -19,7 +19,6 @@
19 19
20#include <asm/cio.h> 20#include <asm/cio.h>
21#include <asm/uaccess.h> 21#include <asm/uaccess.h>
22#include <asm/cio.h>
23 22
24#include "blacklist.h" 23#include "blacklist.h"
25#include "cio.h" 24#include "cio.h"
diff --git a/drivers/s390/cio/device_pgid.c b/drivers/s390/cio/device_pgid.c
index ba559053402e..5cf7be008e98 100644
--- a/drivers/s390/cio/device_pgid.c
+++ b/drivers/s390/cio/device_pgid.c
@@ -243,16 +243,10 @@ __ccw_device_do_pgid(struct ccw_device *cdev, __u8 func)
243 /* Setup sense path group id channel program. */ 243 /* Setup sense path group id channel program. */
244 cdev->private->pgid[0].inf.fc = func; 244 cdev->private->pgid[0].inf.fc = func;
245 ccw = cdev->private->iccws; 245 ccw = cdev->private->iccws;
246 if (!cdev->private->flags.pgid_single) { 246 if (cdev->private->flags.pgid_single)
247 cdev->private->pgid[0].inf.fc |= SPID_FUNC_MULTI_PATH;
248 ccw->cmd_code = CCW_CMD_SUSPEND_RECONN;
249 ccw->cda = 0;
250 ccw->count = 0;
251 ccw->flags = CCW_FLAG_SLI | CCW_FLAG_CC;
252 ccw++;
253 } else
254 cdev->private->pgid[0].inf.fc |= SPID_FUNC_SINGLE_PATH; 247 cdev->private->pgid[0].inf.fc |= SPID_FUNC_SINGLE_PATH;
255 248 else
249 cdev->private->pgid[0].inf.fc |= SPID_FUNC_MULTI_PATH;
256 ccw->cmd_code = CCW_CMD_SET_PGID; 250 ccw->cmd_code = CCW_CMD_SET_PGID;
257 ccw->cda = (__u32) __pa (&cdev->private->pgid[0]); 251 ccw->cda = (__u32) __pa (&cdev->private->pgid[0]);
258 ccw->count = sizeof (struct pgid); 252 ccw->count = sizeof (struct pgid);
diff --git a/drivers/scsi/aha152x.c b/drivers/scsi/aha152x.c
index f5215fd4b73d..1dca1775f4b1 100644
--- a/drivers/scsi/aha152x.c
+++ b/drivers/scsi/aha152x.c
@@ -3830,7 +3830,7 @@ static int __init aha152x_init(void)
3830 iounmap(p); 3830 iounmap(p);
3831 } 3831 }
3832 if (!ok && setup_count == 0) 3832 if (!ok && setup_count == 0)
3833 return 0; 3833 return -ENODEV;
3834 3834
3835 printk(KERN_INFO "aha152x: BIOS test: passed, "); 3835 printk(KERN_INFO "aha152x: BIOS test: passed, ");
3836#else 3836#else
@@ -3909,14 +3909,14 @@ static int __init aha152x_init(void)
3909#endif 3909#endif
3910 } 3910 }
3911 3911
3912 return 1; 3912 return 0;
3913} 3913}
3914 3914
3915static void __exit aha152x_exit(void) 3915static void __exit aha152x_exit(void)
3916{ 3916{
3917 struct aha152x_hostdata *hd; 3917 struct aha152x_hostdata *hd, *tmp;
3918 3918
3919 list_for_each_entry(hd, &aha152x_host_list, host_list) { 3919 list_for_each_entry_safe(hd, tmp, &aha152x_host_list, host_list) {
3920 struct Scsi_Host *shost = container_of((void *)hd, struct Scsi_Host, hostdata); 3920 struct Scsi_Host *shost = container_of((void *)hd, struct Scsi_Host, hostdata);
3921 3921
3922 aha152x_release(shost); 3922 aha152x_release(shost);
diff --git a/drivers/scsi/gdth.c b/drivers/scsi/gdth.c
index 8e2e964af668..46771d4c81bd 100644
--- a/drivers/scsi/gdth.c
+++ b/drivers/scsi/gdth.c
@@ -550,7 +550,6 @@ static int __init gdth_search_isa(ulong32 bios_adr)
550#endif /* CONFIG_ISA */ 550#endif /* CONFIG_ISA */
551 551
552#ifdef CONFIG_PCI 552#ifdef CONFIG_PCI
553static bool gdth_pci_registered;
554 553
555static bool gdth_search_vortex(ushort device) 554static bool gdth_search_vortex(ushort device)
556{ 555{
@@ -3724,6 +3723,8 @@ static void gdth_log_event(gdth_evt_data *dvr, char *buffer)
3724} 3723}
3725 3724
3726#ifdef GDTH_STATISTICS 3725#ifdef GDTH_STATISTICS
3726static unchar gdth_timer_running;
3727
3727static void gdth_timeout(ulong data) 3728static void gdth_timeout(ulong data)
3728{ 3729{
3729 ulong32 i; 3730 ulong32 i;
@@ -3731,7 +3732,10 @@ static void gdth_timeout(ulong data)
3731 gdth_ha_str *ha; 3732 gdth_ha_str *ha;
3732 ulong flags; 3733 ulong flags;
3733 3734
3734 BUG_ON(list_empty(&gdth_instances)); 3735 if(unlikely(list_empty(&gdth_instances))) {
3736 gdth_timer_running = 0;
3737 return;
3738 }
3735 3739
3736 ha = list_first_entry(&gdth_instances, gdth_ha_str, list); 3740 ha = list_first_entry(&gdth_instances, gdth_ha_str, list);
3737 spin_lock_irqsave(&ha->smp_lock, flags); 3741 spin_lock_irqsave(&ha->smp_lock, flags);
@@ -3751,6 +3755,22 @@ static void gdth_timeout(ulong data)
3751 add_timer(&gdth_timer); 3755 add_timer(&gdth_timer);
3752 spin_unlock_irqrestore(&ha->smp_lock, flags); 3756 spin_unlock_irqrestore(&ha->smp_lock, flags);
3753} 3757}
3758
3759static void gdth_timer_init(void)
3760{
3761 if (gdth_timer_running)
3762 return;
3763 gdth_timer_running = 1;
3764 TRACE2(("gdth_detect(): Initializing timer !\n"));
3765 gdth_timer.expires = jiffies + HZ;
3766 gdth_timer.data = 0L;
3767 gdth_timer.function = gdth_timeout;
3768 add_timer(&gdth_timer);
3769}
3770#else
3771static inline void gdth_timer_init(void)
3772{
3773}
3754#endif 3774#endif
3755 3775
3756static void __init internal_setup(char *str,int *ints) 3776static void __init internal_setup(char *str,int *ints)
@@ -4735,6 +4755,7 @@ static int __init gdth_isa_probe_one(ulong32 isa_bios)
4735 if (error) 4755 if (error)
4736 goto out_free_coal_stat; 4756 goto out_free_coal_stat;
4737 list_add_tail(&ha->list, &gdth_instances); 4757 list_add_tail(&ha->list, &gdth_instances);
4758 gdth_timer_init();
4738 4759
4739 scsi_scan_host(shp); 4760 scsi_scan_host(shp);
4740 4761
@@ -4865,6 +4886,7 @@ static int __init gdth_eisa_probe_one(ushort eisa_slot)
4865 if (error) 4886 if (error)
4866 goto out_free_coal_stat; 4887 goto out_free_coal_stat;
4867 list_add_tail(&ha->list, &gdth_instances); 4888 list_add_tail(&ha->list, &gdth_instances);
4889 gdth_timer_init();
4868 4890
4869 scsi_scan_host(shp); 4891 scsi_scan_host(shp);
4870 4892
@@ -5011,6 +5033,7 @@ static int gdth_pci_probe_one(gdth_pci_str *pcistr,
5011 list_add_tail(&ha->list, &gdth_instances); 5033 list_add_tail(&ha->list, &gdth_instances);
5012 5034
5013 pci_set_drvdata(ha->pdev, ha); 5035 pci_set_drvdata(ha->pdev, ha);
5036 gdth_timer_init();
5014 5037
5015 scsi_scan_host(shp); 5038 scsi_scan_host(shp);
5016 5039
@@ -5110,6 +5133,7 @@ static int __init gdth_init(void)
5110 /* initializations */ 5133 /* initializations */
5111 gdth_polling = TRUE; 5134 gdth_polling = TRUE;
5112 gdth_clear_events(); 5135 gdth_clear_events();
5136 init_timer(&gdth_timer);
5113 5137
5114 /* As default we do not probe for EISA or ISA controllers */ 5138 /* As default we do not probe for EISA or ISA controllers */
5115 if (probe_eisa_isa) { 5139 if (probe_eisa_isa) {
@@ -5132,23 +5156,17 @@ static int __init gdth_init(void)
5132 5156
5133#ifdef CONFIG_PCI 5157#ifdef CONFIG_PCI
5134 /* scanning for PCI controllers */ 5158 /* scanning for PCI controllers */
5135 if (pci_register_driver(&gdth_pci_driver) == 0) 5159 if (pci_register_driver(&gdth_pci_driver)) {
5136 gdth_pci_registered = true; 5160 gdth_ha_str *ha;
5161
5162 list_for_each_entry(ha, &gdth_instances, list)
5163 gdth_remove_one(ha);
5164 return -ENODEV;
5165 }
5137#endif /* CONFIG_PCI */ 5166#endif /* CONFIG_PCI */
5138 5167
5139 TRACE2(("gdth_detect() %d controller detected\n", gdth_ctr_count)); 5168 TRACE2(("gdth_detect() %d controller detected\n", gdth_ctr_count));
5140 5169
5141 if (list_empty(&gdth_instances))
5142 return -ENODEV;
5143
5144#ifdef GDTH_STATISTICS
5145 TRACE2(("gdth_detect(): Initializing timer !\n"));
5146 init_timer(&gdth_timer);
5147 gdth_timer.expires = jiffies + HZ;
5148 gdth_timer.data = 0L;
5149 gdth_timer.function = gdth_timeout;
5150 add_timer(&gdth_timer);
5151#endif
5152 major = register_chrdev(0,"gdth", &gdth_fops); 5170 major = register_chrdev(0,"gdth", &gdth_fops);
5153 register_reboot_notifier(&gdth_notifier); 5171 register_reboot_notifier(&gdth_notifier);
5154 gdth_polling = FALSE; 5172 gdth_polling = FALSE;
@@ -5167,8 +5185,7 @@ static void __exit gdth_exit(void)
5167#endif 5185#endif
5168 5186
5169#ifdef CONFIG_PCI 5187#ifdef CONFIG_PCI
5170 if (gdth_pci_registered) 5188 pci_unregister_driver(&gdth_pci_driver);
5171 pci_unregister_driver(&gdth_pci_driver);
5172#endif 5189#endif
5173 5190
5174 list_for_each_entry(ha, &gdth_instances, list) 5191 list_for_each_entry(ha, &gdth_instances, list)
diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c
index 010c1b9b178c..b43bf1d60dac 100644
--- a/drivers/scsi/libiscsi.c
+++ b/drivers/scsi/libiscsi.c
@@ -730,7 +730,9 @@ static int __iscsi_complete_pdu(struct iscsi_conn *conn, struct iscsi_hdr *hdr,
730 if (iscsi_recv_pdu(conn->cls_conn, hdr, data, 730 if (iscsi_recv_pdu(conn->cls_conn, hdr, data,
731 datalen)) 731 datalen))
732 rc = ISCSI_ERR_CONN_FAILED; 732 rc = ISCSI_ERR_CONN_FAILED;
733 } 733 } else
734 mod_timer(&conn->transport_timer,
735 jiffies + conn->recv_timeout);
734 iscsi_free_mgmt_task(conn, mtask); 736 iscsi_free_mgmt_task(conn, mtask);
735 break; 737 break;
736 default: 738 default:
@@ -1453,19 +1455,20 @@ static void iscsi_check_transport_timeouts(unsigned long data)
1453{ 1455{
1454 struct iscsi_conn *conn = (struct iscsi_conn *)data; 1456 struct iscsi_conn *conn = (struct iscsi_conn *)data;
1455 struct iscsi_session *session = conn->session; 1457 struct iscsi_session *session = conn->session;
1456 unsigned long timeout, next_timeout = 0, last_recv; 1458 unsigned long recv_timeout, next_timeout = 0, last_recv;
1457 1459
1458 spin_lock(&session->lock); 1460 spin_lock(&session->lock);
1459 if (session->state != ISCSI_STATE_LOGGED_IN) 1461 if (session->state != ISCSI_STATE_LOGGED_IN)
1460 goto done; 1462 goto done;
1461 1463
1462 timeout = conn->recv_timeout; 1464 recv_timeout = conn->recv_timeout;
1463 if (!timeout) 1465 if (!recv_timeout)
1464 goto done; 1466 goto done;
1465 1467
1466 timeout *= HZ; 1468 recv_timeout *= HZ;
1467 last_recv = conn->last_recv; 1469 last_recv = conn->last_recv;
1468 if (time_before_eq(last_recv + timeout + (conn->ping_timeout * HZ), 1470 if (conn->ping_mtask &&
1471 time_before_eq(conn->last_ping + (conn->ping_timeout * HZ),
1469 jiffies)) { 1472 jiffies)) {
1470 iscsi_conn_printk(KERN_ERR, conn, "ping timeout of %d secs " 1473 iscsi_conn_printk(KERN_ERR, conn, "ping timeout of %d secs "
1471 "expired, last rx %lu, last ping %lu, " 1474 "expired, last rx %lu, last ping %lu, "
@@ -1476,15 +1479,13 @@ static void iscsi_check_transport_timeouts(unsigned long data)
1476 return; 1479 return;
1477 } 1480 }
1478 1481
1479 if (time_before_eq(last_recv + timeout, jiffies)) { 1482 if (time_before_eq(last_recv + recv_timeout, jiffies)) {
1480 if (time_before_eq(conn->last_ping, last_recv)) { 1483 /* send a ping to try to provoke some traffic */
1481 /* send a ping to try to provoke some traffic */ 1484 debug_scsi("Sending nopout as ping on conn %p\n", conn);
1482 debug_scsi("Sending nopout as ping on conn %p\n", conn); 1485 iscsi_send_nopout(conn, NULL);
1483 iscsi_send_nopout(conn, NULL); 1486 next_timeout = conn->last_ping + (conn->ping_timeout * HZ);
1484 }
1485 next_timeout = last_recv + timeout + (conn->ping_timeout * HZ);
1486 } else 1487 } else
1487 next_timeout = last_recv + timeout; 1488 next_timeout = last_recv + recv_timeout;
1488 1489
1489 debug_scsi("Setting next tmo %lu\n", next_timeout); 1490 debug_scsi("Setting next tmo %lu\n", next_timeout);
1490 mod_timer(&conn->transport_timer, next_timeout); 1491 mod_timer(&conn->transport_timer, next_timeout);
diff --git a/drivers/scsi/qla1280.c b/drivers/scsi/qla1280.c
index fa060932d2b4..51e2f299dbbb 100644
--- a/drivers/scsi/qla1280.c
+++ b/drivers/scsi/qla1280.c
@@ -2007,7 +2007,7 @@ qla1280_set_defaults(struct scsi_qla_host *ha)
2007 nv->bus[bus].config_2.req_ack_active_negation = 1; 2007 nv->bus[bus].config_2.req_ack_active_negation = 1;
2008 nv->bus[bus].config_2.data_line_active_negation = 1; 2008 nv->bus[bus].config_2.data_line_active_negation = 1;
2009 nv->bus[bus].selection_timeout = 250; 2009 nv->bus[bus].selection_timeout = 250;
2010 nv->bus[bus].max_queue_depth = 256; 2010 nv->bus[bus].max_queue_depth = 32;
2011 2011
2012 if (IS_ISP1040(ha)) { 2012 if (IS_ISP1040(ha)) {
2013 nv->bus[bus].bus_reset_delay = 3; 2013 nv->bus[bus].bus_reset_delay = 3;
@@ -2051,7 +2051,7 @@ qla1280_config_target(struct scsi_qla_host *ha, int bus, int target)
2051 status = qla1280_mailbox_command(ha, 0x0f, mb); 2051 status = qla1280_mailbox_command(ha, 0x0f, mb);
2052 2052
2053 /* Save Tag queuing enable flag. */ 2053 /* Save Tag queuing enable flag. */
2054 flag = (BIT_0 << target) & mb[0]; 2054 flag = (BIT_0 << target);
2055 if (nv->bus[bus].target[target].parameter.tag_queuing) 2055 if (nv->bus[bus].target[target].parameter.tag_queuing)
2056 ha->bus_settings[bus].qtag_enables |= flag; 2056 ha->bus_settings[bus].qtag_enables |= flag;
2057 2057
diff --git a/drivers/serial/Kconfig b/drivers/serial/Kconfig
index 36acbcca2d48..62e6eb136a3c 100644
--- a/drivers/serial/Kconfig
+++ b/drivers/serial/Kconfig
@@ -976,11 +976,15 @@ config SERIAL_68328_RTS_CTS
976 depends on SERIAL_68328 976 depends on SERIAL_68328
977 977
978config SERIAL_COLDFIRE 978config SERIAL_COLDFIRE
979 bool "ColdFire serial support" 979 bool "ColdFire serial support (DEPRECATED)"
980 depends on COLDFIRE 980 depends on COLDFIRE
981 help 981 help
982 This driver supports the built-in serial ports of the Motorola ColdFire 982 This driver supports the built-in serial ports of the Motorola ColdFire
983 family of CPUs. 983 family of CPUs.
984 This driver is deprecated because it supports only the old interface
985 for serial drivers and features like magic keys are not working.
986 Please switch to the new style driver because this driver will be
987 removed soon.
984 988
985config SERIAL_MCF 989config SERIAL_MCF
986 bool "Coldfire serial support (new style driver)" 990 bool "Coldfire serial support (new style driver)"
diff --git a/drivers/serial/mcfserial.c b/drivers/serial/mcfserial.c
index 43af40d59b8a..56007cc8a9b3 100644
--- a/drivers/serial/mcfserial.c
+++ b/drivers/serial/mcfserial.c
@@ -1,3 +1,4 @@
1#warning This driver is deprecated. Check Kconfig for details.
1/* 2/*
2 * mcfserial.c -- serial driver for ColdFire internal UARTS. 3 * mcfserial.c -- serial driver for ColdFire internal UARTS.
3 * 4 *
diff --git a/drivers/spi/Kconfig b/drivers/spi/Kconfig
index fae9e8f3d092..66ec5d8808de 100644
--- a/drivers/spi/Kconfig
+++ b/drivers/spi/Kconfig
@@ -126,7 +126,6 @@ config SPI_MPC52xx_PSC
126config SPI_MPC83xx 126config SPI_MPC83xx
127 tristate "Freescale MPC83xx/QUICC Engine SPI controller" 127 tristate "Freescale MPC83xx/QUICC Engine SPI controller"
128 depends on SPI_MASTER && (PPC_83xx || QUICC_ENGINE) && EXPERIMENTAL 128 depends on SPI_MASTER && (PPC_83xx || QUICC_ENGINE) && EXPERIMENTAL
129 select SPI_BITBANG
130 help 129 help
131 This enables using the Freescale MPC83xx and QUICC Engine SPI 130 This enables using the Freescale MPC83xx and QUICC Engine SPI
132 controllers in master mode. 131 controllers in master mode.
diff --git a/drivers/spi/mpc52xx_psc_spi.c b/drivers/spi/mpc52xx_psc_spi.c
index 90729469d481..681d62325d3d 100644
--- a/drivers/spi/mpc52xx_psc_spi.c
+++ b/drivers/spi/mpc52xx_psc_spi.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * MPC52xx SPC in SPI mode driver. 2 * MPC52xx PSC in SPI mode driver.
3 * 3 *
4 * Maintainer: Dragos Carp 4 * Maintainer: Dragos Carp
5 * 5 *
diff --git a/drivers/spi/pxa2xx_spi.c b/drivers/spi/pxa2xx_spi.c
index 654bb58be630..0c452c46ab07 100644
--- a/drivers/spi/pxa2xx_spi.c
+++ b/drivers/spi/pxa2xx_spi.c
@@ -1567,7 +1567,7 @@ static int pxa2xx_spi_resume(struct platform_device *pdev)
1567 int status = 0; 1567 int status = 0;
1568 1568
1569 /* Enable the SSP clock */ 1569 /* Enable the SSP clock */
1570 clk_disable(ssp->clk); 1570 clk_enable(ssp->clk);
1571 1571
1572 /* Start the queue running */ 1572 /* Start the queue running */
1573 status = start_queue(drv_data); 1573 status = start_queue(drv_data);
diff --git a/drivers/spi/spi_mpc83xx.c b/drivers/spi/spi_mpc83xx.c
index 189f706b9e4b..6832da6f7109 100644
--- a/drivers/spi/spi_mpc83xx.c
+++ b/drivers/spi/spi_mpc83xx.c
@@ -49,6 +49,7 @@ struct mpc83xx_spi_reg {
49#define SPMODE_LEN(x) ((x) << 20) 49#define SPMODE_LEN(x) ((x) << 20)
50#define SPMODE_PM(x) ((x) << 16) 50#define SPMODE_PM(x) ((x) << 16)
51#define SPMODE_OP (1 << 14) 51#define SPMODE_OP (1 << 14)
52#define SPMODE_CG(x) ((x) << 7)
52 53
53/* 54/*
54 * Default for SPI Mode: 55 * Default for SPI Mode:
@@ -67,10 +68,6 @@ struct mpc83xx_spi_reg {
67 68
68/* SPI Controller driver's private data. */ 69/* SPI Controller driver's private data. */
69struct mpc83xx_spi { 70struct mpc83xx_spi {
70 /* bitbang has to be first */
71 struct spi_bitbang bitbang;
72 struct completion done;
73
74 struct mpc83xx_spi_reg __iomem *base; 71 struct mpc83xx_spi_reg __iomem *base;
75 72
76 /* rx & tx bufs from the spi_transfer */ 73 /* rx & tx bufs from the spi_transfer */
@@ -82,7 +79,7 @@ struct mpc83xx_spi {
82 u32(*get_tx) (struct mpc83xx_spi *); 79 u32(*get_tx) (struct mpc83xx_spi *);
83 80
84 unsigned int count; 81 unsigned int count;
85 u32 irq; 82 int irq;
86 83
87 unsigned nsecs; /* (clock cycle time)/2 */ 84 unsigned nsecs; /* (clock cycle time)/2 */
88 85
@@ -94,6 +91,25 @@ struct mpc83xx_spi {
94 91
95 void (*activate_cs) (u8 cs, u8 polarity); 92 void (*activate_cs) (u8 cs, u8 polarity);
96 void (*deactivate_cs) (u8 cs, u8 polarity); 93 void (*deactivate_cs) (u8 cs, u8 polarity);
94
95 u8 busy;
96
97 struct workqueue_struct *workqueue;
98 struct work_struct work;
99
100 struct list_head queue;
101 spinlock_t lock;
102
103 struct completion done;
104};
105
106struct spi_mpc83xx_cs {
107 /* functions to deal with different sized buffers */
108 void (*get_rx) (u32 rx_data, struct mpc83xx_spi *);
109 u32 (*get_tx) (struct mpc83xx_spi *);
110 u32 rx_shift; /* RX data reg shift when in qe mode */
111 u32 tx_shift; /* TX data reg shift when in qe mode */
112 u32 hw_mode; /* Holds HW mode register settings */
97}; 113};
98 114
99static inline void mpc83xx_spi_write_reg(__be32 __iomem * reg, u32 val) 115static inline void mpc83xx_spi_write_reg(__be32 __iomem * reg, u32 val)
@@ -137,6 +153,7 @@ static void mpc83xx_spi_chipselect(struct spi_device *spi, int value)
137{ 153{
138 struct mpc83xx_spi *mpc83xx_spi; 154 struct mpc83xx_spi *mpc83xx_spi;
139 u8 pol = spi->mode & SPI_CS_HIGH ? 1 : 0; 155 u8 pol = spi->mode & SPI_CS_HIGH ? 1 : 0;
156 struct spi_mpc83xx_cs *cs = spi->controller_state;
140 157
141 mpc83xx_spi = spi_master_get_devdata(spi->master); 158 mpc83xx_spi = spi_master_get_devdata(spi->master);
142 159
@@ -147,50 +164,26 @@ static void mpc83xx_spi_chipselect(struct spi_device *spi, int value)
147 164
148 if (value == BITBANG_CS_ACTIVE) { 165 if (value == BITBANG_CS_ACTIVE) {
149 u32 regval = mpc83xx_spi_read_reg(&mpc83xx_spi->base->mode); 166 u32 regval = mpc83xx_spi_read_reg(&mpc83xx_spi->base->mode);
150 u32 len = spi->bits_per_word;
151 u8 pm;
152 167
153 if (len == 32) 168 mpc83xx_spi->rx_shift = cs->rx_shift;
154 len = 0; 169 mpc83xx_spi->tx_shift = cs->tx_shift;
155 else 170 mpc83xx_spi->get_rx = cs->get_rx;
156 len = len - 1; 171 mpc83xx_spi->get_tx = cs->get_tx;
157 172
158 /* mask out bits we are going to set */ 173 if (cs->hw_mode != regval) {
159 regval &= ~(SPMODE_CP_BEGIN_EDGECLK | SPMODE_CI_INACTIVEHIGH 174 unsigned long flags;
160 | SPMODE_LEN(0xF) | SPMODE_DIV16 175 void *tmp_ptr = &mpc83xx_spi->base->mode;
161 | SPMODE_PM(0xF) | SPMODE_REV | SPMODE_LOOP); 176
162 177 regval = cs->hw_mode;
163 if (spi->mode & SPI_CPHA) 178 /* Turn off IRQs locally to minimize time that
164 regval |= SPMODE_CP_BEGIN_EDGECLK; 179 * SPI is disabled
165 if (spi->mode & SPI_CPOL) 180 */
166 regval |= SPMODE_CI_INACTIVEHIGH; 181 local_irq_save(flags);
167 if (!(spi->mode & SPI_LSB_FIRST)) 182 /* Turn off SPI unit prior changing mode */
168 regval |= SPMODE_REV; 183 mpc83xx_spi_write_reg(tmp_ptr, regval & ~SPMODE_ENABLE);
169 if (spi->mode & SPI_LOOP) 184 mpc83xx_spi_write_reg(tmp_ptr, regval);
170 regval |= SPMODE_LOOP; 185 local_irq_restore(flags);
171
172 regval |= SPMODE_LEN(len);
173
174 if ((mpc83xx_spi->spibrg / spi->max_speed_hz) >= 64) {
175 pm = mpc83xx_spi->spibrg / (spi->max_speed_hz * 64) - 1;
176 if (pm > 0x0f) {
177 dev_err(&spi->dev, "Requested speed is too "
178 "low: %d Hz. Will use %d Hz instead.\n",
179 spi->max_speed_hz,
180 mpc83xx_spi->spibrg / 1024);
181 pm = 0x0f;
182 }
183 regval |= SPMODE_PM(pm) | SPMODE_DIV16;
184 } else {
185 pm = mpc83xx_spi->spibrg / (spi->max_speed_hz * 4);
186 if (pm)
187 pm--;
188 regval |= SPMODE_PM(pm);
189 } 186 }
190
191 /* Turn off SPI unit prior changing mode */
192 mpc83xx_spi_write_reg(&mpc83xx_spi->base->mode, 0);
193 mpc83xx_spi_write_reg(&mpc83xx_spi->base->mode, regval);
194 if (mpc83xx_spi->activate_cs) 187 if (mpc83xx_spi->activate_cs)
195 mpc83xx_spi->activate_cs(spi->chip_select, pol); 188 mpc83xx_spi->activate_cs(spi->chip_select, pol);
196 } 189 }
@@ -201,8 +194,9 @@ int mpc83xx_spi_setup_transfer(struct spi_device *spi, struct spi_transfer *t)
201{ 194{
202 struct mpc83xx_spi *mpc83xx_spi; 195 struct mpc83xx_spi *mpc83xx_spi;
203 u32 regval; 196 u32 regval;
204 u8 bits_per_word; 197 u8 bits_per_word, pm;
205 u32 hz; 198 u32 hz;
199 struct spi_mpc83xx_cs *cs = spi->controller_state;
206 200
207 mpc83xx_spi = spi_master_get_devdata(spi->master); 201 mpc83xx_spi = spi_master_get_devdata(spi->master);
208 202
@@ -223,61 +217,191 @@ int mpc83xx_spi_setup_transfer(struct spi_device *spi, struct spi_transfer *t)
223 || ((bits_per_word > 16) && (bits_per_word != 32))) 217 || ((bits_per_word > 16) && (bits_per_word != 32)))
224 return -EINVAL; 218 return -EINVAL;
225 219
226 mpc83xx_spi->rx_shift = 0; 220 if (!hz)
227 mpc83xx_spi->tx_shift = 0; 221 hz = spi->max_speed_hz;
222
223 cs->rx_shift = 0;
224 cs->tx_shift = 0;
228 if (bits_per_word <= 8) { 225 if (bits_per_word <= 8) {
229 mpc83xx_spi->get_rx = mpc83xx_spi_rx_buf_u8; 226 cs->get_rx = mpc83xx_spi_rx_buf_u8;
230 mpc83xx_spi->get_tx = mpc83xx_spi_tx_buf_u8; 227 cs->get_tx = mpc83xx_spi_tx_buf_u8;
231 if (mpc83xx_spi->qe_mode) { 228 if (mpc83xx_spi->qe_mode) {
232 mpc83xx_spi->rx_shift = 16; 229 cs->rx_shift = 16;
233 mpc83xx_spi->tx_shift = 24; 230 cs->tx_shift = 24;
234 } 231 }
235 } else if (bits_per_word <= 16) { 232 } else if (bits_per_word <= 16) {
236 mpc83xx_spi->get_rx = mpc83xx_spi_rx_buf_u16; 233 cs->get_rx = mpc83xx_spi_rx_buf_u16;
237 mpc83xx_spi->get_tx = mpc83xx_spi_tx_buf_u16; 234 cs->get_tx = mpc83xx_spi_tx_buf_u16;
238 if (mpc83xx_spi->qe_mode) { 235 if (mpc83xx_spi->qe_mode) {
239 mpc83xx_spi->rx_shift = 16; 236 cs->rx_shift = 16;
240 mpc83xx_spi->tx_shift = 16; 237 cs->tx_shift = 16;
241 } 238 }
242 } else if (bits_per_word <= 32) { 239 } else if (bits_per_word <= 32) {
243 mpc83xx_spi->get_rx = mpc83xx_spi_rx_buf_u32; 240 cs->get_rx = mpc83xx_spi_rx_buf_u32;
244 mpc83xx_spi->get_tx = mpc83xx_spi_tx_buf_u32; 241 cs->get_tx = mpc83xx_spi_tx_buf_u32;
245 } else 242 } else
246 return -EINVAL; 243 return -EINVAL;
247 244
248 if (mpc83xx_spi->qe_mode && spi->mode & SPI_LSB_FIRST) { 245 if (mpc83xx_spi->qe_mode && spi->mode & SPI_LSB_FIRST) {
249 mpc83xx_spi->tx_shift = 0; 246 cs->tx_shift = 0;
250 if (bits_per_word <= 8) 247 if (bits_per_word <= 8)
251 mpc83xx_spi->rx_shift = 8; 248 cs->rx_shift = 8;
252 else 249 else
253 mpc83xx_spi->rx_shift = 0; 250 cs->rx_shift = 0;
254 } 251 }
255 252
256 /* nsecs = (clock period)/2 */ 253 mpc83xx_spi->rx_shift = cs->rx_shift;
257 if (!hz) 254 mpc83xx_spi->tx_shift = cs->tx_shift;
258 hz = spi->max_speed_hz; 255 mpc83xx_spi->get_rx = cs->get_rx;
259 mpc83xx_spi->nsecs = (1000000000 / 2) / hz; 256 mpc83xx_spi->get_tx = cs->get_tx;
260 if (mpc83xx_spi->nsecs > MAX_UDELAY_MS * 1000)
261 return -EINVAL;
262 257
263 if (bits_per_word == 32) 258 if (bits_per_word == 32)
264 bits_per_word = 0; 259 bits_per_word = 0;
265 else 260 else
266 bits_per_word = bits_per_word - 1; 261 bits_per_word = bits_per_word - 1;
267 262
268 regval = mpc83xx_spi_read_reg(&mpc83xx_spi->base->mode);
269
270 /* mask out bits we are going to set */ 263 /* mask out bits we are going to set */
271 regval &= ~(SPMODE_LEN(0xF) | SPMODE_REV); 264 cs->hw_mode &= ~(SPMODE_LEN(0xF) | SPMODE_DIV16
272 regval |= SPMODE_LEN(bits_per_word); 265 | SPMODE_PM(0xF));
273 if (!(spi->mode & SPI_LSB_FIRST)) 266
274 regval |= SPMODE_REV; 267 cs->hw_mode |= SPMODE_LEN(bits_per_word);
268
269 if ((mpc83xx_spi->spibrg / hz) >= 64) {
270 pm = mpc83xx_spi->spibrg / (hz * 64) - 1;
271 if (pm > 0x0f) {
272 dev_err(&spi->dev, "Requested speed is too "
273 "low: %d Hz. Will use %d Hz instead.\n",
274 hz, mpc83xx_spi->spibrg / 1024);
275 pm = 0x0f;
276 }
277 cs->hw_mode |= SPMODE_PM(pm) | SPMODE_DIV16;
278 } else {
279 pm = mpc83xx_spi->spibrg / (hz * 4);
280 if (pm)
281 pm--;
282 cs->hw_mode |= SPMODE_PM(pm);
283 }
284 regval = mpc83xx_spi_read_reg(&mpc83xx_spi->base->mode);
285 if (cs->hw_mode != regval) {
286 unsigned long flags;
287 void *tmp_ptr = &mpc83xx_spi->base->mode;
288
289 regval = cs->hw_mode;
290 /* Turn off IRQs locally to minimize time
291 * that SPI is disabled
292 */
293 local_irq_save(flags);
294 /* Turn off SPI unit prior changing mode */
295 mpc83xx_spi_write_reg(tmp_ptr, regval & ~SPMODE_ENABLE);
296 mpc83xx_spi_write_reg(tmp_ptr, regval);
297 local_irq_restore(flags);
298 }
299 return 0;
300}
275 301
276 /* Turn off SPI unit prior changing mode */ 302static int mpc83xx_spi_bufs(struct spi_device *spi, struct spi_transfer *t)
277 mpc83xx_spi_write_reg(&mpc83xx_spi->base->mode, 0); 303{
278 mpc83xx_spi_write_reg(&mpc83xx_spi->base->mode, regval); 304 struct mpc83xx_spi *mpc83xx_spi;
305 u32 word, len, bits_per_word;
279 306
280 return 0; 307 mpc83xx_spi = spi_master_get_devdata(spi->master);
308
309 mpc83xx_spi->tx = t->tx_buf;
310 mpc83xx_spi->rx = t->rx_buf;
311 bits_per_word = spi->bits_per_word;
312 if (t->bits_per_word)
313 bits_per_word = t->bits_per_word;
314 len = t->len;
315 if (bits_per_word > 8)
316 len /= 2;
317 if (bits_per_word > 16)
318 len /= 2;
319 mpc83xx_spi->count = len;
320 INIT_COMPLETION(mpc83xx_spi->done);
321
322 /* enable rx ints */
323 mpc83xx_spi_write_reg(&mpc83xx_spi->base->mask, SPIM_NE);
324
325 /* transmit word */
326 word = mpc83xx_spi->get_tx(mpc83xx_spi);
327 mpc83xx_spi_write_reg(&mpc83xx_spi->base->transmit, word);
328
329 wait_for_completion(&mpc83xx_spi->done);
330
331 /* disable rx ints */
332 mpc83xx_spi_write_reg(&mpc83xx_spi->base->mask, 0);
333
334 return mpc83xx_spi->count;
335}
336
337static void mpc83xx_spi_work(struct work_struct *work)
338{
339 struct mpc83xx_spi *mpc83xx_spi =
340 container_of(work, struct mpc83xx_spi, work);
341
342 spin_lock_irq(&mpc83xx_spi->lock);
343 mpc83xx_spi->busy = 1;
344 while (!list_empty(&mpc83xx_spi->queue)) {
345 struct spi_message *m;
346 struct spi_device *spi;
347 struct spi_transfer *t = NULL;
348 unsigned cs_change;
349 int status, nsecs = 50;
350
351 m = container_of(mpc83xx_spi->queue.next,
352 struct spi_message, queue);
353 list_del_init(&m->queue);
354 spin_unlock_irq(&mpc83xx_spi->lock);
355
356 spi = m->spi;
357 cs_change = 1;
358 status = 0;
359 list_for_each_entry(t, &m->transfers, transfer_list) {
360 if (t->bits_per_word || t->speed_hz) {
361 /* Don't allow changes if CS is active */
362 status = -EINVAL;
363
364 if (cs_change)
365 status = mpc83xx_spi_setup_transfer(spi, t);
366 if (status < 0)
367 break;
368 }
369
370 if (cs_change)
371 mpc83xx_spi_chipselect(spi, BITBANG_CS_ACTIVE);
372 cs_change = t->cs_change;
373 if (t->len)
374 status = mpc83xx_spi_bufs(spi, t);
375 if (status) {
376 status = -EMSGSIZE;
377 break;
378 }
379 m->actual_length += t->len;
380
381 if (t->delay_usecs)
382 udelay(t->delay_usecs);
383
384 if (cs_change) {
385 ndelay(nsecs);
386 mpc83xx_spi_chipselect(spi, BITBANG_CS_INACTIVE);
387 ndelay(nsecs);
388 }
389 }
390
391 m->status = status;
392 m->complete(m->context);
393
394 if (status || !cs_change) {
395 ndelay(nsecs);
396 mpc83xx_spi_chipselect(spi, BITBANG_CS_INACTIVE);
397 }
398
399 mpc83xx_spi_setup_transfer(spi, NULL);
400
401 spin_lock_irq(&mpc83xx_spi->lock);
402 }
403 mpc83xx_spi->busy = 0;
404 spin_unlock_irq(&mpc83xx_spi->lock);
281} 405}
282 406
283/* the spi->mode bits understood by this driver: */ 407/* the spi->mode bits understood by this driver: */
@@ -286,9 +410,10 @@ int mpc83xx_spi_setup_transfer(struct spi_device *spi, struct spi_transfer *t)
286 410
287static int mpc83xx_spi_setup(struct spi_device *spi) 411static int mpc83xx_spi_setup(struct spi_device *spi)
288{ 412{
289 struct spi_bitbang *bitbang;
290 struct mpc83xx_spi *mpc83xx_spi; 413 struct mpc83xx_spi *mpc83xx_spi;
291 int retval; 414 int retval;
415 u32 hw_mode;
416 struct spi_mpc83xx_cs *cs = spi->controller_state;
292 417
293 if (spi->mode & ~MODEBITS) { 418 if (spi->mode & ~MODEBITS) {
294 dev_dbg(&spi->dev, "setup: unsupported mode bits %x\n", 419 dev_dbg(&spi->dev, "setup: unsupported mode bits %x\n",
@@ -299,63 +424,56 @@ static int mpc83xx_spi_setup(struct spi_device *spi)
299 if (!spi->max_speed_hz) 424 if (!spi->max_speed_hz)
300 return -EINVAL; 425 return -EINVAL;
301 426
302 bitbang = spi_master_get_devdata(spi->master); 427 if (!cs) {
428 cs = kzalloc(sizeof *cs, GFP_KERNEL);
429 if (!cs)
430 return -ENOMEM;
431 spi->controller_state = cs;
432 }
303 mpc83xx_spi = spi_master_get_devdata(spi->master); 433 mpc83xx_spi = spi_master_get_devdata(spi->master);
304 434
305 if (!spi->bits_per_word) 435 if (!spi->bits_per_word)
306 spi->bits_per_word = 8; 436 spi->bits_per_word = 8;
307 437
438 hw_mode = cs->hw_mode; /* Save orginal settings */
439 cs->hw_mode = mpc83xx_spi_read_reg(&mpc83xx_spi->base->mode);
440 /* mask out bits we are going to set */
441 cs->hw_mode &= ~(SPMODE_CP_BEGIN_EDGECLK | SPMODE_CI_INACTIVEHIGH
442 | SPMODE_REV | SPMODE_LOOP);
443
444 if (spi->mode & SPI_CPHA)
445 cs->hw_mode |= SPMODE_CP_BEGIN_EDGECLK;
446 if (spi->mode & SPI_CPOL)
447 cs->hw_mode |= SPMODE_CI_INACTIVEHIGH;
448 if (!(spi->mode & SPI_LSB_FIRST))
449 cs->hw_mode |= SPMODE_REV;
450 if (spi->mode & SPI_LOOP)
451 cs->hw_mode |= SPMODE_LOOP;
452
308 retval = mpc83xx_spi_setup_transfer(spi, NULL); 453 retval = mpc83xx_spi_setup_transfer(spi, NULL);
309 if (retval < 0) 454 if (retval < 0) {
455 cs->hw_mode = hw_mode; /* Restore settings */
310 return retval; 456 return retval;
457 }
311 458
312 dev_dbg(&spi->dev, "%s, mode %d, %u bits/w, %u nsec\n", 459 dev_dbg(&spi->dev, "%s, mode %d, %u bits/w, %u Hz\n",
313 __func__, spi->mode & (SPI_CPOL | SPI_CPHA), 460 __func__, spi->mode & (SPI_CPOL | SPI_CPHA),
314 spi->bits_per_word, 2 * mpc83xx_spi->nsecs); 461 spi->bits_per_word, spi->max_speed_hz);
315 462#if 0 /* Don't think this is needed */
316 /* NOTE we _need_ to call chipselect() early, ideally with adapter 463 /* NOTE we _need_ to call chipselect() early, ideally with adapter
317 * setup, unless the hardware defaults cooperate to avoid confusion 464 * setup, unless the hardware defaults cooperate to avoid confusion
318 * between normal (active low) and inverted chipselects. 465 * between normal (active low) and inverted chipselects.
319 */ 466 */
320 467
321 /* deselect chip (low or high) */ 468 /* deselect chip (low or high) */
322 spin_lock(&bitbang->lock); 469 spin_lock(&mpc83xx_spi->lock);
323 if (!bitbang->busy) { 470 if (!mpc83xx_spi->busy)
324 bitbang->chipselect(spi, BITBANG_CS_INACTIVE); 471 mpc83xx_spi_chipselect(spi, BITBANG_CS_INACTIVE);
325 ndelay(mpc83xx_spi->nsecs); 472 spin_unlock(&mpc83xx_spi->lock);
326 } 473#endif
327 spin_unlock(&bitbang->lock);
328
329 return 0; 474 return 0;
330} 475}
331 476
332static int mpc83xx_spi_bufs(struct spi_device *spi, struct spi_transfer *t)
333{
334 struct mpc83xx_spi *mpc83xx_spi;
335 u32 word;
336
337 mpc83xx_spi = spi_master_get_devdata(spi->master);
338
339 mpc83xx_spi->tx = t->tx_buf;
340 mpc83xx_spi->rx = t->rx_buf;
341 mpc83xx_spi->count = t->len;
342 INIT_COMPLETION(mpc83xx_spi->done);
343
344 /* enable rx ints */
345 mpc83xx_spi_write_reg(&mpc83xx_spi->base->mask, SPIM_NE);
346
347 /* transmit word */
348 word = mpc83xx_spi->get_tx(mpc83xx_spi);
349 mpc83xx_spi_write_reg(&mpc83xx_spi->base->transmit, word);
350
351 wait_for_completion(&mpc83xx_spi->done);
352
353 /* disable rx ints */
354 mpc83xx_spi_write_reg(&mpc83xx_spi->base->mask, 0);
355
356 return t->len - mpc83xx_spi->count;
357}
358
359irqreturn_t mpc83xx_spi_irq(s32 irq, void *context_data) 477irqreturn_t mpc83xx_spi_irq(s32 irq, void *context_data)
360{ 478{
361 struct mpc83xx_spi *mpc83xx_spi = context_data; 479 struct mpc83xx_spi *mpc83xx_spi = context_data;
@@ -395,6 +513,28 @@ irqreturn_t mpc83xx_spi_irq(s32 irq, void *context_data)
395 513
396 return ret; 514 return ret;
397} 515}
516static int mpc83xx_spi_transfer(struct spi_device *spi,
517 struct spi_message *m)
518{
519 struct mpc83xx_spi *mpc83xx_spi = spi_master_get_devdata(spi->master);
520 unsigned long flags;
521
522 m->actual_length = 0;
523 m->status = -EINPROGRESS;
524
525 spin_lock_irqsave(&mpc83xx_spi->lock, flags);
526 list_add_tail(&m->queue, &mpc83xx_spi->queue);
527 queue_work(mpc83xx_spi->workqueue, &mpc83xx_spi->work);
528 spin_unlock_irqrestore(&mpc83xx_spi->lock, flags);
529
530 return 0;
531}
532
533
534static void mpc83xx_spi_cleanup(struct spi_device *spi)
535{
536 kfree(spi->controller_state);
537}
398 538
399static int __init mpc83xx_spi_probe(struct platform_device *dev) 539static int __init mpc83xx_spi_probe(struct platform_device *dev)
400{ 540{
@@ -426,11 +566,11 @@ static int __init mpc83xx_spi_probe(struct platform_device *dev)
426 ret = -ENODEV; 566 ret = -ENODEV;
427 goto free_master; 567 goto free_master;
428 } 568 }
569 master->setup = mpc83xx_spi_setup;
570 master->transfer = mpc83xx_spi_transfer;
571 master->cleanup = mpc83xx_spi_cleanup;
572
429 mpc83xx_spi = spi_master_get_devdata(master); 573 mpc83xx_spi = spi_master_get_devdata(master);
430 mpc83xx_spi->bitbang.master = spi_master_get(master);
431 mpc83xx_spi->bitbang.chipselect = mpc83xx_spi_chipselect;
432 mpc83xx_spi->bitbang.setup_transfer = mpc83xx_spi_setup_transfer;
433 mpc83xx_spi->bitbang.txrx_bufs = mpc83xx_spi_bufs;
434 mpc83xx_spi->activate_cs = pdata->activate_cs; 574 mpc83xx_spi->activate_cs = pdata->activate_cs;
435 mpc83xx_spi->deactivate_cs = pdata->deactivate_cs; 575 mpc83xx_spi->deactivate_cs = pdata->deactivate_cs;
436 mpc83xx_spi->qe_mode = pdata->qe_mode; 576 mpc83xx_spi->qe_mode = pdata->qe_mode;
@@ -445,7 +585,6 @@ static int __init mpc83xx_spi_probe(struct platform_device *dev)
445 mpc83xx_spi->tx_shift = 24; 585 mpc83xx_spi->tx_shift = 24;
446 } 586 }
447 587
448 mpc83xx_spi->bitbang.master->setup = mpc83xx_spi_setup;
449 init_completion(&mpc83xx_spi->done); 588 init_completion(&mpc83xx_spi->done);
450 589
451 mpc83xx_spi->base = ioremap(r->start, r->end - r->start + 1); 590 mpc83xx_spi->base = ioremap(r->start, r->end - r->start + 1);
@@ -483,11 +622,21 @@ static int __init mpc83xx_spi_probe(struct platform_device *dev)
483 regval |= SPMODE_OP; 622 regval |= SPMODE_OP;
484 623
485 mpc83xx_spi_write_reg(&mpc83xx_spi->base->mode, regval); 624 mpc83xx_spi_write_reg(&mpc83xx_spi->base->mode, regval);
625 spin_lock_init(&mpc83xx_spi->lock);
626 init_completion(&mpc83xx_spi->done);
627 INIT_WORK(&mpc83xx_spi->work, mpc83xx_spi_work);
628 INIT_LIST_HEAD(&mpc83xx_spi->queue);
486 629
487 ret = spi_bitbang_start(&mpc83xx_spi->bitbang); 630 mpc83xx_spi->workqueue = create_singlethread_workqueue(
488 631 master->dev.parent->bus_id);
489 if (ret != 0) 632 if (mpc83xx_spi->workqueue == NULL) {
633 ret = -EBUSY;
490 goto free_irq; 634 goto free_irq;
635 }
636
637 ret = spi_register_master(master);
638 if (ret < 0)
639 goto unreg_master;
491 640
492 printk(KERN_INFO 641 printk(KERN_INFO
493 "%s: MPC83xx SPI Controller driver at 0x%p (irq = %d)\n", 642 "%s: MPC83xx SPI Controller driver at 0x%p (irq = %d)\n",
@@ -495,6 +644,8 @@ static int __init mpc83xx_spi_probe(struct platform_device *dev)
495 644
496 return ret; 645 return ret;
497 646
647unreg_master:
648 destroy_workqueue(mpc83xx_spi->workqueue);
498free_irq: 649free_irq:
499 free_irq(mpc83xx_spi->irq, mpc83xx_spi); 650 free_irq(mpc83xx_spi->irq, mpc83xx_spi);
500unmap_io: 651unmap_io:
@@ -515,10 +666,12 @@ static int __exit mpc83xx_spi_remove(struct platform_device *dev)
515 master = platform_get_drvdata(dev); 666 master = platform_get_drvdata(dev);
516 mpc83xx_spi = spi_master_get_devdata(master); 667 mpc83xx_spi = spi_master_get_devdata(master);
517 668
518 spi_bitbang_stop(&mpc83xx_spi->bitbang); 669 flush_workqueue(mpc83xx_spi->workqueue);
670 destroy_workqueue(mpc83xx_spi->workqueue);
671 spi_unregister_master(master);
672
519 free_irq(mpc83xx_spi->irq, mpc83xx_spi); 673 free_irq(mpc83xx_spi->irq, mpc83xx_spi);
520 iounmap(mpc83xx_spi->base); 674 iounmap(mpc83xx_spi->base);
521 spi_master_put(mpc83xx_spi->bitbang.master);
522 675
523 return 0; 676 return 0;
524} 677}
diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c
index cefe7f2c6f75..63c34043b4d9 100644
--- a/drivers/usb/class/cdc-acm.c
+++ b/drivers/usb/class/cdc-acm.c
@@ -1248,6 +1248,9 @@ static struct usb_device_id acm_ids[] = {
1248 { USB_DEVICE(0x22b8, 0x7000), /* Motorola Q Phone */ 1248 { USB_DEVICE(0x22b8, 0x7000), /* Motorola Q Phone */
1249 .driver_info = NO_UNION_NORMAL, /* has no union descriptor */ 1249 .driver_info = NO_UNION_NORMAL, /* has no union descriptor */
1250 }, 1250 },
1251 { USB_DEVICE(0x0803, 0x3095), /* Zoom Telephonics Model 3095F USB MODEM */
1252 .driver_info = NO_UNION_NORMAL, /* has no union descriptor */
1253 },
1251 1254
1252 /* control interfaces with various AT-command sets */ 1255 /* control interfaces with various AT-command sets */
1253 { USB_INTERFACE_INFO(USB_CLASS_COMM, USB_CDC_SUBCLASS_ACM, 1256 { USB_INTERFACE_INFO(USB_CLASS_COMM, USB_CDC_SUBCLASS_ACM,
diff --git a/drivers/usb/core/endpoint.c b/drivers/usb/core/endpoint.c
index 99e5a68a3f12..fae55a31e26d 100644
--- a/drivers/usb/core/endpoint.c
+++ b/drivers/usb/core/endpoint.c
@@ -156,6 +156,10 @@ static struct attribute *ep_dev_attrs[] = {
156static struct attribute_group ep_dev_attr_grp = { 156static struct attribute_group ep_dev_attr_grp = {
157 .attrs = ep_dev_attrs, 157 .attrs = ep_dev_attrs,
158}; 158};
159static struct attribute_group *ep_dev_groups[] = {
160 &ep_dev_attr_grp,
161 NULL
162};
159 163
160static int usb_endpoint_major_init(void) 164static int usb_endpoint_major_init(void)
161{ 165{
@@ -298,6 +302,7 @@ int usb_create_ep_files(struct device *parent,
298 302
299 ep_dev->desc = &endpoint->desc; 303 ep_dev->desc = &endpoint->desc;
300 ep_dev->udev = udev; 304 ep_dev->udev = udev;
305 ep_dev->dev.groups = ep_dev_groups;
301 ep_dev->dev.devt = MKDEV(usb_endpoint_major, ep_dev->minor); 306 ep_dev->dev.devt = MKDEV(usb_endpoint_major, ep_dev->minor);
302 ep_dev->dev.class = ep_class->class; 307 ep_dev->dev.class = ep_class->class;
303 ep_dev->dev.parent = parent; 308 ep_dev->dev.parent = parent;
@@ -309,9 +314,6 @@ int usb_create_ep_files(struct device *parent,
309 retval = device_register(&ep_dev->dev); 314 retval = device_register(&ep_dev->dev);
310 if (retval) 315 if (retval)
311 goto error_chrdev; 316 goto error_chrdev;
312 retval = sysfs_create_group(&ep_dev->dev.kobj, &ep_dev_attr_grp);
313 if (retval)
314 goto error_group;
315 317
316 /* create the symlink to the old-style "ep_XX" directory */ 318 /* create the symlink to the old-style "ep_XX" directory */
317 sprintf(name, "ep_%02x", endpoint->desc.bEndpointAddress); 319 sprintf(name, "ep_%02x", endpoint->desc.bEndpointAddress);
@@ -322,8 +324,6 @@ int usb_create_ep_files(struct device *parent,
322 return retval; 324 return retval;
323 325
324error_link: 326error_link:
325 sysfs_remove_group(&ep_dev->dev.kobj, &ep_dev_attr_grp);
326error_group:
327 device_unregister(&ep_dev->dev); 327 device_unregister(&ep_dev->dev);
328 destroy_endpoint_class(); 328 destroy_endpoint_class();
329 return retval; 329 return retval;
@@ -348,7 +348,6 @@ void usb_remove_ep_files(struct usb_host_endpoint *endpoint)
348 348
349 sprintf(name, "ep_%02x", endpoint->desc.bEndpointAddress); 349 sprintf(name, "ep_%02x", endpoint->desc.bEndpointAddress);
350 sysfs_remove_link(&ep_dev->dev.parent->kobj, name); 350 sysfs_remove_link(&ep_dev->dev.parent->kobj, name);
351 sysfs_remove_group(&ep_dev->dev.kobj, &ep_dev_attr_grp);
352 device_unregister(&ep_dev->dev); 351 device_unregister(&ep_dev->dev);
353 endpoint->ep_dev = NULL; 352 endpoint->ep_dev = NULL;
354 destroy_endpoint_class(); 353 destroy_endpoint_class();
diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c
index 3e69266e1f4d..fe47d145255a 100644
--- a/drivers/usb/core/message.c
+++ b/drivers/usb/core/message.c
@@ -1607,6 +1607,7 @@ free_interfaces:
1607 intf->dev.driver = NULL; 1607 intf->dev.driver = NULL;
1608 intf->dev.bus = &usb_bus_type; 1608 intf->dev.bus = &usb_bus_type;
1609 intf->dev.type = &usb_if_device_type; 1609 intf->dev.type = &usb_if_device_type;
1610 intf->dev.groups = usb_interface_groups;
1610 intf->dev.dma_mask = dev->dev.dma_mask; 1611 intf->dev.dma_mask = dev->dev.dma_mask;
1611 device_initialize(&intf->dev); 1612 device_initialize(&intf->dev);
1612 mark_quiesced(intf); 1613 mark_quiesced(intf);
diff --git a/drivers/usb/core/sysfs.c b/drivers/usb/core/sysfs.c
index 5b20a60de8ba..c783cb111847 100644
--- a/drivers/usb/core/sysfs.c
+++ b/drivers/usb/core/sysfs.c
@@ -538,6 +538,46 @@ static struct attribute_group dev_attr_grp = {
538 .attrs = dev_attrs, 538 .attrs = dev_attrs,
539}; 539};
540 540
541/* When modifying this list, be sure to modify dev_string_attrs_are_visible()
542 * accordingly.
543 */
544static struct attribute *dev_string_attrs[] = {
545 &dev_attr_manufacturer.attr,
546 &dev_attr_product.attr,
547 &dev_attr_serial.attr,
548 NULL
549};
550
551static mode_t dev_string_attrs_are_visible(struct kobject *kobj,
552 struct attribute *a, int n)
553{
554 struct usb_device *udev = to_usb_device(
555 container_of(kobj, struct device, kobj));
556
557 if (a == &dev_attr_manufacturer.attr) {
558 if (udev->manufacturer == NULL)
559 return 0;
560 } else if (a == &dev_attr_product.attr) {
561 if (udev->product == NULL)
562 return 0;
563 } else if (a == &dev_attr_serial.attr) {
564 if (udev->serial == NULL)
565 return 0;
566 }
567 return a->mode;
568}
569
570static struct attribute_group dev_string_attr_grp = {
571 .attrs = dev_string_attrs,
572 .is_visible = dev_string_attrs_are_visible,
573};
574
575struct attribute_group *usb_device_groups[] = {
576 &dev_attr_grp,
577 &dev_string_attr_grp,
578 NULL
579};
580
541/* Binary descriptors */ 581/* Binary descriptors */
542 582
543static ssize_t 583static ssize_t
@@ -591,10 +631,9 @@ int usb_create_sysfs_dev_files(struct usb_device *udev)
591 struct device *dev = &udev->dev; 631 struct device *dev = &udev->dev;
592 int retval; 632 int retval;
593 633
594 retval = sysfs_create_group(&dev->kobj, &dev_attr_grp); 634 /* Unforunately these attributes cannot be created before
595 if (retval) 635 * the uevent is broadcast.
596 return retval; 636 */
597
598 retval = device_create_bin_file(dev, &dev_bin_attr_descriptors); 637 retval = device_create_bin_file(dev, &dev_bin_attr_descriptors);
599 if (retval) 638 if (retval)
600 goto error; 639 goto error;
@@ -607,21 +646,6 @@ int usb_create_sysfs_dev_files(struct usb_device *udev)
607 if (retval) 646 if (retval)
608 goto error; 647 goto error;
609 648
610 if (udev->manufacturer) {
611 retval = device_create_file(dev, &dev_attr_manufacturer);
612 if (retval)
613 goto error;
614 }
615 if (udev->product) {
616 retval = device_create_file(dev, &dev_attr_product);
617 if (retval)
618 goto error;
619 }
620 if (udev->serial) {
621 retval = device_create_file(dev, &dev_attr_serial);
622 if (retval)
623 goto error;
624 }
625 retval = usb_create_ep_files(dev, &udev->ep0, udev); 649 retval = usb_create_ep_files(dev, &udev->ep0, udev);
626 if (retval) 650 if (retval)
627 goto error; 651 goto error;
@@ -636,13 +660,9 @@ void usb_remove_sysfs_dev_files(struct usb_device *udev)
636 struct device *dev = &udev->dev; 660 struct device *dev = &udev->dev;
637 661
638 usb_remove_ep_files(&udev->ep0); 662 usb_remove_ep_files(&udev->ep0);
639 device_remove_file(dev, &dev_attr_manufacturer);
640 device_remove_file(dev, &dev_attr_product);
641 device_remove_file(dev, &dev_attr_serial);
642 remove_power_attributes(dev); 663 remove_power_attributes(dev);
643 remove_persist_attributes(dev); 664 remove_persist_attributes(dev);
644 device_remove_bin_file(dev, &dev_bin_attr_descriptors); 665 device_remove_bin_file(dev, &dev_bin_attr_descriptors);
645 sysfs_remove_group(&dev->kobj, &dev_attr_grp);
646} 666}
647 667
648/* Interface Accociation Descriptor fields */ 668/* Interface Accociation Descriptor fields */
@@ -688,17 +708,15 @@ static ssize_t show_interface_string(struct device *dev,
688 struct device_attribute *attr, char *buf) 708 struct device_attribute *attr, char *buf)
689{ 709{
690 struct usb_interface *intf; 710 struct usb_interface *intf;
691 struct usb_device *udev; 711 char *string;
692 int len;
693 712
694 intf = to_usb_interface(dev); 713 intf = to_usb_interface(dev);
695 udev = interface_to_usbdev(intf); 714 string = intf->cur_altsetting->string;
696 len = snprintf(buf, 256, "%s", intf->cur_altsetting->string); 715 barrier(); /* The altsetting might change! */
697 if (len < 0) 716
717 if (!string)
698 return 0; 718 return 0;
699 buf[len] = '\n'; 719 return sprintf(buf, "%s\n", string);
700 buf[len+1] = 0;
701 return len+1;
702} 720}
703static DEVICE_ATTR(interface, S_IRUGO, show_interface_string, NULL); 721static DEVICE_ATTR(interface, S_IRUGO, show_interface_string, NULL);
704 722
@@ -727,18 +745,6 @@ static ssize_t show_modalias(struct device *dev,
727} 745}
728static DEVICE_ATTR(modalias, S_IRUGO, show_modalias, NULL); 746static DEVICE_ATTR(modalias, S_IRUGO, show_modalias, NULL);
729 747
730static struct attribute *intf_assoc_attrs[] = {
731 &dev_attr_iad_bFirstInterface.attr,
732 &dev_attr_iad_bInterfaceCount.attr,
733 &dev_attr_iad_bFunctionClass.attr,
734 &dev_attr_iad_bFunctionSubClass.attr,
735 &dev_attr_iad_bFunctionProtocol.attr,
736 NULL,
737};
738static struct attribute_group intf_assoc_attr_grp = {
739 .attrs = intf_assoc_attrs,
740};
741
742static struct attribute *intf_attrs[] = { 748static struct attribute *intf_attrs[] = {
743 &dev_attr_bInterfaceNumber.attr, 749 &dev_attr_bInterfaceNumber.attr,
744 &dev_attr_bAlternateSetting.attr, 750 &dev_attr_bAlternateSetting.attr,
@@ -753,6 +759,37 @@ static struct attribute_group intf_attr_grp = {
753 .attrs = intf_attrs, 759 .attrs = intf_attrs,
754}; 760};
755 761
762static struct attribute *intf_assoc_attrs[] = {
763 &dev_attr_iad_bFirstInterface.attr,
764 &dev_attr_iad_bInterfaceCount.attr,
765 &dev_attr_iad_bFunctionClass.attr,
766 &dev_attr_iad_bFunctionSubClass.attr,
767 &dev_attr_iad_bFunctionProtocol.attr,
768 NULL,
769};
770
771static mode_t intf_assoc_attrs_are_visible(struct kobject *kobj,
772 struct attribute *a, int n)
773{
774 struct usb_interface *intf = to_usb_interface(
775 container_of(kobj, struct device, kobj));
776
777 if (intf->intf_assoc == NULL)
778 return 0;
779 return a->mode;
780}
781
782static struct attribute_group intf_assoc_attr_grp = {
783 .attrs = intf_assoc_attrs,
784 .is_visible = intf_assoc_attrs_are_visible,
785};
786
787struct attribute_group *usb_interface_groups[] = {
788 &intf_attr_grp,
789 &intf_assoc_attr_grp,
790 NULL
791};
792
756static inline void usb_create_intf_ep_files(struct usb_interface *intf, 793static inline void usb_create_intf_ep_files(struct usb_interface *intf,
757 struct usb_device *udev) 794 struct usb_device *udev)
758{ 795{
@@ -777,23 +814,21 @@ static inline void usb_remove_intf_ep_files(struct usb_interface *intf)
777 814
778int usb_create_sysfs_intf_files(struct usb_interface *intf) 815int usb_create_sysfs_intf_files(struct usb_interface *intf)
779{ 816{
780 struct device *dev = &intf->dev;
781 struct usb_device *udev = interface_to_usbdev(intf); 817 struct usb_device *udev = interface_to_usbdev(intf);
782 struct usb_host_interface *alt = intf->cur_altsetting; 818 struct usb_host_interface *alt = intf->cur_altsetting;
783 int retval; 819 int retval;
784 820
785 if (intf->sysfs_files_created) 821 if (intf->sysfs_files_created)
786 return 0; 822 return 0;
787 retval = sysfs_create_group(&dev->kobj, &intf_attr_grp);
788 if (retval)
789 return retval;
790 823
824 /* The interface string may be present in some altsettings
825 * and missing in others. Hence its attribute cannot be created
826 * before the uevent is broadcast.
827 */
791 if (alt->string == NULL) 828 if (alt->string == NULL)
792 alt->string = usb_cache_string(udev, alt->desc.iInterface); 829 alt->string = usb_cache_string(udev, alt->desc.iInterface);
793 if (alt->string) 830 if (alt->string)
794 retval = device_create_file(dev, &dev_attr_interface); 831 retval = device_create_file(&intf->dev, &dev_attr_interface);
795 if (intf->intf_assoc)
796 retval = sysfs_create_group(&dev->kobj, &intf_assoc_attr_grp);
797 usb_create_intf_ep_files(intf, udev); 832 usb_create_intf_ep_files(intf, udev);
798 intf->sysfs_files_created = 1; 833 intf->sysfs_files_created = 1;
799 return 0; 834 return 0;
@@ -807,7 +842,5 @@ void usb_remove_sysfs_intf_files(struct usb_interface *intf)
807 return; 842 return;
808 usb_remove_intf_ep_files(intf); 843 usb_remove_intf_ep_files(intf);
809 device_remove_file(dev, &dev_attr_interface); 844 device_remove_file(dev, &dev_attr_interface);
810 sysfs_remove_group(&dev->kobj, &intf_attr_grp);
811 sysfs_remove_group(&intf->dev.kobj, &intf_assoc_attr_grp);
812 intf->sysfs_files_created = 0; 845 intf->sysfs_files_created = 0;
813} 846}
diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c
index 1f0db51190cc..325774375837 100644
--- a/drivers/usb/core/usb.c
+++ b/drivers/usb/core/usb.c
@@ -291,6 +291,7 @@ struct usb_device *usb_alloc_dev(struct usb_device *parent,
291 device_initialize(&dev->dev); 291 device_initialize(&dev->dev);
292 dev->dev.bus = &usb_bus_type; 292 dev->dev.bus = &usb_bus_type;
293 dev->dev.type = &usb_device_type; 293 dev->dev.type = &usb_device_type;
294 dev->dev.groups = usb_device_groups;
294 dev->dev.dma_mask = bus->controller->dma_mask; 295 dev->dev.dma_mask = bus->controller->dma_mask;
295 set_dev_node(&dev->dev, dev_to_node(bus->controller)); 296 set_dev_node(&dev->dev, dev_to_node(bus->controller));
296 dev->state = USB_STATE_ATTACHED; 297 dev->state = USB_STATE_ATTACHED;
diff --git a/drivers/usb/core/usb.h b/drivers/usb/core/usb.h
index 1bf8ccb9c58d..1a8bc21c335e 100644
--- a/drivers/usb/core/usb.h
+++ b/drivers/usb/core/usb.h
@@ -130,6 +130,10 @@ static inline int is_active(const struct usb_interface *f)
130/* for labeling diagnostics */ 130/* for labeling diagnostics */
131extern const char *usbcore_name; 131extern const char *usbcore_name;
132 132
133/* sysfs stuff */
134extern struct attribute_group *usb_device_groups[];
135extern struct attribute_group *usb_interface_groups[];
136
133/* usbfs stuff */ 137/* usbfs stuff */
134extern struct mutex usbfs_mutex; 138extern struct mutex usbfs_mutex;
135extern struct usb_driver usbfs_driver; 139extern struct usb_driver usbfs_driver;
diff --git a/drivers/usb/gadget/amd5536udc.c b/drivers/usb/gadget/amd5536udc.c
index ce337cb5d137..f261d2a9a5f0 100644
--- a/drivers/usb/gadget/amd5536udc.c
+++ b/drivers/usb/gadget/amd5536udc.c
@@ -3251,7 +3251,7 @@ static int udc_pci_probe(
3251 /* pci setup */ 3251 /* pci setup */
3252 if (pci_enable_device(pdev) < 0) { 3252 if (pci_enable_device(pdev) < 0) {
3253 kfree(dev); 3253 kfree(dev);
3254 dev = 0; 3254 dev = NULL;
3255 retval = -ENODEV; 3255 retval = -ENODEV;
3256 goto finished; 3256 goto finished;
3257 } 3257 }
@@ -3264,7 +3264,7 @@ static int udc_pci_probe(
3264 if (!request_mem_region(resource, len, name)) { 3264 if (!request_mem_region(resource, len, name)) {
3265 dev_dbg(&pdev->dev, "pci device used already\n"); 3265 dev_dbg(&pdev->dev, "pci device used already\n");
3266 kfree(dev); 3266 kfree(dev);
3267 dev = 0; 3267 dev = NULL;
3268 retval = -EBUSY; 3268 retval = -EBUSY;
3269 goto finished; 3269 goto finished;
3270 } 3270 }
@@ -3274,7 +3274,7 @@ static int udc_pci_probe(
3274 if (dev->virt_addr == NULL) { 3274 if (dev->virt_addr == NULL) {
3275 dev_dbg(&pdev->dev, "start address cannot be mapped\n"); 3275 dev_dbg(&pdev->dev, "start address cannot be mapped\n");
3276 kfree(dev); 3276 kfree(dev);
3277 dev = 0; 3277 dev = NULL;
3278 retval = -EFAULT; 3278 retval = -EFAULT;
3279 goto finished; 3279 goto finished;
3280 } 3280 }
@@ -3282,7 +3282,7 @@ static int udc_pci_probe(
3282 if (!pdev->irq) { 3282 if (!pdev->irq) {
3283 dev_err(&dev->pdev->dev, "irq not set\n"); 3283 dev_err(&dev->pdev->dev, "irq not set\n");
3284 kfree(dev); 3284 kfree(dev);
3285 dev = 0; 3285 dev = NULL;
3286 retval = -ENODEV; 3286 retval = -ENODEV;
3287 goto finished; 3287 goto finished;
3288 } 3288 }
@@ -3290,7 +3290,7 @@ static int udc_pci_probe(
3290 if (request_irq(pdev->irq, udc_irq, IRQF_SHARED, name, dev) != 0) { 3290 if (request_irq(pdev->irq, udc_irq, IRQF_SHARED, name, dev) != 0) {
3291 dev_dbg(&dev->pdev->dev, "request_irq(%d) fail\n", pdev->irq); 3291 dev_dbg(&dev->pdev->dev, "request_irq(%d) fail\n", pdev->irq);
3292 kfree(dev); 3292 kfree(dev);
3293 dev = 0; 3293 dev = NULL;
3294 retval = -EBUSY; 3294 retval = -EBUSY;
3295 goto finished; 3295 goto finished;
3296 } 3296 }
diff --git a/drivers/usb/gadget/atmel_usba_udc.c b/drivers/usb/gadget/atmel_usba_udc.c
index e756023362c2..07e5a0b5dcda 100644
--- a/drivers/usb/gadget/atmel_usba_udc.c
+++ b/drivers/usb/gadget/atmel_usba_udc.c
@@ -649,7 +649,13 @@ static int usba_ep_disable(struct usb_ep *_ep)
649 649
650 if (!ep->desc) { 650 if (!ep->desc) {
651 spin_unlock_irqrestore(&udc->lock, flags); 651 spin_unlock_irqrestore(&udc->lock, flags);
652 DBG(DBG_ERR, "ep_disable: %s not enabled\n", ep->ep.name); 652 /* REVISIT because this driver disables endpoints in
653 * reset_all_endpoints() before calling disconnect(),
654 * most gadget drivers would trigger this non-error ...
655 */
656 if (udc->gadget.speed != USB_SPEED_UNKNOWN)
657 DBG(DBG_ERR, "ep_disable: %s not enabled\n",
658 ep->ep.name);
653 return -EINVAL; 659 return -EINVAL;
654 } 660 }
655 ep->desc = NULL; 661 ep->desc = NULL;
@@ -1032,8 +1038,6 @@ static struct usba_udc the_udc = {
1032 .release = nop_release, 1038 .release = nop_release,
1033 }, 1039 },
1034 }, 1040 },
1035
1036 .lock = SPIN_LOCK_UNLOCKED,
1037}; 1041};
1038 1042
1039/* 1043/*
@@ -1052,6 +1056,12 @@ static void reset_all_endpoints(struct usba_udc *udc)
1052 request_complete(ep, req, -ECONNRESET); 1056 request_complete(ep, req, -ECONNRESET);
1053 } 1057 }
1054 1058
1059 /* NOTE: normally, the next call to the gadget driver is in
1060 * charge of disabling endpoints... usually disconnect().
1061 * The exception would be entering a high speed test mode.
1062 *
1063 * FIXME remove this code ... and retest thoroughly.
1064 */
1055 list_for_each_entry(ep, &udc->gadget.ep_list, ep.ep_list) { 1065 list_for_each_entry(ep, &udc->gadget.ep_list, ep.ep_list) {
1056 if (ep->desc) { 1066 if (ep->desc) {
1057 spin_unlock(&udc->lock); 1067 spin_unlock(&udc->lock);
@@ -1219,7 +1229,7 @@ static inline bool feature_is_ep_halt(struct usb_ctrlrequest *crq)
1219static int handle_ep0_setup(struct usba_udc *udc, struct usba_ep *ep, 1229static int handle_ep0_setup(struct usba_udc *udc, struct usba_ep *ep,
1220 struct usb_ctrlrequest *crq) 1230 struct usb_ctrlrequest *crq)
1221{ 1231{
1222 int retval = 0;; 1232 int retval = 0;
1223 1233
1224 switch (crq->bRequest) { 1234 switch (crq->bRequest) {
1225 case USB_REQ_GET_STATUS: { 1235 case USB_REQ_GET_STATUS: {
@@ -1693,6 +1703,14 @@ static irqreturn_t usba_udc_irq(int irq, void *devid)
1693 usba_writel(udc, INT_CLR, USBA_END_OF_RESET); 1703 usba_writel(udc, INT_CLR, USBA_END_OF_RESET);
1694 reset_all_endpoints(udc); 1704 reset_all_endpoints(udc);
1695 1705
1706 if (udc->gadget.speed != USB_SPEED_UNKNOWN
1707 && udc->driver->disconnect) {
1708 udc->gadget.speed = USB_SPEED_UNKNOWN;
1709 spin_unlock(&udc->lock);
1710 udc->driver->disconnect(&udc->gadget);
1711 spin_lock(&udc->lock);
1712 }
1713
1696 if (status & USBA_HIGH_SPEED) { 1714 if (status & USBA_HIGH_SPEED) {
1697 DBG(DBG_BUS, "High-speed bus reset detected\n"); 1715 DBG(DBG_BUS, "High-speed bus reset detected\n");
1698 udc->gadget.speed = USB_SPEED_HIGH; 1716 udc->gadget.speed = USB_SPEED_HIGH;
@@ -1716,9 +1734,13 @@ static irqreturn_t usba_udc_irq(int irq, void *devid)
1716 | USBA_DET_SUSPEND 1734 | USBA_DET_SUSPEND
1717 | USBA_END_OF_RESUME)); 1735 | USBA_END_OF_RESUME));
1718 1736
1737 /*
1738 * Unclear why we hit this irregularly, e.g. in usbtest,
1739 * but it's clearly harmless...
1740 */
1719 if (!(usba_ep_readl(ep0, CFG) & USBA_EPT_MAPPED)) 1741 if (!(usba_ep_readl(ep0, CFG) & USBA_EPT_MAPPED))
1720 dev_warn(&udc->pdev->dev, 1742 dev_dbg(&udc->pdev->dev,
1721 "WARNING: EP0 configuration is invalid!\n"); 1743 "ODD: EP0 configuration is invalid!\n");
1722 } 1744 }
1723 1745
1724 spin_unlock(&udc->lock); 1746 spin_unlock(&udc->lock);
@@ -1751,9 +1773,11 @@ static irqreturn_t usba_vbus_irq(int irq, void *devid)
1751 reset_all_endpoints(udc); 1773 reset_all_endpoints(udc);
1752 toggle_bias(0); 1774 toggle_bias(0);
1753 usba_writel(udc, CTRL, USBA_DISABLE_MASK); 1775 usba_writel(udc, CTRL, USBA_DISABLE_MASK);
1754 spin_unlock(&udc->lock); 1776 if (udc->driver->disconnect) {
1755 udc->driver->disconnect(&udc->gadget); 1777 spin_unlock(&udc->lock);
1756 spin_lock(&udc->lock); 1778 udc->driver->disconnect(&udc->gadget);
1779 spin_lock(&udc->lock);
1780 }
1757 } 1781 }
1758 udc->vbus_prev = vbus; 1782 udc->vbus_prev = vbus;
1759 } 1783 }
@@ -1825,7 +1849,7 @@ int usb_gadget_unregister_driver(struct usb_gadget_driver *driver)
1825 1849
1826 if (!udc->pdev) 1850 if (!udc->pdev)
1827 return -ENODEV; 1851 return -ENODEV;
1828 if (driver != udc->driver) 1852 if (driver != udc->driver || !driver->unbind)
1829 return -EINVAL; 1853 return -EINVAL;
1830 1854
1831 if (udc->vbus_pin != -1) 1855 if (udc->vbus_pin != -1)
@@ -1840,6 +1864,9 @@ int usb_gadget_unregister_driver(struct usb_gadget_driver *driver)
1840 toggle_bias(0); 1864 toggle_bias(0);
1841 usba_writel(udc, CTRL, USBA_DISABLE_MASK); 1865 usba_writel(udc, CTRL, USBA_DISABLE_MASK);
1842 1866
1867 if (udc->driver->disconnect)
1868 udc->driver->disconnect(&udc->gadget);
1869
1843 driver->unbind(&udc->gadget); 1870 driver->unbind(&udc->gadget);
1844 udc->gadget.dev.driver = NULL; 1871 udc->gadget.dev.driver = NULL;
1845 udc->driver = NULL; 1872 udc->driver = NULL;
@@ -1879,6 +1906,7 @@ static int __init usba_udc_probe(struct platform_device *pdev)
1879 goto err_get_hclk; 1906 goto err_get_hclk;
1880 } 1907 }
1881 1908
1909 spin_lock_init(&udc->lock);
1882 udc->pdev = pdev; 1910 udc->pdev = pdev;
1883 udc->pclk = pclk; 1911 udc->pclk = pclk;
1884 udc->hclk = hclk; 1912 udc->hclk = hclk;
diff --git a/drivers/usb/gadget/pxa27x_udc.c b/drivers/usb/gadget/pxa27x_udc.c
index 75eba202f737..499b7a23f351 100644
--- a/drivers/usb/gadget/pxa27x_udc.c
+++ b/drivers/usb/gadget/pxa27x_udc.c
@@ -1546,7 +1546,6 @@ static __init void udc_init_data(struct pxa_udc *dev)
1546 INIT_LIST_HEAD(&dev->gadget.ep0->ep_list); 1546 INIT_LIST_HEAD(&dev->gadget.ep0->ep_list);
1547 dev->udc_usb_ep[0].pxa_ep = &dev->pxa_ep[0]; 1547 dev->udc_usb_ep[0].pxa_ep = &dev->pxa_ep[0];
1548 ep0_idle(dev); 1548 ep0_idle(dev);
1549 strcpy(dev->dev->bus_id, "");
1550 1549
1551 /* PXA endpoints init */ 1550 /* PXA endpoints init */
1552 for (i = 0; i < NR_PXA_ENDPOINTS; i++) { 1551 for (i = 0; i < NR_PXA_ENDPOINTS; i++) {
@@ -1746,13 +1745,10 @@ static void handle_ep0_ctrl_req(struct pxa_udc *udc,
1746 ep_err(ep, "wrong to have extra bytes for setup : 0x%08x\n", i); 1745 ep_err(ep, "wrong to have extra bytes for setup : 0x%08x\n", i);
1747 } 1746 }
1748 1747
1749 le16_to_cpus(&u.r.wValue);
1750 le16_to_cpus(&u.r.wIndex);
1751 le16_to_cpus(&u.r.wLength);
1752
1753 ep_dbg(ep, "SETUP %02x.%02x v%04x i%04x l%04x\n", 1748 ep_dbg(ep, "SETUP %02x.%02x v%04x i%04x l%04x\n",
1754 u.r.bRequestType, u.r.bRequest, 1749 u.r.bRequestType, u.r.bRequest,
1755 u.r.wValue, u.r.wIndex, u.r.wLength); 1750 le16_to_cpu(u.r.wValue), le16_to_cpu(u.r.wIndex),
1751 le16_to_cpu(u.r.wLength));
1756 if (unlikely(have_extrabytes)) 1752 if (unlikely(have_extrabytes))
1757 goto stall; 1753 goto stall;
1758 1754
@@ -2296,7 +2292,8 @@ static void pxa_udc_shutdown(struct platform_device *_dev)
2296{ 2292{
2297 struct pxa_udc *udc = platform_get_drvdata(_dev); 2293 struct pxa_udc *udc = platform_get_drvdata(_dev);
2298 2294
2299 udc_disable(udc); 2295 if (udc_readl(udc, UDCCR) & UDCCR_UDE)
2296 udc_disable(udc);
2300} 2297}
2301 2298
2302#ifdef CONFIG_PM 2299#ifdef CONFIG_PM
@@ -2361,9 +2358,8 @@ static int pxa_udc_resume(struct platform_device *_dev)
2361 * Upon exit from sleep mode and before clearing OTGPH, 2358 * Upon exit from sleep mode and before clearing OTGPH,
2362 * Software must configure the USB OTG pad, UDC, and UHC 2359 * Software must configure the USB OTG pad, UDC, and UHC
2363 * to the state they were in before entering sleep mode. 2360 * to the state they were in before entering sleep mode.
2364 *
2365 * Should be : PSSR |= PSSR_OTGPH;
2366 */ 2361 */
2362 PSSR |= PSSR_OTGPH;
2367 2363
2368 return 0; 2364 return 0;
2369} 2365}
@@ -2387,6 +2383,9 @@ static struct platform_driver udc_driver = {
2387 2383
2388static int __init udc_init(void) 2384static int __init udc_init(void)
2389{ 2385{
2386 if (!cpu_is_pxa27x())
2387 return -ENODEV;
2388
2390 printk(KERN_INFO "%s: version %s\n", driver_name, DRIVER_VERSION); 2389 printk(KERN_INFO "%s: version %s\n", driver_name, DRIVER_VERSION);
2391 return platform_driver_probe(&udc_driver, pxa_udc_probe); 2390 return platform_driver_probe(&udc_driver, pxa_udc_probe);
2392} 2391}
diff --git a/drivers/usb/gadget/pxa27x_udc.h b/drivers/usb/gadget/pxa27x_udc.h
index 1d1b7936ee11..97453db924ff 100644
--- a/drivers/usb/gadget/pxa27x_udc.h
+++ b/drivers/usb/gadget/pxa27x_udc.h
@@ -484,4 +484,12 @@ static inline struct pxa_udc *to_gadget_udc(struct usb_gadget *gadget)
484#define ep_warn(ep, fmt, arg...) \ 484#define ep_warn(ep, fmt, arg...) \
485 dev_warn(ep->dev->dev, "%s:%s:" fmt, EPNAME(ep), __func__, ## arg) 485 dev_warn(ep->dev->dev, "%s:%s:" fmt, EPNAME(ep), __func__, ## arg)
486 486
487/*
488 * Cannot include pxa-regs.h, as register names are similar.
489 * So PSSR is redefined here. This should be removed once UDC registers will
490 * be gone from pxa-regs.h.
491 */
492#define PSSR __REG(0x40F00004) /* Power Manager Sleep Status */
493#define PSSR_OTGPH (1 << 6) /* OTG Peripheral Hold */
494
487#endif /* __LINUX_USB_GADGET_PXA27X_H */ 495#endif /* __LINUX_USB_GADGET_PXA27X_H */
diff --git a/drivers/usb/gadget/serial.c b/drivers/usb/gadget/serial.c
index 54cdd6f94034..fa019fa73334 100644
--- a/drivers/usb/gadget/serial.c
+++ b/drivers/usb/gadget/serial.c
@@ -14,7 +14,6 @@
14 * This software is distributed under the terms of the GNU General 14 * This software is distributed under the terms of the GNU General
15 * Public License ("GPL") as published by the Free Software Foundation, 15 * Public License ("GPL") as published by the Free Software Foundation,
16 * either version 2 of that License or (at your option) any later version. 16 * either version 2 of that License or (at your option) any later version.
17 *
18 */ 17 */
19 18
20#include <linux/kernel.h> 19#include <linux/kernel.h>
@@ -33,7 +32,7 @@
33/* Defines */ 32/* Defines */
34 33
35#define GS_VERSION_STR "v2.2" 34#define GS_VERSION_STR "v2.2"
36#define GS_VERSION_NUM 0x0202 35#define GS_VERSION_NUM 0x2200
37 36
38#define GS_LONG_NAME "Gadget Serial" 37#define GS_LONG_NAME "Gadget Serial"
39#define GS_SHORT_NAME "g_serial" 38#define GS_SHORT_NAME "g_serial"
@@ -41,7 +40,11 @@
41#define GS_MAJOR 127 40#define GS_MAJOR 127
42#define GS_MINOR_START 0 41#define GS_MINOR_START 0
43 42
44#define GS_NUM_PORTS 16 43/* REVISIT only one port is supported for now;
44 * see gs_{send,recv}_packet() ... no multiplexing,
45 * and no support for multiple ACM devices.
46 */
47#define GS_NUM_PORTS 1
45 48
46#define GS_NUM_CONFIGS 1 49#define GS_NUM_CONFIGS 1
47#define GS_NO_CONFIG_ID 0 50#define GS_NO_CONFIG_ID 0
@@ -65,6 +68,9 @@
65 68
66#define GS_DEFAULT_USE_ACM 0 69#define GS_DEFAULT_USE_ACM 0
67 70
71/* 9600-8-N-1 ... matches init_termios.c_cflag and defaults
72 * expected by "usbser.sys" on MS-Windows.
73 */
68#define GS_DEFAULT_DTE_RATE 9600 74#define GS_DEFAULT_DTE_RATE 9600
69#define GS_DEFAULT_DATA_BITS 8 75#define GS_DEFAULT_DATA_BITS 8
70#define GS_DEFAULT_PARITY USB_CDC_NO_PARITY 76#define GS_DEFAULT_PARITY USB_CDC_NO_PARITY
@@ -107,10 +113,6 @@ static int debug = 1;
107#define GS_NOTIFY_MAXPACKET 8 113#define GS_NOTIFY_MAXPACKET 8
108 114
109 115
110/* Structures */
111
112struct gs_dev;
113
114/* circular buffer */ 116/* circular buffer */
115struct gs_buf { 117struct gs_buf {
116 unsigned int buf_size; 118 unsigned int buf_size;
@@ -119,12 +121,6 @@ struct gs_buf {
119 char *buf_put; 121 char *buf_put;
120}; 122};
121 123
122/* list of requests */
123struct gs_req_entry {
124 struct list_head re_entry;
125 struct usb_request *re_req;
126};
127
128/* the port structure holds info for each port, one for each minor number */ 124/* the port structure holds info for each port, one for each minor number */
129struct gs_port { 125struct gs_port {
130 struct gs_dev *port_dev; /* pointer to device struct */ 126 struct gs_dev *port_dev; /* pointer to device struct */
@@ -164,26 +160,7 @@ struct gs_dev {
164 160
165/* Functions */ 161/* Functions */
166 162
167/* module */ 163/* tty driver internals */
168static int __init gs_module_init(void);
169static void __exit gs_module_exit(void);
170
171/* tty driver */
172static int gs_open(struct tty_struct *tty, struct file *file);
173static void gs_close(struct tty_struct *tty, struct file *file);
174static int gs_write(struct tty_struct *tty,
175 const unsigned char *buf, int count);
176static int gs_put_char(struct tty_struct *tty, unsigned char ch);
177static void gs_flush_chars(struct tty_struct *tty);
178static int gs_write_room(struct tty_struct *tty);
179static int gs_chars_in_buffer(struct tty_struct *tty);
180static void gs_throttle(struct tty_struct * tty);
181static void gs_unthrottle(struct tty_struct * tty);
182static void gs_break(struct tty_struct *tty, int break_state);
183static int gs_ioctl(struct tty_struct *tty, struct file *file,
184 unsigned int cmd, unsigned long arg);
185static void gs_set_termios(struct tty_struct *tty, struct ktermios *old);
186
187static int gs_send(struct gs_dev *dev); 164static int gs_send(struct gs_dev *dev);
188static int gs_send_packet(struct gs_dev *dev, char *packet, 165static int gs_send_packet(struct gs_dev *dev, char *packet,
189 unsigned int size); 166 unsigned int size);
@@ -192,19 +169,7 @@ static int gs_recv_packet(struct gs_dev *dev, char *packet,
192static void gs_read_complete(struct usb_ep *ep, struct usb_request *req); 169static void gs_read_complete(struct usb_ep *ep, struct usb_request *req);
193static void gs_write_complete(struct usb_ep *ep, struct usb_request *req); 170static void gs_write_complete(struct usb_ep *ep, struct usb_request *req);
194 171
195/* gadget driver */ 172/* gadget driver internals */
196static int gs_bind(struct usb_gadget *gadget);
197static void gs_unbind(struct usb_gadget *gadget);
198static int gs_setup(struct usb_gadget *gadget,
199 const struct usb_ctrlrequest *ctrl);
200static int gs_setup_standard(struct usb_gadget *gadget,
201 const struct usb_ctrlrequest *ctrl);
202static int gs_setup_class(struct usb_gadget *gadget,
203 const struct usb_ctrlrequest *ctrl);
204static void gs_setup_complete(struct usb_ep *ep, struct usb_request *req);
205static void gs_setup_complete_set_line_coding(struct usb_ep *ep,
206 struct usb_request *req);
207static void gs_disconnect(struct usb_gadget *gadget);
208static int gs_set_config(struct gs_dev *dev, unsigned config); 173static int gs_set_config(struct gs_dev *dev, unsigned config);
209static void gs_reset_config(struct gs_dev *dev); 174static void gs_reset_config(struct gs_dev *dev);
210static int gs_build_config_buf(u8 *buf, struct usb_gadget *g, 175static int gs_build_config_buf(u8 *buf, struct usb_gadget *g,
@@ -214,10 +179,6 @@ static struct usb_request *gs_alloc_req(struct usb_ep *ep, unsigned int len,
214 gfp_t kmalloc_flags); 179 gfp_t kmalloc_flags);
215static void gs_free_req(struct usb_ep *ep, struct usb_request *req); 180static void gs_free_req(struct usb_ep *ep, struct usb_request *req);
216 181
217static struct gs_req_entry *gs_alloc_req_entry(struct usb_ep *ep, unsigned len,
218 gfp_t kmalloc_flags);
219static void gs_free_req_entry(struct usb_ep *ep, struct gs_req_entry *req);
220
221static int gs_alloc_ports(struct gs_dev *dev, gfp_t kmalloc_flags); 182static int gs_alloc_ports(struct gs_dev *dev, gfp_t kmalloc_flags);
222static void gs_free_ports(struct gs_dev *dev); 183static void gs_free_ports(struct gs_dev *dev);
223 184
@@ -232,62 +193,15 @@ static unsigned int gs_buf_put(struct gs_buf *gb, const char *buf,
232static unsigned int gs_buf_get(struct gs_buf *gb, char *buf, 193static unsigned int gs_buf_get(struct gs_buf *gb, char *buf,
233 unsigned int count); 194 unsigned int count);
234 195
235/* external functions */
236extern int net2280_set_fifo_mode(struct usb_gadget *gadget, int mode);
237
238 196
239/* Globals */ 197/* Globals */
240 198
241static struct gs_dev *gs_device; 199static struct gs_dev *gs_device;
242 200
243static const char *EP_IN_NAME;
244static const char *EP_OUT_NAME;
245static const char *EP_NOTIFY_NAME;
246
247static struct mutex gs_open_close_lock[GS_NUM_PORTS]; 201static struct mutex gs_open_close_lock[GS_NUM_PORTS];
248 202
249static unsigned int read_q_size = GS_DEFAULT_READ_Q_SIZE;
250static unsigned int write_q_size = GS_DEFAULT_WRITE_Q_SIZE;
251
252static unsigned int write_buf_size = GS_DEFAULT_WRITE_BUF_SIZE;
253
254static unsigned int use_acm = GS_DEFAULT_USE_ACM;
255
256
257/* tty driver struct */
258static const struct tty_operations gs_tty_ops = {
259 .open = gs_open,
260 .close = gs_close,
261 .write = gs_write,
262 .put_char = gs_put_char,
263 .flush_chars = gs_flush_chars,
264 .write_room = gs_write_room,
265 .ioctl = gs_ioctl,
266 .set_termios = gs_set_termios,
267 .throttle = gs_throttle,
268 .unthrottle = gs_unthrottle,
269 .break_ctl = gs_break,
270 .chars_in_buffer = gs_chars_in_buffer,
271};
272static struct tty_driver *gs_tty_driver;
273
274/* gadget driver struct */
275static struct usb_gadget_driver gs_gadget_driver = {
276#ifdef CONFIG_USB_GADGET_DUALSPEED
277 .speed = USB_SPEED_HIGH,
278#else
279 .speed = USB_SPEED_FULL,
280#endif /* CONFIG_USB_GADGET_DUALSPEED */
281 .function = GS_LONG_NAME,
282 .bind = gs_bind,
283 .unbind = gs_unbind,
284 .setup = gs_setup,
285 .disconnect = gs_disconnect,
286 .driver = {
287 .name = GS_SHORT_NAME,
288 },
289};
290 203
204/*-------------------------------------------------------------------------*/
291 205
292/* USB descriptors */ 206/* USB descriptors */
293 207
@@ -304,7 +218,6 @@ static char manufacturer[50];
304static struct usb_string gs_strings[] = { 218static struct usb_string gs_strings[] = {
305 { GS_MANUFACTURER_STR_ID, manufacturer }, 219 { GS_MANUFACTURER_STR_ID, manufacturer },
306 { GS_PRODUCT_STR_ID, GS_LONG_NAME }, 220 { GS_PRODUCT_STR_ID, GS_LONG_NAME },
307 { GS_SERIAL_STR_ID, "0" },
308 { GS_BULK_CONFIG_STR_ID, "Gadget Serial Bulk" }, 221 { GS_BULK_CONFIG_STR_ID, "Gadget Serial Bulk" },
309 { GS_ACM_CONFIG_STR_ID, "Gadget Serial CDC ACM" }, 222 { GS_ACM_CONFIG_STR_ID, "Gadget Serial CDC ACM" },
310 { GS_CONTROL_STR_ID, "Gadget Serial Control" }, 223 { GS_CONTROL_STR_ID, "Gadget Serial Control" },
@@ -327,7 +240,6 @@ static struct usb_device_descriptor gs_device_desc = {
327 .idProduct = __constant_cpu_to_le16(GS_PRODUCT_ID), 240 .idProduct = __constant_cpu_to_le16(GS_PRODUCT_ID),
328 .iManufacturer = GS_MANUFACTURER_STR_ID, 241 .iManufacturer = GS_MANUFACTURER_STR_ID,
329 .iProduct = GS_PRODUCT_STR_ID, 242 .iProduct = GS_PRODUCT_STR_ID,
330 .iSerialNumber = GS_SERIAL_STR_ID,
331 .bNumConfigurations = GS_NUM_CONFIGS, 243 .bNumConfigurations = GS_NUM_CONFIGS,
332}; 244};
333 245
@@ -364,7 +276,7 @@ static const struct usb_interface_descriptor gs_bulk_interface_desc = {
364 .bDescriptorType = USB_DT_INTERFACE, 276 .bDescriptorType = USB_DT_INTERFACE,
365 .bInterfaceNumber = GS_BULK_INTERFACE_ID, 277 .bInterfaceNumber = GS_BULK_INTERFACE_ID,
366 .bNumEndpoints = 2, 278 .bNumEndpoints = 2,
367 .bInterfaceClass = USB_CLASS_CDC_DATA, 279 .bInterfaceClass = USB_CLASS_VENDOR_SPEC,
368 .bInterfaceSubClass = 0, 280 .bInterfaceSubClass = 0,
369 .bInterfaceProtocol = 0, 281 .bInterfaceProtocol = 0,
370 .iInterface = GS_DATA_STR_ID, 282 .iInterface = GS_DATA_STR_ID,
@@ -521,6 +433,8 @@ static const struct usb_descriptor_header *gs_acm_highspeed_function[] = {
521}; 433};
522 434
523 435
436/*-------------------------------------------------------------------------*/
437
524/* Module */ 438/* Module */
525MODULE_DESCRIPTION(GS_LONG_NAME); 439MODULE_DESCRIPTION(GS_LONG_NAME);
526MODULE_AUTHOR("Al Borchers"); 440MODULE_AUTHOR("Al Borchers");
@@ -531,84 +445,23 @@ module_param(debug, int, S_IRUGO|S_IWUSR);
531MODULE_PARM_DESC(debug, "Enable debugging, 0=off, 1=on"); 445MODULE_PARM_DESC(debug, "Enable debugging, 0=off, 1=on");
532#endif 446#endif
533 447
448static unsigned int read_q_size = GS_DEFAULT_READ_Q_SIZE;
534module_param(read_q_size, uint, S_IRUGO); 449module_param(read_q_size, uint, S_IRUGO);
535MODULE_PARM_DESC(read_q_size, "Read request queue size, default=32"); 450MODULE_PARM_DESC(read_q_size, "Read request queue size, default=32");
536 451
452static unsigned int write_q_size = GS_DEFAULT_WRITE_Q_SIZE;
537module_param(write_q_size, uint, S_IRUGO); 453module_param(write_q_size, uint, S_IRUGO);
538MODULE_PARM_DESC(write_q_size, "Write request queue size, default=32"); 454MODULE_PARM_DESC(write_q_size, "Write request queue size, default=32");
539 455
456static unsigned int write_buf_size = GS_DEFAULT_WRITE_BUF_SIZE;
540module_param(write_buf_size, uint, S_IRUGO); 457module_param(write_buf_size, uint, S_IRUGO);
541MODULE_PARM_DESC(write_buf_size, "Write buffer size, default=8192"); 458MODULE_PARM_DESC(write_buf_size, "Write buffer size, default=8192");
542 459
460static unsigned int use_acm = GS_DEFAULT_USE_ACM;
543module_param(use_acm, uint, S_IRUGO); 461module_param(use_acm, uint, S_IRUGO);
544MODULE_PARM_DESC(use_acm, "Use CDC ACM, 0=no, 1=yes, default=no"); 462MODULE_PARM_DESC(use_acm, "Use CDC ACM, 0=no, 1=yes, default=no");
545 463
546module_init(gs_module_init); 464/*-------------------------------------------------------------------------*/
547module_exit(gs_module_exit);
548
549/*
550* gs_module_init
551*
552* Register as a USB gadget driver and a tty driver.
553*/
554static int __init gs_module_init(void)
555{
556 int i;
557 int retval;
558
559 retval = usb_gadget_register_driver(&gs_gadget_driver);
560 if (retval) {
561 pr_err("gs_module_init: cannot register gadget driver, "
562 "ret=%d\n", retval);
563 return retval;
564 }
565
566 gs_tty_driver = alloc_tty_driver(GS_NUM_PORTS);
567 if (!gs_tty_driver)
568 return -ENOMEM;
569 gs_tty_driver->owner = THIS_MODULE;
570 gs_tty_driver->driver_name = GS_SHORT_NAME;
571 gs_tty_driver->name = "ttygs";
572 gs_tty_driver->major = GS_MAJOR;
573 gs_tty_driver->minor_start = GS_MINOR_START;
574 gs_tty_driver->type = TTY_DRIVER_TYPE_SERIAL;
575 gs_tty_driver->subtype = SERIAL_TYPE_NORMAL;
576 gs_tty_driver->flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV;
577 gs_tty_driver->init_termios = tty_std_termios;
578 gs_tty_driver->init_termios.c_cflag = B9600 | CS8 | CREAD | HUPCL | CLOCAL;
579 tty_set_operations(gs_tty_driver, &gs_tty_ops);
580
581 for (i=0; i < GS_NUM_PORTS; i++)
582 mutex_init(&gs_open_close_lock[i]);
583
584 retval = tty_register_driver(gs_tty_driver);
585 if (retval) {
586 usb_gadget_unregister_driver(&gs_gadget_driver);
587 put_tty_driver(gs_tty_driver);
588 pr_err("gs_module_init: cannot register tty driver, "
589 "ret=%d\n", retval);
590 return retval;
591 }
592
593 pr_info("gs_module_init: %s %s loaded\n",
594 GS_LONG_NAME, GS_VERSION_STR);
595 return 0;
596}
597
598/*
599* gs_module_exit
600*
601* Unregister as a tty driver and a USB gadget driver.
602*/
603static void __exit gs_module_exit(void)
604{
605 tty_unregister_driver(gs_tty_driver);
606 put_tty_driver(gs_tty_driver);
607 usb_gadget_unregister_driver(&gs_gadget_driver);
608
609 pr_info("gs_module_exit: %s %s unloaded\n",
610 GS_LONG_NAME, GS_VERSION_STR);
611}
612 465
613/* TTY Driver */ 466/* TTY Driver */
614 467
@@ -753,15 +606,15 @@ exit_unlock_dev:
753 * gs_close 606 * gs_close
754 */ 607 */
755 608
756#define GS_WRITE_FINISHED_EVENT_SAFELY(p) \ 609static int gs_write_finished_event_safely(struct gs_port *p)
757({ \ 610{
758 int cond; \ 611 int cond;
759 \ 612
760 spin_lock_irq(&(p)->port_lock); \ 613 spin_lock_irq(&(p)->port_lock);
761 cond = !(p)->port_dev || !gs_buf_data_avail((p)->port_write_buf); \ 614 cond = !(p)->port_dev || !gs_buf_data_avail((p)->port_write_buf);
762 spin_unlock_irq(&(p)->port_lock); \ 615 spin_unlock_irq(&(p)->port_lock);
763 cond; \ 616 return cond;
764}) 617}
765 618
766static void gs_close(struct tty_struct *tty, struct file *file) 619static void gs_close(struct tty_struct *tty, struct file *file)
767{ 620{
@@ -807,7 +660,7 @@ static void gs_close(struct tty_struct *tty, struct file *file)
807 if (gs_buf_data_avail(port->port_write_buf) > 0) { 660 if (gs_buf_data_avail(port->port_write_buf) > 0) {
808 spin_unlock_irq(&port->port_lock); 661 spin_unlock_irq(&port->port_lock);
809 wait_event_interruptible_timeout(port->port_write_wait, 662 wait_event_interruptible_timeout(port->port_write_wait,
810 GS_WRITE_FINISHED_EVENT_SAFELY(port), 663 gs_write_finished_event_safely(port),
811 GS_CLOSE_TIMEOUT * HZ); 664 GS_CLOSE_TIMEOUT * HZ);
812 spin_lock_irq(&port->port_lock); 665 spin_lock_irq(&port->port_lock);
813 } 666 }
@@ -1065,6 +918,23 @@ static void gs_set_termios(struct tty_struct *tty, struct ktermios *old)
1065{ 918{
1066} 919}
1067 920
921static const struct tty_operations gs_tty_ops = {
922 .open = gs_open,
923 .close = gs_close,
924 .write = gs_write,
925 .put_char = gs_put_char,
926 .flush_chars = gs_flush_chars,
927 .write_room = gs_write_room,
928 .ioctl = gs_ioctl,
929 .set_termios = gs_set_termios,
930 .throttle = gs_throttle,
931 .unthrottle = gs_unthrottle,
932 .break_ctl = gs_break,
933 .chars_in_buffer = gs_chars_in_buffer,
934};
935
936/*-------------------------------------------------------------------------*/
937
1068/* 938/*
1069* gs_send 939* gs_send
1070* 940*
@@ -1080,7 +950,6 @@ static int gs_send(struct gs_dev *dev)
1080 unsigned long flags; 950 unsigned long flags;
1081 struct usb_ep *ep; 951 struct usb_ep *ep;
1082 struct usb_request *req; 952 struct usb_request *req;
1083 struct gs_req_entry *req_entry;
1084 953
1085 if (dev == NULL) { 954 if (dev == NULL) {
1086 pr_err("gs_send: NULL device pointer\n"); 955 pr_err("gs_send: NULL device pointer\n");
@@ -1093,10 +962,8 @@ static int gs_send(struct gs_dev *dev)
1093 962
1094 while(!list_empty(&dev->dev_req_list)) { 963 while(!list_empty(&dev->dev_req_list)) {
1095 964
1096 req_entry = list_entry(dev->dev_req_list.next, 965 req = list_entry(dev->dev_req_list.next,
1097 struct gs_req_entry, re_entry); 966 struct usb_request, list);
1098
1099 req = req_entry->re_req;
1100 967
1101 len = gs_send_packet(dev, req->buf, ep->maxpacket); 968 len = gs_send_packet(dev, req->buf, ep->maxpacket);
1102 969
@@ -1106,7 +973,7 @@ static int gs_send(struct gs_dev *dev)
1106 *((unsigned char *)req->buf), 973 *((unsigned char *)req->buf),
1107 *((unsigned char *)req->buf+1), 974 *((unsigned char *)req->buf+1),
1108 *((unsigned char *)req->buf+2)); 975 *((unsigned char *)req->buf+2));
1109 list_del(&req_entry->re_entry); 976 list_del(&req->list);
1110 req->length = len; 977 req->length = len;
1111 spin_unlock_irqrestore(&dev->dev_lock, flags); 978 spin_unlock_irqrestore(&dev->dev_lock, flags);
1112 if ((ret=usb_ep_queue(ep, req, GFP_ATOMIC))) { 979 if ((ret=usb_ep_queue(ep, req, GFP_ATOMIC))) {
@@ -1289,7 +1156,6 @@ requeue:
1289static void gs_write_complete(struct usb_ep *ep, struct usb_request *req) 1156static void gs_write_complete(struct usb_ep *ep, struct usb_request *req)
1290{ 1157{
1291 struct gs_dev *dev = ep->driver_data; 1158 struct gs_dev *dev = ep->driver_data;
1292 struct gs_req_entry *gs_req = req->context;
1293 1159
1294 if (dev == NULL) { 1160 if (dev == NULL) {
1295 pr_err("gs_write_complete: NULL device pointer\n"); 1161 pr_err("gs_write_complete: NULL device pointer\n");
@@ -1300,13 +1166,8 @@ static void gs_write_complete(struct usb_ep *ep, struct usb_request *req)
1300 case 0: 1166 case 0:
1301 /* normal completion */ 1167 /* normal completion */
1302requeue: 1168requeue:
1303 if (gs_req == NULL) {
1304 pr_err("gs_write_complete: NULL request pointer\n");
1305 return;
1306 }
1307
1308 spin_lock(&dev->dev_lock); 1169 spin_lock(&dev->dev_lock);
1309 list_add(&gs_req->re_entry, &dev->dev_req_list); 1170 list_add(&req->list, &dev->dev_req_list);
1310 spin_unlock(&dev->dev_lock); 1171 spin_unlock(&dev->dev_lock);
1311 1172
1312 gs_send(dev); 1173 gs_send(dev);
@@ -1328,9 +1189,39 @@ requeue:
1328 } 1189 }
1329} 1190}
1330 1191
1192/*-------------------------------------------------------------------------*/
1193
1331/* Gadget Driver */ 1194/* Gadget Driver */
1332 1195
1333/* 1196/*
1197 * gs_unbind
1198 *
1199 * Called on module unload. Frees the control request and device
1200 * structure.
1201 */
1202static void /* __init_or_exit */ gs_unbind(struct usb_gadget *gadget)
1203{
1204 struct gs_dev *dev = get_gadget_data(gadget);
1205
1206 gs_device = NULL;
1207
1208 /* read/write requests already freed, only control request remains */
1209 if (dev != NULL) {
1210 if (dev->dev_ctrl_req != NULL) {
1211 gs_free_req(gadget->ep0, dev->dev_ctrl_req);
1212 dev->dev_ctrl_req = NULL;
1213 }
1214 gs_reset_config(dev);
1215 gs_free_ports(dev);
1216 kfree(dev);
1217 set_gadget_data(gadget, NULL);
1218 }
1219
1220 pr_info("gs_unbind: %s %s unbound\n", GS_LONG_NAME,
1221 GS_VERSION_STR);
1222}
1223
1224/*
1334 * gs_bind 1225 * gs_bind
1335 * 1226 *
1336 * Called on module load. Allocates and initializes the device 1227 * Called on module load. Allocates and initializes the device
@@ -1362,19 +1253,23 @@ static int __init gs_bind(struct usb_gadget *gadget)
1362 __constant_cpu_to_le16(GS_VERSION_NUM|0x0099); 1253 __constant_cpu_to_le16(GS_VERSION_NUM|0x0099);
1363 } 1254 }
1364 1255
1256 dev = kzalloc(sizeof(struct gs_dev), GFP_KERNEL);
1257 if (dev == NULL)
1258 return -ENOMEM;
1259
1365 usb_ep_autoconfig_reset(gadget); 1260 usb_ep_autoconfig_reset(gadget);
1366 1261
1367 ep = usb_ep_autoconfig(gadget, &gs_fullspeed_in_desc); 1262 ep = usb_ep_autoconfig(gadget, &gs_fullspeed_in_desc);
1368 if (!ep) 1263 if (!ep)
1369 goto autoconf_fail; 1264 goto autoconf_fail;
1370 EP_IN_NAME = ep->name; 1265 dev->dev_in_ep = ep;
1371 ep->driver_data = ep; /* claim the endpoint */ 1266 ep->driver_data = dev; /* claim the endpoint */
1372 1267
1373 ep = usb_ep_autoconfig(gadget, &gs_fullspeed_out_desc); 1268 ep = usb_ep_autoconfig(gadget, &gs_fullspeed_out_desc);
1374 if (!ep) 1269 if (!ep)
1375 goto autoconf_fail; 1270 goto autoconf_fail;
1376 EP_OUT_NAME = ep->name; 1271 dev->dev_out_ep = ep;
1377 ep->driver_data = ep; /* claim the endpoint */ 1272 ep->driver_data = dev; /* claim the endpoint */
1378 1273
1379 if (use_acm) { 1274 if (use_acm) {
1380 ep = usb_ep_autoconfig(gadget, &gs_fullspeed_notify_desc); 1275 ep = usb_ep_autoconfig(gadget, &gs_fullspeed_notify_desc);
@@ -1384,8 +1279,8 @@ static int __init gs_bind(struct usb_gadget *gadget)
1384 } 1279 }
1385 gs_device_desc.idProduct = __constant_cpu_to_le16( 1280 gs_device_desc.idProduct = __constant_cpu_to_le16(
1386 GS_CDC_PRODUCT_ID), 1281 GS_CDC_PRODUCT_ID),
1387 EP_NOTIFY_NAME = ep->name; 1282 dev->dev_notify_ep = ep;
1388 ep->driver_data = ep; /* claim the endpoint */ 1283 ep->driver_data = dev; /* claim the endpoint */
1389 } 1284 }
1390 1285
1391 gs_device_desc.bDeviceClass = use_acm 1286 gs_device_desc.bDeviceClass = use_acm
@@ -1415,9 +1310,7 @@ static int __init gs_bind(struct usb_gadget *gadget)
1415 gs_acm_config_desc.bmAttributes |= USB_CONFIG_ATT_WAKEUP; 1310 gs_acm_config_desc.bmAttributes |= USB_CONFIG_ATT_WAKEUP;
1416 } 1311 }
1417 1312
1418 gs_device = dev = kzalloc(sizeof(struct gs_dev), GFP_KERNEL); 1313 gs_device = dev;
1419 if (dev == NULL)
1420 return -ENOMEM;
1421 1314
1422 snprintf(manufacturer, sizeof(manufacturer), "%s %s with %s", 1315 snprintf(manufacturer, sizeof(manufacturer), "%s %s with %s",
1423 init_utsname()->sysname, init_utsname()->release, 1316 init_utsname()->sysname, init_utsname()->release,
@@ -1441,8 +1334,6 @@ static int __init gs_bind(struct usb_gadget *gadget)
1441 gs_unbind(gadget); 1334 gs_unbind(gadget);
1442 return -ENOMEM; 1335 return -ENOMEM;
1443 } 1336 }
1444 dev->dev_ctrl_req->complete = gs_setup_complete;
1445
1446 gadget->ep0->driver_data = dev; 1337 gadget->ep0->driver_data = dev;
1447 1338
1448 pr_info("gs_bind: %s %s bound\n", 1339 pr_info("gs_bind: %s %s bound\n",
@@ -1451,99 +1342,11 @@ static int __init gs_bind(struct usb_gadget *gadget)
1451 return 0; 1342 return 0;
1452 1343
1453autoconf_fail: 1344autoconf_fail:
1345 kfree(dev);
1454 pr_err("gs_bind: cannot autoconfigure on %s\n", gadget->name); 1346 pr_err("gs_bind: cannot autoconfigure on %s\n", gadget->name);
1455 return -ENODEV; 1347 return -ENODEV;
1456} 1348}
1457 1349
1458/*
1459 * gs_unbind
1460 *
1461 * Called on module unload. Frees the control request and device
1462 * structure.
1463 */
1464static void /* __init_or_exit */ gs_unbind(struct usb_gadget *gadget)
1465{
1466 struct gs_dev *dev = get_gadget_data(gadget);
1467
1468 gs_device = NULL;
1469
1470 /* read/write requests already freed, only control request remains */
1471 if (dev != NULL) {
1472 if (dev->dev_ctrl_req != NULL) {
1473 gs_free_req(gadget->ep0, dev->dev_ctrl_req);
1474 dev->dev_ctrl_req = NULL;
1475 }
1476 gs_free_ports(dev);
1477 if (dev->dev_notify_ep)
1478 usb_ep_disable(dev->dev_notify_ep);
1479 if (dev->dev_in_ep)
1480 usb_ep_disable(dev->dev_in_ep);
1481 if (dev->dev_out_ep)
1482 usb_ep_disable(dev->dev_out_ep);
1483 kfree(dev);
1484 set_gadget_data(gadget, NULL);
1485 }
1486
1487 pr_info("gs_unbind: %s %s unbound\n", GS_LONG_NAME,
1488 GS_VERSION_STR);
1489}
1490
1491/*
1492 * gs_setup
1493 *
1494 * Implements all the control endpoint functionality that's not
1495 * handled in hardware or the hardware driver.
1496 *
1497 * Returns the size of the data sent to the host, or a negative
1498 * error number.
1499 */
1500static int gs_setup(struct usb_gadget *gadget,
1501 const struct usb_ctrlrequest *ctrl)
1502{
1503 int ret = -EOPNOTSUPP;
1504 struct gs_dev *dev = get_gadget_data(gadget);
1505 struct usb_request *req = dev->dev_ctrl_req;
1506 u16 wIndex = le16_to_cpu(ctrl->wIndex);
1507 u16 wValue = le16_to_cpu(ctrl->wValue);
1508 u16 wLength = le16_to_cpu(ctrl->wLength);
1509
1510 req->complete = gs_setup_complete;
1511
1512 switch (ctrl->bRequestType & USB_TYPE_MASK) {
1513 case USB_TYPE_STANDARD:
1514 ret = gs_setup_standard(gadget,ctrl);
1515 break;
1516
1517 case USB_TYPE_CLASS:
1518 ret = gs_setup_class(gadget,ctrl);
1519 break;
1520
1521 default:
1522 pr_err("gs_setup: unknown request, type=%02x, request=%02x, "
1523 "value=%04x, index=%04x, length=%d\n",
1524 ctrl->bRequestType, ctrl->bRequest,
1525 wValue, wIndex, wLength);
1526 break;
1527 }
1528
1529 /* respond with data transfer before status phase? */
1530 if (ret >= 0) {
1531 req->length = ret;
1532 req->zero = ret < wLength
1533 && (ret % gadget->ep0->maxpacket) == 0;
1534 ret = usb_ep_queue(gadget->ep0, req, GFP_ATOMIC);
1535 if (ret < 0) {
1536 pr_err("gs_setup: cannot queue response, ret=%d\n",
1537 ret);
1538 req->status = 0;
1539 gs_setup_complete(gadget->ep0, req);
1540 }
1541 }
1542
1543 /* device either stalls (ret < 0) or reports success */
1544 return ret;
1545}
1546
1547static int gs_setup_standard(struct usb_gadget *gadget, 1350static int gs_setup_standard(struct usb_gadget *gadget,
1548 const struct usb_ctrlrequest *ctrl) 1351 const struct usb_ctrlrequest *ctrl)
1549{ 1352{
@@ -1673,6 +1476,42 @@ set_interface_done:
1673 return ret; 1476 return ret;
1674} 1477}
1675 1478
1479static void gs_setup_complete_set_line_coding(struct usb_ep *ep,
1480 struct usb_request *req)
1481{
1482 struct gs_dev *dev = ep->driver_data;
1483 struct gs_port *port = dev->dev_port[0]; /* ACM only has one port */
1484
1485 switch (req->status) {
1486 case 0:
1487 /* normal completion */
1488 if (req->actual != sizeof(port->port_line_coding))
1489 usb_ep_set_halt(ep);
1490 else if (port) {
1491 struct usb_cdc_line_coding *value = req->buf;
1492
1493 /* REVISIT: we currently just remember this data.
1494 * If we change that, (a) validate it first, then
1495 * (b) update whatever hardware needs updating.
1496 */
1497 spin_lock(&port->port_lock);
1498 port->port_line_coding = *value;
1499 spin_unlock(&port->port_lock);
1500 }
1501 break;
1502
1503 case -ESHUTDOWN:
1504 /* disconnect */
1505 gs_free_req(ep, req);
1506 break;
1507
1508 default:
1509 /* unexpected */
1510 break;
1511 }
1512 return;
1513}
1514
1676static int gs_setup_class(struct usb_gadget *gadget, 1515static int gs_setup_class(struct usb_gadget *gadget,
1677 const struct usb_ctrlrequest *ctrl) 1516 const struct usb_ctrlrequest *ctrl)
1678{ 1517{
@@ -1734,52 +1573,72 @@ static int gs_setup_class(struct usb_gadget *gadget,
1734 return ret; 1573 return ret;
1735} 1574}
1736 1575
1737static void gs_setup_complete_set_line_coding(struct usb_ep *ep, 1576/*
1738 struct usb_request *req) 1577 * gs_setup_complete
1578 */
1579static void gs_setup_complete(struct usb_ep *ep, struct usb_request *req)
1739{ 1580{
1740 struct gs_dev *dev = ep->driver_data; 1581 if (req->status || req->actual != req->length) {
1741 struct gs_port *port = dev->dev_port[0]; /* ACM only has one port */ 1582 pr_err("gs_setup_complete: status error, status=%d, "
1583 "actual=%d, length=%d\n",
1584 req->status, req->actual, req->length);
1585 }
1586}
1742 1587
1743 switch (req->status) { 1588/*
1744 case 0: 1589 * gs_setup
1745 /* normal completion */ 1590 *
1746 if (req->actual != sizeof(port->port_line_coding)) 1591 * Implements all the control endpoint functionality that's not
1747 usb_ep_set_halt(ep); 1592 * handled in hardware or the hardware driver.
1748 else if (port) { 1593 *
1749 struct usb_cdc_line_coding *value = req->buf; 1594 * Returns the size of the data sent to the host, or a negative
1595 * error number.
1596 */
1597static int gs_setup(struct usb_gadget *gadget,
1598 const struct usb_ctrlrequest *ctrl)
1599{
1600 int ret = -EOPNOTSUPP;
1601 struct gs_dev *dev = get_gadget_data(gadget);
1602 struct usb_request *req = dev->dev_ctrl_req;
1603 u16 wIndex = le16_to_cpu(ctrl->wIndex);
1604 u16 wValue = le16_to_cpu(ctrl->wValue);
1605 u16 wLength = le16_to_cpu(ctrl->wLength);
1750 1606
1751 /* REVISIT: we currently just remember this data. 1607 req->complete = gs_setup_complete;
1752 * If we change that, (a) validate it first, then 1608
1753 * (b) update whatever hardware needs updating. 1609 switch (ctrl->bRequestType & USB_TYPE_MASK) {
1754 */ 1610 case USB_TYPE_STANDARD:
1755 spin_lock(&port->port_lock); 1611 ret = gs_setup_standard(gadget, ctrl);
1756 port->port_line_coding = *value;
1757 spin_unlock(&port->port_lock);
1758 }
1759 break; 1612 break;
1760 1613
1761 case -ESHUTDOWN: 1614 case USB_TYPE_CLASS:
1762 /* disconnect */ 1615 ret = gs_setup_class(gadget, ctrl);
1763 gs_free_req(ep, req);
1764 break; 1616 break;
1765 1617
1766 default: 1618 default:
1767 /* unexpected */ 1619 pr_err("gs_setup: unknown request, type=%02x, request=%02x, "
1620 "value=%04x, index=%04x, length=%d\n",
1621 ctrl->bRequestType, ctrl->bRequest,
1622 wValue, wIndex, wLength);
1768 break; 1623 break;
1769 } 1624 }
1770 return;
1771}
1772 1625
1773/* 1626 /* respond with data transfer before status phase? */
1774 * gs_setup_complete 1627 if (ret >= 0) {
1775 */ 1628 req->length = ret;
1776static void gs_setup_complete(struct usb_ep *ep, struct usb_request *req) 1629 req->zero = ret < wLength
1777{ 1630 && (ret % gadget->ep0->maxpacket) == 0;
1778 if (req->status || req->actual != req->length) { 1631 ret = usb_ep_queue(gadget->ep0, req, GFP_ATOMIC);
1779 pr_err("gs_setup_complete: status error, status=%d, " 1632 if (ret < 0) {
1780 "actual=%d, length=%d\n", 1633 pr_err("gs_setup: cannot queue response, ret=%d\n",
1781 req->status, req->actual, req->length); 1634 ret);
1635 req->status = 0;
1636 gs_setup_complete(gadget->ep0, req);
1637 }
1782 } 1638 }
1639
1640 /* device either stalls (ret < 0) or reports success */
1641 return ret;
1783} 1642}
1784 1643
1785/* 1644/*
@@ -1811,6 +1670,23 @@ static void gs_disconnect(struct usb_gadget *gadget)
1811 pr_info("gs_disconnect: %s disconnected\n", GS_LONG_NAME); 1670 pr_info("gs_disconnect: %s disconnected\n", GS_LONG_NAME);
1812} 1671}
1813 1672
1673static struct usb_gadget_driver gs_gadget_driver = {
1674#ifdef CONFIG_USB_GADGET_DUALSPEED
1675 .speed = USB_SPEED_HIGH,
1676#else
1677 .speed = USB_SPEED_FULL,
1678#endif /* CONFIG_USB_GADGET_DUALSPEED */
1679 .function = GS_LONG_NAME,
1680 .bind = gs_bind,
1681 .unbind = gs_unbind,
1682 .setup = gs_setup,
1683 .disconnect = gs_disconnect,
1684 .driver = {
1685 .name = GS_SHORT_NAME,
1686 .owner = THIS_MODULE,
1687 },
1688};
1689
1814/* 1690/*
1815 * gs_set_config 1691 * gs_set_config
1816 * 1692 *
@@ -1826,9 +1702,8 @@ static int gs_set_config(struct gs_dev *dev, unsigned config)
1826 int ret = 0; 1702 int ret = 0;
1827 struct usb_gadget *gadget = dev->dev_gadget; 1703 struct usb_gadget *gadget = dev->dev_gadget;
1828 struct usb_ep *ep; 1704 struct usb_ep *ep;
1829 struct usb_endpoint_descriptor *ep_desc; 1705 struct usb_endpoint_descriptor *out, *in, *notify;
1830 struct usb_request *req; 1706 struct usb_request *req;
1831 struct gs_req_entry *req_entry;
1832 1707
1833 if (dev == NULL) { 1708 if (dev == NULL) {
1834 pr_err("gs_set_config: NULL device pointer\n"); 1709 pr_err("gs_set_config: NULL device pointer\n");
@@ -1846,86 +1721,62 @@ static int gs_set_config(struct gs_dev *dev, unsigned config)
1846 case GS_BULK_CONFIG_ID: 1721 case GS_BULK_CONFIG_ID:
1847 if (use_acm) 1722 if (use_acm)
1848 return -EINVAL; 1723 return -EINVAL;
1849 /* device specific optimizations */
1850 if (gadget_is_net2280(gadget))
1851 net2280_set_fifo_mode(gadget, 1);
1852 break; 1724 break;
1853 case GS_ACM_CONFIG_ID: 1725 case GS_ACM_CONFIG_ID:
1854 if (!use_acm) 1726 if (!use_acm)
1855 return -EINVAL; 1727 return -EINVAL;
1856 /* device specific optimizations */
1857 if (gadget_is_net2280(gadget))
1858 net2280_set_fifo_mode(gadget, 1);
1859 break; 1728 break;
1860 default: 1729 default:
1861 return -EINVAL; 1730 return -EINVAL;
1862 } 1731 }
1863 1732
1864 dev->dev_config = config; 1733 in = choose_ep_desc(gadget,
1865 1734 &gs_highspeed_in_desc,
1866 gadget_for_each_ep(ep, gadget) { 1735 &gs_fullspeed_in_desc);
1867 1736 out = choose_ep_desc(gadget,
1868 if (EP_NOTIFY_NAME 1737 &gs_highspeed_out_desc,
1869 && strcmp(ep->name, EP_NOTIFY_NAME) == 0) { 1738 &gs_fullspeed_out_desc);
1870 ep_desc = choose_ep_desc(gadget, 1739 notify = dev->dev_notify_ep
1740 ? choose_ep_desc(gadget,
1871 &gs_highspeed_notify_desc, 1741 &gs_highspeed_notify_desc,
1872 &gs_fullspeed_notify_desc); 1742 &gs_fullspeed_notify_desc)
1873 ret = usb_ep_enable(ep,ep_desc); 1743 : NULL;
1874 if (ret == 0) {
1875 ep->driver_data = dev;
1876 dev->dev_notify_ep = ep;
1877 dev->dev_notify_ep_desc = ep_desc;
1878 } else {
1879 pr_err("gs_set_config: cannot enable NOTIFY "
1880 "endpoint %s, ret=%d\n",
1881 ep->name, ret);
1882 goto exit_reset_config;
1883 }
1884 }
1885
1886 else if (strcmp(ep->name, EP_IN_NAME) == 0) {
1887 ep_desc = choose_ep_desc(gadget,
1888 &gs_highspeed_in_desc,
1889 &gs_fullspeed_in_desc);
1890 ret = usb_ep_enable(ep,ep_desc);
1891 if (ret == 0) {
1892 ep->driver_data = dev;
1893 dev->dev_in_ep = ep;
1894 dev->dev_in_ep_desc = ep_desc;
1895 } else {
1896 pr_err("gs_set_config: cannot enable IN "
1897 "endpoint %s, ret=%d\n",
1898 ep->name, ret);
1899 goto exit_reset_config;
1900 }
1901 }
1902 1744
1903 else if (strcmp(ep->name, EP_OUT_NAME) == 0) { 1745 ret = usb_ep_enable(dev->dev_in_ep, in);
1904 ep_desc = choose_ep_desc(gadget, 1746 if (ret == 0) {
1905 &gs_highspeed_out_desc, 1747 dev->dev_in_ep_desc = in;
1906 &gs_fullspeed_out_desc); 1748 } else {
1907 ret = usb_ep_enable(ep,ep_desc); 1749 pr_debug("%s: cannot enable %s %s, ret=%d\n",
1908 if (ret == 0) { 1750 __func__, "IN", dev->dev_in_ep->name, ret);
1909 ep->driver_data = dev; 1751 return ret;
1910 dev->dev_out_ep = ep; 1752 }
1911 dev->dev_out_ep_desc = ep_desc;
1912 } else {
1913 pr_err("gs_set_config: cannot enable OUT "
1914 "endpoint %s, ret=%d\n",
1915 ep->name, ret);
1916 goto exit_reset_config;
1917 }
1918 }
1919 1753
1754 ret = usb_ep_enable(dev->dev_out_ep, out);
1755 if (ret == 0) {
1756 dev->dev_out_ep_desc = out;
1757 } else {
1758 pr_debug("%s: cannot enable %s %s, ret=%d\n",
1759 __func__, "OUT", dev->dev_out_ep->name, ret);
1760fail0:
1761 usb_ep_disable(dev->dev_in_ep);
1762 return ret;
1920 } 1763 }
1921 1764
1922 if (dev->dev_in_ep == NULL || dev->dev_out_ep == NULL 1765 if (notify) {
1923 || (config != GS_BULK_CONFIG_ID && dev->dev_notify_ep == NULL)) { 1766 ret = usb_ep_enable(dev->dev_notify_ep, notify);
1924 pr_err("gs_set_config: cannot find endpoints\n"); 1767 if (ret == 0) {
1925 ret = -ENODEV; 1768 dev->dev_notify_ep_desc = notify;
1926 goto exit_reset_config; 1769 } else {
1770 pr_debug("%s: cannot enable %s %s, ret=%d\n",
1771 __func__, "NOTIFY",
1772 dev->dev_notify_ep->name, ret);
1773 usb_ep_disable(dev->dev_out_ep);
1774 goto fail0;
1775 }
1927 } 1776 }
1928 1777
1778 dev->dev_config = config;
1779
1929 /* allocate and queue read requests */ 1780 /* allocate and queue read requests */
1930 ep = dev->dev_out_ep; 1781 ep = dev->dev_out_ep;
1931 for (i=0; i<read_q_size && ret == 0; i++) { 1782 for (i=0; i<read_q_size && ret == 0; i++) {
@@ -1946,9 +1797,10 @@ static int gs_set_config(struct gs_dev *dev, unsigned config)
1946 /* allocate write requests, and put on free list */ 1797 /* allocate write requests, and put on free list */
1947 ep = dev->dev_in_ep; 1798 ep = dev->dev_in_ep;
1948 for (i=0; i<write_q_size; i++) { 1799 for (i=0; i<write_q_size; i++) {
1949 if ((req_entry=gs_alloc_req_entry(ep, ep->maxpacket, GFP_ATOMIC))) { 1800 req = gs_alloc_req(ep, ep->maxpacket, GFP_ATOMIC);
1950 req_entry->re_req->complete = gs_write_complete; 1801 if (req) {
1951 list_add(&req_entry->re_entry, &dev->dev_req_list); 1802 req->complete = gs_write_complete;
1803 list_add(&req->list, &dev->dev_req_list);
1952 } else { 1804 } else {
1953 pr_err("gs_set_config: cannot allocate " 1805 pr_err("gs_set_config: cannot allocate "
1954 "write requests\n"); 1806 "write requests\n");
@@ -1986,7 +1838,7 @@ exit_reset_config:
1986 */ 1838 */
1987static void gs_reset_config(struct gs_dev *dev) 1839static void gs_reset_config(struct gs_dev *dev)
1988{ 1840{
1989 struct gs_req_entry *req_entry; 1841 struct usb_request *req;
1990 1842
1991 if (dev == NULL) { 1843 if (dev == NULL) {
1992 pr_err("gs_reset_config: NULL device pointer\n"); 1844 pr_err("gs_reset_config: NULL device pointer\n");
@@ -2000,26 +1852,18 @@ static void gs_reset_config(struct gs_dev *dev)
2000 1852
2001 /* free write requests on the free list */ 1853 /* free write requests on the free list */
2002 while(!list_empty(&dev->dev_req_list)) { 1854 while(!list_empty(&dev->dev_req_list)) {
2003 req_entry = list_entry(dev->dev_req_list.next, 1855 req = list_entry(dev->dev_req_list.next,
2004 struct gs_req_entry, re_entry); 1856 struct usb_request, list);
2005 list_del(&req_entry->re_entry); 1857 list_del(&req->list);
2006 gs_free_req_entry(dev->dev_in_ep, req_entry); 1858 gs_free_req(dev->dev_in_ep, req);
2007 } 1859 }
2008 1860
2009 /* disable endpoints, forcing completion of pending i/o; */ 1861 /* disable endpoints, forcing completion of pending i/o; */
2010 /* completion handlers free their requests in this case */ 1862 /* completion handlers free their requests in this case */
2011 if (dev->dev_notify_ep) { 1863 if (dev->dev_notify_ep)
2012 usb_ep_disable(dev->dev_notify_ep); 1864 usb_ep_disable(dev->dev_notify_ep);
2013 dev->dev_notify_ep = NULL; 1865 usb_ep_disable(dev->dev_in_ep);
2014 } 1866 usb_ep_disable(dev->dev_out_ep);
2015 if (dev->dev_in_ep) {
2016 usb_ep_disable(dev->dev_in_ep);
2017 dev->dev_in_ep = NULL;
2018 }
2019 if (dev->dev_out_ep) {
2020 usb_ep_disable(dev->dev_out_ep);
2021 dev->dev_out_ep = NULL;
2022 }
2023} 1867}
2024 1868
2025/* 1869/*
@@ -2113,46 +1957,6 @@ static void gs_free_req(struct usb_ep *ep, struct usb_request *req)
2113} 1957}
2114 1958
2115/* 1959/*
2116 * gs_alloc_req_entry
2117 *
2118 * Allocates a request and its buffer, using the given
2119 * endpoint, buffer len, and kmalloc flags.
2120 */
2121static struct gs_req_entry *
2122gs_alloc_req_entry(struct usb_ep *ep, unsigned len, gfp_t kmalloc_flags)
2123{
2124 struct gs_req_entry *req;
2125
2126 req = kmalloc(sizeof(struct gs_req_entry), kmalloc_flags);
2127 if (req == NULL)
2128 return NULL;
2129
2130 req->re_req = gs_alloc_req(ep, len, kmalloc_flags);
2131 if (req->re_req == NULL) {
2132 kfree(req);
2133 return NULL;
2134 }
2135
2136 req->re_req->context = req;
2137
2138 return req;
2139}
2140
2141/*
2142 * gs_free_req_entry
2143 *
2144 * Frees a request and its buffer.
2145 */
2146static void gs_free_req_entry(struct usb_ep *ep, struct gs_req_entry *req)
2147{
2148 if (ep != NULL && req != NULL) {
2149 if (req->re_req != NULL)
2150 gs_free_req(ep, req->re_req);
2151 kfree(req);
2152 }
2153}
2154
2155/*
2156 * gs_alloc_ports 1960 * gs_alloc_ports
2157 * 1961 *
2158 * Allocate all ports and set the gs_dev struct to point to them. 1962 * Allocate all ports and set the gs_dev struct to point to them.
@@ -2233,6 +2037,8 @@ static void gs_free_ports(struct gs_dev *dev)
2233 } 2037 }
2234} 2038}
2235 2039
2040/*-------------------------------------------------------------------------*/
2041
2236/* Circular Buffer */ 2042/* Circular Buffer */
2237 2043
2238/* 2044/*
@@ -2393,3 +2199,77 @@ gs_buf_get(struct gs_buf *gb, char *buf, unsigned int count)
2393 2199
2394 return count; 2200 return count;
2395} 2201}
2202
2203/*-------------------------------------------------------------------------*/
2204
2205static struct tty_driver *gs_tty_driver;
2206
2207/*
2208 * gs_module_init
2209 *
2210 * Register as a USB gadget driver and a tty driver.
2211 */
2212static int __init gs_module_init(void)
2213{
2214 int i;
2215 int retval;
2216
2217 retval = usb_gadget_register_driver(&gs_gadget_driver);
2218 if (retval) {
2219 pr_err("gs_module_init: cannot register gadget driver, "
2220 "ret=%d\n", retval);
2221 return retval;
2222 }
2223
2224 gs_tty_driver = alloc_tty_driver(GS_NUM_PORTS);
2225 if (!gs_tty_driver)
2226 return -ENOMEM;
2227 gs_tty_driver->owner = THIS_MODULE;
2228 gs_tty_driver->driver_name = GS_SHORT_NAME;
2229 gs_tty_driver->name = "ttygs";
2230 gs_tty_driver->major = GS_MAJOR;
2231 gs_tty_driver->minor_start = GS_MINOR_START;
2232 gs_tty_driver->type = TTY_DRIVER_TYPE_SERIAL;
2233 gs_tty_driver->subtype = SERIAL_TYPE_NORMAL;
2234 gs_tty_driver->flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV;
2235 gs_tty_driver->init_termios = tty_std_termios;
2236 /* must match GS_DEFAULT_DTE_RATE and friends */
2237 gs_tty_driver->init_termios.c_cflag =
2238 B9600 | CS8 | CREAD | HUPCL | CLOCAL;
2239 gs_tty_driver->init_termios.c_ispeed = GS_DEFAULT_DTE_RATE;
2240 gs_tty_driver->init_termios.c_ospeed = GS_DEFAULT_DTE_RATE;
2241 tty_set_operations(gs_tty_driver, &gs_tty_ops);
2242
2243 for (i = 0; i < GS_NUM_PORTS; i++)
2244 mutex_init(&gs_open_close_lock[i]);
2245
2246 retval = tty_register_driver(gs_tty_driver);
2247 if (retval) {
2248 usb_gadget_unregister_driver(&gs_gadget_driver);
2249 put_tty_driver(gs_tty_driver);
2250 pr_err("gs_module_init: cannot register tty driver, "
2251 "ret=%d\n", retval);
2252 return retval;
2253 }
2254
2255 pr_info("gs_module_init: %s %s loaded\n",
2256 GS_LONG_NAME, GS_VERSION_STR);
2257 return 0;
2258}
2259module_init(gs_module_init);
2260
2261/*
2262 * gs_module_exit
2263 *
2264 * Unregister as a tty driver and a USB gadget driver.
2265 */
2266static void __exit gs_module_exit(void)
2267{
2268 tty_unregister_driver(gs_tty_driver);
2269 put_tty_driver(gs_tty_driver);
2270 usb_gadget_unregister_driver(&gs_gadget_driver);
2271
2272 pr_info("gs_module_exit: %s %s unloaded\n",
2273 GS_LONG_NAME, GS_VERSION_STR);
2274}
2275module_exit(gs_module_exit);
diff --git a/drivers/usb/host/isp1760-hcd.c b/drivers/usb/host/isp1760-hcd.c
index 4ba96c1e060c..c9cec8738261 100644
--- a/drivers/usb/host/isp1760-hcd.c
+++ b/drivers/usb/host/isp1760-hcd.c
@@ -988,7 +988,7 @@ static void do_atl_int(struct usb_hcd *usb_hcd)
988 * This did not trigger for a long time now. 988 * This did not trigger for a long time now.
989 */ 989 */
990 printk(KERN_ERR "Reloading ptd %p/%p... qh %p readed: " 990 printk(KERN_ERR "Reloading ptd %p/%p... qh %p readed: "
991 "%d of %d done: %08x cur: %08x\n", qtd, 991 "%d of %zu done: %08x cur: %08x\n", qtd,
992 urb, qh, PTD_XFERRED_LENGTH(dw3), 992 urb, qh, PTD_XFERRED_LENGTH(dw3),
993 qtd->length, done_map, 993 qtd->length, done_map,
994 (1 << queue_entry)); 994 (1 << queue_entry));
@@ -1088,7 +1088,7 @@ static void do_atl_int(struct usb_hcd *usb_hcd)
1088 } else if (usb_pipebulk(urb->pipe) && (length < qtd->length)) { 1088 } else if (usb_pipebulk(urb->pipe) && (length < qtd->length)) {
1089 /* short BULK received */ 1089 /* short BULK received */
1090 1090
1091 printk(KERN_ERR "short bulk, %d instead %d\n", length, 1091 printk(KERN_ERR "short bulk, %d instead %zu\n", length,
1092 qtd->length); 1092 qtd->length);
1093 if (urb->transfer_flags & URB_SHORT_NOT_OK) { 1093 if (urb->transfer_flags & URB_SHORT_NOT_OK) {
1094 urb->status = -EREMOTEIO; 1094 urb->status = -EREMOTEIO;
diff --git a/drivers/usb/host/isp1760-if.c b/drivers/usb/host/isp1760-if.c
index 73fb2a38f1e4..440bf94f0d4c 100644
--- a/drivers/usb/host/isp1760-if.c
+++ b/drivers/usb/host/isp1760-if.c
@@ -256,7 +256,7 @@ static struct pci_driver isp1761_pci_driver = {
256 256
257static int __init isp1760_init(void) 257static int __init isp1760_init(void)
258{ 258{
259 int ret; 259 int ret = -ENODEV;
260 260
261 init_kmem_once(); 261 init_kmem_once();
262 262
diff --git a/drivers/usb/host/ohci-sm501.c b/drivers/usb/host/ohci-sm501.c
index 77204f001b9a..e899a77dfb83 100644
--- a/drivers/usb/host/ohci-sm501.c
+++ b/drivers/usb/host/ohci-sm501.c
@@ -90,7 +90,7 @@ static int ohci_hcd_sm501_drv_probe(struct platform_device *pdev)
90 struct device *dev = &pdev->dev; 90 struct device *dev = &pdev->dev;
91 struct resource *res, *mem; 91 struct resource *res, *mem;
92 int retval, irq; 92 int retval, irq;
93 struct usb_hcd *hcd = 0; 93 struct usb_hcd *hcd = NULL;
94 94
95 irq = retval = platform_get_irq(pdev, 0); 95 irq = retval = platform_get_irq(pdev, 0);
96 if (retval < 0) 96 if (retval < 0)
diff --git a/drivers/usb/misc/ldusb.c b/drivers/usb/misc/ldusb.c
index 7aafd53fbcab..189a9db03509 100644
--- a/drivers/usb/misc/ldusb.c
+++ b/drivers/usb/misc/ldusb.c
@@ -63,9 +63,6 @@
63#define USB_DEVICE_ID_VERNIER_CYCLOPS 0x0004 63#define USB_DEVICE_ID_VERNIER_CYCLOPS 0x0004
64#define USB_DEVICE_ID_VERNIER_LCSPEC 0x0006 64#define USB_DEVICE_ID_VERNIER_LCSPEC 0x0006
65 65
66#define USB_VENDOR_ID_MICROCHIP 0x04d8
67#define USB_DEVICE_ID_PICDEM 0x000c
68
69#ifdef CONFIG_USB_DYNAMIC_MINORS 66#ifdef CONFIG_USB_DYNAMIC_MINORS
70#define USB_LD_MINOR_BASE 0 67#define USB_LD_MINOR_BASE 0
71#else 68#else
@@ -92,7 +89,6 @@ static struct usb_device_id ld_usb_table [] = {
92 { USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_GOTEMP) }, 89 { USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_GOTEMP) },
93 { USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_SKIP) }, 90 { USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_SKIP) },
94 { USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_CYCLOPS) }, 91 { USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_CYCLOPS) },
95 { USB_DEVICE(USB_VENDOR_ID_MICROCHIP, USB_DEVICE_ID_PICDEM) },
96 { USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_LCSPEC) }, 92 { USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_LCSPEC) },
97 { } /* Terminating entry */ 93 { } /* Terminating entry */
98}; 94};
diff --git a/drivers/usb/misc/usbtest.c b/drivers/usb/misc/usbtest.c
index 742be3c35947..054dedd28127 100644
--- a/drivers/usb/misc/usbtest.c
+++ b/drivers/usb/misc/usbtest.c
@@ -856,6 +856,11 @@ test_ctrl_queue (struct usbtest_dev *dev, struct usbtest_param *param)
856 struct urb *u; 856 struct urb *u;
857 struct usb_ctrlrequest req; 857 struct usb_ctrlrequest req;
858 struct subcase *reqp; 858 struct subcase *reqp;
859
860 /* sign of this variable means:
861 * -: tested code must return this (negative) error code
862 * +: tested code may return this (negative too) error code
863 */
859 int expected = 0; 864 int expected = 0;
860 865
861 /* requests here are mostly expected to succeed on any 866 /* requests here are mostly expected to succeed on any
diff --git a/drivers/usb/serial/Kconfig b/drivers/usb/serial/Kconfig
index 2cffec85ee7e..9ba64ccc1359 100644
--- a/drivers/usb/serial/Kconfig
+++ b/drivers/usb/serial/Kconfig
@@ -447,6 +447,15 @@ config USB_SERIAL_MOS7840
447 To compile this driver as a module, choose M here: the 447 To compile this driver as a module, choose M here: the
448 module will be called mos7840. If unsure, choose N. 448 module will be called mos7840. If unsure, choose N.
449 449
450config USB_SERIAL_MOTOROLA
451 tristate "USB Motorola Phone modem driver"
452 ---help---
453 Say Y here if you want to use a Motorola phone with a USB
454 connector as a modem link.
455
456 To compile this driver as a module, choose M here: the
457 module will be called moto_modem. If unsure, choose N.
458
450config USB_SERIAL_NAVMAN 459config USB_SERIAL_NAVMAN
451 tristate "USB Navman GPS device" 460 tristate "USB Navman GPS device"
452 help 461 help
diff --git a/drivers/usb/serial/Makefile b/drivers/usb/serial/Makefile
index 756859510d8c..17a762ab6769 100644
--- a/drivers/usb/serial/Makefile
+++ b/drivers/usb/serial/Makefile
@@ -39,6 +39,7 @@ obj-$(CONFIG_USB_SERIAL_KOBIL_SCT) += kobil_sct.o
39obj-$(CONFIG_USB_SERIAL_MCT_U232) += mct_u232.o 39obj-$(CONFIG_USB_SERIAL_MCT_U232) += mct_u232.o
40obj-$(CONFIG_USB_SERIAL_MOS7720) += mos7720.o 40obj-$(CONFIG_USB_SERIAL_MOS7720) += mos7720.o
41obj-$(CONFIG_USB_SERIAL_MOS7840) += mos7840.o 41obj-$(CONFIG_USB_SERIAL_MOS7840) += mos7840.o
42obj-$(CONFIG_USB_SERIAL_MOTOROLA) += moto_modem.o
42obj-$(CONFIG_USB_SERIAL_NAVMAN) += navman.o 43obj-$(CONFIG_USB_SERIAL_NAVMAN) += navman.o
43obj-$(CONFIG_USB_SERIAL_OMNINET) += omninet.o 44obj-$(CONFIG_USB_SERIAL_OMNINET) += omninet.o
44obj-$(CONFIG_USB_SERIAL_OPTION) += option.o 45obj-$(CONFIG_USB_SERIAL_OPTION) += option.o
diff --git a/drivers/usb/serial/moto_modem.c b/drivers/usb/serial/moto_modem.c
new file mode 100644
index 000000000000..2e8e05462ef7
--- /dev/null
+++ b/drivers/usb/serial/moto_modem.c
@@ -0,0 +1,70 @@
1/*
2 * Motorola USB Phone driver
3 *
4 * Copyright (C) 2008 Greg Kroah-Hartman <greg@kroah.com>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 *
10 * {sigh}
11 * Mororola should be using the CDC ACM USB spec, but instead
12 * they try to just "do their own thing"... This driver should handle a
13 * few phones in which a basic "dumb serial connection" is needed to be
14 * able to get a connection through to them.
15 */
16
17#include <linux/kernel.h>
18#include <linux/init.h>
19#include <linux/tty.h>
20#include <linux/module.h>
21#include <linux/usb.h>
22#include <linux/usb/serial.h>
23
24static struct usb_device_id id_table [] = {
25 { USB_DEVICE(0x05c6, 0x3197) }, /* unknown Motorola phone */
26 { USB_DEVICE(0x0c44, 0x0022) }, /* unknown Mororola phone */
27 { USB_DEVICE(0x22b8, 0x2a64) }, /* Motorola KRZR K1m */
28 { },
29};
30MODULE_DEVICE_TABLE(usb, id_table);
31
32static struct usb_driver moto_driver = {
33 .name = "moto-modem",
34 .probe = usb_serial_probe,
35 .disconnect = usb_serial_disconnect,
36 .id_table = id_table,
37 .no_dynamic_id = 1,
38};
39
40static struct usb_serial_driver moto_device = {
41 .driver = {
42 .owner = THIS_MODULE,
43 .name = "moto-modem",
44 },
45 .id_table = id_table,
46 .num_ports = 1,
47};
48
49static int __init moto_init(void)
50{
51 int retval;
52
53 retval = usb_serial_register(&moto_device);
54 if (retval)
55 return retval;
56 retval = usb_register(&moto_driver);
57 if (retval)
58 usb_serial_deregister(&moto_device);
59 return retval;
60}
61
62static void __exit moto_exit(void)
63{
64 usb_deregister(&moto_driver);
65 usb_serial_deregister(&moto_device);
66}
67
68module_init(moto_init);
69module_exit(moto_exit);
70MODULE_LICENSE("GPL");
diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c
index e4be2d442b1e..e7e016e60333 100644
--- a/drivers/usb/serial/option.c
+++ b/drivers/usb/serial/option.c
@@ -154,8 +154,6 @@ static int option_send_setup(struct usb_serial_port *port);
154#define NOVATELWIRELESS_PRODUCT_MC727 0x4100 154#define NOVATELWIRELESS_PRODUCT_MC727 0x4100
155#define NOVATELWIRELESS_PRODUCT_MC950D 0x4400 155#define NOVATELWIRELESS_PRODUCT_MC950D 0x4400
156 156
157#define NOVATELWIRELESS_PRODUCT_U727 0x5010
158
159/* FUTURE NOVATEL PRODUCTS */ 157/* FUTURE NOVATEL PRODUCTS */
160#define NOVATELWIRELESS_PRODUCT_EVDO_1 0x6000 158#define NOVATELWIRELESS_PRODUCT_EVDO_1 0x6000
161#define NOVATELWIRELESS_PRODUCT_HSPA_1 0x7000 159#define NOVATELWIRELESS_PRODUCT_HSPA_1 0x7000
@@ -184,6 +182,9 @@ static int option_send_setup(struct usb_serial_port *port);
184#define AXESSTEL_VENDOR_ID 0x1726 182#define AXESSTEL_VENDOR_ID 0x1726
185#define AXESSTEL_PRODUCT_MV110H 0x1000 183#define AXESSTEL_PRODUCT_MV110H 0x1000
186 184
185#define ONDA_VENDOR_ID 0x19d2
186#define ONDA_PRODUCT_ET502HS 0x0002
187
187#define BANDRICH_VENDOR_ID 0x1A8D 188#define BANDRICH_VENDOR_ID 0x1A8D
188#define BANDRICH_PRODUCT_C100_1 0x1002 189#define BANDRICH_PRODUCT_C100_1 0x1002
189#define BANDRICH_PRODUCT_C100_2 0x1003 190#define BANDRICH_PRODUCT_C100_2 0x1003
@@ -269,7 +270,6 @@ static struct usb_device_id option_ids[] = {
269 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_EU870D) }, /* Novatel EU850D/EU860D/EU870D */ 270 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_EU870D) }, /* Novatel EU850D/EU860D/EU870D */
270 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_MC950D) }, /* Novatel MC930D/MC950D */ 271 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_MC950D) }, /* Novatel MC930D/MC950D */
271 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_MC727) }, /* Novatel MC727/U727/USB727 */ 272 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_MC727) }, /* Novatel MC727/U727/USB727 */
272 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_U727) }, /* Novatel U727 */
273 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_EVDO_1) }, /* Novatel EVDO product */ 273 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_EVDO_1) }, /* Novatel EVDO product */
274 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_HSPA_1) }, /* Novatel HSPA product */ 274 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_HSPA_1) }, /* Novatel HSPA product */
275 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_EMBEDDED_1) }, /* Novatel Embedded product */ 275 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_EMBEDDED_1) }, /* Novatel Embedded product */
@@ -293,14 +293,17 @@ static struct usb_device_id option_ids[] = {
293 { USB_DEVICE(DELL_VENDOR_ID, 0x8133) }, /* Dell Wireless 5720 == Novatel EV620 CDMA/EV-DO */ 293 { USB_DEVICE(DELL_VENDOR_ID, 0x8133) }, /* Dell Wireless 5720 == Novatel EV620 CDMA/EV-DO */
294 { USB_DEVICE(DELL_VENDOR_ID, 0x8136) }, /* Dell Wireless HSDPA 5520 == Novatel Expedite EU860D */ 294 { USB_DEVICE(DELL_VENDOR_ID, 0x8136) }, /* Dell Wireless HSDPA 5520 == Novatel Expedite EU860D */
295 { USB_DEVICE(DELL_VENDOR_ID, 0x8137) }, /* Dell Wireless HSDPA 5520 */ 295 { USB_DEVICE(DELL_VENDOR_ID, 0x8137) }, /* Dell Wireless HSDPA 5520 */
296 { USB_DEVICE(DELL_VENDOR_ID, 0x8138) }, /* Dell Wireless 5520 Voda I Mobile Broadband (3G HSDPA) Minicard */
296 { USB_DEVICE(ANYDATA_VENDOR_ID, ANYDATA_PRODUCT_ADU_E100A) }, 297 { USB_DEVICE(ANYDATA_VENDOR_ID, ANYDATA_PRODUCT_ADU_E100A) },
297 { USB_DEVICE(ANYDATA_VENDOR_ID, ANYDATA_PRODUCT_ADU_500A) }, 298 { USB_DEVICE(ANYDATA_VENDOR_ID, ANYDATA_PRODUCT_ADU_500A) },
298 { USB_DEVICE(AXESSTEL_VENDOR_ID, AXESSTEL_PRODUCT_MV110H) }, 299 { USB_DEVICE(AXESSTEL_VENDOR_ID, AXESSTEL_PRODUCT_MV110H) },
300 { USB_DEVICE(ONDA_VENDOR_ID, ONDA_PRODUCT_ET502HS) },
299 { USB_DEVICE(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_C100_1) }, 301 { USB_DEVICE(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_C100_1) },
300 { USB_DEVICE(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_C100_2) }, 302 { USB_DEVICE(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_C100_2) },
301 { USB_DEVICE(KYOCERA_VENDOR_ID, KYOCERA_PRODUCT_KPC680) }, 303 { USB_DEVICE(KYOCERA_VENDOR_ID, KYOCERA_PRODUCT_KPC680) },
302 { USB_DEVICE(QUALCOMM_VENDOR_ID, 0x6613)}, /* Onda H600/ZTE MF330 */ 304 { USB_DEVICE(QUALCOMM_VENDOR_ID, 0x6613)}, /* Onda H600/ZTE MF330 */
303 { USB_DEVICE(MAXON_VENDOR_ID, 0x6280) }, /* BP3-USB & BP3-EXT HSDPA */ 305 { USB_DEVICE(MAXON_VENDOR_ID, 0x6280) }, /* BP3-USB & BP3-EXT HSDPA */
306 { USB_DEVICE(0x19d2, 0x0001) }, /* Telstra NextG CDMA */
304 { } /* Terminating entry */ 307 { } /* Terminating entry */
305}; 308};
306MODULE_DEVICE_TABLE(usb, option_ids); 309MODULE_DEVICE_TABLE(usb, option_ids);
diff --git a/drivers/usb/storage/unusual_devs.h b/drivers/usb/storage/unusual_devs.h
index a0ed889230aa..1b09578cbb10 100644
--- a/drivers/usb/storage/unusual_devs.h
+++ b/drivers/usb/storage/unusual_devs.h
@@ -401,6 +401,14 @@ UNUSUAL_DEV( 0x04a5, 0x3010, 0x0100, 0x0100,
401 US_SC_DEVICE, US_PR_DEVICE, NULL, 401 US_SC_DEVICE, US_PR_DEVICE, NULL,
402 US_FL_IGNORE_RESIDUE ), 402 US_FL_IGNORE_RESIDUE ),
403 403
404#ifdef CONFIG_USB_STORAGE_CYPRESS_ATACB
405UNUSUAL_DEV( 0x04b4, 0x6830, 0x0000, 0x9999,
406 "Cypress",
407 "Cypress AT2LP",
408 US_SC_CYP_ATACB, US_PR_BULK, NULL,
409 0),
410#endif
411
404/* Reported by Simon Levitt <simon@whattf.com> 412/* Reported by Simon Levitt <simon@whattf.com>
405 * This entry needs Sub and Proto fields */ 413 * This entry needs Sub and Proto fields */
406UNUSUAL_DEV( 0x04b8, 0x0601, 0x0100, 0x0100, 414UNUSUAL_DEV( 0x04b8, 0x0601, 0x0100, 0x0100,
@@ -539,17 +547,6 @@ UNUSUAL_DEV( 0x04e6, 0x0101, 0x0200, 0x0200,
539 "CD-RW Device", 547 "CD-RW Device",
540 US_SC_8020, US_PR_CB, NULL, 0), 548 US_SC_8020, US_PR_CB, NULL, 0),
541 549
542/* Entry and supporting patch by Theodore Kilgore <kilgota@auburn.edu>.
543 * Device uses standards-violating 32-byte Bulk Command Block Wrappers and
544 * reports itself as "Proprietary SCSI Bulk." Cf. device entry 0x084d:0x0011.
545 */
546
547UNUSUAL_DEV( 0x04fc, 0x80c2, 0x0100, 0x0100,
548 "Kobian Mercury",
549 "Binocam DCB-132",
550 US_SC_DEVICE, US_PR_DEVICE, NULL,
551 US_FL_BULK32),
552
553#ifdef CONFIG_USB_STORAGE_USBAT 550#ifdef CONFIG_USB_STORAGE_USBAT
554UNUSUAL_DEV( 0x04e6, 0x1010, 0x0000, 0x9999, 551UNUSUAL_DEV( 0x04e6, 0x1010, 0x0000, 0x9999,
555 "Shuttle/SCM", 552 "Shuttle/SCM",
@@ -565,6 +562,16 @@ UNUSUAL_DEV( 0x04e8, 0x507c, 0x0220, 0x0220,
565 US_SC_DEVICE, US_PR_DEVICE, NULL, 562 US_SC_DEVICE, US_PR_DEVICE, NULL,
566 US_FL_MAX_SECTORS_64), 563 US_FL_MAX_SECTORS_64),
567 564
565/* Entry and supporting patch by Theodore Kilgore <kilgota@auburn.edu>.
566 * Device uses standards-violating 32-byte Bulk Command Block Wrappers and
567 * reports itself as "Proprietary SCSI Bulk." Cf. device entry 0x084d:0x0011.
568 */
569UNUSUAL_DEV( 0x04fc, 0x80c2, 0x0100, 0x0100,
570 "Kobian Mercury",
571 "Binocam DCB-132",
572 US_SC_DEVICE, US_PR_DEVICE, NULL,
573 US_FL_BULK32),
574
568/* Reported by Bob Sass <rls@vectordb.com> -- only rev 1.33 tested */ 575/* Reported by Bob Sass <rls@vectordb.com> -- only rev 1.33 tested */
569UNUSUAL_DEV( 0x050d, 0x0115, 0x0133, 0x0133, 576UNUSUAL_DEV( 0x050d, 0x0115, 0x0133, 0x0133,
570 "Belkin", 577 "Belkin",
@@ -1304,6 +1311,16 @@ UNUSUAL_DEV( 0x0ace, 0x20ff, 0x0101, 0x0101,
1304 US_SC_DEVICE, US_PR_DEVICE, NULL, 1311 US_SC_DEVICE, US_PR_DEVICE, NULL,
1305 US_FL_IGNORE_DEVICE ), 1312 US_FL_IGNORE_DEVICE ),
1306 1313
1314/* Reported by F. Aben <f.aben@option.com>
1315 * This device (wrongly) has a vendor-specific device descriptor.
1316 * The entry is needed so usb-storage can bind to it's mass-storage
1317 * interface as an interface driver */
1318UNUSUAL_DEV( 0x0af0, 0x7401, 0x0000, 0x0000,
1319 "Option",
1320 "GI 0401 SD-Card",
1321 US_SC_DEVICE, US_PR_DEVICE, NULL,
1322 0 ),
1323
1307#ifdef CONFIG_USB_STORAGE_ISD200 1324#ifdef CONFIG_USB_STORAGE_ISD200
1308UNUSUAL_DEV( 0x0bf6, 0xa001, 0x0100, 0x0110, 1325UNUSUAL_DEV( 0x0bf6, 0xa001, 0x0100, 0x0110,
1309 "ATI", 1326 "ATI",
@@ -1361,13 +1378,6 @@ UNUSUAL_DEV( 0x0d96, 0x410a, 0x0001, 0xffff,
1361 US_SC_DEVICE, US_PR_DEVICE, NULL, 1378 US_SC_DEVICE, US_PR_DEVICE, NULL,
1362 US_FL_FIX_INQUIRY), 1379 US_FL_FIX_INQUIRY),
1363 1380
1364/* Reported by Rohan Hart <rohan.hart17@gmail.com> */
1365UNUSUAL_DEV( 0x2770, 0x915d, 0x0010, 0x0010,
1366 "INTOVA",
1367 "Pixtreme",
1368 US_SC_DEVICE, US_PR_DEVICE, NULL,
1369 US_FL_FIX_CAPACITY ),
1370
1371/* 1381/*
1372 * Entry for Jenoptik JD 5200z3 1382 * Entry for Jenoptik JD 5200z3
1373 * 1383 *
@@ -1684,6 +1694,16 @@ UNUSUAL_DEV( 0x1652, 0x6600, 0x0201, 0x0201,
1684 US_SC_DEVICE, US_PR_DEVICE, NULL, 1694 US_SC_DEVICE, US_PR_DEVICE, NULL,
1685 US_FL_IGNORE_RESIDUE ), 1695 US_FL_IGNORE_RESIDUE ),
1686 1696
1697/* Reported by Mauro Andreolini <andreoli@weblab.ing.unimo.it>
1698 * This entry is needed to bypass the ZeroCD mechanism
1699 * and to properly load as a modem device.
1700 */
1701UNUSUAL_DEV( 0x19d2, 0x2000, 0x0000, 0x0000,
1702 "Onda ET502HS",
1703 "USB MMC Storage",
1704 US_SC_DEVICE, US_PR_DEVICE, NULL,
1705 US_FL_IGNORE_DEVICE),
1706
1687/* patch submitted by Davide Perini <perini.davide@dpsoftware.org> 1707/* patch submitted by Davide Perini <perini.davide@dpsoftware.org>
1688 * and Renato Perini <rperini@email.it> 1708 * and Renato Perini <rperini@email.it>
1689 */ 1709 */
@@ -1721,6 +1741,13 @@ UNUSUAL_DEV( 0x2735, 0x100b, 0x0000, 0x9999,
1721 US_SC_DEVICE, US_PR_DEVICE, NULL, 1741 US_SC_DEVICE, US_PR_DEVICE, NULL,
1722 US_FL_GO_SLOW ), 1742 US_FL_GO_SLOW ),
1723 1743
1744/* Reported by Rohan Hart <rohan.hart17@gmail.com> */
1745UNUSUAL_DEV( 0x2770, 0x915d, 0x0010, 0x0010,
1746 "INTOVA",
1747 "Pixtreme",
1748 US_SC_DEVICE, US_PR_DEVICE, NULL,
1749 US_FL_FIX_CAPACITY ),
1750
1724/* 1751/*
1725 * David Härdeman <david@2gen.com> 1752 * David Härdeman <david@2gen.com>
1726 * The key makes the SCSI stack print confusing (but harmless) messages 1753 * The key makes the SCSI stack print confusing (but harmless) messages
@@ -1745,14 +1772,6 @@ UNUSUAL_DEV( 0xed06, 0x4500, 0x0001, 0x0001,
1745 US_SC_DEVICE, US_PR_DEVICE, NULL, 1772 US_SC_DEVICE, US_PR_DEVICE, NULL,
1746 US_FL_CAPACITY_HEURISTICS), 1773 US_FL_CAPACITY_HEURISTICS),
1747 1774
1748#ifdef CONFIG_USB_STORAGE_CYPRESS_ATACB
1749UNUSUAL_DEV( 0x04b4, 0x6830, 0x0000, 0x9999,
1750 "Cypress",
1751 "Cypress AT2LP",
1752 US_SC_CYP_ATACB, US_PR_BULK, NULL,
1753 0),
1754#endif
1755
1756/* Control/Bulk transport for all SubClass values */ 1775/* Control/Bulk transport for all SubClass values */
1757USUAL_DEV(US_SC_RBC, US_PR_CB, USB_US_TYPE_STOR), 1776USUAL_DEV(US_SC_RBC, US_PR_CB, USB_US_TYPE_STOR),
1758USUAL_DEV(US_SC_8020, US_PR_CB, USB_US_TYPE_STOR), 1777USUAL_DEV(US_SC_8020, US_PR_CB, USB_US_TYPE_STOR),
diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig
index bb1dadaa4a23..2cdaf1ff8315 100644
--- a/drivers/video/Kconfig
+++ b/drivers/video/Kconfig
@@ -171,7 +171,6 @@ config FB_SYS_FOPS
171config FB_DEFERRED_IO 171config FB_DEFERRED_IO
172 bool 172 bool
173 depends on FB 173 depends on FB
174 default y
175 174
176config FB_METRONOME 175config FB_METRONOME
177 tristate 176 tristate
diff --git a/drivers/video/atmel_lcdfb.c b/drivers/video/atmel_lcdfb.c
index 8ffdf3578768..b004036d4087 100644
--- a/drivers/video/atmel_lcdfb.c
+++ b/drivers/video/atmel_lcdfb.c
@@ -441,14 +441,15 @@ static int atmel_lcdfb_set_par(struct fb_info *info)
441 441
442 value = DIV_ROUND_UP(clk_value_khz, PICOS2KHZ(info->var.pixclock)); 442 value = DIV_ROUND_UP(clk_value_khz, PICOS2KHZ(info->var.pixclock));
443 443
444 value = (value / 2) - 1; 444 if (value < 2) {
445 dev_dbg(info->device, " * programming CLKVAL = 0x%08lx\n", value);
446
447 if (value <= 0) {
448 dev_notice(info->device, "Bypassing pixel clock divider\n"); 445 dev_notice(info->device, "Bypassing pixel clock divider\n");
449 lcdc_writel(sinfo, ATMEL_LCDC_LCDCON1, ATMEL_LCDC_BYPASS); 446 lcdc_writel(sinfo, ATMEL_LCDC_LCDCON1, ATMEL_LCDC_BYPASS);
450 } else { 447 } else {
451 lcdc_writel(sinfo, ATMEL_LCDC_LCDCON1, value << ATMEL_LCDC_CLKVAL_OFFSET); 448 value = (value / 2) - 1;
449 dev_dbg(info->device, " * programming CLKVAL = 0x%08lx\n",
450 value);
451 lcdc_writel(sinfo, ATMEL_LCDC_LCDCON1,
452 value << ATMEL_LCDC_CLKVAL_OFFSET);
452 info->var.pixclock = KHZ2PICOS(clk_value_khz / (2 * (value + 1))); 453 info->var.pixclock = KHZ2PICOS(clk_value_khz / (2 * (value + 1)));
453 dev_dbg(info->device, " updated pixclk: %lu KHz\n", 454 dev_dbg(info->device, " updated pixclk: %lu KHz\n",
454 PICOS2KHZ(info->var.pixclock)); 455 PICOS2KHZ(info->var.pixclock));
diff --git a/drivers/video/console/fbcon.c b/drivers/video/console/fbcon.c
index ad31983b43eb..5fa8b76673cb 100644
--- a/drivers/video/console/fbcon.c
+++ b/drivers/video/console/fbcon.c
@@ -1853,6 +1853,8 @@ static int fbcon_scroll(struct vc_data *vc, int t, int b, int dir,
1853 struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]]; 1853 struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]];
1854 struct display *p = &fb_display[vc->vc_num]; 1854 struct display *p = &fb_display[vc->vc_num];
1855 int scroll_partial = info->flags & FBINFO_PARTIAL_PAN_OK; 1855 int scroll_partial = info->flags & FBINFO_PARTIAL_PAN_OK;
1856 unsigned short saved_ec;
1857 int ret;
1856 1858
1857 if (fbcon_is_inactive(vc, info)) 1859 if (fbcon_is_inactive(vc, info))
1858 return -EINVAL; 1860 return -EINVAL;
@@ -1865,6 +1867,11 @@ static int fbcon_scroll(struct vc_data *vc, int t, int b, int dir,
1865 * whole screen (prevents flicker). 1867 * whole screen (prevents flicker).
1866 */ 1868 */
1867 1869
1870 saved_ec = vc->vc_video_erase_char;
1871 vc->vc_video_erase_char = vc->vc_scrl_erase_char;
1872
1873 ret = 0;
1874
1868 switch (dir) { 1875 switch (dir) {
1869 case SM_UP: 1876 case SM_UP:
1870 if (count > vc->vc_rows) /* Maximum realistic size */ 1877 if (count > vc->vc_rows) /* Maximum realistic size */
@@ -1883,7 +1890,7 @@ static int fbcon_scroll(struct vc_data *vc, int t, int b, int dir,
1883 (b - count)), 1890 (b - count)),
1884 vc->vc_scrl_erase_char, 1891 vc->vc_scrl_erase_char,
1885 vc->vc_size_row * count); 1892 vc->vc_size_row * count);
1886 return 1; 1893 ret = 1;
1887 break; 1894 break;
1888 1895
1889 case SCROLL_WRAP_MOVE: 1896 case SCROLL_WRAP_MOVE:
@@ -1955,7 +1962,8 @@ static int fbcon_scroll(struct vc_data *vc, int t, int b, int dir,
1955 (b - count)), 1962 (b - count)),
1956 vc->vc_scrl_erase_char, 1963 vc->vc_scrl_erase_char,
1957 vc->vc_size_row * count); 1964 vc->vc_size_row * count);
1958 return 1; 1965 ret = 1;
1966 break;
1959 } 1967 }
1960 break; 1968 break;
1961 1969
@@ -1974,7 +1982,7 @@ static int fbcon_scroll(struct vc_data *vc, int t, int b, int dir,
1974 t), 1982 t),
1975 vc->vc_scrl_erase_char, 1983 vc->vc_scrl_erase_char,
1976 vc->vc_size_row * count); 1984 vc->vc_size_row * count);
1977 return 1; 1985 ret = 1;
1978 break; 1986 break;
1979 1987
1980 case SCROLL_WRAP_MOVE: 1988 case SCROLL_WRAP_MOVE:
@@ -2044,10 +2052,13 @@ static int fbcon_scroll(struct vc_data *vc, int t, int b, int dir,
2044 t), 2052 t),
2045 vc->vc_scrl_erase_char, 2053 vc->vc_scrl_erase_char,
2046 vc->vc_size_row * count); 2054 vc->vc_size_row * count);
2047 return 1; 2055 ret = 1;
2056 break;
2048 } 2057 }
2058 break;
2049 } 2059 }
2050 return 0; 2060 vc->vc_video_erase_char = saved_ec;
2061 return ret;
2051} 2062}
2052 2063
2053 2064
@@ -2507,6 +2518,9 @@ static int fbcon_do_set_font(struct vc_data *vc, int w, int h,
2507 c = vc->vc_video_erase_char; 2518 c = vc->vc_video_erase_char;
2508 vc->vc_video_erase_char = 2519 vc->vc_video_erase_char =
2509 ((c & 0xfe00) >> 1) | (c & 0xff); 2520 ((c & 0xfe00) >> 1) | (c & 0xff);
2521 c = vc->vc_def_color;
2522 vc->vc_scrl_erase_char =
2523 ((c & 0xFE00) >> 1) | (c & 0xFF);
2510 vc->vc_attr >>= 1; 2524 vc->vc_attr >>= 1;
2511 } 2525 }
2512 } else if (!vc->vc_hi_font_mask && cnt == 512) { 2526 } else if (!vc->vc_hi_font_mask && cnt == 512) {
@@ -2537,9 +2551,14 @@ static int fbcon_do_set_font(struct vc_data *vc, int w, int h,
2537 if (vc->vc_can_do_color) { 2551 if (vc->vc_can_do_color) {
2538 vc->vc_video_erase_char = 2552 vc->vc_video_erase_char =
2539 ((c & 0xff00) << 1) | (c & 0xff); 2553 ((c & 0xff00) << 1) | (c & 0xff);
2554 c = vc->vc_def_color;
2555 vc->vc_scrl_erase_char =
2556 ((c & 0xFF00) << 1) | (c & 0xFF);
2540 vc->vc_attr <<= 1; 2557 vc->vc_attr <<= 1;
2541 } else 2558 } else {
2542 vc->vc_video_erase_char = c & ~0x100; 2559 vc->vc_video_erase_char = c & ~0x100;
2560 vc->vc_scrl_erase_char = c & ~0x100;
2561 }
2543 } 2562 }
2544 2563
2545 } 2564 }
diff --git a/drivers/video/geode/lxfb_ops.c b/drivers/video/geode/lxfb_ops.c
index cd9d4cc26954..aaef9165ec9b 100644
--- a/drivers/video/geode/lxfb_ops.c
+++ b/drivers/video/geode/lxfb_ops.c
@@ -63,54 +63,32 @@ static const struct {
63 { 0x00014284, 19688 }, 63 { 0x00014284, 19688 },
64 { 0x00011104, 20400 }, 64 { 0x00011104, 20400 },
65 { 0x00016363, 23625 }, 65 { 0x00016363, 23625 },
66 { 0x00015303, 24380 },
67 { 0x000031AC, 24923 }, 66 { 0x000031AC, 24923 },
68 { 0x0000215D, 25175 }, 67 { 0x0000215D, 25175 },
69 { 0x00001087, 27000 }, 68 { 0x00001087, 27000 },
70 { 0x0000216C, 28322 }, 69 { 0x0000216C, 28322 },
71 { 0x0000218D, 28560 }, 70 { 0x0000218D, 28560 },
72 { 0x00010041, 29913 },
73 { 0x000010C9, 31200 }, 71 { 0x000010C9, 31200 },
74 { 0x00003147, 31500 }, 72 { 0x00003147, 31500 },
75 { 0x000141A1, 32400 },
76 { 0x000010A7, 33032 }, 73 { 0x000010A7, 33032 },
77 { 0x00012182, 33375 },
78 { 0x000141B1, 33750 },
79 { 0x00002159, 35112 }, 74 { 0x00002159, 35112 },
80 { 0x00004249, 35500 }, 75 { 0x00004249, 35500 },
81 { 0x00000057, 36000 }, 76 { 0x00000057, 36000 },
82 { 0x000141E1, 37125 },
83 { 0x0000219A, 37889 }, 77 { 0x0000219A, 37889 },
84 { 0x00002158, 39168 }, 78 { 0x00002158, 39168 },
85 { 0x00000045, 40000 }, 79 { 0x00000045, 40000 },
86 { 0x000131A1, 40500 },
87 { 0x00010061, 42301 },
88 { 0x00000089, 43163 }, 80 { 0x00000089, 43163 },
89 { 0x00012151, 43875 },
90 { 0x000010E7, 44900 }, 81 { 0x000010E7, 44900 },
91 { 0x00002136, 45720 }, 82 { 0x00002136, 45720 },
92 { 0x000152E1, 47250 },
93 { 0x00010071, 48000 },
94 { 0x00003207, 49500 }, 83 { 0x00003207, 49500 },
95 { 0x00002187, 50000 }, 84 { 0x00002187, 50000 },
96 { 0x00014291, 50625 },
97 { 0x00011101, 51188 },
98 { 0x00017481, 54563 },
99 { 0x00004286, 56250 }, 85 { 0x00004286, 56250 },
100 { 0x00014170, 57375 },
101 { 0x00016210, 58500 },
102 { 0x000010E5, 60065 }, 86 { 0x000010E5, 60065 },
103 { 0x00013140, 62796 },
104 { 0x00004214, 65000 }, 87 { 0x00004214, 65000 },
105 { 0x00016250, 65250 },
106 { 0x00001105, 68179 }, 88 { 0x00001105, 68179 },
107 { 0x000141C0, 69600 },
108 { 0x00015220, 70160 },
109 { 0x00010050, 72000 },
110 { 0x000031E4, 74250 }, 89 { 0x000031E4, 74250 },
111 { 0x00003183, 75000 }, 90 { 0x00003183, 75000 },
112 { 0x00004284, 78750 }, 91 { 0x00004284, 78750 },
113 { 0x00012130, 80052 },
114 { 0x00001104, 81600 }, 92 { 0x00001104, 81600 },
115 { 0x00006363, 94500 }, 93 { 0x00006363, 94500 },
116 { 0x00005303, 97520 }, 94 { 0x00005303, 97520 },
diff --git a/drivers/video/logo/Kconfig b/drivers/video/logo/Kconfig
index 9de1c114f809..39ac49e0682c 100644
--- a/drivers/video/logo/Kconfig
+++ b/drivers/video/logo/Kconfig
@@ -27,6 +27,16 @@ config LOGO_LINUX_CLUT224
27 bool "Standard 224-color Linux logo" 27 bool "Standard 224-color Linux logo"
28 default y 28 default y
29 29
30config LOGO_BLACKFIN_VGA16
31 bool "16-colour Blackfin Processor Linux logo"
32 depends on BLACKFIN
33 default y
34
35config LOGO_BLACKFIN_CLUT224
36 bool "224-colour Blackfin Processor Linux logo"
37 depends on BLACKFIN
38 default y
39
30config LOGO_DEC_CLUT224 40config LOGO_DEC_CLUT224
31 bool "224-color Digital Equipment Corporation Linux logo" 41 bool "224-color Digital Equipment Corporation Linux logo"
32 depends on MACH_DECSTATION || ALPHA 42 depends on MACH_DECSTATION || ALPHA
diff --git a/drivers/video/logo/Makefile b/drivers/video/logo/Makefile
index a5fc4edf84e6..b91251d1fe41 100644
--- a/drivers/video/logo/Makefile
+++ b/drivers/video/logo/Makefile
@@ -4,6 +4,8 @@ obj-$(CONFIG_LOGO) += logo.o
4obj-$(CONFIG_LOGO_LINUX_MONO) += logo_linux_mono.o 4obj-$(CONFIG_LOGO_LINUX_MONO) += logo_linux_mono.o
5obj-$(CONFIG_LOGO_LINUX_VGA16) += logo_linux_vga16.o 5obj-$(CONFIG_LOGO_LINUX_VGA16) += logo_linux_vga16.o
6obj-$(CONFIG_LOGO_LINUX_CLUT224) += logo_linux_clut224.o 6obj-$(CONFIG_LOGO_LINUX_CLUT224) += logo_linux_clut224.o
7obj-$(CONFIG_LOGO_BLACKFIN_CLUT224) += logo_blackfin_clut224.o
8obj-$(CONFIG_LOGO_BLACKFIN_VGA16) += logo_blackfin_vga16.o
7obj-$(CONFIG_LOGO_DEC_CLUT224) += logo_dec_clut224.o 9obj-$(CONFIG_LOGO_DEC_CLUT224) += logo_dec_clut224.o
8obj-$(CONFIG_LOGO_MAC_CLUT224) += logo_mac_clut224.o 10obj-$(CONFIG_LOGO_MAC_CLUT224) += logo_mac_clut224.o
9obj-$(CONFIG_LOGO_PARISC_CLUT224) += logo_parisc_clut224.o 11obj-$(CONFIG_LOGO_PARISC_CLUT224) += logo_parisc_clut224.o
diff --git a/drivers/video/logo/logo.c b/drivers/video/logo/logo.c
index fc72684aae5a..2e85a2b52d05 100644
--- a/drivers/video/logo/logo.c
+++ b/drivers/video/logo/logo.c
@@ -24,6 +24,8 @@
24extern const struct linux_logo logo_linux_mono; 24extern const struct linux_logo logo_linux_mono;
25extern const struct linux_logo logo_linux_vga16; 25extern const struct linux_logo logo_linux_vga16;
26extern const struct linux_logo logo_linux_clut224; 26extern const struct linux_logo logo_linux_clut224;
27extern const struct linux_logo logo_blackfin_vga16;
28extern const struct linux_logo logo_blackfin_clut224;
27extern const struct linux_logo logo_dec_clut224; 29extern const struct linux_logo logo_dec_clut224;
28extern const struct linux_logo logo_mac_clut224; 30extern const struct linux_logo logo_mac_clut224;
29extern const struct linux_logo logo_parisc_clut224; 31extern const struct linux_logo logo_parisc_clut224;
@@ -65,6 +67,10 @@ const struct linux_logo * __init_refok fb_find_logo(int depth)
65 /* Generic Linux logo */ 67 /* Generic Linux logo */
66 logo = &logo_linux_vga16; 68 logo = &logo_linux_vga16;
67#endif 69#endif
70#ifdef CONFIG_LOGO_BLACKFIN_VGA16
71 /* Blackfin processor logo */
72 logo = &logo_blackfin_vga16;
73#endif
68#ifdef CONFIG_LOGO_SUPERH_VGA16 74#ifdef CONFIG_LOGO_SUPERH_VGA16
69 /* SuperH Linux logo */ 75 /* SuperH Linux logo */
70 logo = &logo_superh_vga16; 76 logo = &logo_superh_vga16;
@@ -76,6 +82,10 @@ const struct linux_logo * __init_refok fb_find_logo(int depth)
76 /* Generic Linux logo */ 82 /* Generic Linux logo */
77 logo = &logo_linux_clut224; 83 logo = &logo_linux_clut224;
78#endif 84#endif
85#ifdef CONFIG_LOGO_BLACKFIN_CLUT224
86 /* Blackfin Linux logo */
87 logo = &logo_blackfin_clut224;
88#endif
79#ifdef CONFIG_LOGO_DEC_CLUT224 89#ifdef CONFIG_LOGO_DEC_CLUT224
80 /* DEC Linux logo on MIPS/MIPS64 or ALPHA */ 90 /* DEC Linux logo on MIPS/MIPS64 or ALPHA */
81 logo = &logo_dec_clut224; 91 logo = &logo_dec_clut224;
diff --git a/drivers/video/logo/logo_blackfin_clut224.ppm b/drivers/video/logo/logo_blackfin_clut224.ppm
new file mode 100644
index 000000000000..dc9a50a14477
--- /dev/null
+++ b/drivers/video/logo/logo_blackfin_clut224.ppm
@@ -0,0 +1,1127 @@
1P3
2# This was generated by the GIMP & Netpbm tools
3# gimp linux_bf.svg (create 80x80 save as linux_bf.ppm)
4# pnmquant 224 linux_bf.ppm | pnmnoraw > logo_blackfin_clut224.ppm
5#
680 80
7255
80 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
90 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
100 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
110 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
120 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
130 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
141 1 1 3 3 3 4 6 6 6 6 6 4 6 6 3 3 3
150 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
160 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
170 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
180 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
190 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
200 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
210 0 0 0 0 0
220 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
230 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
240 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
250 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
260 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
270 0 0 0 0 0 0 0 0 2 2 2 10 10 10 26 26 27
2844 44 45 66 66 66 78 81 81 78 81 81 75 75 76 60 60 60
2939 39 39 20 20 20 6 6 6 1 1 1 0 0 0 0 0 0
300 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
310 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
320 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
330 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
340 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
350 0 0 0 0 0
360 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
370 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
380 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
390 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
400 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
410 0 0 2 2 2 14 14 14 47 47 47 84 84 84 75 75 76
4247 47 47 12 12 12 0 0 0 0 0 0 0 0 0 20 20 20
4353 54 54 81 81 82 74 74 74 31 31 31 6 6 6 0 0 0
440 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
450 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
460 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
470 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
480 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
490 0 0 0 0 0
500 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
510 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
520 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
530 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
540 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
554 4 4 34 34 35 84 84 84 60 60 60 4 4 4 0 0 0
560 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
570 0 0 0 0 0 17 18 18 75 75 76 66 66 66 17 18 18
581 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
590 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
600 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
610 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
620 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
630 0 0 0 0 0
640 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
650 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
660 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
670 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
680 0 0 0 0 0 0 0 0 0 0 0 0 0 0 3 3 3
6942 42 43 84 84 84 8 8 8 0 0 0 0 0 0 0 0 0
700 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
710 3 3 36 40 40 10 16 16 0 0 0 31 31 31 84 84 84
7229 29 30 2 2 2 0 0 0 0 0 0 0 0 0 0 0 0
730 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
740 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
750 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
760 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
770 0 0 0 0 0
780 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
790 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
800 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
810 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
820 0 0 0 0 0 0 0 0 0 0 0 1 1 1 26 27 27
8384 84 84 3 3 3 0 0 0 0 0 0 0 0 0 0 0 0
840 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
8515 19 19 114 115 115 110 114 114 44 46 46 0 0 0 12 12 12
8690 87 86 24 24 24 1 1 1 0 0 0 0 0 0 0 0 0
870 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
880 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
890 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
900 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
910 0 0 0 0 0
920 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
930 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
940 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
950 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
960 0 0 0 0 0 0 0 0 0 0 0 8 8 8 75 75 76
9714 14 14 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
980 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
9930 40 40 133 133 133 129 130 130 78 85 85 23 31 30 0 0 0
10019 19 19 78 81 81 13 13 13 0 0 0 0 0 0 0 0 0
1010 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1020 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1030 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1040 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1050 0 0 0 0 0
1060 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1070 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1080 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1090 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1100 0 0 0 0 0 0 0 0 0 0 0 26 27 27 81 81 82
1110 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1120 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
11336 40 40 89 90 91 55 63 63 23 31 30 4 6 6 0 0 0
1140 0 0 60 60 60 47 47 47 2 2 2 0 0 0 0 0 0
1150 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1160 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1170 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1180 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1190 0 0 0 0 0
1200 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1210 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1220 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1230 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1240 0 0 0 0 0 0 0 0 2 2 2 53 54 54 34 34 35
1250 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1260 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1274 10 10 7 9 9 0 0 0 0 0 0 0 0 0 0 0 0
1280 0 0 1 1 1 84 84 84 13 13 13 0 0 0 0 0 0
1290 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1300 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1310 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1320 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1330 0 0 0 0 0
1340 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1350 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1360 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1370 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1380 0 0 0 0 0 0 0 0 4 6 6 78 81 81 2 2 2
1390 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1400 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1410 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1420 0 0 0 0 0 65 64 64 36 36 36 0 0 0 0 0 0
1430 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1440 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1450 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1460 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1470 0 0 0 0 0
1480 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1490 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1500 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1510 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1520 0 0 0 0 0 0 0 0 10 11 11 81 81 82 0 0 0
1530 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1540 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1550 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1560 0 0 0 0 0 12 12 12 67 70 70 4 4 4 0 0 0
1570 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1580 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1590 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1600 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1610 0 0 0 0 0
1620 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1630 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1640 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1650 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1660 0 0 0 0 0 0 0 0 16 16 16 81 81 82 0 0 0
1670 0 0 0 0 0 4 10 10 44 50 50 18 21 21 0 0 0
1680 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1690 1 1 78 85 85 120 121 122 7 9 9 0 0 0 0 0 0
1700 0 0 0 0 0 0 0 0 82 82 81 12 12 12 0 0 0
1710 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1720 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1730 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1740 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1750 0 0 0 0 0
1760 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1770 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1780 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1790 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1800 0 0 0 0 0 0 0 0 19 19 19 81 81 82 0 0 0
1810 0 0 2 2 2 8 8 8 55 63 63 108 110 110 52 58 58
1820 0 0 0 0 0 0 0 0 0 0 0 42 42 43 129 130 130
183140 142 143 114 115 115 110 114 114 129 130 130 0 0 0 0 0 0
1840 0 0 0 0 0 0 0 0 75 75 76 24 24 24 0 0 0
1850 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1860 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1870 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1880 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1890 0 0 0 0 0
1900 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1910 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1920 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1930 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1940 0 0 0 0 0 0 0 0 19 19 19 74 74 74 0 0 0
1954 6 6 167 168 167 196 196 197 196 196 197 61 65 66 78 85 85
1960 0 0 0 0 0 0 0 0 118 118 118 202 202 203 219 219 219
197219 219 219 214 214 215 187 187 188 78 85 85 29 33 34 0 0 0
1980 0 0 0 0 0 0 0 0 60 60 60 39 39 39 0 0 0
1990 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2010 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2020 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2030 0 0 0 0 0
2040 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2050 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2060 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2070 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2080 0 0 0 0 0 0 0 0 19 19 19 72 71 71 0 0 0
209185 185 184 244 245 245 250 251 252 251 251 252 247 248 249 36 36 36
2100 0 0 0 0 0 13 13 13 243 243 241 252 252 252 253 253 253
211253 253 253 252 252 252 247 247 246 193 193 194 0 0 0 0 0 0
2120 0 0 0 0 0 0 0 0 42 42 43 50 51 51 1 1 1
2130 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2140 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2150 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2160 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2170 0 0 0 0 0
2180 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2190 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2200 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2210 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2220 0 0 0 0 0 0 0 0 19 19 19 78 81 81 0 0 0
223247 247 246 193 193 194 95 97 97 193 193 194 255 255 255 237 237 238
2240 0 0 0 0 0 202 202 203 255 255 255 247 247 246 108 107 107
22582 85 86 167 168 167 255 255 255 248 248 249 0 0 0 0 0 0
2260 0 0 0 0 0 0 0 0 34 34 35 56 56 56 2 2 2
2270 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2280 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2290 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2300 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2310 0 0 0 0 0
2320 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2330 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2340 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2350 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2360 0 0 0 0 0 0 0 0 19 19 19 78 81 81 0 0 0
237250 250 251 50 51 51 153 154 155 150 151 151 244 245 245 244 245 245
23844 50 50 84 89 89 153 154 155 255 255 255 140 142 143 0 0 0
239149 149 150 156 155 156 237 237 238 254 254 254 67 70 70 0 0 0
2400 0 0 0 0 0 0 0 0 39 39 39 47 47 47 1 1 1
2410 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2420 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2430 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2440 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2450 0 0 0 0 0
2460 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2470 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2480 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2490 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2500 0 0 0 0 0 0 0 0 19 19 19 81 81 82 0 0 0
251248 248 249 34 34 35 72 71 71 165 165 165 202 202 203 244 245 245
25210 16 16 82 85 86 89 90 91 255 255 255 95 97 97 0 0 0
2530 0 0 53 54 54 177 177 174 255 255 255 127 127 126 0 0 0
2540 0 0 0 0 0 0 0 0 39 39 39 36 36 36 0 0 0
2550 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2560 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2570 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2580 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2590 0 0 0 0 0
2600 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2610 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2620 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2630 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2640 0 0 0 0 0 0 0 0 14 14 14 78 81 81 0 0 0
265243 243 243 89 90 91 0 0 0 36 40 40 201 147 55 241 205 27
266241 205 27 241 205 27 241 205 27 238 192 33 108 110 110 0 0 0
2670 0 0 0 0 0 191 190 190 254 254 254 34 34 35 0 0 0
2680 0 0 0 0 0 0 0 0 42 42 43 42 42 43 0 0 0
2690 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2700 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2710 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2720 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2730 0 0 0 0 0
2740 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2750 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2760 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2770 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2780 0 0 0 0 0 0 0 0 10 10 10 75 75 76 0 0 0
279202 202 203 218 217 217 21 19 17 230 165 41 199 129 48 213 157 40
280244 212 23 243 206 27 180 121 62 243 206 27 244 209 25 226 179 40
28115 10 7 103 103 103 254 254 254 251 251 252 0 0 0 0 0 0
2820 0 0 0 0 0 0 0 0 17 18 18 58 58 58 2 2 2
2830 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2840 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2850 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2860 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2870 0 0 0 0 0
2880 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2890 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2900 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2910 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2920 0 0 0 0 0 0 0 0 9 9 9 84 84 84 0 0 0
2930 0 0 226 226 219 213 157 40 244 209 25 245 211 23 245 211 23
294245 214 38 245 214 38 245 211 23 245 211 23 245 211 23 244 212 23
295244 212 23 241 205 27 226 179 40 196 196 197 0 0 0 0 0 0
2960 0 0 0 0 0 0 0 0 0 0 0 74 74 74 4 6 6
2970 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2980 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2990 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3010 0 0 0 0 0
3020 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3030 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3040 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3050 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3060 0 0 0 0 0 0 0 0 7 7 7 84 84 84 0 0 0
30754 42 32 213 157 40 243 206 27 245 211 23 245 211 23 245 211 23
308245 215 41 245 214 35 245 211 23 245 211 23 245 214 35 245 215 41
309245 214 35 245 211 23 245 211 23 238 204 29 0 0 0 0 0 0
3100 0 0 0 0 0 0 0 0 0 0 0 81 81 82 12 12 12
3110 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3120 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3130 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3140 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3150 0 0 0 0 0
3160 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3170 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3180 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3190 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3200 0 0 0 0 0 0 0 0 4 6 6 74 74 74 0 0 0
321201 147 55 241 205 27 245 211 23 245 211 23 245 211 23 245 213 29
322245 214 38 245 211 23 245 211 23 245 214 35 245 215 41 245 215 41
323245 213 29 142 83 36 142 83 36 244 209 25 1 1 1 0 0 0
3240 0 0 0 0 0 0 0 0 0 0 0 74 74 74 25 25 26
3250 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3260 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3270 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3280 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3290 0 0 0 0 0
3300 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3310 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3320 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3330 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3340 0 0 0 0 0 0 0 0 4 4 4 72 71 71 6 6 6
335213 157 40 244 209 25 245 211 23 245 211 23 245 211 23 245 213 29
336244 212 23 245 211 23 245 214 35 245 215 41 245 215 41 245 213 29
337142 83 36 142 83 36 238 192 33 241 205 27 0 0 0 0 0 0
3380 0 0 0 0 0 0 0 0 0 0 0 44 44 44 49 50 50
3392 2 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3400 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3410 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3420 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3430 0 0 0 0 0
3440 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3450 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3460 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3470 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3480 0 0 0 0 0 0 0 0 3 3 3 65 64 64 17 18 18
349199 129 48 199 129 48 245 211 23 245 211 23 245 211 23 245 211 23
350245 211 23 244 212 23 245 214 38 245 214 38 142 83 36 142 83 36
351142 83 36 245 211 23 244 210 23 230 165 41 0 0 0 0 0 0
35278 81 81 114 115 115 73 79 79 0 0 0 3 3 3 81 81 82
3539 9 9 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3540 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3550 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3560 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3570 0 0 0 0 0
3580 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3590 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3600 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3610 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3620 0 0 0 0 0 0 0 0 1 1 1 49 50 50 29 29 30
36390 87 86 199 129 48 173 101 51 173 101 51 245 211 23 245 211 23
364245 211 23 230 165 41 142 83 36 142 83 36 142 83 36 245 211 23
365244 210 23 241 205 27 230 165 41 175 173 165 3 3 3 0 0 0
36644 46 46 118 118 118 118 118 118 108 110 110 0 0 0 75 75 76
36728 28 28 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3680 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3690 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3700 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3710 0 0 0 0 0
3720 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3730 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3740 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3750 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3760 0 0 0 0 0 0 0 0 1 1 1 52 53 53 26 26 27
377118 118 118 175 173 165 199 129 48 173 101 51 173 101 51 173 101 51
378173 101 51 142 83 36 173 101 51 245 211 23 244 209 25 238 204 29
379213 157 40 214 196 166 227 227 227 214 214 215 120 121 122 0 0 0
3800 0 0 108 110 110 118 118 118 118 118 118 0 0 0 23 23 23
38166 66 66 4 6 6 0 0 0 0 0 0 0 0 0 0 0 0
3820 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3830 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3840 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3850 0 0 0 0 0
3860 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3870 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3880 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3890 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3900 0 0 0 0 0 0 0 0 7 7 7 75 75 76 4 4 4
391127 127 126 205 205 205 181 181 181 199 129 48 226 179 40 244 209 25
392244 209 25 244 209 25 243 206 27 238 192 33 213 157 40 187 166 103
393234 234 234 248 248 249 251 252 252 248 248 249 214 214 215 0 0 0
3940 0 0 0 0 0 103 103 103 100 103 103 0 0 0 0 0 0
39578 81 81 24 24 24 0 0 0 0 0 0 0 0 0 0 0 0
3960 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3970 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3980 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3990 0 0 0 0 0
4000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4010 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4020 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4030 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4040 0 0 0 0 0 0 0 0 26 27 27 82 82 81 0 0 0
405146 146 147 234 234 234 222 221 221 178 178 179 180 121 62 213 157 40
406213 157 40 213 157 40 201 147 55 180 121 62 219 219 219 243 243 241
407253 253 253 255 255 255 255 255 255 255 255 255 250 250 251 120 121 122
4080 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
40920 20 20 72 71 71 8 8 8 0 0 0 0 0 0 0 0 0
4100 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4110 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4120 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4130 0 0 0 0 0
4140 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4150 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4160 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4170 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4180 0 0 0 0 0 10 10 10 75 75 76 22 22 22 0 0 0
419205 205 205 253 253 253 247 248 249 212 211 212 178 178 179 161 161 162
420165 165 165 181 181 181 205 205 205 227 227 227 244 245 245 254 254 254
421255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 239 239 240
4220 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4230 0 0 67 70 70 39 39 39 2 2 2 0 0 0 0 0 0
4240 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4250 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4260 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4270 0 0 0 0 0
4280 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4290 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4300 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4310 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4320 0 0 4 4 4 50 51 51 60 60 60 0 0 0 16 16 16
433249 250 251 255 255 255 255 255 255 240 240 240 209 210 210 193 193 194
434200 200 197 212 211 212 231 231 231 246 247 248 255 255 255 255 255 255
435255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 253 253 253
436153 154 155 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4370 0 0 3 3 3 84 84 84 20 20 20 0 0 0 0 0 0
4380 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4390 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4400 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4410 0 0 0 0 0
4420 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4430 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4440 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4450 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4462 2 2 33 33 34 81 81 82 0 0 0 0 0 0 231 231 231
447255 255 255 255 255 255 255 255 255 253 253 253 234 234 234 222 221 221
448227 227 227 237 237 238 250 250 251 255 255 255 255 255 255 255 255 255
449255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
450240 240 240 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4510 0 0 0 0 0 26 27 27 72 71 71 8 8 8 0 0 0
4520 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4530 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4540 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4550 0 0 0 0 0
4560 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4570 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4580 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4590 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1
46021 21 22 84 84 84 7 7 7 0 0 0 150 151 151 252 252 252
461255 255 255 255 255 255 255 255 255 255 255 255 252 252 252 244 245 245
462246 247 248 253 253 253 255 255 255 255 255 255 255 255 255 255 255 255
463255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
464251 251 252 9 9 9 0 0 0 0 0 0 0 0 0 0 0 0
4650 0 0 0 0 0 0 0 0 65 64 64 47 47 47 3 3 3
4660 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4670 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4680 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4690 0 0 0 0 0
4700 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4710 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4720 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4730 0 0 0 0 0 0 0 0 0 0 0 0 0 0 12 12 12
47475 75 76 26 26 27 0 0 0 1 1 1 239 239 240 255 255 255
475255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
476255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
477255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
478255 255 255 202 202 203 0 0 0 0 0 0 0 0 0 0 0 0
4790 0 0 0 0 0 0 0 0 0 0 0 84 84 84 28 28 29
4801 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4810 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4820 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4830 0 0 0 0 0
4840 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4850 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4860 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4870 0 0 0 0 0 0 0 0 0 0 0 4 4 4 55 55 55
48860 60 60 0 0 0 0 0 0 95 97 97 248 248 249 255 255 255
489255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
490255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
491255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
492255 255 255 244 245 245 0 0 0 0 0 0 0 0 0 0 0 0
4930 0 0 0 0 0 0 0 0 0 0 0 14 14 14 82 82 81
49415 15 15 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4950 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4960 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4970 0 0 0 0 0
4980 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4990 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5010 0 0 0 0 0 0 0 0 1 1 1 29 29 30 84 84 84
5020 0 0 0 0 0 0 0 0 156 155 156 247 247 246 255 255 255
503255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
504255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
505255 255 255 255 255 255 247 247 246 240 240 240 232 232 233 232 232 233
506243 243 243 253 253 253 53 54 54 0 0 0 0 0 0 0 0 0
5070 0 0 0 0 0 0 0 0 0 0 0 0 0 0 44 44 44
50860 60 60 6 6 6 0 0 0 0 0 0 0 0 0 0 0 0
5090 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5100 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5110 0 0 0 0 0
5120 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5130 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5140 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5150 0 0 0 0 0 0 0 0 10 10 10 81 81 82 14 14 14
5160 0 0 0 0 0 6 6 6 150 151 151 214 214 215 250 251 252
517255 255 255 255 255 255 255 255 255 246 247 248 218 217 217 214 214 215
518218 217 217 244 245 245 255 255 255 255 255 255 255 255 255 250 248 249
519232 232 233 214 214 215 196 196 197 182 183 184 181 181 181 181 181 181
520187 187 188 240 240 240 232 232 233 0 0 0 0 0 0 0 0 0
5210 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
52278 81 81 34 34 35 1 1 1 0 0 0 0 0 0 0 0 0
5230 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5240 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5250 0 0 0 0 0
5260 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5270 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5280 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5290 0 0 0 0 0 1 1 1 39 39 39 74 74 74 0 0 0
5300 0 0 0 0 0 60 60 60 161 161 162 200 200 197 229 229 230
531251 251 252 255 255 255 255 255 255 255 255 255 243 243 241 214 214 215
532248 248 249 255 255 255 255 255 255 255 255 255 255 255 255 254 254 254
533239 239 240 214 214 215 193 193 194 182 183 184 178 178 179 176 177 177
534176 177 177 182 183 184 248 248 249 14 14 14 0 0 0 61 65 66
53510 16 16 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
53610 10 10 84 84 84 13 13 13 0 0 0 0 0 0 0 0 0
5370 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5380 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5390 0 0 0 0 0
5400 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5410 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5420 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5430 0 0 0 0 0 10 11 11 82 82 81 7 7 7 0 0 0
5440 0 0 0 0 0 165 165 165 229 229 230 249 250 251 254 254 254
545255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
546255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
547255 255 255 255 255 255 253 253 253 240 240 240 227 227 227 205 205 205
548181 181 181 176 177 177 191 190 190 227 227 227 0 0 0 44 50 50
54984 89 89 61 65 66 0 0 0 0 0 0 0 0 0 0 0 0
5500 0 0 58 58 58 49 50 50 3 3 3 0 0 0 0 0 0
5510 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5520 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5530 0 0 0 0 0
5540 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5550 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5560 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5570 0 0 1 1 1 36 36 36 66 66 66 0 0 0 29 33 34
5580 3 3 26 27 27 234 234 234 254 254 254 255 255 255 255 255 255
559255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
560254 254 254 253 253 254 252 253 253 253 253 254 253 254 254 253 254 254
561254 254 254 255 255 255 255 255 255 255 255 255 255 255 255 251 251 252
562227 227 227 187 187 188 176 177 177 222 221 221 13 13 13 0 0 0
56312 15 14 73 79 79 36 40 40 0 0 0 0 0 0 0 0 0
5640 0 0 1 1 1 90 87 86 17 18 18 0 0 0 0 0 0
5650 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5660 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5670 0 0 0 0 0
5680 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5690 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5700 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5710 0 0 7 7 7 78 81 81 12 12 12 23 31 30 52 58 58
5720 0 0 209 210 210 253 253 253 255 255 255 255 255 255 255 255 255
573255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 254 254 254
574251 251 252 150 151 151 103 103 103 129 130 130 196 196 197 250 250 251
575252 252 253 254 254 254 255 255 255 255 255 255 255 255 255 255 255 255
576255 255 255 240 240 240 193 193 194 196 196 197 229 229 230 0 0 0
5770 0 0 4 10 10 30 40 40 0 3 3 0 0 0 0 0 0
5780 0 0 0 0 0 47 47 47 53 54 54 3 3 3 0 0 0
5790 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5800 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5810 0 0 0 0 0
5820 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5830 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5840 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5850 0 0 23 23 23 81 81 82 0 0 0 52 58 58 36 40 40
58642 42 43 250 250 251 255 255 255 255 255 255 255 255 255 255 255 255
587255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 254 254 254
588227 227 227 7 7 7 7 7 7 7 7 7 7 7 7 44 44 45
589156 155 156 249 250 251 253 253 253 254 254 254 255 255 255 255 255 255
590255 255 255 255 255 255 247 247 246 222 221 221 239 239 240 0 0 0
59130 40 40 44 50 50 23 31 30 29 33 34 0 0 0 0 0 0
5920 0 0 0 0 0 0 0 0 90 87 86 16 16 16 0 0 0
5930 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5940 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5950 0 0 0 0 0
5960 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5970 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5980 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5992 2 2 50 51 51 42 42 43 29 33 34 52 58 58 0 0 0
600232 232 233 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
601255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 254 254 254
602250 251 252 44 44 44 7 7 7 7 7 7 7 7 7 7 7 7
6037 7 7 56 56 56 209 210 210 252 252 253 254 254 254 255 255 255
604255 255 255 255 255 255 255 255 255 254 253 253 249 250 251 146 146 147
60536 40 40 44 50 50 36 40 40 67 70 70 61 65 66 0 0 0
6060 0 0 0 0 0 0 0 0 55 55 55 44 44 45 1 1 1
6070 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
6080 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
6090 0 0 0 0 0
6100 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
6110 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
6120 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
61310 10 10 81 81 82 1 1 1 52 58 58 44 50 50 52 53 53
614251 251 252 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
615255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 254 254 254
616253 253 253 187 187 188 8 8 8 7 7 7 7 7 7 7 7 7
6177 7 7 7 7 7 19 19 19 178 178 179 252 252 253 254 254 254
618255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 237 237 238
61910 16 16 30 40 40 0 3 3 23 31 30 84 89 89 0 0 0
6200 0 0 0 0 0 0 0 0 3 3 3 81 81 82 9 9 9
6210 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
6220 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
6230 0 0 0 0 0
6240 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
6250 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
6260 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
62729 29 30 72 71 71 10 16 16 52 58 58 0 0 0 222 221 221
628255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
629255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
630254 254 254 251 251 252 95 97 97 7 7 7 7 7 7 7 7 7
6317 7 7 7 7 7 7 7 7 10 10 10 161 161 162 251 252 252
632254 254 254 255 255 255 255 255 255 255 255 255 255 255 255 248 248 249
6330 0 0 0 0 0 0 0 0 0 0 0 84 89 89 0 3 3
6340 0 0 0 0 0 0 0 0 0 0 0 74 74 74 26 27 27
6350 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
6360 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
6370 0 0 0 0 0
6380 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
6390 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
6400 0 0 0 0 0 0 0 0 0 0 0 0 0 0 4 4 4
64165 64 64 20 20 20 20 25 25 30 40 40 0 0 0 247 247 246
642255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
643255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
644255 255 255 253 253 254 222 221 221 9 9 9 7 7 7 7 7 7
6457 7 7 7 7 7 7 7 7 7 7 7 8 8 8 149 149 150
646252 252 253 254 254 254 255 255 255 255 255 255 255 255 255 252 252 252
6470 0 0 0 0 0 0 0 0 0 0 0 73 79 79 12 15 14
6480 0 0 0 0 0 0 0 0 0 0 0 36 36 36 58 58 58
6493 3 3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
6500 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
6510 0 0 0 0 0
6520 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
6530 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
6540 0 0 0 0 0 0 0 0 0 0 0 0 0 0 20 20 20
65574 74 74 0 0 0 4 10 10 4 10 10 36 36 36 252 252 252
656255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
657255 255 255 255 255 255 255 255 255 227 227 227 253 253 253 255 255 255
658255 255 255 254 254 254 250 251 252 65 64 64 7 7 7 7 7 7
6597 7 7 7 7 7 7 7 7 7 7 7 7 7 7 8 8 8
660146 146 147 251 252 252 254 254 254 255 255 255 255 255 255 253 254 254
6610 0 0 0 0 0 0 0 0 0 0 0 52 58 58 10 16 16
6620 0 0 0 0 0 0 0 0 0 0 0 0 0 0 82 82 81
6639 9 9 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
6640 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
6650 0 0 0 0 0
6660 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
6670 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
6680 0 0 0 0 0 0 0 0 0 0 0 4 6 6 65 64 64
66925 25 25 0 3 3 30 40 40 0 0 0 187 187 188 254 254 254
670255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
671255 255 255 255 255 255 255 255 255 193 193 194 253 252 252 255 255 255
672255 255 255 255 255 255 252 253 253 129 130 130 7 7 7 7 7 7
6737 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7
6748 8 8 149 149 150 252 252 253 254 254 254 255 255 255 254 254 254
67552 53 53 0 0 0 0 0 0 0 0 0 20 25 25 2 5 4
6760 0 0 0 0 0 0 0 0 0 0 0 0 0 0 81 81 82
67720 20 20 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
6780 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
6790 0 0 0 0 0
6800 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
6810 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
6820 0 0 0 0 0 0 0 0 0 0 0 26 26 27 81 81 82
6830 0 0 18 21 21 73 79 79 0 0 0 237 237 238 255 255 255
684255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
685255 255 255 255 255 255 255 255 255 182 183 184 255 255 255 255 255 255
686255 255 255 255 255 255 253 253 253 176 177 177 7 7 7 7 7 7
6877 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7
6887 7 7 8 8 8 153 154 155 251 252 252 254 254 254 255 255 255
689150 151 151 0 0 0 0 0 0 0 0 0 20 25 25 0 0 0
6900 0 0 0 0 0 0 0 0 0 0 0 0 0 0 65 64 64
69133 33 34 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
6920 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
6930 0 0 0 0 0
6940 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
6950 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
6960 0 0 0 0 0 0 0 0 6 6 6 67 70 70 20 20 20
6970 0 0 23 31 30 82 85 86 0 0 0 247 247 246 255 255 255
698255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
699255 255 255 255 255 255 255 255 255 182 183 184 255 255 255 255 255 255
700255 255 255 255 255 255 253 254 254 214 214 215 7 7 7 7 7 7
7017 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7
7027 7 7 7 7 7 8 8 8 156 155 156 252 252 253 254 254 254
703167 168 167 0 0 0 0 0 0 0 0 0 67 70 70 0 0 0
7040 0 0 0 0 0 0 0 0 0 0 0 0 0 0 47 47 47
70544 44 44 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
7060 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
7070 0 0 0 0 0
7080 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
7090 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
7100 0 0 0 0 0 0 0 0 21 21 22 75 75 76 0 0 0
7110 0 0 29 33 34 84 89 89 0 0 0 248 248 249 255 255 255
712255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
713255 255 255 255 255 255 248 248 249 181 181 181 255 255 255 255 255 255
714255 255 255 255 255 255 254 254 254 240 240 240 7 7 7 7 7 7
7157 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7
7167 7 7 7 7 7 7 7 7 8 8 8 161 161 162 251 252 252
717185 185 184 4 4 4 0 0 0 10 11 11 100 103 103 0 0 0
7180 0 0 0 0 0 0 0 0 0 0 0 0 0 0 36 36 36
71955 55 55 2 2 2 0 0 0 0 0 0 0 0 0 0 0 0
7200 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
7210 0 0 0 0 0
7220 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
7230 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
7240 0 0 0 0 0 0 0 0 33 33 34 50 51 51 0 0 0
7250 0 0 9 11 11 82 85 86 10 16 16 248 248 249 255 255 255
726255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
727255 255 255 255 255 255 245 244 245 179 180 181 255 255 255 255 255 255
728255 255 255 255 255 255 254 254 254 251 252 252 20 20 20 7 7 7
7297 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7
7307 7 7 7 7 7 7 7 7 7 7 7 10 10 10 161 161 162
731205 205 205 17 18 18 0 0 0 95 97 97 78 81 81 0 0 0
7320 0 0 0 0 0 0 0 0 0 0 0 0 0 0 36 36 36
73353 54 54 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0
7340 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
7350 0 0 0 0 0
7360 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
7370 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
7380 0 0 0 0 0 0 0 0 31 31 31 58 58 58 0 0 0
7390 0 0 0 0 0 67 70 70 78 81 81 248 248 249 255 255 255
740255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
741255 255 255 255 255 255 234 234 234 179 180 181 255 255 255 255 255 255
742255 255 255 255 255 255 254 254 254 251 252 252 23 23 23 7 7 7
7437 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7
74410 11 11 84 84 84 161 161 162 209 210 210 229 229 230 237 237 238
745202 202 203 26 26 27 9 11 11 44 50 50 0 0 0 4 6 6
7460 0 0 0 0 0 0 0 0 0 0 0 0 0 0 52 53 53
74739 39 39 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
7480 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
7490 0 0 0 0 0
7500 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
7510 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
7520 0 0 0 0 0 0 0 0 23 23 23 78 81 81 213 157 40
753243 206 27 243 206 27 54 42 32 73 79 79 222 221 221 255 255 255
754255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
755255 255 255 255 255 255 238 238 236 178 178 179 255 255 255 255 255 255
756255 255 255 255 255 255 254 254 254 251 252 253 36 36 36 7 7 7
7577 7 7 7 7 7 7 7 7 7 7 7 7 7 7 84 84 84
758222 221 221 251 252 252 252 253 253 253 253 253 253 254 254 252 252 253
759146 146 147 140 142 143 156 155 156 110 114 114 26 27 27 82 85 86
76084 89 89 95 97 97 36 40 40 0 0 0 0 0 0 74 74 74
76123 23 23 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
7620 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
7630 0 0 0 0 0
7640 0 0 0 0 0 0 0 0 0 0 0 2 2 2 14 14 14
76524 24 24 26 26 27 26 26 27 26 26 27 25 25 26 21 21 22
7667 7 7 0 0 0 1 1 1 34 34 35 238 192 33 244 210 23
767244 212 23 244 212 23 244 210 23 88 79 47 200 200 197 254 254 254
768255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
769255 255 255 255 255 255 244 245 245 179 180 181 255 255 255 255 255 255
770255 255 255 255 255 255 254 254 254 252 252 253 36 36 36 7 7 7
7717 7 7 7 7 7 7 7 7 8 8 8 149 149 150 251 251 252
772252 252 253 253 253 253 253 253 253 250 248 249 239 223 156 239 223 156
773120 121 122 182 183 184 176 177 177 120 121 122 33 33 34 3 3 3
7740 0 0 67 70 70 146 146 147 20 25 25 1 1 1 82 82 81
7759 9 9 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
7760 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
7770 0 0 0 0 0
7780 0 0 0 0 0 0 0 0 0 0 0 19 19 19 89 90 91
779146 146 147 150 151 151 150 151 151 150 151 151 150 151 151 129 130 130
78058 58 58 6 6 6 14 14 14 201 147 55 245 211 23 245 213 29
781245 214 35 245 215 41 245 213 29 244 210 23 142 83 36 232 232 233
782254 254 254 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
783255 255 255 255 255 255 255 255 255 185 185 184 255 255 255 255 255 255
784255 255 255 255 255 255 254 254 254 251 252 252 50 51 51 7 7 7
7857 7 7 7 7 7 7 7 7 146 146 147 251 252 252 252 253 253
786251 252 253 239 239 240 171 168 154 129 130 130 137 136 134 175 173 165
787221 218 200 65 64 64 22 22 22 186 186 187 114 115 115 26 26 27
7882 2 2 0 0 0 61 65 66 31 33 27 238 192 33 108 96 91
7899 9 9 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
7900 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
7910 0 0 0 0 0
7920 0 0 0 0 0 0 0 0 2 2 2 52 53 53 178 178 179
79321 21 22 7 7 7 7 7 7 7 7 7 7 7 7 118 118 118
794137 136 134 36 36 36 65 64 64 243 206 27 244 212 23 245 215 41
795245 215 41 245 215 41 245 215 41 244 209 25 244 209 25 1 1 1
796219 219 219 253 253 253 255 255 255 255 255 255 255 255 255 255 255 255
797255 255 255 255 255 255 255 255 255 214 214 215 255 255 255 255 255 255
798255 255 255 255 255 255 254 254 254 252 252 253 50 51 51 7 7 7
7997 7 7 7 7 7 84 84 84 250 251 252 252 253 253 251 251 252
800167 168 167 22 22 22 7 7 7 7 7 7 7 7 7 7 7 7
8017 7 7 7 7 7 7 7 7 34 34 35 187 187 188 103 103 103
80229 29 30 3 3 3 7 9 9 238 204 29 245 215 41 245 214 35
80328 28 28 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
8040 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
8050 0 0 0 0 0
8060 0 0 0 0 0 0 0 0 7 7 7 90 87 86 178 178 179
8077 7 7 7 7 7 7 7 7 7 7 7 7 7 7 16 16 16
808193 193 194 133 133 133 187 166 103 245 218 76 245 218 76 245 216 51
809245 216 51 245 218 76 246 224 96 245 218 76 245 218 76 245 218 76
81025 25 25 186 186 187 252 252 252 254 254 254 254 254 254 253 254 254
811254 254 254 254 254 254 254 254 254 246 247 248 254 254 254 253 254 254
812254 254 254 254 254 254 253 254 254 251 252 252 36 36 36 7 7 7
8137 7 7 20 20 20 229 229 230 253 253 253 252 253 253 178 178 179
81410 10 10 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7
8157 7 7 7 7 7 7 7 7 7 7 7 42 42 43 196 196 197
816118 118 118 33 33 34 238 204 29 245 215 41 245 215 41 245 215 41
81749 50 50 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0
8180 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
8190 0 0 0 0 0
8200 0 0 0 0 0 0 0 0 17 18 18 120 121 122 137 136 134
8217 7 7 7 7 7 34 34 35 20 20 20 7 7 7 7 7 7
822202 202 203 209 206 202 193 187 162 193 187 162 248 234 156 245 218 76
823245 218 76 248 234 156 193 187 162 193 187 162 193 187 162 214 196 166
824240 219 129 95 97 97 196 196 197 186 186 187 187 187 188 196 196 197
825252 252 253 251 252 253 212 211 212 187 187 188 196 196 197 251 252 252
826218 217 217 187 187 188 191 190 190 250 251 252 24 24 24 7 7 7
8277 7 7 110 114 114 252 252 253 253 254 254 250 251 252 89 90 91
82889 90 91 129 130 130 127 127 126 44 44 44 7 7 7 7 7 7
8297 7 7 7 7 7 7 7 7 7 7 7 7 7 7 49 50 50
830202 202 203 214 196 166 245 216 51 245 214 38 245 214 35 245 214 38
83158 58 58 2 2 2 0 0 0 0 0 0 0 0 0 0 0 0
8320 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
8330 0 0 0 0 0
8340 0 0 0 0 0 0 0 0 31 31 31 156 155 156 82 82 81
8357 7 7 10 10 10 237 237 238 66 66 66 7 7 7 25 25 25
836247 248 249 81 81 82 7 7 7 31 31 31 247 237 174 245 218 76
837246 226 108 200 200 197 7 7 7 7 7 7 7 7 7 137 136 134
838247 237 174 193 193 194 72 71 71 7 7 7 7 7 7 8 8 8
839196 196 197 250 251 252 67 70 70 7 7 7 84 84 84 244 245 245
84047 47 47 7 7 7 118 118 118 249 250 251 12 12 12 7 7 7
8419 9 9 218 217 217 253 253 253 254 254 254 252 253 253 251 251 252
842249 250 251 237 237 238 95 97 97 9 9 9 15 15 15 95 97 97
84347 47 47 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7
84466 66 66 240 230 197 246 226 108 245 214 38 245 211 23 244 212 23
84565 64 64 3 3 3 0 0 0 0 0 0 0 0 0 0 0 0
8460 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
8470 0 0 0 0 0
8480 0 0 0 0 0 2 2 2 52 53 53 185 185 184 25 25 25
8497 7 7 60 60 60 240 240 240 14 14 14 7 7 7 84 84 84
850247 248 249 23 23 23 7 7 7 94 91 88 248 234 156 245 218 76
851248 234 156 127 127 126 7 7 7 7 7 7 7 7 7 167 168 167
852251 248 240 65 64 64 7 7 7 7 7 7 7 7 7 7 7 7
85384 84 84 243 243 243 15 15 15 7 7 7 140 142 143 146 146 147
8547 7 7 33 33 34 237 237 238 243 243 243 21 21 22 120 121 122
855218 217 217 252 252 253 254 254 254 253 253 254 252 253 253 251 252 252
856247 248 249 72 71 71 7 7 7 58 58 58 222 221 221 248 248 249
85775 75 76 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7
8587 7 7 82 82 81 246 239 193 246 226 108 245 216 51 245 214 38
859238 192 33 21 21 22 1 1 1 0 0 0 0 0 0 0 0 0
8600 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
8610 0 0 0 0 0
8620 0 0 0 0 0 8 8 8 90 87 86 182 183 184 7 7 7
8637 7 7 120 121 122 187 187 188 7 7 7 7 7 7 146 146 147
864205 205 205 7 7 7 7 7 7 153 153 148 240 219 129 246 224 96
865246 239 193 39 39 39 60 60 60 108 110 110 7 7 7 202 202 203
866227 227 227 7 7 7 7 7 7 205 205 205 89 90 91 7 7 7
867120 121 122 193 193 194 7 7 7 7 7 7 186 186 187 25 25 25
8687 7 7 167 168 167 251 251 252 243 243 243 214 214 215 250 251 252
869251 252 253 254 254 254 253 253 253 219 219 219 140 140 139 140 140 139
870118 118 118 7 7 7 52 53 53 237 237 238 247 247 246 176 177 177
8718 8 8 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7
8727 7 7 7 7 7 95 97 97 246 239 193 246 226 108 245 216 51
873245 214 38 201 147 55 31 31 31 103 103 103 103 103 103 72 71 71
8740 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
8750 0 0 0 0 0
8760 0 0 0 0 0 17 18 18 127 127 126 140 140 139 7 7 7
8777 7 7 17 18 18 17 18 18 7 7 7 95 97 97 244 245 245
878146 146 147 7 7 7 7 7 7 200 200 197 246 226 108 240 219 129
879194 194 184 7 7 7 140 140 139 89 90 91 7 7 7 232 232 233
880165 165 165 7 7 7 31 31 31 249 250 251 39 39 39 7 7 7
881176 177 177 133 133 133 7 7 7 22 22 22 108 110 110 7 7 7
88272 71 71 251 252 252 252 253 253 250 251 252 247 248 249 205 205 205
883251 252 253 254 254 254 252 252 253 84 84 84 7 7 7 7 7 7
8847 7 7 7 7 7 140 142 143 247 248 249 140 140 139 14 14 14
8857 7 7 7 7 7 7 7 7 7 7 7 7 7 7 16 16 16
88614 14 14 7 7 7 7 7 7 114 115 115 246 239 193 246 224 96
887245 216 51 245 216 51 243 235 220 176 177 177 185 185 184 229 229 230
88847 47 47 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
8890 0 0 0 0 0
8900 0 0 0 0 0 31 31 31 156 155 156 90 87 86 7 7 7
8917 7 7 7 7 7 7 7 7 31 31 31 243 243 241 247 247 246
89284 84 84 7 7 7 26 27 27 246 239 193 246 226 108 248 234 156
893108 110 110 7 7 7 212 211 212 44 44 44 22 22 22 249 250 251
894108 107 107 7 7 7 89 90 91 238 238 236 114 115 115 118 118 118
895231 231 231 75 75 76 7 7 7 34 34 35 10 11 11 12 12 12
896214 214 215 253 253 253 253 253 253 200 200 197 31 31 31 103 103 103
897252 252 253 252 253 253 218 217 217 9 9 9 7 7 7 7 7 7
8987 7 7 7 7 7 25 25 25 39 39 39 7 7 7 7 7 7
8997 7 7 7 7 7 7 7 7 7 7 7 103 103 103 234 234 234
900181 181 181 7 7 7 7 7 7 7 7 7 133 133 133 247 237 174
901246 224 96 246 226 108 185 185 184 177 177 174 153 154 155 181 181 181
902140 140 139 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
9030 0 0 0 0 0
9040 0 0 1 1 1 49 50 50 186 186 187 28 28 28 7 7 7
90512 12 12 22 22 22 7 7 7 7 7 7 108 107 107 247 247 246
90625 25 25 7 7 7 90 87 86 247 237 174 246 226 108 246 239 193
90728 28 28 44 44 44 237 237 238 9 9 9 53 54 54 249 250 251
90849 50 50 7 7 7 153 153 148 249 241 199 214 196 166 185 185 184
909229 229 230 19 19 19 7 7 7 7 7 7 7 7 7 103 103 103
910251 252 253 254 254 254 253 253 253 150 151 151 7 7 7 187 187 188
911252 252 253 251 251 252 103 103 103 7 7 7 7 7 7 7 7 7
9127 7 7 23 23 23 17 18 18 7 7 7 7 7 7 7 7 7
9137 7 7 7 7 7 12 12 12 153 153 148 246 239 193 249 241 199
914161 161 162 9 9 9 84 84 84 108 110 110 25 25 25 153 153 148
915247 237 174 246 224 96 218 217 217 165 165 165 182 183 184 193 193 194
916114 115 115 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
9170 0 0 0 0 0
9180 0 0 4 4 4 74 74 74 181 181 181 7 7 7 7 7 7
919110 114 114 200 200 197 7 7 7 7 7 7 60 60 60 209 210 210
9207 7 7 7 7 7 146 146 147 248 234 156 248 234 156 177 177 174
9217 7 7 118 118 118 193 193 194 7 7 7 84 84 84 232 232 233
9228 8 8 7 7 7 209 210 210 221 218 200 193 187 162 219 219 219
923200 200 197 7 7 7 7 7 7 7 7 7 7 7 7 95 97 97
924251 252 252 254 254 254 252 253 253 118 118 118 29 29 30 247 248 249
925252 252 253 227 227 227 16 16 16 7 7 7 7 7 7 7 7 7
926100 103 103 218 217 217 219 218 214 7 7 7 7 7 7 7 7 7
9277 7 7 21 21 22 185 185 184 246 239 193 248 234 156 240 230 197
92860 60 60 194 194 184 246 239 193 249 241 199 137 136 134 10 10 10
929171 168 154 248 234 156 248 234 156 226 226 219 209 210 210 249 241 199
93028 28 28 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
9310 0 0 0 0 0
9320 0 0 13 13 13 108 110 110 146 146 147 7 7 7 7 7 7
933167 168 167 140 140 139 7 7 7 7 7 7 120 121 122 146 146 147
9347 7 7 7 7 7 194 194 184 240 219 129 247 237 174 95 97 97
9357 7 7 95 97 97 90 87 86 7 7 7 118 118 118 176 177 177
9367 7 7 28 28 28 248 248 249 44 44 45 7 7 7 167 168 167
937140 140 139 7 7 7 36 36 36 74 74 74 7 7 7 65 64 64
938251 252 253 254 254 254 251 252 252 81 81 82 108 110 110 251 252 252
939251 251 252 127 127 126 7 7 7 7 7 7 8 8 8 140 140 139
940181 181 181 140 140 139 221 218 200 7 7 7 7 7 7 7 7 7
94134 34 35 209 210 210 231 231 231 246 239 193 247 237 174 194 194 184
942227 227 227 249 241 199 240 219 129 248 234 156 153 153 148 7 7 7
94313 13 13 185 185 184 248 234 156 245 218 76 245 216 51 245 214 38
94431 31 31 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
9450 0 0 0 0 0
9460 0 0 31 31 31 153 154 155 89 90 91 7 7 7 8 8 8
947232 232 233 82 82 81 7 7 7 7 7 7 179 180 181 89 90 91
9487 7 7 24 24 24 243 235 220 248 234 156 240 230 197 20 20 20
9497 7 7 7 7 7 7 7 7 7 7 7 149 149 150 118 118 118
9507 7 7 90 87 86 229 229 230 7 7 7 7 7 7 229 229 230
95182 82 81 7 7 7 95 97 97 100 103 103 7 7 7 34 34 35
952251 252 252 253 253 254 251 251 252 47 47 47 193 193 194 251 252 252
953239 239 240 23 23 23 7 7 7 13 13 13 165 165 165 234 234 234
954149 149 150 146 114 101 200 200 197 7 7 7 7 7 7 52 53 53
955227 227 227 167 168 167 16 16 16 214 196 166 248 234 156 243 235 220
956219 219 219 156 155 156 247 237 174 246 239 193 75 75 76 7 7 7
95760 60 60 227 227 227 243 235 220 240 219 129 245 218 76 245 213 29
95816 16 16 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
9590 0 0 0 0 0
9601 1 1 49 50 50 185 185 184 33 33 34 7 7 7 10 11 11
96156 56 56 16 16 16 7 7 7 10 10 10 237 237 238 26 27 27
9627 7 7 55 55 55 185 185 184 221 218 200 167 168 167 7 7 7
96320 20 20 39 39 39 10 11 11 7 7 7 181 181 181 58 58 58
9647 7 7 103 103 103 133 133 133 7 7 7 44 44 44 247 248 249
96524 24 24 7 7 7 156 155 156 129 130 130 7 7 7 9 9 9
966244 245 245 252 253 253 237 237 238 34 34 35 248 248 249 251 251 252
967161 161 162 7 7 7 24 24 24 187 187 188 212 211 212 67 70 70
968187 187 188 173 170 143 209 206 202 10 10 10 95 97 97 237 237 238
969129 130 130 8 8 8 89 90 91 246 239 193 247 237 174 177 177 174
97017 18 18 137 136 134 249 241 199 219 218 214 10 10 10 95 97 97
971243 243 243 150 151 151 31 31 31 221 218 200 240 219 129 53 54 54
9723 3 3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
9730 0 0 0 0 0
9744 4 4 72 71 71 182 183 184 7 7 7 7 7 7 7 7 7
9757 7 7 7 7 7 12 12 12 161 161 162 209 210 210 7 7 7
9767 7 7 7 7 7 7 7 7 187 187 188 82 82 81 7 7 7
977146 146 147 247 248 249 17 18 18 7 7 7 212 211 212 47 47 47
9787 7 7 7 7 7 7 7 7 8 8 8 146 146 147 205 205 205
9797 7 7 7 7 7 214 214 215 156 155 156 7 7 7 7 7 7
980218 217 217 251 252 252 186 186 187 110 114 114 249 250 251 248 248 249
98175 75 76 34 34 35 205 205 205 129 130 130 16 16 16 7 7 7
982156 155 156 214 196 166 240 230 197 243 243 241 227 227 227 74 74 74
9837 7 7 29 29 30 226 226 219 249 241 199 175 173 165 14 14 14
9849 9 9 221 218 200 246 239 193 153 153 148 146 146 147 246 247 248
985110 114 114 7 7 7 7 7 7 42 42 43 193 193 194 95 97 97
98619 19 19 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0
9870 0 0 0 0 0
9886 6 6 84 84 84 140 142 143 7 7 7 7 7 7 7 7 7
9897 7 7 20 20 20 177 177 174 249 241 199 149 149 150 7 7 7
9907 7 7 7 7 7 10 11 11 226 226 219 13 13 13 8 8 8
991219 218 214 219 218 214 7 7 7 8 8 8 238 238 236 200 200 197
99213 13 13 7 7 7 13 13 13 161 161 162 243 235 220 146 146 147
9937 7 7 29 29 30 232 232 233 176 177 177 7 7 7 7 7 7
994182 183 184 237 237 238 129 130 130 167 168 167 176 177 177 202 202 203
99510 11 11 95 97 97 44 44 45 7 7 7 7 7 7 7 7 7
99675 75 76 226 226 219 243 235 220 156 155 156 24 24 24 7 7 7
9977 7 7 176 177 177 247 247 246 200 200 197 17 18 18 7 7 7
99849 50 50 246 239 193 248 234 156 251 248 240 239 239 240 84 84 84
9997 7 7 7 7 7 7 7 7 7 7 7 60 60 60 187 187 188
100084 84 84 14 14 14 0 0 0 0 0 0 0 0 0 0 0 0
10010 0 0 0 0 0
10024 4 4 53 54 54 137 136 134 156 155 156 161 161 162 161 161 162
1003167 168 167 239 223 156 240 219 129 246 226 108 239 223 156 239 223 156
1004239 223 156 239 223 156 214 196 166 239 223 156 193 187 162 193 187 162
1005248 234 156 239 223 156 193 187 162 193 187 162 248 234 156 248 234 156
1006214 196 166 193 187 162 214 196 166 248 234 156 240 219 129 214 196 166
1007193 187 162 193 187 162 171 168 154 146 146 147 137 136 134 137 136 134
1008161 161 162 209 210 210 65 64 64 202 202 203 179 180 181 140 140 139
10097 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7
10107 7 7 60 60 60 39 39 39 7 7 7 7 7 7 7 7 7
101166 66 66 249 250 251 202 202 203 16 16 16 7 7 7 7 7 7
101223 23 23 243 235 220 246 239 193 226 226 219 52 53 53 7 7 7
10137 7 7 7 7 7 7 7 7 7 7 7 7 7 7 75 75 76
1014176 177 177 66 66 66 9 9 9 0 0 0 0 0 0 0 0 0
10150 0 0 0 0 0
10160 0 0 10 10 10 28 28 29 34 34 35 36 36 36 36 36 36
101744 44 45 146 114 101 241 207 50 241 207 50 241 207 50 241 211 63
1018241 211 63 241 211 63 241 211 63 241 211 63 241 211 63 245 216 51
1019245 216 51 245 216 51 241 211 63 241 211 63 245 216 51 241 211 63
1020245 218 76 245 218 76 245 216 51 245 215 41 245 214 38 241 207 50
1021241 211 63 201 147 55 88 79 47 29 29 30 34 34 35 42 42 43
1022103 103 103 191 190 190 75 75 76 196 196 197 200 200 197 65 64 64
10237 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7
10247 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7
102590 87 86 146 146 147 19 19 19 7 7 7 7 7 7 7 7 7
10267 7 7 90 87 86 140 140 139 31 31 31 7 7 7 7 7 7
10277 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7
1028103 103 103 161 161 162 53 54 54 7 7 7 0 0 0 0 0 0
10290 0 0 0 0 0
10300 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
10310 0 0 12 12 12 50 51 51 146 114 101 180 121 62 199 129 48
1032201 147 55 213 157 40 213 157 40 230 165 41 226 179 40 226 179 40
1033238 192 33 241 205 27 244 209 25 244 210 23 244 212 23 245 211 23
1034245 211 23 245 211 23 245 211 23 244 209 25 238 204 29 226 179 40
1035213 157 40 199 129 48 54 42 32 0 0 0 4 6 6 44 44 45
1036150 151 151 129 130 130 137 136 134 205 205 205 202 202 203 8 8 8
10377 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7
10387 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7
10397 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7
10407 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7
10417 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7
10427 7 7 129 130 130 146 146 147 47 47 47 4 4 4 0 0 0
10430 0 0 0 0 0
10440 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
10450 0 0 0 0 0 2 2 2 12 12 12 28 28 29 49 50 50
104674 74 74 108 96 91 180 121 62 180 121 62 199 129 48 201 147 55
1047213 157 40 230 165 41 226 179 40 238 192 33 241 205 27 241 205 27
1048243 206 27 243 206 27 241 205 27 238 204 29 226 179 40 213 157 40
1049199 129 48 199 129 48 21 19 17 65 64 64 103 103 103 167 168 167
1050202 202 203 24 24 24 193 193 194 229 229 230 140 140 139 7 7 7
10517 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7
10527 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7
10537 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7
10547 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7
10557 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7
10567 7 7 8 8 8 156 155 156 133 133 133 36 36 36 3 3 3
10570 0 0 0 0 0
10580 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
10590 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1
10604 4 4 10 11 11 21 21 22 39 39 39 60 60 60 108 96 91
1061180 121 62 199 129 48 199 129 48 213 157 40 230 165 41 226 179 40
1062226 179 40 226 179 40 226 179 40 226 179 40 213 157 40 199 129 48
1063180 121 62 99 91 79 72 71 71 56 56 56 129 130 130 167 168 167
106421 21 22 17 18 18 231 231 231 229 229 230 52 53 53 7 7 7
10657 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7
10667 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7
10677 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7
10687 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7
10697 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7
10707 7 7 7 7 7 13 13 13 176 177 177 120 121 122 33 33 34
10712 2 2 0 0 0
10720 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
10730 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
10740 0 0 0 0 0 0 0 0 0 0 0 2 2 2 8 8 8
107521 21 22 47 47 47 99 91 79 180 121 62 199 129 48 199 129 48
1076201 147 55 213 157 40 213 157 40 201 147 55 199 129 48 180 121 62
107799 91 79 26 26 27 9 9 9 60 60 60 186 186 187 31 31 31
10787 7 7 60 60 60 243 243 243 209 210 210 7 7 7 7 7 7
10797 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7
10807 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7
10817 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7
10827 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7
10837 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7
10847 7 7 7 7 7 7 7 7 26 27 27 193 193 194 108 110 110
108522 22 22 0 0 0
10860 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
10870 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
10880 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
10890 0 0 1 1 1 8 8 8 24 24 24 58 58 58 108 96 91
1090180 121 62 180 121 62 180 121 62 180 121 62 180 121 62 72 71 71
109115 15 15 0 0 0 4 6 6 75 75 76 156 155 156 24 24 24
109224 24 24 108 107 107 232 232 233 137 136 134 24 24 24 24 24 24
109324 24 24 24 24 24 24 24 24 24 24 24 24 24 24 24 24 24
109424 24 24 24 24 24 24 24 24 24 24 24 24 24 24 24 24 24
109524 24 24 24 24 24 24 24 24 24 24 24 24 24 24 24 24 24
109624 24 24 24 24 24 24 24 24 24 24 24 24 24 24 24 24 24
109724 24 24 24 24 24 24 24 24 24 24 24 24 24 24 24 24 24
109824 24 24 24 24 24 24 24 24 24 24 24 58 58 58 176 177 177
109960 60 60 3 3 3
11000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
11010 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
11020 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
11030 0 0 0 0 0 0 0 0 0 0 0 2 2 2 12 12 12
110426 27 27 44 44 44 55 55 55 50 51 51 29 29 30 8 8 8
11050 0 0 0 0 0 3 3 3 47 47 47 127 127 126 150 151 151
1106150 151 151 140 142 143 129 130 130 140 142 143 150 151 151 150 151 151
1107150 151 151 150 151 151 150 151 151 150 151 151 150 151 151 150 151 151
1108150 151 151 150 151 151 153 154 155 161 161 162 165 165 165 167 168 167
1109177 177 174 167 168 167 161 161 162 156 155 156 150 151 151 150 151 151
1110150 151 151 150 151 151 150 151 151 150 151 151 150 151 151 150 151 151
1111150 151 151 150 151 151 150 151 151 150 151 151 150 151 151 150 151 151
1112150 151 151 150 151 151 150 151 151 150 151 151 149 149 150 127 127 126
111344 44 45 2 2 2
11140 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
11150 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
11160 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
11170 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
11180 0 0 0 0 0 2 2 2 1 1 1 0 0 0 0 0 0
11190 0 0 0 0 0 0 0 0 7 7 7 21 21 22 25 25 26
112025 25 26 24 24 24 20 20 20 23 23 24 25 25 26 26 26 27
112126 26 27 26 26 27 26 26 27 26 26 27 26 26 27 26 26 27
112226 26 27 26 26 27 26 26 27 26 26 27 26 26 27 26 27 27
112328 28 29 26 27 27 26 26 27 26 26 27 26 26 27 26 26 27
112426 26 27 26 26 27 26 26 27 26 26 27 26 26 27 26 26 27
112526 26 27 26 26 27 26 26 27 26 26 27 26 26 27 26 26 27
112626 26 27 26 26 27 26 26 27 26 26 27 25 25 26 21 21 22
11277 7 7 0 0 0
diff --git a/drivers/video/logo/logo_blackfin_vga16.ppm b/drivers/video/logo/logo_blackfin_vga16.ppm
new file mode 100644
index 000000000000..1352b02a9d93
--- /dev/null
+++ b/drivers/video/logo/logo_blackfin_vga16.ppm
@@ -0,0 +1,1127 @@
1P3
2# This was generated by the GIMP & Netpbm tools
3# gimp linux_bf.svg (create 80x80 save as linux_bf.ppm)
4# ppmquant -mapfile clut_vga16.ppm linux_bf.ppm | pnmnoraw > logo_blackfin_vga16.ppm
5#
680 80
7255
80 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
90 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
100 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
110 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
120 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
130 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
140 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
150 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
160 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
170 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
180 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
190 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
200 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
210 0 0 0 0 0
220 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
230 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
240 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
250 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
260 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
270 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2885 85 85 85 85 85 85 85 85 85 85 85 85 85 85 85 85 85
290 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
300 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
310 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
320 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
330 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
340 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
350 0 0 0 0 0
360 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
370 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
380 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
390 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
400 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
410 0 0 0 0 0 0 0 0 85 85 85 85 85 85 85 85 85
4285 85 85 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4385 85 85 85 85 85 85 85 85 0 0 0 0 0 0 0 0 0
440 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
450 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
460 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
470 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
480 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
490 0 0 0 0 0
500 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
510 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
520 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
530 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
540 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
550 0 0 0 0 0 85 85 85 85 85 85 0 0 0 0 0 0
560 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
570 0 0 0 0 0 0 0 0 85 85 85 85 85 85 0 0 0
580 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
590 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
600 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
610 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
620 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
630 0 0 0 0 0
640 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
650 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
660 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
670 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
680 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
690 0 0 85 85 85 0 0 0 0 0 0 0 0 0 0 0 0
700 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
710 0 0 0 0 0 0 0 0 0 0 0 0 0 0 85 85 85
720 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
730 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
740 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
750 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
760 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
770 0 0 0 0 0
780 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
790 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
800 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
810 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
820 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
8385 85 85 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
840 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
850 0 0 85 85 85 85 85 85 85 85 85 0 0 0 0 0 0
8685 85 85 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
870 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
880 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
890 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
900 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
910 0 0 0 0 0
920 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
930 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
940 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
950 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
960 0 0 0 0 0 0 0 0 0 0 0 0 0 0 85 85 85
970 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
980 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
990 0 0 170 170 170 170 170 170 85 85 85 0 0 0 0 0 0
1000 0 0 85 85 85 0 0 0 0 0 0 0 0 0 0 0 0
1010 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1020 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1030 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1040 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1050 0 0 0 0 0
1060 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1070 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1080 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1090 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1100 0 0 0 0 0 0 0 0 0 0 0 0 0 0 85 85 85
1110 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1120 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1130 0 0 85 85 85 85 85 85 0 0 0 0 0 0 0 0 0
1140 0 0 85 85 85 85 85 85 0 0 0 0 0 0 0 0 0
1150 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1160 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1170 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1180 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1190 0 0 0 0 0
1200 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1210 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1220 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1230 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1240 0 0 0 0 0 0 0 0 0 0 0 85 85 85 0 0 0
1250 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1260 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1270 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1280 0 0 0 0 0 85 85 85 0 0 0 0 0 0 0 0 0
1290 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1300 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1310 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1320 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1330 0 0 0 0 0
1340 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1350 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1360 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1370 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1380 0 0 0 0 0 0 0 0 0 0 0 85 85 85 0 0 0
1390 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1400 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1410 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1420 0 0 0 0 0 85 85 85 0 0 0 0 0 0 0 0 0
1430 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1440 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1450 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1460 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1470 0 0 0 0 0
1480 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1490 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1500 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1510 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1520 0 0 0 0 0 0 0 0 0 0 0 85 85 85 0 0 0
1530 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1540 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1550 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1560 0 0 0 0 0 0 0 0 85 85 85 0 0 0 0 0 0
1570 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1580 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1590 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1600 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1610 0 0 0 0 0
1620 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1630 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1640 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1650 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1660 0 0 0 0 0 0 0 0 0 0 0 85 85 85 0 0 0
1670 0 0 0 0 0 0 0 0 85 85 85 0 0 0 0 0 0
1680 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1690 0 0 85 85 85 85 85 85 0 0 0 0 0 0 0 0 0
1700 0 0 0 0 0 0 0 0 85 85 85 0 0 0 0 0 0
1710 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1720 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1730 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1740 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1750 0 0 0 0 0
1760 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1770 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1780 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1790 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1800 0 0 0 0 0 0 0 0 0 0 0 85 85 85 0 0 0
1810 0 0 0 0 0 0 0 0 85 85 85 85 85 85 85 85 85
1820 0 0 0 0 0 0 0 0 0 0 0 85 85 85 170 170 170
183170 170 170 85 85 85 85 85 85 170 170 170 0 0 0 0 0 0
1840 0 0 0 0 0 0 0 0 85 85 85 0 0 0 0 0 0
1850 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1860 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1870 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1880 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1890 0 0 0 0 0
1900 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1910 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1920 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1930 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1940 0 0 0 0 0 0 0 0 0 0 0 85 85 85 0 0 0
1950 0 0 170 170 170 170 170 170 170 170 170 85 85 85 85 85 85
1960 0 0 0 0 0 0 0 0 85 85 85 170 170 170 255 255 255
197255 255 255 255 255 255 170 170 170 85 85 85 0 0 0 0 0 0
1980 0 0 0 0 0 0 0 0 85 85 85 0 0 0 0 0 0
1990 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2010 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2020 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2030 0 0 0 0 0
2040 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2050 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2060 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2070 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2080 0 0 0 0 0 0 0 0 0 0 0 85 85 85 0 0 0
209170 170 170 255 255 255 255 255 255 255 255 255 255 255 255 0 0 0
2100 0 0 0 0 0 0 0 0 255 255 255 255 255 255 255 255 255
211255 255 255 255 255 255 255 255 255 170 170 170 0 0 0 0 0 0
2120 0 0 0 0 0 0 0 0 0 0 0 85 85 85 0 0 0
2130 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2140 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2150 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2160 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2170 0 0 0 0 0
2180 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2190 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2200 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2210 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2220 0 0 0 0 0 0 0 0 0 0 0 85 85 85 0 0 0
223255 255 255 170 170 170 85 85 85 170 170 170 255 255 255 255 255 255
2240 0 0 0 0 0 170 170 170 255 255 255 255 255 255 85 85 85
22585 85 85 170 170 170 255 255 255 255 255 255 0 0 0 0 0 0
2260 0 0 0 0 0 0 0 0 0 0 0 85 85 85 0 0 0
2270 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2280 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2290 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2300 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2310 0 0 0 0 0
2320 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2330 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2340 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2350 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2360 0 0 0 0 0 0 0 0 0 0 0 85 85 85 0 0 0
237255 255 255 85 85 85 170 170 170 170 170 170 255 255 255 255 255 255
23885 85 85 85 85 85 170 170 170 255 255 255 170 170 170 0 0 0
239170 170 170 170 170 170 255 255 255 255 255 255 85 85 85 0 0 0
2400 0 0 0 0 0 0 0 0 0 0 0 85 85 85 0 0 0
2410 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2420 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2430 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2440 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2450 0 0 0 0 0
2460 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2470 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2480 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2490 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2500 0 0 0 0 0 0 0 0 0 0 0 85 85 85 0 0 0
251255 255 255 0 0 0 85 85 85 170 170 170 170 170 170 255 255 255
2520 0 0 85 85 85 85 85 85 255 255 255 85 85 85 0 0 0
2530 0 0 85 85 85 170 170 170 255 255 255 85 85 85 0 0 0
2540 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2550 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2560 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2570 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2580 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2590 0 0 0 0 0
2600 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2610 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2620 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2630 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2640 0 0 0 0 0 0 0 0 0 0 0 85 85 85 0 0 0
265255 255 255 85 85 85 0 0 0 0 0 0 255 85 85 255 255 85
266255 255 85 255 255 85 255 255 85 255 255 85 85 85 85 0 0 0
2670 0 0 0 0 0 170 170 170 255 255 255 0 0 0 0 0 0
2680 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2690 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2700 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2710 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2720 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2730 0 0 0 0 0
2740 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2750 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2760 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2770 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2780 0 0 0 0 0 0 0 0 0 0 0 85 85 85 0 0 0
279170 170 170 255 255 255 0 0 0 255 85 85 170 85 0 170 85 0
280255 255 85 255 255 85 170 85 0 255 255 85 255 255 85 255 255 85
2810 0 0 85 85 85 255 255 255 255 255 255 0 0 0 0 0 0
2820 0 0 0 0 0 0 0 0 0 0 0 85 85 85 0 0 0
2830 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2840 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2850 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2860 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2870 0 0 0 0 0
2880 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2890 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2900 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2910 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2920 0 0 0 0 0 0 0 0 0 0 0 85 85 85 0 0 0
2930 0 0 255 255 255 255 85 85 255 255 85 255 255 85 255 255 85
294255 255 85 255 255 85 255 255 85 255 255 85 255 255 85 255 255 85
295255 255 85 255 255 85 255 255 85 170 170 170 0 0 0 0 0 0
2960 0 0 0 0 0 0 0 0 0 0 0 85 85 85 0 0 0
2970 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2980 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2990 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3010 0 0 0 0 0
3020 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3030 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3040 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3050 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3060 0 0 0 0 0 0 0 0 0 0 0 85 85 85 0 0 0
3070 0 0 255 85 85 255 255 85 255 255 85 255 255 85 255 255 85
308255 255 85 255 255 85 255 255 85 255 255 85 255 255 85 255 255 85
309255 255 85 255 255 85 255 255 85 255 255 85 0 0 0 0 0 0
3100 0 0 0 0 0 0 0 0 0 0 0 85 85 85 0 0 0
3110 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3120 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3130 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3140 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3150 0 0 0 0 0
3160 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3170 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3180 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3190 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3200 0 0 0 0 0 0 0 0 0 0 0 85 85 85 0 0 0
321170 85 0 255 255 85 255 255 85 255 255 85 255 255 85 255 255 85
322255 255 85 255 255 85 255 255 85 255 255 85 255 255 85 255 255 85
323255 255 85 170 85 0 85 85 85 255 255 85 0 0 0 0 0 0
3240 0 0 0 0 0 0 0 0 0 0 0 85 85 85 0 0 0
3250 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3260 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3270 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3280 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3290 0 0 0 0 0
3300 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3310 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3320 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3330 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3340 0 0 0 0 0 0 0 0 0 0 0 85 85 85 0 0 0
335255 85 85 255 255 85 255 255 85 255 255 85 255 255 85 255 255 85
336255 255 85 255 255 85 255 255 85 255 255 85 255 255 85 255 255 85
337170 85 0 85 85 85 255 255 85 255 255 85 0 0 0 0 0 0
3380 0 0 0 0 0 0 0 0 0 0 0 85 85 85 85 85 85
3390 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3400 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3410 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3420 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3430 0 0 0 0 0
3440 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3450 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3460 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3470 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3480 0 0 0 0 0 0 0 0 0 0 0 85 85 85 0 0 0
349170 85 0 170 85 0 255 255 85 255 255 85 255 255 85 255 255 85
350255 255 85 255 255 85 255 255 85 255 255 85 170 85 0 170 85 0
351170 85 0 255 255 85 255 255 85 255 85 85 0 0 0 0 0 0
35285 85 85 85 85 85 85 85 85 0 0 0 0 0 0 85 85 85
3530 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3540 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3550 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3560 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3570 0 0 0 0 0
3580 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3590 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3600 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3610 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3620 0 0 0 0 0 0 0 0 0 0 0 85 85 85 0 0 0
36385 85 85 170 85 0 170 85 0 170 85 0 255 255 85 255 255 85
364255 255 85 255 85 85 170 85 0 170 85 0 170 85 0 255 255 85
365255 255 85 255 255 85 255 85 85 170 170 170 0 0 0 0 0 0
36685 85 85 85 85 85 85 85 85 85 85 85 0 0 0 85 85 85
3670 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3680 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3690 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3700 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3710 0 0 0 0 0
3720 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3730 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3740 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3750 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3760 0 0 0 0 0 0 0 0 0 0 0 85 85 85 0 0 0
37785 85 85 170 170 170 170 85 0 170 85 0 170 85 0 170 85 0
378170 85 0 170 85 0 170 85 0 255 255 85 255 255 85 255 255 85
379255 85 85 170 170 170 255 255 255 255 255 255 85 85 85 0 0 0
3800 0 0 85 85 85 85 85 85 85 85 85 0 0 0 0 0 0
38185 85 85 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3820 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3830 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3840 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3850 0 0 0 0 0
3860 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3870 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3880 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3890 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3900 0 0 0 0 0 0 0 0 0 0 0 85 85 85 0 0 0
391170 170 170 170 170 170 170 170 170 170 85 0 255 255 85 255 255 85
392255 255 85 255 255 85 255 255 85 255 255 85 255 85 85 170 170 170
393255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 0 0 0
3940 0 0 0 0 0 85 85 85 85 85 85 0 0 0 0 0 0
39585 85 85 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3960 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3970 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3980 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3990 0 0 0 0 0
4000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4010 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4020 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4030 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4040 0 0 0 0 0 0 0 0 0 0 0 85 85 85 0 0 0
405170 170 170 255 255 255 255 255 255 170 170 170 170 85 0 255 85 85
406255 85 85 255 85 85 255 85 85 255 85 85 255 255 255 255 255 255
407255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 85 85 85
4080 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4090 0 0 85 85 85 0 0 0 0 0 0 0 0 0 0 0 0
4100 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4110 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4120 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4130 0 0 0 0 0
4140 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4150 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4160 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4170 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4180 0 0 0 0 0 0 0 0 85 85 85 0 0 0 0 0 0
419170 170 170 255 255 255 255 255 255 170 170 170 170 170 170 170 170 170
420170 170 170 170 170 170 170 170 170 255 255 255 255 255 255 255 255 255
421255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
4220 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4230 0 0 85 85 85 0 0 0 0 0 0 0 0 0 0 0 0
4240 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4250 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4260 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4270 0 0 0 0 0
4280 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4290 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4300 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4310 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4320 0 0 0 0 0 85 85 85 85 85 85 0 0 0 0 0 0
433255 255 255 255 255 255 255 255 255 255 255 255 170 170 170 170 170 170
434170 170 170 170 170 170 255 255 255 255 255 255 255 255 255 255 255 255
435255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
436170 170 170 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4370 0 0 0 0 0 85 85 85 0 0 0 0 0 0 0 0 0
4380 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4390 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4400 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4410 0 0 0 0 0
4420 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4430 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4440 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4450 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4460 0 0 0 0 0 85 85 85 0 0 0 0 0 0 255 255 255
447255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
448255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
449255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
450255 255 255 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4510 0 0 0 0 0 0 0 0 85 85 85 0 0 0 0 0 0
4520 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4530 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4540 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4550 0 0 0 0 0
4560 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4570 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4580 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4590 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4600 0 0 85 85 85 0 0 0 0 0 0 170 170 170 255 255 255
461255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
462255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
463255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
464255 255 255 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4650 0 0 0 0 0 0 0 0 85 85 85 85 85 85 0 0 0
4660 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4670 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4680 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4690 0 0 0 0 0
4700 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4710 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4720 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4730 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
47485 85 85 0 0 0 0 0 0 0 0 0 255 255 255 255 255 255
475255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
476255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
477255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
478255 255 255 170 170 170 0 0 0 0 0 0 0 0 0 0 0 0
4790 0 0 0 0 0 0 0 0 0 0 0 85 85 85 0 0 0
4800 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4810 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4820 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4830 0 0 0 0 0
4840 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4850 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4860 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4870 0 0 0 0 0 0 0 0 0 0 0 0 0 0 85 85 85
48885 85 85 0 0 0 0 0 0 85 85 85 255 255 255 255 255 255
489255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
490255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
491255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
492255 255 255 255 255 255 0 0 0 0 0 0 0 0 0 0 0 0
4930 0 0 0 0 0 0 0 0 0 0 0 0 0 0 85 85 85
4940 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4950 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4960 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4970 0 0 0 0 0
4980 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4990 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5010 0 0 0 0 0 0 0 0 0 0 0 0 0 0 85 85 85
5020 0 0 0 0 0 0 0 0 170 170 170 255 255 255 255 255 255
503255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
504255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
505255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
506255 255 255 255 255 255 85 85 85 0 0 0 0 0 0 0 0 0
5070 0 0 0 0 0 0 0 0 0 0 0 0 0 0 85 85 85
50885 85 85 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5090 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5100 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5110 0 0 0 0 0
5120 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5130 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5140 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5150 0 0 0 0 0 0 0 0 0 0 0 85 85 85 0 0 0
5160 0 0 0 0 0 0 0 0 170 170 170 255 255 255 255 255 255
517255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
518255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
519255 255 255 255 255 255 170 170 170 170 170 170 170 170 170 170 170 170
520170 170 170 255 255 255 255 255 255 0 0 0 0 0 0 0 0 0
5210 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
52285 85 85 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5230 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5240 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5250 0 0 0 0 0
5260 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5270 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5280 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5290 0 0 0 0 0 0 0 0 0 0 0 85 85 85 0 0 0
5300 0 0 0 0 0 85 85 85 170 170 170 170 170 170 255 255 255
531255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
532255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
533255 255 255 255 255 255 170 170 170 170 170 170 170 170 170 170 170 170
534170 170 170 170 170 170 255 255 255 0 0 0 0 0 0 85 85 85
5350 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5360 0 0 85 85 85 0 0 0 0 0 0 0 0 0 0 0 0
5370 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5380 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5390 0 0 0 0 0
5400 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5410 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5420 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5430 0 0 0 0 0 0 0 0 85 85 85 0 0 0 0 0 0
5440 0 0 0 0 0 170 170 170 255 255 255 255 255 255 255 255 255
545255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
546255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
547255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 170 170 170
548170 170 170 170 170 170 170 170 170 255 255 255 0 0 0 85 85 85
54985 85 85 85 85 85 0 0 0 0 0 0 0 0 0 0 0 0
5500 0 0 85 85 85 85 85 85 0 0 0 0 0 0 0 0 0
5510 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5520 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5530 0 0 0 0 0
5540 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5550 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5560 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5570 0 0 0 0 0 0 0 0 85 85 85 0 0 0 0 0 0
5580 0 0 0 0 0 255 255 255 255 255 255 255 255 255 255 255 255
559255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
560255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
561255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
562255 255 255 170 170 170 170 170 170 255 255 255 0 0 0 0 0 0
5630 0 0 85 85 85 0 0 0 0 0 0 0 0 0 0 0 0
5640 0 0 0 0 0 85 85 85 0 0 0 0 0 0 0 0 0
5650 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5660 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5670 0 0 0 0 0
5680 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5690 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5700 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5710 0 0 0 0 0 85 85 85 0 0 0 0 0 0 85 85 85
5720 0 0 170 170 170 255 255 255 255 255 255 255 255 255 255 255 255
573255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
574255 255 255 170 170 170 85 85 85 170 170 170 170 170 170 255 255 255
575255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
576255 255 255 255 255 255 170 170 170 170 170 170 255 255 255 0 0 0
5770 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5780 0 0 0 0 0 85 85 85 85 85 85 0 0 0 0 0 0
5790 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5800 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5810 0 0 0 0 0
5820 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5830 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5840 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5850 0 0 0 0 0 85 85 85 0 0 0 85 85 85 0 0 0
5860 0 0 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
587255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
588255 255 255 0 0 0 0 0 0 0 0 0 0 0 0 85 85 85
589170 170 170 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
590255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 0 0 0
5910 0 0 85 85 85 0 0 0 0 0 0 0 0 0 0 0 0
5920 0 0 0 0 0 0 0 0 85 85 85 0 0 0 0 0 0
5930 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5940 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5950 0 0 0 0 0
5960 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5970 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5980 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5990 0 0 85 85 85 0 0 0 0 0 0 85 85 85 0 0 0
600255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
601255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
602255 255 255 85 85 85 0 0 0 0 0 0 0 0 0 0 0 0
6030 0 0 85 85 85 170 170 170 255 255 255 255 255 255 255 255 255
604255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 170 170 170
6050 0 0 85 85 85 0 0 0 85 85 85 85 85 85 0 0 0
6060 0 0 0 0 0 0 0 0 85 85 85 85 85 85 0 0 0
6070 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
6080 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
6090 0 0 0 0 0
6100 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
6110 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
6120 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
6130 0 0 85 85 85 0 0 0 85 85 85 85 85 85 85 85 85
614255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
615255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
616255 255 255 170 170 170 0 0 0 0 0 0 0 0 0 0 0 0
6170 0 0 0 0 0 0 0 0 170 170 170 255 255 255 255 255 255
618255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
6190 0 0 0 0 0 0 0 0 0 0 0 85 85 85 0 0 0
6200 0 0 0 0 0 0 0 0 0 0 0 85 85 85 0 0 0
6210 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
6220 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
6230 0 0 0 0 0
6240 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
6250 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
6260 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
6270 0 0 85 85 85 0 0 0 85 85 85 0 0 0 255 255 255
628255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
629255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
630255 255 255 255 255 255 85 85 85 0 0 0 0 0 0 0 0 0
6310 0 0 0 0 0 0 0 0 0 0 0 170 170 170 255 255 255
632255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
6330 0 0 0 0 0 0 0 0 0 0 0 85 85 85 0 0 0
6340 0 0 0 0 0 0 0 0 0 0 0 85 85 85 0 0 0
6350 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
6360 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
6370 0 0 0 0 0
6380 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
6390 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
6400 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
64185 85 85 0 0 0 0 0 0 0 0 0 0 0 0 255 255 255
642255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
643255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
644255 255 255 255 255 255 255 255 255 0 0 0 0 0 0 0 0 0
6450 0 0 0 0 0 0 0 0 0 0 0 0 0 0 170 170 170
646255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
6470 0 0 0 0 0 0 0 0 0 0 0 85 85 85 0 0 0
6480 0 0 0 0 0 0 0 0 0 0 0 0 0 0 85 85 85
6490 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
6500 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
6510 0 0 0 0 0
6520 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
6530 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
6540 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
65585 85 85 0 0 0 0 0 0 0 0 0 0 0 0 255 255 255
656255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
657255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
658255 255 255 255 255 255 255 255 255 85 85 85 0 0 0 0 0 0
6590 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
660170 170 170 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
6610 0 0 0 0 0 0 0 0 0 0 0 85 85 85 0 0 0
6620 0 0 0 0 0 0 0 0 0 0 0 0 0 0 85 85 85
6630 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
6640 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
6650 0 0 0 0 0
6660 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
6670 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
6680 0 0 0 0 0 0 0 0 0 0 0 0 0 0 85 85 85
6690 0 0 0 0 0 0 0 0 0 0 0 170 170 170 255 255 255
670255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
671255 255 255 255 255 255 255 255 255 170 170 170 255 255 255 255 255 255
672255 255 255 255 255 255 255 255 255 170 170 170 0 0 0 0 0 0
6730 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
6740 0 0 170 170 170 255 255 255 255 255 255 255 255 255 255 255 255
67585 85 85 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
6760 0 0 0 0 0 0 0 0 0 0 0 0 0 0 85 85 85
6770 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
6780 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
6790 0 0 0 0 0
6800 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
6810 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
6820 0 0 0 0 0 0 0 0 0 0 0 0 0 0 85 85 85
6830 0 0 0 0 0 85 85 85 0 0 0 255 255 255 255 255 255
684255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
685255 255 255 255 255 255 255 255 255 170 170 170 255 255 255 255 255 255
686255 255 255 255 255 255 255 255 255 170 170 170 0 0 0 0 0 0
6870 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
6880 0 0 0 0 0 170 170 170 255 255 255 255 255 255 255 255 255
689170 170 170 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
6900 0 0 0 0 0 0 0 0 0 0 0 0 0 0 85 85 85
6910 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
6920 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
6930 0 0 0 0 0
6940 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
6950 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
6960 0 0 0 0 0 0 0 0 0 0 0 85 85 85 0 0 0
6970 0 0 0 0 0 85 85 85 0 0 0 255 255 255 255 255 255
698255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
699255 255 255 255 255 255 255 255 255 170 170 170 255 255 255 255 255 255
700255 255 255 255 255 255 255 255 255 255 255 255 0 0 0 0 0 0
7010 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
7020 0 0 0 0 0 0 0 0 170 170 170 255 255 255 255 255 255
703170 170 170 0 0 0 0 0 0 0 0 0 85 85 85 0 0 0
7040 0 0 0 0 0 0 0 0 0 0 0 0 0 0 85 85 85
70585 85 85 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
7060 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
7070 0 0 0 0 0
7080 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
7090 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
7100 0 0 0 0 0 0 0 0 0 0 0 85 85 85 0 0 0
7110 0 0 0 0 0 85 85 85 0 0 0 255 255 255 255 255 255
712255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
713255 255 255 255 255 255 255 255 255 170 170 170 255 255 255 255 255 255
714255 255 255 255 255 255 255 255 255 255 255 255 0 0 0 0 0 0
7150 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
7160 0 0 0 0 0 0 0 0 0 0 0 170 170 170 255 255 255
717170 170 170 0 0 0 0 0 0 0 0 0 85 85 85 0 0 0
7180 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
71985 85 85 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
7200 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
7210 0 0 0 0 0
7220 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
7230 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
7240 0 0 0 0 0 0 0 0 0 0 0 85 85 85 0 0 0
7250 0 0 0 0 0 85 85 85 0 0 0 255 255 255 255 255 255
726255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
727255 255 255 255 255 255 255 255 255 170 170 170 255 255 255 255 255 255
728255 255 255 255 255 255 255 255 255 255 255 255 0 0 0 0 0 0
7290 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
7300 0 0 0 0 0 0 0 0 0 0 0 0 0 0 170 170 170
731170 170 170 0 0 0 0 0 0 85 85 85 85 85 85 0 0 0
7320 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
73385 85 85 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
7340 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
7350 0 0 0 0 0
7360 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
7370 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
7380 0 0 0 0 0 0 0 0 0 0 0 85 85 85 0 0 0
7390 0 0 0 0 0 85 85 85 85 85 85 255 255 255 255 255 255
740255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
741255 255 255 255 255 255 255 255 255 170 170 170 255 255 255 255 255 255
742255 255 255 255 255 255 255 255 255 255 255 255 0 0 0 0 0 0
7430 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
7440 0 0 85 85 85 170 170 170 170 170 170 255 255 255 255 255 255
745170 170 170 0 0 0 0 0 0 85 85 85 0 0 0 0 0 0
7460 0 0 0 0 0 0 0 0 0 0 0 0 0 0 85 85 85
7470 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
7480 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
7490 0 0 0 0 0
7500 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
7510 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
7520 0 0 0 0 0 0 0 0 0 0 0 85 85 85 170 85 0
753255 255 85 255 255 85 0 0 0 85 85 85 255 255 255 255 255 255
754255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
755255 255 255 255 255 255 255 255 255 170 170 170 255 255 255 255 255 255
756255 255 255 255 255 255 255 255 255 255 255 255 0 0 0 0 0 0
7570 0 0 0 0 0 0 0 0 0 0 0 0 0 0 85 85 85
758255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
759170 170 170 170 170 170 170 170 170 85 85 85 0 0 0 85 85 85
76085 85 85 85 85 85 0 0 0 0 0 0 0 0 0 85 85 85
7610 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
7620 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
7630 0 0 0 0 0
7640 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
7650 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
7660 0 0 0 0 0 0 0 0 0 0 0 255 255 85 255 255 85
767255 255 85 255 255 85 255 255 85 85 85 85 170 170 170 255 255 255
768255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
769255 255 255 255 255 255 255 255 255 170 170 170 255 255 255 255 255 255
770255 255 255 255 255 255 255 255 255 255 255 255 0 0 0 0 0 0
7710 0 0 0 0 0 0 0 0 0 0 0 170 170 170 255 255 255
772255 255 255 255 255 255 255 255 255 255 255 255 255 255 85 170 170 170
77385 85 85 170 170 170 170 170 170 85 85 85 0 0 0 0 0 0
7740 0 0 85 85 85 170 170 170 0 0 0 0 0 0 85 85 85
7750 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
7760 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
7770 0 0 0 0 0
7780 0 0 0 0 0 0 0 0 0 0 0 0 0 0 85 85 85
779170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170
78085 85 85 0 0 0 0 0 0 170 85 0 255 255 85 255 255 85
781255 255 85 255 255 85 255 255 85 255 255 85 170 85 0 255 255 255
782255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
783255 255 255 255 255 255 255 255 255 170 170 170 255 255 255 255 255 255
784255 255 255 255 255 255 255 255 255 255 255 255 85 85 85 0 0 0
7850 0 0 0 0 0 0 0 0 170 170 170 255 255 255 255 255 255
786255 255 255 255 255 255 170 170 170 170 170 170 170 170 170 170 170 170
787255 255 255 85 85 85 0 0 0 170 170 170 85 85 85 0 0 0
7880 0 0 0 0 0 85 85 85 0 0 0 255 255 85 85 85 85
7890 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
7900 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
7910 0 0 0 0 0
7920 0 0 0 0 0 0 0 0 0 0 0 85 85 85 170 170 170
7930 0 0 0 0 0 0 0 0 0 0 0 0 0 0 85 85 85
794170 170 170 0 0 0 85 85 85 255 255 85 255 255 85 255 255 85
795255 255 85 255 255 85 255 255 85 255 255 85 255 255 85 0 0 0
796255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
797255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
798255 255 255 255 255 255 255 255 255 255 255 255 85 85 85 0 0 0
7990 0 0 0 0 0 85 85 85 255 255 255 255 255 255 255 255 255
800170 170 170 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
8010 0 0 0 0 0 0 0 0 0 0 0 170 170 170 85 85 85
8020 0 0 0 0 0 0 0 0 255 255 85 255 255 85 255 255 85
8030 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
8040 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
8050 0 0 0 0 0
8060 0 0 0 0 0 0 0 0 0 0 0 85 85 85 170 170 170
8070 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
808170 170 170 170 170 170 255 255 85 255 255 85 255 255 85 255 255 85
809255 255 85 255 255 85 255 255 85 255 255 85 255 255 85 255 255 85
8100 0 0 170 170 170 255 255 255 255 255 255 255 255 255 255 255 255
811255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
812255 255 255 255 255 255 255 255 255 255 255 255 0 0 0 0 0 0
8130 0 0 0 0 0 255 255 255 255 255 255 255 255 255 170 170 170
8140 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
8150 0 0 0 0 0 0 0 0 0 0 0 0 0 0 170 170 170
81685 85 85 0 0 0 255 255 85 255 255 85 255 255 85 255 255 85
81785 85 85 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
8180 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
8190 0 0 0 0 0
8200 0 0 0 0 0 0 0 0 0 0 0 85 85 85 170 170 170
8210 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
822170 170 170 170 170 170 170 170 170 170 170 170 255 255 85 255 255 85
823255 255 85 255 255 85 170 170 170 170 170 170 170 170 170 170 170 170
824255 255 85 85 85 85 170 170 170 170 170 170 170 170 170 170 170 170
825255 255 255 255 255 255 170 170 170 170 170 170 170 170 170 255 255 255
826255 255 255 170 170 170 170 170 170 255 255 255 0 0 0 0 0 0
8270 0 0 85 85 85 255 255 255 255 255 255 255 255 255 85 85 85
82885 85 85 170 170 170 170 170 170 85 85 85 0 0 0 0 0 0
8290 0 0 0 0 0 0 0 0 0 0 0 0 0 0 85 85 85
830170 170 170 170 170 170 255 255 85 255 255 85 255 255 85 255 255 85
83185 85 85 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
8320 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
8330 0 0 0 0 0
8340 0 0 0 0 0 0 0 0 0 0 0 170 170 170 85 85 85
8350 0 0 0 0 0 255 255 255 85 85 85 0 0 0 0 0 0
836255 255 255 85 85 85 0 0 0 0 0 0 255 255 255 255 255 85
837255 255 85 170 170 170 0 0 0 0 0 0 0 0 0 170 170 170
838255 255 255 170 170 170 85 85 85 0 0 0 0 0 0 0 0 0
839170 170 170 255 255 255 85 85 85 0 0 0 85 85 85 255 255 255
84085 85 85 0 0 0 85 85 85 255 255 255 0 0 0 0 0 0
8410 0 0 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
842255 255 255 255 255 255 85 85 85 0 0 0 0 0 0 85 85 85
84385 85 85 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
84485 85 85 255 255 255 255 255 85 255 255 85 255 255 85 255 255 85
84585 85 85 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
8460 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
8470 0 0 0 0 0
8480 0 0 0 0 0 0 0 0 85 85 85 170 170 170 0 0 0
8490 0 0 85 85 85 255 255 255 0 0 0 0 0 0 85 85 85
850255 255 255 0 0 0 0 0 0 85 85 85 255 255 85 255 255 85
851255 255 85 85 85 85 0 0 0 0 0 0 0 0 0 170 170 170
852255 255 255 85 85 85 0 0 0 0 0 0 0 0 0 0 0 0
85385 85 85 255 255 255 0 0 0 0 0 0 170 170 170 170 170 170
8540 0 0 0 0 0 255 255 255 255 255 255 0 0 0 85 85 85
855255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
856255 255 255 85 85 85 0 0 0 85 85 85 255 255 255 255 255 255
85785 85 85 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
8580 0 0 85 85 85 255 255 255 255 255 85 255 255 85 255 255 85
859255 255 85 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
8600 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
8610 0 0 0 0 0
8620 0 0 0 0 0 0 0 0 85 85 85 170 170 170 0 0 0
8630 0 0 85 85 85 170 170 170 0 0 0 0 0 0 170 170 170
864170 170 170 0 0 0 0 0 0 170 170 170 255 255 85 255 255 85
865255 255 255 0 0 0 85 85 85 85 85 85 0 0 0 170 170 170
866255 255 255 0 0 0 0 0 0 170 170 170 85 85 85 0 0 0
86785 85 85 170 170 170 0 0 0 0 0 0 170 170 170 0 0 0
8680 0 0 170 170 170 255 255 255 255 255 255 255 255 255 255 255 255
869255 255 255 255 255 255 255 255 255 255 255 255 170 170 170 170 170 170
87085 85 85 0 0 0 85 85 85 255 255 255 255 255 255 170 170 170
8710 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
8720 0 0 0 0 0 85 85 85 255 255 255 255 255 85 255 255 85
873255 255 85 170 85 0 0 0 0 85 85 85 85 85 85 85 85 85
8740 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
8750 0 0 0 0 0
8760 0 0 0 0 0 0 0 0 85 85 85 170 170 170 0 0 0
8770 0 0 0 0 0 0 0 0 0 0 0 85 85 85 255 255 255
878170 170 170 0 0 0 0 0 0 170 170 170 255 255 85 255 255 85
879170 170 170 0 0 0 170 170 170 85 85 85 0 0 0 255 255 255
880170 170 170 0 0 0 0 0 0 255 255 255 0 0 0 0 0 0
881170 170 170 170 170 170 0 0 0 0 0 0 85 85 85 0 0 0
88285 85 85 255 255 255 255 255 255 255 255 255 255 255 255 170 170 170
883255 255 255 255 255 255 255 255 255 85 85 85 0 0 0 0 0 0
8840 0 0 0 0 0 170 170 170 255 255 255 170 170 170 0 0 0
8850 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
8860 0 0 0 0 0 0 0 0 85 85 85 255 255 255 255 255 85
887255 255 85 255 255 85 255 255 255 170 170 170 170 170 170 255 255 255
88885 85 85 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
8890 0 0 0 0 0
8900 0 0 0 0 0 0 0 0 170 170 170 85 85 85 0 0 0
8910 0 0 0 0 0 0 0 0 0 0 0 255 255 255 255 255 255
89285 85 85 0 0 0 0 0 0 255 255 255 255 255 85 255 255 85
89385 85 85 0 0 0 255 255 255 85 85 85 0 0 0 255 255 255
89485 85 85 0 0 0 85 85 85 255 255 255 85 85 85 85 85 85
895255 255 255 85 85 85 0 0 0 0 0 0 0 0 0 0 0 0
896255 255 255 255 255 255 255 255 255 170 170 170 0 0 0 85 85 85
897255 255 255 255 255 255 255 255 255 0 0 0 0 0 0 0 0 0
8980 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
8990 0 0 0 0 0 0 0 0 0 0 0 85 85 85 255 255 255
900170 170 170 0 0 0 0 0 0 0 0 0 170 170 170 255 255 255
901255 255 85 255 255 85 170 170 170 170 170 170 170 170 170 170 170 170
902170 170 170 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
9030 0 0 0 0 0
9040 0 0 0 0 0 85 85 85 170 170 170 0 0 0 0 0 0
9050 0 0 0 0 0 0 0 0 0 0 0 85 85 85 255 255 255
9060 0 0 0 0 0 85 85 85 255 255 85 255 255 85 255 255 255
9070 0 0 85 85 85 255 255 255 0 0 0 85 85 85 255 255 255
90885 85 85 0 0 0 170 170 170 255 255 255 170 170 170 170 170 170
909255 255 255 0 0 0 0 0 0 0 0 0 0 0 0 85 85 85
910255 255 255 255 255 255 255 255 255 170 170 170 0 0 0 170 170 170
911255 255 255 255 255 255 85 85 85 0 0 0 0 0 0 0 0 0
9120 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
9130 0 0 0 0 0 0 0 0 170 170 170 255 255 255 255 255 255
914170 170 170 0 0 0 85 85 85 85 85 85 0 0 0 170 170 170
915255 255 85 255 255 85 255 255 255 170 170 170 170 170 170 170 170 170
91685 85 85 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
9170 0 0 0 0 0
9180 0 0 0 0 0 85 85 85 170 170 170 0 0 0 0 0 0
91985 85 85 170 170 170 0 0 0 0 0 0 85 85 85 170 170 170
9200 0 0 0 0 0 170 170 170 255 255 85 255 255 85 170 170 170
9210 0 0 85 85 85 170 170 170 0 0 0 85 85 85 255 255 255
9220 0 0 0 0 0 170 170 170 170 170 170 170 170 170 255 255 255
923170 170 170 0 0 0 0 0 0 0 0 0 0 0 0 85 85 85
924255 255 255 255 255 255 255 255 255 85 85 85 0 0 0 255 255 255
925255 255 255 255 255 255 0 0 0 0 0 0 0 0 0 0 0 0
92685 85 85 255 255 255 255 255 255 0 0 0 0 0 0 0 0 0
9270 0 0 0 0 0 170 170 170 255 255 255 255 255 85 255 255 255
92885 85 85 170 170 170 255 255 255 255 255 255 170 170 170 0 0 0
929170 170 170 255 255 85 255 255 85 255 255 255 170 170 170 255 255 255
9300 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
9310 0 0 0 0 0
9320 0 0 0 0 0 85 85 85 170 170 170 0 0 0 0 0 0
933170 170 170 170 170 170 0 0 0 0 0 0 85 85 85 170 170 170
9340 0 0 0 0 0 170 170 170 255 255 85 255 255 255 85 85 85
9350 0 0 85 85 85 85 85 85 0 0 0 85 85 85 170 170 170
9360 0 0 0 0 0 255 255 255 85 85 85 0 0 0 170 170 170
937170 170 170 0 0 0 0 0 0 85 85 85 0 0 0 85 85 85
938255 255 255 255 255 255 255 255 255 85 85 85 85 85 85 255 255 255
939255 255 255 85 85 85 0 0 0 0 0 0 0 0 0 170 170 170
940170 170 170 170 170 170 255 255 255 0 0 0 0 0 0 0 0 0
9410 0 0 170 170 170 255 255 255 255 255 255 255 255 85 170 170 170
942255 255 255 255 255 255 255 255 85 255 255 85 170 170 170 0 0 0
9430 0 0 170 170 170 255 255 85 255 255 85 255 255 85 255 255 85
9440 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
9450 0 0 0 0 0
9460 0 0 0 0 0 170 170 170 85 85 85 0 0 0 0 0 0
947255 255 255 85 85 85 0 0 0 0 0 0 170 170 170 85 85 85
9480 0 0 0 0 0 255 255 255 255 255 85 255 255 255 0 0 0
9490 0 0 0 0 0 0 0 0 0 0 0 170 170 170 85 85 85
9500 0 0 85 85 85 255 255 255 0 0 0 0 0 0 255 255 255
95185 85 85 0 0 0 85 85 85 85 85 85 0 0 0 0 0 0
952255 255 255 255 255 255 255 255 255 85 85 85 170 170 170 255 255 255
953255 255 255 0 0 0 0 0 0 0 0 0 170 170 170 255 255 255
954170 170 170 85 85 85 170 170 170 0 0 0 0 0 0 85 85 85
955255 255 255 170 170 170 0 0 0 170 170 170 255 255 85 255 255 255
956255 255 255 170 170 170 255 255 255 255 255 255 85 85 85 0 0 0
95785 85 85 255 255 255 255 255 255 255 255 85 255 255 85 255 255 85
9580 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
9590 0 0 0 0 0
9600 0 0 85 85 85 170 170 170 0 0 0 0 0 0 0 0 0
96185 85 85 0 0 0 0 0 0 0 0 0 255 255 255 0 0 0
9620 0 0 85 85 85 170 170 170 255 255 255 170 170 170 0 0 0
9630 0 0 0 0 0 0 0 0 0 0 0 170 170 170 85 85 85
9640 0 0 85 85 85 170 170 170 0 0 0 85 85 85 255 255 255
9650 0 0 0 0 0 170 170 170 170 170 170 0 0 0 0 0 0
966255 255 255 255 255 255 255 255 255 0 0 0 255 255 255 255 255 255
967170 170 170 0 0 0 0 0 0 170 170 170 255 255 255 85 85 85
968170 170 170 170 170 170 170 170 170 0 0 0 85 85 85 255 255 255
969170 170 170 0 0 0 85 85 85 255 255 255 255 255 85 170 170 170
9700 0 0 170 170 170 255 255 255 255 255 255 0 0 0 85 85 85
971255 255 255 170 170 170 0 0 0 170 170 170 255 255 85 85 85 85
9720 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
9730 0 0 0 0 0
9740 0 0 85 85 85 170 170 170 0 0 0 0 0 0 0 0 0
9750 0 0 0 0 0 0 0 0 170 170 170 170 170 170 0 0 0
9760 0 0 0 0 0 0 0 0 170 170 170 85 85 85 0 0 0
977170 170 170 255 255 255 0 0 0 0 0 0 170 170 170 85 85 85
9780 0 0 0 0 0 0 0 0 0 0 0 170 170 170 170 170 170
9790 0 0 0 0 0 255 255 255 170 170 170 0 0 0 0 0 0
980255 255 255 255 255 255 170 170 170 85 85 85 255 255 255 255 255 255
98185 85 85 0 0 0 170 170 170 170 170 170 0 0 0 0 0 0
982170 170 170 170 170 170 255 255 255 255 255 255 255 255 255 85 85 85
9830 0 0 0 0 0 255 255 255 255 255 255 170 170 170 0 0 0
9840 0 0 170 170 170 255 255 255 170 170 170 170 170 170 255 255 255
98585 85 85 0 0 0 0 0 0 0 0 0 170 170 170 85 85 85
9860 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
9870 0 0 0 0 0
9880 0 0 85 85 85 170 170 170 0 0 0 0 0 0 0 0 0
9890 0 0 0 0 0 170 170 170 255 255 255 170 170 170 0 0 0
9900 0 0 0 0 0 0 0 0 255 255 255 0 0 0 0 0 0
991255 255 255 255 255 255 0 0 0 0 0 0 255 255 255 170 170 170
9920 0 0 0 0 0 0 0 0 170 170 170 255 255 255 170 170 170
9930 0 0 0 0 0 255 255 255 170 170 170 0 0 0 0 0 0
994170 170 170 255 255 255 170 170 170 170 170 170 170 170 170 170 170 170
9950 0 0 85 85 85 85 85 85 0 0 0 0 0 0 0 0 0
99685 85 85 255 255 255 255 255 255 170 170 170 0 0 0 0 0 0
9970 0 0 170 170 170 255 255 255 170 170 170 0 0 0 0 0 0
99885 85 85 255 255 255 255 255 85 255 255 255 255 255 255 85 85 85
9990 0 0 0 0 0 0 0 0 0 0 0 85 85 85 170 170 170
100085 85 85 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
10010 0 0 0 0 0
10020 0 0 85 85 85 170 170 170 170 170 170 170 170 170 170 170 170
1003170 170 170 170 170 170 255 255 85 255 255 85 255 255 85 170 170 170
1004170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170
1005255 255 85 170 170 170 170 170 170 170 170 170 255 255 85 255 255 85
1006170 170 170 170 170 170 170 170 170 255 255 85 255 255 85 170 170 170
1007170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170
1008170 170 170 170 170 170 85 85 85 170 170 170 170 170 170 170 170 170
10090 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
10100 0 0 85 85 85 0 0 0 0 0 0 0 0 0 0 0 0
101185 85 85 255 255 255 170 170 170 0 0 0 0 0 0 0 0 0
10120 0 0 255 255 255 255 255 255 255 255 255 85 85 85 0 0 0
10130 0 0 0 0 0 0 0 0 0 0 0 0 0 0 85 85 85
1014170 170 170 85 85 85 0 0 0 0 0 0 0 0 0 0 0 0
10150 0 0 0 0 0
10160 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
101785 85 85 85 85 85 255 255 85 255 255 85 255 255 85 255 255 85
1018255 255 85 255 255 85 255 255 85 255 255 85 255 255 85 255 255 85
1019255 255 85 255 255 85 255 255 85 255 255 85 255 255 85 255 255 85
1020255 255 85 255 255 85 255 255 85 255 255 85 255 255 85 255 255 85
1021255 255 85 255 85 85 85 85 85 0 0 0 0 0 0 0 0 0
102285 85 85 170 170 170 85 85 85 170 170 170 170 170 170 85 85 85
10230 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
10240 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
102585 85 85 170 170 170 0 0 0 0 0 0 0 0 0 0 0 0
10260 0 0 85 85 85 170 170 170 0 0 0 0 0 0 0 0 0
10270 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
102885 85 85 170 170 170 85 85 85 0 0 0 0 0 0 0 0 0
10290 0 0 0 0 0
10300 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
10310 0 0 0 0 0 85 85 85 85 85 85 170 85 0 170 85 0
1032170 85 0 255 85 85 255 85 85 255 85 85 255 255 85 255 255 85
1033255 255 85 255 255 85 255 255 85 255 255 85 255 255 85 255 255 85
1034255 255 85 255 255 85 255 255 85 255 255 85 255 255 85 255 255 85
1035255 85 85 170 85 0 85 85 85 0 0 0 0 0 0 85 85 85
1036170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 0 0 0
10370 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
10380 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
10390 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
10400 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
10410 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
10420 0 0 170 170 170 170 170 170 85 85 85 0 0 0 0 0 0
10430 0 0 0 0 0
10440 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
10450 0 0 0 0 0 0 0 0 0 0 0 0 0 0 85 85 85
104685 85 85 85 85 85 170 85 0 170 85 0 170 85 0 170 85 0
1047255 85 85 255 85 85 255 255 85 255 255 85 255 255 85 255 255 85
1048255 255 85 255 255 85 255 255 85 255 255 85 255 255 85 255 85 85
1049170 85 0 170 85 0 0 0 0 85 85 85 85 85 85 170 170 170
1050170 170 170 0 0 0 170 170 170 255 255 255 170 170 170 0 0 0
10510 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
10520 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
10530 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
10540 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
10550 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
10560 0 0 0 0 0 170 170 170 170 170 170 0 0 0 0 0 0
10570 0 0 0 0 0
10580 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
10590 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
10600 0 0 0 0 0 0 0 0 0 0 0 85 85 85 85 85 85
1061170 85 0 170 85 0 170 85 0 255 85 85 255 85 85 255 255 85
1062255 255 85 255 255 85 255 255 85 255 255 85 255 85 85 170 85 0
1063170 85 0 85 85 85 85 85 85 85 85 85 170 170 170 170 170 170
10640 0 0 0 0 0 255 255 255 255 255 255 85 85 85 0 0 0
10650 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
10660 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
10670 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
10680 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
10690 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
10700 0 0 0 0 0 0 0 0 170 170 170 85 85 85 0 0 0
10710 0 0 0 0 0
10720 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
10730 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
10740 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
10750 0 0 85 85 85 85 85 85 170 85 0 170 85 0 170 85 0
1076170 85 0 255 85 85 255 85 85 255 85 85 170 85 0 170 85 0
107785 85 85 0 0 0 0 0 0 85 85 85 170 170 170 0 0 0
10780 0 0 85 85 85 255 255 255 170 170 170 0 0 0 0 0 0
10790 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
10800 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
10810 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
10820 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
10830 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
10840 0 0 0 0 0 0 0 0 0 0 0 170 170 170 85 85 85
10850 0 0 0 0 0
10860 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
10870 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
10880 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
10890 0 0 0 0 0 0 0 0 0 0 0 85 85 85 85 85 85
1090170 85 0 170 85 0 170 85 0 170 85 0 170 85 0 85 85 85
10910 0 0 0 0 0 0 0 0 85 85 85 170 170 170 0 0 0
10920 0 0 85 85 85 255 255 255 170 170 170 0 0 0 0 0 0
10930 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
10940 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
10950 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
10960 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
10970 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
10980 0 0 0 0 0 0 0 0 0 0 0 85 85 85 170 170 170
109985 85 85 0 0 0
11000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
11010 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
11020 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
11030 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
11040 0 0 85 85 85 85 85 85 85 85 85 0 0 0 0 0 0
11050 0 0 0 0 0 0 0 0 85 85 85 85 85 85 170 170 170
1106170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170
1107170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170
1108170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170
1109170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170
1110170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170
1111170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170
1112170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 85 85 85
111385 85 85 0 0 0
11140 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
11150 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
11160 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
11170 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
11180 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
11190 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
11200 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
11210 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
11220 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
11230 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
11240 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
11250 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
11260 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
11270 0 0 0 0 0
diff --git a/drivers/video/pnx4008/pnxrgbfb.c b/drivers/video/pnx4008/pnxrgbfb.c
index 685761a0732c..4db6b48a8715 100644
--- a/drivers/video/pnx4008/pnxrgbfb.c
+++ b/drivers/video/pnx4008/pnxrgbfb.c
@@ -100,7 +100,6 @@ static int rgbfb_remove(struct platform_device *pdev)
100 fb_dealloc_cmap(&info->cmap); 100 fb_dealloc_cmap(&info->cmap);
101 framebuffer_release(info); 101 framebuffer_release(info);
102 platform_set_drvdata(pdev, NULL); 102 platform_set_drvdata(pdev, NULL);
103 kfree(info);
104 } 103 }
105 104
106 pnx4008_free_dum_channel(channel_owned, pdev->id); 105 pnx4008_free_dum_channel(channel_owned, pdev->id);
@@ -168,23 +167,21 @@ static int __devinit rgbfb_probe(struct platform_device *pdev)
168 167
169 ret = fb_alloc_cmap(&info->cmap, 256, 0); 168 ret = fb_alloc_cmap(&info->cmap, 256, 0);
170 if (ret < 0) 169 if (ret < 0)
171 goto err2; 170 goto err1;
172 171
173 ret = register_framebuffer(info); 172 ret = register_framebuffer(info);
174 if (ret < 0) 173 if (ret < 0)
175 goto err3; 174 goto err2;
176 platform_set_drvdata(pdev, info); 175 platform_set_drvdata(pdev, info);
177 176
178 return 0; 177 return 0;
179 178
180err3:
181 fb_dealloc_cmap(&info->cmap);
182err2: 179err2:
183 framebuffer_release(info); 180 fb_dealloc_cmap(&info->cmap);
184err1: 181err1:
185 pnx4008_free_dum_channel(channel_owned, pdev->id); 182 pnx4008_free_dum_channel(channel_owned, pdev->id);
186err0: 183err0:
187 kfree(info); 184 framebuffer_release(info);
188err: 185err:
189 return ret; 186 return ret;
190} 187}
diff --git a/drivers/video/tridentfb.c b/drivers/video/tridentfb.c
index bd54cd0de39a..beefab2992c0 100644
--- a/drivers/video/tridentfb.c
+++ b/drivers/video/tridentfb.c
@@ -27,7 +27,6 @@
27#define VERSION "0.7.8-NEWAPI" 27#define VERSION "0.7.8-NEWAPI"
28 28
29struct tridentfb_par { 29struct tridentfb_par {
30 int vclk; /* in MHz */
31 void __iomem *io_virt; /* iospace virtual memory address */ 30 void __iomem *io_virt; /* iospace virtual memory address */
32}; 31};
33 32
@@ -669,27 +668,26 @@ static void set_screen_start(int base)
669 (read3X4(CRTHiOrd) & 0xF8) | ((base & 0xE0000) >> 17)); 668 (read3X4(CRTHiOrd) & 0xF8) | ((base & 0xE0000) >> 17));
670} 669}
671 670
672/* Use 20.12 fixed-point for NTSC value and frequency calculation */
673#define calc_freq(n, m, k) ( ((unsigned long)0xE517 * (n + 8) / ((m + 2) * (1 << k))) >> 12 )
674
675/* Set dotclock frequency */ 671/* Set dotclock frequency */
676static void set_vclk(int freq) 672static void set_vclk(unsigned long freq)
677{ 673{
678 int m, n, k; 674 int m, n, k;
679 int f, fi, d, di; 675 unsigned long f, fi, d, di;
680 unsigned char lo = 0, hi = 0; 676 unsigned char lo = 0, hi = 0;
681 677
682 d = 20; 678 d = 20000;
683 for (k = 2; k >= 0; k--) 679 for (k = 2; k >= 0; k--)
684 for (m = 0; m < 63; m++) 680 for (m = 0; m < 63; m++)
685 for (n = 0; n < 128; n++) { 681 for (n = 0; n < 128; n++) {
686 fi = calc_freq(n, m, k); 682 fi = ((14318l * (n + 8)) / (m + 2)) >> k;
687 if ((di = abs(fi - freq)) < d) { 683 if ((di = abs(fi - freq)) < d) {
688 d = di; 684 d = di;
689 f = fi; 685 f = fi;
690 lo = n; 686 lo = n;
691 hi = (k << 6) | m; 687 hi = (k << 6) | m;
692 } 688 }
689 if (fi > freq)
690 break;
693 } 691 }
694 if (chip3D) { 692 if (chip3D) {
695 write3C4(ClockHigh, hi); 693 write3C4(ClockHigh, hi);
@@ -888,6 +886,8 @@ static int tridentfb_set_par(struct fb_info *info)
888 struct fb_var_screeninfo *var = &info->var; 886 struct fb_var_screeninfo *var = &info->var;
889 int bpp = var->bits_per_pixel; 887 int bpp = var->bits_per_pixel;
890 unsigned char tmp; 888 unsigned char tmp;
889 unsigned long vclk;
890
891 debug("enter\n"); 891 debug("enter\n");
892 hdispend = var->xres / 8 - 1; 892 hdispend = var->xres / 8 - 1;
893 hsyncstart = (var->xres + var->right_margin) / 8; 893 hsyncstart = (var->xres + var->right_margin) / 8;
@@ -905,7 +905,6 @@ static int tridentfb_set_par(struct fb_info *info)
905 vblankstart = var->yres; 905 vblankstart = var->yres;
906 vblankend = vtotal + 2; 906 vblankend = vtotal + 2;
907 907
908 enable_mmio();
909 crtc_unlock(); 908 crtc_unlock();
910 write3CE(CyberControl, 8); 909 write3CE(CyberControl, 8);
911 910
@@ -1015,11 +1014,11 @@ static int tridentfb_set_par(struct fb_info *info)
1015 write3X4(Performance, 0x92); 1014 write3X4(Performance, 0x92);
1016 write3X4(PCIReg, 0x07); /* MMIO & PCI read and write burst enable */ 1015 write3X4(PCIReg, 0x07); /* MMIO & PCI read and write burst enable */
1017 1016
1018 /* convert from picoseconds to MHz */ 1017 /* convert from picoseconds to kHz */
1019 par->vclk = 1000000 / info->var.pixclock; 1018 vclk = PICOS2KHZ(info->var.pixclock);
1020 if (bpp == 32) 1019 if (bpp == 32)
1021 par->vclk *= 2; 1020 vclk *= 2;
1022 set_vclk(par->vclk); 1021 set_vclk(vclk);
1023 1022
1024 write3C4(0, 3); 1023 write3C4(0, 3);
1025 write3C4(1, 1); /* set char clock 8 dots wide */ 1024 write3C4(1, 1); /* set char clock 8 dots wide */