aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>2012-05-02 17:33:37 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2012-05-02 17:33:37 -0400
commiteb1574270a6de8fb8d31ffc3b021e30df0afcda3 (patch)
treed154ba369f222f5108ed1a2462d815d7faadc2e5 /drivers
parentaac10aaa8cc65a6fef6f5bc7d0b96035b0225a61 (diff)
parent69964ea4c7b68c9399f7977aa5b9aa6539a6a98a (diff)
Merge 3.4-rc5 into driver-core-next
This was done to resolve a merge issue with the init/main.c file. Reported-by: Stephen Rothwell <sfr@canb.auug.org.au> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/acpi/acpica/hwxface.c3
-rw-r--r--drivers/acpi/osl.c3
-rw-r--r--drivers/acpi/reboot.c3
-rw-r--r--drivers/acpi/sleep.c52
-rw-r--r--drivers/amba/bus.c42
-rw-r--r--drivers/ata/ata_piix.c2
-rw-r--r--drivers/ata/libata-core.c4
-rw-r--r--drivers/ata/libata-scsi.c4
-rw-r--r--drivers/ata/libata-transport.c1
-rw-r--r--drivers/ata/libata.h2
-rw-r--r--drivers/ata/sata_mv.c3
-rw-r--r--drivers/base/soc.c4
-rw-r--r--drivers/bcma/Kconfig2
-rw-r--r--drivers/bcma/driver_pci_host.c1
-rw-r--r--drivers/bcma/sprom.c7
-rw-r--r--drivers/block/cciss_scsi.c3
-rw-r--r--drivers/block/mtip32xx/Kconfig2
-rw-r--r--drivers/block/mtip32xx/mtip32xx.c860
-rw-r--r--drivers/block/mtip32xx/mtip32xx.h58
-rw-r--r--drivers/block/virtio_blk.c42
-rw-r--r--drivers/block/xen-blkback/blkback.c50
-rw-r--r--drivers/block/xen-blkback/common.h6
-rw-r--r--drivers/block/xen-blkback/xenbus.c89
-rw-r--r--drivers/block/xen-blkfront.c41
-rw-r--r--drivers/bluetooth/ath3k.c4
-rw-r--r--drivers/bluetooth/btusb.c5
-rw-r--r--drivers/bluetooth/hci_ldisc.c2
-rw-r--r--drivers/char/hpet.c4
-rw-r--r--drivers/char/random.c11
-rw-r--r--drivers/clocksource/acpi_pm.c24
-rw-r--r--drivers/cpufreq/Kconfig.arm1
-rw-r--r--drivers/crypto/ixp4xx_crypto.c1
-rw-r--r--drivers/crypto/talitos.c20
-rw-r--r--drivers/dma/Kconfig5
-rw-r--r--drivers/dma/amba-pl08x.c1
-rw-r--r--drivers/dma/at_hdmac.c4
-rw-r--r--drivers/dma/dmaengine.c14
-rw-r--r--drivers/dma/imx-dma.c9
-rw-r--r--drivers/dma/ioat/dma.c16
-rw-r--r--drivers/dma/ioat/dma.h6
-rw-r--r--drivers/dma/ioat/dma_v2.c12
-rw-r--r--drivers/dma/ioat/dma_v2.h4
-rw-r--r--drivers/dma/ioat/dma_v3.c49
-rw-r--r--drivers/dma/iop-adma.c4
-rw-r--r--drivers/dma/mxs-dma.c10
-rw-r--r--drivers/dma/pl330.c25
-rw-r--r--drivers/dma/ste_dma40.c323
-rw-r--r--drivers/dma/ste_dma40_ll.h2
-rw-r--r--drivers/gpio/Kconfig2
-rw-r--r--drivers/gpio/gpio-adp5588.c2
-rw-r--r--drivers/gpio/gpio-pxa.c21
-rw-r--r--drivers/gpio/gpio-samsung.c16
-rw-r--r--drivers/gpio/gpio-sodaville.c23
-rw-r--r--drivers/gpu/drm/drm_bufs.c12
-rw-r--r--drivers/gpu/drm/drm_crtc.c10
-rw-r--r--drivers/gpu/drm/drm_fops.c6
-rw-r--r--drivers/gpu/drm/drm_usb.c6
-rw-r--r--drivers/gpu/drm/exynos/exynos_drm_buf.c47
-rw-r--r--drivers/gpu/drm/exynos/exynos_drm_core.c14
-rw-r--r--drivers/gpu/drm/exynos/exynos_drm_drv.h10
-rw-r--r--drivers/gpu/drm/exynos/exynos_drm_fimd.c20
-rw-r--r--drivers/gpu/drm/exynos/exynos_drm_gem.c79
-rw-r--r--drivers/gpu/drm/exynos/exynos_drm_gem.h2
-rw-r--r--drivers/gpu/drm/exynos/exynos_drm_hdmi.c107
-rw-r--r--drivers/gpu/drm/exynos/exynos_drm_hdmi.h23
-rw-r--r--drivers/gpu/drm/exynos/exynos_drm_plane.c4
-rw-r--r--drivers/gpu/drm/exynos/exynos_drm_vidi.c20
-rw-r--r--drivers/gpu/drm/exynos/exynos_hdmi.c42
-rw-r--r--drivers/gpu/drm/exynos/exynos_mixer.c40
-rw-r--r--drivers/gpu/drm/gma500/mdfld_dsi_output.h1
-rw-r--r--drivers/gpu/drm/i810/i810_dma.c6
-rw-r--r--drivers/gpu/drm/i915/i915_drv.c2
-rw-r--r--drivers/gpu/drm/i915/i915_gem.c6
-rw-r--r--drivers/gpu/drm/i915/i915_gem_execbuffer.c8
-rw-r--r--drivers/gpu/drm/i915/i915_reg.h4
-rw-r--r--drivers/gpu/drm/i915/intel_crt.c29
-rw-r--r--drivers/gpu/drm/i915/intel_display.c84
-rw-r--r--drivers/gpu/drm/i915/intel_dp.c49
-rw-r--r--drivers/gpu/drm/i915/intel_drv.h4
-rw-r--r--drivers/gpu/drm/i915/intel_fb.c4
-rw-r--r--drivers/gpu/drm/i915/intel_i2c.c2
-rw-r--r--drivers/gpu/drm/i915/intel_lvds.c6
-rw-r--r--drivers/gpu/drm/i915/intel_panel.c2
-rw-r--r--drivers/gpu/drm/i915/intel_ringbuffer.c10
-rw-r--r--drivers/gpu/drm/i915/intel_sdvo.c34
-rw-r--r--drivers/gpu/drm/i915/intel_sprite.c1
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_pm.c1
-rw-r--r--drivers/gpu/drm/nouveau/nv50_sor.c2
-rw-r--r--drivers/gpu/drm/radeon/atombios_crtc.c7
-rw-r--r--drivers/gpu/drm/radeon/atombios_encoders.c4
-rw-r--r--drivers/gpu/drm/radeon/r100.c2
-rw-r--r--drivers/gpu/drm/radeon/r600.c6
-rw-r--r--drivers/gpu/drm/radeon/r600_cp.c6
-rw-r--r--drivers/gpu/drm/radeon/radeon_clocks.c24
-rw-r--r--drivers/gpu/drm/radeon/radeon_combios.c8
-rw-r--r--drivers/gpu/drm/radeon/radeon_connectors.c4
-rw-r--r--drivers/gpu/drm/radeon/radeon_display.c3
-rw-r--r--drivers/gpu/drm/radeon/radeon_i2c.c4
-rw-r--r--drivers/gpu/drm/radeon/radeon_irq_kms.c6
-rw-r--r--drivers/gpu/drm/radeon/radeon_legacy_encoders.c12
-rw-r--r--drivers/gpu/drm/radeon/rv770.c4
-rw-r--r--drivers/gpu/drm/radeon/si.c5
-rw-r--r--drivers/gpu/drm/savage/savage_state.c6
-rw-r--r--drivers/hid/Kconfig2
-rw-r--r--drivers/hid/hid-tivo.c2
-rw-r--r--drivers/hsi/clients/hsi_char.c2
-rw-r--r--drivers/hsi/hsi.c223
-rw-r--r--drivers/hwmon/acpi_power_meter.c1
-rw-r--r--drivers/hwmon/ad7314.c12
-rw-r--r--drivers/hwmon/ads1015.c33
-rw-r--r--drivers/hwmon/fam15h_power.c42
-rw-r--r--drivers/hwmon/pmbus/pmbus_core.c17
-rw-r--r--drivers/hwmon/smsc47b397.c14
-rw-r--r--drivers/hwmon/smsc47m1.c19
-rw-r--r--drivers/i2c/busses/i2c-designware-pcidrv.c1
-rw-r--r--drivers/infiniband/core/mad.c8
-rw-r--r--drivers/infiniband/core/sysfs.c9
-rw-r--r--drivers/infiniband/hw/mlx4/main.c7
-rw-r--r--drivers/infiniband/ulp/srpt/ib_srpt.c1
-rw-r--r--drivers/input/misc/Kconfig3
-rw-r--r--drivers/input/misc/da9052_onkey.c3
-rw-r--r--drivers/input/misc/twl6040-vibra.c4
-rw-r--r--drivers/input/mouse/elantech.c10
-rw-r--r--drivers/input/mouse/gpio_mouse.c2
-rw-r--r--drivers/input/mouse/sentelic.c8
-rw-r--r--drivers/input/mouse/trackpoint.c14
-rw-r--r--drivers/input/touchscreen/tps6507x-ts.c4
-rw-r--r--drivers/isdn/gigaset/interface.c2
-rw-r--r--drivers/leds/leds-atmel-pwm.c2
-rw-r--r--drivers/md/bitmap.c5
-rw-r--r--drivers/md/dm-raid.c4
-rw-r--r--drivers/md/md.c7
-rw-r--r--drivers/md/raid1.c3
-rw-r--r--drivers/md/raid10.c4
-rw-r--r--drivers/media/common/tuners/xc5000.c39
-rw-r--r--drivers/media/common/tuners/xc5000.h1
-rw-r--r--drivers/media/dvb/dvb-core/dvb_frontend.c37
-rw-r--r--drivers/media/dvb/dvb-usb/it913x.c54
-rw-r--r--drivers/media/dvb/frontends/drxk_hard.c6
-rw-r--r--drivers/media/rc/winbond-cir.c1
-rw-r--r--drivers/media/video/Kconfig2
-rw-r--r--drivers/media/video/ivtv/ivtv-ioctl.c4
-rw-r--r--drivers/media/video/mt9m032.c5
-rw-r--r--drivers/media/video/uvc/uvc_video.c50
-rw-r--r--drivers/mfd/Kconfig11
-rw-r--r--drivers/mfd/asic3.c4
-rw-r--r--drivers/mfd/db8500-prcmu.c1
-rw-r--r--drivers/mfd/omap-usb-host.c44
-rw-r--r--drivers/mfd/rc5t583.c39
-rw-r--r--drivers/mfd/twl6040-core.c114
-rw-r--r--drivers/mmc/card/block.c56
-rw-r--r--drivers/mmc/card/queue.c2
-rw-r--r--drivers/mmc/core/bus.c24
-rw-r--r--drivers/mmc/core/cd-gpio.c1
-rw-r--r--drivers/mmc/core/core.c64
-rw-r--r--drivers/mmc/host/dw_mmc.c7
-rw-r--r--drivers/mmc/host/mxs-mmc.c3
-rw-r--r--drivers/mmc/host/omap_hsmmc.c6
-rw-r--r--drivers/mmc/host/sdhci-esdhc-imx.c3
-rw-r--r--drivers/mmc/host/sdhci.c2
-rw-r--r--drivers/mtd/mtdchar.c20
-rw-r--r--drivers/mtd/nand/gpmi-nand/gpmi-nand.c1
-rw-r--r--drivers/net/arcnet/arc-rimi.c8
-rw-r--r--drivers/net/caif/caif_hsi.c9
-rw-r--r--drivers/net/can/usb/peak_usb/pcan_usb_pro.c2
-rw-r--r--drivers/net/dummy.c6
-rw-r--r--drivers/net/ethernet/atheros/atlx/atl1.c12
-rw-r--r--drivers/net/ethernet/atheros/atlx/atl1.h3
-rw-r--r--drivers/net/ethernet/atheros/atlx/atlx.c2
-rw-r--r--drivers/net/ethernet/broadcom/bnx2x/bnx2x_link.c12
-rw-r--r--drivers/net/ethernet/intel/e1000e/ich8lan.c15
-rw-r--r--drivers/net/ethernet/intel/ixgbe/ixgbe_lib.c10
-rw-r--r--drivers/net/ethernet/intel/ixgbe/ixgbe_main.c20
-rw-r--r--drivers/net/ethernet/micrel/ks8851.c21
-rw-r--r--drivers/net/ethernet/micrel/ks8851_mll.c2
-rw-r--r--drivers/net/ethernet/micrel/ksz884x.c2
-rw-r--r--drivers/net/ethernet/realtek/8139cp.c10
-rw-r--r--drivers/net/ethernet/smsc/smsc911x.c17
-rw-r--r--drivers/net/ethernet/ti/davinci_mdio.c5
-rw-r--r--drivers/net/ethernet/xilinx/xilinx_axienet.h4
-rw-r--r--drivers/net/ethernet/xilinx/xilinx_axienet_main.c6
-rw-r--r--drivers/net/ethernet/xilinx/xilinx_axienet_mdio.c6
-rw-r--r--drivers/net/hyperv/netvsc_drv.c38
-rw-r--r--drivers/net/phy/icplus.c12
-rw-r--r--drivers/net/ppp/ppp_generic.c15
-rw-r--r--drivers/net/usb/qmi_wwan.c30
-rw-r--r--drivers/net/usb/smsc75xx.c1
-rw-r--r--drivers/net/virtio_net.c5
-rw-r--r--drivers/net/wan/farsync.c1
-rw-r--r--drivers/net/wireless/ath/ath5k/ahb.c7
-rw-r--r--drivers/net/wireless/ath/ath9k/main.c17
-rw-r--r--drivers/net/wireless/ath/ath9k/xmit.c10
-rw-r--r--drivers/net/wireless/brcm80211/brcmsmac/main.c8
-rw-r--r--drivers/net/wireless/libertas/cfg.c9
-rw-r--r--drivers/net/wireless/mwifiex/pcie.h18
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00dev.c6
-rw-r--r--drivers/net/wireless/rtlwifi/base.c5
-rw-r--r--drivers/net/wireless/rtlwifi/pci.c7
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8192de/sw.c6
-rw-r--r--drivers/net/wireless/rtlwifi/usb.c34
-rw-r--r--drivers/net/wireless/rtlwifi/wifi.h6
-rw-r--r--drivers/of/gpio.c2
-rw-r--r--drivers/pci/Makefile1
-rw-r--r--drivers/pci/pci.c71
-rw-r--r--drivers/pinctrl/core.c25
-rw-r--r--drivers/platform/x86/acerhdf.c67
-rw-r--r--drivers/platform/x86/dell-laptop.c1
-rw-r--r--drivers/platform/x86/intel_ips.c2
-rw-r--r--drivers/regulator/anatop-regulator.c6
-rw-r--r--drivers/rtc/rtc-ds1307.c1
-rw-r--r--drivers/rtc/rtc-efi.c1
-rw-r--r--drivers/rtc/rtc-pl031.c3
-rw-r--r--drivers/rtc/rtc-r9701.c22
-rw-r--r--drivers/rtc/rtc-s3c.c31
-rw-r--r--drivers/rtc/rtc-twl.c43
-rw-r--r--drivers/s390/block/dasd_eckd.c24
-rw-r--r--drivers/s390/char/vmur.c2
-rw-r--r--drivers/scsi/scsi_error.c2
-rw-r--r--drivers/spi/Kconfig2
-rw-r--r--drivers/spi/Makefile2
-rw-r--r--drivers/spi/spi-bcm63xx.c163
-rw-r--r--drivers/spi/spi-bfin-sport.c21
-rw-r--r--drivers/spi/spi-bfin5xx.c14
-rw-r--r--drivers/spi/spi-davinci.c6
-rw-r--r--drivers/spi/spi-ep93xx.c24
-rw-r--r--drivers/spi/spi-fsl-spi.c4
-rw-r--r--drivers/spi/spi-imx.c12
-rw-r--r--drivers/spi/spi-pl022.c60
-rw-r--r--drivers/staging/android/Kconfig3
-rw-r--r--drivers/staging/android/lowmemorykiller.c48
-rw-r--r--drivers/staging/android/persistent_ram.c11
-rw-r--r--drivers/staging/android/timed_gpio.c27
-rw-r--r--drivers/staging/iio/inkern.c1
-rw-r--r--drivers/staging/iio/magnetometer/ak8975.c8
-rw-r--r--drivers/staging/iio/magnetometer/hmc5843.c4
-rw-r--r--drivers/staging/media/as102/as102_fw.c2
-rw-r--r--drivers/staging/octeon/ethernet-rx.c1
-rw-r--r--drivers/staging/octeon/ethernet-tx.c1
-rw-r--r--drivers/staging/octeon/ethernet.c1
-rw-r--r--drivers/staging/omapdrm/omap_drv.c7
-rw-r--r--drivers/staging/ozwpan/TODO4
-rw-r--r--drivers/staging/ozwpan/ozpd.c2
-rw-r--r--drivers/staging/ramster/Kconfig6
-rw-r--r--drivers/staging/rts_pstor/ms.c3
-rw-r--r--drivers/staging/rts_pstor/rtsx.c5
-rw-r--r--drivers/staging/rts_pstor/rtsx_transport.c11
-rw-r--r--drivers/staging/sep/sep_main.c6
-rw-r--r--drivers/staging/tidspbridge/core/tiomap3430.c20
-rw-r--r--drivers/staging/tidspbridge/core/wdt.c8
-rw-r--r--drivers/staging/vme/devices/vme_pio2_core.c4
-rw-r--r--drivers/staging/vt6655/key.c3
-rw-r--r--drivers/staging/vt6656/ioctl.c3
-rw-r--r--drivers/staging/vt6656/key.c3
-rw-r--r--drivers/staging/xgifb/vb_init.c2
-rw-r--r--drivers/staging/xgifb/vb_setmode.c7
-rw-r--r--drivers/staging/xgifb/vb_table.h11
-rw-r--r--drivers/staging/zcache/Kconfig2
-rw-r--r--drivers/staging/zsmalloc/zsmalloc-main.c30
-rw-r--r--drivers/tty/amiserial.c4
-rw-r--r--drivers/tty/serial/8250/8250.c12
-rw-r--r--drivers/tty/serial/8250/8250_pci.c16
-rw-r--r--drivers/tty/serial/Kconfig2
-rw-r--r--drivers/tty/serial/altera_uart.c4
-rw-r--r--drivers/tty/serial/amba-pl011.c8
-rw-r--r--drivers/tty/serial/atmel_serial.c4
-rw-r--r--drivers/tty/serial/clps711x.c14
-rw-r--r--drivers/tty/serial/omap-serial.c43
-rw-r--r--drivers/tty/serial/pch_uart.c12
-rw-r--r--drivers/tty/serial/samsung.c1
-rw-r--r--drivers/tty/vt/vt.c3
-rw-r--r--drivers/usb/Kconfig16
-rw-r--r--drivers/usb/class/cdc-wdm.c7
-rw-r--r--drivers/usb/core/driver.c9
-rw-r--r--drivers/usb/core/hcd-pci.c9
-rw-r--r--drivers/usb/core/hcd.c12
-rw-r--r--drivers/usb/core/hub.c19
-rw-r--r--drivers/usb/core/message.c17
-rw-r--r--drivers/usb/core/urb.c12
-rw-r--r--drivers/usb/dwc3/core.c6
-rw-r--r--drivers/usb/dwc3/ep0.c12
-rw-r--r--drivers/usb/gadget/at91_udc.c8
-rw-r--r--drivers/usb/gadget/dummy_hcd.c1
-rw-r--r--drivers/usb/gadget/f_fs.c3
-rw-r--r--drivers/usb/gadget/f_mass_storage.c2
-rw-r--r--drivers/usb/gadget/f_rndis.c1
-rw-r--r--drivers/usb/gadget/file_storage.c2
-rw-r--r--drivers/usb/gadget/fsl_udc_core.c25
-rw-r--r--drivers/usb/gadget/g_ffs.c4
-rw-r--r--drivers/usb/gadget/inode.c1
-rw-r--r--drivers/usb/gadget/s3c-hsotg.c17
-rw-r--r--drivers/usb/gadget/udc-core.c6
-rw-r--r--drivers/usb/gadget/uvc.h2
-rw-r--r--drivers/usb/gadget/uvc_queue.c4
-rw-r--r--drivers/usb/gadget/uvc_v4l2.c2
-rw-r--r--drivers/usb/host/ehci-fsl.c7
-rw-r--r--drivers/usb/host/ehci-hcd.c12
-rw-r--r--drivers/usb/host/ehci-hub.c31
-rw-r--r--drivers/usb/host/ehci-omap.c39
-rw-r--r--drivers/usb/host/ehci-pci.c8
-rw-r--r--drivers/usb/host/ehci-tegra.c3
-rw-r--r--drivers/usb/host/ehci.h2
-rw-r--r--drivers/usb/host/ohci-at91.c12
-rw-r--r--drivers/usb/host/pci-quirks.c10
-rw-r--r--drivers/usb/host/uhci-hub.c5
-rw-r--r--drivers/usb/host/xhci-dbg.c2
-rw-r--r--drivers/usb/host/xhci-ext-caps.h5
-rw-r--r--drivers/usb/host/xhci-mem.c9
-rw-r--r--drivers/usb/host/xhci-pci.c4
-rw-r--r--drivers/usb/host/xhci-ring.c6
-rw-r--r--drivers/usb/host/xhci.c12
-rw-r--r--drivers/usb/host/xhci.h4
-rw-r--r--drivers/usb/misc/usbtest.c9
-rw-r--r--drivers/usb/misc/yurex.c10
-rw-r--r--drivers/usb/musb/davinci.c3
-rw-r--r--drivers/usb/musb/musb_core.c40
-rw-r--r--drivers/usb/musb/musb_core.h2
-rw-r--r--drivers/usb/musb/musb_host.c2
-rw-r--r--drivers/usb/musb/omap2430.c31
-rw-r--r--drivers/usb/otg/gpio_vbus.c15
-rw-r--r--drivers/usb/serial/bus.c5
-rw-r--r--drivers/usb/serial/cp210x.c9
-rw-r--r--drivers/usb/serial/ftdi_sio.c36
-rw-r--r--drivers/usb/serial/metro-usb.c6
-rw-r--r--drivers/usb/serial/option.c1
-rw-r--r--drivers/usb/serial/pl2303.c2
-rw-r--r--drivers/usb/serial/sierra.c5
-rw-r--r--drivers/usb/serial/usb-serial.c31
-rw-r--r--drivers/usb/storage/usb.c30
-rw-r--r--drivers/uwb/hwa-rc.c3
-rw-r--r--drivers/uwb/neh.c12
-rw-r--r--drivers/vhost/net.c2
-rw-r--r--drivers/vhost/test.c2
-rw-r--r--drivers/vhost/vhost.c5
-rw-r--r--drivers/vhost/vhost.h2
-rw-r--r--drivers/video/au1100fb.c5
-rw-r--r--drivers/video/au1200fb.c2
-rw-r--r--drivers/video/bfin-lq035q1-fb.c1
-rw-r--r--drivers/video/kyro/STG4000Reg.h376
-rw-r--r--drivers/video/msm/mddi.c8
-rw-r--r--drivers/video/uvesafb.c11
-rw-r--r--drivers/virtio/virtio_balloon.c58
-rw-r--r--drivers/watchdog/hpwdt.c6
-rw-r--r--drivers/xen/events.c2
-rw-r--r--drivers/xen/gntdev.c2
-rw-r--r--drivers/xen/grant-table.c13
-rw-r--r--drivers/xen/manage.c1
-rw-r--r--drivers/xen/xen-acpi-processor.c5
-rw-r--r--drivers/xen/xenbus/xenbus_probe_frontend.c69
348 files changed, 3888 insertions, 2459 deletions
diff --git a/drivers/acpi/acpica/hwxface.c b/drivers/acpi/acpica/hwxface.c
index ab513a972c95..a716fede4f25 100644
--- a/drivers/acpi/acpica/hwxface.c
+++ b/drivers/acpi/acpica/hwxface.c
@@ -74,7 +74,8 @@ acpi_status acpi_reset(void)
74 74
75 /* Check if the reset register is supported */ 75 /* Check if the reset register is supported */
76 76
77 if (!reset_reg->address) { 77 if (!(acpi_gbl_FADT.flags & ACPI_FADT_RESET_REGISTER) ||
78 !reset_reg->address) {
78 return_ACPI_STATUS(AE_NOT_EXIST); 79 return_ACPI_STATUS(AE_NOT_EXIST);
79 } 80 }
80 81
diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c
index ba14fb93c929..c3881b2eb8b2 100644
--- a/drivers/acpi/osl.c
+++ b/drivers/acpi/osl.c
@@ -607,8 +607,7 @@ acpi_os_install_interrupt_handler(u32 gsi, acpi_osd_handler handler,
607 607
608 acpi_irq_handler = handler; 608 acpi_irq_handler = handler;
609 acpi_irq_context = context; 609 acpi_irq_context = context;
610 if (request_threaded_irq(irq, NULL, acpi_irq, IRQF_SHARED, "acpi", 610 if (request_irq(irq, acpi_irq, IRQF_SHARED, "acpi", acpi_irq)) {
611 acpi_irq)) {
612 printk(KERN_ERR PREFIX "SCI (IRQ%d) allocation failed\n", irq); 611 printk(KERN_ERR PREFIX "SCI (IRQ%d) allocation failed\n", irq);
613 acpi_irq_handler = NULL; 612 acpi_irq_handler = NULL;
614 return AE_NOT_ACQUIRED; 613 return AE_NOT_ACQUIRED;
diff --git a/drivers/acpi/reboot.c b/drivers/acpi/reboot.c
index c1d612435939..a6c77e8b37bd 100644
--- a/drivers/acpi/reboot.c
+++ b/drivers/acpi/reboot.c
@@ -23,7 +23,8 @@ void acpi_reboot(void)
23 /* Is the reset register supported? The spec says we should be 23 /* Is the reset register supported? The spec says we should be
24 * checking the bit width and bit offset, but Windows ignores 24 * checking the bit width and bit offset, but Windows ignores
25 * these fields */ 25 * these fields */
26 /* Ignore also acpi_gbl_FADT.flags.ACPI_FADT_RESET_REGISTER */ 26 if (!(acpi_gbl_FADT.flags & ACPI_FADT_RESET_REGISTER))
27 return;
27 28
28 reset_value = acpi_gbl_FADT.reset_value; 29 reset_value = acpi_gbl_FADT.reset_value;
29 30
diff --git a/drivers/acpi/sleep.c b/drivers/acpi/sleep.c
index 1d661b5c3287..eb6fd233764b 100644
--- a/drivers/acpi/sleep.c
+++ b/drivers/acpi/sleep.c
@@ -28,23 +28,33 @@
28#include "internal.h" 28#include "internal.h"
29#include "sleep.h" 29#include "sleep.h"
30 30
31u8 wake_sleep_flags = ACPI_NO_OPTIONAL_METHODS;
31static unsigned int gts, bfs; 32static unsigned int gts, bfs;
32module_param(gts, uint, 0644); 33static int set_param_wake_flag(const char *val, struct kernel_param *kp)
33module_param(bfs, uint, 0644);
34MODULE_PARM_DESC(gts, "Enable evaluation of _GTS on suspend.");
35MODULE_PARM_DESC(bfs, "Enable evaluation of _BFS on resume".);
36
37static u8 wake_sleep_flags(void)
38{ 34{
39 u8 flags = ACPI_NO_OPTIONAL_METHODS; 35 int ret = param_set_int(val, kp);
40 36
41 if (gts) 37 if (ret)
42 flags |= ACPI_EXECUTE_GTS; 38 return ret;
43 if (bfs)
44 flags |= ACPI_EXECUTE_BFS;
45 39
46 return flags; 40 if (kp->arg == (const char *)&gts) {
41 if (gts)
42 wake_sleep_flags |= ACPI_EXECUTE_GTS;
43 else
44 wake_sleep_flags &= ~ACPI_EXECUTE_GTS;
45 }
46 if (kp->arg == (const char *)&bfs) {
47 if (bfs)
48 wake_sleep_flags |= ACPI_EXECUTE_BFS;
49 else
50 wake_sleep_flags &= ~ACPI_EXECUTE_BFS;
51 }
52 return ret;
47} 53}
54module_param_call(gts, set_param_wake_flag, param_get_int, &gts, 0644);
55module_param_call(bfs, set_param_wake_flag, param_get_int, &bfs, 0644);
56MODULE_PARM_DESC(gts, "Enable evaluation of _GTS on suspend.");
57MODULE_PARM_DESC(bfs, "Enable evaluation of _BFS on resume".);
48 58
49static u8 sleep_states[ACPI_S_STATE_COUNT]; 59static u8 sleep_states[ACPI_S_STATE_COUNT];
50 60
@@ -263,7 +273,6 @@ static int acpi_suspend_enter(suspend_state_t pm_state)
263{ 273{
264 acpi_status status = AE_OK; 274 acpi_status status = AE_OK;
265 u32 acpi_state = acpi_target_sleep_state; 275 u32 acpi_state = acpi_target_sleep_state;
266 u8 flags = wake_sleep_flags();
267 int error; 276 int error;
268 277
269 ACPI_FLUSH_CPU_CACHE(); 278 ACPI_FLUSH_CPU_CACHE();
@@ -271,7 +280,7 @@ static int acpi_suspend_enter(suspend_state_t pm_state)
271 switch (acpi_state) { 280 switch (acpi_state) {
272 case ACPI_STATE_S1: 281 case ACPI_STATE_S1:
273 barrier(); 282 barrier();
274 status = acpi_enter_sleep_state(acpi_state, flags); 283 status = acpi_enter_sleep_state(acpi_state, wake_sleep_flags);
275 break; 284 break;
276 285
277 case ACPI_STATE_S3: 286 case ACPI_STATE_S3:
@@ -286,7 +295,7 @@ static int acpi_suspend_enter(suspend_state_t pm_state)
286 acpi_write_bit_register(ACPI_BITREG_SCI_ENABLE, 1); 295 acpi_write_bit_register(ACPI_BITREG_SCI_ENABLE, 1);
287 296
288 /* Reprogram control registers and execute _BFS */ 297 /* Reprogram control registers and execute _BFS */
289 acpi_leave_sleep_state_prep(acpi_state, flags); 298 acpi_leave_sleep_state_prep(acpi_state, wake_sleep_flags);
290 299
291 /* ACPI 3.0 specs (P62) says that it's the responsibility 300 /* ACPI 3.0 specs (P62) says that it's the responsibility
292 * of the OSPM to clear the status bit [ implying that the 301 * of the OSPM to clear the status bit [ implying that the
@@ -550,30 +559,27 @@ static int acpi_hibernation_begin(void)
550 559
551static int acpi_hibernation_enter(void) 560static int acpi_hibernation_enter(void)
552{ 561{
553 u8 flags = wake_sleep_flags();
554 acpi_status status = AE_OK; 562 acpi_status status = AE_OK;
555 563
556 ACPI_FLUSH_CPU_CACHE(); 564 ACPI_FLUSH_CPU_CACHE();
557 565
558 /* This shouldn't return. If it returns, we have a problem */ 566 /* This shouldn't return. If it returns, we have a problem */
559 status = acpi_enter_sleep_state(ACPI_STATE_S4, flags); 567 status = acpi_enter_sleep_state(ACPI_STATE_S4, wake_sleep_flags);
560 /* Reprogram control registers and execute _BFS */ 568 /* Reprogram control registers and execute _BFS */
561 acpi_leave_sleep_state_prep(ACPI_STATE_S4, flags); 569 acpi_leave_sleep_state_prep(ACPI_STATE_S4, wake_sleep_flags);
562 570
563 return ACPI_SUCCESS(status) ? 0 : -EFAULT; 571 return ACPI_SUCCESS(status) ? 0 : -EFAULT;
564} 572}
565 573
566static void acpi_hibernation_leave(void) 574static void acpi_hibernation_leave(void)
567{ 575{
568 u8 flags = wake_sleep_flags();
569
570 /* 576 /*
571 * If ACPI is not enabled by the BIOS and the boot kernel, we need to 577 * If ACPI is not enabled by the BIOS and the boot kernel, we need to
572 * enable it here. 578 * enable it here.
573 */ 579 */
574 acpi_enable(); 580 acpi_enable();
575 /* Reprogram control registers and execute _BFS */ 581 /* Reprogram control registers and execute _BFS */
576 acpi_leave_sleep_state_prep(ACPI_STATE_S4, flags); 582 acpi_leave_sleep_state_prep(ACPI_STATE_S4, wake_sleep_flags);
577 /* Check the hardware signature */ 583 /* Check the hardware signature */
578 if (facs && s4_hardware_signature != facs->hardware_signature) { 584 if (facs && s4_hardware_signature != facs->hardware_signature) {
579 printk(KERN_EMERG "ACPI: Hardware changed while hibernated, " 585 printk(KERN_EMERG "ACPI: Hardware changed while hibernated, "
@@ -828,12 +834,10 @@ static void acpi_power_off_prepare(void)
828 834
829static void acpi_power_off(void) 835static void acpi_power_off(void)
830{ 836{
831 u8 flags = wake_sleep_flags();
832
833 /* acpi_sleep_prepare(ACPI_STATE_S5) should have already been called */ 837 /* acpi_sleep_prepare(ACPI_STATE_S5) should have already been called */
834 printk(KERN_DEBUG "%s called\n", __func__); 838 printk(KERN_DEBUG "%s called\n", __func__);
835 local_irq_disable(); 839 local_irq_disable();
836 acpi_enter_sleep_state(ACPI_STATE_S5, flags); 840 acpi_enter_sleep_state(ACPI_STATE_S5, wake_sleep_flags);
837} 841}
838 842
839/* 843/*
diff --git a/drivers/amba/bus.c b/drivers/amba/bus.c
index 01c2cf4efcdd..cc273226dbd0 100644
--- a/drivers/amba/bus.c
+++ b/drivers/amba/bus.c
@@ -247,8 +247,7 @@ static int amba_pm_restore(struct device *dev)
247/* 247/*
248 * Hooks to provide runtime PM of the pclk (bus clock). It is safe to 248 * Hooks to provide runtime PM of the pclk (bus clock). It is safe to
249 * enable/disable the bus clock at runtime PM suspend/resume as this 249 * enable/disable the bus clock at runtime PM suspend/resume as this
250 * does not result in loss of context. However, disabling vcore power 250 * does not result in loss of context.
251 * would do, so we leave that to the driver.
252 */ 251 */
253static int amba_pm_runtime_suspend(struct device *dev) 252static int amba_pm_runtime_suspend(struct device *dev)
254{ 253{
@@ -354,39 +353,6 @@ static void amba_put_disable_pclk(struct amba_device *pcdev)
354 clk_put(pclk); 353 clk_put(pclk);
355} 354}
356 355
357static int amba_get_enable_vcore(struct amba_device *pcdev)
358{
359 struct regulator *vcore = regulator_get(&pcdev->dev, "vcore");
360 int ret;
361
362 pcdev->vcore = vcore;
363
364 if (IS_ERR(vcore)) {
365 /* It is OK not to supply a vcore regulator */
366 if (PTR_ERR(vcore) == -ENODEV)
367 return 0;
368 return PTR_ERR(vcore);
369 }
370
371 ret = regulator_enable(vcore);
372 if (ret) {
373 regulator_put(vcore);
374 pcdev->vcore = ERR_PTR(-ENODEV);
375 }
376
377 return ret;
378}
379
380static void amba_put_disable_vcore(struct amba_device *pcdev)
381{
382 struct regulator *vcore = pcdev->vcore;
383
384 if (!IS_ERR(vcore)) {
385 regulator_disable(vcore);
386 regulator_put(vcore);
387 }
388}
389
390/* 356/*
391 * These are the device model conversion veneers; they convert the 357 * These are the device model conversion veneers; they convert the
392 * device model structures to our more specific structures. 358 * device model structures to our more specific structures.
@@ -399,10 +365,6 @@ static int amba_probe(struct device *dev)
399 int ret; 365 int ret;
400 366
401 do { 367 do {
402 ret = amba_get_enable_vcore(pcdev);
403 if (ret)
404 break;
405
406 ret = amba_get_enable_pclk(pcdev); 368 ret = amba_get_enable_pclk(pcdev);
407 if (ret) 369 if (ret)
408 break; 370 break;
@@ -420,7 +382,6 @@ static int amba_probe(struct device *dev)
420 pm_runtime_put_noidle(dev); 382 pm_runtime_put_noidle(dev);
421 383
422 amba_put_disable_pclk(pcdev); 384 amba_put_disable_pclk(pcdev);
423 amba_put_disable_vcore(pcdev);
424 } while (0); 385 } while (0);
425 386
426 return ret; 387 return ret;
@@ -442,7 +403,6 @@ static int amba_remove(struct device *dev)
442 pm_runtime_put_noidle(dev); 403 pm_runtime_put_noidle(dev);
443 404
444 amba_put_disable_pclk(pcdev); 405 amba_put_disable_pclk(pcdev);
445 amba_put_disable_vcore(pcdev);
446 406
447 return ret; 407 return ret;
448} 408}
diff --git a/drivers/ata/ata_piix.c b/drivers/ata/ata_piix.c
index 68013f96729f..7857e8fd0a3e 100644
--- a/drivers/ata/ata_piix.c
+++ b/drivers/ata/ata_piix.c
@@ -329,6 +329,8 @@ static const struct pci_device_id piix_pci_tbl[] = {
329 { 0x8086, 0x8c08, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_2port_sata }, 329 { 0x8086, 0x8c08, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_2port_sata },
330 /* SATA Controller IDE (Lynx Point) */ 330 /* SATA Controller IDE (Lynx Point) */
331 { 0x8086, 0x8c09, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_2port_sata }, 331 { 0x8086, 0x8c09, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_2port_sata },
332 /* SATA Controller IDE (DH89xxCC) */
333 { 0x8086, 0x2326, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_2port_sata },
332 { } /* terminate list */ 334 { } /* terminate list */
333}; 335};
334 336
diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
index e0bda9ff89cd..28db50b57b91 100644
--- a/drivers/ata/libata-core.c
+++ b/drivers/ata/libata-core.c
@@ -95,7 +95,7 @@ static unsigned int ata_dev_set_xfermode(struct ata_device *dev);
95static void ata_dev_xfermask(struct ata_device *dev); 95static void ata_dev_xfermask(struct ata_device *dev);
96static unsigned long ata_dev_blacklisted(const struct ata_device *dev); 96static unsigned long ata_dev_blacklisted(const struct ata_device *dev);
97 97
98unsigned int ata_print_id = 1; 98atomic_t ata_print_id = ATOMIC_INIT(1);
99 99
100struct ata_force_param { 100struct ata_force_param {
101 const char *name; 101 const char *name;
@@ -6029,7 +6029,7 @@ int ata_host_register(struct ata_host *host, struct scsi_host_template *sht)
6029 6029
6030 /* give ports names and add SCSI hosts */ 6030 /* give ports names and add SCSI hosts */
6031 for (i = 0; i < host->n_ports; i++) 6031 for (i = 0; i < host->n_ports; i++)
6032 host->ports[i]->print_id = ata_print_id++; 6032 host->ports[i]->print_id = atomic_inc_return(&ata_print_id);
6033 6033
6034 6034
6035 /* Create associated sysfs transport objects */ 6035 /* Create associated sysfs transport objects */
diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
index 1ee00c8b5b04..93dabdcd2cbe 100644
--- a/drivers/ata/libata-scsi.c
+++ b/drivers/ata/libata-scsi.c
@@ -3843,7 +3843,7 @@ int ata_sas_async_port_init(struct ata_port *ap)
3843 int rc = ap->ops->port_start(ap); 3843 int rc = ap->ops->port_start(ap);
3844 3844
3845 if (!rc) { 3845 if (!rc) {
3846 ap->print_id = ata_print_id++; 3846 ap->print_id = atomic_inc_return(&ata_print_id);
3847 __ata_port_probe(ap); 3847 __ata_port_probe(ap);
3848 } 3848 }
3849 3849
@@ -3867,7 +3867,7 @@ int ata_sas_port_init(struct ata_port *ap)
3867 int rc = ap->ops->port_start(ap); 3867 int rc = ap->ops->port_start(ap);
3868 3868
3869 if (!rc) { 3869 if (!rc) {
3870 ap->print_id = ata_print_id++; 3870 ap->print_id = atomic_inc_return(&ata_print_id);
3871 rc = ata_port_probe(ap); 3871 rc = ata_port_probe(ap);
3872 } 3872 }
3873 3873
diff --git a/drivers/ata/libata-transport.c b/drivers/ata/libata-transport.c
index 74aaee30e264..c34190485377 100644
--- a/drivers/ata/libata-transport.c
+++ b/drivers/ata/libata-transport.c
@@ -294,6 +294,7 @@ int ata_tport_add(struct device *parent,
294 device_enable_async_suspend(dev); 294 device_enable_async_suspend(dev);
295 pm_runtime_set_active(dev); 295 pm_runtime_set_active(dev);
296 pm_runtime_enable(dev); 296 pm_runtime_enable(dev);
297 pm_runtime_forbid(dev);
297 298
298 transport_add_device(dev); 299 transport_add_device(dev);
299 transport_configure_device(dev); 300 transport_configure_device(dev);
diff --git a/drivers/ata/libata.h b/drivers/ata/libata.h
index 2e26fcaf635b..9d0fd0b71852 100644
--- a/drivers/ata/libata.h
+++ b/drivers/ata/libata.h
@@ -53,7 +53,7 @@ enum {
53 ATA_DNXFER_QUIET = (1 << 31), 53 ATA_DNXFER_QUIET = (1 << 31),
54}; 54};
55 55
56extern unsigned int ata_print_id; 56extern atomic_t ata_print_id;
57extern int atapi_passthru16; 57extern int atapi_passthru16;
58extern int libata_fua; 58extern int libata_fua;
59extern int libata_noacpi; 59extern int libata_noacpi;
diff --git a/drivers/ata/sata_mv.c b/drivers/ata/sata_mv.c
index 38950ea8398a..7336d4a7ab31 100644
--- a/drivers/ata/sata_mv.c
+++ b/drivers/ata/sata_mv.c
@@ -4025,7 +4025,8 @@ static int mv_platform_probe(struct platform_device *pdev)
4025 struct ata_host *host; 4025 struct ata_host *host;
4026 struct mv_host_priv *hpriv; 4026 struct mv_host_priv *hpriv;
4027 struct resource *res; 4027 struct resource *res;
4028 int n_ports, rc; 4028 int n_ports = 0;
4029 int rc;
4029 4030
4030 ata_print_version_once(&pdev->dev, DRV_VERSION); 4031 ata_print_version_once(&pdev->dev, DRV_VERSION);
4031 4032
diff --git a/drivers/base/soc.c b/drivers/base/soc.c
index 05f150382da8..ba29b2e73d48 100644
--- a/drivers/base/soc.c
+++ b/drivers/base/soc.c
@@ -15,7 +15,7 @@
15#include <linux/sys_soc.h> 15#include <linux/sys_soc.h>
16#include <linux/err.h> 16#include <linux/err.h>
17 17
18static DEFINE_IDR(soc_ida); 18static DEFINE_IDA(soc_ida);
19static DEFINE_SPINLOCK(soc_lock); 19static DEFINE_SPINLOCK(soc_lock);
20 20
21static ssize_t soc_info_get(struct device *dev, 21static ssize_t soc_info_get(struct device *dev,
@@ -168,8 +168,6 @@ void soc_device_unregister(struct soc_device *soc_dev)
168 168
169static int __init soc_bus_register(void) 169static int __init soc_bus_register(void)
170{ 170{
171 spin_lock_init(&soc_lock);
172
173 return bus_register(&soc_bus_type); 171 return bus_register(&soc_bus_type);
174} 172}
175core_initcall(soc_bus_register); 173core_initcall(soc_bus_register);
diff --git a/drivers/bcma/Kconfig b/drivers/bcma/Kconfig
index c1172dafdffa..fb7c80fb721e 100644
--- a/drivers/bcma/Kconfig
+++ b/drivers/bcma/Kconfig
@@ -29,7 +29,7 @@ config BCMA_HOST_PCI
29 29
30config BCMA_DRIVER_PCI_HOSTMODE 30config BCMA_DRIVER_PCI_HOSTMODE
31 bool "Driver for PCI core working in hostmode" 31 bool "Driver for PCI core working in hostmode"
32 depends on BCMA && MIPS 32 depends on BCMA && MIPS && BCMA_HOST_PCI
33 help 33 help
34 PCI core hostmode operation (external PCI bus). 34 PCI core hostmode operation (external PCI bus).
35 35
diff --git a/drivers/bcma/driver_pci_host.c b/drivers/bcma/driver_pci_host.c
index 4e20bcfa7ec5..d2097a11c3c7 100644
--- a/drivers/bcma/driver_pci_host.c
+++ b/drivers/bcma/driver_pci_host.c
@@ -10,6 +10,7 @@
10 */ 10 */
11 11
12#include "bcma_private.h" 12#include "bcma_private.h"
13#include <linux/pci.h>
13#include <linux/export.h> 14#include <linux/export.h>
14#include <linux/bcma/bcma.h> 15#include <linux/bcma/bcma.h>
15#include <asm/paccess.h> 16#include <asm/paccess.h>
diff --git a/drivers/bcma/sprom.c b/drivers/bcma/sprom.c
index cdcf75c0954f..3e2a6002aae6 100644
--- a/drivers/bcma/sprom.c
+++ b/drivers/bcma/sprom.c
@@ -404,16 +404,19 @@ int bcma_sprom_get(struct bcma_bus *bus)
404 return -EOPNOTSUPP; 404 return -EOPNOTSUPP;
405 405
406 if (!bcma_sprom_ext_available(bus)) { 406 if (!bcma_sprom_ext_available(bus)) {
407 bool sprom_onchip;
408
407 /* 409 /*
408 * External SPROM takes precedence so check 410 * External SPROM takes precedence so check
409 * on-chip OTP only when no external SPROM 411 * on-chip OTP only when no external SPROM
410 * is present. 412 * is present.
411 */ 413 */
412 if (bcma_sprom_onchip_available(bus)) { 414 sprom_onchip = bcma_sprom_onchip_available(bus);
415 if (sprom_onchip) {
413 /* determine offset */ 416 /* determine offset */
414 offset = bcma_sprom_onchip_offset(bus); 417 offset = bcma_sprom_onchip_offset(bus);
415 } 418 }
416 if (!offset) { 419 if (!offset || !sprom_onchip) {
417 /* 420 /*
418 * Maybe there is no SPROM on the device? 421 * Maybe there is no SPROM on the device?
419 * Now we ask the arch code if there is some sprom 422 * Now we ask the arch code if there is some sprom
diff --git a/drivers/block/cciss_scsi.c b/drivers/block/cciss_scsi.c
index e820b68d2f6c..acda773b3720 100644
--- a/drivers/block/cciss_scsi.c
+++ b/drivers/block/cciss_scsi.c
@@ -866,6 +866,7 @@ cciss_scsi_detect(ctlr_info_t *h)
866 sh->can_queue = cciss_tape_cmds; 866 sh->can_queue = cciss_tape_cmds;
867 sh->sg_tablesize = h->maxsgentries; 867 sh->sg_tablesize = h->maxsgentries;
868 sh->max_cmd_len = MAX_COMMAND_SIZE; 868 sh->max_cmd_len = MAX_COMMAND_SIZE;
869 sh->max_sectors = h->cciss_max_sectors;
869 870
870 ((struct cciss_scsi_adapter_data_t *) 871 ((struct cciss_scsi_adapter_data_t *)
871 h->scsi_ctlr)->scsi_host = sh; 872 h->scsi_ctlr)->scsi_host = sh;
@@ -1410,7 +1411,7 @@ static void cciss_scatter_gather(ctlr_info_t *h, CommandList_struct *c,
1410 /* track how many SG entries we are using */ 1411 /* track how many SG entries we are using */
1411 if (request_nsgs > h->maxSG) 1412 if (request_nsgs > h->maxSG)
1412 h->maxSG = request_nsgs; 1413 h->maxSG = request_nsgs;
1413 c->Header.SGTotal = (__u8) request_nsgs + chained; 1414 c->Header.SGTotal = (u16) request_nsgs + chained;
1414 if (request_nsgs > h->max_cmd_sgentries) 1415 if (request_nsgs > h->max_cmd_sgentries)
1415 c->Header.SGList = h->max_cmd_sgentries; 1416 c->Header.SGList = h->max_cmd_sgentries;
1416 else 1417 else
diff --git a/drivers/block/mtip32xx/Kconfig b/drivers/block/mtip32xx/Kconfig
index b5dd14e072f2..0ba837fc62a8 100644
--- a/drivers/block/mtip32xx/Kconfig
+++ b/drivers/block/mtip32xx/Kconfig
@@ -4,6 +4,6 @@
4 4
5config BLK_DEV_PCIESSD_MTIP32XX 5config BLK_DEV_PCIESSD_MTIP32XX
6 tristate "Block Device Driver for Micron PCIe SSDs" 6 tristate "Block Device Driver for Micron PCIe SSDs"
7 depends on HOTPLUG_PCI_PCIE 7 depends on PCI
8 help 8 help
9 This enables the block driver for Micron PCIe SSDs. 9 This enables the block driver for Micron PCIe SSDs.
diff --git a/drivers/block/mtip32xx/mtip32xx.c b/drivers/block/mtip32xx/mtip32xx.c
index 8eb81c96608f..00f9fc992090 100644
--- a/drivers/block/mtip32xx/mtip32xx.c
+++ b/drivers/block/mtip32xx/mtip32xx.c
@@ -36,6 +36,7 @@
36#include <linux/idr.h> 36#include <linux/idr.h>
37#include <linux/kthread.h> 37#include <linux/kthread.h>
38#include <../drivers/ata/ahci.h> 38#include <../drivers/ata/ahci.h>
39#include <linux/export.h>
39#include "mtip32xx.h" 40#include "mtip32xx.h"
40 41
41#define HW_CMD_SLOT_SZ (MTIP_MAX_COMMAND_SLOTS * 32) 42#define HW_CMD_SLOT_SZ (MTIP_MAX_COMMAND_SLOTS * 32)
@@ -44,6 +45,7 @@
44#define HW_PORT_PRIV_DMA_SZ \ 45#define HW_PORT_PRIV_DMA_SZ \
45 (HW_CMD_SLOT_SZ + HW_CMD_TBL_AR_SZ + AHCI_RX_FIS_SZ) 46 (HW_CMD_SLOT_SZ + HW_CMD_TBL_AR_SZ + AHCI_RX_FIS_SZ)
46 47
48#define HOST_CAP_NZDMA (1 << 19)
47#define HOST_HSORG 0xFC 49#define HOST_HSORG 0xFC
48#define HSORG_DISABLE_SLOTGRP_INTR (1<<24) 50#define HSORG_DISABLE_SLOTGRP_INTR (1<<24)
49#define HSORG_DISABLE_SLOTGRP_PXIS (1<<16) 51#define HSORG_DISABLE_SLOTGRP_PXIS (1<<16)
@@ -139,6 +141,12 @@ static void mtip_command_cleanup(struct driver_data *dd)
139 int group = 0, commandslot = 0, commandindex = 0; 141 int group = 0, commandslot = 0, commandindex = 0;
140 struct mtip_cmd *command; 142 struct mtip_cmd *command;
141 struct mtip_port *port = dd->port; 143 struct mtip_port *port = dd->port;
144 static int in_progress;
145
146 if (in_progress)
147 return;
148
149 in_progress = 1;
142 150
143 for (group = 0; group < 4; group++) { 151 for (group = 0; group < 4; group++) {
144 for (commandslot = 0; commandslot < 32; commandslot++) { 152 for (commandslot = 0; commandslot < 32; commandslot++) {
@@ -165,7 +173,8 @@ static void mtip_command_cleanup(struct driver_data *dd)
165 173
166 up(&port->cmd_slot); 174 up(&port->cmd_slot);
167 175
168 atomic_set(&dd->drv_cleanup_done, true); 176 set_bit(MTIP_DDF_CLEANUP_BIT, &dd->dd_flag);
177 in_progress = 0;
169} 178}
170 179
171/* 180/*
@@ -262,6 +271,9 @@ static int hba_reset_nosleep(struct driver_data *dd)
262 && time_before(jiffies, timeout)) 271 && time_before(jiffies, timeout))
263 mdelay(1); 272 mdelay(1);
264 273
274 if (test_bit(MTIP_DDF_REMOVE_PENDING_BIT, &dd->dd_flag))
275 return -1;
276
265 if (readl(dd->mmio + HOST_CTL) & HOST_RESET) 277 if (readl(dd->mmio + HOST_CTL) & HOST_RESET)
266 return -1; 278 return -1;
267 279
@@ -294,6 +306,10 @@ static inline void mtip_issue_ncq_command(struct mtip_port *port, int tag)
294 port->cmd_issue[MTIP_TAG_INDEX(tag)]); 306 port->cmd_issue[MTIP_TAG_INDEX(tag)]);
295 307
296 spin_unlock_irqrestore(&port->cmd_issue_lock, flags); 308 spin_unlock_irqrestore(&port->cmd_issue_lock, flags);
309
310 /* Set the command's timeout value.*/
311 port->commands[tag].comp_time = jiffies + msecs_to_jiffies(
312 MTIP_NCQ_COMMAND_TIMEOUT_MS);
297} 313}
298 314
299/* 315/*
@@ -420,7 +436,12 @@ static void mtip_init_port(struct mtip_port *port)
420 writel(0xFFFFFFFF, port->completed[i]); 436 writel(0xFFFFFFFF, port->completed[i]);
421 437
422 /* Clear any pending interrupts for this port */ 438 /* Clear any pending interrupts for this port */
423 writel(readl(port->mmio + PORT_IRQ_STAT), port->mmio + PORT_IRQ_STAT); 439 writel(readl(port->dd->mmio + PORT_IRQ_STAT),
440 port->dd->mmio + PORT_IRQ_STAT);
441
442 /* Clear any pending interrupts on the HBA. */
443 writel(readl(port->dd->mmio + HOST_IRQ_STAT),
444 port->dd->mmio + HOST_IRQ_STAT);
424 445
425 /* Enable port interrupts */ 446 /* Enable port interrupts */
426 writel(DEF_PORT_IRQ, port->mmio + PORT_IRQ_MASK); 447 writel(DEF_PORT_IRQ, port->mmio + PORT_IRQ_MASK);
@@ -447,6 +468,9 @@ static void mtip_restart_port(struct mtip_port *port)
447 && time_before(jiffies, timeout)) 468 && time_before(jiffies, timeout))
448 ; 469 ;
449 470
471 if (test_bit(MTIP_DDF_REMOVE_PENDING_BIT, &port->dd->dd_flag))
472 return;
473
450 /* 474 /*
451 * Chip quirk: escalate to hba reset if 475 * Chip quirk: escalate to hba reset if
452 * PxCMD.CR not clear after 500 ms 476 * PxCMD.CR not clear after 500 ms
@@ -475,6 +499,9 @@ static void mtip_restart_port(struct mtip_port *port)
475 while (time_before(jiffies, timeout)) 499 while (time_before(jiffies, timeout))
476 ; 500 ;
477 501
502 if (test_bit(MTIP_DDF_REMOVE_PENDING_BIT, &port->dd->dd_flag))
503 return;
504
478 /* Clear PxSCTL.DET */ 505 /* Clear PxSCTL.DET */
479 writel(readl(port->mmio + PORT_SCR_CTL) & ~1, 506 writel(readl(port->mmio + PORT_SCR_CTL) & ~1,
480 port->mmio + PORT_SCR_CTL); 507 port->mmio + PORT_SCR_CTL);
@@ -486,15 +513,35 @@ static void mtip_restart_port(struct mtip_port *port)
486 && time_before(jiffies, timeout)) 513 && time_before(jiffies, timeout))
487 ; 514 ;
488 515
516 if (test_bit(MTIP_DDF_REMOVE_PENDING_BIT, &port->dd->dd_flag))
517 return;
518
489 if ((readl(port->mmio + PORT_SCR_STAT) & 0x01) == 0) 519 if ((readl(port->mmio + PORT_SCR_STAT) & 0x01) == 0)
490 dev_warn(&port->dd->pdev->dev, 520 dev_warn(&port->dd->pdev->dev,
491 "COM reset failed\n"); 521 "COM reset failed\n");
492 522
493 /* Clear SError, the PxSERR.DIAG.x should be set so clear it */ 523 mtip_init_port(port);
494 writel(readl(port->mmio + PORT_SCR_ERR), port->mmio + PORT_SCR_ERR); 524 mtip_start_port(port);
495 525
496 /* Enable the DMA engine */ 526}
497 mtip_enable_engine(port, 1); 527
528/*
529 * Helper function for tag logging
530 */
531static void print_tags(struct driver_data *dd,
532 char *msg,
533 unsigned long *tagbits,
534 int cnt)
535{
536 unsigned char tagmap[128];
537 int group, tagmap_len = 0;
538
539 memset(tagmap, 0, sizeof(tagmap));
540 for (group = SLOTBITS_IN_LONGS; group > 0; group--)
541 tagmap_len = sprintf(tagmap + tagmap_len, "%016lX ",
542 tagbits[group-1]);
543 dev_warn(&dd->pdev->dev,
544 "%d command(s) %s: tagmap [%s]", cnt, msg, tagmap);
498} 545}
499 546
500/* 547/*
@@ -514,15 +561,18 @@ static void mtip_timeout_function(unsigned long int data)
514 int tag, cmdto_cnt = 0; 561 int tag, cmdto_cnt = 0;
515 unsigned int bit, group; 562 unsigned int bit, group;
516 unsigned int num_command_slots = port->dd->slot_groups * 32; 563 unsigned int num_command_slots = port->dd->slot_groups * 32;
564 unsigned long to, tagaccum[SLOTBITS_IN_LONGS];
517 565
518 if (unlikely(!port)) 566 if (unlikely(!port))
519 return; 567 return;
520 568
521 if (atomic_read(&port->dd->resumeflag) == true) { 569 if (test_bit(MTIP_DDF_RESUME_BIT, &port->dd->dd_flag)) {
522 mod_timer(&port->cmd_timer, 570 mod_timer(&port->cmd_timer,
523 jiffies + msecs_to_jiffies(30000)); 571 jiffies + msecs_to_jiffies(30000));
524 return; 572 return;
525 } 573 }
574 /* clear the tag accumulator */
575 memset(tagaccum, 0, SLOTBITS_IN_LONGS * sizeof(long));
526 576
527 for (tag = 0; tag < num_command_slots; tag++) { 577 for (tag = 0; tag < num_command_slots; tag++) {
528 /* 578 /*
@@ -540,12 +590,10 @@ static void mtip_timeout_function(unsigned long int data)
540 command = &port->commands[tag]; 590 command = &port->commands[tag];
541 fis = (struct host_to_dev_fis *) command->command; 591 fis = (struct host_to_dev_fis *) command->command;
542 592
543 dev_warn(&port->dd->pdev->dev, 593 set_bit(tag, tagaccum);
544 "Timeout for command tag %d\n", tag);
545
546 cmdto_cnt++; 594 cmdto_cnt++;
547 if (cmdto_cnt == 1) 595 if (cmdto_cnt == 1)
548 set_bit(MTIP_FLAG_EH_ACTIVE_BIT, &port->flags); 596 set_bit(MTIP_PF_EH_ACTIVE_BIT, &port->flags);
549 597
550 /* 598 /*
551 * Clear the completed bit. This should prevent 599 * Clear the completed bit. This should prevent
@@ -578,15 +626,29 @@ static void mtip_timeout_function(unsigned long int data)
578 } 626 }
579 } 627 }
580 628
581 if (cmdto_cnt) { 629 if (cmdto_cnt && !test_bit(MTIP_PF_IC_ACTIVE_BIT, &port->flags)) {
582 dev_warn(&port->dd->pdev->dev, 630 print_tags(port->dd, "timed out", tagaccum, cmdto_cnt);
583 "%d commands timed out: restarting port", 631
584 cmdto_cnt);
585 mtip_restart_port(port); 632 mtip_restart_port(port);
586 clear_bit(MTIP_FLAG_EH_ACTIVE_BIT, &port->flags); 633 clear_bit(MTIP_PF_EH_ACTIVE_BIT, &port->flags);
587 wake_up_interruptible(&port->svc_wait); 634 wake_up_interruptible(&port->svc_wait);
588 } 635 }
589 636
637 if (port->ic_pause_timer) {
638 to = port->ic_pause_timer + msecs_to_jiffies(1000);
639 if (time_after(jiffies, to)) {
640 if (!test_bit(MTIP_PF_IC_ACTIVE_BIT, &port->flags)) {
641 port->ic_pause_timer = 0;
642 clear_bit(MTIP_PF_SE_ACTIVE_BIT, &port->flags);
643 clear_bit(MTIP_PF_DM_ACTIVE_BIT, &port->flags);
644 clear_bit(MTIP_PF_IC_ACTIVE_BIT, &port->flags);
645 wake_up_interruptible(&port->svc_wait);
646 }
647
648
649 }
650 }
651
590 /* Restart the timer */ 652 /* Restart the timer */
591 mod_timer(&port->cmd_timer, 653 mod_timer(&port->cmd_timer,
592 jiffies + msecs_to_jiffies(MTIP_TIMEOUT_CHECK_PERIOD)); 654 jiffies + msecs_to_jiffies(MTIP_TIMEOUT_CHECK_PERIOD));
@@ -681,23 +743,18 @@ static void mtip_completion(struct mtip_port *port,
681 complete(waiting); 743 complete(waiting);
682} 744}
683 745
684/* 746static void mtip_null_completion(struct mtip_port *port,
685 * Helper function for tag logging 747 int tag,
686 */ 748 void *data,
687static void print_tags(struct driver_data *dd, 749 int status)
688 char *msg,
689 unsigned long *tagbits)
690{ 750{
691 unsigned int tag, count = 0; 751 return;
692
693 for (tag = 0; tag < (dd->slot_groups) * 32; tag++) {
694 if (test_bit(tag, tagbits))
695 count++;
696 }
697 if (count)
698 dev_info(&dd->pdev->dev, "%s [%i tags]\n", msg, count);
699} 752}
700 753
754static int mtip_read_log_page(struct mtip_port *port, u8 page, u16 *buffer,
755 dma_addr_t buffer_dma, unsigned int sectors);
756static int mtip_get_smart_attr(struct mtip_port *port, unsigned int id,
757 struct smart_attr *attrib);
701/* 758/*
702 * Handle an error. 759 * Handle an error.
703 * 760 *
@@ -708,12 +765,16 @@ static void print_tags(struct driver_data *dd,
708 */ 765 */
709static void mtip_handle_tfe(struct driver_data *dd) 766static void mtip_handle_tfe(struct driver_data *dd)
710{ 767{
711 int group, tag, bit, reissue; 768 int group, tag, bit, reissue, rv;
712 struct mtip_port *port; 769 struct mtip_port *port;
713 struct mtip_cmd *command; 770 struct mtip_cmd *cmd;
714 u32 completed; 771 u32 completed;
715 struct host_to_dev_fis *fis; 772 struct host_to_dev_fis *fis;
716 unsigned long tagaccum[SLOTBITS_IN_LONGS]; 773 unsigned long tagaccum[SLOTBITS_IN_LONGS];
774 unsigned int cmd_cnt = 0;
775 unsigned char *buf;
776 char *fail_reason = NULL;
777 int fail_all_ncq_write = 0, fail_all_ncq_cmds = 0;
717 778
718 dev_warn(&dd->pdev->dev, "Taskfile error\n"); 779 dev_warn(&dd->pdev->dev, "Taskfile error\n");
719 780
@@ -722,8 +783,11 @@ static void mtip_handle_tfe(struct driver_data *dd)
722 /* Stop the timer to prevent command timeouts. */ 783 /* Stop the timer to prevent command timeouts. */
723 del_timer(&port->cmd_timer); 784 del_timer(&port->cmd_timer);
724 785
786 /* clear the tag accumulator */
787 memset(tagaccum, 0, SLOTBITS_IN_LONGS * sizeof(long));
788
725 /* Set eh_active */ 789 /* Set eh_active */
726 set_bit(MTIP_FLAG_EH_ACTIVE_BIT, &port->flags); 790 set_bit(MTIP_PF_EH_ACTIVE_BIT, &port->flags);
727 791
728 /* Loop through all the groups */ 792 /* Loop through all the groups */
729 for (group = 0; group < dd->slot_groups; group++) { 793 for (group = 0; group < dd->slot_groups; group++) {
@@ -732,9 +796,6 @@ static void mtip_handle_tfe(struct driver_data *dd)
732 /* clear completed status register in the hardware.*/ 796 /* clear completed status register in the hardware.*/
733 writel(completed, port->completed[group]); 797 writel(completed, port->completed[group]);
734 798
735 /* clear the tag accumulator */
736 memset(tagaccum, 0, SLOTBITS_IN_LONGS * sizeof(long));
737
738 /* Process successfully completed commands */ 799 /* Process successfully completed commands */
739 for (bit = 0; bit < 32 && completed; bit++) { 800 for (bit = 0; bit < 32 && completed; bit++) {
740 if (!(completed & (1<<bit))) 801 if (!(completed & (1<<bit)))
@@ -745,13 +806,14 @@ static void mtip_handle_tfe(struct driver_data *dd)
745 if (tag == MTIP_TAG_INTERNAL) 806 if (tag == MTIP_TAG_INTERNAL)
746 continue; 807 continue;
747 808
748 command = &port->commands[tag]; 809 cmd = &port->commands[tag];
749 if (likely(command->comp_func)) { 810 if (likely(cmd->comp_func)) {
750 set_bit(tag, tagaccum); 811 set_bit(tag, tagaccum);
751 atomic_set(&port->commands[tag].active, 0); 812 cmd_cnt++;
752 command->comp_func(port, 813 atomic_set(&cmd->active, 0);
814 cmd->comp_func(port,
753 tag, 815 tag,
754 command->comp_data, 816 cmd->comp_data,
755 0); 817 0);
756 } else { 818 } else {
757 dev_err(&port->dd->pdev->dev, 819 dev_err(&port->dd->pdev->dev,
@@ -765,12 +827,45 @@ static void mtip_handle_tfe(struct driver_data *dd)
765 } 827 }
766 } 828 }
767 } 829 }
768 print_tags(dd, "TFE tags completed:", tagaccum); 830
831 print_tags(dd, "completed (TFE)", tagaccum, cmd_cnt);
769 832
770 /* Restart the port */ 833 /* Restart the port */
771 mdelay(20); 834 mdelay(20);
772 mtip_restart_port(port); 835 mtip_restart_port(port);
773 836
837 /* Trying to determine the cause of the error */
838 rv = mtip_read_log_page(dd->port, ATA_LOG_SATA_NCQ,
839 dd->port->log_buf,
840 dd->port->log_buf_dma, 1);
841 if (rv) {
842 dev_warn(&dd->pdev->dev,
843 "Error in READ LOG EXT (10h) command\n");
844 /* non-critical error, don't fail the load */
845 } else {
846 buf = (unsigned char *)dd->port->log_buf;
847 if (buf[259] & 0x1) {
848 dev_info(&dd->pdev->dev,
849 "Write protect bit is set.\n");
850 set_bit(MTIP_DDF_WRITE_PROTECT_BIT, &dd->dd_flag);
851 fail_all_ncq_write = 1;
852 fail_reason = "write protect";
853 }
854 if (buf[288] == 0xF7) {
855 dev_info(&dd->pdev->dev,
856 "Exceeded Tmax, drive in thermal shutdown.\n");
857 set_bit(MTIP_DDF_OVER_TEMP_BIT, &dd->dd_flag);
858 fail_all_ncq_cmds = 1;
859 fail_reason = "thermal shutdown";
860 }
861 if (buf[288] == 0xBF) {
862 dev_info(&dd->pdev->dev,
863 "Drive indicates rebuild has failed.\n");
864 fail_all_ncq_cmds = 1;
865 fail_reason = "rebuild failed";
866 }
867 }
868
774 /* clear the tag accumulator */ 869 /* clear the tag accumulator */
775 memset(tagaccum, 0, SLOTBITS_IN_LONGS * sizeof(long)); 870 memset(tagaccum, 0, SLOTBITS_IN_LONGS * sizeof(long));
776 871
@@ -779,32 +874,47 @@ static void mtip_handle_tfe(struct driver_data *dd)
779 for (bit = 0; bit < 32; bit++) { 874 for (bit = 0; bit < 32; bit++) {
780 reissue = 1; 875 reissue = 1;
781 tag = (group << 5) + bit; 876 tag = (group << 5) + bit;
877 cmd = &port->commands[tag];
782 878
783 /* If the active bit is set re-issue the command */ 879 /* If the active bit is set re-issue the command */
784 if (atomic_read(&port->commands[tag].active) == 0) 880 if (atomic_read(&cmd->active) == 0)
785 continue; 881 continue;
786 882
787 fis = (struct host_to_dev_fis *) 883 fis = (struct host_to_dev_fis *)cmd->command;
788 port->commands[tag].command;
789 884
790 /* Should re-issue? */ 885 /* Should re-issue? */
791 if (tag == MTIP_TAG_INTERNAL || 886 if (tag == MTIP_TAG_INTERNAL ||
792 fis->command == ATA_CMD_SET_FEATURES) 887 fis->command == ATA_CMD_SET_FEATURES)
793 reissue = 0; 888 reissue = 0;
889 else {
890 if (fail_all_ncq_cmds ||
891 (fail_all_ncq_write &&
892 fis->command == ATA_CMD_FPDMA_WRITE)) {
893 dev_warn(&dd->pdev->dev,
894 " Fail: %s w/tag %d [%s].\n",
895 fis->command == ATA_CMD_FPDMA_WRITE ?
896 "write" : "read",
897 tag,
898 fail_reason != NULL ?
899 fail_reason : "unknown");
900 atomic_set(&cmd->active, 0);
901 if (cmd->comp_func) {
902 cmd->comp_func(port, tag,
903 cmd->comp_data,
904 -ENODATA);
905 }
906 continue;
907 }
908 }
794 909
795 /* 910 /*
796 * First check if this command has 911 * First check if this command has
797 * exceeded its retries. 912 * exceeded its retries.
798 */ 913 */
799 if (reissue && 914 if (reissue && (cmd->retries-- > 0)) {
800 (port->commands[tag].retries-- > 0)) {
801 915
802 set_bit(tag, tagaccum); 916 set_bit(tag, tagaccum);
803 917
804 /* Update the timeout value. */
805 port->commands[tag].comp_time =
806 jiffies + msecs_to_jiffies(
807 MTIP_NCQ_COMMAND_TIMEOUT_MS);
808 /* Re-issue the command. */ 918 /* Re-issue the command. */
809 mtip_issue_ncq_command(port, tag); 919 mtip_issue_ncq_command(port, tag);
810 920
@@ -814,13 +924,13 @@ static void mtip_handle_tfe(struct driver_data *dd)
814 /* Retire a command that will not be reissued */ 924 /* Retire a command that will not be reissued */
815 dev_warn(&port->dd->pdev->dev, 925 dev_warn(&port->dd->pdev->dev,
816 "retiring tag %d\n", tag); 926 "retiring tag %d\n", tag);
817 atomic_set(&port->commands[tag].active, 0); 927 atomic_set(&cmd->active, 0);
818 928
819 if (port->commands[tag].comp_func) 929 if (cmd->comp_func)
820 port->commands[tag].comp_func( 930 cmd->comp_func(
821 port, 931 port,
822 tag, 932 tag,
823 port->commands[tag].comp_data, 933 cmd->comp_data,
824 PORT_IRQ_TF_ERR); 934 PORT_IRQ_TF_ERR);
825 else 935 else
826 dev_warn(&port->dd->pdev->dev, 936 dev_warn(&port->dd->pdev->dev,
@@ -828,10 +938,10 @@ static void mtip_handle_tfe(struct driver_data *dd)
828 tag); 938 tag);
829 } 939 }
830 } 940 }
831 print_tags(dd, "TFE tags reissued:", tagaccum); 941 print_tags(dd, "reissued (TFE)", tagaccum, cmd_cnt);
832 942
833 /* clear eh_active */ 943 /* clear eh_active */
834 clear_bit(MTIP_FLAG_EH_ACTIVE_BIT, &port->flags); 944 clear_bit(MTIP_PF_EH_ACTIVE_BIT, &port->flags);
835 wake_up_interruptible(&port->svc_wait); 945 wake_up_interruptible(&port->svc_wait);
836 946
837 mod_timer(&port->cmd_timer, 947 mod_timer(&port->cmd_timer,
@@ -899,7 +1009,7 @@ static inline void mtip_process_legacy(struct driver_data *dd, u32 port_stat)
899 struct mtip_port *port = dd->port; 1009 struct mtip_port *port = dd->port;
900 struct mtip_cmd *cmd = &port->commands[MTIP_TAG_INTERNAL]; 1010 struct mtip_cmd *cmd = &port->commands[MTIP_TAG_INTERNAL];
901 1011
902 if (test_bit(MTIP_FLAG_IC_ACTIVE_BIT, &port->flags) && 1012 if (test_bit(MTIP_PF_IC_ACTIVE_BIT, &port->flags) &&
903 (cmd != NULL) && !(readl(port->cmd_issue[MTIP_TAG_INTERNAL]) 1013 (cmd != NULL) && !(readl(port->cmd_issue[MTIP_TAG_INTERNAL])
904 & (1 << MTIP_TAG_INTERNAL))) { 1014 & (1 << MTIP_TAG_INTERNAL))) {
905 if (cmd->comp_func) { 1015 if (cmd->comp_func) {
@@ -911,8 +1021,6 @@ static inline void mtip_process_legacy(struct driver_data *dd, u32 port_stat)
911 } 1021 }
912 } 1022 }
913 1023
914 dev_warn(&dd->pdev->dev, "IRQ status 0x%x ignored.\n", port_stat);
915
916 return; 1024 return;
917} 1025}
918 1026
@@ -968,6 +1076,9 @@ static inline irqreturn_t mtip_handle_irq(struct driver_data *data)
968 /* don't proceed further */ 1076 /* don't proceed further */
969 return IRQ_HANDLED; 1077 return IRQ_HANDLED;
970 } 1078 }
1079 if (test_bit(MTIP_DDF_REMOVE_PENDING_BIT,
1080 &dd->dd_flag))
1081 return rv;
971 1082
972 mtip_process_errors(dd, port_stat & PORT_IRQ_ERR); 1083 mtip_process_errors(dd, port_stat & PORT_IRQ_ERR);
973 } 1084 }
@@ -1015,6 +1126,39 @@ static void mtip_issue_non_ncq_command(struct mtip_port *port, int tag)
1015 port->cmd_issue[MTIP_TAG_INDEX(tag)]); 1126 port->cmd_issue[MTIP_TAG_INDEX(tag)]);
1016} 1127}
1017 1128
1129static bool mtip_pause_ncq(struct mtip_port *port,
1130 struct host_to_dev_fis *fis)
1131{
1132 struct host_to_dev_fis *reply;
1133 unsigned long task_file_data;
1134
1135 reply = port->rxfis + RX_FIS_D2H_REG;
1136 task_file_data = readl(port->mmio+PORT_TFDATA);
1137
1138 if ((task_file_data & 1) || (fis->command == ATA_CMD_SEC_ERASE_UNIT))
1139 return false;
1140
1141 if (fis->command == ATA_CMD_SEC_ERASE_PREP) {
1142 set_bit(MTIP_PF_SE_ACTIVE_BIT, &port->flags);
1143 port->ic_pause_timer = jiffies;
1144 return true;
1145 } else if ((fis->command == ATA_CMD_DOWNLOAD_MICRO) &&
1146 (fis->features == 0x03)) {
1147 set_bit(MTIP_PF_DM_ACTIVE_BIT, &port->flags);
1148 port->ic_pause_timer = jiffies;
1149 return true;
1150 } else if ((fis->command == ATA_CMD_SEC_ERASE_UNIT) ||
1151 ((fis->command == 0xFC) &&
1152 (fis->features == 0x27 || fis->features == 0x72 ||
1153 fis->features == 0x62 || fis->features == 0x26))) {
1154 /* Com reset after secure erase or lowlevel format */
1155 mtip_restart_port(port);
1156 return false;
1157 }
1158
1159 return false;
1160}
1161
1018/* 1162/*
1019 * Wait for port to quiesce 1163 * Wait for port to quiesce
1020 * 1164 *
@@ -1033,11 +1177,13 @@ static int mtip_quiesce_io(struct mtip_port *port, unsigned long timeout)
1033 1177
1034 to = jiffies + msecs_to_jiffies(timeout); 1178 to = jiffies + msecs_to_jiffies(timeout);
1035 do { 1179 do {
1036 if (test_bit(MTIP_FLAG_SVC_THD_ACTIVE_BIT, &port->flags) && 1180 if (test_bit(MTIP_PF_SVC_THD_ACTIVE_BIT, &port->flags) &&
1037 test_bit(MTIP_FLAG_ISSUE_CMDS_BIT, &port->flags)) { 1181 test_bit(MTIP_PF_ISSUE_CMDS_BIT, &port->flags)) {
1038 msleep(20); 1182 msleep(20);
1039 continue; /* svc thd is actively issuing commands */ 1183 continue; /* svc thd is actively issuing commands */
1040 } 1184 }
1185 if (test_bit(MTIP_DDF_REMOVE_PENDING_BIT, &port->dd->dd_flag))
1186 return -EFAULT;
1041 /* 1187 /*
1042 * Ignore s_active bit 0 of array element 0. 1188 * Ignore s_active bit 0 of array element 0.
1043 * This bit will always be set 1189 * This bit will always be set
@@ -1074,7 +1220,7 @@ static int mtip_quiesce_io(struct mtip_port *port, unsigned long timeout)
1074 * -EAGAIN Time out waiting for command to complete. 1220 * -EAGAIN Time out waiting for command to complete.
1075 */ 1221 */
1076static int mtip_exec_internal_command(struct mtip_port *port, 1222static int mtip_exec_internal_command(struct mtip_port *port,
1077 void *fis, 1223 struct host_to_dev_fis *fis,
1078 int fis_len, 1224 int fis_len,
1079 dma_addr_t buffer, 1225 dma_addr_t buffer,
1080 int buf_len, 1226 int buf_len,
@@ -1084,8 +1230,9 @@ static int mtip_exec_internal_command(struct mtip_port *port,
1084{ 1230{
1085 struct mtip_cmd_sg *command_sg; 1231 struct mtip_cmd_sg *command_sg;
1086 DECLARE_COMPLETION_ONSTACK(wait); 1232 DECLARE_COMPLETION_ONSTACK(wait);
1087 int rv = 0; 1233 int rv = 0, ready2go = 1;
1088 struct mtip_cmd *int_cmd = &port->commands[MTIP_TAG_INTERNAL]; 1234 struct mtip_cmd *int_cmd = &port->commands[MTIP_TAG_INTERNAL];
1235 unsigned long to;
1089 1236
1090 /* Make sure the buffer is 8 byte aligned. This is asic specific. */ 1237 /* Make sure the buffer is 8 byte aligned. This is asic specific. */
1091 if (buffer & 0x00000007) { 1238 if (buffer & 0x00000007) {
@@ -1094,23 +1241,38 @@ static int mtip_exec_internal_command(struct mtip_port *port,
1094 return -EFAULT; 1241 return -EFAULT;
1095 } 1242 }
1096 1243
1097 /* Only one internal command should be running at a time */ 1244 to = jiffies + msecs_to_jiffies(timeout);
1098 if (test_and_set_bit(MTIP_TAG_INTERNAL, port->allocated)) { 1245 do {
1246 ready2go = !test_and_set_bit(MTIP_TAG_INTERNAL,
1247 port->allocated);
1248 if (ready2go)
1249 break;
1250 mdelay(100);
1251 } while (time_before(jiffies, to));
1252 if (!ready2go) {
1099 dev_warn(&port->dd->pdev->dev, 1253 dev_warn(&port->dd->pdev->dev,
1100 "Internal command already active\n"); 1254 "Internal cmd active. new cmd [%02X]\n", fis->command);
1101 return -EBUSY; 1255 return -EBUSY;
1102 } 1256 }
1103 set_bit(MTIP_FLAG_IC_ACTIVE_BIT, &port->flags); 1257 set_bit(MTIP_PF_IC_ACTIVE_BIT, &port->flags);
1258 port->ic_pause_timer = 0;
1259
1260 if (fis->command == ATA_CMD_SEC_ERASE_UNIT)
1261 clear_bit(MTIP_PF_SE_ACTIVE_BIT, &port->flags);
1262 else if (fis->command == ATA_CMD_DOWNLOAD_MICRO)
1263 clear_bit(MTIP_PF_DM_ACTIVE_BIT, &port->flags);
1104 1264
1105 if (atomic == GFP_KERNEL) { 1265 if (atomic == GFP_KERNEL) {
1106 /* wait for io to complete if non atomic */ 1266 if (fis->command != ATA_CMD_STANDBYNOW1) {
1107 if (mtip_quiesce_io(port, 5000) < 0) { 1267 /* wait for io to complete if non atomic */
1108 dev_warn(&port->dd->pdev->dev, 1268 if (mtip_quiesce_io(port, 5000) < 0) {
1109 "Failed to quiesce IO\n"); 1269 dev_warn(&port->dd->pdev->dev,
1110 release_slot(port, MTIP_TAG_INTERNAL); 1270 "Failed to quiesce IO\n");
1111 clear_bit(MTIP_FLAG_IC_ACTIVE_BIT, &port->flags); 1271 release_slot(port, MTIP_TAG_INTERNAL);
1112 wake_up_interruptible(&port->svc_wait); 1272 clear_bit(MTIP_PF_IC_ACTIVE_BIT, &port->flags);
1113 return -EBUSY; 1273 wake_up_interruptible(&port->svc_wait);
1274 return -EBUSY;
1275 }
1114 } 1276 }
1115 1277
1116 /* Set the completion function and data for the command. */ 1278 /* Set the completion function and data for the command. */
@@ -1120,7 +1282,7 @@ static int mtip_exec_internal_command(struct mtip_port *port,
1120 } else { 1282 } else {
1121 /* Clear completion - we're going to poll */ 1283 /* Clear completion - we're going to poll */
1122 int_cmd->comp_data = NULL; 1284 int_cmd->comp_data = NULL;
1123 int_cmd->comp_func = NULL; 1285 int_cmd->comp_func = mtip_null_completion;
1124 } 1286 }
1125 1287
1126 /* Copy the command to the command table */ 1288 /* Copy the command to the command table */
@@ -1159,6 +1321,12 @@ static int mtip_exec_internal_command(struct mtip_port *port,
1159 "Internal command did not complete [%d] " 1321 "Internal command did not complete [%d] "
1160 "within timeout of %lu ms\n", 1322 "within timeout of %lu ms\n",
1161 atomic, timeout); 1323 atomic, timeout);
1324 if (mtip_check_surprise_removal(port->dd->pdev) ||
1325 test_bit(MTIP_DDF_REMOVE_PENDING_BIT,
1326 &port->dd->dd_flag)) {
1327 rv = -ENXIO;
1328 goto exec_ic_exit;
1329 }
1162 rv = -EAGAIN; 1330 rv = -EAGAIN;
1163 } 1331 }
1164 1332
@@ -1166,31 +1334,59 @@ static int mtip_exec_internal_command(struct mtip_port *port,
1166 & (1 << MTIP_TAG_INTERNAL)) { 1334 & (1 << MTIP_TAG_INTERNAL)) {
1167 dev_warn(&port->dd->pdev->dev, 1335 dev_warn(&port->dd->pdev->dev,
1168 "Retiring internal command but CI is 1.\n"); 1336 "Retiring internal command but CI is 1.\n");
1337 if (test_bit(MTIP_DDF_REMOVE_PENDING_BIT,
1338 &port->dd->dd_flag)) {
1339 hba_reset_nosleep(port->dd);
1340 rv = -ENXIO;
1341 } else {
1342 mtip_restart_port(port);
1343 rv = -EAGAIN;
1344 }
1345 goto exec_ic_exit;
1169 } 1346 }
1170 1347
1171 } else { 1348 } else {
1172 /* Spin for <timeout> checking if command still outstanding */ 1349 /* Spin for <timeout> checking if command still outstanding */
1173 timeout = jiffies + msecs_to_jiffies(timeout); 1350 timeout = jiffies + msecs_to_jiffies(timeout);
1174 1351 while ((readl(port->cmd_issue[MTIP_TAG_INTERNAL])
1175 while ((readl( 1352 & (1 << MTIP_TAG_INTERNAL))
1176 port->cmd_issue[MTIP_TAG_INTERNAL]) 1353 && time_before(jiffies, timeout)) {
1177 & (1 << MTIP_TAG_INTERNAL)) 1354 if (mtip_check_surprise_removal(port->dd->pdev)) {
1178 && time_before(jiffies, timeout)) 1355 rv = -ENXIO;
1179 ; 1356 goto exec_ic_exit;
1357 }
1358 if ((fis->command != ATA_CMD_STANDBYNOW1) &&
1359 test_bit(MTIP_DDF_REMOVE_PENDING_BIT,
1360 &port->dd->dd_flag)) {
1361 rv = -ENXIO;
1362 goto exec_ic_exit;
1363 }
1364 }
1180 1365
1181 if (readl(port->cmd_issue[MTIP_TAG_INTERNAL]) 1366 if (readl(port->cmd_issue[MTIP_TAG_INTERNAL])
1182 & (1 << MTIP_TAG_INTERNAL)) { 1367 & (1 << MTIP_TAG_INTERNAL)) {
1183 dev_err(&port->dd->pdev->dev, 1368 dev_err(&port->dd->pdev->dev,
1184 "Internal command did not complete [%d]\n", 1369 "Internal command did not complete [atomic]\n");
1185 atomic);
1186 rv = -EAGAIN; 1370 rv = -EAGAIN;
1371 if (test_bit(MTIP_DDF_REMOVE_PENDING_BIT,
1372 &port->dd->dd_flag)) {
1373 hba_reset_nosleep(port->dd);
1374 rv = -ENXIO;
1375 } else {
1376 mtip_restart_port(port);
1377 rv = -EAGAIN;
1378 }
1187 } 1379 }
1188 } 1380 }
1189 1381exec_ic_exit:
1190 /* Clear the allocated and active bits for the internal command. */ 1382 /* Clear the allocated and active bits for the internal command. */
1191 atomic_set(&int_cmd->active, 0); 1383 atomic_set(&int_cmd->active, 0);
1192 release_slot(port, MTIP_TAG_INTERNAL); 1384 release_slot(port, MTIP_TAG_INTERNAL);
1193 clear_bit(MTIP_FLAG_IC_ACTIVE_BIT, &port->flags); 1385 if (rv >= 0 && mtip_pause_ncq(port, fis)) {
1386 /* NCQ paused */
1387 return rv;
1388 }
1389 clear_bit(MTIP_PF_IC_ACTIVE_BIT, &port->flags);
1194 wake_up_interruptible(&port->svc_wait); 1390 wake_up_interruptible(&port->svc_wait);
1195 1391
1196 return rv; 1392 return rv;
@@ -1240,6 +1436,9 @@ static int mtip_get_identify(struct mtip_port *port, void __user *user_buffer)
1240 int rv = 0; 1436 int rv = 0;
1241 struct host_to_dev_fis fis; 1437 struct host_to_dev_fis fis;
1242 1438
1439 if (test_bit(MTIP_DDF_REMOVE_PENDING_BIT, &port->dd->dd_flag))
1440 return -EFAULT;
1441
1243 /* Build the FIS. */ 1442 /* Build the FIS. */
1244 memset(&fis, 0, sizeof(struct host_to_dev_fis)); 1443 memset(&fis, 0, sizeof(struct host_to_dev_fis));
1245 fis.type = 0x27; 1444 fis.type = 0x27;
@@ -1313,6 +1512,7 @@ static int mtip_standby_immediate(struct mtip_port *port)
1313{ 1512{
1314 int rv; 1513 int rv;
1315 struct host_to_dev_fis fis; 1514 struct host_to_dev_fis fis;
1515 unsigned long start;
1316 1516
1317 /* Build the FIS. */ 1517 /* Build the FIS. */
1318 memset(&fis, 0, sizeof(struct host_to_dev_fis)); 1518 memset(&fis, 0, sizeof(struct host_to_dev_fis));
@@ -1320,15 +1520,150 @@ static int mtip_standby_immediate(struct mtip_port *port)
1320 fis.opts = 1 << 7; 1520 fis.opts = 1 << 7;
1321 fis.command = ATA_CMD_STANDBYNOW1; 1521 fis.command = ATA_CMD_STANDBYNOW1;
1322 1522
1323 /* Execute the command. Use a 15-second timeout for large drives. */ 1523 start = jiffies;
1324 rv = mtip_exec_internal_command(port, 1524 rv = mtip_exec_internal_command(port,
1325 &fis, 1525 &fis,
1326 5, 1526 5,
1327 0, 1527 0,
1328 0, 1528 0,
1329 0, 1529 0,
1330 GFP_KERNEL, 1530 GFP_ATOMIC,
1331 15000); 1531 15000);
1532 dbg_printk(MTIP_DRV_NAME "Time taken to complete standby cmd: %d ms\n",
1533 jiffies_to_msecs(jiffies - start));
1534 if (rv)
1535 dev_warn(&port->dd->pdev->dev,
1536 "STANDBY IMMEDIATE command failed.\n");
1537
1538 return rv;
1539}
1540
1541/*
1542 * Issue a READ LOG EXT command to the device.
1543 *
1544 * @port pointer to the port structure.
1545 * @page page number to fetch
1546 * @buffer pointer to buffer
1547 * @buffer_dma dma address corresponding to @buffer
1548 * @sectors page length to fetch, in sectors
1549 *
1550 * return value
1551 * @rv return value from mtip_exec_internal_command()
1552 */
1553static int mtip_read_log_page(struct mtip_port *port, u8 page, u16 *buffer,
1554 dma_addr_t buffer_dma, unsigned int sectors)
1555{
1556 struct host_to_dev_fis fis;
1557
1558 memset(&fis, 0, sizeof(struct host_to_dev_fis));
1559 fis.type = 0x27;
1560 fis.opts = 1 << 7;
1561 fis.command = ATA_CMD_READ_LOG_EXT;
1562 fis.sect_count = sectors & 0xFF;
1563 fis.sect_cnt_ex = (sectors >> 8) & 0xFF;
1564 fis.lba_low = page;
1565 fis.lba_mid = 0;
1566 fis.device = ATA_DEVICE_OBS;
1567
1568 memset(buffer, 0, sectors * ATA_SECT_SIZE);
1569
1570 return mtip_exec_internal_command(port,
1571 &fis,
1572 5,
1573 buffer_dma,
1574 sectors * ATA_SECT_SIZE,
1575 0,
1576 GFP_ATOMIC,
1577 MTIP_INTERNAL_COMMAND_TIMEOUT_MS);
1578}
1579
1580/*
1581 * Issue a SMART READ DATA command to the device.
1582 *
1583 * @port pointer to the port structure.
1584 * @buffer pointer to buffer
1585 * @buffer_dma dma address corresponding to @buffer
1586 *
1587 * return value
1588 * @rv return value from mtip_exec_internal_command()
1589 */
1590static int mtip_get_smart_data(struct mtip_port *port, u8 *buffer,
1591 dma_addr_t buffer_dma)
1592{
1593 struct host_to_dev_fis fis;
1594
1595 memset(&fis, 0, sizeof(struct host_to_dev_fis));
1596 fis.type = 0x27;
1597 fis.opts = 1 << 7;
1598 fis.command = ATA_CMD_SMART;
1599 fis.features = 0xD0;
1600 fis.sect_count = 1;
1601 fis.lba_mid = 0x4F;
1602 fis.lba_hi = 0xC2;
1603 fis.device = ATA_DEVICE_OBS;
1604
1605 return mtip_exec_internal_command(port,
1606 &fis,
1607 5,
1608 buffer_dma,
1609 ATA_SECT_SIZE,
1610 0,
1611 GFP_ATOMIC,
1612 15000);
1613}
1614
1615/*
1616 * Get the value of a smart attribute
1617 *
1618 * @port pointer to the port structure
1619 * @id attribute number
1620 * @attrib pointer to return attrib information corresponding to @id
1621 *
1622 * return value
1623 * -EINVAL NULL buffer passed or unsupported attribute @id.
1624 * -EPERM Identify data not valid, SMART not supported or not enabled
1625 */
1626static int mtip_get_smart_attr(struct mtip_port *port, unsigned int id,
1627 struct smart_attr *attrib)
1628{
1629 int rv, i;
1630 struct smart_attr *pattr;
1631
1632 if (!attrib)
1633 return -EINVAL;
1634
1635 if (!port->identify_valid) {
1636 dev_warn(&port->dd->pdev->dev, "IDENTIFY DATA not valid\n");
1637 return -EPERM;
1638 }
1639 if (!(port->identify[82] & 0x1)) {
1640 dev_warn(&port->dd->pdev->dev, "SMART not supported\n");
1641 return -EPERM;
1642 }
1643 if (!(port->identify[85] & 0x1)) {
1644 dev_warn(&port->dd->pdev->dev, "SMART not enabled\n");
1645 return -EPERM;
1646 }
1647
1648 memset(port->smart_buf, 0, ATA_SECT_SIZE);
1649 rv = mtip_get_smart_data(port, port->smart_buf, port->smart_buf_dma);
1650 if (rv) {
1651 dev_warn(&port->dd->pdev->dev, "Failed to ge SMART data\n");
1652 return rv;
1653 }
1654
1655 pattr = (struct smart_attr *)(port->smart_buf + 2);
1656 for (i = 0; i < 29; i++, pattr++)
1657 if (pattr->attr_id == id) {
1658 memcpy(attrib, pattr, sizeof(struct smart_attr));
1659 break;
1660 }
1661
1662 if (i == 29) {
1663 dev_warn(&port->dd->pdev->dev,
1664 "Query for invalid SMART attribute ID\n");
1665 rv = -EINVAL;
1666 }
1332 1667
1333 return rv; 1668 return rv;
1334} 1669}
@@ -1504,10 +1839,7 @@ static int exec_drive_task(struct mtip_port *port, u8 *command)
1504 fis.cyl_hi = command[5]; 1839 fis.cyl_hi = command[5];
1505 fis.device = command[6] & ~0x10; /* Clear the dev bit*/ 1840 fis.device = command[6] & ~0x10; /* Clear the dev bit*/
1506 1841
1507 1842 dbg_printk(MTIP_DRV_NAME " %s: User Command: cmd %x, feat %x, nsect %x, sect %x, lcyl %x, hcyl %x, sel %x\n",
1508 dbg_printk(MTIP_DRV_NAME "%s: User Command: cmd %x, feat %x, "
1509 "nsect %x, sect %x, lcyl %x, "
1510 "hcyl %x, sel %x\n",
1511 __func__, 1843 __func__,
1512 command[0], 1844 command[0],
1513 command[1], 1845 command[1],
@@ -1534,8 +1866,7 @@ static int exec_drive_task(struct mtip_port *port, u8 *command)
1534 command[4] = reply->cyl_low; 1866 command[4] = reply->cyl_low;
1535 command[5] = reply->cyl_hi; 1867 command[5] = reply->cyl_hi;
1536 1868
1537 dbg_printk(MTIP_DRV_NAME "%s: Completion Status: stat %x, " 1869 dbg_printk(MTIP_DRV_NAME " %s: Completion Status: stat %x, err %x , cyl_lo %x cyl_hi %x\n",
1538 "err %x , cyl_lo %x cyl_hi %x\n",
1539 __func__, 1870 __func__,
1540 command[0], 1871 command[0],
1541 command[1], 1872 command[1],
@@ -1578,7 +1909,7 @@ static int exec_drive_command(struct mtip_port *port, u8 *command,
1578 } 1909 }
1579 1910
1580 dbg_printk(MTIP_DRV_NAME 1911 dbg_printk(MTIP_DRV_NAME
1581 "%s: User Command: cmd %x, sect %x, " 1912 " %s: User Command: cmd %x, sect %x, "
1582 "feat %x, sectcnt %x\n", 1913 "feat %x, sectcnt %x\n",
1583 __func__, 1914 __func__,
1584 command[0], 1915 command[0],
@@ -1607,7 +1938,7 @@ static int exec_drive_command(struct mtip_port *port, u8 *command,
1607 command[2] = command[3]; 1938 command[2] = command[3];
1608 1939
1609 dbg_printk(MTIP_DRV_NAME 1940 dbg_printk(MTIP_DRV_NAME
1610 "%s: Completion Status: stat %x, " 1941 " %s: Completion Status: stat %x, "
1611 "err %x, cmd %x\n", 1942 "err %x, cmd %x\n",
1612 __func__, 1943 __func__,
1613 command[0], 1944 command[0],
@@ -1810,9 +2141,10 @@ static int exec_drive_taskfile(struct driver_data *dd,
1810 } 2141 }
1811 2142
1812 dbg_printk(MTIP_DRV_NAME 2143 dbg_printk(MTIP_DRV_NAME
1813 "taskfile: cmd %x, feat %x, nsect %x," 2144 " %s: cmd %x, feat %x, nsect %x,"
1814 " sect/lbal %x, lcyl/lbam %x, hcyl/lbah %x," 2145 " sect/lbal %x, lcyl/lbam %x, hcyl/lbah %x,"
1815 " head/dev %x\n", 2146 " head/dev %x\n",
2147 __func__,
1816 fis.command, 2148 fis.command,
1817 fis.features, 2149 fis.features,
1818 fis.sect_count, 2150 fis.sect_count,
@@ -1823,8 +2155,8 @@ static int exec_drive_taskfile(struct driver_data *dd,
1823 2155
1824 switch (fis.command) { 2156 switch (fis.command) {
1825 case ATA_CMD_DOWNLOAD_MICRO: 2157 case ATA_CMD_DOWNLOAD_MICRO:
1826 /* Change timeout for Download Microcode to 60 seconds.*/ 2158 /* Change timeout for Download Microcode to 2 minutes */
1827 timeout = 60000; 2159 timeout = 120000;
1828 break; 2160 break;
1829 case ATA_CMD_SEC_ERASE_UNIT: 2161 case ATA_CMD_SEC_ERASE_UNIT:
1830 /* Change timeout for Security Erase Unit to 4 minutes.*/ 2162 /* Change timeout for Security Erase Unit to 4 minutes.*/
@@ -1840,8 +2172,8 @@ static int exec_drive_taskfile(struct driver_data *dd,
1840 timeout = 10000; 2172 timeout = 10000;
1841 break; 2173 break;
1842 case ATA_CMD_SMART: 2174 case ATA_CMD_SMART:
1843 /* Change timeout for vendor unique command to 10 secs */ 2175 /* Change timeout for vendor unique command to 15 secs */
1844 timeout = 10000; 2176 timeout = 15000;
1845 break; 2177 break;
1846 default: 2178 default:
1847 timeout = MTIP_IOCTL_COMMAND_TIMEOUT_MS; 2179 timeout = MTIP_IOCTL_COMMAND_TIMEOUT_MS;
@@ -1903,18 +2235,8 @@ static int exec_drive_taskfile(struct driver_data *dd,
1903 req_task->hob_ports[1] = reply->features_ex; 2235 req_task->hob_ports[1] = reply->features_ex;
1904 req_task->hob_ports[2] = reply->sect_cnt_ex; 2236 req_task->hob_ports[2] = reply->sect_cnt_ex;
1905 } 2237 }
1906
1907 /* Com rest after secure erase or lowlevel format */
1908 if (((fis.command == ATA_CMD_SEC_ERASE_UNIT) ||
1909 ((fis.command == 0xFC) &&
1910 (fis.features == 0x27 || fis.features == 0x72 ||
1911 fis.features == 0x62 || fis.features == 0x26))) &&
1912 !(reply->command & 1)) {
1913 mtip_restart_port(dd->port);
1914 }
1915
1916 dbg_printk(MTIP_DRV_NAME 2238 dbg_printk(MTIP_DRV_NAME
1917 "%s: Completion: stat %x," 2239 " %s: Completion: stat %x,"
1918 "err %x, sect_cnt %x, lbalo %x," 2240 "err %x, sect_cnt %x, lbalo %x,"
1919 "lbamid %x, lbahi %x, dev %x\n", 2241 "lbamid %x, lbahi %x, dev %x\n",
1920 __func__, 2242 __func__,
@@ -2080,14 +2402,10 @@ static void mtip_hw_submit_io(struct driver_data *dd, sector_t start,
2080 struct host_to_dev_fis *fis; 2402 struct host_to_dev_fis *fis;
2081 struct mtip_port *port = dd->port; 2403 struct mtip_port *port = dd->port;
2082 struct mtip_cmd *command = &port->commands[tag]; 2404 struct mtip_cmd *command = &port->commands[tag];
2405 int dma_dir = (dir == READ) ? DMA_FROM_DEVICE : DMA_TO_DEVICE;
2083 2406
2084 /* Map the scatter list for DMA access */ 2407 /* Map the scatter list for DMA access */
2085 if (dir == READ) 2408 nents = dma_map_sg(&dd->pdev->dev, command->sg, nents, dma_dir);
2086 nents = dma_map_sg(&dd->pdev->dev, command->sg,
2087 nents, DMA_FROM_DEVICE);
2088 else
2089 nents = dma_map_sg(&dd->pdev->dev, command->sg,
2090 nents, DMA_TO_DEVICE);
2091 2409
2092 command->scatter_ents = nents; 2410 command->scatter_ents = nents;
2093 2411
@@ -2127,7 +2445,7 @@ static void mtip_hw_submit_io(struct driver_data *dd, sector_t start,
2127 */ 2445 */
2128 command->comp_data = dd; 2446 command->comp_data = dd;
2129 command->comp_func = mtip_async_complete; 2447 command->comp_func = mtip_async_complete;
2130 command->direction = (dir == READ ? DMA_FROM_DEVICE : DMA_TO_DEVICE); 2448 command->direction = dma_dir;
2131 2449
2132 /* 2450 /*
2133 * Set the completion function and data for the command passed 2451 * Set the completion function and data for the command passed
@@ -2140,19 +2458,16 @@ static void mtip_hw_submit_io(struct driver_data *dd, sector_t start,
2140 * To prevent this command from being issued 2458 * To prevent this command from being issued
2141 * if an internal command is in progress or error handling is active. 2459 * if an internal command is in progress or error handling is active.
2142 */ 2460 */
2143 if (unlikely(test_bit(MTIP_FLAG_IC_ACTIVE_BIT, &port->flags) || 2461 if (port->flags & MTIP_PF_PAUSE_IO) {
2144 test_bit(MTIP_FLAG_EH_ACTIVE_BIT, &port->flags))) {
2145 set_bit(tag, port->cmds_to_issue); 2462 set_bit(tag, port->cmds_to_issue);
2146 set_bit(MTIP_FLAG_ISSUE_CMDS_BIT, &port->flags); 2463 set_bit(MTIP_PF_ISSUE_CMDS_BIT, &port->flags);
2147 return; 2464 return;
2148 } 2465 }
2149 2466
2150 /* Issue the command to the hardware */ 2467 /* Issue the command to the hardware */
2151 mtip_issue_ncq_command(port, tag); 2468 mtip_issue_ncq_command(port, tag);
2152 2469
2153 /* Set the command's timeout value.*/ 2470 return;
2154 port->commands[tag].comp_time = jiffies + msecs_to_jiffies(
2155 MTIP_NCQ_COMMAND_TIMEOUT_MS);
2156} 2471}
2157 2472
2158/* 2473/*
@@ -2191,6 +2506,10 @@ static struct scatterlist *mtip_hw_get_scatterlist(struct driver_data *dd,
2191 down(&dd->port->cmd_slot); 2506 down(&dd->port->cmd_slot);
2192 *tag = get_slot(dd->port); 2507 *tag = get_slot(dd->port);
2193 2508
2509 if (unlikely(test_bit(MTIP_DDF_REMOVE_PENDING_BIT, &dd->dd_flag))) {
2510 up(&dd->port->cmd_slot);
2511 return NULL;
2512 }
2194 if (unlikely(*tag < 0)) 2513 if (unlikely(*tag < 0))
2195 return NULL; 2514 return NULL;
2196 2515
@@ -2207,7 +2526,7 @@ static struct scatterlist *mtip_hw_get_scatterlist(struct driver_data *dd,
2207 * return value 2526 * return value
2208 * The size, in bytes, of the data copied into buf. 2527 * The size, in bytes, of the data copied into buf.
2209 */ 2528 */
2210static ssize_t hw_show_registers(struct device *dev, 2529static ssize_t mtip_hw_show_registers(struct device *dev,
2211 struct device_attribute *attr, 2530 struct device_attribute *attr,
2212 char *buf) 2531 char *buf)
2213{ 2532{
@@ -2216,7 +2535,7 @@ static ssize_t hw_show_registers(struct device *dev,
2216 int size = 0; 2535 int size = 0;
2217 int n; 2536 int n;
2218 2537
2219 size += sprintf(&buf[size], "%s:\ns_active:\n", __func__); 2538 size += sprintf(&buf[size], "S ACTive:\n");
2220 2539
2221 for (n = 0; n < dd->slot_groups; n++) 2540 for (n = 0; n < dd->slot_groups; n++)
2222 size += sprintf(&buf[size], "0x%08x\n", 2541 size += sprintf(&buf[size], "0x%08x\n",
@@ -2240,20 +2559,39 @@ static ssize_t hw_show_registers(struct device *dev,
2240 group_allocated); 2559 group_allocated);
2241 } 2560 }
2242 2561
2243 size += sprintf(&buf[size], "completed:\n"); 2562 size += sprintf(&buf[size], "Completed:\n");
2244 2563
2245 for (n = 0; n < dd->slot_groups; n++) 2564 for (n = 0; n < dd->slot_groups; n++)
2246 size += sprintf(&buf[size], "0x%08x\n", 2565 size += sprintf(&buf[size], "0x%08x\n",
2247 readl(dd->port->completed[n])); 2566 readl(dd->port->completed[n]));
2248 2567
2249 size += sprintf(&buf[size], "PORT_IRQ_STAT 0x%08x\n", 2568 size += sprintf(&buf[size], "PORT IRQ STAT : 0x%08x\n",
2250 readl(dd->port->mmio + PORT_IRQ_STAT)); 2569 readl(dd->port->mmio + PORT_IRQ_STAT));
2251 size += sprintf(&buf[size], "HOST_IRQ_STAT 0x%08x\n", 2570 size += sprintf(&buf[size], "HOST IRQ STAT : 0x%08x\n",
2252 readl(dd->mmio + HOST_IRQ_STAT)); 2571 readl(dd->mmio + HOST_IRQ_STAT));
2253 2572
2254 return size; 2573 return size;
2255} 2574}
2256static DEVICE_ATTR(registers, S_IRUGO, hw_show_registers, NULL); 2575
2576static ssize_t mtip_hw_show_status(struct device *dev,
2577 struct device_attribute *attr,
2578 char *buf)
2579{
2580 struct driver_data *dd = dev_to_disk(dev)->private_data;
2581 int size = 0;
2582
2583 if (test_bit(MTIP_DDF_OVER_TEMP_BIT, &dd->dd_flag))
2584 size += sprintf(buf, "%s", "thermal_shutdown\n");
2585 else if (test_bit(MTIP_DDF_WRITE_PROTECT_BIT, &dd->dd_flag))
2586 size += sprintf(buf, "%s", "write_protect\n");
2587 else
2588 size += sprintf(buf, "%s", "online\n");
2589
2590 return size;
2591}
2592
2593static DEVICE_ATTR(registers, S_IRUGO, mtip_hw_show_registers, NULL);
2594static DEVICE_ATTR(status, S_IRUGO, mtip_hw_show_status, NULL);
2257 2595
2258/* 2596/*
2259 * Create the sysfs related attributes. 2597 * Create the sysfs related attributes.
@@ -2272,7 +2610,10 @@ static int mtip_hw_sysfs_init(struct driver_data *dd, struct kobject *kobj)
2272 2610
2273 if (sysfs_create_file(kobj, &dev_attr_registers.attr)) 2611 if (sysfs_create_file(kobj, &dev_attr_registers.attr))
2274 dev_warn(&dd->pdev->dev, 2612 dev_warn(&dd->pdev->dev,
2275 "Error creating registers sysfs entry\n"); 2613 "Error creating 'registers' sysfs entry\n");
2614 if (sysfs_create_file(kobj, &dev_attr_status.attr))
2615 dev_warn(&dd->pdev->dev,
2616 "Error creating 'status' sysfs entry\n");
2276 return 0; 2617 return 0;
2277} 2618}
2278 2619
@@ -2292,6 +2633,7 @@ static int mtip_hw_sysfs_exit(struct driver_data *dd, struct kobject *kobj)
2292 return -EINVAL; 2633 return -EINVAL;
2293 2634
2294 sysfs_remove_file(kobj, &dev_attr_registers.attr); 2635 sysfs_remove_file(kobj, &dev_attr_registers.attr);
2636 sysfs_remove_file(kobj, &dev_attr_status.attr);
2295 2637
2296 return 0; 2638 return 0;
2297} 2639}
@@ -2384,10 +2726,12 @@ static int mtip_ftl_rebuild_poll(struct driver_data *dd)
2384 "FTL rebuild in progress. Polling for completion.\n"); 2726 "FTL rebuild in progress. Polling for completion.\n");
2385 2727
2386 start = jiffies; 2728 start = jiffies;
2387 dd->ftlrebuildflag = 1;
2388 timeout = jiffies + msecs_to_jiffies(MTIP_FTL_REBUILD_TIMEOUT_MS); 2729 timeout = jiffies + msecs_to_jiffies(MTIP_FTL_REBUILD_TIMEOUT_MS);
2389 2730
2390 do { 2731 do {
2732 if (unlikely(test_bit(MTIP_DDF_REMOVE_PENDING_BIT,
2733 &dd->dd_flag)))
2734 return -EFAULT;
2391 if (mtip_check_surprise_removal(dd->pdev)) 2735 if (mtip_check_surprise_removal(dd->pdev))
2392 return -EFAULT; 2736 return -EFAULT;
2393 2737
@@ -2408,22 +2752,17 @@ static int mtip_ftl_rebuild_poll(struct driver_data *dd)
2408 dev_warn(&dd->pdev->dev, 2752 dev_warn(&dd->pdev->dev,
2409 "FTL rebuild complete (%d secs).\n", 2753 "FTL rebuild complete (%d secs).\n",
2410 jiffies_to_msecs(jiffies - start) / 1000); 2754 jiffies_to_msecs(jiffies - start) / 1000);
2411 dd->ftlrebuildflag = 0;
2412 mtip_block_initialize(dd); 2755 mtip_block_initialize(dd);
2413 break; 2756 return 0;
2414 } 2757 }
2415 ssleep(10); 2758 ssleep(10);
2416 } while (time_before(jiffies, timeout)); 2759 } while (time_before(jiffies, timeout));
2417 2760
2418 /* Check for timeout */ 2761 /* Check for timeout */
2419 if (dd->ftlrebuildflag) { 2762 dev_err(&dd->pdev->dev,
2420 dev_err(&dd->pdev->dev,
2421 "Timed out waiting for FTL rebuild to complete (%d secs).\n", 2763 "Timed out waiting for FTL rebuild to complete (%d secs).\n",
2422 jiffies_to_msecs(jiffies - start) / 1000); 2764 jiffies_to_msecs(jiffies - start) / 1000);
2423 return -EFAULT; 2765 return -EFAULT;
2424 }
2425
2426 return 0;
2427} 2766}
2428 2767
2429/* 2768/*
@@ -2448,14 +2787,17 @@ static int mtip_service_thread(void *data)
2448 * is in progress nor error handling is active 2787 * is in progress nor error handling is active
2449 */ 2788 */
2450 wait_event_interruptible(port->svc_wait, (port->flags) && 2789 wait_event_interruptible(port->svc_wait, (port->flags) &&
2451 !test_bit(MTIP_FLAG_IC_ACTIVE_BIT, &port->flags) && 2790 !(port->flags & MTIP_PF_PAUSE_IO));
2452 !test_bit(MTIP_FLAG_EH_ACTIVE_BIT, &port->flags));
2453 2791
2454 if (kthread_should_stop()) 2792 if (kthread_should_stop())
2455 break; 2793 break;
2456 2794
2457 set_bit(MTIP_FLAG_SVC_THD_ACTIVE_BIT, &port->flags); 2795 if (unlikely(test_bit(MTIP_DDF_REMOVE_PENDING_BIT,
2458 if (test_bit(MTIP_FLAG_ISSUE_CMDS_BIT, &port->flags)) { 2796 &dd->dd_flag)))
2797 break;
2798
2799 set_bit(MTIP_PF_SVC_THD_ACTIVE_BIT, &port->flags);
2800 if (test_bit(MTIP_PF_ISSUE_CMDS_BIT, &port->flags)) {
2459 slot = 1; 2801 slot = 1;
2460 /* used to restrict the loop to one iteration */ 2802 /* used to restrict the loop to one iteration */
2461 slot_start = num_cmd_slots; 2803 slot_start = num_cmd_slots;
@@ -2480,21 +2822,19 @@ static int mtip_service_thread(void *data)
2480 /* Issue the command to the hardware */ 2822 /* Issue the command to the hardware */
2481 mtip_issue_ncq_command(port, slot); 2823 mtip_issue_ncq_command(port, slot);
2482 2824
2483 /* Set the command's timeout value.*/
2484 port->commands[slot].comp_time = jiffies +
2485 msecs_to_jiffies(MTIP_NCQ_COMMAND_TIMEOUT_MS);
2486
2487 clear_bit(slot, port->cmds_to_issue); 2825 clear_bit(slot, port->cmds_to_issue);
2488 } 2826 }
2489 2827
2490 clear_bit(MTIP_FLAG_ISSUE_CMDS_BIT, &port->flags); 2828 clear_bit(MTIP_PF_ISSUE_CMDS_BIT, &port->flags);
2491 } else if (test_bit(MTIP_FLAG_REBUILD_BIT, &port->flags)) { 2829 } else if (test_bit(MTIP_PF_REBUILD_BIT, &port->flags)) {
2492 mtip_ftl_rebuild_poll(dd); 2830 if (!mtip_ftl_rebuild_poll(dd))
2493 clear_bit(MTIP_FLAG_REBUILD_BIT, &port->flags); 2831 set_bit(MTIP_DDF_REBUILD_FAILED_BIT,
2832 &dd->dd_flag);
2833 clear_bit(MTIP_PF_REBUILD_BIT, &port->flags);
2494 } 2834 }
2495 clear_bit(MTIP_FLAG_SVC_THD_ACTIVE_BIT, &port->flags); 2835 clear_bit(MTIP_PF_SVC_THD_ACTIVE_BIT, &port->flags);
2496 2836
2497 if (test_bit(MTIP_FLAG_SVC_THD_SHOULD_STOP_BIT, &port->flags)) 2837 if (test_bit(MTIP_PF_SVC_THD_STOP_BIT, &port->flags))
2498 break; 2838 break;
2499 } 2839 }
2500 return 0; 2840 return 0;
@@ -2513,6 +2853,9 @@ static int mtip_hw_init(struct driver_data *dd)
2513 int i; 2853 int i;
2514 int rv; 2854 int rv;
2515 unsigned int num_command_slots; 2855 unsigned int num_command_slots;
2856 unsigned long timeout, timetaken;
2857 unsigned char *buf;
2858 struct smart_attr attr242;
2516 2859
2517 dd->mmio = pcim_iomap_table(dd->pdev)[MTIP_ABAR]; 2860 dd->mmio = pcim_iomap_table(dd->pdev)[MTIP_ABAR];
2518 2861
@@ -2547,7 +2890,7 @@ static int mtip_hw_init(struct driver_data *dd)
2547 /* Allocate memory for the command list. */ 2890 /* Allocate memory for the command list. */
2548 dd->port->command_list = 2891 dd->port->command_list =
2549 dmam_alloc_coherent(&dd->pdev->dev, 2892 dmam_alloc_coherent(&dd->pdev->dev,
2550 HW_PORT_PRIV_DMA_SZ + (ATA_SECT_SIZE * 2), 2893 HW_PORT_PRIV_DMA_SZ + (ATA_SECT_SIZE * 4),
2551 &dd->port->command_list_dma, 2894 &dd->port->command_list_dma,
2552 GFP_KERNEL); 2895 GFP_KERNEL);
2553 if (!dd->port->command_list) { 2896 if (!dd->port->command_list) {
@@ -2560,7 +2903,7 @@ static int mtip_hw_init(struct driver_data *dd)
2560 /* Clear the memory we have allocated. */ 2903 /* Clear the memory we have allocated. */
2561 memset(dd->port->command_list, 2904 memset(dd->port->command_list,
2562 0, 2905 0,
2563 HW_PORT_PRIV_DMA_SZ + (ATA_SECT_SIZE * 2)); 2906 HW_PORT_PRIV_DMA_SZ + (ATA_SECT_SIZE * 4));
2564 2907
2565 /* Setup the addresse of the RX FIS. */ 2908 /* Setup the addresse of the RX FIS. */
2566 dd->port->rxfis = dd->port->command_list + HW_CMD_SLOT_SZ; 2909 dd->port->rxfis = dd->port->command_list + HW_CMD_SLOT_SZ;
@@ -2576,10 +2919,19 @@ static int mtip_hw_init(struct driver_data *dd)
2576 dd->port->identify_dma = dd->port->command_tbl_dma + 2919 dd->port->identify_dma = dd->port->command_tbl_dma +
2577 HW_CMD_TBL_AR_SZ; 2920 HW_CMD_TBL_AR_SZ;
2578 2921
2579 /* Setup the address of the sector buffer. */ 2922 /* Setup the address of the sector buffer - for some non-ncq cmds */
2580 dd->port->sector_buffer = (void *) dd->port->identify + ATA_SECT_SIZE; 2923 dd->port->sector_buffer = (void *) dd->port->identify + ATA_SECT_SIZE;
2581 dd->port->sector_buffer_dma = dd->port->identify_dma + ATA_SECT_SIZE; 2924 dd->port->sector_buffer_dma = dd->port->identify_dma + ATA_SECT_SIZE;
2582 2925
2926 /* Setup the address of the log buf - for read log command */
2927 dd->port->log_buf = (void *)dd->port->sector_buffer + ATA_SECT_SIZE;
2928 dd->port->log_buf_dma = dd->port->sector_buffer_dma + ATA_SECT_SIZE;
2929
2930 /* Setup the address of the smart buf - for smart read data command */
2931 dd->port->smart_buf = (void *)dd->port->log_buf + ATA_SECT_SIZE;
2932 dd->port->smart_buf_dma = dd->port->log_buf_dma + ATA_SECT_SIZE;
2933
2934
2583 /* Point the command headers at the command tables. */ 2935 /* Point the command headers at the command tables. */
2584 for (i = 0; i < num_command_slots; i++) { 2936 for (i = 0; i < num_command_slots; i++) {
2585 dd->port->commands[i].command_header = 2937 dd->port->commands[i].command_header =
@@ -2623,14 +2975,43 @@ static int mtip_hw_init(struct driver_data *dd)
2623 dd->port->mmio + i*0x80 + PORT_SDBV; 2975 dd->port->mmio + i*0x80 + PORT_SDBV;
2624 } 2976 }
2625 2977
2626 /* Reset the HBA. */ 2978 timetaken = jiffies;
2627 if (mtip_hba_reset(dd) < 0) { 2979 timeout = jiffies + msecs_to_jiffies(30000);
2628 dev_err(&dd->pdev->dev, 2980 while (((readl(dd->port->mmio + PORT_SCR_STAT) & 0x0F) != 0x03) &&
2629 "Card did not reset within timeout\n"); 2981 time_before(jiffies, timeout)) {
2630 rv = -EIO; 2982 mdelay(100);
2983 }
2984 if (unlikely(mtip_check_surprise_removal(dd->pdev))) {
2985 timetaken = jiffies - timetaken;
2986 dev_warn(&dd->pdev->dev,
2987 "Surprise removal detected at %u ms\n",
2988 jiffies_to_msecs(timetaken));
2989 rv = -ENODEV;
2990 goto out2 ;
2991 }
2992 if (unlikely(test_bit(MTIP_DDF_REMOVE_PENDING_BIT, &dd->dd_flag))) {
2993 timetaken = jiffies - timetaken;
2994 dev_warn(&dd->pdev->dev,
2995 "Removal detected at %u ms\n",
2996 jiffies_to_msecs(timetaken));
2997 rv = -EFAULT;
2631 goto out2; 2998 goto out2;
2632 } 2999 }
2633 3000
3001 /* Conditionally reset the HBA. */
3002 if (!(readl(dd->mmio + HOST_CAP) & HOST_CAP_NZDMA)) {
3003 if (mtip_hba_reset(dd) < 0) {
3004 dev_err(&dd->pdev->dev,
3005 "Card did not reset within timeout\n");
3006 rv = -EIO;
3007 goto out2;
3008 }
3009 } else {
3010 /* Clear any pending interrupts on the HBA */
3011 writel(readl(dd->mmio + HOST_IRQ_STAT),
3012 dd->mmio + HOST_IRQ_STAT);
3013 }
3014
2634 mtip_init_port(dd->port); 3015 mtip_init_port(dd->port);
2635 mtip_start_port(dd->port); 3016 mtip_start_port(dd->port);
2636 3017
@@ -2660,6 +3041,12 @@ static int mtip_hw_init(struct driver_data *dd)
2660 mod_timer(&dd->port->cmd_timer, 3041 mod_timer(&dd->port->cmd_timer,
2661 jiffies + msecs_to_jiffies(MTIP_TIMEOUT_CHECK_PERIOD)); 3042 jiffies + msecs_to_jiffies(MTIP_TIMEOUT_CHECK_PERIOD));
2662 3043
3044
3045 if (test_bit(MTIP_DDF_REMOVE_PENDING_BIT, &dd->dd_flag)) {
3046 rv = -EFAULT;
3047 goto out3;
3048 }
3049
2663 if (mtip_get_identify(dd->port, NULL) < 0) { 3050 if (mtip_get_identify(dd->port, NULL) < 0) {
2664 rv = -EFAULT; 3051 rv = -EFAULT;
2665 goto out3; 3052 goto out3;
@@ -2667,10 +3054,47 @@ static int mtip_hw_init(struct driver_data *dd)
2667 3054
2668 if (*(dd->port->identify + MTIP_FTL_REBUILD_OFFSET) == 3055 if (*(dd->port->identify + MTIP_FTL_REBUILD_OFFSET) ==
2669 MTIP_FTL_REBUILD_MAGIC) { 3056 MTIP_FTL_REBUILD_MAGIC) {
2670 set_bit(MTIP_FLAG_REBUILD_BIT, &dd->port->flags); 3057 set_bit(MTIP_PF_REBUILD_BIT, &dd->port->flags);
2671 return MTIP_FTL_REBUILD_MAGIC; 3058 return MTIP_FTL_REBUILD_MAGIC;
2672 } 3059 }
2673 mtip_dump_identify(dd->port); 3060 mtip_dump_identify(dd->port);
3061
3062 /* check write protect, over temp and rebuild statuses */
3063 rv = mtip_read_log_page(dd->port, ATA_LOG_SATA_NCQ,
3064 dd->port->log_buf,
3065 dd->port->log_buf_dma, 1);
3066 if (rv) {
3067 dev_warn(&dd->pdev->dev,
3068 "Error in READ LOG EXT (10h) command\n");
3069 /* non-critical error, don't fail the load */
3070 } else {
3071 buf = (unsigned char *)dd->port->log_buf;
3072 if (buf[259] & 0x1) {
3073 dev_info(&dd->pdev->dev,
3074 "Write protect bit is set.\n");
3075 set_bit(MTIP_DDF_WRITE_PROTECT_BIT, &dd->dd_flag);
3076 }
3077 if (buf[288] == 0xF7) {
3078 dev_info(&dd->pdev->dev,
3079 "Exceeded Tmax, drive in thermal shutdown.\n");
3080 set_bit(MTIP_DDF_OVER_TEMP_BIT, &dd->dd_flag);
3081 }
3082 if (buf[288] == 0xBF) {
3083 dev_info(&dd->pdev->dev,
3084 "Drive indicates rebuild has failed.\n");
3085 /* TODO */
3086 }
3087 }
3088
3089 /* get write protect progess */
3090 memset(&attr242, 0, sizeof(struct smart_attr));
3091 if (mtip_get_smart_attr(dd->port, 242, &attr242))
3092 dev_warn(&dd->pdev->dev,
3093 "Unable to check write protect progress\n");
3094 else
3095 dev_info(&dd->pdev->dev,
3096 "Write protect progress: %d%% (%d blocks)\n",
3097 attr242.cur, attr242.data);
2674 return rv; 3098 return rv;
2675 3099
2676out3: 3100out3:
@@ -2688,7 +3112,7 @@ out2:
2688 3112
2689 /* Free the command/command header memory. */ 3113 /* Free the command/command header memory. */
2690 dmam_free_coherent(&dd->pdev->dev, 3114 dmam_free_coherent(&dd->pdev->dev,
2691 HW_PORT_PRIV_DMA_SZ + (ATA_SECT_SIZE * 2), 3115 HW_PORT_PRIV_DMA_SZ + (ATA_SECT_SIZE * 4),
2692 dd->port->command_list, 3116 dd->port->command_list,
2693 dd->port->command_list_dma); 3117 dd->port->command_list_dma);
2694out1: 3118out1:
@@ -2712,9 +3136,12 @@ static int mtip_hw_exit(struct driver_data *dd)
2712 * Send standby immediate (E0h) to the drive so that it 3136 * Send standby immediate (E0h) to the drive so that it
2713 * saves its state. 3137 * saves its state.
2714 */ 3138 */
2715 if (atomic_read(&dd->drv_cleanup_done) != true) { 3139 if (!test_bit(MTIP_DDF_CLEANUP_BIT, &dd->dd_flag)) {
2716 3140
2717 mtip_standby_immediate(dd->port); 3141 if (!test_bit(MTIP_PF_REBUILD_BIT, &dd->port->flags))
3142 if (mtip_standby_immediate(dd->port))
3143 dev_warn(&dd->pdev->dev,
3144 "STANDBY IMMEDIATE failed\n");
2718 3145
2719 /* de-initialize the port. */ 3146 /* de-initialize the port. */
2720 mtip_deinit_port(dd->port); 3147 mtip_deinit_port(dd->port);
@@ -2734,7 +3161,7 @@ static int mtip_hw_exit(struct driver_data *dd)
2734 3161
2735 /* Free the command/command header memory. */ 3162 /* Free the command/command header memory. */
2736 dmam_free_coherent(&dd->pdev->dev, 3163 dmam_free_coherent(&dd->pdev->dev,
2737 HW_PORT_PRIV_DMA_SZ + (ATA_SECT_SIZE * 2), 3164 HW_PORT_PRIV_DMA_SZ + (ATA_SECT_SIZE * 4),
2738 dd->port->command_list, 3165 dd->port->command_list,
2739 dd->port->command_list_dma); 3166 dd->port->command_list_dma);
2740 /* Free the memory allocated for the for structure. */ 3167 /* Free the memory allocated for the for structure. */
@@ -2892,6 +3319,9 @@ static int mtip_block_ioctl(struct block_device *dev,
2892 if (!dd) 3319 if (!dd)
2893 return -ENOTTY; 3320 return -ENOTTY;
2894 3321
3322 if (unlikely(test_bit(MTIP_DDF_REMOVE_PENDING_BIT, &dd->dd_flag)))
3323 return -ENOTTY;
3324
2895 switch (cmd) { 3325 switch (cmd) {
2896 case BLKFLSBUF: 3326 case BLKFLSBUF:
2897 return -ENOTTY; 3327 return -ENOTTY;
@@ -2927,6 +3357,9 @@ static int mtip_block_compat_ioctl(struct block_device *dev,
2927 if (!dd) 3357 if (!dd)
2928 return -ENOTTY; 3358 return -ENOTTY;
2929 3359
3360 if (unlikely(test_bit(MTIP_DDF_REMOVE_PENDING_BIT, &dd->dd_flag)))
3361 return -ENOTTY;
3362
2930 switch (cmd) { 3363 switch (cmd) {
2931 case BLKFLSBUF: 3364 case BLKFLSBUF:
2932 return -ENOTTY; 3365 return -ENOTTY;
@@ -3049,6 +3482,24 @@ static void mtip_make_request(struct request_queue *queue, struct bio *bio)
3049 int nents = 0; 3482 int nents = 0;
3050 int tag = 0; 3483 int tag = 0;
3051 3484
3485 if (unlikely(dd->dd_flag & MTIP_DDF_STOP_IO)) {
3486 if (unlikely(test_bit(MTIP_DDF_REMOVE_PENDING_BIT,
3487 &dd->dd_flag))) {
3488 bio_endio(bio, -ENXIO);
3489 return;
3490 }
3491 if (unlikely(test_bit(MTIP_DDF_OVER_TEMP_BIT, &dd->dd_flag))) {
3492 bio_endio(bio, -ENODATA);
3493 return;
3494 }
3495 if (unlikely(test_bit(MTIP_DDF_WRITE_PROTECT_BIT,
3496 &dd->dd_flag) &&
3497 bio_data_dir(bio))) {
3498 bio_endio(bio, -ENODATA);
3499 return;
3500 }
3501 }
3502
3052 if (unlikely(!bio_has_data(bio))) { 3503 if (unlikely(!bio_has_data(bio))) {
3053 blk_queue_flush(queue, 0); 3504 blk_queue_flush(queue, 0);
3054 bio_endio(bio, 0); 3505 bio_endio(bio, 0);
@@ -3061,7 +3512,7 @@ static void mtip_make_request(struct request_queue *queue, struct bio *bio)
3061 3512
3062 if (unlikely((bio)->bi_vcnt > MTIP_MAX_SG)) { 3513 if (unlikely((bio)->bi_vcnt > MTIP_MAX_SG)) {
3063 dev_warn(&dd->pdev->dev, 3514 dev_warn(&dd->pdev->dev,
3064 "Maximum number of SGL entries exceeded"); 3515 "Maximum number of SGL entries exceeded\n");
3065 bio_io_error(bio); 3516 bio_io_error(bio);
3066 mtip_hw_release_scatterlist(dd, tag); 3517 mtip_hw_release_scatterlist(dd, tag);
3067 return; 3518 return;
@@ -3210,8 +3661,10 @@ skip_create_disk:
3210 kobject_put(kobj); 3661 kobject_put(kobj);
3211 } 3662 }
3212 3663
3213 if (dd->mtip_svc_handler) 3664 if (dd->mtip_svc_handler) {
3665 set_bit(MTIP_DDF_INIT_DONE_BIT, &dd->dd_flag);
3214 return rv; /* service thread created for handling rebuild */ 3666 return rv; /* service thread created for handling rebuild */
3667 }
3215 3668
3216start_service_thread: 3669start_service_thread:
3217 sprintf(thd_name, "mtip_svc_thd_%02d", index); 3670 sprintf(thd_name, "mtip_svc_thd_%02d", index);
@@ -3220,12 +3673,15 @@ start_service_thread:
3220 dd, thd_name); 3673 dd, thd_name);
3221 3674
3222 if (IS_ERR(dd->mtip_svc_handler)) { 3675 if (IS_ERR(dd->mtip_svc_handler)) {
3223 printk(KERN_ERR "mtip32xx: service thread failed to start\n"); 3676 dev_err(&dd->pdev->dev, "service thread failed to start\n");
3224 dd->mtip_svc_handler = NULL; 3677 dd->mtip_svc_handler = NULL;
3225 rv = -EFAULT; 3678 rv = -EFAULT;
3226 goto kthread_run_error; 3679 goto kthread_run_error;
3227 } 3680 }
3228 3681
3682 if (wait_for_rebuild == MTIP_FTL_REBUILD_MAGIC)
3683 rv = wait_for_rebuild;
3684
3229 return rv; 3685 return rv;
3230 3686
3231kthread_run_error: 3687kthread_run_error:
@@ -3266,16 +3722,18 @@ static int mtip_block_remove(struct driver_data *dd)
3266 struct kobject *kobj; 3722 struct kobject *kobj;
3267 3723
3268 if (dd->mtip_svc_handler) { 3724 if (dd->mtip_svc_handler) {
3269 set_bit(MTIP_FLAG_SVC_THD_SHOULD_STOP_BIT, &dd->port->flags); 3725 set_bit(MTIP_PF_SVC_THD_STOP_BIT, &dd->port->flags);
3270 wake_up_interruptible(&dd->port->svc_wait); 3726 wake_up_interruptible(&dd->port->svc_wait);
3271 kthread_stop(dd->mtip_svc_handler); 3727 kthread_stop(dd->mtip_svc_handler);
3272 } 3728 }
3273 3729
3274 /* Clean up the sysfs attributes managed by the protocol layer. */ 3730 /* Clean up the sysfs attributes, if created */
3275 kobj = kobject_get(&disk_to_dev(dd->disk)->kobj); 3731 if (test_bit(MTIP_DDF_INIT_DONE_BIT, &dd->dd_flag)) {
3276 if (kobj) { 3732 kobj = kobject_get(&disk_to_dev(dd->disk)->kobj);
3277 mtip_hw_sysfs_exit(dd, kobj); 3733 if (kobj) {
3278 kobject_put(kobj); 3734 mtip_hw_sysfs_exit(dd, kobj);
3735 kobject_put(kobj);
3736 }
3279 } 3737 }
3280 3738
3281 /* 3739 /*
@@ -3283,6 +3741,11 @@ static int mtip_block_remove(struct driver_data *dd)
3283 * from /dev 3741 * from /dev
3284 */ 3742 */
3285 del_gendisk(dd->disk); 3743 del_gendisk(dd->disk);
3744
3745 spin_lock(&rssd_index_lock);
3746 ida_remove(&rssd_index_ida, dd->index);
3747 spin_unlock(&rssd_index_lock);
3748
3286 blk_cleanup_queue(dd->queue); 3749 blk_cleanup_queue(dd->queue);
3287 dd->disk = NULL; 3750 dd->disk = NULL;
3288 dd->queue = NULL; 3751 dd->queue = NULL;
@@ -3312,6 +3775,11 @@ static int mtip_block_shutdown(struct driver_data *dd)
3312 3775
3313 /* Delete our gendisk structure, and cleanup the blk queue. */ 3776 /* Delete our gendisk structure, and cleanup the blk queue. */
3314 del_gendisk(dd->disk); 3777 del_gendisk(dd->disk);
3778
3779 spin_lock(&rssd_index_lock);
3780 ida_remove(&rssd_index_ida, dd->index);
3781 spin_unlock(&rssd_index_lock);
3782
3315 blk_cleanup_queue(dd->queue); 3783 blk_cleanup_queue(dd->queue);
3316 dd->disk = NULL; 3784 dd->disk = NULL;
3317 dd->queue = NULL; 3785 dd->queue = NULL;
@@ -3359,11 +3827,6 @@ static int mtip_pci_probe(struct pci_dev *pdev,
3359 return -ENOMEM; 3827 return -ENOMEM;
3360 } 3828 }
3361 3829
3362 /* Set the atomic variable as 1 in case of SRSI */
3363 atomic_set(&dd->drv_cleanup_done, true);
3364
3365 atomic_set(&dd->resumeflag, false);
3366
3367 /* Attach the private data to this PCI device. */ 3830 /* Attach the private data to this PCI device. */
3368 pci_set_drvdata(pdev, dd); 3831 pci_set_drvdata(pdev, dd);
3369 3832
@@ -3420,7 +3883,8 @@ static int mtip_pci_probe(struct pci_dev *pdev,
3420 * instance number. 3883 * instance number.
3421 */ 3884 */
3422 instance++; 3885 instance++;
3423 3886 if (rv != MTIP_FTL_REBUILD_MAGIC)
3887 set_bit(MTIP_DDF_INIT_DONE_BIT, &dd->dd_flag);
3424 goto done; 3888 goto done;
3425 3889
3426block_initialize_err: 3890block_initialize_err:
@@ -3434,9 +3898,6 @@ iomap_err:
3434 pci_set_drvdata(pdev, NULL); 3898 pci_set_drvdata(pdev, NULL);
3435 return rv; 3899 return rv;
3436done: 3900done:
3437 /* Set the atomic variable as 0 in case of SRSI */
3438 atomic_set(&dd->drv_cleanup_done, true);
3439
3440 return rv; 3901 return rv;
3441} 3902}
3442 3903
@@ -3452,8 +3913,10 @@ static void mtip_pci_remove(struct pci_dev *pdev)
3452 struct driver_data *dd = pci_get_drvdata(pdev); 3913 struct driver_data *dd = pci_get_drvdata(pdev);
3453 int counter = 0; 3914 int counter = 0;
3454 3915
3916 set_bit(MTIP_DDF_REMOVE_PENDING_BIT, &dd->dd_flag);
3917
3455 if (mtip_check_surprise_removal(pdev)) { 3918 if (mtip_check_surprise_removal(pdev)) {
3456 while (atomic_read(&dd->drv_cleanup_done) == false) { 3919 while (!test_bit(MTIP_DDF_CLEANUP_BIT, &dd->dd_flag)) {
3457 counter++; 3920 counter++;
3458 msleep(20); 3921 msleep(20);
3459 if (counter == 10) { 3922 if (counter == 10) {
@@ -3463,8 +3926,6 @@ static void mtip_pci_remove(struct pci_dev *pdev)
3463 } 3926 }
3464 } 3927 }
3465 } 3928 }
3466 /* Set the atomic variable as 1 in case of SRSI */
3467 atomic_set(&dd->drv_cleanup_done, true);
3468 3929
3469 /* Clean up the block layer. */ 3930 /* Clean up the block layer. */
3470 mtip_block_remove(dd); 3931 mtip_block_remove(dd);
@@ -3493,7 +3954,7 @@ static int mtip_pci_suspend(struct pci_dev *pdev, pm_message_t mesg)
3493 return -EFAULT; 3954 return -EFAULT;
3494 } 3955 }
3495 3956
3496 atomic_set(&dd->resumeflag, true); 3957 set_bit(MTIP_DDF_RESUME_BIT, &dd->dd_flag);
3497 3958
3498 /* Disable ports & interrupts then send standby immediate */ 3959 /* Disable ports & interrupts then send standby immediate */
3499 rv = mtip_block_suspend(dd); 3960 rv = mtip_block_suspend(dd);
@@ -3559,7 +4020,7 @@ static int mtip_pci_resume(struct pci_dev *pdev)
3559 dev_err(&pdev->dev, "Unable to resume\n"); 4020 dev_err(&pdev->dev, "Unable to resume\n");
3560 4021
3561err: 4022err:
3562 atomic_set(&dd->resumeflag, false); 4023 clear_bit(MTIP_DDF_RESUME_BIT, &dd->dd_flag);
3563 4024
3564 return rv; 4025 return rv;
3565} 4026}
@@ -3608,18 +4069,25 @@ MODULE_DEVICE_TABLE(pci, mtip_pci_tbl);
3608 */ 4069 */
3609static int __init mtip_init(void) 4070static int __init mtip_init(void)
3610{ 4071{
4072 int error;
4073
3611 printk(KERN_INFO MTIP_DRV_NAME " Version " MTIP_DRV_VERSION "\n"); 4074 printk(KERN_INFO MTIP_DRV_NAME " Version " MTIP_DRV_VERSION "\n");
3612 4075
3613 /* Allocate a major block device number to use with this driver. */ 4076 /* Allocate a major block device number to use with this driver. */
3614 mtip_major = register_blkdev(0, MTIP_DRV_NAME); 4077 error = register_blkdev(0, MTIP_DRV_NAME);
3615 if (mtip_major < 0) { 4078 if (error <= 0) {
3616 printk(KERN_ERR "Unable to register block device (%d)\n", 4079 printk(KERN_ERR "Unable to register block device (%d)\n",
3617 mtip_major); 4080 error);
3618 return -EBUSY; 4081 return -EBUSY;
3619 } 4082 }
4083 mtip_major = error;
3620 4084
3621 /* Register our PCI operations. */ 4085 /* Register our PCI operations. */
3622 return pci_register_driver(&mtip_pci_driver); 4086 error = pci_register_driver(&mtip_pci_driver);
4087 if (error)
4088 unregister_blkdev(mtip_major, MTIP_DRV_NAME);
4089
4090 return error;
3623} 4091}
3624 4092
3625/* 4093/*
diff --git a/drivers/block/mtip32xx/mtip32xx.h b/drivers/block/mtip32xx/mtip32xx.h
index e0554a8f2233..4ef58336310a 100644
--- a/drivers/block/mtip32xx/mtip32xx.h
+++ b/drivers/block/mtip32xx/mtip32xx.h
@@ -34,8 +34,8 @@
34/* offset of Device Control register in PCIe extended capabilites space */ 34/* offset of Device Control register in PCIe extended capabilites space */
35#define PCIE_CONFIG_EXT_DEVICE_CONTROL_OFFSET 0x48 35#define PCIE_CONFIG_EXT_DEVICE_CONTROL_OFFSET 0x48
36 36
37/* # of times to retry timed out IOs */ 37/* # of times to retry timed out/failed IOs */
38#define MTIP_MAX_RETRIES 5 38#define MTIP_MAX_RETRIES 2
39 39
40/* Various timeout values in ms */ 40/* Various timeout values in ms */
41#define MTIP_NCQ_COMMAND_TIMEOUT_MS 5000 41#define MTIP_NCQ_COMMAND_TIMEOUT_MS 5000
@@ -114,12 +114,41 @@
114#define __force_bit2int (unsigned int __force) 114#define __force_bit2int (unsigned int __force)
115 115
116/* below are bit numbers in 'flags' defined in mtip_port */ 116/* below are bit numbers in 'flags' defined in mtip_port */
117#define MTIP_FLAG_IC_ACTIVE_BIT 0 117#define MTIP_PF_IC_ACTIVE_BIT 0 /* pio/ioctl */
118#define MTIP_FLAG_EH_ACTIVE_BIT 1 118#define MTIP_PF_EH_ACTIVE_BIT 1 /* error handling */
119#define MTIP_FLAG_SVC_THD_ACTIVE_BIT 2 119#define MTIP_PF_SE_ACTIVE_BIT 2 /* secure erase */
120#define MTIP_FLAG_ISSUE_CMDS_BIT 4 120#define MTIP_PF_DM_ACTIVE_BIT 3 /* download microcde */
121#define MTIP_FLAG_REBUILD_BIT 5 121#define MTIP_PF_PAUSE_IO ((1 << MTIP_PF_IC_ACTIVE_BIT) | \
122#define MTIP_FLAG_SVC_THD_SHOULD_STOP_BIT 8 122 (1 << MTIP_PF_EH_ACTIVE_BIT) | \
123 (1 << MTIP_PF_SE_ACTIVE_BIT) | \
124 (1 << MTIP_PF_DM_ACTIVE_BIT))
125
126#define MTIP_PF_SVC_THD_ACTIVE_BIT 4
127#define MTIP_PF_ISSUE_CMDS_BIT 5
128#define MTIP_PF_REBUILD_BIT 6
129#define MTIP_PF_SVC_THD_STOP_BIT 8
130
131/* below are bit numbers in 'dd_flag' defined in driver_data */
132#define MTIP_DDF_REMOVE_PENDING_BIT 1
133#define MTIP_DDF_OVER_TEMP_BIT 2
134#define MTIP_DDF_WRITE_PROTECT_BIT 3
135#define MTIP_DDF_STOP_IO ((1 << MTIP_DDF_REMOVE_PENDING_BIT) | \
136 (1 << MTIP_DDF_OVER_TEMP_BIT) | \
137 (1 << MTIP_DDF_WRITE_PROTECT_BIT))
138
139#define MTIP_DDF_CLEANUP_BIT 5
140#define MTIP_DDF_RESUME_BIT 6
141#define MTIP_DDF_INIT_DONE_BIT 7
142#define MTIP_DDF_REBUILD_FAILED_BIT 8
143
144__packed struct smart_attr{
145 u8 attr_id;
146 u16 flags;
147 u8 cur;
148 u8 worst;
149 u32 data;
150 u8 res[3];
151};
123 152
124/* Register Frame Information Structure (FIS), host to device. */ 153/* Register Frame Information Structure (FIS), host to device. */
125struct host_to_dev_fis { 154struct host_to_dev_fis {
@@ -345,6 +374,12 @@ struct mtip_port {
345 * when the command slot and all associated data structures 374 * when the command slot and all associated data structures
346 * are no longer needed. 375 * are no longer needed.
347 */ 376 */
377 u16 *log_buf;
378 dma_addr_t log_buf_dma;
379
380 u8 *smart_buf;
381 dma_addr_t smart_buf_dma;
382
348 unsigned long allocated[SLOTBITS_IN_LONGS]; 383 unsigned long allocated[SLOTBITS_IN_LONGS];
349 /* 384 /*
350 * used to queue commands when an internal command is in progress 385 * used to queue commands when an internal command is in progress
@@ -368,6 +403,7 @@ struct mtip_port {
368 * Timer used to complete commands that have been active for too long. 403 * Timer used to complete commands that have been active for too long.
369 */ 404 */
370 struct timer_list cmd_timer; 405 struct timer_list cmd_timer;
406 unsigned long ic_pause_timer;
371 /* 407 /*
372 * Semaphore used to block threads if there are no 408 * Semaphore used to block threads if there are no
373 * command slots available. 409 * command slots available.
@@ -404,13 +440,9 @@ struct driver_data {
404 440
405 unsigned slot_groups; /* number of slot groups the product supports */ 441 unsigned slot_groups; /* number of slot groups the product supports */
406 442
407 atomic_t drv_cleanup_done; /* Atomic variable for SRSI */
408
409 unsigned long index; /* Index to determine the disk name */ 443 unsigned long index; /* Index to determine the disk name */
410 444
411 unsigned int ftlrebuildflag; /* FTL rebuild flag */ 445 unsigned long dd_flag; /* NOTE: use atomic bit operations on this */
412
413 atomic_t resumeflag; /* Atomic variable to track suspend/resume */
414 446
415 struct task_struct *mtip_svc_handler; /* task_struct of svc thd */ 447 struct task_struct *mtip_svc_handler; /* task_struct of svc thd */
416}; 448};
diff --git a/drivers/block/virtio_blk.c b/drivers/block/virtio_blk.c
index c4a60badf252..0d39f2f4294a 100644
--- a/drivers/block/virtio_blk.c
+++ b/drivers/block/virtio_blk.c
@@ -351,6 +351,7 @@ static void virtblk_config_changed_work(struct work_struct *work)
351 cap_str_10, cap_str_2); 351 cap_str_10, cap_str_2);
352 352
353 set_capacity(vblk->disk, capacity); 353 set_capacity(vblk->disk, capacity);
354 revalidate_disk(vblk->disk);
354done: 355done:
355 mutex_unlock(&vblk->config_lock); 356 mutex_unlock(&vblk->config_lock);
356} 357}
@@ -374,6 +375,34 @@ static int init_vq(struct virtio_blk *vblk)
374 return err; 375 return err;
375} 376}
376 377
378/*
379 * Legacy naming scheme used for virtio devices. We are stuck with it for
380 * virtio blk but don't ever use it for any new driver.
381 */
382static int virtblk_name_format(char *prefix, int index, char *buf, int buflen)
383{
384 const int base = 'z' - 'a' + 1;
385 char *begin = buf + strlen(prefix);
386 char *end = buf + buflen;
387 char *p;
388 int unit;
389
390 p = end - 1;
391 *p = '\0';
392 unit = base;
393 do {
394 if (p == begin)
395 return -EINVAL;
396 *--p = 'a' + (index % unit);
397 index = (index / unit) - 1;
398 } while (index >= 0);
399
400 memmove(begin, p, end - p);
401 memcpy(buf, prefix, strlen(prefix));
402
403 return 0;
404}
405
377static int __devinit virtblk_probe(struct virtio_device *vdev) 406static int __devinit virtblk_probe(struct virtio_device *vdev)
378{ 407{
379 struct virtio_blk *vblk; 408 struct virtio_blk *vblk;
@@ -442,18 +471,7 @@ static int __devinit virtblk_probe(struct virtio_device *vdev)
442 471
443 q->queuedata = vblk; 472 q->queuedata = vblk;
444 473
445 if (index < 26) { 474 virtblk_name_format("vd", index, vblk->disk->disk_name, DISK_NAME_LEN);
446 sprintf(vblk->disk->disk_name, "vd%c", 'a' + index % 26);
447 } else if (index < (26 + 1) * 26) {
448 sprintf(vblk->disk->disk_name, "vd%c%c",
449 'a' + index / 26 - 1, 'a' + index % 26);
450 } else {
451 const unsigned int m1 = (index / 26 - 1) / 26 - 1;
452 const unsigned int m2 = (index / 26 - 1) % 26;
453 const unsigned int m3 = index % 26;
454 sprintf(vblk->disk->disk_name, "vd%c%c%c",
455 'a' + m1, 'a' + m2, 'a' + m3);
456 }
457 475
458 vblk->disk->major = major; 476 vblk->disk->major = major;
459 vblk->disk->first_minor = index_to_minor(index); 477 vblk->disk->first_minor = index_to_minor(index);
diff --git a/drivers/block/xen-blkback/blkback.c b/drivers/block/xen-blkback/blkback.c
index 0088bf60f368..73f196ca713f 100644
--- a/drivers/block/xen-blkback/blkback.c
+++ b/drivers/block/xen-blkback/blkback.c
@@ -321,6 +321,7 @@ struct seg_buf {
321static void xen_blkbk_unmap(struct pending_req *req) 321static void xen_blkbk_unmap(struct pending_req *req)
322{ 322{
323 struct gnttab_unmap_grant_ref unmap[BLKIF_MAX_SEGMENTS_PER_REQUEST]; 323 struct gnttab_unmap_grant_ref unmap[BLKIF_MAX_SEGMENTS_PER_REQUEST];
324 struct page *pages[BLKIF_MAX_SEGMENTS_PER_REQUEST];
324 unsigned int i, invcount = 0; 325 unsigned int i, invcount = 0;
325 grant_handle_t handle; 326 grant_handle_t handle;
326 int ret; 327 int ret;
@@ -332,25 +333,12 @@ static void xen_blkbk_unmap(struct pending_req *req)
332 gnttab_set_unmap_op(&unmap[invcount], vaddr(req, i), 333 gnttab_set_unmap_op(&unmap[invcount], vaddr(req, i),
333 GNTMAP_host_map, handle); 334 GNTMAP_host_map, handle);
334 pending_handle(req, i) = BLKBACK_INVALID_HANDLE; 335 pending_handle(req, i) = BLKBACK_INVALID_HANDLE;
336 pages[invcount] = virt_to_page(vaddr(req, i));
335 invcount++; 337 invcount++;
336 } 338 }
337 339
338 ret = HYPERVISOR_grant_table_op( 340 ret = gnttab_unmap_refs(unmap, pages, invcount, false);
339 GNTTABOP_unmap_grant_ref, unmap, invcount);
340 BUG_ON(ret); 341 BUG_ON(ret);
341 /*
342 * Note, we use invcount, so nr->pages, so we can't index
343 * using vaddr(req, i).
344 */
345 for (i = 0; i < invcount; i++) {
346 ret = m2p_remove_override(
347 virt_to_page(unmap[i].host_addr), false);
348 if (ret) {
349 pr_alert(DRV_PFX "Failed to remove M2P override for %lx\n",
350 (unsigned long)unmap[i].host_addr);
351 continue;
352 }
353 }
354} 342}
355 343
356static int xen_blkbk_map(struct blkif_request *req, 344static int xen_blkbk_map(struct blkif_request *req,
@@ -378,7 +366,7 @@ static int xen_blkbk_map(struct blkif_request *req,
378 pending_req->blkif->domid); 366 pending_req->blkif->domid);
379 } 367 }
380 368
381 ret = HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref, map, nseg); 369 ret = gnttab_map_refs(map, NULL, &blkbk->pending_page(pending_req, 0), nseg);
382 BUG_ON(ret); 370 BUG_ON(ret);
383 371
384 /* 372 /*
@@ -398,15 +386,6 @@ static int xen_blkbk_map(struct blkif_request *req,
398 if (ret) 386 if (ret)
399 continue; 387 continue;
400 388
401 ret = m2p_add_override(PFN_DOWN(map[i].dev_bus_addr),
402 blkbk->pending_page(pending_req, i), NULL);
403 if (ret) {
404 pr_alert(DRV_PFX "Failed to install M2P override for %lx (ret: %d)\n",
405 (unsigned long)map[i].dev_bus_addr, ret);
406 /* We could switch over to GNTTABOP_copy */
407 continue;
408 }
409
410 seg[i].buf = map[i].dev_bus_addr | 389 seg[i].buf = map[i].dev_bus_addr |
411 (req->u.rw.seg[i].first_sect << 9); 390 (req->u.rw.seg[i].first_sect << 9);
412 } 391 }
@@ -419,21 +398,18 @@ static int dispatch_discard_io(struct xen_blkif *blkif,
419 int err = 0; 398 int err = 0;
420 int status = BLKIF_RSP_OKAY; 399 int status = BLKIF_RSP_OKAY;
421 struct block_device *bdev = blkif->vbd.bdev; 400 struct block_device *bdev = blkif->vbd.bdev;
401 unsigned long secure;
422 402
423 blkif->st_ds_req++; 403 blkif->st_ds_req++;
424 404
425 xen_blkif_get(blkif); 405 xen_blkif_get(blkif);
426 if (blkif->blk_backend_type == BLKIF_BACKEND_PHY || 406 secure = (blkif->vbd.discard_secure &&
427 blkif->blk_backend_type == BLKIF_BACKEND_FILE) { 407 (req->u.discard.flag & BLKIF_DISCARD_SECURE)) ?
428 unsigned long secure = (blkif->vbd.discard_secure && 408 BLKDEV_DISCARD_SECURE : 0;
429 (req->u.discard.flag & BLKIF_DISCARD_SECURE)) ? 409
430 BLKDEV_DISCARD_SECURE : 0; 410 err = blkdev_issue_discard(bdev, req->u.discard.sector_number,
431 err = blkdev_issue_discard(bdev, 411 req->u.discard.nr_sectors,
432 req->u.discard.sector_number, 412 GFP_KERNEL, secure);
433 req->u.discard.nr_sectors,
434 GFP_KERNEL, secure);
435 } else
436 err = -EOPNOTSUPP;
437 413
438 if (err == -EOPNOTSUPP) { 414 if (err == -EOPNOTSUPP) {
439 pr_debug(DRV_PFX "discard op failed, not supported\n"); 415 pr_debug(DRV_PFX "discard op failed, not supported\n");
@@ -830,7 +806,7 @@ static int __init xen_blkif_init(void)
830 int i, mmap_pages; 806 int i, mmap_pages;
831 int rc = 0; 807 int rc = 0;
832 808
833 if (!xen_pv_domain()) 809 if (!xen_domain())
834 return -ENODEV; 810 return -ENODEV;
835 811
836 blkbk = kzalloc(sizeof(struct xen_blkbk), GFP_KERNEL); 812 blkbk = kzalloc(sizeof(struct xen_blkbk), GFP_KERNEL);
diff --git a/drivers/block/xen-blkback/common.h b/drivers/block/xen-blkback/common.h
index d0ee7edc9be8..773cf27dc23f 100644
--- a/drivers/block/xen-blkback/common.h
+++ b/drivers/block/xen-blkback/common.h
@@ -146,11 +146,6 @@ enum blkif_protocol {
146 BLKIF_PROTOCOL_X86_64 = 3, 146 BLKIF_PROTOCOL_X86_64 = 3,
147}; 147};
148 148
149enum blkif_backend_type {
150 BLKIF_BACKEND_PHY = 1,
151 BLKIF_BACKEND_FILE = 2,
152};
153
154struct xen_vbd { 149struct xen_vbd {
155 /* What the domain refers to this vbd as. */ 150 /* What the domain refers to this vbd as. */
156 blkif_vdev_t handle; 151 blkif_vdev_t handle;
@@ -177,7 +172,6 @@ struct xen_blkif {
177 unsigned int irq; 172 unsigned int irq;
178 /* Comms information. */ 173 /* Comms information. */
179 enum blkif_protocol blk_protocol; 174 enum blkif_protocol blk_protocol;
180 enum blkif_backend_type blk_backend_type;
181 union blkif_back_rings blk_rings; 175 union blkif_back_rings blk_rings;
182 void *blk_ring; 176 void *blk_ring;
183 /* The VBD attached to this interface. */ 177 /* The VBD attached to this interface. */
diff --git a/drivers/block/xen-blkback/xenbus.c b/drivers/block/xen-blkback/xenbus.c
index 24a2fb57e5d0..4f66171c6683 100644
--- a/drivers/block/xen-blkback/xenbus.c
+++ b/drivers/block/xen-blkback/xenbus.c
@@ -381,72 +381,49 @@ int xen_blkbk_flush_diskcache(struct xenbus_transaction xbt,
381 err = xenbus_printf(xbt, dev->nodename, "feature-flush-cache", 381 err = xenbus_printf(xbt, dev->nodename, "feature-flush-cache",
382 "%d", state); 382 "%d", state);
383 if (err) 383 if (err)
384 xenbus_dev_fatal(dev, err, "writing feature-flush-cache"); 384 dev_warn(&dev->dev, "writing feature-flush-cache (%d)", err);
385 385
386 return err; 386 return err;
387} 387}
388 388
389int xen_blkbk_discard(struct xenbus_transaction xbt, struct backend_info *be) 389static void xen_blkbk_discard(struct xenbus_transaction xbt, struct backend_info *be)
390{ 390{
391 struct xenbus_device *dev = be->dev; 391 struct xenbus_device *dev = be->dev;
392 struct xen_blkif *blkif = be->blkif; 392 struct xen_blkif *blkif = be->blkif;
393 char *type;
394 int err; 393 int err;
395 int state = 0; 394 int state = 0;
395 struct block_device *bdev = be->blkif->vbd.bdev;
396 struct request_queue *q = bdev_get_queue(bdev);
396 397
397 type = xenbus_read(XBT_NIL, dev->nodename, "type", NULL); 398 if (blk_queue_discard(q)) {
398 if (!IS_ERR(type)) { 399 err = xenbus_printf(xbt, dev->nodename,
399 if (strncmp(type, "file", 4) == 0) { 400 "discard-granularity", "%u",
400 state = 1; 401 q->limits.discard_granularity);
401 blkif->blk_backend_type = BLKIF_BACKEND_FILE; 402 if (err) {
403 dev_warn(&dev->dev, "writing discard-granularity (%d)", err);
404 return;
402 } 405 }
403 if (strncmp(type, "phy", 3) == 0) { 406 err = xenbus_printf(xbt, dev->nodename,
404 struct block_device *bdev = be->blkif->vbd.bdev; 407 "discard-alignment", "%u",
405 struct request_queue *q = bdev_get_queue(bdev); 408 q->limits.discard_alignment);
406 if (blk_queue_discard(q)) { 409 if (err) {
407 err = xenbus_printf(xbt, dev->nodename, 410 dev_warn(&dev->dev, "writing discard-alignment (%d)", err);
408 "discard-granularity", "%u", 411 return;
409 q->limits.discard_granularity); 412 }
410 if (err) { 413 state = 1;
411 xenbus_dev_fatal(dev, err, 414 /* Optional. */
412 "writing discard-granularity"); 415 err = xenbus_printf(xbt, dev->nodename,
413 goto kfree; 416 "discard-secure", "%d",
414 } 417 blkif->vbd.discard_secure);
415 err = xenbus_printf(xbt, dev->nodename, 418 if (err) {
416 "discard-alignment", "%u", 419 dev_warn(&dev->dev, "writing discard-secure (%d)", err);
417 q->limits.discard_alignment); 420 return;
418 if (err) {
419 xenbus_dev_fatal(dev, err,
420 "writing discard-alignment");
421 goto kfree;
422 }
423 state = 1;
424 blkif->blk_backend_type = BLKIF_BACKEND_PHY;
425 }
426 /* Optional. */
427 err = xenbus_printf(xbt, dev->nodename,
428 "discard-secure", "%d",
429 blkif->vbd.discard_secure);
430 if (err) {
431 xenbus_dev_fatal(dev, err,
432 "writting discard-secure");
433 goto kfree;
434 }
435 } 421 }
436 } else {
437 err = PTR_ERR(type);
438 xenbus_dev_fatal(dev, err, "reading type");
439 goto out;
440 } 422 }
441
442 err = xenbus_printf(xbt, dev->nodename, "feature-discard", 423 err = xenbus_printf(xbt, dev->nodename, "feature-discard",
443 "%d", state); 424 "%d", state);
444 if (err) 425 if (err)
445 xenbus_dev_fatal(dev, err, "writing feature-discard"); 426 dev_warn(&dev->dev, "writing feature-discard (%d)", err);
446kfree:
447 kfree(type);
448out:
449 return err;
450} 427}
451int xen_blkbk_barrier(struct xenbus_transaction xbt, 428int xen_blkbk_barrier(struct xenbus_transaction xbt,
452 struct backend_info *be, int state) 429 struct backend_info *be, int state)
@@ -457,7 +434,7 @@ int xen_blkbk_barrier(struct xenbus_transaction xbt,
457 err = xenbus_printf(xbt, dev->nodename, "feature-barrier", 434 err = xenbus_printf(xbt, dev->nodename, "feature-barrier",
458 "%d", state); 435 "%d", state);
459 if (err) 436 if (err)
460 xenbus_dev_fatal(dev, err, "writing feature-barrier"); 437 dev_warn(&dev->dev, "writing feature-barrier (%d)", err);
461 438
462 return err; 439 return err;
463} 440}
@@ -689,14 +666,12 @@ again:
689 return; 666 return;
690 } 667 }
691 668
692 err = xen_blkbk_flush_diskcache(xbt, be, be->blkif->vbd.flush_support); 669 /* If we can't advertise it is OK. */
693 if (err) 670 xen_blkbk_flush_diskcache(xbt, be, be->blkif->vbd.flush_support);
694 goto abort;
695 671
696 err = xen_blkbk_discard(xbt, be); 672 xen_blkbk_discard(xbt, be);
697 673
698 /* If we can't advertise it is OK. */ 674 xen_blkbk_barrier(xbt, be, be->blkif->vbd.flush_support);
699 err = xen_blkbk_barrier(xbt, be, be->blkif->vbd.flush_support);
700 675
701 err = xenbus_printf(xbt, dev->nodename, "sectors", "%llu", 676 err = xenbus_printf(xbt, dev->nodename, "sectors", "%llu",
702 (unsigned long long)vbd_sz(&be->blkif->vbd)); 677 (unsigned long long)vbd_sz(&be->blkif->vbd));
diff --git a/drivers/block/xen-blkfront.c b/drivers/block/xen-blkfront.c
index 98cbeba8cd53..4e86393a09cf 100644
--- a/drivers/block/xen-blkfront.c
+++ b/drivers/block/xen-blkfront.c
@@ -43,6 +43,7 @@
43#include <linux/slab.h> 43#include <linux/slab.h>
44#include <linux/mutex.h> 44#include <linux/mutex.h>
45#include <linux/scatterlist.h> 45#include <linux/scatterlist.h>
46#include <linux/bitmap.h>
46 47
47#include <xen/xen.h> 48#include <xen/xen.h>
48#include <xen/xenbus.h> 49#include <xen/xenbus.h>
@@ -81,6 +82,7 @@ static const struct block_device_operations xlvbd_block_fops;
81 */ 82 */
82struct blkfront_info 83struct blkfront_info
83{ 84{
85 spinlock_t io_lock;
84 struct mutex mutex; 86 struct mutex mutex;
85 struct xenbus_device *xbdev; 87 struct xenbus_device *xbdev;
86 struct gendisk *gd; 88 struct gendisk *gd;
@@ -105,8 +107,6 @@ struct blkfront_info
105 int is_ready; 107 int is_ready;
106}; 108};
107 109
108static DEFINE_SPINLOCK(blkif_io_lock);
109
110static unsigned int nr_minors; 110static unsigned int nr_minors;
111static unsigned long *minors; 111static unsigned long *minors;
112static DEFINE_SPINLOCK(minor_lock); 112static DEFINE_SPINLOCK(minor_lock);
@@ -177,8 +177,7 @@ static int xlbd_reserve_minors(unsigned int minor, unsigned int nr)
177 177
178 spin_lock(&minor_lock); 178 spin_lock(&minor_lock);
179 if (find_next_bit(minors, end, minor) >= end) { 179 if (find_next_bit(minors, end, minor) >= end) {
180 for (; minor < end; ++minor) 180 bitmap_set(minors, minor, nr);
181 __set_bit(minor, minors);
182 rc = 0; 181 rc = 0;
183 } else 182 } else
184 rc = -EBUSY; 183 rc = -EBUSY;
@@ -193,8 +192,7 @@ static void xlbd_release_minors(unsigned int minor, unsigned int nr)
193 192
194 BUG_ON(end > nr_minors); 193 BUG_ON(end > nr_minors);
195 spin_lock(&minor_lock); 194 spin_lock(&minor_lock);
196 for (; minor < end; ++minor) 195 bitmap_clear(minors, minor, nr);
197 __clear_bit(minor, minors);
198 spin_unlock(&minor_lock); 196 spin_unlock(&minor_lock);
199} 197}
200 198
@@ -419,7 +417,7 @@ static int xlvbd_init_blk_queue(struct gendisk *gd, u16 sector_size)
419 struct request_queue *rq; 417 struct request_queue *rq;
420 struct blkfront_info *info = gd->private_data; 418 struct blkfront_info *info = gd->private_data;
421 419
422 rq = blk_init_queue(do_blkif_request, &blkif_io_lock); 420 rq = blk_init_queue(do_blkif_request, &info->io_lock);
423 if (rq == NULL) 421 if (rq == NULL)
424 return -1; 422 return -1;
425 423
@@ -636,14 +634,14 @@ static void xlvbd_release_gendisk(struct blkfront_info *info)
636 if (info->rq == NULL) 634 if (info->rq == NULL)
637 return; 635 return;
638 636
639 spin_lock_irqsave(&blkif_io_lock, flags); 637 spin_lock_irqsave(&info->io_lock, flags);
640 638
641 /* No more blkif_request(). */ 639 /* No more blkif_request(). */
642 blk_stop_queue(info->rq); 640 blk_stop_queue(info->rq);
643 641
644 /* No more gnttab callback work. */ 642 /* No more gnttab callback work. */
645 gnttab_cancel_free_callback(&info->callback); 643 gnttab_cancel_free_callback(&info->callback);
646 spin_unlock_irqrestore(&blkif_io_lock, flags); 644 spin_unlock_irqrestore(&info->io_lock, flags);
647 645
648 /* Flush gnttab callback work. Must be done with no locks held. */ 646 /* Flush gnttab callback work. Must be done with no locks held. */
649 flush_work_sync(&info->work); 647 flush_work_sync(&info->work);
@@ -675,16 +673,16 @@ static void blkif_restart_queue(struct work_struct *work)
675{ 673{
676 struct blkfront_info *info = container_of(work, struct blkfront_info, work); 674 struct blkfront_info *info = container_of(work, struct blkfront_info, work);
677 675
678 spin_lock_irq(&blkif_io_lock); 676 spin_lock_irq(&info->io_lock);
679 if (info->connected == BLKIF_STATE_CONNECTED) 677 if (info->connected == BLKIF_STATE_CONNECTED)
680 kick_pending_request_queues(info); 678 kick_pending_request_queues(info);
681 spin_unlock_irq(&blkif_io_lock); 679 spin_unlock_irq(&info->io_lock);
682} 680}
683 681
684static void blkif_free(struct blkfront_info *info, int suspend) 682static void blkif_free(struct blkfront_info *info, int suspend)
685{ 683{
686 /* Prevent new requests being issued until we fix things up. */ 684 /* Prevent new requests being issued until we fix things up. */
687 spin_lock_irq(&blkif_io_lock); 685 spin_lock_irq(&info->io_lock);
688 info->connected = suspend ? 686 info->connected = suspend ?
689 BLKIF_STATE_SUSPENDED : BLKIF_STATE_DISCONNECTED; 687 BLKIF_STATE_SUSPENDED : BLKIF_STATE_DISCONNECTED;
690 /* No more blkif_request(). */ 688 /* No more blkif_request(). */
@@ -692,7 +690,7 @@ static void blkif_free(struct blkfront_info *info, int suspend)
692 blk_stop_queue(info->rq); 690 blk_stop_queue(info->rq);
693 /* No more gnttab callback work. */ 691 /* No more gnttab callback work. */
694 gnttab_cancel_free_callback(&info->callback); 692 gnttab_cancel_free_callback(&info->callback);
695 spin_unlock_irq(&blkif_io_lock); 693 spin_unlock_irq(&info->io_lock);
696 694
697 /* Flush gnttab callback work. Must be done with no locks held. */ 695 /* Flush gnttab callback work. Must be done with no locks held. */
698 flush_work_sync(&info->work); 696 flush_work_sync(&info->work);
@@ -728,10 +726,10 @@ static irqreturn_t blkif_interrupt(int irq, void *dev_id)
728 struct blkfront_info *info = (struct blkfront_info *)dev_id; 726 struct blkfront_info *info = (struct blkfront_info *)dev_id;
729 int error; 727 int error;
730 728
731 spin_lock_irqsave(&blkif_io_lock, flags); 729 spin_lock_irqsave(&info->io_lock, flags);
732 730
733 if (unlikely(info->connected != BLKIF_STATE_CONNECTED)) { 731 if (unlikely(info->connected != BLKIF_STATE_CONNECTED)) {
734 spin_unlock_irqrestore(&blkif_io_lock, flags); 732 spin_unlock_irqrestore(&info->io_lock, flags);
735 return IRQ_HANDLED; 733 return IRQ_HANDLED;
736 } 734 }
737 735
@@ -816,7 +814,7 @@ static irqreturn_t blkif_interrupt(int irq, void *dev_id)
816 814
817 kick_pending_request_queues(info); 815 kick_pending_request_queues(info);
818 816
819 spin_unlock_irqrestore(&blkif_io_lock, flags); 817 spin_unlock_irqrestore(&info->io_lock, flags);
820 818
821 return IRQ_HANDLED; 819 return IRQ_HANDLED;
822} 820}
@@ -991,6 +989,7 @@ static int blkfront_probe(struct xenbus_device *dev,
991 } 989 }
992 990
993 mutex_init(&info->mutex); 991 mutex_init(&info->mutex);
992 spin_lock_init(&info->io_lock);
994 info->xbdev = dev; 993 info->xbdev = dev;
995 info->vdevice = vdevice; 994 info->vdevice = vdevice;
996 info->connected = BLKIF_STATE_DISCONNECTED; 995 info->connected = BLKIF_STATE_DISCONNECTED;
@@ -1068,7 +1067,7 @@ static int blkif_recover(struct blkfront_info *info)
1068 1067
1069 xenbus_switch_state(info->xbdev, XenbusStateConnected); 1068 xenbus_switch_state(info->xbdev, XenbusStateConnected);
1070 1069
1071 spin_lock_irq(&blkif_io_lock); 1070 spin_lock_irq(&info->io_lock);
1072 1071
1073 /* Now safe for us to use the shared ring */ 1072 /* Now safe for us to use the shared ring */
1074 info->connected = BLKIF_STATE_CONNECTED; 1073 info->connected = BLKIF_STATE_CONNECTED;
@@ -1079,7 +1078,7 @@ static int blkif_recover(struct blkfront_info *info)
1079 /* Kick any other new requests queued since we resumed */ 1078 /* Kick any other new requests queued since we resumed */
1080 kick_pending_request_queues(info); 1079 kick_pending_request_queues(info);
1081 1080
1082 spin_unlock_irq(&blkif_io_lock); 1081 spin_unlock_irq(&info->io_lock);
1083 1082
1084 return 0; 1083 return 0;
1085} 1084}
@@ -1277,10 +1276,10 @@ static void blkfront_connect(struct blkfront_info *info)
1277 xenbus_switch_state(info->xbdev, XenbusStateConnected); 1276 xenbus_switch_state(info->xbdev, XenbusStateConnected);
1278 1277
1279 /* Kick pending requests. */ 1278 /* Kick pending requests. */
1280 spin_lock_irq(&blkif_io_lock); 1279 spin_lock_irq(&info->io_lock);
1281 info->connected = BLKIF_STATE_CONNECTED; 1280 info->connected = BLKIF_STATE_CONNECTED;
1282 kick_pending_request_queues(info); 1281 kick_pending_request_queues(info);
1283 spin_unlock_irq(&blkif_io_lock); 1282 spin_unlock_irq(&info->io_lock);
1284 1283
1285 add_disk(info->gd); 1284 add_disk(info->gd);
1286 1285
@@ -1410,7 +1409,6 @@ static int blkif_release(struct gendisk *disk, fmode_t mode)
1410 mutex_lock(&blkfront_mutex); 1409 mutex_lock(&blkfront_mutex);
1411 1410
1412 bdev = bdget_disk(disk, 0); 1411 bdev = bdget_disk(disk, 0);
1413 bdput(bdev);
1414 1412
1415 if (bdev->bd_openers) 1413 if (bdev->bd_openers)
1416 goto out; 1414 goto out;
@@ -1441,6 +1439,7 @@ static int blkif_release(struct gendisk *disk, fmode_t mode)
1441 } 1439 }
1442 1440
1443out: 1441out:
1442 bdput(bdev);
1444 mutex_unlock(&blkfront_mutex); 1443 mutex_unlock(&blkfront_mutex);
1445 return 0; 1444 return 0;
1446} 1445}
diff --git a/drivers/bluetooth/ath3k.c b/drivers/bluetooth/ath3k.c
index 48442476ec00..ae9edca7b56d 100644
--- a/drivers/bluetooth/ath3k.c
+++ b/drivers/bluetooth/ath3k.c
@@ -72,7 +72,9 @@ static struct usb_device_id ath3k_table[] = {
72 72
73 /* Atheros AR3012 with sflash firmware*/ 73 /* Atheros AR3012 with sflash firmware*/
74 { USB_DEVICE(0x0CF3, 0x3004) }, 74 { USB_DEVICE(0x0CF3, 0x3004) },
75 { USB_DEVICE(0x0CF3, 0x311D) },
75 { USB_DEVICE(0x13d3, 0x3375) }, 76 { USB_DEVICE(0x13d3, 0x3375) },
77 { USB_DEVICE(0x04CA, 0x3005) },
76 78
77 /* Atheros AR5BBU12 with sflash firmware */ 79 /* Atheros AR5BBU12 with sflash firmware */
78 { USB_DEVICE(0x0489, 0xE02C) }, 80 { USB_DEVICE(0x0489, 0xE02C) },
@@ -89,7 +91,9 @@ static struct usb_device_id ath3k_blist_tbl[] = {
89 91
90 /* Atheros AR3012 with sflash firmware*/ 92 /* Atheros AR3012 with sflash firmware*/
91 { USB_DEVICE(0x0cf3, 0x3004), .driver_info = BTUSB_ATH3012 }, 93 { USB_DEVICE(0x0cf3, 0x3004), .driver_info = BTUSB_ATH3012 },
94 { USB_DEVICE(0x0cf3, 0x311D), .driver_info = BTUSB_ATH3012 },
92 { USB_DEVICE(0x13d3, 0x3375), .driver_info = BTUSB_ATH3012 }, 95 { USB_DEVICE(0x13d3, 0x3375), .driver_info = BTUSB_ATH3012 },
96 { USB_DEVICE(0x04ca, 0x3005), .driver_info = BTUSB_ATH3012 },
93 97
94 { } /* Terminating entry */ 98 { } /* Terminating entry */
95}; 99};
diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
index 480cad920048..3311b812a0c6 100644
--- a/drivers/bluetooth/btusb.c
+++ b/drivers/bluetooth/btusb.c
@@ -61,7 +61,7 @@ static struct usb_device_id btusb_table[] = {
61 { USB_DEVICE_INFO(0xe0, 0x01, 0x01) }, 61 { USB_DEVICE_INFO(0xe0, 0x01, 0x01) },
62 62
63 /* Broadcom SoftSailing reporting vendor specific */ 63 /* Broadcom SoftSailing reporting vendor specific */
64 { USB_DEVICE(0x05ac, 0x21e1) }, 64 { USB_DEVICE(0x0a5c, 0x21e1) },
65 65
66 /* Apple MacBookPro 7,1 */ 66 /* Apple MacBookPro 7,1 */
67 { USB_DEVICE(0x05ac, 0x8213) }, 67 { USB_DEVICE(0x05ac, 0x8213) },
@@ -103,6 +103,7 @@ static struct usb_device_id btusb_table[] = {
103 /* Broadcom BCM20702A0 */ 103 /* Broadcom BCM20702A0 */
104 { USB_DEVICE(0x0a5c, 0x21e3) }, 104 { USB_DEVICE(0x0a5c, 0x21e3) },
105 { USB_DEVICE(0x0a5c, 0x21e6) }, 105 { USB_DEVICE(0x0a5c, 0x21e6) },
106 { USB_DEVICE(0x0a5c, 0x21e8) },
106 { USB_DEVICE(0x0a5c, 0x21f3) }, 107 { USB_DEVICE(0x0a5c, 0x21f3) },
107 { USB_DEVICE(0x413c, 0x8197) }, 108 { USB_DEVICE(0x413c, 0x8197) },
108 109
@@ -129,7 +130,9 @@ static struct usb_device_id blacklist_table[] = {
129 130
130 /* Atheros 3012 with sflash firmware */ 131 /* Atheros 3012 with sflash firmware */
131 { USB_DEVICE(0x0cf3, 0x3004), .driver_info = BTUSB_ATH3012 }, 132 { USB_DEVICE(0x0cf3, 0x3004), .driver_info = BTUSB_ATH3012 },
133 { USB_DEVICE(0x0cf3, 0x311d), .driver_info = BTUSB_ATH3012 },
132 { USB_DEVICE(0x13d3, 0x3375), .driver_info = BTUSB_ATH3012 }, 134 { USB_DEVICE(0x13d3, 0x3375), .driver_info = BTUSB_ATH3012 },
135 { USB_DEVICE(0x04ca, 0x3005), .driver_info = BTUSB_ATH3012 },
133 136
134 /* Atheros AR5BBU12 with sflash firmware */ 137 /* Atheros AR5BBU12 with sflash firmware */
135 { USB_DEVICE(0x0489, 0xe02c), .driver_info = BTUSB_IGNORE }, 138 { USB_DEVICE(0x0489, 0xe02c), .driver_info = BTUSB_IGNORE },
diff --git a/drivers/bluetooth/hci_ldisc.c b/drivers/bluetooth/hci_ldisc.c
index fd5adb408f44..98a8c05d4f23 100644
--- a/drivers/bluetooth/hci_ldisc.c
+++ b/drivers/bluetooth/hci_ldisc.c
@@ -299,11 +299,11 @@ static void hci_uart_tty_close(struct tty_struct *tty)
299 hci_uart_close(hdev); 299 hci_uart_close(hdev);
300 300
301 if (test_and_clear_bit(HCI_UART_PROTO_SET, &hu->flags)) { 301 if (test_and_clear_bit(HCI_UART_PROTO_SET, &hu->flags)) {
302 hu->proto->close(hu);
303 if (hdev) { 302 if (hdev) {
304 hci_unregister_dev(hdev); 303 hci_unregister_dev(hdev);
305 hci_free_dev(hdev); 304 hci_free_dev(hdev);
306 } 305 }
306 hu->proto->close(hu);
307 } 307 }
308 308
309 kfree(hu); 309 kfree(hu);
diff --git a/drivers/char/hpet.c b/drivers/char/hpet.c
index 3845ab44c330..dfd7876f127c 100644
--- a/drivers/char/hpet.c
+++ b/drivers/char/hpet.c
@@ -906,8 +906,8 @@ int hpet_alloc(struct hpet_data *hdp)
906 hpetp->hp_which, hdp->hd_phys_address, 906 hpetp->hp_which, hdp->hd_phys_address,
907 hpetp->hp_ntimer > 1 ? "s" : ""); 907 hpetp->hp_ntimer > 1 ? "s" : "");
908 for (i = 0; i < hpetp->hp_ntimer; i++) 908 for (i = 0; i < hpetp->hp_ntimer; i++)
909 printk("%s %d", i > 0 ? "," : "", hdp->hd_irq[i]); 909 printk(KERN_CONT "%s %d", i > 0 ? "," : "", hdp->hd_irq[i]);
910 printk("\n"); 910 printk(KERN_CONT "\n");
911 911
912 temp = hpetp->hp_tick_freq; 912 temp = hpetp->hp_tick_freq;
913 remainder = do_div(temp, 1000000); 913 remainder = do_div(temp, 1000000);
diff --git a/drivers/char/random.c b/drivers/char/random.c
index 54ca8b23cde3..4ec04a754733 100644
--- a/drivers/char/random.c
+++ b/drivers/char/random.c
@@ -1260,10 +1260,15 @@ static int proc_do_uuid(ctl_table *table, int write,
1260 uuid = table->data; 1260 uuid = table->data;
1261 if (!uuid) { 1261 if (!uuid) {
1262 uuid = tmp_uuid; 1262 uuid = tmp_uuid;
1263 uuid[8] = 0;
1264 }
1265 if (uuid[8] == 0)
1266 generate_random_uuid(uuid); 1263 generate_random_uuid(uuid);
1264 } else {
1265 static DEFINE_SPINLOCK(bootid_spinlock);
1266
1267 spin_lock(&bootid_spinlock);
1268 if (!uuid[8])
1269 generate_random_uuid(uuid);
1270 spin_unlock(&bootid_spinlock);
1271 }
1267 1272
1268 sprintf(buf, "%pU", uuid); 1273 sprintf(buf, "%pU", uuid);
1269 1274
diff --git a/drivers/clocksource/acpi_pm.c b/drivers/clocksource/acpi_pm.c
index 82e882028fcf..6b5cf02c35c8 100644
--- a/drivers/clocksource/acpi_pm.c
+++ b/drivers/clocksource/acpi_pm.c
@@ -23,7 +23,6 @@
23#include <linux/init.h> 23#include <linux/init.h>
24#include <linux/pci.h> 24#include <linux/pci.h>
25#include <linux/delay.h> 25#include <linux/delay.h>
26#include <linux/async.h>
27#include <asm/io.h> 26#include <asm/io.h>
28 27
29/* 28/*
@@ -180,15 +179,17 @@ static int verify_pmtmr_rate(void)
180/* Number of reads we try to get two different values */ 179/* Number of reads we try to get two different values */
181#define ACPI_PM_READ_CHECKS 10000 180#define ACPI_PM_READ_CHECKS 10000
182 181
183static void __init acpi_pm_clocksource_async(void *unused, async_cookie_t cookie) 182static int __init init_acpi_pm_clocksource(void)
184{ 183{
185 cycle_t value1, value2; 184 cycle_t value1, value2;
186 unsigned int i, j = 0; 185 unsigned int i, j = 0;
187 186
187 if (!pmtmr_ioport)
188 return -ENODEV;
188 189
189 /* "verify" this timing source: */ 190 /* "verify" this timing source: */
190 for (j = 0; j < ACPI_PM_MONOTONICITY_CHECKS; j++) { 191 for (j = 0; j < ACPI_PM_MONOTONICITY_CHECKS; j++) {
191 usleep_range(100 * j, 100 * j + 100); 192 udelay(100 * j);
192 value1 = clocksource_acpi_pm.read(&clocksource_acpi_pm); 193 value1 = clocksource_acpi_pm.read(&clocksource_acpi_pm);
193 for (i = 0; i < ACPI_PM_READ_CHECKS; i++) { 194 for (i = 0; i < ACPI_PM_READ_CHECKS; i++) {
194 value2 = clocksource_acpi_pm.read(&clocksource_acpi_pm); 195 value2 = clocksource_acpi_pm.read(&clocksource_acpi_pm);
@@ -202,34 +203,25 @@ static void __init acpi_pm_clocksource_async(void *unused, async_cookie_t cookie
202 " 0x%#llx, 0x%#llx - aborting.\n", 203 " 0x%#llx, 0x%#llx - aborting.\n",
203 value1, value2); 204 value1, value2);
204 pmtmr_ioport = 0; 205 pmtmr_ioport = 0;
205 return; 206 return -EINVAL;
206 } 207 }
207 if (i == ACPI_PM_READ_CHECKS) { 208 if (i == ACPI_PM_READ_CHECKS) {
208 printk(KERN_INFO "PM-Timer failed consistency check " 209 printk(KERN_INFO "PM-Timer failed consistency check "
209 " (0x%#llx) - aborting.\n", value1); 210 " (0x%#llx) - aborting.\n", value1);
210 pmtmr_ioport = 0; 211 pmtmr_ioport = 0;
211 return; 212 return -ENODEV;
212 } 213 }
213 } 214 }
214 215
215 if (verify_pmtmr_rate() != 0){ 216 if (verify_pmtmr_rate() != 0){
216 pmtmr_ioport = 0; 217 pmtmr_ioport = 0;
217 return; 218 return -ENODEV;
218 } 219 }
219 220
220 clocksource_register_hz(&clocksource_acpi_pm, 221 return clocksource_register_hz(&clocksource_acpi_pm,
221 PMTMR_TICKS_PER_SEC); 222 PMTMR_TICKS_PER_SEC);
222} 223}
223 224
224static int __init init_acpi_pm_clocksource(void)
225{
226 if (!pmtmr_ioport)
227 return -ENODEV;
228
229 async_schedule(acpi_pm_clocksource_async, NULL);
230 return 0;
231}
232
233/* We use fs_initcall because we want the PCI fixups to have run 225/* We use fs_initcall because we want the PCI fixups to have run
234 * but we still need to load before device_initcall 226 * but we still need to load before device_initcall
235 */ 227 */
diff --git a/drivers/cpufreq/Kconfig.arm b/drivers/cpufreq/Kconfig.arm
index ffbb44685915..5961e6415f08 100644
--- a/drivers/cpufreq/Kconfig.arm
+++ b/drivers/cpufreq/Kconfig.arm
@@ -4,6 +4,7 @@
4 4
5config ARM_OMAP2PLUS_CPUFREQ 5config ARM_OMAP2PLUS_CPUFREQ
6 bool "TI OMAP2+" 6 bool "TI OMAP2+"
7 depends on ARCH_OMAP2PLUS
7 default ARCH_OMAP2PLUS 8 default ARCH_OMAP2PLUS
8 select CPU_FREQ_TABLE 9 select CPU_FREQ_TABLE
9 10
diff --git a/drivers/crypto/ixp4xx_crypto.c b/drivers/crypto/ixp4xx_crypto.c
index 0053d7ebb5ca..8f3f74ce8c7f 100644
--- a/drivers/crypto/ixp4xx_crypto.c
+++ b/drivers/crypto/ixp4xx_crypto.c
@@ -18,6 +18,7 @@
18#include <linux/interrupt.h> 18#include <linux/interrupt.h>
19#include <linux/spinlock.h> 19#include <linux/spinlock.h>
20#include <linux/gfp.h> 20#include <linux/gfp.h>
21#include <linux/module.h>
21 22
22#include <crypto/ctr.h> 23#include <crypto/ctr.h>
23#include <crypto/des.h> 24#include <crypto/des.h>
diff --git a/drivers/crypto/talitos.c b/drivers/crypto/talitos.c
index dc641c796526..921039e56f87 100644
--- a/drivers/crypto/talitos.c
+++ b/drivers/crypto/talitos.c
@@ -124,6 +124,9 @@ struct talitos_private {
124 void __iomem *reg; 124 void __iomem *reg;
125 int irq[2]; 125 int irq[2];
126 126
127 /* SEC global registers lock */
128 spinlock_t reg_lock ____cacheline_aligned;
129
127 /* SEC version geometry (from device tree node) */ 130 /* SEC version geometry (from device tree node) */
128 unsigned int num_channels; 131 unsigned int num_channels;
129 unsigned int chfifo_len; 132 unsigned int chfifo_len;
@@ -412,6 +415,7 @@ static void talitos_done_##name(unsigned long data) \
412{ \ 415{ \
413 struct device *dev = (struct device *)data; \ 416 struct device *dev = (struct device *)data; \
414 struct talitos_private *priv = dev_get_drvdata(dev); \ 417 struct talitos_private *priv = dev_get_drvdata(dev); \
418 unsigned long flags; \
415 \ 419 \
416 if (ch_done_mask & 1) \ 420 if (ch_done_mask & 1) \
417 flush_channel(dev, 0, 0, 0); \ 421 flush_channel(dev, 0, 0, 0); \
@@ -427,8 +431,10 @@ static void talitos_done_##name(unsigned long data) \
427out: \ 431out: \
428 /* At this point, all completed channels have been processed */ \ 432 /* At this point, all completed channels have been processed */ \
429 /* Unmask done interrupts for channels completed later on. */ \ 433 /* Unmask done interrupts for channels completed later on. */ \
434 spin_lock_irqsave(&priv->reg_lock, flags); \
430 setbits32(priv->reg + TALITOS_IMR, ch_done_mask); \ 435 setbits32(priv->reg + TALITOS_IMR, ch_done_mask); \
431 setbits32(priv->reg + TALITOS_IMR_LO, TALITOS_IMR_LO_INIT); \ 436 setbits32(priv->reg + TALITOS_IMR_LO, TALITOS_IMR_LO_INIT); \
437 spin_unlock_irqrestore(&priv->reg_lock, flags); \
432} 438}
433DEF_TALITOS_DONE(4ch, TALITOS_ISR_4CHDONE) 439DEF_TALITOS_DONE(4ch, TALITOS_ISR_4CHDONE)
434DEF_TALITOS_DONE(ch0_2, TALITOS_ISR_CH_0_2_DONE) 440DEF_TALITOS_DONE(ch0_2, TALITOS_ISR_CH_0_2_DONE)
@@ -619,22 +625,28 @@ static irqreturn_t talitos_interrupt_##name(int irq, void *data) \
619 struct device *dev = data; \ 625 struct device *dev = data; \
620 struct talitos_private *priv = dev_get_drvdata(dev); \ 626 struct talitos_private *priv = dev_get_drvdata(dev); \
621 u32 isr, isr_lo; \ 627 u32 isr, isr_lo; \
628 unsigned long flags; \
622 \ 629 \
630 spin_lock_irqsave(&priv->reg_lock, flags); \
623 isr = in_be32(priv->reg + TALITOS_ISR); \ 631 isr = in_be32(priv->reg + TALITOS_ISR); \
624 isr_lo = in_be32(priv->reg + TALITOS_ISR_LO); \ 632 isr_lo = in_be32(priv->reg + TALITOS_ISR_LO); \
625 /* Acknowledge interrupt */ \ 633 /* Acknowledge interrupt */ \
626 out_be32(priv->reg + TALITOS_ICR, isr & (ch_done_mask | ch_err_mask)); \ 634 out_be32(priv->reg + TALITOS_ICR, isr & (ch_done_mask | ch_err_mask)); \
627 out_be32(priv->reg + TALITOS_ICR_LO, isr_lo); \ 635 out_be32(priv->reg + TALITOS_ICR_LO, isr_lo); \
628 \ 636 \
629 if (unlikely((isr & ~TALITOS_ISR_4CHDONE) & ch_err_mask || isr_lo)) \ 637 if (unlikely(isr & ch_err_mask || isr_lo)) { \
630 talitos_error(dev, isr, isr_lo); \ 638 spin_unlock_irqrestore(&priv->reg_lock, flags); \
631 else \ 639 talitos_error(dev, isr & ch_err_mask, isr_lo); \
640 } \
641 else { \
632 if (likely(isr & ch_done_mask)) { \ 642 if (likely(isr & ch_done_mask)) { \
633 /* mask further done interrupts. */ \ 643 /* mask further done interrupts. */ \
634 clrbits32(priv->reg + TALITOS_IMR, ch_done_mask); \ 644 clrbits32(priv->reg + TALITOS_IMR, ch_done_mask); \
635 /* done_task will unmask done interrupts at exit */ \ 645 /* done_task will unmask done interrupts at exit */ \
636 tasklet_schedule(&priv->done_task[tlet]); \ 646 tasklet_schedule(&priv->done_task[tlet]); \
637 } \ 647 } \
648 spin_unlock_irqrestore(&priv->reg_lock, flags); \
649 } \
638 \ 650 \
639 return (isr & (ch_done_mask | ch_err_mask) || isr_lo) ? IRQ_HANDLED : \ 651 return (isr & (ch_done_mask | ch_err_mask) || isr_lo) ? IRQ_HANDLED : \
640 IRQ_NONE; \ 652 IRQ_NONE; \
@@ -2719,6 +2731,8 @@ static int talitos_probe(struct platform_device *ofdev)
2719 2731
2720 priv->ofdev = ofdev; 2732 priv->ofdev = ofdev;
2721 2733
2734 spin_lock_init(&priv->reg_lock);
2735
2722 err = talitos_probe_irq(ofdev); 2736 err = talitos_probe_irq(ofdev);
2723 if (err) 2737 if (err)
2724 goto err_out; 2738 goto err_out;
diff --git a/drivers/dma/Kconfig b/drivers/dma/Kconfig
index cf9da362d64f..ef378b5b17e4 100644
--- a/drivers/dma/Kconfig
+++ b/drivers/dma/Kconfig
@@ -91,11 +91,10 @@ config DW_DMAC
91 91
92config AT_HDMAC 92config AT_HDMAC
93 tristate "Atmel AHB DMA support" 93 tristate "Atmel AHB DMA support"
94 depends on ARCH_AT91SAM9RL || ARCH_AT91SAM9G45 94 depends on ARCH_AT91
95 select DMA_ENGINE 95 select DMA_ENGINE
96 help 96 help
97 Support the Atmel AHB DMA controller. This can be integrated in 97 Support the Atmel AHB DMA controller.
98 chips such as the Atmel AT91SAM9RL.
99 98
100config FSL_DMA 99config FSL_DMA
101 tristate "Freescale Elo and Elo Plus DMA support" 100 tristate "Freescale Elo and Elo Plus DMA support"
diff --git a/drivers/dma/amba-pl08x.c b/drivers/dma/amba-pl08x.c
index c301a8ec31aa..3d704abd7912 100644
--- a/drivers/dma/amba-pl08x.c
+++ b/drivers/dma/amba-pl08x.c
@@ -1429,6 +1429,7 @@ static int pl08x_control(struct dma_chan *chan, enum dma_ctrl_cmd cmd,
1429 * signal 1429 * signal
1430 */ 1430 */
1431 release_phy_channel(plchan); 1431 release_phy_channel(plchan);
1432 plchan->phychan_hold = 0;
1432 } 1433 }
1433 /* Dequeue jobs and free LLIs */ 1434 /* Dequeue jobs and free LLIs */
1434 if (plchan->at) { 1435 if (plchan->at) {
diff --git a/drivers/dma/at_hdmac.c b/drivers/dma/at_hdmac.c
index 7aa58d204892..445fdf811695 100644
--- a/drivers/dma/at_hdmac.c
+++ b/drivers/dma/at_hdmac.c
@@ -221,10 +221,6 @@ static void atc_dostart(struct at_dma_chan *atchan, struct at_desc *first)
221 221
222 vdbg_dump_regs(atchan); 222 vdbg_dump_regs(atchan);
223 223
224 /* clear any pending interrupt */
225 while (dma_readl(atdma, EBCISR))
226 cpu_relax();
227
228 channel_writel(atchan, SADDR, 0); 224 channel_writel(atchan, SADDR, 0);
229 channel_writel(atchan, DADDR, 0); 225 channel_writel(atchan, DADDR, 0);
230 channel_writel(atchan, CTRLA, 0); 226 channel_writel(atchan, CTRLA, 0);
diff --git a/drivers/dma/dmaengine.c b/drivers/dma/dmaengine.c
index 767bcc31b365..2397f6f451b1 100644
--- a/drivers/dma/dmaengine.c
+++ b/drivers/dma/dmaengine.c
@@ -332,6 +332,20 @@ struct dma_chan *dma_find_channel(enum dma_transaction_type tx_type)
332} 332}
333EXPORT_SYMBOL(dma_find_channel); 333EXPORT_SYMBOL(dma_find_channel);
334 334
335/*
336 * net_dma_find_channel - find a channel for net_dma
337 * net_dma has alignment requirements
338 */
339struct dma_chan *net_dma_find_channel(void)
340{
341 struct dma_chan *chan = dma_find_channel(DMA_MEMCPY);
342 if (chan && !is_dma_copy_aligned(chan->device, 1, 1, 1))
343 return NULL;
344
345 return chan;
346}
347EXPORT_SYMBOL(net_dma_find_channel);
348
335/** 349/**
336 * dma_issue_pending_all - flush all pending operations across all channels 350 * dma_issue_pending_all - flush all pending operations across all channels
337 */ 351 */
diff --git a/drivers/dma/imx-dma.c b/drivers/dma/imx-dma.c
index a45b5d2a5987..bb787d8e1529 100644
--- a/drivers/dma/imx-dma.c
+++ b/drivers/dma/imx-dma.c
@@ -571,11 +571,14 @@ static void imxdma_tasklet(unsigned long data)
571 if (desc->desc.callback) 571 if (desc->desc.callback)
572 desc->desc.callback(desc->desc.callback_param); 572 desc->desc.callback(desc->desc.callback_param);
573 573
574 dma_cookie_complete(&desc->desc); 574 /* If we are dealing with a cyclic descriptor keep it on ld_active
575 575 * and dont mark the descripor as complete.
576 /* If we are dealing with a cyclic descriptor keep it on ld_active */ 576 * Only in non-cyclic cases it would be marked as complete
577 */
577 if (imxdma_chan_is_doing_cyclic(imxdmac)) 578 if (imxdma_chan_is_doing_cyclic(imxdmac))
578 goto out; 579 goto out;
580 else
581 dma_cookie_complete(&desc->desc);
579 582
580 /* Free 2D slot if it was an interleaved transfer */ 583 /* Free 2D slot if it was an interleaved transfer */
581 if (imxdmac->enabled_2d) { 584 if (imxdmac->enabled_2d) {
diff --git a/drivers/dma/ioat/dma.c b/drivers/dma/ioat/dma.c
index 31493d80e0e9..73b2b65cb1de 100644
--- a/drivers/dma/ioat/dma.c
+++ b/drivers/dma/ioat/dma.c
@@ -546,9 +546,9 @@ void ioat_dma_unmap(struct ioat_chan_common *chan, enum dma_ctrl_flags flags,
546 PCI_DMA_TODEVICE, flags, 0); 546 PCI_DMA_TODEVICE, flags, 0);
547} 547}
548 548
549unsigned long ioat_get_current_completion(struct ioat_chan_common *chan) 549dma_addr_t ioat_get_current_completion(struct ioat_chan_common *chan)
550{ 550{
551 unsigned long phys_complete; 551 dma_addr_t phys_complete;
552 u64 completion; 552 u64 completion;
553 553
554 completion = *chan->completion; 554 completion = *chan->completion;
@@ -569,7 +569,7 @@ unsigned long ioat_get_current_completion(struct ioat_chan_common *chan)
569} 569}
570 570
571bool ioat_cleanup_preamble(struct ioat_chan_common *chan, 571bool ioat_cleanup_preamble(struct ioat_chan_common *chan,
572 unsigned long *phys_complete) 572 dma_addr_t *phys_complete)
573{ 573{
574 *phys_complete = ioat_get_current_completion(chan); 574 *phys_complete = ioat_get_current_completion(chan);
575 if (*phys_complete == chan->last_completion) 575 if (*phys_complete == chan->last_completion)
@@ -580,14 +580,14 @@ bool ioat_cleanup_preamble(struct ioat_chan_common *chan,
580 return true; 580 return true;
581} 581}
582 582
583static void __cleanup(struct ioat_dma_chan *ioat, unsigned long phys_complete) 583static void __cleanup(struct ioat_dma_chan *ioat, dma_addr_t phys_complete)
584{ 584{
585 struct ioat_chan_common *chan = &ioat->base; 585 struct ioat_chan_common *chan = &ioat->base;
586 struct list_head *_desc, *n; 586 struct list_head *_desc, *n;
587 struct dma_async_tx_descriptor *tx; 587 struct dma_async_tx_descriptor *tx;
588 588
589 dev_dbg(to_dev(chan), "%s: phys_complete: %lx\n", 589 dev_dbg(to_dev(chan), "%s: phys_complete: %llx\n",
590 __func__, phys_complete); 590 __func__, (unsigned long long) phys_complete);
591 list_for_each_safe(_desc, n, &ioat->used_desc) { 591 list_for_each_safe(_desc, n, &ioat->used_desc) {
592 struct ioat_desc_sw *desc; 592 struct ioat_desc_sw *desc;
593 593
@@ -652,7 +652,7 @@ static void __cleanup(struct ioat_dma_chan *ioat, unsigned long phys_complete)
652static void ioat1_cleanup(struct ioat_dma_chan *ioat) 652static void ioat1_cleanup(struct ioat_dma_chan *ioat)
653{ 653{
654 struct ioat_chan_common *chan = &ioat->base; 654 struct ioat_chan_common *chan = &ioat->base;
655 unsigned long phys_complete; 655 dma_addr_t phys_complete;
656 656
657 prefetch(chan->completion); 657 prefetch(chan->completion);
658 658
@@ -698,7 +698,7 @@ static void ioat1_timer_event(unsigned long data)
698 mod_timer(&chan->timer, jiffies + COMPLETION_TIMEOUT); 698 mod_timer(&chan->timer, jiffies + COMPLETION_TIMEOUT);
699 spin_unlock_bh(&ioat->desc_lock); 699 spin_unlock_bh(&ioat->desc_lock);
700 } else if (test_bit(IOAT_COMPLETION_PENDING, &chan->state)) { 700 } else if (test_bit(IOAT_COMPLETION_PENDING, &chan->state)) {
701 unsigned long phys_complete; 701 dma_addr_t phys_complete;
702 702
703 spin_lock_bh(&ioat->desc_lock); 703 spin_lock_bh(&ioat->desc_lock);
704 /* if we haven't made progress and we have already 704 /* if we haven't made progress and we have already
diff --git a/drivers/dma/ioat/dma.h b/drivers/dma/ioat/dma.h
index c7888bccd974..5e8fe01ba69d 100644
--- a/drivers/dma/ioat/dma.h
+++ b/drivers/dma/ioat/dma.h
@@ -88,7 +88,7 @@ struct ioatdma_device {
88struct ioat_chan_common { 88struct ioat_chan_common {
89 struct dma_chan common; 89 struct dma_chan common;
90 void __iomem *reg_base; 90 void __iomem *reg_base;
91 unsigned long last_completion; 91 dma_addr_t last_completion;
92 spinlock_t cleanup_lock; 92 spinlock_t cleanup_lock;
93 unsigned long state; 93 unsigned long state;
94 #define IOAT_COMPLETION_PENDING 0 94 #define IOAT_COMPLETION_PENDING 0
@@ -310,7 +310,7 @@ int __devinit ioat_dma_self_test(struct ioatdma_device *device);
310void __devexit ioat_dma_remove(struct ioatdma_device *device); 310void __devexit ioat_dma_remove(struct ioatdma_device *device);
311struct dca_provider * __devinit ioat_dca_init(struct pci_dev *pdev, 311struct dca_provider * __devinit ioat_dca_init(struct pci_dev *pdev,
312 void __iomem *iobase); 312 void __iomem *iobase);
313unsigned long ioat_get_current_completion(struct ioat_chan_common *chan); 313dma_addr_t ioat_get_current_completion(struct ioat_chan_common *chan);
314void ioat_init_channel(struct ioatdma_device *device, 314void ioat_init_channel(struct ioatdma_device *device,
315 struct ioat_chan_common *chan, int idx); 315 struct ioat_chan_common *chan, int idx);
316enum dma_status ioat_dma_tx_status(struct dma_chan *c, dma_cookie_t cookie, 316enum dma_status ioat_dma_tx_status(struct dma_chan *c, dma_cookie_t cookie,
@@ -318,7 +318,7 @@ enum dma_status ioat_dma_tx_status(struct dma_chan *c, dma_cookie_t cookie,
318void ioat_dma_unmap(struct ioat_chan_common *chan, enum dma_ctrl_flags flags, 318void ioat_dma_unmap(struct ioat_chan_common *chan, enum dma_ctrl_flags flags,
319 size_t len, struct ioat_dma_descriptor *hw); 319 size_t len, struct ioat_dma_descriptor *hw);
320bool ioat_cleanup_preamble(struct ioat_chan_common *chan, 320bool ioat_cleanup_preamble(struct ioat_chan_common *chan,
321 unsigned long *phys_complete); 321 dma_addr_t *phys_complete);
322void ioat_kobject_add(struct ioatdma_device *device, struct kobj_type *type); 322void ioat_kobject_add(struct ioatdma_device *device, struct kobj_type *type);
323void ioat_kobject_del(struct ioatdma_device *device); 323void ioat_kobject_del(struct ioatdma_device *device);
324extern const struct sysfs_ops ioat_sysfs_ops; 324extern const struct sysfs_ops ioat_sysfs_ops;
diff --git a/drivers/dma/ioat/dma_v2.c b/drivers/dma/ioat/dma_v2.c
index e8e110ff3d96..86895760b598 100644
--- a/drivers/dma/ioat/dma_v2.c
+++ b/drivers/dma/ioat/dma_v2.c
@@ -128,7 +128,7 @@ static void ioat2_start_null_desc(struct ioat2_dma_chan *ioat)
128 spin_unlock_bh(&ioat->prep_lock); 128 spin_unlock_bh(&ioat->prep_lock);
129} 129}
130 130
131static void __cleanup(struct ioat2_dma_chan *ioat, unsigned long phys_complete) 131static void __cleanup(struct ioat2_dma_chan *ioat, dma_addr_t phys_complete)
132{ 132{
133 struct ioat_chan_common *chan = &ioat->base; 133 struct ioat_chan_common *chan = &ioat->base;
134 struct dma_async_tx_descriptor *tx; 134 struct dma_async_tx_descriptor *tx;
@@ -179,7 +179,7 @@ static void __cleanup(struct ioat2_dma_chan *ioat, unsigned long phys_complete)
179static void ioat2_cleanup(struct ioat2_dma_chan *ioat) 179static void ioat2_cleanup(struct ioat2_dma_chan *ioat)
180{ 180{
181 struct ioat_chan_common *chan = &ioat->base; 181 struct ioat_chan_common *chan = &ioat->base;
182 unsigned long phys_complete; 182 dma_addr_t phys_complete;
183 183
184 spin_lock_bh(&chan->cleanup_lock); 184 spin_lock_bh(&chan->cleanup_lock);
185 if (ioat_cleanup_preamble(chan, &phys_complete)) 185 if (ioat_cleanup_preamble(chan, &phys_complete))
@@ -260,7 +260,7 @@ int ioat2_reset_sync(struct ioat_chan_common *chan, unsigned long tmo)
260static void ioat2_restart_channel(struct ioat2_dma_chan *ioat) 260static void ioat2_restart_channel(struct ioat2_dma_chan *ioat)
261{ 261{
262 struct ioat_chan_common *chan = &ioat->base; 262 struct ioat_chan_common *chan = &ioat->base;
263 unsigned long phys_complete; 263 dma_addr_t phys_complete;
264 264
265 ioat2_quiesce(chan, 0); 265 ioat2_quiesce(chan, 0);
266 if (ioat_cleanup_preamble(chan, &phys_complete)) 266 if (ioat_cleanup_preamble(chan, &phys_complete))
@@ -275,7 +275,7 @@ void ioat2_timer_event(unsigned long data)
275 struct ioat_chan_common *chan = &ioat->base; 275 struct ioat_chan_common *chan = &ioat->base;
276 276
277 if (test_bit(IOAT_COMPLETION_PENDING, &chan->state)) { 277 if (test_bit(IOAT_COMPLETION_PENDING, &chan->state)) {
278 unsigned long phys_complete; 278 dma_addr_t phys_complete;
279 u64 status; 279 u64 status;
280 280
281 status = ioat_chansts(chan); 281 status = ioat_chansts(chan);
@@ -572,9 +572,9 @@ bool reshape_ring(struct ioat2_dma_chan *ioat, int order)
572 */ 572 */
573 struct ioat_chan_common *chan = &ioat->base; 573 struct ioat_chan_common *chan = &ioat->base;
574 struct dma_chan *c = &chan->common; 574 struct dma_chan *c = &chan->common;
575 const u16 curr_size = ioat2_ring_size(ioat); 575 const u32 curr_size = ioat2_ring_size(ioat);
576 const u16 active = ioat2_ring_active(ioat); 576 const u16 active = ioat2_ring_active(ioat);
577 const u16 new_size = 1 << order; 577 const u32 new_size = 1 << order;
578 struct ioat_ring_ent **ring; 578 struct ioat_ring_ent **ring;
579 u16 i; 579 u16 i;
580 580
diff --git a/drivers/dma/ioat/dma_v2.h b/drivers/dma/ioat/dma_v2.h
index a2c413b2b8d8..be2a55b95c23 100644
--- a/drivers/dma/ioat/dma_v2.h
+++ b/drivers/dma/ioat/dma_v2.h
@@ -74,7 +74,7 @@ static inline struct ioat2_dma_chan *to_ioat2_chan(struct dma_chan *c)
74 return container_of(chan, struct ioat2_dma_chan, base); 74 return container_of(chan, struct ioat2_dma_chan, base);
75} 75}
76 76
77static inline u16 ioat2_ring_size(struct ioat2_dma_chan *ioat) 77static inline u32 ioat2_ring_size(struct ioat2_dma_chan *ioat)
78{ 78{
79 return 1 << ioat->alloc_order; 79 return 1 << ioat->alloc_order;
80} 80}
@@ -91,7 +91,7 @@ static inline u16 ioat2_ring_pending(struct ioat2_dma_chan *ioat)
91 return CIRC_CNT(ioat->head, ioat->issued, ioat2_ring_size(ioat)); 91 return CIRC_CNT(ioat->head, ioat->issued, ioat2_ring_size(ioat));
92} 92}
93 93
94static inline u16 ioat2_ring_space(struct ioat2_dma_chan *ioat) 94static inline u32 ioat2_ring_space(struct ioat2_dma_chan *ioat)
95{ 95{
96 return ioat2_ring_size(ioat) - ioat2_ring_active(ioat); 96 return ioat2_ring_size(ioat) - ioat2_ring_active(ioat);
97} 97}
diff --git a/drivers/dma/ioat/dma_v3.c b/drivers/dma/ioat/dma_v3.c
index 2c4476c0e405..f7f1dc62c15c 100644
--- a/drivers/dma/ioat/dma_v3.c
+++ b/drivers/dma/ioat/dma_v3.c
@@ -257,7 +257,7 @@ static bool desc_has_ext(struct ioat_ring_ent *desc)
257 * The difference from the dma_v2.c __cleanup() is that this routine 257 * The difference from the dma_v2.c __cleanup() is that this routine
258 * handles extended descriptors and dma-unmapping raid operations. 258 * handles extended descriptors and dma-unmapping raid operations.
259 */ 259 */
260static void __cleanup(struct ioat2_dma_chan *ioat, unsigned long phys_complete) 260static void __cleanup(struct ioat2_dma_chan *ioat, dma_addr_t phys_complete)
261{ 261{
262 struct ioat_chan_common *chan = &ioat->base; 262 struct ioat_chan_common *chan = &ioat->base;
263 struct ioat_ring_ent *desc; 263 struct ioat_ring_ent *desc;
@@ -314,7 +314,7 @@ static void __cleanup(struct ioat2_dma_chan *ioat, unsigned long phys_complete)
314static void ioat3_cleanup(struct ioat2_dma_chan *ioat) 314static void ioat3_cleanup(struct ioat2_dma_chan *ioat)
315{ 315{
316 struct ioat_chan_common *chan = &ioat->base; 316 struct ioat_chan_common *chan = &ioat->base;
317 unsigned long phys_complete; 317 dma_addr_t phys_complete;
318 318
319 spin_lock_bh(&chan->cleanup_lock); 319 spin_lock_bh(&chan->cleanup_lock);
320 if (ioat_cleanup_preamble(chan, &phys_complete)) 320 if (ioat_cleanup_preamble(chan, &phys_complete))
@@ -333,7 +333,7 @@ static void ioat3_cleanup_event(unsigned long data)
333static void ioat3_restart_channel(struct ioat2_dma_chan *ioat) 333static void ioat3_restart_channel(struct ioat2_dma_chan *ioat)
334{ 334{
335 struct ioat_chan_common *chan = &ioat->base; 335 struct ioat_chan_common *chan = &ioat->base;
336 unsigned long phys_complete; 336 dma_addr_t phys_complete;
337 337
338 ioat2_quiesce(chan, 0); 338 ioat2_quiesce(chan, 0);
339 if (ioat_cleanup_preamble(chan, &phys_complete)) 339 if (ioat_cleanup_preamble(chan, &phys_complete))
@@ -348,7 +348,7 @@ static void ioat3_timer_event(unsigned long data)
348 struct ioat_chan_common *chan = &ioat->base; 348 struct ioat_chan_common *chan = &ioat->base;
349 349
350 if (test_bit(IOAT_COMPLETION_PENDING, &chan->state)) { 350 if (test_bit(IOAT_COMPLETION_PENDING, &chan->state)) {
351 unsigned long phys_complete; 351 dma_addr_t phys_complete;
352 u64 status; 352 u64 status;
353 353
354 status = ioat_chansts(chan); 354 status = ioat_chansts(chan);
@@ -1149,6 +1149,44 @@ static int ioat3_reset_hw(struct ioat_chan_common *chan)
1149 return ioat2_reset_sync(chan, msecs_to_jiffies(200)); 1149 return ioat2_reset_sync(chan, msecs_to_jiffies(200));
1150} 1150}
1151 1151
1152static bool is_jf_ioat(struct pci_dev *pdev)
1153{
1154 switch (pdev->device) {
1155 case PCI_DEVICE_ID_INTEL_IOAT_JSF0:
1156 case PCI_DEVICE_ID_INTEL_IOAT_JSF1:
1157 case PCI_DEVICE_ID_INTEL_IOAT_JSF2:
1158 case PCI_DEVICE_ID_INTEL_IOAT_JSF3:
1159 case PCI_DEVICE_ID_INTEL_IOAT_JSF4:
1160 case PCI_DEVICE_ID_INTEL_IOAT_JSF5:
1161 case PCI_DEVICE_ID_INTEL_IOAT_JSF6:
1162 case PCI_DEVICE_ID_INTEL_IOAT_JSF7:
1163 case PCI_DEVICE_ID_INTEL_IOAT_JSF8:
1164 case PCI_DEVICE_ID_INTEL_IOAT_JSF9:
1165 return true;
1166 default:
1167 return false;
1168 }
1169}
1170
1171static bool is_snb_ioat(struct pci_dev *pdev)
1172{
1173 switch (pdev->device) {
1174 case PCI_DEVICE_ID_INTEL_IOAT_SNB0:
1175 case PCI_DEVICE_ID_INTEL_IOAT_SNB1:
1176 case PCI_DEVICE_ID_INTEL_IOAT_SNB2:
1177 case PCI_DEVICE_ID_INTEL_IOAT_SNB3:
1178 case PCI_DEVICE_ID_INTEL_IOAT_SNB4:
1179 case PCI_DEVICE_ID_INTEL_IOAT_SNB5:
1180 case PCI_DEVICE_ID_INTEL_IOAT_SNB6:
1181 case PCI_DEVICE_ID_INTEL_IOAT_SNB7:
1182 case PCI_DEVICE_ID_INTEL_IOAT_SNB8:
1183 case PCI_DEVICE_ID_INTEL_IOAT_SNB9:
1184 return true;
1185 default:
1186 return false;
1187 }
1188}
1189
1152int __devinit ioat3_dma_probe(struct ioatdma_device *device, int dca) 1190int __devinit ioat3_dma_probe(struct ioatdma_device *device, int dca)
1153{ 1191{
1154 struct pci_dev *pdev = device->pdev; 1192 struct pci_dev *pdev = device->pdev;
@@ -1169,6 +1207,9 @@ int __devinit ioat3_dma_probe(struct ioatdma_device *device, int dca)
1169 dma->device_alloc_chan_resources = ioat2_alloc_chan_resources; 1207 dma->device_alloc_chan_resources = ioat2_alloc_chan_resources;
1170 dma->device_free_chan_resources = ioat2_free_chan_resources; 1208 dma->device_free_chan_resources = ioat2_free_chan_resources;
1171 1209
1210 if (is_jf_ioat(pdev) || is_snb_ioat(pdev))
1211 dma->copy_align = 6;
1212
1172 dma_cap_set(DMA_INTERRUPT, dma->cap_mask); 1213 dma_cap_set(DMA_INTERRUPT, dma->cap_mask);
1173 dma->device_prep_dma_interrupt = ioat3_prep_interrupt_lock; 1214 dma->device_prep_dma_interrupt = ioat3_prep_interrupt_lock;
1174 1215
diff --git a/drivers/dma/iop-adma.c b/drivers/dma/iop-adma.c
index da6c4c2c066a..79e3eba29702 100644
--- a/drivers/dma/iop-adma.c
+++ b/drivers/dma/iop-adma.c
@@ -1252,8 +1252,8 @@ iop_adma_pq_zero_sum_self_test(struct iop_adma_device *device)
1252 struct page **pq_hw = &pq[IOP_ADMA_NUM_SRC_TEST+2]; 1252 struct page **pq_hw = &pq[IOP_ADMA_NUM_SRC_TEST+2];
1253 /* address conversion buffers (dma_map / page_address) */ 1253 /* address conversion buffers (dma_map / page_address) */
1254 void *pq_sw[IOP_ADMA_NUM_SRC_TEST+2]; 1254 void *pq_sw[IOP_ADMA_NUM_SRC_TEST+2];
1255 dma_addr_t pq_src[IOP_ADMA_NUM_SRC_TEST]; 1255 dma_addr_t pq_src[IOP_ADMA_NUM_SRC_TEST+2];
1256 dma_addr_t pq_dest[2]; 1256 dma_addr_t *pq_dest = &pq_src[IOP_ADMA_NUM_SRC_TEST];
1257 1257
1258 int i; 1258 int i;
1259 struct dma_async_tx_descriptor *tx; 1259 struct dma_async_tx_descriptor *tx;
diff --git a/drivers/dma/mxs-dma.c b/drivers/dma/mxs-dma.c
index c81ef7e10e08..655d4ce6ed0d 100644
--- a/drivers/dma/mxs-dma.c
+++ b/drivers/dma/mxs-dma.c
@@ -201,10 +201,6 @@ static struct mxs_dma_chan *to_mxs_dma_chan(struct dma_chan *chan)
201 201
202static dma_cookie_t mxs_dma_tx_submit(struct dma_async_tx_descriptor *tx) 202static dma_cookie_t mxs_dma_tx_submit(struct dma_async_tx_descriptor *tx)
203{ 203{
204 struct mxs_dma_chan *mxs_chan = to_mxs_dma_chan(tx->chan);
205
206 mxs_dma_enable_chan(mxs_chan);
207
208 return dma_cookie_assign(tx); 204 return dma_cookie_assign(tx);
209} 205}
210 206
@@ -558,9 +554,9 @@ static enum dma_status mxs_dma_tx_status(struct dma_chan *chan,
558 554
559static void mxs_dma_issue_pending(struct dma_chan *chan) 555static void mxs_dma_issue_pending(struct dma_chan *chan)
560{ 556{
561 /* 557 struct mxs_dma_chan *mxs_chan = to_mxs_dma_chan(chan);
562 * Nothing to do. We only have a single descriptor. 558
563 */ 559 mxs_dma_enable_chan(mxs_chan);
564} 560}
565 561
566static int __init mxs_dma_init(struct mxs_dma_engine *mxs_dma) 562static int __init mxs_dma_init(struct mxs_dma_engine *mxs_dma)
diff --git a/drivers/dma/pl330.c b/drivers/dma/pl330.c
index 282caf118be8..2ee6e23930ad 100644
--- a/drivers/dma/pl330.c
+++ b/drivers/dma/pl330.c
@@ -2225,12 +2225,9 @@ static inline void free_desc_list(struct list_head *list)
2225{ 2225{
2226 struct dma_pl330_dmac *pdmac; 2226 struct dma_pl330_dmac *pdmac;
2227 struct dma_pl330_desc *desc; 2227 struct dma_pl330_desc *desc;
2228 struct dma_pl330_chan *pch; 2228 struct dma_pl330_chan *pch = NULL;
2229 unsigned long flags; 2229 unsigned long flags;
2230 2230
2231 if (list_empty(list))
2232 return;
2233
2234 /* Finish off the work list */ 2231 /* Finish off the work list */
2235 list_for_each_entry(desc, list, node) { 2232 list_for_each_entry(desc, list, node) {
2236 dma_async_tx_callback callback; 2233 dma_async_tx_callback callback;
@@ -2247,6 +2244,10 @@ static inline void free_desc_list(struct list_head *list)
2247 desc->pchan = NULL; 2244 desc->pchan = NULL;
2248 } 2245 }
2249 2246
2247 /* pch will be unset if list was empty */
2248 if (!pch)
2249 return;
2250
2250 pdmac = pch->dmac; 2251 pdmac = pch->dmac;
2251 2252
2252 spin_lock_irqsave(&pdmac->pool_lock, flags); 2253 spin_lock_irqsave(&pdmac->pool_lock, flags);
@@ -2257,12 +2258,9 @@ static inline void free_desc_list(struct list_head *list)
2257static inline void handle_cyclic_desc_list(struct list_head *list) 2258static inline void handle_cyclic_desc_list(struct list_head *list)
2258{ 2259{
2259 struct dma_pl330_desc *desc; 2260 struct dma_pl330_desc *desc;
2260 struct dma_pl330_chan *pch; 2261 struct dma_pl330_chan *pch = NULL;
2261 unsigned long flags; 2262 unsigned long flags;
2262 2263
2263 if (list_empty(list))
2264 return;
2265
2266 list_for_each_entry(desc, list, node) { 2264 list_for_each_entry(desc, list, node) {
2267 dma_async_tx_callback callback; 2265 dma_async_tx_callback callback;
2268 2266
@@ -2274,6 +2272,10 @@ static inline void handle_cyclic_desc_list(struct list_head *list)
2274 callback(desc->txd.callback_param); 2272 callback(desc->txd.callback_param);
2275 } 2273 }
2276 2274
2275 /* pch will be unset if list was empty */
2276 if (!pch)
2277 return;
2278
2277 spin_lock_irqsave(&pch->lock, flags); 2279 spin_lock_irqsave(&pch->lock, flags);
2278 list_splice_tail_init(list, &pch->work_list); 2280 list_splice_tail_init(list, &pch->work_list);
2279 spin_unlock_irqrestore(&pch->lock, flags); 2281 spin_unlock_irqrestore(&pch->lock, flags);
@@ -2926,8 +2928,11 @@ pl330_probe(struct amba_device *adev, const struct amba_id *id)
2926 INIT_LIST_HEAD(&pd->channels); 2928 INIT_LIST_HEAD(&pd->channels);
2927 2929
2928 /* Initialize channel parameters */ 2930 /* Initialize channel parameters */
2929 num_chan = max(pdat ? pdat->nr_valid_peri : (u8)pi->pcfg.num_peri, 2931 if (pdat)
2930 (u8)pi->pcfg.num_chan); 2932 num_chan = max_t(int, pdat->nr_valid_peri, pi->pcfg.num_chan);
2933 else
2934 num_chan = max_t(int, pi->pcfg.num_peri, pi->pcfg.num_chan);
2935
2931 pdmac->peripherals = kzalloc(num_chan * sizeof(*pch), GFP_KERNEL); 2936 pdmac->peripherals = kzalloc(num_chan * sizeof(*pch), GFP_KERNEL);
2932 2937
2933 for (i = 0; i < num_chan; i++) { 2938 for (i = 0; i < num_chan; i++) {
diff --git a/drivers/dma/ste_dma40.c b/drivers/dma/ste_dma40.c
index bdd41d4bfa8d..2ed1ac3513f3 100644
--- a/drivers/dma/ste_dma40.c
+++ b/drivers/dma/ste_dma40.c
@@ -18,6 +18,7 @@
18#include <linux/pm_runtime.h> 18#include <linux/pm_runtime.h>
19#include <linux/err.h> 19#include <linux/err.h>
20#include <linux/amba/bus.h> 20#include <linux/amba/bus.h>
21#include <linux/regulator/consumer.h>
21 22
22#include <plat/ste_dma40.h> 23#include <plat/ste_dma40.h>
23 24
@@ -69,6 +70,22 @@ enum d40_command {
69}; 70};
70 71
71/* 72/*
73 * enum d40_events - The different Event Enables for the event lines.
74 *
75 * @D40_DEACTIVATE_EVENTLINE: De-activate Event line, stopping the logical chan.
76 * @D40_ACTIVATE_EVENTLINE: Activate the Event line, to start a logical chan.
77 * @D40_SUSPEND_REQ_EVENTLINE: Requesting for suspending a event line.
78 * @D40_ROUND_EVENTLINE: Status check for event line.
79 */
80
81enum d40_events {
82 D40_DEACTIVATE_EVENTLINE = 0,
83 D40_ACTIVATE_EVENTLINE = 1,
84 D40_SUSPEND_REQ_EVENTLINE = 2,
85 D40_ROUND_EVENTLINE = 3
86};
87
88/*
72 * These are the registers that has to be saved and later restored 89 * These are the registers that has to be saved and later restored
73 * when the DMA hw is powered off. 90 * when the DMA hw is powered off.
74 * TODO: Add save/restore of D40_DREG_GCC on dma40 v3 or later, if that works. 91 * TODO: Add save/restore of D40_DREG_GCC on dma40 v3 or later, if that works.
@@ -870,8 +887,8 @@ static void d40_save_restore_registers(struct d40_base *base, bool save)
870} 887}
871#endif 888#endif
872 889
873static int d40_channel_execute_command(struct d40_chan *d40c, 890static int __d40_execute_command_phy(struct d40_chan *d40c,
874 enum d40_command command) 891 enum d40_command command)
875{ 892{
876 u32 status; 893 u32 status;
877 int i; 894 int i;
@@ -880,6 +897,12 @@ static int d40_channel_execute_command(struct d40_chan *d40c,
880 unsigned long flags; 897 unsigned long flags;
881 u32 wmask; 898 u32 wmask;
882 899
900 if (command == D40_DMA_STOP) {
901 ret = __d40_execute_command_phy(d40c, D40_DMA_SUSPEND_REQ);
902 if (ret)
903 return ret;
904 }
905
883 spin_lock_irqsave(&d40c->base->execmd_lock, flags); 906 spin_lock_irqsave(&d40c->base->execmd_lock, flags);
884 907
885 if (d40c->phy_chan->num % 2 == 0) 908 if (d40c->phy_chan->num % 2 == 0)
@@ -973,67 +996,109 @@ static void d40_term_all(struct d40_chan *d40c)
973 } 996 }
974 997
975 d40c->pending_tx = 0; 998 d40c->pending_tx = 0;
976 d40c->busy = false;
977} 999}
978 1000
979static void __d40_config_set_event(struct d40_chan *d40c, bool enable, 1001static void __d40_config_set_event(struct d40_chan *d40c,
980 u32 event, int reg) 1002 enum d40_events event_type, u32 event,
1003 int reg)
981{ 1004{
982 void __iomem *addr = chan_base(d40c) + reg; 1005 void __iomem *addr = chan_base(d40c) + reg;
983 int tries; 1006 int tries;
1007 u32 status;
1008
1009 switch (event_type) {
1010
1011 case D40_DEACTIVATE_EVENTLINE:
984 1012
985 if (!enable) {
986 writel((D40_DEACTIVATE_EVENTLINE << D40_EVENTLINE_POS(event)) 1013 writel((D40_DEACTIVATE_EVENTLINE << D40_EVENTLINE_POS(event))
987 | ~D40_EVENTLINE_MASK(event), addr); 1014 | ~D40_EVENTLINE_MASK(event), addr);
988 return; 1015 break;
989 } 1016
1017 case D40_SUSPEND_REQ_EVENTLINE:
1018 status = (readl(addr) & D40_EVENTLINE_MASK(event)) >>
1019 D40_EVENTLINE_POS(event);
1020
1021 if (status == D40_DEACTIVATE_EVENTLINE ||
1022 status == D40_SUSPEND_REQ_EVENTLINE)
1023 break;
990 1024
1025 writel((D40_SUSPEND_REQ_EVENTLINE << D40_EVENTLINE_POS(event))
1026 | ~D40_EVENTLINE_MASK(event), addr);
1027
1028 for (tries = 0 ; tries < D40_SUSPEND_MAX_IT; tries++) {
1029
1030 status = (readl(addr) & D40_EVENTLINE_MASK(event)) >>
1031 D40_EVENTLINE_POS(event);
1032
1033 cpu_relax();
1034 /*
1035 * Reduce the number of bus accesses while
1036 * waiting for the DMA to suspend.
1037 */
1038 udelay(3);
1039
1040 if (status == D40_DEACTIVATE_EVENTLINE)
1041 break;
1042 }
1043
1044 if (tries == D40_SUSPEND_MAX_IT) {
1045 chan_err(d40c,
1046 "unable to stop the event_line chl %d (log: %d)"
1047 "status %x\n", d40c->phy_chan->num,
1048 d40c->log_num, status);
1049 }
1050 break;
1051
1052 case D40_ACTIVATE_EVENTLINE:
991 /* 1053 /*
992 * The hardware sometimes doesn't register the enable when src and dst 1054 * The hardware sometimes doesn't register the enable when src and dst
993 * event lines are active on the same logical channel. Retry to ensure 1055 * event lines are active on the same logical channel. Retry to ensure
994 * it does. Usually only one retry is sufficient. 1056 * it does. Usually only one retry is sufficient.
995 */ 1057 */
996 tries = 100; 1058 tries = 100;
997 while (--tries) { 1059 while (--tries) {
998 writel((D40_ACTIVATE_EVENTLINE << D40_EVENTLINE_POS(event)) 1060 writel((D40_ACTIVATE_EVENTLINE <<
999 | ~D40_EVENTLINE_MASK(event), addr); 1061 D40_EVENTLINE_POS(event)) |
1062 ~D40_EVENTLINE_MASK(event), addr);
1000 1063
1001 if (readl(addr) & D40_EVENTLINE_MASK(event)) 1064 if (readl(addr) & D40_EVENTLINE_MASK(event))
1002 break; 1065 break;
1003 } 1066 }
1004 1067
1005 if (tries != 99) 1068 if (tries != 99)
1006 dev_dbg(chan2dev(d40c), 1069 dev_dbg(chan2dev(d40c),
1007 "[%s] workaround enable S%cLNK (%d tries)\n", 1070 "[%s] workaround enable S%cLNK (%d tries)\n",
1008 __func__, reg == D40_CHAN_REG_SSLNK ? 'S' : 'D', 1071 __func__, reg == D40_CHAN_REG_SSLNK ? 'S' : 'D',
1009 100 - tries); 1072 100 - tries);
1010 1073
1011 WARN_ON(!tries); 1074 WARN_ON(!tries);
1012} 1075 break;
1013 1076
1014static void d40_config_set_event(struct d40_chan *d40c, bool do_enable) 1077 case D40_ROUND_EVENTLINE:
1015{ 1078 BUG();
1016 unsigned long flags; 1079 break;
1017 1080
1018 spin_lock_irqsave(&d40c->phy_chan->lock, flags); 1081 }
1082}
1019 1083
1084static void d40_config_set_event(struct d40_chan *d40c,
1085 enum d40_events event_type)
1086{
1020 /* Enable event line connected to device (or memcpy) */ 1087 /* Enable event line connected to device (or memcpy) */
1021 if ((d40c->dma_cfg.dir == STEDMA40_PERIPH_TO_MEM) || 1088 if ((d40c->dma_cfg.dir == STEDMA40_PERIPH_TO_MEM) ||
1022 (d40c->dma_cfg.dir == STEDMA40_PERIPH_TO_PERIPH)) { 1089 (d40c->dma_cfg.dir == STEDMA40_PERIPH_TO_PERIPH)) {
1023 u32 event = D40_TYPE_TO_EVENT(d40c->dma_cfg.src_dev_type); 1090 u32 event = D40_TYPE_TO_EVENT(d40c->dma_cfg.src_dev_type);
1024 1091
1025 __d40_config_set_event(d40c, do_enable, event, 1092 __d40_config_set_event(d40c, event_type, event,
1026 D40_CHAN_REG_SSLNK); 1093 D40_CHAN_REG_SSLNK);
1027 } 1094 }
1028 1095
1029 if (d40c->dma_cfg.dir != STEDMA40_PERIPH_TO_MEM) { 1096 if (d40c->dma_cfg.dir != STEDMA40_PERIPH_TO_MEM) {
1030 u32 event = D40_TYPE_TO_EVENT(d40c->dma_cfg.dst_dev_type); 1097 u32 event = D40_TYPE_TO_EVENT(d40c->dma_cfg.dst_dev_type);
1031 1098
1032 __d40_config_set_event(d40c, do_enable, event, 1099 __d40_config_set_event(d40c, event_type, event,
1033 D40_CHAN_REG_SDLNK); 1100 D40_CHAN_REG_SDLNK);
1034 } 1101 }
1035
1036 spin_unlock_irqrestore(&d40c->phy_chan->lock, flags);
1037} 1102}
1038 1103
1039static u32 d40_chan_has_events(struct d40_chan *d40c) 1104static u32 d40_chan_has_events(struct d40_chan *d40c)
@@ -1047,6 +1112,64 @@ static u32 d40_chan_has_events(struct d40_chan *d40c)
1047 return val; 1112 return val;
1048} 1113}
1049 1114
1115static int
1116__d40_execute_command_log(struct d40_chan *d40c, enum d40_command command)
1117{
1118 unsigned long flags;
1119 int ret = 0;
1120 u32 active_status;
1121 void __iomem *active_reg;
1122
1123 if (d40c->phy_chan->num % 2 == 0)
1124 active_reg = d40c->base->virtbase + D40_DREG_ACTIVE;
1125 else
1126 active_reg = d40c->base->virtbase + D40_DREG_ACTIVO;
1127
1128
1129 spin_lock_irqsave(&d40c->phy_chan->lock, flags);
1130
1131 switch (command) {
1132 case D40_DMA_STOP:
1133 case D40_DMA_SUSPEND_REQ:
1134
1135 active_status = (readl(active_reg) &
1136 D40_CHAN_POS_MASK(d40c->phy_chan->num)) >>
1137 D40_CHAN_POS(d40c->phy_chan->num);
1138
1139 if (active_status == D40_DMA_RUN)
1140 d40_config_set_event(d40c, D40_SUSPEND_REQ_EVENTLINE);
1141 else
1142 d40_config_set_event(d40c, D40_DEACTIVATE_EVENTLINE);
1143
1144 if (!d40_chan_has_events(d40c) && (command == D40_DMA_STOP))
1145 ret = __d40_execute_command_phy(d40c, command);
1146
1147 break;
1148
1149 case D40_DMA_RUN:
1150
1151 d40_config_set_event(d40c, D40_ACTIVATE_EVENTLINE);
1152 ret = __d40_execute_command_phy(d40c, command);
1153 break;
1154
1155 case D40_DMA_SUSPENDED:
1156 BUG();
1157 break;
1158 }
1159
1160 spin_unlock_irqrestore(&d40c->phy_chan->lock, flags);
1161 return ret;
1162}
1163
1164static int d40_channel_execute_command(struct d40_chan *d40c,
1165 enum d40_command command)
1166{
1167 if (chan_is_logical(d40c))
1168 return __d40_execute_command_log(d40c, command);
1169 else
1170 return __d40_execute_command_phy(d40c, command);
1171}
1172
1050static u32 d40_get_prmo(struct d40_chan *d40c) 1173static u32 d40_get_prmo(struct d40_chan *d40c)
1051{ 1174{
1052 static const unsigned int phy_map[] = { 1175 static const unsigned int phy_map[] = {
@@ -1149,15 +1272,7 @@ static int d40_pause(struct d40_chan *d40c)
1149 spin_lock_irqsave(&d40c->lock, flags); 1272 spin_lock_irqsave(&d40c->lock, flags);
1150 1273
1151 res = d40_channel_execute_command(d40c, D40_DMA_SUSPEND_REQ); 1274 res = d40_channel_execute_command(d40c, D40_DMA_SUSPEND_REQ);
1152 if (res == 0) { 1275
1153 if (chan_is_logical(d40c)) {
1154 d40_config_set_event(d40c, false);
1155 /* Resume the other logical channels if any */
1156 if (d40_chan_has_events(d40c))
1157 res = d40_channel_execute_command(d40c,
1158 D40_DMA_RUN);
1159 }
1160 }
1161 pm_runtime_mark_last_busy(d40c->base->dev); 1276 pm_runtime_mark_last_busy(d40c->base->dev);
1162 pm_runtime_put_autosuspend(d40c->base->dev); 1277 pm_runtime_put_autosuspend(d40c->base->dev);
1163 spin_unlock_irqrestore(&d40c->lock, flags); 1278 spin_unlock_irqrestore(&d40c->lock, flags);
@@ -1174,45 +1289,17 @@ static int d40_resume(struct d40_chan *d40c)
1174 1289
1175 spin_lock_irqsave(&d40c->lock, flags); 1290 spin_lock_irqsave(&d40c->lock, flags);
1176 pm_runtime_get_sync(d40c->base->dev); 1291 pm_runtime_get_sync(d40c->base->dev);
1177 if (d40c->base->rev == 0)
1178 if (chan_is_logical(d40c)) {
1179 res = d40_channel_execute_command(d40c,
1180 D40_DMA_SUSPEND_REQ);
1181 goto no_suspend;
1182 }
1183 1292
1184 /* If bytes left to transfer or linked tx resume job */ 1293 /* If bytes left to transfer or linked tx resume job */
1185 if (d40_residue(d40c) || d40_tx_is_linked(d40c)) { 1294 if (d40_residue(d40c) || d40_tx_is_linked(d40c))
1186
1187 if (chan_is_logical(d40c))
1188 d40_config_set_event(d40c, true);
1189
1190 res = d40_channel_execute_command(d40c, D40_DMA_RUN); 1295 res = d40_channel_execute_command(d40c, D40_DMA_RUN);
1191 }
1192 1296
1193no_suspend:
1194 pm_runtime_mark_last_busy(d40c->base->dev); 1297 pm_runtime_mark_last_busy(d40c->base->dev);
1195 pm_runtime_put_autosuspend(d40c->base->dev); 1298 pm_runtime_put_autosuspend(d40c->base->dev);
1196 spin_unlock_irqrestore(&d40c->lock, flags); 1299 spin_unlock_irqrestore(&d40c->lock, flags);
1197 return res; 1300 return res;
1198} 1301}
1199 1302
1200static int d40_terminate_all(struct d40_chan *chan)
1201{
1202 unsigned long flags;
1203 int ret = 0;
1204
1205 ret = d40_pause(chan);
1206 if (!ret && chan_is_physical(chan))
1207 ret = d40_channel_execute_command(chan, D40_DMA_STOP);
1208
1209 spin_lock_irqsave(&chan->lock, flags);
1210 d40_term_all(chan);
1211 spin_unlock_irqrestore(&chan->lock, flags);
1212
1213 return ret;
1214}
1215
1216static dma_cookie_t d40_tx_submit(struct dma_async_tx_descriptor *tx) 1303static dma_cookie_t d40_tx_submit(struct dma_async_tx_descriptor *tx)
1217{ 1304{
1218 struct d40_chan *d40c = container_of(tx->chan, 1305 struct d40_chan *d40c = container_of(tx->chan,
@@ -1232,20 +1319,6 @@ static dma_cookie_t d40_tx_submit(struct dma_async_tx_descriptor *tx)
1232 1319
1233static int d40_start(struct d40_chan *d40c) 1320static int d40_start(struct d40_chan *d40c)
1234{ 1321{
1235 if (d40c->base->rev == 0) {
1236 int err;
1237
1238 if (chan_is_logical(d40c)) {
1239 err = d40_channel_execute_command(d40c,
1240 D40_DMA_SUSPEND_REQ);
1241 if (err)
1242 return err;
1243 }
1244 }
1245
1246 if (chan_is_logical(d40c))
1247 d40_config_set_event(d40c, true);
1248
1249 return d40_channel_execute_command(d40c, D40_DMA_RUN); 1322 return d40_channel_execute_command(d40c, D40_DMA_RUN);
1250} 1323}
1251 1324
@@ -1258,10 +1331,10 @@ static struct d40_desc *d40_queue_start(struct d40_chan *d40c)
1258 d40d = d40_first_queued(d40c); 1331 d40d = d40_first_queued(d40c);
1259 1332
1260 if (d40d != NULL) { 1333 if (d40d != NULL) {
1261 if (!d40c->busy) 1334 if (!d40c->busy) {
1262 d40c->busy = true; 1335 d40c->busy = true;
1263 1336 pm_runtime_get_sync(d40c->base->dev);
1264 pm_runtime_get_sync(d40c->base->dev); 1337 }
1265 1338
1266 /* Remove from queue */ 1339 /* Remove from queue */
1267 d40_desc_remove(d40d); 1340 d40_desc_remove(d40d);
@@ -1388,8 +1461,8 @@ static void dma_tasklet(unsigned long data)
1388 1461
1389 return; 1462 return;
1390 1463
1391 err: 1464err:
1392 /* Rescue manoeuvre if receiving double interrupts */ 1465 /* Rescue manouver if receiving double interrupts */
1393 if (d40c->pending_tx > 0) 1466 if (d40c->pending_tx > 0)
1394 d40c->pending_tx--; 1467 d40c->pending_tx--;
1395 spin_unlock_irqrestore(&d40c->lock, flags); 1468 spin_unlock_irqrestore(&d40c->lock, flags);
@@ -1770,7 +1843,6 @@ static int d40_config_memcpy(struct d40_chan *d40c)
1770 return 0; 1843 return 0;
1771} 1844}
1772 1845
1773
1774static int d40_free_dma(struct d40_chan *d40c) 1846static int d40_free_dma(struct d40_chan *d40c)
1775{ 1847{
1776 1848
@@ -1806,43 +1878,18 @@ static int d40_free_dma(struct d40_chan *d40c)
1806 } 1878 }
1807 1879
1808 pm_runtime_get_sync(d40c->base->dev); 1880 pm_runtime_get_sync(d40c->base->dev);
1809 res = d40_channel_execute_command(d40c, D40_DMA_SUSPEND_REQ); 1881 res = d40_channel_execute_command(d40c, D40_DMA_STOP);
1810 if (res) { 1882 if (res) {
1811 chan_err(d40c, "suspend failed\n"); 1883 chan_err(d40c, "stop failed\n");
1812 goto out; 1884 goto out;
1813 } 1885 }
1814 1886
1815 if (chan_is_logical(d40c)) { 1887 d40_alloc_mask_free(phy, is_src, chan_is_logical(d40c) ? event : 0);
1816 /* Release logical channel, deactivate the event line */
1817 1888
1818 d40_config_set_event(d40c, false); 1889 if (chan_is_logical(d40c))
1819 d40c->base->lookup_log_chans[d40c->log_num] = NULL; 1890 d40c->base->lookup_log_chans[d40c->log_num] = NULL;
1820 1891 else
1821 /* 1892 d40c->base->lookup_phy_chans[phy->num] = NULL;
1822 * Check if there are more logical allocation
1823 * on this phy channel.
1824 */
1825 if (!d40_alloc_mask_free(phy, is_src, event)) {
1826 /* Resume the other logical channels if any */
1827 if (d40_chan_has_events(d40c)) {
1828 res = d40_channel_execute_command(d40c,
1829 D40_DMA_RUN);
1830 if (res)
1831 chan_err(d40c,
1832 "Executing RUN command\n");
1833 }
1834 goto out;
1835 }
1836 } else {
1837 (void) d40_alloc_mask_free(phy, is_src, 0);
1838 }
1839
1840 /* Release physical channel */
1841 res = d40_channel_execute_command(d40c, D40_DMA_STOP);
1842 if (res) {
1843 chan_err(d40c, "Failed to stop channel\n");
1844 goto out;
1845 }
1846 1893
1847 if (d40c->busy) { 1894 if (d40c->busy) {
1848 pm_runtime_mark_last_busy(d40c->base->dev); 1895 pm_runtime_mark_last_busy(d40c->base->dev);
@@ -1852,7 +1899,6 @@ static int d40_free_dma(struct d40_chan *d40c)
1852 d40c->busy = false; 1899 d40c->busy = false;
1853 d40c->phy_chan = NULL; 1900 d40c->phy_chan = NULL;
1854 d40c->configured = false; 1901 d40c->configured = false;
1855 d40c->base->lookup_phy_chans[phy->num] = NULL;
1856out: 1902out:
1857 1903
1858 pm_runtime_mark_last_busy(d40c->base->dev); 1904 pm_runtime_mark_last_busy(d40c->base->dev);
@@ -2070,7 +2116,7 @@ d40_prep_sg(struct dma_chan *dchan, struct scatterlist *sg_src,
2070 if (sg_next(&sg_src[sg_len - 1]) == sg_src) 2116 if (sg_next(&sg_src[sg_len - 1]) == sg_src)
2071 desc->cyclic = true; 2117 desc->cyclic = true;
2072 2118
2073 if (direction != DMA_NONE) { 2119 if (direction != DMA_TRANS_NONE) {
2074 dma_addr_t dev_addr = d40_get_dev_addr(chan, direction); 2120 dma_addr_t dev_addr = d40_get_dev_addr(chan, direction);
2075 2121
2076 if (direction == DMA_DEV_TO_MEM) 2122 if (direction == DMA_DEV_TO_MEM)
@@ -2371,6 +2417,31 @@ static void d40_issue_pending(struct dma_chan *chan)
2371 spin_unlock_irqrestore(&d40c->lock, flags); 2417 spin_unlock_irqrestore(&d40c->lock, flags);
2372} 2418}
2373 2419
2420static void d40_terminate_all(struct dma_chan *chan)
2421{
2422 unsigned long flags;
2423 struct d40_chan *d40c = container_of(chan, struct d40_chan, chan);
2424 int ret;
2425
2426 spin_lock_irqsave(&d40c->lock, flags);
2427
2428 pm_runtime_get_sync(d40c->base->dev);
2429 ret = d40_channel_execute_command(d40c, D40_DMA_STOP);
2430 if (ret)
2431 chan_err(d40c, "Failed to stop channel\n");
2432
2433 d40_term_all(d40c);
2434 pm_runtime_mark_last_busy(d40c->base->dev);
2435 pm_runtime_put_autosuspend(d40c->base->dev);
2436 if (d40c->busy) {
2437 pm_runtime_mark_last_busy(d40c->base->dev);
2438 pm_runtime_put_autosuspend(d40c->base->dev);
2439 }
2440 d40c->busy = false;
2441
2442 spin_unlock_irqrestore(&d40c->lock, flags);
2443}
2444
2374static int 2445static int
2375dma40_config_to_halfchannel(struct d40_chan *d40c, 2446dma40_config_to_halfchannel(struct d40_chan *d40c,
2376 struct stedma40_half_channel_info *info, 2447 struct stedma40_half_channel_info *info,
@@ -2551,7 +2622,8 @@ static int d40_control(struct dma_chan *chan, enum dma_ctrl_cmd cmd,
2551 2622
2552 switch (cmd) { 2623 switch (cmd) {
2553 case DMA_TERMINATE_ALL: 2624 case DMA_TERMINATE_ALL:
2554 return d40_terminate_all(d40c); 2625 d40_terminate_all(chan);
2626 return 0;
2555 case DMA_PAUSE: 2627 case DMA_PAUSE:
2556 return d40_pause(d40c); 2628 return d40_pause(d40c);
2557 case DMA_RESUME: 2629 case DMA_RESUME:
@@ -2908,6 +2980,12 @@ static struct d40_base * __init d40_hw_detect_init(struct platform_device *pdev)
2908 dev_info(&pdev->dev, "hardware revision: %d @ 0x%x\n", 2980 dev_info(&pdev->dev, "hardware revision: %d @ 0x%x\n",
2909 rev, res->start); 2981 rev, res->start);
2910 2982
2983 if (rev < 2) {
2984 d40_err(&pdev->dev, "hardware revision: %d is not supported",
2985 rev);
2986 goto failure;
2987 }
2988
2911 plat_data = pdev->dev.platform_data; 2989 plat_data = pdev->dev.platform_data;
2912 2990
2913 /* Count the number of logical channels in use */ 2991 /* Count the number of logical channels in use */
@@ -2998,6 +3076,7 @@ failure:
2998 3076
2999 if (base) { 3077 if (base) {
3000 kfree(base->lcla_pool.alloc_map); 3078 kfree(base->lcla_pool.alloc_map);
3079 kfree(base->reg_val_backup_chan);
3001 kfree(base->lookup_log_chans); 3080 kfree(base->lookup_log_chans);
3002 kfree(base->lookup_phy_chans); 3081 kfree(base->lookup_phy_chans);
3003 kfree(base->phy_res); 3082 kfree(base->phy_res);
diff --git a/drivers/dma/ste_dma40_ll.h b/drivers/dma/ste_dma40_ll.h
index 8d3d490968a3..51e8e5396e9b 100644
--- a/drivers/dma/ste_dma40_ll.h
+++ b/drivers/dma/ste_dma40_ll.h
@@ -62,8 +62,6 @@
62#define D40_SREG_ELEM_LOG_LIDX_MASK (0xFF << D40_SREG_ELEM_LOG_LIDX_POS) 62#define D40_SREG_ELEM_LOG_LIDX_MASK (0xFF << D40_SREG_ELEM_LOG_LIDX_POS)
63 63
64/* Link register */ 64/* Link register */
65#define D40_DEACTIVATE_EVENTLINE 0x0
66#define D40_ACTIVATE_EVENTLINE 0x1
67#define D40_EVENTLINE_POS(i) (2 * i) 65#define D40_EVENTLINE_POS(i) (2 * i)
68#define D40_EVENTLINE_MASK(i) (0x3 << D40_EVENTLINE_POS(i)) 66#define D40_EVENTLINE_MASK(i) (0x3 << D40_EVENTLINE_POS(i))
69 67
diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig
index edadbdad31d0..e03653d69357 100644
--- a/drivers/gpio/Kconfig
+++ b/drivers/gpio/Kconfig
@@ -430,7 +430,7 @@ config GPIO_ML_IOH
430 430
431config GPIO_SODAVILLE 431config GPIO_SODAVILLE
432 bool "Intel Sodaville GPIO support" 432 bool "Intel Sodaville GPIO support"
433 depends on X86 && PCI && OF && BROKEN 433 depends on X86 && PCI && OF
434 select GPIO_GENERIC 434 select GPIO_GENERIC
435 select GENERIC_IRQ_CHIP 435 select GENERIC_IRQ_CHIP
436 help 436 help
diff --git a/drivers/gpio/gpio-adp5588.c b/drivers/gpio/gpio-adp5588.c
index 9ad1703d1408..ae5d7f12ce66 100644
--- a/drivers/gpio/gpio-adp5588.c
+++ b/drivers/gpio/gpio-adp5588.c
@@ -252,7 +252,7 @@ static irqreturn_t adp5588_irq_handler(int irq, void *devid)
252 if (ret < 0) 252 if (ret < 0)
253 memset(dev->irq_stat, 0, ARRAY_SIZE(dev->irq_stat)); 253 memset(dev->irq_stat, 0, ARRAY_SIZE(dev->irq_stat));
254 254
255 for (bank = 0; bank <= ADP5588_BANK(ADP5588_MAXGPIO); 255 for (bank = 0, bit = 0; bank <= ADP5588_BANK(ADP5588_MAXGPIO);
256 bank++, bit = 0) { 256 bank++, bit = 0) {
257 pending = dev->irq_stat[bank] & dev->irq_mask[bank]; 257 pending = dev->irq_stat[bank] & dev->irq_mask[bank];
258 258
diff --git a/drivers/gpio/gpio-pxa.c b/drivers/gpio/gpio-pxa.c
index 5689ce62fd81..fc3ace3fd4cb 100644
--- a/drivers/gpio/gpio-pxa.c
+++ b/drivers/gpio/gpio-pxa.c
@@ -64,6 +64,7 @@ struct pxa_gpio_chip {
64 unsigned long irq_mask; 64 unsigned long irq_mask;
65 unsigned long irq_edge_rise; 65 unsigned long irq_edge_rise;
66 unsigned long irq_edge_fall; 66 unsigned long irq_edge_fall;
67 int (*set_wake)(unsigned int gpio, unsigned int on);
67 68
68#ifdef CONFIG_PM 69#ifdef CONFIG_PM
69 unsigned long saved_gplr; 70 unsigned long saved_gplr;
@@ -269,7 +270,8 @@ static void pxa_gpio_set(struct gpio_chip *chip, unsigned offset, int value)
269 (value ? GPSR_OFFSET : GPCR_OFFSET)); 270 (value ? GPSR_OFFSET : GPCR_OFFSET));
270} 271}
271 272
272static int __devinit pxa_init_gpio_chip(int gpio_end) 273static int __devinit pxa_init_gpio_chip(int gpio_end,
274 int (*set_wake)(unsigned int, unsigned int))
273{ 275{
274 int i, gpio, nbanks = gpio_to_bank(gpio_end) + 1; 276 int i, gpio, nbanks = gpio_to_bank(gpio_end) + 1;
275 struct pxa_gpio_chip *chips; 277 struct pxa_gpio_chip *chips;
@@ -285,6 +287,7 @@ static int __devinit pxa_init_gpio_chip(int gpio_end)
285 287
286 sprintf(chips[i].label, "gpio-%d", i); 288 sprintf(chips[i].label, "gpio-%d", i);
287 chips[i].regbase = gpio_reg_base + BANK_OFF(i); 289 chips[i].regbase = gpio_reg_base + BANK_OFF(i);
290 chips[i].set_wake = set_wake;
288 291
289 c->base = gpio; 292 c->base = gpio;
290 c->label = chips[i].label; 293 c->label = chips[i].label;
@@ -412,6 +415,17 @@ static void pxa_mask_muxed_gpio(struct irq_data *d)
412 writel_relaxed(gfer, c->regbase + GFER_OFFSET); 415 writel_relaxed(gfer, c->regbase + GFER_OFFSET);
413} 416}
414 417
418static int pxa_gpio_set_wake(struct irq_data *d, unsigned int on)
419{
420 int gpio = pxa_irq_to_gpio(d->irq);
421 struct pxa_gpio_chip *c = gpio_to_pxachip(gpio);
422
423 if (c->set_wake)
424 return c->set_wake(gpio, on);
425 else
426 return 0;
427}
428
415static void pxa_unmask_muxed_gpio(struct irq_data *d) 429static void pxa_unmask_muxed_gpio(struct irq_data *d)
416{ 430{
417 int gpio = pxa_irq_to_gpio(d->irq); 431 int gpio = pxa_irq_to_gpio(d->irq);
@@ -427,6 +441,7 @@ static struct irq_chip pxa_muxed_gpio_chip = {
427 .irq_mask = pxa_mask_muxed_gpio, 441 .irq_mask = pxa_mask_muxed_gpio,
428 .irq_unmask = pxa_unmask_muxed_gpio, 442 .irq_unmask = pxa_unmask_muxed_gpio,
429 .irq_set_type = pxa_gpio_irq_type, 443 .irq_set_type = pxa_gpio_irq_type,
444 .irq_set_wake = pxa_gpio_set_wake,
430}; 445};
431 446
432static int pxa_gpio_nums(void) 447static int pxa_gpio_nums(void)
@@ -471,6 +486,7 @@ static int __devinit pxa_gpio_probe(struct platform_device *pdev)
471 struct pxa_gpio_chip *c; 486 struct pxa_gpio_chip *c;
472 struct resource *res; 487 struct resource *res;
473 struct clk *clk; 488 struct clk *clk;
489 struct pxa_gpio_platform_data *info;
474 int gpio, irq, ret; 490 int gpio, irq, ret;
475 int irq0 = 0, irq1 = 0, irq_mux, gpio_offset = 0; 491 int irq0 = 0, irq1 = 0, irq_mux, gpio_offset = 0;
476 492
@@ -516,7 +532,8 @@ static int __devinit pxa_gpio_probe(struct platform_device *pdev)
516 } 532 }
517 533
518 /* Initialize GPIO chips */ 534 /* Initialize GPIO chips */
519 pxa_init_gpio_chip(pxa_last_gpio); 535 info = dev_get_platdata(&pdev->dev);
536 pxa_init_gpio_chip(pxa_last_gpio, info ? info->gpio_set_wake : NULL);
520 537
521 /* clear all GPIO edge detects */ 538 /* clear all GPIO edge detects */
522 for_each_gpio_chip(gpio, c) { 539 for_each_gpio_chip(gpio, c) {
diff --git a/drivers/gpio/gpio-samsung.c b/drivers/gpio/gpio-samsung.c
index 46277877b7ec..19d6fc0229c3 100644
--- a/drivers/gpio/gpio-samsung.c
+++ b/drivers/gpio/gpio-samsung.c
@@ -2382,8 +2382,8 @@ static struct samsung_gpio_chip exynos4_gpios_3[] = {
2382#endif 2382#endif
2383}; 2383};
2384 2384
2385static struct samsung_gpio_chip exynos5_gpios_1[] = {
2386#ifdef CONFIG_ARCH_EXYNOS5 2385#ifdef CONFIG_ARCH_EXYNOS5
2386static struct samsung_gpio_chip exynos5_gpios_1[] = {
2387 { 2387 {
2388 .chip = { 2388 .chip = {
2389 .base = EXYNOS5_GPA0(0), 2389 .base = EXYNOS5_GPA0(0),
@@ -2541,11 +2541,11 @@ static struct samsung_gpio_chip exynos5_gpios_1[] = {
2541 .to_irq = samsung_gpiolib_to_irq, 2541 .to_irq = samsung_gpiolib_to_irq,
2542 }, 2542 },
2543 }, 2543 },
2544#endif
2545}; 2544};
2545#endif
2546 2546
2547static struct samsung_gpio_chip exynos5_gpios_2[] = {
2548#ifdef CONFIG_ARCH_EXYNOS5 2547#ifdef CONFIG_ARCH_EXYNOS5
2548static struct samsung_gpio_chip exynos5_gpios_2[] = {
2549 { 2549 {
2550 .chip = { 2550 .chip = {
2551 .base = EXYNOS5_GPE0(0), 2551 .base = EXYNOS5_GPE0(0),
@@ -2602,11 +2602,11 @@ static struct samsung_gpio_chip exynos5_gpios_2[] = {
2602 2602
2603 }, 2603 },
2604 }, 2604 },
2605#endif
2606}; 2605};
2606#endif
2607 2607
2608static struct samsung_gpio_chip exynos5_gpios_3[] = {
2609#ifdef CONFIG_ARCH_EXYNOS5 2608#ifdef CONFIG_ARCH_EXYNOS5
2609static struct samsung_gpio_chip exynos5_gpios_3[] = {
2610 { 2610 {
2611 .chip = { 2611 .chip = {
2612 .base = EXYNOS5_GPV0(0), 2612 .base = EXYNOS5_GPV0(0),
@@ -2638,11 +2638,11 @@ static struct samsung_gpio_chip exynos5_gpios_3[] = {
2638 .label = "GPV4", 2638 .label = "GPV4",
2639 }, 2639 },
2640 }, 2640 },
2641#endif
2642}; 2641};
2642#endif
2643 2643
2644static struct samsung_gpio_chip exynos5_gpios_4[] = {
2645#ifdef CONFIG_ARCH_EXYNOS5 2644#ifdef CONFIG_ARCH_EXYNOS5
2645static struct samsung_gpio_chip exynos5_gpios_4[] = {
2646 { 2646 {
2647 .chip = { 2647 .chip = {
2648 .base = EXYNOS5_GPZ(0), 2648 .base = EXYNOS5_GPZ(0),
@@ -2650,8 +2650,8 @@ static struct samsung_gpio_chip exynos5_gpios_4[] = {
2650 .label = "GPZ", 2650 .label = "GPZ",
2651 }, 2651 },
2652 }, 2652 },
2653#endif
2654}; 2653};
2654#endif
2655 2655
2656 2656
2657#if defined(CONFIG_ARCH_EXYNOS) && defined(CONFIG_OF) 2657#if defined(CONFIG_ARCH_EXYNOS) && defined(CONFIG_OF)
diff --git a/drivers/gpio/gpio-sodaville.c b/drivers/gpio/gpio-sodaville.c
index 9ba15d31d242..031e5d24837d 100644
--- a/drivers/gpio/gpio-sodaville.c
+++ b/drivers/gpio/gpio-sodaville.c
@@ -41,7 +41,7 @@
41struct sdv_gpio_chip_data { 41struct sdv_gpio_chip_data {
42 int irq_base; 42 int irq_base;
43 void __iomem *gpio_pub_base; 43 void __iomem *gpio_pub_base;
44 struct irq_domain id; 44 struct irq_domain *id;
45 struct irq_chip_generic *gc; 45 struct irq_chip_generic *gc;
46 struct bgpio_chip bgpio; 46 struct bgpio_chip bgpio;
47}; 47};
@@ -51,10 +51,9 @@ static int sdv_gpio_pub_set_type(struct irq_data *d, unsigned int type)
51 struct irq_chip_generic *gc = irq_data_get_irq_chip_data(d); 51 struct irq_chip_generic *gc = irq_data_get_irq_chip_data(d);
52 struct sdv_gpio_chip_data *sd = gc->private; 52 struct sdv_gpio_chip_data *sd = gc->private;
53 void __iomem *type_reg; 53 void __iomem *type_reg;
54 u32 irq_offs = d->irq - sd->irq_base;
55 u32 reg; 54 u32 reg;
56 55
57 if (irq_offs < 8) 56 if (d->hwirq < 8)
58 type_reg = sd->gpio_pub_base + GPIT1R0; 57 type_reg = sd->gpio_pub_base + GPIT1R0;
59 else 58 else
60 type_reg = sd->gpio_pub_base + GPIT1R1; 59 type_reg = sd->gpio_pub_base + GPIT1R1;
@@ -63,11 +62,11 @@ static int sdv_gpio_pub_set_type(struct irq_data *d, unsigned int type)
63 62
64 switch (type) { 63 switch (type) {
65 case IRQ_TYPE_LEVEL_HIGH: 64 case IRQ_TYPE_LEVEL_HIGH:
66 reg &= ~BIT(4 * (irq_offs % 8)); 65 reg &= ~BIT(4 * (d->hwirq % 8));
67 break; 66 break;
68 67
69 case IRQ_TYPE_LEVEL_LOW: 68 case IRQ_TYPE_LEVEL_LOW:
70 reg |= BIT(4 * (irq_offs % 8)); 69 reg |= BIT(4 * (d->hwirq % 8));
71 break; 70 break;
72 71
73 default: 72 default:
@@ -91,7 +90,7 @@ static irqreturn_t sdv_gpio_pub_irq_handler(int irq, void *data)
91 u32 irq_bit = __fls(irq_stat); 90 u32 irq_bit = __fls(irq_stat);
92 91
93 irq_stat &= ~BIT(irq_bit); 92 irq_stat &= ~BIT(irq_bit);
94 generic_handle_irq(sd->irq_base + irq_bit); 93 generic_handle_irq(irq_find_mapping(sd->id, irq_bit));
95 } 94 }
96 95
97 return IRQ_HANDLED; 96 return IRQ_HANDLED;
@@ -127,7 +126,7 @@ static int sdv_xlate(struct irq_domain *h, struct device_node *node,
127} 126}
128 127
129static struct irq_domain_ops irq_domain_sdv_ops = { 128static struct irq_domain_ops irq_domain_sdv_ops = {
130 .dt_translate = sdv_xlate, 129 .xlate = sdv_xlate,
131}; 130};
132 131
133static __devinit int sdv_register_irqsupport(struct sdv_gpio_chip_data *sd, 132static __devinit int sdv_register_irqsupport(struct sdv_gpio_chip_data *sd,
@@ -149,10 +148,6 @@ static __devinit int sdv_register_irqsupport(struct sdv_gpio_chip_data *sd,
149 if (ret) 148 if (ret)
150 goto out_free_desc; 149 goto out_free_desc;
151 150
152 sd->id.irq_base = sd->irq_base;
153 sd->id.of_node = of_node_get(pdev->dev.of_node);
154 sd->id.ops = &irq_domain_sdv_ops;
155
156 /* 151 /*
157 * This gpio irq controller latches level irqs. Testing shows that if 152 * This gpio irq controller latches level irqs. Testing shows that if
158 * we unmask & ACK the IRQ before the source of the interrupt is gone 153 * we unmask & ACK the IRQ before the source of the interrupt is gone
@@ -179,7 +174,10 @@ static __devinit int sdv_register_irqsupport(struct sdv_gpio_chip_data *sd,
179 IRQ_GC_INIT_MASK_CACHE, IRQ_NOREQUEST, 174 IRQ_GC_INIT_MASK_CACHE, IRQ_NOREQUEST,
180 IRQ_LEVEL | IRQ_NOPROBE); 175 IRQ_LEVEL | IRQ_NOPROBE);
181 176
182 irq_domain_add(&sd->id); 177 sd->id = irq_domain_add_legacy(pdev->dev.of_node, SDV_NUM_PUB_GPIOS,
178 sd->irq_base, 0, &irq_domain_sdv_ops, sd);
179 if (!sd->id)
180 goto out_free_irq;
183 return 0; 181 return 0;
184out_free_irq: 182out_free_irq:
185 free_irq(pdev->irq, sd); 183 free_irq(pdev->irq, sd);
@@ -260,7 +258,6 @@ static void sdv_gpio_remove(struct pci_dev *pdev)
260{ 258{
261 struct sdv_gpio_chip_data *sd = pci_get_drvdata(pdev); 259 struct sdv_gpio_chip_data *sd = pci_get_drvdata(pdev);
262 260
263 irq_domain_del(&sd->id);
264 free_irq(pdev->irq, sd); 261 free_irq(pdev->irq, sd);
265 irq_free_descs(sd->irq_base, SDV_NUM_PUB_GPIOS); 262 irq_free_descs(sd->irq_base, SDV_NUM_PUB_GPIOS);
266 263
diff --git a/drivers/gpu/drm/drm_bufs.c b/drivers/gpu/drm/drm_bufs.c
index 30372f7b2d45..348b367debeb 100644
--- a/drivers/gpu/drm/drm_bufs.c
+++ b/drivers/gpu/drm/drm_bufs.c
@@ -1510,8 +1510,8 @@ int drm_freebufs(struct drm_device *dev, void *data,
1510 * \param arg pointer to a drm_buf_map structure. 1510 * \param arg pointer to a drm_buf_map structure.
1511 * \return zero on success or a negative number on failure. 1511 * \return zero on success or a negative number on failure.
1512 * 1512 *
1513 * Maps the AGP, SG or PCI buffer region with do_mmap(), and copies information 1513 * Maps the AGP, SG or PCI buffer region with vm_mmap(), and copies information
1514 * about each buffer into user space. For PCI buffers, it calls do_mmap() with 1514 * about each buffer into user space. For PCI buffers, it calls vm_mmap() with
1515 * offset equal to 0, which drm_mmap() interpretes as PCI buffers and calls 1515 * offset equal to 0, which drm_mmap() interpretes as PCI buffers and calls
1516 * drm_mmap_dma(). 1516 * drm_mmap_dma().
1517 */ 1517 */
@@ -1553,18 +1553,14 @@ int drm_mapbufs(struct drm_device *dev, void *data,
1553 retcode = -EINVAL; 1553 retcode = -EINVAL;
1554 goto done; 1554 goto done;
1555 } 1555 }
1556 down_write(&current->mm->mmap_sem); 1556 virtual = vm_mmap(file_priv->filp, 0, map->size,
1557 virtual = do_mmap(file_priv->filp, 0, map->size,
1558 PROT_READ | PROT_WRITE, 1557 PROT_READ | PROT_WRITE,
1559 MAP_SHARED, 1558 MAP_SHARED,
1560 token); 1559 token);
1561 up_write(&current->mm->mmap_sem);
1562 } else { 1560 } else {
1563 down_write(&current->mm->mmap_sem); 1561 virtual = vm_mmap(file_priv->filp, 0, dma->byte_count,
1564 virtual = do_mmap(file_priv->filp, 0, dma->byte_count,
1565 PROT_READ | PROT_WRITE, 1562 PROT_READ | PROT_WRITE,
1566 MAP_SHARED, 0); 1563 MAP_SHARED, 0);
1567 up_write(&current->mm->mmap_sem);
1568 } 1564 }
1569 if (virtual > -1024UL) { 1565 if (virtual > -1024UL) {
1570 /* Real error */ 1566 /* Real error */
diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
index d3aaeb6ae236..c79870a75c2f 100644
--- a/drivers/gpu/drm/drm_crtc.c
+++ b/drivers/gpu/drm/drm_crtc.c
@@ -3335,10 +3335,12 @@ int drm_mode_page_flip_ioctl(struct drm_device *dev,
3335 3335
3336 ret = crtc->funcs->page_flip(crtc, fb, e); 3336 ret = crtc->funcs->page_flip(crtc, fb, e);
3337 if (ret) { 3337 if (ret) {
3338 spin_lock_irqsave(&dev->event_lock, flags); 3338 if (page_flip->flags & DRM_MODE_PAGE_FLIP_EVENT) {
3339 file_priv->event_space += sizeof e->event; 3339 spin_lock_irqsave(&dev->event_lock, flags);
3340 spin_unlock_irqrestore(&dev->event_lock, flags); 3340 file_priv->event_space += sizeof e->event;
3341 kfree(e); 3341 spin_unlock_irqrestore(&dev->event_lock, flags);
3342 kfree(e);
3343 }
3342 } 3344 }
3343 3345
3344out: 3346out:
diff --git a/drivers/gpu/drm/drm_fops.c b/drivers/gpu/drm/drm_fops.c
index cdfbf27b2b3c..123de28f94ef 100644
--- a/drivers/gpu/drm/drm_fops.c
+++ b/drivers/gpu/drm/drm_fops.c
@@ -507,12 +507,12 @@ int drm_release(struct inode *inode, struct file *filp)
507 507
508 drm_events_release(file_priv); 508 drm_events_release(file_priv);
509 509
510 if (dev->driver->driver_features & DRIVER_GEM)
511 drm_gem_release(dev, file_priv);
512
513 if (dev->driver->driver_features & DRIVER_MODESET) 510 if (dev->driver->driver_features & DRIVER_MODESET)
514 drm_fb_release(file_priv); 511 drm_fb_release(file_priv);
515 512
513 if (dev->driver->driver_features & DRIVER_GEM)
514 drm_gem_release(dev, file_priv);
515
516 mutex_lock(&dev->ctxlist_mutex); 516 mutex_lock(&dev->ctxlist_mutex);
517 if (!list_empty(&dev->ctxlist)) { 517 if (!list_empty(&dev->ctxlist)) {
518 struct drm_ctx_list *pos, *n; 518 struct drm_ctx_list *pos, *n;
diff --git a/drivers/gpu/drm/drm_usb.c b/drivers/gpu/drm/drm_usb.c
index c8c83dad2ce1..37c9a523dd1c 100644
--- a/drivers/gpu/drm/drm_usb.c
+++ b/drivers/gpu/drm/drm_usb.c
@@ -1,6 +1,6 @@
1#include "drmP.h" 1#include "drmP.h"
2#include <linux/usb.h> 2#include <linux/usb.h>
3#include <linux/export.h> 3#include <linux/module.h>
4 4
5int drm_get_usb_dev(struct usb_interface *interface, 5int drm_get_usb_dev(struct usb_interface *interface,
6 const struct usb_device_id *id, 6 const struct usb_device_id *id,
@@ -114,3 +114,7 @@ void drm_usb_exit(struct drm_driver *driver,
114 usb_deregister(udriver); 114 usb_deregister(udriver);
115} 115}
116EXPORT_SYMBOL(drm_usb_exit); 116EXPORT_SYMBOL(drm_usb_exit);
117
118MODULE_AUTHOR("David Airlie");
119MODULE_DESCRIPTION("USB DRM support");
120MODULE_LICENSE("GPL and additional rights");
diff --git a/drivers/gpu/drm/exynos/exynos_drm_buf.c b/drivers/gpu/drm/exynos/exynos_drm_buf.c
index 4a3a5f72ed4a..de8d2090bce3 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_buf.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_buf.c
@@ -34,14 +34,14 @@
34static int lowlevel_buffer_allocate(struct drm_device *dev, 34static int lowlevel_buffer_allocate(struct drm_device *dev,
35 unsigned int flags, struct exynos_drm_gem_buf *buf) 35 unsigned int flags, struct exynos_drm_gem_buf *buf)
36{ 36{
37 dma_addr_t start_addr, end_addr; 37 dma_addr_t start_addr;
38 unsigned int npages, page_size, i = 0; 38 unsigned int npages, page_size, i = 0;
39 struct scatterlist *sgl; 39 struct scatterlist *sgl;
40 int ret = 0; 40 int ret = 0;
41 41
42 DRM_DEBUG_KMS("%s\n", __FILE__); 42 DRM_DEBUG_KMS("%s\n", __FILE__);
43 43
44 if (flags & EXYNOS_BO_NONCONTIG) { 44 if (IS_NONCONTIG_BUFFER(flags)) {
45 DRM_DEBUG_KMS("not support allocation type.\n"); 45 DRM_DEBUG_KMS("not support allocation type.\n");
46 return -EINVAL; 46 return -EINVAL;
47 } 47 }
@@ -52,13 +52,13 @@ static int lowlevel_buffer_allocate(struct drm_device *dev,
52 } 52 }
53 53
54 if (buf->size >= SZ_1M) { 54 if (buf->size >= SZ_1M) {
55 npages = (buf->size >> SECTION_SHIFT) + 1; 55 npages = buf->size >> SECTION_SHIFT;
56 page_size = SECTION_SIZE; 56 page_size = SECTION_SIZE;
57 } else if (buf->size >= SZ_64K) { 57 } else if (buf->size >= SZ_64K) {
58 npages = (buf->size >> 16) + 1; 58 npages = buf->size >> 16;
59 page_size = SZ_64K; 59 page_size = SZ_64K;
60 } else { 60 } else {
61 npages = (buf->size >> PAGE_SHIFT) + 1; 61 npages = buf->size >> PAGE_SHIFT;
62 page_size = PAGE_SIZE; 62 page_size = PAGE_SIZE;
63 } 63 }
64 64
@@ -76,26 +76,13 @@ static int lowlevel_buffer_allocate(struct drm_device *dev,
76 return -ENOMEM; 76 return -ENOMEM;
77 } 77 }
78 78
79 buf->kvaddr = dma_alloc_writecombine(dev->dev, buf->size, 79 buf->kvaddr = dma_alloc_writecombine(dev->dev, buf->size,
80 &buf->dma_addr, GFP_KERNEL); 80 &buf->dma_addr, GFP_KERNEL);
81 if (!buf->kvaddr) { 81 if (!buf->kvaddr) {
82 DRM_ERROR("failed to allocate buffer.\n"); 82 DRM_ERROR("failed to allocate buffer.\n");
83 ret = -ENOMEM; 83 ret = -ENOMEM;
84 goto err1; 84 goto err1;
85 } 85 }
86
87 start_addr = buf->dma_addr;
88 end_addr = buf->dma_addr + buf->size;
89
90 buf->pages = kzalloc(sizeof(struct page) * npages, GFP_KERNEL);
91 if (!buf->pages) {
92 DRM_ERROR("failed to allocate pages.\n");
93 ret = -ENOMEM;
94 goto err2;
95 }
96
97 start_addr = buf->dma_addr;
98 end_addr = buf->dma_addr + buf->size;
99 86
100 buf->pages = kzalloc(sizeof(struct page) * npages, GFP_KERNEL); 87 buf->pages = kzalloc(sizeof(struct page) * npages, GFP_KERNEL);
101 if (!buf->pages) { 88 if (!buf->pages) {
@@ -105,23 +92,17 @@ static int lowlevel_buffer_allocate(struct drm_device *dev,
105 } 92 }
106 93
107 sgl = buf->sgt->sgl; 94 sgl = buf->sgt->sgl;
95 start_addr = buf->dma_addr;
108 96
109 while (i < npages) { 97 while (i < npages) {
110 buf->pages[i] = phys_to_page(start_addr); 98 buf->pages[i] = phys_to_page(start_addr);
111 sg_set_page(sgl, buf->pages[i], page_size, 0); 99 sg_set_page(sgl, buf->pages[i], page_size, 0);
112 sg_dma_address(sgl) = start_addr; 100 sg_dma_address(sgl) = start_addr;
113 start_addr += page_size; 101 start_addr += page_size;
114 if (end_addr - start_addr < page_size)
115 break;
116 sgl = sg_next(sgl); 102 sgl = sg_next(sgl);
117 i++; 103 i++;
118 } 104 }
119 105
120 buf->pages[i] = phys_to_page(start_addr);
121
122 sgl = sg_next(sgl);
123 sg_set_page(sgl, buf->pages[i+1], end_addr - start_addr, 0);
124
125 DRM_DEBUG_KMS("vaddr(0x%lx), dma_addr(0x%lx), size(0x%lx)\n", 106 DRM_DEBUG_KMS("vaddr(0x%lx), dma_addr(0x%lx), size(0x%lx)\n",
126 (unsigned long)buf->kvaddr, 107 (unsigned long)buf->kvaddr,
127 (unsigned long)buf->dma_addr, 108 (unsigned long)buf->dma_addr,
@@ -150,7 +131,7 @@ static void lowlevel_buffer_deallocate(struct drm_device *dev,
150 * non-continuous memory would be released by exynos 131 * non-continuous memory would be released by exynos
151 * gem framework. 132 * gem framework.
152 */ 133 */
153 if (flags & EXYNOS_BO_NONCONTIG) { 134 if (IS_NONCONTIG_BUFFER(flags)) {
154 DRM_DEBUG_KMS("not support allocation type.\n"); 135 DRM_DEBUG_KMS("not support allocation type.\n");
155 return; 136 return;
156 } 137 }
diff --git a/drivers/gpu/drm/exynos/exynos_drm_core.c b/drivers/gpu/drm/exynos/exynos_drm_core.c
index 411832e8e17a..eaf630dc5dba 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_core.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_core.c
@@ -54,16 +54,18 @@ static int exynos_drm_subdrv_probe(struct drm_device *dev,
54 * 54 *
55 * P.S. note that this driver is considered for modularization. 55 * P.S. note that this driver is considered for modularization.
56 */ 56 */
57 ret = subdrv->probe(dev, subdrv->manager.dev); 57 ret = subdrv->probe(dev, subdrv->dev);
58 if (ret) 58 if (ret)
59 return ret; 59 return ret;
60 } 60 }
61 61
62 if (subdrv->is_local) 62 if (!subdrv->manager)
63 return 0; 63 return 0;
64 64
65 subdrv->manager->dev = subdrv->dev;
66
65 /* create and initialize a encoder for this sub driver. */ 67 /* create and initialize a encoder for this sub driver. */
66 encoder = exynos_drm_encoder_create(dev, &subdrv->manager, 68 encoder = exynos_drm_encoder_create(dev, subdrv->manager,
67 (1 << MAX_CRTC) - 1); 69 (1 << MAX_CRTC) - 1);
68 if (!encoder) { 70 if (!encoder) {
69 DRM_ERROR("failed to create encoder\n"); 71 DRM_ERROR("failed to create encoder\n");
@@ -186,7 +188,7 @@ int exynos_drm_subdrv_open(struct drm_device *dev, struct drm_file *file)
186 188
187 list_for_each_entry(subdrv, &exynos_drm_subdrv_list, list) { 189 list_for_each_entry(subdrv, &exynos_drm_subdrv_list, list) {
188 if (subdrv->open) { 190 if (subdrv->open) {
189 ret = subdrv->open(dev, subdrv->manager.dev, file); 191 ret = subdrv->open(dev, subdrv->dev, file);
190 if (ret) 192 if (ret)
191 goto err; 193 goto err;
192 } 194 }
@@ -197,7 +199,7 @@ int exynos_drm_subdrv_open(struct drm_device *dev, struct drm_file *file)
197err: 199err:
198 list_for_each_entry_reverse(subdrv, &subdrv->list, list) { 200 list_for_each_entry_reverse(subdrv, &subdrv->list, list) {
199 if (subdrv->close) 201 if (subdrv->close)
200 subdrv->close(dev, subdrv->manager.dev, file); 202 subdrv->close(dev, subdrv->dev, file);
201 } 203 }
202 return ret; 204 return ret;
203} 205}
@@ -209,7 +211,7 @@ void exynos_drm_subdrv_close(struct drm_device *dev, struct drm_file *file)
209 211
210 list_for_each_entry(subdrv, &exynos_drm_subdrv_list, list) { 212 list_for_each_entry(subdrv, &exynos_drm_subdrv_list, list) {
211 if (subdrv->close) 213 if (subdrv->close)
212 subdrv->close(dev, subdrv->manager.dev, file); 214 subdrv->close(dev, subdrv->dev, file);
213 } 215 }
214} 216}
215EXPORT_SYMBOL_GPL(exynos_drm_subdrv_close); 217EXPORT_SYMBOL_GPL(exynos_drm_subdrv_close);
diff --git a/drivers/gpu/drm/exynos/exynos_drm_drv.h b/drivers/gpu/drm/exynos/exynos_drm_drv.h
index fbd0a232c93d..1d814175cd49 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_drv.h
+++ b/drivers/gpu/drm/exynos/exynos_drm_drv.h
@@ -225,24 +225,25 @@ struct exynos_drm_private {
225 * Exynos drm sub driver structure. 225 * Exynos drm sub driver structure.
226 * 226 *
227 * @list: sub driver has its own list object to register to exynos drm driver. 227 * @list: sub driver has its own list object to register to exynos drm driver.
228 * @dev: pointer to device object for subdrv device driver.
228 * @drm_dev: pointer to drm_device and this pointer would be set 229 * @drm_dev: pointer to drm_device and this pointer would be set
229 * when sub driver calls exynos_drm_subdrv_register(). 230 * when sub driver calls exynos_drm_subdrv_register().
230 * @is_local: appear encoder and connector disrelated device. 231 * @manager: subdrv has its own manager to control a hardware appropriately
232 * and we can access a hardware drawing on this manager.
231 * @probe: this callback would be called by exynos drm driver after 233 * @probe: this callback would be called by exynos drm driver after
232 * subdrv is registered to it. 234 * subdrv is registered to it.
233 * @remove: this callback is used to release resources created 235 * @remove: this callback is used to release resources created
234 * by probe callback. 236 * by probe callback.
235 * @open: this would be called with drm device file open. 237 * @open: this would be called with drm device file open.
236 * @close: this would be called with drm device file close. 238 * @close: this would be called with drm device file close.
237 * @manager: subdrv has its own manager to control a hardware appropriately
238 * and we can access a hardware drawing on this manager.
239 * @encoder: encoder object owned by this sub driver. 239 * @encoder: encoder object owned by this sub driver.
240 * @connector: connector object owned by this sub driver. 240 * @connector: connector object owned by this sub driver.
241 */ 241 */
242struct exynos_drm_subdrv { 242struct exynos_drm_subdrv {
243 struct list_head list; 243 struct list_head list;
244 struct device *dev;
244 struct drm_device *drm_dev; 245 struct drm_device *drm_dev;
245 bool is_local; 246 struct exynos_drm_manager *manager;
246 247
247 int (*probe)(struct drm_device *drm_dev, struct device *dev); 248 int (*probe)(struct drm_device *drm_dev, struct device *dev);
248 void (*remove)(struct drm_device *dev); 249 void (*remove)(struct drm_device *dev);
@@ -251,7 +252,6 @@ struct exynos_drm_subdrv {
251 void (*close)(struct drm_device *drm_dev, struct device *dev, 252 void (*close)(struct drm_device *drm_dev, struct device *dev,
252 struct drm_file *file); 253 struct drm_file *file);
253 254
254 struct exynos_drm_manager manager;
255 struct drm_encoder *encoder; 255 struct drm_encoder *encoder;
256 struct drm_connector *connector; 256 struct drm_connector *connector;
257}; 257};
diff --git a/drivers/gpu/drm/exynos/exynos_drm_fimd.c b/drivers/gpu/drm/exynos/exynos_drm_fimd.c
index ecb6db229700..29fdbfeb43cb 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_fimd.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_fimd.c
@@ -172,7 +172,7 @@ static void fimd_dpms(struct device *subdrv_dev, int mode)
172static void fimd_apply(struct device *subdrv_dev) 172static void fimd_apply(struct device *subdrv_dev)
173{ 173{
174 struct fimd_context *ctx = get_fimd_context(subdrv_dev); 174 struct fimd_context *ctx = get_fimd_context(subdrv_dev);
175 struct exynos_drm_manager *mgr = &ctx->subdrv.manager; 175 struct exynos_drm_manager *mgr = ctx->subdrv.manager;
176 struct exynos_drm_manager_ops *mgr_ops = mgr->ops; 176 struct exynos_drm_manager_ops *mgr_ops = mgr->ops;
177 struct exynos_drm_overlay_ops *ovl_ops = mgr->overlay_ops; 177 struct exynos_drm_overlay_ops *ovl_ops = mgr->overlay_ops;
178 struct fimd_win_data *win_data; 178 struct fimd_win_data *win_data;
@@ -577,6 +577,13 @@ static struct exynos_drm_overlay_ops fimd_overlay_ops = {
577 .disable = fimd_win_disable, 577 .disable = fimd_win_disable,
578}; 578};
579 579
580static struct exynos_drm_manager fimd_manager = {
581 .pipe = -1,
582 .ops = &fimd_manager_ops,
583 .overlay_ops = &fimd_overlay_ops,
584 .display_ops = &fimd_display_ops,
585};
586
580static void fimd_finish_pageflip(struct drm_device *drm_dev, int crtc) 587static void fimd_finish_pageflip(struct drm_device *drm_dev, int crtc)
581{ 588{
582 struct exynos_drm_private *dev_priv = drm_dev->dev_private; 589 struct exynos_drm_private *dev_priv = drm_dev->dev_private;
@@ -628,7 +635,7 @@ static irqreturn_t fimd_irq_handler(int irq, void *dev_id)
628 struct fimd_context *ctx = (struct fimd_context *)dev_id; 635 struct fimd_context *ctx = (struct fimd_context *)dev_id;
629 struct exynos_drm_subdrv *subdrv = &ctx->subdrv; 636 struct exynos_drm_subdrv *subdrv = &ctx->subdrv;
630 struct drm_device *drm_dev = subdrv->drm_dev; 637 struct drm_device *drm_dev = subdrv->drm_dev;
631 struct exynos_drm_manager *manager = &subdrv->manager; 638 struct exynos_drm_manager *manager = subdrv->manager;
632 u32 val; 639 u32 val;
633 640
634 val = readl(ctx->regs + VIDINTCON1); 641 val = readl(ctx->regs + VIDINTCON1);
@@ -744,7 +751,7 @@ static void fimd_clear_win(struct fimd_context *ctx, int win)
744static int fimd_power_on(struct fimd_context *ctx, bool enable) 751static int fimd_power_on(struct fimd_context *ctx, bool enable)
745{ 752{
746 struct exynos_drm_subdrv *subdrv = &ctx->subdrv; 753 struct exynos_drm_subdrv *subdrv = &ctx->subdrv;
747 struct device *dev = subdrv->manager.dev; 754 struct device *dev = subdrv->dev;
748 755
749 DRM_DEBUG_KMS("%s\n", __FILE__); 756 DRM_DEBUG_KMS("%s\n", __FILE__);
750 757
@@ -867,13 +874,10 @@ static int __devinit fimd_probe(struct platform_device *pdev)
867 874
868 subdrv = &ctx->subdrv; 875 subdrv = &ctx->subdrv;
869 876
877 subdrv->dev = dev;
878 subdrv->manager = &fimd_manager;
870 subdrv->probe = fimd_subdrv_probe; 879 subdrv->probe = fimd_subdrv_probe;
871 subdrv->remove = fimd_subdrv_remove; 880 subdrv->remove = fimd_subdrv_remove;
872 subdrv->manager.pipe = -1;
873 subdrv->manager.ops = &fimd_manager_ops;
874 subdrv->manager.overlay_ops = &fimd_overlay_ops;
875 subdrv->manager.display_ops = &fimd_display_ops;
876 subdrv->manager.dev = dev;
877 881
878 mutex_init(&ctx->lock); 882 mutex_init(&ctx->lock);
879 883
diff --git a/drivers/gpu/drm/exynos/exynos_drm_gem.c b/drivers/gpu/drm/exynos/exynos_drm_gem.c
index fa1aa94a3d8e..1dffa8359f88 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_gem.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_gem.c
@@ -56,9 +56,28 @@ static unsigned int convert_to_vm_err_msg(int msg)
56 return out_msg; 56 return out_msg;
57} 57}
58 58
59static unsigned int mask_gem_flags(unsigned int flags) 59static int check_gem_flags(unsigned int flags)
60{ 60{
61 return flags &= EXYNOS_BO_NONCONTIG; 61 if (flags & ~(EXYNOS_BO_MASK)) {
62 DRM_ERROR("invalid flags.\n");
63 return -EINVAL;
64 }
65
66 return 0;
67}
68
69static unsigned long roundup_gem_size(unsigned long size, unsigned int flags)
70{
71 if (!IS_NONCONTIG_BUFFER(flags)) {
72 if (size >= SZ_1M)
73 return roundup(size, SECTION_SIZE);
74 else if (size >= SZ_64K)
75 return roundup(size, SZ_64K);
76 else
77 goto out;
78 }
79out:
80 return roundup(size, PAGE_SIZE);
62} 81}
63 82
64static struct page **exynos_gem_get_pages(struct drm_gem_object *obj, 83static struct page **exynos_gem_get_pages(struct drm_gem_object *obj,
@@ -130,22 +149,12 @@ static int exynos_drm_gem_map_pages(struct drm_gem_object *obj,
130 unsigned long pfn; 149 unsigned long pfn;
131 150
132 if (exynos_gem_obj->flags & EXYNOS_BO_NONCONTIG) { 151 if (exynos_gem_obj->flags & EXYNOS_BO_NONCONTIG) {
133 unsigned long usize = buf->size;
134
135 if (!buf->pages) 152 if (!buf->pages)
136 return -EINTR; 153 return -EINTR;
137 154
138 while (usize > 0) { 155 pfn = page_to_pfn(buf->pages[page_offset++]);
139 pfn = page_to_pfn(buf->pages[page_offset++]); 156 } else
140 vm_insert_mixed(vma, f_vaddr, pfn); 157 pfn = (buf->dma_addr >> PAGE_SHIFT) + page_offset;
141 f_vaddr += PAGE_SIZE;
142 usize -= PAGE_SIZE;
143 }
144
145 return 0;
146 }
147
148 pfn = (buf->dma_addr >> PAGE_SHIFT) + page_offset;
149 158
150 return vm_insert_mixed(vma, f_vaddr, pfn); 159 return vm_insert_mixed(vma, f_vaddr, pfn);
151} 160}
@@ -319,10 +328,17 @@ struct exynos_drm_gem_obj *exynos_drm_gem_create(struct drm_device *dev,
319 struct exynos_drm_gem_buf *buf; 328 struct exynos_drm_gem_buf *buf;
320 int ret; 329 int ret;
321 330
322 size = roundup(size, PAGE_SIZE); 331 if (!size) {
323 DRM_DEBUG_KMS("%s: size = 0x%lx\n", __FILE__, size); 332 DRM_ERROR("invalid size.\n");
333 return ERR_PTR(-EINVAL);
334 }
335
336 size = roundup_gem_size(size, flags);
337 DRM_DEBUG_KMS("%s\n", __FILE__);
324 338
325 flags = mask_gem_flags(flags); 339 ret = check_gem_flags(flags);
340 if (ret)
341 return ERR_PTR(ret);
326 342
327 buf = exynos_drm_init_buf(dev, size); 343 buf = exynos_drm_init_buf(dev, size);
328 if (!buf) 344 if (!buf)
@@ -331,7 +347,7 @@ struct exynos_drm_gem_obj *exynos_drm_gem_create(struct drm_device *dev,
331 exynos_gem_obj = exynos_drm_gem_init(dev, size); 347 exynos_gem_obj = exynos_drm_gem_init(dev, size);
332 if (!exynos_gem_obj) { 348 if (!exynos_gem_obj) {
333 ret = -ENOMEM; 349 ret = -ENOMEM;
334 goto err; 350 goto err_fini_buf;
335 } 351 }
336 352
337 exynos_gem_obj->buffer = buf; 353 exynos_gem_obj->buffer = buf;
@@ -347,18 +363,19 @@ struct exynos_drm_gem_obj *exynos_drm_gem_create(struct drm_device *dev,
347 ret = exynos_drm_gem_get_pages(&exynos_gem_obj->base); 363 ret = exynos_drm_gem_get_pages(&exynos_gem_obj->base);
348 if (ret < 0) { 364 if (ret < 0) {
349 drm_gem_object_release(&exynos_gem_obj->base); 365 drm_gem_object_release(&exynos_gem_obj->base);
350 goto err; 366 goto err_fini_buf;
351 } 367 }
352 } else { 368 } else {
353 ret = exynos_drm_alloc_buf(dev, buf, flags); 369 ret = exynos_drm_alloc_buf(dev, buf, flags);
354 if (ret < 0) { 370 if (ret < 0) {
355 drm_gem_object_release(&exynos_gem_obj->base); 371 drm_gem_object_release(&exynos_gem_obj->base);
356 goto err; 372 goto err_fini_buf;
357 } 373 }
358 } 374 }
359 375
360 return exynos_gem_obj; 376 return exynos_gem_obj;
361err: 377
378err_fini_buf:
362 exynos_drm_fini_buf(dev, buf); 379 exynos_drm_fini_buf(dev, buf);
363 return ERR_PTR(ret); 380 return ERR_PTR(ret);
364} 381}
@@ -497,6 +514,8 @@ static int exynos_drm_gem_mmap_buffer(struct file *filp,
497 if (!buffer->pages) 514 if (!buffer->pages)
498 return -EINVAL; 515 return -EINVAL;
499 516
517 vma->vm_flags |= VM_MIXEDMAP;
518
500 do { 519 do {
501 ret = vm_insert_page(vma, uaddr, buffer->pages[i++]); 520 ret = vm_insert_page(vma, uaddr, buffer->pages[i++]);
502 if (ret) { 521 if (ret) {
@@ -554,10 +573,8 @@ int exynos_drm_gem_mmap_ioctl(struct drm_device *dev, void *data,
554 obj->filp->f_op = &exynos_drm_gem_fops; 573 obj->filp->f_op = &exynos_drm_gem_fops;
555 obj->filp->private_data = obj; 574 obj->filp->private_data = obj;
556 575
557 down_write(&current->mm->mmap_sem); 576 addr = vm_mmap(obj->filp, 0, args->size,
558 addr = do_mmap(obj->filp, 0, args->size,
559 PROT_READ | PROT_WRITE, MAP_SHARED, 0); 577 PROT_READ | PROT_WRITE, MAP_SHARED, 0);
560 up_write(&current->mm->mmap_sem);
561 578
562 drm_gem_object_unreference_unlocked(obj); 579 drm_gem_object_unreference_unlocked(obj);
563 580
@@ -685,7 +702,6 @@ int exynos_drm_gem_dumb_destroy(struct drm_file *file_priv,
685int exynos_drm_gem_fault(struct vm_area_struct *vma, struct vm_fault *vmf) 702int exynos_drm_gem_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
686{ 703{
687 struct drm_gem_object *obj = vma->vm_private_data; 704 struct drm_gem_object *obj = vma->vm_private_data;
688 struct exynos_drm_gem_obj *exynos_gem_obj = to_exynos_gem_obj(obj);
689 struct drm_device *dev = obj->dev; 705 struct drm_device *dev = obj->dev;
690 unsigned long f_vaddr; 706 unsigned long f_vaddr;
691 pgoff_t page_offset; 707 pgoff_t page_offset;
@@ -697,21 +713,10 @@ int exynos_drm_gem_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
697 713
698 mutex_lock(&dev->struct_mutex); 714 mutex_lock(&dev->struct_mutex);
699 715
700 /*
701 * allocate all pages as desired size if user wants to allocate
702 * physically non-continuous memory.
703 */
704 if (exynos_gem_obj->flags & EXYNOS_BO_NONCONTIG) {
705 ret = exynos_drm_gem_get_pages(obj);
706 if (ret < 0)
707 goto err;
708 }
709
710 ret = exynos_drm_gem_map_pages(obj, vma, f_vaddr, page_offset); 716 ret = exynos_drm_gem_map_pages(obj, vma, f_vaddr, page_offset);
711 if (ret < 0) 717 if (ret < 0)
712 DRM_ERROR("failed to map pages.\n"); 718 DRM_ERROR("failed to map pages.\n");
713 719
714err:
715 mutex_unlock(&dev->struct_mutex); 720 mutex_unlock(&dev->struct_mutex);
716 721
717 return convert_to_vm_err_msg(ret); 722 return convert_to_vm_err_msg(ret);
diff --git a/drivers/gpu/drm/exynos/exynos_drm_gem.h b/drivers/gpu/drm/exynos/exynos_drm_gem.h
index e40fbad8b705..4ed842039505 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_gem.h
+++ b/drivers/gpu/drm/exynos/exynos_drm_gem.h
@@ -29,6 +29,8 @@
29#define to_exynos_gem_obj(x) container_of(x,\ 29#define to_exynos_gem_obj(x) container_of(x,\
30 struct exynos_drm_gem_obj, base) 30 struct exynos_drm_gem_obj, base)
31 31
32#define IS_NONCONTIG_BUFFER(f) (f & EXYNOS_BO_NONCONTIG)
33
32/* 34/*
33 * exynos drm gem buffer structure. 35 * exynos drm gem buffer structure.
34 * 36 *
diff --git a/drivers/gpu/drm/exynos/exynos_drm_hdmi.c b/drivers/gpu/drm/exynos/exynos_drm_hdmi.c
index 14eb26b0ba1c..3424463676e0 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_hdmi.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_hdmi.c
@@ -30,9 +30,8 @@
30 struct drm_hdmi_context, subdrv); 30 struct drm_hdmi_context, subdrv);
31 31
32/* these callback points shoud be set by specific drivers. */ 32/* these callback points shoud be set by specific drivers. */
33static struct exynos_hdmi_display_ops *hdmi_display_ops; 33static struct exynos_hdmi_ops *hdmi_ops;
34static struct exynos_hdmi_manager_ops *hdmi_manager_ops; 34static struct exynos_mixer_ops *mixer_ops;
35static struct exynos_hdmi_overlay_ops *hdmi_overlay_ops;
36 35
37struct drm_hdmi_context { 36struct drm_hdmi_context {
38 struct exynos_drm_subdrv subdrv; 37 struct exynos_drm_subdrv subdrv;
@@ -40,31 +39,20 @@ struct drm_hdmi_context {
40 struct exynos_drm_hdmi_context *mixer_ctx; 39 struct exynos_drm_hdmi_context *mixer_ctx;
41}; 40};
42 41
43void exynos_drm_display_ops_register(struct exynos_hdmi_display_ops 42void exynos_hdmi_ops_register(struct exynos_hdmi_ops *ops)
44 *display_ops)
45{ 43{
46 DRM_DEBUG_KMS("%s\n", __FILE__); 44 DRM_DEBUG_KMS("%s\n", __FILE__);
47 45
48 if (display_ops) 46 if (ops)
49 hdmi_display_ops = display_ops; 47 hdmi_ops = ops;
50} 48}
51 49
52void exynos_drm_manager_ops_register(struct exynos_hdmi_manager_ops 50void exynos_mixer_ops_register(struct exynos_mixer_ops *ops)
53 *manager_ops)
54{ 51{
55 DRM_DEBUG_KMS("%s\n", __FILE__); 52 DRM_DEBUG_KMS("%s\n", __FILE__);
56 53
57 if (manager_ops) 54 if (ops)
58 hdmi_manager_ops = manager_ops; 55 mixer_ops = ops;
59}
60
61void exynos_drm_overlay_ops_register(struct exynos_hdmi_overlay_ops
62 *overlay_ops)
63{
64 DRM_DEBUG_KMS("%s\n", __FILE__);
65
66 if (overlay_ops)
67 hdmi_overlay_ops = overlay_ops;
68} 56}
69 57
70static bool drm_hdmi_is_connected(struct device *dev) 58static bool drm_hdmi_is_connected(struct device *dev)
@@ -73,8 +61,8 @@ static bool drm_hdmi_is_connected(struct device *dev)
73 61
74 DRM_DEBUG_KMS("%s\n", __FILE__); 62 DRM_DEBUG_KMS("%s\n", __FILE__);
75 63
76 if (hdmi_display_ops && hdmi_display_ops->is_connected) 64 if (hdmi_ops && hdmi_ops->is_connected)
77 return hdmi_display_ops->is_connected(ctx->hdmi_ctx->ctx); 65 return hdmi_ops->is_connected(ctx->hdmi_ctx->ctx);
78 66
79 return false; 67 return false;
80} 68}
@@ -86,9 +74,9 @@ static int drm_hdmi_get_edid(struct device *dev,
86 74
87 DRM_DEBUG_KMS("%s\n", __FILE__); 75 DRM_DEBUG_KMS("%s\n", __FILE__);
88 76
89 if (hdmi_display_ops && hdmi_display_ops->get_edid) 77 if (hdmi_ops && hdmi_ops->get_edid)
90 return hdmi_display_ops->get_edid(ctx->hdmi_ctx->ctx, 78 return hdmi_ops->get_edid(ctx->hdmi_ctx->ctx, connector, edid,
91 connector, edid, len); 79 len);
92 80
93 return 0; 81 return 0;
94} 82}
@@ -99,9 +87,8 @@ static int drm_hdmi_check_timing(struct device *dev, void *timing)
99 87
100 DRM_DEBUG_KMS("%s\n", __FILE__); 88 DRM_DEBUG_KMS("%s\n", __FILE__);
101 89
102 if (hdmi_display_ops && hdmi_display_ops->check_timing) 90 if (hdmi_ops && hdmi_ops->check_timing)
103 return hdmi_display_ops->check_timing(ctx->hdmi_ctx->ctx, 91 return hdmi_ops->check_timing(ctx->hdmi_ctx->ctx, timing);
104 timing);
105 92
106 return 0; 93 return 0;
107} 94}
@@ -112,8 +99,8 @@ static int drm_hdmi_power_on(struct device *dev, int mode)
112 99
113 DRM_DEBUG_KMS("%s\n", __FILE__); 100 DRM_DEBUG_KMS("%s\n", __FILE__);
114 101
115 if (hdmi_display_ops && hdmi_display_ops->power_on) 102 if (hdmi_ops && hdmi_ops->power_on)
116 return hdmi_display_ops->power_on(ctx->hdmi_ctx->ctx, mode); 103 return hdmi_ops->power_on(ctx->hdmi_ctx->ctx, mode);
117 104
118 return 0; 105 return 0;
119} 106}
@@ -130,13 +117,13 @@ static int drm_hdmi_enable_vblank(struct device *subdrv_dev)
130{ 117{
131 struct drm_hdmi_context *ctx = to_context(subdrv_dev); 118 struct drm_hdmi_context *ctx = to_context(subdrv_dev);
132 struct exynos_drm_subdrv *subdrv = &ctx->subdrv; 119 struct exynos_drm_subdrv *subdrv = &ctx->subdrv;
133 struct exynos_drm_manager *manager = &subdrv->manager; 120 struct exynos_drm_manager *manager = subdrv->manager;
134 121
135 DRM_DEBUG_KMS("%s\n", __FILE__); 122 DRM_DEBUG_KMS("%s\n", __FILE__);
136 123
137 if (hdmi_overlay_ops && hdmi_overlay_ops->enable_vblank) 124 if (mixer_ops && mixer_ops->enable_vblank)
138 return hdmi_overlay_ops->enable_vblank(ctx->mixer_ctx->ctx, 125 return mixer_ops->enable_vblank(ctx->mixer_ctx->ctx,
139 manager->pipe); 126 manager->pipe);
140 127
141 return 0; 128 return 0;
142} 129}
@@ -147,8 +134,8 @@ static void drm_hdmi_disable_vblank(struct device *subdrv_dev)
147 134
148 DRM_DEBUG_KMS("%s\n", __FILE__); 135 DRM_DEBUG_KMS("%s\n", __FILE__);
149 136
150 if (hdmi_overlay_ops && hdmi_overlay_ops->disable_vblank) 137 if (mixer_ops && mixer_ops->disable_vblank)
151 return hdmi_overlay_ops->disable_vblank(ctx->mixer_ctx->ctx); 138 return mixer_ops->disable_vblank(ctx->mixer_ctx->ctx);
152} 139}
153 140
154static void drm_hdmi_mode_fixup(struct device *subdrv_dev, 141static void drm_hdmi_mode_fixup(struct device *subdrv_dev,
@@ -160,9 +147,9 @@ static void drm_hdmi_mode_fixup(struct device *subdrv_dev,
160 147
161 DRM_DEBUG_KMS("%s\n", __FILE__); 148 DRM_DEBUG_KMS("%s\n", __FILE__);
162 149
163 if (hdmi_manager_ops && hdmi_manager_ops->mode_fixup) 150 if (hdmi_ops && hdmi_ops->mode_fixup)
164 hdmi_manager_ops->mode_fixup(ctx->hdmi_ctx->ctx, connector, 151 hdmi_ops->mode_fixup(ctx->hdmi_ctx->ctx, connector, mode,
165 mode, adjusted_mode); 152 adjusted_mode);
166} 153}
167 154
168static void drm_hdmi_mode_set(struct device *subdrv_dev, void *mode) 155static void drm_hdmi_mode_set(struct device *subdrv_dev, void *mode)
@@ -171,8 +158,8 @@ static void drm_hdmi_mode_set(struct device *subdrv_dev, void *mode)
171 158
172 DRM_DEBUG_KMS("%s\n", __FILE__); 159 DRM_DEBUG_KMS("%s\n", __FILE__);
173 160
174 if (hdmi_manager_ops && hdmi_manager_ops->mode_set) 161 if (hdmi_ops && hdmi_ops->mode_set)
175 hdmi_manager_ops->mode_set(ctx->hdmi_ctx->ctx, mode); 162 hdmi_ops->mode_set(ctx->hdmi_ctx->ctx, mode);
176} 163}
177 164
178static void drm_hdmi_get_max_resol(struct device *subdrv_dev, 165static void drm_hdmi_get_max_resol(struct device *subdrv_dev,
@@ -182,9 +169,8 @@ static void drm_hdmi_get_max_resol(struct device *subdrv_dev,
182 169
183 DRM_DEBUG_KMS("%s\n", __FILE__); 170 DRM_DEBUG_KMS("%s\n", __FILE__);
184 171
185 if (hdmi_manager_ops && hdmi_manager_ops->get_max_resol) 172 if (hdmi_ops && hdmi_ops->get_max_resol)
186 hdmi_manager_ops->get_max_resol(ctx->hdmi_ctx->ctx, width, 173 hdmi_ops->get_max_resol(ctx->hdmi_ctx->ctx, width, height);
187 height);
188} 174}
189 175
190static void drm_hdmi_commit(struct device *subdrv_dev) 176static void drm_hdmi_commit(struct device *subdrv_dev)
@@ -193,8 +179,8 @@ static void drm_hdmi_commit(struct device *subdrv_dev)
193 179
194 DRM_DEBUG_KMS("%s\n", __FILE__); 180 DRM_DEBUG_KMS("%s\n", __FILE__);
195 181
196 if (hdmi_manager_ops && hdmi_manager_ops->commit) 182 if (hdmi_ops && hdmi_ops->commit)
197 hdmi_manager_ops->commit(ctx->hdmi_ctx->ctx); 183 hdmi_ops->commit(ctx->hdmi_ctx->ctx);
198} 184}
199 185
200static void drm_hdmi_dpms(struct device *subdrv_dev, int mode) 186static void drm_hdmi_dpms(struct device *subdrv_dev, int mode)
@@ -209,8 +195,8 @@ static void drm_hdmi_dpms(struct device *subdrv_dev, int mode)
209 case DRM_MODE_DPMS_STANDBY: 195 case DRM_MODE_DPMS_STANDBY:
210 case DRM_MODE_DPMS_SUSPEND: 196 case DRM_MODE_DPMS_SUSPEND:
211 case DRM_MODE_DPMS_OFF: 197 case DRM_MODE_DPMS_OFF:
212 if (hdmi_manager_ops && hdmi_manager_ops->disable) 198 if (hdmi_ops && hdmi_ops->disable)
213 hdmi_manager_ops->disable(ctx->hdmi_ctx->ctx); 199 hdmi_ops->disable(ctx->hdmi_ctx->ctx);
214 break; 200 break;
215 default: 201 default:
216 DRM_DEBUG_KMS("unkown dps mode: %d\n", mode); 202 DRM_DEBUG_KMS("unkown dps mode: %d\n", mode);
@@ -235,8 +221,8 @@ static void drm_mixer_mode_set(struct device *subdrv_dev,
235 221
236 DRM_DEBUG_KMS("%s\n", __FILE__); 222 DRM_DEBUG_KMS("%s\n", __FILE__);
237 223
238 if (hdmi_overlay_ops && hdmi_overlay_ops->win_mode_set) 224 if (mixer_ops && mixer_ops->win_mode_set)
239 hdmi_overlay_ops->win_mode_set(ctx->mixer_ctx->ctx, overlay); 225 mixer_ops->win_mode_set(ctx->mixer_ctx->ctx, overlay);
240} 226}
241 227
242static void drm_mixer_commit(struct device *subdrv_dev, int zpos) 228static void drm_mixer_commit(struct device *subdrv_dev, int zpos)
@@ -245,8 +231,8 @@ static void drm_mixer_commit(struct device *subdrv_dev, int zpos)
245 231
246 DRM_DEBUG_KMS("%s\n", __FILE__); 232 DRM_DEBUG_KMS("%s\n", __FILE__);
247 233
248 if (hdmi_overlay_ops && hdmi_overlay_ops->win_commit) 234 if (mixer_ops && mixer_ops->win_commit)
249 hdmi_overlay_ops->win_commit(ctx->mixer_ctx->ctx, zpos); 235 mixer_ops->win_commit(ctx->mixer_ctx->ctx, zpos);
250} 236}
251 237
252static void drm_mixer_disable(struct device *subdrv_dev, int zpos) 238static void drm_mixer_disable(struct device *subdrv_dev, int zpos)
@@ -255,8 +241,8 @@ static void drm_mixer_disable(struct device *subdrv_dev, int zpos)
255 241
256 DRM_DEBUG_KMS("%s\n", __FILE__); 242 DRM_DEBUG_KMS("%s\n", __FILE__);
257 243
258 if (hdmi_overlay_ops && hdmi_overlay_ops->win_disable) 244 if (mixer_ops && mixer_ops->win_disable)
259 hdmi_overlay_ops->win_disable(ctx->mixer_ctx->ctx, zpos); 245 mixer_ops->win_disable(ctx->mixer_ctx->ctx, zpos);
260} 246}
261 247
262static struct exynos_drm_overlay_ops drm_hdmi_overlay_ops = { 248static struct exynos_drm_overlay_ops drm_hdmi_overlay_ops = {
@@ -265,6 +251,12 @@ static struct exynos_drm_overlay_ops drm_hdmi_overlay_ops = {
265 .disable = drm_mixer_disable, 251 .disable = drm_mixer_disable,
266}; 252};
267 253
254static struct exynos_drm_manager hdmi_manager = {
255 .pipe = -1,
256 .ops = &drm_hdmi_manager_ops,
257 .overlay_ops = &drm_hdmi_overlay_ops,
258 .display_ops = &drm_hdmi_display_ops,
259};
268 260
269static int hdmi_subdrv_probe(struct drm_device *drm_dev, 261static int hdmi_subdrv_probe(struct drm_device *drm_dev,
270 struct device *dev) 262 struct device *dev)
@@ -332,12 +324,9 @@ static int __devinit exynos_drm_hdmi_probe(struct platform_device *pdev)
332 324
333 subdrv = &ctx->subdrv; 325 subdrv = &ctx->subdrv;
334 326
327 subdrv->dev = dev;
328 subdrv->manager = &hdmi_manager;
335 subdrv->probe = hdmi_subdrv_probe; 329 subdrv->probe = hdmi_subdrv_probe;
336 subdrv->manager.pipe = -1;
337 subdrv->manager.ops = &drm_hdmi_manager_ops;
338 subdrv->manager.overlay_ops = &drm_hdmi_overlay_ops;
339 subdrv->manager.display_ops = &drm_hdmi_display_ops;
340 subdrv->manager.dev = dev;
341 330
342 platform_set_drvdata(pdev, subdrv); 331 platform_set_drvdata(pdev, subdrv);
343 332
diff --git a/drivers/gpu/drm/exynos/exynos_drm_hdmi.h b/drivers/gpu/drm/exynos/exynos_drm_hdmi.h
index 44497cfb6c74..f3ae192c8dcf 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_hdmi.h
+++ b/drivers/gpu/drm/exynos/exynos_drm_hdmi.h
@@ -38,15 +38,15 @@ struct exynos_drm_hdmi_context {
38 void *ctx; 38 void *ctx;
39}; 39};
40 40
41struct exynos_hdmi_display_ops { 41struct exynos_hdmi_ops {
42 /* display */
42 bool (*is_connected)(void *ctx); 43 bool (*is_connected)(void *ctx);
43 int (*get_edid)(void *ctx, struct drm_connector *connector, 44 int (*get_edid)(void *ctx, struct drm_connector *connector,
44 u8 *edid, int len); 45 u8 *edid, int len);
45 int (*check_timing)(void *ctx, void *timing); 46 int (*check_timing)(void *ctx, void *timing);
46 int (*power_on)(void *ctx, int mode); 47 int (*power_on)(void *ctx, int mode);
47};
48 48
49struct exynos_hdmi_manager_ops { 49 /* manager */
50 void (*mode_fixup)(void *ctx, struct drm_connector *connector, 50 void (*mode_fixup)(void *ctx, struct drm_connector *connector,
51 struct drm_display_mode *mode, 51 struct drm_display_mode *mode,
52 struct drm_display_mode *adjusted_mode); 52 struct drm_display_mode *adjusted_mode);
@@ -57,22 +57,17 @@ struct exynos_hdmi_manager_ops {
57 void (*disable)(void *ctx); 57 void (*disable)(void *ctx);
58}; 58};
59 59
60struct exynos_hdmi_overlay_ops { 60struct exynos_mixer_ops {
61 /* manager */
61 int (*enable_vblank)(void *ctx, int pipe); 62 int (*enable_vblank)(void *ctx, int pipe);
62 void (*disable_vblank)(void *ctx); 63 void (*disable_vblank)(void *ctx);
64
65 /* overlay */
63 void (*win_mode_set)(void *ctx, struct exynos_drm_overlay *overlay); 66 void (*win_mode_set)(void *ctx, struct exynos_drm_overlay *overlay);
64 void (*win_commit)(void *ctx, int zpos); 67 void (*win_commit)(void *ctx, int zpos);
65 void (*win_disable)(void *ctx, int zpos); 68 void (*win_disable)(void *ctx, int zpos);
66}; 69};
67 70
68extern struct platform_driver hdmi_driver; 71void exynos_hdmi_ops_register(struct exynos_hdmi_ops *ops);
69extern struct platform_driver mixer_driver; 72void exynos_mixer_ops_register(struct exynos_mixer_ops *ops);
70
71void exynos_drm_display_ops_register(struct exynos_hdmi_display_ops
72 *display_ops);
73void exynos_drm_manager_ops_register(struct exynos_hdmi_manager_ops
74 *manager_ops);
75void exynos_drm_overlay_ops_register(struct exynos_hdmi_overlay_ops
76 *overlay_ops);
77
78#endif 73#endif
diff --git a/drivers/gpu/drm/exynos/exynos_drm_plane.c b/drivers/gpu/drm/exynos/exynos_drm_plane.c
index c277a3a445f5..f92fe4c6174a 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_plane.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_plane.c
@@ -24,6 +24,10 @@ struct exynos_plane {
24 24
25static const uint32_t formats[] = { 25static const uint32_t formats[] = {
26 DRM_FORMAT_XRGB8888, 26 DRM_FORMAT_XRGB8888,
27 DRM_FORMAT_ARGB8888,
28 DRM_FORMAT_NV12,
29 DRM_FORMAT_NV12M,
30 DRM_FORMAT_NV12MT,
27}; 31};
28 32
29static int 33static int
diff --git a/drivers/gpu/drm/exynos/exynos_drm_vidi.c b/drivers/gpu/drm/exynos/exynos_drm_vidi.c
index 8e1339f9fe1f..7b9c153dceb6 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_vidi.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_vidi.c
@@ -199,7 +199,7 @@ static void vidi_dpms(struct device *subdrv_dev, int mode)
199static void vidi_apply(struct device *subdrv_dev) 199static void vidi_apply(struct device *subdrv_dev)
200{ 200{
201 struct vidi_context *ctx = get_vidi_context(subdrv_dev); 201 struct vidi_context *ctx = get_vidi_context(subdrv_dev);
202 struct exynos_drm_manager *mgr = &ctx->subdrv.manager; 202 struct exynos_drm_manager *mgr = ctx->subdrv.manager;
203 struct exynos_drm_manager_ops *mgr_ops = mgr->ops; 203 struct exynos_drm_manager_ops *mgr_ops = mgr->ops;
204 struct exynos_drm_overlay_ops *ovl_ops = mgr->overlay_ops; 204 struct exynos_drm_overlay_ops *ovl_ops = mgr->overlay_ops;
205 struct vidi_win_data *win_data; 205 struct vidi_win_data *win_data;
@@ -374,6 +374,13 @@ static struct exynos_drm_overlay_ops vidi_overlay_ops = {
374 .disable = vidi_win_disable, 374 .disable = vidi_win_disable,
375}; 375};
376 376
377static struct exynos_drm_manager vidi_manager = {
378 .pipe = -1,
379 .ops = &vidi_manager_ops,
380 .overlay_ops = &vidi_overlay_ops,
381 .display_ops = &vidi_display_ops,
382};
383
377static void vidi_finish_pageflip(struct drm_device *drm_dev, int crtc) 384static void vidi_finish_pageflip(struct drm_device *drm_dev, int crtc)
378{ 385{
379 struct exynos_drm_private *dev_priv = drm_dev->dev_private; 386 struct exynos_drm_private *dev_priv = drm_dev->dev_private;
@@ -425,7 +432,7 @@ static void vidi_fake_vblank_handler(struct work_struct *work)
425 struct vidi_context *ctx = container_of(work, struct vidi_context, 432 struct vidi_context *ctx = container_of(work, struct vidi_context,
426 work); 433 work);
427 struct exynos_drm_subdrv *subdrv = &ctx->subdrv; 434 struct exynos_drm_subdrv *subdrv = &ctx->subdrv;
428 struct exynos_drm_manager *manager = &subdrv->manager; 435 struct exynos_drm_manager *manager = subdrv->manager;
429 436
430 if (manager->pipe < 0) 437 if (manager->pipe < 0)
431 return; 438 return;
@@ -471,7 +478,7 @@ static void vidi_subdrv_remove(struct drm_device *drm_dev)
471static int vidi_power_on(struct vidi_context *ctx, bool enable) 478static int vidi_power_on(struct vidi_context *ctx, bool enable)
472{ 479{
473 struct exynos_drm_subdrv *subdrv = &ctx->subdrv; 480 struct exynos_drm_subdrv *subdrv = &ctx->subdrv;
474 struct device *dev = subdrv->manager.dev; 481 struct device *dev = subdrv->dev;
475 482
476 DRM_DEBUG_KMS("%s\n", __FILE__); 483 DRM_DEBUG_KMS("%s\n", __FILE__);
477 484
@@ -611,13 +618,10 @@ static int __devinit vidi_probe(struct platform_device *pdev)
611 ctx->raw_edid = (struct edid *)fake_edid_info; 618 ctx->raw_edid = (struct edid *)fake_edid_info;
612 619
613 subdrv = &ctx->subdrv; 620 subdrv = &ctx->subdrv;
621 subdrv->dev = dev;
622 subdrv->manager = &vidi_manager;
614 subdrv->probe = vidi_subdrv_probe; 623 subdrv->probe = vidi_subdrv_probe;
615 subdrv->remove = vidi_subdrv_remove; 624 subdrv->remove = vidi_subdrv_remove;
616 subdrv->manager.pipe = -1;
617 subdrv->manager.ops = &vidi_manager_ops;
618 subdrv->manager.overlay_ops = &vidi_overlay_ops;
619 subdrv->manager.display_ops = &vidi_display_ops;
620 subdrv->manager.dev = dev;
621 625
622 mutex_init(&ctx->lock); 626 mutex_init(&ctx->lock);
623 627
diff --git a/drivers/gpu/drm/exynos/exynos_hdmi.c b/drivers/gpu/drm/exynos/exynos_hdmi.c
index 575a8cbd3533..b00353876458 100644
--- a/drivers/gpu/drm/exynos/exynos_hdmi.c
+++ b/drivers/gpu/drm/exynos/exynos_hdmi.c
@@ -40,7 +40,6 @@
40 40
41#include "exynos_hdmi.h" 41#include "exynos_hdmi.h"
42 42
43#define HDMI_OVERLAY_NUMBER 3
44#define MAX_WIDTH 1920 43#define MAX_WIDTH 1920
45#define MAX_HEIGHT 1080 44#define MAX_HEIGHT 1080
46#define get_hdmi_context(dev) platform_get_drvdata(to_platform_device(dev)) 45#define get_hdmi_context(dev) platform_get_drvdata(to_platform_device(dev))
@@ -1194,7 +1193,7 @@ static int hdmi_conf_index(struct hdmi_context *hdata,
1194 1193
1195static bool hdmi_is_connected(void *ctx) 1194static bool hdmi_is_connected(void *ctx)
1196{ 1195{
1197 struct hdmi_context *hdata = (struct hdmi_context *)ctx; 1196 struct hdmi_context *hdata = ctx;
1198 u32 val = hdmi_reg_read(hdata, HDMI_HPD_STATUS); 1197 u32 val = hdmi_reg_read(hdata, HDMI_HPD_STATUS);
1199 1198
1200 if (val) 1199 if (val)
@@ -1207,7 +1206,7 @@ static int hdmi_get_edid(void *ctx, struct drm_connector *connector,
1207 u8 *edid, int len) 1206 u8 *edid, int len)
1208{ 1207{
1209 struct edid *raw_edid; 1208 struct edid *raw_edid;
1210 struct hdmi_context *hdata = (struct hdmi_context *)ctx; 1209 struct hdmi_context *hdata = ctx;
1211 1210
1212 DRM_DEBUG_KMS("[%d] %s\n", __LINE__, __func__); 1211 DRM_DEBUG_KMS("[%d] %s\n", __LINE__, __func__);
1213 1212
@@ -1275,7 +1274,7 @@ static int hdmi_v14_check_timing(struct fb_videomode *check_timing)
1275 1274
1276static int hdmi_check_timing(void *ctx, void *timing) 1275static int hdmi_check_timing(void *ctx, void *timing)
1277{ 1276{
1278 struct hdmi_context *hdata = (struct hdmi_context *)ctx; 1277 struct hdmi_context *hdata = ctx;
1279 struct fb_videomode *check_timing = timing; 1278 struct fb_videomode *check_timing = timing;
1280 1279
1281 DRM_DEBUG_KMS("[%d] %s\n", __LINE__, __func__); 1280 DRM_DEBUG_KMS("[%d] %s\n", __LINE__, __func__);
@@ -1312,13 +1311,6 @@ static int hdmi_display_power_on(void *ctx, int mode)
1312 return 0; 1311 return 0;
1313} 1312}
1314 1313
1315static struct exynos_hdmi_display_ops display_ops = {
1316 .is_connected = hdmi_is_connected,
1317 .get_edid = hdmi_get_edid,
1318 .check_timing = hdmi_check_timing,
1319 .power_on = hdmi_display_power_on,
1320};
1321
1322static void hdmi_set_acr(u32 freq, u8 *acr) 1314static void hdmi_set_acr(u32 freq, u8 *acr)
1323{ 1315{
1324 u32 n, cts; 1316 u32 n, cts;
@@ -1914,7 +1906,7 @@ static void hdmi_mode_fixup(void *ctx, struct drm_connector *connector,
1914 struct drm_display_mode *adjusted_mode) 1906 struct drm_display_mode *adjusted_mode)
1915{ 1907{
1916 struct drm_display_mode *m; 1908 struct drm_display_mode *m;
1917 struct hdmi_context *hdata = (struct hdmi_context *)ctx; 1909 struct hdmi_context *hdata = ctx;
1918 int index; 1910 int index;
1919 1911
1920 DRM_DEBUG_KMS("[%d] %s\n", __LINE__, __func__); 1912 DRM_DEBUG_KMS("[%d] %s\n", __LINE__, __func__);
@@ -1951,7 +1943,7 @@ static void hdmi_mode_fixup(void *ctx, struct drm_connector *connector,
1951 1943
1952static void hdmi_mode_set(void *ctx, void *mode) 1944static void hdmi_mode_set(void *ctx, void *mode)
1953{ 1945{
1954 struct hdmi_context *hdata = (struct hdmi_context *)ctx; 1946 struct hdmi_context *hdata = ctx;
1955 int conf_idx; 1947 int conf_idx;
1956 1948
1957 DRM_DEBUG_KMS("[%d] %s\n", __LINE__, __func__); 1949 DRM_DEBUG_KMS("[%d] %s\n", __LINE__, __func__);
@@ -1974,7 +1966,7 @@ static void hdmi_get_max_resol(void *ctx, unsigned int *width,
1974 1966
1975static void hdmi_commit(void *ctx) 1967static void hdmi_commit(void *ctx)
1976{ 1968{
1977 struct hdmi_context *hdata = (struct hdmi_context *)ctx; 1969 struct hdmi_context *hdata = ctx;
1978 1970
1979 DRM_DEBUG_KMS("[%d] %s\n", __LINE__, __func__); 1971 DRM_DEBUG_KMS("[%d] %s\n", __LINE__, __func__);
1980 1972
@@ -1985,7 +1977,7 @@ static void hdmi_commit(void *ctx)
1985 1977
1986static void hdmi_disable(void *ctx) 1978static void hdmi_disable(void *ctx)
1987{ 1979{
1988 struct hdmi_context *hdata = (struct hdmi_context *)ctx; 1980 struct hdmi_context *hdata = ctx;
1989 1981
1990 DRM_DEBUG_KMS("[%d] %s\n", __LINE__, __func__); 1982 DRM_DEBUG_KMS("[%d] %s\n", __LINE__, __func__);
1991 1983
@@ -1996,7 +1988,14 @@ static void hdmi_disable(void *ctx)
1996 } 1988 }
1997} 1989}
1998 1990
1999static struct exynos_hdmi_manager_ops manager_ops = { 1991static struct exynos_hdmi_ops hdmi_ops = {
1992 /* display */
1993 .is_connected = hdmi_is_connected,
1994 .get_edid = hdmi_get_edid,
1995 .check_timing = hdmi_check_timing,
1996 .power_on = hdmi_display_power_on,
1997
1998 /* manager */
2000 .mode_fixup = hdmi_mode_fixup, 1999 .mode_fixup = hdmi_mode_fixup,
2001 .mode_set = hdmi_mode_set, 2000 .mode_set = hdmi_mode_set,
2002 .get_max_resol = hdmi_get_max_resol, 2001 .get_max_resol = hdmi_get_max_resol,
@@ -2020,7 +2019,7 @@ static void hdmi_hotplug_func(struct work_struct *work)
2020static irqreturn_t hdmi_irq_handler(int irq, void *arg) 2019static irqreturn_t hdmi_irq_handler(int irq, void *arg)
2021{ 2020{
2022 struct exynos_drm_hdmi_context *ctx = arg; 2021 struct exynos_drm_hdmi_context *ctx = arg;
2023 struct hdmi_context *hdata = (struct hdmi_context *)ctx->ctx; 2022 struct hdmi_context *hdata = ctx->ctx;
2024 u32 intc_flag; 2023 u32 intc_flag;
2025 2024
2026 intc_flag = hdmi_reg_read(hdata, HDMI_INTC_FLAG); 2025 intc_flag = hdmi_reg_read(hdata, HDMI_INTC_FLAG);
@@ -2173,7 +2172,7 @@ static int hdmi_runtime_suspend(struct device *dev)
2173 2172
2174 DRM_DEBUG_KMS("%s\n", __func__); 2173 DRM_DEBUG_KMS("%s\n", __func__);
2175 2174
2176 hdmi_resource_poweroff((struct hdmi_context *)ctx->ctx); 2175 hdmi_resource_poweroff(ctx->ctx);
2177 2176
2178 return 0; 2177 return 0;
2179} 2178}
@@ -2184,7 +2183,7 @@ static int hdmi_runtime_resume(struct device *dev)
2184 2183
2185 DRM_DEBUG_KMS("%s\n", __func__); 2184 DRM_DEBUG_KMS("%s\n", __func__);
2186 2185
2187 hdmi_resource_poweron((struct hdmi_context *)ctx->ctx); 2186 hdmi_resource_poweron(ctx->ctx);
2188 2187
2189 return 0; 2188 return 0;
2190} 2189}
@@ -2322,8 +2321,7 @@ static int __devinit hdmi_probe(struct platform_device *pdev)
2322 hdata->irq = res->start; 2321 hdata->irq = res->start;
2323 2322
2324 /* register specific callbacks to common hdmi. */ 2323 /* register specific callbacks to common hdmi. */
2325 exynos_drm_display_ops_register(&display_ops); 2324 exynos_hdmi_ops_register(&hdmi_ops);
2326 exynos_drm_manager_ops_register(&manager_ops);
2327 2325
2328 hdmi_resource_poweron(hdata); 2326 hdmi_resource_poweron(hdata);
2329 2327
@@ -2351,7 +2349,7 @@ err_data:
2351static int __devexit hdmi_remove(struct platform_device *pdev) 2349static int __devexit hdmi_remove(struct platform_device *pdev)
2352{ 2350{
2353 struct exynos_drm_hdmi_context *ctx = platform_get_drvdata(pdev); 2351 struct exynos_drm_hdmi_context *ctx = platform_get_drvdata(pdev);
2354 struct hdmi_context *hdata = (struct hdmi_context *)ctx->ctx; 2352 struct hdmi_context *hdata = ctx->ctx;
2355 2353
2356 DRM_DEBUG_KMS("[%d] %s\n", __LINE__, __func__); 2354 DRM_DEBUG_KMS("[%d] %s\n", __LINE__, __func__);
2357 2355
diff --git a/drivers/gpu/drm/exynos/exynos_mixer.c b/drivers/gpu/drm/exynos/exynos_mixer.c
index 4d5f41e19527..e15438c01129 100644
--- a/drivers/gpu/drm/exynos/exynos_mixer.c
+++ b/drivers/gpu/drm/exynos/exynos_mixer.c
@@ -37,7 +37,8 @@
37#include "exynos_drm_drv.h" 37#include "exynos_drm_drv.h"
38#include "exynos_drm_hdmi.h" 38#include "exynos_drm_hdmi.h"
39 39
40#define HDMI_OVERLAY_NUMBER 3 40#define MIXER_WIN_NR 3
41#define MIXER_DEFAULT_WIN 0
41 42
42#define get_mixer_context(dev) platform_get_drvdata(to_platform_device(dev)) 43#define get_mixer_context(dev) platform_get_drvdata(to_platform_device(dev))
43 44
@@ -75,16 +76,12 @@ struct mixer_resources {
75}; 76};
76 77
77struct mixer_context { 78struct mixer_context {
78 struct fb_videomode *default_timing;
79 unsigned int default_win;
80 unsigned int default_bpp;
81 unsigned int irq; 79 unsigned int irq;
82 int pipe; 80 int pipe;
83 bool interlace; 81 bool interlace;
84 bool vp_enabled;
85 82
86 struct mixer_resources mixer_res; 83 struct mixer_resources mixer_res;
87 struct hdmi_win_data win_data[HDMI_OVERLAY_NUMBER]; 84 struct hdmi_win_data win_data[MIXER_WIN_NR];
88}; 85};
89 86
90static const u8 filter_y_horiz_tap8[] = { 87static const u8 filter_y_horiz_tap8[] = {
@@ -643,9 +640,9 @@ static void mixer_win_mode_set(void *ctx,
643 640
644 win = overlay->zpos; 641 win = overlay->zpos;
645 if (win == DEFAULT_ZPOS) 642 if (win == DEFAULT_ZPOS)
646 win = mixer_ctx->default_win; 643 win = MIXER_DEFAULT_WIN;
647 644
648 if (win < 0 || win > HDMI_OVERLAY_NUMBER) { 645 if (win < 0 || win > MIXER_WIN_NR) {
649 DRM_ERROR("overlay plane[%d] is wrong\n", win); 646 DRM_ERROR("overlay plane[%d] is wrong\n", win);
650 return; 647 return;
651 } 648 }
@@ -683,9 +680,9 @@ static void mixer_win_commit(void *ctx, int zpos)
683 DRM_DEBUG_KMS("[%d] %s, win: %d\n", __LINE__, __func__, win); 680 DRM_DEBUG_KMS("[%d] %s, win: %d\n", __LINE__, __func__, win);
684 681
685 if (win == DEFAULT_ZPOS) 682 if (win == DEFAULT_ZPOS)
686 win = mixer_ctx->default_win; 683 win = MIXER_DEFAULT_WIN;
687 684
688 if (win < 0 || win > HDMI_OVERLAY_NUMBER) { 685 if (win < 0 || win > MIXER_WIN_NR) {
689 DRM_ERROR("overlay plane[%d] is wrong\n", win); 686 DRM_ERROR("overlay plane[%d] is wrong\n", win);
690 return; 687 return;
691 } 688 }
@@ -706,9 +703,9 @@ static void mixer_win_disable(void *ctx, int zpos)
706 DRM_DEBUG_KMS("[%d] %s, win: %d\n", __LINE__, __func__, win); 703 DRM_DEBUG_KMS("[%d] %s, win: %d\n", __LINE__, __func__, win);
707 704
708 if (win == DEFAULT_ZPOS) 705 if (win == DEFAULT_ZPOS)
709 win = mixer_ctx->default_win; 706 win = MIXER_DEFAULT_WIN;
710 707
711 if (win < 0 || win > HDMI_OVERLAY_NUMBER) { 708 if (win < 0 || win > MIXER_WIN_NR) {
712 DRM_ERROR("overlay plane[%d] is wrong\n", win); 709 DRM_ERROR("overlay plane[%d] is wrong\n", win);
713 return; 710 return;
714 } 711 }
@@ -722,9 +719,12 @@ static void mixer_win_disable(void *ctx, int zpos)
722 spin_unlock_irqrestore(&res->reg_slock, flags); 719 spin_unlock_irqrestore(&res->reg_slock, flags);
723} 720}
724 721
725static struct exynos_hdmi_overlay_ops overlay_ops = { 722static struct exynos_mixer_ops mixer_ops = {
723 /* manager */
726 .enable_vblank = mixer_enable_vblank, 724 .enable_vblank = mixer_enable_vblank,
727 .disable_vblank = mixer_disable_vblank, 725 .disable_vblank = mixer_disable_vblank,
726
727 /* overlay */
728 .win_mode_set = mixer_win_mode_set, 728 .win_mode_set = mixer_win_mode_set,
729 .win_commit = mixer_win_commit, 729 .win_commit = mixer_win_commit,
730 .win_disable = mixer_win_disable, 730 .win_disable = mixer_win_disable,
@@ -771,8 +771,7 @@ static void mixer_finish_pageflip(struct drm_device *drm_dev, int crtc)
771static irqreturn_t mixer_irq_handler(int irq, void *arg) 771static irqreturn_t mixer_irq_handler(int irq, void *arg)
772{ 772{
773 struct exynos_drm_hdmi_context *drm_hdmi_ctx = arg; 773 struct exynos_drm_hdmi_context *drm_hdmi_ctx = arg;
774 struct mixer_context *ctx = 774 struct mixer_context *ctx = drm_hdmi_ctx->ctx;
775 (struct mixer_context *)drm_hdmi_ctx->ctx;
776 struct mixer_resources *res = &ctx->mixer_res; 775 struct mixer_resources *res = &ctx->mixer_res;
777 u32 val, val_base; 776 u32 val, val_base;
778 777
@@ -902,7 +901,7 @@ static int mixer_runtime_resume(struct device *dev)
902 901
903 DRM_DEBUG_KMS("resume - start\n"); 902 DRM_DEBUG_KMS("resume - start\n");
904 903
905 mixer_resource_poweron((struct mixer_context *)ctx->ctx); 904 mixer_resource_poweron(ctx->ctx);
906 905
907 return 0; 906 return 0;
908} 907}
@@ -913,7 +912,7 @@ static int mixer_runtime_suspend(struct device *dev)
913 912
914 DRM_DEBUG_KMS("suspend - start\n"); 913 DRM_DEBUG_KMS("suspend - start\n");
915 914
916 mixer_resource_poweroff((struct mixer_context *)ctx->ctx); 915 mixer_resource_poweroff(ctx->ctx);
917 916
918 return 0; 917 return 0;
919} 918}
@@ -926,8 +925,7 @@ static const struct dev_pm_ops mixer_pm_ops = {
926static int __devinit mixer_resources_init(struct exynos_drm_hdmi_context *ctx, 925static int __devinit mixer_resources_init(struct exynos_drm_hdmi_context *ctx,
927 struct platform_device *pdev) 926 struct platform_device *pdev)
928{ 927{
929 struct mixer_context *mixer_ctx = 928 struct mixer_context *mixer_ctx = ctx->ctx;
930 (struct mixer_context *)ctx->ctx;
931 struct device *dev = &pdev->dev; 929 struct device *dev = &pdev->dev;
932 struct mixer_resources *mixer_res = &mixer_ctx->mixer_res; 930 struct mixer_resources *mixer_res = &mixer_ctx->mixer_res;
933 struct resource *res; 931 struct resource *res;
@@ -1076,7 +1074,7 @@ static int __devinit mixer_probe(struct platform_device *pdev)
1076 goto fail; 1074 goto fail;
1077 1075
1078 /* register specific callback point to common hdmi. */ 1076 /* register specific callback point to common hdmi. */
1079 exynos_drm_overlay_ops_register(&overlay_ops); 1077 exynos_mixer_ops_register(&mixer_ops);
1080 1078
1081 mixer_resource_poweron(ctx); 1079 mixer_resource_poweron(ctx);
1082 1080
@@ -1093,7 +1091,7 @@ static int mixer_remove(struct platform_device *pdev)
1093 struct device *dev = &pdev->dev; 1091 struct device *dev = &pdev->dev;
1094 struct exynos_drm_hdmi_context *drm_hdmi_ctx = 1092 struct exynos_drm_hdmi_context *drm_hdmi_ctx =
1095 platform_get_drvdata(pdev); 1093 platform_get_drvdata(pdev);
1096 struct mixer_context *ctx = (struct mixer_context *)drm_hdmi_ctx->ctx; 1094 struct mixer_context *ctx = drm_hdmi_ctx->ctx;
1097 1095
1098 dev_info(dev, "remove successful\n"); 1096 dev_info(dev, "remove successful\n");
1099 1097
diff --git a/drivers/gpu/drm/gma500/mdfld_dsi_output.h b/drivers/gpu/drm/gma500/mdfld_dsi_output.h
index 21071cef92a4..36eb0744841c 100644
--- a/drivers/gpu/drm/gma500/mdfld_dsi_output.h
+++ b/drivers/gpu/drm/gma500/mdfld_dsi_output.h
@@ -29,7 +29,6 @@
29#define __MDFLD_DSI_OUTPUT_H__ 29#define __MDFLD_DSI_OUTPUT_H__
30 30
31#include <linux/backlight.h> 31#include <linux/backlight.h>
32#include <linux/version.h>
33#include <drm/drmP.h> 32#include <drm/drmP.h>
34#include <drm/drm.h> 33#include <drm/drm.h>
35#include <drm/drm_crtc.h> 34#include <drm/drm_crtc.h>
diff --git a/drivers/gpu/drm/i810/i810_dma.c b/drivers/gpu/drm/i810/i810_dma.c
index 2c8a60c3b98e..f920fb5e42b6 100644
--- a/drivers/gpu/drm/i810/i810_dma.c
+++ b/drivers/gpu/drm/i810/i810_dma.c
@@ -129,6 +129,7 @@ static int i810_map_buffer(struct drm_buf *buf, struct drm_file *file_priv)
129 if (buf_priv->currently_mapped == I810_BUF_MAPPED) 129 if (buf_priv->currently_mapped == I810_BUF_MAPPED)
130 return -EINVAL; 130 return -EINVAL;
131 131
132 /* This is all entirely broken */
132 down_write(&current->mm->mmap_sem); 133 down_write(&current->mm->mmap_sem);
133 old_fops = file_priv->filp->f_op; 134 old_fops = file_priv->filp->f_op;
134 file_priv->filp->f_op = &i810_buffer_fops; 135 file_priv->filp->f_op = &i810_buffer_fops;
@@ -157,11 +158,8 @@ static int i810_unmap_buffer(struct drm_buf *buf)
157 if (buf_priv->currently_mapped != I810_BUF_MAPPED) 158 if (buf_priv->currently_mapped != I810_BUF_MAPPED)
158 return -EINVAL; 159 return -EINVAL;
159 160
160 down_write(&current->mm->mmap_sem); 161 retcode = vm_munmap((unsigned long)buf_priv->virtual,
161 retcode = do_munmap(current->mm,
162 (unsigned long)buf_priv->virtual,
163 (size_t) buf->total); 162 (size_t) buf->total);
164 up_write(&current->mm->mmap_sem);
165 163
166 buf_priv->currently_mapped = I810_BUF_UNMAPPED; 164 buf_priv->currently_mapped = I810_BUF_UNMAPPED;
167 buf_priv->virtual = NULL; 165 buf_priv->virtual = NULL;
diff --git a/drivers/gpu/drm/i915/i915_drv.c b/drivers/gpu/drm/i915/i915_drv.c
index dfa55e7478fb..ae8a64f9f845 100644
--- a/drivers/gpu/drm/i915/i915_drv.c
+++ b/drivers/gpu/drm/i915/i915_drv.c
@@ -64,7 +64,7 @@ MODULE_PARM_DESC(semaphores,
64 "Use semaphores for inter-ring sync (default: -1 (use per-chip defaults))"); 64 "Use semaphores for inter-ring sync (default: -1 (use per-chip defaults))");
65 65
66int i915_enable_rc6 __read_mostly = -1; 66int i915_enable_rc6 __read_mostly = -1;
67module_param_named(i915_enable_rc6, i915_enable_rc6, int, 0600); 67module_param_named(i915_enable_rc6, i915_enable_rc6, int, 0400);
68MODULE_PARM_DESC(i915_enable_rc6, 68MODULE_PARM_DESC(i915_enable_rc6,
69 "Enable power-saving render C-state 6. " 69 "Enable power-saving render C-state 6. "
70 "Different stages can be selected via bitmask values " 70 "Different stages can be selected via bitmask values "
diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
index 4c65c639f772..0d1e4b7b4b99 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -1087,11 +1087,9 @@ i915_gem_mmap_ioctl(struct drm_device *dev, void *data,
1087 if (obj == NULL) 1087 if (obj == NULL)
1088 return -ENOENT; 1088 return -ENOENT;
1089 1089
1090 down_write(&current->mm->mmap_sem); 1090 addr = vm_mmap(obj->filp, 0, args->size,
1091 addr = do_mmap(obj->filp, 0, args->size,
1092 PROT_READ | PROT_WRITE, MAP_SHARED, 1091 PROT_READ | PROT_WRITE, MAP_SHARED,
1093 args->offset); 1092 args->offset);
1094 up_write(&current->mm->mmap_sem);
1095 drm_gem_object_unreference_unlocked(obj); 1093 drm_gem_object_unreference_unlocked(obj);
1096 if (IS_ERR((void *)addr)) 1094 if (IS_ERR((void *)addr))
1097 return addr; 1095 return addr;
@@ -1493,6 +1491,7 @@ i915_gem_object_move_off_active(struct drm_i915_gem_object *obj)
1493{ 1491{
1494 list_del_init(&obj->ring_list); 1492 list_del_init(&obj->ring_list);
1495 obj->last_rendering_seqno = 0; 1493 obj->last_rendering_seqno = 0;
1494 obj->last_fenced_seqno = 0;
1496} 1495}
1497 1496
1498static void 1497static void
@@ -1521,6 +1520,7 @@ i915_gem_object_move_to_inactive(struct drm_i915_gem_object *obj)
1521 BUG_ON(!list_empty(&obj->gpu_write_list)); 1520 BUG_ON(!list_empty(&obj->gpu_write_list));
1522 BUG_ON(!obj->active); 1521 BUG_ON(!obj->active);
1523 obj->ring = NULL; 1522 obj->ring = NULL;
1523 obj->last_fenced_ring = NULL;
1524 1524
1525 i915_gem_object_move_off_active(obj); 1525 i915_gem_object_move_off_active(obj);
1526 obj->fenced_gpu_access = false; 1526 obj->fenced_gpu_access = false;
diff --git a/drivers/gpu/drm/i915/i915_gem_execbuffer.c b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
index f51a696486cb..de431942ded4 100644
--- a/drivers/gpu/drm/i915/i915_gem_execbuffer.c
+++ b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
@@ -1133,6 +1133,11 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data,
1133 return -EINVAL; 1133 return -EINVAL;
1134 } 1134 }
1135 1135
1136 if (args->num_cliprects > UINT_MAX / sizeof(*cliprects)) {
1137 DRM_DEBUG("execbuf with %u cliprects\n",
1138 args->num_cliprects);
1139 return -EINVAL;
1140 }
1136 cliprects = kmalloc(args->num_cliprects * sizeof(*cliprects), 1141 cliprects = kmalloc(args->num_cliprects * sizeof(*cliprects),
1137 GFP_KERNEL); 1142 GFP_KERNEL);
1138 if (cliprects == NULL) { 1143 if (cliprects == NULL) {
@@ -1404,7 +1409,8 @@ i915_gem_execbuffer2(struct drm_device *dev, void *data,
1404 struct drm_i915_gem_exec_object2 *exec2_list = NULL; 1409 struct drm_i915_gem_exec_object2 *exec2_list = NULL;
1405 int ret; 1410 int ret;
1406 1411
1407 if (args->buffer_count < 1) { 1412 if (args->buffer_count < 1 ||
1413 args->buffer_count > UINT_MAX / sizeof(*exec2_list)) {
1408 DRM_DEBUG("execbuf2 with %d buffers\n", args->buffer_count); 1414 DRM_DEBUG("execbuf2 with %d buffers\n", args->buffer_count);
1409 return -EINVAL; 1415 return -EINVAL;
1410 } 1416 }
diff --git a/drivers/gpu/drm/i915/i915_reg.h b/drivers/gpu/drm/i915/i915_reg.h
index 2abf4eb94039..9d24d65f0c3e 100644
--- a/drivers/gpu/drm/i915/i915_reg.h
+++ b/drivers/gpu/drm/i915/i915_reg.h
@@ -568,6 +568,7 @@
568#define CM0_MASK_SHIFT 16 568#define CM0_MASK_SHIFT 16
569#define CM0_IZ_OPT_DISABLE (1<<6) 569#define CM0_IZ_OPT_DISABLE (1<<6)
570#define CM0_ZR_OPT_DISABLE (1<<5) 570#define CM0_ZR_OPT_DISABLE (1<<5)
571#define CM0_STC_EVICT_DISABLE_LRA_SNB (1<<5)
571#define CM0_DEPTH_EVICT_DISABLE (1<<4) 572#define CM0_DEPTH_EVICT_DISABLE (1<<4)
572#define CM0_COLOR_EVICT_DISABLE (1<<3) 573#define CM0_COLOR_EVICT_DISABLE (1<<3)
573#define CM0_DEPTH_WRITE_DISABLE (1<<1) 574#define CM0_DEPTH_WRITE_DISABLE (1<<1)
@@ -3728,6 +3729,9 @@
3728#define GT_FIFO_FREE_ENTRIES 0x120008 3729#define GT_FIFO_FREE_ENTRIES 0x120008
3729#define GT_FIFO_NUM_RESERVED_ENTRIES 20 3730#define GT_FIFO_NUM_RESERVED_ENTRIES 20
3730 3731
3732#define GEN6_UCGCTL1 0x9400
3733# define GEN6_BLBUNIT_CLOCK_GATE_DISABLE (1 << 5)
3734
3731#define GEN6_UCGCTL2 0x9404 3735#define GEN6_UCGCTL2 0x9404
3732# define GEN6_RCZUNIT_CLOCK_GATE_DISABLE (1 << 13) 3736# define GEN6_RCZUNIT_CLOCK_GATE_DISABLE (1 << 13)
3733# define GEN6_RCPBUNIT_CLOCK_GATE_DISABLE (1 << 12) 3737# define GEN6_RCPBUNIT_CLOCK_GATE_DISABLE (1 << 12)
diff --git a/drivers/gpu/drm/i915/intel_crt.c b/drivers/gpu/drm/i915/intel_crt.c
index 4d3d736a4f56..90b9793fd5da 100644
--- a/drivers/gpu/drm/i915/intel_crt.c
+++ b/drivers/gpu/drm/i915/intel_crt.c
@@ -430,8 +430,8 @@ intel_crt_detect(struct drm_connector *connector, bool force)
430{ 430{
431 struct drm_device *dev = connector->dev; 431 struct drm_device *dev = connector->dev;
432 struct intel_crt *crt = intel_attached_crt(connector); 432 struct intel_crt *crt = intel_attached_crt(connector);
433 struct drm_crtc *crtc;
434 enum drm_connector_status status; 433 enum drm_connector_status status;
434 struct intel_load_detect_pipe tmp;
435 435
436 if (I915_HAS_HOTPLUG(dev)) { 436 if (I915_HAS_HOTPLUG(dev)) {
437 if (intel_crt_detect_hotplug(connector)) { 437 if (intel_crt_detect_hotplug(connector)) {
@@ -450,23 +450,16 @@ intel_crt_detect(struct drm_connector *connector, bool force)
450 return connector->status; 450 return connector->status;
451 451
452 /* for pre-945g platforms use load detect */ 452 /* for pre-945g platforms use load detect */
453 crtc = crt->base.base.crtc; 453 if (intel_get_load_detect_pipe(&crt->base, connector, NULL,
454 if (crtc && crtc->enabled) { 454 &tmp)) {
455 status = intel_crt_load_detect(crt); 455 if (intel_crt_detect_ddc(connector))
456 } else { 456 status = connector_status_connected;
457 struct intel_load_detect_pipe tmp; 457 else
458 458 status = intel_crt_load_detect(crt);
459 if (intel_get_load_detect_pipe(&crt->base, connector, NULL, 459 intel_release_load_detect_pipe(&crt->base, connector,
460 &tmp)) { 460 &tmp);
461 if (intel_crt_detect_ddc(connector)) 461 } else
462 status = connector_status_connected; 462 status = connector_status_unknown;
463 else
464 status = intel_crt_load_detect(crt);
465 intel_release_load_detect_pipe(&crt->base, connector,
466 &tmp);
467 } else
468 status = connector_status_unknown;
469 }
470 463
471 return status; 464 return status;
472} 465}
diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
index 91b35fd1db8c..5908cd563400 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -2245,6 +2245,33 @@ intel_pipe_set_base_atomic(struct drm_crtc *crtc, struct drm_framebuffer *fb,
2245} 2245}
2246 2246
2247static int 2247static int
2248intel_finish_fb(struct drm_framebuffer *old_fb)
2249{
2250 struct drm_i915_gem_object *obj = to_intel_framebuffer(old_fb)->obj;
2251 struct drm_i915_private *dev_priv = obj->base.dev->dev_private;
2252 bool was_interruptible = dev_priv->mm.interruptible;
2253 int ret;
2254
2255 wait_event(dev_priv->pending_flip_queue,
2256 atomic_read(&dev_priv->mm.wedged) ||
2257 atomic_read(&obj->pending_flip) == 0);
2258
2259 /* Big Hammer, we also need to ensure that any pending
2260 * MI_WAIT_FOR_EVENT inside a user batch buffer on the
2261 * current scanout is retired before unpinning the old
2262 * framebuffer.
2263 *
2264 * This should only fail upon a hung GPU, in which case we
2265 * can safely continue.
2266 */
2267 dev_priv->mm.interruptible = false;
2268 ret = i915_gem_object_finish_gpu(obj);
2269 dev_priv->mm.interruptible = was_interruptible;
2270
2271 return ret;
2272}
2273
2274static int
2248intel_pipe_set_base(struct drm_crtc *crtc, int x, int y, 2275intel_pipe_set_base(struct drm_crtc *crtc, int x, int y,
2249 struct drm_framebuffer *old_fb) 2276 struct drm_framebuffer *old_fb)
2250{ 2277{
@@ -2282,25 +2309,8 @@ intel_pipe_set_base(struct drm_crtc *crtc, int x, int y,
2282 return ret; 2309 return ret;
2283 } 2310 }
2284 2311
2285 if (old_fb) { 2312 if (old_fb)
2286 struct drm_i915_private *dev_priv = dev->dev_private; 2313 intel_finish_fb(old_fb);
2287 struct drm_i915_gem_object *obj = to_intel_framebuffer(old_fb)->obj;
2288
2289 wait_event(dev_priv->pending_flip_queue,
2290 atomic_read(&dev_priv->mm.wedged) ||
2291 atomic_read(&obj->pending_flip) == 0);
2292
2293 /* Big Hammer, we also need to ensure that any pending
2294 * MI_WAIT_FOR_EVENT inside a user batch buffer on the
2295 * current scanout is retired before unpinning the old
2296 * framebuffer.
2297 *
2298 * This should only fail upon a hung GPU, in which case we
2299 * can safely continue.
2300 */
2301 ret = i915_gem_object_finish_gpu(obj);
2302 (void) ret;
2303 }
2304 2314
2305 ret = intel_pipe_set_base_atomic(crtc, crtc->fb, x, y, 2315 ret = intel_pipe_set_base_atomic(crtc, crtc->fb, x, y,
2306 LEAVE_ATOMIC_MODE_SET); 2316 LEAVE_ATOMIC_MODE_SET);
@@ -3371,6 +3381,23 @@ static void intel_crtc_disable(struct drm_crtc *crtc)
3371 struct drm_crtc_helper_funcs *crtc_funcs = crtc->helper_private; 3381 struct drm_crtc_helper_funcs *crtc_funcs = crtc->helper_private;
3372 struct drm_device *dev = crtc->dev; 3382 struct drm_device *dev = crtc->dev;
3373 3383
3384 /* Flush any pending WAITs before we disable the pipe. Note that
3385 * we need to drop the struct_mutex in order to acquire it again
3386 * during the lowlevel dpms routines around a couple of the
3387 * operations. It does not look trivial nor desirable to move
3388 * that locking higher. So instead we leave a window for the
3389 * submission of further commands on the fb before we can actually
3390 * disable it. This race with userspace exists anyway, and we can
3391 * only rely on the pipe being disabled by userspace after it
3392 * receives the hotplug notification and has flushed any pending
3393 * batches.
3394 */
3395 if (crtc->fb) {
3396 mutex_lock(&dev->struct_mutex);
3397 intel_finish_fb(crtc->fb);
3398 mutex_unlock(&dev->struct_mutex);
3399 }
3400
3374 crtc_funcs->dpms(crtc, DRM_MODE_DPMS_OFF); 3401 crtc_funcs->dpms(crtc, DRM_MODE_DPMS_OFF);
3375 assert_plane_disabled(dev->dev_private, to_intel_crtc(crtc)->plane); 3402 assert_plane_disabled(dev->dev_private, to_intel_crtc(crtc)->plane);
3376 assert_pipe_disabled(dev->dev_private, to_intel_crtc(crtc)->pipe); 3403 assert_pipe_disabled(dev->dev_private, to_intel_crtc(crtc)->pipe);
@@ -3451,8 +3478,11 @@ static bool intel_crtc_mode_fixup(struct drm_crtc *crtc,
3451 return false; 3478 return false;
3452 } 3479 }
3453 3480
3454 /* All interlaced capable intel hw wants timings in frames. */ 3481 /* All interlaced capable intel hw wants timings in frames. Note though
3455 drm_mode_set_crtcinfo(adjusted_mode, 0); 3482 * that intel_lvds_mode_fixup does some funny tricks with the crtc
3483 * timings, so we need to be careful not to clobber these.*/
3484 if (!(adjusted_mode->private_flags & INTEL_MODE_CRTC_TIMINGS_SET))
3485 drm_mode_set_crtcinfo(adjusted_mode, 0);
3456 3486
3457 return true; 3487 return true;
3458} 3488}
@@ -7438,7 +7468,13 @@ static int intel_gen6_queue_flip(struct drm_device *dev,
7438 OUT_RING(fb->pitches[0] | obj->tiling_mode); 7468 OUT_RING(fb->pitches[0] | obj->tiling_mode);
7439 OUT_RING(obj->gtt_offset); 7469 OUT_RING(obj->gtt_offset);
7440 7470
7441 pf = I915_READ(PF_CTL(intel_crtc->pipe)) & PF_ENABLE; 7471 /* Contrary to the suggestions in the documentation,
7472 * "Enable Panel Fitter" does not seem to be required when page
7473 * flipping with a non-native mode, and worse causes a normal
7474 * modeset to fail.
7475 * pf = I915_READ(PF_CTL(intel_crtc->pipe)) & PF_ENABLE;
7476 */
7477 pf = 0;
7442 pipesrc = I915_READ(PIPESRC(intel_crtc->pipe)) & 0x0fff0fff; 7478 pipesrc = I915_READ(PIPESRC(intel_crtc->pipe)) & 0x0fff0fff;
7443 OUT_RING(pf | pipesrc); 7479 OUT_RING(pf | pipesrc);
7444 ADVANCE_LP_RING(); 7480 ADVANCE_LP_RING();
@@ -8529,6 +8565,10 @@ static void gen6_init_clock_gating(struct drm_device *dev)
8529 I915_WRITE(WM2_LP_ILK, 0); 8565 I915_WRITE(WM2_LP_ILK, 0);
8530 I915_WRITE(WM1_LP_ILK, 0); 8566 I915_WRITE(WM1_LP_ILK, 0);
8531 8567
8568 I915_WRITE(GEN6_UCGCTL1,
8569 I915_READ(GEN6_UCGCTL1) |
8570 GEN6_BLBUNIT_CLOCK_GATE_DISABLE);
8571
8532 /* According to the BSpec vol1g, bit 12 (RCPBUNIT) clock 8572 /* According to the BSpec vol1g, bit 12 (RCPBUNIT) clock
8533 * gating disable must be set. Failure to set it results in 8573 * gating disable must be set. Failure to set it results in
8534 * flickering pixels due to Z write ordering failures after 8574 * flickering pixels due to Z write ordering failures after
diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c
index 110552ff302c..4b637919f74f 100644
--- a/drivers/gpu/drm/i915/intel_dp.c
+++ b/drivers/gpu/drm/i915/intel_dp.c
@@ -219,14 +219,38 @@ intel_dp_max_data_rate(int max_link_clock, int max_lanes)
219 return (max_link_clock * max_lanes * 8) / 10; 219 return (max_link_clock * max_lanes * 8) / 10;
220} 220}
221 221
222static bool
223intel_dp_adjust_dithering(struct intel_dp *intel_dp,
224 struct drm_display_mode *mode,
225 struct drm_display_mode *adjusted_mode)
226{
227 int max_link_clock = intel_dp_link_clock(intel_dp_max_link_bw(intel_dp));
228 int max_lanes = intel_dp_max_lane_count(intel_dp);
229 int max_rate, mode_rate;
230
231 mode_rate = intel_dp_link_required(mode->clock, 24);
232 max_rate = intel_dp_max_data_rate(max_link_clock, max_lanes);
233
234 if (mode_rate > max_rate) {
235 mode_rate = intel_dp_link_required(mode->clock, 18);
236 if (mode_rate > max_rate)
237 return false;
238
239 if (adjusted_mode)
240 adjusted_mode->private_flags
241 |= INTEL_MODE_DP_FORCE_6BPC;
242
243 return true;
244 }
245
246 return true;
247}
248
222static int 249static int
223intel_dp_mode_valid(struct drm_connector *connector, 250intel_dp_mode_valid(struct drm_connector *connector,
224 struct drm_display_mode *mode) 251 struct drm_display_mode *mode)
225{ 252{
226 struct intel_dp *intel_dp = intel_attached_dp(connector); 253 struct intel_dp *intel_dp = intel_attached_dp(connector);
227 int max_link_clock = intel_dp_link_clock(intel_dp_max_link_bw(intel_dp));
228 int max_lanes = intel_dp_max_lane_count(intel_dp);
229 int max_rate, mode_rate;
230 254
231 if (is_edp(intel_dp) && intel_dp->panel_fixed_mode) { 255 if (is_edp(intel_dp) && intel_dp->panel_fixed_mode) {
232 if (mode->hdisplay > intel_dp->panel_fixed_mode->hdisplay) 256 if (mode->hdisplay > intel_dp->panel_fixed_mode->hdisplay)
@@ -236,16 +260,8 @@ intel_dp_mode_valid(struct drm_connector *connector,
236 return MODE_PANEL; 260 return MODE_PANEL;
237 } 261 }
238 262
239 mode_rate = intel_dp_link_required(mode->clock, 24); 263 if (!intel_dp_adjust_dithering(intel_dp, mode, NULL))
240 max_rate = intel_dp_max_data_rate(max_link_clock, max_lanes); 264 return MODE_CLOCK_HIGH;
241
242 if (mode_rate > max_rate) {
243 mode_rate = intel_dp_link_required(mode->clock, 18);
244 if (mode_rate > max_rate)
245 return MODE_CLOCK_HIGH;
246 else
247 mode->private_flags |= INTEL_MODE_DP_FORCE_6BPC;
248 }
249 265
250 if (mode->clock < 10000) 266 if (mode->clock < 10000)
251 return MODE_CLOCK_LOW; 267 return MODE_CLOCK_LOW;
@@ -672,7 +688,7 @@ intel_dp_mode_fixup(struct drm_encoder *encoder, struct drm_display_mode *mode,
672 int lane_count, clock; 688 int lane_count, clock;
673 int max_lane_count = intel_dp_max_lane_count(intel_dp); 689 int max_lane_count = intel_dp_max_lane_count(intel_dp);
674 int max_clock = intel_dp_max_link_bw(intel_dp) == DP_LINK_BW_2_7 ? 1 : 0; 690 int max_clock = intel_dp_max_link_bw(intel_dp) == DP_LINK_BW_2_7 ? 1 : 0;
675 int bpp = mode->private_flags & INTEL_MODE_DP_FORCE_6BPC ? 18 : 24; 691 int bpp;
676 static int bws[2] = { DP_LINK_BW_1_62, DP_LINK_BW_2_7 }; 692 static int bws[2] = { DP_LINK_BW_1_62, DP_LINK_BW_2_7 };
677 693
678 if (is_edp(intel_dp) && intel_dp->panel_fixed_mode) { 694 if (is_edp(intel_dp) && intel_dp->panel_fixed_mode) {
@@ -686,6 +702,11 @@ intel_dp_mode_fixup(struct drm_encoder *encoder, struct drm_display_mode *mode,
686 mode->clock = intel_dp->panel_fixed_mode->clock; 702 mode->clock = intel_dp->panel_fixed_mode->clock;
687 } 703 }
688 704
705 if (!intel_dp_adjust_dithering(intel_dp, mode, adjusted_mode))
706 return false;
707
708 bpp = adjusted_mode->private_flags & INTEL_MODE_DP_FORCE_6BPC ? 18 : 24;
709
689 for (lane_count = 1; lane_count <= max_lane_count; lane_count <<= 1) { 710 for (lane_count = 1; lane_count <= max_lane_count; lane_count <<= 1) {
690 for (clock = 0; clock <= max_clock; clock++) { 711 for (clock = 0; clock <= max_clock; clock++) {
691 int link_avail = intel_dp_max_data_rate(intel_dp_link_clock(bws[clock]), lane_count); 712 int link_avail = intel_dp_max_data_rate(intel_dp_link_clock(bws[clock]), lane_count);
diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h
index 5a14149b3794..715afa153025 100644
--- a/drivers/gpu/drm/i915/intel_drv.h
+++ b/drivers/gpu/drm/i915/intel_drv.h
@@ -105,6 +105,10 @@
105#define INTEL_MODE_PIXEL_MULTIPLIER_SHIFT (0x0) 105#define INTEL_MODE_PIXEL_MULTIPLIER_SHIFT (0x0)
106#define INTEL_MODE_PIXEL_MULTIPLIER_MASK (0xf << INTEL_MODE_PIXEL_MULTIPLIER_SHIFT) 106#define INTEL_MODE_PIXEL_MULTIPLIER_MASK (0xf << INTEL_MODE_PIXEL_MULTIPLIER_SHIFT)
107#define INTEL_MODE_DP_FORCE_6BPC (0x10) 107#define INTEL_MODE_DP_FORCE_6BPC (0x10)
108/* This flag must be set by the encoder's mode_fixup if it changes the crtc
109 * timings in the mode to prevent the crtc fixup from overwriting them.
110 * Currently only lvds needs that. */
111#define INTEL_MODE_CRTC_TIMINGS_SET (0x20)
108 112
109static inline void 113static inline void
110intel_mode_set_pixel_multiplier(struct drm_display_mode *mode, 114intel_mode_set_pixel_multiplier(struct drm_display_mode *mode,
diff --git a/drivers/gpu/drm/i915/intel_fb.c b/drivers/gpu/drm/i915/intel_fb.c
index 19ecd78b8a2c..6e9ee33fd412 100644
--- a/drivers/gpu/drm/i915/intel_fb.c
+++ b/drivers/gpu/drm/i915/intel_fb.c
@@ -279,6 +279,8 @@ void intel_fb_restore_mode(struct drm_device *dev)
279 struct drm_mode_config *config = &dev->mode_config; 279 struct drm_mode_config *config = &dev->mode_config;
280 struct drm_plane *plane; 280 struct drm_plane *plane;
281 281
282 mutex_lock(&dev->mode_config.mutex);
283
282 ret = drm_fb_helper_restore_fbdev_mode(&dev_priv->fbdev->helper); 284 ret = drm_fb_helper_restore_fbdev_mode(&dev_priv->fbdev->helper);
283 if (ret) 285 if (ret)
284 DRM_DEBUG("failed to restore crtc mode\n"); 286 DRM_DEBUG("failed to restore crtc mode\n");
@@ -286,4 +288,6 @@ void intel_fb_restore_mode(struct drm_device *dev)
286 /* Be sure to shut off any planes that may be active */ 288 /* Be sure to shut off any planes that may be active */
287 list_for_each_entry(plane, &config->plane_list, head) 289 list_for_each_entry(plane, &config->plane_list, head)
288 plane->funcs->disable_plane(plane); 290 plane->funcs->disable_plane(plane);
291
292 mutex_unlock(&dev->mode_config.mutex);
289} 293}
diff --git a/drivers/gpu/drm/i915/intel_i2c.c b/drivers/gpu/drm/i915/intel_i2c.c
index 601c86e664af..8fdc95700218 100644
--- a/drivers/gpu/drm/i915/intel_i2c.c
+++ b/drivers/gpu/drm/i915/intel_i2c.c
@@ -390,7 +390,7 @@ int intel_setup_gmbus(struct drm_device *dev)
390 bus->has_gpio = intel_gpio_setup(bus, i); 390 bus->has_gpio = intel_gpio_setup(bus, i);
391 391
392 /* XXX force bit banging until GMBUS is fully debugged */ 392 /* XXX force bit banging until GMBUS is fully debugged */
393 if (bus->has_gpio && IS_GEN2(dev)) 393 if (bus->has_gpio)
394 bus->force_bit = true; 394 bus->force_bit = true;
395 } 395 }
396 396
diff --git a/drivers/gpu/drm/i915/intel_lvds.c b/drivers/gpu/drm/i915/intel_lvds.c
index 95db2e988227..30e2c82101de 100644
--- a/drivers/gpu/drm/i915/intel_lvds.c
+++ b/drivers/gpu/drm/i915/intel_lvds.c
@@ -187,6 +187,8 @@ centre_horizontally(struct drm_display_mode *mode,
187 187
188 mode->crtc_hsync_start = mode->crtc_hblank_start + sync_pos; 188 mode->crtc_hsync_start = mode->crtc_hblank_start + sync_pos;
189 mode->crtc_hsync_end = mode->crtc_hsync_start + sync_width; 189 mode->crtc_hsync_end = mode->crtc_hsync_start + sync_width;
190
191 mode->private_flags |= INTEL_MODE_CRTC_TIMINGS_SET;
190} 192}
191 193
192static void 194static void
@@ -208,6 +210,8 @@ centre_vertically(struct drm_display_mode *mode,
208 210
209 mode->crtc_vsync_start = mode->crtc_vblank_start + sync_pos; 211 mode->crtc_vsync_start = mode->crtc_vblank_start + sync_pos;
210 mode->crtc_vsync_end = mode->crtc_vsync_start + sync_width; 212 mode->crtc_vsync_end = mode->crtc_vsync_start + sync_width;
213
214 mode->private_flags |= INTEL_MODE_CRTC_TIMINGS_SET;
211} 215}
212 216
213static inline u32 panel_fitter_scaling(u32 source, u32 target) 217static inline u32 panel_fitter_scaling(u32 source, u32 target)
@@ -283,6 +287,8 @@ static bool intel_lvds_mode_fixup(struct drm_encoder *encoder,
283 for_each_pipe(pipe) 287 for_each_pipe(pipe)
284 I915_WRITE(BCLRPAT(pipe), 0); 288 I915_WRITE(BCLRPAT(pipe), 0);
285 289
290 drm_mode_set_crtcinfo(adjusted_mode, 0);
291
286 switch (intel_lvds->fitting_mode) { 292 switch (intel_lvds->fitting_mode) {
287 case DRM_MODE_SCALE_CENTER: 293 case DRM_MODE_SCALE_CENTER:
288 /* 294 /*
diff --git a/drivers/gpu/drm/i915/intel_panel.c b/drivers/gpu/drm/i915/intel_panel.c
index 230a141dbea3..48177ec4720e 100644
--- a/drivers/gpu/drm/i915/intel_panel.c
+++ b/drivers/gpu/drm/i915/intel_panel.c
@@ -47,8 +47,6 @@ intel_fixed_panel_mode(struct drm_display_mode *fixed_mode,
47 adjusted_mode->vtotal = fixed_mode->vtotal; 47 adjusted_mode->vtotal = fixed_mode->vtotal;
48 48
49 adjusted_mode->clock = fixed_mode->clock; 49 adjusted_mode->clock = fixed_mode->clock;
50
51 drm_mode_set_crtcinfo(adjusted_mode, 0);
52} 50}
53 51
54/* adjusted_mode has been preset to be the panel's fixed mode */ 52/* adjusted_mode has been preset to be the panel's fixed mode */
diff --git a/drivers/gpu/drm/i915/intel_ringbuffer.c b/drivers/gpu/drm/i915/intel_ringbuffer.c
index e25581a9f60f..80fce51e2f43 100644
--- a/drivers/gpu/drm/i915/intel_ringbuffer.c
+++ b/drivers/gpu/drm/i915/intel_ringbuffer.c
@@ -401,6 +401,14 @@ static int init_render_ring(struct intel_ring_buffer *ring)
401 if (INTEL_INFO(dev)->gen >= 6) { 401 if (INTEL_INFO(dev)->gen >= 6) {
402 I915_WRITE(INSTPM, 402 I915_WRITE(INSTPM,
403 INSTPM_FORCE_ORDERING << 16 | INSTPM_FORCE_ORDERING); 403 INSTPM_FORCE_ORDERING << 16 | INSTPM_FORCE_ORDERING);
404
405 /* From the Sandybridge PRM, volume 1 part 3, page 24:
406 * "If this bit is set, STCunit will have LRA as replacement
407 * policy. [...] This bit must be reset. LRA replacement
408 * policy is not supported."
409 */
410 I915_WRITE(CACHE_MODE_0,
411 CM0_STC_EVICT_DISABLE_LRA_SNB << CM0_MASK_SHIFT);
404 } 412 }
405 413
406 return ret; 414 return ret;
@@ -1038,7 +1046,7 @@ int intel_init_ring_buffer(struct drm_device *dev,
1038 * of the buffer. 1046 * of the buffer.
1039 */ 1047 */
1040 ring->effective_size = ring->size; 1048 ring->effective_size = ring->size;
1041 if (IS_I830(ring->dev)) 1049 if (IS_I830(ring->dev) || IS_845G(ring->dev))
1042 ring->effective_size -= 128; 1050 ring->effective_size -= 128;
1043 1051
1044 return 0; 1052 return 0;
diff --git a/drivers/gpu/drm/i915/intel_sdvo.c b/drivers/gpu/drm/i915/intel_sdvo.c
index e36b171c1e7d..232d77d07d8b 100644
--- a/drivers/gpu/drm/i915/intel_sdvo.c
+++ b/drivers/gpu/drm/i915/intel_sdvo.c
@@ -731,6 +731,7 @@ static void intel_sdvo_get_dtd_from_mode(struct intel_sdvo_dtd *dtd,
731 uint16_t width, height; 731 uint16_t width, height;
732 uint16_t h_blank_len, h_sync_len, v_blank_len, v_sync_len; 732 uint16_t h_blank_len, h_sync_len, v_blank_len, v_sync_len;
733 uint16_t h_sync_offset, v_sync_offset; 733 uint16_t h_sync_offset, v_sync_offset;
734 int mode_clock;
734 735
735 width = mode->crtc_hdisplay; 736 width = mode->crtc_hdisplay;
736 height = mode->crtc_vdisplay; 737 height = mode->crtc_vdisplay;
@@ -745,7 +746,11 @@ static void intel_sdvo_get_dtd_from_mode(struct intel_sdvo_dtd *dtd,
745 h_sync_offset = mode->crtc_hsync_start - mode->crtc_hblank_start; 746 h_sync_offset = mode->crtc_hsync_start - mode->crtc_hblank_start;
746 v_sync_offset = mode->crtc_vsync_start - mode->crtc_vblank_start; 747 v_sync_offset = mode->crtc_vsync_start - mode->crtc_vblank_start;
747 748
748 dtd->part1.clock = mode->clock / 10; 749 mode_clock = mode->clock;
750 mode_clock /= intel_mode_get_pixel_multiplier(mode) ?: 1;
751 mode_clock /= 10;
752 dtd->part1.clock = mode_clock;
753
749 dtd->part1.h_active = width & 0xff; 754 dtd->part1.h_active = width & 0xff;
750 dtd->part1.h_blank = h_blank_len & 0xff; 755 dtd->part1.h_blank = h_blank_len & 0xff;
751 dtd->part1.h_high = (((width >> 8) & 0xf) << 4) | 756 dtd->part1.h_high = (((width >> 8) & 0xf) << 4) |
@@ -996,7 +1001,7 @@ static void intel_sdvo_mode_set(struct drm_encoder *encoder,
996 struct intel_sdvo *intel_sdvo = to_intel_sdvo(encoder); 1001 struct intel_sdvo *intel_sdvo = to_intel_sdvo(encoder);
997 u32 sdvox; 1002 u32 sdvox;
998 struct intel_sdvo_in_out_map in_out; 1003 struct intel_sdvo_in_out_map in_out;
999 struct intel_sdvo_dtd input_dtd; 1004 struct intel_sdvo_dtd input_dtd, output_dtd;
1000 int pixel_multiplier = intel_mode_get_pixel_multiplier(adjusted_mode); 1005 int pixel_multiplier = intel_mode_get_pixel_multiplier(adjusted_mode);
1001 int rate; 1006 int rate;
1002 1007
@@ -1021,20 +1026,13 @@ static void intel_sdvo_mode_set(struct drm_encoder *encoder,
1021 intel_sdvo->attached_output)) 1026 intel_sdvo->attached_output))
1022 return; 1027 return;
1023 1028
1024 /* We have tried to get input timing in mode_fixup, and filled into 1029 /* lvds has a special fixed output timing. */
1025 * adjusted_mode. 1030 if (intel_sdvo->is_lvds)
1026 */ 1031 intel_sdvo_get_dtd_from_mode(&output_dtd,
1027 if (intel_sdvo->is_tv || intel_sdvo->is_lvds) { 1032 intel_sdvo->sdvo_lvds_fixed_mode);
1028 input_dtd = intel_sdvo->input_dtd; 1033 else
1029 } else { 1034 intel_sdvo_get_dtd_from_mode(&output_dtd, mode);
1030 /* Set the output timing to the screen */ 1035 (void) intel_sdvo_set_output_timing(intel_sdvo, &output_dtd);
1031 if (!intel_sdvo_set_target_output(intel_sdvo,
1032 intel_sdvo->attached_output))
1033 return;
1034
1035 intel_sdvo_get_dtd_from_mode(&input_dtd, adjusted_mode);
1036 (void) intel_sdvo_set_output_timing(intel_sdvo, &input_dtd);
1037 }
1038 1036
1039 /* Set the input timing to the screen. Assume always input 0. */ 1037 /* Set the input timing to the screen. Assume always input 0. */
1040 if (!intel_sdvo_set_target_input(intel_sdvo)) 1038 if (!intel_sdvo_set_target_input(intel_sdvo))
@@ -1052,6 +1050,10 @@ static void intel_sdvo_mode_set(struct drm_encoder *encoder,
1052 !intel_sdvo_set_tv_format(intel_sdvo)) 1050 !intel_sdvo_set_tv_format(intel_sdvo))
1053 return; 1051 return;
1054 1052
1053 /* We have tried to get input timing in mode_fixup, and filled into
1054 * adjusted_mode.
1055 */
1056 intel_sdvo_get_dtd_from_mode(&input_dtd, adjusted_mode);
1055 (void) intel_sdvo_set_input_timing(intel_sdvo, &input_dtd); 1057 (void) intel_sdvo_set_input_timing(intel_sdvo, &input_dtd);
1056 1058
1057 switch (pixel_multiplier) { 1059 switch (pixel_multiplier) {
diff --git a/drivers/gpu/drm/i915/intel_sprite.c b/drivers/gpu/drm/i915/intel_sprite.c
index a464771a7240..e90dfb625c42 100644
--- a/drivers/gpu/drm/i915/intel_sprite.c
+++ b/drivers/gpu/drm/i915/intel_sprite.c
@@ -95,7 +95,6 @@ ivb_update_plane(struct drm_plane *plane, struct drm_framebuffer *fb,
95 /* must disable */ 95 /* must disable */
96 sprctl |= SPRITE_TRICKLE_FEED_DISABLE; 96 sprctl |= SPRITE_TRICKLE_FEED_DISABLE;
97 sprctl |= SPRITE_ENABLE; 97 sprctl |= SPRITE_ENABLE;
98 sprctl |= SPRITE_DEST_KEY;
99 98
100 /* Sizes are 0 based */ 99 /* Sizes are 0 based */
101 src_w--; 100 src_w--;
diff --git a/drivers/gpu/drm/nouveau/nouveau_pm.c b/drivers/gpu/drm/nouveau/nouveau_pm.c
index 34d591b7d4ef..da3e7c3abab7 100644
--- a/drivers/gpu/drm/nouveau/nouveau_pm.c
+++ b/drivers/gpu/drm/nouveau/nouveau_pm.c
@@ -235,6 +235,7 @@ nouveau_pm_profile_set(struct drm_device *dev, const char *profile)
235 return -EPERM; 235 return -EPERM;
236 236
237 strncpy(string, profile, sizeof(string)); 237 strncpy(string, profile, sizeof(string));
238 string[sizeof(string) - 1] = 0;
238 if ((ptr = strchr(string, '\n'))) 239 if ((ptr = strchr(string, '\n')))
239 *ptr = '\0'; 240 *ptr = '\0';
240 241
diff --git a/drivers/gpu/drm/nouveau/nv50_sor.c b/drivers/gpu/drm/nouveau/nv50_sor.c
index a7844ab6a50c..274640212475 100644
--- a/drivers/gpu/drm/nouveau/nv50_sor.c
+++ b/drivers/gpu/drm/nouveau/nv50_sor.c
@@ -42,7 +42,7 @@ nv50_sor_dp_lane_map(struct drm_device *dev, struct dcb_entry *dcb, u8 lane)
42 struct drm_nouveau_private *dev_priv = dev->dev_private; 42 struct drm_nouveau_private *dev_priv = dev->dev_private;
43 static const u8 nvaf[] = { 24, 16, 8, 0 }; /* thanks, apple.. */ 43 static const u8 nvaf[] = { 24, 16, 8, 0 }; /* thanks, apple.. */
44 static const u8 nv50[] = { 16, 8, 0, 24 }; 44 static const u8 nv50[] = { 16, 8, 0, 24 };
45 if (dev_priv->card_type == 0xaf) 45 if (dev_priv->chipset == 0xaf)
46 return nvaf[lane]; 46 return nvaf[lane];
47 return nv50[lane]; 47 return nv50[lane];
48} 48}
diff --git a/drivers/gpu/drm/radeon/atombios_crtc.c b/drivers/gpu/drm/radeon/atombios_crtc.c
index b5ff1f7b6f7e..af1054f8202a 100644
--- a/drivers/gpu/drm/radeon/atombios_crtc.c
+++ b/drivers/gpu/drm/radeon/atombios_crtc.c
@@ -575,6 +575,9 @@ static u32 atombios_adjust_pll(struct drm_crtc *crtc,
575 575
576 if (rdev->family < CHIP_RV770) 576 if (rdev->family < CHIP_RV770)
577 pll->flags |= RADEON_PLL_PREFER_MINM_OVER_MAXP; 577 pll->flags |= RADEON_PLL_PREFER_MINM_OVER_MAXP;
578 /* use frac fb div on APUs */
579 if (ASIC_IS_DCE41(rdev) || ASIC_IS_DCE61(rdev))
580 pll->flags |= RADEON_PLL_USE_FRAC_FB_DIV;
578 } else { 581 } else {
579 pll->flags |= RADEON_PLL_LEGACY; 582 pll->flags |= RADEON_PLL_LEGACY;
580 583
@@ -955,8 +958,8 @@ static void atombios_crtc_set_pll(struct drm_crtc *crtc, struct drm_display_mode
955 break; 958 break;
956 } 959 }
957 960
958 if (radeon_encoder->active_device & 961 if ((radeon_encoder->active_device & (ATOM_DEVICE_LCD_SUPPORT | ATOM_DEVICE_DFP_SUPPORT)) ||
959 (ATOM_DEVICE_LCD_SUPPORT | ATOM_DEVICE_DFP_SUPPORT)) { 962 (radeon_encoder_get_dp_bridge_encoder_id(encoder) != ENCODER_OBJECT_ID_NONE)) {
960 struct radeon_encoder_atom_dig *dig = radeon_encoder->enc_priv; 963 struct radeon_encoder_atom_dig *dig = radeon_encoder->enc_priv;
961 struct drm_connector *connector = 964 struct drm_connector *connector =
962 radeon_get_connector_for_encoder(encoder); 965 radeon_get_connector_for_encoder(encoder);
diff --git a/drivers/gpu/drm/radeon/atombios_encoders.c b/drivers/gpu/drm/radeon/atombios_encoders.c
index e607c4d7dd98..2d39f9977e00 100644
--- a/drivers/gpu/drm/radeon/atombios_encoders.c
+++ b/drivers/gpu/drm/radeon/atombios_encoders.c
@@ -230,6 +230,10 @@ atombios_dvo_setup(struct drm_encoder *encoder, int action)
230 if (!atom_parse_cmd_header(rdev->mode_info.atom_context, index, &frev, &crev)) 230 if (!atom_parse_cmd_header(rdev->mode_info.atom_context, index, &frev, &crev))
231 return; 231 return;
232 232
233 /* some R4xx chips have the wrong frev */
234 if (rdev->family <= CHIP_RV410)
235 frev = 1;
236
233 switch (frev) { 237 switch (frev) {
234 case 1: 238 case 1:
235 switch (crev) { 239 switch (crev) {
diff --git a/drivers/gpu/drm/radeon/r100.c b/drivers/gpu/drm/radeon/r100.c
index 81801c176aa5..fe33d35dae8c 100644
--- a/drivers/gpu/drm/radeon/r100.c
+++ b/drivers/gpu/drm/radeon/r100.c
@@ -2553,7 +2553,7 @@ static void r100_pll_errata_after_data(struct radeon_device *rdev)
2553 * or the chip could hang on a subsequent access 2553 * or the chip could hang on a subsequent access
2554 */ 2554 */
2555 if (rdev->pll_errata & CHIP_ERRATA_PLL_DELAY) { 2555 if (rdev->pll_errata & CHIP_ERRATA_PLL_DELAY) {
2556 udelay(5000); 2556 mdelay(5);
2557 } 2557 }
2558 2558
2559 /* This function is required to workaround a hardware bug in some (all?) 2559 /* This function is required to workaround a hardware bug in some (all?)
diff --git a/drivers/gpu/drm/radeon/r600.c b/drivers/gpu/drm/radeon/r600.c
index 391bd2636a80..c8187c4b6ae8 100644
--- a/drivers/gpu/drm/radeon/r600.c
+++ b/drivers/gpu/drm/radeon/r600.c
@@ -1135,7 +1135,7 @@ static void r600_vram_gtt_location(struct radeon_device *rdev, struct radeon_mc
1135 } 1135 }
1136 if (rdev->flags & RADEON_IS_AGP) { 1136 if (rdev->flags & RADEON_IS_AGP) {
1137 size_bf = mc->gtt_start; 1137 size_bf = mc->gtt_start;
1138 size_af = 0xFFFFFFFF - mc->gtt_end + 1; 1138 size_af = 0xFFFFFFFF - mc->gtt_end;
1139 if (size_bf > size_af) { 1139 if (size_bf > size_af) {
1140 if (mc->mc_vram_size > size_bf) { 1140 if (mc->mc_vram_size > size_bf) {
1141 dev_warn(rdev->dev, "limiting VRAM\n"); 1141 dev_warn(rdev->dev, "limiting VRAM\n");
@@ -1149,7 +1149,7 @@ static void r600_vram_gtt_location(struct radeon_device *rdev, struct radeon_mc
1149 mc->real_vram_size = size_af; 1149 mc->real_vram_size = size_af;
1150 mc->mc_vram_size = size_af; 1150 mc->mc_vram_size = size_af;
1151 } 1151 }
1152 mc->vram_start = mc->gtt_end; 1152 mc->vram_start = mc->gtt_end + 1;
1153 } 1153 }
1154 mc->vram_end = mc->vram_start + mc->mc_vram_size - 1; 1154 mc->vram_end = mc->vram_start + mc->mc_vram_size - 1;
1155 dev_info(rdev->dev, "VRAM: %lluM 0x%08llX - 0x%08llX (%lluM used)\n", 1155 dev_info(rdev->dev, "VRAM: %lluM 0x%08llX - 0x%08llX (%lluM used)\n",
@@ -2839,7 +2839,7 @@ void r600_rlc_stop(struct radeon_device *rdev)
2839 /* r7xx asics need to soft reset RLC before halting */ 2839 /* r7xx asics need to soft reset RLC before halting */
2840 WREG32(SRBM_SOFT_RESET, SOFT_RESET_RLC); 2840 WREG32(SRBM_SOFT_RESET, SOFT_RESET_RLC);
2841 RREG32(SRBM_SOFT_RESET); 2841 RREG32(SRBM_SOFT_RESET);
2842 udelay(15000); 2842 mdelay(15);
2843 WREG32(SRBM_SOFT_RESET, 0); 2843 WREG32(SRBM_SOFT_RESET, 0);
2844 RREG32(SRBM_SOFT_RESET); 2844 RREG32(SRBM_SOFT_RESET);
2845 } 2845 }
diff --git a/drivers/gpu/drm/radeon/r600_cp.c b/drivers/gpu/drm/radeon/r600_cp.c
index 84c546250955..75ed17c96115 100644
--- a/drivers/gpu/drm/radeon/r600_cp.c
+++ b/drivers/gpu/drm/radeon/r600_cp.c
@@ -407,7 +407,7 @@ static void r600_cp_load_microcode(drm_radeon_private_t *dev_priv)
407 407
408 RADEON_WRITE(R600_GRBM_SOFT_RESET, R600_SOFT_RESET_CP); 408 RADEON_WRITE(R600_GRBM_SOFT_RESET, R600_SOFT_RESET_CP);
409 RADEON_READ(R600_GRBM_SOFT_RESET); 409 RADEON_READ(R600_GRBM_SOFT_RESET);
410 DRM_UDELAY(15000); 410 mdelay(15);
411 RADEON_WRITE(R600_GRBM_SOFT_RESET, 0); 411 RADEON_WRITE(R600_GRBM_SOFT_RESET, 0);
412 412
413 fw_data = (const __be32 *)dev_priv->me_fw->data; 413 fw_data = (const __be32 *)dev_priv->me_fw->data;
@@ -500,7 +500,7 @@ static void r700_cp_load_microcode(drm_radeon_private_t *dev_priv)
500 500
501 RADEON_WRITE(R600_GRBM_SOFT_RESET, R600_SOFT_RESET_CP); 501 RADEON_WRITE(R600_GRBM_SOFT_RESET, R600_SOFT_RESET_CP);
502 RADEON_READ(R600_GRBM_SOFT_RESET); 502 RADEON_READ(R600_GRBM_SOFT_RESET);
503 DRM_UDELAY(15000); 503 mdelay(15);
504 RADEON_WRITE(R600_GRBM_SOFT_RESET, 0); 504 RADEON_WRITE(R600_GRBM_SOFT_RESET, 0);
505 505
506 fw_data = (const __be32 *)dev_priv->pfp_fw->data; 506 fw_data = (const __be32 *)dev_priv->pfp_fw->data;
@@ -1797,7 +1797,7 @@ static void r600_cp_init_ring_buffer(struct drm_device *dev,
1797 1797
1798 RADEON_WRITE(R600_GRBM_SOFT_RESET, R600_SOFT_RESET_CP); 1798 RADEON_WRITE(R600_GRBM_SOFT_RESET, R600_SOFT_RESET_CP);
1799 RADEON_READ(R600_GRBM_SOFT_RESET); 1799 RADEON_READ(R600_GRBM_SOFT_RESET);
1800 DRM_UDELAY(15000); 1800 mdelay(15);
1801 RADEON_WRITE(R600_GRBM_SOFT_RESET, 0); 1801 RADEON_WRITE(R600_GRBM_SOFT_RESET, 0);
1802 1802
1803 1803
diff --git a/drivers/gpu/drm/radeon/radeon_clocks.c b/drivers/gpu/drm/radeon/radeon_clocks.c
index 6ae0c75f016a..9c6b29a41927 100644
--- a/drivers/gpu/drm/radeon/radeon_clocks.c
+++ b/drivers/gpu/drm/radeon/radeon_clocks.c
@@ -633,7 +633,7 @@ void radeon_legacy_set_clock_gating(struct radeon_device *rdev, int enable)
633 tmp &= ~(R300_SCLK_FORCE_VAP); 633 tmp &= ~(R300_SCLK_FORCE_VAP);
634 tmp |= RADEON_SCLK_FORCE_CP; 634 tmp |= RADEON_SCLK_FORCE_CP;
635 WREG32_PLL(RADEON_SCLK_CNTL, tmp); 635 WREG32_PLL(RADEON_SCLK_CNTL, tmp);
636 udelay(15000); 636 mdelay(15);
637 637
638 tmp = RREG32_PLL(R300_SCLK_CNTL2); 638 tmp = RREG32_PLL(R300_SCLK_CNTL2);
639 tmp &= ~(R300_SCLK_FORCE_TCL | 639 tmp &= ~(R300_SCLK_FORCE_TCL |
@@ -651,12 +651,12 @@ void radeon_legacy_set_clock_gating(struct radeon_device *rdev, int enable)
651 tmp |= (RADEON_ENGIN_DYNCLK_MODE | 651 tmp |= (RADEON_ENGIN_DYNCLK_MODE |
652 (0x01 << RADEON_ACTIVE_HILO_LAT_SHIFT)); 652 (0x01 << RADEON_ACTIVE_HILO_LAT_SHIFT));
653 WREG32_PLL(RADEON_CLK_PWRMGT_CNTL, tmp); 653 WREG32_PLL(RADEON_CLK_PWRMGT_CNTL, tmp);
654 udelay(15000); 654 mdelay(15);
655 655
656 tmp = RREG32_PLL(RADEON_CLK_PIN_CNTL); 656 tmp = RREG32_PLL(RADEON_CLK_PIN_CNTL);
657 tmp |= RADEON_SCLK_DYN_START_CNTL; 657 tmp |= RADEON_SCLK_DYN_START_CNTL;
658 WREG32_PLL(RADEON_CLK_PIN_CNTL, tmp); 658 WREG32_PLL(RADEON_CLK_PIN_CNTL, tmp);
659 udelay(15000); 659 mdelay(15);
660 660
661 /* When DRI is enabled, setting DYN_STOP_LAT to zero can cause some R200 661 /* When DRI is enabled, setting DYN_STOP_LAT to zero can cause some R200
662 to lockup randomly, leave them as set by BIOS. 662 to lockup randomly, leave them as set by BIOS.
@@ -696,7 +696,7 @@ void radeon_legacy_set_clock_gating(struct radeon_device *rdev, int enable)
696 tmp |= RADEON_SCLK_MORE_FORCEON; 696 tmp |= RADEON_SCLK_MORE_FORCEON;
697 } 697 }
698 WREG32_PLL(RADEON_SCLK_MORE_CNTL, tmp); 698 WREG32_PLL(RADEON_SCLK_MORE_CNTL, tmp);
699 udelay(15000); 699 mdelay(15);
700 } 700 }
701 701
702 /* RV200::A11 A12, RV250::A11 A12 */ 702 /* RV200::A11 A12, RV250::A11 A12 */
@@ -709,7 +709,7 @@ void radeon_legacy_set_clock_gating(struct radeon_device *rdev, int enable)
709 tmp |= RADEON_TCL_BYPASS_DISABLE; 709 tmp |= RADEON_TCL_BYPASS_DISABLE;
710 WREG32_PLL(RADEON_PLL_PWRMGT_CNTL, tmp); 710 WREG32_PLL(RADEON_PLL_PWRMGT_CNTL, tmp);
711 } 711 }
712 udelay(15000); 712 mdelay(15);
713 713
714 /*enable dynamic mode for display clocks (PIXCLK and PIX2CLK) */ 714 /*enable dynamic mode for display clocks (PIXCLK and PIX2CLK) */
715 tmp = RREG32_PLL(RADEON_PIXCLKS_CNTL); 715 tmp = RREG32_PLL(RADEON_PIXCLKS_CNTL);
@@ -722,14 +722,14 @@ void radeon_legacy_set_clock_gating(struct radeon_device *rdev, int enable)
722 RADEON_PIXCLK_TMDS_ALWAYS_ONb); 722 RADEON_PIXCLK_TMDS_ALWAYS_ONb);
723 723
724 WREG32_PLL(RADEON_PIXCLKS_CNTL, tmp); 724 WREG32_PLL(RADEON_PIXCLKS_CNTL, tmp);
725 udelay(15000); 725 mdelay(15);
726 726
727 tmp = RREG32_PLL(RADEON_VCLK_ECP_CNTL); 727 tmp = RREG32_PLL(RADEON_VCLK_ECP_CNTL);
728 tmp |= (RADEON_PIXCLK_ALWAYS_ONb | 728 tmp |= (RADEON_PIXCLK_ALWAYS_ONb |
729 RADEON_PIXCLK_DAC_ALWAYS_ONb); 729 RADEON_PIXCLK_DAC_ALWAYS_ONb);
730 730
731 WREG32_PLL(RADEON_VCLK_ECP_CNTL, tmp); 731 WREG32_PLL(RADEON_VCLK_ECP_CNTL, tmp);
732 udelay(15000); 732 mdelay(15);
733 } 733 }
734 } else { 734 } else {
735 /* Turn everything OFF (ForceON to everything) */ 735 /* Turn everything OFF (ForceON to everything) */
@@ -861,7 +861,7 @@ void radeon_legacy_set_clock_gating(struct radeon_device *rdev, int enable)
861 } 861 }
862 WREG32_PLL(RADEON_SCLK_CNTL, tmp); 862 WREG32_PLL(RADEON_SCLK_CNTL, tmp);
863 863
864 udelay(16000); 864 mdelay(16);
865 865
866 if ((rdev->family == CHIP_R300) || 866 if ((rdev->family == CHIP_R300) ||
867 (rdev->family == CHIP_R350)) { 867 (rdev->family == CHIP_R350)) {
@@ -870,7 +870,7 @@ void radeon_legacy_set_clock_gating(struct radeon_device *rdev, int enable)
870 R300_SCLK_FORCE_GA | 870 R300_SCLK_FORCE_GA |
871 R300_SCLK_FORCE_CBA); 871 R300_SCLK_FORCE_CBA);
872 WREG32_PLL(R300_SCLK_CNTL2, tmp); 872 WREG32_PLL(R300_SCLK_CNTL2, tmp);
873 udelay(16000); 873 mdelay(16);
874 } 874 }
875 875
876 if (rdev->flags & RADEON_IS_IGP) { 876 if (rdev->flags & RADEON_IS_IGP) {
@@ -878,7 +878,7 @@ void radeon_legacy_set_clock_gating(struct radeon_device *rdev, int enable)
878 tmp &= ~(RADEON_FORCEON_MCLKA | 878 tmp &= ~(RADEON_FORCEON_MCLKA |
879 RADEON_FORCEON_YCLKA); 879 RADEON_FORCEON_YCLKA);
880 WREG32_PLL(RADEON_MCLK_CNTL, tmp); 880 WREG32_PLL(RADEON_MCLK_CNTL, tmp);
881 udelay(16000); 881 mdelay(16);
882 } 882 }
883 883
884 if ((rdev->family == CHIP_RV200) || 884 if ((rdev->family == CHIP_RV200) ||
@@ -887,7 +887,7 @@ void radeon_legacy_set_clock_gating(struct radeon_device *rdev, int enable)
887 tmp = RREG32_PLL(RADEON_SCLK_MORE_CNTL); 887 tmp = RREG32_PLL(RADEON_SCLK_MORE_CNTL);
888 tmp |= RADEON_SCLK_MORE_FORCEON; 888 tmp |= RADEON_SCLK_MORE_FORCEON;
889 WREG32_PLL(RADEON_SCLK_MORE_CNTL, tmp); 889 WREG32_PLL(RADEON_SCLK_MORE_CNTL, tmp);
890 udelay(16000); 890 mdelay(16);
891 } 891 }
892 892
893 tmp = RREG32_PLL(RADEON_PIXCLKS_CNTL); 893 tmp = RREG32_PLL(RADEON_PIXCLKS_CNTL);
@@ -900,7 +900,7 @@ void radeon_legacy_set_clock_gating(struct radeon_device *rdev, int enable)
900 RADEON_PIXCLK_TMDS_ALWAYS_ONb); 900 RADEON_PIXCLK_TMDS_ALWAYS_ONb);
901 901
902 WREG32_PLL(RADEON_PIXCLKS_CNTL, tmp); 902 WREG32_PLL(RADEON_PIXCLKS_CNTL, tmp);
903 udelay(16000); 903 mdelay(16);
904 904
905 tmp = RREG32_PLL(RADEON_VCLK_ECP_CNTL); 905 tmp = RREG32_PLL(RADEON_VCLK_ECP_CNTL);
906 tmp &= ~(RADEON_PIXCLK_ALWAYS_ONb | 906 tmp &= ~(RADEON_PIXCLK_ALWAYS_ONb |
diff --git a/drivers/gpu/drm/radeon/radeon_combios.c b/drivers/gpu/drm/radeon/radeon_combios.c
index 81fc100be7e1..2cad9fde92fc 100644
--- a/drivers/gpu/drm/radeon/radeon_combios.c
+++ b/drivers/gpu/drm/radeon/radeon_combios.c
@@ -2845,7 +2845,7 @@ bool radeon_combios_external_tmds_setup(struct drm_encoder *encoder)
2845 case 4: 2845 case 4:
2846 val = RBIOS16(index); 2846 val = RBIOS16(index);
2847 index += 2; 2847 index += 2;
2848 udelay(val * 1000); 2848 mdelay(val);
2849 break; 2849 break;
2850 case 6: 2850 case 6:
2851 slave_addr = id & 0xff; 2851 slave_addr = id & 0xff;
@@ -3044,7 +3044,7 @@ static void combios_parse_pll_table(struct drm_device *dev, uint16_t offset)
3044 udelay(150); 3044 udelay(150);
3045 break; 3045 break;
3046 case 2: 3046 case 2:
3047 udelay(1000); 3047 mdelay(1);
3048 break; 3048 break;
3049 case 3: 3049 case 3:
3050 while (tmp--) { 3050 while (tmp--) {
@@ -3075,13 +3075,13 @@ static void combios_parse_pll_table(struct drm_device *dev, uint16_t offset)
3075 /*mclk_cntl |= 0x00001111;*//* ??? */ 3075 /*mclk_cntl |= 0x00001111;*//* ??? */
3076 WREG32_PLL(RADEON_MCLK_CNTL, 3076 WREG32_PLL(RADEON_MCLK_CNTL,
3077 mclk_cntl); 3077 mclk_cntl);
3078 udelay(10000); 3078 mdelay(10);
3079#endif 3079#endif
3080 WREG32_PLL 3080 WREG32_PLL
3081 (RADEON_CLK_PWRMGT_CNTL, 3081 (RADEON_CLK_PWRMGT_CNTL,
3082 tmp & 3082 tmp &
3083 ~RADEON_CG_NO1_DEBUG_0); 3083 ~RADEON_CG_NO1_DEBUG_0);
3084 udelay(10000); 3084 mdelay(10);
3085 } 3085 }
3086 break; 3086 break;
3087 default: 3087 default:
diff --git a/drivers/gpu/drm/radeon/radeon_connectors.c b/drivers/gpu/drm/radeon/radeon_connectors.c
index bd05156edbdb..3c2e7a000a2a 100644
--- a/drivers/gpu/drm/radeon/radeon_connectors.c
+++ b/drivers/gpu/drm/radeon/radeon_connectors.c
@@ -970,7 +970,7 @@ radeon_dvi_detect(struct drm_connector *connector, bool force)
970 970
971 encoder = obj_to_encoder(obj); 971 encoder = obj_to_encoder(obj);
972 972
973 if (encoder->encoder_type != DRM_MODE_ENCODER_DAC || 973 if (encoder->encoder_type != DRM_MODE_ENCODER_DAC &&
974 encoder->encoder_type != DRM_MODE_ENCODER_TVDAC) 974 encoder->encoder_type != DRM_MODE_ENCODER_TVDAC)
975 continue; 975 continue;
976 976
@@ -1000,6 +1000,7 @@ radeon_dvi_detect(struct drm_connector *connector, bool force)
1000 * cases the DVI port is actually a virtual KVM port connected to the service 1000 * cases the DVI port is actually a virtual KVM port connected to the service
1001 * processor. 1001 * processor.
1002 */ 1002 */
1003out:
1003 if ((!rdev->is_atom_bios) && 1004 if ((!rdev->is_atom_bios) &&
1004 (ret == connector_status_disconnected) && 1005 (ret == connector_status_disconnected) &&
1005 rdev->mode_info.bios_hardcoded_edid_size) { 1006 rdev->mode_info.bios_hardcoded_edid_size) {
@@ -1007,7 +1008,6 @@ radeon_dvi_detect(struct drm_connector *connector, bool force)
1007 ret = connector_status_connected; 1008 ret = connector_status_connected;
1008 } 1009 }
1009 1010
1010out:
1011 /* updated in get modes as well since we need to know if it's analog or digital */ 1011 /* updated in get modes as well since we need to know if it's analog or digital */
1012 radeon_connector_update_scratch_regs(connector, ret); 1012 radeon_connector_update_scratch_regs(connector, ret);
1013 return ret; 1013 return ret;
diff --git a/drivers/gpu/drm/radeon/radeon_display.c b/drivers/gpu/drm/radeon/radeon_display.c
index 8086c96e0b06..0a1d4bd65edc 100644
--- a/drivers/gpu/drm/radeon/radeon_display.c
+++ b/drivers/gpu/drm/radeon/radeon_display.c
@@ -533,7 +533,7 @@ static void radeon_crtc_init(struct drm_device *dev, int index)
533 radeon_legacy_init_crtc(dev, radeon_crtc); 533 radeon_legacy_init_crtc(dev, radeon_crtc);
534} 534}
535 535
536static const char *encoder_names[36] = { 536static const char *encoder_names[37] = {
537 "NONE", 537 "NONE",
538 "INTERNAL_LVDS", 538 "INTERNAL_LVDS",
539 "INTERNAL_TMDS1", 539 "INTERNAL_TMDS1",
@@ -570,6 +570,7 @@ static const char *encoder_names[36] = {
570 "INTERNAL_UNIPHY2", 570 "INTERNAL_UNIPHY2",
571 "NUTMEG", 571 "NUTMEG",
572 "TRAVIS", 572 "TRAVIS",
573 "INTERNAL_VCE"
573}; 574};
574 575
575static const char *connector_names[15] = { 576static const char *connector_names[15] = {
diff --git a/drivers/gpu/drm/radeon/radeon_i2c.c b/drivers/gpu/drm/radeon/radeon_i2c.c
index 85bcfc8923a7..3edec1c198e3 100644
--- a/drivers/gpu/drm/radeon/radeon_i2c.c
+++ b/drivers/gpu/drm/radeon/radeon_i2c.c
@@ -900,6 +900,10 @@ struct radeon_i2c_chan *radeon_i2c_create(struct drm_device *dev,
900 struct radeon_i2c_chan *i2c; 900 struct radeon_i2c_chan *i2c;
901 int ret; 901 int ret;
902 902
903 /* don't add the mm_i2c bus unless hw_i2c is enabled */
904 if (rec->mm_i2c && (radeon_hw_i2c == 0))
905 return NULL;
906
903 i2c = kzalloc(sizeof(struct radeon_i2c_chan), GFP_KERNEL); 907 i2c = kzalloc(sizeof(struct radeon_i2c_chan), GFP_KERNEL);
904 if (i2c == NULL) 908 if (i2c == NULL)
905 return NULL; 909 return NULL;
diff --git a/drivers/gpu/drm/radeon/radeon_irq_kms.c b/drivers/gpu/drm/radeon/radeon_irq_kms.c
index 66d5fe1c8174..65060b77c805 100644
--- a/drivers/gpu/drm/radeon/radeon_irq_kms.c
+++ b/drivers/gpu/drm/radeon/radeon_irq_kms.c
@@ -147,6 +147,12 @@ static bool radeon_msi_ok(struct radeon_device *rdev)
147 (rdev->pdev->subsystem_device == 0x01fd)) 147 (rdev->pdev->subsystem_device == 0x01fd))
148 return true; 148 return true;
149 149
150 /* RV515 seems to have MSI issues where it loses
151 * MSI rearms occasionally. This leads to lockups and freezes.
152 * disable it by default.
153 */
154 if (rdev->family == CHIP_RV515)
155 return false;
150 if (rdev->flags & RADEON_IS_IGP) { 156 if (rdev->flags & RADEON_IS_IGP) {
151 /* APUs work fine with MSIs */ 157 /* APUs work fine with MSIs */
152 if (rdev->family >= CHIP_PALM) 158 if (rdev->family >= CHIP_PALM)
diff --git a/drivers/gpu/drm/radeon/radeon_legacy_encoders.c b/drivers/gpu/drm/radeon/radeon_legacy_encoders.c
index 2f46e0c8df53..42db254f6bb0 100644
--- a/drivers/gpu/drm/radeon/radeon_legacy_encoders.c
+++ b/drivers/gpu/drm/radeon/radeon_legacy_encoders.c
@@ -88,7 +88,7 @@ static void radeon_legacy_lvds_update(struct drm_encoder *encoder, int mode)
88 lvds_pll_cntl = RREG32(RADEON_LVDS_PLL_CNTL); 88 lvds_pll_cntl = RREG32(RADEON_LVDS_PLL_CNTL);
89 lvds_pll_cntl |= RADEON_LVDS_PLL_EN; 89 lvds_pll_cntl |= RADEON_LVDS_PLL_EN;
90 WREG32(RADEON_LVDS_PLL_CNTL, lvds_pll_cntl); 90 WREG32(RADEON_LVDS_PLL_CNTL, lvds_pll_cntl);
91 udelay(1000); 91 mdelay(1);
92 92
93 lvds_pll_cntl = RREG32(RADEON_LVDS_PLL_CNTL); 93 lvds_pll_cntl = RREG32(RADEON_LVDS_PLL_CNTL);
94 lvds_pll_cntl &= ~RADEON_LVDS_PLL_RESET; 94 lvds_pll_cntl &= ~RADEON_LVDS_PLL_RESET;
@@ -101,7 +101,7 @@ static void radeon_legacy_lvds_update(struct drm_encoder *encoder, int mode)
101 (backlight_level << RADEON_LVDS_BL_MOD_LEVEL_SHIFT)); 101 (backlight_level << RADEON_LVDS_BL_MOD_LEVEL_SHIFT));
102 if (is_mac) 102 if (is_mac)
103 lvds_gen_cntl |= RADEON_LVDS_BL_MOD_EN; 103 lvds_gen_cntl |= RADEON_LVDS_BL_MOD_EN;
104 udelay(panel_pwr_delay * 1000); 104 mdelay(panel_pwr_delay);
105 WREG32(RADEON_LVDS_GEN_CNTL, lvds_gen_cntl); 105 WREG32(RADEON_LVDS_GEN_CNTL, lvds_gen_cntl);
106 break; 106 break;
107 case DRM_MODE_DPMS_STANDBY: 107 case DRM_MODE_DPMS_STANDBY:
@@ -118,10 +118,10 @@ static void radeon_legacy_lvds_update(struct drm_encoder *encoder, int mode)
118 WREG32(RADEON_LVDS_GEN_CNTL, lvds_gen_cntl); 118 WREG32(RADEON_LVDS_GEN_CNTL, lvds_gen_cntl);
119 lvds_gen_cntl &= ~(RADEON_LVDS_ON | RADEON_LVDS_BLON | RADEON_LVDS_EN | RADEON_LVDS_DIGON); 119 lvds_gen_cntl &= ~(RADEON_LVDS_ON | RADEON_LVDS_BLON | RADEON_LVDS_EN | RADEON_LVDS_DIGON);
120 } 120 }
121 udelay(panel_pwr_delay * 1000); 121 mdelay(panel_pwr_delay);
122 WREG32(RADEON_LVDS_GEN_CNTL, lvds_gen_cntl); 122 WREG32(RADEON_LVDS_GEN_CNTL, lvds_gen_cntl);
123 WREG32_PLL(RADEON_PIXCLKS_CNTL, pixclks_cntl); 123 WREG32_PLL(RADEON_PIXCLKS_CNTL, pixclks_cntl);
124 udelay(panel_pwr_delay * 1000); 124 mdelay(panel_pwr_delay);
125 break; 125 break;
126 } 126 }
127 127
@@ -656,7 +656,7 @@ static enum drm_connector_status radeon_legacy_primary_dac_detect(struct drm_enc
656 656
657 WREG32(RADEON_DAC_MACRO_CNTL, tmp); 657 WREG32(RADEON_DAC_MACRO_CNTL, tmp);
658 658
659 udelay(2000); 659 mdelay(2);
660 660
661 if (RREG32(RADEON_DAC_CNTL) & RADEON_DAC_CMP_OUTPUT) 661 if (RREG32(RADEON_DAC_CNTL) & RADEON_DAC_CMP_OUTPUT)
662 found = connector_status_connected; 662 found = connector_status_connected;
@@ -1499,7 +1499,7 @@ static enum drm_connector_status radeon_legacy_tv_dac_detect(struct drm_encoder
1499 tmp = dac_cntl2 | RADEON_DAC2_DAC2_CLK_SEL | RADEON_DAC2_CMP_EN; 1499 tmp = dac_cntl2 | RADEON_DAC2_DAC2_CLK_SEL | RADEON_DAC2_CMP_EN;
1500 WREG32(RADEON_DAC_CNTL2, tmp); 1500 WREG32(RADEON_DAC_CNTL2, tmp);
1501 1501
1502 udelay(10000); 1502 mdelay(10);
1503 1503
1504 if (ASIC_IS_R300(rdev)) { 1504 if (ASIC_IS_R300(rdev)) {
1505 if (RREG32(RADEON_DAC_CNTL2) & RADEON_DAC2_CMP_OUT_B) 1505 if (RREG32(RADEON_DAC_CNTL2) & RADEON_DAC2_CMP_OUT_B)
diff --git a/drivers/gpu/drm/radeon/rv770.c b/drivers/gpu/drm/radeon/rv770.c
index c62ae4be3845..cdab1aeaed6e 100644
--- a/drivers/gpu/drm/radeon/rv770.c
+++ b/drivers/gpu/drm/radeon/rv770.c
@@ -969,7 +969,7 @@ void r700_vram_gtt_location(struct radeon_device *rdev, struct radeon_mc *mc)
969 } 969 }
970 if (rdev->flags & RADEON_IS_AGP) { 970 if (rdev->flags & RADEON_IS_AGP) {
971 size_bf = mc->gtt_start; 971 size_bf = mc->gtt_start;
972 size_af = 0xFFFFFFFF - mc->gtt_end + 1; 972 size_af = 0xFFFFFFFF - mc->gtt_end;
973 if (size_bf > size_af) { 973 if (size_bf > size_af) {
974 if (mc->mc_vram_size > size_bf) { 974 if (mc->mc_vram_size > size_bf) {
975 dev_warn(rdev->dev, "limiting VRAM\n"); 975 dev_warn(rdev->dev, "limiting VRAM\n");
@@ -983,7 +983,7 @@ void r700_vram_gtt_location(struct radeon_device *rdev, struct radeon_mc *mc)
983 mc->real_vram_size = size_af; 983 mc->real_vram_size = size_af;
984 mc->mc_vram_size = size_af; 984 mc->mc_vram_size = size_af;
985 } 985 }
986 mc->vram_start = mc->gtt_end; 986 mc->vram_start = mc->gtt_end + 1;
987 } 987 }
988 mc->vram_end = mc->vram_start + mc->mc_vram_size - 1; 988 mc->vram_end = mc->vram_start + mc->mc_vram_size - 1;
989 dev_info(rdev->dev, "VRAM: %lluM 0x%08llX - 0x%08llX (%lluM used)\n", 989 dev_info(rdev->dev, "VRAM: %lluM 0x%08llX - 0x%08llX (%lluM used)\n",
diff --git a/drivers/gpu/drm/radeon/si.c b/drivers/gpu/drm/radeon/si.c
index ac7a199ffece..27bda986fc2b 100644
--- a/drivers/gpu/drm/radeon/si.c
+++ b/drivers/gpu/drm/radeon/si.c
@@ -2999,8 +2999,8 @@ int si_rlc_init(struct radeon_device *rdev)
2999 } 2999 }
3000 r = radeon_bo_pin(rdev->rlc.save_restore_obj, RADEON_GEM_DOMAIN_VRAM, 3000 r = radeon_bo_pin(rdev->rlc.save_restore_obj, RADEON_GEM_DOMAIN_VRAM,
3001 &rdev->rlc.save_restore_gpu_addr); 3001 &rdev->rlc.save_restore_gpu_addr);
3002 radeon_bo_unreserve(rdev->rlc.save_restore_obj);
3002 if (r) { 3003 if (r) {
3003 radeon_bo_unreserve(rdev->rlc.save_restore_obj);
3004 dev_warn(rdev->dev, "(%d) pin RLC sr bo failed\n", r); 3004 dev_warn(rdev->dev, "(%d) pin RLC sr bo failed\n", r);
3005 si_rlc_fini(rdev); 3005 si_rlc_fini(rdev);
3006 return r; 3006 return r;
@@ -3023,9 +3023,8 @@ int si_rlc_init(struct radeon_device *rdev)
3023 } 3023 }
3024 r = radeon_bo_pin(rdev->rlc.clear_state_obj, RADEON_GEM_DOMAIN_VRAM, 3024 r = radeon_bo_pin(rdev->rlc.clear_state_obj, RADEON_GEM_DOMAIN_VRAM,
3025 &rdev->rlc.clear_state_gpu_addr); 3025 &rdev->rlc.clear_state_gpu_addr);
3026 radeon_bo_unreserve(rdev->rlc.clear_state_obj);
3026 if (r) { 3027 if (r) {
3027
3028 radeon_bo_unreserve(rdev->rlc.clear_state_obj);
3029 dev_warn(rdev->dev, "(%d) pin RLC c bo failed\n", r); 3028 dev_warn(rdev->dev, "(%d) pin RLC c bo failed\n", r);
3030 si_rlc_fini(rdev); 3029 si_rlc_fini(rdev);
3031 return r; 3030 return r;
diff --git a/drivers/gpu/drm/savage/savage_state.c b/drivers/gpu/drm/savage/savage_state.c
index 031aaaf79ac2..b6d8608375cd 100644
--- a/drivers/gpu/drm/savage/savage_state.c
+++ b/drivers/gpu/drm/savage/savage_state.c
@@ -988,7 +988,7 @@ int savage_bci_cmdbuf(struct drm_device *dev, void *data, struct drm_file *file_
988 * for locking on FreeBSD. 988 * for locking on FreeBSD.
989 */ 989 */
990 if (cmdbuf->size) { 990 if (cmdbuf->size) {
991 kcmd_addr = kmalloc(cmdbuf->size * 8, GFP_KERNEL); 991 kcmd_addr = kmalloc_array(cmdbuf->size, 8, GFP_KERNEL);
992 if (kcmd_addr == NULL) 992 if (kcmd_addr == NULL)
993 return -ENOMEM; 993 return -ENOMEM;
994 994
@@ -1015,8 +1015,8 @@ int savage_bci_cmdbuf(struct drm_device *dev, void *data, struct drm_file *file_
1015 cmdbuf->vb_addr = kvb_addr; 1015 cmdbuf->vb_addr = kvb_addr;
1016 } 1016 }
1017 if (cmdbuf->nbox) { 1017 if (cmdbuf->nbox) {
1018 kbox_addr = kmalloc(cmdbuf->nbox * sizeof(struct drm_clip_rect), 1018 kbox_addr = kmalloc_array(cmdbuf->nbox, sizeof(struct drm_clip_rect),
1019 GFP_KERNEL); 1019 GFP_KERNEL);
1020 if (kbox_addr == NULL) { 1020 if (kbox_addr == NULL) {
1021 ret = -ENOMEM; 1021 ret = -ENOMEM;
1022 goto done; 1022 goto done;
diff --git a/drivers/hid/Kconfig b/drivers/hid/Kconfig
index a3d033252995..ffddcba32af6 100644
--- a/drivers/hid/Kconfig
+++ b/drivers/hid/Kconfig
@@ -34,7 +34,7 @@ config HID
34config HID_BATTERY_STRENGTH 34config HID_BATTERY_STRENGTH
35 bool 35 bool
36 depends on HID && POWER_SUPPLY && HID = POWER_SUPPLY 36 depends on HID && POWER_SUPPLY && HID = POWER_SUPPLY
37 default y 37 default n
38 38
39config HIDRAW 39config HIDRAW
40 bool "/dev/hidraw raw HID device support" 40 bool "/dev/hidraw raw HID device support"
diff --git a/drivers/hid/hid-tivo.c b/drivers/hid/hid-tivo.c
index de47039c708c..9f85f827607f 100644
--- a/drivers/hid/hid-tivo.c
+++ b/drivers/hid/hid-tivo.c
@@ -62,7 +62,7 @@ static int tivo_input_mapping(struct hid_device *hdev, struct hid_input *hi,
62 62
63static const struct hid_device_id tivo_devices[] = { 63static const struct hid_device_id tivo_devices[] = {
64 /* TiVo Slide Bluetooth remote, pairs with a Broadcom dongle */ 64 /* TiVo Slide Bluetooth remote, pairs with a Broadcom dongle */
65 { HID_USB_DEVICE(USB_VENDOR_ID_TIVO, USB_DEVICE_ID_TIVO_SLIDE_BT) }, 65 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_TIVO, USB_DEVICE_ID_TIVO_SLIDE_BT) },
66 { HID_USB_DEVICE(USB_VENDOR_ID_TIVO, USB_DEVICE_ID_TIVO_SLIDE) }, 66 { HID_USB_DEVICE(USB_VENDOR_ID_TIVO, USB_DEVICE_ID_TIVO_SLIDE) },
67 { } 67 { }
68}; 68};
diff --git a/drivers/hsi/clients/hsi_char.c b/drivers/hsi/clients/hsi_char.c
index 88a050df2389..3ad91f6447d8 100644
--- a/drivers/hsi/clients/hsi_char.c
+++ b/drivers/hsi/clients/hsi_char.c
@@ -123,7 +123,7 @@ struct hsc_client_data {
123static unsigned int hsc_major; 123static unsigned int hsc_major;
124/* Maximum buffer size that hsi_char will accept from userspace */ 124/* Maximum buffer size that hsi_char will accept from userspace */
125static unsigned int max_data_size = 0x1000; 125static unsigned int max_data_size = 0x1000;
126module_param(max_data_size, uint, S_IRUSR | S_IWUSR); 126module_param(max_data_size, uint, 0);
127MODULE_PARM_DESC(max_data_size, "max read/write data size [4,8..65536] (^2)"); 127MODULE_PARM_DESC(max_data_size, "max read/write data size [4,8..65536] (^2)");
128 128
129static void hsc_add_tail(struct hsc_channel *channel, struct hsi_msg *msg, 129static void hsc_add_tail(struct hsc_channel *channel, struct hsi_msg *msg,
diff --git a/drivers/hsi/hsi.c b/drivers/hsi/hsi.c
index 4e2d79b79334..2d58f939d27f 100644
--- a/drivers/hsi/hsi.c
+++ b/drivers/hsi/hsi.c
@@ -21,26 +21,13 @@
21 */ 21 */
22#include <linux/hsi/hsi.h> 22#include <linux/hsi/hsi.h>
23#include <linux/compiler.h> 23#include <linux/compiler.h>
24#include <linux/rwsem.h>
25#include <linux/list.h> 24#include <linux/list.h>
26#include <linux/spinlock.h>
27#include <linux/kobject.h> 25#include <linux/kobject.h>
28#include <linux/slab.h> 26#include <linux/slab.h>
29#include <linux/string.h> 27#include <linux/string.h>
28#include <linux/notifier.h>
30#include "hsi_core.h" 29#include "hsi_core.h"
31 30
32static struct device_type hsi_ctrl = {
33 .name = "hsi_controller",
34};
35
36static struct device_type hsi_cl = {
37 .name = "hsi_client",
38};
39
40static struct device_type hsi_port = {
41 .name = "hsi_port",
42};
43
44static ssize_t modalias_show(struct device *dev, 31static ssize_t modalias_show(struct device *dev,
45 struct device_attribute *a __maybe_unused, char *buf) 32 struct device_attribute *a __maybe_unused, char *buf)
46{ 33{
@@ -54,8 +41,7 @@ static struct device_attribute hsi_bus_dev_attrs[] = {
54 41
55static int hsi_bus_uevent(struct device *dev, struct kobj_uevent_env *env) 42static int hsi_bus_uevent(struct device *dev, struct kobj_uevent_env *env)
56{ 43{
57 if (dev->type == &hsi_cl) 44 add_uevent_var(env, "MODALIAS=hsi:%s", dev_name(dev));
58 add_uevent_var(env, "MODALIAS=hsi:%s", dev_name(dev));
59 45
60 return 0; 46 return 0;
61} 47}
@@ -80,12 +66,10 @@ static void hsi_client_release(struct device *dev)
80static void hsi_new_client(struct hsi_port *port, struct hsi_board_info *info) 66static void hsi_new_client(struct hsi_port *port, struct hsi_board_info *info)
81{ 67{
82 struct hsi_client *cl; 68 struct hsi_client *cl;
83 unsigned long flags;
84 69
85 cl = kzalloc(sizeof(*cl), GFP_KERNEL); 70 cl = kzalloc(sizeof(*cl), GFP_KERNEL);
86 if (!cl) 71 if (!cl)
87 return; 72 return;
88 cl->device.type = &hsi_cl;
89 cl->tx_cfg = info->tx_cfg; 73 cl->tx_cfg = info->tx_cfg;
90 cl->rx_cfg = info->rx_cfg; 74 cl->rx_cfg = info->rx_cfg;
91 cl->device.bus = &hsi_bus_type; 75 cl->device.bus = &hsi_bus_type;
@@ -93,14 +77,11 @@ static void hsi_new_client(struct hsi_port *port, struct hsi_board_info *info)
93 cl->device.release = hsi_client_release; 77 cl->device.release = hsi_client_release;
94 dev_set_name(&cl->device, info->name); 78 dev_set_name(&cl->device, info->name);
95 cl->device.platform_data = info->platform_data; 79 cl->device.platform_data = info->platform_data;
96 spin_lock_irqsave(&port->clock, flags);
97 list_add_tail(&cl->link, &port->clients);
98 spin_unlock_irqrestore(&port->clock, flags);
99 if (info->archdata) 80 if (info->archdata)
100 cl->device.archdata = *info->archdata; 81 cl->device.archdata = *info->archdata;
101 if (device_register(&cl->device) < 0) { 82 if (device_register(&cl->device) < 0) {
102 pr_err("hsi: failed to register client: %s\n", info->name); 83 pr_err("hsi: failed to register client: %s\n", info->name);
103 kfree(cl); 84 put_device(&cl->device);
104 } 85 }
105} 86}
106 87
@@ -120,13 +101,6 @@ static void hsi_scan_board_info(struct hsi_controller *hsi)
120 101
121static int hsi_remove_client(struct device *dev, void *data __maybe_unused) 102static int hsi_remove_client(struct device *dev, void *data __maybe_unused)
122{ 103{
123 struct hsi_client *cl = to_hsi_client(dev);
124 struct hsi_port *port = to_hsi_port(dev->parent);
125 unsigned long flags;
126
127 spin_lock_irqsave(&port->clock, flags);
128 list_del(&cl->link);
129 spin_unlock_irqrestore(&port->clock, flags);
130 device_unregister(dev); 104 device_unregister(dev);
131 105
132 return 0; 106 return 0;
@@ -140,12 +114,17 @@ static int hsi_remove_port(struct device *dev, void *data __maybe_unused)
140 return 0; 114 return 0;
141} 115}
142 116
143static void hsi_controller_release(struct device *dev __maybe_unused) 117static void hsi_controller_release(struct device *dev)
144{ 118{
119 struct hsi_controller *hsi = to_hsi_controller(dev);
120
121 kfree(hsi->port);
122 kfree(hsi);
145} 123}
146 124
147static void hsi_port_release(struct device *dev __maybe_unused) 125static void hsi_port_release(struct device *dev)
148{ 126{
127 kfree(to_hsi_port(dev));
149} 128}
150 129
151/** 130/**
@@ -170,20 +149,12 @@ int hsi_register_controller(struct hsi_controller *hsi)
170 unsigned int i; 149 unsigned int i;
171 int err; 150 int err;
172 151
173 hsi->device.type = &hsi_ctrl; 152 err = device_add(&hsi->device);
174 hsi->device.bus = &hsi_bus_type;
175 hsi->device.release = hsi_controller_release;
176 err = device_register(&hsi->device);
177 if (err < 0) 153 if (err < 0)
178 return err; 154 return err;
179 for (i = 0; i < hsi->num_ports; i++) { 155 for (i = 0; i < hsi->num_ports; i++) {
180 hsi->port[i].device.parent = &hsi->device; 156 hsi->port[i]->device.parent = &hsi->device;
181 hsi->port[i].device.bus = &hsi_bus_type; 157 err = device_add(&hsi->port[i]->device);
182 hsi->port[i].device.release = hsi_port_release;
183 hsi->port[i].device.type = &hsi_port;
184 INIT_LIST_HEAD(&hsi->port[i].clients);
185 spin_lock_init(&hsi->port[i].clock);
186 err = device_register(&hsi->port[i].device);
187 if (err < 0) 158 if (err < 0)
188 goto out; 159 goto out;
189 } 160 }
@@ -192,7 +163,9 @@ int hsi_register_controller(struct hsi_controller *hsi)
192 163
193 return 0; 164 return 0;
194out: 165out:
195 hsi_unregister_controller(hsi); 166 while (i-- > 0)
167 device_del(&hsi->port[i]->device);
168 device_del(&hsi->device);
196 169
197 return err; 170 return err;
198} 171}
@@ -223,6 +196,29 @@ static inline int hsi_dummy_cl(struct hsi_client *cl __maybe_unused)
223} 196}
224 197
225/** 198/**
199 * hsi_put_controller - Free an HSI controller
200 *
201 * @hsi: Pointer to the HSI controller to freed
202 *
203 * HSI controller drivers should only use this function if they need
204 * to free their allocated hsi_controller structures before a successful
205 * call to hsi_register_controller. Other use is not allowed.
206 */
207void hsi_put_controller(struct hsi_controller *hsi)
208{
209 unsigned int i;
210
211 if (!hsi)
212 return;
213
214 for (i = 0; i < hsi->num_ports; i++)
215 if (hsi->port && hsi->port[i])
216 put_device(&hsi->port[i]->device);
217 put_device(&hsi->device);
218}
219EXPORT_SYMBOL_GPL(hsi_put_controller);
220
221/**
226 * hsi_alloc_controller - Allocate an HSI controller and its ports 222 * hsi_alloc_controller - Allocate an HSI controller and its ports
227 * @n_ports: Number of ports on the HSI controller 223 * @n_ports: Number of ports on the HSI controller
228 * @flags: Kernel allocation flags 224 * @flags: Kernel allocation flags
@@ -232,55 +228,52 @@ static inline int hsi_dummy_cl(struct hsi_client *cl __maybe_unused)
232struct hsi_controller *hsi_alloc_controller(unsigned int n_ports, gfp_t flags) 228struct hsi_controller *hsi_alloc_controller(unsigned int n_ports, gfp_t flags)
233{ 229{
234 struct hsi_controller *hsi; 230 struct hsi_controller *hsi;
235 struct hsi_port *port; 231 struct hsi_port **port;
236 unsigned int i; 232 unsigned int i;
237 233
238 if (!n_ports) 234 if (!n_ports)
239 return NULL; 235 return NULL;
240 236
241 port = kzalloc(sizeof(*port)*n_ports, flags);
242 if (!port)
243 return NULL;
244 hsi = kzalloc(sizeof(*hsi), flags); 237 hsi = kzalloc(sizeof(*hsi), flags);
245 if (!hsi) 238 if (!hsi)
246 goto out; 239 return NULL;
247 for (i = 0; i < n_ports; i++) { 240 port = kzalloc(sizeof(*port)*n_ports, flags);
248 dev_set_name(&port[i].device, "port%d", i); 241 if (!port) {
249 port[i].num = i; 242 kfree(hsi);
250 port[i].async = hsi_dummy_msg; 243 return NULL;
251 port[i].setup = hsi_dummy_cl;
252 port[i].flush = hsi_dummy_cl;
253 port[i].start_tx = hsi_dummy_cl;
254 port[i].stop_tx = hsi_dummy_cl;
255 port[i].release = hsi_dummy_cl;
256 mutex_init(&port[i].lock);
257 } 244 }
258 hsi->num_ports = n_ports; 245 hsi->num_ports = n_ports;
259 hsi->port = port; 246 hsi->port = port;
247 hsi->device.release = hsi_controller_release;
248 device_initialize(&hsi->device);
249
250 for (i = 0; i < n_ports; i++) {
251 port[i] = kzalloc(sizeof(**port), flags);
252 if (port[i] == NULL)
253 goto out;
254 port[i]->num = i;
255 port[i]->async = hsi_dummy_msg;
256 port[i]->setup = hsi_dummy_cl;
257 port[i]->flush = hsi_dummy_cl;
258 port[i]->start_tx = hsi_dummy_cl;
259 port[i]->stop_tx = hsi_dummy_cl;
260 port[i]->release = hsi_dummy_cl;
261 mutex_init(&port[i]->lock);
262 ATOMIC_INIT_NOTIFIER_HEAD(&port[i]->n_head);
263 dev_set_name(&port[i]->device, "port%d", i);
264 hsi->port[i]->device.release = hsi_port_release;
265 device_initialize(&hsi->port[i]->device);
266 }
260 267
261 return hsi; 268 return hsi;
262out: 269out:
263 kfree(port); 270 hsi_put_controller(hsi);
264 271
265 return NULL; 272 return NULL;
266} 273}
267EXPORT_SYMBOL_GPL(hsi_alloc_controller); 274EXPORT_SYMBOL_GPL(hsi_alloc_controller);
268 275
269/** 276/**
270 * hsi_free_controller - Free an HSI controller
271 * @hsi: Pointer to HSI controller
272 */
273void hsi_free_controller(struct hsi_controller *hsi)
274{
275 if (!hsi)
276 return;
277
278 kfree(hsi->port);
279 kfree(hsi);
280}
281EXPORT_SYMBOL_GPL(hsi_free_controller);
282
283/**
284 * hsi_free_msg - Free an HSI message 277 * hsi_free_msg - Free an HSI message
285 * @msg: Pointer to the HSI message 278 * @msg: Pointer to the HSI message
286 * 279 *
@@ -414,37 +407,67 @@ void hsi_release_port(struct hsi_client *cl)
414} 407}
415EXPORT_SYMBOL_GPL(hsi_release_port); 408EXPORT_SYMBOL_GPL(hsi_release_port);
416 409
417static int hsi_start_rx(struct hsi_client *cl, void *data __maybe_unused) 410static int hsi_event_notifier_call(struct notifier_block *nb,
411 unsigned long event, void *data __maybe_unused)
418{ 412{
419 if (cl->hsi_start_rx) 413 struct hsi_client *cl = container_of(nb, struct hsi_client, nb);
420 (*cl->hsi_start_rx)(cl); 414
415 (*cl->ehandler)(cl, event);
421 416
422 return 0; 417 return 0;
423} 418}
424 419
425static int hsi_stop_rx(struct hsi_client *cl, void *data __maybe_unused) 420/**
421 * hsi_register_port_event - Register a client to receive port events
422 * @cl: HSI client that wants to receive port events
423 * @cb: Event handler callback
424 *
425 * Clients should register a callback to be able to receive
426 * events from the ports. Registration should happen after
427 * claiming the port.
428 * The handler can be called in interrupt context.
429 *
430 * Returns -errno on error, or 0 on success.
431 */
432int hsi_register_port_event(struct hsi_client *cl,
433 void (*handler)(struct hsi_client *, unsigned long))
426{ 434{
427 if (cl->hsi_stop_rx) 435 struct hsi_port *port = hsi_get_port(cl);
428 (*cl->hsi_stop_rx)(cl);
429 436
430 return 0; 437 if (!handler || cl->ehandler)
438 return -EINVAL;
439 if (!hsi_port_claimed(cl))
440 return -EACCES;
441 cl->ehandler = handler;
442 cl->nb.notifier_call = hsi_event_notifier_call;
443
444 return atomic_notifier_chain_register(&port->n_head, &cl->nb);
431} 445}
446EXPORT_SYMBOL_GPL(hsi_register_port_event);
432 447
433static int hsi_port_for_each_client(struct hsi_port *port, void *data, 448/**
434 int (*fn)(struct hsi_client *cl, void *data)) 449 * hsi_unregister_port_event - Stop receiving port events for a client
450 * @cl: HSI client that wants to stop receiving port events
451 *
452 * Clients should call this function before releasing their associated
453 * port.
454 *
455 * Returns -errno on error, or 0 on success.
456 */
457int hsi_unregister_port_event(struct hsi_client *cl)
435{ 458{
436 struct hsi_client *cl; 459 struct hsi_port *port = hsi_get_port(cl);
460 int err;
437 461
438 spin_lock(&port->clock); 462 WARN_ON(!hsi_port_claimed(cl));
439 list_for_each_entry(cl, &port->clients, link) {
440 spin_unlock(&port->clock);
441 (*fn)(cl, data);
442 spin_lock(&port->clock);
443 }
444 spin_unlock(&port->clock);
445 463
446 return 0; 464 err = atomic_notifier_chain_unregister(&port->n_head, &cl->nb);
465 if (!err)
466 cl->ehandler = NULL;
467
468 return err;
447} 469}
470EXPORT_SYMBOL_GPL(hsi_unregister_port_event);
448 471
449/** 472/**
450 * hsi_event -Notifies clients about port events 473 * hsi_event -Notifies clients about port events
@@ -458,22 +481,12 @@ static int hsi_port_for_each_client(struct hsi_port *port, void *data,
458 * Events: 481 * Events:
459 * HSI_EVENT_START_RX - Incoming wake line high 482 * HSI_EVENT_START_RX - Incoming wake line high
460 * HSI_EVENT_STOP_RX - Incoming wake line down 483 * HSI_EVENT_STOP_RX - Incoming wake line down
484 *
485 * Returns -errno on error, or 0 on success.
461 */ 486 */
462void hsi_event(struct hsi_port *port, unsigned int event) 487int hsi_event(struct hsi_port *port, unsigned long event)
463{ 488{
464 int (*fn)(struct hsi_client *cl, void *data); 489 return atomic_notifier_call_chain(&port->n_head, event, NULL);
465
466 switch (event) {
467 case HSI_EVENT_START_RX:
468 fn = hsi_start_rx;
469 break;
470 case HSI_EVENT_STOP_RX:
471 fn = hsi_stop_rx;
472 break;
473 default:
474 return;
475 }
476 hsi_port_for_each_client(port, NULL, fn);
477} 490}
478EXPORT_SYMBOL_GPL(hsi_event); 491EXPORT_SYMBOL_GPL(hsi_event);
479 492
diff --git a/drivers/hwmon/acpi_power_meter.c b/drivers/hwmon/acpi_power_meter.c
index 145f13580ff0..9140236a0182 100644
--- a/drivers/hwmon/acpi_power_meter.c
+++ b/drivers/hwmon/acpi_power_meter.c
@@ -391,6 +391,7 @@ static ssize_t show_str(struct device *dev,
391 break; 391 break;
392 default: 392 default:
393 BUG(); 393 BUG();
394 val = "";
394 } 395 }
395 396
396 return sprintf(buf, "%s\n", val); 397 return sprintf(buf, "%s\n", val);
diff --git a/drivers/hwmon/ad7314.c b/drivers/hwmon/ad7314.c
index ce43642ef03e..f85ce70d9677 100644
--- a/drivers/hwmon/ad7314.c
+++ b/drivers/hwmon/ad7314.c
@@ -47,7 +47,7 @@ struct ad7314_data {
47 u16 rx ____cacheline_aligned; 47 u16 rx ____cacheline_aligned;
48}; 48};
49 49
50static int ad7314_spi_read(struct ad7314_data *chip, s16 *data) 50static int ad7314_spi_read(struct ad7314_data *chip)
51{ 51{
52 int ret; 52 int ret;
53 53
@@ -57,9 +57,7 @@ static int ad7314_spi_read(struct ad7314_data *chip, s16 *data)
57 return ret; 57 return ret;
58 } 58 }
59 59
60 *data = be16_to_cpu(chip->rx); 60 return be16_to_cpu(chip->rx);
61
62 return ret;
63} 61}
64 62
65static ssize_t ad7314_show_temperature(struct device *dev, 63static ssize_t ad7314_show_temperature(struct device *dev,
@@ -70,12 +68,12 @@ static ssize_t ad7314_show_temperature(struct device *dev,
70 s16 data; 68 s16 data;
71 int ret; 69 int ret;
72 70
73 ret = ad7314_spi_read(chip, &data); 71 ret = ad7314_spi_read(chip);
74 if (ret < 0) 72 if (ret < 0)
75 return ret; 73 return ret;
76 switch (spi_get_device_id(chip->spi_dev)->driver_data) { 74 switch (spi_get_device_id(chip->spi_dev)->driver_data) {
77 case ad7314: 75 case ad7314:
78 data = (data & AD7314_TEMP_MASK) >> AD7314_TEMP_OFFSET; 76 data = (ret & AD7314_TEMP_MASK) >> AD7314_TEMP_OFFSET;
79 data = (data << 6) >> 6; 77 data = (data << 6) >> 6;
80 78
81 return sprintf(buf, "%d\n", 250 * data); 79 return sprintf(buf, "%d\n", 250 * data);
@@ -86,7 +84,7 @@ static ssize_t ad7314_show_temperature(struct device *dev,
86 * with a sign bit - which is a 14 bit 2's complement 84 * with a sign bit - which is a 14 bit 2's complement
87 * register. 1lsb - 31.25 milli degrees centigrade 85 * register. 1lsb - 31.25 milli degrees centigrade
88 */ 86 */
89 data &= ADT7301_TEMP_MASK; 87 data = ret & ADT7301_TEMP_MASK;
90 data = (data << 2) >> 2; 88 data = (data << 2) >> 2;
91 89
92 return sprintf(buf, "%d\n", 90 return sprintf(buf, "%d\n",
diff --git a/drivers/hwmon/ads1015.c b/drivers/hwmon/ads1015.c
index 7765e4f74ec5..1958f03efd7a 100644
--- a/drivers/hwmon/ads1015.c
+++ b/drivers/hwmon/ads1015.c
@@ -59,14 +59,11 @@ struct ads1015_data {
59 struct ads1015_channel_data channel_data[ADS1015_CHANNELS]; 59 struct ads1015_channel_data channel_data[ADS1015_CHANNELS];
60}; 60};
61 61
62static int ads1015_read_value(struct i2c_client *client, unsigned int channel, 62static int ads1015_read_adc(struct i2c_client *client, unsigned int channel)
63 int *value)
64{ 63{
65 u16 config; 64 u16 config;
66 s16 conversion;
67 struct ads1015_data *data = i2c_get_clientdata(client); 65 struct ads1015_data *data = i2c_get_clientdata(client);
68 unsigned int pga = data->channel_data[channel].pga; 66 unsigned int pga = data->channel_data[channel].pga;
69 int fullscale;
70 unsigned int data_rate = data->channel_data[channel].data_rate; 67 unsigned int data_rate = data->channel_data[channel].data_rate;
71 unsigned int conversion_time_ms; 68 unsigned int conversion_time_ms;
72 int res; 69 int res;
@@ -78,7 +75,6 @@ static int ads1015_read_value(struct i2c_client *client, unsigned int channel,
78 if (res < 0) 75 if (res < 0)
79 goto err_unlock; 76 goto err_unlock;
80 config = res; 77 config = res;
81 fullscale = fullscale_table[pga];
82 conversion_time_ms = DIV_ROUND_UP(1000, data_rate_table[data_rate]); 78 conversion_time_ms = DIV_ROUND_UP(1000, data_rate_table[data_rate]);
83 79
84 /* setup and start single conversion */ 80 /* setup and start single conversion */
@@ -105,33 +101,36 @@ static int ads1015_read_value(struct i2c_client *client, unsigned int channel,
105 } 101 }
106 102
107 res = i2c_smbus_read_word_swapped(client, ADS1015_CONVERSION); 103 res = i2c_smbus_read_word_swapped(client, ADS1015_CONVERSION);
108 if (res < 0)
109 goto err_unlock;
110 conversion = res;
111
112 mutex_unlock(&data->update_lock);
113
114 *value = DIV_ROUND_CLOSEST(conversion * fullscale, 0x7ff0);
115
116 return 0;
117 104
118err_unlock: 105err_unlock:
119 mutex_unlock(&data->update_lock); 106 mutex_unlock(&data->update_lock);
120 return res; 107 return res;
121} 108}
122 109
110static int ads1015_reg_to_mv(struct i2c_client *client, unsigned int channel,
111 s16 reg)
112{
113 struct ads1015_data *data = i2c_get_clientdata(client);
114 unsigned int pga = data->channel_data[channel].pga;
115 int fullscale = fullscale_table[pga];
116
117 return DIV_ROUND_CLOSEST(reg * fullscale, 0x7ff0);
118}
119
123/* sysfs callback function */ 120/* sysfs callback function */
124static ssize_t show_in(struct device *dev, struct device_attribute *da, 121static ssize_t show_in(struct device *dev, struct device_attribute *da,
125 char *buf) 122 char *buf)
126{ 123{
127 struct sensor_device_attribute *attr = to_sensor_dev_attr(da); 124 struct sensor_device_attribute *attr = to_sensor_dev_attr(da);
128 struct i2c_client *client = to_i2c_client(dev); 125 struct i2c_client *client = to_i2c_client(dev);
129 int in;
130 int res; 126 int res;
127 int index = attr->index;
131 128
132 res = ads1015_read_value(client, attr->index, &in); 129 res = ads1015_read_adc(client, index);
130 if (res < 0)
131 return res;
133 132
134 return (res < 0) ? res : sprintf(buf, "%d\n", in); 133 return sprintf(buf, "%d\n", ads1015_reg_to_mv(client, index, res));
135} 134}
136 135
137static const struct sensor_device_attribute ads1015_in[] = { 136static const struct sensor_device_attribute ads1015_in[] = {
diff --git a/drivers/hwmon/fam15h_power.c b/drivers/hwmon/fam15h_power.c
index b7494af1e4a9..e8e18cab1fb8 100644
--- a/drivers/hwmon/fam15h_power.c
+++ b/drivers/hwmon/fam15h_power.c
@@ -122,6 +122,41 @@ static bool __devinit fam15h_power_is_internal_node0(struct pci_dev *f4)
122 return true; 122 return true;
123} 123}
124 124
125/*
126 * Newer BKDG versions have an updated recommendation on how to properly
127 * initialize the running average range (was: 0xE, now: 0x9). This avoids
128 * counter saturations resulting in bogus power readings.
129 * We correct this value ourselves to cope with older BIOSes.
130 */
131static DEFINE_PCI_DEVICE_TABLE(affected_device) = {
132 { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_15H_NB_F4) },
133 { 0 }
134};
135
136static void __devinit tweak_runavg_range(struct pci_dev *pdev)
137{
138 u32 val;
139
140 /*
141 * let this quirk apply only to the current version of the
142 * northbridge, since future versions may change the behavior
143 */
144 if (!pci_match_id(affected_device, pdev))
145 return;
146
147 pci_bus_read_config_dword(pdev->bus,
148 PCI_DEVFN(PCI_SLOT(pdev->devfn), 5),
149 REG_TDP_RUNNING_AVERAGE, &val);
150 if ((val & 0xf) != 0xe)
151 return;
152
153 val &= ~0xf;
154 val |= 0x9;
155 pci_bus_write_config_dword(pdev->bus,
156 PCI_DEVFN(PCI_SLOT(pdev->devfn), 5),
157 REG_TDP_RUNNING_AVERAGE, val);
158}
159
125static void __devinit fam15h_power_init_data(struct pci_dev *f4, 160static void __devinit fam15h_power_init_data(struct pci_dev *f4,
126 struct fam15h_power_data *data) 161 struct fam15h_power_data *data)
127{ 162{
@@ -155,6 +190,13 @@ static int __devinit fam15h_power_probe(struct pci_dev *pdev,
155 struct device *dev; 190 struct device *dev;
156 int err; 191 int err;
157 192
193 /*
194 * though we ignore every other northbridge, we still have to
195 * do the tweaking on _each_ node in MCM processors as the counters
196 * are working hand-in-hand
197 */
198 tweak_runavg_range(pdev);
199
158 if (!fam15h_power_is_internal_node0(pdev)) { 200 if (!fam15h_power_is_internal_node0(pdev)) {
159 err = -ENODEV; 201 err = -ENODEV;
160 goto exit; 202 goto exit;
diff --git a/drivers/hwmon/pmbus/pmbus_core.c b/drivers/hwmon/pmbus/pmbus_core.c
index be51037363c8..29b319db573e 100644
--- a/drivers/hwmon/pmbus/pmbus_core.c
+++ b/drivers/hwmon/pmbus/pmbus_core.c
@@ -710,13 +710,13 @@ static u16 pmbus_data2reg(struct pmbus_data *data,
710 * If a negative value is stored in any of the referenced registers, this value 710 * If a negative value is stored in any of the referenced registers, this value
711 * reflects an error code which will be returned. 711 * reflects an error code which will be returned.
712 */ 712 */
713static int pmbus_get_boolean(struct pmbus_data *data, int index, int *val) 713static int pmbus_get_boolean(struct pmbus_data *data, int index)
714{ 714{
715 u8 s1 = (index >> 24) & 0xff; 715 u8 s1 = (index >> 24) & 0xff;
716 u8 s2 = (index >> 16) & 0xff; 716 u8 s2 = (index >> 16) & 0xff;
717 u8 reg = (index >> 8) & 0xff; 717 u8 reg = (index >> 8) & 0xff;
718 u8 mask = index & 0xff; 718 u8 mask = index & 0xff;
719 int status; 719 int ret, status;
720 u8 regval; 720 u8 regval;
721 721
722 status = data->status[reg]; 722 status = data->status[reg];
@@ -725,7 +725,7 @@ static int pmbus_get_boolean(struct pmbus_data *data, int index, int *val)
725 725
726 regval = status & mask; 726 regval = status & mask;
727 if (!s1 && !s2) 727 if (!s1 && !s2)
728 *val = !!regval; 728 ret = !!regval;
729 else { 729 else {
730 long v1, v2; 730 long v1, v2;
731 struct pmbus_sensor *sensor1, *sensor2; 731 struct pmbus_sensor *sensor1, *sensor2;
@@ -739,9 +739,9 @@ static int pmbus_get_boolean(struct pmbus_data *data, int index, int *val)
739 739
740 v1 = pmbus_reg2data(data, sensor1); 740 v1 = pmbus_reg2data(data, sensor1);
741 v2 = pmbus_reg2data(data, sensor2); 741 v2 = pmbus_reg2data(data, sensor2);
742 *val = !!(regval && v1 >= v2); 742 ret = !!(regval && v1 >= v2);
743 } 743 }
744 return 0; 744 return ret;
745} 745}
746 746
747static ssize_t pmbus_show_boolean(struct device *dev, 747static ssize_t pmbus_show_boolean(struct device *dev,
@@ -750,11 +750,10 @@ static ssize_t pmbus_show_boolean(struct device *dev,
750 struct sensor_device_attribute *attr = to_sensor_dev_attr(da); 750 struct sensor_device_attribute *attr = to_sensor_dev_attr(da);
751 struct pmbus_data *data = pmbus_update_device(dev); 751 struct pmbus_data *data = pmbus_update_device(dev);
752 int val; 752 int val;
753 int err;
754 753
755 err = pmbus_get_boolean(data, attr->index, &val); 754 val = pmbus_get_boolean(data, attr->index);
756 if (err) 755 if (val < 0)
757 return err; 756 return val;
758 return snprintf(buf, PAGE_SIZE, "%d\n", val); 757 return snprintf(buf, PAGE_SIZE, "%d\n", val);
759} 758}
760 759
diff --git a/drivers/hwmon/smsc47b397.c b/drivers/hwmon/smsc47b397.c
index d3b778da3f86..c5f6be478bad 100644
--- a/drivers/hwmon/smsc47b397.c
+++ b/drivers/hwmon/smsc47b397.c
@@ -343,10 +343,11 @@ exit:
343 return err; 343 return err;
344} 344}
345 345
346static int __init smsc47b397_find(unsigned short *addr) 346static int __init smsc47b397_find(void)
347{ 347{
348 u8 id, rev; 348 u8 id, rev;
349 char *name; 349 char *name;
350 unsigned short addr;
350 351
351 superio_enter(); 352 superio_enter();
352 id = force_id ? force_id : superio_inb(SUPERIO_REG_DEVID); 353 id = force_id ? force_id : superio_inb(SUPERIO_REG_DEVID);
@@ -370,14 +371,14 @@ static int __init smsc47b397_find(unsigned short *addr)
370 rev = superio_inb(SUPERIO_REG_DEVREV); 371 rev = superio_inb(SUPERIO_REG_DEVREV);
371 372
372 superio_select(SUPERIO_REG_LD8); 373 superio_select(SUPERIO_REG_LD8);
373 *addr = (superio_inb(SUPERIO_REG_BASE_MSB) << 8) 374 addr = (superio_inb(SUPERIO_REG_BASE_MSB) << 8)
374 | superio_inb(SUPERIO_REG_BASE_LSB); 375 | superio_inb(SUPERIO_REG_BASE_LSB);
375 376
376 pr_info("found SMSC %s (base address 0x%04x, revision %u)\n", 377 pr_info("found SMSC %s (base address 0x%04x, revision %u)\n",
377 name, *addr, rev); 378 name, addr, rev);
378 379
379 superio_exit(); 380 superio_exit();
380 return 0; 381 return addr;
381} 382}
382 383
383static int __init smsc47b397_init(void) 384static int __init smsc47b397_init(void)
@@ -385,9 +386,10 @@ static int __init smsc47b397_init(void)
385 unsigned short address; 386 unsigned short address;
386 int ret; 387 int ret;
387 388
388 ret = smsc47b397_find(&address); 389 ret = smsc47b397_find();
389 if (ret) 390 if (ret < 0)
390 return ret; 391 return ret;
392 address = ret;
391 393
392 ret = platform_driver_register(&smsc47b397_driver); 394 ret = platform_driver_register(&smsc47b397_driver);
393 if (ret) 395 if (ret)
diff --git a/drivers/hwmon/smsc47m1.c b/drivers/hwmon/smsc47m1.c
index c590c1469793..b5aa38dd7ab9 100644
--- a/drivers/hwmon/smsc47m1.c
+++ b/drivers/hwmon/smsc47m1.c
@@ -491,10 +491,10 @@ static const struct attribute_group smsc47m1_group = {
491 .attrs = smsc47m1_attributes, 491 .attrs = smsc47m1_attributes,
492}; 492};
493 493
494static int __init smsc47m1_find(unsigned short *addr, 494static int __init smsc47m1_find(struct smsc47m1_sio_data *sio_data)
495 struct smsc47m1_sio_data *sio_data)
496{ 495{
497 u8 val; 496 u8 val;
497 unsigned short addr;
498 498
499 superio_enter(); 499 superio_enter();
500 val = force_id ? force_id : superio_inb(SUPERIO_REG_DEVID); 500 val = force_id ? force_id : superio_inb(SUPERIO_REG_DEVID);
@@ -546,9 +546,9 @@ static int __init smsc47m1_find(unsigned short *addr,
546 } 546 }
547 547
548 superio_select(); 548 superio_select();
549 *addr = (superio_inb(SUPERIO_REG_BASE) << 8) 549 addr = (superio_inb(SUPERIO_REG_BASE) << 8)
550 | superio_inb(SUPERIO_REG_BASE + 1); 550 | superio_inb(SUPERIO_REG_BASE + 1);
551 if (*addr == 0) { 551 if (addr == 0) {
552 pr_info("Device address not set, will not use\n"); 552 pr_info("Device address not set, will not use\n");
553 superio_exit(); 553 superio_exit();
554 return -ENODEV; 554 return -ENODEV;
@@ -565,7 +565,7 @@ static int __init smsc47m1_find(unsigned short *addr,
565 } 565 }
566 566
567 superio_exit(); 567 superio_exit();
568 return 0; 568 return addr;
569} 569}
570 570
571/* Restore device to its initial state */ 571/* Restore device to its initial state */
@@ -938,13 +938,15 @@ static int __init sm_smsc47m1_init(void)
938 unsigned short address; 938 unsigned short address;
939 struct smsc47m1_sio_data sio_data; 939 struct smsc47m1_sio_data sio_data;
940 940
941 if (smsc47m1_find(&address, &sio_data)) 941 err = smsc47m1_find(&sio_data);
942 return -ENODEV; 942 if (err < 0)
943 return err;
944 address = err;
943 945
944 /* Sets global pdev as a side effect */ 946 /* Sets global pdev as a side effect */
945 err = smsc47m1_device_add(address, &sio_data); 947 err = smsc47m1_device_add(address, &sio_data);
946 if (err) 948 if (err)
947 goto exit; 949 return err;
948 950
949 err = platform_driver_probe(&smsc47m1_driver, smsc47m1_probe); 951 err = platform_driver_probe(&smsc47m1_driver, smsc47m1_probe);
950 if (err) 952 if (err)
@@ -955,7 +957,6 @@ static int __init sm_smsc47m1_init(void)
955exit_device: 957exit_device:
956 platform_device_unregister(pdev); 958 platform_device_unregister(pdev);
957 smsc47m1_restore(&sio_data); 959 smsc47m1_restore(&sio_data);
958exit:
959 return err; 960 return err;
960} 961}
961 962
diff --git a/drivers/i2c/busses/i2c-designware-pcidrv.c b/drivers/i2c/busses/i2c-designware-pcidrv.c
index 37f42113af31..00e8f213f56e 100644
--- a/drivers/i2c/busses/i2c-designware-pcidrv.c
+++ b/drivers/i2c/busses/i2c-designware-pcidrv.c
@@ -182,7 +182,6 @@ static int i2c_dw_pci_resume(struct device *dev)
182 pci_restore_state(pdev); 182 pci_restore_state(pdev);
183 183
184 i2c_dw_init(i2c); 184 i2c_dw_init(i2c);
185 i2c_dw_enable(i2c);
186 return 0; 185 return 0;
187} 186}
188 187
diff --git a/drivers/infiniband/core/mad.c b/drivers/infiniband/core/mad.c
index 426bb7617ec6..b0d0bc8a6fb6 100644
--- a/drivers/infiniband/core/mad.c
+++ b/drivers/infiniband/core/mad.c
@@ -1854,6 +1854,8 @@ static bool generate_unmatched_resp(struct ib_mad_private *recv,
1854 response->mad.mad.mad_hdr.method = IB_MGMT_METHOD_GET_RESP; 1854 response->mad.mad.mad_hdr.method = IB_MGMT_METHOD_GET_RESP;
1855 response->mad.mad.mad_hdr.status = 1855 response->mad.mad.mad_hdr.status =
1856 cpu_to_be16(IB_MGMT_MAD_STATUS_UNSUPPORTED_METHOD_ATTRIB); 1856 cpu_to_be16(IB_MGMT_MAD_STATUS_UNSUPPORTED_METHOD_ATTRIB);
1857 if (recv->mad.mad.mad_hdr.mgmt_class == IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE)
1858 response->mad.mad.mad_hdr.status |= IB_SMP_DIRECTION;
1857 1859
1858 return true; 1860 return true;
1859 } else { 1861 } else {
@@ -1869,6 +1871,7 @@ static void ib_mad_recv_done_handler(struct ib_mad_port_private *port_priv,
1869 struct ib_mad_list_head *mad_list; 1871 struct ib_mad_list_head *mad_list;
1870 struct ib_mad_agent_private *mad_agent; 1872 struct ib_mad_agent_private *mad_agent;
1871 int port_num; 1873 int port_num;
1874 int ret = IB_MAD_RESULT_SUCCESS;
1872 1875
1873 mad_list = (struct ib_mad_list_head *)(unsigned long)wc->wr_id; 1876 mad_list = (struct ib_mad_list_head *)(unsigned long)wc->wr_id;
1874 qp_info = mad_list->mad_queue->qp_info; 1877 qp_info = mad_list->mad_queue->qp_info;
@@ -1952,8 +1955,6 @@ static void ib_mad_recv_done_handler(struct ib_mad_port_private *port_priv,
1952local: 1955local:
1953 /* Give driver "right of first refusal" on incoming MAD */ 1956 /* Give driver "right of first refusal" on incoming MAD */
1954 if (port_priv->device->process_mad) { 1957 if (port_priv->device->process_mad) {
1955 int ret;
1956
1957 ret = port_priv->device->process_mad(port_priv->device, 0, 1958 ret = port_priv->device->process_mad(port_priv->device, 0,
1958 port_priv->port_num, 1959 port_priv->port_num,
1959 wc, &recv->grh, 1960 wc, &recv->grh,
@@ -1981,7 +1982,8 @@ local:
1981 * or via recv_handler in ib_mad_complete_recv() 1982 * or via recv_handler in ib_mad_complete_recv()
1982 */ 1983 */
1983 recv = NULL; 1984 recv = NULL;
1984 } else if (generate_unmatched_resp(recv, response)) { 1985 } else if ((ret & IB_MAD_RESULT_SUCCESS) &&
1986 generate_unmatched_resp(recv, response)) {
1985 agent_send_response(&response->mad.mad, &recv->grh, wc, 1987 agent_send_response(&response->mad.mad, &recv->grh, wc,
1986 port_priv->device, port_num, qp_info->qp->qp_num); 1988 port_priv->device, port_num, qp_info->qp->qp_num);
1987 } 1989 }
diff --git a/drivers/infiniband/core/sysfs.c b/drivers/infiniband/core/sysfs.c
index 83b720ef6c34..246fdc151652 100644
--- a/drivers/infiniband/core/sysfs.c
+++ b/drivers/infiniband/core/sysfs.c
@@ -179,7 +179,7 @@ static ssize_t rate_show(struct ib_port *p, struct port_attribute *unused,
179{ 179{
180 struct ib_port_attr attr; 180 struct ib_port_attr attr;
181 char *speed = ""; 181 char *speed = "";
182 int rate = -1; /* in deci-Gb/sec */ 182 int rate; /* in deci-Gb/sec */
183 ssize_t ret; 183 ssize_t ret;
184 184
185 ret = ib_query_port(p->ibdev, p->port_num, &attr); 185 ret = ib_query_port(p->ibdev, p->port_num, &attr);
@@ -187,9 +187,6 @@ static ssize_t rate_show(struct ib_port *p, struct port_attribute *unused,
187 return ret; 187 return ret;
188 188
189 switch (attr.active_speed) { 189 switch (attr.active_speed) {
190 case IB_SPEED_SDR:
191 rate = 25;
192 break;
193 case IB_SPEED_DDR: 190 case IB_SPEED_DDR:
194 speed = " DDR"; 191 speed = " DDR";
195 rate = 50; 192 rate = 50;
@@ -210,6 +207,10 @@ static ssize_t rate_show(struct ib_port *p, struct port_attribute *unused,
210 speed = " EDR"; 207 speed = " EDR";
211 rate = 250; 208 rate = 250;
212 break; 209 break;
210 case IB_SPEED_SDR:
211 default: /* default to SDR for invalid rates */
212 rate = 25;
213 break;
213 } 214 }
214 215
215 rate *= ib_width_enum_to_int(attr.active_width); 216 rate *= ib_width_enum_to_int(attr.active_width);
diff --git a/drivers/infiniband/hw/mlx4/main.c b/drivers/infiniband/hw/mlx4/main.c
index 75d305629300..b948b6dd5d55 100644
--- a/drivers/infiniband/hw/mlx4/main.c
+++ b/drivers/infiniband/hw/mlx4/main.c
@@ -247,12 +247,17 @@ static int ib_link_query_port(struct ib_device *ibdev, u8 port,
247 err = mlx4_MAD_IFC(to_mdev(ibdev), 1, 1, port, 247 err = mlx4_MAD_IFC(to_mdev(ibdev), 1, 1, port,
248 NULL, NULL, in_mad, out_mad); 248 NULL, NULL, in_mad, out_mad);
249 if (err) 249 if (err)
250 return err; 250 goto out;
251 251
252 /* Checking LinkSpeedActive for FDR-10 */ 252 /* Checking LinkSpeedActive for FDR-10 */
253 if (out_mad->data[15] & 0x1) 253 if (out_mad->data[15] & 0x1)
254 props->active_speed = IB_SPEED_FDR10; 254 props->active_speed = IB_SPEED_FDR10;
255 } 255 }
256
257 /* Avoid wrong speed value returned by FW if the IB link is down. */
258 if (props->state == IB_PORT_DOWN)
259 props->active_speed = IB_SPEED_SDR;
260
256out: 261out:
257 kfree(in_mad); 262 kfree(in_mad);
258 kfree(out_mad); 263 kfree(out_mad);
diff --git a/drivers/infiniband/ulp/srpt/ib_srpt.c b/drivers/infiniband/ulp/srpt/ib_srpt.c
index 69e2ad06e515..daf21b899999 100644
--- a/drivers/infiniband/ulp/srpt/ib_srpt.c
+++ b/drivers/infiniband/ulp/srpt/ib_srpt.c
@@ -3232,6 +3232,7 @@ static void srpt_add_one(struct ib_device *device)
3232 srq_attr.attr.max_wr = sdev->srq_size; 3232 srq_attr.attr.max_wr = sdev->srq_size;
3233 srq_attr.attr.max_sge = 1; 3233 srq_attr.attr.max_sge = 1;
3234 srq_attr.attr.srq_limit = 0; 3234 srq_attr.attr.srq_limit = 0;
3235 srq_attr.srq_type = IB_SRQT_BASIC;
3235 3236
3236 sdev->srq = ib_create_srq(sdev->pd, &srq_attr); 3237 sdev->srq = ib_create_srq(sdev->pd, &srq_attr);
3237 if (IS_ERR(sdev->srq)) 3238 if (IS_ERR(sdev->srq))
diff --git a/drivers/input/misc/Kconfig b/drivers/input/misc/Kconfig
index 2d787796bf50..7faf4a7fcaa9 100644
--- a/drivers/input/misc/Kconfig
+++ b/drivers/input/misc/Kconfig
@@ -380,8 +380,7 @@ config INPUT_TWL4030_VIBRA
380 380
381config INPUT_TWL6040_VIBRA 381config INPUT_TWL6040_VIBRA
382 tristate "Support for TWL6040 Vibrator" 382 tristate "Support for TWL6040 Vibrator"
383 depends on TWL4030_CORE 383 depends on TWL6040_CORE
384 select TWL6040_CORE
385 select INPUT_FF_MEMLESS 384 select INPUT_FF_MEMLESS
386 help 385 help
387 This option enables support for TWL6040 Vibrator Driver. 386 This option enables support for TWL6040 Vibrator Driver.
diff --git a/drivers/input/misc/da9052_onkey.c b/drivers/input/misc/da9052_onkey.c
index 34aebb8cd080..3c843cd725fa 100644
--- a/drivers/input/misc/da9052_onkey.c
+++ b/drivers/input/misc/da9052_onkey.c
@@ -95,7 +95,8 @@ static int __devinit da9052_onkey_probe(struct platform_device *pdev)
95 input_dev = input_allocate_device(); 95 input_dev = input_allocate_device();
96 if (!onkey || !input_dev) { 96 if (!onkey || !input_dev) {
97 dev_err(&pdev->dev, "Failed to allocate memory\n"); 97 dev_err(&pdev->dev, "Failed to allocate memory\n");
98 return -ENOMEM; 98 error = -ENOMEM;
99 goto err_free_mem;
99 } 100 }
100 101
101 onkey->input = input_dev; 102 onkey->input = input_dev;
diff --git a/drivers/input/misc/twl6040-vibra.c b/drivers/input/misc/twl6040-vibra.c
index 45874fed523a..14e94f56cb7d 100644
--- a/drivers/input/misc/twl6040-vibra.c
+++ b/drivers/input/misc/twl6040-vibra.c
@@ -28,7 +28,7 @@
28#include <linux/module.h> 28#include <linux/module.h>
29#include <linux/platform_device.h> 29#include <linux/platform_device.h>
30#include <linux/workqueue.h> 30#include <linux/workqueue.h>
31#include <linux/i2c/twl.h> 31#include <linux/input.h>
32#include <linux/mfd/twl6040.h> 32#include <linux/mfd/twl6040.h>
33#include <linux/slab.h> 33#include <linux/slab.h>
34#include <linux/delay.h> 34#include <linux/delay.h>
@@ -257,7 +257,7 @@ static SIMPLE_DEV_PM_OPS(twl6040_vibra_pm_ops, twl6040_vibra_suspend, NULL);
257 257
258static int __devinit twl6040_vibra_probe(struct platform_device *pdev) 258static int __devinit twl6040_vibra_probe(struct platform_device *pdev)
259{ 259{
260 struct twl4030_vibra_data *pdata = pdev->dev.platform_data; 260 struct twl6040_vibra_data *pdata = pdev->dev.platform_data;
261 struct vibra_info *info; 261 struct vibra_info *info;
262 int ret; 262 int ret;
263 263
diff --git a/drivers/input/mouse/elantech.c b/drivers/input/mouse/elantech.c
index d2c0db159b18..479011004a11 100644
--- a/drivers/input/mouse/elantech.c
+++ b/drivers/input/mouse/elantech.c
@@ -486,7 +486,6 @@ static void elantech_input_sync_v4(struct psmouse *psmouse)
486 unsigned char *packet = psmouse->packet; 486 unsigned char *packet = psmouse->packet;
487 487
488 input_report_key(dev, BTN_LEFT, packet[0] & 0x01); 488 input_report_key(dev, BTN_LEFT, packet[0] & 0x01);
489 input_report_key(dev, BTN_RIGHT, packet[0] & 0x02);
490 input_mt_report_pointer_emulation(dev, true); 489 input_mt_report_pointer_emulation(dev, true);
491 input_sync(dev); 490 input_sync(dev);
492} 491}
@@ -967,6 +966,7 @@ static int elantech_set_input_params(struct psmouse *psmouse)
967 if (elantech_set_range(psmouse, &x_min, &y_min, &x_max, &y_max, &width)) 966 if (elantech_set_range(psmouse, &x_min, &y_min, &x_max, &y_max, &width))
968 return -1; 967 return -1;
969 968
969 __set_bit(INPUT_PROP_POINTER, dev->propbit);
970 __set_bit(EV_KEY, dev->evbit); 970 __set_bit(EV_KEY, dev->evbit);
971 __set_bit(EV_ABS, dev->evbit); 971 __set_bit(EV_ABS, dev->evbit);
972 __clear_bit(EV_REL, dev->evbit); 972 __clear_bit(EV_REL, dev->evbit);
@@ -1017,7 +1017,9 @@ static int elantech_set_input_params(struct psmouse *psmouse)
1017 */ 1017 */
1018 psmouse_warn(psmouse, "couldn't query resolution data.\n"); 1018 psmouse_warn(psmouse, "couldn't query resolution data.\n");
1019 } 1019 }
1020 1020 /* v4 is clickpad, with only one button. */
1021 __set_bit(INPUT_PROP_BUTTONPAD, dev->propbit);
1022 __clear_bit(BTN_RIGHT, dev->keybit);
1021 __set_bit(BTN_TOOL_QUADTAP, dev->keybit); 1023 __set_bit(BTN_TOOL_QUADTAP, dev->keybit);
1022 /* For X to recognize me as touchpad. */ 1024 /* For X to recognize me as touchpad. */
1023 input_set_abs_params(dev, ABS_X, x_min, x_max, 0, 0); 1025 input_set_abs_params(dev, ABS_X, x_min, x_max, 0, 0);
@@ -1245,6 +1247,8 @@ static void elantech_disconnect(struct psmouse *psmouse)
1245 */ 1247 */
1246static int elantech_reconnect(struct psmouse *psmouse) 1248static int elantech_reconnect(struct psmouse *psmouse)
1247{ 1249{
1250 psmouse_reset(psmouse);
1251
1248 if (elantech_detect(psmouse, 0)) 1252 if (elantech_detect(psmouse, 0))
1249 return -1; 1253 return -1;
1250 1254
@@ -1324,6 +1328,8 @@ int elantech_init(struct psmouse *psmouse)
1324 if (!etd) 1328 if (!etd)
1325 return -ENOMEM; 1329 return -ENOMEM;
1326 1330
1331 psmouse_reset(psmouse);
1332
1327 etd->parity[0] = 1; 1333 etd->parity[0] = 1;
1328 for (i = 1; i < 256; i++) 1334 for (i = 1; i < 256; i++)
1329 etd->parity[i] = etd->parity[i & (i - 1)] ^ 1; 1335 etd->parity[i] = etd->parity[i & (i - 1)] ^ 1;
diff --git a/drivers/input/mouse/gpio_mouse.c b/drivers/input/mouse/gpio_mouse.c
index a9ad8e1402be..39fe9b737cae 100644
--- a/drivers/input/mouse/gpio_mouse.c
+++ b/drivers/input/mouse/gpio_mouse.c
@@ -12,9 +12,9 @@
12#include <linux/module.h> 12#include <linux/module.h>
13#include <linux/platform_device.h> 13#include <linux/platform_device.h>
14#include <linux/input-polldev.h> 14#include <linux/input-polldev.h>
15#include <linux/gpio.h>
15#include <linux/gpio_mouse.h> 16#include <linux/gpio_mouse.h>
16 17
17#include <asm/gpio.h>
18 18
19/* 19/*
20 * Timer function which is run every scan_ms ms when the device is opened. 20 * Timer function which is run every scan_ms ms when the device is opened.
diff --git a/drivers/input/mouse/sentelic.c b/drivers/input/mouse/sentelic.c
index a977bfaa6821..661a0ca3b3d6 100644
--- a/drivers/input/mouse/sentelic.c
+++ b/drivers/input/mouse/sentelic.c
@@ -741,6 +741,14 @@ static psmouse_ret_t fsp_process_byte(struct psmouse *psmouse)
741 } 741 }
742 } else { 742 } else {
743 /* SFAC packet */ 743 /* SFAC packet */
744 if ((packet[0] & (FSP_PB0_LBTN|FSP_PB0_PHY_BTN)) ==
745 FSP_PB0_LBTN) {
746 /* On-pad click in SFAC mode should be handled
747 * by userspace. On-pad clicks in MFMC mode
748 * are real clickpad clicks, and not ignored.
749 */
750 packet[0] &= ~FSP_PB0_LBTN;
751 }
744 752
745 /* no multi-finger information */ 753 /* no multi-finger information */
746 ad->last_mt_fgr = 0; 754 ad->last_mt_fgr = 0;
diff --git a/drivers/input/mouse/trackpoint.c b/drivers/input/mouse/trackpoint.c
index 22b218018137..f3102494237d 100644
--- a/drivers/input/mouse/trackpoint.c
+++ b/drivers/input/mouse/trackpoint.c
@@ -304,7 +304,7 @@ int trackpoint_detect(struct psmouse *psmouse, bool set_properties)
304 return 0; 304 return 0;
305 305
306 if (trackpoint_read(&psmouse->ps2dev, TP_EXT_BTN, &button_info)) { 306 if (trackpoint_read(&psmouse->ps2dev, TP_EXT_BTN, &button_info)) {
307 printk(KERN_WARNING "trackpoint.c: failed to get extended button data\n"); 307 psmouse_warn(psmouse, "failed to get extended button data\n");
308 button_info = 0; 308 button_info = 0;
309 } 309 }
310 310
@@ -326,16 +326,18 @@ int trackpoint_detect(struct psmouse *psmouse, bool set_properties)
326 326
327 error = sysfs_create_group(&ps2dev->serio->dev.kobj, &trackpoint_attr_group); 327 error = sysfs_create_group(&ps2dev->serio->dev.kobj, &trackpoint_attr_group);
328 if (error) { 328 if (error) {
329 printk(KERN_ERR 329 psmouse_err(psmouse,
330 "trackpoint.c: failed to create sysfs attributes, error: %d\n", 330 "failed to create sysfs attributes, error: %d\n",
331 error); 331 error);
332 kfree(psmouse->private); 332 kfree(psmouse->private);
333 psmouse->private = NULL; 333 psmouse->private = NULL;
334 return -1; 334 return -1;
335 } 335 }
336 336
337 printk(KERN_INFO "IBM TrackPoint firmware: 0x%02x, buttons: %d/%d\n", 337 psmouse_info(psmouse,
338 firmware_id, (button_info & 0xf0) >> 4, button_info & 0x0f); 338 "IBM TrackPoint firmware: 0x%02x, buttons: %d/%d\n",
339 firmware_id,
340 (button_info & 0xf0) >> 4, button_info & 0x0f);
339 341
340 return 0; 342 return 0;
341} 343}
diff --git a/drivers/input/touchscreen/tps6507x-ts.c b/drivers/input/touchscreen/tps6507x-ts.c
index 6c6f6d8ea9b4..f7eda3d00fad 100644
--- a/drivers/input/touchscreen/tps6507x-ts.c
+++ b/drivers/input/touchscreen/tps6507x-ts.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * drivers/input/touchscreen/tps6507x_ts.c
3 *
4 * Touchscreen driver for the tps6507x chip. 2 * Touchscreen driver for the tps6507x chip.
5 * 3 *
6 * Copyright (c) 2009 RidgeRun (todd.fischer@ridgerun.com) 4 * Copyright (c) 2009 RidgeRun (todd.fischer@ridgerun.com)
@@ -376,4 +374,4 @@ module_platform_driver(tps6507x_ts_driver);
376MODULE_AUTHOR("Todd Fischer <todd.fischer@ridgerun.com>"); 374MODULE_AUTHOR("Todd Fischer <todd.fischer@ridgerun.com>");
377MODULE_DESCRIPTION("TPS6507x - TouchScreen driver"); 375MODULE_DESCRIPTION("TPS6507x - TouchScreen driver");
378MODULE_LICENSE("GPL v2"); 376MODULE_LICENSE("GPL v2");
379MODULE_ALIAS("platform:tps6507x-tsc"); 377MODULE_ALIAS("platform:tps6507x-ts");
diff --git a/drivers/isdn/gigaset/interface.c b/drivers/isdn/gigaset/interface.c
index b3d6ac17272d..a6d9fd2858f7 100644
--- a/drivers/isdn/gigaset/interface.c
+++ b/drivers/isdn/gigaset/interface.c
@@ -176,7 +176,7 @@ static void if_close(struct tty_struct *tty, struct file *filp)
176 struct cardstate *cs = tty->driver_data; 176 struct cardstate *cs = tty->driver_data;
177 177
178 if (!cs) { /* happens if we didn't find cs in open */ 178 if (!cs) { /* happens if we didn't find cs in open */
179 printk(KERN_DEBUG "%s: no cardstate\n", __func__); 179 gig_dbg(DEBUG_IF, "%s: no cardstate", __func__);
180 return; 180 return;
181 } 181 }
182 182
diff --git a/drivers/leds/leds-atmel-pwm.c b/drivers/leds/leds-atmel-pwm.c
index 800243b6037e..64ad702a2ecc 100644
--- a/drivers/leds/leds-atmel-pwm.c
+++ b/drivers/leds/leds-atmel-pwm.c
@@ -35,7 +35,7 @@ static void pwmled_brightness(struct led_classdev *cdev, enum led_brightness b)
35 * NOTE: we reuse the platform_data structure of GPIO leds, 35 * NOTE: we reuse the platform_data structure of GPIO leds,
36 * but repurpose its "gpio" number as a PWM channel number. 36 * but repurpose its "gpio" number as a PWM channel number.
37 */ 37 */
38static int __init pwmled_probe(struct platform_device *pdev) 38static int __devinit pwmled_probe(struct platform_device *pdev)
39{ 39{
40 const struct gpio_led_platform_data *pdata; 40 const struct gpio_led_platform_data *pdata;
41 struct pwmled *leds; 41 struct pwmled *leds;
diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c
index 3d0dfa7a89a2..97e73e555d11 100644
--- a/drivers/md/bitmap.c
+++ b/drivers/md/bitmap.c
@@ -539,9 +539,6 @@ static int bitmap_new_disk_sb(struct bitmap *bitmap)
539 bitmap->events_cleared = bitmap->mddev->events; 539 bitmap->events_cleared = bitmap->mddev->events;
540 sb->events_cleared = cpu_to_le64(bitmap->mddev->events); 540 sb->events_cleared = cpu_to_le64(bitmap->mddev->events);
541 541
542 bitmap->flags |= BITMAP_HOSTENDIAN;
543 sb->version = cpu_to_le32(BITMAP_MAJOR_HOSTENDIAN);
544
545 kunmap_atomic(sb); 542 kunmap_atomic(sb);
546 543
547 return 0; 544 return 0;
@@ -1788,7 +1785,9 @@ int bitmap_load(struct mddev *mddev)
1788 * re-add of a missing device */ 1785 * re-add of a missing device */
1789 start = mddev->recovery_cp; 1786 start = mddev->recovery_cp;
1790 1787
1788 mutex_lock(&mddev->bitmap_info.mutex);
1791 err = bitmap_init_from_disk(bitmap, start); 1789 err = bitmap_init_from_disk(bitmap, start);
1790 mutex_unlock(&mddev->bitmap_info.mutex);
1792 1791
1793 if (err) 1792 if (err)
1794 goto out; 1793 goto out;
diff --git a/drivers/md/dm-raid.c b/drivers/md/dm-raid.c
index b0ba52459ed7..68965e663248 100644
--- a/drivers/md/dm-raid.c
+++ b/drivers/md/dm-raid.c
@@ -859,7 +859,7 @@ static int analyse_superblocks(struct dm_target *ti, struct raid_set *rs)
859 int ret; 859 int ret;
860 unsigned redundancy = 0; 860 unsigned redundancy = 0;
861 struct raid_dev *dev; 861 struct raid_dev *dev;
862 struct md_rdev *rdev, *freshest; 862 struct md_rdev *rdev, *tmp, *freshest;
863 struct mddev *mddev = &rs->md; 863 struct mddev *mddev = &rs->md;
864 864
865 switch (rs->raid_type->level) { 865 switch (rs->raid_type->level) {
@@ -877,7 +877,7 @@ static int analyse_superblocks(struct dm_target *ti, struct raid_set *rs)
877 } 877 }
878 878
879 freshest = NULL; 879 freshest = NULL;
880 rdev_for_each(rdev, mddev) { 880 rdev_for_each_safe(rdev, tmp, mddev) {
881 if (!rdev->meta_bdev) 881 if (!rdev->meta_bdev)
882 continue; 882 continue;
883 883
diff --git a/drivers/md/md.c b/drivers/md/md.c
index b572e1e386ce..477eb2e180c0 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -7560,14 +7560,14 @@ void md_check_recovery(struct mddev *mddev)
7560 * any transients in the value of "sync_action". 7560 * any transients in the value of "sync_action".
7561 */ 7561 */
7562 set_bit(MD_RECOVERY_RUNNING, &mddev->recovery); 7562 set_bit(MD_RECOVERY_RUNNING, &mddev->recovery);
7563 clear_bit(MD_RECOVERY_NEEDED, &mddev->recovery);
7564 /* Clear some bits that don't mean anything, but 7563 /* Clear some bits that don't mean anything, but
7565 * might be left set 7564 * might be left set
7566 */ 7565 */
7567 clear_bit(MD_RECOVERY_INTR, &mddev->recovery); 7566 clear_bit(MD_RECOVERY_INTR, &mddev->recovery);
7568 clear_bit(MD_RECOVERY_DONE, &mddev->recovery); 7567 clear_bit(MD_RECOVERY_DONE, &mddev->recovery);
7569 7568
7570 if (test_bit(MD_RECOVERY_FROZEN, &mddev->recovery)) 7569 if (!test_and_clear_bit(MD_RECOVERY_NEEDED, &mddev->recovery) ||
7570 test_bit(MD_RECOVERY_FROZEN, &mddev->recovery))
7571 goto unlock; 7571 goto unlock;
7572 /* no recovery is running. 7572 /* no recovery is running.
7573 * remove any failed drives, then 7573 * remove any failed drives, then
@@ -8140,7 +8140,8 @@ static int md_notify_reboot(struct notifier_block *this,
8140 8140
8141 for_each_mddev(mddev, tmp) { 8141 for_each_mddev(mddev, tmp) {
8142 if (mddev_trylock(mddev)) { 8142 if (mddev_trylock(mddev)) {
8143 __md_stop_writes(mddev); 8143 if (mddev->pers)
8144 __md_stop_writes(mddev);
8144 mddev->safemode = 2; 8145 mddev->safemode = 2;
8145 mddev_unlock(mddev); 8146 mddev_unlock(mddev);
8146 } 8147 }
diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
index d35e4c991e38..15dd59b84e94 100644
--- a/drivers/md/raid1.c
+++ b/drivers/md/raid1.c
@@ -1712,6 +1712,7 @@ static int process_checks(struct r1bio *r1_bio)
1712 struct r1conf *conf = mddev->private; 1712 struct r1conf *conf = mddev->private;
1713 int primary; 1713 int primary;
1714 int i; 1714 int i;
1715 int vcnt;
1715 1716
1716 for (primary = 0; primary < conf->raid_disks * 2; primary++) 1717 for (primary = 0; primary < conf->raid_disks * 2; primary++)
1717 if (r1_bio->bios[primary]->bi_end_io == end_sync_read && 1718 if (r1_bio->bios[primary]->bi_end_io == end_sync_read &&
@@ -1721,9 +1722,9 @@ static int process_checks(struct r1bio *r1_bio)
1721 break; 1722 break;
1722 } 1723 }
1723 r1_bio->read_disk = primary; 1724 r1_bio->read_disk = primary;
1725 vcnt = (r1_bio->sectors + PAGE_SIZE / 512 - 1) >> (PAGE_SHIFT - 9);
1724 for (i = 0; i < conf->raid_disks * 2; i++) { 1726 for (i = 0; i < conf->raid_disks * 2; i++) {
1725 int j; 1727 int j;
1726 int vcnt = r1_bio->sectors >> (PAGE_SHIFT- 9);
1727 struct bio *pbio = r1_bio->bios[primary]; 1728 struct bio *pbio = r1_bio->bios[primary];
1728 struct bio *sbio = r1_bio->bios[i]; 1729 struct bio *sbio = r1_bio->bios[i];
1729 int size; 1730 int size;
diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
index fff782189e48..c8dbb84d5357 100644
--- a/drivers/md/raid10.c
+++ b/drivers/md/raid10.c
@@ -1788,6 +1788,7 @@ static void sync_request_write(struct mddev *mddev, struct r10bio *r10_bio)
1788 struct r10conf *conf = mddev->private; 1788 struct r10conf *conf = mddev->private;
1789 int i, first; 1789 int i, first;
1790 struct bio *tbio, *fbio; 1790 struct bio *tbio, *fbio;
1791 int vcnt;
1791 1792
1792 atomic_set(&r10_bio->remaining, 1); 1793 atomic_set(&r10_bio->remaining, 1);
1793 1794
@@ -1802,10 +1803,10 @@ static void sync_request_write(struct mddev *mddev, struct r10bio *r10_bio)
1802 first = i; 1803 first = i;
1803 fbio = r10_bio->devs[i].bio; 1804 fbio = r10_bio->devs[i].bio;
1804 1805
1806 vcnt = (r10_bio->sectors + (PAGE_SIZE >> 9) - 1) >> (PAGE_SHIFT - 9);
1805 /* now find blocks with errors */ 1807 /* now find blocks with errors */
1806 for (i=0 ; i < conf->copies ; i++) { 1808 for (i=0 ; i < conf->copies ; i++) {
1807 int j, d; 1809 int j, d;
1808 int vcnt = r10_bio->sectors >> (PAGE_SHIFT-9);
1809 1810
1810 tbio = r10_bio->devs[i].bio; 1811 tbio = r10_bio->devs[i].bio;
1811 1812
@@ -1871,7 +1872,6 @@ static void sync_request_write(struct mddev *mddev, struct r10bio *r10_bio)
1871 */ 1872 */
1872 for (i = 0; i < conf->copies; i++) { 1873 for (i = 0; i < conf->copies; i++) {
1873 int j, d; 1874 int j, d;
1874 int vcnt = r10_bio->sectors >> (PAGE_SHIFT-9);
1875 1875
1876 tbio = r10_bio->devs[i].repl_bio; 1876 tbio = r10_bio->devs[i].repl_bio;
1877 if (!tbio || !tbio->bi_end_io) 1877 if (!tbio || !tbio->bi_end_io)
diff --git a/drivers/media/common/tuners/xc5000.c b/drivers/media/common/tuners/xc5000.c
index 7f98984e4fad..eab2ea424200 100644
--- a/drivers/media/common/tuners/xc5000.c
+++ b/drivers/media/common/tuners/xc5000.c
@@ -54,6 +54,7 @@ struct xc5000_priv {
54 struct list_head hybrid_tuner_instance_list; 54 struct list_head hybrid_tuner_instance_list;
55 55
56 u32 if_khz; 56 u32 if_khz;
57 u32 xtal_khz;
57 u32 freq_hz; 58 u32 freq_hz;
58 u32 bandwidth; 59 u32 bandwidth;
59 u8 video_standard; 60 u8 video_standard;
@@ -214,9 +215,9 @@ static const struct xc5000_fw_cfg xc5000a_1_6_114 = {
214 .size = 12401, 215 .size = 12401,
215}; 216};
216 217
217static const struct xc5000_fw_cfg xc5000c_41_024_5_31875 = { 218static const struct xc5000_fw_cfg xc5000c_41_024_5 = {
218 .name = "dvb-fe-xc5000c-41.024.5-31875.fw", 219 .name = "dvb-fe-xc5000c-41.024.5.fw",
219 .size = 16503, 220 .size = 16497,
220}; 221};
221 222
222static inline const struct xc5000_fw_cfg *xc5000_assign_firmware(int chip_id) 223static inline const struct xc5000_fw_cfg *xc5000_assign_firmware(int chip_id)
@@ -226,7 +227,7 @@ static inline const struct xc5000_fw_cfg *xc5000_assign_firmware(int chip_id)
226 case XC5000A: 227 case XC5000A:
227 return &xc5000a_1_6_114; 228 return &xc5000a_1_6_114;
228 case XC5000C: 229 case XC5000C:
229 return &xc5000c_41_024_5_31875; 230 return &xc5000c_41_024_5;
230 } 231 }
231} 232}
232 233
@@ -572,6 +573,31 @@ static int xc_tune_channel(struct xc5000_priv *priv, u32 freq_hz, int mode)
572 return found; 573 return found;
573} 574}
574 575
576static int xc_set_xtal(struct dvb_frontend *fe)
577{
578 struct xc5000_priv *priv = fe->tuner_priv;
579 int ret = XC_RESULT_SUCCESS;
580
581 switch (priv->chip_id) {
582 default:
583 case XC5000A:
584 /* 32.000 MHz xtal is default */
585 break;
586 case XC5000C:
587 switch (priv->xtal_khz) {
588 default:
589 case 32000:
590 /* 32.000 MHz xtal is default */
591 break;
592 case 31875:
593 /* 31.875 MHz xtal configuration */
594 ret = xc_write_reg(priv, 0x000f, 0x8081);
595 break;
596 }
597 break;
598 }
599 return ret;
600}
575 601
576static int xc5000_fwupload(struct dvb_frontend *fe) 602static int xc5000_fwupload(struct dvb_frontend *fe)
577{ 603{
@@ -603,6 +629,8 @@ static int xc5000_fwupload(struct dvb_frontend *fe)
603 } else { 629 } else {
604 printk(KERN_INFO "xc5000: firmware uploading...\n"); 630 printk(KERN_INFO "xc5000: firmware uploading...\n");
605 ret = xc_load_i2c_sequence(fe, fw->data); 631 ret = xc_load_i2c_sequence(fe, fw->data);
632 if (XC_RESULT_SUCCESS == ret)
633 ret = xc_set_xtal(fe);
606 printk(KERN_INFO "xc5000: firmware upload complete...\n"); 634 printk(KERN_INFO "xc5000: firmware upload complete...\n");
607 } 635 }
608 636
@@ -1164,6 +1192,9 @@ struct dvb_frontend *xc5000_attach(struct dvb_frontend *fe,
1164 priv->if_khz = cfg->if_khz; 1192 priv->if_khz = cfg->if_khz;
1165 } 1193 }
1166 1194
1195 if (priv->xtal_khz == 0)
1196 priv->xtal_khz = cfg->xtal_khz;
1197
1167 if (priv->radio_input == 0) 1198 if (priv->radio_input == 0)
1168 priv->radio_input = cfg->radio_input; 1199 priv->radio_input = cfg->radio_input;
1169 1200
diff --git a/drivers/media/common/tuners/xc5000.h b/drivers/media/common/tuners/xc5000.h
index 3396f8e02b40..39a73bf01406 100644
--- a/drivers/media/common/tuners/xc5000.h
+++ b/drivers/media/common/tuners/xc5000.h
@@ -34,6 +34,7 @@ struct xc5000_config {
34 u8 i2c_address; 34 u8 i2c_address;
35 u32 if_khz; 35 u32 if_khz;
36 u8 radio_input; 36 u8 radio_input;
37 u32 xtal_khz;
37 38
38 int chip_id; 39 int chip_id;
39}; 40};
diff --git a/drivers/media/dvb/dvb-core/dvb_frontend.c b/drivers/media/dvb/dvb-core/dvb_frontend.c
index 4555baa383b2..0f64d7182657 100644
--- a/drivers/media/dvb/dvb-core/dvb_frontend.c
+++ b/drivers/media/dvb/dvb-core/dvb_frontend.c
@@ -143,10 +143,12 @@ struct dvb_frontend_private {
143static void dvb_frontend_wakeup(struct dvb_frontend *fe); 143static void dvb_frontend_wakeup(struct dvb_frontend *fe);
144static int dtv_get_frontend(struct dvb_frontend *fe, 144static int dtv_get_frontend(struct dvb_frontend *fe,
145 struct dvb_frontend_parameters *p_out); 145 struct dvb_frontend_parameters *p_out);
146static int dtv_property_legacy_params_sync(struct dvb_frontend *fe,
147 struct dvb_frontend_parameters *p);
146 148
147static bool has_get_frontend(struct dvb_frontend *fe) 149static bool has_get_frontend(struct dvb_frontend *fe)
148{ 150{
149 return fe->ops.get_frontend; 151 return fe->ops.get_frontend != NULL;
150} 152}
151 153
152/* 154/*
@@ -697,6 +699,7 @@ restart:
697 fepriv->algo_status |= DVBFE_ALGO_SEARCH_AGAIN; 699 fepriv->algo_status |= DVBFE_ALGO_SEARCH_AGAIN;
698 fepriv->delay = HZ / 2; 700 fepriv->delay = HZ / 2;
699 } 701 }
702 dtv_property_legacy_params_sync(fe, &fepriv->parameters_out);
700 fe->ops.read_status(fe, &s); 703 fe->ops.read_status(fe, &s);
701 if (s != fepriv->status) { 704 if (s != fepriv->status) {
702 dvb_frontend_add_event(fe, s); /* update event list */ 705 dvb_frontend_add_event(fe, s); /* update event list */
@@ -1443,6 +1446,28 @@ static int set_delivery_system(struct dvb_frontend *fe, u32 desired_system)
1443 __func__); 1446 __func__);
1444 return -EINVAL; 1447 return -EINVAL;
1445 } 1448 }
1449 /*
1450 * Get a delivery system that is compatible with DVBv3
1451 * NOTE: in order for this to work with softwares like Kaffeine that
1452 * uses a DVBv5 call for DVB-S2 and a DVBv3 call to go back to
1453 * DVB-S, drivers that support both should put the SYS_DVBS entry
1454 * before the SYS_DVBS2, otherwise it won't switch back to DVB-S.
1455 * The real fix is that userspace applications should not use DVBv3
1456 * and not trust on calling FE_SET_FRONTEND to switch the delivery
1457 * system.
1458 */
1459 ncaps = 0;
1460 while (fe->ops.delsys[ncaps] && ncaps < MAX_DELSYS) {
1461 if (fe->ops.delsys[ncaps] == desired_system) {
1462 delsys = desired_system;
1463 break;
1464 }
1465 ncaps++;
1466 }
1467 if (delsys == SYS_UNDEFINED) {
1468 dprintk("%s() Couldn't find a delivery system that matches %d\n",
1469 __func__, desired_system);
1470 }
1446 } else { 1471 } else {
1447 /* 1472 /*
1448 * This is a DVBv5 call. So, it likely knows the supported 1473 * This is a DVBv5 call. So, it likely knows the supported
@@ -1491,9 +1516,10 @@ static int set_delivery_system(struct dvb_frontend *fe, u32 desired_system)
1491 __func__); 1516 __func__);
1492 return -EINVAL; 1517 return -EINVAL;
1493 } 1518 }
1494 c->delivery_system = delsys;
1495 } 1519 }
1496 1520
1521 c->delivery_system = delsys;
1522
1497 /* 1523 /*
1498 * The DVBv3 or DVBv5 call is requesting a different system. So, 1524 * The DVBv3 or DVBv5 call is requesting a different system. So,
1499 * emulation is needed. 1525 * emulation is needed.
@@ -1833,6 +1859,13 @@ static int dtv_set_frontend(struct dvb_frontend *fe)
1833 return -EINVAL; 1859 return -EINVAL;
1834 1860
1835 /* 1861 /*
1862 * Initialize output parameters to match the values given by
1863 * the user. FE_SET_FRONTEND triggers an initial frontend event
1864 * with status = 0, which copies output parameters to userspace.
1865 */
1866 dtv_property_legacy_params_sync(fe, &fepriv->parameters_out);
1867
1868 /*
1836 * Be sure that the bandwidth will be filled for all 1869 * Be sure that the bandwidth will be filled for all
1837 * non-satellite systems, as tuners need to know what 1870 * non-satellite systems, as tuners need to know what
1838 * low pass/Nyquist half filter should be applied, in 1871 * low pass/Nyquist half filter should be applied, in
diff --git a/drivers/media/dvb/dvb-usb/it913x.c b/drivers/media/dvb/dvb-usb/it913x.c
index 3b7b102f20ae..482d249ca7f3 100644
--- a/drivers/media/dvb/dvb-usb/it913x.c
+++ b/drivers/media/dvb/dvb-usb/it913x.c
@@ -238,12 +238,27 @@ static int it913x_read_reg(struct usb_device *udev, u32 reg)
238 238
239static u32 it913x_query(struct usb_device *udev, u8 pro) 239static u32 it913x_query(struct usb_device *udev, u8 pro)
240{ 240{
241 int ret; 241 int ret, i;
242 u8 data[4]; 242 u8 data[4];
243 ret = it913x_io(udev, READ_LONG, pro, CMD_DEMOD_READ, 243 u8 ver;
244 0x1222, 0, &data[0], 3); 244
245 for (i = 0; i < 5; i++) {
246 ret = it913x_io(udev, READ_LONG, pro, CMD_DEMOD_READ,
247 0x1222, 0, &data[0], 3);
248 ver = data[0];
249 if (ver > 0 && ver < 3)
250 break;
251 msleep(100);
252 }
245 253
246 it913x_config.chip_ver = data[0]; 254 if (ver < 1 || ver > 2) {
255 info("Failed to identify chip version applying 1");
256 it913x_config.chip_ver = 0x1;
257 it913x_config.chip_type = 0x9135;
258 return 0;
259 }
260
261 it913x_config.chip_ver = ver;
247 it913x_config.chip_type = (u16)(data[2] << 8) + data[1]; 262 it913x_config.chip_type = (u16)(data[2] << 8) + data[1];
248 263
249 info("Chip Version=%02x Chip Type=%04x", it913x_config.chip_ver, 264 info("Chip Version=%02x Chip Type=%04x", it913x_config.chip_ver,
@@ -660,30 +675,41 @@ static int it913x_download_firmware(struct usb_device *udev,
660 if ((packet_size > min_pkt) || (i == fw->size)) { 675 if ((packet_size > min_pkt) || (i == fw->size)) {
661 fw_data = (u8 *)(fw->data + pos); 676 fw_data = (u8 *)(fw->data + pos);
662 pos += packet_size; 677 pos += packet_size;
663 if (packet_size > 0) 678 if (packet_size > 0) {
664 ret |= it913x_io(udev, WRITE_DATA, 679 ret = it913x_io(udev, WRITE_DATA,
665 DEV_0, CMD_SCATTER_WRITE, 0, 680 DEV_0, CMD_SCATTER_WRITE, 0,
666 0, fw_data, packet_size); 681 0, fw_data, packet_size);
682 if (ret < 0)
683 break;
684 }
667 udelay(1000); 685 udelay(1000);
668 } 686 }
669 } 687 }
670 i++; 688 i++;
671 } 689 }
672 690
673 ret |= it913x_io(udev, WRITE_CMD, DEV_0, CMD_BOOT, 0, 0, NULL, 0);
674
675 msleep(100);
676
677 if (ret < 0) 691 if (ret < 0)
678 info("FRM Firmware Download Failed (%04x)" , ret); 692 info("FRM Firmware Download Failed (%d)" , ret);
679 else 693 else
680 info("FRM Firmware Download Completed - Resetting Device"); 694 info("FRM Firmware Download Completed - Resetting Device");
681 695
682 ret |= it913x_return_status(udev); 696 msleep(30);
697
698 ret = it913x_io(udev, WRITE_CMD, DEV_0, CMD_BOOT, 0, 0, NULL, 0);
699 if (ret < 0)
700 info("FRM Device not responding to reboot");
701
702 ret = it913x_return_status(udev);
703 if (ret == 0) {
704 info("FRM Failed to reboot device");
705 return -ENODEV;
706 }
683 707
684 msleep(30); 708 msleep(30);
685 709
686 ret |= it913x_wr_reg(udev, DEV_0, I2C_CLK, I2C_CLK_400); 710 ret = it913x_wr_reg(udev, DEV_0, I2C_CLK, I2C_CLK_400);
711
712 msleep(30);
687 713
688 /* Tuner function */ 714 /* Tuner function */
689 if (it913x_config.dual_mode) 715 if (it913x_config.dual_mode)
@@ -901,5 +927,5 @@ module_usb_driver(it913x_driver);
901 927
902MODULE_AUTHOR("Malcolm Priestley <tvboxspy@gmail.com>"); 928MODULE_AUTHOR("Malcolm Priestley <tvboxspy@gmail.com>");
903MODULE_DESCRIPTION("it913x USB 2 Driver"); 929MODULE_DESCRIPTION("it913x USB 2 Driver");
904MODULE_VERSION("1.27"); 930MODULE_VERSION("1.28");
905MODULE_LICENSE("GPL"); 931MODULE_LICENSE("GPL");
diff --git a/drivers/media/dvb/frontends/drxk_hard.c b/drivers/media/dvb/frontends/drxk_hard.c
index 36d11756492f..a414b1f2b6a5 100644
--- a/drivers/media/dvb/frontends/drxk_hard.c
+++ b/drivers/media/dvb/frontends/drxk_hard.c
@@ -1520,8 +1520,10 @@ static int scu_command(struct drxk_state *state,
1520 dprintk(1, "\n"); 1520 dprintk(1, "\n");
1521 1521
1522 if ((cmd == 0) || ((parameterLen > 0) && (parameter == NULL)) || 1522 if ((cmd == 0) || ((parameterLen > 0) && (parameter == NULL)) ||
1523 ((resultLen > 0) && (result == NULL))) 1523 ((resultLen > 0) && (result == NULL))) {
1524 goto error; 1524 printk(KERN_ERR "drxk: Error %d on %s\n", status, __func__);
1525 return status;
1526 }
1525 1527
1526 mutex_lock(&state->mutex); 1528 mutex_lock(&state->mutex);
1527 1529
diff --git a/drivers/media/rc/winbond-cir.c b/drivers/media/rc/winbond-cir.c
index b09c5fae489b..af526586fa26 100644
--- a/drivers/media/rc/winbond-cir.c
+++ b/drivers/media/rc/winbond-cir.c
@@ -1046,6 +1046,7 @@ wbcir_probe(struct pnp_dev *device, const struct pnp_device_id *dev_id)
1046 goto exit_unregister_led; 1046 goto exit_unregister_led;
1047 } 1047 }
1048 1048
1049 data->dev->driver_type = RC_DRIVER_IR_RAW;
1049 data->dev->driver_name = WBCIR_NAME; 1050 data->dev->driver_name = WBCIR_NAME;
1050 data->dev->input_name = WBCIR_NAME; 1051 data->dev->input_name = WBCIR_NAME;
1051 data->dev->input_phys = "wbcir/cir0"; 1052 data->dev->input_phys = "wbcir/cir0";
diff --git a/drivers/media/video/Kconfig b/drivers/media/video/Kconfig
index f2479c5c0eb2..ce1e7ba940f6 100644
--- a/drivers/media/video/Kconfig
+++ b/drivers/media/video/Kconfig
@@ -492,7 +492,7 @@ config VIDEO_VS6624
492 492
493config VIDEO_MT9M032 493config VIDEO_MT9M032
494 tristate "MT9M032 camera sensor support" 494 tristate "MT9M032 camera sensor support"
495 depends on I2C && VIDEO_V4L2 495 depends on I2C && VIDEO_V4L2 && VIDEO_V4L2_SUBDEV_API
496 select VIDEO_APTINA_PLL 496 select VIDEO_APTINA_PLL
497 ---help--- 497 ---help---
498 This driver supports MT9M032 camera sensors from Aptina, monochrome 498 This driver supports MT9M032 camera sensors from Aptina, monochrome
diff --git a/drivers/media/video/ivtv/ivtv-ioctl.c b/drivers/media/video/ivtv/ivtv-ioctl.c
index 5452beef8e11..989e556913ed 100644
--- a/drivers/media/video/ivtv/ivtv-ioctl.c
+++ b/drivers/media/video/ivtv/ivtv-ioctl.c
@@ -1763,13 +1763,13 @@ static int ivtv_decoder_ioctls(struct file *filp, unsigned int cmd, void *arg)
1763 IVTV_DEBUG_IOCTL("AUDIO_CHANNEL_SELECT\n"); 1763 IVTV_DEBUG_IOCTL("AUDIO_CHANNEL_SELECT\n");
1764 if (iarg > AUDIO_STEREO_SWAPPED) 1764 if (iarg > AUDIO_STEREO_SWAPPED)
1765 return -EINVAL; 1765 return -EINVAL;
1766 return v4l2_ctrl_s_ctrl(itv->ctrl_audio_playback, iarg); 1766 return v4l2_ctrl_s_ctrl(itv->ctrl_audio_playback, iarg + 1);
1767 1767
1768 case AUDIO_BILINGUAL_CHANNEL_SELECT: 1768 case AUDIO_BILINGUAL_CHANNEL_SELECT:
1769 IVTV_DEBUG_IOCTL("AUDIO_BILINGUAL_CHANNEL_SELECT\n"); 1769 IVTV_DEBUG_IOCTL("AUDIO_BILINGUAL_CHANNEL_SELECT\n");
1770 if (iarg > AUDIO_STEREO_SWAPPED) 1770 if (iarg > AUDIO_STEREO_SWAPPED)
1771 return -EINVAL; 1771 return -EINVAL;
1772 return v4l2_ctrl_s_ctrl(itv->ctrl_audio_multilingual_playback, iarg); 1772 return v4l2_ctrl_s_ctrl(itv->ctrl_audio_multilingual_playback, iarg + 1);
1773 1773
1774 default: 1774 default:
1775 return -EINVAL; 1775 return -EINVAL;
diff --git a/drivers/media/video/mt9m032.c b/drivers/media/video/mt9m032.c
index 7636672c3548..645973c5feb0 100644
--- a/drivers/media/video/mt9m032.c
+++ b/drivers/media/video/mt9m032.c
@@ -392,10 +392,11 @@ static int mt9m032_set_pad_format(struct v4l2_subdev *subdev,
392 } 392 }
393 393
394 /* Scaling is not supported, the format is thus fixed. */ 394 /* Scaling is not supported, the format is thus fixed. */
395 ret = mt9m032_get_pad_format(subdev, fh, fmt); 395 fmt->format = *__mt9m032_get_pad_format(sensor, fh, fmt->which);
396 ret = 0;
396 397
397done: 398done:
398 mutex_lock(&sensor->lock); 399 mutex_unlock(&sensor->lock);
399 return ret; 400 return ret;
400} 401}
401 402
diff --git a/drivers/media/video/uvc/uvc_video.c b/drivers/media/video/uvc/uvc_video.c
index 4a44f9a1bae0..b76b0ac0958f 100644
--- a/drivers/media/video/uvc/uvc_video.c
+++ b/drivers/media/video/uvc/uvc_video.c
@@ -468,22 +468,30 @@ uvc_video_clock_decode(struct uvc_streaming *stream, struct uvc_buffer *buf,
468 spin_unlock_irqrestore(&stream->clock.lock, flags); 468 spin_unlock_irqrestore(&stream->clock.lock, flags);
469} 469}
470 470
471static int uvc_video_clock_init(struct uvc_streaming *stream) 471static void uvc_video_clock_reset(struct uvc_streaming *stream)
472{ 472{
473 struct uvc_clock *clock = &stream->clock; 473 struct uvc_clock *clock = &stream->clock;
474 474
475 spin_lock_init(&clock->lock);
476 clock->head = 0; 475 clock->head = 0;
477 clock->count = 0; 476 clock->count = 0;
478 clock->size = 32;
479 clock->last_sof = -1; 477 clock->last_sof = -1;
480 clock->sof_offset = -1; 478 clock->sof_offset = -1;
479}
480
481static int uvc_video_clock_init(struct uvc_streaming *stream)
482{
483 struct uvc_clock *clock = &stream->clock;
484
485 spin_lock_init(&clock->lock);
486 clock->size = 32;
481 487
482 clock->samples = kmalloc(clock->size * sizeof(*clock->samples), 488 clock->samples = kmalloc(clock->size * sizeof(*clock->samples),
483 GFP_KERNEL); 489 GFP_KERNEL);
484 if (clock->samples == NULL) 490 if (clock->samples == NULL)
485 return -ENOMEM; 491 return -ENOMEM;
486 492
493 uvc_video_clock_reset(stream);
494
487 return 0; 495 return 0;
488} 496}
489 497
@@ -1424,8 +1432,6 @@ static void uvc_uninit_video(struct uvc_streaming *stream, int free_buffers)
1424 1432
1425 if (free_buffers) 1433 if (free_buffers)
1426 uvc_free_urb_buffers(stream); 1434 uvc_free_urb_buffers(stream);
1427
1428 uvc_video_clock_cleanup(stream);
1429} 1435}
1430 1436
1431/* 1437/*
@@ -1555,10 +1561,6 @@ static int uvc_init_video(struct uvc_streaming *stream, gfp_t gfp_flags)
1555 1561
1556 uvc_video_stats_start(stream); 1562 uvc_video_stats_start(stream);
1557 1563
1558 ret = uvc_video_clock_init(stream);
1559 if (ret < 0)
1560 return ret;
1561
1562 if (intf->num_altsetting > 1) { 1564 if (intf->num_altsetting > 1) {
1563 struct usb_host_endpoint *best_ep = NULL; 1565 struct usb_host_endpoint *best_ep = NULL;
1564 unsigned int best_psize = 3 * 1024; 1566 unsigned int best_psize = 3 * 1024;
@@ -1683,6 +1685,8 @@ int uvc_video_resume(struct uvc_streaming *stream, int reset)
1683 1685
1684 stream->frozen = 0; 1686 stream->frozen = 0;
1685 1687
1688 uvc_video_clock_reset(stream);
1689
1686 ret = uvc_commit_video(stream, &stream->ctrl); 1690 ret = uvc_commit_video(stream, &stream->ctrl);
1687 if (ret < 0) { 1691 if (ret < 0) {
1688 uvc_queue_enable(&stream->queue, 0); 1692 uvc_queue_enable(&stream->queue, 0);
@@ -1819,25 +1823,35 @@ int uvc_video_enable(struct uvc_streaming *stream, int enable)
1819 uvc_uninit_video(stream, 1); 1823 uvc_uninit_video(stream, 1);
1820 usb_set_interface(stream->dev->udev, stream->intfnum, 0); 1824 usb_set_interface(stream->dev->udev, stream->intfnum, 0);
1821 uvc_queue_enable(&stream->queue, 0); 1825 uvc_queue_enable(&stream->queue, 0);
1826 uvc_video_clock_cleanup(stream);
1822 return 0; 1827 return 0;
1823 } 1828 }
1824 1829
1825 ret = uvc_queue_enable(&stream->queue, 1); 1830 ret = uvc_video_clock_init(stream);
1826 if (ret < 0) 1831 if (ret < 0)
1827 return ret; 1832 return ret;
1828 1833
1834 ret = uvc_queue_enable(&stream->queue, 1);
1835 if (ret < 0)
1836 goto error_queue;
1837
1829 /* Commit the streaming parameters. */ 1838 /* Commit the streaming parameters. */
1830 ret = uvc_commit_video(stream, &stream->ctrl); 1839 ret = uvc_commit_video(stream, &stream->ctrl);
1831 if (ret < 0) { 1840 if (ret < 0)
1832 uvc_queue_enable(&stream->queue, 0); 1841 goto error_commit;
1833 return ret;
1834 }
1835 1842
1836 ret = uvc_init_video(stream, GFP_KERNEL); 1843 ret = uvc_init_video(stream, GFP_KERNEL);
1837 if (ret < 0) { 1844 if (ret < 0)
1838 usb_set_interface(stream->dev->udev, stream->intfnum, 0); 1845 goto error_video;
1839 uvc_queue_enable(&stream->queue, 0); 1846
1840 } 1847 return 0;
1848
1849error_video:
1850 usb_set_interface(stream->dev->udev, stream->intfnum, 0);
1851error_commit:
1852 uvc_queue_enable(&stream->queue, 0);
1853error_queue:
1854 uvc_video_clock_cleanup(stream);
1841 1855
1842 return ret; 1856 return ret;
1843} 1857}
diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index 29f463cc09cb..11e44386fa9b 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -268,10 +268,17 @@ config TWL6030_PWM
268 This is used to control charging LED brightness. 268 This is used to control charging LED brightness.
269 269
270config TWL6040_CORE 270config TWL6040_CORE
271 bool 271 bool "Support for TWL6040 audio codec"
272 depends on TWL4030_CORE && GENERIC_HARDIRQS 272 depends on I2C=y && GENERIC_HARDIRQS
273 select MFD_CORE 273 select MFD_CORE
274 select REGMAP_I2C
274 default n 275 default n
276 help
277 Say yes here if you want support for Texas Instruments TWL6040 audio
278 codec.
279 This driver provides common support for accessing the device,
280 additional drivers must be enabled in order to use the
281 functionality of the device (audio, vibra).
275 282
276config MFD_STMPE 283config MFD_STMPE
277 bool "Support STMicroelectronics STMPE" 284 bool "Support STMicroelectronics STMPE"
diff --git a/drivers/mfd/asic3.c b/drivers/mfd/asic3.c
index 1895cf9fab8c..1582c3d95257 100644
--- a/drivers/mfd/asic3.c
+++ b/drivers/mfd/asic3.c
@@ -527,7 +527,9 @@ static void asic3_gpio_set(struct gpio_chip *chip,
527 527
528static int asic3_gpio_to_irq(struct gpio_chip *chip, unsigned offset) 528static int asic3_gpio_to_irq(struct gpio_chip *chip, unsigned offset)
529{ 529{
530 return (offset < ASIC3_NUM_GPIOS) ? IRQ_BOARD_START + offset : -ENXIO; 530 struct asic3 *asic = container_of(chip, struct asic3, gpio);
531
532 return (offset < ASIC3_NUM_GPIOS) ? asic->irq_base + offset : -ENXIO;
531} 533}
532 534
533static __init int asic3_gpio_probe(struct platform_device *pdev, 535static __init int asic3_gpio_probe(struct platform_device *pdev,
diff --git a/drivers/mfd/db8500-prcmu.c b/drivers/mfd/db8500-prcmu.c
index ebc1e8658226..5be32489714f 100644
--- a/drivers/mfd/db8500-prcmu.c
+++ b/drivers/mfd/db8500-prcmu.c
@@ -2788,6 +2788,7 @@ static struct regulator_init_data db8500_regulators[DB8500_NUM_REGULATORS] = {
2788 .constraints = { 2788 .constraints = {
2789 .name = "db8500-vape", 2789 .name = "db8500-vape",
2790 .valid_ops_mask = REGULATOR_CHANGE_STATUS, 2790 .valid_ops_mask = REGULATOR_CHANGE_STATUS,
2791 .always_on = true,
2791 }, 2792 },
2792 .consumer_supplies = db8500_vape_consumers, 2793 .consumer_supplies = db8500_vape_consumers,
2793 .num_consumer_supplies = ARRAY_SIZE(db8500_vape_consumers), 2794 .num_consumer_supplies = ARRAY_SIZE(db8500_vape_consumers),
diff --git a/drivers/mfd/omap-usb-host.c b/drivers/mfd/omap-usb-host.c
index 95a2e546a489..c8aae6640e64 100644
--- a/drivers/mfd/omap-usb-host.c
+++ b/drivers/mfd/omap-usb-host.c
@@ -25,7 +25,6 @@
25#include <linux/clk.h> 25#include <linux/clk.h>
26#include <linux/dma-mapping.h> 26#include <linux/dma-mapping.h>
27#include <linux/spinlock.h> 27#include <linux/spinlock.h>
28#include <linux/gpio.h>
29#include <plat/usb.h> 28#include <plat/usb.h>
30#include <linux/pm_runtime.h> 29#include <linux/pm_runtime.h>
31 30
@@ -502,19 +501,6 @@ static void omap_usbhs_init(struct device *dev)
502 pm_runtime_get_sync(dev); 501 pm_runtime_get_sync(dev);
503 spin_lock_irqsave(&omap->lock, flags); 502 spin_lock_irqsave(&omap->lock, flags);
504 503
505 if (pdata->ehci_data->phy_reset) {
506 if (gpio_is_valid(pdata->ehci_data->reset_gpio_port[0]))
507 gpio_request_one(pdata->ehci_data->reset_gpio_port[0],
508 GPIOF_OUT_INIT_LOW, "USB1 PHY reset");
509
510 if (gpio_is_valid(pdata->ehci_data->reset_gpio_port[1]))
511 gpio_request_one(pdata->ehci_data->reset_gpio_port[1],
512 GPIOF_OUT_INIT_LOW, "USB2 PHY reset");
513
514 /* Hold the PHY in RESET for enough time till DIR is high */
515 udelay(10);
516 }
517
518 omap->usbhs_rev = usbhs_read(omap->uhh_base, OMAP_UHH_REVISION); 504 omap->usbhs_rev = usbhs_read(omap->uhh_base, OMAP_UHH_REVISION);
519 dev_dbg(dev, "OMAP UHH_REVISION 0x%x\n", omap->usbhs_rev); 505 dev_dbg(dev, "OMAP UHH_REVISION 0x%x\n", omap->usbhs_rev);
520 506
@@ -593,39 +579,10 @@ static void omap_usbhs_init(struct device *dev)
593 usbhs_omap_tll_init(dev, OMAP_TLL_CHANNEL_COUNT); 579 usbhs_omap_tll_init(dev, OMAP_TLL_CHANNEL_COUNT);
594 } 580 }
595 581
596 if (pdata->ehci_data->phy_reset) {
597 /* Hold the PHY in RESET for enough time till
598 * PHY is settled and ready
599 */
600 udelay(10);
601
602 if (gpio_is_valid(pdata->ehci_data->reset_gpio_port[0]))
603 gpio_set_value
604 (pdata->ehci_data->reset_gpio_port[0], 1);
605
606 if (gpio_is_valid(pdata->ehci_data->reset_gpio_port[1]))
607 gpio_set_value
608 (pdata->ehci_data->reset_gpio_port[1], 1);
609 }
610
611 spin_unlock_irqrestore(&omap->lock, flags); 582 spin_unlock_irqrestore(&omap->lock, flags);
612 pm_runtime_put_sync(dev); 583 pm_runtime_put_sync(dev);
613} 584}
614 585
615static void omap_usbhs_deinit(struct device *dev)
616{
617 struct usbhs_hcd_omap *omap = dev_get_drvdata(dev);
618 struct usbhs_omap_platform_data *pdata = &omap->platdata;
619
620 if (pdata->ehci_data->phy_reset) {
621 if (gpio_is_valid(pdata->ehci_data->reset_gpio_port[0]))
622 gpio_free(pdata->ehci_data->reset_gpio_port[0]);
623
624 if (gpio_is_valid(pdata->ehci_data->reset_gpio_port[1]))
625 gpio_free(pdata->ehci_data->reset_gpio_port[1]);
626 }
627}
628
629 586
630/** 587/**
631 * usbhs_omap_probe - initialize TI-based HCDs 588 * usbhs_omap_probe - initialize TI-based HCDs
@@ -860,7 +817,6 @@ static int __devexit usbhs_omap_remove(struct platform_device *pdev)
860{ 817{
861 struct usbhs_hcd_omap *omap = platform_get_drvdata(pdev); 818 struct usbhs_hcd_omap *omap = platform_get_drvdata(pdev);
862 819
863 omap_usbhs_deinit(&pdev->dev);
864 iounmap(omap->tll_base); 820 iounmap(omap->tll_base);
865 iounmap(omap->uhh_base); 821 iounmap(omap->uhh_base);
866 clk_put(omap->init_60m_fclk); 822 clk_put(omap->init_60m_fclk);
diff --git a/drivers/mfd/rc5t583.c b/drivers/mfd/rc5t583.c
index 99ef944c621d..44afae0a69ce 100644
--- a/drivers/mfd/rc5t583.c
+++ b/drivers/mfd/rc5t583.c
@@ -80,44 +80,6 @@ static struct mfd_cell rc5t583_subdevs[] = {
80 {.name = "rc5t583-key", } 80 {.name = "rc5t583-key", }
81}; 81};
82 82
83int rc5t583_write(struct device *dev, uint8_t reg, uint8_t val)
84{
85 struct rc5t583 *rc5t583 = dev_get_drvdata(dev);
86 return regmap_write(rc5t583->regmap, reg, val);
87}
88
89int rc5t583_read(struct device *dev, uint8_t reg, uint8_t *val)
90{
91 struct rc5t583 *rc5t583 = dev_get_drvdata(dev);
92 unsigned int ival;
93 int ret;
94 ret = regmap_read(rc5t583->regmap, reg, &ival);
95 if (!ret)
96 *val = (uint8_t)ival;
97 return ret;
98}
99
100int rc5t583_set_bits(struct device *dev, unsigned int reg,
101 unsigned int bit_mask)
102{
103 struct rc5t583 *rc5t583 = dev_get_drvdata(dev);
104 return regmap_update_bits(rc5t583->regmap, reg, bit_mask, bit_mask);
105}
106
107int rc5t583_clear_bits(struct device *dev, unsigned int reg,
108 unsigned int bit_mask)
109{
110 struct rc5t583 *rc5t583 = dev_get_drvdata(dev);
111 return regmap_update_bits(rc5t583->regmap, reg, bit_mask, 0);
112}
113
114int rc5t583_update(struct device *dev, unsigned int reg,
115 unsigned int val, unsigned int mask)
116{
117 struct rc5t583 *rc5t583 = dev_get_drvdata(dev);
118 return regmap_update_bits(rc5t583->regmap, reg, mask, val);
119}
120
121static int __rc5t583_set_ext_pwrreq1_control(struct device *dev, 83static int __rc5t583_set_ext_pwrreq1_control(struct device *dev,
122 int id, int ext_pwr, int slots) 84 int id, int ext_pwr, int slots)
123{ 85{
@@ -197,6 +159,7 @@ int rc5t583_ext_power_req_config(struct device *dev, int ds_id,
197 ds_id, ext_pwr_req); 159 ds_id, ext_pwr_req);
198 return 0; 160 return 0;
199} 161}
162EXPORT_SYMBOL(rc5t583_ext_power_req_config);
200 163
201static int rc5t583_clear_ext_power_req(struct rc5t583 *rc5t583, 164static int rc5t583_clear_ext_power_req(struct rc5t583 *rc5t583,
202 struct rc5t583_platform_data *pdata) 165 struct rc5t583_platform_data *pdata)
diff --git a/drivers/mfd/twl6040-core.c b/drivers/mfd/twl6040-core.c
index b2d8e512d3cb..2d6bedadca09 100644
--- a/drivers/mfd/twl6040-core.c
+++ b/drivers/mfd/twl6040-core.c
@@ -30,7 +30,9 @@
30#include <linux/platform_device.h> 30#include <linux/platform_device.h>
31#include <linux/gpio.h> 31#include <linux/gpio.h>
32#include <linux/delay.h> 32#include <linux/delay.h>
33#include <linux/i2c/twl.h> 33#include <linux/i2c.h>
34#include <linux/regmap.h>
35#include <linux/err.h>
34#include <linux/mfd/core.h> 36#include <linux/mfd/core.h>
35#include <linux/mfd/twl6040.h> 37#include <linux/mfd/twl6040.h>
36 38
@@ -39,7 +41,7 @@
39int twl6040_reg_read(struct twl6040 *twl6040, unsigned int reg) 41int twl6040_reg_read(struct twl6040 *twl6040, unsigned int reg)
40{ 42{
41 int ret; 43 int ret;
42 u8 val = 0; 44 unsigned int val;
43 45
44 mutex_lock(&twl6040->io_mutex); 46 mutex_lock(&twl6040->io_mutex);
45 /* Vibra control registers from cache */ 47 /* Vibra control registers from cache */
@@ -47,7 +49,7 @@ int twl6040_reg_read(struct twl6040 *twl6040, unsigned int reg)
47 reg == TWL6040_REG_VIBCTLR)) { 49 reg == TWL6040_REG_VIBCTLR)) {
48 val = twl6040->vibra_ctrl_cache[VIBRACTRL_MEMBER(reg)]; 50 val = twl6040->vibra_ctrl_cache[VIBRACTRL_MEMBER(reg)];
49 } else { 51 } else {
50 ret = twl_i2c_read_u8(TWL_MODULE_AUDIO_VOICE, &val, reg); 52 ret = regmap_read(twl6040->regmap, reg, &val);
51 if (ret < 0) { 53 if (ret < 0) {
52 mutex_unlock(&twl6040->io_mutex); 54 mutex_unlock(&twl6040->io_mutex);
53 return ret; 55 return ret;
@@ -64,7 +66,7 @@ int twl6040_reg_write(struct twl6040 *twl6040, unsigned int reg, u8 val)
64 int ret; 66 int ret;
65 67
66 mutex_lock(&twl6040->io_mutex); 68 mutex_lock(&twl6040->io_mutex);
67 ret = twl_i2c_write_u8(TWL_MODULE_AUDIO_VOICE, val, reg); 69 ret = regmap_write(twl6040->regmap, reg, val);
68 /* Cache the vibra control registers */ 70 /* Cache the vibra control registers */
69 if (reg == TWL6040_REG_VIBCTLL || reg == TWL6040_REG_VIBCTLR) 71 if (reg == TWL6040_REG_VIBCTLL || reg == TWL6040_REG_VIBCTLR)
70 twl6040->vibra_ctrl_cache[VIBRACTRL_MEMBER(reg)] = val; 72 twl6040->vibra_ctrl_cache[VIBRACTRL_MEMBER(reg)] = val;
@@ -77,16 +79,9 @@ EXPORT_SYMBOL(twl6040_reg_write);
77int twl6040_set_bits(struct twl6040 *twl6040, unsigned int reg, u8 mask) 79int twl6040_set_bits(struct twl6040 *twl6040, unsigned int reg, u8 mask)
78{ 80{
79 int ret; 81 int ret;
80 u8 val;
81 82
82 mutex_lock(&twl6040->io_mutex); 83 mutex_lock(&twl6040->io_mutex);
83 ret = twl_i2c_read_u8(TWL_MODULE_AUDIO_VOICE, &val, reg); 84 ret = regmap_update_bits(twl6040->regmap, reg, mask, mask);
84 if (ret)
85 goto out;
86
87 val |= mask;
88 ret = twl_i2c_write_u8(TWL_MODULE_AUDIO_VOICE, val, reg);
89out:
90 mutex_unlock(&twl6040->io_mutex); 85 mutex_unlock(&twl6040->io_mutex);
91 return ret; 86 return ret;
92} 87}
@@ -95,16 +90,9 @@ EXPORT_SYMBOL(twl6040_set_bits);
95int twl6040_clear_bits(struct twl6040 *twl6040, unsigned int reg, u8 mask) 90int twl6040_clear_bits(struct twl6040 *twl6040, unsigned int reg, u8 mask)
96{ 91{
97 int ret; 92 int ret;
98 u8 val;
99 93
100 mutex_lock(&twl6040->io_mutex); 94 mutex_lock(&twl6040->io_mutex);
101 ret = twl_i2c_read_u8(TWL_MODULE_AUDIO_VOICE, &val, reg); 95 ret = regmap_update_bits(twl6040->regmap, reg, mask, 0);
102 if (ret)
103 goto out;
104
105 val &= ~mask;
106 ret = twl_i2c_write_u8(TWL_MODULE_AUDIO_VOICE, val, reg);
107out:
108 mutex_unlock(&twl6040->io_mutex); 96 mutex_unlock(&twl6040->io_mutex);
109 return ret; 97 return ret;
110} 98}
@@ -494,32 +482,58 @@ static struct resource twl6040_codec_rsrc[] = {
494 }, 482 },
495}; 483};
496 484
497static int __devinit twl6040_probe(struct platform_device *pdev) 485static bool twl6040_readable_reg(struct device *dev, unsigned int reg)
498{ 486{
499 struct twl4030_audio_data *pdata = pdev->dev.platform_data; 487 /* Register 0 is not readable */
488 if (!reg)
489 return false;
490 return true;
491}
492
493static struct regmap_config twl6040_regmap_config = {
494 .reg_bits = 8,
495 .val_bits = 8,
496 .max_register = TWL6040_REG_STATUS, /* 0x2e */
497
498 .readable_reg = twl6040_readable_reg,
499};
500
501static int __devinit twl6040_probe(struct i2c_client *client,
502 const struct i2c_device_id *id)
503{
504 struct twl6040_platform_data *pdata = client->dev.platform_data;
500 struct twl6040 *twl6040; 505 struct twl6040 *twl6040;
501 struct mfd_cell *cell = NULL; 506 struct mfd_cell *cell = NULL;
502 int ret, children = 0; 507 int ret, children = 0;
503 508
504 if (!pdata) { 509 if (!pdata) {
505 dev_err(&pdev->dev, "Platform data is missing\n"); 510 dev_err(&client->dev, "Platform data is missing\n");
506 return -EINVAL; 511 return -EINVAL;
507 } 512 }
508 513
509 /* In order to operate correctly we need valid interrupt config */ 514 /* In order to operate correctly we need valid interrupt config */
510 if (!pdata->naudint_irq || !pdata->irq_base) { 515 if (!client->irq || !pdata->irq_base) {
511 dev_err(&pdev->dev, "Invalid IRQ configuration\n"); 516 dev_err(&client->dev, "Invalid IRQ configuration\n");
512 return -EINVAL; 517 return -EINVAL;
513 } 518 }
514 519
515 twl6040 = kzalloc(sizeof(struct twl6040), GFP_KERNEL); 520 twl6040 = devm_kzalloc(&client->dev, sizeof(struct twl6040),
516 if (!twl6040) 521 GFP_KERNEL);
517 return -ENOMEM; 522 if (!twl6040) {
523 ret = -ENOMEM;
524 goto err;
525 }
526
527 twl6040->regmap = regmap_init_i2c(client, &twl6040_regmap_config);
528 if (IS_ERR(twl6040->regmap)) {
529 ret = PTR_ERR(twl6040->regmap);
530 goto err;
531 }
518 532
519 platform_set_drvdata(pdev, twl6040); 533 i2c_set_clientdata(client, twl6040);
520 534
521 twl6040->dev = &pdev->dev; 535 twl6040->dev = &client->dev;
522 twl6040->irq = pdata->naudint_irq; 536 twl6040->irq = client->irq;
523 twl6040->irq_base = pdata->irq_base; 537 twl6040->irq_base = pdata->irq_base;
524 538
525 mutex_init(&twl6040->mutex); 539 mutex_init(&twl6040->mutex);
@@ -588,12 +602,12 @@ static int __devinit twl6040_probe(struct platform_device *pdev)
588 } 602 }
589 603
590 if (children) { 604 if (children) {
591 ret = mfd_add_devices(&pdev->dev, pdev->id, twl6040->cells, 605 ret = mfd_add_devices(&client->dev, -1, twl6040->cells,
592 children, NULL, 0); 606 children, NULL, 0);
593 if (ret) 607 if (ret)
594 goto mfd_err; 608 goto mfd_err;
595 } else { 609 } else {
596 dev_err(&pdev->dev, "No platform data found for children\n"); 610 dev_err(&client->dev, "No platform data found for children\n");
597 ret = -ENODEV; 611 ret = -ENODEV;
598 goto mfd_err; 612 goto mfd_err;
599 } 613 }
@@ -608,14 +622,15 @@ gpio2_err:
608 if (gpio_is_valid(twl6040->audpwron)) 622 if (gpio_is_valid(twl6040->audpwron))
609 gpio_free(twl6040->audpwron); 623 gpio_free(twl6040->audpwron);
610gpio1_err: 624gpio1_err:
611 platform_set_drvdata(pdev, NULL); 625 i2c_set_clientdata(client, NULL);
612 kfree(twl6040); 626 regmap_exit(twl6040->regmap);
627err:
613 return ret; 628 return ret;
614} 629}
615 630
616static int __devexit twl6040_remove(struct platform_device *pdev) 631static int __devexit twl6040_remove(struct i2c_client *client)
617{ 632{
618 struct twl6040 *twl6040 = platform_get_drvdata(pdev); 633 struct twl6040 *twl6040 = i2c_get_clientdata(client);
619 634
620 if (twl6040->power_count) 635 if (twl6040->power_count)
621 twl6040_power(twl6040, 0); 636 twl6040_power(twl6040, 0);
@@ -626,23 +641,30 @@ static int __devexit twl6040_remove(struct platform_device *pdev)
626 free_irq(twl6040->irq_base + TWL6040_IRQ_READY, twl6040); 641 free_irq(twl6040->irq_base + TWL6040_IRQ_READY, twl6040);
627 twl6040_irq_exit(twl6040); 642 twl6040_irq_exit(twl6040);
628 643
629 mfd_remove_devices(&pdev->dev); 644 mfd_remove_devices(&client->dev);
630 platform_set_drvdata(pdev, NULL); 645 i2c_set_clientdata(client, NULL);
631 kfree(twl6040); 646 regmap_exit(twl6040->regmap);
632 647
633 return 0; 648 return 0;
634} 649}
635 650
636static struct platform_driver twl6040_driver = { 651static const struct i2c_device_id twl6040_i2c_id[] = {
652 { "twl6040", 0, },
653 { },
654};
655MODULE_DEVICE_TABLE(i2c, twl6040_i2c_id);
656
657static struct i2c_driver twl6040_driver = {
658 .driver = {
659 .name = "twl6040",
660 .owner = THIS_MODULE,
661 },
637 .probe = twl6040_probe, 662 .probe = twl6040_probe,
638 .remove = __devexit_p(twl6040_remove), 663 .remove = __devexit_p(twl6040_remove),
639 .driver = { 664 .id_table = twl6040_i2c_id,
640 .owner = THIS_MODULE,
641 .name = "twl6040",
642 },
643}; 665};
644 666
645module_platform_driver(twl6040_driver); 667module_i2c_driver(twl6040_driver);
646 668
647MODULE_DESCRIPTION("TWL6040 MFD"); 669MODULE_DESCRIPTION("TWL6040 MFD");
648MODULE_AUTHOR("Misael Lopez Cruz <misael.lopez@ti.com>"); 670MODULE_AUTHOR("Misael Lopez Cruz <misael.lopez@ti.com>");
diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c
index b1809650b7aa..dabec556ebb8 100644
--- a/drivers/mmc/card/block.c
+++ b/drivers/mmc/card/block.c
@@ -873,7 +873,7 @@ static int mmc_blk_issue_secdiscard_rq(struct mmc_queue *mq,
873{ 873{
874 struct mmc_blk_data *md = mq->data; 874 struct mmc_blk_data *md = mq->data;
875 struct mmc_card *card = md->queue.card; 875 struct mmc_card *card = md->queue.card;
876 unsigned int from, nr, arg; 876 unsigned int from, nr, arg, trim_arg, erase_arg;
877 int err = 0, type = MMC_BLK_SECDISCARD; 877 int err = 0, type = MMC_BLK_SECDISCARD;
878 878
879 if (!(mmc_can_secure_erase_trim(card) || mmc_can_sanitize(card))) { 879 if (!(mmc_can_secure_erase_trim(card) || mmc_can_sanitize(card))) {
@@ -881,20 +881,26 @@ static int mmc_blk_issue_secdiscard_rq(struct mmc_queue *mq,
881 goto out; 881 goto out;
882 } 882 }
883 883
884 from = blk_rq_pos(req);
885 nr = blk_rq_sectors(req);
886
884 /* The sanitize operation is supported at v4.5 only */ 887 /* The sanitize operation is supported at v4.5 only */
885 if (mmc_can_sanitize(card)) { 888 if (mmc_can_sanitize(card)) {
886 err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, 889 erase_arg = MMC_ERASE_ARG;
887 EXT_CSD_SANITIZE_START, 1, 0); 890 trim_arg = MMC_TRIM_ARG;
888 goto out; 891 } else {
892 erase_arg = MMC_SECURE_ERASE_ARG;
893 trim_arg = MMC_SECURE_TRIM1_ARG;
889 } 894 }
890 895
891 from = blk_rq_pos(req); 896 if (mmc_erase_group_aligned(card, from, nr))
892 nr = blk_rq_sectors(req); 897 arg = erase_arg;
893 898 else if (mmc_can_trim(card))
894 if (mmc_can_trim(card) && !mmc_erase_group_aligned(card, from, nr)) 899 arg = trim_arg;
895 arg = MMC_SECURE_TRIM1_ARG; 900 else {
896 else 901 err = -EINVAL;
897 arg = MMC_SECURE_ERASE_ARG; 902 goto out;
903 }
898retry: 904retry:
899 if (card->quirks & MMC_QUIRK_INAND_CMD38) { 905 if (card->quirks & MMC_QUIRK_INAND_CMD38) {
900 err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, 906 err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
@@ -904,25 +910,41 @@ retry:
904 INAND_CMD38_ARG_SECERASE, 910 INAND_CMD38_ARG_SECERASE,
905 0); 911 0);
906 if (err) 912 if (err)
907 goto out; 913 goto out_retry;
908 } 914 }
915
909 err = mmc_erase(card, from, nr, arg); 916 err = mmc_erase(card, from, nr, arg);
910 if (!err && arg == MMC_SECURE_TRIM1_ARG) { 917 if (err == -EIO)
918 goto out_retry;
919 if (err)
920 goto out;
921
922 if (arg == MMC_SECURE_TRIM1_ARG) {
911 if (card->quirks & MMC_QUIRK_INAND_CMD38) { 923 if (card->quirks & MMC_QUIRK_INAND_CMD38) {
912 err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, 924 err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
913 INAND_CMD38_ARG_EXT_CSD, 925 INAND_CMD38_ARG_EXT_CSD,
914 INAND_CMD38_ARG_SECTRIM2, 926 INAND_CMD38_ARG_SECTRIM2,
915 0); 927 0);
916 if (err) 928 if (err)
917 goto out; 929 goto out_retry;
918 } 930 }
931
919 err = mmc_erase(card, from, nr, MMC_SECURE_TRIM2_ARG); 932 err = mmc_erase(card, from, nr, MMC_SECURE_TRIM2_ARG);
933 if (err == -EIO)
934 goto out_retry;
935 if (err)
936 goto out;
920 } 937 }
921out: 938
922 if (err == -EIO && !mmc_blk_reset(md, card->host, type)) 939 if (mmc_can_sanitize(card))
940 err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
941 EXT_CSD_SANITIZE_START, 1, 0);
942out_retry:
943 if (err && !mmc_blk_reset(md, card->host, type))
923 goto retry; 944 goto retry;
924 if (!err) 945 if (!err)
925 mmc_blk_reset_success(md, type); 946 mmc_blk_reset_success(md, type);
947out:
926 spin_lock_irq(&md->lock); 948 spin_lock_irq(&md->lock);
927 __blk_end_request(req, err, blk_rq_bytes(req)); 949 __blk_end_request(req, err, blk_rq_bytes(req));
928 spin_unlock_irq(&md->lock); 950 spin_unlock_irq(&md->lock);
@@ -1802,7 +1824,7 @@ static void mmc_blk_remove(struct mmc_card *card)
1802} 1824}
1803 1825
1804#ifdef CONFIG_PM 1826#ifdef CONFIG_PM
1805static int mmc_blk_suspend(struct mmc_card *card, pm_message_t state) 1827static int mmc_blk_suspend(struct mmc_card *card)
1806{ 1828{
1807 struct mmc_blk_data *part_md; 1829 struct mmc_blk_data *part_md;
1808 struct mmc_blk_data *md = mmc_get_drvdata(card); 1830 struct mmc_blk_data *md = mmc_get_drvdata(card);
diff --git a/drivers/mmc/card/queue.c b/drivers/mmc/card/queue.c
index 2517547b4366..996f8e36e23d 100644
--- a/drivers/mmc/card/queue.c
+++ b/drivers/mmc/card/queue.c
@@ -139,7 +139,7 @@ static void mmc_queue_setup_discard(struct request_queue *q,
139 139
140 queue_flag_set_unlocked(QUEUE_FLAG_DISCARD, q); 140 queue_flag_set_unlocked(QUEUE_FLAG_DISCARD, q);
141 q->limits.max_discard_sectors = max_discard; 141 q->limits.max_discard_sectors = max_discard;
142 if (card->erased_byte == 0) 142 if (card->erased_byte == 0 && !mmc_can_discard(card))
143 q->limits.discard_zeroes_data = 1; 143 q->limits.discard_zeroes_data = 1;
144 q->limits.discard_granularity = card->pref_erase << 9; 144 q->limits.discard_granularity = card->pref_erase << 9;
145 /* granularity must not be greater than max. discard */ 145 /* granularity must not be greater than max. discard */
diff --git a/drivers/mmc/core/bus.c b/drivers/mmc/core/bus.c
index 3f606068d552..c60cee92a2b2 100644
--- a/drivers/mmc/core/bus.c
+++ b/drivers/mmc/core/bus.c
@@ -122,14 +122,14 @@ static int mmc_bus_remove(struct device *dev)
122 return 0; 122 return 0;
123} 123}
124 124
125static int mmc_bus_suspend(struct device *dev, pm_message_t state) 125static int mmc_bus_suspend(struct device *dev)
126{ 126{
127 struct mmc_driver *drv = to_mmc_driver(dev->driver); 127 struct mmc_driver *drv = to_mmc_driver(dev->driver);
128 struct mmc_card *card = mmc_dev_to_card(dev); 128 struct mmc_card *card = mmc_dev_to_card(dev);
129 int ret = 0; 129 int ret = 0;
130 130
131 if (dev->driver && drv->suspend) 131 if (dev->driver && drv->suspend)
132 ret = drv->suspend(card, state); 132 ret = drv->suspend(card);
133 return ret; 133 return ret;
134} 134}
135 135
@@ -165,20 +165,14 @@ static int mmc_runtime_idle(struct device *dev)
165 return pm_runtime_suspend(dev); 165 return pm_runtime_suspend(dev);
166} 166}
167 167
168#endif /* !CONFIG_PM_RUNTIME */
169
168static const struct dev_pm_ops mmc_bus_pm_ops = { 170static const struct dev_pm_ops mmc_bus_pm_ops = {
169 .runtime_suspend = mmc_runtime_suspend, 171 SET_RUNTIME_PM_OPS(mmc_runtime_suspend, mmc_runtime_resume,
170 .runtime_resume = mmc_runtime_resume, 172 mmc_runtime_idle)
171 .runtime_idle = mmc_runtime_idle, 173 SET_SYSTEM_SLEEP_PM_OPS(mmc_bus_suspend, mmc_bus_resume)
172}; 174};
173 175
174#define MMC_PM_OPS_PTR (&mmc_bus_pm_ops)
175
176#else /* !CONFIG_PM_RUNTIME */
177
178#define MMC_PM_OPS_PTR NULL
179
180#endif /* !CONFIG_PM_RUNTIME */
181
182static struct bus_type mmc_bus_type = { 176static struct bus_type mmc_bus_type = {
183 .name = "mmc", 177 .name = "mmc",
184 .dev_attrs = mmc_dev_attrs, 178 .dev_attrs = mmc_dev_attrs,
@@ -186,9 +180,7 @@ static struct bus_type mmc_bus_type = {
186 .uevent = mmc_bus_uevent, 180 .uevent = mmc_bus_uevent,
187 .probe = mmc_bus_probe, 181 .probe = mmc_bus_probe,
188 .remove = mmc_bus_remove, 182 .remove = mmc_bus_remove,
189 .suspend = mmc_bus_suspend, 183 .pm = &mmc_bus_pm_ops,
190 .resume = mmc_bus_resume,
191 .pm = MMC_PM_OPS_PTR,
192}; 184};
193 185
194int mmc_register_bus(void) 186int mmc_register_bus(void)
diff --git a/drivers/mmc/core/cd-gpio.c b/drivers/mmc/core/cd-gpio.c
index 29de31e260dd..2c14be73254c 100644
--- a/drivers/mmc/core/cd-gpio.c
+++ b/drivers/mmc/core/cd-gpio.c
@@ -12,6 +12,7 @@
12#include <linux/gpio.h> 12#include <linux/gpio.h>
13#include <linux/interrupt.h> 13#include <linux/interrupt.h>
14#include <linux/jiffies.h> 14#include <linux/jiffies.h>
15#include <linux/mmc/cd-gpio.h>
15#include <linux/mmc/host.h> 16#include <linux/mmc/host.h>
16#include <linux/module.h> 17#include <linux/module.h>
17#include <linux/slab.h> 18#include <linux/slab.h>
diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c
index 7474c47b9c08..ba821fe70bca 100644
--- a/drivers/mmc/core/core.c
+++ b/drivers/mmc/core/core.c
@@ -1409,7 +1409,10 @@ static unsigned int mmc_mmc_erase_timeout(struct mmc_card *card,
1409{ 1409{
1410 unsigned int erase_timeout; 1410 unsigned int erase_timeout;
1411 1411
1412 if (card->ext_csd.erase_group_def & 1) { 1412 if (arg == MMC_DISCARD_ARG ||
1413 (arg == MMC_TRIM_ARG && card->ext_csd.rev >= 6)) {
1414 erase_timeout = card->ext_csd.trim_timeout;
1415 } else if (card->ext_csd.erase_group_def & 1) {
1413 /* High Capacity Erase Group Size uses HC timeouts */ 1416 /* High Capacity Erase Group Size uses HC timeouts */
1414 if (arg == MMC_TRIM_ARG) 1417 if (arg == MMC_TRIM_ARG)
1415 erase_timeout = card->ext_csd.trim_timeout; 1418 erase_timeout = card->ext_csd.trim_timeout;
@@ -1681,8 +1684,6 @@ int mmc_can_trim(struct mmc_card *card)
1681{ 1684{
1682 if (card->ext_csd.sec_feature_support & EXT_CSD_SEC_GB_CL_EN) 1685 if (card->ext_csd.sec_feature_support & EXT_CSD_SEC_GB_CL_EN)
1683 return 1; 1686 return 1;
1684 if (mmc_can_discard(card))
1685 return 1;
1686 return 0; 1687 return 0;
1687} 1688}
1688EXPORT_SYMBOL(mmc_can_trim); 1689EXPORT_SYMBOL(mmc_can_trim);
@@ -1701,6 +1702,8 @@ EXPORT_SYMBOL(mmc_can_discard);
1701 1702
1702int mmc_can_sanitize(struct mmc_card *card) 1703int mmc_can_sanitize(struct mmc_card *card)
1703{ 1704{
1705 if (!mmc_can_trim(card) && !mmc_can_erase(card))
1706 return 0;
1704 if (card->ext_csd.sec_feature_support & EXT_CSD_SEC_SANITIZE) 1707 if (card->ext_csd.sec_feature_support & EXT_CSD_SEC_SANITIZE)
1705 return 1; 1708 return 1;
1706 return 0; 1709 return 0;
@@ -2235,6 +2238,7 @@ int mmc_cache_ctrl(struct mmc_host *host, u8 enable)
2235 mmc_card_is_removable(host)) 2238 mmc_card_is_removable(host))
2236 return err; 2239 return err;
2237 2240
2241 mmc_claim_host(host);
2238 if (card && mmc_card_mmc(card) && 2242 if (card && mmc_card_mmc(card) &&
2239 (card->ext_csd.cache_size > 0)) { 2243 (card->ext_csd.cache_size > 0)) {
2240 enable = !!enable; 2244 enable = !!enable;
@@ -2252,6 +2256,7 @@ int mmc_cache_ctrl(struct mmc_host *host, u8 enable)
2252 card->ext_csd.cache_ctrl = enable; 2256 card->ext_csd.cache_ctrl = enable;
2253 } 2257 }
2254 } 2258 }
2259 mmc_release_host(host);
2255 2260
2256 return err; 2261 return err;
2257} 2262}
@@ -2269,49 +2274,32 @@ int mmc_suspend_host(struct mmc_host *host)
2269 2274
2270 cancel_delayed_work(&host->detect); 2275 cancel_delayed_work(&host->detect);
2271 mmc_flush_scheduled_work(); 2276 mmc_flush_scheduled_work();
2272 if (mmc_try_claim_host(host)) {
2273 err = mmc_cache_ctrl(host, 0);
2274 mmc_release_host(host);
2275 } else {
2276 err = -EBUSY;
2277 }
2278 2277
2278 err = mmc_cache_ctrl(host, 0);
2279 if (err) 2279 if (err)
2280 goto out; 2280 goto out;
2281 2281
2282 mmc_bus_get(host); 2282 mmc_bus_get(host);
2283 if (host->bus_ops && !host->bus_dead) { 2283 if (host->bus_ops && !host->bus_dead) {
2284 2284
2285 /* 2285 if (host->bus_ops->suspend)
2286 * A long response time is not acceptable for device drivers 2286 err = host->bus_ops->suspend(host);
2287 * when doing suspend. Prevent mmc_claim_host in the suspend
2288 * sequence, to potentially wait "forever" by trying to
2289 * pre-claim the host.
2290 */
2291 if (mmc_try_claim_host(host)) {
2292 if (host->bus_ops->suspend) {
2293 err = host->bus_ops->suspend(host);
2294 }
2295 mmc_release_host(host);
2296 2287
2297 if (err == -ENOSYS || !host->bus_ops->resume) { 2288 if (err == -ENOSYS || !host->bus_ops->resume) {
2298 /* 2289 /*
2299 * We simply "remove" the card in this case. 2290 * We simply "remove" the card in this case.
2300 * It will be redetected on resume. (Calling 2291 * It will be redetected on resume. (Calling
2301 * bus_ops->remove() with a claimed host can 2292 * bus_ops->remove() with a claimed host can
2302 * deadlock.) 2293 * deadlock.)
2303 */ 2294 */
2304 if (host->bus_ops->remove) 2295 if (host->bus_ops->remove)
2305 host->bus_ops->remove(host); 2296 host->bus_ops->remove(host);
2306 mmc_claim_host(host); 2297 mmc_claim_host(host);
2307 mmc_detach_bus(host); 2298 mmc_detach_bus(host);
2308 mmc_power_off(host); 2299 mmc_power_off(host);
2309 mmc_release_host(host); 2300 mmc_release_host(host);
2310 host->pm_flags = 0; 2301 host->pm_flags = 0;
2311 err = 0; 2302 err = 0;
2312 }
2313 } else {
2314 err = -EBUSY;
2315 } 2303 }
2316 } 2304 }
2317 mmc_bus_put(host); 2305 mmc_bus_put(host);
diff --git a/drivers/mmc/host/dw_mmc.c b/drivers/mmc/host/dw_mmc.c
index bf3c9b456aaf..ab3fc4617107 100644
--- a/drivers/mmc/host/dw_mmc.c
+++ b/drivers/mmc/host/dw_mmc.c
@@ -526,8 +526,10 @@ static int dw_mci_submit_data_dma(struct dw_mci *host, struct mmc_data *data)
526 return -ENODEV; 526 return -ENODEV;
527 527
528 sg_len = dw_mci_pre_dma_transfer(host, data, 0); 528 sg_len = dw_mci_pre_dma_transfer(host, data, 0);
529 if (sg_len < 0) 529 if (sg_len < 0) {
530 host->dma_ops->stop(host);
530 return sg_len; 531 return sg_len;
532 }
531 533
532 host->using_dma = 1; 534 host->using_dma = 1;
533 535
@@ -1879,7 +1881,8 @@ static void dw_mci_init_dma(struct dw_mci *host)
1879 if (!host->dma_ops) 1881 if (!host->dma_ops)
1880 goto no_dma; 1882 goto no_dma;
1881 1883
1882 if (host->dma_ops->init) { 1884 if (host->dma_ops->init && host->dma_ops->start &&
1885 host->dma_ops->stop && host->dma_ops->cleanup) {
1883 if (host->dma_ops->init(host)) { 1886 if (host->dma_ops->init(host)) {
1884 dev_err(&host->dev, "%s: Unable to initialize " 1887 dev_err(&host->dev, "%s: Unable to initialize "
1885 "DMA Controller.\n", __func__); 1888 "DMA Controller.\n", __func__);
diff --git a/drivers/mmc/host/mxs-mmc.c b/drivers/mmc/host/mxs-mmc.c
index b0f2ef988188..e3f5af96ab87 100644
--- a/drivers/mmc/host/mxs-mmc.c
+++ b/drivers/mmc/host/mxs-mmc.c
@@ -363,6 +363,7 @@ static void mxs_mmc_bc(struct mxs_mmc_host *host)
363 goto out; 363 goto out;
364 364
365 dmaengine_submit(desc); 365 dmaengine_submit(desc);
366 dma_async_issue_pending(host->dmach);
366 return; 367 return;
367 368
368out: 369out:
@@ -403,6 +404,7 @@ static void mxs_mmc_ac(struct mxs_mmc_host *host)
403 goto out; 404 goto out;
404 405
405 dmaengine_submit(desc); 406 dmaengine_submit(desc);
407 dma_async_issue_pending(host->dmach);
406 return; 408 return;
407 409
408out: 410out:
@@ -531,6 +533,7 @@ static void mxs_mmc_adtc(struct mxs_mmc_host *host)
531 goto out; 533 goto out;
532 534
533 dmaengine_submit(desc); 535 dmaengine_submit(desc);
536 dma_async_issue_pending(host->dmach);
534 return; 537 return;
535out: 538out:
536 dev_warn(mmc_dev(host->mmc), 539 dev_warn(mmc_dev(host->mmc),
diff --git a/drivers/mmc/host/omap_hsmmc.c b/drivers/mmc/host/omap_hsmmc.c
index 5c2b1c10af9c..56d4499d4388 100644
--- a/drivers/mmc/host/omap_hsmmc.c
+++ b/drivers/mmc/host/omap_hsmmc.c
@@ -249,7 +249,7 @@ static int omap_hsmmc_set_power(struct device *dev, int slot, int power_on,
249 * the pbias cell programming support is still missing when 249 * the pbias cell programming support is still missing when
250 * booting with Device tree 250 * booting with Device tree
251 */ 251 */
252 if (of_have_populated_dt() && !vdd) 252 if (dev->of_node && !vdd)
253 return 0; 253 return 0;
254 254
255 if (mmc_slot(host).before_set_reg) 255 if (mmc_slot(host).before_set_reg)
@@ -1549,7 +1549,7 @@ static void omap_hsmmc_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
1549 * can't be allowed when booting with device 1549 * can't be allowed when booting with device
1550 * tree. 1550 * tree.
1551 */ 1551 */
1552 (!of_have_populated_dt())) { 1552 !host->dev->of_node) {
1553 /* 1553 /*
1554 * The mmc_select_voltage fn of the core does 1554 * The mmc_select_voltage fn of the core does
1555 * not seem to set the power_mode to 1555 * not seem to set the power_mode to
@@ -1741,7 +1741,7 @@ static const struct of_device_id omap_mmc_of_match[] = {
1741 .data = &omap4_reg_offset, 1741 .data = &omap4_reg_offset,
1742 }, 1742 },
1743 {}, 1743 {},
1744} 1744};
1745MODULE_DEVICE_TABLE(of, omap_mmc_of_match); 1745MODULE_DEVICE_TABLE(of, omap_mmc_of_match);
1746 1746
1747static struct omap_mmc_platform_data *of_get_hsmmc_pdata(struct device *dev) 1747static struct omap_mmc_platform_data *of_get_hsmmc_pdata(struct device *dev)
diff --git a/drivers/mmc/host/sdhci-esdhc-imx.c b/drivers/mmc/host/sdhci-esdhc-imx.c
index 6193a0d7bde5..8abdaf6697a8 100644
--- a/drivers/mmc/host/sdhci-esdhc-imx.c
+++ b/drivers/mmc/host/sdhci-esdhc-imx.c
@@ -467,8 +467,7 @@ static int __devinit sdhci_esdhc_imx_probe(struct platform_device *pdev)
467 clk_prepare_enable(clk); 467 clk_prepare_enable(clk);
468 pltfm_host->clk = clk; 468 pltfm_host->clk = clk;
469 469
470 if (!is_imx25_esdhc(imx_data)) 470 host->quirks |= SDHCI_QUIRK_BROKEN_TIMEOUT_VAL;
471 host->quirks |= SDHCI_QUIRK_BROKEN_TIMEOUT_VAL;
472 471
473 if (is_imx25_esdhc(imx_data) || is_imx35_esdhc(imx_data)) 472 if (is_imx25_esdhc(imx_data) || is_imx35_esdhc(imx_data))
474 /* Fix errata ENGcm07207 present on i.MX25 and i.MX35 */ 473 /* Fix errata ENGcm07207 present on i.MX25 and i.MX35 */
diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
index 9aa77f3f04a8..ccefdebeff14 100644
--- a/drivers/mmc/host/sdhci.c
+++ b/drivers/mmc/host/sdhci.c
@@ -147,7 +147,7 @@ static void sdhci_set_card_detection(struct sdhci_host *host, bool enable)
147 u32 present, irqs; 147 u32 present, irqs;
148 148
149 if ((host->quirks & SDHCI_QUIRK_BROKEN_CARD_DETECTION) || 149 if ((host->quirks & SDHCI_QUIRK_BROKEN_CARD_DETECTION) ||
150 !mmc_card_is_removable(host->mmc)) 150 (host->mmc->caps & MMC_CAP_NONREMOVABLE))
151 return; 151 return;
152 152
153 present = sdhci_readl(host, SDHCI_PRESENT_STATE) & 153 present = sdhci_readl(host, SDHCI_PRESENT_STATE) &
diff --git a/drivers/mtd/mtdchar.c b/drivers/mtd/mtdchar.c
index 94eb05b1afdf..58fc65f5c817 100644
--- a/drivers/mtd/mtdchar.c
+++ b/drivers/mtd/mtdchar.c
@@ -106,16 +106,14 @@ static int mtdchar_open(struct inode *inode, struct file *file)
106 } 106 }
107 107
108 if (mtd->type == MTD_ABSENT) { 108 if (mtd->type == MTD_ABSENT) {
109 put_mtd_device(mtd);
110 ret = -ENODEV; 109 ret = -ENODEV;
111 goto out; 110 goto out1;
112 } 111 }
113 112
114 mtd_ino = iget_locked(mnt->mnt_sb, devnum); 113 mtd_ino = iget_locked(mnt->mnt_sb, devnum);
115 if (!mtd_ino) { 114 if (!mtd_ino) {
116 put_mtd_device(mtd);
117 ret = -ENOMEM; 115 ret = -ENOMEM;
118 goto out; 116 goto out1;
119 } 117 }
120 if (mtd_ino->i_state & I_NEW) { 118 if (mtd_ino->i_state & I_NEW) {
121 mtd_ino->i_private = mtd; 119 mtd_ino->i_private = mtd;
@@ -127,23 +125,25 @@ static int mtdchar_open(struct inode *inode, struct file *file)
127 125
128 /* You can't open it RW if it's not a writeable device */ 126 /* You can't open it RW if it's not a writeable device */
129 if ((file->f_mode & FMODE_WRITE) && !(mtd->flags & MTD_WRITEABLE)) { 127 if ((file->f_mode & FMODE_WRITE) && !(mtd->flags & MTD_WRITEABLE)) {
130 iput(mtd_ino);
131 put_mtd_device(mtd);
132 ret = -EACCES; 128 ret = -EACCES;
133 goto out; 129 goto out2;
134 } 130 }
135 131
136 mfi = kzalloc(sizeof(*mfi), GFP_KERNEL); 132 mfi = kzalloc(sizeof(*mfi), GFP_KERNEL);
137 if (!mfi) { 133 if (!mfi) {
138 iput(mtd_ino);
139 put_mtd_device(mtd);
140 ret = -ENOMEM; 134 ret = -ENOMEM;
141 goto out; 135 goto out2;
142 } 136 }
143 mfi->ino = mtd_ino; 137 mfi->ino = mtd_ino;
144 mfi->mtd = mtd; 138 mfi->mtd = mtd;
145 file->private_data = mfi; 139 file->private_data = mfi;
140 mutex_unlock(&mtd_mutex);
141 return 0;
146 142
143out2:
144 iput(mtd_ino);
145out1:
146 put_mtd_device(mtd);
147out: 147out:
148 mutex_unlock(&mtd_mutex); 148 mutex_unlock(&mtd_mutex);
149 simple_release_fs(&mnt, &count); 149 simple_release_fs(&mnt, &count);
diff --git a/drivers/mtd/nand/gpmi-nand/gpmi-nand.c b/drivers/mtd/nand/gpmi-nand/gpmi-nand.c
index 75b1dde16358..9ec51cec2e14 100644
--- a/drivers/mtd/nand/gpmi-nand/gpmi-nand.c
+++ b/drivers/mtd/nand/gpmi-nand/gpmi-nand.c
@@ -266,6 +266,7 @@ int start_dma_without_bch_irq(struct gpmi_nand_data *this,
266 desc->callback = dma_irq_callback; 266 desc->callback = dma_irq_callback;
267 desc->callback_param = this; 267 desc->callback_param = this;
268 dmaengine_submit(desc); 268 dmaengine_submit(desc);
269 dma_async_issue_pending(get_dma_chan(this));
269 270
270 /* Wait for the interrupt from the DMA block. */ 271 /* Wait for the interrupt from the DMA block. */
271 err = wait_for_completion_timeout(dma_c, msecs_to_jiffies(1000)); 272 err = wait_for_completion_timeout(dma_c, msecs_to_jiffies(1000));
diff --git a/drivers/net/arcnet/arc-rimi.c b/drivers/net/arcnet/arc-rimi.c
index 25197b698dd6..b8b4c7ba884f 100644
--- a/drivers/net/arcnet/arc-rimi.c
+++ b/drivers/net/arcnet/arc-rimi.c
@@ -89,16 +89,16 @@ static int __init arcrimi_probe(struct net_device *dev)
89 BUGLVL(D_NORMAL) printk(VERSION); 89 BUGLVL(D_NORMAL) printk(VERSION);
90 BUGLVL(D_NORMAL) printk("E-mail me if you actually test the RIM I driver, please!\n"); 90 BUGLVL(D_NORMAL) printk("E-mail me if you actually test the RIM I driver, please!\n");
91 91
92 BUGMSG(D_NORMAL, "Given: node %02Xh, shmem %lXh, irq %d\n", 92 BUGLVL(D_NORMAL) printk("Given: node %02Xh, shmem %lXh, irq %d\n",
93 dev->dev_addr[0], dev->mem_start, dev->irq); 93 dev->dev_addr[0], dev->mem_start, dev->irq);
94 94
95 if (dev->mem_start <= 0 || dev->irq <= 0) { 95 if (dev->mem_start <= 0 || dev->irq <= 0) {
96 BUGMSG(D_NORMAL, "No autoprobe for RIM I; you " 96 BUGLVL(D_NORMAL) printk("No autoprobe for RIM I; you "
97 "must specify the shmem and irq!\n"); 97 "must specify the shmem and irq!\n");
98 return -ENODEV; 98 return -ENODEV;
99 } 99 }
100 if (dev->dev_addr[0] == 0) { 100 if (dev->dev_addr[0] == 0) {
101 BUGMSG(D_NORMAL, "You need to specify your card's station " 101 BUGLVL(D_NORMAL) printk("You need to specify your card's station "
102 "ID!\n"); 102 "ID!\n");
103 return -ENODEV; 103 return -ENODEV;
104 } 104 }
@@ -109,7 +109,7 @@ static int __init arcrimi_probe(struct net_device *dev)
109 * will be taken. 109 * will be taken.
110 */ 110 */
111 if (!request_mem_region(dev->mem_start, MIRROR_SIZE, "arcnet (90xx)")) { 111 if (!request_mem_region(dev->mem_start, MIRROR_SIZE, "arcnet (90xx)")) {
112 BUGMSG(D_NORMAL, "Card memory already allocated\n"); 112 BUGLVL(D_NORMAL) printk("Card memory already allocated\n");
113 return -ENODEV; 113 return -ENODEV;
114 } 114 }
115 return arcrimi_found(dev); 115 return arcrimi_found(dev);
diff --git a/drivers/net/caif/caif_hsi.c b/drivers/net/caif/caif_hsi.c
index 9a66e2a910ae..9c1c8cd5223f 100644
--- a/drivers/net/caif/caif_hsi.c
+++ b/drivers/net/caif/caif_hsi.c
@@ -744,14 +744,14 @@ static void cfhsi_wake_up(struct work_struct *work)
744 size_t fifo_occupancy = 0; 744 size_t fifo_occupancy = 0;
745 745
746 /* Wakeup timeout */ 746 /* Wakeup timeout */
747 dev_err(&cfhsi->ndev->dev, "%s: Timeout.\n", 747 dev_dbg(&cfhsi->ndev->dev, "%s: Timeout.\n",
748 __func__); 748 __func__);
749 749
750 /* Check FIFO to check if modem has sent something. */ 750 /* Check FIFO to check if modem has sent something. */
751 WARN_ON(cfhsi->dev->cfhsi_fifo_occupancy(cfhsi->dev, 751 WARN_ON(cfhsi->dev->cfhsi_fifo_occupancy(cfhsi->dev,
752 &fifo_occupancy)); 752 &fifo_occupancy));
753 753
754 dev_err(&cfhsi->ndev->dev, "%s: Bytes in FIFO: %u.\n", 754 dev_dbg(&cfhsi->ndev->dev, "%s: Bytes in FIFO: %u.\n",
755 __func__, (unsigned) fifo_occupancy); 755 __func__, (unsigned) fifo_occupancy);
756 756
757 /* Check if we misssed the interrupt. */ 757 /* Check if we misssed the interrupt. */
@@ -1210,7 +1210,7 @@ int cfhsi_probe(struct platform_device *pdev)
1210 1210
1211static void cfhsi_shutdown(struct cfhsi *cfhsi) 1211static void cfhsi_shutdown(struct cfhsi *cfhsi)
1212{ 1212{
1213 u8 *tx_buf, *rx_buf; 1213 u8 *tx_buf, *rx_buf, *flip_buf;
1214 1214
1215 /* Stop TXing */ 1215 /* Stop TXing */
1216 netif_tx_stop_all_queues(cfhsi->ndev); 1216 netif_tx_stop_all_queues(cfhsi->ndev);
@@ -1234,7 +1234,7 @@ static void cfhsi_shutdown(struct cfhsi *cfhsi)
1234 /* Store bufferes: will be freed later. */ 1234 /* Store bufferes: will be freed later. */
1235 tx_buf = cfhsi->tx_buf; 1235 tx_buf = cfhsi->tx_buf;
1236 rx_buf = cfhsi->rx_buf; 1236 rx_buf = cfhsi->rx_buf;
1237 1237 flip_buf = cfhsi->rx_flip_buf;
1238 /* Flush transmit queues. */ 1238 /* Flush transmit queues. */
1239 cfhsi_abort_tx(cfhsi); 1239 cfhsi_abort_tx(cfhsi);
1240 1240
@@ -1247,6 +1247,7 @@ static void cfhsi_shutdown(struct cfhsi *cfhsi)
1247 /* Free buffers. */ 1247 /* Free buffers. */
1248 kfree(tx_buf); 1248 kfree(tx_buf);
1249 kfree(rx_buf); 1249 kfree(rx_buf);
1250 kfree(flip_buf);
1250} 1251}
1251 1252
1252int cfhsi_remove(struct platform_device *pdev) 1253int cfhsi_remove(struct platform_device *pdev)
diff --git a/drivers/net/can/usb/peak_usb/pcan_usb_pro.c b/drivers/net/can/usb/peak_usb/pcan_usb_pro.c
index 5234586dff15..629c4ba5d49d 100644
--- a/drivers/net/can/usb/peak_usb/pcan_usb_pro.c
+++ b/drivers/net/can/usb/peak_usb/pcan_usb_pro.c
@@ -875,6 +875,7 @@ static int pcan_usb_pro_init(struct peak_usb_device *dev)
875 PCAN_USBPRO_INFO_FW, 875 PCAN_USBPRO_INFO_FW,
876 &fi, sizeof(fi)); 876 &fi, sizeof(fi));
877 if (err) { 877 if (err) {
878 kfree(usb_if);
878 dev_err(dev->netdev->dev.parent, 879 dev_err(dev->netdev->dev.parent,
879 "unable to read %s firmware info (err %d)\n", 880 "unable to read %s firmware info (err %d)\n",
880 pcan_usb_pro.name, err); 881 pcan_usb_pro.name, err);
@@ -885,6 +886,7 @@ static int pcan_usb_pro_init(struct peak_usb_device *dev)
885 PCAN_USBPRO_INFO_BL, 886 PCAN_USBPRO_INFO_BL,
886 &bi, sizeof(bi)); 887 &bi, sizeof(bi));
887 if (err) { 888 if (err) {
889 kfree(usb_if);
888 dev_err(dev->netdev->dev.parent, 890 dev_err(dev->netdev->dev.parent,
889 "unable to read %s bootloader info (err %d)\n", 891 "unable to read %s bootloader info (err %d)\n",
890 pcan_usb_pro.name, err); 892 pcan_usb_pro.name, err);
diff --git a/drivers/net/dummy.c b/drivers/net/dummy.c
index d5c6d92f1ee7..442d91a2747b 100644
--- a/drivers/net/dummy.c
+++ b/drivers/net/dummy.c
@@ -107,14 +107,14 @@ static int dummy_dev_init(struct net_device *dev)
107 return 0; 107 return 0;
108} 108}
109 109
110static void dummy_dev_free(struct net_device *dev) 110static void dummy_dev_uninit(struct net_device *dev)
111{ 111{
112 free_percpu(dev->dstats); 112 free_percpu(dev->dstats);
113 free_netdev(dev);
114} 113}
115 114
116static const struct net_device_ops dummy_netdev_ops = { 115static const struct net_device_ops dummy_netdev_ops = {
117 .ndo_init = dummy_dev_init, 116 .ndo_init = dummy_dev_init,
117 .ndo_uninit = dummy_dev_uninit,
118 .ndo_start_xmit = dummy_xmit, 118 .ndo_start_xmit = dummy_xmit,
119 .ndo_validate_addr = eth_validate_addr, 119 .ndo_validate_addr = eth_validate_addr,
120 .ndo_set_rx_mode = set_multicast_list, 120 .ndo_set_rx_mode = set_multicast_list,
@@ -128,7 +128,7 @@ static void dummy_setup(struct net_device *dev)
128 128
129 /* Initialize the device structure. */ 129 /* Initialize the device structure. */
130 dev->netdev_ops = &dummy_netdev_ops; 130 dev->netdev_ops = &dummy_netdev_ops;
131 dev->destructor = dummy_dev_free; 131 dev->destructor = free_netdev;
132 132
133 /* Fill in device structure with ethernet-generic values. */ 133 /* Fill in device structure with ethernet-generic values. */
134 dev->tx_queue_len = 0; 134 dev->tx_queue_len = 0;
diff --git a/drivers/net/ethernet/atheros/atlx/atl1.c b/drivers/net/ethernet/atheros/atlx/atl1.c
index 40ac41436549..c926857e8205 100644
--- a/drivers/net/ethernet/atheros/atlx/atl1.c
+++ b/drivers/net/ethernet/atheros/atlx/atl1.c
@@ -2476,7 +2476,7 @@ static irqreturn_t atl1_intr(int irq, void *data)
2476 "pcie phy link down %x\n", status); 2476 "pcie phy link down %x\n", status);
2477 if (netif_running(adapter->netdev)) { /* reset MAC */ 2477 if (netif_running(adapter->netdev)) { /* reset MAC */
2478 iowrite32(0, adapter->hw.hw_addr + REG_IMR); 2478 iowrite32(0, adapter->hw.hw_addr + REG_IMR);
2479 schedule_work(&adapter->pcie_dma_to_rst_task); 2479 schedule_work(&adapter->reset_dev_task);
2480 return IRQ_HANDLED; 2480 return IRQ_HANDLED;
2481 } 2481 }
2482 } 2482 }
@@ -2488,7 +2488,7 @@ static irqreturn_t atl1_intr(int irq, void *data)
2488 "pcie DMA r/w error (status = 0x%x)\n", 2488 "pcie DMA r/w error (status = 0x%x)\n",
2489 status); 2489 status);
2490 iowrite32(0, adapter->hw.hw_addr + REG_IMR); 2490 iowrite32(0, adapter->hw.hw_addr + REG_IMR);
2491 schedule_work(&adapter->pcie_dma_to_rst_task); 2491 schedule_work(&adapter->reset_dev_task);
2492 return IRQ_HANDLED; 2492 return IRQ_HANDLED;
2493 } 2493 }
2494 2494
@@ -2633,10 +2633,10 @@ static void atl1_down(struct atl1_adapter *adapter)
2633 atl1_clean_rx_ring(adapter); 2633 atl1_clean_rx_ring(adapter);
2634} 2634}
2635 2635
2636static void atl1_tx_timeout_task(struct work_struct *work) 2636static void atl1_reset_dev_task(struct work_struct *work)
2637{ 2637{
2638 struct atl1_adapter *adapter = 2638 struct atl1_adapter *adapter =
2639 container_of(work, struct atl1_adapter, tx_timeout_task); 2639 container_of(work, struct atl1_adapter, reset_dev_task);
2640 struct net_device *netdev = adapter->netdev; 2640 struct net_device *netdev = adapter->netdev;
2641 2641
2642 netif_device_detach(netdev); 2642 netif_device_detach(netdev);
@@ -3038,12 +3038,10 @@ static int __devinit atl1_probe(struct pci_dev *pdev,
3038 (unsigned long)adapter); 3038 (unsigned long)adapter);
3039 adapter->phy_timer_pending = false; 3039 adapter->phy_timer_pending = false;
3040 3040
3041 INIT_WORK(&adapter->tx_timeout_task, atl1_tx_timeout_task); 3041 INIT_WORK(&adapter->reset_dev_task, atl1_reset_dev_task);
3042 3042
3043 INIT_WORK(&adapter->link_chg_task, atlx_link_chg_task); 3043 INIT_WORK(&adapter->link_chg_task, atlx_link_chg_task);
3044 3044
3045 INIT_WORK(&adapter->pcie_dma_to_rst_task, atl1_tx_timeout_task);
3046
3047 err = register_netdev(netdev); 3045 err = register_netdev(netdev);
3048 if (err) 3046 if (err)
3049 goto err_common; 3047 goto err_common;
diff --git a/drivers/net/ethernet/atheros/atlx/atl1.h b/drivers/net/ethernet/atheros/atlx/atl1.h
index 109d6da8be97..e04bf4d71e46 100644
--- a/drivers/net/ethernet/atheros/atlx/atl1.h
+++ b/drivers/net/ethernet/atheros/atlx/atl1.h
@@ -758,9 +758,8 @@ struct atl1_adapter {
758 u16 link_speed; 758 u16 link_speed;
759 u16 link_duplex; 759 u16 link_duplex;
760 spinlock_t lock; 760 spinlock_t lock;
761 struct work_struct tx_timeout_task; 761 struct work_struct reset_dev_task;
762 struct work_struct link_chg_task; 762 struct work_struct link_chg_task;
763 struct work_struct pcie_dma_to_rst_task;
764 763
765 struct timer_list phy_config_timer; 764 struct timer_list phy_config_timer;
766 bool phy_timer_pending; 765 bool phy_timer_pending;
diff --git a/drivers/net/ethernet/atheros/atlx/atlx.c b/drivers/net/ethernet/atheros/atlx/atlx.c
index 3cd8837236dc..c9e9dc57986c 100644
--- a/drivers/net/ethernet/atheros/atlx/atlx.c
+++ b/drivers/net/ethernet/atheros/atlx/atlx.c
@@ -194,7 +194,7 @@ static void atlx_tx_timeout(struct net_device *netdev)
194{ 194{
195 struct atlx_adapter *adapter = netdev_priv(netdev); 195 struct atlx_adapter *adapter = netdev_priv(netdev);
196 /* Do the reset outside of interrupt context */ 196 /* Do the reset outside of interrupt context */
197 schedule_work(&adapter->tx_timeout_task); 197 schedule_work(&adapter->reset_dev_task);
198} 198}
199 199
200/* 200/*
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_link.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_link.c
index ad95324dc042..64392ec410a3 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_link.c
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_link.c
@@ -942,6 +942,12 @@ static int bnx2x_ets_e3b0_sp_pri_to_cos_set(const struct link_params *params,
942 const u8 max_num_of_cos = (port) ? DCBX_E3B0_MAX_NUM_COS_PORT1 : 942 const u8 max_num_of_cos = (port) ? DCBX_E3B0_MAX_NUM_COS_PORT1 :
943 DCBX_E3B0_MAX_NUM_COS_PORT0; 943 DCBX_E3B0_MAX_NUM_COS_PORT0;
944 944
945 if (pri >= max_num_of_cos) {
946 DP(NETIF_MSG_LINK, "bnx2x_ets_e3b0_sp_pri_to_cos_set invalid "
947 "parameter Illegal strict priority\n");
948 return -EINVAL;
949 }
950
945 if (sp_pri_to_cos[pri] != DCBX_INVALID_COS) { 951 if (sp_pri_to_cos[pri] != DCBX_INVALID_COS) {
946 DP(NETIF_MSG_LINK, "bnx2x_ets_e3b0_sp_pri_to_cos_set invalid " 952 DP(NETIF_MSG_LINK, "bnx2x_ets_e3b0_sp_pri_to_cos_set invalid "
947 "parameter There can't be two COS's with " 953 "parameter There can't be two COS's with "
@@ -949,12 +955,6 @@ static int bnx2x_ets_e3b0_sp_pri_to_cos_set(const struct link_params *params,
949 return -EINVAL; 955 return -EINVAL;
950 } 956 }
951 957
952 if (pri > max_num_of_cos) {
953 DP(NETIF_MSG_LINK, "bnx2x_ets_e3b0_sp_pri_to_cos_set invalid "
954 "parameter Illegal strict priority\n");
955 return -EINVAL;
956 }
957
958 sp_pri_to_cos[pri] = cos_entry; 958 sp_pri_to_cos[pri] = cos_entry;
959 return 0; 959 return 0;
960 960
diff --git a/drivers/net/ethernet/intel/e1000e/ich8lan.c b/drivers/net/ethernet/intel/e1000e/ich8lan.c
index 64c76443a7aa..b461c24945e3 100644
--- a/drivers/net/ethernet/intel/e1000e/ich8lan.c
+++ b/drivers/net/ethernet/intel/e1000e/ich8lan.c
@@ -1310,10 +1310,6 @@ static s32 e1000_oem_bits_config_ich8lan(struct e1000_hw *hw, bool d0_state)
1310 1310
1311 if (mac_reg & E1000_PHY_CTRL_D0A_LPLU) 1311 if (mac_reg & E1000_PHY_CTRL_D0A_LPLU)
1312 oem_reg |= HV_OEM_BITS_LPLU; 1312 oem_reg |= HV_OEM_BITS_LPLU;
1313
1314 /* Set Restart auto-neg to activate the bits */
1315 if (!hw->phy.ops.check_reset_block(hw))
1316 oem_reg |= HV_OEM_BITS_RESTART_AN;
1317 } else { 1313 } else {
1318 if (mac_reg & (E1000_PHY_CTRL_GBE_DISABLE | 1314 if (mac_reg & (E1000_PHY_CTRL_GBE_DISABLE |
1319 E1000_PHY_CTRL_NOND0A_GBE_DISABLE)) 1315 E1000_PHY_CTRL_NOND0A_GBE_DISABLE))
@@ -1324,6 +1320,11 @@ static s32 e1000_oem_bits_config_ich8lan(struct e1000_hw *hw, bool d0_state)
1324 oem_reg |= HV_OEM_BITS_LPLU; 1320 oem_reg |= HV_OEM_BITS_LPLU;
1325 } 1321 }
1326 1322
1323 /* Set Restart auto-neg to activate the bits */
1324 if ((d0_state || (hw->mac.type != e1000_pchlan)) &&
1325 !hw->phy.ops.check_reset_block(hw))
1326 oem_reg |= HV_OEM_BITS_RESTART_AN;
1327
1327 ret_val = hw->phy.ops.write_reg_locked(hw, HV_OEM_BITS, oem_reg); 1328 ret_val = hw->phy.ops.write_reg_locked(hw, HV_OEM_BITS, oem_reg);
1328 1329
1329release: 1330release:
@@ -3682,7 +3683,11 @@ void e1000_suspend_workarounds_ich8lan(struct e1000_hw *hw)
3682 3683
3683 if (hw->mac.type >= e1000_pchlan) { 3684 if (hw->mac.type >= e1000_pchlan) {
3684 e1000_oem_bits_config_ich8lan(hw, false); 3685 e1000_oem_bits_config_ich8lan(hw, false);
3685 e1000_phy_hw_reset_ich8lan(hw); 3686
3687 /* Reset PHY to activate OEM bits on 82577/8 */
3688 if (hw->mac.type == e1000_pchlan)
3689 e1000e_phy_hw_reset_generic(hw);
3690
3686 ret_val = hw->phy.ops.acquire(hw); 3691 ret_val = hw->phy.ops.acquire(hw);
3687 if (ret_val) 3692 if (ret_val)
3688 return; 3693 return;
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_lib.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_lib.c
index 027d7a75be39..ed1b47dc0834 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_lib.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_lib.c
@@ -622,6 +622,16 @@ static int ixgbe_alloc_q_vector(struct ixgbe_adapter *adapter, int v_idx,
622 if (adapter->hw.mac.type == ixgbe_mac_82599EB) 622 if (adapter->hw.mac.type == ixgbe_mac_82599EB)
623 set_bit(__IXGBE_RX_CSUM_UDP_ZERO_ERR, &ring->state); 623 set_bit(__IXGBE_RX_CSUM_UDP_ZERO_ERR, &ring->state);
624 624
625#ifdef IXGBE_FCOE
626 if (adapter->netdev->features & NETIF_F_FCOE_MTU) {
627 struct ixgbe_ring_feature *f;
628 f = &adapter->ring_feature[RING_F_FCOE];
629 if ((rxr_idx >= f->mask) &&
630 (rxr_idx < f->mask + f->indices))
631 set_bit(__IXGBE_RX_FCOE_BUFSZ, &ring->state);
632 }
633
634#endif /* IXGBE_FCOE */
625 /* apply Rx specific ring traits */ 635 /* apply Rx specific ring traits */
626 ring->count = adapter->rx_ring_count; 636 ring->count = adapter->rx_ring_count;
627 ring->queue_index = rxr_idx; 637 ring->queue_index = rxr_idx;
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
index 3e26b1f9ac75..a7f3cd872caf 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
@@ -3154,14 +3154,6 @@ static void ixgbe_set_rx_buffer_len(struct ixgbe_adapter *adapter)
3154 set_ring_rsc_enabled(rx_ring); 3154 set_ring_rsc_enabled(rx_ring);
3155 else 3155 else
3156 clear_ring_rsc_enabled(rx_ring); 3156 clear_ring_rsc_enabled(rx_ring);
3157#ifdef IXGBE_FCOE
3158 if (netdev->features & NETIF_F_FCOE_MTU) {
3159 struct ixgbe_ring_feature *f;
3160 f = &adapter->ring_feature[RING_F_FCOE];
3161 if ((i >= f->mask) && (i < f->mask + f->indices))
3162 set_bit(__IXGBE_RX_FCOE_BUFSZ, &rx_ring->state);
3163 }
3164#endif /* IXGBE_FCOE */
3165 } 3157 }
3166} 3158}
3167 3159
@@ -4836,7 +4828,9 @@ static int ixgbe_resume(struct pci_dev *pdev)
4836 4828
4837 pci_wake_from_d3(pdev, false); 4829 pci_wake_from_d3(pdev, false);
4838 4830
4831 rtnl_lock();
4839 err = ixgbe_init_interrupt_scheme(adapter); 4832 err = ixgbe_init_interrupt_scheme(adapter);
4833 rtnl_unlock();
4840 if (err) { 4834 if (err) {
4841 e_dev_err("Cannot initialize interrupts for device\n"); 4835 e_dev_err("Cannot initialize interrupts for device\n");
4842 return err; 4836 return err;
@@ -4893,6 +4887,16 @@ static int __ixgbe_shutdown(struct pci_dev *pdev, bool *enable_wake)
4893 if (wufc) { 4887 if (wufc) {
4894 ixgbe_set_rx_mode(netdev); 4888 ixgbe_set_rx_mode(netdev);
4895 4889
4890 /*
4891 * enable the optics for both mult-speed fiber and
4892 * 82599 SFP+ fiber as we can WoL.
4893 */
4894 if (hw->mac.ops.enable_tx_laser &&
4895 (hw->phy.multispeed_fiber ||
4896 (hw->mac.ops.get_media_type(hw) == ixgbe_media_type_fiber &&
4897 hw->mac.type == ixgbe_mac_82599EB)))
4898 hw->mac.ops.enable_tx_laser(hw);
4899
4896 /* turn on all-multi mode if wake on multicast is enabled */ 4900 /* turn on all-multi mode if wake on multicast is enabled */
4897 if (wufc & IXGBE_WUFC_MC) { 4901 if (wufc & IXGBE_WUFC_MC) {
4898 fctrl = IXGBE_READ_REG(hw, IXGBE_FCTRL); 4902 fctrl = IXGBE_READ_REG(hw, IXGBE_FCTRL);
diff --git a/drivers/net/ethernet/micrel/ks8851.c b/drivers/net/ethernet/micrel/ks8851.c
index c722aa607d07..f8dda009d3c0 100644
--- a/drivers/net/ethernet/micrel/ks8851.c
+++ b/drivers/net/ethernet/micrel/ks8851.c
@@ -889,16 +889,17 @@ static int ks8851_net_stop(struct net_device *dev)
889 netif_stop_queue(dev); 889 netif_stop_queue(dev);
890 890
891 mutex_lock(&ks->lock); 891 mutex_lock(&ks->lock);
892 /* turn off the IRQs and ack any outstanding */
893 ks8851_wrreg16(ks, KS_IER, 0x0000);
894 ks8851_wrreg16(ks, KS_ISR, 0xffff);
895 mutex_unlock(&ks->lock);
892 896
893 /* stop any outstanding work */ 897 /* stop any outstanding work */
894 flush_work(&ks->irq_work); 898 flush_work(&ks->irq_work);
895 flush_work(&ks->tx_work); 899 flush_work(&ks->tx_work);
896 flush_work(&ks->rxctrl_work); 900 flush_work(&ks->rxctrl_work);
897 901
898 /* turn off the IRQs and ack any outstanding */ 902 mutex_lock(&ks->lock);
899 ks8851_wrreg16(ks, KS_IER, 0x0000);
900 ks8851_wrreg16(ks, KS_ISR, 0xffff);
901
902 /* shutdown RX process */ 903 /* shutdown RX process */
903 ks8851_wrreg16(ks, KS_RXCR1, 0x0000); 904 ks8851_wrreg16(ks, KS_RXCR1, 0x0000);
904 905
@@ -907,6 +908,7 @@ static int ks8851_net_stop(struct net_device *dev)
907 908
908 /* set powermode to soft power down to save power */ 909 /* set powermode to soft power down to save power */
909 ks8851_set_powermode(ks, PMECR_PM_SOFTDOWN); 910 ks8851_set_powermode(ks, PMECR_PM_SOFTDOWN);
911 mutex_unlock(&ks->lock);
910 912
911 /* ensure any queued tx buffers are dumped */ 913 /* ensure any queued tx buffers are dumped */
912 while (!skb_queue_empty(&ks->txq)) { 914 while (!skb_queue_empty(&ks->txq)) {
@@ -918,7 +920,6 @@ static int ks8851_net_stop(struct net_device *dev)
918 dev_kfree_skb(txb); 920 dev_kfree_skb(txb);
919 } 921 }
920 922
921 mutex_unlock(&ks->lock);
922 return 0; 923 return 0;
923} 924}
924 925
@@ -1418,6 +1419,7 @@ static int __devinit ks8851_probe(struct spi_device *spi)
1418 struct net_device *ndev; 1419 struct net_device *ndev;
1419 struct ks8851_net *ks; 1420 struct ks8851_net *ks;
1420 int ret; 1421 int ret;
1422 unsigned cider;
1421 1423
1422 ndev = alloc_etherdev(sizeof(struct ks8851_net)); 1424 ndev = alloc_etherdev(sizeof(struct ks8851_net));
1423 if (!ndev) 1425 if (!ndev)
@@ -1484,8 +1486,8 @@ static int __devinit ks8851_probe(struct spi_device *spi)
1484 ks8851_soft_reset(ks, GRR_GSR); 1486 ks8851_soft_reset(ks, GRR_GSR);
1485 1487
1486 /* simple check for a valid chip being connected to the bus */ 1488 /* simple check for a valid chip being connected to the bus */
1487 1489 cider = ks8851_rdreg16(ks, KS_CIDER);
1488 if ((ks8851_rdreg16(ks, KS_CIDER) & ~CIDER_REV_MASK) != CIDER_ID) { 1490 if ((cider & ~CIDER_REV_MASK) != CIDER_ID) {
1489 dev_err(&spi->dev, "failed to read device ID\n"); 1491 dev_err(&spi->dev, "failed to read device ID\n");
1490 ret = -ENODEV; 1492 ret = -ENODEV;
1491 goto err_id; 1493 goto err_id;
@@ -1516,15 +1518,14 @@ static int __devinit ks8851_probe(struct spi_device *spi)
1516 } 1518 }
1517 1519
1518 netdev_info(ndev, "revision %d, MAC %pM, IRQ %d, %s EEPROM\n", 1520 netdev_info(ndev, "revision %d, MAC %pM, IRQ %d, %s EEPROM\n",
1519 CIDER_REV_GET(ks8851_rdreg16(ks, KS_CIDER)), 1521 CIDER_REV_GET(cider), ndev->dev_addr, ndev->irq,
1520 ndev->dev_addr, ndev->irq,
1521 ks->rc_ccr & CCR_EEPROM ? "has" : "no"); 1522 ks->rc_ccr & CCR_EEPROM ? "has" : "no");
1522 1523
1523 return 0; 1524 return 0;
1524 1525
1525 1526
1526err_netdev: 1527err_netdev:
1527 free_irq(ndev->irq, ndev); 1528 free_irq(ndev->irq, ks);
1528 1529
1529err_id: 1530err_id:
1530err_irq: 1531err_irq:
diff --git a/drivers/net/ethernet/micrel/ks8851_mll.c b/drivers/net/ethernet/micrel/ks8851_mll.c
index b8104d9f4081..5ffde23ac8fb 100644
--- a/drivers/net/ethernet/micrel/ks8851_mll.c
+++ b/drivers/net/ethernet/micrel/ks8851_mll.c
@@ -40,7 +40,7 @@
40#define DRV_NAME "ks8851_mll" 40#define DRV_NAME "ks8851_mll"
41 41
42static u8 KS_DEFAULT_MAC_ADDRESS[] = { 0x00, 0x10, 0xA1, 0x86, 0x95, 0x11 }; 42static u8 KS_DEFAULT_MAC_ADDRESS[] = { 0x00, 0x10, 0xA1, 0x86, 0x95, 0x11 };
43#define MAX_RECV_FRAMES 32 43#define MAX_RECV_FRAMES 255
44#define MAX_BUF_SIZE 2048 44#define MAX_BUF_SIZE 2048
45#define TX_BUF_SIZE 2000 45#define TX_BUF_SIZE 2000
46#define RX_BUF_SIZE 2000 46#define RX_BUF_SIZE 2000
diff --git a/drivers/net/ethernet/micrel/ksz884x.c b/drivers/net/ethernet/micrel/ksz884x.c
index ef723b185d85..eaf9ff0262a9 100644
--- a/drivers/net/ethernet/micrel/ksz884x.c
+++ b/drivers/net/ethernet/micrel/ksz884x.c
@@ -5675,7 +5675,7 @@ static int netdev_set_mac_address(struct net_device *dev, void *addr)
5675 memcpy(hw->override_addr, mac->sa_data, ETH_ALEN); 5675 memcpy(hw->override_addr, mac->sa_data, ETH_ALEN);
5676 } 5676 }
5677 5677
5678 memcpy(dev->dev_addr, mac->sa_data, MAX_ADDR_LEN); 5678 memcpy(dev->dev_addr, mac->sa_data, ETH_ALEN);
5679 5679
5680 interrupt = hw_block_intr(hw); 5680 interrupt = hw_block_intr(hw);
5681 5681
diff --git a/drivers/net/ethernet/realtek/8139cp.c b/drivers/net/ethernet/realtek/8139cp.c
index abc79076f867..b3287c0fe279 100644
--- a/drivers/net/ethernet/realtek/8139cp.c
+++ b/drivers/net/ethernet/realtek/8139cp.c
@@ -958,6 +958,11 @@ static inline void cp_start_hw (struct cp_private *cp)
958 cpw8(Cmd, RxOn | TxOn); 958 cpw8(Cmd, RxOn | TxOn);
959} 959}
960 960
961static void cp_enable_irq(struct cp_private *cp)
962{
963 cpw16_f(IntrMask, cp_intr_mask);
964}
965
961static void cp_init_hw (struct cp_private *cp) 966static void cp_init_hw (struct cp_private *cp)
962{ 967{
963 struct net_device *dev = cp->dev; 968 struct net_device *dev = cp->dev;
@@ -997,8 +1002,6 @@ static void cp_init_hw (struct cp_private *cp)
997 1002
998 cpw16(MultiIntr, 0); 1003 cpw16(MultiIntr, 0);
999 1004
1000 cpw16_f(IntrMask, cp_intr_mask);
1001
1002 cpw8_f(Cfg9346, Cfg9346_Lock); 1005 cpw8_f(Cfg9346, Cfg9346_Lock);
1003} 1006}
1004 1007
@@ -1130,6 +1133,8 @@ static int cp_open (struct net_device *dev)
1130 if (rc) 1133 if (rc)
1131 goto err_out_hw; 1134 goto err_out_hw;
1132 1135
1136 cp_enable_irq(cp);
1137
1133 netif_carrier_off(dev); 1138 netif_carrier_off(dev);
1134 mii_check_media(&cp->mii_if, netif_msg_link(cp), true); 1139 mii_check_media(&cp->mii_if, netif_msg_link(cp), true);
1135 netif_start_queue(dev); 1140 netif_start_queue(dev);
@@ -2031,6 +2036,7 @@ static int cp_resume (struct pci_dev *pdev)
2031 /* FIXME: sh*t may happen if the Rx ring buffer is depleted */ 2036 /* FIXME: sh*t may happen if the Rx ring buffer is depleted */
2032 cp_init_rings_index (cp); 2037 cp_init_rings_index (cp);
2033 cp_init_hw (cp); 2038 cp_init_hw (cp);
2039 cp_enable_irq(cp);
2034 netif_start_queue (dev); 2040 netif_start_queue (dev);
2035 2041
2036 spin_lock_irqsave (&cp->lock, flags); 2042 spin_lock_irqsave (&cp->lock, flags);
diff --git a/drivers/net/ethernet/smsc/smsc911x.c b/drivers/net/ethernet/smsc/smsc911x.c
index 4a6971027076..cd3defb11ffb 100644
--- a/drivers/net/ethernet/smsc/smsc911x.c
+++ b/drivers/net/ethernet/smsc/smsc911x.c
@@ -1166,10 +1166,8 @@ smsc911x_rx_counterrors(struct net_device *dev, unsigned int rxstat)
1166 1166
1167/* Quickly dumps bad packets */ 1167/* Quickly dumps bad packets */
1168static void 1168static void
1169smsc911x_rx_fastforward(struct smsc911x_data *pdata, unsigned int pktbytes) 1169smsc911x_rx_fastforward(struct smsc911x_data *pdata, unsigned int pktwords)
1170{ 1170{
1171 unsigned int pktwords = (pktbytes + NET_IP_ALIGN + 3) >> 2;
1172
1173 if (likely(pktwords >= 4)) { 1171 if (likely(pktwords >= 4)) {
1174 unsigned int timeout = 500; 1172 unsigned int timeout = 500;
1175 unsigned int val; 1173 unsigned int val;
@@ -1233,7 +1231,7 @@ static int smsc911x_poll(struct napi_struct *napi, int budget)
1233 continue; 1231 continue;
1234 } 1232 }
1235 1233
1236 skb = netdev_alloc_skb(dev, pktlength + NET_IP_ALIGN); 1234 skb = netdev_alloc_skb(dev, pktwords << 2);
1237 if (unlikely(!skb)) { 1235 if (unlikely(!skb)) {
1238 SMSC_WARN(pdata, rx_err, 1236 SMSC_WARN(pdata, rx_err,
1239 "Unable to allocate skb for rx packet"); 1237 "Unable to allocate skb for rx packet");
@@ -1243,14 +1241,12 @@ static int smsc911x_poll(struct napi_struct *napi, int budget)
1243 break; 1241 break;
1244 } 1242 }
1245 1243
1246 skb->data = skb->head; 1244 pdata->ops->rx_readfifo(pdata,
1247 skb_reset_tail_pointer(skb); 1245 (unsigned int *)skb->data, pktwords);
1248 1246
1249 /* Align IP on 16B boundary */ 1247 /* Align IP on 16B boundary */
1250 skb_reserve(skb, NET_IP_ALIGN); 1248 skb_reserve(skb, NET_IP_ALIGN);
1251 skb_put(skb, pktlength - 4); 1249 skb_put(skb, pktlength - 4);
1252 pdata->ops->rx_readfifo(pdata,
1253 (unsigned int *)skb->head, pktwords);
1254 skb->protocol = eth_type_trans(skb, dev); 1250 skb->protocol = eth_type_trans(skb, dev);
1255 skb_checksum_none_assert(skb); 1251 skb_checksum_none_assert(skb);
1256 netif_receive_skb(skb); 1252 netif_receive_skb(skb);
@@ -1565,7 +1561,7 @@ static int smsc911x_open(struct net_device *dev)
1565 smsc911x_reg_write(pdata, FIFO_INT, temp); 1561 smsc911x_reg_write(pdata, FIFO_INT, temp);
1566 1562
1567 /* set RX Data offset to 2 bytes for alignment */ 1563 /* set RX Data offset to 2 bytes for alignment */
1568 smsc911x_reg_write(pdata, RX_CFG, (2 << 8)); 1564 smsc911x_reg_write(pdata, RX_CFG, (NET_IP_ALIGN << 8));
1569 1565
1570 /* enable NAPI polling before enabling RX interrupts */ 1566 /* enable NAPI polling before enabling RX interrupts */
1571 napi_enable(&pdata->napi); 1567 napi_enable(&pdata->napi);
@@ -2382,7 +2378,6 @@ static int __devinit smsc911x_drv_probe(struct platform_device *pdev)
2382 SET_NETDEV_DEV(dev, &pdev->dev); 2378 SET_NETDEV_DEV(dev, &pdev->dev);
2383 2379
2384 pdata = netdev_priv(dev); 2380 pdata = netdev_priv(dev);
2385
2386 dev->irq = irq_res->start; 2381 dev->irq = irq_res->start;
2387 irq_flags = irq_res->flags & IRQF_TRIGGER_MASK; 2382 irq_flags = irq_res->flags & IRQF_TRIGGER_MASK;
2388 pdata->ioaddr = ioremap_nocache(res->start, res_size); 2383 pdata->ioaddr = ioremap_nocache(res->start, res_size);
@@ -2446,7 +2441,7 @@ static int __devinit smsc911x_drv_probe(struct platform_device *pdev)
2446 if (retval) { 2441 if (retval) {
2447 SMSC_WARN(pdata, probe, 2442 SMSC_WARN(pdata, probe,
2448 "Unable to claim requested irq: %d", dev->irq); 2443 "Unable to claim requested irq: %d", dev->irq);
2449 goto out_free_irq; 2444 goto out_disable_resources;
2450 } 2445 }
2451 2446
2452 retval = register_netdev(dev); 2447 retval = register_netdev(dev);
diff --git a/drivers/net/ethernet/ti/davinci_mdio.c b/drivers/net/ethernet/ti/davinci_mdio.c
index 2757c7d6e633..e4e47088e26b 100644
--- a/drivers/net/ethernet/ti/davinci_mdio.c
+++ b/drivers/net/ethernet/ti/davinci_mdio.c
@@ -181,6 +181,11 @@ static inline int wait_for_user_access(struct davinci_mdio_data *data)
181 __davinci_mdio_reset(data); 181 __davinci_mdio_reset(data);
182 return -EAGAIN; 182 return -EAGAIN;
183 } 183 }
184
185 reg = __raw_readl(&regs->user[0].access);
186 if ((reg & USERACCESS_GO) == 0)
187 return 0;
188
184 dev_err(data->dev, "timed out waiting for user access\n"); 189 dev_err(data->dev, "timed out waiting for user access\n");
185 return -ETIMEDOUT; 190 return -ETIMEDOUT;
186} 191}
diff --git a/drivers/net/ethernet/xilinx/xilinx_axienet.h b/drivers/net/ethernet/xilinx/xilinx_axienet.h
index cc83af083fd7..44b8d2bad8c3 100644
--- a/drivers/net/ethernet/xilinx/xilinx_axienet.h
+++ b/drivers/net/ethernet/xilinx/xilinx_axienet.h
@@ -2,9 +2,7 @@
2 * Definitions for Xilinx Axi Ethernet device driver. 2 * Definitions for Xilinx Axi Ethernet device driver.
3 * 3 *
4 * Copyright (c) 2009 Secret Lab Technologies, Ltd. 4 * Copyright (c) 2009 Secret Lab Technologies, Ltd.
5 * Copyright (c) 2010 Xilinx, Inc. All rights reserved. 5 * Copyright (c) 2010 - 2012 Xilinx, Inc. All rights reserved.
6 * Copyright (c) 2012 Daniel Borkmann, <daniel.borkmann@tik.ee.ethz.ch>
7 * Copyright (c) 2012 Ariane Keller, <ariane.keller@tik.ee.ethz.ch>
8 */ 6 */
9 7
10#ifndef XILINX_AXIENET_H 8#ifndef XILINX_AXIENET_H
diff --git a/drivers/net/ethernet/xilinx/xilinx_axienet_main.c b/drivers/net/ethernet/xilinx/xilinx_axienet_main.c
index 2fcbeba6814b..9c365e192a31 100644
--- a/drivers/net/ethernet/xilinx/xilinx_axienet_main.c
+++ b/drivers/net/ethernet/xilinx/xilinx_axienet_main.c
@@ -4,9 +4,9 @@
4 * Copyright (c) 2008 Nissin Systems Co., Ltd., Yoshio Kashiwagi 4 * Copyright (c) 2008 Nissin Systems Co., Ltd., Yoshio Kashiwagi
5 * Copyright (c) 2005-2008 DLA Systems, David H. Lynch Jr. <dhlii@dlasys.net> 5 * Copyright (c) 2005-2008 DLA Systems, David H. Lynch Jr. <dhlii@dlasys.net>
6 * Copyright (c) 2008-2009 Secret Lab Technologies Ltd. 6 * Copyright (c) 2008-2009 Secret Lab Technologies Ltd.
7 * Copyright (c) 2010 Xilinx, Inc. All rights reserved. 7 * Copyright (c) 2010 - 2011 Michal Simek <monstr@monstr.eu>
8 * Copyright (c) 2012 Daniel Borkmann, <daniel.borkmann@tik.ee.ethz.ch> 8 * Copyright (c) 2010 - 2011 PetaLogix
9 * Copyright (c) 2012 Ariane Keller, <ariane.keller@tik.ee.ethz.ch> 9 * Copyright (c) 2010 - 2012 Xilinx, Inc. All rights reserved.
10 * 10 *
11 * This is a driver for the Xilinx Axi Ethernet which is used in the Virtex6 11 * This is a driver for the Xilinx Axi Ethernet which is used in the Virtex6
12 * and Spartan6. 12 * and Spartan6.
diff --git a/drivers/net/ethernet/xilinx/xilinx_axienet_mdio.c b/drivers/net/ethernet/xilinx/xilinx_axienet_mdio.c
index d70b6e79f6c0..e90e1f46121e 100644
--- a/drivers/net/ethernet/xilinx/xilinx_axienet_mdio.c
+++ b/drivers/net/ethernet/xilinx/xilinx_axienet_mdio.c
@@ -2,9 +2,9 @@
2 * MDIO bus driver for the Xilinx Axi Ethernet device 2 * MDIO bus driver for the Xilinx Axi Ethernet device
3 * 3 *
4 * Copyright (c) 2009 Secret Lab Technologies, Ltd. 4 * Copyright (c) 2009 Secret Lab Technologies, Ltd.
5 * Copyright (c) 2010 Xilinx, Inc. All rights reserved. 5 * Copyright (c) 2010 - 2011 Michal Simek <monstr@monstr.eu>
6 * Copyright (c) 2012 Daniel Borkmann, <daniel.borkmann@tik.ee.ethz.ch> 6 * Copyright (c) 2010 - 2011 PetaLogix
7 * Copyright (c) 2012 Ariane Keller, <ariane.keller@tik.ee.ethz.ch> 7 * Copyright (c) 2010 - 2012 Xilinx, Inc. All rights reserved.
8 */ 8 */
9 9
10#include <linux/of_address.h> 10#include <linux/of_address.h>
diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c
index dd294783b5c5..2d59138db7f3 100644
--- a/drivers/net/hyperv/netvsc_drv.c
+++ b/drivers/net/hyperv/netvsc_drv.c
@@ -44,6 +44,7 @@ struct net_device_context {
44 /* point back to our device context */ 44 /* point back to our device context */
45 struct hv_device *device_ctx; 45 struct hv_device *device_ctx;
46 struct delayed_work dwork; 46 struct delayed_work dwork;
47 struct work_struct work;
47}; 48};
48 49
49 50
@@ -51,30 +52,22 @@ static int ring_size = 128;
51module_param(ring_size, int, S_IRUGO); 52module_param(ring_size, int, S_IRUGO);
52MODULE_PARM_DESC(ring_size, "Ring buffer size (# of pages)"); 53MODULE_PARM_DESC(ring_size, "Ring buffer size (# of pages)");
53 54
54struct set_multicast_work {
55 struct work_struct work;
56 struct net_device *net;
57};
58
59static void do_set_multicast(struct work_struct *w) 55static void do_set_multicast(struct work_struct *w)
60{ 56{
61 struct set_multicast_work *swk = 57 struct net_device_context *ndevctx =
62 container_of(w, struct set_multicast_work, work); 58 container_of(w, struct net_device_context, work);
63 struct net_device *net = swk->net;
64
65 struct net_device_context *ndevctx = netdev_priv(net);
66 struct netvsc_device *nvdev; 59 struct netvsc_device *nvdev;
67 struct rndis_device *rdev; 60 struct rndis_device *rdev;
68 61
69 nvdev = hv_get_drvdata(ndevctx->device_ctx); 62 nvdev = hv_get_drvdata(ndevctx->device_ctx);
70 if (nvdev == NULL) 63 if (nvdev == NULL || nvdev->ndev == NULL)
71 goto out; 64 return;
72 65
73 rdev = nvdev->extension; 66 rdev = nvdev->extension;
74 if (rdev == NULL) 67 if (rdev == NULL)
75 goto out; 68 return;
76 69
77 if (net->flags & IFF_PROMISC) 70 if (nvdev->ndev->flags & IFF_PROMISC)
78 rndis_filter_set_packet_filter(rdev, 71 rndis_filter_set_packet_filter(rdev,
79 NDIS_PACKET_TYPE_PROMISCUOUS); 72 NDIS_PACKET_TYPE_PROMISCUOUS);
80 else 73 else
@@ -82,21 +75,13 @@ static void do_set_multicast(struct work_struct *w)
82 NDIS_PACKET_TYPE_BROADCAST | 75 NDIS_PACKET_TYPE_BROADCAST |
83 NDIS_PACKET_TYPE_ALL_MULTICAST | 76 NDIS_PACKET_TYPE_ALL_MULTICAST |
84 NDIS_PACKET_TYPE_DIRECTED); 77 NDIS_PACKET_TYPE_DIRECTED);
85
86out:
87 kfree(w);
88} 78}
89 79
90static void netvsc_set_multicast_list(struct net_device *net) 80static void netvsc_set_multicast_list(struct net_device *net)
91{ 81{
92 struct set_multicast_work *swk = 82 struct net_device_context *net_device_ctx = netdev_priv(net);
93 kmalloc(sizeof(struct set_multicast_work), GFP_ATOMIC);
94 if (swk == NULL)
95 return;
96 83
97 swk->net = net; 84 schedule_work(&net_device_ctx->work);
98 INIT_WORK(&swk->work, do_set_multicast);
99 schedule_work(&swk->work);
100} 85}
101 86
102static int netvsc_open(struct net_device *net) 87static int netvsc_open(struct net_device *net)
@@ -125,6 +110,8 @@ static int netvsc_close(struct net_device *net)
125 110
126 netif_tx_disable(net); 111 netif_tx_disable(net);
127 112
113 /* Make sure netvsc_set_multicast_list doesn't re-enable filter! */
114 cancel_work_sync(&net_device_ctx->work);
128 ret = rndis_filter_close(device_obj); 115 ret = rndis_filter_close(device_obj);
129 if (ret != 0) 116 if (ret != 0)
130 netdev_err(net, "unable to close device (ret %d).\n", ret); 117 netdev_err(net, "unable to close device (ret %d).\n", ret);
@@ -335,6 +322,7 @@ static int netvsc_change_mtu(struct net_device *ndev, int mtu)
335 322
336 nvdev->start_remove = true; 323 nvdev->start_remove = true;
337 cancel_delayed_work_sync(&ndevctx->dwork); 324 cancel_delayed_work_sync(&ndevctx->dwork);
325 cancel_work_sync(&ndevctx->work);
338 netif_tx_disable(ndev); 326 netif_tx_disable(ndev);
339 rndis_filter_device_remove(hdev); 327 rndis_filter_device_remove(hdev);
340 328
@@ -403,6 +391,7 @@ static int netvsc_probe(struct hv_device *dev,
403 net_device_ctx->device_ctx = dev; 391 net_device_ctx->device_ctx = dev;
404 hv_set_drvdata(dev, net); 392 hv_set_drvdata(dev, net);
405 INIT_DELAYED_WORK(&net_device_ctx->dwork, netvsc_send_garp); 393 INIT_DELAYED_WORK(&net_device_ctx->dwork, netvsc_send_garp);
394 INIT_WORK(&net_device_ctx->work, do_set_multicast);
406 395
407 net->netdev_ops = &device_ops; 396 net->netdev_ops = &device_ops;
408 397
@@ -456,6 +445,7 @@ static int netvsc_remove(struct hv_device *dev)
456 445
457 ndev_ctx = netdev_priv(net); 446 ndev_ctx = netdev_priv(net);
458 cancel_delayed_work_sync(&ndev_ctx->dwork); 447 cancel_delayed_work_sync(&ndev_ctx->dwork);
448 cancel_work_sync(&ndev_ctx->work);
459 449
460 /* Stop outbound asap */ 450 /* Stop outbound asap */
461 netif_tx_disable(net); 451 netif_tx_disable(net);
diff --git a/drivers/net/phy/icplus.c b/drivers/net/phy/icplus.c
index f08c85acf761..5ac46f5226f3 100644
--- a/drivers/net/phy/icplus.c
+++ b/drivers/net/phy/icplus.c
@@ -40,6 +40,7 @@ MODULE_LICENSE("GPL");
40#define IP1001_PHASE_SEL_MASK 3 /* IP1001 RX/TXPHASE_SEL */ 40#define IP1001_PHASE_SEL_MASK 3 /* IP1001 RX/TXPHASE_SEL */
41#define IP1001_APS_ON 11 /* IP1001 APS Mode bit */ 41#define IP1001_APS_ON 11 /* IP1001 APS Mode bit */
42#define IP101A_G_APS_ON 2 /* IP101A/G APS Mode bit */ 42#define IP101A_G_APS_ON 2 /* IP101A/G APS Mode bit */
43#define IP101A_G_IRQ_CONF_STATUS 0x11 /* Conf Info IRQ & Status Reg */
43 44
44static int ip175c_config_init(struct phy_device *phydev) 45static int ip175c_config_init(struct phy_device *phydev)
45{ 46{
@@ -185,6 +186,15 @@ static int ip175c_config_aneg(struct phy_device *phydev)
185 return 0; 186 return 0;
186} 187}
187 188
189static int ip101a_g_ack_interrupt(struct phy_device *phydev)
190{
191 int err = phy_read(phydev, IP101A_G_IRQ_CONF_STATUS);
192 if (err < 0)
193 return err;
194
195 return 0;
196}
197
188static struct phy_driver ip175c_driver = { 198static struct phy_driver ip175c_driver = {
189 .phy_id = 0x02430d80, 199 .phy_id = 0x02430d80,
190 .name = "ICPlus IP175C", 200 .name = "ICPlus IP175C",
@@ -204,7 +214,6 @@ static struct phy_driver ip1001_driver = {
204 .phy_id_mask = 0x0ffffff0, 214 .phy_id_mask = 0x0ffffff0,
205 .features = PHY_GBIT_FEATURES | SUPPORTED_Pause | 215 .features = PHY_GBIT_FEATURES | SUPPORTED_Pause |
206 SUPPORTED_Asym_Pause, 216 SUPPORTED_Asym_Pause,
207 .flags = PHY_HAS_INTERRUPT,
208 .config_init = &ip1001_config_init, 217 .config_init = &ip1001_config_init,
209 .config_aneg = &genphy_config_aneg, 218 .config_aneg = &genphy_config_aneg,
210 .read_status = &genphy_read_status, 219 .read_status = &genphy_read_status,
@@ -220,6 +229,7 @@ static struct phy_driver ip101a_g_driver = {
220 .features = PHY_BASIC_FEATURES | SUPPORTED_Pause | 229 .features = PHY_BASIC_FEATURES | SUPPORTED_Pause |
221 SUPPORTED_Asym_Pause, 230 SUPPORTED_Asym_Pause,
222 .flags = PHY_HAS_INTERRUPT, 231 .flags = PHY_HAS_INTERRUPT,
232 .ack_interrupt = ip101a_g_ack_interrupt,
223 .config_init = &ip101a_g_config_init, 233 .config_init = &ip101a_g_config_init,
224 .config_aneg = &genphy_config_aneg, 234 .config_aneg = &genphy_config_aneg,
225 .read_status = &genphy_read_status, 235 .read_status = &genphy_read_status,
diff --git a/drivers/net/ppp/ppp_generic.c b/drivers/net/ppp/ppp_generic.c
index 33f8c51968b6..21d7151fb0ab 100644
--- a/drivers/net/ppp/ppp_generic.c
+++ b/drivers/net/ppp/ppp_generic.c
@@ -235,7 +235,7 @@ struct ppp_net {
235/* Prototypes. */ 235/* Prototypes. */
236static int ppp_unattached_ioctl(struct net *net, struct ppp_file *pf, 236static int ppp_unattached_ioctl(struct net *net, struct ppp_file *pf,
237 struct file *file, unsigned int cmd, unsigned long arg); 237 struct file *file, unsigned int cmd, unsigned long arg);
238static int ppp_xmit_process(struct ppp *ppp); 238static void ppp_xmit_process(struct ppp *ppp);
239static void ppp_send_frame(struct ppp *ppp, struct sk_buff *skb); 239static void ppp_send_frame(struct ppp *ppp, struct sk_buff *skb);
240static void ppp_push(struct ppp *ppp); 240static void ppp_push(struct ppp *ppp);
241static void ppp_channel_push(struct channel *pch); 241static void ppp_channel_push(struct channel *pch);
@@ -969,8 +969,7 @@ ppp_start_xmit(struct sk_buff *skb, struct net_device *dev)
969 put_unaligned_be16(proto, pp); 969 put_unaligned_be16(proto, pp);
970 970
971 skb_queue_tail(&ppp->file.xq, skb); 971 skb_queue_tail(&ppp->file.xq, skb);
972 if (!ppp_xmit_process(ppp)) 972 ppp_xmit_process(ppp);
973 netif_stop_queue(dev);
974 return NETDEV_TX_OK; 973 return NETDEV_TX_OK;
975 974
976 outf: 975 outf:
@@ -1048,11 +1047,10 @@ static void ppp_setup(struct net_device *dev)
1048 * Called to do any work queued up on the transmit side 1047 * Called to do any work queued up on the transmit side
1049 * that can now be done. 1048 * that can now be done.
1050 */ 1049 */
1051static int 1050static void
1052ppp_xmit_process(struct ppp *ppp) 1051ppp_xmit_process(struct ppp *ppp)
1053{ 1052{
1054 struct sk_buff *skb; 1053 struct sk_buff *skb;
1055 int ret = 0;
1056 1054
1057 ppp_xmit_lock(ppp); 1055 ppp_xmit_lock(ppp);
1058 if (!ppp->closing) { 1056 if (!ppp->closing) {
@@ -1062,13 +1060,12 @@ ppp_xmit_process(struct ppp *ppp)
1062 ppp_send_frame(ppp, skb); 1060 ppp_send_frame(ppp, skb);
1063 /* If there's no work left to do, tell the core net 1061 /* If there's no work left to do, tell the core net
1064 code that we can accept some more. */ 1062 code that we can accept some more. */
1065 if (!ppp->xmit_pending && !skb_peek(&ppp->file.xq)) { 1063 if (!ppp->xmit_pending && !skb_peek(&ppp->file.xq))
1066 netif_wake_queue(ppp->dev); 1064 netif_wake_queue(ppp->dev);
1067 ret = 1; 1065 else
1068 } 1066 netif_stop_queue(ppp->dev);
1069 } 1067 }
1070 ppp_xmit_unlock(ppp); 1068 ppp_xmit_unlock(ppp);
1071 return ret;
1072} 1069}
1073 1070
1074static inline struct sk_buff * 1071static inline struct sk_buff *
diff --git a/drivers/net/usb/qmi_wwan.c b/drivers/net/usb/qmi_wwan.c
index 552d24bf862e..d316503b35d4 100644
--- a/drivers/net/usb/qmi_wwan.c
+++ b/drivers/net/usb/qmi_wwan.c
@@ -365,6 +365,27 @@ static const struct driver_info qmi_wwan_force_int4 = {
365 .data = BIT(4), /* interface whitelist bitmap */ 365 .data = BIT(4), /* interface whitelist bitmap */
366}; 366};
367 367
368/* Sierra Wireless provide equally useless interface descriptors
369 * Devices in QMI mode can be switched between two different
370 * configurations:
371 * a) USB interface #8 is QMI/wwan
372 * b) USB interfaces #8, #19 and #20 are QMI/wwan
373 *
374 * Both configurations provide a number of other interfaces (serial++),
375 * some of which have the same endpoint configuration as we expect, so
376 * a whitelist or blacklist is necessary.
377 *
378 * FIXME: The below whitelist should include BIT(20). It does not
379 * because I cannot get it to work...
380 */
381static const struct driver_info qmi_wwan_sierra = {
382 .description = "Sierra Wireless wwan/QMI device",
383 .flags = FLAG_WWAN,
384 .bind = qmi_wwan_bind_gobi,
385 .unbind = qmi_wwan_unbind_shared,
386 .manage_power = qmi_wwan_manage_power,
387 .data = BIT(8) | BIT(19), /* interface whitelist bitmap */
388};
368 389
369#define HUAWEI_VENDOR_ID 0x12D1 390#define HUAWEI_VENDOR_ID 0x12D1
370#define QMI_GOBI_DEVICE(vend, prod) \ 391#define QMI_GOBI_DEVICE(vend, prod) \
@@ -445,6 +466,15 @@ static const struct usb_device_id products[] = {
445 .bInterfaceProtocol = 0xff, 466 .bInterfaceProtocol = 0xff,
446 .driver_info = (unsigned long)&qmi_wwan_force_int4, 467 .driver_info = (unsigned long)&qmi_wwan_force_int4,
447 }, 468 },
469 { /* Sierra Wireless MC77xx in QMI mode */
470 .match_flags = USB_DEVICE_ID_MATCH_DEVICE | USB_DEVICE_ID_MATCH_INT_INFO,
471 .idVendor = 0x1199,
472 .idProduct = 0x68a2,
473 .bInterfaceClass = 0xff,
474 .bInterfaceSubClass = 0xff,
475 .bInterfaceProtocol = 0xff,
476 .driver_info = (unsigned long)&qmi_wwan_sierra,
477 },
448 {QMI_GOBI_DEVICE(0x05c6, 0x9212)}, /* Acer Gobi Modem Device */ 478 {QMI_GOBI_DEVICE(0x05c6, 0x9212)}, /* Acer Gobi Modem Device */
449 {QMI_GOBI_DEVICE(0x03f0, 0x1f1d)}, /* HP un2400 Gobi Modem Device */ 479 {QMI_GOBI_DEVICE(0x03f0, 0x1f1d)}, /* HP un2400 Gobi Modem Device */
450 {QMI_GOBI_DEVICE(0x03f0, 0x371d)}, /* HP un2430 Mobile Broadband Module */ 480 {QMI_GOBI_DEVICE(0x03f0, 0x371d)}, /* HP un2430 Mobile Broadband Module */
diff --git a/drivers/net/usb/smsc75xx.c b/drivers/net/usb/smsc75xx.c
index 187d01ccb973..a2349483cd2a 100644
--- a/drivers/net/usb/smsc75xx.c
+++ b/drivers/net/usb/smsc75xx.c
@@ -1051,6 +1051,7 @@ static int smsc75xx_bind(struct usbnet *dev, struct usb_interface *intf)
1051 dev->net->ethtool_ops = &smsc75xx_ethtool_ops; 1051 dev->net->ethtool_ops = &smsc75xx_ethtool_ops;
1052 dev->net->flags |= IFF_MULTICAST; 1052 dev->net->flags |= IFF_MULTICAST;
1053 dev->net->hard_header_len += SMSC75XX_TX_OVERHEAD; 1053 dev->net->hard_header_len += SMSC75XX_TX_OVERHEAD;
1054 dev->hard_mtu = dev->net->mtu + dev->net->hard_header_len;
1054 return 0; 1055 return 0;
1055} 1056}
1056 1057
diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
index 4de2760c5937..af8acc85f4bb 100644
--- a/drivers/net/virtio_net.c
+++ b/drivers/net/virtio_net.c
@@ -626,16 +626,15 @@ static netdev_tx_t start_xmit(struct sk_buff *skb, struct net_device *dev)
626 /* This can happen with OOM and indirect buffers. */ 626 /* This can happen with OOM and indirect buffers. */
627 if (unlikely(capacity < 0)) { 627 if (unlikely(capacity < 0)) {
628 if (likely(capacity == -ENOMEM)) { 628 if (likely(capacity == -ENOMEM)) {
629 if (net_ratelimit()) { 629 if (net_ratelimit())
630 dev_warn(&dev->dev, 630 dev_warn(&dev->dev,
631 "TX queue failure: out of memory\n"); 631 "TX queue failure: out of memory\n");
632 } else { 632 } else {
633 dev->stats.tx_fifo_errors++; 633 dev->stats.tx_fifo_errors++;
634 if (net_ratelimit()) 634 if (net_ratelimit())
635 dev_warn(&dev->dev, 635 dev_warn(&dev->dev,
636 "Unexpected TX queue failure: %d\n", 636 "Unexpected TX queue failure: %d\n",
637 capacity); 637 capacity);
638 }
639 } 638 }
640 dev->stats.tx_dropped++; 639 dev->stats.tx_dropped++;
641 kfree_skb(skb); 640 kfree_skb(skb);
diff --git a/drivers/net/wan/farsync.c b/drivers/net/wan/farsync.c
index ebb9f24eefb5..1a623183cbe5 100644
--- a/drivers/net/wan/farsync.c
+++ b/drivers/net/wan/farsync.c
@@ -2483,6 +2483,7 @@ fst_add_one(struct pci_dev *pdev, const struct pci_device_id *ent)
2483 pr_err("Control memory remap failed\n"); 2483 pr_err("Control memory remap failed\n");
2484 pci_release_regions(pdev); 2484 pci_release_regions(pdev);
2485 pci_disable_device(pdev); 2485 pci_disable_device(pdev);
2486 iounmap(card->mem);
2486 kfree(card); 2487 kfree(card);
2487 return -ENODEV; 2488 return -ENODEV;
2488 } 2489 }
diff --git a/drivers/net/wireless/ath/ath5k/ahb.c b/drivers/net/wireless/ath/ath5k/ahb.c
index 8faa129da5a0..8c50d9d19d78 100644
--- a/drivers/net/wireless/ath/ath5k/ahb.c
+++ b/drivers/net/wireless/ath/ath5k/ahb.c
@@ -19,6 +19,7 @@
19#include <linux/nl80211.h> 19#include <linux/nl80211.h>
20#include <linux/platform_device.h> 20#include <linux/platform_device.h>
21#include <linux/etherdevice.h> 21#include <linux/etherdevice.h>
22#include <linux/export.h>
22#include <ar231x_platform.h> 23#include <ar231x_platform.h>
23#include "ath5k.h" 24#include "ath5k.h"
24#include "debug.h" 25#include "debug.h"
@@ -119,7 +120,7 @@ static int ath_ahb_probe(struct platform_device *pdev)
119 if (res == NULL) { 120 if (res == NULL) {
120 dev_err(&pdev->dev, "no IRQ resource found\n"); 121 dev_err(&pdev->dev, "no IRQ resource found\n");
121 ret = -ENXIO; 122 ret = -ENXIO;
122 goto err_out; 123 goto err_iounmap;
123 } 124 }
124 125
125 irq = res->start; 126 irq = res->start;
@@ -128,7 +129,7 @@ static int ath_ahb_probe(struct platform_device *pdev)
128 if (hw == NULL) { 129 if (hw == NULL) {
129 dev_err(&pdev->dev, "no memory for ieee80211_hw\n"); 130 dev_err(&pdev->dev, "no memory for ieee80211_hw\n");
130 ret = -ENOMEM; 131 ret = -ENOMEM;
131 goto err_out; 132 goto err_iounmap;
132 } 133 }
133 134
134 ah = hw->priv; 135 ah = hw->priv;
@@ -185,6 +186,8 @@ static int ath_ahb_probe(struct platform_device *pdev)
185 err_free_hw: 186 err_free_hw:
186 ieee80211_free_hw(hw); 187 ieee80211_free_hw(hw);
187 platform_set_drvdata(pdev, NULL); 188 platform_set_drvdata(pdev, NULL);
189 err_iounmap:
190 iounmap(mem);
188 err_out: 191 err_out:
189 return ret; 192 return ret;
190} 193}
diff --git a/drivers/net/wireless/ath/ath9k/main.c b/drivers/net/wireless/ath/ath9k/main.c
index 215eb2536b1e..798ea57252b4 100644
--- a/drivers/net/wireless/ath/ath9k/main.c
+++ b/drivers/net/wireless/ath/ath9k/main.c
@@ -118,15 +118,13 @@ void ath9k_ps_restore(struct ath_softc *sc)
118 if (--sc->ps_usecount != 0) 118 if (--sc->ps_usecount != 0)
119 goto unlock; 119 goto unlock;
120 120
121 if (sc->ps_flags & PS_WAIT_FOR_TX_ACK) 121 if (sc->ps_idle && (sc->ps_flags & PS_WAIT_FOR_TX_ACK))
122 goto unlock;
123
124 if (sc->ps_idle)
125 mode = ATH9K_PM_FULL_SLEEP; 122 mode = ATH9K_PM_FULL_SLEEP;
126 else if (sc->ps_enabled && 123 else if (sc->ps_enabled &&
127 !(sc->ps_flags & (PS_WAIT_FOR_BEACON | 124 !(sc->ps_flags & (PS_WAIT_FOR_BEACON |
128 PS_WAIT_FOR_CAB | 125 PS_WAIT_FOR_CAB |
129 PS_WAIT_FOR_PSPOLL_DATA))) 126 PS_WAIT_FOR_PSPOLL_DATA |
127 PS_WAIT_FOR_TX_ACK)))
130 mode = ATH9K_PM_NETWORK_SLEEP; 128 mode = ATH9K_PM_NETWORK_SLEEP;
131 else 129 else
132 goto unlock; 130 goto unlock;
@@ -1550,6 +1548,7 @@ static int ath9k_config(struct ieee80211_hw *hw, u32 changed)
1550 struct ath_hw *ah = sc->sc_ah; 1548 struct ath_hw *ah = sc->sc_ah;
1551 struct ath_common *common = ath9k_hw_common(ah); 1549 struct ath_common *common = ath9k_hw_common(ah);
1552 struct ieee80211_conf *conf = &hw->conf; 1550 struct ieee80211_conf *conf = &hw->conf;
1551 bool reset_channel = false;
1553 1552
1554 ath9k_ps_wakeup(sc); 1553 ath9k_ps_wakeup(sc);
1555 mutex_lock(&sc->mutex); 1554 mutex_lock(&sc->mutex);
@@ -1558,6 +1557,12 @@ static int ath9k_config(struct ieee80211_hw *hw, u32 changed)
1558 sc->ps_idle = !!(conf->flags & IEEE80211_CONF_IDLE); 1557 sc->ps_idle = !!(conf->flags & IEEE80211_CONF_IDLE);
1559 if (sc->ps_idle) 1558 if (sc->ps_idle)
1560 ath_cancel_work(sc); 1559 ath_cancel_work(sc);
1560 else
1561 /*
1562 * The chip needs a reset to properly wake up from
1563 * full sleep
1564 */
1565 reset_channel = ah->chip_fullsleep;
1561 } 1566 }
1562 1567
1563 /* 1568 /*
@@ -1586,7 +1591,7 @@ static int ath9k_config(struct ieee80211_hw *hw, u32 changed)
1586 } 1591 }
1587 } 1592 }
1588 1593
1589 if (changed & IEEE80211_CONF_CHANGE_CHANNEL) { 1594 if ((changed & IEEE80211_CONF_CHANGE_CHANNEL) || reset_channel) {
1590 struct ieee80211_channel *curchan = hw->conf.channel; 1595 struct ieee80211_channel *curchan = hw->conf.channel;
1591 int pos = curchan->hw_value; 1596 int pos = curchan->hw_value;
1592 int old_pos = -1; 1597 int old_pos = -1;
diff --git a/drivers/net/wireless/ath/ath9k/xmit.c b/drivers/net/wireless/ath/ath9k/xmit.c
index 834e6bc45e8b..23eaa1b26ebe 100644
--- a/drivers/net/wireless/ath/ath9k/xmit.c
+++ b/drivers/net/wireless/ath/ath9k/xmit.c
@@ -1820,6 +1820,7 @@ static struct ath_buf *ath_tx_setup_buffer(struct ath_softc *sc,
1820 struct ath_frame_info *fi = get_frame_info(skb); 1820 struct ath_frame_info *fi = get_frame_info(skb);
1821 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; 1821 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
1822 struct ath_buf *bf; 1822 struct ath_buf *bf;
1823 int fragno;
1823 u16 seqno; 1824 u16 seqno;
1824 1825
1825 bf = ath_tx_get_buffer(sc); 1826 bf = ath_tx_get_buffer(sc);
@@ -1831,9 +1832,16 @@ static struct ath_buf *ath_tx_setup_buffer(struct ath_softc *sc,
1831 ATH_TXBUF_RESET(bf); 1832 ATH_TXBUF_RESET(bf);
1832 1833
1833 if (tid) { 1834 if (tid) {
1835 fragno = le16_to_cpu(hdr->seq_ctrl) & IEEE80211_SCTL_FRAG;
1834 seqno = tid->seq_next; 1836 seqno = tid->seq_next;
1835 hdr->seq_ctrl = cpu_to_le16(tid->seq_next << IEEE80211_SEQ_SEQ_SHIFT); 1837 hdr->seq_ctrl = cpu_to_le16(tid->seq_next << IEEE80211_SEQ_SEQ_SHIFT);
1836 INCR(tid->seq_next, IEEE80211_SEQ_MAX); 1838
1839 if (fragno)
1840 hdr->seq_ctrl |= cpu_to_le16(fragno);
1841
1842 if (!ieee80211_has_morefrags(hdr->frame_control))
1843 INCR(tid->seq_next, IEEE80211_SEQ_MAX);
1844
1837 bf->bf_state.seqno = seqno; 1845 bf->bf_state.seqno = seqno;
1838 } 1846 }
1839 1847
diff --git a/drivers/net/wireless/brcm80211/brcmsmac/main.c b/drivers/net/wireless/brcm80211/brcmsmac/main.c
index 231ddf4a674f..7083db75b00c 100644
--- a/drivers/net/wireless/brcm80211/brcmsmac/main.c
+++ b/drivers/net/wireless/brcm80211/brcmsmac/main.c
@@ -7614,6 +7614,7 @@ brcms_c_recvctl(struct brcms_c_info *wlc, struct d11rxhdr *rxh,
7614{ 7614{
7615 int len_mpdu; 7615 int len_mpdu;
7616 struct ieee80211_rx_status rx_status; 7616 struct ieee80211_rx_status rx_status;
7617 struct ieee80211_hdr *hdr;
7617 7618
7618 memset(&rx_status, 0, sizeof(rx_status)); 7619 memset(&rx_status, 0, sizeof(rx_status));
7619 prep_mac80211_status(wlc, rxh, p, &rx_status); 7620 prep_mac80211_status(wlc, rxh, p, &rx_status);
@@ -7623,6 +7624,13 @@ brcms_c_recvctl(struct brcms_c_info *wlc, struct d11rxhdr *rxh,
7623 skb_pull(p, D11_PHY_HDR_LEN); 7624 skb_pull(p, D11_PHY_HDR_LEN);
7624 __skb_trim(p, len_mpdu); 7625 __skb_trim(p, len_mpdu);
7625 7626
7627 /* unmute transmit */
7628 if (wlc->hw->suspended_fifos) {
7629 hdr = (struct ieee80211_hdr *)p->data;
7630 if (ieee80211_is_beacon(hdr->frame_control))
7631 brcms_b_mute(wlc->hw, false);
7632 }
7633
7626 memcpy(IEEE80211_SKB_RXCB(p), &rx_status, sizeof(rx_status)); 7634 memcpy(IEEE80211_SKB_RXCB(p), &rx_status, sizeof(rx_status));
7627 ieee80211_rx_irqsafe(wlc->pub->ieee_hw, p); 7635 ieee80211_rx_irqsafe(wlc->pub->ieee_hw, p);
7628} 7636}
diff --git a/drivers/net/wireless/libertas/cfg.c b/drivers/net/wireless/libertas/cfg.c
index 3fa1ecebadfd..2fa879b015b6 100644
--- a/drivers/net/wireless/libertas/cfg.c
+++ b/drivers/net/wireless/libertas/cfg.c
@@ -103,7 +103,7 @@ static const u32 cipher_suites[] = {
103 * Convert NL80211's auth_type to the one from Libertas, see chapter 5.9.1 103 * Convert NL80211's auth_type to the one from Libertas, see chapter 5.9.1
104 * in the firmware spec 104 * in the firmware spec
105 */ 105 */
106static u8 lbs_auth_to_authtype(enum nl80211_auth_type auth_type) 106static int lbs_auth_to_authtype(enum nl80211_auth_type auth_type)
107{ 107{
108 int ret = -ENOTSUPP; 108 int ret = -ENOTSUPP;
109 109
@@ -1411,7 +1411,12 @@ static int lbs_cfg_connect(struct wiphy *wiphy, struct net_device *dev,
1411 goto done; 1411 goto done;
1412 } 1412 }
1413 1413
1414 lbs_set_authtype(priv, sme); 1414 ret = lbs_set_authtype(priv, sme);
1415 if (ret == -ENOTSUPP) {
1416 wiphy_err(wiphy, "unsupported authtype 0x%x\n", sme->auth_type);
1417 goto done;
1418 }
1419
1415 lbs_set_radio(priv, preamble, 1); 1420 lbs_set_radio(priv, preamble, 1);
1416 1421
1417 /* Do the actual association */ 1422 /* Do the actual association */
diff --git a/drivers/net/wireless/mwifiex/pcie.h b/drivers/net/wireless/mwifiex/pcie.h
index 445ff21772e2..2f218f9a3fd3 100644
--- a/drivers/net/wireless/mwifiex/pcie.h
+++ b/drivers/net/wireless/mwifiex/pcie.h
@@ -48,15 +48,15 @@
48#define PCIE_HOST_INT_STATUS_MASK 0xC3C 48#define PCIE_HOST_INT_STATUS_MASK 0xC3C
49#define PCIE_SCRATCH_2_REG 0xC40 49#define PCIE_SCRATCH_2_REG 0xC40
50#define PCIE_SCRATCH_3_REG 0xC44 50#define PCIE_SCRATCH_3_REG 0xC44
51#define PCIE_SCRATCH_4_REG 0xCC0 51#define PCIE_SCRATCH_4_REG 0xCD0
52#define PCIE_SCRATCH_5_REG 0xCC4 52#define PCIE_SCRATCH_5_REG 0xCD4
53#define PCIE_SCRATCH_6_REG 0xCC8 53#define PCIE_SCRATCH_6_REG 0xCD8
54#define PCIE_SCRATCH_7_REG 0xCCC 54#define PCIE_SCRATCH_7_REG 0xCDC
55#define PCIE_SCRATCH_8_REG 0xCD0 55#define PCIE_SCRATCH_8_REG 0xCE0
56#define PCIE_SCRATCH_9_REG 0xCD4 56#define PCIE_SCRATCH_9_REG 0xCE4
57#define PCIE_SCRATCH_10_REG 0xCD8 57#define PCIE_SCRATCH_10_REG 0xCE8
58#define PCIE_SCRATCH_11_REG 0xCDC 58#define PCIE_SCRATCH_11_REG 0xCEC
59#define PCIE_SCRATCH_12_REG 0xCE0 59#define PCIE_SCRATCH_12_REG 0xCF0
60 60
61#define CPU_INTR_DNLD_RDY BIT(0) 61#define CPU_INTR_DNLD_RDY BIT(0)
62#define CPU_INTR_DOOR_BELL BIT(1) 62#define CPU_INTR_DOOR_BELL BIT(1)
diff --git a/drivers/net/wireless/rt2x00/rt2x00dev.c b/drivers/net/wireless/rt2x00/rt2x00dev.c
index fc9901e027c1..90cc5e772650 100644
--- a/drivers/net/wireless/rt2x00/rt2x00dev.c
+++ b/drivers/net/wireless/rt2x00/rt2x00dev.c
@@ -1062,11 +1062,6 @@ static int rt2x00lib_initialize(struct rt2x00_dev *rt2x00dev)
1062 1062
1063 set_bit(DEVICE_STATE_INITIALIZED, &rt2x00dev->flags); 1063 set_bit(DEVICE_STATE_INITIALIZED, &rt2x00dev->flags);
1064 1064
1065 /*
1066 * Register the extra components.
1067 */
1068 rt2x00rfkill_register(rt2x00dev);
1069
1070 return 0; 1065 return 0;
1071} 1066}
1072 1067
@@ -1210,6 +1205,7 @@ int rt2x00lib_probe_dev(struct rt2x00_dev *rt2x00dev)
1210 rt2x00link_register(rt2x00dev); 1205 rt2x00link_register(rt2x00dev);
1211 rt2x00leds_register(rt2x00dev); 1206 rt2x00leds_register(rt2x00dev);
1212 rt2x00debug_register(rt2x00dev); 1207 rt2x00debug_register(rt2x00dev);
1208 rt2x00rfkill_register(rt2x00dev);
1213 1209
1214 return 0; 1210 return 0;
1215 1211
diff --git a/drivers/net/wireless/rtlwifi/base.c b/drivers/net/wireless/rtlwifi/base.c
index 510023554e5f..e54488db0e10 100644
--- a/drivers/net/wireless/rtlwifi/base.c
+++ b/drivers/net/wireless/rtlwifi/base.c
@@ -838,7 +838,10 @@ void rtl_get_tcb_desc(struct ieee80211_hw *hw,
838 __le16 fc = hdr->frame_control; 838 __le16 fc = hdr->frame_control;
839 839
840 txrate = ieee80211_get_tx_rate(hw, info); 840 txrate = ieee80211_get_tx_rate(hw, info);
841 tcb_desc->hw_rate = txrate->hw_value; 841 if (txrate)
842 tcb_desc->hw_rate = txrate->hw_value;
843 else
844 tcb_desc->hw_rate = 0;
842 845
843 if (ieee80211_is_data(fc)) { 846 if (ieee80211_is_data(fc)) {
844 /* 847 /*
diff --git a/drivers/net/wireless/rtlwifi/pci.c b/drivers/net/wireless/rtlwifi/pci.c
index 07dd38efe62a..288b035a3579 100644
--- a/drivers/net/wireless/rtlwifi/pci.c
+++ b/drivers/net/wireless/rtlwifi/pci.c
@@ -912,8 +912,13 @@ static void _rtl_pci_prepare_bcn_tasklet(struct ieee80211_hw *hw)
912 memset(&tcb_desc, 0, sizeof(struct rtl_tcb_desc)); 912 memset(&tcb_desc, 0, sizeof(struct rtl_tcb_desc));
913 ring = &rtlpci->tx_ring[BEACON_QUEUE]; 913 ring = &rtlpci->tx_ring[BEACON_QUEUE];
914 pskb = __skb_dequeue(&ring->queue); 914 pskb = __skb_dequeue(&ring->queue);
915 if (pskb) 915 if (pskb) {
916 struct rtl_tx_desc *entry = &ring->desc[ring->idx];
917 pci_unmap_single(rtlpci->pdev, rtlpriv->cfg->ops->get_desc(
918 (u8 *) entry, true, HW_DESC_TXBUFF_ADDR),
919 pskb->len, PCI_DMA_TODEVICE);
916 kfree_skb(pskb); 920 kfree_skb(pskb);
921 }
917 922
918 /*NB: the beacon data buffer must be 32-bit aligned. */ 923 /*NB: the beacon data buffer must be 32-bit aligned. */
919 pskb = ieee80211_beacon_get(hw, mac->vif); 924 pskb = ieee80211_beacon_get(hw, mac->vif);
diff --git a/drivers/net/wireless/rtlwifi/rtl8192de/sw.c b/drivers/net/wireless/rtlwifi/rtl8192de/sw.c
index 4898c502974d..480862c07f92 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192de/sw.c
+++ b/drivers/net/wireless/rtlwifi/rtl8192de/sw.c
@@ -91,7 +91,6 @@ static int rtl92d_init_sw_vars(struct ieee80211_hw *hw)
91 u8 tid; 91 u8 tid;
92 struct rtl_priv *rtlpriv = rtl_priv(hw); 92 struct rtl_priv *rtlpriv = rtl_priv(hw);
93 struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw)); 93 struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw));
94 static int header_print;
95 94
96 rtlpriv->dm.dm_initialgain_enable = true; 95 rtlpriv->dm.dm_initialgain_enable = true;
97 rtlpriv->dm.dm_flag = 0; 96 rtlpriv->dm.dm_flag = 0;
@@ -171,10 +170,6 @@ static int rtl92d_init_sw_vars(struct ieee80211_hw *hw)
171 for (tid = 0; tid < 8; tid++) 170 for (tid = 0; tid < 8; tid++)
172 skb_queue_head_init(&rtlpriv->mac80211.skb_waitq[tid]); 171 skb_queue_head_init(&rtlpriv->mac80211.skb_waitq[tid]);
173 172
174 /* Only load firmware for first MAC */
175 if (header_print)
176 return 0;
177
178 /* for firmware buf */ 173 /* for firmware buf */
179 rtlpriv->rtlhal.pfirmware = vzalloc(0x8000); 174 rtlpriv->rtlhal.pfirmware = vzalloc(0x8000);
180 if (!rtlpriv->rtlhal.pfirmware) { 175 if (!rtlpriv->rtlhal.pfirmware) {
@@ -186,7 +181,6 @@ static int rtl92d_init_sw_vars(struct ieee80211_hw *hw)
186 rtlpriv->max_fw_size = 0x8000; 181 rtlpriv->max_fw_size = 0x8000;
187 pr_info("Driver for Realtek RTL8192DE WLAN interface\n"); 182 pr_info("Driver for Realtek RTL8192DE WLAN interface\n");
188 pr_info("Loading firmware file %s\n", rtlpriv->cfg->fw_name); 183 pr_info("Loading firmware file %s\n", rtlpriv->cfg->fw_name);
189 header_print++;
190 184
191 /* request fw */ 185 /* request fw */
192 err = request_firmware_nowait(THIS_MODULE, 1, rtlpriv->cfg->fw_name, 186 err = request_firmware_nowait(THIS_MODULE, 1, rtlpriv->cfg->fw_name,
diff --git a/drivers/net/wireless/rtlwifi/usb.c b/drivers/net/wireless/rtlwifi/usb.c
index 2e1e352864bb..d04dbda13f5a 100644
--- a/drivers/net/wireless/rtlwifi/usb.c
+++ b/drivers/net/wireless/rtlwifi/usb.c
@@ -124,46 +124,38 @@ static int _usbctrl_vendorreq_sync_read(struct usb_device *udev, u8 request,
124 return status; 124 return status;
125} 125}
126 126
127static u32 _usb_read_sync(struct usb_device *udev, u32 addr, u16 len) 127static u32 _usb_read_sync(struct rtl_priv *rtlpriv, u32 addr, u16 len)
128{ 128{
129 struct device *dev = rtlpriv->io.dev;
130 struct usb_device *udev = to_usb_device(dev);
129 u8 request; 131 u8 request;
130 u16 wvalue; 132 u16 wvalue;
131 u16 index; 133 u16 index;
132 u32 *data; 134 __le32 *data = &rtlpriv->usb_data[rtlpriv->usb_data_index];
133 u32 ret;
134 135
135 data = kmalloc(sizeof(u32), GFP_KERNEL);
136 if (!data)
137 return -ENOMEM;
138 request = REALTEK_USB_VENQT_CMD_REQ; 136 request = REALTEK_USB_VENQT_CMD_REQ;
139 index = REALTEK_USB_VENQT_CMD_IDX; /* n/a */ 137 index = REALTEK_USB_VENQT_CMD_IDX; /* n/a */
140 138
141 wvalue = (u16)addr; 139 wvalue = (u16)addr;
142 _usbctrl_vendorreq_sync_read(udev, request, wvalue, index, data, len); 140 _usbctrl_vendorreq_sync_read(udev, request, wvalue, index, data, len);
143 ret = le32_to_cpu(*data); 141 if (++rtlpriv->usb_data_index >= RTL_USB_MAX_RX_COUNT)
144 kfree(data); 142 rtlpriv->usb_data_index = 0;
145 return ret; 143 return le32_to_cpu(*data);
146} 144}
147 145
148static u8 _usb_read8_sync(struct rtl_priv *rtlpriv, u32 addr) 146static u8 _usb_read8_sync(struct rtl_priv *rtlpriv, u32 addr)
149{ 147{
150 struct device *dev = rtlpriv->io.dev; 148 return (u8)_usb_read_sync(rtlpriv, addr, 1);
151
152 return (u8)_usb_read_sync(to_usb_device(dev), addr, 1);
153} 149}
154 150
155static u16 _usb_read16_sync(struct rtl_priv *rtlpriv, u32 addr) 151static u16 _usb_read16_sync(struct rtl_priv *rtlpriv, u32 addr)
156{ 152{
157 struct device *dev = rtlpriv->io.dev; 153 return (u16)_usb_read_sync(rtlpriv, addr, 2);
158
159 return (u16)_usb_read_sync(to_usb_device(dev), addr, 2);
160} 154}
161 155
162static u32 _usb_read32_sync(struct rtl_priv *rtlpriv, u32 addr) 156static u32 _usb_read32_sync(struct rtl_priv *rtlpriv, u32 addr)
163{ 157{
164 struct device *dev = rtlpriv->io.dev; 158 return _usb_read_sync(rtlpriv, addr, 4);
165
166 return _usb_read_sync(to_usb_device(dev), addr, 4);
167} 159}
168 160
169static void _usb_write_async(struct usb_device *udev, u32 addr, u32 val, 161static void _usb_write_async(struct usb_device *udev, u32 addr, u32 val,
@@ -955,6 +947,11 @@ int __devinit rtl_usb_probe(struct usb_interface *intf,
955 return -ENOMEM; 947 return -ENOMEM;
956 } 948 }
957 rtlpriv = hw->priv; 949 rtlpriv = hw->priv;
950 rtlpriv->usb_data = kzalloc(RTL_USB_MAX_RX_COUNT * sizeof(u32),
951 GFP_KERNEL);
952 if (!rtlpriv->usb_data)
953 return -ENOMEM;
954 rtlpriv->usb_data_index = 0;
958 init_completion(&rtlpriv->firmware_loading_complete); 955 init_completion(&rtlpriv->firmware_loading_complete);
959 SET_IEEE80211_DEV(hw, &intf->dev); 956 SET_IEEE80211_DEV(hw, &intf->dev);
960 udev = interface_to_usbdev(intf); 957 udev = interface_to_usbdev(intf);
@@ -1025,6 +1022,7 @@ void rtl_usb_disconnect(struct usb_interface *intf)
1025 /* rtl_deinit_rfkill(hw); */ 1022 /* rtl_deinit_rfkill(hw); */
1026 rtl_usb_deinit(hw); 1023 rtl_usb_deinit(hw);
1027 rtl_deinit_core(hw); 1024 rtl_deinit_core(hw);
1025 kfree(rtlpriv->usb_data);
1028 rtlpriv->cfg->ops->deinit_sw_leds(hw); 1026 rtlpriv->cfg->ops->deinit_sw_leds(hw);
1029 rtlpriv->cfg->ops->deinit_sw_vars(hw); 1027 rtlpriv->cfg->ops->deinit_sw_vars(hw);
1030 _rtl_usb_io_handler_release(hw); 1028 _rtl_usb_io_handler_release(hw);
diff --git a/drivers/net/wireless/rtlwifi/wifi.h b/drivers/net/wireless/rtlwifi/wifi.h
index b591614c3b9b..28ebc69218a3 100644
--- a/drivers/net/wireless/rtlwifi/wifi.h
+++ b/drivers/net/wireless/rtlwifi/wifi.h
@@ -67,7 +67,7 @@
67#define QOS_QUEUE_NUM 4 67#define QOS_QUEUE_NUM 4
68#define RTL_MAC80211_NUM_QUEUE 5 68#define RTL_MAC80211_NUM_QUEUE 5
69#define REALTEK_USB_VENQT_MAX_BUF_SIZE 254 69#define REALTEK_USB_VENQT_MAX_BUF_SIZE 254
70 70#define RTL_USB_MAX_RX_COUNT 100
71#define QBSS_LOAD_SIZE 5 71#define QBSS_LOAD_SIZE 5
72#define MAX_WMMELE_LENGTH 64 72#define MAX_WMMELE_LENGTH 64
73 73
@@ -1629,6 +1629,10 @@ struct rtl_priv {
1629 interface or hardware */ 1629 interface or hardware */
1630 unsigned long status; 1630 unsigned long status;
1631 1631
1632 /* data buffer pointer for USB reads */
1633 __le32 *usb_data;
1634 int usb_data_index;
1635
1632 /*This must be the last item so 1636 /*This must be the last item so
1633 that it points to the data allocated 1637 that it points to the data allocated
1634 beyond this structure like: 1638 beyond this structure like:
diff --git a/drivers/of/gpio.c b/drivers/of/gpio.c
index bba81216b4db..bf984b6dc477 100644
--- a/drivers/of/gpio.c
+++ b/drivers/of/gpio.c
@@ -140,7 +140,7 @@ int of_gpio_simple_xlate(struct gpio_chip *gc,
140 if (WARN_ON(gpiospec->args_count < gc->of_gpio_n_cells)) 140 if (WARN_ON(gpiospec->args_count < gc->of_gpio_n_cells))
141 return -EINVAL; 141 return -EINVAL;
142 142
143 if (gpiospec->args[0] > gc->ngpio) 143 if (gpiospec->args[0] >= gc->ngpio)
144 return -EINVAL; 144 return -EINVAL;
145 145
146 if (flags) 146 if (flags)
diff --git a/drivers/pci/Makefile b/drivers/pci/Makefile
index 083a49fee56a..165274c064bc 100644
--- a/drivers/pci/Makefile
+++ b/drivers/pci/Makefile
@@ -42,6 +42,7 @@ obj-$(CONFIG_UNICORE32) += setup-bus.o setup-irq.o
42obj-$(CONFIG_PARISC) += setup-bus.o 42obj-$(CONFIG_PARISC) += setup-bus.o
43obj-$(CONFIG_SUPERH) += setup-bus.o setup-irq.o 43obj-$(CONFIG_SUPERH) += setup-bus.o setup-irq.o
44obj-$(CONFIG_PPC) += setup-bus.o 44obj-$(CONFIG_PPC) += setup-bus.o
45obj-$(CONFIG_FRV) += setup-bus.o
45obj-$(CONFIG_MIPS) += setup-bus.o setup-irq.o 46obj-$(CONFIG_MIPS) += setup-bus.o setup-irq.o
46obj-$(CONFIG_X86_VISWS) += setup-irq.o 47obj-$(CONFIG_X86_VISWS) += setup-irq.o
47obj-$(CONFIG_MN10300) += setup-bus.o 48obj-$(CONFIG_MN10300) += setup-bus.o
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index 815674415267..111569ccab43 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -967,16 +967,59 @@ pci_save_state(struct pci_dev *dev)
967 return 0; 967 return 0;
968} 968}
969 969
970static void pci_restore_config_dword(struct pci_dev *pdev, int offset,
971 u32 saved_val, int retry)
972{
973 u32 val;
974
975 pci_read_config_dword(pdev, offset, &val);
976 if (val == saved_val)
977 return;
978
979 for (;;) {
980 dev_dbg(&pdev->dev, "restoring config space at offset "
981 "%#x (was %#x, writing %#x)\n", offset, val, saved_val);
982 pci_write_config_dword(pdev, offset, saved_val);
983 if (retry-- <= 0)
984 return;
985
986 pci_read_config_dword(pdev, offset, &val);
987 if (val == saved_val)
988 return;
989
990 mdelay(1);
991 }
992}
993
994static void pci_restore_config_space_range(struct pci_dev *pdev,
995 int start, int end, int retry)
996{
997 int index;
998
999 for (index = end; index >= start; index--)
1000 pci_restore_config_dword(pdev, 4 * index,
1001 pdev->saved_config_space[index],
1002 retry);
1003}
1004
1005static void pci_restore_config_space(struct pci_dev *pdev)
1006{
1007 if (pdev->hdr_type == PCI_HEADER_TYPE_NORMAL) {
1008 pci_restore_config_space_range(pdev, 10, 15, 0);
1009 /* Restore BARs before the command register. */
1010 pci_restore_config_space_range(pdev, 4, 9, 10);
1011 pci_restore_config_space_range(pdev, 0, 3, 0);
1012 } else {
1013 pci_restore_config_space_range(pdev, 0, 15, 0);
1014 }
1015}
1016
970/** 1017/**
971 * pci_restore_state - Restore the saved state of a PCI device 1018 * pci_restore_state - Restore the saved state of a PCI device
972 * @dev: - PCI device that we're dealing with 1019 * @dev: - PCI device that we're dealing with
973 */ 1020 */
974void pci_restore_state(struct pci_dev *dev) 1021void pci_restore_state(struct pci_dev *dev)
975{ 1022{
976 int i;
977 u32 val;
978 int tries;
979
980 if (!dev->state_saved) 1023 if (!dev->state_saved)
981 return; 1024 return;
982 1025
@@ -984,24 +1027,8 @@ void pci_restore_state(struct pci_dev *dev)
984 pci_restore_pcie_state(dev); 1027 pci_restore_pcie_state(dev);
985 pci_restore_ats_state(dev); 1028 pci_restore_ats_state(dev);
986 1029
987 /* 1030 pci_restore_config_space(dev);
988 * The Base Address register should be programmed before the command 1031
989 * register(s)
990 */
991 for (i = 15; i >= 0; i--) {
992 pci_read_config_dword(dev, i * 4, &val);
993 tries = 10;
994 while (tries && val != dev->saved_config_space[i]) {
995 dev_dbg(&dev->dev, "restoring config "
996 "space at offset %#x (was %#x, writing %#x)\n",
997 i, val, (int)dev->saved_config_space[i]);
998 pci_write_config_dword(dev,i * 4,
999 dev->saved_config_space[i]);
1000 pci_read_config_dword(dev, i * 4, &val);
1001 mdelay(10);
1002 tries--;
1003 }
1004 }
1005 pci_restore_pcix_state(dev); 1032 pci_restore_pcix_state(dev);
1006 pci_restore_msi_state(dev); 1033 pci_restore_msi_state(dev);
1007 pci_restore_iov_state(dev); 1034 pci_restore_iov_state(dev);
diff --git a/drivers/pinctrl/core.c b/drivers/pinctrl/core.c
index ec3b8cc188af..df6296c5f47b 100644
--- a/drivers/pinctrl/core.c
+++ b/drivers/pinctrl/core.c
@@ -908,10 +908,6 @@ static int pinctrl_groups_show(struct seq_file *s, void *what)
908 const struct pinctrl_ops *ops = pctldev->desc->pctlops; 908 const struct pinctrl_ops *ops = pctldev->desc->pctlops;
909 unsigned selector = 0; 909 unsigned selector = 0;
910 910
911 /* No grouping */
912 if (!ops)
913 return 0;
914
915 mutex_lock(&pinctrl_mutex); 911 mutex_lock(&pinctrl_mutex);
916 912
917 seq_puts(s, "registered pin groups:\n"); 913 seq_puts(s, "registered pin groups:\n");
@@ -1225,6 +1221,19 @@ static void pinctrl_remove_device_debugfs(struct pinctrl_dev *pctldev)
1225 1221
1226#endif 1222#endif
1227 1223
1224static int pinctrl_check_ops(struct pinctrl_dev *pctldev)
1225{
1226 const struct pinctrl_ops *ops = pctldev->desc->pctlops;
1227
1228 if (!ops ||
1229 !ops->list_groups ||
1230 !ops->get_group_name ||
1231 !ops->get_group_pins)
1232 return -EINVAL;
1233
1234 return 0;
1235}
1236
1228/** 1237/**
1229 * pinctrl_register() - register a pin controller device 1238 * pinctrl_register() - register a pin controller device
1230 * @pctldesc: descriptor for this pin controller 1239 * @pctldesc: descriptor for this pin controller
@@ -1256,6 +1265,14 @@ struct pinctrl_dev *pinctrl_register(struct pinctrl_desc *pctldesc,
1256 INIT_LIST_HEAD(&pctldev->gpio_ranges); 1265 INIT_LIST_HEAD(&pctldev->gpio_ranges);
1257 pctldev->dev = dev; 1266 pctldev->dev = dev;
1258 1267
1268 /* check core ops for sanity */
1269 ret = pinctrl_check_ops(pctldev);
1270 if (ret) {
1271 pr_err("%s pinctrl ops lacks necessary functions\n",
1272 pctldesc->name);
1273 goto out_err;
1274 }
1275
1259 /* If we're implementing pinmuxing, check the ops for sanity */ 1276 /* If we're implementing pinmuxing, check the ops for sanity */
1260 if (pctldesc->pmxops) { 1277 if (pctldesc->pmxops) {
1261 ret = pinmux_check_ops(pctldev); 1278 ret = pinmux_check_ops(pctldev);
diff --git a/drivers/platform/x86/acerhdf.c b/drivers/platform/x86/acerhdf.c
index bc8384c6f3eb..639db4d0aa76 100644
--- a/drivers/platform/x86/acerhdf.c
+++ b/drivers/platform/x86/acerhdf.c
@@ -50,7 +50,7 @@
50 */ 50 */
51#undef START_IN_KERNEL_MODE 51#undef START_IN_KERNEL_MODE
52 52
53#define DRV_VER "0.5.24" 53#define DRV_VER "0.5.26"
54 54
55/* 55/*
56 * According to the Atom N270 datasheet, 56 * According to the Atom N270 datasheet,
@@ -83,8 +83,8 @@ static int kernelmode;
83#endif 83#endif
84 84
85static unsigned int interval = 10; 85static unsigned int interval = 10;
86static unsigned int fanon = 63000; 86static unsigned int fanon = 60000;
87static unsigned int fanoff = 58000; 87static unsigned int fanoff = 53000;
88static unsigned int verbose; 88static unsigned int verbose;
89static unsigned int fanstate = ACERHDF_FAN_AUTO; 89static unsigned int fanstate = ACERHDF_FAN_AUTO;
90static char force_bios[16]; 90static char force_bios[16];
@@ -150,6 +150,8 @@ static const struct bios_settings_t bios_tbl[] = {
150 {"Acer", "AOA150", "v0.3308", 0x55, 0x58, {0x20, 0x00} }, 150 {"Acer", "AOA150", "v0.3308", 0x55, 0x58, {0x20, 0x00} },
151 {"Acer", "AOA150", "v0.3309", 0x55, 0x58, {0x20, 0x00} }, 151 {"Acer", "AOA150", "v0.3309", 0x55, 0x58, {0x20, 0x00} },
152 {"Acer", "AOA150", "v0.3310", 0x55, 0x58, {0x20, 0x00} }, 152 {"Acer", "AOA150", "v0.3310", 0x55, 0x58, {0x20, 0x00} },
153 /* LT1005u */
154 {"Acer", "LT-10Q", "v0.3310", 0x55, 0x58, {0x20, 0x00} },
153 /* Acer 1410 */ 155 /* Acer 1410 */
154 {"Acer", "Aspire 1410", "v0.3108", 0x55, 0x58, {0x9e, 0x00} }, 156 {"Acer", "Aspire 1410", "v0.3108", 0x55, 0x58, {0x9e, 0x00} },
155 {"Acer", "Aspire 1410", "v0.3113", 0x55, 0x58, {0x9e, 0x00} }, 157 {"Acer", "Aspire 1410", "v0.3113", 0x55, 0x58, {0x9e, 0x00} },
@@ -161,6 +163,7 @@ static const struct bios_settings_t bios_tbl[] = {
161 {"Acer", "Aspire 1410", "v1.3303", 0x55, 0x58, {0x9e, 0x00} }, 163 {"Acer", "Aspire 1410", "v1.3303", 0x55, 0x58, {0x9e, 0x00} },
162 {"Acer", "Aspire 1410", "v1.3308", 0x55, 0x58, {0x9e, 0x00} }, 164 {"Acer", "Aspire 1410", "v1.3308", 0x55, 0x58, {0x9e, 0x00} },
163 {"Acer", "Aspire 1410", "v1.3310", 0x55, 0x58, {0x9e, 0x00} }, 165 {"Acer", "Aspire 1410", "v1.3310", 0x55, 0x58, {0x9e, 0x00} },
166 {"Acer", "Aspire 1410", "v1.3314", 0x55, 0x58, {0x9e, 0x00} },
164 /* Acer 1810xx */ 167 /* Acer 1810xx */
165 {"Acer", "Aspire 1810TZ", "v0.3108", 0x55, 0x58, {0x9e, 0x00} }, 168 {"Acer", "Aspire 1810TZ", "v0.3108", 0x55, 0x58, {0x9e, 0x00} },
166 {"Acer", "Aspire 1810T", "v0.3108", 0x55, 0x58, {0x9e, 0x00} }, 169 {"Acer", "Aspire 1810T", "v0.3108", 0x55, 0x58, {0x9e, 0x00} },
@@ -183,29 +186,44 @@ static const struct bios_settings_t bios_tbl[] = {
183 {"Acer", "Aspire 1810TZ", "v1.3310", 0x55, 0x58, {0x9e, 0x00} }, 186 {"Acer", "Aspire 1810TZ", "v1.3310", 0x55, 0x58, {0x9e, 0x00} },
184 {"Acer", "Aspire 1810T", "v1.3310", 0x55, 0x58, {0x9e, 0x00} }, 187 {"Acer", "Aspire 1810T", "v1.3310", 0x55, 0x58, {0x9e, 0x00} },
185 {"Acer", "Aspire 1810TZ", "v1.3314", 0x55, 0x58, {0x9e, 0x00} }, 188 {"Acer", "Aspire 1810TZ", "v1.3314", 0x55, 0x58, {0x9e, 0x00} },
189 {"Acer", "Aspire 1810T", "v1.3314", 0x55, 0x58, {0x9e, 0x00} },
186 /* Acer 531 */ 190 /* Acer 531 */
191 {"Acer", "AO531h", "v0.3104", 0x55, 0x58, {0x20, 0x00} },
187 {"Acer", "AO531h", "v0.3201", 0x55, 0x58, {0x20, 0x00} }, 192 {"Acer", "AO531h", "v0.3201", 0x55, 0x58, {0x20, 0x00} },
193 {"Acer", "AO531h", "v0.3304", 0x55, 0x58, {0x20, 0x00} },
194 /* Acer 751 */
195 {"Acer", "AO751h", "V0.3212", 0x55, 0x58, {0x21, 0x00} },
196 /* Acer 1825 */
197 {"Acer", "Aspire 1825PTZ", "V1.3118", 0x55, 0x58, {0x9e, 0x00} },
198 {"Acer", "Aspire 1825PTZ", "V1.3127", 0x55, 0x58, {0x9e, 0x00} },
199 /* Acer TravelMate 7730 */
200 {"Acer", "TravelMate 7730G", "v0.3509", 0x55, 0x58, {0xaf, 0x00} },
188 /* Gateway */ 201 /* Gateway */
189 {"Gateway", "AOA110", "v0.3103", 0x55, 0x58, {0x21, 0x00} }, 202 {"Gateway", "AOA110", "v0.3103", 0x55, 0x58, {0x21, 0x00} },
190 {"Gateway", "AOA150", "v0.3103", 0x55, 0x58, {0x20, 0x00} }, 203 {"Gateway", "AOA150", "v0.3103", 0x55, 0x58, {0x20, 0x00} },
191 {"Gateway", "LT31", "v1.3103", 0x55, 0x58, {0x9e, 0x00} }, 204 {"Gateway", "LT31", "v1.3103", 0x55, 0x58, {0x9e, 0x00} },
192 {"Gateway", "LT31", "v1.3201", 0x55, 0x58, {0x9e, 0x00} }, 205 {"Gateway", "LT31", "v1.3201", 0x55, 0x58, {0x9e, 0x00} },
193 {"Gateway", "LT31", "v1.3302", 0x55, 0x58, {0x9e, 0x00} }, 206 {"Gateway", "LT31", "v1.3302", 0x55, 0x58, {0x9e, 0x00} },
207 {"Gateway", "LT31", "v1.3303t", 0x55, 0x58, {0x9e, 0x00} },
194 /* Packard Bell */ 208 /* Packard Bell */
195 {"Packard Bell", "DOA150", "v0.3104", 0x55, 0x58, {0x21, 0x00} }, 209 {"Packard Bell", "DOA150", "v0.3104", 0x55, 0x58, {0x21, 0x00} },
196 {"Packard Bell", "DOA150", "v0.3105", 0x55, 0x58, {0x20, 0x00} }, 210 {"Packard Bell", "DOA150", "v0.3105", 0x55, 0x58, {0x20, 0x00} },
197 {"Packard Bell", "AOA110", "v0.3105", 0x55, 0x58, {0x21, 0x00} }, 211 {"Packard Bell", "AOA110", "v0.3105", 0x55, 0x58, {0x21, 0x00} },
198 {"Packard Bell", "AOA150", "v0.3105", 0x55, 0x58, {0x20, 0x00} }, 212 {"Packard Bell", "AOA150", "v0.3105", 0x55, 0x58, {0x20, 0x00} },
199 {"Packard Bell", "DOTMU", "v1.3303", 0x55, 0x58, {0x9e, 0x00} }, 213 {"Packard Bell", "ENBFT", "V1.3118", 0x55, 0x58, {0x9e, 0x00} },
200 {"Packard Bell", "DOTMU", "v0.3120", 0x55, 0x58, {0x9e, 0x00} }, 214 {"Packard Bell", "ENBFT", "V1.3127", 0x55, 0x58, {0x9e, 0x00} },
201 {"Packard Bell", "DOTMU", "v0.3108", 0x55, 0x58, {0x9e, 0x00} }, 215 {"Packard Bell", "DOTMU", "v1.3303", 0x55, 0x58, {0x9e, 0x00} },
202 {"Packard Bell", "DOTMU", "v0.3113", 0x55, 0x58, {0x9e, 0x00} }, 216 {"Packard Bell", "DOTMU", "v0.3120", 0x55, 0x58, {0x9e, 0x00} },
203 {"Packard Bell", "DOTMU", "v0.3115", 0x55, 0x58, {0x9e, 0x00} }, 217 {"Packard Bell", "DOTMU", "v0.3108", 0x55, 0x58, {0x9e, 0x00} },
204 {"Packard Bell", "DOTMU", "v0.3117", 0x55, 0x58, {0x9e, 0x00} }, 218 {"Packard Bell", "DOTMU", "v0.3113", 0x55, 0x58, {0x9e, 0x00} },
205 {"Packard Bell", "DOTMU", "v0.3119", 0x55, 0x58, {0x9e, 0x00} }, 219 {"Packard Bell", "DOTMU", "v0.3115", 0x55, 0x58, {0x9e, 0x00} },
206 {"Packard Bell", "DOTMU", "v1.3204", 0x55, 0x58, {0x9e, 0x00} }, 220 {"Packard Bell", "DOTMU", "v0.3117", 0x55, 0x58, {0x9e, 0x00} },
207 {"Packard Bell", "DOTMA", "v1.3201", 0x55, 0x58, {0x9e, 0x00} }, 221 {"Packard Bell", "DOTMU", "v0.3119", 0x55, 0x58, {0x9e, 0x00} },
208 {"Packard Bell", "DOTMA", "v1.3302", 0x55, 0x58, {0x9e, 0x00} }, 222 {"Packard Bell", "DOTMU", "v1.3204", 0x55, 0x58, {0x9e, 0x00} },
223 {"Packard Bell", "DOTMA", "v1.3201", 0x55, 0x58, {0x9e, 0x00} },
224 {"Packard Bell", "DOTMA", "v1.3302", 0x55, 0x58, {0x9e, 0x00} },
225 {"Packard Bell", "DOTMA", "v1.3303t", 0x55, 0x58, {0x9e, 0x00} },
226 {"Packard Bell", "DOTVR46", "v1.3308", 0x55, 0x58, {0x9e, 0x00} },
209 /* pewpew-terminator */ 227 /* pewpew-terminator */
210 {"", "", "", 0, 0, {0, 0} } 228 {"", "", "", 0, 0, {0, 0} }
211}; 229};
@@ -701,15 +719,20 @@ MODULE_LICENSE("GPL");
701MODULE_AUTHOR("Peter Feuerer"); 719MODULE_AUTHOR("Peter Feuerer");
702MODULE_DESCRIPTION("Aspire One temperature and fan driver"); 720MODULE_DESCRIPTION("Aspire One temperature and fan driver");
703MODULE_ALIAS("dmi:*:*Acer*:pnAOA*:"); 721MODULE_ALIAS("dmi:*:*Acer*:pnAOA*:");
722MODULE_ALIAS("dmi:*:*Acer*:pnAO751h*:");
704MODULE_ALIAS("dmi:*:*Acer*:pnAspire*1410*:"); 723MODULE_ALIAS("dmi:*:*Acer*:pnAspire*1410*:");
705MODULE_ALIAS("dmi:*:*Acer*:pnAspire*1810*:"); 724MODULE_ALIAS("dmi:*:*Acer*:pnAspire*1810*:");
725MODULE_ALIAS("dmi:*:*Acer*:pnAspire*1825PTZ:");
706MODULE_ALIAS("dmi:*:*Acer*:pnAO531*:"); 726MODULE_ALIAS("dmi:*:*Acer*:pnAO531*:");
727MODULE_ALIAS("dmi:*:*Acer*:TravelMate*7730G:");
707MODULE_ALIAS("dmi:*:*Gateway*:pnAOA*:"); 728MODULE_ALIAS("dmi:*:*Gateway*:pnAOA*:");
708MODULE_ALIAS("dmi:*:*Gateway*:pnLT31*:"); 729MODULE_ALIAS("dmi:*:*Gateway*:pnLT31*:");
709MODULE_ALIAS("dmi:*:*Packard*Bell*:pnAOA*:"); 730MODULE_ALIAS("dmi:*:*Packard*Bell*:pnAOA*:");
710MODULE_ALIAS("dmi:*:*Packard*Bell*:pnDOA*:"); 731MODULE_ALIAS("dmi:*:*Packard*Bell*:pnDOA*:");
711MODULE_ALIAS("dmi:*:*Packard*Bell*:pnDOTMU*:"); 732MODULE_ALIAS("dmi:*:*Packard*Bell*:pnDOTMU*:");
733MODULE_ALIAS("dmi:*:*Packard*Bell*:pnENBFT*:");
712MODULE_ALIAS("dmi:*:*Packard*Bell*:pnDOTMA*:"); 734MODULE_ALIAS("dmi:*:*Packard*Bell*:pnDOTMA*:");
735MODULE_ALIAS("dmi:*:*Packard*Bell*:pnDOTVR46*:");
713 736
714module_init(acerhdf_init); 737module_init(acerhdf_init);
715module_exit(acerhdf_exit); 738module_exit(acerhdf_exit);
diff --git a/drivers/platform/x86/dell-laptop.c b/drivers/platform/x86/dell-laptop.c
index a05fc9c955d8..e6c08ee8d46c 100644
--- a/drivers/platform/x86/dell-laptop.c
+++ b/drivers/platform/x86/dell-laptop.c
@@ -212,6 +212,7 @@ static struct dmi_system_id __devinitdata dell_quirks[] = {
212 }, 212 },
213 .driver_data = &quirk_dell_vostro_v130, 213 .driver_data = &quirk_dell_vostro_v130,
214 }, 214 },
215 { }
215}; 216};
216 217
217static struct calling_interface_buffer *buffer; 218static struct calling_interface_buffer *buffer;
diff --git a/drivers/platform/x86/intel_ips.c b/drivers/platform/x86/intel_ips.c
index f7ba316e0ed6..0ffdb3cde2bb 100644
--- a/drivers/platform/x86/intel_ips.c
+++ b/drivers/platform/x86/intel_ips.c
@@ -1565,7 +1565,7 @@ static int ips_probe(struct pci_dev *dev, const struct pci_device_id *id)
1565 ips->poll_turbo_status = true; 1565 ips->poll_turbo_status = true;
1566 1566
1567 if (!ips_get_i915_syms(ips)) { 1567 if (!ips_get_i915_syms(ips)) {
1568 dev_err(&dev->dev, "failed to get i915 symbols, graphics turbo disabled\n"); 1568 dev_info(&dev->dev, "failed to get i915 symbols, graphics turbo disabled until i915 loads\n");
1569 ips->gpu_turbo_enabled = false; 1569 ips->gpu_turbo_enabled = false;
1570 } else { 1570 } else {
1571 dev_dbg(&dev->dev, "graphics turbo enabled\n"); 1571 dev_dbg(&dev->dev, "graphics turbo enabled\n");
diff --git a/drivers/regulator/anatop-regulator.c b/drivers/regulator/anatop-regulator.c
index 53969af17558..81fd606e47bc 100644
--- a/drivers/regulator/anatop-regulator.c
+++ b/drivers/regulator/anatop-regulator.c
@@ -214,7 +214,7 @@ static struct of_device_id __devinitdata of_anatop_regulator_match_tbl[] = {
214 { /* end */ } 214 { /* end */ }
215}; 215};
216 216
217static struct platform_driver anatop_regulator = { 217static struct platform_driver anatop_regulator_driver = {
218 .driver = { 218 .driver = {
219 .name = "anatop_regulator", 219 .name = "anatop_regulator",
220 .owner = THIS_MODULE, 220 .owner = THIS_MODULE,
@@ -226,13 +226,13 @@ static struct platform_driver anatop_regulator = {
226 226
227static int __init anatop_regulator_init(void) 227static int __init anatop_regulator_init(void)
228{ 228{
229 return platform_driver_register(&anatop_regulator); 229 return platform_driver_register(&anatop_regulator_driver);
230} 230}
231postcore_initcall(anatop_regulator_init); 231postcore_initcall(anatop_regulator_init);
232 232
233static void __exit anatop_regulator_exit(void) 233static void __exit anatop_regulator_exit(void)
234{ 234{
235 platform_driver_unregister(&anatop_regulator); 235 platform_driver_unregister(&anatop_regulator_driver);
236} 236}
237module_exit(anatop_regulator_exit); 237module_exit(anatop_regulator_exit);
238 238
diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c
index cd188ab72f79..c293d0cdb104 100644
--- a/drivers/rtc/rtc-ds1307.c
+++ b/drivers/rtc/rtc-ds1307.c
@@ -902,6 +902,7 @@ read_rtc:
902 } 902 }
903 ds1307->nvram->attr.name = "nvram"; 903 ds1307->nvram->attr.name = "nvram";
904 ds1307->nvram->attr.mode = S_IRUGO | S_IWUSR; 904 ds1307->nvram->attr.mode = S_IRUGO | S_IWUSR;
905 sysfs_bin_attr_init(ds1307->nvram);
905 ds1307->nvram->read = ds1307_nvram_read, 906 ds1307->nvram->read = ds1307_nvram_read,
906 ds1307->nvram->write = ds1307_nvram_write, 907 ds1307->nvram->write = ds1307_nvram_write,
907 ds1307->nvram->size = chip->nvram_size; 908 ds1307->nvram->size = chip->nvram_size;
diff --git a/drivers/rtc/rtc-efi.c b/drivers/rtc/rtc-efi.c
index 550292304b0f..c9f890b088da 100644
--- a/drivers/rtc/rtc-efi.c
+++ b/drivers/rtc/rtc-efi.c
@@ -213,7 +213,6 @@ static struct platform_driver efi_rtc_driver = {
213 .name = "rtc-efi", 213 .name = "rtc-efi",
214 .owner = THIS_MODULE, 214 .owner = THIS_MODULE,
215 }, 215 },
216 .probe = efi_rtc_probe,
217 .remove = __exit_p(efi_rtc_remove), 216 .remove = __exit_p(efi_rtc_remove),
218}; 217};
219 218
diff --git a/drivers/rtc/rtc-pl031.c b/drivers/rtc/rtc-pl031.c
index 692de7360e94..684ef4bbfce4 100644
--- a/drivers/rtc/rtc-pl031.c
+++ b/drivers/rtc/rtc-pl031.c
@@ -339,8 +339,7 @@ static int pl031_probe(struct amba_device *adev, const struct amba_id *id)
339 dev_dbg(&adev->dev, "revision = 0x%01x\n", ldata->hw_revision); 339 dev_dbg(&adev->dev, "revision = 0x%01x\n", ldata->hw_revision);
340 340
341 /* Enable the clockwatch on ST Variants */ 341 /* Enable the clockwatch on ST Variants */
342 if ((ldata->hw_designer == AMBA_VENDOR_ST) && 342 if (ldata->hw_designer == AMBA_VENDOR_ST)
343 (ldata->hw_revision > 1))
344 writel(readl(ldata->base + RTC_CR) | RTC_CR_CWEN, 343 writel(readl(ldata->base + RTC_CR) | RTC_CR_CWEN,
345 ldata->base + RTC_CR); 344 ldata->base + RTC_CR);
346 345
diff --git a/drivers/rtc/rtc-r9701.c b/drivers/rtc/rtc-r9701.c
index 7f8e6c247935..33b6ba0afa0d 100644
--- a/drivers/rtc/rtc-r9701.c
+++ b/drivers/rtc/rtc-r9701.c
@@ -122,6 +122,7 @@ static const struct rtc_class_ops r9701_rtc_ops = {
122static int __devinit r9701_probe(struct spi_device *spi) 122static int __devinit r9701_probe(struct spi_device *spi)
123{ 123{
124 struct rtc_device *rtc; 124 struct rtc_device *rtc;
125 struct rtc_time dt;
125 unsigned char tmp; 126 unsigned char tmp;
126 int res; 127 int res;
127 128
@@ -132,6 +133,27 @@ static int __devinit r9701_probe(struct spi_device *spi)
132 return -ENODEV; 133 return -ENODEV;
133 } 134 }
134 135
136 /*
137 * The device seems to be present. Now check if the registers
138 * contain invalid values. If so, try to write a default date:
139 * 2000/1/1 00:00:00
140 */
141 r9701_get_datetime(&spi->dev, &dt);
142 if (rtc_valid_tm(&dt)) {
143 dev_info(&spi->dev, "trying to repair invalid date/time\n");
144 dt.tm_sec = 0;
145 dt.tm_min = 0;
146 dt.tm_hour = 0;
147 dt.tm_mday = 1;
148 dt.tm_mon = 0;
149 dt.tm_year = 100;
150
151 if (r9701_set_datetime(&spi->dev, &dt)) {
152 dev_err(&spi->dev, "cannot repair RTC register\n");
153 return -ENODEV;
154 }
155 }
156
135 rtc = rtc_device_register("r9701", 157 rtc = rtc_device_register("r9701",
136 &spi->dev, &r9701_rtc_ops, THIS_MODULE); 158 &spi->dev, &r9701_rtc_ops, THIS_MODULE);
137 if (IS_ERR(rtc)) 159 if (IS_ERR(rtc))
diff --git a/drivers/rtc/rtc-s3c.c b/drivers/rtc/rtc-s3c.c
index 9ccea134a996..3f3a29752369 100644
--- a/drivers/rtc/rtc-s3c.c
+++ b/drivers/rtc/rtc-s3c.c
@@ -40,6 +40,10 @@ enum s3c_cpu_type {
40 TYPE_S3C64XX, 40 TYPE_S3C64XX,
41}; 41};
42 42
43struct s3c_rtc_drv_data {
44 int cpu_type;
45};
46
43/* I have yet to find an S3C implementation with more than one 47/* I have yet to find an S3C implementation with more than one
44 * of these rtc blocks in */ 48 * of these rtc blocks in */
45 49
@@ -446,10 +450,12 @@ static const struct of_device_id s3c_rtc_dt_match[];
446static inline int s3c_rtc_get_driver_data(struct platform_device *pdev) 450static inline int s3c_rtc_get_driver_data(struct platform_device *pdev)
447{ 451{
448#ifdef CONFIG_OF 452#ifdef CONFIG_OF
453 struct s3c_rtc_drv_data *data;
449 if (pdev->dev.of_node) { 454 if (pdev->dev.of_node) {
450 const struct of_device_id *match; 455 const struct of_device_id *match;
451 match = of_match_node(s3c_rtc_dt_match, pdev->dev.of_node); 456 match = of_match_node(s3c_rtc_dt_match, pdev->dev.of_node);
452 return match->data; 457 data = (struct s3c_rtc_drv_data *) match->data;
458 return data->cpu_type;
453 } 459 }
454#endif 460#endif
455 return platform_get_device_id(pdev)->driver_data; 461 return platform_get_device_id(pdev)->driver_data;
@@ -664,20 +670,27 @@ static int s3c_rtc_resume(struct platform_device *pdev)
664#define s3c_rtc_resume NULL 670#define s3c_rtc_resume NULL
665#endif 671#endif
666 672
673static struct s3c_rtc_drv_data s3c_rtc_drv_data_array[] = {
674 [TYPE_S3C2410] = { TYPE_S3C2410 },
675 [TYPE_S3C2416] = { TYPE_S3C2416 },
676 [TYPE_S3C2443] = { TYPE_S3C2443 },
677 [TYPE_S3C64XX] = { TYPE_S3C64XX },
678};
679
667#ifdef CONFIG_OF 680#ifdef CONFIG_OF
668static const struct of_device_id s3c_rtc_dt_match[] = { 681static const struct of_device_id s3c_rtc_dt_match[] = {
669 { 682 {
670 .compatible = "samsung,s3c2410-rtc" 683 .compatible = "samsung,s3c2410-rtc",
671 .data = TYPE_S3C2410, 684 .data = &s3c_rtc_drv_data_array[TYPE_S3C2410],
672 }, { 685 }, {
673 .compatible = "samsung,s3c2416-rtc" 686 .compatible = "samsung,s3c2416-rtc",
674 .data = TYPE_S3C2416, 687 .data = &s3c_rtc_drv_data_array[TYPE_S3C2416],
675 }, { 688 }, {
676 .compatible = "samsung,s3c2443-rtc" 689 .compatible = "samsung,s3c2443-rtc",
677 .data = TYPE_S3C2443, 690 .data = &s3c_rtc_drv_data_array[TYPE_S3C2443],
678 }, { 691 }, {
679 .compatible = "samsung,s3c6410-rtc" 692 .compatible = "samsung,s3c6410-rtc",
680 .data = TYPE_S3C64XX, 693 .data = &s3c_rtc_drv_data_array[TYPE_S3C64XX],
681 }, 694 },
682 {}, 695 {},
683}; 696};
diff --git a/drivers/rtc/rtc-twl.c b/drivers/rtc/rtc-twl.c
index 4c2c6df2a9ef..258abeabf624 100644
--- a/drivers/rtc/rtc-twl.c
+++ b/drivers/rtc/rtc-twl.c
@@ -112,6 +112,7 @@ static const u8 twl6030_rtc_reg_map[] = {
112#define BIT_RTC_CTRL_REG_TEST_MODE_M 0x10 112#define BIT_RTC_CTRL_REG_TEST_MODE_M 0x10
113#define BIT_RTC_CTRL_REG_SET_32_COUNTER_M 0x20 113#define BIT_RTC_CTRL_REG_SET_32_COUNTER_M 0x20
114#define BIT_RTC_CTRL_REG_GET_TIME_M 0x40 114#define BIT_RTC_CTRL_REG_GET_TIME_M 0x40
115#define BIT_RTC_CTRL_REG_RTC_V_OPT 0x80
115 116
116/* RTC_STATUS_REG bitfields */ 117/* RTC_STATUS_REG bitfields */
117#define BIT_RTC_STATUS_REG_RUN_M 0x02 118#define BIT_RTC_STATUS_REG_RUN_M 0x02
@@ -235,25 +236,57 @@ static int twl_rtc_read_time(struct device *dev, struct rtc_time *tm)
235 unsigned char rtc_data[ALL_TIME_REGS + 1]; 236 unsigned char rtc_data[ALL_TIME_REGS + 1];
236 int ret; 237 int ret;
237 u8 save_control; 238 u8 save_control;
239 u8 rtc_control;
238 240
239 ret = twl_rtc_read_u8(&save_control, REG_RTC_CTRL_REG); 241 ret = twl_rtc_read_u8(&save_control, REG_RTC_CTRL_REG);
240 if (ret < 0) 242 if (ret < 0) {
243 dev_err(dev, "%s: reading CTRL_REG, error %d\n", __func__, ret);
241 return ret; 244 return ret;
245 }
246 /* for twl6030/32 make sure BIT_RTC_CTRL_REG_GET_TIME_M is clear */
247 if (twl_class_is_6030()) {
248 if (save_control & BIT_RTC_CTRL_REG_GET_TIME_M) {
249 save_control &= ~BIT_RTC_CTRL_REG_GET_TIME_M;
250 ret = twl_rtc_write_u8(save_control, REG_RTC_CTRL_REG);
251 if (ret < 0) {
252 dev_err(dev, "%s clr GET_TIME, error %d\n",
253 __func__, ret);
254 return ret;
255 }
256 }
257 }
242 258
243 save_control |= BIT_RTC_CTRL_REG_GET_TIME_M; 259 /* Copy RTC counting registers to static registers or latches */
260 rtc_control = save_control | BIT_RTC_CTRL_REG_GET_TIME_M;
244 261
245 ret = twl_rtc_write_u8(save_control, REG_RTC_CTRL_REG); 262 /* for twl6030/32 enable read access to static shadowed registers */
246 if (ret < 0) 263 if (twl_class_is_6030())
264 rtc_control |= BIT_RTC_CTRL_REG_RTC_V_OPT;
265
266 ret = twl_rtc_write_u8(rtc_control, REG_RTC_CTRL_REG);
267 if (ret < 0) {
268 dev_err(dev, "%s: writing CTRL_REG, error %d\n", __func__, ret);
247 return ret; 269 return ret;
270 }
248 271
249 ret = twl_i2c_read(TWL_MODULE_RTC, rtc_data, 272 ret = twl_i2c_read(TWL_MODULE_RTC, rtc_data,
250 (rtc_reg_map[REG_SECONDS_REG]), ALL_TIME_REGS); 273 (rtc_reg_map[REG_SECONDS_REG]), ALL_TIME_REGS);
251 274
252 if (ret < 0) { 275 if (ret < 0) {
253 dev_err(dev, "rtc_read_time error %d\n", ret); 276 dev_err(dev, "%s: reading data, error %d\n", __func__, ret);
254 return ret; 277 return ret;
255 } 278 }
256 279
280 /* for twl6030 restore original state of rtc control register */
281 if (twl_class_is_6030()) {
282 ret = twl_rtc_write_u8(save_control, REG_RTC_CTRL_REG);
283 if (ret < 0) {
284 dev_err(dev, "%s: restore CTRL_REG, error %d\n",
285 __func__, ret);
286 return ret;
287 }
288 }
289
257 tm->tm_sec = bcd2bin(rtc_data[0]); 290 tm->tm_sec = bcd2bin(rtc_data[0]);
258 tm->tm_min = bcd2bin(rtc_data[1]); 291 tm->tm_min = bcd2bin(rtc_data[1]);
259 tm->tm_hour = bcd2bin(rtc_data[2]); 292 tm->tm_hour = bcd2bin(rtc_data[2]);
diff --git a/drivers/s390/block/dasd_eckd.c b/drivers/s390/block/dasd_eckd.c
index c21871a4e73d..bc2e8a7c265b 100644
--- a/drivers/s390/block/dasd_eckd.c
+++ b/drivers/s390/block/dasd_eckd.c
@@ -2844,6 +2844,7 @@ static struct dasd_ccw_req *dasd_eckd_build_cp_tpm_track(
2844 sector_t recid, trkid; 2844 sector_t recid, trkid;
2845 unsigned int offs; 2845 unsigned int offs;
2846 unsigned int count, count_to_trk_end; 2846 unsigned int count, count_to_trk_end;
2847 int ret;
2847 2848
2848 basedev = block->base; 2849 basedev = block->base;
2849 if (rq_data_dir(req) == READ) { 2850 if (rq_data_dir(req) == READ) {
@@ -2884,8 +2885,8 @@ static struct dasd_ccw_req *dasd_eckd_build_cp_tpm_track(
2884 2885
2885 itcw = itcw_init(cqr->data, itcw_size, itcw_op, 0, ctidaw, 0); 2886 itcw = itcw_init(cqr->data, itcw_size, itcw_op, 0, ctidaw, 0);
2886 if (IS_ERR(itcw)) { 2887 if (IS_ERR(itcw)) {
2887 dasd_sfree_request(cqr, startdev); 2888 ret = -EINVAL;
2888 return ERR_PTR(-EINVAL); 2889 goto out_error;
2889 } 2890 }
2890 cqr->cpaddr = itcw_get_tcw(itcw); 2891 cqr->cpaddr = itcw_get_tcw(itcw);
2891 if (prepare_itcw(itcw, first_trk, last_trk, 2892 if (prepare_itcw(itcw, first_trk, last_trk,
@@ -2897,8 +2898,8 @@ static struct dasd_ccw_req *dasd_eckd_build_cp_tpm_track(
2897 /* Clock not in sync and XRC is enabled. 2898 /* Clock not in sync and XRC is enabled.
2898 * Try again later. 2899 * Try again later.
2899 */ 2900 */
2900 dasd_sfree_request(cqr, startdev); 2901 ret = -EAGAIN;
2901 return ERR_PTR(-EAGAIN); 2902 goto out_error;
2902 } 2903 }
2903 len_to_track_end = 0; 2904 len_to_track_end = 0;
2904 /* 2905 /*
@@ -2937,8 +2938,10 @@ static struct dasd_ccw_req *dasd_eckd_build_cp_tpm_track(
2937 tidaw_flags = 0; 2938 tidaw_flags = 0;
2938 last_tidaw = itcw_add_tidaw(itcw, tidaw_flags, 2939 last_tidaw = itcw_add_tidaw(itcw, tidaw_flags,
2939 dst, part_len); 2940 dst, part_len);
2940 if (IS_ERR(last_tidaw)) 2941 if (IS_ERR(last_tidaw)) {
2941 return ERR_PTR(-EINVAL); 2942 ret = -EINVAL;
2943 goto out_error;
2944 }
2942 dst += part_len; 2945 dst += part_len;
2943 } 2946 }
2944 } 2947 }
@@ -2947,8 +2950,10 @@ static struct dasd_ccw_req *dasd_eckd_build_cp_tpm_track(
2947 dst = page_address(bv->bv_page) + bv->bv_offset; 2950 dst = page_address(bv->bv_page) + bv->bv_offset;
2948 last_tidaw = itcw_add_tidaw(itcw, 0x00, 2951 last_tidaw = itcw_add_tidaw(itcw, 0x00,
2949 dst, bv->bv_len); 2952 dst, bv->bv_len);
2950 if (IS_ERR(last_tidaw)) 2953 if (IS_ERR(last_tidaw)) {
2951 return ERR_PTR(-EINVAL); 2954 ret = -EINVAL;
2955 goto out_error;
2956 }
2952 } 2957 }
2953 } 2958 }
2954 last_tidaw->flags |= TIDAW_FLAGS_LAST; 2959 last_tidaw->flags |= TIDAW_FLAGS_LAST;
@@ -2968,6 +2973,9 @@ static struct dasd_ccw_req *dasd_eckd_build_cp_tpm_track(
2968 cqr->buildclk = get_clock(); 2973 cqr->buildclk = get_clock();
2969 cqr->status = DASD_CQR_FILLED; 2974 cqr->status = DASD_CQR_FILLED;
2970 return cqr; 2975 return cqr;
2976out_error:
2977 dasd_sfree_request(cqr, startdev);
2978 return ERR_PTR(ret);
2971} 2979}
2972 2980
2973static struct dasd_ccw_req *dasd_eckd_build_cp(struct dasd_device *startdev, 2981static struct dasd_ccw_req *dasd_eckd_build_cp(struct dasd_device *startdev,
diff --git a/drivers/s390/char/vmur.c b/drivers/s390/char/vmur.c
index 85f4a9a5d12e..73bef0bd394c 100644
--- a/drivers/s390/char/vmur.c
+++ b/drivers/s390/char/vmur.c
@@ -903,7 +903,7 @@ static int ur_set_online(struct ccw_device *cdev)
903 goto fail_urdev_put; 903 goto fail_urdev_put;
904 } 904 }
905 905
906 cdev_init(urd->char_device, &ur_fops); 906 urd->char_device->ops = &ur_fops;
907 urd->char_device->dev = MKDEV(major, minor); 907 urd->char_device->dev = MKDEV(major, minor);
908 urd->char_device->owner = ur_fops.owner; 908 urd->char_device->owner = ur_fops.owner;
909 909
diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c
index 2cfcbffa41fd..386f0c53bea7 100644
--- a/drivers/scsi/scsi_error.c
+++ b/drivers/scsi/scsi_error.c
@@ -835,7 +835,7 @@ static int scsi_send_eh_cmnd(struct scsi_cmnd *scmd, unsigned char *cmnd,
835 835
836 scsi_eh_restore_cmnd(scmd, &ses); 836 scsi_eh_restore_cmnd(scmd, &ses);
837 837
838 if (sdrv->eh_action) 838 if (sdrv && sdrv->eh_action)
839 rtn = sdrv->eh_action(scmd, cmnd, cmnd_size, rtn); 839 rtn = sdrv->eh_action(scmd, cmnd, cmnd_size, rtn);
840 840
841 return rtn; 841 return rtn;
diff --git a/drivers/spi/Kconfig b/drivers/spi/Kconfig
index 3ed748355b98..00c024039c97 100644
--- a/drivers/spi/Kconfig
+++ b/drivers/spi/Kconfig
@@ -74,7 +74,7 @@ config SPI_ATMEL
74 This selects a driver for the Atmel SPI Controller, present on 74 This selects a driver for the Atmel SPI Controller, present on
75 many AT32 (AVR32) and AT91 (ARM) chips. 75 many AT32 (AVR32) and AT91 (ARM) chips.
76 76
77config SPI_BFIN 77config SPI_BFIN5XX
78 tristate "SPI controller driver for ADI Blackfin5xx" 78 tristate "SPI controller driver for ADI Blackfin5xx"
79 depends on BLACKFIN 79 depends on BLACKFIN
80 help 80 help
diff --git a/drivers/spi/Makefile b/drivers/spi/Makefile
index a1d48e0ba3dc..9d75d2198ff5 100644
--- a/drivers/spi/Makefile
+++ b/drivers/spi/Makefile
@@ -15,7 +15,7 @@ obj-$(CONFIG_SPI_ATMEL) += spi-atmel.o
15obj-$(CONFIG_SPI_ATH79) += spi-ath79.o 15obj-$(CONFIG_SPI_ATH79) += spi-ath79.o
16obj-$(CONFIG_SPI_AU1550) += spi-au1550.o 16obj-$(CONFIG_SPI_AU1550) += spi-au1550.o
17obj-$(CONFIG_SPI_BCM63XX) += spi-bcm63xx.o 17obj-$(CONFIG_SPI_BCM63XX) += spi-bcm63xx.o
18obj-$(CONFIG_SPI_BFIN) += spi-bfin5xx.o 18obj-$(CONFIG_SPI_BFIN5XX) += spi-bfin5xx.o
19obj-$(CONFIG_SPI_BFIN_SPORT) += spi-bfin-sport.o 19obj-$(CONFIG_SPI_BFIN_SPORT) += spi-bfin-sport.o
20obj-$(CONFIG_SPI_BITBANG) += spi-bitbang.o 20obj-$(CONFIG_SPI_BITBANG) += spi-bitbang.o
21obj-$(CONFIG_SPI_BUTTERFLY) += spi-butterfly.o 21obj-$(CONFIG_SPI_BUTTERFLY) += spi-butterfly.o
diff --git a/drivers/spi/spi-bcm63xx.c b/drivers/spi/spi-bcm63xx.c
index f01b2648452e..7491971139a6 100644
--- a/drivers/spi/spi-bcm63xx.c
+++ b/drivers/spi/spi-bcm63xx.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * Broadcom BCM63xx SPI controller support 2 * Broadcom BCM63xx SPI controller support
3 * 3 *
4 * Copyright (C) 2009-2011 Florian Fainelli <florian@openwrt.org> 4 * Copyright (C) 2009-2012 Florian Fainelli <florian@openwrt.org>
5 * Copyright (C) 2010 Tanguy Bouzeloc <tanguy.bouzeloc@efixo.com> 5 * Copyright (C) 2010 Tanguy Bouzeloc <tanguy.bouzeloc@efixo.com>
6 * 6 *
7 * This program is free software; you can redistribute it and/or 7 * This program is free software; you can redistribute it and/or
@@ -30,6 +30,8 @@
30#include <linux/spi/spi.h> 30#include <linux/spi/spi.h>
31#include <linux/completion.h> 31#include <linux/completion.h>
32#include <linux/err.h> 32#include <linux/err.h>
33#include <linux/workqueue.h>
34#include <linux/pm_runtime.h>
33 35
34#include <bcm63xx_dev_spi.h> 36#include <bcm63xx_dev_spi.h>
35 37
@@ -37,8 +39,6 @@
37#define DRV_VER "0.1.2" 39#define DRV_VER "0.1.2"
38 40
39struct bcm63xx_spi { 41struct bcm63xx_spi {
40 spinlock_t lock;
41 int stopping;
42 struct completion done; 42 struct completion done;
43 43
44 void __iomem *regs; 44 void __iomem *regs;
@@ -96,17 +96,12 @@ static const unsigned bcm63xx_spi_freq_table[SPI_CLK_MASK][2] = {
96 { 391000, SPI_CLK_0_391MHZ } 96 { 391000, SPI_CLK_0_391MHZ }
97}; 97};
98 98
99static int bcm63xx_spi_setup_transfer(struct spi_device *spi, 99static int bcm63xx_spi_check_transfer(struct spi_device *spi,
100 struct spi_transfer *t) 100 struct spi_transfer *t)
101{ 101{
102 struct bcm63xx_spi *bs = spi_master_get_devdata(spi->master);
103 u8 bits_per_word; 102 u8 bits_per_word;
104 u8 clk_cfg, reg;
105 u32 hz;
106 int i;
107 103
108 bits_per_word = (t) ? t->bits_per_word : spi->bits_per_word; 104 bits_per_word = (t) ? t->bits_per_word : spi->bits_per_word;
109 hz = (t) ? t->speed_hz : spi->max_speed_hz;
110 if (bits_per_word != 8) { 105 if (bits_per_word != 8) {
111 dev_err(&spi->dev, "%s, unsupported bits_per_word=%d\n", 106 dev_err(&spi->dev, "%s, unsupported bits_per_word=%d\n",
112 __func__, bits_per_word); 107 __func__, bits_per_word);
@@ -119,6 +114,19 @@ static int bcm63xx_spi_setup_transfer(struct spi_device *spi,
119 return -EINVAL; 114 return -EINVAL;
120 } 115 }
121 116
117 return 0;
118}
119
120static void bcm63xx_spi_setup_transfer(struct spi_device *spi,
121 struct spi_transfer *t)
122{
123 struct bcm63xx_spi *bs = spi_master_get_devdata(spi->master);
124 u32 hz;
125 u8 clk_cfg, reg;
126 int i;
127
128 hz = (t) ? t->speed_hz : spi->max_speed_hz;
129
122 /* Find the closest clock configuration */ 130 /* Find the closest clock configuration */
123 for (i = 0; i < SPI_CLK_MASK; i++) { 131 for (i = 0; i < SPI_CLK_MASK; i++) {
124 if (hz <= bcm63xx_spi_freq_table[i][0]) { 132 if (hz <= bcm63xx_spi_freq_table[i][0]) {
@@ -139,8 +147,6 @@ static int bcm63xx_spi_setup_transfer(struct spi_device *spi,
139 bcm_spi_writeb(bs, reg, SPI_CLK_CFG); 147 bcm_spi_writeb(bs, reg, SPI_CLK_CFG);
140 dev_dbg(&spi->dev, "Setting clock register to %02x (hz %d)\n", 148 dev_dbg(&spi->dev, "Setting clock register to %02x (hz %d)\n",
141 clk_cfg, hz); 149 clk_cfg, hz);
142
143 return 0;
144} 150}
145 151
146/* the spi->mode bits understood by this driver: */ 152/* the spi->mode bits understood by this driver: */
@@ -153,9 +159,6 @@ static int bcm63xx_spi_setup(struct spi_device *spi)
153 159
154 bs = spi_master_get_devdata(spi->master); 160 bs = spi_master_get_devdata(spi->master);
155 161
156 if (bs->stopping)
157 return -ESHUTDOWN;
158
159 if (!spi->bits_per_word) 162 if (!spi->bits_per_word)
160 spi->bits_per_word = 8; 163 spi->bits_per_word = 8;
161 164
@@ -165,7 +168,7 @@ static int bcm63xx_spi_setup(struct spi_device *spi)
165 return -EINVAL; 168 return -EINVAL;
166 } 169 }
167 170
168 ret = bcm63xx_spi_setup_transfer(spi, NULL); 171 ret = bcm63xx_spi_check_transfer(spi, NULL);
169 if (ret < 0) { 172 if (ret < 0) {
170 dev_err(&spi->dev, "setup: unsupported mode bits %x\n", 173 dev_err(&spi->dev, "setup: unsupported mode bits %x\n",
171 spi->mode & ~MODEBITS); 174 spi->mode & ~MODEBITS);
@@ -190,28 +193,29 @@ static void bcm63xx_spi_fill_tx_fifo(struct bcm63xx_spi *bs)
190 bs->remaining_bytes -= size; 193 bs->remaining_bytes -= size;
191} 194}
192 195
193static int bcm63xx_txrx_bufs(struct spi_device *spi, struct spi_transfer *t) 196static unsigned int bcm63xx_txrx_bufs(struct spi_device *spi,
197 struct spi_transfer *t)
194{ 198{
195 struct bcm63xx_spi *bs = spi_master_get_devdata(spi->master); 199 struct bcm63xx_spi *bs = spi_master_get_devdata(spi->master);
196 u16 msg_ctl; 200 u16 msg_ctl;
197 u16 cmd; 201 u16 cmd;
198 202
203 /* Disable the CMD_DONE interrupt */
204 bcm_spi_writeb(bs, 0, SPI_INT_MASK);
205
199 dev_dbg(&spi->dev, "txrx: tx %p, rx %p, len %d\n", 206 dev_dbg(&spi->dev, "txrx: tx %p, rx %p, len %d\n",
200 t->tx_buf, t->rx_buf, t->len); 207 t->tx_buf, t->rx_buf, t->len);
201 208
202 /* Transmitter is inhibited */ 209 /* Transmitter is inhibited */
203 bs->tx_ptr = t->tx_buf; 210 bs->tx_ptr = t->tx_buf;
204 bs->rx_ptr = t->rx_buf; 211 bs->rx_ptr = t->rx_buf;
205 init_completion(&bs->done);
206 212
207 if (t->tx_buf) { 213 if (t->tx_buf) {
208 bs->remaining_bytes = t->len; 214 bs->remaining_bytes = t->len;
209 bcm63xx_spi_fill_tx_fifo(bs); 215 bcm63xx_spi_fill_tx_fifo(bs);
210 } 216 }
211 217
212 /* Enable the command done interrupt which 218 init_completion(&bs->done);
213 * we use to determine completion of a command */
214 bcm_spi_writeb(bs, SPI_INTR_CMD_DONE, SPI_INT_MASK);
215 219
216 /* Fill in the Message control register */ 220 /* Fill in the Message control register */
217 msg_ctl = (t->len << SPI_BYTE_CNT_SHIFT); 221 msg_ctl = (t->len << SPI_BYTE_CNT_SHIFT);
@@ -230,33 +234,76 @@ static int bcm63xx_txrx_bufs(struct spi_device *spi, struct spi_transfer *t)
230 cmd |= (0 << SPI_CMD_PREPEND_BYTE_CNT_SHIFT); 234 cmd |= (0 << SPI_CMD_PREPEND_BYTE_CNT_SHIFT);
231 cmd |= (spi->chip_select << SPI_CMD_DEVICE_ID_SHIFT); 235 cmd |= (spi->chip_select << SPI_CMD_DEVICE_ID_SHIFT);
232 bcm_spi_writew(bs, cmd, SPI_CMD); 236 bcm_spi_writew(bs, cmd, SPI_CMD);
233 wait_for_completion(&bs->done);
234 237
235 /* Disable the CMD_DONE interrupt */ 238 /* Enable the CMD_DONE interrupt */
236 bcm_spi_writeb(bs, 0, SPI_INT_MASK); 239 bcm_spi_writeb(bs, SPI_INTR_CMD_DONE, SPI_INT_MASK);
237 240
238 return t->len - bs->remaining_bytes; 241 return t->len - bs->remaining_bytes;
239} 242}
240 243
241static int bcm63xx_transfer(struct spi_device *spi, struct spi_message *m) 244static int bcm63xx_spi_prepare_transfer(struct spi_master *master)
242{ 245{
243 struct bcm63xx_spi *bs = spi_master_get_devdata(spi->master); 246 struct bcm63xx_spi *bs = spi_master_get_devdata(master);
244 struct spi_transfer *t;
245 int ret = 0;
246 247
247 if (unlikely(list_empty(&m->transfers))) 248 pm_runtime_get_sync(&bs->pdev->dev);
248 return -EINVAL;
249 249
250 if (bs->stopping) 250 return 0;
251 return -ESHUTDOWN; 251}
252
253static int bcm63xx_spi_unprepare_transfer(struct spi_master *master)
254{
255 struct bcm63xx_spi *bs = spi_master_get_devdata(master);
256
257 pm_runtime_put(&bs->pdev->dev);
258
259 return 0;
260}
261
262static int bcm63xx_spi_transfer_one(struct spi_master *master,
263 struct spi_message *m)
264{
265 struct bcm63xx_spi *bs = spi_master_get_devdata(master);
266 struct spi_transfer *t;
267 struct spi_device *spi = m->spi;
268 int status = 0;
269 unsigned int timeout = 0;
252 270
253 list_for_each_entry(t, &m->transfers, transfer_list) { 271 list_for_each_entry(t, &m->transfers, transfer_list) {
254 ret += bcm63xx_txrx_bufs(spi, t); 272 unsigned int len = t->len;
255 } 273 u8 rx_tail;
256 274
257 m->complete(m->context); 275 status = bcm63xx_spi_check_transfer(spi, t);
276 if (status < 0)
277 goto exit;
258 278
259 return ret; 279 /* configure adapter for a new transfer */
280 bcm63xx_spi_setup_transfer(spi, t);
281
282 while (len) {
283 /* send the data */
284 len -= bcm63xx_txrx_bufs(spi, t);
285
286 timeout = wait_for_completion_timeout(&bs->done, HZ);
287 if (!timeout) {
288 status = -ETIMEDOUT;
289 goto exit;
290 }
291
292 /* read out all data */
293 rx_tail = bcm_spi_readb(bs, SPI_RX_TAIL);
294
295 /* Read out all the data */
296 if (rx_tail)
297 memcpy_fromio(bs->rx_ptr, bs->rx_io, rx_tail);
298 }
299
300 m->actual_length += t->len;
301 }
302exit:
303 m->status = status;
304 spi_finalize_current_message(master);
305
306 return 0;
260} 307}
261 308
262/* This driver supports single master mode only. Hence 309/* This driver supports single master mode only. Hence
@@ -267,39 +314,15 @@ static irqreturn_t bcm63xx_spi_interrupt(int irq, void *dev_id)
267 struct spi_master *master = (struct spi_master *)dev_id; 314 struct spi_master *master = (struct spi_master *)dev_id;
268 struct bcm63xx_spi *bs = spi_master_get_devdata(master); 315 struct bcm63xx_spi *bs = spi_master_get_devdata(master);
269 u8 intr; 316 u8 intr;
270 u16 cmd;
271 317
272 /* Read interupts and clear them immediately */ 318 /* Read interupts and clear them immediately */
273 intr = bcm_spi_readb(bs, SPI_INT_STATUS); 319 intr = bcm_spi_readb(bs, SPI_INT_STATUS);
274 bcm_spi_writeb(bs, SPI_INTR_CLEAR_ALL, SPI_INT_STATUS); 320 bcm_spi_writeb(bs, SPI_INTR_CLEAR_ALL, SPI_INT_STATUS);
275 bcm_spi_writeb(bs, 0, SPI_INT_MASK); 321 bcm_spi_writeb(bs, 0, SPI_INT_MASK);
276 322
277 /* A tansfer completed */ 323 /* A transfer completed */
278 if (intr & SPI_INTR_CMD_DONE) { 324 if (intr & SPI_INTR_CMD_DONE)
279 u8 rx_tail; 325 complete(&bs->done);
280
281 rx_tail = bcm_spi_readb(bs, SPI_RX_TAIL);
282
283 /* Read out all the data */
284 if (rx_tail)
285 memcpy_fromio(bs->rx_ptr, bs->rx_io, rx_tail);
286
287 /* See if there is more data to send */
288 if (bs->remaining_bytes > 0) {
289 bcm63xx_spi_fill_tx_fifo(bs);
290
291 /* Start the transfer */
292 bcm_spi_writew(bs, SPI_HD_W << SPI_MSG_TYPE_SHIFT,
293 SPI_MSG_CTL);
294 cmd = bcm_spi_readw(bs, SPI_CMD);
295 cmd |= SPI_CMD_START_IMMEDIATE;
296 cmd |= (0 << SPI_CMD_PREPEND_BYTE_CNT_SHIFT);
297 bcm_spi_writeb(bs, SPI_INTR_CMD_DONE, SPI_INT_MASK);
298 bcm_spi_writew(bs, cmd, SPI_CMD);
299 } else {
300 complete(&bs->done);
301 }
302 }
303 326
304 return IRQ_HANDLED; 327 return IRQ_HANDLED;
305} 328}
@@ -345,7 +368,6 @@ static int __devinit bcm63xx_spi_probe(struct platform_device *pdev)
345 } 368 }
346 369
347 bs = spi_master_get_devdata(master); 370 bs = spi_master_get_devdata(master);
348 init_completion(&bs->done);
349 371
350 platform_set_drvdata(pdev, master); 372 platform_set_drvdata(pdev, master);
351 bs->pdev = pdev; 373 bs->pdev = pdev;
@@ -379,12 +401,13 @@ static int __devinit bcm63xx_spi_probe(struct platform_device *pdev)
379 master->bus_num = pdata->bus_num; 401 master->bus_num = pdata->bus_num;
380 master->num_chipselect = pdata->num_chipselect; 402 master->num_chipselect = pdata->num_chipselect;
381 master->setup = bcm63xx_spi_setup; 403 master->setup = bcm63xx_spi_setup;
382 master->transfer = bcm63xx_transfer; 404 master->prepare_transfer_hardware = bcm63xx_spi_prepare_transfer;
405 master->unprepare_transfer_hardware = bcm63xx_spi_unprepare_transfer;
406 master->transfer_one_message = bcm63xx_spi_transfer_one;
407 master->mode_bits = MODEBITS;
383 bs->speed_hz = pdata->speed_hz; 408 bs->speed_hz = pdata->speed_hz;
384 bs->stopping = 0;
385 bs->tx_io = (u8 *)(bs->regs + bcm63xx_spireg(SPI_MSG_DATA)); 409 bs->tx_io = (u8 *)(bs->regs + bcm63xx_spireg(SPI_MSG_DATA));
386 bs->rx_io = (const u8 *)(bs->regs + bcm63xx_spireg(SPI_RX_DATA)); 410 bs->rx_io = (const u8 *)(bs->regs + bcm63xx_spireg(SPI_RX_DATA));
387 spin_lock_init(&bs->lock);
388 411
389 /* Initialize hardware */ 412 /* Initialize hardware */
390 clk_enable(bs->clk); 413 clk_enable(bs->clk);
@@ -418,18 +441,16 @@ static int __devexit bcm63xx_spi_remove(struct platform_device *pdev)
418 struct spi_master *master = platform_get_drvdata(pdev); 441 struct spi_master *master = platform_get_drvdata(pdev);
419 struct bcm63xx_spi *bs = spi_master_get_devdata(master); 442 struct bcm63xx_spi *bs = spi_master_get_devdata(master);
420 443
444 spi_unregister_master(master);
445
421 /* reset spi block */ 446 /* reset spi block */
422 bcm_spi_writeb(bs, 0, SPI_INT_MASK); 447 bcm_spi_writeb(bs, 0, SPI_INT_MASK);
423 spin_lock(&bs->lock);
424 bs->stopping = 1;
425 448
426 /* HW shutdown */ 449 /* HW shutdown */
427 clk_disable(bs->clk); 450 clk_disable(bs->clk);
428 clk_put(bs->clk); 451 clk_put(bs->clk);
429 452
430 spin_unlock(&bs->lock);
431 platform_set_drvdata(pdev, 0); 453 platform_set_drvdata(pdev, 0);
432 spi_unregister_master(master);
433 454
434 return 0; 455 return 0;
435} 456}
diff --git a/drivers/spi/spi-bfin-sport.c b/drivers/spi/spi-bfin-sport.c
index 248a2cc671a9..1fe51198a622 100644
--- a/drivers/spi/spi-bfin-sport.c
+++ b/drivers/spi/spi-bfin-sport.c
@@ -252,19 +252,15 @@ static void
252bfin_sport_spi_restore_state(struct bfin_sport_spi_master_data *drv_data) 252bfin_sport_spi_restore_state(struct bfin_sport_spi_master_data *drv_data)
253{ 253{
254 struct bfin_sport_spi_slave_data *chip = drv_data->cur_chip; 254 struct bfin_sport_spi_slave_data *chip = drv_data->cur_chip;
255 unsigned int bits = (drv_data->ops == &bfin_sport_transfer_ops_u8 ? 7 : 15);
256 255
257 bfin_sport_spi_disable(drv_data); 256 bfin_sport_spi_disable(drv_data);
258 dev_dbg(drv_data->dev, "restoring spi ctl state\n"); 257 dev_dbg(drv_data->dev, "restoring spi ctl state\n");
259 258
260 bfin_write(&drv_data->regs->tcr1, chip->ctl_reg); 259 bfin_write(&drv_data->regs->tcr1, chip->ctl_reg);
261 bfin_write(&drv_data->regs->tcr2, bits);
262 bfin_write(&drv_data->regs->tclkdiv, chip->baud); 260 bfin_write(&drv_data->regs->tclkdiv, chip->baud);
263 bfin_write(&drv_data->regs->tfsdiv, bits);
264 SSYNC(); 261 SSYNC();
265 262
266 bfin_write(&drv_data->regs->rcr1, chip->ctl_reg & ~(ITCLK | ITFS)); 263 bfin_write(&drv_data->regs->rcr1, chip->ctl_reg & ~(ITCLK | ITFS));
267 bfin_write(&drv_data->regs->rcr2, bits);
268 SSYNC(); 264 SSYNC();
269 265
270 bfin_sport_spi_cs_active(chip); 266 bfin_sport_spi_cs_active(chip);
@@ -420,11 +416,15 @@ bfin_sport_spi_pump_transfers(unsigned long data)
420 drv_data->cs_change = transfer->cs_change; 416 drv_data->cs_change = transfer->cs_change;
421 417
422 /* Bits per word setup */ 418 /* Bits per word setup */
423 bits_per_word = transfer->bits_per_word ? : message->spi->bits_per_word; 419 bits_per_word = transfer->bits_per_word ? :
424 if (bits_per_word == 8) 420 message->spi->bits_per_word ? : 8;
425 drv_data->ops = &bfin_sport_transfer_ops_u8; 421 if (bits_per_word % 16 == 0)
426 else
427 drv_data->ops = &bfin_sport_transfer_ops_u16; 422 drv_data->ops = &bfin_sport_transfer_ops_u16;
423 else
424 drv_data->ops = &bfin_sport_transfer_ops_u8;
425 bfin_write(&drv_data->regs->tcr2, bits_per_word - 1);
426 bfin_write(&drv_data->regs->tfsdiv, bits_per_word - 1);
427 bfin_write(&drv_data->regs->rcr2, bits_per_word - 1);
428 428
429 drv_data->state = RUNNING_STATE; 429 drv_data->state = RUNNING_STATE;
430 430
@@ -598,11 +598,12 @@ bfin_sport_spi_setup(struct spi_device *spi)
598 } 598 }
599 chip->cs_chg_udelay = chip_info->cs_chg_udelay; 599 chip->cs_chg_udelay = chip_info->cs_chg_udelay;
600 chip->idle_tx_val = chip_info->idle_tx_val; 600 chip->idle_tx_val = chip_info->idle_tx_val;
601 spi->bits_per_word = chip_info->bits_per_word;
602 } 601 }
603 } 602 }
604 603
605 if (spi->bits_per_word != 8 && spi->bits_per_word != 16) { 604 if (spi->bits_per_word % 8) {
605 dev_err(&spi->dev, "%d bits_per_word is not supported\n",
606 spi->bits_per_word);
606 ret = -EINVAL; 607 ret = -EINVAL;
607 goto error; 608 goto error;
608 } 609 }
diff --git a/drivers/spi/spi-bfin5xx.c b/drivers/spi/spi-bfin5xx.c
index 3b83ff8b1e2b..9bb4d4af8547 100644
--- a/drivers/spi/spi-bfin5xx.c
+++ b/drivers/spi/spi-bfin5xx.c
@@ -396,7 +396,7 @@ static irqreturn_t bfin_spi_pio_irq_handler(int irq, void *dev_id)
396 /* last read */ 396 /* last read */
397 if (drv_data->rx) { 397 if (drv_data->rx) {
398 dev_dbg(&drv_data->pdev->dev, "last read\n"); 398 dev_dbg(&drv_data->pdev->dev, "last read\n");
399 if (n_bytes % 2) { 399 if (!(n_bytes % 2)) {
400 u16 *buf = (u16 *)drv_data->rx; 400 u16 *buf = (u16 *)drv_data->rx;
401 for (loop = 0; loop < n_bytes / 2; loop++) 401 for (loop = 0; loop < n_bytes / 2; loop++)
402 *buf++ = bfin_read(&drv_data->regs->rdbr); 402 *buf++ = bfin_read(&drv_data->regs->rdbr);
@@ -424,7 +424,7 @@ static irqreturn_t bfin_spi_pio_irq_handler(int irq, void *dev_id)
424 if (drv_data->rx && drv_data->tx) { 424 if (drv_data->rx && drv_data->tx) {
425 /* duplex */ 425 /* duplex */
426 dev_dbg(&drv_data->pdev->dev, "duplex: write_TDBR\n"); 426 dev_dbg(&drv_data->pdev->dev, "duplex: write_TDBR\n");
427 if (n_bytes % 2) { 427 if (!(n_bytes % 2)) {
428 u16 *buf = (u16 *)drv_data->rx; 428 u16 *buf = (u16 *)drv_data->rx;
429 u16 *buf2 = (u16 *)drv_data->tx; 429 u16 *buf2 = (u16 *)drv_data->tx;
430 for (loop = 0; loop < n_bytes / 2; loop++) { 430 for (loop = 0; loop < n_bytes / 2; loop++) {
@@ -442,7 +442,7 @@ static irqreturn_t bfin_spi_pio_irq_handler(int irq, void *dev_id)
442 } else if (drv_data->rx) { 442 } else if (drv_data->rx) {
443 /* read */ 443 /* read */
444 dev_dbg(&drv_data->pdev->dev, "read: write_TDBR\n"); 444 dev_dbg(&drv_data->pdev->dev, "read: write_TDBR\n");
445 if (n_bytes % 2) { 445 if (!(n_bytes % 2)) {
446 u16 *buf = (u16 *)drv_data->rx; 446 u16 *buf = (u16 *)drv_data->rx;
447 for (loop = 0; loop < n_bytes / 2; loop++) { 447 for (loop = 0; loop < n_bytes / 2; loop++) {
448 *buf++ = bfin_read(&drv_data->regs->rdbr); 448 *buf++ = bfin_read(&drv_data->regs->rdbr);
@@ -458,7 +458,7 @@ static irqreturn_t bfin_spi_pio_irq_handler(int irq, void *dev_id)
458 } else if (drv_data->tx) { 458 } else if (drv_data->tx) {
459 /* write */ 459 /* write */
460 dev_dbg(&drv_data->pdev->dev, "write: write_TDBR\n"); 460 dev_dbg(&drv_data->pdev->dev, "write: write_TDBR\n");
461 if (n_bytes % 2) { 461 if (!(n_bytes % 2)) {
462 u16 *buf = (u16 *)drv_data->tx; 462 u16 *buf = (u16 *)drv_data->tx;
463 for (loop = 0; loop < n_bytes / 2; loop++) { 463 for (loop = 0; loop < n_bytes / 2; loop++) {
464 bfin_read(&drv_data->regs->rdbr); 464 bfin_read(&drv_data->regs->rdbr);
@@ -587,6 +587,7 @@ static void bfin_spi_pump_transfers(unsigned long data)
587 if (message->state == DONE_STATE) { 587 if (message->state == DONE_STATE) {
588 dev_dbg(&drv_data->pdev->dev, "transfer: all done!\n"); 588 dev_dbg(&drv_data->pdev->dev, "transfer: all done!\n");
589 message->status = 0; 589 message->status = 0;
590 bfin_spi_flush(drv_data);
590 bfin_spi_giveback(drv_data); 591 bfin_spi_giveback(drv_data);
591 return; 592 return;
592 } 593 }
@@ -870,8 +871,10 @@ static void bfin_spi_pump_transfers(unsigned long data)
870 message->actual_length += drv_data->len_in_bytes; 871 message->actual_length += drv_data->len_in_bytes;
871 /* Move to next transfer of this msg */ 872 /* Move to next transfer of this msg */
872 message->state = bfin_spi_next_transfer(drv_data); 873 message->state = bfin_spi_next_transfer(drv_data);
873 if (drv_data->cs_change) 874 if (drv_data->cs_change && message->state != DONE_STATE) {
875 bfin_spi_flush(drv_data);
874 bfin_spi_cs_deactive(drv_data, chip); 876 bfin_spi_cs_deactive(drv_data, chip);
877 }
875 } 878 }
876 879
877 /* Schedule next transfer tasklet */ 880 /* Schedule next transfer tasklet */
@@ -1026,7 +1029,6 @@ static int bfin_spi_setup(struct spi_device *spi)
1026 chip->cs_chg_udelay = chip_info->cs_chg_udelay; 1029 chip->cs_chg_udelay = chip_info->cs_chg_udelay;
1027 chip->idle_tx_val = chip_info->idle_tx_val; 1030 chip->idle_tx_val = chip_info->idle_tx_val;
1028 chip->pio_interrupt = chip_info->pio_interrupt; 1031 chip->pio_interrupt = chip_info->pio_interrupt;
1029 spi->bits_per_word = chip_info->bits_per_word;
1030 } else { 1032 } else {
1031 /* force a default base state */ 1033 /* force a default base state */
1032 chip->ctl_reg &= bfin_ctl_reg; 1034 chip->ctl_reg &= bfin_ctl_reg;
diff --git a/drivers/spi/spi-davinci.c b/drivers/spi/spi-davinci.c
index 31bfba805cf4..9b2901feaf78 100644
--- a/drivers/spi/spi-davinci.c
+++ b/drivers/spi/spi-davinci.c
@@ -653,7 +653,7 @@ static int davinci_spi_bufs(struct spi_device *spi, struct spi_transfer *t)
653 dev_dbg(sdev, "Couldn't DMA map a %d bytes RX buffer\n", 653 dev_dbg(sdev, "Couldn't DMA map a %d bytes RX buffer\n",
654 rx_buf_count); 654 rx_buf_count);
655 if (t->tx_buf) 655 if (t->tx_buf)
656 dma_unmap_single(NULL, t->tx_dma, t->len, 656 dma_unmap_single(&spi->dev, t->tx_dma, t->len,
657 DMA_TO_DEVICE); 657 DMA_TO_DEVICE);
658 return -ENOMEM; 658 return -ENOMEM;
659 } 659 }
@@ -692,10 +692,10 @@ static int davinci_spi_bufs(struct spi_device *spi, struct spi_transfer *t)
692 if (spicfg->io_type == SPI_IO_TYPE_DMA) { 692 if (spicfg->io_type == SPI_IO_TYPE_DMA) {
693 693
694 if (t->tx_buf) 694 if (t->tx_buf)
695 dma_unmap_single(NULL, t->tx_dma, t->len, 695 dma_unmap_single(&spi->dev, t->tx_dma, t->len,
696 DMA_TO_DEVICE); 696 DMA_TO_DEVICE);
697 697
698 dma_unmap_single(NULL, t->rx_dma, rx_buf_count, 698 dma_unmap_single(&spi->dev, t->rx_dma, rx_buf_count,
699 DMA_FROM_DEVICE); 699 DMA_FROM_DEVICE);
700 700
701 clear_io_bits(dspi->base + SPIINT, SPIINT_DMA_REQ_EN); 701 clear_io_bits(dspi->base + SPIINT, SPIINT_DMA_REQ_EN);
diff --git a/drivers/spi/spi-ep93xx.c b/drivers/spi/spi-ep93xx.c
index 6db2887852d6..e8055073e84d 100644
--- a/drivers/spi/spi-ep93xx.c
+++ b/drivers/spi/spi-ep93xx.c
@@ -545,13 +545,12 @@ static void ep93xx_spi_pio_transfer(struct ep93xx_spi *espi)
545 * in case of failure. 545 * in case of failure.
546 */ 546 */
547static struct dma_async_tx_descriptor * 547static struct dma_async_tx_descriptor *
548ep93xx_spi_dma_prepare(struct ep93xx_spi *espi, enum dma_data_direction dir) 548ep93xx_spi_dma_prepare(struct ep93xx_spi *espi, enum dma_transfer_direction dir)
549{ 549{
550 struct spi_transfer *t = espi->current_msg->state; 550 struct spi_transfer *t = espi->current_msg->state;
551 struct dma_async_tx_descriptor *txd; 551 struct dma_async_tx_descriptor *txd;
552 enum dma_slave_buswidth buswidth; 552 enum dma_slave_buswidth buswidth;
553 struct dma_slave_config conf; 553 struct dma_slave_config conf;
554 enum dma_transfer_direction slave_dirn;
555 struct scatterlist *sg; 554 struct scatterlist *sg;
556 struct sg_table *sgt; 555 struct sg_table *sgt;
557 struct dma_chan *chan; 556 struct dma_chan *chan;
@@ -567,14 +566,13 @@ ep93xx_spi_dma_prepare(struct ep93xx_spi *espi, enum dma_data_direction dir)
567 memset(&conf, 0, sizeof(conf)); 566 memset(&conf, 0, sizeof(conf));
568 conf.direction = dir; 567 conf.direction = dir;
569 568
570 if (dir == DMA_FROM_DEVICE) { 569 if (dir == DMA_DEV_TO_MEM) {
571 chan = espi->dma_rx; 570 chan = espi->dma_rx;
572 buf = t->rx_buf; 571 buf = t->rx_buf;
573 sgt = &espi->rx_sgt; 572 sgt = &espi->rx_sgt;
574 573
575 conf.src_addr = espi->sspdr_phys; 574 conf.src_addr = espi->sspdr_phys;
576 conf.src_addr_width = buswidth; 575 conf.src_addr_width = buswidth;
577 slave_dirn = DMA_DEV_TO_MEM;
578 } else { 576 } else {
579 chan = espi->dma_tx; 577 chan = espi->dma_tx;
580 buf = t->tx_buf; 578 buf = t->tx_buf;
@@ -582,7 +580,6 @@ ep93xx_spi_dma_prepare(struct ep93xx_spi *espi, enum dma_data_direction dir)
582 580
583 conf.dst_addr = espi->sspdr_phys; 581 conf.dst_addr = espi->sspdr_phys;
584 conf.dst_addr_width = buswidth; 582 conf.dst_addr_width = buswidth;
585 slave_dirn = DMA_MEM_TO_DEV;
586 } 583 }
587 584
588 ret = dmaengine_slave_config(chan, &conf); 585 ret = dmaengine_slave_config(chan, &conf);
@@ -633,8 +630,7 @@ ep93xx_spi_dma_prepare(struct ep93xx_spi *espi, enum dma_data_direction dir)
633 if (!nents) 630 if (!nents)
634 return ERR_PTR(-ENOMEM); 631 return ERR_PTR(-ENOMEM);
635 632
636 txd = dmaengine_prep_slave_sg(chan, sgt->sgl, nents, 633 txd = dmaengine_prep_slave_sg(chan, sgt->sgl, nents, dir, DMA_CTRL_ACK);
637 slave_dirn, DMA_CTRL_ACK);
638 if (!txd) { 634 if (!txd) {
639 dma_unmap_sg(chan->device->dev, sgt->sgl, sgt->nents, dir); 635 dma_unmap_sg(chan->device->dev, sgt->sgl, sgt->nents, dir);
640 return ERR_PTR(-ENOMEM); 636 return ERR_PTR(-ENOMEM);
@@ -651,12 +647,12 @@ ep93xx_spi_dma_prepare(struct ep93xx_spi *espi, enum dma_data_direction dir)
651 * unmapped. 647 * unmapped.
652 */ 648 */
653static void ep93xx_spi_dma_finish(struct ep93xx_spi *espi, 649static void ep93xx_spi_dma_finish(struct ep93xx_spi *espi,
654 enum dma_data_direction dir) 650 enum dma_transfer_direction dir)
655{ 651{
656 struct dma_chan *chan; 652 struct dma_chan *chan;
657 struct sg_table *sgt; 653 struct sg_table *sgt;
658 654
659 if (dir == DMA_FROM_DEVICE) { 655 if (dir == DMA_DEV_TO_MEM) {
660 chan = espi->dma_rx; 656 chan = espi->dma_rx;
661 sgt = &espi->rx_sgt; 657 sgt = &espi->rx_sgt;
662 } else { 658 } else {
@@ -677,16 +673,16 @@ static void ep93xx_spi_dma_transfer(struct ep93xx_spi *espi)
677 struct spi_message *msg = espi->current_msg; 673 struct spi_message *msg = espi->current_msg;
678 struct dma_async_tx_descriptor *rxd, *txd; 674 struct dma_async_tx_descriptor *rxd, *txd;
679 675
680 rxd = ep93xx_spi_dma_prepare(espi, DMA_FROM_DEVICE); 676 rxd = ep93xx_spi_dma_prepare(espi, DMA_DEV_TO_MEM);
681 if (IS_ERR(rxd)) { 677 if (IS_ERR(rxd)) {
682 dev_err(&espi->pdev->dev, "DMA RX failed: %ld\n", PTR_ERR(rxd)); 678 dev_err(&espi->pdev->dev, "DMA RX failed: %ld\n", PTR_ERR(rxd));
683 msg->status = PTR_ERR(rxd); 679 msg->status = PTR_ERR(rxd);
684 return; 680 return;
685 } 681 }
686 682
687 txd = ep93xx_spi_dma_prepare(espi, DMA_TO_DEVICE); 683 txd = ep93xx_spi_dma_prepare(espi, DMA_MEM_TO_DEV);
688 if (IS_ERR(txd)) { 684 if (IS_ERR(txd)) {
689 ep93xx_spi_dma_finish(espi, DMA_FROM_DEVICE); 685 ep93xx_spi_dma_finish(espi, DMA_DEV_TO_MEM);
690 dev_err(&espi->pdev->dev, "DMA TX failed: %ld\n", PTR_ERR(rxd)); 686 dev_err(&espi->pdev->dev, "DMA TX failed: %ld\n", PTR_ERR(rxd));
691 msg->status = PTR_ERR(txd); 687 msg->status = PTR_ERR(txd);
692 return; 688 return;
@@ -705,8 +701,8 @@ static void ep93xx_spi_dma_transfer(struct ep93xx_spi *espi)
705 701
706 wait_for_completion(&espi->wait); 702 wait_for_completion(&espi->wait);
707 703
708 ep93xx_spi_dma_finish(espi, DMA_TO_DEVICE); 704 ep93xx_spi_dma_finish(espi, DMA_MEM_TO_DEV);
709 ep93xx_spi_dma_finish(espi, DMA_FROM_DEVICE); 705 ep93xx_spi_dma_finish(espi, DMA_DEV_TO_MEM);
710} 706}
711 707
712/** 708/**
diff --git a/drivers/spi/spi-fsl-spi.c b/drivers/spi/spi-fsl-spi.c
index 24cacff57786..5f748c0d96bd 100644
--- a/drivers/spi/spi-fsl-spi.c
+++ b/drivers/spi/spi-fsl-spi.c
@@ -139,10 +139,12 @@ static void fsl_spi_change_mode(struct spi_device *spi)
139static void fsl_spi_chipselect(struct spi_device *spi, int value) 139static void fsl_spi_chipselect(struct spi_device *spi, int value)
140{ 140{
141 struct mpc8xxx_spi *mpc8xxx_spi = spi_master_get_devdata(spi->master); 141 struct mpc8xxx_spi *mpc8xxx_spi = spi_master_get_devdata(spi->master);
142 struct fsl_spi_platform_data *pdata = spi->dev.parent->platform_data; 142 struct fsl_spi_platform_data *pdata;
143 bool pol = spi->mode & SPI_CS_HIGH; 143 bool pol = spi->mode & SPI_CS_HIGH;
144 struct spi_mpc8xxx_cs *cs = spi->controller_state; 144 struct spi_mpc8xxx_cs *cs = spi->controller_state;
145 145
146 pdata = spi->dev.parent->parent->platform_data;
147
146 if (value == BITBANG_CS_INACTIVE) { 148 if (value == BITBANG_CS_INACTIVE) {
147 if (pdata->cs_control) 149 if (pdata->cs_control)
148 pdata->cs_control(spi, !pol); 150 pdata->cs_control(spi, !pol);
diff --git a/drivers/spi/spi-imx.c b/drivers/spi/spi-imx.c
index 31054e3de4c1..570f22053be8 100644
--- a/drivers/spi/spi-imx.c
+++ b/drivers/spi/spi-imx.c
@@ -83,7 +83,7 @@ struct spi_imx_data {
83 struct spi_bitbang bitbang; 83 struct spi_bitbang bitbang;
84 84
85 struct completion xfer_done; 85 struct completion xfer_done;
86 void *base; 86 void __iomem *base;
87 int irq; 87 int irq;
88 struct clk *clk; 88 struct clk *clk;
89 unsigned long spi_clk; 89 unsigned long spi_clk;
@@ -766,8 +766,12 @@ static int __devinit spi_imx_probe(struct platform_device *pdev)
766 } 766 }
767 767
768 ret = of_property_read_u32(np, "fsl,spi-num-chipselects", &num_cs); 768 ret = of_property_read_u32(np, "fsl,spi-num-chipselects", &num_cs);
769 if (ret < 0) 769 if (ret < 0) {
770 num_cs = mxc_platform_info->num_chipselect; 770 if (mxc_platform_info)
771 num_cs = mxc_platform_info->num_chipselect;
772 else
773 return ret;
774 }
771 775
772 master = spi_alloc_master(&pdev->dev, 776 master = spi_alloc_master(&pdev->dev,
773 sizeof(struct spi_imx_data) + sizeof(int) * num_cs); 777 sizeof(struct spi_imx_data) + sizeof(int) * num_cs);
@@ -784,7 +788,7 @@ static int __devinit spi_imx_probe(struct platform_device *pdev)
784 788
785 for (i = 0; i < master->num_chipselect; i++) { 789 for (i = 0; i < master->num_chipselect; i++) {
786 int cs_gpio = of_get_named_gpio(np, "cs-gpios", i); 790 int cs_gpio = of_get_named_gpio(np, "cs-gpios", i);
787 if (cs_gpio < 0) 791 if (cs_gpio < 0 && mxc_platform_info)
788 cs_gpio = mxc_platform_info->chipselect[i]; 792 cs_gpio = mxc_platform_info->chipselect[i];
789 793
790 spi_imx->chipselect[i] = cs_gpio; 794 spi_imx->chipselect[i] = cs_gpio;
diff --git a/drivers/spi/spi-pl022.c b/drivers/spi/spi-pl022.c
index 96f0da66b185..400ae2121a2a 100644
--- a/drivers/spi/spi-pl022.c
+++ b/drivers/spi/spi-pl022.c
@@ -1667,9 +1667,15 @@ static int calculate_effective_freq(struct pl022 *pl022, int freq, struct
1667 /* cpsdvsr = 254 & scr = 255 */ 1667 /* cpsdvsr = 254 & scr = 255 */
1668 min_tclk = spi_rate(rate, CPSDVR_MAX, SCR_MAX); 1668 min_tclk = spi_rate(rate, CPSDVR_MAX, SCR_MAX);
1669 1669
1670 if (!((freq <= max_tclk) && (freq >= min_tclk))) { 1670 if (freq > max_tclk)
1671 dev_warn(&pl022->adev->dev,
1672 "Max speed that can be programmed is %d Hz, you requested %d\n",
1673 max_tclk, freq);
1674
1675 if (freq < min_tclk) {
1671 dev_err(&pl022->adev->dev, 1676 dev_err(&pl022->adev->dev,
1672 "controller data is incorrect: out of range frequency"); 1677 "Requested frequency: %d Hz is less than minimum possible %d Hz\n",
1678 freq, min_tclk);
1673 return -EINVAL; 1679 return -EINVAL;
1674 } 1680 }
1675 1681
@@ -1681,26 +1687,37 @@ static int calculate_effective_freq(struct pl022 *pl022, int freq, struct
1681 while (scr <= SCR_MAX) { 1687 while (scr <= SCR_MAX) {
1682 tmp = spi_rate(rate, cpsdvsr, scr); 1688 tmp = spi_rate(rate, cpsdvsr, scr);
1683 1689
1684 if (tmp > freq) 1690 if (tmp > freq) {
1691 /* we need lower freq */
1685 scr++; 1692 scr++;
1693 continue;
1694 }
1695
1686 /* 1696 /*
1687 * If found exact value, update and break. 1697 * If found exact value, mark found and break.
1688 * If found more closer value, update and continue. 1698 * If found more closer value, update and break.
1689 */ 1699 */
1690 else if ((tmp == freq) || (tmp > best_freq)) { 1700 if (tmp > best_freq) {
1691 best_freq = tmp; 1701 best_freq = tmp;
1692 best_cpsdvsr = cpsdvsr; 1702 best_cpsdvsr = cpsdvsr;
1693 best_scr = scr; 1703 best_scr = scr;
1694 1704
1695 if (tmp == freq) 1705 if (tmp == freq)
1696 break; 1706 found = 1;
1697 } 1707 }
1698 scr++; 1708 /*
1709 * increased scr will give lower rates, which are not
1710 * required
1711 */
1712 break;
1699 } 1713 }
1700 cpsdvsr += 2; 1714 cpsdvsr += 2;
1701 scr = SCR_MIN; 1715 scr = SCR_MIN;
1702 } 1716 }
1703 1717
1718 WARN(!best_freq, "pl022: Matching cpsdvsr and scr not found for %d Hz rate \n",
1719 freq);
1720
1704 clk_freq->cpsdvsr = (u8) (best_cpsdvsr & 0xFF); 1721 clk_freq->cpsdvsr = (u8) (best_cpsdvsr & 0xFF);
1705 clk_freq->scr = (u8) (best_scr & 0xFF); 1722 clk_freq->scr = (u8) (best_scr & 0xFF);
1706 dev_dbg(&pl022->adev->dev, 1723 dev_dbg(&pl022->adev->dev,
@@ -1823,9 +1840,12 @@ static int pl022_setup(struct spi_device *spi)
1823 } else 1840 } else
1824 chip->cs_control = chip_info->cs_control; 1841 chip->cs_control = chip_info->cs_control;
1825 1842
1826 if (bits <= 3) { 1843 /* Check bits per word with vendor specific range */
1827 /* PL022 doesn't support less than 4-bits */ 1844 if ((bits <= 3) || (bits > pl022->vendor->max_bpw)) {
1828 status = -ENOTSUPP; 1845 status = -ENOTSUPP;
1846 dev_err(&spi->dev, "illegal data size for this controller!\n");
1847 dev_err(&spi->dev, "This controller can only handle 4 <= n <= %d bit words\n",
1848 pl022->vendor->max_bpw);
1829 goto err_config_params; 1849 goto err_config_params;
1830 } else if (bits <= 8) { 1850 } else if (bits <= 8) {
1831 dev_dbg(&spi->dev, "4 <= n <=8 bits per word\n"); 1851 dev_dbg(&spi->dev, "4 <= n <=8 bits per word\n");
@@ -1838,20 +1858,10 @@ static int pl022_setup(struct spi_device *spi)
1838 chip->read = READING_U16; 1858 chip->read = READING_U16;
1839 chip->write = WRITING_U16; 1859 chip->write = WRITING_U16;
1840 } else { 1860 } else {
1841 if (pl022->vendor->max_bpw >= 32) { 1861 dev_dbg(&spi->dev, "17 <= n <= 32 bits per word\n");
1842 dev_dbg(&spi->dev, "17 <= n <= 32 bits per word\n"); 1862 chip->n_bytes = 4;
1843 chip->n_bytes = 4; 1863 chip->read = READING_U32;
1844 chip->read = READING_U32; 1864 chip->write = WRITING_U32;
1845 chip->write = WRITING_U32;
1846 } else {
1847 dev_err(&spi->dev,
1848 "illegal data size for this controller!\n");
1849 dev_err(&spi->dev,
1850 "a standard pl022 can only handle "
1851 "1 <= n <= 16 bit words\n");
1852 status = -ENOTSUPP;
1853 goto err_config_params;
1854 }
1855 } 1865 }
1856 1866
1857 /* Now Initialize all register settings required for this chip */ 1867 /* Now Initialize all register settings required for this chip */
@@ -2195,7 +2205,6 @@ static int pl022_runtime_suspend(struct device *dev)
2195 struct pl022 *pl022 = dev_get_drvdata(dev); 2205 struct pl022 *pl022 = dev_get_drvdata(dev);
2196 2206
2197 clk_disable(pl022->clk); 2207 clk_disable(pl022->clk);
2198 amba_vcore_disable(pl022->adev);
2199 2208
2200 return 0; 2209 return 0;
2201} 2210}
@@ -2204,7 +2213,6 @@ static int pl022_runtime_resume(struct device *dev)
2204{ 2213{
2205 struct pl022 *pl022 = dev_get_drvdata(dev); 2214 struct pl022 *pl022 = dev_get_drvdata(dev);
2206 2215
2207 amba_vcore_enable(pl022->adev);
2208 clk_enable(pl022->clk); 2216 clk_enable(pl022->clk);
2209 2217
2210 return 0; 2218 return 0;
diff --git a/drivers/staging/android/Kconfig b/drivers/staging/android/Kconfig
index 60dc7108c8b3..c706635f3f82 100644
--- a/drivers/staging/android/Kconfig
+++ b/drivers/staging/android/Kconfig
@@ -27,13 +27,14 @@ config ANDROID_LOGGER
27 27
28config ANDROID_PERSISTENT_RAM 28config ANDROID_PERSISTENT_RAM
29 bool 29 bool
30 depends on HAVE_MEMBLOCK
30 select REED_SOLOMON 31 select REED_SOLOMON
31 select REED_SOLOMON_ENC8 32 select REED_SOLOMON_ENC8
32 select REED_SOLOMON_DEC8 33 select REED_SOLOMON_DEC8
33 34
34config ANDROID_RAM_CONSOLE 35config ANDROID_RAM_CONSOLE
35 bool "Android RAM buffer console" 36 bool "Android RAM buffer console"
36 depends on !S390 && !UML 37 depends on !S390 && !UML && HAVE_MEMBLOCK
37 select ANDROID_PERSISTENT_RAM 38 select ANDROID_PERSISTENT_RAM
38 default n 39 default n
39 40
diff --git a/drivers/staging/android/lowmemorykiller.c b/drivers/staging/android/lowmemorykiller.c
index 052b43e4e505..b91e4bc332a7 100644
--- a/drivers/staging/android/lowmemorykiller.c
+++ b/drivers/staging/android/lowmemorykiller.c
@@ -55,7 +55,6 @@ static int lowmem_minfree[6] = {
55}; 55};
56static int lowmem_minfree_size = 4; 56static int lowmem_minfree_size = 4;
57 57
58static struct task_struct *lowmem_deathpending;
59static unsigned long lowmem_deathpending_timeout; 58static unsigned long lowmem_deathpending_timeout;
60 59
61#define lowmem_print(level, x...) \ 60#define lowmem_print(level, x...) \
@@ -64,24 +63,6 @@ static unsigned long lowmem_deathpending_timeout;
64 printk(x); \ 63 printk(x); \
65 } while (0) 64 } while (0)
66 65
67static int
68task_notify_func(struct notifier_block *self, unsigned long val, void *data);
69
70static struct notifier_block task_nb = {
71 .notifier_call = task_notify_func,
72};
73
74static int
75task_notify_func(struct notifier_block *self, unsigned long val, void *data)
76{
77 struct task_struct *task = data;
78
79 if (task == lowmem_deathpending)
80 lowmem_deathpending = NULL;
81
82 return NOTIFY_OK;
83}
84
85static int lowmem_shrink(struct shrinker *s, struct shrink_control *sc) 66static int lowmem_shrink(struct shrinker *s, struct shrink_control *sc)
86{ 67{
87 struct task_struct *tsk; 68 struct task_struct *tsk;
@@ -97,19 +78,6 @@ static int lowmem_shrink(struct shrinker *s, struct shrink_control *sc)
97 int other_file = global_page_state(NR_FILE_PAGES) - 78 int other_file = global_page_state(NR_FILE_PAGES) -
98 global_page_state(NR_SHMEM); 79 global_page_state(NR_SHMEM);
99 80
100 /*
101 * If we already have a death outstanding, then
102 * bail out right away; indicating to vmscan
103 * that we have nothing further to offer on
104 * this pass.
105 *
106 * Note: Currently you need CONFIG_PROFILING
107 * for this to work correctly.
108 */
109 if (lowmem_deathpending &&
110 time_before_eq(jiffies, lowmem_deathpending_timeout))
111 return 0;
112
113 if (lowmem_adj_size < array_size) 81 if (lowmem_adj_size < array_size)
114 array_size = lowmem_adj_size; 82 array_size = lowmem_adj_size;
115 if (lowmem_minfree_size < array_size) 83 if (lowmem_minfree_size < array_size)
@@ -148,6 +116,12 @@ static int lowmem_shrink(struct shrinker *s, struct shrink_control *sc)
148 if (!p) 116 if (!p)
149 continue; 117 continue;
150 118
119 if (test_tsk_thread_flag(p, TIF_MEMDIE) &&
120 time_before_eq(jiffies, lowmem_deathpending_timeout)) {
121 task_unlock(p);
122 rcu_read_unlock();
123 return 0;
124 }
151 oom_score_adj = p->signal->oom_score_adj; 125 oom_score_adj = p->signal->oom_score_adj;
152 if (oom_score_adj < min_score_adj) { 126 if (oom_score_adj < min_score_adj) {
153 task_unlock(p); 127 task_unlock(p);
@@ -174,15 +148,9 @@ static int lowmem_shrink(struct shrinker *s, struct shrink_control *sc)
174 lowmem_print(1, "send sigkill to %d (%s), adj %d, size %d\n", 148 lowmem_print(1, "send sigkill to %d (%s), adj %d, size %d\n",
175 selected->pid, selected->comm, 149 selected->pid, selected->comm,
176 selected_oom_score_adj, selected_tasksize); 150 selected_oom_score_adj, selected_tasksize);
177 /*
178 * If CONFIG_PROFILING is off, then we don't want to stall
179 * the killer by setting lowmem_deathpending.
180 */
181#ifdef CONFIG_PROFILING
182 lowmem_deathpending = selected;
183 lowmem_deathpending_timeout = jiffies + HZ; 151 lowmem_deathpending_timeout = jiffies + HZ;
184#endif
185 send_sig(SIGKILL, selected, 0); 152 send_sig(SIGKILL, selected, 0);
153 set_tsk_thread_flag(selected, TIF_MEMDIE);
186 rem -= selected_tasksize; 154 rem -= selected_tasksize;
187 } 155 }
188 lowmem_print(4, "lowmem_shrink %lu, %x, return %d\n", 156 lowmem_print(4, "lowmem_shrink %lu, %x, return %d\n",
@@ -198,7 +166,6 @@ static struct shrinker lowmem_shrinker = {
198 166
199static int __init lowmem_init(void) 167static int __init lowmem_init(void)
200{ 168{
201 task_handoff_register(&task_nb);
202 register_shrinker(&lowmem_shrinker); 169 register_shrinker(&lowmem_shrinker);
203 return 0; 170 return 0;
204} 171}
@@ -206,7 +173,6 @@ static int __init lowmem_init(void)
206static void __exit lowmem_exit(void) 173static void __exit lowmem_exit(void)
207{ 174{
208 unregister_shrinker(&lowmem_shrinker); 175 unregister_shrinker(&lowmem_shrinker);
209 task_handoff_unregister(&task_nb);
210} 176}
211 177
212module_param_named(cost, lowmem_shrinker.seeks, int, S_IRUGO | S_IWUSR); 178module_param_named(cost, lowmem_shrinker.seeks, int, S_IRUGO | S_IWUSR);
diff --git a/drivers/staging/android/persistent_ram.c b/drivers/staging/android/persistent_ram.c
index e08f2574e30a..8d8c1e33e0ff 100644
--- a/drivers/staging/android/persistent_ram.c
+++ b/drivers/staging/android/persistent_ram.c
@@ -399,12 +399,12 @@ static __init
399struct persistent_ram_zone *__persistent_ram_init(struct device *dev, bool ecc) 399struct persistent_ram_zone *__persistent_ram_init(struct device *dev, bool ecc)
400{ 400{
401 struct persistent_ram_zone *prz; 401 struct persistent_ram_zone *prz;
402 int ret; 402 int ret = -ENOMEM;
403 403
404 prz = kzalloc(sizeof(struct persistent_ram_zone), GFP_KERNEL); 404 prz = kzalloc(sizeof(struct persistent_ram_zone), GFP_KERNEL);
405 if (!prz) { 405 if (!prz) {
406 pr_err("persistent_ram: failed to allocate persistent ram zone\n"); 406 pr_err("persistent_ram: failed to allocate persistent ram zone\n");
407 return ERR_PTR(-ENOMEM); 407 goto err;
408 } 408 }
409 409
410 INIT_LIST_HEAD(&prz->node); 410 INIT_LIST_HEAD(&prz->node);
@@ -412,13 +412,13 @@ struct persistent_ram_zone *__persistent_ram_init(struct device *dev, bool ecc)
412 ret = persistent_ram_buffer_init(dev_name(dev), prz); 412 ret = persistent_ram_buffer_init(dev_name(dev), prz);
413 if (ret) { 413 if (ret) {
414 pr_err("persistent_ram: failed to initialize buffer\n"); 414 pr_err("persistent_ram: failed to initialize buffer\n");
415 return ERR_PTR(ret); 415 goto err;
416 } 416 }
417 417
418 prz->ecc = ecc; 418 prz->ecc = ecc;
419 ret = persistent_ram_init_ecc(prz, prz->buffer_size); 419 ret = persistent_ram_init_ecc(prz, prz->buffer_size);
420 if (ret) 420 if (ret)
421 return ERR_PTR(ret); 421 goto err;
422 422
423 if (prz->buffer->sig == PERSISTENT_RAM_SIG) { 423 if (prz->buffer->sig == PERSISTENT_RAM_SIG) {
424 if (buffer_size(prz) > prz->buffer_size || 424 if (buffer_size(prz) > prz->buffer_size ||
@@ -442,6 +442,9 @@ struct persistent_ram_zone *__persistent_ram_init(struct device *dev, bool ecc)
442 atomic_set(&prz->buffer->size, 0); 442 atomic_set(&prz->buffer->size, 0);
443 443
444 return prz; 444 return prz;
445err:
446 kfree(prz);
447 return ERR_PTR(ret);
445} 448}
446 449
447struct persistent_ram_zone * __init 450struct persistent_ram_zone * __init
diff --git a/drivers/staging/android/timed_gpio.c b/drivers/staging/android/timed_gpio.c
index bc723eff11af..45c522cbe784 100644
--- a/drivers/staging/android/timed_gpio.c
+++ b/drivers/staging/android/timed_gpio.c
@@ -85,7 +85,7 @@ static int timed_gpio_probe(struct platform_device *pdev)
85 struct timed_gpio_platform_data *pdata = pdev->dev.platform_data; 85 struct timed_gpio_platform_data *pdata = pdev->dev.platform_data;
86 struct timed_gpio *cur_gpio; 86 struct timed_gpio *cur_gpio;
87 struct timed_gpio_data *gpio_data, *gpio_dat; 87 struct timed_gpio_data *gpio_data, *gpio_dat;
88 int i, j, ret = 0; 88 int i, ret;
89 89
90 if (!pdata) 90 if (!pdata)
91 return -EBUSY; 91 return -EBUSY;
@@ -108,18 +108,12 @@ static int timed_gpio_probe(struct platform_device *pdev)
108 gpio_dat->dev.get_time = gpio_get_time; 108 gpio_dat->dev.get_time = gpio_get_time;
109 gpio_dat->dev.enable = gpio_enable; 109 gpio_dat->dev.enable = gpio_enable;
110 ret = gpio_request(cur_gpio->gpio, cur_gpio->name); 110 ret = gpio_request(cur_gpio->gpio, cur_gpio->name);
111 if (ret >= 0) { 111 if (ret < 0)
112 ret = timed_output_dev_register(&gpio_dat->dev); 112 goto err_out;
113 if (ret < 0) 113 ret = timed_output_dev_register(&gpio_dat->dev);
114 gpio_free(cur_gpio->gpio);
115 }
116 if (ret < 0) { 114 if (ret < 0) {
117 for (j = 0; j < i; j++) { 115 gpio_free(cur_gpio->gpio);
118 timed_output_dev_unregister(&gpio_data[i].dev); 116 goto err_out;
119 gpio_free(gpio_data[i].gpio);
120 }
121 kfree(gpio_data);
122 return ret;
123 } 117 }
124 118
125 gpio_dat->gpio = cur_gpio->gpio; 119 gpio_dat->gpio = cur_gpio->gpio;
@@ -131,6 +125,15 @@ static int timed_gpio_probe(struct platform_device *pdev)
131 platform_set_drvdata(pdev, gpio_data); 125 platform_set_drvdata(pdev, gpio_data);
132 126
133 return 0; 127 return 0;
128
129err_out:
130 while (--i >= 0) {
131 timed_output_dev_unregister(&gpio_data[i].dev);
132 gpio_free(gpio_data[i].gpio);
133 }
134 kfree(gpio_data);
135
136 return ret;
134} 137}
135 138
136static int timed_gpio_remove(struct platform_device *pdev) 139static int timed_gpio_remove(struct platform_device *pdev)
diff --git a/drivers/staging/iio/inkern.c b/drivers/staging/iio/inkern.c
index de2c8ea64965..ef07a02bf542 100644
--- a/drivers/staging/iio/inkern.c
+++ b/drivers/staging/iio/inkern.c
@@ -82,6 +82,7 @@ int iio_map_array_unregister(struct iio_dev *indio_dev,
82 ret = -ENODEV; 82 ret = -ENODEV;
83 goto error_ret; 83 goto error_ret;
84 } 84 }
85 i++;
85 } 86 }
86error_ret: 87error_ret:
87 mutex_unlock(&iio_map_list_lock); 88 mutex_unlock(&iio_map_list_lock);
diff --git a/drivers/staging/iio/magnetometer/ak8975.c b/drivers/staging/iio/magnetometer/ak8975.c
index d5ddac3d8831..ebc2d0840caf 100644
--- a/drivers/staging/iio/magnetometer/ak8975.c
+++ b/drivers/staging/iio/magnetometer/ak8975.c
@@ -108,7 +108,8 @@ static const int ak8975_index_to_reg[] = {
108static int ak8975_write_data(struct i2c_client *client, 108static int ak8975_write_data(struct i2c_client *client,
109 u8 reg, u8 val, u8 mask, u8 shift) 109 u8 reg, u8 val, u8 mask, u8 shift)
110{ 110{
111 struct ak8975_data *data = i2c_get_clientdata(client); 111 struct iio_dev *indio_dev = i2c_get_clientdata(client);
112 struct ak8975_data *data = iio_priv(indio_dev);
112 u8 regval; 113 u8 regval;
113 int ret; 114 int ret;
114 115
@@ -159,7 +160,8 @@ static int ak8975_read_data(struct i2c_client *client,
159 */ 160 */
160static int ak8975_setup(struct i2c_client *client) 161static int ak8975_setup(struct i2c_client *client)
161{ 162{
162 struct ak8975_data *data = i2c_get_clientdata(client); 163 struct iio_dev *indio_dev = i2c_get_clientdata(client);
164 struct ak8975_data *data = iio_priv(indio_dev);
163 u8 device_id; 165 u8 device_id;
164 int ret; 166 int ret;
165 167
@@ -509,6 +511,7 @@ static int ak8975_probe(struct i2c_client *client,
509 goto exit_gpio; 511 goto exit_gpio;
510 } 512 }
511 data = iio_priv(indio_dev); 513 data = iio_priv(indio_dev);
514 i2c_set_clientdata(client, indio_dev);
512 /* Perform some basic start-of-day setup of the device. */ 515 /* Perform some basic start-of-day setup of the device. */
513 err = ak8975_setup(client); 516 err = ak8975_setup(client);
514 if (err < 0) { 517 if (err < 0) {
@@ -516,7 +519,6 @@ static int ak8975_probe(struct i2c_client *client,
516 goto exit_free_iio; 519 goto exit_free_iio;
517 } 520 }
518 521
519 i2c_set_clientdata(client, indio_dev);
520 data->client = client; 522 data->client = client;
521 mutex_init(&data->lock); 523 mutex_init(&data->lock);
522 data->eoc_irq = client->irq; 524 data->eoc_irq = client->irq;
diff --git a/drivers/staging/iio/magnetometer/hmc5843.c b/drivers/staging/iio/magnetometer/hmc5843.c
index 91dd3da70cb4..e00b416c4d33 100644
--- a/drivers/staging/iio/magnetometer/hmc5843.c
+++ b/drivers/staging/iio/magnetometer/hmc5843.c
@@ -521,7 +521,9 @@ static int hmc5843_detect(struct i2c_client *client,
521/* Called when we have found a new HMC5843. */ 521/* Called when we have found a new HMC5843. */
522static void hmc5843_init_client(struct i2c_client *client) 522static void hmc5843_init_client(struct i2c_client *client)
523{ 523{
524 struct hmc5843_data *data = i2c_get_clientdata(client); 524 struct iio_dev *indio_dev = i2c_get_clientdata(client);
525 struct hmc5843_data *data = iio_priv(indio_dev);
526
525 hmc5843_set_meas_conf(client, data->meas_conf); 527 hmc5843_set_meas_conf(client, data->meas_conf);
526 hmc5843_set_rate(client, data->rate); 528 hmc5843_set_rate(client, data->rate);
527 hmc5843_configure(client, data->operating_mode); 529 hmc5843_configure(client, data->operating_mode);
diff --git a/drivers/staging/media/as102/as102_fw.c b/drivers/staging/media/as102/as102_fw.c
index 43ebc43e6b9a..1075fb1df0d9 100644
--- a/drivers/staging/media/as102/as102_fw.c
+++ b/drivers/staging/media/as102/as102_fw.c
@@ -165,7 +165,7 @@ error:
165int as102_fw_upload(struct as10x_bus_adapter_t *bus_adap) 165int as102_fw_upload(struct as10x_bus_adapter_t *bus_adap)
166{ 166{
167 int errno = -EFAULT; 167 int errno = -EFAULT;
168 const struct firmware *firmware; 168 const struct firmware *firmware = NULL;
169 unsigned char *cmd_buf = NULL; 169 unsigned char *cmd_buf = NULL;
170 char *fw1, *fw2; 170 char *fw1, *fw2;
171 struct usb_device *dev = bus_adap->usb_dev; 171 struct usb_device *dev = bus_adap->usb_dev;
diff --git a/drivers/staging/octeon/ethernet-rx.c b/drivers/staging/octeon/ethernet-rx.c
index 400df8cbee53..d91751f9ffe8 100644
--- a/drivers/staging/octeon/ethernet-rx.c
+++ b/drivers/staging/octeon/ethernet-rx.c
@@ -36,6 +36,7 @@
36#include <linux/prefetch.h> 36#include <linux/prefetch.h>
37#include <linux/ratelimit.h> 37#include <linux/ratelimit.h>
38#include <linux/smp.h> 38#include <linux/smp.h>
39#include <linux/interrupt.h>
39#include <net/dst.h> 40#include <net/dst.h>
40#ifdef CONFIG_XFRM 41#ifdef CONFIG_XFRM
41#include <linux/xfrm.h> 42#include <linux/xfrm.h>
diff --git a/drivers/staging/octeon/ethernet-tx.c b/drivers/staging/octeon/ethernet-tx.c
index 56d74dc2fbd5..91a97b3e45c6 100644
--- a/drivers/staging/octeon/ethernet-tx.c
+++ b/drivers/staging/octeon/ethernet-tx.c
@@ -32,6 +32,7 @@
32#include <linux/ip.h> 32#include <linux/ip.h>
33#include <linux/ratelimit.h> 33#include <linux/ratelimit.h>
34#include <linux/string.h> 34#include <linux/string.h>
35#include <linux/interrupt.h>
35#include <net/dst.h> 36#include <net/dst.h>
36#ifdef CONFIG_XFRM 37#ifdef CONFIG_XFRM
37#include <linux/xfrm.h> 38#include <linux/xfrm.h>
diff --git a/drivers/staging/octeon/ethernet.c b/drivers/staging/octeon/ethernet.c
index 9112cd882154..60cba8194de3 100644
--- a/drivers/staging/octeon/ethernet.c
+++ b/drivers/staging/octeon/ethernet.c
@@ -31,6 +31,7 @@
31#include <linux/etherdevice.h> 31#include <linux/etherdevice.h>
32#include <linux/phy.h> 32#include <linux/phy.h>
33#include <linux/slab.h> 33#include <linux/slab.h>
34#include <linux/interrupt.h>
34 35
35#include <net/dst.h> 36#include <net/dst.h>
36 37
diff --git a/drivers/staging/omapdrm/omap_drv.c b/drivers/staging/omapdrm/omap_drv.c
index 3df5b4c58ecd..620b8d54223d 100644
--- a/drivers/staging/omapdrm/omap_drv.c
+++ b/drivers/staging/omapdrm/omap_drv.c
@@ -803,9 +803,6 @@ static void pdev_shutdown(struct platform_device *device)
803static int pdev_probe(struct platform_device *device) 803static int pdev_probe(struct platform_device *device)
804{ 804{
805 DBG("%s", device->name); 805 DBG("%s", device->name);
806 if (platform_driver_register(&omap_dmm_driver))
807 dev_err(&device->dev, "DMM registration failed\n");
808
809 return drm_platform_init(&omap_drm_driver, device); 806 return drm_platform_init(&omap_drm_driver, device);
810} 807}
811 808
@@ -833,6 +830,10 @@ struct platform_driver pdev = {
833static int __init omap_drm_init(void) 830static int __init omap_drm_init(void)
834{ 831{
835 DBG("init"); 832 DBG("init");
833 if (platform_driver_register(&omap_dmm_driver)) {
834 /* we can continue on without DMM.. so not fatal */
835 dev_err(NULL, "DMM registration failed\n");
836 }
836 return platform_driver_register(&pdev); 837 return platform_driver_register(&pdev);
837} 838}
838 839
diff --git a/drivers/staging/ozwpan/TODO b/drivers/staging/ozwpan/TODO
index f7a9c122f596..c2d30a7112f3 100644
--- a/drivers/staging/ozwpan/TODO
+++ b/drivers/staging/ozwpan/TODO
@@ -8,5 +8,7 @@ TODO:
8 - code review by USB developer community. 8 - code review by USB developer community.
9 - testing with as many devices as possible. 9 - testing with as many devices as possible.
10 10
11Please send any patches for this driver to Chris Kelly <ckelly@ozmodevices.com> 11Please send any patches for this driver to
12Rupesh Gujare <rgujare@ozmodevices.com>
13Chris Kelly <ckelly@ozmodevices.com>
12and Greg Kroah-Hartman <gregkh@linuxfoundation.org>. 14and Greg Kroah-Hartman <gregkh@linuxfoundation.org>.
diff --git a/drivers/staging/ozwpan/ozpd.c b/drivers/staging/ozwpan/ozpd.c
index 2b45d3d1800c..04cd57f2a6da 100644
--- a/drivers/staging/ozwpan/ozpd.c
+++ b/drivers/staging/ozwpan/ozpd.c
@@ -383,8 +383,6 @@ static void oz_tx_frame_free(struct oz_pd *pd, struct oz_tx_frame *f)
383 pd->tx_pool = &f->link; 383 pd->tx_pool = &f->link;
384 pd->tx_pool_count++; 384 pd->tx_pool_count++;
385 f = 0; 385 f = 0;
386 } else {
387 kfree(f);
388 } 386 }
389 spin_unlock_bh(&pd->tx_frame_lock); 387 spin_unlock_bh(&pd->tx_frame_lock);
390 if (f) 388 if (f)
diff --git a/drivers/staging/ramster/Kconfig b/drivers/staging/ramster/Kconfig
index 8b57b87edda4..4af1f8d4b953 100644
--- a/drivers/staging/ramster/Kconfig
+++ b/drivers/staging/ramster/Kconfig
@@ -1,10 +1,6 @@
1# Dependency on CONFIG_BROKEN is because there is a commit dependency
2# on a cleancache naming change to be submitted by Konrad Wilk
3# a39c00ded70339603ffe1b0ffdf3ade85bcf009a "Merge branch 'stable/cleancache.v13'
4# into linux-next. Once this commit is present, BROKEN can be removed
5config RAMSTER 1config RAMSTER
6 bool "Cross-machine RAM capacity sharing, aka peer-to-peer tmem" 2 bool "Cross-machine RAM capacity sharing, aka peer-to-peer tmem"
7 depends on (CLEANCACHE || FRONTSWAP) && CONFIGFS_FS=y && !ZCACHE && !XVMALLOC && !HIGHMEM && BROKEN 3 depends on (CLEANCACHE || FRONTSWAP) && CONFIGFS_FS=y && !ZCACHE && !XVMALLOC && !HIGHMEM
8 select LZO_COMPRESS 4 select LZO_COMPRESS
9 select LZO_DECOMPRESS 5 select LZO_DECOMPRESS
10 default n 6 default n
diff --git a/drivers/staging/rts_pstor/ms.c b/drivers/staging/rts_pstor/ms.c
index 66341dff8c99..f9a4498984cc 100644
--- a/drivers/staging/rts_pstor/ms.c
+++ b/drivers/staging/rts_pstor/ms.c
@@ -3498,7 +3498,8 @@ static int ms_rw_multi_sector(struct scsi_cmnd *srb, struct rtsx_chip *chip, u32
3498 3498
3499 log_blk++; 3499 log_blk++;
3500 3500
3501 for (seg_no = 0; seg_no < sizeof(ms_start_idx)/2; seg_no++) { 3501 for (seg_no = 0; seg_no < ARRAY_SIZE(ms_start_idx) - 1;
3502 seg_no++) {
3502 if (log_blk < ms_start_idx[seg_no+1]) 3503 if (log_blk < ms_start_idx[seg_no+1])
3503 break; 3504 break;
3504 } 3505 }
diff --git a/drivers/staging/rts_pstor/rtsx.c b/drivers/staging/rts_pstor/rtsx.c
index a7feb3e328a0..1dccd933a7e4 100644
--- a/drivers/staging/rts_pstor/rtsx.c
+++ b/drivers/staging/rts_pstor/rtsx.c
@@ -1000,6 +1000,11 @@ static int __devinit rtsx_probe(struct pci_dev *pci,
1000 1000
1001 rtsx_init_chip(dev->chip); 1001 rtsx_init_chip(dev->chip);
1002 1002
1003 /* set the supported max_lun and max_id for the scsi host
1004 * NOTE: the minimal value of max_id is 1 */
1005 host->max_id = 1;
1006 host->max_lun = dev->chip->max_lun;
1007
1003 /* Start up our control thread */ 1008 /* Start up our control thread */
1004 th = kthread_run(rtsx_control_thread, dev, CR_DRIVER_NAME); 1009 th = kthread_run(rtsx_control_thread, dev, CR_DRIVER_NAME);
1005 if (IS_ERR(th)) { 1010 if (IS_ERR(th)) {
diff --git a/drivers/staging/rts_pstor/rtsx_transport.c b/drivers/staging/rts_pstor/rtsx_transport.c
index 4e3d2c106af0..9b2e5c99870f 100644
--- a/drivers/staging/rts_pstor/rtsx_transport.c
+++ b/drivers/staging/rts_pstor/rtsx_transport.c
@@ -335,6 +335,7 @@ static int rtsx_transfer_sglist_adma_partial(struct rtsx_chip *chip, u8 card,
335 int sg_cnt, i, resid; 335 int sg_cnt, i, resid;
336 int err = 0; 336 int err = 0;
337 long timeleft; 337 long timeleft;
338 struct scatterlist *sg_ptr;
338 u32 val = TRIG_DMA; 339 u32 val = TRIG_DMA;
339 340
340 if ((sg == NULL) || (num_sg <= 0) || !offset || !index) 341 if ((sg == NULL) || (num_sg <= 0) || !offset || !index)
@@ -371,7 +372,7 @@ static int rtsx_transfer_sglist_adma_partial(struct rtsx_chip *chip, u8 card,
371 sg_cnt = dma_map_sg(&(rtsx->pci->dev), sg, num_sg, dma_dir); 372 sg_cnt = dma_map_sg(&(rtsx->pci->dev), sg, num_sg, dma_dir);
372 373
373 resid = size; 374 resid = size;
374 375 sg_ptr = sg;
375 chip->sgi = 0; 376 chip->sgi = 0;
376 /* Usually the next entry will be @sg@ + 1, but if this sg element 377 /* Usually the next entry will be @sg@ + 1, but if this sg element
377 * is part of a chained scatterlist, it could jump to the start of 378 * is part of a chained scatterlist, it could jump to the start of
@@ -379,14 +380,14 @@ static int rtsx_transfer_sglist_adma_partial(struct rtsx_chip *chip, u8 card,
379 * the proper sg 380 * the proper sg
380 */ 381 */
381 for (i = 0; i < *index; i++) 382 for (i = 0; i < *index; i++)
382 sg = sg_next(sg); 383 sg_ptr = sg_next(sg_ptr);
383 for (i = *index; i < sg_cnt; i++) { 384 for (i = *index; i < sg_cnt; i++) {
384 dma_addr_t addr; 385 dma_addr_t addr;
385 unsigned int len; 386 unsigned int len;
386 u8 option; 387 u8 option;
387 388
388 addr = sg_dma_address(sg); 389 addr = sg_dma_address(sg_ptr);
389 len = sg_dma_len(sg); 390 len = sg_dma_len(sg_ptr);
390 391
391 RTSX_DEBUGP("DMA addr: 0x%x, Len: 0x%x\n", 392 RTSX_DEBUGP("DMA addr: 0x%x, Len: 0x%x\n",
392 (unsigned int)addr, len); 393 (unsigned int)addr, len);
@@ -415,7 +416,7 @@ static int rtsx_transfer_sglist_adma_partial(struct rtsx_chip *chip, u8 card,
415 if (!resid) 416 if (!resid)
416 break; 417 break;
417 418
418 sg = sg_next(sg); 419 sg_ptr = sg_next(sg_ptr);
419 } 420 }
420 421
421 RTSX_DEBUGP("SG table count = %d\n", chip->sgi); 422 RTSX_DEBUGP("SG table count = %d\n", chip->sgi);
diff --git a/drivers/staging/sep/sep_main.c b/drivers/staging/sep/sep_main.c
index ad54c2e5c932..f1701bc6e312 100644
--- a/drivers/staging/sep/sep_main.c
+++ b/drivers/staging/sep/sep_main.c
@@ -3114,7 +3114,7 @@ static long sep_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
3114 current->pid); 3114 current->pid);
3115 if (1 == test_bit(SEP_LEGACY_SENDMSG_DONE_OFFSET, 3115 if (1 == test_bit(SEP_LEGACY_SENDMSG_DONE_OFFSET,
3116 &call_status->status)) { 3116 &call_status->status)) {
3117 dev_warn(&sep->pdev->dev, 3117 dev_dbg(&sep->pdev->dev,
3118 "[PID%d] dcb prep needed before send msg\n", 3118 "[PID%d] dcb prep needed before send msg\n",
3119 current->pid); 3119 current->pid);
3120 error = -EPROTO; 3120 error = -EPROTO;
@@ -3122,9 +3122,9 @@ static long sep_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
3122 } 3122 }
3123 3123
3124 if (!arg) { 3124 if (!arg) {
3125 dev_warn(&sep->pdev->dev, 3125 dev_dbg(&sep->pdev->dev,
3126 "[PID%d] dcb null arg\n", current->pid); 3126 "[PID%d] dcb null arg\n", current->pid);
3127 error = EINVAL; 3127 error = -EINVAL;
3128 goto end_function; 3128 goto end_function;
3129 } 3129 }
3130 3130
diff --git a/drivers/staging/tidspbridge/core/tiomap3430.c b/drivers/staging/tidspbridge/core/tiomap3430.c
index 7862513cc295..9cf29fcea11e 100644
--- a/drivers/staging/tidspbridge/core/tiomap3430.c
+++ b/drivers/staging/tidspbridge/core/tiomap3430.c
@@ -79,10 +79,6 @@
79#define OMAP343X_CONTROL_IVA2_BOOTADDR (OMAP2_CONTROL_GENERAL + 0x0190) 79#define OMAP343X_CONTROL_IVA2_BOOTADDR (OMAP2_CONTROL_GENERAL + 0x0190)
80#define OMAP343X_CONTROL_IVA2_BOOTMOD (OMAP2_CONTROL_GENERAL + 0x0194) 80#define OMAP343X_CONTROL_IVA2_BOOTMOD (OMAP2_CONTROL_GENERAL + 0x0194)
81 81
82#define OMAP343X_CTRL_REGADDR(reg) \
83 OMAP2_L4_IO_ADDRESS(OMAP343X_CTRL_BASE + (reg))
84
85
86/* Forward Declarations: */ 82/* Forward Declarations: */
87static int bridge_brd_monitor(struct bridge_dev_context *dev_ctxt); 83static int bridge_brd_monitor(struct bridge_dev_context *dev_ctxt);
88static int bridge_brd_read(struct bridge_dev_context *dev_ctxt, 84static int bridge_brd_read(struct bridge_dev_context *dev_ctxt,
@@ -418,19 +414,27 @@ static int bridge_brd_start(struct bridge_dev_context *dev_ctxt,
418 414
419 /* Assert RST1 i.e only the RST only for DSP megacell */ 415 /* Assert RST1 i.e only the RST only for DSP megacell */
420 if (!status) { 416 if (!status) {
417 /*
418 * XXX: ioremapping MUST be removed once ctrl
419 * function is made available.
420 */
421 void __iomem *ctrl = ioremap(OMAP343X_CTRL_BASE, SZ_4K);
422 if (!ctrl)
423 return -ENOMEM;
424
421 (*pdata->dsp_prm_rmw_bits)(OMAP3430_RST1_IVA2_MASK, 425 (*pdata->dsp_prm_rmw_bits)(OMAP3430_RST1_IVA2_MASK,
422 OMAP3430_RST1_IVA2_MASK, OMAP3430_IVA2_MOD, 426 OMAP3430_RST1_IVA2_MASK, OMAP3430_IVA2_MOD,
423 OMAP2_RM_RSTCTRL); 427 OMAP2_RM_RSTCTRL);
424 /* Mask address with 1K for compatibility */ 428 /* Mask address with 1K for compatibility */
425 __raw_writel(dsp_addr & OMAP3_IVA2_BOOTADDR_MASK, 429 __raw_writel(dsp_addr & OMAP3_IVA2_BOOTADDR_MASK,
426 OMAP343X_CTRL_REGADDR( 430 ctrl + OMAP343X_CONTROL_IVA2_BOOTADDR);
427 OMAP343X_CONTROL_IVA2_BOOTADDR));
428 /* 431 /*
429 * Set bootmode to self loop if dsp_debug flag is true 432 * Set bootmode to self loop if dsp_debug flag is true
430 */ 433 */
431 __raw_writel((dsp_debug) ? OMAP3_IVA2_BOOTMOD_IDLE : 0, 434 __raw_writel((dsp_debug) ? OMAP3_IVA2_BOOTMOD_IDLE : 0,
432 OMAP343X_CTRL_REGADDR( 435 ctrl + OMAP343X_CONTROL_IVA2_BOOTMOD);
433 OMAP343X_CONTROL_IVA2_BOOTMOD)); 436
437 iounmap(ctrl);
434 } 438 }
435 } 439 }
436 if (!status) { 440 if (!status) {
diff --git a/drivers/staging/tidspbridge/core/wdt.c b/drivers/staging/tidspbridge/core/wdt.c
index 70055c8111ed..870f934f4f3b 100644
--- a/drivers/staging/tidspbridge/core/wdt.c
+++ b/drivers/staging/tidspbridge/core/wdt.c
@@ -53,7 +53,10 @@ int dsp_wdt_init(void)
53 int ret = 0; 53 int ret = 0;
54 54
55 dsp_wdt.sm_wdt = NULL; 55 dsp_wdt.sm_wdt = NULL;
56 dsp_wdt.reg_base = OMAP2_L4_IO_ADDRESS(OMAP34XX_WDT3_BASE); 56 dsp_wdt.reg_base = ioremap(OMAP34XX_WDT3_BASE, SZ_4K);
57 if (!dsp_wdt.reg_base)
58 return -ENOMEM;
59
57 tasklet_init(&dsp_wdt.wdt3_tasklet, dsp_wdt_dpc, 0); 60 tasklet_init(&dsp_wdt.wdt3_tasklet, dsp_wdt_dpc, 0);
58 61
59 dsp_wdt.fclk = clk_get(NULL, "wdt3_fck"); 62 dsp_wdt.fclk = clk_get(NULL, "wdt3_fck");
@@ -99,6 +102,9 @@ void dsp_wdt_exit(void)
99 dsp_wdt.fclk = NULL; 102 dsp_wdt.fclk = NULL;
100 dsp_wdt.iclk = NULL; 103 dsp_wdt.iclk = NULL;
101 dsp_wdt.sm_wdt = NULL; 104 dsp_wdt.sm_wdt = NULL;
105
106 if (dsp_wdt.reg_base)
107 iounmap(dsp_wdt.reg_base);
102 dsp_wdt.reg_base = NULL; 108 dsp_wdt.reg_base = NULL;
103} 109}
104 110
diff --git a/drivers/staging/vme/devices/vme_pio2_core.c b/drivers/staging/vme/devices/vme_pio2_core.c
index 9fedc442a779..573c80003f0c 100644
--- a/drivers/staging/vme/devices/vme_pio2_core.c
+++ b/drivers/staging/vme/devices/vme_pio2_core.c
@@ -35,10 +35,10 @@ static int vector[PIO2_CARDS_MAX];
35static int vector_num; 35static int vector_num;
36static int level[PIO2_CARDS_MAX]; 36static int level[PIO2_CARDS_MAX];
37static int level_num; 37static int level_num;
38static const char *variant[PIO2_CARDS_MAX]; 38static char *variant[PIO2_CARDS_MAX];
39static int variant_num; 39static int variant_num;
40 40
41static int loopback; 41static bool loopback;
42 42
43static int pio2_match(struct vme_dev *); 43static int pio2_match(struct vme_dev *);
44static int __devinit pio2_probe(struct vme_dev *); 44static int __devinit pio2_probe(struct vme_dev *);
diff --git a/drivers/staging/vt6655/key.c b/drivers/staging/vt6655/key.c
index 0ff8d7bbf2a7..774b0d4a7e06 100644
--- a/drivers/staging/vt6655/key.c
+++ b/drivers/staging/vt6655/key.c
@@ -655,6 +655,9 @@ bool KeybSetDefaultKey (
655 return (false); 655 return (false);
656 } 656 }
657 657
658 if (uKeyLength > MAX_KEY_LEN)
659 return false;
660
658 pTable->KeyTable[MAX_KEY_TABLE-1].bInUse = true; 661 pTable->KeyTable[MAX_KEY_TABLE-1].bInUse = true;
659 for(ii=0;ii<ETH_ALEN;ii++) 662 for(ii=0;ii<ETH_ALEN;ii++)
660 pTable->KeyTable[MAX_KEY_TABLE-1].abyBSSID[ii] = 0xFF; 663 pTable->KeyTable[MAX_KEY_TABLE-1].abyBSSID[ii] = 0xFF;
diff --git a/drivers/staging/vt6656/ioctl.c b/drivers/staging/vt6656/ioctl.c
index 1463d76895f0..d59456c29df1 100644
--- a/drivers/staging/vt6656/ioctl.c
+++ b/drivers/staging/vt6656/ioctl.c
@@ -565,7 +565,7 @@ int private_ioctl(PSDevice pDevice, struct ifreq *rq)
565 result = -ENOMEM; 565 result = -ENOMEM;
566 break; 566 break;
567 } 567 }
568 pNodeList = (PSNodeList)kmalloc(sizeof(SNodeList) + (sNodeList.uItem * sizeof(SNodeItem)), (int)GFP_ATOMIC); 568 pNodeList = kmalloc(sizeof(SNodeList) + (sNodeList.uItem * sizeof(SNodeItem)), (int)GFP_ATOMIC);
569 if (pNodeList == NULL) { 569 if (pNodeList == NULL) {
570 result = -ENOMEM; 570 result = -ENOMEM;
571 break; 571 break;
@@ -601,6 +601,7 @@ int private_ioctl(PSDevice pDevice, struct ifreq *rq)
601 } 601 }
602 } 602 }
603 if (copy_to_user(pReq->data, pNodeList, sizeof(SNodeList) + (sNodeList.uItem * sizeof(SNodeItem)))) { 603 if (copy_to_user(pReq->data, pNodeList, sizeof(SNodeList) + (sNodeList.uItem * sizeof(SNodeItem)))) {
604 kfree(pNodeList);
604 result = -EFAULT; 605 result = -EFAULT;
605 break; 606 break;
606 } 607 }
diff --git a/drivers/staging/vt6656/key.c b/drivers/staging/vt6656/key.c
index 27bb523c8a97..ee62a06a75f4 100644
--- a/drivers/staging/vt6656/key.c
+++ b/drivers/staging/vt6656/key.c
@@ -684,6 +684,9 @@ BOOL KeybSetDefaultKey(
684 return (FALSE); 684 return (FALSE);
685 } 685 }
686 686
687 if (uKeyLength > MAX_KEY_LEN)
688 return false;
689
687 pTable->KeyTable[MAX_KEY_TABLE-1].bInUse = TRUE; 690 pTable->KeyTable[MAX_KEY_TABLE-1].bInUse = TRUE;
688 for (ii = 0; ii < ETH_ALEN; ii++) 691 for (ii = 0; ii < ETH_ALEN; ii++)
689 pTable->KeyTable[MAX_KEY_TABLE-1].abyBSSID[ii] = 0xFF; 692 pTable->KeyTable[MAX_KEY_TABLE-1].abyBSSID[ii] = 0xFF;
diff --git a/drivers/staging/xgifb/vb_init.c b/drivers/staging/xgifb/vb_init.c
index 94d5c35e22fb..3650bbff7686 100644
--- a/drivers/staging/xgifb/vb_init.c
+++ b/drivers/staging/xgifb/vb_init.c
@@ -61,7 +61,7 @@ XGINew_GetXG20DRAMType(struct xgi_hw_device_info *HwDeviceExtension,
61 } 61 }
62 temp = xgifb_reg_get(pVBInfo->P3c4, 0x3B); 62 temp = xgifb_reg_get(pVBInfo->P3c4, 0x3B);
63 /* SR3B[7][3]MAA15 MAA11 (Power on Trapping) */ 63 /* SR3B[7][3]MAA15 MAA11 (Power on Trapping) */
64 if ((temp & 0x88) == 0x80) 64 if (((temp & 0x88) == 0x80) || ((temp & 0x88) == 0x08))
65 data = 0; /* DDR */ 65 data = 0; /* DDR */
66 else 66 else
67 data = 1; /* DDRII */ 67 data = 1; /* DDRII */
diff --git a/drivers/staging/xgifb/vb_setmode.c b/drivers/staging/xgifb/vb_setmode.c
index 2919924213c4..60d4adf99923 100644
--- a/drivers/staging/xgifb/vb_setmode.c
+++ b/drivers/staging/xgifb/vb_setmode.c
@@ -152,6 +152,7 @@ void InitTo330Pointer(unsigned char ChipType, struct vb_device_info *pVBInfo)
152 pVBInfo->pXGINew_CR97 = &XG20_CR97; 152 pVBInfo->pXGINew_CR97 = &XG20_CR97;
153 153
154 if (ChipType == XG27) { 154 if (ChipType == XG27) {
155 unsigned char temp;
155 pVBInfo->MCLKData 156 pVBInfo->MCLKData
156 = (struct SiS_MCLKData *) XGI27New_MCLKData; 157 = (struct SiS_MCLKData *) XGI27New_MCLKData;
157 pVBInfo->CR40 = XGI27_cr41; 158 pVBInfo->CR40 = XGI27_cr41;
@@ -162,7 +163,13 @@ void InitTo330Pointer(unsigned char ChipType, struct vb_device_info *pVBInfo)
162 pVBInfo->pCRDE = XG27_CRDE; 163 pVBInfo->pCRDE = XG27_CRDE;
163 pVBInfo->pSR40 = &XG27_SR40; 164 pVBInfo->pSR40 = &XG27_SR40;
164 pVBInfo->pSR41 = &XG27_SR41; 165 pVBInfo->pSR41 = &XG27_SR41;
166 pVBInfo->SR15 = XG27_SR13;
165 167
168 /*Z11m DDR*/
169 temp = xgifb_reg_get(pVBInfo->P3c4, 0x3B);
170 /* SR3B[7][3]MAA15 MAA11 (Power on Trapping) */
171 if (((temp & 0x88) == 0x80) || ((temp & 0x88) == 0x08))
172 pVBInfo->pXGINew_CR97 = &Z11m_CR97;
166 } 173 }
167 174
168 if (ChipType >= XG20) { 175 if (ChipType >= XG20) {
diff --git a/drivers/staging/xgifb/vb_table.h b/drivers/staging/xgifb/vb_table.h
index dddf261ed53d..e8d6f674b274 100644
--- a/drivers/staging/xgifb/vb_table.h
+++ b/drivers/staging/xgifb/vb_table.h
@@ -33,6 +33,13 @@ static struct XGI_ECLKDataStruct XGI340_ECLKData[] = {
33 {0x5c, 0x23, 0x01, 166} 33 {0x5c, 0x23, 0x01, 166}
34}; 34};
35 35
36static unsigned char XG27_SR13[4][8] = {
37 {0x35, 0x45, 0xb1, 0x00, 0x00, 0x00, 0x00, 0x00}, /* SR13 */
38 {0x41, 0x51, 0x5c, 0x00, 0x00, 0x00, 0x00, 0x00}, /* SR14 */
39 {0x32, 0x32, 0x42, 0x00, 0x00, 0x00, 0x00, 0x00}, /* SR18 */
40 {0x03, 0x03, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00} /* SR1B */
41};
42
36static unsigned char XGI340_SR13[4][8] = { 43static unsigned char XGI340_SR13[4][8] = {
37 {0x35, 0x45, 0xb1, 0x00, 0x00, 0x00, 0x00, 0x00}, /* SR13 */ 44 {0x35, 0x45, 0xb1, 0x00, 0x00, 0x00, 0x00, 0x00}, /* SR13 */
38 {0x41, 0x51, 0x5c, 0x00, 0x00, 0x00, 0x00, 0x00}, /* SR14 */ 45 {0x41, 0x51, 0x5c, 0x00, 0x00, 0x00, 0x00, 0x00}, /* SR14 */
@@ -71,7 +78,7 @@ static unsigned char XGI27_cr41[24][8] = {
71 {0x20, 0x40, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00}, /* 0 CR41 */ 78 {0x20, 0x40, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00}, /* 0 CR41 */
72 {0xC4, 0x40, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00}, /* 1 CR8A */ 79 {0xC4, 0x40, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00}, /* 1 CR8A */
73 {0xC4, 0x40, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00}, /* 2 CR8B */ 80 {0xC4, 0x40, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00}, /* 2 CR8B */
74 {0xB5, 0x13, 0xa4, 0x00, 0x00, 0x00, 0x00, 0x00}, /* 3 CR40[7], 81 {0xB3, 0x13, 0xa4, 0x00, 0x00, 0x00, 0x00, 0x00}, /* 3 CR40[7],
75 CR99[2:0], 82 CR99[2:0],
76 CR45[3:0]*/ 83 CR45[3:0]*/
77 {0xf0, 0xf5, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00}, /* 4 CR59 */ 84 {0xf0, 0xf5, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00}, /* 4 CR59 */
@@ -2803,6 +2810,8 @@ static unsigned char XG27_CRDE[2];
2803static unsigned char XG27_SR40 = 0x04 ; 2810static unsigned char XG27_SR40 = 0x04 ;
2804static unsigned char XG27_SR41 = 0x00 ; 2811static unsigned char XG27_SR41 = 0x00 ;
2805 2812
2813static unsigned char Z11m_CR97 = 0x80 ;
2814
2806static struct XGI330_VCLKDataStruct XGI_VCLKData[] = { 2815static struct XGI330_VCLKDataStruct XGI_VCLKData[] = {
2807 /* SR2B,SR2C,SR2D */ 2816 /* SR2B,SR2C,SR2D */
2808 {0x1B, 0xE1, 25}, /* 00 (25.175MHz) */ 2817 {0x1B, 0xE1, 25}, /* 00 (25.175MHz) */
diff --git a/drivers/staging/zcache/Kconfig b/drivers/staging/zcache/Kconfig
index 3ed2c8f656a5..7048e01f0817 100644
--- a/drivers/staging/zcache/Kconfig
+++ b/drivers/staging/zcache/Kconfig
@@ -2,7 +2,7 @@ config ZCACHE
2 bool "Dynamic compression of swap pages and clean pagecache pages" 2 bool "Dynamic compression of swap pages and clean pagecache pages"
3 # X86 dependency is because zsmalloc uses non-portable pte/tlb 3 # X86 dependency is because zsmalloc uses non-portable pte/tlb
4 # functions 4 # functions
5 depends on (CLEANCACHE || FRONTSWAP) && CRYPTO && X86 5 depends on (CLEANCACHE || FRONTSWAP) && CRYPTO=y && X86
6 select ZSMALLOC 6 select ZSMALLOC
7 select CRYPTO_LZO 7 select CRYPTO_LZO
8 default n 8 default n
diff --git a/drivers/staging/zsmalloc/zsmalloc-main.c b/drivers/staging/zsmalloc/zsmalloc-main.c
index 09caa4f2687e..917461c66014 100644
--- a/drivers/staging/zsmalloc/zsmalloc-main.c
+++ b/drivers/staging/zsmalloc/zsmalloc-main.c
@@ -267,33 +267,39 @@ static unsigned long obj_idx_to_offset(struct page *page,
267 return off + obj_idx * class_size; 267 return off + obj_idx * class_size;
268} 268}
269 269
270static void reset_page(struct page *page)
271{
272 clear_bit(PG_private, &page->flags);
273 clear_bit(PG_private_2, &page->flags);
274 set_page_private(page, 0);
275 page->mapping = NULL;
276 page->freelist = NULL;
277 reset_page_mapcount(page);
278}
279
270static void free_zspage(struct page *first_page) 280static void free_zspage(struct page *first_page)
271{ 281{
272 struct page *nextp, *tmp; 282 struct page *nextp, *tmp, *head_extra;
273 283
274 BUG_ON(!is_first_page(first_page)); 284 BUG_ON(!is_first_page(first_page));
275 BUG_ON(first_page->inuse); 285 BUG_ON(first_page->inuse);
276 286
277 nextp = (struct page *)page_private(first_page); 287 head_extra = (struct page *)page_private(first_page);
278 288
279 clear_bit(PG_private, &first_page->flags); 289 reset_page(first_page);
280 clear_bit(PG_private_2, &first_page->flags);
281 set_page_private(first_page, 0);
282 first_page->mapping = NULL;
283 first_page->freelist = NULL;
284 reset_page_mapcount(first_page);
285 __free_page(first_page); 290 __free_page(first_page);
286 291
287 /* zspage with only 1 system page */ 292 /* zspage with only 1 system page */
288 if (!nextp) 293 if (!head_extra)
289 return; 294 return;
290 295
291 list_for_each_entry_safe(nextp, tmp, &nextp->lru, lru) { 296 list_for_each_entry_safe(nextp, tmp, &head_extra->lru, lru) {
292 list_del(&nextp->lru); 297 list_del(&nextp->lru);
293 clear_bit(PG_private_2, &nextp->flags); 298 reset_page(nextp);
294 nextp->index = 0;
295 __free_page(nextp); 299 __free_page(nextp);
296 } 300 }
301 reset_page(head_extra);
302 __free_page(head_extra);
297} 303}
298 304
299/* Initialize a newly allocated zspage */ 305/* Initialize a newly allocated zspage */
diff --git a/drivers/tty/amiserial.c b/drivers/tty/amiserial.c
index 24145c30c9b0..6cc4358f68c1 100644
--- a/drivers/tty/amiserial.c
+++ b/drivers/tty/amiserial.c
@@ -1073,8 +1073,10 @@ static int set_serial_info(struct tty_struct *tty, struct serial_state *state,
1073 (new_serial.close_delay != port->close_delay) || 1073 (new_serial.close_delay != port->close_delay) ||
1074 (new_serial.xmit_fifo_size != state->xmit_fifo_size) || 1074 (new_serial.xmit_fifo_size != state->xmit_fifo_size) ||
1075 ((new_serial.flags & ~ASYNC_USR_MASK) != 1075 ((new_serial.flags & ~ASYNC_USR_MASK) !=
1076 (port->flags & ~ASYNC_USR_MASK))) 1076 (port->flags & ~ASYNC_USR_MASK))) {
1077 tty_unlock();
1077 return -EPERM; 1078 return -EPERM;
1079 }
1078 port->flags = ((port->flags & ~ASYNC_USR_MASK) | 1080 port->flags = ((port->flags & ~ASYNC_USR_MASK) |
1079 (new_serial.flags & ASYNC_USR_MASK)); 1081 (new_serial.flags & ASYNC_USR_MASK));
1080 state->custom_divisor = new_serial.custom_divisor; 1082 state->custom_divisor = new_serial.custom_divisor;
diff --git a/drivers/tty/serial/8250/8250.c b/drivers/tty/serial/8250/8250.c
index 5b149b466ec8..5c27f7e6c9f1 100644
--- a/drivers/tty/serial/8250/8250.c
+++ b/drivers/tty/serial/8250/8250.c
@@ -1572,13 +1572,11 @@ static irqreturn_t serial8250_interrupt(int irq, void *dev_id)
1572 do { 1572 do {
1573 struct uart_8250_port *up; 1573 struct uart_8250_port *up;
1574 struct uart_port *port; 1574 struct uart_port *port;
1575 bool skip;
1576 1575
1577 up = list_entry(l, struct uart_8250_port, list); 1576 up = list_entry(l, struct uart_8250_port, list);
1578 port = &up->port; 1577 port = &up->port;
1579 skip = pass_counter && up->port.flags & UPF_IIR_ONCE;
1580 1578
1581 if (!skip && port->handle_irq(port)) { 1579 if (port->handle_irq(port)) {
1582 handled = 1; 1580 handled = 1;
1583 end = NULL; 1581 end = NULL;
1584 } else if (end == NULL) 1582 } else if (end == NULL)
@@ -2037,10 +2035,12 @@ static int serial8250_startup(struct uart_port *port)
2037 spin_unlock_irqrestore(&port->lock, flags); 2035 spin_unlock_irqrestore(&port->lock, flags);
2038 2036
2039 /* 2037 /*
2040 * If the interrupt is not reasserted, setup a timer to 2038 * If the interrupt is not reasserted, or we otherwise
2041 * kick the UART on a regular basis. 2039 * don't trust the iir, setup a timer to kick the UART
2040 * on a regular basis.
2042 */ 2041 */
2043 if (!(iir1 & UART_IIR_NO_INT) && (iir & UART_IIR_NO_INT)) { 2042 if ((!(iir1 & UART_IIR_NO_INT) && (iir & UART_IIR_NO_INT)) ||
2043 up->port.flags & UPF_BUG_THRE) {
2044 up->bugs |= UART_BUG_THRE; 2044 up->bugs |= UART_BUG_THRE;
2045 pr_debug("ttyS%d - using backup timer\n", 2045 pr_debug("ttyS%d - using backup timer\n",
2046 serial_index(port)); 2046 serial_index(port));
diff --git a/drivers/tty/serial/8250/8250_pci.c b/drivers/tty/serial/8250/8250_pci.c
index da2b0b0a183f..858dca865d6a 100644
--- a/drivers/tty/serial/8250/8250_pci.c
+++ b/drivers/tty/serial/8250/8250_pci.c
@@ -1096,7 +1096,7 @@ static int kt_serial_setup(struct serial_private *priv,
1096 const struct pciserial_board *board, 1096 const struct pciserial_board *board,
1097 struct uart_port *port, int idx) 1097 struct uart_port *port, int idx)
1098{ 1098{
1099 port->flags |= UPF_IIR_ONCE; 1099 port->flags |= UPF_BUG_THRE;
1100 return skip_tx_en_setup(priv, board, port, idx); 1100 return skip_tx_en_setup(priv, board, port, idx);
1101} 1101}
1102 1102
@@ -1118,18 +1118,6 @@ pci_xr17c154_setup(struct serial_private *priv,
1118 return pci_default_setup(priv, board, port, idx); 1118 return pci_default_setup(priv, board, port, idx);
1119} 1119}
1120 1120
1121static int try_enable_msi(struct pci_dev *dev)
1122{
1123 /* use msi if available, but fallback to legacy otherwise */
1124 pci_enable_msi(dev);
1125 return 0;
1126}
1127
1128static void disable_msi(struct pci_dev *dev)
1129{
1130 pci_disable_msi(dev);
1131}
1132
1133#define PCI_VENDOR_ID_SBSMODULARIO 0x124B 1121#define PCI_VENDOR_ID_SBSMODULARIO 0x124B
1134#define PCI_SUBVENDOR_ID_SBSMODULARIO 0x124B 1122#define PCI_SUBVENDOR_ID_SBSMODULARIO 0x124B
1135#define PCI_DEVICE_ID_OCTPRO 0x0001 1123#define PCI_DEVICE_ID_OCTPRO 0x0001
@@ -1249,9 +1237,7 @@ static struct pci_serial_quirk pci_serial_quirks[] __refdata = {
1249 .device = PCI_DEVICE_ID_INTEL_PATSBURG_KT, 1237 .device = PCI_DEVICE_ID_INTEL_PATSBURG_KT,
1250 .subvendor = PCI_ANY_ID, 1238 .subvendor = PCI_ANY_ID,
1251 .subdevice = PCI_ANY_ID, 1239 .subdevice = PCI_ANY_ID,
1252 .init = try_enable_msi,
1253 .setup = kt_serial_setup, 1240 .setup = kt_serial_setup,
1254 .exit = disable_msi,
1255 }, 1241 },
1256 /* 1242 /*
1257 * ITE 1243 * ITE
diff --git a/drivers/tty/serial/Kconfig b/drivers/tty/serial/Kconfig
index 665beb68f670..070b442c1f81 100644
--- a/drivers/tty/serial/Kconfig
+++ b/drivers/tty/serial/Kconfig
@@ -1041,7 +1041,7 @@ config SERIAL_OMAP
1041 1041
1042config SERIAL_OMAP_CONSOLE 1042config SERIAL_OMAP_CONSOLE
1043 bool "Console on OMAP serial port" 1043 bool "Console on OMAP serial port"
1044 depends on SERIAL_OMAP 1044 depends on SERIAL_OMAP=y
1045 select SERIAL_CORE_CONSOLE 1045 select SERIAL_CORE_CONSOLE
1046 help 1046 help
1047 Select this option if you would like to use omap serial port as 1047 Select this option if you would like to use omap serial port as
diff --git a/drivers/tty/serial/altera_uart.c b/drivers/tty/serial/altera_uart.c
index e7903751e058..1f0330915d5a 100644
--- a/drivers/tty/serial/altera_uart.c
+++ b/drivers/tty/serial/altera_uart.c
@@ -556,7 +556,7 @@ static int __devinit altera_uart_probe(struct platform_device *pdev)
556 res_mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); 556 res_mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
557 if (res_mem) 557 if (res_mem)
558 port->mapbase = res_mem->start; 558 port->mapbase = res_mem->start;
559 else if (platp->mapbase) 559 else if (platp)
560 port->mapbase = platp->mapbase; 560 port->mapbase = platp->mapbase;
561 else 561 else
562 return -EINVAL; 562 return -EINVAL;
@@ -564,7 +564,7 @@ static int __devinit altera_uart_probe(struct platform_device *pdev)
564 res_irq = platform_get_resource(pdev, IORESOURCE_IRQ, 0); 564 res_irq = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
565 if (res_irq) 565 if (res_irq)
566 port->irq = res_irq->start; 566 port->irq = res_irq->start;
567 else if (platp->irq) 567 else if (platp)
568 port->irq = platp->irq; 568 port->irq = platp->irq;
569 569
570 /* Check platform data first so we can override device node data */ 570 /* Check platform data first so we can override device node data */
diff --git a/drivers/tty/serial/amba-pl011.c b/drivers/tty/serial/amba-pl011.c
index 0c65c9e66986..3d569cd68f58 100644
--- a/drivers/tty/serial/amba-pl011.c
+++ b/drivers/tty/serial/amba-pl011.c
@@ -1946,10 +1946,6 @@ static int pl011_probe(struct amba_device *dev, const struct amba_id *id)
1946 goto unmap; 1946 goto unmap;
1947 } 1947 }
1948 1948
1949 /* Ensure interrupts from this UART are masked and cleared */
1950 writew(0, uap->port.membase + UART011_IMSC);
1951 writew(0xffff, uap->port.membase + UART011_ICR);
1952
1953 uap->vendor = vendor; 1949 uap->vendor = vendor;
1954 uap->lcrh_rx = vendor->lcrh_rx; 1950 uap->lcrh_rx = vendor->lcrh_rx;
1955 uap->lcrh_tx = vendor->lcrh_tx; 1951 uap->lcrh_tx = vendor->lcrh_tx;
@@ -1967,6 +1963,10 @@ static int pl011_probe(struct amba_device *dev, const struct amba_id *id)
1967 uap->port.line = i; 1963 uap->port.line = i;
1968 pl011_dma_probe(uap); 1964 pl011_dma_probe(uap);
1969 1965
1966 /* Ensure interrupts from this UART are masked and cleared */
1967 writew(0, uap->port.membase + UART011_IMSC);
1968 writew(0xffff, uap->port.membase + UART011_ICR);
1969
1970 snprintf(uap->type, sizeof(uap->type), "PL011 rev%u", amba_rev(dev)); 1970 snprintf(uap->type, sizeof(uap->type), "PL011 rev%u", amba_rev(dev));
1971 1971
1972 amba_ports[i] = uap; 1972 amba_ports[i] = uap;
diff --git a/drivers/tty/serial/atmel_serial.c b/drivers/tty/serial/atmel_serial.c
index f9a6be7a9bed..3d7e1ee2fa57 100644
--- a/drivers/tty/serial/atmel_serial.c
+++ b/drivers/tty/serial/atmel_serial.c
@@ -389,6 +389,8 @@ static void atmel_start_rx(struct uart_port *port)
389{ 389{
390 UART_PUT_CR(port, ATMEL_US_RSTSTA); /* reset status and receiver */ 390 UART_PUT_CR(port, ATMEL_US_RSTSTA); /* reset status and receiver */
391 391
392 UART_PUT_CR(port, ATMEL_US_RXEN);
393
392 if (atmel_use_dma_rx(port)) { 394 if (atmel_use_dma_rx(port)) {
393 /* enable PDC controller */ 395 /* enable PDC controller */
394 UART_PUT_IER(port, ATMEL_US_ENDRX | ATMEL_US_TIMEOUT | 396 UART_PUT_IER(port, ATMEL_US_ENDRX | ATMEL_US_TIMEOUT |
@@ -404,6 +406,8 @@ static void atmel_start_rx(struct uart_port *port)
404 */ 406 */
405static void atmel_stop_rx(struct uart_port *port) 407static void atmel_stop_rx(struct uart_port *port)
406{ 408{
409 UART_PUT_CR(port, ATMEL_US_RXDIS);
410
407 if (atmel_use_dma_rx(port)) { 411 if (atmel_use_dma_rx(port)) {
408 /* disable PDC receive */ 412 /* disable PDC receive */
409 UART_PUT_PTCR(port, ATMEL_PDC_RXTDIS); 413 UART_PUT_PTCR(port, ATMEL_PDC_RXTDIS);
diff --git a/drivers/tty/serial/clps711x.c b/drivers/tty/serial/clps711x.c
index e6c3dbd781d6..836fe2731234 100644
--- a/drivers/tty/serial/clps711x.c
+++ b/drivers/tty/serial/clps711x.c
@@ -154,10 +154,9 @@ static irqreturn_t clps711xuart_int_tx(int irq, void *dev_id)
154 port->x_char = 0; 154 port->x_char = 0;
155 return IRQ_HANDLED; 155 return IRQ_HANDLED;
156 } 156 }
157 if (uart_circ_empty(xmit) || uart_tx_stopped(port)) { 157
158 clps711xuart_stop_tx(port); 158 if (uart_circ_empty(xmit) || uart_tx_stopped(port))
159 return IRQ_HANDLED; 159 goto disable_tx_irq;
160 }
161 160
162 count = port->fifosize >> 1; 161 count = port->fifosize >> 1;
163 do { 162 do {
@@ -171,8 +170,11 @@ static irqreturn_t clps711xuart_int_tx(int irq, void *dev_id)
171 if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS) 170 if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS)
172 uart_write_wakeup(port); 171 uart_write_wakeup(port);
173 172
174 if (uart_circ_empty(xmit)) 173 if (uart_circ_empty(xmit)) {
175 clps711xuart_stop_tx(port); 174 disable_tx_irq:
175 disable_irq_nosync(TX_IRQ(port));
176 tx_enabled(port) = 0;
177 }
176 178
177 return IRQ_HANDLED; 179 return IRQ_HANDLED;
178} 180}
diff --git a/drivers/tty/serial/omap-serial.c b/drivers/tty/serial/omap-serial.c
index 0121486ac4fa..d00b38eb268e 100644
--- a/drivers/tty/serial/omap-serial.c
+++ b/drivers/tty/serial/omap-serial.c
@@ -1381,29 +1381,24 @@ static int serial_omap_probe(struct platform_device *pdev)
1381 return -ENODEV; 1381 return -ENODEV;
1382 } 1382 }
1383 1383
1384 if (!request_mem_region(mem->start, resource_size(mem), 1384 if (!devm_request_mem_region(&pdev->dev, mem->start, resource_size(mem),
1385 pdev->dev.driver->name)) { 1385 pdev->dev.driver->name)) {
1386 dev_err(&pdev->dev, "memory region already claimed\n"); 1386 dev_err(&pdev->dev, "memory region already claimed\n");
1387 return -EBUSY; 1387 return -EBUSY;
1388 } 1388 }
1389 1389
1390 dma_rx = platform_get_resource_byname(pdev, IORESOURCE_DMA, "rx"); 1390 dma_rx = platform_get_resource_byname(pdev, IORESOURCE_DMA, "rx");
1391 if (!dma_rx) { 1391 if (!dma_rx)
1392 ret = -EINVAL; 1392 return -ENXIO;
1393 goto err;
1394 }
1395 1393
1396 dma_tx = platform_get_resource_byname(pdev, IORESOURCE_DMA, "tx"); 1394 dma_tx = platform_get_resource_byname(pdev, IORESOURCE_DMA, "tx");
1397 if (!dma_tx) { 1395 if (!dma_tx)
1398 ret = -EINVAL; 1396 return -ENXIO;
1399 goto err; 1397
1400 } 1398 up = devm_kzalloc(&pdev->dev, sizeof(*up), GFP_KERNEL);
1399 if (!up)
1400 return -ENOMEM;
1401 1401
1402 up = kzalloc(sizeof(*up), GFP_KERNEL);
1403 if (up == NULL) {
1404 ret = -ENOMEM;
1405 goto do_release_region;
1406 }
1407 up->pdev = pdev; 1402 up->pdev = pdev;
1408 up->port.dev = &pdev->dev; 1403 up->port.dev = &pdev->dev;
1409 up->port.type = PORT_OMAP; 1404 up->port.type = PORT_OMAP;
@@ -1423,16 +1418,17 @@ static int serial_omap_probe(struct platform_device *pdev)
1423 dev_err(&pdev->dev, "failed to get alias/pdev id, errno %d\n", 1418 dev_err(&pdev->dev, "failed to get alias/pdev id, errno %d\n",
1424 up->port.line); 1419 up->port.line);
1425 ret = -ENODEV; 1420 ret = -ENODEV;
1426 goto err; 1421 goto err_port_line;
1427 } 1422 }
1428 1423
1429 sprintf(up->name, "OMAP UART%d", up->port.line); 1424 sprintf(up->name, "OMAP UART%d", up->port.line);
1430 up->port.mapbase = mem->start; 1425 up->port.mapbase = mem->start;
1431 up->port.membase = ioremap(mem->start, resource_size(mem)); 1426 up->port.membase = devm_ioremap(&pdev->dev, mem->start,
1427 resource_size(mem));
1432 if (!up->port.membase) { 1428 if (!up->port.membase) {
1433 dev_err(&pdev->dev, "can't ioremap UART\n"); 1429 dev_err(&pdev->dev, "can't ioremap UART\n");
1434 ret = -ENOMEM; 1430 ret = -ENOMEM;
1435 goto err; 1431 goto err_ioremap;
1436 } 1432 }
1437 1433
1438 up->port.flags = omap_up_info->flags; 1434 up->port.flags = omap_up_info->flags;
@@ -1478,16 +1474,19 @@ static int serial_omap_probe(struct platform_device *pdev)
1478 1474
1479 ret = uart_add_one_port(&serial_omap_reg, &up->port); 1475 ret = uart_add_one_port(&serial_omap_reg, &up->port);
1480 if (ret != 0) 1476 if (ret != 0)
1481 goto do_release_region; 1477 goto err_add_port;
1482 1478
1483 pm_runtime_put(&pdev->dev); 1479 pm_runtime_put(&pdev->dev);
1484 platform_set_drvdata(pdev, up); 1480 platform_set_drvdata(pdev, up);
1485 return 0; 1481 return 0;
1486err: 1482
1483err_add_port:
1484 pm_runtime_put(&pdev->dev);
1485 pm_runtime_disable(&pdev->dev);
1486err_ioremap:
1487err_port_line:
1487 dev_err(&pdev->dev, "[UART%d]: failure [%s]: %d\n", 1488 dev_err(&pdev->dev, "[UART%d]: failure [%s]: %d\n",
1488 pdev->id, __func__, ret); 1489 pdev->id, __func__, ret);
1489do_release_region:
1490 release_mem_region(mem->start, resource_size(mem));
1491 return ret; 1490 return ret;
1492} 1491}
1493 1492
@@ -1499,8 +1498,6 @@ static int serial_omap_remove(struct platform_device *dev)
1499 pm_runtime_disable(&up->pdev->dev); 1498 pm_runtime_disable(&up->pdev->dev);
1500 uart_remove_one_port(&serial_omap_reg, &up->port); 1499 uart_remove_one_port(&serial_omap_reg, &up->port);
1501 pm_qos_remove_request(&up->pm_qos_request); 1500 pm_qos_remove_request(&up->pm_qos_request);
1502
1503 kfree(up);
1504 } 1501 }
1505 1502
1506 platform_set_drvdata(dev, NULL); 1503 platform_set_drvdata(dev, NULL);
diff --git a/drivers/tty/serial/pch_uart.c b/drivers/tty/serial/pch_uart.c
index 08b9962b8fda..c2816f494807 100644
--- a/drivers/tty/serial/pch_uart.c
+++ b/drivers/tty/serial/pch_uart.c
@@ -210,6 +210,7 @@ enum {
210#define CMITC_UARTCLK 192000000 /* 192.0000 MHz */ 210#define CMITC_UARTCLK 192000000 /* 192.0000 MHz */
211#define FRI2_64_UARTCLK 64000000 /* 64.0000 MHz */ 211#define FRI2_64_UARTCLK 64000000 /* 64.0000 MHz */
212#define FRI2_48_UARTCLK 48000000 /* 48.0000 MHz */ 212#define FRI2_48_UARTCLK 48000000 /* 48.0000 MHz */
213#define NTC1_UARTCLK 64000000 /* 64.0000 MHz */
213 214
214struct pch_uart_buffer { 215struct pch_uart_buffer {
215 unsigned char *buf; 216 unsigned char *buf;
@@ -384,6 +385,12 @@ static int pch_uart_get_uartclk(void)
384 if (cmp && strstr(cmp, "Fish River Island II")) 385 if (cmp && strstr(cmp, "Fish River Island II"))
385 return FRI2_48_UARTCLK; 386 return FRI2_48_UARTCLK;
386 387
388 /* Kontron COMe-mTT10 (nanoETXexpress-TT) */
389 cmp = dmi_get_system_info(DMI_BOARD_NAME);
390 if (cmp && (strstr(cmp, "COMe-mTT") ||
391 strstr(cmp, "nanoETXexpress-TT")))
392 return NTC1_UARTCLK;
393
387 return DEFAULT_UARTCLK; 394 return DEFAULT_UARTCLK;
388} 395}
389 396
@@ -1440,9 +1447,11 @@ static int pch_uart_verify_port(struct uart_port *port,
1440 __func__); 1447 __func__);
1441 return -EOPNOTSUPP; 1448 return -EOPNOTSUPP;
1442#endif 1449#endif
1443 priv->use_dma = 1;
1444 priv->use_dma_flag = 1; 1450 priv->use_dma_flag = 1;
1445 dev_info(priv->port.dev, "PCH UART : Use DMA Mode\n"); 1451 dev_info(priv->port.dev, "PCH UART : Use DMA Mode\n");
1452 if (!priv->use_dma)
1453 pch_request_dma(port);
1454 priv->use_dma = 1;
1446 } 1455 }
1447 1456
1448 return 0; 1457 return 0;
@@ -1651,6 +1660,7 @@ static struct eg20t_port *pch_uart_init_port(struct pci_dev *pdev,
1651 } 1660 }
1652 1661
1653 pci_enable_msi(pdev); 1662 pci_enable_msi(pdev);
1663 pci_set_master(pdev);
1654 1664
1655 iobase = pci_resource_start(pdev, 0); 1665 iobase = pci_resource_start(pdev, 0);
1656 mapbase = pci_resource_start(pdev, 1); 1666 mapbase = pci_resource_start(pdev, 1);
diff --git a/drivers/tty/serial/samsung.c b/drivers/tty/serial/samsung.c
index de249d265bec..d8b0aee35632 100644
--- a/drivers/tty/serial/samsung.c
+++ b/drivers/tty/serial/samsung.c
@@ -982,6 +982,7 @@ static void s3c24xx_serial_resetport(struct uart_port *port,
982 982
983 ucon &= ucon_mask; 983 ucon &= ucon_mask;
984 wr_regl(port, S3C2410_UCON, ucon | cfg->ucon); 984 wr_regl(port, S3C2410_UCON, ucon | cfg->ucon);
985 wr_regl(port, S3C2410_ULCON, cfg->ulcon);
985 986
986 /* reset both fifos */ 987 /* reset both fifos */
987 wr_regl(port, S3C2410_UFCON, cfg->ufcon | S3C2410_UFCON_RESETBOTH); 988 wr_regl(port, S3C2410_UFCON, cfg->ufcon | S3C2410_UFCON_RESETBOTH);
diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c
index 3bdd4b19dd06..2156188db4a6 100644
--- a/drivers/tty/vt/vt.c
+++ b/drivers/tty/vt/vt.c
@@ -2932,11 +2932,10 @@ static int __init con_init(void)
2932 gotoxy(vc, vc->vc_x, vc->vc_y); 2932 gotoxy(vc, vc->vc_x, vc->vc_y);
2933 csi_J(vc, 0); 2933 csi_J(vc, 0);
2934 update_screen(vc); 2934 update_screen(vc);
2935 pr_info("Console: %s %s %dx%d", 2935 pr_info("Console: %s %s %dx%d\n",
2936 vc->vc_can_do_color ? "colour" : "mono", 2936 vc->vc_can_do_color ? "colour" : "mono",
2937 display_desc, vc->vc_cols, vc->vc_rows); 2937 display_desc, vc->vc_cols, vc->vc_rows);
2938 printable = 1; 2938 printable = 1;
2939 printk("\n");
2940 2939
2941 console_unlock(); 2940 console_unlock();
2942 2941
diff --git a/drivers/usb/Kconfig b/drivers/usb/Kconfig
index cbd8f5f80596..76316a33061b 100644
--- a/drivers/usb/Kconfig
+++ b/drivers/usb/Kconfig
@@ -2,14 +2,6 @@
2# USB device configuration 2# USB device configuration
3# 3#
4 4
5menuconfig USB_SUPPORT
6 bool "USB support"
7 depends on HAS_IOMEM
8 default y
9 ---help---
10 This option adds core support for Universal Serial Bus (USB).
11 You will also need drivers from the following menu to make use of it.
12
13# many non-PCI SOC chips embed OHCI 5# many non-PCI SOC chips embed OHCI
14config USB_ARCH_HAS_OHCI 6config USB_ARCH_HAS_OHCI
15 boolean 7 boolean
@@ -63,6 +55,14 @@ config USB_ARCH_HAS_XHCI
63 boolean 55 boolean
64 default PCI 56 default PCI
65 57
58menuconfig USB_SUPPORT
59 bool "USB support"
60 depends on HAS_IOMEM
61 default y
62 ---help---
63 This option adds core support for Universal Serial Bus (USB).
64 You will also need drivers from the following menu to make use of it.
65
66if USB_SUPPORT 66if USB_SUPPORT
67 67
68config USB_COMMON 68config USB_COMMON
diff --git a/drivers/usb/class/cdc-wdm.c b/drivers/usb/class/cdc-wdm.c
index c6f6560d436c..0bb2b3248dad 100644
--- a/drivers/usb/class/cdc-wdm.c
+++ b/drivers/usb/class/cdc-wdm.c
@@ -157,8 +157,9 @@ static void wdm_out_callback(struct urb *urb)
157 spin_lock(&desc->iuspin); 157 spin_lock(&desc->iuspin);
158 desc->werr = urb->status; 158 desc->werr = urb->status;
159 spin_unlock(&desc->iuspin); 159 spin_unlock(&desc->iuspin);
160 clear_bit(WDM_IN_USE, &desc->flags);
161 kfree(desc->outbuf); 160 kfree(desc->outbuf);
161 desc->outbuf = NULL;
162 clear_bit(WDM_IN_USE, &desc->flags);
162 wake_up(&desc->wait); 163 wake_up(&desc->wait);
163} 164}
164 165
@@ -338,7 +339,7 @@ static ssize_t wdm_write
338 if (we < 0) 339 if (we < 0)
339 return -EIO; 340 return -EIO;
340 341
341 desc->outbuf = buf = kmalloc(count, GFP_KERNEL); 342 buf = kmalloc(count, GFP_KERNEL);
342 if (!buf) { 343 if (!buf) {
343 rv = -ENOMEM; 344 rv = -ENOMEM;
344 goto outnl; 345 goto outnl;
@@ -406,10 +407,12 @@ static ssize_t wdm_write
406 req->wIndex = desc->inum; 407 req->wIndex = desc->inum;
407 req->wLength = cpu_to_le16(count); 408 req->wLength = cpu_to_le16(count);
408 set_bit(WDM_IN_USE, &desc->flags); 409 set_bit(WDM_IN_USE, &desc->flags);
410 desc->outbuf = buf;
409 411
410 rv = usb_submit_urb(desc->command, GFP_KERNEL); 412 rv = usb_submit_urb(desc->command, GFP_KERNEL);
411 if (rv < 0) { 413 if (rv < 0) {
412 kfree(buf); 414 kfree(buf);
415 desc->outbuf = NULL;
413 clear_bit(WDM_IN_USE, &desc->flags); 416 clear_bit(WDM_IN_USE, &desc->flags);
414 dev_err(&desc->intf->dev, "Tx URB error: %d\n", rv); 417 dev_err(&desc->intf->dev, "Tx URB error: %d\n", rv);
415 } else { 418 } else {
diff --git a/drivers/usb/core/driver.c b/drivers/usb/core/driver.c
index f8e2d6d52e5c..9a56635dc19c 100644
--- a/drivers/usb/core/driver.c
+++ b/drivers/usb/core/driver.c
@@ -1189,8 +1189,13 @@ static int usb_suspend_both(struct usb_device *udev, pm_message_t msg)
1189 if (status == 0) { 1189 if (status == 0) {
1190 status = usb_suspend_device(udev, msg); 1190 status = usb_suspend_device(udev, msg);
1191 1191
1192 /* Again, ignore errors during system sleep transitions */ 1192 /*
1193 if (!PMSG_IS_AUTO(msg)) 1193 * Ignore errors from non-root-hub devices during
1194 * system sleep transitions. For the most part,
1195 * these devices should go to low power anyway when
1196 * the entire bus is suspended.
1197 */
1198 if (udev->parent && !PMSG_IS_AUTO(msg))
1194 status = 0; 1199 status = 0;
1195 } 1200 }
1196 1201
diff --git a/drivers/usb/core/hcd-pci.c b/drivers/usb/core/hcd-pci.c
index 622b4a48e732..57ed9e400c06 100644
--- a/drivers/usb/core/hcd-pci.c
+++ b/drivers/usb/core/hcd-pci.c
@@ -493,6 +493,15 @@ static int hcd_pci_suspend_noirq(struct device *dev)
493 493
494 pci_save_state(pci_dev); 494 pci_save_state(pci_dev);
495 495
496 /*
497 * Some systems crash if an EHCI controller is in D3 during
498 * a sleep transition. We have to leave such controllers in D0.
499 */
500 if (hcd->broken_pci_sleep) {
501 dev_dbg(dev, "Staying in PCI D0\n");
502 return retval;
503 }
504
496 /* If the root hub is dead rather than suspended, disallow remote 505 /* If the root hub is dead rather than suspended, disallow remote
497 * wakeup. usb_hc_died() should ensure that both hosts are marked as 506 * wakeup. usb_hc_died() should ensure that both hosts are marked as
498 * dying, so we only need to check the primary roothub. 507 * dying, so we only need to check the primary roothub.
diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
index 9d7fc9a39933..140d3e11f212 100644
--- a/drivers/usb/core/hcd.c
+++ b/drivers/usb/core/hcd.c
@@ -1978,6 +1978,18 @@ int hcd_bus_suspend(struct usb_device *rhdev, pm_message_t msg)
1978 if (status == 0) { 1978 if (status == 0) {
1979 usb_set_device_state(rhdev, USB_STATE_SUSPENDED); 1979 usb_set_device_state(rhdev, USB_STATE_SUSPENDED);
1980 hcd->state = HC_STATE_SUSPENDED; 1980 hcd->state = HC_STATE_SUSPENDED;
1981
1982 /* Did we race with a root-hub wakeup event? */
1983 if (rhdev->do_remote_wakeup) {
1984 char buffer[6];
1985
1986 status = hcd->driver->hub_status_data(hcd, buffer);
1987 if (status != 0) {
1988 dev_dbg(&rhdev->dev, "suspend raced with wakeup event\n");
1989 hcd_bus_resume(rhdev, PMSG_AUTO_RESUME);
1990 status = -EBUSY;
1991 }
1992 }
1981 } else { 1993 } else {
1982 spin_lock_irq(&hcd_root_hub_lock); 1994 spin_lock_irq(&hcd_root_hub_lock);
1983 if (!HCD_DEAD(hcd)) { 1995 if (!HCD_DEAD(hcd)) {
diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index 28664eb7f555..ec6c97dadbe4 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -1667,7 +1667,6 @@ void usb_disconnect(struct usb_device **pdev)
1667{ 1667{
1668 struct usb_device *udev = *pdev; 1668 struct usb_device *udev = *pdev;
1669 int i; 1669 int i;
1670 struct usb_hcd *hcd = bus_to_hcd(udev->bus);
1671 1670
1672 /* mark the device as inactive, so any further urb submissions for 1671 /* mark the device as inactive, so any further urb submissions for
1673 * this device (and any of its children) will fail immediately. 1672 * this device (and any of its children) will fail immediately.
@@ -1690,9 +1689,7 @@ void usb_disconnect(struct usb_device **pdev)
1690 * so that the hardware is now fully quiesced. 1689 * so that the hardware is now fully quiesced.
1691 */ 1690 */
1692 dev_dbg (&udev->dev, "unregistering device\n"); 1691 dev_dbg (&udev->dev, "unregistering device\n");
1693 mutex_lock(hcd->bandwidth_mutex);
1694 usb_disable_device(udev, 0); 1692 usb_disable_device(udev, 0);
1695 mutex_unlock(hcd->bandwidth_mutex);
1696 usb_hcd_synchronize_unlinks(udev); 1693 usb_hcd_synchronize_unlinks(udev);
1697 1694
1698 usb_remove_ep_devs(&udev->ep0); 1695 usb_remove_ep_devs(&udev->ep0);
@@ -3163,6 +3160,22 @@ hub_port_init (struct usb_hub *hub, struct usb_device *udev, int port1,
3163 if (retval) 3160 if (retval)
3164 goto fail; 3161 goto fail;
3165 3162
3163 /*
3164 * Some superspeed devices have finished the link training process
3165 * and attached to a superspeed hub port, but the device descriptor
3166 * got from those devices show they aren't superspeed devices. Warm
3167 * reset the port attached by the devices can fix them.
3168 */
3169 if ((udev->speed == USB_SPEED_SUPER) &&
3170 (le16_to_cpu(udev->descriptor.bcdUSB) < 0x0300)) {
3171 dev_err(&udev->dev, "got a wrong device descriptor, "
3172 "warm reset device\n");
3173 hub_port_reset(hub, port1, udev,
3174 HUB_BH_RESET_TIME, true);
3175 retval = -EINVAL;
3176 goto fail;
3177 }
3178
3166 if (udev->descriptor.bMaxPacketSize0 == 0xff || 3179 if (udev->descriptor.bMaxPacketSize0 == 0xff ||
3167 udev->speed == USB_SPEED_SUPER) 3180 udev->speed == USB_SPEED_SUPER)
3168 i = 512; 3181 i = 512;
diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c
index b3bdfede45e6..ca717da3be95 100644
--- a/drivers/usb/core/message.c
+++ b/drivers/usb/core/message.c
@@ -308,7 +308,8 @@ static void sg_complete(struct urb *urb)
308 retval = usb_unlink_urb(io->urbs [i]); 308 retval = usb_unlink_urb(io->urbs [i]);
309 if (retval != -EINPROGRESS && 309 if (retval != -EINPROGRESS &&
310 retval != -ENODEV && 310 retval != -ENODEV &&
311 retval != -EBUSY) 311 retval != -EBUSY &&
312 retval != -EIDRM)
312 dev_err(&io->dev->dev, 313 dev_err(&io->dev->dev,
313 "%s, unlink --> %d\n", 314 "%s, unlink --> %d\n",
314 __func__, retval); 315 __func__, retval);
@@ -317,7 +318,6 @@ static void sg_complete(struct urb *urb)
317 } 318 }
318 spin_lock(&io->lock); 319 spin_lock(&io->lock);
319 } 320 }
320 urb->dev = NULL;
321 321
322 /* on the last completion, signal usb_sg_wait() */ 322 /* on the last completion, signal usb_sg_wait() */
323 io->bytes += urb->actual_length; 323 io->bytes += urb->actual_length;
@@ -524,7 +524,6 @@ void usb_sg_wait(struct usb_sg_request *io)
524 case -ENXIO: /* hc didn't queue this one */ 524 case -ENXIO: /* hc didn't queue this one */
525 case -EAGAIN: 525 case -EAGAIN:
526 case -ENOMEM: 526 case -ENOMEM:
527 io->urbs[i]->dev = NULL;
528 retval = 0; 527 retval = 0;
529 yield(); 528 yield();
530 break; 529 break;
@@ -542,7 +541,6 @@ void usb_sg_wait(struct usb_sg_request *io)
542 541
543 /* fail any uncompleted urbs */ 542 /* fail any uncompleted urbs */
544 default: 543 default:
545 io->urbs[i]->dev = NULL;
546 io->urbs[i]->status = retval; 544 io->urbs[i]->status = retval;
547 dev_dbg(&io->dev->dev, "%s, submit --> %d\n", 545 dev_dbg(&io->dev->dev, "%s, submit --> %d\n",
548 __func__, retval); 546 __func__, retval);
@@ -593,7 +591,10 @@ void usb_sg_cancel(struct usb_sg_request *io)
593 if (!io->urbs [i]->dev) 591 if (!io->urbs [i]->dev)
594 continue; 592 continue;
595 retval = usb_unlink_urb(io->urbs [i]); 593 retval = usb_unlink_urb(io->urbs [i]);
596 if (retval != -EINPROGRESS && retval != -EBUSY) 594 if (retval != -EINPROGRESS
595 && retval != -ENODEV
596 && retval != -EBUSY
597 && retval != -EIDRM)
597 dev_warn(&io->dev->dev, "%s, unlink --> %d\n", 598 dev_warn(&io->dev->dev, "%s, unlink --> %d\n",
598 __func__, retval); 599 __func__, retval);
599 } 600 }
@@ -1135,8 +1136,6 @@ void usb_disable_interface(struct usb_device *dev, struct usb_interface *intf,
1135 * Deallocates hcd/hardware state for the endpoints (nuking all or most 1136 * Deallocates hcd/hardware state for the endpoints (nuking all or most
1136 * pending urbs) and usbcore state for the interfaces, so that usbcore 1137 * pending urbs) and usbcore state for the interfaces, so that usbcore
1137 * must usb_set_configuration() before any interfaces could be used. 1138 * must usb_set_configuration() before any interfaces could be used.
1138 *
1139 * Must be called with hcd->bandwidth_mutex held.
1140 */ 1139 */
1141void usb_disable_device(struct usb_device *dev, int skip_ep0) 1140void usb_disable_device(struct usb_device *dev, int skip_ep0)
1142{ 1141{
@@ -1189,7 +1188,9 @@ void usb_disable_device(struct usb_device *dev, int skip_ep0)
1189 usb_disable_endpoint(dev, i + USB_DIR_IN, false); 1188 usb_disable_endpoint(dev, i + USB_DIR_IN, false);
1190 } 1189 }
1191 /* Remove endpoints from the host controller internal state */ 1190 /* Remove endpoints from the host controller internal state */
1191 mutex_lock(hcd->bandwidth_mutex);
1192 usb_hcd_alloc_bandwidth(dev, NULL, NULL, NULL); 1192 usb_hcd_alloc_bandwidth(dev, NULL, NULL, NULL);
1193 mutex_unlock(hcd->bandwidth_mutex);
1193 /* Second pass: remove endpoint pointers */ 1194 /* Second pass: remove endpoint pointers */
1194 } 1195 }
1195 for (i = skip_ep0; i < 16; ++i) { 1196 for (i = skip_ep0; i < 16; ++i) {
@@ -1749,7 +1750,6 @@ free_interfaces:
1749 /* if it's already configured, clear out old state first. 1750 /* if it's already configured, clear out old state first.
1750 * getting rid of old interfaces means unbinding their drivers. 1751 * getting rid of old interfaces means unbinding their drivers.
1751 */ 1752 */
1752 mutex_lock(hcd->bandwidth_mutex);
1753 if (dev->state != USB_STATE_ADDRESS) 1753 if (dev->state != USB_STATE_ADDRESS)
1754 usb_disable_device(dev, 1); /* Skip ep0 */ 1754 usb_disable_device(dev, 1); /* Skip ep0 */
1755 1755
@@ -1762,6 +1762,7 @@ free_interfaces:
1762 * host controller will not allow submissions to dropped endpoints. If 1762 * host controller will not allow submissions to dropped endpoints. If
1763 * this call fails, the device state is unchanged. 1763 * this call fails, the device state is unchanged.
1764 */ 1764 */
1765 mutex_lock(hcd->bandwidth_mutex);
1765 ret = usb_hcd_alloc_bandwidth(dev, cp, NULL, NULL); 1766 ret = usb_hcd_alloc_bandwidth(dev, cp, NULL, NULL);
1766 if (ret < 0) { 1767 if (ret < 0) {
1767 mutex_unlock(hcd->bandwidth_mutex); 1768 mutex_unlock(hcd->bandwidth_mutex);
diff --git a/drivers/usb/core/urb.c b/drivers/usb/core/urb.c
index 7239a73c1b8c..cd9b3a2cd8a7 100644
--- a/drivers/usb/core/urb.c
+++ b/drivers/usb/core/urb.c
@@ -539,6 +539,10 @@ EXPORT_SYMBOL_GPL(usb_submit_urb);
539 * never submitted, or it was unlinked before, or the hardware is already 539 * never submitted, or it was unlinked before, or the hardware is already
540 * finished with it), even if the completion handler has not yet run. 540 * finished with it), even if the completion handler has not yet run.
541 * 541 *
542 * The URB must not be deallocated while this routine is running. In
543 * particular, when a driver calls this routine, it must insure that the
544 * completion handler cannot deallocate the URB.
545 *
542 * Unlinking and Endpoint Queues: 546 * Unlinking and Endpoint Queues:
543 * 547 *
544 * [The behaviors and guarantees described below do not apply to virtual 548 * [The behaviors and guarantees described below do not apply to virtual
@@ -603,6 +607,10 @@ EXPORT_SYMBOL_GPL(usb_unlink_urb);
603 * with error -EPERM. Thus even if the URB's completion handler always 607 * with error -EPERM. Thus even if the URB's completion handler always
604 * tries to resubmit, it will not succeed and the URB will become idle. 608 * tries to resubmit, it will not succeed and the URB will become idle.
605 * 609 *
610 * The URB must not be deallocated while this routine is running. In
611 * particular, when a driver calls this routine, it must insure that the
612 * completion handler cannot deallocate the URB.
613 *
606 * This routine may not be used in an interrupt context (such as a bottom 614 * This routine may not be used in an interrupt context (such as a bottom
607 * half or a completion handler), or when holding a spinlock, or in other 615 * half or a completion handler), or when holding a spinlock, or in other
608 * situations where the caller can't schedule(). 616 * situations where the caller can't schedule().
@@ -640,6 +648,10 @@ EXPORT_SYMBOL_GPL(usb_kill_urb);
640 * with error -EPERM. Thus even if the URB's completion handler always 648 * with error -EPERM. Thus even if the URB's completion handler always
641 * tries to resubmit, it will not succeed and the URB will become idle. 649 * tries to resubmit, it will not succeed and the URB will become idle.
642 * 650 *
651 * The URB must not be deallocated while this routine is running. In
652 * particular, when a driver calls this routine, it must insure that the
653 * completion handler cannot deallocate the URB.
654 *
643 * This routine may not be used in an interrupt context (such as a bottom 655 * This routine may not be used in an interrupt context (such as a bottom
644 * half or a completion handler), or when holding a spinlock, or in other 656 * half or a completion handler), or when holding a spinlock, or in other
645 * situations where the caller can't schedule(). 657 * situations where the caller can't schedule().
diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
index 7bd815a507e8..99b58d84553a 100644
--- a/drivers/usb/dwc3/core.c
+++ b/drivers/usb/dwc3/core.c
@@ -206,11 +206,11 @@ static void dwc3_free_event_buffers(struct dwc3 *dwc)
206 206
207 for (i = 0; i < dwc->num_event_buffers; i++) { 207 for (i = 0; i < dwc->num_event_buffers; i++) {
208 evt = dwc->ev_buffs[i]; 208 evt = dwc->ev_buffs[i];
209 if (evt) { 209 if (evt)
210 dwc3_free_one_event_buffer(dwc, evt); 210 dwc3_free_one_event_buffer(dwc, evt);
211 dwc->ev_buffs[i] = NULL;
212 }
213 } 211 }
212
213 kfree(dwc->ev_buffs);
214} 214}
215 215
216/** 216/**
diff --git a/drivers/usb/dwc3/ep0.c b/drivers/usb/dwc3/ep0.c
index 25910e251c04..3584a169886f 100644
--- a/drivers/usb/dwc3/ep0.c
+++ b/drivers/usb/dwc3/ep0.c
@@ -353,6 +353,9 @@ static int dwc3_ep0_handle_feature(struct dwc3 *dwc,
353 353
354 dwc->test_mode_nr = wIndex >> 8; 354 dwc->test_mode_nr = wIndex >> 8;
355 dwc->test_mode = true; 355 dwc->test_mode = true;
356 break;
357 default:
358 return -EINVAL;
356 } 359 }
357 break; 360 break;
358 361
@@ -559,15 +562,20 @@ static void dwc3_ep0_complete_data(struct dwc3 *dwc,
559 length = trb->size & DWC3_TRB_SIZE_MASK; 562 length = trb->size & DWC3_TRB_SIZE_MASK;
560 563
561 if (dwc->ep0_bounced) { 564 if (dwc->ep0_bounced) {
565 unsigned transfer_size = ur->length;
566 unsigned maxp = ep0->endpoint.maxpacket;
567
568 transfer_size += (maxp - (transfer_size % maxp));
562 transferred = min_t(u32, ur->length, 569 transferred = min_t(u32, ur->length,
563 ep0->endpoint.maxpacket - length); 570 transfer_size - length);
564 memcpy(ur->buf, dwc->ep0_bounce, transferred); 571 memcpy(ur->buf, dwc->ep0_bounce, transferred);
565 dwc->ep0_bounced = false; 572 dwc->ep0_bounced = false;
566 } else { 573 } else {
567 transferred = ur->length - length; 574 transferred = ur->length - length;
568 ur->actual += transferred;
569 } 575 }
570 576
577 ur->actual += transferred;
578
571 if ((epnum & 1) && ur->actual < ur->length) { 579 if ((epnum & 1) && ur->actual < ur->length) {
572 /* for some reason we did not get everything out */ 580 /* for some reason we did not get everything out */
573 581
diff --git a/drivers/usb/gadget/at91_udc.c b/drivers/usb/gadget/at91_udc.c
index 0c935d7c65bd..9d7bcd910074 100644
--- a/drivers/usb/gadget/at91_udc.c
+++ b/drivers/usb/gadget/at91_udc.c
@@ -1863,8 +1863,8 @@ static int __devinit at91udc_probe(struct platform_device *pdev)
1863 mod_timer(&udc->vbus_timer, 1863 mod_timer(&udc->vbus_timer,
1864 jiffies + VBUS_POLL_TIMEOUT); 1864 jiffies + VBUS_POLL_TIMEOUT);
1865 } else { 1865 } else {
1866 if (request_irq(udc->board.vbus_pin, at91_vbus_irq, 1866 if (request_irq(gpio_to_irq(udc->board.vbus_pin),
1867 0, driver_name, udc)) { 1867 at91_vbus_irq, 0, driver_name, udc)) {
1868 DBG("request vbus irq %d failed\n", 1868 DBG("request vbus irq %d failed\n",
1869 udc->board.vbus_pin); 1869 udc->board.vbus_pin);
1870 retval = -EBUSY; 1870 retval = -EBUSY;
@@ -1886,7 +1886,7 @@ static int __devinit at91udc_probe(struct platform_device *pdev)
1886 return 0; 1886 return 0;
1887fail4: 1887fail4:
1888 if (gpio_is_valid(udc->board.vbus_pin) && !udc->board.vbus_polled) 1888 if (gpio_is_valid(udc->board.vbus_pin) && !udc->board.vbus_polled)
1889 free_irq(udc->board.vbus_pin, udc); 1889 free_irq(gpio_to_irq(udc->board.vbus_pin), udc);
1890fail3: 1890fail3:
1891 if (gpio_is_valid(udc->board.vbus_pin)) 1891 if (gpio_is_valid(udc->board.vbus_pin))
1892 gpio_free(udc->board.vbus_pin); 1892 gpio_free(udc->board.vbus_pin);
@@ -1924,7 +1924,7 @@ static int __exit at91udc_remove(struct platform_device *pdev)
1924 device_init_wakeup(&pdev->dev, 0); 1924 device_init_wakeup(&pdev->dev, 0);
1925 remove_debug_file(udc); 1925 remove_debug_file(udc);
1926 if (gpio_is_valid(udc->board.vbus_pin)) { 1926 if (gpio_is_valid(udc->board.vbus_pin)) {
1927 free_irq(udc->board.vbus_pin, udc); 1927 free_irq(gpio_to_irq(udc->board.vbus_pin), udc);
1928 gpio_free(udc->board.vbus_pin); 1928 gpio_free(udc->board.vbus_pin);
1929 } 1929 }
1930 free_irq(udc->udp_irq, udc); 1930 free_irq(udc->udp_irq, udc);
diff --git a/drivers/usb/gadget/dummy_hcd.c b/drivers/usb/gadget/dummy_hcd.c
index a6dfd2164166..170cbe89d9f8 100644
--- a/drivers/usb/gadget/dummy_hcd.c
+++ b/drivers/usb/gadget/dummy_hcd.c
@@ -927,7 +927,6 @@ static int dummy_udc_stop(struct usb_gadget *g,
927 927
928 dum->driver = NULL; 928 dum->driver = NULL;
929 929
930 dummy_pullup(&dum->gadget, 0);
931 return 0; 930 return 0;
932} 931}
933 932
diff --git a/drivers/usb/gadget/f_fs.c b/drivers/usb/gadget/f_fs.c
index 1cbba70836bc..f52cb1ae45d9 100644
--- a/drivers/usb/gadget/f_fs.c
+++ b/drivers/usb/gadget/f_fs.c
@@ -712,7 +712,7 @@ static long ffs_ep0_ioctl(struct file *file, unsigned code, unsigned long value)
712 if (code == FUNCTIONFS_INTERFACE_REVMAP) { 712 if (code == FUNCTIONFS_INTERFACE_REVMAP) {
713 struct ffs_function *func = ffs->func; 713 struct ffs_function *func = ffs->func;
714 ret = func ? ffs_func_revmap_intf(func, value) : -ENODEV; 714 ret = func ? ffs_func_revmap_intf(func, value) : -ENODEV;
715 } else if (gadget->ops->ioctl) { 715 } else if (gadget && gadget->ops->ioctl) {
716 ret = gadget->ops->ioctl(gadget, code, value); 716 ret = gadget->ops->ioctl(gadget, code, value);
717 } else { 717 } else {
718 ret = -ENOTTY; 718 ret = -ENOTTY;
@@ -1382,6 +1382,7 @@ static void functionfs_unbind(struct ffs_data *ffs)
1382 ffs->ep0req = NULL; 1382 ffs->ep0req = NULL;
1383 ffs->gadget = NULL; 1383 ffs->gadget = NULL;
1384 ffs_data_put(ffs); 1384 ffs_data_put(ffs);
1385 clear_bit(FFS_FL_BOUND, &ffs->flags);
1385 } 1386 }
1386} 1387}
1387 1388
diff --git a/drivers/usb/gadget/f_mass_storage.c b/drivers/usb/gadget/f_mass_storage.c
index a371e966425f..cb8c162cae5a 100644
--- a/drivers/usb/gadget/f_mass_storage.c
+++ b/drivers/usb/gadget/f_mass_storage.c
@@ -2189,7 +2189,7 @@ unknown_cmnd:
2189 common->data_size_from_cmnd = 0; 2189 common->data_size_from_cmnd = 0;
2190 sprintf(unknown, "Unknown x%02x", common->cmnd[0]); 2190 sprintf(unknown, "Unknown x%02x", common->cmnd[0]);
2191 reply = check_command(common, common->cmnd_size, 2191 reply = check_command(common, common->cmnd_size,
2192 DATA_DIR_UNKNOWN, 0xff, 0, unknown); 2192 DATA_DIR_UNKNOWN, ~0, 0, unknown);
2193 if (reply == 0) { 2193 if (reply == 0) {
2194 common->curlun->sense_data = SS_INVALID_COMMAND; 2194 common->curlun->sense_data = SS_INVALID_COMMAND;
2195 reply = -EINVAL; 2195 reply = -EINVAL;
diff --git a/drivers/usb/gadget/f_rndis.c b/drivers/usb/gadget/f_rndis.c
index 7b1cf18df5e3..52343654f5df 100644
--- a/drivers/usb/gadget/f_rndis.c
+++ b/drivers/usb/gadget/f_rndis.c
@@ -500,6 +500,7 @@ rndis_setup(struct usb_function *f, const struct usb_ctrlrequest *ctrl)
500 if (buf) { 500 if (buf) {
501 memcpy(req->buf, buf, n); 501 memcpy(req->buf, buf, n);
502 req->complete = rndis_response_complete; 502 req->complete = rndis_response_complete;
503 req->context = rndis;
503 rndis_free_response(rndis->config, buf); 504 rndis_free_response(rndis->config, buf);
504 value = n; 505 value = n;
505 } 506 }
diff --git a/drivers/usb/gadget/file_storage.c b/drivers/usb/gadget/file_storage.c
index 4fac56927741..a896d73f7a93 100644
--- a/drivers/usb/gadget/file_storage.c
+++ b/drivers/usb/gadget/file_storage.c
@@ -2579,7 +2579,7 @@ static int do_scsi_command(struct fsg_dev *fsg)
2579 fsg->data_size_from_cmnd = 0; 2579 fsg->data_size_from_cmnd = 0;
2580 sprintf(unknown, "Unknown x%02x", fsg->cmnd[0]); 2580 sprintf(unknown, "Unknown x%02x", fsg->cmnd[0]);
2581 if ((reply = check_command(fsg, fsg->cmnd_size, 2581 if ((reply = check_command(fsg, fsg->cmnd_size,
2582 DATA_DIR_UNKNOWN, 0xff, 0, unknown)) == 0) { 2582 DATA_DIR_UNKNOWN, ~0, 0, unknown)) == 0) {
2583 fsg->curlun->sense_data = SS_INVALID_COMMAND; 2583 fsg->curlun->sense_data = SS_INVALID_COMMAND;
2584 reply = -EINVAL; 2584 reply = -EINVAL;
2585 } 2585 }
diff --git a/drivers/usb/gadget/fsl_udc_core.c b/drivers/usb/gadget/fsl_udc_core.c
index 5f94e79cd6b9..55abfb6bd612 100644
--- a/drivers/usb/gadget/fsl_udc_core.c
+++ b/drivers/usb/gadget/fsl_udc_core.c
@@ -730,7 +730,7 @@ static void fsl_queue_td(struct fsl_ep *ep, struct fsl_req *req)
730 : (1 << (ep_index(ep))); 730 : (1 << (ep_index(ep)));
731 731
732 /* check if the pipe is empty */ 732 /* check if the pipe is empty */
733 if (!(list_empty(&ep->queue))) { 733 if (!(list_empty(&ep->queue)) && !(ep_index(ep) == 0)) {
734 /* Add td to the end */ 734 /* Add td to the end */
735 struct fsl_req *lastreq; 735 struct fsl_req *lastreq;
736 lastreq = list_entry(ep->queue.prev, struct fsl_req, queue); 736 lastreq = list_entry(ep->queue.prev, struct fsl_req, queue);
@@ -918,10 +918,6 @@ fsl_ep_queue(struct usb_ep *_ep, struct usb_request *_req, gfp_t gfp_flags)
918 return -ENOMEM; 918 return -ENOMEM;
919 } 919 }
920 920
921 /* Update ep0 state */
922 if ((ep_index(ep) == 0))
923 udc->ep0_state = DATA_STATE_XMIT;
924
925 /* irq handler advances the queue */ 921 /* irq handler advances the queue */
926 if (req != NULL) 922 if (req != NULL)
927 list_add_tail(&req->queue, &ep->queue); 923 list_add_tail(&req->queue, &ep->queue);
@@ -1279,7 +1275,8 @@ static int ep0_prime_status(struct fsl_udc *udc, int direction)
1279 udc->ep0_dir = USB_DIR_OUT; 1275 udc->ep0_dir = USB_DIR_OUT;
1280 1276
1281 ep = &udc->eps[0]; 1277 ep = &udc->eps[0];
1282 udc->ep0_state = WAIT_FOR_OUT_STATUS; 1278 if (udc->ep0_state != DATA_STATE_XMIT)
1279 udc->ep0_state = WAIT_FOR_OUT_STATUS;
1283 1280
1284 req->ep = ep; 1281 req->ep = ep;
1285 req->req.length = 0; 1282 req->req.length = 0;
@@ -1384,6 +1381,9 @@ static void ch9getstatus(struct fsl_udc *udc, u8 request_type, u16 value,
1384 1381
1385 list_add_tail(&req->queue, &ep->queue); 1382 list_add_tail(&req->queue, &ep->queue);
1386 udc->ep0_state = DATA_STATE_XMIT; 1383 udc->ep0_state = DATA_STATE_XMIT;
1384 if (ep0_prime_status(udc, EP_DIR_OUT))
1385 ep0stall(udc);
1386
1387 return; 1387 return;
1388stall: 1388stall:
1389 ep0stall(udc); 1389 ep0stall(udc);
@@ -1492,6 +1492,14 @@ static void setup_received_irq(struct fsl_udc *udc,
1492 spin_lock(&udc->lock); 1492 spin_lock(&udc->lock);
1493 udc->ep0_state = (setup->bRequestType & USB_DIR_IN) 1493 udc->ep0_state = (setup->bRequestType & USB_DIR_IN)
1494 ? DATA_STATE_XMIT : DATA_STATE_RECV; 1494 ? DATA_STATE_XMIT : DATA_STATE_RECV;
1495 /*
1496 * If the data stage is IN, send status prime immediately.
1497 * See 2.0 Spec chapter 8.5.3.3 for detail.
1498 */
1499 if (udc->ep0_state == DATA_STATE_XMIT)
1500 if (ep0_prime_status(udc, EP_DIR_OUT))
1501 ep0stall(udc);
1502
1495 } else { 1503 } else {
1496 /* No data phase, IN status from gadget */ 1504 /* No data phase, IN status from gadget */
1497 udc->ep0_dir = USB_DIR_IN; 1505 udc->ep0_dir = USB_DIR_IN;
@@ -1520,9 +1528,8 @@ static void ep0_req_complete(struct fsl_udc *udc, struct fsl_ep *ep0,
1520 1528
1521 switch (udc->ep0_state) { 1529 switch (udc->ep0_state) {
1522 case DATA_STATE_XMIT: 1530 case DATA_STATE_XMIT:
1523 /* receive status phase */ 1531 /* already primed at setup_received_irq */
1524 if (ep0_prime_status(udc, EP_DIR_OUT)) 1532 udc->ep0_state = WAIT_FOR_OUT_STATUS;
1525 ep0stall(udc);
1526 break; 1533 break;
1527 case DATA_STATE_RECV: 1534 case DATA_STATE_RECV:
1528 /* send status phase */ 1535 /* send status phase */
diff --git a/drivers/usb/gadget/g_ffs.c b/drivers/usb/gadget/g_ffs.c
index 331cd6729d3c..a85eaf40b948 100644
--- a/drivers/usb/gadget/g_ffs.c
+++ b/drivers/usb/gadget/g_ffs.c
@@ -161,7 +161,7 @@ static struct usb_composite_driver gfs_driver = {
161static struct ffs_data *gfs_ffs_data; 161static struct ffs_data *gfs_ffs_data;
162static unsigned long gfs_registered; 162static unsigned long gfs_registered;
163 163
164static int gfs_init(void) 164static int __init gfs_init(void)
165{ 165{
166 ENTER(); 166 ENTER();
167 167
@@ -169,7 +169,7 @@ static int gfs_init(void)
169} 169}
170module_init(gfs_init); 170module_init(gfs_init);
171 171
172static void gfs_exit(void) 172static void __exit gfs_exit(void)
173{ 173{
174 ENTER(); 174 ENTER();
175 175
diff --git a/drivers/usb/gadget/inode.c b/drivers/usb/gadget/inode.c
index 8793f32bab11..e58b16442971 100644
--- a/drivers/usb/gadget/inode.c
+++ b/drivers/usb/gadget/inode.c
@@ -1574,7 +1574,6 @@ static void destroy_ep_files (struct dev_data *dev)
1574 DBG (dev, "%s %d\n", __func__, dev->state); 1574 DBG (dev, "%s %d\n", __func__, dev->state);
1575 1575
1576 /* dev->state must prevent interference */ 1576 /* dev->state must prevent interference */
1577restart:
1578 spin_lock_irq (&dev->lock); 1577 spin_lock_irq (&dev->lock);
1579 while (!list_empty(&dev->epfiles)) { 1578 while (!list_empty(&dev->epfiles)) {
1580 struct ep_data *ep; 1579 struct ep_data *ep;
diff --git a/drivers/usb/gadget/s3c-hsotg.c b/drivers/usb/gadget/s3c-hsotg.c
index 69295ba9d99a..105b206cd844 100644
--- a/drivers/usb/gadget/s3c-hsotg.c
+++ b/drivers/usb/gadget/s3c-hsotg.c
@@ -340,7 +340,7 @@ static void s3c_hsotg_init_fifo(struct s3c_hsotg *hsotg)
340 /* currently we allocate TX FIFOs for all possible endpoints, 340 /* currently we allocate TX FIFOs for all possible endpoints,
341 * and assume that they are all the same size. */ 341 * and assume that they are all the same size. */
342 342
343 for (ep = 0; ep <= 15; ep++) { 343 for (ep = 1; ep <= 15; ep++) {
344 val = addr; 344 val = addr;
345 val |= size << S3C_DPTXFSIZn_DPTxFSize_SHIFT; 345 val |= size << S3C_DPTXFSIZn_DPTxFSize_SHIFT;
346 addr += size; 346 addr += size;
@@ -741,7 +741,7 @@ static void s3c_hsotg_start_req(struct s3c_hsotg *hsotg,
741 /* write size / packets */ 741 /* write size / packets */
742 writel(epsize, hsotg->regs + epsize_reg); 742 writel(epsize, hsotg->regs + epsize_reg);
743 743
744 if (using_dma(hsotg)) { 744 if (using_dma(hsotg) && !continuing) {
745 unsigned int dma_reg; 745 unsigned int dma_reg;
746 746
747 /* write DMA address to control register, buffer already 747 /* write DMA address to control register, buffer already
@@ -1696,10 +1696,12 @@ static void s3c_hsotg_set_ep_maxpacket(struct s3c_hsotg *hsotg,
1696 reg |= mpsval; 1696 reg |= mpsval;
1697 writel(reg, regs + S3C_DIEPCTL(ep)); 1697 writel(reg, regs + S3C_DIEPCTL(ep));
1698 1698
1699 reg = readl(regs + S3C_DOEPCTL(ep)); 1699 if (ep) {
1700 reg &= ~S3C_DxEPCTL_MPS_MASK; 1700 reg = readl(regs + S3C_DOEPCTL(ep));
1701 reg |= mpsval; 1701 reg &= ~S3C_DxEPCTL_MPS_MASK;
1702 writel(reg, regs + S3C_DOEPCTL(ep)); 1702 reg |= mpsval;
1703 writel(reg, regs + S3C_DOEPCTL(ep));
1704 }
1703 1705
1704 return; 1706 return;
1705 1707
@@ -1919,7 +1921,8 @@ static void s3c_hsotg_epint(struct s3c_hsotg *hsotg, unsigned int idx,
1919 ints & S3C_DIEPMSK_TxFIFOEmpty) { 1921 ints & S3C_DIEPMSK_TxFIFOEmpty) {
1920 dev_dbg(hsotg->dev, "%s: ep%d: TxFIFOEmpty\n", 1922 dev_dbg(hsotg->dev, "%s: ep%d: TxFIFOEmpty\n",
1921 __func__, idx); 1923 __func__, idx);
1922 s3c_hsotg_trytx(hsotg, hs_ep); 1924 if (!using_dma(hsotg))
1925 s3c_hsotg_trytx(hsotg, hs_ep);
1923 } 1926 }
1924 } 1927 }
1925} 1928}
diff --git a/drivers/usb/gadget/udc-core.c b/drivers/usb/gadget/udc-core.c
index 56da49f31d6c..e5e44f8cde9a 100644
--- a/drivers/usb/gadget/udc-core.c
+++ b/drivers/usb/gadget/udc-core.c
@@ -263,9 +263,9 @@ static void usb_gadget_remove_driver(struct usb_udc *udc)
263 263
264 if (udc_is_newstyle(udc)) { 264 if (udc_is_newstyle(udc)) {
265 udc->driver->disconnect(udc->gadget); 265 udc->driver->disconnect(udc->gadget);
266 usb_gadget_disconnect(udc->gadget);
266 udc->driver->unbind(udc->gadget); 267 udc->driver->unbind(udc->gadget);
267 usb_gadget_udc_stop(udc->gadget, udc->driver); 268 usb_gadget_udc_stop(udc->gadget, udc->driver);
268 usb_gadget_disconnect(udc->gadget);
269 } else { 269 } else {
270 usb_gadget_stop(udc->gadget, udc->driver); 270 usb_gadget_stop(udc->gadget, udc->driver);
271 } 271 }
@@ -411,9 +411,13 @@ static ssize_t usb_udc_softconn_store(struct device *dev,
411 struct usb_udc *udc = container_of(dev, struct usb_udc, dev); 411 struct usb_udc *udc = container_of(dev, struct usb_udc, dev);
412 412
413 if (sysfs_streq(buf, "connect")) { 413 if (sysfs_streq(buf, "connect")) {
414 if (udc_is_newstyle(udc))
415 usb_gadget_udc_start(udc->gadget, udc->driver);
414 usb_gadget_connect(udc->gadget); 416 usb_gadget_connect(udc->gadget);
415 } else if (sysfs_streq(buf, "disconnect")) { 417 } else if (sysfs_streq(buf, "disconnect")) {
416 usb_gadget_disconnect(udc->gadget); 418 usb_gadget_disconnect(udc->gadget);
419 if (udc_is_newstyle(udc))
420 usb_gadget_udc_stop(udc->gadget, udc->driver);
417 } else { 421 } else {
418 dev_err(dev, "unsupported command '%s'\n", buf); 422 dev_err(dev, "unsupported command '%s'\n", buf);
419 return -EINVAL; 423 return -EINVAL;
diff --git a/drivers/usb/gadget/uvc.h b/drivers/usb/gadget/uvc.h
index bc78c606c12b..ca4e03a1c73a 100644
--- a/drivers/usb/gadget/uvc.h
+++ b/drivers/usb/gadget/uvc.h
@@ -28,7 +28,7 @@
28 28
29struct uvc_request_data 29struct uvc_request_data
30{ 30{
31 unsigned int length; 31 __s32 length;
32 __u8 data[60]; 32 __u8 data[60];
33}; 33};
34 34
diff --git a/drivers/usb/gadget/uvc_queue.c b/drivers/usb/gadget/uvc_queue.c
index d776adb2da67..0cdf89d32a15 100644
--- a/drivers/usb/gadget/uvc_queue.c
+++ b/drivers/usb/gadget/uvc_queue.c
@@ -543,11 +543,11 @@ done:
543 return ret; 543 return ret;
544} 544}
545 545
546/* called with queue->irqlock held.. */
546static struct uvc_buffer * 547static struct uvc_buffer *
547uvc_queue_next_buffer(struct uvc_video_queue *queue, struct uvc_buffer *buf) 548uvc_queue_next_buffer(struct uvc_video_queue *queue, struct uvc_buffer *buf)
548{ 549{
549 struct uvc_buffer *nextbuf; 550 struct uvc_buffer *nextbuf;
550 unsigned long flags;
551 551
552 if ((queue->flags & UVC_QUEUE_DROP_INCOMPLETE) && 552 if ((queue->flags & UVC_QUEUE_DROP_INCOMPLETE) &&
553 buf->buf.length != buf->buf.bytesused) { 553 buf->buf.length != buf->buf.bytesused) {
@@ -556,14 +556,12 @@ uvc_queue_next_buffer(struct uvc_video_queue *queue, struct uvc_buffer *buf)
556 return buf; 556 return buf;
557 } 557 }
558 558
559 spin_lock_irqsave(&queue->irqlock, flags);
560 list_del(&buf->queue); 559 list_del(&buf->queue);
561 if (!list_empty(&queue->irqqueue)) 560 if (!list_empty(&queue->irqqueue))
562 nextbuf = list_first_entry(&queue->irqqueue, struct uvc_buffer, 561 nextbuf = list_first_entry(&queue->irqqueue, struct uvc_buffer,
563 queue); 562 queue);
564 else 563 else
565 nextbuf = NULL; 564 nextbuf = NULL;
566 spin_unlock_irqrestore(&queue->irqlock, flags);
567 565
568 buf->buf.sequence = queue->sequence++; 566 buf->buf.sequence = queue->sequence++;
569 do_gettimeofday(&buf->buf.timestamp); 567 do_gettimeofday(&buf->buf.timestamp);
diff --git a/drivers/usb/gadget/uvc_v4l2.c b/drivers/usb/gadget/uvc_v4l2.c
index f6e083b50191..54d7ca559cb2 100644
--- a/drivers/usb/gadget/uvc_v4l2.c
+++ b/drivers/usb/gadget/uvc_v4l2.c
@@ -39,7 +39,7 @@ uvc_send_response(struct uvc_device *uvc, struct uvc_request_data *data)
39 if (data->length < 0) 39 if (data->length < 0)
40 return usb_ep_set_halt(cdev->gadget->ep0); 40 return usb_ep_set_halt(cdev->gadget->ep0);
41 41
42 req->length = min(uvc->event_length, data->length); 42 req->length = min_t(unsigned int, uvc->event_length, data->length);
43 req->zero = data->length < uvc->event_length; 43 req->zero = data->length < uvc->event_length;
44 req->dma = DMA_ADDR_INVALID; 44 req->dma = DMA_ADDR_INVALID;
45 45
diff --git a/drivers/usb/host/ehci-fsl.c b/drivers/usb/host/ehci-fsl.c
index 3e7345172e03..d0a84bd3f3eb 100644
--- a/drivers/usb/host/ehci-fsl.c
+++ b/drivers/usb/host/ehci-fsl.c
@@ -218,6 +218,9 @@ static void ehci_fsl_setup_phy(struct ehci_hcd *ehci,
218 u32 portsc; 218 u32 portsc;
219 struct usb_hcd *hcd = ehci_to_hcd(ehci); 219 struct usb_hcd *hcd = ehci_to_hcd(ehci);
220 void __iomem *non_ehci = hcd->regs; 220 void __iomem *non_ehci = hcd->regs;
221 struct fsl_usb2_platform_data *pdata;
222
223 pdata = hcd->self.controller->platform_data;
221 224
222 portsc = ehci_readl(ehci, &ehci->regs->port_status[port_offset]); 225 portsc = ehci_readl(ehci, &ehci->regs->port_status[port_offset]);
223 portsc &= ~(PORT_PTS_MSK | PORT_PTS_PTW); 226 portsc &= ~(PORT_PTS_MSK | PORT_PTS_PTW);
@@ -234,7 +237,9 @@ static void ehci_fsl_setup_phy(struct ehci_hcd *ehci,
234 /* fall through */ 237 /* fall through */
235 case FSL_USB2_PHY_UTMI: 238 case FSL_USB2_PHY_UTMI:
236 /* enable UTMI PHY */ 239 /* enable UTMI PHY */
237 setbits32(non_ehci + FSL_SOC_USB_CTRL, CTRL_UTMI_PHY_EN); 240 if (pdata->have_sysif_regs)
241 setbits32(non_ehci + FSL_SOC_USB_CTRL,
242 CTRL_UTMI_PHY_EN);
238 portsc |= PORT_PTS_UTMI; 243 portsc |= PORT_PTS_UTMI;
239 break; 244 break;
240 case FSL_USB2_PHY_NONE: 245 case FSL_USB2_PHY_NONE:
diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c
index 057cdda7a489..4a3bc5b7a06f 100644
--- a/drivers/usb/host/ehci-hcd.c
+++ b/drivers/usb/host/ehci-hcd.c
@@ -347,6 +347,8 @@ static int ehci_reset (struct ehci_hcd *ehci)
347 if (ehci->debug) 347 if (ehci->debug)
348 dbgp_external_startup(); 348 dbgp_external_startup();
349 349
350 ehci->port_c_suspend = ehci->suspended_ports =
351 ehci->resuming_ports = 0;
350 return retval; 352 return retval;
351} 353}
352 354
@@ -856,8 +858,13 @@ static irqreturn_t ehci_irq (struct usb_hcd *hcd)
856 goto dead; 858 goto dead;
857 } 859 }
858 860
861 /*
862 * We don't use STS_FLR, but some controllers don't like it to
863 * remain on, so mask it out along with the other status bits.
864 */
865 masked_status = status & (INTR_MASK | STS_FLR);
866
859 /* Shared IRQ? */ 867 /* Shared IRQ? */
860 masked_status = status & INTR_MASK;
861 if (!masked_status || unlikely(ehci->rh_state == EHCI_RH_HALTED)) { 868 if (!masked_status || unlikely(ehci->rh_state == EHCI_RH_HALTED)) {
862 spin_unlock(&ehci->lock); 869 spin_unlock(&ehci->lock);
863 return IRQ_NONE; 870 return IRQ_NONE;
@@ -908,7 +915,7 @@ static irqreturn_t ehci_irq (struct usb_hcd *hcd)
908 pcd_status = status; 915 pcd_status = status;
909 916
910 /* resume root hub? */ 917 /* resume root hub? */
911 if (!(cmd & CMD_RUN)) 918 if (ehci->rh_state == EHCI_RH_SUSPENDED)
912 usb_hcd_resume_root_hub(hcd); 919 usb_hcd_resume_root_hub(hcd);
913 920
914 /* get per-port change detect bits */ 921 /* get per-port change detect bits */
@@ -939,6 +946,7 @@ static irqreturn_t ehci_irq (struct usb_hcd *hcd)
939 * like usb_port_resume() does. 946 * like usb_port_resume() does.
940 */ 947 */
941 ehci->reset_done[i] = jiffies + msecs_to_jiffies(25); 948 ehci->reset_done[i] = jiffies + msecs_to_jiffies(25);
949 set_bit(i, &ehci->resuming_ports);
942 ehci_dbg (ehci, "port %d remote wakeup\n", i + 1); 950 ehci_dbg (ehci, "port %d remote wakeup\n", i + 1);
943 mod_timer(&hcd->rh_timer, ehci->reset_done[i]); 951 mod_timer(&hcd->rh_timer, ehci->reset_done[i]);
944 } 952 }
diff --git a/drivers/usb/host/ehci-hub.c b/drivers/usb/host/ehci-hub.c
index 256fbd42e48c..38fe07623152 100644
--- a/drivers/usb/host/ehci-hub.c
+++ b/drivers/usb/host/ehci-hub.c
@@ -223,15 +223,10 @@ static int ehci_bus_suspend (struct usb_hcd *hcd)
223 * remote wakeup, we must fail the suspend. 223 * remote wakeup, we must fail the suspend.
224 */ 224 */
225 if (hcd->self.root_hub->do_remote_wakeup) { 225 if (hcd->self.root_hub->do_remote_wakeup) {
226 port = HCS_N_PORTS(ehci->hcs_params); 226 if (ehci->resuming_ports) {
227 while (port--) { 227 spin_unlock_irq(&ehci->lock);
228 if (ehci->reset_done[port] != 0) { 228 ehci_dbg(ehci, "suspend failed because a port is resuming\n");
229 spin_unlock_irq(&ehci->lock); 229 return -EBUSY;
230 ehci_dbg(ehci, "suspend failed because "
231 "port %d is resuming\n",
232 port + 1);
233 return -EBUSY;
234 }
235 } 230 }
236 } 231 }
237 232
@@ -554,16 +549,12 @@ static int
554ehci_hub_status_data (struct usb_hcd *hcd, char *buf) 549ehci_hub_status_data (struct usb_hcd *hcd, char *buf)
555{ 550{
556 struct ehci_hcd *ehci = hcd_to_ehci (hcd); 551 struct ehci_hcd *ehci = hcd_to_ehci (hcd);
557 u32 temp, status = 0; 552 u32 temp, status;
558 u32 mask; 553 u32 mask;
559 int ports, i, retval = 1; 554 int ports, i, retval = 1;
560 unsigned long flags; 555 unsigned long flags;
561 u32 ppcd = 0; 556 u32 ppcd = 0;
562 557
563 /* if !USB_SUSPEND, root hub timers won't get shut down ... */
564 if (ehci->rh_state != EHCI_RH_RUNNING)
565 return 0;
566
567 /* init status to no-changes */ 558 /* init status to no-changes */
568 buf [0] = 0; 559 buf [0] = 0;
569 ports = HCS_N_PORTS (ehci->hcs_params); 560 ports = HCS_N_PORTS (ehci->hcs_params);
@@ -572,6 +563,11 @@ ehci_hub_status_data (struct usb_hcd *hcd, char *buf)
572 retval++; 563 retval++;
573 } 564 }
574 565
566 /* Inform the core about resumes-in-progress by returning
567 * a non-zero value even if there are no status changes.
568 */
569 status = ehci->resuming_ports;
570
575 /* Some boards (mostly VIA?) report bogus overcurrent indications, 571 /* Some boards (mostly VIA?) report bogus overcurrent indications,
576 * causing massive log spam unless we completely ignore them. It 572 * causing massive log spam unless we completely ignore them. It
577 * may be relevant that VIA VT8235 controllers, where PORT_POWER is 573 * may be relevant that VIA VT8235 controllers, where PORT_POWER is
@@ -846,6 +842,7 @@ static int ehci_hub_control (
846 ehci_writel(ehci, 842 ehci_writel(ehci,
847 temp & ~(PORT_RWC_BITS | PORT_RESUME), 843 temp & ~(PORT_RWC_BITS | PORT_RESUME),
848 status_reg); 844 status_reg);
845 clear_bit(wIndex, &ehci->resuming_ports);
849 retval = handshake(ehci, status_reg, 846 retval = handshake(ehci, status_reg,
850 PORT_RESUME, 0, 2000 /* 2msec */); 847 PORT_RESUME, 0, 2000 /* 2msec */);
851 if (retval != 0) { 848 if (retval != 0) {
@@ -864,6 +861,7 @@ static int ehci_hub_control (
864 ehci->reset_done[wIndex])) { 861 ehci->reset_done[wIndex])) {
865 status |= USB_PORT_STAT_C_RESET << 16; 862 status |= USB_PORT_STAT_C_RESET << 16;
866 ehci->reset_done [wIndex] = 0; 863 ehci->reset_done [wIndex] = 0;
864 clear_bit(wIndex, &ehci->resuming_ports);
867 865
868 /* force reset to complete */ 866 /* force reset to complete */
869 ehci_writel(ehci, temp & ~(PORT_RWC_BITS | PORT_RESET), 867 ehci_writel(ehci, temp & ~(PORT_RWC_BITS | PORT_RESET),
@@ -884,8 +882,10 @@ static int ehci_hub_control (
884 ehci_readl(ehci, status_reg)); 882 ehci_readl(ehci, status_reg));
885 } 883 }
886 884
887 if (!(temp & (PORT_RESUME|PORT_RESET))) 885 if (!(temp & (PORT_RESUME|PORT_RESET))) {
888 ehci->reset_done[wIndex] = 0; 886 ehci->reset_done[wIndex] = 0;
887 clear_bit(wIndex, &ehci->resuming_ports);
888 }
889 889
890 /* transfer dedicated ports to the companion hc */ 890 /* transfer dedicated ports to the companion hc */
891 if ((temp & PORT_CONNECT) && 891 if ((temp & PORT_CONNECT) &&
@@ -920,6 +920,7 @@ static int ehci_hub_control (
920 status |= USB_PORT_STAT_SUSPEND; 920 status |= USB_PORT_STAT_SUSPEND;
921 } else if (test_bit(wIndex, &ehci->suspended_ports)) { 921 } else if (test_bit(wIndex, &ehci->suspended_ports)) {
922 clear_bit(wIndex, &ehci->suspended_ports); 922 clear_bit(wIndex, &ehci->suspended_ports);
923 clear_bit(wIndex, &ehci->resuming_ports);
923 ehci->reset_done[wIndex] = 0; 924 ehci->reset_done[wIndex] = 0;
924 if (temp & PORT_PE) 925 if (temp & PORT_PE)
925 set_bit(wIndex, &ehci->port_c_suspend); 926 set_bit(wIndex, &ehci->port_c_suspend);
diff --git a/drivers/usb/host/ehci-omap.c b/drivers/usb/host/ehci-omap.c
index bba9850f32f0..5c78f9e71466 100644
--- a/drivers/usb/host/ehci-omap.c
+++ b/drivers/usb/host/ehci-omap.c
@@ -42,6 +42,7 @@
42#include <plat/usb.h> 42#include <plat/usb.h>
43#include <linux/regulator/consumer.h> 43#include <linux/regulator/consumer.h>
44#include <linux/pm_runtime.h> 44#include <linux/pm_runtime.h>
45#include <linux/gpio.h>
45 46
46/* EHCI Register Set */ 47/* EHCI Register Set */
47#define EHCI_INSNREG04 (0xA0) 48#define EHCI_INSNREG04 (0xA0)
@@ -191,6 +192,19 @@ static int ehci_hcd_omap_probe(struct platform_device *pdev)
191 } 192 }
192 } 193 }
193 194
195 if (pdata->phy_reset) {
196 if (gpio_is_valid(pdata->reset_gpio_port[0]))
197 gpio_request_one(pdata->reset_gpio_port[0],
198 GPIOF_OUT_INIT_LOW, "USB1 PHY reset");
199
200 if (gpio_is_valid(pdata->reset_gpio_port[1]))
201 gpio_request_one(pdata->reset_gpio_port[1],
202 GPIOF_OUT_INIT_LOW, "USB2 PHY reset");
203
204 /* Hold the PHY in RESET for enough time till DIR is high */
205 udelay(10);
206 }
207
194 pm_runtime_enable(dev); 208 pm_runtime_enable(dev);
195 pm_runtime_get_sync(dev); 209 pm_runtime_get_sync(dev);
196 210
@@ -237,6 +251,19 @@ static int ehci_hcd_omap_probe(struct platform_device *pdev)
237 /* root ports should always stay powered */ 251 /* root ports should always stay powered */
238 ehci_port_power(omap_ehci, 1); 252 ehci_port_power(omap_ehci, 1);
239 253
254 if (pdata->phy_reset) {
255 /* Hold the PHY in RESET for enough time till
256 * PHY is settled and ready
257 */
258 udelay(10);
259
260 if (gpio_is_valid(pdata->reset_gpio_port[0]))
261 gpio_set_value(pdata->reset_gpio_port[0], 1);
262
263 if (gpio_is_valid(pdata->reset_gpio_port[1]))
264 gpio_set_value(pdata->reset_gpio_port[1], 1);
265 }
266
240 return 0; 267 return 0;
241 268
242err_add_hcd: 269err_add_hcd:
@@ -259,8 +286,9 @@ err_io:
259 */ 286 */
260static int ehci_hcd_omap_remove(struct platform_device *pdev) 287static int ehci_hcd_omap_remove(struct platform_device *pdev)
261{ 288{
262 struct device *dev = &pdev->dev; 289 struct device *dev = &pdev->dev;
263 struct usb_hcd *hcd = dev_get_drvdata(dev); 290 struct usb_hcd *hcd = dev_get_drvdata(dev);
291 struct ehci_hcd_omap_platform_data *pdata = dev->platform_data;
264 292
265 usb_remove_hcd(hcd); 293 usb_remove_hcd(hcd);
266 disable_put_regulator(dev->platform_data); 294 disable_put_regulator(dev->platform_data);
@@ -269,6 +297,13 @@ static int ehci_hcd_omap_remove(struct platform_device *pdev)
269 pm_runtime_put_sync(dev); 297 pm_runtime_put_sync(dev);
270 pm_runtime_disable(dev); 298 pm_runtime_disable(dev);
271 299
300 if (pdata->phy_reset) {
301 if (gpio_is_valid(pdata->reset_gpio_port[0]))
302 gpio_free(pdata->reset_gpio_port[0]);
303
304 if (gpio_is_valid(pdata->reset_gpio_port[1]))
305 gpio_free(pdata->reset_gpio_port[1]);
306 }
272 return 0; 307 return 0;
273} 308}
274 309
diff --git a/drivers/usb/host/ehci-pci.c b/drivers/usb/host/ehci-pci.c
index 01bb7241d6ef..fe8dc069164e 100644
--- a/drivers/usb/host/ehci-pci.c
+++ b/drivers/usb/host/ehci-pci.c
@@ -144,6 +144,14 @@ static int ehci_pci_setup(struct usb_hcd *hcd)
144 hcd->has_tt = 1; 144 hcd->has_tt = 1;
145 tdi_reset(ehci); 145 tdi_reset(ehci);
146 } 146 }
147 if (pdev->subsystem_vendor == PCI_VENDOR_ID_ASUSTEK) {
148 /* EHCI #1 or #2 on 6 Series/C200 Series chipset */
149 if (pdev->device == 0x1c26 || pdev->device == 0x1c2d) {
150 ehci_info(ehci, "broken D3 during system sleep on ASUS\n");
151 hcd->broken_pci_sleep = 1;
152 device_set_wakeup_capable(&pdev->dev, false);
153 }
154 }
147 break; 155 break;
148 case PCI_VENDOR_ID_TDI: 156 case PCI_VENDOR_ID_TDI:
149 if (pdev->device == PCI_DEVICE_ID_TDI_EHCI) { 157 if (pdev->device == PCI_DEVICE_ID_TDI_EHCI) {
diff --git a/drivers/usb/host/ehci-tegra.c b/drivers/usb/host/ehci-tegra.c
index 3de48a2d7955..86183366647f 100644
--- a/drivers/usb/host/ehci-tegra.c
+++ b/drivers/usb/host/ehci-tegra.c
@@ -224,6 +224,7 @@ static int tegra_ehci_hub_control(
224 temp &= ~(PORT_RWC_BITS | PORT_WAKE_BITS); 224 temp &= ~(PORT_RWC_BITS | PORT_WAKE_BITS);
225 /* start resume signalling */ 225 /* start resume signalling */
226 ehci_writel(ehci, temp | PORT_RESUME, status_reg); 226 ehci_writel(ehci, temp | PORT_RESUME, status_reg);
227 set_bit(wIndex-1, &ehci->resuming_ports);
227 228
228 spin_unlock_irqrestore(&ehci->lock, flags); 229 spin_unlock_irqrestore(&ehci->lock, flags);
229 msleep(20); 230 msleep(20);
@@ -236,6 +237,7 @@ static int tegra_ehci_hub_control(
236 pr_err("%s: timeout waiting for SUSPEND\n", __func__); 237 pr_err("%s: timeout waiting for SUSPEND\n", __func__);
237 238
238 ehci->reset_done[wIndex-1] = 0; 239 ehci->reset_done[wIndex-1] = 0;
240 clear_bit(wIndex-1, &ehci->resuming_ports);
239 241
240 tegra->port_resuming = 1; 242 tegra->port_resuming = 1;
241 goto done; 243 goto done;
@@ -729,7 +731,6 @@ static int tegra_ehci_probe(struct platform_device *pdev)
729 err = -ENODEV; 731 err = -ENODEV;
730 goto fail; 732 goto fail;
731 } 733 }
732 set_irq_flags(irq, IRQF_VALID);
733 734
734#ifdef CONFIG_USB_OTG_UTILS 735#ifdef CONFIG_USB_OTG_UTILS
735 if (pdata->operating_mode == TEGRA_USB_OTG) { 736 if (pdata->operating_mode == TEGRA_USB_OTG) {
diff --git a/drivers/usb/host/ehci.h b/drivers/usb/host/ehci.h
index 8f9acbc96fde..2694ed6558d2 100644
--- a/drivers/usb/host/ehci.h
+++ b/drivers/usb/host/ehci.h
@@ -117,6 +117,8 @@ struct ehci_hcd { /* one per controller */
117 the change-suspend feature turned on */ 117 the change-suspend feature turned on */
118 unsigned long suspended_ports; /* which ports are 118 unsigned long suspended_ports; /* which ports are
119 suspended */ 119 suspended */
120 unsigned long resuming_ports; /* which ports have
121 started to resume */
120 122
121 /* per-HC memory pools (could be per-bus, but ...) */ 123 /* per-HC memory pools (could be per-bus, but ...) */
122 struct dma_pool *qh_pool; /* qh per active urb */ 124 struct dma_pool *qh_pool; /* qh per active urb */
diff --git a/drivers/usb/host/ohci-at91.c b/drivers/usb/host/ohci-at91.c
index 09f597ad6e00..13ebeca8e73e 100644
--- a/drivers/usb/host/ohci-at91.c
+++ b/drivers/usb/host/ohci-at91.c
@@ -94,7 +94,7 @@ static void at91_stop_hc(struct platform_device *pdev)
94 94
95/*-------------------------------------------------------------------------*/ 95/*-------------------------------------------------------------------------*/
96 96
97static void usb_hcd_at91_remove (struct usb_hcd *, struct platform_device *); 97static void __devexit usb_hcd_at91_remove (struct usb_hcd *, struct platform_device *);
98 98
99/* configure so an HC device and id are always provided */ 99/* configure so an HC device and id are always provided */
100/* always called with process context; sleeping is OK */ 100/* always called with process context; sleeping is OK */
@@ -108,7 +108,7 @@ static void usb_hcd_at91_remove (struct usb_hcd *, struct platform_device *);
108 * then invokes the start() method for the HCD associated with it 108 * then invokes the start() method for the HCD associated with it
109 * through the hotplug entry's driver_data. 109 * through the hotplug entry's driver_data.
110 */ 110 */
111static int usb_hcd_at91_probe(const struct hc_driver *driver, 111static int __devinit usb_hcd_at91_probe(const struct hc_driver *driver,
112 struct platform_device *pdev) 112 struct platform_device *pdev)
113{ 113{
114 int retval; 114 int retval;
@@ -203,7 +203,7 @@ static int usb_hcd_at91_probe(const struct hc_driver *driver,
203 * context, "rmmod" or something similar. 203 * context, "rmmod" or something similar.
204 * 204 *
205 */ 205 */
206static void usb_hcd_at91_remove(struct usb_hcd *hcd, 206static void __devexit usb_hcd_at91_remove(struct usb_hcd *hcd,
207 struct platform_device *pdev) 207 struct platform_device *pdev)
208{ 208{
209 usb_remove_hcd(hcd); 209 usb_remove_hcd(hcd);
@@ -545,7 +545,7 @@ static int __devinit ohci_at91_of_init(struct platform_device *pdev)
545 545
546/*-------------------------------------------------------------------------*/ 546/*-------------------------------------------------------------------------*/
547 547
548static int ohci_hcd_at91_drv_probe(struct platform_device *pdev) 548static int __devinit ohci_hcd_at91_drv_probe(struct platform_device *pdev)
549{ 549{
550 struct at91_usbh_data *pdata; 550 struct at91_usbh_data *pdata;
551 int i; 551 int i;
@@ -620,7 +620,7 @@ static int ohci_hcd_at91_drv_probe(struct platform_device *pdev)
620 return usb_hcd_at91_probe(&ohci_at91_hc_driver, pdev); 620 return usb_hcd_at91_probe(&ohci_at91_hc_driver, pdev);
621} 621}
622 622
623static int ohci_hcd_at91_drv_remove(struct platform_device *pdev) 623static int __devexit ohci_hcd_at91_drv_remove(struct platform_device *pdev)
624{ 624{
625 struct at91_usbh_data *pdata = pdev->dev.platform_data; 625 struct at91_usbh_data *pdata = pdev->dev.platform_data;
626 int i; 626 int i;
@@ -696,7 +696,7 @@ MODULE_ALIAS("platform:at91_ohci");
696 696
697static struct platform_driver ohci_hcd_at91_driver = { 697static struct platform_driver ohci_hcd_at91_driver = {
698 .probe = ohci_hcd_at91_drv_probe, 698 .probe = ohci_hcd_at91_drv_probe,
699 .remove = ohci_hcd_at91_drv_remove, 699 .remove = __devexit_p(ohci_hcd_at91_drv_remove),
700 .shutdown = usb_hcd_platform_shutdown, 700 .shutdown = usb_hcd_platform_shutdown,
701 .suspend = ohci_hcd_at91_drv_suspend, 701 .suspend = ohci_hcd_at91_drv_suspend,
702 .resume = ohci_hcd_at91_drv_resume, 702 .resume = ohci_hcd_at91_drv_resume,
diff --git a/drivers/usb/host/pci-quirks.c b/drivers/usb/host/pci-quirks.c
index 11de5f1be981..32dada8c8b4f 100644
--- a/drivers/usb/host/pci-quirks.c
+++ b/drivers/usb/host/pci-quirks.c
@@ -825,9 +825,13 @@ static void __devinit quirk_usb_handoff_xhci(struct pci_dev *pdev)
825 } 825 }
826 } 826 }
827 827
828 /* Disable any BIOS SMIs */ 828 val = readl(base + ext_cap_offset + XHCI_LEGACY_CONTROL_OFFSET);
829 writel(XHCI_LEGACY_DISABLE_SMI, 829 /* Mask off (turn off) any enabled SMIs */
830 base + ext_cap_offset + XHCI_LEGACY_CONTROL_OFFSET); 830 val &= XHCI_LEGACY_DISABLE_SMI;
831 /* Mask all SMI events bits, RW1C */
832 val |= XHCI_LEGACY_SMI_EVENTS;
833 /* Disable any BIOS SMIs and clear all SMI events*/
834 writel(val, base + ext_cap_offset + XHCI_LEGACY_CONTROL_OFFSET);
831 835
832 if (usb_is_intel_switchable_xhci(pdev)) 836 if (usb_is_intel_switchable_xhci(pdev))
833 usb_enable_xhci_ports(pdev); 837 usb_enable_xhci_ports(pdev);
diff --git a/drivers/usb/host/uhci-hub.c b/drivers/usb/host/uhci-hub.c
index 045cde4cbc3d..768d54295a20 100644
--- a/drivers/usb/host/uhci-hub.c
+++ b/drivers/usb/host/uhci-hub.c
@@ -196,11 +196,12 @@ static int uhci_hub_status_data(struct usb_hcd *hcd, char *buf)
196 status = get_hub_status_data(uhci, buf); 196 status = get_hub_status_data(uhci, buf);
197 197
198 switch (uhci->rh_state) { 198 switch (uhci->rh_state) {
199 case UHCI_RH_SUSPENDING:
200 case UHCI_RH_SUSPENDED: 199 case UHCI_RH_SUSPENDED:
201 /* if port change, ask to be resumed */ 200 /* if port change, ask to be resumed */
202 if (status || uhci->resuming_ports) 201 if (status || uhci->resuming_ports) {
202 status = 1;
203 usb_hcd_resume_root_hub(hcd); 203 usb_hcd_resume_root_hub(hcd);
204 }
204 break; 205 break;
205 206
206 case UHCI_RH_AUTO_STOPPED: 207 case UHCI_RH_AUTO_STOPPED:
diff --git a/drivers/usb/host/xhci-dbg.c b/drivers/usb/host/xhci-dbg.c
index e9b0f043455d..4b436f5a4171 100644
--- a/drivers/usb/host/xhci-dbg.c
+++ b/drivers/usb/host/xhci-dbg.c
@@ -119,7 +119,7 @@ static void xhci_print_command_reg(struct xhci_hcd *xhci)
119 xhci_dbg(xhci, " Event Interrupts %s\n", 119 xhci_dbg(xhci, " Event Interrupts %s\n",
120 (temp & CMD_EIE) ? "enabled " : "disabled"); 120 (temp & CMD_EIE) ? "enabled " : "disabled");
121 xhci_dbg(xhci, " Host System Error Interrupts %s\n", 121 xhci_dbg(xhci, " Host System Error Interrupts %s\n",
122 (temp & CMD_EIE) ? "enabled " : "disabled"); 122 (temp & CMD_HSEIE) ? "enabled " : "disabled");
123 xhci_dbg(xhci, " HC has %sfinished light reset\n", 123 xhci_dbg(xhci, " HC has %sfinished light reset\n",
124 (temp & CMD_LRESET) ? "not " : ""); 124 (temp & CMD_LRESET) ? "not " : "");
125} 125}
diff --git a/drivers/usb/host/xhci-ext-caps.h b/drivers/usb/host/xhci-ext-caps.h
index c7f33123d4c0..377f4242dabb 100644
--- a/drivers/usb/host/xhci-ext-caps.h
+++ b/drivers/usb/host/xhci-ext-caps.h
@@ -62,8 +62,9 @@
62/* USB Legacy Support Control and Status Register - section 7.1.2 */ 62/* USB Legacy Support Control and Status Register - section 7.1.2 */
63/* Add this offset, plus the value of xECP in HCCPARAMS to the base address */ 63/* Add this offset, plus the value of xECP in HCCPARAMS to the base address */
64#define XHCI_LEGACY_CONTROL_OFFSET (0x04) 64#define XHCI_LEGACY_CONTROL_OFFSET (0x04)
65/* bits 1:2, 5:12, and 17:19 need to be preserved; bits 21:28 should be zero */ 65/* bits 1:3, 5:12, and 17:19 need to be preserved; bits 21:28 should be zero */
66#define XHCI_LEGACY_DISABLE_SMI ((0x3 << 1) + (0xff << 5) + (0x7 << 17)) 66#define XHCI_LEGACY_DISABLE_SMI ((0x7 << 1) + (0xff << 5) + (0x7 << 17))
67#define XHCI_LEGACY_SMI_EVENTS (0x7 << 29)
67 68
68/* USB 2.0 xHCI 0.96 L1C capability - section 7.2.2.1.3.2 */ 69/* USB 2.0 xHCI 0.96 L1C capability - section 7.2.2.1.3.2 */
69#define XHCI_L1C (1 << 16) 70#define XHCI_L1C (1 << 16)
diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c
index cae4c6f2845a..68eaa908ac8e 100644
--- a/drivers/usb/host/xhci-mem.c
+++ b/drivers/usb/host/xhci-mem.c
@@ -1796,11 +1796,6 @@ void xhci_mem_cleanup(struct xhci_hcd *xhci)
1796 int i; 1796 int i;
1797 1797
1798 /* Free the Event Ring Segment Table and the actual Event Ring */ 1798 /* Free the Event Ring Segment Table and the actual Event Ring */
1799 if (xhci->ir_set) {
1800 xhci_writel(xhci, 0, &xhci->ir_set->erst_size);
1801 xhci_write_64(xhci, 0, &xhci->ir_set->erst_base);
1802 xhci_write_64(xhci, 0, &xhci->ir_set->erst_dequeue);
1803 }
1804 size = sizeof(struct xhci_erst_entry)*(xhci->erst.num_entries); 1799 size = sizeof(struct xhci_erst_entry)*(xhci->erst.num_entries);
1805 if (xhci->erst.entries) 1800 if (xhci->erst.entries)
1806 dma_free_coherent(&pdev->dev, size, 1801 dma_free_coherent(&pdev->dev, size,
@@ -1812,7 +1807,6 @@ void xhci_mem_cleanup(struct xhci_hcd *xhci)
1812 xhci->event_ring = NULL; 1807 xhci->event_ring = NULL;
1813 xhci_dbg(xhci, "Freed event ring\n"); 1808 xhci_dbg(xhci, "Freed event ring\n");
1814 1809
1815 xhci_write_64(xhci, 0, &xhci->op_regs->cmd_ring);
1816 if (xhci->cmd_ring) 1810 if (xhci->cmd_ring)
1817 xhci_ring_free(xhci, xhci->cmd_ring); 1811 xhci_ring_free(xhci, xhci->cmd_ring);
1818 xhci->cmd_ring = NULL; 1812 xhci->cmd_ring = NULL;
@@ -1841,7 +1835,6 @@ void xhci_mem_cleanup(struct xhci_hcd *xhci)
1841 xhci->medium_streams_pool = NULL; 1835 xhci->medium_streams_pool = NULL;
1842 xhci_dbg(xhci, "Freed medium stream array pool\n"); 1836 xhci_dbg(xhci, "Freed medium stream array pool\n");
1843 1837
1844 xhci_write_64(xhci, 0, &xhci->op_regs->dcbaa_ptr);
1845 if (xhci->dcbaa) 1838 if (xhci->dcbaa)
1846 dma_free_coherent(&pdev->dev, sizeof(*xhci->dcbaa), 1839 dma_free_coherent(&pdev->dev, sizeof(*xhci->dcbaa),
1847 xhci->dcbaa, xhci->dcbaa->dma); 1840 xhci->dcbaa, xhci->dcbaa->dma);
@@ -2459,6 +2452,8 @@ int xhci_mem_init(struct xhci_hcd *xhci, gfp_t flags)
2459 2452
2460fail: 2453fail:
2461 xhci_warn(xhci, "Couldn't initialize memory\n"); 2454 xhci_warn(xhci, "Couldn't initialize memory\n");
2455 xhci_halt(xhci);
2456 xhci_reset(xhci);
2462 xhci_mem_cleanup(xhci); 2457 xhci_mem_cleanup(xhci);
2463 return -ENOMEM; 2458 return -ENOMEM;
2464} 2459}
diff --git a/drivers/usb/host/xhci-pci.c b/drivers/usb/host/xhci-pci.c
index ef98b38626fb..7a856a767e77 100644
--- a/drivers/usb/host/xhci-pci.c
+++ b/drivers/usb/host/xhci-pci.c
@@ -95,6 +95,8 @@ static void xhci_pci_quirks(struct device *dev, struct xhci_hcd *xhci)
95 xhci->quirks |= XHCI_RESET_ON_RESUME; 95 xhci->quirks |= XHCI_RESET_ON_RESUME;
96 xhci_dbg(xhci, "QUIRK: Resetting on resume\n"); 96 xhci_dbg(xhci, "QUIRK: Resetting on resume\n");
97 } 97 }
98 if (pdev->vendor == PCI_VENDOR_ID_VIA)
99 xhci->quirks |= XHCI_RESET_ON_RESUME;
98} 100}
99 101
100/* called during probe() after chip reset completes */ 102/* called during probe() after chip reset completes */
@@ -326,7 +328,7 @@ int __init xhci_register_pci(void)
326 return pci_register_driver(&xhci_pci_driver); 328 return pci_register_driver(&xhci_pci_driver);
327} 329}
328 330
329void __exit xhci_unregister_pci(void) 331void xhci_unregister_pci(void)
330{ 332{
331 pci_unregister_driver(&xhci_pci_driver); 333 pci_unregister_driver(&xhci_pci_driver);
332} 334}
diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c
index 6bd9d53062eb..3d9422f16a20 100644
--- a/drivers/usb/host/xhci-ring.c
+++ b/drivers/usb/host/xhci-ring.c
@@ -2417,7 +2417,7 @@ hw_died:
2417 u32 irq_pending; 2417 u32 irq_pending;
2418 /* Acknowledge the PCI interrupt */ 2418 /* Acknowledge the PCI interrupt */
2419 irq_pending = xhci_readl(xhci, &xhci->ir_set->irq_pending); 2419 irq_pending = xhci_readl(xhci, &xhci->ir_set->irq_pending);
2420 irq_pending |= 0x3; 2420 irq_pending |= IMAN_IP;
2421 xhci_writel(xhci, irq_pending, &xhci->ir_set->irq_pending); 2421 xhci_writel(xhci, irq_pending, &xhci->ir_set->irq_pending);
2422 } 2422 }
2423 2423
@@ -2734,7 +2734,7 @@ int xhci_queue_intr_tx(struct xhci_hcd *xhci, gfp_t mem_flags,
2734 urb->dev->speed == USB_SPEED_FULL) 2734 urb->dev->speed == USB_SPEED_FULL)
2735 urb->interval /= 8; 2735 urb->interval /= 8;
2736 } 2736 }
2737 return xhci_queue_bulk_tx(xhci, GFP_ATOMIC, urb, slot_id, ep_index); 2737 return xhci_queue_bulk_tx(xhci, mem_flags, urb, slot_id, ep_index);
2738} 2738}
2739 2739
2740/* 2740/*
@@ -3514,7 +3514,7 @@ int xhci_queue_isoc_tx_prepare(struct xhci_hcd *xhci, gfp_t mem_flags,
3514 } 3514 }
3515 ep_ring->num_trbs_free_temp = ep_ring->num_trbs_free; 3515 ep_ring->num_trbs_free_temp = ep_ring->num_trbs_free;
3516 3516
3517 return xhci_queue_isoc_tx(xhci, GFP_ATOMIC, urb, slot_id, ep_index); 3517 return xhci_queue_isoc_tx(xhci, mem_flags, urb, slot_id, ep_index);
3518} 3518}
3519 3519
3520/**** Command Ring Operations ****/ 3520/**** Command Ring Operations ****/
diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index e1963d4a430f..36641a7f2371 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -106,6 +106,9 @@ int xhci_halt(struct xhci_hcd *xhci)
106 STS_HALT, STS_HALT, XHCI_MAX_HALT_USEC); 106 STS_HALT, STS_HALT, XHCI_MAX_HALT_USEC);
107 if (!ret) 107 if (!ret)
108 xhci->xhc_state |= XHCI_STATE_HALTED; 108 xhci->xhc_state |= XHCI_STATE_HALTED;
109 else
110 xhci_warn(xhci, "Host not halted after %u microseconds.\n",
111 XHCI_MAX_HALT_USEC);
109 return ret; 112 return ret;
110} 113}
111 114
@@ -664,11 +667,11 @@ static void xhci_save_registers(struct xhci_hcd *xhci)
664 xhci->s3.dev_nt = xhci_readl(xhci, &xhci->op_regs->dev_notification); 667 xhci->s3.dev_nt = xhci_readl(xhci, &xhci->op_regs->dev_notification);
665 xhci->s3.dcbaa_ptr = xhci_read_64(xhci, &xhci->op_regs->dcbaa_ptr); 668 xhci->s3.dcbaa_ptr = xhci_read_64(xhci, &xhci->op_regs->dcbaa_ptr);
666 xhci->s3.config_reg = xhci_readl(xhci, &xhci->op_regs->config_reg); 669 xhci->s3.config_reg = xhci_readl(xhci, &xhci->op_regs->config_reg);
667 xhci->s3.irq_pending = xhci_readl(xhci, &xhci->ir_set->irq_pending);
668 xhci->s3.irq_control = xhci_readl(xhci, &xhci->ir_set->irq_control);
669 xhci->s3.erst_size = xhci_readl(xhci, &xhci->ir_set->erst_size); 670 xhci->s3.erst_size = xhci_readl(xhci, &xhci->ir_set->erst_size);
670 xhci->s3.erst_base = xhci_read_64(xhci, &xhci->ir_set->erst_base); 671 xhci->s3.erst_base = xhci_read_64(xhci, &xhci->ir_set->erst_base);
671 xhci->s3.erst_dequeue = xhci_read_64(xhci, &xhci->ir_set->erst_dequeue); 672 xhci->s3.erst_dequeue = xhci_read_64(xhci, &xhci->ir_set->erst_dequeue);
673 xhci->s3.irq_pending = xhci_readl(xhci, &xhci->ir_set->irq_pending);
674 xhci->s3.irq_control = xhci_readl(xhci, &xhci->ir_set->irq_control);
672} 675}
673 676
674static void xhci_restore_registers(struct xhci_hcd *xhci) 677static void xhci_restore_registers(struct xhci_hcd *xhci)
@@ -677,10 +680,11 @@ static void xhci_restore_registers(struct xhci_hcd *xhci)
677 xhci_writel(xhci, xhci->s3.dev_nt, &xhci->op_regs->dev_notification); 680 xhci_writel(xhci, xhci->s3.dev_nt, &xhci->op_regs->dev_notification);
678 xhci_write_64(xhci, xhci->s3.dcbaa_ptr, &xhci->op_regs->dcbaa_ptr); 681 xhci_write_64(xhci, xhci->s3.dcbaa_ptr, &xhci->op_regs->dcbaa_ptr);
679 xhci_writel(xhci, xhci->s3.config_reg, &xhci->op_regs->config_reg); 682 xhci_writel(xhci, xhci->s3.config_reg, &xhci->op_regs->config_reg);
680 xhci_writel(xhci, xhci->s3.irq_pending, &xhci->ir_set->irq_pending);
681 xhci_writel(xhci, xhci->s3.irq_control, &xhci->ir_set->irq_control);
682 xhci_writel(xhci, xhci->s3.erst_size, &xhci->ir_set->erst_size); 683 xhci_writel(xhci, xhci->s3.erst_size, &xhci->ir_set->erst_size);
683 xhci_write_64(xhci, xhci->s3.erst_base, &xhci->ir_set->erst_base); 684 xhci_write_64(xhci, xhci->s3.erst_base, &xhci->ir_set->erst_base);
685 xhci_write_64(xhci, xhci->s3.erst_dequeue, &xhci->ir_set->erst_dequeue);
686 xhci_writel(xhci, xhci->s3.irq_pending, &xhci->ir_set->irq_pending);
687 xhci_writel(xhci, xhci->s3.irq_control, &xhci->ir_set->irq_control);
684} 688}
685 689
686static void xhci_set_cmd_ring_deq(struct xhci_hcd *xhci) 690static void xhci_set_cmd_ring_deq(struct xhci_hcd *xhci)
diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h
index 91074fdab3eb..3d69c4b2b542 100644
--- a/drivers/usb/host/xhci.h
+++ b/drivers/usb/host/xhci.h
@@ -205,6 +205,10 @@ struct xhci_op_regs {
205#define CMD_PM_INDEX (1 << 11) 205#define CMD_PM_INDEX (1 << 11)
206/* bits 12:31 are reserved (and should be preserved on writes). */ 206/* bits 12:31 are reserved (and should be preserved on writes). */
207 207
208/* IMAN - Interrupt Management Register */
209#define IMAN_IP (1 << 1)
210#define IMAN_IE (1 << 0)
211
208/* USBSTS - USB status - status bitmasks */ 212/* USBSTS - USB status - status bitmasks */
209/* HC not running - set to 1 when run/stop bit is cleared. */ 213/* HC not running - set to 1 when run/stop bit is cleared. */
210#define STS_HALT XHCI_STS_HALT 214#define STS_HALT XHCI_STS_HALT
diff --git a/drivers/usb/misc/usbtest.c b/drivers/usb/misc/usbtest.c
index 959145baf3cf..9dcb68f04f03 100644
--- a/drivers/usb/misc/usbtest.c
+++ b/drivers/usb/misc/usbtest.c
@@ -423,7 +423,7 @@ alloc_sglist(int nents, int max, int vary)
423 unsigned i; 423 unsigned i;
424 unsigned size = max; 424 unsigned size = max;
425 425
426 sg = kmalloc(nents * sizeof *sg, GFP_KERNEL); 426 sg = kmalloc_array(nents, sizeof *sg, GFP_KERNEL);
427 if (!sg) 427 if (!sg)
428 return NULL; 428 return NULL;
429 sg_init_table(sg, nents); 429 sg_init_table(sg, nents);
@@ -904,6 +904,9 @@ test_ctrl_queue(struct usbtest_dev *dev, struct usbtest_param *param)
904 struct ctrl_ctx context; 904 struct ctrl_ctx context;
905 int i; 905 int i;
906 906
907 if (param->sglen == 0 || param->iterations > UINT_MAX / param->sglen)
908 return -EOPNOTSUPP;
909
907 spin_lock_init(&context.lock); 910 spin_lock_init(&context.lock);
908 context.dev = dev; 911 context.dev = dev;
909 init_completion(&context.complete); 912 init_completion(&context.complete);
@@ -1981,8 +1984,6 @@ usbtest_ioctl(struct usb_interface *intf, unsigned int code, void *buf)
1981 1984
1982 /* queued control messaging */ 1985 /* queued control messaging */
1983 case 10: 1986 case 10:
1984 if (param->sglen == 0)
1985 break;
1986 retval = 0; 1987 retval = 0;
1987 dev_info(&intf->dev, 1988 dev_info(&intf->dev,
1988 "TEST 10: queue %d control calls, %d times\n", 1989 "TEST 10: queue %d control calls, %d times\n",
@@ -2276,6 +2277,8 @@ usbtest_probe(struct usb_interface *intf, const struct usb_device_id *id)
2276 if (status < 0) { 2277 if (status < 0) {
2277 WARNING(dev, "couldn't get endpoints, %d\n", 2278 WARNING(dev, "couldn't get endpoints, %d\n",
2278 status); 2279 status);
2280 kfree(dev->buf);
2281 kfree(dev);
2279 return status; 2282 return status;
2280 } 2283 }
2281 /* may find bulk or ISO pipes */ 2284 /* may find bulk or ISO pipes */
diff --git a/drivers/usb/misc/yurex.c b/drivers/usb/misc/yurex.c
index 897edda42270..70201462e19c 100644
--- a/drivers/usb/misc/yurex.c
+++ b/drivers/usb/misc/yurex.c
@@ -99,9 +99,7 @@ static void yurex_delete(struct kref *kref)
99 usb_put_dev(dev->udev); 99 usb_put_dev(dev->udev);
100 if (dev->cntl_urb) { 100 if (dev->cntl_urb) {
101 usb_kill_urb(dev->cntl_urb); 101 usb_kill_urb(dev->cntl_urb);
102 if (dev->cntl_req) 102 kfree(dev->cntl_req);
103 usb_free_coherent(dev->udev, YUREX_BUF_SIZE,
104 dev->cntl_req, dev->cntl_urb->setup_dma);
105 if (dev->cntl_buffer) 103 if (dev->cntl_buffer)
106 usb_free_coherent(dev->udev, YUREX_BUF_SIZE, 104 usb_free_coherent(dev->udev, YUREX_BUF_SIZE,
107 dev->cntl_buffer, dev->cntl_urb->transfer_dma); 105 dev->cntl_buffer, dev->cntl_urb->transfer_dma);
@@ -234,9 +232,7 @@ static int yurex_probe(struct usb_interface *interface, const struct usb_device_
234 } 232 }
235 233
236 /* allocate buffer for control req */ 234 /* allocate buffer for control req */
237 dev->cntl_req = usb_alloc_coherent(dev->udev, YUREX_BUF_SIZE, 235 dev->cntl_req = kmalloc(YUREX_BUF_SIZE, GFP_KERNEL);
238 GFP_KERNEL,
239 &dev->cntl_urb->setup_dma);
240 if (!dev->cntl_req) { 236 if (!dev->cntl_req) {
241 err("Could not allocate cntl_req"); 237 err("Could not allocate cntl_req");
242 goto error; 238 goto error;
@@ -286,7 +282,7 @@ static int yurex_probe(struct usb_interface *interface, const struct usb_device_
286 usb_rcvintpipe(dev->udev, dev->int_in_endpointAddr), 282 usb_rcvintpipe(dev->udev, dev->int_in_endpointAddr),
287 dev->int_buffer, YUREX_BUF_SIZE, yurex_interrupt, 283 dev->int_buffer, YUREX_BUF_SIZE, yurex_interrupt,
288 dev, 1); 284 dev, 1);
289 dev->cntl_urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; 285 dev->urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
290 if (usb_submit_urb(dev->urb, GFP_KERNEL)) { 286 if (usb_submit_urb(dev->urb, GFP_KERNEL)) {
291 retval = -EIO; 287 retval = -EIO;
292 err("Could not submitting URB"); 288 err("Could not submitting URB");
diff --git a/drivers/usb/musb/davinci.c b/drivers/usb/musb/davinci.c
index 97ab975fa442..768b4b55c816 100644
--- a/drivers/usb/musb/davinci.c
+++ b/drivers/usb/musb/davinci.c
@@ -386,7 +386,7 @@ static int davinci_musb_init(struct musb *musb)
386 usb_nop_xceiv_register(); 386 usb_nop_xceiv_register();
387 musb->xceiv = usb_get_transceiver(); 387 musb->xceiv = usb_get_transceiver();
388 if (!musb->xceiv) 388 if (!musb->xceiv)
389 return -ENODEV; 389 goto unregister;
390 390
391 musb->mregs += DAVINCI_BASE_OFFSET; 391 musb->mregs += DAVINCI_BASE_OFFSET;
392 392
@@ -444,6 +444,7 @@ static int davinci_musb_init(struct musb *musb)
444 444
445fail: 445fail:
446 usb_put_transceiver(musb->xceiv); 446 usb_put_transceiver(musb->xceiv);
447unregister:
447 usb_nop_xceiv_unregister(); 448 usb_nop_xceiv_unregister();
448 return -ENODEV; 449 return -ENODEV;
449} 450}
diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c
index 0f8b82918a40..66aaccf04490 100644
--- a/drivers/usb/musb/musb_core.c
+++ b/drivers/usb/musb/musb_core.c
@@ -137,6 +137,9 @@ static int musb_ulpi_read(struct usb_phy *phy, u32 offset)
137 int i = 0; 137 int i = 0;
138 u8 r; 138 u8 r;
139 u8 power; 139 u8 power;
140 int ret;
141
142 pm_runtime_get_sync(phy->io_dev);
140 143
141 /* Make sure the transceiver is not in low power mode */ 144 /* Make sure the transceiver is not in low power mode */
142 power = musb_readb(addr, MUSB_POWER); 145 power = musb_readb(addr, MUSB_POWER);
@@ -154,15 +157,22 @@ static int musb_ulpi_read(struct usb_phy *phy, u32 offset)
154 while (!(musb_readb(addr, MUSB_ULPI_REG_CONTROL) 157 while (!(musb_readb(addr, MUSB_ULPI_REG_CONTROL)
155 & MUSB_ULPI_REG_CMPLT)) { 158 & MUSB_ULPI_REG_CMPLT)) {
156 i++; 159 i++;
157 if (i == 10000) 160 if (i == 10000) {
158 return -ETIMEDOUT; 161 ret = -ETIMEDOUT;
162 goto out;
163 }
159 164
160 } 165 }
161 r = musb_readb(addr, MUSB_ULPI_REG_CONTROL); 166 r = musb_readb(addr, MUSB_ULPI_REG_CONTROL);
162 r &= ~MUSB_ULPI_REG_CMPLT; 167 r &= ~MUSB_ULPI_REG_CMPLT;
163 musb_writeb(addr, MUSB_ULPI_REG_CONTROL, r); 168 musb_writeb(addr, MUSB_ULPI_REG_CONTROL, r);
164 169
165 return musb_readb(addr, MUSB_ULPI_REG_DATA); 170 ret = musb_readb(addr, MUSB_ULPI_REG_DATA);
171
172out:
173 pm_runtime_put(phy->io_dev);
174
175 return ret;
166} 176}
167 177
168static int musb_ulpi_write(struct usb_phy *phy, u32 offset, u32 data) 178static int musb_ulpi_write(struct usb_phy *phy, u32 offset, u32 data)
@@ -171,6 +181,9 @@ static int musb_ulpi_write(struct usb_phy *phy, u32 offset, u32 data)
171 int i = 0; 181 int i = 0;
172 u8 r = 0; 182 u8 r = 0;
173 u8 power; 183 u8 power;
184 int ret = 0;
185
186 pm_runtime_get_sync(phy->io_dev);
174 187
175 /* Make sure the transceiver is not in low power mode */ 188 /* Make sure the transceiver is not in low power mode */
176 power = musb_readb(addr, MUSB_POWER); 189 power = musb_readb(addr, MUSB_POWER);
@@ -184,15 +197,20 @@ static int musb_ulpi_write(struct usb_phy *phy, u32 offset, u32 data)
184 while (!(musb_readb(addr, MUSB_ULPI_REG_CONTROL) 197 while (!(musb_readb(addr, MUSB_ULPI_REG_CONTROL)
185 & MUSB_ULPI_REG_CMPLT)) { 198 & MUSB_ULPI_REG_CMPLT)) {
186 i++; 199 i++;
187 if (i == 10000) 200 if (i == 10000) {
188 return -ETIMEDOUT; 201 ret = -ETIMEDOUT;
202 goto out;
203 }
189 } 204 }
190 205
191 r = musb_readb(addr, MUSB_ULPI_REG_CONTROL); 206 r = musb_readb(addr, MUSB_ULPI_REG_CONTROL);
192 r &= ~MUSB_ULPI_REG_CMPLT; 207 r &= ~MUSB_ULPI_REG_CMPLT;
193 musb_writeb(addr, MUSB_ULPI_REG_CONTROL, r); 208 musb_writeb(addr, MUSB_ULPI_REG_CONTROL, r);
194 209
195 return 0; 210out:
211 pm_runtime_put(phy->io_dev);
212
213 return ret;
196} 214}
197#else 215#else
198#define musb_ulpi_read NULL 216#define musb_ulpi_read NULL
@@ -1904,14 +1922,17 @@ musb_init_controller(struct device *dev, int nIrq, void __iomem *ctrl)
1904 1922
1905 if (!musb->isr) { 1923 if (!musb->isr) {
1906 status = -ENODEV; 1924 status = -ENODEV;
1907 goto fail3; 1925 goto fail2;
1908 } 1926 }
1909 1927
1910 if (!musb->xceiv->io_ops) { 1928 if (!musb->xceiv->io_ops) {
1929 musb->xceiv->io_dev = musb->controller;
1911 musb->xceiv->io_priv = musb->mregs; 1930 musb->xceiv->io_priv = musb->mregs;
1912 musb->xceiv->io_ops = &musb_ulpi_access; 1931 musb->xceiv->io_ops = &musb_ulpi_access;
1913 } 1932 }
1914 1933
1934 pm_runtime_get_sync(musb->controller);
1935
1915#ifndef CONFIG_MUSB_PIO_ONLY 1936#ifndef CONFIG_MUSB_PIO_ONLY
1916 if (use_dma && dev->dma_mask) { 1937 if (use_dma && dev->dma_mask) {
1917 struct dma_controller *c; 1938 struct dma_controller *c;
@@ -2023,6 +2044,8 @@ musb_init_controller(struct device *dev, int nIrq, void __iomem *ctrl)
2023 goto fail5; 2044 goto fail5;
2024#endif 2045#endif
2025 2046
2047 pm_runtime_put(musb->controller);
2048
2026 dev_info(dev, "USB %s mode controller at %p using %s, IRQ %d\n", 2049 dev_info(dev, "USB %s mode controller at %p using %s, IRQ %d\n",
2027 ({char *s; 2050 ({char *s;
2028 switch (musb->board_mode) { 2051 switch (musb->board_mode) {
@@ -2047,6 +2070,9 @@ fail4:
2047 musb_gadget_cleanup(musb); 2070 musb_gadget_cleanup(musb);
2048 2071
2049fail3: 2072fail3:
2073 pm_runtime_put_sync(musb->controller);
2074
2075fail2:
2050 if (musb->irq_wake) 2076 if (musb->irq_wake)
2051 device_init_wakeup(dev, 0); 2077 device_init_wakeup(dev, 0);
2052 musb_platform_exit(musb); 2078 musb_platform_exit(musb);
diff --git a/drivers/usb/musb/musb_core.h b/drivers/usb/musb/musb_core.h
index 93de517a32a0..f4a40f001c88 100644
--- a/drivers/usb/musb/musb_core.h
+++ b/drivers/usb/musb/musb_core.h
@@ -449,7 +449,7 @@ struct musb {
449 * We added this flag to forcefully disable double 449 * We added this flag to forcefully disable double
450 * buffering until we get it working. 450 * buffering until we get it working.
451 */ 451 */
452 unsigned double_buffer_not_ok:1 __deprecated; 452 unsigned double_buffer_not_ok:1;
453 453
454 struct musb_hdrc_config *config; 454 struct musb_hdrc_config *config;
455 455
diff --git a/drivers/usb/musb/musb_host.c b/drivers/usb/musb/musb_host.c
index 79cb0af779fa..ef8d744800ac 100644
--- a/drivers/usb/musb/musb_host.c
+++ b/drivers/usb/musb/musb_host.c
@@ -2098,7 +2098,7 @@ static int musb_cleanup_urb(struct urb *urb, struct musb_qh *qh)
2098 } 2098 }
2099 2099
2100 /* turn off DMA requests, discard state, stop polling ... */ 2100 /* turn off DMA requests, discard state, stop polling ... */
2101 if (is_in) { 2101 if (ep->epnum && is_in) {
2102 /* giveback saves bulk toggle */ 2102 /* giveback saves bulk toggle */
2103 csr = musb_h_flush_rxfifo(ep, 0); 2103 csr = musb_h_flush_rxfifo(ep, 0);
2104 2104
diff --git a/drivers/usb/musb/omap2430.c b/drivers/usb/musb/omap2430.c
index 2ae0bb309994..c7785e81254c 100644
--- a/drivers/usb/musb/omap2430.c
+++ b/drivers/usb/musb/omap2430.c
@@ -282,7 +282,8 @@ static void musb_otg_notifier_work(struct work_struct *data_notifier_work)
282 282
283static int omap2430_musb_init(struct musb *musb) 283static int omap2430_musb_init(struct musb *musb)
284{ 284{
285 u32 l, status = 0; 285 u32 l;
286 int status = 0;
286 struct device *dev = musb->controller; 287 struct device *dev = musb->controller;
287 struct musb_hdrc_platform_data *plat = dev->platform_data; 288 struct musb_hdrc_platform_data *plat = dev->platform_data;
288 struct omap_musb_board_data *data = plat->board_data; 289 struct omap_musb_board_data *data = plat->board_data;
@@ -301,7 +302,7 @@ static int omap2430_musb_init(struct musb *musb)
301 302
302 status = pm_runtime_get_sync(dev); 303 status = pm_runtime_get_sync(dev);
303 if (status < 0) { 304 if (status < 0) {
304 dev_err(dev, "pm_runtime_get_sync FAILED"); 305 dev_err(dev, "pm_runtime_get_sync FAILED %d\n", status);
305 goto err1; 306 goto err1;
306 } 307 }
307 308
@@ -333,6 +334,7 @@ static int omap2430_musb_init(struct musb *musb)
333 334
334 setup_timer(&musb_idle_timer, musb_do_idle, (unsigned long) musb); 335 setup_timer(&musb_idle_timer, musb_do_idle, (unsigned long) musb);
335 336
337 pm_runtime_put_noidle(musb->controller);
336 return 0; 338 return 0;
337 339
338err1: 340err1:
@@ -452,14 +454,14 @@ static int __devinit omap2430_probe(struct platform_device *pdev)
452 goto err2; 454 goto err2;
453 } 455 }
454 456
457 pm_runtime_enable(&pdev->dev);
458
455 ret = platform_device_add(musb); 459 ret = platform_device_add(musb);
456 if (ret) { 460 if (ret) {
457 dev_err(&pdev->dev, "failed to register musb device\n"); 461 dev_err(&pdev->dev, "failed to register musb device\n");
458 goto err2; 462 goto err2;
459 } 463 }
460 464
461 pm_runtime_enable(&pdev->dev);
462
463 return 0; 465 return 0;
464 466
465err2: 467err2:
@@ -478,7 +480,6 @@ static int __devexit omap2430_remove(struct platform_device *pdev)
478 480
479 platform_device_del(glue->musb); 481 platform_device_del(glue->musb);
480 platform_device_put(glue->musb); 482 platform_device_put(glue->musb);
481 pm_runtime_put(&pdev->dev);
482 kfree(glue); 483 kfree(glue);
483 484
484 return 0; 485 return 0;
@@ -491,11 +492,13 @@ static int omap2430_runtime_suspend(struct device *dev)
491 struct omap2430_glue *glue = dev_get_drvdata(dev); 492 struct omap2430_glue *glue = dev_get_drvdata(dev);
492 struct musb *musb = glue_to_musb(glue); 493 struct musb *musb = glue_to_musb(glue);
493 494
494 musb->context.otg_interfsel = musb_readl(musb->mregs, 495 if (musb) {
495 OTG_INTERFSEL); 496 musb->context.otg_interfsel = musb_readl(musb->mregs,
497 OTG_INTERFSEL);
496 498
497 omap2430_low_level_exit(musb); 499 omap2430_low_level_exit(musb);
498 usb_phy_set_suspend(musb->xceiv, 1); 500 usb_phy_set_suspend(musb->xceiv, 1);
501 }
499 502
500 return 0; 503 return 0;
501} 504}
@@ -505,11 +508,13 @@ static int omap2430_runtime_resume(struct device *dev)
505 struct omap2430_glue *glue = dev_get_drvdata(dev); 508 struct omap2430_glue *glue = dev_get_drvdata(dev);
506 struct musb *musb = glue_to_musb(glue); 509 struct musb *musb = glue_to_musb(glue);
507 510
508 omap2430_low_level_init(musb); 511 if (musb) {
509 musb_writel(musb->mregs, OTG_INTERFSEL, 512 omap2430_low_level_init(musb);
510 musb->context.otg_interfsel); 513 musb_writel(musb->mregs, OTG_INTERFSEL,
514 musb->context.otg_interfsel);
511 515
512 usb_phy_set_suspend(musb->xceiv, 0); 516 usb_phy_set_suspend(musb->xceiv, 0);
517 }
513 518
514 return 0; 519 return 0;
515} 520}
diff --git a/drivers/usb/otg/gpio_vbus.c b/drivers/usb/otg/gpio_vbus.c
index 3ece43a2e4c1..a0a2178974fe 100644
--- a/drivers/usb/otg/gpio_vbus.c
+++ b/drivers/usb/otg/gpio_vbus.c
@@ -96,7 +96,7 @@ static void gpio_vbus_work(struct work_struct *work)
96 struct gpio_vbus_data *gpio_vbus = 96 struct gpio_vbus_data *gpio_vbus =
97 container_of(work, struct gpio_vbus_data, work); 97 container_of(work, struct gpio_vbus_data, work);
98 struct gpio_vbus_mach_info *pdata = gpio_vbus->dev->platform_data; 98 struct gpio_vbus_mach_info *pdata = gpio_vbus->dev->platform_data;
99 int gpio; 99 int gpio, status;
100 100
101 if (!gpio_vbus->phy.otg->gadget) 101 if (!gpio_vbus->phy.otg->gadget)
102 return; 102 return;
@@ -108,7 +108,9 @@ static void gpio_vbus_work(struct work_struct *work)
108 */ 108 */
109 gpio = pdata->gpio_pullup; 109 gpio = pdata->gpio_pullup;
110 if (is_vbus_powered(pdata)) { 110 if (is_vbus_powered(pdata)) {
111 status = USB_EVENT_VBUS;
111 gpio_vbus->phy.state = OTG_STATE_B_PERIPHERAL; 112 gpio_vbus->phy.state = OTG_STATE_B_PERIPHERAL;
113 gpio_vbus->phy.last_event = status;
112 usb_gadget_vbus_connect(gpio_vbus->phy.otg->gadget); 114 usb_gadget_vbus_connect(gpio_vbus->phy.otg->gadget);
113 115
114 /* drawing a "unit load" is *always* OK, except for OTG */ 116 /* drawing a "unit load" is *always* OK, except for OTG */
@@ -117,6 +119,9 @@ static void gpio_vbus_work(struct work_struct *work)
117 /* optionally enable D+ pullup */ 119 /* optionally enable D+ pullup */
118 if (gpio_is_valid(gpio)) 120 if (gpio_is_valid(gpio))
119 gpio_set_value(gpio, !pdata->gpio_pullup_inverted); 121 gpio_set_value(gpio, !pdata->gpio_pullup_inverted);
122
123 atomic_notifier_call_chain(&gpio_vbus->phy.notifier,
124 status, gpio_vbus->phy.otg->gadget);
120 } else { 125 } else {
121 /* optionally disable D+ pullup */ 126 /* optionally disable D+ pullup */
122 if (gpio_is_valid(gpio)) 127 if (gpio_is_valid(gpio))
@@ -125,7 +130,12 @@ static void gpio_vbus_work(struct work_struct *work)
125 set_vbus_draw(gpio_vbus, 0); 130 set_vbus_draw(gpio_vbus, 0);
126 131
127 usb_gadget_vbus_disconnect(gpio_vbus->phy.otg->gadget); 132 usb_gadget_vbus_disconnect(gpio_vbus->phy.otg->gadget);
133 status = USB_EVENT_NONE;
128 gpio_vbus->phy.state = OTG_STATE_B_IDLE; 134 gpio_vbus->phy.state = OTG_STATE_B_IDLE;
135 gpio_vbus->phy.last_event = status;
136
137 atomic_notifier_call_chain(&gpio_vbus->phy.notifier,
138 status, gpio_vbus->phy.otg->gadget);
129 } 139 }
130} 140}
131 141
@@ -287,6 +297,9 @@ static int __init gpio_vbus_probe(struct platform_device *pdev)
287 irq, err); 297 irq, err);
288 goto err_irq; 298 goto err_irq;
289 } 299 }
300
301 ATOMIC_INIT_NOTIFIER_HEAD(&gpio_vbus->phy.notifier);
302
290 INIT_WORK(&gpio_vbus->work, gpio_vbus_work); 303 INIT_WORK(&gpio_vbus->work, gpio_vbus_work);
291 304
292 gpio_vbus->vbus_draw = regulator_get(&pdev->dev, "vbus_draw"); 305 gpio_vbus->vbus_draw = regulator_get(&pdev->dev, "vbus_draw");
diff --git a/drivers/usb/serial/bus.c b/drivers/usb/serial/bus.c
index 7f547dc3a590..ed8adb052ca7 100644
--- a/drivers/usb/serial/bus.c
+++ b/drivers/usb/serial/bus.c
@@ -60,8 +60,6 @@ static int usb_serial_device_probe(struct device *dev)
60 retval = -ENODEV; 60 retval = -ENODEV;
61 goto exit; 61 goto exit;
62 } 62 }
63 if (port->dev_state != PORT_REGISTERING)
64 goto exit;
65 63
66 driver = port->serial->type; 64 driver = port->serial->type;
67 if (driver->port_probe) { 65 if (driver->port_probe) {
@@ -98,9 +96,6 @@ static int usb_serial_device_remove(struct device *dev)
98 if (!port) 96 if (!port)
99 return -ENODEV; 97 return -ENODEV;
100 98
101 if (port->dev_state != PORT_UNREGISTERING)
102 return retval;
103
104 device_remove_file(&port->dev, &dev_attr_port_number); 99 device_remove_file(&port->dev, &dev_attr_port_number);
105 100
106 driver = port->serial->type; 101 driver = port->serial->type;
diff --git a/drivers/usb/serial/cp210x.c b/drivers/usb/serial/cp210x.c
index 0310e2df59f5..ec30f95ef399 100644
--- a/drivers/usb/serial/cp210x.c
+++ b/drivers/usb/serial/cp210x.c
@@ -287,7 +287,8 @@ static int cp210x_get_config(struct usb_serial_port *port, u8 request,
287 /* Issue the request, attempting to read 'size' bytes */ 287 /* Issue the request, attempting to read 'size' bytes */
288 result = usb_control_msg(serial->dev, usb_rcvctrlpipe(serial->dev, 0), 288 result = usb_control_msg(serial->dev, usb_rcvctrlpipe(serial->dev, 0),
289 request, REQTYPE_DEVICE_TO_HOST, 0x0000, 289 request, REQTYPE_DEVICE_TO_HOST, 0x0000,
290 port_priv->bInterfaceNumber, buf, size, 300); 290 port_priv->bInterfaceNumber, buf, size,
291 USB_CTRL_GET_TIMEOUT);
291 292
292 /* Convert data into an array of integers */ 293 /* Convert data into an array of integers */
293 for (i = 0; i < length; i++) 294 for (i = 0; i < length; i++)
@@ -340,12 +341,14 @@ static int cp210x_set_config(struct usb_serial_port *port, u8 request,
340 result = usb_control_msg(serial->dev, 341 result = usb_control_msg(serial->dev,
341 usb_sndctrlpipe(serial->dev, 0), 342 usb_sndctrlpipe(serial->dev, 0),
342 request, REQTYPE_HOST_TO_DEVICE, 0x0000, 343 request, REQTYPE_HOST_TO_DEVICE, 0x0000,
343 port_priv->bInterfaceNumber, buf, size, 300); 344 port_priv->bInterfaceNumber, buf, size,
345 USB_CTRL_SET_TIMEOUT);
344 } else { 346 } else {
345 result = usb_control_msg(serial->dev, 347 result = usb_control_msg(serial->dev,
346 usb_sndctrlpipe(serial->dev, 0), 348 usb_sndctrlpipe(serial->dev, 0),
347 request, REQTYPE_HOST_TO_DEVICE, data[0], 349 request, REQTYPE_HOST_TO_DEVICE, data[0],
348 port_priv->bInterfaceNumber, NULL, 0, 300); 350 port_priv->bInterfaceNumber, NULL, 0,
351 USB_CTRL_SET_TIMEOUT);
349 } 352 }
350 353
351 kfree(buf); 354 kfree(buf);
diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c
index ff8605b4b4be..02e7f2d32d52 100644
--- a/drivers/usb/serial/ftdi_sio.c
+++ b/drivers/usb/serial/ftdi_sio.c
@@ -75,7 +75,8 @@ struct ftdi_private {
75 unsigned long last_dtr_rts; /* saved modem control outputs */ 75 unsigned long last_dtr_rts; /* saved modem control outputs */
76 struct async_icount icount; 76 struct async_icount icount;
77 wait_queue_head_t delta_msr_wait; /* Used for TIOCMIWAIT */ 77 wait_queue_head_t delta_msr_wait; /* Used for TIOCMIWAIT */
78 char prev_status, diff_status; /* Used for TIOCMIWAIT */ 78 char prev_status; /* Used for TIOCMIWAIT */
79 bool dev_gone; /* Used to abort TIOCMIWAIT */
79 char transmit_empty; /* If transmitter is empty or not */ 80 char transmit_empty; /* If transmitter is empty or not */
80 struct usb_serial_port *port; 81 struct usb_serial_port *port;
81 __u16 interface; /* FT2232C, FT2232H or FT4232H port interface 82 __u16 interface; /* FT2232C, FT2232H or FT4232H port interface
@@ -1681,6 +1682,7 @@ static int ftdi_sio_port_probe(struct usb_serial_port *port)
1681 init_waitqueue_head(&priv->delta_msr_wait); 1682 init_waitqueue_head(&priv->delta_msr_wait);
1682 1683
1683 priv->flags = ASYNC_LOW_LATENCY; 1684 priv->flags = ASYNC_LOW_LATENCY;
1685 priv->dev_gone = false;
1684 1686
1685 if (quirk && quirk->port_probe) 1687 if (quirk && quirk->port_probe)
1686 quirk->port_probe(priv); 1688 quirk->port_probe(priv);
@@ -1839,6 +1841,9 @@ static int ftdi_sio_port_remove(struct usb_serial_port *port)
1839 1841
1840 dbg("%s", __func__); 1842 dbg("%s", __func__);
1841 1843
1844 priv->dev_gone = true;
1845 wake_up_interruptible_all(&priv->delta_msr_wait);
1846
1842 remove_sysfs_attrs(port); 1847 remove_sysfs_attrs(port);
1843 1848
1844 kref_put(&priv->kref, ftdi_sio_priv_release); 1849 kref_put(&priv->kref, ftdi_sio_priv_release);
@@ -1982,17 +1987,19 @@ static int ftdi_process_packet(struct tty_struct *tty,
1982 N.B. packet may be processed more than once, but differences 1987 N.B. packet may be processed more than once, but differences
1983 are only processed once. */ 1988 are only processed once. */
1984 status = packet[0] & FTDI_STATUS_B0_MASK; 1989 status = packet[0] & FTDI_STATUS_B0_MASK;
1985 if (status & FTDI_RS0_CTS)
1986 priv->icount.cts++;
1987 if (status & FTDI_RS0_DSR)
1988 priv->icount.dsr++;
1989 if (status & FTDI_RS0_RI)
1990 priv->icount.rng++;
1991 if (status & FTDI_RS0_RLSD)
1992 priv->icount.dcd++;
1993 if (status != priv->prev_status) { 1990 if (status != priv->prev_status) {
1994 priv->diff_status |= status ^ priv->prev_status; 1991 char diff_status = status ^ priv->prev_status;
1995 wake_up_interruptible(&priv->delta_msr_wait); 1992
1993 if (diff_status & FTDI_RS0_CTS)
1994 priv->icount.cts++;
1995 if (diff_status & FTDI_RS0_DSR)
1996 priv->icount.dsr++;
1997 if (diff_status & FTDI_RS0_RI)
1998 priv->icount.rng++;
1999 if (diff_status & FTDI_RS0_RLSD)
2000 priv->icount.dcd++;
2001
2002 wake_up_interruptible_all(&priv->delta_msr_wait);
1996 priv->prev_status = status; 2003 priv->prev_status = status;
1997 } 2004 }
1998 2005
@@ -2395,15 +2402,12 @@ static int ftdi_ioctl(struct tty_struct *tty,
2395 */ 2402 */
2396 case TIOCMIWAIT: 2403 case TIOCMIWAIT:
2397 cprev = priv->icount; 2404 cprev = priv->icount;
2398 while (1) { 2405 while (!priv->dev_gone) {
2399 interruptible_sleep_on(&priv->delta_msr_wait); 2406 interruptible_sleep_on(&priv->delta_msr_wait);
2400 /* see if a signal did it */ 2407 /* see if a signal did it */
2401 if (signal_pending(current)) 2408 if (signal_pending(current))
2402 return -ERESTARTSYS; 2409 return -ERESTARTSYS;
2403 cnow = priv->icount; 2410 cnow = priv->icount;
2404 if (cnow.rng == cprev.rng && cnow.dsr == cprev.dsr &&
2405 cnow.dcd == cprev.dcd && cnow.cts == cprev.cts)
2406 return -EIO; /* no change => error */
2407 if (((arg & TIOCM_RNG) && (cnow.rng != cprev.rng)) || 2411 if (((arg & TIOCM_RNG) && (cnow.rng != cprev.rng)) ||
2408 ((arg & TIOCM_DSR) && (cnow.dsr != cprev.dsr)) || 2412 ((arg & TIOCM_DSR) && (cnow.dsr != cprev.dsr)) ||
2409 ((arg & TIOCM_CD) && (cnow.dcd != cprev.dcd)) || 2413 ((arg & TIOCM_CD) && (cnow.dcd != cprev.dcd)) ||
@@ -2412,7 +2416,7 @@ static int ftdi_ioctl(struct tty_struct *tty,
2412 } 2416 }
2413 cprev = cnow; 2417 cprev = cnow;
2414 } 2418 }
2415 /* not reached */ 2419 return -EIO;
2416 break; 2420 break;
2417 case TIOCSERGETLSR: 2421 case TIOCSERGETLSR:
2418 return get_lsr_info(port, (struct serial_struct __user *)arg); 2422 return get_lsr_info(port, (struct serial_struct __user *)arg);
diff --git a/drivers/usb/serial/metro-usb.c b/drivers/usb/serial/metro-usb.c
index 6e1622f2a297..08d16e8c002d 100644
--- a/drivers/usb/serial/metro-usb.c
+++ b/drivers/usb/serial/metro-usb.c
@@ -27,8 +27,8 @@
27 27
28/* Product information. */ 28/* Product information. */
29#define FOCUS_VENDOR_ID 0x0C2E 29#define FOCUS_VENDOR_ID 0x0C2E
30#define FOCUS_PRODUCT_ID 0x0720 30#define FOCUS_PRODUCT_ID_BI 0x0720
31#define FOCUS_PRODUCT_ID_UNI 0x0710 31#define FOCUS_PRODUCT_ID_UNI 0x0700
32 32
33#define METROUSB_SET_REQUEST_TYPE 0x40 33#define METROUSB_SET_REQUEST_TYPE 0x40
34#define METROUSB_SET_MODEM_CTRL_REQUEST 10 34#define METROUSB_SET_MODEM_CTRL_REQUEST 10
@@ -47,7 +47,7 @@ struct metrousb_private {
47 47
48/* Device table list. */ 48/* Device table list. */
49static struct usb_device_id id_table[] = { 49static struct usb_device_id id_table[] = {
50 { USB_DEVICE(FOCUS_VENDOR_ID, FOCUS_PRODUCT_ID) }, 50 { USB_DEVICE(FOCUS_VENDOR_ID, FOCUS_PRODUCT_ID_BI) },
51 { USB_DEVICE(FOCUS_VENDOR_ID, FOCUS_PRODUCT_ID_UNI) }, 51 { USB_DEVICE(FOCUS_VENDOR_ID, FOCUS_PRODUCT_ID_UNI) },
52 { }, /* Terminating entry. */ 52 { }, /* Terminating entry. */
53}; 53};
diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c
index 836cfa9a515f..f4465ccddc35 100644
--- a/drivers/usb/serial/option.c
+++ b/drivers/usb/serial/option.c
@@ -708,6 +708,7 @@ static const struct usb_device_id option_ids[] = {
708 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_EVDO_EMBEDDED_FULLSPEED) }, 708 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_EVDO_EMBEDDED_FULLSPEED) },
709 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_HSPA_EMBEDDED_FULLSPEED) }, 709 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_HSPA_EMBEDDED_FULLSPEED) },
710 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_EVDO_HIGHSPEED) }, 710 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_EVDO_HIGHSPEED) },
711 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_HSPA_HIGHSPEED) },
711 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_HSPA_HIGHSPEED3) }, 712 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_HSPA_HIGHSPEED3) },
712 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_HSPA_HIGHSPEED4) }, 713 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_HSPA_HIGHSPEED4) },
713 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_HSPA_HIGHSPEED5) }, 714 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_HSPA_HIGHSPEED5) },
diff --git a/drivers/usb/serial/pl2303.c b/drivers/usb/serial/pl2303.c
index ff4a174fa5de..a1a9062954c4 100644
--- a/drivers/usb/serial/pl2303.c
+++ b/drivers/usb/serial/pl2303.c
@@ -420,7 +420,7 @@ static void pl2303_set_termios(struct tty_struct *tty,
420 control = priv->line_control; 420 control = priv->line_control;
421 if ((cflag & CBAUD) == B0) 421 if ((cflag & CBAUD) == B0)
422 priv->line_control &= ~(CONTROL_DTR | CONTROL_RTS); 422 priv->line_control &= ~(CONTROL_DTR | CONTROL_RTS);
423 else 423 else if ((old_termios->c_cflag & CBAUD) == B0)
424 priv->line_control |= (CONTROL_DTR | CONTROL_RTS); 424 priv->line_control |= (CONTROL_DTR | CONTROL_RTS);
425 if (control != priv->line_control) { 425 if (control != priv->line_control) {
426 control = priv->line_control; 426 control = priv->line_control;
diff --git a/drivers/usb/serial/sierra.c b/drivers/usb/serial/sierra.c
index f14465a83dd1..8c8bf806f6fa 100644
--- a/drivers/usb/serial/sierra.c
+++ b/drivers/usb/serial/sierra.c
@@ -221,7 +221,7 @@ static const struct sierra_iface_info typeB_interface_list = {
221}; 221};
222 222
223/* 'blacklist' of interfaces not served by this driver */ 223/* 'blacklist' of interfaces not served by this driver */
224static const u8 direct_ip_non_serial_ifaces[] = { 7, 8, 9, 10, 11 }; 224static const u8 direct_ip_non_serial_ifaces[] = { 7, 8, 9, 10, 11, 19, 20 };
225static const struct sierra_iface_info direct_ip_interface_blacklist = { 225static const struct sierra_iface_info direct_ip_interface_blacklist = {
226 .infolen = ARRAY_SIZE(direct_ip_non_serial_ifaces), 226 .infolen = ARRAY_SIZE(direct_ip_non_serial_ifaces),
227 .ifaceinfo = direct_ip_non_serial_ifaces, 227 .ifaceinfo = direct_ip_non_serial_ifaces,
@@ -298,6 +298,9 @@ static const struct usb_device_id id_table[] = {
298 /* Sierra Wireless HSPA Non-Composite Device */ 298 /* Sierra Wireless HSPA Non-Composite Device */
299 { USB_DEVICE_AND_INTERFACE_INFO(0x1199, 0x6892, 0xFF, 0xFF, 0xFF)}, 299 { USB_DEVICE_AND_INTERFACE_INFO(0x1199, 0x6892, 0xFF, 0xFF, 0xFF)},
300 { USB_DEVICE(0x1199, 0x6893) }, /* Sierra Wireless Device */ 300 { USB_DEVICE(0x1199, 0x6893) }, /* Sierra Wireless Device */
301 { USB_DEVICE(0x1199, 0x68A2), /* Sierra Wireless MC77xx in QMI mode */
302 .driver_info = (kernel_ulong_t)&direct_ip_interface_blacklist
303 },
301 { USB_DEVICE(0x1199, 0x68A3), /* Sierra Wireless Direct IP modems */ 304 { USB_DEVICE(0x1199, 0x68A3), /* Sierra Wireless Direct IP modems */
302 .driver_info = (kernel_ulong_t)&direct_ip_interface_blacklist 305 .driver_info = (kernel_ulong_t)&direct_ip_interface_blacklist
303 }, 306 },
diff --git a/drivers/usb/serial/usb-serial.c b/drivers/usb/serial/usb-serial.c
index 69230f01056a..97355a15bbea 100644
--- a/drivers/usb/serial/usb-serial.c
+++ b/drivers/usb/serial/usb-serial.c
@@ -1059,6 +1059,12 @@ int usb_serial_probe(struct usb_interface *interface,
1059 serial->attached = 1; 1059 serial->attached = 1;
1060 } 1060 }
1061 1061
1062 /* Avoid race with tty_open and serial_install by setting the
1063 * disconnected flag and not clearing it until all ports have been
1064 * registered.
1065 */
1066 serial->disconnected = 1;
1067
1062 if (get_free_serial(serial, num_ports, &minor) == NULL) { 1068 if (get_free_serial(serial, num_ports, &minor) == NULL) {
1063 dev_err(&interface->dev, "No more free serial devices\n"); 1069 dev_err(&interface->dev, "No more free serial devices\n");
1064 goto probe_error; 1070 goto probe_error;
@@ -1070,19 +1076,16 @@ int usb_serial_probe(struct usb_interface *interface,
1070 port = serial->port[i]; 1076 port = serial->port[i];
1071 dev_set_name(&port->dev, "ttyUSB%d", port->number); 1077 dev_set_name(&port->dev, "ttyUSB%d", port->number);
1072 dbg ("%s - registering %s", __func__, dev_name(&port->dev)); 1078 dbg ("%s - registering %s", __func__, dev_name(&port->dev));
1073 port->dev_state = PORT_REGISTERING;
1074 device_enable_async_suspend(&port->dev); 1079 device_enable_async_suspend(&port->dev);
1075 1080
1076 retval = device_add(&port->dev); 1081 retval = device_add(&port->dev);
1077 if (retval) { 1082 if (retval)
1078 dev_err(&port->dev, "Error registering port device, " 1083 dev_err(&port->dev, "Error registering port device, "
1079 "continuing\n"); 1084 "continuing\n");
1080 port->dev_state = PORT_UNREGISTERED;
1081 } else {
1082 port->dev_state = PORT_REGISTERED;
1083 }
1084 } 1085 }
1085 1086
1087 serial->disconnected = 0;
1088
1086 usb_serial_console_init(debug, minor); 1089 usb_serial_console_init(debug, minor);
1087 1090
1088exit: 1091exit:
@@ -1124,22 +1127,8 @@ void usb_serial_disconnect(struct usb_interface *interface)
1124 } 1127 }
1125 kill_traffic(port); 1128 kill_traffic(port);
1126 cancel_work_sync(&port->work); 1129 cancel_work_sync(&port->work);
1127 if (port->dev_state == PORT_REGISTERED) { 1130 if (device_is_registered(&port->dev))
1128
1129 /* Make sure the port is bound so that the
1130 * driver's port_remove method is called.
1131 */
1132 if (!port->dev.driver) {
1133 int rc;
1134
1135 port->dev.driver =
1136 &serial->type->driver;
1137 rc = device_bind_driver(&port->dev);
1138 }
1139 port->dev_state = PORT_UNREGISTERING;
1140 device_del(&port->dev); 1131 device_del(&port->dev);
1141 port->dev_state = PORT_UNREGISTERED;
1142 }
1143 } 1132 }
1144 } 1133 }
1145 serial->type->disconnect(serial); 1134 serial->type->disconnect(serial);
diff --git a/drivers/usb/storage/usb.c b/drivers/usb/storage/usb.c
index c18538e4a6db..2653e73db623 100644
--- a/drivers/usb/storage/usb.c
+++ b/drivers/usb/storage/usb.c
@@ -132,6 +132,35 @@ static struct us_unusual_dev for_dynamic_ids =
132#undef COMPLIANT_DEV 132#undef COMPLIANT_DEV
133#undef USUAL_DEV 133#undef USUAL_DEV
134 134
135#ifdef CONFIG_LOCKDEP
136
137static struct lock_class_key us_interface_key[USB_MAXINTERFACES];
138
139static void us_set_lock_class(struct mutex *mutex,
140 struct usb_interface *intf)
141{
142 struct usb_device *udev = interface_to_usbdev(intf);
143 struct usb_host_config *config = udev->actconfig;
144 int i;
145
146 for (i = 0; i < config->desc.bNumInterfaces; i++) {
147 if (config->interface[i] == intf)
148 break;
149 }
150
151 BUG_ON(i == config->desc.bNumInterfaces);
152
153 lockdep_set_class(mutex, &us_interface_key[i]);
154}
155
156#else
157
158static void us_set_lock_class(struct mutex *mutex,
159 struct usb_interface *intf)
160{
161}
162
163#endif
135 164
136#ifdef CONFIG_PM /* Minimal support for suspend and resume */ 165#ifdef CONFIG_PM /* Minimal support for suspend and resume */
137 166
@@ -895,6 +924,7 @@ int usb_stor_probe1(struct us_data **pus,
895 *pus = us = host_to_us(host); 924 *pus = us = host_to_us(host);
896 memset(us, 0, sizeof(struct us_data)); 925 memset(us, 0, sizeof(struct us_data));
897 mutex_init(&(us->dev_mutex)); 926 mutex_init(&(us->dev_mutex));
927 us_set_lock_class(&us->dev_mutex, intf);
898 init_completion(&us->cmnd_ready); 928 init_completion(&us->cmnd_ready);
899 init_completion(&(us->notify)); 929 init_completion(&(us->notify));
900 init_waitqueue_head(&us->delay_wait); 930 init_waitqueue_head(&us->delay_wait);
diff --git a/drivers/uwb/hwa-rc.c b/drivers/uwb/hwa-rc.c
index 66797e9c5010..810c90ae2c55 100644
--- a/drivers/uwb/hwa-rc.c
+++ b/drivers/uwb/hwa-rc.c
@@ -645,7 +645,8 @@ void hwarc_neep_cb(struct urb *urb)
645 dev_err(dev, "NEEP: URB error %d\n", urb->status); 645 dev_err(dev, "NEEP: URB error %d\n", urb->status);
646 } 646 }
647 result = usb_submit_urb(urb, GFP_ATOMIC); 647 result = usb_submit_urb(urb, GFP_ATOMIC);
648 if (result < 0) { 648 if (result < 0 && result != -ENODEV && result != -EPERM) {
649 /* ignoring unrecoverable errors */
649 dev_err(dev, "NEEP: Can't resubmit URB (%d) resetting device\n", 650 dev_err(dev, "NEEP: Can't resubmit URB (%d) resetting device\n",
650 result); 651 result);
651 goto error; 652 goto error;
diff --git a/drivers/uwb/neh.c b/drivers/uwb/neh.c
index a269937be1b8..8cb71bb333c2 100644
--- a/drivers/uwb/neh.c
+++ b/drivers/uwb/neh.c
@@ -107,6 +107,7 @@ struct uwb_rc_neh {
107 u8 evt_type; 107 u8 evt_type;
108 __le16 evt; 108 __le16 evt;
109 u8 context; 109 u8 context;
110 u8 completed;
110 uwb_rc_cmd_cb_f cb; 111 uwb_rc_cmd_cb_f cb;
111 void *arg; 112 void *arg;
112 113
@@ -409,6 +410,7 @@ static void uwb_rc_neh_grok_event(struct uwb_rc *rc, struct uwb_rceb *rceb, size
409 struct device *dev = &rc->uwb_dev.dev; 410 struct device *dev = &rc->uwb_dev.dev;
410 struct uwb_rc_neh *neh; 411 struct uwb_rc_neh *neh;
411 struct uwb_rceb *notif; 412 struct uwb_rceb *notif;
413 unsigned long flags;
412 414
413 if (rceb->bEventContext == 0) { 415 if (rceb->bEventContext == 0) {
414 notif = kmalloc(size, GFP_ATOMIC); 416 notif = kmalloc(size, GFP_ATOMIC);
@@ -422,7 +424,11 @@ static void uwb_rc_neh_grok_event(struct uwb_rc *rc, struct uwb_rceb *rceb, size
422 } else { 424 } else {
423 neh = uwb_rc_neh_lookup(rc, rceb); 425 neh = uwb_rc_neh_lookup(rc, rceb);
424 if (neh) { 426 if (neh) {
425 del_timer_sync(&neh->timer); 427 spin_lock_irqsave(&rc->neh_lock, flags);
428 /* to guard against a timeout */
429 neh->completed = 1;
430 del_timer(&neh->timer);
431 spin_unlock_irqrestore(&rc->neh_lock, flags);
426 uwb_rc_neh_cb(neh, rceb, size); 432 uwb_rc_neh_cb(neh, rceb, size);
427 } else 433 } else
428 dev_warn(dev, "event 0x%02x/%04x/%02x (%zu bytes): nobody cared\n", 434 dev_warn(dev, "event 0x%02x/%04x/%02x (%zu bytes): nobody cared\n",
@@ -568,6 +574,10 @@ static void uwb_rc_neh_timer(unsigned long arg)
568 unsigned long flags; 574 unsigned long flags;
569 575
570 spin_lock_irqsave(&rc->neh_lock, flags); 576 spin_lock_irqsave(&rc->neh_lock, flags);
577 if (neh->completed) {
578 spin_unlock_irqrestore(&rc->neh_lock, flags);
579 return;
580 }
571 if (neh->context) 581 if (neh->context)
572 __uwb_rc_neh_rm(rc, neh); 582 __uwb_rc_neh_rm(rc, neh);
573 else 583 else
diff --git a/drivers/vhost/net.c b/drivers/vhost/net.c
index f0da2c32fbde..1f21d2a1e528 100644
--- a/drivers/vhost/net.c
+++ b/drivers/vhost/net.c
@@ -238,7 +238,7 @@ static void handle_tx(struct vhost_net *net)
238 238
239 vq->heads[vq->upend_idx].len = len; 239 vq->heads[vq->upend_idx].len = len;
240 ubuf->callback = vhost_zerocopy_callback; 240 ubuf->callback = vhost_zerocopy_callback;
241 ubuf->arg = vq->ubufs; 241 ubuf->ctx = vq->ubufs;
242 ubuf->desc = vq->upend_idx; 242 ubuf->desc = vq->upend_idx;
243 msg.msg_control = ubuf; 243 msg.msg_control = ubuf;
244 msg.msg_controllen = sizeof(ubuf); 244 msg.msg_controllen = sizeof(ubuf);
diff --git a/drivers/vhost/test.c b/drivers/vhost/test.c
index fc9a1d75281f..3de00d9fae2e 100644
--- a/drivers/vhost/test.c
+++ b/drivers/vhost/test.c
@@ -155,7 +155,7 @@ static int vhost_test_release(struct inode *inode, struct file *f)
155 155
156 vhost_test_stop(n, &private); 156 vhost_test_stop(n, &private);
157 vhost_test_flush(n); 157 vhost_test_flush(n);
158 vhost_dev_cleanup(&n->dev); 158 vhost_dev_cleanup(&n->dev, false);
159 /* We do an extra flush before freeing memory, 159 /* We do an extra flush before freeing memory,
160 * since jobs can re-queue themselves. */ 160 * since jobs can re-queue themselves. */
161 vhost_test_flush(n); 161 vhost_test_flush(n);
diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c
index 947f00d8e091..51e4c1eeec4f 100644
--- a/drivers/vhost/vhost.c
+++ b/drivers/vhost/vhost.c
@@ -1598,10 +1598,9 @@ void vhost_ubuf_put_and_wait(struct vhost_ubuf_ref *ubufs)
1598 kfree(ubufs); 1598 kfree(ubufs);
1599} 1599}
1600 1600
1601void vhost_zerocopy_callback(void *arg) 1601void vhost_zerocopy_callback(struct ubuf_info *ubuf)
1602{ 1602{
1603 struct ubuf_info *ubuf = arg; 1603 struct vhost_ubuf_ref *ubufs = ubuf->ctx;
1604 struct vhost_ubuf_ref *ubufs = ubuf->arg;
1605 struct vhost_virtqueue *vq = ubufs->vq; 1604 struct vhost_virtqueue *vq = ubufs->vq;
1606 1605
1607 /* set len = 1 to mark this desc buffers done DMA */ 1606 /* set len = 1 to mark this desc buffers done DMA */
diff --git a/drivers/vhost/vhost.h b/drivers/vhost/vhost.h
index 8dcf4cca6bf2..8de1fd5b8efb 100644
--- a/drivers/vhost/vhost.h
+++ b/drivers/vhost/vhost.h
@@ -188,7 +188,7 @@ bool vhost_enable_notify(struct vhost_dev *, struct vhost_virtqueue *);
188 188
189int vhost_log_write(struct vhost_virtqueue *vq, struct vhost_log *log, 189int vhost_log_write(struct vhost_virtqueue *vq, struct vhost_log *log,
190 unsigned int log_num, u64 len); 190 unsigned int log_num, u64 len);
191void vhost_zerocopy_callback(void *arg); 191void vhost_zerocopy_callback(struct ubuf_info *);
192int vhost_zerocopy_signal_used(struct vhost_virtqueue *vq); 192int vhost_zerocopy_signal_used(struct vhost_virtqueue *vq);
193 193
194#define vq_err(vq, fmt, ...) do { \ 194#define vq_err(vq, fmt, ...) do { \
diff --git a/drivers/video/au1100fb.c b/drivers/video/au1100fb.c
index befcbd8ef019..ffbce4525468 100644
--- a/drivers/video/au1100fb.c
+++ b/drivers/video/au1100fb.c
@@ -499,7 +499,8 @@ static int __devinit au1100fb_drv_probe(struct platform_device *dev)
499 au1100fb_fix.mmio_start = regs_res->start; 499 au1100fb_fix.mmio_start = regs_res->start;
500 au1100fb_fix.mmio_len = resource_size(regs_res); 500 au1100fb_fix.mmio_len = resource_size(regs_res);
501 501
502 if (!devm_request_mem_region(au1100fb_fix.mmio_start, 502 if (!devm_request_mem_region(&dev->dev,
503 au1100fb_fix.mmio_start,
503 au1100fb_fix.mmio_len, 504 au1100fb_fix.mmio_len,
504 DRIVER_NAME)) { 505 DRIVER_NAME)) {
505 print_err("fail to lock memory region at 0x%08lx", 506 print_err("fail to lock memory region at 0x%08lx",
@@ -516,7 +517,7 @@ static int __devinit au1100fb_drv_probe(struct platform_device *dev)
516 fbdev->fb_len = fbdev->panel->xres * fbdev->panel->yres * 517 fbdev->fb_len = fbdev->panel->xres * fbdev->panel->yres *
517 (fbdev->panel->bpp >> 3) * AU1100FB_NBR_VIDEO_BUFFERS; 518 (fbdev->panel->bpp >> 3) * AU1100FB_NBR_VIDEO_BUFFERS;
518 519
519 fbdev->fb_mem = dmam_alloc_coherent(&dev->dev, &dev->dev, 520 fbdev->fb_mem = dmam_alloc_coherent(&dev->dev,
520 PAGE_ALIGN(fbdev->fb_len), 521 PAGE_ALIGN(fbdev->fb_len),
521 &fbdev->fb_phys, GFP_KERNEL); 522 &fbdev->fb_phys, GFP_KERNEL);
522 if (!fbdev->fb_mem) { 523 if (!fbdev->fb_mem) {
diff --git a/drivers/video/au1200fb.c b/drivers/video/au1200fb.c
index 3e9a773db09f..7ca79f02056e 100644
--- a/drivers/video/au1200fb.c
+++ b/drivers/video/au1200fb.c
@@ -1724,7 +1724,7 @@ static int __devinit au1200fb_drv_probe(struct platform_device *dev)
1724 /* Allocate the framebuffer to the maximum screen size */ 1724 /* Allocate the framebuffer to the maximum screen size */
1725 fbdev->fb_len = (win->w[plane].xres * win->w[plane].yres * bpp) / 8; 1725 fbdev->fb_len = (win->w[plane].xres * win->w[plane].yres * bpp) / 8;
1726 1726
1727 fbdev->fb_mem = dmam_alloc_noncoherent(&dev->dev, &dev->dev, 1727 fbdev->fb_mem = dmam_alloc_noncoherent(&dev->dev,
1728 PAGE_ALIGN(fbdev->fb_len), 1728 PAGE_ALIGN(fbdev->fb_len),
1729 &fbdev->fb_phys, GFP_KERNEL); 1729 &fbdev->fb_phys, GFP_KERNEL);
1730 if (!fbdev->fb_mem) { 1730 if (!fbdev->fb_mem) {
diff --git a/drivers/video/bfin-lq035q1-fb.c b/drivers/video/bfin-lq035q1-fb.c
index 86922ac84412..353c02fe8a95 100644
--- a/drivers/video/bfin-lq035q1-fb.c
+++ b/drivers/video/bfin-lq035q1-fb.c
@@ -13,6 +13,7 @@
13#include <linux/errno.h> 13#include <linux/errno.h>
14#include <linux/string.h> 14#include <linux/string.h>
15#include <linux/fb.h> 15#include <linux/fb.h>
16#include <linux/gpio.h>
16#include <linux/slab.h> 17#include <linux/slab.h>
17#include <linux/init.h> 18#include <linux/init.h>
18#include <linux/types.h> 19#include <linux/types.h>
diff --git a/drivers/video/kyro/STG4000Reg.h b/drivers/video/kyro/STG4000Reg.h
index 5d6269882589..50f4670e9252 100644
--- a/drivers/video/kyro/STG4000Reg.h
+++ b/drivers/video/kyro/STG4000Reg.h
@@ -73,210 +73,210 @@ typedef enum _OVRL_PIX_FORMAT {
73/* Register Table */ 73/* Register Table */
74typedef struct { 74typedef struct {
75 /* 0h */ 75 /* 0h */
76 volatile unsigned long Thread0Enable; /* 0x0000 */ 76 volatile u32 Thread0Enable; /* 0x0000 */
77 volatile unsigned long Thread1Enable; /* 0x0004 */ 77 volatile u32 Thread1Enable; /* 0x0004 */
78 volatile unsigned long Thread0Recover; /* 0x0008 */ 78 volatile u32 Thread0Recover; /* 0x0008 */
79 volatile unsigned long Thread1Recover; /* 0x000C */ 79 volatile u32 Thread1Recover; /* 0x000C */
80 volatile unsigned long Thread0Step; /* 0x0010 */ 80 volatile u32 Thread0Step; /* 0x0010 */
81 volatile unsigned long Thread1Step; /* 0x0014 */ 81 volatile u32 Thread1Step; /* 0x0014 */
82 volatile unsigned long VideoInStatus; /* 0x0018 */ 82 volatile u32 VideoInStatus; /* 0x0018 */
83 volatile unsigned long Core2InSignStart; /* 0x001C */ 83 volatile u32 Core2InSignStart; /* 0x001C */
84 volatile unsigned long Core1ResetVector; /* 0x0020 */ 84 volatile u32 Core1ResetVector; /* 0x0020 */
85 volatile unsigned long Core1ROMOffset; /* 0x0024 */ 85 volatile u32 Core1ROMOffset; /* 0x0024 */
86 volatile unsigned long Core1ArbiterPriority; /* 0x0028 */ 86 volatile u32 Core1ArbiterPriority; /* 0x0028 */
87 volatile unsigned long VideoInControl; /* 0x002C */ 87 volatile u32 VideoInControl; /* 0x002C */
88 volatile unsigned long VideoInReg0CtrlA; /* 0x0030 */ 88 volatile u32 VideoInReg0CtrlA; /* 0x0030 */
89 volatile unsigned long VideoInReg0CtrlB; /* 0x0034 */ 89 volatile u32 VideoInReg0CtrlB; /* 0x0034 */
90 volatile unsigned long VideoInReg1CtrlA; /* 0x0038 */ 90 volatile u32 VideoInReg1CtrlA; /* 0x0038 */
91 volatile unsigned long VideoInReg1CtrlB; /* 0x003C */ 91 volatile u32 VideoInReg1CtrlB; /* 0x003C */
92 volatile unsigned long Thread0Kicker; /* 0x0040 */ 92 volatile u32 Thread0Kicker; /* 0x0040 */
93 volatile unsigned long Core2InputSign; /* 0x0044 */ 93 volatile u32 Core2InputSign; /* 0x0044 */
94 volatile unsigned long Thread0ProgCtr; /* 0x0048 */ 94 volatile u32 Thread0ProgCtr; /* 0x0048 */
95 volatile unsigned long Thread1ProgCtr; /* 0x004C */ 95 volatile u32 Thread1ProgCtr; /* 0x004C */
96 volatile unsigned long Thread1Kicker; /* 0x0050 */ 96 volatile u32 Thread1Kicker; /* 0x0050 */
97 volatile unsigned long GPRegister1; /* 0x0054 */ 97 volatile u32 GPRegister1; /* 0x0054 */
98 volatile unsigned long GPRegister2; /* 0x0058 */ 98 volatile u32 GPRegister2; /* 0x0058 */
99 volatile unsigned long GPRegister3; /* 0x005C */ 99 volatile u32 GPRegister3; /* 0x005C */
100 volatile unsigned long GPRegister4; /* 0x0060 */ 100 volatile u32 GPRegister4; /* 0x0060 */
101 volatile unsigned long SerialIntA; /* 0x0064 */ 101 volatile u32 SerialIntA; /* 0x0064 */
102 102
103 volatile unsigned long Fill0[6]; /* GAP 0x0068 - 0x007C */ 103 volatile u32 Fill0[6]; /* GAP 0x0068 - 0x007C */
104 104
105 volatile unsigned long SoftwareReset; /* 0x0080 */ 105 volatile u32 SoftwareReset; /* 0x0080 */
106 volatile unsigned long SerialIntB; /* 0x0084 */ 106 volatile u32 SerialIntB; /* 0x0084 */
107 107
108 volatile unsigned long Fill1[37]; /* GAP 0x0088 - 0x011C */ 108 volatile u32 Fill1[37]; /* GAP 0x0088 - 0x011C */
109 109
110 volatile unsigned long ROMELQV; /* 0x011C */ 110 volatile u32 ROMELQV; /* 0x011C */
111 volatile unsigned long WLWH; /* 0x0120 */ 111 volatile u32 WLWH; /* 0x0120 */
112 volatile unsigned long ROMELWL; /* 0x0124 */ 112 volatile u32 ROMELWL; /* 0x0124 */
113 113
114 volatile unsigned long dwFill_1; /* GAP 0x0128 */ 114 volatile u32 dwFill_1; /* GAP 0x0128 */
115 115
116 volatile unsigned long IntStatus; /* 0x012C */ 116 volatile u32 IntStatus; /* 0x012C */
117 volatile unsigned long IntMask; /* 0x0130 */ 117 volatile u32 IntMask; /* 0x0130 */
118 volatile unsigned long IntClear; /* 0x0134 */ 118 volatile u32 IntClear; /* 0x0134 */
119 119
120 volatile unsigned long Fill2[6]; /* GAP 0x0138 - 0x014C */ 120 volatile u32 Fill2[6]; /* GAP 0x0138 - 0x014C */
121 121
122 volatile unsigned long ROMGPIOA; /* 0x0150 */ 122 volatile u32 ROMGPIOA; /* 0x0150 */
123 volatile unsigned long ROMGPIOB; /* 0x0154 */ 123 volatile u32 ROMGPIOB; /* 0x0154 */
124 volatile unsigned long ROMGPIOC; /* 0x0158 */ 124 volatile u32 ROMGPIOC; /* 0x0158 */
125 volatile unsigned long ROMGPIOD; /* 0x015C */ 125 volatile u32 ROMGPIOD; /* 0x015C */
126 126
127 volatile unsigned long Fill3[2]; /* GAP 0x0160 - 0x0168 */ 127 volatile u32 Fill3[2]; /* GAP 0x0160 - 0x0168 */
128 128
129 volatile unsigned long AGPIntID; /* 0x0168 */ 129 volatile u32 AGPIntID; /* 0x0168 */
130 volatile unsigned long AGPIntClassCode; /* 0x016C */ 130 volatile u32 AGPIntClassCode; /* 0x016C */
131 volatile unsigned long AGPIntBIST; /* 0x0170 */ 131 volatile u32 AGPIntBIST; /* 0x0170 */
132 volatile unsigned long AGPIntSSID; /* 0x0174 */ 132 volatile u32 AGPIntSSID; /* 0x0174 */
133 volatile unsigned long AGPIntPMCSR; /* 0x0178 */ 133 volatile u32 AGPIntPMCSR; /* 0x0178 */
134 volatile unsigned long VGAFrameBufBase; /* 0x017C */ 134 volatile u32 VGAFrameBufBase; /* 0x017C */
135 volatile unsigned long VGANotify; /* 0x0180 */ 135 volatile u32 VGANotify; /* 0x0180 */
136 volatile unsigned long DACPLLMode; /* 0x0184 */ 136 volatile u32 DACPLLMode; /* 0x0184 */
137 volatile unsigned long Core1VideoClockDiv; /* 0x0188 */ 137 volatile u32 Core1VideoClockDiv; /* 0x0188 */
138 volatile unsigned long AGPIntStat; /* 0x018C */ 138 volatile u32 AGPIntStat; /* 0x018C */
139 139
140 /* 140 /*
141 volatile unsigned long Fill4[0x0400/4 - 0x0190/4]; //GAP 0x0190 - 0x0400 141 volatile u32 Fill4[0x0400/4 - 0x0190/4]; //GAP 0x0190 - 0x0400
142 volatile unsigned long Fill5[0x05FC/4 - 0x0400/4]; //GAP 0x0400 - 0x05FC Fog Table 142 volatile u32 Fill5[0x05FC/4 - 0x0400/4]; //GAP 0x0400 - 0x05FC Fog Table
143 volatile unsigned long Fill6[0x0604/4 - 0x0600/4]; //GAP 0x0600 - 0x0604 143 volatile u32 Fill6[0x0604/4 - 0x0600/4]; //GAP 0x0600 - 0x0604
144 volatile unsigned long Fill7[0x0680/4 - 0x0608/4]; //GAP 0x0608 - 0x0680 144 volatile u32 Fill7[0x0680/4 - 0x0608/4]; //GAP 0x0608 - 0x0680
145 volatile unsigned long Fill8[0x07FC/4 - 0x0684/4]; //GAP 0x0684 - 0x07FC 145 volatile u32 Fill8[0x07FC/4 - 0x0684/4]; //GAP 0x0684 - 0x07FC
146 */ 146 */
147 volatile unsigned long Fill4[412]; /* 0x0190 - 0x07FC */ 147 volatile u32 Fill4[412]; /* 0x0190 - 0x07FC */
148 148
149 volatile unsigned long TACtrlStreamBase; /* 0x0800 */ 149 volatile u32 TACtrlStreamBase; /* 0x0800 */
150 volatile unsigned long TAObjDataBase; /* 0x0804 */ 150 volatile u32 TAObjDataBase; /* 0x0804 */
151 volatile unsigned long TAPtrDataBase; /* 0x0808 */ 151 volatile u32 TAPtrDataBase; /* 0x0808 */
152 volatile unsigned long TARegionDataBase; /* 0x080C */ 152 volatile u32 TARegionDataBase; /* 0x080C */
153 volatile unsigned long TATailPtrBase; /* 0x0810 */ 153 volatile u32 TATailPtrBase; /* 0x0810 */
154 volatile unsigned long TAPtrRegionSize; /* 0x0814 */ 154 volatile u32 TAPtrRegionSize; /* 0x0814 */
155 volatile unsigned long TAConfiguration; /* 0x0818 */ 155 volatile u32 TAConfiguration; /* 0x0818 */
156 volatile unsigned long TAObjDataStartAddr; /* 0x081C */ 156 volatile u32 TAObjDataStartAddr; /* 0x081C */
157 volatile unsigned long TAObjDataEndAddr; /* 0x0820 */ 157 volatile u32 TAObjDataEndAddr; /* 0x0820 */
158 volatile unsigned long TAXScreenClip; /* 0x0824 */ 158 volatile u32 TAXScreenClip; /* 0x0824 */
159 volatile unsigned long TAYScreenClip; /* 0x0828 */ 159 volatile u32 TAYScreenClip; /* 0x0828 */
160 volatile unsigned long TARHWClamp; /* 0x082C */ 160 volatile u32 TARHWClamp; /* 0x082C */
161 volatile unsigned long TARHWCompare; /* 0x0830 */ 161 volatile u32 TARHWCompare; /* 0x0830 */
162 volatile unsigned long TAStart; /* 0x0834 */ 162 volatile u32 TAStart; /* 0x0834 */
163 volatile unsigned long TAObjReStart; /* 0x0838 */ 163 volatile u32 TAObjReStart; /* 0x0838 */
164 volatile unsigned long TAPtrReStart; /* 0x083C */ 164 volatile u32 TAPtrReStart; /* 0x083C */
165 volatile unsigned long TAStatus1; /* 0x0840 */ 165 volatile u32 TAStatus1; /* 0x0840 */
166 volatile unsigned long TAStatus2; /* 0x0844 */ 166 volatile u32 TAStatus2; /* 0x0844 */
167 volatile unsigned long TAIntStatus; /* 0x0848 */ 167 volatile u32 TAIntStatus; /* 0x0848 */
168 volatile unsigned long TAIntMask; /* 0x084C */ 168 volatile u32 TAIntMask; /* 0x084C */
169 169
170 volatile unsigned long Fill5[235]; /* GAP 0x0850 - 0x0BF8 */ 170 volatile u32 Fill5[235]; /* GAP 0x0850 - 0x0BF8 */
171 171
172 volatile unsigned long TextureAddrThresh; /* 0x0BFC */ 172 volatile u32 TextureAddrThresh; /* 0x0BFC */
173 volatile unsigned long Core1Translation; /* 0x0C00 */ 173 volatile u32 Core1Translation; /* 0x0C00 */
174 volatile unsigned long TextureAddrReMap; /* 0x0C04 */ 174 volatile u32 TextureAddrReMap; /* 0x0C04 */
175 volatile unsigned long RenderOutAGPRemap; /* 0x0C08 */ 175 volatile u32 RenderOutAGPRemap; /* 0x0C08 */
176 volatile unsigned long _3DRegionReadTrans; /* 0x0C0C */ 176 volatile u32 _3DRegionReadTrans; /* 0x0C0C */
177 volatile unsigned long _3DPtrReadTrans; /* 0x0C10 */ 177 volatile u32 _3DPtrReadTrans; /* 0x0C10 */
178 volatile unsigned long _3DParamReadTrans; /* 0x0C14 */ 178 volatile u32 _3DParamReadTrans; /* 0x0C14 */
179 volatile unsigned long _3DRegionReadThresh; /* 0x0C18 */ 179 volatile u32 _3DRegionReadThresh; /* 0x0C18 */
180 volatile unsigned long _3DPtrReadThresh; /* 0x0C1C */ 180 volatile u32 _3DPtrReadThresh; /* 0x0C1C */
181 volatile unsigned long _3DParamReadThresh; /* 0x0C20 */ 181 volatile u32 _3DParamReadThresh; /* 0x0C20 */
182 volatile unsigned long _3DRegionReadAGPRemap; /* 0x0C24 */ 182 volatile u32 _3DRegionReadAGPRemap; /* 0x0C24 */
183 volatile unsigned long _3DPtrReadAGPRemap; /* 0x0C28 */ 183 volatile u32 _3DPtrReadAGPRemap; /* 0x0C28 */
184 volatile unsigned long _3DParamReadAGPRemap; /* 0x0C2C */ 184 volatile u32 _3DParamReadAGPRemap; /* 0x0C2C */
185 volatile unsigned long ZBufferAGPRemap; /* 0x0C30 */ 185 volatile u32 ZBufferAGPRemap; /* 0x0C30 */
186 volatile unsigned long TAIndexAGPRemap; /* 0x0C34 */ 186 volatile u32 TAIndexAGPRemap; /* 0x0C34 */
187 volatile unsigned long TAVertexAGPRemap; /* 0x0C38 */ 187 volatile u32 TAVertexAGPRemap; /* 0x0C38 */
188 volatile unsigned long TAUVAddrTrans; /* 0x0C3C */ 188 volatile u32 TAUVAddrTrans; /* 0x0C3C */
189 volatile unsigned long TATailPtrCacheTrans; /* 0x0C40 */ 189 volatile u32 TATailPtrCacheTrans; /* 0x0C40 */
190 volatile unsigned long TAParamWriteTrans; /* 0x0C44 */ 190 volatile u32 TAParamWriteTrans; /* 0x0C44 */
191 volatile unsigned long TAPtrWriteTrans; /* 0x0C48 */ 191 volatile u32 TAPtrWriteTrans; /* 0x0C48 */
192 volatile unsigned long TAParamWriteThresh; /* 0x0C4C */ 192 volatile u32 TAParamWriteThresh; /* 0x0C4C */
193 volatile unsigned long TAPtrWriteThresh; /* 0x0C50 */ 193 volatile u32 TAPtrWriteThresh; /* 0x0C50 */
194 volatile unsigned long TATailPtrCacheAGPRe; /* 0x0C54 */ 194 volatile u32 TATailPtrCacheAGPRe; /* 0x0C54 */
195 volatile unsigned long TAParamWriteAGPRe; /* 0x0C58 */ 195 volatile u32 TAParamWriteAGPRe; /* 0x0C58 */
196 volatile unsigned long TAPtrWriteAGPRe; /* 0x0C5C */ 196 volatile u32 TAPtrWriteAGPRe; /* 0x0C5C */
197 volatile unsigned long SDRAMArbiterConf; /* 0x0C60 */ 197 volatile u32 SDRAMArbiterConf; /* 0x0C60 */
198 volatile unsigned long SDRAMConf0; /* 0x0C64 */ 198 volatile u32 SDRAMConf0; /* 0x0C64 */
199 volatile unsigned long SDRAMConf1; /* 0x0C68 */ 199 volatile u32 SDRAMConf1; /* 0x0C68 */
200 volatile unsigned long SDRAMConf2; /* 0x0C6C */ 200 volatile u32 SDRAMConf2; /* 0x0C6C */
201 volatile unsigned long SDRAMRefresh; /* 0x0C70 */ 201 volatile u32 SDRAMRefresh; /* 0x0C70 */
202 volatile unsigned long SDRAMPowerStat; /* 0x0C74 */ 202 volatile u32 SDRAMPowerStat; /* 0x0C74 */
203 203
204 volatile unsigned long Fill6[2]; /* GAP 0x0C78 - 0x0C7C */ 204 volatile u32 Fill6[2]; /* GAP 0x0C78 - 0x0C7C */
205 205
206 volatile unsigned long RAMBistData; /* 0x0C80 */ 206 volatile u32 RAMBistData; /* 0x0C80 */
207 volatile unsigned long RAMBistCtrl; /* 0x0C84 */ 207 volatile u32 RAMBistCtrl; /* 0x0C84 */
208 volatile unsigned long FIFOBistKey; /* 0x0C88 */ 208 volatile u32 FIFOBistKey; /* 0x0C88 */
209 volatile unsigned long RAMBistResult; /* 0x0C8C */ 209 volatile u32 RAMBistResult; /* 0x0C8C */
210 volatile unsigned long FIFOBistResult; /* 0x0C90 */ 210 volatile u32 FIFOBistResult; /* 0x0C90 */
211 211
212 /* 212 /*
213 volatile unsigned long Fill11[0x0CBC/4 - 0x0C94/4]; //GAP 0x0C94 - 0x0CBC 213 volatile u32 Fill11[0x0CBC/4 - 0x0C94/4]; //GAP 0x0C94 - 0x0CBC
214 volatile unsigned long Fill12[0x0CD0/4 - 0x0CC0/4]; //GAP 0x0CC0 - 0x0CD0 3DRegisters 214 volatile u32 Fill12[0x0CD0/4 - 0x0CC0/4]; //GAP 0x0CC0 - 0x0CD0 3DRegisters
215 */ 215 */
216 216
217 volatile unsigned long Fill7[16]; /* 0x0c94 - 0x0cd0 */ 217 volatile u32 Fill7[16]; /* 0x0c94 - 0x0cd0 */
218 218
219 volatile unsigned long SDRAMAddrSign; /* 0x0CD4 */ 219 volatile u32 SDRAMAddrSign; /* 0x0CD4 */
220 volatile unsigned long SDRAMDataSign; /* 0x0CD8 */ 220 volatile u32 SDRAMDataSign; /* 0x0CD8 */
221 volatile unsigned long SDRAMSignConf; /* 0x0CDC */ 221 volatile u32 SDRAMSignConf; /* 0x0CDC */
222 222
223 /* DWFILL; //GAP 0x0CE0 */ 223 /* DWFILL; //GAP 0x0CE0 */
224 volatile unsigned long dwFill_2; 224 volatile u32 dwFill_2;
225 225
226 volatile unsigned long ISPSignature; /* 0x0CE4 */ 226 volatile u32 ISPSignature; /* 0x0CE4 */
227 227
228 volatile unsigned long Fill8[454]; /*GAP 0x0CE8 - 0x13FC */ 228 volatile u32 Fill8[454]; /*GAP 0x0CE8 - 0x13FC */
229 229
230 volatile unsigned long DACPrimAddress; /* 0x1400 */ 230 volatile u32 DACPrimAddress; /* 0x1400 */
231 volatile unsigned long DACPrimSize; /* 0x1404 */ 231 volatile u32 DACPrimSize; /* 0x1404 */
232 volatile unsigned long DACCursorAddr; /* 0x1408 */ 232 volatile u32 DACCursorAddr; /* 0x1408 */
233 volatile unsigned long DACCursorCtrl; /* 0x140C */ 233 volatile u32 DACCursorCtrl; /* 0x140C */
234 volatile unsigned long DACOverlayAddr; /* 0x1410 */ 234 volatile u32 DACOverlayAddr; /* 0x1410 */
235 volatile unsigned long DACOverlayUAddr; /* 0x1414 */ 235 volatile u32 DACOverlayUAddr; /* 0x1414 */
236 volatile unsigned long DACOverlayVAddr; /* 0x1418 */ 236 volatile u32 DACOverlayVAddr; /* 0x1418 */
237 volatile unsigned long DACOverlaySize; /* 0x141C */ 237 volatile u32 DACOverlaySize; /* 0x141C */
238 volatile unsigned long DACOverlayVtDec; /* 0x1420 */ 238 volatile u32 DACOverlayVtDec; /* 0x1420 */
239 239
240 volatile unsigned long Fill9[9]; /* GAP 0x1424 - 0x1444 */ 240 volatile u32 Fill9[9]; /* GAP 0x1424 - 0x1444 */
241 241
242 volatile unsigned long DACVerticalScal; /* 0x1448 */ 242 volatile u32 DACVerticalScal; /* 0x1448 */
243 volatile unsigned long DACPixelFormat; /* 0x144C */ 243 volatile u32 DACPixelFormat; /* 0x144C */
244 volatile unsigned long DACHorizontalScal; /* 0x1450 */ 244 volatile u32 DACHorizontalScal; /* 0x1450 */
245 volatile unsigned long DACVidWinStart; /* 0x1454 */ 245 volatile u32 DACVidWinStart; /* 0x1454 */
246 volatile unsigned long DACVidWinEnd; /* 0x1458 */ 246 volatile u32 DACVidWinEnd; /* 0x1458 */
247 volatile unsigned long DACBlendCtrl; /* 0x145C */ 247 volatile u32 DACBlendCtrl; /* 0x145C */
248 volatile unsigned long DACHorTim1; /* 0x1460 */ 248 volatile u32 DACHorTim1; /* 0x1460 */
249 volatile unsigned long DACHorTim2; /* 0x1464 */ 249 volatile u32 DACHorTim2; /* 0x1464 */
250 volatile unsigned long DACHorTim3; /* 0x1468 */ 250 volatile u32 DACHorTim3; /* 0x1468 */
251 volatile unsigned long DACVerTim1; /* 0x146C */ 251 volatile u32 DACVerTim1; /* 0x146C */
252 volatile unsigned long DACVerTim2; /* 0x1470 */ 252 volatile u32 DACVerTim2; /* 0x1470 */
253 volatile unsigned long DACVerTim3; /* 0x1474 */ 253 volatile u32 DACVerTim3; /* 0x1474 */
254 volatile unsigned long DACBorderColor; /* 0x1478 */ 254 volatile u32 DACBorderColor; /* 0x1478 */
255 volatile unsigned long DACSyncCtrl; /* 0x147C */ 255 volatile u32 DACSyncCtrl; /* 0x147C */
256 volatile unsigned long DACStreamCtrl; /* 0x1480 */ 256 volatile u32 DACStreamCtrl; /* 0x1480 */
257 volatile unsigned long DACLUTAddress; /* 0x1484 */ 257 volatile u32 DACLUTAddress; /* 0x1484 */
258 volatile unsigned long DACLUTData; /* 0x1488 */ 258 volatile u32 DACLUTData; /* 0x1488 */
259 volatile unsigned long DACBurstCtrl; /* 0x148C */ 259 volatile u32 DACBurstCtrl; /* 0x148C */
260 volatile unsigned long DACCrcTrigger; /* 0x1490 */ 260 volatile u32 DACCrcTrigger; /* 0x1490 */
261 volatile unsigned long DACCrcDone; /* 0x1494 */ 261 volatile u32 DACCrcDone; /* 0x1494 */
262 volatile unsigned long DACCrcResult1; /* 0x1498 */ 262 volatile u32 DACCrcResult1; /* 0x1498 */
263 volatile unsigned long DACCrcResult2; /* 0x149C */ 263 volatile u32 DACCrcResult2; /* 0x149C */
264 volatile unsigned long DACLinecount; /* 0x14A0 */ 264 volatile u32 DACLinecount; /* 0x14A0 */
265 265
266 volatile unsigned long Fill10[151]; /*GAP 0x14A4 - 0x16FC */ 266 volatile u32 Fill10[151]; /*GAP 0x14A4 - 0x16FC */
267 267
268 volatile unsigned long DigVidPortCtrl; /* 0x1700 */ 268 volatile u32 DigVidPortCtrl; /* 0x1700 */
269 volatile unsigned long DigVidPortStat; /* 0x1704 */ 269 volatile u32 DigVidPortStat; /* 0x1704 */
270 270
271 /* 271 /*
272 volatile unsigned long Fill11[0x1FFC/4 - 0x1708/4]; //GAP 0x1708 - 0x1FFC 272 volatile u32 Fill11[0x1FFC/4 - 0x1708/4]; //GAP 0x1708 - 0x1FFC
273 volatile unsigned long Fill17[0x3000/4 - 0x2FFC/4]; //GAP 0x2000 - 0x2FFC ALUT 273 volatile u32 Fill17[0x3000/4 - 0x2FFC/4]; //GAP 0x2000 - 0x2FFC ALUT
274 */ 274 */
275 275
276 volatile unsigned long Fill11[1598]; 276 volatile u32 Fill11[1598];
277 277
278 /* DWFILL; //GAP 0x3000 ALUT 256MB offset */ 278 /* DWFILL; //GAP 0x3000 ALUT 256MB offset */
279 volatile unsigned long Fill_3; 279 volatile u32 Fill_3;
280 280
281} STG4000REG; 281} STG4000REG;
282 282
diff --git a/drivers/video/msm/mddi.c b/drivers/video/msm/mddi.c
index 4527cbf0a4ec..b061d709bc44 100644
--- a/drivers/video/msm/mddi.c
+++ b/drivers/video/msm/mddi.c
@@ -420,7 +420,7 @@ static void mddi_resume(struct msm_mddi_client_data *cdata)
420 mddi_set_auto_hibernate(&mddi->client_data, 1); 420 mddi_set_auto_hibernate(&mddi->client_data, 1);
421} 421}
422 422
423static int __init mddi_get_client_caps(struct mddi_info *mddi) 423static int __devinit mddi_get_client_caps(struct mddi_info *mddi)
424{ 424{
425 int i, j; 425 int i, j;
426 426
@@ -622,9 +622,9 @@ uint32_t mddi_remote_read(struct msm_mddi_client_data *cdata, uint32_t reg)
622 622
623static struct mddi_info mddi_info[2]; 623static struct mddi_info mddi_info[2];
624 624
625static int __init mddi_clk_setup(struct platform_device *pdev, 625static int __devinit mddi_clk_setup(struct platform_device *pdev,
626 struct mddi_info *mddi, 626 struct mddi_info *mddi,
627 unsigned long clk_rate) 627 unsigned long clk_rate)
628{ 628{
629 int ret; 629 int ret;
630 630
diff --git a/drivers/video/uvesafb.c b/drivers/video/uvesafb.c
index 260cca7ddb41..26e83d7fdd6f 100644
--- a/drivers/video/uvesafb.c
+++ b/drivers/video/uvesafb.c
@@ -815,8 +815,15 @@ static int __devinit uvesafb_vbe_init(struct fb_info *info)
815 par->pmi_setpal = pmi_setpal; 815 par->pmi_setpal = pmi_setpal;
816 par->ypan = ypan; 816 par->ypan = ypan;
817 817
818 if (par->pmi_setpal || par->ypan) 818 if (par->pmi_setpal || par->ypan) {
819 uvesafb_vbe_getpmi(task, par); 819 if (__supported_pte_mask & _PAGE_NX) {
820 par->pmi_setpal = par->ypan = 0;
821 printk(KERN_WARNING "uvesafb: NX protection is actively."
822 "We have better not to use the PMI.\n");
823 } else {
824 uvesafb_vbe_getpmi(task, par);
825 }
826 }
820#else 827#else
821 /* The protected mode interface is not available on non-x86. */ 828 /* The protected mode interface is not available on non-x86. */
822 par->pmi_setpal = par->ypan = 0; 829 par->pmi_setpal = par->ypan = 0;
diff --git a/drivers/virtio/virtio_balloon.c b/drivers/virtio/virtio_balloon.c
index 05f0a80818a2..c2d05a8279fd 100644
--- a/drivers/virtio/virtio_balloon.c
+++ b/drivers/virtio/virtio_balloon.c
@@ -28,6 +28,13 @@
28#include <linux/slab.h> 28#include <linux/slab.h>
29#include <linux/module.h> 29#include <linux/module.h>
30 30
31/*
32 * Balloon device works in 4K page units. So each page is pointed to by
33 * multiple balloon pages. All memory counters in this driver are in balloon
34 * page units.
35 */
36#define VIRTIO_BALLOON_PAGES_PER_PAGE (PAGE_SIZE >> VIRTIO_BALLOON_PFN_SHIFT)
37
31struct virtio_balloon 38struct virtio_balloon
32{ 39{
33 struct virtio_device *vdev; 40 struct virtio_device *vdev;
@@ -42,8 +49,13 @@ struct virtio_balloon
42 /* Waiting for host to ack the pages we released. */ 49 /* Waiting for host to ack the pages we released. */
43 struct completion acked; 50 struct completion acked;
44 51
45 /* The pages we've told the Host we're not using. */ 52 /* Number of balloon pages we've told the Host we're not using. */
46 unsigned int num_pages; 53 unsigned int num_pages;
54 /*
55 * The pages we've told the Host we're not using.
56 * Each page on this list adds VIRTIO_BALLOON_PAGES_PER_PAGE
57 * to num_pages above.
58 */
47 struct list_head pages; 59 struct list_head pages;
48 60
49 /* The array of pfns we tell the Host about. */ 61 /* The array of pfns we tell the Host about. */
@@ -66,7 +78,13 @@ static u32 page_to_balloon_pfn(struct page *page)
66 78
67 BUILD_BUG_ON(PAGE_SHIFT < VIRTIO_BALLOON_PFN_SHIFT); 79 BUILD_BUG_ON(PAGE_SHIFT < VIRTIO_BALLOON_PFN_SHIFT);
68 /* Convert pfn from Linux page size to balloon page size. */ 80 /* Convert pfn from Linux page size to balloon page size. */
69 return pfn >> (PAGE_SHIFT - VIRTIO_BALLOON_PFN_SHIFT); 81 return pfn * VIRTIO_BALLOON_PAGES_PER_PAGE;
82}
83
84static struct page *balloon_pfn_to_page(u32 pfn)
85{
86 BUG_ON(pfn % VIRTIO_BALLOON_PAGES_PER_PAGE);
87 return pfn_to_page(pfn / VIRTIO_BALLOON_PAGES_PER_PAGE);
70} 88}
71 89
72static void balloon_ack(struct virtqueue *vq) 90static void balloon_ack(struct virtqueue *vq)
@@ -96,12 +114,23 @@ static void tell_host(struct virtio_balloon *vb, struct virtqueue *vq)
96 wait_for_completion(&vb->acked); 114 wait_for_completion(&vb->acked);
97} 115}
98 116
117static void set_page_pfns(u32 pfns[], struct page *page)
118{
119 unsigned int i;
120
121 /* Set balloon pfns pointing at this page.
122 * Note that the first pfn points at start of the page. */
123 for (i = 0; i < VIRTIO_BALLOON_PAGES_PER_PAGE; i++)
124 pfns[i] = page_to_balloon_pfn(page) + i;
125}
126
99static void fill_balloon(struct virtio_balloon *vb, size_t num) 127static void fill_balloon(struct virtio_balloon *vb, size_t num)
100{ 128{
101 /* We can only do one array worth at a time. */ 129 /* We can only do one array worth at a time. */
102 num = min(num, ARRAY_SIZE(vb->pfns)); 130 num = min(num, ARRAY_SIZE(vb->pfns));
103 131
104 for (vb->num_pfns = 0; vb->num_pfns < num; vb->num_pfns++) { 132 for (vb->num_pfns = 0; vb->num_pfns < num;
133 vb->num_pfns += VIRTIO_BALLOON_PAGES_PER_PAGE) {
105 struct page *page = alloc_page(GFP_HIGHUSER | __GFP_NORETRY | 134 struct page *page = alloc_page(GFP_HIGHUSER | __GFP_NORETRY |
106 __GFP_NOMEMALLOC | __GFP_NOWARN); 135 __GFP_NOMEMALLOC | __GFP_NOWARN);
107 if (!page) { 136 if (!page) {
@@ -113,9 +142,9 @@ static void fill_balloon(struct virtio_balloon *vb, size_t num)
113 msleep(200); 142 msleep(200);
114 break; 143 break;
115 } 144 }
116 vb->pfns[vb->num_pfns] = page_to_balloon_pfn(page); 145 set_page_pfns(vb->pfns + vb->num_pfns, page);
146 vb->num_pages += VIRTIO_BALLOON_PAGES_PER_PAGE;
117 totalram_pages--; 147 totalram_pages--;
118 vb->num_pages++;
119 list_add(&page->lru, &vb->pages); 148 list_add(&page->lru, &vb->pages);
120 } 149 }
121 150
@@ -130,8 +159,9 @@ static void release_pages_by_pfn(const u32 pfns[], unsigned int num)
130{ 159{
131 unsigned int i; 160 unsigned int i;
132 161
133 for (i = 0; i < num; i++) { 162 /* Find pfns pointing at start of each page, get pages and free them. */
134 __free_page(pfn_to_page(pfns[i])); 163 for (i = 0; i < num; i += VIRTIO_BALLOON_PAGES_PER_PAGE) {
164 __free_page(balloon_pfn_to_page(pfns[i]));
135 totalram_pages++; 165 totalram_pages++;
136 } 166 }
137} 167}
@@ -143,11 +173,12 @@ static void leak_balloon(struct virtio_balloon *vb, size_t num)
143 /* We can only do one array worth at a time. */ 173 /* We can only do one array worth at a time. */
144 num = min(num, ARRAY_SIZE(vb->pfns)); 174 num = min(num, ARRAY_SIZE(vb->pfns));
145 175
146 for (vb->num_pfns = 0; vb->num_pfns < num; vb->num_pfns++) { 176 for (vb->num_pfns = 0; vb->num_pfns < num;
177 vb->num_pfns += VIRTIO_BALLOON_PAGES_PER_PAGE) {
147 page = list_first_entry(&vb->pages, struct page, lru); 178 page = list_first_entry(&vb->pages, struct page, lru);
148 list_del(&page->lru); 179 list_del(&page->lru);
149 vb->pfns[vb->num_pfns] = page_to_balloon_pfn(page); 180 set_page_pfns(vb->pfns + vb->num_pfns, page);
150 vb->num_pages--; 181 vb->num_pages -= VIRTIO_BALLOON_PAGES_PER_PAGE;
151 } 182 }
152 183
153 /* 184 /*
@@ -234,11 +265,14 @@ static void virtballoon_changed(struct virtio_device *vdev)
234 265
235static inline s64 towards_target(struct virtio_balloon *vb) 266static inline s64 towards_target(struct virtio_balloon *vb)
236{ 267{
237 u32 v; 268 __le32 v;
269 s64 target;
270
238 vb->vdev->config->get(vb->vdev, 271 vb->vdev->config->get(vb->vdev,
239 offsetof(struct virtio_balloon_config, num_pages), 272 offsetof(struct virtio_balloon_config, num_pages),
240 &v, sizeof(v)); 273 &v, sizeof(v));
241 return (s64)v - vb->num_pages; 274 target = le32_to_cpu(v);
275 return target - vb->num_pages;
242} 276}
243 277
244static void update_balloon_size(struct virtio_balloon *vb) 278static void update_balloon_size(struct virtio_balloon *vb)
diff --git a/drivers/watchdog/hpwdt.c b/drivers/watchdog/hpwdt.c
index cbc7ceef2786..9f13b897fd64 100644
--- a/drivers/watchdog/hpwdt.c
+++ b/drivers/watchdog/hpwdt.c
@@ -435,16 +435,16 @@ static void hpwdt_start(void)
435{ 435{
436 reload = SECS_TO_TICKS(soft_margin); 436 reload = SECS_TO_TICKS(soft_margin);
437 iowrite16(reload, hpwdt_timer_reg); 437 iowrite16(reload, hpwdt_timer_reg);
438 iowrite16(0x85, hpwdt_timer_con); 438 iowrite8(0x85, hpwdt_timer_con);
439} 439}
440 440
441static void hpwdt_stop(void) 441static void hpwdt_stop(void)
442{ 442{
443 unsigned long data; 443 unsigned long data;
444 444
445 data = ioread16(hpwdt_timer_con); 445 data = ioread8(hpwdt_timer_con);
446 data &= 0xFE; 446 data &= 0xFE;
447 iowrite16(data, hpwdt_timer_con); 447 iowrite8(data, hpwdt_timer_con);
448} 448}
449 449
450static void hpwdt_ping(void) 450static void hpwdt_ping(void)
diff --git a/drivers/xen/events.c b/drivers/xen/events.c
index 4b33acd8ed4e..0a8a17cd80be 100644
--- a/drivers/xen/events.c
+++ b/drivers/xen/events.c
@@ -274,7 +274,7 @@ static unsigned int cpu_from_evtchn(unsigned int evtchn)
274 274
275static bool pirq_check_eoi_map(unsigned irq) 275static bool pirq_check_eoi_map(unsigned irq)
276{ 276{
277 return test_bit(irq, pirq_eoi_map); 277 return test_bit(pirq_from_irq(irq), pirq_eoi_map);
278} 278}
279 279
280static bool pirq_needs_eoi_flag(unsigned irq) 280static bool pirq_needs_eoi_flag(unsigned irq)
diff --git a/drivers/xen/gntdev.c b/drivers/xen/gntdev.c
index 99d8151c824a..1ffd03bf8e10 100644
--- a/drivers/xen/gntdev.c
+++ b/drivers/xen/gntdev.c
@@ -722,7 +722,7 @@ static int gntdev_mmap(struct file *flip, struct vm_area_struct *vma)
722 vma->vm_flags |= VM_RESERVED|VM_DONTEXPAND; 722 vma->vm_flags |= VM_RESERVED|VM_DONTEXPAND;
723 723
724 if (use_ptemod) 724 if (use_ptemod)
725 vma->vm_flags |= VM_DONTCOPY|VM_PFNMAP; 725 vma->vm_flags |= VM_DONTCOPY;
726 726
727 vma->vm_private_data = map; 727 vma->vm_private_data = map;
728 728
diff --git a/drivers/xen/grant-table.c b/drivers/xen/grant-table.c
index b4d4eac761db..f100ce20b16b 100644
--- a/drivers/xen/grant-table.c
+++ b/drivers/xen/grant-table.c
@@ -1029,6 +1029,7 @@ int gnttab_init(void)
1029 int i; 1029 int i;
1030 unsigned int max_nr_glist_frames, nr_glist_frames; 1030 unsigned int max_nr_glist_frames, nr_glist_frames;
1031 unsigned int nr_init_grefs; 1031 unsigned int nr_init_grefs;
1032 int ret;
1032 1033
1033 nr_grant_frames = 1; 1034 nr_grant_frames = 1;
1034 boot_max_nr_grant_frames = __max_nr_grant_frames(); 1035 boot_max_nr_grant_frames = __max_nr_grant_frames();
@@ -1047,12 +1048,16 @@ int gnttab_init(void)
1047 nr_glist_frames = (nr_grant_frames * GREFS_PER_GRANT_FRAME + RPP - 1) / RPP; 1048 nr_glist_frames = (nr_grant_frames * GREFS_PER_GRANT_FRAME + RPP - 1) / RPP;
1048 for (i = 0; i < nr_glist_frames; i++) { 1049 for (i = 0; i < nr_glist_frames; i++) {
1049 gnttab_list[i] = (grant_ref_t *)__get_free_page(GFP_KERNEL); 1050 gnttab_list[i] = (grant_ref_t *)__get_free_page(GFP_KERNEL);
1050 if (gnttab_list[i] == NULL) 1051 if (gnttab_list[i] == NULL) {
1052 ret = -ENOMEM;
1051 goto ini_nomem; 1053 goto ini_nomem;
1054 }
1052 } 1055 }
1053 1056
1054 if (gnttab_resume() < 0) 1057 if (gnttab_resume() < 0) {
1055 return -ENODEV; 1058 ret = -ENODEV;
1059 goto ini_nomem;
1060 }
1056 1061
1057 nr_init_grefs = nr_grant_frames * GREFS_PER_GRANT_FRAME; 1062 nr_init_grefs = nr_grant_frames * GREFS_PER_GRANT_FRAME;
1058 1063
@@ -1070,7 +1075,7 @@ int gnttab_init(void)
1070 for (i--; i >= 0; i--) 1075 for (i--; i >= 0; i--)
1071 free_page((unsigned long)gnttab_list[i]); 1076 free_page((unsigned long)gnttab_list[i]);
1072 kfree(gnttab_list); 1077 kfree(gnttab_list);
1073 return -ENOMEM; 1078 return ret;
1074} 1079}
1075EXPORT_SYMBOL_GPL(gnttab_init); 1080EXPORT_SYMBOL_GPL(gnttab_init);
1076 1081
diff --git a/drivers/xen/manage.c b/drivers/xen/manage.c
index 9e14ae6cd49c..412b96cc5305 100644
--- a/drivers/xen/manage.c
+++ b/drivers/xen/manage.c
@@ -132,6 +132,7 @@ static void do_suspend(void)
132 err = dpm_suspend_end(PMSG_FREEZE); 132 err = dpm_suspend_end(PMSG_FREEZE);
133 if (err) { 133 if (err) {
134 printk(KERN_ERR "dpm_suspend_end failed: %d\n", err); 134 printk(KERN_ERR "dpm_suspend_end failed: %d\n", err);
135 si.cancelled = 0;
135 goto out_resume; 136 goto out_resume;
136 } 137 }
137 138
diff --git a/drivers/xen/xen-acpi-processor.c b/drivers/xen/xen-acpi-processor.c
index 174b5653cd8a..0b48579a9cd6 100644
--- a/drivers/xen/xen-acpi-processor.c
+++ b/drivers/xen/xen-acpi-processor.c
@@ -128,7 +128,10 @@ static int push_cxx_to_hypervisor(struct acpi_processor *_pr)
128 pr_debug(" C%d: %s %d uS\n", 128 pr_debug(" C%d: %s %d uS\n",
129 cx->type, cx->desc, (u32)cx->latency); 129 cx->type, cx->desc, (u32)cx->latency);
130 } 130 }
131 } else 131 } else if (ret != -EINVAL)
132 /* EINVAL means the ACPI ID is incorrect - meaning the ACPI
133 * table is referencing a non-existing CPU - which can happen
134 * with broken ACPI tables. */
132 pr_err(DRV_NAME "(CX): Hypervisor error (%d) for ACPI CPU%u\n", 135 pr_err(DRV_NAME "(CX): Hypervisor error (%d) for ACPI CPU%u\n",
133 ret, _pr->acpi_id); 136 ret, _pr->acpi_id);
134 137
diff --git a/drivers/xen/xenbus/xenbus_probe_frontend.c b/drivers/xen/xenbus/xenbus_probe_frontend.c
index f20c5f178b40..a31b54d48839 100644
--- a/drivers/xen/xenbus/xenbus_probe_frontend.c
+++ b/drivers/xen/xenbus/xenbus_probe_frontend.c
@@ -135,7 +135,7 @@ static int read_backend_details(struct xenbus_device *xendev)
135 return xenbus_read_otherend_details(xendev, "backend-id", "backend"); 135 return xenbus_read_otherend_details(xendev, "backend-id", "backend");
136} 136}
137 137
138static int is_device_connecting(struct device *dev, void *data) 138static int is_device_connecting(struct device *dev, void *data, bool ignore_nonessential)
139{ 139{
140 struct xenbus_device *xendev = to_xenbus_device(dev); 140 struct xenbus_device *xendev = to_xenbus_device(dev);
141 struct device_driver *drv = data; 141 struct device_driver *drv = data;
@@ -152,16 +152,41 @@ static int is_device_connecting(struct device *dev, void *data)
152 if (drv && (dev->driver != drv)) 152 if (drv && (dev->driver != drv))
153 return 0; 153 return 0;
154 154
155 if (ignore_nonessential) {
156 /* With older QEMU, for PVonHVM guests the guest config files
157 * could contain: vfb = [ 'vnc=1, vnclisten=0.0.0.0']
158 * which is nonsensical as there is no PV FB (there can be
159 * a PVKB) running as HVM guest. */
160
161 if ((strncmp(xendev->nodename, "device/vkbd", 11) == 0))
162 return 0;
163
164 if ((strncmp(xendev->nodename, "device/vfb", 10) == 0))
165 return 0;
166 }
155 xendrv = to_xenbus_driver(dev->driver); 167 xendrv = to_xenbus_driver(dev->driver);
156 return (xendev->state < XenbusStateConnected || 168 return (xendev->state < XenbusStateConnected ||
157 (xendev->state == XenbusStateConnected && 169 (xendev->state == XenbusStateConnected &&
158 xendrv->is_ready && !xendrv->is_ready(xendev))); 170 xendrv->is_ready && !xendrv->is_ready(xendev)));
159} 171}
172static int essential_device_connecting(struct device *dev, void *data)
173{
174 return is_device_connecting(dev, data, true /* ignore PV[KBB+FB] */);
175}
176static int non_essential_device_connecting(struct device *dev, void *data)
177{
178 return is_device_connecting(dev, data, false);
179}
160 180
161static int exists_connecting_device(struct device_driver *drv) 181static int exists_essential_connecting_device(struct device_driver *drv)
162{ 182{
163 return bus_for_each_dev(&xenbus_frontend.bus, NULL, drv, 183 return bus_for_each_dev(&xenbus_frontend.bus, NULL, drv,
164 is_device_connecting); 184 essential_device_connecting);
185}
186static int exists_non_essential_connecting_device(struct device_driver *drv)
187{
188 return bus_for_each_dev(&xenbus_frontend.bus, NULL, drv,
189 non_essential_device_connecting);
165} 190}
166 191
167static int print_device_status(struct device *dev, void *data) 192static int print_device_status(struct device *dev, void *data)
@@ -192,6 +217,23 @@ static int print_device_status(struct device *dev, void *data)
192/* We only wait for device setup after most initcalls have run. */ 217/* We only wait for device setup after most initcalls have run. */
193static int ready_to_wait_for_devices; 218static int ready_to_wait_for_devices;
194 219
220static bool wait_loop(unsigned long start, unsigned int max_delay,
221 unsigned int *seconds_waited)
222{
223 if (time_after(jiffies, start + (*seconds_waited+5)*HZ)) {
224 if (!*seconds_waited)
225 printk(KERN_WARNING "XENBUS: Waiting for "
226 "devices to initialise: ");
227 *seconds_waited += 5;
228 printk("%us...", max_delay - *seconds_waited);
229 if (*seconds_waited == max_delay)
230 return true;
231 }
232
233 schedule_timeout_interruptible(HZ/10);
234
235 return false;
236}
195/* 237/*
196 * On a 5-minute timeout, wait for all devices currently configured. We need 238 * On a 5-minute timeout, wait for all devices currently configured. We need
197 * to do this to guarantee that the filesystems and / or network devices 239 * to do this to guarantee that the filesystems and / or network devices
@@ -215,19 +257,14 @@ static void wait_for_devices(struct xenbus_driver *xendrv)
215 if (!ready_to_wait_for_devices || !xen_domain()) 257 if (!ready_to_wait_for_devices || !xen_domain())
216 return; 258 return;
217 259
218 while (exists_connecting_device(drv)) { 260 while (exists_non_essential_connecting_device(drv))
219 if (time_after(jiffies, start + (seconds_waited+5)*HZ)) { 261 if (wait_loop(start, 30, &seconds_waited))
220 if (!seconds_waited) 262 break;
221 printk(KERN_WARNING "XENBUS: Waiting for " 263
222 "devices to initialise: "); 264 /* Skips PVKB and PVFB check.*/
223 seconds_waited += 5; 265 while (exists_essential_connecting_device(drv))
224 printk("%us...", 300 - seconds_waited); 266 if (wait_loop(start, 270, &seconds_waited))
225 if (seconds_waited == 300) 267 break;
226 break;
227 }
228
229 schedule_timeout_interruptible(HZ/10);
230 }
231 268
232 if (seconds_waited) 269 if (seconds_waited)
233 printk("\n"); 270 printk("\n");