aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorGrant Likely <grant.likely@secretlab.ca>2010-07-25 19:52:21 -0400
committerGrant Likely <grant.likely@secretlab.ca>2010-07-25 19:52:21 -0400
commit5ffdcd94ea0171cf9a3ca63051c2246426103b5b (patch)
treedfa1522796d5af649caf64ac6e2f1e69119e85d0 /drivers
parentcf40f082f8d3a98e28af02af20d00d2500eb6a65 (diff)
parentb37fa16e78d6f9790462b3181602a26b5af36260 (diff)
Merge commit 'v2.6.35-rc6' into spi/test
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.c59
-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/blacklist.c8
-rw-r--r--drivers/acpi/button.c4
-rw-r--r--drivers/acpi/fan.c3
-rw-r--r--drivers/acpi/processor_driver.c5
-rw-r--r--drivers/acpi/sleep.c34
-rw-r--r--drivers/acpi/system.c6
-rw-r--r--drivers/acpi/wakeup.c20
-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/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/ipmi/ipmi_si_intf.c23
-rw-r--r--drivers/char/sysrq.c10
-rw-r--r--drivers/char/tpm/tpm.h1
-rw-r--r--drivers/clocksource/cs5535-clockevt.c2
-rw-r--r--drivers/clocksource/sh_cmt.c2
-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.c53
-rw-r--r--drivers/edac/mpc85xx_edac.c1
-rw-r--r--drivers/gpio/Kconfig2
-rw-r--r--drivers/gpio/Makefile6
-rw-r--r--drivers/gpio/cs5535-gpio.c2
-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.c2
-rw-r--r--drivers/gpu/drm/i915/i915_dma.c8
-rw-r--r--drivers/gpu/drm/i915/i915_drv.h3
-rw-r--r--drivers/gpu/drm/i915/i915_gem.c15
-rw-r--r--drivers/gpu/drm/i915/i915_irq.c76
-rw-r--r--drivers/gpu/drm/i915/i915_reg.h69
-rw-r--r--drivers/gpu/drm/i915/intel_crt.c6
-rw-r--r--drivers/gpu/drm/i915/intel_display.c60
-rw-r--r--drivers/gpu/drm/i915/intel_dp.c27
-rw-r--r--drivers/gpu/drm/i915/intel_drv.h1
-rw-r--r--drivers/gpu/drm/i915/intel_lvds.c4
-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.c41
-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/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/ivtv/ivtv-streams.c3
-rw-r--r--drivers/media/video/mem2mem_testdev.c3
-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/cs5535-mfgpt.c2
-rw-r--r--drivers/mmc/host/sdhci-s3c.c20
-rw-r--r--drivers/net/Kconfig2
-rw-r--r--drivers/net/bnx2.c11
-rw-r--r--drivers/net/bonding/bond_alb.c3
-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/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/ixgbe/ixgbe_ethtool.c37
-rw-r--r--drivers/net/ixgbe/ixgbe_main.c21
-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/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/qlge/qlge_main.c11
-rw-r--r--drivers/net/r8169.c2
-rw-r--r--drivers/net/s2io.c101
-rw-r--r--drivers/net/s2io.h4
-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/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/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/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/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/platform/x86/intel_scu_ipc.c12
-rw-r--r--drivers/power/ds2782_battery.c2
-rw-r--r--drivers/power/z2_battery.c12
-rw-r--r--drivers/rtc/rtc-davinci.c1
-rw-r--r--drivers/rtc/rtc-ds1307.c4
-rw-r--r--drivers/s390/block/dasd_devmap.c4
-rw-r--r--drivers/s390/cio/chsc.c2
-rw-r--r--drivers/sbus/char/openprom.c4
-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/core/driver.c13
-rw-r--r--drivers/usb/core/message.c7
-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/g_ffs.c11
-rw-r--r--drivers/usb/gadget/printer.c32
-rw-r--r--drivers/usb/gadget/s3c2410_udc.c6
-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.c13
-rw-r--r--drivers/usb/host/isp1362-hcd.c15
-rw-r--r--drivers/usb/host/r8a66597-hcd.c2
-rw-r--r--drivers/usb/host/xhci-ring.c62
-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/otg/ulpi.c17
-rw-r--r--drivers/usb/serial/ftdi_sio.c1
-rw-r--r--drivers/usb/serial/ftdi_sio_ids.h7
-rw-r--r--drivers/usb/serial/qcserial.c3
-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/geode/gxfb_core.c20
-rw-r--r--drivers/video/geode/lxfb_core.c18
-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/virtio/virtio_pci.c3
-rw-r--r--drivers/virtio/virtio_ring.c2
-rw-r--r--drivers/watchdog/at32ap700x_wdt.c16
-rw-r--r--drivers/watchdog/imx2_wdt.c1
307 files changed, 3251 insertions, 2990 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..d97b8dce1668 100644
--- a/drivers/acpi/acpica/evxfevnt.c
+++ b/drivers/acpi/acpica/evxfevnt.c
@@ -210,6 +210,44 @@ ACPI_EXPORT_SYMBOL(acpi_enable_event)
210 210
211/******************************************************************************* 211/*******************************************************************************
212 * 212 *
213 * FUNCTION: acpi_clear_and_enable_gpe
214 *
215 * PARAMETERS: gpe_event_info - GPE to enable
216 *
217 * RETURN: Status
218 *
219 * DESCRIPTION: Clear the given GPE from stale events and enable it.
220 *
221 ******************************************************************************/
222static acpi_status
223acpi_clear_and_enable_gpe(struct acpi_gpe_event_info *gpe_event_info)
224{
225 acpi_status status;
226
227 /*
228 * We will only allow a GPE to be enabled if it has either an
229 * associated method (_Lxx/_Exx) or a handler. Otherwise, the
230 * GPE will be immediately disabled by acpi_ev_gpe_dispatch the
231 * first time it fires.
232 */
233 if (!(gpe_event_info->flags & ACPI_GPE_DISPATCH_MASK)) {
234 return_ACPI_STATUS(AE_NO_HANDLER);
235 }
236
237 /* Clear the GPE (of stale events) */
238 status = acpi_hw_clear_gpe(gpe_event_info);
239 if (ACPI_FAILURE(status)) {
240 return_ACPI_STATUS(status);
241 }
242
243 /* Enable the requested GPE */
244 status = acpi_hw_low_set_gpe(gpe_event_info, ACPI_GPE_ENABLE);
245
246 return_ACPI_STATUS(status);
247}
248
249/*******************************************************************************
250 *
213 * FUNCTION: acpi_set_gpe 251 * FUNCTION: acpi_set_gpe
214 * 252 *
215 * PARAMETERS: gpe_device - Parent GPE Device. NULL for GPE0/GPE1 253 * PARAMETERS: gpe_device - Parent GPE Device. NULL for GPE0/GPE1
@@ -249,11 +287,11 @@ acpi_status acpi_set_gpe(acpi_handle gpe_device, u32 gpe_number, u8 action)
249 287
250 switch (action) { 288 switch (action) {
251 case ACPI_GPE_ENABLE: 289 case ACPI_GPE_ENABLE:
252 status = acpi_ev_enable_gpe(gpe_event_info); 290 status = acpi_clear_and_enable_gpe(gpe_event_info);
253 break; 291 break;
254 292
255 case ACPI_GPE_DISABLE: 293 case ACPI_GPE_DISABLE:
256 status = acpi_ev_disable_gpe(gpe_event_info); 294 status = acpi_hw_low_set_gpe(gpe_event_info, ACPI_GPE_DISABLE);
257 break; 295 break;
258 296
259 default: 297 default:
@@ -316,7 +354,11 @@ acpi_status acpi_enable_gpe(acpi_handle gpe_device, u32 gpe_number, u8 gpe_type)
316 354
317 gpe_event_info->runtime_count++; 355 gpe_event_info->runtime_count++;
318 if (gpe_event_info->runtime_count == 1) { 356 if (gpe_event_info->runtime_count == 1) {
319 status = acpi_ev_enable_gpe(gpe_event_info); 357 status = acpi_ev_update_gpe_enable_masks(gpe_event_info);
358 if (ACPI_SUCCESS(status)) {
359 status = acpi_clear_and_enable_gpe(gpe_event_info);
360 }
361
320 if (ACPI_FAILURE(status)) { 362 if (ACPI_FAILURE(status)) {
321 gpe_event_info->runtime_count--; 363 gpe_event_info->runtime_count--;
322 goto unlock_and_exit; 364 goto unlock_and_exit;
@@ -343,7 +385,7 @@ acpi_status acpi_enable_gpe(acpi_handle gpe_device, u32 gpe_number, u8 gpe_type)
343 */ 385 */
344 gpe_event_info->wakeup_count++; 386 gpe_event_info->wakeup_count++;
345 if (gpe_event_info->wakeup_count == 1) { 387 if (gpe_event_info->wakeup_count == 1) {
346 (void)acpi_ev_update_gpe_enable_masks(gpe_event_info); 388 status = acpi_ev_update_gpe_enable_masks(gpe_event_info);
347 } 389 }
348 } 390 }
349 391
@@ -403,7 +445,12 @@ acpi_status acpi_disable_gpe(acpi_handle gpe_device, u32 gpe_number, u8 gpe_type
403 445
404 gpe_event_info->runtime_count--; 446 gpe_event_info->runtime_count--;
405 if (!gpe_event_info->runtime_count) { 447 if (!gpe_event_info->runtime_count) {
406 status = acpi_ev_disable_gpe(gpe_event_info); 448 status = acpi_ev_update_gpe_enable_masks(gpe_event_info);
449 if (ACPI_SUCCESS(status)) {
450 status = acpi_hw_low_set_gpe(gpe_event_info,
451 ACPI_GPE_DISABLE);
452 }
453
407 if (ACPI_FAILURE(status)) { 454 if (ACPI_FAILURE(status)) {
408 gpe_event_info->runtime_count++; 455 gpe_event_info->runtime_count++;
409 goto unlock_and_exit; 456 goto unlock_and_exit;
@@ -424,7 +471,7 @@ acpi_status acpi_disable_gpe(acpi_handle gpe_device, u32 gpe_number, u8 gpe_type
424 471
425 gpe_event_info->wakeup_count--; 472 gpe_event_info->wakeup_count--;
426 if (!gpe_event_info->wakeup_count) { 473 if (!gpe_event_info->wakeup_count) {
427 (void)acpi_ev_update_gpe_enable_masks(gpe_event_info); 474 status = acpi_ev_update_gpe_enable_masks(gpe_event_info);
428 } 475 }
429 } 476 }
430 477
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/blacklist.c b/drivers/acpi/blacklist.c
index 2815df66f6f7..01381be05e96 100644
--- a/drivers/acpi/blacklist.c
+++ b/drivers/acpi/blacklist.c
@@ -218,6 +218,14 @@ static struct dmi_system_id acpi_osi_dmi_table[] __initdata = {
218 }, 218 },
219 }, 219 },
220 { 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"),
226 },
227 },
228 {
221 .callback = dmi_disable_osi_win7, 229 .callback = dmi_disable_osi_win7,
222 .ident = "ASUS K50IJ", 230 .ident = "ASUS K50IJ",
223 .matches = { 231 .matches = {
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_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/sleep.c b/drivers/acpi/sleep.c
index 3fb4bdea7e06..5b7c52e4a00f 100644
--- a/drivers/acpi/sleep.c
+++ b/drivers/acpi/sleep.c
@@ -114,6 +114,8 @@ static int __acpi_pm_prepare(void)
114{ 114{
115 int error = acpi_sleep_prepare(acpi_target_sleep_state); 115 int error = acpi_sleep_prepare(acpi_target_sleep_state);
116 116
117 suspend_nvs_save();
118
117 if (error) 119 if (error)
118 acpi_target_sleep_state = ACPI_STATE_S0; 120 acpi_target_sleep_state = ACPI_STATE_S0;
119 return error; 121 return error;
@@ -143,6 +145,9 @@ static void acpi_pm_finish(void)
143{ 145{
144 u32 acpi_state = acpi_target_sleep_state; 146 u32 acpi_state = acpi_target_sleep_state;
145 147
148 suspend_nvs_free();
149 acpi_ec_unblock_transactions();
150
146 if (acpi_state == ACPI_STATE_S0) 151 if (acpi_state == ACPI_STATE_S0)
147 return; 152 return;
148 153
@@ -192,6 +197,11 @@ static int acpi_suspend_begin(suspend_state_t pm_state)
192 u32 acpi_state = acpi_suspend_states[pm_state]; 197 u32 acpi_state = acpi_suspend_states[pm_state];
193 int error = 0; 198 int error = 0;
194 199
200 error = suspend_nvs_alloc();
201
202 if (error)
203 return error;
204
195 if (sleep_states[acpi_state]) { 205 if (sleep_states[acpi_state]) {
196 acpi_target_sleep_state = acpi_state; 206 acpi_target_sleep_state = acpi_state;
197 acpi_sleep_tts_switch(acpi_target_sleep_state); 207 acpi_sleep_tts_switch(acpi_target_sleep_state);
@@ -269,12 +279,13 @@ static int acpi_suspend_enter(suspend_state_t pm_state)
269 if (acpi_state == ACPI_STATE_S3) 279 if (acpi_state == ACPI_STATE_S3)
270 acpi_restore_state_mem(); 280 acpi_restore_state_mem();
271 281
282 suspend_nvs_restore();
283
272 return ACPI_SUCCESS(status) ? 0 : -EFAULT; 284 return ACPI_SUCCESS(status) ? 0 : -EFAULT;
273} 285}
274 286
275static void acpi_suspend_finish(void) 287static void acpi_suspend_finish(void)
276{ 288{
277 acpi_ec_unblock_transactions();
278 acpi_pm_finish(); 289 acpi_pm_finish();
279} 290}
280 291
@@ -404,7 +415,7 @@ static int acpi_hibernation_begin(void)
404{ 415{
405 int error; 416 int error;
406 417
407 error = s4_no_nvs ? 0 : hibernate_nvs_alloc(); 418 error = s4_no_nvs ? 0 : suspend_nvs_alloc();
408 if (!error) { 419 if (!error) {
409 acpi_target_sleep_state = ACPI_STATE_S4; 420 acpi_target_sleep_state = ACPI_STATE_S4;
410 acpi_sleep_tts_switch(acpi_target_sleep_state); 421 acpi_sleep_tts_switch(acpi_target_sleep_state);
@@ -418,7 +429,7 @@ static int acpi_hibernation_pre_snapshot(void)
418 int error = acpi_pm_prepare(); 429 int error = acpi_pm_prepare();
419 430
420 if (!error) 431 if (!error)
421 hibernate_nvs_save(); 432 suspend_nvs_save();
422 433
423 return error; 434 return error;
424} 435}
@@ -441,13 +452,6 @@ static int acpi_hibernation_enter(void)
441 return ACPI_SUCCESS(status) ? 0 : -EFAULT; 452 return ACPI_SUCCESS(status) ? 0 : -EFAULT;
442} 453}
443 454
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) 455static void acpi_hibernation_leave(void)
452{ 456{
453 /* 457 /*
@@ -464,7 +468,7 @@ static void acpi_hibernation_leave(void)
464 panic("ACPI S4 hardware signature mismatch"); 468 panic("ACPI S4 hardware signature mismatch");
465 } 469 }
466 /* Restore the NVS memory area */ 470 /* Restore the NVS memory area */
467 hibernate_nvs_restore(); 471 suspend_nvs_restore();
468 /* Allow EC transactions to happen. */ 472 /* Allow EC transactions to happen. */
469 acpi_ec_unblock_transactions_early(); 473 acpi_ec_unblock_transactions_early();
470} 474}
@@ -479,7 +483,7 @@ static struct platform_hibernation_ops acpi_hibernation_ops = {
479 .begin = acpi_hibernation_begin, 483 .begin = acpi_hibernation_begin,
480 .end = acpi_pm_end, 484 .end = acpi_pm_end,
481 .pre_snapshot = acpi_hibernation_pre_snapshot, 485 .pre_snapshot = acpi_hibernation_pre_snapshot,
482 .finish = acpi_hibernation_finish, 486 .finish = acpi_pm_finish,
483 .prepare = acpi_pm_prepare, 487 .prepare = acpi_pm_prepare,
484 .enter = acpi_hibernation_enter, 488 .enter = acpi_hibernation_enter,
485 .leave = acpi_hibernation_leave, 489 .leave = acpi_hibernation_leave,
@@ -507,7 +511,7 @@ static int acpi_hibernation_begin_old(void)
507 511
508 if (!error) { 512 if (!error) {
509 if (!s4_no_nvs) 513 if (!s4_no_nvs)
510 error = hibernate_nvs_alloc(); 514 error = suspend_nvs_alloc();
511 if (!error) 515 if (!error)
512 acpi_target_sleep_state = ACPI_STATE_S4; 516 acpi_target_sleep_state = ACPI_STATE_S4;
513 } 517 }
@@ -517,7 +521,7 @@ static int acpi_hibernation_begin_old(void)
517static int acpi_hibernation_pre_snapshot_old(void) 521static int acpi_hibernation_pre_snapshot_old(void)
518{ 522{
519 acpi_pm_freeze(); 523 acpi_pm_freeze();
520 hibernate_nvs_save(); 524 suspend_nvs_save();
521 return 0; 525 return 0;
522} 526}
523 527
@@ -529,8 +533,8 @@ static struct platform_hibernation_ops acpi_hibernation_ops_old = {
529 .begin = acpi_hibernation_begin_old, 533 .begin = acpi_hibernation_begin_old,
530 .end = acpi_pm_end, 534 .end = acpi_pm_end,
531 .pre_snapshot = acpi_hibernation_pre_snapshot_old, 535 .pre_snapshot = acpi_hibernation_pre_snapshot_old,
532 .finish = acpi_hibernation_finish,
533 .prepare = acpi_pm_freeze, 536 .prepare = acpi_pm_freeze,
537 .finish = acpi_pm_finish,
534 .enter = acpi_hibernation_enter, 538 .enter = acpi_hibernation_enter,
535 .leave = acpi_hibernation_leave, 539 .leave = acpi_hibernation_leave,
536 .pre_restore = acpi_pm_freeze, 540 .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/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/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/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/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/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..cc9357da0e34 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
@@ -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..f39b00a46eda 100644
--- a/drivers/edac/mpc85xx_edac.c
+++ b/drivers/edac/mpc85xx_edac.c
@@ -1120,6 +1120,7 @@ static struct of_device_id mpc85xx_mc_err_of_match[] = {
1120 { .compatible = "fsl,mpc8555-memory-controller", }, 1120 { .compatible = "fsl,mpc8555-memory-controller", },
1121 { .compatible = "fsl,mpc8560-memory-controller", }, 1121 { .compatible = "fsl,mpc8560-memory-controller", },
1122 { .compatible = "fsl,mpc8568-memory-controller", }, 1122 { .compatible = "fsl,mpc8568-memory-controller", },
1123 { .compatible = "fsl,mpc8569-memory-controller", },
1123 { .compatible = "fsl,mpc8572-memory-controller", }, 1124 { .compatible = "fsl,mpc8572-memory-controller", },
1124 { .compatible = "fsl,mpc8349-memory-controller", }, 1125 { .compatible = "fsl,mpc8349-memory-controller", },
1125 { .compatible = "fsl,p2020-memory-controller", }, 1126 { .compatible = "fsl,p2020-memory-controller", },
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/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..aee83fa178f6 100644
--- a/drivers/gpu/drm/i915/i915_debugfs.c
+++ b/drivers/gpu/drm/i915/i915_debugfs.c
@@ -620,7 +620,7 @@ static int i915_sr_status(struct seq_file *m, void *unused)
620 drm_i915_private_t *dev_priv = dev->dev_private; 620 drm_i915_private_t *dev_priv = dev->dev_private;
621 bool sr_enabled = false; 621 bool sr_enabled = false;
622 622
623 if (IS_I965G(dev) || IS_I945G(dev) || IS_I945GM(dev)) 623 if (IS_I965GM(dev) || IS_I945G(dev) || IS_I945GM(dev))
624 sr_enabled = I915_READ(FW_BLC_SELF) & FW_BLC_SELF_EN; 624 sr_enabled = I915_READ(FW_BLC_SELF) & FW_BLC_SELF_EN;
625 else if (IS_I915GM(dev)) 625 else if (IS_I915GM(dev))
626 sr_enabled = I915_READ(INSTPM) & INSTPM_SELF_EN; 626 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..f00c5ae9556c 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
@@ -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..d147ab2f5bfc 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -596,6 +596,7 @@ typedef struct drm_i915_private {
596 struct drm_crtc *plane_to_crtc_mapping[2]; 596 struct drm_crtc *plane_to_crtc_mapping[2];
597 struct drm_crtc *pipe_to_crtc_mapping[2]; 597 struct drm_crtc *pipe_to_crtc_mapping[2];
598 wait_queue_head_t pending_flip_queue; 598 wait_queue_head_t pending_flip_queue;
599 bool flip_pending_is_done;
599 600
600 /* Reclocking support */ 601 /* Reclocking support */
601 bool render_reclock_avail; 602 bool render_reclock_avail;
@@ -1076,7 +1077,7 @@ extern int intel_trans_dp_port_sel (struct drm_crtc *crtc);
1076 drm_i915_private_t *dev_priv = dev->dev_private; \ 1077 drm_i915_private_t *dev_priv = dev->dev_private; \
1077 if (I915_VERBOSE) \ 1078 if (I915_VERBOSE) \
1078 DRM_DEBUG(" BEGIN_LP_RING %x\n", (int)(n)); \ 1079 DRM_DEBUG(" BEGIN_LP_RING %x\n", (int)(n)); \
1079 intel_ring_begin(dev, &dev_priv->render_ring, 4*(n)); \ 1080 intel_ring_begin(dev, &dev_priv->render_ring, (n)); \
1080} while (0) 1081} while (0)
1081 1082
1082 1083
diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
index 9ded3dae6c87..51bd301cf10d 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;
@@ -4741,6 +4742,16 @@ i915_gem_load(struct drm_device *dev)
4741 list_add(&dev_priv->mm.shrink_list, &shrink_list); 4742 list_add(&dev_priv->mm.shrink_list, &shrink_list);
4742 spin_unlock(&shrink_list_lock); 4743 spin_unlock(&shrink_list_lock);
4743 4744
4745 /* On GEN3 we really need to make sure the ARB C3 LP bit is set */
4746 if (IS_GEN3(dev)) {
4747 u32 tmp = I915_READ(MI_ARB_STATE);
4748 if (!(tmp & MI_ARB_C3_LP_WRITE_ENABLE)) {
4749 /* arb state is a masked write, so set bit + bit in mask */
4750 tmp = MI_ARB_C3_LP_WRITE_ENABLE | (MI_ARB_C3_LP_WRITE_ENABLE << MI_ARB_MASK_SHIFT);
4751 I915_WRITE(MI_ARB_STATE, tmp);
4752 }
4753 }
4754
4744 /* Old X drivers will take 0-2 for front, back, depth buffers */ 4755 /* Old X drivers will take 0-2 for front, back, depth buffers */
4745 if (!drm_core_check_feature(dev, DRIVER_MODESET)) 4756 if (!drm_core_check_feature(dev, DRIVER_MODESET))
4746 dev_priv->fence_reg_start = 3; 4757 dev_priv->fence_reg_start = 3;
@@ -4977,7 +4988,7 @@ i915_gpu_is_active(struct drm_device *dev)
4977} 4988}
4978 4989
4979static int 4990static int
4980i915_gem_shrink(int nr_to_scan, gfp_t gfp_mask) 4991i915_gem_shrink(struct shrinker *shrink, int nr_to_scan, gfp_t gfp_mask)
4981{ 4992{
4982 drm_i915_private_t *dev_priv, *next_dev; 4993 drm_i915_private_t *dev_priv, *next_dev;
4983 struct drm_i915_gem_object *obj_priv, *next_obj; 4994 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..6d9b0288272a 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)
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..68dcf36e2793 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -2970,11 +2970,13 @@ static void i965_update_wm(struct drm_device *dev, int planea_clock,
2970 if (srwm < 0) 2970 if (srwm < 0)
2971 srwm = 1; 2971 srwm = 1;
2972 srwm &= 0x3f; 2972 srwm &= 0x3f;
2973 I915_WRITE(FW_BLC_SELF, FW_BLC_SELF_EN); 2973 if (IS_I965GM(dev))
2974 I915_WRITE(FW_BLC_SELF, FW_BLC_SELF_EN);
2974 } else { 2975 } else {
2975 /* Turn off self refresh if both pipes are enabled */ 2976 /* Turn off self refresh if both pipes are enabled */
2976 I915_WRITE(FW_BLC_SELF, I915_READ(FW_BLC_SELF) 2977 if (IS_I965GM(dev))
2977 & ~FW_BLC_SELF_EN); 2978 I915_WRITE(FW_BLC_SELF, I915_READ(FW_BLC_SELF)
2979 & ~FW_BLC_SELF_EN);
2978 } 2980 }
2979 2981
2980 DRM_DEBUG_KMS("Setting FIFO watermarks - A: 8, B: 8, C: 8, SR %d\n", 2982 DRM_DEBUG_KMS("Setting FIFO watermarks - A: 8, B: 8, C: 8, SR %d\n",
@@ -4483,6 +4485,7 @@ static void intel_idle_update(struct work_struct *work)
4483 struct drm_device *dev = dev_priv->dev; 4485 struct drm_device *dev = dev_priv->dev;
4484 struct drm_crtc *crtc; 4486 struct drm_crtc *crtc;
4485 struct intel_crtc *intel_crtc; 4487 struct intel_crtc *intel_crtc;
4488 int enabled = 0;
4486 4489
4487 if (!i915_powersave) 4490 if (!i915_powersave)
4488 return; 4491 return;
@@ -4491,21 +4494,22 @@ static void intel_idle_update(struct work_struct *work)
4491 4494
4492 i915_update_gfx_val(dev_priv); 4495 i915_update_gfx_val(dev_priv);
4493 4496
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) { 4497 list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) {
4500 /* Skip inactive CRTCs */ 4498 /* Skip inactive CRTCs */
4501 if (!crtc->fb) 4499 if (!crtc->fb)
4502 continue; 4500 continue;
4503 4501
4502 enabled++;
4504 intel_crtc = to_intel_crtc(crtc); 4503 intel_crtc = to_intel_crtc(crtc);
4505 if (!intel_crtc->busy) 4504 if (!intel_crtc->busy)
4506 intel_decrease_pllclock(crtc); 4505 intel_decrease_pllclock(crtc);
4507 } 4506 }
4508 4507
4508 if ((enabled == 1) && (IS_I945G(dev) || IS_I945GM(dev))) {
4509 DRM_DEBUG_DRIVER("enable memory self refresh on 945\n");
4510 I915_WRITE(FW_BLC_SELF, FW_BLC_SELF_EN_MASK | FW_BLC_SELF_EN);
4511 }
4512
4509 mutex_unlock(&dev->struct_mutex); 4513 mutex_unlock(&dev->struct_mutex);
4510} 4514}
4511 4515
@@ -4601,10 +4605,10 @@ static void intel_unpin_work_fn(struct work_struct *__work)
4601 kfree(work); 4605 kfree(work);
4602} 4606}
4603 4607
4604void intel_finish_page_flip(struct drm_device *dev, int pipe) 4608static void do_intel_finish_page_flip(struct drm_device *dev,
4609 struct drm_crtc *crtc)
4605{ 4610{
4606 drm_i915_private_t *dev_priv = dev->dev_private; 4611 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); 4612 struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
4609 struct intel_unpin_work *work; 4613 struct intel_unpin_work *work;
4610 struct drm_i915_gem_object *obj_priv; 4614 struct drm_i915_gem_object *obj_priv;
@@ -4648,6 +4652,22 @@ void intel_finish_page_flip(struct drm_device *dev, int pipe)
4648 schedule_work(&work->work); 4652 schedule_work(&work->work);
4649} 4653}
4650 4654
4655void intel_finish_page_flip(struct drm_device *dev, int pipe)
4656{
4657 drm_i915_private_t *dev_priv = dev->dev_private;
4658 struct drm_crtc *crtc = dev_priv->pipe_to_crtc_mapping[pipe];
4659
4660 do_intel_finish_page_flip(dev, crtc);
4661}
4662
4663void intel_finish_page_flip_plane(struct drm_device *dev, int plane)
4664{
4665 drm_i915_private_t *dev_priv = dev->dev_private;
4666 struct drm_crtc *crtc = dev_priv->plane_to_crtc_mapping[plane];
4667
4668 do_intel_finish_page_flip(dev, crtc);
4669}
4670
4651void intel_prepare_page_flip(struct drm_device *dev, int plane) 4671void intel_prepare_page_flip(struct drm_device *dev, int plane)
4652{ 4672{
4653 drm_i915_private_t *dev_priv = dev->dev_private; 4673 drm_i915_private_t *dev_priv = dev->dev_private;
@@ -4678,6 +4698,7 @@ static int intel_crtc_page_flip(struct drm_crtc *crtc,
4678 unsigned long flags; 4698 unsigned long flags;
4679 int pipesrc_reg = (intel_crtc->pipe == 0) ? PIPEASRC : PIPEBSRC; 4699 int pipesrc_reg = (intel_crtc->pipe == 0) ? PIPEASRC : PIPEBSRC;
4680 int ret, pipesrc; 4700 int ret, pipesrc;
4701 u32 flip_mask;
4681 4702
4682 work = kzalloc(sizeof *work, GFP_KERNEL); 4703 work = kzalloc(sizeof *work, GFP_KERNEL);
4683 if (work == NULL) 4704 if (work == NULL)
@@ -4731,15 +4752,28 @@ static int intel_crtc_page_flip(struct drm_crtc *crtc,
4731 atomic_inc(&obj_priv->pending_flip); 4752 atomic_inc(&obj_priv->pending_flip);
4732 work->pending_flip_obj = obj; 4753 work->pending_flip_obj = obj;
4733 4754
4755 if (intel_crtc->plane)
4756 flip_mask = I915_DISPLAY_PLANE_B_FLIP_PENDING_INTERRUPT;
4757 else
4758 flip_mask = I915_DISPLAY_PLANE_A_FLIP_PENDING_INTERRUPT;
4759
4760 /* Wait for any previous flip to finish */
4761 if (IS_GEN3(dev))
4762 while (I915_READ(ISR) & flip_mask)
4763 ;
4764
4734 BEGIN_LP_RING(4); 4765 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)) { 4766 if (IS_I965G(dev)) {
4767 OUT_RING(MI_DISPLAY_FLIP |
4768 MI_DISPLAY_FLIP_PLANE(intel_crtc->plane));
4769 OUT_RING(fb->pitch);
4739 OUT_RING(obj_priv->gtt_offset | obj_priv->tiling_mode); 4770 OUT_RING(obj_priv->gtt_offset | obj_priv->tiling_mode);
4740 pipesrc = I915_READ(pipesrc_reg); 4771 pipesrc = I915_READ(pipesrc_reg);
4741 OUT_RING(pipesrc & 0x0fff0fff); 4772 OUT_RING(pipesrc & 0x0fff0fff);
4742 } else { 4773 } else {
4774 OUT_RING(MI_DISPLAY_FLIP_I915 |
4775 MI_DISPLAY_FLIP_PLANE(intel_crtc->plane));
4776 OUT_RING(fb->pitch);
4743 OUT_RING(obj_priv->gtt_offset); 4777 OUT_RING(obj_priv->gtt_offset);
4744 OUT_RING(MI_NOOP); 4778 OUT_RING(MI_NOOP);
4745 } 4779 }
diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c
index 49b54f05d3cf..1aac59e83bff 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
diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h
index df931f787665..72206f37c4fb 100644
--- a/drivers/gpu/drm/i915/intel_drv.h
+++ b/drivers/gpu/drm/i915/intel_drv.h
@@ -224,6 +224,7 @@ extern void intel_fbdev_fini(struct drm_device *dev);
224 224
225extern void intel_prepare_page_flip(struct drm_device *dev, int plane); 225extern void intel_prepare_page_flip(struct drm_device *dev, int plane);
226extern void intel_finish_page_flip(struct drm_device *dev, int pipe); 226extern void intel_finish_page_flip(struct drm_device *dev, int pipe);
227extern void intel_finish_page_flip_plane(struct drm_device *dev, int plane);
227 228
228extern void intel_setup_overlay(struct drm_device *dev); 229extern void intel_setup_overlay(struct drm_device *dev);
229extern void intel_cleanup_overlay(struct drm_device *dev); 230extern void intel_cleanup_overlay(struct drm_device *dev);
diff --git a/drivers/gpu/drm/i915/intel_lvds.c b/drivers/gpu/drm/i915/intel_lvds.c
index 6a1accd83aec..31df55f0a0a7 100644
--- a/drivers/gpu/drm/i915/intel_lvds.c
+++ b/drivers/gpu/drm/i915/intel_lvds.c
@@ -983,8 +983,8 @@ void intel_lvds_init(struct drm_device *dev)
983 983
984 drm_connector_attach_property(&intel_connector->base, 984 drm_connector_attach_property(&intel_connector->base,
985 dev->mode_config.scaling_mode_property, 985 dev->mode_config.scaling_mode_property,
986 DRM_MODE_SCALE_FULLSCREEN); 986 DRM_MODE_SCALE_ASPECT);
987 lvds_priv->fitting_mode = DRM_MODE_SCALE_FULLSCREEN; 987 lvds_priv->fitting_mode = DRM_MODE_SCALE_ASPECT;
988 /* 988 /*
989 * LVDS discovery: 989 * LVDS discovery:
990 * 1) check for EDID on DDC 990 * 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..115d26b762cc 100644
--- a/drivers/gpu/drm/radeon/radeon_pm.c
+++ b/drivers/gpu/drm/radeon/radeon_pm.c
@@ -397,13 +397,20 @@ static ssize_t radeon_set_pm_method(struct device *dev,
397 rdev->pm.dynpm_planned_action = DYNPM_ACTION_DEFAULT; 397 rdev->pm.dynpm_planned_action = DYNPM_ACTION_DEFAULT;
398 mutex_unlock(&rdev->pm.mutex); 398 mutex_unlock(&rdev->pm.mutex);
399 } else if (strncmp("profile", buf, strlen("profile")) == 0) { 399 } else if (strncmp("profile", buf, strlen("profile")) == 0) {
400 bool flush_wq = false;
401
400 mutex_lock(&rdev->pm.mutex); 402 mutex_lock(&rdev->pm.mutex);
401 rdev->pm.pm_method = PM_METHOD_PROFILE; 403 if (rdev->pm.pm_method == PM_METHOD_DYNPM) {
404 cancel_delayed_work(&rdev->pm.dynpm_idle_work);
405 flush_wq = true;
406 }
402 /* disable dynpm */ 407 /* disable dynpm */
403 rdev->pm.dynpm_state = DYNPM_STATE_DISABLED; 408 rdev->pm.dynpm_state = DYNPM_STATE_DISABLED;
404 rdev->pm.dynpm_planned_action = DYNPM_ACTION_NONE; 409 rdev->pm.dynpm_planned_action = DYNPM_ACTION_NONE;
405 cancel_delayed_work(&rdev->pm.dynpm_idle_work); 410 rdev->pm.pm_method = PM_METHOD_PROFILE;
406 mutex_unlock(&rdev->pm.mutex); 411 mutex_unlock(&rdev->pm.mutex);
412 if (flush_wq)
413 flush_workqueue(rdev->wq);
407 } else { 414 } else {
408 DRM_ERROR("invalid power method!\n"); 415 DRM_ERROR("invalid power method!\n");
409 goto fail; 416 goto fail;
@@ -418,9 +425,18 @@ static DEVICE_ATTR(power_method, S_IRUGO | S_IWUSR, radeon_get_pm_method, radeon
418 425
419void radeon_pm_suspend(struct radeon_device *rdev) 426void radeon_pm_suspend(struct radeon_device *rdev)
420{ 427{
428 bool flush_wq = false;
429
421 mutex_lock(&rdev->pm.mutex); 430 mutex_lock(&rdev->pm.mutex);
422 cancel_delayed_work(&rdev->pm.dynpm_idle_work); 431 if (rdev->pm.pm_method == PM_METHOD_DYNPM) {
432 cancel_delayed_work(&rdev->pm.dynpm_idle_work);
433 if (rdev->pm.dynpm_state == DYNPM_STATE_ACTIVE)
434 rdev->pm.dynpm_state = DYNPM_STATE_SUSPENDED;
435 flush_wq = true;
436 }
423 mutex_unlock(&rdev->pm.mutex); 437 mutex_unlock(&rdev->pm.mutex);
438 if (flush_wq)
439 flush_workqueue(rdev->wq);
424} 440}
425 441
426void radeon_pm_resume(struct radeon_device *rdev) 442void radeon_pm_resume(struct radeon_device *rdev)
@@ -432,6 +448,12 @@ void radeon_pm_resume(struct radeon_device *rdev)
432 rdev->pm.current_sclk = rdev->clock.default_sclk; 448 rdev->pm.current_sclk = rdev->clock.default_sclk;
433 rdev->pm.current_mclk = rdev->clock.default_mclk; 449 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; 450 rdev->pm.current_vddc = rdev->pm.power_state[rdev->pm.default_power_state_index].clock_info[0].voltage.voltage;
451 if (rdev->pm.pm_method == PM_METHOD_DYNPM
452 && rdev->pm.dynpm_state == DYNPM_STATE_SUSPENDED) {
453 rdev->pm.dynpm_state = DYNPM_STATE_ACTIVE;
454 queue_delayed_work(rdev->wq, &rdev->pm.dynpm_idle_work,
455 msecs_to_jiffies(RADEON_IDLE_LOOP_MS));
456 }
435 mutex_unlock(&rdev->pm.mutex); 457 mutex_unlock(&rdev->pm.mutex);
436 radeon_pm_compute_clocks(rdev); 458 radeon_pm_compute_clocks(rdev);
437} 459}
@@ -486,6 +508,8 @@ int radeon_pm_init(struct radeon_device *rdev)
486void radeon_pm_fini(struct radeon_device *rdev) 508void radeon_pm_fini(struct radeon_device *rdev)
487{ 509{
488 if (rdev->pm.num_power_states > 1) { 510 if (rdev->pm.num_power_states > 1) {
511 bool flush_wq = false;
512
489 mutex_lock(&rdev->pm.mutex); 513 mutex_lock(&rdev->pm.mutex);
490 if (rdev->pm.pm_method == PM_METHOD_PROFILE) { 514 if (rdev->pm.pm_method == PM_METHOD_PROFILE) {
491 rdev->pm.profile = PM_PROFILE_DEFAULT; 515 rdev->pm.profile = PM_PROFILE_DEFAULT;
@@ -493,13 +517,16 @@ void radeon_pm_fini(struct radeon_device *rdev)
493 radeon_pm_set_clocks(rdev); 517 radeon_pm_set_clocks(rdev);
494 } else if (rdev->pm.pm_method == PM_METHOD_DYNPM) { 518 } else if (rdev->pm.pm_method == PM_METHOD_DYNPM) {
495 /* cancel work */ 519 /* cancel work */
496 cancel_delayed_work_sync(&rdev->pm.dynpm_idle_work); 520 cancel_delayed_work(&rdev->pm.dynpm_idle_work);
521 flush_wq = true;
497 /* reset default clocks */ 522 /* reset default clocks */
498 rdev->pm.dynpm_state = DYNPM_STATE_DISABLED; 523 rdev->pm.dynpm_state = DYNPM_STATE_DISABLED;
499 rdev->pm.dynpm_planned_action = DYNPM_ACTION_DEFAULT; 524 rdev->pm.dynpm_planned_action = DYNPM_ACTION_DEFAULT;
500 radeon_pm_set_clocks(rdev); 525 radeon_pm_set_clocks(rdev);
501 } 526 }
502 mutex_unlock(&rdev->pm.mutex); 527 mutex_unlock(&rdev->pm.mutex);
528 if (flush_wq)
529 flush_workqueue(rdev->wq);
503 530
504 device_remove_file(rdev->dev, &dev_attr_power_profile); 531 device_remove_file(rdev->dev, &dev_attr_power_profile);
505 device_remove_file(rdev->dev, &dev_attr_power_method); 532 device_remove_file(rdev->dev, &dev_attr_power_method);
@@ -720,12 +747,12 @@ static void radeon_dynpm_idle_work_handler(struct work_struct *work)
720 radeon_pm_get_dynpm_state(rdev); 747 radeon_pm_get_dynpm_state(rdev);
721 radeon_pm_set_clocks(rdev); 748 radeon_pm_set_clocks(rdev);
722 } 749 }
750
751 queue_delayed_work(rdev->wq, &rdev->pm.dynpm_idle_work,
752 msecs_to_jiffies(RADEON_IDLE_LOOP_MS));
723 } 753 }
724 mutex_unlock(&rdev->pm.mutex); 754 mutex_unlock(&rdev->pm.mutex);
725 ttm_bo_unlock_delayed_workqueue(&rdev->mman.bdev, resched); 755 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} 756}
730 757
731/* 758/*
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 0c28ed1eafa6..7065cb310553 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/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/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/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/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/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/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/bonding/bond_alb.c b/drivers/net/bonding/bond_alb.c
index 40fdc41446cc..df483076eda6 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;
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/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 46c69cd06553..28b53d1cd4f1 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/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..7b5d9764f317 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);
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 52dcc8495647..6474c4973d3a 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/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/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..5e52c75892df 100644
--- a/drivers/net/s2io.h
+++ b/drivers/net/s2io.h
@@ -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/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/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/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 ff9b5c882184..2f999fc94f60 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/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/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..2afbeec8b791 100644
--- a/drivers/power/ds2782_battery.c
+++ b/drivers/power/ds2782_battery.c
@@ -163,7 +163,7 @@ static int ds2782_get_capacity(struct ds278x_info *info, int *capacity)
163 if (err) 163 if (err)
164 return err; 164 return err;
165 *capacity = raw; 165 *capacity = raw;
166 return raw; 166 return 0;
167} 167}
168 168
169static int ds2786_get_current(struct ds278x_info *info, int *current_uA) 169static int ds2786_get_current(struct ds278x_info *info, int *current_uA)
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/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/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/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/serial/cpm_uart/cpm_uart_core.c b/drivers/serial/cpm_uart/cpm_uart_core.c
index 9eb62a256e9a..cd6cf575902e 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/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/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/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/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/s3c2410_udc.c b/drivers/usb/gadget/s3c2410_udc.c
index d5f4c1d45c97..e724a051bfdd 100644
--- a/drivers/usb/gadget/s3c2410_udc.c
+++ b/drivers/usb/gadget/s3c2410_udc.c
@@ -1700,9 +1700,13 @@ int usb_gadget_unregister_driver(struct usb_gadget_driver *driver)
1700 if (!driver || driver != udc->driver || !driver->unbind) 1700 if (!driver || driver != udc->driver || !driver->unbind)
1701 return -EINVAL; 1701 return -EINVAL;
1702 1702
1703 dprintk(DEBUG_NORMAL,"usb_gadget_register_driver() '%s'\n", 1703 dprintk(DEBUG_NORMAL, "usb_gadget_unregister_driver() '%s'\n",
1704 driver->driver.name); 1704 driver->driver.name);
1705 1705
1706 /* report disconnect */
1707 if (driver->disconnect)
1708 driver->disconnect(&udc->gadget);
1709
1706 driver->unbind(&udc->gadget); 1710 driver->unbind(&udc->gadget);
1707 1711
1708 device_del(&udc->gadget.dev); 1712 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..bd4027745aa7 100644
--- a/drivers/usb/host/ehci-mxc.c
+++ b/drivers/usb/host/ehci-mxc.c
@@ -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/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-ring.c b/drivers/usb/host/xhci-ring.c
index 9012098add6b..94e6934edb09 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),
@@ -2361,7 +2391,7 @@ static int queue_command(struct xhci_hcd *xhci, u32 field1, u32 field2,
2361 "unfailable commands failed.\n"); 2391 "unfailable commands failed.\n");
2362 return -ENOMEM; 2392 return -ENOMEM;
2363 } 2393 }
2364 queue_trb(xhci, xhci->cmd_ring, false, field1, field2, field3, 2394 queue_trb(xhci, xhci->cmd_ring, false, false, field1, field2, field3,
2365 field4 | xhci->cmd_ring->cycle_state); 2395 field4 | xhci->cmd_ring->cycle_state);
2366 return 0; 2396 return 0;
2367} 2397}
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/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..da7e334b0407 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) },
diff --git a/drivers/usb/serial/ftdi_sio_ids.h b/drivers/usb/serial/ftdi_sio_ids.h
index 94d86c3febcb..bbc159a1df45 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 */
diff --git a/drivers/usb/serial/qcserial.c b/drivers/usb/serial/qcserial.c
index 04bb759536bb..93d72eb8cafc 100644
--- a/drivers/usb/serial/qcserial.c
+++ b/drivers/usb/serial/qcserial.c
@@ -139,6 +139,7 @@ static int qcprobe(struct usb_serial *serial, const struct usb_device_id *id)
139 "Could not set interface, error %d\n", 139 "Could not set interface, error %d\n",
140 retval); 140 retval);
141 retval = -ENODEV; 141 retval = -ENODEV;
142 kfree(data);
142 } 143 }
143 return retval; 144 return retval;
144 } 145 }
@@ -155,6 +156,7 @@ static int qcprobe(struct usb_serial *serial, const struct usb_device_id *id)
155 "Could not set interface, error %d\n", 156 "Could not set interface, error %d\n",
156 retval); 157 retval);
157 retval = -ENODEV; 158 retval = -ENODEV;
159 kfree(data);
158 } 160 }
159 return retval; 161 return retval;
160 } 162 }
@@ -163,6 +165,7 @@ static int qcprobe(struct usb_serial *serial, const struct usb_device_id *id)
163 default: 165 default:
164 dev_err(&serial->dev->dev, 166 dev_err(&serial->dev->dev,
165 "unknown number of interfaces: %d\n", nintf); 167 "unknown number of interfaces: %d\n", nintf);
168 kfree(data);
166 return -ENODEV; 169 return -ENODEV;
167 } 170 }
168 171
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/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/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/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..afe7e21dd0ae 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++) {
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 = {