aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorJiri Kosina <jkosina@suse.cz>2010-08-04 09:14:38 -0400
committerJiri Kosina <jkosina@suse.cz>2010-08-04 09:14:38 -0400
commitd790d4d583aeaed9fc6f8a9f4d9f8ce6b1c15c7f (patch)
tree854ab394486288d40fa8179cbfaf66e8bdc44b0f /drivers
parent73b2c7165b76b20eb1290e7efebc33cfd21db1ca (diff)
parent3a09b1be53d23df780a0cd0e4087a05e2ca4a00c (diff)
Merge branch 'master' into for-next
Diffstat (limited to 'drivers')
-rw-r--r--drivers/acpi/acpi_pad.c36
-rw-r--r--drivers/acpi/acpica/acconfig.h4
-rw-r--r--drivers/acpi/acpica/acevents.h4
-rw-r--r--drivers/acpi/acpica/acglobal.h8
-rw-r--r--drivers/acpi/acpica/achware.h6
-rw-r--r--drivers/acpi/acpica/evgpe.c115
-rw-r--r--drivers/acpi/acpica/evgpeblk.c14
-rw-r--r--drivers/acpi/acpica/evxface.c7
-rw-r--r--drivers/acpi/acpica/evxfevnt.c78
-rw-r--r--drivers/acpi/acpica/exsystem.c8
-rw-r--r--drivers/acpi/acpica/hwgpe.c94
-rw-r--r--drivers/acpi/acpica/hwvalid.c12
-rw-r--r--drivers/acpi/acpica/nsinit.c9
-rw-r--r--drivers/acpi/apei/apei-base.c1
-rw-r--r--drivers/acpi/apei/erst.c2
-rw-r--r--drivers/acpi/atomicio.c1
-rw-r--r--drivers/acpi/battery.c8
-rw-r--r--drivers/acpi/blacklist.c10
-rw-r--r--drivers/acpi/button.c4
-rw-r--r--drivers/acpi/fan.c3
-rw-r--r--drivers/acpi/processor_core.c2
-rw-r--r--drivers/acpi/processor_driver.c5
-rw-r--r--drivers/acpi/processor_idle.c10
-rw-r--r--drivers/acpi/sleep.c63
-rw-r--r--drivers/acpi/system.c6
-rw-r--r--drivers/acpi/wakeup.c20
-rw-r--r--drivers/amba/bus.c88
-rw-r--r--drivers/ata/ahci.c10
-rw-r--r--drivers/ata/ata_generic.c30
-rw-r--r--drivers/ata/libahci.c5
-rw-r--r--drivers/base/core.c2
-rw-r--r--drivers/block/cciss_scsi.c1
-rw-r--r--drivers/block/cpqarray.c6
-rw-r--r--drivers/block/drbd/drbd_main.c2
-rw-r--r--drivers/block/drbd/drbd_nl.c6
-rw-r--r--drivers/bluetooth/bluecard_cs.c2
-rw-r--r--drivers/bluetooth/hci_bcsp.c2
-rw-r--r--drivers/char/agp/generic.c6
-rw-r--r--drivers/char/agp/intel-gtt.c13
-rw-r--r--drivers/char/ipmi/ipmi_si_intf.c23
-rw-r--r--drivers/char/sysrq.c10
-rw-r--r--drivers/char/tpm/tpm.h1
-rw-r--r--drivers/char/tpm/tpm_tis.c9
-rw-r--r--drivers/clocksource/cs5535-clockevt.c2
-rw-r--r--drivers/clocksource/sh_cmt.c2
-rw-r--r--drivers/cpufreq/cpufreq.c12
-rw-r--r--drivers/cpuidle/governors/menu.c4
-rw-r--r--drivers/crypto/talitos.c6
-rw-r--r--drivers/dma/ppc4xx/adma.c4
-rw-r--r--drivers/edac/Kconfig2
-rw-r--r--drivers/edac/amd64_edac.c24
-rw-r--r--drivers/edac/i7core_edac.c55
-rw-r--r--drivers/edac/mpc85xx_edac.c4
-rw-r--r--drivers/gpio/Kconfig2
-rw-r--r--drivers/gpio/Makefile6
-rw-r--r--drivers/gpio/cs5535-gpio.c2
-rw-r--r--drivers/gpio/gpiolib.c7
-rw-r--r--drivers/gpio/pl061.c4
-rw-r--r--drivers/gpu/drm/drm_edid.c4
-rw-r--r--drivers/gpu/drm/drm_fb_helper.c42
-rw-r--r--drivers/gpu/drm/i915/dvo_tfp410.c2
-rw-r--r--drivers/gpu/drm/i915/i915_debugfs.c5
-rw-r--r--drivers/gpu/drm/i915/i915_dma.c10
-rw-r--r--drivers/gpu/drm/i915/i915_drv.h8
-rw-r--r--drivers/gpu/drm/i915/i915_gem.c18
-rw-r--r--drivers/gpu/drm/i915/i915_irq.c76
-rw-r--r--drivers/gpu/drm/i915/i915_reg.h70
-rw-r--r--drivers/gpu/drm/i915/intel_crt.c6
-rw-r--r--drivers/gpu/drm/i915/intel_display.c169
-rw-r--r--drivers/gpu/drm/i915/intel_dp.c80
-rw-r--r--drivers/gpu/drm/i915/intel_drv.h4
-rw-r--r--drivers/gpu/drm/i915/intel_fb.c4
-rw-r--r--drivers/gpu/drm/i915/intel_lvds.c27
-rw-r--r--drivers/gpu/drm/i915/intel_ringbuffer.c10
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_bios.c33
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_fbcon.c3
-rw-r--r--drivers/gpu/drm/radeon/atombios_crtc.c2
-rw-r--r--drivers/gpu/drm/radeon/evergreen.c35
-rw-r--r--drivers/gpu/drm/radeon/evergreen_cs.c6
-rw-r--r--drivers/gpu/drm/radeon/evergreend.h3
-rw-r--r--drivers/gpu/drm/radeon/r100.c84
-rw-r--r--drivers/gpu/drm/radeon/r200.c5
-rw-r--r--drivers/gpu/drm/radeon/r300.c8
-rw-r--r--drivers/gpu/drm/radeon/r520.c1
-rw-r--r--drivers/gpu/drm/radeon/r600.c18
-rw-r--r--drivers/gpu/drm/radeon/r600_blit.c5
-rw-r--r--drivers/gpu/drm/radeon/r600_cs.c3
-rw-r--r--drivers/gpu/drm/radeon/radeon.h5
-rw-r--r--drivers/gpu/drm/radeon/radeon_asic.c7
-rw-r--r--drivers/gpu/drm/radeon/radeon_atombios.c20
-rw-r--r--drivers/gpu/drm/radeon/radeon_bios.c4
-rw-r--r--drivers/gpu/drm/radeon/radeon_combios.c57
-rw-r--r--drivers/gpu/drm/radeon/radeon_connectors.c27
-rw-r--r--drivers/gpu/drm/radeon/radeon_cursor.c2
-rw-r--r--drivers/gpu/drm/radeon/radeon_device.c15
-rw-r--r--drivers/gpu/drm/radeon/radeon_encoders.c4
-rw-r--r--drivers/gpu/drm/radeon/radeon_kms.c3
-rw-r--r--drivers/gpu/drm/radeon/radeon_legacy_encoders.c23
-rw-r--r--drivers/gpu/drm/radeon/radeon_legacy_tv.c4
-rw-r--r--drivers/gpu/drm/radeon/radeon_mode.h1
-rw-r--r--drivers/gpu/drm/radeon/radeon_pm.c42
-rw-r--r--drivers/gpu/drm/radeon/reg_srcs/evergreen10
-rw-r--r--drivers/gpu/drm/radeon/rs400.c5
-rw-r--r--drivers/gpu/drm/radeon/rs600.c1
-rw-r--r--drivers/gpu/drm/radeon/rs690.c42
-rw-r--r--drivers/gpu/drm/radeon/rv515.c1
-rw-r--r--drivers/gpu/drm/radeon/rv770.c2
-rw-r--r--drivers/gpu/drm/ttm/ttm_page_alloc.c76
-rw-r--r--drivers/gpu/drm/vmwgfx/vmwgfx_kms.c1
-rw-r--r--drivers/hid/Kconfig1
-rw-r--r--drivers/hid/hid-core.c21
-rw-r--r--drivers/hid/hid-debug.c2
-rw-r--r--drivers/hid/hid-ids.h21
-rw-r--r--drivers/hid/hid-ntrig.c36
-rw-r--r--drivers/hid/usbhid/hid-core.c13
-rw-r--r--drivers/hid/usbhid/hid-quirks.c2
-rw-r--r--drivers/hwmon/coretemp.c32
-rw-r--r--drivers/hwmon/i5k_amb.c6
-rw-r--r--drivers/hwmon/it87.c22
-rw-r--r--drivers/hwmon/k10temp.c14
-rw-r--r--drivers/hwmon/k8temp.c12
-rw-r--r--drivers/i2c/busses/i2c-i801.c8
-rw-r--r--drivers/i2c/busses/i2c-sibyte.c4
-rw-r--r--drivers/i2c/i2c-core.c7
-rw-r--r--drivers/infiniband/hw/cxgb4/cm.c12
-rw-r--r--drivers/infiniband/hw/cxgb4/cq.c31
-rw-r--r--drivers/infiniband/hw/cxgb4/iw_cxgb4.h2
-rw-r--r--drivers/infiniband/hw/cxgb4/mem.c4
-rw-r--r--drivers/infiniband/hw/cxgb4/qp.c12
-rw-r--r--drivers/infiniband/hw/cxgb4/t4.h6
-rw-r--r--drivers/infiniband/hw/qib/Makefile2
-rw-r--r--drivers/infiniband/hw/qib/qib.h1
-rw-r--r--drivers/infiniband/hw/qib/qib_7220.h7
-rw-r--r--drivers/infiniband/hw/qib/qib_7322_regs.h48
-rw-r--r--drivers/infiniband/hw/qib/qib_diag.c19
-rw-r--r--drivers/infiniband/hw/qib/qib_iba6120.c3
-rw-r--r--drivers/infiniband/hw/qib/qib_iba7322.c43
-rw-r--r--drivers/infiniband/hw/qib/qib_init.c21
-rw-r--r--drivers/infiniband/hw/qib/qib_pcie.c2
-rw-r--r--drivers/infiniband/hw/qib/qib_sd7220.c56
-rw-r--r--drivers/infiniband/hw/qib/qib_sd7220_img.c1081
-rw-r--r--drivers/infiniband/hw/qib/qib_tx.c6
-rw-r--r--drivers/infiniband/ulp/ipoib/ipoib_main.c4
-rw-r--r--drivers/input/joystick/gamecon.c5
-rw-r--r--drivers/input/keyboard/Kconfig4
-rw-r--r--drivers/input/keyboard/twl4030_keypad.c17
-rw-r--r--drivers/input/keyboard/w90p910_keypad.c2
-rw-r--r--drivers/input/misc/pcf8574_keypad.c2
-rw-r--r--drivers/input/mouse/Kconfig2
-rw-r--r--drivers/input/mouse/synaptics.c8
-rw-r--r--drivers/input/mouse/synaptics.h3
-rw-r--r--drivers/input/serio/i8042-x86ia64io.h17
-rw-r--r--drivers/input/tablet/wacom_wac.c9
-rw-r--r--drivers/input/touchscreen/ad7877.c7
-rw-r--r--drivers/input/touchscreen/w90p910_ts.c2
-rw-r--r--drivers/isdn/gigaset/asyncdata.c44
-rw-r--r--drivers/isdn/gigaset/capi.c405
-rw-r--r--drivers/isdn/gigaset/common.c36
-rw-r--r--drivers/isdn/gigaset/ev-layer.c4
-rw-r--r--drivers/isdn/gigaset/gigaset.h38
-rw-r--r--drivers/isdn/gigaset/i4l.c21
-rw-r--r--drivers/isdn/gigaset/isocdata.c72
-rw-r--r--drivers/isdn/hysdn/hysdn_net.c3
-rw-r--r--drivers/leds/Kconfig9
-rw-r--r--drivers/leds/Makefile1
-rw-r--r--drivers/leds/leds-ns2.c338
-rw-r--r--drivers/md/md.c38
-rw-r--r--drivers/md/md.h3
-rw-r--r--drivers/md/raid0.c21
-rw-r--r--drivers/md/raid0.h3
-rw-r--r--drivers/md/raid10.c46
-rw-r--r--drivers/md/raid10.h5
-rw-r--r--drivers/md/raid5.c150
-rw-r--r--drivers/media/common/tuners/tuner-simple.c1
-rw-r--r--drivers/media/common/tuners/tuner-types.c16
-rw-r--r--drivers/media/video/Kconfig13
-rw-r--r--drivers/media/video/Makefile1
-rw-r--r--drivers/media/video/ivtv/ivtv-streams.c3
-rw-r--r--drivers/media/video/mem2mem_testdev.c3
-rw-r--r--drivers/media/video/mx2_camera.c1513
-rw-r--r--drivers/media/video/omap/Kconfig4
-rw-r--r--drivers/media/video/omap/Makefile4
-rw-r--r--drivers/media/video/omap/omap_vout.c81
-rw-r--r--drivers/media/video/tveeprom.c15
-rw-r--r--drivers/media/video/uvc/uvc_ctrl.c4
-rw-r--r--drivers/misc/Kconfig10
-rw-r--r--drivers/misc/Makefile1
-rw-r--r--drivers/misc/arm-charlcd.c396
-rw-r--r--drivers/misc/cs5535-mfgpt.c2
-rw-r--r--drivers/mmc/host/mmci.c156
-rw-r--r--drivers/mmc/host/mmci.h39
-rw-r--r--drivers/mmc/host/mxcmmc.c48
-rw-r--r--drivers/mmc/host/sdhci-s3c.c20
-rw-r--r--drivers/mtd/nand/mxc_nand.c33
-rw-r--r--drivers/mtd/ubi/build.c3
-rw-r--r--drivers/mtd/ubi/eba.c49
-rw-r--r--drivers/mtd/ubi/io.c60
-rw-r--r--drivers/mtd/ubi/scan.c131
-rw-r--r--drivers/mtd/ubi/scan.h19
-rw-r--r--drivers/mtd/ubi/ubi.h10
-rw-r--r--drivers/net/Kconfig2
-rw-r--r--drivers/net/bnx2.c11
-rw-r--r--drivers/net/bnx2x.h4
-rw-r--r--drivers/net/bnx2x_main.c42
-rw-r--r--drivers/net/bonding/bond_alb.c5
-rw-r--r--drivers/net/bonding/bond_main.c33
-rw-r--r--drivers/net/cnic.c55
-rw-r--r--drivers/net/cpmac.c3
-rw-r--r--drivers/net/declance.c6
-rw-r--r--drivers/net/e1000/e1000_main.c17
-rw-r--r--drivers/net/ehea/ehea.h2
-rw-r--r--drivers/net/ehea/ehea_main.c9
-rw-r--r--drivers/net/enic/vnic_dev.c2
-rw-r--r--drivers/net/gianfar.c25
-rw-r--r--drivers/net/ibmveth.c4
-rw-r--r--drivers/net/igb/igb_main.c9
-rw-r--r--drivers/net/ixgbe/ixgbe_ethtool.c37
-rw-r--r--drivers/net/ixgbe/ixgbe_main.c30
-rw-r--r--drivers/net/ixgbe/ixgbe_phy.c2
-rw-r--r--drivers/net/lib82596.c2
-rw-r--r--drivers/net/ll_temac_main.c18
-rw-r--r--drivers/net/macvlan.c10
-rw-r--r--drivers/net/macvtap.c18
-rw-r--r--drivers/net/mipsnet.c2
-rw-r--r--drivers/net/mv643xx_eth.c9
-rw-r--r--drivers/net/ne.c4
-rw-r--r--drivers/net/netxen/netxen_nic_ctx.c3
-rw-r--r--drivers/net/netxen/netxen_nic_hw.c4
-rw-r--r--drivers/net/netxen/netxen_nic_init.c13
-rw-r--r--drivers/net/pcmcia/axnet_cs.c7
-rw-r--r--drivers/net/pcmcia/pcnet_cs.c1
-rw-r--r--drivers/net/pcmcia/smc91c92_cs.c18
-rw-r--r--drivers/net/phy/lxt.c1
-rw-r--r--drivers/net/phy/marvell.c38
-rw-r--r--drivers/net/qlge/qlge_main.c11
-rw-r--r--drivers/net/r8169.c2
-rw-r--r--drivers/net/s2io.c101
-rw-r--r--drivers/net/s2io.h6
-rw-r--r--drivers/net/sb1250-mac.c1
-rw-r--r--drivers/net/sky2.c19
-rw-r--r--drivers/net/tulip/de2104x.c5
-rw-r--r--drivers/net/tun.c14
-rw-r--r--drivers/net/ucc_geth.c2
-rw-r--r--drivers/net/usb/hso.c1
-rw-r--r--drivers/net/usb/rndis_host.c18
-rw-r--r--drivers/net/usb/usbnet.c5
-rw-r--r--drivers/net/virtio_net.c28
-rw-r--r--drivers/net/vxge/vxge-main.c33
-rw-r--r--drivers/net/wimax/i2400m/i2400m-usb.h1
-rw-r--r--drivers/net/wimax/i2400m/usb.c2
-rw-r--r--drivers/net/wireless/ath/ath5k/attach.c1
-rw-r--r--drivers/net/wireless/ath/ath9k/ath9k.h1
-rw-r--r--drivers/net/wireless/ath/ath9k/hif_usb.c8
-rw-r--r--drivers/net/wireless/ath/ath9k/main.c11
-rw-r--r--drivers/net/wireless/ath/ath9k/recv.c4
-rw-r--r--drivers/net/wireless/hostap/hostap_cs.c15
-rw-r--r--drivers/net/wireless/hostap/hostap_hw.c13
-rw-r--r--drivers/net/wireless/hostap/hostap_pci.c1
-rw-r--r--drivers/net/wireless/hostap/hostap_wlan.h2
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn-hcmd.c6
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn-tx.c5
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn.c8
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-core.c7
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-scan.c1
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-sta.c4
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-sta.h11
-rw-r--r--drivers/net/wireless/iwlwifi/iwl3945-base.c9
-rw-r--r--drivers/net/wireless/libertas_tf/main.c2
-rw-r--r--drivers/net/wireless/p54/p54pci.c2
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00dev.c10
-rw-r--r--drivers/parisc/led.c6
-rw-r--r--drivers/pci/intel-iommu.c14
-rw-r--r--drivers/pci/pci.c1
-rw-r--r--drivers/pci/pcie/pme/pcie_pme.c19
-rw-r--r--drivers/pci/setup-res.c32
-rw-r--r--drivers/pcmcia/ds.c3
-rw-r--r--drivers/pcmcia/pcmcia_resource.c4
-rw-r--r--drivers/pcmcia/pxa2xx_base.c5
-rw-r--r--drivers/platform/x86/intel_scu_ipc.c12
-rw-r--r--drivers/power/ds2782_battery.c31
-rw-r--r--drivers/power/z2_battery.c12
-rw-r--r--drivers/regulator/ab3100.c4
-rw-r--r--drivers/regulator/tps6507x-regulator.c36
-rw-r--r--drivers/regulator/wm8350-regulator.c2
-rw-r--r--drivers/rtc/rtc-davinci.c1
-rw-r--r--drivers/rtc/rtc-ds1307.c4
-rw-r--r--drivers/rtc/rtc-pl031.c2
-rw-r--r--drivers/rtc/rtc-rx8581.c20
-rw-r--r--drivers/s390/block/dasd_devmap.c4
-rw-r--r--drivers/s390/cio/chsc.c2
-rw-r--r--drivers/s390/scsi/zfcp_erp.c8
-rw-r--r--drivers/s390/scsi/zfcp_fsf.c10
-rw-r--r--drivers/s390/scsi/zfcp_qdio.c10
-rw-r--r--drivers/sbus/char/openprom.c4
-rw-r--r--drivers/scsi/ibmvscsi/rpa_vscsi.c13
-rw-r--r--drivers/scsi/ipr.c51
-rw-r--r--drivers/scsi/ipr.h5
-rw-r--r--drivers/serial/amba-pl010.c2
-rw-r--r--drivers/serial/amba-pl011.c90
-rw-r--r--drivers/serial/atmel_serial.c1
-rw-r--r--drivers/serial/cpm_uart/cpm_uart_core.c143
-rw-r--r--drivers/serial/serial_cs.c1
-rw-r--r--drivers/serial/suncore.c4
-rw-r--r--drivers/serial/sunsu.c13
-rw-r--r--drivers/spi/spi_mpc8xxx.c22
-rw-r--r--drivers/staging/batman-adv/bat_sysfs.c24
-rw-r--r--drivers/staging/batman-adv/device.c2
-rw-r--r--drivers/staging/comedi/drivers/adl_pci9111.c9
-rw-r--r--drivers/staging/comedi/drivers/cb_pcidda.c3
-rw-r--r--drivers/staging/hv/channel_mgmt.c41
-rw-r--r--drivers/staging/hv/hv_utils.c28
-rw-r--r--drivers/staging/hv/vmbus.h2
-rw-r--r--drivers/staging/hv/vmbus_drv.c3
-rw-r--r--drivers/staging/mrst-touchscreen/intel-mid-touch.c2
-rw-r--r--drivers/staging/rt2860/usb_main_dev.c1
-rw-r--r--drivers/staging/rtl8187se/r8180_core.c2
-rw-r--r--drivers/staging/rtl8192su/r8192U_core.c43
-rw-r--r--drivers/staging/rtl8192u/r8192U_core.c2
-rw-r--r--drivers/staging/tm6000/tm6000-alsa.c1
-rw-r--r--drivers/staging/tm6000/tm6000-cards.c1
-rw-r--r--drivers/staging/tm6000/tm6000-core.c1
-rw-r--r--drivers/staging/tm6000/tm6000-dvb.c1
-rw-r--r--drivers/staging/usbip/usbip_common.c46
-rw-r--r--drivers/staging/wlags49_h2/wl_enc.c1
-rw-r--r--drivers/staging/wlags49_h2/wl_sysfs.h4
-rw-r--r--drivers/usb/class/cdc-acm.c1
-rw-r--r--drivers/usb/core/driver.c13
-rw-r--r--drivers/usb/core/hub.c2
-rw-r--r--drivers/usb/core/message.c7
-rw-r--r--drivers/usb/core/quirks.c7
-rw-r--r--drivers/usb/gadget/at91_udc.c205
-rw-r--r--drivers/usb/gadget/at91_udc.h3
-rw-r--r--drivers/usb/gadget/f_eem.c3
-rw-r--r--drivers/usb/gadget/f_fs.c2
-rw-r--r--drivers/usb/gadget/f_mass_storage.c194
-rw-r--r--drivers/usb/gadget/f_uvc.c4
-rw-r--r--drivers/usb/gadget/fsl_mxc_udc.c2
-rw-r--r--drivers/usb/gadget/g_ffs.c11
-rw-r--r--drivers/usb/gadget/printer.c32
-rw-r--r--drivers/usb/gadget/pxa27x_udc.c2
-rw-r--r--drivers/usb/gadget/s3c2410_udc.c10
-rw-r--r--drivers/usb/gadget/u_serial.c16
-rw-r--r--drivers/usb/gadget/uvc.h10
-rw-r--r--drivers/usb/gadget/uvc_queue.c153
-rw-r--r--drivers/usb/gadget/uvc_queue.h20
-rw-r--r--drivers/usb/gadget/uvc_v4l2.c2
-rw-r--r--drivers/usb/gadget/uvc_video.c6
-rw-r--r--drivers/usb/gadget/webcam.c4
-rw-r--r--drivers/usb/host/ehci-mxc.c15
-rw-r--r--drivers/usb/host/isp1362-hcd.c15
-rw-r--r--drivers/usb/host/ohci-pxa27x.c2
-rw-r--r--drivers/usb/host/r8a66597-hcd.c2
-rw-r--r--drivers/usb/host/xhci-mem.c26
-rw-r--r--drivers/usb/host/xhci-ring.c73
-rw-r--r--drivers/usb/host/xhci.c2
-rw-r--r--drivers/usb/host/xhci.h2
-rw-r--r--drivers/usb/misc/sisusbvga/sisusb.c5
-rw-r--r--drivers/usb/musb/musb_core.c13
-rw-r--r--drivers/usb/musb/musb_core.h6
-rw-r--r--drivers/usb/musb/musbhsdma.c13
-rw-r--r--drivers/usb/musb/tusb6010.c13
-rw-r--r--drivers/usb/otg/ulpi.c17
-rw-r--r--drivers/usb/serial/ftdi_sio.c10
-rw-r--r--drivers/usb/serial/ftdi_sio_ids.h22
-rw-r--r--drivers/usb/serial/option.c4
-rw-r--r--drivers/usb/serial/qcserial.c5
-rw-r--r--drivers/usb/serial/sierra.c1
-rw-r--r--drivers/usb/storage/transport.c4
-rw-r--r--drivers/vhost/net.c25
-rw-r--r--drivers/vhost/vhost.c86
-rw-r--r--drivers/vhost/vhost.h8
-rw-r--r--drivers/video/aty/radeon_pm.c2
-rw-r--r--drivers/video/au1100fb.c6
-rw-r--r--drivers/video/cyber2000fb.c3
-rw-r--r--drivers/video/gbefb.c16
-rw-r--r--drivers/video/geode/gxfb_core.c20
-rw-r--r--drivers/video/geode/lxfb_core.c18
-rw-r--r--drivers/video/imxfb.c72
-rw-r--r--drivers/video/nuc900fb.c2
-rw-r--r--drivers/video/omap/lcdc.c14
-rw-r--r--drivers/video/omap/rfbi.c5
-rw-r--r--drivers/video/omap2/vram.c33
-rw-r--r--drivers/video/pmag-ba-fb.c6
-rw-r--r--drivers/video/pmagb-b-fb.c12
-rw-r--r--drivers/virtio/virtio_pci.c3
-rw-r--r--drivers/virtio/virtio_ring.c7
-rw-r--r--drivers/watchdog/at32ap700x_wdt.c16
-rw-r--r--drivers/watchdog/imx2_wdt.c1
388 files changed, 6874 insertions, 3550 deletions
diff --git a/drivers/acpi/acpi_pad.c b/drivers/acpi/acpi_pad.c
index d269a8f3329c..446aced33aff 100644
--- a/drivers/acpi/acpi_pad.c
+++ b/drivers/acpi/acpi_pad.c
@@ -46,6 +46,8 @@ static unsigned long power_saving_mwait_eax;
46 46
47static unsigned char tsc_detected_unstable; 47static unsigned char tsc_detected_unstable;
48static unsigned char tsc_marked_unstable; 48static unsigned char tsc_marked_unstable;
49static unsigned char lapic_detected_unstable;
50static unsigned char lapic_marked_unstable;
49 51
50static void power_saving_mwait_init(void) 52static void power_saving_mwait_init(void)
51{ 53{
@@ -75,9 +77,6 @@ static void power_saving_mwait_init(void)
75 power_saving_mwait_eax = (highest_cstate << MWAIT_SUBSTATE_SIZE) | 77 power_saving_mwait_eax = (highest_cstate << MWAIT_SUBSTATE_SIZE) |
76 (highest_subcstate - 1); 78 (highest_subcstate - 1);
77 79
78 for_each_online_cpu(i)
79 clockevents_notify(CLOCK_EVT_NOTIFY_BROADCAST_ON, &i);
80
81#if defined(CONFIG_GENERIC_TIME) && defined(CONFIG_X86) 80#if defined(CONFIG_GENERIC_TIME) && defined(CONFIG_X86)
82 switch (boot_cpu_data.x86_vendor) { 81 switch (boot_cpu_data.x86_vendor) {
83 case X86_VENDOR_AMD: 82 case X86_VENDOR_AMD:
@@ -86,13 +85,15 @@ static void power_saving_mwait_init(void)
86 * AMD Fam10h TSC will tick in all 85 * AMD Fam10h TSC will tick in all
87 * C/P/S0/S1 states when this bit is set. 86 * C/P/S0/S1 states when this bit is set.
88 */ 87 */
89 if (boot_cpu_has(X86_FEATURE_NONSTOP_TSC)) 88 if (!boot_cpu_has(X86_FEATURE_NONSTOP_TSC))
90 return; 89 tsc_detected_unstable = 1;
91 90 if (!boot_cpu_has(X86_FEATURE_ARAT))
92 /*FALL THROUGH*/ 91 lapic_detected_unstable = 1;
92 break;
93 default: 93 default:
94 /* TSC could halt in idle */ 94 /* TSC & LAPIC could halt in idle */
95 tsc_detected_unstable = 1; 95 tsc_detected_unstable = 1;
96 lapic_detected_unstable = 1;
96 } 97 }
97#endif 98#endif
98} 99}
@@ -180,10 +181,20 @@ static int power_saving_thread(void *data)
180 mark_tsc_unstable("TSC halts in idle"); 181 mark_tsc_unstable("TSC halts in idle");
181 tsc_marked_unstable = 1; 182 tsc_marked_unstable = 1;
182 } 183 }
184 if (lapic_detected_unstable && !lapic_marked_unstable) {
185 int i;
186 /* LAPIC could halt in idle, so notify users */
187 for_each_online_cpu(i)
188 clockevents_notify(
189 CLOCK_EVT_NOTIFY_BROADCAST_ON,
190 &i);
191 lapic_marked_unstable = 1;
192 }
183 local_irq_disable(); 193 local_irq_disable();
184 cpu = smp_processor_id(); 194 cpu = smp_processor_id();
185 clockevents_notify(CLOCK_EVT_NOTIFY_BROADCAST_ENTER, 195 if (lapic_marked_unstable)
186 &cpu); 196 clockevents_notify(
197 CLOCK_EVT_NOTIFY_BROADCAST_ENTER, &cpu);
187 stop_critical_timings(); 198 stop_critical_timings();
188 199
189 __monitor((void *)&current_thread_info()->flags, 0, 0); 200 __monitor((void *)&current_thread_info()->flags, 0, 0);
@@ -192,8 +203,9 @@ static int power_saving_thread(void *data)
192 __mwait(power_saving_mwait_eax, 1); 203 __mwait(power_saving_mwait_eax, 1);
193 204
194 start_critical_timings(); 205 start_critical_timings();
195 clockevents_notify(CLOCK_EVT_NOTIFY_BROADCAST_EXIT, 206 if (lapic_marked_unstable)
196 &cpu); 207 clockevents_notify(
208 CLOCK_EVT_NOTIFY_BROADCAST_EXIT, &cpu);
197 local_irq_enable(); 209 local_irq_enable();
198 210
199 if (jiffies > expire_time) { 211 if (jiffies > expire_time) {
diff --git a/drivers/acpi/acpica/acconfig.h b/drivers/acpi/acpica/acconfig.h
index 33181ad350d5..b17d8de9f6ff 100644
--- a/drivers/acpi/acpica/acconfig.h
+++ b/drivers/acpi/acpica/acconfig.h
@@ -119,6 +119,10 @@
119 119
120#define ACPI_MAX_LOOP_ITERATIONS 0xFFFF 120#define ACPI_MAX_LOOP_ITERATIONS 0xFFFF
121 121
122/* Maximum sleep allowed via Sleep() operator */
123
124#define ACPI_MAX_SLEEP 20000 /* Two seconds */
125
122/****************************************************************************** 126/******************************************************************************
123 * 127 *
124 * ACPI Specification constants (Do not change unless the specification changes) 128 * ACPI Specification constants (Do not change unless the specification changes)
diff --git a/drivers/acpi/acpica/acevents.h b/drivers/acpi/acpica/acevents.h
index 64d1e5c2d4ae..c3f43daa8be3 100644
--- a/drivers/acpi/acpica/acevents.h
+++ b/drivers/acpi/acpica/acevents.h
@@ -80,10 +80,6 @@ u32 acpi_ev_gpe_detect(struct acpi_gpe_xrupt_info *gpe_xrupt_list);
80acpi_status 80acpi_status
81acpi_ev_update_gpe_enable_masks(struct acpi_gpe_event_info *gpe_event_info); 81acpi_ev_update_gpe_enable_masks(struct acpi_gpe_event_info *gpe_event_info);
82 82
83acpi_status acpi_ev_enable_gpe(struct acpi_gpe_event_info *gpe_event_info);
84
85acpi_status acpi_ev_disable_gpe(struct acpi_gpe_event_info *gpe_event_info);
86
87struct acpi_gpe_event_info *acpi_ev_get_gpe_event_info(acpi_handle gpe_device, 83struct acpi_gpe_event_info *acpi_ev_get_gpe_event_info(acpi_handle gpe_device,
88 u32 gpe_number); 84 u32 gpe_number);
89 85
diff --git a/drivers/acpi/acpica/acglobal.h b/drivers/acpi/acpica/acglobal.h
index 9070f1fe8f17..899d68afc3c5 100644
--- a/drivers/acpi/acpica/acglobal.h
+++ b/drivers/acpi/acpica/acglobal.h
@@ -125,6 +125,14 @@ u8 ACPI_INIT_GLOBAL(acpi_gbl_enable_aml_debug_object, FALSE);
125 */ 125 */
126u8 ACPI_INIT_GLOBAL(acpi_gbl_copy_dsdt_locally, FALSE); 126u8 ACPI_INIT_GLOBAL(acpi_gbl_copy_dsdt_locally, FALSE);
127 127
128/*
129 * Optionally truncate I/O addresses to 16 bits. Provides compatibility
130 * with other ACPI implementations. NOTE: During ACPICA initialization,
131 * this value is set to TRUE if any Windows OSI strings have been
132 * requested by the BIOS.
133 */
134u8 ACPI_INIT_GLOBAL(acpi_gbl_truncate_io_addresses, FALSE);
135
128/* acpi_gbl_FADT is a local copy of the FADT, converted to a common format. */ 136/* acpi_gbl_FADT is a local copy of the FADT, converted to a common format. */
129 137
130struct acpi_table_fadt acpi_gbl_FADT; 138struct acpi_table_fadt acpi_gbl_FADT;
diff --git a/drivers/acpi/acpica/achware.h b/drivers/acpi/acpica/achware.h
index 5900f135dc6d..32391588e163 100644
--- a/drivers/acpi/acpica/achware.h
+++ b/drivers/acpi/acpica/achware.h
@@ -90,7 +90,11 @@ acpi_status acpi_hw_write_port(acpi_io_address address, u32 value, u32 width);
90/* 90/*
91 * hwgpe - GPE support 91 * hwgpe - GPE support
92 */ 92 */
93acpi_status acpi_hw_low_disable_gpe(struct acpi_gpe_event_info *gpe_event_info); 93u32 acpi_hw_gpe_register_bit(struct acpi_gpe_event_info *gpe_event_info,
94 struct acpi_gpe_register_info *gpe_register_info);
95
96acpi_status
97acpi_hw_low_set_gpe(struct acpi_gpe_event_info *gpe_event_info, u8 action);
94 98
95acpi_status 99acpi_status
96acpi_hw_write_gpe_enable_reg(struct acpi_gpe_event_info *gpe_event_info); 100acpi_hw_write_gpe_enable_reg(struct acpi_gpe_event_info *gpe_event_info);
diff --git a/drivers/acpi/acpica/evgpe.c b/drivers/acpi/acpica/evgpe.c
index a221ad404167..7c2c336006a1 100644
--- a/drivers/acpi/acpica/evgpe.c
+++ b/drivers/acpi/acpica/evgpe.c
@@ -69,7 +69,7 @@ acpi_status
69acpi_ev_update_gpe_enable_masks(struct acpi_gpe_event_info *gpe_event_info) 69acpi_ev_update_gpe_enable_masks(struct acpi_gpe_event_info *gpe_event_info)
70{ 70{
71 struct acpi_gpe_register_info *gpe_register_info; 71 struct acpi_gpe_register_info *gpe_register_info;
72 u8 register_bit; 72 u32 register_bit;
73 73
74 ACPI_FUNCTION_TRACE(ev_update_gpe_enable_masks); 74 ACPI_FUNCTION_TRACE(ev_update_gpe_enable_masks);
75 75
@@ -78,9 +78,8 @@ acpi_ev_update_gpe_enable_masks(struct acpi_gpe_event_info *gpe_event_info)
78 return_ACPI_STATUS(AE_NOT_EXIST); 78 return_ACPI_STATUS(AE_NOT_EXIST);
79 } 79 }
80 80
81 register_bit = (u8) 81 register_bit = acpi_hw_gpe_register_bit(gpe_event_info,
82 (1 << 82 gpe_register_info);
83 (gpe_event_info->gpe_number - gpe_register_info->base_gpe_number));
84 83
85 /* Clear the wake/run bits up front */ 84 /* Clear the wake/run bits up front */
86 85
@@ -100,106 +99,6 @@ acpi_ev_update_gpe_enable_masks(struct acpi_gpe_event_info *gpe_event_info)
100 return_ACPI_STATUS(AE_OK); 99 return_ACPI_STATUS(AE_OK);
101} 100}
102 101
103/*******************************************************************************
104 *
105 * FUNCTION: acpi_ev_enable_gpe
106 *
107 * PARAMETERS: gpe_event_info - GPE to enable
108 *
109 * RETURN: Status
110 *
111 * DESCRIPTION: Hardware-enable a GPE. Always enables the GPE, regardless
112 * of type or number of references.
113 *
114 * Note: The GPE lock should be already acquired when this function is called.
115 *
116 ******************************************************************************/
117
118acpi_status acpi_ev_enable_gpe(struct acpi_gpe_event_info *gpe_event_info)
119{
120 acpi_status status;
121
122
123 ACPI_FUNCTION_TRACE(ev_enable_gpe);
124
125
126 /*
127 * We will only allow a GPE to be enabled if it has either an
128 * associated method (_Lxx/_Exx) or a handler. Otherwise, the
129 * GPE will be immediately disabled by acpi_ev_gpe_dispatch the
130 * first time it fires.
131 */
132 if (!(gpe_event_info->flags & ACPI_GPE_DISPATCH_MASK)) {
133 return_ACPI_STATUS(AE_NO_HANDLER);
134 }
135
136 /* Ensure the HW enable masks are current */
137
138 status = acpi_ev_update_gpe_enable_masks(gpe_event_info);
139 if (ACPI_FAILURE(status)) {
140 return_ACPI_STATUS(status);
141 }
142
143 /* Clear the GPE (of stale events) */
144
145 status = acpi_hw_clear_gpe(gpe_event_info);
146 if (ACPI_FAILURE(status)) {
147 return_ACPI_STATUS(status);
148 }
149
150 /* Enable the requested GPE */
151
152 status = acpi_hw_write_gpe_enable_reg(gpe_event_info);
153 return_ACPI_STATUS(status);
154}
155
156/*******************************************************************************
157 *
158 * FUNCTION: acpi_ev_disable_gpe
159 *
160 * PARAMETERS: gpe_event_info - GPE to disable
161 *
162 * RETURN: Status
163 *
164 * DESCRIPTION: Hardware-disable a GPE. Always disables the requested GPE,
165 * regardless of the type or number of references.
166 *
167 * Note: The GPE lock should be already acquired when this function is called.
168 *
169 ******************************************************************************/
170
171acpi_status acpi_ev_disable_gpe(struct acpi_gpe_event_info *gpe_event_info)
172{
173 acpi_status status;
174
175 ACPI_FUNCTION_TRACE(ev_disable_gpe);
176
177
178 /*
179 * Note: Always disable the GPE, even if we think that that it is already
180 * disabled. It is possible that the AML or some other code has enabled
181 * the GPE behind our back.
182 */
183
184 /* Ensure the HW enable masks are current */
185
186 status = acpi_ev_update_gpe_enable_masks(gpe_event_info);
187 if (ACPI_FAILURE(status)) {
188 return_ACPI_STATUS(status);
189 }
190
191 /*
192 * Always H/W disable this GPE, even if we don't know the GPE type.
193 * Simply clear the enable bit for this particular GPE, but do not
194 * write out the current GPE enable mask since this may inadvertently
195 * enable GPEs too early. An example is a rogue GPE that has arrived
196 * during ACPICA initialization - possibly because AML or other code
197 * has enabled the GPE.
198 */
199 status = acpi_hw_low_disable_gpe(gpe_event_info);
200 return_ACPI_STATUS(status);
201}
202
203 102
204/******************************************************************************* 103/*******************************************************************************
205 * 104 *
@@ -451,10 +350,6 @@ static void ACPI_SYSTEM_XFACE acpi_ev_asynch_execute_gpe_method(void *context)
451 return_VOID; 350 return_VOID;
452 } 351 }
453 352
454 /* Update the GPE register masks for return to enabled state */
455
456 (void)acpi_ev_update_gpe_enable_masks(gpe_event_info);
457
458 /* 353 /*
459 * Take a snapshot of the GPE info for this level - we copy the info to 354 * Take a snapshot of the GPE info for this level - we copy the info to
460 * prevent a race condition with remove_handler/remove_block. 355 * prevent a race condition with remove_handler/remove_block.
@@ -607,7 +502,7 @@ acpi_ev_gpe_dispatch(struct acpi_gpe_event_info *gpe_event_info, u32 gpe_number)
607 * Disable the GPE, so it doesn't keep firing before the method has a 502 * Disable the GPE, so it doesn't keep firing before the method has a
608 * chance to run (it runs asynchronously with interrupts enabled). 503 * chance to run (it runs asynchronously with interrupts enabled).
609 */ 504 */
610 status = acpi_ev_disable_gpe(gpe_event_info); 505 status = acpi_hw_low_set_gpe(gpe_event_info, ACPI_GPE_DISABLE);
611 if (ACPI_FAILURE(status)) { 506 if (ACPI_FAILURE(status)) {
612 ACPI_EXCEPTION((AE_INFO, status, 507 ACPI_EXCEPTION((AE_INFO, status,
613 "Unable to disable GPE[0x%2X]", 508 "Unable to disable GPE[0x%2X]",
@@ -644,7 +539,7 @@ acpi_ev_gpe_dispatch(struct acpi_gpe_event_info *gpe_event_info, u32 gpe_number)
644 * Disable the GPE. The GPE will remain disabled a handler 539 * Disable the GPE. The GPE will remain disabled a handler
645 * is installed or ACPICA is restarted. 540 * is installed or ACPICA is restarted.
646 */ 541 */
647 status = acpi_ev_disable_gpe(gpe_event_info); 542 status = acpi_hw_low_set_gpe(gpe_event_info, ACPI_GPE_DISABLE);
648 if (ACPI_FAILURE(status)) { 543 if (ACPI_FAILURE(status)) {
649 ACPI_EXCEPTION((AE_INFO, status, 544 ACPI_EXCEPTION((AE_INFO, status,
650 "Unable to disable GPE[0x%2X]", 545 "Unable to disable GPE[0x%2X]",
diff --git a/drivers/acpi/acpica/evgpeblk.c b/drivers/acpi/acpica/evgpeblk.c
index 7c28f2d9fd35..341a38ce8aa6 100644
--- a/drivers/acpi/acpica/evgpeblk.c
+++ b/drivers/acpi/acpica/evgpeblk.c
@@ -500,6 +500,19 @@ acpi_ev_initialize_gpe_block(struct acpi_namespace_node *gpe_device,
500 500
501 gpe_index = (i * ACPI_GPE_REGISTER_WIDTH) + j; 501 gpe_index = (i * ACPI_GPE_REGISTER_WIDTH) + j;
502 gpe_event_info = &gpe_block->event_info[gpe_index]; 502 gpe_event_info = &gpe_block->event_info[gpe_index];
503 gpe_number = gpe_index + gpe_block->block_base_number;
504
505 /*
506 * If the GPE has already been enabled for runtime
507 * signaling, make sure it remains enabled, but do not
508 * increment its reference counter.
509 */
510 if (gpe_event_info->runtime_count) {
511 acpi_set_gpe(gpe_device, gpe_number,
512 ACPI_GPE_ENABLE);
513 gpe_enabled_count++;
514 continue;
515 }
503 516
504 if (gpe_event_info->flags & ACPI_GPE_CAN_WAKE) { 517 if (gpe_event_info->flags & ACPI_GPE_CAN_WAKE) {
505 wake_gpe_count++; 518 wake_gpe_count++;
@@ -516,7 +529,6 @@ acpi_ev_initialize_gpe_block(struct acpi_namespace_node *gpe_device,
516 529
517 /* Enable this GPE */ 530 /* Enable this GPE */
518 531
519 gpe_number = gpe_index + gpe_block->block_base_number;
520 status = acpi_enable_gpe(gpe_device, gpe_number, 532 status = acpi_enable_gpe(gpe_device, gpe_number,
521 ACPI_GPE_TYPE_RUNTIME); 533 ACPI_GPE_TYPE_RUNTIME);
522 if (ACPI_FAILURE(status)) { 534 if (ACPI_FAILURE(status)) {
diff --git a/drivers/acpi/acpica/evxface.c b/drivers/acpi/acpica/evxface.c
index cc825023012a..4a531cdf7942 100644
--- a/drivers/acpi/acpica/evxface.c
+++ b/drivers/acpi/acpica/evxface.c
@@ -719,13 +719,6 @@ acpi_install_gpe_handler(acpi_handle gpe_device,
719 handler->context = context; 719 handler->context = context;
720 handler->method_node = gpe_event_info->dispatch.method_node; 720 handler->method_node = gpe_event_info->dispatch.method_node;
721 721
722 /* Disable the GPE before installing the handler */
723
724 status = acpi_ev_disable_gpe(gpe_event_info);
725 if (ACPI_FAILURE (status)) {
726 goto unlock_and_exit;
727 }
728
729 /* Install the handler */ 722 /* Install the handler */
730 723
731 flags = acpi_os_acquire_lock(acpi_gbl_gpe_lock); 724 flags = acpi_os_acquire_lock(acpi_gbl_gpe_lock);
diff --git a/drivers/acpi/acpica/evxfevnt.c b/drivers/acpi/acpica/evxfevnt.c
index d5a5efc043bf..18b3f1468b7d 100644
--- a/drivers/acpi/acpica/evxfevnt.c
+++ b/drivers/acpi/acpica/evxfevnt.c
@@ -70,6 +70,7 @@ acpi_ev_get_gpe_device(struct acpi_gpe_xrupt_info *gpe_xrupt_info,
70acpi_status acpi_enable(void) 70acpi_status acpi_enable(void)
71{ 71{
72 acpi_status status; 72 acpi_status status;
73 int retry;
73 74
74 ACPI_FUNCTION_TRACE(acpi_enable); 75 ACPI_FUNCTION_TRACE(acpi_enable);
75 76
@@ -98,16 +99,18 @@ acpi_status acpi_enable(void)
98 99
99 /* Sanity check that transition succeeded */ 100 /* Sanity check that transition succeeded */
100 101
101 if (acpi_hw_get_mode() != ACPI_SYS_MODE_ACPI) { 102 for (retry = 0; retry < 30000; ++retry) {
102 ACPI_ERROR((AE_INFO, 103 if (acpi_hw_get_mode() == ACPI_SYS_MODE_ACPI) {
103 "Hardware did not enter ACPI mode")); 104 if (retry != 0)
104 return_ACPI_STATUS(AE_NO_HARDWARE_RESPONSE); 105 ACPI_WARNING((AE_INFO,
106 "Platform took > %d00 usec to enter ACPI mode", retry));
107 return_ACPI_STATUS(AE_OK);
108 }
109 acpi_os_stall(100); /* 100 usec */
105 } 110 }
106 111
107 ACPI_DEBUG_PRINT((ACPI_DB_INIT, 112 ACPI_ERROR((AE_INFO, "Hardware did not enter ACPI mode"));
108 "Transition to ACPI mode successful\n")); 113 return_ACPI_STATUS(AE_NO_HARDWARE_RESPONSE);
109
110 return_ACPI_STATUS(AE_OK);
111} 114}
112 115
113ACPI_EXPORT_SYMBOL(acpi_enable) 116ACPI_EXPORT_SYMBOL(acpi_enable)
@@ -210,6 +213,44 @@ ACPI_EXPORT_SYMBOL(acpi_enable_event)
210 213
211/******************************************************************************* 214/*******************************************************************************
212 * 215 *
216 * FUNCTION: acpi_clear_and_enable_gpe
217 *
218 * PARAMETERS: gpe_event_info - GPE to enable
219 *
220 * RETURN: Status
221 *
222 * DESCRIPTION: Clear the given GPE from stale events and enable it.
223 *
224 ******************************************************************************/
225static acpi_status
226acpi_clear_and_enable_gpe(struct acpi_gpe_event_info *gpe_event_info)
227{
228 acpi_status status;
229
230 /*
231 * We will only allow a GPE to be enabled if it has either an
232 * associated method (_Lxx/_Exx) or a handler. Otherwise, the
233 * GPE will be immediately disabled by acpi_ev_gpe_dispatch the
234 * first time it fires.
235 */
236 if (!(gpe_event_info->flags & ACPI_GPE_DISPATCH_MASK)) {
237 return_ACPI_STATUS(AE_NO_HANDLER);
238 }
239
240 /* Clear the GPE (of stale events) */
241 status = acpi_hw_clear_gpe(gpe_event_info);
242 if (ACPI_FAILURE(status)) {
243 return_ACPI_STATUS(status);
244 }
245
246 /* Enable the requested GPE */
247 status = acpi_hw_low_set_gpe(gpe_event_info, ACPI_GPE_ENABLE);
248
249 return_ACPI_STATUS(status);
250}
251
252/*******************************************************************************
253 *
213 * FUNCTION: acpi_set_gpe 254 * FUNCTION: acpi_set_gpe
214 * 255 *
215 * PARAMETERS: gpe_device - Parent GPE Device. NULL for GPE0/GPE1 256 * PARAMETERS: gpe_device - Parent GPE Device. NULL for GPE0/GPE1
@@ -249,11 +290,11 @@ acpi_status acpi_set_gpe(acpi_handle gpe_device, u32 gpe_number, u8 action)
249 290
250 switch (action) { 291 switch (action) {
251 case ACPI_GPE_ENABLE: 292 case ACPI_GPE_ENABLE:
252 status = acpi_ev_enable_gpe(gpe_event_info); 293 status = acpi_clear_and_enable_gpe(gpe_event_info);
253 break; 294 break;
254 295
255 case ACPI_GPE_DISABLE: 296 case ACPI_GPE_DISABLE:
256 status = acpi_ev_disable_gpe(gpe_event_info); 297 status = acpi_hw_low_set_gpe(gpe_event_info, ACPI_GPE_DISABLE);
257 break; 298 break;
258 299
259 default: 300 default:
@@ -316,7 +357,11 @@ acpi_status acpi_enable_gpe(acpi_handle gpe_device, u32 gpe_number, u8 gpe_type)
316 357
317 gpe_event_info->runtime_count++; 358 gpe_event_info->runtime_count++;
318 if (gpe_event_info->runtime_count == 1) { 359 if (gpe_event_info->runtime_count == 1) {
319 status = acpi_ev_enable_gpe(gpe_event_info); 360 status = acpi_ev_update_gpe_enable_masks(gpe_event_info);
361 if (ACPI_SUCCESS(status)) {
362 status = acpi_clear_and_enable_gpe(gpe_event_info);
363 }
364
320 if (ACPI_FAILURE(status)) { 365 if (ACPI_FAILURE(status)) {
321 gpe_event_info->runtime_count--; 366 gpe_event_info->runtime_count--;
322 goto unlock_and_exit; 367 goto unlock_and_exit;
@@ -343,7 +388,7 @@ acpi_status acpi_enable_gpe(acpi_handle gpe_device, u32 gpe_number, u8 gpe_type)
343 */ 388 */
344 gpe_event_info->wakeup_count++; 389 gpe_event_info->wakeup_count++;
345 if (gpe_event_info->wakeup_count == 1) { 390 if (gpe_event_info->wakeup_count == 1) {
346 (void)acpi_ev_update_gpe_enable_masks(gpe_event_info); 391 status = acpi_ev_update_gpe_enable_masks(gpe_event_info);
347 } 392 }
348 } 393 }
349 394
@@ -403,7 +448,12 @@ acpi_status acpi_disable_gpe(acpi_handle gpe_device, u32 gpe_number, u8 gpe_type
403 448
404 gpe_event_info->runtime_count--; 449 gpe_event_info->runtime_count--;
405 if (!gpe_event_info->runtime_count) { 450 if (!gpe_event_info->runtime_count) {
406 status = acpi_ev_disable_gpe(gpe_event_info); 451 status = acpi_ev_update_gpe_enable_masks(gpe_event_info);
452 if (ACPI_SUCCESS(status)) {
453 status = acpi_hw_low_set_gpe(gpe_event_info,
454 ACPI_GPE_DISABLE);
455 }
456
407 if (ACPI_FAILURE(status)) { 457 if (ACPI_FAILURE(status)) {
408 gpe_event_info->runtime_count++; 458 gpe_event_info->runtime_count++;
409 goto unlock_and_exit; 459 goto unlock_and_exit;
@@ -424,7 +474,7 @@ acpi_status acpi_disable_gpe(acpi_handle gpe_device, u32 gpe_number, u8 gpe_type
424 474
425 gpe_event_info->wakeup_count--; 475 gpe_event_info->wakeup_count--;
426 if (!gpe_event_info->wakeup_count) { 476 if (!gpe_event_info->wakeup_count) {
427 (void)acpi_ev_update_gpe_enable_masks(gpe_event_info); 477 status = acpi_ev_update_gpe_enable_masks(gpe_event_info);
428 } 478 }
429 } 479 }
430 480
diff --git a/drivers/acpi/acpica/exsystem.c b/drivers/acpi/acpica/exsystem.c
index 6d32e09327f1..675aaa91a770 100644
--- a/drivers/acpi/acpica/exsystem.c
+++ b/drivers/acpi/acpica/exsystem.c
@@ -201,6 +201,14 @@ acpi_status acpi_ex_system_do_sleep(u64 how_long)
201 201
202 acpi_ex_relinquish_interpreter(); 202 acpi_ex_relinquish_interpreter();
203 203
204 /*
205 * For compatibility with other ACPI implementations and to prevent
206 * accidental deep sleeps, limit the sleep time to something reasonable.
207 */
208 if (how_long > ACPI_MAX_SLEEP) {
209 how_long = ACPI_MAX_SLEEP;
210 }
211
204 acpi_os_sleep(how_long); 212 acpi_os_sleep(how_long);
205 213
206 /* And now we must get the interpreter again */ 214 /* And now we must get the interpreter again */
diff --git a/drivers/acpi/acpica/hwgpe.c b/drivers/acpi/acpica/hwgpe.c
index bd72319a38f0..3450309c2786 100644
--- a/drivers/acpi/acpica/hwgpe.c
+++ b/drivers/acpi/acpica/hwgpe.c
@@ -57,21 +57,47 @@ acpi_hw_enable_wakeup_gpe_block(struct acpi_gpe_xrupt_info *gpe_xrupt_info,
57 57
58/****************************************************************************** 58/******************************************************************************
59 * 59 *
60 * FUNCTION: acpi_hw_low_disable_gpe 60 * FUNCTION: acpi_hw_gpe_register_bit
61 *
62 * PARAMETERS: gpe_event_info - Info block for the GPE
63 * gpe_register_info - Info block for the GPE register
64 *
65 * RETURN: Status
66 *
67 * DESCRIPTION: Compute GPE enable mask with one bit corresponding to the given
68 * GPE set.
69 *
70 ******************************************************************************/
71
72u32 acpi_hw_gpe_register_bit(struct acpi_gpe_event_info *gpe_event_info,
73 struct acpi_gpe_register_info *gpe_register_info)
74{
75 return (u32)1 << (gpe_event_info->gpe_number -
76 gpe_register_info->base_gpe_number);
77}
78
79/******************************************************************************
80 *
81 * FUNCTION: acpi_hw_low_set_gpe
61 * 82 *
62 * PARAMETERS: gpe_event_info - Info block for the GPE to be disabled 83 * PARAMETERS: gpe_event_info - Info block for the GPE to be disabled
84 * action - Enable or disable
63 * 85 *
64 * RETURN: Status 86 * RETURN: Status
65 * 87 *
66 * DESCRIPTION: Disable a single GPE in the enable register. 88 * DESCRIPTION: Enable or disable a single GPE in its enable register.
67 * 89 *
68 ******************************************************************************/ 90 ******************************************************************************/
69 91
70acpi_status acpi_hw_low_disable_gpe(struct acpi_gpe_event_info *gpe_event_info) 92acpi_status
93acpi_hw_low_set_gpe(struct acpi_gpe_event_info *gpe_event_info, u8 action)
71{ 94{
72 struct acpi_gpe_register_info *gpe_register_info; 95 struct acpi_gpe_register_info *gpe_register_info;
73 acpi_status status; 96 acpi_status status;
74 u32 enable_mask; 97 u32 enable_mask;
98 u32 register_bit;
99
100 ACPI_FUNCTION_ENTRY();
75 101
76 /* Get the info block for the entire GPE register */ 102 /* Get the info block for the entire GPE register */
77 103
@@ -87,11 +113,27 @@ acpi_status acpi_hw_low_disable_gpe(struct acpi_gpe_event_info *gpe_event_info)
87 return (status); 113 return (status);
88 } 114 }
89 115
90 /* Clear just the bit that corresponds to this GPE */ 116 /* Set ot clear just the bit that corresponds to this GPE */
91 117
92 ACPI_CLEAR_BIT(enable_mask, ((u32)1 << 118 register_bit = acpi_hw_gpe_register_bit(gpe_event_info,
93 (gpe_event_info->gpe_number - 119 gpe_register_info);
94 gpe_register_info->base_gpe_number))); 120 switch (action) {
121 case ACPI_GPE_COND_ENABLE:
122 if (!(register_bit & gpe_register_info->enable_for_run))
123 return (AE_BAD_PARAMETER);
124
125 case ACPI_GPE_ENABLE:
126 ACPI_SET_BIT(enable_mask, register_bit);
127 break;
128
129 case ACPI_GPE_DISABLE:
130 ACPI_CLEAR_BIT(enable_mask, register_bit);
131 break;
132
133 default:
134 ACPI_ERROR((AE_INFO, "Invalid action\n"));
135 return (AE_BAD_PARAMETER);
136 }
95 137
96 /* Write the updated enable mask */ 138 /* Write the updated enable mask */
97 139
@@ -116,23 +158,11 @@ acpi_status acpi_hw_low_disable_gpe(struct acpi_gpe_event_info *gpe_event_info)
116acpi_status 158acpi_status
117acpi_hw_write_gpe_enable_reg(struct acpi_gpe_event_info * gpe_event_info) 159acpi_hw_write_gpe_enable_reg(struct acpi_gpe_event_info * gpe_event_info)
118{ 160{
119 struct acpi_gpe_register_info *gpe_register_info;
120 acpi_status status; 161 acpi_status status;
121 162
122 ACPI_FUNCTION_ENTRY(); 163 ACPI_FUNCTION_ENTRY();
123 164
124 /* Get the info block for the entire GPE register */ 165 status = acpi_hw_low_set_gpe(gpe_event_info, ACPI_GPE_COND_ENABLE);
125
126 gpe_register_info = gpe_event_info->register_info;
127 if (!gpe_register_info) {
128 return (AE_NOT_EXIST);
129 }
130
131 /* Write the entire GPE (runtime) enable register */
132
133 status = acpi_hw_write(gpe_register_info->enable_for_run,
134 &gpe_register_info->enable_address);
135
136 return (status); 166 return (status);
137} 167}
138 168
@@ -150,21 +180,28 @@ acpi_hw_write_gpe_enable_reg(struct acpi_gpe_event_info * gpe_event_info)
150 180
151acpi_status acpi_hw_clear_gpe(struct acpi_gpe_event_info * gpe_event_info) 181acpi_status acpi_hw_clear_gpe(struct acpi_gpe_event_info * gpe_event_info)
152{ 182{
183 struct acpi_gpe_register_info *gpe_register_info;
153 acpi_status status; 184 acpi_status status;
154 u8 register_bit; 185 u32 register_bit;
155 186
156 ACPI_FUNCTION_ENTRY(); 187 ACPI_FUNCTION_ENTRY();
157 188
158 register_bit = (u8)(1 << 189 /* Get the info block for the entire GPE register */
159 (gpe_event_info->gpe_number - 190
160 gpe_event_info->register_info->base_gpe_number)); 191 gpe_register_info = gpe_event_info->register_info;
192 if (!gpe_register_info) {
193 return (AE_NOT_EXIST);
194 }
195
196 register_bit = acpi_hw_gpe_register_bit(gpe_event_info,
197 gpe_register_info);
161 198
162 /* 199 /*
163 * Write a one to the appropriate bit in the status register to 200 * Write a one to the appropriate bit in the status register to
164 * clear this GPE. 201 * clear this GPE.
165 */ 202 */
166 status = acpi_hw_write(register_bit, 203 status = acpi_hw_write(register_bit,
167 &gpe_event_info->register_info->status_address); 204 &gpe_register_info->status_address);
168 205
169 return (status); 206 return (status);
170} 207}
@@ -187,7 +224,7 @@ acpi_hw_get_gpe_status(struct acpi_gpe_event_info * gpe_event_info,
187 acpi_event_status * event_status) 224 acpi_event_status * event_status)
188{ 225{
189 u32 in_byte; 226 u32 in_byte;
190 u8 register_bit; 227 u32 register_bit;
191 struct acpi_gpe_register_info *gpe_register_info; 228 struct acpi_gpe_register_info *gpe_register_info;
192 acpi_status status; 229 acpi_status status;
193 acpi_event_status local_event_status = 0; 230 acpi_event_status local_event_status = 0;
@@ -204,9 +241,8 @@ acpi_hw_get_gpe_status(struct acpi_gpe_event_info * gpe_event_info,
204 241
205 /* Get the register bitmask for this GPE */ 242 /* Get the register bitmask for this GPE */
206 243
207 register_bit = (u8)(1 << 244 register_bit = acpi_hw_gpe_register_bit(gpe_event_info,
208 (gpe_event_info->gpe_number - 245 gpe_register_info);
209 gpe_event_info->register_info->base_gpe_number));
210 246
211 /* GPE currently enabled? (enabled for runtime?) */ 247 /* GPE currently enabled? (enabled for runtime?) */
212 248
diff --git a/drivers/acpi/acpica/hwvalid.c b/drivers/acpi/acpica/hwvalid.c
index c10d587c1641..e1d9c777b213 100644
--- a/drivers/acpi/acpica/hwvalid.c
+++ b/drivers/acpi/acpica/hwvalid.c
@@ -222,6 +222,12 @@ acpi_status acpi_hw_read_port(acpi_io_address address, u32 *value, u32 width)
222 u32 one_byte; 222 u32 one_byte;
223 u32 i; 223 u32 i;
224 224
225 /* Truncate address to 16 bits if requested */
226
227 if (acpi_gbl_truncate_io_addresses) {
228 address &= ACPI_UINT16_MAX;
229 }
230
225 /* Validate the entire request and perform the I/O */ 231 /* Validate the entire request and perform the I/O */
226 232
227 status = acpi_hw_validate_io_request(address, width); 233 status = acpi_hw_validate_io_request(address, width);
@@ -279,6 +285,12 @@ acpi_status acpi_hw_write_port(acpi_io_address address, u32 value, u32 width)
279 acpi_status status; 285 acpi_status status;
280 u32 i; 286 u32 i;
281 287
288 /* Truncate address to 16 bits if requested */
289
290 if (acpi_gbl_truncate_io_addresses) {
291 address &= ACPI_UINT16_MAX;
292 }
293
282 /* Validate the entire request and perform the I/O */ 294 /* Validate the entire request and perform the I/O */
283 295
284 status = acpi_hw_validate_io_request(address, width); 296 status = acpi_hw_validate_io_request(address, width);
diff --git a/drivers/acpi/acpica/nsinit.c b/drivers/acpi/acpica/nsinit.c
index 9bd6f050f299..4e5272c313e0 100644
--- a/drivers/acpi/acpica/nsinit.c
+++ b/drivers/acpi/acpica/nsinit.c
@@ -193,6 +193,15 @@ acpi_status acpi_ns_initialize_devices(void)
193 acpi_ns_init_one_device, NULL, &info, 193 acpi_ns_init_one_device, NULL, &info,
194 NULL); 194 NULL);
195 195
196 /*
197 * Any _OSI requests should be completed by now. If the BIOS has
198 * requested any Windows OSI strings, we will always truncate
199 * I/O addresses to 16 bits -- for Windows compatibility.
200 */
201 if (acpi_gbl_osi_data >= ACPI_OSI_WIN_2000) {
202 acpi_gbl_truncate_io_addresses = TRUE;
203 }
204
196 ACPI_FREE(info.evaluate_info); 205 ACPI_FREE(info.evaluate_info);
197 if (ACPI_FAILURE(status)) { 206 if (ACPI_FAILURE(status)) {
198 goto error_exit; 207 goto error_exit;
diff --git a/drivers/acpi/apei/apei-base.c b/drivers/acpi/apei/apei-base.c
index db3946e9c66b..216e1e948ff6 100644
--- a/drivers/acpi/apei/apei-base.c
+++ b/drivers/acpi/apei/apei-base.c
@@ -34,6 +34,7 @@
34#include <linux/module.h> 34#include <linux/module.h>
35#include <linux/init.h> 35#include <linux/init.h>
36#include <linux/acpi.h> 36#include <linux/acpi.h>
37#include <linux/slab.h>
37#include <linux/io.h> 38#include <linux/io.h>
38#include <linux/kref.h> 39#include <linux/kref.h>
39#include <linux/rculist.h> 40#include <linux/rculist.h>
diff --git a/drivers/acpi/apei/erst.c b/drivers/acpi/apei/erst.c
index 2ebc39115507..864dd46c346f 100644
--- a/drivers/acpi/apei/erst.c
+++ b/drivers/acpi/apei/erst.c
@@ -781,7 +781,7 @@ static int __init erst_init(void)
781 status = acpi_get_table(ACPI_SIG_ERST, 0, 781 status = acpi_get_table(ACPI_SIG_ERST, 0,
782 (struct acpi_table_header **)&erst_tab); 782 (struct acpi_table_header **)&erst_tab);
783 if (status == AE_NOT_FOUND) { 783 if (status == AE_NOT_FOUND) {
784 pr_err(ERST_PFX "Table is not found!\n"); 784 pr_info(ERST_PFX "Table is not found!\n");
785 goto err; 785 goto err;
786 } else if (ACPI_FAILURE(status)) { 786 } else if (ACPI_FAILURE(status)) {
787 const char *msg = acpi_format_exception(status); 787 const char *msg = acpi_format_exception(status);
diff --git a/drivers/acpi/atomicio.c b/drivers/acpi/atomicio.c
index 814b19249616..8f8bd736d4ff 100644
--- a/drivers/acpi/atomicio.c
+++ b/drivers/acpi/atomicio.c
@@ -31,6 +31,7 @@
31#include <linux/kref.h> 31#include <linux/kref.h>
32#include <linux/rculist.h> 32#include <linux/rculist.h>
33#include <linux/interrupt.h> 33#include <linux/interrupt.h>
34#include <linux/slab.h>
34#include <acpi/atomicio.h> 35#include <acpi/atomicio.h>
35 36
36#define ACPI_PFX "ACPI: " 37#define ACPI_PFX "ACPI: "
diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c
index 3026e3fa83ef..dc58402b0a17 100644
--- a/drivers/acpi/battery.c
+++ b/drivers/acpi/battery.c
@@ -868,9 +868,15 @@ static void acpi_battery_remove_fs(struct acpi_device *device)
868static void acpi_battery_notify(struct acpi_device *device, u32 event) 868static void acpi_battery_notify(struct acpi_device *device, u32 event)
869{ 869{
870 struct acpi_battery *battery = acpi_driver_data(device); 870 struct acpi_battery *battery = acpi_driver_data(device);
871#ifdef CONFIG_ACPI_SYSFS_POWER
872 struct device *old;
873#endif
871 874
872 if (!battery) 875 if (!battery)
873 return; 876 return;
877#ifdef CONFIG_ACPI_SYSFS_POWER
878 old = battery->bat.dev;
879#endif
874 acpi_battery_update(battery); 880 acpi_battery_update(battery);
875 acpi_bus_generate_proc_event(device, event, 881 acpi_bus_generate_proc_event(device, event,
876 acpi_battery_present(battery)); 882 acpi_battery_present(battery));
@@ -879,7 +885,7 @@ static void acpi_battery_notify(struct acpi_device *device, u32 event)
879 acpi_battery_present(battery)); 885 acpi_battery_present(battery));
880#ifdef CONFIG_ACPI_SYSFS_POWER 886#ifdef CONFIG_ACPI_SYSFS_POWER
881 /* acpi_battery_update could remove power_supply object */ 887 /* acpi_battery_update could remove power_supply object */
882 if (battery->bat.dev) 888 if (old && battery->bat.dev)
883 power_supply_changed(&battery->bat); 889 power_supply_changed(&battery->bat);
884#endif 890#endif
885} 891}
diff --git a/drivers/acpi/blacklist.c b/drivers/acpi/blacklist.c
index 2815df66f6f7..2bb28b9d91c4 100644
--- a/drivers/acpi/blacklist.c
+++ b/drivers/acpi/blacklist.c
@@ -214,7 +214,15 @@ static struct dmi_system_id acpi_osi_dmi_table[] __initdata = {
214 .ident = "Sony VGN-SR290J", 214 .ident = "Sony VGN-SR290J",
215 .matches = { 215 .matches = {
216 DMI_MATCH(DMI_SYS_VENDOR, "Sony Corporation"), 216 DMI_MATCH(DMI_SYS_VENDOR, "Sony Corporation"),
217 DMI_MATCH(DMI_PRODUCT_NAME, "Sony VGN-SR290J"), 217 DMI_MATCH(DMI_PRODUCT_NAME, "VGN-SR290J"),
218 },
219 },
220 {
221 .callback = dmi_disable_osi_vista,
222 .ident = "VGN-NS50B_L",
223 .matches = {
224 DMI_MATCH(DMI_SYS_VENDOR, "Sony Corporation"),
225 DMI_MATCH(DMI_PRODUCT_NAME, "VGN-NS50B_L"),
218 }, 226 },
219 }, 227 },
220 { 228 {
diff --git a/drivers/acpi/button.c b/drivers/acpi/button.c
index fd51c4ab4829..7d857dabdde4 100644
--- a/drivers/acpi/button.c
+++ b/drivers/acpi/button.c
@@ -425,7 +425,7 @@ static int acpi_button_add(struct acpi_device *device)
425 /* Button's GPE is run-wake GPE */ 425 /* Button's GPE is run-wake GPE */
426 acpi_enable_gpe(device->wakeup.gpe_device, 426 acpi_enable_gpe(device->wakeup.gpe_device,
427 device->wakeup.gpe_number, 427 device->wakeup.gpe_number,
428 ACPI_GPE_TYPE_WAKE_RUN); 428 ACPI_GPE_TYPE_RUNTIME);
429 device->wakeup.run_wake_count++; 429 device->wakeup.run_wake_count++;
430 device->wakeup.state.enabled = 1; 430 device->wakeup.state.enabled = 1;
431 } 431 }
@@ -449,7 +449,7 @@ static int acpi_button_remove(struct acpi_device *device, int type)
449 if (device->wakeup.flags.valid) { 449 if (device->wakeup.flags.valid) {
450 acpi_disable_gpe(device->wakeup.gpe_device, 450 acpi_disable_gpe(device->wakeup.gpe_device,
451 device->wakeup.gpe_number, 451 device->wakeup.gpe_number,
452 ACPI_GPE_TYPE_WAKE_RUN); 452 ACPI_GPE_TYPE_RUNTIME);
453 device->wakeup.run_wake_count--; 453 device->wakeup.run_wake_count--;
454 device->wakeup.state.enabled = 0; 454 device->wakeup.state.enabled = 0;
455 } 455 }
diff --git a/drivers/acpi/fan.c b/drivers/acpi/fan.c
index acf2ab249842..8a3b840c0bb2 100644
--- a/drivers/acpi/fan.c
+++ b/drivers/acpi/fan.c
@@ -347,7 +347,6 @@ static int __init acpi_fan_init(void)
347{ 347{
348 int result = 0; 348 int result = 0;
349 349
350
351#ifdef CONFIG_ACPI_PROCFS 350#ifdef CONFIG_ACPI_PROCFS
352 acpi_fan_dir = proc_mkdir(ACPI_FAN_CLASS, acpi_root_dir); 351 acpi_fan_dir = proc_mkdir(ACPI_FAN_CLASS, acpi_root_dir);
353 if (!acpi_fan_dir) 352 if (!acpi_fan_dir)
@@ -356,7 +355,9 @@ static int __init acpi_fan_init(void)
356 355
357 result = acpi_bus_register_driver(&acpi_fan_driver); 356 result = acpi_bus_register_driver(&acpi_fan_driver);
358 if (result < 0) { 357 if (result < 0) {
358#ifdef CONFIG_ACPI_PROCFS
359 remove_proc_entry(ACPI_FAN_CLASS, acpi_root_dir); 359 remove_proc_entry(ACPI_FAN_CLASS, acpi_root_dir);
360#endif
360 return -ENODEV; 361 return -ENODEV;
361 } 362 }
362 363
diff --git a/drivers/acpi/processor_core.c b/drivers/acpi/processor_core.c
index 51284351418f..e9699aaed109 100644
--- a/drivers/acpi/processor_core.c
+++ b/drivers/acpi/processor_core.c
@@ -223,7 +223,7 @@ static bool processor_physically_present(acpi_handle handle)
223 type = (acpi_type == ACPI_TYPE_DEVICE) ? 1 : 0; 223 type = (acpi_type == ACPI_TYPE_DEVICE) ? 1 : 0;
224 cpuid = acpi_get_cpuid(handle, type, acpi_id); 224 cpuid = acpi_get_cpuid(handle, type, acpi_id);
225 225
226 if (cpuid == -1) 226 if ((cpuid == -1) && (num_possible_cpus() > 1))
227 return false; 227 return false;
228 228
229 return true; 229 return true;
diff --git a/drivers/acpi/processor_driver.c b/drivers/acpi/processor_driver.c
index b1034a9ada4e..38ea0cc6dc49 100644
--- a/drivers/acpi/processor_driver.c
+++ b/drivers/acpi/processor_driver.c
@@ -581,6 +581,11 @@ static int __cpuinit acpi_processor_add(struct acpi_device *device)
581 return 0; 581 return 0;
582 } 582 }
583 583
584#ifdef CONFIG_SMP
585 if (pr->id >= setup_max_cpus && pr->id != 0)
586 return 0;
587#endif
588
584 BUG_ON((pr->id >= nr_cpu_ids) || (pr->id < 0)); 589 BUG_ON((pr->id >= nr_cpu_ids) || (pr->id < 0));
585 590
586 /* 591 /*
diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c
index b1b385692f46..e9a8026d39f0 100644
--- a/drivers/acpi/processor_idle.c
+++ b/drivers/acpi/processor_idle.c
@@ -76,14 +76,19 @@ static unsigned int max_cstate __read_mostly = ACPI_PROCESSOR_MAX_POWER;
76module_param(max_cstate, uint, 0000); 76module_param(max_cstate, uint, 0000);
77static unsigned int nocst __read_mostly; 77static unsigned int nocst __read_mostly;
78module_param(nocst, uint, 0000); 78module_param(nocst, uint, 0000);
79static int bm_check_disable __read_mostly;
80module_param(bm_check_disable, uint, 0000);
79 81
80static unsigned int latency_factor __read_mostly = 2; 82static unsigned int latency_factor __read_mostly = 2;
81module_param(latency_factor, uint, 0644); 83module_param(latency_factor, uint, 0644);
82 84
85#ifdef CONFIG_ACPI_PROCFS
83static u64 us_to_pm_timer_ticks(s64 t) 86static u64 us_to_pm_timer_ticks(s64 t)
84{ 87{
85 return div64_u64(t * PM_TIMER_FREQUENCY, 1000000); 88 return div64_u64(t * PM_TIMER_FREQUENCY, 1000000);
86} 89}
90#endif
91
87/* 92/*
88 * IBM ThinkPad R40e crashes mysteriously when going into C2 or C3. 93 * IBM ThinkPad R40e crashes mysteriously when going into C2 or C3.
89 * For now disable this. Probably a bug somewhere else. 94 * For now disable this. Probably a bug somewhere else.
@@ -763,6 +768,9 @@ static int acpi_idle_bm_check(void)
763{ 768{
764 u32 bm_status = 0; 769 u32 bm_status = 0;
765 770
771 if (bm_check_disable)
772 return 0;
773
766 acpi_read_bit_register(ACPI_BITREG_BUS_MASTER_STATUS, &bm_status); 774 acpi_read_bit_register(ACPI_BITREG_BUS_MASTER_STATUS, &bm_status);
767 if (bm_status) 775 if (bm_status)
768 acpi_write_bit_register(ACPI_BITREG_BUS_MASTER_STATUS, 1); 776 acpi_write_bit_register(ACPI_BITREG_BUS_MASTER_STATUS, 1);
@@ -947,7 +955,7 @@ static int acpi_idle_enter_bm(struct cpuidle_device *dev,
947 if (acpi_idle_suspend) 955 if (acpi_idle_suspend)
948 return(acpi_idle_enter_c1(dev, state)); 956 return(acpi_idle_enter_c1(dev, state));
949 957
950 if (acpi_idle_bm_check()) { 958 if (!cx->bm_sts_skip && acpi_idle_bm_check()) {
951 if (dev->safe_state) { 959 if (dev->safe_state) {
952 dev->last_state = dev->safe_state; 960 dev->last_state = dev->safe_state;
953 return dev->safe_state->enter(dev, dev->safe_state); 961 return dev->safe_state->enter(dev, dev->safe_state);
diff --git a/drivers/acpi/sleep.c b/drivers/acpi/sleep.c
index 3fb4bdea7e06..2862c781b372 100644
--- a/drivers/acpi/sleep.c
+++ b/drivers/acpi/sleep.c
@@ -82,6 +82,20 @@ static int acpi_sleep_prepare(u32 acpi_state)
82static u32 acpi_target_sleep_state = ACPI_STATE_S0; 82static u32 acpi_target_sleep_state = ACPI_STATE_S0;
83 83
84/* 84/*
85 * The ACPI specification wants us to save NVS memory regions during hibernation
86 * and to restore them during the subsequent resume. Windows does that also for
87 * suspend to RAM. However, it is known that this mechanism does not work on
88 * all machines, so we allow the user to disable it with the help of the
89 * 'acpi_sleep=nonvs' kernel command line option.
90 */
91static bool nvs_nosave;
92
93void __init acpi_nvs_nosave(void)
94{
95 nvs_nosave = true;
96}
97
98/*
85 * ACPI 1.0 wants us to execute _PTS before suspending devices, so we allow the 99 * ACPI 1.0 wants us to execute _PTS before suspending devices, so we allow the
86 * user to request that behavior by using the 'acpi_old_suspend_ordering' 100 * user to request that behavior by using the 'acpi_old_suspend_ordering'
87 * kernel command line option that causes the following variable to be set. 101 * kernel command line option that causes the following variable to be set.
@@ -114,6 +128,8 @@ static int __acpi_pm_prepare(void)
114{ 128{
115 int error = acpi_sleep_prepare(acpi_target_sleep_state); 129 int error = acpi_sleep_prepare(acpi_target_sleep_state);
116 130
131 suspend_nvs_save();
132
117 if (error) 133 if (error)
118 acpi_target_sleep_state = ACPI_STATE_S0; 134 acpi_target_sleep_state = ACPI_STATE_S0;
119 return error; 135 return error;
@@ -143,6 +159,9 @@ static void acpi_pm_finish(void)
143{ 159{
144 u32 acpi_state = acpi_target_sleep_state; 160 u32 acpi_state = acpi_target_sleep_state;
145 161
162 suspend_nvs_free();
163 acpi_ec_unblock_transactions();
164
146 if (acpi_state == ACPI_STATE_S0) 165 if (acpi_state == ACPI_STATE_S0)
147 return; 166 return;
148 167
@@ -192,6 +211,10 @@ static int acpi_suspend_begin(suspend_state_t pm_state)
192 u32 acpi_state = acpi_suspend_states[pm_state]; 211 u32 acpi_state = acpi_suspend_states[pm_state];
193 int error = 0; 212 int error = 0;
194 213
214 error = nvs_nosave ? 0 : suspend_nvs_alloc();
215 if (error)
216 return error;
217
195 if (sleep_states[acpi_state]) { 218 if (sleep_states[acpi_state]) {
196 acpi_target_sleep_state = acpi_state; 219 acpi_target_sleep_state = acpi_state;
197 acpi_sleep_tts_switch(acpi_target_sleep_state); 220 acpi_sleep_tts_switch(acpi_target_sleep_state);
@@ -269,12 +292,13 @@ static int acpi_suspend_enter(suspend_state_t pm_state)
269 if (acpi_state == ACPI_STATE_S3) 292 if (acpi_state == ACPI_STATE_S3)
270 acpi_restore_state_mem(); 293 acpi_restore_state_mem();
271 294
295 suspend_nvs_restore();
296
272 return ACPI_SUCCESS(status) ? 0 : -EFAULT; 297 return ACPI_SUCCESS(status) ? 0 : -EFAULT;
273} 298}
274 299
275static void acpi_suspend_finish(void) 300static void acpi_suspend_finish(void)
276{ 301{
277 acpi_ec_unblock_transactions();
278 acpi_pm_finish(); 302 acpi_pm_finish();
279} 303}
280 304
@@ -377,20 +401,6 @@ static struct dmi_system_id __initdata acpisleep_dmi_table[] = {
377#endif /* CONFIG_SUSPEND */ 401#endif /* CONFIG_SUSPEND */
378 402
379#ifdef CONFIG_HIBERNATION 403#ifdef CONFIG_HIBERNATION
380/*
381 * The ACPI specification wants us to save NVS memory regions during hibernation
382 * and to restore them during the subsequent resume. However, it is not certain
383 * if this mechanism is going to work on all machines, so we allow the user to
384 * disable this mechanism using the 'acpi_sleep=s4_nonvs' kernel command line
385 * option.
386 */
387static bool s4_no_nvs;
388
389void __init acpi_s4_no_nvs(void)
390{
391 s4_no_nvs = true;
392}
393
394static unsigned long s4_hardware_signature; 404static unsigned long s4_hardware_signature;
395static struct acpi_table_facs *facs; 405static struct acpi_table_facs *facs;
396static bool nosigcheck; 406static bool nosigcheck;
@@ -404,7 +414,7 @@ static int acpi_hibernation_begin(void)
404{ 414{
405 int error; 415 int error;
406 416
407 error = s4_no_nvs ? 0 : hibernate_nvs_alloc(); 417 error = nvs_nosave ? 0 : suspend_nvs_alloc();
408 if (!error) { 418 if (!error) {
409 acpi_target_sleep_state = ACPI_STATE_S4; 419 acpi_target_sleep_state = ACPI_STATE_S4;
410 acpi_sleep_tts_switch(acpi_target_sleep_state); 420 acpi_sleep_tts_switch(acpi_target_sleep_state);
@@ -418,7 +428,7 @@ static int acpi_hibernation_pre_snapshot(void)
418 int error = acpi_pm_prepare(); 428 int error = acpi_pm_prepare();
419 429
420 if (!error) 430 if (!error)
421 hibernate_nvs_save(); 431 suspend_nvs_save();
422 432
423 return error; 433 return error;
424} 434}
@@ -441,13 +451,6 @@ static int acpi_hibernation_enter(void)
441 return ACPI_SUCCESS(status) ? 0 : -EFAULT; 451 return ACPI_SUCCESS(status) ? 0 : -EFAULT;
442} 452}
443 453
444static void acpi_hibernation_finish(void)
445{
446 hibernate_nvs_free();
447 acpi_ec_unblock_transactions();
448 acpi_pm_finish();
449}
450
451static void acpi_hibernation_leave(void) 454static void acpi_hibernation_leave(void)
452{ 455{
453 /* 456 /*
@@ -464,7 +467,7 @@ static void acpi_hibernation_leave(void)
464 panic("ACPI S4 hardware signature mismatch"); 467 panic("ACPI S4 hardware signature mismatch");
465 } 468 }
466 /* Restore the NVS memory area */ 469 /* Restore the NVS memory area */
467 hibernate_nvs_restore(); 470 suspend_nvs_restore();
468 /* Allow EC transactions to happen. */ 471 /* Allow EC transactions to happen. */
469 acpi_ec_unblock_transactions_early(); 472 acpi_ec_unblock_transactions_early();
470} 473}
@@ -479,7 +482,7 @@ static struct platform_hibernation_ops acpi_hibernation_ops = {
479 .begin = acpi_hibernation_begin, 482 .begin = acpi_hibernation_begin,
480 .end = acpi_pm_end, 483 .end = acpi_pm_end,
481 .pre_snapshot = acpi_hibernation_pre_snapshot, 484 .pre_snapshot = acpi_hibernation_pre_snapshot,
482 .finish = acpi_hibernation_finish, 485 .finish = acpi_pm_finish,
483 .prepare = acpi_pm_prepare, 486 .prepare = acpi_pm_prepare,
484 .enter = acpi_hibernation_enter, 487 .enter = acpi_hibernation_enter,
485 .leave = acpi_hibernation_leave, 488 .leave = acpi_hibernation_leave,
@@ -506,8 +509,8 @@ static int acpi_hibernation_begin_old(void)
506 error = acpi_sleep_prepare(ACPI_STATE_S4); 509 error = acpi_sleep_prepare(ACPI_STATE_S4);
507 510
508 if (!error) { 511 if (!error) {
509 if (!s4_no_nvs) 512 if (!nvs_nosave)
510 error = hibernate_nvs_alloc(); 513 error = suspend_nvs_alloc();
511 if (!error) 514 if (!error)
512 acpi_target_sleep_state = ACPI_STATE_S4; 515 acpi_target_sleep_state = ACPI_STATE_S4;
513 } 516 }
@@ -517,7 +520,7 @@ static int acpi_hibernation_begin_old(void)
517static int acpi_hibernation_pre_snapshot_old(void) 520static int acpi_hibernation_pre_snapshot_old(void)
518{ 521{
519 acpi_pm_freeze(); 522 acpi_pm_freeze();
520 hibernate_nvs_save(); 523 suspend_nvs_save();
521 return 0; 524 return 0;
522} 525}
523 526
@@ -529,8 +532,8 @@ static struct platform_hibernation_ops acpi_hibernation_ops_old = {
529 .begin = acpi_hibernation_begin_old, 532 .begin = acpi_hibernation_begin_old,
530 .end = acpi_pm_end, 533 .end = acpi_pm_end,
531 .pre_snapshot = acpi_hibernation_pre_snapshot_old, 534 .pre_snapshot = acpi_hibernation_pre_snapshot_old,
532 .finish = acpi_hibernation_finish,
533 .prepare = acpi_pm_freeze, 535 .prepare = acpi_pm_freeze,
536 .finish = acpi_pm_finish,
534 .enter = acpi_hibernation_enter, 537 .enter = acpi_hibernation_enter,
535 .leave = acpi_hibernation_leave, 538 .leave = acpi_hibernation_leave,
536 .pre_restore = acpi_pm_freeze, 539 .pre_restore = acpi_pm_freeze,
diff --git a/drivers/acpi/system.c b/drivers/acpi/system.c
index c79e789ed03a..f8db50a0941c 100644
--- a/drivers/acpi/system.c
+++ b/drivers/acpi/system.c
@@ -388,10 +388,12 @@ static ssize_t counter_set(struct kobject *kobj,
388 if (index < num_gpes) { 388 if (index < num_gpes) {
389 if (!strcmp(buf, "disable\n") && 389 if (!strcmp(buf, "disable\n") &&
390 (status & ACPI_EVENT_FLAG_ENABLED)) 390 (status & ACPI_EVENT_FLAG_ENABLED))
391 result = acpi_set_gpe(handle, index, ACPI_GPE_DISABLE); 391 result = acpi_disable_gpe(handle, index,
392 ACPI_GPE_TYPE_RUNTIME);
392 else if (!strcmp(buf, "enable\n") && 393 else if (!strcmp(buf, "enable\n") &&
393 !(status & ACPI_EVENT_FLAG_ENABLED)) 394 !(status & ACPI_EVENT_FLAG_ENABLED))
394 result = acpi_set_gpe(handle, index, ACPI_GPE_ENABLE); 395 result = acpi_enable_gpe(handle, index,
396 ACPI_GPE_TYPE_RUNTIME);
395 else if (!strcmp(buf, "clear\n") && 397 else if (!strcmp(buf, "clear\n") &&
396 (status & ACPI_EVENT_FLAG_SET)) 398 (status & ACPI_EVENT_FLAG_SET))
397 result = acpi_clear_gpe(handle, index); 399 result = acpi_clear_gpe(handle, index);
diff --git a/drivers/acpi/wakeup.c b/drivers/acpi/wakeup.c
index 4b9d339a6e28..388747a7ef4f 100644
--- a/drivers/acpi/wakeup.c
+++ b/drivers/acpi/wakeup.c
@@ -64,16 +64,13 @@ void acpi_enable_wakeup_device(u8 sleep_state)
64 struct acpi_device *dev = 64 struct acpi_device *dev =
65 container_of(node, struct acpi_device, wakeup_list); 65 container_of(node, struct acpi_device, wakeup_list);
66 66
67 if (!dev->wakeup.flags.valid) 67 if (!dev->wakeup.flags.valid || !dev->wakeup.state.enabled
68 continue;
69
70 if ((!dev->wakeup.state.enabled && !dev->wakeup.prepare_count)
71 || sleep_state > (u32) dev->wakeup.sleep_state) 68 || sleep_state > (u32) dev->wakeup.sleep_state)
72 continue; 69 continue;
73 70
74 /* The wake-up power should have been enabled already. */ 71 /* The wake-up power should have been enabled already. */
75 acpi_set_gpe(dev->wakeup.gpe_device, dev->wakeup.gpe_number, 72 acpi_enable_gpe(dev->wakeup.gpe_device, dev->wakeup.gpe_number,
76 ACPI_GPE_ENABLE); 73 ACPI_GPE_TYPE_WAKE);
77 } 74 }
78} 75}
79 76
@@ -96,6 +93,8 @@ void acpi_disable_wakeup_device(u8 sleep_state)
96 || (sleep_state > (u32) dev->wakeup.sleep_state)) 93 || (sleep_state > (u32) dev->wakeup.sleep_state))
97 continue; 94 continue;
98 95
96 acpi_disable_gpe(dev->wakeup.gpe_device, dev->wakeup.gpe_number,
97 ACPI_GPE_TYPE_WAKE);
99 acpi_disable_wakeup_device_power(dev); 98 acpi_disable_wakeup_device_power(dev);
100 } 99 }
101} 100}
@@ -109,13 +108,8 @@ int __init acpi_wakeup_device_init(void)
109 struct acpi_device *dev = container_of(node, 108 struct acpi_device *dev = container_of(node,
110 struct acpi_device, 109 struct acpi_device,
111 wakeup_list); 110 wakeup_list);
112 /* In case user doesn't load button driver */ 111 if (dev->wakeup.flags.always_enabled)
113 if (!dev->wakeup.flags.always_enabled || 112 dev->wakeup.state.enabled = 1;
114 dev->wakeup.state.enabled)
115 continue;
116 acpi_enable_gpe(dev->wakeup.gpe_device, dev->wakeup.gpe_number,
117 ACPI_GPE_TYPE_WAKE);
118 dev->wakeup.state.enabled = 1;
119 } 113 }
120 mutex_unlock(&acpi_device_lock); 114 mutex_unlock(&acpi_device_lock);
121 return 0; 115 return 0;
diff --git a/drivers/amba/bus.c b/drivers/amba/bus.c
index f60b2b6a0931..d31590e7011b 100644
--- a/drivers/amba/bus.c
+++ b/drivers/amba/bus.c
@@ -122,6 +122,31 @@ static int __init amba_init(void)
122 122
123postcore_initcall(amba_init); 123postcore_initcall(amba_init);
124 124
125static int amba_get_enable_pclk(struct amba_device *pcdev)
126{
127 struct clk *pclk = clk_get(&pcdev->dev, "apb_pclk");
128 int ret;
129
130 pcdev->pclk = pclk;
131
132 if (IS_ERR(pclk))
133 return PTR_ERR(pclk);
134
135 ret = clk_enable(pclk);
136 if (ret)
137 clk_put(pclk);
138
139 return ret;
140}
141
142static void amba_put_disable_pclk(struct amba_device *pcdev)
143{
144 struct clk *pclk = pcdev->pclk;
145
146 clk_disable(pclk);
147 clk_put(pclk);
148}
149
125/* 150/*
126 * These are the device model conversion veneers; they convert the 151 * These are the device model conversion veneers; they convert the
127 * device model structures to our more specific structures. 152 * device model structures to our more specific structures.
@@ -130,17 +155,33 @@ static int amba_probe(struct device *dev)
130{ 155{
131 struct amba_device *pcdev = to_amba_device(dev); 156 struct amba_device *pcdev = to_amba_device(dev);
132 struct amba_driver *pcdrv = to_amba_driver(dev->driver); 157 struct amba_driver *pcdrv = to_amba_driver(dev->driver);
133 struct amba_id *id; 158 struct amba_id *id = amba_lookup(pcdrv->id_table, pcdev);
159 int ret;
134 160
135 id = amba_lookup(pcdrv->id_table, pcdev); 161 do {
162 ret = amba_get_enable_pclk(pcdev);
163 if (ret)
164 break;
165
166 ret = pcdrv->probe(pcdev, id);
167 if (ret == 0)
168 break;
136 169
137 return pcdrv->probe(pcdev, id); 170 amba_put_disable_pclk(pcdev);
171 } while (0);
172
173 return ret;
138} 174}
139 175
140static int amba_remove(struct device *dev) 176static int amba_remove(struct device *dev)
141{ 177{
178 struct amba_device *pcdev = to_amba_device(dev);
142 struct amba_driver *drv = to_amba_driver(dev->driver); 179 struct amba_driver *drv = to_amba_driver(dev->driver);
143 return drv->remove(to_amba_device(dev)); 180 int ret = drv->remove(pcdev);
181
182 amba_put_disable_pclk(pcdev);
183
184 return ret;
144} 185}
145 186
146static void amba_shutdown(struct device *dev) 187static void amba_shutdown(struct device *dev)
@@ -203,7 +244,6 @@ static void amba_device_release(struct device *dev)
203 */ 244 */
204int amba_device_register(struct amba_device *dev, struct resource *parent) 245int amba_device_register(struct amba_device *dev, struct resource *parent)
205{ 246{
206 u32 pid, cid;
207 u32 size; 247 u32 size;
208 void __iomem *tmp; 248 void __iomem *tmp;
209 int i, ret; 249 int i, ret;
@@ -241,25 +281,35 @@ int amba_device_register(struct amba_device *dev, struct resource *parent)
241 goto err_release; 281 goto err_release;
242 } 282 }
243 283
244 /* 284 ret = amba_get_enable_pclk(dev);
245 * Read pid and cid based on size of resource 285 if (ret == 0) {
246 * they are located at end of region 286 u32 pid, cid;
247 */
248 for (pid = 0, i = 0; i < 4; i++)
249 pid |= (readl(tmp + size - 0x20 + 4 * i) & 255) << (i * 8);
250 for (cid = 0, i = 0; i < 4; i++)
251 cid |= (readl(tmp + size - 0x10 + 4 * i) & 255) << (i * 8);
252 287
253 iounmap(tmp); 288 /*
289 * Read pid and cid based on size of resource
290 * they are located at end of region
291 */
292 for (pid = 0, i = 0; i < 4; i++)
293 pid |= (readl(tmp + size - 0x20 + 4 * i) & 255) <<
294 (i * 8);
295 for (cid = 0, i = 0; i < 4; i++)
296 cid |= (readl(tmp + size - 0x10 + 4 * i) & 255) <<
297 (i * 8);
254 298
255 if (cid == 0xb105f00d) 299 amba_put_disable_pclk(dev);
256 dev->periphid = pid;
257 300
258 if (!dev->periphid) { 301 if (cid == 0xb105f00d)
259 ret = -ENODEV; 302 dev->periphid = pid;
260 goto err_release; 303
304 if (!dev->periphid)
305 ret = -ENODEV;
261 } 306 }
262 307
308 iounmap(tmp);
309
310 if (ret)
311 goto err_release;
312
263 ret = device_add(&dev->dev); 313 ret = device_add(&dev->dev);
264 if (ret) 314 if (ret)
265 goto err_release; 315 goto err_release;
diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c
index 8ca16f54e1ed..f2522534ae63 100644
--- a/drivers/ata/ahci.c
+++ b/drivers/ata/ahci.c
@@ -1053,6 +1053,16 @@ static int ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
1053 if (pdev->vendor == PCI_VENDOR_ID_MARVELL && !marvell_enable) 1053 if (pdev->vendor == PCI_VENDOR_ID_MARVELL && !marvell_enable)
1054 return -ENODEV; 1054 return -ENODEV;
1055 1055
1056 /*
1057 * For some reason, MCP89 on MacBook 7,1 doesn't work with
1058 * ahci, use ata_generic instead.
1059 */
1060 if (pdev->vendor == PCI_VENDOR_ID_NVIDIA &&
1061 pdev->device == PCI_DEVICE_ID_NVIDIA_NFORCE_MCP89_SATA &&
1062 pdev->subsystem_vendor == PCI_VENDOR_ID_APPLE &&
1063 pdev->subsystem_device == 0xcb89)
1064 return -ENODEV;
1065
1056 /* Promise's PDC42819 is a SAS/SATA controller that has an AHCI mode. 1066 /* Promise's PDC42819 is a SAS/SATA controller that has an AHCI mode.
1057 * At the moment, we can only use the AHCI mode. Let the users know 1067 * At the moment, we can only use the AHCI mode. Let the users know
1058 * that for SAS drives they're out of luck. 1068 * that for SAS drives they're out of luck.
diff --git a/drivers/ata/ata_generic.c b/drivers/ata/ata_generic.c
index 573158a9668d..7107a6929deb 100644
--- a/drivers/ata/ata_generic.c
+++ b/drivers/ata/ata_generic.c
@@ -32,6 +32,11 @@
32 * A generic parallel ATA driver using libata 32 * A generic parallel ATA driver using libata
33 */ 33 */
34 34
35enum {
36 ATA_GEN_CLASS_MATCH = (1 << 0),
37 ATA_GEN_FORCE_DMA = (1 << 1),
38};
39
35/** 40/**
36 * generic_set_mode - mode setting 41 * generic_set_mode - mode setting
37 * @link: link to set up 42 * @link: link to set up
@@ -46,13 +51,17 @@
46static int generic_set_mode(struct ata_link *link, struct ata_device **unused) 51static int generic_set_mode(struct ata_link *link, struct ata_device **unused)
47{ 52{
48 struct ata_port *ap = link->ap; 53 struct ata_port *ap = link->ap;
54 const struct pci_device_id *id = ap->host->private_data;
49 int dma_enabled = 0; 55 int dma_enabled = 0;
50 struct ata_device *dev; 56 struct ata_device *dev;
51 struct pci_dev *pdev = to_pci_dev(ap->host->dev); 57 struct pci_dev *pdev = to_pci_dev(ap->host->dev);
52 58
53 /* Bits 5 and 6 indicate if DMA is active on master/slave */ 59 if (id->driver_data & ATA_GEN_FORCE_DMA) {
54 if (ap->ioaddr.bmdma_addr) 60 dma_enabled = 0xff;
61 } else if (ap->ioaddr.bmdma_addr) {
62 /* Bits 5 and 6 indicate if DMA is active on master/slave */
55 dma_enabled = ioread8(ap->ioaddr.bmdma_addr + ATA_DMA_STATUS); 63 dma_enabled = ioread8(ap->ioaddr.bmdma_addr + ATA_DMA_STATUS);
64 }
56 65
57 if (pdev->vendor == PCI_VENDOR_ID_CENATEK) 66 if (pdev->vendor == PCI_VENDOR_ID_CENATEK)
58 dma_enabled = 0xFF; 67 dma_enabled = 0xFF;
@@ -126,7 +135,7 @@ static int ata_generic_init_one(struct pci_dev *dev, const struct pci_device_id
126 const struct ata_port_info *ppi[] = { &info, NULL }; 135 const struct ata_port_info *ppi[] = { &info, NULL };
127 136
128 /* Don't use the generic entry unless instructed to do so */ 137 /* Don't use the generic entry unless instructed to do so */
129 if (id->driver_data == 1 && all_generic_ide == 0) 138 if ((id->driver_data & ATA_GEN_CLASS_MATCH) && all_generic_ide == 0)
130 return -ENODEV; 139 return -ENODEV;
131 140
132 /* Devices that need care */ 141 /* Devices that need care */
@@ -155,7 +164,7 @@ static int ata_generic_init_one(struct pci_dev *dev, const struct pci_device_id
155 return rc; 164 return rc;
156 pcim_pin_device(dev); 165 pcim_pin_device(dev);
157 } 166 }
158 return ata_pci_bmdma_init_one(dev, ppi, &generic_sht, NULL, 0); 167 return ata_pci_bmdma_init_one(dev, ppi, &generic_sht, (void *)id, 0);
159} 168}
160 169
161static struct pci_device_id ata_generic[] = { 170static struct pci_device_id ata_generic[] = {
@@ -167,7 +176,15 @@ static struct pci_device_id ata_generic[] = {
167 { PCI_DEVICE(PCI_VENDOR_ID_HINT, PCI_DEVICE_ID_HINT_VXPROII_IDE), }, 176 { PCI_DEVICE(PCI_VENDOR_ID_HINT, PCI_DEVICE_ID_HINT_VXPROII_IDE), },
168 { PCI_DEVICE(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C561), }, 177 { PCI_DEVICE(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C561), },
169 { PCI_DEVICE(PCI_VENDOR_ID_OPTI, PCI_DEVICE_ID_OPTI_82C558), }, 178 { PCI_DEVICE(PCI_VENDOR_ID_OPTI, PCI_DEVICE_ID_OPTI_82C558), },
170 { PCI_DEVICE(PCI_VENDOR_ID_CENATEK,PCI_DEVICE_ID_CENATEK_IDE), }, 179 { PCI_DEVICE(PCI_VENDOR_ID_CENATEK,PCI_DEVICE_ID_CENATEK_IDE),
180 .driver_data = ATA_GEN_FORCE_DMA },
181 /*
182 * For some reason, MCP89 on MacBook 7,1 doesn't work with
183 * ahci, use ata_generic instead.
184 */
185 { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP89_SATA,
186 PCI_VENDOR_ID_APPLE, 0xcb89,
187 .driver_data = ATA_GEN_FORCE_DMA },
171#if !defined(CONFIG_PATA_TOSHIBA) && !defined(CONFIG_PATA_TOSHIBA_MODULE) 188#if !defined(CONFIG_PATA_TOSHIBA) && !defined(CONFIG_PATA_TOSHIBA_MODULE)
172 { PCI_DEVICE(PCI_VENDOR_ID_TOSHIBA,PCI_DEVICE_ID_TOSHIBA_PICCOLO_1), }, 189 { PCI_DEVICE(PCI_VENDOR_ID_TOSHIBA,PCI_DEVICE_ID_TOSHIBA_PICCOLO_1), },
173 { PCI_DEVICE(PCI_VENDOR_ID_TOSHIBA,PCI_DEVICE_ID_TOSHIBA_PICCOLO_2), }, 190 { PCI_DEVICE(PCI_VENDOR_ID_TOSHIBA,PCI_DEVICE_ID_TOSHIBA_PICCOLO_2), },
@@ -175,7 +192,8 @@ static struct pci_device_id ata_generic[] = {
175 { PCI_DEVICE(PCI_VENDOR_ID_TOSHIBA,PCI_DEVICE_ID_TOSHIBA_PICCOLO_5), }, 192 { PCI_DEVICE(PCI_VENDOR_ID_TOSHIBA,PCI_DEVICE_ID_TOSHIBA_PICCOLO_5), },
176#endif 193#endif
177 /* Must come last. If you add entries adjust this table appropriately */ 194 /* Must come last. If you add entries adjust this table appropriately */
178 { PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_STORAGE_IDE << 8, 0xFFFFFF00UL, 1}, 195 { PCI_DEVICE_CLASS(PCI_CLASS_STORAGE_IDE << 8, 0xFFFFFF00UL),
196 .driver_data = ATA_GEN_CLASS_MATCH },
179 { 0, }, 197 { 0, },
180}; 198};
181 199
diff --git a/drivers/ata/libahci.c b/drivers/ata/libahci.c
index 261f86d102e8..81e772a94d59 100644
--- a/drivers/ata/libahci.c
+++ b/drivers/ata/libahci.c
@@ -324,6 +324,7 @@ static ssize_t ahci_store_em_buffer(struct device *dev,
324 struct ahci_host_priv *hpriv = ap->host->private_data; 324 struct ahci_host_priv *hpriv = ap->host->private_data;
325 void __iomem *mmio = hpriv->mmio; 325 void __iomem *mmio = hpriv->mmio;
326 void __iomem *em_mmio = mmio + hpriv->em_loc; 326 void __iomem *em_mmio = mmio + hpriv->em_loc;
327 const unsigned char *msg_buf = buf;
327 u32 em_ctl, msg; 328 u32 em_ctl, msg;
328 unsigned long flags; 329 unsigned long flags;
329 int i; 330 int i;
@@ -343,8 +344,8 @@ static ssize_t ahci_store_em_buffer(struct device *dev,
343 } 344 }
344 345
345 for (i = 0; i < size; i += 4) { 346 for (i = 0; i < size; i += 4) {
346 msg = buf[i] | buf[i + 1] << 8 | 347 msg = msg_buf[i] | msg_buf[i + 1] << 8 |
347 buf[i + 2] << 16 | buf[i + 3] << 24; 348 msg_buf[i + 2] << 16 | msg_buf[i + 3] << 24;
348 writel(msg, em_mmio + i); 349 writel(msg, em_mmio + i);
349 } 350 }
350 351
diff --git a/drivers/base/core.c b/drivers/base/core.c
index 9630fbdf4e6c..9b9d3bd54e3a 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -673,7 +673,7 @@ static struct kobject *get_device_parent(struct device *dev,
673 */ 673 */
674 if (parent == NULL) 674 if (parent == NULL)
675 parent_kobj = virtual_device_parent(dev); 675 parent_kobj = virtual_device_parent(dev);
676 else if (parent->class) 676 else if (parent->class && !dev->class->ns_type)
677 return &parent->kobj; 677 return &parent->kobj;
678 else 678 else
679 parent_kobj = &parent->kobj; 679 parent_kobj = &parent->kobj;
diff --git a/drivers/block/cciss_scsi.c b/drivers/block/cciss_scsi.c
index 3381505c8a6c..72dae92f3cab 100644
--- a/drivers/block/cciss_scsi.c
+++ b/drivers/block/cciss_scsi.c
@@ -861,6 +861,7 @@ cciss_scsi_detect(int ctlr)
861 sh->n_io_port = 0; // I don't think we use these two... 861 sh->n_io_port = 0; // I don't think we use these two...
862 sh->this_id = SELF_SCSI_ID; 862 sh->this_id = SELF_SCSI_ID;
863 sh->sg_tablesize = hba[ctlr]->maxsgentries; 863 sh->sg_tablesize = hba[ctlr]->maxsgentries;
864 sh->max_cmd_len = MAX_COMMAND_SIZE;
864 865
865 ((struct cciss_scsi_adapter_data_t *) 866 ((struct cciss_scsi_adapter_data_t *)
866 hba[ctlr]->scsi_ctlr)->scsi_host = sh; 867 hba[ctlr]->scsi_ctlr)->scsi_host = sh;
diff --git a/drivers/block/cpqarray.c b/drivers/block/cpqarray.c
index 91d11631cec9..abb4ec6690fc 100644
--- a/drivers/block/cpqarray.c
+++ b/drivers/block/cpqarray.c
@@ -386,7 +386,7 @@ static void __devexit cpqarray_remove_one_eisa (int i)
386} 386}
387 387
388/* pdev is NULL for eisa */ 388/* pdev is NULL for eisa */
389static int __init cpqarray_register_ctlr( int i, struct pci_dev *pdev) 389static int __devinit cpqarray_register_ctlr( int i, struct pci_dev *pdev)
390{ 390{
391 struct request_queue *q; 391 struct request_queue *q;
392 int j; 392 int j;
@@ -503,7 +503,7 @@ Enomem4:
503 return -1; 503 return -1;
504} 504}
505 505
506static int __init cpqarray_init_one( struct pci_dev *pdev, 506static int __devinit cpqarray_init_one( struct pci_dev *pdev,
507 const struct pci_device_id *ent) 507 const struct pci_device_id *ent)
508{ 508{
509 int i; 509 int i;
@@ -740,7 +740,7 @@ __setup("smart2=", cpqarray_setup);
740/* 740/*
741 * Find an EISA controller's signature. Set up an hba if we find it. 741 * Find an EISA controller's signature. Set up an hba if we find it.
742 */ 742 */
743static int __init cpqarray_eisa_detect(void) 743static int __devinit cpqarray_eisa_detect(void)
744{ 744{
745 int i=0, j; 745 int i=0, j;
746 __u32 board_id; 746 __u32 board_id;
diff --git a/drivers/block/drbd/drbd_main.c b/drivers/block/drbd/drbd_main.c
index 6b077f93acc6..7258c95e895e 100644
--- a/drivers/block/drbd/drbd_main.c
+++ b/drivers/block/drbd/drbd_main.c
@@ -1236,8 +1236,6 @@ static void after_state_ch(struct drbd_conf *mdev, union drbd_state os,
1236 /* Last part of the attaching process ... */ 1236 /* Last part of the attaching process ... */
1237 if (ns.conn >= C_CONNECTED && 1237 if (ns.conn >= C_CONNECTED &&
1238 os.disk == D_ATTACHING && ns.disk == D_NEGOTIATING) { 1238 os.disk == D_ATTACHING && ns.disk == D_NEGOTIATING) {
1239 kfree(mdev->p_uuid); /* We expect to receive up-to-date UUIDs soon. */
1240 mdev->p_uuid = NULL; /* ...to not use the old ones in the mean time */
1241 drbd_send_sizes(mdev, 0, 0); /* to start sync... */ 1239 drbd_send_sizes(mdev, 0, 0); /* to start sync... */
1242 drbd_send_uuids(mdev); 1240 drbd_send_uuids(mdev);
1243 drbd_send_state(mdev); 1241 drbd_send_state(mdev);
diff --git a/drivers/block/drbd/drbd_nl.c b/drivers/block/drbd/drbd_nl.c
index 632e3245d1bb..2151f18b21de 100644
--- a/drivers/block/drbd/drbd_nl.c
+++ b/drivers/block/drbd/drbd_nl.c
@@ -1114,6 +1114,12 @@ static int drbd_nl_disk_conf(struct drbd_conf *mdev, struct drbd_nl_cfg_req *nlp
1114 mdev->new_state_tmp.i = ns.i; 1114 mdev->new_state_tmp.i = ns.i;
1115 ns.i = os.i; 1115 ns.i = os.i;
1116 ns.disk = D_NEGOTIATING; 1116 ns.disk = D_NEGOTIATING;
1117
1118 /* We expect to receive up-to-date UUIDs soon.
1119 To avoid a race in receive_state, free p_uuid while
1120 holding req_lock. I.e. atomic with the state change */
1121 kfree(mdev->p_uuid);
1122 mdev->p_uuid = NULL;
1117 } 1123 }
1118 1124
1119 rv = _drbd_set_state(mdev, ns, CS_VERBOSE, NULL); 1125 rv = _drbd_set_state(mdev, ns, CS_VERBOSE, NULL);
diff --git a/drivers/bluetooth/bluecard_cs.c b/drivers/bluetooth/bluecard_cs.c
index 6f907ebed2d5..6d34f405a2f3 100644
--- a/drivers/bluetooth/bluecard_cs.c
+++ b/drivers/bluetooth/bluecard_cs.c
@@ -37,7 +37,7 @@
37#include <linux/wait.h> 37#include <linux/wait.h>
38 38
39#include <linux/skbuff.h> 39#include <linux/skbuff.h>
40#include <asm/io.h> 40#include <linux/io.h>
41 41
42#include <pcmcia/cs_types.h> 42#include <pcmcia/cs_types.h>
43#include <pcmcia/cs.h> 43#include <pcmcia/cs.h>
diff --git a/drivers/bluetooth/hci_bcsp.c b/drivers/bluetooth/hci_bcsp.c
index 40aec0fb8596..42d69d4de05c 100644
--- a/drivers/bluetooth/hci_bcsp.c
+++ b/drivers/bluetooth/hci_bcsp.c
@@ -244,7 +244,7 @@ static struct sk_buff *bcsp_prepare_pkt(struct bcsp_struct *bcsp, u8 *data,
244 if (rel) { 244 if (rel) {
245 hdr[0] |= 0x80 + bcsp->msgq_txseq; 245 hdr[0] |= 0x80 + bcsp->msgq_txseq;
246 BT_DBG("Sending packet with seqno %u", bcsp->msgq_txseq); 246 BT_DBG("Sending packet with seqno %u", bcsp->msgq_txseq);
247 bcsp->msgq_txseq = ++(bcsp->msgq_txseq) & 0x07; 247 bcsp->msgq_txseq = (bcsp->msgq_txseq + 1) & 0x07;
248 } 248 }
249 249
250 if (bcsp->use_crc) 250 if (bcsp->use_crc)
diff --git a/drivers/char/agp/generic.c b/drivers/char/agp/generic.c
index 4b51982fd23a..d2abf5143983 100644
--- a/drivers/char/agp/generic.c
+++ b/drivers/char/agp/generic.c
@@ -97,20 +97,18 @@ EXPORT_SYMBOL(agp_flush_chipset);
97void agp_alloc_page_array(size_t size, struct agp_memory *mem) 97void agp_alloc_page_array(size_t size, struct agp_memory *mem)
98{ 98{
99 mem->pages = NULL; 99 mem->pages = NULL;
100 mem->vmalloc_flag = false;
101 100
102 if (size <= 2*PAGE_SIZE) 101 if (size <= 2*PAGE_SIZE)
103 mem->pages = kmalloc(size, GFP_KERNEL | __GFP_NORETRY); 102 mem->pages = kmalloc(size, GFP_KERNEL | __GFP_NOWARN);
104 if (mem->pages == NULL) { 103 if (mem->pages == NULL) {
105 mem->pages = vmalloc(size); 104 mem->pages = vmalloc(size);
106 mem->vmalloc_flag = true;
107 } 105 }
108} 106}
109EXPORT_SYMBOL(agp_alloc_page_array); 107EXPORT_SYMBOL(agp_alloc_page_array);
110 108
111void agp_free_page_array(struct agp_memory *mem) 109void agp_free_page_array(struct agp_memory *mem)
112{ 110{
113 if (mem->vmalloc_flag) { 111 if (is_vmalloc_addr(mem->pages)) {
114 vfree(mem->pages); 112 vfree(mem->pages);
115 } else { 113 } else {
116 kfree(mem->pages); 114 kfree(mem->pages);
diff --git a/drivers/char/agp/intel-gtt.c b/drivers/char/agp/intel-gtt.c
index 9344216183a4..a7547150a705 100644
--- a/drivers/char/agp/intel-gtt.c
+++ b/drivers/char/agp/intel-gtt.c
@@ -1216,17 +1216,20 @@ static int intel_i915_get_gtt_size(void)
1216 1216
1217 /* G33's GTT size defined in gmch_ctrl */ 1217 /* G33's GTT size defined in gmch_ctrl */
1218 pci_read_config_word(agp_bridge->dev, I830_GMCH_CTRL, &gmch_ctrl); 1218 pci_read_config_word(agp_bridge->dev, I830_GMCH_CTRL, &gmch_ctrl);
1219 switch (gmch_ctrl & G33_PGETBL_SIZE_MASK) { 1219 switch (gmch_ctrl & I830_GMCH_GMS_MASK) {
1220 case G33_PGETBL_SIZE_1M: 1220 case I830_GMCH_GMS_STOLEN_512:
1221 size = 512;
1222 break;
1223 case I830_GMCH_GMS_STOLEN_1024:
1221 size = 1024; 1224 size = 1024;
1222 break; 1225 break;
1223 case G33_PGETBL_SIZE_2M: 1226 case I830_GMCH_GMS_STOLEN_8192:
1224 size = 2048; 1227 size = 8*1024;
1225 break; 1228 break;
1226 default: 1229 default:
1227 dev_info(&agp_bridge->dev->dev, 1230 dev_info(&agp_bridge->dev->dev,
1228 "unknown page table size 0x%x, assuming 512KB\n", 1231 "unknown page table size 0x%x, assuming 512KB\n",
1229 (gmch_ctrl & G33_PGETBL_SIZE_MASK)); 1232 (gmch_ctrl & I830_GMCH_GMS_MASK));
1230 size = 512; 1233 size = 512;
1231 } 1234 }
1232 } else { 1235 } else {
diff --git a/drivers/char/ipmi/ipmi_si_intf.c b/drivers/char/ipmi/ipmi_si_intf.c
index 35603dd4e6c5..094bdc355b1f 100644
--- a/drivers/char/ipmi/ipmi_si_intf.c
+++ b/drivers/char/ipmi/ipmi_si_intf.c
@@ -302,6 +302,12 @@ struct smi_info {
302 302
303static int force_kipmid[SI_MAX_PARMS]; 303static int force_kipmid[SI_MAX_PARMS];
304static int num_force_kipmid; 304static int num_force_kipmid;
305#ifdef CONFIG_PCI
306static int pci_registered;
307#endif
308#ifdef CONFIG_PPC_OF
309static int of_registered;
310#endif
305 311
306static unsigned int kipmid_max_busy_us[SI_MAX_PARMS]; 312static unsigned int kipmid_max_busy_us[SI_MAX_PARMS];
307static int num_max_busy_us; 313static int num_max_busy_us;
@@ -1018,7 +1024,7 @@ static int ipmi_thread(void *data)
1018 else if (smi_result == SI_SM_IDLE) 1024 else if (smi_result == SI_SM_IDLE)
1019 schedule_timeout_interruptible(100); 1025 schedule_timeout_interruptible(100);
1020 else 1026 else
1021 schedule_timeout_interruptible(0); 1027 schedule_timeout_interruptible(1);
1022 } 1028 }
1023 return 0; 1029 return 0;
1024} 1030}
@@ -3314,6 +3320,8 @@ static __devinit int init_ipmi_si(void)
3314 rv = pci_register_driver(&ipmi_pci_driver); 3320 rv = pci_register_driver(&ipmi_pci_driver);
3315 if (rv) 3321 if (rv)
3316 printk(KERN_ERR PFX "Unable to register PCI driver: %d\n", rv); 3322 printk(KERN_ERR PFX "Unable to register PCI driver: %d\n", rv);
3323 else
3324 pci_registered = 1;
3317#endif 3325#endif
3318 3326
3319#ifdef CONFIG_ACPI 3327#ifdef CONFIG_ACPI
@@ -3330,6 +3338,7 @@ static __devinit int init_ipmi_si(void)
3330 3338
3331#ifdef CONFIG_PPC_OF 3339#ifdef CONFIG_PPC_OF
3332 of_register_platform_driver(&ipmi_of_platform_driver); 3340 of_register_platform_driver(&ipmi_of_platform_driver);
3341 of_registered = 1;
3333#endif 3342#endif
3334 3343
3335 /* We prefer devices with interrupts, but in the case of a machine 3344 /* We prefer devices with interrupts, but in the case of a machine
@@ -3383,11 +3392,13 @@ static __devinit int init_ipmi_si(void)
3383 if (unload_when_empty && list_empty(&smi_infos)) { 3392 if (unload_when_empty && list_empty(&smi_infos)) {
3384 mutex_unlock(&smi_infos_lock); 3393 mutex_unlock(&smi_infos_lock);
3385#ifdef CONFIG_PCI 3394#ifdef CONFIG_PCI
3386 pci_unregister_driver(&ipmi_pci_driver); 3395 if (pci_registered)
3396 pci_unregister_driver(&ipmi_pci_driver);
3387#endif 3397#endif
3388 3398
3389#ifdef CONFIG_PPC_OF 3399#ifdef CONFIG_PPC_OF
3390 of_unregister_platform_driver(&ipmi_of_platform_driver); 3400 if (of_registered)
3401 of_unregister_platform_driver(&ipmi_of_platform_driver);
3391#endif 3402#endif
3392 driver_unregister(&ipmi_driver.driver); 3403 driver_unregister(&ipmi_driver.driver);
3393 printk(KERN_WARNING PFX 3404 printk(KERN_WARNING PFX
@@ -3478,14 +3489,16 @@ static __exit void cleanup_ipmi_si(void)
3478 return; 3489 return;
3479 3490
3480#ifdef CONFIG_PCI 3491#ifdef CONFIG_PCI
3481 pci_unregister_driver(&ipmi_pci_driver); 3492 if (pci_registered)
3493 pci_unregister_driver(&ipmi_pci_driver);
3482#endif 3494#endif
3483#ifdef CONFIG_ACPI 3495#ifdef CONFIG_ACPI
3484 pnp_unregister_driver(&ipmi_pnp_driver); 3496 pnp_unregister_driver(&ipmi_pnp_driver);
3485#endif 3497#endif
3486 3498
3487#ifdef CONFIG_PPC_OF 3499#ifdef CONFIG_PPC_OF
3488 of_unregister_platform_driver(&ipmi_of_platform_driver); 3500 if (of_registered)
3501 of_unregister_platform_driver(&ipmi_of_platform_driver);
3489#endif 3502#endif
3490 3503
3491 mutex_lock(&smi_infos_lock); 3504 mutex_lock(&smi_infos_lock);
diff --git a/drivers/char/sysrq.c b/drivers/char/sysrq.c
index 5d15630a5830..878ac0c2cc68 100644
--- a/drivers/char/sysrq.c
+++ b/drivers/char/sysrq.c
@@ -493,7 +493,7 @@ static void __sysrq_put_key_op(int key, struct sysrq_key_op *op_p)
493 sysrq_key_table[i] = op_p; 493 sysrq_key_table[i] = op_p;
494} 494}
495 495
496static void __handle_sysrq(int key, struct tty_struct *tty, int check_mask) 496void __handle_sysrq(int key, struct tty_struct *tty, int check_mask)
497{ 497{
498 struct sysrq_key_op *op_p; 498 struct sysrq_key_op *op_p;
499 int orig_log_level; 499 int orig_log_level;
@@ -580,8 +580,12 @@ static bool sysrq_filter(struct input_handle *handle, unsigned int type,
580 case KEY_RIGHTALT: 580 case KEY_RIGHTALT:
581 if (value) 581 if (value)
582 sysrq_alt = code; 582 sysrq_alt = code;
583 else if (sysrq_down && code == sysrq_alt_use) 583 else {
584 sysrq_down = false; 584 if (sysrq_down && code == sysrq_alt_use)
585 sysrq_down = false;
586
587 sysrq_alt = 0;
588 }
585 break; 589 break;
586 590
587 case KEY_SYSRQ: 591 case KEY_SYSRQ:
diff --git a/drivers/char/tpm/tpm.h b/drivers/char/tpm/tpm.h
index 8e00b4ddd083..792868d24f2a 100644
--- a/drivers/char/tpm/tpm.h
+++ b/drivers/char/tpm/tpm.h
@@ -224,6 +224,7 @@ struct tpm_readpubek_params_out {
224 u8 algorithm[4]; 224 u8 algorithm[4];
225 u8 encscheme[2]; 225 u8 encscheme[2];
226 u8 sigscheme[2]; 226 u8 sigscheme[2];
227 __be32 paramsize;
227 u8 parameters[12]; /*assuming RSA*/ 228 u8 parameters[12]; /*assuming RSA*/
228 __be32 keysize; 229 __be32 keysize;
229 u8 modulus[256]; 230 u8 modulus[256];
diff --git a/drivers/char/tpm/tpm_tis.c b/drivers/char/tpm/tpm_tis.c
index 24314a9cffe8..1030f8420137 100644
--- a/drivers/char/tpm/tpm_tis.c
+++ b/drivers/char/tpm/tpm_tis.c
@@ -623,7 +623,14 @@ static int tpm_tis_pnp_suspend(struct pnp_dev *dev, pm_message_t msg)
623 623
624static int tpm_tis_pnp_resume(struct pnp_dev *dev) 624static int tpm_tis_pnp_resume(struct pnp_dev *dev)
625{ 625{
626 return tpm_pm_resume(&dev->dev); 626 struct tpm_chip *chip = pnp_get_drvdata(dev);
627 int ret;
628
629 ret = tpm_pm_resume(&dev->dev);
630 if (!ret)
631 tpm_continue_selftest(chip);
632
633 return ret;
627} 634}
628 635
629static struct pnp_device_id tpm_pnp_tbl[] __devinitdata = { 636static struct pnp_device_id tpm_pnp_tbl[] __devinitdata = {
diff --git a/drivers/clocksource/cs5535-clockevt.c b/drivers/clocksource/cs5535-clockevt.c
index d7be69f13154..b7dab32ce63c 100644
--- a/drivers/clocksource/cs5535-clockevt.c
+++ b/drivers/clocksource/cs5535-clockevt.c
@@ -194,6 +194,6 @@ err_timer:
194 194
195module_init(cs5535_mfgpt_init); 195module_init(cs5535_mfgpt_init);
196 196
197MODULE_AUTHOR("Andres Salomon <dilinger@collabora.co.uk>"); 197MODULE_AUTHOR("Andres Salomon <dilinger@queued.net>");
198MODULE_DESCRIPTION("CS5535/CS5536 MFGPT clock event driver"); 198MODULE_DESCRIPTION("CS5535/CS5536 MFGPT clock event driver");
199MODULE_LICENSE("GPL"); 199MODULE_LICENSE("GPL");
diff --git a/drivers/clocksource/sh_cmt.c b/drivers/clocksource/sh_cmt.c
index f3d3898898ed..717305d30444 100644
--- a/drivers/clocksource/sh_cmt.c
+++ b/drivers/clocksource/sh_cmt.c
@@ -449,7 +449,7 @@ static int sh_cmt_register_clocksource(struct sh_cmt_priv *p,
449 clk_disable(p->clk); 449 clk_disable(p->clk);
450 450
451 /* TODO: calculate good shift from rate and counter bit width */ 451 /* TODO: calculate good shift from rate and counter bit width */
452 cs->shift = 10; 452 cs->shift = 0;
453 cs->mult = clocksource_hz2mult(p->rate, cs->shift); 453 cs->mult = clocksource_hz2mult(p->rate, cs->shift);
454 454
455 dev_info(&p->pdev->dev, "used as clock source\n"); 455 dev_info(&p->pdev->dev, "used as clock source\n");
diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index 063b2184caf5..938b74ea9ffb 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -1077,6 +1077,7 @@ err_out_unregister:
1077 1077
1078err_unlock_policy: 1078err_unlock_policy:
1079 unlock_policy_rwsem_write(cpu); 1079 unlock_policy_rwsem_write(cpu);
1080 free_cpumask_var(policy->related_cpus);
1080err_free_cpumask: 1081err_free_cpumask:
1081 free_cpumask_var(policy->cpus); 1082 free_cpumask_var(policy->cpus);
1082err_free_policy: 1083err_free_policy:
@@ -1762,17 +1763,8 @@ static int __cpufreq_set_policy(struct cpufreq_policy *data,
1762 dprintk("governor switch\n"); 1763 dprintk("governor switch\n");
1763 1764
1764 /* end old governor */ 1765 /* end old governor */
1765 if (data->governor) { 1766 if (data->governor)
1766 /*
1767 * Need to release the rwsem around governor
1768 * stop due to lock dependency between
1769 * cancel_delayed_work_sync and the read lock
1770 * taken in the delayed work handler.
1771 */
1772 unlock_policy_rwsem_write(data->cpu);
1773 __cpufreq_governor(data, CPUFREQ_GOV_STOP); 1767 __cpufreq_governor(data, CPUFREQ_GOV_STOP);
1774 lock_policy_rwsem_write(data->cpu);
1775 }
1776 1768
1777 /* start new governor */ 1769 /* start new governor */
1778 data->governor = policy->governor; 1770 data->governor = policy->governor;
diff --git a/drivers/cpuidle/governors/menu.c b/drivers/cpuidle/governors/menu.c
index 52ff8aa63f84..1b128702d300 100644
--- a/drivers/cpuidle/governors/menu.c
+++ b/drivers/cpuidle/governors/menu.c
@@ -143,7 +143,7 @@ static inline int which_bucket(unsigned int duration)
143 * This allows us to calculate 143 * This allows us to calculate
144 * E(duration)|iowait 144 * E(duration)|iowait
145 */ 145 */
146 if (nr_iowait_cpu()) 146 if (nr_iowait_cpu(smp_processor_id()))
147 bucket = BUCKETS/2; 147 bucket = BUCKETS/2;
148 148
149 if (duration < 10) 149 if (duration < 10)
@@ -175,7 +175,7 @@ static inline int performance_multiplier(void)
175 mult += 2 * get_loadavg(); 175 mult += 2 * get_loadavg();
176 176
177 /* for IO wait tasks (per cpu!) we add 5x each */ 177 /* for IO wait tasks (per cpu!) we add 5x each */
178 mult += 10 * nr_iowait_cpu(); 178 mult += 10 * nr_iowait_cpu(smp_processor_id());
179 179
180 return mult; 180 return mult;
181} 181}
diff --git a/drivers/crypto/talitos.c b/drivers/crypto/talitos.c
index 637c105f53d2..bd78acf3c365 100644
--- a/drivers/crypto/talitos.c
+++ b/drivers/crypto/talitos.c
@@ -1183,10 +1183,14 @@ static size_t sg_copy_end_to_buffer(struct scatterlist *sgl, unsigned int nents,
1183 /* Copy part of this segment */ 1183 /* Copy part of this segment */
1184 ignore = skip - offset; 1184 ignore = skip - offset;
1185 len = miter.length - ignore; 1185 len = miter.length - ignore;
1186 if (boffset + len > buflen)
1187 len = buflen - boffset;
1186 memcpy(buf + boffset, miter.addr + ignore, len); 1188 memcpy(buf + boffset, miter.addr + ignore, len);
1187 } else { 1189 } else {
1188 /* Copy all of this segment */ 1190 /* Copy all of this segment (up to buflen) */
1189 len = miter.length; 1191 len = miter.length;
1192 if (boffset + len > buflen)
1193 len = buflen - boffset;
1190 memcpy(buf + boffset, miter.addr, len); 1194 memcpy(buf + boffset, miter.addr, len);
1191 } 1195 }
1192 boffset += len; 1196 boffset += len;
diff --git a/drivers/dma/ppc4xx/adma.c b/drivers/dma/ppc4xx/adma.c
index 5a22ca6927e5..7c3747902a37 100644
--- a/drivers/dma/ppc4xx/adma.c
+++ b/drivers/dma/ppc4xx/adma.c
@@ -4257,10 +4257,12 @@ static int ppc440spe_adma_setup_irqs(struct ppc440spe_adma_device *adev,
4257 struct ppc440spe_adma_chan *chan, 4257 struct ppc440spe_adma_chan *chan,
4258 int *initcode) 4258 int *initcode)
4259{ 4259{
4260 struct of_device *ofdev;
4260 struct device_node *np; 4261 struct device_node *np;
4261 int ret; 4262 int ret;
4262 4263
4263 np = container_of(adev->dev, struct of_device, dev)->node; 4264 ofdev = container_of(adev->dev, struct of_device, dev);
4265 np = ofdev->dev.of_node;
4264 if (adev->id != PPC440SPE_XOR_ID) { 4266 if (adev->id != PPC440SPE_XOR_ID) {
4265 adev->err_irq = irq_of_parse_and_map(np, 1); 4267 adev->err_irq = irq_of_parse_and_map(np, 1);
4266 if (adev->err_irq == NO_IRQ) { 4268 if (adev->err_irq == NO_IRQ) {
diff --git a/drivers/edac/Kconfig b/drivers/edac/Kconfig
index aedef7941b22..0d2f9dbb47e4 100644
--- a/drivers/edac/Kconfig
+++ b/drivers/edac/Kconfig
@@ -209,7 +209,7 @@ config EDAC_I5100
209 209
210config EDAC_MPC85XX 210config EDAC_MPC85XX
211 tristate "Freescale MPC83xx / MPC85xx" 211 tristate "Freescale MPC83xx / MPC85xx"
212 depends on EDAC_MM_EDAC && FSL_SOC && (PPC_83xx || MPC85xx) 212 depends on EDAC_MM_EDAC && FSL_SOC && (PPC_83xx || PPC_85xx)
213 help 213 help
214 Support for error detection and correction on the Freescale 214 Support for error detection and correction on the Freescale
215 MPC8349, MPC8560, MPC8540, MPC8548 215 MPC8349, MPC8560, MPC8540, MPC8548
diff --git a/drivers/edac/amd64_edac.c b/drivers/edac/amd64_edac.c
index cf17dbb8014f..ac9f7985096d 100644
--- a/drivers/edac/amd64_edac.c
+++ b/drivers/edac/amd64_edac.c
@@ -1958,20 +1958,20 @@ static int get_channel_from_ecc_syndrome(struct mem_ctl_info *mci, u16 syndrome)
1958 u32 value = 0; 1958 u32 value = 0;
1959 int err_sym = 0; 1959 int err_sym = 0;
1960 1960
1961 amd64_read_pci_cfg(pvt->misc_f3_ctl, 0x180, &value); 1961 if (boot_cpu_data.x86 == 0x10) {
1962 1962
1963 /* F3x180[EccSymbolSize]=1, x8 symbols */ 1963 amd64_read_pci_cfg(pvt->misc_f3_ctl, 0x180, &value);
1964 if (boot_cpu_data.x86 == 0x10 && 1964
1965 boot_cpu_data.x86_model > 7 && 1965 /* F3x180[EccSymbolSize]=1 => x8 symbols */
1966 value & BIT(25)) { 1966 if (boot_cpu_data.x86_model > 7 &&
1967 err_sym = decode_syndrome(syndrome, x8_vectors, 1967 value & BIT(25)) {
1968 ARRAY_SIZE(x8_vectors), 8); 1968 err_sym = decode_syndrome(syndrome, x8_vectors,
1969 return map_err_sym_to_channel(err_sym, 8); 1969 ARRAY_SIZE(x8_vectors), 8);
1970 } else { 1970 return map_err_sym_to_channel(err_sym, 8);
1971 err_sym = decode_syndrome(syndrome, x4_vectors, 1971 }
1972 ARRAY_SIZE(x4_vectors), 4);
1973 return map_err_sym_to_channel(err_sym, 4);
1974 } 1972 }
1973 err_sym = decode_syndrome(syndrome, x4_vectors, ARRAY_SIZE(x4_vectors), 4);
1974 return map_err_sym_to_channel(err_sym, 4);
1975} 1975}
1976 1976
1977/* 1977/*
diff --git a/drivers/edac/i7core_edac.c b/drivers/edac/i7core_edac.c
index 6b8b7b41ec5f..e0187d16dd7c 100644
--- a/drivers/edac/i7core_edac.c
+++ b/drivers/edac/i7core_edac.c
@@ -1233,10 +1233,28 @@ static void __init i7core_xeon_pci_fixup(struct pci_id_table *table)
1233 for (i = 0; i < MAX_SOCKET_BUSES; i++) 1233 for (i = 0; i < MAX_SOCKET_BUSES; i++)
1234 pcibios_scan_specific_bus(255-i); 1234 pcibios_scan_specific_bus(255-i);
1235 } 1235 }
1236 pci_dev_put(pdev);
1236 table++; 1237 table++;
1237 } 1238 }
1238} 1239}
1239 1240
1241static unsigned i7core_pci_lastbus(void)
1242{
1243 int last_bus = 0, bus;
1244 struct pci_bus *b = NULL;
1245
1246 while ((b = pci_find_next_bus(b)) != NULL) {
1247 bus = b->number;
1248 debugf0("Found bus %d\n", bus);
1249 if (bus > last_bus)
1250 last_bus = bus;
1251 }
1252
1253 debugf0("Last bus %d\n", last_bus);
1254
1255 return last_bus;
1256}
1257
1240/* 1258/*
1241 * i7core_get_devices Find and perform 'get' operation on the MCH's 1259 * i7core_get_devices Find and perform 'get' operation on the MCH's
1242 * device/functions we want to reference for this driver 1260 * device/functions we want to reference for this driver
@@ -1244,7 +1262,8 @@ static void __init i7core_xeon_pci_fixup(struct pci_id_table *table)
1244 * Need to 'get' device 16 func 1 and func 2 1262 * Need to 'get' device 16 func 1 and func 2
1245 */ 1263 */
1246int i7core_get_onedevice(struct pci_dev **prev, int devno, 1264int i7core_get_onedevice(struct pci_dev **prev, int devno,
1247 struct pci_id_descr *dev_descr, unsigned n_devs) 1265 struct pci_id_descr *dev_descr, unsigned n_devs,
1266 unsigned last_bus)
1248{ 1267{
1249 struct i7core_dev *i7core_dev; 1268 struct i7core_dev *i7core_dev;
1250 1269
@@ -1281,7 +1300,7 @@ int i7core_get_onedevice(struct pci_dev **prev, int devno,
1281 if (devno == 0) 1300 if (devno == 0)
1282 return -ENODEV; 1301 return -ENODEV;
1283 1302
1284 i7core_printk(KERN_ERR, 1303 i7core_printk(KERN_INFO,
1285 "Device not found: dev %02x.%d PCI ID %04x:%04x\n", 1304 "Device not found: dev %02x.%d PCI ID %04x:%04x\n",
1286 dev_descr->dev, dev_descr->func, 1305 dev_descr->dev, dev_descr->func,
1287 PCI_VENDOR_ID_INTEL, dev_descr->dev_id); 1306 PCI_VENDOR_ID_INTEL, dev_descr->dev_id);
@@ -1291,10 +1310,7 @@ int i7core_get_onedevice(struct pci_dev **prev, int devno,
1291 } 1310 }
1292 bus = pdev->bus->number; 1311 bus = pdev->bus->number;
1293 1312
1294 if (bus == 0x3f) 1313 socket = last_bus - bus;
1295 socket = 0;
1296 else
1297 socket = 255 - bus;
1298 1314
1299 i7core_dev = get_i7core_dev(socket); 1315 i7core_dev = get_i7core_dev(socket);
1300 if (!i7core_dev) { 1316 if (!i7core_dev) {
@@ -1358,17 +1374,21 @@ int i7core_get_onedevice(struct pci_dev **prev, int devno,
1358 1374
1359static int i7core_get_devices(struct pci_id_table *table) 1375static int i7core_get_devices(struct pci_id_table *table)
1360{ 1376{
1361 int i, rc; 1377 int i, rc, last_bus;
1362 struct pci_dev *pdev = NULL; 1378 struct pci_dev *pdev = NULL;
1363 struct pci_id_descr *dev_descr; 1379 struct pci_id_descr *dev_descr;
1364 1380
1381 last_bus = i7core_pci_lastbus();
1382
1365 while (table && table->descr) { 1383 while (table && table->descr) {
1366 dev_descr = table->descr; 1384 dev_descr = table->descr;
1367 for (i = 0; i < table->n_devs; i++) { 1385 for (i = 0; i < table->n_devs; i++) {
1368 pdev = NULL; 1386 pdev = NULL;
1369 do { 1387 do {
1370 rc = i7core_get_onedevice(&pdev, i, &dev_descr[i], 1388 rc = i7core_get_onedevice(&pdev, i,
1371 table->n_devs); 1389 &dev_descr[i],
1390 table->n_devs,
1391 last_bus);
1372 if (rc < 0) { 1392 if (rc < 0) {
1373 if (i == 0) { 1393 if (i == 0) {
1374 i = table->n_devs; 1394 i = table->n_devs;
@@ -1927,21 +1947,26 @@ fail:
1927 * 0 for FOUND a device 1947 * 0 for FOUND a device
1928 * < 0 for error code 1948 * < 0 for error code
1929 */ 1949 */
1950
1951static int probed = 0;
1952
1930static int __devinit i7core_probe(struct pci_dev *pdev, 1953static int __devinit i7core_probe(struct pci_dev *pdev,
1931 const struct pci_device_id *id) 1954 const struct pci_device_id *id)
1932{ 1955{
1933 int dev_idx = id->driver_data;
1934 int rc; 1956 int rc;
1935 struct i7core_dev *i7core_dev; 1957 struct i7core_dev *i7core_dev;
1936 1958
1959 /* get the pci devices we want to reserve for our use */
1960 mutex_lock(&i7core_edac_lock);
1961
1937 /* 1962 /*
1938 * All memory controllers are allocated at the first pass. 1963 * All memory controllers are allocated at the first pass.
1939 */ 1964 */
1940 if (unlikely(dev_idx >= 1)) 1965 if (unlikely(probed >= 1)) {
1966 mutex_unlock(&i7core_edac_lock);
1941 return -EINVAL; 1967 return -EINVAL;
1942 1968 }
1943 /* get the pci devices we want to reserve for our use */ 1969 probed++;
1944 mutex_lock(&i7core_edac_lock);
1945 1970
1946 rc = i7core_get_devices(pci_dev_table); 1971 rc = i7core_get_devices(pci_dev_table);
1947 if (unlikely(rc < 0)) 1972 if (unlikely(rc < 0))
@@ -2013,6 +2038,8 @@ static void __devexit i7core_remove(struct pci_dev *pdev)
2013 i7core_dev->socket); 2038 i7core_dev->socket);
2014 } 2039 }
2015 } 2040 }
2041 probed--;
2042
2016 mutex_unlock(&i7core_edac_lock); 2043 mutex_unlock(&i7core_edac_lock);
2017} 2044}
2018 2045
diff --git a/drivers/edac/mpc85xx_edac.c b/drivers/edac/mpc85xx_edac.c
index 52ca09bf4726..1052340e6802 100644
--- a/drivers/edac/mpc85xx_edac.c
+++ b/drivers/edac/mpc85xx_edac.c
@@ -336,6 +336,7 @@ static struct of_device_id mpc85xx_pci_err_of_match[] = {
336 }, 336 },
337 {}, 337 {},
338}; 338};
339MODULE_DEVICE_TABLE(of, mpc85xx_pci_err_of_match);
339 340
340static struct of_platform_driver mpc85xx_pci_err_driver = { 341static struct of_platform_driver mpc85xx_pci_err_driver = {
341 .probe = mpc85xx_pci_err_probe, 342 .probe = mpc85xx_pci_err_probe,
@@ -650,6 +651,7 @@ static struct of_device_id mpc85xx_l2_err_of_match[] = {
650 { .compatible = "fsl,p2020-l2-cache-controller", }, 651 { .compatible = "fsl,p2020-l2-cache-controller", },
651 {}, 652 {},
652}; 653};
654MODULE_DEVICE_TABLE(of, mpc85xx_l2_err_of_match);
653 655
654static struct of_platform_driver mpc85xx_l2_err_driver = { 656static struct of_platform_driver mpc85xx_l2_err_driver = {
655 .probe = mpc85xx_l2_err_probe, 657 .probe = mpc85xx_l2_err_probe,
@@ -1120,11 +1122,13 @@ static struct of_device_id mpc85xx_mc_err_of_match[] = {
1120 { .compatible = "fsl,mpc8555-memory-controller", }, 1122 { .compatible = "fsl,mpc8555-memory-controller", },
1121 { .compatible = "fsl,mpc8560-memory-controller", }, 1123 { .compatible = "fsl,mpc8560-memory-controller", },
1122 { .compatible = "fsl,mpc8568-memory-controller", }, 1124 { .compatible = "fsl,mpc8568-memory-controller", },
1125 { .compatible = "fsl,mpc8569-memory-controller", },
1123 { .compatible = "fsl,mpc8572-memory-controller", }, 1126 { .compatible = "fsl,mpc8572-memory-controller", },
1124 { .compatible = "fsl,mpc8349-memory-controller", }, 1127 { .compatible = "fsl,mpc8349-memory-controller", },
1125 { .compatible = "fsl,p2020-memory-controller", }, 1128 { .compatible = "fsl,p2020-memory-controller", },
1126 {}, 1129 {},
1127}; 1130};
1131MODULE_DEVICE_TABLE(of, mpc85xx_mc_err_of_match);
1128 1132
1129static struct of_platform_driver mpc85xx_mc_err_driver = { 1133static struct of_platform_driver mpc85xx_mc_err_driver = {
1130 .probe = mpc85xx_mc_err_probe, 1134 .probe = mpc85xx_mc_err_probe,
diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig
index 724038dab4ca..7face915b963 100644
--- a/drivers/gpio/Kconfig
+++ b/drivers/gpio/Kconfig
@@ -1,5 +1,5 @@
1# 1#
2# GPIO infrastructure and expanders 2# platform-neutral GPIO infrastructure and expanders
3# 3#
4 4
5config ARCH_WANT_OPTIONAL_GPIOLIB 5config ARCH_WANT_OPTIONAL_GPIOLIB
diff --git a/drivers/gpio/Makefile b/drivers/gpio/Makefile
index 51c3cdd41b5a..e53dcff49b4f 100644
--- a/drivers/gpio/Makefile
+++ b/drivers/gpio/Makefile
@@ -1,4 +1,8 @@
1# gpio support: dedicated expander chips, etc 1# generic gpio support: dedicated expander chips, etc
2#
3# NOTE: platform-specific GPIO drivers don't belong in the
4# drivers/gpio directory; put them with other platform setup
5# code, IRQ controllers, board init, etc.
2 6
3ccflags-$(CONFIG_DEBUG_GPIO) += -DDEBUG 7ccflags-$(CONFIG_DEBUG_GPIO) += -DDEBUG
4 8
diff --git a/drivers/gpio/cs5535-gpio.c b/drivers/gpio/cs5535-gpio.c
index f73a1555e49d..e23c06893d19 100644
--- a/drivers/gpio/cs5535-gpio.c
+++ b/drivers/gpio/cs5535-gpio.c
@@ -352,6 +352,6 @@ static void __exit cs5535_gpio_exit(void)
352module_init(cs5535_gpio_init); 352module_init(cs5535_gpio_init);
353module_exit(cs5535_gpio_exit); 353module_exit(cs5535_gpio_exit);
354 354
355MODULE_AUTHOR("Andres Salomon <dilinger@collabora.co.uk>"); 355MODULE_AUTHOR("Andres Salomon <dilinger@queued.net>");
356MODULE_DESCRIPTION("AMD CS5535/CS5536 GPIO driver"); 356MODULE_DESCRIPTION("AMD CS5535/CS5536 GPIO driver");
357MODULE_LICENSE("GPL"); 357MODULE_LICENSE("GPL");
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index 3ca36542e338..4e51fe3c1fc4 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -893,10 +893,12 @@ EXPORT_SYMBOL_GPL(gpio_sysfs_set_active_low);
893void gpio_unexport(unsigned gpio) 893void gpio_unexport(unsigned gpio)
894{ 894{
895 struct gpio_desc *desc; 895 struct gpio_desc *desc;
896 int status = -EINVAL; 896 int status = 0;
897 897
898 if (!gpio_is_valid(gpio)) 898 if (!gpio_is_valid(gpio)) {
899 status = -EINVAL;
899 goto done; 900 goto done;
901 }
900 902
901 mutex_lock(&sysfs_lock); 903 mutex_lock(&sysfs_lock);
902 904
@@ -911,7 +913,6 @@ void gpio_unexport(unsigned gpio)
911 clear_bit(FLAG_EXPORT, &desc->flags); 913 clear_bit(FLAG_EXPORT, &desc->flags);
912 put_device(dev); 914 put_device(dev);
913 device_unregister(dev); 915 device_unregister(dev);
914 status = 0;
915 } else 916 } else
916 status = -ENODEV; 917 status = -ENODEV;
917 } 918 }
diff --git a/drivers/gpio/pl061.c b/drivers/gpio/pl061.c
index ee568c8fcbd0..5005990f751f 100644
--- a/drivers/gpio/pl061.c
+++ b/drivers/gpio/pl061.c
@@ -232,7 +232,7 @@ static void pl061_irq_handler(unsigned irq, struct irq_desc *desc)
232 desc->chip->unmask(irq); 232 desc->chip->unmask(irq);
233} 233}
234 234
235static int __init pl061_probe(struct amba_device *dev, struct amba_id *id) 235static int pl061_probe(struct amba_device *dev, struct amba_id *id)
236{ 236{
237 struct pl061_platform_data *pdata; 237 struct pl061_platform_data *pdata;
238 struct pl061_gpio *chip; 238 struct pl061_gpio *chip;
@@ -333,7 +333,7 @@ free_mem:
333 return ret; 333 return ret;
334} 334}
335 335
336static struct amba_id pl061_ids[] __initdata = { 336static struct amba_id pl061_ids[] = {
337 { 337 {
338 .id = 0x00041061, 338 .id = 0x00041061,
339 .mask = 0x000fffff, 339 .mask = 0x000fffff,
diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
index da06476f2df4..9585e531ac6b 100644
--- a/drivers/gpu/drm/drm_edid.c
+++ b/drivers/gpu/drm/drm_edid.c
@@ -864,8 +864,8 @@ drm_mode_std(struct drm_connector *connector, struct edid *edid,
864 mode = drm_cvt_mode(dev, 1366, 768, vrefresh_rate, 0, 0, 864 mode = drm_cvt_mode(dev, 1366, 768, vrefresh_rate, 0, 0,
865 false); 865 false);
866 mode->hdisplay = 1366; 866 mode->hdisplay = 1366;
867 mode->vsync_start = mode->vsync_start - 1; 867 mode->hsync_start = mode->hsync_start - 1;
868 mode->vsync_end = mode->vsync_end - 1; 868 mode->hsync_end = mode->hsync_end - 1;
869 return mode; 869 return mode;
870 } 870 }
871 871
diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
index 08c4c926e65f..719662034bbf 100644
--- a/drivers/gpu/drm/drm_fb_helper.c
+++ b/drivers/gpu/drm/drm_fb_helper.c
@@ -146,7 +146,7 @@ static bool drm_fb_helper_connector_parse_command_line(struct drm_fb_helper_conn
146 cvt = 1; 146 cvt = 1;
147 break; 147 break;
148 case 'R': 148 case 'R':
149 if (!cvt) 149 if (cvt)
150 rb = 1; 150 rb = 1;
151 break; 151 break;
152 case 'm': 152 case 'm':
@@ -315,8 +315,9 @@ static void drm_fb_helper_on(struct fb_info *info)
315 struct drm_device *dev = fb_helper->dev; 315 struct drm_device *dev = fb_helper->dev;
316 struct drm_crtc *crtc; 316 struct drm_crtc *crtc;
317 struct drm_crtc_helper_funcs *crtc_funcs; 317 struct drm_crtc_helper_funcs *crtc_funcs;
318 struct drm_connector *connector;
318 struct drm_encoder *encoder; 319 struct drm_encoder *encoder;
319 int i; 320 int i, j;
320 321
321 /* 322 /*
322 * For each CRTC in this fb, turn the crtc on then, 323 * For each CRTC in this fb, turn the crtc on then,
@@ -332,7 +333,14 @@ static void drm_fb_helper_on(struct fb_info *info)
332 333
333 crtc_funcs->dpms(crtc, DRM_MODE_DPMS_ON); 334 crtc_funcs->dpms(crtc, DRM_MODE_DPMS_ON);
334 335
335 336 /* Walk the connectors & encoders on this fb turning them on */
337 for (j = 0; j < fb_helper->connector_count; j++) {
338 connector = fb_helper->connector_info[j]->connector;
339 connector->dpms = DRM_MODE_DPMS_ON;
340 drm_connector_property_set_value(connector,
341 dev->mode_config.dpms_property,
342 DRM_MODE_DPMS_ON);
343 }
336 /* Found a CRTC on this fb, now find encoders */ 344 /* Found a CRTC on this fb, now find encoders */
337 list_for_each_entry(encoder, &dev->mode_config.encoder_list, head) { 345 list_for_each_entry(encoder, &dev->mode_config.encoder_list, head) {
338 if (encoder->crtc == crtc) { 346 if (encoder->crtc == crtc) {
@@ -352,8 +360,9 @@ static void drm_fb_helper_off(struct fb_info *info, int dpms_mode)
352 struct drm_device *dev = fb_helper->dev; 360 struct drm_device *dev = fb_helper->dev;
353 struct drm_crtc *crtc; 361 struct drm_crtc *crtc;
354 struct drm_crtc_helper_funcs *crtc_funcs; 362 struct drm_crtc_helper_funcs *crtc_funcs;
363 struct drm_connector *connector;
355 struct drm_encoder *encoder; 364 struct drm_encoder *encoder;
356 int i; 365 int i, j;
357 366
358 /* 367 /*
359 * For each CRTC in this fb, find all associated encoders 368 * For each CRTC in this fb, find all associated encoders
@@ -367,6 +376,14 @@ static void drm_fb_helper_off(struct fb_info *info, int dpms_mode)
367 if (!crtc->enabled) 376 if (!crtc->enabled)
368 continue; 377 continue;
369 378
379 /* Walk the connectors on this fb and mark them off */
380 for (j = 0; j < fb_helper->connector_count; j++) {
381 connector = fb_helper->connector_info[j]->connector;
382 connector->dpms = dpms_mode;
383 drm_connector_property_set_value(connector,
384 dev->mode_config.dpms_property,
385 dpms_mode);
386 }
370 /* Found a CRTC on this fb, now find encoders */ 387 /* Found a CRTC on this fb, now find encoders */
371 list_for_each_entry(encoder, &dev->mode_config.encoder_list, head) { 388 list_for_each_entry(encoder, &dev->mode_config.encoder_list, head) {
372 if (encoder->crtc == crtc) { 389 if (encoder->crtc == crtc) {
@@ -1024,11 +1041,18 @@ static struct drm_display_mode *drm_pick_cmdline_mode(struct drm_fb_helper_conne
1024 } 1041 }
1025 1042
1026create_mode: 1043create_mode:
1027 mode = drm_cvt_mode(fb_helper_conn->connector->dev, cmdline_mode->xres, 1044 if (cmdline_mode->cvt)
1028 cmdline_mode->yres, 1045 mode = drm_cvt_mode(fb_helper_conn->connector->dev,
1029 cmdline_mode->refresh_specified ? cmdline_mode->refresh : 60, 1046 cmdline_mode->xres, cmdline_mode->yres,
1030 cmdline_mode->rb, cmdline_mode->interlace, 1047 cmdline_mode->refresh_specified ? cmdline_mode->refresh : 60,
1031 cmdline_mode->margins); 1048 cmdline_mode->rb, cmdline_mode->interlace,
1049 cmdline_mode->margins);
1050 else
1051 mode = drm_gtf_mode(fb_helper_conn->connector->dev,
1052 cmdline_mode->xres, cmdline_mode->yres,
1053 cmdline_mode->refresh_specified ? cmdline_mode->refresh : 60,
1054 cmdline_mode->interlace,
1055 cmdline_mode->margins);
1032 drm_mode_set_crtcinfo(mode, CRTC_INTERLACE_HALVE_V); 1056 drm_mode_set_crtcinfo(mode, CRTC_INTERLACE_HALVE_V);
1033 list_add(&mode->head, &fb_helper_conn->connector->modes); 1057 list_add(&mode->head, &fb_helper_conn->connector->modes);
1034 return mode; 1058 return mode;
diff --git a/drivers/gpu/drm/i915/dvo_tfp410.c b/drivers/gpu/drm/i915/dvo_tfp410.c
index 66c697bc9b22..56f66426207f 100644
--- a/drivers/gpu/drm/i915/dvo_tfp410.c
+++ b/drivers/gpu/drm/i915/dvo_tfp410.c
@@ -208,7 +208,7 @@ static enum drm_connector_status tfp410_detect(struct intel_dvo_device *dvo)
208 uint8_t ctl2; 208 uint8_t ctl2;
209 209
210 if (tfp410_readb(dvo, TFP410_CTL_2, &ctl2)) { 210 if (tfp410_readb(dvo, TFP410_CTL_2, &ctl2)) {
211 if (ctl2 & TFP410_CTL_2_HTPLG) 211 if (ctl2 & TFP410_CTL_2_RSEN)
212 ret = connector_status_connected; 212 ret = connector_status_connected;
213 else 213 else
214 ret = connector_status_disconnected; 214 ret = connector_status_disconnected;
diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c
index 52510ad8b25d..9214119c0154 100644
--- a/drivers/gpu/drm/i915/i915_debugfs.c
+++ b/drivers/gpu/drm/i915/i915_debugfs.c
@@ -605,6 +605,9 @@ static int i915_fbc_status(struct seq_file *m, void *unused)
605 case FBC_NOT_TILED: 605 case FBC_NOT_TILED:
606 seq_printf(m, "scanout buffer not tiled"); 606 seq_printf(m, "scanout buffer not tiled");
607 break; 607 break;
608 case FBC_MULTIPLE_PIPES:
609 seq_printf(m, "multiple pipes are enabled");
610 break;
608 default: 611 default:
609 seq_printf(m, "unknown reason"); 612 seq_printf(m, "unknown reason");
610 } 613 }
@@ -620,7 +623,7 @@ static int i915_sr_status(struct seq_file *m, void *unused)
620 drm_i915_private_t *dev_priv = dev->dev_private; 623 drm_i915_private_t *dev_priv = dev->dev_private;
621 bool sr_enabled = false; 624 bool sr_enabled = false;
622 625
623 if (IS_I965G(dev) || IS_I945G(dev) || IS_I945GM(dev)) 626 if (IS_I965GM(dev) || IS_I945G(dev) || IS_I945GM(dev))
624 sr_enabled = I915_READ(FW_BLC_SELF) & FW_BLC_SELF_EN; 627 sr_enabled = I915_READ(FW_BLC_SELF) & FW_BLC_SELF_EN;
625 else if (IS_I915GM(dev)) 628 else if (IS_I915GM(dev))
626 sr_enabled = I915_READ(INSTPM) & INSTPM_SELF_EN; 629 sr_enabled = I915_READ(INSTPM) & INSTPM_SELF_EN;
diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c
index 59a2bf8592ec..2305a1234f1e 100644
--- a/drivers/gpu/drm/i915/i915_dma.c
+++ b/drivers/gpu/drm/i915/i915_dma.c
@@ -128,9 +128,11 @@ static int i915_dma_cleanup(struct drm_device * dev)
128 if (dev->irq_enabled) 128 if (dev->irq_enabled)
129 drm_irq_uninstall(dev); 129 drm_irq_uninstall(dev);
130 130
131 mutex_lock(&dev->struct_mutex);
131 intel_cleanup_ring_buffer(dev, &dev_priv->render_ring); 132 intel_cleanup_ring_buffer(dev, &dev_priv->render_ring);
132 if (HAS_BSD(dev)) 133 if (HAS_BSD(dev))
133 intel_cleanup_ring_buffer(dev, &dev_priv->bsd_ring); 134 intel_cleanup_ring_buffer(dev, &dev_priv->bsd_ring);
135 mutex_unlock(&dev->struct_mutex);
134 136
135 /* Clear the HWS virtual address at teardown */ 137 /* Clear the HWS virtual address at teardown */
136 if (I915_NEED_GFX_HWS(dev)) 138 if (I915_NEED_GFX_HWS(dev))
@@ -1229,7 +1231,7 @@ static void i915_warn_stolen(struct drm_device *dev)
1229static void i915_setup_compression(struct drm_device *dev, int size) 1231static void i915_setup_compression(struct drm_device *dev, int size)
1230{ 1232{
1231 struct drm_i915_private *dev_priv = dev->dev_private; 1233 struct drm_i915_private *dev_priv = dev->dev_private;
1232 struct drm_mm_node *compressed_fb, *compressed_llb; 1234 struct drm_mm_node *compressed_fb, *uninitialized_var(compressed_llb);
1233 unsigned long cfb_base; 1235 unsigned long cfb_base;
1234 unsigned long ll_base = 0; 1236 unsigned long ll_base = 0;
1235 1237
@@ -1298,7 +1300,7 @@ static void i915_cleanup_compression(struct drm_device *dev)
1298 struct drm_i915_private *dev_priv = dev->dev_private; 1300 struct drm_i915_private *dev_priv = dev->dev_private;
1299 1301
1300 drm_mm_put_block(dev_priv->compressed_fb); 1302 drm_mm_put_block(dev_priv->compressed_fb);
1301 if (!IS_GM45(dev)) 1303 if (dev_priv->compressed_llb)
1302 drm_mm_put_block(dev_priv->compressed_llb); 1304 drm_mm_put_block(dev_priv->compressed_llb);
1303} 1305}
1304 1306
@@ -1410,6 +1412,10 @@ static int i915_load_modeset_init(struct drm_device *dev,
1410 if (ret) 1412 if (ret)
1411 goto cleanup_vga_client; 1413 goto cleanup_vga_client;
1412 1414
1415 /* IIR "flip pending" bit means done if this bit is set */
1416 if (IS_GEN3(dev) && (I915_READ(ECOSKPD) & ECO_FLIP_DONE))
1417 dev_priv->flip_pending_is_done = true;
1418
1413 intel_modeset_init(dev); 1419 intel_modeset_init(dev);
1414 1420
1415 ret = drm_irq_install(dev); 1421 ret = drm_irq_install(dev);
diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index 276583159847..2e1744d37ad5 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -215,6 +215,7 @@ enum no_fbc_reason {
215 FBC_MODE_TOO_LARGE, /* mode too large for compression */ 215 FBC_MODE_TOO_LARGE, /* mode too large for compression */
216 FBC_BAD_PLANE, /* fbc not supported on plane */ 216 FBC_BAD_PLANE, /* fbc not supported on plane */
217 FBC_NOT_TILED, /* buffer not tiled */ 217 FBC_NOT_TILED, /* buffer not tiled */
218 FBC_MULTIPLE_PIPES, /* more than one pipe active */
218}; 219};
219 220
220enum intel_pch { 221enum intel_pch {
@@ -222,6 +223,8 @@ enum intel_pch {
222 PCH_CPT, /* Cougarpoint PCH */ 223 PCH_CPT, /* Cougarpoint PCH */
223}; 224};
224 225
226#define QUIRK_PIPEA_FORCE (1<<0)
227
225struct intel_fbdev; 228struct intel_fbdev;
226 229
227typedef struct drm_i915_private { 230typedef struct drm_i915_private {
@@ -337,6 +340,8 @@ typedef struct drm_i915_private {
337 /* PCH chipset type */ 340 /* PCH chipset type */
338 enum intel_pch pch_type; 341 enum intel_pch pch_type;
339 342
343 unsigned long quirks;
344
340 /* Register state */ 345 /* Register state */
341 bool modeset_on_lid; 346 bool modeset_on_lid;
342 u8 saveLBB; 347 u8 saveLBB;
@@ -596,6 +601,7 @@ typedef struct drm_i915_private {
596 struct drm_crtc *plane_to_crtc_mapping[2]; 601 struct drm_crtc *plane_to_crtc_mapping[2];
597 struct drm_crtc *pipe_to_crtc_mapping[2]; 602 struct drm_crtc *pipe_to_crtc_mapping[2];
598 wait_queue_head_t pending_flip_queue; 603 wait_queue_head_t pending_flip_queue;
604 bool flip_pending_is_done;
599 605
600 /* Reclocking support */ 606 /* Reclocking support */
601 bool render_reclock_avail; 607 bool render_reclock_avail;
@@ -1076,7 +1082,7 @@ extern int intel_trans_dp_port_sel (struct drm_crtc *crtc);
1076 drm_i915_private_t *dev_priv = dev->dev_private; \ 1082 drm_i915_private_t *dev_priv = dev->dev_private; \
1077 if (I915_VERBOSE) \ 1083 if (I915_VERBOSE) \
1078 DRM_DEBUG(" BEGIN_LP_RING %x\n", (int)(n)); \ 1084 DRM_DEBUG(" BEGIN_LP_RING %x\n", (int)(n)); \
1079 intel_ring_begin(dev, &dev_priv->render_ring, 4*(n)); \ 1085 intel_ring_begin(dev, &dev_priv->render_ring, (n)); \
1080} while (0) 1086} while (0)
1081 1087
1082 1088
diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
index 9ded3dae6c87..5aa747fc25a9 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -2239,8 +2239,9 @@ i915_gem_object_get_pages(struct drm_gem_object *obj,
2239 mapping = inode->i_mapping; 2239 mapping = inode->i_mapping;
2240 for (i = 0; i < page_count; i++) { 2240 for (i = 0; i < page_count; i++) {
2241 page = read_cache_page_gfp(mapping, i, 2241 page = read_cache_page_gfp(mapping, i,
2242 mapping_gfp_mask (mapping) | 2242 GFP_HIGHUSER |
2243 __GFP_COLD | 2243 __GFP_COLD |
2244 __GFP_RECLAIMABLE |
2244 gfpmask); 2245 gfpmask);
2245 if (IS_ERR(page)) 2246 if (IS_ERR(page))
2246 goto err_pages; 2247 goto err_pages;
@@ -3646,6 +3647,7 @@ i915_gem_wait_for_pending_flip(struct drm_device *dev,
3646 return ret; 3647 return ret;
3647} 3648}
3648 3649
3650
3649int 3651int
3650i915_gem_do_execbuffer(struct drm_device *dev, void *data, 3652i915_gem_do_execbuffer(struct drm_device *dev, void *data,
3651 struct drm_file *file_priv, 3653 struct drm_file *file_priv,
@@ -3793,7 +3795,7 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data,
3793 unsigned long long total_size = 0; 3795 unsigned long long total_size = 0;
3794 int num_fences = 0; 3796 int num_fences = 0;
3795 for (i = 0; i < args->buffer_count; i++) { 3797 for (i = 0; i < args->buffer_count; i++) {
3796 obj_priv = object_list[i]->driver_private; 3798 obj_priv = to_intel_bo(object_list[i]);
3797 3799
3798 total_size += object_list[i]->size; 3800 total_size += object_list[i]->size;
3799 num_fences += 3801 num_fences +=
@@ -4741,6 +4743,16 @@ i915_gem_load(struct drm_device *dev)
4741 list_add(&dev_priv->mm.shrink_list, &shrink_list); 4743 list_add(&dev_priv->mm.shrink_list, &shrink_list);
4742 spin_unlock(&shrink_list_lock); 4744 spin_unlock(&shrink_list_lock);
4743 4745
4746 /* On GEN3 we really need to make sure the ARB C3 LP bit is set */
4747 if (IS_GEN3(dev)) {
4748 u32 tmp = I915_READ(MI_ARB_STATE);
4749 if (!(tmp & MI_ARB_C3_LP_WRITE_ENABLE)) {
4750 /* arb state is a masked write, so set bit + bit in mask */
4751 tmp = MI_ARB_C3_LP_WRITE_ENABLE | (MI_ARB_C3_LP_WRITE_ENABLE << MI_ARB_MASK_SHIFT);
4752 I915_WRITE(MI_ARB_STATE, tmp);
4753 }
4754 }
4755
4744 /* Old X drivers will take 0-2 for front, back, depth buffers */ 4756 /* Old X drivers will take 0-2 for front, back, depth buffers */
4745 if (!drm_core_check_feature(dev, DRIVER_MODESET)) 4757 if (!drm_core_check_feature(dev, DRIVER_MODESET))
4746 dev_priv->fence_reg_start = 3; 4758 dev_priv->fence_reg_start = 3;
@@ -4977,7 +4989,7 @@ i915_gpu_is_active(struct drm_device *dev)
4977} 4989}
4978 4990
4979static int 4991static int
4980i915_gem_shrink(int nr_to_scan, gfp_t gfp_mask) 4992i915_gem_shrink(struct shrinker *shrink, int nr_to_scan, gfp_t gfp_mask)
4981{ 4993{
4982 drm_i915_private_t *dev_priv, *next_dev; 4994 drm_i915_private_t *dev_priv, *next_dev;
4983 struct drm_i915_gem_object *obj_priv, *next_obj; 4995 struct drm_i915_gem_object *obj_priv, *next_obj;
diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c
index 2479be001e40..dba53d4b9fb3 100644
--- a/drivers/gpu/drm/i915/i915_irq.c
+++ b/drivers/gpu/drm/i915/i915_irq.c
@@ -940,22 +940,30 @@ irqreturn_t i915_driver_irq_handler(DRM_IRQ_ARGS)
940 if (HAS_BSD(dev) && (iir & I915_BSD_USER_INTERRUPT)) 940 if (HAS_BSD(dev) && (iir & I915_BSD_USER_INTERRUPT))
941 DRM_WAKEUP(&dev_priv->bsd_ring.irq_queue); 941 DRM_WAKEUP(&dev_priv->bsd_ring.irq_queue);
942 942
943 if (iir & I915_DISPLAY_PLANE_A_FLIP_PENDING_INTERRUPT) 943 if (iir & I915_DISPLAY_PLANE_A_FLIP_PENDING_INTERRUPT) {
944 intel_prepare_page_flip(dev, 0); 944 intel_prepare_page_flip(dev, 0);
945 if (dev_priv->flip_pending_is_done)
946 intel_finish_page_flip_plane(dev, 0);
947 }
945 948
946 if (iir & I915_DISPLAY_PLANE_B_FLIP_PENDING_INTERRUPT) 949 if (iir & I915_DISPLAY_PLANE_B_FLIP_PENDING_INTERRUPT) {
947 intel_prepare_page_flip(dev, 1); 950 intel_prepare_page_flip(dev, 1);
951 if (dev_priv->flip_pending_is_done)
952 intel_finish_page_flip_plane(dev, 1);
953 }
948 954
949 if (pipea_stats & vblank_status) { 955 if (pipea_stats & vblank_status) {
950 vblank++; 956 vblank++;
951 drm_handle_vblank(dev, 0); 957 drm_handle_vblank(dev, 0);
952 intel_finish_page_flip(dev, 0); 958 if (!dev_priv->flip_pending_is_done)
959 intel_finish_page_flip(dev, 0);
953 } 960 }
954 961
955 if (pipeb_stats & vblank_status) { 962 if (pipeb_stats & vblank_status) {
956 vblank++; 963 vblank++;
957 drm_handle_vblank(dev, 1); 964 drm_handle_vblank(dev, 1);
958 intel_finish_page_flip(dev, 1); 965 if (!dev_priv->flip_pending_is_done)
966 intel_finish_page_flip(dev, 1);
959 } 967 }
960 968
961 if ((pipea_stats & I915_LEGACY_BLC_EVENT_STATUS) || 969 if ((pipea_stats & I915_LEGACY_BLC_EVENT_STATUS) ||
@@ -1387,29 +1395,10 @@ int i915_driver_irq_postinstall(struct drm_device *dev)
1387 dev_priv->pipestat[1] = 0; 1395 dev_priv->pipestat[1] = 0;
1388 1396
1389 if (I915_HAS_HOTPLUG(dev)) { 1397 if (I915_HAS_HOTPLUG(dev)) {
1390 u32 hotplug_en = I915_READ(PORT_HOTPLUG_EN);
1391
1392 /* Note HDMI and DP share bits */
1393 if (dev_priv->hotplug_supported_mask & HDMIB_HOTPLUG_INT_STATUS)
1394 hotplug_en |= HDMIB_HOTPLUG_INT_EN;
1395 if (dev_priv->hotplug_supported_mask & HDMIC_HOTPLUG_INT_STATUS)
1396 hotplug_en |= HDMIC_HOTPLUG_INT_EN;
1397 if (dev_priv->hotplug_supported_mask & HDMID_HOTPLUG_INT_STATUS)
1398 hotplug_en |= HDMID_HOTPLUG_INT_EN;
1399 if (dev_priv->hotplug_supported_mask & SDVOC_HOTPLUG_INT_STATUS)
1400 hotplug_en |= SDVOC_HOTPLUG_INT_EN;
1401 if (dev_priv->hotplug_supported_mask & SDVOB_HOTPLUG_INT_STATUS)
1402 hotplug_en |= SDVOB_HOTPLUG_INT_EN;
1403 if (dev_priv->hotplug_supported_mask & CRT_HOTPLUG_INT_STATUS)
1404 hotplug_en |= CRT_HOTPLUG_INT_EN;
1405 /* Ignore TV since it's buggy */
1406
1407 I915_WRITE(PORT_HOTPLUG_EN, hotplug_en);
1408
1409 /* Enable in IER... */ 1398 /* Enable in IER... */
1410 enable_mask |= I915_DISPLAY_PORT_INTERRUPT; 1399 enable_mask |= I915_DISPLAY_PORT_INTERRUPT;
1411 /* and unmask in IMR */ 1400 /* and unmask in IMR */
1412 i915_enable_irq(dev_priv, I915_DISPLAY_PORT_INTERRUPT); 1401 dev_priv->irq_mask_reg &= ~I915_DISPLAY_PORT_INTERRUPT;
1413 } 1402 }
1414 1403
1415 /* 1404 /*
@@ -1427,16 +1416,41 @@ int i915_driver_irq_postinstall(struct drm_device *dev)
1427 } 1416 }
1428 I915_WRITE(EMR, error_mask); 1417 I915_WRITE(EMR, error_mask);
1429 1418
1430 /* Disable pipe interrupt enables, clear pending pipe status */
1431 I915_WRITE(PIPEASTAT, I915_READ(PIPEASTAT) & 0x8000ffff);
1432 I915_WRITE(PIPEBSTAT, I915_READ(PIPEBSTAT) & 0x8000ffff);
1433 /* Clear pending interrupt status */
1434 I915_WRITE(IIR, I915_READ(IIR));
1435
1436 I915_WRITE(IER, enable_mask);
1437 I915_WRITE(IMR, dev_priv->irq_mask_reg); 1419 I915_WRITE(IMR, dev_priv->irq_mask_reg);
1420 I915_WRITE(IER, enable_mask);
1438 (void) I915_READ(IER); 1421 (void) I915_READ(IER);
1439 1422
1423 if (I915_HAS_HOTPLUG(dev)) {
1424 u32 hotplug_en = I915_READ(PORT_HOTPLUG_EN);
1425
1426 /* Note HDMI and DP share bits */
1427 if (dev_priv->hotplug_supported_mask & HDMIB_HOTPLUG_INT_STATUS)
1428 hotplug_en |= HDMIB_HOTPLUG_INT_EN;
1429 if (dev_priv->hotplug_supported_mask & HDMIC_HOTPLUG_INT_STATUS)
1430 hotplug_en |= HDMIC_HOTPLUG_INT_EN;
1431 if (dev_priv->hotplug_supported_mask & HDMID_HOTPLUG_INT_STATUS)
1432 hotplug_en |= HDMID_HOTPLUG_INT_EN;
1433 if (dev_priv->hotplug_supported_mask & SDVOC_HOTPLUG_INT_STATUS)
1434 hotplug_en |= SDVOC_HOTPLUG_INT_EN;
1435 if (dev_priv->hotplug_supported_mask & SDVOB_HOTPLUG_INT_STATUS)
1436 hotplug_en |= SDVOB_HOTPLUG_INT_EN;
1437 if (dev_priv->hotplug_supported_mask & CRT_HOTPLUG_INT_STATUS) {
1438 hotplug_en |= CRT_HOTPLUG_INT_EN;
1439
1440 /* Programming the CRT detection parameters tends
1441 to generate a spurious hotplug event about three
1442 seconds later. So just do it once.
1443 */
1444 if (IS_G4X(dev))
1445 hotplug_en |= CRT_HOTPLUG_ACTIVATION_PERIOD_64;
1446 hotplug_en |= CRT_HOTPLUG_VOLTAGE_COMPARE_50;
1447 }
1448
1449 /* Ignore TV since it's buggy */
1450
1451 I915_WRITE(PORT_HOTPLUG_EN, hotplug_en);
1452 }
1453
1440 opregion_enable_asle(dev); 1454 opregion_enable_asle(dev);
1441 1455
1442 return 0; 1456 return 0;
diff --git a/drivers/gpu/drm/i915/i915_reg.h b/drivers/gpu/drm/i915/i915_reg.h
index 64b0a3afd92b..cf41c672defe 100644
--- a/drivers/gpu/drm/i915/i915_reg.h
+++ b/drivers/gpu/drm/i915/i915_reg.h
@@ -178,6 +178,7 @@
178#define MI_OVERLAY_OFF (0x2<<21) 178#define MI_OVERLAY_OFF (0x2<<21)
179#define MI_LOAD_SCAN_LINES_INCL MI_INSTR(0x12, 0) 179#define MI_LOAD_SCAN_LINES_INCL MI_INSTR(0x12, 0)
180#define MI_DISPLAY_FLIP MI_INSTR(0x14, 2) 180#define MI_DISPLAY_FLIP MI_INSTR(0x14, 2)
181#define MI_DISPLAY_FLIP_I915 MI_INSTR(0x14, 1)
181#define MI_DISPLAY_FLIP_PLANE(n) ((n) << 20) 182#define MI_DISPLAY_FLIP_PLANE(n) ((n) << 20)
182#define MI_STORE_DWORD_IMM MI_INSTR(0x20, 1) 183#define MI_STORE_DWORD_IMM MI_INSTR(0x20, 1)
183#define MI_MEM_VIRTUAL (1 << 22) /* 965+ only */ 184#define MI_MEM_VIRTUAL (1 << 22) /* 965+ only */
@@ -358,6 +359,70 @@
358#define LM_BURST_LENGTH 0x00000700 359#define LM_BURST_LENGTH 0x00000700
359#define LM_FIFO_WATERMARK 0x0000001F 360#define LM_FIFO_WATERMARK 0x0000001F
360#define MI_ARB_STATE 0x020e4 /* 915+ only */ 361#define MI_ARB_STATE 0x020e4 /* 915+ only */
362#define MI_ARB_MASK_SHIFT 16 /* shift for enable bits */
363
364/* Make render/texture TLB fetches lower priorty than associated data
365 * fetches. This is not turned on by default
366 */
367#define MI_ARB_RENDER_TLB_LOW_PRIORITY (1 << 15)
368
369/* Isoch request wait on GTT enable (Display A/B/C streams).
370 * Make isoch requests stall on the TLB update. May cause
371 * display underruns (test mode only)
372 */
373#define MI_ARB_ISOCH_WAIT_GTT (1 << 14)
374
375/* Block grant count for isoch requests when block count is
376 * set to a finite value.
377 */
378#define MI_ARB_BLOCK_GRANT_MASK (3 << 12)
379#define MI_ARB_BLOCK_GRANT_8 (0 << 12) /* for 3 display planes */
380#define MI_ARB_BLOCK_GRANT_4 (1 << 12) /* for 2 display planes */
381#define MI_ARB_BLOCK_GRANT_2 (2 << 12) /* for 1 display plane */
382#define MI_ARB_BLOCK_GRANT_0 (3 << 12) /* don't use */
383
384/* Enable render writes to complete in C2/C3/C4 power states.
385 * If this isn't enabled, render writes are prevented in low
386 * power states. That seems bad to me.
387 */
388#define MI_ARB_C3_LP_WRITE_ENABLE (1 << 11)
389
390/* This acknowledges an async flip immediately instead
391 * of waiting for 2TLB fetches.
392 */
393#define MI_ARB_ASYNC_FLIP_ACK_IMMEDIATE (1 << 10)
394
395/* Enables non-sequential data reads through arbiter
396 */
397#define MI_ARB_DUAL_DATA_PHASE_DISABLE (1 << 9)
398
399/* Disable FSB snooping of cacheable write cycles from binner/render
400 * command stream
401 */
402#define MI_ARB_CACHE_SNOOP_DISABLE (1 << 8)
403
404/* Arbiter time slice for non-isoch streams */
405#define MI_ARB_TIME_SLICE_MASK (7 << 5)
406#define MI_ARB_TIME_SLICE_1 (0 << 5)
407#define MI_ARB_TIME_SLICE_2 (1 << 5)
408#define MI_ARB_TIME_SLICE_4 (2 << 5)
409#define MI_ARB_TIME_SLICE_6 (3 << 5)
410#define MI_ARB_TIME_SLICE_8 (4 << 5)
411#define MI_ARB_TIME_SLICE_10 (5 << 5)
412#define MI_ARB_TIME_SLICE_14 (6 << 5)
413#define MI_ARB_TIME_SLICE_16 (7 << 5)
414
415/* Low priority grace period page size */
416#define MI_ARB_LOW_PRIORITY_GRACE_4KB (0 << 4) /* default */
417#define MI_ARB_LOW_PRIORITY_GRACE_8KB (1 << 4)
418
419/* Disable display A/B trickle feed */
420#define MI_ARB_DISPLAY_TRICKLE_FEED_DISABLE (1 << 2)
421
422/* Set display plane priority */
423#define MI_ARB_DISPLAY_PRIORITY_A_B (0 << 0) /* display A > display B */
424#define MI_ARB_DISPLAY_PRIORITY_B_A (1 << 0) /* display B > display A */
425
361#define CACHE_MODE_0 0x02120 /* 915+ only */ 426#define CACHE_MODE_0 0x02120 /* 915+ only */
362#define CM0_MASK_SHIFT 16 427#define CM0_MASK_SHIFT 16
363#define CM0_IZ_OPT_DISABLE (1<<6) 428#define CM0_IZ_OPT_DISABLE (1<<6)
@@ -368,6 +433,9 @@
368#define CM0_RC_OP_FLUSH_DISABLE (1<<0) 433#define CM0_RC_OP_FLUSH_DISABLE (1<<0)
369#define BB_ADDR 0x02140 /* 8 bytes */ 434#define BB_ADDR 0x02140 /* 8 bytes */
370#define GFX_FLSH_CNTL 0x02170 /* 915+ only */ 435#define GFX_FLSH_CNTL 0x02170 /* 915+ only */
436#define ECOSKPD 0x021d0
437#define ECO_GATING_CX_ONLY (1<<3)
438#define ECO_FLIP_DONE (1<<0)
371 439
372/* GEN6 interrupt control */ 440/* GEN6 interrupt control */
373#define GEN6_RENDER_HWSTAM 0x2098 441#define GEN6_RENDER_HWSTAM 0x2098
@@ -1130,7 +1198,6 @@
1130#define CRT_HOTPLUG_DETECT_DELAY_2G (1 << 4) 1198#define CRT_HOTPLUG_DETECT_DELAY_2G (1 << 4)
1131#define CRT_HOTPLUG_DETECT_VOLTAGE_325MV (0 << 2) 1199#define CRT_HOTPLUG_DETECT_VOLTAGE_325MV (0 << 2)
1132#define CRT_HOTPLUG_DETECT_VOLTAGE_475MV (1 << 2) 1200#define CRT_HOTPLUG_DETECT_VOLTAGE_475MV (1 << 2)
1133#define CRT_HOTPLUG_MASK (0x3fc) /* Bits 9-2 */
1134 1201
1135#define PORT_HOTPLUG_STAT 0x61114 1202#define PORT_HOTPLUG_STAT 0x61114
1136#define HDMIB_HOTPLUG_INT_STATUS (1 << 29) 1203#define HDMIB_HOTPLUG_INT_STATUS (1 << 29)
@@ -2802,6 +2869,7 @@
2802 2869
2803#define PCH_PP_STATUS 0xc7200 2870#define PCH_PP_STATUS 0xc7200
2804#define PCH_PP_CONTROL 0xc7204 2871#define PCH_PP_CONTROL 0xc7204
2872#define PANEL_UNLOCK_REGS (0xabcd << 16)
2805#define EDP_FORCE_VDD (1 << 3) 2873#define EDP_FORCE_VDD (1 << 3)
2806#define EDP_BLC_ENABLE (1 << 2) 2874#define EDP_BLC_ENABLE (1 << 2)
2807#define PANEL_POWER_RESET (1 << 1) 2875#define PANEL_POWER_RESET (1 << 1)
diff --git a/drivers/gpu/drm/i915/intel_crt.c b/drivers/gpu/drm/i915/intel_crt.c
index 22ff38455731..ee0732b222a1 100644
--- a/drivers/gpu/drm/i915/intel_crt.c
+++ b/drivers/gpu/drm/i915/intel_crt.c
@@ -234,14 +234,8 @@ static bool intel_crt_detect_hotplug(struct drm_connector *connector)
234 else 234 else
235 tries = 1; 235 tries = 1;
236 hotplug_en = orig = I915_READ(PORT_HOTPLUG_EN); 236 hotplug_en = orig = I915_READ(PORT_HOTPLUG_EN);
237 hotplug_en &= CRT_HOTPLUG_MASK;
238 hotplug_en |= CRT_HOTPLUG_FORCE_DETECT; 237 hotplug_en |= CRT_HOTPLUG_FORCE_DETECT;
239 238
240 if (IS_G4X(dev))
241 hotplug_en |= CRT_HOTPLUG_ACTIVATION_PERIOD_64;
242
243 hotplug_en |= CRT_HOTPLUG_VOLTAGE_COMPARE_50;
244
245 for (i = 0; i < tries ; i++) { 239 for (i = 0; i < tries ; i++) {
246 unsigned long timeout; 240 unsigned long timeout;
247 /* turn on the FORCE_DETECT */ 241 /* turn on the FORCE_DETECT */
diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
index cc8131ff319f..5e21b3119824 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -862,8 +862,8 @@ intel_g4x_find_best_PLL(const intel_limit_t *limit, struct drm_crtc *crtc,
862 intel_clock_t clock; 862 intel_clock_t clock;
863 int max_n; 863 int max_n;
864 bool found; 864 bool found;
865 /* approximately equals target * 0.00488 */ 865 /* approximately equals target * 0.00585 */
866 int err_most = (target >> 8) + (target >> 10); 866 int err_most = (target >> 8) + (target >> 9);
867 found = false; 867 found = false;
868 868
869 if (intel_pipe_has_type(crtc, INTEL_OUTPUT_LVDS)) { 869 if (intel_pipe_has_type(crtc, INTEL_OUTPUT_LVDS)) {
@@ -1180,8 +1180,12 @@ static void intel_update_fbc(struct drm_crtc *crtc,
1180 struct drm_framebuffer *fb = crtc->fb; 1180 struct drm_framebuffer *fb = crtc->fb;
1181 struct intel_framebuffer *intel_fb; 1181 struct intel_framebuffer *intel_fb;
1182 struct drm_i915_gem_object *obj_priv; 1182 struct drm_i915_gem_object *obj_priv;
1183 struct drm_crtc *tmp_crtc;
1183 struct intel_crtc *intel_crtc = to_intel_crtc(crtc); 1184 struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
1184 int plane = intel_crtc->plane; 1185 int plane = intel_crtc->plane;
1186 int crtcs_enabled = 0;
1187
1188 DRM_DEBUG_KMS("\n");
1185 1189
1186 if (!i915_powersave) 1190 if (!i915_powersave)
1187 return; 1191 return;
@@ -1199,10 +1203,21 @@ static void intel_update_fbc(struct drm_crtc *crtc,
1199 * If FBC is already on, we just have to verify that we can 1203 * If FBC is already on, we just have to verify that we can
1200 * keep it that way... 1204 * keep it that way...
1201 * Need to disable if: 1205 * Need to disable if:
1206 * - more than one pipe is active
1202 * - changing FBC params (stride, fence, mode) 1207 * - changing FBC params (stride, fence, mode)
1203 * - new fb is too large to fit in compressed buffer 1208 * - new fb is too large to fit in compressed buffer
1204 * - going to an unsupported config (interlace, pixel multiply, etc.) 1209 * - going to an unsupported config (interlace, pixel multiply, etc.)
1205 */ 1210 */
1211 list_for_each_entry(tmp_crtc, &dev->mode_config.crtc_list, head) {
1212 if (tmp_crtc->enabled)
1213 crtcs_enabled++;
1214 }
1215 DRM_DEBUG_KMS("%d pipes active\n", crtcs_enabled);
1216 if (crtcs_enabled > 1) {
1217 DRM_DEBUG_KMS("more than one pipe active, disabling compression\n");
1218 dev_priv->no_fbc_reason = FBC_MULTIPLE_PIPES;
1219 goto out_disable;
1220 }
1206 if (intel_fb->obj->size > dev_priv->cfb_size) { 1221 if (intel_fb->obj->size > dev_priv->cfb_size) {
1207 DRM_DEBUG_KMS("framebuffer too large, disabling " 1222 DRM_DEBUG_KMS("framebuffer too large, disabling "
1208 "compression\n"); 1223 "compression\n");
@@ -1255,7 +1270,7 @@ out_disable:
1255 } 1270 }
1256} 1271}
1257 1272
1258static int 1273int
1259intel_pin_and_fence_fb_obj(struct drm_device *dev, struct drm_gem_object *obj) 1274intel_pin_and_fence_fb_obj(struct drm_device *dev, struct drm_gem_object *obj)
1260{ 1275{
1261 struct drm_i915_gem_object *obj_priv = to_intel_bo(obj); 1276 struct drm_i915_gem_object *obj_priv = to_intel_bo(obj);
@@ -2255,6 +2270,11 @@ static void i9xx_crtc_dpms(struct drm_crtc *crtc, int mode)
2255 intel_wait_for_vblank(dev); 2270 intel_wait_for_vblank(dev);
2256 } 2271 }
2257 2272
2273 /* Don't disable pipe A or pipe A PLLs if needed */
2274 if (pipeconf_reg == PIPEACONF &&
2275 (dev_priv->quirks & QUIRK_PIPEA_FORCE))
2276 goto skip_pipe_off;
2277
2258 /* Next, disable display pipes */ 2278 /* Next, disable display pipes */
2259 temp = I915_READ(pipeconf_reg); 2279 temp = I915_READ(pipeconf_reg);
2260 if ((temp & PIPEACONF_ENABLE) != 0) { 2280 if ((temp & PIPEACONF_ENABLE) != 0) {
@@ -2270,7 +2290,7 @@ static void i9xx_crtc_dpms(struct drm_crtc *crtc, int mode)
2270 I915_WRITE(dpll_reg, temp & ~DPLL_VCO_ENABLE); 2290 I915_WRITE(dpll_reg, temp & ~DPLL_VCO_ENABLE);
2271 I915_READ(dpll_reg); 2291 I915_READ(dpll_reg);
2272 } 2292 }
2273 2293 skip_pipe_off:
2274 /* Wait for the clocks to turn off. */ 2294 /* Wait for the clocks to turn off. */
2275 udelay(150); 2295 udelay(150);
2276 break; 2296 break;
@@ -2356,8 +2376,6 @@ static bool intel_crtc_mode_fixup(struct drm_crtc *crtc,
2356 if (mode->clock * 3 > 27000 * 4) 2376 if (mode->clock * 3 > 27000 * 4)
2357 return MODE_CLOCK_HIGH; 2377 return MODE_CLOCK_HIGH;
2358 } 2378 }
2359
2360 drm_mode_set_crtcinfo(adjusted_mode, 0);
2361 return true; 2379 return true;
2362} 2380}
2363 2381
@@ -2970,11 +2988,13 @@ static void i965_update_wm(struct drm_device *dev, int planea_clock,
2970 if (srwm < 0) 2988 if (srwm < 0)
2971 srwm = 1; 2989 srwm = 1;
2972 srwm &= 0x3f; 2990 srwm &= 0x3f;
2973 I915_WRITE(FW_BLC_SELF, FW_BLC_SELF_EN); 2991 if (IS_I965GM(dev))
2992 I915_WRITE(FW_BLC_SELF, FW_BLC_SELF_EN);
2974 } else { 2993 } else {
2975 /* Turn off self refresh if both pipes are enabled */ 2994 /* Turn off self refresh if both pipes are enabled */
2976 I915_WRITE(FW_BLC_SELF, I915_READ(FW_BLC_SELF) 2995 if (IS_I965GM(dev))
2977 & ~FW_BLC_SELF_EN); 2996 I915_WRITE(FW_BLC_SELF, I915_READ(FW_BLC_SELF)
2997 & ~FW_BLC_SELF_EN);
2978 } 2998 }
2979 2999
2980 DRM_DEBUG_KMS("Setting FIFO watermarks - A: 8, B: 8, C: 8, SR %d\n", 3000 DRM_DEBUG_KMS("Setting FIFO watermarks - A: 8, B: 8, C: 8, SR %d\n",
@@ -3734,6 +3754,7 @@ static int intel_crtc_mode_set(struct drm_crtc *crtc,
3734 if (dev_priv->lvds_dither) { 3754 if (dev_priv->lvds_dither) {
3735 if (HAS_PCH_SPLIT(dev)) { 3755 if (HAS_PCH_SPLIT(dev)) {
3736 pipeconf |= PIPE_ENABLE_DITHER; 3756 pipeconf |= PIPE_ENABLE_DITHER;
3757 pipeconf &= ~PIPE_DITHER_TYPE_MASK;
3737 pipeconf |= PIPE_DITHER_TYPE_ST01; 3758 pipeconf |= PIPE_DITHER_TYPE_ST01;
3738 } else 3759 } else
3739 lvds |= LVDS_ENABLE_DITHER; 3760 lvds |= LVDS_ENABLE_DITHER;
@@ -4410,7 +4431,8 @@ static void intel_increase_pllclock(struct drm_crtc *crtc, bool schedule)
4410 DRM_DEBUG_DRIVER("upclocking LVDS\n"); 4431 DRM_DEBUG_DRIVER("upclocking LVDS\n");
4411 4432
4412 /* Unlock panel regs */ 4433 /* Unlock panel regs */
4413 I915_WRITE(PP_CONTROL, I915_READ(PP_CONTROL) | (0xabcd << 16)); 4434 I915_WRITE(PP_CONTROL, I915_READ(PP_CONTROL) |
4435 PANEL_UNLOCK_REGS);
4414 4436
4415 dpll &= ~DISPLAY_RATE_SELECT_FPA1; 4437 dpll &= ~DISPLAY_RATE_SELECT_FPA1;
4416 I915_WRITE(dpll_reg, dpll); 4438 I915_WRITE(dpll_reg, dpll);
@@ -4453,7 +4475,8 @@ static void intel_decrease_pllclock(struct drm_crtc *crtc)
4453 DRM_DEBUG_DRIVER("downclocking LVDS\n"); 4475 DRM_DEBUG_DRIVER("downclocking LVDS\n");
4454 4476
4455 /* Unlock panel regs */ 4477 /* Unlock panel regs */
4456 I915_WRITE(PP_CONTROL, I915_READ(PP_CONTROL) | (0xabcd << 16)); 4478 I915_WRITE(PP_CONTROL, I915_READ(PP_CONTROL) |
4479 PANEL_UNLOCK_REGS);
4457 4480
4458 dpll |= DISPLAY_RATE_SELECT_FPA1; 4481 dpll |= DISPLAY_RATE_SELECT_FPA1;
4459 I915_WRITE(dpll_reg, dpll); 4482 I915_WRITE(dpll_reg, dpll);
@@ -4483,6 +4506,7 @@ static void intel_idle_update(struct work_struct *work)
4483 struct drm_device *dev = dev_priv->dev; 4506 struct drm_device *dev = dev_priv->dev;
4484 struct drm_crtc *crtc; 4507 struct drm_crtc *crtc;
4485 struct intel_crtc *intel_crtc; 4508 struct intel_crtc *intel_crtc;
4509 int enabled = 0;
4486 4510
4487 if (!i915_powersave) 4511 if (!i915_powersave)
4488 return; 4512 return;
@@ -4491,21 +4515,22 @@ static void intel_idle_update(struct work_struct *work)
4491 4515
4492 i915_update_gfx_val(dev_priv); 4516 i915_update_gfx_val(dev_priv);
4493 4517
4494 if (IS_I945G(dev) || IS_I945GM(dev)) {
4495 DRM_DEBUG_DRIVER("enable memory self refresh on 945\n");
4496 I915_WRITE(FW_BLC_SELF, FW_BLC_SELF_EN_MASK | FW_BLC_SELF_EN);
4497 }
4498
4499 list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) { 4518 list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) {
4500 /* Skip inactive CRTCs */ 4519 /* Skip inactive CRTCs */
4501 if (!crtc->fb) 4520 if (!crtc->fb)
4502 continue; 4521 continue;
4503 4522
4523 enabled++;
4504 intel_crtc = to_intel_crtc(crtc); 4524 intel_crtc = to_intel_crtc(crtc);
4505 if (!intel_crtc->busy) 4525 if (!intel_crtc->busy)
4506 intel_decrease_pllclock(crtc); 4526 intel_decrease_pllclock(crtc);
4507 } 4527 }
4508 4528
4529 if ((enabled == 1) && (IS_I945G(dev) || IS_I945GM(dev))) {
4530 DRM_DEBUG_DRIVER("enable memory self refresh on 945\n");
4531 I915_WRITE(FW_BLC_SELF, FW_BLC_SELF_EN_MASK | FW_BLC_SELF_EN);
4532 }
4533
4509 mutex_unlock(&dev->struct_mutex); 4534 mutex_unlock(&dev->struct_mutex);
4510} 4535}
4511 4536
@@ -4601,10 +4626,10 @@ static void intel_unpin_work_fn(struct work_struct *__work)
4601 kfree(work); 4626 kfree(work);
4602} 4627}
4603 4628
4604void intel_finish_page_flip(struct drm_device *dev, int pipe) 4629static void do_intel_finish_page_flip(struct drm_device *dev,
4630 struct drm_crtc *crtc)
4605{ 4631{
4606 drm_i915_private_t *dev_priv = dev->dev_private; 4632 drm_i915_private_t *dev_priv = dev->dev_private;
4607 struct drm_crtc *crtc = dev_priv->pipe_to_crtc_mapping[pipe];
4608 struct intel_crtc *intel_crtc = to_intel_crtc(crtc); 4633 struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
4609 struct intel_unpin_work *work; 4634 struct intel_unpin_work *work;
4610 struct drm_i915_gem_object *obj_priv; 4635 struct drm_i915_gem_object *obj_priv;
@@ -4648,6 +4673,22 @@ void intel_finish_page_flip(struct drm_device *dev, int pipe)
4648 schedule_work(&work->work); 4673 schedule_work(&work->work);
4649} 4674}
4650 4675
4676void intel_finish_page_flip(struct drm_device *dev, int pipe)
4677{
4678 drm_i915_private_t *dev_priv = dev->dev_private;
4679 struct drm_crtc *crtc = dev_priv->pipe_to_crtc_mapping[pipe];
4680
4681 do_intel_finish_page_flip(dev, crtc);
4682}
4683
4684void intel_finish_page_flip_plane(struct drm_device *dev, int plane)
4685{
4686 drm_i915_private_t *dev_priv = dev->dev_private;
4687 struct drm_crtc *crtc = dev_priv->plane_to_crtc_mapping[plane];
4688
4689 do_intel_finish_page_flip(dev, crtc);
4690}
4691
4651void intel_prepare_page_flip(struct drm_device *dev, int plane) 4692void intel_prepare_page_flip(struct drm_device *dev, int plane)
4652{ 4693{
4653 drm_i915_private_t *dev_priv = dev->dev_private; 4694 drm_i915_private_t *dev_priv = dev->dev_private;
@@ -4675,9 +4716,10 @@ static int intel_crtc_page_flip(struct drm_crtc *crtc,
4675 struct drm_gem_object *obj; 4716 struct drm_gem_object *obj;
4676 struct intel_crtc *intel_crtc = to_intel_crtc(crtc); 4717 struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
4677 struct intel_unpin_work *work; 4718 struct intel_unpin_work *work;
4678 unsigned long flags; 4719 unsigned long flags, offset;
4679 int pipesrc_reg = (intel_crtc->pipe == 0) ? PIPEASRC : PIPEBSRC; 4720 int pipesrc_reg = (intel_crtc->pipe == 0) ? PIPEASRC : PIPEBSRC;
4680 int ret, pipesrc; 4721 int ret, pipesrc;
4722 u32 flip_mask;
4681 4723
4682 work = kzalloc(sizeof *work, GFP_KERNEL); 4724 work = kzalloc(sizeof *work, GFP_KERNEL);
4683 if (work == NULL) 4725 if (work == NULL)
@@ -4731,16 +4773,33 @@ static int intel_crtc_page_flip(struct drm_crtc *crtc,
4731 atomic_inc(&obj_priv->pending_flip); 4773 atomic_inc(&obj_priv->pending_flip);
4732 work->pending_flip_obj = obj; 4774 work->pending_flip_obj = obj;
4733 4775
4776 if (intel_crtc->plane)
4777 flip_mask = I915_DISPLAY_PLANE_B_FLIP_PENDING_INTERRUPT;
4778 else
4779 flip_mask = I915_DISPLAY_PLANE_A_FLIP_PENDING_INTERRUPT;
4780
4781 /* Wait for any previous flip to finish */
4782 if (IS_GEN3(dev))
4783 while (I915_READ(ISR) & flip_mask)
4784 ;
4785
4786 /* Offset into the new buffer for cases of shared fbs between CRTCs */
4787 offset = obj_priv->gtt_offset;
4788 offset += (crtc->y * fb->pitch) + (crtc->x * (fb->bits_per_pixel) / 8);
4789
4734 BEGIN_LP_RING(4); 4790 BEGIN_LP_RING(4);
4735 OUT_RING(MI_DISPLAY_FLIP |
4736 MI_DISPLAY_FLIP_PLANE(intel_crtc->plane));
4737 OUT_RING(fb->pitch);
4738 if (IS_I965G(dev)) { 4791 if (IS_I965G(dev)) {
4739 OUT_RING(obj_priv->gtt_offset | obj_priv->tiling_mode); 4792 OUT_RING(MI_DISPLAY_FLIP |
4793 MI_DISPLAY_FLIP_PLANE(intel_crtc->plane));
4794 OUT_RING(fb->pitch);
4795 OUT_RING(offset | obj_priv->tiling_mode);
4740 pipesrc = I915_READ(pipesrc_reg); 4796 pipesrc = I915_READ(pipesrc_reg);
4741 OUT_RING(pipesrc & 0x0fff0fff); 4797 OUT_RING(pipesrc & 0x0fff0fff);
4742 } else { 4798 } else {
4743 OUT_RING(obj_priv->gtt_offset); 4799 OUT_RING(MI_DISPLAY_FLIP_I915 |
4800 MI_DISPLAY_FLIP_PLANE(intel_crtc->plane));
4801 OUT_RING(fb->pitch);
4802 OUT_RING(offset);
4744 OUT_RING(MI_NOOP); 4803 OUT_RING(MI_NOOP);
4745 } 4804 }
4746 ADVANCE_LP_RING(); 4805 ADVANCE_LP_RING();
@@ -5472,6 +5531,66 @@ static void intel_init_display(struct drm_device *dev)
5472 } 5531 }
5473} 5532}
5474 5533
5534/*
5535 * Some BIOSes insist on assuming the GPU's pipe A is enabled at suspend,
5536 * resume, or other times. This quirk makes sure that's the case for
5537 * affected systems.
5538 */
5539static void quirk_pipea_force (struct drm_device *dev)
5540{
5541 struct drm_i915_private *dev_priv = dev->dev_private;
5542
5543 dev_priv->quirks |= QUIRK_PIPEA_FORCE;
5544 DRM_DEBUG_DRIVER("applying pipe a force quirk\n");
5545}
5546
5547struct intel_quirk {
5548 int device;
5549 int subsystem_vendor;
5550 int subsystem_device;
5551 void (*hook)(struct drm_device *dev);
5552};
5553
5554struct intel_quirk intel_quirks[] = {
5555 /* HP Compaq 2730p needs pipe A force quirk (LP: #291555) */
5556 { 0x2a42, 0x103c, 0x30eb, quirk_pipea_force },
5557 /* HP Mini needs pipe A force quirk (LP: #322104) */
5558 { 0x27ae,0x103c, 0x361a, quirk_pipea_force },
5559
5560 /* Thinkpad R31 needs pipe A force quirk */
5561 { 0x3577, 0x1014, 0x0505, quirk_pipea_force },
5562 /* Toshiba Protege R-205, S-209 needs pipe A force quirk */
5563 { 0x2592, 0x1179, 0x0001, quirk_pipea_force },
5564
5565 /* ThinkPad X30 needs pipe A force quirk (LP: #304614) */
5566 { 0x3577, 0x1014, 0x0513, quirk_pipea_force },
5567 /* ThinkPad X40 needs pipe A force quirk */
5568
5569 /* ThinkPad T60 needs pipe A force quirk (bug #16494) */
5570 { 0x2782, 0x17aa, 0x201a, quirk_pipea_force },
5571
5572 /* 855 & before need to leave pipe A & dpll A up */
5573 { 0x3582, PCI_ANY_ID, PCI_ANY_ID, quirk_pipea_force },
5574 { 0x2562, PCI_ANY_ID, PCI_ANY_ID, quirk_pipea_force },
5575};
5576
5577static void intel_init_quirks(struct drm_device *dev)
5578{
5579 struct pci_dev *d = dev->pdev;
5580 int i;
5581
5582 for (i = 0; i < ARRAY_SIZE(intel_quirks); i++) {
5583 struct intel_quirk *q = &intel_quirks[i];
5584
5585 if (d->device == q->device &&
5586 (d->subsystem_vendor == q->subsystem_vendor ||
5587 q->subsystem_vendor == PCI_ANY_ID) &&
5588 (d->subsystem_device == q->subsystem_device ||
5589 q->subsystem_device == PCI_ANY_ID))
5590 q->hook(dev);
5591 }
5592}
5593
5475void intel_modeset_init(struct drm_device *dev) 5594void intel_modeset_init(struct drm_device *dev)
5476{ 5595{
5477 struct drm_i915_private *dev_priv = dev->dev_private; 5596 struct drm_i915_private *dev_priv = dev->dev_private;
@@ -5484,6 +5603,8 @@ void intel_modeset_init(struct drm_device *dev)
5484 5603
5485 dev->mode_config.funcs = (void *)&intel_mode_funcs; 5604 dev->mode_config.funcs = (void *)&intel_mode_funcs;
5486 5605
5606 intel_init_quirks(dev);
5607
5487 intel_init_display(dev); 5608 intel_init_display(dev);
5488 5609
5489 if (IS_I965G(dev)) { 5610 if (IS_I965G(dev)) {
diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c
index 49b54f05d3cf..5dde80f9e652 100644
--- a/drivers/gpu/drm/i915/intel_dp.c
+++ b/drivers/gpu/drm/i915/intel_dp.c
@@ -136,6 +136,12 @@ intel_dp_link_required(struct drm_device *dev,
136} 136}
137 137
138static int 138static int
139intel_dp_max_data_rate(int max_link_clock, int max_lanes)
140{
141 return (max_link_clock * max_lanes * 8) / 10;
142}
143
144static int
139intel_dp_mode_valid(struct drm_connector *connector, 145intel_dp_mode_valid(struct drm_connector *connector,
140 struct drm_display_mode *mode) 146 struct drm_display_mode *mode)
141{ 147{
@@ -144,8 +150,11 @@ intel_dp_mode_valid(struct drm_connector *connector,
144 int max_link_clock = intel_dp_link_clock(intel_dp_max_link_bw(intel_encoder)); 150 int max_link_clock = intel_dp_link_clock(intel_dp_max_link_bw(intel_encoder));
145 int max_lanes = intel_dp_max_lane_count(intel_encoder); 151 int max_lanes = intel_dp_max_lane_count(intel_encoder);
146 152
147 if (intel_dp_link_required(connector->dev, intel_encoder, mode->clock) 153 /* only refuse the mode on non eDP since we have seen some wierd eDP panels
148 > max_link_clock * max_lanes) 154 which are outside spec tolerances but somehow work by magic */
155 if (!IS_eDP(intel_encoder) &&
156 (intel_dp_link_required(connector->dev, intel_encoder, mode->clock)
157 > intel_dp_max_data_rate(max_link_clock, max_lanes)))
149 return MODE_CLOCK_HIGH; 158 return MODE_CLOCK_HIGH;
150 159
151 if (mode->clock < 10000) 160 if (mode->clock < 10000)
@@ -506,7 +515,7 @@ intel_dp_mode_fixup(struct drm_encoder *encoder, struct drm_display_mode *mode,
506 515
507 for (lane_count = 1; lane_count <= max_lane_count; lane_count <<= 1) { 516 for (lane_count = 1; lane_count <= max_lane_count; lane_count <<= 1) {
508 for (clock = 0; clock <= max_clock; clock++) { 517 for (clock = 0; clock <= max_clock; clock++) {
509 int link_avail = intel_dp_link_clock(bws[clock]) * lane_count; 518 int link_avail = intel_dp_max_data_rate(intel_dp_link_clock(bws[clock]), lane_count);
510 519
511 if (intel_dp_link_required(encoder->dev, intel_encoder, mode->clock) 520 if (intel_dp_link_required(encoder->dev, intel_encoder, mode->clock)
512 <= link_avail) { 521 <= link_avail) {
@@ -521,6 +530,18 @@ intel_dp_mode_fixup(struct drm_encoder *encoder, struct drm_display_mode *mode,
521 } 530 }
522 } 531 }
523 } 532 }
533
534 if (IS_eDP(intel_encoder)) {
535 /* okay we failed just pick the highest */
536 dp_priv->lane_count = max_lane_count;
537 dp_priv->link_bw = bws[max_clock];
538 adjusted_mode->clock = intel_dp_link_clock(dp_priv->link_bw);
539 DRM_DEBUG_KMS("Force picking display port link bw %02x lane "
540 "count %d clock %d\n",
541 dp_priv->link_bw, dp_priv->lane_count,
542 adjusted_mode->clock);
543 return true;
544 }
524 return false; 545 return false;
525} 546}
526 547
@@ -696,6 +717,51 @@ intel_dp_mode_set(struct drm_encoder *encoder, struct drm_display_mode *mode,
696 } 717 }
697} 718}
698 719
720static void ironlake_edp_panel_on (struct drm_device *dev)
721{
722 struct drm_i915_private *dev_priv = dev->dev_private;
723 unsigned long timeout = jiffies + msecs_to_jiffies(5000);
724 u32 pp, pp_status;
725
726 pp_status = I915_READ(PCH_PP_STATUS);
727 if (pp_status & PP_ON)
728 return;
729
730 pp = I915_READ(PCH_PP_CONTROL);
731 pp |= PANEL_UNLOCK_REGS | POWER_TARGET_ON;
732 I915_WRITE(PCH_PP_CONTROL, pp);
733 do {
734 pp_status = I915_READ(PCH_PP_STATUS);
735 } while (((pp_status & PP_ON) == 0) && !time_after(jiffies, timeout));
736
737 if (time_after(jiffies, timeout))
738 DRM_DEBUG_KMS("panel on wait timed out: 0x%08x\n", pp_status);
739
740 pp &= ~(PANEL_UNLOCK_REGS | EDP_FORCE_VDD);
741 I915_WRITE(PCH_PP_CONTROL, pp);
742}
743
744static void ironlake_edp_panel_off (struct drm_device *dev)
745{
746 struct drm_i915_private *dev_priv = dev->dev_private;
747 unsigned long timeout = jiffies + msecs_to_jiffies(5000);
748 u32 pp, pp_status;
749
750 pp = I915_READ(PCH_PP_CONTROL);
751 pp &= ~POWER_TARGET_ON;
752 I915_WRITE(PCH_PP_CONTROL, pp);
753 do {
754 pp_status = I915_READ(PCH_PP_STATUS);
755 } while ((pp_status & PP_ON) && !time_after(jiffies, timeout));
756
757 if (time_after(jiffies, timeout))
758 DRM_DEBUG_KMS("panel off wait timed out\n");
759
760 /* Make sure VDD is enabled so DP AUX will work */
761 pp |= EDP_FORCE_VDD;
762 I915_WRITE(PCH_PP_CONTROL, pp);
763}
764
699static void ironlake_edp_backlight_on (struct drm_device *dev) 765static void ironlake_edp_backlight_on (struct drm_device *dev)
700{ 766{
701 struct drm_i915_private *dev_priv = dev->dev_private; 767 struct drm_i915_private *dev_priv = dev->dev_private;
@@ -730,14 +796,18 @@ intel_dp_dpms(struct drm_encoder *encoder, int mode)
730 if (mode != DRM_MODE_DPMS_ON) { 796 if (mode != DRM_MODE_DPMS_ON) {
731 if (dp_reg & DP_PORT_EN) { 797 if (dp_reg & DP_PORT_EN) {
732 intel_dp_link_down(intel_encoder, dp_priv->DP); 798 intel_dp_link_down(intel_encoder, dp_priv->DP);
733 if (IS_eDP(intel_encoder)) 799 if (IS_eDP(intel_encoder)) {
734 ironlake_edp_backlight_off(dev); 800 ironlake_edp_backlight_off(dev);
801 ironlake_edp_panel_off(dev);
802 }
735 } 803 }
736 } else { 804 } else {
737 if (!(dp_reg & DP_PORT_EN)) { 805 if (!(dp_reg & DP_PORT_EN)) {
738 intel_dp_link_train(intel_encoder, dp_priv->DP, dp_priv->link_configuration); 806 intel_dp_link_train(intel_encoder, dp_priv->DP, dp_priv->link_configuration);
739 if (IS_eDP(intel_encoder)) 807 if (IS_eDP(intel_encoder)) {
808 ironlake_edp_panel_on(dev);
740 ironlake_edp_backlight_on(dev); 809 ironlake_edp_backlight_on(dev);
810 }
741 } 811 }
742 } 812 }
743 dp_priv->dpms_mode = mode; 813 dp_priv->dpms_mode = mode;
diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h
index df931f787665..2f7970be9051 100644
--- a/drivers/gpu/drm/i915/intel_drv.h
+++ b/drivers/gpu/drm/i915/intel_drv.h
@@ -215,6 +215,9 @@ extern void intel_init_clock_gating(struct drm_device *dev);
215extern void ironlake_enable_drps(struct drm_device *dev); 215extern void ironlake_enable_drps(struct drm_device *dev);
216extern void ironlake_disable_drps(struct drm_device *dev); 216extern void ironlake_disable_drps(struct drm_device *dev);
217 217
218extern int intel_pin_and_fence_fb_obj(struct drm_device *dev,
219 struct drm_gem_object *obj);
220
218extern int intel_framebuffer_init(struct drm_device *dev, 221extern int intel_framebuffer_init(struct drm_device *dev,
219 struct intel_framebuffer *ifb, 222 struct intel_framebuffer *ifb,
220 struct drm_mode_fb_cmd *mode_cmd, 223 struct drm_mode_fb_cmd *mode_cmd,
@@ -224,6 +227,7 @@ extern void intel_fbdev_fini(struct drm_device *dev);
224 227
225extern void intel_prepare_page_flip(struct drm_device *dev, int plane); 228extern void intel_prepare_page_flip(struct drm_device *dev, int plane);
226extern void intel_finish_page_flip(struct drm_device *dev, int pipe); 229extern void intel_finish_page_flip(struct drm_device *dev, int pipe);
230extern void intel_finish_page_flip_plane(struct drm_device *dev, int plane);
227 231
228extern void intel_setup_overlay(struct drm_device *dev); 232extern void intel_setup_overlay(struct drm_device *dev);
229extern void intel_cleanup_overlay(struct drm_device *dev); 233extern void intel_cleanup_overlay(struct drm_device *dev);
diff --git a/drivers/gpu/drm/i915/intel_fb.c b/drivers/gpu/drm/i915/intel_fb.c
index c3c505244e07..3e18c9e7729b 100644
--- a/drivers/gpu/drm/i915/intel_fb.c
+++ b/drivers/gpu/drm/i915/intel_fb.c
@@ -98,7 +98,7 @@ static int intelfb_create(struct intel_fbdev *ifbdev,
98 98
99 mutex_lock(&dev->struct_mutex); 99 mutex_lock(&dev->struct_mutex);
100 100
101 ret = i915_gem_object_pin(fbo, 64*1024); 101 ret = intel_pin_and_fence_fb_obj(dev, fbo);
102 if (ret) { 102 if (ret) {
103 DRM_ERROR("failed to pin fb: %d\n", ret); 103 DRM_ERROR("failed to pin fb: %d\n", ret);
104 goto out_unref; 104 goto out_unref;
@@ -236,7 +236,7 @@ int intel_fbdev_destroy(struct drm_device *dev,
236 236
237 drm_framebuffer_cleanup(&ifb->base); 237 drm_framebuffer_cleanup(&ifb->base);
238 if (ifb->obj) 238 if (ifb->obj)
239 drm_gem_object_unreference_unlocked(ifb->obj); 239 drm_gem_object_unreference(ifb->obj);
240 240
241 return 0; 241 return 0;
242} 242}
diff --git a/drivers/gpu/drm/i915/intel_lvds.c b/drivers/gpu/drm/i915/intel_lvds.c
index 6a1accd83aec..0eab8df5bf7e 100644
--- a/drivers/gpu/drm/i915/intel_lvds.c
+++ b/drivers/gpu/drm/i915/intel_lvds.c
@@ -599,6 +599,26 @@ static int intel_lvds_get_modes(struct drm_connector *connector)
599 return 0; 599 return 0;
600} 600}
601 601
602static int intel_no_modeset_on_lid_dmi_callback(const struct dmi_system_id *id)
603{
604 DRM_DEBUG_KMS("Skipping forced modeset for %s\n", id->ident);
605 return 1;
606}
607
608/* The GPU hangs up on these systems if modeset is performed on LID open */
609static const struct dmi_system_id intel_no_modeset_on_lid[] = {
610 {
611 .callback = intel_no_modeset_on_lid_dmi_callback,
612 .ident = "Toshiba Tecra A11",
613 .matches = {
614 DMI_MATCH(DMI_SYS_VENDOR, "TOSHIBA"),
615 DMI_MATCH(DMI_PRODUCT_NAME, "TECRA A11"),
616 },
617 },
618
619 { } /* terminating entry */
620};
621
602/* 622/*
603 * Lid events. Note the use of 'modeset_on_lid': 623 * Lid events. Note the use of 'modeset_on_lid':
604 * - we set it on lid close, and reset it on open 624 * - we set it on lid close, and reset it on open
@@ -622,6 +642,9 @@ static int intel_lid_notify(struct notifier_block *nb, unsigned long val,
622 */ 642 */
623 if (connector) 643 if (connector)
624 connector->status = connector->funcs->detect(connector); 644 connector->status = connector->funcs->detect(connector);
645 /* Don't force modeset on machines where it causes a GPU lockup */
646 if (dmi_check_system(intel_no_modeset_on_lid))
647 return NOTIFY_OK;
625 if (!acpi_lid_open()) { 648 if (!acpi_lid_open()) {
626 dev_priv->modeset_on_lid = 1; 649 dev_priv->modeset_on_lid = 1;
627 return NOTIFY_OK; 650 return NOTIFY_OK;
@@ -983,8 +1006,8 @@ void intel_lvds_init(struct drm_device *dev)
983 1006
984 drm_connector_attach_property(&intel_connector->base, 1007 drm_connector_attach_property(&intel_connector->base,
985 dev->mode_config.scaling_mode_property, 1008 dev->mode_config.scaling_mode_property,
986 DRM_MODE_SCALE_FULLSCREEN); 1009 DRM_MODE_SCALE_ASPECT);
987 lvds_priv->fitting_mode = DRM_MODE_SCALE_FULLSCREEN; 1010 lvds_priv->fitting_mode = DRM_MODE_SCALE_ASPECT;
988 /* 1011 /*
989 * LVDS discovery: 1012 * LVDS discovery:
990 * 1) check for EDID on DDC 1013 * 1) check for EDID on DDC
diff --git a/drivers/gpu/drm/i915/intel_ringbuffer.c b/drivers/gpu/drm/i915/intel_ringbuffer.c
index cea4f1a8709e..26362f8495a8 100644
--- a/drivers/gpu/drm/i915/intel_ringbuffer.c
+++ b/drivers/gpu/drm/i915/intel_ringbuffer.c
@@ -94,7 +94,7 @@ render_ring_flush(struct drm_device *dev,
94#if WATCH_EXEC 94#if WATCH_EXEC
95 DRM_INFO("%s: queue flush %08x to ring\n", __func__, cmd); 95 DRM_INFO("%s: queue flush %08x to ring\n", __func__, cmd);
96#endif 96#endif
97 intel_ring_begin(dev, ring, 8); 97 intel_ring_begin(dev, ring, 2);
98 intel_ring_emit(dev, ring, cmd); 98 intel_ring_emit(dev, ring, cmd);
99 intel_ring_emit(dev, ring, MI_NOOP); 99 intel_ring_emit(dev, ring, MI_NOOP);
100 intel_ring_advance(dev, ring); 100 intel_ring_advance(dev, ring);
@@ -358,7 +358,7 @@ bsd_ring_flush(struct drm_device *dev,
358 u32 invalidate_domains, 358 u32 invalidate_domains,
359 u32 flush_domains) 359 u32 flush_domains)
360{ 360{
361 intel_ring_begin(dev, ring, 8); 361 intel_ring_begin(dev, ring, 2);
362 intel_ring_emit(dev, ring, MI_FLUSH); 362 intel_ring_emit(dev, ring, MI_FLUSH);
363 intel_ring_emit(dev, ring, MI_NOOP); 363 intel_ring_emit(dev, ring, MI_NOOP);
364 intel_ring_advance(dev, ring); 364 intel_ring_advance(dev, ring);
@@ -687,6 +687,7 @@ int intel_wrap_ring_buffer(struct drm_device *dev,
687 *virt++ = MI_NOOP; 687 *virt++ = MI_NOOP;
688 688
689 ring->tail = 0; 689 ring->tail = 0;
690 ring->space = ring->head - 8;
690 691
691 return 0; 692 return 0;
692} 693}
@@ -721,8 +722,9 @@ int intel_wait_ring_buffer(struct drm_device *dev,
721} 722}
722 723
723void intel_ring_begin(struct drm_device *dev, 724void intel_ring_begin(struct drm_device *dev,
724 struct intel_ring_buffer *ring, int n) 725 struct intel_ring_buffer *ring, int num_dwords)
725{ 726{
727 int n = 4*num_dwords;
726 if (unlikely(ring->tail + n > ring->size)) 728 if (unlikely(ring->tail + n > ring->size))
727 intel_wrap_ring_buffer(dev, ring); 729 intel_wrap_ring_buffer(dev, ring);
728 if (unlikely(ring->space < n)) 730 if (unlikely(ring->space < n))
@@ -752,7 +754,7 @@ void intel_fill_struct(struct drm_device *dev,
752{ 754{
753 unsigned int *virt = ring->virtual_start + ring->tail; 755 unsigned int *virt = ring->virtual_start + ring->tail;
754 BUG_ON((len&~(4-1)) != 0); 756 BUG_ON((len&~(4-1)) != 0);
755 intel_ring_begin(dev, ring, len); 757 intel_ring_begin(dev, ring, len/4);
756 memcpy(virt, data, len); 758 memcpy(virt, data, len);
757 ring->tail += len; 759 ring->tail += len;
758 ring->tail &= ring->size - 1; 760 ring->tail &= ring->size - 1;
diff --git a/drivers/gpu/drm/nouveau/nouveau_bios.c b/drivers/gpu/drm/nouveau/nouveau_bios.c
index fc924b649195..e492919faf44 100644
--- a/drivers/gpu/drm/nouveau/nouveau_bios.c
+++ b/drivers/gpu/drm/nouveau/nouveau_bios.c
@@ -203,36 +203,26 @@ struct methods {
203 const bool rw; 203 const bool rw;
204}; 204};
205 205
206static struct methods nv04_methods[] = { 206static struct methods shadow_methods[] = {
207 { "PROM", load_vbios_prom, false },
208 { "PRAMIN", load_vbios_pramin, true },
209 { "PCIROM", load_vbios_pci, true },
210};
211
212static struct methods nv50_methods[] = {
213 { "ACPI", load_vbios_acpi, true },
214 { "PRAMIN", load_vbios_pramin, true }, 207 { "PRAMIN", load_vbios_pramin, true },
215 { "PROM", load_vbios_prom, false }, 208 { "PROM", load_vbios_prom, false },
216 { "PCIROM", load_vbios_pci, true }, 209 { "PCIROM", load_vbios_pci, true },
210 { "ACPI", load_vbios_acpi, true },
217}; 211};
218 212
219#define METHODCNT 3
220
221static bool NVShadowVBIOS(struct drm_device *dev, uint8_t *data) 213static bool NVShadowVBIOS(struct drm_device *dev, uint8_t *data)
222{ 214{
223 struct drm_nouveau_private *dev_priv = dev->dev_private; 215 const int nr_methods = ARRAY_SIZE(shadow_methods);
224 struct methods *methods; 216 struct methods *methods = shadow_methods;
225 int i;
226 int testscore = 3; 217 int testscore = 3;
227 int scores[METHODCNT]; 218 int scores[nr_methods], i;
228 219
229 if (nouveau_vbios) { 220 if (nouveau_vbios) {
230 methods = nv04_methods; 221 for (i = 0; i < nr_methods; i++)
231 for (i = 0; i < METHODCNT; i++)
232 if (!strcasecmp(nouveau_vbios, methods[i].desc)) 222 if (!strcasecmp(nouveau_vbios, methods[i].desc))
233 break; 223 break;
234 224
235 if (i < METHODCNT) { 225 if (i < nr_methods) {
236 NV_INFO(dev, "Attempting to use BIOS image from %s\n", 226 NV_INFO(dev, "Attempting to use BIOS image from %s\n",
237 methods[i].desc); 227 methods[i].desc);
238 228
@@ -244,12 +234,7 @@ static bool NVShadowVBIOS(struct drm_device *dev, uint8_t *data)
244 NV_ERROR(dev, "VBIOS source \'%s\' invalid\n", nouveau_vbios); 234 NV_ERROR(dev, "VBIOS source \'%s\' invalid\n", nouveau_vbios);
245 } 235 }
246 236
247 if (dev_priv->card_type < NV_50) 237 for (i = 0; i < nr_methods; i++) {
248 methods = nv04_methods;
249 else
250 methods = nv50_methods;
251
252 for (i = 0; i < METHODCNT; i++) {
253 NV_TRACE(dev, "Attempting to load BIOS image from %s\n", 238 NV_TRACE(dev, "Attempting to load BIOS image from %s\n",
254 methods[i].desc); 239 methods[i].desc);
255 data[0] = data[1] = 0; /* avoid reuse of previous image */ 240 data[0] = data[1] = 0; /* avoid reuse of previous image */
@@ -260,7 +245,7 @@ static bool NVShadowVBIOS(struct drm_device *dev, uint8_t *data)
260 } 245 }
261 246
262 while (--testscore > 0) { 247 while (--testscore > 0) {
263 for (i = 0; i < METHODCNT; i++) { 248 for (i = 0; i < nr_methods; i++) {
264 if (scores[i] == testscore) { 249 if (scores[i] == testscore) {
265 NV_TRACE(dev, "Using BIOS image from %s\n", 250 NV_TRACE(dev, "Using BIOS image from %s\n",
266 methods[i].desc); 251 methods[i].desc);
diff --git a/drivers/gpu/drm/nouveau/nouveau_fbcon.c b/drivers/gpu/drm/nouveau/nouveau_fbcon.c
index c9a4a0d2a115..257ea130ae13 100644
--- a/drivers/gpu/drm/nouveau/nouveau_fbcon.c
+++ b/drivers/gpu/drm/nouveau/nouveau_fbcon.c
@@ -387,7 +387,8 @@ int nouveau_fbcon_init(struct drm_device *dev)
387 dev_priv->nfbdev = nfbdev; 387 dev_priv->nfbdev = nfbdev;
388 nfbdev->helper.funcs = &nouveau_fbcon_helper_funcs; 388 nfbdev->helper.funcs = &nouveau_fbcon_helper_funcs;
389 389
390 ret = drm_fb_helper_init(dev, &nfbdev->helper, 2, 4); 390 ret = drm_fb_helper_init(dev, &nfbdev->helper,
391 nv_two_heads(dev) ? 2 : 1, 4);
391 if (ret) { 392 if (ret) {
392 kfree(nfbdev); 393 kfree(nfbdev);
393 return ret; 394 return ret;
diff --git a/drivers/gpu/drm/radeon/atombios_crtc.c b/drivers/gpu/drm/radeon/atombios_crtc.c
index f3f2827017ef..8c2d6478a221 100644
--- a/drivers/gpu/drm/radeon/atombios_crtc.c
+++ b/drivers/gpu/drm/radeon/atombios_crtc.c
@@ -498,7 +498,7 @@ static u32 atombios_adjust_pll(struct drm_crtc *crtc,
498 if ((rdev->family == CHIP_RS600) || 498 if ((rdev->family == CHIP_RS600) ||
499 (rdev->family == CHIP_RS690) || 499 (rdev->family == CHIP_RS690) ||
500 (rdev->family == CHIP_RS740)) 500 (rdev->family == CHIP_RS740))
501 pll->flags |= (RADEON_PLL_USE_FRAC_FB_DIV | 501 pll->flags |= (/*RADEON_PLL_USE_FRAC_FB_DIV |*/
502 RADEON_PLL_PREFER_CLOSEST_LOWER); 502 RADEON_PLL_PREFER_CLOSEST_LOWER);
503 503
504 if (ASIC_IS_DCE32(rdev) && mode->clock > 200000) /* range limits??? */ 504 if (ASIC_IS_DCE32(rdev) && mode->clock > 200000) /* range limits??? */
diff --git a/drivers/gpu/drm/radeon/evergreen.c b/drivers/gpu/drm/radeon/evergreen.c
index 4b6623df3b96..1caf625e472b 100644
--- a/drivers/gpu/drm/radeon/evergreen.c
+++ b/drivers/gpu/drm/radeon/evergreen.c
@@ -607,7 +607,7 @@ static void evergreen_mc_program(struct radeon_device *rdev)
607 WREG32(MC_VM_FB_LOCATION, tmp); 607 WREG32(MC_VM_FB_LOCATION, tmp);
608 WREG32(HDP_NONSURFACE_BASE, (rdev->mc.vram_start >> 8)); 608 WREG32(HDP_NONSURFACE_BASE, (rdev->mc.vram_start >> 8));
609 WREG32(HDP_NONSURFACE_INFO, (2 << 7)); 609 WREG32(HDP_NONSURFACE_INFO, (2 << 7));
610 WREG32(HDP_NONSURFACE_SIZE, (rdev->mc.mc_vram_size - 1) | 0x3FF); 610 WREG32(HDP_NONSURFACE_SIZE, 0x3FFFFFFF);
611 if (rdev->flags & RADEON_IS_AGP) { 611 if (rdev->flags & RADEON_IS_AGP) {
612 WREG32(MC_VM_AGP_TOP, rdev->mc.gtt_end >> 16); 612 WREG32(MC_VM_AGP_TOP, rdev->mc.gtt_end >> 16);
613 WREG32(MC_VM_AGP_BOT, rdev->mc.gtt_start >> 16); 613 WREG32(MC_VM_AGP_BOT, rdev->mc.gtt_start >> 16);
@@ -1222,11 +1222,11 @@ static void evergreen_gpu_init(struct radeon_device *rdev)
1222 ps_thread_count = 128; 1222 ps_thread_count = 128;
1223 1223
1224 sq_thread_resource_mgmt = NUM_PS_THREADS(ps_thread_count); 1224 sq_thread_resource_mgmt = NUM_PS_THREADS(ps_thread_count);
1225 sq_thread_resource_mgmt |= NUM_VS_THREADS(((rdev->config.evergreen.max_threads - ps_thread_count) / 6) / 8) * 8; 1225 sq_thread_resource_mgmt |= NUM_VS_THREADS((((rdev->config.evergreen.max_threads - ps_thread_count) / 6) / 8) * 8);
1226 sq_thread_resource_mgmt |= NUM_GS_THREADS(((rdev->config.evergreen.max_threads - ps_thread_count) / 6) / 8) * 8; 1226 sq_thread_resource_mgmt |= NUM_GS_THREADS((((rdev->config.evergreen.max_threads - ps_thread_count) / 6) / 8) * 8);
1227 sq_thread_resource_mgmt |= NUM_ES_THREADS(((rdev->config.evergreen.max_threads - ps_thread_count) / 6) / 8) * 8; 1227 sq_thread_resource_mgmt |= NUM_ES_THREADS((((rdev->config.evergreen.max_threads - ps_thread_count) / 6) / 8) * 8);
1228 sq_thread_resource_mgmt_2 = NUM_HS_THREADS(((rdev->config.evergreen.max_threads - ps_thread_count) / 6) / 8) * 8; 1228 sq_thread_resource_mgmt_2 = NUM_HS_THREADS((((rdev->config.evergreen.max_threads - ps_thread_count) / 6) / 8) * 8);
1229 sq_thread_resource_mgmt_2 |= NUM_LS_THREADS(((rdev->config.evergreen.max_threads - ps_thread_count) / 6) / 8) * 8; 1229 sq_thread_resource_mgmt_2 |= NUM_LS_THREADS((((rdev->config.evergreen.max_threads - ps_thread_count) / 6) / 8) * 8);
1230 1230
1231 sq_stack_resource_mgmt_1 = NUM_PS_STACK_ENTRIES((rdev->config.evergreen.max_stack_entries * 1) / 6); 1231 sq_stack_resource_mgmt_1 = NUM_PS_STACK_ENTRIES((rdev->config.evergreen.max_stack_entries * 1) / 6);
1232 sq_stack_resource_mgmt_1 |= NUM_VS_STACK_ENTRIES((rdev->config.evergreen.max_stack_entries * 1) / 6); 1232 sq_stack_resource_mgmt_1 |= NUM_VS_STACK_ENTRIES((rdev->config.evergreen.max_stack_entries * 1) / 6);
@@ -1260,6 +1260,9 @@ static void evergreen_gpu_init(struct radeon_device *rdev)
1260 WREG32(VGT_GS_VERTEX_REUSE, 16); 1260 WREG32(VGT_GS_VERTEX_REUSE, 16);
1261 WREG32(PA_SC_LINE_STIPPLE_STATE, 0); 1261 WREG32(PA_SC_LINE_STIPPLE_STATE, 0);
1262 1262
1263 WREG32(VGT_VERTEX_REUSE_BLOCK_CNTL, 14);
1264 WREG32(VGT_OUT_DEALLOC_CNTL, 16);
1265
1263 WREG32(CB_PERF_CTR0_SEL_0, 0); 1266 WREG32(CB_PERF_CTR0_SEL_0, 0);
1264 WREG32(CB_PERF_CTR0_SEL_1, 0); 1267 WREG32(CB_PERF_CTR0_SEL_1, 0);
1265 WREG32(CB_PERF_CTR1_SEL_0, 0); 1268 WREG32(CB_PERF_CTR1_SEL_0, 0);
@@ -1269,6 +1272,26 @@ static void evergreen_gpu_init(struct radeon_device *rdev)
1269 WREG32(CB_PERF_CTR3_SEL_0, 0); 1272 WREG32(CB_PERF_CTR3_SEL_0, 0);
1270 WREG32(CB_PERF_CTR3_SEL_1, 0); 1273 WREG32(CB_PERF_CTR3_SEL_1, 0);
1271 1274
1275 /* clear render buffer base addresses */
1276 WREG32(CB_COLOR0_BASE, 0);
1277 WREG32(CB_COLOR1_BASE, 0);
1278 WREG32(CB_COLOR2_BASE, 0);
1279 WREG32(CB_COLOR3_BASE, 0);
1280 WREG32(CB_COLOR4_BASE, 0);
1281 WREG32(CB_COLOR5_BASE, 0);
1282 WREG32(CB_COLOR6_BASE, 0);
1283 WREG32(CB_COLOR7_BASE, 0);
1284 WREG32(CB_COLOR8_BASE, 0);
1285 WREG32(CB_COLOR9_BASE, 0);
1286 WREG32(CB_COLOR10_BASE, 0);
1287 WREG32(CB_COLOR11_BASE, 0);
1288
1289 /* set the shader const cache sizes to 0 */
1290 for (i = SQ_ALU_CONST_BUFFER_SIZE_PS_0; i < 0x28200; i += 4)
1291 WREG32(i, 0);
1292 for (i = SQ_ALU_CONST_BUFFER_SIZE_HS_0; i < 0x29000; i += 4)
1293 WREG32(i, 0);
1294
1272 hdp_host_path_cntl = RREG32(HDP_HOST_PATH_CNTL); 1295 hdp_host_path_cntl = RREG32(HDP_HOST_PATH_CNTL);
1273 WREG32(HDP_HOST_PATH_CNTL, hdp_host_path_cntl); 1296 WREG32(HDP_HOST_PATH_CNTL, hdp_host_path_cntl);
1274 1297
diff --git a/drivers/gpu/drm/radeon/evergreen_cs.c b/drivers/gpu/drm/radeon/evergreen_cs.c
index 64516b950891..345a75a03c96 100644
--- a/drivers/gpu/drm/radeon/evergreen_cs.c
+++ b/drivers/gpu/drm/radeon/evergreen_cs.c
@@ -333,7 +333,6 @@ static int evergreen_cs_packet_parse_vline(struct radeon_cs_parser *p)
333 header = radeon_get_ib_value(p, h_idx); 333 header = radeon_get_ib_value(p, h_idx);
334 crtc_id = radeon_get_ib_value(p, h_idx + 2 + 7 + 1); 334 crtc_id = radeon_get_ib_value(p, h_idx + 2 + 7 + 1);
335 reg = CP_PACKET0_GET_REG(header); 335 reg = CP_PACKET0_GET_REG(header);
336 mutex_lock(&p->rdev->ddev->mode_config.mutex);
337 obj = drm_mode_object_find(p->rdev->ddev, crtc_id, DRM_MODE_OBJECT_CRTC); 336 obj = drm_mode_object_find(p->rdev->ddev, crtc_id, DRM_MODE_OBJECT_CRTC);
338 if (!obj) { 337 if (!obj) {
339 DRM_ERROR("cannot find crtc %d\n", crtc_id); 338 DRM_ERROR("cannot find crtc %d\n", crtc_id);
@@ -368,7 +367,6 @@ static int evergreen_cs_packet_parse_vline(struct radeon_cs_parser *p)
368 } 367 }
369 } 368 }
370out: 369out:
371 mutex_unlock(&p->rdev->ddev->mode_config.mutex);
372 return r; 370 return r;
373} 371}
374 372
@@ -1197,7 +1195,7 @@ static int evergreen_packet3_check(struct radeon_cs_parser *p,
1197 DRM_ERROR("bad SET_RESOURCE (tex)\n"); 1195 DRM_ERROR("bad SET_RESOURCE (tex)\n");
1198 return -EINVAL; 1196 return -EINVAL;
1199 } 1197 }
1200 ib[idx+1+(i*8)+3] += (u32)((reloc->lobj.gpu_offset >> 8) & 0xffffffff); 1198 ib[idx+1+(i*8)+2] += (u32)((reloc->lobj.gpu_offset >> 8) & 0xffffffff);
1201 if (reloc->lobj.tiling_flags & RADEON_TILING_MACRO) 1199 if (reloc->lobj.tiling_flags & RADEON_TILING_MACRO)
1202 ib[idx+1+(i*8)+1] |= TEX_ARRAY_MODE(ARRAY_2D_TILED_THIN1); 1200 ib[idx+1+(i*8)+1] |= TEX_ARRAY_MODE(ARRAY_2D_TILED_THIN1);
1203 else if (reloc->lobj.tiling_flags & RADEON_TILING_MICRO) 1201 else if (reloc->lobj.tiling_flags & RADEON_TILING_MICRO)
@@ -1209,7 +1207,7 @@ static int evergreen_packet3_check(struct radeon_cs_parser *p,
1209 DRM_ERROR("bad SET_RESOURCE (tex)\n"); 1207 DRM_ERROR("bad SET_RESOURCE (tex)\n");
1210 return -EINVAL; 1208 return -EINVAL;
1211 } 1209 }
1212 ib[idx+1+(i*8)+4] += (u32)((reloc->lobj.gpu_offset >> 8) & 0xffffffff); 1210 ib[idx+1+(i*8)+3] += (u32)((reloc->lobj.gpu_offset >> 8) & 0xffffffff);
1213 mipmap = reloc->robj; 1211 mipmap = reloc->robj;
1214 r = evergreen_check_texture_resource(p, idx+1+(i*8), 1212 r = evergreen_check_texture_resource(p, idx+1+(i*8),
1215 texture, mipmap); 1213 texture, mipmap);
diff --git a/drivers/gpu/drm/radeon/evergreend.h b/drivers/gpu/drm/radeon/evergreend.h
index 79683f6b4452..a1cd621780e2 100644
--- a/drivers/gpu/drm/radeon/evergreend.h
+++ b/drivers/gpu/drm/radeon/evergreend.h
@@ -713,6 +713,9 @@
713#define SQ_GSVS_RING_OFFSET_2 0x28930 713#define SQ_GSVS_RING_OFFSET_2 0x28930
714#define SQ_GSVS_RING_OFFSET_3 0x28934 714#define SQ_GSVS_RING_OFFSET_3 0x28934
715 715
716#define SQ_ALU_CONST_BUFFER_SIZE_PS_0 0x28140
717#define SQ_ALU_CONST_BUFFER_SIZE_HS_0 0x28f80
718
716#define SQ_ALU_CONST_CACHE_PS_0 0x28940 719#define SQ_ALU_CONST_CACHE_PS_0 0x28940
717#define SQ_ALU_CONST_CACHE_PS_1 0x28944 720#define SQ_ALU_CONST_CACHE_PS_1 0x28944
718#define SQ_ALU_CONST_CACHE_PS_2 0x28948 721#define SQ_ALU_CONST_CACHE_PS_2 0x28948
diff --git a/drivers/gpu/drm/radeon/r100.c b/drivers/gpu/drm/radeon/r100.c
index cf89aa2eb28c..a89a15ab524d 100644
--- a/drivers/gpu/drm/radeon/r100.c
+++ b/drivers/gpu/drm/radeon/r100.c
@@ -1230,7 +1230,6 @@ int r100_cs_packet_parse_vline(struct radeon_cs_parser *p)
1230 header = radeon_get_ib_value(p, h_idx); 1230 header = radeon_get_ib_value(p, h_idx);
1231 crtc_id = radeon_get_ib_value(p, h_idx + 5); 1231 crtc_id = radeon_get_ib_value(p, h_idx + 5);
1232 reg = CP_PACKET0_GET_REG(header); 1232 reg = CP_PACKET0_GET_REG(header);
1233 mutex_lock(&p->rdev->ddev->mode_config.mutex);
1234 obj = drm_mode_object_find(p->rdev->ddev, crtc_id, DRM_MODE_OBJECT_CRTC); 1233 obj = drm_mode_object_find(p->rdev->ddev, crtc_id, DRM_MODE_OBJECT_CRTC);
1235 if (!obj) { 1234 if (!obj) {
1236 DRM_ERROR("cannot find crtc %d\n", crtc_id); 1235 DRM_ERROR("cannot find crtc %d\n", crtc_id);
@@ -1264,7 +1263,6 @@ int r100_cs_packet_parse_vline(struct radeon_cs_parser *p)
1264 ib[h_idx + 3] |= RADEON_ENG_DISPLAY_SELECT_CRTC1; 1263 ib[h_idx + 3] |= RADEON_ENG_DISPLAY_SELECT_CRTC1;
1265 } 1264 }
1266out: 1265out:
1267 mutex_unlock(&p->rdev->ddev->mode_config.mutex);
1268 return r; 1266 return r;
1269} 1267}
1270 1268
@@ -1628,6 +1626,7 @@ static int r100_packet0_check(struct radeon_cs_parser *p,
1628 case RADEON_TXFORMAT_RGB332: 1626 case RADEON_TXFORMAT_RGB332:
1629 case RADEON_TXFORMAT_Y8: 1627 case RADEON_TXFORMAT_Y8:
1630 track->textures[i].cpp = 1; 1628 track->textures[i].cpp = 1;
1629 track->textures[i].compress_format = R100_TRACK_COMP_NONE;
1631 break; 1630 break;
1632 case RADEON_TXFORMAT_AI88: 1631 case RADEON_TXFORMAT_AI88:
1633 case RADEON_TXFORMAT_ARGB1555: 1632 case RADEON_TXFORMAT_ARGB1555:
@@ -1639,12 +1638,14 @@ static int r100_packet0_check(struct radeon_cs_parser *p,
1639 case RADEON_TXFORMAT_LDUDV655: 1638 case RADEON_TXFORMAT_LDUDV655:
1640 case RADEON_TXFORMAT_DUDV88: 1639 case RADEON_TXFORMAT_DUDV88:
1641 track->textures[i].cpp = 2; 1640 track->textures[i].cpp = 2;
1641 track->textures[i].compress_format = R100_TRACK_COMP_NONE;
1642 break; 1642 break;
1643 case RADEON_TXFORMAT_ARGB8888: 1643 case RADEON_TXFORMAT_ARGB8888:
1644 case RADEON_TXFORMAT_RGBA8888: 1644 case RADEON_TXFORMAT_RGBA8888:
1645 case RADEON_TXFORMAT_SHADOW32: 1645 case RADEON_TXFORMAT_SHADOW32:
1646 case RADEON_TXFORMAT_LDUDUV8888: 1646 case RADEON_TXFORMAT_LDUDUV8888:
1647 track->textures[i].cpp = 4; 1647 track->textures[i].cpp = 4;
1648 track->textures[i].compress_format = R100_TRACK_COMP_NONE;
1648 break; 1649 break;
1649 case RADEON_TXFORMAT_DXT1: 1650 case RADEON_TXFORMAT_DXT1:
1650 track->textures[i].cpp = 1; 1651 track->textures[i].cpp = 1;
@@ -2351,6 +2352,7 @@ void r100_mc_init(struct radeon_device *rdev)
2351 if (rdev->flags & RADEON_IS_IGP) 2352 if (rdev->flags & RADEON_IS_IGP)
2352 base = (RREG32(RADEON_NB_TOM) & 0xffff) << 16; 2353 base = (RREG32(RADEON_NB_TOM) & 0xffff) << 16;
2353 radeon_vram_location(rdev, &rdev->mc, base); 2354 radeon_vram_location(rdev, &rdev->mc, base);
2355 rdev->mc.gtt_base_align = 0;
2354 if (!(rdev->flags & RADEON_IS_AGP)) 2356 if (!(rdev->flags & RADEON_IS_AGP))
2355 radeon_gtt_location(rdev, &rdev->mc); 2357 radeon_gtt_location(rdev, &rdev->mc);
2356 radeon_update_bandwidth_info(rdev); 2358 radeon_update_bandwidth_info(rdev);
@@ -2604,12 +2606,6 @@ int r100_set_surface_reg(struct radeon_device *rdev, int reg,
2604 int surf_index = reg * 16; 2606 int surf_index = reg * 16;
2605 int flags = 0; 2607 int flags = 0;
2606 2608
2607 /* r100/r200 divide by 16 */
2608 if (rdev->family < CHIP_R300)
2609 flags = pitch / 16;
2610 else
2611 flags = pitch / 8;
2612
2613 if (rdev->family <= CHIP_RS200) { 2609 if (rdev->family <= CHIP_RS200) {
2614 if ((tiling_flags & (RADEON_TILING_MACRO|RADEON_TILING_MICRO)) 2610 if ((tiling_flags & (RADEON_TILING_MACRO|RADEON_TILING_MICRO))
2615 == (RADEON_TILING_MACRO|RADEON_TILING_MICRO)) 2611 == (RADEON_TILING_MACRO|RADEON_TILING_MICRO))
@@ -2633,6 +2629,20 @@ int r100_set_surface_reg(struct radeon_device *rdev, int reg,
2633 if (tiling_flags & RADEON_TILING_SWAP_32BIT) 2629 if (tiling_flags & RADEON_TILING_SWAP_32BIT)
2634 flags |= RADEON_SURF_AP0_SWP_32BPP | RADEON_SURF_AP1_SWP_32BPP; 2630 flags |= RADEON_SURF_AP0_SWP_32BPP | RADEON_SURF_AP1_SWP_32BPP;
2635 2631
2632 /* when we aren't tiling the pitch seems to needs to be furtherdivided down. - tested on power5 + rn50 server */
2633 if (tiling_flags & (RADEON_TILING_SWAP_16BIT | RADEON_TILING_SWAP_32BIT)) {
2634 if (!(tiling_flags & (RADEON_TILING_MACRO | RADEON_TILING_MICRO)))
2635 if (ASIC_IS_RN50(rdev))
2636 pitch /= 16;
2637 }
2638
2639 /* r100/r200 divide by 16 */
2640 if (rdev->family < CHIP_R300)
2641 flags |= pitch / 16;
2642 else
2643 flags |= pitch / 8;
2644
2645
2636 DRM_DEBUG("writing surface %d %d %x %x\n", reg, flags, offset, offset+obj_size-1); 2646 DRM_DEBUG("writing surface %d %d %x %x\n", reg, flags, offset, offset+obj_size-1);
2637 WREG32(RADEON_SURFACE0_INFO + surf_index, flags); 2647 WREG32(RADEON_SURFACE0_INFO + surf_index, flags);
2638 WREG32(RADEON_SURFACE0_LOWER_BOUND + surf_index, offset); 2648 WREG32(RADEON_SURFACE0_LOWER_BOUND + surf_index, offset);
@@ -3147,33 +3157,6 @@ static inline void r100_cs_track_texture_print(struct r100_cs_track_texture *t)
3147 DRM_ERROR("compress format %d\n", t->compress_format); 3157 DRM_ERROR("compress format %d\n", t->compress_format);
3148} 3158}
3149 3159
3150static int r100_cs_track_cube(struct radeon_device *rdev,
3151 struct r100_cs_track *track, unsigned idx)
3152{
3153 unsigned face, w, h;
3154 struct radeon_bo *cube_robj;
3155 unsigned long size;
3156
3157 for (face = 0; face < 5; face++) {
3158 cube_robj = track->textures[idx].cube_info[face].robj;
3159 w = track->textures[idx].cube_info[face].width;
3160 h = track->textures[idx].cube_info[face].height;
3161
3162 size = w * h;
3163 size *= track->textures[idx].cpp;
3164
3165 size += track->textures[idx].cube_info[face].offset;
3166
3167 if (size > radeon_bo_size(cube_robj)) {
3168 DRM_ERROR("Cube texture offset greater than object size %lu %lu\n",
3169 size, radeon_bo_size(cube_robj));
3170 r100_cs_track_texture_print(&track->textures[idx]);
3171 return -1;
3172 }
3173 }
3174 return 0;
3175}
3176
3177static int r100_track_compress_size(int compress_format, int w, int h) 3160static int r100_track_compress_size(int compress_format, int w, int h)
3178{ 3161{
3179 int block_width, block_height, block_bytes; 3162 int block_width, block_height, block_bytes;
@@ -3204,6 +3187,37 @@ static int r100_track_compress_size(int compress_format, int w, int h)
3204 return sz; 3187 return sz;
3205} 3188}
3206 3189
3190static int r100_cs_track_cube(struct radeon_device *rdev,
3191 struct r100_cs_track *track, unsigned idx)
3192{
3193 unsigned face, w, h;
3194 struct radeon_bo *cube_robj;
3195 unsigned long size;
3196 unsigned compress_format = track->textures[idx].compress_format;
3197
3198 for (face = 0; face < 5; face++) {
3199 cube_robj = track->textures[idx].cube_info[face].robj;
3200 w = track->textures[idx].cube_info[face].width;
3201 h = track->textures[idx].cube_info[face].height;
3202
3203 if (compress_format) {
3204 size = r100_track_compress_size(compress_format, w, h);
3205 } else
3206 size = w * h;
3207 size *= track->textures[idx].cpp;
3208
3209 size += track->textures[idx].cube_info[face].offset;
3210
3211 if (size > radeon_bo_size(cube_robj)) {
3212 DRM_ERROR("Cube texture offset greater than object size %lu %lu\n",
3213 size, radeon_bo_size(cube_robj));
3214 r100_cs_track_texture_print(&track->textures[idx]);
3215 return -1;
3216 }
3217 }
3218 return 0;
3219}
3220
3207static int r100_cs_track_texture_check(struct radeon_device *rdev, 3221static int r100_cs_track_texture_check(struct radeon_device *rdev,
3208 struct r100_cs_track *track) 3222 struct r100_cs_track *track)
3209{ 3223{
diff --git a/drivers/gpu/drm/radeon/r200.c b/drivers/gpu/drm/radeon/r200.c
index 85617c311212..0266d72e0a4c 100644
--- a/drivers/gpu/drm/radeon/r200.c
+++ b/drivers/gpu/drm/radeon/r200.c
@@ -415,6 +415,8 @@ int r200_packet0_check(struct radeon_cs_parser *p,
415 /* 2D, 3D, CUBE */ 415 /* 2D, 3D, CUBE */
416 switch (tmp) { 416 switch (tmp) {
417 case 0: 417 case 0:
418 case 3:
419 case 4:
418 case 5: 420 case 5:
419 case 6: 421 case 6:
420 case 7: 422 case 7:
@@ -450,6 +452,7 @@ int r200_packet0_check(struct radeon_cs_parser *p,
450 case R200_TXFORMAT_RGB332: 452 case R200_TXFORMAT_RGB332:
451 case R200_TXFORMAT_Y8: 453 case R200_TXFORMAT_Y8:
452 track->textures[i].cpp = 1; 454 track->textures[i].cpp = 1;
455 track->textures[i].compress_format = R100_TRACK_COMP_NONE;
453 break; 456 break;
454 case R200_TXFORMAT_AI88: 457 case R200_TXFORMAT_AI88:
455 case R200_TXFORMAT_ARGB1555: 458 case R200_TXFORMAT_ARGB1555:
@@ -461,6 +464,7 @@ int r200_packet0_check(struct radeon_cs_parser *p,
461 case R200_TXFORMAT_DVDU88: 464 case R200_TXFORMAT_DVDU88:
462 case R200_TXFORMAT_AVYU4444: 465 case R200_TXFORMAT_AVYU4444:
463 track->textures[i].cpp = 2; 466 track->textures[i].cpp = 2;
467 track->textures[i].compress_format = R100_TRACK_COMP_NONE;
464 break; 468 break;
465 case R200_TXFORMAT_ARGB8888: 469 case R200_TXFORMAT_ARGB8888:
466 case R200_TXFORMAT_RGBA8888: 470 case R200_TXFORMAT_RGBA8888:
@@ -468,6 +472,7 @@ int r200_packet0_check(struct radeon_cs_parser *p,
468 case R200_TXFORMAT_BGR111110: 472 case R200_TXFORMAT_BGR111110:
469 case R200_TXFORMAT_LDVDU8888: 473 case R200_TXFORMAT_LDVDU8888:
470 track->textures[i].cpp = 4; 474 track->textures[i].cpp = 4;
475 track->textures[i].compress_format = R100_TRACK_COMP_NONE;
471 break; 476 break;
472 case R200_TXFORMAT_DXT1: 477 case R200_TXFORMAT_DXT1:
473 track->textures[i].cpp = 1; 478 track->textures[i].cpp = 1;
diff --git a/drivers/gpu/drm/radeon/r300.c b/drivers/gpu/drm/radeon/r300.c
index b2f9efe2897c..19a7ef7ee344 100644
--- a/drivers/gpu/drm/radeon/r300.c
+++ b/drivers/gpu/drm/radeon/r300.c
@@ -481,6 +481,7 @@ void r300_mc_init(struct radeon_device *rdev)
481 if (rdev->flags & RADEON_IS_IGP) 481 if (rdev->flags & RADEON_IS_IGP)
482 base = (RREG32(RADEON_NB_TOM) & 0xffff) << 16; 482 base = (RREG32(RADEON_NB_TOM) & 0xffff) << 16;
483 radeon_vram_location(rdev, &rdev->mc, base); 483 radeon_vram_location(rdev, &rdev->mc, base);
484 rdev->mc.gtt_base_align = 0;
484 if (!(rdev->flags & RADEON_IS_AGP)) 485 if (!(rdev->flags & RADEON_IS_AGP))
485 radeon_gtt_location(rdev, &rdev->mc); 486 radeon_gtt_location(rdev, &rdev->mc);
486 radeon_update_bandwidth_info(rdev); 487 radeon_update_bandwidth_info(rdev);
@@ -881,6 +882,7 @@ static int r300_packet0_check(struct radeon_cs_parser *p,
881 case R300_TX_FORMAT_Y4X4: 882 case R300_TX_FORMAT_Y4X4:
882 case R300_TX_FORMAT_Z3Y3X2: 883 case R300_TX_FORMAT_Z3Y3X2:
883 track->textures[i].cpp = 1; 884 track->textures[i].cpp = 1;
885 track->textures[i].compress_format = R100_TRACK_COMP_NONE;
884 break; 886 break;
885 case R300_TX_FORMAT_X16: 887 case R300_TX_FORMAT_X16:
886 case R300_TX_FORMAT_Y8X8: 888 case R300_TX_FORMAT_Y8X8:
@@ -892,6 +894,7 @@ static int r300_packet0_check(struct radeon_cs_parser *p,
892 case R300_TX_FORMAT_B8G8_B8G8: 894 case R300_TX_FORMAT_B8G8_B8G8:
893 case R300_TX_FORMAT_G8R8_G8B8: 895 case R300_TX_FORMAT_G8R8_G8B8:
894 track->textures[i].cpp = 2; 896 track->textures[i].cpp = 2;
897 track->textures[i].compress_format = R100_TRACK_COMP_NONE;
895 break; 898 break;
896 case R300_TX_FORMAT_Y16X16: 899 case R300_TX_FORMAT_Y16X16:
897 case R300_TX_FORMAT_Z11Y11X10: 900 case R300_TX_FORMAT_Z11Y11X10:
@@ -902,14 +905,17 @@ static int r300_packet0_check(struct radeon_cs_parser *p,
902 case R300_TX_FORMAT_FL_I32: 905 case R300_TX_FORMAT_FL_I32:
903 case 0x1e: 906 case 0x1e:
904 track->textures[i].cpp = 4; 907 track->textures[i].cpp = 4;
908 track->textures[i].compress_format = R100_TRACK_COMP_NONE;
905 break; 909 break;
906 case R300_TX_FORMAT_W16Z16Y16X16: 910 case R300_TX_FORMAT_W16Z16Y16X16:
907 case R300_TX_FORMAT_FL_R16G16B16A16: 911 case R300_TX_FORMAT_FL_R16G16B16A16:
908 case R300_TX_FORMAT_FL_I32A32: 912 case R300_TX_FORMAT_FL_I32A32:
909 track->textures[i].cpp = 8; 913 track->textures[i].cpp = 8;
914 track->textures[i].compress_format = R100_TRACK_COMP_NONE;
910 break; 915 break;
911 case R300_TX_FORMAT_FL_R32G32B32A32: 916 case R300_TX_FORMAT_FL_R32G32B32A32:
912 track->textures[i].cpp = 16; 917 track->textures[i].cpp = 16;
918 track->textures[i].compress_format = R100_TRACK_COMP_NONE;
913 break; 919 break;
914 case R300_TX_FORMAT_DXT1: 920 case R300_TX_FORMAT_DXT1:
915 track->textures[i].cpp = 1; 921 track->textures[i].cpp = 1;
@@ -1171,6 +1177,8 @@ int r300_cs_parse(struct radeon_cs_parser *p)
1171 int r; 1177 int r;
1172 1178
1173 track = kzalloc(sizeof(*track), GFP_KERNEL); 1179 track = kzalloc(sizeof(*track), GFP_KERNEL);
1180 if (track == NULL)
1181 return -ENOMEM;
1174 r100_cs_track_clear(p->rdev, track); 1182 r100_cs_track_clear(p->rdev, track);
1175 p->track = track; 1183 p->track = track;
1176 do { 1184 do {
diff --git a/drivers/gpu/drm/radeon/r520.c b/drivers/gpu/drm/radeon/r520.c
index 34330df28483..694af7cc23ac 100644
--- a/drivers/gpu/drm/radeon/r520.c
+++ b/drivers/gpu/drm/radeon/r520.c
@@ -125,6 +125,7 @@ void r520_mc_init(struct radeon_device *rdev)
125 r520_vram_get_type(rdev); 125 r520_vram_get_type(rdev);
126 r100_vram_init_sizes(rdev); 126 r100_vram_init_sizes(rdev);
127 radeon_vram_location(rdev, &rdev->mc, 0); 127 radeon_vram_location(rdev, &rdev->mc, 0);
128 rdev->mc.gtt_base_align = 0;
128 if (!(rdev->flags & RADEON_IS_AGP)) 129 if (!(rdev->flags & RADEON_IS_AGP))
129 radeon_gtt_location(rdev, &rdev->mc); 130 radeon_gtt_location(rdev, &rdev->mc);
130 radeon_update_bandwidth_info(rdev); 131 radeon_update_bandwidth_info(rdev);
diff --git a/drivers/gpu/drm/radeon/r600.c b/drivers/gpu/drm/radeon/r600.c
index 0e91871f45be..e100f69faeec 100644
--- a/drivers/gpu/drm/radeon/r600.c
+++ b/drivers/gpu/drm/radeon/r600.c
@@ -130,9 +130,14 @@ void r600_pm_get_dynpm_state(struct radeon_device *rdev)
130 break; 130 break;
131 } 131 }
132 } 132 }
133 } else 133 } else {
134 rdev->pm.requested_power_state_index = 134 if (rdev->pm.current_power_state_index == 0)
135 rdev->pm.current_power_state_index - 1; 135 rdev->pm.requested_power_state_index =
136 rdev->pm.num_power_states - 1;
137 else
138 rdev->pm.requested_power_state_index =
139 rdev->pm.current_power_state_index - 1;
140 }
136 } 141 }
137 rdev->pm.requested_clock_mode_index = 0; 142 rdev->pm.requested_clock_mode_index = 0;
138 /* don't use the power state if crtcs are active and no display flag is set */ 143 /* don't use the power state if crtcs are active and no display flag is set */
@@ -1097,7 +1102,7 @@ static void r600_mc_program(struct radeon_device *rdev)
1097 WREG32(MC_VM_FB_LOCATION, tmp); 1102 WREG32(MC_VM_FB_LOCATION, tmp);
1098 WREG32(HDP_NONSURFACE_BASE, (rdev->mc.vram_start >> 8)); 1103 WREG32(HDP_NONSURFACE_BASE, (rdev->mc.vram_start >> 8));
1099 WREG32(HDP_NONSURFACE_INFO, (2 << 7)); 1104 WREG32(HDP_NONSURFACE_INFO, (2 << 7));
1100 WREG32(HDP_NONSURFACE_SIZE, rdev->mc.mc_vram_size | 0x3FF); 1105 WREG32(HDP_NONSURFACE_SIZE, 0x3FFFFFFF);
1101 if (rdev->flags & RADEON_IS_AGP) { 1106 if (rdev->flags & RADEON_IS_AGP) {
1102 WREG32(MC_VM_AGP_TOP, rdev->mc.gtt_end >> 22); 1107 WREG32(MC_VM_AGP_TOP, rdev->mc.gtt_end >> 22);
1103 WREG32(MC_VM_AGP_BOT, rdev->mc.gtt_start >> 22); 1108 WREG32(MC_VM_AGP_BOT, rdev->mc.gtt_start >> 22);
@@ -1174,6 +1179,7 @@ void r600_vram_gtt_location(struct radeon_device *rdev, struct radeon_mc *mc)
1174 if (rdev->flags & RADEON_IS_IGP) 1179 if (rdev->flags & RADEON_IS_IGP)
1175 base = (RREG32(MC_VM_FB_LOCATION) & 0xFFFF) << 24; 1180 base = (RREG32(MC_VM_FB_LOCATION) & 0xFFFF) << 24;
1176 radeon_vram_location(rdev, &rdev->mc, base); 1181 radeon_vram_location(rdev, &rdev->mc, base);
1182 rdev->mc.gtt_base_align = 0;
1177 radeon_gtt_location(rdev, mc); 1183 radeon_gtt_location(rdev, mc);
1178 } 1184 }
1179} 1185}
@@ -1219,8 +1225,10 @@ int r600_mc_init(struct radeon_device *rdev)
1219 rdev->mc.visible_vram_size = rdev->mc.aper_size; 1225 rdev->mc.visible_vram_size = rdev->mc.aper_size;
1220 r600_vram_gtt_location(rdev, &rdev->mc); 1226 r600_vram_gtt_location(rdev, &rdev->mc);
1221 1227
1222 if (rdev->flags & RADEON_IS_IGP) 1228 if (rdev->flags & RADEON_IS_IGP) {
1229 rs690_pm_info(rdev);
1223 rdev->mc.igp_sideport_enabled = radeon_atombios_sideport_present(rdev); 1230 rdev->mc.igp_sideport_enabled = radeon_atombios_sideport_present(rdev);
1231 }
1224 radeon_update_bandwidth_info(rdev); 1232 radeon_update_bandwidth_info(rdev);
1225 return 0; 1233 return 0;
1226} 1234}
diff --git a/drivers/gpu/drm/radeon/r600_blit.c b/drivers/gpu/drm/radeon/r600_blit.c
index f4fb88ece2bb..ca5c29f70779 100644
--- a/drivers/gpu/drm/radeon/r600_blit.c
+++ b/drivers/gpu/drm/radeon/r600_blit.c
@@ -538,9 +538,12 @@ int
538r600_prepare_blit_copy(struct drm_device *dev, struct drm_file *file_priv) 538r600_prepare_blit_copy(struct drm_device *dev, struct drm_file *file_priv)
539{ 539{
540 drm_radeon_private_t *dev_priv = dev->dev_private; 540 drm_radeon_private_t *dev_priv = dev->dev_private;
541 int ret;
541 DRM_DEBUG("\n"); 542 DRM_DEBUG("\n");
542 543
543 r600_nomm_get_vb(dev); 544 ret = r600_nomm_get_vb(dev);
545 if (ret)
546 return ret;
544 547
545 dev_priv->blit_vb->file_priv = file_priv; 548 dev_priv->blit_vb->file_priv = file_priv;
546 549
diff --git a/drivers/gpu/drm/radeon/r600_cs.c b/drivers/gpu/drm/radeon/r600_cs.c
index c39c1bc13016..144c32d37136 100644
--- a/drivers/gpu/drm/radeon/r600_cs.c
+++ b/drivers/gpu/drm/radeon/r600_cs.c
@@ -585,7 +585,7 @@ static int r600_cs_packet_parse_vline(struct radeon_cs_parser *p)
585 header = radeon_get_ib_value(p, h_idx); 585 header = radeon_get_ib_value(p, h_idx);
586 crtc_id = radeon_get_ib_value(p, h_idx + 2 + 7 + 1); 586 crtc_id = radeon_get_ib_value(p, h_idx + 2 + 7 + 1);
587 reg = CP_PACKET0_GET_REG(header); 587 reg = CP_PACKET0_GET_REG(header);
588 mutex_lock(&p->rdev->ddev->mode_config.mutex); 588
589 obj = drm_mode_object_find(p->rdev->ddev, crtc_id, DRM_MODE_OBJECT_CRTC); 589 obj = drm_mode_object_find(p->rdev->ddev, crtc_id, DRM_MODE_OBJECT_CRTC);
590 if (!obj) { 590 if (!obj) {
591 DRM_ERROR("cannot find crtc %d\n", crtc_id); 591 DRM_ERROR("cannot find crtc %d\n", crtc_id);
@@ -620,7 +620,6 @@ static int r600_cs_packet_parse_vline(struct radeon_cs_parser *p)
620 ib[h_idx + 4] = AVIVO_D2MODE_VLINE_STATUS >> 2; 620 ib[h_idx + 4] = AVIVO_D2MODE_VLINE_STATUS >> 2;
621 } 621 }
622out: 622out:
623 mutex_unlock(&p->rdev->ddev->mode_config.mutex);
624 return r; 623 return r;
625} 624}
626 625
diff --git a/drivers/gpu/drm/radeon/radeon.h b/drivers/gpu/drm/radeon/radeon.h
index 8e1d44ca26ec..2f94dc66c183 100644
--- a/drivers/gpu/drm/radeon/radeon.h
+++ b/drivers/gpu/drm/radeon/radeon.h
@@ -177,6 +177,7 @@ void radeon_pm_resume(struct radeon_device *rdev);
177void radeon_combios_get_power_modes(struct radeon_device *rdev); 177void radeon_combios_get_power_modes(struct radeon_device *rdev);
178void radeon_atombios_get_power_modes(struct radeon_device *rdev); 178void radeon_atombios_get_power_modes(struct radeon_device *rdev);
179void radeon_atom_set_voltage(struct radeon_device *rdev, u16 level); 179void radeon_atom_set_voltage(struct radeon_device *rdev, u16 level);
180void rs690_pm_info(struct radeon_device *rdev);
180 181
181/* 182/*
182 * Fences. 183 * Fences.
@@ -350,6 +351,7 @@ struct radeon_mc {
350 int vram_mtrr; 351 int vram_mtrr;
351 bool vram_is_ddr; 352 bool vram_is_ddr;
352 bool igp_sideport_enabled; 353 bool igp_sideport_enabled;
354 u64 gtt_base_align;
353}; 355};
354 356
355bool radeon_combios_sideport_present(struct radeon_device *rdev); 357bool radeon_combios_sideport_present(struct radeon_device *rdev);
@@ -619,7 +621,8 @@ enum radeon_dynpm_state {
619 DYNPM_STATE_DISABLED, 621 DYNPM_STATE_DISABLED,
620 DYNPM_STATE_MINIMUM, 622 DYNPM_STATE_MINIMUM,
621 DYNPM_STATE_PAUSED, 623 DYNPM_STATE_PAUSED,
622 DYNPM_STATE_ACTIVE 624 DYNPM_STATE_ACTIVE,
625 DYNPM_STATE_SUSPENDED,
623}; 626};
624enum radeon_dynpm_action { 627enum radeon_dynpm_action {
625 DYNPM_ACTION_NONE, 628 DYNPM_ACTION_NONE,
diff --git a/drivers/gpu/drm/radeon/radeon_asic.c b/drivers/gpu/drm/radeon/radeon_asic.c
index 87f7e2cc52d4..646f96f97c77 100644
--- a/drivers/gpu/drm/radeon/radeon_asic.c
+++ b/drivers/gpu/drm/radeon/radeon_asic.c
@@ -780,6 +780,13 @@ int radeon_asic_init(struct radeon_device *rdev)
780 case CHIP_R423: 780 case CHIP_R423:
781 case CHIP_RV410: 781 case CHIP_RV410:
782 rdev->asic = &r420_asic; 782 rdev->asic = &r420_asic;
783 /* handle macs */
784 if (rdev->bios == NULL) {
785 rdev->asic->get_engine_clock = &radeon_legacy_get_engine_clock;
786 rdev->asic->set_engine_clock = &radeon_legacy_set_engine_clock;
787 rdev->asic->get_memory_clock = &radeon_legacy_get_memory_clock;
788 rdev->asic->set_memory_clock = NULL;
789 }
783 break; 790 break;
784 case CHIP_RS400: 791 case CHIP_RS400:
785 case CHIP_RS480: 792 case CHIP_RS480:
diff --git a/drivers/gpu/drm/radeon/radeon_atombios.c b/drivers/gpu/drm/radeon/radeon_atombios.c
index 99bd8a9c56b3..10673ae59cfa 100644
--- a/drivers/gpu/drm/radeon/radeon_atombios.c
+++ b/drivers/gpu/drm/radeon/radeon_atombios.c
@@ -280,6 +280,15 @@ static bool radeon_atom_apply_quirks(struct drm_device *dev,
280 } 280 }
281 } 281 }
282 282
283 /* ASUS HD 3600 board lists the DVI port as HDMI */
284 if ((dev->pdev->device == 0x9598) &&
285 (dev->pdev->subsystem_vendor == 0x1043) &&
286 (dev->pdev->subsystem_device == 0x01e4)) {
287 if (*connector_type == DRM_MODE_CONNECTOR_HDMIA) {
288 *connector_type = DRM_MODE_CONNECTOR_DVII;
289 }
290 }
291
283 /* ASUS HD 3450 board lists the DVI port as HDMI */ 292 /* ASUS HD 3450 board lists the DVI port as HDMI */
284 if ((dev->pdev->device == 0x95C5) && 293 if ((dev->pdev->device == 0x95C5) &&
285 (dev->pdev->subsystem_vendor == 0x1043) && 294 (dev->pdev->subsystem_vendor == 0x1043) &&
@@ -1029,8 +1038,15 @@ bool radeon_atombios_sideport_present(struct radeon_device *rdev)
1029 data_offset); 1038 data_offset);
1030 switch (crev) { 1039 switch (crev) {
1031 case 1: 1040 case 1:
1032 if (igp_info->info.ucMemoryType & 0xf0) 1041 /* AMD IGPS */
1033 return true; 1042 if ((rdev->family == CHIP_RS690) ||
1043 (rdev->family == CHIP_RS740)) {
1044 if (igp_info->info.ulBootUpMemoryClock)
1045 return true;
1046 } else {
1047 if (igp_info->info.ucMemoryType & 0xf0)
1048 return true;
1049 }
1034 break; 1050 break;
1035 case 2: 1051 case 2:
1036 if (igp_info->info_2.ucMemoryType & 0x0f) 1052 if (igp_info->info_2.ucMemoryType & 0x0f)
diff --git a/drivers/gpu/drm/radeon/radeon_bios.c b/drivers/gpu/drm/radeon/radeon_bios.c
index fbba938f8048..2c9213739999 100644
--- a/drivers/gpu/drm/radeon/radeon_bios.c
+++ b/drivers/gpu/drm/radeon/radeon_bios.c
@@ -48,6 +48,10 @@ static bool igp_read_bios_from_vram(struct radeon_device *rdev)
48 resource_size_t vram_base; 48 resource_size_t vram_base;
49 resource_size_t size = 256 * 1024; /* ??? */ 49 resource_size_t size = 256 * 1024; /* ??? */
50 50
51 if (!(rdev->flags & RADEON_IS_IGP))
52 if (!radeon_card_posted(rdev))
53 return false;
54
51 rdev->bios = NULL; 55 rdev->bios = NULL;
52 vram_base = drm_get_resource_start(rdev->ddev, 0); 56 vram_base = drm_get_resource_start(rdev->ddev, 0);
53 bios = ioremap(vram_base, size); 57 bios = ioremap(vram_base, size);
diff --git a/drivers/gpu/drm/radeon/radeon_combios.c b/drivers/gpu/drm/radeon/radeon_combios.c
index 1bee2f9e24a5..2417d7b06fdb 100644
--- a/drivers/gpu/drm/radeon/radeon_combios.c
+++ b/drivers/gpu/drm/radeon/radeon_combios.c
@@ -1411,6 +1411,11 @@ bool radeon_get_legacy_connector_info_from_table(struct drm_device *dev)
1411 rdev->mode_info.connector_table = CT_IMAC_G5_ISIGHT; 1411 rdev->mode_info.connector_table = CT_IMAC_G5_ISIGHT;
1412 } else 1412 } else
1413#endif /* CONFIG_PPC_PMAC */ 1413#endif /* CONFIG_PPC_PMAC */
1414#ifdef CONFIG_PPC64
1415 if (ASIC_IS_RN50(rdev))
1416 rdev->mode_info.connector_table = CT_RN50_POWER;
1417 else
1418#endif
1414 rdev->mode_info.connector_table = CT_GENERIC; 1419 rdev->mode_info.connector_table = CT_GENERIC;
1415 } 1420 }
1416 1421
@@ -1853,6 +1858,33 @@ bool radeon_get_legacy_connector_info_from_table(struct drm_device *dev)
1853 CONNECTOR_OBJECT_ID_SVIDEO, 1858 CONNECTOR_OBJECT_ID_SVIDEO,
1854 &hpd); 1859 &hpd);
1855 break; 1860 break;
1861 case CT_RN50_POWER:
1862 DRM_INFO("Connector Table: %d (rn50-power)\n",
1863 rdev->mode_info.connector_table);
1864 /* VGA - primary dac */
1865 ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_VGA_DDC);
1866 hpd.hpd = RADEON_HPD_NONE;
1867 radeon_add_legacy_encoder(dev,
1868 radeon_get_encoder_id(dev,
1869 ATOM_DEVICE_CRT1_SUPPORT,
1870 1),
1871 ATOM_DEVICE_CRT1_SUPPORT);
1872 radeon_add_legacy_connector(dev, 0, ATOM_DEVICE_CRT1_SUPPORT,
1873 DRM_MODE_CONNECTOR_VGA, &ddc_i2c,
1874 CONNECTOR_OBJECT_ID_VGA,
1875 &hpd);
1876 ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_CRT2_DDC);
1877 hpd.hpd = RADEON_HPD_NONE;
1878 radeon_add_legacy_encoder(dev,
1879 radeon_get_encoder_id(dev,
1880 ATOM_DEVICE_CRT2_SUPPORT,
1881 2),
1882 ATOM_DEVICE_CRT2_SUPPORT);
1883 radeon_add_legacy_connector(dev, 1, ATOM_DEVICE_CRT2_SUPPORT,
1884 DRM_MODE_CONNECTOR_VGA, &ddc_i2c,
1885 CONNECTOR_OBJECT_ID_VGA,
1886 &hpd);
1887 break;
1856 default: 1888 default:
1857 DRM_INFO("Connector table: %d (invalid)\n", 1889 DRM_INFO("Connector table: %d (invalid)\n",
1858 rdev->mode_info.connector_table); 1890 rdev->mode_info.connector_table);
@@ -1906,15 +1938,6 @@ static bool radeon_apply_legacy_quirks(struct drm_device *dev,
1906 return false; 1938 return false;
1907 } 1939 }
1908 1940
1909 /* Some RV100 cards with 2 VGA ports show up with DVI+VGA */
1910 if (dev->pdev->device == 0x5159 &&
1911 dev->pdev->subsystem_vendor == 0x1002 &&
1912 dev->pdev->subsystem_device == 0x013a) {
1913 if (*legacy_connector == CONNECTOR_DVI_I_LEGACY)
1914 *legacy_connector = CONNECTOR_CRT_LEGACY;
1915
1916 }
1917
1918 /* X300 card with extra non-existent DVI port */ 1941 /* X300 card with extra non-existent DVI port */
1919 if (dev->pdev->device == 0x5B60 && 1942 if (dev->pdev->device == 0x5B60 &&
1920 dev->pdev->subsystem_vendor == 0x17af && 1943 dev->pdev->subsystem_vendor == 0x17af &&
@@ -3019,6 +3042,22 @@ void radeon_combios_asic_init(struct drm_device *dev)
3019 combios_write_ram_size(dev); 3042 combios_write_ram_size(dev);
3020 } 3043 }
3021 3044
3045 /* quirk for rs4xx HP nx6125 laptop to make it resume
3046 * - it hangs on resume inside the dynclk 1 table.
3047 */
3048 if (rdev->family == CHIP_RS480 &&
3049 rdev->pdev->subsystem_vendor == 0x103c &&
3050 rdev->pdev->subsystem_device == 0x308b)
3051 return;
3052
3053 /* quirk for rs4xx HP dv5000 laptop to make it resume
3054 * - it hangs on resume inside the dynclk 1 table.
3055 */
3056 if (rdev->family == CHIP_RS480 &&
3057 rdev->pdev->subsystem_vendor == 0x103c &&
3058 rdev->pdev->subsystem_device == 0x30a4)
3059 return;
3060
3022 /* DYN CLK 1 */ 3061 /* DYN CLK 1 */
3023 table = combios_get_table_offset(dev, COMBIOS_DYN_CLK_1_TABLE); 3062 table = combios_get_table_offset(dev, COMBIOS_DYN_CLK_1_TABLE);
3024 if (table) 3063 if (table)
diff --git a/drivers/gpu/drm/radeon/radeon_connectors.c b/drivers/gpu/drm/radeon/radeon_connectors.c
index 0c7ccc6961a3..adccbc2c202c 100644
--- a/drivers/gpu/drm/radeon/radeon_connectors.c
+++ b/drivers/gpu/drm/radeon/radeon_connectors.c
@@ -771,30 +771,27 @@ static enum drm_connector_status radeon_dvi_detect(struct drm_connector *connect
771 } else 771 } else
772 ret = connector_status_connected; 772 ret = connector_status_connected;
773 773
774 /* multiple connectors on the same encoder with the same ddc line 774 /* This gets complicated. We have boards with VGA + HDMI with a
775 * This tends to be HDMI and DVI on the same encoder with the 775 * shared DDC line and we have boards with DVI-D + HDMI with a shared
776 * same ddc line. If the edid says HDMI, consider the HDMI port 776 * DDC line. The latter is more complex because with DVI<->HDMI adapters
777 * connected and the DVI port disconnected. If the edid doesn't 777 * you don't really know what's connected to which port as both are digital.
778 * say HDMI, vice versa.
779 */ 778 */
780 if (radeon_connector->shared_ddc && (ret == connector_status_connected)) { 779 if (radeon_connector->shared_ddc && (ret == connector_status_connected)) {
781 struct drm_device *dev = connector->dev; 780 struct drm_device *dev = connector->dev;
781 struct radeon_device *rdev = dev->dev_private;
782 struct drm_connector *list_connector; 782 struct drm_connector *list_connector;
783 struct radeon_connector *list_radeon_connector; 783 struct radeon_connector *list_radeon_connector;
784 list_for_each_entry(list_connector, &dev->mode_config.connector_list, head) { 784 list_for_each_entry(list_connector, &dev->mode_config.connector_list, head) {
785 if (connector == list_connector) 785 if (connector == list_connector)
786 continue; 786 continue;
787 list_radeon_connector = to_radeon_connector(list_connector); 787 list_radeon_connector = to_radeon_connector(list_connector);
788 if (radeon_connector->devices == list_radeon_connector->devices) { 788 if (list_radeon_connector->shared_ddc &&
789 if (drm_detect_hdmi_monitor(radeon_connector->edid)) { 789 (list_radeon_connector->ddc_bus->rec.i2c_id ==
790 if (connector->connector_type == DRM_MODE_CONNECTOR_DVID) { 790 radeon_connector->ddc_bus->rec.i2c_id)) {
791 kfree(radeon_connector->edid); 791 /* cases where both connectors are digital */
792 radeon_connector->edid = NULL; 792 if (list_connector->connector_type != DRM_MODE_CONNECTOR_VGA) {
793 ret = connector_status_disconnected; 793 /* hpd is our only option in this case */
794 } 794 if (!radeon_hpd_sense(rdev, radeon_connector->hpd.hpd)) {
795 } else {
796 if ((connector->connector_type == DRM_MODE_CONNECTOR_HDMIA) ||
797 (connector->connector_type == DRM_MODE_CONNECTOR_HDMIB)) {
798 kfree(radeon_connector->edid); 795 kfree(radeon_connector->edid);
799 radeon_connector->edid = NULL; 796 radeon_connector->edid = NULL;
800 ret = connector_status_disconnected; 797 ret = connector_status_disconnected;
diff --git a/drivers/gpu/drm/radeon/radeon_cursor.c b/drivers/gpu/drm/radeon/radeon_cursor.c
index b7023fff89eb..4eb67c0e0996 100644
--- a/drivers/gpu/drm/radeon/radeon_cursor.c
+++ b/drivers/gpu/drm/radeon/radeon_cursor.c
@@ -194,7 +194,7 @@ unpin:
194fail: 194fail:
195 drm_gem_object_unreference_unlocked(obj); 195 drm_gem_object_unreference_unlocked(obj);
196 196
197 return 0; 197 return ret;
198} 198}
199 199
200int radeon_crtc_cursor_move(struct drm_crtc *crtc, 200int radeon_crtc_cursor_move(struct drm_crtc *crtc,
diff --git a/drivers/gpu/drm/radeon/radeon_device.c b/drivers/gpu/drm/radeon/radeon_device.c
index f10faed21567..dd279da90546 100644
--- a/drivers/gpu/drm/radeon/radeon_device.c
+++ b/drivers/gpu/drm/radeon/radeon_device.c
@@ -226,20 +226,20 @@ void radeon_gtt_location(struct radeon_device *rdev, struct radeon_mc *mc)
226{ 226{
227 u64 size_af, size_bf; 227 u64 size_af, size_bf;
228 228
229 size_af = 0xFFFFFFFF - mc->vram_end; 229 size_af = ((0xFFFFFFFF - mc->vram_end) + mc->gtt_base_align) & ~mc->gtt_base_align;
230 size_bf = mc->vram_start; 230 size_bf = mc->vram_start & ~mc->gtt_base_align;
231 if (size_bf > size_af) { 231 if (size_bf > size_af) {
232 if (mc->gtt_size > size_bf) { 232 if (mc->gtt_size > size_bf) {
233 dev_warn(rdev->dev, "limiting GTT\n"); 233 dev_warn(rdev->dev, "limiting GTT\n");
234 mc->gtt_size = size_bf; 234 mc->gtt_size = size_bf;
235 } 235 }
236 mc->gtt_start = mc->vram_start - mc->gtt_size; 236 mc->gtt_start = (mc->vram_start & ~mc->gtt_base_align) - mc->gtt_size;
237 } else { 237 } else {
238 if (mc->gtt_size > size_af) { 238 if (mc->gtt_size > size_af) {
239 dev_warn(rdev->dev, "limiting GTT\n"); 239 dev_warn(rdev->dev, "limiting GTT\n");
240 mc->gtt_size = size_af; 240 mc->gtt_size = size_af;
241 } 241 }
242 mc->gtt_start = mc->vram_end + 1; 242 mc->gtt_start = (mc->vram_end + 1 + mc->gtt_base_align) & ~mc->gtt_base_align;
243 } 243 }
244 mc->gtt_end = mc->gtt_start + mc->gtt_size - 1; 244 mc->gtt_end = mc->gtt_start + mc->gtt_size - 1;
245 dev_info(rdev->dev, "GTT: %lluM 0x%08llX - 0x%08llX\n", 245 dev_info(rdev->dev, "GTT: %lluM 0x%08llX - 0x%08llX\n",
@@ -779,6 +779,7 @@ int radeon_suspend_kms(struct drm_device *dev, pm_message_t state)
779 779
780int radeon_resume_kms(struct drm_device *dev) 780int radeon_resume_kms(struct drm_device *dev)
781{ 781{
782 struct drm_connector *connector;
782 struct radeon_device *rdev = dev->dev_private; 783 struct radeon_device *rdev = dev->dev_private;
783 784
784 if (rdev->powered_down) 785 if (rdev->powered_down)
@@ -797,6 +798,12 @@ int radeon_resume_kms(struct drm_device *dev)
797 radeon_resume(rdev); 798 radeon_resume(rdev);
798 radeon_pm_resume(rdev); 799 radeon_pm_resume(rdev);
799 radeon_restore_bios_scratch_regs(rdev); 800 radeon_restore_bios_scratch_regs(rdev);
801
802 /* turn on display hw */
803 list_for_each_entry(connector, &dev->mode_config.connector_list, head) {
804 drm_helper_connector_dpms(connector, DRM_MODE_DPMS_ON);
805 }
806
800 radeon_fbdev_set_suspend(rdev, 0); 807 radeon_fbdev_set_suspend(rdev, 0);
801 release_console_sem(); 808 release_console_sem();
802 809
diff --git a/drivers/gpu/drm/radeon/radeon_encoders.c b/drivers/gpu/drm/radeon/radeon_encoders.c
index 1ebb100015b7..e0b30b264c28 100644
--- a/drivers/gpu/drm/radeon/radeon_encoders.c
+++ b/drivers/gpu/drm/radeon/radeon_encoders.c
@@ -1072,6 +1072,8 @@ radeon_atom_encoder_dpms(struct drm_encoder *encoder, int mode)
1072 if (is_dig) { 1072 if (is_dig) {
1073 switch (mode) { 1073 switch (mode) {
1074 case DRM_MODE_DPMS_ON: 1074 case DRM_MODE_DPMS_ON:
1075 if (!ASIC_IS_DCE4(rdev))
1076 atombios_dig_transmitter_setup(encoder, ATOM_TRANSMITTER_ACTION_ENABLE_OUTPUT, 0, 0);
1075 if (atombios_get_encoder_mode(encoder) == ATOM_ENCODER_MODE_DP) { 1077 if (atombios_get_encoder_mode(encoder) == ATOM_ENCODER_MODE_DP) {
1076 struct drm_connector *connector = radeon_get_connector_for_encoder(encoder); 1078 struct drm_connector *connector = radeon_get_connector_for_encoder(encoder);
1077 1079
@@ -1079,8 +1081,6 @@ radeon_atom_encoder_dpms(struct drm_encoder *encoder, int mode)
1079 if (ASIC_IS_DCE4(rdev)) 1081 if (ASIC_IS_DCE4(rdev))
1080 atombios_dig_encoder_setup(encoder, ATOM_ENCODER_CMD_DP_VIDEO_ON); 1082 atombios_dig_encoder_setup(encoder, ATOM_ENCODER_CMD_DP_VIDEO_ON);
1081 } 1083 }
1082 if (!ASIC_IS_DCE4(rdev))
1083 atombios_dig_transmitter_setup(encoder, ATOM_TRANSMITTER_ACTION_ENABLE_OUTPUT, 0, 0);
1084 break; 1084 break;
1085 case DRM_MODE_DPMS_STANDBY: 1085 case DRM_MODE_DPMS_STANDBY:
1086 case DRM_MODE_DPMS_SUSPEND: 1086 case DRM_MODE_DPMS_SUSPEND:
diff --git a/drivers/gpu/drm/radeon/radeon_kms.c b/drivers/gpu/drm/radeon/radeon_kms.c
index 6a70c0dc7f92..ab389f89fa8d 100644
--- a/drivers/gpu/drm/radeon/radeon_kms.c
+++ b/drivers/gpu/drm/radeon/radeon_kms.c
@@ -128,7 +128,8 @@ int radeon_info_ioctl(struct drm_device *dev, void *data, struct drm_file *filp)
128 for (i = 0, found = 0; i < rdev->num_crtc; i++) { 128 for (i = 0, found = 0; i < rdev->num_crtc; i++) {
129 crtc = (struct drm_crtc *)minfo->crtcs[i]; 129 crtc = (struct drm_crtc *)minfo->crtcs[i];
130 if (crtc && crtc->base.id == value) { 130 if (crtc && crtc->base.id == value) {
131 value = i; 131 struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc);
132 value = radeon_crtc->crtc_id;
132 found = 1; 133 found = 1;
133 break; 134 break;
134 } 135 }
diff --git a/drivers/gpu/drm/radeon/radeon_legacy_encoders.c b/drivers/gpu/drm/radeon/radeon_legacy_encoders.c
index 5b07b8848e09..5688a0cf6bbe 100644
--- a/drivers/gpu/drm/radeon/radeon_legacy_encoders.c
+++ b/drivers/gpu/drm/radeon/radeon_legacy_encoders.c
@@ -108,6 +108,7 @@ static void radeon_legacy_lvds_dpms(struct drm_encoder *encoder, int mode)
108 udelay(panel_pwr_delay * 1000); 108 udelay(panel_pwr_delay * 1000);
109 WREG32(RADEON_LVDS_GEN_CNTL, lvds_gen_cntl); 109 WREG32(RADEON_LVDS_GEN_CNTL, lvds_gen_cntl);
110 WREG32_PLL(RADEON_PIXCLKS_CNTL, pixclks_cntl); 110 WREG32_PLL(RADEON_PIXCLKS_CNTL, pixclks_cntl);
111 udelay(panel_pwr_delay * 1000);
111 break; 112 break;
112 } 113 }
113 114
@@ -928,16 +929,14 @@ static void radeon_legacy_tv_dac_mode_set(struct drm_encoder *encoder,
928 if (ASIC_IS_R300(rdev)) { 929 if (ASIC_IS_R300(rdev)) {
929 gpiopad_a = RREG32(RADEON_GPIOPAD_A) | 1; 930 gpiopad_a = RREG32(RADEON_GPIOPAD_A) | 1;
930 disp_output_cntl = RREG32(RADEON_DISP_OUTPUT_CNTL); 931 disp_output_cntl = RREG32(RADEON_DISP_OUTPUT_CNTL);
931 } 932 } else if (rdev->family != CHIP_R200)
932
933 if (rdev->family == CHIP_R200 || ASIC_IS_R300(rdev))
934 disp_tv_out_cntl = RREG32(RADEON_DISP_TV_OUT_CNTL);
935 else
936 disp_hw_debug = RREG32(RADEON_DISP_HW_DEBUG); 933 disp_hw_debug = RREG32(RADEON_DISP_HW_DEBUG);
937 934 else if (rdev->family == CHIP_R200)
938 if (rdev->family == CHIP_R200)
939 fp2_gen_cntl = RREG32(RADEON_FP2_GEN_CNTL); 935 fp2_gen_cntl = RREG32(RADEON_FP2_GEN_CNTL);
940 936
937 if (rdev->family >= CHIP_R200)
938 disp_tv_out_cntl = RREG32(RADEON_DISP_TV_OUT_CNTL);
939
941 if (is_tv) { 940 if (is_tv) {
942 uint32_t dac_cntl; 941 uint32_t dac_cntl;
943 942
@@ -1002,15 +1001,13 @@ static void radeon_legacy_tv_dac_mode_set(struct drm_encoder *encoder,
1002 if (ASIC_IS_R300(rdev)) { 1001 if (ASIC_IS_R300(rdev)) {
1003 WREG32_P(RADEON_GPIOPAD_A, gpiopad_a, ~1); 1002 WREG32_P(RADEON_GPIOPAD_A, gpiopad_a, ~1);
1004 WREG32(RADEON_DISP_OUTPUT_CNTL, disp_output_cntl); 1003 WREG32(RADEON_DISP_OUTPUT_CNTL, disp_output_cntl);
1005 } 1004 } else if (rdev->family != CHIP_R200)
1005 WREG32(RADEON_DISP_HW_DEBUG, disp_hw_debug);
1006 else if (rdev->family == CHIP_R200)
1007 WREG32(RADEON_FP2_GEN_CNTL, fp2_gen_cntl);
1006 1008
1007 if (rdev->family >= CHIP_R200) 1009 if (rdev->family >= CHIP_R200)
1008 WREG32(RADEON_DISP_TV_OUT_CNTL, disp_tv_out_cntl); 1010 WREG32(RADEON_DISP_TV_OUT_CNTL, disp_tv_out_cntl);
1009 else
1010 WREG32(RADEON_DISP_HW_DEBUG, disp_hw_debug);
1011
1012 if (rdev->family == CHIP_R200)
1013 WREG32(RADEON_FP2_GEN_CNTL, fp2_gen_cntl);
1014 1011
1015 if (is_tv) 1012 if (is_tv)
1016 radeon_legacy_tv_mode_set(encoder, mode, adjusted_mode); 1013 radeon_legacy_tv_mode_set(encoder, mode, adjusted_mode);
diff --git a/drivers/gpu/drm/radeon/radeon_legacy_tv.c b/drivers/gpu/drm/radeon/radeon_legacy_tv.c
index f2ed27c8055b..032040397743 100644
--- a/drivers/gpu/drm/radeon/radeon_legacy_tv.c
+++ b/drivers/gpu/drm/radeon/radeon_legacy_tv.c
@@ -642,8 +642,8 @@ void radeon_legacy_tv_mode_set(struct drm_encoder *encoder,
642 } 642 }
643 flicker_removal = (tmp + 500) / 1000; 643 flicker_removal = (tmp + 500) / 1000;
644 644
645 if (flicker_removal < 2) 645 if (flicker_removal < 3)
646 flicker_removal = 2; 646 flicker_removal = 3;
647 for (i = 0; i < ARRAY_SIZE(SLOPE_limit); ++i) { 647 for (i = 0; i < ARRAY_SIZE(SLOPE_limit); ++i) {
648 if (flicker_removal == SLOPE_limit[i]) 648 if (flicker_removal == SLOPE_limit[i])
649 break; 649 break;
diff --git a/drivers/gpu/drm/radeon/radeon_mode.h b/drivers/gpu/drm/radeon/radeon_mode.h
index 67358baf28b2..95696aa57ac8 100644
--- a/drivers/gpu/drm/radeon/radeon_mode.h
+++ b/drivers/gpu/drm/radeon/radeon_mode.h
@@ -206,6 +206,7 @@ enum radeon_connector_table {
206 CT_MINI_INTERNAL, 206 CT_MINI_INTERNAL,
207 CT_IMAC_G5_ISIGHT, 207 CT_IMAC_G5_ISIGHT,
208 CT_EMAC, 208 CT_EMAC,
209 CT_RN50_POWER,
209}; 210};
210 211
211enum radeon_dvo_chip { 212enum radeon_dvo_chip {
diff --git a/drivers/gpu/drm/radeon/radeon_pm.c b/drivers/gpu/drm/radeon/radeon_pm.c
index 63f679a04b25..3fa6984d9896 100644
--- a/drivers/gpu/drm/radeon/radeon_pm.c
+++ b/drivers/gpu/drm/radeon/radeon_pm.c
@@ -333,6 +333,7 @@ static ssize_t radeon_get_pm_profile(struct device *dev,
333 return snprintf(buf, PAGE_SIZE, "%s\n", 333 return snprintf(buf, PAGE_SIZE, "%s\n",
334 (cp == PM_PROFILE_AUTO) ? "auto" : 334 (cp == PM_PROFILE_AUTO) ? "auto" :
335 (cp == PM_PROFILE_LOW) ? "low" : 335 (cp == PM_PROFILE_LOW) ? "low" :
336 (cp == PM_PROFILE_MID) ? "mid" :
336 (cp == PM_PROFILE_HIGH) ? "high" : "default"); 337 (cp == PM_PROFILE_HIGH) ? "high" : "default");
337} 338}
338 339
@@ -397,13 +398,20 @@ static ssize_t radeon_set_pm_method(struct device *dev,
397 rdev->pm.dynpm_planned_action = DYNPM_ACTION_DEFAULT; 398 rdev->pm.dynpm_planned_action = DYNPM_ACTION_DEFAULT;
398 mutex_unlock(&rdev->pm.mutex); 399 mutex_unlock(&rdev->pm.mutex);
399 } else if (strncmp("profile", buf, strlen("profile")) == 0) { 400 } else if (strncmp("profile", buf, strlen("profile")) == 0) {
401 bool flush_wq = false;
402
400 mutex_lock(&rdev->pm.mutex); 403 mutex_lock(&rdev->pm.mutex);
401 rdev->pm.pm_method = PM_METHOD_PROFILE; 404 if (rdev->pm.pm_method == PM_METHOD_DYNPM) {
405 cancel_delayed_work(&rdev->pm.dynpm_idle_work);
406 flush_wq = true;
407 }
402 /* disable dynpm */ 408 /* disable dynpm */
403 rdev->pm.dynpm_state = DYNPM_STATE_DISABLED; 409 rdev->pm.dynpm_state = DYNPM_STATE_DISABLED;
404 rdev->pm.dynpm_planned_action = DYNPM_ACTION_NONE; 410 rdev->pm.dynpm_planned_action = DYNPM_ACTION_NONE;
405 cancel_delayed_work(&rdev->pm.dynpm_idle_work); 411 rdev->pm.pm_method = PM_METHOD_PROFILE;
406 mutex_unlock(&rdev->pm.mutex); 412 mutex_unlock(&rdev->pm.mutex);
413 if (flush_wq)
414 flush_workqueue(rdev->wq);
407 } else { 415 } else {
408 DRM_ERROR("invalid power method!\n"); 416 DRM_ERROR("invalid power method!\n");
409 goto fail; 417 goto fail;
@@ -418,9 +426,18 @@ static DEVICE_ATTR(power_method, S_IRUGO | S_IWUSR, radeon_get_pm_method, radeon
418 426
419void radeon_pm_suspend(struct radeon_device *rdev) 427void radeon_pm_suspend(struct radeon_device *rdev)
420{ 428{
429 bool flush_wq = false;
430
421 mutex_lock(&rdev->pm.mutex); 431 mutex_lock(&rdev->pm.mutex);
422 cancel_delayed_work(&rdev->pm.dynpm_idle_work); 432 if (rdev->pm.pm_method == PM_METHOD_DYNPM) {
433 cancel_delayed_work(&rdev->pm.dynpm_idle_work);
434 if (rdev->pm.dynpm_state == DYNPM_STATE_ACTIVE)
435 rdev->pm.dynpm_state = DYNPM_STATE_SUSPENDED;
436 flush_wq = true;
437 }
423 mutex_unlock(&rdev->pm.mutex); 438 mutex_unlock(&rdev->pm.mutex);
439 if (flush_wq)
440 flush_workqueue(rdev->wq);
424} 441}
425 442
426void radeon_pm_resume(struct radeon_device *rdev) 443void radeon_pm_resume(struct radeon_device *rdev)
@@ -432,6 +449,12 @@ void radeon_pm_resume(struct radeon_device *rdev)
432 rdev->pm.current_sclk = rdev->clock.default_sclk; 449 rdev->pm.current_sclk = rdev->clock.default_sclk;
433 rdev->pm.current_mclk = rdev->clock.default_mclk; 450 rdev->pm.current_mclk = rdev->clock.default_mclk;
434 rdev->pm.current_vddc = rdev->pm.power_state[rdev->pm.default_power_state_index].clock_info[0].voltage.voltage; 451 rdev->pm.current_vddc = rdev->pm.power_state[rdev->pm.default_power_state_index].clock_info[0].voltage.voltage;
452 if (rdev->pm.pm_method == PM_METHOD_DYNPM
453 && rdev->pm.dynpm_state == DYNPM_STATE_SUSPENDED) {
454 rdev->pm.dynpm_state = DYNPM_STATE_ACTIVE;
455 queue_delayed_work(rdev->wq, &rdev->pm.dynpm_idle_work,
456 msecs_to_jiffies(RADEON_IDLE_LOOP_MS));
457 }
435 mutex_unlock(&rdev->pm.mutex); 458 mutex_unlock(&rdev->pm.mutex);
436 radeon_pm_compute_clocks(rdev); 459 radeon_pm_compute_clocks(rdev);
437} 460}
@@ -486,6 +509,8 @@ int radeon_pm_init(struct radeon_device *rdev)
486void radeon_pm_fini(struct radeon_device *rdev) 509void radeon_pm_fini(struct radeon_device *rdev)
487{ 510{
488 if (rdev->pm.num_power_states > 1) { 511 if (rdev->pm.num_power_states > 1) {
512 bool flush_wq = false;
513
489 mutex_lock(&rdev->pm.mutex); 514 mutex_lock(&rdev->pm.mutex);
490 if (rdev->pm.pm_method == PM_METHOD_PROFILE) { 515 if (rdev->pm.pm_method == PM_METHOD_PROFILE) {
491 rdev->pm.profile = PM_PROFILE_DEFAULT; 516 rdev->pm.profile = PM_PROFILE_DEFAULT;
@@ -493,13 +518,16 @@ void radeon_pm_fini(struct radeon_device *rdev)
493 radeon_pm_set_clocks(rdev); 518 radeon_pm_set_clocks(rdev);
494 } else if (rdev->pm.pm_method == PM_METHOD_DYNPM) { 519 } else if (rdev->pm.pm_method == PM_METHOD_DYNPM) {
495 /* cancel work */ 520 /* cancel work */
496 cancel_delayed_work_sync(&rdev->pm.dynpm_idle_work); 521 cancel_delayed_work(&rdev->pm.dynpm_idle_work);
522 flush_wq = true;
497 /* reset default clocks */ 523 /* reset default clocks */
498 rdev->pm.dynpm_state = DYNPM_STATE_DISABLED; 524 rdev->pm.dynpm_state = DYNPM_STATE_DISABLED;
499 rdev->pm.dynpm_planned_action = DYNPM_ACTION_DEFAULT; 525 rdev->pm.dynpm_planned_action = DYNPM_ACTION_DEFAULT;
500 radeon_pm_set_clocks(rdev); 526 radeon_pm_set_clocks(rdev);
501 } 527 }
502 mutex_unlock(&rdev->pm.mutex); 528 mutex_unlock(&rdev->pm.mutex);
529 if (flush_wq)
530 flush_workqueue(rdev->wq);
503 531
504 device_remove_file(rdev->dev, &dev_attr_power_profile); 532 device_remove_file(rdev->dev, &dev_attr_power_profile);
505 device_remove_file(rdev->dev, &dev_attr_power_method); 533 device_remove_file(rdev->dev, &dev_attr_power_method);
@@ -720,12 +748,12 @@ static void radeon_dynpm_idle_work_handler(struct work_struct *work)
720 radeon_pm_get_dynpm_state(rdev); 748 radeon_pm_get_dynpm_state(rdev);
721 radeon_pm_set_clocks(rdev); 749 radeon_pm_set_clocks(rdev);
722 } 750 }
751
752 queue_delayed_work(rdev->wq, &rdev->pm.dynpm_idle_work,
753 msecs_to_jiffies(RADEON_IDLE_LOOP_MS));
723 } 754 }
724 mutex_unlock(&rdev->pm.mutex); 755 mutex_unlock(&rdev->pm.mutex);
725 ttm_bo_unlock_delayed_workqueue(&rdev->mman.bdev, resched); 756 ttm_bo_unlock_delayed_workqueue(&rdev->mman.bdev, resched);
726
727 queue_delayed_work(rdev->wq, &rdev->pm.dynpm_idle_work,
728 msecs_to_jiffies(RADEON_IDLE_LOOP_MS));
729} 757}
730 758
731/* 759/*
diff --git a/drivers/gpu/drm/radeon/reg_srcs/evergreen b/drivers/gpu/drm/radeon/reg_srcs/evergreen
index b5c757f68d3c..f78fd592544d 100644
--- a/drivers/gpu/drm/radeon/reg_srcs/evergreen
+++ b/drivers/gpu/drm/radeon/reg_srcs/evergreen
@@ -80,8 +80,8 @@ evergreen 0x9400
800x00028010 DB_RENDER_OVERRIDE2 800x00028010 DB_RENDER_OVERRIDE2
810x00028028 DB_STENCIL_CLEAR 810x00028028 DB_STENCIL_CLEAR
820x0002802C DB_DEPTH_CLEAR 820x0002802C DB_DEPTH_CLEAR
830x00028034 PA_SC_SCREEN_SCISSOR_BR
840x00028030 PA_SC_SCREEN_SCISSOR_TL 830x00028030 PA_SC_SCREEN_SCISSOR_TL
840x00028034 PA_SC_SCREEN_SCISSOR_BR
850x0002805C DB_DEPTH_SLICE 850x0002805C DB_DEPTH_SLICE
860x00028140 SQ_ALU_CONST_BUFFER_SIZE_PS_0 860x00028140 SQ_ALU_CONST_BUFFER_SIZE_PS_0
870x00028144 SQ_ALU_CONST_BUFFER_SIZE_PS_1 870x00028144 SQ_ALU_CONST_BUFFER_SIZE_PS_1
@@ -460,8 +460,8 @@ evergreen 0x9400
4600x00028844 SQ_PGM_RESOURCES_PS 4600x00028844 SQ_PGM_RESOURCES_PS
4610x00028848 SQ_PGM_RESOURCES_2_PS 4610x00028848 SQ_PGM_RESOURCES_2_PS
4620x0002884C SQ_PGM_EXPORTS_PS 4620x0002884C SQ_PGM_EXPORTS_PS
4630x0002885C SQ_PGM_RESOURCES_VS 4630x00028860 SQ_PGM_RESOURCES_VS
4640x00028860 SQ_PGM_RESOURCES_2_VS 4640x00028864 SQ_PGM_RESOURCES_2_VS
4650x00028878 SQ_PGM_RESOURCES_GS 4650x00028878 SQ_PGM_RESOURCES_GS
4660x0002887C SQ_PGM_RESOURCES_2_GS 4660x0002887C SQ_PGM_RESOURCES_2_GS
4670x00028890 SQ_PGM_RESOURCES_ES 4670x00028890 SQ_PGM_RESOURCES_ES
@@ -469,8 +469,8 @@ evergreen 0x9400
4690x000288A8 SQ_PGM_RESOURCES_FS 4690x000288A8 SQ_PGM_RESOURCES_FS
4700x000288BC SQ_PGM_RESOURCES_HS 4700x000288BC SQ_PGM_RESOURCES_HS
4710x000288C0 SQ_PGM_RESOURCES_2_HS 4710x000288C0 SQ_PGM_RESOURCES_2_HS
4720x000288D0 SQ_PGM_RESOURCES_LS 4720x000288D4 SQ_PGM_RESOURCES_LS
4730x000288D4 SQ_PGM_RESOURCES_2_LS 4730x000288D8 SQ_PGM_RESOURCES_2_LS
4740x000288E8 SQ_LDS_ALLOC 4740x000288E8 SQ_LDS_ALLOC
4750x000288EC SQ_LDS_ALLOC_PS 4750x000288EC SQ_LDS_ALLOC_PS
4760x000288F0 SQ_VTX_SEMANTIC_CLEAR 4760x000288F0 SQ_VTX_SEMANTIC_CLEAR
diff --git a/drivers/gpu/drm/radeon/rs400.c b/drivers/gpu/drm/radeon/rs400.c
index 9e4240b3bf0b..f454c9a5e7f2 100644
--- a/drivers/gpu/drm/radeon/rs400.c
+++ b/drivers/gpu/drm/radeon/rs400.c
@@ -57,7 +57,9 @@ void rs400_gart_adjust_size(struct radeon_device *rdev)
57 } 57 }
58 if (rdev->family == CHIP_RS400 || rdev->family == CHIP_RS480) { 58 if (rdev->family == CHIP_RS400 || rdev->family == CHIP_RS480) {
59 /* FIXME: RS400 & RS480 seems to have issue with GART size 59 /* FIXME: RS400 & RS480 seems to have issue with GART size
60 * if 4G of system memory (needs more testing) */ 60 * if 4G of system memory (needs more testing)
61 */
62 /* XXX is this still an issue with proper alignment? */
61 rdev->mc.gtt_size = 32 * 1024 * 1024; 63 rdev->mc.gtt_size = 32 * 1024 * 1024;
62 DRM_ERROR("Forcing to 32M GART size (because of ASIC bug ?)\n"); 64 DRM_ERROR("Forcing to 32M GART size (because of ASIC bug ?)\n");
63 } 65 }
@@ -263,6 +265,7 @@ void rs400_mc_init(struct radeon_device *rdev)
263 r100_vram_init_sizes(rdev); 265 r100_vram_init_sizes(rdev);
264 base = (RREG32(RADEON_NB_TOM) & 0xffff) << 16; 266 base = (RREG32(RADEON_NB_TOM) & 0xffff) << 16;
265 radeon_vram_location(rdev, &rdev->mc, base); 267 radeon_vram_location(rdev, &rdev->mc, base);
268 rdev->mc.gtt_base_align = rdev->mc.gtt_size - 1;
266 radeon_gtt_location(rdev, &rdev->mc); 269 radeon_gtt_location(rdev, &rdev->mc);
267 radeon_update_bandwidth_info(rdev); 270 radeon_update_bandwidth_info(rdev);
268} 271}
diff --git a/drivers/gpu/drm/radeon/rs600.c b/drivers/gpu/drm/radeon/rs600.c
index 7bb4c3e52f3b..6dc15ea8ba33 100644
--- a/drivers/gpu/drm/radeon/rs600.c
+++ b/drivers/gpu/drm/radeon/rs600.c
@@ -698,6 +698,7 @@ void rs600_mc_init(struct radeon_device *rdev)
698 base = G_000004_MC_FB_START(base) << 16; 698 base = G_000004_MC_FB_START(base) << 16;
699 rdev->mc.igp_sideport_enabled = radeon_atombios_sideport_present(rdev); 699 rdev->mc.igp_sideport_enabled = radeon_atombios_sideport_present(rdev);
700 radeon_vram_location(rdev, &rdev->mc, base); 700 radeon_vram_location(rdev, &rdev->mc, base);
701 rdev->mc.gtt_base_align = 0;
701 radeon_gtt_location(rdev, &rdev->mc); 702 radeon_gtt_location(rdev, &rdev->mc);
702 radeon_update_bandwidth_info(rdev); 703 radeon_update_bandwidth_info(rdev);
703} 704}
diff --git a/drivers/gpu/drm/radeon/rs690.c b/drivers/gpu/drm/radeon/rs690.c
index bcc33195ebc2..ce4ecbe10816 100644
--- a/drivers/gpu/drm/radeon/rs690.c
+++ b/drivers/gpu/drm/radeon/rs690.c
@@ -79,7 +79,13 @@ void rs690_pm_info(struct radeon_device *rdev)
79 tmp.full = dfixed_const(100); 79 tmp.full = dfixed_const(100);
80 rdev->pm.igp_sideport_mclk.full = dfixed_const(info->info.ulBootUpMemoryClock); 80 rdev->pm.igp_sideport_mclk.full = dfixed_const(info->info.ulBootUpMemoryClock);
81 rdev->pm.igp_sideport_mclk.full = dfixed_div(rdev->pm.igp_sideport_mclk, tmp); 81 rdev->pm.igp_sideport_mclk.full = dfixed_div(rdev->pm.igp_sideport_mclk, tmp);
82 rdev->pm.igp_system_mclk.full = dfixed_const(le16_to_cpu(info->info.usK8MemoryClock)); 82 if (info->info.usK8MemoryClock)
83 rdev->pm.igp_system_mclk.full = dfixed_const(le16_to_cpu(info->info.usK8MemoryClock));
84 else if (rdev->clock.default_mclk) {
85 rdev->pm.igp_system_mclk.full = dfixed_const(rdev->clock.default_mclk);
86 rdev->pm.igp_system_mclk.full = dfixed_div(rdev->pm.igp_system_mclk, tmp);
87 } else
88 rdev->pm.igp_system_mclk.full = dfixed_const(400);
83 rdev->pm.igp_ht_link_clk.full = dfixed_const(le16_to_cpu(info->info.usFSBClock)); 89 rdev->pm.igp_ht_link_clk.full = dfixed_const(le16_to_cpu(info->info.usFSBClock));
84 rdev->pm.igp_ht_link_width.full = dfixed_const(info->info.ucHTLinkWidth); 90 rdev->pm.igp_ht_link_width.full = dfixed_const(info->info.ucHTLinkWidth);
85 break; 91 break;
@@ -87,34 +93,31 @@ void rs690_pm_info(struct radeon_device *rdev)
87 tmp.full = dfixed_const(100); 93 tmp.full = dfixed_const(100);
88 rdev->pm.igp_sideport_mclk.full = dfixed_const(info->info_v2.ulBootUpSidePortClock); 94 rdev->pm.igp_sideport_mclk.full = dfixed_const(info->info_v2.ulBootUpSidePortClock);
89 rdev->pm.igp_sideport_mclk.full = dfixed_div(rdev->pm.igp_sideport_mclk, tmp); 95 rdev->pm.igp_sideport_mclk.full = dfixed_div(rdev->pm.igp_sideport_mclk, tmp);
90 rdev->pm.igp_system_mclk.full = dfixed_const(info->info_v2.ulBootUpUMAClock); 96 if (info->info_v2.ulBootUpUMAClock)
97 rdev->pm.igp_system_mclk.full = dfixed_const(info->info_v2.ulBootUpUMAClock);
98 else if (rdev->clock.default_mclk)
99 rdev->pm.igp_system_mclk.full = dfixed_const(rdev->clock.default_mclk);
100 else
101 rdev->pm.igp_system_mclk.full = dfixed_const(66700);
91 rdev->pm.igp_system_mclk.full = dfixed_div(rdev->pm.igp_system_mclk, tmp); 102 rdev->pm.igp_system_mclk.full = dfixed_div(rdev->pm.igp_system_mclk, tmp);
92 rdev->pm.igp_ht_link_clk.full = dfixed_const(info->info_v2.ulHTLinkFreq); 103 rdev->pm.igp_ht_link_clk.full = dfixed_const(info->info_v2.ulHTLinkFreq);
93 rdev->pm.igp_ht_link_clk.full = dfixed_div(rdev->pm.igp_ht_link_clk, tmp); 104 rdev->pm.igp_ht_link_clk.full = dfixed_div(rdev->pm.igp_ht_link_clk, tmp);
94 rdev->pm.igp_ht_link_width.full = dfixed_const(le16_to_cpu(info->info_v2.usMinHTLinkWidth)); 105 rdev->pm.igp_ht_link_width.full = dfixed_const(le16_to_cpu(info->info_v2.usMinHTLinkWidth));
95 break; 106 break;
96 default: 107 default:
97 tmp.full = dfixed_const(100);
98 /* We assume the slower possible clock ie worst case */ 108 /* We assume the slower possible clock ie worst case */
99 /* DDR 333Mhz */ 109 rdev->pm.igp_sideport_mclk.full = dfixed_const(200);
100 rdev->pm.igp_sideport_mclk.full = dfixed_const(333); 110 rdev->pm.igp_system_mclk.full = dfixed_const(200);
101 /* FIXME: system clock ? */ 111 rdev->pm.igp_ht_link_clk.full = dfixed_const(1000);
102 rdev->pm.igp_system_mclk.full = dfixed_const(100);
103 rdev->pm.igp_system_mclk.full = dfixed_div(rdev->pm.igp_system_mclk, tmp);
104 rdev->pm.igp_ht_link_clk.full = dfixed_const(200);
105 rdev->pm.igp_ht_link_width.full = dfixed_const(8); 112 rdev->pm.igp_ht_link_width.full = dfixed_const(8);
106 DRM_ERROR("No integrated system info for your GPU, using safe default\n"); 113 DRM_ERROR("No integrated system info for your GPU, using safe default\n");
107 break; 114 break;
108 } 115 }
109 } else { 116 } else {
110 tmp.full = dfixed_const(100);
111 /* We assume the slower possible clock ie worst case */ 117 /* We assume the slower possible clock ie worst case */
112 /* DDR 333Mhz */ 118 rdev->pm.igp_sideport_mclk.full = dfixed_const(200);
113 rdev->pm.igp_sideport_mclk.full = dfixed_const(333); 119 rdev->pm.igp_system_mclk.full = dfixed_const(200);
114 /* FIXME: system clock ? */ 120 rdev->pm.igp_ht_link_clk.full = dfixed_const(1000);
115 rdev->pm.igp_system_mclk.full = dfixed_const(100);
116 rdev->pm.igp_system_mclk.full = dfixed_div(rdev->pm.igp_system_mclk, tmp);
117 rdev->pm.igp_ht_link_clk.full = dfixed_const(200);
118 rdev->pm.igp_ht_link_width.full = dfixed_const(8); 121 rdev->pm.igp_ht_link_width.full = dfixed_const(8);
119 DRM_ERROR("No integrated system info for your GPU, using safe default\n"); 122 DRM_ERROR("No integrated system info for your GPU, using safe default\n");
120 } 123 }
@@ -159,6 +162,7 @@ void rs690_mc_init(struct radeon_device *rdev)
159 rs690_pm_info(rdev); 162 rs690_pm_info(rdev);
160 rdev->mc.igp_sideport_enabled = radeon_atombios_sideport_present(rdev); 163 rdev->mc.igp_sideport_enabled = radeon_atombios_sideport_present(rdev);
161 radeon_vram_location(rdev, &rdev->mc, base); 164 radeon_vram_location(rdev, &rdev->mc, base);
165 rdev->mc.gtt_base_align = rdev->mc.gtt_size - 1;
162 radeon_gtt_location(rdev, &rdev->mc); 166 radeon_gtt_location(rdev, &rdev->mc);
163 radeon_update_bandwidth_info(rdev); 167 radeon_update_bandwidth_info(rdev);
164} 168}
@@ -228,10 +232,6 @@ void rs690_crtc_bandwidth_compute(struct radeon_device *rdev,
228 fixed20_12 a, b, c; 232 fixed20_12 a, b, c;
229 fixed20_12 pclk, request_fifo_depth, tolerable_latency, estimated_width; 233 fixed20_12 pclk, request_fifo_depth, tolerable_latency, estimated_width;
230 fixed20_12 consumption_time, line_time, chunk_time, read_delay_latency; 234 fixed20_12 consumption_time, line_time, chunk_time, read_delay_latency;
231 /* FIXME: detect IGP with sideport memory, i don't think there is any
232 * such product available
233 */
234 bool sideport = false;
235 235
236 if (!crtc->base.enabled) { 236 if (!crtc->base.enabled) {
237 /* FIXME: wouldn't it better to set priority mark to maximum */ 237 /* FIXME: wouldn't it better to set priority mark to maximum */
@@ -300,7 +300,7 @@ void rs690_crtc_bandwidth_compute(struct radeon_device *rdev,
300 300
301 /* Maximun bandwidth is the minimun bandwidth of all component */ 301 /* Maximun bandwidth is the minimun bandwidth of all component */
302 rdev->pm.max_bandwidth = rdev->pm.core_bandwidth; 302 rdev->pm.max_bandwidth = rdev->pm.core_bandwidth;
303 if (sideport) { 303 if (rdev->mc.igp_sideport_enabled) {
304 if (rdev->pm.max_bandwidth.full > rdev->pm.sideport_bandwidth.full && 304 if (rdev->pm.max_bandwidth.full > rdev->pm.sideport_bandwidth.full &&
305 rdev->pm.sideport_bandwidth.full) 305 rdev->pm.sideport_bandwidth.full)
306 rdev->pm.max_bandwidth = rdev->pm.sideport_bandwidth; 306 rdev->pm.max_bandwidth = rdev->pm.sideport_bandwidth;
diff --git a/drivers/gpu/drm/radeon/rv515.c b/drivers/gpu/drm/radeon/rv515.c
index 7d9a7b0a180a..0c9c169a6852 100644
--- a/drivers/gpu/drm/radeon/rv515.c
+++ b/drivers/gpu/drm/radeon/rv515.c
@@ -195,6 +195,7 @@ void rv515_mc_init(struct radeon_device *rdev)
195 rv515_vram_get_type(rdev); 195 rv515_vram_get_type(rdev);
196 r100_vram_init_sizes(rdev); 196 r100_vram_init_sizes(rdev);
197 radeon_vram_location(rdev, &rdev->mc, 0); 197 radeon_vram_location(rdev, &rdev->mc, 0);
198 rdev->mc.gtt_base_align = 0;
198 if (!(rdev->flags & RADEON_IS_AGP)) 199 if (!(rdev->flags & RADEON_IS_AGP))
199 radeon_gtt_location(rdev, &rdev->mc); 200 radeon_gtt_location(rdev, &rdev->mc);
200 radeon_update_bandwidth_info(rdev); 201 radeon_update_bandwidth_info(rdev);
diff --git a/drivers/gpu/drm/radeon/rv770.c b/drivers/gpu/drm/radeon/rv770.c
index cec536c222c5..b7fd82064922 100644
--- a/drivers/gpu/drm/radeon/rv770.c
+++ b/drivers/gpu/drm/radeon/rv770.c
@@ -224,7 +224,7 @@ static void rv770_mc_program(struct radeon_device *rdev)
224 WREG32(MC_VM_FB_LOCATION, tmp); 224 WREG32(MC_VM_FB_LOCATION, tmp);
225 WREG32(HDP_NONSURFACE_BASE, (rdev->mc.vram_start >> 8)); 225 WREG32(HDP_NONSURFACE_BASE, (rdev->mc.vram_start >> 8));
226 WREG32(HDP_NONSURFACE_INFO, (2 << 7)); 226 WREG32(HDP_NONSURFACE_INFO, (2 << 7));
227 WREG32(HDP_NONSURFACE_SIZE, (rdev->mc.mc_vram_size - 1) | 0x3FF); 227 WREG32(HDP_NONSURFACE_SIZE, 0x3FFFFFFF);
228 if (rdev->flags & RADEON_IS_AGP) { 228 if (rdev->flags & RADEON_IS_AGP) {
229 WREG32(MC_VM_AGP_TOP, rdev->mc.gtt_end >> 16); 229 WREG32(MC_VM_AGP_TOP, rdev->mc.gtt_end >> 16);
230 WREG32(MC_VM_AGP_BOT, rdev->mc.gtt_start >> 16); 230 WREG32(MC_VM_AGP_BOT, rdev->mc.gtt_start >> 16);
diff --git a/drivers/gpu/drm/ttm/ttm_page_alloc.c b/drivers/gpu/drm/ttm/ttm_page_alloc.c
index ef910694bd63..ca904799f018 100644
--- a/drivers/gpu/drm/ttm/ttm_page_alloc.c
+++ b/drivers/gpu/drm/ttm/ttm_page_alloc.c
@@ -40,11 +40,13 @@
40#include <linux/slab.h> 40#include <linux/slab.h>
41 41
42#include <asm/atomic.h> 42#include <asm/atomic.h>
43#include <asm/agp.h>
44 43
45#include "ttm/ttm_bo_driver.h" 44#include "ttm/ttm_bo_driver.h"
46#include "ttm/ttm_page_alloc.h" 45#include "ttm/ttm_page_alloc.h"
47 46
47#ifdef TTM_HAS_AGP
48#include <asm/agp.h>
49#endif
48 50
49#define NUM_PAGES_TO_ALLOC (PAGE_SIZE/sizeof(struct page *)) 51#define NUM_PAGES_TO_ALLOC (PAGE_SIZE/sizeof(struct page *))
50#define SMALL_ALLOCATION 16 52#define SMALL_ALLOCATION 16
@@ -104,7 +106,6 @@ struct ttm_pool_opts {
104struct ttm_pool_manager { 106struct ttm_pool_manager {
105 struct kobject kobj; 107 struct kobject kobj;
106 struct shrinker mm_shrink; 108 struct shrinker mm_shrink;
107 atomic_t page_alloc_inited;
108 struct ttm_pool_opts options; 109 struct ttm_pool_opts options;
109 110
110 union { 111 union {
@@ -142,7 +143,7 @@ static void ttm_pool_kobj_release(struct kobject *kobj)
142{ 143{
143 struct ttm_pool_manager *m = 144 struct ttm_pool_manager *m =
144 container_of(kobj, struct ttm_pool_manager, kobj); 145 container_of(kobj, struct ttm_pool_manager, kobj);
145 (void)m; 146 kfree(m);
146} 147}
147 148
148static ssize_t ttm_pool_store(struct kobject *kobj, 149static ssize_t ttm_pool_store(struct kobject *kobj,
@@ -214,9 +215,7 @@ static struct kobj_type ttm_pool_kobj_type = {
214 .default_attrs = ttm_pool_attrs, 215 .default_attrs = ttm_pool_attrs,
215}; 216};
216 217
217static struct ttm_pool_manager _manager = { 218static struct ttm_pool_manager *_manager;
218 .page_alloc_inited = ATOMIC_INIT(0)
219};
220 219
221#ifndef CONFIG_X86 220#ifndef CONFIG_X86
222static int set_pages_array_wb(struct page **pages, int addrinarray) 221static int set_pages_array_wb(struct page **pages, int addrinarray)
@@ -271,7 +270,7 @@ static struct ttm_page_pool *ttm_get_pool(int flags,
271 if (flags & TTM_PAGE_FLAG_DMA32) 270 if (flags & TTM_PAGE_FLAG_DMA32)
272 pool_index |= 0x2; 271 pool_index |= 0x2;
273 272
274 return &_manager.pools[pool_index]; 273 return &_manager->pools[pool_index];
275} 274}
276 275
277/* set memory back to wb and free the pages. */ 276/* set memory back to wb and free the pages. */
@@ -387,7 +386,7 @@ static int ttm_pool_get_num_unused_pages(void)
387 unsigned i; 386 unsigned i;
388 int total = 0; 387 int total = 0;
389 for (i = 0; i < NUM_POOLS; ++i) 388 for (i = 0; i < NUM_POOLS; ++i)
390 total += _manager.pools[i].npages; 389 total += _manager->pools[i].npages;
391 390
392 return total; 391 return total;
393} 392}
@@ -395,7 +394,7 @@ static int ttm_pool_get_num_unused_pages(void)
395/** 394/**
396 * Callback for mm to request pool to reduce number of page held. 395 * Callback for mm to request pool to reduce number of page held.
397 */ 396 */
398static int ttm_pool_mm_shrink(int shrink_pages, gfp_t gfp_mask) 397static int ttm_pool_mm_shrink(struct shrinker *shrink, int shrink_pages, gfp_t gfp_mask)
399{ 398{
400 static atomic_t start_pool = ATOMIC_INIT(0); 399 static atomic_t start_pool = ATOMIC_INIT(0);
401 unsigned i; 400 unsigned i;
@@ -408,7 +407,7 @@ static int ttm_pool_mm_shrink(int shrink_pages, gfp_t gfp_mask)
408 unsigned nr_free = shrink_pages; 407 unsigned nr_free = shrink_pages;
409 if (shrink_pages == 0) 408 if (shrink_pages == 0)
410 break; 409 break;
411 pool = &_manager.pools[(i + pool_offset)%NUM_POOLS]; 410 pool = &_manager->pools[(i + pool_offset)%NUM_POOLS];
412 shrink_pages = ttm_page_pool_free(pool, nr_free); 411 shrink_pages = ttm_page_pool_free(pool, nr_free);
413 } 412 }
414 /* return estimated number of unused pages in pool */ 413 /* return estimated number of unused pages in pool */
@@ -576,10 +575,10 @@ static void ttm_page_pool_fill_locked(struct ttm_page_pool *pool,
576 575
577 /* If allocation request is small and there is not enough 576 /* If allocation request is small and there is not enough
578 * pages in pool we fill the pool first */ 577 * pages in pool we fill the pool first */
579 if (count < _manager.options.small 578 if (count < _manager->options.small
580 && count > pool->npages) { 579 && count > pool->npages) {
581 struct list_head new_pages; 580 struct list_head new_pages;
582 unsigned alloc_size = _manager.options.alloc_size; 581 unsigned alloc_size = _manager->options.alloc_size;
583 582
584 /** 583 /**
585 * Can't change page caching if in irqsave context. We have to 584 * Can't change page caching if in irqsave context. We have to
@@ -667,7 +666,7 @@ int ttm_get_pages(struct list_head *pages, int flags,
667{ 666{
668 struct ttm_page_pool *pool = ttm_get_pool(flags, cstate); 667 struct ttm_page_pool *pool = ttm_get_pool(flags, cstate);
669 struct page *p = NULL; 668 struct page *p = NULL;
670 int gfp_flags = 0; 669 int gfp_flags = GFP_USER;
671 int r; 670 int r;
672 671
673 /* set zero flag for page allocation if required */ 672 /* set zero flag for page allocation if required */
@@ -759,8 +758,8 @@ void ttm_put_pages(struct list_head *pages, unsigned page_count, int flags,
759 pool->npages += page_count; 758 pool->npages += page_count;
760 /* Check that we don't go over the pool limit */ 759 /* Check that we don't go over the pool limit */
761 page_count = 0; 760 page_count = 0;
762 if (pool->npages > _manager.options.max_size) { 761 if (pool->npages > _manager->options.max_size) {
763 page_count = pool->npages - _manager.options.max_size; 762 page_count = pool->npages - _manager->options.max_size;
764 /* free at least NUM_PAGES_TO_ALLOC number of pages 763 /* free at least NUM_PAGES_TO_ALLOC number of pages
765 * to reduce calls to set_memory_wb */ 764 * to reduce calls to set_memory_wb */
766 if (page_count < NUM_PAGES_TO_ALLOC) 765 if (page_count < NUM_PAGES_TO_ALLOC)
@@ -785,33 +784,36 @@ static void ttm_page_pool_init_locked(struct ttm_page_pool *pool, int flags,
785int ttm_page_alloc_init(struct ttm_mem_global *glob, unsigned max_pages) 784int ttm_page_alloc_init(struct ttm_mem_global *glob, unsigned max_pages)
786{ 785{
787 int ret; 786 int ret;
788 if (atomic_add_return(1, &_manager.page_alloc_inited) > 1) 787
789 return 0; 788 WARN_ON(_manager);
790 789
791 printk(KERN_INFO TTM_PFX "Initializing pool allocator.\n"); 790 printk(KERN_INFO TTM_PFX "Initializing pool allocator.\n");
792 791
793 ttm_page_pool_init_locked(&_manager.wc_pool, GFP_HIGHUSER, "wc"); 792 _manager = kzalloc(sizeof(*_manager), GFP_KERNEL);
793
794 ttm_page_pool_init_locked(&_manager->wc_pool, GFP_HIGHUSER, "wc");
794 795
795 ttm_page_pool_init_locked(&_manager.uc_pool, GFP_HIGHUSER, "uc"); 796 ttm_page_pool_init_locked(&_manager->uc_pool, GFP_HIGHUSER, "uc");
796 797
797 ttm_page_pool_init_locked(&_manager.wc_pool_dma32, GFP_USER | GFP_DMA32, 798 ttm_page_pool_init_locked(&_manager->wc_pool_dma32,
798 "wc dma"); 799 GFP_USER | GFP_DMA32, "wc dma");
799 800
800 ttm_page_pool_init_locked(&_manager.uc_pool_dma32, GFP_USER | GFP_DMA32, 801 ttm_page_pool_init_locked(&_manager->uc_pool_dma32,
801 "uc dma"); 802 GFP_USER | GFP_DMA32, "uc dma");
802 803
803 _manager.options.max_size = max_pages; 804 _manager->options.max_size = max_pages;
804 _manager.options.small = SMALL_ALLOCATION; 805 _manager->options.small = SMALL_ALLOCATION;
805 _manager.options.alloc_size = NUM_PAGES_TO_ALLOC; 806 _manager->options.alloc_size = NUM_PAGES_TO_ALLOC;
806 807
807 kobject_init(&_manager.kobj, &ttm_pool_kobj_type); 808 ret = kobject_init_and_add(&_manager->kobj, &ttm_pool_kobj_type,
808 ret = kobject_add(&_manager.kobj, &glob->kobj, "pool"); 809 &glob->kobj, "pool");
809 if (unlikely(ret != 0)) { 810 if (unlikely(ret != 0)) {
810 kobject_put(&_manager.kobj); 811 kobject_put(&_manager->kobj);
812 _manager = NULL;
811 return ret; 813 return ret;
812 } 814 }
813 815
814 ttm_pool_mm_shrink_init(&_manager); 816 ttm_pool_mm_shrink_init(_manager);
815 817
816 return 0; 818 return 0;
817} 819}
@@ -820,16 +822,14 @@ void ttm_page_alloc_fini()
820{ 822{
821 int i; 823 int i;
822 824
823 if (atomic_sub_return(1, &_manager.page_alloc_inited) > 0)
824 return;
825
826 printk(KERN_INFO TTM_PFX "Finalizing pool allocator.\n"); 825 printk(KERN_INFO TTM_PFX "Finalizing pool allocator.\n");
827 ttm_pool_mm_shrink_fini(&_manager); 826 ttm_pool_mm_shrink_fini(_manager);
828 827
829 for (i = 0; i < NUM_POOLS; ++i) 828 for (i = 0; i < NUM_POOLS; ++i)
830 ttm_page_pool_free(&_manager.pools[i], FREE_ALL_PAGES); 829 ttm_page_pool_free(&_manager->pools[i], FREE_ALL_PAGES);
831 830
832 kobject_put(&_manager.kobj); 831 kobject_put(&_manager->kobj);
832 _manager = NULL;
833} 833}
834 834
835int ttm_page_alloc_debugfs(struct seq_file *m, void *data) 835int ttm_page_alloc_debugfs(struct seq_file *m, void *data)
@@ -837,14 +837,14 @@ int ttm_page_alloc_debugfs(struct seq_file *m, void *data)
837 struct ttm_page_pool *p; 837 struct ttm_page_pool *p;
838 unsigned i; 838 unsigned i;
839 char *h[] = {"pool", "refills", "pages freed", "size"}; 839 char *h[] = {"pool", "refills", "pages freed", "size"};
840 if (atomic_read(&_manager.page_alloc_inited) == 0) { 840 if (!_manager) {
841 seq_printf(m, "No pool allocator running.\n"); 841 seq_printf(m, "No pool allocator running.\n");
842 return 0; 842 return 0;
843 } 843 }
844 seq_printf(m, "%6s %12s %13s %8s\n", 844 seq_printf(m, "%6s %12s %13s %8s\n",
845 h[0], h[1], h[2], h[3]); 845 h[0], h[1], h[2], h[3]);
846 for (i = 0; i < NUM_POOLS; ++i) { 846 for (i = 0; i < NUM_POOLS; ++i) {
847 p = &_manager.pools[i]; 847 p = &_manager->pools[i];
848 848
849 seq_printf(m, "%6s %12ld %13ld %8d\n", 849 seq_printf(m, "%6s %12ld %13ld %8d\n",
850 p->name, p->nrefills, 850 p->name, p->nrefills,
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
index f1d626112415..437ac786277a 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
@@ -972,6 +972,7 @@ int vmw_kms_update_layout_ioctl(struct drm_device *dev, void *data,
972 ret = copy_from_user(rects, user_rects, rects_size); 972 ret = copy_from_user(rects, user_rects, rects_size);
973 if (unlikely(ret != 0)) { 973 if (unlikely(ret != 0)) {
974 DRM_ERROR("Failed to get rects.\n"); 974 DRM_ERROR("Failed to get rects.\n");
975 ret = -EFAULT;
975 goto out_free; 976 goto out_free;
976 } 977 }
977 978
diff --git a/drivers/hid/Kconfig b/drivers/hid/Kconfig
index 132278fa6240..434099369058 100644
--- a/drivers/hid/Kconfig
+++ b/drivers/hid/Kconfig
@@ -358,6 +358,7 @@ config HID_ROCCAT
358config HID_ROCCAT_KONE 358config HID_ROCCAT_KONE
359 tristate "Roccat Kone Mouse support" 359 tristate "Roccat Kone Mouse support"
360 depends on USB_HID 360 depends on USB_HID
361 select HID_ROCCAT
361 ---help--- 362 ---help---
362 Support for Roccat Kone mouse. 363 Support for Roccat Kone mouse.
363 364
diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
index aa0f7dcabcd7..866e54ec5fb2 100644
--- a/drivers/hid/hid-core.c
+++ b/drivers/hid/hid-core.c
@@ -1337,6 +1337,24 @@ static const struct hid_device_id hid_blacklist[] = {
1337 { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_WIRELESS_OPTICAL_DESKTOP_3_0) }, 1337 { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_WIRELESS_OPTICAL_DESKTOP_3_0) },
1338 { HID_USB_DEVICE(USB_VENDOR_ID_MONTEREY, USB_DEVICE_ID_GENIUS_KB29E) }, 1338 { HID_USB_DEVICE(USB_VENDOR_ID_MONTEREY, USB_DEVICE_ID_GENIUS_KB29E) },
1339 { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN) }, 1339 { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN) },
1340 { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_1) },
1341 { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_2) },
1342 { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_3) },
1343 { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_4) },
1344 { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_5) },
1345 { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_6) },
1346 { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_7) },
1347 { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_8) },
1348 { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_9) },
1349 { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_10) },
1350 { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_11) },
1351 { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_12) },
1352 { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_13) },
1353 { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_14) },
1354 { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_15) },
1355 { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_16) },
1356 { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_17) },
1357 { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_18) },
1340 { HID_USB_DEVICE(USB_VENDOR_ID_ORTEK, USB_DEVICE_ID_ORTEK_WKB2000) }, 1358 { HID_USB_DEVICE(USB_VENDOR_ID_ORTEK, USB_DEVICE_ID_ORTEK_WKB2000) },
1341 { HID_USB_DEVICE(USB_VENDOR_ID_PETALYNX, USB_DEVICE_ID_PETALYNX_MAXTER_REMOTE) }, 1359 { HID_USB_DEVICE(USB_VENDOR_ID_PETALYNX, USB_DEVICE_ID_PETALYNX_MAXTER_REMOTE) },
1342 { HID_USB_DEVICE(USB_VENDOR_ID_QUANTA, USB_DEVICE_ID_QUANTA_OPTICAL_TOUCH) }, 1360 { HID_USB_DEVICE(USB_VENDOR_ID_QUANTA, USB_DEVICE_ID_QUANTA_OPTICAL_TOUCH) },
@@ -1760,7 +1778,8 @@ int hid_add_device(struct hid_device *hdev)
1760 1778
1761 /* we need to kill them here, otherwise they will stay allocated to 1779 /* we need to kill them here, otherwise they will stay allocated to
1762 * wait for coming driver */ 1780 * wait for coming driver */
1763 if (!(hdev->quirks & HID_QUIRK_NO_IGNORE) && hid_ignore(hdev)) 1781 if (!(hdev->quirks & HID_QUIRK_NO_IGNORE)
1782 && (hid_ignore(hdev) || (hdev->quirks & HID_QUIRK_IGNORE)))
1764 return -ENODEV; 1783 return -ENODEV;
1765 1784
1766 /* XXX hack, any other cleaner solution after the driver core 1785 /* XXX hack, any other cleaner solution after the driver core
diff --git a/drivers/hid/hid-debug.c b/drivers/hid/hid-debug.c
index c94026768570..850d02a7a925 100644
--- a/drivers/hid/hid-debug.c
+++ b/drivers/hid/hid-debug.c
@@ -949,8 +949,8 @@ static ssize_t hid_debug_events_read(struct file *file, char __user *buffer,
949 int ret = 0, len; 949 int ret = 0, len;
950 DECLARE_WAITQUEUE(wait, current); 950 DECLARE_WAITQUEUE(wait, current);
951 951
952 mutex_lock(&list->read_mutex);
952 while (ret == 0) { 953 while (ret == 0) {
953 mutex_lock(&list->read_mutex);
954 if (list->head == list->tail) { 954 if (list->head == list->tail) {
955 add_wait_queue(&list->hdev->debug_wait, &wait); 955 add_wait_queue(&list->hdev->debug_wait, &wait);
956 set_current_state(TASK_INTERRUPTIBLE); 956 set_current_state(TASK_INTERRUPTIBLE);
diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h
index 6af77ed0b555..31601eef25dd 100644
--- a/drivers/hid/hid-ids.h
+++ b/drivers/hid/hid-ids.h
@@ -134,6 +134,7 @@
134#define USB_VENDOR_ID_CH 0x068e 134#define USB_VENDOR_ID_CH 0x068e
135#define USB_DEVICE_ID_CH_PRO_PEDALS 0x00f2 135#define USB_DEVICE_ID_CH_PRO_PEDALS 0x00f2
136#define USB_DEVICE_ID_CH_COMBATSTICK 0x00f4 136#define USB_DEVICE_ID_CH_COMBATSTICK 0x00f4
137#define USB_DEVICE_ID_CH_FLIGHT_SIM_ECLIPSE_YOKE 0x0051
137#define USB_DEVICE_ID_CH_FLIGHT_SIM_YOKE 0x00ff 138#define USB_DEVICE_ID_CH_FLIGHT_SIM_YOKE 0x00ff
138#define USB_DEVICE_ID_CH_3AXIS_5BUTTON_STICK 0x00d3 139#define USB_DEVICE_ID_CH_3AXIS_5BUTTON_STICK 0x00d3
139 140
@@ -369,6 +370,8 @@
369#define USB_DEVICE_ID_MS_PRESENTER_8K_BT 0x0701 370#define USB_DEVICE_ID_MS_PRESENTER_8K_BT 0x0701
370#define USB_DEVICE_ID_MS_PRESENTER_8K_USB 0x0713 371#define USB_DEVICE_ID_MS_PRESENTER_8K_USB 0x0713
371 372
373#define USB_VENDOR_ID_MOJO 0x8282
374#define USB_DEVICE_ID_RETRO_ADAPTER 0x3201
372 375
373#define USB_VENDOR_ID_MONTEREY 0x0566 376#define USB_VENDOR_ID_MONTEREY 0x0566
374#define USB_DEVICE_ID_GENIUS_KB29E 0x3004 377#define USB_DEVICE_ID_GENIUS_KB29E 0x3004
@@ -391,6 +394,24 @@
391 394
392#define USB_VENDOR_ID_NTRIG 0x1b96 395#define USB_VENDOR_ID_NTRIG 0x1b96
393#define USB_DEVICE_ID_NTRIG_TOUCH_SCREEN 0x0001 396#define USB_DEVICE_ID_NTRIG_TOUCH_SCREEN 0x0001
397#define USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_1 0x0003
398#define USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_2 0x0004
399#define USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_3 0x0005
400#define USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_4 0x0006
401#define USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_5 0x0007
402#define USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_6 0x0008
403#define USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_7 0x0009
404#define USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_8 0x000A
405#define USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_9 0x000B
406#define USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_10 0x000C
407#define USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_11 0x000D
408#define USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_12 0x000E
409#define USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_13 0x000F
410#define USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_14 0x0010
411#define USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_15 0x0011
412#define USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_16 0x0012
413#define USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_17 0x0013
414#define USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_18 0x0014
394 415
395#define USB_VENDOR_ID_ONTRAK 0x0a07 416#define USB_VENDOR_ID_ONTRAK 0x0a07
396#define USB_DEVICE_ID_ONTRAK_ADU100 0x0064 417#define USB_DEVICE_ID_ONTRAK_ADU100 0x0064
diff --git a/drivers/hid/hid-ntrig.c b/drivers/hid/hid-ntrig.c
index b6b0caeeac58..fb69b8c4953f 100644
--- a/drivers/hid/hid-ntrig.c
+++ b/drivers/hid/hid-ntrig.c
@@ -868,6 +868,42 @@ static void ntrig_remove(struct hid_device *hdev)
868static const struct hid_device_id ntrig_devices[] = { 868static const struct hid_device_id ntrig_devices[] = {
869 { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN), 869 { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN),
870 .driver_data = NTRIG_DUPLICATE_USAGES }, 870 .driver_data = NTRIG_DUPLICATE_USAGES },
871 { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_1),
872 .driver_data = NTRIG_DUPLICATE_USAGES },
873 { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_2),
874 .driver_data = NTRIG_DUPLICATE_USAGES },
875 { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_3),
876 .driver_data = NTRIG_DUPLICATE_USAGES },
877 { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_4),
878 .driver_data = NTRIG_DUPLICATE_USAGES },
879 { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_5),
880 .driver_data = NTRIG_DUPLICATE_USAGES },
881 { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_6),
882 .driver_data = NTRIG_DUPLICATE_USAGES },
883 { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_7),
884 .driver_data = NTRIG_DUPLICATE_USAGES },
885 { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_8),
886 .driver_data = NTRIG_DUPLICATE_USAGES },
887 { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_9),
888 .driver_data = NTRIG_DUPLICATE_USAGES },
889 { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_10),
890 .driver_data = NTRIG_DUPLICATE_USAGES },
891 { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_11),
892 .driver_data = NTRIG_DUPLICATE_USAGES },
893 { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_12),
894 .driver_data = NTRIG_DUPLICATE_USAGES },
895 { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_13),
896 .driver_data = NTRIG_DUPLICATE_USAGES },
897 { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_14),
898 .driver_data = NTRIG_DUPLICATE_USAGES },
899 { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_15),
900 .driver_data = NTRIG_DUPLICATE_USAGES },
901 { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_16),
902 .driver_data = NTRIG_DUPLICATE_USAGES },
903 { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_17),
904 .driver_data = NTRIG_DUPLICATE_USAGES },
905 { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_18),
906 .driver_data = NTRIG_DUPLICATE_USAGES },
871 { } 907 { }
872}; 908};
873MODULE_DEVICE_TABLE(hid, ntrig_devices); 909MODULE_DEVICE_TABLE(hid, ntrig_devices);
diff --git a/drivers/hid/usbhid/hid-core.c b/drivers/hid/usbhid/hid-core.c
index 1ebd3244eb85..b729c0286679 100644
--- a/drivers/hid/usbhid/hid-core.c
+++ b/drivers/hid/usbhid/hid-core.c
@@ -827,14 +827,21 @@ static int usbhid_output_raw_report(struct hid_device *hid, __u8 *buf, size_t co
827 ret++; 827 ret++;
828 } 828 }
829 } else { 829 } else {
830 int skipped_report_id = 0;
831 if (buf[0] == 0x0) {
832 /* Don't send the Report ID */
833 buf++;
834 count--;
835 skipped_report_id = 1;
836 }
830 ret = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), 837 ret = usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
831 HID_REQ_SET_REPORT, 838 HID_REQ_SET_REPORT,
832 USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE, 839 USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE,
833 ((report_type + 1) << 8) | *buf, 840 ((report_type + 1) << 8) | *buf,
834 interface->desc.bInterfaceNumber, buf + 1, count - 1, 841 interface->desc.bInterfaceNumber, buf, count,
835 USB_CTRL_SET_TIMEOUT); 842 USB_CTRL_SET_TIMEOUT);
836 /* count also the report id */ 843 /* count also the report id, if this was a numbered report. */
837 if (ret > 0) 844 if (ret > 0 && skipped_report_id)
838 ret++; 845 ret++;
839 } 846 }
840 847
diff --git a/drivers/hid/usbhid/hid-quirks.c b/drivers/hid/usbhid/hid-quirks.c
index 5ff8d327f33a..5f5aa39b3988 100644
--- a/drivers/hid/usbhid/hid-quirks.c
+++ b/drivers/hid/usbhid/hid-quirks.c
@@ -34,6 +34,7 @@ static const struct hid_blacklist {
34 { USB_VENDOR_ID_ALPS, USB_DEVICE_ID_IBM_GAMEPAD, HID_QUIRK_BADPAD }, 34 { USB_VENDOR_ID_ALPS, USB_DEVICE_ID_IBM_GAMEPAD, HID_QUIRK_BADPAD },
35 { USB_VENDOR_ID_CHIC, USB_DEVICE_ID_CHIC_GAMEPAD, HID_QUIRK_BADPAD }, 35 { USB_VENDOR_ID_CHIC, USB_DEVICE_ID_CHIC_GAMEPAD, HID_QUIRK_BADPAD },
36 { USB_VENDOR_ID_DWAV, USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH, HID_QUIRK_MULTI_INPUT }, 36 { USB_VENDOR_ID_DWAV, USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH, HID_QUIRK_MULTI_INPUT },
37 { USB_VENDOR_ID_MOJO, USB_DEVICE_ID_RETRO_ADAPTER, HID_QUIRK_MULTI_INPUT },
37 { USB_VENDOR_ID_HAPP, USB_DEVICE_ID_UGCI_DRIVING, HID_QUIRK_BADPAD | HID_QUIRK_MULTI_INPUT }, 38 { USB_VENDOR_ID_HAPP, USB_DEVICE_ID_UGCI_DRIVING, HID_QUIRK_BADPAD | HID_QUIRK_MULTI_INPUT },
38 { USB_VENDOR_ID_HAPP, USB_DEVICE_ID_UGCI_FLYING, HID_QUIRK_BADPAD | HID_QUIRK_MULTI_INPUT }, 39 { USB_VENDOR_ID_HAPP, USB_DEVICE_ID_UGCI_FLYING, HID_QUIRK_BADPAD | HID_QUIRK_MULTI_INPUT },
39 { USB_VENDOR_ID_HAPP, USB_DEVICE_ID_UGCI_FIGHTING, HID_QUIRK_BADPAD | HID_QUIRK_MULTI_INPUT }, 40 { USB_VENDOR_ID_HAPP, USB_DEVICE_ID_UGCI_FIGHTING, HID_QUIRK_BADPAD | HID_QUIRK_MULTI_INPUT },
@@ -56,6 +57,7 @@ static const struct hid_blacklist {
56 { USB_VENDOR_ID_ATEN, USB_DEVICE_ID_ATEN_4PORTKVM, HID_QUIRK_NOGET }, 57 { USB_VENDOR_ID_ATEN, USB_DEVICE_ID_ATEN_4PORTKVM, HID_QUIRK_NOGET },
57 { USB_VENDOR_ID_ATEN, USB_DEVICE_ID_ATEN_4PORTKVMC, HID_QUIRK_NOGET }, 58 { USB_VENDOR_ID_ATEN, USB_DEVICE_ID_ATEN_4PORTKVMC, HID_QUIRK_NOGET },
58 { USB_VENDOR_ID_CH, USB_DEVICE_ID_CH_COMBATSTICK, HID_QUIRK_NOGET }, 59 { USB_VENDOR_ID_CH, USB_DEVICE_ID_CH_COMBATSTICK, HID_QUIRK_NOGET },
60 { USB_VENDOR_ID_CH, USB_DEVICE_ID_CH_FLIGHT_SIM_ECLIPSE_YOKE, HID_QUIRK_NOGET },
59 { USB_VENDOR_ID_CH, USB_DEVICE_ID_CH_FLIGHT_SIM_YOKE, HID_QUIRK_NOGET }, 61 { USB_VENDOR_ID_CH, USB_DEVICE_ID_CH_FLIGHT_SIM_YOKE, HID_QUIRK_NOGET },
60 { USB_VENDOR_ID_CH, USB_DEVICE_ID_CH_PRO_PEDALS, HID_QUIRK_NOGET }, 62 { USB_VENDOR_ID_CH, USB_DEVICE_ID_CH_PRO_PEDALS, HID_QUIRK_NOGET },
61 { USB_VENDOR_ID_CH, USB_DEVICE_ID_CH_3AXIS_5BUTTON_STICK, HID_QUIRK_NOGET }, 63 { USB_VENDOR_ID_CH, USB_DEVICE_ID_CH_3AXIS_5BUTTON_STICK, HID_QUIRK_NOGET },
diff --git a/drivers/hwmon/coretemp.c b/drivers/hwmon/coretemp.c
index 2988da150ed6..05344af50734 100644
--- a/drivers/hwmon/coretemp.c
+++ b/drivers/hwmon/coretemp.c
@@ -53,6 +53,7 @@ struct coretemp_data {
53 struct mutex update_lock; 53 struct mutex update_lock;
54 const char *name; 54 const char *name;
55 u32 id; 55 u32 id;
56 u16 core_id;
56 char valid; /* zero until following fields are valid */ 57 char valid; /* zero until following fields are valid */
57 unsigned long last_updated; /* in jiffies */ 58 unsigned long last_updated; /* in jiffies */
58 int temp; 59 int temp;
@@ -75,7 +76,7 @@ static ssize_t show_name(struct device *dev, struct device_attribute
75 if (attr->index == SHOW_NAME) 76 if (attr->index == SHOW_NAME)
76 ret = sprintf(buf, "%s\n", data->name); 77 ret = sprintf(buf, "%s\n", data->name);
77 else /* show label */ 78 else /* show label */
78 ret = sprintf(buf, "Core %d\n", data->id); 79 ret = sprintf(buf, "Core %d\n", data->core_id);
79 return ret; 80 return ret;
80} 81}
81 82
@@ -304,6 +305,9 @@ static int __devinit coretemp_probe(struct platform_device *pdev)
304 } 305 }
305 306
306 data->id = pdev->id; 307 data->id = pdev->id;
308#ifdef CONFIG_SMP
309 data->core_id = c->cpu_core_id;
310#endif
307 data->name = "coretemp"; 311 data->name = "coretemp";
308 mutex_init(&data->update_lock); 312 mutex_init(&data->update_lock);
309 313
@@ -405,6 +409,10 @@ struct pdev_entry {
405 struct list_head list; 409 struct list_head list;
406 struct platform_device *pdev; 410 struct platform_device *pdev;
407 unsigned int cpu; 411 unsigned int cpu;
412#ifdef CONFIG_SMP
413 u16 phys_proc_id;
414 u16 cpu_core_id;
415#endif
408}; 416};
409 417
410static LIST_HEAD(pdev_list); 418static LIST_HEAD(pdev_list);
@@ -415,6 +423,22 @@ static int __cpuinit coretemp_device_add(unsigned int cpu)
415 int err; 423 int err;
416 struct platform_device *pdev; 424 struct platform_device *pdev;
417 struct pdev_entry *pdev_entry; 425 struct pdev_entry *pdev_entry;
426#ifdef CONFIG_SMP
427 struct cpuinfo_x86 *c = &cpu_data(cpu);
428#endif
429
430 mutex_lock(&pdev_list_mutex);
431
432#ifdef CONFIG_SMP
433 /* Skip second HT entry of each core */
434 list_for_each_entry(pdev_entry, &pdev_list, list) {
435 if (c->phys_proc_id == pdev_entry->phys_proc_id &&
436 c->cpu_core_id == pdev_entry->cpu_core_id) {
437 err = 0; /* Not an error */
438 goto exit;
439 }
440 }
441#endif
418 442
419 pdev = platform_device_alloc(DRVNAME, cpu); 443 pdev = platform_device_alloc(DRVNAME, cpu);
420 if (!pdev) { 444 if (!pdev) {
@@ -438,7 +462,10 @@ static int __cpuinit coretemp_device_add(unsigned int cpu)
438 462
439 pdev_entry->pdev = pdev; 463 pdev_entry->pdev = pdev;
440 pdev_entry->cpu = cpu; 464 pdev_entry->cpu = cpu;
441 mutex_lock(&pdev_list_mutex); 465#ifdef CONFIG_SMP
466 pdev_entry->phys_proc_id = c->phys_proc_id;
467 pdev_entry->cpu_core_id = c->cpu_core_id;
468#endif
442 list_add_tail(&pdev_entry->list, &pdev_list); 469 list_add_tail(&pdev_entry->list, &pdev_list);
443 mutex_unlock(&pdev_list_mutex); 470 mutex_unlock(&pdev_list_mutex);
444 471
@@ -449,6 +476,7 @@ exit_device_free:
449exit_device_put: 476exit_device_put:
450 platform_device_put(pdev); 477 platform_device_put(pdev);
451exit: 478exit:
479 mutex_unlock(&pdev_list_mutex);
452 return err; 480 return err;
453} 481}
454 482
diff --git a/drivers/hwmon/i5k_amb.c b/drivers/hwmon/i5k_amb.c
index e880e2c3871d..937983407e2a 100644
--- a/drivers/hwmon/i5k_amb.c
+++ b/drivers/hwmon/i5k_amb.c
@@ -289,6 +289,7 @@ static int __devinit i5k_amb_hwmon_init(struct platform_device *pdev)
289 iattr->s_attr.dev_attr.attr.mode = S_IRUGO; 289 iattr->s_attr.dev_attr.attr.mode = S_IRUGO;
290 iattr->s_attr.dev_attr.show = show_label; 290 iattr->s_attr.dev_attr.show = show_label;
291 iattr->s_attr.index = k; 291 iattr->s_attr.index = k;
292 sysfs_attr_init(&iattr->s_attr.dev_attr.attr);
292 res = device_create_file(&pdev->dev, 293 res = device_create_file(&pdev->dev,
293 &iattr->s_attr.dev_attr); 294 &iattr->s_attr.dev_attr);
294 if (res) 295 if (res)
@@ -303,6 +304,7 @@ static int __devinit i5k_amb_hwmon_init(struct platform_device *pdev)
303 iattr->s_attr.dev_attr.attr.mode = S_IRUGO; 304 iattr->s_attr.dev_attr.attr.mode = S_IRUGO;
304 iattr->s_attr.dev_attr.show = show_amb_temp; 305 iattr->s_attr.dev_attr.show = show_amb_temp;
305 iattr->s_attr.index = k; 306 iattr->s_attr.index = k;
307 sysfs_attr_init(&iattr->s_attr.dev_attr.attr);
306 res = device_create_file(&pdev->dev, 308 res = device_create_file(&pdev->dev,
307 &iattr->s_attr.dev_attr); 309 &iattr->s_attr.dev_attr);
308 if (res) 310 if (res)
@@ -318,6 +320,7 @@ static int __devinit i5k_amb_hwmon_init(struct platform_device *pdev)
318 iattr->s_attr.dev_attr.show = show_amb_min; 320 iattr->s_attr.dev_attr.show = show_amb_min;
319 iattr->s_attr.dev_attr.store = store_amb_min; 321 iattr->s_attr.dev_attr.store = store_amb_min;
320 iattr->s_attr.index = k; 322 iattr->s_attr.index = k;
323 sysfs_attr_init(&iattr->s_attr.dev_attr.attr);
321 res = device_create_file(&pdev->dev, 324 res = device_create_file(&pdev->dev,
322 &iattr->s_attr.dev_attr); 325 &iattr->s_attr.dev_attr);
323 if (res) 326 if (res)
@@ -333,6 +336,7 @@ static int __devinit i5k_amb_hwmon_init(struct platform_device *pdev)
333 iattr->s_attr.dev_attr.show = show_amb_mid; 336 iattr->s_attr.dev_attr.show = show_amb_mid;
334 iattr->s_attr.dev_attr.store = store_amb_mid; 337 iattr->s_attr.dev_attr.store = store_amb_mid;
335 iattr->s_attr.index = k; 338 iattr->s_attr.index = k;
339 sysfs_attr_init(&iattr->s_attr.dev_attr.attr);
336 res = device_create_file(&pdev->dev, 340 res = device_create_file(&pdev->dev,
337 &iattr->s_attr.dev_attr); 341 &iattr->s_attr.dev_attr);
338 if (res) 342 if (res)
@@ -348,6 +352,7 @@ static int __devinit i5k_amb_hwmon_init(struct platform_device *pdev)
348 iattr->s_attr.dev_attr.show = show_amb_max; 352 iattr->s_attr.dev_attr.show = show_amb_max;
349 iattr->s_attr.dev_attr.store = store_amb_max; 353 iattr->s_attr.dev_attr.store = store_amb_max;
350 iattr->s_attr.index = k; 354 iattr->s_attr.index = k;
355 sysfs_attr_init(&iattr->s_attr.dev_attr.attr);
351 res = device_create_file(&pdev->dev, 356 res = device_create_file(&pdev->dev,
352 &iattr->s_attr.dev_attr); 357 &iattr->s_attr.dev_attr);
353 if (res) 358 if (res)
@@ -362,6 +367,7 @@ static int __devinit i5k_amb_hwmon_init(struct platform_device *pdev)
362 iattr->s_attr.dev_attr.attr.mode = S_IRUGO; 367 iattr->s_attr.dev_attr.attr.mode = S_IRUGO;
363 iattr->s_attr.dev_attr.show = show_amb_alarm; 368 iattr->s_attr.dev_attr.show = show_amb_alarm;
364 iattr->s_attr.index = k; 369 iattr->s_attr.index = k;
370 sysfs_attr_init(&iattr->s_attr.dev_attr.attr);
365 res = device_create_file(&pdev->dev, 371 res = device_create_file(&pdev->dev,
366 &iattr->s_attr.dev_attr); 372 &iattr->s_attr.dev_attr);
367 if (res) 373 if (res)
diff --git a/drivers/hwmon/it87.c b/drivers/hwmon/it87.c
index 5be09c048c5f..25763d2223b6 100644
--- a/drivers/hwmon/it87.c
+++ b/drivers/hwmon/it87.c
@@ -80,6 +80,13 @@ superio_inb(int reg)
80 return inb(VAL); 80 return inb(VAL);
81} 81}
82 82
83static inline void
84superio_outb(int reg, int val)
85{
86 outb(reg, REG);
87 outb(val, VAL);
88}
89
83static int superio_inw(int reg) 90static int superio_inw(int reg)
84{ 91{
85 int val; 92 int val;
@@ -1517,6 +1524,21 @@ static int __init it87_find(unsigned short *address,
1517 sio_data->vid_value = superio_inb(IT87_SIO_VID_REG); 1524 sio_data->vid_value = superio_inb(IT87_SIO_VID_REG);
1518 1525
1519 reg = superio_inb(IT87_SIO_PINX2_REG); 1526 reg = superio_inb(IT87_SIO_PINX2_REG);
1527 /*
1528 * The IT8720F has no VIN7 pin, so VCCH should always be
1529 * routed internally to VIN7 with an internal divider.
1530 * Curiously, there still is a configuration bit to control
1531 * this, which means it can be set incorrectly. And even
1532 * more curiously, many boards out there are improperly
1533 * configured, even though the IT8720F datasheet claims
1534 * that the internal routing of VCCH to VIN7 is the default
1535 * setting. So we force the internal routing in this case.
1536 */
1537 if (sio_data->type == it8720 && !(reg & (1 << 1))) {
1538 reg |= (1 << 1);
1539 superio_outb(IT87_SIO_PINX2_REG, reg);
1540 pr_notice("it87: Routing internal VCCH to in7\n");
1541 }
1520 if (reg & (1 << 0)) 1542 if (reg & (1 << 0))
1521 pr_info("it87: in3 is VCC (+5V)\n"); 1543 pr_info("it87: in3 is VCC (+5V)\n");
1522 if (reg & (1 << 1)) 1544 if (reg & (1 << 1))
diff --git a/drivers/hwmon/k10temp.c b/drivers/hwmon/k10temp.c
index 099a2138cdf6..da5a2404cd3e 100644
--- a/drivers/hwmon/k10temp.c
+++ b/drivers/hwmon/k10temp.c
@@ -112,11 +112,21 @@ static bool __devinit has_erratum_319(struct pci_dev *pdev)
112 if (pkg_type != CPUID_PKGTYPE_AM2R2_AM3) 112 if (pkg_type != CPUID_PKGTYPE_AM2R2_AM3)
113 return false; 113 return false;
114 114
115 /* Differentiate between AM2+ (bad) and AM3 (good) */ 115 /* DDR3 memory implies socket AM3, which is good */
116 pci_bus_read_config_dword(pdev->bus, 116 pci_bus_read_config_dword(pdev->bus,
117 PCI_DEVFN(PCI_SLOT(pdev->devfn), 2), 117 PCI_DEVFN(PCI_SLOT(pdev->devfn), 2),
118 REG_DCT0_CONFIG_HIGH, &reg_dram_cfg); 118 REG_DCT0_CONFIG_HIGH, &reg_dram_cfg);
119 return !(reg_dram_cfg & DDR3_MODE); 119 if (reg_dram_cfg & DDR3_MODE)
120 return false;
121
122 /*
123 * Unfortunately it is possible to run a socket AM3 CPU with DDR2
124 * memory. We blacklist all the cores which do exist in socket AM2+
125 * format. It still isn't perfect, as RB-C2 cores exist in both AM2+
126 * and AM3 formats, but that's the best we can do.
127 */
128 return boot_cpu_data.x86_model < 4 ||
129 (boot_cpu_data.x86_model == 4 && boot_cpu_data.x86_mask <= 2);
120} 130}
121 131
122static int __devinit k10temp_probe(struct pci_dev *pdev, 132static int __devinit k10temp_probe(struct pci_dev *pdev,
diff --git a/drivers/hwmon/k8temp.c b/drivers/hwmon/k8temp.c
index 0ceb6d6200a3..8bdf80d91598 100644
--- a/drivers/hwmon/k8temp.c
+++ b/drivers/hwmon/k8temp.c
@@ -120,7 +120,7 @@ static ssize_t show_temp(struct device *dev,
120 int temp; 120 int temp;
121 struct k8temp_data *data = k8temp_update_device(dev); 121 struct k8temp_data *data = k8temp_update_device(dev);
122 122
123 if (data->swap_core_select) 123 if (data->swap_core_select && (data->sensorsp & SEL_CORE))
124 core = core ? 0 : 1; 124 core = core ? 0 : 1;
125 125
126 temp = TEMP_FROM_REG(data->temp[core][place]) + data->temp_offset; 126 temp = TEMP_FROM_REG(data->temp[core][place]) + data->temp_offset;
@@ -180,11 +180,13 @@ static int __devinit k8temp_probe(struct pci_dev *pdev,
180 } 180 }
181 181
182 if ((model >= 0x69) && 182 if ((model >= 0x69) &&
183 !(model == 0xc1 || model == 0x6c || model == 0x7c)) { 183 !(model == 0xc1 || model == 0x6c || model == 0x7c ||
184 model == 0x6b || model == 0x6f || model == 0x7f)) {
184 /* 185 /*
185 * RevG desktop CPUs (i.e. no socket S1G1 parts) 186 * RevG desktop CPUs (i.e. no socket S1G1 or
186 * need additional offset, otherwise reported 187 * ASB1 parts) need additional offset,
187 * temperature is below ambient temperature 188 * otherwise reported temperature is below
189 * ambient temperature
188 */ 190 */
189 data->temp_offset = 21000; 191 data->temp_offset = 21000;
190 } 192 }
diff --git a/drivers/i2c/busses/i2c-i801.c b/drivers/i2c/busses/i2c-i801.c
index f4b21f2bb8ed..c60081169cc3 100644
--- a/drivers/i2c/busses/i2c-i801.c
+++ b/drivers/i2c/busses/i2c-i801.c
@@ -655,7 +655,7 @@ static void __devinit dmi_check_onboard_device(u8 type, const char *name,
655 /* & ~0x80, ignore enabled/disabled bit */ 655 /* & ~0x80, ignore enabled/disabled bit */
656 if ((type & ~0x80) != dmi_devices[i].type) 656 if ((type & ~0x80) != dmi_devices[i].type)
657 continue; 657 continue;
658 if (strcmp(name, dmi_devices[i].name)) 658 if (strcasecmp(name, dmi_devices[i].name))
659 continue; 659 continue;
660 660
661 memset(&info, 0, sizeof(struct i2c_board_info)); 661 memset(&info, 0, sizeof(struct i2c_board_info));
@@ -704,9 +704,6 @@ static int __devinit i801_probe(struct pci_dev *dev,
704{ 704{
705 unsigned char temp; 705 unsigned char temp;
706 int err, i; 706 int err, i;
707#if defined CONFIG_SENSORS_FSCHMD || defined CONFIG_SENSORS_FSCHMD_MODULE
708 const char *vendor;
709#endif
710 707
711 I801_dev = dev; 708 I801_dev = dev;
712 i801_features = 0; 709 i801_features = 0;
@@ -808,8 +805,7 @@ static int __devinit i801_probe(struct pci_dev *dev,
808 } 805 }
809#endif 806#endif
810#if defined CONFIG_SENSORS_FSCHMD || defined CONFIG_SENSORS_FSCHMD_MODULE 807#if defined CONFIG_SENSORS_FSCHMD || defined CONFIG_SENSORS_FSCHMD_MODULE
811 vendor = dmi_get_system_info(DMI_BOARD_VENDOR); 808 if (dmi_name_in_vendors("FUJITSU"))
812 if (vendor && !strcmp(vendor, "FUJITSU SIEMENS"))
813 dmi_walk(dmi_check_onboard_devices, &i801_adapter); 809 dmi_walk(dmi_check_onboard_devices, &i801_adapter);
814#endif 810#endif
815 811
diff --git a/drivers/i2c/busses/i2c-sibyte.c b/drivers/i2c/busses/i2c-sibyte.c
index 3d76a188e42f..0fe505d7abe9 100644
--- a/drivers/i2c/busses/i2c-sibyte.c
+++ b/drivers/i2c/busses/i2c-sibyte.c
@@ -94,7 +94,7 @@ static int smbus_xfer(struct i2c_adapter *i2c_adap, u16 addr,
94 } 94 }
95 break; 95 break;
96 default: 96 default:
97 return -1; /* XXXKW better error code? */ 97 return -EOPNOTSUPP;
98 } 98 }
99 99
100 while (csr_in32(SMB_CSR(adap, R_SMB_STATUS)) & M_SMB_BUSY) 100 while (csr_in32(SMB_CSR(adap, R_SMB_STATUS)) & M_SMB_BUSY)
@@ -104,7 +104,7 @@ static int smbus_xfer(struct i2c_adapter *i2c_adap, u16 addr,
104 if (error & M_SMB_ERROR) { 104 if (error & M_SMB_ERROR) {
105 /* Clear error bit by writing a 1 */ 105 /* Clear error bit by writing a 1 */
106 csr_out32(M_SMB_ERROR, SMB_CSR(adap, R_SMB_STATUS)); 106 csr_out32(M_SMB_ERROR, SMB_CSR(adap, R_SMB_STATUS));
107 return -1; /* XXXKW better error code? */ 107 return (error & M_SMB_ERROR_TYPE) ? -EIO : -ENXIO;
108 } 108 }
109 109
110 if (data_bytes == 1) 110 if (data_bytes == 1)
diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
index 1cca2631e5b3..0815e10da7c6 100644
--- a/drivers/i2c/i2c-core.c
+++ b/drivers/i2c/i2c-core.c
@@ -1428,13 +1428,12 @@ static int i2c_detect(struct i2c_adapter *adapter, struct i2c_driver *driver)
1428 if (!(adapter->class & driver->class)) 1428 if (!(adapter->class & driver->class))
1429 goto exit_free; 1429 goto exit_free;
1430 1430
1431 /* Stop here if we can't use SMBUS_QUICK */ 1431 /* Stop here if the bus doesn't support probing */
1432 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_QUICK)) { 1432 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_READ_BYTE)) {
1433 if (address_list[0] == I2C_CLIENT_END) 1433 if (address_list[0] == I2C_CLIENT_END)
1434 goto exit_free; 1434 goto exit_free;
1435 1435
1436 dev_warn(&adapter->dev, "SMBus Quick command not supported, " 1436 dev_warn(&adapter->dev, "Probing not supported\n");
1437 "can't probe for chips\n");
1438 err = -EOPNOTSUPP; 1437 err = -EOPNOTSUPP;
1439 goto exit_free; 1438 goto exit_free;
1440 } 1439 }
diff --git a/drivers/infiniband/hw/cxgb4/cm.c b/drivers/infiniband/hw/cxgb4/cm.c
index 30ce0a8eca09..855ee44fdb52 100644
--- a/drivers/infiniband/hw/cxgb4/cm.c
+++ b/drivers/infiniband/hw/cxgb4/cm.c
@@ -969,7 +969,8 @@ static void process_mpa_reply(struct c4iw_ep *ep, struct sk_buff *skb)
969 goto err; 969 goto err;
970 goto out; 970 goto out;
971err: 971err:
972 abort_connection(ep, skb, GFP_KERNEL); 972 state_set(&ep->com, ABORTING);
973 send_abort(ep, skb, GFP_KERNEL);
973out: 974out:
974 connect_reply_upcall(ep, err); 975 connect_reply_upcall(ep, err);
975 return; 976 return;
@@ -1372,7 +1373,7 @@ static int pass_accept_req(struct c4iw_dev *dev, struct sk_buff *skb)
1372 pdev, 0); 1373 pdev, 0);
1373 mtu = pdev->mtu; 1374 mtu = pdev->mtu;
1374 tx_chan = cxgb4_port_chan(pdev); 1375 tx_chan = cxgb4_port_chan(pdev);
1375 smac_idx = tx_chan << 1; 1376 smac_idx = (cxgb4_port_viid(pdev) & 0x7F) << 1;
1376 step = dev->rdev.lldi.ntxq / dev->rdev.lldi.nchan; 1377 step = dev->rdev.lldi.ntxq / dev->rdev.lldi.nchan;
1377 txq_idx = cxgb4_port_idx(pdev) * step; 1378 txq_idx = cxgb4_port_idx(pdev) * step;
1378 step = dev->rdev.lldi.nrxq / dev->rdev.lldi.nchan; 1379 step = dev->rdev.lldi.nrxq / dev->rdev.lldi.nchan;
@@ -1383,7 +1384,7 @@ static int pass_accept_req(struct c4iw_dev *dev, struct sk_buff *skb)
1383 dst->neighbour->dev, 0); 1384 dst->neighbour->dev, 0);
1384 mtu = dst_mtu(dst); 1385 mtu = dst_mtu(dst);
1385 tx_chan = cxgb4_port_chan(dst->neighbour->dev); 1386 tx_chan = cxgb4_port_chan(dst->neighbour->dev);
1386 smac_idx = tx_chan << 1; 1387 smac_idx = (cxgb4_port_viid(dst->neighbour->dev) & 0x7F) << 1;
1387 step = dev->rdev.lldi.ntxq / dev->rdev.lldi.nchan; 1388 step = dev->rdev.lldi.ntxq / dev->rdev.lldi.nchan;
1388 txq_idx = cxgb4_port_idx(dst->neighbour->dev) * step; 1389 txq_idx = cxgb4_port_idx(dst->neighbour->dev) * step;
1389 step = dev->rdev.lldi.nrxq / dev->rdev.lldi.nchan; 1390 step = dev->rdev.lldi.nrxq / dev->rdev.lldi.nchan;
@@ -1950,7 +1951,7 @@ int c4iw_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
1950 pdev, 0); 1951 pdev, 0);
1951 ep->mtu = pdev->mtu; 1952 ep->mtu = pdev->mtu;
1952 ep->tx_chan = cxgb4_port_chan(pdev); 1953 ep->tx_chan = cxgb4_port_chan(pdev);
1953 ep->smac_idx = ep->tx_chan << 1; 1954 ep->smac_idx = (cxgb4_port_viid(pdev) & 0x7F) << 1;
1954 step = ep->com.dev->rdev.lldi.ntxq / 1955 step = ep->com.dev->rdev.lldi.ntxq /
1955 ep->com.dev->rdev.lldi.nchan; 1956 ep->com.dev->rdev.lldi.nchan;
1956 ep->txq_idx = cxgb4_port_idx(pdev) * step; 1957 ep->txq_idx = cxgb4_port_idx(pdev) * step;
@@ -1965,7 +1966,8 @@ int c4iw_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
1965 ep->dst->neighbour->dev, 0); 1966 ep->dst->neighbour->dev, 0);
1966 ep->mtu = dst_mtu(ep->dst); 1967 ep->mtu = dst_mtu(ep->dst);
1967 ep->tx_chan = cxgb4_port_chan(ep->dst->neighbour->dev); 1968 ep->tx_chan = cxgb4_port_chan(ep->dst->neighbour->dev);
1968 ep->smac_idx = ep->tx_chan << 1; 1969 ep->smac_idx = (cxgb4_port_viid(ep->dst->neighbour->dev) &
1970 0x7F) << 1;
1969 step = ep->com.dev->rdev.lldi.ntxq / 1971 step = ep->com.dev->rdev.lldi.ntxq /
1970 ep->com.dev->rdev.lldi.nchan; 1972 ep->com.dev->rdev.lldi.nchan;
1971 ep->txq_idx = cxgb4_port_idx(ep->dst->neighbour->dev) * step; 1973 ep->txq_idx = cxgb4_port_idx(ep->dst->neighbour->dev) * step;
diff --git a/drivers/infiniband/hw/cxgb4/cq.c b/drivers/infiniband/hw/cxgb4/cq.c
index 2447f5295482..fac5c6e68011 100644
--- a/drivers/infiniband/hw/cxgb4/cq.c
+++ b/drivers/infiniband/hw/cxgb4/cq.c
@@ -77,7 +77,7 @@ static int destroy_cq(struct c4iw_rdev *rdev, struct t4_cq *cq,
77 kfree(cq->sw_queue); 77 kfree(cq->sw_queue);
78 dma_free_coherent(&(rdev->lldi.pdev->dev), 78 dma_free_coherent(&(rdev->lldi.pdev->dev),
79 cq->memsize, cq->queue, 79 cq->memsize, cq->queue,
80 pci_unmap_addr(cq, mapping)); 80 dma_unmap_addr(cq, mapping));
81 c4iw_put_cqid(rdev, cq->cqid, uctx); 81 c4iw_put_cqid(rdev, cq->cqid, uctx);
82 return ret; 82 return ret;
83} 83}
@@ -112,7 +112,7 @@ static int create_cq(struct c4iw_rdev *rdev, struct t4_cq *cq,
112 ret = -ENOMEM; 112 ret = -ENOMEM;
113 goto err3; 113 goto err3;
114 } 114 }
115 pci_unmap_addr_set(cq, mapping, cq->dma_addr); 115 dma_unmap_addr_set(cq, mapping, cq->dma_addr);
116 memset(cq->queue, 0, cq->memsize); 116 memset(cq->queue, 0, cq->memsize);
117 117
118 /* build fw_ri_res_wr */ 118 /* build fw_ri_res_wr */
@@ -179,7 +179,7 @@ static int create_cq(struct c4iw_rdev *rdev, struct t4_cq *cq,
179 return 0; 179 return 0;
180err4: 180err4:
181 dma_free_coherent(&rdev->lldi.pdev->dev, cq->memsize, cq->queue, 181 dma_free_coherent(&rdev->lldi.pdev->dev, cq->memsize, cq->queue,
182 pci_unmap_addr(cq, mapping)); 182 dma_unmap_addr(cq, mapping));
183err3: 183err3:
184 kfree(cq->sw_queue); 184 kfree(cq->sw_queue);
185err2: 185err2:
@@ -764,7 +764,7 @@ struct ib_cq *c4iw_create_cq(struct ib_device *ibdev, int entries,
764 struct c4iw_create_cq_resp uresp; 764 struct c4iw_create_cq_resp uresp;
765 struct c4iw_ucontext *ucontext = NULL; 765 struct c4iw_ucontext *ucontext = NULL;
766 int ret; 766 int ret;
767 size_t memsize; 767 size_t memsize, hwentries;
768 struct c4iw_mm_entry *mm, *mm2; 768 struct c4iw_mm_entry *mm, *mm2;
769 769
770 PDBG("%s ib_dev %p entries %d\n", __func__, ibdev, entries); 770 PDBG("%s ib_dev %p entries %d\n", __func__, ibdev, entries);
@@ -788,14 +788,29 @@ struct ib_cq *c4iw_create_cq(struct ib_device *ibdev, int entries,
788 * entries must be multiple of 16 for HW. 788 * entries must be multiple of 16 for HW.
789 */ 789 */
790 entries = roundup(entries, 16); 790 entries = roundup(entries, 16);
791 memsize = entries * sizeof *chp->cq.queue; 791
792 /*
793 * Make actual HW queue 2x to avoid cdix_inc overflows.
794 */
795 hwentries = entries * 2;
796
797 /*
798 * Make HW queue at least 64 entries so GTS updates aren't too
799 * frequent.
800 */
801 if (hwentries < 64)
802 hwentries = 64;
803
804 memsize = hwentries * sizeof *chp->cq.queue;
792 805
793 /* 806 /*
794 * memsize must be a multiple of the page size if its a user cq. 807 * memsize must be a multiple of the page size if its a user cq.
795 */ 808 */
796 if (ucontext) 809 if (ucontext) {
797 memsize = roundup(memsize, PAGE_SIZE); 810 memsize = roundup(memsize, PAGE_SIZE);
798 chp->cq.size = entries; 811 hwentries = memsize / sizeof *chp->cq.queue;
812 }
813 chp->cq.size = hwentries;
799 chp->cq.memsize = memsize; 814 chp->cq.memsize = memsize;
800 815
801 ret = create_cq(&rhp->rdev, &chp->cq, 816 ret = create_cq(&rhp->rdev, &chp->cq,
@@ -805,7 +820,7 @@ struct ib_cq *c4iw_create_cq(struct ib_device *ibdev, int entries,
805 820
806 chp->rhp = rhp; 821 chp->rhp = rhp;
807 chp->cq.size--; /* status page */ 822 chp->cq.size--; /* status page */
808 chp->ibcq.cqe = chp->cq.size - 1; 823 chp->ibcq.cqe = entries - 2;
809 spin_lock_init(&chp->lock); 824 spin_lock_init(&chp->lock);
810 atomic_set(&chp->refcnt, 1); 825 atomic_set(&chp->refcnt, 1);
811 init_waitqueue_head(&chp->wait); 826 init_waitqueue_head(&chp->wait);
diff --git a/drivers/infiniband/hw/cxgb4/iw_cxgb4.h b/drivers/infiniband/hw/cxgb4/iw_cxgb4.h
index 277ab589b44d..d33e1a668811 100644
--- a/drivers/infiniband/hw/cxgb4/iw_cxgb4.h
+++ b/drivers/infiniband/hw/cxgb4/iw_cxgb4.h
@@ -261,7 +261,7 @@ static inline struct c4iw_mw *to_c4iw_mw(struct ib_mw *ibmw)
261 261
262struct c4iw_fr_page_list { 262struct c4iw_fr_page_list {
263 struct ib_fast_reg_page_list ibpl; 263 struct ib_fast_reg_page_list ibpl;
264 DECLARE_PCI_UNMAP_ADDR(mapping); 264 DEFINE_DMA_UNMAP_ADDR(mapping);
265 dma_addr_t dma_addr; 265 dma_addr_t dma_addr;
266 struct c4iw_dev *dev; 266 struct c4iw_dev *dev;
267 int size; 267 int size;
diff --git a/drivers/infiniband/hw/cxgb4/mem.c b/drivers/infiniband/hw/cxgb4/mem.c
index 7f94da1a2437..82b5703b8947 100644
--- a/drivers/infiniband/hw/cxgb4/mem.c
+++ b/drivers/infiniband/hw/cxgb4/mem.c
@@ -764,7 +764,7 @@ struct ib_fast_reg_page_list *c4iw_alloc_fastreg_pbl(struct ib_device *device,
764 if (!c4pl) 764 if (!c4pl)
765 return ERR_PTR(-ENOMEM); 765 return ERR_PTR(-ENOMEM);
766 766
767 pci_unmap_addr_set(c4pl, mapping, dma_addr); 767 dma_unmap_addr_set(c4pl, mapping, dma_addr);
768 c4pl->dma_addr = dma_addr; 768 c4pl->dma_addr = dma_addr;
769 c4pl->dev = dev; 769 c4pl->dev = dev;
770 c4pl->size = size; 770 c4pl->size = size;
@@ -779,7 +779,7 @@ void c4iw_free_fastreg_pbl(struct ib_fast_reg_page_list *ibpl)
779 struct c4iw_fr_page_list *c4pl = to_c4iw_fr_page_list(ibpl); 779 struct c4iw_fr_page_list *c4pl = to_c4iw_fr_page_list(ibpl);
780 780
781 dma_free_coherent(&c4pl->dev->rdev.lldi.pdev->dev, c4pl->size, 781 dma_free_coherent(&c4pl->dev->rdev.lldi.pdev->dev, c4pl->size,
782 c4pl, pci_unmap_addr(c4pl, mapping)); 782 c4pl, dma_unmap_addr(c4pl, mapping));
783} 783}
784 784
785int c4iw_dereg_mr(struct ib_mr *ib_mr) 785int c4iw_dereg_mr(struct ib_mr *ib_mr)
diff --git a/drivers/infiniband/hw/cxgb4/qp.c b/drivers/infiniband/hw/cxgb4/qp.c
index 646a2a5711f2..86b93f2ecca3 100644
--- a/drivers/infiniband/hw/cxgb4/qp.c
+++ b/drivers/infiniband/hw/cxgb4/qp.c
@@ -40,10 +40,10 @@ static int destroy_qp(struct c4iw_rdev *rdev, struct t4_wq *wq,
40 */ 40 */
41 dma_free_coherent(&(rdev->lldi.pdev->dev), 41 dma_free_coherent(&(rdev->lldi.pdev->dev),
42 wq->rq.memsize, wq->rq.queue, 42 wq->rq.memsize, wq->rq.queue,
43 pci_unmap_addr(&wq->rq, mapping)); 43 dma_unmap_addr(&wq->rq, mapping));
44 dma_free_coherent(&(rdev->lldi.pdev->dev), 44 dma_free_coherent(&(rdev->lldi.pdev->dev),
45 wq->sq.memsize, wq->sq.queue, 45 wq->sq.memsize, wq->sq.queue,
46 pci_unmap_addr(&wq->sq, mapping)); 46 dma_unmap_addr(&wq->sq, mapping));
47 c4iw_rqtpool_free(rdev, wq->rq.rqt_hwaddr, wq->rq.rqt_size); 47 c4iw_rqtpool_free(rdev, wq->rq.rqt_hwaddr, wq->rq.rqt_size);
48 kfree(wq->rq.sw_rq); 48 kfree(wq->rq.sw_rq);
49 kfree(wq->sq.sw_sq); 49 kfree(wq->sq.sw_sq);
@@ -99,7 +99,7 @@ static int create_qp(struct c4iw_rdev *rdev, struct t4_wq *wq,
99 if (!wq->sq.queue) 99 if (!wq->sq.queue)
100 goto err5; 100 goto err5;
101 memset(wq->sq.queue, 0, wq->sq.memsize); 101 memset(wq->sq.queue, 0, wq->sq.memsize);
102 pci_unmap_addr_set(&wq->sq, mapping, wq->sq.dma_addr); 102 dma_unmap_addr_set(&wq->sq, mapping, wq->sq.dma_addr);
103 103
104 wq->rq.queue = dma_alloc_coherent(&(rdev->lldi.pdev->dev), 104 wq->rq.queue = dma_alloc_coherent(&(rdev->lldi.pdev->dev),
105 wq->rq.memsize, &(wq->rq.dma_addr), 105 wq->rq.memsize, &(wq->rq.dma_addr),
@@ -112,7 +112,7 @@ static int create_qp(struct c4iw_rdev *rdev, struct t4_wq *wq,
112 wq->rq.queue, 112 wq->rq.queue,
113 (unsigned long long)virt_to_phys(wq->rq.queue)); 113 (unsigned long long)virt_to_phys(wq->rq.queue));
114 memset(wq->rq.queue, 0, wq->rq.memsize); 114 memset(wq->rq.queue, 0, wq->rq.memsize);
115 pci_unmap_addr_set(&wq->rq, mapping, wq->rq.dma_addr); 115 dma_unmap_addr_set(&wq->rq, mapping, wq->rq.dma_addr);
116 116
117 wq->db = rdev->lldi.db_reg; 117 wq->db = rdev->lldi.db_reg;
118 wq->gts = rdev->lldi.gts_reg; 118 wq->gts = rdev->lldi.gts_reg;
@@ -217,11 +217,11 @@ static int create_qp(struct c4iw_rdev *rdev, struct t4_wq *wq,
217err7: 217err7:
218 dma_free_coherent(&(rdev->lldi.pdev->dev), 218 dma_free_coherent(&(rdev->lldi.pdev->dev),
219 wq->rq.memsize, wq->rq.queue, 219 wq->rq.memsize, wq->rq.queue,
220 pci_unmap_addr(&wq->rq, mapping)); 220 dma_unmap_addr(&wq->rq, mapping));
221err6: 221err6:
222 dma_free_coherent(&(rdev->lldi.pdev->dev), 222 dma_free_coherent(&(rdev->lldi.pdev->dev),
223 wq->sq.memsize, wq->sq.queue, 223 wq->sq.memsize, wq->sq.queue,
224 pci_unmap_addr(&wq->sq, mapping)); 224 dma_unmap_addr(&wq->sq, mapping));
225err5: 225err5:
226 c4iw_rqtpool_free(rdev, wq->rq.rqt_hwaddr, wq->rq.rqt_size); 226 c4iw_rqtpool_free(rdev, wq->rq.rqt_hwaddr, wq->rq.rqt_size);
227err4: 227err4:
diff --git a/drivers/infiniband/hw/cxgb4/t4.h b/drivers/infiniband/hw/cxgb4/t4.h
index 1057cb96302e..9cf8d85bfcff 100644
--- a/drivers/infiniband/hw/cxgb4/t4.h
+++ b/drivers/infiniband/hw/cxgb4/t4.h
@@ -279,7 +279,7 @@ struct t4_swsqe {
279struct t4_sq { 279struct t4_sq {
280 union t4_wr *queue; 280 union t4_wr *queue;
281 dma_addr_t dma_addr; 281 dma_addr_t dma_addr;
282 DECLARE_PCI_UNMAP_ADDR(mapping); 282 DEFINE_DMA_UNMAP_ADDR(mapping);
283 struct t4_swsqe *sw_sq; 283 struct t4_swsqe *sw_sq;
284 struct t4_swsqe *oldest_read; 284 struct t4_swsqe *oldest_read;
285 u64 udb; 285 u64 udb;
@@ -298,7 +298,7 @@ struct t4_swrqe {
298struct t4_rq { 298struct t4_rq {
299 union t4_recv_wr *queue; 299 union t4_recv_wr *queue;
300 dma_addr_t dma_addr; 300 dma_addr_t dma_addr;
301 DECLARE_PCI_UNMAP_ADDR(mapping); 301 DEFINE_DMA_UNMAP_ADDR(mapping);
302 struct t4_swrqe *sw_rq; 302 struct t4_swrqe *sw_rq;
303 u64 udb; 303 u64 udb;
304 size_t memsize; 304 size_t memsize;
@@ -429,7 +429,7 @@ static inline int t4_wq_db_enabled(struct t4_wq *wq)
429struct t4_cq { 429struct t4_cq {
430 struct t4_cqe *queue; 430 struct t4_cqe *queue;
431 dma_addr_t dma_addr; 431 dma_addr_t dma_addr;
432 DECLARE_PCI_UNMAP_ADDR(mapping); 432 DEFINE_DMA_UNMAP_ADDR(mapping);
433 struct t4_cqe *sw_queue; 433 struct t4_cqe *sw_queue;
434 void __iomem *gts; 434 void __iomem *gts;
435 struct c4iw_rdev *rdev; 435 struct c4iw_rdev *rdev;
diff --git a/drivers/infiniband/hw/qib/Makefile b/drivers/infiniband/hw/qib/Makefile
index c6515a1b9a6a..f12d7bb8b39f 100644
--- a/drivers/infiniband/hw/qib/Makefile
+++ b/drivers/infiniband/hw/qib/Makefile
@@ -6,7 +6,7 @@ ib_qib-y := qib_cq.o qib_diag.o qib_dma.o qib_driver.o qib_eeprom.o \
6 qib_qp.o qib_qsfp.o qib_rc.o qib_ruc.o qib_sdma.o qib_srq.o \ 6 qib_qp.o qib_qsfp.o qib_rc.o qib_ruc.o qib_sdma.o qib_srq.o \
7 qib_sysfs.o qib_twsi.o qib_tx.o qib_uc.o qib_ud.o \ 7 qib_sysfs.o qib_twsi.o qib_tx.o qib_uc.o qib_ud.o \
8 qib_user_pages.o qib_user_sdma.o qib_verbs_mcast.o qib_iba7220.o \ 8 qib_user_pages.o qib_user_sdma.o qib_verbs_mcast.o qib_iba7220.o \
9 qib_sd7220.o qib_sd7220_img.o qib_iba7322.o qib_verbs.o 9 qib_sd7220.o qib_iba7322.o qib_verbs.o
10 10
11# 6120 has no fallback if no MSI interrupts, others can do INTx 11# 6120 has no fallback if no MSI interrupts, others can do INTx
12ib_qib-$(CONFIG_PCI_MSI) += qib_iba6120.o 12ib_qib-$(CONFIG_PCI_MSI) += qib_iba6120.o
diff --git a/drivers/infiniband/hw/qib/qib.h b/drivers/infiniband/hw/qib/qib.h
index 32d9208efcff..3593983df7ba 100644
--- a/drivers/infiniband/hw/qib/qib.h
+++ b/drivers/infiniband/hw/qib/qib.h
@@ -686,6 +686,7 @@ struct qib_devdata {
686 void __iomem *piobase; 686 void __iomem *piobase;
687 /* mem-mapped pointer to base of user chip regs (if using WC PAT) */ 687 /* mem-mapped pointer to base of user chip regs (if using WC PAT) */
688 u64 __iomem *userbase; 688 u64 __iomem *userbase;
689 void __iomem *piovl15base; /* base of VL15 buffers, if not WC */
689 /* 690 /*
690 * points to area where PIOavail registers will be DMA'ed. 691 * points to area where PIOavail registers will be DMA'ed.
691 * Has to be on a page of it's own, because the page will be 692 * Has to be on a page of it's own, because the page will be
diff --git a/drivers/infiniband/hw/qib/qib_7220.h b/drivers/infiniband/hw/qib/qib_7220.h
index ea0bfd896f92..21f374aa0631 100644
--- a/drivers/infiniband/hw/qib/qib_7220.h
+++ b/drivers/infiniband/hw/qib/qib_7220.h
@@ -109,10 +109,6 @@ struct qib_chippport_specific {
109 */ 109 */
110int qib_sd7220_presets(struct qib_devdata *dd); 110int qib_sd7220_presets(struct qib_devdata *dd);
111int qib_sd7220_init(struct qib_devdata *dd); 111int qib_sd7220_init(struct qib_devdata *dd);
112int qib_sd7220_prog_ld(struct qib_devdata *dd, int sdnum, u8 *img,
113 int len, int offset);
114int qib_sd7220_prog_vfy(struct qib_devdata *dd, int sdnum, const u8 *img,
115 int len, int offset);
116void qib_sd7220_clr_ibpar(struct qib_devdata *); 112void qib_sd7220_clr_ibpar(struct qib_devdata *);
117/* 113/*
118 * Below used for sdnum parameter, selecting one of the two sections 114 * Below used for sdnum parameter, selecting one of the two sections
@@ -121,9 +117,6 @@ void qib_sd7220_clr_ibpar(struct qib_devdata *);
121 */ 117 */
122#define IB_7220_SERDES 2 118#define IB_7220_SERDES 2
123 119
124int qib_sd7220_ib_load(struct qib_devdata *dd);
125int qib_sd7220_ib_vfy(struct qib_devdata *dd);
126
127static inline u32 qib_read_kreg32(const struct qib_devdata *dd, 120static inline u32 qib_read_kreg32(const struct qib_devdata *dd,
128 const u16 regno) 121 const u16 regno)
129{ 122{
diff --git a/drivers/infiniband/hw/qib/qib_7322_regs.h b/drivers/infiniband/hw/qib/qib_7322_regs.h
index a97440ba924c..32dc81ff8d4a 100644
--- a/drivers/infiniband/hw/qib/qib_7322_regs.h
+++ b/drivers/infiniband/hw/qib/qib_7322_regs.h
@@ -742,15 +742,15 @@
742#define QIB_7322_HwErrMask_IBCBusFromSPCParityErrMask_1_LSB 0xF 742#define QIB_7322_HwErrMask_IBCBusFromSPCParityErrMask_1_LSB 0xF
743#define QIB_7322_HwErrMask_IBCBusFromSPCParityErrMask_1_MSB 0xF 743#define QIB_7322_HwErrMask_IBCBusFromSPCParityErrMask_1_MSB 0xF
744#define QIB_7322_HwErrMask_IBCBusFromSPCParityErrMask_1_RMASK 0x1 744#define QIB_7322_HwErrMask_IBCBusFromSPCParityErrMask_1_RMASK 0x1
745#define QIB_7322_HwErrMask_statusValidNoEopMask_1_LSB 0xE 745#define QIB_7322_HwErrMask_IBCBusToSPCParityErrMask_1_LSB 0xE
746#define QIB_7322_HwErrMask_statusValidNoEopMask_1_MSB 0xE 746#define QIB_7322_HwErrMask_IBCBusToSPCParityErrMask_1_MSB 0xE
747#define QIB_7322_HwErrMask_statusValidNoEopMask_1_RMASK 0x1 747#define QIB_7322_HwErrMask_IBCBusToSPCParityErrMask_1_RMASK 0x1
748#define QIB_7322_HwErrMask_IBCBusFromSPCParityErrMask_0_LSB 0xD 748#define QIB_7322_HwErrMask_IBCBusFromSPCParityErrMask_0_LSB 0xD
749#define QIB_7322_HwErrMask_IBCBusFromSPCParityErrMask_0_MSB 0xD 749#define QIB_7322_HwErrMask_IBCBusFromSPCParityErrMask_0_MSB 0xD
750#define QIB_7322_HwErrMask_IBCBusFromSPCParityErrMask_0_RMASK 0x1 750#define QIB_7322_HwErrMask_IBCBusFromSPCParityErrMask_0_RMASK 0x1
751#define QIB_7322_HwErrMask_statusValidNoEopMask_0_LSB 0xC 751#define QIB_7322_HwErrMask_statusValidNoEopMask_LSB 0xC
752#define QIB_7322_HwErrMask_statusValidNoEopMask_0_MSB 0xC 752#define QIB_7322_HwErrMask_statusValidNoEopMask_MSB 0xC
753#define QIB_7322_HwErrMask_statusValidNoEopMask_0_RMASK 0x1 753#define QIB_7322_HwErrMask_statusValidNoEopMask_RMASK 0x1
754#define QIB_7322_HwErrMask_LATriggeredMask_LSB 0xB 754#define QIB_7322_HwErrMask_LATriggeredMask_LSB 0xB
755#define QIB_7322_HwErrMask_LATriggeredMask_MSB 0xB 755#define QIB_7322_HwErrMask_LATriggeredMask_MSB 0xB
756#define QIB_7322_HwErrMask_LATriggeredMask_RMASK 0x1 756#define QIB_7322_HwErrMask_LATriggeredMask_RMASK 0x1
@@ -796,15 +796,15 @@
796#define QIB_7322_HwErrStatus_IBCBusFromSPCParityErr_1_LSB 0xF 796#define QIB_7322_HwErrStatus_IBCBusFromSPCParityErr_1_LSB 0xF
797#define QIB_7322_HwErrStatus_IBCBusFromSPCParityErr_1_MSB 0xF 797#define QIB_7322_HwErrStatus_IBCBusFromSPCParityErr_1_MSB 0xF
798#define QIB_7322_HwErrStatus_IBCBusFromSPCParityErr_1_RMASK 0x1 798#define QIB_7322_HwErrStatus_IBCBusFromSPCParityErr_1_RMASK 0x1
799#define QIB_7322_HwErrStatus_statusValidNoEop_1_LSB 0xE 799#define QIB_7322_HwErrStatus_IBCBusToSPCParityErr_1_LSB 0xE
800#define QIB_7322_HwErrStatus_statusValidNoEop_1_MSB 0xE 800#define QIB_7322_HwErrStatus_IBCBusToSPCParityErr_1_MSB 0xE
801#define QIB_7322_HwErrStatus_statusValidNoEop_1_RMASK 0x1 801#define QIB_7322_HwErrStatus_IBCBusToSPCParityErr_1_RMASK 0x1
802#define QIB_7322_HwErrStatus_IBCBusFromSPCParityErr_0_LSB 0xD 802#define QIB_7322_HwErrStatus_IBCBusFromSPCParityErr_0_LSB 0xD
803#define QIB_7322_HwErrStatus_IBCBusFromSPCParityErr_0_MSB 0xD 803#define QIB_7322_HwErrStatus_IBCBusFromSPCParityErr_0_MSB 0xD
804#define QIB_7322_HwErrStatus_IBCBusFromSPCParityErr_0_RMASK 0x1 804#define QIB_7322_HwErrStatus_IBCBusFromSPCParityErr_0_RMASK 0x1
805#define QIB_7322_HwErrStatus_statusValidNoEop_0_LSB 0xC 805#define QIB_7322_HwErrStatus_statusValidNoEop_LSB 0xC
806#define QIB_7322_HwErrStatus_statusValidNoEop_0_MSB 0xC 806#define QIB_7322_HwErrStatus_statusValidNoEop_MSB 0xC
807#define QIB_7322_HwErrStatus_statusValidNoEop_0_RMASK 0x1 807#define QIB_7322_HwErrStatus_statusValidNoEop_RMASK 0x1
808#define QIB_7322_HwErrStatus_LATriggered_LSB 0xB 808#define QIB_7322_HwErrStatus_LATriggered_LSB 0xB
809#define QIB_7322_HwErrStatus_LATriggered_MSB 0xB 809#define QIB_7322_HwErrStatus_LATriggered_MSB 0xB
810#define QIB_7322_HwErrStatus_LATriggered_RMASK 0x1 810#define QIB_7322_HwErrStatus_LATriggered_RMASK 0x1
@@ -850,15 +850,15 @@
850#define QIB_7322_HwErrClear_IBCBusFromSPCParityErrClear_1_LSB 0xF 850#define QIB_7322_HwErrClear_IBCBusFromSPCParityErrClear_1_LSB 0xF
851#define QIB_7322_HwErrClear_IBCBusFromSPCParityErrClear_1_MSB 0xF 851#define QIB_7322_HwErrClear_IBCBusFromSPCParityErrClear_1_MSB 0xF
852#define QIB_7322_HwErrClear_IBCBusFromSPCParityErrClear_1_RMASK 0x1 852#define QIB_7322_HwErrClear_IBCBusFromSPCParityErrClear_1_RMASK 0x1
853#define QIB_7322_HwErrClear_IBCBusToSPCparityErrClear_1_LSB 0xE 853#define QIB_7322_HwErrClear_IBCBusToSPCParityErrClear_1_LSB 0xE
854#define QIB_7322_HwErrClear_IBCBusToSPCparityErrClear_1_MSB 0xE 854#define QIB_7322_HwErrClear_IBCBusToSPCParityErrClear_1_MSB 0xE
855#define QIB_7322_HwErrClear_IBCBusToSPCparityErrClear_1_RMASK 0x1 855#define QIB_7322_HwErrClear_IBCBusToSPCParityErrClear_1_RMASK 0x1
856#define QIB_7322_HwErrClear_IBCBusFromSPCParityErrClear_0_LSB 0xD 856#define QIB_7322_HwErrClear_IBCBusFromSPCParityErrClear_0_LSB 0xD
857#define QIB_7322_HwErrClear_IBCBusFromSPCParityErrClear_0_MSB 0xD 857#define QIB_7322_HwErrClear_IBCBusFromSPCParityErrClear_0_MSB 0xD
858#define QIB_7322_HwErrClear_IBCBusFromSPCParityErrClear_0_RMASK 0x1 858#define QIB_7322_HwErrClear_IBCBusFromSPCParityErrClear_0_RMASK 0x1
859#define QIB_7322_HwErrClear_IBCBusToSPCparityErrClear_0_LSB 0xC 859#define QIB_7322_HwErrClear_statusValidNoEopClear_LSB 0xC
860#define QIB_7322_HwErrClear_IBCBusToSPCparityErrClear_0_MSB 0xC 860#define QIB_7322_HwErrClear_statusValidNoEopClear_MSB 0xC
861#define QIB_7322_HwErrClear_IBCBusToSPCparityErrClear_0_RMASK 0x1 861#define QIB_7322_HwErrClear_statusValidNoEopClear_RMASK 0x1
862#define QIB_7322_HwErrClear_LATriggeredClear_LSB 0xB 862#define QIB_7322_HwErrClear_LATriggeredClear_LSB 0xB
863#define QIB_7322_HwErrClear_LATriggeredClear_MSB 0xB 863#define QIB_7322_HwErrClear_LATriggeredClear_MSB 0xB
864#define QIB_7322_HwErrClear_LATriggeredClear_RMASK 0x1 864#define QIB_7322_HwErrClear_LATriggeredClear_RMASK 0x1
@@ -880,15 +880,15 @@
880#define QIB_7322_HwDiagCtrl_ForceIBCBusFromSPCParityErr_1_LSB 0xF 880#define QIB_7322_HwDiagCtrl_ForceIBCBusFromSPCParityErr_1_LSB 0xF
881#define QIB_7322_HwDiagCtrl_ForceIBCBusFromSPCParityErr_1_MSB 0xF 881#define QIB_7322_HwDiagCtrl_ForceIBCBusFromSPCParityErr_1_MSB 0xF
882#define QIB_7322_HwDiagCtrl_ForceIBCBusFromSPCParityErr_1_RMASK 0x1 882#define QIB_7322_HwDiagCtrl_ForceIBCBusFromSPCParityErr_1_RMASK 0x1
883#define QIB_7322_HwDiagCtrl_ForcestatusValidNoEop_1_LSB 0xE 883#define QIB_7322_HwDiagCtrl_ForceIBCBusToSPCParityErr_1_LSB 0xE
884#define QIB_7322_HwDiagCtrl_ForcestatusValidNoEop_1_MSB 0xE 884#define QIB_7322_HwDiagCtrl_ForceIBCBusToSPCParityErr_1_MSB 0xE
885#define QIB_7322_HwDiagCtrl_ForcestatusValidNoEop_1_RMASK 0x1 885#define QIB_7322_HwDiagCtrl_ForceIBCBusToSPCParityErr_1_RMASK 0x1
886#define QIB_7322_HwDiagCtrl_ForceIBCBusFromSPCParityErr_0_LSB 0xD 886#define QIB_7322_HwDiagCtrl_ForceIBCBusFromSPCParityErr_0_LSB 0xD
887#define QIB_7322_HwDiagCtrl_ForceIBCBusFromSPCParityErr_0_MSB 0xD 887#define QIB_7322_HwDiagCtrl_ForceIBCBusFromSPCParityErr_0_MSB 0xD
888#define QIB_7322_HwDiagCtrl_ForceIBCBusFromSPCParityErr_0_RMASK 0x1 888#define QIB_7322_HwDiagCtrl_ForceIBCBusFromSPCParityErr_0_RMASK 0x1
889#define QIB_7322_HwDiagCtrl_ForcestatusValidNoEop_0_LSB 0xC 889#define QIB_7322_HwDiagCtrl_ForceIBCBusToSPCParityErr_0_LSB 0xC
890#define QIB_7322_HwDiagCtrl_ForcestatusValidNoEop_0_MSB 0xC 890#define QIB_7322_HwDiagCtrl_ForceIBCBusToSPCParityErr_0_MSB 0xC
891#define QIB_7322_HwDiagCtrl_ForcestatusValidNoEop_0_RMASK 0x1 891#define QIB_7322_HwDiagCtrl_ForceIBCBusToSPCParityErr_0_RMASK 0x1
892 892
893#define QIB_7322_EXTStatus_OFFS 0xC0 893#define QIB_7322_EXTStatus_OFFS 0xC0
894#define QIB_7322_EXTStatus_DEF 0x000000000000X000 894#define QIB_7322_EXTStatus_DEF 0x000000000000X000
diff --git a/drivers/infiniband/hw/qib/qib_diag.c b/drivers/infiniband/hw/qib/qib_diag.c
index ca98dd523752..05dcf0d9a7d3 100644
--- a/drivers/infiniband/hw/qib/qib_diag.c
+++ b/drivers/infiniband/hw/qib/qib_diag.c
@@ -233,6 +233,7 @@ static u32 __iomem *qib_remap_ioaddr32(struct qib_devdata *dd, u32 offset,
233 u32 __iomem *krb32 = (u32 __iomem *)dd->kregbase; 233 u32 __iomem *krb32 = (u32 __iomem *)dd->kregbase;
234 u32 __iomem *map = NULL; 234 u32 __iomem *map = NULL;
235 u32 cnt = 0; 235 u32 cnt = 0;
236 u32 tot4k, offs4k;
236 237
237 /* First, simplest case, offset is within the first map. */ 238 /* First, simplest case, offset is within the first map. */
238 kreglen = (dd->kregend - dd->kregbase) * sizeof(u64); 239 kreglen = (dd->kregend - dd->kregbase) * sizeof(u64);
@@ -250,7 +251,8 @@ static u32 __iomem *qib_remap_ioaddr32(struct qib_devdata *dd, u32 offset,
250 if (dd->userbase) { 251 if (dd->userbase) {
251 /* If user regs mapped, they are after send, so set limit. */ 252 /* If user regs mapped, they are after send, so set limit. */
252 u32 ulim = (dd->cfgctxts * dd->ureg_align) + dd->uregbase; 253 u32 ulim = (dd->cfgctxts * dd->ureg_align) + dd->uregbase;
253 snd_lim = dd->uregbase; 254 if (!dd->piovl15base)
255 snd_lim = dd->uregbase;
254 krb32 = (u32 __iomem *)dd->userbase; 256 krb32 = (u32 __iomem *)dd->userbase;
255 if (offset >= dd->uregbase && offset < ulim) { 257 if (offset >= dd->uregbase && offset < ulim) {
256 map = krb32 + (offset - dd->uregbase) / sizeof(u32); 258 map = krb32 + (offset - dd->uregbase) / sizeof(u32);
@@ -277,14 +279,14 @@ static u32 __iomem *qib_remap_ioaddr32(struct qib_devdata *dd, u32 offset,
277 /* If 4k buffers exist, account for them by bumping 279 /* If 4k buffers exist, account for them by bumping
278 * appropriate limit. 280 * appropriate limit.
279 */ 281 */
282 tot4k = dd->piobcnt4k * dd->align4k;
283 offs4k = dd->piobufbase >> 32;
280 if (dd->piobcnt4k) { 284 if (dd->piobcnt4k) {
281 u32 tot4k = dd->piobcnt4k * dd->align4k;
282 u32 offs4k = dd->piobufbase >> 32;
283 if (snd_bottom > offs4k) 285 if (snd_bottom > offs4k)
284 snd_bottom = offs4k; 286 snd_bottom = offs4k;
285 else { 287 else {
286 /* 4k above 2k. Bump snd_lim, if needed*/ 288 /* 4k above 2k. Bump snd_lim, if needed*/
287 if (!dd->userbase) 289 if (!dd->userbase || dd->piovl15base)
288 snd_lim = offs4k + tot4k; 290 snd_lim = offs4k + tot4k;
289 } 291 }
290 } 292 }
@@ -298,6 +300,15 @@ static u32 __iomem *qib_remap_ioaddr32(struct qib_devdata *dd, u32 offset,
298 cnt = snd_lim - offset; 300 cnt = snd_lim - offset;
299 } 301 }
300 302
303 if (!map && offs4k && dd->piovl15base) {
304 snd_lim = offs4k + tot4k + 2 * dd->align4k;
305 if (offset >= (offs4k + tot4k) && offset < snd_lim) {
306 map = (u32 __iomem *)dd->piovl15base +
307 ((offset - (offs4k + tot4k)) / sizeof(u32));
308 cnt = snd_lim - offset;
309 }
310 }
311
301mapped: 312mapped:
302 if (cntp) 313 if (cntp)
303 *cntp = cnt; 314 *cntp = cnt;
diff --git a/drivers/infiniband/hw/qib/qib_iba6120.c b/drivers/infiniband/hw/qib/qib_iba6120.c
index 1eadadc13da8..a5e29dbb9537 100644
--- a/drivers/infiniband/hw/qib/qib_iba6120.c
+++ b/drivers/infiniband/hw/qib/qib_iba6120.c
@@ -1355,8 +1355,7 @@ static int qib_6120_bringup_serdes(struct qib_pportdata *ppd)
1355 hwstat = qib_read_kreg64(dd, kr_hwerrstatus); 1355 hwstat = qib_read_kreg64(dd, kr_hwerrstatus);
1356 if (hwstat) { 1356 if (hwstat) {
1357 /* should just have PLL, clear all set, in an case */ 1357 /* should just have PLL, clear all set, in an case */
1358 if (hwstat & ~QLOGIC_IB_HWE_SERDESPLLFAILED) 1358 qib_write_kreg(dd, kr_hwerrclear, hwstat);
1359 qib_write_kreg(dd, kr_hwerrclear, hwstat);
1360 qib_write_kreg(dd, kr_errclear, ERR_MASK(HardwareErr)); 1359 qib_write_kreg(dd, kr_errclear, ERR_MASK(HardwareErr));
1361 } 1360 }
1362 1361
diff --git a/drivers/infiniband/hw/qib/qib_iba7322.c b/drivers/infiniband/hw/qib/qib_iba7322.c
index 503992d9c5ce..5eedf83e2c3b 100644
--- a/drivers/infiniband/hw/qib/qib_iba7322.c
+++ b/drivers/infiniband/hw/qib/qib_iba7322.c
@@ -543,7 +543,7 @@ struct vendor_txdds_ent {
543static void write_tx_serdes_param(struct qib_pportdata *, struct txdds_ent *); 543static void write_tx_serdes_param(struct qib_pportdata *, struct txdds_ent *);
544 544
545#define TXDDS_TABLE_SZ 16 /* number of entries per speed in onchip table */ 545#define TXDDS_TABLE_SZ 16 /* number of entries per speed in onchip table */
546#define TXDDS_EXTRA_SZ 11 /* number of extra tx settings entries */ 546#define TXDDS_EXTRA_SZ 13 /* number of extra tx settings entries */
547#define SERDES_CHANS 4 /* yes, it's obvious, but one less magic number */ 547#define SERDES_CHANS 4 /* yes, it's obvious, but one less magic number */
548 548
549#define H1_FORCE_VAL 8 549#define H1_FORCE_VAL 8
@@ -1100,9 +1100,9 @@ static const struct qib_hwerror_msgs qib_7322_hwerror_msgs[] = {
1100 HWE_AUTO_P(SDmaMemReadErr, 1), 1100 HWE_AUTO_P(SDmaMemReadErr, 1),
1101 HWE_AUTO_P(SDmaMemReadErr, 0), 1101 HWE_AUTO_P(SDmaMemReadErr, 0),
1102 HWE_AUTO_P(IBCBusFromSPCParityErr, 1), 1102 HWE_AUTO_P(IBCBusFromSPCParityErr, 1),
1103 HWE_AUTO_P(IBCBusToSPCParityErr, 1),
1103 HWE_AUTO_P(IBCBusFromSPCParityErr, 0), 1104 HWE_AUTO_P(IBCBusFromSPCParityErr, 0),
1104 HWE_AUTO_P(statusValidNoEop, 1), 1105 HWE_AUTO(statusValidNoEop),
1105 HWE_AUTO_P(statusValidNoEop, 0),
1106 HWE_AUTO(LATriggered), 1106 HWE_AUTO(LATriggered),
1107 { .mask = 0 } 1107 { .mask = 0 }
1108}; 1108};
@@ -4763,6 +4763,8 @@ static void qib_7322_mini_pcs_reset(struct qib_pportdata *ppd)
4763 SYM_MASK(IBPCSConfig_0, tx_rx_reset); 4763 SYM_MASK(IBPCSConfig_0, tx_rx_reset);
4764 4764
4765 val = qib_read_kreg_port(ppd, krp_ib_pcsconfig); 4765 val = qib_read_kreg_port(ppd, krp_ib_pcsconfig);
4766 qib_write_kreg(dd, kr_hwerrmask,
4767 dd->cspec->hwerrmask & ~HWE_MASK(statusValidNoEop));
4766 qib_write_kreg_port(ppd, krp_ibcctrl_a, 4768 qib_write_kreg_port(ppd, krp_ibcctrl_a,
4767 ppd->cpspec->ibcctrl_a & 4769 ppd->cpspec->ibcctrl_a &
4768 ~SYM_MASK(IBCCtrlA_0, IBLinkEn)); 4770 ~SYM_MASK(IBCCtrlA_0, IBLinkEn));
@@ -4772,6 +4774,9 @@ static void qib_7322_mini_pcs_reset(struct qib_pportdata *ppd)
4772 qib_write_kreg_port(ppd, krp_ib_pcsconfig, val & ~reset_bits); 4774 qib_write_kreg_port(ppd, krp_ib_pcsconfig, val & ~reset_bits);
4773 qib_write_kreg_port(ppd, krp_ibcctrl_a, ppd->cpspec->ibcctrl_a); 4775 qib_write_kreg_port(ppd, krp_ibcctrl_a, ppd->cpspec->ibcctrl_a);
4774 qib_write_kreg(dd, kr_scratch, 0ULL); 4776 qib_write_kreg(dd, kr_scratch, 0ULL);
4777 qib_write_kreg(dd, kr_hwerrclear,
4778 SYM_MASK(HwErrClear, statusValidNoEopClear));
4779 qib_write_kreg(dd, kr_hwerrmask, dd->cspec->hwerrmask);
4775} 4780}
4776 4781
4777/* 4782/*
@@ -5624,6 +5629,8 @@ static void set_no_qsfp_atten(struct qib_devdata *dd, int change)
5624 if (ppd->port != port || !ppd->link_speed_supported) 5629 if (ppd->port != port || !ppd->link_speed_supported)
5625 continue; 5630 continue;
5626 ppd->cpspec->no_eep = val; 5631 ppd->cpspec->no_eep = val;
5632 if (seth1)
5633 ppd->cpspec->h1_val = h1;
5627 /* now change the IBC and serdes, overriding generic */ 5634 /* now change the IBC and serdes, overriding generic */
5628 init_txdds_table(ppd, 1); 5635 init_txdds_table(ppd, 1);
5629 any++; 5636 any++;
@@ -6064,9 +6071,9 @@ static int qib_init_7322_variables(struct qib_devdata *dd)
6064 * the "cable info" setup here. Can be overridden 6071 * the "cable info" setup here. Can be overridden
6065 * in adapter-specific routines. 6072 * in adapter-specific routines.
6066 */ 6073 */
6067 if (!(ppd->dd->flags & QIB_HAS_QSFP)) { 6074 if (!(dd->flags & QIB_HAS_QSFP)) {
6068 if (!IS_QMH(ppd->dd) && !IS_QME(ppd->dd)) 6075 if (!IS_QMH(dd) && !IS_QME(dd))
6069 qib_devinfo(ppd->dd->pcidev, "IB%u:%u: " 6076 qib_devinfo(dd->pcidev, "IB%u:%u: "
6070 "Unknown mezzanine card type\n", 6077 "Unknown mezzanine card type\n",
6071 dd->unit, ppd->port); 6078 dd->unit, ppd->port);
6072 cp->h1_val = IS_QMH(dd) ? H1_FORCE_QMH : H1_FORCE_QME; 6079 cp->h1_val = IS_QMH(dd) ? H1_FORCE_QMH : H1_FORCE_QME;
@@ -6119,9 +6126,25 @@ static int qib_init_7322_variables(struct qib_devdata *dd)
6119 qib_set_ctxtcnt(dd); 6126 qib_set_ctxtcnt(dd);
6120 6127
6121 if (qib_wc_pat) { 6128 if (qib_wc_pat) {
6122 ret = init_chip_wc_pat(dd, NUM_VL15_BUFS * dd->align4k); 6129 resource_size_t vl15off;
6130 /*
6131 * We do not set WC on the VL15 buffers to avoid
6132 * a rare problem with unaligned writes from
6133 * interrupt-flushed store buffers, so we need
6134 * to map those separately here. We can't solve
6135 * this for the rarely used mtrr case.
6136 */
6137 ret = init_chip_wc_pat(dd, 0);
6123 if (ret) 6138 if (ret)
6124 goto bail; 6139 goto bail;
6140
6141 /* vl15 buffers start just after the 4k buffers */
6142 vl15off = dd->physaddr + (dd->piobufbase >> 32) +
6143 dd->piobcnt4k * dd->align4k;
6144 dd->piovl15base = ioremap_nocache(vl15off,
6145 NUM_VL15_BUFS * dd->align4k);
6146 if (!dd->piovl15base)
6147 goto bail;
6125 } 6148 }
6126 qib_7322_set_baseaddrs(dd); /* set chip access pointers now */ 6149 qib_7322_set_baseaddrs(dd); /* set chip access pointers now */
6127 6150
@@ -6932,6 +6955,8 @@ static const struct txdds_ent txdds_extra_sdr[TXDDS_EXTRA_SZ] = {
6932 { 0, 0, 0, 11 }, /* QME7342 backplane settings */ 6955 { 0, 0, 0, 11 }, /* QME7342 backplane settings */
6933 { 0, 0, 0, 11 }, /* QME7342 backplane settings */ 6956 { 0, 0, 0, 11 }, /* QME7342 backplane settings */
6934 { 0, 0, 0, 11 }, /* QME7342 backplane settings */ 6957 { 0, 0, 0, 11 }, /* QME7342 backplane settings */
6958 { 0, 0, 0, 3 }, /* QMH7342 backplane settings */
6959 { 0, 0, 0, 4 }, /* QMH7342 backplane settings */
6935}; 6960};
6936 6961
6937static const struct txdds_ent txdds_extra_ddr[TXDDS_EXTRA_SZ] = { 6962static const struct txdds_ent txdds_extra_ddr[TXDDS_EXTRA_SZ] = {
@@ -6947,6 +6972,8 @@ static const struct txdds_ent txdds_extra_ddr[TXDDS_EXTRA_SZ] = {
6947 { 0, 0, 0, 13 }, /* QME7342 backplane settings */ 6972 { 0, 0, 0, 13 }, /* QME7342 backplane settings */
6948 { 0, 0, 0, 13 }, /* QME7342 backplane settings */ 6973 { 0, 0, 0, 13 }, /* QME7342 backplane settings */
6949 { 0, 0, 0, 13 }, /* QME7342 backplane settings */ 6974 { 0, 0, 0, 13 }, /* QME7342 backplane settings */
6975 { 0, 0, 0, 9 }, /* QMH7342 backplane settings */
6976 { 0, 0, 0, 10 }, /* QMH7342 backplane settings */
6950}; 6977};
6951 6978
6952static const struct txdds_ent txdds_extra_qdr[TXDDS_EXTRA_SZ] = { 6979static const struct txdds_ent txdds_extra_qdr[TXDDS_EXTRA_SZ] = {
@@ -6962,6 +6989,8 @@ static const struct txdds_ent txdds_extra_qdr[TXDDS_EXTRA_SZ] = {
6962 { 0, 1, 12, 6 }, /* QME7342 backplane setting */ 6989 { 0, 1, 12, 6 }, /* QME7342 backplane setting */
6963 { 0, 1, 12, 7 }, /* QME7342 backplane setting */ 6990 { 0, 1, 12, 7 }, /* QME7342 backplane setting */
6964 { 0, 1, 12, 8 }, /* QME7342 backplane setting */ 6991 { 0, 1, 12, 8 }, /* QME7342 backplane setting */
6992 { 0, 1, 0, 10 }, /* QMH7342 backplane settings */
6993 { 0, 1, 0, 12 }, /* QMH7342 backplane settings */
6965}; 6994};
6966 6995
6967static const struct txdds_ent *get_atten_table(const struct txdds_ent *txdds, 6996static const struct txdds_ent *get_atten_table(const struct txdds_ent *txdds,
diff --git a/drivers/infiniband/hw/qib/qib_init.c b/drivers/infiniband/hw/qib/qib_init.c
index 9b40f345ac3f..a873dd596e81 100644
--- a/drivers/infiniband/hw/qib/qib_init.c
+++ b/drivers/infiniband/hw/qib/qib_init.c
@@ -1059,7 +1059,7 @@ static int __init qlogic_ib_init(void)
1059 goto bail_dev; 1059 goto bail_dev;
1060 } 1060 }
1061 1061
1062 qib_cq_wq = create_workqueue("qib_cq"); 1062 qib_cq_wq = create_singlethread_workqueue("qib_cq");
1063 if (!qib_cq_wq) { 1063 if (!qib_cq_wq) {
1064 ret = -ENOMEM; 1064 ret = -ENOMEM;
1065 goto bail_wq; 1065 goto bail_wq;
@@ -1289,8 +1289,18 @@ static int __devinit qib_init_one(struct pci_dev *pdev,
1289 1289
1290 if (qib_mini_init || initfail || ret) { 1290 if (qib_mini_init || initfail || ret) {
1291 qib_stop_timers(dd); 1291 qib_stop_timers(dd);
1292 flush_scheduled_work();
1292 for (pidx = 0; pidx < dd->num_pports; ++pidx) 1293 for (pidx = 0; pidx < dd->num_pports; ++pidx)
1293 dd->f_quiet_serdes(dd->pport + pidx); 1294 dd->f_quiet_serdes(dd->pport + pidx);
1295 if (qib_mini_init)
1296 goto bail;
1297 if (!j) {
1298 (void) qibfs_remove(dd);
1299 qib_device_remove(dd);
1300 }
1301 if (!ret)
1302 qib_unregister_ib_device(dd);
1303 qib_postinit_cleanup(dd);
1294 if (initfail) 1304 if (initfail)
1295 ret = initfail; 1305 ret = initfail;
1296 goto bail; 1306 goto bail;
@@ -1472,6 +1482,9 @@ int qib_setup_eagerbufs(struct qib_ctxtdata *rcd)
1472 dma_addr_t pa = rcd->rcvegrbuf_phys[chunk]; 1482 dma_addr_t pa = rcd->rcvegrbuf_phys[chunk];
1473 unsigned i; 1483 unsigned i;
1474 1484
1485 /* clear for security and sanity on each use */
1486 memset(rcd->rcvegrbuf[chunk], 0, size);
1487
1475 for (i = 0; e < egrcnt && i < egrperchunk; e++, i++) { 1488 for (i = 0; e < egrcnt && i < egrperchunk; e++, i++) {
1476 dd->f_put_tid(dd, e + egroff + 1489 dd->f_put_tid(dd, e + egroff +
1477 (u64 __iomem *) 1490 (u64 __iomem *)
@@ -1499,6 +1512,12 @@ bail:
1499 return -ENOMEM; 1512 return -ENOMEM;
1500} 1513}
1501 1514
1515/*
1516 * Note: Changes to this routine should be mirrored
1517 * for the diagnostics routine qib_remap_ioaddr32().
1518 * There is also related code for VL15 buffers in qib_init_7322_variables().
1519 * The teardown code that unmaps is in qib_pcie_ddcleanup()
1520 */
1502int init_chip_wc_pat(struct qib_devdata *dd, u32 vl15buflen) 1521int init_chip_wc_pat(struct qib_devdata *dd, u32 vl15buflen)
1503{ 1522{
1504 u64 __iomem *qib_kregbase = NULL; 1523 u64 __iomem *qib_kregbase = NULL;
diff --git a/drivers/infiniband/hw/qib/qib_pcie.c b/drivers/infiniband/hw/qib/qib_pcie.c
index c926bf4541df..7fa6e5592630 100644
--- a/drivers/infiniband/hw/qib/qib_pcie.c
+++ b/drivers/infiniband/hw/qib/qib_pcie.c
@@ -179,6 +179,8 @@ void qib_pcie_ddcleanup(struct qib_devdata *dd)
179 iounmap(dd->piobase); 179 iounmap(dd->piobase);
180 if (dd->userbase) 180 if (dd->userbase)
181 iounmap(dd->userbase); 181 iounmap(dd->userbase);
182 if (dd->piovl15base)
183 iounmap(dd->piovl15base);
182 184
183 pci_disable_device(dd->pcidev); 185 pci_disable_device(dd->pcidev);
184 pci_release_regions(dd->pcidev); 186 pci_release_regions(dd->pcidev);
diff --git a/drivers/infiniband/hw/qib/qib_sd7220.c b/drivers/infiniband/hw/qib/qib_sd7220.c
index 0aeed0e74cb6..e9f9f8bc3204 100644
--- a/drivers/infiniband/hw/qib/qib_sd7220.c
+++ b/drivers/infiniband/hw/qib/qib_sd7220.c
@@ -1,5 +1,6 @@
1/* 1/*
2 * Copyright (c) 2006, 2007, 2008, 2009 QLogic Corporation. All rights reserved. 2 * Copyright (c) 2006, 2007, 2008, 2009, 2010 QLogic Corporation.
3 * All rights reserved.
3 * Copyright (c) 2003, 2004, 2005, 2006 PathScale, Inc. All rights reserved. 4 * Copyright (c) 2003, 2004, 2005, 2006 PathScale, Inc. All rights reserved.
4 * 5 *
5 * This software is available to you under a choice of one of two 6 * This software is available to you under a choice of one of two
@@ -37,10 +38,14 @@
37 38
38#include <linux/pci.h> 39#include <linux/pci.h>
39#include <linux/delay.h> 40#include <linux/delay.h>
41#include <linux/firmware.h>
40 42
41#include "qib.h" 43#include "qib.h"
42#include "qib_7220.h" 44#include "qib_7220.h"
43 45
46#define SD7220_FW_NAME "qlogic/sd7220.fw"
47MODULE_FIRMWARE(SD7220_FW_NAME);
48
44/* 49/*
45 * Same as in qib_iba7220.c, but just the registers needed here. 50 * Same as in qib_iba7220.c, but just the registers needed here.
46 * Could move whole set to qib_7220.h, but decided better to keep 51 * Could move whole set to qib_7220.h, but decided better to keep
@@ -102,6 +107,10 @@ static int qib_internal_presets(struct qib_devdata *dd);
102/* Tweak the register (CMUCTRL5) that contains the TRIMSELF controls */ 107/* Tweak the register (CMUCTRL5) that contains the TRIMSELF controls */
103static int qib_sd_trimself(struct qib_devdata *dd, int val); 108static int qib_sd_trimself(struct qib_devdata *dd, int val);
104static int epb_access(struct qib_devdata *dd, int sdnum, int claim); 109static int epb_access(struct qib_devdata *dd, int sdnum, int claim);
110static int qib_sd7220_ib_load(struct qib_devdata *dd,
111 const struct firmware *fw);
112static int qib_sd7220_ib_vfy(struct qib_devdata *dd,
113 const struct firmware *fw);
105 114
106/* 115/*
107 * Below keeps track of whether the "once per power-on" initialization has 116 * Below keeps track of whether the "once per power-on" initialization has
@@ -110,10 +119,13 @@ static int epb_access(struct qib_devdata *dd, int sdnum, int claim);
110 * state of the reset "pin", is no longer valid. Instead, we check for the 119 * state of the reset "pin", is no longer valid. Instead, we check for the
111 * actual uC code having been loaded. 120 * actual uC code having been loaded.
112 */ 121 */
113static int qib_ibsd_ucode_loaded(struct qib_pportdata *ppd) 122static int qib_ibsd_ucode_loaded(struct qib_pportdata *ppd,
123 const struct firmware *fw)
114{ 124{
115 struct qib_devdata *dd = ppd->dd; 125 struct qib_devdata *dd = ppd->dd;
116 if (!dd->cspec->serdes_first_init_done && (qib_sd7220_ib_vfy(dd) > 0)) 126
127 if (!dd->cspec->serdes_first_init_done &&
128 qib_sd7220_ib_vfy(dd, fw) > 0)
117 dd->cspec->serdes_first_init_done = 1; 129 dd->cspec->serdes_first_init_done = 1;
118 return dd->cspec->serdes_first_init_done; 130 return dd->cspec->serdes_first_init_done;
119} 131}
@@ -377,6 +389,7 @@ static void qib_sd_trimdone_monitor(struct qib_devdata *dd,
377 */ 389 */
378int qib_sd7220_init(struct qib_devdata *dd) 390int qib_sd7220_init(struct qib_devdata *dd)
379{ 391{
392 const struct firmware *fw;
380 int ret = 1; /* default to failure */ 393 int ret = 1; /* default to failure */
381 int first_reset, was_reset; 394 int first_reset, was_reset;
382 395
@@ -387,8 +400,15 @@ int qib_sd7220_init(struct qib_devdata *dd)
387 qib_ibsd_reset(dd, 1); 400 qib_ibsd_reset(dd, 1);
388 qib_sd_trimdone_monitor(dd, "Driver-reload"); 401 qib_sd_trimdone_monitor(dd, "Driver-reload");
389 } 402 }
403
404 ret = request_firmware(&fw, SD7220_FW_NAME, &dd->pcidev->dev);
405 if (ret) {
406 qib_dev_err(dd, "Failed to load IB SERDES image\n");
407 goto done;
408 }
409
390 /* Substitute our deduced value for was_reset */ 410 /* Substitute our deduced value for was_reset */
391 ret = qib_ibsd_ucode_loaded(dd->pport); 411 ret = qib_ibsd_ucode_loaded(dd->pport, fw);
392 if (ret < 0) 412 if (ret < 0)
393 goto bail; 413 goto bail;
394 414
@@ -437,13 +457,13 @@ int qib_sd7220_init(struct qib_devdata *dd)
437 int vfy; 457 int vfy;
438 int trim_done; 458 int trim_done;
439 459
440 ret = qib_sd7220_ib_load(dd); 460 ret = qib_sd7220_ib_load(dd, fw);
441 if (ret < 0) { 461 if (ret < 0) {
442 qib_dev_err(dd, "Failed to load IB SERDES image\n"); 462 qib_dev_err(dd, "Failed to load IB SERDES image\n");
443 goto bail; 463 goto bail;
444 } else { 464 } else {
445 /* Loaded image, try to verify */ 465 /* Loaded image, try to verify */
446 vfy = qib_sd7220_ib_vfy(dd); 466 vfy = qib_sd7220_ib_vfy(dd, fw);
447 if (vfy != ret) { 467 if (vfy != ret) {
448 qib_dev_err(dd, "SERDES PRAM VFY failed\n"); 468 qib_dev_err(dd, "SERDES PRAM VFY failed\n");
449 goto bail; 469 goto bail;
@@ -506,6 +526,8 @@ bail:
506done: 526done:
507 /* start relock timer regardless, but start at 1 second */ 527 /* start relock timer regardless, but start at 1 second */
508 set_7220_relock_poll(dd, -1); 528 set_7220_relock_poll(dd, -1);
529
530 release_firmware(fw);
509 return ret; 531 return ret;
510} 532}
511 533
@@ -829,8 +851,8 @@ static int qib_sd7220_ram_xfer(struct qib_devdata *dd, int sdnum, u32 loc,
829 851
830#define PROG_CHUNK 64 852#define PROG_CHUNK 64
831 853
832int qib_sd7220_prog_ld(struct qib_devdata *dd, int sdnum, 854static int qib_sd7220_prog_ld(struct qib_devdata *dd, int sdnum,
833 u8 *img, int len, int offset) 855 const u8 *img, int len, int offset)
834{ 856{
835 int cnt, sofar, req; 857 int cnt, sofar, req;
836 858
@@ -840,7 +862,7 @@ int qib_sd7220_prog_ld(struct qib_devdata *dd, int sdnum,
840 if (req > PROG_CHUNK) 862 if (req > PROG_CHUNK)
841 req = PROG_CHUNK; 863 req = PROG_CHUNK;
842 cnt = qib_sd7220_ram_xfer(dd, sdnum, offset + sofar, 864 cnt = qib_sd7220_ram_xfer(dd, sdnum, offset + sofar,
843 img + sofar, req, 0); 865 (u8 *)img + sofar, req, 0);
844 if (cnt < req) { 866 if (cnt < req) {
845 sofar = -1; 867 sofar = -1;
846 break; 868 break;
@@ -853,8 +875,8 @@ int qib_sd7220_prog_ld(struct qib_devdata *dd, int sdnum,
853#define VFY_CHUNK 64 875#define VFY_CHUNK 64
854#define SD_PRAM_ERROR_LIMIT 42 876#define SD_PRAM_ERROR_LIMIT 42
855 877
856int qib_sd7220_prog_vfy(struct qib_devdata *dd, int sdnum, 878static int qib_sd7220_prog_vfy(struct qib_devdata *dd, int sdnum,
857 const u8 *img, int len, int offset) 879 const u8 *img, int len, int offset)
858{ 880{
859 int cnt, sofar, req, idx, errors; 881 int cnt, sofar, req, idx, errors;
860 unsigned char readback[VFY_CHUNK]; 882 unsigned char readback[VFY_CHUNK];
@@ -881,6 +903,18 @@ int qib_sd7220_prog_vfy(struct qib_devdata *dd, int sdnum,
881 return errors ? -errors : sofar; 903 return errors ? -errors : sofar;
882} 904}
883 905
906static int
907qib_sd7220_ib_load(struct qib_devdata *dd, const struct firmware *fw)
908{
909 return qib_sd7220_prog_ld(dd, IB_7220_SERDES, fw->data, fw->size, 0);
910}
911
912static int
913qib_sd7220_ib_vfy(struct qib_devdata *dd, const struct firmware *fw)
914{
915 return qib_sd7220_prog_vfy(dd, IB_7220_SERDES, fw->data, fw->size, 0);
916}
917
884/* 918/*
885 * IRQ not set up at this point in init, so we poll. 919 * IRQ not set up at this point in init, so we poll.
886 */ 920 */
diff --git a/drivers/infiniband/hw/qib/qib_sd7220_img.c b/drivers/infiniband/hw/qib/qib_sd7220_img.c
deleted file mode 100644
index a1118fbd2370..000000000000
--- a/drivers/infiniband/hw/qib/qib_sd7220_img.c
+++ /dev/null
@@ -1,1081 +0,0 @@
1/*
2 * Copyright (c) 2007, 2008 QLogic Corporation. All rights reserved.
3 *
4 * This software is available to you under a choice of one of two
5 * licenses. You may choose to be licensed under the terms of the GNU
6 * General Public License (GPL) Version 2, available from the file
7 * COPYING in the main directory of this source tree, or the
8 * OpenIB.org BSD license below:
9 *
10 * Redistribution and use in source and binary forms, with or
11 * without modification, are permitted provided that the following
12 * conditions are met:
13 *
14 * - Redistributions of source code must retain the above
15 * copyright notice, this list of conditions and the following
16 * disclaimer.
17 *
18 * - Redistributions in binary form must reproduce the above
19 * copyright notice, this list of conditions and the following
20 * disclaimer in the documentation and/or other materials
21 * provided with the distribution.
22 *
23 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
24 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
25 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
26 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
27 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
28 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
29 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
30 * SOFTWARE.
31 */
32
33/*
34 * This file contains the memory image from the vendor, to be copied into
35 * the IB SERDES of the IBA7220 during initialization.
36 * The file also includes the two functions which use this image.
37 */
38#include <linux/pci.h>
39#include <linux/delay.h>
40
41#include "qib.h"
42#include "qib_7220.h"
43
44static unsigned char qib_sd7220_ib_img[] = {
45/*0000*/0x02, 0x0A, 0x29, 0x02, 0x0A, 0x87, 0xE5, 0xE6,
46 0x30, 0xE6, 0x04, 0x7F, 0x01, 0x80, 0x02, 0x7F,
47/*0010*/0x00, 0xE5, 0xE2, 0x30, 0xE4, 0x04, 0x7E, 0x01,
48 0x80, 0x02, 0x7E, 0x00, 0xEE, 0x5F, 0x60, 0x08,
49/*0020*/0x53, 0xF9, 0xF7, 0xE4, 0xF5, 0xFE, 0x80, 0x08,
50 0x7F, 0x0A, 0x12, 0x17, 0x31, 0x12, 0x0E, 0xA2,
51/*0030*/0x75, 0xFC, 0x08, 0xE4, 0xF5, 0xFD, 0xE5, 0xE7,
52 0x20, 0xE7, 0x03, 0x43, 0xF9, 0x08, 0x22, 0x00,
53/*0040*/0x01, 0x20, 0x11, 0x00, 0x04, 0x20, 0x00, 0x75,
54 0x51, 0x01, 0xE4, 0xF5, 0x52, 0xF5, 0x53, 0xF5,
55/*0050*/0x52, 0xF5, 0x7E, 0x7F, 0x04, 0x02, 0x04, 0x38,
56 0xC2, 0x36, 0x05, 0x52, 0xE5, 0x52, 0xD3, 0x94,
57/*0060*/0x0C, 0x40, 0x05, 0x75, 0x52, 0x01, 0xD2, 0x36,
58 0x90, 0x07, 0x0C, 0x74, 0x07, 0xF0, 0xA3, 0x74,
59/*0070*/0xFF, 0xF0, 0xE4, 0xF5, 0x0C, 0xA3, 0xF0, 0x90,
60 0x07, 0x14, 0xF0, 0xA3, 0xF0, 0x75, 0x0B, 0x20,
61/*0080*/0xF5, 0x09, 0xE4, 0xF5, 0x08, 0xE5, 0x08, 0xD3,
62 0x94, 0x30, 0x40, 0x03, 0x02, 0x04, 0x04, 0x12,
63/*0090*/0x00, 0x06, 0x15, 0x0B, 0xE5, 0x08, 0x70, 0x04,
64 0x7F, 0x01, 0x80, 0x02, 0x7F, 0x00, 0xE5, 0x09,
65/*00A0*/0x70, 0x04, 0x7E, 0x01, 0x80, 0x02, 0x7E, 0x00,
66 0xEE, 0x5F, 0x60, 0x05, 0x12, 0x18, 0x71, 0xD2,
67/*00B0*/0x35, 0x53, 0xE1, 0xF7, 0xE5, 0x08, 0x45, 0x09,
68 0xFF, 0xE5, 0x0B, 0x25, 0xE0, 0x25, 0xE0, 0x24,
69/*00C0*/0x83, 0xF5, 0x82, 0xE4, 0x34, 0x07, 0xF5, 0x83,
70 0xEF, 0xF0, 0x85, 0xE2, 0x20, 0xE5, 0x52, 0xD3,
71/*00D0*/0x94, 0x01, 0x40, 0x0D, 0x12, 0x19, 0xF3, 0xE0,
72 0x54, 0xA0, 0x64, 0x40, 0x70, 0x03, 0x02, 0x03,
73/*00E0*/0xFB, 0x53, 0xF9, 0xF8, 0x90, 0x94, 0x70, 0xE4,
74 0xF0, 0xE0, 0xF5, 0x10, 0xAF, 0x09, 0x12, 0x1E,
75/*00F0*/0xB3, 0xAF, 0x08, 0xEF, 0x44, 0x08, 0xF5, 0x82,
76 0x75, 0x83, 0x80, 0xE0, 0xF5, 0x29, 0xEF, 0x44,
77/*0100*/0x07, 0x12, 0x1A, 0x3C, 0xF5, 0x22, 0x54, 0x40,
78 0xD3, 0x94, 0x00, 0x40, 0x1E, 0xE5, 0x29, 0x54,
79/*0110*/0xF0, 0x70, 0x21, 0x12, 0x19, 0xF3, 0xE0, 0x44,
80 0x80, 0xF0, 0xE5, 0x22, 0x54, 0x30, 0x65, 0x08,
81/*0120*/0x70, 0x09, 0x12, 0x19, 0xF3, 0xE0, 0x54, 0xBF,
82 0xF0, 0x80, 0x09, 0x12, 0x19, 0xF3, 0x74, 0x40,
83/*0130*/0xF0, 0x02, 0x03, 0xFB, 0x12, 0x1A, 0x12, 0x75,
84 0x83, 0xAE, 0x74, 0xFF, 0xF0, 0xAF, 0x08, 0x7E,
85/*0140*/0x00, 0xEF, 0x44, 0x07, 0xF5, 0x82, 0xE0, 0xFD,
86 0xE5, 0x0B, 0x25, 0xE0, 0x25, 0xE0, 0x24, 0x81,
87/*0150*/0xF5, 0x82, 0xE4, 0x34, 0x07, 0xF5, 0x83, 0xED,
88 0xF0, 0x90, 0x07, 0x0E, 0xE0, 0x04, 0xF0, 0xEF,
89/*0160*/0x44, 0x07, 0xF5, 0x82, 0x75, 0x83, 0x98, 0xE0,
90 0xF5, 0x28, 0x12, 0x1A, 0x23, 0x40, 0x0C, 0x12,
91/*0170*/0x19, 0xF3, 0xE0, 0x44, 0x01, 0x12, 0x1A, 0x32,
92 0x02, 0x03, 0xF6, 0xAF, 0x08, 0x7E, 0x00, 0x74,
93/*0180*/0x80, 0xCD, 0xEF, 0xCD, 0x8D, 0x82, 0xF5, 0x83,
94 0xE0, 0x30, 0xE0, 0x0A, 0x12, 0x19, 0xF3, 0xE0,
95/*0190*/0x44, 0x20, 0xF0, 0x02, 0x03, 0xFB, 0x12, 0x19,
96 0xF3, 0xE0, 0x54, 0xDF, 0xF0, 0xEE, 0x44, 0xAE,
97/*01A0*/0x12, 0x1A, 0x43, 0x30, 0xE4, 0x03, 0x02, 0x03,
98 0xFB, 0x74, 0x9E, 0x12, 0x1A, 0x05, 0x20, 0xE0,
99/*01B0*/0x03, 0x02, 0x03, 0xFB, 0x8F, 0x82, 0x8E, 0x83,
100 0xE0, 0x20, 0xE0, 0x03, 0x02, 0x03, 0xFB, 0x12,
101/*01C0*/0x19, 0xF3, 0xE0, 0x44, 0x10, 0xF0, 0xE5, 0xE3,
102 0x20, 0xE7, 0x08, 0xE5, 0x08, 0x12, 0x1A, 0x3A,
103/*01D0*/0x44, 0x04, 0xF0, 0xAF, 0x08, 0x7E, 0x00, 0xEF,
104 0x12, 0x1A, 0x3A, 0x20, 0xE2, 0x34, 0x12, 0x19,
105/*01E0*/0xF3, 0xE0, 0x44, 0x08, 0xF0, 0xE5, 0xE4, 0x30,
106 0xE6, 0x04, 0x7D, 0x01, 0x80, 0x02, 0x7D, 0x00,
107/*01F0*/0xE5, 0x7E, 0xC3, 0x94, 0x04, 0x50, 0x04, 0x7C,
108 0x01, 0x80, 0x02, 0x7C, 0x00, 0xEC, 0x4D, 0x60,
109/*0200*/0x05, 0xC2, 0x35, 0x02, 0x03, 0xFB, 0xEE, 0x44,
110 0xD2, 0x12, 0x1A, 0x43, 0x44, 0x40, 0xF0, 0x02,
111/*0210*/0x03, 0xFB, 0x12, 0x19, 0xF3, 0xE0, 0x54, 0xF7,
112 0xF0, 0x12, 0x1A, 0x12, 0x75, 0x83, 0xD2, 0xE0,
113/*0220*/0x54, 0xBF, 0xF0, 0x90, 0x07, 0x14, 0xE0, 0x04,
114 0xF0, 0xE5, 0x7E, 0x70, 0x03, 0x75, 0x7E, 0x01,
115/*0230*/0xAF, 0x08, 0x7E, 0x00, 0x12, 0x1A, 0x23, 0x40,
116 0x12, 0x12, 0x19, 0xF3, 0xE0, 0x44, 0x01, 0x12,
117/*0240*/0x19, 0xF2, 0xE0, 0x54, 0x02, 0x12, 0x1A, 0x32,
118 0x02, 0x03, 0xFB, 0x12, 0x19, 0xF3, 0xE0, 0x44,
119/*0250*/0x02, 0x12, 0x19, 0xF2, 0xE0, 0x54, 0xFE, 0xF0,
120 0xC2, 0x35, 0xEE, 0x44, 0x8A, 0x8F, 0x82, 0xF5,
121/*0260*/0x83, 0xE0, 0xF5, 0x17, 0x54, 0x8F, 0x44, 0x40,
122 0xF0, 0x74, 0x90, 0xFC, 0xE5, 0x08, 0x44, 0x07,
123/*0270*/0xFD, 0xF5, 0x82, 0x8C, 0x83, 0xE0, 0x54, 0x3F,
124 0x90, 0x07, 0x02, 0xF0, 0xE0, 0x54, 0xC0, 0x8D,
125/*0280*/0x82, 0x8C, 0x83, 0xF0, 0x74, 0x92, 0x12, 0x1A,
126 0x05, 0x90, 0x07, 0x03, 0x12, 0x1A, 0x19, 0x74,
127/*0290*/0x82, 0x12, 0x1A, 0x05, 0x90, 0x07, 0x04, 0x12,
128 0x1A, 0x19, 0x74, 0xB4, 0x12, 0x1A, 0x05, 0x90,
129/*02A0*/0x07, 0x05, 0x12, 0x1A, 0x19, 0x74, 0x94, 0xFE,
130 0xE5, 0x08, 0x44, 0x06, 0x12, 0x1A, 0x0A, 0xF5,
131/*02B0*/0x10, 0x30, 0xE0, 0x04, 0xD2, 0x37, 0x80, 0x02,
132 0xC2, 0x37, 0xE5, 0x10, 0x54, 0x7F, 0x8F, 0x82,
133/*02C0*/0x8E, 0x83, 0xF0, 0x30, 0x44, 0x30, 0x12, 0x1A,
134 0x03, 0x54, 0x80, 0xD3, 0x94, 0x00, 0x40, 0x04,
135/*02D0*/0xD2, 0x39, 0x80, 0x02, 0xC2, 0x39, 0x8F, 0x82,
136 0x8E, 0x83, 0xE0, 0x44, 0x80, 0xF0, 0x12, 0x1A,
137/*02E0*/0x03, 0x54, 0x40, 0xD3, 0x94, 0x00, 0x40, 0x04,
138 0xD2, 0x3A, 0x80, 0x02, 0xC2, 0x3A, 0x8F, 0x82,
139/*02F0*/0x8E, 0x83, 0xE0, 0x44, 0x40, 0xF0, 0x74, 0x92,
140 0xFE, 0xE5, 0x08, 0x44, 0x06, 0x12, 0x1A, 0x0A,
141/*0300*/0x30, 0xE7, 0x04, 0xD2, 0x38, 0x80, 0x02, 0xC2,
142 0x38, 0x8F, 0x82, 0x8E, 0x83, 0xE0, 0x54, 0x7F,
143/*0310*/0xF0, 0x12, 0x1E, 0x46, 0xE4, 0xF5, 0x0A, 0x20,
144 0x03, 0x02, 0x80, 0x03, 0x30, 0x43, 0x03, 0x12,
145/*0320*/0x19, 0x95, 0x20, 0x02, 0x02, 0x80, 0x03, 0x30,
146 0x42, 0x03, 0x12, 0x0C, 0x8F, 0x30, 0x30, 0x06,
147/*0330*/0x12, 0x19, 0x95, 0x12, 0x0C, 0x8F, 0x12, 0x0D,
148 0x47, 0x12, 0x19, 0xF3, 0xE0, 0x54, 0xFB, 0xF0,
149/*0340*/0xE5, 0x0A, 0xC3, 0x94, 0x01, 0x40, 0x46, 0x43,
150 0xE1, 0x08, 0x12, 0x19, 0xF3, 0xE0, 0x44, 0x04,
151/*0350*/0xF0, 0xE5, 0xE4, 0x20, 0xE7, 0x2A, 0x12, 0x1A,
152 0x12, 0x75, 0x83, 0xD2, 0xE0, 0x54, 0x08, 0xD3,
153/*0360*/0x94, 0x00, 0x40, 0x04, 0x7F, 0x01, 0x80, 0x02,
154 0x7F, 0x00, 0xE5, 0x0A, 0xC3, 0x94, 0x01, 0x40,
155/*0370*/0x04, 0x7E, 0x01, 0x80, 0x02, 0x7E, 0x00, 0xEF,
156 0x5E, 0x60, 0x05, 0x12, 0x1D, 0xD7, 0x80, 0x17,
157/*0380*/0x12, 0x1A, 0x12, 0x75, 0x83, 0xD2, 0xE0, 0x44,
158 0x08, 0xF0, 0x02, 0x03, 0xFB, 0x12, 0x1A, 0x12,
159/*0390*/0x75, 0x83, 0xD2, 0xE0, 0x54, 0xF7, 0xF0, 0x12,
160 0x1E, 0x46, 0x7F, 0x08, 0x12, 0x17, 0x31, 0x74,
161/*03A0*/0x8E, 0xFE, 0x12, 0x1A, 0x12, 0x8E, 0x83, 0xE0,
162 0xF5, 0x10, 0x54, 0xFE, 0xF0, 0xE5, 0x10, 0x44,
163/*03B0*/0x01, 0xFF, 0xE5, 0x08, 0xFD, 0xED, 0x44, 0x07,
164 0xF5, 0x82, 0xEF, 0xF0, 0xE5, 0x10, 0x54, 0xFE,
165/*03C0*/0xFF, 0xED, 0x44, 0x07, 0xF5, 0x82, 0xEF, 0x12,
166 0x1A, 0x11, 0x75, 0x83, 0x86, 0xE0, 0x44, 0x10,
167/*03D0*/0x12, 0x1A, 0x11, 0xE0, 0x44, 0x10, 0xF0, 0x12,
168 0x19, 0xF3, 0xE0, 0x54, 0xFD, 0x44, 0x01, 0xFF,
169/*03E0*/0x12, 0x19, 0xF3, 0xEF, 0x12, 0x1A, 0x32, 0x30,
170 0x32, 0x0C, 0xE5, 0x08, 0x44, 0x08, 0xF5, 0x82,
171/*03F0*/0x75, 0x83, 0x82, 0x74, 0x05, 0xF0, 0xAF, 0x0B,
172 0x12, 0x18, 0xD7, 0x74, 0x10, 0x25, 0x08, 0xF5,
173/*0400*/0x08, 0x02, 0x00, 0x85, 0x05, 0x09, 0xE5, 0x09,
174 0xD3, 0x94, 0x07, 0x50, 0x03, 0x02, 0x00, 0x82,
175/*0410*/0xE5, 0x7E, 0xD3, 0x94, 0x00, 0x40, 0x04, 0x7F,
176 0x01, 0x80, 0x02, 0x7F, 0x00, 0xE5, 0x7E, 0xC3,
177/*0420*/0x94, 0xFA, 0x50, 0x04, 0x7E, 0x01, 0x80, 0x02,
178 0x7E, 0x00, 0xEE, 0x5F, 0x60, 0x02, 0x05, 0x7E,
179/*0430*/0x30, 0x35, 0x0B, 0x43, 0xE1, 0x01, 0x7F, 0x09,
180 0x12, 0x17, 0x31, 0x02, 0x00, 0x58, 0x53, 0xE1,
181/*0440*/0xFE, 0x02, 0x00, 0x58, 0x8E, 0x6A, 0x8F, 0x6B,
182 0x8C, 0x6C, 0x8D, 0x6D, 0x75, 0x6E, 0x01, 0x75,
183/*0450*/0x6F, 0x01, 0x75, 0x70, 0x01, 0xE4, 0xF5, 0x73,
184 0xF5, 0x74, 0xF5, 0x75, 0x90, 0x07, 0x2F, 0xF0,
185/*0460*/0xF5, 0x3C, 0xF5, 0x3E, 0xF5, 0x46, 0xF5, 0x47,
186 0xF5, 0x3D, 0xF5, 0x3F, 0xF5, 0x6F, 0xE5, 0x6F,
187/*0470*/0x70, 0x0F, 0xE5, 0x6B, 0x45, 0x6A, 0x12, 0x07,
188 0x2A, 0x75, 0x83, 0x80, 0x74, 0x3A, 0xF0, 0x80,
189/*0480*/0x09, 0x12, 0x07, 0x2A, 0x75, 0x83, 0x80, 0x74,
190 0x1A, 0xF0, 0xE4, 0xF5, 0x6E, 0xC3, 0x74, 0x3F,
191/*0490*/0x95, 0x6E, 0xFF, 0x12, 0x08, 0x65, 0x75, 0x83,
192 0x82, 0xEF, 0xF0, 0x12, 0x1A, 0x4D, 0x12, 0x08,
193/*04A0*/0xC6, 0xE5, 0x33, 0xF0, 0x12, 0x08, 0xFA, 0x12,
194 0x08, 0xB1, 0x40, 0xE1, 0xE5, 0x6F, 0x70, 0x0B,
195/*04B0*/0x12, 0x07, 0x2A, 0x75, 0x83, 0x80, 0x74, 0x36,
196 0xF0, 0x80, 0x09, 0x12, 0x07, 0x2A, 0x75, 0x83,
197/*04C0*/0x80, 0x74, 0x16, 0xF0, 0x75, 0x6E, 0x01, 0x12,
198 0x07, 0x2A, 0x75, 0x83, 0xB4, 0xE5, 0x6E, 0xF0,
199/*04D0*/0x12, 0x1A, 0x4D, 0x74, 0x3F, 0x25, 0x6E, 0xF5,
200 0x82, 0xE4, 0x34, 0x00, 0xF5, 0x83, 0xE5, 0x33,
201/*04E0*/0xF0, 0x74, 0xBF, 0x25, 0x6E, 0xF5, 0x82, 0xE4,
202 0x34, 0x00, 0x12, 0x08, 0xB1, 0x40, 0xD8, 0xE4,
203/*04F0*/0xF5, 0x70, 0xF5, 0x46, 0xF5, 0x47, 0xF5, 0x6E,
204 0x12, 0x08, 0xFA, 0xF5, 0x83, 0xE0, 0xFE, 0x12,
205/*0500*/0x08, 0xC6, 0xE0, 0x7C, 0x00, 0x24, 0x00, 0xFF,
206 0xEC, 0x3E, 0xFE, 0xAD, 0x3B, 0xD3, 0xEF, 0x9D,
207/*0510*/0xEE, 0x9C, 0x50, 0x04, 0x7B, 0x01, 0x80, 0x02,
208 0x7B, 0x00, 0xE5, 0x70, 0x70, 0x04, 0x7A, 0x01,
209/*0520*/0x80, 0x02, 0x7A, 0x00, 0xEB, 0x5A, 0x60, 0x06,
210 0x85, 0x6E, 0x46, 0x75, 0x70, 0x01, 0xD3, 0xEF,
211/*0530*/0x9D, 0xEE, 0x9C, 0x50, 0x04, 0x7F, 0x01, 0x80,
212 0x02, 0x7F, 0x00, 0xE5, 0x70, 0xB4, 0x01, 0x04,
213/*0540*/0x7E, 0x01, 0x80, 0x02, 0x7E, 0x00, 0xEF, 0x5E,
214 0x60, 0x03, 0x85, 0x6E, 0x47, 0x05, 0x6E, 0xE5,
215/*0550*/0x6E, 0x64, 0x7F, 0x70, 0xA3, 0xE5, 0x46, 0x60,
216 0x05, 0xE5, 0x47, 0xB4, 0x7E, 0x03, 0x85, 0x46,
217/*0560*/0x47, 0xE5, 0x6F, 0x70, 0x08, 0x85, 0x46, 0x76,
218 0x85, 0x47, 0x77, 0x80, 0x0E, 0xC3, 0x74, 0x7F,
219/*0570*/0x95, 0x46, 0xF5, 0x78, 0xC3, 0x74, 0x7F, 0x95,
220 0x47, 0xF5, 0x79, 0xE5, 0x6F, 0x70, 0x37, 0xE5,
221/*0580*/0x46, 0x65, 0x47, 0x70, 0x0C, 0x75, 0x73, 0x01,
222 0x75, 0x74, 0x01, 0xF5, 0x3C, 0xF5, 0x3D, 0x80,
223/*0590*/0x35, 0xE4, 0xF5, 0x4E, 0xC3, 0xE5, 0x47, 0x95,
224 0x46, 0xF5, 0x3C, 0xC3, 0x13, 0xF5, 0x71, 0x25,
225/*05A0*/0x46, 0xF5, 0x72, 0xC3, 0x94, 0x3F, 0x40, 0x05,
226 0xE4, 0xF5, 0x3D, 0x80, 0x40, 0xC3, 0x74, 0x3F,
227/*05B0*/0x95, 0x72, 0xF5, 0x3D, 0x80, 0x37, 0xE5, 0x46,
228 0x65, 0x47, 0x70, 0x0F, 0x75, 0x73, 0x01, 0x75,
229/*05C0*/0x75, 0x01, 0xF5, 0x3E, 0xF5, 0x3F, 0x75, 0x4E,
230 0x01, 0x80, 0x22, 0xE4, 0xF5, 0x4E, 0xC3, 0xE5,
231/*05D0*/0x47, 0x95, 0x46, 0xF5, 0x3E, 0xC3, 0x13, 0xF5,
232 0x71, 0x25, 0x46, 0xF5, 0x72, 0xD3, 0x94, 0x3F,
233/*05E0*/0x50, 0x05, 0xE4, 0xF5, 0x3F, 0x80, 0x06, 0xE5,
234 0x72, 0x24, 0xC1, 0xF5, 0x3F, 0x05, 0x6F, 0xE5,
235/*05F0*/0x6F, 0xC3, 0x94, 0x02, 0x50, 0x03, 0x02, 0x04,
236 0x6E, 0xE5, 0x6D, 0x45, 0x6C, 0x70, 0x02, 0x80,
237/*0600*/0x04, 0xE5, 0x74, 0x45, 0x75, 0x90, 0x07, 0x2F,
238 0xF0, 0x7F, 0x01, 0xE5, 0x3E, 0x60, 0x04, 0xE5,
239/*0610*/0x3C, 0x70, 0x14, 0xE4, 0xF5, 0x3C, 0xF5, 0x3D,
240 0xF5, 0x3E, 0xF5, 0x3F, 0x12, 0x08, 0xD2, 0x70,
241/*0620*/0x04, 0xF0, 0x02, 0x06, 0xA4, 0x80, 0x7A, 0xE5,
242 0x3C, 0xC3, 0x95, 0x3E, 0x40, 0x07, 0xE5, 0x3C,
243/*0630*/0x95, 0x3E, 0xFF, 0x80, 0x06, 0xC3, 0xE5, 0x3E,
244 0x95, 0x3C, 0xFF, 0xE5, 0x76, 0xD3, 0x95, 0x79,
245/*0640*/0x40, 0x05, 0x85, 0x76, 0x7A, 0x80, 0x03, 0x85,
246 0x79, 0x7A, 0xE5, 0x77, 0xC3, 0x95, 0x78, 0x50,
247/*0650*/0x05, 0x85, 0x77, 0x7B, 0x80, 0x03, 0x85, 0x78,
248 0x7B, 0xE5, 0x7B, 0xD3, 0x95, 0x7A, 0x40, 0x30,
249/*0660*/0xE5, 0x7B, 0x95, 0x7A, 0xF5, 0x3C, 0xF5, 0x3E,
250 0xC3, 0xE5, 0x7B, 0x95, 0x7A, 0x90, 0x07, 0x19,
251/*0670*/0xF0, 0xE5, 0x3C, 0xC3, 0x13, 0xF5, 0x71, 0x25,
252 0x7A, 0xF5, 0x72, 0xC3, 0x94, 0x3F, 0x40, 0x05,
253/*0680*/0xE4, 0xF5, 0x3D, 0x80, 0x1F, 0xC3, 0x74, 0x3F,
254 0x95, 0x72, 0xF5, 0x3D, 0xF5, 0x3F, 0x80, 0x14,
255/*0690*/0xE4, 0xF5, 0x3C, 0xF5, 0x3E, 0x90, 0x07, 0x19,
256 0xF0, 0x12, 0x08, 0xD2, 0x70, 0x03, 0xF0, 0x80,
257/*06A0*/0x03, 0x74, 0x01, 0xF0, 0x12, 0x08, 0x65, 0x75,
258 0x83, 0xD0, 0xE0, 0x54, 0x0F, 0xFE, 0xAD, 0x3C,
259/*06B0*/0x70, 0x02, 0x7E, 0x07, 0xBE, 0x0F, 0x02, 0x7E,
260 0x80, 0xEE, 0xFB, 0xEF, 0xD3, 0x9B, 0x74, 0x80,
261/*06C0*/0xF8, 0x98, 0x40, 0x1F, 0xE4, 0xF5, 0x3C, 0xF5,
262 0x3E, 0x12, 0x08, 0xD2, 0x70, 0x03, 0xF0, 0x80,
263/*06D0*/0x12, 0x74, 0x01, 0xF0, 0xE5, 0x08, 0xFB, 0xEB,
264 0x44, 0x07, 0xF5, 0x82, 0x75, 0x83, 0xD2, 0xE0,
265/*06E0*/0x44, 0x10, 0xF0, 0xE5, 0x08, 0xFB, 0xEB, 0x44,
266 0x09, 0xF5, 0x82, 0x75, 0x83, 0x9E, 0xED, 0xF0,
267/*06F0*/0xEB, 0x44, 0x07, 0xF5, 0x82, 0x75, 0x83, 0xCA,
268 0xED, 0xF0, 0x12, 0x08, 0x65, 0x75, 0x83, 0xCC,
269/*0700*/0xEF, 0xF0, 0x22, 0xE5, 0x08, 0x44, 0x07, 0xF5,
270 0x82, 0x75, 0x83, 0xBC, 0xE0, 0x54, 0xF0, 0xF0,
271/*0710*/0xE5, 0x08, 0x44, 0x07, 0xF5, 0x82, 0x75, 0x83,
272 0xBE, 0xE0, 0x54, 0xF0, 0xF0, 0xE5, 0x08, 0x44,
273/*0720*/0x07, 0xF5, 0x82, 0x75, 0x83, 0xC0, 0xE0, 0x54,
274 0xF0, 0xF0, 0xE5, 0x08, 0x44, 0x07, 0xF5, 0x82,
275/*0730*/0x22, 0xF0, 0x90, 0x07, 0x28, 0xE0, 0xFE, 0xA3,
276 0xE0, 0xF5, 0x82, 0x8E, 0x83, 0x22, 0x85, 0x42,
277/*0740*/0x42, 0x85, 0x41, 0x41, 0x85, 0x40, 0x40, 0x74,
278 0xC0, 0x2F, 0xF5, 0x82, 0x74, 0x02, 0x3E, 0xF5,
279/*0750*/0x83, 0xE5, 0x42, 0xF0, 0x74, 0xE0, 0x2F, 0xF5,
280 0x82, 0x74, 0x02, 0x3E, 0xF5, 0x83, 0x22, 0xE5,
281/*0760*/0x42, 0x29, 0xFD, 0xE4, 0x33, 0xFC, 0xE5, 0x3C,
282 0xC3, 0x9D, 0xEC, 0x64, 0x80, 0xF8, 0x74, 0x80,
283/*0770*/0x98, 0x22, 0xF5, 0x83, 0xE0, 0x90, 0x07, 0x22,
284 0x54, 0x1F, 0xFD, 0xE0, 0xFA, 0xA3, 0xE0, 0xF5,
285/*0780*/0x82, 0x8A, 0x83, 0xED, 0xF0, 0x22, 0x90, 0x07,
286 0x22, 0xE0, 0xFC, 0xA3, 0xE0, 0xF5, 0x82, 0x8C,
287/*0790*/0x83, 0x22, 0x90, 0x07, 0x24, 0xFF, 0xED, 0x44,
288 0x07, 0xCF, 0xF0, 0xA3, 0xEF, 0xF0, 0x22, 0x85,
289/*07A0*/0x38, 0x38, 0x85, 0x39, 0x39, 0x85, 0x3A, 0x3A,
290 0x74, 0xC0, 0x2F, 0xF5, 0x82, 0x74, 0x02, 0x3E,
291/*07B0*/0xF5, 0x83, 0x22, 0x90, 0x07, 0x26, 0xFF, 0xED,
292 0x44, 0x07, 0xCF, 0xF0, 0xA3, 0xEF, 0xF0, 0x22,
293/*07C0*/0xF0, 0x74, 0xA0, 0x2F, 0xF5, 0x82, 0x74, 0x02,
294 0x3E, 0xF5, 0x83, 0x22, 0x74, 0xC0, 0x25, 0x11,
295/*07D0*/0xF5, 0x82, 0xE4, 0x34, 0x01, 0xF5, 0x83, 0x22,
296 0x74, 0x00, 0x25, 0x11, 0xF5, 0x82, 0xE4, 0x34,
297/*07E0*/0x02, 0xF5, 0x83, 0x22, 0x74, 0x60, 0x25, 0x11,
298 0xF5, 0x82, 0xE4, 0x34, 0x03, 0xF5, 0x83, 0x22,
299/*07F0*/0x74, 0x80, 0x25, 0x11, 0xF5, 0x82, 0xE4, 0x34,
300 0x03, 0xF5, 0x83, 0x22, 0x74, 0xE0, 0x25, 0x11,
301/*0800*/0xF5, 0x82, 0xE4, 0x34, 0x03, 0xF5, 0x83, 0x22,
302 0x74, 0x40, 0x25, 0x11, 0xF5, 0x82, 0xE4, 0x34,
303/*0810*/0x06, 0xF5, 0x83, 0x22, 0x74, 0x80, 0x2F, 0xF5,
304 0x82, 0x74, 0x02, 0x3E, 0xF5, 0x83, 0x22, 0xAF,
305/*0820*/0x08, 0x7E, 0x00, 0xEF, 0x44, 0x07, 0xF5, 0x82,
306 0x22, 0xF5, 0x83, 0xE5, 0x82, 0x44, 0x07, 0xF5,
307/*0830*/0x82, 0xE5, 0x40, 0xF0, 0x22, 0x74, 0x40, 0x25,
308 0x11, 0xF5, 0x82, 0xE4, 0x34, 0x02, 0xF5, 0x83,
309/*0840*/0x22, 0x74, 0xC0, 0x25, 0x11, 0xF5, 0x82, 0xE4,
310 0x34, 0x03, 0xF5, 0x83, 0x22, 0x74, 0x00, 0x25,
311/*0850*/0x11, 0xF5, 0x82, 0xE4, 0x34, 0x06, 0xF5, 0x83,
312 0x22, 0x74, 0x20, 0x25, 0x11, 0xF5, 0x82, 0xE4,
313/*0860*/0x34, 0x06, 0xF5, 0x83, 0x22, 0xE5, 0x08, 0xFD,
314 0xED, 0x44, 0x07, 0xF5, 0x82, 0x22, 0xE5, 0x41,
315/*0870*/0xF0, 0xE5, 0x65, 0x64, 0x01, 0x45, 0x64, 0x22,
316 0x7E, 0x00, 0xFB, 0x7A, 0x00, 0xFD, 0x7C, 0x00,
317/*0880*/0x22, 0x74, 0x20, 0x25, 0x11, 0xF5, 0x82, 0xE4,
318 0x34, 0x02, 0x22, 0x74, 0xA0, 0x25, 0x11, 0xF5,
319/*0890*/0x82, 0xE4, 0x34, 0x03, 0x22, 0x85, 0x3E, 0x42,
320 0x85, 0x3F, 0x41, 0x8F, 0x40, 0x22, 0x85, 0x3C,
321/*08A0*/0x42, 0x85, 0x3D, 0x41, 0x8F, 0x40, 0x22, 0x75,
322 0x45, 0x3F, 0x90, 0x07, 0x20, 0xE4, 0xF0, 0xA3,
323/*08B0*/0x22, 0xF5, 0x83, 0xE5, 0x32, 0xF0, 0x05, 0x6E,
324 0xE5, 0x6E, 0xC3, 0x94, 0x40, 0x22, 0xF0, 0xE5,
325/*08C0*/0x08, 0x44, 0x06, 0xF5, 0x82, 0x22, 0x74, 0x00,
326 0x25, 0x6E, 0xF5, 0x82, 0xE4, 0x34, 0x00, 0xF5,
327/*08D0*/0x83, 0x22, 0xE5, 0x6D, 0x45, 0x6C, 0x90, 0x07,
328 0x2F, 0x22, 0xE4, 0xF9, 0xE5, 0x3C, 0xD3, 0x95,
329/*08E0*/0x3E, 0x22, 0x74, 0x80, 0x2E, 0xF5, 0x82, 0xE4,
330 0x34, 0x02, 0xF5, 0x83, 0xE0, 0x22, 0x74, 0xA0,
331/*08F0*/0x2E, 0xF5, 0x82, 0xE4, 0x34, 0x02, 0xF5, 0x83,
332 0xE0, 0x22, 0x74, 0x80, 0x25, 0x6E, 0xF5, 0x82,
333/*0900*/0xE4, 0x34, 0x00, 0x22, 0x25, 0x42, 0xFD, 0xE4,
334 0x33, 0xFC, 0x22, 0x85, 0x42, 0x42, 0x85, 0x41,
335/*0910*/0x41, 0x85, 0x40, 0x40, 0x22, 0xED, 0x4C, 0x60,
336 0x03, 0x02, 0x09, 0xE5, 0xEF, 0x4E, 0x70, 0x37,
337/*0920*/0x90, 0x07, 0x26, 0x12, 0x07, 0x89, 0xE0, 0xFD,
338 0x12, 0x07, 0xCC, 0xED, 0xF0, 0x90, 0x07, 0x28,
339/*0930*/0x12, 0x07, 0x89, 0xE0, 0xFD, 0x12, 0x07, 0xD8,
340 0xED, 0xF0, 0x12, 0x07, 0x86, 0xE0, 0x54, 0x1F,
341/*0940*/0xFD, 0x12, 0x08, 0x81, 0xF5, 0x83, 0xED, 0xF0,
342 0x90, 0x07, 0x24, 0x12, 0x07, 0x89, 0xE0, 0x54,
343/*0950*/0x1F, 0xFD, 0x12, 0x08, 0x35, 0xED, 0xF0, 0xEF,
344 0x64, 0x04, 0x4E, 0x70, 0x37, 0x90, 0x07, 0x26,
345/*0960*/0x12, 0x07, 0x89, 0xE0, 0xFD, 0x12, 0x07, 0xE4,
346 0xED, 0xF0, 0x90, 0x07, 0x28, 0x12, 0x07, 0x89,
347/*0970*/0xE0, 0xFD, 0x12, 0x07, 0xF0, 0xED, 0xF0, 0x12,
348 0x07, 0x86, 0xE0, 0x54, 0x1F, 0xFD, 0x12, 0x08,
349/*0980*/0x8B, 0xF5, 0x83, 0xED, 0xF0, 0x90, 0x07, 0x24,
350 0x12, 0x07, 0x89, 0xE0, 0x54, 0x1F, 0xFD, 0x12,
351/*0990*/0x08, 0x41, 0xED, 0xF0, 0xEF, 0x64, 0x01, 0x4E,
352 0x70, 0x04, 0x7D, 0x01, 0x80, 0x02, 0x7D, 0x00,
353/*09A0*/0xEF, 0x64, 0x02, 0x4E, 0x70, 0x04, 0x7F, 0x01,
354 0x80, 0x02, 0x7F, 0x00, 0xEF, 0x4D, 0x60, 0x78,
355/*09B0*/0x90, 0x07, 0x26, 0x12, 0x07, 0x35, 0xE0, 0xFF,
356 0x12, 0x07, 0xFC, 0xEF, 0x12, 0x07, 0x31, 0xE0,
357/*09C0*/0xFF, 0x12, 0x08, 0x08, 0xEF, 0xF0, 0x90, 0x07,
358 0x22, 0x12, 0x07, 0x35, 0xE0, 0x54, 0x1F, 0xFF,
359/*09D0*/0x12, 0x08, 0x4D, 0xEF, 0xF0, 0x90, 0x07, 0x24,
360 0x12, 0x07, 0x35, 0xE0, 0x54, 0x1F, 0xFF, 0x12,
361/*09E0*/0x08, 0x59, 0xEF, 0xF0, 0x22, 0x12, 0x07, 0xCC,
362 0xE4, 0xF0, 0x12, 0x07, 0xD8, 0xE4, 0xF0, 0x12,
363/*09F0*/0x08, 0x81, 0xF5, 0x83, 0xE4, 0xF0, 0x12, 0x08,
364 0x35, 0x74, 0x14, 0xF0, 0x12, 0x07, 0xE4, 0xE4,
365/*0A00*/0xF0, 0x12, 0x07, 0xF0, 0xE4, 0xF0, 0x12, 0x08,
366 0x8B, 0xF5, 0x83, 0xE4, 0xF0, 0x12, 0x08, 0x41,
367/*0A10*/0x74, 0x14, 0xF0, 0x12, 0x07, 0xFC, 0xE4, 0xF0,
368 0x12, 0x08, 0x08, 0xE4, 0xF0, 0x12, 0x08, 0x4D,
369/*0A20*/0xE4, 0xF0, 0x12, 0x08, 0x59, 0x74, 0x14, 0xF0,
370 0x22, 0x53, 0xF9, 0xF7, 0x75, 0xFC, 0x10, 0xE4,
371/*0A30*/0xF5, 0xFD, 0x75, 0xFE, 0x30, 0xF5, 0xFF, 0xE5,
372 0xE7, 0x20, 0xE7, 0x03, 0x43, 0xF9, 0x08, 0xE5,
373/*0A40*/0xE6, 0x20, 0xE7, 0x0B, 0x78, 0xFF, 0xE4, 0xF6,
374 0xD8, 0xFD, 0x53, 0xE6, 0xFE, 0x80, 0x09, 0x78,
375/*0A50*/0x08, 0xE4, 0xF6, 0xD8, 0xFD, 0x53, 0xE6, 0xFE,
376 0x75, 0x81, 0x80, 0xE4, 0xF5, 0xA8, 0xD2, 0xA8,
377/*0A60*/0xC2, 0xA9, 0xD2, 0xAF, 0xE5, 0xE2, 0x20, 0xE5,
378 0x05, 0x20, 0xE6, 0x02, 0x80, 0x03, 0x43, 0xE1,
379/*0A70*/0x02, 0xE5, 0xE2, 0x20, 0xE0, 0x0E, 0x90, 0x00,
380 0x00, 0x7F, 0x00, 0x7E, 0x08, 0xE4, 0xF0, 0xA3,
381/*0A80*/0xDF, 0xFC, 0xDE, 0xFA, 0x02, 0x0A, 0xDB, 0x43,
382 0xFA, 0x01, 0xC0, 0xE0, 0xC0, 0xF0, 0xC0, 0x83,
383/*0A90*/0xC0, 0x82, 0xC0, 0xD0, 0x12, 0x1C, 0xE7, 0xD0,
384 0xD0, 0xD0, 0x82, 0xD0, 0x83, 0xD0, 0xF0, 0xD0,
385/*0AA0*/0xE0, 0x53, 0xFA, 0xFE, 0x32, 0x02, 0x1B, 0x55,
386 0xE4, 0x93, 0xA3, 0xF8, 0xE4, 0x93, 0xA3, 0xF6,
387/*0AB0*/0x08, 0xDF, 0xF9, 0x80, 0x29, 0xE4, 0x93, 0xA3,
388 0xF8, 0x54, 0x07, 0x24, 0x0C, 0xC8, 0xC3, 0x33,
389/*0AC0*/0xC4, 0x54, 0x0F, 0x44, 0x20, 0xC8, 0x83, 0x40,
390 0x04, 0xF4, 0x56, 0x80, 0x01, 0x46, 0xF6, 0xDF,
391/*0AD0*/0xE4, 0x80, 0x0B, 0x01, 0x02, 0x04, 0x08, 0x10,
392 0x20, 0x40, 0x80, 0x90, 0x00, 0x3F, 0xE4, 0x7E,
393/*0AE0*/0x01, 0x93, 0x60, 0xC1, 0xA3, 0xFF, 0x54, 0x3F,
394 0x30, 0xE5, 0x09, 0x54, 0x1F, 0xFE, 0xE4, 0x93,
395/*0AF0*/0xA3, 0x60, 0x01, 0x0E, 0xCF, 0x54, 0xC0, 0x25,
396 0xE0, 0x60, 0xAD, 0x40, 0xB8, 0x80, 0xFE, 0x8C,
397/*0B00*/0x64, 0x8D, 0x65, 0x8A, 0x66, 0x8B, 0x67, 0xE4,
398 0xF5, 0x69, 0xEF, 0x4E, 0x70, 0x03, 0x02, 0x1D,
399/*0B10*/0x55, 0xE4, 0xF5, 0x68, 0xE5, 0x67, 0x45, 0x66,
400 0x70, 0x32, 0x12, 0x07, 0x2A, 0x75, 0x83, 0x90,
401/*0B20*/0xE4, 0x12, 0x07, 0x29, 0x75, 0x83, 0xC2, 0xE4,
402 0x12, 0x07, 0x29, 0x75, 0x83, 0xC4, 0xE4, 0x12,
403/*0B30*/0x08, 0x70, 0x70, 0x29, 0x12, 0x07, 0x2A, 0x75,
404 0x83, 0x92, 0xE4, 0x12, 0x07, 0x29, 0x75, 0x83,
405/*0B40*/0xC6, 0xE4, 0x12, 0x07, 0x29, 0x75, 0x83, 0xC8,
406 0xE4, 0xF0, 0x80, 0x11, 0x90, 0x07, 0x26, 0x12,
407/*0B50*/0x07, 0x35, 0xE4, 0x12, 0x08, 0x70, 0x70, 0x05,
408 0x12, 0x07, 0x32, 0xE4, 0xF0, 0x12, 0x1D, 0x55,
409/*0B60*/0x12, 0x1E, 0xBF, 0xE5, 0x67, 0x45, 0x66, 0x70,
410 0x33, 0x12, 0x07, 0x2A, 0x75, 0x83, 0x90, 0xE5,
411/*0B70*/0x41, 0x12, 0x07, 0x29, 0x75, 0x83, 0xC2, 0xE5,
412 0x41, 0x12, 0x07, 0x29, 0x75, 0x83, 0xC4, 0x12,
413/*0B80*/0x08, 0x6E, 0x70, 0x29, 0x12, 0x07, 0x2A, 0x75,
414 0x83, 0x92, 0xE5, 0x40, 0x12, 0x07, 0x29, 0x75,
415/*0B90*/0x83, 0xC6, 0xE5, 0x40, 0x12, 0x07, 0x29, 0x75,
416 0x83, 0xC8, 0x80, 0x0E, 0x90, 0x07, 0x26, 0x12,
417/*0BA0*/0x07, 0x35, 0x12, 0x08, 0x6E, 0x70, 0x06, 0x12,
418 0x07, 0x32, 0xE5, 0x40, 0xF0, 0xAF, 0x69, 0x7E,
419/*0BB0*/0x00, 0xAD, 0x67, 0xAC, 0x66, 0x12, 0x04, 0x44,
420 0x12, 0x07, 0x2A, 0x75, 0x83, 0xCA, 0xE0, 0xD3,
421/*0BC0*/0x94, 0x00, 0x50, 0x0C, 0x05, 0x68, 0xE5, 0x68,
422 0xC3, 0x94, 0x05, 0x50, 0x03, 0x02, 0x0B, 0x14,
423/*0BD0*/0x22, 0x8C, 0x60, 0x8D, 0x61, 0x12, 0x08, 0xDA,
424 0x74, 0x20, 0x40, 0x0D, 0x2F, 0xF5, 0x82, 0x74,
425/*0BE0*/0x03, 0x3E, 0xF5, 0x83, 0xE5, 0x3E, 0xF0, 0x80,
426 0x0B, 0x2F, 0xF5, 0x82, 0x74, 0x03, 0x3E, 0xF5,
427/*0BF0*/0x83, 0xE5, 0x3C, 0xF0, 0xE5, 0x3C, 0xD3, 0x95,
428 0x3E, 0x40, 0x3C, 0xE5, 0x61, 0x45, 0x60, 0x70,
429/*0C00*/0x10, 0xE9, 0x12, 0x09, 0x04, 0xE5, 0x3E, 0x12,
430 0x07, 0x68, 0x40, 0x3B, 0x12, 0x08, 0x95, 0x80,
431/*0C10*/0x18, 0xE5, 0x3E, 0xC3, 0x95, 0x38, 0x40, 0x1D,
432 0x85, 0x3E, 0x38, 0xE5, 0x3E, 0x60, 0x05, 0x85,
433/*0C20*/0x3F, 0x39, 0x80, 0x03, 0x85, 0x39, 0x39, 0x8F,
434 0x3A, 0x12, 0x08, 0x14, 0xE5, 0x3E, 0x12, 0x07,
435/*0C30*/0xC0, 0xE5, 0x3F, 0xF0, 0x22, 0x80, 0x43, 0xE5,
436 0x61, 0x45, 0x60, 0x70, 0x19, 0x12, 0x07, 0x5F,
437/*0C40*/0x40, 0x05, 0x12, 0x08, 0x9E, 0x80, 0x27, 0x12,
438 0x09, 0x0B, 0x12, 0x08, 0x14, 0xE5, 0x42, 0x12,
439/*0C50*/0x07, 0xC0, 0xE5, 0x41, 0xF0, 0x22, 0xE5, 0x3C,
440 0xC3, 0x95, 0x38, 0x40, 0x1D, 0x85, 0x3C, 0x38,
441/*0C60*/0xE5, 0x3C, 0x60, 0x05, 0x85, 0x3D, 0x39, 0x80,
442 0x03, 0x85, 0x39, 0x39, 0x8F, 0x3A, 0x12, 0x08,
443/*0C70*/0x14, 0xE5, 0x3C, 0x12, 0x07, 0xC0, 0xE5, 0x3D,
444 0xF0, 0x22, 0x85, 0x38, 0x38, 0x85, 0x39, 0x39,
445/*0C80*/0x85, 0x3A, 0x3A, 0x12, 0x08, 0x14, 0xE5, 0x38,
446 0x12, 0x07, 0xC0, 0xE5, 0x39, 0xF0, 0x22, 0x7F,
447/*0C90*/0x06, 0x12, 0x17, 0x31, 0x12, 0x1D, 0x23, 0x12,
448 0x0E, 0x04, 0x12, 0x0E, 0x33, 0xE0, 0x44, 0x0A,
449/*0CA0*/0xF0, 0x74, 0x8E, 0xFE, 0x12, 0x0E, 0x04, 0x12,
450 0x0E, 0x0B, 0xEF, 0xF0, 0xE5, 0x28, 0x30, 0xE5,
451/*0CB0*/0x03, 0xD3, 0x80, 0x01, 0xC3, 0x40, 0x05, 0x75,
452 0x14, 0x20, 0x80, 0x03, 0x75, 0x14, 0x08, 0x12,
453/*0CC0*/0x0E, 0x04, 0x75, 0x83, 0x8A, 0xE5, 0x14, 0xF0,
454 0xB4, 0xFF, 0x05, 0x75, 0x12, 0x80, 0x80, 0x06,
455/*0CD0*/0xE5, 0x14, 0xC3, 0x13, 0xF5, 0x12, 0xE4, 0xF5,
456 0x16, 0xF5, 0x7F, 0x12, 0x19, 0x36, 0x12, 0x13,
457/*0CE0*/0xA3, 0xE5, 0x0A, 0xC3, 0x94, 0x01, 0x50, 0x09,
458 0x05, 0x16, 0xE5, 0x16, 0xC3, 0x94, 0x14, 0x40,
459/*0CF0*/0xEA, 0xE5, 0xE4, 0x20, 0xE7, 0x28, 0x12, 0x0E,
460 0x04, 0x75, 0x83, 0xD2, 0xE0, 0x54, 0x08, 0xD3,
461/*0D00*/0x94, 0x00, 0x40, 0x04, 0x7F, 0x01, 0x80, 0x02,
462 0x7F, 0x00, 0xE5, 0x0A, 0xC3, 0x94, 0x01, 0x40,
463/*0D10*/0x04, 0x7E, 0x01, 0x80, 0x02, 0x7E, 0x00, 0xEF,
464 0x5E, 0x60, 0x03, 0x12, 0x1D, 0xD7, 0xE5, 0x7F,
465/*0D20*/0xC3, 0x94, 0x11, 0x40, 0x14, 0x12, 0x0E, 0x04,
466 0x75, 0x83, 0xD2, 0xE0, 0x44, 0x80, 0xF0, 0xE5,
467/*0D30*/0xE4, 0x20, 0xE7, 0x0F, 0x12, 0x1D, 0xD7, 0x80,
468 0x0A, 0x12, 0x0E, 0x04, 0x75, 0x83, 0xD2, 0xE0,
469/*0D40*/0x54, 0x7F, 0xF0, 0x12, 0x1D, 0x23, 0x22, 0x74,
470 0x8A, 0x85, 0x08, 0x82, 0xF5, 0x83, 0xE5, 0x17,
471/*0D50*/0xF0, 0x12, 0x0E, 0x3A, 0xE4, 0xF0, 0x90, 0x07,
472 0x02, 0xE0, 0x12, 0x0E, 0x17, 0x75, 0x83, 0x90,
473/*0D60*/0xEF, 0xF0, 0x74, 0x92, 0xFE, 0xE5, 0x08, 0x44,
474 0x07, 0xFF, 0xF5, 0x82, 0x8E, 0x83, 0xE0, 0x54,
475/*0D70*/0xC0, 0xFD, 0x90, 0x07, 0x03, 0xE0, 0x54, 0x3F,
476 0x4D, 0x8F, 0x82, 0x8E, 0x83, 0xF0, 0x90, 0x07,
477/*0D80*/0x04, 0xE0, 0x12, 0x0E, 0x17, 0x75, 0x83, 0x82,
478 0xEF, 0xF0, 0x90, 0x07, 0x05, 0xE0, 0xFF, 0xED,
479/*0D90*/0x44, 0x07, 0xF5, 0x82, 0x75, 0x83, 0xB4, 0xEF,
480 0x12, 0x0E, 0x03, 0x75, 0x83, 0x80, 0xE0, 0x54,
481/*0DA0*/0xBF, 0xF0, 0x30, 0x37, 0x0A, 0x12, 0x0E, 0x91,
482 0x75, 0x83, 0x94, 0xE0, 0x44, 0x80, 0xF0, 0x30,
483/*0DB0*/0x38, 0x0A, 0x12, 0x0E, 0x91, 0x75, 0x83, 0x92,
484 0xE0, 0x44, 0x80, 0xF0, 0xE5, 0x28, 0x30, 0xE4,
485/*0DC0*/0x1A, 0x20, 0x39, 0x0A, 0x12, 0x0E, 0x04, 0x75,
486 0x83, 0x88, 0xE0, 0x54, 0x7F, 0xF0, 0x20, 0x3A,
487/*0DD0*/0x0A, 0x12, 0x0E, 0x04, 0x75, 0x83, 0x88, 0xE0,
488 0x54, 0xBF, 0xF0, 0x74, 0x8C, 0xFE, 0x12, 0x0E,
489/*0DE0*/0x04, 0x8E, 0x83, 0xE0, 0x54, 0x0F, 0x12, 0x0E,
490 0x03, 0x75, 0x83, 0x86, 0xE0, 0x54, 0xBF, 0xF0,
491/*0DF0*/0xE5, 0x08, 0x44, 0x06, 0x12, 0x0D, 0xFD, 0x75,
492 0x83, 0x8A, 0xE4, 0xF0, 0x22, 0xF5, 0x82, 0x75,
493/*0E00*/0x83, 0x82, 0xE4, 0xF0, 0xE5, 0x08, 0x44, 0x07,
494 0xF5, 0x82, 0x22, 0x8E, 0x83, 0xE0, 0xF5, 0x10,
495/*0E10*/0x54, 0xFE, 0xF0, 0xE5, 0x10, 0x44, 0x01, 0xFF,
496 0xE5, 0x08, 0xFD, 0xED, 0x44, 0x07, 0xF5, 0x82,
497/*0E20*/0x22, 0xE5, 0x15, 0xC4, 0x54, 0x07, 0xFF, 0xE5,
498 0x08, 0xFD, 0xED, 0x44, 0x08, 0xF5, 0x82, 0x75,
499/*0E30*/0x83, 0x82, 0x22, 0x75, 0x83, 0x80, 0xE0, 0x44,
500 0x40, 0xF0, 0xE5, 0x08, 0x44, 0x08, 0xF5, 0x82,
501/*0E40*/0x75, 0x83, 0x8A, 0x22, 0xE5, 0x16, 0x25, 0xE0,
502 0x25, 0xE0, 0x24, 0xAF, 0xF5, 0x82, 0xE4, 0x34,
503/*0E50*/0x1A, 0xF5, 0x83, 0xE4, 0x93, 0xF5, 0x0D, 0x22,
504 0x43, 0xE1, 0x10, 0x43, 0xE1, 0x80, 0x53, 0xE1,
505/*0E60*/0xFD, 0x85, 0xE1, 0x10, 0x22, 0xE5, 0x16, 0x25,
506 0xE0, 0x25, 0xE0, 0x24, 0xB2, 0xF5, 0x82, 0xE4,
507/*0E70*/0x34, 0x1A, 0xF5, 0x83, 0xE4, 0x93, 0x22, 0x85,
508 0x55, 0x82, 0x85, 0x54, 0x83, 0xE5, 0x15, 0xF0,
509/*0E80*/0x22, 0xE5, 0xE2, 0x54, 0x20, 0xD3, 0x94, 0x00,
510 0x22, 0xE5, 0xE2, 0x54, 0x40, 0xD3, 0x94, 0x00,
511/*0E90*/0x22, 0xE5, 0x08, 0x44, 0x06, 0xF5, 0x82, 0x22,
512 0xFD, 0xE5, 0x08, 0xFB, 0xEB, 0x44, 0x07, 0xF5,
513/*0EA0*/0x82, 0x22, 0x53, 0xF9, 0xF7, 0x75, 0xFE, 0x30,
514 0x22, 0xEF, 0x4E, 0x70, 0x26, 0x12, 0x07, 0xCC,
515/*0EB0*/0xE0, 0xFD, 0x90, 0x07, 0x26, 0x12, 0x07, 0x7B,
516 0x12, 0x07, 0xD8, 0xE0, 0xFD, 0x90, 0x07, 0x28,
517/*0EC0*/0x12, 0x07, 0x7B, 0x12, 0x08, 0x81, 0x12, 0x07,
518 0x72, 0x12, 0x08, 0x35, 0xE0, 0x90, 0x07, 0x24,
519/*0ED0*/0x12, 0x07, 0x78, 0xEF, 0x64, 0x04, 0x4E, 0x70,
520 0x29, 0x12, 0x07, 0xE4, 0xE0, 0xFD, 0x90, 0x07,
521/*0EE0*/0x26, 0x12, 0x07, 0x7B, 0x12, 0x07, 0xF0, 0xE0,
522 0xFD, 0x90, 0x07, 0x28, 0x12, 0x07, 0x7B, 0x12,
523/*0EF0*/0x08, 0x8B, 0x12, 0x07, 0x72, 0x12, 0x08, 0x41,
524 0xE0, 0x54, 0x1F, 0xFD, 0x90, 0x07, 0x24, 0x12,
525/*0F00*/0x07, 0x7B, 0xEF, 0x64, 0x01, 0x4E, 0x70, 0x04,
526 0x7D, 0x01, 0x80, 0x02, 0x7D, 0x00, 0xEF, 0x64,
527/*0F10*/0x02, 0x4E, 0x70, 0x04, 0x7F, 0x01, 0x80, 0x02,
528 0x7F, 0x00, 0xEF, 0x4D, 0x60, 0x35, 0x12, 0x07,
529/*0F20*/0xFC, 0xE0, 0xFF, 0x90, 0x07, 0x26, 0x12, 0x07,
530 0x89, 0xEF, 0xF0, 0x12, 0x08, 0x08, 0xE0, 0xFF,
531/*0F30*/0x90, 0x07, 0x28, 0x12, 0x07, 0x89, 0xEF, 0xF0,
532 0x12, 0x08, 0x4D, 0xE0, 0x54, 0x1F, 0xFF, 0x12,
533/*0F40*/0x07, 0x86, 0xEF, 0xF0, 0x12, 0x08, 0x59, 0xE0,
534 0x54, 0x1F, 0xFF, 0x90, 0x07, 0x24, 0x12, 0x07,
535/*0F50*/0x89, 0xEF, 0xF0, 0x22, 0xE4, 0xF5, 0x53, 0x12,
536 0x0E, 0x81, 0x40, 0x04, 0x7F, 0x01, 0x80, 0x02,
537/*0F60*/0x7F, 0x00, 0x12, 0x0E, 0x89, 0x40, 0x04, 0x7E,
538 0x01, 0x80, 0x02, 0x7E, 0x00, 0xEE, 0x4F, 0x70,
539/*0F70*/0x03, 0x02, 0x0F, 0xF6, 0x85, 0xE1, 0x10, 0x43,
540 0xE1, 0x02, 0x53, 0xE1, 0x0F, 0x85, 0xE1, 0x10,
541/*0F80*/0xE4, 0xF5, 0x51, 0xE5, 0xE3, 0x54, 0x3F, 0xF5,
542 0x52, 0x12, 0x0E, 0x89, 0x40, 0x1D, 0xAD, 0x52,
543/*0F90*/0xAF, 0x51, 0x12, 0x11, 0x18, 0xEF, 0x60, 0x08,
544 0x85, 0xE1, 0x10, 0x43, 0xE1, 0x40, 0x80, 0x0B,
545/*0FA0*/0x53, 0xE1, 0xBF, 0x12, 0x0E, 0x58, 0x12, 0x00,
546 0x06, 0x80, 0xFB, 0xE5, 0xE3, 0x54, 0x3F, 0xF5,
547/*0FB0*/0x51, 0xE5, 0xE4, 0x54, 0x3F, 0xF5, 0x52, 0x12,
548 0x0E, 0x81, 0x40, 0x1D, 0xAD, 0x52, 0xAF, 0x51,
549/*0FC0*/0x12, 0x11, 0x18, 0xEF, 0x60, 0x08, 0x85, 0xE1,
550 0x10, 0x43, 0xE1, 0x20, 0x80, 0x0B, 0x53, 0xE1,
551/*0FD0*/0xDF, 0x12, 0x0E, 0x58, 0x12, 0x00, 0x06, 0x80,
552 0xFB, 0x12, 0x0E, 0x81, 0x40, 0x04, 0x7F, 0x01,
553/*0FE0*/0x80, 0x02, 0x7F, 0x00, 0x12, 0x0E, 0x89, 0x40,
554 0x04, 0x7E, 0x01, 0x80, 0x02, 0x7E, 0x00, 0xEE,
555/*0FF0*/0x4F, 0x60, 0x03, 0x12, 0x0E, 0x5B, 0x22, 0x12,
556 0x0E, 0x21, 0xEF, 0xF0, 0x12, 0x10, 0x91, 0x22,
557/*1000*/0x02, 0x11, 0x00, 0x02, 0x10, 0x40, 0x02, 0x10,
558 0x90, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
559/*1010*/0x01, 0x20, 0x01, 0x20, 0xE4, 0xF5, 0x57, 0x12,
560 0x16, 0xBD, 0x12, 0x16, 0x44, 0xE4, 0x12, 0x10,
561/*1020*/0x56, 0x12, 0x14, 0xB7, 0x90, 0x07, 0x26, 0x12,
562 0x07, 0x35, 0xE4, 0x12, 0x07, 0x31, 0xE4, 0xF0,
563/*1030*/0x12, 0x10, 0x56, 0x12, 0x14, 0xB7, 0x90, 0x07,
564 0x26, 0x12, 0x07, 0x35, 0xE5, 0x41, 0x12, 0x07,
565/*1040*/0x31, 0xE5, 0x40, 0xF0, 0xAF, 0x57, 0x7E, 0x00,
566 0xAD, 0x56, 0x7C, 0x00, 0x12, 0x04, 0x44, 0xAF,
567/*1050*/0x56, 0x7E, 0x00, 0x02, 0x11, 0xEE, 0xFF, 0x90,
568 0x07, 0x20, 0xA3, 0xE0, 0xFD, 0xE4, 0xF5, 0x56,
569/*1060*/0xF5, 0x40, 0xFE, 0xFC, 0xAB, 0x56, 0xFA, 0x12,
570 0x11, 0x51, 0x7F, 0x0F, 0x7D, 0x18, 0xE4, 0xF5,
571/*1070*/0x56, 0xF5, 0x40, 0xFE, 0xFC, 0xAB, 0x56, 0xFA,
572 0x12, 0x15, 0x41, 0xAF, 0x56, 0x7E, 0x00, 0x12,
573/*1080*/0x1A, 0xFF, 0xE4, 0xFF, 0xF5, 0x56, 0x7D, 0x1F,
574 0xF5, 0x40, 0xFE, 0xFC, 0xAB, 0x56, 0xFA, 0x22,
575/*1090*/0x22, 0xE4, 0xF5, 0x55, 0xE5, 0x08, 0xFD, 0x74,
576 0xA0, 0xF5, 0x56, 0xED, 0x44, 0x07, 0xF5, 0x57,
577/*10A0*/0xE5, 0x28, 0x30, 0xE5, 0x03, 0xD3, 0x80, 0x01,
578 0xC3, 0x40, 0x05, 0x7F, 0x28, 0xEF, 0x80, 0x04,
579/*10B0*/0x7F, 0x14, 0xEF, 0xC3, 0x13, 0xF5, 0x54, 0xE4,
580 0xF9, 0x12, 0x0E, 0x18, 0x75, 0x83, 0x8E, 0xE0,
581/*10C0*/0xF5, 0x10, 0xCE, 0xEF, 0xCE, 0xEE, 0xD3, 0x94,
582 0x00, 0x40, 0x26, 0xE5, 0x10, 0x54, 0xFE, 0x12,
583/*10D0*/0x0E, 0x98, 0x75, 0x83, 0x8E, 0xED, 0xF0, 0xE5,
584 0x10, 0x44, 0x01, 0xFD, 0xEB, 0x44, 0x07, 0xF5,
585/*10E0*/0x82, 0xED, 0xF0, 0x85, 0x57, 0x82, 0x85, 0x56,
586 0x83, 0xE0, 0x30, 0xE3, 0x01, 0x09, 0x1E, 0x80,
587/*10F0*/0xD4, 0xC2, 0x34, 0xE9, 0xC3, 0x95, 0x54, 0x40,
588 0x02, 0xD2, 0x34, 0x22, 0x02, 0x00, 0x06, 0x22,
589/*1100*/0x30, 0x30, 0x11, 0x90, 0x10, 0x00, 0xE4, 0x93,
590 0xF5, 0x10, 0x90, 0x10, 0x10, 0xE4, 0x93, 0xF5,
591/*1110*/0x10, 0x12, 0x10, 0x90, 0x12, 0x11, 0x50, 0x22,
592 0xE4, 0xFC, 0xC3, 0xED, 0x9F, 0xFA, 0xEF, 0xF5,
593/*1120*/0x83, 0x75, 0x82, 0x00, 0x79, 0xFF, 0xE4, 0x93,
594 0xCC, 0x6C, 0xCC, 0xA3, 0xD9, 0xF8, 0xDA, 0xF6,
595/*1130*/0xE5, 0xE2, 0x30, 0xE4, 0x02, 0x8C, 0xE5, 0xED,
596 0x24, 0xFF, 0xFF, 0xEF, 0x75, 0x82, 0xFF, 0xF5,
597/*1140*/0x83, 0xE4, 0x93, 0x6C, 0x70, 0x03, 0x7F, 0x01,
598 0x22, 0x7F, 0x00, 0x22, 0x22, 0x11, 0x00, 0x00,
599/*1150*/0x22, 0x8E, 0x58, 0x8F, 0x59, 0x8C, 0x5A, 0x8D,
600 0x5B, 0x8A, 0x5C, 0x8B, 0x5D, 0x75, 0x5E, 0x01,
601/*1160*/0xE4, 0xF5, 0x5F, 0xF5, 0x60, 0xF5, 0x62, 0x12,
602 0x07, 0x2A, 0x75, 0x83, 0xD0, 0xE0, 0xFF, 0xC4,
603/*1170*/0x54, 0x0F, 0xF5, 0x61, 0x12, 0x1E, 0xA5, 0x85,
604 0x59, 0x5E, 0xD3, 0xE5, 0x5E, 0x95, 0x5B, 0xE5,
605/*1180*/0x5A, 0x12, 0x07, 0x6B, 0x50, 0x4B, 0x12, 0x07,
606 0x03, 0x75, 0x83, 0xBC, 0xE0, 0x45, 0x5E, 0x12,
607/*1190*/0x07, 0x29, 0x75, 0x83, 0xBE, 0xE0, 0x45, 0x5E,
608 0x12, 0x07, 0x29, 0x75, 0x83, 0xC0, 0xE0, 0x45,
609/*11A0*/0x5E, 0xF0, 0xAF, 0x5F, 0xE5, 0x60, 0x12, 0x08,
610 0x78, 0x12, 0x0A, 0xFF, 0xAF, 0x62, 0x7E, 0x00,
611/*11B0*/0xAD, 0x5D, 0xAC, 0x5C, 0x12, 0x04, 0x44, 0xE5,
612 0x61, 0xAF, 0x5E, 0x7E, 0x00, 0xB4, 0x03, 0x05,
613/*11C0*/0x12, 0x1E, 0x21, 0x80, 0x07, 0xAD, 0x5D, 0xAC,
614 0x5C, 0x12, 0x13, 0x17, 0x05, 0x5E, 0x02, 0x11,
615/*11D0*/0x7A, 0x12, 0x07, 0x03, 0x75, 0x83, 0xBC, 0xE0,
616 0x45, 0x40, 0x12, 0x07, 0x29, 0x75, 0x83, 0xBE,
617/*11E0*/0xE0, 0x45, 0x40, 0x12, 0x07, 0x29, 0x75, 0x83,
618 0xC0, 0xE0, 0x45, 0x40, 0xF0, 0x22, 0x8E, 0x58,
619/*11F0*/0x8F, 0x59, 0x75, 0x5A, 0x01, 0x79, 0x01, 0x75,
620 0x5B, 0x01, 0xE4, 0xFB, 0x12, 0x07, 0x2A, 0x75,
621/*1200*/0x83, 0xAE, 0xE0, 0x54, 0x1A, 0xFF, 0x12, 0x08,
622 0x65, 0xE0, 0xC4, 0x13, 0x54, 0x07, 0xFE, 0xEF,
623/*1210*/0x70, 0x0C, 0xEE, 0x65, 0x35, 0x70, 0x07, 0x90,
624 0x07, 0x2F, 0xE0, 0xB4, 0x01, 0x0D, 0xAF, 0x35,
625/*1220*/0x7E, 0x00, 0x12, 0x0E, 0xA9, 0xCF, 0xEB, 0xCF,
626 0x02, 0x1E, 0x60, 0xE5, 0x59, 0x64, 0x02, 0x45,
627/*1230*/0x58, 0x70, 0x04, 0x7F, 0x01, 0x80, 0x02, 0x7F,
628 0x00, 0xE5, 0x59, 0x45, 0x58, 0x70, 0x04, 0x7E,
629/*1240*/0x01, 0x80, 0x02, 0x7E, 0x00, 0xEE, 0x4F, 0x60,
630 0x23, 0x85, 0x41, 0x49, 0x85, 0x40, 0x4B, 0xE5,
631/*1250*/0x59, 0x45, 0x58, 0x70, 0x2C, 0xAF, 0x5A, 0xFE,
632 0xCD, 0xE9, 0xCD, 0xFC, 0xAB, 0x59, 0xAA, 0x58,
633/*1260*/0x12, 0x0A, 0xFF, 0xAF, 0x5B, 0x7E, 0x00, 0x12,
634 0x1E, 0x60, 0x80, 0x15, 0xAF, 0x5B, 0x7E, 0x00,
635/*1270*/0x12, 0x1E, 0x60, 0x90, 0x07, 0x26, 0x12, 0x07,
636 0x35, 0xE5, 0x49, 0x12, 0x07, 0x31, 0xE5, 0x4B,
637/*1280*/0xF0, 0xE4, 0xFD, 0xAF, 0x35, 0xFE, 0xFC, 0x12,
638 0x09, 0x15, 0x22, 0x8C, 0x64, 0x8D, 0x65, 0x12,
639/*1290*/0x08, 0xDA, 0x40, 0x3C, 0xE5, 0x65, 0x45, 0x64,
640 0x70, 0x10, 0x12, 0x09, 0x04, 0xC3, 0xE5, 0x3E,
641/*12A0*/0x12, 0x07, 0x69, 0x40, 0x3B, 0x12, 0x08, 0x95,
642 0x80, 0x18, 0xE5, 0x3E, 0xC3, 0x95, 0x38, 0x40,
643/*12B0*/0x1D, 0x85, 0x3E, 0x38, 0xE5, 0x3E, 0x60, 0x05,
644 0x85, 0x3F, 0x39, 0x80, 0x03, 0x85, 0x39, 0x39,
645/*12C0*/0x8F, 0x3A, 0x12, 0x07, 0xA8, 0xE5, 0x3E, 0x12,
646 0x07, 0x53, 0xE5, 0x3F, 0xF0, 0x22, 0x80, 0x3B,
647/*12D0*/0xE5, 0x65, 0x45, 0x64, 0x70, 0x11, 0x12, 0x07,
648 0x5F, 0x40, 0x05, 0x12, 0x08, 0x9E, 0x80, 0x1F,
649/*12E0*/0x12, 0x07, 0x3E, 0xE5, 0x41, 0xF0, 0x22, 0xE5,
650 0x3C, 0xC3, 0x95, 0x38, 0x40, 0x1D, 0x85, 0x3C,
651/*12F0*/0x38, 0xE5, 0x3C, 0x60, 0x05, 0x85, 0x3D, 0x39,
652 0x80, 0x03, 0x85, 0x39, 0x39, 0x8F, 0x3A, 0x12,
653/*1300*/0x07, 0xA8, 0xE5, 0x3C, 0x12, 0x07, 0x53, 0xE5,
654 0x3D, 0xF0, 0x22, 0x12, 0x07, 0x9F, 0xE5, 0x38,
655/*1310*/0x12, 0x07, 0x53, 0xE5, 0x39, 0xF0, 0x22, 0x8C,
656 0x63, 0x8D, 0x64, 0x12, 0x08, 0xDA, 0x40, 0x3C,
657/*1320*/0xE5, 0x64, 0x45, 0x63, 0x70, 0x10, 0x12, 0x09,
658 0x04, 0xC3, 0xE5, 0x3E, 0x12, 0x07, 0x69, 0x40,
659/*1330*/0x3B, 0x12, 0x08, 0x95, 0x80, 0x18, 0xE5, 0x3E,
660 0xC3, 0x95, 0x38, 0x40, 0x1D, 0x85, 0x3E, 0x38,
661/*1340*/0xE5, 0x3E, 0x60, 0x05, 0x85, 0x3F, 0x39, 0x80,
662 0x03, 0x85, 0x39, 0x39, 0x8F, 0x3A, 0x12, 0x07,
663/*1350*/0xA8, 0xE5, 0x3E, 0x12, 0x07, 0x53, 0xE5, 0x3F,
664 0xF0, 0x22, 0x80, 0x3B, 0xE5, 0x64, 0x45, 0x63,
665/*1360*/0x70, 0x11, 0x12, 0x07, 0x5F, 0x40, 0x05, 0x12,
666 0x08, 0x9E, 0x80, 0x1F, 0x12, 0x07, 0x3E, 0xE5,
667/*1370*/0x41, 0xF0, 0x22, 0xE5, 0x3C, 0xC3, 0x95, 0x38,
668 0x40, 0x1D, 0x85, 0x3C, 0x38, 0xE5, 0x3C, 0x60,
669/*1380*/0x05, 0x85, 0x3D, 0x39, 0x80, 0x03, 0x85, 0x39,
670 0x39, 0x8F, 0x3A, 0x12, 0x07, 0xA8, 0xE5, 0x3C,
671/*1390*/0x12, 0x07, 0x53, 0xE5, 0x3D, 0xF0, 0x22, 0x12,
672 0x07, 0x9F, 0xE5, 0x38, 0x12, 0x07, 0x53, 0xE5,
673/*13A0*/0x39, 0xF0, 0x22, 0xE5, 0x0D, 0xFE, 0xE5, 0x08,
674 0x8E, 0x54, 0x44, 0x05, 0xF5, 0x55, 0x75, 0x15,
675/*13B0*/0x0F, 0xF5, 0x82, 0x12, 0x0E, 0x7A, 0x12, 0x17,
676 0xA3, 0x20, 0x31, 0x05, 0x75, 0x15, 0x03, 0x80,
677/*13C0*/0x03, 0x75, 0x15, 0x0B, 0xE5, 0x0A, 0xC3, 0x94,
678 0x01, 0x50, 0x38, 0x12, 0x14, 0x20, 0x20, 0x31,
679/*13D0*/0x06, 0x05, 0x15, 0x05, 0x15, 0x80, 0x04, 0x15,
680 0x15, 0x15, 0x15, 0xE5, 0x0A, 0xC3, 0x94, 0x01,
681/*13E0*/0x50, 0x21, 0x12, 0x14, 0x20, 0x20, 0x31, 0x04,
682 0x05, 0x15, 0x80, 0x02, 0x15, 0x15, 0xE5, 0x0A,
683/*13F0*/0xC3, 0x94, 0x01, 0x50, 0x0E, 0x12, 0x0E, 0x77,
684 0x12, 0x17, 0xA3, 0x20, 0x31, 0x05, 0x05, 0x15,
685/*1400*/0x12, 0x0E, 0x77, 0xE5, 0x15, 0xB4, 0x08, 0x04,
686 0x7F, 0x01, 0x80, 0x02, 0x7F, 0x00, 0xE5, 0x15,
687/*1410*/0xB4, 0x07, 0x04, 0x7E, 0x01, 0x80, 0x02, 0x7E,
688 0x00, 0xEE, 0x4F, 0x60, 0x02, 0x05, 0x7F, 0x22,
689/*1420*/0x85, 0x55, 0x82, 0x85, 0x54, 0x83, 0xE5, 0x15,
690 0xF0, 0x12, 0x17, 0xA3, 0x22, 0x12, 0x07, 0x2A,
691/*1430*/0x75, 0x83, 0xAE, 0x74, 0xFF, 0x12, 0x07, 0x29,
692 0xE0, 0x54, 0x1A, 0xF5, 0x34, 0xE0, 0xC4, 0x13,
693/*1440*/0x54, 0x07, 0xF5, 0x35, 0x24, 0xFE, 0x60, 0x24,
694 0x24, 0xFE, 0x60, 0x3C, 0x24, 0x04, 0x70, 0x63,
695/*1450*/0x75, 0x31, 0x2D, 0xE5, 0x08, 0xFD, 0x74, 0xB6,
696 0x12, 0x07, 0x92, 0x74, 0xBC, 0x90, 0x07, 0x22,
697/*1460*/0x12, 0x07, 0x95, 0x74, 0x90, 0x12, 0x07, 0xB3,
698 0x74, 0x92, 0x80, 0x3C, 0x75, 0x31, 0x3A, 0xE5,
699/*1470*/0x08, 0xFD, 0x74, 0xBA, 0x12, 0x07, 0x92, 0x74,
700 0xC0, 0x90, 0x07, 0x22, 0x12, 0x07, 0xB6, 0x74,
701/*1480*/0xC4, 0x12, 0x07, 0xB3, 0x74, 0xC8, 0x80, 0x20,
702 0x75, 0x31, 0x35, 0xE5, 0x08, 0xFD, 0x74, 0xB8,
703/*1490*/0x12, 0x07, 0x92, 0x74, 0xBE, 0xFF, 0xED, 0x44,
704 0x07, 0x90, 0x07, 0x22, 0xCF, 0xF0, 0xA3, 0xEF,
705/*14A0*/0xF0, 0x74, 0xC2, 0x12, 0x07, 0xB3, 0x74, 0xC6,
706 0xFF, 0xED, 0x44, 0x07, 0xA3, 0xCF, 0xF0, 0xA3,
707/*14B0*/0xEF, 0xF0, 0x22, 0x75, 0x34, 0x01, 0x22, 0x8E,
708 0x58, 0x8F, 0x59, 0x8C, 0x5A, 0x8D, 0x5B, 0x8A,
709/*14C0*/0x5C, 0x8B, 0x5D, 0x75, 0x5E, 0x01, 0xE4, 0xF5,
710 0x5F, 0x12, 0x1E, 0xA5, 0x85, 0x59, 0x5E, 0xD3,
711/*14D0*/0xE5, 0x5E, 0x95, 0x5B, 0xE5, 0x5A, 0x12, 0x07,
712 0x6B, 0x50, 0x57, 0xE5, 0x5D, 0x45, 0x5C, 0x70,
713/*14E0*/0x30, 0x12, 0x07, 0x2A, 0x75, 0x83, 0x92, 0xE5,
714 0x5E, 0x12, 0x07, 0x29, 0x75, 0x83, 0xC6, 0xE5,
715/*14F0*/0x5E, 0x12, 0x07, 0x29, 0x75, 0x83, 0xC8, 0xE5,
716 0x5E, 0x12, 0x07, 0x29, 0x75, 0x83, 0x90, 0xE5,
717/*1500*/0x5E, 0x12, 0x07, 0x29, 0x75, 0x83, 0xC2, 0xE5,
718 0x5E, 0x12, 0x07, 0x29, 0x75, 0x83, 0xC4, 0x80,
719/*1510*/0x03, 0x12, 0x07, 0x32, 0xE5, 0x5E, 0xF0, 0xAF,
720 0x5F, 0x7E, 0x00, 0xAD, 0x5D, 0xAC, 0x5C, 0x12,
721/*1520*/0x04, 0x44, 0xAF, 0x5E, 0x7E, 0x00, 0xAD, 0x5D,
722 0xAC, 0x5C, 0x12, 0x0B, 0xD1, 0x05, 0x5E, 0x02,
723/*1530*/0x14, 0xCF, 0xAB, 0x5D, 0xAA, 0x5C, 0xAD, 0x5B,
724 0xAC, 0x5A, 0xAF, 0x59, 0xAE, 0x58, 0x02, 0x1B,
725/*1540*/0xFB, 0x8C, 0x5C, 0x8D, 0x5D, 0x8A, 0x5E, 0x8B,
726 0x5F, 0x75, 0x60, 0x01, 0xE4, 0xF5, 0x61, 0xF5,
727/*1550*/0x62, 0xF5, 0x63, 0x12, 0x1E, 0xA5, 0x8F, 0x60,
728 0xD3, 0xE5, 0x60, 0x95, 0x5D, 0xE5, 0x5C, 0x12,
729/*1560*/0x07, 0x6B, 0x50, 0x61, 0xE5, 0x5F, 0x45, 0x5E,
730 0x70, 0x27, 0x12, 0x07, 0x2A, 0x75, 0x83, 0xB6,
731/*1570*/0xE5, 0x60, 0x12, 0x07, 0x29, 0x75, 0x83, 0xB8,
732 0xE5, 0x60, 0x12, 0x07, 0x29, 0x75, 0x83, 0xBA,
733/*1580*/0xE5, 0x60, 0xF0, 0xAF, 0x61, 0x7E, 0x00, 0xE5,
734 0x62, 0x12, 0x08, 0x7A, 0x12, 0x0A, 0xFF, 0x80,
735/*1590*/0x19, 0x90, 0x07, 0x24, 0x12, 0x07, 0x35, 0xE5,
736 0x60, 0x12, 0x07, 0x29, 0x75, 0x83, 0x8E, 0xE4,
737/*15A0*/0x12, 0x07, 0x29, 0x74, 0x01, 0x12, 0x07, 0x29,
738 0xE4, 0xF0, 0xAF, 0x63, 0x7E, 0x00, 0xAD, 0x5F,
739/*15B0*/0xAC, 0x5E, 0x12, 0x04, 0x44, 0xAF, 0x60, 0x7E,
740 0x00, 0xAD, 0x5F, 0xAC, 0x5E, 0x12, 0x12, 0x8B,
741/*15C0*/0x05, 0x60, 0x02, 0x15, 0x58, 0x22, 0x90, 0x11,
742 0x4D, 0xE4, 0x93, 0x90, 0x07, 0x2E, 0xF0, 0x12,
743/*15D0*/0x08, 0x1F, 0x75, 0x83, 0xAE, 0xE0, 0x54, 0x1A,
744 0xF5, 0x34, 0x70, 0x67, 0xEF, 0x44, 0x07, 0xF5,
745/*15E0*/0x82, 0x75, 0x83, 0xCE, 0xE0, 0xFF, 0x13, 0x13,
746 0x13, 0x54, 0x07, 0xF5, 0x36, 0x54, 0x0F, 0xD3,
747/*15F0*/0x94, 0x00, 0x40, 0x06, 0x12, 0x14, 0x2D, 0x12,
748 0x1B, 0xA9, 0xE5, 0x36, 0x54, 0x0F, 0x24, 0xFE,
749/*1600*/0x60, 0x0C, 0x14, 0x60, 0x0C, 0x14, 0x60, 0x19,
750 0x24, 0x03, 0x70, 0x37, 0x80, 0x10, 0x02, 0x1E,
751/*1610*/0x91, 0x12, 0x1E, 0x91, 0x12, 0x07, 0x2A, 0x75,
752 0x83, 0xCE, 0xE0, 0x54, 0xEF, 0xF0, 0x02, 0x1D,
753/*1620*/0xAE, 0x12, 0x10, 0x14, 0xE4, 0xF5, 0x55, 0x12,
754 0x1D, 0x85, 0x05, 0x55, 0xE5, 0x55, 0xC3, 0x94,
755/*1630*/0x05, 0x40, 0xF4, 0x12, 0x07, 0x2A, 0x75, 0x83,
756 0xCE, 0xE0, 0x54, 0xC7, 0x12, 0x07, 0x29, 0xE0,
757/*1640*/0x44, 0x08, 0xF0, 0x22, 0xE4, 0xF5, 0x58, 0xF5,
758 0x59, 0xAF, 0x08, 0xEF, 0x44, 0x07, 0xF5, 0x82,
759/*1650*/0x75, 0x83, 0xD0, 0xE0, 0xFD, 0xC4, 0x54, 0x0F,
760 0xF5, 0x5A, 0xEF, 0x44, 0x07, 0xF5, 0x82, 0x75,
761/*1660*/0x83, 0x80, 0x74, 0x01, 0xF0, 0x12, 0x08, 0x21,
762 0x75, 0x83, 0x82, 0xE5, 0x45, 0xF0, 0xEF, 0x44,
763/*1670*/0x07, 0xF5, 0x82, 0x75, 0x83, 0x8A, 0x74, 0xFF,
764 0xF0, 0x12, 0x1A, 0x4D, 0x12, 0x07, 0x2A, 0x75,
765/*1680*/0x83, 0xBC, 0xE0, 0x54, 0xEF, 0x12, 0x07, 0x29,
766 0x75, 0x83, 0xBE, 0xE0, 0x54, 0xEF, 0x12, 0x07,
767/*1690*/0x29, 0x75, 0x83, 0xC0, 0xE0, 0x54, 0xEF, 0x12,
768 0x07, 0x29, 0x75, 0x83, 0xBC, 0xE0, 0x44, 0x10,
769/*16A0*/0x12, 0x07, 0x29, 0x75, 0x83, 0xBE, 0xE0, 0x44,
770 0x10, 0x12, 0x07, 0x29, 0x75, 0x83, 0xC0, 0xE0,
771/*16B0*/0x44, 0x10, 0xF0, 0xAF, 0x58, 0xE5, 0x59, 0x12,
772 0x08, 0x78, 0x02, 0x0A, 0xFF, 0xE4, 0xF5, 0x58,
773/*16C0*/0x7D, 0x01, 0xF5, 0x59, 0xAF, 0x35, 0xFE, 0xFC,
774 0x12, 0x09, 0x15, 0x12, 0x07, 0x2A, 0x75, 0x83,
775/*16D0*/0xB6, 0x74, 0x10, 0x12, 0x07, 0x29, 0x75, 0x83,
776 0xB8, 0x74, 0x10, 0x12, 0x07, 0x29, 0x75, 0x83,
777/*16E0*/0xBA, 0x74, 0x10, 0x12, 0x07, 0x29, 0x75, 0x83,
778 0xBC, 0x74, 0x10, 0x12, 0x07, 0x29, 0x75, 0x83,
779/*16F0*/0xBE, 0x74, 0x10, 0x12, 0x07, 0x29, 0x75, 0x83,
780 0xC0, 0x74, 0x10, 0x12, 0x07, 0x29, 0x75, 0x83,
781/*1700*/0x90, 0xE4, 0x12, 0x07, 0x29, 0x75, 0x83, 0xC2,
782 0xE4, 0x12, 0x07, 0x29, 0x75, 0x83, 0xC4, 0xE4,
783/*1710*/0x12, 0x07, 0x29, 0x75, 0x83, 0x92, 0xE4, 0x12,
784 0x07, 0x29, 0x75, 0x83, 0xC6, 0xE4, 0x12, 0x07,
785/*1720*/0x29, 0x75, 0x83, 0xC8, 0xE4, 0xF0, 0xAF, 0x58,
786 0xFE, 0xE5, 0x59, 0x12, 0x08, 0x7A, 0x02, 0x0A,
787/*1730*/0xFF, 0xE5, 0xE2, 0x30, 0xE4, 0x6C, 0xE5, 0xE7,
788 0x54, 0xC0, 0x64, 0x40, 0x70, 0x64, 0xE5, 0x09,
789/*1740*/0xC4, 0x54, 0x30, 0xFE, 0xE5, 0x08, 0x25, 0xE0,
790 0x25, 0xE0, 0x54, 0xC0, 0x4E, 0xFE, 0xEF, 0x54,
791/*1750*/0x3F, 0x4E, 0xFD, 0xE5, 0x2B, 0xAE, 0x2A, 0x78,
792 0x02, 0xC3, 0x33, 0xCE, 0x33, 0xCE, 0xD8, 0xF9,
793/*1760*/0xF5, 0x82, 0x8E, 0x83, 0xED, 0xF0, 0xE5, 0x2B,
794 0xAE, 0x2A, 0x78, 0x02, 0xC3, 0x33, 0xCE, 0x33,
795/*1770*/0xCE, 0xD8, 0xF9, 0xFF, 0xF5, 0x82, 0x8E, 0x83,
796 0xA3, 0xE5, 0xFE, 0xF0, 0x8F, 0x82, 0x8E, 0x83,
797/*1780*/0xA3, 0xA3, 0xE5, 0xFD, 0xF0, 0x8F, 0x82, 0x8E,
798 0x83, 0xA3, 0xA3, 0xA3, 0xE5, 0xFC, 0xF0, 0xC3,
799/*1790*/0xE5, 0x2B, 0x94, 0xFA, 0xE5, 0x2A, 0x94, 0x00,
800 0x50, 0x08, 0x05, 0x2B, 0xE5, 0x2B, 0x70, 0x02,
801/*17A0*/0x05, 0x2A, 0x22, 0xE4, 0xFF, 0xE4, 0xF5, 0x58,
802 0xF5, 0x56, 0xF5, 0x57, 0x74, 0x82, 0xFC, 0x12,
803/*17B0*/0x0E, 0x04, 0x8C, 0x83, 0xE0, 0xF5, 0x10, 0x54,
804 0x7F, 0xF0, 0xE5, 0x10, 0x44, 0x80, 0x12, 0x0E,
805/*17C0*/0x98, 0xED, 0xF0, 0x7E, 0x0A, 0x12, 0x0E, 0x04,
806 0x75, 0x83, 0xA0, 0xE0, 0x20, 0xE0, 0x26, 0xDE,
807/*17D0*/0xF4, 0x05, 0x57, 0xE5, 0x57, 0x70, 0x02, 0x05,
808 0x56, 0xE5, 0x14, 0x24, 0x01, 0xFD, 0xE4, 0x33,
809/*17E0*/0xFC, 0xD3, 0xE5, 0x57, 0x9D, 0xE5, 0x56, 0x9C,
810 0x40, 0xD9, 0xE5, 0x0A, 0x94, 0x20, 0x50, 0x02,
811/*17F0*/0x05, 0x0A, 0x43, 0xE1, 0x08, 0xC2, 0x31, 0x12,
812 0x0E, 0x04, 0x75, 0x83, 0xA6, 0xE0, 0x55, 0x12,
813/*1800*/0x65, 0x12, 0x70, 0x03, 0xD2, 0x31, 0x22, 0xC2,
814 0x31, 0x22, 0x90, 0x07, 0x26, 0xE0, 0xFA, 0xA3,
815/*1810*/0xE0, 0xF5, 0x82, 0x8A, 0x83, 0xE0, 0xF5, 0x41,
816 0xE5, 0x39, 0xC3, 0x95, 0x41, 0x40, 0x26, 0xE5,
817/*1820*/0x39, 0x95, 0x41, 0xC3, 0x9F, 0xEE, 0x12, 0x07,
818 0x6B, 0x40, 0x04, 0x7C, 0x01, 0x80, 0x02, 0x7C,
819/*1830*/0x00, 0xE5, 0x41, 0x64, 0x3F, 0x60, 0x04, 0x7B,
820 0x01, 0x80, 0x02, 0x7B, 0x00, 0xEC, 0x5B, 0x60,
821/*1840*/0x29, 0x05, 0x41, 0x80, 0x28, 0xC3, 0xE5, 0x41,
822 0x95, 0x39, 0xC3, 0x9F, 0xEE, 0x12, 0x07, 0x6B,
823/*1850*/0x40, 0x04, 0x7F, 0x01, 0x80, 0x02, 0x7F, 0x00,
824 0xE5, 0x41, 0x60, 0x04, 0x7E, 0x01, 0x80, 0x02,
825/*1860*/0x7E, 0x00, 0xEF, 0x5E, 0x60, 0x04, 0x15, 0x41,
826 0x80, 0x03, 0x85, 0x39, 0x41, 0x85, 0x3A, 0x40,
827/*1870*/0x22, 0xE5, 0xE2, 0x30, 0xE4, 0x60, 0xE5, 0xE1,
828 0x30, 0xE2, 0x5B, 0xE5, 0x09, 0x70, 0x04, 0x7F,
829/*1880*/0x01, 0x80, 0x02, 0x7F, 0x00, 0xE5, 0x08, 0x70,
830 0x04, 0x7E, 0x01, 0x80, 0x02, 0x7E, 0x00, 0xEE,
831/*1890*/0x5F, 0x60, 0x43, 0x53, 0xF9, 0xF8, 0xE5, 0xE2,
832 0x30, 0xE4, 0x3B, 0xE5, 0xE1, 0x30, 0xE2, 0x2E,
833/*18A0*/0x43, 0xFA, 0x02, 0x53, 0xFA, 0xFB, 0xE4, 0xF5,
834 0x10, 0x90, 0x94, 0x70, 0xE5, 0x10, 0xF0, 0xE5,
835/*18B0*/0xE1, 0x30, 0xE2, 0xE7, 0x90, 0x94, 0x70, 0xE0,
836 0x65, 0x10, 0x60, 0x03, 0x43, 0xFA, 0x04, 0x05,
837/*18C0*/0x10, 0x90, 0x94, 0x70, 0xE5, 0x10, 0xF0, 0x70,
838 0xE6, 0x12, 0x00, 0x06, 0x80, 0xE1, 0x53, 0xFA,
839/*18D0*/0xFD, 0x53, 0xFA, 0xFB, 0x80, 0xC0, 0x22, 0x8F,
840 0x54, 0x12, 0x00, 0x06, 0xE5, 0xE1, 0x30, 0xE0,
841/*18E0*/0x04, 0x7F, 0x01, 0x80, 0x02, 0x7F, 0x00, 0xE5,
842 0x7E, 0xD3, 0x94, 0x05, 0x40, 0x04, 0x7E, 0x01,
843/*18F0*/0x80, 0x02, 0x7E, 0x00, 0xEE, 0x4F, 0x60, 0x3D,
844 0x85, 0x54, 0x11, 0xE5, 0xE2, 0x20, 0xE1, 0x32,
845/*1900*/0x74, 0xCE, 0x12, 0x1A, 0x05, 0x30, 0xE7, 0x04,
846 0x7D, 0x01, 0x80, 0x02, 0x7D, 0x00, 0x8F, 0x82,
847/*1910*/0x8E, 0x83, 0xE0, 0x30, 0xE6, 0x04, 0x7F, 0x01,
848 0x80, 0x02, 0x7F, 0x00, 0xEF, 0x5D, 0x70, 0x15,
849/*1920*/0x12, 0x15, 0xC6, 0x74, 0xCE, 0x12, 0x1A, 0x05,
850 0x30, 0xE6, 0x07, 0xE0, 0x44, 0x80, 0xF0, 0x43,
851/*1930*/0xF9, 0x80, 0x12, 0x18, 0x71, 0x22, 0x12, 0x0E,
852 0x44, 0xE5, 0x16, 0x25, 0xE0, 0x25, 0xE0, 0x24,
853/*1940*/0xB0, 0xF5, 0x82, 0xE4, 0x34, 0x1A, 0xF5, 0x83,
854 0xE4, 0x93, 0xF5, 0x0F, 0xE5, 0x16, 0x25, 0xE0,
855/*1950*/0x25, 0xE0, 0x24, 0xB1, 0xF5, 0x82, 0xE4, 0x34,
856 0x1A, 0xF5, 0x83, 0xE4, 0x93, 0xF5, 0x0E, 0x12,
857/*1960*/0x0E, 0x65, 0xF5, 0x10, 0xE5, 0x0F, 0x54, 0xF0,
858 0x12, 0x0E, 0x17, 0x75, 0x83, 0x8C, 0xEF, 0xF0,
859/*1970*/0xE5, 0x0F, 0x30, 0xE0, 0x0C, 0x12, 0x0E, 0x04,
860 0x75, 0x83, 0x86, 0xE0, 0x44, 0x40, 0xF0, 0x80,
861/*1980*/0x0A, 0x12, 0x0E, 0x04, 0x75, 0x83, 0x86, 0xE0,
862 0x54, 0xBF, 0xF0, 0x12, 0x0E, 0x91, 0x75, 0x83,
863/*1990*/0x82, 0xE5, 0x0E, 0xF0, 0x22, 0x7F, 0x05, 0x12,
864 0x17, 0x31, 0x12, 0x0E, 0x04, 0x12, 0x0E, 0x33,
865/*19A0*/0x74, 0x02, 0xF0, 0x74, 0x8E, 0xFE, 0x12, 0x0E,
866 0x04, 0x12, 0x0E, 0x0B, 0xEF, 0xF0, 0x75, 0x15,
867/*19B0*/0x70, 0x12, 0x0F, 0xF7, 0x20, 0x34, 0x05, 0x75,
868 0x15, 0x10, 0x80, 0x03, 0x75, 0x15, 0x50, 0x12,
869/*19C0*/0x0F, 0xF7, 0x20, 0x34, 0x04, 0x74, 0x10, 0x80,
870 0x02, 0x74, 0xF0, 0x25, 0x15, 0xF5, 0x15, 0x12,
871/*19D0*/0x0E, 0x21, 0xEF, 0xF0, 0x12, 0x10, 0x91, 0x20,
872 0x34, 0x17, 0xE5, 0x15, 0x64, 0x30, 0x60, 0x0C,
873/*19E0*/0x74, 0x10, 0x25, 0x15, 0xF5, 0x15, 0xB4, 0x80,
874 0x03, 0xE4, 0xF5, 0x15, 0x12, 0x0E, 0x21, 0xEF,
875/*19F0*/0xF0, 0x22, 0xF0, 0xE5, 0x0B, 0x25, 0xE0, 0x25,
876 0xE0, 0x24, 0x82, 0xF5, 0x82, 0xE4, 0x34, 0x07,
877/*1A00*/0xF5, 0x83, 0x22, 0x74, 0x88, 0xFE, 0xE5, 0x08,
878 0x44, 0x07, 0xFF, 0xF5, 0x82, 0x8E, 0x83, 0xE0,
879/*1A10*/0x22, 0xF0, 0xE5, 0x08, 0x44, 0x07, 0xF5, 0x82,
880 0x22, 0xF0, 0xE0, 0x54, 0xC0, 0x8F, 0x82, 0x8E,
881/*1A20*/0x83, 0xF0, 0x22, 0xEF, 0x44, 0x07, 0xF5, 0x82,
882 0x75, 0x83, 0x86, 0xE0, 0x54, 0x10, 0xD3, 0x94,
883/*1A30*/0x00, 0x22, 0xF0, 0x90, 0x07, 0x15, 0xE0, 0x04,
884 0xF0, 0x22, 0x44, 0x06, 0xF5, 0x82, 0x75, 0x83,
885/*1A40*/0x9E, 0xE0, 0x22, 0xFE, 0xEF, 0x44, 0x07, 0xF5,
886 0x82, 0x8E, 0x83, 0xE0, 0x22, 0xE4, 0x90, 0x07,
887/*1A50*/0x2A, 0xF0, 0xA3, 0xF0, 0x12, 0x07, 0x2A, 0x75,
888 0x83, 0x82, 0xE0, 0x54, 0x7F, 0x12, 0x07, 0x29,
889/*1A60*/0xE0, 0x44, 0x80, 0xF0, 0x12, 0x10, 0xFC, 0x12,
890 0x08, 0x1F, 0x75, 0x83, 0xA0, 0xE0, 0x20, 0xE0,
891/*1A70*/0x1A, 0x90, 0x07, 0x2B, 0xE0, 0x04, 0xF0, 0x70,
892 0x06, 0x90, 0x07, 0x2A, 0xE0, 0x04, 0xF0, 0x90,
893/*1A80*/0x07, 0x2A, 0xE0, 0xB4, 0x10, 0xE1, 0xA3, 0xE0,
894 0xB4, 0x00, 0xDC, 0xEE, 0x44, 0xA6, 0xFC, 0xEF,
895/*1A90*/0x44, 0x07, 0xF5, 0x82, 0x8C, 0x83, 0xE0, 0xF5,
896 0x32, 0xEE, 0x44, 0xA8, 0xFE, 0xEF, 0x44, 0x07,
897/*1AA0*/0xF5, 0x82, 0x8E, 0x83, 0xE0, 0xF5, 0x33, 0x22,
898 0x01, 0x20, 0x11, 0x00, 0x04, 0x20, 0x00, 0x90,
899/*1AB0*/0x00, 0x20, 0x0F, 0x92, 0x00, 0x21, 0x0F, 0x94,
900 0x00, 0x22, 0x0F, 0x96, 0x00, 0x23, 0x0F, 0x98,
901/*1AC0*/0x00, 0x24, 0x0F, 0x9A, 0x00, 0x25, 0x0F, 0x9C,
902 0x00, 0x26, 0x0F, 0x9E, 0x00, 0x27, 0x0F, 0xA0,
903/*1AD0*/0x01, 0x20, 0x01, 0xA2, 0x01, 0x21, 0x01, 0xA4,
904 0x01, 0x22, 0x01, 0xA6, 0x01, 0x23, 0x01, 0xA8,
905/*1AE0*/0x01, 0x24, 0x01, 0xAA, 0x01, 0x25, 0x01, 0xAC,
906 0x01, 0x26, 0x01, 0xAE, 0x01, 0x27, 0x01, 0xB0,
907/*1AF0*/0x01, 0x28, 0x01, 0xB4, 0x00, 0x28, 0x0F, 0xB6,
908 0x40, 0x28, 0x0F, 0xB8, 0x61, 0x28, 0x01, 0xCB,
909/*1B00*/0xEF, 0xCB, 0xCA, 0xEE, 0xCA, 0x7F, 0x01, 0xE4,
910 0xFD, 0xEB, 0x4A, 0x70, 0x24, 0xE5, 0x08, 0xF5,
911/*1B10*/0x82, 0x74, 0xB6, 0x12, 0x08, 0x29, 0xE5, 0x08,
912 0xF5, 0x82, 0x74, 0xB8, 0x12, 0x08, 0x29, 0xE5,
913/*1B20*/0x08, 0xF5, 0x82, 0x74, 0xBA, 0x12, 0x08, 0x29,
914 0x7E, 0x00, 0x7C, 0x00, 0x12, 0x0A, 0xFF, 0x80,
915/*1B30*/0x12, 0x90, 0x07, 0x26, 0x12, 0x07, 0x35, 0xE5,
916 0x41, 0xF0, 0x90, 0x07, 0x24, 0x12, 0x07, 0x35,
917/*1B40*/0xE5, 0x40, 0xF0, 0x12, 0x07, 0x2A, 0x75, 0x83,
918 0x8E, 0xE4, 0x12, 0x07, 0x29, 0x74, 0x01, 0x12,
919/*1B50*/0x07, 0x29, 0xE4, 0xF0, 0x22, 0xE4, 0xF5, 0x26,
920 0xF5, 0x27, 0x53, 0xE1, 0xFE, 0xF5, 0x2A, 0x75,
921/*1B60*/0x2B, 0x01, 0xF5, 0x08, 0x7F, 0x01, 0x12, 0x17,
922 0x31, 0x30, 0x30, 0x1C, 0x90, 0x1A, 0xA9, 0xE4,
923/*1B70*/0x93, 0xF5, 0x10, 0x90, 0x1F, 0xF9, 0xE4, 0x93,
924 0xF5, 0x10, 0x90, 0x00, 0x41, 0xE4, 0x93, 0xF5,
925/*1B80*/0x10, 0x90, 0x1E, 0xCA, 0xE4, 0x93, 0xF5, 0x10,
926 0x7F, 0x02, 0x12, 0x17, 0x31, 0x12, 0x0F, 0x54,
927/*1B90*/0x7F, 0x03, 0x12, 0x17, 0x31, 0x12, 0x00, 0x06,
928 0xE5, 0xE2, 0x30, 0xE7, 0x09, 0x12, 0x10, 0x00,
929/*1BA0*/0x30, 0x30, 0x03, 0x12, 0x11, 0x00, 0x02, 0x00,
930 0x47, 0x12, 0x08, 0x1F, 0x75, 0x83, 0xD0, 0xE0,
931/*1BB0*/0xC4, 0x54, 0x0F, 0xFD, 0x75, 0x43, 0x01, 0x75,
932 0x44, 0xFF, 0x12, 0x08, 0xAA, 0x74, 0x04, 0xF0,
933/*1BC0*/0x75, 0x3B, 0x01, 0xED, 0x14, 0x60, 0x0C, 0x14,
934 0x60, 0x0B, 0x14, 0x60, 0x0F, 0x24, 0x03, 0x70,
935/*1BD0*/0x0B, 0x80, 0x09, 0x80, 0x00, 0x12, 0x08, 0xA7,
936 0x04, 0xF0, 0x80, 0x06, 0x12, 0x08, 0xA7, 0x74,
937/*1BE0*/0x04, 0xF0, 0xEE, 0x44, 0x82, 0xFE, 0xEF, 0x44,
938 0x07, 0xF5, 0x82, 0x8E, 0x83, 0xE5, 0x45, 0x12,
939/*1BF0*/0x08, 0xBE, 0x75, 0x83, 0x82, 0xE5, 0x31, 0xF0,
940 0x02, 0x11, 0x4C, 0x8E, 0x60, 0x8F, 0x61, 0x12,
941/*1C00*/0x1E, 0xA5, 0xE4, 0xFF, 0xCE, 0xED, 0xCE, 0xEE,
942 0xD3, 0x95, 0x61, 0xE5, 0x60, 0x12, 0x07, 0x6B,
943/*1C10*/0x40, 0x39, 0x74, 0x20, 0x2E, 0xF5, 0x82, 0xE4,
944 0x34, 0x03, 0xF5, 0x83, 0xE0, 0x70, 0x03, 0xFF,
945/*1C20*/0x80, 0x26, 0x12, 0x08, 0xE2, 0xFD, 0xC3, 0x9F,
946 0x40, 0x1E, 0xCF, 0xED, 0xCF, 0xEB, 0x4A, 0x70,
947/*1C30*/0x0B, 0x8D, 0x42, 0x12, 0x08, 0xEE, 0xF5, 0x41,
948 0x8E, 0x40, 0x80, 0x0C, 0x12, 0x08, 0xE2, 0xF5,
949/*1C40*/0x38, 0x12, 0x08, 0xEE, 0xF5, 0x39, 0x8E, 0x3A,
950 0x1E, 0x80, 0xBC, 0x22, 0x75, 0x58, 0x01, 0xE5,
951/*1C50*/0x35, 0x70, 0x0C, 0x12, 0x07, 0xCC, 0xE0, 0xF5,
952 0x4A, 0x12, 0x07, 0xD8, 0xE0, 0xF5, 0x4C, 0xE5,
953/*1C60*/0x35, 0xB4, 0x04, 0x0C, 0x12, 0x07, 0xE4, 0xE0,
954 0xF5, 0x4A, 0x12, 0x07, 0xF0, 0xE0, 0xF5, 0x4C,
955/*1C70*/0xE5, 0x35, 0xB4, 0x01, 0x04, 0x7F, 0x01, 0x80,
956 0x02, 0x7F, 0x00, 0xE5, 0x35, 0xB4, 0x02, 0x04,
957/*1C80*/0x7E, 0x01, 0x80, 0x02, 0x7E, 0x00, 0xEE, 0x4F,
958 0x60, 0x0C, 0x12, 0x07, 0xFC, 0xE0, 0xF5, 0x4A,
959/*1C90*/0x12, 0x08, 0x08, 0xE0, 0xF5, 0x4C, 0x85, 0x41,
960 0x49, 0x85, 0x40, 0x4B, 0x22, 0x75, 0x5B, 0x01,
961/*1CA0*/0x90, 0x07, 0x24, 0x12, 0x07, 0x35, 0xE0, 0x54,
962 0x1F, 0xFF, 0xD3, 0x94, 0x02, 0x50, 0x04, 0x8F,
963/*1CB0*/0x58, 0x80, 0x05, 0xEF, 0x24, 0xFE, 0xF5, 0x58,
964 0xEF, 0xC3, 0x94, 0x18, 0x40, 0x05, 0x75, 0x59,
965/*1CC0*/0x18, 0x80, 0x04, 0xEF, 0x04, 0xF5, 0x59, 0x85,
966 0x43, 0x5A, 0xAF, 0x58, 0x7E, 0x00, 0xAD, 0x59,
967/*1CD0*/0x7C, 0x00, 0xAB, 0x5B, 0x7A, 0x00, 0x12, 0x15,
968 0x41, 0xAF, 0x5A, 0x7E, 0x00, 0x12, 0x18, 0x0A,
969/*1CE0*/0xAF, 0x5B, 0x7E, 0x00, 0x02, 0x1A, 0xFF, 0xE5,
970 0xE2, 0x30, 0xE7, 0x0E, 0x12, 0x10, 0x03, 0xC2,
971/*1CF0*/0x30, 0x30, 0x30, 0x03, 0x12, 0x10, 0xFF, 0x20,
972 0x33, 0x28, 0xE5, 0xE7, 0x30, 0xE7, 0x05, 0x12,
973/*1D00*/0x0E, 0xA2, 0x80, 0x0D, 0xE5, 0xFE, 0xC3, 0x94,
974 0x20, 0x50, 0x06, 0x12, 0x0E, 0xA2, 0x43, 0xF9,
975/*1D10*/0x08, 0xE5, 0xF2, 0x30, 0xE7, 0x03, 0x53, 0xF9,
976 0x7F, 0xE5, 0xF1, 0x54, 0x70, 0xD3, 0x94, 0x00,
977/*1D20*/0x50, 0xD8, 0x22, 0x12, 0x0E, 0x04, 0x75, 0x83,
978 0x80, 0xE4, 0xF0, 0xE5, 0x08, 0x44, 0x07, 0x12,
979/*1D30*/0x0D, 0xFD, 0x75, 0x83, 0x84, 0x12, 0x0E, 0x02,
980 0x75, 0x83, 0x86, 0x12, 0x0E, 0x02, 0x75, 0x83,
981/*1D40*/0x8C, 0xE0, 0x54, 0xF3, 0x12, 0x0E, 0x03, 0x75,
982 0x83, 0x8E, 0x12, 0x0E, 0x02, 0x75, 0x83, 0x94,
983/*1D50*/0xE0, 0x54, 0xFB, 0xF0, 0x22, 0x12, 0x07, 0x2A,
984 0x75, 0x83, 0x8E, 0xE4, 0x12, 0x07, 0x29, 0x74,
985/*1D60*/0x01, 0x12, 0x07, 0x29, 0xE4, 0x12, 0x08, 0xBE,
986 0x75, 0x83, 0x8C, 0xE0, 0x44, 0x20, 0x12, 0x08,
987/*1D70*/0xBE, 0xE0, 0x54, 0xDF, 0xF0, 0x74, 0x84, 0x85,
988 0x08, 0x82, 0xF5, 0x83, 0xE0, 0x54, 0x7F, 0xF0,
989/*1D80*/0xE0, 0x44, 0x80, 0xF0, 0x22, 0x75, 0x56, 0x01,
990 0xE4, 0xFD, 0xF5, 0x57, 0xAF, 0x35, 0xFE, 0xFC,
991/*1D90*/0x12, 0x09, 0x15, 0x12, 0x1C, 0x9D, 0x12, 0x1E,
992 0x7A, 0x12, 0x1C, 0x4C, 0xAF, 0x57, 0x7E, 0x00,
993/*1DA0*/0xAD, 0x56, 0x7C, 0x00, 0x12, 0x04, 0x44, 0xAF,
994 0x56, 0x7E, 0x00, 0x02, 0x11, 0xEE, 0x75, 0x56,
995/*1DB0*/0x01, 0xE4, 0xFD, 0xF5, 0x57, 0xAF, 0x35, 0xFE,
996 0xFC, 0x12, 0x09, 0x15, 0x12, 0x1C, 0x9D, 0x12,
997/*1DC0*/0x1E, 0x7A, 0x12, 0x1C, 0x4C, 0xAF, 0x57, 0x7E,
998 0x00, 0xAD, 0x56, 0x7C, 0x00, 0x12, 0x04, 0x44,
999/*1DD0*/0xAF, 0x56, 0x7E, 0x00, 0x02, 0x11, 0xEE, 0xE4,
1000 0xF5, 0x16, 0x12, 0x0E, 0x44, 0xFE, 0xE5, 0x08,
1001/*1DE0*/0x44, 0x05, 0xFF, 0x12, 0x0E, 0x65, 0x8F, 0x82,
1002 0x8E, 0x83, 0xF0, 0x05, 0x16, 0xE5, 0x16, 0xC3,
1003/*1DF0*/0x94, 0x14, 0x40, 0xE6, 0xE5, 0x08, 0x12, 0x0E,
1004 0x2B, 0xE4, 0xF0, 0x22, 0xE4, 0xF5, 0x58, 0xF5,
1005/*1E00*/0x59, 0xF5, 0x5A, 0xFF, 0xFE, 0xAD, 0x58, 0xFC,
1006 0x12, 0x09, 0x15, 0x7F, 0x04, 0x7E, 0x00, 0xAD,
1007/*1E10*/0x58, 0x7C, 0x00, 0x12, 0x09, 0x15, 0x7F, 0x02,
1008 0x7E, 0x00, 0xAD, 0x58, 0x7C, 0x00, 0x02, 0x09,
1009/*1E20*/0x15, 0xE5, 0x3C, 0x25, 0x3E, 0xFC, 0xE5, 0x42,
1010 0x24, 0x00, 0xFB, 0xE4, 0x33, 0xFA, 0xEC, 0xC3,
1011/*1E30*/0x9B, 0xEA, 0x12, 0x07, 0x6B, 0x40, 0x0B, 0x8C,
1012 0x42, 0xE5, 0x3D, 0x25, 0x3F, 0xF5, 0x41, 0x8F,
1013/*1E40*/0x40, 0x22, 0x12, 0x09, 0x0B, 0x22, 0x74, 0x84,
1014 0xF5, 0x18, 0x85, 0x08, 0x19, 0x85, 0x19, 0x82,
1015/*1E50*/0x85, 0x18, 0x83, 0xE0, 0x54, 0x7F, 0xF0, 0xE0,
1016 0x44, 0x80, 0xF0, 0xE0, 0x44, 0x80, 0xF0, 0x22,
1017/*1E60*/0xEF, 0x4E, 0x70, 0x0B, 0x12, 0x07, 0x2A, 0x75,
1018 0x83, 0xD2, 0xE0, 0x54, 0xDF, 0xF0, 0x22, 0x12,
1019/*1E70*/0x07, 0x2A, 0x75, 0x83, 0xD2, 0xE0, 0x44, 0x20,
1020 0xF0, 0x22, 0x75, 0x58, 0x01, 0x90, 0x07, 0x26,
1021/*1E80*/0x12, 0x07, 0x35, 0xE0, 0x54, 0x3F, 0xF5, 0x41,
1022 0x12, 0x07, 0x32, 0xE0, 0x54, 0x3F, 0xF5, 0x40,
1023/*1E90*/0x22, 0x75, 0x56, 0x02, 0xE4, 0xF5, 0x57, 0x12,
1024 0x1D, 0xFC, 0xAF, 0x57, 0x7E, 0x00, 0xAD, 0x56,
1025/*1EA0*/0x7C, 0x00, 0x02, 0x04, 0x44, 0xE4, 0xF5, 0x42,
1026 0xF5, 0x41, 0xF5, 0x40, 0xF5, 0x38, 0xF5, 0x39,
1027/*1EB0*/0xF5, 0x3A, 0x22, 0xEF, 0x54, 0x07, 0xFF, 0xE5,
1028 0xF9, 0x54, 0xF8, 0x4F, 0xF5, 0xF9, 0x22, 0x7F,
1029/*1EC0*/0x01, 0xE4, 0xFE, 0x0F, 0x0E, 0xBE, 0xFF, 0xFB,
1030 0x22, 0x01, 0x20, 0x00, 0x01, 0x04, 0x20, 0x00,
1031/*1ED0*/0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1032 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1033/*1EE0*/0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1034 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1035/*1EF0*/0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1036 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1037/*1F00*/0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1038 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1039/*1F10*/0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1040 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1041/*1F20*/0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1042 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1043/*1F30*/0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1044 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1045/*1F40*/0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1046 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1047/*1F50*/0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1048 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1049/*1F60*/0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1050 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1051/*1F70*/0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1052 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1053/*1F80*/0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1054 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1055/*1F90*/0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1056 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1057/*1FA0*/0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1058 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1059/*1FB0*/0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1060 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1061/*1FC0*/0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1062 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1063/*1FD0*/0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1064 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1065/*1FE0*/0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1066 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1067/*1FF0*/0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1068 0x01, 0x20, 0x11, 0x00, 0x04, 0x20, 0x00, 0x81
1069};
1070
1071int qib_sd7220_ib_load(struct qib_devdata *dd)
1072{
1073 return qib_sd7220_prog_ld(dd, IB_7220_SERDES, qib_sd7220_ib_img,
1074 sizeof(qib_sd7220_ib_img), 0);
1075}
1076
1077int qib_sd7220_ib_vfy(struct qib_devdata *dd)
1078{
1079 return qib_sd7220_prog_vfy(dd, IB_7220_SERDES, qib_sd7220_ib_img,
1080 sizeof(qib_sd7220_ib_img), 0);
1081}
diff --git a/drivers/infiniband/hw/qib/qib_tx.c b/drivers/infiniband/hw/qib/qib_tx.c
index f7eb1ddff5f3..af30232b6831 100644
--- a/drivers/infiniband/hw/qib/qib_tx.c
+++ b/drivers/infiniband/hw/qib/qib_tx.c
@@ -340,9 +340,13 @@ rescan:
340 if (i < dd->piobcnt2k) 340 if (i < dd->piobcnt2k)
341 buf = (u32 __iomem *)(dd->pio2kbase + 341 buf = (u32 __iomem *)(dd->pio2kbase +
342 i * dd->palign); 342 i * dd->palign);
343 else 343 else if (i < dd->piobcnt2k + dd->piobcnt4k || !dd->piovl15base)
344 buf = (u32 __iomem *)(dd->pio4kbase + 344 buf = (u32 __iomem *)(dd->pio4kbase +
345 (i - dd->piobcnt2k) * dd->align4k); 345 (i - dd->piobcnt2k) * dd->align4k);
346 else
347 buf = (u32 __iomem *)(dd->piovl15base +
348 (i - (dd->piobcnt2k + dd->piobcnt4k)) *
349 dd->align4k);
346 if (pbufnum) 350 if (pbufnum)
347 *pbufnum = i; 351 *pbufnum = i;
348 dd->upd_pio_shadow = 0; 352 dd->upd_pio_shadow = 0;
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_main.c b/drivers/infiniband/ulp/ipoib/ipoib_main.c
index df3eb8c9fd96..b4b22576f12a 100644
--- a/drivers/infiniband/ulp/ipoib/ipoib_main.c
+++ b/drivers/infiniband/ulp/ipoib/ipoib_main.c
@@ -1163,7 +1163,7 @@ static ssize_t create_child(struct device *dev,
1163 1163
1164 return ret ? ret : count; 1164 return ret ? ret : count;
1165} 1165}
1166static DEVICE_ATTR(create_child, S_IWUGO, NULL, create_child); 1166static DEVICE_ATTR(create_child, S_IWUSR, NULL, create_child);
1167 1167
1168static ssize_t delete_child(struct device *dev, 1168static ssize_t delete_child(struct device *dev,
1169 struct device_attribute *attr, 1169 struct device_attribute *attr,
@@ -1183,7 +1183,7 @@ static ssize_t delete_child(struct device *dev,
1183 return ret ? ret : count; 1183 return ret ? ret : count;
1184 1184
1185} 1185}
1186static DEVICE_ATTR(delete_child, S_IWUGO, NULL, delete_child); 1186static DEVICE_ATTR(delete_child, S_IWUSR, NULL, delete_child);
1187 1187
1188int ipoib_add_pkey_attr(struct net_device *dev) 1188int ipoib_add_pkey_attr(struct net_device *dev)
1189{ 1189{
diff --git a/drivers/input/joystick/gamecon.c b/drivers/input/joystick/gamecon.c
index fbd62abb66f9..0ffaf2c77a19 100644
--- a/drivers/input/joystick/gamecon.c
+++ b/drivers/input/joystick/gamecon.c
@@ -89,7 +89,6 @@ struct gc_pad {
89struct gc { 89struct gc {
90 struct pardevice *pd; 90 struct pardevice *pd;
91 struct gc_pad pads[GC_MAX_DEVICES]; 91 struct gc_pad pads[GC_MAX_DEVICES];
92 struct input_dev *dev[GC_MAX_DEVICES];
93 struct timer_list timer; 92 struct timer_list timer;
94 int pad_count[GC_MAX]; 93 int pad_count[GC_MAX];
95 int used; 94 int used;
@@ -387,7 +386,7 @@ static void gc_nes_process_packet(struct gc *gc)
387 for (i = 0; i < GC_MAX_DEVICES; i++) { 386 for (i = 0; i < GC_MAX_DEVICES; i++) {
388 387
389 pad = &gc->pads[i]; 388 pad = &gc->pads[i];
390 dev = gc->dev[i]; 389 dev = pad->dev;
391 s = gc_status_bit[i]; 390 s = gc_status_bit[i];
392 391
393 switch (pad->type) { 392 switch (pad->type) {
@@ -579,7 +578,7 @@ static void gc_psx_command(struct gc *gc, int b, unsigned char *data)
579 read = parport_read_status(port) ^ 0x80; 578 read = parport_read_status(port) ^ 0x80;
580 579
581 for (j = 0; j < GC_MAX_DEVICES; j++) { 580 for (j = 0; j < GC_MAX_DEVICES; j++) {
582 struct gc_pad *pad = &gc->pads[i]; 581 struct gc_pad *pad = &gc->pads[j];
583 582
584 if (pad->type == GC_PSX || pad->type == GC_DDR) 583 if (pad->type == GC_PSX || pad->type == GC_DDR)
585 data[j] |= (read & gc_status_bit[j]) ? (1 << i) : 0; 584 data[j] |= (read & gc_status_bit[j]) ? (1 << i) : 0;
diff --git a/drivers/input/keyboard/Kconfig b/drivers/input/keyboard/Kconfig
index d8fa5d724c57..1ba25145b333 100644
--- a/drivers/input/keyboard/Kconfig
+++ b/drivers/input/keyboard/Kconfig
@@ -73,7 +73,7 @@ config KEYBOARD_ATKBD
73 default y 73 default y
74 select SERIO 74 select SERIO
75 select SERIO_LIBPS2 75 select SERIO_LIBPS2
76 select SERIO_I8042 if X86 && !X86_MRST 76 select SERIO_I8042 if X86
77 select SERIO_GSCPS2 if GSC 77 select SERIO_GSCPS2 if GSC
78 help 78 help
79 Say Y here if you want to use a standard AT or PS/2 keyboard. Usually 79 Say Y here if you want to use a standard AT or PS/2 keyboard. Usually
@@ -124,7 +124,7 @@ config KEYBOARD_ATKBD_RDI_KEYCODES
124 right-hand column will be interpreted as the key shown in the 124 right-hand column will be interpreted as the key shown in the
125 left-hand column. 125 left-hand column.
126 126
127config QT2160 127config KEYBOARD_QT2160
128 tristate "Atmel AT42QT2160 Touch Sensor Chip" 128 tristate "Atmel AT42QT2160 Touch Sensor Chip"
129 depends on I2C && EXPERIMENTAL 129 depends on I2C && EXPERIMENTAL
130 help 130 help
diff --git a/drivers/input/keyboard/twl4030_keypad.c b/drivers/input/keyboard/twl4030_keypad.c
index 7aa59e07b689..fb16b5e5ea13 100644
--- a/drivers/input/keyboard/twl4030_keypad.c
+++ b/drivers/input/keyboard/twl4030_keypad.c
@@ -51,8 +51,12 @@
51 */ 51 */
52#define TWL4030_MAX_ROWS 8 /* TWL4030 hard limit */ 52#define TWL4030_MAX_ROWS 8 /* TWL4030 hard limit */
53#define TWL4030_MAX_COLS 8 53#define TWL4030_MAX_COLS 8
54#define TWL4030_ROW_SHIFT 3 54/*
55#define TWL4030_KEYMAP_SIZE (TWL4030_MAX_ROWS * TWL4030_MAX_COLS) 55 * Note that we add space for an extra column so that we can handle
56 * row lines connected to the gnd (see twl4030_col_xlate()).
57 */
58#define TWL4030_ROW_SHIFT 4
59#define TWL4030_KEYMAP_SIZE (TWL4030_MAX_ROWS << TWL4030_ROW_SHIFT)
56 60
57struct twl4030_keypad { 61struct twl4030_keypad {
58 unsigned short keymap[TWL4030_KEYMAP_SIZE]; 62 unsigned short keymap[TWL4030_KEYMAP_SIZE];
@@ -182,7 +186,7 @@ static int twl4030_read_kp_matrix_state(struct twl4030_keypad *kp, u16 *state)
182 return ret; 186 return ret;
183} 187}
184 188
185static int twl4030_is_in_ghost_state(struct twl4030_keypad *kp, u16 *key_state) 189static bool twl4030_is_in_ghost_state(struct twl4030_keypad *kp, u16 *key_state)
186{ 190{
187 int i; 191 int i;
188 u16 check = 0; 192 u16 check = 0;
@@ -191,12 +195,12 @@ static int twl4030_is_in_ghost_state(struct twl4030_keypad *kp, u16 *key_state)
191 u16 col = key_state[i]; 195 u16 col = key_state[i];
192 196
193 if ((col & check) && hweight16(col) > 1) 197 if ((col & check) && hweight16(col) > 1)
194 return 1; 198 return true;
195 199
196 check |= col; 200 check |= col;
197 } 201 }
198 202
199 return 0; 203 return false;
200} 204}
201 205
202static void twl4030_kp_scan(struct twl4030_keypad *kp, bool release_all) 206static void twl4030_kp_scan(struct twl4030_keypad *kp, bool release_all)
@@ -225,7 +229,8 @@ static void twl4030_kp_scan(struct twl4030_keypad *kp, bool release_all)
225 if (!changed) 229 if (!changed)
226 continue; 230 continue;
227 231
228 for (col = 0; col < kp->n_cols; col++) { 232 /* Extra column handles "all gnd" rows */
233 for (col = 0; col < kp->n_cols + 1; col++) {
229 int code; 234 int code;
230 235
231 if (!(changed & (1 << col))) 236 if (!(changed & (1 << col)))
diff --git a/drivers/input/keyboard/w90p910_keypad.c b/drivers/input/keyboard/w90p910_keypad.c
index 4ef764cc493c..ee2bf6bcf291 100644
--- a/drivers/input/keyboard/w90p910_keypad.c
+++ b/drivers/input/keyboard/w90p910_keypad.c
@@ -258,7 +258,7 @@ static struct platform_driver w90p910_keypad_driver = {
258 .probe = w90p910_keypad_probe, 258 .probe = w90p910_keypad_probe,
259 .remove = __devexit_p(w90p910_keypad_remove), 259 .remove = __devexit_p(w90p910_keypad_remove),
260 .driver = { 260 .driver = {
261 .name = "nuc900-keypad", 261 .name = "nuc900-kpi",
262 .owner = THIS_MODULE, 262 .owner = THIS_MODULE,
263 }, 263 },
264}; 264};
diff --git a/drivers/input/misc/pcf8574_keypad.c b/drivers/input/misc/pcf8574_keypad.c
index 0ac47d2898ec..4b42ffc0532a 100644
--- a/drivers/input/misc/pcf8574_keypad.c
+++ b/drivers/input/misc/pcf8574_keypad.c
@@ -69,7 +69,7 @@ static irqreturn_t pcf8574_kp_irq_handler(int irq, void *dev_id)
69 unsigned char nextstate = read_state(lp); 69 unsigned char nextstate = read_state(lp);
70 70
71 if (lp->laststate != nextstate) { 71 if (lp->laststate != nextstate) {
72 int key_down = nextstate <= ARRAY_SIZE(lp->btncode); 72 int key_down = nextstate < ARRAY_SIZE(lp->btncode);
73 unsigned short keycode = key_down ? 73 unsigned short keycode = key_down ?
74 lp->btncode[nextstate] : lp->btncode[lp->laststate]; 74 lp->btncode[nextstate] : lp->btncode[lp->laststate];
75 75
diff --git a/drivers/input/mouse/Kconfig b/drivers/input/mouse/Kconfig
index eeb58c1cac16..c714ca2407f8 100644
--- a/drivers/input/mouse/Kconfig
+++ b/drivers/input/mouse/Kconfig
@@ -17,7 +17,7 @@ config MOUSE_PS2
17 default y 17 default y
18 select SERIO 18 select SERIO
19 select SERIO_LIBPS2 19 select SERIO_LIBPS2
20 select SERIO_I8042 if X86 && !X86_MRST 20 select SERIO_I8042 if X86
21 select SERIO_GSCPS2 if GSC 21 select SERIO_GSCPS2 if GSC
22 help 22 help
23 Say Y here if you have a PS/2 mouse connected to your system. This 23 Say Y here if you have a PS/2 mouse connected to your system. This
diff --git a/drivers/input/mouse/synaptics.c b/drivers/input/mouse/synaptics.c
index 40cea334ad13..705589dc9ac5 100644
--- a/drivers/input/mouse/synaptics.c
+++ b/drivers/input/mouse/synaptics.c
@@ -141,8 +141,13 @@ static int synaptics_capability(struct psmouse *psmouse)
141 priv->capabilities = (cap[0] << 16) | (cap[1] << 8) | cap[2]; 141 priv->capabilities = (cap[0] << 16) | (cap[1] << 8) | cap[2];
142 priv->ext_cap = priv->ext_cap_0c = 0; 142 priv->ext_cap = priv->ext_cap_0c = 0;
143 143
144 if (!SYN_CAP_VALID(priv->capabilities)) 144 /*
145 * Older firmwares had submodel ID fixed to 0x47
146 */
147 if (SYN_ID_FULL(priv->identity) < 0x705 &&
148 SYN_CAP_SUBMODEL_ID(priv->capabilities) != 0x47) {
145 return -1; 149 return -1;
150 }
146 151
147 /* 152 /*
148 * Unless capExtended is set the rest of the flags should be ignored 153 * Unless capExtended is set the rest of the flags should be ignored
@@ -206,6 +211,7 @@ static int synaptics_resolution(struct psmouse *psmouse)
206 unsigned char max[3]; 211 unsigned char max[3];
207 212
208 if (SYN_ID_MAJOR(priv->identity) < 4) 213 if (SYN_ID_MAJOR(priv->identity) < 4)
214 return 0;
209 215
210 if (synaptics_send_cmd(psmouse, SYN_QUE_RESOLUTION, res) == 0) { 216 if (synaptics_send_cmd(psmouse, SYN_QUE_RESOLUTION, res) == 0) {
211 if (res[0] != 0 && (res[1] & 0x80) && res[2] != 0) { 217 if (res[0] != 0 && (res[1] & 0x80) && res[2] != 0) {
diff --git a/drivers/input/mouse/synaptics.h b/drivers/input/mouse/synaptics.h
index 7d4d5e12c0df..b6aa7d20d8a3 100644
--- a/drivers/input/mouse/synaptics.h
+++ b/drivers/input/mouse/synaptics.h
@@ -47,7 +47,7 @@
47#define SYN_CAP_FOUR_BUTTON(c) ((c) & (1 << 3)) 47#define SYN_CAP_FOUR_BUTTON(c) ((c) & (1 << 3))
48#define SYN_CAP_MULTIFINGER(c) ((c) & (1 << 1)) 48#define SYN_CAP_MULTIFINGER(c) ((c) & (1 << 1))
49#define SYN_CAP_PALMDETECT(c) ((c) & (1 << 0)) 49#define SYN_CAP_PALMDETECT(c) ((c) & (1 << 0))
50#define SYN_CAP_VALID(c) ((((c) & 0x00ff00) >> 8) == 0x47) 50#define SYN_CAP_SUBMODEL_ID(c) (((c) & 0x00ff00) >> 8)
51#define SYN_EXT_CAP_REQUESTS(c) (((c) & 0x700000) >> 20) 51#define SYN_EXT_CAP_REQUESTS(c) (((c) & 0x700000) >> 20)
52#define SYN_CAP_MULTI_BUTTON_NO(ec) (((ec) & 0x00f000) >> 12) 52#define SYN_CAP_MULTI_BUTTON_NO(ec) (((ec) & 0x00f000) >> 12)
53#define SYN_CAP_PRODUCT_ID(ec) (((ec) & 0xff0000) >> 16) 53#define SYN_CAP_PRODUCT_ID(ec) (((ec) & 0xff0000) >> 16)
@@ -66,6 +66,7 @@
66#define SYN_ID_MODEL(i) (((i) >> 4) & 0x0f) 66#define SYN_ID_MODEL(i) (((i) >> 4) & 0x0f)
67#define SYN_ID_MAJOR(i) ((i) & 0x0f) 67#define SYN_ID_MAJOR(i) ((i) & 0x0f)
68#define SYN_ID_MINOR(i) (((i) >> 16) & 0xff) 68#define SYN_ID_MINOR(i) (((i) >> 16) & 0xff)
69#define SYN_ID_FULL(i) ((SYN_ID_MAJOR(i) << 8) | SYN_ID_MINOR(i))
69#define SYN_ID_IS_SYNAPTICS(i) ((((i) >> 8) & 0xff) == 0x47) 70#define SYN_ID_IS_SYNAPTICS(i) ((((i) >> 8) & 0xff) == 0x47)
70 71
71/* synaptics special commands */ 72/* synaptics special commands */
diff --git a/drivers/input/serio/i8042-x86ia64io.h b/drivers/input/serio/i8042-x86ia64io.h
index 6168469ad1a6..ed7ad7416b24 100644
--- a/drivers/input/serio/i8042-x86ia64io.h
+++ b/drivers/input/serio/i8042-x86ia64io.h
@@ -7,6 +7,10 @@
7 * the Free Software Foundation. 7 * the Free Software Foundation.
8 */ 8 */
9 9
10#ifdef CONFIG_X86
11#include <asm/x86_init.h>
12#endif
13
10/* 14/*
11 * Names. 15 * Names.
12 */ 16 */
@@ -166,6 +170,13 @@ static const struct dmi_system_id __initconst i8042_dmi_noloop_table[] = {
166 }, 170 },
167 }, 171 },
168 { 172 {
173 /* Gigabyte Spring Peak - defines wrong chassis type */
174 .matches = {
175 DMI_MATCH(DMI_SYS_VENDOR, "GIGABYTE"),
176 DMI_MATCH(DMI_PRODUCT_NAME, "Spring Peak"),
177 },
178 },
179 {
169 .matches = { 180 .matches = {
170 DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"), 181 DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
171 DMI_MATCH(DMI_PRODUCT_NAME, "HP Pavilion dv9700"), 182 DMI_MATCH(DMI_PRODUCT_NAME, "HP Pavilion dv9700"),
@@ -840,6 +851,12 @@ static int __init i8042_platform_init(void)
840{ 851{
841 int retval; 852 int retval;
842 853
854#ifdef CONFIG_X86
855 /* Just return if pre-detection shows no i8042 controller exist */
856 if (!x86_platform.i8042_detect())
857 return -ENODEV;
858#endif
859
843/* 860/*
844 * On ix86 platforms touching the i8042 data register region can do really 861 * On ix86 platforms touching the i8042 data register region can do really
845 * bad things. Because of this the region is always reserved on ix86 boxes. 862 * bad things. Because of this the region is always reserved on ix86 boxes.
diff --git a/drivers/input/tablet/wacom_wac.c b/drivers/input/tablet/wacom_wac.c
index d564af58175c..415f6306105d 100644
--- a/drivers/input/tablet/wacom_wac.c
+++ b/drivers/input/tablet/wacom_wac.c
@@ -284,12 +284,13 @@ static int wacom_intuos_inout(struct wacom_wac *wacom)
284 (data[4] << 20) + (data[5] << 12) + 284 (data[4] << 20) + (data[5] << 12) +
285 (data[6] << 4) + (data[7] >> 4); 285 (data[6] << 4) + (data[7] >> 4);
286 286
287 wacom->id[idx] = (data[2] << 4) | (data[3] >> 4); 287 wacom->id[idx] = (data[2] << 4) | (data[3] >> 4) |
288 ((data[7] & 0x0f) << 20) | ((data[8] & 0xf0) << 12);
288 289
289 switch (wacom->id[idx]) { 290 switch (wacom->id[idx] & 0xfffff) {
290 case 0x812: /* Inking pen */ 291 case 0x812: /* Inking pen */
291 case 0x801: /* Intuos3 Inking pen */ 292 case 0x801: /* Intuos3 Inking pen */
292 case 0x20802: /* Intuos4 Classic Pen */ 293 case 0x20802: /* Intuos4 Inking Pen */
293 case 0x012: 294 case 0x012:
294 wacom->tool[idx] = BTN_TOOL_PENCIL; 295 wacom->tool[idx] = BTN_TOOL_PENCIL;
295 break; 296 break;
@@ -513,7 +514,7 @@ static int wacom_intuos_irq(struct wacom_wac *wacom)
513 input_report_abs(input, ABS_RX, ((data[1] & 0x1f) << 8) | data[2]); 514 input_report_abs(input, ABS_RX, ((data[1] & 0x1f) << 8) | data[2]);
514 input_report_abs(input, ABS_RY, ((data[3] & 0x1f) << 8) | data[4]); 515 input_report_abs(input, ABS_RY, ((data[3] & 0x1f) << 8) | data[4]);
515 516
516 if ((data[5] & 0x1f) | (data[6] & 0x1f) | (data[1] & 0x1f) | 517 if ((data[5] & 0x1f) | data[6] | (data[1] & 0x1f) |
517 data[2] | (data[3] & 0x1f) | data[4] | data[8] | 518 data[2] | (data[3] & 0x1f) | data[4] | data[8] |
518 (data[7] & 0x01)) { 519 (data[7] & 0x01)) {
519 input_report_key(input, wacom->tool[1], 1); 520 input_report_key(input, wacom->tool[1], 1);
diff --git a/drivers/input/touchscreen/ad7877.c b/drivers/input/touchscreen/ad7877.c
index 0d2d7e54b465..5f0221cffef9 100644
--- a/drivers/input/touchscreen/ad7877.c
+++ b/drivers/input/touchscreen/ad7877.c
@@ -679,6 +679,13 @@ static int __devinit ad7877_probe(struct spi_device *spi)
679 return -EINVAL; 679 return -EINVAL;
680 } 680 }
681 681
682 spi->bits_per_word = 16;
683 err = spi_setup(spi);
684 if (err) {
685 dev_dbg(&spi->dev, "spi master doesn't support 16 bits/word\n");
686 return err;
687 }
688
682 ts = kzalloc(sizeof(struct ad7877), GFP_KERNEL); 689 ts = kzalloc(sizeof(struct ad7877), GFP_KERNEL);
683 input_dev = input_allocate_device(); 690 input_dev = input_allocate_device();
684 if (!ts || !input_dev) { 691 if (!ts || !input_dev) {
diff --git a/drivers/input/touchscreen/w90p910_ts.c b/drivers/input/touchscreen/w90p910_ts.c
index cc18265be1a8..7a45d68c3516 100644
--- a/drivers/input/touchscreen/w90p910_ts.c
+++ b/drivers/input/touchscreen/w90p910_ts.c
@@ -233,7 +233,7 @@ static int __devinit w90x900ts_probe(struct platform_device *pdev)
233 w90p910_ts->state = TS_IDLE; 233 w90p910_ts->state = TS_IDLE;
234 spin_lock_init(&w90p910_ts->lock); 234 spin_lock_init(&w90p910_ts->lock);
235 setup_timer(&w90p910_ts->timer, w90p910_check_pen_up, 235 setup_timer(&w90p910_ts->timer, w90p910_check_pen_up,
236 (unsigned long)&w90p910_ts); 236 (unsigned long)w90p910_ts);
237 237
238 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 238 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
239 if (!res) { 239 if (!res) {
diff --git a/drivers/isdn/gigaset/asyncdata.c b/drivers/isdn/gigaset/asyncdata.c
index c5016bd2d94f..c3b1dc3a13a0 100644
--- a/drivers/isdn/gigaset/asyncdata.c
+++ b/drivers/isdn/gigaset/asyncdata.c
@@ -126,26 +126,6 @@ static unsigned lock_loop(unsigned numbytes, struct inbuf_t *inbuf)
126 return numbytes; 126 return numbytes;
127} 127}
128 128
129/* set up next receive skb for data mode
130 */
131static void new_rcv_skb(struct bc_state *bcs)
132{
133 struct cardstate *cs = bcs->cs;
134 unsigned short hw_hdr_len = cs->hw_hdr_len;
135
136 if (bcs->ignore) {
137 bcs->skb = NULL;
138 return;
139 }
140
141 bcs->skb = dev_alloc_skb(SBUFSIZE + hw_hdr_len);
142 if (bcs->skb == NULL) {
143 dev_warn(cs->dev, "could not allocate new skb\n");
144 return;
145 }
146 skb_reserve(bcs->skb, hw_hdr_len);
147}
148
149/* process a block of received bytes in HDLC data mode 129/* process a block of received bytes in HDLC data mode
150 * (mstate != MS_LOCKED && !(inputstate & INS_command) && proto2 == L2_HDLC) 130 * (mstate != MS_LOCKED && !(inputstate & INS_command) && proto2 == L2_HDLC)
151 * Collect HDLC frames, undoing byte stuffing and watching for DLE escapes. 131 * Collect HDLC frames, undoing byte stuffing and watching for DLE escapes.
@@ -159,8 +139,8 @@ static unsigned hdlc_loop(unsigned numbytes, struct inbuf_t *inbuf)
159 struct cardstate *cs = inbuf->cs; 139 struct cardstate *cs = inbuf->cs;
160 struct bc_state *bcs = cs->bcs; 140 struct bc_state *bcs = cs->bcs;
161 int inputstate = bcs->inputstate; 141 int inputstate = bcs->inputstate;
162 __u16 fcs = bcs->fcs; 142 __u16 fcs = bcs->rx_fcs;
163 struct sk_buff *skb = bcs->skb; 143 struct sk_buff *skb = bcs->rx_skb;
164 unsigned char *src = inbuf->data + inbuf->head; 144 unsigned char *src = inbuf->data + inbuf->head;
165 unsigned procbytes = 0; 145 unsigned procbytes = 0;
166 unsigned char c; 146 unsigned char c;
@@ -245,8 +225,7 @@ byte_stuff:
245 225
246 /* prepare reception of next frame */ 226 /* prepare reception of next frame */
247 inputstate &= ~INS_have_data; 227 inputstate &= ~INS_have_data;
248 new_rcv_skb(bcs); 228 skb = gigaset_new_rx_skb(bcs);
249 skb = bcs->skb;
250 } else { 229 } else {
251 /* empty frame (7E 7E) */ 230 /* empty frame (7E 7E) */
252#ifdef CONFIG_GIGASET_DEBUG 231#ifdef CONFIG_GIGASET_DEBUG
@@ -255,8 +234,7 @@ byte_stuff:
255 if (!skb) { 234 if (!skb) {
256 /* skipped (?) */ 235 /* skipped (?) */
257 gigaset_isdn_rcv_err(bcs); 236 gigaset_isdn_rcv_err(bcs);
258 new_rcv_skb(bcs); 237 skb = gigaset_new_rx_skb(bcs);
259 skb = bcs->skb;
260 } 238 }
261 } 239 }
262 240
@@ -279,11 +257,11 @@ byte_stuff:
279#endif 257#endif
280 inputstate |= INS_have_data; 258 inputstate |= INS_have_data;
281 if (skb) { 259 if (skb) {
282 if (skb->len == SBUFSIZE) { 260 if (skb->len >= bcs->rx_bufsize) {
283 dev_warn(cs->dev, "received packet too long\n"); 261 dev_warn(cs->dev, "received packet too long\n");
284 dev_kfree_skb_any(skb); 262 dev_kfree_skb_any(skb);
285 /* skip remainder of packet */ 263 /* skip remainder of packet */
286 bcs->skb = skb = NULL; 264 bcs->rx_skb = skb = NULL;
287 } else { 265 } else {
288 *__skb_put(skb, 1) = c; 266 *__skb_put(skb, 1) = c;
289 fcs = crc_ccitt_byte(fcs, c); 267 fcs = crc_ccitt_byte(fcs, c);
@@ -292,7 +270,7 @@ byte_stuff:
292 } 270 }
293 271
294 bcs->inputstate = inputstate; 272 bcs->inputstate = inputstate;
295 bcs->fcs = fcs; 273 bcs->rx_fcs = fcs;
296 return procbytes; 274 return procbytes;
297} 275}
298 276
@@ -308,18 +286,18 @@ static unsigned iraw_loop(unsigned numbytes, struct inbuf_t *inbuf)
308 struct cardstate *cs = inbuf->cs; 286 struct cardstate *cs = inbuf->cs;
309 struct bc_state *bcs = cs->bcs; 287 struct bc_state *bcs = cs->bcs;
310 int inputstate = bcs->inputstate; 288 int inputstate = bcs->inputstate;
311 struct sk_buff *skb = bcs->skb; 289 struct sk_buff *skb = bcs->rx_skb;
312 unsigned char *src = inbuf->data + inbuf->head; 290 unsigned char *src = inbuf->data + inbuf->head;
313 unsigned procbytes = 0; 291 unsigned procbytes = 0;
314 unsigned char c; 292 unsigned char c;
315 293
316 if (!skb) { 294 if (!skb) {
317 /* skip this block */ 295 /* skip this block */
318 new_rcv_skb(bcs); 296 gigaset_new_rx_skb(bcs);
319 return numbytes; 297 return numbytes;
320 } 298 }
321 299
322 while (procbytes < numbytes && skb->len < SBUFSIZE) { 300 while (procbytes < numbytes && skb->len < bcs->rx_bufsize) {
323 c = *src++; 301 c = *src++;
324 procbytes++; 302 procbytes++;
325 303
@@ -343,7 +321,7 @@ static unsigned iraw_loop(unsigned numbytes, struct inbuf_t *inbuf)
343 if (inputstate & INS_have_data) { 321 if (inputstate & INS_have_data) {
344 gigaset_skb_rcvd(bcs, skb); 322 gigaset_skb_rcvd(bcs, skb);
345 inputstate &= ~INS_have_data; 323 inputstate &= ~INS_have_data;
346 new_rcv_skb(bcs); 324 gigaset_new_rx_skb(bcs);
347 } 325 }
348 326
349 bcs->inputstate = inputstate; 327 bcs->inputstate = inputstate;
diff --git a/drivers/isdn/gigaset/capi.c b/drivers/isdn/gigaset/capi.c
index 8f78f15c8ef7..6fbe8999c419 100644
--- a/drivers/isdn/gigaset/capi.c
+++ b/drivers/isdn/gigaset/capi.c
@@ -70,7 +70,7 @@
70#define MAX_NUMBER_DIGITS 20 70#define MAX_NUMBER_DIGITS 20
71#define MAX_FMT_IE_LEN 20 71#define MAX_FMT_IE_LEN 20
72 72
73/* values for gigaset_capi_appl.connected */ 73/* values for bcs->apconnstate */
74#define APCONN_NONE 0 /* inactive/listening */ 74#define APCONN_NONE 0 /* inactive/listening */
75#define APCONN_SETUP 1 /* connecting */ 75#define APCONN_SETUP 1 /* connecting */
76#define APCONN_ACTIVE 2 /* B channel up */ 76#define APCONN_ACTIVE 2 /* B channel up */
@@ -80,10 +80,10 @@ struct gigaset_capi_appl {
80 struct list_head ctrlist; 80 struct list_head ctrlist;
81 struct gigaset_capi_appl *bcnext; 81 struct gigaset_capi_appl *bcnext;
82 u16 id; 82 u16 id;
83 struct capi_register_params rp;
83 u16 nextMessageNumber; 84 u16 nextMessageNumber;
84 u32 listenInfoMask; 85 u32 listenInfoMask;
85 u32 listenCIPmask; 86 u32 listenCIPmask;
86 int connected;
87}; 87};
88 88
89/* CAPI specific controller data structure */ 89/* CAPI specific controller data structure */
@@ -319,6 +319,39 @@ static const char *format_ie(const char *ie)
319 return result; 319 return result;
320} 320}
321 321
322/*
323 * emit DATA_B3_CONF message
324 */
325static void send_data_b3_conf(struct cardstate *cs, struct capi_ctr *ctr,
326 u16 appl, u16 msgid, int channel,
327 u16 handle, u16 info)
328{
329 struct sk_buff *cskb;
330 u8 *msg;
331
332 cskb = alloc_skb(CAPI_DATA_B3_CONF_LEN, GFP_ATOMIC);
333 if (!cskb) {
334 dev_err(cs->dev, "%s: out of memory\n", __func__);
335 return;
336 }
337 /* frequent message, avoid _cmsg overhead */
338 msg = __skb_put(cskb, CAPI_DATA_B3_CONF_LEN);
339 CAPIMSG_SETLEN(msg, CAPI_DATA_B3_CONF_LEN);
340 CAPIMSG_SETAPPID(msg, appl);
341 CAPIMSG_SETCOMMAND(msg, CAPI_DATA_B3);
342 CAPIMSG_SETSUBCOMMAND(msg, CAPI_CONF);
343 CAPIMSG_SETMSGID(msg, msgid);
344 CAPIMSG_SETCONTROLLER(msg, ctr->cnr);
345 CAPIMSG_SETPLCI_PART(msg, channel);
346 CAPIMSG_SETNCCI_PART(msg, 1);
347 CAPIMSG_SETHANDLE_CONF(msg, handle);
348 CAPIMSG_SETINFO_CONF(msg, info);
349
350 /* emit message */
351 dump_rawmsg(DEBUG_MCMD, __func__, msg);
352 capi_ctr_handle_message(ctr, appl, cskb);
353}
354
322 355
323/* 356/*
324 * driver interface functions 357 * driver interface functions
@@ -339,7 +372,6 @@ void gigaset_skb_sent(struct bc_state *bcs, struct sk_buff *dskb)
339 struct gigaset_capi_ctr *iif = cs->iif; 372 struct gigaset_capi_ctr *iif = cs->iif;
340 struct gigaset_capi_appl *ap = bcs->ap; 373 struct gigaset_capi_appl *ap = bcs->ap;
341 unsigned char *req = skb_mac_header(dskb); 374 unsigned char *req = skb_mac_header(dskb);
342 struct sk_buff *cskb;
343 u16 flags; 375 u16 flags;
344 376
345 /* update statistics */ 377 /* update statistics */
@@ -351,39 +383,22 @@ void gigaset_skb_sent(struct bc_state *bcs, struct sk_buff *dskb)
351 } 383 }
352 384
353 /* don't send further B3 messages if disconnected */ 385 /* don't send further B3 messages if disconnected */
354 if (ap->connected < APCONN_ACTIVE) { 386 if (bcs->apconnstate < APCONN_ACTIVE) {
355 gig_dbg(DEBUG_LLDATA, "disconnected, discarding ack"); 387 gig_dbg(DEBUG_LLDATA, "disconnected, discarding ack");
356 return; 388 return;
357 } 389 }
358 390
359 /* ToDo: honor unset "delivery confirmation" bit */ 391 /*
392 * send DATA_B3_CONF if "delivery confirmation" bit was set in request;
393 * otherwise it has already been sent by do_data_b3_req()
394 */
360 flags = CAPIMSG_FLAGS(req); 395 flags = CAPIMSG_FLAGS(req);
361 396 if (flags & CAPI_FLAGS_DELIVERY_CONFIRMATION)
362 /* build DATA_B3_CONF message */ 397 send_data_b3_conf(cs, &iif->ctr, ap->id, CAPIMSG_MSGID(req),
363 cskb = alloc_skb(CAPI_DATA_B3_CONF_LEN, GFP_ATOMIC); 398 bcs->channel + 1, CAPIMSG_HANDLE_REQ(req),
364 if (!cskb) { 399 (flags & ~CAPI_FLAGS_DELIVERY_CONFIRMATION) ?
365 dev_err(cs->dev, "%s: out of memory\n", __func__); 400 CapiFlagsNotSupportedByProtocol :
366 return; 401 CAPI_NOERROR);
367 }
368 /* frequent message, avoid _cmsg overhead */
369 CAPIMSG_SETLEN(cskb->data, CAPI_DATA_B3_CONF_LEN);
370 CAPIMSG_SETAPPID(cskb->data, ap->id);
371 CAPIMSG_SETCOMMAND(cskb->data, CAPI_DATA_B3);
372 CAPIMSG_SETSUBCOMMAND(cskb->data, CAPI_CONF);
373 CAPIMSG_SETMSGID(cskb->data, CAPIMSG_MSGID(req));
374 CAPIMSG_SETCONTROLLER(cskb->data, iif->ctr.cnr);
375 CAPIMSG_SETPLCI_PART(cskb->data, bcs->channel + 1);
376 CAPIMSG_SETNCCI_PART(cskb->data, 1);
377 CAPIMSG_SETHANDLE_CONF(cskb->data, CAPIMSG_HANDLE_REQ(req));
378 if (flags & ~CAPI_FLAGS_DELIVERY_CONFIRMATION)
379 CAPIMSG_SETINFO_CONF(cskb->data,
380 CapiFlagsNotSupportedByProtocol);
381 else
382 CAPIMSG_SETINFO_CONF(cskb->data, CAPI_NOERROR);
383
384 /* emit message */
385 dump_rawmsg(DEBUG_LLDATA, "DATA_B3_CONF", cskb->data);
386 capi_ctr_handle_message(&iif->ctr, ap->id, cskb);
387} 402}
388EXPORT_SYMBOL_GPL(gigaset_skb_sent); 403EXPORT_SYMBOL_GPL(gigaset_skb_sent);
389 404
@@ -412,7 +427,7 @@ void gigaset_skb_rcvd(struct bc_state *bcs, struct sk_buff *skb)
412 } 427 }
413 428
414 /* don't send further B3 messages if disconnected */ 429 /* don't send further B3 messages if disconnected */
415 if (ap->connected < APCONN_ACTIVE) { 430 if (bcs->apconnstate < APCONN_ACTIVE) {
416 gig_dbg(DEBUG_LLDATA, "disconnected, discarding data"); 431 gig_dbg(DEBUG_LLDATA, "disconnected, discarding data");
417 dev_kfree_skb_any(skb); 432 dev_kfree_skb_any(skb);
418 return; 433 return;
@@ -484,6 +499,7 @@ int gigaset_isdn_icall(struct at_state_t *at_state)
484 u32 actCIPmask; 499 u32 actCIPmask;
485 struct sk_buff *skb; 500 struct sk_buff *skb;
486 unsigned int msgsize; 501 unsigned int msgsize;
502 unsigned long flags;
487 int i; 503 int i;
488 504
489 /* 505 /*
@@ -608,7 +624,14 @@ int gigaset_isdn_icall(struct at_state_t *at_state)
608 format_ie(iif->hcmsg.CalledPartyNumber)); 624 format_ie(iif->hcmsg.CalledPartyNumber));
609 625
610 /* scan application list for matching listeners */ 626 /* scan application list for matching listeners */
611 bcs->ap = NULL; 627 spin_lock_irqsave(&bcs->aplock, flags);
628 if (bcs->ap != NULL || bcs->apconnstate != APCONN_NONE) {
629 dev_warn(cs->dev, "%s: channel not properly cleared (%p/%d)\n",
630 __func__, bcs->ap, bcs->apconnstate);
631 bcs->ap = NULL;
632 bcs->apconnstate = APCONN_NONE;
633 }
634 spin_unlock_irqrestore(&bcs->aplock, flags);
612 actCIPmask = 1 | (1 << iif->hcmsg.CIPValue); 635 actCIPmask = 1 | (1 << iif->hcmsg.CIPValue);
613 list_for_each_entry(ap, &iif->appls, ctrlist) 636 list_for_each_entry(ap, &iif->appls, ctrlist)
614 if (actCIPmask & ap->listenCIPmask) { 637 if (actCIPmask & ap->listenCIPmask) {
@@ -626,10 +649,12 @@ int gigaset_isdn_icall(struct at_state_t *at_state)
626 dump_cmsg(DEBUG_CMD, __func__, &iif->hcmsg); 649 dump_cmsg(DEBUG_CMD, __func__, &iif->hcmsg);
627 650
628 /* add to listeners on this B channel, update state */ 651 /* add to listeners on this B channel, update state */
652 spin_lock_irqsave(&bcs->aplock, flags);
629 ap->bcnext = bcs->ap; 653 ap->bcnext = bcs->ap;
630 bcs->ap = ap; 654 bcs->ap = ap;
631 bcs->chstate |= CHS_NOTIFY_LL; 655 bcs->chstate |= CHS_NOTIFY_LL;
632 ap->connected = APCONN_SETUP; 656 bcs->apconnstate = APCONN_SETUP;
657 spin_unlock_irqrestore(&bcs->aplock, flags);
633 658
634 /* emit message */ 659 /* emit message */
635 capi_ctr_handle_message(&iif->ctr, ap->id, skb); 660 capi_ctr_handle_message(&iif->ctr, ap->id, skb);
@@ -654,7 +679,7 @@ static void send_disconnect_ind(struct bc_state *bcs,
654 struct gigaset_capi_ctr *iif = cs->iif; 679 struct gigaset_capi_ctr *iif = cs->iif;
655 struct sk_buff *skb; 680 struct sk_buff *skb;
656 681
657 if (ap->connected == APCONN_NONE) 682 if (bcs->apconnstate == APCONN_NONE)
658 return; 683 return;
659 684
660 capi_cmsg_header(&iif->hcmsg, ap->id, CAPI_DISCONNECT, CAPI_IND, 685 capi_cmsg_header(&iif->hcmsg, ap->id, CAPI_DISCONNECT, CAPI_IND,
@@ -668,7 +693,6 @@ static void send_disconnect_ind(struct bc_state *bcs,
668 } 693 }
669 capi_cmsg2message(&iif->hcmsg, __skb_put(skb, CAPI_DISCONNECT_IND_LEN)); 694 capi_cmsg2message(&iif->hcmsg, __skb_put(skb, CAPI_DISCONNECT_IND_LEN));
670 dump_cmsg(DEBUG_CMD, __func__, &iif->hcmsg); 695 dump_cmsg(DEBUG_CMD, __func__, &iif->hcmsg);
671 ap->connected = APCONN_NONE;
672 capi_ctr_handle_message(&iif->ctr, ap->id, skb); 696 capi_ctr_handle_message(&iif->ctr, ap->id, skb);
673} 697}
674 698
@@ -685,9 +709,9 @@ static void send_disconnect_b3_ind(struct bc_state *bcs,
685 struct sk_buff *skb; 709 struct sk_buff *skb;
686 710
687 /* nothing to do if no logical connection active */ 711 /* nothing to do if no logical connection active */
688 if (ap->connected < APCONN_ACTIVE) 712 if (bcs->apconnstate < APCONN_ACTIVE)
689 return; 713 return;
690 ap->connected = APCONN_SETUP; 714 bcs->apconnstate = APCONN_SETUP;
691 715
692 capi_cmsg_header(&iif->hcmsg, ap->id, CAPI_DISCONNECT_B3, CAPI_IND, 716 capi_cmsg_header(&iif->hcmsg, ap->id, CAPI_DISCONNECT_B3, CAPI_IND,
693 ap->nextMessageNumber++, 717 ap->nextMessageNumber++,
@@ -714,14 +738,25 @@ void gigaset_isdn_connD(struct bc_state *bcs)
714{ 738{
715 struct cardstate *cs = bcs->cs; 739 struct cardstate *cs = bcs->cs;
716 struct gigaset_capi_ctr *iif = cs->iif; 740 struct gigaset_capi_ctr *iif = cs->iif;
717 struct gigaset_capi_appl *ap = bcs->ap; 741 struct gigaset_capi_appl *ap;
718 struct sk_buff *skb; 742 struct sk_buff *skb;
719 unsigned int msgsize; 743 unsigned int msgsize;
744 unsigned long flags;
720 745
746 spin_lock_irqsave(&bcs->aplock, flags);
747 ap = bcs->ap;
721 if (!ap) { 748 if (!ap) {
749 spin_unlock_irqrestore(&bcs->aplock, flags);
722 dev_err(cs->dev, "%s: no application\n", __func__); 750 dev_err(cs->dev, "%s: no application\n", __func__);
723 return; 751 return;
724 } 752 }
753 if (bcs->apconnstate == APCONN_NONE) {
754 spin_unlock_irqrestore(&bcs->aplock, flags);
755 dev_warn(cs->dev, "%s: application %u not connected\n",
756 __func__, ap->id);
757 return;
758 }
759 spin_unlock_irqrestore(&bcs->aplock, flags);
725 while (ap->bcnext) { 760 while (ap->bcnext) {
726 /* this should never happen */ 761 /* this should never happen */
727 dev_warn(cs->dev, "%s: dropping extra application %u\n", 762 dev_warn(cs->dev, "%s: dropping extra application %u\n",
@@ -730,11 +765,6 @@ void gigaset_isdn_connD(struct bc_state *bcs)
730 CapiCallGivenToOtherApplication); 765 CapiCallGivenToOtherApplication);
731 ap->bcnext = ap->bcnext->bcnext; 766 ap->bcnext = ap->bcnext->bcnext;
732 } 767 }
733 if (ap->connected == APCONN_NONE) {
734 dev_warn(cs->dev, "%s: application %u not connected\n",
735 __func__, ap->id);
736 return;
737 }
738 768
739 /* prepare CONNECT_ACTIVE_IND message 769 /* prepare CONNECT_ACTIVE_IND message
740 * Note: LLC not supported by device 770 * Note: LLC not supported by device
@@ -772,17 +802,24 @@ void gigaset_isdn_connD(struct bc_state *bcs)
772void gigaset_isdn_hupD(struct bc_state *bcs) 802void gigaset_isdn_hupD(struct bc_state *bcs)
773{ 803{
774 struct gigaset_capi_appl *ap; 804 struct gigaset_capi_appl *ap;
805 unsigned long flags;
775 806
776 /* 807 /*
777 * ToDo: pass on reason code reported by device 808 * ToDo: pass on reason code reported by device
778 * (requires ev-layer state machine extension to collect 809 * (requires ev-layer state machine extension to collect
779 * ZCAU device reply) 810 * ZCAU device reply)
780 */ 811 */
781 for (ap = bcs->ap; ap != NULL; ap = ap->bcnext) { 812 spin_lock_irqsave(&bcs->aplock, flags);
813 while (bcs->ap != NULL) {
814 ap = bcs->ap;
815 bcs->ap = ap->bcnext;
816 spin_unlock_irqrestore(&bcs->aplock, flags);
782 send_disconnect_b3_ind(bcs, ap); 817 send_disconnect_b3_ind(bcs, ap);
783 send_disconnect_ind(bcs, ap, 0); 818 send_disconnect_ind(bcs, ap, 0);
819 spin_lock_irqsave(&bcs->aplock, flags);
784 } 820 }
785 bcs->ap = NULL; 821 bcs->apconnstate = APCONN_NONE;
822 spin_unlock_irqrestore(&bcs->aplock, flags);
786} 823}
787 824
788/** 825/**
@@ -796,24 +833,21 @@ void gigaset_isdn_connB(struct bc_state *bcs)
796{ 833{
797 struct cardstate *cs = bcs->cs; 834 struct cardstate *cs = bcs->cs;
798 struct gigaset_capi_ctr *iif = cs->iif; 835 struct gigaset_capi_ctr *iif = cs->iif;
799 struct gigaset_capi_appl *ap = bcs->ap; 836 struct gigaset_capi_appl *ap;
800 struct sk_buff *skb; 837 struct sk_buff *skb;
838 unsigned long flags;
801 unsigned int msgsize; 839 unsigned int msgsize;
802 u8 command; 840 u8 command;
803 841
842 spin_lock_irqsave(&bcs->aplock, flags);
843 ap = bcs->ap;
804 if (!ap) { 844 if (!ap) {
845 spin_unlock_irqrestore(&bcs->aplock, flags);
805 dev_err(cs->dev, "%s: no application\n", __func__); 846 dev_err(cs->dev, "%s: no application\n", __func__);
806 return; 847 return;
807 } 848 }
808 while (ap->bcnext) { 849 if (!bcs->apconnstate) {
809 /* this should never happen */ 850 spin_unlock_irqrestore(&bcs->aplock, flags);
810 dev_warn(cs->dev, "%s: dropping extra application %u\n",
811 __func__, ap->bcnext->id);
812 send_disconnect_ind(bcs, ap->bcnext,
813 CapiCallGivenToOtherApplication);
814 ap->bcnext = ap->bcnext->bcnext;
815 }
816 if (!ap->connected) {
817 dev_warn(cs->dev, "%s: application %u not connected\n", 851 dev_warn(cs->dev, "%s: application %u not connected\n",
818 __func__, ap->id); 852 __func__, ap->id);
819 return; 853 return;
@@ -825,13 +859,26 @@ void gigaset_isdn_connB(struct bc_state *bcs)
825 * CONNECT_B3_ACTIVE_IND in reply to CONNECT_B3_RESP 859 * CONNECT_B3_ACTIVE_IND in reply to CONNECT_B3_RESP
826 * Parameters in both cases always: NCCI = 1, NCPI empty 860 * Parameters in both cases always: NCCI = 1, NCPI empty
827 */ 861 */
828 if (ap->connected >= APCONN_ACTIVE) { 862 if (bcs->apconnstate >= APCONN_ACTIVE) {
829 command = CAPI_CONNECT_B3_ACTIVE; 863 command = CAPI_CONNECT_B3_ACTIVE;
830 msgsize = CAPI_CONNECT_B3_ACTIVE_IND_BASELEN; 864 msgsize = CAPI_CONNECT_B3_ACTIVE_IND_BASELEN;
831 } else { 865 } else {
832 command = CAPI_CONNECT_B3; 866 command = CAPI_CONNECT_B3;
833 msgsize = CAPI_CONNECT_B3_IND_BASELEN; 867 msgsize = CAPI_CONNECT_B3_IND_BASELEN;
834 } 868 }
869 bcs->apconnstate = APCONN_ACTIVE;
870
871 spin_unlock_irqrestore(&bcs->aplock, flags);
872
873 while (ap->bcnext) {
874 /* this should never happen */
875 dev_warn(cs->dev, "%s: dropping extra application %u\n",
876 __func__, ap->bcnext->id);
877 send_disconnect_ind(bcs, ap->bcnext,
878 CapiCallGivenToOtherApplication);
879 ap->bcnext = ap->bcnext->bcnext;
880 }
881
835 capi_cmsg_header(&iif->hcmsg, ap->id, command, CAPI_IND, 882 capi_cmsg_header(&iif->hcmsg, ap->id, command, CAPI_IND,
836 ap->nextMessageNumber++, 883 ap->nextMessageNumber++,
837 iif->ctr.cnr | ((bcs->channel + 1) << 8) | (1 << 16)); 884 iif->ctr.cnr | ((bcs->channel + 1) << 8) | (1 << 16));
@@ -842,7 +889,6 @@ void gigaset_isdn_connB(struct bc_state *bcs)
842 } 889 }
843 capi_cmsg2message(&iif->hcmsg, __skb_put(skb, msgsize)); 890 capi_cmsg2message(&iif->hcmsg, __skb_put(skb, msgsize));
844 dump_cmsg(DEBUG_CMD, __func__, &iif->hcmsg); 891 dump_cmsg(DEBUG_CMD, __func__, &iif->hcmsg);
845 ap->connected = APCONN_ACTIVE;
846 capi_ctr_handle_message(&iif->ctr, ap->id, skb); 892 capi_ctr_handle_message(&iif->ctr, ap->id, skb);
847} 893}
848 894
@@ -945,8 +991,64 @@ static void gigaset_register_appl(struct capi_ctr *ctr, u16 appl,
945 return; 991 return;
946 } 992 }
947 ap->id = appl; 993 ap->id = appl;
994 ap->rp = *rp;
948 995
949 list_add(&ap->ctrlist, &iif->appls); 996 list_add(&ap->ctrlist, &iif->appls);
997 dev_info(cs->dev, "application %u registered\n", ap->id);
998}
999
1000/*
1001 * remove CAPI application from channel
1002 * helper function to keep indentation levels down and stay in 80 columns
1003 */
1004
1005static inline void remove_appl_from_channel(struct bc_state *bcs,
1006 struct gigaset_capi_appl *ap)
1007{
1008 struct cardstate *cs = bcs->cs;
1009 struct gigaset_capi_appl *bcap;
1010 unsigned long flags;
1011 int prevconnstate;
1012
1013 spin_lock_irqsave(&bcs->aplock, flags);
1014 bcap = bcs->ap;
1015 if (bcap == NULL) {
1016 spin_unlock_irqrestore(&bcs->aplock, flags);
1017 return;
1018 }
1019
1020 /* check first application on channel */
1021 if (bcap == ap) {
1022 bcs->ap = ap->bcnext;
1023 if (bcs->ap != NULL) {
1024 spin_unlock_irqrestore(&bcs->aplock, flags);
1025 return;
1026 }
1027
1028 /* none left, clear channel state */
1029 prevconnstate = bcs->apconnstate;
1030 bcs->apconnstate = APCONN_NONE;
1031 spin_unlock_irqrestore(&bcs->aplock, flags);
1032
1033 if (prevconnstate == APCONN_ACTIVE) {
1034 dev_notice(cs->dev, "%s: hanging up channel %u\n",
1035 __func__, bcs->channel);
1036 gigaset_add_event(cs, &bcs->at_state,
1037 EV_HUP, NULL, 0, NULL);
1038 gigaset_schedule_event(cs);
1039 }
1040 return;
1041 }
1042
1043 /* check remaining list */
1044 do {
1045 if (bcap->bcnext == ap) {
1046 bcap->bcnext = bcap->bcnext->bcnext;
1047 return;
1048 }
1049 bcap = bcap->bcnext;
1050 } while (bcap != NULL);
1051 spin_unlock_irqrestore(&bcs->aplock, flags);
950} 1052}
951 1053
952/* 1054/*
@@ -958,19 +1060,19 @@ static void gigaset_release_appl(struct capi_ctr *ctr, u16 appl)
958 = container_of(ctr, struct gigaset_capi_ctr, ctr); 1060 = container_of(ctr, struct gigaset_capi_ctr, ctr);
959 struct cardstate *cs = iif->ctr.driverdata; 1061 struct cardstate *cs = iif->ctr.driverdata;
960 struct gigaset_capi_appl *ap, *tmp; 1062 struct gigaset_capi_appl *ap, *tmp;
1063 unsigned ch;
961 1064
962 list_for_each_entry_safe(ap, tmp, &iif->appls, ctrlist) 1065 list_for_each_entry_safe(ap, tmp, &iif->appls, ctrlist)
963 if (ap->id == appl) { 1066 if (ap->id == appl) {
964 if (ap->connected != APCONN_NONE) { 1067 /* remove from any channels */
965 dev_err(cs->dev, 1068 for (ch = 0; ch < cs->channels; ch++)
966 "%s: application %u still connected\n", 1069 remove_appl_from_channel(&cs->bcs[ch], ap);
967 __func__, ap->id); 1070
968 /* ToDo: clear active connection */ 1071 /* remove from registration list */
969 }
970 list_del(&ap->ctrlist); 1072 list_del(&ap->ctrlist);
971 kfree(ap); 1073 kfree(ap);
1074 dev_info(cs->dev, "application %u released\n", appl);
972 } 1075 }
973
974} 1076}
975 1077
976/* 1078/*
@@ -1149,7 +1251,8 @@ static void do_connect_req(struct gigaset_capi_ctr *iif,
1149 char **commands; 1251 char **commands;
1150 char *s; 1252 char *s;
1151 u8 *pp; 1253 u8 *pp;
1152 int i, l; 1254 unsigned long flags;
1255 int i, l, lbc, lhlc;
1153 u16 info; 1256 u16 info;
1154 1257
1155 /* decode message */ 1258 /* decode message */
@@ -1164,8 +1267,18 @@ static void do_connect_req(struct gigaset_capi_ctr *iif,
1164 send_conf(iif, ap, skb, CapiNoPlciAvailable); 1267 send_conf(iif, ap, skb, CapiNoPlciAvailable);
1165 return; 1268 return;
1166 } 1269 }
1270 spin_lock_irqsave(&bcs->aplock, flags);
1271 if (bcs->ap != NULL || bcs->apconnstate != APCONN_NONE)
1272 dev_warn(cs->dev, "%s: channel not properly cleared (%p/%d)\n",
1273 __func__, bcs->ap, bcs->apconnstate);
1167 ap->bcnext = NULL; 1274 ap->bcnext = NULL;
1168 bcs->ap = ap; 1275 bcs->ap = ap;
1276 bcs->apconnstate = APCONN_SETUP;
1277 spin_unlock_irqrestore(&bcs->aplock, flags);
1278
1279 bcs->rx_bufsize = ap->rp.datablklen;
1280 dev_kfree_skb(bcs->rx_skb);
1281 gigaset_new_rx_skb(bcs);
1169 cmsg->adr.adrPLCI |= (bcs->channel + 1) << 8; 1282 cmsg->adr.adrPLCI |= (bcs->channel + 1) << 8;
1170 1283
1171 /* build command table */ 1284 /* build command table */
@@ -1273,42 +1386,59 @@ static void do_connect_req(struct gigaset_capi_ctr *iif,
1273 goto error; 1386 goto error;
1274 } 1387 }
1275 1388
1276 /* check/encode parameter: BC */ 1389 /*
1277 if (cmsg->BC && cmsg->BC[0]) { 1390 * check/encode parameters: BC & HLC
1278 /* explicit BC overrides CIP */ 1391 * must be encoded together as device doesn't accept HLC separately
1279 l = 2*cmsg->BC[0] + 7; 1392 * explicit parameters override values derived from CIP
1393 */
1394
1395 /* determine lengths */
1396 if (cmsg->BC && cmsg->BC[0]) /* BC specified explicitly */
1397 lbc = 2*cmsg->BC[0];
1398 else if (cip2bchlc[cmsg->CIPValue].bc) /* BC derived from CIP */
1399 lbc = strlen(cip2bchlc[cmsg->CIPValue].bc);
1400 else /* no BC */
1401 lbc = 0;
1402 if (cmsg->HLC && cmsg->HLC[0]) /* HLC specified explicitly */
1403 lhlc = 2*cmsg->HLC[0];
1404 else if (cip2bchlc[cmsg->CIPValue].hlc) /* HLC derived from CIP */
1405 lhlc = strlen(cip2bchlc[cmsg->CIPValue].hlc);
1406 else /* no HLC */
1407 lhlc = 0;
1408
1409 if (lbc) {
1410 /* have BC: allocate and assemble command string */
1411 l = lbc + 7; /* "^SBC=" + value + "\r" + null byte */
1412 if (lhlc)
1413 l += lhlc + 7; /* ";^SHLC=" + value */
1280 commands[AT_BC] = kmalloc(l, GFP_KERNEL); 1414 commands[AT_BC] = kmalloc(l, GFP_KERNEL);
1281 if (!commands[AT_BC]) 1415 if (!commands[AT_BC])
1282 goto oom; 1416 goto oom;
1283 strcpy(commands[AT_BC], "^SBC="); 1417 strcpy(commands[AT_BC], "^SBC=");
1284 decode_ie(cmsg->BC, commands[AT_BC]+5); 1418 if (cmsg->BC && cmsg->BC[0]) /* BC specified explicitly */
1419 decode_ie(cmsg->BC, commands[AT_BC] + 5);
1420 else /* BC derived from CIP */
1421 strcpy(commands[AT_BC] + 5,
1422 cip2bchlc[cmsg->CIPValue].bc);
1423 if (lhlc) {
1424 strcpy(commands[AT_BC] + lbc + 5, ";^SHLC=");
1425 if (cmsg->HLC && cmsg->HLC[0])
1426 /* HLC specified explicitly */
1427 decode_ie(cmsg->HLC,
1428 commands[AT_BC] + lbc + 12);
1429 else /* HLC derived from CIP */
1430 strcpy(commands[AT_BC] + lbc + 12,
1431 cip2bchlc[cmsg->CIPValue].hlc);
1432 }
1285 strcpy(commands[AT_BC] + l - 2, "\r"); 1433 strcpy(commands[AT_BC] + l - 2, "\r");
1286 } else if (cip2bchlc[cmsg->CIPValue].bc) { 1434 } else {
1287 l = strlen(cip2bchlc[cmsg->CIPValue].bc) + 7; 1435 /* no BC */
1288 commands[AT_BC] = kmalloc(l, GFP_KERNEL); 1436 if (lhlc) {
1289 if (!commands[AT_BC]) 1437 dev_notice(cs->dev, "%s: cannot set HLC without BC\n",
1290 goto oom; 1438 "CONNECT_REQ");
1291 snprintf(commands[AT_BC], l, "^SBC=%s\r", 1439 info = CapiIllMessageParmCoding; /* ? */
1292 cip2bchlc[cmsg->CIPValue].bc); 1440 goto error;
1293 } 1441 }
1294
1295 /* check/encode parameter: HLC */
1296 if (cmsg->HLC && cmsg->HLC[0]) {
1297 /* explicit HLC overrides CIP */
1298 l = 2*cmsg->HLC[0] + 7;
1299 commands[AT_HLC] = kmalloc(l, GFP_KERNEL);
1300 if (!commands[AT_HLC])
1301 goto oom;
1302 strcpy(commands[AT_HLC], "^SHLC=");
1303 decode_ie(cmsg->HLC, commands[AT_HLC]+5);
1304 strcpy(commands[AT_HLC] + l - 2, "\r");
1305 } else if (cip2bchlc[cmsg->CIPValue].hlc) {
1306 l = strlen(cip2bchlc[cmsg->CIPValue].hlc) + 7;
1307 commands[AT_HLC] = kmalloc(l, GFP_KERNEL);
1308 if (!commands[AT_HLC])
1309 goto oom;
1310 snprintf(commands[AT_HLC], l, "^SHLC=%s\r",
1311 cip2bchlc[cmsg->CIPValue].hlc);
1312 } 1442 }
1313 1443
1314 /* check/encode parameter: B Protocol */ 1444 /* check/encode parameter: B Protocol */
@@ -1322,13 +1452,13 @@ static void do_connect_req(struct gigaset_capi_ctr *iif,
1322 bcs->proto2 = L2_HDLC; 1452 bcs->proto2 = L2_HDLC;
1323 break; 1453 break;
1324 case 1: 1454 case 1:
1325 bcs->proto2 = L2_BITSYNC; 1455 bcs->proto2 = L2_VOICE;
1326 break; 1456 break;
1327 default: 1457 default:
1328 dev_warn(cs->dev, 1458 dev_warn(cs->dev,
1329 "B1 Protocol %u unsupported, using Transparent\n", 1459 "B1 Protocol %u unsupported, using Transparent\n",
1330 cmsg->B1protocol); 1460 cmsg->B1protocol);
1331 bcs->proto2 = L2_BITSYNC; 1461 bcs->proto2 = L2_VOICE;
1332 } 1462 }
1333 if (cmsg->B2protocol != 1) 1463 if (cmsg->B2protocol != 1)
1334 dev_warn(cs->dev, 1464 dev_warn(cs->dev,
@@ -1382,7 +1512,6 @@ static void do_connect_req(struct gigaset_capi_ctr *iif,
1382 goto error; 1512 goto error;
1383 } 1513 }
1384 gigaset_schedule_event(cs); 1514 gigaset_schedule_event(cs);
1385 ap->connected = APCONN_SETUP;
1386 send_conf(iif, ap, skb, CapiSuccess); 1515 send_conf(iif, ap, skb, CapiSuccess);
1387 return; 1516 return;
1388 1517
@@ -1410,6 +1539,7 @@ static void do_connect_resp(struct gigaset_capi_ctr *iif,
1410 _cmsg *cmsg = &iif->acmsg; 1539 _cmsg *cmsg = &iif->acmsg;
1411 struct bc_state *bcs; 1540 struct bc_state *bcs;
1412 struct gigaset_capi_appl *oap; 1541 struct gigaset_capi_appl *oap;
1542 unsigned long flags;
1413 int channel; 1543 int channel;
1414 1544
1415 /* decode message */ 1545 /* decode message */
@@ -1429,12 +1559,24 @@ static void do_connect_resp(struct gigaset_capi_ctr *iif,
1429 switch (cmsg->Reject) { 1559 switch (cmsg->Reject) {
1430 case 0: /* Accept */ 1560 case 0: /* Accept */
1431 /* drop all competing applications, keep only this one */ 1561 /* drop all competing applications, keep only this one */
1432 for (oap = bcs->ap; oap != NULL; oap = oap->bcnext) 1562 spin_lock_irqsave(&bcs->aplock, flags);
1433 if (oap != ap) 1563 while (bcs->ap != NULL) {
1564 oap = bcs->ap;
1565 bcs->ap = oap->bcnext;
1566 if (oap != ap) {
1567 spin_unlock_irqrestore(&bcs->aplock, flags);
1434 send_disconnect_ind(bcs, oap, 1568 send_disconnect_ind(bcs, oap,
1435 CapiCallGivenToOtherApplication); 1569 CapiCallGivenToOtherApplication);
1570 spin_lock_irqsave(&bcs->aplock, flags);
1571 }
1572 }
1436 ap->bcnext = NULL; 1573 ap->bcnext = NULL;
1437 bcs->ap = ap; 1574 bcs->ap = ap;
1575 spin_unlock_irqrestore(&bcs->aplock, flags);
1576
1577 bcs->rx_bufsize = ap->rp.datablklen;
1578 dev_kfree_skb(bcs->rx_skb);
1579 gigaset_new_rx_skb(bcs);
1438 bcs->chstate |= CHS_NOTIFY_LL; 1580 bcs->chstate |= CHS_NOTIFY_LL;
1439 1581
1440 /* check/encode B channel protocol */ 1582 /* check/encode B channel protocol */
@@ -1448,13 +1590,13 @@ static void do_connect_resp(struct gigaset_capi_ctr *iif,
1448 bcs->proto2 = L2_HDLC; 1590 bcs->proto2 = L2_HDLC;
1449 break; 1591 break;
1450 case 1: 1592 case 1:
1451 bcs->proto2 = L2_BITSYNC; 1593 bcs->proto2 = L2_VOICE;
1452 break; 1594 break;
1453 default: 1595 default:
1454 dev_warn(cs->dev, 1596 dev_warn(cs->dev,
1455 "B1 Protocol %u unsupported, using Transparent\n", 1597 "B1 Protocol %u unsupported, using Transparent\n",
1456 cmsg->B1protocol); 1598 cmsg->B1protocol);
1457 bcs->proto2 = L2_BITSYNC; 1599 bcs->proto2 = L2_VOICE;
1458 } 1600 }
1459 if (cmsg->B2protocol != 1) 1601 if (cmsg->B2protocol != 1)
1460 dev_warn(cs->dev, 1602 dev_warn(cs->dev,
@@ -1502,31 +1644,45 @@ static void do_connect_resp(struct gigaset_capi_ctr *iif,
1502 send_disconnect_ind(bcs, ap, 0); 1644 send_disconnect_ind(bcs, ap, 0);
1503 1645
1504 /* remove it from the list of listening apps */ 1646 /* remove it from the list of listening apps */
1647 spin_lock_irqsave(&bcs->aplock, flags);
1505 if (bcs->ap == ap) { 1648 if (bcs->ap == ap) {
1506 bcs->ap = ap->bcnext; 1649 bcs->ap = ap->bcnext;
1507 if (bcs->ap == NULL) 1650 if (bcs->ap == NULL) {
1508 /* last one: stop ev-layer hupD notifications */ 1651 /* last one: stop ev-layer hupD notifications */
1652 bcs->apconnstate = APCONN_NONE;
1509 bcs->chstate &= ~CHS_NOTIFY_LL; 1653 bcs->chstate &= ~CHS_NOTIFY_LL;
1654 }
1655 spin_unlock_irqrestore(&bcs->aplock, flags);
1510 return; 1656 return;
1511 } 1657 }
1512 for (oap = bcs->ap; oap != NULL; oap = oap->bcnext) { 1658 for (oap = bcs->ap; oap != NULL; oap = oap->bcnext) {
1513 if (oap->bcnext == ap) { 1659 if (oap->bcnext == ap) {
1514 oap->bcnext = oap->bcnext->bcnext; 1660 oap->bcnext = oap->bcnext->bcnext;
1661 spin_unlock_irqrestore(&bcs->aplock, flags);
1515 return; 1662 return;
1516 } 1663 }
1517 } 1664 }
1665 spin_unlock_irqrestore(&bcs->aplock, flags);
1518 dev_err(cs->dev, "%s: application %u not found\n", 1666 dev_err(cs->dev, "%s: application %u not found\n",
1519 __func__, ap->id); 1667 __func__, ap->id);
1520 return; 1668 return;
1521 1669
1522 default: /* Reject */ 1670 default: /* Reject */
1523 /* drop all competing applications, keep only this one */ 1671 /* drop all competing applications, keep only this one */
1524 for (oap = bcs->ap; oap != NULL; oap = oap->bcnext) 1672 spin_lock_irqsave(&bcs->aplock, flags);
1525 if (oap != ap) 1673 while (bcs->ap != NULL) {
1674 oap = bcs->ap;
1675 bcs->ap = oap->bcnext;
1676 if (oap != ap) {
1677 spin_unlock_irqrestore(&bcs->aplock, flags);
1526 send_disconnect_ind(bcs, oap, 1678 send_disconnect_ind(bcs, oap,
1527 CapiCallGivenToOtherApplication); 1679 CapiCallGivenToOtherApplication);
1680 spin_lock_irqsave(&bcs->aplock, flags);
1681 }
1682 }
1528 ap->bcnext = NULL; 1683 ap->bcnext = NULL;
1529 bcs->ap = ap; 1684 bcs->ap = ap;
1685 spin_unlock_irqrestore(&bcs->aplock, flags);
1530 1686
1531 /* reject call - will trigger DISCONNECT_IND for this app */ 1687 /* reject call - will trigger DISCONNECT_IND for this app */
1532 dev_info(cs->dev, "%s: Reject=%x\n", 1688 dev_info(cs->dev, "%s: Reject=%x\n",
@@ -1549,6 +1705,7 @@ static void do_connect_b3_req(struct gigaset_capi_ctr *iif,
1549{ 1705{
1550 struct cardstate *cs = iif->ctr.driverdata; 1706 struct cardstate *cs = iif->ctr.driverdata;
1551 _cmsg *cmsg = &iif->acmsg; 1707 _cmsg *cmsg = &iif->acmsg;
1708 struct bc_state *bcs;
1552 int channel; 1709 int channel;
1553 1710
1554 /* decode message */ 1711 /* decode message */
@@ -1563,9 +1720,10 @@ static void do_connect_b3_req(struct gigaset_capi_ctr *iif,
1563 send_conf(iif, ap, skb, CapiIllContrPlciNcci); 1720 send_conf(iif, ap, skb, CapiIllContrPlciNcci);
1564 return; 1721 return;
1565 } 1722 }
1723 bcs = &cs->bcs[channel-1];
1566 1724
1567 /* mark logical connection active */ 1725 /* mark logical connection active */
1568 ap->connected = APCONN_ACTIVE; 1726 bcs->apconnstate = APCONN_ACTIVE;
1569 1727
1570 /* build NCCI: always 1 (one B3 connection only) */ 1728 /* build NCCI: always 1 (one B3 connection only) */
1571 cmsg->adr.adrNCCI |= 1 << 16; 1729 cmsg->adr.adrNCCI |= 1 << 16;
@@ -1611,7 +1769,7 @@ static void do_connect_b3_resp(struct gigaset_capi_ctr *iif,
1611 1769
1612 if (cmsg->Reject) { 1770 if (cmsg->Reject) {
1613 /* Reject: clear B3 connect received flag */ 1771 /* Reject: clear B3 connect received flag */
1614 ap->connected = APCONN_SETUP; 1772 bcs->apconnstate = APCONN_SETUP;
1615 1773
1616 /* trigger hangup, causing eventual DISCONNECT_IND */ 1774 /* trigger hangup, causing eventual DISCONNECT_IND */
1617 if (!gigaset_add_event(cs, &bcs->at_state, 1775 if (!gigaset_add_event(cs, &bcs->at_state,
@@ -1683,11 +1841,11 @@ static void do_disconnect_req(struct gigaset_capi_ctr *iif,
1683 } 1841 }
1684 1842
1685 /* skip if DISCONNECT_IND already sent */ 1843 /* skip if DISCONNECT_IND already sent */
1686 if (!ap->connected) 1844 if (!bcs->apconnstate)
1687 return; 1845 return;
1688 1846
1689 /* check for active logical connection */ 1847 /* check for active logical connection */
1690 if (ap->connected >= APCONN_ACTIVE) { 1848 if (bcs->apconnstate >= APCONN_ACTIVE) {
1691 /* 1849 /*
1692 * emit DISCONNECT_B3_IND with cause 0x3301 1850 * emit DISCONNECT_B3_IND with cause 0x3301
1693 * use separate cmsg structure, as the content of iif->acmsg 1851 * use separate cmsg structure, as the content of iif->acmsg
@@ -1736,6 +1894,7 @@ static void do_disconnect_b3_req(struct gigaset_capi_ctr *iif,
1736{ 1894{
1737 struct cardstate *cs = iif->ctr.driverdata; 1895 struct cardstate *cs = iif->ctr.driverdata;
1738 _cmsg *cmsg = &iif->acmsg; 1896 _cmsg *cmsg = &iif->acmsg;
1897 struct bc_state *bcs;
1739 int channel; 1898 int channel;
1740 1899
1741 /* decode message */ 1900 /* decode message */
@@ -1751,17 +1910,17 @@ static void do_disconnect_b3_req(struct gigaset_capi_ctr *iif,
1751 send_conf(iif, ap, skb, CapiIllContrPlciNcci); 1910 send_conf(iif, ap, skb, CapiIllContrPlciNcci);
1752 return; 1911 return;
1753 } 1912 }
1913 bcs = &cs->bcs[channel-1];
1754 1914
1755 /* reject if logical connection not active */ 1915 /* reject if logical connection not active */
1756 if (ap->connected < APCONN_ACTIVE) { 1916 if (bcs->apconnstate < APCONN_ACTIVE) {
1757 send_conf(iif, ap, skb, 1917 send_conf(iif, ap, skb,
1758 CapiMessageNotSupportedInCurrentState); 1918 CapiMessageNotSupportedInCurrentState);
1759 return; 1919 return;
1760 } 1920 }
1761 1921
1762 /* trigger hangup, causing eventual DISCONNECT_B3_IND */ 1922 /* trigger hangup, causing eventual DISCONNECT_B3_IND */
1763 if (!gigaset_add_event(cs, &cs->bcs[channel-1].at_state, 1923 if (!gigaset_add_event(cs, &bcs->at_state, EV_HUP, NULL, 0, NULL)) {
1764 EV_HUP, NULL, 0, NULL)) {
1765 send_conf(iif, ap, skb, CAPI_MSGOSRESOURCEERR); 1924 send_conf(iif, ap, skb, CAPI_MSGOSRESOURCEERR);
1766 return; 1925 return;
1767 } 1926 }
@@ -1782,11 +1941,14 @@ static void do_data_b3_req(struct gigaset_capi_ctr *iif,
1782 struct sk_buff *skb) 1941 struct sk_buff *skb)
1783{ 1942{
1784 struct cardstate *cs = iif->ctr.driverdata; 1943 struct cardstate *cs = iif->ctr.driverdata;
1944 struct bc_state *bcs;
1785 int channel = CAPIMSG_PLCI_PART(skb->data); 1945 int channel = CAPIMSG_PLCI_PART(skb->data);
1786 u16 ncci = CAPIMSG_NCCI_PART(skb->data); 1946 u16 ncci = CAPIMSG_NCCI_PART(skb->data);
1787 u16 msglen = CAPIMSG_LEN(skb->data); 1947 u16 msglen = CAPIMSG_LEN(skb->data);
1788 u16 datalen = CAPIMSG_DATALEN(skb->data); 1948 u16 datalen = CAPIMSG_DATALEN(skb->data);
1789 u16 flags = CAPIMSG_FLAGS(skb->data); 1949 u16 flags = CAPIMSG_FLAGS(skb->data);
1950 u16 msgid = CAPIMSG_MSGID(skb->data);
1951 u16 handle = CAPIMSG_HANDLE_REQ(skb->data);
1790 1952
1791 /* frequent message, avoid _cmsg overhead */ 1953 /* frequent message, avoid _cmsg overhead */
1792 dump_rawmsg(DEBUG_LLDATA, "DATA_B3_REQ", skb->data); 1954 dump_rawmsg(DEBUG_LLDATA, "DATA_B3_REQ", skb->data);
@@ -1802,6 +1964,7 @@ static void do_data_b3_req(struct gigaset_capi_ctr *iif,
1802 send_conf(iif, ap, skb, CapiIllContrPlciNcci); 1964 send_conf(iif, ap, skb, CapiIllContrPlciNcci);
1803 return; 1965 return;
1804 } 1966 }
1967 bcs = &cs->bcs[channel-1];
1805 if (msglen != CAPI_DATA_B3_REQ_LEN && msglen != CAPI_DATA_B3_REQ_LEN64) 1968 if (msglen != CAPI_DATA_B3_REQ_LEN && msglen != CAPI_DATA_B3_REQ_LEN64)
1806 dev_notice(cs->dev, "%s: unexpected length %d\n", 1969 dev_notice(cs->dev, "%s: unexpected length %d\n",
1807 "DATA_B3_REQ", msglen); 1970 "DATA_B3_REQ", msglen);
@@ -1821,7 +1984,7 @@ static void do_data_b3_req(struct gigaset_capi_ctr *iif,
1821 } 1984 }
1822 1985
1823 /* reject if logical connection not active */ 1986 /* reject if logical connection not active */
1824 if (ap->connected < APCONN_ACTIVE) { 1987 if (bcs->apconnstate < APCONN_ACTIVE) {
1825 send_conf(iif, ap, skb, CapiMessageNotSupportedInCurrentState); 1988 send_conf(iif, ap, skb, CapiMessageNotSupportedInCurrentState);
1826 return; 1989 return;
1827 } 1990 }
@@ -1832,17 +1995,19 @@ static void do_data_b3_req(struct gigaset_capi_ctr *iif,
1832 skb_pull(skb, msglen); 1995 skb_pull(skb, msglen);
1833 1996
1834 /* pass to device-specific module */ 1997 /* pass to device-specific module */
1835 if (cs->ops->send_skb(&cs->bcs[channel-1], skb) < 0) { 1998 if (cs->ops->send_skb(bcs, skb) < 0) {
1836 send_conf(iif, ap, skb, CAPI_MSGOSRESOURCEERR); 1999 send_conf(iif, ap, skb, CAPI_MSGOSRESOURCEERR);
1837 return; 2000 return;
1838 } 2001 }
1839 2002
1840 /* DATA_B3_CONF reply will be sent by gigaset_skb_sent() */
1841
1842 /* 2003 /*
1843 * ToDo: honor unset "delivery confirmation" bit 2004 * DATA_B3_CONF will be sent by gigaset_skb_sent() only if "delivery
1844 * (send DATA_B3_CONF immediately?) 2005 * confirmation" bit is set; otherwise we have to send it now
1845 */ 2006 */
2007 if (!(flags & CAPI_FLAGS_DELIVERY_CONFIRMATION))
2008 send_data_b3_conf(cs, &iif->ctr, ap->id, msgid, channel, handle,
2009 flags ? CapiFlagsNotSupportedByProtocol
2010 : CAPI_NOERROR);
1846} 2011}
1847 2012
1848/* 2013/*
diff --git a/drivers/isdn/gigaset/common.c b/drivers/isdn/gigaset/common.c
index f6f45f221920..5d4befb81057 100644
--- a/drivers/isdn/gigaset/common.c
+++ b/drivers/isdn/gigaset/common.c
@@ -399,8 +399,8 @@ static void gigaset_freebcs(struct bc_state *bcs)
399 gig_dbg(DEBUG_INIT, "clearing bcs[%d]->at_state", bcs->channel); 399 gig_dbg(DEBUG_INIT, "clearing bcs[%d]->at_state", bcs->channel);
400 clear_at_state(&bcs->at_state); 400 clear_at_state(&bcs->at_state);
401 gig_dbg(DEBUG_INIT, "freeing bcs[%d]->skb", bcs->channel); 401 gig_dbg(DEBUG_INIT, "freeing bcs[%d]->skb", bcs->channel);
402 dev_kfree_skb(bcs->skb); 402 dev_kfree_skb(bcs->rx_skb);
403 bcs->skb = NULL; 403 bcs->rx_skb = NULL;
404 404
405 for (i = 0; i < AT_NUM; ++i) { 405 for (i = 0; i < AT_NUM; ++i) {
406 kfree(bcs->commands[i]); 406 kfree(bcs->commands[i]);
@@ -634,19 +634,10 @@ static struct bc_state *gigaset_initbcs(struct bc_state *bcs,
634 bcs->emptycount = 0; 634 bcs->emptycount = 0;
635#endif 635#endif
636 636
637 gig_dbg(DEBUG_INIT, "allocating bcs[%d]->skb", channel); 637 bcs->rx_bufsize = 0;
638 bcs->fcs = PPP_INITFCS; 638 bcs->rx_skb = NULL;
639 bcs->rx_fcs = PPP_INITFCS;
639 bcs->inputstate = 0; 640 bcs->inputstate = 0;
640 if (cs->ignoreframes) {
641 bcs->skb = NULL;
642 } else {
643 bcs->skb = dev_alloc_skb(SBUFSIZE + cs->hw_hdr_len);
644 if (bcs->skb != NULL)
645 skb_reserve(bcs->skb, cs->hw_hdr_len);
646 else
647 pr_err("out of memory\n");
648 }
649
650 bcs->channel = channel; 641 bcs->channel = channel;
651 bcs->cs = cs; 642 bcs->cs = cs;
652 643
@@ -658,16 +649,15 @@ static struct bc_state *gigaset_initbcs(struct bc_state *bcs,
658 for (i = 0; i < AT_NUM; ++i) 649 for (i = 0; i < AT_NUM; ++i)
659 bcs->commands[i] = NULL; 650 bcs->commands[i] = NULL;
660 651
652 spin_lock_init(&bcs->aplock);
653 bcs->ap = NULL;
654 bcs->apconnstate = 0;
655
661 gig_dbg(DEBUG_INIT, " setting up bcs[%d]->hw", channel); 656 gig_dbg(DEBUG_INIT, " setting up bcs[%d]->hw", channel);
662 if (cs->ops->initbcshw(bcs)) 657 if (cs->ops->initbcshw(bcs))
663 return bcs; 658 return bcs;
664 659
665 gig_dbg(DEBUG_INIT, " failed"); 660 gig_dbg(DEBUG_INIT, " failed");
666
667 gig_dbg(DEBUG_INIT, " freeing bcs[%d]->skb", channel);
668 dev_kfree_skb(bcs->skb);
669 bcs->skb = NULL;
670
671 return NULL; 661 return NULL;
672} 662}
673 663
@@ -839,14 +829,12 @@ void gigaset_bcs_reinit(struct bc_state *bcs)
839 bcs->emptycount = 0; 829 bcs->emptycount = 0;
840#endif 830#endif
841 831
842 bcs->fcs = PPP_INITFCS; 832 bcs->rx_fcs = PPP_INITFCS;
843 bcs->chstate = 0; 833 bcs->chstate = 0;
844 834
845 bcs->ignore = cs->ignoreframes; 835 bcs->ignore = cs->ignoreframes;
846 if (bcs->ignore) { 836 dev_kfree_skb(bcs->rx_skb);
847 dev_kfree_skb(bcs->skb); 837 bcs->rx_skb = NULL;
848 bcs->skb = NULL;
849 }
850 838
851 cs->ops->reinitbcshw(bcs); 839 cs->ops->reinitbcshw(bcs);
852} 840}
diff --git a/drivers/isdn/gigaset/ev-layer.c b/drivers/isdn/gigaset/ev-layer.c
index 206c380c5235..ceaef9a04a42 100644
--- a/drivers/isdn/gigaset/ev-layer.c
+++ b/drivers/isdn/gigaset/ev-layer.c
@@ -282,9 +282,7 @@ struct reply_t gigaset_tab_cid[] =
282/* dial */ 282/* dial */
283{EV_DIAL, -1, -1, -1, -1, -1, {ACT_DIAL} }, 283{EV_DIAL, -1, -1, -1, -1, -1, {ACT_DIAL} },
284{RSP_INIT, 0, 0, SEQ_DIAL, 601, 5, {ACT_CMD+AT_BC} }, 284{RSP_INIT, 0, 0, SEQ_DIAL, 601, 5, {ACT_CMD+AT_BC} },
285{RSP_OK, 601, 601, -1, 602, 5, {ACT_CMD+AT_HLC} }, 285{RSP_OK, 601, 601, -1, 603, 5, {ACT_CMD+AT_PROTO} },
286{RSP_NULL, 602, 602, -1, 603, 5, {ACT_CMD+AT_PROTO} },
287{RSP_OK, 602, 602, -1, 603, 5, {ACT_CMD+AT_PROTO} },
288{RSP_OK, 603, 603, -1, 604, 5, {ACT_CMD+AT_TYPE} }, 286{RSP_OK, 603, 603, -1, 604, 5, {ACT_CMD+AT_TYPE} },
289{RSP_OK, 604, 604, -1, 605, 5, {ACT_CMD+AT_MSN} }, 287{RSP_OK, 604, 604, -1, 605, 5, {ACT_CMD+AT_MSN} },
290{RSP_NULL, 605, 605, -1, 606, 5, {ACT_CMD+AT_CLIP} }, 288{RSP_NULL, 605, 605, -1, 606, 5, {ACT_CMD+AT_CLIP} },
diff --git a/drivers/isdn/gigaset/gigaset.h b/drivers/isdn/gigaset/gigaset.h
index 05947f9c1849..8738b0821fc9 100644
--- a/drivers/isdn/gigaset/gigaset.h
+++ b/drivers/isdn/gigaset/gigaset.h
@@ -45,10 +45,6 @@
45#define MAX_EVENTS 64 /* size of event queue */ 45#define MAX_EVENTS 64 /* size of event queue */
46 46
47#define RBUFSIZE 8192 47#define RBUFSIZE 8192
48#define SBUFSIZE 4096 /* sk_buff payload size */
49
50#define TRANSBUFSIZE 768 /* bytes per skb for transparent receive */
51#define MAX_BUF_SIZE (SBUFSIZE - 2) /* Max. size of a data packet from LL */
52 48
53/* compile time options */ 49/* compile time options */
54#define GIG_MAJOR 0 50#define GIG_MAJOR 0
@@ -190,10 +186,9 @@ void gigaset_dbg_buffer(enum debuglevel level, const unsigned char *msg,
190#define AT_BC 3 186#define AT_BC 3
191#define AT_PROTO 4 187#define AT_PROTO 4
192#define AT_TYPE 5 188#define AT_TYPE 5
193#define AT_HLC 6 189#define AT_CLIP 6
194#define AT_CLIP 7
195/* total number */ 190/* total number */
196#define AT_NUM 8 191#define AT_NUM 7
197 192
198/* variables in struct at_state_t */ 193/* variables in struct at_state_t */
199#define VAR_ZSAU 0 194#define VAR_ZSAU 0
@@ -380,8 +375,10 @@ struct bc_state {
380 375
381 struct at_state_t at_state; 376 struct at_state_t at_state;
382 377
383 __u16 fcs; 378 /* receive buffer */
384 struct sk_buff *skb; 379 unsigned rx_bufsize; /* max size accepted by application */
380 struct sk_buff *rx_skb;
381 __u16 rx_fcs;
385 int inputstate; /* see INS_XXXX */ 382 int inputstate; /* see INS_XXXX */
386 383
387 int channel; 384 int channel;
@@ -406,7 +403,9 @@ struct bc_state {
406 struct bas_bc_state *bas; /* usb hardware driver (base) */ 403 struct bas_bc_state *bas; /* usb hardware driver (base) */
407 } hw; 404 } hw;
408 405
409 void *ap; /* LL application structure */ 406 void *ap; /* associated LL application */
407 int apconnstate; /* LL application connection state */
408 spinlock_t aplock;
410}; 409};
411 410
412struct cardstate { 411struct cardstate {
@@ -801,8 +800,23 @@ static inline void gigaset_bchannel_up(struct bc_state *bcs)
801 gigaset_schedule_event(bcs->cs); 800 gigaset_schedule_event(bcs->cs);
802} 801}
803 802
804/* handling routines for sk_buff */ 803/* set up next receive skb for data mode */
805/* ============================= */ 804static inline struct sk_buff *gigaset_new_rx_skb(struct bc_state *bcs)
805{
806 struct cardstate *cs = bcs->cs;
807 unsigned short hw_hdr_len = cs->hw_hdr_len;
808
809 if (bcs->ignore) {
810 bcs->rx_skb = NULL;
811 } else {
812 bcs->rx_skb = dev_alloc_skb(bcs->rx_bufsize + hw_hdr_len);
813 if (bcs->rx_skb == NULL)
814 dev_warn(cs->dev, "could not allocate skb\n");
815 else
816 skb_reserve(bcs->rx_skb, hw_hdr_len);
817 }
818 return bcs->rx_skb;
819}
806 820
807/* append received bytes to inbuf */ 821/* append received bytes to inbuf */
808int gigaset_fill_inbuf(struct inbuf_t *inbuf, const unsigned char *src, 822int gigaset_fill_inbuf(struct inbuf_t *inbuf, const unsigned char *src,
diff --git a/drivers/isdn/gigaset/i4l.c b/drivers/isdn/gigaset/i4l.c
index c22e5ace8276..f01c3c2e2e46 100644
--- a/drivers/isdn/gigaset/i4l.c
+++ b/drivers/isdn/gigaset/i4l.c
@@ -16,7 +16,10 @@
16#include "gigaset.h" 16#include "gigaset.h"
17#include <linux/isdnif.h> 17#include <linux/isdnif.h>
18 18
19#define SBUFSIZE 4096 /* sk_buff payload size */
20#define TRANSBUFSIZE 768 /* bytes per skb for transparent receive */
19#define HW_HDR_LEN 2 /* Header size used to store ack info */ 21#define HW_HDR_LEN 2 /* Header size used to store ack info */
22#define MAX_BUF_SIZE (SBUFSIZE - HW_HDR_LEN) /* max data packet from LL */
20 23
21/* == Handling of I4L IO =====================================================*/ 24/* == Handling of I4L IO =====================================================*/
22 25
@@ -231,6 +234,15 @@ static int command_from_LL(isdn_ctrl *cntrl)
231 dev_err(cs->dev, "ISDN_CMD_DIAL: channel not free\n"); 234 dev_err(cs->dev, "ISDN_CMD_DIAL: channel not free\n");
232 return -EBUSY; 235 return -EBUSY;
233 } 236 }
237 switch (bcs->proto2) {
238 case L2_HDLC:
239 bcs->rx_bufsize = SBUFSIZE;
240 break;
241 default: /* assume transparent */
242 bcs->rx_bufsize = TRANSBUFSIZE;
243 }
244 dev_kfree_skb(bcs->rx_skb);
245 gigaset_new_rx_skb(bcs);
234 246
235 commands = kzalloc(AT_NUM*(sizeof *commands), GFP_ATOMIC); 247 commands = kzalloc(AT_NUM*(sizeof *commands), GFP_ATOMIC);
236 if (!commands) { 248 if (!commands) {
@@ -314,6 +326,15 @@ static int command_from_LL(isdn_ctrl *cntrl)
314 return -EINVAL; 326 return -EINVAL;
315 } 327 }
316 bcs = cs->bcs + ch; 328 bcs = cs->bcs + ch;
329 switch (bcs->proto2) {
330 case L2_HDLC:
331 bcs->rx_bufsize = SBUFSIZE;
332 break;
333 default: /* assume transparent */
334 bcs->rx_bufsize = TRANSBUFSIZE;
335 }
336 dev_kfree_skb(bcs->rx_skb);
337 gigaset_new_rx_skb(bcs);
317 if (!gigaset_add_event(cs, &bcs->at_state, 338 if (!gigaset_add_event(cs, &bcs->at_state,
318 EV_ACCEPT, NULL, 0, NULL)) 339 EV_ACCEPT, NULL, 0, NULL))
319 return -ENOMEM; 340 return -ENOMEM;
diff --git a/drivers/isdn/gigaset/isocdata.c b/drivers/isdn/gigaset/isocdata.c
index 16fd3bd48883..2dfd346fc889 100644
--- a/drivers/isdn/gigaset/isocdata.c
+++ b/drivers/isdn/gigaset/isocdata.c
@@ -500,19 +500,18 @@ int gigaset_isoc_buildframe(struct bc_state *bcs, unsigned char *in, int len)
500 */ 500 */
501static inline void hdlc_putbyte(unsigned char c, struct bc_state *bcs) 501static inline void hdlc_putbyte(unsigned char c, struct bc_state *bcs)
502{ 502{
503 bcs->fcs = crc_ccitt_byte(bcs->fcs, c); 503 bcs->rx_fcs = crc_ccitt_byte(bcs->rx_fcs, c);
504 if (unlikely(bcs->skb == NULL)) { 504 if (bcs->rx_skb == NULL)
505 /* skipping */ 505 /* skipping */
506 return; 506 return;
507 } 507 if (bcs->rx_skb->len >= bcs->rx_bufsize) {
508 if (unlikely(bcs->skb->len == SBUFSIZE)) {
509 dev_warn(bcs->cs->dev, "received oversized packet discarded\n"); 508 dev_warn(bcs->cs->dev, "received oversized packet discarded\n");
510 bcs->hw.bas->giants++; 509 bcs->hw.bas->giants++;
511 dev_kfree_skb_any(bcs->skb); 510 dev_kfree_skb_any(bcs->rx_skb);
512 bcs->skb = NULL; 511 bcs->rx_skb = NULL;
513 return; 512 return;
514 } 513 }
515 *__skb_put(bcs->skb, 1) = c; 514 *__skb_put(bcs->rx_skb, 1) = c;
516} 515}
517 516
518/* hdlc_flush 517/* hdlc_flush
@@ -521,18 +520,13 @@ static inline void hdlc_putbyte(unsigned char c, struct bc_state *bcs)
521static inline void hdlc_flush(struct bc_state *bcs) 520static inline void hdlc_flush(struct bc_state *bcs)
522{ 521{
523 /* clear skb or allocate new if not skipping */ 522 /* clear skb or allocate new if not skipping */
524 if (likely(bcs->skb != NULL)) 523 if (bcs->rx_skb != NULL)
525 skb_trim(bcs->skb, 0); 524 skb_trim(bcs->rx_skb, 0);
526 else if (!bcs->ignore) { 525 else
527 bcs->skb = dev_alloc_skb(SBUFSIZE + bcs->cs->hw_hdr_len); 526 gigaset_new_rx_skb(bcs);
528 if (bcs->skb)
529 skb_reserve(bcs->skb, bcs->cs->hw_hdr_len);
530 else
531 dev_err(bcs->cs->dev, "could not allocate skb\n");
532 }
533 527
534 /* reset packet state */ 528 /* reset packet state */
535 bcs->fcs = PPP_INITFCS; 529 bcs->rx_fcs = PPP_INITFCS;
536} 530}
537 531
538/* hdlc_done 532/* hdlc_done
@@ -549,7 +543,7 @@ static inline void hdlc_done(struct bc_state *bcs)
549 hdlc_flush(bcs); 543 hdlc_flush(bcs);
550 return; 544 return;
551 } 545 }
552 procskb = bcs->skb; 546 procskb = bcs->rx_skb;
553 if (procskb == NULL) { 547 if (procskb == NULL) {
554 /* previous error */ 548 /* previous error */
555 gig_dbg(DEBUG_ISO, "%s: skb=NULL", __func__); 549 gig_dbg(DEBUG_ISO, "%s: skb=NULL", __func__);
@@ -560,8 +554,8 @@ static inline void hdlc_done(struct bc_state *bcs)
560 bcs->hw.bas->runts++; 554 bcs->hw.bas->runts++;
561 dev_kfree_skb_any(procskb); 555 dev_kfree_skb_any(procskb);
562 gigaset_isdn_rcv_err(bcs); 556 gigaset_isdn_rcv_err(bcs);
563 } else if (bcs->fcs != PPP_GOODFCS) { 557 } else if (bcs->rx_fcs != PPP_GOODFCS) {
564 dev_notice(cs->dev, "frame check error (0x%04x)\n", bcs->fcs); 558 dev_notice(cs->dev, "frame check error\n");
565 bcs->hw.bas->fcserrs++; 559 bcs->hw.bas->fcserrs++;
566 dev_kfree_skb_any(procskb); 560 dev_kfree_skb_any(procskb);
567 gigaset_isdn_rcv_err(bcs); 561 gigaset_isdn_rcv_err(bcs);
@@ -574,13 +568,8 @@ static inline void hdlc_done(struct bc_state *bcs)
574 bcs->hw.bas->goodbytes += len; 568 bcs->hw.bas->goodbytes += len;
575 gigaset_skb_rcvd(bcs, procskb); 569 gigaset_skb_rcvd(bcs, procskb);
576 } 570 }
577 571 gigaset_new_rx_skb(bcs);
578 bcs->skb = dev_alloc_skb(SBUFSIZE + cs->hw_hdr_len); 572 bcs->rx_fcs = PPP_INITFCS;
579 if (bcs->skb)
580 skb_reserve(bcs->skb, cs->hw_hdr_len);
581 else
582 dev_err(cs->dev, "could not allocate skb\n");
583 bcs->fcs = PPP_INITFCS;
584} 573}
585 574
586/* hdlc_frag 575/* hdlc_frag
@@ -597,8 +586,8 @@ static inline void hdlc_frag(struct bc_state *bcs, unsigned inbits)
597 dev_notice(bcs->cs->dev, "received partial byte (%d bits)\n", inbits); 586 dev_notice(bcs->cs->dev, "received partial byte (%d bits)\n", inbits);
598 bcs->hw.bas->alignerrs++; 587 bcs->hw.bas->alignerrs++;
599 gigaset_isdn_rcv_err(bcs); 588 gigaset_isdn_rcv_err(bcs);
600 __skb_trim(bcs->skb, 0); 589 __skb_trim(bcs->rx_skb, 0);
601 bcs->fcs = PPP_INITFCS; 590 bcs->rx_fcs = PPP_INITFCS;
602} 591}
603 592
604/* bit counts lookup table for HDLC bit unstuffing 593/* bit counts lookup table for HDLC bit unstuffing
@@ -847,7 +836,6 @@ static inline void hdlc_unpack(unsigned char *src, unsigned count,
847static inline void trans_receive(unsigned char *src, unsigned count, 836static inline void trans_receive(unsigned char *src, unsigned count,
848 struct bc_state *bcs) 837 struct bc_state *bcs)
849{ 838{
850 struct cardstate *cs = bcs->cs;
851 struct sk_buff *skb; 839 struct sk_buff *skb;
852 int dobytes; 840 int dobytes;
853 unsigned char *dst; 841 unsigned char *dst;
@@ -857,17 +845,11 @@ static inline void trans_receive(unsigned char *src, unsigned count,
857 hdlc_flush(bcs); 845 hdlc_flush(bcs);
858 return; 846 return;
859 } 847 }
860 skb = bcs->skb; 848 skb = bcs->rx_skb;
861 if (unlikely(skb == NULL)) { 849 if (skb == NULL)
862 bcs->skb = skb = dev_alloc_skb(SBUFSIZE + cs->hw_hdr_len); 850 skb = gigaset_new_rx_skb(bcs);
863 if (!skb) {
864 dev_err(cs->dev, "could not allocate skb\n");
865 return;
866 }
867 skb_reserve(skb, cs->hw_hdr_len);
868 }
869 bcs->hw.bas->goodbytes += skb->len; 851 bcs->hw.bas->goodbytes += skb->len;
870 dobytes = TRANSBUFSIZE - skb->len; 852 dobytes = bcs->rx_bufsize - skb->len;
871 while (count > 0) { 853 while (count > 0) {
872 dst = skb_put(skb, count < dobytes ? count : dobytes); 854 dst = skb_put(skb, count < dobytes ? count : dobytes);
873 while (count > 0 && dobytes > 0) { 855 while (count > 0 && dobytes > 0) {
@@ -879,14 +861,10 @@ static inline void trans_receive(unsigned char *src, unsigned count,
879 dump_bytes(DEBUG_STREAM_DUMP, 861 dump_bytes(DEBUG_STREAM_DUMP,
880 "rcv data", skb->data, skb->len); 862 "rcv data", skb->data, skb->len);
881 gigaset_skb_rcvd(bcs, skb); 863 gigaset_skb_rcvd(bcs, skb);
882 bcs->skb = skb = 864 skb = gigaset_new_rx_skb(bcs);
883 dev_alloc_skb(SBUFSIZE + cs->hw_hdr_len); 865 if (skb == NULL)
884 if (!skb) {
885 dev_err(cs->dev, "could not allocate skb\n");
886 return; 866 return;
887 } 867 dobytes = bcs->rx_bufsize;
888 skb_reserve(skb, cs->hw_hdr_len);
889 dobytes = TRANSBUFSIZE;
890 } 868 }
891 } 869 }
892} 870}
diff --git a/drivers/isdn/hysdn/hysdn_net.c b/drivers/isdn/hysdn/hysdn_net.c
index 72eb92647c1b..feec8d89d719 100644
--- a/drivers/isdn/hysdn/hysdn_net.c
+++ b/drivers/isdn/hysdn/hysdn_net.c
@@ -187,12 +187,13 @@ void
187hysdn_rx_netpkt(hysdn_card * card, unsigned char *buf, unsigned short len) 187hysdn_rx_netpkt(hysdn_card * card, unsigned char *buf, unsigned short len)
188{ 188{
189 struct net_local *lp = card->netif; 189 struct net_local *lp = card->netif;
190 struct net_device *dev = lp->dev; 190 struct net_device *dev;
191 struct sk_buff *skb; 191 struct sk_buff *skb;
192 192
193 if (!lp) 193 if (!lp)
194 return; /* non existing device */ 194 return; /* non existing device */
195 195
196 dev = lp->dev;
196 dev->stats.rx_bytes += len; 197 dev->stats.rx_bytes += len;
197 198
198 skb = dev_alloc_skb(len); 199 skb = dev_alloc_skb(len);
diff --git a/drivers/leds/Kconfig b/drivers/leds/Kconfig
index 81bf25e67ce1..e4112622e5a2 100644
--- a/drivers/leds/Kconfig
+++ b/drivers/leds/Kconfig
@@ -302,6 +302,15 @@ config LEDS_MC13783
302 This option enable support for on-chip LED drivers found 302 This option enable support for on-chip LED drivers found
303 on Freescale Semiconductor MC13783 PMIC. 303 on Freescale Semiconductor MC13783 PMIC.
304 304
305config LEDS_NS2
306 tristate "LED support for Network Space v2 GPIO LEDs"
307 depends on MACH_NETSPACE_V2 || MACH_INETSPACE_V2 || MACH_NETSPACE_MAX_V2
308 default y
309 help
310 This option enable support for the dual-GPIO LED found on the
311 Network Space v2 board (and parents). This include Internet Space v2,
312 Network Space (Max) v2 and d2 Network v2 boards.
313
305config LEDS_TRIGGERS 314config LEDS_TRIGGERS
306 bool "LED Trigger support" 315 bool "LED Trigger support"
307 help 316 help
diff --git a/drivers/leds/Makefile b/drivers/leds/Makefile
index 2493de499374..7d6b95831f8e 100644
--- a/drivers/leds/Makefile
+++ b/drivers/leds/Makefile
@@ -37,6 +37,7 @@ obj-$(CONFIG_LEDS_LT3593) += leds-lt3593.o
37obj-$(CONFIG_LEDS_ADP5520) += leds-adp5520.o 37obj-$(CONFIG_LEDS_ADP5520) += leds-adp5520.o
38obj-$(CONFIG_LEDS_DELL_NETBOOKS) += dell-led.o 38obj-$(CONFIG_LEDS_DELL_NETBOOKS) += dell-led.o
39obj-$(CONFIG_LEDS_MC13783) += leds-mc13783.o 39obj-$(CONFIG_LEDS_MC13783) += leds-mc13783.o
40obj-$(CONFIG_LEDS_NS2) += leds-ns2.o
40 41
41# LED SPI Drivers 42# LED SPI Drivers
42obj-$(CONFIG_LEDS_DAC124S085) += leds-dac124s085.o 43obj-$(CONFIG_LEDS_DAC124S085) += leds-dac124s085.o
diff --git a/drivers/leds/leds-ns2.c b/drivers/leds/leds-ns2.c
new file mode 100644
index 000000000000..74dce4ba0262
--- /dev/null
+++ b/drivers/leds/leds-ns2.c
@@ -0,0 +1,338 @@
1/*
2 * leds-ns2.c - Driver for the Network Space v2 (and parents) dual-GPIO LED
3 *
4 * Copyright (C) 2010 LaCie
5 *
6 * Author: Simon Guinot <sguinot@lacie.com>
7 *
8 * Based on leds-gpio.c by Raphael Assenat <raph@8d.com>
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 */
24
25#include <linux/kernel.h>
26#include <linux/init.h>
27#include <linux/platform_device.h>
28#include <linux/slab.h>
29#include <linux/gpio.h>
30#include <linux/leds.h>
31#include <mach/leds-ns2.h>
32
33/*
34 * The Network Space v2 dual-GPIO LED is wired to a CPLD and can blink in
35 * relation with the SATA activity. This capability is exposed through the
36 * "sata" sysfs attribute.
37 *
38 * The following array detail the different LED registers and the combination
39 * of their possible values:
40 *
41 * cmd_led | slow_led | /SATA active | LED state
42 * | | |
43 * 1 | 0 | x | off
44 * - | 1 | x | on
45 * 0 | 0 | 1 | on
46 * 0 | 0 | 0 | blink (rate 300ms)
47 */
48
49enum ns2_led_modes {
50 NS_V2_LED_OFF,
51 NS_V2_LED_ON,
52 NS_V2_LED_SATA,
53};
54
55struct ns2_led_mode_value {
56 enum ns2_led_modes mode;
57 int cmd_level;
58 int slow_level;
59};
60
61static struct ns2_led_mode_value ns2_led_modval[] = {
62 { NS_V2_LED_OFF , 1, 0 },
63 { NS_V2_LED_ON , 0, 1 },
64 { NS_V2_LED_ON , 1, 1 },
65 { NS_V2_LED_SATA, 0, 0 },
66};
67
68struct ns2_led_data {
69 struct led_classdev cdev;
70 unsigned cmd;
71 unsigned slow;
72 unsigned char sata; /* True when SATA mode active. */
73 rwlock_t rw_lock; /* Lock GPIOs. */
74};
75
76static int ns2_led_get_mode(struct ns2_led_data *led_dat,
77 enum ns2_led_modes *mode)
78{
79 int i;
80 int ret = -EINVAL;
81 int cmd_level;
82 int slow_level;
83
84 read_lock(&led_dat->rw_lock);
85
86 cmd_level = gpio_get_value(led_dat->cmd);
87 slow_level = gpio_get_value(led_dat->slow);
88
89 for (i = 0; i < ARRAY_SIZE(ns2_led_modval); i++) {
90 if (cmd_level == ns2_led_modval[i].cmd_level &&
91 slow_level == ns2_led_modval[i].slow_level) {
92 *mode = ns2_led_modval[i].mode;
93 ret = 0;
94 break;
95 }
96 }
97
98 read_unlock(&led_dat->rw_lock);
99
100 return ret;
101}
102
103static void ns2_led_set_mode(struct ns2_led_data *led_dat,
104 enum ns2_led_modes mode)
105{
106 int i;
107
108 write_lock(&led_dat->rw_lock);
109
110 for (i = 0; i < ARRAY_SIZE(ns2_led_modval); i++) {
111 if (mode == ns2_led_modval[i].mode) {
112 gpio_set_value(led_dat->cmd,
113 ns2_led_modval[i].cmd_level);
114 gpio_set_value(led_dat->slow,
115 ns2_led_modval[i].slow_level);
116 }
117 }
118
119 write_unlock(&led_dat->rw_lock);
120}
121
122static void ns2_led_set(struct led_classdev *led_cdev,
123 enum led_brightness value)
124{
125 struct ns2_led_data *led_dat =
126 container_of(led_cdev, struct ns2_led_data, cdev);
127 enum ns2_led_modes mode;
128
129 if (value == LED_OFF)
130 mode = NS_V2_LED_OFF;
131 else if (led_dat->sata)
132 mode = NS_V2_LED_SATA;
133 else
134 mode = NS_V2_LED_ON;
135
136 ns2_led_set_mode(led_dat, mode);
137}
138
139static ssize_t ns2_led_sata_store(struct device *dev,
140 struct device_attribute *attr,
141 const char *buff, size_t count)
142{
143 int ret;
144 unsigned long enable;
145 enum ns2_led_modes mode;
146 struct ns2_led_data *led_dat = dev_get_drvdata(dev);
147
148 ret = strict_strtoul(buff, 10, &enable);
149 if (ret < 0)
150 return ret;
151
152 enable = !!enable;
153
154 if (led_dat->sata == enable)
155 return count;
156
157 ret = ns2_led_get_mode(led_dat, &mode);
158 if (ret < 0)
159 return ret;
160
161 if (enable && mode == NS_V2_LED_ON)
162 ns2_led_set_mode(led_dat, NS_V2_LED_SATA);
163 if (!enable && mode == NS_V2_LED_SATA)
164 ns2_led_set_mode(led_dat, NS_V2_LED_ON);
165
166 led_dat->sata = enable;
167
168 return count;
169}
170
171static ssize_t ns2_led_sata_show(struct device *dev,
172 struct device_attribute *attr, char *buf)
173{
174 struct ns2_led_data *led_dat = dev_get_drvdata(dev);
175
176 return sprintf(buf, "%d\n", led_dat->sata);
177}
178
179static DEVICE_ATTR(sata, 0644, ns2_led_sata_show, ns2_led_sata_store);
180
181static int __devinit
182create_ns2_led(struct platform_device *pdev, struct ns2_led_data *led_dat,
183 const struct ns2_led *template)
184{
185 int ret;
186 enum ns2_led_modes mode;
187
188 ret = gpio_request(template->cmd, template->name);
189 if (ret == 0) {
190 ret = gpio_direction_output(template->cmd,
191 gpio_get_value(template->cmd));
192 if (ret)
193 gpio_free(template->cmd);
194 }
195 if (ret) {
196 dev_err(&pdev->dev, "%s: failed to setup command GPIO\n",
197 template->name);
198 }
199
200 ret = gpio_request(template->slow, template->name);
201 if (ret == 0) {
202 ret = gpio_direction_output(template->slow,
203 gpio_get_value(template->slow));
204 if (ret)
205 gpio_free(template->slow);
206 }
207 if (ret) {
208 dev_err(&pdev->dev, "%s: failed to setup slow GPIO\n",
209 template->name);
210 goto err_free_cmd;
211 }
212
213 rwlock_init(&led_dat->rw_lock);
214
215 led_dat->cdev.name = template->name;
216 led_dat->cdev.default_trigger = template->default_trigger;
217 led_dat->cdev.blink_set = NULL;
218 led_dat->cdev.brightness_set = ns2_led_set;
219 led_dat->cdev.flags |= LED_CORE_SUSPENDRESUME;
220 led_dat->cmd = template->cmd;
221 led_dat->slow = template->slow;
222
223 ret = ns2_led_get_mode(led_dat, &mode);
224 if (ret < 0)
225 goto err_free_slow;
226
227 /* Set LED initial state. */
228 led_dat->sata = (mode == NS_V2_LED_SATA) ? 1 : 0;
229 led_dat->cdev.brightness =
230 (mode == NS_V2_LED_OFF) ? LED_OFF : LED_FULL;
231
232 ret = led_classdev_register(&pdev->dev, &led_dat->cdev);
233 if (ret < 0)
234 goto err_free_slow;
235
236 dev_set_drvdata(led_dat->cdev.dev, led_dat);
237 ret = device_create_file(led_dat->cdev.dev, &dev_attr_sata);
238 if (ret < 0)
239 goto err_free_cdev;
240
241 return 0;
242
243err_free_cdev:
244 led_classdev_unregister(&led_dat->cdev);
245err_free_slow:
246 gpio_free(led_dat->slow);
247err_free_cmd:
248 gpio_free(led_dat->cmd);
249
250 return ret;
251}
252
253static void __devexit delete_ns2_led(struct ns2_led_data *led_dat)
254{
255 device_remove_file(led_dat->cdev.dev, &dev_attr_sata);
256 led_classdev_unregister(&led_dat->cdev);
257 gpio_free(led_dat->cmd);
258 gpio_free(led_dat->slow);
259}
260
261static int __devinit ns2_led_probe(struct platform_device *pdev)
262{
263 struct ns2_led_platform_data *pdata = pdev->dev.platform_data;
264 struct ns2_led_data *leds_data;
265 int i;
266 int ret;
267
268 if (!pdata)
269 return -EINVAL;
270
271 leds_data = kzalloc(sizeof(struct ns2_led_data) *
272 pdata->num_leds, GFP_KERNEL);
273 if (!leds_data)
274 return -ENOMEM;
275
276 for (i = 0; i < pdata->num_leds; i++) {
277 ret = create_ns2_led(pdev, &leds_data[i], &pdata->leds[i]);
278 if (ret < 0)
279 goto err;
280
281 }
282
283 platform_set_drvdata(pdev, leds_data);
284
285 return 0;
286
287err:
288 for (i = i - 1; i >= 0; i--)
289 delete_ns2_led(&leds_data[i]);
290
291 kfree(leds_data);
292
293 return ret;
294}
295
296static int __devexit ns2_led_remove(struct platform_device *pdev)
297{
298 int i;
299 struct ns2_led_platform_data *pdata = pdev->dev.platform_data;
300 struct ns2_led_data *leds_data;
301
302 leds_data = platform_get_drvdata(pdev);
303
304 for (i = 0; i < pdata->num_leds; i++)
305 delete_ns2_led(&leds_data[i]);
306
307 kfree(leds_data);
308 platform_set_drvdata(pdev, NULL);
309
310 return 0;
311}
312
313static struct platform_driver ns2_led_driver = {
314 .probe = ns2_led_probe,
315 .remove = __devexit_p(ns2_led_remove),
316 .driver = {
317 .name = "leds-ns2",
318 .owner = THIS_MODULE,
319 },
320};
321MODULE_ALIAS("platform:leds-ns2");
322
323static int __init ns2_led_init(void)
324{
325 return platform_driver_register(&ns2_led_driver);
326}
327
328static void __exit ns2_led_exit(void)
329{
330 platform_driver_unregister(&ns2_led_driver);
331}
332
333module_init(ns2_led_init);
334module_exit(ns2_led_exit);
335
336MODULE_AUTHOR("Simon Guinot <sguinot@lacie.com>");
337MODULE_DESCRIPTION("Network Space v2 LED driver");
338MODULE_LICENSE("GPL");
diff --git a/drivers/md/md.c b/drivers/md/md.c
index 46b3a044eadf..cb20d0b0555a 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -2087,6 +2087,7 @@ static void sync_sbs(mddev_t * mddev, int nospares)
2087 /* First make sure individual recovery_offsets are correct */ 2087 /* First make sure individual recovery_offsets are correct */
2088 list_for_each_entry(rdev, &mddev->disks, same_set) { 2088 list_for_each_entry(rdev, &mddev->disks, same_set) {
2089 if (rdev->raid_disk >= 0 && 2089 if (rdev->raid_disk >= 0 &&
2090 mddev->delta_disks >= 0 &&
2090 !test_bit(In_sync, &rdev->flags) && 2091 !test_bit(In_sync, &rdev->flags) &&
2091 mddev->curr_resync_completed > rdev->recovery_offset) 2092 mddev->curr_resync_completed > rdev->recovery_offset)
2092 rdev->recovery_offset = mddev->curr_resync_completed; 2093 rdev->recovery_offset = mddev->curr_resync_completed;
@@ -3001,6 +3002,9 @@ level_store(mddev_t *mddev, const char *buf, size_t len)
3001 return -EINVAL; 3002 return -EINVAL;
3002 } 3003 }
3003 3004
3005 list_for_each_entry(rdev, &mddev->disks, same_set)
3006 rdev->new_raid_disk = rdev->raid_disk;
3007
3004 /* ->takeover must set new_* and/or delta_disks 3008 /* ->takeover must set new_* and/or delta_disks
3005 * if it succeeds, and may set them when it fails. 3009 * if it succeeds, and may set them when it fails.
3006 */ 3010 */
@@ -3051,13 +3055,35 @@ level_store(mddev_t *mddev, const char *buf, size_t len)
3051 mddev->safemode = 0; 3055 mddev->safemode = 0;
3052 } 3056 }
3053 3057
3054 module_put(mddev->pers->owner); 3058 list_for_each_entry(rdev, &mddev->disks, same_set) {
3055 /* Invalidate devices that are now superfluous */ 3059 char nm[20];
3056 list_for_each_entry(rdev, &mddev->disks, same_set) 3060 if (rdev->raid_disk < 0)
3057 if (rdev->raid_disk >= mddev->raid_disks) { 3061 continue;
3058 rdev->raid_disk = -1; 3062 if (rdev->new_raid_disk > mddev->raid_disks)
3063 rdev->new_raid_disk = -1;
3064 if (rdev->new_raid_disk == rdev->raid_disk)
3065 continue;
3066 sprintf(nm, "rd%d", rdev->raid_disk);
3067 sysfs_remove_link(&mddev->kobj, nm);
3068 }
3069 list_for_each_entry(rdev, &mddev->disks, same_set) {
3070 if (rdev->raid_disk < 0)
3071 continue;
3072 if (rdev->new_raid_disk == rdev->raid_disk)
3073 continue;
3074 rdev->raid_disk = rdev->new_raid_disk;
3075 if (rdev->raid_disk < 0)
3059 clear_bit(In_sync, &rdev->flags); 3076 clear_bit(In_sync, &rdev->flags);
3077 else {
3078 char nm[20];
3079 sprintf(nm, "rd%d", rdev->raid_disk);
3080 if(sysfs_create_link(&mddev->kobj, &rdev->kobj, nm))
3081 printk("md: cannot register %s for %s after level change\n",
3082 nm, mdname(mddev));
3060 } 3083 }
3084 }
3085
3086 module_put(mddev->pers->owner);
3061 mddev->pers = pers; 3087 mddev->pers = pers;
3062 mddev->private = priv; 3088 mddev->private = priv;
3063 strlcpy(mddev->clevel, pers->name, sizeof(mddev->clevel)); 3089 strlcpy(mddev->clevel, pers->name, sizeof(mddev->clevel));
@@ -5895,6 +5921,7 @@ static int md_open(struct block_device *bdev, fmode_t mode)
5895 atomic_inc(&mddev->openers); 5921 atomic_inc(&mddev->openers);
5896 mutex_unlock(&mddev->open_mutex); 5922 mutex_unlock(&mddev->open_mutex);
5897 5923
5924 check_disk_size_change(mddev->gendisk, bdev);
5898 out: 5925 out:
5899 return err; 5926 return err;
5900} 5927}
@@ -6846,6 +6873,7 @@ void md_do_sync(mddev_t *mddev)
6846 rcu_read_lock(); 6873 rcu_read_lock();
6847 list_for_each_entry_rcu(rdev, &mddev->disks, same_set) 6874 list_for_each_entry_rcu(rdev, &mddev->disks, same_set)
6848 if (rdev->raid_disk >= 0 && 6875 if (rdev->raid_disk >= 0 &&
6876 mddev->delta_disks >= 0 &&
6849 !test_bit(Faulty, &rdev->flags) && 6877 !test_bit(Faulty, &rdev->flags) &&
6850 !test_bit(In_sync, &rdev->flags) && 6878 !test_bit(In_sync, &rdev->flags) &&
6851 rdev->recovery_offset < mddev->curr_resync) 6879 rdev->recovery_offset < mddev->curr_resync)
diff --git a/drivers/md/md.h b/drivers/md/md.h
index 7ab5ea155452..10597bfec000 100644
--- a/drivers/md/md.h
+++ b/drivers/md/md.h
@@ -78,6 +78,9 @@ struct mdk_rdev_s
78 78
79 int desc_nr; /* descriptor index in the superblock */ 79 int desc_nr; /* descriptor index in the superblock */
80 int raid_disk; /* role of device in array */ 80 int raid_disk; /* role of device in array */
81 int new_raid_disk; /* role that the device will have in
82 * the array after a level-change completes.
83 */
81 int saved_raid_disk; /* role that device used to have in the 84 int saved_raid_disk; /* role that device used to have in the
82 * array and could again if we did a partial 85 * array and could again if we did a partial
83 * resync from the bitmap 86 * resync from the bitmap
diff --git a/drivers/md/raid0.c b/drivers/md/raid0.c
index e70f004c99e8..563abed5a2cb 100644
--- a/drivers/md/raid0.c
+++ b/drivers/md/raid0.c
@@ -173,9 +173,11 @@ static int create_strip_zones(mddev_t *mddev, raid0_conf_t **private_conf)
173 list_for_each_entry(rdev1, &mddev->disks, same_set) { 173 list_for_each_entry(rdev1, &mddev->disks, same_set) {
174 int j = rdev1->raid_disk; 174 int j = rdev1->raid_disk;
175 175
176 if (mddev->level == 10) 176 if (mddev->level == 10) {
177 /* taking over a raid10-n2 array */ 177 /* taking over a raid10-n2 array */
178 j /= 2; 178 j /= 2;
179 rdev1->new_raid_disk = j;
180 }
179 181
180 if (j < 0 || j >= mddev->raid_disks) { 182 if (j < 0 || j >= mddev->raid_disks) {
181 printk(KERN_ERR "md/raid0:%s: bad disk number %d - " 183 printk(KERN_ERR "md/raid0:%s: bad disk number %d - "
@@ -361,12 +363,6 @@ static int raid0_run(mddev_t *mddev)
361 mddev->private = conf; 363 mddev->private = conf;
362 } 364 }
363 conf = mddev->private; 365 conf = mddev->private;
364 if (conf->scale_raid_disks) {
365 int i;
366 for (i=0; i < conf->strip_zone[0].nb_dev; i++)
367 conf->devlist[i]->raid_disk /= conf->scale_raid_disks;
368 /* FIXME update sysfs rd links */
369 }
370 366
371 /* calculate array device size */ 367 /* calculate array device size */
372 md_set_array_sectors(mddev, raid0_size(mddev, 0, 0)); 368 md_set_array_sectors(mddev, raid0_size(mddev, 0, 0));
@@ -573,7 +569,7 @@ static void raid0_status(struct seq_file *seq, mddev_t *mddev)
573 return; 569 return;
574} 570}
575 571
576static void *raid0_takeover_raid5(mddev_t *mddev) 572static void *raid0_takeover_raid45(mddev_t *mddev)
577{ 573{
578 mdk_rdev_t *rdev; 574 mdk_rdev_t *rdev;
579 raid0_conf_t *priv_conf; 575 raid0_conf_t *priv_conf;
@@ -596,6 +592,7 @@ static void *raid0_takeover_raid5(mddev_t *mddev)
596 592
597 /* Set new parameters */ 593 /* Set new parameters */
598 mddev->new_level = 0; 594 mddev->new_level = 0;
595 mddev->new_layout = 0;
599 mddev->new_chunk_sectors = mddev->chunk_sectors; 596 mddev->new_chunk_sectors = mddev->chunk_sectors;
600 mddev->raid_disks--; 597 mddev->raid_disks--;
601 mddev->delta_disks = -1; 598 mddev->delta_disks = -1;
@@ -635,6 +632,7 @@ static void *raid0_takeover_raid10(mddev_t *mddev)
635 632
636 /* Set new parameters */ 633 /* Set new parameters */
637 mddev->new_level = 0; 634 mddev->new_level = 0;
635 mddev->new_layout = 0;
638 mddev->new_chunk_sectors = mddev->chunk_sectors; 636 mddev->new_chunk_sectors = mddev->chunk_sectors;
639 mddev->delta_disks = - mddev->raid_disks / 2; 637 mddev->delta_disks = - mddev->raid_disks / 2;
640 mddev->raid_disks += mddev->delta_disks; 638 mddev->raid_disks += mddev->delta_disks;
@@ -643,19 +641,22 @@ static void *raid0_takeover_raid10(mddev_t *mddev)
643 mddev->recovery_cp = MaxSector; 641 mddev->recovery_cp = MaxSector;
644 642
645 create_strip_zones(mddev, &priv_conf); 643 create_strip_zones(mddev, &priv_conf);
646 priv_conf->scale_raid_disks = 2;
647 return priv_conf; 644 return priv_conf;
648} 645}
649 646
650static void *raid0_takeover(mddev_t *mddev) 647static void *raid0_takeover(mddev_t *mddev)
651{ 648{
652 /* raid0 can take over: 649 /* raid0 can take over:
650 * raid4 - if all data disks are active.
653 * raid5 - providing it is Raid4 layout and one disk is faulty 651 * raid5 - providing it is Raid4 layout and one disk is faulty
654 * raid10 - assuming we have all necessary active disks 652 * raid10 - assuming we have all necessary active disks
655 */ 653 */
654 if (mddev->level == 4)
655 return raid0_takeover_raid45(mddev);
656
656 if (mddev->level == 5) { 657 if (mddev->level == 5) {
657 if (mddev->layout == ALGORITHM_PARITY_N) 658 if (mddev->layout == ALGORITHM_PARITY_N)
658 return raid0_takeover_raid5(mddev); 659 return raid0_takeover_raid45(mddev);
659 660
660 printk(KERN_ERR "md/raid0:%s: Raid can only takeover Raid5 with layout: %d\n", 661 printk(KERN_ERR "md/raid0:%s: Raid can only takeover Raid5 with layout: %d\n",
661 mdname(mddev), ALGORITHM_PARITY_N); 662 mdname(mddev), ALGORITHM_PARITY_N);
diff --git a/drivers/md/raid0.h b/drivers/md/raid0.h
index d724e664ca4d..91f8e876ee64 100644
--- a/drivers/md/raid0.h
+++ b/drivers/md/raid0.h
@@ -13,9 +13,6 @@ struct raid0_private_data
13 struct strip_zone *strip_zone; 13 struct strip_zone *strip_zone;
14 mdk_rdev_t **devlist; /* lists of rdevs, pointed to by strip_zone->dev */ 14 mdk_rdev_t **devlist; /* lists of rdevs, pointed to by strip_zone->dev */
15 int nr_strip_zones; 15 int nr_strip_zones;
16 int scale_raid_disks; /* divide rdev->raid_disks by this in run()
17 * to handle conversion from raid10
18 */
19}; 16};
20 17
21typedef struct raid0_private_data raid0_conf_t; 18typedef struct raid0_private_data raid0_conf_t;
diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
index 03724992cdf2..42e64e4e5e25 100644
--- a/drivers/md/raid10.c
+++ b/drivers/md/raid10.c
@@ -1482,14 +1482,14 @@ static void fix_read_error(conf_t *conf, mddev_t *mddev, r10bio_t *r10_bio)
1482 int sectors = r10_bio->sectors; 1482 int sectors = r10_bio->sectors;
1483 mdk_rdev_t*rdev; 1483 mdk_rdev_t*rdev;
1484 int max_read_errors = atomic_read(&mddev->max_corr_read_errors); 1484 int max_read_errors = atomic_read(&mddev->max_corr_read_errors);
1485 int d = r10_bio->devs[r10_bio->read_slot].devnum;
1485 1486
1486 rcu_read_lock(); 1487 rcu_read_lock();
1487 { 1488 rdev = rcu_dereference(conf->mirrors[d].rdev);
1488 int d = r10_bio->devs[r10_bio->read_slot].devnum; 1489 if (rdev) { /* If rdev is not NULL */
1489 char b[BDEVNAME_SIZE]; 1490 char b[BDEVNAME_SIZE];
1490 int cur_read_error_count = 0; 1491 int cur_read_error_count = 0;
1491 1492
1492 rdev = rcu_dereference(conf->mirrors[d].rdev);
1493 bdevname(rdev->bdev, b); 1493 bdevname(rdev->bdev, b);
1494 1494
1495 if (test_bit(Faulty, &rdev->flags)) { 1495 if (test_bit(Faulty, &rdev->flags)) {
@@ -1530,7 +1530,7 @@ static void fix_read_error(conf_t *conf, mddev_t *mddev, r10bio_t *r10_bio)
1530 1530
1531 rcu_read_lock(); 1531 rcu_read_lock();
1532 do { 1532 do {
1533 int d = r10_bio->devs[sl].devnum; 1533 d = r10_bio->devs[sl].devnum;
1534 rdev = rcu_dereference(conf->mirrors[d].rdev); 1534 rdev = rcu_dereference(conf->mirrors[d].rdev);
1535 if (rdev && 1535 if (rdev &&
1536 test_bit(In_sync, &rdev->flags)) { 1536 test_bit(In_sync, &rdev->flags)) {
@@ -1564,7 +1564,7 @@ static void fix_read_error(conf_t *conf, mddev_t *mddev, r10bio_t *r10_bio)
1564 rcu_read_lock(); 1564 rcu_read_lock();
1565 while (sl != r10_bio->read_slot) { 1565 while (sl != r10_bio->read_slot) {
1566 char b[BDEVNAME_SIZE]; 1566 char b[BDEVNAME_SIZE];
1567 int d; 1567
1568 if (sl==0) 1568 if (sl==0)
1569 sl = conf->copies; 1569 sl = conf->copies;
1570 sl--; 1570 sl--;
@@ -1601,7 +1601,7 @@ static void fix_read_error(conf_t *conf, mddev_t *mddev, r10bio_t *r10_bio)
1601 } 1601 }
1602 sl = start; 1602 sl = start;
1603 while (sl != r10_bio->read_slot) { 1603 while (sl != r10_bio->read_slot) {
1604 int d; 1604
1605 if (sl==0) 1605 if (sl==0)
1606 sl = conf->copies; 1606 sl = conf->copies;
1607 sl--; 1607 sl--;
@@ -2161,22 +2161,22 @@ static conf_t *setup_conf(mddev_t *mddev)
2161 sector_t stride, size; 2161 sector_t stride, size;
2162 int err = -EINVAL; 2162 int err = -EINVAL;
2163 2163
2164 if (mddev->chunk_sectors < (PAGE_SIZE >> 9) || 2164 if (mddev->new_chunk_sectors < (PAGE_SIZE >> 9) ||
2165 !is_power_of_2(mddev->chunk_sectors)) { 2165 !is_power_of_2(mddev->new_chunk_sectors)) {
2166 printk(KERN_ERR "md/raid10:%s: chunk size must be " 2166 printk(KERN_ERR "md/raid10:%s: chunk size must be "
2167 "at least PAGE_SIZE(%ld) and be a power of 2.\n", 2167 "at least PAGE_SIZE(%ld) and be a power of 2.\n",
2168 mdname(mddev), PAGE_SIZE); 2168 mdname(mddev), PAGE_SIZE);
2169 goto out; 2169 goto out;
2170 } 2170 }
2171 2171
2172 nc = mddev->layout & 255; 2172 nc = mddev->new_layout & 255;
2173 fc = (mddev->layout >> 8) & 255; 2173 fc = (mddev->new_layout >> 8) & 255;
2174 fo = mddev->layout & (1<<16); 2174 fo = mddev->new_layout & (1<<16);
2175 2175
2176 if ((nc*fc) <2 || (nc*fc) > mddev->raid_disks || 2176 if ((nc*fc) <2 || (nc*fc) > mddev->raid_disks ||
2177 (mddev->layout >> 17)) { 2177 (mddev->new_layout >> 17)) {
2178 printk(KERN_ERR "md/raid10:%s: unsupported raid10 layout: 0x%8x\n", 2178 printk(KERN_ERR "md/raid10:%s: unsupported raid10 layout: 0x%8x\n",
2179 mdname(mddev), mddev->layout); 2179 mdname(mddev), mddev->new_layout);
2180 goto out; 2180 goto out;
2181 } 2181 }
2182 2182
@@ -2241,7 +2241,6 @@ static conf_t *setup_conf(mddev_t *mddev)
2241 if (!conf->thread) 2241 if (!conf->thread)
2242 goto out; 2242 goto out;
2243 2243
2244 conf->scale_disks = 0;
2245 conf->mddev = mddev; 2244 conf->mddev = mddev;
2246 return conf; 2245 return conf;
2247 2246
@@ -2300,11 +2299,6 @@ static int run(mddev_t *mddev)
2300 if (disk_idx >= conf->raid_disks 2299 if (disk_idx >= conf->raid_disks
2301 || disk_idx < 0) 2300 || disk_idx < 0)
2302 continue; 2301 continue;
2303 if (conf->scale_disks) {
2304 disk_idx *= conf->scale_disks;
2305 rdev->raid_disk = disk_idx;
2306 /* MOVE 'rd%d' link !! */
2307 }
2308 disk = conf->mirrors + disk_idx; 2302 disk = conf->mirrors + disk_idx;
2309 2303
2310 disk->rdev = rdev; 2304 disk->rdev = rdev;
@@ -2435,26 +2429,22 @@ static void *raid10_takeover_raid0(mddev_t *mddev)
2435 return ERR_PTR(-EINVAL); 2429 return ERR_PTR(-EINVAL);
2436 } 2430 }
2437 2431
2438 /* Update slot numbers to obtain
2439 * degraded raid10 with missing mirrors
2440 */
2441 list_for_each_entry(rdev, &mddev->disks, same_set) {
2442 rdev->raid_disk *= 2;
2443 }
2444
2445 /* Set new parameters */ 2432 /* Set new parameters */
2446 mddev->new_level = 10; 2433 mddev->new_level = 10;
2447 /* new layout: far_copies = 1, near_copies = 2 */ 2434 /* new layout: far_copies = 1, near_copies = 2 */
2448 mddev->new_layout = (1<<8) + 2; 2435 mddev->new_layout = (1<<8) + 2;
2449 mddev->new_chunk_sectors = mddev->chunk_sectors; 2436 mddev->new_chunk_sectors = mddev->chunk_sectors;
2450 mddev->delta_disks = mddev->raid_disks; 2437 mddev->delta_disks = mddev->raid_disks;
2451 mddev->degraded = mddev->raid_disks;
2452 mddev->raid_disks *= 2; 2438 mddev->raid_disks *= 2;
2453 /* make sure it will be not marked as dirty */ 2439 /* make sure it will be not marked as dirty */
2454 mddev->recovery_cp = MaxSector; 2440 mddev->recovery_cp = MaxSector;
2455 2441
2456 conf = setup_conf(mddev); 2442 conf = setup_conf(mddev);
2457 conf->scale_disks = 2; 2443 if (!IS_ERR(conf))
2444 list_for_each_entry(rdev, &mddev->disks, same_set)
2445 if (rdev->raid_disk >= 0)
2446 rdev->new_raid_disk = rdev->raid_disk * 2;
2447
2458 return conf; 2448 return conf;
2459} 2449}
2460 2450
diff --git a/drivers/md/raid10.h b/drivers/md/raid10.h
index 3824a087e17c..2316ac2e8e21 100644
--- a/drivers/md/raid10.h
+++ b/drivers/md/raid10.h
@@ -38,11 +38,6 @@ struct r10_private_data_s {
38 int chunk_shift; /* shift from chunks to sectors */ 38 int chunk_shift; /* shift from chunks to sectors */
39 sector_t chunk_mask; 39 sector_t chunk_mask;
40 40
41 int scale_disks; /* When starting array, multiply
42 * each ->raid_disk by this.
43 * Need for raid0->raid10 migration
44 */
45
46 struct list_head retry_list; 41 struct list_head retry_list;
47 /* queue pending writes and submit them on unplug */ 42 /* queue pending writes and submit them on unplug */
48 struct bio_list pending_bio_list; 43 struct bio_list pending_bio_list;
diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
index d2c0f94fa37d..96c690279fc6 100644
--- a/drivers/md/raid5.c
+++ b/drivers/md/raid5.c
@@ -277,12 +277,13 @@ out:
277 return sh; 277 return sh;
278} 278}
279 279
280static void shrink_buffers(struct stripe_head *sh, int num) 280static void shrink_buffers(struct stripe_head *sh)
281{ 281{
282 struct page *p; 282 struct page *p;
283 int i; 283 int i;
284 int num = sh->raid_conf->pool_size;
284 285
285 for (i=0; i<num ; i++) { 286 for (i = 0; i < num ; i++) {
286 p = sh->dev[i].page; 287 p = sh->dev[i].page;
287 if (!p) 288 if (!p)
288 continue; 289 continue;
@@ -291,11 +292,12 @@ static void shrink_buffers(struct stripe_head *sh, int num)
291 } 292 }
292} 293}
293 294
294static int grow_buffers(struct stripe_head *sh, int num) 295static int grow_buffers(struct stripe_head *sh)
295{ 296{
296 int i; 297 int i;
298 int num = sh->raid_conf->pool_size;
297 299
298 for (i=0; i<num; i++) { 300 for (i = 0; i < num; i++) {
299 struct page *page; 301 struct page *page;
300 302
301 if (!(page = alloc_page(GFP_KERNEL))) { 303 if (!(page = alloc_page(GFP_KERNEL))) {
@@ -364,6 +366,73 @@ static struct stripe_head *__find_stripe(raid5_conf_t *conf, sector_t sector,
364 return NULL; 366 return NULL;
365} 367}
366 368
369/*
370 * Need to check if array has failed when deciding whether to:
371 * - start an array
372 * - remove non-faulty devices
373 * - add a spare
374 * - allow a reshape
375 * This determination is simple when no reshape is happening.
376 * However if there is a reshape, we need to carefully check
377 * both the before and after sections.
378 * This is because some failed devices may only affect one
379 * of the two sections, and some non-in_sync devices may
380 * be insync in the section most affected by failed devices.
381 */
382static int has_failed(raid5_conf_t *conf)
383{
384 int degraded;
385 int i;
386 if (conf->mddev->reshape_position == MaxSector)
387 return conf->mddev->degraded > conf->max_degraded;
388
389 rcu_read_lock();
390 degraded = 0;
391 for (i = 0; i < conf->previous_raid_disks; i++) {
392 mdk_rdev_t *rdev = rcu_dereference(conf->disks[i].rdev);
393 if (!rdev || test_bit(Faulty, &rdev->flags))
394 degraded++;
395 else if (test_bit(In_sync, &rdev->flags))
396 ;
397 else
398 /* not in-sync or faulty.
399 * If the reshape increases the number of devices,
400 * this is being recovered by the reshape, so
401 * this 'previous' section is not in_sync.
402 * If the number of devices is being reduced however,
403 * the device can only be part of the array if
404 * we are reverting a reshape, so this section will
405 * be in-sync.
406 */
407 if (conf->raid_disks >= conf->previous_raid_disks)
408 degraded++;
409 }
410 rcu_read_unlock();
411 if (degraded > conf->max_degraded)
412 return 1;
413 rcu_read_lock();
414 degraded = 0;
415 for (i = 0; i < conf->raid_disks; i++) {
416 mdk_rdev_t *rdev = rcu_dereference(conf->disks[i].rdev);
417 if (!rdev || test_bit(Faulty, &rdev->flags))
418 degraded++;
419 else if (test_bit(In_sync, &rdev->flags))
420 ;
421 else
422 /* not in-sync or faulty.
423 * If reshape increases the number of devices, this
424 * section has already been recovered, else it
425 * almost certainly hasn't.
426 */
427 if (conf->raid_disks <= conf->previous_raid_disks)
428 degraded++;
429 }
430 rcu_read_unlock();
431 if (degraded > conf->max_degraded)
432 return 1;
433 return 0;
434}
435
367static void unplug_slaves(mddev_t *mddev); 436static void unplug_slaves(mddev_t *mddev);
368static void raid5_unplug_device(struct request_queue *q); 437static void raid5_unplug_device(struct request_queue *q);
369 438
@@ -1240,19 +1309,18 @@ static void raid_run_ops(struct stripe_head *sh, unsigned long ops_request)
1240static int grow_one_stripe(raid5_conf_t *conf) 1309static int grow_one_stripe(raid5_conf_t *conf)
1241{ 1310{
1242 struct stripe_head *sh; 1311 struct stripe_head *sh;
1243 int disks = max(conf->raid_disks, conf->previous_raid_disks);
1244 sh = kmem_cache_alloc(conf->slab_cache, GFP_KERNEL); 1312 sh = kmem_cache_alloc(conf->slab_cache, GFP_KERNEL);
1245 if (!sh) 1313 if (!sh)
1246 return 0; 1314 return 0;
1247 memset(sh, 0, sizeof(*sh) + (disks-1)*sizeof(struct r5dev)); 1315 memset(sh, 0, sizeof(*sh) + (conf->pool_size-1)*sizeof(struct r5dev));
1248 sh->raid_conf = conf; 1316 sh->raid_conf = conf;
1249 spin_lock_init(&sh->lock); 1317 spin_lock_init(&sh->lock);
1250 #ifdef CONFIG_MULTICORE_RAID456 1318 #ifdef CONFIG_MULTICORE_RAID456
1251 init_waitqueue_head(&sh->ops.wait_for_ops); 1319 init_waitqueue_head(&sh->ops.wait_for_ops);
1252 #endif 1320 #endif
1253 1321
1254 if (grow_buffers(sh, disks)) { 1322 if (grow_buffers(sh)) {
1255 shrink_buffers(sh, disks); 1323 shrink_buffers(sh);
1256 kmem_cache_free(conf->slab_cache, sh); 1324 kmem_cache_free(conf->slab_cache, sh);
1257 return 0; 1325 return 0;
1258 } 1326 }
@@ -1468,7 +1536,7 @@ static int drop_one_stripe(raid5_conf_t *conf)
1468 if (!sh) 1536 if (!sh)
1469 return 0; 1537 return 0;
1470 BUG_ON(atomic_read(&sh->count)); 1538 BUG_ON(atomic_read(&sh->count));
1471 shrink_buffers(sh, conf->pool_size); 1539 shrink_buffers(sh);
1472 kmem_cache_free(conf->slab_cache, sh); 1540 kmem_cache_free(conf->slab_cache, sh);
1473 atomic_dec(&conf->active_stripes); 1541 atomic_dec(&conf->active_stripes);
1474 return 1; 1542 return 1;
@@ -2963,7 +3031,6 @@ static void handle_stripe5(struct stripe_head *sh)
2963 mdk_rdev_t *rdev; 3031 mdk_rdev_t *rdev;
2964 3032
2965 dev = &sh->dev[i]; 3033 dev = &sh->dev[i];
2966 clear_bit(R5_Insync, &dev->flags);
2967 3034
2968 pr_debug("check %d: state 0x%lx toread %p read %p write %p " 3035 pr_debug("check %d: state 0x%lx toread %p read %p write %p "
2969 "written %p\n", i, dev->flags, dev->toread, dev->read, 3036 "written %p\n", i, dev->flags, dev->toread, dev->read,
@@ -3000,17 +3067,27 @@ static void handle_stripe5(struct stripe_head *sh)
3000 blocked_rdev = rdev; 3067 blocked_rdev = rdev;
3001 atomic_inc(&rdev->nr_pending); 3068 atomic_inc(&rdev->nr_pending);
3002 } 3069 }
3003 if (!rdev || !test_bit(In_sync, &rdev->flags)) { 3070 clear_bit(R5_Insync, &dev->flags);
3071 if (!rdev)
3072 /* Not in-sync */;
3073 else if (test_bit(In_sync, &rdev->flags))
3074 set_bit(R5_Insync, &dev->flags);
3075 else {
3076 /* could be in-sync depending on recovery/reshape status */
3077 if (sh->sector + STRIPE_SECTORS <= rdev->recovery_offset)
3078 set_bit(R5_Insync, &dev->flags);
3079 }
3080 if (!test_bit(R5_Insync, &dev->flags)) {
3004 /* The ReadError flag will just be confusing now */ 3081 /* The ReadError flag will just be confusing now */
3005 clear_bit(R5_ReadError, &dev->flags); 3082 clear_bit(R5_ReadError, &dev->flags);
3006 clear_bit(R5_ReWrite, &dev->flags); 3083 clear_bit(R5_ReWrite, &dev->flags);
3007 } 3084 }
3008 if (!rdev || !test_bit(In_sync, &rdev->flags) 3085 if (test_bit(R5_ReadError, &dev->flags))
3009 || test_bit(R5_ReadError, &dev->flags)) { 3086 clear_bit(R5_Insync, &dev->flags);
3087 if (!test_bit(R5_Insync, &dev->flags)) {
3010 s.failed++; 3088 s.failed++;
3011 s.failed_num = i; 3089 s.failed_num = i;
3012 } else 3090 }
3013 set_bit(R5_Insync, &dev->flags);
3014 } 3091 }
3015 rcu_read_unlock(); 3092 rcu_read_unlock();
3016 3093
@@ -3244,7 +3321,6 @@ static void handle_stripe6(struct stripe_head *sh)
3244 for (i=disks; i--; ) { 3321 for (i=disks; i--; ) {
3245 mdk_rdev_t *rdev; 3322 mdk_rdev_t *rdev;
3246 dev = &sh->dev[i]; 3323 dev = &sh->dev[i];
3247 clear_bit(R5_Insync, &dev->flags);
3248 3324
3249 pr_debug("check %d: state 0x%lx read %p write %p written %p\n", 3325 pr_debug("check %d: state 0x%lx read %p write %p written %p\n",
3250 i, dev->flags, dev->toread, dev->towrite, dev->written); 3326 i, dev->flags, dev->toread, dev->towrite, dev->written);
@@ -3282,18 +3358,28 @@ static void handle_stripe6(struct stripe_head *sh)
3282 blocked_rdev = rdev; 3358 blocked_rdev = rdev;
3283 atomic_inc(&rdev->nr_pending); 3359 atomic_inc(&rdev->nr_pending);
3284 } 3360 }
3285 if (!rdev || !test_bit(In_sync, &rdev->flags)) { 3361 clear_bit(R5_Insync, &dev->flags);
3362 if (!rdev)
3363 /* Not in-sync */;
3364 else if (test_bit(In_sync, &rdev->flags))
3365 set_bit(R5_Insync, &dev->flags);
3366 else {
3367 /* in sync if before recovery_offset */
3368 if (sh->sector + STRIPE_SECTORS <= rdev->recovery_offset)
3369 set_bit(R5_Insync, &dev->flags);
3370 }
3371 if (!test_bit(R5_Insync, &dev->flags)) {
3286 /* The ReadError flag will just be confusing now */ 3372 /* The ReadError flag will just be confusing now */
3287 clear_bit(R5_ReadError, &dev->flags); 3373 clear_bit(R5_ReadError, &dev->flags);
3288 clear_bit(R5_ReWrite, &dev->flags); 3374 clear_bit(R5_ReWrite, &dev->flags);
3289 } 3375 }
3290 if (!rdev || !test_bit(In_sync, &rdev->flags) 3376 if (test_bit(R5_ReadError, &dev->flags))
3291 || test_bit(R5_ReadError, &dev->flags)) { 3377 clear_bit(R5_Insync, &dev->flags);
3378 if (!test_bit(R5_Insync, &dev->flags)) {
3292 if (s.failed < 2) 3379 if (s.failed < 2)
3293 r6s.failed_num[s.failed] = i; 3380 r6s.failed_num[s.failed] = i;
3294 s.failed++; 3381 s.failed++;
3295 } else 3382 }
3296 set_bit(R5_Insync, &dev->flags);
3297 } 3383 }
3298 rcu_read_unlock(); 3384 rcu_read_unlock();
3299 3385
@@ -4971,8 +5057,10 @@ static int run(mddev_t *mddev)
4971 list_for_each_entry(rdev, &mddev->disks, same_set) { 5057 list_for_each_entry(rdev, &mddev->disks, same_set) {
4972 if (rdev->raid_disk < 0) 5058 if (rdev->raid_disk < 0)
4973 continue; 5059 continue;
4974 if (test_bit(In_sync, &rdev->flags)) 5060 if (test_bit(In_sync, &rdev->flags)) {
4975 working_disks++; 5061 working_disks++;
5062 continue;
5063 }
4976 /* This disc is not fully in-sync. However if it 5064 /* This disc is not fully in-sync. However if it
4977 * just stored parity (beyond the recovery_offset), 5065 * just stored parity (beyond the recovery_offset),
4978 * when we don't need to be concerned about the 5066 * when we don't need to be concerned about the
@@ -5005,7 +5093,7 @@ static int run(mddev_t *mddev)
5005 mddev->degraded = (max(conf->raid_disks, conf->previous_raid_disks) 5093 mddev->degraded = (max(conf->raid_disks, conf->previous_raid_disks)
5006 - working_disks); 5094 - working_disks);
5007 5095
5008 if (mddev->degraded > conf->max_degraded) { 5096 if (has_failed(conf)) {
5009 printk(KERN_ERR "md/raid:%s: not enough operational devices" 5097 printk(KERN_ERR "md/raid:%s: not enough operational devices"
5010 " (%d/%d failed)\n", 5098 " (%d/%d failed)\n",
5011 mdname(mddev), mddev->degraded, conf->raid_disks); 5099 mdname(mddev), mddev->degraded, conf->raid_disks);
@@ -5207,6 +5295,7 @@ static int raid5_spare_active(mddev_t *mddev)
5207 for (i = 0; i < conf->raid_disks; i++) { 5295 for (i = 0; i < conf->raid_disks; i++) {
5208 tmp = conf->disks + i; 5296 tmp = conf->disks + i;
5209 if (tmp->rdev 5297 if (tmp->rdev
5298 && tmp->rdev->recovery_offset == MaxSector
5210 && !test_bit(Faulty, &tmp->rdev->flags) 5299 && !test_bit(Faulty, &tmp->rdev->flags)
5211 && !test_and_set_bit(In_sync, &tmp->rdev->flags)) { 5300 && !test_and_set_bit(In_sync, &tmp->rdev->flags)) {
5212 unsigned long flags; 5301 unsigned long flags;
@@ -5242,7 +5331,7 @@ static int raid5_remove_disk(mddev_t *mddev, int number)
5242 * isn't possible. 5331 * isn't possible.
5243 */ 5332 */
5244 if (!test_bit(Faulty, &rdev->flags) && 5333 if (!test_bit(Faulty, &rdev->flags) &&
5245 mddev->degraded <= conf->max_degraded && 5334 !has_failed(conf) &&
5246 number < conf->raid_disks) { 5335 number < conf->raid_disks) {
5247 err = -EBUSY; 5336 err = -EBUSY;
5248 goto abort; 5337 goto abort;
@@ -5270,7 +5359,7 @@ static int raid5_add_disk(mddev_t *mddev, mdk_rdev_t *rdev)
5270 int first = 0; 5359 int first = 0;
5271 int last = conf->raid_disks - 1; 5360 int last = conf->raid_disks - 1;
5272 5361
5273 if (mddev->degraded > conf->max_degraded) 5362 if (has_failed(conf))
5274 /* no point adding a device */ 5363 /* no point adding a device */
5275 return -EINVAL; 5364 return -EINVAL;
5276 5365
@@ -5362,7 +5451,7 @@ static int check_reshape(mddev_t *mddev)
5362 if (mddev->bitmap) 5451 if (mddev->bitmap)
5363 /* Cannot grow a bitmap yet */ 5452 /* Cannot grow a bitmap yet */
5364 return -EBUSY; 5453 return -EBUSY;
5365 if (mddev->degraded > conf->max_degraded) 5454 if (has_failed(conf))
5366 return -EINVAL; 5455 return -EINVAL;
5367 if (mddev->delta_disks < 0) { 5456 if (mddev->delta_disks < 0) {
5368 /* We might be able to shrink, but the devices must 5457 /* We might be able to shrink, but the devices must
@@ -5437,8 +5526,13 @@ static int raid5_start_reshape(mddev_t *mddev)
5437 5526
5438 /* Add some new drives, as many as will fit. 5527 /* Add some new drives, as many as will fit.
5439 * We know there are enough to make the newly sized array work. 5528 * We know there are enough to make the newly sized array work.
5529 * Don't add devices if we are reducing the number of
5530 * devices in the array. This is because it is not possible
5531 * to correctly record the "partially reconstructed" state of
5532 * such devices during the reshape and confusion could result.
5440 */ 5533 */
5441 list_for_each_entry(rdev, &mddev->disks, same_set) 5534 if (mddev->delta_disks >= 0)
5535 list_for_each_entry(rdev, &mddev->disks, same_set)
5442 if (rdev->raid_disk < 0 && 5536 if (rdev->raid_disk < 0 &&
5443 !test_bit(Faulty, &rdev->flags)) { 5537 !test_bit(Faulty, &rdev->flags)) {
5444 if (raid5_add_disk(mddev, rdev) == 0) { 5538 if (raid5_add_disk(mddev, rdev) == 0) {
@@ -5460,7 +5554,7 @@ static int raid5_start_reshape(mddev_t *mddev)
5460 } 5554 }
5461 5555
5462 /* When a reshape changes the number of devices, ->degraded 5556 /* When a reshape changes the number of devices, ->degraded
5463 * is measured against the large of the pre and post number of 5557 * is measured against the larger of the pre and post number of
5464 * devices.*/ 5558 * devices.*/
5465 if (mddev->delta_disks > 0) { 5559 if (mddev->delta_disks > 0) {
5466 spin_lock_irqsave(&conf->device_lock, flags); 5560 spin_lock_irqsave(&conf->device_lock, flags);
diff --git a/drivers/media/common/tuners/tuner-simple.c b/drivers/media/common/tuners/tuner-simple.c
index 8abbcc5fcf95..8cf2ab609d5e 100644
--- a/drivers/media/common/tuners/tuner-simple.c
+++ b/drivers/media/common/tuners/tuner-simple.c
@@ -524,6 +524,7 @@ static int simple_radio_bandswitch(struct dvb_frontend *fe, u8 *buffer)
524 buffer[3] = 0x39; 524 buffer[3] = 0x39;
525 break; 525 break;
526 case TUNER_PHILIPS_FQ1216LME_MK3: 526 case TUNER_PHILIPS_FQ1216LME_MK3:
527 case TUNER_PHILIPS_FQ1236_MK5:
527 tuner_err("This tuner doesn't have FM\n"); 528 tuner_err("This tuner doesn't have FM\n");
528 /* Set the low band for sanity, since it covers 88-108 MHz */ 529 /* Set the low band for sanity, since it covers 88-108 MHz */
529 buffer[3] = 0x01; 530 buffer[3] = 0x01;
diff --git a/drivers/media/common/tuners/tuner-types.c b/drivers/media/common/tuners/tuner-types.c
index d9aaaca620c9..58a513bcd747 100644
--- a/drivers/media/common/tuners/tuner-types.c
+++ b/drivers/media/common/tuners/tuner-types.c
@@ -1353,6 +1353,17 @@ static struct tuner_params tuner_sony_btf_pxn01z_params[] = {
1353 }, 1353 },
1354}; 1354};
1355 1355
1356/* ------------ TUNER_PHILIPS_FQ1236_MK5 - Philips NTSC ------------ */
1357
1358static struct tuner_params tuner_philips_fq1236_mk5_params[] = {
1359 {
1360 .type = TUNER_PARAM_TYPE_NTSC,
1361 .ranges = tuner_fm1236_mk3_ntsc_ranges,
1362 .count = ARRAY_SIZE(tuner_fm1236_mk3_ntsc_ranges),
1363 .has_tda9887 = 1, /* TDA9885, no FM radio */
1364 },
1365};
1366
1356/* --------------------------------------------------------------------- */ 1367/* --------------------------------------------------------------------- */
1357 1368
1358struct tunertype tuners[] = { 1369struct tunertype tuners[] = {
@@ -1826,6 +1837,11 @@ struct tunertype tuners[] = {
1826 .params = tuner_sony_btf_pxn01z_params, 1837 .params = tuner_sony_btf_pxn01z_params,
1827 .count = ARRAY_SIZE(tuner_sony_btf_pxn01z_params), 1838 .count = ARRAY_SIZE(tuner_sony_btf_pxn01z_params),
1828 }, 1839 },
1840 [TUNER_PHILIPS_FQ1236_MK5] = { /* NTSC, TDA9885, no FM radio */
1841 .name = "Philips FQ1236 MK5",
1842 .params = tuner_philips_fq1236_mk5_params,
1843 .count = ARRAY_SIZE(tuner_philips_fq1236_mk5_params),
1844 },
1829}; 1845};
1830EXPORT_SYMBOL(tuners); 1846EXPORT_SYMBOL(tuners);
1831 1847
diff --git a/drivers/media/video/Kconfig b/drivers/media/video/Kconfig
index bdbc9d305419..27e2acce3c3a 100644
--- a/drivers/media/video/Kconfig
+++ b/drivers/media/video/Kconfig
@@ -969,6 +969,19 @@ config VIDEO_OMAP2
969 ---help--- 969 ---help---
970 This is a v4l2 driver for the TI OMAP2 camera capture interface 970 This is a v4l2 driver for the TI OMAP2 camera capture interface
971 971
972config VIDEO_MX2_HOSTSUPPORT
973 bool
974
975config VIDEO_MX2
976 tristate "i.MX27/i.MX25 Camera Sensor Interface driver"
977 depends on VIDEO_DEV && SOC_CAMERA && (MACH_MX27 || ARCH_MX25)
978 select VIDEOBUF_DMA_CONTIG
979 select VIDEO_MX2_HOSTSUPPORT
980 ---help---
981 This is a v4l2 driver for the i.MX27 and the i.MX25 Camera Sensor
982 Interface
983
984
972# 985#
973# USB Multimedia device configuration 986# USB Multimedia device configuration
974# 987#
diff --git a/drivers/media/video/Makefile b/drivers/media/video/Makefile
index cc93859d3164..b08bd2b65cd0 100644
--- a/drivers/media/video/Makefile
+++ b/drivers/media/video/Makefile
@@ -162,6 +162,7 @@ obj-$(CONFIG_SOC_CAMERA) += soc_camera.o soc_mediabus.o
162obj-$(CONFIG_SOC_CAMERA_PLATFORM) += soc_camera_platform.o 162obj-$(CONFIG_SOC_CAMERA_PLATFORM) += soc_camera_platform.o
163# soc-camera host drivers have to be linked after camera drivers 163# soc-camera host drivers have to be linked after camera drivers
164obj-$(CONFIG_VIDEO_MX1) += mx1_camera.o 164obj-$(CONFIG_VIDEO_MX1) += mx1_camera.o
165obj-$(CONFIG_VIDEO_MX2) += mx2_camera.o
165obj-$(CONFIG_VIDEO_MX3) += mx3_camera.o 166obj-$(CONFIG_VIDEO_MX3) += mx3_camera.o
166obj-$(CONFIG_VIDEO_PXA27x) += pxa_camera.o 167obj-$(CONFIG_VIDEO_PXA27x) += pxa_camera.o
167obj-$(CONFIG_VIDEO_SH_MOBILE_CEU) += sh_mobile_ceu_camera.o 168obj-$(CONFIG_VIDEO_SH_MOBILE_CEU) += sh_mobile_ceu_camera.o
diff --git a/drivers/media/video/ivtv/ivtv-streams.c b/drivers/media/video/ivtv/ivtv-streams.c
index 9ecacab4b89b..a937e2ff9b6e 100644
--- a/drivers/media/video/ivtv/ivtv-streams.c
+++ b/drivers/media/video/ivtv/ivtv-streams.c
@@ -912,6 +912,9 @@ int ivtv_stop_v4l2_decode_stream(struct ivtv_stream *s, int flags, u64 pts)
912 clear_bit(IVTV_F_S_STREAMING, &s->s_flags); 912 clear_bit(IVTV_F_S_STREAMING, &s->s_flags);
913 ivtv_flush_queues(s); 913 ivtv_flush_queues(s);
914 914
915 /* decoder needs time to settle */
916 ivtv_msleep_timeout(40, 0);
917
915 /* decrement decoding */ 918 /* decrement decoding */
916 atomic_dec(&itv->decoding); 919 atomic_dec(&itv->decoding);
917 920
diff --git a/drivers/media/video/mem2mem_testdev.c b/drivers/media/video/mem2mem_testdev.c
index 554eaf140128..10ddeccc70eb 100644
--- a/drivers/media/video/mem2mem_testdev.c
+++ b/drivers/media/video/mem2mem_testdev.c
@@ -988,6 +988,9 @@ static int m2mtest_probe(struct platform_device *pdev)
988 goto err_m2m; 988 goto err_m2m;
989 } 989 }
990 990
991 q_data[V4L2_M2M_SRC].fmt = &formats[0];
992 q_data[V4L2_M2M_DST].fmt = &formats[0];
993
991 return 0; 994 return 0;
992 995
993err_m2m: 996err_m2m:
diff --git a/drivers/media/video/mx2_camera.c b/drivers/media/video/mx2_camera.c
new file mode 100644
index 000000000000..026bef0ba403
--- /dev/null
+++ b/drivers/media/video/mx2_camera.c
@@ -0,0 +1,1513 @@
1/*
2 * V4L2 Driver for i.MX27/i.MX25 camera host
3 *
4 * Copyright (C) 2008, Sascha Hauer, Pengutronix
5 * Copyright (C) 2010, Baruch Siach, Orex Computed Radiography
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
13#include <linux/init.h>
14#include <linux/module.h>
15#include <linux/io.h>
16#include <linux/delay.h>
17#include <linux/slab.h>
18#include <linux/dma-mapping.h>
19#include <linux/errno.h>
20#include <linux/fs.h>
21#include <linux/interrupt.h>
22#include <linux/kernel.h>
23#include <linux/mm.h>
24#include <linux/moduleparam.h>
25#include <linux/time.h>
26#include <linux/version.h>
27#include <linux/device.h>
28#include <linux/platform_device.h>
29#include <linux/mutex.h>
30#include <linux/clk.h>
31
32#include <media/v4l2-common.h>
33#include <media/v4l2-dev.h>
34#include <media/videobuf-dma-contig.h>
35#include <media/soc_camera.h>
36#include <media/soc_mediabus.h>
37
38#include <linux/videodev2.h>
39
40#include <mach/mx2_cam.h>
41#ifdef CONFIG_MACH_MX27
42#include <mach/dma-mx1-mx2.h>
43#endif
44#include <mach/hardware.h>
45
46#include <asm/dma.h>
47
48#define MX2_CAM_DRV_NAME "mx2-camera"
49#define MX2_CAM_VERSION_CODE KERNEL_VERSION(0, 0, 5)
50#define MX2_CAM_DRIVER_DESCRIPTION "i.MX2x_Camera"
51
52/* reset values */
53#define CSICR1_RESET_VAL 0x40000800
54#define CSICR2_RESET_VAL 0x0
55#define CSICR3_RESET_VAL 0x0
56
57/* csi control reg 1 */
58#define CSICR1_SWAP16_EN (1 << 31)
59#define CSICR1_EXT_VSYNC (1 << 30)
60#define CSICR1_EOF_INTEN (1 << 29)
61#define CSICR1_PRP_IF_EN (1 << 28)
62#define CSICR1_CCIR_MODE (1 << 27)
63#define CSICR1_COF_INTEN (1 << 26)
64#define CSICR1_SF_OR_INTEN (1 << 25)
65#define CSICR1_RF_OR_INTEN (1 << 24)
66#define CSICR1_STATFF_LEVEL (3 << 22)
67#define CSICR1_STATFF_INTEN (1 << 21)
68#define CSICR1_RXFF_LEVEL(l) (((l) & 3) << 19) /* MX27 */
69#define CSICR1_FB2_DMA_INTEN (1 << 20) /* MX25 */
70#define CSICR1_FB1_DMA_INTEN (1 << 19) /* MX25 */
71#define CSICR1_RXFF_INTEN (1 << 18)
72#define CSICR1_SOF_POL (1 << 17)
73#define CSICR1_SOF_INTEN (1 << 16)
74#define CSICR1_MCLKDIV(d) (((d) & 0xF) << 12)
75#define CSICR1_HSYNC_POL (1 << 11)
76#define CSICR1_CCIR_EN (1 << 10)
77#define CSICR1_MCLKEN (1 << 9)
78#define CSICR1_FCC (1 << 8)
79#define CSICR1_PACK_DIR (1 << 7)
80#define CSICR1_CLR_STATFIFO (1 << 6)
81#define CSICR1_CLR_RXFIFO (1 << 5)
82#define CSICR1_GCLK_MODE (1 << 4)
83#define CSICR1_INV_DATA (1 << 3)
84#define CSICR1_INV_PCLK (1 << 2)
85#define CSICR1_REDGE (1 << 1)
86
87#define SHIFT_STATFF_LEVEL 22
88#define SHIFT_RXFF_LEVEL 19
89#define SHIFT_MCLKDIV 12
90
91/* control reg 3 */
92#define CSICR3_FRMCNT (0xFFFF << 16)
93#define CSICR3_FRMCNT_RST (1 << 15)
94#define CSICR3_DMA_REFLASH_RFF (1 << 14)
95#define CSICR3_DMA_REFLASH_SFF (1 << 13)
96#define CSICR3_DMA_REQ_EN_RFF (1 << 12)
97#define CSICR3_DMA_REQ_EN_SFF (1 << 11)
98#define CSICR3_RXFF_LEVEL(l) (((l) & 7) << 4) /* MX25 */
99#define CSICR3_CSI_SUP (1 << 3)
100#define CSICR3_ZERO_PACK_EN (1 << 2)
101#define CSICR3_ECC_INT_EN (1 << 1)
102#define CSICR3_ECC_AUTO_EN (1 << 0)
103
104#define SHIFT_FRMCNT 16
105
106/* csi status reg */
107#define CSISR_SFF_OR_INT (1 << 25)
108#define CSISR_RFF_OR_INT (1 << 24)
109#define CSISR_STATFF_INT (1 << 21)
110#define CSISR_DMA_TSF_FB2_INT (1 << 20) /* MX25 */
111#define CSISR_DMA_TSF_FB1_INT (1 << 19) /* MX25 */
112#define CSISR_RXFF_INT (1 << 18)
113#define CSISR_EOF_INT (1 << 17)
114#define CSISR_SOF_INT (1 << 16)
115#define CSISR_F2_INT (1 << 15)
116#define CSISR_F1_INT (1 << 14)
117#define CSISR_COF_INT (1 << 13)
118#define CSISR_ECC_INT (1 << 1)
119#define CSISR_DRDY (1 << 0)
120
121#define CSICR1 0x00
122#define CSICR2 0x04
123#define CSISR (cpu_is_mx27() ? 0x08 : 0x18)
124#define CSISTATFIFO 0x0c
125#define CSIRFIFO 0x10
126#define CSIRXCNT 0x14
127#define CSICR3 (cpu_is_mx27() ? 0x1C : 0x08)
128#define CSIDMASA_STATFIFO 0x20
129#define CSIDMATA_STATFIFO 0x24
130#define CSIDMASA_FB1 0x28
131#define CSIDMASA_FB2 0x2c
132#define CSIFBUF_PARA 0x30
133#define CSIIMAG_PARA 0x34
134
135/* EMMA PrP */
136#define PRP_CNTL 0x00
137#define PRP_INTR_CNTL 0x04
138#define PRP_INTRSTATUS 0x08
139#define PRP_SOURCE_Y_PTR 0x0c
140#define PRP_SOURCE_CB_PTR 0x10
141#define PRP_SOURCE_CR_PTR 0x14
142#define PRP_DEST_RGB1_PTR 0x18
143#define PRP_DEST_RGB2_PTR 0x1c
144#define PRP_DEST_Y_PTR 0x20
145#define PRP_DEST_CB_PTR 0x24
146#define PRP_DEST_CR_PTR 0x28
147#define PRP_SRC_FRAME_SIZE 0x2c
148#define PRP_DEST_CH1_LINE_STRIDE 0x30
149#define PRP_SRC_PIXEL_FORMAT_CNTL 0x34
150#define PRP_CH1_PIXEL_FORMAT_CNTL 0x38
151#define PRP_CH1_OUT_IMAGE_SIZE 0x3c
152#define PRP_CH2_OUT_IMAGE_SIZE 0x40
153#define PRP_SRC_LINE_STRIDE 0x44
154#define PRP_CSC_COEF_012 0x48
155#define PRP_CSC_COEF_345 0x4c
156#define PRP_CSC_COEF_678 0x50
157#define PRP_CH1_RZ_HORI_COEF1 0x54
158#define PRP_CH1_RZ_HORI_COEF2 0x58
159#define PRP_CH1_RZ_HORI_VALID 0x5c
160#define PRP_CH1_RZ_VERT_COEF1 0x60
161#define PRP_CH1_RZ_VERT_COEF2 0x64
162#define PRP_CH1_RZ_VERT_VALID 0x68
163#define PRP_CH2_RZ_HORI_COEF1 0x6c
164#define PRP_CH2_RZ_HORI_COEF2 0x70
165#define PRP_CH2_RZ_HORI_VALID 0x74
166#define PRP_CH2_RZ_VERT_COEF1 0x78
167#define PRP_CH2_RZ_VERT_COEF2 0x7c
168#define PRP_CH2_RZ_VERT_VALID 0x80
169
170#define PRP_CNTL_CH1EN (1 << 0)
171#define PRP_CNTL_CH2EN (1 << 1)
172#define PRP_CNTL_CSIEN (1 << 2)
173#define PRP_CNTL_DATA_IN_YUV420 (0 << 3)
174#define PRP_CNTL_DATA_IN_YUV422 (1 << 3)
175#define PRP_CNTL_DATA_IN_RGB16 (2 << 3)
176#define PRP_CNTL_DATA_IN_RGB32 (3 << 3)
177#define PRP_CNTL_CH1_OUT_RGB8 (0 << 5)
178#define PRP_CNTL_CH1_OUT_RGB16 (1 << 5)
179#define PRP_CNTL_CH1_OUT_RGB32 (2 << 5)
180#define PRP_CNTL_CH1_OUT_YUV422 (3 << 5)
181#define PRP_CNTL_CH2_OUT_YUV420 (0 << 7)
182#define PRP_CNTL_CH2_OUT_YUV422 (1 << 7)
183#define PRP_CNTL_CH2_OUT_YUV444 (2 << 7)
184#define PRP_CNTL_CH1_LEN (1 << 9)
185#define PRP_CNTL_CH2_LEN (1 << 10)
186#define PRP_CNTL_SKIP_FRAME (1 << 11)
187#define PRP_CNTL_SWRST (1 << 12)
188#define PRP_CNTL_CLKEN (1 << 13)
189#define PRP_CNTL_WEN (1 << 14)
190#define PRP_CNTL_CH1BYP (1 << 15)
191#define PRP_CNTL_IN_TSKIP(x) ((x) << 16)
192#define PRP_CNTL_CH1_TSKIP(x) ((x) << 19)
193#define PRP_CNTL_CH2_TSKIP(x) ((x) << 22)
194#define PRP_CNTL_INPUT_FIFO_LEVEL(x) ((x) << 25)
195#define PRP_CNTL_RZ_FIFO_LEVEL(x) ((x) << 27)
196#define PRP_CNTL_CH2B1EN (1 << 29)
197#define PRP_CNTL_CH2B2EN (1 << 30)
198#define PRP_CNTL_CH2FEN (1 << 31)
199
200/* IRQ Enable and status register */
201#define PRP_INTR_RDERR (1 << 0)
202#define PRP_INTR_CH1WERR (1 << 1)
203#define PRP_INTR_CH2WERR (1 << 2)
204#define PRP_INTR_CH1FC (1 << 3)
205#define PRP_INTR_CH2FC (1 << 5)
206#define PRP_INTR_LBOVF (1 << 7)
207#define PRP_INTR_CH2OVF (1 << 8)
208
209#define mx27_camera_emma(pcdev) (cpu_is_mx27() && pcdev->use_emma)
210
211#define MAX_VIDEO_MEM 16
212
213struct mx2_camera_dev {
214 struct device *dev;
215 struct soc_camera_host soc_host;
216 struct soc_camera_device *icd;
217 struct clk *clk_csi, *clk_emma;
218
219 unsigned int irq_csi, irq_emma;
220 void __iomem *base_csi, *base_emma;
221 unsigned long base_dma;
222
223 struct mx2_camera_platform_data *pdata;
224 struct resource *res_csi, *res_emma;
225 unsigned long platform_flags;
226
227 struct list_head capture;
228 struct list_head active_bufs;
229
230 spinlock_t lock;
231
232 int dma;
233 struct mx2_buffer *active;
234 struct mx2_buffer *fb1_active;
235 struct mx2_buffer *fb2_active;
236
237 int use_emma;
238
239 u32 csicr1;
240
241 void *discard_buffer;
242 dma_addr_t discard_buffer_dma;
243 size_t discard_size;
244};
245
246/* buffer for one video frame */
247struct mx2_buffer {
248 /* common v4l buffer stuff -- must be first */
249 struct videobuf_buffer vb;
250
251 enum v4l2_mbus_pixelcode code;
252
253 int bufnum;
254};
255
256static void mx2_camera_deactivate(struct mx2_camera_dev *pcdev)
257{
258 unsigned long flags;
259
260 clk_disable(pcdev->clk_csi);
261 writel(0, pcdev->base_csi + CSICR1);
262 if (mx27_camera_emma(pcdev)) {
263 writel(0, pcdev->base_emma + PRP_CNTL);
264 } else if (cpu_is_mx25()) {
265 spin_lock_irqsave(&pcdev->lock, flags);
266 pcdev->fb1_active = NULL;
267 pcdev->fb2_active = NULL;
268 writel(0, pcdev->base_csi + CSIDMASA_FB1);
269 writel(0, pcdev->base_csi + CSIDMASA_FB2);
270 spin_unlock_irqrestore(&pcdev->lock, flags);
271 }
272}
273
274/*
275 * The following two functions absolutely depend on the fact, that
276 * there can be only one camera on mx2 camera sensor interface
277 */
278static int mx2_camera_add_device(struct soc_camera_device *icd)
279{
280 struct soc_camera_host *ici = to_soc_camera_host(icd->dev.parent);
281 struct mx2_camera_dev *pcdev = ici->priv;
282 int ret;
283 u32 csicr1;
284
285 if (pcdev->icd)
286 return -EBUSY;
287
288 ret = clk_enable(pcdev->clk_csi);
289 if (ret < 0)
290 return ret;
291
292 csicr1 = CSICR1_MCLKEN;
293
294 if (mx27_camera_emma(pcdev)) {
295 csicr1 |= CSICR1_PRP_IF_EN | CSICR1_FCC |
296 CSICR1_RXFF_LEVEL(0);
297 } else if (cpu_is_mx27())
298 csicr1 |= CSICR1_SOF_INTEN | CSICR1_RXFF_LEVEL(2);
299
300 pcdev->csicr1 = csicr1;
301 writel(pcdev->csicr1, pcdev->base_csi + CSICR1);
302
303 pcdev->icd = icd;
304
305 dev_info(icd->dev.parent, "Camera driver attached to camera %d\n",
306 icd->devnum);
307
308 return 0;
309}
310
311static void mx2_camera_remove_device(struct soc_camera_device *icd)
312{
313 struct soc_camera_host *ici = to_soc_camera_host(icd->dev.parent);
314 struct mx2_camera_dev *pcdev = ici->priv;
315
316 BUG_ON(icd != pcdev->icd);
317
318 dev_info(icd->dev.parent, "Camera driver detached from camera %d\n",
319 icd->devnum);
320
321 mx2_camera_deactivate(pcdev);
322
323 if (pcdev->discard_buffer) {
324 dma_free_coherent(ici->v4l2_dev.dev, pcdev->discard_size,
325 pcdev->discard_buffer,
326 pcdev->discard_buffer_dma);
327 pcdev->discard_buffer = NULL;
328 }
329
330 pcdev->icd = NULL;
331}
332
333#ifdef CONFIG_MACH_MX27
334static void mx27_camera_dma_enable(struct mx2_camera_dev *pcdev)
335{
336 u32 tmp;
337
338 imx_dma_enable(pcdev->dma);
339
340 tmp = readl(pcdev->base_csi + CSICR1);
341 tmp |= CSICR1_RF_OR_INTEN;
342 writel(tmp, pcdev->base_csi + CSICR1);
343}
344
345static irqreturn_t mx27_camera_irq(int irq_csi, void *data)
346{
347 struct mx2_camera_dev *pcdev = data;
348 u32 status = readl(pcdev->base_csi + CSISR);
349
350 if (status & CSISR_SOF_INT && pcdev->active) {
351 u32 tmp;
352
353 tmp = readl(pcdev->base_csi + CSICR1);
354 writel(tmp | CSICR1_CLR_RXFIFO, pcdev->base_csi + CSICR1);
355 mx27_camera_dma_enable(pcdev);
356 }
357
358 writel(CSISR_SOF_INT | CSISR_RFF_OR_INT, pcdev->base_csi + CSISR);
359
360 return IRQ_HANDLED;
361}
362#else
363static irqreturn_t mx27_camera_irq(int irq_csi, void *data)
364{
365 return IRQ_NONE;
366}
367#endif /* CONFIG_MACH_MX27 */
368
369static void mx25_camera_frame_done(struct mx2_camera_dev *pcdev, int fb,
370 int state)
371{
372 struct videobuf_buffer *vb;
373 struct mx2_buffer *buf;
374 struct mx2_buffer **fb_active = fb == 1 ? &pcdev->fb1_active :
375 &pcdev->fb2_active;
376 u32 fb_reg = fb == 1 ? CSIDMASA_FB1 : CSIDMASA_FB2;
377 unsigned long flags;
378
379 spin_lock_irqsave(&pcdev->lock, flags);
380
381 vb = &(*fb_active)->vb;
382 dev_dbg(pcdev->dev, "%s (vb=0x%p) 0x%08lx %d\n", __func__,
383 vb, vb->baddr, vb->bsize);
384
385 vb->state = state;
386 do_gettimeofday(&vb->ts);
387 vb->field_count++;
388
389 wake_up(&vb->done);
390
391 if (list_empty(&pcdev->capture)) {
392 buf = NULL;
393 writel(0, pcdev->base_csi + fb_reg);
394 } else {
395 buf = list_entry(pcdev->capture.next, struct mx2_buffer,
396 vb.queue);
397 vb = &buf->vb;
398 list_del(&vb->queue);
399 vb->state = VIDEOBUF_ACTIVE;
400 writel(videobuf_to_dma_contig(vb), pcdev->base_csi + fb_reg);
401 }
402
403 *fb_active = buf;
404
405 spin_unlock_irqrestore(&pcdev->lock, flags);
406}
407
408static irqreturn_t mx25_camera_irq(int irq_csi, void *data)
409{
410 struct mx2_camera_dev *pcdev = data;
411 u32 status = readl(pcdev->base_csi + CSISR);
412
413 if (status & CSISR_DMA_TSF_FB1_INT)
414 mx25_camera_frame_done(pcdev, 1, VIDEOBUF_DONE);
415 else if (status & CSISR_DMA_TSF_FB2_INT)
416 mx25_camera_frame_done(pcdev, 2, VIDEOBUF_DONE);
417
418 /* FIXME: handle CSISR_RFF_OR_INT */
419
420 writel(status, pcdev->base_csi + CSISR);
421
422 return IRQ_HANDLED;
423}
424
425/*
426 * Videobuf operations
427 */
428static int mx2_videobuf_setup(struct videobuf_queue *vq, unsigned int *count,
429 unsigned int *size)
430{
431 struct soc_camera_device *icd = vq->priv_data;
432 int bytes_per_line = soc_mbus_bytes_per_line(icd->user_width,
433 icd->current_fmt->host_fmt);
434
435 dev_dbg(&icd->dev, "count=%d, size=%d\n", *count, *size);
436
437 if (bytes_per_line < 0)
438 return bytes_per_line;
439
440 *size = bytes_per_line * icd->user_height;
441
442 if (0 == *count)
443 *count = 32;
444 if (*size * *count > MAX_VIDEO_MEM * 1024 * 1024)
445 *count = (MAX_VIDEO_MEM * 1024 * 1024) / *size;
446
447 return 0;
448}
449
450static void free_buffer(struct videobuf_queue *vq, struct mx2_buffer *buf)
451{
452 struct soc_camera_device *icd = vq->priv_data;
453 struct videobuf_buffer *vb = &buf->vb;
454
455 dev_dbg(&icd->dev, "%s (vb=0x%p) 0x%08lx %d\n", __func__,
456 vb, vb->baddr, vb->bsize);
457
458 /*
459 * This waits until this buffer is out of danger, i.e., until it is no
460 * longer in STATE_QUEUED or STATE_ACTIVE
461 */
462 videobuf_waiton(vb, 0, 0);
463
464 videobuf_dma_contig_free(vq, vb);
465 dev_dbg(&icd->dev, "%s freed\n", __func__);
466
467 vb->state = VIDEOBUF_NEEDS_INIT;
468}
469
470static int mx2_videobuf_prepare(struct videobuf_queue *vq,
471 struct videobuf_buffer *vb, enum v4l2_field field)
472{
473 struct soc_camera_device *icd = vq->priv_data;
474 struct mx2_buffer *buf = container_of(vb, struct mx2_buffer, vb);
475 int bytes_per_line = soc_mbus_bytes_per_line(icd->user_width,
476 icd->current_fmt->host_fmt);
477 int ret = 0;
478
479 dev_dbg(&icd->dev, "%s (vb=0x%p) 0x%08lx %d\n", __func__,
480 vb, vb->baddr, vb->bsize);
481
482 if (bytes_per_line < 0)
483 return bytes_per_line;
484
485#ifdef DEBUG
486 /*
487 * This can be useful if you want to see if we actually fill
488 * the buffer with something
489 */
490 memset((void *)vb->baddr, 0xaa, vb->bsize);
491#endif
492
493 if (buf->code != icd->current_fmt->code ||
494 vb->width != icd->user_width ||
495 vb->height != icd->user_height ||
496 vb->field != field) {
497 buf->code = icd->current_fmt->code;
498 vb->width = icd->user_width;
499 vb->height = icd->user_height;
500 vb->field = field;
501 vb->state = VIDEOBUF_NEEDS_INIT;
502 }
503
504 vb->size = bytes_per_line * vb->height;
505 if (vb->baddr && vb->bsize < vb->size) {
506 ret = -EINVAL;
507 goto out;
508 }
509
510 if (vb->state == VIDEOBUF_NEEDS_INIT) {
511 ret = videobuf_iolock(vq, vb, NULL);
512 if (ret)
513 goto fail;
514
515 vb->state = VIDEOBUF_PREPARED;
516 }
517
518 return 0;
519
520fail:
521 free_buffer(vq, buf);
522out:
523 return ret;
524}
525
526static void mx2_videobuf_queue(struct videobuf_queue *vq,
527 struct videobuf_buffer *vb)
528{
529 struct soc_camera_device *icd = vq->priv_data;
530 struct soc_camera_host *ici =
531 to_soc_camera_host(icd->dev.parent);
532 struct mx2_camera_dev *pcdev = ici->priv;
533 struct mx2_buffer *buf = container_of(vb, struct mx2_buffer, vb);
534 unsigned long flags;
535
536 dev_dbg(&icd->dev, "%s (vb=0x%p) 0x%08lx %d\n", __func__,
537 vb, vb->baddr, vb->bsize);
538
539 spin_lock_irqsave(&pcdev->lock, flags);
540
541 vb->state = VIDEOBUF_QUEUED;
542 list_add_tail(&vb->queue, &pcdev->capture);
543
544 if (mx27_camera_emma(pcdev)) {
545 goto out;
546#ifdef CONFIG_MACH_MX27
547 } else if (cpu_is_mx27()) {
548 int ret;
549
550 if (pcdev->active == NULL) {
551 ret = imx_dma_setup_single(pcdev->dma,
552 videobuf_to_dma_contig(vb), vb->size,
553 (u32)pcdev->base_dma + 0x10,
554 DMA_MODE_READ);
555 if (ret) {
556 vb->state = VIDEOBUF_ERROR;
557 wake_up(&vb->done);
558 goto out;
559 }
560
561 vb->state = VIDEOBUF_ACTIVE;
562 pcdev->active = buf;
563 }
564#endif
565 } else { /* cpu_is_mx25() */
566 u32 csicr3, dma_inten = 0;
567
568 if (pcdev->fb1_active == NULL) {
569 writel(videobuf_to_dma_contig(vb),
570 pcdev->base_csi + CSIDMASA_FB1);
571 pcdev->fb1_active = buf;
572 dma_inten = CSICR1_FB1_DMA_INTEN;
573 } else if (pcdev->fb2_active == NULL) {
574 writel(videobuf_to_dma_contig(vb),
575 pcdev->base_csi + CSIDMASA_FB2);
576 pcdev->fb2_active = buf;
577 dma_inten = CSICR1_FB2_DMA_INTEN;
578 }
579
580 if (dma_inten) {
581 list_del(&vb->queue);
582 vb->state = VIDEOBUF_ACTIVE;
583
584 csicr3 = readl(pcdev->base_csi + CSICR3);
585
586 /* Reflash DMA */
587 writel(csicr3 | CSICR3_DMA_REFLASH_RFF,
588 pcdev->base_csi + CSICR3);
589
590 /* clear & enable interrupts */
591 writel(dma_inten, pcdev->base_csi + CSISR);
592 pcdev->csicr1 |= dma_inten;
593 writel(pcdev->csicr1, pcdev->base_csi + CSICR1);
594
595 /* enable DMA */
596 csicr3 |= CSICR3_DMA_REQ_EN_RFF | CSICR3_RXFF_LEVEL(1);
597 writel(csicr3, pcdev->base_csi + CSICR3);
598 }
599 }
600
601out:
602 spin_unlock_irqrestore(&pcdev->lock, flags);
603}
604
605static void mx2_videobuf_release(struct videobuf_queue *vq,
606 struct videobuf_buffer *vb)
607{
608 struct soc_camera_device *icd = vq->priv_data;
609 struct soc_camera_host *ici = to_soc_camera_host(icd->dev.parent);
610 struct mx2_camera_dev *pcdev = ici->priv;
611 struct mx2_buffer *buf = container_of(vb, struct mx2_buffer, vb);
612 unsigned long flags;
613
614#ifdef DEBUG
615 dev_dbg(&icd->dev, "%s (vb=0x%p) 0x%08lx %d\n", __func__,
616 vb, vb->baddr, vb->bsize);
617
618 switch (vb->state) {
619 case VIDEOBUF_ACTIVE:
620 dev_info(&icd->dev, "%s (active)\n", __func__);
621 break;
622 case VIDEOBUF_QUEUED:
623 dev_info(&icd->dev, "%s (queued)\n", __func__);
624 break;
625 case VIDEOBUF_PREPARED:
626 dev_info(&icd->dev, "%s (prepared)\n", __func__);
627 break;
628 default:
629 dev_info(&icd->dev, "%s (unknown) %d\n", __func__,
630 vb->state);
631 break;
632 }
633#endif
634
635 /*
636 * Terminate only queued but inactive buffers. Active buffers are
637 * released when they become inactive after videobuf_waiton().
638 *
639 * FIXME: implement forced termination of active buffers, so that the
640 * user won't get stuck in an uninterruptible state. This requires a
641 * specific handling for each of the three DMA types that this driver
642 * supports.
643 */
644 spin_lock_irqsave(&pcdev->lock, flags);
645 if (vb->state == VIDEOBUF_QUEUED) {
646 list_del(&vb->queue);
647 vb->state = VIDEOBUF_ERROR;
648 }
649 spin_unlock_irqrestore(&pcdev->lock, flags);
650
651 free_buffer(vq, buf);
652}
653
654static struct videobuf_queue_ops mx2_videobuf_ops = {
655 .buf_setup = mx2_videobuf_setup,
656 .buf_prepare = mx2_videobuf_prepare,
657 .buf_queue = mx2_videobuf_queue,
658 .buf_release = mx2_videobuf_release,
659};
660
661static void mx2_camera_init_videobuf(struct videobuf_queue *q,
662 struct soc_camera_device *icd)
663{
664 struct soc_camera_host *ici = to_soc_camera_host(icd->dev.parent);
665 struct mx2_camera_dev *pcdev = ici->priv;
666
667 videobuf_queue_dma_contig_init(q, &mx2_videobuf_ops, pcdev->dev,
668 &pcdev->lock, V4L2_BUF_TYPE_VIDEO_CAPTURE,
669 V4L2_FIELD_NONE, sizeof(struct mx2_buffer), icd);
670}
671
672#define MX2_BUS_FLAGS (SOCAM_DATAWIDTH_8 | \
673 SOCAM_MASTER | \
674 SOCAM_VSYNC_ACTIVE_HIGH | \
675 SOCAM_VSYNC_ACTIVE_LOW | \
676 SOCAM_HSYNC_ACTIVE_HIGH | \
677 SOCAM_HSYNC_ACTIVE_LOW | \
678 SOCAM_PCLK_SAMPLE_RISING | \
679 SOCAM_PCLK_SAMPLE_FALLING | \
680 SOCAM_DATA_ACTIVE_HIGH | \
681 SOCAM_DATA_ACTIVE_LOW)
682
683static int mx27_camera_emma_prp_reset(struct mx2_camera_dev *pcdev)
684{
685 u32 cntl;
686 int count = 0;
687
688 cntl = readl(pcdev->base_emma + PRP_CNTL);
689 writel(PRP_CNTL_SWRST, pcdev->base_emma + PRP_CNTL);
690 while (count++ < 100) {
691 if (!(readl(pcdev->base_emma + PRP_CNTL) & PRP_CNTL_SWRST))
692 return 0;
693 barrier();
694 udelay(1);
695 }
696
697 return -ETIMEDOUT;
698}
699
700static void mx27_camera_emma_buf_init(struct soc_camera_device *icd,
701 int bytesperline)
702{
703 struct soc_camera_host *ici =
704 to_soc_camera_host(icd->dev.parent);
705 struct mx2_camera_dev *pcdev = ici->priv;
706
707 writel(pcdev->discard_buffer_dma,
708 pcdev->base_emma + PRP_DEST_RGB1_PTR);
709 writel(pcdev->discard_buffer_dma,
710 pcdev->base_emma + PRP_DEST_RGB2_PTR);
711
712 /*
713 * We only use the EMMA engine to get rid of the broken
714 * DMA Engine. No color space consversion at the moment.
715 * We adjust incoming and outgoing pixelformat to rgb16
716 * and adjust the bytesperline accordingly.
717 */
718 writel(PRP_CNTL_CH1EN |
719 PRP_CNTL_CSIEN |
720 PRP_CNTL_DATA_IN_RGB16 |
721 PRP_CNTL_CH1_OUT_RGB16 |
722 PRP_CNTL_CH1_LEN |
723 PRP_CNTL_CH1BYP |
724 PRP_CNTL_CH1_TSKIP(0) |
725 PRP_CNTL_IN_TSKIP(0),
726 pcdev->base_emma + PRP_CNTL);
727
728 writel(((bytesperline >> 1) << 16) | icd->user_height,
729 pcdev->base_emma + PRP_SRC_FRAME_SIZE);
730 writel(((bytesperline >> 1) << 16) | icd->user_height,
731 pcdev->base_emma + PRP_CH1_OUT_IMAGE_SIZE);
732 writel(bytesperline,
733 pcdev->base_emma + PRP_DEST_CH1_LINE_STRIDE);
734 writel(0x2ca00565, /* RGB565 */
735 pcdev->base_emma + PRP_SRC_PIXEL_FORMAT_CNTL);
736 writel(0x2ca00565, /* RGB565 */
737 pcdev->base_emma + PRP_CH1_PIXEL_FORMAT_CNTL);
738
739 /* Enable interrupts */
740 writel(PRP_INTR_RDERR |
741 PRP_INTR_CH1WERR |
742 PRP_INTR_CH2WERR |
743 PRP_INTR_CH1FC |
744 PRP_INTR_CH2FC |
745 PRP_INTR_LBOVF |
746 PRP_INTR_CH2OVF,
747 pcdev->base_emma + PRP_INTR_CNTL);
748}
749
750static int mx2_camera_set_bus_param(struct soc_camera_device *icd,
751 __u32 pixfmt)
752{
753 struct soc_camera_host *ici =
754 to_soc_camera_host(icd->dev.parent);
755 struct mx2_camera_dev *pcdev = ici->priv;
756 unsigned long camera_flags, common_flags;
757 int ret = 0;
758 int bytesperline;
759 u32 csicr1 = pcdev->csicr1;
760
761 camera_flags = icd->ops->query_bus_param(icd);
762
763 common_flags = soc_camera_bus_param_compatible(camera_flags,
764 MX2_BUS_FLAGS);
765 if (!common_flags)
766 return -EINVAL;
767
768 if ((common_flags & SOCAM_HSYNC_ACTIVE_HIGH) &&
769 (common_flags & SOCAM_HSYNC_ACTIVE_LOW)) {
770 if (pcdev->platform_flags & MX2_CAMERA_HSYNC_HIGH)
771 common_flags &= ~SOCAM_HSYNC_ACTIVE_LOW;
772 else
773 common_flags &= ~SOCAM_HSYNC_ACTIVE_HIGH;
774 }
775
776 if ((common_flags & SOCAM_PCLK_SAMPLE_RISING) &&
777 (common_flags & SOCAM_PCLK_SAMPLE_FALLING)) {
778 if (pcdev->platform_flags & MX2_CAMERA_PCLK_SAMPLE_RISING)
779 common_flags &= ~SOCAM_PCLK_SAMPLE_FALLING;
780 else
781 common_flags &= ~SOCAM_PCLK_SAMPLE_RISING;
782 }
783
784 ret = icd->ops->set_bus_param(icd, common_flags);
785 if (ret < 0)
786 return ret;
787
788 if (common_flags & SOCAM_PCLK_SAMPLE_FALLING)
789 csicr1 |= CSICR1_INV_PCLK;
790 if (common_flags & SOCAM_VSYNC_ACTIVE_HIGH)
791 csicr1 |= CSICR1_SOF_POL;
792 if (common_flags & SOCAM_HSYNC_ACTIVE_HIGH)
793 csicr1 |= CSICR1_HSYNC_POL;
794 if (pcdev->platform_flags & MX2_CAMERA_SWAP16)
795 csicr1 |= CSICR1_SWAP16_EN;
796 if (pcdev->platform_flags & MX2_CAMERA_EXT_VSYNC)
797 csicr1 |= CSICR1_EXT_VSYNC;
798 if (pcdev->platform_flags & MX2_CAMERA_CCIR)
799 csicr1 |= CSICR1_CCIR_EN;
800 if (pcdev->platform_flags & MX2_CAMERA_CCIR_INTERLACE)
801 csicr1 |= CSICR1_CCIR_MODE;
802 if (pcdev->platform_flags & MX2_CAMERA_GATED_CLOCK)
803 csicr1 |= CSICR1_GCLK_MODE;
804 if (pcdev->platform_flags & MX2_CAMERA_INV_DATA)
805 csicr1 |= CSICR1_INV_DATA;
806 if (pcdev->platform_flags & MX2_CAMERA_PACK_DIR_MSB)
807 csicr1 |= CSICR1_PACK_DIR;
808
809 pcdev->csicr1 = csicr1;
810
811 bytesperline = soc_mbus_bytes_per_line(icd->user_width,
812 icd->current_fmt->host_fmt);
813 if (bytesperline < 0)
814 return bytesperline;
815
816 if (mx27_camera_emma(pcdev)) {
817 ret = mx27_camera_emma_prp_reset(pcdev);
818 if (ret)
819 return ret;
820
821 if (pcdev->discard_buffer)
822 dma_free_coherent(ici->v4l2_dev.dev,
823 pcdev->discard_size, pcdev->discard_buffer,
824 pcdev->discard_buffer_dma);
825
826 /*
827 * I didn't manage to properly enable/disable the prp
828 * on a per frame basis during running transfers,
829 * thus we allocate a buffer here and use it to
830 * discard frames when no buffer is available.
831 * Feel free to work on this ;)
832 */
833 pcdev->discard_size = icd->user_height * bytesperline;
834 pcdev->discard_buffer = dma_alloc_coherent(ici->v4l2_dev.dev,
835 pcdev->discard_size, &pcdev->discard_buffer_dma,
836 GFP_KERNEL);
837 if (!pcdev->discard_buffer)
838 return -ENOMEM;
839
840 mx27_camera_emma_buf_init(icd, bytesperline);
841 } else if (cpu_is_mx25()) {
842 writel((bytesperline * icd->user_height) >> 2,
843 pcdev->base_csi + CSIRXCNT);
844 writel((bytesperline << 16) | icd->user_height,
845 pcdev->base_csi + CSIIMAG_PARA);
846 }
847
848 writel(pcdev->csicr1, pcdev->base_csi + CSICR1);
849
850 return 0;
851}
852
853static int mx2_camera_set_crop(struct soc_camera_device *icd,
854 struct v4l2_crop *a)
855{
856 struct v4l2_rect *rect = &a->c;
857 struct v4l2_subdev *sd = soc_camera_to_subdev(icd);
858 struct v4l2_mbus_framefmt mf;
859 int ret;
860
861 soc_camera_limit_side(&rect->left, &rect->width, 0, 2, 4096);
862 soc_camera_limit_side(&rect->top, &rect->height, 0, 2, 4096);
863
864 ret = v4l2_subdev_call(sd, video, s_crop, a);
865 if (ret < 0)
866 return ret;
867
868 /* The capture device might have changed its output */
869 ret = v4l2_subdev_call(sd, video, g_mbus_fmt, &mf);
870 if (ret < 0)
871 return ret;
872
873 dev_dbg(icd->dev.parent, "Sensor cropped %dx%d\n",
874 mf.width, mf.height);
875
876 icd->user_width = mf.width;
877 icd->user_height = mf.height;
878
879 return ret;
880}
881
882static int mx2_camera_set_fmt(struct soc_camera_device *icd,
883 struct v4l2_format *f)
884{
885 struct soc_camera_host *ici = to_soc_camera_host(icd->dev.parent);
886 struct mx2_camera_dev *pcdev = ici->priv;
887 struct v4l2_subdev *sd = soc_camera_to_subdev(icd);
888 const struct soc_camera_format_xlate *xlate;
889 struct v4l2_pix_format *pix = &f->fmt.pix;
890 struct v4l2_mbus_framefmt mf;
891 int ret;
892
893 xlate = soc_camera_xlate_by_fourcc(icd, pix->pixelformat);
894 if (!xlate) {
895 dev_warn(icd->dev.parent, "Format %x not found\n",
896 pix->pixelformat);
897 return -EINVAL;
898 }
899
900 /* eMMA can only do RGB565 */
901 if (mx27_camera_emma(pcdev) && pix->pixelformat != V4L2_PIX_FMT_RGB565)
902 return -EINVAL;
903
904 mf.width = pix->width;
905 mf.height = pix->height;
906 mf.field = pix->field;
907 mf.colorspace = pix->colorspace;
908 mf.code = xlate->code;
909
910 ret = v4l2_subdev_call(sd, video, s_mbus_fmt, &mf);
911 if (ret < 0 && ret != -ENOIOCTLCMD)
912 return ret;
913
914 if (mf.code != xlate->code)
915 return -EINVAL;
916
917 pix->width = mf.width;
918 pix->height = mf.height;
919 pix->field = mf.field;
920 pix->colorspace = mf.colorspace;
921 icd->current_fmt = xlate;
922
923 return 0;
924}
925
926static int mx2_camera_try_fmt(struct soc_camera_device *icd,
927 struct v4l2_format *f)
928{
929 struct soc_camera_host *ici = to_soc_camera_host(icd->dev.parent);
930 struct mx2_camera_dev *pcdev = ici->priv;
931 struct v4l2_subdev *sd = soc_camera_to_subdev(icd);
932 const struct soc_camera_format_xlate *xlate;
933 struct v4l2_pix_format *pix = &f->fmt.pix;
934 struct v4l2_mbus_framefmt mf;
935 __u32 pixfmt = pix->pixelformat;
936 unsigned int width_limit;
937 int ret;
938
939 xlate = soc_camera_xlate_by_fourcc(icd, pixfmt);
940 if (pixfmt && !xlate) {
941 dev_warn(icd->dev.parent, "Format %x not found\n", pixfmt);
942 return -EINVAL;
943 }
944
945 /* FIXME: implement MX27 limits */
946
947 /* eMMA can only do RGB565 */
948 if (mx27_camera_emma(pcdev) && pixfmt != V4L2_PIX_FMT_RGB565)
949 return -EINVAL;
950
951 /* limit to MX25 hardware capabilities */
952 if (cpu_is_mx25()) {
953 if (xlate->host_fmt->bits_per_sample <= 8)
954 width_limit = 0xffff * 4;
955 else
956 width_limit = 0xffff * 2;
957 /* CSIIMAG_PARA limit */
958 if (pix->width > width_limit)
959 pix->width = width_limit;
960 if (pix->height > 0xffff)
961 pix->height = 0xffff;
962
963 pix->bytesperline = soc_mbus_bytes_per_line(pix->width,
964 xlate->host_fmt);
965 if (pix->bytesperline < 0)
966 return pix->bytesperline;
967 pix->sizeimage = pix->height * pix->bytesperline;
968 if (pix->sizeimage > (4 * 0x3ffff)) { /* CSIRXCNT limit */
969 dev_warn(icd->dev.parent,
970 "Image size (%u) above limit\n",
971 pix->sizeimage);
972 return -EINVAL;
973 }
974 }
975
976 /* limit to sensor capabilities */
977 mf.width = pix->width;
978 mf.height = pix->height;
979 mf.field = pix->field;
980 mf.colorspace = pix->colorspace;
981 mf.code = xlate->code;
982
983 ret = v4l2_subdev_call(sd, video, try_mbus_fmt, &mf);
984 if (ret < 0)
985 return ret;
986
987 if (mf.field == V4L2_FIELD_ANY)
988 mf.field = V4L2_FIELD_NONE;
989 if (mf.field != V4L2_FIELD_NONE) {
990 dev_err(icd->dev.parent, "Field type %d unsupported.\n",
991 mf.field);
992 return -EINVAL;
993 }
994
995 pix->width = mf.width;
996 pix->height = mf.height;
997 pix->field = mf.field;
998 pix->colorspace = mf.colorspace;
999
1000 return 0;
1001}
1002
1003static int mx2_camera_querycap(struct soc_camera_host *ici,
1004 struct v4l2_capability *cap)
1005{
1006 /* cap->name is set by the friendly caller:-> */
1007 strlcpy(cap->card, MX2_CAM_DRIVER_DESCRIPTION, sizeof(cap->card));
1008 cap->version = MX2_CAM_VERSION_CODE;
1009 cap->capabilities = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_STREAMING;
1010
1011 return 0;
1012}
1013
1014static int mx2_camera_reqbufs(struct soc_camera_file *icf,
1015 struct v4l2_requestbuffers *p)
1016{
1017 int i;
1018
1019 for (i = 0; i < p->count; i++) {
1020 struct mx2_buffer *buf = container_of(icf->vb_vidq.bufs[i],
1021 struct mx2_buffer, vb);
1022 INIT_LIST_HEAD(&buf->vb.queue);
1023 }
1024
1025 return 0;
1026}
1027
1028#ifdef CONFIG_MACH_MX27
1029static void mx27_camera_frame_done(struct mx2_camera_dev *pcdev, int state)
1030{
1031 struct videobuf_buffer *vb;
1032 struct mx2_buffer *buf;
1033 unsigned long flags;
1034 int ret;
1035
1036 spin_lock_irqsave(&pcdev->lock, flags);
1037
1038 if (!pcdev->active) {
1039 dev_err(pcdev->dev, "%s called with no active buffer!\n",
1040 __func__);
1041 goto out;
1042 }
1043
1044 vb = &pcdev->active->vb;
1045 buf = container_of(vb, struct mx2_buffer, vb);
1046 WARN_ON(list_empty(&vb->queue));
1047 dev_dbg(pcdev->dev, "%s (vb=0x%p) 0x%08lx %d\n", __func__,
1048 vb, vb->baddr, vb->bsize);
1049
1050 /* _init is used to debug races, see comment in pxa_camera_reqbufs() */
1051 list_del_init(&vb->queue);
1052 vb->state = state;
1053 do_gettimeofday(&vb->ts);
1054 vb->field_count++;
1055
1056 wake_up(&vb->done);
1057
1058 if (list_empty(&pcdev->capture)) {
1059 pcdev->active = NULL;
1060 goto out;
1061 }
1062
1063 pcdev->active = list_entry(pcdev->capture.next,
1064 struct mx2_buffer, vb.queue);
1065
1066 vb = &pcdev->active->vb;
1067 vb->state = VIDEOBUF_ACTIVE;
1068
1069 ret = imx_dma_setup_single(pcdev->dma, videobuf_to_dma_contig(vb),
1070 vb->size, (u32)pcdev->base_dma + 0x10, DMA_MODE_READ);
1071
1072 if (ret) {
1073 vb->state = VIDEOBUF_ERROR;
1074 pcdev->active = NULL;
1075 wake_up(&vb->done);
1076 }
1077
1078out:
1079 spin_unlock_irqrestore(&pcdev->lock, flags);
1080}
1081
1082static void mx27_camera_dma_err_callback(int channel, void *data, int err)
1083{
1084 struct mx2_camera_dev *pcdev = data;
1085
1086 mx27_camera_frame_done(pcdev, VIDEOBUF_ERROR);
1087}
1088
1089static void mx27_camera_dma_callback(int channel, void *data)
1090{
1091 struct mx2_camera_dev *pcdev = data;
1092
1093 mx27_camera_frame_done(pcdev, VIDEOBUF_DONE);
1094}
1095
1096#define DMA_REQ_CSI_RX 31 /* FIXME: Add this to a resource */
1097
1098static int __devinit mx27_camera_dma_init(struct platform_device *pdev,
1099 struct mx2_camera_dev *pcdev)
1100{
1101 int err;
1102
1103 pcdev->dma = imx_dma_request_by_prio("CSI RX DMA", DMA_PRIO_HIGH);
1104 if (pcdev->dma < 0) {
1105 dev_err(&pdev->dev, "%s failed to request DMA channel\n",
1106 __func__);
1107 return pcdev->dma;
1108 }
1109
1110 err = imx_dma_setup_handlers(pcdev->dma, mx27_camera_dma_callback,
1111 mx27_camera_dma_err_callback, pcdev);
1112 if (err) {
1113 dev_err(&pdev->dev, "%s failed to set DMA callback\n",
1114 __func__);
1115 goto err_out;
1116 }
1117
1118 err = imx_dma_config_channel(pcdev->dma,
1119 IMX_DMA_MEMSIZE_32 | IMX_DMA_TYPE_FIFO,
1120 IMX_DMA_MEMSIZE_32 | IMX_DMA_TYPE_LINEAR,
1121 DMA_REQ_CSI_RX, 1);
1122 if (err) {
1123 dev_err(&pdev->dev, "%s failed to config DMA channel\n",
1124 __func__);
1125 goto err_out;
1126 }
1127
1128 imx_dma_config_burstlen(pcdev->dma, 64);
1129
1130 return 0;
1131
1132err_out:
1133 imx_dma_free(pcdev->dma);
1134
1135 return err;
1136}
1137#endif /* CONFIG_MACH_MX27 */
1138
1139static unsigned int mx2_camera_poll(struct file *file, poll_table *pt)
1140{
1141 struct soc_camera_file *icf = file->private_data;
1142
1143 return videobuf_poll_stream(file, &icf->vb_vidq, pt);
1144}
1145
1146static struct soc_camera_host_ops mx2_soc_camera_host_ops = {
1147 .owner = THIS_MODULE,
1148 .add = mx2_camera_add_device,
1149 .remove = mx2_camera_remove_device,
1150 .set_fmt = mx2_camera_set_fmt,
1151 .set_crop = mx2_camera_set_crop,
1152 .try_fmt = mx2_camera_try_fmt,
1153 .init_videobuf = mx2_camera_init_videobuf,
1154 .reqbufs = mx2_camera_reqbufs,
1155 .poll = mx2_camera_poll,
1156 .querycap = mx2_camera_querycap,
1157 .set_bus_param = mx2_camera_set_bus_param,
1158};
1159
1160static void mx27_camera_frame_done_emma(struct mx2_camera_dev *pcdev,
1161 int bufnum, int state)
1162{
1163 struct mx2_buffer *buf;
1164 struct videobuf_buffer *vb;
1165 unsigned long phys;
1166
1167 if (!list_empty(&pcdev->active_bufs)) {
1168 buf = list_entry(pcdev->active_bufs.next,
1169 struct mx2_buffer, vb.queue);
1170
1171 BUG_ON(buf->bufnum != bufnum);
1172
1173 vb = &buf->vb;
1174#ifdef DEBUG
1175 phys = videobuf_to_dma_contig(vb);
1176 if (readl(pcdev->base_emma + PRP_DEST_RGB1_PTR + 4 * bufnum)
1177 != phys) {
1178 dev_err(pcdev->dev, "%p != %p\n", phys,
1179 readl(pcdev->base_emma +
1180 PRP_DEST_RGB1_PTR +
1181 4 * bufnum));
1182 }
1183#endif
1184 dev_dbg(pcdev->dev, "%s (vb=0x%p) 0x%08lx %d\n", __func__, vb,
1185 vb->baddr, vb->bsize);
1186
1187 list_del(&vb->queue);
1188 vb->state = state;
1189 do_gettimeofday(&vb->ts);
1190 vb->field_count++;
1191
1192 wake_up(&vb->done);
1193 }
1194
1195 if (list_empty(&pcdev->capture)) {
1196 writel(pcdev->discard_buffer_dma, pcdev->base_emma +
1197 PRP_DEST_RGB1_PTR + 4 * bufnum);
1198 return;
1199 }
1200
1201 buf = list_entry(pcdev->capture.next,
1202 struct mx2_buffer, vb.queue);
1203
1204 buf->bufnum = bufnum;
1205
1206 list_move_tail(pcdev->capture.next, &pcdev->active_bufs);
1207
1208 vb = &buf->vb;
1209 vb->state = VIDEOBUF_ACTIVE;
1210
1211 phys = videobuf_to_dma_contig(vb);
1212 writel(phys, pcdev->base_emma + PRP_DEST_RGB1_PTR + 4 * bufnum);
1213}
1214
1215static irqreturn_t mx27_camera_emma_irq(int irq_emma, void *data)
1216{
1217 struct mx2_camera_dev *pcdev = data;
1218 unsigned int status = readl(pcdev->base_emma + PRP_INTRSTATUS);
1219 struct mx2_buffer *buf;
1220
1221 if (status & (1 << 7)) { /* overflow */
1222 u32 cntl;
1223 /*
1224 * We only disable channel 1 here since this is the only
1225 * enabled channel
1226 *
1227 * FIXME: the correct DMA overflow handling should be resetting
1228 * the buffer, returning an error frame, and continuing with
1229 * the next one.
1230 */
1231 cntl = readl(pcdev->base_emma + PRP_CNTL);
1232 writel(cntl & ~PRP_CNTL_CH1EN, pcdev->base_emma + PRP_CNTL);
1233 writel(cntl, pcdev->base_emma + PRP_CNTL);
1234 }
1235 if ((status & (3 << 5)) == (3 << 5)
1236 && !list_empty(&pcdev->active_bufs)) {
1237 /*
1238 * Both buffers have triggered, process the one we're expecting
1239 * to first
1240 */
1241 buf = list_entry(pcdev->active_bufs.next,
1242 struct mx2_buffer, vb.queue);
1243 mx27_camera_frame_done_emma(pcdev, buf->bufnum, VIDEOBUF_DONE);
1244 status &= ~(1 << (6 - buf->bufnum)); /* mark processed */
1245 }
1246 if (status & (1 << 6))
1247 mx27_camera_frame_done_emma(pcdev, 0, VIDEOBUF_DONE);
1248 if (status & (1 << 5))
1249 mx27_camera_frame_done_emma(pcdev, 1, VIDEOBUF_DONE);
1250
1251 writel(status, pcdev->base_emma + PRP_INTRSTATUS);
1252
1253 return IRQ_HANDLED;
1254}
1255
1256static int __devinit mx27_camera_emma_init(struct mx2_camera_dev *pcdev)
1257{
1258 struct resource *res_emma = pcdev->res_emma;
1259 int err = 0;
1260
1261 if (!request_mem_region(res_emma->start, resource_size(res_emma),
1262 MX2_CAM_DRV_NAME)) {
1263 err = -EBUSY;
1264 goto out;
1265 }
1266
1267 pcdev->base_emma = ioremap(res_emma->start, resource_size(res_emma));
1268 if (!pcdev->base_emma) {
1269 err = -ENOMEM;
1270 goto exit_release;
1271 }
1272
1273 err = request_irq(pcdev->irq_emma, mx27_camera_emma_irq, 0,
1274 MX2_CAM_DRV_NAME, pcdev);
1275 if (err) {
1276 dev_err(pcdev->dev, "Camera EMMA interrupt register failed \n");
1277 goto exit_iounmap;
1278 }
1279
1280 pcdev->clk_emma = clk_get(NULL, "emma");
1281 if (IS_ERR(pcdev->clk_emma)) {
1282 err = PTR_ERR(pcdev->clk_emma);
1283 goto exit_free_irq;
1284 }
1285
1286 clk_enable(pcdev->clk_emma);
1287
1288 err = mx27_camera_emma_prp_reset(pcdev);
1289 if (err)
1290 goto exit_clk_emma_put;
1291
1292 return err;
1293
1294exit_clk_emma_put:
1295 clk_disable(pcdev->clk_emma);
1296 clk_put(pcdev->clk_emma);
1297exit_free_irq:
1298 free_irq(pcdev->irq_emma, pcdev);
1299exit_iounmap:
1300 iounmap(pcdev->base_emma);
1301exit_release:
1302 release_mem_region(res_emma->start, resource_size(res_emma));
1303out:
1304 return err;
1305}
1306
1307static int __devinit mx2_camera_probe(struct platform_device *pdev)
1308{
1309 struct mx2_camera_dev *pcdev;
1310 struct resource *res_csi, *res_emma;
1311 void __iomem *base_csi;
1312 int irq_csi, irq_emma;
1313 irq_handler_t mx2_cam_irq_handler = cpu_is_mx25() ? mx25_camera_irq
1314 : mx27_camera_irq;
1315 int err = 0;
1316
1317 dev_dbg(&pdev->dev, "initialising\n");
1318
1319 res_csi = platform_get_resource(pdev, IORESOURCE_MEM, 0);
1320 irq_csi = platform_get_irq(pdev, 0);
1321 if (res_csi == NULL || irq_csi < 0) {
1322 dev_err(&pdev->dev, "Missing platform resources data\n");
1323 err = -ENODEV;
1324 goto exit;
1325 }
1326
1327 pcdev = kzalloc(sizeof(*pcdev), GFP_KERNEL);
1328 if (!pcdev) {
1329 dev_err(&pdev->dev, "Could not allocate pcdev\n");
1330 err = -ENOMEM;
1331 goto exit;
1332 }
1333
1334 pcdev->clk_csi = clk_get(&pdev->dev, NULL);
1335 if (IS_ERR(pcdev->clk_csi)) {
1336 err = PTR_ERR(pcdev->clk_csi);
1337 goto exit_kfree;
1338 }
1339
1340 dev_dbg(&pdev->dev, "Camera clock frequency: %ld\n",
1341 clk_get_rate(pcdev->clk_csi));
1342
1343 /* Initialize DMA */
1344#ifdef CONFIG_MACH_MX27
1345 if (cpu_is_mx27()) {
1346 err = mx27_camera_dma_init(pdev, pcdev);
1347 if (err)
1348 goto exit_clk_put;
1349 }
1350#endif /* CONFIG_MACH_MX27 */
1351
1352 pcdev->res_csi = res_csi;
1353 pcdev->pdata = pdev->dev.platform_data;
1354 if (pcdev->pdata) {
1355 long rate;
1356
1357 pcdev->platform_flags = pcdev->pdata->flags;
1358
1359 rate = clk_round_rate(pcdev->clk_csi, pcdev->pdata->clk * 2);
1360 if (rate <= 0) {
1361 err = -ENODEV;
1362 goto exit_dma_free;
1363 }
1364 err = clk_set_rate(pcdev->clk_csi, rate);
1365 if (err < 0)
1366 goto exit_dma_free;
1367 }
1368
1369 INIT_LIST_HEAD(&pcdev->capture);
1370 INIT_LIST_HEAD(&pcdev->active_bufs);
1371 spin_lock_init(&pcdev->lock);
1372
1373 /*
1374 * Request the regions.
1375 */
1376 if (!request_mem_region(res_csi->start, resource_size(res_csi),
1377 MX2_CAM_DRV_NAME)) {
1378 err = -EBUSY;
1379 goto exit_dma_free;
1380 }
1381
1382 base_csi = ioremap(res_csi->start, resource_size(res_csi));
1383 if (!base_csi) {
1384 err = -ENOMEM;
1385 goto exit_release;
1386 }
1387 pcdev->irq_csi = irq_csi;
1388 pcdev->base_csi = base_csi;
1389 pcdev->base_dma = res_csi->start;
1390 pcdev->dev = &pdev->dev;
1391
1392 err = request_irq(pcdev->irq_csi, mx2_cam_irq_handler, 0,
1393 MX2_CAM_DRV_NAME, pcdev);
1394 if (err) {
1395 dev_err(pcdev->dev, "Camera interrupt register failed \n");
1396 goto exit_iounmap;
1397 }
1398
1399 if (cpu_is_mx27()) {
1400 /* EMMA support */
1401 res_emma = platform_get_resource(pdev, IORESOURCE_MEM, 1);
1402 irq_emma = platform_get_irq(pdev, 1);
1403
1404 if (res_emma && irq_emma >= 0) {
1405 dev_info(&pdev->dev, "Using EMMA\n");
1406 pcdev->use_emma = 1;
1407 pcdev->res_emma = res_emma;
1408 pcdev->irq_emma = irq_emma;
1409 if (mx27_camera_emma_init(pcdev))
1410 goto exit_free_irq;
1411 }
1412 }
1413
1414 pcdev->soc_host.drv_name = MX2_CAM_DRV_NAME,
1415 pcdev->soc_host.ops = &mx2_soc_camera_host_ops,
1416 pcdev->soc_host.priv = pcdev;
1417 pcdev->soc_host.v4l2_dev.dev = &pdev->dev;
1418 pcdev->soc_host.nr = pdev->id;
1419 err = soc_camera_host_register(&pcdev->soc_host);
1420 if (err)
1421 goto exit_free_emma;
1422
1423 return 0;
1424
1425exit_free_emma:
1426 if (mx27_camera_emma(pcdev)) {
1427 free_irq(pcdev->irq_emma, pcdev);
1428 clk_disable(pcdev->clk_emma);
1429 clk_put(pcdev->clk_emma);
1430 iounmap(pcdev->base_emma);
1431 release_mem_region(res_emma->start, resource_size(res_emma));
1432 }
1433exit_free_irq:
1434 free_irq(pcdev->irq_csi, pcdev);
1435exit_iounmap:
1436 iounmap(base_csi);
1437exit_release:
1438 release_mem_region(res_csi->start, resource_size(res_csi));
1439exit_dma_free:
1440#ifdef CONFIG_MACH_MX27
1441 if (cpu_is_mx27())
1442 imx_dma_free(pcdev->dma);
1443exit_clk_put:
1444 clk_put(pcdev->clk_csi);
1445#endif /* CONFIG_MACH_MX27 */
1446exit_kfree:
1447 kfree(pcdev);
1448exit:
1449 return err;
1450}
1451
1452static int __devexit mx2_camera_remove(struct platform_device *pdev)
1453{
1454 struct soc_camera_host *soc_host = to_soc_camera_host(&pdev->dev);
1455 struct mx2_camera_dev *pcdev = container_of(soc_host,
1456 struct mx2_camera_dev, soc_host);
1457 struct resource *res;
1458
1459 clk_put(pcdev->clk_csi);
1460#ifdef CONFIG_MACH_MX27
1461 if (cpu_is_mx27())
1462 imx_dma_free(pcdev->dma);
1463#endif /* CONFIG_MACH_MX27 */
1464 free_irq(pcdev->irq_csi, pcdev);
1465 if (mx27_camera_emma(pcdev))
1466 free_irq(pcdev->irq_emma, pcdev);
1467
1468 soc_camera_host_unregister(&pcdev->soc_host);
1469
1470 iounmap(pcdev->base_csi);
1471
1472 if (mx27_camera_emma(pcdev)) {
1473 clk_disable(pcdev->clk_emma);
1474 clk_put(pcdev->clk_emma);
1475 iounmap(pcdev->base_emma);
1476 res = pcdev->res_emma;
1477 release_mem_region(res->start, resource_size(res));
1478 }
1479
1480 res = pcdev->res_csi;
1481 release_mem_region(res->start, resource_size(res));
1482
1483 kfree(pcdev);
1484
1485 dev_info(&pdev->dev, "MX2 Camera driver unloaded\n");
1486
1487 return 0;
1488}
1489
1490static struct platform_driver mx2_camera_driver = {
1491 .driver = {
1492 .name = MX2_CAM_DRV_NAME,
1493 },
1494 .remove = __devexit_p(mx2_camera_remove),
1495};
1496
1497
1498static int __init mx2_camera_init(void)
1499{
1500 return platform_driver_probe(&mx2_camera_driver, &mx2_camera_probe);
1501}
1502
1503static void __exit mx2_camera_exit(void)
1504{
1505 return platform_driver_unregister(&mx2_camera_driver);
1506}
1507
1508module_init(mx2_camera_init);
1509module_exit(mx2_camera_exit);
1510
1511MODULE_DESCRIPTION("i.MX27/i.MX25 SoC Camera Host driver");
1512MODULE_AUTHOR("Sascha Hauer <sha@pengutronix.de>");
1513MODULE_LICENSE("GPL");
diff --git a/drivers/media/video/omap/Kconfig b/drivers/media/video/omap/Kconfig
index 97c53949ca89..e63233fd2aaa 100644
--- a/drivers/media/video/omap/Kconfig
+++ b/drivers/media/video/omap/Kconfig
@@ -1,8 +1,8 @@
1config VIDEO_OMAP2_VOUT 1config VIDEO_OMAP2_VOUT
2 tristate "OMAP2/OMAP3 V4L2-Display driver" 2 tristate "OMAP2/OMAP3 V4L2-Display driver"
3 depends on ARCH_OMAP24XX || ARCH_OMAP34XX 3 depends on ARCH_OMAP2 || ARCH_OMAP3
4 select VIDEOBUF_GEN 4 select VIDEOBUF_GEN
5 select VIDEOBUF_DMA_SG 5 select VIDEOBUF_DMA_CONTIG
6 select OMAP2_DSS 6 select OMAP2_DSS
7 select OMAP2_VRAM 7 select OMAP2_VRAM
8 select OMAP2_VRFB 8 select OMAP2_VRFB
diff --git a/drivers/media/video/omap/Makefile b/drivers/media/video/omap/Makefile
index b8bab00ad010..b28788070ae1 100644
--- a/drivers/media/video/omap/Makefile
+++ b/drivers/media/video/omap/Makefile
@@ -3,5 +3,5 @@
3# 3#
4 4
5# OMAP2/3 Display driver 5# OMAP2/3 Display driver
6omap-vout-mod-objs := omap_vout.o omap_voutlib.o 6omap-vout-y := omap_vout.o omap_voutlib.o
7obj-$(CONFIG_VIDEO_OMAP2_VOUT) += omap-vout-mod.o 7obj-$(CONFIG_VIDEO_OMAP2_VOUT) += omap-vout.o
diff --git a/drivers/media/video/omap/omap_vout.c b/drivers/media/video/omap/omap_vout.c
index e7db0554949a..929073e792c9 100644
--- a/drivers/media/video/omap/omap_vout.c
+++ b/drivers/media/video/omap/omap_vout.c
@@ -38,8 +38,9 @@
38#include <linux/dma-mapping.h> 38#include <linux/dma-mapping.h>
39#include <linux/irq.h> 39#include <linux/irq.h>
40#include <linux/videodev2.h> 40#include <linux/videodev2.h>
41#include <linux/slab.h>
41 42
42#include <media/videobuf-dma-sg.h> 43#include <media/videobuf-dma-contig.h>
43#include <media/v4l2-device.h> 44#include <media/v4l2-device.h>
44#include <media/v4l2-ioctl.h> 45#include <media/v4l2-ioctl.h>
45 46
@@ -1053,9 +1054,9 @@ static int omap_vout_buffer_prepare(struct videobuf_queue *q,
1053 struct videobuf_buffer *vb, 1054 struct videobuf_buffer *vb,
1054 enum v4l2_field field) 1055 enum v4l2_field field)
1055{ 1056{
1057 dma_addr_t dmabuf;
1056 struct vid_vrfb_dma *tx; 1058 struct vid_vrfb_dma *tx;
1057 enum dss_rotation rotation; 1059 enum dss_rotation rotation;
1058 struct videobuf_dmabuf *dmabuf = NULL;
1059 struct omap_vout_device *vout = q->priv_data; 1060 struct omap_vout_device *vout = q->priv_data;
1060 u32 dest_frame_index = 0, src_element_index = 0; 1061 u32 dest_frame_index = 0, src_element_index = 0;
1061 u32 dest_element_index = 0, src_frame_index = 0; 1062 u32 dest_element_index = 0, src_frame_index = 0;
@@ -1074,24 +1075,17 @@ static int omap_vout_buffer_prepare(struct videobuf_queue *q,
1074 if (V4L2_MEMORY_USERPTR == vb->memory) { 1075 if (V4L2_MEMORY_USERPTR == vb->memory) {
1075 if (0 == vb->baddr) 1076 if (0 == vb->baddr)
1076 return -EINVAL; 1077 return -EINVAL;
1077 /* Virtual address */
1078 /* priv points to struct videobuf_pci_sg_memory. But we went
1079 * pointer to videobuf_dmabuf, which is member of
1080 * videobuf_pci_sg_memory */
1081 dmabuf = videobuf_to_dma(q->bufs[vb->i]);
1082 dmabuf->vmalloc = (void *) vb->baddr;
1083
1084 /* Physical address */ 1078 /* Physical address */
1085 dmabuf->bus_addr = 1079 vout->queued_buf_addr[vb->i] = (u8 *)
1086 (dma_addr_t) omap_vout_uservirt_to_phys(vb->baddr); 1080 omap_vout_uservirt_to_phys(vb->baddr);
1081 } else {
1082 vout->queued_buf_addr[vb->i] = (u8 *)vout->buf_phy_addr[vb->i];
1087 } 1083 }
1088 1084
1089 if (!rotation_enabled(vout)) { 1085 if (!rotation_enabled(vout))
1090 dmabuf = videobuf_to_dma(q->bufs[vb->i]);
1091 vout->queued_buf_addr[vb->i] = (u8 *) dmabuf->bus_addr;
1092 return 0; 1086 return 0;
1093 } 1087
1094 dmabuf = videobuf_to_dma(q->bufs[vb->i]); 1088 dmabuf = vout->buf_phy_addr[vb->i];
1095 /* If rotation is enabled, copy input buffer into VRFB 1089 /* If rotation is enabled, copy input buffer into VRFB
1096 * memory space using DMA. We are copying input buffer 1090 * memory space using DMA. We are copying input buffer
1097 * into VRFB memory space of desired angle and DSS will 1091 * into VRFB memory space of desired angle and DSS will
@@ -1120,7 +1114,7 @@ static int omap_vout_buffer_prepare(struct videobuf_queue *q,
1120 tx->dev_id, 0x0); 1114 tx->dev_id, 0x0);
1121 /* src_port required only for OMAP1 */ 1115 /* src_port required only for OMAP1 */
1122 omap_set_dma_src_params(tx->dma_ch, 0, OMAP_DMA_AMODE_POST_INC, 1116 omap_set_dma_src_params(tx->dma_ch, 0, OMAP_DMA_AMODE_POST_INC,
1123 dmabuf->bus_addr, src_element_index, src_frame_index); 1117 dmabuf, src_element_index, src_frame_index);
1124 /*set dma source burst mode for VRFB */ 1118 /*set dma source burst mode for VRFB */
1125 omap_set_dma_src_burst_mode(tx->dma_ch, OMAP_DMA_DATA_BURST_16); 1119 omap_set_dma_src_burst_mode(tx->dma_ch, OMAP_DMA_DATA_BURST_16);
1126 rotation = calc_rotation(vout); 1120 rotation = calc_rotation(vout);
@@ -1211,7 +1205,6 @@ static int omap_vout_mmap(struct file *file, struct vm_area_struct *vma)
1211 void *pos; 1205 void *pos;
1212 unsigned long start = vma->vm_start; 1206 unsigned long start = vma->vm_start;
1213 unsigned long size = (vma->vm_end - vma->vm_start); 1207 unsigned long size = (vma->vm_end - vma->vm_start);
1214 struct videobuf_dmabuf *dmabuf = NULL;
1215 struct omap_vout_device *vout = file->private_data; 1208 struct omap_vout_device *vout = file->private_data;
1216 struct videobuf_queue *q = &vout->vbq; 1209 struct videobuf_queue *q = &vout->vbq;
1217 1210
@@ -1241,8 +1234,7 @@ static int omap_vout_mmap(struct file *file, struct vm_area_struct *vma)
1241 vma->vm_page_prot = pgprot_writecombine(vma->vm_page_prot); 1234 vma->vm_page_prot = pgprot_writecombine(vma->vm_page_prot);
1242 vma->vm_ops = &omap_vout_vm_ops; 1235 vma->vm_ops = &omap_vout_vm_ops;
1243 vma->vm_private_data = (void *) vout; 1236 vma->vm_private_data = (void *) vout;
1244 dmabuf = videobuf_to_dma(q->bufs[i]); 1237 pos = (void *)vout->buf_virt_addr[i];
1245 pos = dmabuf->vmalloc;
1246 vma->vm_pgoff = virt_to_phys((void *)pos) >> PAGE_SHIFT; 1238 vma->vm_pgoff = virt_to_phys((void *)pos) >> PAGE_SHIFT;
1247 while (size > 0) { 1239 while (size > 0) {
1248 unsigned long pfn; 1240 unsigned long pfn;
@@ -1347,8 +1339,8 @@ static int omap_vout_open(struct file *file)
1347 video_vbq_ops.buf_queue = omap_vout_buffer_queue; 1339 video_vbq_ops.buf_queue = omap_vout_buffer_queue;
1348 spin_lock_init(&vout->vbq_lock); 1340 spin_lock_init(&vout->vbq_lock);
1349 1341
1350 videobuf_queue_sg_init(q, &video_vbq_ops, NULL, &vout->vbq_lock, 1342 videobuf_queue_dma_contig_init(q, &video_vbq_ops, q->dev,
1351 vout->type, V4L2_FIELD_NONE, 1343 &vout->vbq_lock, vout->type, V4L2_FIELD_NONE,
1352 sizeof(struct videobuf_buffer), vout); 1344 sizeof(struct videobuf_buffer), vout);
1353 1345
1354 v4l2_dbg(1, debug, &vout->vid_dev->v4l2_dev, "Exiting %s\n", __func__); 1346 v4l2_dbg(1, debug, &vout->vid_dev->v4l2_dev, "Exiting %s\n", __func__);
@@ -1799,7 +1791,6 @@ static int vidioc_reqbufs(struct file *file, void *fh,
1799 unsigned int i, num_buffers = 0; 1791 unsigned int i, num_buffers = 0;
1800 struct omap_vout_device *vout = fh; 1792 struct omap_vout_device *vout = fh;
1801 struct videobuf_queue *q = &vout->vbq; 1793 struct videobuf_queue *q = &vout->vbq;
1802 struct videobuf_dmabuf *dmabuf = NULL;
1803 1794
1804 if ((req->type != V4L2_BUF_TYPE_VIDEO_OUTPUT) || (req->count < 0)) 1795 if ((req->type != V4L2_BUF_TYPE_VIDEO_OUTPUT) || (req->count < 0))
1805 return -EINVAL; 1796 return -EINVAL;
@@ -1825,8 +1816,7 @@ static int vidioc_reqbufs(struct file *file, void *fh,
1825 num_buffers = (vout->vid == OMAP_VIDEO1) ? 1816 num_buffers = (vout->vid == OMAP_VIDEO1) ?
1826 video1_numbuffers : video2_numbuffers; 1817 video1_numbuffers : video2_numbuffers;
1827 for (i = num_buffers; i < vout->buffer_allocated; i++) { 1818 for (i = num_buffers; i < vout->buffer_allocated; i++) {
1828 dmabuf = videobuf_to_dma(q->bufs[i]); 1819 omap_vout_free_buffer(vout->buf_virt_addr[i],
1829 omap_vout_free_buffer((u32)dmabuf->vmalloc,
1830 vout->buffer_size); 1820 vout->buffer_size);
1831 vout->buf_virt_addr[i] = 0; 1821 vout->buf_virt_addr[i] = 0;
1832 vout->buf_phy_addr[i] = 0; 1822 vout->buf_phy_addr[i] = 0;
@@ -1855,12 +1845,7 @@ static int vidioc_reqbufs(struct file *file, void *fh,
1855 goto reqbuf_err; 1845 goto reqbuf_err;
1856 1846
1857 vout->buffer_allocated = req->count; 1847 vout->buffer_allocated = req->count;
1858 for (i = 0; i < req->count; i++) { 1848
1859 dmabuf = videobuf_to_dma(q->bufs[i]);
1860 dmabuf->vmalloc = (void *) vout->buf_virt_addr[i];
1861 dmabuf->bus_addr = (dma_addr_t) vout->buf_phy_addr[i];
1862 dmabuf->sglen = 1;
1863 }
1864reqbuf_err: 1849reqbuf_err:
1865 mutex_unlock(&vout->lock); 1850 mutex_unlock(&vout->lock);
1866 return ret; 1851 return ret;
@@ -2488,7 +2473,7 @@ static int omap_vout_remove(struct platform_device *pdev)
2488 2473
2489 for (k = 0; k < vid_dev->num_displays; k++) { 2474 for (k = 0; k < vid_dev->num_displays; k++) {
2490 if (vid_dev->displays[k]->state != OMAP_DSS_DISPLAY_DISABLED) 2475 if (vid_dev->displays[k]->state != OMAP_DSS_DISPLAY_DISABLED)
2491 vid_dev->displays[k]->disable(vid_dev->displays[k]); 2476 vid_dev->displays[k]->driver->disable(vid_dev->displays[k]);
2492 2477
2493 omap_dss_put_device(vid_dev->displays[k]); 2478 omap_dss_put_device(vid_dev->displays[k]);
2494 } 2479 }
@@ -2545,7 +2530,9 @@ static int __init omap_vout_probe(struct platform_device *pdev)
2545 def_display = NULL; 2530 def_display = NULL;
2546 } 2531 }
2547 if (def_display) { 2532 if (def_display) {
2548 ret = def_display->enable(def_display); 2533 struct omap_dss_driver *dssdrv = def_display->driver;
2534
2535 ret = dssdrv->enable(def_display);
2549 if (ret) { 2536 if (ret) {
2550 /* Here we are not considering a error 2537 /* Here we are not considering a error
2551 * as display may be enabled by frame 2538 * as display may be enabled by frame
@@ -2559,21 +2546,21 @@ static int __init omap_vout_probe(struct platform_device *pdev)
2559 if (def_display->caps & 2546 if (def_display->caps &
2560 OMAP_DSS_DISPLAY_CAP_MANUAL_UPDATE) { 2547 OMAP_DSS_DISPLAY_CAP_MANUAL_UPDATE) {
2561#ifdef CONFIG_FB_OMAP2_FORCE_AUTO_UPDATE 2548#ifdef CONFIG_FB_OMAP2_FORCE_AUTO_UPDATE
2562 if (def_display->enable_te) 2549 if (dssdrv->enable_te)
2563 def_display->enable_te(def_display, 1); 2550 dssdrv->enable_te(def_display, 1);
2564 if (def_display->set_update_mode) 2551 if (dssdrv->set_update_mode)
2565 def_display->set_update_mode(def_display, 2552 dssdrv->set_update_mode(def_display,
2566 OMAP_DSS_UPDATE_AUTO); 2553 OMAP_DSS_UPDATE_AUTO);
2567#else /* MANUAL_UPDATE */ 2554#else /* MANUAL_UPDATE */
2568 if (def_display->enable_te) 2555 if (dssdrv->enable_te)
2569 def_display->enable_te(def_display, 0); 2556 dssdrv->enable_te(def_display, 0);
2570 if (def_display->set_update_mode) 2557 if (dssdrv->set_update_mode)
2571 def_display->set_update_mode(def_display, 2558 dssdrv->set_update_mode(def_display,
2572 OMAP_DSS_UPDATE_MANUAL); 2559 OMAP_DSS_UPDATE_MANUAL);
2573#endif 2560#endif
2574 } else { 2561 } else {
2575 if (def_display->set_update_mode) 2562 if (dssdrv->set_update_mode)
2576 def_display->set_update_mode(def_display, 2563 dssdrv->set_update_mode(def_display,
2577 OMAP_DSS_UPDATE_AUTO); 2564 OMAP_DSS_UPDATE_AUTO);
2578 } 2565 }
2579 } 2566 }
@@ -2592,8 +2579,8 @@ static int __init omap_vout_probe(struct platform_device *pdev)
2592 for (i = 0; i < vid_dev->num_displays; i++) { 2579 for (i = 0; i < vid_dev->num_displays; i++) {
2593 struct omap_dss_device *display = vid_dev->displays[i]; 2580 struct omap_dss_device *display = vid_dev->displays[i];
2594 2581
2595 if (display->update) 2582 if (display->driver->update)
2596 display->update(display, 0, 0, 2583 display->driver->update(display, 0, 0,
2597 display->panel.timings.x_res, 2584 display->panel.timings.x_res,
2598 display->panel.timings.y_res); 2585 display->panel.timings.y_res);
2599 } 2586 }
@@ -2608,8 +2595,8 @@ probe_err1:
2608 if (ovl->manager && ovl->manager->device) 2595 if (ovl->manager && ovl->manager->device)
2609 def_display = ovl->manager->device; 2596 def_display = ovl->manager->device;
2610 2597
2611 if (def_display) 2598 if (def_display && def_display->driver)
2612 def_display->disable(def_display); 2599 def_display->driver->disable(def_display);
2613 } 2600 }
2614probe_err0: 2601probe_err0:
2615 kfree(vid_dev); 2602 kfree(vid_dev);
diff --git a/drivers/media/video/tveeprom.c b/drivers/media/video/tveeprom.c
index 0a877497b93f..07fabdd9b465 100644
--- a/drivers/media/video/tveeprom.c
+++ b/drivers/media/video/tveeprom.c
@@ -267,6 +267,21 @@ hauppauge_tuner[] =
267 { TUNER_ABSENT, "Xceive XC4000"}, 267 { TUNER_ABSENT, "Xceive XC4000"},
268 { TUNER_ABSENT, "Dibcom 7070"}, 268 { TUNER_ABSENT, "Dibcom 7070"},
269 { TUNER_PHILIPS_TDA8290, "NXP 18271C2"}, 269 { TUNER_PHILIPS_TDA8290, "NXP 18271C2"},
270 { TUNER_ABSENT, "unknown"},
271 { TUNER_ABSENT, "unknown"},
272 { TUNER_ABSENT, "unknown"},
273 { TUNER_ABSENT, "unknown"},
274 /* 160-169 */
275 { TUNER_ABSENT, "unknown"},
276 { TUNER_ABSENT, "unknown"},
277 { TUNER_ABSENT, "unknown"},
278 { TUNER_ABSENT, "unknown"},
279 { TUNER_ABSENT, "unknown"},
280 { TUNER_ABSENT, "unknown"},
281 { TUNER_ABSENT, "unknown"},
282 { TUNER_ABSENT, "unknown"},
283 { TUNER_PHILIPS_FQ1236_MK5, "TCL M30WTP-4N-E"},
284 { TUNER_ABSENT, "unknown"},
270}; 285};
271 286
272/* Use V4L2_IDENT_AMBIGUOUS for those audio 'chips' that are 287/* Use V4L2_IDENT_AMBIGUOUS for those audio 'chips' that are
diff --git a/drivers/media/video/uvc/uvc_ctrl.c b/drivers/media/video/uvc/uvc_ctrl.c
index aa0720af07a0..27a79f087b15 100644
--- a/drivers/media/video/uvc/uvc_ctrl.c
+++ b/drivers/media/video/uvc/uvc_ctrl.c
@@ -122,8 +122,8 @@ static struct uvc_control_info uvc_ctrls[] = {
122 .selector = UVC_PU_POWER_LINE_FREQUENCY_CONTROL, 122 .selector = UVC_PU_POWER_LINE_FREQUENCY_CONTROL,
123 .index = 10, 123 .index = 10,
124 .size = 1, 124 .size = 1,
125 .flags = UVC_CONTROL_SET_CUR | UVC_CONTROL_GET_RANGE 125 .flags = UVC_CONTROL_SET_CUR | UVC_CONTROL_GET_CUR
126 | UVC_CONTROL_RESTORE, 126 | UVC_CONTROL_GET_DEF | UVC_CONTROL_RESTORE,
127 }, 127 },
128 { 128 {
129 .entity = UVC_GUID_UVC_PROCESSING, 129 .entity = UVC_GUID_UVC_PROCESSING,
diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig
index 26386a92f5aa..9b089dfb173e 100644
--- a/drivers/misc/Kconfig
+++ b/drivers/misc/Kconfig
@@ -353,6 +353,16 @@ config VMWARE_BALLOON
353 To compile this driver as a module, choose M here: the 353 To compile this driver as a module, choose M here: the
354 module will be called vmware_balloon. 354 module will be called vmware_balloon.
355 355
356config ARM_CHARLCD
357 bool "ARM Ltd. Character LCD Driver"
358 depends on PLAT_VERSATILE
359 help
360 This is a driver for the character LCD found on the ARM Ltd.
361 Versatile and RealView Platform Baseboards. It doesn't do
362 very much more than display the text "ARM Linux" on the first
363 line and the Linux version on the second line, but that's
364 still useful.
365
356source "drivers/misc/c2port/Kconfig" 366source "drivers/misc/c2port/Kconfig"
357source "drivers/misc/eeprom/Kconfig" 367source "drivers/misc/eeprom/Kconfig"
358source "drivers/misc/cb710/Kconfig" 368source "drivers/misc/cb710/Kconfig"
diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile
index 6ed06a19474a..67552d6e9327 100644
--- a/drivers/misc/Makefile
+++ b/drivers/misc/Makefile
@@ -31,3 +31,4 @@ obj-$(CONFIG_IWMC3200TOP) += iwmc3200top/
31obj-y += eeprom/ 31obj-y += eeprom/
32obj-y += cb710/ 32obj-y += cb710/
33obj-$(CONFIG_VMWARE_BALLOON) += vmware_balloon.o 33obj-$(CONFIG_VMWARE_BALLOON) += vmware_balloon.o
34obj-$(CONFIG_ARM_CHARLCD) += arm-charlcd.o
diff --git a/drivers/misc/arm-charlcd.c b/drivers/misc/arm-charlcd.c
new file mode 100644
index 000000000000..9e3879ef58f2
--- /dev/null
+++ b/drivers/misc/arm-charlcd.c
@@ -0,0 +1,396 @@
1/*
2 * Driver for the on-board character LCD found on some ARM reference boards
3 * This is basically an Hitachi HD44780 LCD with a custom IP block to drive it
4 * http://en.wikipedia.org/wiki/HD44780_Character_LCD
5 * Currently it will just display the text "ARM Linux" and the linux version
6 *
7 * License terms: GNU General Public License (GPL) version 2
8 * Author: Linus Walleij <triad@df.lth.se>
9 */
10#include <linux/init.h>
11#include <linux/module.h>
12#include <linux/interrupt.h>
13#include <linux/platform_device.h>
14#include <linux/completion.h>
15#include <linux/delay.h>
16#include <linux/io.h>
17#include <linux/slab.h>
18#include <linux/workqueue.h>
19#include <generated/utsrelease.h>
20
21#define DRIVERNAME "arm-charlcd"
22#define CHARLCD_TIMEOUT (msecs_to_jiffies(1000))
23
24/* Offsets to registers */
25#define CHAR_COM 0x00U
26#define CHAR_DAT 0x04U
27#define CHAR_RD 0x08U
28#define CHAR_RAW 0x0CU
29#define CHAR_MASK 0x10U
30#define CHAR_STAT 0x14U
31
32#define CHAR_RAW_CLEAR 0x00000000U
33#define CHAR_RAW_VALID 0x00000100U
34
35/* Hitachi HD44780 display commands */
36#define HD_CLEAR 0x01U
37#define HD_HOME 0x02U
38#define HD_ENTRYMODE 0x04U
39#define HD_ENTRYMODE_INCREMENT 0x02U
40#define HD_ENTRYMODE_SHIFT 0x01U
41#define HD_DISPCTRL 0x08U
42#define HD_DISPCTRL_ON 0x04U
43#define HD_DISPCTRL_CURSOR_ON 0x02U
44#define HD_DISPCTRL_CURSOR_BLINK 0x01U
45#define HD_CRSR_SHIFT 0x10U
46#define HD_CRSR_SHIFT_DISPLAY 0x08U
47#define HD_CRSR_SHIFT_DISPLAY_RIGHT 0x04U
48#define HD_FUNCSET 0x20U
49#define HD_FUNCSET_8BIT 0x10U
50#define HD_FUNCSET_2_LINES 0x08U
51#define HD_FUNCSET_FONT_5X10 0x04U
52#define HD_SET_CGRAM 0x40U
53#define HD_SET_DDRAM 0x80U
54#define HD_BUSY_FLAG 0x80U
55
56/**
57 * @dev: a pointer back to containing device
58 * @phybase: the offset to the controller in physical memory
59 * @physize: the size of the physical page
60 * @virtbase: the offset to the controller in virtual memory
61 * @irq: reserved interrupt number
62 * @complete: completion structure for the last LCD command
63 */
64struct charlcd {
65 struct device *dev;
66 u32 phybase;
67 u32 physize;
68 void __iomem *virtbase;
69 int irq;
70 struct completion complete;
71 struct delayed_work init_work;
72};
73
74static irqreturn_t charlcd_interrupt(int irq, void *data)
75{
76 struct charlcd *lcd = data;
77 u8 status;
78
79 status = readl(lcd->virtbase + CHAR_STAT) & 0x01;
80 /* Clear IRQ */
81 writel(CHAR_RAW_CLEAR, lcd->virtbase + CHAR_RAW);
82 if (status)
83 complete(&lcd->complete);
84 else
85 dev_info(lcd->dev, "Spurious IRQ (%02x)\n", status);
86 return IRQ_HANDLED;
87}
88
89
90static void charlcd_wait_complete_irq(struct charlcd *lcd)
91{
92 int ret;
93
94 ret = wait_for_completion_interruptible_timeout(&lcd->complete,
95 CHARLCD_TIMEOUT);
96 /* Disable IRQ after completion */
97 writel(0x00, lcd->virtbase + CHAR_MASK);
98
99 if (ret < 0) {
100 dev_err(lcd->dev,
101 "wait_for_completion_interruptible_timeout() "
102 "returned %d waiting for ready\n", ret);
103 return;
104 }
105
106 if (ret == 0) {
107 dev_err(lcd->dev, "charlcd controller timed out "
108 "waiting for ready\n");
109 return;
110 }
111}
112
113static u8 charlcd_4bit_read_char(struct charlcd *lcd)
114{
115 u8 data;
116 u32 val;
117 int i;
118
119 /* If we can, use an IRQ to wait for the data, else poll */
120 if (lcd->irq >= 0)
121 charlcd_wait_complete_irq(lcd);
122 else {
123 i = 0;
124 val = 0;
125 while (!(val & CHAR_RAW_VALID) && i < 10) {
126 udelay(100);
127 val = readl(lcd->virtbase + CHAR_RAW);
128 i++;
129 }
130
131 writel(CHAR_RAW_CLEAR, lcd->virtbase + CHAR_RAW);
132 }
133 msleep(1);
134
135 /* Read the 4 high bits of the data */
136 data = readl(lcd->virtbase + CHAR_RD) & 0xf0;
137
138 /*
139 * The second read for the low bits does not trigger an IRQ
140 * so in this case we have to poll for the 4 lower bits
141 */
142 i = 0;
143 val = 0;
144 while (!(val & CHAR_RAW_VALID) && i < 10) {
145 udelay(100);
146 val = readl(lcd->virtbase + CHAR_RAW);
147 i++;
148 }
149 writel(CHAR_RAW_CLEAR, lcd->virtbase + CHAR_RAW);
150 msleep(1);
151
152 /* Read the 4 low bits of the data */
153 data |= (readl(lcd->virtbase + CHAR_RD) >> 4) & 0x0f;
154
155 return data;
156}
157
158static bool charlcd_4bit_read_bf(struct charlcd *lcd)
159{
160 if (lcd->irq >= 0) {
161 /*
162 * If we'll use IRQs to wait for the busyflag, clear any
163 * pending flag and enable IRQ
164 */
165 writel(CHAR_RAW_CLEAR, lcd->virtbase + CHAR_RAW);
166 init_completion(&lcd->complete);
167 writel(0x01, lcd->virtbase + CHAR_MASK);
168 }
169 readl(lcd->virtbase + CHAR_COM);
170 return charlcd_4bit_read_char(lcd) & HD_BUSY_FLAG ? true : false;
171}
172
173static void charlcd_4bit_wait_busy(struct charlcd *lcd)
174{
175 int retries = 50;
176
177 udelay(100);
178 while (charlcd_4bit_read_bf(lcd) && retries)
179 retries--;
180 if (!retries)
181 dev_err(lcd->dev, "timeout waiting for busyflag\n");
182}
183
184static void charlcd_4bit_command(struct charlcd *lcd, u8 cmd)
185{
186 u32 cmdlo = (cmd << 4) & 0xf0;
187 u32 cmdhi = (cmd & 0xf0);
188
189 writel(cmdhi, lcd->virtbase + CHAR_COM);
190 udelay(10);
191 writel(cmdlo, lcd->virtbase + CHAR_COM);
192 charlcd_4bit_wait_busy(lcd);
193}
194
195static void charlcd_4bit_char(struct charlcd *lcd, u8 ch)
196{
197 u32 chlo = (ch << 4) & 0xf0;
198 u32 chhi = (ch & 0xf0);
199
200 writel(chhi, lcd->virtbase + CHAR_DAT);
201 udelay(10);
202 writel(chlo, lcd->virtbase + CHAR_DAT);
203 charlcd_4bit_wait_busy(lcd);
204}
205
206static void charlcd_4bit_print(struct charlcd *lcd, int line, const char *str)
207{
208 u8 offset;
209 int i;
210
211 /*
212 * We support line 0, 1
213 * Line 1 runs from 0x00..0x27
214 * Line 2 runs from 0x28..0x4f
215 */
216 if (line == 0)
217 offset = 0;
218 else if (line == 1)
219 offset = 0x28;
220 else
221 return;
222
223 /* Set offset */
224 charlcd_4bit_command(lcd, HD_SET_DDRAM | offset);
225
226 /* Send string */
227 for (i = 0; i < strlen(str) && i < 0x28; i++)
228 charlcd_4bit_char(lcd, str[i]);
229}
230
231static void charlcd_4bit_init(struct charlcd *lcd)
232{
233 /* These commands cannot be checked with the busy flag */
234 writel(HD_FUNCSET | HD_FUNCSET_8BIT, lcd->virtbase + CHAR_COM);
235 msleep(5);
236 writel(HD_FUNCSET | HD_FUNCSET_8BIT, lcd->virtbase + CHAR_COM);
237 udelay(100);
238 writel(HD_FUNCSET | HD_FUNCSET_8BIT, lcd->virtbase + CHAR_COM);
239 udelay(100);
240 /* Go to 4bit mode */
241 writel(HD_FUNCSET, lcd->virtbase + CHAR_COM);
242 udelay(100);
243 /*
244 * 4bit mode, 2 lines, 5x8 font, after this the number of lines
245 * and the font cannot be changed until the next initialization sequence
246 */
247 charlcd_4bit_command(lcd, HD_FUNCSET | HD_FUNCSET_2_LINES);
248 charlcd_4bit_command(lcd, HD_DISPCTRL | HD_DISPCTRL_ON);
249 charlcd_4bit_command(lcd, HD_ENTRYMODE | HD_ENTRYMODE_INCREMENT);
250 charlcd_4bit_command(lcd, HD_CLEAR);
251 charlcd_4bit_command(lcd, HD_HOME);
252 /* Put something useful in the display */
253 charlcd_4bit_print(lcd, 0, "ARM Linux");
254 charlcd_4bit_print(lcd, 1, UTS_RELEASE);
255}
256
257static void charlcd_init_work(struct work_struct *work)
258{
259 struct charlcd *lcd =
260 container_of(work, struct charlcd, init_work.work);
261
262 charlcd_4bit_init(lcd);
263}
264
265static int __init charlcd_probe(struct platform_device *pdev)
266{
267 int ret;
268 struct charlcd *lcd;
269 struct resource *res;
270
271 lcd = kzalloc(sizeof(struct charlcd), GFP_KERNEL);
272 if (!lcd)
273 return -ENOMEM;
274
275 lcd->dev = &pdev->dev;
276
277 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
278 if (!res) {
279 ret = -ENOENT;
280 goto out_no_resource;
281 }
282 lcd->phybase = res->start;
283 lcd->physize = resource_size(res);
284
285 if (request_mem_region(lcd->phybase, lcd->physize,
286 DRIVERNAME) == NULL) {
287 ret = -EBUSY;
288 goto out_no_memregion;
289 }
290
291 lcd->virtbase = ioremap(lcd->phybase, lcd->physize);
292 if (!lcd->virtbase) {
293 ret = -ENOMEM;
294 goto out_no_remap;
295 }
296
297 lcd->irq = platform_get_irq(pdev, 0);
298 /* If no IRQ is supplied, we'll survive without it */
299 if (lcd->irq >= 0) {
300 if (request_irq(lcd->irq, charlcd_interrupt, IRQF_DISABLED,
301 DRIVERNAME, lcd)) {
302 ret = -EIO;
303 goto out_no_irq;
304 }
305 }
306
307 platform_set_drvdata(pdev, lcd);
308
309 /*
310 * Initialize the display in a delayed work, because
311 * it is VERY slow and would slow down the boot of the system.
312 */
313 INIT_DELAYED_WORK(&lcd->init_work, charlcd_init_work);
314 schedule_delayed_work(&lcd->init_work, 0);
315
316 dev_info(&pdev->dev, "initalized ARM character LCD at %08x\n",
317 lcd->phybase);
318
319 return 0;
320
321out_no_irq:
322 iounmap(lcd->virtbase);
323out_no_remap:
324 platform_set_drvdata(pdev, NULL);
325out_no_memregion:
326 release_mem_region(lcd->phybase, SZ_4K);
327out_no_resource:
328 kfree(lcd);
329 return ret;
330}
331
332static int __exit charlcd_remove(struct platform_device *pdev)
333{
334 struct charlcd *lcd = platform_get_drvdata(pdev);
335
336 if (lcd) {
337 free_irq(lcd->irq, lcd);
338 iounmap(lcd->virtbase);
339 release_mem_region(lcd->phybase, lcd->physize);
340 platform_set_drvdata(pdev, NULL);
341 kfree(lcd);
342 }
343
344 return 0;
345}
346
347static int charlcd_suspend(struct device *dev)
348{
349 struct platform_device *pdev = to_platform_device(dev);
350 struct charlcd *lcd = platform_get_drvdata(pdev);
351
352 /* Power the display off */
353 charlcd_4bit_command(lcd, HD_DISPCTRL);
354 return 0;
355}
356
357static int charlcd_resume(struct device *dev)
358{
359 struct platform_device *pdev = to_platform_device(dev);
360 struct charlcd *lcd = platform_get_drvdata(pdev);
361
362 /* Turn the display back on */
363 charlcd_4bit_command(lcd, HD_DISPCTRL | HD_DISPCTRL_ON);
364 return 0;
365}
366
367static const struct dev_pm_ops charlcd_pm_ops = {
368 .suspend = charlcd_suspend,
369 .resume = charlcd_resume,
370};
371
372static struct platform_driver charlcd_driver = {
373 .driver = {
374 .name = DRIVERNAME,
375 .owner = THIS_MODULE,
376 .pm = &charlcd_pm_ops,
377 },
378 .remove = __exit_p(charlcd_remove),
379};
380
381static int __init charlcd_init(void)
382{
383 return platform_driver_probe(&charlcd_driver, charlcd_probe);
384}
385
386static void __exit charlcd_exit(void)
387{
388 platform_driver_unregister(&charlcd_driver);
389}
390
391module_init(charlcd_init);
392module_exit(charlcd_exit);
393
394MODULE_AUTHOR("Linus Walleij <triad@df.lth.se>");
395MODULE_DESCRIPTION("ARM Character LCD Driver");
396MODULE_LICENSE("GPL v2");
diff --git a/drivers/misc/cs5535-mfgpt.c b/drivers/misc/cs5535-mfgpt.c
index 9bec24db4d41..2d44b3300104 100644
--- a/drivers/misc/cs5535-mfgpt.c
+++ b/drivers/misc/cs5535-mfgpt.c
@@ -366,6 +366,6 @@ static int __init cs5535_mfgpt_init(void)
366 366
367module_init(cs5535_mfgpt_init); 367module_init(cs5535_mfgpt_init);
368 368
369MODULE_AUTHOR("Andres Salomon <dilinger@collabora.co.uk>"); 369MODULE_AUTHOR("Andres Salomon <dilinger@queued.net>");
370MODULE_DESCRIPTION("CS5535/CS5536 MFGPT timer driver"); 370MODULE_DESCRIPTION("CS5535/CS5536 MFGPT timer driver");
371MODULE_LICENSE("GPL"); 371MODULE_LICENSE("GPL");
diff --git a/drivers/mmc/host/mmci.c b/drivers/mmc/host/mmci.c
index 4917af96bae1..840b301b5671 100644
--- a/drivers/mmc/host/mmci.c
+++ b/drivers/mmc/host/mmci.c
@@ -26,7 +26,6 @@
26#include <linux/amba/mmci.h> 26#include <linux/amba/mmci.h>
27#include <linux/regulator/consumer.h> 27#include <linux/regulator/consumer.h>
28 28
29#include <asm/cacheflush.h>
30#include <asm/div64.h> 29#include <asm/div64.h>
31#include <asm/io.h> 30#include <asm/io.h>
32#include <asm/sizes.h> 31#include <asm/sizes.h>
@@ -37,12 +36,39 @@
37 36
38static unsigned int fmax = 515633; 37static unsigned int fmax = 515633;
39 38
39/**
40 * struct variant_data - MMCI variant-specific quirks
41 * @clkreg: default value for MCICLOCK register
42 * @clkreg_enable: enable value for MMCICLOCK register
43 * @datalength_bits: number of bits in the MMCIDATALENGTH register
44 */
45struct variant_data {
46 unsigned int clkreg;
47 unsigned int clkreg_enable;
48 unsigned int datalength_bits;
49};
50
51static struct variant_data variant_arm = {
52 .datalength_bits = 16,
53};
54
55static struct variant_data variant_u300 = {
56 .clkreg_enable = 1 << 13, /* HWFCEN */
57 .datalength_bits = 16,
58};
59
60static struct variant_data variant_ux500 = {
61 .clkreg = MCI_CLK_ENABLE,
62 .clkreg_enable = 1 << 14, /* HWFCEN */
63 .datalength_bits = 24,
64};
40/* 65/*
41 * This must be called with host->lock held 66 * This must be called with host->lock held
42 */ 67 */
43static void mmci_set_clkreg(struct mmci_host *host, unsigned int desired) 68static void mmci_set_clkreg(struct mmci_host *host, unsigned int desired)
44{ 69{
45 u32 clk = 0; 70 struct variant_data *variant = host->variant;
71 u32 clk = variant->clkreg;
46 72
47 if (desired) { 73 if (desired) {
48 if (desired >= host->mclk) { 74 if (desired >= host->mclk) {
@@ -54,8 +80,8 @@ static void mmci_set_clkreg(struct mmci_host *host, unsigned int desired)
54 clk = 255; 80 clk = 255;
55 host->cclk = host->mclk / (2 * (clk + 1)); 81 host->cclk = host->mclk / (2 * (clk + 1));
56 } 82 }
57 if (host->hw_designer == AMBA_VENDOR_ST) 83
58 clk |= MCI_ST_FCEN; /* Bug fix in ST IP block */ 84 clk |= variant->clkreg_enable;
59 clk |= MCI_CLK_ENABLE; 85 clk |= MCI_CLK_ENABLE;
60 /* This hasn't proven to be worthwhile */ 86 /* This hasn't proven to be worthwhile */
61 /* clk |= MCI_CLK_PWRSAVE; */ 87 /* clk |= MCI_CLK_PWRSAVE; */
@@ -98,6 +124,18 @@ static void mmci_stop_data(struct mmci_host *host)
98 host->data = NULL; 124 host->data = NULL;
99} 125}
100 126
127static void mmci_init_sg(struct mmci_host *host, struct mmc_data *data)
128{
129 unsigned int flags = SG_MITER_ATOMIC;
130
131 if (data->flags & MMC_DATA_READ)
132 flags |= SG_MITER_TO_SG;
133 else
134 flags |= SG_MITER_FROM_SG;
135
136 sg_miter_start(&host->sg_miter, data->sg, data->sg_len, flags);
137}
138
101static void mmci_start_data(struct mmci_host *host, struct mmc_data *data) 139static void mmci_start_data(struct mmci_host *host, struct mmc_data *data)
102{ 140{
103 unsigned int datactrl, timeout, irqmask; 141 unsigned int datactrl, timeout, irqmask;
@@ -109,7 +147,7 @@ static void mmci_start_data(struct mmci_host *host, struct mmc_data *data)
109 data->blksz, data->blocks, data->flags); 147 data->blksz, data->blocks, data->flags);
110 148
111 host->data = data; 149 host->data = data;
112 host->size = data->blksz; 150 host->size = data->blksz * data->blocks;
113 host->data_xfered = 0; 151 host->data_xfered = 0;
114 152
115 mmci_init_sg(host, data); 153 mmci_init_sg(host, data);
@@ -210,8 +248,17 @@ mmci_data_irq(struct mmci_host *host, struct mmc_data *data,
210 * We hit an error condition. Ensure that any data 248 * We hit an error condition. Ensure that any data
211 * partially written to a page is properly coherent. 249 * partially written to a page is properly coherent.
212 */ 250 */
213 if (host->sg_len && data->flags & MMC_DATA_READ) 251 if (data->flags & MMC_DATA_READ) {
214 flush_dcache_page(sg_page(host->sg_ptr)); 252 struct sg_mapping_iter *sg_miter = &host->sg_miter;
253 unsigned long flags;
254
255 local_irq_save(flags);
256 if (sg_miter_next(sg_miter)) {
257 flush_dcache_page(sg_miter->page);
258 sg_miter_stop(sg_miter);
259 }
260 local_irq_restore(flags);
261 }
215 } 262 }
216 if (status & MCI_DATAEND) { 263 if (status & MCI_DATAEND) {
217 mmci_stop_data(host); 264 mmci_stop_data(host);
@@ -314,15 +361,18 @@ static int mmci_pio_write(struct mmci_host *host, char *buffer, unsigned int rem
314static irqreturn_t mmci_pio_irq(int irq, void *dev_id) 361static irqreturn_t mmci_pio_irq(int irq, void *dev_id)
315{ 362{
316 struct mmci_host *host = dev_id; 363 struct mmci_host *host = dev_id;
364 struct sg_mapping_iter *sg_miter = &host->sg_miter;
317 void __iomem *base = host->base; 365 void __iomem *base = host->base;
366 unsigned long flags;
318 u32 status; 367 u32 status;
319 368
320 status = readl(base + MMCISTATUS); 369 status = readl(base + MMCISTATUS);
321 370
322 dev_dbg(mmc_dev(host->mmc), "irq1 (pio) %08x\n", status); 371 dev_dbg(mmc_dev(host->mmc), "irq1 (pio) %08x\n", status);
323 372
373 local_irq_save(flags);
374
324 do { 375 do {
325 unsigned long flags;
326 unsigned int remain, len; 376 unsigned int remain, len;
327 char *buffer; 377 char *buffer;
328 378
@@ -336,11 +386,11 @@ static irqreturn_t mmci_pio_irq(int irq, void *dev_id)
336 if (!(status & (MCI_TXFIFOHALFEMPTY|MCI_RXDATAAVLBL))) 386 if (!(status & (MCI_TXFIFOHALFEMPTY|MCI_RXDATAAVLBL)))
337 break; 387 break;
338 388
339 /* 389 if (!sg_miter_next(sg_miter))
340 * Map the current scatter buffer. 390 break;
341 */ 391
342 buffer = mmci_kmap_atomic(host, &flags) + host->sg_off; 392 buffer = sg_miter->addr;
343 remain = host->sg_ptr->length - host->sg_off; 393 remain = sg_miter->length;
344 394
345 len = 0; 395 len = 0;
346 if (status & MCI_RXACTIVE) 396 if (status & MCI_RXACTIVE)
@@ -348,31 +398,24 @@ static irqreturn_t mmci_pio_irq(int irq, void *dev_id)
348 if (status & MCI_TXACTIVE) 398 if (status & MCI_TXACTIVE)
349 len = mmci_pio_write(host, buffer, remain, status); 399 len = mmci_pio_write(host, buffer, remain, status);
350 400
351 /* 401 sg_miter->consumed = len;
352 * Unmap the buffer.
353 */
354 mmci_kunmap_atomic(host, buffer, &flags);
355 402
356 host->sg_off += len;
357 host->size -= len; 403 host->size -= len;
358 remain -= len; 404 remain -= len;
359 405
360 if (remain) 406 if (remain)
361 break; 407 break;
362 408
363 /*
364 * If we were reading, and we have completed this
365 * page, ensure that the data cache is coherent.
366 */
367 if (status & MCI_RXACTIVE) 409 if (status & MCI_RXACTIVE)
368 flush_dcache_page(sg_page(host->sg_ptr)); 410 flush_dcache_page(sg_miter->page);
369
370 if (!mmci_next_sg(host))
371 break;
372 411
373 status = readl(base + MMCISTATUS); 412 status = readl(base + MMCISTATUS);
374 } while (1); 413 } while (1);
375 414
415 sg_miter_stop(sg_miter);
416
417 local_irq_restore(flags);
418
376 /* 419 /*
377 * If we're nearing the end of the read, switch to 420 * If we're nearing the end of the read, switch to
378 * "any data available" mode. 421 * "any data available" mode.
@@ -477,16 +520,9 @@ static void mmci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
477 /* This implicitly enables the regulator */ 520 /* This implicitly enables the regulator */
478 mmc_regulator_set_ocr(host->vcc, ios->vdd); 521 mmc_regulator_set_ocr(host->vcc, ios->vdd);
479#endif 522#endif
480 /* 523 if (host->plat->vdd_handler)
481 * The translate_vdd function is not used if you have 524 pwr |= host->plat->vdd_handler(mmc_dev(mmc), ios->vdd,
482 * an external regulator, or your design is really weird. 525 ios->power_mode);
483 * Using it would mean sending in power control BOTH using
484 * a regulator AND the 4 MMCIPWR bits. If we don't have
485 * a regulator, we might have some other platform specific
486 * power control behind this translate function.
487 */
488 if (!host->vcc && host->plat->translate_vdd)
489 pwr |= host->plat->translate_vdd(mmc_dev(mmc), ios->vdd);
490 /* The ST version does not have this, fall through to POWER_ON */ 526 /* The ST version does not have this, fall through to POWER_ON */
491 if (host->hw_designer != AMBA_VENDOR_ST) { 527 if (host->hw_designer != AMBA_VENDOR_ST) {
492 pwr |= MCI_PWR_UP; 528 pwr |= MCI_PWR_UP;
@@ -539,9 +575,13 @@ static int mmci_get_cd(struct mmc_host *mmc)
539 if (host->gpio_cd == -ENOSYS) 575 if (host->gpio_cd == -ENOSYS)
540 status = host->plat->status(mmc_dev(host->mmc)); 576 status = host->plat->status(mmc_dev(host->mmc));
541 else 577 else
542 status = gpio_get_value(host->gpio_cd); 578 status = !gpio_get_value(host->gpio_cd);
543 579
544 return !status; 580 /*
581 * Use positive logic throughout - status is zero for no card,
582 * non-zero for card inserted.
583 */
584 return status;
545} 585}
546 586
547static const struct mmc_host_ops mmci_ops = { 587static const struct mmc_host_ops mmci_ops = {
@@ -551,21 +591,10 @@ static const struct mmc_host_ops mmci_ops = {
551 .get_cd = mmci_get_cd, 591 .get_cd = mmci_get_cd,
552}; 592};
553 593
554static void mmci_check_status(unsigned long data)
555{
556 struct mmci_host *host = (struct mmci_host *)data;
557 unsigned int status = mmci_get_cd(host->mmc);
558
559 if (status ^ host->oldstat)
560 mmc_detect_change(host->mmc, 0);
561
562 host->oldstat = status;
563 mod_timer(&host->timer, jiffies + HZ);
564}
565
566static int __devinit mmci_probe(struct amba_device *dev, struct amba_id *id) 594static int __devinit mmci_probe(struct amba_device *dev, struct amba_id *id)
567{ 595{
568 struct mmci_platform_data *plat = dev->dev.platform_data; 596 struct mmci_platform_data *plat = dev->dev.platform_data;
597 struct variant_data *variant = id->data;
569 struct mmci_host *host; 598 struct mmci_host *host;
570 struct mmc_host *mmc; 599 struct mmc_host *mmc;
571 int ret; 600 int ret;
@@ -609,6 +638,7 @@ static int __devinit mmci_probe(struct amba_device *dev, struct amba_id *id)
609 goto clk_free; 638 goto clk_free;
610 639
611 host->plat = plat; 640 host->plat = plat;
641 host->variant = variant;
612 host->mclk = clk_get_rate(host->clk); 642 host->mclk = clk_get_rate(host->clk);
613 /* 643 /*
614 * According to the spec, mclk is max 100 MHz, 644 * According to the spec, mclk is max 100 MHz,
@@ -669,6 +699,7 @@ static int __devinit mmci_probe(struct amba_device *dev, struct amba_id *id)
669 if (host->vcc == NULL) 699 if (host->vcc == NULL)
670 mmc->ocr_avail = plat->ocr_mask; 700 mmc->ocr_avail = plat->ocr_mask;
671 mmc->caps = plat->capabilities; 701 mmc->caps = plat->capabilities;
702 mmc->caps |= MMC_CAP_NEEDS_POLL;
672 703
673 /* 704 /*
674 * We can do SGIO 705 * We can do SGIO
@@ -677,10 +708,11 @@ static int __devinit mmci_probe(struct amba_device *dev, struct amba_id *id)
677 mmc->max_phys_segs = NR_SG; 708 mmc->max_phys_segs = NR_SG;
678 709
679 /* 710 /*
680 * Since we only have a 16-bit data length register, we must 711 * Since only a certain number of bits are valid in the data length
681 * ensure that we don't exceed 2^16-1 bytes in a single request. 712 * register, we must ensure that we don't exceed 2^num-1 bytes in a
713 * single request.
682 */ 714 */
683 mmc->max_req_size = 65535; 715 mmc->max_req_size = (1 << variant->datalength_bits) - 1;
684 716
685 /* 717 /*
686 * Set the maximum segment size. Since we aren't doing DMA 718 * Set the maximum segment size. Since we aren't doing DMA
@@ -734,7 +766,6 @@ static int __devinit mmci_probe(struct amba_device *dev, struct amba_id *id)
734 writel(MCI_IRQENABLE, host->base + MMCIMASK0); 766 writel(MCI_IRQENABLE, host->base + MMCIMASK0);
735 767
736 amba_set_drvdata(dev, mmc); 768 amba_set_drvdata(dev, mmc);
737 host->oldstat = mmci_get_cd(host->mmc);
738 769
739 mmc_add_host(mmc); 770 mmc_add_host(mmc);
740 771
@@ -742,12 +773,6 @@ static int __devinit mmci_probe(struct amba_device *dev, struct amba_id *id)
742 mmc_hostname(mmc), amba_rev(dev), amba_config(dev), 773 mmc_hostname(mmc), amba_rev(dev), amba_config(dev),
743 (unsigned long long)dev->res.start, dev->irq[0], dev->irq[1]); 774 (unsigned long long)dev->res.start, dev->irq[0], dev->irq[1]);
744 775
745 init_timer(&host->timer);
746 host->timer.data = (unsigned long)host;
747 host->timer.function = mmci_check_status;
748 host->timer.expires = jiffies + HZ;
749 add_timer(&host->timer);
750
751 return 0; 776 return 0;
752 777
753 irq0_free: 778 irq0_free:
@@ -781,8 +806,6 @@ static int __devexit mmci_remove(struct amba_device *dev)
781 if (mmc) { 806 if (mmc) {
782 struct mmci_host *host = mmc_priv(mmc); 807 struct mmci_host *host = mmc_priv(mmc);
783 808
784 del_timer_sync(&host->timer);
785
786 mmc_remove_host(mmc); 809 mmc_remove_host(mmc);
787 810
788 writel(0, host->base + MMCIMASK0); 811 writel(0, host->base + MMCIMASK0);
@@ -856,19 +879,28 @@ static struct amba_id mmci_ids[] = {
856 { 879 {
857 .id = 0x00041180, 880 .id = 0x00041180,
858 .mask = 0x000fffff, 881 .mask = 0x000fffff,
882 .data = &variant_arm,
859 }, 883 },
860 { 884 {
861 .id = 0x00041181, 885 .id = 0x00041181,
862 .mask = 0x000fffff, 886 .mask = 0x000fffff,
887 .data = &variant_arm,
863 }, 888 },
864 /* ST Micro variants */ 889 /* ST Micro variants */
865 { 890 {
866 .id = 0x00180180, 891 .id = 0x00180180,
867 .mask = 0x00ffffff, 892 .mask = 0x00ffffff,
893 .data = &variant_u300,
868 }, 894 },
869 { 895 {
870 .id = 0x00280180, 896 .id = 0x00280180,
871 .mask = 0x00ffffff, 897 .mask = 0x00ffffff,
898 .data = &variant_u300,
899 },
900 {
901 .id = 0x00480180,
902 .mask = 0x00ffffff,
903 .data = &variant_ux500,
872 }, 904 },
873 { 0, 0 }, 905 { 0, 0 },
874}; 906};
diff --git a/drivers/mmc/host/mmci.h b/drivers/mmc/host/mmci.h
index d77062e5e3af..68970cfb81e1 100644
--- a/drivers/mmc/host/mmci.h
+++ b/drivers/mmc/host/mmci.h
@@ -28,8 +28,6 @@
28#define MCI_4BIT_BUS (1 << 11) 28#define MCI_4BIT_BUS (1 << 11)
29/* 8bit wide buses supported in ST Micro versions */ 29/* 8bit wide buses supported in ST Micro versions */
30#define MCI_ST_8BIT_BUS (1 << 12) 30#define MCI_ST_8BIT_BUS (1 << 12)
31/* HW flow control on the ST Micro version */
32#define MCI_ST_FCEN (1 << 13)
33 31
34#define MMCIARGUMENT 0x008 32#define MMCIARGUMENT 0x008
35#define MMCICOMMAND 0x00c 33#define MMCICOMMAND 0x00c
@@ -145,6 +143,7 @@
145#define NR_SG 16 143#define NR_SG 16
146 144
147struct clk; 145struct clk;
146struct variant_data;
148 147
149struct mmci_host { 148struct mmci_host {
150 void __iomem *base; 149 void __iomem *base;
@@ -164,6 +163,7 @@ struct mmci_host {
164 unsigned int cclk; 163 unsigned int cclk;
165 u32 pwr; 164 u32 pwr;
166 struct mmci_platform_data *plat; 165 struct mmci_platform_data *plat;
166 struct variant_data *variant;
167 167
168 u8 hw_designer; 168 u8 hw_designer;
169 u8 hw_revision:4; 169 u8 hw_revision:4;
@@ -171,42 +171,9 @@ struct mmci_host {
171 struct timer_list timer; 171 struct timer_list timer;
172 unsigned int oldstat; 172 unsigned int oldstat;
173 173
174 unsigned int sg_len;
175
176 /* pio stuff */ 174 /* pio stuff */
177 struct scatterlist *sg_ptr; 175 struct sg_mapping_iter sg_miter;
178 unsigned int sg_off;
179 unsigned int size; 176 unsigned int size;
180 struct regulator *vcc; 177 struct regulator *vcc;
181}; 178};
182 179
183static inline void mmci_init_sg(struct mmci_host *host, struct mmc_data *data)
184{
185 /*
186 * Ideally, we want the higher levels to pass us a scatter list.
187 */
188 host->sg_len = data->sg_len;
189 host->sg_ptr = data->sg;
190 host->sg_off = 0;
191}
192
193static inline int mmci_next_sg(struct mmci_host *host)
194{
195 host->sg_ptr++;
196 host->sg_off = 0;
197 return --host->sg_len;
198}
199
200static inline char *mmci_kmap_atomic(struct mmci_host *host, unsigned long *flags)
201{
202 struct scatterlist *sg = host->sg_ptr;
203
204 local_irq_save(*flags);
205 return kmap_atomic(sg_page(sg), KM_BIO_SRC_IRQ) + sg->offset;
206}
207
208static inline void mmci_kunmap_atomic(struct mmci_host *host, void *buffer, unsigned long *flags)
209{
210 kunmap_atomic(buffer, KM_BIO_SRC_IRQ);
211 local_irq_restore(*flags);
212}
diff --git a/drivers/mmc/host/mxcmmc.c b/drivers/mmc/host/mxcmmc.c
index d9d4a72e0ec7..350f78e86245 100644
--- a/drivers/mmc/host/mxcmmc.c
+++ b/drivers/mmc/host/mxcmmc.c
@@ -119,6 +119,7 @@ struct mxcmci_host {
119 int detect_irq; 119 int detect_irq;
120 int dma; 120 int dma;
121 int do_dma; 121 int do_dma;
122 int default_irq_mask;
122 int use_sdio; 123 int use_sdio;
123 unsigned int power_mode; 124 unsigned int power_mode;
124 struct imxmmc_platform_data *pdata; 125 struct imxmmc_platform_data *pdata;
@@ -228,7 +229,7 @@ static int mxcmci_setup_data(struct mxcmci_host *host, struct mmc_data *data)
228static int mxcmci_start_cmd(struct mxcmci_host *host, struct mmc_command *cmd, 229static int mxcmci_start_cmd(struct mxcmci_host *host, struct mmc_command *cmd,
229 unsigned int cmdat) 230 unsigned int cmdat)
230{ 231{
231 u32 int_cntr; 232 u32 int_cntr = host->default_irq_mask;
232 unsigned long flags; 233 unsigned long flags;
233 234
234 WARN_ON(host->cmd != NULL); 235 WARN_ON(host->cmd != NULL);
@@ -275,7 +276,7 @@ static int mxcmci_start_cmd(struct mxcmci_host *host, struct mmc_command *cmd,
275static void mxcmci_finish_request(struct mxcmci_host *host, 276static void mxcmci_finish_request(struct mxcmci_host *host,
276 struct mmc_request *req) 277 struct mmc_request *req)
277{ 278{
278 u32 int_cntr = 0; 279 u32 int_cntr = host->default_irq_mask;
279 unsigned long flags; 280 unsigned long flags;
280 281
281 spin_lock_irqsave(&host->lock, flags); 282 spin_lock_irqsave(&host->lock, flags);
@@ -585,6 +586,9 @@ static irqreturn_t mxcmci_irq(int irq, void *devid)
585 (stat & (STATUS_DATA_TRANS_DONE | STATUS_WRITE_OP_DONE))) 586 (stat & (STATUS_DATA_TRANS_DONE | STATUS_WRITE_OP_DONE)))
586 mxcmci_data_done(host, stat); 587 mxcmci_data_done(host, stat);
587#endif 588#endif
589 if (host->default_irq_mask &&
590 (stat & (STATUS_CARD_INSERTION | STATUS_CARD_REMOVAL)))
591 mmc_detect_change(host->mmc, msecs_to_jiffies(200));
588 return IRQ_HANDLED; 592 return IRQ_HANDLED;
589} 593}
590 594
@@ -809,6 +813,12 @@ static int mxcmci_probe(struct platform_device *pdev)
809 else 813 else
810 mmc->ocr_avail = MMC_VDD_32_33 | MMC_VDD_33_34; 814 mmc->ocr_avail = MMC_VDD_32_33 | MMC_VDD_33_34;
811 815
816 if (host->pdata && host->pdata->dat3_card_detect)
817 host->default_irq_mask =
818 INT_CARD_INSERTION_EN | INT_CARD_REMOVAL_EN;
819 else
820 host->default_irq_mask = 0;
821
812 host->res = r; 822 host->res = r;
813 host->irq = irq; 823 host->irq = irq;
814 824
@@ -835,7 +845,7 @@ static int mxcmci_probe(struct platform_device *pdev)
835 /* recommended in data sheet */ 845 /* recommended in data sheet */
836 writew(0x2db4, host->base + MMC_REG_READ_TO); 846 writew(0x2db4, host->base + MMC_REG_READ_TO);
837 847
838 writel(0, host->base + MMC_REG_INT_CNTR); 848 writel(host->default_irq_mask, host->base + MMC_REG_INT_CNTR);
839 849
840#ifdef HAS_DMA 850#ifdef HAS_DMA
841 host->dma = imx_dma_request_by_prio(DRIVER_NAME, DMA_PRIO_LOW); 851 host->dma = imx_dma_request_by_prio(DRIVER_NAME, DMA_PRIO_LOW);
@@ -926,43 +936,47 @@ static int mxcmci_remove(struct platform_device *pdev)
926} 936}
927 937
928#ifdef CONFIG_PM 938#ifdef CONFIG_PM
929static int mxcmci_suspend(struct platform_device *dev, pm_message_t state) 939static int mxcmci_suspend(struct device *dev)
930{ 940{
931 struct mmc_host *mmc = platform_get_drvdata(dev); 941 struct mmc_host *mmc = dev_get_drvdata(dev);
942 struct mxcmci_host *host = mmc_priv(mmc);
932 int ret = 0; 943 int ret = 0;
933 944
934 if (mmc) 945 if (mmc)
935 ret = mmc_suspend_host(mmc); 946 ret = mmc_suspend_host(mmc);
947 clk_disable(host->clk);
936 948
937 return ret; 949 return ret;
938} 950}
939 951
940static int mxcmci_resume(struct platform_device *dev) 952static int mxcmci_resume(struct device *dev)
941{ 953{
942 struct mmc_host *mmc = platform_get_drvdata(dev); 954 struct mmc_host *mmc = dev_get_drvdata(dev);
943 struct mxcmci_host *host; 955 struct mxcmci_host *host = mmc_priv(mmc);
944 int ret = 0; 956 int ret = 0;
945 957
946 if (mmc) { 958 clk_enable(host->clk);
947 host = mmc_priv(mmc); 959 if (mmc)
948 ret = mmc_resume_host(mmc); 960 ret = mmc_resume_host(mmc);
949 }
950 961
951 return ret; 962 return ret;
952} 963}
953#else 964
954#define mxcmci_suspend NULL 965static const struct dev_pm_ops mxcmci_pm_ops = {
955#define mxcmci_resume NULL 966 .suspend = mxcmci_suspend,
956#endif /* CONFIG_PM */ 967 .resume = mxcmci_resume,
968};
969#endif
957 970
958static struct platform_driver mxcmci_driver = { 971static struct platform_driver mxcmci_driver = {
959 .probe = mxcmci_probe, 972 .probe = mxcmci_probe,
960 .remove = mxcmci_remove, 973 .remove = mxcmci_remove,
961 .suspend = mxcmci_suspend,
962 .resume = mxcmci_resume,
963 .driver = { 974 .driver = {
964 .name = DRIVER_NAME, 975 .name = DRIVER_NAME,
965 .owner = THIS_MODULE, 976 .owner = THIS_MODULE,
977#ifdef CONFIG_PM
978 .pm = &mxcmci_pm_ops,
979#endif
966 } 980 }
967}; 981};
968 982
diff --git a/drivers/mmc/host/sdhci-s3c.c b/drivers/mmc/host/sdhci-s3c.c
index af217924a76e..ad30f074ee15 100644
--- a/drivers/mmc/host/sdhci-s3c.c
+++ b/drivers/mmc/host/sdhci-s3c.c
@@ -365,6 +365,26 @@ static int __devinit sdhci_s3c_probe(struct platform_device *pdev)
365 365
366static int __devexit sdhci_s3c_remove(struct platform_device *pdev) 366static int __devexit sdhci_s3c_remove(struct platform_device *pdev)
367{ 367{
368 struct sdhci_host *host = platform_get_drvdata(pdev);
369 struct sdhci_s3c *sc = sdhci_priv(host);
370 int ptr;
371
372 sdhci_remove_host(host, 1);
373
374 for (ptr = 0; ptr < 3; ptr++) {
375 clk_disable(sc->clk_bus[ptr]);
376 clk_put(sc->clk_bus[ptr]);
377 }
378 clk_disable(sc->clk_io);
379 clk_put(sc->clk_io);
380
381 iounmap(host->ioaddr);
382 release_resource(sc->ioarea);
383 kfree(sc->ioarea);
384
385 sdhci_free_host(host);
386 platform_set_drvdata(pdev, NULL);
387
368 return 0; 388 return 0;
369} 389}
370 390
diff --git a/drivers/mtd/nand/mxc_nand.c b/drivers/mtd/nand/mxc_nand.c
index 82e94389824e..0d76b169482f 100644
--- a/drivers/mtd/nand/mxc_nand.c
+++ b/drivers/mtd/nand/mxc_nand.c
@@ -623,8 +623,7 @@ static void mxc_nand_command(struct mtd_info *mtd, unsigned command,
623 else 623 else
624 host->buf_start = column + mtd->writesize; 624 host->buf_start = column + mtd->writesize;
625 625
626 if (mtd->writesize > 512) 626 command = NAND_CMD_READ0; /* only READ0 is valid */
627 command = NAND_CMD_READ0; /* only READ0 is valid */
628 627
629 send_cmd(host, command, false); 628 send_cmd(host, command, false);
630 mxc_do_addr_cycle(mtd, column, page_addr); 629 mxc_do_addr_cycle(mtd, column, page_addr);
@@ -639,31 +638,11 @@ static void mxc_nand_command(struct mtd_info *mtd, unsigned command,
639 break; 638 break;
640 639
641 case NAND_CMD_SEQIN: 640 case NAND_CMD_SEQIN:
642 if (column >= mtd->writesize) { 641 if (column >= mtd->writesize)
643 /* 642 /* call ourself to read a page */
644 * FIXME: before send SEQIN command for write OOB, 643 mxc_nand_command(mtd, NAND_CMD_READ0, 0, page_addr);
645 * We must read one page out.
646 * For K9F1GXX has no READ1 command to set current HW
647 * pointer to spare area, we must write the whole page
648 * including OOB together.
649 */
650 if (mtd->writesize > 512)
651 /* call ourself to read a page */
652 mxc_nand_command(mtd, NAND_CMD_READ0, 0,
653 page_addr);
654
655 host->buf_start = column;
656
657 /* Set program pointer to spare region */
658 if (mtd->writesize == 512)
659 send_cmd(host, NAND_CMD_READOOB, false);
660 } else {
661 host->buf_start = column;
662 644
663 /* Set program pointer to page start */ 645 host->buf_start = column;
664 if (mtd->writesize == 512)
665 send_cmd(host, NAND_CMD_READ0, false);
666 }
667 646
668 send_cmd(host, command, false); 647 send_cmd(host, command, false);
669 mxc_do_addr_cycle(mtd, column, page_addr); 648 mxc_do_addr_cycle(mtd, column, page_addr);
@@ -853,6 +832,8 @@ static int __init mxcnd_probe(struct platform_device *pdev)
853 parse_mtd_partitions(mtd, part_probes, &host->parts, 0); 832 parse_mtd_partitions(mtd, part_probes, &host->parts, 0);
854 if (nr_parts > 0) 833 if (nr_parts > 0)
855 add_mtd_partitions(mtd, host->parts, nr_parts); 834 add_mtd_partitions(mtd, host->parts, nr_parts);
835 else if (pdata->parts)
836 add_mtd_partitions(mtd, pdata->parts, pdata->nr_parts);
856 else 837 else
857#endif 838#endif
858 { 839 {
diff --git a/drivers/mtd/ubi/build.c b/drivers/mtd/ubi/build.c
index 13b05cb33b08..78ae89488a4f 100644
--- a/drivers/mtd/ubi/build.c
+++ b/drivers/mtd/ubi/build.c
@@ -593,6 +593,7 @@ static int attach_by_scanning(struct ubi_device *ubi)
593 ubi->good_peb_count = ubi->peb_count - ubi->bad_peb_count; 593 ubi->good_peb_count = ubi->peb_count - ubi->bad_peb_count;
594 ubi->max_ec = si->max_ec; 594 ubi->max_ec = si->max_ec;
595 ubi->mean_ec = si->mean_ec; 595 ubi->mean_ec = si->mean_ec;
596 ubi_msg("max. sequence number: %llu", si->max_sqnum);
596 597
597 err = ubi_read_volume_table(ubi, si); 598 err = ubi_read_volume_table(ubi, si);
598 if (err) 599 if (err)
@@ -981,7 +982,7 @@ int ubi_attach_mtd_dev(struct mtd_info *mtd, int ubi_num, int vid_hdr_offset)
981 ubi_msg("number of PEBs reserved for bad PEB handling: %d", 982 ubi_msg("number of PEBs reserved for bad PEB handling: %d",
982 ubi->beb_rsvd_pebs); 983 ubi->beb_rsvd_pebs);
983 ubi_msg("max/mean erase counter: %d/%d", ubi->max_ec, ubi->mean_ec); 984 ubi_msg("max/mean erase counter: %d/%d", ubi->max_ec, ubi->mean_ec);
984 ubi_msg("image sequence number: %d", ubi->image_seq); 985 ubi_msg("image sequence number: %d", ubi->image_seq);
985 986
986 /* 987 /*
987 * The below lock makes sure we do not race with 'ubi_thread()' which 988 * The below lock makes sure we do not race with 'ubi_thread()' which
diff --git a/drivers/mtd/ubi/eba.c b/drivers/mtd/ubi/eba.c
index 9f87c99189a9..fe74749e0dae 100644
--- a/drivers/mtd/ubi/eba.c
+++ b/drivers/mtd/ubi/eba.c
@@ -418,7 +418,8 @@ retry:
418 * may try to recover data. FIXME: but this is 418 * may try to recover data. FIXME: but this is
419 * not implemented. 419 * not implemented.
420 */ 420 */
421 if (err == UBI_IO_BAD_VID_HDR) { 421 if (err == UBI_IO_BAD_HDR_READ ||
422 err == UBI_IO_BAD_HDR) {
422 ubi_warn("corrupted VID header at PEB " 423 ubi_warn("corrupted VID header at PEB "
423 "%d, LEB %d:%d", pnum, vol_id, 424 "%d, LEB %d:%d", pnum, vol_id,
424 lnum); 425 lnum);
@@ -961,8 +962,8 @@ write_error:
961 */ 962 */
962static int is_error_sane(int err) 963static int is_error_sane(int err)
963{ 964{
964 if (err == -EIO || err == -ENOMEM || err == UBI_IO_BAD_VID_HDR || 965 if (err == -EIO || err == -ENOMEM || err == UBI_IO_BAD_HDR ||
965 err == -ETIMEDOUT) 966 err == UBI_IO_BAD_HDR_READ || err == -ETIMEDOUT)
966 return 0; 967 return 0;
967 return 1; 968 return 1;
968} 969}
@@ -1165,6 +1166,44 @@ out_unlock_leb:
1165} 1166}
1166 1167
1167/** 1168/**
1169 * print_rsvd_warning - warn about not having enough reserved PEBs.
1170 * @ubi: UBI device description object
1171 *
1172 * This is a helper function for 'ubi_eba_init_scan()' which is called when UBI
1173 * cannot reserve enough PEBs for bad block handling. This function makes a
1174 * decision whether we have to print a warning or not. The algorithm is as
1175 * follows:
1176 * o if this is a new UBI image, then just print the warning
1177 * o if this is an UBI image which has already been used for some time, print
1178 * a warning only if we can reserve less than 10% of the expected amount of
1179 * the reserved PEB.
1180 *
1181 * The idea is that when UBI is used, PEBs become bad, and the reserved pool
1182 * of PEBs becomes smaller, which is normal and we do not want to scare users
1183 * with a warning every time they attach the MTD device. This was an issue
1184 * reported by real users.
1185 */
1186static void print_rsvd_warning(struct ubi_device *ubi,
1187 struct ubi_scan_info *si)
1188{
1189 /*
1190 * The 1 << 18 (256KiB) number is picked randomly, just a reasonably
1191 * large number to distinguish between newly flashed and used images.
1192 */
1193 if (si->max_sqnum > (1 << 18)) {
1194 int min = ubi->beb_rsvd_level / 10;
1195
1196 if (!min)
1197 min = 1;
1198 if (ubi->beb_rsvd_pebs > min)
1199 return;
1200 }
1201
1202 ubi_warn("cannot reserve enough PEBs for bad PEB handling, reserved %d,"
1203 " need %d", ubi->beb_rsvd_pebs, ubi->beb_rsvd_level);
1204}
1205
1206/**
1168 * ubi_eba_init_scan - initialize the EBA sub-system using scanning information. 1207 * ubi_eba_init_scan - initialize the EBA sub-system using scanning information.
1169 * @ubi: UBI device description object 1208 * @ubi: UBI device description object
1170 * @si: scanning information 1209 * @si: scanning information
@@ -1236,9 +1275,7 @@ int ubi_eba_init_scan(struct ubi_device *ubi, struct ubi_scan_info *si)
1236 if (ubi->avail_pebs < ubi->beb_rsvd_level) { 1275 if (ubi->avail_pebs < ubi->beb_rsvd_level) {
1237 /* No enough free physical eraseblocks */ 1276 /* No enough free physical eraseblocks */
1238 ubi->beb_rsvd_pebs = ubi->avail_pebs; 1277 ubi->beb_rsvd_pebs = ubi->avail_pebs;
1239 ubi_warn("cannot reserve enough PEBs for bad PEB " 1278 print_rsvd_warning(ubi, si);
1240 "handling, reserved %d, need %d",
1241 ubi->beb_rsvd_pebs, ubi->beb_rsvd_level);
1242 } else 1279 } else
1243 ubi->beb_rsvd_pebs = ubi->beb_rsvd_level; 1280 ubi->beb_rsvd_pebs = ubi->beb_rsvd_level;
1244 1281
diff --git a/drivers/mtd/ubi/io.c b/drivers/mtd/ubi/io.c
index 4b979e34b159..332f992f13d9 100644
--- a/drivers/mtd/ubi/io.c
+++ b/drivers/mtd/ubi/io.c
@@ -150,6 +150,8 @@ int ubi_io_read(const struct ubi_device *ubi, void *buf, int pnum, int offset,
150retry: 150retry:
151 err = ubi->mtd->read(ubi->mtd, addr, len, &read, buf); 151 err = ubi->mtd->read(ubi->mtd, addr, len, &read, buf);
152 if (err) { 152 if (err) {
153 const char *errstr = (err == -EBADMSG) ? " (ECC error)" : "";
154
153 if (err == -EUCLEAN) { 155 if (err == -EUCLEAN) {
154 /* 156 /*
155 * -EUCLEAN is reported if there was a bit-flip which 157 * -EUCLEAN is reported if there was a bit-flip which
@@ -165,15 +167,15 @@ retry:
165 } 167 }
166 168
167 if (read != len && retries++ < UBI_IO_RETRIES) { 169 if (read != len && retries++ < UBI_IO_RETRIES) {
168 dbg_io("error %d while reading %d bytes from PEB %d:%d," 170 dbg_io("error %d%s while reading %d bytes from PEB %d:%d,"
169 " read only %zd bytes, retry", 171 " read only %zd bytes, retry",
170 err, len, pnum, offset, read); 172 err, errstr, len, pnum, offset, read);
171 yield(); 173 yield();
172 goto retry; 174 goto retry;
173 } 175 }
174 176
175 ubi_err("error %d while reading %d bytes from PEB %d:%d, " 177 ubi_err("error %d%s while reading %d bytes from PEB %d:%d, "
176 "read %zd bytes", err, len, pnum, offset, read); 178 "read %zd bytes", err, errstr, len, pnum, offset, read);
177 ubi_dbg_dump_stack(); 179 ubi_dbg_dump_stack();
178 180
179 /* 181 /*
@@ -515,7 +517,7 @@ static int nor_erase_prepare(struct ubi_device *ubi, int pnum)
515 * In this case we probably anyway have garbage in this PEB. 517 * In this case we probably anyway have garbage in this PEB.
516 */ 518 */
517 err1 = ubi_io_read_vid_hdr(ubi, pnum, &vid_hdr, 0); 519 err1 = ubi_io_read_vid_hdr(ubi, pnum, &vid_hdr, 0);
518 if (err1 == UBI_IO_BAD_VID_HDR) 520 if (err1 == UBI_IO_BAD_HDR_READ || err1 == UBI_IO_BAD_HDR)
519 /* 521 /*
520 * The VID header is corrupted, so we can safely erase this 522 * The VID header is corrupted, so we can safely erase this
521 * PEB and not afraid that it will be treated as a valid PEB in 523 * PEB and not afraid that it will be treated as a valid PEB in
@@ -709,7 +711,7 @@ bad:
709 * o %UBI_IO_BITFLIPS if the CRC is correct, but bit-flips were detected 711 * o %UBI_IO_BITFLIPS if the CRC is correct, but bit-flips were detected
710 * and corrected by the flash driver; this is harmless but may indicate that 712 * and corrected by the flash driver; this is harmless but may indicate that
711 * this eraseblock may become bad soon (but may be not); 713 * this eraseblock may become bad soon (but may be not);
712 * o %UBI_IO_BAD_EC_HDR if the erase counter header is corrupted (a CRC error); 714 * o %UBI_IO_BAD_HDR if the erase counter header is corrupted (a CRC error);
713 * o %UBI_IO_PEB_EMPTY if the physical eraseblock is empty; 715 * o %UBI_IO_PEB_EMPTY if the physical eraseblock is empty;
714 * o a negative error code in case of failure. 716 * o a negative error code in case of failure.
715 */ 717 */
@@ -736,23 +738,21 @@ int ubi_io_read_ec_hdr(struct ubi_device *ubi, int pnum,
736 * header is still OK, we just report this as there was a 738 * header is still OK, we just report this as there was a
737 * bit-flip. 739 * bit-flip.
738 */ 740 */
739 read_err = err; 741 if (err == -EBADMSG)
742 read_err = UBI_IO_BAD_HDR_READ;
740 } 743 }
741 744
742 magic = be32_to_cpu(ec_hdr->magic); 745 magic = be32_to_cpu(ec_hdr->magic);
743 if (magic != UBI_EC_HDR_MAGIC) { 746 if (magic != UBI_EC_HDR_MAGIC) {
747 if (read_err)
748 return read_err;
749
744 /* 750 /*
745 * The magic field is wrong. Let's check if we have read all 751 * The magic field is wrong. Let's check if we have read all
746 * 0xFF. If yes, this physical eraseblock is assumed to be 752 * 0xFF. If yes, this physical eraseblock is assumed to be
747 * empty. 753 * empty.
748 *
749 * But if there was a read error, we do not test it for all
750 * 0xFFs. Even if it does contain all 0xFFs, this error
751 * indicates that something is still wrong with this physical
752 * eraseblock and we anyway cannot treat it as empty.
753 */ 754 */
754 if (read_err != -EBADMSG && 755 if (check_pattern(ec_hdr, 0xFF, UBI_EC_HDR_SIZE)) {
755 check_pattern(ec_hdr, 0xFF, UBI_EC_HDR_SIZE)) {
756 /* The physical eraseblock is supposedly empty */ 756 /* The physical eraseblock is supposedly empty */
757 if (verbose) 757 if (verbose)
758 ubi_warn("no EC header found at PEB %d, " 758 ubi_warn("no EC header found at PEB %d, "
@@ -774,7 +774,7 @@ int ubi_io_read_ec_hdr(struct ubi_device *ubi, int pnum,
774 } else if (UBI_IO_DEBUG) 774 } else if (UBI_IO_DEBUG)
775 dbg_msg("bad magic number at PEB %d: %08x instead of " 775 dbg_msg("bad magic number at PEB %d: %08x instead of "
776 "%08x", pnum, magic, UBI_EC_HDR_MAGIC); 776 "%08x", pnum, magic, UBI_EC_HDR_MAGIC);
777 return UBI_IO_BAD_EC_HDR; 777 return UBI_IO_BAD_HDR;
778 } 778 }
779 779
780 crc = crc32(UBI_CRC32_INIT, ec_hdr, UBI_EC_HDR_SIZE_CRC); 780 crc = crc32(UBI_CRC32_INIT, ec_hdr, UBI_EC_HDR_SIZE_CRC);
@@ -788,7 +788,7 @@ int ubi_io_read_ec_hdr(struct ubi_device *ubi, int pnum,
788 } else if (UBI_IO_DEBUG) 788 } else if (UBI_IO_DEBUG)
789 dbg_msg("bad EC header CRC at PEB %d, calculated " 789 dbg_msg("bad EC header CRC at PEB %d, calculated "
790 "%#08x, read %#08x", pnum, crc, hdr_crc); 790 "%#08x, read %#08x", pnum, crc, hdr_crc);
791 return UBI_IO_BAD_EC_HDR; 791 return read_err ?: UBI_IO_BAD_HDR;
792 } 792 }
793 793
794 /* And of course validate what has just been read from the media */ 794 /* And of course validate what has just been read from the media */
@@ -798,6 +798,10 @@ int ubi_io_read_ec_hdr(struct ubi_device *ubi, int pnum,
798 return -EINVAL; 798 return -EINVAL;
799 } 799 }
800 800
801 /*
802 * If there was %-EBADMSG, but the header CRC is still OK, report about
803 * a bit-flip to force scrubbing on this PEB.
804 */
801 return read_err ? UBI_IO_BITFLIPS : 0; 805 return read_err ? UBI_IO_BITFLIPS : 0;
802} 806}
803 807
@@ -977,7 +981,7 @@ bad:
977 * o %UBI_IO_BITFLIPS if the CRC is correct, but bit-flips were detected 981 * o %UBI_IO_BITFLIPS if the CRC is correct, but bit-flips were detected
978 * and corrected by the flash driver; this is harmless but may indicate that 982 * and corrected by the flash driver; this is harmless but may indicate that
979 * this eraseblock may become bad soon; 983 * this eraseblock may become bad soon;
980 * o %UBI_IO_BAD_VID_HDR if the volume identifier header is corrupted (a CRC 984 * o %UBI_IO_BAD_HDR if the volume identifier header is corrupted (a CRC
981 * error detected); 985 * error detected);
982 * o %UBI_IO_PEB_FREE if the physical eraseblock is free (i.e., there is no VID 986 * o %UBI_IO_PEB_FREE if the physical eraseblock is free (i.e., there is no VID
983 * header there); 987 * header there);
@@ -1008,22 +1012,20 @@ int ubi_io_read_vid_hdr(struct ubi_device *ubi, int pnum,
1008 * CRC check-sum and we will identify this. If the VID header is 1012 * CRC check-sum and we will identify this. If the VID header is
1009 * still OK, we just report this as there was a bit-flip. 1013 * still OK, we just report this as there was a bit-flip.
1010 */ 1014 */
1011 read_err = err; 1015 if (err == -EBADMSG)
1016 read_err = UBI_IO_BAD_HDR_READ;
1012 } 1017 }
1013 1018
1014 magic = be32_to_cpu(vid_hdr->magic); 1019 magic = be32_to_cpu(vid_hdr->magic);
1015 if (magic != UBI_VID_HDR_MAGIC) { 1020 if (magic != UBI_VID_HDR_MAGIC) {
1021 if (read_err)
1022 return read_err;
1023
1016 /* 1024 /*
1017 * If we have read all 0xFF bytes, the VID header probably does 1025 * If we have read all 0xFF bytes, the VID header probably does
1018 * not exist and the physical eraseblock is assumed to be free. 1026 * not exist and the physical eraseblock is assumed to be free.
1019 *
1020 * But if there was a read error, we do not test the data for
1021 * 0xFFs. Even if it does contain all 0xFFs, this error
1022 * indicates that something is still wrong with this physical
1023 * eraseblock and it cannot be regarded as free.
1024 */ 1027 */
1025 if (read_err != -EBADMSG && 1028 if (check_pattern(vid_hdr, 0xFF, UBI_VID_HDR_SIZE)) {
1026 check_pattern(vid_hdr, 0xFF, UBI_VID_HDR_SIZE)) {
1027 /* The physical eraseblock is supposedly free */ 1029 /* The physical eraseblock is supposedly free */
1028 if (verbose) 1030 if (verbose)
1029 ubi_warn("no VID header found at PEB %d, " 1031 ubi_warn("no VID header found at PEB %d, "
@@ -1045,7 +1047,7 @@ int ubi_io_read_vid_hdr(struct ubi_device *ubi, int pnum,
1045 } else if (UBI_IO_DEBUG) 1047 } else if (UBI_IO_DEBUG)
1046 dbg_msg("bad magic number at PEB %d: %08x instead of " 1048 dbg_msg("bad magic number at PEB %d: %08x instead of "
1047 "%08x", pnum, magic, UBI_VID_HDR_MAGIC); 1049 "%08x", pnum, magic, UBI_VID_HDR_MAGIC);
1048 return UBI_IO_BAD_VID_HDR; 1050 return UBI_IO_BAD_HDR;
1049 } 1051 }
1050 1052
1051 crc = crc32(UBI_CRC32_INIT, vid_hdr, UBI_VID_HDR_SIZE_CRC); 1053 crc = crc32(UBI_CRC32_INIT, vid_hdr, UBI_VID_HDR_SIZE_CRC);
@@ -1059,7 +1061,7 @@ int ubi_io_read_vid_hdr(struct ubi_device *ubi, int pnum,
1059 } else if (UBI_IO_DEBUG) 1061 } else if (UBI_IO_DEBUG)
1060 dbg_msg("bad CRC at PEB %d, calculated %#08x, " 1062 dbg_msg("bad CRC at PEB %d, calculated %#08x, "
1061 "read %#08x", pnum, crc, hdr_crc); 1063 "read %#08x", pnum, crc, hdr_crc);
1062 return UBI_IO_BAD_VID_HDR; 1064 return read_err ?: UBI_IO_BAD_HDR;
1063 } 1065 }
1064 1066
1065 /* Validate the VID header that we have just read */ 1067 /* Validate the VID header that we have just read */
@@ -1069,6 +1071,10 @@ int ubi_io_read_vid_hdr(struct ubi_device *ubi, int pnum,
1069 return -EINVAL; 1071 return -EINVAL;
1070 } 1072 }
1071 1073
1074 /*
1075 * If there was a read error (%-EBADMSG), but the header CRC is still
1076 * OK, report about a bit-flip to force scrubbing on this PEB.
1077 */
1072 return read_err ? UBI_IO_BITFLIPS : 0; 1078 return read_err ? UBI_IO_BITFLIPS : 0;
1073} 1079}
1074 1080
diff --git a/drivers/mtd/ubi/scan.c b/drivers/mtd/ubi/scan.c
index aed19f33b8f3..372a15ac9995 100644
--- a/drivers/mtd/ubi/scan.c
+++ b/drivers/mtd/ubi/scan.c
@@ -44,6 +44,7 @@
44#include <linux/slab.h> 44#include <linux/slab.h>
45#include <linux/crc32.h> 45#include <linux/crc32.h>
46#include <linux/math64.h> 46#include <linux/math64.h>
47#include <linux/random.h>
47#include "ubi.h" 48#include "ubi.h"
48 49
49#ifdef CONFIG_MTD_UBI_DEBUG_PARANOID 50#ifdef CONFIG_MTD_UBI_DEBUG_PARANOID
@@ -72,16 +73,19 @@ static int add_to_list(struct ubi_scan_info *si, int pnum, int ec,
72{ 73{
73 struct ubi_scan_leb *seb; 74 struct ubi_scan_leb *seb;
74 75
75 if (list == &si->free) 76 if (list == &si->free) {
76 dbg_bld("add to free: PEB %d, EC %d", pnum, ec); 77 dbg_bld("add to free: PEB %d, EC %d", pnum, ec);
77 else if (list == &si->erase) 78 si->free_peb_count += 1;
79 } else if (list == &si->erase) {
78 dbg_bld("add to erase: PEB %d, EC %d", pnum, ec); 80 dbg_bld("add to erase: PEB %d, EC %d", pnum, ec);
79 else if (list == &si->corr) { 81 si->erase_peb_count += 1;
82 } else if (list == &si->corr) {
80 dbg_bld("add to corrupted: PEB %d, EC %d", pnum, ec); 83 dbg_bld("add to corrupted: PEB %d, EC %d", pnum, ec);
81 si->corr_count += 1; 84 si->corr_peb_count += 1;
82 } else if (list == &si->alien) 85 } else if (list == &si->alien) {
83 dbg_bld("add to alien: PEB %d, EC %d", pnum, ec); 86 dbg_bld("add to alien: PEB %d, EC %d", pnum, ec);
84 else 87 si->alien_peb_count += 1;
88 } else
85 BUG(); 89 BUG();
86 90
87 seb = kmalloc(sizeof(struct ubi_scan_leb), GFP_KERNEL); 91 seb = kmalloc(sizeof(struct ubi_scan_leb), GFP_KERNEL);
@@ -517,6 +521,7 @@ int ubi_scan_add_used(struct ubi_device *ubi, struct ubi_scan_info *si,
517 sv->leb_count += 1; 521 sv->leb_count += 1;
518 rb_link_node(&seb->u.rb, parent, p); 522 rb_link_node(&seb->u.rb, parent, p);
519 rb_insert_color(&seb->u.rb, &sv->root); 523 rb_insert_color(&seb->u.rb, &sv->root);
524 si->used_peb_count += 1;
520 return 0; 525 return 0;
521} 526}
522 527
@@ -745,19 +750,17 @@ static int process_eb(struct ubi_device *ubi, struct ubi_scan_info *si,
745 bitflips = 1; 750 bitflips = 1;
746 else if (err == UBI_IO_PEB_EMPTY) 751 else if (err == UBI_IO_PEB_EMPTY)
747 return add_to_list(si, pnum, UBI_SCAN_UNKNOWN_EC, &si->erase); 752 return add_to_list(si, pnum, UBI_SCAN_UNKNOWN_EC, &si->erase);
748 else if (err == UBI_IO_BAD_EC_HDR) { 753 else if (err == UBI_IO_BAD_HDR_READ || err == UBI_IO_BAD_HDR) {
749 /* 754 /*
750 * We have to also look at the VID header, possibly it is not 755 * We have to also look at the VID header, possibly it is not
751 * corrupted. Set %bitflips flag in order to make this PEB be 756 * corrupted. Set %bitflips flag in order to make this PEB be
752 * moved and EC be re-created. 757 * moved and EC be re-created.
753 */ 758 */
754 ec_corr = 1; 759 ec_corr = err;
755 ec = UBI_SCAN_UNKNOWN_EC; 760 ec = UBI_SCAN_UNKNOWN_EC;
756 bitflips = 1; 761 bitflips = 1;
757 } 762 }
758 763
759 si->is_empty = 0;
760
761 if (!ec_corr) { 764 if (!ec_corr) {
762 int image_seq; 765 int image_seq;
763 766
@@ -813,9 +816,12 @@ static int process_eb(struct ubi_device *ubi, struct ubi_scan_info *si,
813 return err; 816 return err;
814 else if (err == UBI_IO_BITFLIPS) 817 else if (err == UBI_IO_BITFLIPS)
815 bitflips = 1; 818 bitflips = 1;
816 else if (err == UBI_IO_BAD_VID_HDR || 819 else if (err == UBI_IO_BAD_HDR_READ || err == UBI_IO_BAD_HDR ||
817 (err == UBI_IO_PEB_FREE && ec_corr)) { 820 (err == UBI_IO_PEB_FREE && ec_corr)) {
818 /* VID header is corrupted */ 821 /* VID header is corrupted */
822 if (err == UBI_IO_BAD_HDR_READ ||
823 ec_corr == UBI_IO_BAD_HDR_READ)
824 si->read_err_count += 1;
819 err = add_to_list(si, pnum, ec, &si->corr); 825 err = add_to_list(si, pnum, ec, &si->corr);
820 if (err) 826 if (err)
821 return err; 827 return err;
@@ -836,11 +842,11 @@ static int process_eb(struct ubi_device *ubi, struct ubi_scan_info *si,
836 switch (vidh->compat) { 842 switch (vidh->compat) {
837 case UBI_COMPAT_DELETE: 843 case UBI_COMPAT_DELETE:
838 ubi_msg("\"delete\" compatible internal volume %d:%d" 844 ubi_msg("\"delete\" compatible internal volume %d:%d"
839 " found, remove it", vol_id, lnum); 845 " found, will remove it", vol_id, lnum);
840 err = add_to_list(si, pnum, ec, &si->corr); 846 err = add_to_list(si, pnum, ec, &si->corr);
841 if (err) 847 if (err)
842 return err; 848 return err;
843 break; 849 return 0;
844 850
845 case UBI_COMPAT_RO: 851 case UBI_COMPAT_RO:
846 ubi_msg("read-only compatible internal volume %d:%d" 852 ubi_msg("read-only compatible internal volume %d:%d"
@@ -855,7 +861,6 @@ static int process_eb(struct ubi_device *ubi, struct ubi_scan_info *si,
855 err = add_to_list(si, pnum, ec, &si->alien); 861 err = add_to_list(si, pnum, ec, &si->alien);
856 if (err) 862 if (err)
857 return err; 863 return err;
858 si->alien_peb_count += 1;
859 return 0; 864 return 0;
860 865
861 case UBI_COMPAT_REJECT: 866 case UBI_COMPAT_REJECT:
@@ -886,6 +891,85 @@ adjust_mean_ec:
886} 891}
887 892
888/** 893/**
894 * check_what_we_have - check what PEB were found by scanning.
895 * @ubi: UBI device description object
896 * @si: scanning information
897 *
898 * This is a helper function which takes a look what PEBs were found by
899 * scanning, and decides whether the flash is empty and should be formatted and
900 * whether there are too many corrupted PEBs and we should not attach this
901 * MTD device. Returns zero if we should proceed with attaching the MTD device,
902 * and %-EINVAL if we should not.
903 */
904static int check_what_we_have(struct ubi_device *ubi, struct ubi_scan_info *si)
905{
906 struct ubi_scan_leb *seb;
907 int max_corr;
908
909 max_corr = ubi->peb_count - si->bad_peb_count - si->alien_peb_count;
910 max_corr = max_corr / 20 ?: 8;
911
912 /*
913 * Few corrupted PEBs are not a problem and may be just a result of
914 * unclean reboots. However, many of them may indicate some problems
915 * with the flash HW or driver.
916 */
917 if (si->corr_peb_count >= 8) {
918 ubi_warn("%d PEBs are corrupted", si->corr_peb_count);
919 printk(KERN_WARNING "corrupted PEBs are:");
920 list_for_each_entry(seb, &si->corr, u.list)
921 printk(KERN_CONT " %d", seb->pnum);
922 printk(KERN_CONT "\n");
923
924 /*
925 * If too many PEBs are corrupted, we refuse attaching,
926 * otherwise, only print a warning.
927 */
928 if (si->corr_peb_count >= max_corr) {
929 ubi_err("too many corrupted PEBs, refusing this device");
930 return -EINVAL;
931 }
932 }
933
934 if (si->free_peb_count + si->used_peb_count +
935 si->alien_peb_count == 0) {
936 /* No UBI-formatted eraseblocks were found */
937 if (si->corr_peb_count == si->read_err_count &&
938 si->corr_peb_count < 8) {
939 /* No or just few corrupted PEBs, and all of them had a
940 * read error. We assume that those are bad PEBs, which
941 * were just not marked as bad so far.
942 *
943 * This piece of code basically tries to distinguish
944 * between the following 2 situations:
945 *
946 * 1. Flash is empty, but there are few bad PEBs, which
947 * are not marked as bad so far, and which were read
948 * with error. We want to go ahead and format this
949 * flash. While formating, the faulty PEBs will
950 * probably be marked as bad.
951 *
952 * 2. Flash probably contains non-UBI data and we do
953 * not want to format it and destroy possibly needed
954 * data (e.g., consider the case when the bootloader
955 * MTD partition was accidentally fed to UBI).
956 */
957 si->is_empty = 1;
958 ubi_msg("empty MTD device detected");
959 get_random_bytes(&ubi->image_seq, sizeof(ubi->image_seq));
960 } else {
961 ubi_err("MTD device possibly contains non-UBI data, "
962 "refusing it");
963 return -EINVAL;
964 }
965 }
966
967 if (si->corr_peb_count > 0)
968 ubi_msg("corrupted PEBs will be formatted");
969 return 0;
970}
971
972/**
889 * ubi_scan - scan an MTD device. 973 * ubi_scan - scan an MTD device.
890 * @ubi: UBI device description object 974 * @ubi: UBI device description object
891 * 975 *
@@ -909,7 +993,6 @@ struct ubi_scan_info *ubi_scan(struct ubi_device *ubi)
909 INIT_LIST_HEAD(&si->erase); 993 INIT_LIST_HEAD(&si->erase);
910 INIT_LIST_HEAD(&si->alien); 994 INIT_LIST_HEAD(&si->alien);
911 si->volumes = RB_ROOT; 995 si->volumes = RB_ROOT;
912 si->is_empty = 1;
913 996
914 err = -ENOMEM; 997 err = -ENOMEM;
915 ech = kzalloc(ubi->ec_hdr_alsize, GFP_KERNEL); 998 ech = kzalloc(ubi->ec_hdr_alsize, GFP_KERNEL);
@@ -935,21 +1018,9 @@ struct ubi_scan_info *ubi_scan(struct ubi_device *ubi)
935 if (si->ec_count) 1018 if (si->ec_count)
936 si->mean_ec = div_u64(si->ec_sum, si->ec_count); 1019 si->mean_ec = div_u64(si->ec_sum, si->ec_count);
937 1020
938 if (si->is_empty) 1021 err = check_what_we_have(ubi, si);
939 ubi_msg("empty MTD device detected"); 1022 if (err)
940 1023 goto out_vidh;
941 /*
942 * Few corrupted PEBs are not a problem and may be just a result of
943 * unclean reboots. However, many of them may indicate some problems
944 * with the flash HW or driver. Print a warning in this case.
945 */
946 if (si->corr_count >= 8 || si->corr_count >= ubi->peb_count / 4) {
947 ubi_warn("%d PEBs are corrupted", si->corr_count);
948 printk(KERN_WARNING "corrupted PEBs are:");
949 list_for_each_entry(seb, &si->corr, u.list)
950 printk(KERN_CONT " %d", seb->pnum);
951 printk(KERN_CONT "\n");
952 }
953 1024
954 /* 1025 /*
955 * In case of unknown erase counter we use the mean erase counter 1026 * In case of unknown erase counter we use the mean erase counter
diff --git a/drivers/mtd/ubi/scan.h b/drivers/mtd/ubi/scan.h
index ff179ad7ca55..2576a8d1532b 100644
--- a/drivers/mtd/ubi/scan.h
+++ b/drivers/mtd/ubi/scan.h
@@ -91,10 +91,16 @@ struct ubi_scan_volume {
91 * @erase: list of physical eraseblocks which have to be erased 91 * @erase: list of physical eraseblocks which have to be erased
92 * @alien: list of physical eraseblocks which should not be used by UBI (e.g., 92 * @alien: list of physical eraseblocks which should not be used by UBI (e.g.,
93 * those belonging to "preserve"-compatible internal volumes) 93 * those belonging to "preserve"-compatible internal volumes)
94 * @used_peb_count: count of used PEBs
95 * @corr_peb_count: count of PEBs in the @corr list
96 * @read_err_count: count of PEBs read with error (%UBI_IO_BAD_HDR_READ was
97 * returned)
98 * @free_peb_count: count of PEBs in the @free list
99 * @erase_peb_count: count of PEBs in the @erase list
100 * @alien_peb_count: count of PEBs in the @alien list
94 * @bad_peb_count: count of bad physical eraseblocks 101 * @bad_peb_count: count of bad physical eraseblocks
95 * @vols_found: number of volumes found during scanning 102 * @vols_found: number of volumes found during scanning
96 * @highest_vol_id: highest volume ID 103 * @highest_vol_id: highest volume ID
97 * @alien_peb_count: count of physical eraseblocks in the @alien list
98 * @is_empty: flag indicating whether the MTD device is empty or not 104 * @is_empty: flag indicating whether the MTD device is empty or not
99 * @min_ec: lowest erase counter value 105 * @min_ec: lowest erase counter value
100 * @max_ec: highest erase counter value 106 * @max_ec: highest erase counter value
@@ -102,7 +108,6 @@ struct ubi_scan_volume {
102 * @mean_ec: mean erase counter value 108 * @mean_ec: mean erase counter value
103 * @ec_sum: a temporary variable used when calculating @mean_ec 109 * @ec_sum: a temporary variable used when calculating @mean_ec
104 * @ec_count: a temporary variable used when calculating @mean_ec 110 * @ec_count: a temporary variable used when calculating @mean_ec
105 * @corr_count: count of corrupted PEBs
106 * 111 *
107 * This data structure contains the result of scanning and may be used by other 112 * This data structure contains the result of scanning and may be used by other
108 * UBI sub-systems to build final UBI data structures, further error-recovery 113 * UBI sub-systems to build final UBI data structures, further error-recovery
@@ -114,10 +119,15 @@ struct ubi_scan_info {
114 struct list_head free; 119 struct list_head free;
115 struct list_head erase; 120 struct list_head erase;
116 struct list_head alien; 121 struct list_head alien;
122 int used_peb_count;
123 int corr_peb_count;
124 int read_err_count;
125 int free_peb_count;
126 int erase_peb_count;
127 int alien_peb_count;
117 int bad_peb_count; 128 int bad_peb_count;
118 int vols_found; 129 int vols_found;
119 int highest_vol_id; 130 int highest_vol_id;
120 int alien_peb_count;
121 int is_empty; 131 int is_empty;
122 int min_ec; 132 int min_ec;
123 int max_ec; 133 int max_ec;
@@ -125,7 +135,6 @@ struct ubi_scan_info {
125 int mean_ec; 135 int mean_ec;
126 uint64_t ec_sum; 136 uint64_t ec_sum;
127 int ec_count; 137 int ec_count;
128 int corr_count;
129}; 138};
130 139
131struct ubi_device; 140struct ubi_device;
@@ -135,7 +144,7 @@ struct ubi_vid_hdr;
135 * ubi_scan_move_to_list - move a PEB from the volume tree to a list. 144 * ubi_scan_move_to_list - move a PEB from the volume tree to a list.
136 * 145 *
137 * @sv: volume scanning information 146 * @sv: volume scanning information
138 * @seb: scanning eraseblock infprmation 147 * @seb: scanning eraseblock information
139 * @list: the list to move to 148 * @list: the list to move to
140 */ 149 */
141static inline void ubi_scan_move_to_list(struct ubi_scan_volume *sv, 150static inline void ubi_scan_move_to_list(struct ubi_scan_volume *sv,
diff --git a/drivers/mtd/ubi/ubi.h b/drivers/mtd/ubi/ubi.h
index a637f0283add..0359e0cce482 100644
--- a/drivers/mtd/ubi/ubi.h
+++ b/drivers/mtd/ubi/ubi.h
@@ -89,16 +89,16 @@
89 * %0xFF bytes 89 * %0xFF bytes
90 * UBI_IO_PEB_FREE: the physical eraseblock is free, i.e. it contains only a 90 * UBI_IO_PEB_FREE: the physical eraseblock is free, i.e. it contains only a
91 * valid erase counter header, and the rest are %0xFF bytes 91 * valid erase counter header, and the rest are %0xFF bytes
92 * UBI_IO_BAD_EC_HDR: the erase counter header is corrupted (bad magic or CRC) 92 * UBI_IO_BAD_HDR: the EC or VID header is corrupted (bad magic or CRC)
93 * UBI_IO_BAD_VID_HDR: the volume identifier header is corrupted (bad magic or 93 * UBI_IO_BAD_HDR_READ: the same as %UBI_IO_BAD_HDR, but also there was a read
94 * CRC) 94 * error reported by the flash driver
95 * UBI_IO_BITFLIPS: bit-flips were detected and corrected 95 * UBI_IO_BITFLIPS: bit-flips were detected and corrected
96 */ 96 */
97enum { 97enum {
98 UBI_IO_PEB_EMPTY = 1, 98 UBI_IO_PEB_EMPTY = 1,
99 UBI_IO_PEB_FREE, 99 UBI_IO_PEB_FREE,
100 UBI_IO_BAD_EC_HDR, 100 UBI_IO_BAD_HDR,
101 UBI_IO_BAD_VID_HDR, 101 UBI_IO_BAD_HDR_READ,
102 UBI_IO_BITFLIPS 102 UBI_IO_BITFLIPS
103}; 103};
104 104
diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig
index 2decc597bda7..ce2fcdd4ab90 100644
--- a/drivers/net/Kconfig
+++ b/drivers/net/Kconfig
@@ -2754,6 +2754,7 @@ config MYRI10GE_DCA
2754config NETXEN_NIC 2754config NETXEN_NIC
2755 tristate "NetXen Multi port (1/10) Gigabit Ethernet NIC" 2755 tristate "NetXen Multi port (1/10) Gigabit Ethernet NIC"
2756 depends on PCI 2756 depends on PCI
2757 select FW_LOADER
2757 help 2758 help
2758 This enables the support for NetXen's Gigabit Ethernet card. 2759 This enables the support for NetXen's Gigabit Ethernet card.
2759 2760
@@ -2819,6 +2820,7 @@ config BNX2X
2819config QLCNIC 2820config QLCNIC
2820 tristate "QLOGIC QLCNIC 1/10Gb Converged Ethernet NIC Support" 2821 tristate "QLOGIC QLCNIC 1/10Gb Converged Ethernet NIC Support"
2821 depends on PCI 2822 depends on PCI
2823 select FW_LOADER
2822 help 2824 help
2823 This driver supports QLogic QLE8240 and QLE8242 Converged Ethernet 2825 This driver supports QLogic QLE8240 and QLE8242 Converged Ethernet
2824 devices. 2826 devices.
diff --git a/drivers/net/bnx2.c b/drivers/net/bnx2.c
index 949d7a9dcf92..117432222a09 100644
--- a/drivers/net/bnx2.c
+++ b/drivers/net/bnx2.c
@@ -3073,7 +3073,6 @@ bnx2_rx_int(struct bnx2 *bp, struct bnx2_napi *bnapi, int budget)
3073 u16 hw_cons, sw_cons, sw_ring_cons, sw_prod, sw_ring_prod; 3073 u16 hw_cons, sw_cons, sw_ring_cons, sw_prod, sw_ring_prod;
3074 struct l2_fhdr *rx_hdr; 3074 struct l2_fhdr *rx_hdr;
3075 int rx_pkt = 0, pg_ring_used = 0; 3075 int rx_pkt = 0, pg_ring_used = 0;
3076 struct pci_dev *pdev = bp->pdev;
3077 3076
3078 hw_cons = bnx2_get_hw_rx_cons(bnapi); 3077 hw_cons = bnx2_get_hw_rx_cons(bnapi);
3079 sw_cons = rxr->rx_cons; 3078 sw_cons = rxr->rx_cons;
@@ -3099,12 +3098,10 @@ bnx2_rx_int(struct bnx2 *bp, struct bnx2_napi *bnapi, int budget)
3099 skb = rx_buf->skb; 3098 skb = rx_buf->skb;
3100 prefetchw(skb); 3099 prefetchw(skb);
3101 3100
3102 if (!get_dma_ops(&pdev->dev)->sync_single_for_cpu) { 3101 next_rx_buf =
3103 next_rx_buf = 3102 &rxr->rx_buf_ring[RX_RING_IDX(NEXT_RX_BD(sw_cons))];
3104 &rxr->rx_buf_ring[ 3103 prefetch(next_rx_buf->desc);
3105 RX_RING_IDX(NEXT_RX_BD(sw_cons))]; 3104
3106 prefetch(next_rx_buf->desc);
3107 }
3108 rx_buf->skb = NULL; 3105 rx_buf->skb = NULL;
3109 3106
3110 dma_addr = dma_unmap_addr(rx_buf, mapping); 3107 dma_addr = dma_unmap_addr(rx_buf, mapping);
diff --git a/drivers/net/bnx2x.h b/drivers/net/bnx2x.h
index 8bd23687c530..bb0872a63315 100644
--- a/drivers/net/bnx2x.h
+++ b/drivers/net/bnx2x.h
@@ -1062,6 +1062,10 @@ struct bnx2x {
1062 1062
1063 /* used to synchronize stats collecting */ 1063 /* used to synchronize stats collecting */
1064 int stats_state; 1064 int stats_state;
1065
1066 /* used for synchronization of concurrent threads statistics handling */
1067 spinlock_t stats_lock;
1068
1065 /* used by dmae command loader */ 1069 /* used by dmae command loader */
1066 struct dmae_command stats_dmae; 1070 struct dmae_command stats_dmae;
1067 int executer_idx; 1071 int executer_idx;
diff --git a/drivers/net/bnx2x_main.c b/drivers/net/bnx2x_main.c
index 57ff5b3bcce6..46167c081727 100644
--- a/drivers/net/bnx2x_main.c
+++ b/drivers/net/bnx2x_main.c
@@ -57,8 +57,8 @@
57#include "bnx2x_init_ops.h" 57#include "bnx2x_init_ops.h"
58#include "bnx2x_dump.h" 58#include "bnx2x_dump.h"
59 59
60#define DRV_MODULE_VERSION "1.52.53-1" 60#define DRV_MODULE_VERSION "1.52.53-2"
61#define DRV_MODULE_RELDATE "2010/18/04" 61#define DRV_MODULE_RELDATE "2010/21/07"
62#define BNX2X_BC_VER 0x040200 62#define BNX2X_BC_VER 0x040200
63 63
64#include <linux/firmware.h> 64#include <linux/firmware.h>
@@ -3789,6 +3789,8 @@ static void bnx2x_storm_stats_post(struct bnx2x *bp)
3789 struct eth_query_ramrod_data ramrod_data = {0}; 3789 struct eth_query_ramrod_data ramrod_data = {0};
3790 int i, rc; 3790 int i, rc;
3791 3791
3792 spin_lock_bh(&bp->stats_lock);
3793
3792 ramrod_data.drv_counter = bp->stats_counter++; 3794 ramrod_data.drv_counter = bp->stats_counter++;
3793 ramrod_data.collect_port = bp->port.pmf ? 1 : 0; 3795 ramrod_data.collect_port = bp->port.pmf ? 1 : 0;
3794 for_each_queue(bp, i) 3796 for_each_queue(bp, i)
@@ -3802,6 +3804,8 @@ static void bnx2x_storm_stats_post(struct bnx2x *bp)
3802 bp->spq_left++; 3804 bp->spq_left++;
3803 bp->stats_pending = 1; 3805 bp->stats_pending = 1;
3804 } 3806 }
3807
3808 spin_unlock_bh(&bp->stats_lock);
3805 } 3809 }
3806} 3810}
3807 3811
@@ -4367,6 +4371,14 @@ static int bnx2x_storm_stats_update(struct bnx2x *bp)
4367 struct host_func_stats *fstats = bnx2x_sp(bp, func_stats); 4371 struct host_func_stats *fstats = bnx2x_sp(bp, func_stats);
4368 struct bnx2x_eth_stats *estats = &bp->eth_stats; 4372 struct bnx2x_eth_stats *estats = &bp->eth_stats;
4369 int i; 4373 int i;
4374 u16 cur_stats_counter;
4375
4376 /* Make sure we use the value of the counter
4377 * used for sending the last stats ramrod.
4378 */
4379 spin_lock_bh(&bp->stats_lock);
4380 cur_stats_counter = bp->stats_counter - 1;
4381 spin_unlock_bh(&bp->stats_lock);
4370 4382
4371 memcpy(&(fstats->total_bytes_received_hi), 4383 memcpy(&(fstats->total_bytes_received_hi),
4372 &(bnx2x_sp(bp, func_stats_base)->total_bytes_received_hi), 4384 &(bnx2x_sp(bp, func_stats_base)->total_bytes_received_hi),
@@ -4394,25 +4406,22 @@ static int bnx2x_storm_stats_update(struct bnx2x *bp)
4394 u32 diff; 4406 u32 diff;
4395 4407
4396 /* are storm stats valid? */ 4408 /* are storm stats valid? */
4397 if ((u16)(le16_to_cpu(xclient->stats_counter) + 1) != 4409 if (le16_to_cpu(xclient->stats_counter) != cur_stats_counter) {
4398 bp->stats_counter) {
4399 DP(BNX2X_MSG_STATS, "[%d] stats not updated by xstorm" 4410 DP(BNX2X_MSG_STATS, "[%d] stats not updated by xstorm"
4400 " xstorm counter (0x%x) != stats_counter (0x%x)\n", 4411 " xstorm counter (0x%x) != stats_counter (0x%x)\n",
4401 i, xclient->stats_counter, bp->stats_counter); 4412 i, xclient->stats_counter, cur_stats_counter + 1);
4402 return -1; 4413 return -1;
4403 } 4414 }
4404 if ((u16)(le16_to_cpu(tclient->stats_counter) + 1) != 4415 if (le16_to_cpu(tclient->stats_counter) != cur_stats_counter) {
4405 bp->stats_counter) {
4406 DP(BNX2X_MSG_STATS, "[%d] stats not updated by tstorm" 4416 DP(BNX2X_MSG_STATS, "[%d] stats not updated by tstorm"
4407 " tstorm counter (0x%x) != stats_counter (0x%x)\n", 4417 " tstorm counter (0x%x) != stats_counter (0x%x)\n",
4408 i, tclient->stats_counter, bp->stats_counter); 4418 i, tclient->stats_counter, cur_stats_counter + 1);
4409 return -2; 4419 return -2;
4410 } 4420 }
4411 if ((u16)(le16_to_cpu(uclient->stats_counter) + 1) != 4421 if (le16_to_cpu(uclient->stats_counter) != cur_stats_counter) {
4412 bp->stats_counter) {
4413 DP(BNX2X_MSG_STATS, "[%d] stats not updated by ustorm" 4422 DP(BNX2X_MSG_STATS, "[%d] stats not updated by ustorm"
4414 " ustorm counter (0x%x) != stats_counter (0x%x)\n", 4423 " ustorm counter (0x%x) != stats_counter (0x%x)\n",
4415 i, uclient->stats_counter, bp->stats_counter); 4424 i, uclient->stats_counter, cur_stats_counter + 1);
4416 return -4; 4425 return -4;
4417 } 4426 }
4418 4427
@@ -4849,16 +4858,18 @@ static const struct {
4849 4858
4850static void bnx2x_stats_handle(struct bnx2x *bp, enum bnx2x_stats_event event) 4859static void bnx2x_stats_handle(struct bnx2x *bp, enum bnx2x_stats_event event)
4851{ 4860{
4852 enum bnx2x_stats_state state = bp->stats_state; 4861 enum bnx2x_stats_state state;
4853 4862
4854 if (unlikely(bp->panic)) 4863 if (unlikely(bp->panic))
4855 return; 4864 return;
4856 4865
4857 bnx2x_stats_stm[state][event].action(bp); 4866 /* Protect a state change flow */
4867 spin_lock_bh(&bp->stats_lock);
4868 state = bp->stats_state;
4858 bp->stats_state = bnx2x_stats_stm[state][event].next_state; 4869 bp->stats_state = bnx2x_stats_stm[state][event].next_state;
4870 spin_unlock_bh(&bp->stats_lock);
4859 4871
4860 /* Make sure the state has been "changed" */ 4872 bnx2x_stats_stm[state][event].action(bp);
4861 smp_wmb();
4862 4873
4863 if ((event != STATS_EVENT_UPDATE) || netif_msg_timer(bp)) 4874 if ((event != STATS_EVENT_UPDATE) || netif_msg_timer(bp))
4864 DP(BNX2X_MSG_STATS, "state %d -> event %d -> state %d\n", 4875 DP(BNX2X_MSG_STATS, "state %d -> event %d -> state %d\n",
@@ -9908,6 +9919,7 @@ static int __devinit bnx2x_init_bp(struct bnx2x *bp)
9908 9919
9909 mutex_init(&bp->port.phy_mutex); 9920 mutex_init(&bp->port.phy_mutex);
9910 mutex_init(&bp->fw_mb_mutex); 9921 mutex_init(&bp->fw_mb_mutex);
9922 spin_lock_init(&bp->stats_lock);
9911#ifdef BCM_CNIC 9923#ifdef BCM_CNIC
9912 mutex_init(&bp->cnic_mutex); 9924 mutex_init(&bp->cnic_mutex);
9913#endif 9925#endif
diff --git a/drivers/net/bonding/bond_alb.c b/drivers/net/bonding/bond_alb.c
index 40fdc41446cc..8d7dfd2f1e90 100644
--- a/drivers/net/bonding/bond_alb.c
+++ b/drivers/net/bonding/bond_alb.c
@@ -340,7 +340,8 @@ static void rlb_update_entry_from_arp(struct bonding *bond, struct arp_pkt *arp)
340 340
341 if ((client_info->assigned) && 341 if ((client_info->assigned) &&
342 (client_info->ip_src == arp->ip_dst) && 342 (client_info->ip_src == arp->ip_dst) &&
343 (client_info->ip_dst == arp->ip_src)) { 343 (client_info->ip_dst == arp->ip_src) &&
344 (compare_ether_addr_64bits(client_info->mac_dst, arp->mac_src))) {
344 /* update the clients MAC address */ 345 /* update the clients MAC address */
345 memcpy(client_info->mac_dst, arp->mac_src, ETH_ALEN); 346 memcpy(client_info->mac_dst, arp->mac_src, ETH_ALEN);
346 client_info->ntt = 1; 347 client_info->ntt = 1;
@@ -821,7 +822,7 @@ static int rlb_initialize(struct bonding *bond)
821 822
822 /*initialize packet type*/ 823 /*initialize packet type*/
823 pk_type->type = cpu_to_be16(ETH_P_ARP); 824 pk_type->type = cpu_to_be16(ETH_P_ARP);
824 pk_type->dev = NULL; 825 pk_type->dev = bond->dev;
825 pk_type->func = rlb_arp_recv; 826 pk_type->func = rlb_arp_recv;
826 827
827 /* register to receive ARPs */ 828 /* register to receive ARPs */
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index 5e12462a9d5e..c3d98dde2f86 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -168,7 +168,7 @@ static int arp_ip_count;
168static int bond_mode = BOND_MODE_ROUNDROBIN; 168static int bond_mode = BOND_MODE_ROUNDROBIN;
169static int xmit_hashtype = BOND_XMIT_POLICY_LAYER2; 169static int xmit_hashtype = BOND_XMIT_POLICY_LAYER2;
170static int lacp_fast; 170static int lacp_fast;
171 171static int disable_netpoll = 1;
172 172
173const struct bond_parm_tbl bond_lacp_tbl[] = { 173const struct bond_parm_tbl bond_lacp_tbl[] = {
174{ "slow", AD_LACP_SLOW}, 174{ "slow", AD_LACP_SLOW},
@@ -1742,15 +1742,23 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev)
1742 bond_set_carrier(bond); 1742 bond_set_carrier(bond);
1743 1743
1744#ifdef CONFIG_NET_POLL_CONTROLLER 1744#ifdef CONFIG_NET_POLL_CONTROLLER
1745 if (slaves_support_netpoll(bond_dev)) { 1745 /*
1746 bond_dev->priv_flags &= ~IFF_DISABLE_NETPOLL; 1746 * Netpoll and bonding is broken, make sure it is not initialized
1747 if (bond_dev->npinfo) 1747 * until it is fixed.
1748 slave_dev->npinfo = bond_dev->npinfo; 1748 */
1749 } else if (!(bond_dev->priv_flags & IFF_DISABLE_NETPOLL)) { 1749 if (disable_netpoll) {
1750 bond_dev->priv_flags |= IFF_DISABLE_NETPOLL; 1750 bond_dev->priv_flags |= IFF_DISABLE_NETPOLL;
1751 pr_info("New slave device %s does not support netpoll\n", 1751 } else {
1752 slave_dev->name); 1752 if (slaves_support_netpoll(bond_dev)) {
1753 pr_info("Disabling netpoll support for %s\n", bond_dev->name); 1753 bond_dev->priv_flags &= ~IFF_DISABLE_NETPOLL;
1754 if (bond_dev->npinfo)
1755 slave_dev->npinfo = bond_dev->npinfo;
1756 } else if (!(bond_dev->priv_flags & IFF_DISABLE_NETPOLL)) {
1757 bond_dev->priv_flags |= IFF_DISABLE_NETPOLL;
1758 pr_info("New slave device %s does not support netpoll\n",
1759 slave_dev->name);
1760 pr_info("Disabling netpoll support for %s\n", bond_dev->name);
1761 }
1754 } 1762 }
1755#endif 1763#endif
1756 read_unlock(&bond->lock); 1764 read_unlock(&bond->lock);
@@ -1950,8 +1958,11 @@ int bond_release(struct net_device *bond_dev, struct net_device *slave_dev)
1950 1958
1951#ifdef CONFIG_NET_POLL_CONTROLLER 1959#ifdef CONFIG_NET_POLL_CONTROLLER
1952 read_lock_bh(&bond->lock); 1960 read_lock_bh(&bond->lock);
1953 if (slaves_support_netpoll(bond_dev)) 1961
1954 bond_dev->priv_flags &= ~IFF_DISABLE_NETPOLL; 1962 /* Make sure netpoll over stays disabled until fixed. */
1963 if (!disable_netpoll)
1964 if (slaves_support_netpoll(bond_dev))
1965 bond_dev->priv_flags &= ~IFF_DISABLE_NETPOLL;
1955 read_unlock_bh(&bond->lock); 1966 read_unlock_bh(&bond->lock);
1956 if (slave_dev->netdev_ops->ndo_netpoll_cleanup) 1967 if (slave_dev->netdev_ops->ndo_netpoll_cleanup)
1957 slave_dev->netdev_ops->ndo_netpoll_cleanup(slave_dev); 1968 slave_dev->netdev_ops->ndo_netpoll_cleanup(slave_dev);
diff --git a/drivers/net/cnic.c b/drivers/net/cnic.c
index fe925663d39a..80471269977a 100644
--- a/drivers/net/cnic.c
+++ b/drivers/net/cnic.c
@@ -3919,8 +3919,9 @@ static void cnic_init_bnx2x_tx_ring(struct cnic_dev *dev)
3919 HC_INDEX_DEF_C_ETH_ISCSI_CQ_CONS; 3919 HC_INDEX_DEF_C_ETH_ISCSI_CQ_CONS;
3920 context->cstorm_st_context.status_block_id = BNX2X_DEF_SB_ID; 3920 context->cstorm_st_context.status_block_id = BNX2X_DEF_SB_ID;
3921 3921
3922 context->xstorm_st_context.statistics_data = (cli | 3922 if (cli < MAX_X_STAT_COUNTER_ID)
3923 XSTORM_ETH_ST_CONTEXT_STATISTICS_ENABLE); 3923 context->xstorm_st_context.statistics_data = cli |
3924 XSTORM_ETH_ST_CONTEXT_STATISTICS_ENABLE;
3924 3925
3925 context->xstorm_ag_context.cdu_reserved = 3926 context->xstorm_ag_context.cdu_reserved =
3926 CDU_RSRVD_VALUE_TYPE_A(BNX2X_HW_CID(BNX2X_ISCSI_L2_CID, func), 3927 CDU_RSRVD_VALUE_TYPE_A(BNX2X_HW_CID(BNX2X_ISCSI_L2_CID, func),
@@ -3928,10 +3929,12 @@ static void cnic_init_bnx2x_tx_ring(struct cnic_dev *dev)
3928 ETH_CONNECTION_TYPE); 3929 ETH_CONNECTION_TYPE);
3929 3930
3930 /* reset xstorm per client statistics */ 3931 /* reset xstorm per client statistics */
3931 val = BAR_XSTRORM_INTMEM + 3932 if (cli < MAX_X_STAT_COUNTER_ID) {
3932 XSTORM_PER_COUNTER_ID_STATS_OFFSET(port, cli); 3933 val = BAR_XSTRORM_INTMEM +
3933 for (i = 0; i < sizeof(struct xstorm_per_client_stats) / 4; i++) 3934 XSTORM_PER_COUNTER_ID_STATS_OFFSET(port, cli);
3934 CNIC_WR(dev, val + i * 4, 0); 3935 for (i = 0; i < sizeof(struct xstorm_per_client_stats) / 4; i++)
3936 CNIC_WR(dev, val + i * 4, 0);
3937 }
3935 3938
3936 cp->tx_cons_ptr = 3939 cp->tx_cons_ptr =
3937 &cp->bnx2x_def_status_blk->c_def_status_block.index_values[ 3940 &cp->bnx2x_def_status_blk->c_def_status_block.index_values[
@@ -3978,9 +3981,11 @@ static void cnic_init_bnx2x_rx_ring(struct cnic_dev *dev)
3978 BNX2X_ISCSI_RX_SB_INDEX_NUM; 3981 BNX2X_ISCSI_RX_SB_INDEX_NUM;
3979 context->ustorm_st_context.common.clientId = cli; 3982 context->ustorm_st_context.common.clientId = cli;
3980 context->ustorm_st_context.common.status_block_id = BNX2X_DEF_SB_ID; 3983 context->ustorm_st_context.common.status_block_id = BNX2X_DEF_SB_ID;
3981 context->ustorm_st_context.common.flags = 3984 if (cli < MAX_U_STAT_COUNTER_ID) {
3982 USTORM_ETH_ST_CONTEXT_CONFIG_ENABLE_STATISTICS; 3985 context->ustorm_st_context.common.flags =
3983 context->ustorm_st_context.common.statistics_counter_id = cli; 3986 USTORM_ETH_ST_CONTEXT_CONFIG_ENABLE_STATISTICS;
3987 context->ustorm_st_context.common.statistics_counter_id = cli;
3988 }
3984 context->ustorm_st_context.common.mc_alignment_log_size = 0; 3989 context->ustorm_st_context.common.mc_alignment_log_size = 0;
3985 context->ustorm_st_context.common.bd_buff_size = 3990 context->ustorm_st_context.common.bd_buff_size =
3986 cp->l2_single_buf_size; 3991 cp->l2_single_buf_size;
@@ -4011,10 +4016,13 @@ static void cnic_init_bnx2x_rx_ring(struct cnic_dev *dev)
4011 4016
4012 /* client tstorm info */ 4017 /* client tstorm info */
4013 tstorm_client.mtu = cp->l2_single_buf_size - 14; 4018 tstorm_client.mtu = cp->l2_single_buf_size - 14;
4014 tstorm_client.config_flags = 4019 tstorm_client.config_flags = TSTORM_ETH_CLIENT_CONFIG_E1HOV_REM_ENABLE;
4015 (TSTORM_ETH_CLIENT_CONFIG_E1HOV_REM_ENABLE | 4020
4016 TSTORM_ETH_CLIENT_CONFIG_STATSITICS_ENABLE); 4021 if (cli < MAX_T_STAT_COUNTER_ID) {
4017 tstorm_client.statistics_counter_id = cli; 4022 tstorm_client.config_flags |=
4023 TSTORM_ETH_CLIENT_CONFIG_STATSITICS_ENABLE;
4024 tstorm_client.statistics_counter_id = cli;
4025 }
4018 4026
4019 CNIC_WR(dev, BAR_TSTRORM_INTMEM + 4027 CNIC_WR(dev, BAR_TSTRORM_INTMEM +
4020 TSTORM_CLIENT_CONFIG_OFFSET(port, cli), 4028 TSTORM_CLIENT_CONFIG_OFFSET(port, cli),
@@ -4024,16 +4032,21 @@ static void cnic_init_bnx2x_rx_ring(struct cnic_dev *dev)
4024 ((u32 *)&tstorm_client)[1]); 4032 ((u32 *)&tstorm_client)[1]);
4025 4033
4026 /* reset tstorm per client statistics */ 4034 /* reset tstorm per client statistics */
4027 val = BAR_TSTRORM_INTMEM + 4035 if (cli < MAX_T_STAT_COUNTER_ID) {
4028 TSTORM_PER_COUNTER_ID_STATS_OFFSET(port, cli); 4036
4029 for (i = 0; i < sizeof(struct tstorm_per_client_stats) / 4; i++) 4037 val = BAR_TSTRORM_INTMEM +
4030 CNIC_WR(dev, val + i * 4, 0); 4038 TSTORM_PER_COUNTER_ID_STATS_OFFSET(port, cli);
4039 for (i = 0; i < sizeof(struct tstorm_per_client_stats) / 4; i++)
4040 CNIC_WR(dev, val + i * 4, 0);
4041 }
4031 4042
4032 /* reset ustorm per client statistics */ 4043 /* reset ustorm per client statistics */
4033 val = BAR_USTRORM_INTMEM + 4044 if (cli < MAX_U_STAT_COUNTER_ID) {
4034 USTORM_PER_COUNTER_ID_STATS_OFFSET(port, cli); 4045 val = BAR_USTRORM_INTMEM +
4035 for (i = 0; i < sizeof(struct ustorm_per_client_stats) / 4; i++) 4046 USTORM_PER_COUNTER_ID_STATS_OFFSET(port, cli);
4036 CNIC_WR(dev, val + i * 4, 0); 4047 for (i = 0; i < sizeof(struct ustorm_per_client_stats) / 4; i++)
4048 CNIC_WR(dev, val + i * 4, 0);
4049 }
4037 4050
4038 cp->rx_cons_ptr = 4051 cp->rx_cons_ptr =
4039 &cp->bnx2x_def_status_blk->u_def_status_block.index_values[ 4052 &cp->bnx2x_def_status_blk->u_def_status_block.index_values[
diff --git a/drivers/net/cpmac.c b/drivers/net/cpmac.c
index 3c58db595285..23786ee34bed 100644
--- a/drivers/net/cpmac.c
+++ b/drivers/net/cpmac.c
@@ -1181,7 +1181,8 @@ static int __devinit cpmac_probe(struct platform_device *pdev)
1181 if (netif_msg_drv(priv)) 1181 if (netif_msg_drv(priv))
1182 printk(KERN_ERR "%s: Could not attach to PHY\n", 1182 printk(KERN_ERR "%s: Could not attach to PHY\n",
1183 dev->name); 1183 dev->name);
1184 return PTR_ERR(priv->phy); 1184 rc = PTR_ERR(priv->phy);
1185 goto fail;
1185 } 1186 }
1186 1187
1187 if ((rc = register_netdev(dev))) { 1188 if ((rc = register_netdev(dev))) {
diff --git a/drivers/net/declance.c b/drivers/net/declance.c
index 1d973db27c32..d7de376d7178 100644
--- a/drivers/net/declance.c
+++ b/drivers/net/declance.c
@@ -1022,7 +1022,7 @@ static const struct net_device_ops lance_netdev_ops = {
1022 .ndo_set_mac_address = eth_mac_addr, 1022 .ndo_set_mac_address = eth_mac_addr,
1023}; 1023};
1024 1024
1025static int __init dec_lance_probe(struct device *bdev, const int type) 1025static int __devinit dec_lance_probe(struct device *bdev, const int type)
1026{ 1026{
1027 static unsigned version_printed; 1027 static unsigned version_printed;
1028 static const char fmt[] = "declance%d"; 1028 static const char fmt[] = "declance%d";
@@ -1326,7 +1326,7 @@ static void __exit dec_lance_platform_remove(void)
1326} 1326}
1327 1327
1328#ifdef CONFIG_TC 1328#ifdef CONFIG_TC
1329static int __init dec_lance_tc_probe(struct device *dev); 1329static int __devinit dec_lance_tc_probe(struct device *dev);
1330static int __exit dec_lance_tc_remove(struct device *dev); 1330static int __exit dec_lance_tc_remove(struct device *dev);
1331 1331
1332static const struct tc_device_id dec_lance_tc_table[] = { 1332static const struct tc_device_id dec_lance_tc_table[] = {
@@ -1345,7 +1345,7 @@ static struct tc_driver dec_lance_tc_driver = {
1345 }, 1345 },
1346}; 1346};
1347 1347
1348static int __init dec_lance_tc_probe(struct device *dev) 1348static int __devinit dec_lance_tc_probe(struct device *dev)
1349{ 1349{
1350 int status = dec_lance_probe(dev, PMAD_LANCE); 1350 int status = dec_lance_probe(dev, PMAD_LANCE);
1351 if (!status) 1351 if (!status)
diff --git a/drivers/net/e1000/e1000_main.c b/drivers/net/e1000/e1000_main.c
index ebdea0891665..68a80893dce1 100644
--- a/drivers/net/e1000/e1000_main.c
+++ b/drivers/net/e1000/e1000_main.c
@@ -1047,15 +1047,14 @@ static int __devinit e1000_probe(struct pci_dev *pdev,
1047 goto err_register; 1047 goto err_register;
1048 1048
1049 /* print bus type/speed/width info */ 1049 /* print bus type/speed/width info */
1050 e_info("(PCI%s:%s:%s) ", 1050 e_info("(PCI%s:%dMHz:%d-bit) %pM\n",
1051 ((hw->bus_type == e1000_bus_type_pcix) ? "-X" : ""), 1051 ((hw->bus_type == e1000_bus_type_pcix) ? "-X" : ""),
1052 ((hw->bus_speed == e1000_bus_speed_133) ? "133MHz" : 1052 ((hw->bus_speed == e1000_bus_speed_133) ? 133 :
1053 (hw->bus_speed == e1000_bus_speed_120) ? "120MHz" : 1053 (hw->bus_speed == e1000_bus_speed_120) ? 120 :
1054 (hw->bus_speed == e1000_bus_speed_100) ? "100MHz" : 1054 (hw->bus_speed == e1000_bus_speed_100) ? 100 :
1055 (hw->bus_speed == e1000_bus_speed_66) ? "66MHz" : "33MHz"), 1055 (hw->bus_speed == e1000_bus_speed_66) ? 66 : 33),
1056 ((hw->bus_width == e1000_bus_width_64) ? "64-bit" : "32-bit")); 1056 ((hw->bus_width == e1000_bus_width_64) ? 64 : 32),
1057 1057 netdev->dev_addr);
1058 e_info("%pM\n", netdev->dev_addr);
1059 1058
1060 /* carrier off reporting is important to ethtool even BEFORE open */ 1059 /* carrier off reporting is important to ethtool even BEFORE open */
1061 netif_carrier_off(netdev); 1060 netif_carrier_off(netdev);
diff --git a/drivers/net/ehea/ehea.h b/drivers/net/ehea/ehea.h
index 0630980a2722..0060e422f171 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_0103" 43#define DRV_VERSION "EHEA_0105"
44 44
45/* eHEA capability flags */ 45/* eHEA capability flags */
46#define DLPAR_PORT_ADD_REM 1 46#define DLPAR_PORT_ADD_REM 1
diff --git a/drivers/net/ehea/ehea_main.c b/drivers/net/ehea/ehea_main.c
index f547894ff48f..8b92acb448c2 100644
--- a/drivers/net/ehea/ehea_main.c
+++ b/drivers/net/ehea/ehea_main.c
@@ -867,6 +867,7 @@ static int ehea_poll(struct napi_struct *napi, int budget)
867 ehea_reset_cq_ep(pr->send_cq); 867 ehea_reset_cq_ep(pr->send_cq);
868 ehea_reset_cq_n1(pr->recv_cq); 868 ehea_reset_cq_n1(pr->recv_cq);
869 ehea_reset_cq_n1(pr->send_cq); 869 ehea_reset_cq_n1(pr->send_cq);
870 rmb();
870 cqe = ehea_poll_rq1(pr->qp, &wqe_index); 871 cqe = ehea_poll_rq1(pr->qp, &wqe_index);
871 cqe_skb = ehea_poll_cq(pr->send_cq); 872 cqe_skb = ehea_poll_cq(pr->send_cq);
872 873
@@ -2859,6 +2860,7 @@ static void ehea_reset_port(struct work_struct *work)
2859 container_of(work, struct ehea_port, reset_task); 2860 container_of(work, struct ehea_port, reset_task);
2860 struct net_device *dev = port->netdev; 2861 struct net_device *dev = port->netdev;
2861 2862
2863 mutex_lock(&dlpar_mem_lock);
2862 port->resets++; 2864 port->resets++;
2863 mutex_lock(&port->port_lock); 2865 mutex_lock(&port->port_lock);
2864 netif_stop_queue(dev); 2866 netif_stop_queue(dev);
@@ -2881,6 +2883,7 @@ static void ehea_reset_port(struct work_struct *work)
2881 netif_wake_queue(dev); 2883 netif_wake_queue(dev);
2882out: 2884out:
2883 mutex_unlock(&port->port_lock); 2885 mutex_unlock(&port->port_lock);
2886 mutex_unlock(&dlpar_mem_lock);
2884} 2887}
2885 2888
2886static void ehea_rereg_mrs(struct work_struct *work) 2889static void ehea_rereg_mrs(struct work_struct *work)
@@ -3542,10 +3545,7 @@ static int ehea_mem_notifier(struct notifier_block *nb,
3542 int ret = NOTIFY_BAD; 3545 int ret = NOTIFY_BAD;
3543 struct memory_notify *arg = data; 3546 struct memory_notify *arg = data;
3544 3547
3545 if (!mutex_trylock(&dlpar_mem_lock)) { 3548 mutex_lock(&dlpar_mem_lock);
3546 ehea_info("ehea_mem_notifier must not be called parallelized");
3547 goto out;
3548 }
3549 3549
3550 switch (action) { 3550 switch (action) {
3551 case MEM_CANCEL_OFFLINE: 3551 case MEM_CANCEL_OFFLINE:
@@ -3574,7 +3574,6 @@ static int ehea_mem_notifier(struct notifier_block *nb,
3574 3574
3575out_unlock: 3575out_unlock:
3576 mutex_unlock(&dlpar_mem_lock); 3576 mutex_unlock(&dlpar_mem_lock);
3577out:
3578 return ret; 3577 return ret;
3579} 3578}
3580 3579
diff --git a/drivers/net/enic/vnic_dev.c b/drivers/net/enic/vnic_dev.c
index 2b3e16db5c82..e0d33281ec98 100644
--- a/drivers/net/enic/vnic_dev.c
+++ b/drivers/net/enic/vnic_dev.c
@@ -709,7 +709,7 @@ int vnic_dev_init_prov(struct vnic_dev *vdev, u8 *buf, u32 len)
709{ 709{
710 u64 a0, a1 = len; 710 u64 a0, a1 = len;
711 int wait = 1000; 711 int wait = 1000;
712 u64 prov_pa; 712 dma_addr_t prov_pa;
713 void *prov_buf; 713 void *prov_buf;
714 int ret; 714 int ret;
715 715
diff --git a/drivers/net/gianfar.c b/drivers/net/gianfar.c
index ba190376e030..efd4c70753db 100644
--- a/drivers/net/gianfar.c
+++ b/drivers/net/gianfar.c
@@ -381,10 +381,14 @@ static void gfar_init_mac(struct net_device *ndev)
381 /* Insert receive time stamps into padding alignment bytes */ 381 /* Insert receive time stamps into padding alignment bytes */
382 if (priv->device_flags & FSL_GIANFAR_DEV_HAS_TIMER) { 382 if (priv->device_flags & FSL_GIANFAR_DEV_HAS_TIMER) {
383 rctrl &= ~RCTRL_PAL_MASK; 383 rctrl &= ~RCTRL_PAL_MASK;
384 rctrl |= RCTRL_PRSDEP_INIT | RCTRL_TS_ENABLE | RCTRL_PADDING(8); 384 rctrl |= RCTRL_PADDING(8);
385 priv->padding = 8; 385 priv->padding = 8;
386 } 386 }
387 387
388 /* Enable HW time stamping if requested from user space */
389 if (priv->hwts_rx_en)
390 rctrl |= RCTRL_PRSDEP_INIT | RCTRL_TS_ENABLE;
391
388 /* keep vlan related bits if it's enabled */ 392 /* keep vlan related bits if it's enabled */
389 if (priv->vlgrp) { 393 if (priv->vlgrp) {
390 rctrl |= RCTRL_VLEX | RCTRL_PRSDEP_INIT; 394 rctrl |= RCTRL_VLEX | RCTRL_PRSDEP_INIT;
@@ -747,7 +751,8 @@ static int gfar_of_init(struct of_device *ofdev, struct net_device **pdev)
747 FSL_GIANFAR_DEV_HAS_CSUM | 751 FSL_GIANFAR_DEV_HAS_CSUM |
748 FSL_GIANFAR_DEV_HAS_VLAN | 752 FSL_GIANFAR_DEV_HAS_VLAN |
749 FSL_GIANFAR_DEV_HAS_MAGIC_PACKET | 753 FSL_GIANFAR_DEV_HAS_MAGIC_PACKET |
750 FSL_GIANFAR_DEV_HAS_EXTENDED_HASH; 754 FSL_GIANFAR_DEV_HAS_EXTENDED_HASH |
755 FSL_GIANFAR_DEV_HAS_TIMER;
751 756
752 ctype = of_get_property(np, "phy-connection-type", NULL); 757 ctype = of_get_property(np, "phy-connection-type", NULL);
753 758
@@ -805,12 +810,20 @@ static int gfar_hwtstamp_ioctl(struct net_device *netdev,
805 810
806 switch (config.rx_filter) { 811 switch (config.rx_filter) {
807 case HWTSTAMP_FILTER_NONE: 812 case HWTSTAMP_FILTER_NONE:
808 priv->hwts_rx_en = 0; 813 if (priv->hwts_rx_en) {
814 stop_gfar(netdev);
815 priv->hwts_rx_en = 0;
816 startup_gfar(netdev);
817 }
809 break; 818 break;
810 default: 819 default:
811 if (!(priv->device_flags & FSL_GIANFAR_DEV_HAS_TIMER)) 820 if (!(priv->device_flags & FSL_GIANFAR_DEV_HAS_TIMER))
812 return -ERANGE; 821 return -ERANGE;
813 priv->hwts_rx_en = 1; 822 if (!priv->hwts_rx_en) {
823 stop_gfar(netdev);
824 priv->hwts_rx_en = 1;
825 startup_gfar(netdev);
826 }
814 config.rx_filter = HWTSTAMP_FILTER_ALL; 827 config.rx_filter = HWTSTAMP_FILTER_ALL;
815 break; 828 break;
816 } 829 }
@@ -2642,6 +2655,10 @@ int gfar_clean_rx_ring(struct gfar_priv_rx_q *rx_queue, int rx_work_limit)
2642 dma_unmap_single(&priv->ofdev->dev, bdp->bufPtr, 2655 dma_unmap_single(&priv->ofdev->dev, bdp->bufPtr,
2643 priv->rx_buffer_size, DMA_FROM_DEVICE); 2656 priv->rx_buffer_size, DMA_FROM_DEVICE);
2644 2657
2658 if (unlikely(!(bdp->status & RXBD_ERR) &&
2659 bdp->length > priv->rx_buffer_size))
2660 bdp->status = RXBD_LARGE;
2661
2645 /* We drop the frame if we failed to allocate a new buffer */ 2662 /* We drop the frame if we failed to allocate a new buffer */
2646 if (unlikely(!newskb || !(bdp->status & RXBD_LAST) || 2663 if (unlikely(!newskb || !(bdp->status & RXBD_LAST) ||
2647 bdp->status & RXBD_ERR)) { 2664 bdp->status & RXBD_ERR)) {
diff --git a/drivers/net/ibmveth.c b/drivers/net/ibmveth.c
index 7acb3edc47ef..2602852cc55a 100644
--- a/drivers/net/ibmveth.c
+++ b/drivers/net/ibmveth.c
@@ -677,7 +677,7 @@ static int ibmveth_close(struct net_device *netdev)
677 if (!adapter->pool_config) 677 if (!adapter->pool_config)
678 netif_stop_queue(netdev); 678 netif_stop_queue(netdev);
679 679
680 free_irq(netdev->irq, netdev); 680 h_vio_signal(adapter->vdev->unit_address, VIO_IRQ_DISABLE);
681 681
682 do { 682 do {
683 lpar_rc = h_free_logical_lan(adapter->vdev->unit_address); 683 lpar_rc = h_free_logical_lan(adapter->vdev->unit_address);
@@ -689,6 +689,8 @@ static int ibmveth_close(struct net_device *netdev)
689 lpar_rc); 689 lpar_rc);
690 } 690 }
691 691
692 free_irq(netdev->irq, netdev);
693
692 adapter->rx_no_buffer = *(u64*)(((char*)adapter->buffer_list_addr) + 4096 - 8); 694 adapter->rx_no_buffer = *(u64*)(((char*)adapter->buffer_list_addr) + 4096 - 8);
693 695
694 ibmveth_cleanup(adapter); 696 ibmveth_cleanup(adapter);
diff --git a/drivers/net/igb/igb_main.c b/drivers/net/igb/igb_main.c
index 3881918f5382..cea37e0837ff 100644
--- a/drivers/net/igb/igb_main.c
+++ b/drivers/net/igb/igb_main.c
@@ -1722,6 +1722,15 @@ static int __devinit igb_probe(struct pci_dev *pdev,
1722 u16 eeprom_apme_mask = IGB_EEPROM_APME; 1722 u16 eeprom_apme_mask = IGB_EEPROM_APME;
1723 u32 part_num; 1723 u32 part_num;
1724 1724
1725 /* Catch broken hardware that put the wrong VF device ID in
1726 * the PCIe SR-IOV capability.
1727 */
1728 if (pdev->is_virtfn) {
1729 WARN(1, KERN_ERR "%s (%hx:%hx) should not be a VF!\n",
1730 pci_name(pdev), pdev->vendor, pdev->device);
1731 return -EINVAL;
1732 }
1733
1725 err = pci_enable_device_mem(pdev); 1734 err = pci_enable_device_mem(pdev);
1726 if (err) 1735 if (err)
1727 return err; 1736 return err;
diff --git a/drivers/net/ixgbe/ixgbe_ethtool.c b/drivers/net/ixgbe/ixgbe_ethtool.c
index c50a7541ffec..3a93a81872b8 100644
--- a/drivers/net/ixgbe/ixgbe_ethtool.c
+++ b/drivers/net/ixgbe/ixgbe_ethtool.c
@@ -2077,25 +2077,6 @@ static int ixgbe_get_coalesce(struct net_device *netdev,
2077 return 0; 2077 return 0;
2078} 2078}
2079 2079
2080/*
2081 * this function must be called before setting the new value of
2082 * rx_itr_setting
2083 */
2084static bool ixgbe_reenable_rsc(struct ixgbe_adapter *adapter,
2085 struct ethtool_coalesce *ec)
2086{
2087 /* check the old value and enable RSC if necessary */
2088 if ((adapter->rx_itr_setting == 0) &&
2089 (adapter->flags2 & IXGBE_FLAG2_RSC_CAPABLE)) {
2090 adapter->flags2 |= IXGBE_FLAG2_RSC_ENABLED;
2091 adapter->netdev->features |= NETIF_F_LRO;
2092 DPRINTK(PROBE, INFO, "rx-usecs set to %d, re-enabling RSC\n",
2093 ec->rx_coalesce_usecs);
2094 return true;
2095 }
2096 return false;
2097}
2098
2099static int ixgbe_set_coalesce(struct net_device *netdev, 2080static int ixgbe_set_coalesce(struct net_device *netdev,
2100 struct ethtool_coalesce *ec) 2081 struct ethtool_coalesce *ec)
2101{ 2082{
@@ -2124,9 +2105,6 @@ static int ixgbe_set_coalesce(struct net_device *netdev,
2124 (1000000/ec->rx_coalesce_usecs < IXGBE_MIN_INT_RATE)) 2105 (1000000/ec->rx_coalesce_usecs < IXGBE_MIN_INT_RATE))
2125 return -EINVAL; 2106 return -EINVAL;
2126 2107
2127 /* check the old value and enable RSC if necessary */
2128 need_reset = ixgbe_reenable_rsc(adapter, ec);
2129
2130 /* store the value in ints/second */ 2108 /* store the value in ints/second */
2131 adapter->rx_eitr_param = 1000000/ec->rx_coalesce_usecs; 2109 adapter->rx_eitr_param = 1000000/ec->rx_coalesce_usecs;
2132 2110
@@ -2135,9 +2113,6 @@ static int ixgbe_set_coalesce(struct net_device *netdev,
2135 /* clear the lower bit as its used for dynamic state */ 2113 /* clear the lower bit as its used for dynamic state */
2136 adapter->rx_itr_setting &= ~1; 2114 adapter->rx_itr_setting &= ~1;
2137 } else if (ec->rx_coalesce_usecs == 1) { 2115 } else if (ec->rx_coalesce_usecs == 1) {
2138 /* check the old value and enable RSC if necessary */
2139 need_reset = ixgbe_reenable_rsc(adapter, ec);
2140
2141 /* 1 means dynamic mode */ 2116 /* 1 means dynamic mode */
2142 adapter->rx_eitr_param = 20000; 2117 adapter->rx_eitr_param = 20000;
2143 adapter->rx_itr_setting = 1; 2118 adapter->rx_itr_setting = 1;
@@ -2157,10 +2132,11 @@ static int ixgbe_set_coalesce(struct net_device *netdev,
2157 */ 2132 */
2158 if (adapter->flags2 & IXGBE_FLAG2_RSC_ENABLED) { 2133 if (adapter->flags2 & IXGBE_FLAG2_RSC_ENABLED) {
2159 adapter->flags2 &= ~IXGBE_FLAG2_RSC_ENABLED; 2134 adapter->flags2 &= ~IXGBE_FLAG2_RSC_ENABLED;
2160 netdev->features &= ~NETIF_F_LRO; 2135 if (netdev->features & NETIF_F_LRO) {
2161 DPRINTK(PROBE, INFO, 2136 netdev->features &= ~NETIF_F_LRO;
2162 "rx-usecs set to 0, disabling RSC\n"); 2137 DPRINTK(PROBE, INFO, "rx-usecs set to 0, "
2163 2138 "disabling LRO/RSC\n");
2139 }
2164 need_reset = true; 2140 need_reset = true;
2165 } 2141 }
2166 } 2142 }
@@ -2255,6 +2231,9 @@ static int ixgbe_set_flags(struct net_device *netdev, u32 data)
2255 } 2231 }
2256 } else if (!adapter->rx_itr_setting) { 2232 } else if (!adapter->rx_itr_setting) {
2257 netdev->features &= ~ETH_FLAG_LRO; 2233 netdev->features &= ~ETH_FLAG_LRO;
2234 if (data & ETH_FLAG_LRO)
2235 DPRINTK(PROBE, INFO, "rx-usecs set to 0, "
2236 "LRO/RSC cannot be enabled.\n");
2258 } 2237 }
2259 } 2238 }
2260 2239
diff --git a/drivers/net/ixgbe/ixgbe_main.c b/drivers/net/ixgbe/ixgbe_main.c
index b2af2f67f604..74d9b6df3029 100644
--- a/drivers/net/ixgbe/ixgbe_main.c
+++ b/drivers/net/ixgbe/ixgbe_main.c
@@ -3684,10 +3684,6 @@ void ixgbe_down(struct ixgbe_adapter *adapter)
3684 /* signal that we are down to the interrupt handler */ 3684 /* signal that we are down to the interrupt handler */
3685 set_bit(__IXGBE_DOWN, &adapter->state); 3685 set_bit(__IXGBE_DOWN, &adapter->state);
3686 3686
3687 /* power down the optics */
3688 if (hw->phy.multispeed_fiber)
3689 hw->mac.ops.disable_tx_laser(hw);
3690
3691 /* disable receive for all VFs and wait one second */ 3687 /* disable receive for all VFs and wait one second */
3692 if (adapter->num_vfs) { 3688 if (adapter->num_vfs) {
3693 /* ping all the active vfs to let them know we are going down */ 3689 /* ping all the active vfs to let them know we are going down */
@@ -3742,6 +3738,10 @@ void ixgbe_down(struct ixgbe_adapter *adapter)
3742 (IXGBE_READ_REG(hw, IXGBE_DMATXCTL) & 3738 (IXGBE_READ_REG(hw, IXGBE_DMATXCTL) &
3743 ~IXGBE_DMATXCTL_TE)); 3739 ~IXGBE_DMATXCTL_TE));
3744 3740
3741 /* power down the optics */
3742 if (hw->phy.multispeed_fiber)
3743 hw->mac.ops.disable_tx_laser(hw);
3744
3745 /* clear n-tuple filters that are cached */ 3745 /* clear n-tuple filters that are cached */
3746 ethtool_ntuple_flush(netdev); 3746 ethtool_ntuple_flush(netdev);
3747 3747
@@ -4001,7 +4001,7 @@ static void ixgbe_set_num_queues(struct ixgbe_adapter *adapter)
4001 4001
4002done: 4002done:
4003 /* Notify the stack of the (possibly) reduced Tx Queue count. */ 4003 /* Notify the stack of the (possibly) reduced Tx Queue count. */
4004 adapter->netdev->real_num_tx_queues = adapter->num_tx_queues; 4004 netif_set_real_num_tx_queues(adapter->netdev, adapter->num_tx_queues);
4005} 4005}
4006 4006
4007static void ixgbe_acquire_msix_vectors(struct ixgbe_adapter *adapter, 4007static void ixgbe_acquire_msix_vectors(struct ixgbe_adapter *adapter,
@@ -5195,7 +5195,6 @@ static int __ixgbe_shutdown(struct pci_dev *pdev, bool *enable_wake)
5195 ixgbe_free_all_tx_resources(adapter); 5195 ixgbe_free_all_tx_resources(adapter);
5196 ixgbe_free_all_rx_resources(adapter); 5196 ixgbe_free_all_rx_resources(adapter);
5197 } 5197 }
5198 ixgbe_clear_interrupt_scheme(adapter);
5199 5198
5200#ifdef CONFIG_PM 5199#ifdef CONFIG_PM
5201 retval = pci_save_state(pdev); 5200 retval = pci_save_state(pdev);
@@ -5230,6 +5229,8 @@ static int __ixgbe_shutdown(struct pci_dev *pdev, bool *enable_wake)
5230 5229
5231 *enable_wake = !!wufc; 5230 *enable_wake = !!wufc;
5232 5231
5232 ixgbe_clear_interrupt_scheme(adapter);
5233
5233 ixgbe_release_hw_control(adapter); 5234 ixgbe_release_hw_control(adapter);
5234 5235
5235 pci_disable_device(pdev); 5236 pci_disable_device(pdev);
@@ -5282,6 +5283,10 @@ void ixgbe_update_stats(struct ixgbe_adapter *adapter)
5282 u32 i, missed_rx = 0, mpc, bprc, lxon, lxoff, xon_off_tot; 5283 u32 i, missed_rx = 0, mpc, bprc, lxon, lxoff, xon_off_tot;
5283 u64 non_eop_descs = 0, restart_queue = 0; 5284 u64 non_eop_descs = 0, restart_queue = 0;
5284 5285
5286 if (test_bit(__IXGBE_DOWN, &adapter->state) ||
5287 test_bit(__IXGBE_RESETTING, &adapter->state))
5288 return;
5289
5285 if (adapter->flags2 & IXGBE_FLAG2_RSC_ENABLED) { 5290 if (adapter->flags2 & IXGBE_FLAG2_RSC_ENABLED) {
5286 u64 rsc_count = 0; 5291 u64 rsc_count = 0;
5287 u64 rsc_flush = 0; 5292 u64 rsc_flush = 0;
@@ -6019,7 +6024,6 @@ static void ixgbe_tx_queue(struct ixgbe_adapter *adapter,
6019static void ixgbe_atr(struct ixgbe_adapter *adapter, struct sk_buff *skb, 6024static void ixgbe_atr(struct ixgbe_adapter *adapter, struct sk_buff *skb,
6020 int queue, u32 tx_flags) 6025 int queue, u32 tx_flags)
6021{ 6026{
6022 /* Right now, we support IPv4 only */
6023 struct ixgbe_atr_input atr_input; 6027 struct ixgbe_atr_input atr_input;
6024 struct tcphdr *th; 6028 struct tcphdr *th;
6025 struct iphdr *iph = ip_hdr(skb); 6029 struct iphdr *iph = ip_hdr(skb);
@@ -6028,6 +6032,9 @@ static void ixgbe_atr(struct ixgbe_adapter *adapter, struct sk_buff *skb,
6028 u32 src_ipv4_addr, dst_ipv4_addr; 6032 u32 src_ipv4_addr, dst_ipv4_addr;
6029 u8 l4type = 0; 6033 u8 l4type = 0;
6030 6034
6035 /* Right now, we support IPv4 only */
6036 if (skb->protocol != htons(ETH_P_IP))
6037 return;
6031 /* check if we're UDP or TCP */ 6038 /* check if we're UDP or TCP */
6032 if (iph->protocol == IPPROTO_TCP) { 6039 if (iph->protocol == IPPROTO_TCP) {
6033 th = tcp_hdr(skb); 6040 th = tcp_hdr(skb);
@@ -6485,6 +6492,15 @@ static int __devinit ixgbe_probe(struct pci_dev *pdev,
6485#endif 6492#endif
6486 u32 part_num, eec; 6493 u32 part_num, eec;
6487 6494
6495 /* Catch broken hardware that put the wrong VF device ID in
6496 * the PCIe SR-IOV capability.
6497 */
6498 if (pdev->is_virtfn) {
6499 WARN(1, KERN_ERR "%s (%hx:%hx) should not be a VF!\n",
6500 pci_name(pdev), pdev->vendor, pdev->device);
6501 return -EINVAL;
6502 }
6503
6488 err = pci_enable_device_mem(pdev); 6504 err = pci_enable_device_mem(pdev);
6489 if (err) 6505 if (err)
6490 return err; 6506 return err;
diff --git a/drivers/net/ixgbe/ixgbe_phy.c b/drivers/net/ixgbe/ixgbe_phy.c
index 09e1911ff510..48325a5beff2 100644
--- a/drivers/net/ixgbe/ixgbe_phy.c
+++ b/drivers/net/ixgbe/ixgbe_phy.c
@@ -575,6 +575,8 @@ s32 ixgbe_identify_sfp_module_generic(struct ixgbe_hw *hw)
575 * 4 SFP_DA_CORE1 - 82599-specific 575 * 4 SFP_DA_CORE1 - 82599-specific
576 * 5 SFP_SR/LR_CORE0 - 82599-specific 576 * 5 SFP_SR/LR_CORE0 - 82599-specific
577 * 6 SFP_SR/LR_CORE1 - 82599-specific 577 * 6 SFP_SR/LR_CORE1 - 82599-specific
578 * 7 SFP_act_lmt_DA_CORE0 - 82599-specific
579 * 8 SFP_act_lmt_DA_CORE1 - 82599-specific
578 */ 580 */
579 if (hw->mac.type == ixgbe_mac_82598EB) { 581 if (hw->mac.type == ixgbe_mac_82598EB) {
580 if (cable_tech & IXGBE_SFF_DA_PASSIVE_CABLE) 582 if (cable_tech & IXGBE_SFF_DA_PASSIVE_CABLE)
diff --git a/drivers/net/lib82596.c b/drivers/net/lib82596.c
index ce5d6e909218..c27f4291b350 100644
--- a/drivers/net/lib82596.c
+++ b/drivers/net/lib82596.c
@@ -1343,7 +1343,7 @@ static void set_multicast_list(struct net_device *dev)
1343 DEB(DEB_MULTI, 1343 DEB(DEB_MULTI,
1344 printk(KERN_DEBUG 1344 printk(KERN_DEBUG
1345 "%s: set multicast list, %d entries, promisc %s, allmulti %s\n", 1345 "%s: set multicast list, %d entries, promisc %s, allmulti %s\n",
1346 dev->name, dev->mc_count, 1346 dev->name, netdev_mc_count(dev),
1347 dev->flags & IFF_PROMISC ? "ON" : "OFF", 1347 dev->flags & IFF_PROMISC ? "ON" : "OFF",
1348 dev->flags & IFF_ALLMULTI ? "ON" : "OFF")); 1348 dev->flags & IFF_ALLMULTI ? "ON" : "OFF"));
1349 1349
diff --git a/drivers/net/ll_temac_main.c b/drivers/net/ll_temac_main.c
index 315eb4cdb58e..dc6bf042579d 100644
--- a/drivers/net/ll_temac_main.c
+++ b/drivers/net/ll_temac_main.c
@@ -964,7 +964,7 @@ temac_of_probe(struct of_device *op, const struct of_device_id *match)
964 np = of_parse_phandle(op->dev.of_node, "llink-connected", 0); 964 np = of_parse_phandle(op->dev.of_node, "llink-connected", 0);
965 if (!np) { 965 if (!np) {
966 dev_err(&op->dev, "could not find DMA node\n"); 966 dev_err(&op->dev, "could not find DMA node\n");
967 goto nodev; 967 goto err_iounmap;
968 } 968 }
969 969
970 /* Setup the DMA register accesses, could be DCR or memory mapped */ 970 /* Setup the DMA register accesses, could be DCR or memory mapped */
@@ -978,7 +978,7 @@ temac_of_probe(struct of_device *op, const struct of_device_id *match)
978 dev_dbg(&op->dev, "MEM base: %p\n", lp->sdma_regs); 978 dev_dbg(&op->dev, "MEM base: %p\n", lp->sdma_regs);
979 } else { 979 } else {
980 dev_err(&op->dev, "unable to map DMA registers\n"); 980 dev_err(&op->dev, "unable to map DMA registers\n");
981 goto nodev; 981 goto err_iounmap;
982 } 982 }
983 } 983 }
984 984
@@ -987,7 +987,7 @@ temac_of_probe(struct of_device *op, const struct of_device_id *match)
987 if ((lp->rx_irq == NO_IRQ) || (lp->tx_irq == NO_IRQ)) { 987 if ((lp->rx_irq == NO_IRQ) || (lp->tx_irq == NO_IRQ)) {
988 dev_err(&op->dev, "could not determine irqs\n"); 988 dev_err(&op->dev, "could not determine irqs\n");
989 rc = -ENOMEM; 989 rc = -ENOMEM;
990 goto nodev; 990 goto err_iounmap_2;
991 } 991 }
992 992
993 of_node_put(np); /* Finished with the DMA node; drop the reference */ 993 of_node_put(np); /* Finished with the DMA node; drop the reference */
@@ -997,7 +997,7 @@ temac_of_probe(struct of_device *op, const struct of_device_id *match)
997 if ((!addr) || (size != 6)) { 997 if ((!addr) || (size != 6)) {
998 dev_err(&op->dev, "could not find MAC address\n"); 998 dev_err(&op->dev, "could not find MAC address\n");
999 rc = -ENODEV; 999 rc = -ENODEV;
1000 goto nodev; 1000 goto err_iounmap_2;
1001 } 1001 }
1002 temac_set_mac_address(ndev, (void *)addr); 1002 temac_set_mac_address(ndev, (void *)addr);
1003 1003
@@ -1013,7 +1013,7 @@ temac_of_probe(struct of_device *op, const struct of_device_id *match)
1013 rc = sysfs_create_group(&lp->dev->kobj, &temac_attr_group); 1013 rc = sysfs_create_group(&lp->dev->kobj, &temac_attr_group);
1014 if (rc) { 1014 if (rc) {
1015 dev_err(lp->dev, "Error creating sysfs files\n"); 1015 dev_err(lp->dev, "Error creating sysfs files\n");
1016 goto nodev; 1016 goto err_iounmap_2;
1017 } 1017 }
1018 1018
1019 rc = register_netdev(lp->ndev); 1019 rc = register_netdev(lp->ndev);
@@ -1026,6 +1026,11 @@ temac_of_probe(struct of_device *op, const struct of_device_id *match)
1026 1026
1027 err_register_ndev: 1027 err_register_ndev:
1028 sysfs_remove_group(&lp->dev->kobj, &temac_attr_group); 1028 sysfs_remove_group(&lp->dev->kobj, &temac_attr_group);
1029 err_iounmap_2:
1030 if (lp->sdma_regs)
1031 iounmap(lp->sdma_regs);
1032 err_iounmap:
1033 iounmap(lp->regs);
1029 nodev: 1034 nodev:
1030 free_netdev(ndev); 1035 free_netdev(ndev);
1031 ndev = NULL; 1036 ndev = NULL;
@@ -1044,6 +1049,9 @@ static int __devexit temac_of_remove(struct of_device *op)
1044 of_node_put(lp->phy_node); 1049 of_node_put(lp->phy_node);
1045 lp->phy_node = NULL; 1050 lp->phy_node = NULL;
1046 dev_set_drvdata(&op->dev, NULL); 1051 dev_set_drvdata(&op->dev, NULL);
1052 iounmap(lp->regs);
1053 if (lp->sdma_regs)
1054 iounmap(lp->sdma_regs);
1047 free_netdev(ndev); 1055 free_netdev(ndev);
1048 return 0; 1056 return 0;
1049} 1057}
diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c
index 87e8d4cb4057..f15fe2cf72ae 100644
--- a/drivers/net/macvlan.c
+++ b/drivers/net/macvlan.c
@@ -499,7 +499,7 @@ static const struct net_device_ops macvlan_netdev_ops = {
499 .ndo_validate_addr = eth_validate_addr, 499 .ndo_validate_addr = eth_validate_addr,
500}; 500};
501 501
502static void macvlan_setup(struct net_device *dev) 502void macvlan_common_setup(struct net_device *dev)
503{ 503{
504 ether_setup(dev); 504 ether_setup(dev);
505 505
@@ -508,6 +508,12 @@ static void macvlan_setup(struct net_device *dev)
508 dev->destructor = free_netdev; 508 dev->destructor = free_netdev;
509 dev->header_ops = &macvlan_hard_header_ops, 509 dev->header_ops = &macvlan_hard_header_ops,
510 dev->ethtool_ops = &macvlan_ethtool_ops; 510 dev->ethtool_ops = &macvlan_ethtool_ops;
511}
512EXPORT_SYMBOL_GPL(macvlan_common_setup);
513
514static void macvlan_setup(struct net_device *dev)
515{
516 macvlan_common_setup(dev);
511 dev->tx_queue_len = 0; 517 dev->tx_queue_len = 0;
512} 518}
513 519
@@ -705,7 +711,6 @@ int macvlan_link_register(struct rtnl_link_ops *ops)
705 /* common fields */ 711 /* common fields */
706 ops->priv_size = sizeof(struct macvlan_dev); 712 ops->priv_size = sizeof(struct macvlan_dev);
707 ops->get_tx_queues = macvlan_get_tx_queues; 713 ops->get_tx_queues = macvlan_get_tx_queues;
708 ops->setup = macvlan_setup;
709 ops->validate = macvlan_validate; 714 ops->validate = macvlan_validate;
710 ops->maxtype = IFLA_MACVLAN_MAX; 715 ops->maxtype = IFLA_MACVLAN_MAX;
711 ops->policy = macvlan_policy; 716 ops->policy = macvlan_policy;
@@ -719,6 +724,7 @@ EXPORT_SYMBOL_GPL(macvlan_link_register);
719 724
720static struct rtnl_link_ops macvlan_link_ops = { 725static struct rtnl_link_ops macvlan_link_ops = {
721 .kind = "macvlan", 726 .kind = "macvlan",
727 .setup = macvlan_setup,
722 .newlink = macvlan_newlink, 728 .newlink = macvlan_newlink,
723 .dellink = macvlan_dellink, 729 .dellink = macvlan_dellink,
724}; 730};
diff --git a/drivers/net/macvtap.c b/drivers/net/macvtap.c
index a8a94e2f6ddc..ff02b836c3c4 100644
--- a/drivers/net/macvtap.c
+++ b/drivers/net/macvtap.c
@@ -180,11 +180,18 @@ static int macvtap_forward(struct net_device *dev, struct sk_buff *skb)
180{ 180{
181 struct macvtap_queue *q = macvtap_get_queue(dev, skb); 181 struct macvtap_queue *q = macvtap_get_queue(dev, skb);
182 if (!q) 182 if (!q)
183 return -ENOLINK; 183 goto drop;
184
185 if (skb_queue_len(&q->sk.sk_receive_queue) >= dev->tx_queue_len)
186 goto drop;
184 187
185 skb_queue_tail(&q->sk.sk_receive_queue, skb); 188 skb_queue_tail(&q->sk.sk_receive_queue, skb);
186 wake_up_interruptible_poll(sk_sleep(&q->sk), POLLIN | POLLRDNORM | POLLRDBAND); 189 wake_up_interruptible_poll(sk_sleep(&q->sk), POLLIN | POLLRDNORM | POLLRDBAND);
187 return 0; 190 return NET_RX_SUCCESS;
191
192drop:
193 kfree_skb(skb);
194 return NET_RX_DROP;
188} 195}
189 196
190/* 197/*
@@ -235,8 +242,15 @@ static void macvtap_dellink(struct net_device *dev,
235 macvlan_dellink(dev, head); 242 macvlan_dellink(dev, head);
236} 243}
237 244
245static void macvtap_setup(struct net_device *dev)
246{
247 macvlan_common_setup(dev);
248 dev->tx_queue_len = TUN_READQ_SIZE;
249}
250
238static struct rtnl_link_ops macvtap_link_ops __read_mostly = { 251static struct rtnl_link_ops macvtap_link_ops __read_mostly = {
239 .kind = "macvtap", 252 .kind = "macvtap",
253 .setup = macvtap_setup,
240 .newlink = macvtap_newlink, 254 .newlink = macvtap_newlink,
241 .dellink = macvtap_dellink, 255 .dellink = macvtap_dellink,
242}; 256};
diff --git a/drivers/net/mipsnet.c b/drivers/net/mipsnet.c
index 8e9704f5c122..869f0ea43a5b 100644
--- a/drivers/net/mipsnet.c
+++ b/drivers/net/mipsnet.c
@@ -247,7 +247,7 @@ static const struct net_device_ops mipsnet_netdev_ops = {
247 .ndo_set_mac_address = eth_mac_addr, 247 .ndo_set_mac_address = eth_mac_addr,
248}; 248};
249 249
250static int __init mipsnet_probe(struct platform_device *dev) 250static int __devinit mipsnet_probe(struct platform_device *dev)
251{ 251{
252 struct net_device *netdev; 252 struct net_device *netdev;
253 int err; 253 int err;
diff --git a/drivers/net/mv643xx_eth.c b/drivers/net/mv643xx_eth.c
index e345ec8cb473..73bb8ea6f54a 100644
--- a/drivers/net/mv643xx_eth.c
+++ b/drivers/net/mv643xx_eth.c
@@ -289,6 +289,7 @@ struct mv643xx_eth_shared_private {
289 unsigned int t_clk; 289 unsigned int t_clk;
290 int extended_rx_coal_limit; 290 int extended_rx_coal_limit;
291 int tx_bw_control; 291 int tx_bw_control;
292 int tx_csum_limit;
292}; 293};
293 294
294#define TX_BW_CONTROL_ABSENT 0 295#define TX_BW_CONTROL_ABSENT 0
@@ -776,13 +777,16 @@ static int txq_submit_skb(struct tx_queue *txq, struct sk_buff *skb)
776 l4i_chk = 0; 777 l4i_chk = 0;
777 778
778 if (skb->ip_summed == CHECKSUM_PARTIAL) { 779 if (skb->ip_summed == CHECKSUM_PARTIAL) {
780 int hdr_len;
779 int tag_bytes; 781 int tag_bytes;
780 782
781 BUG_ON(skb->protocol != htons(ETH_P_IP) && 783 BUG_ON(skb->protocol != htons(ETH_P_IP) &&
782 skb->protocol != htons(ETH_P_8021Q)); 784 skb->protocol != htons(ETH_P_8021Q));
783 785
784 tag_bytes = (void *)ip_hdr(skb) - (void *)skb->data - ETH_HLEN; 786 hdr_len = (void *)ip_hdr(skb) - (void *)skb->data;
785 if (unlikely(tag_bytes & ~12)) { 787 tag_bytes = hdr_len - ETH_HLEN;
788 if (skb->len - hdr_len > mp->shared->tx_csum_limit ||
789 unlikely(tag_bytes & ~12)) {
786 if (skb_checksum_help(skb) == 0) 790 if (skb_checksum_help(skb) == 0)
787 goto no_csum; 791 goto no_csum;
788 kfree_skb(skb); 792 kfree_skb(skb);
@@ -2666,6 +2670,7 @@ static int mv643xx_eth_shared_probe(struct platform_device *pdev)
2666 * Detect hardware parameters. 2670 * Detect hardware parameters.
2667 */ 2671 */
2668 msp->t_clk = (pd != NULL && pd->t_clk != 0) ? pd->t_clk : 133000000; 2672 msp->t_clk = (pd != NULL && pd->t_clk != 0) ? pd->t_clk : 133000000;
2673 msp->tx_csum_limit = pd->tx_csum_limit ? pd->tx_csum_limit : 9 * 1024;
2669 infer_hw_params(msp); 2674 infer_hw_params(msp);
2670 2675
2671 platform_set_drvdata(pdev, msp); 2676 platform_set_drvdata(pdev, msp);
diff --git a/drivers/net/ne.c b/drivers/net/ne.c
index b8e2923a1d69..1063093b3afc 100644
--- a/drivers/net/ne.c
+++ b/drivers/net/ne.c
@@ -806,8 +806,10 @@ static int __init ne_drv_probe(struct platform_device *pdev)
806 dev->base_addr = res->start; 806 dev->base_addr = res->start;
807 dev->irq = platform_get_irq(pdev, 0); 807 dev->irq = platform_get_irq(pdev, 0);
808 } else { 808 } else {
809 if (this_dev < 0 || this_dev >= MAX_NE_CARDS) 809 if (this_dev < 0 || this_dev >= MAX_NE_CARDS) {
810 free_netdev(dev);
810 return -EINVAL; 811 return -EINVAL;
812 }
811 dev->base_addr = io[this_dev]; 813 dev->base_addr = io[this_dev];
812 dev->irq = irq[this_dev]; 814 dev->irq = irq[this_dev];
813 dev->mem_end = bad[this_dev]; 815 dev->mem_end = bad[this_dev];
diff --git a/drivers/net/netxen/netxen_nic_ctx.c b/drivers/net/netxen/netxen_nic_ctx.c
index f26e54716c88..3a41b6a84a68 100644
--- a/drivers/net/netxen/netxen_nic_ctx.c
+++ b/drivers/net/netxen/netxen_nic_ctx.c
@@ -629,7 +629,8 @@ int netxen_alloc_hw_resources(struct netxen_adapter *adapter)
629 if (addr == NULL) { 629 if (addr == NULL) {
630 dev_err(&pdev->dev, "%s: failed to allocate tx desc ring\n", 630 dev_err(&pdev->dev, "%s: failed to allocate tx desc ring\n",
631 netdev->name); 631 netdev->name);
632 return -ENOMEM; 632 err = -ENOMEM;
633 goto err_out_free;
633 } 634 }
634 635
635 tx_ring->desc_head = (struct cmd_desc_type0 *)addr; 636 tx_ring->desc_head = (struct cmd_desc_type0 *)addr;
diff --git a/drivers/net/netxen/netxen_nic_hw.c b/drivers/net/netxen/netxen_nic_hw.c
index 5c496f8d7c49..29d7b93d0493 100644
--- a/drivers/net/netxen/netxen_nic_hw.c
+++ b/drivers/net/netxen/netxen_nic_hw.c
@@ -1159,9 +1159,6 @@ netxen_nic_pci_set_crbwindow_2M(struct netxen_adapter *adapter, ulong off)
1159 1159
1160 window = CRB_HI(off); 1160 window = CRB_HI(off);
1161 1161
1162 if (adapter->ahw.crb_win == window)
1163 return;
1164
1165 writel(window, addr); 1162 writel(window, addr);
1166 if (readl(addr) != window) { 1163 if (readl(addr) != window) {
1167 if (printk_ratelimit()) 1164 if (printk_ratelimit())
@@ -1169,7 +1166,6 @@ netxen_nic_pci_set_crbwindow_2M(struct netxen_adapter *adapter, ulong off)
1169 "failed to set CRB window to %d off 0x%lx\n", 1166 "failed to set CRB window to %d off 0x%lx\n",
1170 window, off); 1167 window, off);
1171 } 1168 }
1172 adapter->ahw.crb_win = window;
1173} 1169}
1174 1170
1175static void __iomem * 1171static void __iomem *
diff --git a/drivers/net/netxen/netxen_nic_init.c b/drivers/net/netxen/netxen_nic_init.c
index 045a7c8f5bdf..c865dda2adf1 100644
--- a/drivers/net/netxen/netxen_nic_init.c
+++ b/drivers/net/netxen/netxen_nic_init.c
@@ -218,7 +218,7 @@ int netxen_alloc_sw_resources(struct netxen_adapter *adapter)
218 if (cmd_buf_arr == NULL) { 218 if (cmd_buf_arr == NULL) {
219 dev_err(&pdev->dev, "%s: failed to allocate cmd buffer ring\n", 219 dev_err(&pdev->dev, "%s: failed to allocate cmd buffer ring\n",
220 netdev->name); 220 netdev->name);
221 return -ENOMEM; 221 goto err_out;
222 } 222 }
223 memset(cmd_buf_arr, 0, TX_BUFF_RINGSIZE(tx_ring)); 223 memset(cmd_buf_arr, 0, TX_BUFF_RINGSIZE(tx_ring));
224 tx_ring->cmd_buf_arr = cmd_buf_arr; 224 tx_ring->cmd_buf_arr = cmd_buf_arr;
@@ -230,7 +230,7 @@ int netxen_alloc_sw_resources(struct netxen_adapter *adapter)
230 if (rds_ring == NULL) { 230 if (rds_ring == NULL) {
231 dev_err(&pdev->dev, "%s: failed to allocate rds ring struct\n", 231 dev_err(&pdev->dev, "%s: failed to allocate rds ring struct\n",
232 netdev->name); 232 netdev->name);
233 return -ENOMEM; 233 goto err_out;
234 } 234 }
235 recv_ctx->rds_rings = rds_ring; 235 recv_ctx->rds_rings = rds_ring;
236 236
@@ -1805,9 +1805,10 @@ netxen_post_rx_buffers(struct netxen_adapter *adapter, u32 ringid,
1805 netxen_ctx_msg msg = 0; 1805 netxen_ctx_msg msg = 0;
1806 struct list_head *head; 1806 struct list_head *head;
1807 1807
1808 spin_lock(&rds_ring->lock);
1809
1808 producer = rds_ring->producer; 1810 producer = rds_ring->producer;
1809 1811
1810 spin_lock(&rds_ring->lock);
1811 head = &rds_ring->free_list; 1812 head = &rds_ring->free_list;
1812 while (!list_empty(head)) { 1813 while (!list_empty(head)) {
1813 1814
@@ -1829,7 +1830,6 @@ netxen_post_rx_buffers(struct netxen_adapter *adapter, u32 ringid,
1829 1830
1830 producer = get_next_index(producer, rds_ring->num_desc); 1831 producer = get_next_index(producer, rds_ring->num_desc);
1831 } 1832 }
1832 spin_unlock(&rds_ring->lock);
1833 1833
1834 if (count) { 1834 if (count) {
1835 rds_ring->producer = producer; 1835 rds_ring->producer = producer;
@@ -1853,6 +1853,8 @@ netxen_post_rx_buffers(struct netxen_adapter *adapter, u32 ringid,
1853 NETXEN_RCV_PRODUCER_OFFSET), msg); 1853 NETXEN_RCV_PRODUCER_OFFSET), msg);
1854 } 1854 }
1855 } 1855 }
1856
1857 spin_unlock(&rds_ring->lock);
1856} 1858}
1857 1859
1858static void 1860static void
@@ -1864,10 +1866,11 @@ netxen_post_rx_buffers_nodb(struct netxen_adapter *adapter,
1864 int producer, count = 0; 1866 int producer, count = 0;
1865 struct list_head *head; 1867 struct list_head *head;
1866 1868
1867 producer = rds_ring->producer;
1868 if (!spin_trylock(&rds_ring->lock)) 1869 if (!spin_trylock(&rds_ring->lock))
1869 return; 1870 return;
1870 1871
1872 producer = rds_ring->producer;
1873
1871 head = &rds_ring->free_list; 1874 head = &rds_ring->free_list;
1872 while (!list_empty(head)) { 1875 while (!list_empty(head)) {
1873 1876
diff --git a/drivers/net/pcmcia/axnet_cs.c b/drivers/net/pcmcia/axnet_cs.c
index 5b3dfb4ab279..33525bf2a3d3 100644
--- a/drivers/net/pcmcia/axnet_cs.c
+++ b/drivers/net/pcmcia/axnet_cs.c
@@ -1168,6 +1168,7 @@ static irqreturn_t ax_interrupt(int irq, void *dev_id)
1168 int interrupts, nr_serviced = 0, i; 1168 int interrupts, nr_serviced = 0, i;
1169 struct ei_device *ei_local; 1169 struct ei_device *ei_local;
1170 int handled = 0; 1170 int handled = 0;
1171 unsigned long flags;
1171 1172
1172 e8390_base = dev->base_addr; 1173 e8390_base = dev->base_addr;
1173 ei_local = netdev_priv(dev); 1174 ei_local = netdev_priv(dev);
@@ -1176,7 +1177,7 @@ static irqreturn_t ax_interrupt(int irq, void *dev_id)
1176 * Protect the irq test too. 1177 * Protect the irq test too.
1177 */ 1178 */
1178 1179
1179 spin_lock(&ei_local->page_lock); 1180 spin_lock_irqsave(&ei_local->page_lock, flags);
1180 1181
1181 if (ei_local->irqlock) 1182 if (ei_local->irqlock)
1182 { 1183 {
@@ -1188,7 +1189,7 @@ static irqreturn_t ax_interrupt(int irq, void *dev_id)
1188 dev->name, inb_p(e8390_base + EN0_ISR), 1189 dev->name, inb_p(e8390_base + EN0_ISR),
1189 inb_p(e8390_base + EN0_IMR)); 1190 inb_p(e8390_base + EN0_IMR));
1190#endif 1191#endif
1191 spin_unlock(&ei_local->page_lock); 1192 spin_unlock_irqrestore(&ei_local->page_lock, flags);
1192 return IRQ_NONE; 1193 return IRQ_NONE;
1193 } 1194 }
1194 1195
@@ -1261,7 +1262,7 @@ static irqreturn_t ax_interrupt(int irq, void *dev_id)
1261 ei_local->irqlock = 0; 1262 ei_local->irqlock = 0;
1262 outb_p(ENISR_ALL, e8390_base + EN0_IMR); 1263 outb_p(ENISR_ALL, e8390_base + EN0_IMR);
1263 1264
1264 spin_unlock(&ei_local->page_lock); 1265 spin_unlock_irqrestore(&ei_local->page_lock, flags);
1265 return IRQ_RETVAL(handled); 1266 return IRQ_RETVAL(handled);
1266} 1267}
1267 1268
diff --git a/drivers/net/pcmcia/pcnet_cs.c b/drivers/net/pcmcia/pcnet_cs.c
index 6f77a768ba88..bfdef72c5d5e 100644
--- a/drivers/net/pcmcia/pcnet_cs.c
+++ b/drivers/net/pcmcia/pcnet_cs.c
@@ -1727,6 +1727,7 @@ static struct pcmcia_device_id pcnet_ids[] = {
1727 PCMCIA_PFC_DEVICE_CIS_PROD_ID12(0, "Psion Dacom", "Gold Card V34 Ethernet", 0xf5f025c2, 0x338e8155, "cis/PCMLM28.cis"), 1727 PCMCIA_PFC_DEVICE_CIS_PROD_ID12(0, "Psion Dacom", "Gold Card V34 Ethernet", 0xf5f025c2, 0x338e8155, "cis/PCMLM28.cis"),
1728 PCMCIA_PFC_DEVICE_CIS_PROD_ID12(0, "Psion Dacom", "Gold Card V34 Ethernet GSM", 0xf5f025c2, 0x4ae85d35, "cis/PCMLM28.cis"), 1728 PCMCIA_PFC_DEVICE_CIS_PROD_ID12(0, "Psion Dacom", "Gold Card V34 Ethernet GSM", 0xf5f025c2, 0x4ae85d35, "cis/PCMLM28.cis"),
1729 PCMCIA_PFC_DEVICE_CIS_PROD_ID12(0, "LINKSYS", "PCMLM28", 0xf7cb0b07, 0x66881874, "cis/PCMLM28.cis"), 1729 PCMCIA_PFC_DEVICE_CIS_PROD_ID12(0, "LINKSYS", "PCMLM28", 0xf7cb0b07, 0x66881874, "cis/PCMLM28.cis"),
1730 PCMCIA_PFC_DEVICE_CIS_PROD_ID12(0, "TOSHIBA", "Modem/LAN Card", 0xb4585a1a, 0x53f922f8, "cis/PCMLM28.cis"),
1730 PCMCIA_MFC_DEVICE_CIS_PROD_ID12(0, "DAYNA COMMUNICATIONS", "LAN AND MODEM MULTIFUNCTION", 0x8fdf8f89, 0xdd5ed9e8, "cis/DP83903.cis"), 1731 PCMCIA_MFC_DEVICE_CIS_PROD_ID12(0, "DAYNA COMMUNICATIONS", "LAN AND MODEM MULTIFUNCTION", 0x8fdf8f89, 0xdd5ed9e8, "cis/DP83903.cis"),
1731 PCMCIA_MFC_DEVICE_CIS_PROD_ID4(0, "NSC MF LAN/Modem", 0x58fc6056, "cis/DP83903.cis"), 1732 PCMCIA_MFC_DEVICE_CIS_PROD_ID4(0, "NSC MF LAN/Modem", 0x58fc6056, "cis/DP83903.cis"),
1732 PCMCIA_MFC_DEVICE_CIS_MANF_CARD(0, 0x0175, 0x0000, "cis/DP83903.cis"), 1733 PCMCIA_MFC_DEVICE_CIS_MANF_CARD(0, 0x0175, 0x0000, "cis/DP83903.cis"),
diff --git a/drivers/net/pcmcia/smc91c92_cs.c b/drivers/net/pcmcia/smc91c92_cs.c
index 64e6a84bbbbe..307cd1721e91 100644
--- a/drivers/net/pcmcia/smc91c92_cs.c
+++ b/drivers/net/pcmcia/smc91c92_cs.c
@@ -1505,12 +1505,20 @@ irq_done:
1505 writeb(cor & ~COR_IREQ_ENA, smc->base + MOT_LAN + CISREG_COR); 1505 writeb(cor & ~COR_IREQ_ENA, smc->base + MOT_LAN + CISREG_COR);
1506 writeb(cor, smc->base + MOT_LAN + CISREG_COR); 1506 writeb(cor, smc->base + MOT_LAN + CISREG_COR);
1507 } 1507 }
1508#ifdef DOES_NOT_WORK 1508
1509 if (smc->base != NULL) { /* Megahertz MFC's */ 1509 if ((smc->base != NULL) && /* Megahertz MFC's */
1510 readb(smc->base+MEGAHERTZ_ISR); 1510 (smc->manfid == MANFID_MEGAHERTZ) &&
1511 readb(smc->base+MEGAHERTZ_ISR); 1511 (smc->cardid == PRODID_MEGAHERTZ_EM3288)) {
1512
1513 u_char tmp;
1514 tmp = readb(smc->base+MEGAHERTZ_ISR);
1515 tmp = readb(smc->base+MEGAHERTZ_ISR);
1516
1517 /* Retrigger interrupt if needed */
1518 writeb(tmp, smc->base + MEGAHERTZ_ISR);
1519 writeb(tmp, smc->base + MEGAHERTZ_ISR);
1512 } 1520 }
1513#endif 1521
1514 spin_unlock(&smc->lock); 1522 spin_unlock(&smc->lock);
1515 return IRQ_RETVAL(handled); 1523 return IRQ_RETVAL(handled);
1516} 1524}
diff --git a/drivers/net/phy/lxt.c b/drivers/net/phy/lxt.c
index dbd003453737..29c39ff85de5 100644
--- a/drivers/net/phy/lxt.c
+++ b/drivers/net/phy/lxt.c
@@ -226,6 +226,7 @@ module_exit(lxt_exit);
226static struct mdio_device_id lxt_tbl[] = { 226static struct mdio_device_id lxt_tbl[] = {
227 { 0x78100000, 0xfffffff0 }, 227 { 0x78100000, 0xfffffff0 },
228 { 0x001378e0, 0xfffffff0 }, 228 { 0x001378e0, 0xfffffff0 },
229 { 0x00137a10, 0xfffffff0 },
229 { } 230 { }
230}; 231};
231 232
diff --git a/drivers/net/phy/marvell.c b/drivers/net/phy/marvell.c
index 78b74e83ce5d..5a1bd5db2a93 100644
--- a/drivers/net/phy/marvell.c
+++ b/drivers/net/phy/marvell.c
@@ -29,6 +29,7 @@
29#include <linux/mii.h> 29#include <linux/mii.h>
30#include <linux/ethtool.h> 30#include <linux/ethtool.h>
31#include <linux/phy.h> 31#include <linux/phy.h>
32#include <linux/marvell_phy.h>
32 33
33#include <asm/io.h> 34#include <asm/io.h>
34#include <asm/irq.h> 35#include <asm/irq.h>
@@ -48,8 +49,6 @@
48#define MII_M1145_RGMII_RX_DELAY 0x0080 49#define MII_M1145_RGMII_RX_DELAY 0x0080
49#define MII_M1145_RGMII_TX_DELAY 0x0002 50#define MII_M1145_RGMII_TX_DELAY 0x0002
50 51
51#define M1145_DEV_FLAGS_RESISTANCE 0x00000001
52
53#define MII_M1111_PHY_LED_CONTROL 0x18 52#define MII_M1111_PHY_LED_CONTROL 0x18
54#define MII_M1111_PHY_LED_DIRECT 0x4100 53#define MII_M1111_PHY_LED_DIRECT 0x4100
55#define MII_M1111_PHY_LED_COMBINE 0x411c 54#define MII_M1111_PHY_LED_COMBINE 0x411c
@@ -350,7 +349,10 @@ static int m88e1118_config_init(struct phy_device *phydev)
350 return err; 349 return err;
351 350
352 /* Adjust LED Control */ 351 /* Adjust LED Control */
353 err = phy_write(phydev, 0x10, 0x021e); 352 if (phydev->dev_flags & MARVELL_PHY_M1118_DNS323_LEDS)
353 err = phy_write(phydev, 0x10, 0x1100);
354 else
355 err = phy_write(phydev, 0x10, 0x021e);
354 if (err < 0) 356 if (err < 0)
355 return err; 357 return err;
356 358
@@ -398,7 +400,7 @@ static int m88e1145_config_init(struct phy_device *phydev)
398 if (err < 0) 400 if (err < 0)
399 return err; 401 return err;
400 402
401 if (phydev->dev_flags & M1145_DEV_FLAGS_RESISTANCE) { 403 if (phydev->dev_flags & MARVELL_PHY_M1145_FLAGS_RESISTANCE) {
402 err = phy_write(phydev, 0x1d, 0x0012); 404 err = phy_write(phydev, 0x1d, 0x0012);
403 if (err < 0) 405 if (err < 0)
404 return err; 406 return err;
@@ -529,8 +531,8 @@ static int m88e1121_did_interrupt(struct phy_device *phydev)
529 531
530static struct phy_driver marvell_drivers[] = { 532static struct phy_driver marvell_drivers[] = {
531 { 533 {
532 .phy_id = 0x01410c60, 534 .phy_id = MARVELL_PHY_ID_88E1101,
533 .phy_id_mask = 0xfffffff0, 535 .phy_id_mask = MARVELL_PHY_ID_MASK,
534 .name = "Marvell 88E1101", 536 .name = "Marvell 88E1101",
535 .features = PHY_GBIT_FEATURES, 537 .features = PHY_GBIT_FEATURES,
536 .flags = PHY_HAS_INTERRUPT, 538 .flags = PHY_HAS_INTERRUPT,
@@ -541,8 +543,8 @@ static struct phy_driver marvell_drivers[] = {
541 .driver = { .owner = THIS_MODULE }, 543 .driver = { .owner = THIS_MODULE },
542 }, 544 },
543 { 545 {
544 .phy_id = 0x01410c90, 546 .phy_id = MARVELL_PHY_ID_88E1112,
545 .phy_id_mask = 0xfffffff0, 547 .phy_id_mask = MARVELL_PHY_ID_MASK,
546 .name = "Marvell 88E1112", 548 .name = "Marvell 88E1112",
547 .features = PHY_GBIT_FEATURES, 549 .features = PHY_GBIT_FEATURES,
548 .flags = PHY_HAS_INTERRUPT, 550 .flags = PHY_HAS_INTERRUPT,
@@ -554,8 +556,8 @@ static struct phy_driver marvell_drivers[] = {
554 .driver = { .owner = THIS_MODULE }, 556 .driver = { .owner = THIS_MODULE },
555 }, 557 },
556 { 558 {
557 .phy_id = 0x01410cc0, 559 .phy_id = MARVELL_PHY_ID_88E1111,
558 .phy_id_mask = 0xfffffff0, 560 .phy_id_mask = MARVELL_PHY_ID_MASK,
559 .name = "Marvell 88E1111", 561 .name = "Marvell 88E1111",
560 .features = PHY_GBIT_FEATURES, 562 .features = PHY_GBIT_FEATURES,
561 .flags = PHY_HAS_INTERRUPT, 563 .flags = PHY_HAS_INTERRUPT,
@@ -567,8 +569,8 @@ static struct phy_driver marvell_drivers[] = {
567 .driver = { .owner = THIS_MODULE }, 569 .driver = { .owner = THIS_MODULE },
568 }, 570 },
569 { 571 {
570 .phy_id = 0x01410e10, 572 .phy_id = MARVELL_PHY_ID_88E1118,
571 .phy_id_mask = 0xfffffff0, 573 .phy_id_mask = MARVELL_PHY_ID_MASK,
572 .name = "Marvell 88E1118", 574 .name = "Marvell 88E1118",
573 .features = PHY_GBIT_FEATURES, 575 .features = PHY_GBIT_FEATURES,
574 .flags = PHY_HAS_INTERRUPT, 576 .flags = PHY_HAS_INTERRUPT,
@@ -580,8 +582,8 @@ static struct phy_driver marvell_drivers[] = {
580 .driver = {.owner = THIS_MODULE,}, 582 .driver = {.owner = THIS_MODULE,},
581 }, 583 },
582 { 584 {
583 .phy_id = 0x01410cb0, 585 .phy_id = MARVELL_PHY_ID_88E1121R,
584 .phy_id_mask = 0xfffffff0, 586 .phy_id_mask = MARVELL_PHY_ID_MASK,
585 .name = "Marvell 88E1121R", 587 .name = "Marvell 88E1121R",
586 .features = PHY_GBIT_FEATURES, 588 .features = PHY_GBIT_FEATURES,
587 .flags = PHY_HAS_INTERRUPT, 589 .flags = PHY_HAS_INTERRUPT,
@@ -593,8 +595,8 @@ static struct phy_driver marvell_drivers[] = {
593 .driver = { .owner = THIS_MODULE }, 595 .driver = { .owner = THIS_MODULE },
594 }, 596 },
595 { 597 {
596 .phy_id = 0x01410cd0, 598 .phy_id = MARVELL_PHY_ID_88E1145,
597 .phy_id_mask = 0xfffffff0, 599 .phy_id_mask = MARVELL_PHY_ID_MASK,
598 .name = "Marvell 88E1145", 600 .name = "Marvell 88E1145",
599 .features = PHY_GBIT_FEATURES, 601 .features = PHY_GBIT_FEATURES,
600 .flags = PHY_HAS_INTERRUPT, 602 .flags = PHY_HAS_INTERRUPT,
@@ -606,8 +608,8 @@ static struct phy_driver marvell_drivers[] = {
606 .driver = { .owner = THIS_MODULE }, 608 .driver = { .owner = THIS_MODULE },
607 }, 609 },
608 { 610 {
609 .phy_id = 0x01410e30, 611 .phy_id = MARVELL_PHY_ID_88E1240,
610 .phy_id_mask = 0xfffffff0, 612 .phy_id_mask = MARVELL_PHY_ID_MASK,
611 .name = "Marvell 88E1240", 613 .name = "Marvell 88E1240",
612 .features = PHY_GBIT_FEATURES, 614 .features = PHY_GBIT_FEATURES,
613 .flags = PHY_HAS_INTERRUPT, 615 .flags = PHY_HAS_INTERRUPT,
diff --git a/drivers/net/qlge/qlge_main.c b/drivers/net/qlge/qlge_main.c
index fa4b24c49f42..d10bcefc0e45 100644
--- a/drivers/net/qlge/qlge_main.c
+++ b/drivers/net/qlge/qlge_main.c
@@ -4611,8 +4611,7 @@ static void ql_timer(unsigned long data)
4611 return; 4611 return;
4612 } 4612 }
4613 4613
4614 qdev->timer.expires = jiffies + (5*HZ); 4614 mod_timer(&qdev->timer, jiffies + (5*HZ));
4615 add_timer(&qdev->timer);
4616} 4615}
4617 4616
4618static int __devinit qlge_probe(struct pci_dev *pdev, 4617static int __devinit qlge_probe(struct pci_dev *pdev,
@@ -4713,6 +4712,8 @@ static void ql_eeh_close(struct net_device *ndev)
4713 netif_stop_queue(ndev); 4712 netif_stop_queue(ndev);
4714 } 4713 }
4715 4714
4715 /* Disabling the timer */
4716 del_timer_sync(&qdev->timer);
4716 if (test_bit(QL_ADAPTER_UP, &qdev->flags)) 4717 if (test_bit(QL_ADAPTER_UP, &qdev->flags))
4717 cancel_delayed_work_sync(&qdev->asic_reset_work); 4718 cancel_delayed_work_sync(&qdev->asic_reset_work);
4718 cancel_delayed_work_sync(&qdev->mpi_reset_work); 4719 cancel_delayed_work_sync(&qdev->mpi_reset_work);
@@ -4808,8 +4809,7 @@ static void qlge_io_resume(struct pci_dev *pdev)
4808 netif_err(qdev, ifup, qdev->ndev, 4809 netif_err(qdev, ifup, qdev->ndev,
4809 "Device was not running prior to EEH.\n"); 4810 "Device was not running prior to EEH.\n");
4810 } 4811 }
4811 qdev->timer.expires = jiffies + (5*HZ); 4812 mod_timer(&qdev->timer, jiffies + (5*HZ));
4812 add_timer(&qdev->timer);
4813 netif_device_attach(ndev); 4813 netif_device_attach(ndev);
4814} 4814}
4815 4815
@@ -4871,8 +4871,7 @@ static int qlge_resume(struct pci_dev *pdev)
4871 return err; 4871 return err;
4872 } 4872 }
4873 4873
4874 qdev->timer.expires = jiffies + (5*HZ); 4874 mod_timer(&qdev->timer, jiffies + (5*HZ));
4875 add_timer(&qdev->timer);
4876 netif_device_attach(ndev); 4875 netif_device_attach(ndev);
4877 4876
4878 return 0; 4877 return 0;
diff --git a/drivers/net/r8169.c b/drivers/net/r8169.c
index 96b6cfbf0a3a..cdc6a5c2e70d 100644
--- a/drivers/net/r8169.c
+++ b/drivers/net/r8169.c
@@ -1316,7 +1316,7 @@ static void rtl8169_get_mac_version(struct rtl8169_private *tp,
1316 { 0x7c800000, 0x28000000, RTL_GIGA_MAC_VER_26 }, 1316 { 0x7c800000, 0x28000000, RTL_GIGA_MAC_VER_26 },
1317 1317
1318 /* 8168C family. */ 1318 /* 8168C family. */
1319 { 0x7cf00000, 0x3ca00000, RTL_GIGA_MAC_VER_24 }, 1319 { 0x7cf00000, 0x3cb00000, RTL_GIGA_MAC_VER_24 },
1320 { 0x7cf00000, 0x3c900000, RTL_GIGA_MAC_VER_23 }, 1320 { 0x7cf00000, 0x3c900000, RTL_GIGA_MAC_VER_23 },
1321 { 0x7cf00000, 0x3c800000, RTL_GIGA_MAC_VER_18 }, 1321 { 0x7cf00000, 0x3c800000, RTL_GIGA_MAC_VER_18 },
1322 { 0x7c800000, 0x3c800000, RTL_GIGA_MAC_VER_24 }, 1322 { 0x7c800000, 0x3c800000, RTL_GIGA_MAC_VER_24 },
diff --git a/drivers/net/s2io.c b/drivers/net/s2io.c
index 668327ccd8d0..1d37f0c310ca 100644
--- a/drivers/net/s2io.c
+++ b/drivers/net/s2io.c
@@ -3130,7 +3130,6 @@ static void tx_intr_handler(struct fifo_info *fifo_data)
3130 pkt_cnt++; 3130 pkt_cnt++;
3131 3131
3132 /* Updating the statistics block */ 3132 /* Updating the statistics block */
3133 nic->dev->stats.tx_bytes += skb->len;
3134 swstats->mem_freed += skb->truesize; 3133 swstats->mem_freed += skb->truesize;
3135 dev_kfree_skb_irq(skb); 3134 dev_kfree_skb_irq(skb);
3136 3135
@@ -4901,48 +4900,81 @@ static void s2io_updt_stats(struct s2io_nic *sp)
4901 * Return value: 4900 * Return value:
4902 * pointer to the updated net_device_stats structure. 4901 * pointer to the updated net_device_stats structure.
4903 */ 4902 */
4904
4905static struct net_device_stats *s2io_get_stats(struct net_device *dev) 4903static struct net_device_stats *s2io_get_stats(struct net_device *dev)
4906{ 4904{
4907 struct s2io_nic *sp = netdev_priv(dev); 4905 struct s2io_nic *sp = netdev_priv(dev);
4908 struct config_param *config = &sp->config;
4909 struct mac_info *mac_control = &sp->mac_control; 4906 struct mac_info *mac_control = &sp->mac_control;
4910 struct stat_block *stats = mac_control->stats_info; 4907 struct stat_block *stats = mac_control->stats_info;
4911 int i; 4908 u64 delta;
4912 4909
4913 /* Configure Stats for immediate updt */ 4910 /* Configure Stats for immediate updt */
4914 s2io_updt_stats(sp); 4911 s2io_updt_stats(sp);
4915 4912
4916 /* Using sp->stats as a staging area, because reset (due to mtu 4913 /* A device reset will cause the on-adapter statistics to be zero'ed.
4917 change, for example) will clear some hardware counters */ 4914 * This can be done while running by changing the MTU. To prevent the
4918 dev->stats.tx_packets += le32_to_cpu(stats->tmac_frms) - 4915 * system from having the stats zero'ed, the driver keeps a copy of the
4919 sp->stats.tx_packets; 4916 * last update to the system (which is also zero'ed on reset). This
4920 sp->stats.tx_packets = le32_to_cpu(stats->tmac_frms); 4917 * enables the driver to accurately know the delta between the last
4921 4918 * update and the current update.
4922 dev->stats.tx_errors += le32_to_cpu(stats->tmac_any_err_frms) - 4919 */
4923 sp->stats.tx_errors; 4920 delta = ((u64) le32_to_cpu(stats->rmac_vld_frms_oflow) << 32 |
4924 sp->stats.tx_errors = le32_to_cpu(stats->tmac_any_err_frms); 4921 le32_to_cpu(stats->rmac_vld_frms)) - sp->stats.rx_packets;
4925 4922 sp->stats.rx_packets += delta;
4926 dev->stats.rx_errors += le64_to_cpu(stats->rmac_drop_frms) - 4923 dev->stats.rx_packets += delta;
4927 sp->stats.rx_errors; 4924
4928 sp->stats.rx_errors = le64_to_cpu(stats->rmac_drop_frms); 4925 delta = ((u64) le32_to_cpu(stats->tmac_frms_oflow) << 32 |
4929 4926 le32_to_cpu(stats->tmac_frms)) - sp->stats.tx_packets;
4930 dev->stats.multicast = le32_to_cpu(stats->rmac_vld_mcst_frms) - 4927 sp->stats.tx_packets += delta;
4931 sp->stats.multicast; 4928 dev->stats.tx_packets += delta;
4932 sp->stats.multicast = le32_to_cpu(stats->rmac_vld_mcst_frms); 4929
4933 4930 delta = ((u64) le32_to_cpu(stats->rmac_data_octets_oflow) << 32 |
4934 dev->stats.rx_length_errors = le64_to_cpu(stats->rmac_long_frms) - 4931 le32_to_cpu(stats->rmac_data_octets)) - sp->stats.rx_bytes;
4935 sp->stats.rx_length_errors; 4932 sp->stats.rx_bytes += delta;
4936 sp->stats.rx_length_errors = le64_to_cpu(stats->rmac_long_frms); 4933 dev->stats.rx_bytes += delta;
4934
4935 delta = ((u64) le32_to_cpu(stats->tmac_data_octets_oflow) << 32 |
4936 le32_to_cpu(stats->tmac_data_octets)) - sp->stats.tx_bytes;
4937 sp->stats.tx_bytes += delta;
4938 dev->stats.tx_bytes += delta;
4939
4940 delta = le64_to_cpu(stats->rmac_drop_frms) - sp->stats.rx_errors;
4941 sp->stats.rx_errors += delta;
4942 dev->stats.rx_errors += delta;
4943
4944 delta = ((u64) le32_to_cpu(stats->tmac_any_err_frms_oflow) << 32 |
4945 le32_to_cpu(stats->tmac_any_err_frms)) - sp->stats.tx_errors;
4946 sp->stats.tx_errors += delta;
4947 dev->stats.tx_errors += delta;
4948
4949 delta = le64_to_cpu(stats->rmac_drop_frms) - sp->stats.rx_dropped;
4950 sp->stats.rx_dropped += delta;
4951 dev->stats.rx_dropped += delta;
4952
4953 delta = le64_to_cpu(stats->tmac_drop_frms) - sp->stats.tx_dropped;
4954 sp->stats.tx_dropped += delta;
4955 dev->stats.tx_dropped += delta;
4956
4957 /* The adapter MAC interprets pause frames as multicast packets, but
4958 * does not pass them up. This erroneously increases the multicast
4959 * packet count and needs to be deducted when the multicast frame count
4960 * is queried.
4961 */
4962 delta = (u64) le32_to_cpu(stats->rmac_vld_mcst_frms_oflow) << 32 |
4963 le32_to_cpu(stats->rmac_vld_mcst_frms);
4964 delta -= le64_to_cpu(stats->rmac_pause_ctrl_frms);
4965 delta -= sp->stats.multicast;
4966 sp->stats.multicast += delta;
4967 dev->stats.multicast += delta;
4937 4968
4938 /* collect per-ring rx_packets and rx_bytes */ 4969 delta = ((u64) le32_to_cpu(stats->rmac_usized_frms_oflow) << 32 |
4939 dev->stats.rx_packets = dev->stats.rx_bytes = 0; 4970 le32_to_cpu(stats->rmac_usized_frms)) +
4940 for (i = 0; i < config->rx_ring_num; i++) { 4971 le64_to_cpu(stats->rmac_long_frms) - sp->stats.rx_length_errors;
4941 struct ring_info *ring = &mac_control->rings[i]; 4972 sp->stats.rx_length_errors += delta;
4973 dev->stats.rx_length_errors += delta;
4942 4974
4943 dev->stats.rx_packets += ring->rx_packets; 4975 delta = le64_to_cpu(stats->rmac_fcs_err_frms) - sp->stats.rx_crc_errors;
4944 dev->stats.rx_bytes += ring->rx_bytes; 4976 sp->stats.rx_crc_errors += delta;
4945 } 4977 dev->stats.rx_crc_errors += delta;
4946 4978
4947 return &dev->stats; 4979 return &dev->stats;
4948} 4980}
@@ -7455,15 +7487,11 @@ static int rx_osm_handler(struct ring_info *ring_data, struct RxD_t * rxdp)
7455 } 7487 }
7456 } 7488 }
7457 7489
7458 /* Updating statistics */
7459 ring_data->rx_packets++;
7460 rxdp->Host_Control = 0; 7490 rxdp->Host_Control = 0;
7461 if (sp->rxd_mode == RXD_MODE_1) { 7491 if (sp->rxd_mode == RXD_MODE_1) {
7462 int len = RXD_GET_BUFFER0_SIZE_1(rxdp->Control_2); 7492 int len = RXD_GET_BUFFER0_SIZE_1(rxdp->Control_2);
7463 7493
7464 ring_data->rx_bytes += len;
7465 skb_put(skb, len); 7494 skb_put(skb, len);
7466
7467 } else if (sp->rxd_mode == RXD_MODE_3B) { 7495 } else if (sp->rxd_mode == RXD_MODE_3B) {
7468 int get_block = ring_data->rx_curr_get_info.block_index; 7496 int get_block = ring_data->rx_curr_get_info.block_index;
7469 int get_off = ring_data->rx_curr_get_info.offset; 7497 int get_off = ring_data->rx_curr_get_info.offset;
@@ -7472,7 +7500,6 @@ static int rx_osm_handler(struct ring_info *ring_data, struct RxD_t * rxdp)
7472 unsigned char *buff = skb_push(skb, buf0_len); 7500 unsigned char *buff = skb_push(skb, buf0_len);
7473 7501
7474 struct buffAdd *ba = &ring_data->ba[get_block][get_off]; 7502 struct buffAdd *ba = &ring_data->ba[get_block][get_off];
7475 ring_data->rx_bytes += buf0_len + buf2_len;
7476 memcpy(buff, ba->ba_0, buf0_len); 7503 memcpy(buff, ba->ba_0, buf0_len);
7477 skb_put(skb, buf2_len); 7504 skb_put(skb, buf2_len);
7478 } 7505 }
diff --git a/drivers/net/s2io.h b/drivers/net/s2io.h
index 47c36e0994f5..7f3a53dcc6ef 100644
--- a/drivers/net/s2io.h
+++ b/drivers/net/s2io.h
@@ -65,7 +65,7 @@ static int debug_level = ERR_DBG;
65 65
66/* DEBUG message print. */ 66/* DEBUG message print. */
67#define DBG_PRINT(dbg_level, fmt, args...) do { \ 67#define DBG_PRINT(dbg_level, fmt, args...) do { \
68 if (dbg_level >= debug_level) \ 68 if (dbg_level <= debug_level) \
69 pr_info(fmt, ##args); \ 69 pr_info(fmt, ##args); \
70 } while (0) 70 } while (0)
71 71
@@ -745,10 +745,6 @@ struct ring_info {
745 745
746 /* Buffer Address store. */ 746 /* Buffer Address store. */
747 struct buffAdd **ba; 747 struct buffAdd **ba;
748
749 /* per-Ring statistics */
750 unsigned long rx_packets;
751 unsigned long rx_bytes;
752} ____cacheline_aligned; 748} ____cacheline_aligned;
753 749
754/* Fifo specific structure */ 750/* Fifo specific structure */
diff --git a/drivers/net/sb1250-mac.c b/drivers/net/sb1250-mac.c
index 1f3acc3a5dfd..79eee3062083 100644
--- a/drivers/net/sb1250-mac.c
+++ b/drivers/net/sb1250-mac.c
@@ -2671,6 +2671,7 @@ static struct platform_driver sbmac_driver = {
2671 .remove = __exit_p(sbmac_remove), 2671 .remove = __exit_p(sbmac_remove),
2672 .driver = { 2672 .driver = {
2673 .name = sbmac_string, 2673 .name = sbmac_string,
2674 .owner = THIS_MODULE,
2674 }, 2675 },
2675}; 2676};
2676 2677
diff --git a/drivers/net/sky2.c b/drivers/net/sky2.c
index 2111c7bbf578..7985165e84fc 100644
--- a/drivers/net/sky2.c
+++ b/drivers/net/sky2.c
@@ -717,11 +717,24 @@ static void sky2_phy_power_down(struct sky2_hw *hw, unsigned port)
717 sky2_write8(hw, B2_TST_CTRL1, TST_CFG_WRITE_OFF); 717 sky2_write8(hw, B2_TST_CTRL1, TST_CFG_WRITE_OFF);
718} 718}
719 719
720/* Enable Rx/Tx */
721static void sky2_enable_rx_tx(struct sky2_port *sky2)
722{
723 struct sky2_hw *hw = sky2->hw;
724 unsigned port = sky2->port;
725 u16 reg;
726
727 reg = gma_read16(hw, port, GM_GP_CTRL);
728 reg |= GM_GPCR_RX_ENA | GM_GPCR_TX_ENA;
729 gma_write16(hw, port, GM_GP_CTRL, reg);
730}
731
720/* Force a renegotiation */ 732/* Force a renegotiation */
721static void sky2_phy_reinit(struct sky2_port *sky2) 733static void sky2_phy_reinit(struct sky2_port *sky2)
722{ 734{
723 spin_lock_bh(&sky2->phy_lock); 735 spin_lock_bh(&sky2->phy_lock);
724 sky2_phy_init(sky2->hw, sky2->port); 736 sky2_phy_init(sky2->hw, sky2->port);
737 sky2_enable_rx_tx(sky2);
725 spin_unlock_bh(&sky2->phy_lock); 738 spin_unlock_bh(&sky2->phy_lock);
726} 739}
727 740
@@ -2040,7 +2053,6 @@ static void sky2_link_up(struct sky2_port *sky2)
2040{ 2053{
2041 struct sky2_hw *hw = sky2->hw; 2054 struct sky2_hw *hw = sky2->hw;
2042 unsigned port = sky2->port; 2055 unsigned port = sky2->port;
2043 u16 reg;
2044 static const char *fc_name[] = { 2056 static const char *fc_name[] = {
2045 [FC_NONE] = "none", 2057 [FC_NONE] = "none",
2046 [FC_TX] = "tx", 2058 [FC_TX] = "tx",
@@ -2048,10 +2060,7 @@ static void sky2_link_up(struct sky2_port *sky2)
2048 [FC_BOTH] = "both", 2060 [FC_BOTH] = "both",
2049 }; 2061 };
2050 2062
2051 /* enable Rx/Tx */ 2063 sky2_enable_rx_tx(sky2);
2052 reg = gma_read16(hw, port, GM_GP_CTRL);
2053 reg |= GM_GPCR_RX_ENA | GM_GPCR_TX_ENA;
2054 gma_write16(hw, port, GM_GP_CTRL, reg);
2055 2064
2056 gm_phy_write(hw, port, PHY_MARV_INT_MASK, PHY_M_DEF_MSK); 2065 gm_phy_write(hw, port, PHY_MARV_INT_MASK, PHY_M_DEF_MSK);
2057 2066
diff --git a/drivers/net/tulip/de2104x.c b/drivers/net/tulip/de2104x.c
index c0e70006374e..06b552fca63d 100644
--- a/drivers/net/tulip/de2104x.c
+++ b/drivers/net/tulip/de2104x.c
@@ -367,8 +367,8 @@ static u16 t21041_csr14[] = { 0xFFFF, 0xF7FD, 0xF7FD, 0x6F3F, 0x6F3D, };
367static u16 t21041_csr15[] = { 0x0008, 0x0006, 0x000E, 0x0008, 0x0008, }; 367static u16 t21041_csr15[] = { 0x0008, 0x0006, 0x000E, 0x0008, 0x0008, };
368 368
369 369
370#define dr32(reg) readl(de->regs + (reg)) 370#define dr32(reg) ioread32(de->regs + (reg))
371#define dw32(reg,val) writel((val), de->regs + (reg)) 371#define dw32(reg, val) iowrite32((val), de->regs + (reg))
372 372
373 373
374static void de_rx_err_acct (struct de_private *de, unsigned rx_tail, 374static void de_rx_err_acct (struct de_private *de, unsigned rx_tail,
@@ -1706,6 +1706,7 @@ static void __devinit de21040_get_mac_address (struct de_private *de)
1706 int value, boguscnt = 100000; 1706 int value, boguscnt = 100000;
1707 do { 1707 do {
1708 value = dr32(ROMCmd); 1708 value = dr32(ROMCmd);
1709 rmb();
1709 } while (value < 0 && --boguscnt > 0); 1710 } while (value < 0 && --boguscnt > 0);
1710 de->dev->dev_addr[i] = value; 1711 de->dev->dev_addr[i] = value;
1711 udelay(1); 1712 udelay(1);
diff --git a/drivers/net/tun.c b/drivers/net/tun.c
index 6ad6fe706312..63042596f0cf 100644
--- a/drivers/net/tun.c
+++ b/drivers/net/tun.c
@@ -736,8 +736,18 @@ static __inline__ ssize_t tun_put_user(struct tun_struct *tun,
736 gso.gso_type = VIRTIO_NET_HDR_GSO_TCPV6; 736 gso.gso_type = VIRTIO_NET_HDR_GSO_TCPV6;
737 else if (sinfo->gso_type & SKB_GSO_UDP) 737 else if (sinfo->gso_type & SKB_GSO_UDP)
738 gso.gso_type = VIRTIO_NET_HDR_GSO_UDP; 738 gso.gso_type = VIRTIO_NET_HDR_GSO_UDP;
739 else 739 else {
740 BUG(); 740 printk(KERN_ERR "tun: unexpected GSO type: "
741 "0x%x, gso_size %d, hdr_len %d\n",
742 sinfo->gso_type, gso.gso_size,
743 gso.hdr_len);
744 print_hex_dump(KERN_ERR, "tun: ",
745 DUMP_PREFIX_NONE,
746 16, 1, skb->head,
747 min((int)gso.hdr_len, 64), true);
748 WARN_ON_ONCE(1);
749 return -EINVAL;
750 }
741 if (sinfo->gso_type & SKB_GSO_TCP_ECN) 751 if (sinfo->gso_type & SKB_GSO_TCP_ECN)
742 gso.gso_type |= VIRTIO_NET_HDR_GSO_ECN; 752 gso.gso_type |= VIRTIO_NET_HDR_GSO_ECN;
743 } else 753 } else
diff --git a/drivers/net/ucc_geth.c b/drivers/net/ucc_geth.c
index 4a34833b85dd..807470e156af 100644
--- a/drivers/net/ucc_geth.c
+++ b/drivers/net/ucc_geth.c
@@ -3215,6 +3215,8 @@ static int ucc_geth_rx(struct ucc_geth_private *ugeth, u8 rxQ, int rx_work_limit
3215 __func__, __LINE__, (u32) skb); 3215 __func__, __LINE__, (u32) skb);
3216 if (skb) { 3216 if (skb) {
3217 skb->data = skb->head + NET_SKB_PAD; 3217 skb->data = skb->head + NET_SKB_PAD;
3218 skb->len = 0;
3219 skb_reset_tail_pointer(skb);
3218 __skb_queue_head(&ugeth->rx_recycle, skb); 3220 __skb_queue_head(&ugeth->rx_recycle, skb);
3219 } 3221 }
3220 3222
diff --git a/drivers/net/usb/hso.c b/drivers/net/usb/hso.c
index 0a3c41faea9c..4dd23513c5af 100644
--- a/drivers/net/usb/hso.c
+++ b/drivers/net/usb/hso.c
@@ -1334,7 +1334,6 @@ static int hso_serial_open(struct tty_struct *tty, struct file *filp)
1334 /* check for port already opened, if not set the termios */ 1334 /* check for port already opened, if not set the termios */
1335 serial->open_count++; 1335 serial->open_count++;
1336 if (serial->open_count == 1) { 1336 if (serial->open_count == 1) {
1337 tty->low_latency = 1;
1338 serial->rx_state = RX_IDLE; 1337 serial->rx_state = RX_IDLE;
1339 /* Force default termio settings */ 1338 /* Force default termio settings */
1340 _hso_serial_set_termios(tty, NULL); 1339 _hso_serial_set_termios(tty, NULL);
diff --git a/drivers/net/usb/rndis_host.c b/drivers/net/usb/rndis_host.c
index 28d3ee175e7b..dd8a4adf48ca 100644
--- a/drivers/net/usb/rndis_host.c
+++ b/drivers/net/usb/rndis_host.c
@@ -104,10 +104,8 @@ static void rndis_msg_indicate(struct usbnet *dev, struct rndis_indicate *msg,
104int rndis_command(struct usbnet *dev, struct rndis_msg_hdr *buf, int buflen) 104int rndis_command(struct usbnet *dev, struct rndis_msg_hdr *buf, int buflen)
105{ 105{
106 struct cdc_state *info = (void *) &dev->data; 106 struct cdc_state *info = (void *) &dev->data;
107 struct usb_cdc_notification notification;
108 int master_ifnum; 107 int master_ifnum;
109 int retval; 108 int retval;
110 int partial;
111 unsigned count; 109 unsigned count;
112 __le32 rsp; 110 __le32 rsp;
113 u32 xid = 0, msg_len, request_id; 111 u32 xid = 0, msg_len, request_id;
@@ -135,17 +133,13 @@ int rndis_command(struct usbnet *dev, struct rndis_msg_hdr *buf, int buflen)
135 if (unlikely(retval < 0 || xid == 0)) 133 if (unlikely(retval < 0 || xid == 0))
136 return retval; 134 return retval;
137 135
138 /* Some devices don't respond on the control channel until 136 // FIXME Seems like some devices discard responses when
139 * polled on the status channel, so do that first. */ 137 // we time out and cancel our "get response" requests...
140 retval = usb_interrupt_msg( 138 // so, this is fragile. Probably need to poll for status.
141 dev->udev,
142 usb_rcvintpipe(dev->udev, dev->status->desc.bEndpointAddress),
143 &notification, sizeof(notification), &partial,
144 RNDIS_CONTROL_TIMEOUT_MS);
145 if (unlikely(retval < 0))
146 return retval;
147 139
148 /* Poll the control channel; the request probably completed immediately */ 140 /* ignore status endpoint, just poll the control channel;
141 * the request probably completed immediately
142 */
149 rsp = buf->msg_type | RNDIS_MSG_COMPLETION; 143 rsp = buf->msg_type | RNDIS_MSG_COMPLETION;
150 for (count = 0; count < 10; count++) { 144 for (count = 0; count < 10; count++) {
151 memset(buf, 0, CONTROL_BUFFER_SIZE); 145 memset(buf, 0, CONTROL_BUFFER_SIZE);
diff --git a/drivers/net/usb/usbnet.c b/drivers/net/usb/usbnet.c
index a95c73de5824..81c76ada8e56 100644
--- a/drivers/net/usb/usbnet.c
+++ b/drivers/net/usb/usbnet.c
@@ -1293,6 +1293,9 @@ usbnet_probe (struct usb_interface *udev, const struct usb_device_id *prod)
1293 goto out; 1293 goto out;
1294 } 1294 }
1295 1295
1296 /* netdev_printk() needs this so do it as early as possible */
1297 SET_NETDEV_DEV(net, &udev->dev);
1298
1296 dev = netdev_priv(net); 1299 dev = netdev_priv(net);
1297 dev->udev = xdev; 1300 dev->udev = xdev;
1298 dev->intf = udev; 1301 dev->intf = udev;
@@ -1377,8 +1380,6 @@ usbnet_probe (struct usb_interface *udev, const struct usb_device_id *prod)
1377 dev->rx_urb_size = dev->hard_mtu; 1380 dev->rx_urb_size = dev->hard_mtu;
1378 dev->maxpacket = usb_maxpacket (dev->udev, dev->out, 1); 1381 dev->maxpacket = usb_maxpacket (dev->udev, dev->out, 1);
1379 1382
1380 SET_NETDEV_DEV(net, &udev->dev);
1381
1382 if ((dev->driver_info->flags & FLAG_WLAN) != 0) 1383 if ((dev->driver_info->flags & FLAG_WLAN) != 0)
1383 SET_NETDEV_DEVTYPE(net, &wlan_type); 1384 SET_NETDEV_DEVTYPE(net, &wlan_type);
1384 if ((dev->driver_info->flags & FLAG_WWAN) != 0) 1385 if ((dev->driver_info->flags & FLAG_WWAN) != 0)
diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
index 1edb7a61983c..bb6b67f6b0cc 100644
--- a/drivers/net/virtio_net.c
+++ b/drivers/net/virtio_net.c
@@ -415,7 +415,7 @@ static int add_recvbuf_mergeable(struct virtnet_info *vi, gfp_t gfp)
415static bool try_fill_recv(struct virtnet_info *vi, gfp_t gfp) 415static bool try_fill_recv(struct virtnet_info *vi, gfp_t gfp)
416{ 416{
417 int err; 417 int err;
418 bool oom = false; 418 bool oom;
419 419
420 do { 420 do {
421 if (vi->mergeable_rx_bufs) 421 if (vi->mergeable_rx_bufs)
@@ -425,10 +425,9 @@ static bool try_fill_recv(struct virtnet_info *vi, gfp_t gfp)
425 else 425 else
426 err = add_recvbuf_small(vi, gfp); 426 err = add_recvbuf_small(vi, gfp);
427 427
428 if (err < 0) { 428 oom = err == -ENOMEM;
429 oom = true; 429 if (err < 0)
430 break; 430 break;
431 }
432 ++vi->num; 431 ++vi->num;
433 } while (err > 0); 432 } while (err > 0);
434 if (unlikely(vi->num > vi->max)) 433 if (unlikely(vi->num > vi->max))
@@ -563,7 +562,6 @@ static netdev_tx_t start_xmit(struct sk_buff *skb, struct net_device *dev)
563 struct virtnet_info *vi = netdev_priv(dev); 562 struct virtnet_info *vi = netdev_priv(dev);
564 int capacity; 563 int capacity;
565 564
566again:
567 /* Free up any pending old buffers before queueing new ones. */ 565 /* Free up any pending old buffers before queueing new ones. */
568 free_old_xmit_skbs(vi); 566 free_old_xmit_skbs(vi);
569 567
@@ -572,14 +570,20 @@ again:
572 570
573 /* This can happen with OOM and indirect buffers. */ 571 /* This can happen with OOM and indirect buffers. */
574 if (unlikely(capacity < 0)) { 572 if (unlikely(capacity < 0)) {
575 netif_stop_queue(dev); 573 if (net_ratelimit()) {
576 dev_warn(&dev->dev, "Unexpected full queue\n"); 574 if (likely(capacity == -ENOMEM)) {
577 if (unlikely(!virtqueue_enable_cb(vi->svq))) { 575 dev_warn(&dev->dev,
578 virtqueue_disable_cb(vi->svq); 576 "TX queue failure: out of memory\n");
579 netif_start_queue(dev); 577 } else {
580 goto again; 578 dev->stats.tx_fifo_errors++;
579 dev_warn(&dev->dev,
580 "Unexpected TX queue failure: %d\n",
581 capacity);
582 }
581 } 583 }
582 return NETDEV_TX_BUSY; 584 dev->stats.tx_dropped++;
585 kfree_skb(skb);
586 return NETDEV_TX_OK;
583 } 587 }
584 virtqueue_kick(vi->svq); 588 virtqueue_kick(vi->svq);
585 589
diff --git a/drivers/net/vxge/vxge-main.c b/drivers/net/vxge/vxge-main.c
index b504bd561362..fc8b2d7a0919 100644
--- a/drivers/net/vxge/vxge-main.c
+++ b/drivers/net/vxge/vxge-main.c
@@ -2262,7 +2262,8 @@ start:
2262 vxge_debug_init(VXGE_ERR, 2262 vxge_debug_init(VXGE_ERR,
2263 "%s: memory allocation failed", 2263 "%s: memory allocation failed",
2264 VXGE_DRIVER_NAME); 2264 VXGE_DRIVER_NAME);
2265 return -ENOMEM; 2265 ret = -ENOMEM;
2266 goto alloc_entries_failed;
2266 } 2267 }
2267 2268
2268 vdev->vxge_entries = 2269 vdev->vxge_entries =
@@ -2271,8 +2272,8 @@ start:
2271 if (!vdev->vxge_entries) { 2272 if (!vdev->vxge_entries) {
2272 vxge_debug_init(VXGE_ERR, "%s: memory allocation failed", 2273 vxge_debug_init(VXGE_ERR, "%s: memory allocation failed",
2273 VXGE_DRIVER_NAME); 2274 VXGE_DRIVER_NAME);
2274 kfree(vdev->entries); 2275 ret = -ENOMEM;
2275 return -ENOMEM; 2276 goto alloc_vxge_entries_failed;
2276 } 2277 }
2277 2278
2278 for (i = 0, j = 0; i < vdev->no_of_vpath; i++) { 2279 for (i = 0, j = 0; i < vdev->no_of_vpath; i++) {
@@ -2303,22 +2304,32 @@ start:
2303 vxge_debug_init(VXGE_ERR, 2304 vxge_debug_init(VXGE_ERR,
2304 "%s: MSI-X enable failed for %d vectors, ret: %d", 2305 "%s: MSI-X enable failed for %d vectors, ret: %d",
2305 VXGE_DRIVER_NAME, vdev->intr_cnt, ret); 2306 VXGE_DRIVER_NAME, vdev->intr_cnt, ret);
2307 if ((max_config_vpath != VXGE_USE_DEFAULT) || (ret < 3)) {
2308 ret = -ENODEV;
2309 goto enable_msix_failed;
2310 }
2311
2306 kfree(vdev->entries); 2312 kfree(vdev->entries);
2307 kfree(vdev->vxge_entries); 2313 kfree(vdev->vxge_entries);
2308 vdev->entries = NULL; 2314 vdev->entries = NULL;
2309 vdev->vxge_entries = NULL; 2315 vdev->vxge_entries = NULL;
2310
2311 if ((max_config_vpath != VXGE_USE_DEFAULT) || (ret < 3))
2312 return -ENODEV;
2313 /* Try with less no of vector by reducing no of vpaths count */ 2316 /* Try with less no of vector by reducing no of vpaths count */
2314 temp = (ret - 1)/2; 2317 temp = (ret - 1)/2;
2315 vxge_close_vpaths(vdev, temp); 2318 vxge_close_vpaths(vdev, temp);
2316 vdev->no_of_vpath = temp; 2319 vdev->no_of_vpath = temp;
2317 goto start; 2320 goto start;
2318 } else if (ret < 0) 2321 } else if (ret < 0) {
2319 return -ENODEV; 2322 ret = -ENODEV;
2320 2323 goto enable_msix_failed;
2324 }
2321 return 0; 2325 return 0;
2326
2327enable_msix_failed:
2328 kfree(vdev->vxge_entries);
2329alloc_vxge_entries_failed:
2330 kfree(vdev->entries);
2331alloc_entries_failed:
2332 return ret;
2322} 2333}
2323 2334
2324static int vxge_enable_msix(struct vxgedev *vdev) 2335static int vxge_enable_msix(struct vxgedev *vdev)
@@ -4506,9 +4517,9 @@ vxge_starter(void)
4506 char version[32]; 4517 char version[32];
4507 snprintf(version, 32, "%s", DRV_VERSION); 4518 snprintf(version, 32, "%s", DRV_VERSION);
4508 4519
4509 printk(KERN_CRIT "%s: Copyright(c) 2002-2009 Neterion Inc\n", 4520 printk(KERN_INFO "%s: Copyright(c) 2002-2009 Neterion Inc\n",
4510 VXGE_DRIVER_NAME); 4521 VXGE_DRIVER_NAME);
4511 printk(KERN_CRIT "%s: Driver version: %s\n", 4522 printk(KERN_INFO "%s: Driver version: %s\n",
4512 VXGE_DRIVER_NAME, version); 4523 VXGE_DRIVER_NAME, version);
4513 4524
4514 verify_bandwidth(); 4525 verify_bandwidth();
diff --git a/drivers/net/wimax/i2400m/i2400m-usb.h b/drivers/net/wimax/i2400m/i2400m-usb.h
index 2d7c96d7e865..eb80243e22df 100644
--- a/drivers/net/wimax/i2400m/i2400m-usb.h
+++ b/drivers/net/wimax/i2400m/i2400m-usb.h
@@ -152,6 +152,7 @@ enum {
152 /* Device IDs */ 152 /* Device IDs */
153 USB_DEVICE_ID_I6050 = 0x0186, 153 USB_DEVICE_ID_I6050 = 0x0186,
154 USB_DEVICE_ID_I6050_2 = 0x0188, 154 USB_DEVICE_ID_I6050_2 = 0x0188,
155 USB_DEVICE_ID_I6250 = 0x0187,
155}; 156};
156 157
157 158
diff --git a/drivers/net/wimax/i2400m/usb.c b/drivers/net/wimax/i2400m/usb.c
index 0d5081d77dc0..d3365ac85dde 100644
--- a/drivers/net/wimax/i2400m/usb.c
+++ b/drivers/net/wimax/i2400m/usb.c
@@ -491,6 +491,7 @@ int i2400mu_probe(struct usb_interface *iface,
491 switch (id->idProduct) { 491 switch (id->idProduct) {
492 case USB_DEVICE_ID_I6050: 492 case USB_DEVICE_ID_I6050:
493 case USB_DEVICE_ID_I6050_2: 493 case USB_DEVICE_ID_I6050_2:
494 case USB_DEVICE_ID_I6250:
494 i2400mu->i6050 = 1; 495 i2400mu->i6050 = 1;
495 break; 496 break;
496 default: 497 default:
@@ -739,6 +740,7 @@ static
739struct usb_device_id i2400mu_id_table[] = { 740struct usb_device_id i2400mu_id_table[] = {
740 { USB_DEVICE(0x8086, USB_DEVICE_ID_I6050) }, 741 { USB_DEVICE(0x8086, USB_DEVICE_ID_I6050) },
741 { USB_DEVICE(0x8086, USB_DEVICE_ID_I6050_2) }, 742 { USB_DEVICE(0x8086, USB_DEVICE_ID_I6050_2) },
743 { USB_DEVICE(0x8086, USB_DEVICE_ID_I6250) },
742 { USB_DEVICE(0x8086, 0x0181) }, 744 { USB_DEVICE(0x8086, 0x0181) },
743 { USB_DEVICE(0x8086, 0x1403) }, 745 { USB_DEVICE(0x8086, 0x1403) },
744 { USB_DEVICE(0x8086, 0x1405) }, 746 { USB_DEVICE(0x8086, 0x1405) },
diff --git a/drivers/net/wireless/ath/ath5k/attach.c b/drivers/net/wireless/ath/ath5k/attach.c
index e0c244b02f05..31c008042bfe 100644
--- a/drivers/net/wireless/ath/ath5k/attach.c
+++ b/drivers/net/wireless/ath/ath5k/attach.c
@@ -126,6 +126,7 @@ int ath5k_hw_attach(struct ath5k_softc *sc)
126 ah->ah_ant_mode = AR5K_ANTMODE_DEFAULT; 126 ah->ah_ant_mode = AR5K_ANTMODE_DEFAULT;
127 ah->ah_noise_floor = -95; /* until first NF calibration is run */ 127 ah->ah_noise_floor = -95; /* until first NF calibration is run */
128 sc->ani_state.ani_mode = ATH5K_ANI_MODE_AUTO; 128 sc->ani_state.ani_mode = ATH5K_ANI_MODE_AUTO;
129 ah->ah_current_channel = &sc->channels[0];
129 130
130 /* 131 /*
131 * Find the mac version 132 * Find the mac version
diff --git a/drivers/net/wireless/ath/ath9k/ath9k.h b/drivers/net/wireless/ath/ath9k/ath9k.h
index fbb7dec6ddeb..5ea87736a6ae 100644
--- a/drivers/net/wireless/ath/ath9k/ath9k.h
+++ b/drivers/net/wireless/ath/ath9k/ath9k.h
@@ -445,6 +445,7 @@ void ath_deinit_leds(struct ath_softc *sc);
445#define SC_OP_TSF_RESET BIT(11) 445#define SC_OP_TSF_RESET BIT(11)
446#define SC_OP_BT_PRIORITY_DETECTED BIT(12) 446#define SC_OP_BT_PRIORITY_DETECTED BIT(12)
447#define SC_OP_BT_SCAN BIT(13) 447#define SC_OP_BT_SCAN BIT(13)
448#define SC_OP_ANI_RUN BIT(14)
448 449
449/* Powersave flags */ 450/* Powersave flags */
450#define PS_WAIT_FOR_BEACON BIT(0) 451#define PS_WAIT_FOR_BEACON BIT(0)
diff --git a/drivers/net/wireless/ath/ath9k/hif_usb.c b/drivers/net/wireless/ath/ath9k/hif_usb.c
index 77b359162d6c..23c15aa9fbd5 100644
--- a/drivers/net/wireless/ath/ath9k/hif_usb.c
+++ b/drivers/net/wireless/ath/ath9k/hif_usb.c
@@ -730,13 +730,17 @@ static int ath9k_hif_usb_alloc_urbs(struct hif_device_usb *hif_dev)
730 730
731 /* RX */ 731 /* RX */
732 if (ath9k_hif_usb_alloc_rx_urbs(hif_dev) < 0) 732 if (ath9k_hif_usb_alloc_rx_urbs(hif_dev) < 0)
733 goto err; 733 goto err_rx;
734 734
735 /* Register Read */ 735 /* Register Read */
736 if (ath9k_hif_usb_alloc_reg_in_urb(hif_dev) < 0) 736 if (ath9k_hif_usb_alloc_reg_in_urb(hif_dev) < 0)
737 goto err; 737 goto err_reg;
738 738
739 return 0; 739 return 0;
740err_reg:
741 ath9k_hif_usb_dealloc_rx_urbs(hif_dev);
742err_rx:
743 ath9k_hif_usb_dealloc_tx_urbs(hif_dev);
740err: 744err:
741 return -ENOMEM; 745 return -ENOMEM;
742} 746}
diff --git a/drivers/net/wireless/ath/ath9k/main.c b/drivers/net/wireless/ath/ath9k/main.c
index abfa0493236f..1e2a68ea9355 100644
--- a/drivers/net/wireless/ath/ath9k/main.c
+++ b/drivers/net/wireless/ath/ath9k/main.c
@@ -336,6 +336,10 @@ set_timer:
336static void ath_start_ani(struct ath_common *common) 336static void ath_start_ani(struct ath_common *common)
337{ 337{
338 unsigned long timestamp = jiffies_to_msecs(jiffies); 338 unsigned long timestamp = jiffies_to_msecs(jiffies);
339 struct ath_softc *sc = (struct ath_softc *) common->priv;
340
341 if (!(sc->sc_flags & SC_OP_ANI_RUN))
342 return;
339 343
340 common->ani.longcal_timer = timestamp; 344 common->ani.longcal_timer = timestamp;
341 common->ani.shortcal_timer = timestamp; 345 common->ani.shortcal_timer = timestamp;
@@ -872,11 +876,13 @@ static void ath9k_bss_assoc_info(struct ath_softc *sc,
872 /* Reset rssi stats */ 876 /* Reset rssi stats */
873 sc->sc_ah->stats.avgbrssi = ATH_RSSI_DUMMY_MARKER; 877 sc->sc_ah->stats.avgbrssi = ATH_RSSI_DUMMY_MARKER;
874 878
879 sc->sc_flags |= SC_OP_ANI_RUN;
875 ath_start_ani(common); 880 ath_start_ani(common);
876 } else { 881 } else {
877 ath_print(common, ATH_DBG_CONFIG, "Bss Info DISASSOC\n"); 882 ath_print(common, ATH_DBG_CONFIG, "Bss Info DISASSOC\n");
878 common->curaid = 0; 883 common->curaid = 0;
879 /* Stop ANI */ 884 /* Stop ANI */
885 sc->sc_flags &= ~SC_OP_ANI_RUN;
880 del_timer_sync(&common->ani.timer); 886 del_timer_sync(&common->ani.timer);
881 } 887 }
882} 888}
@@ -1478,8 +1484,10 @@ static int ath9k_add_interface(struct ieee80211_hw *hw,
1478 1484
1479 if (vif->type == NL80211_IFTYPE_AP || 1485 if (vif->type == NL80211_IFTYPE_AP ||
1480 vif->type == NL80211_IFTYPE_ADHOC || 1486 vif->type == NL80211_IFTYPE_ADHOC ||
1481 vif->type == NL80211_IFTYPE_MONITOR) 1487 vif->type == NL80211_IFTYPE_MONITOR) {
1488 sc->sc_flags |= SC_OP_ANI_RUN;
1482 ath_start_ani(common); 1489 ath_start_ani(common);
1490 }
1483 1491
1484out: 1492out:
1485 mutex_unlock(&sc->mutex); 1493 mutex_unlock(&sc->mutex);
@@ -1500,6 +1508,7 @@ static void ath9k_remove_interface(struct ieee80211_hw *hw,
1500 mutex_lock(&sc->mutex); 1508 mutex_lock(&sc->mutex);
1501 1509
1502 /* Stop ANI */ 1510 /* Stop ANI */
1511 sc->sc_flags &= ~SC_OP_ANI_RUN;
1503 del_timer_sync(&common->ani.timer); 1512 del_timer_sync(&common->ani.timer);
1504 1513
1505 /* Reclaim beacon resources */ 1514 /* Reclaim beacon resources */
diff --git a/drivers/net/wireless/ath/ath9k/recv.c b/drivers/net/wireless/ath/ath9k/recv.c
index ca6065b71b46..e3e52913d83a 100644
--- a/drivers/net/wireless/ath/ath9k/recv.c
+++ b/drivers/net/wireless/ath/ath9k/recv.c
@@ -844,9 +844,9 @@ int ath_rx_tasklet(struct ath_softc *sc, int flush, bool hp)
844 int dma_type; 844 int dma_type;
845 845
846 if (edma) 846 if (edma)
847 dma_type = DMA_FROM_DEVICE;
848 else
849 dma_type = DMA_BIDIRECTIONAL; 847 dma_type = DMA_BIDIRECTIONAL;
848 else
849 dma_type = DMA_FROM_DEVICE;
850 850
851 qtype = hp ? ATH9K_RX_QUEUE_HP : ATH9K_RX_QUEUE_LP; 851 qtype = hp ? ATH9K_RX_QUEUE_HP : ATH9K_RX_QUEUE_LP;
852 spin_lock_bh(&sc->rx.rxbuflock); 852 spin_lock_bh(&sc->rx.rxbuflock);
diff --git a/drivers/net/wireless/hostap/hostap_cs.c b/drivers/net/wireless/hostap/hostap_cs.c
index db72461c486b..29b31a694b59 100644
--- a/drivers/net/wireless/hostap/hostap_cs.c
+++ b/drivers/net/wireless/hostap/hostap_cs.c
@@ -594,6 +594,7 @@ static int prism2_config(struct pcmcia_device *link)
594 local_info_t *local; 594 local_info_t *local;
595 int ret = 1; 595 int ret = 1;
596 struct hostap_cs_priv *hw_priv; 596 struct hostap_cs_priv *hw_priv;
597 unsigned long flags;
597 598
598 PDEBUG(DEBUG_FLOW, "prism2_config()\n"); 599 PDEBUG(DEBUG_FLOW, "prism2_config()\n");
599 600
@@ -625,9 +626,15 @@ static int prism2_config(struct pcmcia_device *link)
625 local->hw_priv = hw_priv; 626 local->hw_priv = hw_priv;
626 hw_priv->link = link; 627 hw_priv->link = link;
627 628
629 /*
630 * Make sure the IRQ handler cannot proceed until at least
631 * dev->base_addr is initialized.
632 */
633 spin_lock_irqsave(&local->irq_init_lock, flags);
634
628 ret = pcmcia_request_irq(link, prism2_interrupt); 635 ret = pcmcia_request_irq(link, prism2_interrupt);
629 if (ret) 636 if (ret)
630 goto failed; 637 goto failed_unlock;
631 638
632 /* 639 /*
633 * This actually configures the PCMCIA socket -- setting up 640 * This actually configures the PCMCIA socket -- setting up
@@ -636,11 +643,13 @@ static int prism2_config(struct pcmcia_device *link)
636 */ 643 */
637 ret = pcmcia_request_configuration(link, &link->conf); 644 ret = pcmcia_request_configuration(link, &link->conf);
638 if (ret) 645 if (ret)
639 goto failed; 646 goto failed_unlock;
640 647
641 dev->irq = link->irq; 648 dev->irq = link->irq;
642 dev->base_addr = link->io.BasePort1; 649 dev->base_addr = link->io.BasePort1;
643 650
651 spin_unlock_irqrestore(&local->irq_init_lock, flags);
652
644 /* Finally, report what we've done */ 653 /* Finally, report what we've done */
645 printk(KERN_INFO "%s: index 0x%02x: ", 654 printk(KERN_INFO "%s: index 0x%02x: ",
646 dev_info, link->conf.ConfigIndex); 655 dev_info, link->conf.ConfigIndex);
@@ -667,6 +676,8 @@ static int prism2_config(struct pcmcia_device *link)
667 676
668 return ret; 677 return ret;
669 678
679 failed_unlock:
680 spin_unlock_irqrestore(&local->irq_init_lock, flags);
670 failed: 681 failed:
671 kfree(hw_priv); 682 kfree(hw_priv);
672 prism2_release((u_long)link); 683 prism2_release((u_long)link);
diff --git a/drivers/net/wireless/hostap/hostap_hw.c b/drivers/net/wireless/hostap/hostap_hw.c
index 30c2976b3624..e9d9d622a9b0 100644
--- a/drivers/net/wireless/hostap/hostap_hw.c
+++ b/drivers/net/wireless/hostap/hostap_hw.c
@@ -2621,6 +2621,18 @@ static irqreturn_t prism2_interrupt(int irq, void *dev_id)
2621 iface = netdev_priv(dev); 2621 iface = netdev_priv(dev);
2622 local = iface->local; 2622 local = iface->local;
2623 2623
2624 /* Detect early interrupt before driver is fully configued */
2625 spin_lock(&local->irq_init_lock);
2626 if (!dev->base_addr) {
2627 if (net_ratelimit()) {
2628 printk(KERN_DEBUG "%s: Interrupt, but dev not configured\n",
2629 dev->name);
2630 }
2631 spin_unlock(&local->irq_init_lock);
2632 return IRQ_HANDLED;
2633 }
2634 spin_unlock(&local->irq_init_lock);
2635
2624 prism2_io_debug_add(dev, PRISM2_IO_DEBUG_CMD_INTERRUPT, 0, 0); 2636 prism2_io_debug_add(dev, PRISM2_IO_DEBUG_CMD_INTERRUPT, 0, 0);
2625 2637
2626 if (local->func->card_present && !local->func->card_present(local)) { 2638 if (local->func->card_present && !local->func->card_present(local)) {
@@ -3138,6 +3150,7 @@ prism2_init_local_data(struct prism2_helper_functions *funcs, int card_idx,
3138 spin_lock_init(&local->cmdlock); 3150 spin_lock_init(&local->cmdlock);
3139 spin_lock_init(&local->baplock); 3151 spin_lock_init(&local->baplock);
3140 spin_lock_init(&local->lock); 3152 spin_lock_init(&local->lock);
3153 spin_lock_init(&local->irq_init_lock);
3141 mutex_init(&local->rid_bap_mtx); 3154 mutex_init(&local->rid_bap_mtx);
3142 3155
3143 if (card_idx < 0 || card_idx >= MAX_PARM_DEVICES) 3156 if (card_idx < 0 || card_idx >= MAX_PARM_DEVICES)
diff --git a/drivers/net/wireless/hostap/hostap_pci.c b/drivers/net/wireless/hostap/hostap_pci.c
index d24dc7dc0723..972a9c3af39e 100644
--- a/drivers/net/wireless/hostap/hostap_pci.c
+++ b/drivers/net/wireless/hostap/hostap_pci.c
@@ -330,6 +330,7 @@ static int prism2_pci_probe(struct pci_dev *pdev,
330 330
331 dev->irq = pdev->irq; 331 dev->irq = pdev->irq;
332 hw_priv->mem_start = mem; 332 hw_priv->mem_start = mem;
333 dev->base_addr = (unsigned long) mem;
333 334
334 prism2_pci_cor_sreset(local); 335 prism2_pci_cor_sreset(local);
335 336
diff --git a/drivers/net/wireless/hostap/hostap_wlan.h b/drivers/net/wireless/hostap/hostap_wlan.h
index 3d238917af07..1ba33be98b25 100644
--- a/drivers/net/wireless/hostap/hostap_wlan.h
+++ b/drivers/net/wireless/hostap/hostap_wlan.h
@@ -654,7 +654,7 @@ struct local_info {
654 rwlock_t iface_lock; /* hostap_interfaces read lock; use write lock 654 rwlock_t iface_lock; /* hostap_interfaces read lock; use write lock
655 * when removing entries from the list. 655 * when removing entries from the list.
656 * TX and RX paths can use read lock. */ 656 * TX and RX paths can use read lock. */
657 spinlock_t cmdlock, baplock, lock; 657 spinlock_t cmdlock, baplock, lock, irq_init_lock;
658 struct mutex rid_bap_mtx; 658 struct mutex rid_bap_mtx;
659 u16 infofid; /* MAC buffer id for info frame */ 659 u16 infofid; /* MAC buffer id for info frame */
660 /* txfid, intransmitfid, next_txtid, and next_alloc are protected by 660 /* txfid, intransmitfid, next_txtid, and next_alloc are protected by
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-hcmd.c b/drivers/net/wireless/iwlwifi/iwl-agn-hcmd.c
index 44ef5d93befc..01658cf82d39 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn-hcmd.c
+++ b/drivers/net/wireless/iwlwifi/iwl-agn-hcmd.c
@@ -212,11 +212,7 @@ static void iwlagn_chain_noise_reset(struct iwl_priv *priv)
212static void iwlagn_rts_tx_cmd_flag(struct ieee80211_tx_info *info, 212static void iwlagn_rts_tx_cmd_flag(struct ieee80211_tx_info *info,
213 __le32 *tx_flags) 213 __le32 *tx_flags)
214{ 214{
215 if ((info->control.rates[0].flags & IEEE80211_TX_RC_USE_RTS_CTS) || 215 *tx_flags |= TX_CMD_FLG_RTS_CTS_MSK;
216 (info->control.rates[0].flags & IEEE80211_TX_RC_USE_CTS_PROTECT))
217 *tx_flags |= TX_CMD_FLG_RTS_CTS_MSK;
218 else
219 *tx_flags &= ~TX_CMD_FLG_RTS_CTS_MSK;
220} 216}
221 217
222/* Calc max signal level (dBm) among 3 possible receivers */ 218/* Calc max signal level (dBm) among 3 possible receivers */
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-tx.c b/drivers/net/wireless/iwlwifi/iwl-agn-tx.c
index a732f1094e5d..7d614c4d3c62 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn-tx.c
+++ b/drivers/net/wireless/iwlwifi/iwl-agn-tx.c
@@ -1299,6 +1299,11 @@ void iwlagn_rx_reply_compressed_ba(struct iwl_priv *priv,
1299 sta_id = ba_resp->sta_id; 1299 sta_id = ba_resp->sta_id;
1300 tid = ba_resp->tid; 1300 tid = ba_resp->tid;
1301 agg = &priv->stations[sta_id].tid[tid].agg; 1301 agg = &priv->stations[sta_id].tid[tid].agg;
1302 if (unlikely(agg->txq_id != scd_flow)) {
1303 IWL_ERR(priv, "BA scd_flow %d does not match txq_id %d\n",
1304 scd_flow, agg->txq_id);
1305 return;
1306 }
1302 1307
1303 /* Find index just before block-ack window */ 1308 /* Find index just before block-ack window */
1304 index = iwl_queue_dec_wrap(ba_resp_scd_ssn & 0xff, txq->q.n_bd); 1309 index = iwl_queue_dec_wrap(ba_resp_scd_ssn & 0xff, txq->q.n_bd);
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.c b/drivers/net/wireless/iwlwifi/iwl-agn.c
index 7726e67044c0..24aff654fa9c 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn.c
+++ b/drivers/net/wireless/iwlwifi/iwl-agn.c
@@ -3391,10 +3391,12 @@ static int iwlagn_mac_sta_add(struct ieee80211_hw *hw,
3391 int ret; 3391 int ret;
3392 u8 sta_id; 3392 u8 sta_id;
3393 3393
3394 sta_priv->common.sta_id = IWL_INVALID_STATION;
3395
3396 IWL_DEBUG_INFO(priv, "received request to add station %pM\n", 3394 IWL_DEBUG_INFO(priv, "received request to add station %pM\n",
3397 sta->addr); 3395 sta->addr);
3396 mutex_lock(&priv->mutex);
3397 IWL_DEBUG_INFO(priv, "proceeding to add station %pM\n",
3398 sta->addr);
3399 sta_priv->common.sta_id = IWL_INVALID_STATION;
3398 3400
3399 atomic_set(&sta_priv->pending_frames, 0); 3401 atomic_set(&sta_priv->pending_frames, 0);
3400 if (vif->type == NL80211_IFTYPE_AP) 3402 if (vif->type == NL80211_IFTYPE_AP)
@@ -3406,6 +3408,7 @@ static int iwlagn_mac_sta_add(struct ieee80211_hw *hw,
3406 IWL_ERR(priv, "Unable to add station %pM (%d)\n", 3408 IWL_ERR(priv, "Unable to add station %pM (%d)\n",
3407 sta->addr, ret); 3409 sta->addr, ret);
3408 /* Should we return success if return code is EEXIST ? */ 3410 /* Should we return success if return code is EEXIST ? */
3411 mutex_unlock(&priv->mutex);
3409 return ret; 3412 return ret;
3410 } 3413 }
3411 3414
@@ -3415,6 +3418,7 @@ static int iwlagn_mac_sta_add(struct ieee80211_hw *hw,
3415 IWL_DEBUG_INFO(priv, "Initializing rate scaling for station %pM\n", 3418 IWL_DEBUG_INFO(priv, "Initializing rate scaling for station %pM\n",
3416 sta->addr); 3419 sta->addr);
3417 iwl_rs_rate_init(priv, sta, sta_id); 3420 iwl_rs_rate_init(priv, sta, sta_id);
3421 mutex_unlock(&priv->mutex);
3418 3422
3419 return 0; 3423 return 0;
3420} 3424}
diff --git a/drivers/net/wireless/iwlwifi/iwl-core.c b/drivers/net/wireless/iwlwifi/iwl-core.c
index 426e95567de3..5bbc5298ef96 100644
--- a/drivers/net/wireless/iwlwifi/iwl-core.c
+++ b/drivers/net/wireless/iwlwifi/iwl-core.c
@@ -1314,7 +1314,6 @@ void iwl_configure_filter(struct ieee80211_hw *hw,
1314 changed_flags, *total_flags); 1314 changed_flags, *total_flags);
1315 1315
1316 CHK(FIF_OTHER_BSS | FIF_PROMISC_IN_BSS, RXON_FILTER_PROMISC_MSK); 1316 CHK(FIF_OTHER_BSS | FIF_PROMISC_IN_BSS, RXON_FILTER_PROMISC_MSK);
1317 CHK(FIF_ALLMULTI, RXON_FILTER_ACCEPT_GRP_MSK);
1318 CHK(FIF_CONTROL, RXON_FILTER_CTL2HOST_MSK); 1317 CHK(FIF_CONTROL, RXON_FILTER_CTL2HOST_MSK);
1319 CHK(FIF_BCN_PRBRESP_PROMISC, RXON_FILTER_BCON_AWARE_MSK); 1318 CHK(FIF_BCN_PRBRESP_PROMISC, RXON_FILTER_BCON_AWARE_MSK);
1320 1319
@@ -1329,6 +1328,12 @@ void iwl_configure_filter(struct ieee80211_hw *hw,
1329 1328
1330 mutex_unlock(&priv->mutex); 1329 mutex_unlock(&priv->mutex);
1331 1330
1331 /*
1332 * Receiving all multicast frames is always enabled by the
1333 * default flags setup in iwl_connection_init_rx_config()
1334 * since we currently do not support programming multicast
1335 * filters into the device.
1336 */
1332 *total_flags &= FIF_OTHER_BSS | FIF_ALLMULTI | FIF_PROMISC_IN_BSS | 1337 *total_flags &= FIF_OTHER_BSS | FIF_ALLMULTI | FIF_PROMISC_IN_BSS |
1333 FIF_BCN_PRBRESP_PROMISC | FIF_CONTROL; 1338 FIF_BCN_PRBRESP_PROMISC | FIF_CONTROL;
1334} 1339}
diff --git a/drivers/net/wireless/iwlwifi/iwl-scan.c b/drivers/net/wireless/iwlwifi/iwl-scan.c
index 5d3f51ff2f0d..386c5f96eff8 100644
--- a/drivers/net/wireless/iwlwifi/iwl-scan.c
+++ b/drivers/net/wireless/iwlwifi/iwl-scan.c
@@ -491,6 +491,7 @@ void iwl_bg_abort_scan(struct work_struct *work)
491 491
492 mutex_lock(&priv->mutex); 492 mutex_lock(&priv->mutex);
493 493
494 cancel_delayed_work_sync(&priv->scan_check);
494 set_bit(STATUS_SCAN_ABORTING, &priv->status); 495 set_bit(STATUS_SCAN_ABORTING, &priv->status);
495 iwl_send_scan_abort(priv); 496 iwl_send_scan_abort(priv);
496 497
diff --git a/drivers/net/wireless/iwlwifi/iwl-sta.c b/drivers/net/wireless/iwlwifi/iwl-sta.c
index 83a26361a9b5..c27c13fbb1ae 100644
--- a/drivers/net/wireless/iwlwifi/iwl-sta.c
+++ b/drivers/net/wireless/iwlwifi/iwl-sta.c
@@ -1373,10 +1373,14 @@ int iwl_mac_sta_remove(struct ieee80211_hw *hw,
1373 1373
1374 IWL_DEBUG_INFO(priv, "received request to remove station %pM\n", 1374 IWL_DEBUG_INFO(priv, "received request to remove station %pM\n",
1375 sta->addr); 1375 sta->addr);
1376 mutex_lock(&priv->mutex);
1377 IWL_DEBUG_INFO(priv, "proceeding to remove station %pM\n",
1378 sta->addr);
1376 ret = iwl_remove_station(priv, sta_common->sta_id, sta->addr); 1379 ret = iwl_remove_station(priv, sta_common->sta_id, sta->addr);
1377 if (ret) 1380 if (ret)
1378 IWL_ERR(priv, "Error removing station %pM\n", 1381 IWL_ERR(priv, "Error removing station %pM\n",
1379 sta->addr); 1382 sta->addr);
1383 mutex_unlock(&priv->mutex);
1380 return ret; 1384 return ret;
1381} 1385}
1382EXPORT_SYMBOL(iwl_mac_sta_remove); 1386EXPORT_SYMBOL(iwl_mac_sta_remove);
diff --git a/drivers/net/wireless/iwlwifi/iwl-sta.h b/drivers/net/wireless/iwlwifi/iwl-sta.h
index c2a453a1a991..dc43ebd1f1fd 100644
--- a/drivers/net/wireless/iwlwifi/iwl-sta.h
+++ b/drivers/net/wireless/iwlwifi/iwl-sta.h
@@ -97,6 +97,17 @@ static inline void iwl_clear_driver_stations(struct iwl_priv *priv)
97 spin_lock_irqsave(&priv->sta_lock, flags); 97 spin_lock_irqsave(&priv->sta_lock, flags);
98 memset(priv->stations, 0, sizeof(priv->stations)); 98 memset(priv->stations, 0, sizeof(priv->stations));
99 priv->num_stations = 0; 99 priv->num_stations = 0;
100
101 /*
102 * Remove all key information that is not stored as part of station
103 * information since mac80211 may not have had a
104 * chance to remove all the keys. When device is reconfigured by
105 * mac80211 after an error all keys will be reconfigured.
106 */
107 priv->ucode_key_table = 0;
108 priv->key_mapping_key = 0;
109 memset(priv->wep_keys, 0, sizeof(priv->wep_keys));
110
100 spin_unlock_irqrestore(&priv->sta_lock, flags); 111 spin_unlock_irqrestore(&priv->sta_lock, flags);
101} 112}
102 113
diff --git a/drivers/net/wireless/iwlwifi/iwl3945-base.c b/drivers/net/wireless/iwlwifi/iwl3945-base.c
index 6c353cacc8d6..a27872de4106 100644
--- a/drivers/net/wireless/iwlwifi/iwl3945-base.c
+++ b/drivers/net/wireless/iwlwifi/iwl3945-base.c
@@ -3437,10 +3437,13 @@ static int iwl3945_mac_sta_add(struct ieee80211_hw *hw,
3437 bool is_ap = vif->type == NL80211_IFTYPE_STATION; 3437 bool is_ap = vif->type == NL80211_IFTYPE_STATION;
3438 u8 sta_id; 3438 u8 sta_id;
3439 3439
3440 sta_priv->common.sta_id = IWL_INVALID_STATION;
3441
3442 IWL_DEBUG_INFO(priv, "received request to add station %pM\n", 3440 IWL_DEBUG_INFO(priv, "received request to add station %pM\n",
3443 sta->addr); 3441 sta->addr);
3442 mutex_lock(&priv->mutex);
3443 IWL_DEBUG_INFO(priv, "proceeding to add station %pM\n",
3444 sta->addr);
3445 sta_priv->common.sta_id = IWL_INVALID_STATION;
3446
3444 3447
3445 ret = iwl_add_station_common(priv, sta->addr, is_ap, &sta->ht_cap, 3448 ret = iwl_add_station_common(priv, sta->addr, is_ap, &sta->ht_cap,
3446 &sta_id); 3449 &sta_id);
@@ -3448,6 +3451,7 @@ static int iwl3945_mac_sta_add(struct ieee80211_hw *hw,
3448 IWL_ERR(priv, "Unable to add station %pM (%d)\n", 3451 IWL_ERR(priv, "Unable to add station %pM (%d)\n",
3449 sta->addr, ret); 3452 sta->addr, ret);
3450 /* Should we return success if return code is EEXIST ? */ 3453 /* Should we return success if return code is EEXIST ? */
3454 mutex_unlock(&priv->mutex);
3451 return ret; 3455 return ret;
3452 } 3456 }
3453 3457
@@ -3457,6 +3461,7 @@ static int iwl3945_mac_sta_add(struct ieee80211_hw *hw,
3457 IWL_DEBUG_INFO(priv, "Initializing rate scaling for station %pM\n", 3461 IWL_DEBUG_INFO(priv, "Initializing rate scaling for station %pM\n",
3458 sta->addr); 3462 sta->addr);
3459 iwl3945_rs_rate_init(priv, sta, sta_id); 3463 iwl3945_rs_rate_init(priv, sta, sta_id);
3464 mutex_unlock(&priv->mutex);
3460 3465
3461 return 0; 3466 return 0;
3462} 3467}
diff --git a/drivers/net/wireless/libertas_tf/main.c b/drivers/net/wireless/libertas_tf/main.c
index 6a04c2157f73..817fffc0de4b 100644
--- a/drivers/net/wireless/libertas_tf/main.c
+++ b/drivers/net/wireless/libertas_tf/main.c
@@ -549,7 +549,7 @@ int lbtf_rx(struct lbtf_private *priv, struct sk_buff *skb)
549 549
550 prxpd = (struct rxpd *) skb->data; 550 prxpd = (struct rxpd *) skb->data;
551 551
552 stats.flag = 0; 552 memset(&stats, 0, sizeof(stats));
553 if (!(prxpd->status & cpu_to_le16(MRVDRV_RXPD_STATUS_OK))) 553 if (!(prxpd->status & cpu_to_le16(MRVDRV_RXPD_STATUS_OK)))
554 stats.flag |= RX_FLAG_FAILED_FCS_CRC; 554 stats.flag |= RX_FLAG_FAILED_FCS_CRC;
555 stats.freq = priv->cur_freq; 555 stats.freq = priv->cur_freq;
diff --git a/drivers/net/wireless/p54/p54pci.c b/drivers/net/wireless/p54/p54pci.c
index 07c4528f6e6b..a5ea89cde8c4 100644
--- a/drivers/net/wireless/p54/p54pci.c
+++ b/drivers/net/wireless/p54/p54pci.c
@@ -41,6 +41,8 @@ static DEFINE_PCI_DEVICE_TABLE(p54p_table) = {
41 { PCI_DEVICE(0x1260, 0x3877) }, 41 { PCI_DEVICE(0x1260, 0x3877) },
42 /* Intersil PRISM Javelin/Xbow Wireless LAN adapter */ 42 /* Intersil PRISM Javelin/Xbow Wireless LAN adapter */
43 { PCI_DEVICE(0x1260, 0x3886) }, 43 { PCI_DEVICE(0x1260, 0x3886) },
44 /* Intersil PRISM Xbow Wireless LAN adapter (Symbol AP-300) */
45 { PCI_DEVICE(0x1260, 0xffff) },
44 { }, 46 { },
45}; 47};
46 48
diff --git a/drivers/net/wireless/rt2x00/rt2x00dev.c b/drivers/net/wireless/rt2x00/rt2x00dev.c
index 3ae468c4d760..f20d3eeeea7f 100644
--- a/drivers/net/wireless/rt2x00/rt2x00dev.c
+++ b/drivers/net/wireless/rt2x00/rt2x00dev.c
@@ -854,6 +854,11 @@ int rt2x00lib_probe_dev(struct rt2x00_dev *rt2x00dev)
854 BIT(NL80211_IFTYPE_WDS); 854 BIT(NL80211_IFTYPE_WDS);
855 855
856 /* 856 /*
857 * Initialize configuration work.
858 */
859 INIT_WORK(&rt2x00dev->intf_work, rt2x00lib_intf_scheduled);
860
861 /*
857 * Let the driver probe the device to detect the capabilities. 862 * Let the driver probe the device to detect the capabilities.
858 */ 863 */
859 retval = rt2x00dev->ops->lib->probe_hw(rt2x00dev); 864 retval = rt2x00dev->ops->lib->probe_hw(rt2x00dev);
@@ -863,11 +868,6 @@ int rt2x00lib_probe_dev(struct rt2x00_dev *rt2x00dev)
863 } 868 }
864 869
865 /* 870 /*
866 * Initialize configuration work.
867 */
868 INIT_WORK(&rt2x00dev->intf_work, rt2x00lib_intf_scheduled);
869
870 /*
871 * Allocate queue array. 871 * Allocate queue array.
872 */ 872 */
873 retval = rt2x00queue_allocate(rt2x00dev); 873 retval = rt2x00queue_allocate(rt2x00dev);
diff --git a/drivers/parisc/led.c b/drivers/parisc/led.c
index 188bc8496a26..d02be78a4138 100644
--- a/drivers/parisc/led.c
+++ b/drivers/parisc/led.c
@@ -176,16 +176,18 @@ static ssize_t led_proc_write(struct file *file, const char *buf,
176 size_t count, loff_t *pos) 176 size_t count, loff_t *pos)
177{ 177{
178 void *data = PDE(file->f_path.dentry->d_inode)->data; 178 void *data = PDE(file->f_path.dentry->d_inode)->data;
179 char *cur, lbuf[count + 1]; 179 char *cur, lbuf[32];
180 int d; 180 int d;
181 181
182 if (!capable(CAP_SYS_ADMIN)) 182 if (!capable(CAP_SYS_ADMIN))
183 return -EACCES; 183 return -EACCES;
184 184
185 memset(lbuf, 0, count + 1); 185 if (count >= sizeof(lbuf))
186 count = sizeof(lbuf)-1;
186 187
187 if (copy_from_user(lbuf, buf, count)) 188 if (copy_from_user(lbuf, buf, count))
188 return -EFAULT; 189 return -EFAULT;
190 lbuf[count] = 0;
189 191
190 cur = lbuf; 192 cur = lbuf;
191 193
diff --git a/drivers/pci/intel-iommu.c b/drivers/pci/intel-iommu.c
index 796828fce34c..c9171be74564 100644
--- a/drivers/pci/intel-iommu.c
+++ b/drivers/pci/intel-iommu.c
@@ -340,7 +340,7 @@ int dmar_disabled = 0;
340int dmar_disabled = 1; 340int dmar_disabled = 1;
341#endif /*CONFIG_DMAR_DEFAULT_ON*/ 341#endif /*CONFIG_DMAR_DEFAULT_ON*/
342 342
343static int __initdata dmar_map_gfx = 1; 343static int dmar_map_gfx = 1;
344static int dmar_forcedac; 344static int dmar_forcedac;
345static int intel_iommu_strict; 345static int intel_iommu_strict;
346 346
@@ -1874,14 +1874,15 @@ static struct dmar_domain *get_domain_for_dev(struct pci_dev *pdev, int gaw)
1874 } 1874 }
1875 } 1875 }
1876 if (found) { 1876 if (found) {
1877 spin_unlock_irqrestore(&device_domain_lock, flags);
1877 free_devinfo_mem(info); 1878 free_devinfo_mem(info);
1878 domain_exit(domain); 1879 domain_exit(domain);
1879 domain = found; 1880 domain = found;
1880 } else { 1881 } else {
1881 list_add(&info->link, &domain->devices); 1882 list_add(&info->link, &domain->devices);
1882 list_add(&info->global, &device_domain_list); 1883 list_add(&info->global, &device_domain_list);
1884 spin_unlock_irqrestore(&device_domain_lock, flags);
1883 } 1885 }
1884 spin_unlock_irqrestore(&device_domain_lock, flags);
1885 } 1886 }
1886 1887
1887found_domain: 1888found_domain:
@@ -3603,7 +3604,8 @@ static int intel_iommu_attach_device(struct iommu_domain *domain,
3603 pte = dmar_domain->pgd; 3604 pte = dmar_domain->pgd;
3604 if (dma_pte_present(pte)) { 3605 if (dma_pte_present(pte)) {
3605 free_pgtable_page(dmar_domain->pgd); 3606 free_pgtable_page(dmar_domain->pgd);
3606 dmar_domain->pgd = (struct dma_pte *)dma_pte_addr(pte); 3607 dmar_domain->pgd = (struct dma_pte *)
3608 phys_to_virt(dma_pte_addr(pte));
3607 } 3609 }
3608 dmar_domain->agaw--; 3610 dmar_domain->agaw--;
3609 } 3611 }
@@ -3719,6 +3721,12 @@ static void __devinit quirk_iommu_rwbf(struct pci_dev *dev)
3719 */ 3721 */
3720 printk(KERN_INFO "DMAR: Forcing write-buffer flush capability\n"); 3722 printk(KERN_INFO "DMAR: Forcing write-buffer flush capability\n");
3721 rwbf_quirk = 1; 3723 rwbf_quirk = 1;
3724
3725 /* https://bugzilla.redhat.com/show_bug.cgi?id=538163 */
3726 if (dev->revision == 0x07) {
3727 printk(KERN_INFO "DMAR: Disabling IOMMU for graphics on this chipset\n");
3728 dmar_map_gfx = 0;
3729 }
3722} 3730}
3723 3731
3724DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x2a40, quirk_iommu_rwbf); 3732DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x2a40, quirk_iommu_rwbf);
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index 60f30e7f1c8c..740fb4ea9669 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -2292,6 +2292,7 @@ void pci_msi_off(struct pci_dev *dev)
2292 pci_write_config_word(dev, pos + PCI_MSIX_FLAGS, control); 2292 pci_write_config_word(dev, pos + PCI_MSIX_FLAGS, control);
2293 } 2293 }
2294} 2294}
2295EXPORT_SYMBOL_GPL(pci_msi_off);
2295 2296
2296#ifndef HAVE_ARCH_PCI_SET_DMA_MAX_SEGMENT_SIZE 2297#ifndef HAVE_ARCH_PCI_SET_DMA_MAX_SEGMENT_SIZE
2297int pci_set_dma_max_seg_size(struct pci_dev *dev, unsigned int size) 2298int pci_set_dma_max_seg_size(struct pci_dev *dev, unsigned int size)
diff --git a/drivers/pci/pcie/pme/pcie_pme.c b/drivers/pci/pcie/pme/pcie_pme.c
index aac285a16b62..d672a0a63816 100644
--- a/drivers/pci/pcie/pme/pcie_pme.c
+++ b/drivers/pci/pcie/pme/pcie_pme.c
@@ -34,7 +34,7 @@
34 * being registered. Consequently, the interrupt-based PCIe PME signaling will 34 * being registered. Consequently, the interrupt-based PCIe PME signaling will
35 * not be used by any PCIe root ports in that case. 35 * not be used by any PCIe root ports in that case.
36 */ 36 */
37static bool pcie_pme_disabled; 37static bool pcie_pme_disabled = true;
38 38
39/* 39/*
40 * The PCI Express Base Specification 2.0, Section 6.1.8, states the following: 40 * The PCI Express Base Specification 2.0, Section 6.1.8, states the following:
@@ -64,12 +64,19 @@ bool pcie_pme_msi_disabled;
64 64
65static int __init pcie_pme_setup(char *str) 65static int __init pcie_pme_setup(char *str)
66{ 66{
67 if (!strcmp(str, "off")) 67 if (!strncmp(str, "auto", 4))
68 pcie_pme_disabled = true; 68 pcie_pme_disabled = false;
69 else if (!strcmp(str, "force")) 69 else if (!strncmp(str, "force", 5))
70 pcie_pme_force_enable = true; 70 pcie_pme_force_enable = true;
71 else if (!strcmp(str, "nomsi")) 71
72 pcie_pme_msi_disabled = true; 72 str = strchr(str, ',');
73 if (str) {
74 str++;
75 str += strspn(str, " \t");
76 if (*str && !strcmp(str, "nomsi"))
77 pcie_pme_msi_disabled = true;
78 }
79
73 return 1; 80 return 1;
74} 81}
75__setup("pcie_pme=", pcie_pme_setup); 82__setup("pcie_pme=", pcie_pme_setup);
diff --git a/drivers/pci/setup-res.c b/drivers/pci/setup-res.c
index 92379e2d37e7..2aaa13150de3 100644
--- a/drivers/pci/setup-res.c
+++ b/drivers/pci/setup-res.c
@@ -156,6 +156,38 @@ static int __pci_assign_resource(struct pci_bus *bus, struct pci_dev *dev,
156 pcibios_align_resource, dev); 156 pcibios_align_resource, dev);
157 } 157 }
158 158
159 if (ret < 0 && dev->fw_addr[resno]) {
160 struct resource *root, *conflict;
161 resource_size_t start, end;
162
163 /*
164 * If we failed to assign anything, let's try the address
165 * where firmware left it. That at least has a chance of
166 * working, which is better than just leaving it disabled.
167 */
168
169 if (res->flags & IORESOURCE_IO)
170 root = &ioport_resource;
171 else
172 root = &iomem_resource;
173
174 start = res->start;
175 end = res->end;
176 res->start = dev->fw_addr[resno];
177 res->end = res->start + size - 1;
178 dev_info(&dev->dev, "BAR %d: trying firmware assignment %pR\n",
179 resno, res);
180 conflict = request_resource_conflict(root, res);
181 if (conflict) {
182 dev_info(&dev->dev,
183 "BAR %d: %pR conflicts with %s %pR\n", resno,
184 res, conflict->name, conflict);
185 res->start = start;
186 res->end = end;
187 } else
188 ret = 0;
189 }
190
159 if (!ret) { 191 if (!ret) {
160 res->flags &= ~IORESOURCE_STARTALIGN; 192 res->flags &= ~IORESOURCE_STARTALIGN;
161 dev_info(&dev->dev, "BAR %d: assigned %pR\n", resno, res); 193 dev_info(&dev->dev, "BAR %d: assigned %pR\n", resno, res);
diff --git a/drivers/pcmcia/ds.c b/drivers/pcmcia/ds.c
index 9fc339845538..eac961463be2 100644
--- a/drivers/pcmcia/ds.c
+++ b/drivers/pcmcia/ds.c
@@ -1356,6 +1356,7 @@ static int __devinit pcmcia_bus_add_socket(struct device *dev,
1356 INIT_LIST_HEAD(&socket->devices_list); 1356 INIT_LIST_HEAD(&socket->devices_list);
1357 memset(&socket->pcmcia_state, 0, sizeof(u8)); 1357 memset(&socket->pcmcia_state, 0, sizeof(u8));
1358 socket->device_count = 0; 1358 socket->device_count = 0;
1359 atomic_set(&socket->present, 0);
1359 1360
1360 ret = pccard_register_pcmcia(socket, &pcmcia_bus_callback); 1361 ret = pccard_register_pcmcia(socket, &pcmcia_bus_callback);
1361 if (ret) { 1362 if (ret) {
@@ -1364,8 +1365,6 @@ static int __devinit pcmcia_bus_add_socket(struct device *dev,
1364 return ret; 1365 return ret;
1365 } 1366 }
1366 1367
1367 atomic_set(&socket->present, 0);
1368
1369 return 0; 1368 return 0;
1370} 1369}
1371 1370
diff --git a/drivers/pcmcia/pcmcia_resource.c b/drivers/pcmcia/pcmcia_resource.c
index 29f91fac1dff..a4cd9adfcbc0 100644
--- a/drivers/pcmcia/pcmcia_resource.c
+++ b/drivers/pcmcia/pcmcia_resource.c
@@ -857,8 +857,10 @@ void pcmcia_disable_device(struct pcmcia_device *p_dev)
857{ 857{
858 pcmcia_release_configuration(p_dev); 858 pcmcia_release_configuration(p_dev);
859 pcmcia_release_io(p_dev, &p_dev->io); 859 pcmcia_release_io(p_dev, &p_dev->io);
860 if (p_dev->_irq) 860 if (p_dev->_irq) {
861 free_irq(p_dev->irq, p_dev->priv); 861 free_irq(p_dev->irq, p_dev->priv);
862 p_dev->_irq = 0;
863 }
862 if (p_dev->win) 864 if (p_dev->win)
863 pcmcia_release_window(p_dev, p_dev->win); 865 pcmcia_release_window(p_dev, p_dev->win);
864} 866}
diff --git a/drivers/pcmcia/pxa2xx_base.c b/drivers/pcmcia/pxa2xx_base.c
index df4532e91b1a..f370476d5417 100644
--- a/drivers/pcmcia/pxa2xx_base.c
+++ b/drivers/pcmcia/pxa2xx_base.c
@@ -178,7 +178,6 @@ pxa2xx_pcmcia_frequency_change(struct soc_pcmcia_socket *skt,
178 unsigned long val, 178 unsigned long val,
179 struct cpufreq_freqs *freqs) 179 struct cpufreq_freqs *freqs)
180{ 180{
181#warning "it's not clear if this is right since the core CPU (N) clock has no effect on the memory (L) clock"
182 switch (val) { 181 switch (val) {
183 case CPUFREQ_PRECHANGE: 182 case CPUFREQ_PRECHANGE:
184 if (freqs->new > freqs->old) { 183 if (freqs->new > freqs->old) {
@@ -186,7 +185,7 @@ pxa2xx_pcmcia_frequency_change(struct soc_pcmcia_socket *skt,
186 "pre-updating\n", 185 "pre-updating\n",
187 freqs->new / 1000, (freqs->new / 100) % 10, 186 freqs->new / 1000, (freqs->new / 100) % 10,
188 freqs->old / 1000, (freqs->old / 100) % 10); 187 freqs->old / 1000, (freqs->old / 100) % 10);
189 pxa2xx_pcmcia_set_mcxx(skt, freqs->new); 188 pxa2xx_pcmcia_set_timing(skt);
190 } 189 }
191 break; 190 break;
192 191
@@ -196,7 +195,7 @@ pxa2xx_pcmcia_frequency_change(struct soc_pcmcia_socket *skt,
196 "post-updating\n", 195 "post-updating\n",
197 freqs->new / 1000, (freqs->new / 100) % 10, 196 freqs->new / 1000, (freqs->new / 100) % 10,
198 freqs->old / 1000, (freqs->old / 100) % 10); 197 freqs->old / 1000, (freqs->old / 100) % 10);
199 pxa2xx_pcmcia_set_mcxx(skt, freqs->new); 198 pxa2xx_pcmcia_set_timing(skt);
200 } 199 }
201 break; 200 break;
202 } 201 }
diff --git a/drivers/platform/x86/intel_scu_ipc.c b/drivers/platform/x86/intel_scu_ipc.c
index 40658e3385b4..bb2f1fba637b 100644
--- a/drivers/platform/x86/intel_scu_ipc.c
+++ b/drivers/platform/x86/intel_scu_ipc.c
@@ -489,7 +489,7 @@ int intel_scu_ipc_simple_command(int cmd, int sub)
489 mutex_unlock(&ipclock); 489 mutex_unlock(&ipclock);
490 return -ENODEV; 490 return -ENODEV;
491 } 491 }
492 ipc_command(cmd << 12 | sub); 492 ipc_command(sub << 12 | cmd);
493 err = busy_loop(); 493 err = busy_loop();
494 mutex_unlock(&ipclock); 494 mutex_unlock(&ipclock);
495 return err; 495 return err;
@@ -501,9 +501,9 @@ EXPORT_SYMBOL(intel_scu_ipc_simple_command);
501 * @cmd: command 501 * @cmd: command
502 * @sub: sub type 502 * @sub: sub type
503 * @in: input data 503 * @in: input data
504 * @inlen: input length 504 * @inlen: input length in dwords
505 * @out: output data 505 * @out: output data
506 * @outlein: output length 506 * @outlein: output length in dwords
507 * 507 *
508 * Issue a command to the SCU which involves data transfers. Do the 508 * Issue a command to the SCU which involves data transfers. Do the
509 * data copies under the lock but leave it for the caller to interpret 509 * data copies under the lock but leave it for the caller to interpret
@@ -524,7 +524,7 @@ int intel_scu_ipc_command(int cmd, int sub, u32 *in, int inlen,
524 for (i = 0; i < inlen; i++) 524 for (i = 0; i < inlen; i++)
525 ipc_data_writel(*in++, 4 * i); 525 ipc_data_writel(*in++, 4 * i);
526 526
527 ipc_command((cmd << 12) | sub | (inlen << 18)); 527 ipc_command((sub << 12) | cmd | (inlen << 18));
528 err = busy_loop(); 528 err = busy_loop();
529 529
530 for (i = 0; i < outlen; i++) 530 for (i = 0; i < outlen; i++)
@@ -556,6 +556,10 @@ int intel_scu_ipc_i2c_cntrl(u32 addr, u32 *data)
556 u32 cmd = 0; 556 u32 cmd = 0;
557 557
558 mutex_lock(&ipclock); 558 mutex_lock(&ipclock);
559 if (ipcdev.pdev == NULL) {
560 mutex_unlock(&ipclock);
561 return -ENODEV;
562 }
559 cmd = (addr >> 24) & 0xFF; 563 cmd = (addr >> 24) & 0xFF;
560 if (cmd == IPC_I2C_READ) { 564 if (cmd == IPC_I2C_READ) {
561 writel(addr, ipcdev.i2c_base + IPC_I2C_CNTRL_ADDR); 565 writel(addr, ipcdev.i2c_base + IPC_I2C_CNTRL_ADDR);
diff --git a/drivers/power/ds2782_battery.c b/drivers/power/ds2782_battery.c
index d762a0cbc6af..84d3c43cf2bc 100644
--- a/drivers/power/ds2782_battery.c
+++ b/drivers/power/ds2782_battery.c
@@ -43,10 +43,9 @@
43struct ds278x_info; 43struct ds278x_info;
44 44
45struct ds278x_battery_ops { 45struct ds278x_battery_ops {
46 int (*get_current)(struct ds278x_info *info, int *current_uA); 46 int (*get_battery_current)(struct ds278x_info *info, int *current_uA);
47 int (*get_voltage)(struct ds278x_info *info, int *voltage_uA); 47 int (*get_battery_voltage)(struct ds278x_info *info, int *voltage_uA);
48 int (*get_capacity)(struct ds278x_info *info, int *capacity_uA); 48 int (*get_battery_capacity)(struct ds278x_info *info, int *capacity_uA);
49
50}; 49};
51 50
52#define to_ds278x_info(x) container_of(x, struct ds278x_info, battery) 51#define to_ds278x_info(x) container_of(x, struct ds278x_info, battery)
@@ -163,7 +162,7 @@ static int ds2782_get_capacity(struct ds278x_info *info, int *capacity)
163 if (err) 162 if (err)
164 return err; 163 return err;
165 *capacity = raw; 164 *capacity = raw;
166 return raw; 165 return 0;
167} 166}
168 167
169static int ds2786_get_current(struct ds278x_info *info, int *current_uA) 168static int ds2786_get_current(struct ds278x_info *info, int *current_uA)
@@ -213,11 +212,11 @@ static int ds278x_get_status(struct ds278x_info *info, int *status)
213 int current_uA; 212 int current_uA;
214 int capacity; 213 int capacity;
215 214
216 err = info->ops->get_current(info, &current_uA); 215 err = info->ops->get_battery_current(info, &current_uA);
217 if (err) 216 if (err)
218 return err; 217 return err;
219 218
220 err = info->ops->get_capacity(info, &capacity); 219 err = info->ops->get_battery_capacity(info, &capacity);
221 if (err) 220 if (err)
222 return err; 221 return err;
223 222
@@ -246,15 +245,15 @@ static int ds278x_battery_get_property(struct power_supply *psy,
246 break; 245 break;
247 246
248 case POWER_SUPPLY_PROP_CAPACITY: 247 case POWER_SUPPLY_PROP_CAPACITY:
249 ret = info->ops->get_capacity(info, &val->intval); 248 ret = info->ops->get_battery_capacity(info, &val->intval);
250 break; 249 break;
251 250
252 case POWER_SUPPLY_PROP_VOLTAGE_NOW: 251 case POWER_SUPPLY_PROP_VOLTAGE_NOW:
253 ret = info->ops->get_voltage(info, &val->intval); 252 ret = info->ops->get_battery_voltage(info, &val->intval);
254 break; 253 break;
255 254
256 case POWER_SUPPLY_PROP_CURRENT_NOW: 255 case POWER_SUPPLY_PROP_CURRENT_NOW:
257 ret = info->ops->get_current(info, &val->intval); 256 ret = info->ops->get_battery_current(info, &val->intval);
258 break; 257 break;
259 258
260 case POWER_SUPPLY_PROP_TEMP: 259 case POWER_SUPPLY_PROP_TEMP:
@@ -307,14 +306,14 @@ enum ds278x_num_id {
307 306
308static struct ds278x_battery_ops ds278x_ops[] = { 307static struct ds278x_battery_ops ds278x_ops[] = {
309 [DS2782] = { 308 [DS2782] = {
310 .get_current = ds2782_get_current, 309 .get_battery_current = ds2782_get_current,
311 .get_voltage = ds2782_get_voltage, 310 .get_battery_voltage = ds2782_get_voltage,
312 .get_capacity = ds2782_get_capacity, 311 .get_battery_capacity = ds2782_get_capacity,
313 }, 312 },
314 [DS2786] = { 313 [DS2786] = {
315 .get_current = ds2786_get_current, 314 .get_battery_current = ds2786_get_current,
316 .get_voltage = ds2786_get_voltage, 315 .get_battery_voltage = ds2786_get_voltage,
317 .get_capacity = ds2786_get_capacity, 316 .get_battery_capacity = ds2786_get_capacity,
318 } 317 }
319}; 318};
320 319
diff --git a/drivers/power/z2_battery.c b/drivers/power/z2_battery.c
index 9cca465436e3..85064a9f649e 100644
--- a/drivers/power/z2_battery.c
+++ b/drivers/power/z2_battery.c
@@ -9,19 +9,13 @@
9 * 9 *
10 */ 10 */
11 11
12#include <linux/init.h>
13#include <linux/kernel.h>
14#include <linux/module.h> 12#include <linux/module.h>
15#include <linux/platform_device.h>
16#include <linux/power_supply.h>
17#include <linux/i2c.h>
18#include <linux/spinlock.h>
19#include <linux/interrupt.h>
20#include <linux/gpio.h> 13#include <linux/gpio.h>
14#include <linux/i2c.h>
21#include <linux/interrupt.h> 15#include <linux/interrupt.h>
22#include <linux/irq.h> 16#include <linux/irq.h>
23#include <asm/irq.h> 17#include <linux/power_supply.h>
24#include <asm/mach/irq.h> 18#include <linux/slab.h>
25#include <linux/z2_battery.h> 19#include <linux/z2_battery.h>
26 20
27#define Z2_DEFAULT_NAME "Z2" 21#define Z2_DEFAULT_NAME "Z2"
diff --git a/drivers/regulator/ab3100.c b/drivers/regulator/ab3100.c
index 7b14a67bdca2..11790990277a 100644
--- a/drivers/regulator/ab3100.c
+++ b/drivers/regulator/ab3100.c
@@ -286,7 +286,7 @@ static int ab3100_list_voltage_regulator(struct regulator_dev *reg,
286{ 286{
287 struct ab3100_regulator *abreg = reg->reg_data; 287 struct ab3100_regulator *abreg = reg->reg_data;
288 288
289 if (selector > abreg->voltages_len) 289 if (selector >= abreg->voltages_len)
290 return -EINVAL; 290 return -EINVAL;
291 return abreg->typ_voltages[selector]; 291 return abreg->typ_voltages[selector];
292} 292}
@@ -318,7 +318,7 @@ static int ab3100_get_voltage_regulator(struct regulator_dev *reg)
318 regval &= 0xE0; 318 regval &= 0xE0;
319 regval >>= 5; 319 regval >>= 5;
320 320
321 if (regval > abreg->voltages_len) { 321 if (regval >= abreg->voltages_len) {
322 dev_err(&reg->dev, 322 dev_err(&reg->dev,
323 "regulator register %02x contains an illegal voltage setting\n", 323 "regulator register %02x contains an illegal voltage setting\n",
324 abreg->regreg); 324 abreg->regreg);
diff --git a/drivers/regulator/tps6507x-regulator.c b/drivers/regulator/tps6507x-regulator.c
index 14b4576281c5..8152d65220f5 100644
--- a/drivers/regulator/tps6507x-regulator.c
+++ b/drivers/regulator/tps6507x-regulator.c
@@ -22,6 +22,7 @@
22#include <linux/platform_device.h> 22#include <linux/platform_device.h>
23#include <linux/regulator/driver.h> 23#include <linux/regulator/driver.h>
24#include <linux/regulator/machine.h> 24#include <linux/regulator/machine.h>
25#include <linux/regulator/tps6507x.h>
25#include <linux/delay.h> 26#include <linux/delay.h>
26#include <linux/slab.h> 27#include <linux/slab.h>
27#include <linux/mfd/tps6507x.h> 28#include <linux/mfd/tps6507x.h>
@@ -101,9 +102,12 @@ struct tps_info {
101 unsigned max_uV; 102 unsigned max_uV;
102 u8 table_len; 103 u8 table_len;
103 const u16 *table; 104 const u16 *table;
105
106 /* Does DCDC high or the low register defines output voltage? */
107 bool defdcdc_default;
104}; 108};
105 109
106static const struct tps_info tps6507x_pmic_regs[] = { 110static struct tps_info tps6507x_pmic_regs[] = {
107 { 111 {
108 .name = "VDCDC1", 112 .name = "VDCDC1",
109 .min_uV = 725000, 113 .min_uV = 725000,
@@ -145,7 +149,7 @@ struct tps6507x_pmic {
145 struct regulator_desc desc[TPS6507X_NUM_REGULATOR]; 149 struct regulator_desc desc[TPS6507X_NUM_REGULATOR];
146 struct tps6507x_dev *mfd; 150 struct tps6507x_dev *mfd;
147 struct regulator_dev *rdev[TPS6507X_NUM_REGULATOR]; 151 struct regulator_dev *rdev[TPS6507X_NUM_REGULATOR];
148 const struct tps_info *info[TPS6507X_NUM_REGULATOR]; 152 struct tps_info *info[TPS6507X_NUM_REGULATOR];
149 struct mutex io_lock; 153 struct mutex io_lock;
150}; 154};
151static inline int tps6507x_pmic_read(struct tps6507x_pmic *tps, u8 reg) 155static inline int tps6507x_pmic_read(struct tps6507x_pmic *tps, u8 reg)
@@ -341,10 +345,16 @@ static int tps6507x_pmic_dcdc_get_voltage(struct regulator_dev *dev)
341 reg = TPS6507X_REG_DEFDCDC1; 345 reg = TPS6507X_REG_DEFDCDC1;
342 break; 346 break;
343 case TPS6507X_DCDC_2: 347 case TPS6507X_DCDC_2:
344 reg = TPS6507X_REG_DEFDCDC2_LOW; 348 if (tps->info[dcdc]->defdcdc_default)
349 reg = TPS6507X_REG_DEFDCDC2_HIGH;
350 else
351 reg = TPS6507X_REG_DEFDCDC2_LOW;
345 break; 352 break;
346 case TPS6507X_DCDC_3: 353 case TPS6507X_DCDC_3:
347 reg = TPS6507X_REG_DEFDCDC3_LOW; 354 if (tps->info[dcdc]->defdcdc_default)
355 reg = TPS6507X_REG_DEFDCDC3_HIGH;
356 else
357 reg = TPS6507X_REG_DEFDCDC3_LOW;
348 break; 358 break;
349 default: 359 default:
350 return -EINVAL; 360 return -EINVAL;
@@ -370,10 +380,16 @@ static int tps6507x_pmic_dcdc_set_voltage(struct regulator_dev *dev,
370 reg = TPS6507X_REG_DEFDCDC1; 380 reg = TPS6507X_REG_DEFDCDC1;
371 break; 381 break;
372 case TPS6507X_DCDC_2: 382 case TPS6507X_DCDC_2:
373 reg = TPS6507X_REG_DEFDCDC2_LOW; 383 if (tps->info[dcdc]->defdcdc_default)
384 reg = TPS6507X_REG_DEFDCDC2_HIGH;
385 else
386 reg = TPS6507X_REG_DEFDCDC2_LOW;
374 break; 387 break;
375 case TPS6507X_DCDC_3: 388 case TPS6507X_DCDC_3:
376 reg = TPS6507X_REG_DEFDCDC3_LOW; 389 if (tps->info[dcdc]->defdcdc_default)
390 reg = TPS6507X_REG_DEFDCDC3_HIGH;
391 else
392 reg = TPS6507X_REG_DEFDCDC3_LOW;
377 break; 393 break;
378 default: 394 default:
379 return -EINVAL; 395 return -EINVAL;
@@ -532,7 +548,7 @@ int tps6507x_pmic_probe(struct platform_device *pdev)
532{ 548{
533 struct tps6507x_dev *tps6507x_dev = dev_get_drvdata(pdev->dev.parent); 549 struct tps6507x_dev *tps6507x_dev = dev_get_drvdata(pdev->dev.parent);
534 static int desc_id; 550 static int desc_id;
535 const struct tps_info *info = &tps6507x_pmic_regs[0]; 551 struct tps_info *info = &tps6507x_pmic_regs[0];
536 struct regulator_init_data *init_data; 552 struct regulator_init_data *init_data;
537 struct regulator_dev *rdev; 553 struct regulator_dev *rdev;
538 struct tps6507x_pmic *tps; 554 struct tps6507x_pmic *tps;
@@ -569,6 +585,12 @@ int tps6507x_pmic_probe(struct platform_device *pdev)
569 for (i = 0; i < TPS6507X_NUM_REGULATOR; i++, info++, init_data++) { 585 for (i = 0; i < TPS6507X_NUM_REGULATOR; i++, info++, init_data++) {
570 /* Register the regulators */ 586 /* Register the regulators */
571 tps->info[i] = info; 587 tps->info[i] = info;
588 if (init_data->driver_data) {
589 struct tps6507x_reg_platform_data *data =
590 init_data->driver_data;
591 tps->info[i]->defdcdc_default = data->defdcdc_default;
592 }
593
572 tps->desc[i].name = info->name; 594 tps->desc[i].name = info->name;
573 tps->desc[i].id = desc_id++; 595 tps->desc[i].id = desc_id++;
574 tps->desc[i].n_voltages = num_voltages[i]; 596 tps->desc[i].n_voltages = num_voltages[i];
diff --git a/drivers/regulator/wm8350-regulator.c b/drivers/regulator/wm8350-regulator.c
index 723cd1fb4867..0e6ed7db9364 100644
--- a/drivers/regulator/wm8350-regulator.c
+++ b/drivers/regulator/wm8350-regulator.c
@@ -1495,7 +1495,7 @@ int wm8350_register_regulator(struct wm8350 *wm8350, int reg,
1495 if (ret != 0) { 1495 if (ret != 0) {
1496 dev_err(wm8350->dev, "Failed to register regulator %d: %d\n", 1496 dev_err(wm8350->dev, "Failed to register regulator %d: %d\n",
1497 reg, ret); 1497 reg, ret);
1498 platform_device_del(pdev); 1498 platform_device_put(pdev);
1499 wm8350->pmic.pdev[reg] = NULL; 1499 wm8350->pmic.pdev[reg] = NULL;
1500 } 1500 }
1501 1501
diff --git a/drivers/rtc/rtc-davinci.c b/drivers/rtc/rtc-davinci.c
index 92a8f6cacda9..34647fc1ee98 100644
--- a/drivers/rtc/rtc-davinci.c
+++ b/drivers/rtc/rtc-davinci.c
@@ -29,6 +29,7 @@
29#include <linux/bcd.h> 29#include <linux/bcd.h>
30#include <linux/platform_device.h> 30#include <linux/platform_device.h>
31#include <linux/io.h> 31#include <linux/io.h>
32#include <linux/slab.h>
32 33
33/* 34/*
34 * The DaVinci RTC is a simple RTC with the following 35 * The DaVinci RTC is a simple RTC with the following
diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c
index de033b7ac21f..d827ce570a8c 100644
--- a/drivers/rtc/rtc-ds1307.c
+++ b/drivers/rtc/rtc-ds1307.c
@@ -777,7 +777,7 @@ static int __devinit ds1307_probe(struct i2c_client *client,
777 777
778read_rtc: 778read_rtc:
779 /* read RTC registers */ 779 /* read RTC registers */
780 tmp = ds1307->read_block_data(ds1307->client, 0, 8, buf); 780 tmp = ds1307->read_block_data(ds1307->client, ds1307->offset, 8, buf);
781 if (tmp != 8) { 781 if (tmp != 8) {
782 pr_debug("read error %d\n", tmp); 782 pr_debug("read error %d\n", tmp);
783 err = -EIO; 783 err = -EIO;
@@ -862,7 +862,7 @@ read_rtc:
862 if (ds1307->regs[DS1307_REG_HOUR] & DS1307_BIT_PM) 862 if (ds1307->regs[DS1307_REG_HOUR] & DS1307_BIT_PM)
863 tmp += 12; 863 tmp += 12;
864 i2c_smbus_write_byte_data(client, 864 i2c_smbus_write_byte_data(client,
865 DS1307_REG_HOUR, 865 ds1307->offset + DS1307_REG_HOUR,
866 bin2bcd(tmp)); 866 bin2bcd(tmp));
867 } 867 }
868 868
diff --git a/drivers/rtc/rtc-pl031.c b/drivers/rtc/rtc-pl031.c
index 3587d9922f28..71bbefc3544e 100644
--- a/drivers/rtc/rtc-pl031.c
+++ b/drivers/rtc/rtc-pl031.c
@@ -456,7 +456,7 @@ static struct rtc_class_ops stv2_pl031_ops = {
456 .irq_set_freq = pl031_irq_set_freq, 456 .irq_set_freq = pl031_irq_set_freq,
457}; 457};
458 458
459static struct amba_id pl031_ids[] __initdata = { 459static struct amba_id pl031_ids[] = {
460 { 460 {
461 .id = 0x00041031, 461 .id = 0x00041031,
462 .mask = 0x000fffff, 462 .mask = 0x000fffff,
diff --git a/drivers/rtc/rtc-rx8581.c b/drivers/rtc/rtc-rx8581.c
index 9718aaaa8215..600b890a3c15 100644
--- a/drivers/rtc/rtc-rx8581.c
+++ b/drivers/rtc/rtc-rx8581.c
@@ -168,7 +168,7 @@ static int rx8581_set_datetime(struct i2c_client *client, struct rtc_time *tm)
168 return -EIO; 168 return -EIO;
169 } 169 }
170 170
171 err = i2c_smbus_write_byte_data(client, RX8581_REG_FLAG, 171 err = i2c_smbus_write_byte_data(client, RX8581_REG_CTRL,
172 (data | RX8581_CTRL_STOP)); 172 (data | RX8581_CTRL_STOP));
173 if (err < 0) { 173 if (err < 0) {
174 dev_err(&client->dev, "Unable to write control register\n"); 174 dev_err(&client->dev, "Unable to write control register\n");
@@ -182,6 +182,20 @@ static int rx8581_set_datetime(struct i2c_client *client, struct rtc_time *tm)
182 return -EIO; 182 return -EIO;
183 } 183 }
184 184
185 /* get VLF and clear it */
186 data = i2c_smbus_read_byte_data(client, RX8581_REG_FLAG);
187 if (data < 0) {
188 dev_err(&client->dev, "Unable to read flag register\n");
189 return -EIO;
190 }
191
192 err = i2c_smbus_write_byte_data(client, RX8581_REG_FLAG,
193 (data & ~(RX8581_FLAG_VLF)));
194 if (err != 0) {
195 dev_err(&client->dev, "Unable to write flag register\n");
196 return -EIO;
197 }
198
185 /* Restart the clock */ 199 /* Restart the clock */
186 data = i2c_smbus_read_byte_data(client, RX8581_REG_CTRL); 200 data = i2c_smbus_read_byte_data(client, RX8581_REG_CTRL);
187 if (data < 0) { 201 if (data < 0) {
@@ -189,8 +203,8 @@ static int rx8581_set_datetime(struct i2c_client *client, struct rtc_time *tm)
189 return -EIO; 203 return -EIO;
190 } 204 }
191 205
192 err = i2c_smbus_write_byte_data(client, RX8581_REG_FLAG, 206 err = i2c_smbus_write_byte_data(client, RX8581_REG_CTRL,
193 (data | ~(RX8581_CTRL_STOP))); 207 (data & ~(RX8581_CTRL_STOP)));
194 if (err != 0) { 208 if (err != 0) {
195 dev_err(&client->dev, "Unable to write control register\n"); 209 dev_err(&client->dev, "Unable to write control register\n");
196 return -EIO; 210 return -EIO;
diff --git a/drivers/s390/block/dasd_devmap.c b/drivers/s390/block/dasd_devmap.c
index 34d51dd4c539..bed7b4634ccd 100644
--- a/drivers/s390/block/dasd_devmap.c
+++ b/drivers/s390/block/dasd_devmap.c
@@ -948,8 +948,10 @@ static ssize_t dasd_alias_show(struct device *dev,
948 if (device->discipline && device->discipline->get_uid && 948 if (device->discipline && device->discipline->get_uid &&
949 !device->discipline->get_uid(device, &uid)) { 949 !device->discipline->get_uid(device, &uid)) {
950 if (uid.type == UA_BASE_PAV_ALIAS || 950 if (uid.type == UA_BASE_PAV_ALIAS ||
951 uid.type == UA_HYPER_PAV_ALIAS) 951 uid.type == UA_HYPER_PAV_ALIAS) {
952 dasd_put_device(device);
952 return sprintf(buf, "1\n"); 953 return sprintf(buf, "1\n");
954 }
953 } 955 }
954 dasd_put_device(device); 956 dasd_put_device(device);
955 957
diff --git a/drivers/s390/cio/chsc.c b/drivers/s390/cio/chsc.c
index ce7cb87479fe..407d0e9adfaf 100644
--- a/drivers/s390/cio/chsc.c
+++ b/drivers/s390/cio/chsc.c
@@ -713,7 +713,7 @@ int chsc_determine_base_channel_path_desc(struct chp_id chpid,
713 ret = chsc_determine_channel_path_desc(chpid, 0, 0, 0, 0, chsc_resp); 713 ret = chsc_determine_channel_path_desc(chpid, 0, 0, 0, 0, chsc_resp);
714 if (ret) 714 if (ret)
715 goto out_free; 715 goto out_free;
716 memcpy(desc, &chsc_resp->data, chsc_resp->length); 716 memcpy(desc, &chsc_resp->data, sizeof(*desc));
717out_free: 717out_free:
718 kfree(chsc_resp); 718 kfree(chsc_resp);
719 return ret; 719 return ret;
diff --git a/drivers/s390/scsi/zfcp_erp.c b/drivers/s390/scsi/zfcp_erp.c
index e3dbeda97179..fd068bc1bd0a 100644
--- a/drivers/s390/scsi/zfcp_erp.c
+++ b/drivers/s390/scsi/zfcp_erp.c
@@ -714,6 +714,14 @@ static int zfcp_erp_adapter_strategy_open_fsf(struct zfcp_erp_action *act)
714 if (zfcp_erp_adapter_strategy_open_fsf_xport(act) == ZFCP_ERP_FAILED) 714 if (zfcp_erp_adapter_strategy_open_fsf_xport(act) == ZFCP_ERP_FAILED)
715 return ZFCP_ERP_FAILED; 715 return ZFCP_ERP_FAILED;
716 716
717 if (mempool_resize(act->adapter->pool.status_read_data,
718 act->adapter->stat_read_buf_num, GFP_KERNEL))
719 return ZFCP_ERP_FAILED;
720
721 if (mempool_resize(act->adapter->pool.status_read_req,
722 act->adapter->stat_read_buf_num, GFP_KERNEL))
723 return ZFCP_ERP_FAILED;
724
717 atomic_set(&act->adapter->stat_miss, act->adapter->stat_read_buf_num); 725 atomic_set(&act->adapter->stat_miss, act->adapter->stat_read_buf_num);
718 if (zfcp_status_read_refill(act->adapter)) 726 if (zfcp_status_read_refill(act->adapter))
719 return ZFCP_ERP_FAILED; 727 return ZFCP_ERP_FAILED;
diff --git a/drivers/s390/scsi/zfcp_fsf.c b/drivers/s390/scsi/zfcp_fsf.c
index 9ac6a6e4a604..71663fb77310 100644
--- a/drivers/s390/scsi/zfcp_fsf.c
+++ b/drivers/s390/scsi/zfcp_fsf.c
@@ -496,7 +496,8 @@ static int zfcp_fsf_exchange_config_evaluate(struct zfcp_fsf_req *req)
496 496
497 adapter->hydra_version = bottom->adapter_type; 497 adapter->hydra_version = bottom->adapter_type;
498 adapter->timer_ticks = bottom->timer_interval; 498 adapter->timer_ticks = bottom->timer_interval;
499 adapter->stat_read_buf_num = max(bottom->status_read_buf_num, (u16)16); 499 adapter->stat_read_buf_num = max(bottom->status_read_buf_num,
500 (u16)FSF_STATUS_READS_RECOM);
500 501
501 if (fc_host_permanent_port_name(shost) == -1) 502 if (fc_host_permanent_port_name(shost) == -1)
502 fc_host_permanent_port_name(shost) = fc_host_port_name(shost); 503 fc_host_permanent_port_name(shost) = fc_host_port_name(shost);
@@ -719,11 +720,6 @@ static struct zfcp_fsf_req *zfcp_fsf_req_create(struct zfcp_qdio *qdio,
719 zfcp_qdio_req_init(adapter->qdio, &req->qdio_req, req->req_id, sbtype, 720 zfcp_qdio_req_init(adapter->qdio, &req->qdio_req, req->req_id, sbtype,
720 req->qtcb, sizeof(struct fsf_qtcb)); 721 req->qtcb, sizeof(struct fsf_qtcb));
721 722
722 if (!(atomic_read(&adapter->status) & ZFCP_STATUS_ADAPTER_QDIOUP)) {
723 zfcp_fsf_req_free(req);
724 return ERR_PTR(-EIO);
725 }
726
727 return req; 723 return req;
728} 724}
729 725
@@ -981,7 +977,7 @@ static int zfcp_fsf_setup_ct_els_sbals(struct zfcp_fsf_req *req,
981 } 977 }
982 978
983 /* use single, unchained SBAL if it can hold the request */ 979 /* use single, unchained SBAL if it can hold the request */
984 if (zfcp_qdio_sg_one_sbale(sg_req) || zfcp_qdio_sg_one_sbale(sg_resp)) { 980 if (zfcp_qdio_sg_one_sbale(sg_req) && zfcp_qdio_sg_one_sbale(sg_resp)) {
985 zfcp_fsf_setup_ct_els_unchained(adapter->qdio, &req->qdio_req, 981 zfcp_fsf_setup_ct_els_unchained(adapter->qdio, &req->qdio_req,
986 sg_req, sg_resp); 982 sg_req, sg_resp);
987 return 0; 983 return 0;
diff --git a/drivers/s390/scsi/zfcp_qdio.c b/drivers/s390/scsi/zfcp_qdio.c
index 28117e130e2c..6fa5e0453176 100644
--- a/drivers/s390/scsi/zfcp_qdio.c
+++ b/drivers/s390/scsi/zfcp_qdio.c
@@ -251,7 +251,8 @@ static int zfcp_qdio_sbal_check(struct zfcp_qdio *qdio)
251 struct zfcp_qdio_queue *req_q = &qdio->req_q; 251 struct zfcp_qdio_queue *req_q = &qdio->req_q;
252 252
253 spin_lock_bh(&qdio->req_q_lock); 253 spin_lock_bh(&qdio->req_q_lock);
254 if (atomic_read(&req_q->count)) 254 if (atomic_read(&req_q->count) ||
255 !(atomic_read(&qdio->adapter->status) & ZFCP_STATUS_ADAPTER_QDIOUP))
255 return 1; 256 return 1;
256 spin_unlock_bh(&qdio->req_q_lock); 257 spin_unlock_bh(&qdio->req_q_lock);
257 return 0; 258 return 0;
@@ -274,8 +275,13 @@ int zfcp_qdio_sbal_get(struct zfcp_qdio *qdio)
274 spin_unlock_bh(&qdio->req_q_lock); 275 spin_unlock_bh(&qdio->req_q_lock);
275 ret = wait_event_interruptible_timeout(qdio->req_q_wq, 276 ret = wait_event_interruptible_timeout(qdio->req_q_wq,
276 zfcp_qdio_sbal_check(qdio), 5 * HZ); 277 zfcp_qdio_sbal_check(qdio), 5 * HZ);
278
279 if (!(atomic_read(&qdio->adapter->status) & ZFCP_STATUS_ADAPTER_QDIOUP))
280 return -EIO;
281
277 if (ret > 0) 282 if (ret > 0)
278 return 0; 283 return 0;
284
279 if (!ret) { 285 if (!ret) {
280 atomic_inc(&qdio->req_q_full); 286 atomic_inc(&qdio->req_q_full);
281 /* assume hanging outbound queue, try queue recovery */ 287 /* assume hanging outbound queue, try queue recovery */
@@ -375,6 +381,8 @@ void zfcp_qdio_close(struct zfcp_qdio *qdio)
375 atomic_clear_mask(ZFCP_STATUS_ADAPTER_QDIOUP, &qdio->adapter->status); 381 atomic_clear_mask(ZFCP_STATUS_ADAPTER_QDIOUP, &qdio->adapter->status);
376 spin_unlock_bh(&qdio->req_q_lock); 382 spin_unlock_bh(&qdio->req_q_lock);
377 383
384 wake_up(&qdio->req_q_wq);
385
378 qdio_shutdown(qdio->adapter->ccw_device, 386 qdio_shutdown(qdio->adapter->ccw_device,
379 QDIO_FLAG_CLEANUP_USING_CLEAR); 387 QDIO_FLAG_CLEANUP_USING_CLEAR);
380 388
diff --git a/drivers/sbus/char/openprom.c b/drivers/sbus/char/openprom.c
index d53e62ab09da..aacbe14e2e7a 100644
--- a/drivers/sbus/char/openprom.c
+++ b/drivers/sbus/char/openprom.c
@@ -554,7 +554,7 @@ static int opiocgetnext(unsigned int cmd, void __user *argp)
554static int openprom_bsd_ioctl(struct file * file, 554static int openprom_bsd_ioctl(struct file * file,
555 unsigned int cmd, unsigned long arg) 555 unsigned int cmd, unsigned long arg)
556{ 556{
557 DATA *data = (DATA *) file->private_data; 557 DATA *data = file->private_data;
558 void __user *argp = (void __user *)arg; 558 void __user *argp = (void __user *)arg;
559 int err; 559 int err;
560 560
@@ -601,7 +601,7 @@ static int openprom_bsd_ioctl(struct file * file,
601static long openprom_ioctl(struct file * file, 601static long openprom_ioctl(struct file * file,
602 unsigned int cmd, unsigned long arg) 602 unsigned int cmd, unsigned long arg)
603{ 603{
604 DATA *data = (DATA *) file->private_data; 604 DATA *data = file->private_data;
605 605
606 switch (cmd) { 606 switch (cmd) {
607 case OPROMGETOPT: 607 case OPROMGETOPT:
diff --git a/drivers/scsi/ibmvscsi/rpa_vscsi.c b/drivers/scsi/ibmvscsi/rpa_vscsi.c
index a864ccc0a342..989b9a8ba72d 100644
--- a/drivers/scsi/ibmvscsi/rpa_vscsi.c
+++ b/drivers/scsi/ibmvscsi/rpa_vscsi.c
@@ -277,6 +277,12 @@ static int rpavscsi_init_crq_queue(struct crq_queue *queue,
277 goto reg_crq_failed; 277 goto reg_crq_failed;
278 } 278 }
279 279
280 queue->cur = 0;
281 spin_lock_init(&queue->lock);
282
283 tasklet_init(&hostdata->srp_task, (void *)rpavscsi_task,
284 (unsigned long)hostdata);
285
280 if (request_irq(vdev->irq, 286 if (request_irq(vdev->irq,
281 rpavscsi_handle_event, 287 rpavscsi_handle_event,
282 0, "ibmvscsi", (void *)hostdata) != 0) { 288 0, "ibmvscsi", (void *)hostdata) != 0) {
@@ -291,15 +297,10 @@ static int rpavscsi_init_crq_queue(struct crq_queue *queue,
291 goto req_irq_failed; 297 goto req_irq_failed;
292 } 298 }
293 299
294 queue->cur = 0;
295 spin_lock_init(&queue->lock);
296
297 tasklet_init(&hostdata->srp_task, (void *)rpavscsi_task,
298 (unsigned long)hostdata);
299
300 return retrc; 300 return retrc;
301 301
302 req_irq_failed: 302 req_irq_failed:
303 tasklet_kill(&hostdata->srp_task);
303 do { 304 do {
304 rc = plpar_hcall_norets(H_FREE_CRQ, vdev->unit_address); 305 rc = plpar_hcall_norets(H_FREE_CRQ, vdev->unit_address);
305 } while ((rc == H_BUSY) || (H_IS_LONG_BUSY(rc))); 306 } while ((rc == H_BUSY) || (H_IS_LONG_BUSY(rc)));
diff --git a/drivers/scsi/ipr.c b/drivers/scsi/ipr.c
index 82ea4a8226b0..f820cffb7f00 100644
--- a/drivers/scsi/ipr.c
+++ b/drivers/scsi/ipr.c
@@ -1129,20 +1129,22 @@ static int ipr_is_same_device(struct ipr_resource_entry *res,
1129} 1129}
1130 1130
1131/** 1131/**
1132 * ipr_format_resource_path - Format the resource path for printing. 1132 * ipr_format_res_path - Format the resource path for printing.
1133 * @res_path: resource path 1133 * @res_path: resource path
1134 * @buf: buffer 1134 * @buf: buffer
1135 * 1135 *
1136 * Return value: 1136 * Return value:
1137 * pointer to buffer 1137 * pointer to buffer
1138 **/ 1138 **/
1139static char *ipr_format_resource_path(u8 *res_path, char *buffer) 1139static char *ipr_format_res_path(u8 *res_path, char *buffer, int len)
1140{ 1140{
1141 int i; 1141 int i;
1142 char *p = buffer;
1142 1143
1143 sprintf(buffer, "%02X", res_path[0]); 1144 res_path[0] = '\0';
1144 for (i=1; res_path[i] != 0xff; i++) 1145 p += snprintf(p, buffer + len - p, "%02X", res_path[0]);
1145 sprintf(buffer, "%s-%02X", buffer, res_path[i]); 1146 for (i = 1; res_path[i] != 0xff && ((i * 3) < len); i++)
1147 p += snprintf(p, buffer + len - p, "-%02X", res_path[i]);
1146 1148
1147 return buffer; 1149 return buffer;
1148} 1150}
@@ -1187,7 +1189,8 @@ static void ipr_update_res_entry(struct ipr_resource_entry *res,
1187 1189
1188 if (res->sdev && new_path) 1190 if (res->sdev && new_path)
1189 sdev_printk(KERN_INFO, res->sdev, "Resource path: %s\n", 1191 sdev_printk(KERN_INFO, res->sdev, "Resource path: %s\n",
1190 ipr_format_resource_path(&res->res_path[0], &buffer[0])); 1192 ipr_format_res_path(res->res_path, buffer,
1193 sizeof(buffer)));
1191 } else { 1194 } else {
1192 res->flags = cfgtew->u.cfgte->flags; 1195 res->flags = cfgtew->u.cfgte->flags;
1193 if (res->flags & IPR_IS_IOA_RESOURCE) 1196 if (res->flags & IPR_IS_IOA_RESOURCE)
@@ -1573,7 +1576,8 @@ static void ipr_log_sis64_config_error(struct ipr_ioa_cfg *ioa_cfg,
1573 ipr_err_separator; 1576 ipr_err_separator;
1574 1577
1575 ipr_err("Device %d : %s", i + 1, 1578 ipr_err("Device %d : %s", i + 1,
1576 ipr_format_resource_path(&dev_entry->res_path[0], &buffer[0])); 1579 ipr_format_res_path(dev_entry->res_path, buffer,
1580 sizeof(buffer)));
1577 ipr_log_ext_vpd(&dev_entry->vpd); 1581 ipr_log_ext_vpd(&dev_entry->vpd);
1578 1582
1579 ipr_err("-----New Device Information-----\n"); 1583 ipr_err("-----New Device Information-----\n");
@@ -1919,13 +1923,14 @@ static void ipr_log64_fabric_path(struct ipr_hostrcb *hostrcb,
1919 1923
1920 ipr_hcam_err(hostrcb, "%s %s: Resource Path=%s\n", 1924 ipr_hcam_err(hostrcb, "%s %s: Resource Path=%s\n",
1921 path_active_desc[i].desc, path_state_desc[j].desc, 1925 path_active_desc[i].desc, path_state_desc[j].desc,
1922 ipr_format_resource_path(&fabric->res_path[0], &buffer[0])); 1926 ipr_format_res_path(fabric->res_path, buffer,
1927 sizeof(buffer)));
1923 return; 1928 return;
1924 } 1929 }
1925 } 1930 }
1926 1931
1927 ipr_err("Path state=%02X Resource Path=%s\n", path_state, 1932 ipr_err("Path state=%02X Resource Path=%s\n", path_state,
1928 ipr_format_resource_path(&fabric->res_path[0], &buffer[0])); 1933 ipr_format_res_path(fabric->res_path, buffer, sizeof(buffer)));
1929} 1934}
1930 1935
1931static const struct { 1936static const struct {
@@ -2066,7 +2071,8 @@ static void ipr_log64_path_elem(struct ipr_hostrcb *hostrcb,
2066 2071
2067 ipr_hcam_err(hostrcb, "%s %s: Resource Path=%s, Link rate=%s, WWN=%08X%08X\n", 2072 ipr_hcam_err(hostrcb, "%s %s: Resource Path=%s, Link rate=%s, WWN=%08X%08X\n",
2068 path_status_desc[j].desc, path_type_desc[i].desc, 2073 path_status_desc[j].desc, path_type_desc[i].desc,
2069 ipr_format_resource_path(&cfg->res_path[0], &buffer[0]), 2074 ipr_format_res_path(cfg->res_path, buffer,
2075 sizeof(buffer)),
2070 link_rate[cfg->link_rate & IPR_PHY_LINK_RATE_MASK], 2076 link_rate[cfg->link_rate & IPR_PHY_LINK_RATE_MASK],
2071 be32_to_cpu(cfg->wwid[0]), be32_to_cpu(cfg->wwid[1])); 2077 be32_to_cpu(cfg->wwid[0]), be32_to_cpu(cfg->wwid[1]));
2072 return; 2078 return;
@@ -2074,7 +2080,7 @@ static void ipr_log64_path_elem(struct ipr_hostrcb *hostrcb,
2074 } 2080 }
2075 ipr_hcam_err(hostrcb, "Path element=%02X: Resource Path=%s, Link rate=%s " 2081 ipr_hcam_err(hostrcb, "Path element=%02X: Resource Path=%s, Link rate=%s "
2076 "WWN=%08X%08X\n", cfg->type_status, 2082 "WWN=%08X%08X\n", cfg->type_status,
2077 ipr_format_resource_path(&cfg->res_path[0], &buffer[0]), 2083 ipr_format_res_path(cfg->res_path, buffer, sizeof(buffer)),
2078 link_rate[cfg->link_rate & IPR_PHY_LINK_RATE_MASK], 2084 link_rate[cfg->link_rate & IPR_PHY_LINK_RATE_MASK],
2079 be32_to_cpu(cfg->wwid[0]), be32_to_cpu(cfg->wwid[1])); 2085 be32_to_cpu(cfg->wwid[0]), be32_to_cpu(cfg->wwid[1]));
2080} 2086}
@@ -2139,7 +2145,7 @@ static void ipr_log_sis64_array_error(struct ipr_ioa_cfg *ioa_cfg,
2139 2145
2140 ipr_err("RAID %s Array Configuration: %s\n", 2146 ipr_err("RAID %s Array Configuration: %s\n",
2141 error->protection_level, 2147 error->protection_level,
2142 ipr_format_resource_path(&error->last_res_path[0], &buffer[0])); 2148 ipr_format_res_path(error->last_res_path, buffer, sizeof(buffer)));
2143 2149
2144 ipr_err_separator; 2150 ipr_err_separator;
2145 2151
@@ -2160,9 +2166,11 @@ static void ipr_log_sis64_array_error(struct ipr_ioa_cfg *ioa_cfg,
2160 ipr_err("Array Member %d:\n", i); 2166 ipr_err("Array Member %d:\n", i);
2161 ipr_log_ext_vpd(&array_entry->vpd); 2167 ipr_log_ext_vpd(&array_entry->vpd);
2162 ipr_err("Current Location: %s", 2168 ipr_err("Current Location: %s",
2163 ipr_format_resource_path(&array_entry->res_path[0], &buffer[0])); 2169 ipr_format_res_path(array_entry->res_path, buffer,
2170 sizeof(buffer)));
2164 ipr_err("Expected Location: %s", 2171 ipr_err("Expected Location: %s",
2165 ipr_format_resource_path(&array_entry->expected_res_path[0], &buffer[0])); 2172 ipr_format_res_path(array_entry->expected_res_path,
2173 buffer, sizeof(buffer)));
2166 2174
2167 ipr_err_separator; 2175 ipr_err_separator;
2168 } 2176 }
@@ -4079,7 +4087,8 @@ static struct device_attribute ipr_adapter_handle_attr = {
4079}; 4087};
4080 4088
4081/** 4089/**
4082 * ipr_show_resource_path - Show the resource path for this device. 4090 * ipr_show_resource_path - Show the resource path or the resource address for
4091 * this device.
4083 * @dev: device struct 4092 * @dev: device struct
4084 * @buf: buffer 4093 * @buf: buffer
4085 * 4094 *
@@ -4097,9 +4106,14 @@ static ssize_t ipr_show_resource_path(struct device *dev, struct device_attribut
4097 4106
4098 spin_lock_irqsave(ioa_cfg->host->host_lock, lock_flags); 4107 spin_lock_irqsave(ioa_cfg->host->host_lock, lock_flags);
4099 res = (struct ipr_resource_entry *)sdev->hostdata; 4108 res = (struct ipr_resource_entry *)sdev->hostdata;
4100 if (res) 4109 if (res && ioa_cfg->sis64)
4101 len = snprintf(buf, PAGE_SIZE, "%s\n", 4110 len = snprintf(buf, PAGE_SIZE, "%s\n",
4102 ipr_format_resource_path(&res->res_path[0], &buffer[0])); 4111 ipr_format_res_path(res->res_path, buffer,
4112 sizeof(buffer)));
4113 else if (res)
4114 len = snprintf(buf, PAGE_SIZE, "%d:%d:%d:%d\n", ioa_cfg->host->host_no,
4115 res->bus, res->target, res->lun);
4116
4103 spin_unlock_irqrestore(ioa_cfg->host->host_lock, lock_flags); 4117 spin_unlock_irqrestore(ioa_cfg->host->host_lock, lock_flags);
4104 return len; 4118 return len;
4105} 4119}
@@ -4351,7 +4365,8 @@ static int ipr_slave_configure(struct scsi_device *sdev)
4351 scsi_adjust_queue_depth(sdev, 0, sdev->host->cmd_per_lun); 4365 scsi_adjust_queue_depth(sdev, 0, sdev->host->cmd_per_lun);
4352 if (ioa_cfg->sis64) 4366 if (ioa_cfg->sis64)
4353 sdev_printk(KERN_INFO, sdev, "Resource path: %s\n", 4367 sdev_printk(KERN_INFO, sdev, "Resource path: %s\n",
4354 ipr_format_resource_path(&res->res_path[0], &buffer[0])); 4368 ipr_format_res_path(res->res_path, buffer,
4369 sizeof(buffer)));
4355 return 0; 4370 return 0;
4356 } 4371 }
4357 spin_unlock_irqrestore(ioa_cfg->host->host_lock, lock_flags); 4372 spin_unlock_irqrestore(ioa_cfg->host->host_lock, lock_flags);
diff --git a/drivers/scsi/ipr.h b/drivers/scsi/ipr.h
index 9ecd2259eb39..b965f3587c9d 100644
--- a/drivers/scsi/ipr.h
+++ b/drivers/scsi/ipr.h
@@ -1684,8 +1684,9 @@ struct ipr_ucode_image_header {
1684 if (ipr_is_device(hostrcb)) { \ 1684 if (ipr_is_device(hostrcb)) { \
1685 if ((hostrcb)->ioa_cfg->sis64) { \ 1685 if ((hostrcb)->ioa_cfg->sis64) { \
1686 printk(KERN_ERR IPR_NAME ": %s: " fmt, \ 1686 printk(KERN_ERR IPR_NAME ": %s: " fmt, \
1687 ipr_format_resource_path(&hostrcb->hcam.u.error64.fd_res_path[0], \ 1687 ipr_format_res_path(hostrcb->hcam.u.error64.fd_res_path, \
1688 &hostrcb->rp_buffer[0]), \ 1688 hostrcb->rp_buffer, \
1689 sizeof(hostrcb->rp_buffer)), \
1689 __VA_ARGS__); \ 1690 __VA_ARGS__); \
1690 } else { \ 1691 } else { \
1691 ipr_ra_err((hostrcb)->ioa_cfg, \ 1692 ipr_ra_err((hostrcb)->ioa_cfg, \
diff --git a/drivers/serial/amba-pl010.c b/drivers/serial/amba-pl010.c
index b09a638d051f..50441ffe8e38 100644
--- a/drivers/serial/amba-pl010.c
+++ b/drivers/serial/amba-pl010.c
@@ -782,7 +782,7 @@ static int pl010_resume(struct amba_device *dev)
782 return 0; 782 return 0;
783} 783}
784 784
785static struct amba_id pl010_ids[] __initdata = { 785static struct amba_id pl010_ids[] = {
786 { 786 {
787 .id = 0x00041010, 787 .id = 0x00041010,
788 .mask = 0x000fffff, 788 .mask = 0x000fffff,
diff --git a/drivers/serial/amba-pl011.c b/drivers/serial/amba-pl011.c
index eb4cb480b93e..6ca7a44f29c2 100644
--- a/drivers/serial/amba-pl011.c
+++ b/drivers/serial/amba-pl011.c
@@ -69,9 +69,12 @@
69struct uart_amba_port { 69struct uart_amba_port {
70 struct uart_port port; 70 struct uart_port port;
71 struct clk *clk; 71 struct clk *clk;
72 unsigned int im; /* interrupt mask */ 72 unsigned int im; /* interrupt mask */
73 unsigned int old_status; 73 unsigned int old_status;
74 unsigned int ifls; /* vendor-specific */ 74 unsigned int ifls; /* vendor-specific */
75 unsigned int lcrh_tx; /* vendor-specific */
76 unsigned int lcrh_rx; /* vendor-specific */
77 bool oversampling; /* vendor-specific */
75 bool autorts; 78 bool autorts;
76}; 79};
77 80
@@ -79,16 +82,25 @@ struct uart_amba_port {
79struct vendor_data { 82struct vendor_data {
80 unsigned int ifls; 83 unsigned int ifls;
81 unsigned int fifosize; 84 unsigned int fifosize;
85 unsigned int lcrh_tx;
86 unsigned int lcrh_rx;
87 bool oversampling;
82}; 88};
83 89
84static struct vendor_data vendor_arm = { 90static struct vendor_data vendor_arm = {
85 .ifls = UART011_IFLS_RX4_8|UART011_IFLS_TX4_8, 91 .ifls = UART011_IFLS_RX4_8|UART011_IFLS_TX4_8,
86 .fifosize = 16, 92 .fifosize = 16,
93 .lcrh_tx = UART011_LCRH,
94 .lcrh_rx = UART011_LCRH,
95 .oversampling = false,
87}; 96};
88 97
89static struct vendor_data vendor_st = { 98static struct vendor_data vendor_st = {
90 .ifls = UART011_IFLS_RX_HALF|UART011_IFLS_TX_HALF, 99 .ifls = UART011_IFLS_RX_HALF|UART011_IFLS_TX_HALF,
91 .fifosize = 64, 100 .fifosize = 64,
101 .lcrh_tx = ST_UART011_LCRH_TX,
102 .lcrh_rx = ST_UART011_LCRH_RX,
103 .oversampling = true,
92}; 104};
93 105
94static void pl011_stop_tx(struct uart_port *port) 106static void pl011_stop_tx(struct uart_port *port)
@@ -327,12 +339,12 @@ static void pl011_break_ctl(struct uart_port *port, int break_state)
327 unsigned int lcr_h; 339 unsigned int lcr_h;
328 340
329 spin_lock_irqsave(&uap->port.lock, flags); 341 spin_lock_irqsave(&uap->port.lock, flags);
330 lcr_h = readw(uap->port.membase + UART011_LCRH); 342 lcr_h = readw(uap->port.membase + uap->lcrh_tx);
331 if (break_state == -1) 343 if (break_state == -1)
332 lcr_h |= UART01x_LCRH_BRK; 344 lcr_h |= UART01x_LCRH_BRK;
333 else 345 else
334 lcr_h &= ~UART01x_LCRH_BRK; 346 lcr_h &= ~UART01x_LCRH_BRK;
335 writew(lcr_h, uap->port.membase + UART011_LCRH); 347 writew(lcr_h, uap->port.membase + uap->lcrh_tx);
336 spin_unlock_irqrestore(&uap->port.lock, flags); 348 spin_unlock_irqrestore(&uap->port.lock, flags);
337} 349}
338 350
@@ -393,7 +405,17 @@ static int pl011_startup(struct uart_port *port)
393 writew(cr, uap->port.membase + UART011_CR); 405 writew(cr, uap->port.membase + UART011_CR);
394 writew(0, uap->port.membase + UART011_FBRD); 406 writew(0, uap->port.membase + UART011_FBRD);
395 writew(1, uap->port.membase + UART011_IBRD); 407 writew(1, uap->port.membase + UART011_IBRD);
396 writew(0, uap->port.membase + UART011_LCRH); 408 writew(0, uap->port.membase + uap->lcrh_rx);
409 if (uap->lcrh_tx != uap->lcrh_rx) {
410 int i;
411 /*
412 * Wait 10 PCLKs before writing LCRH_TX register,
413 * to get this delay write read only register 10 times
414 */
415 for (i = 0; i < 10; ++i)
416 writew(0xff, uap->port.membase + UART011_MIS);
417 writew(0, uap->port.membase + uap->lcrh_tx);
418 }
397 writew(0, uap->port.membase + UART01x_DR); 419 writew(0, uap->port.membase + UART01x_DR);
398 while (readw(uap->port.membase + UART01x_FR) & UART01x_FR_BUSY) 420 while (readw(uap->port.membase + UART01x_FR) & UART01x_FR_BUSY)
399 barrier(); 421 barrier();
@@ -422,10 +444,19 @@ static int pl011_startup(struct uart_port *port)
422 return retval; 444 return retval;
423} 445}
424 446
447static void pl011_shutdown_channel(struct uart_amba_port *uap,
448 unsigned int lcrh)
449{
450 unsigned long val;
451
452 val = readw(uap->port.membase + lcrh);
453 val &= ~(UART01x_LCRH_BRK | UART01x_LCRH_FEN);
454 writew(val, uap->port.membase + lcrh);
455}
456
425static void pl011_shutdown(struct uart_port *port) 457static void pl011_shutdown(struct uart_port *port)
426{ 458{
427 struct uart_amba_port *uap = (struct uart_amba_port *)port; 459 struct uart_amba_port *uap = (struct uart_amba_port *)port;
428 unsigned long val;
429 460
430 /* 461 /*
431 * disable all interrupts 462 * disable all interrupts
@@ -450,9 +481,9 @@ static void pl011_shutdown(struct uart_port *port)
450 /* 481 /*
451 * disable break condition and fifos 482 * disable break condition and fifos
452 */ 483 */
453 val = readw(uap->port.membase + UART011_LCRH); 484 pl011_shutdown_channel(uap, uap->lcrh_rx);
454 val &= ~(UART01x_LCRH_BRK | UART01x_LCRH_FEN); 485 if (uap->lcrh_rx != uap->lcrh_tx)
455 writew(val, uap->port.membase + UART011_LCRH); 486 pl011_shutdown_channel(uap, uap->lcrh_tx);
456 487
457 /* 488 /*
458 * Shut down the clock producer 489 * Shut down the clock producer
@@ -472,8 +503,13 @@ pl011_set_termios(struct uart_port *port, struct ktermios *termios,
472 /* 503 /*
473 * Ask the core to calculate the divisor for us. 504 * Ask the core to calculate the divisor for us.
474 */ 505 */
475 baud = uart_get_baud_rate(port, termios, old, 0, port->uartclk/16); 506 baud = uart_get_baud_rate(port, termios, old, 0,
476 quot = port->uartclk * 4 / baud; 507 port->uartclk/(uap->oversampling ? 8 : 16));
508
509 if (baud > port->uartclk/16)
510 quot = DIV_ROUND_CLOSEST(port->uartclk * 8, baud);
511 else
512 quot = DIV_ROUND_CLOSEST(port->uartclk * 4, baud);
477 513
478 switch (termios->c_cflag & CSIZE) { 514 switch (termios->c_cflag & CSIZE) {
479 case CS5: 515 case CS5:
@@ -552,6 +588,13 @@ pl011_set_termios(struct uart_port *port, struct ktermios *termios,
552 uap->autorts = false; 588 uap->autorts = false;
553 } 589 }
554 590
591 if (uap->oversampling) {
592 if (baud > port->uartclk/16)
593 old_cr |= ST_UART011_CR_OVSFACT;
594 else
595 old_cr &= ~ST_UART011_CR_OVSFACT;
596 }
597
555 /* Set baud rate */ 598 /* Set baud rate */
556 writew(quot & 0x3f, port->membase + UART011_FBRD); 599 writew(quot & 0x3f, port->membase + UART011_FBRD);
557 writew(quot >> 6, port->membase + UART011_IBRD); 600 writew(quot >> 6, port->membase + UART011_IBRD);
@@ -561,7 +604,17 @@ pl011_set_termios(struct uart_port *port, struct ktermios *termios,
561 * NOTE: MUST BE WRITTEN AFTER UARTLCR_M & UARTLCR_L 604 * NOTE: MUST BE WRITTEN AFTER UARTLCR_M & UARTLCR_L
562 * ----------^----------^----------^----------^----- 605 * ----------^----------^----------^----------^-----
563 */ 606 */
564 writew(lcr_h, port->membase + UART011_LCRH); 607 writew(lcr_h, port->membase + uap->lcrh_rx);
608 if (uap->lcrh_rx != uap->lcrh_tx) {
609 int i;
610 /*
611 * Wait 10 PCLKs before writing LCRH_TX register,
612 * to get this delay write read only register 10 times
613 */
614 for (i = 0; i < 10; ++i)
615 writew(0xff, uap->port.membase + UART011_MIS);
616 writew(lcr_h, port->membase + uap->lcrh_tx);
617 }
565 writew(old_cr, port->membase + UART011_CR); 618 writew(old_cr, port->membase + UART011_CR);
566 619
567 spin_unlock_irqrestore(&port->lock, flags); 620 spin_unlock_irqrestore(&port->lock, flags);
@@ -688,7 +741,7 @@ pl011_console_get_options(struct uart_amba_port *uap, int *baud,
688 if (readw(uap->port.membase + UART011_CR) & UART01x_CR_UARTEN) { 741 if (readw(uap->port.membase + UART011_CR) & UART01x_CR_UARTEN) {
689 unsigned int lcr_h, ibrd, fbrd; 742 unsigned int lcr_h, ibrd, fbrd;
690 743
691 lcr_h = readw(uap->port.membase + UART011_LCRH); 744 lcr_h = readw(uap->port.membase + uap->lcrh_tx);
692 745
693 *parity = 'n'; 746 *parity = 'n';
694 if (lcr_h & UART01x_LCRH_PEN) { 747 if (lcr_h & UART01x_LCRH_PEN) {
@@ -707,6 +760,12 @@ pl011_console_get_options(struct uart_amba_port *uap, int *baud,
707 fbrd = readw(uap->port.membase + UART011_FBRD); 760 fbrd = readw(uap->port.membase + UART011_FBRD);
708 761
709 *baud = uap->port.uartclk * 4 / (64 * ibrd + fbrd); 762 *baud = uap->port.uartclk * 4 / (64 * ibrd + fbrd);
763
764 if (uap->oversampling) {
765 if (readw(uap->port.membase + UART011_CR)
766 & ST_UART011_CR_OVSFACT)
767 *baud *= 2;
768 }
710 } 769 }
711} 770}
712 771
@@ -800,6 +859,9 @@ static int pl011_probe(struct amba_device *dev, struct amba_id *id)
800 } 859 }
801 860
802 uap->ifls = vendor->ifls; 861 uap->ifls = vendor->ifls;
862 uap->lcrh_rx = vendor->lcrh_rx;
863 uap->lcrh_tx = vendor->lcrh_tx;
864 uap->oversampling = vendor->oversampling;
803 uap->port.dev = &dev->dev; 865 uap->port.dev = &dev->dev;
804 uap->port.mapbase = dev->res.start; 866 uap->port.mapbase = dev->res.start;
805 uap->port.membase = base; 867 uap->port.membase = base;
@@ -868,7 +930,7 @@ static int pl011_resume(struct amba_device *dev)
868} 930}
869#endif 931#endif
870 932
871static struct amba_id pl011_ids[] __initdata = { 933static struct amba_id pl011_ids[] = {
872 { 934 {
873 .id = 0x00041011, 935 .id = 0x00041011,
874 .mask = 0x000fffff, 936 .mask = 0x000fffff,
diff --git a/drivers/serial/atmel_serial.c b/drivers/serial/atmel_serial.c
index eed3c2d8dd1c..a182def7007d 100644
--- a/drivers/serial/atmel_serial.c
+++ b/drivers/serial/atmel_serial.c
@@ -41,6 +41,7 @@
41#include <linux/uaccess.h> 41#include <linux/uaccess.h>
42 42
43#include <asm/io.h> 43#include <asm/io.h>
44#include <asm/ioctls.h>
44 45
45#include <asm/mach/serial_at91.h> 46#include <asm/mach/serial_at91.h>
46#include <mach/board.h> 47#include <mach/board.h>
diff --git a/drivers/serial/cpm_uart/cpm_uart_core.c b/drivers/serial/cpm_uart/cpm_uart_core.c
index 9259e849f463..6016179db533 100644
--- a/drivers/serial/cpm_uart/cpm_uart_core.c
+++ b/drivers/serial/cpm_uart/cpm_uart_core.c
@@ -930,6 +930,83 @@ static void cpm_uart_config_port(struct uart_port *port, int flags)
930 } 930 }
931} 931}
932 932
933#if defined(CONFIG_CONSOLE_POLL) || defined(CONFIG_SERIAL_CPM_CONSOLE)
934/*
935 * Write a string to the serial port
936 * Note that this is called with interrupts already disabled
937 */
938static void cpm_uart_early_write(struct uart_cpm_port *pinfo,
939 const char *string, u_int count)
940{
941 unsigned int i;
942 cbd_t __iomem *bdp, *bdbase;
943 unsigned char *cpm_outp_addr;
944
945 /* Get the address of the host memory buffer.
946 */
947 bdp = pinfo->tx_cur;
948 bdbase = pinfo->tx_bd_base;
949
950 /*
951 * Now, do each character. This is not as bad as it looks
952 * since this is a holding FIFO and not a transmitting FIFO.
953 * We could add the complexity of filling the entire transmit
954 * buffer, but we would just wait longer between accesses......
955 */
956 for (i = 0; i < count; i++, string++) {
957 /* Wait for transmitter fifo to empty.
958 * Ready indicates output is ready, and xmt is doing
959 * that, not that it is ready for us to send.
960 */
961 while ((in_be16(&bdp->cbd_sc) & BD_SC_READY) != 0)
962 ;
963
964 /* Send the character out.
965 * If the buffer address is in the CPM DPRAM, don't
966 * convert it.
967 */
968 cpm_outp_addr = cpm2cpu_addr(in_be32(&bdp->cbd_bufaddr),
969 pinfo);
970 *cpm_outp_addr = *string;
971
972 out_be16(&bdp->cbd_datlen, 1);
973 setbits16(&bdp->cbd_sc, BD_SC_READY);
974
975 if (in_be16(&bdp->cbd_sc) & BD_SC_WRAP)
976 bdp = bdbase;
977 else
978 bdp++;
979
980 /* if a LF, also do CR... */
981 if (*string == 10) {
982 while ((in_be16(&bdp->cbd_sc) & BD_SC_READY) != 0)
983 ;
984
985 cpm_outp_addr = cpm2cpu_addr(in_be32(&bdp->cbd_bufaddr),
986 pinfo);
987 *cpm_outp_addr = 13;
988
989 out_be16(&bdp->cbd_datlen, 1);
990 setbits16(&bdp->cbd_sc, BD_SC_READY);
991
992 if (in_be16(&bdp->cbd_sc) & BD_SC_WRAP)
993 bdp = bdbase;
994 else
995 bdp++;
996 }
997 }
998
999 /*
1000 * Finally, Wait for transmitter & holding register to empty
1001 * and restore the IER
1002 */
1003 while ((in_be16(&bdp->cbd_sc) & BD_SC_READY) != 0)
1004 ;
1005
1006 pinfo->tx_cur = bdp;
1007}
1008#endif
1009
933#ifdef CONFIG_CONSOLE_POLL 1010#ifdef CONFIG_CONSOLE_POLL
934/* Serial polling routines for writing and reading from the uart while 1011/* Serial polling routines for writing and reading from the uart while
935 * in an interrupt or debug context. 1012 * in an interrupt or debug context.
@@ -999,7 +1076,7 @@ static void cpm_put_poll_char(struct uart_port *port,
999 static char ch[2]; 1076 static char ch[2];
1000 1077
1001 ch[0] = (char)c; 1078 ch[0] = (char)c;
1002 cpm_uart_early_write(pinfo->port.line, ch, 1); 1079 cpm_uart_early_write(pinfo, ch, 1);
1003} 1080}
1004#endif /* CONFIG_CONSOLE_POLL */ 1081#endif /* CONFIG_CONSOLE_POLL */
1005 1082
@@ -1130,9 +1207,6 @@ static void cpm_uart_console_write(struct console *co, const char *s,
1130 u_int count) 1207 u_int count)
1131{ 1208{
1132 struct uart_cpm_port *pinfo = &cpm_uart_ports[co->index]; 1209 struct uart_cpm_port *pinfo = &cpm_uart_ports[co->index];
1133 unsigned int i;
1134 cbd_t __iomem *bdp, *bdbase;
1135 unsigned char *cp;
1136 unsigned long flags; 1210 unsigned long flags;
1137 int nolock = oops_in_progress; 1211 int nolock = oops_in_progress;
1138 1212
@@ -1142,66 +1216,7 @@ static void cpm_uart_console_write(struct console *co, const char *s,
1142 spin_lock_irqsave(&pinfo->port.lock, flags); 1216 spin_lock_irqsave(&pinfo->port.lock, flags);
1143 } 1217 }
1144 1218
1145 /* Get the address of the host memory buffer. 1219 cpm_uart_early_write(pinfo, s, count);
1146 */
1147 bdp = pinfo->tx_cur;
1148 bdbase = pinfo->tx_bd_base;
1149
1150 /*
1151 * Now, do each character. This is not as bad as it looks
1152 * since this is a holding FIFO and not a transmitting FIFO.
1153 * We could add the complexity of filling the entire transmit
1154 * buffer, but we would just wait longer between accesses......
1155 */
1156 for (i = 0; i < count; i++, s++) {
1157 /* Wait for transmitter fifo to empty.
1158 * Ready indicates output is ready, and xmt is doing
1159 * that, not that it is ready for us to send.
1160 */
1161 while ((in_be16(&bdp->cbd_sc) & BD_SC_READY) != 0)
1162 ;
1163
1164 /* Send the character out.
1165 * If the buffer address is in the CPM DPRAM, don't
1166 * convert it.
1167 */
1168 cp = cpm2cpu_addr(in_be32(&bdp->cbd_bufaddr), pinfo);
1169 *cp = *s;
1170
1171 out_be16(&bdp->cbd_datlen, 1);
1172 setbits16(&bdp->cbd_sc, BD_SC_READY);
1173
1174 if (in_be16(&bdp->cbd_sc) & BD_SC_WRAP)
1175 bdp = bdbase;
1176 else
1177 bdp++;
1178
1179 /* if a LF, also do CR... */
1180 if (*s == 10) {
1181 while ((in_be16(&bdp->cbd_sc) & BD_SC_READY) != 0)
1182 ;
1183
1184 cp = cpm2cpu_addr(in_be32(&bdp->cbd_bufaddr), pinfo);
1185 *cp = 13;
1186
1187 out_be16(&bdp->cbd_datlen, 1);
1188 setbits16(&bdp->cbd_sc, BD_SC_READY);
1189
1190 if (in_be16(&bdp->cbd_sc) & BD_SC_WRAP)
1191 bdp = bdbase;
1192 else
1193 bdp++;
1194 }
1195 }
1196
1197 /*
1198 * Finally, Wait for transmitter & holding register to empty
1199 * and restore the IER
1200 */
1201 while ((in_be16(&bdp->cbd_sc) & BD_SC_READY) != 0)
1202 ;
1203
1204 pinfo->tx_cur = bdp;
1205 1220
1206 if (unlikely(nolock)) { 1221 if (unlikely(nolock)) {
1207 local_irq_restore(flags); 1222 local_irq_restore(flags);
diff --git a/drivers/serial/serial_cs.c b/drivers/serial/serial_cs.c
index 526307368f8b..ab17c08ddc03 100644
--- a/drivers/serial/serial_cs.c
+++ b/drivers/serial/serial_cs.c
@@ -821,6 +821,7 @@ static struct pcmcia_device_id serial_ids[] = {
821 PCMCIA_PFC_DEVICE_CIS_PROD_ID12(1, "Psion Dacom", "Gold Card V34 Ethernet", 0xf5f025c2, 0x338e8155, "cis/PCMLM28.cis"), 821 PCMCIA_PFC_DEVICE_CIS_PROD_ID12(1, "Psion Dacom", "Gold Card V34 Ethernet", 0xf5f025c2, 0x338e8155, "cis/PCMLM28.cis"),
822 PCMCIA_PFC_DEVICE_CIS_PROD_ID12(1, "Psion Dacom", "Gold Card V34 Ethernet GSM", 0xf5f025c2, 0x4ae85d35, "cis/PCMLM28.cis"), 822 PCMCIA_PFC_DEVICE_CIS_PROD_ID12(1, "Psion Dacom", "Gold Card V34 Ethernet GSM", 0xf5f025c2, 0x4ae85d35, "cis/PCMLM28.cis"),
823 PCMCIA_PFC_DEVICE_CIS_PROD_ID12(1, "LINKSYS", "PCMLM28", 0xf7cb0b07, 0x66881874, "cis/PCMLM28.cis"), 823 PCMCIA_PFC_DEVICE_CIS_PROD_ID12(1, "LINKSYS", "PCMLM28", 0xf7cb0b07, 0x66881874, "cis/PCMLM28.cis"),
824 PCMCIA_PFC_DEVICE_CIS_PROD_ID12(1, "TOSHIBA", "Modem/LAN Card", 0xb4585a1a, 0x53f922f8, "cis/PCMLM28.cis"),
824 PCMCIA_MFC_DEVICE_CIS_PROD_ID12(1, "DAYNA COMMUNICATIONS", "LAN AND MODEM MULTIFUNCTION", 0x8fdf8f89, 0xdd5ed9e8, "cis/DP83903.cis"), 825 PCMCIA_MFC_DEVICE_CIS_PROD_ID12(1, "DAYNA COMMUNICATIONS", "LAN AND MODEM MULTIFUNCTION", 0x8fdf8f89, 0xdd5ed9e8, "cis/DP83903.cis"),
825 PCMCIA_MFC_DEVICE_CIS_PROD_ID4(1, "NSC MF LAN/Modem", 0x58fc6056, "cis/DP83903.cis"), 826 PCMCIA_MFC_DEVICE_CIS_PROD_ID4(1, "NSC MF LAN/Modem", 0x58fc6056, "cis/DP83903.cis"),
826 PCMCIA_MFC_DEVICE_CIS_MANF_CARD(1, 0x0101, 0x0556, "cis/3CCFEM556.cis"), 827 PCMCIA_MFC_DEVICE_CIS_MANF_CARD(1, 0x0101, 0x0556, "cis/3CCFEM556.cis"),
diff --git a/drivers/serial/suncore.c b/drivers/serial/suncore.c
index ed7d958b0a01..544f2e25d0e5 100644
--- a/drivers/serial/suncore.c
+++ b/drivers/serial/suncore.c
@@ -71,7 +71,9 @@ int sunserial_console_match(struct console *con, struct device_node *dp,
71 71
72 con->index = line; 72 con->index = line;
73 drv->cons = con; 73 drv->cons = con;
74 add_preferred_console(con->name, line, NULL); 74
75 if (!console_set_on_cmdline)
76 add_preferred_console(con->name, line, NULL);
75 77
76 return 1; 78 return 1;
77} 79}
diff --git a/drivers/serial/sunsu.c b/drivers/serial/sunsu.c
index 234459c2f012..ffbf4553f665 100644
--- a/drivers/serial/sunsu.c
+++ b/drivers/serial/sunsu.c
@@ -1500,20 +1500,25 @@ out_unmap:
1500static int __devexit su_remove(struct of_device *op) 1500static int __devexit su_remove(struct of_device *op)
1501{ 1501{
1502 struct uart_sunsu_port *up = dev_get_drvdata(&op->dev); 1502 struct uart_sunsu_port *up = dev_get_drvdata(&op->dev);
1503 bool kbdms = false;
1503 1504
1504 if (up->su_type == SU_PORT_MS || 1505 if (up->su_type == SU_PORT_MS ||
1505 up->su_type == SU_PORT_KBD) { 1506 up->su_type == SU_PORT_KBD)
1507 kbdms = true;
1508
1509 if (kbdms) {
1506#ifdef CONFIG_SERIO 1510#ifdef CONFIG_SERIO
1507 serio_unregister_port(&up->serio); 1511 serio_unregister_port(&up->serio);
1508#endif 1512#endif
1509 kfree(up); 1513 } else if (up->port.type != PORT_UNKNOWN)
1510 } else if (up->port.type != PORT_UNKNOWN) {
1511 uart_remove_one_port(&sunsu_reg, &up->port); 1514 uart_remove_one_port(&sunsu_reg, &up->port);
1512 }
1513 1515
1514 if (up->port.membase) 1516 if (up->port.membase)
1515 of_iounmap(&op->resource[0], up->port.membase, up->reg_size); 1517 of_iounmap(&op->resource[0], up->port.membase, up->reg_size);
1516 1518
1519 if (kbdms)
1520 kfree(up);
1521
1517 dev_set_drvdata(&op->dev, NULL); 1522 dev_set_drvdata(&op->dev, NULL);
1518 1523
1519 return 0; 1524 return 0;
diff --git a/drivers/spi/spi_mpc8xxx.c b/drivers/spi/spi_mpc8xxx.c
index ffa111a7e9d4..97ab0a81338a 100644
--- a/drivers/spi/spi_mpc8xxx.c
+++ b/drivers/spi/spi_mpc8xxx.c
@@ -66,28 +66,6 @@ struct mpc8xxx_spi_reg {
66 __be32 receive; 66 __be32 receive;
67}; 67};
68 68
69/* SPI Parameter RAM */
70struct spi_pram {
71 __be16 rbase; /* Rx Buffer descriptor base address */
72 __be16 tbase; /* Tx Buffer descriptor base address */
73 u8 rfcr; /* Rx function code */
74 u8 tfcr; /* Tx function code */
75 __be16 mrblr; /* Max receive buffer length */
76 __be32 rstate; /* Internal */
77 __be32 rdp; /* Internal */
78 __be16 rbptr; /* Internal */
79 __be16 rbc; /* Internal */
80 __be32 rxtmp; /* Internal */
81 __be32 tstate; /* Internal */
82 __be32 tdp; /* Internal */
83 __be16 tbptr; /* Internal */
84 __be16 tbc; /* Internal */
85 __be32 txtmp; /* Internal */
86 __be32 res; /* Tx temp. */
87 __be16 rpbase; /* Relocation pointer (CPM1 only) */
88 __be16 res1; /* Reserved */
89};
90
91/* SPI Controller mode register definitions */ 69/* SPI Controller mode register definitions */
92#define SPMODE_LOOP (1 << 30) 70#define SPMODE_LOOP (1 << 30)
93#define SPMODE_CI_INACTIVEHIGH (1 << 29) 71#define SPMODE_CI_INACTIVEHIGH (1 << 29)
diff --git a/drivers/staging/batman-adv/bat_sysfs.c b/drivers/staging/batman-adv/bat_sysfs.c
index e2c000b80ca0..212bc21e6d68 100644
--- a/drivers/staging/batman-adv/bat_sysfs.c
+++ b/drivers/staging/batman-adv/bat_sysfs.c
@@ -225,9 +225,9 @@ static struct bat_attribute *mesh_attrs[] = {
225 NULL, 225 NULL,
226}; 226};
227 227
228static ssize_t transtable_local_read(struct kobject *kobj, 228static ssize_t transtable_local_read(struct file *filp, struct kobject *kobj,
229 struct bin_attribute *bin_attr, 229 struct bin_attribute *bin_attr,
230 char *buff, loff_t off, size_t count) 230 char *buff, loff_t off, size_t count)
231{ 231{
232 struct device *dev = to_dev(kobj->parent); 232 struct device *dev = to_dev(kobj->parent);
233 struct net_device *net_dev = to_net_dev(dev); 233 struct net_device *net_dev = to_net_dev(dev);
@@ -235,9 +235,9 @@ static ssize_t transtable_local_read(struct kobject *kobj,
235 return hna_local_fill_buffer_text(net_dev, buff, count, off); 235 return hna_local_fill_buffer_text(net_dev, buff, count, off);
236} 236}
237 237
238static ssize_t transtable_global_read(struct kobject *kobj, 238static ssize_t transtable_global_read(struct file *filp, struct kobject *kobj,
239 struct bin_attribute *bin_attr, 239 struct bin_attribute *bin_attr,
240 char *buff, loff_t off, size_t count) 240 char *buff, loff_t off, size_t count)
241{ 241{
242 struct device *dev = to_dev(kobj->parent); 242 struct device *dev = to_dev(kobj->parent);
243 struct net_device *net_dev = to_net_dev(dev); 243 struct net_device *net_dev = to_net_dev(dev);
@@ -245,9 +245,9 @@ static ssize_t transtable_global_read(struct kobject *kobj,
245 return hna_global_fill_buffer_text(net_dev, buff, count, off); 245 return hna_global_fill_buffer_text(net_dev, buff, count, off);
246} 246}
247 247
248static ssize_t originators_read(struct kobject *kobj, 248static ssize_t originators_read(struct file *filp, struct kobject *kobj,
249 struct bin_attribute *bin_attr, 249 struct bin_attribute *bin_attr,
250 char *buff, loff_t off, size_t count) 250 char *buff, loff_t off, size_t count)
251{ 251{
252 struct device *dev = to_dev(kobj->parent); 252 struct device *dev = to_dev(kobj->parent);
253 struct net_device *net_dev = to_net_dev(dev); 253 struct net_device *net_dev = to_net_dev(dev);
@@ -255,9 +255,9 @@ static ssize_t originators_read(struct kobject *kobj,
255 return orig_fill_buffer_text(net_dev, buff, count, off); 255 return orig_fill_buffer_text(net_dev, buff, count, off);
256} 256}
257 257
258static ssize_t vis_data_read(struct kobject *kobj, 258static ssize_t vis_data_read(struct file *filp, struct kobject *kobj,
259 struct bin_attribute *bin_attr, 259 struct bin_attribute *bin_attr,
260 char *buff, loff_t off, size_t count) 260 char *buff, loff_t off, size_t count)
261{ 261{
262 struct device *dev = to_dev(kobj->parent); 262 struct device *dev = to_dev(kobj->parent);
263 struct net_device *net_dev = to_net_dev(dev); 263 struct net_device *net_dev = to_net_dev(dev);
diff --git a/drivers/staging/batman-adv/device.c b/drivers/staging/batman-adv/device.c
index 7eb6559e0315..32204b5572d0 100644
--- a/drivers/staging/batman-adv/device.c
+++ b/drivers/staging/batman-adv/device.c
@@ -196,7 +196,7 @@ ssize_t bat_device_read(struct file *file, char __user *buf, size_t count,
196 kfree(device_packet); 196 kfree(device_packet);
197 197
198 if (error) 198 if (error)
199 return error; 199 return -EFAULT;
200 200
201 return sizeof(struct icmp_packet); 201 return sizeof(struct icmp_packet);
202} 202}
diff --git a/drivers/staging/comedi/drivers/adl_pci9111.c b/drivers/staging/comedi/drivers/adl_pci9111.c
index 36a254cd4413..39d112b708e3 100644
--- a/drivers/staging/comedi/drivers/adl_pci9111.c
+++ b/drivers/staging/comedi/drivers/adl_pci9111.c
@@ -824,9 +824,12 @@ static int pci9111_ai_do_cmd(struct comedi_device *dev,
824 plx9050_interrupt_control(dev_private->lcr_io_base, true, true, 824 plx9050_interrupt_control(dev_private->lcr_io_base, true, true,
825 false, true, true); 825 false, true, true);
826 826
827 dev_private->scan_delay = 827 if (async_cmd->scan_begin_src == TRIG_TIMER) {
828 (async_cmd->scan_begin_arg / (async_cmd->convert_arg * 828 dev_private->scan_delay =
829 async_cmd->chanlist_len)) - 1; 829 (async_cmd->scan_begin_arg /
830 (async_cmd->convert_arg *
831 async_cmd->chanlist_len)) - 1;
832 }
830 833
831 break; 834 break;
832 835
diff --git a/drivers/staging/comedi/drivers/cb_pcidda.c b/drivers/staging/comedi/drivers/cb_pcidda.c
index 81829d6fd287..c374bee25068 100644
--- a/drivers/staging/comedi/drivers/cb_pcidda.c
+++ b/drivers/staging/comedi/drivers/cb_pcidda.c
@@ -52,7 +52,6 @@ Please report success/failure with other different cards to
52#include "8255.h" 52#include "8255.h"
53 53
54#define PCI_VENDOR_ID_CB 0x1307 /* PCI vendor number of ComputerBoards */ 54#define PCI_VENDOR_ID_CB 0x1307 /* PCI vendor number of ComputerBoards */
55#define N_BOARDS 10 /* Number of boards in cb_pcidda_boards */
56#define EEPROM_SIZE 128 /* number of entries in eeprom */ 55#define EEPROM_SIZE 128 /* number of entries in eeprom */
57#define MAX_AO_CHANNELS 8 /* maximum number of ao channels for supported boards */ 56#define MAX_AO_CHANNELS 8 /* maximum number of ao channels for supported boards */
58 57
@@ -307,7 +306,7 @@ static int cb_pcidda_attach(struct comedi_device *dev,
307 continue; 306 continue;
308 } 307 }
309 } 308 }
310 for (index = 0; index < N_BOARDS; index++) { 309 for (index = 0; index < ARRAY_SIZE(cb_pcidda_boards); index++) {
311 if (cb_pcidda_boards[index].device_id == 310 if (cb_pcidda_boards[index].device_id ==
312 pcidev->device) { 311 pcidev->device) {
313 goto found; 312 goto found;
diff --git a/drivers/staging/hv/channel_mgmt.c b/drivers/staging/hv/channel_mgmt.c
index 3f53b4d1e4cf..12db555a3a5d 100644
--- a/drivers/staging/hv/channel_mgmt.c
+++ b/drivers/staging/hv/channel_mgmt.c
@@ -23,6 +23,7 @@
23#include <linux/slab.h> 23#include <linux/slab.h>
24#include <linux/list.h> 24#include <linux/list.h>
25#include <linux/module.h> 25#include <linux/module.h>
26#include <linux/completion.h>
26#include "osd.h" 27#include "osd.h"
27#include "logging.h" 28#include "logging.h"
28#include "vmbus_private.h" 29#include "vmbus_private.h"
@@ -293,6 +294,25 @@ void FreeVmbusChannel(struct vmbus_channel *Channel)
293 Channel); 294 Channel);
294} 295}
295 296
297
298DECLARE_COMPLETION(hv_channel_ready);
299
300/*
301 * Count initialized channels, and ensure all channels are ready when hv_vmbus
302 * module loading completes.
303 */
304static void count_hv_channel(void)
305{
306 static int counter;
307 unsigned long flags;
308
309 spin_lock_irqsave(&gVmbusConnection.channel_lock, flags);
310 if (++counter == MAX_MSG_TYPES)
311 complete(&hv_channel_ready);
312 spin_unlock_irqrestore(&gVmbusConnection.channel_lock, flags);
313}
314
315
296/* 316/*
297 * VmbusChannelProcessOffer - Process the offer by creating a channel/device 317 * VmbusChannelProcessOffer - Process the offer by creating a channel/device
298 * associated with this offer 318 * associated with this offer
@@ -373,22 +393,21 @@ static void VmbusChannelProcessOffer(void *context)
373 * can cleanup properly 393 * can cleanup properly
374 */ 394 */
375 newChannel->State = CHANNEL_OPEN_STATE; 395 newChannel->State = CHANNEL_OPEN_STATE;
376 cnt = 0;
377 396
378 while (cnt != MAX_MSG_TYPES) { 397 /* Open IC channels */
398 for (cnt = 0; cnt < MAX_MSG_TYPES; cnt++) {
379 if (memcmp(&newChannel->OfferMsg.Offer.InterfaceType, 399 if (memcmp(&newChannel->OfferMsg.Offer.InterfaceType,
380 &hv_cb_utils[cnt].data, 400 &hv_cb_utils[cnt].data,
381 sizeof(struct hv_guid)) == 0) { 401 sizeof(struct hv_guid)) == 0 &&
402 VmbusChannelOpen(newChannel, 2 * PAGE_SIZE,
403 2 * PAGE_SIZE, NULL, 0,
404 hv_cb_utils[cnt].callback,
405 newChannel) == 0) {
406 hv_cb_utils[cnt].channel = newChannel;
382 DPRINT_INFO(VMBUS, "%s", 407 DPRINT_INFO(VMBUS, "%s",
383 hv_cb_utils[cnt].log_msg); 408 hv_cb_utils[cnt].log_msg);
384 409 count_hv_channel();
385 if (VmbusChannelOpen(newChannel, 2 * PAGE_SIZE,
386 2 * PAGE_SIZE, NULL, 0,
387 hv_cb_utils[cnt].callback,
388 newChannel) == 0)
389 hv_cb_utils[cnt].channel = newChannel;
390 } 410 }
391 cnt++;
392 } 411 }
393 } 412 }
394 DPRINT_EXIT(VMBUS); 413 DPRINT_EXIT(VMBUS);
diff --git a/drivers/staging/hv/hv_utils.c b/drivers/staging/hv/hv_utils.c
index 8a49aafea37a..2adc9b48ca9c 100644
--- a/drivers/staging/hv/hv_utils.c
+++ b/drivers/staging/hv/hv_utils.c
@@ -24,6 +24,8 @@
24#include <linux/slab.h> 24#include <linux/slab.h>
25#include <linux/sysctl.h> 25#include <linux/sysctl.h>
26#include <linux/reboot.h> 26#include <linux/reboot.h>
27#include <linux/dmi.h>
28#include <linux/pci.h>
27 29
28#include "logging.h" 30#include "logging.h"
29#include "osd.h" 31#include "osd.h"
@@ -251,10 +253,36 @@ static void heartbeat_onchannelcallback(void *context)
251 DPRINT_EXIT(VMBUS); 253 DPRINT_EXIT(VMBUS);
252} 254}
253 255
256static const struct pci_device_id __initconst
257hv_utils_pci_table[] __maybe_unused = {
258 { PCI_DEVICE(0x1414, 0x5353) }, /* Hyper-V emulated VGA controller */
259 { 0 }
260};
261MODULE_DEVICE_TABLE(pci, hv_utils_pci_table);
262
263
264static const struct dmi_system_id __initconst
265hv_utils_dmi_table[] __maybe_unused = {
266 {
267 .ident = "Hyper-V",
268 .matches = {
269 DMI_MATCH(DMI_SYS_VENDOR, "Microsoft Corporation"),
270 DMI_MATCH(DMI_PRODUCT_NAME, "Virtual Machine"),
271 DMI_MATCH(DMI_BOARD_NAME, "Virtual Machine"),
272 },
273 },
274 { },
275};
276MODULE_DEVICE_TABLE(dmi, hv_utils_dmi_table);
277
278
254static int __init init_hyperv_utils(void) 279static int __init init_hyperv_utils(void)
255{ 280{
256 printk(KERN_INFO "Registering HyperV Utility Driver\n"); 281 printk(KERN_INFO "Registering HyperV Utility Driver\n");
257 282
283 if (!dmi_check_system(hv_utils_dmi_table))
284 return -ENODEV;
285
258 hv_cb_utils[HV_SHUTDOWN_MSG].channel->OnChannelCallback = 286 hv_cb_utils[HV_SHUTDOWN_MSG].channel->OnChannelCallback =
259 &shutdown_onchannelcallback; 287 &shutdown_onchannelcallback;
260 hv_cb_utils[HV_SHUTDOWN_MSG].callback = &shutdown_onchannelcallback; 288 hv_cb_utils[HV_SHUTDOWN_MSG].callback = &shutdown_onchannelcallback;
diff --git a/drivers/staging/hv/vmbus.h b/drivers/staging/hv/vmbus.h
index 0c6ee0f487f3..3c14b2926e00 100644
--- a/drivers/staging/hv/vmbus.h
+++ b/drivers/staging/hv/vmbus.h
@@ -74,4 +74,6 @@ int vmbus_child_driver_register(struct driver_context *driver_ctx);
74void vmbus_child_driver_unregister(struct driver_context *driver_ctx); 74void vmbus_child_driver_unregister(struct driver_context *driver_ctx);
75void vmbus_get_interface(struct vmbus_channel_interface *interface); 75void vmbus_get_interface(struct vmbus_channel_interface *interface);
76 76
77extern struct completion hv_channel_ready;
78
77#endif /* _VMBUS_H_ */ 79#endif /* _VMBUS_H_ */
diff --git a/drivers/staging/hv/vmbus_drv.c b/drivers/staging/hv/vmbus_drv.c
index c21731a12ca7..22c80ece6388 100644
--- a/drivers/staging/hv/vmbus_drv.c
+++ b/drivers/staging/hv/vmbus_drv.c
@@ -27,6 +27,7 @@
27#include <linux/pci.h> 27#include <linux/pci.h>
28#include <linux/dmi.h> 28#include <linux/dmi.h>
29#include <linux/slab.h> 29#include <linux/slab.h>
30#include <linux/completion.h>
30#include "version_info.h" 31#include "version_info.h"
31#include "osd.h" 32#include "osd.h"
32#include "logging.h" 33#include "logging.h"
@@ -356,6 +357,8 @@ static int vmbus_bus_init(int (*drv_init)(struct hv_driver *drv))
356 357
357 vmbus_drv_obj->GetChannelOffers(); 358 vmbus_drv_obj->GetChannelOffers();
358 359
360 wait_for_completion(&hv_channel_ready);
361
359cleanup: 362cleanup:
360 DPRINT_EXIT(VMBUS_DRV); 363 DPRINT_EXIT(VMBUS_DRV);
361 364
diff --git a/drivers/staging/mrst-touchscreen/intel-mid-touch.c b/drivers/staging/mrst-touchscreen/intel-mid-touch.c
index 1db00975a594..abba22f921be 100644
--- a/drivers/staging/mrst-touchscreen/intel-mid-touch.c
+++ b/drivers/staging/mrst-touchscreen/intel-mid-touch.c
@@ -817,9 +817,9 @@ static int mrstouch_remove(struct spi_device *spi)
817 free_irq(mrstouchdevp->irq, mrstouchdevp); 817 free_irq(mrstouchdevp->irq, mrstouchdevp);
818 input_unregister_device(mrstouchdevp->input); 818 input_unregister_device(mrstouchdevp->input);
819 input_free_device(mrstouchdevp->input); 819 input_free_device(mrstouchdevp->input);
820 kfree(mrstouchdevp);
821 if (mrstouchdevp->pendet_thrd) 820 if (mrstouchdevp->pendet_thrd)
822 kthread_stop(mrstouchdevp->pendet_thrd); 821 kthread_stop(mrstouchdevp->pendet_thrd);
822 kfree(mrstouchdevp);
823 return 0; 823 return 0;
824} 824}
825 825
diff --git a/drivers/staging/rt2860/usb_main_dev.c b/drivers/staging/rt2860/usb_main_dev.c
index b740662d095a..674769d2b59b 100644
--- a/drivers/staging/rt2860/usb_main_dev.c
+++ b/drivers/staging/rt2860/usb_main_dev.c
@@ -77,6 +77,7 @@ struct usb_device_id rtusb_usb_id[] = {
77 {USB_DEVICE(0x083A, 0x7522)}, /* Arcadyan */ 77 {USB_DEVICE(0x083A, 0x7522)}, /* Arcadyan */
78 {USB_DEVICE(0x0CDE, 0x0022)}, /* ZCOM */ 78 {USB_DEVICE(0x0CDE, 0x0022)}, /* ZCOM */
79 {USB_DEVICE(0x0586, 0x3416)}, /* Zyxel */ 79 {USB_DEVICE(0x0586, 0x3416)}, /* Zyxel */
80 {USB_DEVICE(0x0586, 0x341a)}, /* Zyxel NWD-270N */
80 {USB_DEVICE(0x0CDE, 0x0025)}, /* Zyxel */ 81 {USB_DEVICE(0x0CDE, 0x0025)}, /* Zyxel */
81 {USB_DEVICE(0x1740, 0x9701)}, /* EnGenius */ 82 {USB_DEVICE(0x1740, 0x9701)}, /* EnGenius */
82 {USB_DEVICE(0x1740, 0x9702)}, /* EnGenius */ 83 {USB_DEVICE(0x1740, 0x9702)}, /* EnGenius */
diff --git a/drivers/staging/rtl8187se/r8180_core.c b/drivers/staging/rtl8187se/r8180_core.c
index dacefea78113..49ab9fa9ffa7 100644
--- a/drivers/staging/rtl8187se/r8180_core.c
+++ b/drivers/staging/rtl8187se/r8180_core.c
@@ -66,8 +66,6 @@ static int hwseqnum = 0;
66static int hwwep = 0; 66static int hwwep = 0;
67static int channels = 0x3fff; 67static int channels = 0x3fff;
68 68
69#define eqMacAddr(a, b) (((a)[0] == (b)[0] && (a)[1] == (b)[1] && (a)[2] == (b)[2] && (a)[3] == (b)[3] && (a)[4] == (b)[4] && (a)[5] == (b)[5]) ? 1 : 0)
70#define cpMacAddr(des, src) ((des)[0] = (src)[0], (des)[1] = (src)[1], (des)[2] = (src)[2], (des)[3] = (src)[3], (des)[4] = (src)[4], (des)[5] = (src)[5])
71MODULE_LICENSE("GPL"); 69MODULE_LICENSE("GPL");
72MODULE_DEVICE_TABLE(pci, rtl8180_pci_id_tbl); 70MODULE_DEVICE_TABLE(pci, rtl8180_pci_id_tbl);
73MODULE_AUTHOR("Andrea Merello <andreamrl@tiscali.it>"); 71MODULE_AUTHOR("Andrea Merello <andreamrl@tiscali.it>");
diff --git a/drivers/staging/rtl8192su/r8192U_core.c b/drivers/staging/rtl8192su/r8192U_core.c
index 447d6474a70c..1b6890611fb6 100644
--- a/drivers/staging/rtl8192su/r8192U_core.c
+++ b/drivers/staging/rtl8192su/r8192U_core.c
@@ -112,28 +112,29 @@ u32 rt_global_debug_component = \
112#define CAM_CONTENT_COUNT 8 112#define CAM_CONTENT_COUNT 8
113 113
114static const struct usb_device_id rtl8192_usb_id_tbl[] = { 114static const struct usb_device_id rtl8192_usb_id_tbl[] = {
115 /* Realtek */ 115 {USB_DEVICE(0x0bda, 0x8171)}, /* Realtek */
116 {USB_DEVICE(0x0bda, 0x8171)},
117 {USB_DEVICE(0x0bda, 0x8192)},
118 {USB_DEVICE(0x0bda, 0x8709)},
119 /* Corega */
120 {USB_DEVICE(0x07aa, 0x0043)},
121 /* Belkin */
122 {USB_DEVICE(0x050d, 0x805E)},
123 {USB_DEVICE(0x050d, 0x815F)}, /* Belkin F5D8053 v6 */
124 /* Sitecom */
125 {USB_DEVICE(0x0df6, 0x0031)},
126 {USB_DEVICE(0x0df6, 0x004b)}, /* WL-349 */
127 /* EnGenius */
128 {USB_DEVICE(0x1740, 0x9201)},
129 /* Dlink */
130 {USB_DEVICE(0x2001, 0x3301)},
131 /* Zinwell */
132 {USB_DEVICE(0x5a57, 0x0290)},
133 /* Guillemot */
134 {USB_DEVICE(0x06f8, 0xe031)},
135 //92SU
136 {USB_DEVICE(0x0bda, 0x8172)}, 116 {USB_DEVICE(0x0bda, 0x8172)},
117 {USB_DEVICE(0x0bda, 0x8173)},
118 {USB_DEVICE(0x0bda, 0x8174)},
119 {USB_DEVICE(0x0bda, 0x8712)},
120 {USB_DEVICE(0x0bda, 0x8713)},
121 {USB_DEVICE(0x07aa, 0x0047)},
122 {USB_DEVICE(0x07d1, 0x3303)},
123 {USB_DEVICE(0x07d1, 0x3302)},
124 {USB_DEVICE(0x07d1, 0x3300)},
125 {USB_DEVICE(0x1740, 0x9603)},
126 {USB_DEVICE(0x1740, 0x9605)},
127 {USB_DEVICE(0x050d, 0x815F)},
128 {USB_DEVICE(0x06f8, 0xe031)},
129 {USB_DEVICE(0x7392, 0x7611)},
130 {USB_DEVICE(0x7392, 0x7612)},
131 {USB_DEVICE(0x7392, 0x7622)},
132 {USB_DEVICE(0x0DF6, 0x0045)},
133 {USB_DEVICE(0x0E66, 0x0015)},
134 {USB_DEVICE(0x0E66, 0x0016)},
135 {USB_DEVICE(0x0b05, 0x1786)},
136 /* these are not in the official list */
137 {USB_DEVICE(0x0df6, 0x004b)}, /* WL-349 */
137 {} 138 {}
138}; 139};
139 140
diff --git a/drivers/staging/rtl8192u/r8192U_core.c b/drivers/staging/rtl8192u/r8192U_core.c
index 2bede271a2f0..f38472c2e75c 100644
--- a/drivers/staging/rtl8192u/r8192U_core.c
+++ b/drivers/staging/rtl8192u/r8192U_core.c
@@ -121,6 +121,8 @@ static const struct usb_device_id rtl8192_usb_id_tbl[] = {
121 {USB_DEVICE(0x2001, 0x3301)}, 121 {USB_DEVICE(0x2001, 0x3301)},
122 /* Zinwell */ 122 /* Zinwell */
123 {USB_DEVICE(0x5a57, 0x0290)}, 123 {USB_DEVICE(0x5a57, 0x0290)},
124 /* LG */
125 {USB_DEVICE(0x043e, 0x7a01)},
124 {} 126 {}
125}; 127};
126 128
diff --git a/drivers/staging/tm6000/tm6000-alsa.c b/drivers/staging/tm6000/tm6000-alsa.c
index ce081cd44ad4..273e26ede650 100644
--- a/drivers/staging/tm6000/tm6000-alsa.c
+++ b/drivers/staging/tm6000/tm6000-alsa.c
@@ -15,6 +15,7 @@
15#include <linux/device.h> 15#include <linux/device.h>
16#include <linux/interrupt.h> 16#include <linux/interrupt.h>
17#include <linux/usb.h> 17#include <linux/usb.h>
18#include <linux/slab.h>
18 19
19#include <asm/delay.h> 20#include <asm/delay.h>
20#include <sound/core.h> 21#include <sound/core.h>
diff --git a/drivers/staging/tm6000/tm6000-cards.c b/drivers/staging/tm6000/tm6000-cards.c
index cedd9044022f..6a9ae40c7c6d 100644
--- a/drivers/staging/tm6000/tm6000-cards.c
+++ b/drivers/staging/tm6000/tm6000-cards.c
@@ -24,6 +24,7 @@
24#include <linux/i2c.h> 24#include <linux/i2c.h>
25#include <linux/usb.h> 25#include <linux/usb.h>
26#include <linux/version.h> 26#include <linux/version.h>
27#include <linux/slab.h>
27#include <media/v4l2-common.h> 28#include <media/v4l2-common.h>
28#include <media/tuner.h> 29#include <media/tuner.h>
29#include <media/tvaudio.h> 30#include <media/tvaudio.h>
diff --git a/drivers/staging/tm6000/tm6000-core.c b/drivers/staging/tm6000/tm6000-core.c
index 27f3f551b545..c3690e3580da 100644
--- a/drivers/staging/tm6000/tm6000-core.c
+++ b/drivers/staging/tm6000/tm6000-core.c
@@ -22,6 +22,7 @@
22 22
23#include <linux/module.h> 23#include <linux/module.h>
24#include <linux/kernel.h> 24#include <linux/kernel.h>
25#include <linux/slab.h>
25#include <linux/usb.h> 26#include <linux/usb.h>
26#include <linux/i2c.h> 27#include <linux/i2c.h>
27#include "tm6000.h" 28#include "tm6000.h"
diff --git a/drivers/staging/tm6000/tm6000-dvb.c b/drivers/staging/tm6000/tm6000-dvb.c
index 261e66acbe46..86c1c8b5f25a 100644
--- a/drivers/staging/tm6000/tm6000-dvb.c
+++ b/drivers/staging/tm6000/tm6000-dvb.c
@@ -18,6 +18,7 @@
18 */ 18 */
19 19
20#include <linux/kernel.h> 20#include <linux/kernel.h>
21#include <linux/slab.h>
21#include <linux/usb.h> 22#include <linux/usb.h>
22 23
23#include "tm6000.h" 24#include "tm6000.h"
diff --git a/drivers/staging/usbip/usbip_common.c b/drivers/staging/usbip/usbip_common.c
index 52408164036f..6a499f0eb594 100644
--- a/drivers/staging/usbip/usbip_common.c
+++ b/drivers/staging/usbip/usbip_common.c
@@ -378,47 +378,67 @@ int usbip_thread(void *param)
378 complete_and_exit(&ut->thread_done, 0); 378 complete_and_exit(&ut->thread_done, 0);
379} 379}
380 380
381static void stop_rx_thread(struct usbip_device *ud)
382{
383 if (ud->tcp_rx.thread != NULL) {
384 send_sig(SIGKILL, ud->tcp_rx.thread, 1);
385 wait_for_completion(&ud->tcp_rx.thread_done);
386 usbip_udbg("rx_thread for ud %p has finished\n", ud);
387 }
388}
389
390static void stop_tx_thread(struct usbip_device *ud)
391{
392 if (ud->tcp_tx.thread != NULL) {
393 send_sig(SIGKILL, ud->tcp_tx.thread, 1);
394 wait_for_completion(&ud->tcp_tx.thread_done);
395 usbip_udbg("tx_thread for ud %p has finished\n", ud);
396 }
397}
398
381int usbip_start_threads(struct usbip_device *ud) 399int usbip_start_threads(struct usbip_device *ud)
382{ 400{
383 /* 401 /*
384 * threads are invoked per one device (per one connection). 402 * threads are invoked per one device (per one connection).
385 */ 403 */
386 struct task_struct *th; 404 struct task_struct *th;
405 int err = 0;
387 406
388 th = kthread_run(usbip_thread, (void *)&ud->tcp_rx, "usbip"); 407 th = kthread_run(usbip_thread, (void *)&ud->tcp_rx, "usbip");
389 if (IS_ERR(th)) { 408 if (IS_ERR(th)) {
390 printk(KERN_WARNING 409 printk(KERN_WARNING
391 "Unable to start control thread\n"); 410 "Unable to start control thread\n");
392 return PTR_ERR(th); 411 err = PTR_ERR(th);
412 goto ust_exit;
393 } 413 }
414
394 th = kthread_run(usbip_thread, (void *)&ud->tcp_tx, "usbip"); 415 th = kthread_run(usbip_thread, (void *)&ud->tcp_tx, "usbip");
395 if (IS_ERR(th)) { 416 if (IS_ERR(th)) {
396 printk(KERN_WARNING 417 printk(KERN_WARNING
397 "Unable to start control thread\n"); 418 "Unable to start control thread\n");
398 return PTR_ERR(th); 419 err = PTR_ERR(th);
420 goto tx_thread_err;
399 } 421 }
400 422
401 /* confirm threads are starting */ 423 /* confirm threads are starting */
402 wait_for_completion(&ud->tcp_rx.thread_done); 424 wait_for_completion(&ud->tcp_rx.thread_done);
403 wait_for_completion(&ud->tcp_tx.thread_done); 425 wait_for_completion(&ud->tcp_tx.thread_done);
426
404 return 0; 427 return 0;
428
429tx_thread_err:
430 stop_rx_thread(ud);
431
432ust_exit:
433 return err;
405} 434}
406EXPORT_SYMBOL_GPL(usbip_start_threads); 435EXPORT_SYMBOL_GPL(usbip_start_threads);
407 436
408void usbip_stop_threads(struct usbip_device *ud) 437void usbip_stop_threads(struct usbip_device *ud)
409{ 438{
410 /* kill threads related to this sdev, if v.c. exists */ 439 /* kill threads related to this sdev, if v.c. exists */
411 if (ud->tcp_rx.thread != NULL) { 440 stop_rx_thread(ud);
412 send_sig(SIGKILL, ud->tcp_rx.thread, 1); 441 stop_tx_thread(ud);
413 wait_for_completion(&ud->tcp_rx.thread_done);
414 usbip_udbg("rx_thread for ud %p has finished\n", ud);
415 }
416
417 if (ud->tcp_tx.thread != NULL) {
418 send_sig(SIGKILL, ud->tcp_tx.thread, 1);
419 wait_for_completion(&ud->tcp_tx.thread_done);
420 usbip_udbg("tx_thread for ud %p has finished\n", ud);
421 }
422} 442}
423EXPORT_SYMBOL_GPL(usbip_stop_threads); 443EXPORT_SYMBOL_GPL(usbip_stop_threads);
424 444
diff --git a/drivers/staging/wlags49_h2/wl_enc.c b/drivers/staging/wlags49_h2/wl_enc.c
index 48c44c8fdb28..26cf5486edd6 100644
--- a/drivers/staging/wlags49_h2/wl_enc.c
+++ b/drivers/staging/wlags49_h2/wl_enc.c
@@ -62,6 +62,7 @@
62/******************************************************************************* 62/*******************************************************************************
63 * include files 63 * include files
64 ******************************************************************************/ 64 ******************************************************************************/
65#include <linux/string.h>
65#include <wl_version.h> 66#include <wl_version.h>
66 67
67#include <debug.h> 68#include <debug.h>
diff --git a/drivers/staging/wlags49_h2/wl_sysfs.h b/drivers/staging/wlags49_h2/wl_sysfs.h
index 6d96d03cf490..fa658c38001e 100644
--- a/drivers/staging/wlags49_h2/wl_sysfs.h
+++ b/drivers/staging/wlags49_h2/wl_sysfs.h
@@ -2,6 +2,6 @@
2extern void register_wlags_sysfs(struct net_device *); 2extern void register_wlags_sysfs(struct net_device *);
3extern void unregister_wlags_sysfs(struct net_device *); 3extern void unregister_wlags_sysfs(struct net_device *);
4#else 4#else
5static void register_wlags_sysfs(struct net_device *) { return; }; 5static inline void register_wlags_sysfs(struct net_device *net) { }
6static void unregister_wlags_sysfs(struct net_device *) { return; }; 6static inline void unregister_wlags_sysfs(struct net_device *net) { }
7#endif 7#endif
diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c
index 8413a567c12d..89d260d6b031 100644
--- a/drivers/usb/class/cdc-acm.c
+++ b/drivers/usb/class/cdc-acm.c
@@ -1596,6 +1596,7 @@ static const struct usb_device_id acm_ids[] = {
1596 { NOKIA_PCSUITE_ACM_INFO(0x00e9), }, /* Nokia 5320 XpressMusic */ 1596 { NOKIA_PCSUITE_ACM_INFO(0x00e9), }, /* Nokia 5320 XpressMusic */
1597 { NOKIA_PCSUITE_ACM_INFO(0x0108), }, /* Nokia 5320 XpressMusic 2G */ 1597 { NOKIA_PCSUITE_ACM_INFO(0x0108), }, /* Nokia 5320 XpressMusic 2G */
1598 { NOKIA_PCSUITE_ACM_INFO(0x01f5), }, /* Nokia N97, RM-505 */ 1598 { NOKIA_PCSUITE_ACM_INFO(0x01f5), }, /* Nokia N97, RM-505 */
1599 { NOKIA_PCSUITE_ACM_INFO(0x02e3), }, /* Nokia 5230, RM-588 */
1599 1600
1600 /* NOTE: non-Nokia COMM/ACM/0xff is likely MSFT RNDIS... NOT a modem! */ 1601 /* NOTE: non-Nokia COMM/ACM/0xff is likely MSFT RNDIS... NOT a modem! */
1601 1602
diff --git a/drivers/usb/core/driver.c b/drivers/usb/core/driver.c
index de98a94d1853..a6bd53ace035 100644
--- a/drivers/usb/core/driver.c
+++ b/drivers/usb/core/driver.c
@@ -1272,8 +1272,7 @@ static int usb_resume_both(struct usb_device *udev, pm_message_t msg)
1272 1272
1273static void choose_wakeup(struct usb_device *udev, pm_message_t msg) 1273static void choose_wakeup(struct usb_device *udev, pm_message_t msg)
1274{ 1274{
1275 int w, i; 1275 int w;
1276 struct usb_interface *intf;
1277 1276
1278 /* Remote wakeup is needed only when we actually go to sleep. 1277 /* Remote wakeup is needed only when we actually go to sleep.
1279 * For things like FREEZE and QUIESCE, if the device is already 1278 * For things like FREEZE and QUIESCE, if the device is already
@@ -1285,16 +1284,10 @@ static void choose_wakeup(struct usb_device *udev, pm_message_t msg)
1285 return; 1284 return;
1286 } 1285 }
1287 1286
1288 /* If remote wakeup is permitted, see whether any interface drivers 1287 /* Enable remote wakeup if it is allowed, even if no interface drivers
1289 * actually want it. 1288 * actually want it.
1290 */ 1289 */
1291 w = 0; 1290 w = device_may_wakeup(&udev->dev);
1292 if (device_may_wakeup(&udev->dev) && udev->actconfig) {
1293 for (i = 0; i < udev->actconfig->desc.bNumInterfaces; i++) {
1294 intf = udev->actconfig->interface[i];
1295 w |= intf->needs_remote_wakeup;
1296 }
1297 }
1298 1291
1299 /* If the device is autosuspended with the wrong wakeup setting, 1292 /* If the device is autosuspended with the wrong wakeup setting,
1300 * autoresume now so the setting can be changed. 1293 * autoresume now so the setting can be changed.
diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index 83e7bbbe97fa..70cccc75a362 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -1982,6 +1982,8 @@ static int hub_port_wait_reset(struct usb_hub *hub, int port1,
1982 (portstatus & USB_PORT_STAT_ENABLE)) { 1982 (portstatus & USB_PORT_STAT_ENABLE)) {
1983 if (hub_is_wusb(hub)) 1983 if (hub_is_wusb(hub))
1984 udev->speed = USB_SPEED_WIRELESS; 1984 udev->speed = USB_SPEED_WIRELESS;
1985 else if (portstatus & USB_PORT_STAT_SUPER_SPEED)
1986 udev->speed = USB_SPEED_SUPER;
1985 else if (portstatus & USB_PORT_STAT_HIGH_SPEED) 1987 else if (portstatus & USB_PORT_STAT_HIGH_SPEED)
1986 udev->speed = USB_SPEED_HIGH; 1988 udev->speed = USB_SPEED_HIGH;
1987 else if (portstatus & USB_PORT_STAT_LOW_SPEED) 1989 else if (portstatus & USB_PORT_STAT_LOW_SPEED)
diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c
index a73e08fdab36..fd4c36ea5e46 100644
--- a/drivers/usb/core/message.c
+++ b/drivers/usb/core/message.c
@@ -416,8 +416,11 @@ int usb_sg_init(struct usb_sg_request *io, struct usb_device *dev,
416 /* A length of zero means transfer the whole sg list */ 416 /* A length of zero means transfer the whole sg list */
417 len = length; 417 len = length;
418 if (len == 0) { 418 if (len == 0) {
419 for_each_sg(sg, sg, nents, i) 419 struct scatterlist *sg2;
420 len += sg->length; 420 int j;
421
422 for_each_sg(sg, sg2, nents, j)
423 len += sg2->length;
421 } 424 }
422 } else { 425 } else {
423 /* 426 /*
diff --git a/drivers/usb/core/quirks.c b/drivers/usb/core/quirks.c
index f22d03df8b17..db99c084df92 100644
--- a/drivers/usb/core/quirks.c
+++ b/drivers/usb/core/quirks.c
@@ -41,6 +41,10 @@ static const struct usb_device_id usb_quirk_list[] = {
41 /* Philips PSC805 audio device */ 41 /* Philips PSC805 audio device */
42 { USB_DEVICE(0x0471, 0x0155), .driver_info = USB_QUIRK_RESET_RESUME }, 42 { USB_DEVICE(0x0471, 0x0155), .driver_info = USB_QUIRK_RESET_RESUME },
43 43
44 /* Artisman Watchdog Dongle */
45 { USB_DEVICE(0x04b4, 0x0526), .driver_info =
46 USB_QUIRK_CONFIG_INTF_STRINGS },
47
44 /* Roland SC-8820 */ 48 /* Roland SC-8820 */
45 { USB_DEVICE(0x0582, 0x0007), .driver_info = USB_QUIRK_RESET_RESUME }, 49 { USB_DEVICE(0x0582, 0x0007), .driver_info = USB_QUIRK_RESET_RESUME },
46 50
@@ -64,6 +68,9 @@ static const struct usb_device_id usb_quirk_list[] = {
64 /* X-Rite/Gretag-Macbeth Eye-One Pro display colorimeter */ 68 /* X-Rite/Gretag-Macbeth Eye-One Pro display colorimeter */
65 { USB_DEVICE(0x0971, 0x2000), .driver_info = USB_QUIRK_NO_SET_INTF }, 69 { USB_DEVICE(0x0971, 0x2000), .driver_info = USB_QUIRK_NO_SET_INTF },
66 70
71 /* Broadcom BCM92035DGROM BT dongle */
72 { USB_DEVICE(0x0a5c, 0x2021), .driver_info = USB_QUIRK_RESET_RESUME },
73
67 /* Action Semiconductor flash disk */ 74 /* Action Semiconductor flash disk */
68 { USB_DEVICE(0x10d6, 0x2200), .driver_info = 75 { USB_DEVICE(0x10d6, 0x2200), .driver_info =
69 USB_QUIRK_STRING_FETCH_255 }, 76 USB_QUIRK_STRING_FETCH_255 },
diff --git a/drivers/usb/gadget/at91_udc.c b/drivers/usb/gadget/at91_udc.c
index eaa79c8a9b8c..93ead19507b6 100644
--- a/drivers/usb/gadget/at91_udc.c
+++ b/drivers/usb/gadget/at91_udc.c
@@ -76,11 +76,12 @@
76static const char driver_name [] = "at91_udc"; 76static const char driver_name [] = "at91_udc";
77static const char ep0name[] = "ep0"; 77static const char ep0name[] = "ep0";
78 78
79#define VBUS_POLL_TIMEOUT msecs_to_jiffies(1000)
79 80
80#define at91_udp_read(dev, reg) \ 81#define at91_udp_read(udc, reg) \
81 __raw_readl((dev)->udp_baseaddr + (reg)) 82 __raw_readl((udc)->udp_baseaddr + (reg))
82#define at91_udp_write(dev, reg, val) \ 83#define at91_udp_write(udc, reg, val) \
83 __raw_writel((val), (dev)->udp_baseaddr + (reg)) 84 __raw_writel((val), (udc)->udp_baseaddr + (reg))
84 85
85/*-------------------------------------------------------------------------*/ 86/*-------------------------------------------------------------------------*/
86 87
@@ -102,8 +103,9 @@ static void proc_ep_show(struct seq_file *s, struct at91_ep *ep)
102 u32 csr; 103 u32 csr;
103 struct at91_request *req; 104 struct at91_request *req;
104 unsigned long flags; 105 unsigned long flags;
106 struct at91_udc *udc = ep->udc;
105 107
106 local_irq_save(flags); 108 spin_lock_irqsave(&udc->lock, flags);
107 109
108 csr = __raw_readl(ep->creg); 110 csr = __raw_readl(ep->creg);
109 111
@@ -147,7 +149,7 @@ static void proc_ep_show(struct seq_file *s, struct at91_ep *ep)
147 &req->req, length, 149 &req->req, length,
148 req->req.length, req->req.buf); 150 req->req.length, req->req.buf);
149 } 151 }
150 local_irq_restore(flags); 152 spin_unlock_irqrestore(&udc->lock, flags);
151} 153}
152 154
153static void proc_irq_show(struct seq_file *s, const char *label, u32 mask) 155static void proc_irq_show(struct seq_file *s, const char *label, u32 mask)
@@ -272,7 +274,9 @@ static void done(struct at91_ep *ep, struct at91_request *req, int status)
272 VDBG("%s done %p, status %d\n", ep->ep.name, req, status); 274 VDBG("%s done %p, status %d\n", ep->ep.name, req, status);
273 275
274 ep->stopped = 1; 276 ep->stopped = 1;
277 spin_unlock(&udc->lock);
275 req->req.complete(&ep->ep, &req->req); 278 req->req.complete(&ep->ep, &req->req);
279 spin_lock(&udc->lock);
276 ep->stopped = stopped; 280 ep->stopped = stopped;
277 281
278 /* ep0 is always ready; other endpoints need a non-empty queue */ 282 /* ep0 is always ready; other endpoints need a non-empty queue */
@@ -472,7 +476,7 @@ static int at91_ep_enable(struct usb_ep *_ep,
472 const struct usb_endpoint_descriptor *desc) 476 const struct usb_endpoint_descriptor *desc)
473{ 477{
474 struct at91_ep *ep = container_of(_ep, struct at91_ep, ep); 478 struct at91_ep *ep = container_of(_ep, struct at91_ep, ep);
475 struct at91_udc *dev = ep->udc; 479 struct at91_udc *udc = ep->udc;
476 u16 maxpacket; 480 u16 maxpacket;
477 u32 tmp; 481 u32 tmp;
478 unsigned long flags; 482 unsigned long flags;
@@ -487,7 +491,7 @@ static int at91_ep_enable(struct usb_ep *_ep,
487 return -EINVAL; 491 return -EINVAL;
488 } 492 }
489 493
490 if (!dev->driver || dev->gadget.speed == USB_SPEED_UNKNOWN) { 494 if (!udc->driver || udc->gadget.speed == USB_SPEED_UNKNOWN) {
491 DBG("bogus device state\n"); 495 DBG("bogus device state\n");
492 return -ESHUTDOWN; 496 return -ESHUTDOWN;
493 } 497 }
@@ -521,7 +525,7 @@ bogus_max:
521 } 525 }
522 526
523ok: 527ok:
524 local_irq_save(flags); 528 spin_lock_irqsave(&udc->lock, flags);
525 529
526 /* initialize endpoint to match this descriptor */ 530 /* initialize endpoint to match this descriptor */
527 ep->is_in = usb_endpoint_dir_in(desc); 531 ep->is_in = usb_endpoint_dir_in(desc);
@@ -540,10 +544,10 @@ ok:
540 * reset/init endpoint fifo. NOTE: leaves fifo_bank alone, 544 * reset/init endpoint fifo. NOTE: leaves fifo_bank alone,
541 * since endpoint resets don't reset hw pingpong state. 545 * since endpoint resets don't reset hw pingpong state.
542 */ 546 */
543 at91_udp_write(dev, AT91_UDP_RST_EP, ep->int_mask); 547 at91_udp_write(udc, AT91_UDP_RST_EP, ep->int_mask);
544 at91_udp_write(dev, AT91_UDP_RST_EP, 0); 548 at91_udp_write(udc, AT91_UDP_RST_EP, 0);
545 549
546 local_irq_restore(flags); 550 spin_unlock_irqrestore(&udc->lock, flags);
547 return 0; 551 return 0;
548} 552}
549 553
@@ -556,7 +560,7 @@ static int at91_ep_disable (struct usb_ep * _ep)
556 if (ep == &ep->udc->ep[0]) 560 if (ep == &ep->udc->ep[0])
557 return -EINVAL; 561 return -EINVAL;
558 562
559 local_irq_save(flags); 563 spin_lock_irqsave(&udc->lock, flags);
560 564
561 nuke(ep, -ESHUTDOWN); 565 nuke(ep, -ESHUTDOWN);
562 566
@@ -571,7 +575,7 @@ static int at91_ep_disable (struct usb_ep * _ep)
571 __raw_writel(0, ep->creg); 575 __raw_writel(0, ep->creg);
572 } 576 }
573 577
574 local_irq_restore(flags); 578 spin_unlock_irqrestore(&udc->lock, flags);
575 return 0; 579 return 0;
576} 580}
577 581
@@ -607,7 +611,7 @@ static int at91_ep_queue(struct usb_ep *_ep,
607{ 611{
608 struct at91_request *req; 612 struct at91_request *req;
609 struct at91_ep *ep; 613 struct at91_ep *ep;
610 struct at91_udc *dev; 614 struct at91_udc *udc;
611 int status; 615 int status;
612 unsigned long flags; 616 unsigned long flags;
613 617
@@ -625,9 +629,9 @@ static int at91_ep_queue(struct usb_ep *_ep,
625 return -EINVAL; 629 return -EINVAL;
626 } 630 }
627 631
628 dev = ep->udc; 632 udc = ep->udc;
629 633
630 if (!dev || !dev->driver || dev->gadget.speed == USB_SPEED_UNKNOWN) { 634 if (!udc || !udc->driver || udc->gadget.speed == USB_SPEED_UNKNOWN) {
631 DBG("invalid device\n"); 635 DBG("invalid device\n");
632 return -EINVAL; 636 return -EINVAL;
633 } 637 }
@@ -635,7 +639,7 @@ static int at91_ep_queue(struct usb_ep *_ep,
635 _req->status = -EINPROGRESS; 639 _req->status = -EINPROGRESS;
636 _req->actual = 0; 640 _req->actual = 0;
637 641
638 local_irq_save(flags); 642 spin_lock_irqsave(&udc->lock, flags);
639 643
640 /* try to kickstart any empty and idle queue */ 644 /* try to kickstart any empty and idle queue */
641 if (list_empty(&ep->queue) && !ep->stopped) { 645 if (list_empty(&ep->queue) && !ep->stopped) {
@@ -653,7 +657,7 @@ static int at91_ep_queue(struct usb_ep *_ep,
653 if (is_ep0) { 657 if (is_ep0) {
654 u32 tmp; 658 u32 tmp;
655 659
656 if (!dev->req_pending) { 660 if (!udc->req_pending) {
657 status = -EINVAL; 661 status = -EINVAL;
658 goto done; 662 goto done;
659 } 663 }
@@ -662,11 +666,11 @@ static int at91_ep_queue(struct usb_ep *_ep,
662 * defer changing CONFG until after the gadget driver 666 * defer changing CONFG until after the gadget driver
663 * reconfigures the endpoints. 667 * reconfigures the endpoints.
664 */ 668 */
665 if (dev->wait_for_config_ack) { 669 if (udc->wait_for_config_ack) {
666 tmp = at91_udp_read(dev, AT91_UDP_GLB_STAT); 670 tmp = at91_udp_read(udc, AT91_UDP_GLB_STAT);
667 tmp ^= AT91_UDP_CONFG; 671 tmp ^= AT91_UDP_CONFG;
668 VDBG("toggle config\n"); 672 VDBG("toggle config\n");
669 at91_udp_write(dev, AT91_UDP_GLB_STAT, tmp); 673 at91_udp_write(udc, AT91_UDP_GLB_STAT, tmp);
670 } 674 }
671 if (req->req.length == 0) { 675 if (req->req.length == 0) {
672ep0_in_status: 676ep0_in_status:
@@ -676,7 +680,7 @@ ep0_in_status:
676 tmp &= ~SET_FX; 680 tmp &= ~SET_FX;
677 tmp |= CLR_FX | AT91_UDP_TXPKTRDY; 681 tmp |= CLR_FX | AT91_UDP_TXPKTRDY;
678 __raw_writel(tmp, ep->creg); 682 __raw_writel(tmp, ep->creg);
679 dev->req_pending = 0; 683 udc->req_pending = 0;
680 goto done; 684 goto done;
681 } 685 }
682 } 686 }
@@ -695,31 +699,40 @@ ep0_in_status:
695 699
696 if (req && !status) { 700 if (req && !status) {
697 list_add_tail (&req->queue, &ep->queue); 701 list_add_tail (&req->queue, &ep->queue);
698 at91_udp_write(dev, AT91_UDP_IER, ep->int_mask); 702 at91_udp_write(udc, AT91_UDP_IER, ep->int_mask);
699 } 703 }
700done: 704done:
701 local_irq_restore(flags); 705 spin_unlock_irqrestore(&udc->lock, flags);
702 return (status < 0) ? status : 0; 706 return (status < 0) ? status : 0;
703} 707}
704 708
705static int at91_ep_dequeue(struct usb_ep *_ep, struct usb_request *_req) 709static int at91_ep_dequeue(struct usb_ep *_ep, struct usb_request *_req)
706{ 710{
707 struct at91_ep *ep; 711 struct at91_ep *ep;
708 struct at91_request *req; 712 struct at91_request *req;
713 unsigned long flags;
714 struct at91_udc *udc;
709 715
710 ep = container_of(_ep, struct at91_ep, ep); 716 ep = container_of(_ep, struct at91_ep, ep);
711 if (!_ep || ep->ep.name == ep0name) 717 if (!_ep || ep->ep.name == ep0name)
712 return -EINVAL; 718 return -EINVAL;
713 719
720 udc = ep->udc;
721
722 spin_lock_irqsave(&udc->lock, flags);
723
714 /* make sure it's actually queued on this endpoint */ 724 /* make sure it's actually queued on this endpoint */
715 list_for_each_entry (req, &ep->queue, queue) { 725 list_for_each_entry (req, &ep->queue, queue) {
716 if (&req->req == _req) 726 if (&req->req == _req)
717 break; 727 break;
718 } 728 }
719 if (&req->req != _req) 729 if (&req->req != _req) {
730 spin_unlock_irqrestore(&udc->lock, flags);
720 return -EINVAL; 731 return -EINVAL;
732 }
721 733
722 done(ep, req, -ECONNRESET); 734 done(ep, req, -ECONNRESET);
735 spin_unlock_irqrestore(&udc->lock, flags);
723 return 0; 736 return 0;
724} 737}
725 738
@@ -736,7 +749,7 @@ static int at91_ep_set_halt(struct usb_ep *_ep, int value)
736 return -EINVAL; 749 return -EINVAL;
737 750
738 creg = ep->creg; 751 creg = ep->creg;
739 local_irq_save(flags); 752 spin_lock_irqsave(&udc->lock, flags);
740 753
741 csr = __raw_readl(creg); 754 csr = __raw_readl(creg);
742 755
@@ -761,7 +774,7 @@ static int at91_ep_set_halt(struct usb_ep *_ep, int value)
761 __raw_writel(csr, creg); 774 __raw_writel(csr, creg);
762 } 775 }
763 776
764 local_irq_restore(flags); 777 spin_unlock_irqrestore(&udc->lock, flags);
765 return status; 778 return status;
766} 779}
767 780
@@ -795,7 +808,7 @@ static int at91_wakeup(struct usb_gadget *gadget)
795 unsigned long flags; 808 unsigned long flags;
796 809
797 DBG("%s\n", __func__ ); 810 DBG("%s\n", __func__ );
798 local_irq_save(flags); 811 spin_lock_irqsave(&udc->lock, flags);
799 812
800 if (!udc->clocked || !udc->suspended) 813 if (!udc->clocked || !udc->suspended)
801 goto done; 814 goto done;
@@ -809,7 +822,7 @@ static int at91_wakeup(struct usb_gadget *gadget)
809 at91_udp_write(udc, AT91_UDP_GLB_STAT, glbstate); 822 at91_udp_write(udc, AT91_UDP_GLB_STAT, glbstate);
810 823
811done: 824done:
812 local_irq_restore(flags); 825 spin_unlock_irqrestore(&udc->lock, flags);
813 return status; 826 return status;
814} 827}
815 828
@@ -851,8 +864,11 @@ static void stop_activity(struct at91_udc *udc)
851 ep->stopped = 1; 864 ep->stopped = 1;
852 nuke(ep, -ESHUTDOWN); 865 nuke(ep, -ESHUTDOWN);
853 } 866 }
854 if (driver) 867 if (driver) {
868 spin_unlock(&udc->lock);
855 driver->disconnect(&udc->gadget); 869 driver->disconnect(&udc->gadget);
870 spin_lock(&udc->lock);
871 }
856 872
857 udc_reinit(udc); 873 udc_reinit(udc);
858} 874}
@@ -935,13 +951,13 @@ static int at91_vbus_session(struct usb_gadget *gadget, int is_active)
935 unsigned long flags; 951 unsigned long flags;
936 952
937 // VDBG("vbus %s\n", is_active ? "on" : "off"); 953 // VDBG("vbus %s\n", is_active ? "on" : "off");
938 local_irq_save(flags); 954 spin_lock_irqsave(&udc->lock, flags);
939 udc->vbus = (is_active != 0); 955 udc->vbus = (is_active != 0);
940 if (udc->driver) 956 if (udc->driver)
941 pullup(udc, is_active); 957 pullup(udc, is_active);
942 else 958 else
943 pullup(udc, 0); 959 pullup(udc, 0);
944 local_irq_restore(flags); 960 spin_unlock_irqrestore(&udc->lock, flags);
945 return 0; 961 return 0;
946} 962}
947 963
@@ -950,10 +966,10 @@ static int at91_pullup(struct usb_gadget *gadget, int is_on)
950 struct at91_udc *udc = to_udc(gadget); 966 struct at91_udc *udc = to_udc(gadget);
951 unsigned long flags; 967 unsigned long flags;
952 968
953 local_irq_save(flags); 969 spin_lock_irqsave(&udc->lock, flags);
954 udc->enabled = is_on = !!is_on; 970 udc->enabled = is_on = !!is_on;
955 pullup(udc, is_on); 971 pullup(udc, is_on);
956 local_irq_restore(flags); 972 spin_unlock_irqrestore(&udc->lock, flags);
957 return 0; 973 return 0;
958} 974}
959 975
@@ -962,9 +978,9 @@ static int at91_set_selfpowered(struct usb_gadget *gadget, int is_on)
962 struct at91_udc *udc = to_udc(gadget); 978 struct at91_udc *udc = to_udc(gadget);
963 unsigned long flags; 979 unsigned long flags;
964 980
965 local_irq_save(flags); 981 spin_lock_irqsave(&udc->lock, flags);
966 udc->selfpowered = (is_on != 0); 982 udc->selfpowered = (is_on != 0);
967 local_irq_restore(flags); 983 spin_unlock_irqrestore(&udc->lock, flags);
968 return 0; 984 return 0;
969} 985}
970 986
@@ -1226,8 +1242,11 @@ static void handle_setup(struct at91_udc *udc, struct at91_ep *ep, u32 csr)
1226#undef w_length 1242#undef w_length
1227 1243
1228 /* pass request up to the gadget driver */ 1244 /* pass request up to the gadget driver */
1229 if (udc->driver) 1245 if (udc->driver) {
1246 spin_unlock(&udc->lock);
1230 status = udc->driver->setup(&udc->gadget, &pkt.r); 1247 status = udc->driver->setup(&udc->gadget, &pkt.r);
1248 spin_lock(&udc->lock);
1249 }
1231 else 1250 else
1232 status = -ENODEV; 1251 status = -ENODEV;
1233 if (status < 0) { 1252 if (status < 0) {
@@ -1378,6 +1397,9 @@ static irqreturn_t at91_udc_irq (int irq, void *_udc)
1378 struct at91_udc *udc = _udc; 1397 struct at91_udc *udc = _udc;
1379 u32 rescans = 5; 1398 u32 rescans = 5;
1380 int disable_clock = 0; 1399 int disable_clock = 0;
1400 unsigned long flags;
1401
1402 spin_lock_irqsave(&udc->lock, flags);
1381 1403
1382 if (!udc->clocked) { 1404 if (!udc->clocked) {
1383 clk_on(udc); 1405 clk_on(udc);
@@ -1433,8 +1455,11 @@ static irqreturn_t at91_udc_irq (int irq, void *_udc)
1433 * and then into standby to avoid drawing more than 1455 * and then into standby to avoid drawing more than
1434 * 500uA power (2500uA for some high-power configs). 1456 * 500uA power (2500uA for some high-power configs).
1435 */ 1457 */
1436 if (udc->driver && udc->driver->suspend) 1458 if (udc->driver && udc->driver->suspend) {
1459 spin_unlock(&udc->lock);
1437 udc->driver->suspend(&udc->gadget); 1460 udc->driver->suspend(&udc->gadget);
1461 spin_lock(&udc->lock);
1462 }
1438 1463
1439 /* host initiated resume */ 1464 /* host initiated resume */
1440 } else if (status & AT91_UDP_RXRSM) { 1465 } else if (status & AT91_UDP_RXRSM) {
@@ -1451,8 +1476,11 @@ static irqreturn_t at91_udc_irq (int irq, void *_udc)
1451 * would normally want to switch out of slow clock 1476 * would normally want to switch out of slow clock
1452 * mode into normal mode. 1477 * mode into normal mode.
1453 */ 1478 */
1454 if (udc->driver && udc->driver->resume) 1479 if (udc->driver && udc->driver->resume) {
1480 spin_unlock(&udc->lock);
1455 udc->driver->resume(&udc->gadget); 1481 udc->driver->resume(&udc->gadget);
1482 spin_lock(&udc->lock);
1483 }
1456 1484
1457 /* endpoint IRQs are cleared by handling them */ 1485 /* endpoint IRQs are cleared by handling them */
1458 } else { 1486 } else {
@@ -1474,6 +1502,8 @@ static irqreturn_t at91_udc_irq (int irq, void *_udc)
1474 if (disable_clock) 1502 if (disable_clock)
1475 clk_off(udc); 1503 clk_off(udc);
1476 1504
1505 spin_unlock_irqrestore(&udc->lock, flags);
1506
1477 return IRQ_HANDLED; 1507 return IRQ_HANDLED;
1478} 1508}
1479 1509
@@ -1556,24 +1586,53 @@ static struct at91_udc controller = {
1556 /* ep6 and ep7 are also reserved (custom silicon might use them) */ 1586 /* ep6 and ep7 are also reserved (custom silicon might use them) */
1557}; 1587};
1558 1588
1589static void at91_vbus_update(struct at91_udc *udc, unsigned value)
1590{
1591 value ^= udc->board.vbus_active_low;
1592 if (value != udc->vbus)
1593 at91_vbus_session(&udc->gadget, value);
1594}
1595
1559static irqreturn_t at91_vbus_irq(int irq, void *_udc) 1596static irqreturn_t at91_vbus_irq(int irq, void *_udc)
1560{ 1597{
1561 struct at91_udc *udc = _udc; 1598 struct at91_udc *udc = _udc;
1562 unsigned value;
1563 1599
1564 /* vbus needs at least brief debouncing */ 1600 /* vbus needs at least brief debouncing */
1565 udelay(10); 1601 udelay(10);
1566 value = gpio_get_value(udc->board.vbus_pin); 1602 at91_vbus_update(udc, gpio_get_value(udc->board.vbus_pin));
1567 if (value != udc->vbus)
1568 at91_vbus_session(&udc->gadget, value);
1569 1603
1570 return IRQ_HANDLED; 1604 return IRQ_HANDLED;
1571} 1605}
1572 1606
1607static void at91_vbus_timer_work(struct work_struct *work)
1608{
1609 struct at91_udc *udc = container_of(work, struct at91_udc,
1610 vbus_timer_work);
1611
1612 at91_vbus_update(udc, gpio_get_value_cansleep(udc->board.vbus_pin));
1613
1614 if (!timer_pending(&udc->vbus_timer))
1615 mod_timer(&udc->vbus_timer, jiffies + VBUS_POLL_TIMEOUT);
1616}
1617
1618static void at91_vbus_timer(unsigned long data)
1619{
1620 struct at91_udc *udc = (struct at91_udc *)data;
1621
1622 /*
1623 * If we are polling vbus it is likely that the gpio is on an
1624 * bus such as i2c or spi which may sleep, so schedule some work
1625 * to read the vbus gpio
1626 */
1627 if (!work_pending(&udc->vbus_timer_work))
1628 schedule_work(&udc->vbus_timer_work);
1629}
1630
1573int usb_gadget_register_driver (struct usb_gadget_driver *driver) 1631int usb_gadget_register_driver (struct usb_gadget_driver *driver)
1574{ 1632{
1575 struct at91_udc *udc = &controller; 1633 struct at91_udc *udc = &controller;
1576 int retval; 1634 int retval;
1635 unsigned long flags;
1577 1636
1578 if (!driver 1637 if (!driver
1579 || driver->speed < USB_SPEED_FULL 1638 || driver->speed < USB_SPEED_FULL
@@ -1605,9 +1664,9 @@ int usb_gadget_register_driver (struct usb_gadget_driver *driver)
1605 return retval; 1664 return retval;
1606 } 1665 }
1607 1666
1608 local_irq_disable(); 1667 spin_lock_irqsave(&udc->lock, flags);
1609 pullup(udc, 1); 1668 pullup(udc, 1);
1610 local_irq_enable(); 1669 spin_unlock_irqrestore(&udc->lock, flags);
1611 1670
1612 DBG("bound to %s\n", driver->driver.name); 1671 DBG("bound to %s\n", driver->driver.name);
1613 return 0; 1672 return 0;
@@ -1617,15 +1676,16 @@ EXPORT_SYMBOL (usb_gadget_register_driver);
1617int usb_gadget_unregister_driver (struct usb_gadget_driver *driver) 1676int usb_gadget_unregister_driver (struct usb_gadget_driver *driver)
1618{ 1677{
1619 struct at91_udc *udc = &controller; 1678 struct at91_udc *udc = &controller;
1679 unsigned long flags;
1620 1680
1621 if (!driver || driver != udc->driver || !driver->unbind) 1681 if (!driver || driver != udc->driver || !driver->unbind)
1622 return -EINVAL; 1682 return -EINVAL;
1623 1683
1624 local_irq_disable(); 1684 spin_lock_irqsave(&udc->lock, flags);
1625 udc->enabled = 0; 1685 udc->enabled = 0;
1626 at91_udp_write(udc, AT91_UDP_IDR, ~0); 1686 at91_udp_write(udc, AT91_UDP_IDR, ~0);
1627 pullup(udc, 0); 1687 pullup(udc, 0);
1628 local_irq_enable(); 1688 spin_unlock_irqrestore(&udc->lock, flags);
1629 1689
1630 driver->unbind(&udc->gadget); 1690 driver->unbind(&udc->gadget);
1631 udc->gadget.dev.driver = NULL; 1691 udc->gadget.dev.driver = NULL;
@@ -1641,8 +1701,13 @@ EXPORT_SYMBOL (usb_gadget_unregister_driver);
1641 1701
1642static void at91udc_shutdown(struct platform_device *dev) 1702static void at91udc_shutdown(struct platform_device *dev)
1643{ 1703{
1704 struct at91_udc *udc = platform_get_drvdata(dev);
1705 unsigned long flags;
1706
1644 /* force disconnect on reboot */ 1707 /* force disconnect on reboot */
1708 spin_lock_irqsave(&udc->lock, flags);
1645 pullup(platform_get_drvdata(dev), 0); 1709 pullup(platform_get_drvdata(dev), 0);
1710 spin_unlock_irqrestore(&udc->lock, flags);
1646} 1711}
1647 1712
1648static int __init at91udc_probe(struct platform_device *pdev) 1713static int __init at91udc_probe(struct platform_device *pdev)
@@ -1683,6 +1748,7 @@ static int __init at91udc_probe(struct platform_device *pdev)
1683 udc->board = *(struct at91_udc_data *) dev->platform_data; 1748 udc->board = *(struct at91_udc_data *) dev->platform_data;
1684 udc->pdev = pdev; 1749 udc->pdev = pdev;
1685 udc->enabled = 0; 1750 udc->enabled = 0;
1751 spin_lock_init(&udc->lock);
1686 1752
1687 /* rm9200 needs manual D+ pullup; off by default */ 1753 /* rm9200 needs manual D+ pullup; off by default */
1688 if (cpu_is_at91rm9200()) { 1754 if (cpu_is_at91rm9200()) {
@@ -1763,13 +1829,23 @@ static int __init at91udc_probe(struct platform_device *pdev)
1763 * Get the initial state of VBUS - we cannot expect 1829 * Get the initial state of VBUS - we cannot expect
1764 * a pending interrupt. 1830 * a pending interrupt.
1765 */ 1831 */
1766 udc->vbus = gpio_get_value(udc->board.vbus_pin); 1832 udc->vbus = gpio_get_value_cansleep(udc->board.vbus_pin) ^
1767 if (request_irq(udc->board.vbus_pin, at91_vbus_irq, 1833 udc->board.vbus_active_low;
1768 IRQF_DISABLED, driver_name, udc)) { 1834
1769 DBG("request vbus irq %d failed\n", 1835 if (udc->board.vbus_polled) {
1770 udc->board.vbus_pin); 1836 INIT_WORK(&udc->vbus_timer_work, at91_vbus_timer_work);
1771 retval = -EBUSY; 1837 setup_timer(&udc->vbus_timer, at91_vbus_timer,
1772 goto fail3; 1838 (unsigned long)udc);
1839 mod_timer(&udc->vbus_timer,
1840 jiffies + VBUS_POLL_TIMEOUT);
1841 } else {
1842 if (request_irq(udc->board.vbus_pin, at91_vbus_irq,
1843 IRQF_DISABLED, driver_name, udc)) {
1844 DBG("request vbus irq %d failed\n",
1845 udc->board.vbus_pin);
1846 retval = -EBUSY;
1847 goto fail3;
1848 }
1773 } 1849 }
1774 } else { 1850 } else {
1775 DBG("no VBUS detection, assuming always-on\n"); 1851 DBG("no VBUS detection, assuming always-on\n");
@@ -1804,13 +1880,16 @@ static int __exit at91udc_remove(struct platform_device *pdev)
1804{ 1880{
1805 struct at91_udc *udc = platform_get_drvdata(pdev); 1881 struct at91_udc *udc = platform_get_drvdata(pdev);
1806 struct resource *res; 1882 struct resource *res;
1883 unsigned long flags;
1807 1884
1808 DBG("remove\n"); 1885 DBG("remove\n");
1809 1886
1810 if (udc->driver) 1887 if (udc->driver)
1811 return -EBUSY; 1888 return -EBUSY;
1812 1889
1890 spin_lock_irqsave(&udc->lock, flags);
1813 pullup(udc, 0); 1891 pullup(udc, 0);
1892 spin_unlock_irqrestore(&udc->lock, flags);
1814 1893
1815 device_init_wakeup(&pdev->dev, 0); 1894 device_init_wakeup(&pdev->dev, 0);
1816 remove_debug_file(udc); 1895 remove_debug_file(udc);
@@ -1840,6 +1919,7 @@ static int at91udc_suspend(struct platform_device *pdev, pm_message_t mesg)
1840{ 1919{
1841 struct at91_udc *udc = platform_get_drvdata(pdev); 1920 struct at91_udc *udc = platform_get_drvdata(pdev);
1842 int wake = udc->driver && device_may_wakeup(&pdev->dev); 1921 int wake = udc->driver && device_may_wakeup(&pdev->dev);
1922 unsigned long flags;
1843 1923
1844 /* Unless we can act normally to the host (letting it wake us up 1924 /* Unless we can act normally to the host (letting it wake us up
1845 * whenever it has work for us) force disconnect. Wakeup requires 1925 * whenever it has work for us) force disconnect. Wakeup requires
@@ -1849,13 +1929,15 @@ static int at91udc_suspend(struct platform_device *pdev, pm_message_t mesg)
1849 if ((!udc->suspended && udc->addr) 1929 if ((!udc->suspended && udc->addr)
1850 || !wake 1930 || !wake
1851 || at91_suspend_entering_slow_clock()) { 1931 || at91_suspend_entering_slow_clock()) {
1932 spin_lock_irqsave(&udc->lock, flags);
1852 pullup(udc, 0); 1933 pullup(udc, 0);
1853 wake = 0; 1934 wake = 0;
1935 spin_unlock_irqrestore(&udc->lock, flags);
1854 } else 1936 } else
1855 enable_irq_wake(udc->udp_irq); 1937 enable_irq_wake(udc->udp_irq);
1856 1938
1857 udc->active_suspend = wake; 1939 udc->active_suspend = wake;
1858 if (udc->board.vbus_pin > 0 && wake) 1940 if (udc->board.vbus_pin > 0 && !udc->board.vbus_polled && wake)
1859 enable_irq_wake(udc->board.vbus_pin); 1941 enable_irq_wake(udc->board.vbus_pin);
1860 return 0; 1942 return 0;
1861} 1943}
@@ -1863,15 +1945,20 @@ static int at91udc_suspend(struct platform_device *pdev, pm_message_t mesg)
1863static int at91udc_resume(struct platform_device *pdev) 1945static int at91udc_resume(struct platform_device *pdev)
1864{ 1946{
1865 struct at91_udc *udc = platform_get_drvdata(pdev); 1947 struct at91_udc *udc = platform_get_drvdata(pdev);
1948 unsigned long flags;
1866 1949
1867 if (udc->board.vbus_pin > 0 && udc->active_suspend) 1950 if (udc->board.vbus_pin > 0 && !udc->board.vbus_polled &&
1951 udc->active_suspend)
1868 disable_irq_wake(udc->board.vbus_pin); 1952 disable_irq_wake(udc->board.vbus_pin);
1869 1953
1870 /* maybe reconnect to host; if so, clocks on */ 1954 /* maybe reconnect to host; if so, clocks on */
1871 if (udc->active_suspend) 1955 if (udc->active_suspend)
1872 disable_irq_wake(udc->udp_irq); 1956 disable_irq_wake(udc->udp_irq);
1873 else 1957 else {
1958 spin_lock_irqsave(&udc->lock, flags);
1874 pullup(udc, 1); 1959 pullup(udc, 1);
1960 spin_unlock_irqrestore(&udc->lock, flags);
1961 }
1875 return 0; 1962 return 0;
1876} 1963}
1877#else 1964#else
diff --git a/drivers/usb/gadget/at91_udc.h b/drivers/usb/gadget/at91_udc.h
index c65d62295890..108ca54f9092 100644
--- a/drivers/usb/gadget/at91_udc.h
+++ b/drivers/usb/gadget/at91_udc.h
@@ -144,6 +144,9 @@ struct at91_udc {
144 struct proc_dir_entry *pde; 144 struct proc_dir_entry *pde;
145 void __iomem *udp_baseaddr; 145 void __iomem *udp_baseaddr;
146 int udp_irq; 146 int udp_irq;
147 spinlock_t lock;
148 struct timer_list vbus_timer;
149 struct work_struct vbus_timer_work;
147}; 150};
148 151
149static inline struct at91_udc *to_udc(struct usb_gadget *g) 152static inline struct at91_udc *to_udc(struct usb_gadget *g)
diff --git a/drivers/usb/gadget/f_eem.c b/drivers/usb/gadget/f_eem.c
index 38226e9a371d..95dd4662d6a8 100644
--- a/drivers/usb/gadget/f_eem.c
+++ b/drivers/usb/gadget/f_eem.c
@@ -469,8 +469,7 @@ static int eem_unwrap(struct gether *port,
469 crc = get_unaligned_le32(skb->data + len 469 crc = get_unaligned_le32(skb->data + len
470 - ETH_FCS_LEN); 470 - ETH_FCS_LEN);
471 crc2 = ~crc32_le(~0, 471 crc2 = ~crc32_le(~0,
472 skb->data, 472 skb->data, len - ETH_FCS_LEN);
473 skb->len - ETH_FCS_LEN);
474 } else { 473 } else {
475 crc = get_unaligned_be32(skb->data + len 474 crc = get_unaligned_be32(skb->data + len
476 - ETH_FCS_LEN); 475 - ETH_FCS_LEN);
diff --git a/drivers/usb/gadget/f_fs.c b/drivers/usb/gadget/f_fs.c
index d69eccf5f197..2aaa0f75c6cf 100644
--- a/drivers/usb/gadget/f_fs.c
+++ b/drivers/usb/gadget/f_fs.c
@@ -136,7 +136,7 @@ struct ffs_data {
136 * handling setup requests immidiatelly user space may be so 136 * handling setup requests immidiatelly user space may be so
137 * slow that another setup will be sent to the gadget but this 137 * slow that another setup will be sent to the gadget but this
138 * time not to us but another function and then there could be 138 * time not to us but another function and then there could be
139 * a race. Is taht the case? Or maybe we can use cdev->req 139 * a race. Is that the case? Or maybe we can use cdev->req
140 * after all, maybe we just need some spinlock for that? */ 140 * after all, maybe we just need some spinlock for that? */
141 struct usb_request *ep0req; /* P: mutex */ 141 struct usb_request *ep0req; /* P: mutex */
142 struct completion ep0req_completion; /* P: mutex */ 142 struct completion ep0req_completion; /* P: mutex */
diff --git a/drivers/usb/gadget/f_mass_storage.c b/drivers/usb/gadget/f_mass_storage.c
index 7d05a0be5c60..4ce899c9b165 100644
--- a/drivers/usb/gadget/f_mass_storage.c
+++ b/drivers/usb/gadget/f_mass_storage.c
@@ -321,8 +321,8 @@ struct fsg_dev;
321/* Data shared by all the FSG instances. */ 321/* Data shared by all the FSG instances. */
322struct fsg_common { 322struct fsg_common {
323 struct usb_gadget *gadget; 323 struct usb_gadget *gadget;
324 struct fsg_dev *fsg; 324 struct fsg_dev *fsg, *new_fsg;
325 struct fsg_dev *prev_fsg; 325 wait_queue_head_t fsg_wait;
326 326
327 /* filesem protects: backing files in use */ 327 /* filesem protects: backing files in use */
328 struct rw_semaphore filesem; 328 struct rw_semaphore filesem;
@@ -351,7 +351,6 @@ struct fsg_common {
351 enum fsg_state state; /* For exception handling */ 351 enum fsg_state state; /* For exception handling */
352 unsigned int exception_req_tag; 352 unsigned int exception_req_tag;
353 353
354 u8 config, new_config;
355 enum data_direction data_dir; 354 enum data_direction data_dir;
356 u32 data_size; 355 u32 data_size;
357 u32 data_size_from_cmnd; 356 u32 data_size_from_cmnd;
@@ -595,7 +594,7 @@ static int fsg_setup(struct usb_function *f,
595 u16 w_value = le16_to_cpu(ctrl->wValue); 594 u16 w_value = le16_to_cpu(ctrl->wValue);
596 u16 w_length = le16_to_cpu(ctrl->wLength); 595 u16 w_length = le16_to_cpu(ctrl->wLength);
597 596
598 if (!fsg->common->config) 597 if (!fsg_is_set(fsg->common))
599 return -EOPNOTSUPP; 598 return -EOPNOTSUPP;
600 599
601 switch (ctrl->bRequest) { 600 switch (ctrl->bRequest) {
@@ -2303,24 +2302,20 @@ static int alloc_request(struct fsg_common *common, struct usb_ep *ep,
2303 return -ENOMEM; 2302 return -ENOMEM;
2304} 2303}
2305 2304
2306/* 2305/* Reset interface setting and re-init endpoint state (toggle etc). */
2307 * Reset interface setting and re-init endpoint state (toggle etc). 2306static int do_set_interface(struct fsg_common *common, struct fsg_dev *new_fsg)
2308 * Call with altsetting < 0 to disable the interface. The only other
2309 * available altsetting is 0, which enables the interface.
2310 */
2311static int do_set_interface(struct fsg_common *common, int altsetting)
2312{ 2307{
2313 int rc = 0; 2308 const struct usb_endpoint_descriptor *d;
2314 int i; 2309 struct fsg_dev *fsg;
2315 const struct usb_endpoint_descriptor *d; 2310 int i, rc = 0;
2316 2311
2317 if (common->running) 2312 if (common->running)
2318 DBG(common, "reset interface\n"); 2313 DBG(common, "reset interface\n");
2319 2314
2320reset: 2315reset:
2321 /* Deallocate the requests */ 2316 /* Deallocate the requests */
2322 if (common->prev_fsg) { 2317 if (common->fsg) {
2323 struct fsg_dev *fsg = common->prev_fsg; 2318 fsg = common->fsg;
2324 2319
2325 for (i = 0; i < FSG_NUM_BUFFERS; ++i) { 2320 for (i = 0; i < FSG_NUM_BUFFERS; ++i) {
2326 struct fsg_buffhd *bh = &common->buffhds[i]; 2321 struct fsg_buffhd *bh = &common->buffhds[i];
@@ -2345,88 +2340,53 @@ reset:
2345 fsg->bulk_out_enabled = 0; 2340 fsg->bulk_out_enabled = 0;
2346 } 2341 }
2347 2342
2348 common->prev_fsg = 0; 2343 common->fsg = NULL;
2344 wake_up(&common->fsg_wait);
2349 } 2345 }
2350 2346
2351 common->running = 0; 2347 common->running = 0;
2352 if (altsetting < 0 || rc != 0) 2348 if (!new_fsg || rc)
2353 return rc; 2349 return rc;
2354 2350
2355 DBG(common, "set interface %d\n", altsetting); 2351 common->fsg = new_fsg;
2352 fsg = common->fsg;
2356 2353
2357 if (fsg_is_set(common)) { 2354 /* Enable the endpoints */
2358 struct fsg_dev *fsg = common->fsg; 2355 d = fsg_ep_desc(common->gadget,
2359 common->prev_fsg = common->fsg; 2356 &fsg_fs_bulk_in_desc, &fsg_hs_bulk_in_desc);
2357 rc = enable_endpoint(common, fsg->bulk_in, d);
2358 if (rc)
2359 goto reset;
2360 fsg->bulk_in_enabled = 1;
2361
2362 d = fsg_ep_desc(common->gadget,
2363 &fsg_fs_bulk_out_desc, &fsg_hs_bulk_out_desc);
2364 rc = enable_endpoint(common, fsg->bulk_out, d);
2365 if (rc)
2366 goto reset;
2367 fsg->bulk_out_enabled = 1;
2368 common->bulk_out_maxpacket = le16_to_cpu(d->wMaxPacketSize);
2369 clear_bit(IGNORE_BULK_OUT, &fsg->atomic_bitflags);
2360 2370
2361 /* Enable the endpoints */ 2371 /* Allocate the requests */
2362 d = fsg_ep_desc(common->gadget, 2372 for (i = 0; i < FSG_NUM_BUFFERS; ++i) {
2363 &fsg_fs_bulk_in_desc, &fsg_hs_bulk_in_desc); 2373 struct fsg_buffhd *bh = &common->buffhds[i];
2364 rc = enable_endpoint(common, fsg->bulk_in, d); 2374
2375 rc = alloc_request(common, fsg->bulk_in, &bh->inreq);
2365 if (rc) 2376 if (rc)
2366 goto reset; 2377 goto reset;
2367 fsg->bulk_in_enabled = 1; 2378 rc = alloc_request(common, fsg->bulk_out, &bh->outreq);
2368
2369 d = fsg_ep_desc(common->gadget,
2370 &fsg_fs_bulk_out_desc, &fsg_hs_bulk_out_desc);
2371 rc = enable_endpoint(common, fsg->bulk_out, d);
2372 if (rc) 2379 if (rc)
2373 goto reset; 2380 goto reset;
2374 fsg->bulk_out_enabled = 1; 2381 bh->inreq->buf = bh->outreq->buf = bh->buf;
2375 common->bulk_out_maxpacket = le16_to_cpu(d->wMaxPacketSize); 2382 bh->inreq->context = bh->outreq->context = bh;
2376 clear_bit(IGNORE_BULK_OUT, &fsg->atomic_bitflags); 2383 bh->inreq->complete = bulk_in_complete;
2377 2384 bh->outreq->complete = bulk_out_complete;
2378 /* Allocate the requests */
2379 for (i = 0; i < FSG_NUM_BUFFERS; ++i) {
2380 struct fsg_buffhd *bh = &common->buffhds[i];
2381
2382 rc = alloc_request(common, fsg->bulk_in, &bh->inreq);
2383 if (rc)
2384 goto reset;
2385 rc = alloc_request(common, fsg->bulk_out, &bh->outreq);
2386 if (rc)
2387 goto reset;
2388 bh->inreq->buf = bh->outreq->buf = bh->buf;
2389 bh->inreq->context = bh->outreq->context = bh;
2390 bh->inreq->complete = bulk_in_complete;
2391 bh->outreq->complete = bulk_out_complete;
2392 }
2393
2394 common->running = 1;
2395 for (i = 0; i < common->nluns; ++i)
2396 common->luns[i].unit_attention_data = SS_RESET_OCCURRED;
2397 return rc;
2398 } else {
2399 return -EIO;
2400 }
2401}
2402
2403
2404/*
2405 * Change our operational configuration. This code must agree with the code
2406 * that returns config descriptors, and with interface altsetting code.
2407 *
2408 * It's also responsible for power management interactions. Some
2409 * configurations might not work with our current power sources.
2410 * For now we just assume the gadget is always self-powered.
2411 */
2412static int do_set_config(struct fsg_common *common, u8 new_config)
2413{
2414 int rc = 0;
2415
2416 /* Disable the single interface */
2417 if (common->config != 0) {
2418 DBG(common, "reset config\n");
2419 common->config = 0;
2420 rc = do_set_interface(common, -1);
2421 } 2385 }
2422 2386
2423 /* Enable the interface */ 2387 common->running = 1;
2424 if (new_config != 0) { 2388 for (i = 0; i < common->nluns; ++i)
2425 common->config = new_config; 2389 common->luns[i].unit_attention_data = SS_RESET_OCCURRED;
2426 rc = do_set_interface(common, 0);
2427 if (rc != 0)
2428 common->config = 0; /* Reset on errors */
2429 }
2430 return rc; 2390 return rc;
2431} 2391}
2432 2392
@@ -2437,9 +2397,7 @@ static int do_set_config(struct fsg_common *common, u8 new_config)
2437static int fsg_set_alt(struct usb_function *f, unsigned intf, unsigned alt) 2397static int fsg_set_alt(struct usb_function *f, unsigned intf, unsigned alt)
2438{ 2398{
2439 struct fsg_dev *fsg = fsg_from_func(f); 2399 struct fsg_dev *fsg = fsg_from_func(f);
2440 fsg->common->prev_fsg = fsg->common->fsg; 2400 fsg->common->new_fsg = fsg;
2441 fsg->common->fsg = fsg;
2442 fsg->common->new_config = 1;
2443 raise_exception(fsg->common, FSG_STATE_CONFIG_CHANGE); 2401 raise_exception(fsg->common, FSG_STATE_CONFIG_CHANGE);
2444 return 0; 2402 return 0;
2445} 2403}
@@ -2447,9 +2405,7 @@ static int fsg_set_alt(struct usb_function *f, unsigned intf, unsigned alt)
2447static void fsg_disable(struct usb_function *f) 2405static void fsg_disable(struct usb_function *f)
2448{ 2406{
2449 struct fsg_dev *fsg = fsg_from_func(f); 2407 struct fsg_dev *fsg = fsg_from_func(f);
2450 fsg->common->prev_fsg = fsg->common->fsg; 2408 fsg->common->new_fsg = NULL;
2451 fsg->common->fsg = fsg;
2452 fsg->common->new_config = 0;
2453 raise_exception(fsg->common, FSG_STATE_CONFIG_CHANGE); 2409 raise_exception(fsg->common, FSG_STATE_CONFIG_CHANGE);
2454} 2410}
2455 2411
@@ -2459,19 +2415,17 @@ static void fsg_disable(struct usb_function *f)
2459static void handle_exception(struct fsg_common *common) 2415static void handle_exception(struct fsg_common *common)
2460{ 2416{
2461 siginfo_t info; 2417 siginfo_t info;
2462 int sig;
2463 int i; 2418 int i;
2464 struct fsg_buffhd *bh; 2419 struct fsg_buffhd *bh;
2465 enum fsg_state old_state; 2420 enum fsg_state old_state;
2466 u8 new_config;
2467 struct fsg_lun *curlun; 2421 struct fsg_lun *curlun;
2468 unsigned int exception_req_tag; 2422 unsigned int exception_req_tag;
2469 int rc;
2470 2423
2471 /* Clear the existing signals. Anything but SIGUSR1 is converted 2424 /* Clear the existing signals. Anything but SIGUSR1 is converted
2472 * into a high-priority EXIT exception. */ 2425 * into a high-priority EXIT exception. */
2473 for (;;) { 2426 for (;;) {
2474 sig = dequeue_signal_lock(current, &current->blocked, &info); 2427 int sig =
2428 dequeue_signal_lock(current, &current->blocked, &info);
2475 if (!sig) 2429 if (!sig)
2476 break; 2430 break;
2477 if (sig != SIGUSR1) { 2431 if (sig != SIGUSR1) {
@@ -2482,7 +2436,7 @@ static void handle_exception(struct fsg_common *common)
2482 } 2436 }
2483 2437
2484 /* Cancel all the pending transfers */ 2438 /* Cancel all the pending transfers */
2485 if (fsg_is_set(common)) { 2439 if (likely(common->fsg)) {
2486 for (i = 0; i < FSG_NUM_BUFFERS; ++i) { 2440 for (i = 0; i < FSG_NUM_BUFFERS; ++i) {
2487 bh = &common->buffhds[i]; 2441 bh = &common->buffhds[i];
2488 if (bh->inreq_busy) 2442 if (bh->inreq_busy)
@@ -2523,7 +2477,6 @@ static void handle_exception(struct fsg_common *common)
2523 common->next_buffhd_to_fill = &common->buffhds[0]; 2477 common->next_buffhd_to_fill = &common->buffhds[0];
2524 common->next_buffhd_to_drain = &common->buffhds[0]; 2478 common->next_buffhd_to_drain = &common->buffhds[0];
2525 exception_req_tag = common->exception_req_tag; 2479 exception_req_tag = common->exception_req_tag;
2526 new_config = common->new_config;
2527 old_state = common->state; 2480 old_state = common->state;
2528 2481
2529 if (old_state == FSG_STATE_ABORT_BULK_OUT) 2482 if (old_state == FSG_STATE_ABORT_BULK_OUT)
@@ -2573,12 +2526,12 @@ static void handle_exception(struct fsg_common *common)
2573 break; 2526 break;
2574 2527
2575 case FSG_STATE_CONFIG_CHANGE: 2528 case FSG_STATE_CONFIG_CHANGE:
2576 rc = do_set_config(common, new_config); 2529 do_set_interface(common, common->new_fsg);
2577 break; 2530 break;
2578 2531
2579 case FSG_STATE_EXIT: 2532 case FSG_STATE_EXIT:
2580 case FSG_STATE_TERMINATED: 2533 case FSG_STATE_TERMINATED:
2581 do_set_config(common, 0); /* Free resources */ 2534 do_set_interface(common, NULL); /* Free resources */
2582 spin_lock_irq(&common->lock); 2535 spin_lock_irq(&common->lock);
2583 common->state = FSG_STATE_TERMINATED; /* Stop the thread */ 2536 common->state = FSG_STATE_TERMINATED; /* Stop the thread */
2584 spin_unlock_irq(&common->lock); 2537 spin_unlock_irq(&common->lock);
@@ -2863,6 +2816,7 @@ buffhds_first_it:
2863 goto error_release; 2816 goto error_release;
2864 } 2817 }
2865 init_completion(&common->thread_notifier); 2818 init_completion(&common->thread_notifier);
2819 init_waitqueue_head(&common->fsg_wait);
2866#undef OR 2820#undef OR
2867 2821
2868 2822
@@ -2957,9 +2911,17 @@ static void fsg_common_release(struct kref *ref)
2957static void fsg_unbind(struct usb_configuration *c, struct usb_function *f) 2911static void fsg_unbind(struct usb_configuration *c, struct usb_function *f)
2958{ 2912{
2959 struct fsg_dev *fsg = fsg_from_func(f); 2913 struct fsg_dev *fsg = fsg_from_func(f);
2914 struct fsg_common *common = fsg->common;
2960 2915
2961 DBG(fsg, "unbind\n"); 2916 DBG(fsg, "unbind\n");
2962 fsg_common_put(fsg->common); 2917 if (fsg->common->fsg == fsg) {
2918 fsg->common->new_fsg = NULL;
2919 raise_exception(fsg->common, FSG_STATE_CONFIG_CHANGE);
2920 /* FIXME: make interruptible or killable somehow? */
2921 wait_event(common->fsg_wait, common->fsg != fsg);
2922 }
2923
2924 fsg_common_put(common);
2963 usb_free_descriptors(fsg->function.descriptors); 2925 usb_free_descriptors(fsg->function.descriptors);
2964 usb_free_descriptors(fsg->function.hs_descriptors); 2926 usb_free_descriptors(fsg->function.hs_descriptors);
2965 kfree(fsg); 2927 kfree(fsg);
@@ -2970,7 +2932,6 @@ static int fsg_bind(struct usb_configuration *c, struct usb_function *f)
2970{ 2932{
2971 struct fsg_dev *fsg = fsg_from_func(f); 2933 struct fsg_dev *fsg = fsg_from_func(f);
2972 struct usb_gadget *gadget = c->cdev->gadget; 2934 struct usb_gadget *gadget = c->cdev->gadget;
2973 int rc;
2974 int i; 2935 int i;
2975 struct usb_ep *ep; 2936 struct usb_ep *ep;
2976 2937
@@ -2996,6 +2957,11 @@ static int fsg_bind(struct usb_configuration *c, struct usb_function *f)
2996 ep->driver_data = fsg->common; /* claim the endpoint */ 2957 ep->driver_data = fsg->common; /* claim the endpoint */
2997 fsg->bulk_out = ep; 2958 fsg->bulk_out = ep;
2998 2959
2960 /* Copy descriptors */
2961 f->descriptors = usb_copy_descriptors(fsg_fs_function);
2962 if (unlikely(!f->descriptors))
2963 return -ENOMEM;
2964
2999 if (gadget_is_dualspeed(gadget)) { 2965 if (gadget_is_dualspeed(gadget)) {
3000 /* Assume endpoint addresses are the same for both speeds */ 2966 /* Assume endpoint addresses are the same for both speeds */
3001 fsg_hs_bulk_in_desc.bEndpointAddress = 2967 fsg_hs_bulk_in_desc.bEndpointAddress =
@@ -3003,16 +2969,17 @@ static int fsg_bind(struct usb_configuration *c, struct usb_function *f)
3003 fsg_hs_bulk_out_desc.bEndpointAddress = 2969 fsg_hs_bulk_out_desc.bEndpointAddress =
3004 fsg_fs_bulk_out_desc.bEndpointAddress; 2970 fsg_fs_bulk_out_desc.bEndpointAddress;
3005 f->hs_descriptors = usb_copy_descriptors(fsg_hs_function); 2971 f->hs_descriptors = usb_copy_descriptors(fsg_hs_function);
3006 if (unlikely(!f->hs_descriptors)) 2972 if (unlikely(!f->hs_descriptors)) {
2973 usb_free_descriptors(f->descriptors);
3007 return -ENOMEM; 2974 return -ENOMEM;
2975 }
3008 } 2976 }
3009 2977
3010 return 0; 2978 return 0;
3011 2979
3012autoconf_fail: 2980autoconf_fail:
3013 ERROR(fsg, "unable to autoconfigure all endpoints\n"); 2981 ERROR(fsg, "unable to autoconfigure all endpoints\n");
3014 rc = -ENOTSUPP; 2982 return -ENOTSUPP;
3015 return rc;
3016} 2983}
3017 2984
3018 2985
@@ -3036,11 +3003,6 @@ static int fsg_add(struct usb_composite_dev *cdev,
3036 3003
3037 fsg->function.name = FSG_DRIVER_DESC; 3004 fsg->function.name = FSG_DRIVER_DESC;
3038 fsg->function.strings = fsg_strings_array; 3005 fsg->function.strings = fsg_strings_array;
3039 fsg->function.descriptors = usb_copy_descriptors(fsg_fs_function);
3040 if (unlikely(!fsg->function.descriptors)) {
3041 rc = -ENOMEM;
3042 goto error_free_fsg;
3043 }
3044 fsg->function.bind = fsg_bind; 3006 fsg->function.bind = fsg_bind;
3045 fsg->function.unbind = fsg_unbind; 3007 fsg->function.unbind = fsg_unbind;
3046 fsg->function.setup = fsg_setup; 3008 fsg->function.setup = fsg_setup;
@@ -3056,19 +3018,9 @@ static int fsg_add(struct usb_composite_dev *cdev,
3056 3018
3057 rc = usb_add_function(c, &fsg->function); 3019 rc = usb_add_function(c, &fsg->function);
3058 if (unlikely(rc)) 3020 if (unlikely(rc))
3059 goto error_free_all; 3021 kfree(fsg);
3060 3022 else
3061 fsg_common_get(fsg->common); 3023 fsg_common_get(fsg->common);
3062 return 0;
3063
3064error_free_all:
3065 usb_free_descriptors(fsg->function.descriptors);
3066 /* fsg_bind() might have copied those; or maybe not? who cares
3067 * -- free it just in case. */
3068 usb_free_descriptors(fsg->function.hs_descriptors);
3069error_free_fsg:
3070 kfree(fsg);
3071
3072 return rc; 3024 return rc;
3073} 3025}
3074 3026
diff --git a/drivers/usb/gadget/f_uvc.c b/drivers/usb/gadget/f_uvc.c
index fc2611f8b326..dbe6db0184fd 100644
--- a/drivers/usb/gadget/f_uvc.c
+++ b/drivers/usb/gadget/f_uvc.c
@@ -28,7 +28,7 @@
28 28
29#include "uvc.h" 29#include "uvc.h"
30 30
31unsigned int uvc_trace_param; 31unsigned int uvc_gadget_trace_param;
32 32
33/* -------------------------------------------------------------------------- 33/* --------------------------------------------------------------------------
34 * Function descriptors 34 * Function descriptors
@@ -656,6 +656,6 @@ error:
656 return ret; 656 return ret;
657} 657}
658 658
659module_param_named(trace, uvc_trace_param, uint, S_IRUGO|S_IWUSR); 659module_param_named(trace, uvc_gadget_trace_param, uint, S_IRUGO|S_IWUSR);
660MODULE_PARM_DESC(trace, "Trace level bitmask"); 660MODULE_PARM_DESC(trace, "Trace level bitmask");
661 661
diff --git a/drivers/usb/gadget/fsl_mxc_udc.c b/drivers/usb/gadget/fsl_mxc_udc.c
index d0b8bde59e59..eafa6d2c5ed7 100644
--- a/drivers/usb/gadget/fsl_mxc_udc.c
+++ b/drivers/usb/gadget/fsl_mxc_udc.c
@@ -30,7 +30,7 @@ int fsl_udc_clk_init(struct platform_device *pdev)
30 30
31 pdata = pdev->dev.platform_data; 31 pdata = pdev->dev.platform_data;
32 32
33 if (!cpu_is_mx35()) { 33 if (!cpu_is_mx35() && !cpu_is_mx25()) {
34 mxc_ahb_clk = clk_get(&pdev->dev, "usb_ahb"); 34 mxc_ahb_clk = clk_get(&pdev->dev, "usb_ahb");
35 if (IS_ERR(mxc_ahb_clk)) 35 if (IS_ERR(mxc_ahb_clk))
36 return PTR_ERR(mxc_ahb_clk); 36 return PTR_ERR(mxc_ahb_clk);
diff --git a/drivers/usb/gadget/g_ffs.c b/drivers/usb/gadget/g_ffs.c
index 4b0e4a040d6f..d1af253a9105 100644
--- a/drivers/usb/gadget/g_ffs.c
+++ b/drivers/usb/gadget/g_ffs.c
@@ -392,6 +392,17 @@ static int __gfs_do_config(struct usb_configuration *c,
392 if (unlikely(ret < 0)) 392 if (unlikely(ret < 0))
393 return ret; 393 return ret;
394 394
395 /* After previous do_configs there may be some invalid
396 * pointers in c->interface array. This happens every time
397 * a user space function with fewer interfaces than a user
398 * space function that was run before the new one is run. The
399 * compasit's set_config() assumes that if there is no more
400 * then MAX_CONFIG_INTERFACES interfaces in a configuration
401 * then there is a NULL pointer after the last interface in
402 * c->interface array. We need to make sure this is true. */
403 if (c->next_interface_id < ARRAY_SIZE(c->interface))
404 c->interface[c->next_interface_id] = NULL;
405
395 return 0; 406 return 0;
396} 407}
397 408
diff --git a/drivers/usb/gadget/printer.c b/drivers/usb/gadget/printer.c
index 43abf55d8c60..4c3ac5c42237 100644
--- a/drivers/usb/gadget/printer.c
+++ b/drivers/usb/gadget/printer.c
@@ -82,7 +82,7 @@ static struct class *usb_gadget_class;
82struct printer_dev { 82struct printer_dev {
83 spinlock_t lock; /* lock this structure */ 83 spinlock_t lock; /* lock this structure */
84 /* lock buffer lists during read/write calls */ 84 /* lock buffer lists during read/write calls */
85 spinlock_t lock_printer_io; 85 struct mutex lock_printer_io;
86 struct usb_gadget *gadget; 86 struct usb_gadget *gadget;
87 struct usb_request *req; /* for control responses */ 87 struct usb_request *req; /* for control responses */
88 u8 config; 88 u8 config;
@@ -567,7 +567,7 @@ printer_read(struct file *fd, char __user *buf, size_t len, loff_t *ptr)
567 567
568 DBG(dev, "printer_read trying to read %d bytes\n", (int)len); 568 DBG(dev, "printer_read trying to read %d bytes\n", (int)len);
569 569
570 spin_lock(&dev->lock_printer_io); 570 mutex_lock(&dev->lock_printer_io);
571 spin_lock_irqsave(&dev->lock, flags); 571 spin_lock_irqsave(&dev->lock, flags);
572 572
573 /* We will use this flag later to check if a printer reset happened 573 /* We will use this flag later to check if a printer reset happened
@@ -601,7 +601,7 @@ printer_read(struct file *fd, char __user *buf, size_t len, loff_t *ptr)
601 * call or not. 601 * call or not.
602 */ 602 */
603 if (fd->f_flags & (O_NONBLOCK|O_NDELAY)) { 603 if (fd->f_flags & (O_NONBLOCK|O_NDELAY)) {
604 spin_unlock(&dev->lock_printer_io); 604 mutex_unlock(&dev->lock_printer_io);
605 return -EAGAIN; 605 return -EAGAIN;
606 } 606 }
607 607
@@ -648,7 +648,7 @@ printer_read(struct file *fd, char __user *buf, size_t len, loff_t *ptr)
648 if (dev->reset_printer) { 648 if (dev->reset_printer) {
649 list_add(&current_rx_req->list, &dev->rx_reqs); 649 list_add(&current_rx_req->list, &dev->rx_reqs);
650 spin_unlock_irqrestore(&dev->lock, flags); 650 spin_unlock_irqrestore(&dev->lock, flags);
651 spin_unlock(&dev->lock_printer_io); 651 mutex_unlock(&dev->lock_printer_io);
652 return -EAGAIN; 652 return -EAGAIN;
653 } 653 }
654 654
@@ -673,7 +673,7 @@ printer_read(struct file *fd, char __user *buf, size_t len, loff_t *ptr)
673 dev->current_rx_buf = current_rx_buf; 673 dev->current_rx_buf = current_rx_buf;
674 674
675 spin_unlock_irqrestore(&dev->lock, flags); 675 spin_unlock_irqrestore(&dev->lock, flags);
676 spin_unlock(&dev->lock_printer_io); 676 mutex_unlock(&dev->lock_printer_io);
677 677
678 DBG(dev, "printer_read returned %d bytes\n", (int)bytes_copied); 678 DBG(dev, "printer_read returned %d bytes\n", (int)bytes_copied);
679 679
@@ -697,7 +697,7 @@ printer_write(struct file *fd, const char __user *buf, size_t len, loff_t *ptr)
697 if (len == 0) 697 if (len == 0)
698 return -EINVAL; 698 return -EINVAL;
699 699
700 spin_lock(&dev->lock_printer_io); 700 mutex_lock(&dev->lock_printer_io);
701 spin_lock_irqsave(&dev->lock, flags); 701 spin_lock_irqsave(&dev->lock, flags);
702 702
703 /* Check if a printer reset happens while we have interrupts on */ 703 /* Check if a printer reset happens while we have interrupts on */
@@ -713,7 +713,7 @@ printer_write(struct file *fd, const char __user *buf, size_t len, loff_t *ptr)
713 * a NON-Blocking call or not. 713 * a NON-Blocking call or not.
714 */ 714 */
715 if (fd->f_flags & (O_NONBLOCK|O_NDELAY)) { 715 if (fd->f_flags & (O_NONBLOCK|O_NDELAY)) {
716 spin_unlock(&dev->lock_printer_io); 716 mutex_unlock(&dev->lock_printer_io);
717 return -EAGAIN; 717 return -EAGAIN;
718 } 718 }
719 719
@@ -752,7 +752,7 @@ printer_write(struct file *fd, const char __user *buf, size_t len, loff_t *ptr)
752 752
753 if (copy_from_user(req->buf, buf, size)) { 753 if (copy_from_user(req->buf, buf, size)) {
754 list_add(&req->list, &dev->tx_reqs); 754 list_add(&req->list, &dev->tx_reqs);
755 spin_unlock(&dev->lock_printer_io); 755 mutex_unlock(&dev->lock_printer_io);
756 return bytes_copied; 756 return bytes_copied;
757 } 757 }
758 758
@@ -766,14 +766,14 @@ printer_write(struct file *fd, const char __user *buf, size_t len, loff_t *ptr)
766 if (dev->reset_printer) { 766 if (dev->reset_printer) {
767 list_add(&req->list, &dev->tx_reqs); 767 list_add(&req->list, &dev->tx_reqs);
768 spin_unlock_irqrestore(&dev->lock, flags); 768 spin_unlock_irqrestore(&dev->lock, flags);
769 spin_unlock(&dev->lock_printer_io); 769 mutex_unlock(&dev->lock_printer_io);
770 return -EAGAIN; 770 return -EAGAIN;
771 } 771 }
772 772
773 if (usb_ep_queue(dev->in_ep, req, GFP_ATOMIC)) { 773 if (usb_ep_queue(dev->in_ep, req, GFP_ATOMIC)) {
774 list_add(&req->list, &dev->tx_reqs); 774 list_add(&req->list, &dev->tx_reqs);
775 spin_unlock_irqrestore(&dev->lock, flags); 775 spin_unlock_irqrestore(&dev->lock, flags);
776 spin_unlock(&dev->lock_printer_io); 776 mutex_unlock(&dev->lock_printer_io);
777 return -EAGAIN; 777 return -EAGAIN;
778 } 778 }
779 779
@@ -782,7 +782,7 @@ printer_write(struct file *fd, const char __user *buf, size_t len, loff_t *ptr)
782 } 782 }
783 783
784 spin_unlock_irqrestore(&dev->lock, flags); 784 spin_unlock_irqrestore(&dev->lock, flags);
785 spin_unlock(&dev->lock_printer_io); 785 mutex_unlock(&dev->lock_printer_io);
786 786
787 DBG(dev, "printer_write sent %d bytes\n", (int)bytes_copied); 787 DBG(dev, "printer_write sent %d bytes\n", (int)bytes_copied);
788 788
@@ -820,11 +820,11 @@ printer_poll(struct file *fd, poll_table *wait)
820 unsigned long flags; 820 unsigned long flags;
821 int status = 0; 821 int status = 0;
822 822
823 spin_lock(&dev->lock_printer_io); 823 mutex_lock(&dev->lock_printer_io);
824 spin_lock_irqsave(&dev->lock, flags); 824 spin_lock_irqsave(&dev->lock, flags);
825 setup_rx_reqs(dev); 825 setup_rx_reqs(dev);
826 spin_unlock_irqrestore(&dev->lock, flags); 826 spin_unlock_irqrestore(&dev->lock, flags);
827 spin_unlock(&dev->lock_printer_io); 827 mutex_unlock(&dev->lock_printer_io);
828 828
829 poll_wait(fd, &dev->rx_wait, wait); 829 poll_wait(fd, &dev->rx_wait, wait);
830 poll_wait(fd, &dev->tx_wait, wait); 830 poll_wait(fd, &dev->tx_wait, wait);
@@ -1461,7 +1461,7 @@ autoconf_fail:
1461 } 1461 }
1462 1462
1463 spin_lock_init(&dev->lock); 1463 spin_lock_init(&dev->lock);
1464 spin_lock_init(&dev->lock_printer_io); 1464 mutex_init(&dev->lock_printer_io);
1465 INIT_LIST_HEAD(&dev->tx_reqs); 1465 INIT_LIST_HEAD(&dev->tx_reqs);
1466 INIT_LIST_HEAD(&dev->tx_reqs_active); 1466 INIT_LIST_HEAD(&dev->tx_reqs_active);
1467 INIT_LIST_HEAD(&dev->rx_reqs); 1467 INIT_LIST_HEAD(&dev->rx_reqs);
@@ -1594,7 +1594,7 @@ cleanup(void)
1594{ 1594{
1595 int status; 1595 int status;
1596 1596
1597 spin_lock(&usb_printer_gadget.lock_printer_io); 1597 mutex_lock(&usb_printer_gadget.lock_printer_io);
1598 class_destroy(usb_gadget_class); 1598 class_destroy(usb_gadget_class);
1599 unregister_chrdev_region(g_printer_devno, 2); 1599 unregister_chrdev_region(g_printer_devno, 2);
1600 1600
@@ -1602,6 +1602,6 @@ cleanup(void)
1602 if (status) 1602 if (status)
1603 ERROR(dev, "usb_gadget_unregister_driver %x\n", status); 1603 ERROR(dev, "usb_gadget_unregister_driver %x\n", status);
1604 1604
1605 spin_unlock(&usb_printer_gadget.lock_printer_io); 1605 mutex_unlock(&usb_printer_gadget.lock_printer_io);
1606} 1606}
1607module_exit(cleanup); 1607module_exit(cleanup);
diff --git a/drivers/usb/gadget/pxa27x_udc.c b/drivers/usb/gadget/pxa27x_udc.c
index 85b0d8921eae..980762453a9c 100644
--- a/drivers/usb/gadget/pxa27x_udc.c
+++ b/drivers/usb/gadget/pxa27x_udc.c
@@ -2561,7 +2561,7 @@ static void pxa_udc_shutdown(struct platform_device *_dev)
2561 udc_disable(udc); 2561 udc_disable(udc);
2562} 2562}
2563 2563
2564#ifdef CONFIG_CPU_PXA27x 2564#ifdef CONFIG_PXA27x
2565extern void pxa27x_clear_otgph(void); 2565extern void pxa27x_clear_otgph(void);
2566#else 2566#else
2567#define pxa27x_clear_otgph() do {} while (0) 2567#define pxa27x_clear_otgph() do {} while (0)
diff --git a/drivers/usb/gadget/s3c2410_udc.c b/drivers/usb/gadget/s3c2410_udc.c
index d5f4c1d45c97..ea2b3c7ebee5 100644
--- a/drivers/usb/gadget/s3c2410_udc.c
+++ b/drivers/usb/gadget/s3c2410_udc.c
@@ -735,6 +735,10 @@ static void s3c2410_udc_handle_ep0_idle(struct s3c2410_udc *dev,
735 else 735 else
736 dev->ep0state = EP0_OUT_DATA_PHASE; 736 dev->ep0state = EP0_OUT_DATA_PHASE;
737 737
738 if (!dev->driver)
739 return;
740
741 /* deliver the request to the gadget driver */
738 ret = dev->driver->setup(&dev->gadget, crq); 742 ret = dev->driver->setup(&dev->gadget, crq);
739 if (ret < 0) { 743 if (ret < 0) {
740 if (dev->req_config) { 744 if (dev->req_config) {
@@ -1700,9 +1704,13 @@ int usb_gadget_unregister_driver(struct usb_gadget_driver *driver)
1700 if (!driver || driver != udc->driver || !driver->unbind) 1704 if (!driver || driver != udc->driver || !driver->unbind)
1701 return -EINVAL; 1705 return -EINVAL;
1702 1706
1703 dprintk(DEBUG_NORMAL,"usb_gadget_register_driver() '%s'\n", 1707 dprintk(DEBUG_NORMAL, "usb_gadget_unregister_driver() '%s'\n",
1704 driver->driver.name); 1708 driver->driver.name);
1705 1709
1710 /* report disconnect */
1711 if (driver->disconnect)
1712 driver->disconnect(&udc->gadget);
1713
1706 driver->unbind(&udc->gadget); 1714 driver->unbind(&udc->gadget);
1707 1715
1708 device_del(&udc->gadget.dev); 1716 device_del(&udc->gadget.dev);
diff --git a/drivers/usb/gadget/u_serial.c b/drivers/usb/gadget/u_serial.c
index 16bdf77f582a..3e8dcb5455e3 100644
--- a/drivers/usb/gadget/u_serial.c
+++ b/drivers/usb/gadget/u_serial.c
@@ -536,17 +536,11 @@ recycle:
536 list_move(&req->list, &port->read_pool); 536 list_move(&req->list, &port->read_pool);
537 } 537 }
538 538
539 /* Push from tty to ldisc; this is immediate with low_latency, and 539 /* Push from tty to ldisc; without low_latency set this is handled by
540 * may trigger callbacks to this driver ... so drop the spinlock. 540 * a workqueue, so we won't get callbacks and can hold port_lock
541 */ 541 */
542 if (tty && do_push) { 542 if (tty && do_push) {
543 spin_unlock_irq(&port->port_lock);
544 tty_flip_buffer_push(tty); 543 tty_flip_buffer_push(tty);
545 wake_up_interruptible(&tty->read_wait);
546 spin_lock_irq(&port->port_lock);
547
548 /* tty may have been closed */
549 tty = port->port_tty;
550 } 544 }
551 545
552 546
@@ -784,11 +778,6 @@ static int gs_open(struct tty_struct *tty, struct file *file)
784 port->open_count = 1; 778 port->open_count = 1;
785 port->openclose = false; 779 port->openclose = false;
786 780
787 /* low_latency means ldiscs work in tasklet context, without
788 * needing a workqueue schedule ... easier to keep up.
789 */
790 tty->low_latency = 1;
791
792 /* if connected, start the I/O stream */ 781 /* if connected, start the I/O stream */
793 if (port->port_usb) { 782 if (port->port_usb) {
794 struct gserial *gser = port->port_usb; 783 struct gserial *gser = port->port_usb;
@@ -1195,6 +1184,7 @@ void gserial_cleanup(void)
1195 n_ports = 0; 1184 n_ports = 0;
1196 1185
1197 tty_unregister_driver(gs_tty_driver); 1186 tty_unregister_driver(gs_tty_driver);
1187 put_tty_driver(gs_tty_driver);
1198 gs_tty_driver = NULL; 1188 gs_tty_driver = NULL;
1199 1189
1200 pr_debug("%s: cleaned up ttyGS* support\n", __func__); 1190 pr_debug("%s: cleaned up ttyGS* support\n", __func__);
diff --git a/drivers/usb/gadget/uvc.h b/drivers/usb/gadget/uvc.h
index 0a705e63c936..e92454cddd7d 100644
--- a/drivers/usb/gadget/uvc.h
+++ b/drivers/usb/gadget/uvc.h
@@ -107,11 +107,11 @@ struct uvc_streaming_control {
107#define UVC_WARN_MINMAX 0 107#define UVC_WARN_MINMAX 0
108#define UVC_WARN_PROBE_DEF 1 108#define UVC_WARN_PROBE_DEF 1
109 109
110extern unsigned int uvc_trace_param; 110extern unsigned int uvc_gadget_trace_param;
111 111
112#define uvc_trace(flag, msg...) \ 112#define uvc_trace(flag, msg...) \
113 do { \ 113 do { \
114 if (uvc_trace_param & flag) \ 114 if (uvc_gadget_trace_param & flag) \
115 printk(KERN_DEBUG "uvcvideo: " msg); \ 115 printk(KERN_DEBUG "uvcvideo: " msg); \
116 } while (0) 116 } while (0)
117 117
@@ -220,16 +220,10 @@ struct uvc_file_handle
220#define to_uvc_file_handle(handle) \ 220#define to_uvc_file_handle(handle) \
221 container_of(handle, struct uvc_file_handle, vfh) 221 container_of(handle, struct uvc_file_handle, vfh)
222 222
223extern struct v4l2_file_operations uvc_v4l2_fops;
224
225/* ------------------------------------------------------------------------ 223/* ------------------------------------------------------------------------
226 * Functions 224 * Functions
227 */ 225 */
228 226
229extern int uvc_video_enable(struct uvc_video *video, int enable);
230extern int uvc_video_init(struct uvc_video *video);
231extern int uvc_video_pump(struct uvc_video *video);
232
233extern void uvc_endpoint_stream(struct uvc_device *dev); 227extern void uvc_endpoint_stream(struct uvc_device *dev);
234 228
235extern void uvc_function_connect(struct uvc_device *uvc); 229extern void uvc_function_connect(struct uvc_device *uvc);
diff --git a/drivers/usb/gadget/uvc_queue.c b/drivers/usb/gadget/uvc_queue.c
index 43891991bf21..f7395ac5dc17 100644
--- a/drivers/usb/gadget/uvc_queue.c
+++ b/drivers/usb/gadget/uvc_queue.c
@@ -78,7 +78,8 @@
78 * 78 *
79 */ 79 */
80 80
81void uvc_queue_init(struct uvc_video_queue *queue, enum v4l2_buf_type type) 81static void
82uvc_queue_init(struct uvc_video_queue *queue, enum v4l2_buf_type type)
82{ 83{
83 mutex_init(&queue->mutex); 84 mutex_init(&queue->mutex);
84 spin_lock_init(&queue->irqlock); 85 spin_lock_init(&queue->irqlock);
@@ -88,6 +89,28 @@ void uvc_queue_init(struct uvc_video_queue *queue, enum v4l2_buf_type type)
88} 89}
89 90
90/* 91/*
92 * Free the video buffers.
93 *
94 * This function must be called with the queue lock held.
95 */
96static int uvc_free_buffers(struct uvc_video_queue *queue)
97{
98 unsigned int i;
99
100 for (i = 0; i < queue->count; ++i) {
101 if (queue->buffer[i].vma_use_count != 0)
102 return -EBUSY;
103 }
104
105 if (queue->count) {
106 vfree(queue->mem);
107 queue->count = 0;
108 }
109
110 return 0;
111}
112
113/*
91 * Allocate the video buffers. 114 * Allocate the video buffers.
92 * 115 *
93 * Pages are reserved to make sure they will not be swapped, as they will be 116 * Pages are reserved to make sure they will not be swapped, as they will be
@@ -95,8 +118,9 @@ void uvc_queue_init(struct uvc_video_queue *queue, enum v4l2_buf_type type)
95 * 118 *
96 * Buffers will be individually mapped, so they must all be page aligned. 119 * Buffers will be individually mapped, so they must all be page aligned.
97 */ 120 */
98int uvc_alloc_buffers(struct uvc_video_queue *queue, unsigned int nbuffers, 121static int
99 unsigned int buflength) 122uvc_alloc_buffers(struct uvc_video_queue *queue, unsigned int nbuffers,
123 unsigned int buflength)
100{ 124{
101 unsigned int bufsize = PAGE_ALIGN(buflength); 125 unsigned int bufsize = PAGE_ALIGN(buflength);
102 unsigned int i; 126 unsigned int i;
@@ -150,28 +174,6 @@ done:
150 return ret; 174 return ret;
151} 175}
152 176
153/*
154 * Free the video buffers.
155 *
156 * This function must be called with the queue lock held.
157 */
158int uvc_free_buffers(struct uvc_video_queue *queue)
159{
160 unsigned int i;
161
162 for (i = 0; i < queue->count; ++i) {
163 if (queue->buffer[i].vma_use_count != 0)
164 return -EBUSY;
165 }
166
167 if (queue->count) {
168 vfree(queue->mem);
169 queue->count = 0;
170 }
171
172 return 0;
173}
174
175static void __uvc_query_buffer(struct uvc_buffer *buf, 177static void __uvc_query_buffer(struct uvc_buffer *buf,
176 struct v4l2_buffer *v4l2_buf) 178 struct v4l2_buffer *v4l2_buf)
177{ 179{
@@ -195,8 +197,8 @@ static void __uvc_query_buffer(struct uvc_buffer *buf,
195 } 197 }
196} 198}
197 199
198int uvc_query_buffer(struct uvc_video_queue *queue, 200static int
199 struct v4l2_buffer *v4l2_buf) 201uvc_query_buffer(struct uvc_video_queue *queue, struct v4l2_buffer *v4l2_buf)
200{ 202{
201 int ret = 0; 203 int ret = 0;
202 204
@@ -217,8 +219,8 @@ done:
217 * Queue a video buffer. Attempting to queue a buffer that has already been 219 * Queue a video buffer. Attempting to queue a buffer that has already been
218 * queued will return -EINVAL. 220 * queued will return -EINVAL.
219 */ 221 */
220int uvc_queue_buffer(struct uvc_video_queue *queue, 222static int
221 struct v4l2_buffer *v4l2_buf) 223uvc_queue_buffer(struct uvc_video_queue *queue, struct v4l2_buffer *v4l2_buf)
222{ 224{
223 struct uvc_buffer *buf; 225 struct uvc_buffer *buf;
224 unsigned long flags; 226 unsigned long flags;
@@ -298,8 +300,9 @@ static int uvc_queue_waiton(struct uvc_buffer *buf, int nonblocking)
298 * Dequeue a video buffer. If nonblocking is false, block until a buffer is 300 * Dequeue a video buffer. If nonblocking is false, block until a buffer is
299 * available. 301 * available.
300 */ 302 */
301int uvc_dequeue_buffer(struct uvc_video_queue *queue, 303static int
302 struct v4l2_buffer *v4l2_buf, int nonblocking) 304uvc_dequeue_buffer(struct uvc_video_queue *queue, struct v4l2_buffer *v4l2_buf,
305 int nonblocking)
303{ 306{
304 struct uvc_buffer *buf; 307 struct uvc_buffer *buf;
305 int ret = 0; 308 int ret = 0;
@@ -359,8 +362,9 @@ done:
359 * This function implements video queue polling and is intended to be used by 362 * This function implements video queue polling and is intended to be used by
360 * the device poll handler. 363 * the device poll handler.
361 */ 364 */
362unsigned int uvc_queue_poll(struct uvc_video_queue *queue, struct file *file, 365static unsigned int
363 poll_table *wait) 366uvc_queue_poll(struct uvc_video_queue *queue, struct file *file,
367 poll_table *wait)
364{ 368{
365 struct uvc_buffer *buf; 369 struct uvc_buffer *buf;
366 unsigned int mask = 0; 370 unsigned int mask = 0;
@@ -407,7 +411,8 @@ static struct vm_operations_struct uvc_vm_ops = {
407 * This function implements video buffer memory mapping and is intended to be 411 * This function implements video buffer memory mapping and is intended to be
408 * used by the device mmap handler. 412 * used by the device mmap handler.
409 */ 413 */
410int uvc_queue_mmap(struct uvc_video_queue *queue, struct vm_area_struct *vma) 414static int
415uvc_queue_mmap(struct uvc_video_queue *queue, struct vm_area_struct *vma)
411{ 416{
412 struct uvc_buffer *uninitialized_var(buffer); 417 struct uvc_buffer *uninitialized_var(buffer);
413 struct page *page; 418 struct page *page;
@@ -458,6 +463,42 @@ done:
458} 463}
459 464
460/* 465/*
466 * Cancel the video buffers queue.
467 *
468 * Cancelling the queue marks all buffers on the irq queue as erroneous,
469 * wakes them up and removes them from the queue.
470 *
471 * If the disconnect parameter is set, further calls to uvc_queue_buffer will
472 * fail with -ENODEV.
473 *
474 * This function acquires the irq spinlock and can be called from interrupt
475 * context.
476 */
477static void uvc_queue_cancel(struct uvc_video_queue *queue, int disconnect)
478{
479 struct uvc_buffer *buf;
480 unsigned long flags;
481
482 spin_lock_irqsave(&queue->irqlock, flags);
483 while (!list_empty(&queue->irqqueue)) {
484 buf = list_first_entry(&queue->irqqueue, struct uvc_buffer,
485 queue);
486 list_del(&buf->queue);
487 buf->state = UVC_BUF_STATE_ERROR;
488 wake_up(&buf->wait);
489 }
490 /* This must be protected by the irqlock spinlock to avoid race
491 * conditions between uvc_queue_buffer and the disconnection event that
492 * could result in an interruptible wait in uvc_dequeue_buffer. Do not
493 * blindly replace this logic by checking for the UVC_DEV_DISCONNECTED
494 * state outside the queue code.
495 */
496 if (disconnect)
497 queue->flags |= UVC_QUEUE_DISCONNECTED;
498 spin_unlock_irqrestore(&queue->irqlock, flags);
499}
500
501/*
461 * Enable or disable the video buffers queue. 502 * Enable or disable the video buffers queue.
462 * 503 *
463 * The queue must be enabled before starting video acquisition and must be 504 * The queue must be enabled before starting video acquisition and must be
@@ -474,7 +515,7 @@ done:
474 * This function can't be called from interrupt context. Use 515 * This function can't be called from interrupt context. Use
475 * uvc_queue_cancel() instead. 516 * uvc_queue_cancel() instead.
476 */ 517 */
477int uvc_queue_enable(struct uvc_video_queue *queue, int enable) 518static int uvc_queue_enable(struct uvc_video_queue *queue, int enable)
478{ 519{
479 unsigned int i; 520 unsigned int i;
480 int ret = 0; 521 int ret = 0;
@@ -503,44 +544,8 @@ done:
503 return ret; 544 return ret;
504} 545}
505 546
506/* 547static struct uvc_buffer *
507 * Cancel the video buffers queue. 548uvc_queue_next_buffer(struct uvc_video_queue *queue, struct uvc_buffer *buf)
508 *
509 * Cancelling the queue marks all buffers on the irq queue as erroneous,
510 * wakes them up and removes them from the queue.
511 *
512 * If the disconnect parameter is set, further calls to uvc_queue_buffer will
513 * fail with -ENODEV.
514 *
515 * This function acquires the irq spinlock and can be called from interrupt
516 * context.
517 */
518void uvc_queue_cancel(struct uvc_video_queue *queue, int disconnect)
519{
520 struct uvc_buffer *buf;
521 unsigned long flags;
522
523 spin_lock_irqsave(&queue->irqlock, flags);
524 while (!list_empty(&queue->irqqueue)) {
525 buf = list_first_entry(&queue->irqqueue, struct uvc_buffer,
526 queue);
527 list_del(&buf->queue);
528 buf->state = UVC_BUF_STATE_ERROR;
529 wake_up(&buf->wait);
530 }
531 /* This must be protected by the irqlock spinlock to avoid race
532 * conditions between uvc_queue_buffer and the disconnection event that
533 * could result in an interruptible wait in uvc_dequeue_buffer. Do not
534 * blindly replace this logic by checking for the UVC_DEV_DISCONNECTED
535 * state outside the queue code.
536 */
537 if (disconnect)
538 queue->flags |= UVC_QUEUE_DISCONNECTED;
539 spin_unlock_irqrestore(&queue->irqlock, flags);
540}
541
542struct uvc_buffer *uvc_queue_next_buffer(struct uvc_video_queue *queue,
543 struct uvc_buffer *buf)
544{ 549{
545 struct uvc_buffer *nextbuf; 550 struct uvc_buffer *nextbuf;
546 unsigned long flags; 551 unsigned long flags;
@@ -568,7 +573,7 @@ struct uvc_buffer *uvc_queue_next_buffer(struct uvc_video_queue *queue,
568 return nextbuf; 573 return nextbuf;
569} 574}
570 575
571struct uvc_buffer *uvc_queue_head(struct uvc_video_queue *queue) 576static struct uvc_buffer *uvc_queue_head(struct uvc_video_queue *queue)
572{ 577{
573 struct uvc_buffer *buf = NULL; 578 struct uvc_buffer *buf = NULL;
574 579
diff --git a/drivers/usb/gadget/uvc_queue.h b/drivers/usb/gadget/uvc_queue.h
index 7f5a33fe7ae2..1812a8ecc5d0 100644
--- a/drivers/usb/gadget/uvc_queue.h
+++ b/drivers/usb/gadget/uvc_queue.h
@@ -58,30 +58,10 @@ struct uvc_video_queue {
58 struct list_head irqqueue; 58 struct list_head irqqueue;
59}; 59};
60 60
61extern void uvc_queue_init(struct uvc_video_queue *queue,
62 enum v4l2_buf_type type);
63extern int uvc_alloc_buffers(struct uvc_video_queue *queue,
64 unsigned int nbuffers, unsigned int buflength);
65extern int uvc_free_buffers(struct uvc_video_queue *queue);
66extern int uvc_query_buffer(struct uvc_video_queue *queue,
67 struct v4l2_buffer *v4l2_buf);
68extern int uvc_queue_buffer(struct uvc_video_queue *queue,
69 struct v4l2_buffer *v4l2_buf);
70extern int uvc_dequeue_buffer(struct uvc_video_queue *queue,
71 struct v4l2_buffer *v4l2_buf, int nonblocking);
72extern int uvc_queue_enable(struct uvc_video_queue *queue, int enable);
73extern void uvc_queue_cancel(struct uvc_video_queue *queue, int disconnect);
74extern struct uvc_buffer *uvc_queue_next_buffer(struct uvc_video_queue *queue,
75 struct uvc_buffer *buf);
76extern unsigned int uvc_queue_poll(struct uvc_video_queue *queue,
77 struct file *file, poll_table *wait);
78extern int uvc_queue_mmap(struct uvc_video_queue *queue,
79 struct vm_area_struct *vma);
80static inline int uvc_queue_streaming(struct uvc_video_queue *queue) 61static inline int uvc_queue_streaming(struct uvc_video_queue *queue)
81{ 62{
82 return queue->flags & UVC_QUEUE_STREAMING; 63 return queue->flags & UVC_QUEUE_STREAMING;
83} 64}
84extern struct uvc_buffer *uvc_queue_head(struct uvc_video_queue *queue);
85 65
86#endif /* __KERNEL__ */ 66#endif /* __KERNEL__ */
87 67
diff --git a/drivers/usb/gadget/uvc_v4l2.c b/drivers/usb/gadget/uvc_v4l2.c
index a7989f29837e..2dcffdac86d2 100644
--- a/drivers/usb/gadget/uvc_v4l2.c
+++ b/drivers/usb/gadget/uvc_v4l2.c
@@ -363,7 +363,7 @@ uvc_v4l2_poll(struct file *file, poll_table *wait)
363 return mask; 363 return mask;
364} 364}
365 365
366struct v4l2_file_operations uvc_v4l2_fops = { 366static struct v4l2_file_operations uvc_v4l2_fops = {
367 .owner = THIS_MODULE, 367 .owner = THIS_MODULE,
368 .open = uvc_v4l2_open, 368 .open = uvc_v4l2_open,
369 .release = uvc_v4l2_release, 369 .release = uvc_v4l2_release,
diff --git a/drivers/usb/gadget/uvc_video.c b/drivers/usb/gadget/uvc_video.c
index de8cbc46518d..b08f35438d70 100644
--- a/drivers/usb/gadget/uvc_video.c
+++ b/drivers/usb/gadget/uvc_video.c
@@ -271,7 +271,7 @@ error:
271 * This function fills the available USB requests (listed in req_free) with 271 * This function fills the available USB requests (listed in req_free) with
272 * video data from the queued buffers. 272 * video data from the queued buffers.
273 */ 273 */
274int 274static int
275uvc_video_pump(struct uvc_video *video) 275uvc_video_pump(struct uvc_video *video)
276{ 276{
277 struct usb_request *req; 277 struct usb_request *req;
@@ -328,7 +328,7 @@ uvc_video_pump(struct uvc_video *video)
328/* 328/*
329 * Enable or disable the video stream. 329 * Enable or disable the video stream.
330 */ 330 */
331int 331static int
332uvc_video_enable(struct uvc_video *video, int enable) 332uvc_video_enable(struct uvc_video *video, int enable)
333{ 333{
334 unsigned int i; 334 unsigned int i;
@@ -367,7 +367,7 @@ uvc_video_enable(struct uvc_video *video, int enable)
367/* 367/*
368 * Initialize the UVC video stream. 368 * Initialize the UVC video stream.
369 */ 369 */
370int 370static int
371uvc_video_init(struct uvc_video *video) 371uvc_video_init(struct uvc_video *video)
372{ 372{
373 INIT_LIST_HEAD(&video->req_free); 373 INIT_LIST_HEAD(&video->req_free);
diff --git a/drivers/usb/gadget/webcam.c b/drivers/usb/gadget/webcam.c
index 417fd6887698..f5f3030cc416 100644
--- a/drivers/usb/gadget/webcam.c
+++ b/drivers/usb/gadget/webcam.c
@@ -28,10 +28,10 @@
28#include "config.c" 28#include "config.c"
29#include "epautoconf.c" 29#include "epautoconf.c"
30 30
31#include "f_uvc.c"
32#include "uvc_queue.c" 31#include "uvc_queue.c"
33#include "uvc_v4l2.c"
34#include "uvc_video.c" 32#include "uvc_video.c"
33#include "uvc_v4l2.c"
34#include "f_uvc.c"
35 35
36/* -------------------------------------------------------------------------- 36/* --------------------------------------------------------------------------
37 * Device descriptor 37 * Device descriptor
diff --git a/drivers/usb/host/ehci-mxc.c b/drivers/usb/host/ehci-mxc.c
index 544ccfd7056e..a8ad8ac120a2 100644
--- a/drivers/usb/host/ehci-mxc.c
+++ b/drivers/usb/host/ehci-mxc.c
@@ -182,7 +182,7 @@ static int ehci_mxc_drv_probe(struct platform_device *pdev)
182 } 182 }
183 clk_enable(priv->usbclk); 183 clk_enable(priv->usbclk);
184 184
185 if (!cpu_is_mx35()) { 185 if (!cpu_is_mx35() && !cpu_is_mx25()) {
186 priv->ahbclk = clk_get(dev, "usb_ahb"); 186 priv->ahbclk = clk_get(dev, "usb_ahb");
187 if (IS_ERR(priv->ahbclk)) { 187 if (IS_ERR(priv->ahbclk)) {
188 ret = PTR_ERR(priv->ahbclk); 188 ret = PTR_ERR(priv->ahbclk);
@@ -207,10 +207,17 @@ static int ehci_mxc_drv_probe(struct platform_device *pdev)
207 /* Initialize the transceiver */ 207 /* Initialize the transceiver */
208 if (pdata->otg) { 208 if (pdata->otg) {
209 pdata->otg->io_priv = hcd->regs + ULPI_VIEWPORT_OFFSET; 209 pdata->otg->io_priv = hcd->regs + ULPI_VIEWPORT_OFFSET;
210 if (otg_init(pdata->otg) != 0) 210 ret = otg_init(pdata->otg);
211 dev_err(dev, "unable to init transceiver\n"); 211 if (ret) {
212 else if (otg_set_vbus(pdata->otg, 1) != 0) 212 dev_err(dev, "unable to init transceiver, probably missing\n");
213 ret = -ENODEV;
214 goto err_add;
215 }
216 ret = otg_set_vbus(pdata->otg, 1);
217 if (ret) {
213 dev_err(dev, "unable to enable vbus on transceiver\n"); 218 dev_err(dev, "unable to enable vbus on transceiver\n");
219 goto err_add;
220 }
214 } 221 }
215 222
216 priv->hcd = hcd; 223 priv->hcd = hcd;
diff --git a/drivers/usb/host/isp1362-hcd.c b/drivers/usb/host/isp1362-hcd.c
index 20a0dfe0fe36..0587ad4ce5c2 100644
--- a/drivers/usb/host/isp1362-hcd.c
+++ b/drivers/usb/host/isp1362-hcd.c
@@ -2224,12 +2224,9 @@ static void remove_debug_file(struct isp1362_hcd *isp1362_hcd)
2224 2224
2225/*-------------------------------------------------------------------------*/ 2225/*-------------------------------------------------------------------------*/
2226 2226
2227static void isp1362_sw_reset(struct isp1362_hcd *isp1362_hcd) 2227static void __isp1362_sw_reset(struct isp1362_hcd *isp1362_hcd)
2228{ 2228{
2229 int tmp = 20; 2229 int tmp = 20;
2230 unsigned long flags;
2231
2232 spin_lock_irqsave(&isp1362_hcd->lock, flags);
2233 2230
2234 isp1362_write_reg16(isp1362_hcd, HCSWRES, HCSWRES_MAGIC); 2231 isp1362_write_reg16(isp1362_hcd, HCSWRES, HCSWRES_MAGIC);
2235 isp1362_write_reg32(isp1362_hcd, HCCMDSTAT, OHCI_HCR); 2232 isp1362_write_reg32(isp1362_hcd, HCCMDSTAT, OHCI_HCR);
@@ -2240,6 +2237,14 @@ static void isp1362_sw_reset(struct isp1362_hcd *isp1362_hcd)
2240 } 2237 }
2241 if (!tmp) 2238 if (!tmp)
2242 pr_err("Software reset timeout\n"); 2239 pr_err("Software reset timeout\n");
2240}
2241
2242static void isp1362_sw_reset(struct isp1362_hcd *isp1362_hcd)
2243{
2244 unsigned long flags;
2245
2246 spin_lock_irqsave(&isp1362_hcd->lock, flags);
2247 __isp1362_sw_reset(isp1362_hcd);
2243 spin_unlock_irqrestore(&isp1362_hcd->lock, flags); 2248 spin_unlock_irqrestore(&isp1362_hcd->lock, flags);
2244} 2249}
2245 2250
@@ -2418,7 +2423,7 @@ static void isp1362_hc_stop(struct usb_hcd *hcd)
2418 if (isp1362_hcd->board && isp1362_hcd->board->reset) 2423 if (isp1362_hcd->board && isp1362_hcd->board->reset)
2419 isp1362_hcd->board->reset(hcd->self.controller, 1); 2424 isp1362_hcd->board->reset(hcd->self.controller, 1);
2420 else 2425 else
2421 isp1362_sw_reset(isp1362_hcd); 2426 __isp1362_sw_reset(isp1362_hcd);
2422 2427
2423 if (isp1362_hcd->board && isp1362_hcd->board->clock) 2428 if (isp1362_hcd->board && isp1362_hcd->board->clock)
2424 isp1362_hcd->board->clock(hcd->self.controller, 0); 2429 isp1362_hcd->board->clock(hcd->self.controller, 0);
diff --git a/drivers/usb/host/ohci-pxa27x.c b/drivers/usb/host/ohci-pxa27x.c
index a18debdd79b8..418163894775 100644
--- a/drivers/usb/host/ohci-pxa27x.c
+++ b/drivers/usb/host/ohci-pxa27x.c
@@ -203,7 +203,7 @@ static inline void pxa27x_reset_hc(struct pxa27x_ohci *ohci)
203 __raw_writel(uhchr & ~UHCHR_FHR, ohci->mmio_base + UHCHR); 203 __raw_writel(uhchr & ~UHCHR_FHR, ohci->mmio_base + UHCHR);
204} 204}
205 205
206#ifdef CONFIG_CPU_PXA27x 206#ifdef CONFIG_PXA27x
207extern void pxa27x_clear_otgph(void); 207extern void pxa27x_clear_otgph(void);
208#else 208#else
209#define pxa27x_clear_otgph() do {} while (0) 209#define pxa27x_clear_otgph() do {} while (0)
diff --git a/drivers/usb/host/r8a66597-hcd.c b/drivers/usb/host/r8a66597-hcd.c
index 1a2bb4ce638f..77be3c24a427 100644
--- a/drivers/usb/host/r8a66597-hcd.c
+++ b/drivers/usb/host/r8a66597-hcd.c
@@ -1065,7 +1065,7 @@ static void r8a66597_usb_connect(struct r8a66597 *r8a66597, int port)
1065 else if (speed == LSMODE) 1065 else if (speed == LSMODE)
1066 rh->port |= USB_PORT_STAT_LOW_SPEED; 1066 rh->port |= USB_PORT_STAT_LOW_SPEED;
1067 1067
1068 rh->port &= USB_PORT_STAT_RESET; 1068 rh->port &= ~USB_PORT_STAT_RESET;
1069 rh->port |= USB_PORT_STAT_ENABLE; 1069 rh->port |= USB_PORT_STAT_ENABLE;
1070} 1070}
1071 1071
diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c
index fd9e03afd91c..2eb658d26394 100644
--- a/drivers/usb/host/xhci-mem.c
+++ b/drivers/usb/host/xhci-mem.c
@@ -835,6 +835,27 @@ fail:
835 return 0; 835 return 0;
836} 836}
837 837
838void xhci_copy_ep0_dequeue_into_input_ctx(struct xhci_hcd *xhci,
839 struct usb_device *udev)
840{
841 struct xhci_virt_device *virt_dev;
842 struct xhci_ep_ctx *ep0_ctx;
843 struct xhci_ring *ep_ring;
844
845 virt_dev = xhci->devs[udev->slot_id];
846 ep0_ctx = xhci_get_ep_ctx(xhci, virt_dev->in_ctx, 0);
847 ep_ring = virt_dev->eps[0].ring;
848 /*
849 * FIXME we don't keep track of the dequeue pointer very well after a
850 * Set TR dequeue pointer, so we're setting the dequeue pointer of the
851 * host to our enqueue pointer. This should only be called after a
852 * configured device has reset, so all control transfers should have
853 * been completed or cancelled before the reset.
854 */
855 ep0_ctx->deq = xhci_trb_virt_to_dma(ep_ring->enq_seg, ep_ring->enqueue);
856 ep0_ctx->deq |= ep_ring->cycle_state;
857}
858
838/* Setup an xHCI virtual device for a Set Address command */ 859/* Setup an xHCI virtual device for a Set Address command */
839int xhci_setup_addressable_virt_dev(struct xhci_hcd *xhci, struct usb_device *udev) 860int xhci_setup_addressable_virt_dev(struct xhci_hcd *xhci, struct usb_device *udev)
840{ 861{
@@ -1002,7 +1023,7 @@ static inline unsigned int xhci_get_endpoint_interval(struct usb_device *udev,
1002 return EP_INTERVAL(interval); 1023 return EP_INTERVAL(interval);
1003} 1024}
1004 1025
1005/* The "Mult" field in the endpoint context is only set for SuperSpeed devices. 1026/* The "Mult" field in the endpoint context is only set for SuperSpeed isoc eps.
1006 * High speed endpoint descriptors can define "the number of additional 1027 * High speed endpoint descriptors can define "the number of additional
1007 * transaction opportunities per microframe", but that goes in the Max Burst 1028 * transaction opportunities per microframe", but that goes in the Max Burst
1008 * endpoint context field. 1029 * endpoint context field.
@@ -1010,7 +1031,8 @@ static inline unsigned int xhci_get_endpoint_interval(struct usb_device *udev,
1010static inline u32 xhci_get_endpoint_mult(struct usb_device *udev, 1031static inline u32 xhci_get_endpoint_mult(struct usb_device *udev,
1011 struct usb_host_endpoint *ep) 1032 struct usb_host_endpoint *ep)
1012{ 1033{
1013 if (udev->speed != USB_SPEED_SUPER) 1034 if (udev->speed != USB_SPEED_SUPER ||
1035 !usb_endpoint_xfer_isoc(&ep->desc))
1014 return 0; 1036 return 0;
1015 return ep->ss_ep_comp.bmAttributes; 1037 return ep->ss_ep_comp.bmAttributes;
1016} 1038}
diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c
index 9012098add6b..bfc99a939455 100644
--- a/drivers/usb/host/xhci-ring.c
+++ b/drivers/usb/host/xhci-ring.c
@@ -182,8 +182,12 @@ static void inc_deq(struct xhci_hcd *xhci, struct xhci_ring *ring, bool consumer
182 * set, but other sections talk about dealing with the chain bit set. This was 182 * set, but other sections talk about dealing with the chain bit set. This was
183 * fixed in the 0.96 specification errata, but we have to assume that all 0.95 183 * fixed in the 0.96 specification errata, but we have to assume that all 0.95
184 * xHCI hardware can't handle the chain bit being cleared on a link TRB. 184 * xHCI hardware can't handle the chain bit being cleared on a link TRB.
185 *
186 * @more_trbs_coming: Will you enqueue more TRBs before calling
187 * prepare_transfer()?
185 */ 188 */
186static void inc_enq(struct xhci_hcd *xhci, struct xhci_ring *ring, bool consumer) 189static void inc_enq(struct xhci_hcd *xhci, struct xhci_ring *ring,
190 bool consumer, bool more_trbs_coming)
187{ 191{
188 u32 chain; 192 u32 chain;
189 union xhci_trb *next; 193 union xhci_trb *next;
@@ -199,15 +203,28 @@ static void inc_enq(struct xhci_hcd *xhci, struct xhci_ring *ring, bool consumer
199 while (last_trb(xhci, ring, ring->enq_seg, next)) { 203 while (last_trb(xhci, ring, ring->enq_seg, next)) {
200 if (!consumer) { 204 if (!consumer) {
201 if (ring != xhci->event_ring) { 205 if (ring != xhci->event_ring) {
202 if (chain) { 206 /*
203 next->link.control |= TRB_CHAIN; 207 * If the caller doesn't plan on enqueueing more
204 208 * TDs before ringing the doorbell, then we
205 /* Give this link TRB to the hardware */ 209 * don't want to give the link TRB to the
206 wmb(); 210 * hardware just yet. We'll give the link TRB
207 next->link.control ^= TRB_CYCLE; 211 * back in prepare_ring() just before we enqueue
208 } else { 212 * the TD at the top of the ring.
213 */
214 if (!chain && !more_trbs_coming)
209 break; 215 break;
216
217 /* If we're not dealing with 0.95 hardware,
218 * carry over the chain bit of the previous TRB
219 * (which may mean the chain bit is cleared).
220 */
221 if (!xhci_link_trb_quirk(xhci)) {
222 next->link.control &= ~TRB_CHAIN;
223 next->link.control |= chain;
210 } 224 }
225 /* Give this link TRB to the hardware */
226 wmb();
227 next->link.control ^= TRB_CYCLE;
211 } 228 }
212 /* Toggle the cycle bit after the last ring segment. */ 229 /* Toggle the cycle bit after the last ring segment. */
213 if (last_trb_on_last_seg(xhci, ring, ring->enq_seg, next)) { 230 if (last_trb_on_last_seg(xhci, ring, ring->enq_seg, next)) {
@@ -1707,9 +1724,12 @@ void xhci_handle_event(struct xhci_hcd *xhci)
1707/* 1724/*
1708 * Generic function for queueing a TRB on a ring. 1725 * Generic function for queueing a TRB on a ring.
1709 * The caller must have checked to make sure there's room on the ring. 1726 * The caller must have checked to make sure there's room on the ring.
1727 *
1728 * @more_trbs_coming: Will you enqueue more TRBs before calling
1729 * prepare_transfer()?
1710 */ 1730 */
1711static void queue_trb(struct xhci_hcd *xhci, struct xhci_ring *ring, 1731static void queue_trb(struct xhci_hcd *xhci, struct xhci_ring *ring,
1712 bool consumer, 1732 bool consumer, bool more_trbs_coming,
1713 u32 field1, u32 field2, u32 field3, u32 field4) 1733 u32 field1, u32 field2, u32 field3, u32 field4)
1714{ 1734{
1715 struct xhci_generic_trb *trb; 1735 struct xhci_generic_trb *trb;
@@ -1719,7 +1739,7 @@ static void queue_trb(struct xhci_hcd *xhci, struct xhci_ring *ring,
1719 trb->field[1] = field2; 1739 trb->field[1] = field2;
1720 trb->field[2] = field3; 1740 trb->field[2] = field3;
1721 trb->field[3] = field4; 1741 trb->field[3] = field4;
1722 inc_enq(xhci, ring, consumer); 1742 inc_enq(xhci, ring, consumer, more_trbs_coming);
1723} 1743}
1724 1744
1725/* 1745/*
@@ -1988,6 +2008,7 @@ static int queue_bulk_sg_tx(struct xhci_hcd *xhci, gfp_t mem_flags,
1988 int trb_buff_len, this_sg_len, running_total; 2008 int trb_buff_len, this_sg_len, running_total;
1989 bool first_trb; 2009 bool first_trb;
1990 u64 addr; 2010 u64 addr;
2011 bool more_trbs_coming;
1991 2012
1992 struct xhci_generic_trb *start_trb; 2013 struct xhci_generic_trb *start_trb;
1993 int start_cycle; 2014 int start_cycle;
@@ -2073,7 +2094,11 @@ static int queue_bulk_sg_tx(struct xhci_hcd *xhci, gfp_t mem_flags,
2073 length_field = TRB_LEN(trb_buff_len) | 2094 length_field = TRB_LEN(trb_buff_len) |
2074 remainder | 2095 remainder |
2075 TRB_INTR_TARGET(0); 2096 TRB_INTR_TARGET(0);
2076 queue_trb(xhci, ep_ring, false, 2097 if (num_trbs > 1)
2098 more_trbs_coming = true;
2099 else
2100 more_trbs_coming = false;
2101 queue_trb(xhci, ep_ring, false, more_trbs_coming,
2077 lower_32_bits(addr), 2102 lower_32_bits(addr),
2078 upper_32_bits(addr), 2103 upper_32_bits(addr),
2079 length_field, 2104 length_field,
@@ -2124,6 +2149,7 @@ int xhci_queue_bulk_tx(struct xhci_hcd *xhci, gfp_t mem_flags,
2124 int num_trbs; 2149 int num_trbs;
2125 struct xhci_generic_trb *start_trb; 2150 struct xhci_generic_trb *start_trb;
2126 bool first_trb; 2151 bool first_trb;
2152 bool more_trbs_coming;
2127 int start_cycle; 2153 int start_cycle;
2128 u32 field, length_field; 2154 u32 field, length_field;
2129 2155
@@ -2212,7 +2238,11 @@ int xhci_queue_bulk_tx(struct xhci_hcd *xhci, gfp_t mem_flags,
2212 length_field = TRB_LEN(trb_buff_len) | 2238 length_field = TRB_LEN(trb_buff_len) |
2213 remainder | 2239 remainder |
2214 TRB_INTR_TARGET(0); 2240 TRB_INTR_TARGET(0);
2215 queue_trb(xhci, ep_ring, false, 2241 if (num_trbs > 1)
2242 more_trbs_coming = true;
2243 else
2244 more_trbs_coming = false;
2245 queue_trb(xhci, ep_ring, false, more_trbs_coming,
2216 lower_32_bits(addr), 2246 lower_32_bits(addr),
2217 upper_32_bits(addr), 2247 upper_32_bits(addr),
2218 length_field, 2248 length_field,
@@ -2291,7 +2321,7 @@ int xhci_queue_ctrl_tx(struct xhci_hcd *xhci, gfp_t mem_flags,
2291 /* Queue setup TRB - see section 6.4.1.2.1 */ 2321 /* Queue setup TRB - see section 6.4.1.2.1 */
2292 /* FIXME better way to translate setup_packet into two u32 fields? */ 2322 /* FIXME better way to translate setup_packet into two u32 fields? */
2293 setup = (struct usb_ctrlrequest *) urb->setup_packet; 2323 setup = (struct usb_ctrlrequest *) urb->setup_packet;
2294 queue_trb(xhci, ep_ring, false, 2324 queue_trb(xhci, ep_ring, false, true,
2295 /* FIXME endianness is probably going to bite my ass here. */ 2325 /* FIXME endianness is probably going to bite my ass here. */
2296 setup->bRequestType | setup->bRequest << 8 | setup->wValue << 16, 2326 setup->bRequestType | setup->bRequest << 8 | setup->wValue << 16,
2297 setup->wIndex | setup->wLength << 16, 2327 setup->wIndex | setup->wLength << 16,
@@ -2307,7 +2337,7 @@ int xhci_queue_ctrl_tx(struct xhci_hcd *xhci, gfp_t mem_flags,
2307 if (urb->transfer_buffer_length > 0) { 2337 if (urb->transfer_buffer_length > 0) {
2308 if (setup->bRequestType & USB_DIR_IN) 2338 if (setup->bRequestType & USB_DIR_IN)
2309 field |= TRB_DIR_IN; 2339 field |= TRB_DIR_IN;
2310 queue_trb(xhci, ep_ring, false, 2340 queue_trb(xhci, ep_ring, false, true,
2311 lower_32_bits(urb->transfer_dma), 2341 lower_32_bits(urb->transfer_dma),
2312 upper_32_bits(urb->transfer_dma), 2342 upper_32_bits(urb->transfer_dma),
2313 length_field, 2343 length_field,
@@ -2324,7 +2354,7 @@ int xhci_queue_ctrl_tx(struct xhci_hcd *xhci, gfp_t mem_flags,
2324 field = 0; 2354 field = 0;
2325 else 2355 else
2326 field = TRB_DIR_IN; 2356 field = TRB_DIR_IN;
2327 queue_trb(xhci, ep_ring, false, 2357 queue_trb(xhci, ep_ring, false, false,
2328 0, 2358 0,
2329 0, 2359 0,
2330 TRB_INTR_TARGET(0), 2360 TRB_INTR_TARGET(0),
@@ -2350,18 +2380,21 @@ static int queue_command(struct xhci_hcd *xhci, u32 field1, u32 field2,
2350 u32 field3, u32 field4, bool command_must_succeed) 2380 u32 field3, u32 field4, bool command_must_succeed)
2351{ 2381{
2352 int reserved_trbs = xhci->cmd_ring_reserved_trbs; 2382 int reserved_trbs = xhci->cmd_ring_reserved_trbs;
2383 int ret;
2384
2353 if (!command_must_succeed) 2385 if (!command_must_succeed)
2354 reserved_trbs++; 2386 reserved_trbs++;
2355 2387
2356 if (!room_on_ring(xhci, xhci->cmd_ring, reserved_trbs)) { 2388 ret = prepare_ring(xhci, xhci->cmd_ring, EP_STATE_RUNNING,
2357 if (!in_interrupt()) 2389 reserved_trbs, GFP_ATOMIC);
2358 xhci_err(xhci, "ERR: No room for command on command ring\n"); 2390 if (ret < 0) {
2391 xhci_err(xhci, "ERR: No room for command on command ring\n");
2359 if (command_must_succeed) 2392 if (command_must_succeed)
2360 xhci_err(xhci, "ERR: Reserved TRB counting for " 2393 xhci_err(xhci, "ERR: Reserved TRB counting for "
2361 "unfailable commands failed.\n"); 2394 "unfailable commands failed.\n");
2362 return -ENOMEM; 2395 return ret;
2363 } 2396 }
2364 queue_trb(xhci, xhci->cmd_ring, false, field1, field2, field3, 2397 queue_trb(xhci, xhci->cmd_ring, false, false, field1, field2, field3,
2365 field4 | xhci->cmd_ring->cycle_state); 2398 field4 | xhci->cmd_ring->cycle_state);
2366 return 0; 2399 return 0;
2367} 2400}
diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index 27345cd04da0..3998f72cd0c4 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -2134,6 +2134,8 @@ int xhci_address_device(struct usb_hcd *hcd, struct usb_device *udev)
2134 /* If this is a Set Address to an unconfigured device, setup ep 0 */ 2134 /* If this is a Set Address to an unconfigured device, setup ep 0 */
2135 if (!udev->config) 2135 if (!udev->config)
2136 xhci_setup_addressable_virt_dev(xhci, udev); 2136 xhci_setup_addressable_virt_dev(xhci, udev);
2137 else
2138 xhci_copy_ep0_dequeue_into_input_ctx(xhci, udev);
2137 /* Otherwise, assume the core has the device configured how it wants */ 2139 /* Otherwise, assume the core has the device configured how it wants */
2138 xhci_dbg(xhci, "Slot ID %d Input Context:\n", udev->slot_id); 2140 xhci_dbg(xhci, "Slot ID %d Input Context:\n", udev->slot_id);
2139 xhci_dbg_ctx(xhci, virt_dev->in_ctx, 2); 2141 xhci_dbg_ctx(xhci, virt_dev->in_ctx, 2);
diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h
index 8b4b7d39f79c..6c7e3430ec93 100644
--- a/drivers/usb/host/xhci.h
+++ b/drivers/usb/host/xhci.h
@@ -1292,6 +1292,8 @@ int xhci_mem_init(struct xhci_hcd *xhci, gfp_t flags);
1292void xhci_free_virt_device(struct xhci_hcd *xhci, int slot_id); 1292void xhci_free_virt_device(struct xhci_hcd *xhci, int slot_id);
1293int xhci_alloc_virt_device(struct xhci_hcd *xhci, int slot_id, struct usb_device *udev, gfp_t flags); 1293int xhci_alloc_virt_device(struct xhci_hcd *xhci, int slot_id, struct usb_device *udev, gfp_t flags);
1294int xhci_setup_addressable_virt_dev(struct xhci_hcd *xhci, struct usb_device *udev); 1294int xhci_setup_addressable_virt_dev(struct xhci_hcd *xhci, struct usb_device *udev);
1295void xhci_copy_ep0_dequeue_into_input_ctx(struct xhci_hcd *xhci,
1296 struct usb_device *udev);
1295unsigned int xhci_get_endpoint_index(struct usb_endpoint_descriptor *desc); 1297unsigned int xhci_get_endpoint_index(struct usb_endpoint_descriptor *desc);
1296unsigned int xhci_get_endpoint_flag(struct usb_endpoint_descriptor *desc); 1298unsigned int xhci_get_endpoint_flag(struct usb_endpoint_descriptor *desc);
1297unsigned int xhci_get_endpoint_flag_from_index(unsigned int ep_index); 1299unsigned int xhci_get_endpoint_flag_from_index(unsigned int ep_index);
diff --git a/drivers/usb/misc/sisusbvga/sisusb.c b/drivers/usb/misc/sisusbvga/sisusb.c
index 30d930386b65..d25814c172b2 100644
--- a/drivers/usb/misc/sisusbvga/sisusb.c
+++ b/drivers/usb/misc/sisusbvga/sisusb.c
@@ -2436,7 +2436,8 @@ sisusb_open(struct inode *inode, struct file *file)
2436 } 2436 }
2437 2437
2438 if (!sisusb->devinit) { 2438 if (!sisusb->devinit) {
2439 if (sisusb->sisusb_dev->speed == USB_SPEED_HIGH) { 2439 if (sisusb->sisusb_dev->speed == USB_SPEED_HIGH ||
2440 sisusb->sisusb_dev->speed == USB_SPEED_SUPER) {
2440 if (sisusb_init_gfxdevice(sisusb, 0)) { 2441 if (sisusb_init_gfxdevice(sisusb, 0)) {
2441 mutex_unlock(&sisusb->lock); 2442 mutex_unlock(&sisusb->lock);
2442 dev_err(&sisusb->sisusb_dev->dev, "Failed to initialize device\n"); 2443 dev_err(&sisusb->sisusb_dev->dev, "Failed to initialize device\n");
@@ -3166,7 +3167,7 @@ static int sisusb_probe(struct usb_interface *intf,
3166 3167
3167 sisusb->present = 1; 3168 sisusb->present = 1;
3168 3169
3169 if (dev->speed == USB_SPEED_HIGH) { 3170 if (dev->speed == USB_SPEED_HIGH || dev->speed == USB_SPEED_SUPER) {
3170 int initscreen = 1; 3171 int initscreen = 1;
3171#ifdef INCL_SISUSB_CON 3172#ifdef INCL_SISUSB_CON
3172 if (sisusb_first_vc > 0 && 3173 if (sisusb_first_vc > 0 &&
diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c
index fad70bc83555..3b795c56221f 100644
--- a/drivers/usb/musb/musb_core.c
+++ b/drivers/usb/musb/musb_core.c
@@ -219,8 +219,8 @@ static int musb_ulpi_write(struct otg_transceiver *otg,
219 return 0; 219 return 0;
220} 220}
221#else 221#else
222#define musb_ulpi_read(a, b) NULL 222#define musb_ulpi_read NULL
223#define musb_ulpi_write(a, b, c) NULL 223#define musb_ulpi_write NULL
224#endif 224#endif
225 225
226static struct otg_io_access_ops musb_ulpi_access = { 226static struct otg_io_access_ops musb_ulpi_access = {
@@ -451,10 +451,6 @@ void musb_hnp_stop(struct musb *musb)
451 * @param power 451 * @param power
452 */ 452 */
453 453
454#define STAGE0_MASK (MUSB_INTR_RESUME | MUSB_INTR_SESSREQ \
455 | MUSB_INTR_VBUSERROR | MUSB_INTR_CONNECT \
456 | MUSB_INTR_RESET)
457
458static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb, 454static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb,
459 u8 devctl, u8 power) 455 u8 devctl, u8 power)
460{ 456{
@@ -642,7 +638,7 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb,
642 handled = IRQ_HANDLED; 638 handled = IRQ_HANDLED;
643 } 639 }
644 640
645 641#endif
646 if (int_usb & MUSB_INTR_SUSPEND) { 642 if (int_usb & MUSB_INTR_SUSPEND) {
647 DBG(1, "SUSPEND (%s) devctl %02x power %02x\n", 643 DBG(1, "SUSPEND (%s) devctl %02x power %02x\n",
648 otg_state_string(musb), devctl, power); 644 otg_state_string(musb), devctl, power);
@@ -705,6 +701,7 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb,
705 } 701 }
706 } 702 }
707 703
704#ifdef CONFIG_USB_MUSB_HDRC_HCD
708 if (int_usb & MUSB_INTR_CONNECT) { 705 if (int_usb & MUSB_INTR_CONNECT) {
709 struct usb_hcd *hcd = musb_to_hcd(musb); 706 struct usb_hcd *hcd = musb_to_hcd(musb);
710 void __iomem *mbase = musb->mregs; 707 void __iomem *mbase = musb->mregs;
@@ -1597,7 +1594,7 @@ irqreturn_t musb_interrupt(struct musb *musb)
1597 /* the core can interrupt us for multiple reasons; docs have 1594 /* the core can interrupt us for multiple reasons; docs have
1598 * a generic interrupt flowchart to follow 1595 * a generic interrupt flowchart to follow
1599 */ 1596 */
1600 if (musb->int_usb & STAGE0_MASK) 1597 if (musb->int_usb)
1601 retval |= musb_stage0_irq(musb, musb->int_usb, 1598 retval |= musb_stage0_irq(musb, musb->int_usb,
1602 devctl, power); 1599 devctl, power);
1603 1600
diff --git a/drivers/usb/musb/musb_core.h b/drivers/usb/musb/musb_core.h
index b22d02dea7d3..91d67794e350 100644
--- a/drivers/usb/musb/musb_core.h
+++ b/drivers/usb/musb/musb_core.h
@@ -470,7 +470,8 @@ struct musb_csr_regs {
470 470
471struct musb_context_registers { 471struct musb_context_registers {
472 472
473#ifdef CONFIG_PM 473#if defined(CONFIG_ARCH_OMAP2430) || defined(CONFIG_ARCH_OMAP3) || \
474 defined(CONFIG_ARCH_OMAP4)
474 u32 otg_sysconfig, otg_forcestandby; 475 u32 otg_sysconfig, otg_forcestandby;
475#endif 476#endif
476 u8 power; 477 u8 power;
@@ -484,7 +485,8 @@ struct musb_context_registers {
484 struct musb_csr_regs index_regs[MUSB_C_NUM_EPS]; 485 struct musb_csr_regs index_regs[MUSB_C_NUM_EPS];
485}; 486};
486 487
487#ifdef CONFIG_PM 488#if defined(CONFIG_ARCH_OMAP2430) || defined(CONFIG_ARCH_OMAP3) || \
489 defined(CONFIG_ARCH_OMAP4)
488extern void musb_platform_save_context(struct musb *musb, 490extern void musb_platform_save_context(struct musb *musb,
489 struct musb_context_registers *musb_context); 491 struct musb_context_registers *musb_context);
490extern void musb_platform_restore_context(struct musb *musb, 492extern void musb_platform_restore_context(struct musb *musb,
diff --git a/drivers/usb/musb/musbhsdma.c b/drivers/usb/musb/musbhsdma.c
index 1008044a3bbc..dc66e4376d49 100644
--- a/drivers/usb/musb/musbhsdma.c
+++ b/drivers/usb/musb/musbhsdma.c
@@ -132,18 +132,9 @@ static void configure_channel(struct dma_channel *channel,
132 if (mode) { 132 if (mode) {
133 csr |= 1 << MUSB_HSDMA_MODE1_SHIFT; 133 csr |= 1 << MUSB_HSDMA_MODE1_SHIFT;
134 BUG_ON(len < packet_sz); 134 BUG_ON(len < packet_sz);
135
136 if (packet_sz >= 64) {
137 csr |= MUSB_HSDMA_BURSTMODE_INCR16
138 << MUSB_HSDMA_BURSTMODE_SHIFT;
139 } else if (packet_sz >= 32) {
140 csr |= MUSB_HSDMA_BURSTMODE_INCR8
141 << MUSB_HSDMA_BURSTMODE_SHIFT;
142 } else if (packet_sz >= 16) {
143 csr |= MUSB_HSDMA_BURSTMODE_INCR4
144 << MUSB_HSDMA_BURSTMODE_SHIFT;
145 }
146 } 135 }
136 csr |= MUSB_HSDMA_BURSTMODE_INCR16
137 << MUSB_HSDMA_BURSTMODE_SHIFT;
147 138
148 csr |= (musb_channel->epnum << MUSB_HSDMA_ENDPOINT_SHIFT) 139 csr |= (musb_channel->epnum << MUSB_HSDMA_ENDPOINT_SHIFT)
149 | (1 << MUSB_HSDMA_ENABLE_SHIFT) 140 | (1 << MUSB_HSDMA_ENABLE_SHIFT)
diff --git a/drivers/usb/musb/tusb6010.c b/drivers/usb/musb/tusb6010.c
index 05c077f8f9ac..3c48e77a0aa2 100644
--- a/drivers/usb/musb/tusb6010.c
+++ b/drivers/usb/musb/tusb6010.c
@@ -29,19 +29,6 @@ static void tusb_source_power(struct musb *musb, int is_on);
29#define TUSB_REV_MAJOR(reg_val) ((reg_val >> 4) & 0xf) 29#define TUSB_REV_MAJOR(reg_val) ((reg_val >> 4) & 0xf)
30#define TUSB_REV_MINOR(reg_val) (reg_val & 0xf) 30#define TUSB_REV_MINOR(reg_val) (reg_val & 0xf)
31 31
32#ifdef CONFIG_PM
33/* REVISIT: These should be only needed if somebody implements off idle */
34void musb_platform_save_context(struct musb *musb,
35 struct musb_context_registers *musb_context)
36{
37}
38
39void musb_platform_restore_context(struct musb *musb,
40 struct musb_context_registers *musb_context)
41{
42}
43#endif
44
45/* 32/*
46 * Checks the revision. We need to use the DMA register as 3.0 does not 33 * Checks the revision. We need to use the DMA register as 3.0 does not
47 * have correct versions for TUSB_PRCM_REV or TUSB_INT_CTRL_REV. 34 * have correct versions for TUSB_PRCM_REV or TUSB_INT_CTRL_REV.
diff --git a/drivers/usb/otg/ulpi.c b/drivers/usb/otg/ulpi.c
index b1b346932946..d331b222ad21 100644
--- a/drivers/usb/otg/ulpi.c
+++ b/drivers/usb/otg/ulpi.c
@@ -59,12 +59,17 @@ static int ulpi_set_flags(struct otg_transceiver *otg)
59 59
60static int ulpi_init(struct otg_transceiver *otg) 60static int ulpi_init(struct otg_transceiver *otg)
61{ 61{
62 int i, vid, pid; 62 int i, vid, pid, ret;
63 63 u32 ulpi_id = 0;
64 vid = (otg_io_read(otg, ULPI_VENDOR_ID_HIGH) << 8) | 64
65 otg_io_read(otg, ULPI_VENDOR_ID_LOW); 65 for (i = 0; i < 4; i++) {
66 pid = (otg_io_read(otg, ULPI_PRODUCT_ID_HIGH) << 8) | 66 ret = otg_io_read(otg, ULPI_PRODUCT_ID_HIGH - i);
67 otg_io_read(otg, ULPI_PRODUCT_ID_LOW); 67 if (ret < 0)
68 return ret;
69 ulpi_id = (ulpi_id << 8) | ret;
70 }
71 vid = ulpi_id & 0xffff;
72 pid = ulpi_id >> 16;
68 73
69 pr_info("ULPI transceiver vendor/product ID 0x%04x/0x%04x\n", vid, pid); 74 pr_info("ULPI transceiver vendor/product ID 0x%04x/0x%04x\n", vid, pid);
70 75
diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c
index 79dd1ae195e5..e298dc4baed7 100644
--- a/drivers/usb/serial/ftdi_sio.c
+++ b/drivers/usb/serial/ftdi_sio.c
@@ -653,7 +653,6 @@ static struct usb_device_id id_table_combined [] = {
653 { USB_DEVICE(EVOLUTION_VID, EVOLUTION_ER1_PID) }, 653 { USB_DEVICE(EVOLUTION_VID, EVOLUTION_ER1_PID) },
654 { USB_DEVICE(EVOLUTION_VID, EVO_HYBRID_PID) }, 654 { USB_DEVICE(EVOLUTION_VID, EVO_HYBRID_PID) },
655 { USB_DEVICE(EVOLUTION_VID, EVO_RCM4_PID) }, 655 { USB_DEVICE(EVOLUTION_VID, EVO_RCM4_PID) },
656 { USB_DEVICE(CONTEC_VID, CONTEC_COM1USBH_PID) },
657 { USB_DEVICE(FTDI_VID, FTDI_ARTEMIS_PID) }, 656 { USB_DEVICE(FTDI_VID, FTDI_ARTEMIS_PID) },
658 { USB_DEVICE(FTDI_VID, FTDI_ATIK_ATK16_PID) }, 657 { USB_DEVICE(FTDI_VID, FTDI_ATIK_ATK16_PID) },
659 { USB_DEVICE(FTDI_VID, FTDI_ATIK_ATK16C_PID) }, 658 { USB_DEVICE(FTDI_VID, FTDI_ATIK_ATK16C_PID) },
@@ -692,6 +691,7 @@ static struct usb_device_id id_table_combined [] = {
692 { USB_DEVICE(FTDI_VID, FTDI_NDI_AURORA_SCU_PID), 691 { USB_DEVICE(FTDI_VID, FTDI_NDI_AURORA_SCU_PID),
693 .driver_info = (kernel_ulong_t)&ftdi_NDI_device_quirk }, 692 .driver_info = (kernel_ulong_t)&ftdi_NDI_device_quirk },
694 { USB_DEVICE(TELLDUS_VID, TELLDUS_TELLSTICK_PID) }, 693 { USB_DEVICE(TELLDUS_VID, TELLDUS_TELLSTICK_PID) },
694 { USB_DEVICE(RTSYSTEMS_VID, RTSYSTEMS_SERIAL_VX7_PID) },
695 { USB_DEVICE(FTDI_VID, FTDI_MAXSTREAM_PID) }, 695 { USB_DEVICE(FTDI_VID, FTDI_MAXSTREAM_PID) },
696 { USB_DEVICE(FTDI_VID, FTDI_PHI_FISCO_PID) }, 696 { USB_DEVICE(FTDI_VID, FTDI_PHI_FISCO_PID) },
697 { USB_DEVICE(TML_VID, TML_USB_SERIAL_PID) }, 697 { USB_DEVICE(TML_VID, TML_USB_SERIAL_PID) },
@@ -738,6 +738,14 @@ static struct usb_device_id id_table_combined [] = {
738 { USB_DEVICE(FTDI_VID, MJSG_SR_RADIO_PID) }, 738 { USB_DEVICE(FTDI_VID, MJSG_SR_RADIO_PID) },
739 { USB_DEVICE(FTDI_VID, MJSG_HD_RADIO_PID) }, 739 { USB_DEVICE(FTDI_VID, MJSG_HD_RADIO_PID) },
740 { USB_DEVICE(FTDI_VID, MJSG_XM_RADIO_PID) }, 740 { USB_DEVICE(FTDI_VID, MJSG_XM_RADIO_PID) },
741 { USB_DEVICE(FTDI_VID, XVERVE_SIGNALYZER_ST_PID),
742 .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk },
743 { USB_DEVICE(FTDI_VID, XVERVE_SIGNALYZER_SLITE_PID),
744 .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk },
745 { USB_DEVICE(FTDI_VID, XVERVE_SIGNALYZER_SH2_PID),
746 .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk },
747 { USB_DEVICE(FTDI_VID, XVERVE_SIGNALYZER_SH4_PID),
748 .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk },
741 { }, /* Optional parameter entry */ 749 { }, /* Optional parameter entry */
742 { } /* Terminating entry */ 750 { } /* Terminating entry */
743}; 751};
diff --git a/drivers/usb/serial/ftdi_sio_ids.h b/drivers/usb/serial/ftdi_sio_ids.h
index 94d86c3febcb..d01946db8fac 100644
--- a/drivers/usb/serial/ftdi_sio_ids.h
+++ b/drivers/usb/serial/ftdi_sio_ids.h
@@ -501,13 +501,6 @@
501#define CONTEC_COM1USBH_PID 0x8311 /* COM-1(USB)H */ 501#define CONTEC_COM1USBH_PID 0x8311 /* COM-1(USB)H */
502 502
503/* 503/*
504 * Contec products (http://www.contec.com)
505 * Submitted by Daniel Sangorrin
506 */
507#define CONTEC_VID 0x06CE /* Vendor ID */
508#define CONTEC_COM1USBH_PID 0x8311 /* COM-1(USB)H */
509
510/*
511 * Definitions for B&B Electronics products. 504 * Definitions for B&B Electronics products.
512 */ 505 */
513#define BANDB_VID 0x0856 /* B&B Electronics Vendor ID */ 506#define BANDB_VID 0x0856 /* B&B Electronics Vendor ID */
@@ -703,6 +696,12 @@
703#define TELLDUS_TELLSTICK_PID 0x0C30 /* RF control dongle 433 MHz using FT232RL */ 696#define TELLDUS_TELLSTICK_PID 0x0C30 /* RF control dongle 433 MHz using FT232RL */
704 697
705/* 698/*
699 * RT Systems programming cables for various ham radios
700 */
701#define RTSYSTEMS_VID 0x2100 /* Vendor ID */
702#define RTSYSTEMS_SERIAL_VX7_PID 0x9e52 /* Serial converter for VX-7 Radios using FT232RL */
703
704/*
706 * Bayer Ascensia Contour blood glucose meter USB-converter cable. 705 * Bayer Ascensia Contour blood glucose meter USB-converter cable.
707 * http://winglucofacts.com/cables/ 706 * http://winglucofacts.com/cables/
708 */ 707 */
@@ -1024,3 +1023,12 @@
1024#define MJSG_SR_RADIO_PID 0x9379 1023#define MJSG_SR_RADIO_PID 0x9379
1025#define MJSG_XM_RADIO_PID 0x937A 1024#define MJSG_XM_RADIO_PID 0x937A
1026#define MJSG_HD_RADIO_PID 0x937C 1025#define MJSG_HD_RADIO_PID 0x937C
1026
1027/*
1028 * Xverve Signalyzer tools (http://www.signalyzer.com/)
1029 */
1030#define XVERVE_SIGNALYZER_ST_PID 0xBCA0
1031#define XVERVE_SIGNALYZER_SLITE_PID 0xBCA1
1032#define XVERVE_SIGNALYZER_SH2_PID 0xBCA2
1033#define XVERVE_SIGNALYZER_SH4_PID 0xBCA4
1034
diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c
index e280ad8e12f7..5cd30e4345c6 100644
--- a/drivers/usb/serial/option.c
+++ b/drivers/usb/serial/option.c
@@ -206,6 +206,7 @@ static void option_instat_callback(struct urb *urb);
206#define AMOI_PRODUCT_H01 0x0800 206#define AMOI_PRODUCT_H01 0x0800
207#define AMOI_PRODUCT_H01A 0x7002 207#define AMOI_PRODUCT_H01A 0x7002
208#define AMOI_PRODUCT_H02 0x0802 208#define AMOI_PRODUCT_H02 0x0802
209#define AMOI_PRODUCT_SKYPEPHONE_S2 0x0407
209 210
210#define DELL_VENDOR_ID 0x413C 211#define DELL_VENDOR_ID 0x413C
211 212
@@ -302,6 +303,7 @@ static void option_instat_callback(struct urb *urb);
302#define QISDA_PRODUCT_H21_4512 0x4512 303#define QISDA_PRODUCT_H21_4512 0x4512
303#define QISDA_PRODUCT_H21_4523 0x4523 304#define QISDA_PRODUCT_H21_4523 0x4523
304#define QISDA_PRODUCT_H20_4515 0x4515 305#define QISDA_PRODUCT_H20_4515 0x4515
306#define QISDA_PRODUCT_H20_4518 0x4518
305#define QISDA_PRODUCT_H20_4519 0x4519 307#define QISDA_PRODUCT_H20_4519 0x4519
306 308
307/* TLAYTECH PRODUCTS */ 309/* TLAYTECH PRODUCTS */
@@ -516,6 +518,7 @@ static const struct usb_device_id option_ids[] = {
516 { USB_DEVICE(AMOI_VENDOR_ID, AMOI_PRODUCT_H01) }, 518 { USB_DEVICE(AMOI_VENDOR_ID, AMOI_PRODUCT_H01) },
517 { USB_DEVICE(AMOI_VENDOR_ID, AMOI_PRODUCT_H01A) }, 519 { USB_DEVICE(AMOI_VENDOR_ID, AMOI_PRODUCT_H01A) },
518 { USB_DEVICE(AMOI_VENDOR_ID, AMOI_PRODUCT_H02) }, 520 { USB_DEVICE(AMOI_VENDOR_ID, AMOI_PRODUCT_H02) },
521 { USB_DEVICE(AMOI_VENDOR_ID, AMOI_PRODUCT_SKYPEPHONE_S2) },
519 522
520 { USB_DEVICE(DELL_VENDOR_ID, DELL_PRODUCT_5700_MINICARD) }, /* Dell Wireless 5700 Mobile Broadband CDMA/EVDO Mini-Card == Novatel Expedite EV620 CDMA/EV-DO */ 523 { USB_DEVICE(DELL_VENDOR_ID, DELL_PRODUCT_5700_MINICARD) }, /* Dell Wireless 5700 Mobile Broadband CDMA/EVDO Mini-Card == Novatel Expedite EV620 CDMA/EV-DO */
521 { USB_DEVICE(DELL_VENDOR_ID, DELL_PRODUCT_5500_MINICARD) }, /* Dell Wireless 5500 Mobile Broadband HSDPA Mini-Card == Novatel Expedite EU740 HSDPA/3G */ 524 { USB_DEVICE(DELL_VENDOR_ID, DELL_PRODUCT_5500_MINICARD) }, /* Dell Wireless 5500 Mobile Broadband HSDPA Mini-Card == Novatel Expedite EU740 HSDPA/3G */
@@ -852,6 +855,7 @@ static const struct usb_device_id option_ids[] = {
852 { USB_DEVICE(QISDA_VENDOR_ID, QISDA_PRODUCT_H21_4512) }, 855 { USB_DEVICE(QISDA_VENDOR_ID, QISDA_PRODUCT_H21_4512) },
853 { USB_DEVICE(QISDA_VENDOR_ID, QISDA_PRODUCT_H21_4523) }, 856 { USB_DEVICE(QISDA_VENDOR_ID, QISDA_PRODUCT_H21_4523) },
854 { USB_DEVICE(QISDA_VENDOR_ID, QISDA_PRODUCT_H20_4515) }, 857 { USB_DEVICE(QISDA_VENDOR_ID, QISDA_PRODUCT_H20_4515) },
858 { USB_DEVICE(QISDA_VENDOR_ID, QISDA_PRODUCT_H20_4518) },
855 { USB_DEVICE(QISDA_VENDOR_ID, QISDA_PRODUCT_H20_4519) }, 859 { USB_DEVICE(QISDA_VENDOR_ID, QISDA_PRODUCT_H20_4519) },
856 { USB_DEVICE(TOSHIBA_VENDOR_ID, TOSHIBA_PRODUCT_G450) }, 860 { USB_DEVICE(TOSHIBA_VENDOR_ID, TOSHIBA_PRODUCT_G450) },
857 { USB_DEVICE(TOSHIBA_VENDOR_ID, TOSHIBA_PRODUCT_HSDPA_MINICARD ) }, /* Toshiba 3G HSDPA == Novatel Expedite EU870D MiniCard */ 861 { USB_DEVICE(TOSHIBA_VENDOR_ID, TOSHIBA_PRODUCT_HSDPA_MINICARD ) }, /* Toshiba 3G HSDPA == Novatel Expedite EU870D MiniCard */
diff --git a/drivers/usb/serial/qcserial.c b/drivers/usb/serial/qcserial.c
index 04bb759536bb..cde67cacb2c3 100644
--- a/drivers/usb/serial/qcserial.c
+++ b/drivers/usb/serial/qcserial.c
@@ -51,6 +51,8 @@ static const struct usb_device_id id_table[] = {
51 {USB_DEVICE(0x1f45, 0x0001)}, /* Unknown Gobi QDL device */ 51 {USB_DEVICE(0x1f45, 0x0001)}, /* Unknown Gobi QDL device */
52 {USB_DEVICE(0x413c, 0x8185)}, /* Dell Gobi 2000 QDL device (N0218, VU936) */ 52 {USB_DEVICE(0x413c, 0x8185)}, /* Dell Gobi 2000 QDL device (N0218, VU936) */
53 {USB_DEVICE(0x413c, 0x8186)}, /* Dell Gobi 2000 Modem device (N0218, VU936) */ 53 {USB_DEVICE(0x413c, 0x8186)}, /* Dell Gobi 2000 Modem device (N0218, VU936) */
54 {USB_DEVICE(0x05c6, 0x9208)}, /* Generic Gobi 2000 QDL device */
55 {USB_DEVICE(0x05c6, 0x920b)}, /* Generic Gobi 2000 Modem device */
54 {USB_DEVICE(0x05c6, 0x9224)}, /* Sony Gobi 2000 QDL device (N0279, VU730) */ 56 {USB_DEVICE(0x05c6, 0x9224)}, /* Sony Gobi 2000 QDL device (N0279, VU730) */
55 {USB_DEVICE(0x05c6, 0x9225)}, /* Sony Gobi 2000 Modem device (N0279, VU730) */ 57 {USB_DEVICE(0x05c6, 0x9225)}, /* Sony Gobi 2000 Modem device (N0279, VU730) */
56 {USB_DEVICE(0x05c6, 0x9244)}, /* Samsung Gobi 2000 QDL device (VL176) */ 58 {USB_DEVICE(0x05c6, 0x9244)}, /* Samsung Gobi 2000 QDL device (VL176) */
@@ -139,6 +141,7 @@ static int qcprobe(struct usb_serial *serial, const struct usb_device_id *id)
139 "Could not set interface, error %d\n", 141 "Could not set interface, error %d\n",
140 retval); 142 retval);
141 retval = -ENODEV; 143 retval = -ENODEV;
144 kfree(data);
142 } 145 }
143 return retval; 146 return retval;
144 } 147 }
@@ -155,6 +158,7 @@ static int qcprobe(struct usb_serial *serial, const struct usb_device_id *id)
155 "Could not set interface, error %d\n", 158 "Could not set interface, error %d\n",
156 retval); 159 retval);
157 retval = -ENODEV; 160 retval = -ENODEV;
161 kfree(data);
158 } 162 }
159 return retval; 163 return retval;
160 } 164 }
@@ -163,6 +167,7 @@ static int qcprobe(struct usb_serial *serial, const struct usb_device_id *id)
163 default: 167 default:
164 dev_err(&serial->dev->dev, 168 dev_err(&serial->dev->dev,
165 "unknown number of interfaces: %d\n", nintf); 169 "unknown number of interfaces: %d\n", nintf);
170 kfree(data);
166 return -ENODEV; 171 return -ENODEV;
167 } 172 }
168 173
diff --git a/drivers/usb/serial/sierra.c b/drivers/usb/serial/sierra.c
index ef0bdb08d788..d47b56e9e8ce 100644
--- a/drivers/usb/serial/sierra.c
+++ b/drivers/usb/serial/sierra.c
@@ -245,6 +245,7 @@ static const struct usb_device_id id_table[] = {
245 { USB_DEVICE(0x1199, 0x0021) }, /* Sierra Wireless AirCard 597E */ 245 { USB_DEVICE(0x1199, 0x0021) }, /* Sierra Wireless AirCard 597E */
246 { USB_DEVICE(0x1199, 0x0112) }, /* Sierra Wireless AirCard 580 */ 246 { USB_DEVICE(0x1199, 0x0112) }, /* Sierra Wireless AirCard 580 */
247 { USB_DEVICE(0x1199, 0x0120) }, /* Sierra Wireless USB Dongle 595U */ 247 { USB_DEVICE(0x1199, 0x0120) }, /* Sierra Wireless USB Dongle 595U */
248 { USB_DEVICE(0x1199, 0x0301) }, /* Sierra Wireless USB Dongle 250U */
248 /* Sierra Wireless C597 */ 249 /* Sierra Wireless C597 */
249 { USB_DEVICE_AND_INTERFACE_INFO(0x1199, 0x0023, 0xFF, 0xFF, 0xFF) }, 250 { USB_DEVICE_AND_INTERFACE_INFO(0x1199, 0x0023, 0xFF, 0xFF, 0xFF) },
250 /* Sierra Wireless T598 */ 251 /* Sierra Wireless T598 */
diff --git a/drivers/usb/storage/transport.c b/drivers/usb/storage/transport.c
index 44716427c51c..64ec073e89de 100644
--- a/drivers/usb/storage/transport.c
+++ b/drivers/usb/storage/transport.c
@@ -139,9 +139,7 @@ static int usb_stor_msg_common(struct us_data *us, int timeout)
139 139
140 /* fill the common fields in the URB */ 140 /* fill the common fields in the URB */
141 us->current_urb->context = &urb_done; 141 us->current_urb->context = &urb_done;
142 us->current_urb->actual_length = 0; 142 us->current_urb->transfer_flags = 0;
143 us->current_urb->error_count = 0;
144 us->current_urb->status = 0;
145 143
146 /* we assume that if transfer_buffer isn't us->iobuf then it 144 /* we assume that if transfer_buffer isn't us->iobuf then it
147 * hasn't been mapped for DMA. Yes, this is clunky, but it's 145 * hasn't been mapped for DMA. Yes, this is clunky, but it's
diff --git a/drivers/vhost/net.c b/drivers/vhost/net.c
index df5b6b971f26..d219070fed3d 100644
--- a/drivers/vhost/net.c
+++ b/drivers/vhost/net.c
@@ -98,7 +98,8 @@ static void tx_poll_start(struct vhost_net *net, struct socket *sock)
98static void handle_tx(struct vhost_net *net) 98static void handle_tx(struct vhost_net *net)
99{ 99{
100 struct vhost_virtqueue *vq = &net->dev.vqs[VHOST_NET_VQ_TX]; 100 struct vhost_virtqueue *vq = &net->dev.vqs[VHOST_NET_VQ_TX];
101 unsigned head, out, in, s; 101 unsigned out, in, s;
102 int head;
102 struct msghdr msg = { 103 struct msghdr msg = {
103 .msg_name = NULL, 104 .msg_name = NULL,
104 .msg_namelen = 0, 105 .msg_namelen = 0,
@@ -135,6 +136,9 @@ static void handle_tx(struct vhost_net *net)
135 ARRAY_SIZE(vq->iov), 136 ARRAY_SIZE(vq->iov),
136 &out, &in, 137 &out, &in,
137 NULL, NULL); 138 NULL, NULL);
139 /* On error, stop handling until the next kick. */
140 if (unlikely(head < 0))
141 break;
138 /* Nothing new? Wait for eventfd to tell us they refilled. */ 142 /* Nothing new? Wait for eventfd to tell us they refilled. */
139 if (head == vq->num) { 143 if (head == vq->num) {
140 wmem = atomic_read(&sock->sk->sk_wmem_alloc); 144 wmem = atomic_read(&sock->sk->sk_wmem_alloc);
@@ -173,8 +177,8 @@ static void handle_tx(struct vhost_net *net)
173 break; 177 break;
174 } 178 }
175 if (err != len) 179 if (err != len)
176 pr_err("Truncated TX packet: " 180 pr_debug("Truncated TX packet: "
177 " len %d != %zd\n", err, len); 181 " len %d != %zd\n", err, len);
178 vhost_add_used_and_signal(&net->dev, vq, head, 0); 182 vhost_add_used_and_signal(&net->dev, vq, head, 0);
179 total_len += len; 183 total_len += len;
180 if (unlikely(total_len >= VHOST_NET_WEIGHT)) { 184 if (unlikely(total_len >= VHOST_NET_WEIGHT)) {
@@ -192,7 +196,8 @@ static void handle_tx(struct vhost_net *net)
192static void handle_rx(struct vhost_net *net) 196static void handle_rx(struct vhost_net *net)
193{ 197{
194 struct vhost_virtqueue *vq = &net->dev.vqs[VHOST_NET_VQ_RX]; 198 struct vhost_virtqueue *vq = &net->dev.vqs[VHOST_NET_VQ_RX];
195 unsigned head, out, in, log, s; 199 unsigned out, in, log, s;
200 int head;
196 struct vhost_log *vq_log; 201 struct vhost_log *vq_log;
197 struct msghdr msg = { 202 struct msghdr msg = {
198 .msg_name = NULL, 203 .msg_name = NULL,
@@ -228,6 +233,9 @@ static void handle_rx(struct vhost_net *net)
228 ARRAY_SIZE(vq->iov), 233 ARRAY_SIZE(vq->iov),
229 &out, &in, 234 &out, &in,
230 vq_log, &log); 235 vq_log, &log);
236 /* On error, stop handling until the next kick. */
237 if (unlikely(head < 0))
238 break;
231 /* OK, now we need to know about added descriptors. */ 239 /* OK, now we need to know about added descriptors. */
232 if (head == vq->num) { 240 if (head == vq->num) {
233 if (unlikely(vhost_enable_notify(vq))) { 241 if (unlikely(vhost_enable_notify(vq))) {
@@ -267,8 +275,8 @@ static void handle_rx(struct vhost_net *net)
267 } 275 }
268 /* TODO: Should check and handle checksum. */ 276 /* TODO: Should check and handle checksum. */
269 if (err > len) { 277 if (err > len) {
270 pr_err("Discarded truncated rx packet: " 278 pr_debug("Discarded truncated rx packet: "
271 " len %d > %zd\n", err, len); 279 " len %d > %zd\n", err, len);
272 vhost_discard_vq_desc(vq); 280 vhost_discard_vq_desc(vq);
273 continue; 281 continue;
274 } 282 }
@@ -526,11 +534,16 @@ static long vhost_net_set_backend(struct vhost_net *n, unsigned index, int fd)
526 rcu_assign_pointer(vq->private_data, sock); 534 rcu_assign_pointer(vq->private_data, sock);
527 vhost_net_enable_vq(n, vq); 535 vhost_net_enable_vq(n, vq);
528done: 536done:
537 mutex_unlock(&vq->mutex);
538
529 if (oldsock) { 539 if (oldsock) {
530 vhost_net_flush_vq(n, index); 540 vhost_net_flush_vq(n, index);
531 fput(oldsock->file); 541 fput(oldsock->file);
532 } 542 }
533 543
544 mutex_unlock(&n->dev.mutex);
545 return 0;
546
534err_vq: 547err_vq:
535 mutex_unlock(&vq->mutex); 548 mutex_unlock(&vq->mutex);
536err: 549err:
diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c
index 3b83382e06eb..0b99783083f6 100644
--- a/drivers/vhost/vhost.c
+++ b/drivers/vhost/vhost.c
@@ -736,12 +736,12 @@ static int translate_desc(struct vhost_dev *dev, u64 addr, u32 len,
736 mem = rcu_dereference(dev->memory); 736 mem = rcu_dereference(dev->memory);
737 while ((u64)len > s) { 737 while ((u64)len > s) {
738 u64 size; 738 u64 size;
739 if (ret >= iov_size) { 739 if (unlikely(ret >= iov_size)) {
740 ret = -ENOBUFS; 740 ret = -ENOBUFS;
741 break; 741 break;
742 } 742 }
743 reg = find_region(mem, addr, len); 743 reg = find_region(mem, addr, len);
744 if (!reg) { 744 if (unlikely(!reg)) {
745 ret = -EFAULT; 745 ret = -EFAULT;
746 break; 746 break;
747 } 747 }
@@ -780,18 +780,18 @@ static unsigned next_desc(struct vring_desc *desc)
780 return next; 780 return next;
781} 781}
782 782
783static unsigned get_indirect(struct vhost_dev *dev, struct vhost_virtqueue *vq, 783static int get_indirect(struct vhost_dev *dev, struct vhost_virtqueue *vq,
784 struct iovec iov[], unsigned int iov_size, 784 struct iovec iov[], unsigned int iov_size,
785 unsigned int *out_num, unsigned int *in_num, 785 unsigned int *out_num, unsigned int *in_num,
786 struct vhost_log *log, unsigned int *log_num, 786 struct vhost_log *log, unsigned int *log_num,
787 struct vring_desc *indirect) 787 struct vring_desc *indirect)
788{ 788{
789 struct vring_desc desc; 789 struct vring_desc desc;
790 unsigned int i = 0, count, found = 0; 790 unsigned int i = 0, count, found = 0;
791 int ret; 791 int ret;
792 792
793 /* Sanity check */ 793 /* Sanity check */
794 if (indirect->len % sizeof desc) { 794 if (unlikely(indirect->len % sizeof desc)) {
795 vq_err(vq, "Invalid length in indirect descriptor: " 795 vq_err(vq, "Invalid length in indirect descriptor: "
796 "len 0x%llx not multiple of 0x%zx\n", 796 "len 0x%llx not multiple of 0x%zx\n",
797 (unsigned long long)indirect->len, 797 (unsigned long long)indirect->len,
@@ -801,7 +801,7 @@ static unsigned get_indirect(struct vhost_dev *dev, struct vhost_virtqueue *vq,
801 801
802 ret = translate_desc(dev, indirect->addr, indirect->len, vq->indirect, 802 ret = translate_desc(dev, indirect->addr, indirect->len, vq->indirect,
803 ARRAY_SIZE(vq->indirect)); 803 ARRAY_SIZE(vq->indirect));
804 if (ret < 0) { 804 if (unlikely(ret < 0)) {
805 vq_err(vq, "Translation failure %d in indirect.\n", ret); 805 vq_err(vq, "Translation failure %d in indirect.\n", ret);
806 return ret; 806 return ret;
807 } 807 }
@@ -813,7 +813,7 @@ static unsigned get_indirect(struct vhost_dev *dev, struct vhost_virtqueue *vq,
813 count = indirect->len / sizeof desc; 813 count = indirect->len / sizeof desc;
814 /* Buffers are chained via a 16 bit next field, so 814 /* Buffers are chained via a 16 bit next field, so
815 * we can have at most 2^16 of these. */ 815 * we can have at most 2^16 of these. */
816 if (count > USHRT_MAX + 1) { 816 if (unlikely(count > USHRT_MAX + 1)) {
817 vq_err(vq, "Indirect buffer length too big: %d\n", 817 vq_err(vq, "Indirect buffer length too big: %d\n",
818 indirect->len); 818 indirect->len);
819 return -E2BIG; 819 return -E2BIG;
@@ -821,19 +821,19 @@ static unsigned get_indirect(struct vhost_dev *dev, struct vhost_virtqueue *vq,
821 821
822 do { 822 do {
823 unsigned iov_count = *in_num + *out_num; 823 unsigned iov_count = *in_num + *out_num;
824 if (++found > count) { 824 if (unlikely(++found > count)) {
825 vq_err(vq, "Loop detected: last one at %u " 825 vq_err(vq, "Loop detected: last one at %u "
826 "indirect size %u\n", 826 "indirect size %u\n",
827 i, count); 827 i, count);
828 return -EINVAL; 828 return -EINVAL;
829 } 829 }
830 if (memcpy_fromiovec((unsigned char *)&desc, vq->indirect, 830 if (unlikely(memcpy_fromiovec((unsigned char *)&desc, vq->indirect,
831 sizeof desc)) { 831 sizeof desc))) {
832 vq_err(vq, "Failed indirect descriptor: idx %d, %zx\n", 832 vq_err(vq, "Failed indirect descriptor: idx %d, %zx\n",
833 i, (size_t)indirect->addr + i * sizeof desc); 833 i, (size_t)indirect->addr + i * sizeof desc);
834 return -EINVAL; 834 return -EINVAL;
835 } 835 }
836 if (desc.flags & VRING_DESC_F_INDIRECT) { 836 if (unlikely(desc.flags & VRING_DESC_F_INDIRECT)) {
837 vq_err(vq, "Nested indirect descriptor: idx %d, %zx\n", 837 vq_err(vq, "Nested indirect descriptor: idx %d, %zx\n",
838 i, (size_t)indirect->addr + i * sizeof desc); 838 i, (size_t)indirect->addr + i * sizeof desc);
839 return -EINVAL; 839 return -EINVAL;
@@ -841,7 +841,7 @@ static unsigned get_indirect(struct vhost_dev *dev, struct vhost_virtqueue *vq,
841 841
842 ret = translate_desc(dev, desc.addr, desc.len, iov + iov_count, 842 ret = translate_desc(dev, desc.addr, desc.len, iov + iov_count,
843 iov_size - iov_count); 843 iov_size - iov_count);
844 if (ret < 0) { 844 if (unlikely(ret < 0)) {
845 vq_err(vq, "Translation failure %d indirect idx %d\n", 845 vq_err(vq, "Translation failure %d indirect idx %d\n",
846 ret, i); 846 ret, i);
847 return ret; 847 return ret;
@@ -857,7 +857,7 @@ static unsigned get_indirect(struct vhost_dev *dev, struct vhost_virtqueue *vq,
857 } else { 857 } else {
858 /* If it's an output descriptor, they're all supposed 858 /* If it's an output descriptor, they're all supposed
859 * to come before any input descriptors. */ 859 * to come before any input descriptors. */
860 if (*in_num) { 860 if (unlikely(*in_num)) {
861 vq_err(vq, "Indirect descriptor " 861 vq_err(vq, "Indirect descriptor "
862 "has out after in: idx %d\n", i); 862 "has out after in: idx %d\n", i);
863 return -EINVAL; 863 return -EINVAL;
@@ -873,12 +873,13 @@ static unsigned get_indirect(struct vhost_dev *dev, struct vhost_virtqueue *vq,
873 * number of output then some number of input descriptors, it's actually two 873 * number of output then some number of input descriptors, it's actually two
874 * iovecs, but we pack them into one and note how many of each there were. 874 * iovecs, but we pack them into one and note how many of each there were.
875 * 875 *
876 * This function returns the descriptor number found, or vq->num (which 876 * This function returns the descriptor number found, or vq->num (which is
877 * is never a valid descriptor number) if none was found. */ 877 * never a valid descriptor number) if none was found. A negative code is
878unsigned vhost_get_vq_desc(struct vhost_dev *dev, struct vhost_virtqueue *vq, 878 * returned on error. */
879 struct iovec iov[], unsigned int iov_size, 879int vhost_get_vq_desc(struct vhost_dev *dev, struct vhost_virtqueue *vq,
880 unsigned int *out_num, unsigned int *in_num, 880 struct iovec iov[], unsigned int iov_size,
881 struct vhost_log *log, unsigned int *log_num) 881 unsigned int *out_num, unsigned int *in_num,
882 struct vhost_log *log, unsigned int *log_num)
882{ 883{
883 struct vring_desc desc; 884 struct vring_desc desc;
884 unsigned int i, head, found = 0; 885 unsigned int i, head, found = 0;
@@ -887,16 +888,16 @@ unsigned vhost_get_vq_desc(struct vhost_dev *dev, struct vhost_virtqueue *vq,
887 888
888 /* Check it isn't doing very strange things with descriptor numbers. */ 889 /* Check it isn't doing very strange things with descriptor numbers. */
889 last_avail_idx = vq->last_avail_idx; 890 last_avail_idx = vq->last_avail_idx;
890 if (get_user(vq->avail_idx, &vq->avail->idx)) { 891 if (unlikely(get_user(vq->avail_idx, &vq->avail->idx))) {
891 vq_err(vq, "Failed to access avail idx at %p\n", 892 vq_err(vq, "Failed to access avail idx at %p\n",
892 &vq->avail->idx); 893 &vq->avail->idx);
893 return vq->num; 894 return -EFAULT;
894 } 895 }
895 896
896 if ((u16)(vq->avail_idx - last_avail_idx) > vq->num) { 897 if (unlikely((u16)(vq->avail_idx - last_avail_idx) > vq->num)) {
897 vq_err(vq, "Guest moved used index from %u to %u", 898 vq_err(vq, "Guest moved used index from %u to %u",
898 last_avail_idx, vq->avail_idx); 899 last_avail_idx, vq->avail_idx);
899 return vq->num; 900 return -EFAULT;
900 } 901 }
901 902
902 /* If there's nothing new since last we looked, return invalid. */ 903 /* If there's nothing new since last we looked, return invalid. */
@@ -908,18 +909,19 @@ unsigned vhost_get_vq_desc(struct vhost_dev *dev, struct vhost_virtqueue *vq,
908 909
909 /* Grab the next descriptor number they're advertising, and increment 910 /* Grab the next descriptor number they're advertising, and increment
910 * the index we've seen. */ 911 * the index we've seen. */
911 if (get_user(head, &vq->avail->ring[last_avail_idx % vq->num])) { 912 if (unlikely(get_user(head,
913 &vq->avail->ring[last_avail_idx % vq->num]))) {
912 vq_err(vq, "Failed to read head: idx %d address %p\n", 914 vq_err(vq, "Failed to read head: idx %d address %p\n",
913 last_avail_idx, 915 last_avail_idx,
914 &vq->avail->ring[last_avail_idx % vq->num]); 916 &vq->avail->ring[last_avail_idx % vq->num]);
915 return vq->num; 917 return -EFAULT;
916 } 918 }
917 919
918 /* If their number is silly, that's an error. */ 920 /* If their number is silly, that's an error. */
919 if (head >= vq->num) { 921 if (unlikely(head >= vq->num)) {
920 vq_err(vq, "Guest says index %u > %u is available", 922 vq_err(vq, "Guest says index %u > %u is available",
921 head, vq->num); 923 head, vq->num);
922 return vq->num; 924 return -EINVAL;
923 } 925 }
924 926
925 /* When we start there are none of either input nor output. */ 927 /* When we start there are none of either input nor output. */
@@ -930,41 +932,41 @@ unsigned vhost_get_vq_desc(struct vhost_dev *dev, struct vhost_virtqueue *vq,
930 i = head; 932 i = head;
931 do { 933 do {
932 unsigned iov_count = *in_num + *out_num; 934 unsigned iov_count = *in_num + *out_num;
933 if (i >= vq->num) { 935 if (unlikely(i >= vq->num)) {
934 vq_err(vq, "Desc index is %u > %u, head = %u", 936 vq_err(vq, "Desc index is %u > %u, head = %u",
935 i, vq->num, head); 937 i, vq->num, head);
936 return vq->num; 938 return -EINVAL;
937 } 939 }
938 if (++found > vq->num) { 940 if (unlikely(++found > vq->num)) {
939 vq_err(vq, "Loop detected: last one at %u " 941 vq_err(vq, "Loop detected: last one at %u "
940 "vq size %u head %u\n", 942 "vq size %u head %u\n",
941 i, vq->num, head); 943 i, vq->num, head);
942 return vq->num; 944 return -EINVAL;
943 } 945 }
944 ret = copy_from_user(&desc, vq->desc + i, sizeof desc); 946 ret = copy_from_user(&desc, vq->desc + i, sizeof desc);
945 if (ret) { 947 if (unlikely(ret)) {
946 vq_err(vq, "Failed to get descriptor: idx %d addr %p\n", 948 vq_err(vq, "Failed to get descriptor: idx %d addr %p\n",
947 i, vq->desc + i); 949 i, vq->desc + i);
948 return vq->num; 950 return -EFAULT;
949 } 951 }
950 if (desc.flags & VRING_DESC_F_INDIRECT) { 952 if (desc.flags & VRING_DESC_F_INDIRECT) {
951 ret = get_indirect(dev, vq, iov, iov_size, 953 ret = get_indirect(dev, vq, iov, iov_size,
952 out_num, in_num, 954 out_num, in_num,
953 log, log_num, &desc); 955 log, log_num, &desc);
954 if (ret < 0) { 956 if (unlikely(ret < 0)) {
955 vq_err(vq, "Failure detected " 957 vq_err(vq, "Failure detected "
956 "in indirect descriptor at idx %d\n", i); 958 "in indirect descriptor at idx %d\n", i);
957 return vq->num; 959 return ret;
958 } 960 }
959 continue; 961 continue;
960 } 962 }
961 963
962 ret = translate_desc(dev, desc.addr, desc.len, iov + iov_count, 964 ret = translate_desc(dev, desc.addr, desc.len, iov + iov_count,
963 iov_size - iov_count); 965 iov_size - iov_count);
964 if (ret < 0) { 966 if (unlikely(ret < 0)) {
965 vq_err(vq, "Translation failure %d descriptor idx %d\n", 967 vq_err(vq, "Translation failure %d descriptor idx %d\n",
966 ret, i); 968 ret, i);
967 return vq->num; 969 return ret;
968 } 970 }
969 if (desc.flags & VRING_DESC_F_WRITE) { 971 if (desc.flags & VRING_DESC_F_WRITE) {
970 /* If this is an input descriptor, 972 /* If this is an input descriptor,
@@ -978,10 +980,10 @@ unsigned vhost_get_vq_desc(struct vhost_dev *dev, struct vhost_virtqueue *vq,
978 } else { 980 } else {
979 /* If it's an output descriptor, they're all supposed 981 /* If it's an output descriptor, they're all supposed
980 * to come before any input descriptors. */ 982 * to come before any input descriptors. */
981 if (*in_num) { 983 if (unlikely(*in_num)) {
982 vq_err(vq, "Descriptor has out after in: " 984 vq_err(vq, "Descriptor has out after in: "
983 "idx %d\n", i); 985 "idx %d\n", i);
984 return vq->num; 986 return -EINVAL;
985 } 987 }
986 *out_num += ret; 988 *out_num += ret;
987 } 989 }
diff --git a/drivers/vhost/vhost.h b/drivers/vhost/vhost.h
index 44591ba9b07a..11ee13dba0f7 100644
--- a/drivers/vhost/vhost.h
+++ b/drivers/vhost/vhost.h
@@ -120,10 +120,10 @@ long vhost_dev_ioctl(struct vhost_dev *, unsigned int ioctl, unsigned long arg);
120int vhost_vq_access_ok(struct vhost_virtqueue *vq); 120int vhost_vq_access_ok(struct vhost_virtqueue *vq);
121int vhost_log_access_ok(struct vhost_dev *); 121int vhost_log_access_ok(struct vhost_dev *);
122 122
123unsigned vhost_get_vq_desc(struct vhost_dev *, struct vhost_virtqueue *, 123int vhost_get_vq_desc(struct vhost_dev *, struct vhost_virtqueue *,
124 struct iovec iov[], unsigned int iov_count, 124 struct iovec iov[], unsigned int iov_count,
125 unsigned int *out_num, unsigned int *in_num, 125 unsigned int *out_num, unsigned int *in_num,
126 struct vhost_log *log, unsigned int *log_num); 126 struct vhost_log *log, unsigned int *log_num);
127void vhost_discard_vq_desc(struct vhost_virtqueue *); 127void vhost_discard_vq_desc(struct vhost_virtqueue *);
128 128
129int vhost_add_used(struct vhost_virtqueue *, unsigned int head, int len); 129int vhost_add_used(struct vhost_virtqueue *, unsigned int head, int len);
diff --git a/drivers/video/aty/radeon_pm.c b/drivers/video/aty/radeon_pm.c
index 515cf1978d19..c4e17642d9c5 100644
--- a/drivers/video/aty/radeon_pm.c
+++ b/drivers/video/aty/radeon_pm.c
@@ -2872,7 +2872,7 @@ void radeonfb_pm_init(struct radeonfb_info *rinfo, int dynclk, int ignore_devlis
2872 } 2872 }
2873 2873
2874#if 0 2874#if 0
2875 /* Power down TV DAC, taht saves a significant amount of power, 2875 /* Power down TV DAC, that saves a significant amount of power,
2876 * we'll have something better once we actually have some TVOut 2876 * we'll have something better once we actually have some TVOut
2877 * support 2877 * support
2878 */ 2878 */
diff --git a/drivers/video/au1100fb.c b/drivers/video/au1100fb.c
index 40f61320ce16..34b2fc472fe8 100644
--- a/drivers/video/au1100fb.c
+++ b/drivers/video/au1100fb.c
@@ -95,7 +95,7 @@ struct fb_bitfield rgb_bitfields[][4] =
95 { { 8, 4, 0 }, { 4, 4, 0 }, { 0, 4, 0 }, { 0, 0, 0 } }, 95 { { 8, 4, 0 }, { 4, 4, 0 }, { 0, 4, 0 }, { 0, 0, 0 } },
96}; 96};
97 97
98static struct fb_fix_screeninfo au1100fb_fix __initdata = { 98static struct fb_fix_screeninfo au1100fb_fix __devinitdata = {
99 .id = "AU1100 FB", 99 .id = "AU1100 FB",
100 .xpanstep = 1, 100 .xpanstep = 1,
101 .ypanstep = 1, 101 .ypanstep = 1,
@@ -103,7 +103,7 @@ static struct fb_fix_screeninfo au1100fb_fix __initdata = {
103 .accel = FB_ACCEL_NONE, 103 .accel = FB_ACCEL_NONE,
104}; 104};
105 105
106static struct fb_var_screeninfo au1100fb_var __initdata = { 106static struct fb_var_screeninfo au1100fb_var __devinitdata = {
107 .activate = FB_ACTIVATE_NOW, 107 .activate = FB_ACTIVATE_NOW,
108 .height = -1, 108 .height = -1,
109 .width = -1, 109 .width = -1,
@@ -458,7 +458,7 @@ static struct fb_ops au1100fb_ops =
458 458
459/* AU1100 LCD controller device driver */ 459/* AU1100 LCD controller device driver */
460 460
461static int __init au1100fb_drv_probe(struct platform_device *dev) 461static int __devinit au1100fb_drv_probe(struct platform_device *dev)
462{ 462{
463 struct au1100fb_device *fbdev = NULL; 463 struct au1100fb_device *fbdev = NULL;
464 struct resource *regs_res; 464 struct resource *regs_res;
diff --git a/drivers/video/cyber2000fb.c b/drivers/video/cyber2000fb.c
index 3a561df2e8a2..0c1afd13ddd3 100644
--- a/drivers/video/cyber2000fb.c
+++ b/drivers/video/cyber2000fb.c
@@ -388,6 +388,7 @@ cyber2000fb_setcolreg(u_int regno, u_int red, u_int green, u_int blue,
388 pseudo_val |= convert_bitfield(red, &var->red); 388 pseudo_val |= convert_bitfield(red, &var->red);
389 pseudo_val |= convert_bitfield(green, &var->green); 389 pseudo_val |= convert_bitfield(green, &var->green);
390 pseudo_val |= convert_bitfield(blue, &var->blue); 390 pseudo_val |= convert_bitfield(blue, &var->blue);
391 ret = 0;
391 break; 392 break;
392 } 393 }
393 394
@@ -436,6 +437,8 @@ static void cyber2000fb_write_ramdac_ctrl(struct cfb_info *cfb)
436 cyber2000fb_writeb(i | 4, 0x3cf, cfb); 437 cyber2000fb_writeb(i | 4, 0x3cf, cfb);
437 cyber2000fb_writeb(val, 0x3c6, cfb); 438 cyber2000fb_writeb(val, 0x3c6, cfb);
438 cyber2000fb_writeb(i, 0x3cf, cfb); 439 cyber2000fb_writeb(i, 0x3cf, cfb);
440 /* prevent card lock-up observed on x86 with CyberPro 2000 */
441 cyber2000fb_readb(0x3cf, cfb);
439} 442}
440 443
441static void cyber2000fb_set_timing(struct cfb_info *cfb, struct par_info *hw) 444static void cyber2000fb_set_timing(struct cfb_info *cfb, struct par_info *hw)
diff --git a/drivers/video/gbefb.c b/drivers/video/gbefb.c
index 7d8c55d7fd28..ca3355e430bf 100644
--- a/drivers/video/gbefb.c
+++ b/drivers/video/gbefb.c
@@ -91,10 +91,10 @@ static uint32_t pseudo_palette[16];
91static uint32_t gbe_cmap[256]; 91static uint32_t gbe_cmap[256];
92static int gbe_turned_on; /* 0 turned off, 1 turned on */ 92static int gbe_turned_on; /* 0 turned off, 1 turned on */
93 93
94static char *mode_option __initdata = NULL; 94static char *mode_option __devinitdata = NULL;
95 95
96/* default CRT mode */ 96/* default CRT mode */
97static struct fb_var_screeninfo default_var_CRT __initdata = { 97static struct fb_var_screeninfo default_var_CRT __devinitdata = {
98 /* 640x480, 60 Hz, Non-Interlaced (25.175 MHz dotclock) */ 98 /* 640x480, 60 Hz, Non-Interlaced (25.175 MHz dotclock) */
99 .xres = 640, 99 .xres = 640,
100 .yres = 480, 100 .yres = 480,
@@ -125,7 +125,7 @@ static struct fb_var_screeninfo default_var_CRT __initdata = {
125}; 125};
126 126
127/* default LCD mode */ 127/* default LCD mode */
128static struct fb_var_screeninfo default_var_LCD __initdata = { 128static struct fb_var_screeninfo default_var_LCD __devinitdata = {
129 /* 1600x1024, 8 bpp */ 129 /* 1600x1024, 8 bpp */
130 .xres = 1600, 130 .xres = 1600,
131 .yres = 1024, 131 .yres = 1024,
@@ -157,7 +157,7 @@ static struct fb_var_screeninfo default_var_LCD __initdata = {
157 157
158/* default modedb mode */ 158/* default modedb mode */
159/* 640x480, 60 Hz, Non-Interlaced (25.172 MHz dotclock) */ 159/* 640x480, 60 Hz, Non-Interlaced (25.172 MHz dotclock) */
160static struct fb_videomode default_mode_CRT __initdata = { 160static struct fb_videomode default_mode_CRT __devinitdata = {
161 .refresh = 60, 161 .refresh = 60,
162 .xres = 640, 162 .xres = 640,
163 .yres = 480, 163 .yres = 480,
@@ -172,7 +172,7 @@ static struct fb_videomode default_mode_CRT __initdata = {
172 .vmode = FB_VMODE_NONINTERLACED, 172 .vmode = FB_VMODE_NONINTERLACED,
173}; 173};
174/* 1600x1024 SGI flatpanel 1600sw */ 174/* 1600x1024 SGI flatpanel 1600sw */
175static struct fb_videomode default_mode_LCD __initdata = { 175static struct fb_videomode default_mode_LCD __devinitdata = {
176 /* 1600x1024, 8 bpp */ 176 /* 1600x1024, 8 bpp */
177 .xres = 1600, 177 .xres = 1600,
178 .yres = 1024, 178 .yres = 1024,
@@ -186,8 +186,8 @@ static struct fb_videomode default_mode_LCD __initdata = {
186 .vmode = FB_VMODE_NONINTERLACED, 186 .vmode = FB_VMODE_NONINTERLACED,
187}; 187};
188 188
189static struct fb_videomode *default_mode __initdata = &default_mode_CRT; 189static struct fb_videomode *default_mode __devinitdata = &default_mode_CRT;
190static struct fb_var_screeninfo *default_var __initdata = &default_var_CRT; 190static struct fb_var_screeninfo *default_var __devinitdata = &default_var_CRT;
191 191
192static int flat_panel_enabled = 0; 192static int flat_panel_enabled = 0;
193 193
@@ -1098,7 +1098,7 @@ static void gbefb_create_sysfs(struct device *dev)
1098 * Initialization 1098 * Initialization
1099 */ 1099 */
1100 1100
1101static int __init gbefb_setup(char *options) 1101static int __devinit gbefb_setup(char *options)
1102{ 1102{
1103 char *this_opt; 1103 char *this_opt;
1104 1104
diff --git a/drivers/video/geode/gxfb_core.c b/drivers/video/geode/gxfb_core.c
index 76e7dac6f259..70b1d9d51c96 100644
--- a/drivers/video/geode/gxfb_core.c
+++ b/drivers/video/geode/gxfb_core.c
@@ -40,7 +40,7 @@ static int vram;
40static int vt_switch; 40static int vt_switch;
41 41
42/* Modes relevant to the GX (taken from modedb.c) */ 42/* Modes relevant to the GX (taken from modedb.c) */
43static struct fb_videomode gx_modedb[] __initdata = { 43static struct fb_videomode gx_modedb[] __devinitdata = {
44 /* 640x480-60 VESA */ 44 /* 640x480-60 VESA */
45 { NULL, 60, 640, 480, 39682, 48, 16, 33, 10, 96, 2, 45 { NULL, 60, 640, 480, 39682, 48, 16, 33, 10, 96, 2,
46 0, FB_VMODE_NONINTERLACED, FB_MODE_IS_VESA }, 46 0, FB_VMODE_NONINTERLACED, FB_MODE_IS_VESA },
@@ -110,14 +110,15 @@ static struct fb_videomode gx_modedb[] __initdata = {
110#ifdef CONFIG_OLPC 110#ifdef CONFIG_OLPC
111#include <asm/olpc.h> 111#include <asm/olpc.h>
112 112
113static struct fb_videomode gx_dcon_modedb[] __initdata = { 113static struct fb_videomode gx_dcon_modedb[] __devinitdata = {
114 /* The only mode the DCON has is 1200x900 */ 114 /* The only mode the DCON has is 1200x900 */
115 { NULL, 50, 1200, 900, 17460, 24, 8, 4, 5, 8, 3, 115 { NULL, 50, 1200, 900, 17460, 24, 8, 4, 5, 8, 3,
116 FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, 116 FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
117 FB_VMODE_NONINTERLACED, 0 } 117 FB_VMODE_NONINTERLACED, 0 }
118}; 118};
119 119
120static void __init get_modedb(struct fb_videomode **modedb, unsigned int *size) 120static void __devinit get_modedb(struct fb_videomode **modedb,
121 unsigned int *size)
121{ 122{
122 if (olpc_has_dcon()) { 123 if (olpc_has_dcon()) {
123 *modedb = (struct fb_videomode *) gx_dcon_modedb; 124 *modedb = (struct fb_videomode *) gx_dcon_modedb;
@@ -129,7 +130,8 @@ static void __init get_modedb(struct fb_videomode **modedb, unsigned int *size)
129} 130}
130 131
131#else 132#else
132static void __init get_modedb(struct fb_videomode **modedb, unsigned int *size) 133static void __devinit get_modedb(struct fb_videomode **modedb,
134 unsigned int *size)
133{ 135{
134 *modedb = (struct fb_videomode *) gx_modedb; 136 *modedb = (struct fb_videomode *) gx_modedb;
135 *size = ARRAY_SIZE(gx_modedb); 137 *size = ARRAY_SIZE(gx_modedb);
@@ -226,7 +228,8 @@ static int gxfb_blank(int blank_mode, struct fb_info *info)
226 return gx_blank_display(info, blank_mode); 228 return gx_blank_display(info, blank_mode);
227} 229}
228 230
229static int __init gxfb_map_video_memory(struct fb_info *info, struct pci_dev *dev) 231static int __devinit gxfb_map_video_memory(struct fb_info *info,
232 struct pci_dev *dev)
230{ 233{
231 struct gxfb_par *par = info->par; 234 struct gxfb_par *par = info->par;
232 int ret; 235 int ret;
@@ -290,7 +293,7 @@ static struct fb_ops gxfb_ops = {
290 .fb_imageblit = cfb_imageblit, 293 .fb_imageblit = cfb_imageblit,
291}; 294};
292 295
293static struct fb_info * __init gxfb_init_fbinfo(struct device *dev) 296static struct fb_info *__devinit gxfb_init_fbinfo(struct device *dev)
294{ 297{
295 struct gxfb_par *par; 298 struct gxfb_par *par;
296 struct fb_info *info; 299 struct fb_info *info;
@@ -371,7 +374,8 @@ static int gxfb_resume(struct pci_dev *pdev)
371} 374}
372#endif 375#endif
373 376
374static int __init gxfb_probe(struct pci_dev *pdev, const struct pci_device_id *id) 377static int __devinit gxfb_probe(struct pci_dev *pdev,
378 const struct pci_device_id *id)
375{ 379{
376 struct gxfb_par *par; 380 struct gxfb_par *par;
377 struct fb_info *info; 381 struct fb_info *info;
@@ -451,7 +455,7 @@ static int __init gxfb_probe(struct pci_dev *pdev, const struct pci_device_id *i
451 return ret; 455 return ret;
452} 456}
453 457
454static void gxfb_remove(struct pci_dev *pdev) 458static void __devexit gxfb_remove(struct pci_dev *pdev)
455{ 459{
456 struct fb_info *info = pci_get_drvdata(pdev); 460 struct fb_info *info = pci_get_drvdata(pdev);
457 struct gxfb_par *par = info->par; 461 struct gxfb_par *par = info->par;
diff --git a/drivers/video/geode/lxfb_core.c b/drivers/video/geode/lxfb_core.c
index 1a18da86d3fa..39bdbedf43b4 100644
--- a/drivers/video/geode/lxfb_core.c
+++ b/drivers/video/geode/lxfb_core.c
@@ -35,7 +35,7 @@ static int vt_switch;
35 * we try to make it something sane - 640x480-60 is sane 35 * we try to make it something sane - 640x480-60 is sane
36 */ 36 */
37 37
38static struct fb_videomode geode_modedb[] __initdata = { 38static struct fb_videomode geode_modedb[] __devinitdata = {
39 /* 640x480-60 */ 39 /* 640x480-60 */
40 { NULL, 60, 640, 480, 39682, 48, 8, 25, 2, 88, 2, 40 { NULL, 60, 640, 480, 39682, 48, 8, 25, 2, 88, 2,
41 FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, 41 FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
@@ -219,14 +219,15 @@ static struct fb_videomode geode_modedb[] __initdata = {
219#ifdef CONFIG_OLPC 219#ifdef CONFIG_OLPC
220#include <asm/olpc.h> 220#include <asm/olpc.h>
221 221
222static struct fb_videomode olpc_dcon_modedb[] __initdata = { 222static struct fb_videomode olpc_dcon_modedb[] __devinitdata = {
223 /* The only mode the DCON has is 1200x900 */ 223 /* The only mode the DCON has is 1200x900 */
224 { NULL, 50, 1200, 900, 17460, 24, 8, 4, 5, 8, 3, 224 { NULL, 50, 1200, 900, 17460, 24, 8, 4, 5, 8, 3,
225 FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, 225 FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
226 FB_VMODE_NONINTERLACED, 0 } 226 FB_VMODE_NONINTERLACED, 0 }
227}; 227};
228 228
229static void __init get_modedb(struct fb_videomode **modedb, unsigned int *size) 229static void __devinit get_modedb(struct fb_videomode **modedb,
230 unsigned int *size)
230{ 231{
231 if (olpc_has_dcon()) { 232 if (olpc_has_dcon()) {
232 *modedb = (struct fb_videomode *) olpc_dcon_modedb; 233 *modedb = (struct fb_videomode *) olpc_dcon_modedb;
@@ -238,7 +239,8 @@ static void __init get_modedb(struct fb_videomode **modedb, unsigned int *size)
238} 239}
239 240
240#else 241#else
241static void __init get_modedb(struct fb_videomode **modedb, unsigned int *size) 242static void __devinit get_modedb(struct fb_videomode **modedb,
243 unsigned int *size)
242{ 244{
243 *modedb = (struct fb_videomode *) geode_modedb; 245 *modedb = (struct fb_videomode *) geode_modedb;
244 *size = ARRAY_SIZE(geode_modedb); 246 *size = ARRAY_SIZE(geode_modedb);
@@ -334,7 +336,7 @@ static int lxfb_blank(int blank_mode, struct fb_info *info)
334} 336}
335 337
336 338
337static int __init lxfb_map_video_memory(struct fb_info *info, 339static int __devinit lxfb_map_video_memory(struct fb_info *info,
338 struct pci_dev *dev) 340 struct pci_dev *dev)
339{ 341{
340 struct lxfb_par *par = info->par; 342 struct lxfb_par *par = info->par;
@@ -412,7 +414,7 @@ static struct fb_ops lxfb_ops = {
412 .fb_imageblit = cfb_imageblit, 414 .fb_imageblit = cfb_imageblit,
413}; 415};
414 416
415static struct fb_info * __init lxfb_init_fbinfo(struct device *dev) 417static struct fb_info * __devinit lxfb_init_fbinfo(struct device *dev)
416{ 418{
417 struct lxfb_par *par; 419 struct lxfb_par *par;
418 struct fb_info *info; 420 struct fb_info *info;
@@ -496,7 +498,7 @@ static int lxfb_resume(struct pci_dev *pdev)
496#define lxfb_resume NULL 498#define lxfb_resume NULL
497#endif 499#endif
498 500
499static int __init lxfb_probe(struct pci_dev *pdev, 501static int __devinit lxfb_probe(struct pci_dev *pdev,
500 const struct pci_device_id *id) 502 const struct pci_device_id *id)
501{ 503{
502 struct lxfb_par *par; 504 struct lxfb_par *par;
@@ -588,7 +590,7 @@ err:
588 return ret; 590 return ret;
589} 591}
590 592
591static void lxfb_remove(struct pci_dev *pdev) 593static void __devexit lxfb_remove(struct pci_dev *pdev)
592{ 594{
593 struct fb_info *info = pci_get_drvdata(pdev); 595 struct fb_info *info = pci_get_drvdata(pdev);
594 struct lxfb_par *par = info->par; 596 struct lxfb_par *par = info->par;
diff --git a/drivers/video/imxfb.c b/drivers/video/imxfb.c
index b4b6deceed15..43f0639b1c10 100644
--- a/drivers/video/imxfb.c
+++ b/drivers/video/imxfb.c
@@ -175,6 +175,7 @@ struct imxfb_info {
175 175
176 struct imx_fb_videomode *mode; 176 struct imx_fb_videomode *mode;
177 int num_modes; 177 int num_modes;
178 struct backlight_device *bl;
178 179
179 void (*lcd_power)(int); 180 void (*lcd_power)(int);
180 void (*backlight_power)(int); 181 void (*backlight_power)(int);
@@ -449,6 +450,73 @@ static int imxfb_set_par(struct fb_info *info)
449 return 0; 450 return 0;
450} 451}
451 452
453
454
455static int imxfb_bl_get_brightness(struct backlight_device *bl)
456{
457 struct imxfb_info *fbi = bl_get_data(bl);
458
459 return readl(fbi->regs + LCDC_PWMR) & 0xFF;
460}
461
462static int imxfb_bl_update_status(struct backlight_device *bl)
463{
464 struct imxfb_info *fbi = bl_get_data(bl);
465 int brightness = bl->props.brightness;
466
467 if (bl->props.power != FB_BLANK_UNBLANK)
468 brightness = 0;
469 if (bl->props.fb_blank != FB_BLANK_UNBLANK)
470 brightness = 0;
471
472 fbi->pwmr = (fbi->pwmr & ~0xFF) | brightness;
473
474 if (bl->props.fb_blank != FB_BLANK_UNBLANK)
475 clk_enable(fbi->clk);
476 writel(fbi->pwmr, fbi->regs + LCDC_PWMR);
477 if (bl->props.fb_blank != FB_BLANK_UNBLANK)
478 clk_disable(fbi->clk);
479
480 return 0;
481}
482
483static const struct backlight_ops imxfb_lcdc_bl_ops = {
484 .update_status = imxfb_bl_update_status,
485 .get_brightness = imxfb_bl_get_brightness,
486};
487
488static void imxfb_init_backlight(struct imxfb_info *fbi)
489{
490 struct backlight_properties props;
491 struct backlight_device *bl;
492
493 if (fbi->bl)
494 return;
495
496 memset(&props, 0, sizeof(struct backlight_properties));
497 props.max_brightness = 0xff;
498 writel(fbi->pwmr, fbi->regs + LCDC_PWMR);
499
500 bl = backlight_device_register("imxfb-bl", &fbi->pdev->dev, fbi,
501 &imxfb_lcdc_bl_ops, &props);
502 if (IS_ERR(bl)) {
503 dev_err(&fbi->pdev->dev, "error %ld on backlight register\n",
504 PTR_ERR(bl));
505 return;
506 }
507
508 fbi->bl = bl;
509 bl->props.power = FB_BLANK_UNBLANK;
510 bl->props.fb_blank = FB_BLANK_UNBLANK;
511 bl->props.brightness = imxfb_bl_get_brightness(bl);
512}
513
514static void imxfb_exit_backlight(struct imxfb_info *fbi)
515{
516 if (fbi->bl)
517 backlight_device_unregister(fbi->bl);
518}
519
452static void imxfb_enable_controller(struct imxfb_info *fbi) 520static void imxfb_enable_controller(struct imxfb_info *fbi)
453{ 521{
454 pr_debug("Enabling LCD controller\n"); 522 pr_debug("Enabling LCD controller\n");
@@ -579,7 +647,6 @@ static int imxfb_activate_var(struct fb_var_screeninfo *var, struct fb_info *inf
579 fbi->regs + LCDC_SIZE); 647 fbi->regs + LCDC_SIZE);
580 648
581 writel(fbi->pcr, fbi->regs + LCDC_PCR); 649 writel(fbi->pcr, fbi->regs + LCDC_PCR);
582 writel(fbi->pwmr, fbi->regs + LCDC_PWMR);
583 writel(fbi->lscr1, fbi->regs + LCDC_LSCR1); 650 writel(fbi->lscr1, fbi->regs + LCDC_LSCR1);
584 writel(fbi->dmacr, fbi->regs + LCDC_DMACR); 651 writel(fbi->dmacr, fbi->regs + LCDC_DMACR);
585 652
@@ -779,6 +846,8 @@ static int __init imxfb_probe(struct platform_device *pdev)
779 } 846 }
780 847
781 imxfb_enable_controller(fbi); 848 imxfb_enable_controller(fbi);
849 fbi->pdev = pdev;
850 imxfb_init_backlight(fbi);
782 851
783 return 0; 852 return 0;
784 853
@@ -816,6 +885,7 @@ static int __devexit imxfb_remove(struct platform_device *pdev)
816 885
817 imxfb_disable_controller(fbi); 886 imxfb_disable_controller(fbi);
818 887
888 imxfb_exit_backlight(fbi);
819 unregister_framebuffer(info); 889 unregister_framebuffer(info);
820 890
821 pdata = pdev->dev.platform_data; 891 pdata = pdev->dev.platform_data;
diff --git a/drivers/video/nuc900fb.c b/drivers/video/nuc900fb.c
index d4cde79ea15e..81687ed26ba9 100644
--- a/drivers/video/nuc900fb.c
+++ b/drivers/video/nuc900fb.c
@@ -596,8 +596,6 @@ static int __devinit nuc900fb_probe(struct platform_device *pdev)
596 goto release_regs; 596 goto release_regs;
597 } 597 }
598 598
599 nuc900_driver_clksrc_div(&pdev->dev, "ext", 0x2);
600
601 fbi->clk = clk_get(&pdev->dev, NULL); 599 fbi->clk = clk_get(&pdev->dev, NULL);
602 if (!fbi->clk || IS_ERR(fbi->clk)) { 600 if (!fbi->clk || IS_ERR(fbi->clk)) {
603 printk(KERN_ERR "nuc900-lcd:failed to get lcd clock source\n"); 601 printk(KERN_ERR "nuc900-lcd:failed to get lcd clock source\n");
diff --git a/drivers/video/omap/lcdc.c b/drivers/video/omap/lcdc.c
index 43ab7d8b66b2..7767338f8b14 100644
--- a/drivers/video/omap/lcdc.c
+++ b/drivers/video/omap/lcdc.c
@@ -572,22 +572,12 @@ static enum omapfb_update_mode omap_lcdc_get_update_mode(void)
572/* PM code called only in internal controller mode */ 572/* PM code called only in internal controller mode */
573static void omap_lcdc_suspend(void) 573static void omap_lcdc_suspend(void)
574{ 574{
575 if (lcdc.update_mode == OMAPFB_AUTO_UPDATE) { 575 omap_lcdc_set_update_mode(OMAPFB_UPDATE_DISABLED);
576 disable_controller();
577 omap_stop_lcd_dma();
578 }
579} 576}
580 577
581static void omap_lcdc_resume(void) 578static void omap_lcdc_resume(void)
582{ 579{
583 if (lcdc.update_mode == OMAPFB_AUTO_UPDATE) { 580 omap_lcdc_set_update_mode(OMAPFB_AUTO_UPDATE);
584 setup_regs();
585 load_palette();
586 setup_lcd_dma();
587 set_load_mode(OMAP_LCDC_LOAD_FRAME);
588 enable_irqs(OMAP_LCDC_IRQ_DONE);
589 enable_controller();
590 }
591} 581}
592 582
593static void omap_lcdc_get_caps(int plane, struct omapfb_caps *caps) 583static void omap_lcdc_get_caps(int plane, struct omapfb_caps *caps)
diff --git a/drivers/video/omap/rfbi.c b/drivers/video/omap/rfbi.c
index 1162603c72e5..eada9f12efc7 100644
--- a/drivers/video/omap/rfbi.c
+++ b/drivers/video/omap/rfbi.c
@@ -26,6 +26,7 @@
26#include <linux/interrupt.h> 26#include <linux/interrupt.h>
27#include <linux/clk.h> 27#include <linux/clk.h>
28#include <linux/io.h> 28#include <linux/io.h>
29#include <linux/platform_device.h>
29 30
30#include "omapfb.h" 31#include "omapfb.h"
31#include "dispc.h" 32#include "dispc.h"
@@ -83,13 +84,13 @@ static inline u32 rfbi_read_reg(int idx)
83 84
84static int rfbi_get_clocks(void) 85static int rfbi_get_clocks(void)
85{ 86{
86 rfbi.dss_ick = clk_get(&dispc.fbdev->dssdev->dev, "ick"); 87 rfbi.dss_ick = clk_get(&rfbi.fbdev->dssdev->dev, "ick");
87 if (IS_ERR(rfbi.dss_ick)) { 88 if (IS_ERR(rfbi.dss_ick)) {
88 dev_err(rfbi.fbdev->dev, "can't get ick\n"); 89 dev_err(rfbi.fbdev->dev, "can't get ick\n");
89 return PTR_ERR(rfbi.dss_ick); 90 return PTR_ERR(rfbi.dss_ick);
90 } 91 }
91 92
92 rfbi.dss1_fck = clk_get(&dispc.fbdev->dssdev->dev, "dss1_fck"); 93 rfbi.dss1_fck = clk_get(&rfbi.fbdev->dssdev->dev, "dss1_fck");
93 if (IS_ERR(rfbi.dss1_fck)) { 94 if (IS_ERR(rfbi.dss1_fck)) {
94 dev_err(rfbi.fbdev->dev, "can't get dss1_fck\n"); 95 dev_err(rfbi.fbdev->dev, "can't get dss1_fck\n");
95 clk_put(rfbi.dss_ick); 96 clk_put(rfbi.dss_ick);
diff --git a/drivers/video/omap2/vram.c b/drivers/video/omap2/vram.c
index 3b1237ad85ed..f6fdc2085f3e 100644
--- a/drivers/video/omap2/vram.c
+++ b/drivers/video/omap2/vram.c
@@ -25,7 +25,7 @@
25#include <linux/list.h> 25#include <linux/list.h>
26#include <linux/slab.h> 26#include <linux/slab.h>
27#include <linux/seq_file.h> 27#include <linux/seq_file.h>
28#include <linux/bootmem.h> 28#include <linux/memblock.h>
29#include <linux/completion.h> 29#include <linux/completion.h>
30#include <linux/debugfs.h> 30#include <linux/debugfs.h>
31#include <linux/jiffies.h> 31#include <linux/jiffies.h>
@@ -525,10 +525,8 @@ early_param("vram", omap_vram_early_vram);
525 * Called from map_io. We need to call to this early enough so that we 525 * Called from map_io. We need to call to this early enough so that we
526 * can reserve the fixed SDRAM regions before VM could get hold of them. 526 * can reserve the fixed SDRAM regions before VM could get hold of them.
527 */ 527 */
528void __init omap_vram_reserve_sdram(void) 528void __init omap_vram_reserve_sdram_memblock(void)
529{ 529{
530 struct bootmem_data *bdata;
531 unsigned long sdram_start, sdram_size;
532 u32 paddr; 530 u32 paddr;
533 u32 size = 0; 531 u32 size = 0;
534 532
@@ -555,29 +553,28 @@ void __init omap_vram_reserve_sdram(void)
555 553
556 size = PAGE_ALIGN(size); 554 size = PAGE_ALIGN(size);
557 555
558 bdata = NODE_DATA(0)->bdata;
559 sdram_start = bdata->node_min_pfn << PAGE_SHIFT;
560 sdram_size = (bdata->node_low_pfn << PAGE_SHIFT) - sdram_start;
561
562 if (paddr) { 556 if (paddr) {
563 if ((paddr & ~PAGE_MASK) || paddr < sdram_start || 557 struct memblock_property res;
564 paddr + size > sdram_start + sdram_size) { 558
559 res.base = paddr;
560 res.size = size;
561 if ((paddr & ~PAGE_MASK) || memblock_find(&res) ||
562 res.base != paddr || res.size != size) {
565 pr_err("Illegal SDRAM region for VRAM\n"); 563 pr_err("Illegal SDRAM region for VRAM\n");
566 return; 564 return;
567 } 565 }
568 566
569 if (reserve_bootmem(paddr, size, BOOTMEM_EXCLUSIVE) < 0) { 567 if (memblock_is_region_reserved(paddr, size)) {
570 pr_err("FB: failed to reserve VRAM\n"); 568 pr_err("FB: failed to reserve VRAM - busy\n");
571 return; 569 return;
572 } 570 }
573 } else { 571
574 if (size > sdram_size) { 572 if (memblock_reserve(paddr, size) < 0) {
575 pr_err("Illegal SDRAM size for VRAM\n"); 573 pr_err("FB: failed to reserve VRAM - no memory\n");
576 return; 574 return;
577 } 575 }
578 576 } else {
579 paddr = virt_to_phys(alloc_bootmem_pages(size)); 577 paddr = memblock_alloc_base(size, PAGE_SIZE, MEMBLOCK_REAL_LIMIT);
580 BUG_ON(paddr & ~PAGE_MASK);
581 } 578 }
582 579
583 omap_vram_add_region(paddr, size); 580 omap_vram_add_region(paddr, size);
diff --git a/drivers/video/pmag-ba-fb.c b/drivers/video/pmag-ba-fb.c
index 0f361b6100d2..0c69fa20251b 100644
--- a/drivers/video/pmag-ba-fb.c
+++ b/drivers/video/pmag-ba-fb.c
@@ -44,7 +44,7 @@ struct pmagbafb_par {
44}; 44};
45 45
46 46
47static struct fb_var_screeninfo pmagbafb_defined __initdata = { 47static struct fb_var_screeninfo pmagbafb_defined __devinitdata = {
48 .xres = 1024, 48 .xres = 1024,
49 .yres = 864, 49 .yres = 864,
50 .xres_virtual = 1024, 50 .xres_virtual = 1024,
@@ -68,7 +68,7 @@ static struct fb_var_screeninfo pmagbafb_defined __initdata = {
68 .vmode = FB_VMODE_NONINTERLACED, 68 .vmode = FB_VMODE_NONINTERLACED,
69}; 69};
70 70
71static struct fb_fix_screeninfo pmagbafb_fix __initdata = { 71static struct fb_fix_screeninfo pmagbafb_fix __devinitdata = {
72 .id = "PMAG-BA", 72 .id = "PMAG-BA",
73 .smem_len = (1024 * 1024), 73 .smem_len = (1024 * 1024),
74 .type = FB_TYPE_PACKED_PIXELS, 74 .type = FB_TYPE_PACKED_PIXELS,
@@ -142,7 +142,7 @@ static void __init pmagbafb_erase_cursor(struct fb_info *info)
142} 142}
143 143
144 144
145static int __init pmagbafb_probe(struct device *dev) 145static int __devinit pmagbafb_probe(struct device *dev)
146{ 146{
147 struct tc_dev *tdev = to_tc_dev(dev); 147 struct tc_dev *tdev = to_tc_dev(dev);
148 resource_size_t start, len; 148 resource_size_t start, len;
diff --git a/drivers/video/pmagb-b-fb.c b/drivers/video/pmagb-b-fb.c
index 2de0806421b4..22fcb9a3d5c0 100644
--- a/drivers/video/pmagb-b-fb.c
+++ b/drivers/video/pmagb-b-fb.c
@@ -45,7 +45,7 @@ struct pmagbbfb_par {
45}; 45};
46 46
47 47
48static struct fb_var_screeninfo pmagbbfb_defined __initdata = { 48static struct fb_var_screeninfo pmagbbfb_defined __devinitdata = {
49 .bits_per_pixel = 8, 49 .bits_per_pixel = 8,
50 .red.length = 8, 50 .red.length = 8,
51 .green.length = 8, 51 .green.length = 8,
@@ -58,7 +58,7 @@ static struct fb_var_screeninfo pmagbbfb_defined __initdata = {
58 .vmode = FB_VMODE_NONINTERLACED, 58 .vmode = FB_VMODE_NONINTERLACED,
59}; 59};
60 60
61static struct fb_fix_screeninfo pmagbbfb_fix __initdata = { 61static struct fb_fix_screeninfo pmagbbfb_fix __devinitdata = {
62 .id = "PMAGB-BA", 62 .id = "PMAGB-BA",
63 .smem_len = (2048 * 1024), 63 .smem_len = (2048 * 1024),
64 .type = FB_TYPE_PACKED_PIXELS, 64 .type = FB_TYPE_PACKED_PIXELS,
@@ -148,7 +148,7 @@ static void __init pmagbbfb_erase_cursor(struct fb_info *info)
148/* 148/*
149 * Set up screen parameters. 149 * Set up screen parameters.
150 */ 150 */
151static void __init pmagbbfb_screen_setup(struct fb_info *info) 151static void __devinit pmagbbfb_screen_setup(struct fb_info *info)
152{ 152{
153 struct pmagbbfb_par *par = info->par; 153 struct pmagbbfb_par *par = info->par;
154 154
@@ -180,9 +180,9 @@ static void __init pmagbbfb_screen_setup(struct fb_info *info)
180/* 180/*
181 * Determine oscillator configuration. 181 * Determine oscillator configuration.
182 */ 182 */
183static void __init pmagbbfb_osc_setup(struct fb_info *info) 183static void __devinit pmagbbfb_osc_setup(struct fb_info *info)
184{ 184{
185 static unsigned int pmagbbfb_freqs[] __initdata = { 185 static unsigned int pmagbbfb_freqs[] __devinitdata = {
186 130808, 119843, 104000, 92980, 74370, 72800, 186 130808, 119843, 104000, 92980, 74370, 72800,
187 69197, 66000, 65000, 50350, 36000, 32000, 25175 187 69197, 66000, 65000, 50350, 36000, 32000, 25175
188 }; 188 };
@@ -247,7 +247,7 @@ static void __init pmagbbfb_osc_setup(struct fb_info *info)
247}; 247};
248 248
249 249
250static int __init pmagbbfb_probe(struct device *dev) 250static int __devinit pmagbbfb_probe(struct device *dev)
251{ 251{
252 struct tc_dev *tdev = to_tc_dev(dev); 252 struct tc_dev *tdev = to_tc_dev(dev);
253 resource_size_t start, len; 253 resource_size_t start, len;
diff --git a/drivers/virtio/virtio_pci.c b/drivers/virtio/virtio_pci.c
index 95896f387927..ef8d9d558fc7 100644
--- a/drivers/virtio/virtio_pci.c
+++ b/drivers/virtio/virtio_pci.c
@@ -636,6 +636,9 @@ static int __devinit virtio_pci_probe(struct pci_dev *pci_dev,
636 INIT_LIST_HEAD(&vp_dev->virtqueues); 636 INIT_LIST_HEAD(&vp_dev->virtqueues);
637 spin_lock_init(&vp_dev->lock); 637 spin_lock_init(&vp_dev->lock);
638 638
639 /* Disable MSI/MSIX to bring device to a known good state. */
640 pci_msi_off(pci_dev);
641
639 /* enable the device */ 642 /* enable the device */
640 err = pci_enable_device(pci_dev); 643 err = pci_enable_device(pci_dev);
641 if (err) 644 if (err)
diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c
index 1ca88908723b..1475ed6b575f 100644
--- a/drivers/virtio/virtio_ring.c
+++ b/drivers/virtio/virtio_ring.c
@@ -119,7 +119,7 @@ static int vring_add_indirect(struct vring_virtqueue *vq,
119 119
120 desc = kmalloc((out + in) * sizeof(struct vring_desc), gfp); 120 desc = kmalloc((out + in) * sizeof(struct vring_desc), gfp);
121 if (!desc) 121 if (!desc)
122 return vq->vring.num; 122 return -ENOMEM;
123 123
124 /* Transfer entries from the sg list into the indirect page */ 124 /* Transfer entries from the sg list into the indirect page */
125 for (i = 0; i < out; i++) { 125 for (i = 0; i < out; i++) {
@@ -164,7 +164,8 @@ int virtqueue_add_buf_gfp(struct virtqueue *_vq,
164 gfp_t gfp) 164 gfp_t gfp)
165{ 165{
166 struct vring_virtqueue *vq = to_vvq(_vq); 166 struct vring_virtqueue *vq = to_vvq(_vq);
167 unsigned int i, avail, head, uninitialized_var(prev); 167 unsigned int i, avail, uninitialized_var(prev);
168 int head;
168 169
169 START_USE(vq); 170 START_USE(vq);
170 171
@@ -174,7 +175,7 @@ int virtqueue_add_buf_gfp(struct virtqueue *_vq,
174 * buffers, then go indirect. FIXME: tune this threshold */ 175 * buffers, then go indirect. FIXME: tune this threshold */
175 if (vq->indirect && (out + in) > 1 && vq->num_free) { 176 if (vq->indirect && (out + in) > 1 && vq->num_free) {
176 head = vring_add_indirect(vq, sg, out, in, gfp); 177 head = vring_add_indirect(vq, sg, out, in, gfp);
177 if (head != vq->vring.num) 178 if (likely(head >= 0))
178 goto add_head; 179 goto add_head;
179 } 180 }
180 181
diff --git a/drivers/watchdog/at32ap700x_wdt.c b/drivers/watchdog/at32ap700x_wdt.c
index 1cddf92cb9a6..750bc5281d79 100644
--- a/drivers/watchdog/at32ap700x_wdt.c
+++ b/drivers/watchdog/at32ap700x_wdt.c
@@ -346,9 +346,13 @@ static int __init at32_wdt_probe(struct platform_device *pdev)
346 } else { 346 } else {
347 wdt->users = 0; 347 wdt->users = 0;
348 } 348 }
349 wdt->miscdev.minor = WATCHDOG_MINOR; 349
350 wdt->miscdev.name = "watchdog"; 350 wdt->miscdev.minor = WATCHDOG_MINOR;
351 wdt->miscdev.fops = &at32_wdt_fops; 351 wdt->miscdev.name = "watchdog";
352 wdt->miscdev.fops = &at32_wdt_fops;
353 wdt->miscdev.parent = &pdev->dev;
354
355 platform_set_drvdata(pdev, wdt);
352 356
353 if (at32_wdt_settimeout(timeout)) { 357 if (at32_wdt_settimeout(timeout)) {
354 at32_wdt_settimeout(TIMEOUT_DEFAULT); 358 at32_wdt_settimeout(TIMEOUT_DEFAULT);
@@ -360,17 +364,17 @@ static int __init at32_wdt_probe(struct platform_device *pdev)
360 ret = misc_register(&wdt->miscdev); 364 ret = misc_register(&wdt->miscdev);
361 if (ret) { 365 if (ret) {
362 dev_dbg(&pdev->dev, "failed to register wdt miscdev\n"); 366 dev_dbg(&pdev->dev, "failed to register wdt miscdev\n");
363 goto err_iounmap; 367 goto err_register;
364 } 368 }
365 369
366 platform_set_drvdata(pdev, wdt);
367 wdt->miscdev.parent = &pdev->dev;
368 dev_info(&pdev->dev, 370 dev_info(&pdev->dev,
369 "AT32AP700X WDT at 0x%p, timeout %d sec (nowayout=%d)\n", 371 "AT32AP700X WDT at 0x%p, timeout %d sec (nowayout=%d)\n",
370 wdt->regs, wdt->timeout, nowayout); 372 wdt->regs, wdt->timeout, nowayout);
371 373
372 return 0; 374 return 0;
373 375
376err_register:
377 platform_set_drvdata(pdev, NULL);
374err_iounmap: 378err_iounmap:
375 iounmap(wdt->regs); 379 iounmap(wdt->regs);
376err_free: 380err_free:
diff --git a/drivers/watchdog/imx2_wdt.c b/drivers/watchdog/imx2_wdt.c
index ea25885781bb..2ee7dac55a3c 100644
--- a/drivers/watchdog/imx2_wdt.c
+++ b/drivers/watchdog/imx2_wdt.c
@@ -330,7 +330,6 @@ static void imx2_wdt_shutdown(struct platform_device *pdev)
330} 330}
331 331
332static struct platform_driver imx2_wdt_driver = { 332static struct platform_driver imx2_wdt_driver = {
333 .probe = imx2_wdt_probe,
334 .remove = __exit_p(imx2_wdt_remove), 333 .remove = __exit_p(imx2_wdt_remove),
335 .shutdown = imx2_wdt_shutdown, 334 .shutdown = imx2_wdt_shutdown,
336 .driver = { 335 .driver = {